@hanzo/build 0.2.129 → 0.2.131

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.
@@ -56,3 +56,25 @@ export declare function remove(t: Target, id: string): Promise<void>;
56
56
  export declare function brand(t: Target): Promise<Catalogue>;
57
57
  /** One catalogue skill's SKILL.md. */
58
58
  export declare function document(t: Target, name: string): Promise<string>;
59
+ /** One thing Kai picked for a message: a skill (`skill_<name>`) or a tool, how likely it applies, and what it does. */
60
+ export interface Detected {
61
+ /** The skill's own name for a skill (`code-review`), else the tool's. */
62
+ name: string;
63
+ skill: boolean;
64
+ /** Where it comes from: skill, mcp, connector, function, agent. */
65
+ source: string;
66
+ description: string;
67
+ /** 0 to 1. */
68
+ probability: number;
69
+ }
70
+ /**
71
+ * Which skills and tools apply to `prompt`, as Kai decides it (cloud apps/tools
72
+ * detect.go; a lexical fallback answers when Kai does not). Only asks: nothing
73
+ * is switched on (`autoActivate` is left out), so a message carries what was
74
+ * picked for it and nothing more.
75
+ */
76
+ export declare function detect(t: Target, prompt: string, opts?: {
77
+ maxSkills?: number;
78
+ maxTools?: number;
79
+ signal?: AbortSignal;
80
+ }): Promise<Detected[]>;
package/lib/api/skills.js CHANGED
@@ -7,6 +7,7 @@
7
7
  * DELETE /v1/tool/skills/{id} {deleted}
8
8
  * GET /.well-known/agent-skills/index.json the brand's catalogue, public
9
9
  * GET /.well-known/agent-skills/{name}/SKILL.md one of its documents, public
10
+ * POST /v1/tool/detect {prompt, maxSkills, maxTools} → {skills, tools} Kai's pick for one message
10
11
  *
11
12
  * A skill is on when its tool name, `skill_<name>`, is activated (tools.ts):
12
13
  * that is how a catalogue skill is added to an org and how an org's own skill is
@@ -97,3 +98,20 @@ export async function brand(t) {
97
98
  export async function document(t, name) {
98
99
  return (await open(t, `${seg(name)}/SKILL.md`)).text();
99
100
  }
101
+ /**
102
+ * Which skills and tools apply to `prompt`, as Kai decides it (cloud apps/tools
103
+ * detect.go; a lexical fallback answers when Kai does not). Only asks: nothing
104
+ * is switched on (`autoActivate` is left out), so a message carries what was
105
+ * picked for it and nothing more.
106
+ */
107
+ export async function detect(t, prompt, opts = {}) {
108
+ const raw = await call(t, 'POST', '/v1/tool/detect', { prompt, maxSkills: opts.maxSkills ?? 3, maxTools: opts.maxTools ?? 3 }, { signal: opts.signal });
109
+ const r = (raw && typeof raw === 'object' ? raw : {});
110
+ const read = (list, skill) => (Array.isArray(list) ? list : []).flatMap((x) => {
111
+ const o = (x && typeof x === 'object' ? x : {});
112
+ const tool = str(o.name);
113
+ const name = skill ? nameOf(tool) || tool : tool;
114
+ return name ? [{ name, skill, source: str(o.source), description: str(o.description), probability: num(o.probability) }] : [];
115
+ });
116
+ return [...read(r.skills, true), ...read(r.tools, false)];
117
+ }
package/lib/api/turn.d.ts CHANGED
@@ -141,10 +141,13 @@ export type Card = {
141
141
  text: string;
142
142
  done: boolean;
143
143
  }[];
144
- } | {
144
+ }
145
+ /** `step`: a line about the run getting going (started, sent to a machine), the process rather than its end. */
146
+ | {
145
147
  kind: 'note';
146
148
  key: string;
147
149
  text: string;
150
+ step?: true;
148
151
  } | {
149
152
  kind: 'plan';
150
153
  key: string;
package/lib/api/turn.js CHANGED
@@ -518,8 +518,9 @@ export function cards(events, mode = '', t = english) {
518
518
  break;
519
519
  }
520
520
  const line = status(b, mode, t);
521
+ const going = str(b.status) === 'started' || str(b.status) === 'routed';
521
522
  if (line)
522
- out.push({ kind: 'note', key: mint(), text: line });
523
+ out.push(going ? { kind: 'note', key: mint(), text: line, step: true } : { kind: 'note', key: mint(), text: line });
523
524
  break;
524
525
  }
