Skip to content

Commit f6d4330

Browse files
committed
Added a settings panel
1 parent a91eb1e commit f6d4330

26 files changed

Lines changed: 675 additions & 12269 deletions

‎package-lock.json‎

Lines changed: 0 additions & 12215 deletions
This file was deleted.

‎packages/codingcode/src/agent/agent.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,13 @@ export function agentLoop(
490490
yield* q.offer({ _tag: 'ToolDenied', id: r.id, name: r.name, reason: r.reason });
491491
} else {
492492
const isOk = r.type === 'ok';
493-
yield* q.offer({ _tag: 'ToolResult', id: r.id, name: r.name, output: resultOut, ok: isOk });
493+
yield* q.offer({
494+
_tag: 'ToolResult',
495+
id: r.id,
496+
name: r.name,
497+
output: resultOut,
498+
ok: isOk,
499+
});
494500
}
495501
if (!messages.find((m) => m.tool_call_id === r.id)) {
496502
const content =

‎packages/codingcode/src/client/direct/sessions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Effect } from 'effect';
1+
import { Effect } from 'effect';
22
import { SessionService } from '../../session/store.js';
33
import { WorkspaceService } from '../../core/workspace.js';
44
import { deleteSession } from '../../session/file-ops.js';

‎packages/codingcode/src/memory/index.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { updateMemoryEnabled } from '@codingcode/infra/config';
1919
import { extractMemory } from './extractor.js';
2020
import type { StructuredTranscript } from './types.js';
2121

22+
const MAX_BYTES = 16384;
23+
const PROMPT_MAX_BYTES = 8192;
24+
2225
export class MemoryService extends Effect.Service<MemoryService>()('Memory', {
2326
effect: Effect.gen(function* () {
2427
const factory = yield* LLMFactoryService;
@@ -44,7 +47,7 @@ export class MemoryService extends Effect.Service<MemoryService>()('Memory', {
4447
if (!projectAuto) return '';
4548

4649
const stripped = stripMarkersForPrompt(projectAuto);
47-
const truncated = truncateForPrompt(stripped, cfg.promptMaxBytes);
50+
const truncated = truncateForPrompt(stripped, PROMPT_MAX_BYTES);
4851

4952
return truncated ? `## Long-term Memory\n\n${truncated}` : '';
5053
}
@@ -165,7 +168,7 @@ export class MemoryService extends Effect.Service<MemoryService>()('Memory', {
165168
const projectContentFresh = readMemoryFile(projectPath);
166169
const projectAutoFresh = extractAutoBlock(projectContentFresh);
167170
const merged = mergeAutoBlocks(projectAutoFresh, extracted);
168-
const truncated = enforceMaxBytes(merged, cfg.maxBytes);
171+
const truncated = enforceMaxBytes(merged, MAX_BYTES);
169172
const newProjectContent = replaceAutoBlock(projectContentFresh, truncated);
170173

171174
writeMemoryFileAtomic(projectPath, newProjectContent);

‎packages/codingcode/src/server/routes/settings.ts‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ import {
7070
updateMemoryExtraType as _updateMemoryExtraType,
7171
deleteMemoryExtraType as _deleteMemoryExtraType,
7272
} from '../../memory/config.js';
73+
import {
74+
loadConfig,
75+
updateMaxSteps,
76+
updateMaxStopContinuations,
77+
updateContextCompactionModel,
78+
updateMemoryModel,
79+
} from '@codingcode/infra/config';
7380
import { MemoryService } from '../../memory/index.js';
7481
import { createRunWithLayer, errorResponse } from '../util.js';
7582

@@ -268,7 +275,11 @@ export async function createSettingsRouter(rt: ManagedRt): Promise<Hono> {
268275
// ---- Memory ----
269276
settingsRouter.get('/memory/config', (c) => {
270277
const cfg = getMemoryConfig();
271-
return c.json({ enabled: cfg.enabled, types: getAllTypesWithStatus(cfg) });
278+
return c.json({
279+
enabled: cfg.enabled,
280+
types: getAllTypesWithStatus(cfg),
281+
model: cfg.model,
282+
});
272283
});
273284

274285
settingsRouter.post('/memory/enabled', async (c) => {
@@ -333,6 +344,34 @@ export async function createSettingsRouter(rt: ManagedRt): Promise<Hono> {
333344
}
334345
});
335346

347+
settingsRouter.post('/memory/model', async (c) => {
348+
const body = (await c.req.json()) as { model: string };
349+
updateMemoryModel(body.model);
350+
return c.json({ model: body.model });
351+
});
352+
353+
// ---- Agent config ----
354+
settingsRouter.get('/agent/config', (c) => {
355+
const cfg = loadConfig();
356+
return c.json({ maxSteps: cfg.maxSteps, maxStopContinuations: cfg.maxStopContinuations });
357+
});
358+
359+
settingsRouter.post('/agent/config', async (c) => {
360+
const body = (await c.req.json()) as { maxSteps?: number; maxStopContinuations?: number };
361+
if (body.maxSteps !== undefined) updateMaxSteps(body.maxSteps);
362+
if (body.maxStopContinuations !== undefined)
363+
updateMaxStopContinuations(body.maxStopContinuations);
364+
const cfg = loadConfig();
365+
return c.json({ maxSteps: cfg.maxSteps, maxStopContinuations: cfg.maxStopContinuations });
366+
});
367+
368+
// ---- Context config ----
369+
settingsRouter.post('/context/compaction-model', async (c) => {
370+
const body = (await c.req.json()) as { compactionModel: string };
371+
updateContextCompactionModel(body.compactionModel);
372+
return c.json({ compactionModel: body.compactionModel });
373+
});
374+
336375
// ---- Agents ----
337376
settingsRouter.get('/agents', (c) => {
338377
const rawCwd = c.req.query('cwd');

‎packages/codingcode/test/context/append-turn-end.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ describe('appendTurnEnd', () => {
6666
const parsed = JSON.parse(serialized);
6767
expect(parsed.tokenCount).toBe(tokens);
6868
});
69-
7069
});

‎packages/codingcode/test/context/tokens.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, it, expect } from 'vitest';
22
import {
33
estimateTokensForContent,
44
estimateTokens,

‎packages/codingcode/test/core/workspace.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
22
import { Effect } from 'effect';
33
import { mkdirSync, rmSync, writeFileSync } from 'fs';
44
import { join } from 'path';

‎packages/codingcode/test/memory/config.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ function makeCfg(overrides?: Partial<MemoryConfig>): MemoryConfig {
2727
return {
2828
enabled: true,
2929
model: '',
30-
maxBytes: 16384,
31-
promptMaxBytes: 8192,
3230
extraTypes: [],
3331
disabledTypes: [],
3432
...overrides,

‎packages/codingcode/test/self/todo/service.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, it, expect } from 'vitest';
22
import { Effect } from 'effect';
33
import { TodoService, countByStatus } from '../../../src/agent/todo.js';
44
import type { Todo } from '../../../src/agent/types.js';

0 commit comments

Comments
 (0)