Smithy command-line application
moonx moonrockz/smithy-cli@latest --help
moonx moonrockz/smithy-cli@latest versionmise use -g github:moonrockz/smithy
smithy versionmoon build apps/smithy --target native --release
_build/native/release/build/moonrockz/smithy-cli/smithy-cli.exe versionsmithy ast model.smithy extra.json
smithy validate model.smithy extra.json
smithy validate --protocol-tests examples/protocol-tests/greeting.smithy
smithy validate value --shape example#Input --value request.json model.smithy
smithy validate rpc --version 2.0 --service example#Calculator --message call.json api.smithy
smithy diff --old previous/ --new current/
smithy build --config smithy-build.json
smithy clean --config smithy-build.json
smithy select --selector 'structure > member > string' model.smithy
smithy convert --to json model.smithy -o model.json
smithy convert --to idl model.json -o model.smithy
smithy convert --to idl one.json two.json --output-dir generated
smithy format model.smithy
smithy format --check model.smithy model.json
smithy format --write model.smithy model.jsonsmithy diff --old previous/ --new current/ --format jsonl
smithy diff --old previous/ --new current/ --format=jsonl --output changes.jsonl{"id":"ChangedMemberTarget","severity":"ERROR","shape":"example#Value$name","message":"The event message","source":{"file":"current/model.smithy","path":"","span":{"start":42,"length":12}}}| Field | Value |
|---|---|
| id | Event identifier string |
| severity | NOTE, WARNING, DANGER or ERROR |
| shape | Absolute shape ID string, or null for a model-level event |
| message | Complete message string; JSON decoding restores newlines and other escaped characters |
| source | null, or an object containing file, path and span |
| source.file | Physical source identifier, including archive entry paths when present |
| source.path | JSON Pointer for JSON AST input, otherwise usually an empty string |
| source.span | null, or nonnegative integer start and length in zero-based UTF-16 code units |
set -o pipefail
smithy diff --old previous/ --new current/ --format jsonl |
jq --unbuffered -c 'select(.severity == "ERROR" or .severity == "DANGER")'moon run apps/smithy -- build --config examples/openrpc/smithy-build.jsonmise exec -- moon run apps/smithy --target js -- build --config examples/local-resources/smithy-build.jsoncat model.smithy | smithy convert --from idl --to json -{"path":"module.zip","root":"models","paths":["service.smithy"],"globs":["shared/**/*.json"]}{"path":"downloaded-package.tgz","root":"package/models","globs":["**/*.smithy","**/*.json"]}mise exec -- moon run apps/smithy --target js -- build --config examples/npm-archive/smithy-build.json{"url":"https://example.org/models.zip","format":"zip","root":"models","globs":["**/*.smithy"]}mise exec -- moon run apps/smithy --target js -- build --config examples/public-archive/smithy-build.json$version: "2"
namespace example
@range(min: 1, max: 100)
integer Count
structure Input {
@required
count: Count
}smithy validate value --shape example#Input --value request.json model.smithy
smithy validate value --shape example#Input --value request.json --diagnostics json model.smithysmithy validate value --shape example#Input --value request.ion --input-format ion-text model.smithy
smithy validate value --shape example#Input --value request.10n --input-format ion-binary --diagnostics json model.smithysmithy validate rpc --version 2.0 --service example#Calculator --message call.json api.smithy
smithy validate rpc --version 2.0 --service example#Calculator --message invalid.json --diagnostics json api.smithy
smithy validate rpc --version 2.0 --service example#Calculator --response reply.json --method subtract api.smithy
smithy validate rpc --version 2.0 --service example#Calculator --response reply.json --request call.json --diagnostics json api.smithysmithy validate rpc transcript --protocol example.peers#Editor \
examples/json-rpc/peers.smithy examples/json-rpc/transcripts/editor.json
smithy validate rpc transcript --protocol example.peers#Editor --complete --diagnostics json \
examples/json-rpc/peers.smithy examples/json-rpc/transcripts/editor-negative.json
smithy validate rpc transcript --protocol batch#Link \
examples/json-rpc/batches.smithy examples/json-rpc/transcripts/batches.json
smithy validate rpc transcript --protocol example.lifecycle#Lifecycle \
examples/json-rpc/lifecycle.smithy examples/json-rpc/transcripts/lifecycle-violation.json
smithy validate rpc transcript --protocol example.peers#Editor --version 2.0 \
--direction in=client --direction out=server \
examples/json-rpc/peers.smithy examples/json-rpc/transcripts/editor.jsonl
smithy validate rpc transcript --protocol example.peers#Editor --version 2.0 \
--log-mapping examples/json-rpc/transcripts/mcp-like.mapping.json \
examples/json-rpc/peers.smithy examples/json-rpc/transcripts/mcp-like.jsonl
# my-server is any process that logs dir-message records to stderr.
my-server --stdio 2>&1 >/dev/null | smithy validate rpc transcript --protocol example.peers#Editor \
--version 2.0 --diagnostics json examples/json-rpc/peers.smithy -{
"version": "2.0",
"sources": [{
"github": {
"repository": "owner/models",
"tag": "v1.2.3",
"asset": "models.zip"
},
"format": "zip",
"root": "models",
"globs": ["**/*.smithy"]
}]
}{
"version": "2.0",
"sources": [{
"npm": { "package": "@scope/models", "version": "1.2.3" },
"root": "package/models",
"globs": ["**/*.smithy"]
}],
"imports": [{
"maven": {
"group": "org.example",
"artifact": "model-traits",
"version": "1.2.3"
}
}]
}mise exec -- moon run apps/smithy --target js -- build --config examples/npm-registry/smithy-build.json
mise exec -- moon run apps/smithy --target js -- build --config examples/maven-repository/smithy-build.json{
"version": "2.0",
"credentials": [
{ "origin": "https://api.github.com", "bearerTokenEnv": "GITHUB_TOKEN" },
{ "origin": "https://registry.npmjs.org", "bearerTokenEnv": "NPM_TOKEN" },
{ "origin": "https://maven.example.com", "usernameEnv": "MAVEN_USER", "passwordEnv": "MAVEN_PASSWORD" }
]
}type InputSourcetype Layouttype OutputSink