@0perator/operator 0.1.61 → 0.1.153
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/CHANGELOG.md +1037 -1
- package/LICENSE +19 -0
- package/dist/acp/agent.js +103 -0
- package/dist/acp/run.js +23 -0
- package/dist/auth/client.js +4 -1
- package/dist/auth/login-intent.js +12 -0
- package/dist/autonomy/board-run.js +65 -0
- package/dist/autonomy/board.js +83 -0
- package/dist/autonomy/dream.js +71 -0
- package/dist/autonomy/headless.js +70 -0
- package/dist/autonomy/index.js +260 -0
- package/dist/autonomy/keepawake.js +84 -0
- package/dist/autonomy/loop.js +82 -0
- package/dist/autonomy/reporter.js +54 -0
- package/dist/autonomy/routine-run.js +25 -0
- package/dist/autonomy/routines.js +173 -0
- package/dist/autonomy/session-factory.js +61 -0
- package/dist/background/index.js +269 -20
- package/dist/background/worktree.js +62 -0
- package/dist/cli.js +535 -112
- package/dist/config/brand.js +81 -0
- package/dist/config/operator-harness.js +86 -0
- package/dist/config/persona.js +174 -0
- package/dist/config/settings.js +98 -9
- package/dist/engine/agent.js +447 -51
- package/dist/engine/aurora.js +180 -64
- package/dist/engine/compaction.js +97 -5
- package/dist/engine/grandmaster.js +69 -10
- package/dist/engine/router-adapter.js +3 -0
- package/dist/engine/selfheal.js +35 -0
- package/dist/engine/verify-gate.js +81 -0
- package/dist/mcp/index.js +1 -1
- package/dist/permissions/index.js +13 -7
- package/dist/router/models.js +13 -4
- package/dist/router/router.js +46 -7
- package/dist/selfimprove/index.js +88 -0
- package/dist/services/preflight.js +42 -1
- package/dist/session.js +228 -21
- package/dist/telemetry/events.js +9 -0
- package/dist/tools/executor.js +48 -24
- package/dist/tools/git-status.js +71 -0
- package/dist/tools/mutating.js +9 -0
- package/dist/tools/registry.js +214 -11
- package/dist/tools/result-cap.js +23 -0
- package/dist/tools/searxng.js +42 -2
- package/dist/ui/ActivitySpinner.js +6 -5
- package/dist/ui/App.js +23 -5
- package/dist/ui/AuthScreen.js +1 -1
- package/dist/ui/BgPanel.js +60 -5
- package/dist/ui/Composer.js +135 -13
- package/dist/ui/Header.js +14 -6
- package/dist/ui/InputRule.js +2 -1
- package/dist/ui/Markdown.js +69 -10
- package/dist/ui/Masthead.js +6 -4
- package/dist/ui/PlanPane.js +23 -0
- package/dist/ui/QuestionPrompt.js +22 -8
- package/dist/ui/StatsCard.js +15 -0
- package/dist/ui/StatusRule.js +13 -4
- package/dist/ui/SummaryCard.js +18 -0
- package/dist/ui/Table.js +114 -0
- package/dist/ui/ThinkingSpinner.js +6 -4
- package/dist/ui/ToolBatch.js +12 -0
- package/dist/ui/ToolStep.js +12 -4
- package/dist/ui/Transcript.js +30 -6
- package/dist/ui/chart.js +34 -0
- package/dist/ui/editdiff.js +84 -0
- package/dist/ui/highlight.js +89 -0
- package/dist/ui/osc.js +32 -0
- package/dist/ui/planExit.js +26 -0
- package/dist/ui/term.js +16 -0
- package/dist/ui/theme.js +60 -0
- package/dist/ui/tree.js +71 -0
- package/dist/util/slash.js +15 -0
- package/dist/util/throttle.js +28 -0
- package/package.json +10 -1
package/dist/ui/theme.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// One palette for the whole TUI (SPEC §6) — semantic color tokens with capability-aware fallbacks, so
|
|
2
|
+
// every component pulls from ONE source of truth instead of scattering hex/named colors across files.
|
|
3
|
+
// Terminal.app is the floor: 256-color, no truecolor — chalk downsamples our hex to ansi256 there, which
|
|
4
|
+
// looks right. But a 16-color or NO_COLOR terminal (dumb CI, a piped log) needs an EXPLICIT fallback,
|
|
5
|
+
// because chalk's automatic hex→16 picks a muddy color for a brand purple. So each token carries three
|
|
6
|
+
// tiers:
|
|
7
|
+
// hex — truecolor & 256 (levels 3/2): the brand shade
|
|
8
|
+
// ansi — a named ANSI-16 color for level 1
|
|
9
|
+
// hc — a bright named color for high-contrast mode (KODE_THEME=high-contrast)
|
|
10
|
+
// NO_COLOR / KODE_NO_COLOR / level 0 → undefined (Ink renders default fg, emits no escapes). Pure and
|
|
11
|
+
// testable: resolve() takes an explicit level+mode, so the palette is verified without a live TTY.
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
// Semantic tokens. Their hex values match the shades already in use at 0.1.77, so adopting the theme is
|
|
14
|
+
// a no-op at truecolor — the win is one place to change them plus real low-color / high-contrast paths.
|
|
15
|
+
const PALETTE = {
|
|
16
|
+
accent: { hex: "#b98cff", ansi: "magenta", hc: "magentaBright" }, // brand purple — star, wordmark, sub-agent
|
|
17
|
+
accentBright: { hex: "#d3a6ff", ansi: "magentaBright", hc: "magentaBright" },
|
|
18
|
+
info: { hex: "#5ec8e8", ansi: "cyan", hc: "cyanBright" }, // tool/step spinner, neutral highlight
|
|
19
|
+
success: { hex: "#5fd38a", ansi: "green", hc: "greenBright" }, // done / verified
|
|
20
|
+
error: { hex: "#ff6b6b", ansi: "red", hc: "redBright" }, // failed / unverified
|
|
21
|
+
warn: { hex: "#e8c14d", ansi: "yellow", hc: "yellowBright" }, // malformed / caution
|
|
22
|
+
running: { hex: "#e8a33d", ansi: "yellow", hc: "yellowBright" }, // in-flight amber (tool running, star heartbeat)
|
|
23
|
+
starBright: { hex: "#ffe2a0", ansi: "yellowBright", hc: "whiteBright" }, // the star's bright burst
|
|
24
|
+
textBright: { hex: "#ffffff", ansi: "whiteBright", hc: "whiteBright" }, // emphasized foreground
|
|
25
|
+
muted: { hex: "#8a8a8a", ansi: "gray", hc: "white" }, // borders, idle glyphs (a POSITIVE gray, not dimColor)
|
|
26
|
+
};
|
|
27
|
+
// The 8-stop purple ramp for the OPERATOR wordmark (Masthead). Kept here so the brand gradient is part
|
|
28
|
+
// of the one palette; Masthead imports it. chalk.hex downsamples each stop at low color levels.
|
|
29
|
+
export const GRAD = ["#5f4a80", "#7a5fb0", "#9068c9", "#a878e0", "#b98cf0", "#c07cff", "#c88fff", "#d3a6ff"];
|
|
30
|
+
/** The terminal's color level (0–3), honoring NO_COLOR / KODE_NO_COLOR. Mirrors chalk.level — the same
|
|
31
|
+
* signal Ink uses to downsample — so our tokens and Ink's own rendering always agree. */
|
|
32
|
+
export function detectLevel() {
|
|
33
|
+
if (process.env.NO_COLOR != null || process.env.KODE_NO_COLOR === "1")
|
|
34
|
+
return 0;
|
|
35
|
+
const lvl = chalk.level ?? 0;
|
|
36
|
+
return Math.max(0, Math.min(3, lvl));
|
|
37
|
+
}
|
|
38
|
+
/** High-contrast mode via KODE_THEME=high-contrast (or =hc): bright named colors on any capable term. */
|
|
39
|
+
export function detectMode() {
|
|
40
|
+
return /^(high-contrast|hc)$/i.test(process.env.KODE_THEME ?? "") ? "high-contrast" : "normal";
|
|
41
|
+
}
|
|
42
|
+
/** Resolve one token to an Ink `color` value, or undefined for no color. Pure: level + mode in, string
|
|
43
|
+
* out. The order matters — NO_COLOR wins over high-contrast, and high-contrast wins over the hex path. */
|
|
44
|
+
export function resolve(token, level, mode) {
|
|
45
|
+
if (level === 0)
|
|
46
|
+
return undefined; // NO_COLOR / dumb terminal — default fg, no escapes
|
|
47
|
+
const t = PALETTE[token];
|
|
48
|
+
if (mode === "high-contrast")
|
|
49
|
+
return t.hc; // bright named colors, maximally legible
|
|
50
|
+
if (level >= 2)
|
|
51
|
+
return t.hex; // truecolor & 256 — chalk maps hex→ansi256 at level 2
|
|
52
|
+
return t.ansi; // 16-color: the named fallback (never chalk's muddy auto-downsample of a brand hex)
|
|
53
|
+
}
|
|
54
|
+
export function makeTheme(level = detectLevel(), mode = detectMode()) {
|
|
55
|
+
const out = {};
|
|
56
|
+
for (const k of Object.keys(PALETTE))
|
|
57
|
+
out[k] = resolve(k, level, mode);
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
export const theme = makeTheme();
|
package/dist/ui/tree.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Tree renderer (SPEC §6, TUI wave item) — turns an indented outline into a connector-drawn tree
|
|
2
|
+
// (├─ └─ │), the way `tree(1)` shows a directory or a structure. Rendered for a ```tree fenced block in an
|
|
3
|
+
// assistant answer (Markdown.tsx), so the trigger is explicit, never guessed. Pure string→lines; connector
|
|
4
|
+
// glyphs are box-drawing (≤ U+257F), so they render in Terminal.app and width-account correctly.
|
|
5
|
+
//
|
|
6
|
+
// Input: lines whose LEADING INDENT (2 spaces or a tab per level) sets depth. Blank lines are dropped.
|
|
7
|
+
// root
|
|
8
|
+
// child a
|
|
9
|
+
// grandchild
|
|
10
|
+
// child b
|
|
11
|
+
// →
|
|
12
|
+
// root
|
|
13
|
+
// ├─ child a
|
|
14
|
+
// │ └─ grandchild
|
|
15
|
+
// └─ child b
|
|
16
|
+
function depthOf(line) {
|
|
17
|
+
const m = /^([ \t]*)/.exec(line)[1];
|
|
18
|
+
let d = 0, i = 0;
|
|
19
|
+
while (i < m.length) {
|
|
20
|
+
if (m[i] === "\t") {
|
|
21
|
+
d += 1;
|
|
22
|
+
i += 1;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
d += 1;
|
|
26
|
+
i += 2;
|
|
27
|
+
} // two spaces per level (a lone trailing space rounds up, harmless)
|
|
28
|
+
}
|
|
29
|
+
return d;
|
|
30
|
+
}
|
|
31
|
+
/** Render indented outline text to tree lines. Depth-0 nodes print bare (the roots); deeper nodes get
|
|
32
|
+
* ├─/└─ connectors with │ risers under ancestors that still have siblings below. Pure + testable. */
|
|
33
|
+
export function renderTree(text) {
|
|
34
|
+
const nodes = text.split("\n").filter((l) => l.trim().length > 0).map((l) => ({ depth: depthOf(l), text: l.trim() }));
|
|
35
|
+
// isLast[i]: node i is the last child at its own depth within its parent (no later sibling before the
|
|
36
|
+
// subtree closes, i.e. before a shallower node appears).
|
|
37
|
+
const isLast = (i) => {
|
|
38
|
+
for (let j = i + 1; j < nodes.length; j++) {
|
|
39
|
+
if (nodes[j].depth < nodes[i].depth)
|
|
40
|
+
return true;
|
|
41
|
+
if (nodes[j].depth === nodes[i].depth)
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
// ancestorHasMore[i][d]: an ancestor of node i at depth d still has a later sibling → draw a │ riser.
|
|
47
|
+
const out = [];
|
|
48
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
49
|
+
const { depth, text: t } = nodes[i];
|
|
50
|
+
if (depth === 0) {
|
|
51
|
+
out.push(t);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
let prefix = "";
|
|
55
|
+
for (let d = 0; d < depth - 1; d++) {
|
|
56
|
+
// does the ancestor at depth d have a later sibling after node i?
|
|
57
|
+
let more = false;
|
|
58
|
+
for (let j = i + 1; j < nodes.length; j++) {
|
|
59
|
+
if (nodes[j].depth < d + 1)
|
|
60
|
+
break;
|
|
61
|
+
if (nodes[j].depth === d + 1) {
|
|
62
|
+
more = true;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
prefix += more ? "│ " : " ";
|
|
67
|
+
}
|
|
68
|
+
out.push(prefix + (isLast(i) ? "└─ " : "├─ ") + t);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Slash-command guard: only single-line inputs whose first token is a KNOWN command are dispatched
|
|
2
|
+
// to handleSlash. A pasted path like "/Users/foo/bar" or multi-line text starting with "/" is NOT
|
|
3
|
+
// a slash command — it goes to the model as user input.
|
|
4
|
+
const KNOWN = new Set([
|
|
5
|
+
"help", "model", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
|
|
6
|
+
"think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "monitor",
|
|
7
|
+
"bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol",
|
|
8
|
+
]);
|
|
9
|
+
export function isSlashCommand(text) {
|
|
10
|
+
const t = text.trim();
|
|
11
|
+
if (!t.startsWith("/") || t.includes("\n"))
|
|
12
|
+
return false;
|
|
13
|
+
const cmd = t.slice(1).split(/\s+/)[0];
|
|
14
|
+
return KNOWN.has(cmd);
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Coalesce a high-frequency callback to a capped framerate. Ink re-renders the WHOLE non-Static frame on
|
|
2
|
+
// every state change, so an unthrottled update storm — a per-token reply stream, or a multi-agent swarm
|
|
3
|
+
// whose panel updates on every child token — makes a tall dynamic frame (plan + background panes + live
|
|
4
|
+
// tail) flicker. Wrapping the state-update in throttle() fires it at most once per `ms`, with a GUARANTEED
|
|
5
|
+
// trailing call so the final state always lands. Callers keep their live data in refs that the wrapped fn
|
|
6
|
+
// reads, and clear those refs to empty on turn/tool-batch end — so a late trailing tick resolves to the
|
|
7
|
+
// cleared state, never a stale re-show. SPEC §6 (TUI correctness).
|
|
8
|
+
export function throttle(fn, ms) {
|
|
9
|
+
let last = 0;
|
|
10
|
+
let timer = null;
|
|
11
|
+
return () => {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
const wait = ms - (now - last);
|
|
14
|
+
if (wait <= 0) {
|
|
15
|
+
if (timer) {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
timer = null;
|
|
18
|
+
}
|
|
19
|
+
last = now;
|
|
20
|
+
fn();
|
|
21
|
+
}
|
|
22
|
+
else if (!timer) {
|
|
23
|
+
// A call arrived inside the window — schedule ONE trailing run at the window's edge (coalesces every
|
|
24
|
+
// further call in between into that single run).
|
|
25
|
+
timer = setTimeout(() => { last = Date.now(); timer = null; fn(); }, wait);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.153",
|
|
4
4
|
"description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,17 +20,21 @@
|
|
|
20
20
|
"dev": "tsx src/cli.tsx",
|
|
21
21
|
"build": "tsc -p tsconfig.json",
|
|
22
22
|
"start": "node dist/cli.js",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"lint": "biome check src test",
|
|
23
25
|
"test": "tsx test/run.mts",
|
|
24
26
|
"test:watch": "tsx watch test/run.mts",
|
|
25
27
|
"prepublishOnly": "npm run build && npm test"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
30
|
+
"@zed-industries/agent-client-protocol": "^0.4.5",
|
|
28
31
|
"chalk": "^5.6.2",
|
|
29
32
|
"ink": "^5.0.1",
|
|
30
33
|
"react": "^18.3.1",
|
|
31
34
|
"ws": "^8.18.0"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
37
|
+
"@biomejs/biome": "2.5.14",
|
|
34
38
|
"@types/node": "^22.20.3",
|
|
35
39
|
"@types/react": "^18.3.3",
|
|
36
40
|
"ink-testing-library": "^3.0.0",
|
|
@@ -42,6 +46,11 @@
|
|
|
42
46
|
"url": "git+https://github.com/memjar/kode.git",
|
|
43
47
|
"directory": "kode-tsi"
|
|
44
48
|
},
|
|
49
|
+
"homepage": "https://github.com/memjar/kode/tree/main/kode-tsi#readme",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/memjar/kode/issues"
|
|
52
|
+
},
|
|
53
|
+
"main": "dist/index.js",
|
|
45
54
|
"license": "UNLICENSED",
|
|
46
55
|
"private": false,
|
|
47
56
|
"publishConfig": {
|