The `task` spec (argv templates, access modes, output dialects) and the capability flags headlessTask, structuredProgress, resumable and liveWaggleDance described how a Waggle Room run drove a coding agent without its UI. Nothing runs tools headless any more, so built-in manifests, the third-party adapter loader and detection results no longer carry them. An adapter file that still declares `task` is rejected like any other unknown key.
58 lines
2.3 KiB
TypeScript
58 lines
2.3 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { loadThirdPartyManifests } from '../src/tool-manifest-loader.js';
|
|
|
|
function deps(files: Record<string, unknown>) {
|
|
return {
|
|
dir: '/fake',
|
|
readDir: () => Object.keys(files),
|
|
readFile: (p: string) => JSON.stringify(files[p.split(/[/\\]/).pop()!]),
|
|
};
|
|
}
|
|
|
|
describe('loadThirdPartyManifests', () => {
|
|
it('loads a valid PATH manifest, stamped builtin:false', () => {
|
|
const out = loadThirdPartyManifests(deps({
|
|
'foo.json': { id: 'foo-cli', displayName: 'Foo', launchable: true, detect: { kind: 'path', binaryName: 'foo' } },
|
|
}));
|
|
expect(out).toHaveLength(1);
|
|
expect(out[0]).toMatchObject({ id: 'foo-cli', builtin: false, detect: { kind: 'path', binaryName: 'foo' } });
|
|
});
|
|
|
|
it('rejects a headless task contract: captured Room tasks are not part of this edition', () => {
|
|
const out = loadThirdPartyManifests(deps({
|
|
'task.json': {
|
|
id: 'task-cli', displayName: 'T', launchable: true, detect: { kind: 'path', binaryName: 'task' },
|
|
task: { argvTemplate: ['run', '{prompt}'], promptTransport: 'arg' },
|
|
},
|
|
}));
|
|
expect(out).toEqual([]);
|
|
});
|
|
|
|
it('rejects detect.kind:candidates (code-only strategy)', () => {
|
|
const out = loadThirdPartyManifests(deps({
|
|
'bad.json': { id: 'bad', displayName: 'B', launchable: true, detect: { kind: 'candidates' } },
|
|
}));
|
|
expect(out).toEqual([]);
|
|
});
|
|
|
|
it('rejects shell-metachar / traversal in fields', () => {
|
|
const out = loadThirdPartyManifests(deps({
|
|
'evil.json': { id: '../evil', displayName: 'E', launchable: true, detect: { kind: 'path', binaryName: 'foo; rm -rf /' } },
|
|
}));
|
|
expect(out).toEqual([]);
|
|
});
|
|
|
|
it('returns [] when the dir is missing (readDir throws)', () => {
|
|
expect(loadThirdPartyManifests({ dir: '/none', readDir: () => { throw new Error('ENOENT'); }, readFile: () => '' })).toEqual([]);
|
|
});
|
|
|
|
it('skips a malformed JSON file but keeps the valid ones', () => {
|
|
const out = loadThirdPartyManifests({
|
|
dir: '/fake',
|
|
readDir: () => ['broken.json', 'ok.json'],
|
|
readFile: (p: string) => (p.includes('broken') ? '{not json' : JSON.stringify({ id: 'ok-cli', displayName: 'OK', launchable: true, detect: { kind: 'path', binaryName: 'ok' } })),
|
|
});
|
|
expect(out.map((m) => m.id)).toEqual(['ok-cli']);
|
|
});
|
|
});
|