4.8 KiB
4.8 KiB
Architecture
dws is a Go CLI with a versioned, static command surface for DingTalk MCP capabilities. Cobra help serves humans; the embedded Command Catalog serves AI agents.
High-Level Flow
cmdis the CLI entrypoint, invokinginternal/appto build the root Cobra command tree.internal/appwires static utility commands (auth,audit,schema,completion), product helpers, and versioned plugin descriptors.internal/helperscontains the main command handlers for all product surfaces (dev,chat,calendar,contact,aitable, etc.).internal/executorandinternal/transportexecute MCP JSON-RPC calls;internal/outputformats responses.internal/authmanages login state, PAT tokens, and agent-code detection.- Schema generation starts from the reviewed
CommandRegistry, binds each identity to the exact current Cobra leaf, and then resolves typed constraints, sanitized MCP snapshots, Agent hints, and Skills into oneSchemaRegistry. Startup and Schema queries do not call MCPtools/list. - The embedded Catalog is a downstream release artifact and never backfills identity or participates in regeneration. Stable flag-to-interface property bindings come from the reviewed, content-addressed v3 manifest in
schema_parameter_bindings.json; its exact active tuples, corrections, removals, and mapping exclusions are validated against the final boundSchemaRegistry. CLIrequiredand constraints come from the resolved typed contract, while MCPrequiredremains interface-only metadata. - Agent selection results are fixed in versioned review inputs. Every public tool has explicit use/avoid/example and interface disposition metadata; Skill references that are not current leaves require an explicit alias/group/stale/out-of-surface review instead of fuzzy runtime matching.
Repository Structure
cmd: CLI entrypointinternal/app: root command wiring, static utility commands, and plugin loadinginternal/helpers: product command handlers (dev, chat, calendar, contact, etc.)internal/plugin: versioned plugin manifest, hook, skill, and transport descriptor loadinginternal/cli: embedded Agent Command Catalog, static schema query, and catalog contractsinternal/generator: deterministic Agent metadata and Command Catalog generatorsinternal/executor: invocation dispatch and result handlinginternal/transport: MCP HTTP client and request signinginternal/auth: login, token management, agent-code detection, identityinternal/audit: user operation audit log (JSONL, hash chain, forwarding)internal/errors: structured error model with categories and hintsinternal/keychain: OS keychain integration for credential storageinternal/security: endpoint allowlist and domain trustinternal/safety: runtime safety checks (confirm prompts, dry-run guards)internal/cobracmd: shared Cobra command buildersinternal/pat: PAT (Personal Access Token) authorization flowinternal/output: response formatting (json, table, raw, pretty)internal/logging: structured logging and argument sanitizationinternal/tui: terminal UI helpersinternal/recovery: panic recovery and graceful degradationpkg/configmeta: environment variable registry and documentationpkg/config: configuration constants and pathspkg/edition: edition detection (oss vs enterprise)pkg/mcptypes: MCP protocol type definitionsinternal/syncdata: generated static endpoint and command-routing data synced from the Wukong baselineskills/: bundled agent skills (mono/ and multi/ layouts)test/: CLI, integration, contract, unit, and skill E2E testsscripts/: install scripts, policy checks, and CI helpers
Quality Pipeline
Quality enforcement is layered so a pull request receives fast, deterministic admission feedback without pretending that downstream integration has already run.
flowchart TB
PR["Pull request"] --> CA["CI"]
subgraph CA_CHECKS["Nine required contexts"]
L["Lint"]
T["Test"]
C["Coverage"]
P["Policy"]
E["Edition"]
I["Interface Integrity"]
A["AI Behavior"]
S["CLI Smoke"]
M["Mock MCP"]
end
CA --> CA_CHECKS
CA_CHECKS --> MAIN["Protected main"]
MAIN --> MP["Main Integration — 主干集成<br/>Multi-profile E2E"]
MAIN --> PLATFORM["Risk-selected / release native platform validation"]
MP --> RELEASE["Release delivery"]
PLATFORM --> RELEASE
Complete Multi-profile E2E and the ordinary full native-platform matrix are
downstream of PR admission. PRs still run primary-environment assurance and
fast cross-platform compilation; auth, keychain, OS-specific, installer, and
release changes additionally select native platform tests before merge. See
docs/ci-pr-gates.md for the exact context and ruleset
contract.