e2bde2902c
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.
53 lines
2.3 KiB
TypeScript
53 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { Context } from 'cordis'
|
|
import * as acpAgent from '../src/index.ts'
|
|
|
|
/**
|
|
* In-process unit coverage for the @deepseek-ai/dsh-acp-agent composition:
|
|
* mounting it brings up the agent-core spine + JSONL persistence + the ACP
|
|
* bridge in one `ctx.plugin`. Unlike the stdio app, this one loads NO
|
|
* Loader-only plugin (no hmr), so it mounts in a plain Context.
|
|
*
|
|
* The REAL Loader-path guard (export shape via `unwrapExports`, the headline
|
|
* ACP operations end-to-end) is the keyless bin smoke in `load-path.e2e.ts`;
|
|
* this spec asserts the composition and the persistenceRoot default branch.
|
|
*/
|
|
async function mount(config: acpAgent.Config): Promise<Context> {
|
|
const ctx = new Context()
|
|
await ctx.plugin(acpAgent, config)
|
|
// The bundle mounts its children inside apply() (not awaited there); let their
|
|
// fibers settle so the spine services are ready.
|
|
await new Promise(resolve => setTimeout(resolve, 50))
|
|
return ctx
|
|
}
|
|
|
|
describe('dsh-acp-agent composition', () => {
|
|
it('brings up the spine + persistence + the ACP bridge', async () => {
|
|
const ctx = await mount({ model: 'mock', systemPrompt: 'hi', persistenceRoot: '/tmp/dsh-acp-agent-test' })
|
|
expect(ctx.get('agents')).toBeDefined()
|
|
expect(ctx.get('sessions')).toBeDefined()
|
|
expect(ctx.get('sessionPersistence')).toBeDefined()
|
|
expect(ctx.get('agentLoop')).toBeDefined()
|
|
// No pre-created agents — ACP session/new creates them on demand.
|
|
expect(ctx.get('agents')!.list()).toHaveLength(0)
|
|
await ctx.fiber.dispose()
|
|
})
|
|
|
|
it('defaults the persistence root when omitted', async () => {
|
|
// Exercises the `?? './.sessions'` fallback for a direct-apply caller that
|
|
// bypasses the schema's `.default(...)`: call `apply` directly (not via
|
|
// `ctx.plugin`, which validates+defaults the config first) with no
|
|
// persistenceRoot, so the runtime fallback is the one that fires.
|
|
const ctx = new Context()
|
|
acpAgent.apply(ctx, { model: 'mock', systemPrompt: 'hi' })
|
|
await new Promise(resolve => setTimeout(resolve, 50))
|
|
expect(ctx.get('sessionPersistence')).toBeDefined()
|
|
await ctx.fiber.dispose()
|
|
})
|
|
|
|
it('exposes its plugin shape', () => {
|
|
expect(acpAgent.name).toBe('acp-agent')
|
|
expect(acpAgent.Config).toBeDefined()
|
|
})
|
|
})
|