refactor(cordis): migrate remaining Include-dialect YAML call sites

This commit is contained in:
Shigma committed 2026-11-05 19:29:17 +08:00
1 parent 0dd0bd18cd
commit 6d44ea055b
12 files changed
+27 -18

No files matched your search

@@ -5,8 +5,8 @@ import { join } from 'node:path'
import { createInterface } from 'node:readline'
import { fileURLToPath } from 'node:url'
import { execa } from 'execa'
import yaml from 'js-yaml'
import { expect, it, onTestFinished } from 'vitest'
import { stringifyEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import type { BundleInfo, ChangeResult } from '@deepseek-ai/dsh-plugin-manager'
import { getDshRuntimeVersion } from '../../../../packages/boot/app-boot/src/plugin-compatibility.ts'
import { generateOfficialBundleCatalog } from '../../../../scripts/gen-official-bundle-catalog.ts'
@@ -118,7 +118,7 @@ it.skipIf(!built)('installs the exported registry\'s local closure and switches
const observer = join(temporary, 'official-installer-observer.mjs')
await writeFile(observer, await readFile(new URL('./fixtures/official-installer-observer.mjs', import.meta.url), 'utf8'))
const patch = join(temporary, 'official-installer.patch.yml')
await writeFile(patch, yaml.dump([{ insert: [{ id: 'official-installer-observer', name: observer,
await writeFile(patch, stringifyEntryYaml([{ insert: [{ id: 'official-installer-observer', name: observer,
config: {
registry: registry.url,
profile,
@@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url'
import { execa } from 'execa'
import yaml from 'js-yaml'
import { expect, it } from 'vitest'
import { stringifyEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { assertInstalledTree, createPackedInstallation } from './packed-installation.ts'
const root = fileURLToPath(new URL('../../../..', import.meta.url))
@@ -64,7 +65,7 @@ export function apply(ctx) {
}
`)
const patch = join(temporary, 'test.patch.yml')
await writeFile(patch, yaml.dump([
await writeFile(patch, stringifyEntryYaml([
{ id: 'session-telemetry-otel', disabled: true },
{ id: 'github-webhook-ingress', insert: [{ id: 'observe-packed-ingress', name: observer }] },
]))
+4 -4
View File
@@ -8,7 +8,7 @@ import { readProfileManifest } from '@deepseek-ai/dsh-app-boot'
import { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-ptc-runtime'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { load } from 'js-yaml'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { expect, it, vi } from 'vitest'
import { captureStableAria, compareOrRefreshGolden, launchWebScaffold, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { connectFreshWorkspaceZh, ZH_BROWSER_LOCALE } from './support.ts'
@@ -151,9 +151,9 @@ it.skipIf(process.platform !== 'darwin').each([
expect(scaffold.ctx.settings.describe().find(row => row.ns === 'ui-settings')?.value).toMatchObject({ enabled: codingTools })
expect(saved).not.toContain('executionMode:')
if (selectedDefault === undefined) {
expect(load(saved)).not.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'agent-preset-registry' })]))
expect(parseEntryYaml(saved)).not.toEqual(expect.arrayContaining([expect.objectContaining({ id: 'agent-preset-registry' })]))
} else {
expect(load(saved)).toEqual(expect.arrayContaining([
expect(parseEntryYaml(saved)).toEqual(expect.arrayContaining([
expect.objectContaining({ id: 'agent-preset-registry', config: { default: 'standard', selectedDefault } }),
]))
}
@@ -232,7 +232,7 @@ it.skipIf(process.platform !== 'darwin').each([
expect(scaffold.ctx.tools.schemas(ptcAgent).some(tool => tool.name === 'cua')).toBe(true)
expect((await runtime.run(runtime.resolve({ program, bindings: [], stateOwner: owner }))).value).toBe(3)
const confirmedSettings = await readFile(settingsPath, 'utf8')
expect(load(confirmedSettings)).toEqual(expect.arrayContaining([
expect(parseEntryYaml(confirmedSettings)).toEqual(expect.arrayContaining([
expect.objectContaining({ id: 'agent-preset-registry', config: { default: 'standard', selectedDefault: 'ptc' } }),
]))
await toggle.click()
+2 -2
View File
@@ -3,8 +3,8 @@ import { mkdtemp, rm, writeFile, readFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { chromium } from 'playwright'
import yaml from 'js-yaml'
import { expect, it, onTestFinished } from 'vitest'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { credentialRef } from '@deepseek-ai/dsh-credentials'
import { startMockLlmServer } from '@deepseek-ai/dsh-llm-mock-server'
import { launchWebScaffold, webSnapshotMode } from './scaffold.ts'
@@ -44,7 +44,7 @@ it.skipIf(webSnapshotMode() === 'record')('persists the upload switch and omits
await toggle.click()
await expect.poll(() => toggle.getAttribute('aria-checked')).toBe(String(enabled))
await expect.poll(async () => {
const patches = yaml.load(await readFile(join(scaffold.harnessHome, 'profiles/scaffold/cordis.patch.yml'), 'utf8')) as { id: string; config?: { enabled?: boolean } }[]
const patches = parseEntryYaml(await readFile(join(scaffold.harnessHome, 'profiles/scaffold/cordis.patch.yml'), 'utf8')) as { id: string; config?: { enabled?: boolean } }[]
return patches.find(patch => patch.id === 'session-log-deepseek')?.config?.enabled ?? true
}).toBe(enabled)
await page.keyboard.press('Escape')
@@ -150,7 +150,7 @@ export async function collectConfigSchemas(
source = extension === '.json' ? JSON.parse(content) : parseEntryYaml(content)
} catch (error) {
// Parser messages can quote configuration values; retain only the file and location.
const position = extension === '.json' ? undefined : entryYamlErrorPosition(error)
const position = entryYamlErrorPosition(error)
const at = position === undefined ? '' : ` at line ${position.line}, column ${position.column}`
throw new Error(`invalid ${extension === '.json' ? 'JSON' : 'YAML'} include ${filename}${at}`)
}
@@ -55,6 +55,7 @@
},
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/cordis-plugin-include": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-app-boot": "workspace:*",
"@deepseek-ai/dsh-llm": "workspace:*",
@@ -15,7 +15,7 @@ import type {
} from '@anthropic-ai/claude-agent-sdk'
import { Context } from '@deepseek-ai/cordis'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import * as yaml from 'js-yaml'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import {
afterEach,
beforeEach,
@@ -392,7 +392,7 @@ describe('task admission and package contracts', () => {
)
}
const parsed = yaml.load(readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'))
const parsed = parseEntryYaml(readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'))
expect(parsed).toEqual([{ insert: [
{ id: 'subagent-claude-code', name: '@deepseek-ai/dsh-subagent-claude-code' },
{ id: 'tool-subagent-claude-code', name: '@deepseek-ai/dsh-tool-subagent', config: {
@@ -53,6 +53,7 @@
},
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/cordis-plugin-include": "workspace:~",
"@deepseek-ai/cordis-plugin-loader": "workspace:~",
"@deepseek-ai/dsh-agent": "workspace:*",
"@deepseek-ai/dsh-app-boot": "workspace:*",
@@ -7,7 +7,7 @@ import { PassThrough } from 'node:stream'
import { fileURLToPath } from 'node:url'
import { Context } from '@deepseek-ai/cordis'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import * as yaml from 'js-yaml'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { describe, expect, it, vi } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import type { ContentBlock } from '@deepseek-ai/dsh-llm'
@@ -405,7 +405,7 @@ describe('task admission and package contracts', () => {
)
}
const parsed = yaml.load(readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'))
const parsed = parseEntryYaml(readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'))
expect(parsed).toEqual([{ insert: [
{ id: 'subagent-codex', name: '@deepseek-ai/dsh-subagent-codex' },
{ id: 'tool-subagent-codex', name: '@deepseek-ai/dsh-tool-subagent', config: {
+6
View File
@@ -16328,6 +16328,9 @@ importers:
'@deepseek-ai/cordis':
specifier: workspace:~
version: link:../../../vendor/cordis
'@deepseek-ai/cordis-plugin-include':
specifier: workspace:~
version: link:../../../vendor/include
'@deepseek-ai/dsh-agent':
specifier: workspace:*
version: link:../../core/agent
@@ -16398,6 +16401,9 @@ importers:
'@deepseek-ai/cordis':
specifier: workspace:~
version: link:../../../vendor/cordis
'@deepseek-ai/cordis-plugin-include':
specifier: workspace:~
version: link:../../../vendor/include
'@deepseek-ai/cordis-plugin-loader':
specifier: workspace:~
version: link:../../../vendor/loader
+1 -1
View File
@@ -37,7 +37,7 @@ Keep this log exhaustive — every divergence from upstream must be listed. Each
- **V7 · JSDoc enrichment**: added `@param`/`@returns` tags and contract documentation (disposal semantics, waterfall veto, bail conditions, error cases) across the public plugin-author surface — `Context` (class, statics, and the `Context` interface properties incl. `root`), module re-exports, shared utility helpers, `EventsService`, `Fiber`, `RegistryService`, `ReflectService`, `Service`, `LoggerService` and their `declare module './context.ts'` overloads. Loader documentation covers `loader/src/{index,internal,config/entry,config/group,config/isolate,config/tree,config/utils}.ts`, including entry ownership, tree mutation methods, and the `!!js` discriminator. The upstream `EventsService.dispatch()` deprecation annotation is omitted: DSH enumerates callbacks to contain each observer failure independently, which the typed dispatch methods do not provide. Timer retains its local class and helper summaries; its README is local documentation because the upstream package has none. Cosmokit and Schemastery add summaries to their exported helpers, types and namespaces, logger-console to its exporters and config namespace, and HMR to its build-failure logger in `hmr/src/error.ts`. Comment-only; no code changes. Motivation: the website API-reference generator renders these docs and hard-errors on undocumented members. Retire this entry when the enrichment is upstreamed.
- **V9 · `hmr/src/index.ts` module-watcher readiness and native paths**: realpath the existing watch base, classify framework modules and attach listeners before reporting readiness, and compare config paths using both canonical and configured spellings. This preserves Node module-cache identity across Windows short-name paths and filesystem aliases. The main watcher uses `ignoreInitial: true` so startup reads do not trigger another refresh; exact profile patch watching is owned by `packages/boot/hmr/src/watch-config.ts`. The Include change listener logs a rejected `Include.refresh()` instead of leaving the rejection unhandled; the rejection reports unsaved runtime changes while Include keeps its running tree. Covered by `packages/boot/hmr/tests/watch-config.spec.ts` and `scripts/cordis-vendor-hmr-include.spec.ts`.
- **V10 · Vendored Node-compatible TypeScript**: marked erased imports explicitly across `cordis`, `loader`, `include`, `hmr`, and `schemastery` so Node's native TypeScript transform does not request types as runtime exports. Schemastery's source uses an ESM default export and its package declares `type: module`. Conditional exports select `.mjs` for import and `.cjs` for require; without them, concurrent imports under module-hook hosts reach the CJS entry and can race its require of ESM Cosmokit (`ERR_REQUIRE_ESM_RACE_CONDITION`).
- **V11 · Include patch and YAML exports**: `include/src/index.ts` exports upstream `applyPatches` as `applyEntryPatches`, so `dsh --dump-config` composes entries with the same algorithm that mounting uses. It also exports `parseEntryYaml`, `stringifyEntryYaml` and `entryYamlErrorPosition` over the `!!js` YAML dialect, and `_read()` parses through `parseEntryYaml`, so every DSH reader and writer of Include-dialect YAML uses Include's parser; `stringifyEntryYaml` writes with `noRefs`, while Include's own writer keeps upstream's options. Covered by `packages/boot/app-boot/tests/config-reload.spec.ts`, `scripts/cordis-entry-commit.spec.ts` and `scripts/cordis-entry-yaml.spec.ts`.
- **V11 · Include patch and YAML exports**: `include/src/index.ts` exports upstream `applyPatches` as `applyEntryPatches`, so `dsh --dump-config` composes entries with the same algorithm that mounting uses. It also exports `parseEntryYaml`, `stringifyEntryYaml` and `entryYamlErrorPosition` over the `!!js` YAML dialect, and `_read()` parses through `parseEntryYaml`, so every DSH reader and writer of Include-dialect YAML uses Include's parser; `stringifyEntryYaml` always writes with `noRefs` and offers no option to emit aliases, while Include's own writer keeps upstream's options. Covered by `packages/boot/app-boot/tests/config-reload.spec.ts`, `scripts/cordis-entry-commit.spec.ts` and `scripts/cordis-entry-yaml.spec.ts`.
- **V14 · Include persistence results**: `include/src/index.ts` keeps an error for unsaved journal changes. `flush()` retries pending writes and rejects while changes remain unsaved; `stop()` returns the same result and always stops the child tree; a later successful flush clears previous errors. A failed `refresh()` can also reject while runtime changes remain unsaved. Patch-owned changes route to the parent Include, so callers that need them persisted must flush that parent too. The constructor omits upstream's `ctx.hmr.watch(this.filename, () => this.refresh())` registration because neither HMR provider exposes `watch()`; both find each Include by scanning loader entries for its `filename` and call `refresh()`. Ordinary Fiber teardown keeps its error containment. Covered by `scripts/cordis-include-journal.spec.ts` and `packages/host/directory-picker-auto/tests/loader-composition.spec.ts`.
- **V15 · Configuration access across Core, Loader, Include and HMR**: rc.11 Core owns raw `Fiber.config`, `internal/config(fiber, next)`, `internal/commit` and awaited `internal/update(config, next)`. Root-fiber candidate resolution remains available without a plugin schema. Local `rawConfig`, `resolveConfig(candidate)` and `effectiveConfig` accessors retain the DSH consumer API. Fiber caches the object passed to activation or a successful update that keeps the instance; candidate resolution is pure, failed or superseded updates cannot replace the cache, and volatile updates retain references. Loader resolves only entry roots and excludes Group/Include tree carriers, so nested `!!js` expressions wait for their own injections. Include retains its tree-carrier marker and public patch exports, and HMR transfers raw config through the accessors. Covered by `scripts/cordis-config-access.spec.ts`, `scripts/cordis-core-lifecycle.spec.ts` and the boot/HMR suites.
- **V16 · `cordis/package.json` publishes `src`**: added `src` to the `files` list, joining the other eight vendored packages. Cordis declares `"./src/*": "./src/*"` in its exports, so a tarball without `src` publishes an export map pointing at absent files; the release change judgement also reads `files` to decide whether a diff reaches the payload, and a package whose only published paths are build output has no tracked path to match.
+3 -3
View File
@@ -41,8 +41,8 @@ export function parseEntryYaml(content: string): unknown {
}
/**
* Serialize a value in Include's YAML dialect. JavaScript expression nodes are written as `!!js` scalars, and
* repeated object references are written out in full instead of as aliases.
* Serialize a value in Include's YAML dialect. JavaScript expression nodes are written as `!!js` scalars. The output
* never contains anchors or aliases: repeated object references are written out in full, and no option changes this.
* @param value - entry list, patch list, or entry fragment to serialize.
* @param options - output formatting.
* @returns YAML text ending with a newline.
@@ -53,7 +53,7 @@ export function stringifyEntryYaml(value: unknown, options: EntryYamlStringifyOp
/**
* Locate a syntax error thrown by {@link parseEntryYaml}.
* @param error - value thrown by {@link parseEntryYaml}.
* @param error - any caught value; only a parse error thrown by {@link parseEntryYaml} yields a position.
* @returns the one-based line and column of the error, or `undefined` when the error carries no source location.
*/
export function entryYamlErrorPosition(error: unknown): { line: number; column: number } | undefined {