5.8 KiB
5.8 KiB
Schema Contract / Schema 契约
dws schema uses progressive disclosure over the current runnable command surface. Product and group queries are compact browse responses; tool queries use a GWS-style flat leaf contract.
Progressive Queries
dws schema # product overview only
dws schema list # compatibility alias for the product overview
dws schema calendar # tools in one product
dws schema calendar.event # tools in one CLI group
dws schema calendar.create_calendar_event # one complete tool schema
dws schema --all # complete catalog for audit/CI
- The default response has
level: "products", producttool_count, and no embedded tool arrays. - A product response has
level: "product"and includes that product's tool summaries. - A group response has
level: "group"and includes only matching descendant tools. - A tool response remains a flat leaf object for compatibility.
--allpreserves the complete product/tool catalog and is intentionally larger.
Source Of Truth
- Runtime/dynamic products: schema metadata attached to actual Cobra leaf commands.
- Hardcoded helper products: registered runtime schema roots plus curated hints.
- Helper tools, including
dev app, derive schema from their real Cobra flags and versioned metadata; schema queries never call MCPtools/list. - Visible local helper leaves, such as
dev connect status, use ahardcoded:<product>source. - Sanitized CLI/MCP descriptions and parameter facts are snapshotted into
internal/cli/schema_mcp_metadata.json; endpoints, credentials, and cache timestamps are never embedded. - Agent affordances are generated from the versioned Skill files into the product-domain files in
internal/cli/schema_agent_metadata/and embedded in the binary.index.jsoncarries the routing and coverage summary; each product JSON carries only that product's tool metadata. Their paths are reconciled against the versioned, endpoint-freeinternal/cli/schema_command_surface.jsonsnapshot.
Agent Metadata
- Product overview:
use_when,avoid_when, aninterface_metadatasnapshot summary, and anagent_metadataversion/hash summary. - Tool summaries:
use_when,avoid_when,effect,risk, andconfirmationwhen known. - Tool detail: summary fields plus
examples,effect_source, andagent_source_refs. - Skill-derived JSON is deterministic and checked by
scripts/policy/check-generated-drift.sh. Refresh the command-surface snapshot withmake generate-schema-command-surface, then runmake generate-schema-agent-metadata. - Refresh interface metadata explicitly with
make generate-schema-interface-metadata SCHEMA_REGISTRY=/path/to/servers.json; release builds embed the committed snapshot and never perform runtimetools/listdiscovery.
Path Rules
dws schema # compact product overview
dws schema list # compatibility alias for the compact root overview
dws schema calendar # list one product's tools
dws schema calendar.event # list one command group's tools
dws schema --all # full catalog
dws schema ding.send_ding_message # canonical path: product.rpc_name
dws schema ding.message.send # dotted CLI path
dws schema "ding message send" # space CLI path
dws schema --cli-path "ding message send" # explicit CLI-path flag
canonical_pathis stable and usesproduct.rpc_name.cli_pathis the executable CLI path.- If multiple CLI paths map to one canonical tool, the list shows only
primary_cli_path; other paths appear inaliases. - Querying an alias path is valid and returns the same
canonical_pathwithis_alias: true.
Leaf Shape
{
"name": "query_records",
"canonical_path": "aitable.query_records",
"path": "aitable.query_records",
"cli_path": "aitable record query",
"primary_cli_path": "aitable record query",
"aliases": ["aitable record list"],
"is_alias": false,
"source": "hardcoded:aitable",
"product_id": "aitable",
"parameters": {
"base-id": {
"property": "baseId",
"type": "string",
"description": "Base ID。",
"required": true
}
},
"has_parameters": true,
"parameter_count": 1
}
Parameters
parametersis always present.- Parameter keys are real CLI flag names, without the
--prefix. propertyis the field sent to the MCP/API tool.requiredis inline on each parameter and means unconditionally required.required_whenis present only for a conditional requirement; it explains the flag dependency without incorrectly marking the parameter globally required.defaultis present only when there is an explicit useful default.- No-parameter tools use
parameters: {},has_parameters: false, andparameter_count: 0.
Alignment With Lark/GWS
- Like GWS, DWS emits a flat leaf object and keeps
parameters: {}for no-argument tools. - Like Lark, canonical lookup must be stable and duplicate command paths are made explicit instead of silently picking one.
- Unlike Lark, DWS does not wrap leaf output in an MCP
inputSchemaenvelope because agents primarily need executable CLI flags. - Unlike GWS, DWS includes visible hardcoded helper commands in the same flat schema shape.
Validation Invariants
.products[].tools[].canonical_pathis unique in the list output.- The compact root's
tool_countequals the number of primary tools in--all. - Every listed tool has
canonical_pathandcli_path. - Every leaf output has
parameters,has_parameters, andparameter_count. parameter_countequals the number of keys underparameters.- Hidden commands are excluded; visible local helper commands remain queryable with a
hardcoded:<product>source.