koneck 2.25.70 → 2.25.72
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/dist/config-store.d.ts +2 -0
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +5 -1
- package/dist/config-store.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/context-limit.d.ts +21 -0
- package/dist/context-limit.d.ts.map +1 -1
- package/dist/context-limit.js +48 -0
- package/dist/context-limit.js.map +1 -1
- package/dist/engine.d.ts +8 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +152 -42
- package/dist/engine.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/prompt-budget.d.ts +53 -0
- package/dist/prompt-budget.d.ts.map +1 -0
- package/dist/prompt-budget.js +87 -0
- package/dist/prompt-budget.js.map +1 -0
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worktree.d.ts +25 -0
- package/dist/worktree.d.ts.map +1 -1
- package/dist/worktree.js +14 -0
- package/dist/worktree.js.map +1 -1
- package/package.json +1 -1
package/dist/config-store.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface KoneckConfig {
|
|
|
28
28
|
* written before this existed.
|
|
29
29
|
*/
|
|
30
30
|
models?: Record<string, string>;
|
|
31
|
+
/** Send every tool regardless of whether the window can hold their descriptions. */
|
|
32
|
+
leanTools?: boolean;
|
|
31
33
|
}
|
|
32
34
|
export declare function loadKoneckConfig(): Promise<KoneckConfig>;
|
|
33
35
|
export declare function saveKoneckConfig(cfg: KoneckConfig): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../src/config-store.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,WAAW,QAAuC,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,Q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O,MAAM,aAAa,EAAE,SAAS,WAAW,EA4B/C,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAY1F;AAED,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAInD"}
|
package/dist/config-store.js
CHANGED
|
@@ -8,7 +8,7 @@ const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
|
8
8
|
const ALLOWED_KEYS = [
|
|
9
9
|
'provider', 'model', 'baseURL', 'requireApproval', 'maxTurns', 'effort', 'personality', 'budget',
|
|
10
10
|
'maxWidth', 'altScreen', 'contextTokens',
|
|
11
|
-
'agentConcurrency', 'endpoints', 'models',
|
|
11
|
+
'agentConcurrency', 'endpoints', 'models', 'leanTools',
|
|
12
12
|
];
|
|
13
13
|
const KEY_DESCRIPTIONS = {
|
|
14
14
|
provider: 'LLM provider (anthropic, openai, omni, etc.)',
|
|
@@ -20,6 +20,8 @@ const KEY_DESCRIPTIONS = {
|
|
|
20
20
|
maxTurns: 'Turn limit per task; unset or 0 means no limit (number)',
|
|
21
21
|
contextTokens: 'The model\'s context window, when you know it better than KONECK does. ' +
|
|
22
22
|
'Compaction happens at three quarters of this (number)',
|
|
23
|
+
leanTools: 'Let KONECK trim its own tool list when the window cannot hold it. On by ' +
|
|
24
|
+
'default; off sends every tool whatever the cost (true/false)',
|
|
23
25
|
altScreen: 'Own the terminal screen and pin the prompt to the last row; history is then ' +
|
|
24
26
|
'scrolled inside KONECK rather than by the terminal (true/false)',
|
|
25
27
|
maxWidth: 'Cap the UI width in columns; unset fills the terminal (number)',
|
|
@@ -130,6 +132,8 @@ export const CONFIG_SCHEMA = [
|
|
|
130
132
|
type: { kind: 'number', min: 0, max: 100_000 }, clearable: true },
|
|
131
133
|
{ key: 'agentConcurrency', label: 'Sub-agents at once', description: KEY_DESCRIPTIONS['agentConcurrency'],
|
|
132
134
|
type: { kind: 'number', min: 1, max: 8 }, clearable: true },
|
|
135
|
+
{ key: 'leanTools', label: 'Trim tools to fit', description: KEY_DESCRIPTIONS['leanTools'],
|
|
136
|
+
type: { kind: 'boolean' }, clearable: true },
|
|
133
137
|
{ key: 'altScreen', label: 'Alt screen', description: KEY_DESCRIPTIONS['altScreen'],
|
|
134
138
|
type: { kind: 'boolean' }, clearable: true },
|
|
135
139
|
{ key: 'contextTokens', label: 'Context window', description: KEY_DESCRIPTIONS['contextTokens'],
|
package/dist/config-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../src/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE5E,MAAM,UAAU,GAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACvD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../src/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,IAAI,MA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,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,WAAW,CAAC;IAC9E,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface KoneckFileConfig {
|
|
|
13
13
|
endpoints?: Record<string, string>;
|
|
14
14
|
/** Models by provider name, so switching providers restores the model you use with it. */
|
|
15
15
|
models?: Record<string, string>;
|
|
16
|
+
/** Whether KONECK may trim its tool list to fit a window that cannot hold it. */
|
|
17
|
+
leanTools?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export declare function globalConfigPath(): string;
|
|
18
20
|
export declare function loadGlobalConfig(): Promise<KoneckFileConfig>;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,iFAAiF;IACjF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAOlE;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAYnF;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmB5E"}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.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indowAdvice(fixedTokens: number, limit: number,
|
|
|
104
104
|
endpoint: string;
|
|
105
105
|
remote: boolean;
|
|
106
106
|
}): string;
|
|
107
|
+
/**
|
|
108
|
+
* The window a locally served model actually has, asked of the server.
|
|
109
|
+
*
|
|
110
|
+
* KONECK assumed 4,096 for anything served locally, because that is Ollama's default. An
|
|
111
|
+
* assumption is not a measurement, and the objection was fair: if the server is running with a
|
|
112
|
+
* larger window, KONECK was compacting and trimming for a constraint that did not exist. Nothing
|
|
113
|
+
* should be limited that does not have to be.
|
|
114
|
+
*
|
|
115
|
+
* `/api/ps` reports the models Ollama currently has loaded, and each entry carries the context
|
|
116
|
+
* length it was loaded with — the serving value, which is the one that matters. `/api/show` is
|
|
117
|
+
* deliberately not used as a substitute: it reports the length the model was *trained* for, which
|
|
118
|
+
* is the number that caused this whole class of trouble in the first place, being several times
|
|
119
|
+
* larger than what the server will accept.
|
|
120
|
+
*
|
|
121
|
+
* Returns null when the server does not say, and the caller falls back to the default while
|
|
122
|
+
* labelling it as an assumption rather than a fact.
|
|
123
|
+
*/
|
|
124
|
+
export declare function probeOllamaContext(baseURL: string, model: string, fetchImpl?: typeof fetch, timeoutMs?: number): Promise<{
|
|
125
|
+
limit: number;
|
|
126
|
+
source: string;
|
|
127
|
+
} | null>;
|
|
107
128
|
//# sourceMappingURL=context-limit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-limit.d.ts","sourceRoot":"","sources":["../src/context-limit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA6BH;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,uCAAuC;AACvC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,OAAO,CAAC;AAE/B,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAA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AAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACzD,MAAM,CAaR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,OAAO,KAAa,EAC/B,SAAS,SAAQ,GAChB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA0BnD"}
|
package/dist/context-limit.js
CHANGED
|
@@ -213,4 +213,52 @@ export function crowdedWindowAdvice(fixedTokens, limit, opts) {
|
|
|
213
213
|
`Fix it where Ollama runs: set \`OLLAMA_CONTEXT_LENGTH=32768\` ${where}. ` +
|
|
214
214
|
`Then \`/context\` to confirm it took.`;
|
|
215
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* The window a locally served model actually has, asked of the server.
|
|
218
|
+
*
|
|
219
|
+
* KONECK assumed 4,096 for anything served locally, because that is Ollama's default. An
|
|
220
|
+
* assumption is not a measurement, and the objection was fair: if the server is running with a
|
|
221
|
+
* larger window, KONECK was compacting and trimming for a constraint that did not exist. Nothing
|
|
222
|
+
* should be limited that does not have to be.
|
|
223
|
+
*
|
|
224
|
+
* `/api/ps` reports the models Ollama currently has loaded, and each entry carries the context
|
|
225
|
+
* length it was loaded with — the serving value, which is the one that matters. `/api/show` is
|
|
226
|
+
* deliberately not used as a substitute: it reports the length the model was *trained* for, which
|
|
227
|
+
* is the number that caused this whole class of trouble in the first place, being several times
|
|
228
|
+
* larger than what the server will accept.
|
|
229
|
+
*
|
|
230
|
+
* Returns null when the server does not say, and the caller falls back to the default while
|
|
231
|
+
* labelling it as an assumption rather than a fact.
|
|
232
|
+
*/
|
|
233
|
+
export async function probeOllamaContext(baseURL, model, fetchImpl = fetch, timeoutMs = 1_200) {
|
|
234
|
+
// The OpenAI-compatible path is /v1; Ollama's own API sits beside it.
|
|
235
|
+
const root = baseURL.replace(/\/+$/, '').replace(/\/v\d+$/, '');
|
|
236
|
+
const control = new AbortController();
|
|
237
|
+
const timer = setTimeout(() => control.abort(), timeoutMs);
|
|
238
|
+
try {
|
|
239
|
+
const res = await fetchImpl(`${root}/api/ps`, { signal: control.signal });
|
|
240
|
+
if (!res.ok)
|
|
241
|
+
return null;
|
|
242
|
+
const body = await res.json();
|
|
243
|
+
const loaded = body.models ?? [];
|
|
244
|
+
const wanted = model.toLowerCase();
|
|
245
|
+
// An exact name first, then the only loaded model — a machine serving one model is the common
|
|
246
|
+
// case and matching it is better than reporting nothing.
|
|
247
|
+
const entry = loaded.find(m => String(m['name'] ?? m['model'] ?? '').toLowerCase() === wanted)
|
|
248
|
+
?? (loaded.length === 1 ? loaded[0] : undefined);
|
|
249
|
+
if (!entry)
|
|
250
|
+
return null;
|
|
251
|
+
const raw = entry['context_length'] ?? entry['context'] ?? entry['num_ctx'];
|
|
252
|
+
const limit = Number(raw);
|
|
253
|
+
if (!Number.isFinite(limit) || limit < 512)
|
|
254
|
+
return null;
|
|
255
|
+
return { limit: Math.floor(limit), source: 'reported by the server' };
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return null; // unreachable, older Ollama, or something else entirely
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
clearTimeout(timer);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
216
264
|
//# sourceMappingURL=context-limit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-limit.js","sourceRoot":"","sources":["../src/context-limit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,wEAAwE;AACxE,MAAM,YAAY,GAA6C;IAC7D,CAAC,eAAe,EAAE,MAAM,CAAC;IACzB,CAAC,aAAa,EAAE,MAAM,CAAC;IACvB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,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AAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,GAAG;YAAE,OAAO,IAAI,CAAC;QACxD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,CAAuB,wDAAwD;IAC7F,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
package/dist/engine.d.ts
CHANGED
|
@@ -116,6 +116,14 @@ export declare function finishedWithoutBuilding(task: string, usedMutatingTool:
|
|
|
116
116
|
*/
|
|
117
117
|
export declare function announcesMoreWork(text: string): boolean;
|
|
118
118
|
export declare function buildClient(config: AgentConfig): OpenAI;
|
|
119
|
+
/**
|
|
120
|
+
* `git status --short`, summarised rather than pasted.
|
|
121
|
+
*
|
|
122
|
+
* Measured in a real workspace: 1,334 tokens of it, a third of the whole window, listing files in
|
|
123
|
+
* other projects. What the model needs is whether the tree is dirty and roughly where; a complete
|
|
124
|
+
* inventory is something it can ask for with a tool when it matters.
|
|
125
|
+
*/
|
|
126
|
+
export declare function summariseGitStatus(raw: string, maxLines?: number): string;
|
|
119
127
|
/** The first line of a tool failure, short enough for one row. */
|
|
120
128
|
export declare function failureReason(result: string, max?: number): string;
|
|
121
129
|
/** Beyond this, notes crowd out the actual task. Roughly 500 words. */
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAsB5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,M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,CAAC,EAAE,IAAI,GACjB,OAAO,CAAC,YAAY,CAAC,CA0MvB;AAwBD;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAGD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,eAAe,CAAC,EAAE,OAAO,EAAE,EAC3B,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,YAAY,CAAC,CA6IvB"}
|
package/dist/engine.js
CHANGED
|
@@ -6,10 +6,10 @@ import chalk from 'chalk';
|
|
|
6
6
|
import { execa } from 'execa';
|
|
7
7
|
import { TOOL_DEFINITIONS, dispatchTool, describeShell, unknownToolError, resolveToolAlias, aliasNotice, isToolFailure, } from './tools.js';
|
|
8
8
|
import { tui } from './tui.js';
|
|
9
|
-
import { isGitRepo, createWorktree, mergeWorktree } from './worktree.js';
|
|
9
|
+
import { isGitRepo, gitScope, createWorktree, mergeWorktree } from './worktree.js';
|
|
10
10
|
import { resolveProvider, getApiKey, servesLocally, isPrivateHost } from './providers.js';
|
|
11
11
|
import { compressIfNeeded } from './compressor.js';
|
|
12
|
-
import { contextLimitFor, looksLikeContextOverflow, parseContextLimit, fetchModelContextLimit, ollamaServingLimit, fixedRequestTokens, overheadIsCrowded, crowdedWindowAdvice, } from './context-limit.js';
|
|
12
|
+
import { contextLimitFor, looksLikeContextOverflow, parseContextLimit, fetchModelContextLimit, ollamaServingLimit, fixedRequestTokens, overheadIsCrowded, crowdedWindowAdvice, probeOllamaContext, } from './context-limit.js';
|
|
13
13
|
import { generateSessionId, saveSession } from './session.js';
|
|
14
14
|
import { EMPTY_PLAN, parsePlan, planReminder, planAck, noPlanReminder } from './plan.js';
|
|
15
15
|
import { spillIfOversized } from './spill.js';
|
|
@@ -18,7 +18,7 @@ import { resolveSandbox, describeSandbox } from './sandbox.js';
|
|
|
18
18
|
import { loadImages, buildUserContent, imageMime, looksLikeVisionUnsupported, visionUnsupportedNotice, } from './images.js';
|
|
19
19
|
import { parseTextToolCalls, paramTypesFrom, looksLikeTextToolCall, stripTemplateTokens, splitEmittable, parseCommandStyleCalls, toolShapesFrom } from './tool-call-text.js';
|
|
20
20
|
import { isIdentityQuestion, identityAnswer } from './identity.js';
|
|
21
|
-
import {
|
|
21
|
+
import { leanTools, leanToolNotice, leanModeNotice } from './lean-mode.js';
|
|
22
22
|
import { findTailRepetition, trimTailRepetition, repetitionNotice, CHECK_EVERY } from './repetition.js';
|
|
23
23
|
import { loadMemory } from './memory.js';
|
|
24
24
|
import { detectProject, loadAgentInstructions, projectSummary } from './project.js';
|
|
@@ -28,6 +28,7 @@ import { loadMCPConfig, connectMCPServers, callMCPTool, } from './mcp.js';
|
|
|
28
28
|
import { gatherRecon } from './recon.js';
|
|
29
29
|
import { runSelfCritique, detectFileWrites } from './critique.js';
|
|
30
30
|
import { getPackSystemPrompt } from './plugin-packs.js';
|
|
31
|
+
import { assembleWithinBudget, budgetNotice } from './prompt-budget.js';
|
|
31
32
|
import { runQualityGate, qualityGateSummary } from './quality-gate.js';
|
|
32
33
|
import { appendAuditEvent, summarizeToolAction } from './audit.js';
|
|
33
34
|
import { evaluatePolicy, loadPolicy } from './policy.js';
|
|
@@ -345,19 +346,51 @@ export function buildClient(config) {
|
|
|
345
346
|
});
|
|
346
347
|
}
|
|
347
348
|
// ─── Environment discovery ────────────────────────────────────────────────────
|
|
349
|
+
/**
|
|
350
|
+
* `git status --short`, summarised rather than pasted.
|
|
351
|
+
*
|
|
352
|
+
* Measured in a real workspace: 1,334 tokens of it, a third of the whole window, listing files in
|
|
353
|
+
* other projects. What the model needs is whether the tree is dirty and roughly where; a complete
|
|
354
|
+
* inventory is something it can ask for with a tool when it matters.
|
|
355
|
+
*/
|
|
356
|
+
export function summariseGitStatus(raw, maxLines = 12) {
|
|
357
|
+
const lines = raw.split('\n').map(l => l.trimEnd()).filter(l => l.trim() !== '');
|
|
358
|
+
if (lines.length === 0)
|
|
359
|
+
return 'clean';
|
|
360
|
+
if (lines.length <= maxLines)
|
|
361
|
+
return lines.join('\n');
|
|
362
|
+
const shown = lines.slice(0, maxLines).join('\n');
|
|
363
|
+
return `${shown}\n… and ${lines.length - maxLines} more changed files ` +
|
|
364
|
+
`(run git status for the rest)`;
|
|
365
|
+
}
|
|
348
366
|
async function discoverEnvironment(cwd) {
|
|
349
367
|
let gitStatus = null;
|
|
350
368
|
let gitBranch = null;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
369
|
+
// Only the workspace's own repository is described.
|
|
370
|
+
//
|
|
371
|
+
// `git status` run in a folder with no repository of its own answers for whichever ancestor has
|
|
372
|
+
// one. Measured in a real session: 1,334 tokens listing deleted files in sibling projects, every
|
|
373
|
+
// path beginning with `../`, injected into every single request — a third of the window spent
|
|
374
|
+
// telling the model about a tree it was not working in and should not touch. The same mistake as
|
|
375
|
+
// the git tools, in the one place it cost the most.
|
|
376
|
+
const scope = await gitScope(cwd).catch(() => ({ isRepo: false, root: null, ownedByWorkspace: false }));
|
|
377
|
+
if (scope.ownedByWorkspace) {
|
|
378
|
+
try {
|
|
379
|
+
const { stdout: s } = await execa('git', ['status', '--short'], { cwd, stdio: 'pipe' });
|
|
380
|
+
gitStatus = summariseGitStatus(s);
|
|
381
|
+
}
|
|
382
|
+
catch { /* unreadable index, or a race with another git process */ }
|
|
383
|
+
try {
|
|
384
|
+
const { stdout: b } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd, stdio: 'pipe' });
|
|
385
|
+
gitBranch = b.trim();
|
|
386
|
+
}
|
|
387
|
+
catch { /* a repository with no commits yet */ }
|
|
354
388
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
389
|
+
else if (scope.isRepo) {
|
|
390
|
+
// Said, not silently omitted: "not a git repo" would be a lie, and the difference matters if
|
|
391
|
+
// somebody is wondering why git is not available.
|
|
392
|
+
gitStatus = `not tracked here — the enclosing repository is ${scope.root}`;
|
|
359
393
|
}
|
|
360
|
-
catch { /* not a git repo */ }
|
|
361
394
|
return {
|
|
362
395
|
os: `${os.type()} ${os.release()} (${os.arch()})`,
|
|
363
396
|
cwd,
|
|
@@ -400,7 +433,16 @@ function buildSystemPrompt(ctx, memory = null, project = null, agentInstructions
|
|
|
400
433
|
* On a 4,096-token window they are 7% of everything the model will ever see, spent on how to
|
|
401
434
|
* format a table it has no room to write. Identity and the rules that keep it safe stay.
|
|
402
435
|
*/
|
|
403
|
-
lean = false
|
|
436
|
+
lean = false,
|
|
437
|
+
/**
|
|
438
|
+
* A ceiling on the whole prompt, in tokens, or undefined for no ceiling.
|
|
439
|
+
*
|
|
440
|
+
* Set only when the window cannot hold everything. Above it, nothing is dropped and this is the
|
|
441
|
+
* same prompt it always was.
|
|
442
|
+
*/
|
|
443
|
+
budgetTokens,
|
|
444
|
+
/** Framework guidance detected for the project — first to go when there is no room for it. */
|
|
445
|
+
extraPrompt = '') {
|
|
404
446
|
// ── Core identity & non-negotiable rules ────────────────────────────────────
|
|
405
447
|
//
|
|
406
448
|
// The identity comes first, and says what it is not.
|
|
@@ -483,7 +525,23 @@ ${lean
|
|
|
483
525
|
const instructionsSection = agentInstructions
|
|
484
526
|
? '\n## ' + agentInstructions
|
|
485
527
|
: '';
|
|
486
|
-
|
|
528
|
+
// Declared as sections with priorities so the whole prompt can be built to a size when it has
|
|
529
|
+
// to be. Concatenating whatever applies gives a prompt whose length is an accident — measured at
|
|
530
|
+
// 4,166 tokens against a 4,096-token window in a real project, with the tools already trimmed.
|
|
531
|
+
const sections = [
|
|
532
|
+
{ name: 'identity and rules', text: rules, priority: 0, essential: true },
|
|
533
|
+
{ name: 'runtime', text: env, priority: 1, essential: true },
|
|
534
|
+
{ name: 'project', text: projectSection, priority: 2, truncateTo: 600 },
|
|
535
|
+
{ name: 'your instructions', text: instructionsSection, priority: 3, truncateTo: 2_000 },
|
|
536
|
+
{ name: 'notes from previous sessions', text: memorySection, priority: 4, truncateTo: 800 },
|
|
537
|
+
{ name: 'framework guidance', text: extraPrompt ? '\n\n' + extraPrompt : '', priority: 5 },
|
|
538
|
+
];
|
|
539
|
+
if (budgetTokens === undefined) {
|
|
540
|
+
// Its real size, because the caller uses it to decide whether a budget is needed at all.
|
|
541
|
+
const text = sections.map(s => s.text).join('');
|
|
542
|
+
return { text, dropped: [], truncated: [], tokens: Math.round(text.length / 3.6) };
|
|
543
|
+
}
|
|
544
|
+
return assembleWithinBudget(sections, budgetTokens);
|
|
487
545
|
}
|
|
488
546
|
export function availableToolNames(names, available) {
|
|
489
547
|
return names.filter(name => {
|
|
@@ -879,27 +937,31 @@ detectedContext = { current: 0 }) {
|
|
|
879
937
|
// one is a line of shell that execute_command already runs. Reported as a session that planned
|
|
880
938
|
// three steps, called `plan`, and then returned three empty turns: there was nothing left of the
|
|
881
939
|
// window to answer in.
|
|
882
|
-
if (shouldRunLean(effectiveLimit())) {
|
|
883
|
-
const lean = leanTools(openaiTools);
|
|
884
|
-
if (lean.dropped.length > 0) {
|
|
885
|
-
openaiTools = lean.tools;
|
|
886
|
-
// The model is told what it no longer has, so a missing tool is a known constraint rather
|
|
887
|
-
// than something it discovers by calling one that is gone.
|
|
888
|
-
messages.push({ role: 'system', content: leanToolNotice(lean.dropped) });
|
|
889
|
-
config.onLeanMode?.(lean.dropped, effectiveLimit(), leanModeNotice(lean, effectiveLimit()));
|
|
890
|
-
if (!silent)
|
|
891
|
-
tui.printWarning(leanModeNotice(lean, effectiveLimit()));
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
940
|
// What every request costs before the user has typed anything — the instructions plus the tool
|
|
895
|
-
// descriptions.
|
|
896
|
-
//
|
|
897
|
-
//
|
|
898
|
-
// tool calls as prose, and answers questions about itself from its training. All three were
|
|
899
|
-
// reported as separate faults.
|
|
941
|
+
// descriptions. On a large window this is 12% of it and there is nothing to discuss. On a small
|
|
942
|
+
// one it was 93%, which is why a model looped, wrote tool calls as prose, and answered questions
|
|
943
|
+
// about itself from its training: all three were reported separately and all three were this.
|
|
900
944
|
{
|
|
901
945
|
const systemText = messages.find(m => m.role === 'system')?.content;
|
|
902
|
-
const
|
|
946
|
+
const systemChars = typeof systemText === 'string' ? systemText : '';
|
|
947
|
+
let fixed = fixedRequestTokens(systemChars, JSON.stringify(openaiTools));
|
|
948
|
+
// Reduced only when it genuinely does not fit — measured against the window the server
|
|
949
|
+
// reported, not against a threshold KONECK picked. `leanTools: false` turns it off outright.
|
|
950
|
+
if (config.leanTools !== false && overheadIsCrowded(fixed, effectiveLimit())) {
|
|
951
|
+
const lean = leanTools(openaiTools);
|
|
952
|
+
if (lean.dropped.length > 0) {
|
|
953
|
+
openaiTools = lean.tools;
|
|
954
|
+
// The model is told what it no longer has, so a missing tool is a stated constraint rather
|
|
955
|
+
// than something it discovers by calling one that is gone.
|
|
956
|
+
messages.push({ role: 'system', content: leanToolNotice(lean.dropped) });
|
|
957
|
+
config.onLeanMode?.(lean.dropped, effectiveLimit(), leanModeNotice(lean, effectiveLimit()));
|
|
958
|
+
if (!silent)
|
|
959
|
+
tui.printWarning(leanModeNotice(lean, effectiveLimit()));
|
|
960
|
+
fixed = fixedRequestTokens(systemChars, JSON.stringify(openaiTools));
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
// Said only if it still does not fit after that, because otherwise it is solved rather than
|
|
964
|
+
// worth a warning.
|
|
903
965
|
if (overheadIsCrowded(fixed, effectiveLimit())) {
|
|
904
966
|
const advice = crowdedWindowAdvice(fixed, effectiveLimit(), {
|
|
905
967
|
model: config.model,
|
|
@@ -1803,6 +1865,23 @@ initialPlan) {
|
|
|
1803
1865
|
turns: initialStats?.turns ?? 0,
|
|
1804
1866
|
};
|
|
1805
1867
|
const messages = initialMessages ? [...initialMessages] : [];
|
|
1868
|
+
// Judged by the endpoint rather than the provider's name. A LAN Ollama reached through a
|
|
1869
|
+
// provider slot called "omni" is still served by Ollama, and while this asked about the name
|
|
1870
|
+
// that setup got neither the smaller window nor a word of warning.
|
|
1871
|
+
const locallyServed = servesLocally(config.provider, resolveProvider(config.provider, config.baseURL).baseURL);
|
|
1872
|
+
if (!config.contextTokens && locallyServed) {
|
|
1873
|
+
// Asked, not assumed. KONECK took Ollama's 4,096 default as fact for anything served locally,
|
|
1874
|
+
// so a server running with a larger window was being compacted and trimmed for a limit that
|
|
1875
|
+
// did not exist. The objection was fair: nothing should be limited that does not have to be.
|
|
1876
|
+
//
|
|
1877
|
+
// Awaited, unlike the model-catalogue lookup, because this decides how the very first request
|
|
1878
|
+
// is built — and bounded, so an endpoint that does not answer costs a second rather than a
|
|
1879
|
+
// timeout. It is a call to a machine on your own network.
|
|
1880
|
+
const probed = await probeOllamaContext(resolveProvider(config.provider, config.baseURL).baseURL, config.model);
|
|
1881
|
+
config = { ...config, contextTokens: probed?.limit ?? ollamaServingLimit() };
|
|
1882
|
+
if (probed)
|
|
1883
|
+
config.onWindowDetected?.(probed.limit, probed.source);
|
|
1884
|
+
}
|
|
1806
1885
|
if (!initialMessages) {
|
|
1807
1886
|
const [ctx, memory, project, agentInstructions, packPrompt] = await Promise.all([
|
|
1808
1887
|
discoverEnvironment(config.cwd),
|
|
@@ -1816,8 +1895,29 @@ initialPlan) {
|
|
|
1816
1895
|
//
|
|
1817
1896
|
// Lean when the window is small: the guidance is worth less than the room it occupies once
|
|
1818
1897
|
// the instructions and tool descriptions are most of what the model will ever see.
|
|
1819
|
-
|
|
1820
|
-
|
|
1898
|
+
//
|
|
1899
|
+
// The budget is a quarter of the window, which leaves the other three quarters for the
|
|
1900
|
+
// conversation, the reply and the files read. Without one the prompt is whatever the sections
|
|
1901
|
+
// happen to add up to — in a real project 4,166 tokens against a window of 4,096, with the
|
|
1902
|
+
// tool list already cut. Undefined above 8k: nothing is dropped and this is the prompt it
|
|
1903
|
+
// always was.
|
|
1904
|
+
const window = contextLimitFor(config.model, config.contextTokens);
|
|
1905
|
+
const budget = Math.floor(window * 0.25);
|
|
1906
|
+
// Built once to see what it comes to, and rebuilt to the budget only if it exceeds it. The
|
|
1907
|
+
// first version of this guessed the prompt's size at a constant and compared that — 1,500
|
|
1908
|
+
// against half of 4,096 — decided nothing was crowded, and left a 3,559-token prompt in place.
|
|
1909
|
+
// Measuring the actual thing is both simpler and correct.
|
|
1910
|
+
let built = buildSystemPrompt({ ...ctx, model: config.model, provider: config.provider }, memory, project, agentInstructions, false, undefined, packPrompt);
|
|
1911
|
+
const overBudget = built.tokens > budget;
|
|
1912
|
+
if (config.leanTools !== false && overBudget) {
|
|
1913
|
+
built = buildSystemPrompt({ ...ctx, model: config.model, provider: config.provider }, memory, project, agentInstructions, true, budget, packPrompt);
|
|
1914
|
+
}
|
|
1915
|
+
messages.push({ role: 'system', content: built.text });
|
|
1916
|
+
if (built.dropped.length || built.truncated.length) {
|
|
1917
|
+
config.onPromptTrimmed?.(built.dropped, built.truncated, budgetNotice(built, budget));
|
|
1918
|
+
if (!config.silent)
|
|
1919
|
+
tui.printWarning(budgetNotice(built, budget));
|
|
1920
|
+
}
|
|
1821
1921
|
}
|
|
1822
1922
|
// Load MCP and plugins only at top level (spawnDepth === 0)
|
|
1823
1923
|
const isTopLevel = (config.spawnDepth ?? 0) === 0;
|
|
@@ -1826,24 +1926,34 @@ initialPlan) {
|
|
|
1826
1926
|
const plugins = isTopLevel ? await loadPlugins(config.cwd) : [];
|
|
1827
1927
|
// Checked once per session rather than per turn: a directory does not become a git repository
|
|
1828
1928
|
// part-way through, and asking git on every turn costs a process spawn each time.
|
|
1929
|
+
//
|
|
1930
|
+
// "Is there a repository here" is the wrong question, because git answers for any ancestor. A
|
|
1931
|
+
// session in a folder with no .git of its own was offered the git tools because a directory two
|
|
1932
|
+
// levels up is a repository — and a commit from that session would have been a commit there, in
|
|
1933
|
+
// a tree holding every other project on the machine. The question is whether the repository is
|
|
1934
|
+
// this workspace's own.
|
|
1935
|
+
const scope = await gitScope(config.cwd).catch(() => ({ isRepo: false, root: null, ownedByWorkspace: false }));
|
|
1829
1936
|
const available = {
|
|
1830
|
-
git:
|
|
1937
|
+
git: scope.ownedByWorkspace,
|
|
1831
1938
|
webSearch: detectSearchKey(),
|
|
1832
1939
|
};
|
|
1833
|
-
|
|
1940
|
+
let openaiTools = buildToolList(mcpClients, plugins, config, available);
|
|
1941
|
+
// Said rather than left to be noticed: withholding a tool silently looks like a tool that is
|
|
1942
|
+
// broken, and this one is withheld for a reason worth knowing.
|
|
1943
|
+
if (scope.isRepo && !scope.ownedByWorkspace) {
|
|
1944
|
+
config.onGitOutsideWorkspace?.(scope.root ?? '', config.cwd);
|
|
1945
|
+
if (!config.silent) {
|
|
1946
|
+
tui.printWarning(`The git tools are not offered here. This folder has no repository of its own — the one ` +
|
|
1947
|
+
`that answers for it is ${scope.root}, which encloses this workspace, so a commit would ` +
|
|
1948
|
+
`land there rather than here. Run git through execute_command if that is what you want.`);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1834
1951
|
// Asked of the provider once, because a table of model names cannot know what a gateway alias
|
|
1835
1952
|
// resolves to — and guessing small there summarised away most of a conversation that had room.
|
|
1836
1953
|
// An explicit setting still wins; this only fills in what nobody has said.
|
|
1837
1954
|
// A locally served model is planned around what the server will actually accept, not what the
|
|
1838
1955
|
// model was trained for: Ollama reports the trained length and serves its own much smaller
|
|
1839
1956
|
// default, then truncates the difference in silence.
|
|
1840
|
-
// Judged by the endpoint rather than the provider's name. A LAN Ollama reached through a
|
|
1841
|
-
// provider slot called "omni" is still served by Ollama, and while this asked about the name
|
|
1842
|
-
// that setup got neither the smaller window nor a word of warning.
|
|
1843
|
-
const locallyServed = servesLocally(config.provider, resolveProvider(config.provider, config.baseURL).baseURL);
|
|
1844
|
-
if (!config.contextTokens && locallyServed) {
|
|
1845
|
-
config = { ...config, contextTokens: ollamaServingLimit() };
|
|
1846
|
-
}
|
|
1847
1957
|
/**
|
|
1848
1958
|
* The window the provider reports, once it answers.
|
|
1849
1959
|
*
|