Merge pull request #7940 from deepseek-harness/refactor/cordis-include-yaml

refactor(cordis): route Include-dialect YAML through Include exports
This commit is contained in:
Shigma authored and GitHub committed 2026-11-13 15:26:20 +08:00
commit 94d9995755
55 files changed
+186 -237

No files matched your search

+2 -3
View File
@@ -13,9 +13,8 @@ import {
} from '@agentclientprotocol/sdk'
import { withFileLock, writeFileAtomic } from '@deepseek-ai/dsh-atomic-write'
import { startMockLlmServer } from '@deepseek-ai/dsh-llm-mock-server'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { execa } from 'execa'
import * as yaml from 'js-yaml'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { testProfileResolution } from './profiles/headless/tests/profile-resolution.ts'
@@ -1259,7 +1258,7 @@ describe.skipIf(!existsSync(dshBin))('dsh BUILT bin (node lib/bin.js, no tsx)',
)
expect(code).toBe(0)
expect(stderr).toBe('')
const rows = yaml.load(stdout, { schema: entryListSchema }) as Array<{ id?: string; name?: string }>
const rows = parseEntryYaml(stdout) as Array<{ id?: string; name?: string }>
expect(rows.map(row => [row.id, row.name])).toEqual([
['sdk-app-startup', '@deepseek-ai/dsh-sdk-app'],
['sdk-jsonrpc-server', '@deepseek-ai/dsh-sdk-jsonrpc-server'],
@@ -3,8 +3,7 @@
import { existsSync, mkdtempSync, realpathSync } from 'node:fs'
import { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises'
import { Ajv2020 } from 'ajv/dist/2020.js'
import * as yaml from 'js-yaml'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import type { ConfigSchemaDump } from '@deepseek-ai/dsh-app-boot'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
@@ -162,7 +161,7 @@ describe.skipIf(!builtArtifactsExist)('dsh --dump-config-schema assembled output
const composed = await dump(fixture, [], '--dump-config')
const validator = new Ajv2020({ strict: false, validateFormats: false })
const validate = validator.compile(document)
expect(validate(yaml.load(composed.stdout, { schema: entryListSchema })), JSON.stringify(validate.errors)).toBe(true)
expect(validate(parseEntryYaml(composed.stdout)), JSON.stringify(validate.errors)).toBe(true)
expect(validate([{ name: `${packageName}/namespace`, config: { attempts: 'wrong' } }])).toBe(false)
const patch = validator.compile({ $schema: document.$schema, $defs: document.$defs, $ref: '#/$defs/patchList' })
expect(patch([{ id: 'schema-class', config: { enabled: 'wrong' } }])).toBe(false)
@@ -15,7 +15,7 @@ import { mkdtemp, readFile, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import yaml from 'js-yaml'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { describe, expect, it } from 'vitest'
const repoRoot = fileURLToPath(new URL('../../../', import.meta.url))
@@ -37,12 +37,6 @@ interface PatchEntry extends ConfigRow {
insert?: ConfigRow[]
}
const jsExprType = new yaml.Type('tag:yaml.org,2002:js', {
kind: 'scalar',
construct: value => String(value),
})
const configSchema = yaml.JSON_SCHEMA.extend(jsExprType)
/** Boot the built Web CLI, wait for its settled URL, then dispose through SIGTERM. */
function runBuiltWeb(cwd: string): Promise<{ stdout: string; stderr: string; code: number }> {
return new Promise((resolveRun, rejectRun) => {
@@ -103,9 +97,9 @@ describe.skipIf(!requireBuiltArtifacts)('built CLI lazy-search startup', () => {
it('boots and disposes the shipped composition with full-text search off by default', async () => {
expect(existsSync(builtBin), `missing built CLI ${resolve(builtBin)}; run pnpm build`).toBe(true)
expect(existsSync(webDist), `missing Web dist ${resolve(webDist)}; run pnpm run build:web`).toBe(true)
const baseRows = (yaml.load(await readFile(baseConfigPath, 'utf8'), { schema: configSchema }) as PatchEntry[])
const baseRows = (parseEntryYaml(await readFile(baseConfigPath, 'utf8')) as PatchEntry[])
.flatMap(entry => entry.insert ?? [entry])
const webRows = (yaml.load(await readFile(webConfigPath, 'utf8'), { schema: configSchema }) as PatchEntry[])
const webRows = (parseEntryYaml(await readFile(webConfigPath, 'utf8')) as PatchEntry[])
.flatMap(entry => entry.insert ?? [entry])
const baseRow = baseRows.find(row => row.id === 'session-query-sqlite')
const webRow = webRows.find(row => row.id === 'session-query-sqlite')
@@ -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 }] },
]))
+2 -3
View File
@@ -15,8 +15,7 @@ import { mkdtempSync, rmSync, readFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import yaml from 'js-yaml'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include'
import { evaluate } from '@deepseek-ai/cordis-plugin-loader'
import { bundlePatchPaths, composeEntries, initProfile, loadProfile, PROFILES_DIR } from '@deepseek-ai/dsh-app-boot'
@@ -104,7 +103,7 @@ describe('shipped agent presets gate both shell tools by platform', () => {
const webBundle = fileURLToPath(new URL('../../../packages/bundle/web-app/', import.meta.url))
const webManifest = JSON.parse(readFileSync(join(webBundle, 'package.json'), 'utf8')) as { dsh: { bundle: { patch: string[] } } }
const presetRows = composeEntries([bundlePatchPaths(webBundle, webManifest.dsh.bundle).flatMap(file =>
yaml.load(readFileSync(file, 'utf8'), { schema: entryListSchema }) as import('@deepseek-ai/cordis-plugin-include').PatchOptions[])])
parseEntryYaml(readFileSync(file, 'utf8')) as import('@deepseek-ai/cordis-plugin-include').PatchOptions[])])
const definitions = presetRows.filter(row => row.name === '@deepseek-ai/dsh-agent-preset').map(row => row.config as import('@deepseek-ai/dsh-agent-preset-registry').PresetDefinition)