klui-code 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -40,7 +40,6 @@ Klui warns when the selected model can only read text.
40
40
  |---|---|
41
41
  | `/klui` | about card: model, credits left, links |
42
42
  | `/klui model` | pick one of the event models |
43
- | `/klui theme` | `klui-dark`, `klui-light` or `klui-arcade` (default follows your terminal) |
44
43
  | `/klui credits` | credits left on your pass |
45
44
  | `/klui retry` | reconnect after a wifi hiccup |
46
45
  | `/sessions` or `/resume` | pick up an earlier chat |
@@ -92,9 +91,9 @@ klui ──(1) device id──▶ Klui Pass ──▶ key from a pre-made pool
92
91
  so models can change mid-event without a new release. It never sees prompts or code: klui talks to
93
92
  the gateway directly.
94
93
  - **The CLI** is pi with one extension (`src/extension/`): the `klui` provider, the pixel header,
95
- the working line (a shimmering phrase, the time and tokens in one small box), the footer, one-line tool
94
+ the working line (a shimmering phrase, the time and tokens in one small box), the footer, labeled tool
96
95
  rows, the `subagent` tool (each subagent is a child `klui --mode json` process), `/klui`,
97
- `/sessions`, and three themes (`themes/`).
96
+ `/sessions`, and one look in dark and light (`themes/`), picked to match the terminal.
98
97
  - **Web access** (`src/extension/web.ts`): `web_search` and `web_fetch`. They run on the
99
98
  attendee's own machine with keyless services (Exa, then DuckDuckGo), never through Klui Pass, so
100
99
  every attendee has their own limits. Fetched pages return their full extracted text; downloads
package/dist/cli.js CHANGED
@@ -25,7 +25,8 @@ function seedSettings(config, piVersion) {
25
25
  // First run, or unreadable: start fresh.
26
26
  }
27
27
  const ids = new Set(config.models.map((m) => m.id));
28
- settings.theme ??= "klui-light/klui-dark";
28
+ // Klui has one look: dark, or light on a light terminal. Earlier versions let people pick others.
29
+ settings.theme = "klui-light/klui-dark";
29
30
  // Klui draws its own header, so Pi's logo and key hints would only flash up first.
30
31
  settings.quietStartup = true;
31
32
  settings.enabledModels ??= [`${PROVIDER}/*`];
@@ -1,4 +1,4 @@
1
- // /klui: an about card, plus quick pickers for the event models and Klui themes. /sessions: the
1
+ // /klui: an about card, plus a quick picker for the event models. /sessions: the
2
2
  // earlier chats, to pick one up again. /usage: tokens used in the last 24 hours and overall.
3
3
  import { SessionManager, SessionSelectorComponent } from "@earendil-works/pi-coding-agent";
4
4
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
@@ -9,27 +9,19 @@ import { renderPixels } from "../pixels.js";
9
9
  import { update } from "../update.js";
10
10
  import { readUsage } from "../usage.js";
11
11
  import { creditsLabel, modelLabel, state } from "./state.js";
12
- const THEMES = [
13
- { value: "klui-dark", label: "klui-dark", description: "sky blue on midnight" },
14
- { value: "klui-light", label: "klui-light", description: "crisp blue on white" },
15
- { value: "klui-arcade", label: "klui-arcade", description: "neon, for late-night hacking" },
16
- ];
17
12
  const SUBCOMMANDS = [
18
13
  { value: "model", label: "model", description: "pick one of the event models" },
19
- { value: "theme", label: "theme", description: "switch Klui themes" },
20
14
  { value: "credits", label: "credits", description: "check the credits left on your key" },
21
15
  { value: "retry", label: "retry", description: "reconnect to Klui after a network hiccup" },
22
16
  ];
