@hanzo/build 0.2.130 → 0.2.132
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 +8 -0
- package/lib/api/skills.d.ts +22 -0
- package/lib/api/skills.js +18 -0
- package/lib/api/turn.d.ts +4 -1
- package/lib/api/turn.js +2 -1
- package/lib/carry.d.ts +7 -0
- package/lib/carry.js +20 -10
- package/lib/dev-mode.d.ts +17 -0
- package/lib/dev-mode.js +35 -1
- package/lib/host.d.ts +8 -0
- package/lib/host.js +4 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.js +4 -2
- package/lib/landing.js +150 -43
- package/lib/local.d.ts +55 -0
- package/lib/local.js +63 -0
- package/lib/plain.d.ts +46 -0
- package/lib/plain.js +180 -0
- package/lib/run.js +6 -6
- package/lib/transcript.d.ts +7 -1
- package/lib/transcript.js +54 -39
- package/package.json +1 -1
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/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));
|
package/lib/transcript.d.ts
CHANGED
|
@@ -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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.2.132",
|
|
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.",
|