2026-06-14 00:47:38 +08:00
|
|
|
/**
|
2026-06-18 02:18:24 +08:00
|
|
|
* Doc-sync gate (doc-sync-enforcement RFC, part 1): typecheck the fenced `ts` code blocks in our
|
2026-06-14 00:47:38 +08:00
|
|
|
* Markdown so documentation can't drift from the API it documents.
|
|
|
|
|
*
|
|
|
|
|
* Every ```ts block in README.md, docs/** and packages/* /README.md is
|
2026-06-17 23:41:18 +08:00
|
|
|
* extracted to a temp typecheck project and compiled against the workspace
|
|
|
|
|
* sources through the same project-reference boundaries used by repo
|
|
|
|
|
* typecheck. A block that is a deliberate sketch rather than compilable code
|
|
|
|
|
* opts out with an explicit ` ```ts ignore-check ` info string — the opt-out
|
|
|
|
|
* is visible in the source, and this script reports the ratio so the escape
|
2026-06-22 00:35:51 +08:00
|
|
|
* hatch can't quietly become the norm. A third info string,
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
* doc-typecheck.ts recognizes four more fence variants and skips all four (each
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
* is a separately-checked category, not an unchecked sketch, so none counts in
|
|
|
|
|
* the opt-out ratio): ` ```ts type-equiv ` is a verbatim source-type paste that
|
|
|
|
|
* `scripts/verify-type-equiv.ts` drift-checks, ` ```ts cordis-catalog ` is a
|
2026-06-20 19:47:09 +08:00
|
|
|
* generated event/service signature fragment in the cordis catalog (a bare
|
|
|
|
|
* signature is not standalone-compilable; the catalog is generated and frozen by
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
* `scripts/gen-cordis-catalog.ts` + its `--check` freshness gate),
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
* ` ```ts persistence-catalog ` is a generated log-event payload fragment in the
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
* persistence catalog (same reasoning, frozen by `scripts/gen-persistence-catalog.ts`),
|
|
|
|
|
* and ` ```ts config-catalog ` is a generated verbatim config declaration in the
|
|
|
|
|
* plugin config catalog (same reasoning, frozen by `scripts/gen-config-catalog.ts`).
|
2026-06-14 00:47:38 +08:00
|
|
|
*
|
|
|
|
|
* Run: `tsx scripts/doc-typecheck.ts`.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { execFileSync } from 'node:child_process'
|
2026-07-06 12:16:31 +08:00
|
|
|
import { globSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
2026-06-14 00:47:38 +08:00
|
|
|
import { join, relative, resolve } from 'node:path'
|
Reorganize packages into a modular hierarchy
Move the 18 flat packages/<name> packages into role-grouped dirs:
core/, llm/, bash/, session-persistence/, ui/, support/. Group dirs are
pure containers; each package keeps its @deepseek-ai/dsh-* name.
Collapse the per-package tsconfig paths maps (base + typecheck) into one
@deepseek-ai/dsh-* wildcard with a candidate per group, and derive the
publint list from the hierarchy. Update all depth-coupled globs/configs
(workspace, tsdown, vitest, eslint, knip, tsconfig includes/refs,
per-package tsconfigs, generators, doc-script scopes, type-equiv manifest)
and the cross-package/script relative imports in tests.
Fix doc-typecheck's workspacePaths() to parse tsconfig JSONC via the
TypeScript API instead of a regex comment-strip, which corrupted the
new wildcard `/*/` path candidates.
WIP: doc cross-links and package/RFC docs still to update.
2026-06-20 22:55:20 +08:00
|
|
|
import ts from 'typescript'
|
2026-06-14 00:47:38 +08:00
|
|
|
|
|
|
|
|
const root = resolve(import.meta.dirname, '..')
|
|
|
|
|
|
2026-06-20 16:24:37 +08:00
|
|
|
/**
|
|
|
|
|
* How a fenced block participates in this gate:
|
|
|
|
|
* - `check` (` ```ts `) — compiled.
|
|
|
|
|
* - `ignore` (` ```ts ignore-check `) — a deliberate sketch; skipped, and
|
|
|
|
|
* counted in the opt-out ratio so the escape hatch can't quietly take over.
|
|
|
|
|
* - `type-equiv` (` ```ts type-equiv `) — a verbatim paste of a source type
|
|
|
|
|
* definition, drift-checked by `scripts/verify-type-equiv.ts` against the
|
|
|
|
|
* source symbol. Skipped HERE (it is not standalone-compilable — no imports)
|
|
|
|
|
* and EXCLUDED from the opt-out ratio: it is a separate fully-checked
|
|
|
|
|
* category, not an unchecked sketch.
|
2026-06-20 19:47:09 +08:00
|
|
|
* - `cordis-catalog` (` ```ts cordis-catalog `) — a generated event/service
|
|
|
|
|
* signature fragment in the cordis catalog. Skipped HERE for the same reason
|
|
|
|
|
* (a bare signature fragment has no imports and does not stand alone) and
|
|
|
|
|
* EXCLUDED from the opt-out ratio: the catalog is generated and frozen by
|
|
|
|
|
* `scripts/gen-cordis-catalog.ts` + its `--check` freshness gate.
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
* - `persistence-catalog` (` ```ts persistence-catalog `) — a generated
|
|
|
|
|
* log-event payload fragment in the persistence catalog. Same treatment for
|
|
|
|
|
* the same reason; frozen by `scripts/gen-persistence-catalog.ts` + its
|
|
|
|
|
* `--check` freshness gate.
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
* - `config-catalog` (` ```ts config-catalog `) — a generated verbatim config
|
|
|
|
|
* declaration in the plugin config catalog (a lone declaration referencing
|
|
|
|
|
* imported types does not stand alone). Same treatment for the same reason;
|
|
|
|
|
* frozen by `scripts/gen-config-catalog.ts` + its `--check` freshness gate.
|
2026-06-20 16:24:37 +08:00
|
|
|
*/
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
type BlockKind = 'check' | 'ignore' | 'type-equiv' | 'cordis-catalog' | 'persistence-catalog' | 'config-catalog'
|
2026-06-20 16:24:37 +08:00
|
|
|
|
2026-06-14 00:47:38 +08:00
|
|
|
/** One extracted code block. */
|
|
|
|
|
interface Block {
|
|
|
|
|
file: string
|
|
|
|
|
/** 1-based line of the opening fence. */
|
|
|
|
|
line: number
|
2026-06-20 16:24:37 +08:00
|
|
|
kind: BlockKind
|
2026-06-14 00:47:38 +08:00
|
|
|
code: string
|
|
|
|
|
}
|
|
|
|
|
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
/** Extract every ts / ts ignore-check / ts type-equiv / ts cordis-catalog /
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
* ts persistence-catalog / ts config-catalog block from one Markdown file. */
|
2026-06-14 00:47:38 +08:00
|
|
|
function extractBlocks(absPath: string): Block[] {
|
|
|
|
|
const text = readFileSync(absPath, 'utf8')
|
|
|
|
|
const lines = text.split('\n')
|
|
|
|
|
const file = relative(root, absPath)
|
|
|
|
|
const blocks: Block[] = []
|
2026-06-20 16:24:37 +08:00
|
|
|
let open: { line: number; kind: BlockKind; body: string[] } | null = null
|
2026-06-14 00:47:38 +08:00
|
|
|
|
|
|
|
|
lines.forEach((raw, i) => {
|
|
|
|
|
const fence = /^```(\s*)(\S.*)?$/.exec(raw)
|
|
|
|
|
if (!fence) {
|
|
|
|
|
if (open) open.body.push(raw)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (open) {
|
|
|
|
|
// closing fence
|
2026-06-20 16:24:37 +08:00
|
|
|
blocks.push({ file, line: open.line, kind: open.kind, code: open.body.join('\n') })
|
2026-06-14 00:47:38 +08:00
|
|
|
open = null
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// opening fence — only care about ts blocks
|
|
|
|
|
const info = (fence[2] ?? '').trim()
|
2026-06-20 16:24:37 +08:00
|
|
|
const kind: BlockKind | null =
|
|
|
|
|
info === 'ts' ? 'check'
|
|
|
|
|
: info === 'ts ignore-check' ? 'ignore'
|
|
|
|
|
: info === 'ts type-equiv' ? 'type-equiv'
|
2026-06-20 19:47:09 +08:00
|
|
|
: info === 'ts cordis-catalog' ? 'cordis-catalog'
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
: info === 'ts persistence-catalog' ? 'persistence-catalog'
|
feat: generated plugin config catalog (docs/config-catalog.md)
scripts/gen-config-catalog.ts walks every packages/<group>/<pkg> entry with
the TypeScript compiler API and emits docs/config-catalog.md: per loadable
plugin, the verbatim config declaration (JSDoc included) its apply/constructor
receives in a ts config-catalog fence, the inject requirements, resolved links
for every referenced type (package-local types pasted transitively, other
plugins' config types as intra-page anchors, LINK_MAP names to
core-data-structures, workspace types to source), and terse classification
lists for config-free plugins, abstract seams, and libraries — classification
is total, so a new package cannot go undocumented.
The walk enforces per-field JSDoc prose on every pasted declaration and
statically cross-checks the schemastery schema (z.object keys, z.intersect
composition across packages): every schema-validated key must be a declared
member of the config type. One violation existed repo-wide — the agents[].id
field in dsh-agent-loop — fixed by adding its JSDoc (which shifts the
cordis-catalog services page's source pointers; regenerated).
verify-config-catalog (--check) joins doc-sync; doc-typecheck learns the
ts config-catalog fence; gen-cordis-catalog exports its JSDoc/pointer helpers
and LINK_MAP for reuse. Negative-path spec in
packages/core/agent-core/tests/gen-config-catalog.spec.ts mirrors the
gen-cordis-catalog spec. Decision record:
docs/rfc/implemented/process/2026-07-06-generated-config-catalog.md (includes
the deliberate acceptance of README ## Config overlap).
2026-07-06 21:57:17 +08:00
|
|
|
: info === 'ts config-catalog' ? 'config-catalog'
|
|
|
|
|
: null
|
2026-06-20 16:24:37 +08:00
|
|
|
if (kind) open = { line: i + 1, kind, body: [] }
|
2026-06-14 00:47:38 +08:00
|
|
|
})
|
|
|
|
|
return blocks
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 23:41:18 +08:00
|
|
|
/** Reuse the repo typecheck graph references from a temp project one directory below root. */
|
|
|
|
|
function workspaceReferences(): { path: string }[] {
|
2026-06-22 00:35:51 +08:00
|
|
|
const file = join(root, 'tsconfig.json')
|
Reorganize packages into a modular hierarchy
Move the 18 flat packages/<name> packages into role-grouped dirs:
core/, llm/, bash/, session-persistence/, ui/, support/. Group dirs are
pure containers; each package keeps its @deepseek-ai/dsh-* name.
Collapse the per-package tsconfig paths maps (base + typecheck) into one
@deepseek-ai/dsh-* wildcard with a candidate per group, and derive the
publint list from the hierarchy. Update all depth-coupled globs/configs
(workspace, tsdown, vitest, eslint, knip, tsconfig includes/refs,
per-package tsconfigs, generators, doc-script scopes, type-equiv manifest)
and the cross-package/script relative imports in tests.
Fix doc-typecheck's workspacePaths() to parse tsconfig JSONC via the
TypeScript API instead of a regex comment-strip, which corrupted the
new wildcard `/*/` path candidates.
WIP: doc cross-links and package/RFC docs still to update.
2026-06-20 22:55:20 +08:00
|
|
|
// Parse with TypeScript's own JSONC reader, not a hand-rolled comment strip:
|
|
|
|
|
// a regex strip mistakes the `/*/` in a wildcard path candidate
|
|
|
|
|
// (`./packages/core/*/src`) for a block comment and corrupts the map.
|
|
|
|
|
const result = ts.readConfigFile(file, p => readFileSync(p, 'utf8'))
|
|
|
|
|
if (result.error) {
|
|
|
|
|
throw new Error(`doc-typecheck: cannot read ${file}: ${ts.flattenDiagnosticMessageText(result.error.messageText, '\n')}`)
|
|
|
|
|
}
|
|
|
|
|
// `config` is typed `any` by the TS API; narrow it to the one field we read.
|
2026-06-22 00:35:51 +08:00
|
|
|
const { references } = result.config as { compilerOptions: { paths: Record<string, string[]> }; references: { path: string }[] }
|
2026-06-17 23:41:18 +08:00
|
|
|
return references.map(({ path }) => {
|
|
|
|
|
const relativeToTemp = path.startsWith('./') ? `../${path.slice(2)}` : `../${path}`
|
|
|
|
|
return { path: relativeToTemp }
|
|
|
|
|
})
|
2026-06-14 00:47:38 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-17 23:41:18 +08:00
|
|
|
/** The standalone tsconfig for the temp typecheck project. */
|
2026-06-14 00:47:38 +08:00
|
|
|
function tempTsconfig(): string {
|
|
|
|
|
return JSON.stringify({
|
2026-06-17 23:41:18 +08:00
|
|
|
extends: '../tsconfig.json',
|
2026-06-14 00:47:38 +08:00
|
|
|
compilerOptions: {
|
2026-06-17 23:41:18 +08:00
|
|
|
noUnusedLocals: false,
|
|
|
|
|
noUnusedParameters: false,
|
|
|
|
|
tsBuildInfoFile: './tsconfig.tsbuildinfo',
|
2026-06-14 00:47:38 +08:00
|
|
|
},
|
2026-06-17 23:41:18 +08:00
|
|
|
include: ['block-*.ts'],
|
|
|
|
|
references: workspaceReferences(),
|
2026-06-14 00:47:38 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
Reorganize packages into a modular hierarchy
Move the 18 flat packages/<name> packages into role-grouped dirs:
core/, llm/, bash/, session-persistence/, ui/, support/. Group dirs are
pure containers; each package keeps its @deepseek-ai/dsh-* name.
Collapse the per-package tsconfig paths maps (base + typecheck) into one
@deepseek-ai/dsh-* wildcard with a candidate per group, and derive the
publint list from the hierarchy. Update all depth-coupled globs/configs
(workspace, tsdown, vitest, eslint, knip, tsconfig includes/refs,
per-package tsconfigs, generators, doc-script scopes, type-equiv manifest)
and the cross-package/script relative imports in tests.
Fix doc-typecheck's workspacePaths() to parse tsconfig JSONC via the
TypeScript API instead of a regex comment-strip, which corrupted the
new wildcard `/*/` path candidates.
WIP: doc cross-links and package/RFC docs still to update.
2026-06-20 22:55:20 +08:00
|
|
|
const markdownGlobs = ['README.md', 'docs/**/*.md', 'packages/*/*.md', 'packages/*/*/*.md']
|
2026-06-14 00:47:38 +08:00
|
|
|
|
|
|
|
|
const files: string[] = []
|
|
|
|
|
for (const pattern of markdownGlobs) {
|
2026-07-06 12:16:31 +08:00
|
|
|
for (const match of globSync(pattern, { cwd: root })) files.push(resolve(root, match))
|
2026-06-14 00:47:38 +08:00
|
|
|
}
|
|
|
|
|
files.sort()
|
|
|
|
|
|
|
|
|
|
const all = files.flatMap(extractBlocks)
|
2026-06-20 16:24:37 +08:00
|
|
|
const checked = all.filter(b => b.kind === 'check')
|
|
|
|
|
const ignored = all.filter(b => b.kind === 'ignore')
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
// `type-equiv`, `cordis-catalog`, and `persistence-catalog` blocks are verified
|
|
|
|
|
// elsewhere (verify-type-equiv.ts and each catalog generator's `--check`
|
|
|
|
|
// freshness gate), not here: neither compiled nor counted toward the opt-out
|
|
|
|
|
// ratio (each is a separate fully-checked category, not an unchecked sketch).
|
|
|
|
|
// The ratio's denominator is therefore the compile-eligible blocks only.
|
2026-06-20 16:24:37 +08:00
|
|
|
const ratioDenominator = checked.length + ignored.length
|
2026-06-14 00:47:38 +08:00
|
|
|
|
|
|
|
|
if (checked.length === 0) {
|
|
|
|
|
console.log('doc-typecheck: no ts code blocks to check.')
|
|
|
|
|
process.exit(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const tmp = mkdtempSync(join(root, '.doc-typecheck-'))
|
|
|
|
|
try {
|
|
|
|
|
writeFileSync(join(tmp, 'tsconfig.json'), tempTsconfig())
|
|
|
|
|
const fileForBlock = new Map<string, Block>()
|
|
|
|
|
checked.forEach((block, i) => {
|
|
|
|
|
const name = `block-${i}.ts`
|
|
|
|
|
writeFileSync(join(tmp, name), block.code.endsWith('\n') ? block.code : `${block.code}\n`)
|
|
|
|
|
fileForBlock.set(name, block)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
try {
|
2026-06-17 23:41:18 +08:00
|
|
|
execFileSync('node_modules/.bin/tsc', ['-b', join(tmp, 'tsconfig.json')], { cwd: root, stdio: 'pipe' })
|
2026-06-14 00:47:38 +08:00
|
|
|
} catch (error: unknown) {
|
2026-06-17 23:41:18 +08:00
|
|
|
const failed = error as { stdout?: Buffer; stderr?: Buffer }
|
|
|
|
|
const out = `${failed.stdout?.toString() ?? ''}${failed.stderr?.toString() ?? ''}`
|
2026-06-14 00:47:38 +08:00
|
|
|
// Rewrite "block-N.ts(line,col)" to the real "file:fenceLine" for triage.
|
2026-06-17 23:41:18 +08:00
|
|
|
const remapped = out.replace(/(?:[^\s:()]*[/\\])?block-(\d+)\.ts\((\d+),(\d+)\)/g, (_m, idx: string, ln: string, col: string) => {
|
2026-06-14 00:47:38 +08:00
|
|
|
const block = fileForBlock.get(`block-${idx}.ts`)
|
|
|
|
|
if (!block) return `block-${idx}.ts(${ln},${col})`
|
|
|
|
|
return `${block.file} (block at line ${block.line}, +${ln}:${col})`
|
|
|
|
|
})
|
|
|
|
|
console.error('doc-typecheck: documentation code blocks failed to compile.\n')
|
|
|
|
|
console.error(remapped)
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-20 16:24:37 +08:00
|
|
|
const ratio = ignored.length / ratioDenominator
|
2026-06-20 19:47:09 +08:00
|
|
|
const skipped = all.length - ratioDenominator
|
Add generated persistence log event catalog with freshness + completeness gates
docs/persistence-catalog/log-events.md enumerates every SessionEventMap
member — the owning dsh-session vocabulary plus the dsh-compact and
dsh-hook-protocol declaration merges — with payload, surface/log-only badge,
JSDoc prose, and declaration site. scripts/gen-persistence-catalog.ts is a
pure AST pass in the gen-cordis-catalog mold: verify-persistence-catalog
(--check) joins doc-sync, so a stale committed catalog fails pre-push and CI.
The walk enforces JSDoc completeness (every member needs description prose;
@mode is rejected as a category error — log events do not dispatch on the
cordis bus), derives the surface badge from the SurfaceEventType union with a
stale-member cross-check, and hard-errors on duplicate declarations. Payloads
render through the TypeScript printer so newline-separated multi-line type
literals still emit valid one-line fragments.
Documented the five previously JSDoc-less core events (turn/step boundaries,
tool/call), removed the two stray @mode tags on the hook/* merges, and
replaced the hand-restated event enumerations (session.md hook/* table,
compact README table, hook-protocol README bullets, session README name-list
— whose merge note had already drifted) with links to the catalog. RFC:
docs/rfc/implemented/process/2026-07-04-persistence-log-catalog.md.
2026-07-04 22:58:28 +08:00
|
|
|
console.log(`doc-typecheck: ${checked.length} block(s) compiled, ${ignored.length} ignored (${(ratio * 100).toFixed(0)}% opt-out), ${skipped} type-equiv/catalog (checked elsewhere).`)
|
2026-06-14 00:47:38 +08:00
|
|
|
// Guard against the escape hatch becoming the norm.
|
2026-06-20 16:24:37 +08:00
|
|
|
if (ratioDenominator >= 4 && ratio > 0.5) {
|
|
|
|
|
console.error(`doc-typecheck: too many blocks opt out of checking (${ignored.length}/${ratioDenominator}). Make them compile or delete them.`)
|
2026-06-14 00:47:38 +08:00
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
rmSync(tmp, { recursive: true, force: true })
|
|
|
|
|
}
|