Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/agent-cache-stability.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const mockState = {
sessionMeta: { model: 'test-model', createdAt: new Date().toISOString() } as any,
model: 'test-model',
title: 'cache-stability',
mode: 'build' as const,
permissionMode: 'default' as const,
usage: undefined,
memorySnapshot: '',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/agent-concurrent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const mockState = {
sessionMeta: { model: 'test-model', createdAt: new Date().toISOString() } as any,
model: 'test-model',
title: 'concurrent',
mode: 'build' as const,
permissionMode: 'default' as const,
usage: undefined,
memorySnapshot: '',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/agent-todo-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ const mockState = {
sessionMeta: { model: 'test-model', createdAt: new Date().toISOString() } as any,
model: 'test-model',
title: 'test',
mode: 'build' as const,
permissionMode: 'default' as const,
usage: undefined,
memorySnapshot: '',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const mockState = {
sessionMeta: { model: 'test-model', createdAt: new Date().toISOString() } as any,
model: 'test-model',
title: 'test',
mode: 'build' as const,
permissionMode: 'default' as const,
usage: undefined,
memorySnapshot: '',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/hooks-deps-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ describe('agentLoop hooks type', () => {
sessionMeta: { model: 'test-model', createdAt: new Date().toISOString() } as any,
model: 'test-model',
title: 'type-test',
mode: 'build' as const,
permissionMode: 'default' as const,
usage: undefined,
memorySnapshot: '',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/loop-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ describe('agentLoop loop options', () => {
model: 'test-model',
title: 'test',
usage: undefined,
mode: 'build' as const,
permissionMode: 'default' as const,
projectPath: '',
transcriptPath: '',
indexPath: '',
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/memory-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ function makeState(memorySnapshot: string = '') {
model: 'test-model',
title: 'memory-test',
usage: undefined,
mode: 'build' as const,
permissionMode: 'default' as const,
memorySnapshot,
};
}
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/stop-hook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ describe('agentLoop stop hook', () => {
model: 'test-model',
title: 'test',
usage: undefined,
mode: 'build' as const,
permissionMode: 'default' as const,
projectPath: '',
transcriptPath: '',
indexPath: '',
Expand Down
2 changes: 2 additions & 0 deletions packages/codingcode/test/agent/submit-plan-turn-end.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const mockState = {
model: 'test-model',
title: 'test',
usage: undefined,
mode: 'build' as const,
permissionMode: 'default' as const,
projectPath: 'test-project',
transcriptPath: '/tmp/test.jsonl',
indexPath: '/tmp/test.index.json',
Expand Down
4 changes: 3 additions & 1 deletion packages/codingcode/test/client/direct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ describe('createDirectModelClient operations', () => {
const fetchSpy = vi.spyOn(globalThis, 'fetch');
const client = createDirectModelClient(rt);

await expect(client.switchModel({ id: 'missing-model@MISSING_KEY' })).rejects.toThrow('not found');
await expect(client.switchModel({ id: 'missing-model@MISSING_KEY' })).rejects.toThrow(
'not found'
);

expect(fetchSpy).not.toHaveBeenCalled();
fetchSpy.mockRestore();
Expand Down
9 changes: 6 additions & 3 deletions packages/codingcode/test/client/get-session-plan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('getSessionPlan: http + direct both implement', () => {
it('http calls GET /api/sessions/:id/plan?cwd=...', async () => {
const calls: string[] = [];
const c = createHttpSessionClient({
apiGet: async (p) => {
apiGet: async <T>(p: string) => {
calls.push(p);
return { content: 'plan', path: '/p', directory: '/d', exists: true };
return { content: 'plan', path: '/p', directory: '/d', exists: true } as T;
},
apiPost: async () => null as any,
apiPut: async () => null as any,
Expand All @@ -34,7 +34,10 @@ describe('getSessionPlan: http + direct both implement', () => {
writeFileSync(join(projectDir, 'second.md'), '# second');
setProjectBaseDir(base);
try {
const TestLayer = Layer.mergeAll(SessionService.Default, ProjectRuntimeService.Default);
const TestLayer = Layer.mergeAll(
SessionService.Default,
ProjectRuntimeService.Default
) as Layer.Layer<SessionService | ProjectRuntimeService>;
const rt = ManagedRuntime.make(TestLayer);
const c = createDirectSessionClient(rt as any);
const res = await c.getSessionPlan({ sessionId: 's1', cwd: '/my/cwd' });
Expand Down
20 changes: 12 additions & 8 deletions packages/codingcode/test/client/missing-methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ const TestLayer = Layer.mergeAll(
ApprovalWaitService.Default
);

const rt = ManagedRuntime.make(TestLayer);
const rt = ManagedRuntime.make(
TestLayer as Layer.Layer<
SkillService | HookService | ApprovalService | McpService | ApprovalWaitService | MemoryService
>
);

describe('setMemoryModel: http + direct both implement', () => {
it('http calls POST /api/settings/memory/model', async () => {
const calls: Array<{ path: string; body: unknown }> = [];
const c = createHttpSettingsClient({
apiGet: async () => null as any,
apiPost: async (p, b) => {
apiPost: async <T>(p: string, b?: unknown) => {
calls.push({ path: p, body: b });
return { model: (b as { model: string }).model };
return { model: (b as { model: string }).model } as T;
},
apiPut: async () => null as any,
apiDelete: async () => undefined,
Expand All @@ -90,9 +94,9 @@ describe('getAgentConfig: http + direct both implement', () => {
it('http calls GET /api/settings/agent/config', async () => {
const calls: string[] = [];
const c = createHttpSettingsClient({
apiGet: async (p) => {
apiGet: async <T>(p: string) => {
calls.push(p);
return { maxSteps: 100, maxStopContinuations: 3 };
return { maxSteps: 100, maxStopContinuations: 3 } as T;
},
apiPost: async () => null as any,
apiPut: async () => null as any,
Expand All @@ -116,9 +120,9 @@ describe('setCompactionModel: http + direct both implement', () => {
const calls: Array<{ path: string; body: unknown }> = [];
const c = createHttpSettingsClient({
apiGet: async () => null as any,
apiPost: async (p, b) => {
apiPost: async <T>(p: string, b?: unknown) => {
calls.push({ path: p, body: b });
return { compactionModel: (b as { compactionModel: string }).compactionModel };
return { compactionModel: (b as { compactionModel: string }).compactionModel } as T;
},
apiPut: async () => null as any,
apiDelete: async () => undefined,
Expand All @@ -139,7 +143,7 @@ describe('setCompactionModel: http + direct both implement', () => {
describe('getMemoryConfig returns model field', () => {
it('http typed return includes model', async () => {
const c = createHttpSettingsClient({
apiGet: async () => ({ enabled: true, types: [], model: 'm' }),
apiGet: async <T>() => ({ enabled: true, types: [], model: 'm' }) as T,
apiPost: async () => null as any,
apiPut: async () => null as any,
apiDelete: async () => undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function makeFixture(opts: FixtureOptions) {
title: 'fixture',
currentTurnId: opts.currentTurnId ?? opts.numTurns,
usage: undefined,
mode: 'build',
permissionMode: 'default',
};
writeFileSync(indexPath, JSON.stringify(idx, null, 2), 'utf8');
Expand Down
6 changes: 4 additions & 2 deletions packages/codingcode/test/orchestrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const mockState = {
sessionMeta: null,
model: 'test',
title: 'test-sess',
mode: 'build' as const,
permissionMode: 'default' as const,
usage: undefined,
memorySnapshot: '',
};
Expand Down Expand Up @@ -339,7 +341,7 @@ describe('sendMessage stream', () => {

it('should yield AgentEvent chunks from LLM', async () => {
const sessionId = await setupSession();
const program = sendMessage(sessionId, 'hi', '/tmp/test', mockLlm);
const program = sendMessage(sessionId, 'hi', '/tmp/test', mockLlm, {});
const { stream } = (await Effect.runPromise(
program.pipe(Effect.provide(TestLayer) as any)
)) as any;
Expand All @@ -355,7 +357,7 @@ describe('sendMessage stream', () => {

it('should not return empty event stream for normal LLM response', async () => {
const sessionId = await setupSession();
const program = sendMessage(sessionId, 'hi', '/tmp/test', mockLlm);
const program = sendMessage(sessionId, 'hi', '/tmp/test', mockLlm, {});
const { stream } = (await Effect.runPromise(
program.pipe(Effect.provide(TestLayer) as any)
)) as any;
Expand Down
8 changes: 4 additions & 4 deletions packages/codingcode/test/plan/gate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ describe('planModeGateHook', () => {
});
});

it('denies execute_command in plan mode', () => {
it('denies execute_command in plan mode', async () => {
makeSessionIndex(cwd, sessionId, 'plan');
const result = planModeGateHook({
const result = await planModeGateHook({
toolName: 'execute_command',
sessionId,
projectPath: cwd,
Expand All @@ -97,9 +97,9 @@ describe('planModeGateHook', () => {
expect(result?.reason).toMatch(/plan mode/i);
});

it('denies edit_file in plan mode', () => {
it('denies edit_file in plan mode', async () => {
makeSessionIndex(cwd, sessionId, 'plan');
const result = planModeGateHook({
const result = await planModeGateHook({
toolName: 'edit_file',
sessionId,
projectPath: cwd,
Expand Down
4 changes: 3 additions & 1 deletion packages/codingcode/test/scheduler/approval-bypass.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe('scheduler uses real forked ApprovalService', () => {
'C:/Users/10116/Desktop/agent/coding code/packages/codingcode/src/scheduler/service.ts',
'utf8'
);
expect(src).toMatch(/import\s*\{[^}]*ApprovalService[^}]*\}\s*from\s*['"]\.\.\/approval\/index\.js['"]/);
expect(src).toMatch(
/import\s*\{[^}]*ApprovalService[^}]*\}\s*from\s*['"]\.\.\/approval\/index\.js['"]/
);
});

it('scheduler resolves ApprovalService and forks with bypass', () => {
Expand Down
6 changes: 1 addition & 5 deletions packages/codingcode/test/session/compute-paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { join } from 'path';
import { randomUUID } from 'crypto';
import { Effect } from 'effect';
import { SessionService } from '../../src/session/store.js';
import {
computePaths,
sessionJsonlPathFromCwd,
projectSessionsDir,
} from '../../src/core/path.js';
import { computePaths, sessionJsonlPathFromCwd, projectSessionsDir } from '../../src/core/path.js';
import { normalizePath, encodeProjectPath } from '../../src/core/path.js';
import { useTempProjectBase } from '../helpers/project-base.js';

Expand Down
4 changes: 4 additions & 0 deletions packages/codingcode/test/session/filter-ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function makeBaseEvents(extra: SessionEvent[] = []): SessionEvent[] {
projectPath: 'p',
cwd: '/tmp',
createdAt: new Date().toISOString(),
mode: 'build',
permissionMode: 'default',
},
{ type: 'user', turnId: 1, content: 'hello' },
{ type: 'assistant', turnId: 1, content: 'hi', toolCalls: [] },
Expand Down Expand Up @@ -126,6 +128,8 @@ describe('sessionEventsToTurns with summary', () => {
projectPath: 'p',
cwd: '/tmp',
createdAt: new Date().toISOString(),
mode: 'build',
permissionMode: 'default',
},
{ type: 'user', turnId: 1, content: 'hello' },
{ type: 'assistant', turnId: 1, content: 'hi', toolCalls: [] },
Expand Down
16 changes: 14 additions & 2 deletions packages/codingcode/test/session/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function makeFixture(sessionId: string, slug: string) {
title: 'fixture',
currentTurnId: 3,
usage: undefined,
permissionMode: 'default',
mode: 'build' as const,
permissionMode: 'default' as const,
};
writeFileSync(indexPath, JSON.stringify(idx, null, 2), 'utf8');

Expand Down Expand Up @@ -120,6 +121,8 @@ describe('forkSession', () => {
model: 'test',
title: 'fixture',
usage: undefined,
mode: 'build' as const,
permissionMode: 'default' as const,
memorySnapshot: '',
};

Expand Down Expand Up @@ -162,6 +165,8 @@ describe('forkSession', () => {
currentTurnId: 3,
sessionMeta: null,
model: 'test',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'fixture',
usage: undefined,
memorySnapshot: '',
Expand Down Expand Up @@ -216,6 +221,8 @@ describe('forkSession', () => {
currentTurnId: 3,
sessionMeta: null,
model: 'test',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'fixture',
usage: undefined,
memorySnapshot: '',
Expand Down Expand Up @@ -280,6 +287,8 @@ describe('forkSession', () => {
currentTurnId: 3,
sessionMeta: null,
model: 'test',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'fixture',
usage: undefined,
memorySnapshot: '',
Expand Down Expand Up @@ -343,7 +352,8 @@ describe('forkSession', () => {
title: 'uuid-fixture',
currentTurnId: 2,
usage: undefined,
permissionMode: 'default',
mode: 'build' as const,
permissionMode: 'default' as const,
};
writeFileSync(indexPath, JSON.stringify(idx, null, 2), 'utf8');

Expand All @@ -358,6 +368,8 @@ describe('forkSession', () => {
currentTurnId: 2,
sessionMeta: null,
model: 'test',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'uuid-fixture',
usage: undefined,
memorySnapshot: '',
Expand Down
7 changes: 6 additions & 1 deletion packages/codingcode/test/session/prompt-estimate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function makeFixture(
title: 'fixture',
currentTurnId: 2,
usage: usage ?? undefined,
permissionMode: 'default',
mode: 'build' as const,
permissionMode: 'default' as const,
};
writeFileSync(indexPath, JSON.stringify(idx, null, 2), 'utf8');

Expand Down Expand Up @@ -104,6 +105,8 @@ describe('promptEstimate', () => {
currentTurnId: 2,
sessionMeta: null,
model: 'test-model',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'fixture',
usage,
memorySnapshot: '',
Expand Down Expand Up @@ -137,6 +140,8 @@ describe('promptEstimate', () => {
currentTurnId: 2,
sessionMeta: null,
model: 'test-model',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'fixture',
usage: undefined,
memorySnapshot: '',
Expand Down
1 change: 1 addition & 0 deletions packages/codingcode/test/session/rollback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function makeFixture(sessionId: string, slug: string) {
title: 'fixture',
currentTurnId: 3,
usage: undefined,
mode: 'build',
permissionMode: 'default',
};
writeFileSync(indexPath, JSON.stringify(idx, null, 2), 'utf8');
Expand Down
5 changes: 5 additions & 0 deletions packages/codingcode/test/session/store-compact-usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function makeFixture(
title: 'fixture',
currentTurnId: turns.length,
usage: turns[turns.length - 1]?.usage,
mode: 'build',
permissionMode: 'default',
};
writeFileSync(indexPath, JSON.stringify(idx, null, 2), 'utf8');
Expand Down Expand Up @@ -91,8 +92,12 @@ function buildState(
projectPath: encodeProjectPath('/tmp/test'),
cwd: '/tmp/test',
createdAt: new Date().toISOString(),
mode: 'build' as const,
permissionMode: 'default' as const,
},
model: 'test-model',
mode: 'build' as const,
permissionMode: 'default' as const,
title: 'fixture',
usage: initialUsage,
memorySnapshot: '',
Expand Down
Loading
Loading