2026-06-13 00:28:29 +08:00
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
|
|
|
import { defineConfig } from 'vitest/config'
|
|
|
|
|
|
2026-07-13 23:27:00 +08:00
|
|
|
// Real-API suite, separate because it spends tokens. Each test self-skips without
|
2026-07-17 23:33:30 +08:00
|
|
|
// its provider credential for keyless CI; credentialed workflows preflight the
|
|
|
|
|
// secrets they require. Values may come from the environment or gitignored root
|
|
|
|
|
// `.env`, with provider-specific endpoint overrides where supported.
|
2026-06-13 00:28:29 +08:00
|
|
|
try {
|
|
|
|
|
// Node >= 21.7 native; throws when the file does not exist.
|
|
|
|
|
process.loadEnvFile(new URL('.env', import.meta.url).pathname)
|
|
|
|
|
} catch {
|
|
|
|
|
// No .env — fine, the environment may already carry the variables.
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-06 01:10:27 +08:00
|
|
|
const DEFAULT_E2E_MAX_WORKERS = 4
|
|
|
|
|
|
|
|
|
|
function positiveIntFromEnv(name: string, fallback: number): number {
|
|
|
|
|
const raw = process.env[name]
|
|
|
|
|
if (raw === undefined || raw === '') return fallback
|
|
|
|
|
|
|
|
|
|
const value = Number(raw)
|
|
|
|
|
if (!Number.isInteger(value) || value < 1) {
|
|
|
|
|
throw new Error(`${name} must be a positive integer, got ${JSON.stringify(raw)}`)
|
|
|
|
|
}
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const e2eMaxWorkers = positiveIntFromEnv('DSH_E2E_MAX_WORKERS', DEFAULT_E2E_MAX_WORKERS)
|
|
|
|
|
|
2026-06-13 00:28:29 +08:00
|
|
|
export default defineConfig({
|
|
|
|
|
// Same resolution note as vitest.config.ts: bare workspace names resolve
|
2026-07-23 00:02:21 +08:00
|
|
|
// through the tsconfig.base.json paths facade (no include = match-all, so
|
|
|
|
|
// client-package sources get mapping too — dropping /client subpath imports
|
|
|
|
|
// onto package exports would load browser dist bundles into node).
|
|
|
|
|
// Built-artifact e2e suites are unaffected: their built-ness lives in
|
|
|
|
|
// subprocesses and createRequire lookups, which bypass vite resolution
|
|
|
|
|
// entirely.
|
|
|
|
|
plugins: [tsconfigPaths({ projects: ['./tsconfig.base.json'] })],
|
2026-06-13 00:28:29 +08:00
|
|
|
test: {
|
2026-07-19 22:13:50 +08:00
|
|
|
setupFiles: ['./scripts/test-invariants.ts'],
|
refactor(cli): unify the arg grammar — one program, --config flag, real web subcommand
Drop the bare `dsh <config>` positional in favor of a `--config <path>` flag.
Without a root positional, `web` can be a real Commander subcommand in one
program instead of the reserved-first-token dispatch to a second parser, so
`dsh --help` lists every mode natively (no hand-pasted command text) and the
second parser + reserved-token machinery are gone.
Grammar:
dsh TUI (shipped tree + ~/.dsh overlay)
dsh --config <path> TUI, alternate tree (demos/tests only)
dsh --resume <id> TUI, resume a session
dsh -p "task" headless one-shot
dsh web [--host --port --dev]
`dsh` is the product front door with no positional; `--config` exists only so
demo:cordis, demo:code-mode, and the keyless PTY smokes can point the shipped
bin at an example tree. Those three sites and the /resume re-exec argv move to
`--config <path>`. The `-p` + `--config`/`--resume` mode-mixing guard and the
cordis.yml-owns-host/port-default fix are preserved.
Agent Note + Chinese pair, README, tui.ts docs updated. All 13 PTY smokes
(including code-mode via --config and the exec-replace resume handoff) green.
2026-07-25 15:47:55 +08:00
|
|
|
// apps/cli only, not apps/*: apps/web/tests/*.e2e.ts needs the built
|
|
|
|
|
// frontend dist and runs under vitest.web.config.ts (the test:web job).
|
|
|
|
|
include: ['packages/*/*/tests/**/*.e2e.ts', 'apps/cli/tests/**/*.e2e.ts', 'examples/*/tests/**/*.e2e.ts'],
|
Add examples/coding-agent and the docs cookbook
The first real agent wiring: DeepSeek V4 + the bash tool suite + stdio
chat + JSONL persistence, runnable via yarn demo:coding (reads the
gitignored repo-root .env through process.loadEnvFile).
- examples/coding-agent: cordis.yml wiring both real plugin families
(llm-deepseek with !!js env secrets; bash-local + tool-bash), a
bash-only coding system prompt, a max-steps-guard plugin (bounds
runaway turns via the agent/turn-continuation waterfall — abort()
from step-end is a no-op by then), and a stdio UI with dimmed
reasoning and exit-on-idle for piped stdin.
- e2e (yarn test:e2e, key-gated): full-loop.e2e.ts runs a real model
against the real bash tool; coding-task.e2e.ts is the swebench-style
smoke — the model fixes a buggy add.js in a temp dir and the test
re-runs node add.test.js itself rather than trusting the agent.
- docs/cookbook: adding-a-package (the verified checklist),
adding-a-tool (execute() contract, background pattern, seams),
adding-an-llm-adapter (protocol obligations, mock-server testing,
e2e policy). AGENTS.md layout/commands/secrets sections updated;
architecture.md points at both examples and the cookbook.
- vitest.e2e.config.ts: serialize test files + retry twice — parallel
e2e files trip the shared internal key's concurrency quota.
- fix: the !js YAML tag spelling in docs/JSDoc is actually !!js
(js-yaml resolves custom tags under tag:yaml.org,2002:js).
2026-06-13 00:47:32 +08:00
|
|
|
// Real model calls: generous timeouts, and retries for transient flakes
|
|
|
|
|
// (the shared internal key hits concurrency quotas). No coverage — the
|
|
|
|
|
// unit suites own the coverage gate.
|
2026-06-13 00:28:29 +08:00
|
|
|
testTimeout: 120_000,
|
|
|
|
|
hookTimeout: 30_000,
|
Add examples/coding-agent and the docs cookbook
The first real agent wiring: DeepSeek V4 + the bash tool suite + stdio
chat + JSONL persistence, runnable via yarn demo:coding (reads the
gitignored repo-root .env through process.loadEnvFile).
- examples/coding-agent: cordis.yml wiring both real plugin families
(llm-deepseek with !!js env secrets; bash-local + tool-bash), a
bash-only coding system prompt, a max-steps-guard plugin (bounds
runaway turns via the agent/turn-continuation waterfall — abort()
from step-end is a no-op by then), and a stdio UI with dimmed
reasoning and exit-on-idle for piped stdin.
- e2e (yarn test:e2e, key-gated): full-loop.e2e.ts runs a real model
against the real bash tool; coding-task.e2e.ts is the swebench-style
smoke — the model fixes a buggy add.js in a temp dir and the test
re-runs node add.test.js itself rather than trusting the agent.
- docs/cookbook: adding-a-package (the verified checklist),
adding-a-tool (execute() contract, background pattern, seams),
adding-an-llm-adapter (protocol obligations, mock-server testing,
e2e policy). AGENTS.md layout/commands/secrets sections updated;
architecture.md points at both examples and the cookbook.
- vitest.e2e.config.ts: serialize test files + retry twice — parallel
e2e files trip the shared internal key's concurrency quota.
- fix: the !js YAML tag spelling in docs/JSDoc is actually !!js
(js-yaml resolves custom tags under tag:yaml.org,2002:js).
2026-06-13 00:47:32 +08:00
|
|
|
retry: 2,
|
2026-07-06 01:10:27 +08:00
|
|
|
// Run files in a bounded pool: enough lower-level parallelism to keep CI
|
|
|
|
|
// and local with-key runs moving, while leaving a resource knob for shared
|
|
|
|
|
// API quotas (`DSH_E2E_MAX_WORKERS=1` restores serial execution).
|
|
|
|
|
fileParallelism: e2eMaxWorkers > 1,
|
|
|
|
|
maxWorkers: e2eMaxWorkers,
|
2026-06-13 00:28:29 +08:00
|
|
|
},
|
|
|
|
|
})
|