@0perator/operator 0.0.7 → 0.1.21

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.
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ // Split one line into styled inline spans: **bold**, `code`, *italic* / _italic_. Longest markers first.
4
+ function renderInline(text, kp) {
5
+ const nodes = [];
6
+ const re = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g;
7
+ let last = 0;
8
+ let m;
9
+ let i = 0;
10
+ while ((m = re.exec(text)) !== null) {
11
+ if (m.index > last)
12
+ nodes.push(_jsx(Text, { children: text.slice(last, m.index) }, `${kp}t${i++}`));
13
+ const tok = m[0];
14
+ if (tok.startsWith("**"))
15
+ nodes.push(_jsx(Text, { bold: true, children: tok.slice(2, -2) }, `${kp}b${i++}`));
16
+ else if (tok.startsWith("`"))
17
+ nodes.push(_jsx(Text, { color: "cyan", children: tok.slice(1, -1) }, `${kp}c${i++}`));
18
+ else
19
+ nodes.push(_jsx(Text, { italic: true, children: tok.slice(1, -1) }, `${kp}i${i++}`));
20
+ last = m.index + tok.length;
21
+ }
22
+ if (last < text.length)
23
+ nodes.push(_jsx(Text, { children: text.slice(last) }, `${kp}t${i++}`));
24
+ return nodes.length ? nodes : [_jsx(Text, { children: text }, `${kp}e`)];
25
+ }
26
+ export function Markdown({ content }) {
27
+ const lines = content.split("\n");
28
+ const blocks = [];
29
+ let inFence = false;
30
+ let fence = [];
31
+ let k = 0;
32
+ const flushFence = () => {
33
+ // Fenced code: verbatim, tinted, indented — no inline parsing inside.
34
+ blocks.push(_jsx(Box, { flexDirection: "column", paddingLeft: 1, children: fence.map((l, idx) => (_jsx(Text, { color: "cyan", dimColor: true, children: l.length ? l : " " }, idx))) }, `f${k++}`));
35
+ fence = [];
36
+ };
37
+ for (const line of lines) {
38
+ if (/^\s*```/.test(line)) {
39
+ if (inFence) {
40
+ flushFence();
41
+ inFence = false;
42
+ }
43
+ else {
44
+ inFence = true;
45
+ }
46
+ continue;
47
+ }
48
+ if (inFence) {
49
+ fence.push(line);
50
+ continue;
51
+ }
52
+ const h = /^(#{1,6})\s+(.*)$/.exec(line);
53
+ if (h) {
54
+ blocks.push(_jsx(Text, { bold: true, children: renderInline(h[2], `h${k}`) }, `h${k++}`));
55
+ continue;
56
+ }
57
+ const b = /^(\s*)[-*+]\s+(.*)$/.exec(line);
58
+ if (b) {
59
+ blocks.push(_jsxs(Text, { children: [b[1], _jsx(Text, { color: "cyan", children: "\u2022 " }), renderInline(b[2], `b${k}`)] }, `b${k++}`));
60
+ continue;
61
+ }
62
+ const n = /^(\s*)(\d+)\.\s+(.*)$/.exec(line);
63
+ if (n) {
64
+ blocks.push(_jsxs(Text, { children: [n[1], _jsxs(Text, { bold: true, children: [n[2], "."] }), " ", renderInline(n[3], `n${k}`)] }, `n${k++}`));
65
+ continue;
66
+ }
67
+ if (line.trim() === "") {
68
+ blocks.push(_jsx(Text, { children: " " }, `s${k++}`));
69
+ continue;
70
+ }
71
+ blocks.push(_jsx(Text, { children: renderInline(line, `p${k}`) }, `p${k++}`));
72
+ }
73
+ if (inFence && fence.length)
74
+ flushFence();
75
+ return _jsx(Box, { flexDirection: "column", children: blocks });
76
+ }
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Boot masthead (SPEC §6) — header design #29 "Gradient Constellation": the OPERATOR wordmark at full
3
+ // block-letter scale, each letter washed one step along a violet→magenta ramp, framed above and below by
4
+ // a dim constellation star field. Two renderers share ONE source of truth (GLYPHS/GRAD/STAR_*):
5
+ //
6
+ // • mastheadLines() — chalk-colored plain strings, printed ONCE to stdout at boot in cli.tsx BEFORE
7
+ // Ink mounts. This is why the big 5-row wordmark is reflow-safe: it lands in terminal scrollback as
8
+ // static text and never enters Ink's per-keystroke dynamic-frame redraw (the class of bug that moved
9
+ // the input to the top of the screen when a line hit exact terminal width).
10
+ // • <Masthead/> — the same design as Ink <Box>/<Text>, for the static AuthScreen (no live composer
11
+ // below it, so no reflow hazard). NOT used inside App's dynamic tree.
12
+ import React from "react";
13
+ import { Box, Text } from "ink";
14
+ import chalk from "chalk";
15
+ // 5-row block glyphs (█ U+2588, BMP). Only the letters of OPERATOR are needed.
16
+ const GLYPHS = {
17
+ O: [" ███ ", "█ █", "█ █", "█ █", " ███ "],
18
+ P: ["████ ", "█ █", "████ ", "█ ", "█ "],
19
+ E: ["█████", "█ ", "████ ", "█ ", "█████"],
20
+ R: ["████ ", "█ █", "████ ", "█ █ ", "█ █"],
21
+ A: [" ███ ", "█ █", "█████", "█ █", "█ █"],
22
+ T: ["█████", " █ ", " █ ", " █ ", " █ "],
23
+ };
24
+ // violet→magenta ramp, one step per letter of OPERATOR (8 letters, 8 stops).
25
+ const GRAD = ["#5f4a80", "#7a5fb0", "#9068c9", "#a878e0", "#b98cf0", "#c07cff", "#c88fff", "#d3a6ff"];
26
+ const WORD = "OPERATOR";
27
+ const GLYPH_W = 5; // each block glyph is 5 cols wide
28
+ const WORD_W = WORD.length * GLYPH_W + (WORD.length - 1); // 8*5 + 7 gaps = 47 visible cols
29
+ // Constellation star rows framing the wordmark (✦ U+2726, ✧ U+2727, · U+00B7 — all BMP, render on macOS).
30
+ const STAR_TOP = "· ✦ ✧ · ✦ ✧ ·";
31
+ const STAR_BOT = " ✧ · ✦ · ✧ ✦ ·";
32
+ const STAR = "✷"; // AXE signal star (brand glyph, matches ThinkingSpinner)
33
+ /** The 5 block-wordmark rows as arrays of per-letter cells (cell i belongs to WORD[i], colored GRAD[i]). */
34
+ function wordCells() {
35
+ const rows = [[], [], [], [], []];
36
+ for (let i = 0; i < WORD.length; i++) {
37
+ const g = GLYPHS[WORD[i]];
38
+ for (let r = 0; r < 5; r++)
39
+ rows[r].push(g[r]);
40
+ }
41
+ return rows;
42
+ }
43
+ function pad(cols, visibleWidth) {
44
+ return " ".repeat(Math.max(0, Math.floor((cols - visibleWidth) / 2)));
45
+ }
46
+ /**
47
+ * Boot banner as chalk-colored lines for a one-time stdout print. `info` is the dim tagline
48
+ * (e.g. "aurora · 1M · v0.1.21"). Falls back to a compact one-line wordmark on a narrow terminal
49
+ * so the block letters never wrap (a wrapped glyph row is unreadable).
50
+ */
51
+ export function mastheadLines(info, cols = process.stdout.columns ?? 80) {
52
+ if (cols < WORD_W + 4) {
53
+ // compact fallback: single-line gradient wordmark + tagline
54
+ const compact = WORD.split("").map((c, i) => chalk.hex(GRAD[i])(c)).join("");
55
+ return ["", ` ${chalk.hex(GRAD[5])(STAR)} ${chalk.bold(compact)} ${chalk.dim(info)}`, ""];
56
+ }
57
+ const cells = wordCells();
58
+ const wordPad = pad(cols, WORD_W);
59
+ const lines = [""];
60
+ lines.push(pad(cols, STAR_TOP.length) + chalk.dim(STAR_TOP));
61
+ for (let r = 0; r < 5; r++) {
62
+ lines.push(wordPad + cells[r].map((cell, i) => chalk.hex(GRAD[i])(cell)).join(" "));
63
+ }
64
+ lines.push(pad(cols, STAR_BOT.length) + chalk.dim(STAR_BOT));
65
+ const tag = `${STAR} OPERATOR · ${info}`;
66
+ lines.push(pad(cols, tag.length) + chalk.dim(tag));
67
+ lines.push("");
68
+ return lines;
69
+ }
70
+ /** Ink render of design #29 — for static screens only (AuthScreen). Not for App's live tree. */
71
+ export function Masthead({ info }) {
72
+ const cols = process.stdout.columns ?? 80;
73
+ if (cols < WORD_W + 4) {
74
+ return (_jsxs(Box, { children: [_jsx(Text, { color: GRAD[5], bold: true, children: ` ${STAR} ` }), WORD.split("").map((c, i) => (_jsx(Text, { color: GRAD[i], bold: true, children: c }, i))), _jsx(Text, { dimColor: true, children: ` ${info}` })] }));
75
+ }
76
+ const cells = wordCells();
77
+ return (_jsxs(Box, { flexDirection: "column", alignItems: "center", children: [_jsx(Text, { dimColor: true, children: STAR_TOP }), cells.map((row, r) => (_jsx(Box, { children: row.map((cell, i) => (_jsxs(React.Fragment, { children: [_jsx(Text, { color: GRAD[i], children: cell }), i < row.length - 1 ? _jsx(Text, { children: " " }) : null] }, i))) }, r))), _jsx(Text, { dimColor: true, children: STAR_BOT }), _jsx(Text, { dimColor: true, children: `${STAR} OPERATOR · ${info}` })] }));
78
+ }
@@ -2,8 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  export function StatusRule({ route, ctxPct, version, build, user }) {
4
4
  const who = user ? `⬤ ${user} · ` : "";
5
- const tag = ` ${who}${route} · ${Math.round(ctxPct)}% · Operator v${version}${build ? ` ·${build}` : ""} `;
5
+ // Info block: identity · route · ctx% · version. Kept as one string so the width math is exact.
6
+ const info = `${who}${route} · ${Math.round(ctxPct)}% · v${version}${build ? ` ·${build}` : ""}`;
7
+ // The full right-hand content, styled below in segments (✷ magenta, OPERATOR bold, info dim). This
8
+ // plain string is only used to measure width so the leading rule fills precisely.
9
+ const right = `✷ OPERATOR · ${info} ─`;
6
10
  const cols = process.stdout.columns ?? 80;
7
- const fill = Math.max(1, cols - tag.length - 1);
8
- return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "─".repeat(fill) }), _jsx(Text, { dimColor: true, children: tag + "─" })] }));
11
+ // Total width = fill + 1 space + right. Fill to cols-1, NOT cols: a line exactly the terminal width
12
+ // auto-wraps to a 2nd physical line Ink's height accounting misses, so its per-render erase is off by
13
+ // one and the whole dynamic frame (incl. the input) creeps UP the screen on each keystroke.
14
+ const fill = Math.max(1, cols - right.length - 2);
15
+ // Enterprise header: a dim rule sweeping to a magenta ✷ mark + bright OPERATOR wordmark + dim info,
16
+ // sitting just above the composer (the input is bounded between this and the InputRule below).
17
+ return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "─".repeat(fill) + " " }), _jsx(Text, { color: "magenta", children: "\u2737 " }), _jsx(Text, { bold: true, children: "OPERATOR" }), _jsx(Text, { dimColor: true, children: ` · ${info} ─` })] }));
9
18
  }
@@ -1,10 +1,11 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box, Static, Text } from "ink";
3
3
  import { ToolStep } from "./ToolStep.js";
4
+ import { Markdown } from "./Markdown.js";
4
5
  function entryKey(entry) {
5
6
  return entry.kind === "message" ? entry.message.id : entry.step.id;
6
7
  }
7
- function renderEntry(entry) {
8
+ function renderEntry(entry, live = false) {
8
9
  if (entry.kind === "message") {
9
10
  const { message } = entry;
10
11
  if (message.role === "user") {
@@ -13,10 +14,14 @@ function renderEntry(entry) {
13
14
  if (message.role === "system") {
14
15
  return _jsx(Text, { dimColor: true, children: message.content }); // slash-command output / status notes
15
16
  }
16
- return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { children: message.content }), message.reasoning ? _jsx(Text, { dimColor: true, children: message.reasoning }) : null] }));
17
+ // Thought process first, dimmed and lower-opacity; the real answer follows at full weight, so the
18
+ // reasoning reads as recessive scaffolding and the answer stands out (per the requested look).
19
+ // Settled answers render as markdown (bold/code/lists/headers formatted, not raw `**`/backticks);
20
+ // the LIVE stream stays plain text so a half-open ``` fence can't swallow the text while it types.
21
+ return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [message.reasoning ? _jsx(Text, { dimColor: true, children: message.reasoning }) : null, message.content ? (live ? _jsx(Text, { children: message.content }) : _jsx(Markdown, { content: message.content })) : null] }));
17
22
  }
