@vincemakes/kiso-code 0.1.14 → 0.1.16
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/body.d.ts +121 -0
- package/dist/body.js +478 -0
- package/dist/diff.d.ts +32 -0
- package/dist/diff.js +122 -0
- package/dist/dock.d.ts +13 -15
- package/dist/dock.js +11 -37
- package/dist/index.js +231 -142
- package/dist/mode.d.ts +33 -0
- package/dist/mode.js +93 -0
- package/dist/render.d.ts +1 -0
- package/dist/render.js +2 -2
- package/package.json +7 -7
package/dist/mode.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modes — the five built-in approval tiers, built ON the E1 policy chain
|
|
3
|
+
* (the kernel is untouched). Each tier is an in-process "mode:<name>"
|
|
4
|
+
* extension whose decide() is live — it only speaks when it is the
|
|
5
|
+
* CURRENT tier (otherwise abstain = no opinion, ADR-0042), so /mode
|
|
6
|
+
* switches take effect immediately. The extension NAME rides the runtime's decidedBy
|
|
7
|
+
* field: an automated denial records decidedBy: "mode:<name>" — the
|
|
8
|
+
* audit sell. User-level extensions stay on the chain AFTER the mode
|
|
9
|
+
* tiers; a user deny always wins (the chain's deny>ask>allow
|
|
10
|
+
* monotonicity — bypass cannot override an extension deny).
|
|
11
|
+
*/
|
|
12
|
+
export const MODES = ["manual", "default", "accept-edits", "plan", "bypass"];
|
|
13
|
+
/** The read-only tool set (plan): reading is allowed, everything else
|
|
14
|
+
* denied with the guiding reason. */
|
|
15
|
+
const READ_TOOLS = new Set(["read_file", "list_dir", "search_text", "read_skill"]);
|
|
16
|
+
let current = "default";
|
|
17
|
+
export function getMode() {
|
|
18
|
+
return current;
|
|
19
|
+
}
|
|
20
|
+
export function setMode(m) {
|
|
21
|
+
current = m;
|
|
22
|
+
}
|
|
23
|
+
/** The startup mode: KISO_MODE env (or the --mode flag — the CLI applies
|
|
24
|
+
* it before the first makeAgent). */
|
|
25
|
+
export function modeFromEnv() {
|
|
26
|
+
const raw = process.env.KISO_MODE;
|
|
27
|
+
const m = MODES.find((x) => x === raw);
|
|
28
|
+
return m ?? "default";
|
|
29
|
+
}
|
|
30
|
+
/** The per-tier verdict for a tool call — only when this tier is current. */
|
|
31
|
+
function tierVerdict(tier, call) {
|
|
32
|
+
if (tier !== current)
|
|
33
|
+
return { action: "abstain" }; // not our tier — no opinion
|
|
34
|
+
switch (tier) {
|
|
35
|
+
case "manual":
|
|
36
|
+
return { action: "ask" }; // every tool asks
|
|
37
|
+
case "default":
|
|
38
|
+
if (READ_TOOLS.has(call.name))
|
|
39
|
+
return { action: "allow" };
|
|
40
|
+
if (call.name === "write_file" || call.name === "edit_file" || call.name === "shell")
|
|
41
|
+
return { action: "ask" };
|
|
42
|
+
// Abstain (ADR-0042): an extension-provided tool is the
|
|
43
|
+
// EXTENSIONS' business — the tier neither allows nor denies.
|
|
44
|
+
// The chain falls to the ask flow when nobody else speaks, so
|
|
45
|
+
// an uncovered external tool STILL meets the human (the P2
|
|
46
|
+
// finding: "allow"-as-no-opinion auto-approved it).
|
|
47
|
+
return { action: "abstain" };
|
|
48
|
+
case "accept-edits":
|
|
49
|
+
if (READ_TOOLS.has(call.name))
|
|
50
|
+
return { action: "allow" };
|
|
51
|
+
if (call.name === "write_file" || call.name === "edit_file")
|
|
52
|
+
return { action: "allow" };
|
|
53
|
+
if (call.name === "shell")
|
|
54
|
+
return { action: "ask" };
|
|
55
|
+
return { action: "abstain" }; // see "default"
|
|
56
|
+
case "plan":
|
|
57
|
+
if (READ_TOOLS.has(call.name))
|
|
58
|
+
return { action: "allow" };
|
|
59
|
+
return { action: "deny", reason: "plan mode: read-only" };
|
|
60
|
+
case "bypass":
|
|
61
|
+
return { action: "allow" }; // everything — a REAL allow, never an abstain
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** The five built-in mode tiers as chain extensions — named "mode:<tier>"
|
|
65
|
+
* so the runtime's decidedBy records exactly that (the runtime derives
|
|
66
|
+
* approvalPolicies from extensions[].approvals, tagging each with the
|
|
67
|
+
* extension name). The CURRENT tier is first: an all-allow chain records
|
|
68
|
+
* decidedBy = the FIRST SPEAKER, so an auto-allow under the startup mode
|
|
69
|
+
* names that mode honestly. Order never affects verdicts — the chain is
|
|
70
|
+
* deny>ask>allow over the SPEAKING verdicts (abstain = no opinion), so a
|
|
71
|
+
* user extension's deny wins over any mode tier, bypass included (the
|
|
72
|
+
* monotonicity e2e pins it). */
|
|
73
|
+
export function modeExtensions() {
|
|
74
|
+
return [...MODES.filter((m) => m === current), ...MODES.filter((m) => m !== current)].map((m) => ({
|
|
75
|
+
name: `mode:${m}`,
|
|
76
|
+
approvals: [
|
|
77
|
+
{
|
|
78
|
+
decide: async (payload) => tierVerdict(m, { name: payload.name }),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
/** The plan tier's system prompt addition — injected at startup when the
|
|
84
|
+
* initial mode is plan (the session prompt is fixed at creation; runtime
|
|
85
|
+
* switches are guided by the deny reason). */
|
|
86
|
+
export function modeSystemPrompt() {
|
|
87
|
+
if (current !== "plan")
|
|
88
|
+
return undefined;
|
|
89
|
+
return ("plan mode: read-only. You may inspect the workspace (read_file, list_dir, search_text, " +
|
|
90
|
+
"read_skill) but every write/edit/shell call is DENIED with 'plan mode: read-only'. " +
|
|
91
|
+
"Produce a concrete plan (files, searches, proposed edits) as your output; the human " +
|
|
92
|
+
"switches to another mode to execute it.");
|
|
93
|
+
}
|
package/dist/render.d.ts
CHANGED
package/dist/render.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* the lines a human sees. Colors are raw ANSI — no dependencies.
|
|
4
4
|
*/
|
|
5
5
|
import { canonicalTargetPath } from "@vincemakes/kiso-tools-node";
|
|
6
|
-
export const COLOR_ON = { blue: "\x1b[38;5;75m", dim: "\x1b[2m", red: "\x1b[31m", reset: "\x1b[0m" };
|
|
7
|
-
export const COLOR_OFF = { blue: "", dim: "", red: "", reset: "" };
|
|
6
|
+
export const COLOR_ON = { blue: "\x1b[38;5;75m", dim: "\x1b[2m", red: "\x1b[31m", green: "\x1b[32m", reset: "\x1b[0m" };
|
|
7
|
+
export const COLOR_OFF = { blue: "", dim: "", red: "", green: "", reset: "" };
|
|
8
8
|
export function palette() {
|
|
9
9
|
return process.env.NO_COLOR === undefined && process.stdout.isTTY ? COLOR_ON : COLOR_OFF;
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-code",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "kiso CLI — the coding-agent reference product: kiso chat / kiso resume / kiso sessions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@vincemakes/kiso-core": "0.1.
|
|
22
|
-
"@vincemakes/kiso-evals": "0.1.
|
|
23
|
-
"@vincemakes/kiso-provider-anthropic": "0.1.
|
|
24
|
-
"@vincemakes/kiso-provider-openai": "0.1.
|
|
25
|
-
"@vincemakes/kiso-runtime": "0.1.
|
|
26
|
-
"@vincemakes/kiso-tools-node": "0.1.
|
|
21
|
+
"@vincemakes/kiso-core": "0.1.16",
|
|
22
|
+
"@vincemakes/kiso-evals": "0.1.16",
|
|
23
|
+
"@vincemakes/kiso-provider-anthropic": "0.1.16",
|
|
24
|
+
"@vincemakes/kiso-provider-openai": "0.1.16",
|
|
25
|
+
"@vincemakes/kiso-runtime": "0.1.16",
|
|
26
|
+
"@vincemakes/kiso-tools-node": "0.1.16"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.1.2",
|