mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
feat(examples): add one-shot CLI demo
This commit is contained in:
33
examples/coding-agent/tests/cli.e2e.ts
Normal file
33
examples/coding-agent/tests/cli.e2e.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { readFile, writeFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
|
||||
|
||||
const binScript = fileURLToPath(new URL('../../../packages/examples/cli-demo/src/bin.ts', import.meta.url))
|
||||
const configPath = fileURLToPath(new URL('../cli.cordis.yml', import.meta.url))
|
||||
const tsconfigPath = fileURLToPath(new URL('../../../tsconfig.json', import.meta.url))
|
||||
const hasKey = Boolean(process.env.DEEPSEEK_API_KEY)
|
||||
|
||||
describe.skipIf(!hasKey)('coding-agent one-shot CLI with real model', () => {
|
||||
it('modifies a temporary workspace and verifies the file outside the agent', async () => {
|
||||
let verified = ''
|
||||
const { stdout } = await runLoaderSmoke({
|
||||
label: 'coding-agent CLI real model',
|
||||
tempDirPrefix: 'coding-cli-real-',
|
||||
binScript,
|
||||
configPath,
|
||||
binArgs: [
|
||||
'--config',
|
||||
configPath,
|
||||
'Read task.txt, replace its complete contents with exactly "value=after" followed by a newline, read it again, and report briefly.',
|
||||
],
|
||||
tsconfigPath,
|
||||
processTimeoutMs: 120_000,
|
||||
prepare: cwd => writeFile(join(cwd, 'task.txt'), 'value=before\n'),
|
||||
inspect: async (cwd) => { verified = await readFile(join(cwd, 'task.txt'), 'utf8') },
|
||||
})
|
||||
expect(verified).toBe('value=after\n')
|
||||
expect(stdout.trim().length).toBeGreaterThan(0)
|
||||
}, 135_000)
|
||||
})
|
||||
Reference in New Issue
Block a user