mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
Rename the tool-presentation transport from code-mode to ptc everywhere that is not written into session logs: the mode config value becomes 'ptc', the preset directory/id becomes ptc, the demo becomes demo:ptc, the dispatch waterfall becomes tools/ptc-dispatch-log (types PtcDispatch*), the prompt rule becomes tools:ptc-only, source/test files become ptc.ts etc., and prose says PTC mode / PTC 模式. The session-persistent vocabulary (durable events tool/code-dispatch*, logged plugin name tools-code-mode, sub-call id segment :code:) intentionally stays and moves in the stacked persistence PR, which is blocked until the SESSION_FORMAT_VERSION v0→v1 migration lands with it. run_code, its code parameter, CodeSdkLanguage, CodeRunFailedError, the dsh-code-runtime family, third-party codex names, and frozen archived notes keep their names.
107 lines
4.1 KiB
TypeScript
107 lines
4.1 KiB
TypeScript
/** Application-entrypoint classification and dsh-launch enforcement. */
|
|
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { dirname, join, resolve } from 'node:path'
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { applicationEntrypointViolations } from './verify-application-entrypoints.ts'
|
|
|
|
const cleanups: string[] = []
|
|
|
|
afterEach(() => {
|
|
for (const path of cleanups.splice(0)) rmSync(path, { recursive: true, force: true })
|
|
})
|
|
|
|
function fixture(): string {
|
|
const root = mkdtempSync(join(tmpdir(), 'dsh-application-entrypoints-'))
|
|
cleanups.push(root)
|
|
return root
|
|
}
|
|
|
|
function write(root: string, path: string, content: string): void {
|
|
const target = resolve(root, path)
|
|
mkdirSync(dirname(target), { recursive: true })
|
|
writeFileSync(target, content)
|
|
}
|
|
|
|
describe('application entrypoints', () => {
|
|
it('accepts the repository launcher inventory', () => {
|
|
expect(applicationEntrypointViolations(resolve(import.meta.dirname, '..'))).toEqual([])
|
|
})
|
|
|
|
it('rejects a package-level application bin', () => {
|
|
const root = fixture()
|
|
write(root, 'packages/example/app/package.json', JSON.stringify({ bin: { app: 'lib/bin.js' } }))
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'packages/example/app/package.json: package bin bypasses the dsh launcher; applications use apps/cli profiles',
|
|
])
|
|
})
|
|
|
|
it('rejects an unclassified executable source', () => {
|
|
const root = fixture()
|
|
write(root, 'packages/example/app/src/bin.ts', '#!/usr/bin/env node\n')
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'packages/example/app/src/bin.ts: executable source has no application/build/test classification',
|
|
])
|
|
})
|
|
|
|
it('rejects an executable at an application package root', () => {
|
|
const root = fixture()
|
|
write(root, 'apps/example/rogue.mjs', '#!/usr/bin/env node\n')
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'apps/example/rogue.mjs: executable source has no application/build/test classification',
|
|
])
|
|
})
|
|
|
|
it('rejects an executable at the repository root', () => {
|
|
const root = fixture()
|
|
write(root, 'rogue.mjs', '#!/usr/bin/env node\n')
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'rogue.mjs: executable source has no application/build/test classification',
|
|
])
|
|
})
|
|
|
|
it('rejects an unclassified executable in an app workspace', () => {
|
|
const root = fixture()
|
|
write(root, 'apps/rogue/src/bin.ts', '#!/usr/bin/env node\n')
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'apps/rogue/src/bin.ts: executable source has no application/build/test classification',
|
|
])
|
|
})
|
|
|
|
it('rejects a private Python application carrier outside dsh', () => {
|
|
const root = fixture()
|
|
write(root, 'packages/sdk/rogue-python-runtime/package.json', JSON.stringify({ private: true }))
|
|
write(root, 'packages/sdk/rogue-python-runtime/src/bin.ts', '#!/usr/bin/env node\n')
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'packages/sdk/rogue-python-runtime/src/bin.ts: executable source has no application/build/test classification',
|
|
])
|
|
})
|
|
|
|
it('rejects a classified demo wrapper that launches a package entry', () => {
|
|
const root = fixture()
|
|
write(root, 'package.json', JSON.stringify({ scripts: { 'demo:ptc': 'node scripts/demo-ptc.mjs' } }))
|
|
write(root, 'scripts/demo-ptc.mjs', "spawn('node', ['packages/example/app/src/bin.ts'])\n")
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'scripts/demo-ptc.mjs: application demo wrapper must launch apps/cli/src/bin.ts',
|
|
'scripts/demo-ptc.mjs: application demo wrapper must not launch a package entry directly',
|
|
])
|
|
})
|
|
|
|
it('rejects a new root demo until its launch role is classified', () => {
|
|
const root = fixture()
|
|
write(root, 'package.json', JSON.stringify({ scripts: { 'demo:new-app': 'dsh --profile new-app' } }))
|
|
|
|
expect(applicationEntrypointViolations(root)).toEqual([
|
|
'package.json scripts.demo:new-app: demo launcher has no explicit dsh or in-process classification',
|
|
])
|
|
})
|
|
})
|