Document the codebase thoroughly and tighten type safety

Docs: per-folder README.md for packages/ (family overview + one per
package: service, events, API, extension points, TODOs), examples/,
and examples/echo-agent/; folder-level AGENTS.md (+ CLAUDE.md
symlinks) for packages/ and vendor/; module-level doc comments in
every packages/*/src file; richer JSDoc on all exported API
(event side effects, disposal contracts, error behavior). Root
AGENTS.md gains a "Type Safety and Documentation" policy section:
the codebase aims to be very type-safe and well documented; type
gymnastics are acceptable in core packages when they improve
plugin-author DX; verbose docs are fine as long as they stay strictly
in sync with the code.

Type safety: removed the upstream-inherited "noImplicitAny": false
from tsconfig.base.json — packages/* now compile under full strict
mode; vendor/loader and vendor/include set it locally (vendor/cordis
already did). Eliminated every `: any` / `as any` from packages and
examples (catch clauses use unknown + a CodedError narrowing type;
event data access uses discriminated-union narrowing).

Typed tool schemas: new @deepseek-ai/dsh-tools schema DSL —
SchemaSpec with per-property `required: true` booleans, type-level
InferArgs<S>, a runtime SchemaSpec → JSON Schema converter, and
defineTool() so first-party tools get typed execute(args) with zero
casts (raw JSON Schema still accepted for MCP interop; chosen over
schemastery because it targets JSON Schema generation directly).
echo-tool and all test tools migrated; +7 tests.
This commit is contained in:
Tianyi Cui
2026-06-11 12:39:27 +08:00
parent 217b8ec0e2
commit 7f024a1a9d
35 changed files with 1274 additions and 101 deletions

13
vendor/AGENTS.md vendored Normal file
View File

@@ -0,0 +1,13 @@
# AGENTS.md — Vendored Packages
This directory contains source-vendored copies of the Cordis framework and its
foundation libraries. See `vendor/README.md` for the manifest, local-modification
log, and the upstream sync procedure.
**Do NOT edit `vendor/*/src/` files casually.** Every local divergence from
upstream must be logged exhaustively in `vendor/README.md` under "Local
modifications." The `vendor/*/tsconfig.json` files are the exception —
regenerated to fit the monorepo build, and they may be touched for type-checking
policy changes (e.g., `noImplicitAny`).
When changes are unavoidable, follow the sync procedure in `vendor/README.md`.

1
vendor/CLAUDE.md vendored Symbolic link
View File

@@ -0,0 +1 @@
AGENTS.md

View File

@@ -2,7 +2,8 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
"outDir": "lib",
"noImplicitAny": false
},
"include": ["src"],
"references": [

View File

@@ -2,7 +2,8 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
"outDir": "lib",
"noImplicitAny": false
},
"include": ["src"],
"references": [