23
17
  export function registerCommands(pi, actions) {
24
18
  pi.registerCommand("klui", {
25
- description: "About Klui, models, themes and credits",
19
+ description: "About Klui, models and credits",
26
20
  getArgumentCompletions: (prefix) => SUBCOMMANDS.filter((s) => s.value.startsWith(prefix.trim())),
27
21
  handler: async (args, ctx) => {
28
22
  const sub = args.trim().toLowerCase();
29
23
  if (sub === "model" || sub === "models")
30
24
  return pickModel(pi, ctx);
31
- if (sub === "theme" || sub === "themes")
32
- return pickTheme(ctx);
33
25
  if (sub === "retry")
34
26
  return actions.reconnect(ctx);
35
27
  if (sub === "credits") {
@@ -112,16 +104,6 @@ async function pickModel(pi, ctx) {
112
104
  ctx.ui.notify(`Switched to ${picked.name}`, "info");
113
105
  showThinkingMenu();
114
106
  }
115
- async function pickTheme(ctx) {
116
- const labels = THEMES.map((t) => `${t.label} — ${t.description}`);
117
- const choice = await ctx.ui.select("Pick a theme", labels);
118
- if (choice === undefined)
119
- return;
120
- const theme = THEMES[labels.indexOf(choice)];
121
- const result = ctx.ui.setTheme(theme.value);
122
- if (!result.success)
123
- ctx.ui.notify(result.error ?? "Couldn't switch themes.", "error");
124
- }
125
107
  function aboutCard(theme, done) {
126
108
  const border = (s) => theme.fg("borderAccent", s);
127
109
  return {
@@ -151,7 +133,7 @@ function aboutCard(theme, done) {
151
133
  "",
152
134
  ];
153
135
  const body = mascot.map((row, i) => `${row} ${lines[i] ?? ""}`);
154
- body.push("", theme.fg("dim", "/klui model · /klui theme · /klui credits any key to close"));
136
+ body.push("", theme.fg("dim", "/klui model · /klui credits · /usage any key to close"));
155
137
  const pad = (line) => {
156
138
  const fitted = truncateToWidth(line, inner, "");
157
139
  return `${border("│")} ${fitted}${" ".repeat(Math.max(0, inner - visibleWidth(fitted)))} ${border("│")}`;
@@ -1,8 +1,9 @@
1
- // Tool calls drawn the way Claude Code draws them: "● Update(src/app.ts)" with the outcome under
2
- // it, "⎿ Updated src/app.ts with 4 additions and 1 removal", and edits shown as a short diff. Click
3
- // a row, or press the expand key, to see the call and its output drawn the way Pi normally draws them.
1
+ // Tool calls drawn as a labeled row: the tool's name in a label colored by how it's going, then
2
+ // what it works on, "[ Update ] src/app.ts", with the outcome under it, "⎿ Updated src/app.ts with 4
3
+ // additions and 1 removal", and edits shown as a short diff. Click a row, or press the expand key,
4
+ // to see the call and its output drawn the way Pi normally draws them.
4
5
  import { keyText, renderDiff } from "@earendil-works/pi-coding-agent";
5
- import { Box, Container, Text, truncateToWidth } from "@earendil-works/pi-tui";
6
+ import { Box, Container, indexedColor, parseColor, styleText, Text, truncateToWidth } from "@earendil-works/pi-tui";
6
7
  import { isAbsolute, relative } from "node:path";
7
8
  import { agentLines, formatTokens } from "./agents.js";
8
9
  import { DECLINED } from "./permissions.js";
@@ -36,28 +37,41 @@ class Lines {
36
37
  invalidate() { }
37
38
  }
38
39
  const NOTHING = new Container();
40
+ /**
41
+ * Label colors, text then background: lavender while the tool runs, Klui blue when done, red when it
42
+ * failed. Terminals without 24-bit color (Apple's Terminal) get the 256-color numbers picked to
43
+ * match; rounding the deep backgrounds there would turn the blue label teal.
44
+ */
45
+ const LABELS = {
46
+ dark: { running: ["#b9a8ff", "#2a2350", 147, 60], done: ["#8fd3fb", "#1f3358", 117, 24], failed: ["#ff7a85", "#3d1d26", 210, 52] },
47
+ light: { running: ["#5b3fc4", "#ece6ff", 61, 189], done: ["#1585c9", "#dbe7fb", 25, 153], failed: ["#d43c4c", "#fde8ea", 160, 224] },
48
+ };
49
+ function label(name, status, theme) {
50
+ const [fg, bg, fg256, bg256] = LABELS[theme.appearance === "light" ? "light" : "dark"][status];
51
+ const mode = theme.getColorMode();
52
+ const colors = mode === "truecolor" ? { fg: parseColor(fg), bg: parseColor(bg) } : { fg: indexedColor(fg256), bg: indexedColor(bg256) };
53
+ return styleText(` ${name} `, { ...colors, bold: true }, mode);
54
+ }
39
55
  function compactCall(toolName, args, theme, context) {
40
56
  const state = context.state;
41
57
  state.kluiHead ??= new Lines();
42
- // The dot stays dim until the result colors it.
58
+ // Lavender until the result colors it.
43
59
  if (!state.kluiBody)
44
- state.kluiHead.set([`${theme.fg("dim", "●")} ${title(toolName, args, theme, context.cwd)}`], context.outputPad);
60
+ state.kluiHead.set([title(toolName, args, "running", theme, context.cwd)], context.outputPad);
45
61
  return state.kluiHead;
46
62
  }
47
63
  function compactResult(toolName, result, theme, context) {
48
64
  const state = context.state;
49
65
  state.kluiBody ??= new Lines();
50
- const head = title(toolName, context.args, theme, context.cwd);
51
66
  if (context.isPartial) {
52
67
  // Long-running tools (subagents) say what they're up to under the call.
53
68
  const d = result.details;
54
- state.kluiHead?.set([`${theme.fg("dim", "●")} ${head}`], context.outputPad);
69
+ state.kluiHead?.set([title(toolName, context.args, "running", theme, context.cwd)], context.outputPad);
55
70
  const live = toolName === "subagent" && d?.startedAt !== undefined ? agentLines(d, theme) : d?.progress ? [theme.fg("dim", d.progress)] : [];
56
71
  state.kluiBody.set(under(theme, live), context.outputPad);
57
72
  return state.kluiBody;
58
73
  }
59
- const dot = context.isError ? theme.fg("error", "●") : theme.fg("success", "●");
60
- state.kluiHead?.set([`${dot} ${head}`], context.outputPad);
74
+ state.kluiHead?.set([title(toolName, context.args, context.isError ? "failed" : "done", theme, context.cwd)], context.outputPad);
61
75
  const lines = context.isError ? errorLines(result, theme) : outcome(toolName, context.args, result, theme, context.cwd);
62
76
  const time = context.durationMs !== undefined && context.durationMs >= 1000 ? theme.fg("dim", ` · ${(context.durationMs / 1000).toFixed(1)}s`) : "";
63
77
  if (lines[0] !== undefined)
@@ -65,9 +79,9 @@ function compactResult(toolName, result, theme, context) {
65
79
  state.kluiBody.set(under(theme, lines), context.outputPad);
66
80
  return state.kluiBody;
67
81
  }
68
- /** Hang lines under the call: the first after "⎿", the rest lined up with it. */
82
+ /** Hang lines under the call: the first after "⎿", under the label's first letter, the rest lined up with it. */
69
83
  function under(theme, lines) {
70
- return lines.map((line, i) => `${i === 0 ? ` ${theme.fg("dim", "⎿")} ` : " "}${line}`);
84
+ return lines.map((line, i) => `${i === 0 ? ` ${theme.fg("dim", "⎿")} ` : " "}${line}`);
71
85
  }
72
86
  const NAMES = {
73
87
  read: "Read",
@@ -84,10 +98,10 @@ const NAMES = {
84
98
  screenshot: "Screenshot",
85
99
  todo: "Todos",
86
100
  };
87
- function title(toolName, args, theme, cwd) {
101
+ function title(toolName, args, status, theme, cwd) {
88
102
  const a = (args ?? {});
89
- const name = theme.bold(NAMES[toolName] ?? toolName);
90
- const arg = (text) => (text ? `${theme.fg("muted", "(")}${text}${theme.fg("muted", ")")}` : "");
103
+ const name = label(NAMES[toolName] ?? toolName, status, theme);
104
+ const arg = (text) => (text ? ` ${text}` : "");
91
105
  const path = (value) => shortPath(typeof value === "string" ? value : ".", cwd);
92
106
  switch (toolName) {
93
107
  case "read":
@@ -180,11 +180,12 @@ function rebrand(text) {
180
180
  /**
181
181
  * Klui's slash menu: /resume and /exit (see slashAliases) open /sessions and quit. Pi's /session,
182
182
  * its bug reporter (it files issues with the Pi developers), its changelog and /scoped-models stay
183
- * out of the list; they still work when typed. Provider login/logout are removed as well.
183
+ * out of the list; they still work when typed. Provider login/logout and /settings (its themes and
184
+ * options aren't Klui's to change) are removed as well.
184
185
  */
185
186
  async function trimSlashMenu() {
186
187
  const { BUILTIN_SLASH_COMMANDS: commands } = await piModule("./core/slash-commands.js");
187
- const hidden = new Set(["session", "bug", "changelog", "scoped-models", "login", "logout"]);
188
+ const hidden = new Set(["session", "bug", "changelog", "scoped-models", "login", "logout", "settings"]);
188
189
  for (let i = commands.length - 1; i >= 0; i--)
189
190
  if (hidden.has(commands[i].name))
190
191
  commands.splice(i, 1);
@@ -201,7 +202,7 @@ export function showThinkingMenu() {
201
202
  if (interactive?.session.supportsThinking())
202
203
  interactive.showThinkingSelector();
203
204
  }
204
- /** Session aliases and event-pass guidance in place of provider login/logout. */
205
+ /** Session aliases, and a word in place of provider login/logout and /settings. */
205
206
  async function slashAliases() {
206
207
  const { InteractiveMode } = await piModule("./modes/interactive/interactive-mode.js");
207
208
  const proto = InteractiveMode.prototype;
@@ -220,6 +221,10 @@ async function slashAliases() {
220
221
  this.showError("Klui connects with your event pass automatically. Use /klui retry to reconnect.");
221
222
  return;
222
223
  }
224
+ if (/^\/settings(\s|$)/.test(text.trim())) {
225
+ this.showError("Klui has no settings menu. Use /model to switch models and /thinking for reasoning.");
226
+ return;
227
+ }
223
228
  await submit(aliases[text.trim()] ?? text);
224
229
  };
225
230
  };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "klui-code",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "klui-code",
9
- "version": "0.1.5",
9
+ "version": "0.1.6",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@earendil-works/chord": "1.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "klui-code",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Klui Code: a pixel-cute coding agent for your terminal, built on Pi and running on AntSeed.",
5
5
  "keywords": [
6
6
  "klui",
@@ -1,81 +0,0 @@
1
- {
2
- "$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
3
- "name": "klui-arcade",
4
- "appearance": "dark",
5
- "vars": {
6
- "text": "#f2ecff",
7
- "muted": "#b0a3d4",
8
- "dim": "#7d6fa6",
9
- "line": "#43356b",
10
- "sky": "#5fe3ff",
11
- "blue": "#8f7bff",
12
- "soft": "#c3b6ff",
13
- "pink": "#ff5fd2",
14
- "mint": "#a6ff4d",
15
- "coral": "#ff5f6d",
16
- "sun": "#ffe14d"
17
- },
18
- "colors": {
19
- "accent": "sky",
20
- "border": "blue",
21
- "borderAccent": "sky",
22
- "borderMuted": "line",
23
- "success": "mint",
24
- "error": "coral",
25
- "warning": "sun",
26
- "muted": "muted",
27
- "dim": "dim",
28
- "text": "text",
29
- "thinkingText": "muted",
30
- "selectedBg": "#35206b",
31
- "scrollbarTrack": "line",
32
- "scrollbarThumb": "muted",
33
- "searchMatchBg": "#5a4a00",
34
- "searchMatchText": "text",
35
- "userMessageBg": "#24164a",
36
- "userMessageText": "text",
37
- "customMessageBg": "#2e1240",
38
- "customMessageText": "muted",
39
- "customMessageLabel": "pink",
40
- "toolPendingBg": "#1c1433",
41
- "toolSuccessBg": "#18301a",
42
- "toolErrorBg": "#3a1424",
43
- "toolTitle": "text",
44
- "toolOutput": "muted",
45
- "mdHeading": "sky",
46
- "mdLink": "blue",
47
- "mdLinkUrl": "dim",
48
- "mdCode": "pink",
49
- "mdCodeBlock": "text",
50
- "mdCodeBlockBorder": "line",
51
- "mdQuote": "muted",
52
- "mdQuoteBorder": "blue",
53
- "mdHr": "line",
54
- "mdListBullet": "sky",
55
- "toolDiffAdded": "mint",
56
- "toolDiffRemoved": "coral",
57
- "toolDiffContext": "dim",
58
- "syntaxComment": "dim",
59
- "syntaxKeyword": "blue",
60
- "syntaxFunction": "sky",
61
- "syntaxVariable": "text",
62
- "syntaxString": "mint",
63
- "syntaxNumber": "sun",
64
- "syntaxType": "pink",
65
- "syntaxOperator": "muted",
66
- "syntaxPunctuation": "muted",
67
- "thinkingOff": "line",
68
- "thinkingMinimal": "dim",
69
- "thinkingLow": "soft",
70
- "thinkingMedium": "sky",
71
- "thinkingHigh": "blue",
72
- "thinkingXhigh": "pink",
73
- "thinkingMax": "coral",
74
- "bashMode": "mint"
75
- },
76
- "export": {
77
- "pageBg": "#120b24",
78
- "cardBg": "#1a1132",
79
- "infoBg": "#24164a"
80
- }
81
- }