18
23
  return _jsx(ToolStep, { step: entry.step });
19
24
  }
20
25
  export function Transcript({ entries, live }) {
21
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live) }) : null] }));
26
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true) }) : null] }));
22
27
  }
package/dist/update.js CHANGED
@@ -3,8 +3,8 @@
3
3
  // • source/dev → a git checkout linked via `npm link`; update = pull + rebuild.
4
4
  // We detect the shape from where THIS module resolves: a checkout still has a .git above it;
5
5
  // a global install lives under a node_modules tree with no repo around it.
6
- import { spawnSync } from "node:child_process";
7
- import { existsSync } from "node:fs";
6
+ import { spawnSync, execSync } from "node:child_process";
7
+ import { existsSync, readFileSync } from "node:fs";
8
8
  import { dirname, join, resolve } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
10
  const PKG = "@0perator/operator"; // published (private) scope/name — keep in sync with package.json
@@ -43,8 +43,20 @@ export async function runUpdate() {
43
43
  if (code !== 0)
44
44
  return code;
45
45
  code = run("npm", ["run", "build"], pkgDir);
46
- if (code === 0)
47
- process.stderr.write("operator update: done (rebuilt from source).\n");
46
+ if (code === 0) {
47
+ let ver = "?", sha = "";
48
+ try {
49
+ ver = JSON.parse(readFileSync(join(pkgDir, "package.json"), "utf8")).version;
50
+ }
51
+ catch { /* best-effort */ }
52
+ try {
53
+ sha = execSync(`git -C '${repo}' rev-parse --short HEAD`).toString().trim();
54
+ }
55
+ catch { /* best-effort */ }
56
+ process.stderr.write(`\noperator update: ✓ updated to v${ver}${sha ? ` (${sha})` : ""} and rebuilt.\n` +
57
+ `RESTART to run it — type /exit and relaunch \`operator\`, or open a new terminal. Your CURRENT ` +
58
+ `session keeps the old version until you restart (that is why a re-run can behave the same).\n`);
59
+ }
48
60
  return code;
49
61
  }
50
62
  process.stderr.write(`operator update: reinstalling ${PKG}@latest from the registry\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.0.7",
3
+ "version": "0.1.21",
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": {
@@ -23,6 +23,7 @@
23
23
  "prepublishOnly": "npm run build && npm test"
24
24
  },
25
25
  "dependencies": {
26
+ "chalk": "^5.6.2",
26
27
  "ink": "^5.0.1",
27
28
  "react": "^18.3.1"
28
29
  },