2026-06-11 10:52:45 +08:00
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
|
|
|
import { defineConfig } from 'vitest/config'
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
2026-06-11 23:24:41 +08:00
|
|
|
// Vite ≥8 warns that this plugin can be replaced by the native (experimental)
|
|
|
|
|
// `resolve.tsconfigPaths: true`. It cannot — keep the plugin. Tests run
|
|
|
|
|
// unbuilt (see AGENTS.md): bare workspace names like `cordis` or
|
2026-06-17 23:41:18 +08:00
|
|
|
// `@deepseek-ai/dsh-llm` must resolve to src/, and that mapping comes from
|
|
|
|
|
// the root tsconfig.json paths map. The native option is a bare boolean:
|
|
|
|
|
// for each
|
2026-06-11 23:24:41 +08:00
|
|
|
// importing file it discovers the NEAREST tsconfig.json and applies that
|
|
|
|
|
// file's own `paths`. Every workspace under packages/* and vendor/* has its
|
|
|
|
|
// own tsconfig.json without `paths`, so native resolution maps nothing,
|
2026-06-16 14:55:37 +08:00
|
|
|
// falls through to package.json exports (lib/, absent until `pnpm run build`),
|
2026-06-11 23:24:41 +08:00
|
|
|
// and every test file fails to import (verified on vite 8.0.16 /
|
|
|
|
|
// vitest 4.1.8). Making it work would mean copying the paths map into all
|
|
|
|
|
// 15 workspace tsconfigs — including vendor/* ones, which are pinned
|
|
|
|
|
// upstream copies (vendor/README.md). The plugin's `projects` option
|
|
|
|
|
// instead applies the one root map to every importer.
|
2026-06-17 23:41:18 +08:00
|
|
|
plugins: [tsconfigPaths({ projects: ['./tsconfig.json'] })],
|
2026-06-11 10:52:45 +08:00
|
|
|
test: {
|
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
|
|
|
include: ['packages/*/*/tests/**/*.spec.ts', 'examples/*/tests/**/*.spec.ts'],
|
Enforce 100% per-file test coverage on packages/*/src
vitest coverage (v8 provider) with per-file 100% thresholds for
statements, branches, functions, and lines. Scope: our runtime source
only — types-only files, vendor/ (upstream code), and examples/
(exercised by the demo smoke test) are excluded. yarn test:coverage
runs the gate.
59 tests added to close every gap: llm generate-waterfall and adapter
disposal; assembler edge protocol (duplicate block-start, stragglers
after block-end, id fallback, usage omission, invariant violation);
the whole Inbox surface incl. the wakeup-overwrite race; LoopAgent
disposed-state throws and double-stop idempotence; config-driven agent
creation; loop backstop catches (throwing turn-start/turn-end
listeners, non-Error throws, non-JSON tool arguments); system-prompt
dynamic sections and disposer paths; tools errorMessage fallbacks and
the full schema-DSL emission matrix. Genuinely unreachable defensive
guards carry /* v8 ignore */ comments with stated reasons rather than
deletion (132 tests total).
2026-06-11 14:58:36 +08:00
|
|
|
coverage: {
|
|
|
|
|
provider: 'v8',
|
|
|
|
|
// Coverage measures OUR runtime source. Types-only files carry no
|
|
|
|
|
// executable code; vendor/ and examples/ are out of scope (examples are
|
|
|
|
|
// exercised by the demo smoke test instead).
|
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
|
|
|
include: ['packages/*/*/src/**/*.ts'],
|
refactor(examples): extract the app spine into dsh-agent-core + app packages
Implements docs/rfc/.../2026-06-20-extract-example-app-packages.md. Each
example was thick — a hand-rolled start.ts, an infra preamble, nested
base.yml/base-core.yml/acp-tail.yml includes, and a coupled front-door
cluster enforced only by prose. This moves the composition into packages so
each example is a thin leaf cordis.yml: pick the swappable backends, load one
app package.
New packages:
- @deepseek-ai/dsh-agent-core (packages/core/agent-core): one bundle plugin
that loads the providerless/executor-less/UI-less spine (timer + llm +
sessions + system-prompt + tools + agents + invariants + tool-bash +
agent-loop) via ctx.plugin(...) inside apply(), and forwards agent-loop's
`agents` list as its own Config (export const Config = AgentLoop.Config,
default []).
- @deepseek-ai/dsh-stdio-agent (packages/ui/stdio-agent): terminal chat APP —
agent-core + console logger + readline UI + a pre-created `main` agent, with
a bin. The demo:echo/coding front door.
- @deepseek-ai/dsh-acp-agent (packages/ui/acp-agent): ACP server APP —
agent-core + JSONL persistence + the acp bridge, NO stdout logger, with a
bin. The stdout-purity footgun is structurally unreachable from the leaf.
Amendment to the RFC: hmr stays a LEAF cordis.yml entry, not baked into
dsh-stdio-agent. hmr is a Loader-only dev plugin (throws without
--expose-internals; the in-process test tier can't even import its decorator
form), so a package statically importing it could never carry the per-file
coverage gate. Unlike the console logger, a stray hmr is not a stdout-purity
footgun, so leaving it at the leaf costs no safety. With hmr out, all three new
packages carry in-process unit specs at 100%.
Boot glue (Loader tail, .env load, snapshot-mode selection, stdin-dispose
lifecycle) moves into each app's bin; start.ts and base.yml/base-core.yml/
acp-tail.yml are deleted. Each app package gets a keyless real-load-path test
that boots through its bin + the cordis Loader (guarding the unwrapExports
export-shape bug class, postmortem 0001). ACP snapshot replay stays green
against the existing committed goldens (pure boot restructuring). RFC moved
proposed->implemented with the amendment recorded; package/example/architecture
docs and the module graph updated.
2026-06-21 12:03:44 +08:00
|
|
|
// Types-only files carry no executable code. `bin.ts` files are
|
|
|
|
|
// self-executing CLI entrypoints (a top-level `await main()`): a spec
|
|
|
|
|
// can't import one without booting it, so they are driven by the keyless
|
|
|
|
|
// Loader-path smoke (a real subprocess) instead of the in-process unit
|
|
|
|
|
// suite — the same reason `examples/start.ts` sat out of coverage scope.
|
|
|
|
|
exclude: ['packages/*/*/src/types.ts', 'packages/*/*/src/bin.ts'],
|
Enforce 100% per-file test coverage on packages/*/src
vitest coverage (v8 provider) with per-file 100% thresholds for
statements, branches, functions, and lines. Scope: our runtime source
only — types-only files, vendor/ (upstream code), and examples/
(exercised by the demo smoke test) are excluded. yarn test:coverage
runs the gate.
59 tests added to close every gap: llm generate-waterfall and adapter
disposal; assembler edge protocol (duplicate block-start, stragglers
after block-end, id fallback, usage omission, invariant violation);
the whole Inbox surface incl. the wakeup-overwrite race; LoopAgent
disposed-state throws and double-stop idempotence; config-driven agent
creation; loop backstop catches (throwing turn-start/turn-end
listeners, non-Error throws, non-JSON tool arguments); system-prompt
dynamic sections and disposer paths; tools errorMessage fallbacks and
the full schema-DSL emission matrix. Genuinely unreachable defensive
guards carry /* v8 ignore */ comments with stated reasons rather than
deletion (132 tests total).
2026-06-11 14:58:36 +08:00
|
|
|
// 100% or it doesn't merge (AGENTS.md: excessive tests are welcome).
|
|
|
|
|
// Per-file so a well-covered big file can't subsidize a bare one.
|
|
|
|
|
// Every v8 ignore comment must carry a reason — see AGENTS.md.
|
|
|
|
|
thresholds: {
|
|
|
|
|
perFile: true,
|
|
|
|
|
statements: 100,
|
|
|
|
|
branches: 100,
|
|
|
|
|
functions: 100,
|
|
|
|
|
lines: 100,
|
|
|
|
|
},
|
|
|
|
|
reporter: ['text', 'html'],
|
|
|
|
|
},
|
2026-06-11 10:52:45 +08:00
|
|
|
},
|
|
|
|
|
})
|