-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathdefinitions.test.ts
More file actions
50 lines (43 loc) · 2.07 KB
/
Copy pathdefinitions.test.ts
File metadata and controls
50 lines (43 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { AGENT_DEFINITIONS } from './definitions.js';
import { AgentInvocationContext } from './types.js';
const invocationContext: AgentInvocationContext = {
systemPrompt: 'system prompt contents',
userPrompt: 'user prompt contents',
workspaceRoot: '/virtual/workspace',
handoffDir: '/virtual/workspace/node_modules/.cache/grafana-create-plugin/migrate-runs/run-1',
};
function getDefinition(id: string) {
const definition = AGENT_DEFINITIONS.find((agentDefinition) => agentDefinition.id === id);
if (!definition) {
throw new Error(`No agent definition found for ${id}`);
}
return definition;
}
describe('AGENT_DEFINITIONS', () => {
it('should define claude-code and codex in preference order', () => {
expect(AGENT_DEFINITIONS.map((agentDefinition) => agentDefinition.id)).toEqual(['claude-code', 'codex']);
});
AGENT_DEFINITIONS.forEach((definition) => {
describe(definition.id, () => {
it('should have at least one binary name to probe', () => {
expect(definition.binaryNames.length).toBeGreaterThan(0);
});
it('should embed both prompts in the interactive invocation', () => {
const invocation = definition.buildInteractive(invocationContext);
const serialisedArgs = invocation.args.join(' ');
expect(serialisedArgs).toContain(invocationContext.systemPrompt);
expect(serialisedArgs).toContain(invocationContext.userPrompt);
});
});
});
it('should pre-authorize the handoff write for claude-code', () => {
const invocation = getDefinition('claude-code').buildInteractive(invocationContext);
const allowedToolsIndex = invocation.args.indexOf('--allowedTools');
expect(allowedToolsIndex).toBeGreaterThan(-1);
expect(invocation.args[allowedToolsIndex + 1]).toBe(`Write(${invocationContext.handoffDir}/**)`);
});
it('should pass the system prompt as developer instructions for codex', () => {
const invocation = getDefinition('codex').buildInteractive(invocationContext);
expect(invocation.args).toContain(`developer_instructions=${invocationContext.systemPrompt}`);
});
});