mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
fix(webhook): align patch-relative fixtures and invariants
This commit is contained in:
@@ -5,4 +5,4 @@
|
||||
|
||||
- insert:
|
||||
- id: cli-mock-llm
|
||||
name: './snapshot-fixtures/cli-mock-llm.ts'
|
||||
name: './cli-mock-llm.ts'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { copyFile, mkdir, readFile, readdir, writeFile } from 'node:fs/promises'
|
||||
import { readFile, readdir, writeFile } from 'node:fs/promises'
|
||||
import { createServer } from 'node:http'
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http'
|
||||
import { delimiter, dirname, join } from 'node:path'
|
||||
@@ -59,7 +59,6 @@ const deepseekDefaultsConfigPath = fileURLToPath(new URL('./fixtures/deepseek-de
|
||||
const headlessOverlayPath = fileURLToPath(new URL('./fixtures/headless-profile.cordis.yml', import.meta.url))
|
||||
const headlessSessionExpected = join(snapshotsDir, 'headless-profile', 'session.expected.jsonl')
|
||||
const headlessFailureExpected = join(snapshotsDir, 'headless-profile', 'stderr.expected.txt')
|
||||
const cliMockLlmPluginPath = fileURLToPath(new URL('./fixtures/cli-mock-llm.ts', import.meta.url))
|
||||
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
|
||||
|
||||
interface JsonObject {
|
||||
@@ -232,16 +231,6 @@ async function persistedLogs(cwd: string, root: string = join(cwd, '.sessions'))
|
||||
}))
|
||||
}
|
||||
|
||||
/** Install the keyless product-CLI adapter into the temporary headless profile. */
|
||||
async function prepareCliMockFixture(cwd: string): Promise<void> {
|
||||
const fixtureDir = join(cwd, '.dsh', 'profiles', 'headless', 'snapshot-fixtures')
|
||||
await mkdir(fixtureDir, { recursive: true })
|
||||
await Promise.all([
|
||||
copyFile(cliMockLlmPluginPath, join(fixtureDir, 'cli-mock-llm.ts')),
|
||||
writeFile(join(fixtureDir, 'package.json'), '{"type":"module"}\n'),
|
||||
])
|
||||
}
|
||||
|
||||
describe('headless stream-json snapshots', () => {
|
||||
it('runs one task through the product headless profile command', async () => {
|
||||
const task = 'Prove the product headless profile path with one real tool round trip.'
|
||||
@@ -257,7 +246,6 @@ describe('headless stream-json snapshots', () => {
|
||||
DSH_TELEMETRY_DISABLED: '1',
|
||||
NODE_OPTIONS: [process.env.NODE_OPTIONS, '--disable-warning=ExperimentalWarning'].filter(Boolean).join(' '),
|
||||
},
|
||||
prepare: prepareCliMockFixture,
|
||||
inspect: async (cwd) => {
|
||||
const logs = await persistedLogs(cwd, join(cwd, '.dsh', 'sessions'))
|
||||
expect(logs).toHaveLength(1)
|
||||
@@ -290,7 +278,6 @@ describe('headless stream-json snapshots', () => {
|
||||
DSH_TELEMETRY_DISABLED: '1',
|
||||
NODE_OPTIONS: [process.env.NODE_OPTIONS, '--disable-warning=ExperimentalWarning'].filter(Boolean).join(' '),
|
||||
},
|
||||
prepare: prepareCliMockFixture,
|
||||
})
|
||||
|
||||
expect(result.stdout).toBe('\n')
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { mkdtempSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import * as yaml from 'js-yaml'
|
||||
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
|
||||
@@ -74,7 +75,11 @@ describe('renderConfigDump', () => {
|
||||
config: { value: 'surface', key: { __jsExpr: 'process.env.DSH_DUMP_SPEC' } },
|
||||
},
|
||||
{ id: 'untouched', name: './noop.mjs' },
|
||||
{ id: 'surface-extra', name: './noop.mjs', config: { value: 'user' } },
|
||||
{
|
||||
id: 'surface-extra',
|
||||
name: pathToFileURL(join(dir, 'noop.mjs')).href,
|
||||
config: { value: 'user' },
|
||||
},
|
||||
])
|
||||
// Unevaluated: the expression text round-trips as a !!js scalar.
|
||||
expect(dump).toContain('!!js process.env.DSH_DUMP_SPEC')
|
||||
|
||||
@@ -15,7 +15,7 @@ export const name = 'webhook-invariant'
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Verify that one webhook-origin message already belongs to its cwd Workspace. */
|
||||
const install: InvariantInstaller = Object.assign((ctx: Context, fail: InvariantFailure) => {
|
||||
function installWebhookInvariant(ctx: Context, fail: InvariantFailure): void {
|
||||
ctx.on('internal/dispatch', (_mode, eventName, args) => {
|
||||
if (eventName !== 'session/event') return
|
||||
const [session, event] = args as [Session, SessionEvent]
|
||||
@@ -32,7 +32,11 @@ const install: InvariantInstaller = Object.assign((ctx: Context, fail: Invariant
|
||||
fail(`webhook Session "${session.id}" cwd ${JSON.stringify(cwd)} differs from its Workspace path`)
|
||||
}
|
||||
}, { global: true })
|
||||
}, { inject: ['workspaceRegistry'] })
|
||||
}
|
||||
|
||||
const install: InvariantInstaller = Object.assign(installWebhookInvariant, {
|
||||
inject: ['workspaceRegistry'],
|
||||
})
|
||||
|
||||
/**
|
||||
* Register this package's relationship invariant.
|
||||
|
||||
Reference in New Issue
Block a user