525
526
  case 'control': {
package/lib/carry.d.ts CHANGED
@@ -27,6 +27,13 @@ export interface Carry {
27
27
  /** The words the gear adds to every message, '' when none. */
28
28
  text: string;
29
29
  }
30
+ /**
31
+ * The words skills add to a message: each one's SKILL.md (the org's own before
32
+ * the brand's), at most `max` of each, or its name when no document answers.
33
+ * Chat carries the ones Hanzo chose for a single message the same way
34
+ * (hanzo-inc/app issue 314).
35
+ */
36
+ export declare function skillsSaid(t: Target, skills: readonly string[], max?: number): Promise<string>;
30
37
  /** What Manual asks about: a plugin, or a Dev run. `id` is what "always" remembers. */
31
38
  export interface Asked {
32
39
  id: string;
package/lib/carry.js CHANGED
@@ -39,6 +39,23 @@ async function remembered(t) {
39
39
  .map((r) => (r && typeof r === 'object' ? String(r.content ?? '') : ''))
40
40
  .filter(Boolean);
41
41
  }
42
+ /**
43
+ * The words skills add to a message: each one's SKILL.md (the org's own before
44
+ * the brand's), at most `max` of each, or its name when no document answers.
45
+ * Chat carries the ones Hanzo chose for a single message the same way
46
+ * (hanzo-inc/app issue 314).
47
+ */
48
+ export async function skillsSaid(t, skills, max = SKILL_MAX) {
49
+ if (!skills.length)
50
+ return '';
51
+ const own = t.token() ? await authored(t).catch(() => []) : [];
52
+ const parts = [];
53
+ for (const n of skills) {
54
+ const body = own.find((s) => s.name === n)?.content || (await document(t, n).catch(() => ''));
55
+ parts.push(body ? `Use the skill "${n}" where it applies:\n\n${body.slice(0, max)}` : `Use the "${n}" skill where it applies.`);
56
+ }
57
+ return parts.join('\n\n');
58
+ }
42
59
  /** The words `skills`, `memory` and `mode` add to a message. */
43
60
  async function said(t, skills, memory, mode, design) {
44
61
  const parts = [];
@@ -47,16 +64,9 @@ async function said(t, skills, memory, mode, design) {
47
64
  if (b?.name)
48
65
  parts.push(designSaid(b));
49
66
  }
50
- if (skills.length) {
51
- const own = t.token() ? await authored(t).catch(() => []) : [];
52
- for (const n of skills) {
53
- const body = own.find((s) => s.name === n)?.content || (await document(t, n).catch(() => ''));
54
- if (body)
55
- parts.push(`Use the skill "${n}" where it applies:\n\n${body.slice(0, SKILL_MAX)}`);
56
- else
57
- parts.push(`Use the "${n}" skill where it applies.`);
58
- }
59
- }
67
+ const taught = await skillsSaid(t, skills);
68
+ if (taught)
69
+ parts.push(taught);
60
70
  if (memory) {
61
71
  const lines = await remembered(t).catch(() => []);
62
72
  if (lines.length)
package/lib/dev-mode.d.ts CHANGED
@@ -1,6 +1,23 @@
1
1
  import type { Say } from '@hanzo/i18n/react';
2
2
  export declare const DEV_MODE_KEY = "hanzo.dev_mode";
3
3
  export declare const DEV_MODE_EVENT = "hanzo:dev-mode";
4
+ /** What Developer mode does, in one line, wherever its switch is drawn (English, marked; drawn through `t`). */
5
+ export declare const DEV_MODE_NOTE: string;
6
+ /**
7
+ * DEVELOPER MODE IS OFF FOR A NEW PERSON, and the result is what they see
8
+ * (hanzo-inc/app issues 317 and 321). Someone who has worked with the process
9
+ * on this device keeps seeing it: the first time the choice is read where it
10
+ * was never made, it is made once from what this device shows of them, and kept.
11
+ *
12
+ * - Tabs listed a machine or a cloud workspace of theirs (`hanzo.tabs.fleet`):
13
+ * they opened a terminal, or linked a computer with the CLI.
14
+ * - Dev's transcript view is Thinking or Verbose: they asked to see more of it.
15
+ *
16
+ * Anyone else, including someone who has only built with Dev, starts with the
17
+ * result. The switch (Settings › General, the account menu, a run's menu, ⌘⇧D)
18
+ * changes it either way.
19
+ */
20
+ export declare function adopt(store: Pick<Storage, 'getItem'>): boolean;
4
21
  export declare function getDevMode(): boolean;
5
22
  export declare function setDevMode(next: boolean): void;
6
23
  export declare function useDevMode(): [boolean, (next: boolean) => void];
package/lib/dev-mode.js CHANGED
@@ -1,13 +1,47 @@
1
+ import { phrase } from '@hanzo/i18n';
1
2
  import { useCallback, useSyncExternalStore } from 'react';
2
3
  import { friendly } from './names.js';
3
4
  import { english } from './say.js';
4
5
  export const DEV_MODE_KEY = 'hanzo.dev_mode';
5
6
  export const DEV_MODE_EVENT = 'hanzo:dev-mode';
7
+ /** What Developer mode does, in one line, wherever its switch is drawn (English, marked; drawn through `t`). */
8
+ export const DEV_MODE_NOTE = phrase('Shows the process: the terminal, the commands Hanzo runs and each step. Off, Hanzo shows the result.');
9
+ /**
10
+ * DEVELOPER MODE IS OFF FOR A NEW PERSON, and the result is what they see
11
+ * (hanzo-inc/app issues 317 and 321). Someone who has worked with the process
12
+ * on this device keeps seeing it: the first time the choice is read where it
13
+ * was never made, it is made once from what this device shows of them, and kept.
14
+ *
15
+ * - Tabs listed a machine or a cloud workspace of theirs (`hanzo.tabs.fleet`):
16
+ * they opened a terminal, or linked a computer with the CLI.
17
+ * - Dev's transcript view is Thinking or Verbose: they asked to see more of it.
18
+ *
19
+ * Anyone else, including someone who has only built with Dev, starts with the
20
+ * result. The switch (Settings › General, the account menu, a run's menu, ⌘⇧D)
21
+ * changes it either way.
22
+ */
23
+ export function adopt(store) {
24
+ try {
25
+ const view = store.getItem('hanzo.build.transcript.view');
26
+ if (view === '"thinking"' || view === '"verbose"')
27
+ return true;
28
+ const fleet = JSON.parse(store.getItem('hanzo.tabs.fleet') || '[]');
29
+ return Array.isArray(fleet) && fleet.length > 0;
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
6
35
  export function getDevMode() {
7
36
  if (typeof window === 'undefined')
8
37
  return false;
9
38
  try {
10
- return window.localStorage.getItem(DEV_MODE_KEY) === 'true';
39
+ const kept = window.localStorage.getItem(DEV_MODE_KEY);
40
+ if (kept !== null)
41
+ return kept === 'true';
42
+ const chosen = adopt(window.localStorage);
43
+ window.localStorage.setItem(DEV_MODE_KEY, chosen ? 'true' : 'false');
44
+ return chosen;
11
45
  }
12
46
  catch {
13
47
  return false;
package/lib/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export type { Target } from './api/call.ts';
44
44
  export type { Browse, Browser, Host, Person, Shown } from './host.tsx';
45
45
  export type { Session, Status } from './api/sessions.ts';
46
46
  export { talks } from './api/talk.ts';
47
+ export { detect, type Detected } from './api/skills.ts';
47
48
  export type { Read } from './data.ts';
48
49
  export { href, parse, path, PLACES, route, SESSION, SLUG, type Route, type Screen } from './route.ts';
49
50
  /**
@@ -56,13 +57,14 @@ export { catalog, EFFORTS, FIRST, grants, isFree, keep, kept, level, nameOf, pac
56
57
  export { DEV_HANDOFF, takeHandoff } from './handoff.ts';
57
58
  export { useEar } from './voice.ts';
58
59
  export { BARE, CHAT_MODES, DEV_MODES, gearOf, MODES, useGear, useLanguage, type Gear, type GearState, type Mode as GearMode } from './gear.ts';
59
- export { useCarry, type Carry } from './carry.tsx';
60
+ export { skillsSaid, useCarry, type Carry } from './carry.tsx';
60
61
  export { artifacts, blob, lead, renders, Reply, Served, speakable, speaker, type Artifact, type Listen } from './reply.tsx';
61
62
  export { frames, Page, Panel, PanelToggle, type Kind, type PageProps, type PanelProps, type Suggestion } from './panel.tsx';
62
63
  export { SideProvider, useSplit, type Split } from './side.tsx';
63
64
  export { PrefsProvider } from './prefs.tsx';
64
65
  export { deviceKey, friendly, heldNames, NAMES_KEY, rename, shellKey, useDeviceNames, type Names } from './names.ts';
65
- export { formatDeviceLabel, type DeviceLabelOptions } from './dev-mode.ts';
66
+ export { DEV_MODE_NOTE, formatDeviceLabel, type DeviceLabelOptions } from './dev-mode.ts';
67
+ export { plainPath } from './plain.ts';
66
68
  export { Rename } from './ask.tsx';
67
69
  export { kinds, Summary, useKinds, type Entry, type Section } from './summary.tsx';
68
70
  /**
package/lib/index.js CHANGED
@@ -40,6 +40,7 @@ export { Credits, SEPARATE } from './settings/credits.js';
40
40
  export { useStanding, rows, left } from './standing.js';
41
41
  export { kind, label, said, share, spent, ways, when } from './plan.js';
42
42
  export { talks } from './api/talk.js';
43
+ export { detect } from './api/skills.js';
43
44
  export { href, parse, path, PLACES, route, SESSION, SLUG } from './route.js';
44
45
  /**
45
46
  * What Chat draws the same way (@hanzo/rooms imports these): the model and
@@ -51,13 +52,14 @@ export { catalog, EFFORTS, FIRST, grants, isFree, keep, kept, level, nameOf, pac
51
52
  export { DEV_HANDOFF, takeHandoff } from './handoff.js';
52
53
  export { useEar } from './voice.js';
53
54
  export { BARE, CHAT_MODES, DEV_MODES, gearOf, MODES, useGear, useLanguage } from './gear.js';
54
- export { useCarry } from './carry.js';
55
+ export { skillsSaid, useCarry } from './carry.js';
55
56
  export { artifacts, blob, lead, renders, Reply, Served, speakable, speaker } from './reply.js';
56
57
  export { frames, Page, Panel, PanelToggle } from './panel.js';
57
58
  export { SideProvider, useSplit } from './side.js';
58
59
  export { PrefsProvider } from './prefs.js';
59
60
  export { deviceKey, friendly, heldNames, NAMES_KEY, rename, shellKey, useDeviceNames } from './names.js';
60
- export { formatDeviceLabel } from './dev-mode.js';
61
+ export { DEV_MODE_NOTE, formatDeviceLabel } from './dev-mode.js';
62
+ export { plainPath } from './plain.js';
61
63
  export { Rename } from './ask.js';
62
64
  export { kinds, Summary, useKinds } from './summary.js';
63
65
  /**
package/lib/plain.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * THE RESULT FIRST (hanzo-inc/app issues 317 and 321).
3
+ *
4
+ * With Developer mode off, a run reads as what was asked, what the agent said
5
+ * and how it ended. Everything it did on the way there — the commands it ran,
6
+ * the files it read and changed, the sandbox it leased, its reasoning — folds
7
+ * into one line between the turns, saying in plain words what the work was
8
+ * ("Set up the workspace, read 4 files, changed index.html"). That line opens
9
+ * onto the very cards Developer mode draws, so the process stays one press away
10
+ * and nobody has to read a shell line to know what happened.
11
+ *
12
+ * A path a person might still read there is said in words: `~` is "your home
13
+ * folder", `/work` is "your project".
14
+ */
15
+ import type { Say } from '@hanzo/i18n/react';
16
+ import type { Card, Ran } from './api/turn.ts';
17
+ /** A run of process cards between two things a person reads. */
18
+ export interface Work {
19
+ kind: 'work';
20
+ /** The first card's key: a run of work keeps its key, and its open state, as it grows. */
21
+ key: string;
22
+ cards: Card[];
23
+ }
24
+ /**
25
+ * Whether a card is the process — how the agent got there — rather than what a
26
+ * person reads: what was asked, what the agent said, its plan, its question, a
27
+ * coding run it started, how the run ended, and the reason it failed.
28
+ */
29
+ export declare function isProcess(c: Card): boolean;
30
+ /** The transcript with each run of process cards gathered into one `Work`. */
31
+ export declare function fold(cards: readonly Card[]): (Card | Work)[];
32
+ /** How a run of work went: still going while any of it is, otherwise done. */
33
+ export declare function ranOf(cards: readonly Card[], state?: (r: Ran) => Ran): Ran;
34
+ /**
35
+ * A line with the paths in it said in words: `~` is "your home folder",
36
+ * `~/notes/todo.md` is "notes/todo.md in your home folder", `/work` is "your
37
+ * project" and `/work/src/app.ts` is "src/app.ts". Anything else is left as written.
38
+ */
39
+ export declare function plainPath(text: string, say?: Say): string;
40
+ /** What one card was doing, in plain words, for the line while the work goes on. */
41
+ export declare function doing(c: Card, say?: Say): string;
42
+ /**
43
+ * What a run of work did, said in one line: "Set up the workspace, read 4
44
+ * files, changed index.html". Counts, never commands or paths.
45
+ */
46
+ export declare function worked(cards: readonly Card[], say?: Say): string;
package/lib/plain.js ADDED
@@ -0,0 +1,180 @@
1
+ import { english } from './say.js';
2
+ /** The run's own steps that set it up, by the names turn.ts gives them. */
3
+ const SETUP = new Set(['Sandbox', 'Workspace', 'Clone', 'Branch', 'Secrets', 'Install', 'Start', 'Skills']);
4
+ /** The sandbox kept for its screen and previews once the run is done: housekeeping, said nowhere. */
5
+ const KEPT = 'Keep the sandbox';
6
+ /**
7
+ * Whether a card is the process — how the agent got there — rather than what a
8
+ * person reads: what was asked, what the agent said, its plan, its question, a
9
+ * coding run it started, how the run ended, and the reason it failed.
10
+ */
11
+ export function isProcess(c) {
12
+ switch (c.kind) {
13
+ case 'think':
14
+ case 'shell':
15
+ case 'explore':
16
+ case 'edit':
17
+ return true;
18
+ case 'step':
19
+ return c.name !== 'Error';
20
+ case 'note':
21
+ return c.step === true;
22
+ }
23
+ return false;
24
+ }
25
+ /** The transcript with each run of process cards gathered into one `Work`. */
26
+ export function fold(cards) {
27
+ const out = [];
28
+ for (const c of cards) {
29
+ if (!isProcess(c)) {
30
+ out.push(c);
31
+ continue;
32
+ }
33
+ const last = out[out.length - 1];
34
+ if (last?.kind === 'work')
35
+ last.cards.push(c);
36
+ else
37
+ out.push({ kind: 'work', key: `work:${c.key}`, cards: [c] });
38
+ }
39
+ return out;
40
+ }
41
+ /** How a run of work went: still going while any of it is, otherwise done. */
42
+ export function ranOf(cards, state = (r) => r) {
43
+ const ran = cards.map((c) => ('ran' in c ? state(c.ran) : 'done'));
44
+ if (ran.includes('running'))
45
+ return 'running';
46
+ if (ran.includes('cancelled'))
47
+ return 'cancelled';
48
+ return 'done';
49
+ }
50
+ // Paths as a shell writes them, at a word's start: the home folder (`~`, `$HOME`,
51
+ // `/home/<user>`, `/Users/<user>`, `/root`) and the sandbox's working directory (`/work`).
52
+ const HOME = /(^|[\s'"`(=:,])(?:~|\$HOME|\/home\/[\w.-]+|\/Users\/[\w.-]+|\/root)(\/[^\s'"`),;]*)?(?=$|[\s'"`),;:.])/g;
53
+ const WORK = /(^|[\s'"`(=:,])\/work(\/[^\s'"`),;]*)?(?=$|[\s'"`),;:.])/g;
54
+ /**
55
+ * A line with the paths in it said in words: `~` is "your home folder",
56
+ * `~/notes/todo.md` is "notes/todo.md in your home folder", `/work` is "your
57
+ * project" and `/work/src/app.ts` is "src/app.ts". Anything else is left as written.
58
+ */
59
+ export function plainPath(text, say = english) {
60
+ const rest = (tail) => (tail ?? '').replace(/^\/+/, '').replace(/\/+$/, '');
61
+ return text
62
+ .replace(HOME, (_, lead, tail) => {
63
+ const inside = rest(tail);
64
+ return lead + (inside ? say('{path} in your home folder', { path: inside }) : say('your home folder'));
65
+ })
66
+ .replace(WORK, (_, lead, tail) => {
67
+ const inside = rest(tail);
68
+ return lead + (inside || say('your project'));
69
+ });
70
+ }
71
+ /** A file's name as a person reads it: the last part of its path, said in words. */
72
+ const fileName = (path, say) => {
73
+ const plain = plainPath(path, say);
74
+ return plain === path ? path.split('/').filter(Boolean).pop() || path : plain;
75
+ };
76
+ /** What one card was doing, in plain words, for the line while the work goes on. */
77
+ export function doing(c, say = english) {
78
+ switch (c.kind) {
79
+ case 'think':
80
+ return say('Thinking it through');
81
+ case 'shell':
82
+ return say('Running a command');
83
+ case 'explore':
84
+ return say('Looking through the files');
85
+ case 'edit':
86
+ return c.files.length === 1 ? say('Changing {file}', { file: fileName(c.files[0].path, say) }) : say('Changing files');
87
+ case 'note':
88
+ return say('Starting');
89
+ case 'step':
90
+ if (SETUP.has(c.name))
91
+ return say('Setting up the workspace');
92
+ if (c.name === 'Search')
93
+ return say('Searching the web');
94
+ if (c.name === 'Called' || c.name === 'Calling')
95
+ return say('Using a tool');
96
+ if (c.name === 'Push' || c.name === 'Save artifacts')
97
+ return say('Saving the work');
98
+ if (c.name === KEPT)
99
+ return say('Keeping the workspace');
100
+ return say('Checking the work');
101
+ }
102
+ return say('Working');
103
+ }
104
+ /**
105
+ * What a run of work did, said in one line: "Set up the workspace, read 4
106
+ * files, changed index.html". Counts, never commands or paths.
107
+ */
108
+ export function worked(cards, say = english) {
109
+ let setup = false;
110
+ let thought = false;
111
+ let commands = 0;
112
+ const read = new Set();
113
+ let looked = false;
114
+ const changed = new Set();
115
+ let searched = false;
116
+ let tools = 0;
117
+ let saved = false;
118
+ let checked = false;
119
+ for (const c of cards) {
120
+ switch (c.kind) {
121
+ case 'think':
122
+ thought = true;
123
+ break;
124
+ case 'shell':
125
+ commands++;
126
+ break;
127
+ case 'explore':
128
+ for (const call of c.calls)
129
+ for (const a of call.actions) {
130
+ if (a.type === 'read')
131
+ read.add(a.name);
132
+ else
133
+ looked = true;
134
+ }
135
+ break;
136
+ case 'edit':
137
+ for (const f of c.files)
138
+ changed.add(f.path);
139
+ break;
140
+ case 'note':
141
+ setup = true;
142
+ break;
143
+ case 'step':
144
+ if (SETUP.has(c.name))
145
+ setup = true;
146
+ else if (c.name === 'Search')
147
+ searched = true;
148
+ else if (c.name === 'Called' || c.name === 'Calling')
149
+ tools++;
150
+ else if (c.name === 'Push' || c.name === 'Save artifacts')
151
+ saved = true;
152
+ else if (c.name !== KEPT)
153
+ checked = true;
154
+ break;
155
+ }
156
+ }
157
+ const parts = [];
158
+ if (setup)
159
+ parts.push(say('Set up the workspace'));
160
+ if (thought && !commands && !read.size && !changed.size)
161
+ parts.push(say('thought it through'));
162
+ if (read.size)
163
+ parts.push(read.size === 1 ? say('read a file') : say('read {n} files', { n: read.size }));
164
+ else if (looked)
165
+ parts.push(say('looked through the files'));
166
+ if (commands)
167
+ parts.push(commands === 1 ? say('ran a command') : say('ran {n} commands', { n: commands }));
168
+ if (searched)
169
+ parts.push(say('searched the web'));
170
+ if (tools)
171
+ parts.push(tools === 1 ? say('used a tool') : say('used {n} tools', { n: tools }));
172
+ if (changed.size)
173
+ parts.push(changed.size === 1 ? say('changed {file}', { file: fileName([...changed][0], say) }) : say('changed {n} files', { n: changed.size }));
174
+ if (saved)
175
+ parts.push(say('saved the work'));
176
+ if (checked && !parts.length)
177
+ parts.push(say('checked the work'));
178
+ const line = parts.join(', ');
179
+ return line ? line.charAt(0).toUpperCase() + line.slice(1) : '';
180
+ }
package/lib/project.js CHANGED
@@ -9,7 +9,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
9
9
  * opened by its slug (Artifacts), and works the same way.
10
10
  *
11
11
  * bar mark · project · history · chat toggle | Preview Files Code Layers |
12
- * Share · Publish
12
+ * Share · Publish; on a phone the views (with Chat) are a row under it
13
13
  * left the project's runs as a conversation, suggestions, and the ask
14
14
  * right the deployed page, framed under its own bar (reload · page · device
15
15
  * · open), and kept loaded while another view is open; the repository
@@ -456,12 +456,19 @@ export function Project({ at }) {
456
456
  }, empty: _jsx(SizableText, { size: "$2", color: "$soft", p: "$4", children: t('Open a file from Files. Code here is read at {ref}; ask in the chat to change it.', { ref }) }) })) : (_jsx(YStack, { p: "$4", gap: "$2", children: picked.length ? (picked.map((p) => (_jsxs(XStack, { items: "center", gap: "$2.5", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(MousePointerClick, { size: 14, color: "$soft" }), _jsxs(SizableText, { size: "$2", color: "$ink", fontFamily: "$mono", flex: 1, minW: 0, children: [p.label, " \u2014 ", p.id] })] }, p.id)))) : (_jsx(YStack, { p: "$5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", items: "center", gap: "$2", children: _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: bridge
457
457
  ? t('Pick an element in the preview to see it here and attach it to your next ask.')
458
458
  : t('Layers are read through the preview bridge, and this page does not run it. Its elements cannot be listed from here.') }) })) }));
459
- return (_jsxs(_Fragment, { children: [_jsxs(Workspace, { start: _jsxs(XStack, { items: "center", gap: "$2", minW: 0, shrink: 1, children: [_jsx(XStack, { render: "button", "aria-label": t('All runs'), onPress: () => host.go(''), p: "$1", shrink: 0, children: _jsx(HanzoMark, { size: 20 }) }), _jsx(ProjectChip, { name: title, onPress: () => setSwitcher(true) }), _jsx(XStack, { render: "button", "aria-label": t('History'), onPress: () => setHistory(true), p: "$1.5", rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, children: _jsx(Clock, { size: 16 }) }), _jsx(XStack, { render: "button", "aria-label": shut ? t('Show the chat') : t('Hide the chat'), "aria-pressed": !shut, onClick: () => (cramped ? setAsked(!asked) : setCollapsed(!collapsed)), minW: 32, minH: 32, items: "center", justify: "center", rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$max-md": { display: 'none' }, children: _jsx(PanelLeft, { size: 16 }) })] }), middle: _jsx(Views, { views: [CHAT, ...VIEWS], value: pane === 'chat' && !wide ? 'chat' : view, onChange: (v) => {
460
- if (v === 'chat')
461
- return setPane('chat');
462
- setView(v);
463
- setPane('view');
464
- }, label: t('View') }), end: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(XStack, { display: "none", $md: { display: 'flex' }, children: _jsxs(Button, { variant: "outline", size: "sm", onPress: () => void share(), children: [_jsx(Share2, { size: 14 }), " ", t('Share')] }) }), _jsxs(Button, { size: "sm", variant: "primary", "aria-label": t('Publish'), disabled: !clone || !slug, onPress: () => setPublish({ repo: clone, title, ref, name: slug, project: slug }), children: [_jsx(Upload, { size: 14 }), _jsx(SizableText, { size: "$2", color: "inherit", "$max-md": { display: 'none' }, children: t('Publish') })] })] }), chat: chat, dock: _jsx(Console, { lines: lines, height: dock, onHeight: setDock, onClear: () => setPageLines([]), status: run.status || end.status || undefined, label: t('Console') }), collapsed: shut, pane: pane, width: across, onLayout: (e) => setRoom(e.nativeEvent.layout.width), children: [preview, body] }), _jsx(Dialog, { open: history, onOpenChange: setHistory, children: _jsxs(DialogContent, { maxW: 480, children: [_jsx(DialogTitle, { children: t('Runs on {title}', { title }) }), _jsx(YStack, { gap: "$1", children: runs.value.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('No runs yet.') })) : (runs.value.map((r) => {
459
+ const views = (_jsx(Views, { views: [CHAT, ...VIEWS], value: pane === 'chat' && !wide ? 'chat' : view, onChange: (v) => {
460
+ if (v === 'chat')
461
+ return setPane('chat');
462
+ setView(v);
463
+ setPane('view');
464
+ }, label: t('View') }));
465
+ // On a phone the bar has no room for the views beside the project: there
466
+ // they were a scroller of the bar's leftovers, 49px at 375 beside a project
467
+ // named "Instrument", showing part of Chat and none of Code (hanzo-inc/app#305).
468
+ // So below md they take a row of their own under the bar, in whichever pane
469
+ // shows (one pane at a time there, so one row).
470
+ const row = wide ? null : (_jsx(XStack, { "data-slot": "views-row", justify: "center", px: "$3", pb: "$2", shrink: 0, children: views }));
471
+ return (_jsxs(_Fragment, { children: [_jsxs(Workspace, { start: _jsxs(XStack, { items: "center", gap: "$2", minW: 0, shrink: 1, children: [_jsx(XStack, { render: "button", "aria-label": t('All runs'), onPress: () => host.go(''), p: "$1", shrink: 0, children: _jsx(HanzoMark, { size: 20 }) }), _jsx(ProjectChip, { name: title, onPress: () => setSwitcher(true) }), _jsx(XStack, { render: "button", "aria-label": t('History'), onPress: () => setHistory(true), p: "$1.5", rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, children: _jsx(Clock, { size: 16 }) }), _jsx(XStack, { render: "button", "aria-label": shut ? t('Show the chat') : t('Hide the chat'), "aria-pressed": !shut, onClick: () => (cramped ? setAsked(!asked) : setCollapsed(!collapsed)), minW: 32, minH: 32, items: "center", justify: "center", rounded: "$3", shrink: 0, hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$max-md": { display: 'none' }, children: _jsx(PanelLeft, { size: 16 }) })] }), middle: wide ? views : undefined, end: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(XStack, { display: "none", $md: { display: 'flex' }, children: _jsxs(Button, { variant: "outline", size: "sm", onPress: () => void share(), children: [_jsx(Share2, { size: 14 }), " ", t('Share')] }) }), _jsxs(Button, { size: "sm", variant: "primary", "aria-label": t('Publish'), disabled: !clone || !slug, onPress: () => setPublish({ repo: clone, title, ref, name: slug, project: slug }), children: [_jsx(Upload, { size: 14 }), _jsx(SizableText, { size: "$2", color: "inherit", "$max-md": { display: 'none' }, children: t('Publish') })] })] }), chat: _jsxs(_Fragment, { children: [row, chat] }), dock: _jsx(Console, { lines: lines, height: dock, onHeight: setDock, onClear: () => setPageLines([]), status: run.status || end.status || undefined, label: t('Console') }), collapsed: shut, pane: pane, width: across, onLayout: (e) => setRoom(e.nativeEvent.layout.width), children: [row, preview, body] }), _jsx(Dialog, { open: history, onOpenChange: setHistory, children: _jsxs(DialogContent, { maxW: 480, children: [_jsx(DialogTitle, { children: t('Runs on {title}', { title }) }), _jsx(YStack, { gap: "$1", children: runs.value.length === 0 ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('No runs yet.') })) : (runs.value.map((r) => {
465
472
  const active = r.id === current;
466
473
  return (_jsxs(XStack, { render: "button", "aria-current": active ? 'true' : undefined, onPress: () => {
467
474
  setChosen(r.id);
package/lib/run.js CHANGED
@@ -29,7 +29,7 @@ import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
29
29
  import { phrase } from '@hanzo/i18n';
30
30
  import { useI18n } from '@hanzo/i18n/react';
31
31
  import { Check, ChevronDown, ChevronRight, Clock, Copy, ExternalLink, FileDiff, Folder, GitPullRequest, Globe, Layers, MessageSquare, MoreHorizontal, Pencil, Share, SlidersHorizontal, SquareTerminal, } from '@hanzogui/lucide-icons-2';
32
- import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Input, } from '@hanzo/ui';
32
+ import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Input, } from '@hanzo/ui';
33
33
  import { Steer } from '@hanzo/ui/agents';
34
34
  import { Composer, Failure, measure } from '@hanzo/ui/chat';
35
35
  import { useLimits } from '@hanzo/ui/product/useLimits';
@@ -82,7 +82,7 @@ function Job({ id, state: read }) {
82
82
  const host = useHost();
83
83
  const t = useTarget();
84
84
  const signed = Boolean(host.person);
85
- const [devMode] = useDevMode();
85
+ const [devMode, setDevMode] = useDevMode();
86
86
  const { detail, record, events, status, refused } = read;
87
87
  const [draft, setDraft] = useState('');
88
88
  const [files, setFiles] = useState([]);
@@ -499,7 +499,7 @@ function Job({ id, state: read }) {
499
499
  ['concise', say('Concise')],
500
500
  ['explanatory', say('Explanatory')],
501
501
  ['learning', say('Learning')],
502
- ].map(([val, label]) => (_jsxs(DropdownMenuItem, { onSelect: () => setOutputStyle(val), children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: label }), outputStyle === val ? _jsx(Check, { size: 14, color: "$blue10" }) : null] }, val))), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onSelect: () => setOutputStyle('custom'), children: _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: say('New style...') }) })] })] }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onSelect: () => void copy('id', id), children: _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: copied === 'id' ? say('Copied') : say('Copy run id') }) }), _jsx(DropdownMenuItem, { onSelect: () => {
502
+ ].map(([val, label]) => (_jsxs(DropdownMenuItem, { onSelect: () => setOutputStyle(val), children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: label }), outputStyle === val ? _jsx(Check, { size: 14, color: "$blue10" }) : null] }, val))), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onSelect: () => setOutputStyle('custom'), children: _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: say('New style...') }) })] })] }), _jsx(DropdownMenuCheckboxItem, { checked: devMode, onCheckedChange: setDevMode, preventCloseOnSelect: true, "aria-label": say('Developer mode'), children: _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", children: say('Developer mode') }), _jsx(SizableText, { size: "$1", color: "$soft", children: say('Show the terminal, commands and each step') })] }) }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onSelect: () => void copy('id', id), children: _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: copied === 'id' ? say('Copied') : say('Copy run id') }) }), _jsx(DropdownMenuItem, { onSelect: () => {
503
503
  const first = shown.find((c) => c.kind === 'said' && c.who === 'person');
504
504
  schedule(first && 'text' in first ? first.text : headline(record.title, record.repo), host.go);
505
505
  }, children: _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: say('Schedule this') }) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { "aria-label": say('Archive'), onSelect: () => {
@@ -510,7 +510,7 @@ function Job({ id, state: read }) {
510
510
  if (running)
511
511
  void stop(t, id, 'Deleted').catch(() => undefined);
512
512
  host.go('');
513
- }, children: [_jsx(SizableText, { size: "$2", color: "$red10", flex: 1, children: say('Delete') }), _jsx(DropdownMenuShortcut, { children: "D" })] })] })] })) : (_jsx(DropdownMenu, { trigger: triggerButton, items: manage })) }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, maxW: "100%", children: [state ? say(STATUS[state] ?? state) : detail.loading ? say('reading') : '', record?.repo, record?.branch, record?.published ? say('shared') : ''].filter(Boolean).join(' · ') })] }), pr.href ? (_jsx(Out, { href: pr.href, label: say('Open pull request {pr}', { pr: pr.label }), children: _jsxs(XStack, { items: "center", gap: "$1.5", px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, children: [_jsx(GitPullRequest, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: pr.label }), _jsx(ExternalLink, { size: 12, opacity: 0.6 })] }) })) : null, sharing.length ? (_jsx(DropdownMenu, { trigger: _jsxs(XStack, { render: "button", "aria-label": say('Share'), items: "center", gap: "$1.5", px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, children: [_jsx(Share, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Share') })] }), items: sharing })) : null, wide ? (_jsxs(XStack, { items: "center", gap: "$0.5", children: [_jsx(XStack, { render: "button", "aria-label": say('Toggle environment column'), "aria-pressed": envColumn, onPress: () => {
513
+ }, children: [_jsx(SizableText, { size: "$2", color: "$red10", flex: 1, children: say('Delete') }), _jsx(DropdownMenuShortcut, { children: "D" })] })] })] })) : (_jsx(DropdownMenu, { trigger: triggerButton, items: manage })) }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, maxW: "100%", children: [state ? say(STATUS[state] ?? state) : detail.loading ? say('reading') : '', record?.repo, devMode ? record?.branch : '', record?.published ? say('shared') : ''].filter(Boolean).join(' · ') })] }), pr.href ? (_jsx(Out, { href: pr.href, label: say('Open pull request {pr}', { pr: pr.label }), children: _jsxs(XStack, { items: "center", gap: "$1.5", px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, children: [_jsx(GitPullRequest, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: pr.label }), _jsx(ExternalLink, { size: 12, opacity: 0.6 })] }) })) : null, sharing.length ? (_jsx(DropdownMenu, { trigger: _jsxs(XStack, { render: "button", "aria-label": say('Share'), items: "center", gap: "$1.5", px: "$2.5", py: "$1.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, children: [_jsx(Share, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Share') })] }), items: sharing })) : null, wide ? (_jsxs(XStack, { items: "center", gap: "$0.5", children: [_jsx(XStack, { render: "button", "aria-label": say('Toggle environment column'), "aria-pressed": envColumn, onPress: () => {
514
514
  if (!desk)
515
515
  setDesk(true);
516
516
  setEnvColumn((v) => !v);
@@ -522,7 +522,7 @@ function Job({ id, state: read }) {
522
522
  if (!desk)
523
523
  setDesk(true);
524
524
  setEnvColumn(true);
525
- }, children: [_jsx(Layers, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: say('Background tasks') }), _jsx(XStack, { px: "$1.5", py: "$0.5", rounded: 99, bg: "$hover", children: _jsx(SizableText, { size: "$1", color: "$soft", children: String(bgTaskCount) }) })] }), _jsx(DropdownMenuSeparator, {}), _jsx(KeepAwake, { on: keepAwake, onToggle: (on) => void setKeepAwake(on) })] })] })] })) : null, _jsx(PanelToggle, { open: desk, onToggle: () => setDesk(!desk) })] }), _jsx(Transcript, { cards: shown, view: transcriptView, queued: queued, onSendQueued: sendQueued, onOpen: look, onDiff: () => {
525
+ }, children: [_jsx(Layers, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, children: say('Background tasks') }), _jsx(XStack, { px: "$1.5", py: "$0.5", rounded: 99, bg: "$hover", children: _jsx(SizableText, { size: "$1", color: "$soft", children: String(bgTaskCount) }) })] }), _jsx(DropdownMenuSeparator, {}), _jsx(KeepAwake, { on: keepAwake, onToggle: (on) => void setKeepAwake(on) })] })] })] })) : null, _jsx(PanelToggle, { open: desk, onToggle: () => setDesk(!desk) })] }), _jsx(Transcript, { cards: shown, devMode: devMode, view: transcriptView, queued: queued, onSendQueued: sendQueued, onOpen: look, onDiff: () => {
526
526
  side.open({ kind: 'diff', title: say('Diff') });
527
527
  setDesk(true);
528
528
  }, listen: signed ? listen : undefined, end: failed ? (_jsx(Failure, { onRetry: busy ? undefined : () => void act(() => carry(again, 'retry')), children: end.problem
@@ -543,7 +543,7 @@ function Job({ id, state: read }) {
543
543
  ? setup
544
544
  ? say('Setting up environment')
545
545
  : say('Starting…')
546
- : say('Waiting for the run’s first step…') })) : (_jsxs(YStack, { gap: "$3", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: say('Sign in to follow this run.') }), _jsx(Button, { size: "sm", onPress: () => host.signIn?.(), children: say('Sign in') })] })) }), _jsxs(YStack, { pb: "$3", pt: "$2", gap: "$2", children: [_jsxs(YStack, { ...measure, gap: "$2", children: [end.problem ? (_jsx(SizableText, { size: "$1", color: "$soft", children: say('The branch is pushed, and the pull request could not be opened.') })) : null, note || (signed && refused) ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note || refused })) : null, plan.length ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: [_jsxs(XStack, { render: "button", "aria-label": say('Steps · {n}', { n: plan.length }), "aria-expanded": unfolded, onClick: () => setUnfolded(!unfolded), width: "100%", px: "$3", py: "$1.5", minH: 36, gap: "$2", items: "center", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING_INSET, children: [unfolded ? _jsx(ChevronDown, { size: 14 }) : _jsx(ChevronRight, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Steps · {n}', { n: plan.length }) }), current && !unfolded ? (_jsx(SizableText, { flex: 1, minW: 0, size: "$1", color: "$soft", numberOfLines: 1, text: "end", children: current.name })) : null] }), unfolded
546
+ : say('Waiting for the run’s first step…') })) : (_jsxs(YStack, { gap: "$3", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: say('Sign in to follow this run.') }), _jsx(Button, { size: "sm", onPress: () => host.signIn?.(), children: say('Sign in') })] })) }), _jsxs(YStack, { pb: "$3", pt: "$2", gap: "$2", children: [_jsxs(YStack, { ...measure, gap: "$2", children: [end.problem ? (_jsx(SizableText, { size: "$1", color: "$soft", children: say('The branch is pushed, and the pull request could not be opened.') })) : null, note || (signed && refused) ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note || refused })) : null, plan.length && devMode ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: [_jsxs(XStack, { render: "button", "aria-label": say('Steps · {n}', { n: plan.length }), "aria-expanded": unfolded, onClick: () => setUnfolded(!unfolded), width: "100%", px: "$3", py: "$1.5", minH: 36, gap: "$2", items: "center", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING_INSET, children: [unfolded ? _jsx(ChevronDown, { size: 14 }) : _jsx(ChevronRight, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Steps · {n}', { n: plan.length }) }), current && !unfolded ? (_jsx(SizableText, { flex: 1, minW: 0, size: "$1", color: "$soft", numberOfLines: 1, text: "end", children: current.name })) : null] }), unfolded
547
547
  ? plan.map((s) => {
548
548
  const on = s === current;
549
549
  return (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", py: "$1.5", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$2", color: s.done || on ? '$ink' : '$soft', children: s.done ? '✓' : on ? '●' : '○' }), _jsx(SizableText, { size: "$2", color: s.done ? '$soft' : '$ink', numberOfLines: 1, children: s.name })] }, s.name));
@@ -7,7 +7,7 @@ export interface QueuedMessage {
7
7
  text: string;
8
8
  }
9
9
  export type TranscriptView = 'normal' | 'thinking' | 'verbose';
10
- export declare function Transcript({ cards, live, empty, header, onApprove, approving, onVerdict, onOpen, onDiff, listen, end, view, queued, onSendQueued, onRun, onAnswer, }: {
10
+ export declare function Transcript({ cards, live, empty, header, onApprove, approving, onVerdict, onOpen, onDiff, listen, end, view, queued, onSendQueued, onRun, onAnswer, devMode, }: {
11
11
  cards: Card[];
12
12
  /** The run is still working: a card still running shows it; otherwise it was cut off. */
13
13
  live: boolean;
@@ -36,4 +36,10 @@ export declare function Transcript({ cards, live, empty, header, onApprove, appr
36
36
  onRun?: (session: string) => void;
37
37
  /** Answer a question the run asked with one of its options. Absent, a question has no buttons. */
38
38
  onAnswer?: (question: string, label: string) => void;
39
+ /**
40
+ * Draw every command, read, edit and step as its own card. Off, each run of
41
+ * them folds into one plain line that opens onto them (plain.ts), so the
42
+ * transcript reads as its result. Absent, the reader's Developer mode decides.
43
+ */
44
+ devMode?: boolean;
39
45
  }): import("react").JSX.Element;
package/lib/transcript.js CHANGED
@@ -25,6 +25,8 @@ import { Feedback } from '@hanzo/ui/agents';
25
25
  import { Code, GAP, MEASURE, Message, Step, Thread } from '@hanzo/ui/chat';
26
26
  import { useState } from 'react';
27
27
  import { counted, edited, explored } from './api/cli.js';
28
+ import { useDevMode } from './dev-mode.js';
29
+ import { doing, fold, plainPath, ranOf, worked } from './plain.js';
28
30
  import { Prose } from './prose.js';
29
31
  import { artifacts, lead, Reply } from './reply.js';
30
32
  /** A card's output, its tail: what a command said last is why it stopped. */
@@ -40,53 +42,66 @@ function UserSaid({ text, after }) {
40
42
  const long = text.length > 180 || text.includes('\n');
41
43
  return (_jsxs(YStack, { width: "100%", items: "flex-end", gap: "$1", children: [_jsx(Message, { role: "user", children: _jsx(YStack, { ...(long && !open ? { maxHeight: 72, overflow: 'hidden' } : null), children: _jsx(Prose, { text: text }) }) }), long ? (_jsx(XStack, { render: "button", "aria-expanded": open, onPress: () => setOpen((v) => !v), self: "flex-start", px: "$2", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$1", color: "$soft", children: open ? t('Show less') : t('Show more') }) })) : null, after] }));
42
44
  }
43
- export function Transcript({ cards, live, empty, header, onApprove, approving = false, onVerdict, onOpen, onDiff, listen, end, view = 'normal', queued = [], onSendQueued, onRun, onAnswer, }) {
45
+ export function Transcript({ cards, live, empty, header, onApprove, approving = false, onVerdict, onOpen, onDiff, listen, end, view = 'normal', queued = [], onSendQueued, onRun, onAnswer, devMode, }) {
44
46
  const { t } = useI18n();
47
+ const [developer, setDeveloper] = useDevMode();
48
+ const dev = devMode ?? developer;
49
+ // A path a person reads off Developer mode is said in words (`~` is "your home folder").
50
+ const path = (p) => (dev ? p : plainPath(p, t));
45
51
  // A card the run never finished is cut off once the run has ended, not still going.
46
52
  const state = (ran) => (ran === 'running' && !live ? 'cancelled' : ran);
47
53
  // The answer still arriving: the last thing the agent said while the run works.
48
54
  const last = live ? [...cards].reverse().find((c) => c.kind === 'said' && c.who === 'agent')?.key : undefined;
49
55
  const expandThink = view === 'thinking' || view === 'verbose';
50
56
  const expandVerbose = view === 'verbose';
51
- return (_jsxs(Thread, { gap: GAP, column: { maxW: MEASURE }, "aria-label": t('Transcript'), children: [header, cards.length === 0 && queued.length === 0 ? _jsx(YStack, { py: "$2", children: empty }) : null, cards.map((c) => {
52
- switch (c.kind) {
53
- case 'said': {
54
- if (c.who === 'person')
55
- return _jsx(UserSaid, { text: c.text }, c.key);
56
- const made = artifacts(c.text);
57
- const first = lead(made);
58
- return (_jsx(Message, { role: "assistant", busy: c.key === last, children: _jsxs(YStack, { gap: "$1", children: [_jsx(Prose, { text: c.text }), c.key === last ? null : (_jsx(Reply, { text: c.text, listen: listen, onOpen: first && onOpen ? () => onOpen(first) : undefined, children: _jsx(Judge, { onVerdict: onVerdict }) }))] }) }, c.key));
59
- }
60
- case 'think':
61
- return (_jsx(Step, { name: t('Thought'), detail: firstLine(c.text), status: "done", defaultOpen: expandThink, "aria-label": t('Thought'), children: _jsx(Prose, { text: c.text }) }, `${c.key}:${view}`));
62
- case 'todo':
63
- return (_jsx(YStack, { gap: "$1", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Plan checklist'), children: c.items.map((x, i) => (_jsxs(XStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: x.done ? '$ink' : '$soft', children: x.done ? '✓' : '○' }), _jsx(SizableText, { flex: 1, size: "$2", color: x.done ? '$soft' : '$ink', children: x.text })] }, i))) }, c.key));
64
- case 'shell':
65
- // The CLI's words: Ran (Running while it works), the command as the shell got it, its output under it.
66
- return (_jsx(Step, { name: state(c.ran) === 'running' ? t('Running') : t('Ran'), detail: c.command, status: state(c.ran), defaultOpen: expandVerbose, "aria-label": t('Command {command}', { command: c.command }), children: _jsx(Code, { language: "shell", value: c.output || t('(no output)'), children: c.output ? tail(c.output.replace(/\n+$/, '')) : t('(no output)') }) }, `${c.key}:${view}`));
67
- case 'explore':
68
- // The CLI's Explored block: one line an action, consecutive reads on one line (cli.ts explored).
69
- return (_jsxs(YStack, { gap: "$1", "aria-label": state(c.ran) === 'running' ? t('Exploring') : t('Explored'), children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: state(c.ran) === 'running' ? t('Exploring') : t('Explored') }), explored(c.calls).map((l, i) => (_jsxs(XStack, { gap: "$2", pl: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", shrink: 0, children: t(l.title) }), _jsx(SizableText, { size: "$2", color: "$ink", style: { ...mono, overflowWrap: 'anywhere' }, children: l.text })] }, i)))] }, c.key));
70
- case 'edit':
71
- // The CLI's patch header: Added / Deleted / Edited a file, or Edited N files, with the lines added and removed.
72
- return (_jsx(Step, { name: !c.files.length ? t('Edited files') : c.files.length > 1 ? `Edited ${c.files.length} files` : edited(c.files).split(' ')[0], detail: !c.files.length ? '' : c.files.length > 1 ? edited(c.files).split(' ').slice(3).join(' ') : edited(c.files).split(' ').slice(1).join(' '), status: state(c.ran), defaultOpen: expandVerbose, "aria-label": c.files.length ? edited(c.files) : t('Edited files'), children: _jsxs(YStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$1", color: "$soft", style: { whiteSpace: 'pre-wrap' }, children: c.files.length ? c.files.map((f) => `${f.path} ${counted(f)}`.trimEnd()).join('\n') : t('The agent named no files.') }), onDiff ? (_jsx(Button, { size: "sm", variant: "outline", onPress: onDiff, children: t('Open the diff') })) : null] }) }, `${c.key}:${view}`));
73
- case 'step':
74
- return (_jsx(Step, { name: t(c.name), detail: c.detail, status: state(c.ran), defaultOpen: c.name === 'Error' || expandVerbose, "aria-label": `${t(c.name)} ${c.detail}`.trim(), children: c.name === 'Error' ? (_jsx(SizableText, { size: "$2", color: "$ink", style: { ...mono, whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }, children: c.output })) : c.output.trim() ? (_jsx(Code, { language: "output", value: c.output, children: tail(c.output.replace(/\n+$/, '')) })) : undefined }, `${c.key}:${view}`));
75
- case 'note': {
76
- const noteText = t(c.text);
77
- if (/^Pushed\s+/i.test(c.text) || /^Pushed\s+/i.test(noteText)) {
78
- return (_jsx(XStack, { role: "note", self: "flex-start", children: _jsxs(XStack, { items: "center", gap: "$1.5", px: "$2.5", py: "$1", "$platform-web": { display: 'inline-flex' }, children: [_jsx(GitBranch, { size: 12, color: "$soft", shrink: 0, "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", children: noteText })] }) }, c.key));
79
- }
80
- return (_jsx(SizableText, { size: "$1", color: "$soft", role: "note", children: noteText }, c.key));
81
- }
82
- case 'run':
83
- return (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Coding run'), children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", numberOfLines: 1, children: t('Coding run') }), onRun ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => onRun(c.session), children: t('Open the run') })) : null] }, c.key));
84
- case 'ask':
85
- return (_jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Question'), children: [_jsx(Prose, { text: c.text }), c.answer ? (_jsx(SizableText, { size: "$2", color: "$soft", children: `✓ ${c.answer}` })) : (_jsx(XStack, { gap: "$2", flexWrap: "wrap", children: c.options.map((label) => (_jsx(Button, { size: "sm", variant: "outline", disabled: !onAnswer, onPress: () => onAnswer?.(c.question, label), children: label }, label))) }))] }, c.key));
86
- case 'plan':
87
- return (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", "aria-label": t('Plan'), children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Plan') }), _jsx(Prose, { text: c.text }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsx(Reply, { text: c.text, listen: listen }), onApprove ? (_jsx(Button, { size: "sm", disabled: approving, onPress: () => onApprove(c.text), children: approving ? t('Starting the build…') : t('Approve and build') })) : null, _jsx(Judge, { onVerdict: onVerdict })] })] }, c.key));
57
+ const draw = (c) => {
58
+ switch (c.kind) {
59
+ case 'said': {
60
+ if (c.who === 'person')
61
+ return _jsx(UserSaid, { text: c.text }, c.key);
62
+ const made = artifacts(c.text);
63
+ const first = lead(made);
64
+ return (_jsx(Message, { role: "assistant", busy: c.key === last, children: _jsxs(YStack, { gap: "$1", children: [_jsx(Prose, { text: c.text }), c.key === last ? null : (_jsx(Reply, { text: c.text, listen: listen, onOpen: first && onOpen ? () => onOpen(first) : undefined, children: _jsx(Judge, { onVerdict: onVerdict }) }))] }) }, c.key));
65
+ }
66
+ case 'think':
67
+ return (_jsx(Step, { name: t('Thought'), detail: firstLine(c.text), status: "done", defaultOpen: expandThink, "aria-label": t('Thought'), children: _jsx(Prose, { text: c.text }) }, `${c.key}:${view}`));
68
+ case 'todo':
69
+ return (_jsx(YStack, { gap: "$1", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Plan checklist'), children: c.items.map((x, i) => (_jsxs(XStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: x.done ? '$ink' : '$soft', children: x.done ? '✓' : '○' }), _jsx(SizableText, { flex: 1, size: "$2", color: x.done ? '$soft' : '$ink', children: x.text })] }, i))) }, c.key));
70
+ case 'shell':
71
+ // The CLI's words: Ran (Running while it works), the command as the shell got it, its output under it.
72
+ return (_jsx(Step, { name: state(c.ran) === 'running' ? t('Running') : t('Ran'), detail: c.command, status: state(c.ran), defaultOpen: expandVerbose, "aria-label": t('Command {command}', { command: c.command }), children: _jsx(Code, { language: "shell", value: c.output || t('(no output)'), children: c.output ? tail(c.output.replace(/\n+$/, '')) : t('(no output)') }) }, `${c.key}:${view}`));
73
+ case 'explore':
74
+ // The CLI's Explored block: one line an action, consecutive reads on one line (cli.ts explored).
75
+ return (_jsxs(YStack, { gap: "$1", "aria-label": state(c.ran) === 'running' ? t('Exploring') : t('Explored'), children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: state(c.ran) === 'running' ? t('Exploring') : t('Explored') }), explored(c.calls).map((l, i) => (_jsxs(XStack, { gap: "$2", pl: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", shrink: 0, children: t(l.title) }), _jsx(SizableText, { size: "$2", color: "$ink", style: { ...mono, overflowWrap: 'anywhere' }, children: path(l.text) })] }, i)))] }, c.key));
76
+ case 'edit':
77
+ // The CLI's patch header: Added / Deleted / Edited a file, or Edited N files, with the lines added and removed.
78
+ return (_jsx(Step, { name: !c.files.length ? t('Edited files') : c.files.length > 1 ? `Edited ${c.files.length} files` : edited(c.files).split(' ')[0], detail: !c.files.length ? '' : c.files.length > 1 ? edited(c.files).split(' ').slice(3).join(' ') : edited(c.files).split(' ').slice(1).join(' '), status: state(c.ran), defaultOpen: expandVerbose, "aria-label": c.files.length ? edited(c.files) : t('Edited files'), children: _jsxs(YStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$1", color: "$soft", style: { whiteSpace: 'pre-wrap' }, children: c.files.length ? c.files.map((f) => `${path(f.path)} ${counted(f)}`.trimEnd()).join('\n') : t('The agent named no files.') }), onDiff ? (_jsx(Button, { size: "sm", variant: "outline", onPress: onDiff, children: t('Open the diff') })) : null] }) }, `${c.key}:${view}`));
79
+ case 'step':
80
+ return (_jsx(Step, { name: t(c.name), detail: c.detail, status: state(c.ran), defaultOpen: c.name === 'Error' || expandVerbose, "aria-label": `${t(c.name)} ${c.detail}`.trim(), children: c.name === 'Error' ? (_jsx(SizableText, { size: "$2", color: "$ink", style: { ...mono, whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }, children: c.output })) : c.output.trim() ? (_jsx(Code, { language: "output", value: c.output, children: tail(c.output.replace(/\n+$/, '')) })) : undefined }, `${c.key}:${view}`));
81
+ case 'note': {
82
+ const noteText = t(c.text);
83
+ if (/^Pushed\s+/i.test(c.text) || /^Pushed\s+/i.test(noteText)) {
84
+ return (_jsx(XStack, { role: "note", self: "flex-start", children: _jsxs(XStack, { items: "center", gap: "$1.5", px: "$2.5", py: "$1", "$platform-web": { display: 'inline-flex' }, children: [_jsx(GitBranch, { size: 12, color: "$soft", shrink: 0, "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", children: noteText })] }) }, c.key));
88
85
  }
89
- }), queued.map((q) => (_jsx(UserSaid, { text: q.text, after: onSendQueued ? (_jsx(XStack, { render: "button", "aria-label": t('Send now'), onPress: () => onSendQueued(q.id), px: "$2", py: "$0.5", children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('Send now') }) })) : undefined }, q.id))), end] }));
86
+ return (_jsx(SizableText, { size: "$1", color: "$soft", role: "note", children: noteText }, c.key));
87
+ }
88
+ case 'run':
89
+ return (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Coding run'), children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", numberOfLines: 1, children: t('Coding run') }), onRun ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => onRun(c.session), children: t('Open the run') })) : null] }, c.key));
90
+ case 'ask':
91
+ return (_jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Question'), children: [_jsx(Prose, { text: c.text }), c.answer ? (_jsx(SizableText, { size: "$2", color: "$soft", children: `✓ ${c.answer}` })) : (_jsx(XStack, { gap: "$2", flexWrap: "wrap", children: c.options.map((label) => (_jsx(Button, { size: "sm", variant: "outline", disabled: !onAnswer, onPress: () => onAnswer?.(c.question, label), children: label }, label))) }))] }, c.key));
92
+ case 'plan':
93
+ return (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", "aria-label": t('Plan'), children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Plan') }), _jsx(Prose, { text: c.text }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsx(Reply, { text: c.text, listen: listen }), onApprove ? (_jsx(Button, { size: "sm", disabled: approving, onPress: () => onApprove(c.text), children: approving ? t('Starting the build…') : t('Approve and build') })) : null, _jsx(Judge, { onVerdict: onVerdict })] })] }, c.key));
94
+ }
95
+ };
96
+ // The work between two things a person reads, as one line that opens onto it.
97
+ const work = (w) => {
98
+ const ran = ranOf(w.cards, state);
99
+ const now = [...w.cards].reverse().find((c) => 'ran' in c && state(c.ran) === 'running');
100
+ const name = ran === 'running' ? t('Working') : t('Worked');
101
+ const line = ran === 'running' ? doing(now ?? w.cards[w.cards.length - 1], t) : worked(w.cards, t);
102
+ return (_jsx(Step, { name: name, detail: line, status: ran, defaultOpen: expandVerbose, "aria-label": `${name} ${line}`.trim(), children: _jsxs(YStack, { gap: "$2", children: [w.cards.map(draw), _jsx(XStack, { render: "button", self: "flex-start", "aria-label": t('Turn on Developer mode'), onPress: () => setDeveloper(true), px: "$2", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('Always show each step: turn on Developer mode') }) })] }) }, `${w.key}:${view}`));
103
+ };
104
+ return (_jsxs(Thread, { gap: GAP, column: { maxW: MEASURE }, "aria-label": t('Transcript'), children: [header, cards.length === 0 && queued.length === 0 ? _jsx(YStack, { py: "$2", children: empty }) : null, dev ? cards.map(draw) : fold(cards).map((x) => (x.kind === 'work' ? work(x) : draw(x))), queued.map((q) => (_jsx(UserSaid, { text: q.text, after: onSendQueued ? (_jsx(XStack, { render: "button", "aria-label": t('Send now'), onPress: () => onSendQueued(q.id), px: "$2", py: "$0.5", children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('Send now') }) })) : undefined }, q.id))), end] }));
90
105
  }
91
106
  /** Say whether what the agent said was good. A verdict that did not land is taken back and says why. */
92
107
  function Judge({ onVerdict }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/build",
3
- "version": "0.2.129",
3
+ "version": "0.2.131",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",