repositories / will

will

owned by bugabinga

agent: make model+thinking deployment config; dev overlay trusts gitignore

61fff2eea35a60f73b4fa20e64a612c21c9c51e4

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

ZAI_ANALYSIS_MODEL existed but was undocumented; ZAI_THINKING_LEVEL was
missing entirely, leaving the resident session on Pi's implicit default.
Both now flow: env -> config -> createAgentSession (unknown level fails
at boot; Pi clamps model-unsupported levels).

git-init dev overlay replaced its hand-maintained rsync exclude list
with gitignore-driven filtering, so secrets like .env and runtime junk
(test-results/, models-store.json) never enter will's dev genome while
node_modules/.dev stay delete-protected.

Changed files (6)

+47 / −5 text lines

Diff layout

.env.example

Modified

+2 / −0 text lines

66WILL_TELEGRAM_CHAT_ID=-100
77WILL_TELEGRAM_OLIVER_ID=1
88# ZAI_API_KEY=... # real model session (leave unset for fake)
9# ZAI_ANALYSIS_MODEL=glm-5.3-flash
10# ZAI_THINKING_LEVEL=medium # off|minimal|low|medium|high|xhigh|max
911# WILL_DEPLOY_API_URL=... # deployment platform (absent => tools fail closed)
1012# WILL_LUCI_BASE_URL=https://ci.bugabinga.net
1113# WILL_LUCI_REPO=will

compose.yaml

Modified

+2 / −0 text lines

6969 # real session whenever the key is present; WILL_SESSION_MODE=fake forces fake
7070 WILL_SESSION_MODE: ${WILL_SESSION_MODE:-}
7171 ZAI_API_KEY: ${ZAI_API_KEY:-}
72 ZAI_ANALYSIS_MODEL: ${ZAI_ANALYSIS_MODEL:-}
73 ZAI_THINKING_LEVEL: ${ZAI_THINKING_LEVEL:-}
7274 WILL_AGENT_DIR: /will-dev/agent
7375 # dev genome: will's own clone; commit+push loops run against the dev origin
7476 WILL_WORK_DIR: /will-dev/work

deploy/dev/git-init.sh

Modified

+4 / −3 text lines

3434# 4. overlay the dirty workspace state, committed as dev-sync.
3535# Skipped when will left uncommitted work, so nothing is clobbered.
3636if [ -z "$(git -C "$WORK" status --porcelain)" ]; then
37 rsync -a --delete \
38 --exclude .git --exclude node_modules --exclude .dev \
39 --exclude dist --exclude web/dist --exclude docs/dist --exclude coverage \
37 # Mirror the workspace minus gitignored files: .gitignore is the single
38 # source of truth, so secrets like .env never enter will's genome. rsync
39 # excludes are also delete-protected, keeping dest node_modules/.dev intact.
40 rsync -a --delete --filter=':- .gitignore' --filter='- /.git' \
4041 /workspace/ "$WORK/"
4142 git -C "$WORK" add -A
4243 git -C "$WORK" -c user.name=dev-sync -c user.email=dev-sync@local \

src/agent/config.test.ts

Modified

+13 / −1 text lines

11import assert from 'node:assert/strict'
22import { test } from 'node:test'
3import { resolveSessionMode } from './config.ts'
3import { loadAgentConfig, resolveSessionMode } from './config.ts'
55test('explicit fake wins even with a key', () => {
66 assert.equal(resolveSessionMode({ WILL_SESSION_MODE: 'fake', ZAI_API_KEY: 'k' }), 'fake')
2121test('explicit real with a key is real', () => {
2222 assert.equal(resolveSessionMode({ WILL_SESSION_MODE: 'real', ZAI_API_KEY: 'k' }), 'real')
2323})
25test('thinking level defaults to medium', () => {
26 assert.equal(loadAgentConfig({}).zai.thinkingLevel, 'medium')
27})
29test('ZAI_THINKING_LEVEL overrides the default', () => {
30 assert.equal(loadAgentConfig({ ZAI_THINKING_LEVEL: 'max' }).zai.thinkingLevel, 'max')
31})
33test('unknown ZAI_THINKING_LEVEL fails loudly', () => {
34 assert.throws(() => loadAgentConfig({ ZAI_THINKING_LEVEL: 'ultra' }), /ZAI_THINKING_LEVEL/)
35})

src/agent/config.ts

Modified

+25 / −1 text lines

2424 zai: {
2525 apiKey?: string | undefined
2626 baseUrl: string
27 /** multimodal coding model used by zai_analyze_media (pinned deployment config) */
27 /** multimodal coding model used by zai_analyze_media and the resident session (pinned deployment config) */
2828 analysisModel: string
29 /** resident session thinking level; Pi default 'medium' made explicit (pinned deployment config) */
30 thinkingLevel: ThinkingLevel
2931 mcp: { enabled: boolean; serverCommand: string[] }
3032 }
3133 deployApiUrl?: string | undefined
3941export type SessionMode = 'real' | 'fake'
43/** Pi thinking levels; the model clamps unsupported ones (see thinkingLevelMap) */
44export type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'
46const THINKING_LEVELS: readonly ThinkingLevel[] = [
47 'off',
48 'minimal',
49 'low',
50 'medium',
51 'high',
52 'xhigh',
53 'max',
54]
56function thinkingLevelFromEnv(env: NodeJS.ProcessEnv): ThinkingLevel {
57 const raw = env.ZAI_THINKING_LEVEL ?? 'medium'
58 if (!(THINKING_LEVELS as readonly string[]).includes(raw)) {
59 throw new Error(`ZAI_THINKING_LEVEL must be one of ${THINKING_LEVELS.join('|')}; got '${raw}'`)
60 }
61 return raw as ThinkingLevel
62}
4164/**
4265 * Session selection: explicit fake wins; explicit real demands a key;
4366 * unset falls back by key presence so `ZAI_API_KEY=... mise run dev`
80103 apiKey: envOpt('ZAI_API_KEY'),
81104 baseUrl: envStr('ZAI_BASE_URL', 'https://api.z.ai/api'),
82105 analysisModel: envStr('ZAI_ANALYSIS_MODEL', 'glm-5.3-flash'),
106 thinkingLevel: thinkingLevelFromEnv(env),
83107 mcp: {
84108 enabled: env.WILL_ZAI_MCP === '1',
85109 serverCommand: [

src/agent/pi-session.ts

Modified

+1 / −0 text lines

8888 cwd: cfg.resourceDir,
8989 agentDir: join(cfg.agentDir, '.pi-agent'),
9090 model,
91 thinkingLevel: cfg.zai.thinkingLevel,
9192 modelRuntime,
9293 resourceLoader: loader,
9394 sessionManager,