@vincemakes/kiso-code 0.3.0 → 0.5.0
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/dispatch.js +3 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.js +58 -16
- package/package.json +14 -14
package/dist/dispatch.js
CHANGED
|
@@ -27,7 +27,9 @@ export function dispatch(line, ctx) {
|
|
|
27
27
|
bodyLog(cmd("/mode", "show the approval tier; /mode <name> switches (manual/default/accept-edits/plan/bypass)"));
|
|
28
28
|
bodyLog(cmd("/model", "list model profiles; /model <name|provider/model> switches"));
|
|
29
29
|
bodyLog(cmd("/compact", "summarize the older conversation to free context"));
|
|
30
|
-
|
|
30
|
+
// KC1: the composer's keys ride the SAME bodyLog call (it splits
|
|
31
|
+
// on \n) — the help gains a row, the cli source does not
|
|
32
|
+
bodyLog(`${cmd("exit", "leave the session")}\n${cmd("keys", "enter sends · ctrl+J inserts a newline (shift+enter where the terminal encodes it)")}`);
|
|
31
33
|
ctx.input.prompt();
|
|
32
34
|
});
|
|
33
35
|
return;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* index.ts keeps the entry: banner, input sources, the A area prompt,
|
|
23
23
|
* makeAgent, and main.
|
|
24
24
|
*/
|
|
25
|
+
import { type ContextPolicy } from "@vincemakes/kiso-runtime";
|
|
25
26
|
export { applyProjectMerges } from "./trust-ui.js";
|
|
26
27
|
/**
|
|
27
28
|
* A area: the coding-agent system prompt — ONE constant, byte-stable for the
|
|
@@ -30,6 +31,7 @@ export { applyProjectMerges } from "./trust-ui.js";
|
|
|
30
31
|
/** The built-in prompt. Exported for scripts/request-surface.mjs — the
|
|
31
32
|
* model-side token-rent counter measures the REAL bytes, never a copy. */
|
|
32
33
|
export declare const SYSTEM_PROMPT = "You are kiso, a coding agent. You work in a workspace\ndirectory and change code with tools. Be concise: answer in a few lines\nunless the task genuinely needs more. Never claim a file was changed\nunless a tool confirmed it.\n\nTool discipline:\n- READ BEFORE YOU EDIT. For any file you are about to change, read it\n first \u2014 never guess its content.\n- Use edit_file for targeted changes and write_file for full rewrites.\n Prefer many small edits over one large write.\n- shell is for commands: builds, tests, git, grep. Be careful \u2014 shell has\n side effects and may take time. Run one command at a time and inspect\n the output before continuing.\n- Batch independent tool calls into one reply \u2014 they run in parallel.\n- search_text and list_dir are cheap \u2014 locate first, then read ranges\n with read_file offset/limit; never read a whole large file in one call.\n- Do not re-read a file you already read unchanged \u2014 rely on the earlier\n result.\n- When a tool fails, read the error and adjust; do not repeat the same\n call blindly.\n\nWorkflow: understand the request, find the relevant code, make the\nsmallest change that works, then verify with a command (tests/build).\nReport what you did in one or two lines per change.";
|
|
34
|
+
/** Hard cap for injected instructions — truncate and say so. */
|
|
33
35
|
/**
|
|
34
36
|
* A area: read the FIRST present instruction file (AGENTS.md preferred) and
|
|
35
37
|
* return it as an injected section, or "" when none exists. Truncated at
|
|
@@ -40,3 +42,21 @@ export declare function readProjectInstructions(cwd: string): string;
|
|
|
40
42
|
/** A area: the session's system prompt — the constant plus any project
|
|
41
43
|
* instructions found in the workspace. Deterministic per cwd. */
|
|
42
44
|
export declare function composeSystemPrompt(cwd: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* E6: the run-start context policy, OFF unless env-armed (invalid values
|
|
47
|
+
* are ABSENT, never a crash — the autoCompactFromEnv convention).
|
|
48
|
+
* The product arming is KISO_CONTEXT_WINDOW → window − POLICY_RESERVE
|
|
49
|
+
* (the window rides the config as windowTokens; the runtime owns the
|
|
50
|
+
* arithmetic — never a fixed low absolute). KISO_POLICY_SUMMARY_TRIGGER
|
|
51
|
+
* survives ONLY as the legacy absolute override when no window is set
|
|
52
|
+
* (bench back-compat); the window wins when both are set.
|
|
53
|
+
* KISO_POLICY_SUMMARY_KEEP (rounds) and KISO_POLICY_SUMMARY_KEEP_TOKENS
|
|
54
|
+
* override the runtime defaults (KEEP_RECENT_ROUNDS = 4,
|
|
55
|
+
* KEEP_TOKENS_DEFAULT = 20,000) — emitted only when set.
|
|
56
|
+
* KISO_POLICY_SUMMARY_MAX_FAILURES overrides the (h) circuit-breaker
|
|
57
|
+
* default (MAX_SUMMARY_FAILURES = 3).
|
|
58
|
+
* KISO_POLICY_DROP=1 switches the armed mode to the crux C arm
|
|
59
|
+
* (mechanical drop — same trigger/keep envs); KISO_POLICY_MICROCOMPACT
|
|
60
|
+
* arms the session-aware override (MIN_TURNS = the no-fire guard).
|
|
61
|
+
*/
|
|
62
|
+
export declare function contextPolicyFromEnv(): ContextPolicy | undefined;
|
package/dist/index.js
CHANGED
|
@@ -26,8 +26,7 @@ import { readFileSync, realpathSync, rmSync } from "node:fs";
|
|
|
26
26
|
import { createInterface } from "node:readline";
|
|
27
27
|
import { fileURLToPath } from "node:url";
|
|
28
28
|
import { join } from "node:path";
|
|
29
|
-
import { Body, Editor, bannerLines, palette, renderSessionLine } from "@vincemakes/kiso-tui";
|
|
30
|
-
import { escapeTerminal } from "@vincemakes/kiso-tui";
|
|
29
|
+
import { Body, Editor, bannerLines, escapeTerminal, palette, renderSessionLine } from "@vincemakes/kiso-tui";
|
|
31
30
|
import { createAgent, disposeExtensions, loadExtensions, loadProjectExtensions, SessionStore, } from "@vincemakes/kiso-runtime";
|
|
32
31
|
import { createFauxProvider } from "@vincemakes/kiso-evals";
|
|
33
32
|
import { createCodingTools } from "@vincemakes/kiso-tools-node";
|
|
@@ -223,14 +222,13 @@ function bannerExtensionText() {
|
|
|
223
222
|
* resize; the resume list re-gates with the tier); off-TTY: the
|
|
224
223
|
* historical `[N extensions: ...]` standalone line (zero change). */
|
|
225
224
|
function extensionsBanner(resume = []) {
|
|
226
|
-
if (process.stdout.isTTY) {
|
|
227
|
-
body.banner(VERSION, bannerExtensionText().replace(/^ · /, ""), resume);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
225
|
const text = bannerExtensionText();
|
|
231
|
-
if (
|
|
226
|
+
if (!process.stdout.isTTY) {
|
|
227
|
+
if (text !== "")
|
|
228
|
+
bodyLog(`${text}\n`);
|
|
232
229
|
return;
|
|
233
|
-
|
|
230
|
+
}
|
|
231
|
+
body.banner(VERSION, text.replace(/^ · /, ""), resume);
|
|
234
232
|
}
|
|
235
233
|
/** W5: the opening-screen resume list — up to 3 recent sessions, newest
|
|
236
234
|
* first, the CURRENT session excluded (it is not something to pick back
|
|
@@ -278,7 +276,6 @@ Report what you did in one or two lines per change.`;
|
|
|
278
276
|
/** The project-instructions file names, in priority order (A area). */
|
|
279
277
|
const INSTRUCTION_FILES = ["AGENTS.md", "CLAUDE.md"];
|
|
280
278
|
/** Hard cap for injected instructions — truncate and say so. */
|
|
281
|
-
const INSTRUCTION_MAX = 8 * 1024;
|
|
282
279
|
/**
|
|
283
280
|
* A area: read the FIRST present instruction file (AGENTS.md preferred) and
|
|
284
281
|
* return it as an injected section, or "" when none exists. Truncated at
|
|
@@ -294,8 +291,7 @@ export function readProjectInstructions(cwd) {
|
|
|
294
291
|
catch {
|
|
295
292
|
continue; // not present — try the next
|
|
296
293
|
}
|
|
297
|
-
|
|
298
|
-
return `\n\n=== Project instructions (${name}) ===\n${body}`;
|
|
294
|
+
return `\n\n=== Project instructions (${name}) ===\n${text.length > 8 * 1024 ? text.slice(0, 8 * 1024) + `\n\n[truncated at ${8 * 1024} chars]` : text}`;
|
|
299
295
|
}
|
|
300
296
|
return "";
|
|
301
297
|
}
|
|
@@ -305,6 +301,51 @@ export function composeSystemPrompt(cwd) {
|
|
|
305
301
|
const injected = readProjectInstructions(cwd);
|
|
306
302
|
return injected === "" ? SYSTEM_PROMPT : `${SYSTEM_PROMPT}\n${injected}`;
|
|
307
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* E6: the run-start context policy, OFF unless env-armed (invalid values
|
|
306
|
+
* are ABSENT, never a crash — the autoCompactFromEnv convention).
|
|
307
|
+
* The product arming is KISO_CONTEXT_WINDOW → window − POLICY_RESERVE
|
|
308
|
+
* (the window rides the config as windowTokens; the runtime owns the
|
|
309
|
+
* arithmetic — never a fixed low absolute). KISO_POLICY_SUMMARY_TRIGGER
|
|
310
|
+
* survives ONLY as the legacy absolute override when no window is set
|
|
311
|
+
* (bench back-compat); the window wins when both are set.
|
|
312
|
+
* KISO_POLICY_SUMMARY_KEEP (rounds) and KISO_POLICY_SUMMARY_KEEP_TOKENS
|
|
313
|
+
* override the runtime defaults (KEEP_RECENT_ROUNDS = 4,
|
|
314
|
+
* KEEP_TOKENS_DEFAULT = 20,000) — emitted only when set.
|
|
315
|
+
* KISO_POLICY_SUMMARY_MAX_FAILURES overrides the (h) circuit-breaker
|
|
316
|
+
* default (MAX_SUMMARY_FAILURES = 3).
|
|
317
|
+
* KISO_POLICY_DROP=1 switches the armed mode to the crux C arm
|
|
318
|
+
* (mechanical drop — same trigger/keep envs); KISO_POLICY_MICROCOMPACT
|
|
319
|
+
* arms the session-aware override (MIN_TURNS = the no-fire guard).
|
|
320
|
+
*/
|
|
321
|
+
export function contextPolicyFromEnv() {
|
|
322
|
+
const summaryTrigger = positiveIntEnv("KISO_POLICY_SUMMARY_TRIGGER");
|
|
323
|
+
const contextWindow = positiveIntEnv("KISO_CONTEXT_WINDOW");
|
|
324
|
+
const microcompactTrigger = positiveIntEnv("KISO_POLICY_MICROCOMPACT");
|
|
325
|
+
if (summaryTrigger === undefined && contextWindow === undefined && microcompactTrigger === undefined)
|
|
326
|
+
return undefined;
|
|
327
|
+
return {
|
|
328
|
+
...(summaryTrigger === undefined && contextWindow === undefined ? {} : {
|
|
329
|
+
[(process.env.KISO_POLICY_DROP === "1" ? "drop" : "summary")]: {
|
|
330
|
+
...(contextWindow !== undefined ? { windowTokens: contextWindow } : summaryTrigger !== undefined ? { triggerTokens: summaryTrigger } : {}),
|
|
331
|
+
...kv("keepRounds", "KISO_POLICY_SUMMARY_KEEP"),
|
|
332
|
+
...kv("keepTokens", "KISO_POLICY_SUMMARY_KEEP_TOKENS"),
|
|
333
|
+
...kv("maxFailures", "KISO_POLICY_SUMMARY_MAX_FAILURES"),
|
|
334
|
+
},
|
|
335
|
+
}),
|
|
336
|
+
...(microcompactTrigger !== undefined ? { microcompact: { thresholdTokens: microcompactTrigger, ...kv("keepResults", "KISO_POLICY_MICROCOMPACT_KEEP"), ...kv("minTurns", "KISO_POLICY_MICROCOMPACT_MIN_TURNS") } } : {}),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/** { [key]: value } when the env int is set — the spread-friendly optional field. */
|
|
340
|
+
function kv(key, env) {
|
|
341
|
+
const v = positiveIntEnv(env);
|
|
342
|
+
return v !== undefined ? { [key]: v } : {};
|
|
343
|
+
}
|
|
344
|
+
/** Parse a positive-int env var — absent or invalid is undefined (no crash). */
|
|
345
|
+
function positiveIntEnv(name) {
|
|
346
|
+
const n = Number.parseInt(process.env[name] ?? "", 10);
|
|
347
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
348
|
+
}
|
|
308
349
|
async function makeAgent(sessionId, input, modelFlag) {
|
|
309
350
|
// E3: the project-level trust gate runs BEFORE any extension load (the
|
|
310
351
|
// mcp/skills merges must be in the env when the user-level extensions
|
|
@@ -358,6 +399,8 @@ async function makeAgent(sessionId, input, modelFlag) {
|
|
|
358
399
|
// re-reads the config's extensions array per run).
|
|
359
400
|
const extensions = [...modeExtensions(), ...loadedExtensions];
|
|
360
401
|
setCurrentAgentExtensions(extensions);
|
|
402
|
+
// E6: the run-start context policy (captured once — exactOptionalPropertyTypes).
|
|
403
|
+
const contextPolicy = contextPolicyFromEnv();
|
|
361
404
|
const definition = {
|
|
362
405
|
model,
|
|
363
406
|
store,
|
|
@@ -379,6 +422,8 @@ async function makeAgent(sessionId, input, modelFlag) {
|
|
|
379
422
|
// 200k window → 100k tokens). Long sessions compact old read/list/
|
|
380
423
|
// search/shell outputs instead of silently growing past the window.
|
|
381
424
|
microcompact: { thresholdTokens: contextWindowTokens() / 2 },
|
|
425
|
+
// E6: the run-start context policy — OFF unless env-armed (beats the microcompact default when both fire).
|
|
426
|
+
...(contextPolicy !== undefined ? { contextPolicy } : {}),
|
|
382
427
|
maxTurns: 20,
|
|
383
428
|
// Modes: the five tiers join at the CHAIN HEAD, before the user/
|
|
384
429
|
// project extensions (the deny>ask>allow composition keeps a user
|
|
@@ -462,11 +507,8 @@ async function main() {
|
|
|
462
507
|
// (its verdict decides whether the project config exists at all) —
|
|
463
508
|
// unless a higher layer (--mode flag / KISO_MODE) already decided.
|
|
464
509
|
const applyConfigMode = () => {
|
|
465
|
-
if (modeFlag
|
|
466
|
-
|
|
467
|
-
const m = mergedConfig.mode;
|
|
468
|
-
if (m !== undefined)
|
|
469
|
-
setMode(m);
|
|
510
|
+
if (modeFlag === -1 && process.env.KISO_MODE === undefined && mergedConfig.mode !== undefined)
|
|
511
|
+
setMode(mergedConfig.mode);
|
|
470
512
|
};
|
|
471
513
|
switch (command) {
|
|
472
514
|
case "chat": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-code",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "kiso CLI
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "kiso CLI — the durable coding agent that survives kill -9: kiso chat / kiso resume / kiso sessions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@vincemakes/kiso-core": "0.
|
|
22
|
-
"@vincemakes/kiso-evals": "0.
|
|
23
|
-
"@vincemakes/kiso-mcp-ext": "0.
|
|
24
|
-
"@vincemakes/kiso-provider-anthropic": "0.
|
|
25
|
-
"@vincemakes/kiso-provider-openai": "0.
|
|
26
|
-
"@vincemakes/kiso-runtime": "0.
|
|
27
|
-
"@vincemakes/kiso-skills-ext": "0.
|
|
28
|
-
"@vincemakes/kiso-subagent-ext": "0.
|
|
29
|
-
"@vincemakes/kiso-task-ext": "0.
|
|
30
|
-
"@vincemakes/kiso-tools-node": "0.
|
|
31
|
-
"@vincemakes/kiso-tui": "0.
|
|
32
|
-
"@vincemakes/kiso-tui-cells": "0.
|
|
21
|
+
"@vincemakes/kiso-core": "0.5.0",
|
|
22
|
+
"@vincemakes/kiso-evals": "0.5.0",
|
|
23
|
+
"@vincemakes/kiso-mcp-ext": "0.5.0",
|
|
24
|
+
"@vincemakes/kiso-provider-anthropic": "0.5.0",
|
|
25
|
+
"@vincemakes/kiso-provider-openai": "0.5.0",
|
|
26
|
+
"@vincemakes/kiso-runtime": "0.5.0",
|
|
27
|
+
"@vincemakes/kiso-skills-ext": "0.5.0",
|
|
28
|
+
"@vincemakes/kiso-subagent-ext": "0.5.0",
|
|
29
|
+
"@vincemakes/kiso-task-ext": "0.5.0",
|
|
30
|
+
"@vincemakes/kiso-tools-node": "0.5.0",
|
|
31
|
+
"@vincemakes/kiso-tui": "0.5.0",
|
|
32
|
+
"@vincemakes/kiso-tui-cells": "0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^26.1.2",
|