@kkelly-offical/kkcode 0.1.6 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -674
- package/README.md +452 -387
- package/package.json +50 -46
- package/src/agent/agent.mjs +19 -2
- package/src/agent/custom-agent-loader.mjs +6 -3
- package/src/agent/generator.mjs +2 -2
- package/src/agent/prompt/assistant.txt +12 -0
- package/src/agent/prompt/bug-hunter.txt +90 -0
- package/src/agent/prompt/frontend-designer.txt +58 -58
- package/src/agent/prompt/guide.txt +1 -1
- package/src/agent/prompt/longagent-blueprint-agent.txt +83 -83
- package/src/agent/prompt/longagent-coding-agent.txt +37 -37
- package/src/agent/prompt/longagent-debugging-agent.txt +46 -46
- package/src/agent/prompt/longagent-preview-agent.txt +63 -63
- package/src/command/custom-commands.mjs +2 -2
- package/src/commands/agent.mjs +1 -1
- package/src/commands/background.mjs +145 -4
- package/src/commands/chat.mjs +117 -76
- package/src/commands/config.mjs +148 -1
- package/src/commands/doctor.mjs +30 -6
- package/src/commands/init.mjs +32 -6
- package/src/commands/longagent.mjs +117 -0
- package/src/commands/mcp.mjs +275 -43
- package/src/commands/permission.mjs +1 -1
- package/src/commands/session.mjs +195 -140
- package/src/commands/skill.mjs +63 -0
- package/src/commands/theme.mjs +1 -1
- package/src/config/defaults.mjs +280 -260
- package/src/config/import-config.mjs +1 -1
- package/src/config/load-config.mjs +61 -4
- package/src/config/schema.mjs +591 -574
- package/src/context.mjs +4 -1
- package/src/core/constants.mjs +97 -91
- package/src/core/types.mjs +1 -1
- package/src/github/api.mjs +78 -78
- package/src/github/auth.mjs +294 -286
- package/src/github/flow.mjs +298 -298
- package/src/github/workspace.mjs +225 -212
- package/src/index.mjs +84 -82
- package/src/knowledge/frontend-aesthetics.txt +38 -38
- package/src/mcp/client-http.mjs +139 -141
- package/src/mcp/client-sse.mjs +297 -288
- package/src/mcp/client-stdio.mjs +534 -533
- package/src/mcp/constants.mjs +2 -2
- package/src/mcp/registry.mjs +498 -479
- package/src/mcp/stdio-framing.mjs +135 -133
- package/src/mcp/tool-result.mjs +24 -24
- package/src/observability/edit-diagnostics.mjs +449 -0
- package/src/observability/index.mjs +42 -42
- package/src/observability/metrics.mjs +165 -137
- package/src/observability/tracer.mjs +137 -137
- package/src/onboarding.mjs +209 -0
- package/src/orchestration/background-manager.mjs +567 -372
- package/src/orchestration/background-worker.mjs +419 -305
- package/src/orchestration/interruption-reason.mjs +21 -0
- package/src/orchestration/longagent-manager.mjs +197 -171
- package/src/orchestration/stage-scheduler.mjs +733 -728
- package/src/orchestration/subagent-router.mjs +7 -1
- package/src/orchestration/task-scheduler.mjs +219 -7
- package/src/permission/engine.mjs +1 -1
- package/src/permission/exec-policy.mjs +370 -370
- package/src/permission/file-edit-policy.mjs +108 -0
- package/src/permission/prompt.mjs +1 -1
- package/src/permission/rules.mjs +116 -7
- package/src/plugin/builtin-hooks/post-edit-format.mjs +2 -1
- package/src/plugin/builtin-hooks/post-edit-typecheck.mjs +104 -40
- package/src/plugin/hook-bus.mjs +19 -5
- package/src/plugin/manifest-loader.mjs +222 -0
- package/src/provider/anthropic.mjs +396 -390
- package/src/provider/ollama.mjs +7 -1
- package/src/provider/openai.mjs +382 -340
- package/src/provider/retry-policy.mjs +74 -68
- package/src/provider/router.mjs +242 -241
- package/src/provider/sse.mjs +104 -104
- package/src/provider/wizard.mjs +556 -0
- package/src/repl/capability-facade.mjs +30 -0
- package/src/repl/command-surface.mjs +23 -0
- package/src/repl/controller-entry.mjs +40 -0
- package/src/repl/core-shell.mjs +208 -0
- package/src/repl/dialog-router.mjs +87 -0
- package/src/repl/input-engine.mjs +76 -0
- package/src/repl/keymap.mjs +7 -0
- package/src/repl/operator-surface.mjs +15 -0
- package/src/repl/permission-flow.mjs +49 -0
- package/src/repl/runtime-facade.mjs +36 -0
- package/src/repl/slash-router.mjs +62 -0
- package/src/repl/state-store.mjs +29 -0
- package/src/repl/turn-controller.mjs +58 -0
- package/src/repl/verification.mjs +23 -0
- package/src/repl.mjs +3368 -2929
- package/src/rules/load-rules.mjs +3 -3
- package/src/runtime.mjs +1 -1
- package/src/session/agent-transaction.mjs +86 -0
- package/src/session/checkpoint.mjs +302 -302
- package/src/session/compaction.mjs +36 -14
- package/src/session/engine.mjs +417 -227
- package/src/session/longagent-4stage.mjs +467 -460
- package/src/session/longagent-hybrid.mjs +1344 -1081
- package/src/session/longagent-plan.mjs +376 -365
- package/src/session/longagent-project-memory.mjs +53 -53
- package/src/session/longagent-scaffold.mjs +291 -291
- package/src/session/longagent-task-bus.mjs +138 -54
- package/src/session/longagent-utils.mjs +828 -472
- package/src/session/longagent.mjs +911 -884
- package/src/session/loop.mjs +1005 -905
- package/src/session/prompt/agent.txt +25 -0
- package/src/session/prompt/anthropic.txt +150 -150
- package/src/session/prompt/beast.txt +1 -1
- package/src/session/prompt/plan.txt +28 -6
- package/src/session/prompt/qwen.txt +46 -46
- package/src/session/recovery.mjs +21 -0
- package/src/session/rollback.mjs +197 -0
- package/src/session/routing-observability.mjs +72 -0
- package/src/session/runtime-state.mjs +47 -0
- package/src/session/store.mjs +523 -510
- package/src/session/system-prompt.mjs +56 -8
- package/src/session/task-validator.mjs +267 -267
- package/src/session/usability-gates.mjs +2 -2
- package/src/skill/builtin/commit.mjs +64 -64
- package/src/skill/builtin/design.mjs +76 -76
- package/src/skill/generator.mjs +18 -2
- package/src/skill/registry.mjs +642 -390
- package/src/storage/audit-store.mjs +18 -11
- package/src/storage/event-log.mjs +7 -1
- package/src/storage/ghost-commit-store.mjs +243 -245
- package/src/storage/paths.mjs +13 -0
- package/src/theme/default-theme.mjs +1 -1
- package/src/theme/markdown.mjs +4 -0
- package/src/theme/schema.mjs +1 -1
- package/src/theme/status-bar.mjs +162 -158
- package/src/tool/audit-wrapper.mjs +18 -2
- package/src/tool/edit-transaction.mjs +23 -0
- package/src/tool/executor.mjs +26 -1
- package/src/tool/file-read-state.mjs +65 -0
- package/src/tool/git-auto.mjs +526 -526
- package/src/tool/git-full-auto.mjs +487 -478
- package/src/tool/mutation-guard.mjs +54 -0
- package/src/tool/prompt/edit.txt +3 -3
- package/src/tool/prompt/multiedit.txt +1 -0
- package/src/tool/prompt/notebookedit.txt +2 -1
- package/src/tool/prompt/patch.txt +25 -24
- package/src/tool/prompt/read.txt +3 -3
- package/src/tool/prompt/sysinfo.txt +29 -0
- package/src/tool/prompt/task.txt +66 -4
- package/src/tool/prompt/write.txt +2 -2
- package/src/tool/question-prompt.mjs +17 -4
- package/src/tool/registry.mjs +1701 -1343
- package/src/tool/task-tool.mjs +14 -6
- package/src/ui/activity-renderer.mjs +667 -664
- package/src/ui/repl-background-panel.mjs +7 -0
- package/src/ui/repl-capability-panel.mjs +9 -0
- package/src/ui/repl-dashboard.mjs +54 -4
- package/src/ui/repl-help.mjs +110 -0
- package/src/ui/repl-operator-panel.mjs +12 -0
- package/src/ui/repl-route-feedback.mjs +35 -0
- package/src/ui/repl-status-view.mjs +76 -0
- package/src/ui/repl-task-panel.mjs +5 -0
- package/src/ui/repl-transcript-panel.mjs +56 -0
- package/src/ui/repl-turn-summary.mjs +135 -0
- package/src/usage/pricing.mjs +122 -121
- package/src/usage/usage-meter.mjs +1 -0
- package/src/util/git.mjs +562 -519
- package/src/util/template.mjs +6 -1
package/src/config/defaults.mjs
CHANGED
|
@@ -1,260 +1,280 @@
|
|
|
1
|
-
export const DEFAULT_CONFIG = {
|
|
2
|
-
language: "en",
|
|
3
|
-
provider: {
|
|
4
|
-
default: "openai",
|
|
5
|
-
strict_mode: false,
|
|
6
|
-
openai: {
|
|
7
|
-
base_url: "https://api.openai.com/v1",
|
|
8
|
-
api_key_env: "OPENAI_API_KEY",
|
|
9
|
-
default_model: "gpt-5.3-codex",
|
|
10
|
-
models: ["gpt-5.3-codex", "gpt-5.2"],
|
|
11
|
-
timeout_ms: 120000,
|
|
12
|
-
stream_idle_timeout_ms: 120000,
|
|
13
|
-
max_tokens: 32768,
|
|
14
|
-
context_limit: null,
|
|
15
|
-
retry_attempts: 3,
|
|
16
|
-
retry_base_delay_ms: 800,
|
|
17
|
-
stream: true,
|
|
18
|
-
thinking: null
|
|
19
|
-
},
|
|
20
|
-
anthropic: {
|
|
21
|
-
base_url: "https://api.anthropic.com/v1",
|
|
22
|
-
api_key_env: "ANTHROPIC_API_KEY",
|
|
23
|
-
default_model: "claude-opus-4-6",
|
|
24
|
-
models: ["claude-sonnet-4-5", "claude-sonnet-4-6", "claude-haiku-4-5-20251001", "claude-opus-4-6"],
|
|
25
|
-
timeout_ms: 120000,
|
|
26
|
-
stream_idle_timeout_ms: 120000,
|
|
27
|
-
max_tokens: 32768,
|
|
28
|
-
context_limit: null,
|
|
29
|
-
retry_attempts: 3,
|
|
30
|
-
retry_base_delay_ms: 800,
|
|
31
|
-
stream: true,
|
|
32
|
-
thinking: null
|
|
33
|
-
},
|
|
34
|
-
ollama: {
|
|
35
|
-
base_url: "http://localhost:11434",
|
|
36
|
-
api_key_env: "",
|
|
37
|
-
default_model: "llama3.1",
|
|
38
|
-
timeout_ms: 300000,
|
|
39
|
-
stream_idle_timeout_ms: 300000,
|
|
40
|
-
max_tokens: 32768,
|
|
41
|
-
context_limit: null,
|
|
42
|
-
retry_attempts: 1,
|
|
43
|
-
retry_base_delay_ms: 1000,
|
|
44
|
-
stream: true,
|
|
45
|
-
thinking: null
|
|
46
|
-
},
|
|
47
|
-
model_context: {}
|
|
48
|
-
},
|
|
49
|
-
agent: {
|
|
50
|
-
default_mode: "
|
|
51
|
-
max_steps: 8,
|
|
52
|
-
longagent: {
|
|
53
|
-
max_iterations: 0,
|
|
54
|
-
no_progress_warning: 3,
|
|
55
|
-
no_progress_limit: 5,
|
|
56
|
-
max_stage_recoveries: 3,
|
|
57
|
-
heartbeat_timeout_ms: 120000,
|
|
58
|
-
checkpoint_interval: 5,
|
|
59
|
-
lock_timeout_ms: 5000,
|
|
60
|
-
parallel: {
|
|
61
|
-
enabled: true,
|
|
62
|
-
max_concurrency: 3,
|
|
63
|
-
stage_pass_rule: "all_success",
|
|
64
|
-
task_timeout_ms: 600000,
|
|
65
|
-
task_max_retries: 2,
|
|
66
|
-
poll_interval_ms: 300
|
|
67
|
-
},
|
|
68
|
-
planner: {
|
|
69
|
-
intake_questions: {
|
|
70
|
-
enabled: true,
|
|
71
|
-
max_rounds: 6
|
|
72
|
-
},
|
|
73
|
-
ask_user_after_plan_frozen: false
|
|
74
|
-
},
|
|
75
|
-
four_stage: {
|
|
76
|
-
enabled: false,
|
|
77
|
-
preview_max_iterations: 10,
|
|
78
|
-
blueprint_max_iterations: 10,
|
|
79
|
-
coding_max_iterations: 50,
|
|
80
|
-
debugging_max_iterations: 20,
|
|
81
|
-
separate_models: {
|
|
82
|
-
enabled: false,
|
|
83
|
-
preview_model: null,
|
|
84
|
-
blueprint_model: null,
|
|
85
|
-
coding_model: null,
|
|
86
|
-
debugging_model: null
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
hybrid: {
|
|
90
|
-
enabled: true,
|
|
91
|
-
intake: true,
|
|
92
|
-
completion_validation: true,
|
|
93
|
-
debugging_max_iterations: 20,
|
|
94
|
-
max_coding_rollbacks: 2,
|
|
95
|
-
parallel_preview: true,
|
|
96
|
-
blueprint_review: false,
|
|
97
|
-
blueprint_validation: true,
|
|
98
|
-
tdd_mode: false,
|
|
99
|
-
cross_review: true,
|
|
100
|
-
incremental_gates: true,
|
|
101
|
-
context_pressure_limit: 8000,
|
|
102
|
-
budget_awareness: true,
|
|
103
|
-
checkpoint_resume: true,
|
|
104
|
-
project_memory: true,
|
|
105
|
-
task_bus: true,
|
|
106
|
-
coding_phase_timeout_ms: 1800000,
|
|
107
|
-
debugging_phase_timeout_ms: 600000,
|
|
108
|
-
checkpoint_max_keep: 10,
|
|
109
|
-
checkpoint_cleanup: true,
|
|
110
|
-
degradation: {
|
|
111
|
-
enabled: true,
|
|
112
|
-
fallback_model: null,
|
|
113
|
-
skip_non_critical: true
|
|
114
|
-
},
|
|
115
|
-
separate_models: {
|
|
116
|
-
enabled: false,
|
|
117
|
-
preview_model: null,
|
|
118
|
-
blueprint_model: null,
|
|
119
|
-
debugging_model: null
|
|
120
|
-
},
|
|
121
|
-
adaptive_models: {
|
|
122
|
-
enabled: false,
|
|
123
|
-
low: null,
|
|
124
|
-
medium: null,
|
|
125
|
-
high: null
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
resume_incomplete_files: true,
|
|
129
|
-
scaffold: {
|
|
130
|
-
enabled: true
|
|
131
|
-
},
|
|
132
|
-
git: {
|
|
133
|
-
enabled: "ask",
|
|
134
|
-
auto_branch: true,
|
|
135
|
-
auto_commit_stages: true,
|
|
136
|
-
auto_merge: true,
|
|
137
|
-
branch_prefix: "kkcode"
|
|
138
|
-
},
|
|
139
|
-
usability_gates: {
|
|
140
|
-
prompt_user: "first_run",
|
|
141
|
-
build: { enabled: true },
|
|
142
|
-
test: { enabled: true },
|
|
143
|
-
review: { enabled: true },
|
|
144
|
-
health: { enabled: true },
|
|
145
|
-
budget: { enabled: true }
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
subagents: {},
|
|
149
|
-
routing: {
|
|
150
|
-
categories: {}
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
mcp: {
|
|
154
|
-
servers: {},
|
|
155
|
-
auto_discover: true,
|
|
156
|
-
timeout_ms: 30000,
|
|
157
|
-
max_reconnect_attempts: 5,
|
|
158
|
-
circuit_reset_ms: 60000,
|
|
159
|
-
health_check_interval_ms: 0,
|
|
160
|
-
max_buffer_bytes: 16777216,
|
|
161
|
-
shutdown_timeout_ms: 5000,
|
|
162
|
-
max_sse_buffer_bytes: 4194304
|
|
163
|
-
},
|
|
164
|
-
skills: {
|
|
165
|
-
enabled: true,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
1
|
+
export const DEFAULT_CONFIG = {
|
|
2
|
+
language: "en",
|
|
3
|
+
provider: {
|
|
4
|
+
default: "openai",
|
|
5
|
+
strict_mode: false,
|
|
6
|
+
openai: {
|
|
7
|
+
base_url: "https://api.openai.com/v1",
|
|
8
|
+
api_key_env: "OPENAI_API_KEY",
|
|
9
|
+
default_model: "gpt-5.3-codex",
|
|
10
|
+
models: ["gpt-5.3-codex", "gpt-5.2"],
|
|
11
|
+
timeout_ms: 120000,
|
|
12
|
+
stream_idle_timeout_ms: 120000,
|
|
13
|
+
max_tokens: 32768,
|
|
14
|
+
context_limit: null,
|
|
15
|
+
retry_attempts: 3,
|
|
16
|
+
retry_base_delay_ms: 800,
|
|
17
|
+
stream: true,
|
|
18
|
+
thinking: null
|
|
19
|
+
},
|
|
20
|
+
anthropic: {
|
|
21
|
+
base_url: "https://api.anthropic.com/v1",
|
|
22
|
+
api_key_env: "ANTHROPIC_API_KEY",
|
|
23
|
+
default_model: "claude-opus-4-6",
|
|
24
|
+
models: ["claude-sonnet-4-5", "claude-sonnet-4-6", "claude-haiku-4-5-20251001", "claude-opus-4-6"],
|
|
25
|
+
timeout_ms: 120000,
|
|
26
|
+
stream_idle_timeout_ms: 120000,
|
|
27
|
+
max_tokens: 32768,
|
|
28
|
+
context_limit: null,
|
|
29
|
+
retry_attempts: 3,
|
|
30
|
+
retry_base_delay_ms: 800,
|
|
31
|
+
stream: true,
|
|
32
|
+
thinking: null
|
|
33
|
+
},
|
|
34
|
+
ollama: {
|
|
35
|
+
base_url: "http://localhost:11434",
|
|
36
|
+
api_key_env: "",
|
|
37
|
+
default_model: "llama3.1",
|
|
38
|
+
timeout_ms: 300000,
|
|
39
|
+
stream_idle_timeout_ms: 300000,
|
|
40
|
+
max_tokens: 32768,
|
|
41
|
+
context_limit: null,
|
|
42
|
+
retry_attempts: 1,
|
|
43
|
+
retry_base_delay_ms: 1000,
|
|
44
|
+
stream: true,
|
|
45
|
+
thinking: null
|
|
46
|
+
},
|
|
47
|
+
model_context: {}
|
|
48
|
+
},
|
|
49
|
+
agent: {
|
|
50
|
+
default_mode: "assistant",
|
|
51
|
+
max_steps: 8,
|
|
52
|
+
longagent: {
|
|
53
|
+
max_iterations: 0,
|
|
54
|
+
no_progress_warning: 3,
|
|
55
|
+
no_progress_limit: 5,
|
|
56
|
+
max_stage_recoveries: 3,
|
|
57
|
+
heartbeat_timeout_ms: 120000,
|
|
58
|
+
checkpoint_interval: 5,
|
|
59
|
+
lock_timeout_ms: 5000,
|
|
60
|
+
parallel: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
max_concurrency: 3,
|
|
63
|
+
stage_pass_rule: "all_success",
|
|
64
|
+
task_timeout_ms: 600000,
|
|
65
|
+
task_max_retries: 2,
|
|
66
|
+
poll_interval_ms: 300
|
|
67
|
+
},
|
|
68
|
+
planner: {
|
|
69
|
+
intake_questions: {
|
|
70
|
+
enabled: true,
|
|
71
|
+
max_rounds: 6
|
|
72
|
+
},
|
|
73
|
+
ask_user_after_plan_frozen: false
|
|
74
|
+
},
|
|
75
|
+
four_stage: {
|
|
76
|
+
enabled: false,
|
|
77
|
+
preview_max_iterations: 10,
|
|
78
|
+
blueprint_max_iterations: 10,
|
|
79
|
+
coding_max_iterations: 50,
|
|
80
|
+
debugging_max_iterations: 20,
|
|
81
|
+
separate_models: {
|
|
82
|
+
enabled: false,
|
|
83
|
+
preview_model: null,
|
|
84
|
+
blueprint_model: null,
|
|
85
|
+
coding_model: null,
|
|
86
|
+
debugging_model: null
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
hybrid: {
|
|
90
|
+
enabled: true,
|
|
91
|
+
intake: true,
|
|
92
|
+
completion_validation: true,
|
|
93
|
+
debugging_max_iterations: 20,
|
|
94
|
+
max_coding_rollbacks: 2,
|
|
95
|
+
parallel_preview: true,
|
|
96
|
+
blueprint_review: false,
|
|
97
|
+
blueprint_validation: true,
|
|
98
|
+
tdd_mode: false,
|
|
99
|
+
cross_review: true,
|
|
100
|
+
incremental_gates: true,
|
|
101
|
+
context_pressure_limit: 8000,
|
|
102
|
+
budget_awareness: true,
|
|
103
|
+
checkpoint_resume: true,
|
|
104
|
+
project_memory: true,
|
|
105
|
+
task_bus: true,
|
|
106
|
+
coding_phase_timeout_ms: 1800000,
|
|
107
|
+
debugging_phase_timeout_ms: 600000,
|
|
108
|
+
checkpoint_max_keep: 10,
|
|
109
|
+
checkpoint_cleanup: true,
|
|
110
|
+
degradation: {
|
|
111
|
+
enabled: true,
|
|
112
|
+
fallback_model: null,
|
|
113
|
+
skip_non_critical: true
|
|
114
|
+
},
|
|
115
|
+
separate_models: {
|
|
116
|
+
enabled: false,
|
|
117
|
+
preview_model: null,
|
|
118
|
+
blueprint_model: null,
|
|
119
|
+
debugging_model: null
|
|
120
|
+
},
|
|
121
|
+
adaptive_models: {
|
|
122
|
+
enabled: false,
|
|
123
|
+
low: null,
|
|
124
|
+
medium: null,
|
|
125
|
+
high: null
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
resume_incomplete_files: true,
|
|
129
|
+
scaffold: {
|
|
130
|
+
enabled: true
|
|
131
|
+
},
|
|
132
|
+
git: {
|
|
133
|
+
enabled: "ask",
|
|
134
|
+
auto_branch: true,
|
|
135
|
+
auto_commit_stages: true,
|
|
136
|
+
auto_merge: true,
|
|
137
|
+
branch_prefix: "kkcode"
|
|
138
|
+
},
|
|
139
|
+
usability_gates: {
|
|
140
|
+
prompt_user: "first_run",
|
|
141
|
+
build: { enabled: true },
|
|
142
|
+
test: { enabled: true },
|
|
143
|
+
review: { enabled: true },
|
|
144
|
+
health: { enabled: true },
|
|
145
|
+
budget: { enabled: true }
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
subagents: {},
|
|
149
|
+
routing: {
|
|
150
|
+
categories: {}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
mcp: {
|
|
154
|
+
servers: {},
|
|
155
|
+
auto_discover: true,
|
|
156
|
+
timeout_ms: 30000,
|
|
157
|
+
max_reconnect_attempts: 5,
|
|
158
|
+
circuit_reset_ms: 60000,
|
|
159
|
+
health_check_interval_ms: 0,
|
|
160
|
+
max_buffer_bytes: 16777216,
|
|
161
|
+
shutdown_timeout_ms: 5000,
|
|
162
|
+
max_sse_buffer_bytes: 4194304
|
|
163
|
+
},
|
|
164
|
+
skills: {
|
|
165
|
+
enabled: true,
|
|
166
|
+
auto_seed: true,
|
|
167
|
+
dirs: [".kkcode/skills"],
|
|
168
|
+
allowed_commands: []
|
|
169
|
+
},
|
|
170
|
+
permission: {
|
|
171
|
+
mode: "auto",
|
|
172
|
+
default_policy: "ask",
|
|
173
|
+
non_tty_default: "deny",
|
|
174
|
+
rules: []
|
|
175
|
+
},
|
|
176
|
+
storage: {
|
|
177
|
+
session_shard_enabled: true,
|
|
178
|
+
flush_interval_ms: 1000,
|
|
179
|
+
event_rotate_mb: 32,
|
|
180
|
+
event_retain_days: 14
|
|
181
|
+
},
|
|
182
|
+
background: {
|
|
183
|
+
mode: "worker_process",
|
|
184
|
+
worker_timeout_ms: 900000,
|
|
185
|
+
max_parallel: 2,
|
|
186
|
+
max_log_lines: 300
|
|
187
|
+
},
|
|
188
|
+
runtime: {
|
|
189
|
+
tool_registry_cache_ttl_ms: 30000,
|
|
190
|
+
mcp_refresh_ttl_ms: 60000
|
|
191
|
+
},
|
|
192
|
+
tool: {
|
|
193
|
+
sources: {
|
|
194
|
+
builtin: true,
|
|
195
|
+
local: true,
|
|
196
|
+
mcp: true,
|
|
197
|
+
plugin: true
|
|
198
|
+
},
|
|
199
|
+
bash_timeout_ms: 120000,
|
|
200
|
+
write_lock: {
|
|
201
|
+
mode: "file_lock",
|
|
202
|
+
wait_timeout_ms: 120000
|
|
203
|
+
},
|
|
204
|
+
sensitive_file_patterns: [
|
|
205
|
+
"AGENTS.md",
|
|
206
|
+
"**/AGENTS.md",
|
|
207
|
+
"KKCODE.md",
|
|
208
|
+
"**/KKCODE.md",
|
|
209
|
+
".kkcode/**",
|
|
210
|
+
"**/.kkcode/**",
|
|
211
|
+
"kkcode.config.yaml",
|
|
212
|
+
"**/kkcode.config.yaml",
|
|
213
|
+
".mcp.json",
|
|
214
|
+
"**/.mcp.json",
|
|
215
|
+
".env",
|
|
216
|
+
".env.*",
|
|
217
|
+
"**/.env",
|
|
218
|
+
"**/.env.*",
|
|
219
|
+
".github/workflows/**",
|
|
220
|
+
"**/.github/workflows/**"
|
|
221
|
+
],
|
|
222
|
+
local_dirs: [".kkcode/tools", ".kkcode/tool"],
|
|
223
|
+
plugin_dirs: [".kkcode/plugins", ".kkcode/plugin"]
|
|
224
|
+
},
|
|
225
|
+
session: {
|
|
226
|
+
max_history: 30,
|
|
227
|
+
recovery: true,
|
|
228
|
+
compaction_threshold_ratio: 0.7,
|
|
229
|
+
compaction_threshold_messages: 50,
|
|
230
|
+
context_cache_points: true
|
|
231
|
+
},
|
|
232
|
+
review: {
|
|
233
|
+
sort: "risk_first",
|
|
234
|
+
default_lines: 80,
|
|
235
|
+
max_expand_lines: 1200,
|
|
236
|
+
risk_weights: {
|
|
237
|
+
sensitive_path: 4,
|
|
238
|
+
large_change: 3,
|
|
239
|
+
medium_change: 2,
|
|
240
|
+
small_change: 1,
|
|
241
|
+
executable_script: 2,
|
|
242
|
+
command_pattern: 3
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
usage: {
|
|
246
|
+
pricing_file: null,
|
|
247
|
+
aggregation: ["turn", "session", "global"],
|
|
248
|
+
budget: {
|
|
249
|
+
session_usd: null,
|
|
250
|
+
global_usd: null,
|
|
251
|
+
warn_at_percent: 80,
|
|
252
|
+
strategy: "warn"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
ui: {
|
|
256
|
+
theme_file: null,
|
|
257
|
+
mode_colors: {
|
|
258
|
+
assistant: "#22d3ee",
|
|
259
|
+
plan: "#00b7c2",
|
|
260
|
+
agent: "#2ac26f",
|
|
261
|
+
longagent: "#ff7a33"
|
|
262
|
+
},
|
|
263
|
+
layout: "compact",
|
|
264
|
+
markdown_render: true,
|
|
265
|
+
status: {
|
|
266
|
+
show_cost: true,
|
|
267
|
+
show_token_meter: true
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export const VALID_PROVIDER_TYPES = ["openai", "anthropic", "ollama", "openai-compatible"]
|
|
273
|
+
|
|
274
|
+
import { listProviders } from "../provider/router.mjs"
|
|
275
|
+
export function getValidProviderTypes() {
|
|
276
|
+
return listProviders()
|
|
277
|
+
}
|
|
278
|
+
export const VALID_MODES = ["assistant", "plan", "agent", "code", "coding", "longagent"]
|
|
279
|
+
export const VALID_REVIEW_SORT = ["risk_first", "time_order", "file_order"]
|
|
280
|
+
export const VALID_LANGUAGES = ["en", "zh"]
|
|
@@ -3,7 +3,7 @@ import { access, readFile } from "node:fs/promises"
|
|
|
3
3
|
import YAML from "yaml"
|
|
4
4
|
import { DEFAULT_CONFIG } from "./defaults.mjs"
|
|
5
5
|
import { validateConfig } from "./schema.mjs"
|
|
6
|
-
import { projectConfigCandidates, userConfigCandidates } from "../storage/paths.mjs"
|
|
6
|
+
import { projectConfigCandidates, userConfigCandidates, envFileCandidates } from "../storage/paths.mjs"
|
|
7
7
|
|
|
8
8
|
async function exists(file) {
|
|
9
9
|
try {
|
|
@@ -38,6 +38,46 @@ async function firstExisting(candidates) {
|
|
|
38
38
|
return null
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Parse .env file — only extract KKCODE_ prefixed vars into nested config.
|
|
43
|
+
* Uses __ (double underscore) as nesting separator, single _ stays in key name.
|
|
44
|
+
*
|
|
45
|
+
* KKCODE_PROVIDER__DEFAULT=anthropic → { provider: { default: "anthropic" } }
|
|
46
|
+
* KKCODE_AGENT__LONGAGENT__PARALLEL__MAX_CONCURRENCY=5 → { agent: { longagent: { parallel: { max_concurrency: 5 } } } }
|
|
47
|
+
* KKCODE_LANGUAGE=zh → { language: "zh" }
|
|
48
|
+
*/
|
|
49
|
+
export function parseEnvOverlay(content) {
|
|
50
|
+
const config = {}
|
|
51
|
+
for (const line of content.split("\n")) {
|
|
52
|
+
const trimmed = line.trim()
|
|
53
|
+
if (!trimmed || trimmed.startsWith("#")) continue
|
|
54
|
+
const eqIdx = trimmed.indexOf("=")
|
|
55
|
+
if (eqIdx <= 0) continue
|
|
56
|
+
const key = trimmed.slice(0, eqIdx).trim()
|
|
57
|
+
if (!key.startsWith("KKCODE_")) continue
|
|
58
|
+
let val = trimmed.slice(eqIdx + 1).trim()
|
|
59
|
+
// strip surrounding quotes
|
|
60
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
61
|
+
val = val.slice(1, -1)
|
|
62
|
+
}
|
|
63
|
+
// split on __ for nesting, lowercase each part
|
|
64
|
+
const parts = key.slice(7).split("__").map(p => p.toLowerCase())
|
|
65
|
+
// coerce types
|
|
66
|
+
let typed = val
|
|
67
|
+
if (val === "true") typed = true
|
|
68
|
+
else if (val === "false") typed = false
|
|
69
|
+
else if (val !== "" && !isNaN(val)) typed = Number(val)
|
|
70
|
+
|
|
71
|
+
let cursor = config
|
|
72
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
73
|
+
if (!cursor[parts[i]] || typeof cursor[parts[i]] !== "object") cursor[parts[i]] = {}
|
|
74
|
+
cursor = cursor[parts[i]]
|
|
75
|
+
}
|
|
76
|
+
cursor[parts[parts.length - 1]] = typed
|
|
77
|
+
}
|
|
78
|
+
return config
|
|
79
|
+
}
|
|
80
|
+
|
|
41
81
|
async function loadOne(filePath) {
|
|
42
82
|
if (!filePath) return { config: {}, errors: [] }
|
|
43
83
|
try {
|
|
@@ -57,7 +97,22 @@ export async function loadConfig(cwd = process.cwd()) {
|
|
|
57
97
|
|
|
58
98
|
const userLoaded = await loadOne(userPath)
|
|
59
99
|
const projectLoaded = await loadOne(projectPath)
|
|
60
|
-
|
|
100
|
+
let merged = mergeObject(mergeObject(DEFAULT_CONFIG, userLoaded.config), projectLoaded.config)
|
|
101
|
+
|
|
102
|
+
// .env overlay — highest priority, KKCODE_ prefixed vars
|
|
103
|
+
let envPath = null
|
|
104
|
+
let envOverlay = {}
|
|
105
|
+
const envCandidate = await firstExisting(envFileCandidates(cwd))
|
|
106
|
+
if (envCandidate) {
|
|
107
|
+
try {
|
|
108
|
+
const raw = await readFile(envCandidate, "utf8")
|
|
109
|
+
envOverlay = parseEnvOverlay(raw)
|
|
110
|
+
if (Object.keys(envOverlay).length > 0) {
|
|
111
|
+
envPath = envCandidate
|
|
112
|
+
merged = mergeObject(merged, envOverlay)
|
|
113
|
+
}
|
|
114
|
+
} catch { /* ignore unreadable .env */ }
|
|
115
|
+
}
|
|
61
116
|
|
|
62
117
|
const source = {
|
|
63
118
|
userPath,
|
|
@@ -65,7 +120,9 @@ export async function loadConfig(cwd = process.cwd()) {
|
|
|
65
120
|
userRaw: userLoaded.config,
|
|
66
121
|
projectPath,
|
|
67
122
|
projectDir: projectPath ? path.dirname(projectPath) : null,
|
|
68
|
-
projectRaw: projectLoaded.config
|
|
123
|
+
projectRaw: projectLoaded.config,
|
|
124
|
+
envPath,
|
|
125
|
+
envOverlay
|
|
69
126
|
}
|
|
70
127
|
|
|
71
128
|
return {
|
|
@@ -73,4 +130,4 @@ export async function loadConfig(cwd = process.cwd()) {
|
|
|
73
130
|
source,
|
|
74
131
|
errors: [...userLoaded.errors, ...projectLoaded.errors]
|
|
75
132
|
}
|
|
76
|
-
}
|
|
133
|
+
}
|