@hanzo/build 0.2.131 → 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/host.d.ts +8 -0
- package/lib/host.js +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/landing.js +150 -43
- package/lib/local.d.ts +55 -0
- package/lib/local.js +63 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -287,6 +287,14 @@ light round chips as tall as the composer's controls, on one centreline a gap ap
|
|
|
287
287
|
(the composer stands every `ChipSelect` in its pills so, on a phone and a laptop alike),
|
|
288
288
|
and Repos, Branches, Issues and Templates under it, each a press to its list. A codebase can be added to a project. Opening a codebase or an
|
|
289
289
|
issue from its own screen lands here with that choice already made.
|
|
290
|
+
A repository is optional everywhere: with none, a run works in a new folder (in
|
|
291
|
+
the sandbox, or on a machine), and GitHub can be connected later. On a host that
|
|
292
|
+
has the computer (Hanzo Desktop hands `local`, local.ts), This computer comes
|
|
293
|
+
first: the run works in a folder there and needs no repository, the Folder pill
|
|
294
|
+
reads Auto (the folder used most recently) until another is chosen, Choose
|
|
295
|
+
folder… opens the computer's own dialog, and a computer that opened no folder
|
|
296
|
+
asks for one on the first send. The agent reads, edits and runs in that folder
|
|
297
|
+
only, and what it printed shows under the composer when it ends.
|
|
290
298
|
|
|
291
299
|
**A run.** The transcript as it streams, drawn by what each part is: what the
|
|
292
300
|
agent says as markdown, each command it runs as a card that opens onto its
|
package/lib/host.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { type ComponentType, type ReactNode } from 'react';
|
|
|
11
11
|
import type { Cast } from './api/agents.ts';
|
|
12
12
|
import type { Target } from './api/call.ts';
|
|
13
13
|
import type { Theme } from './api/pref.ts';
|
|
14
|
+
import type { Local } from './local.ts';
|
|
14
15
|
export interface Person {
|
|
15
16
|
name: string;
|
|
16
17
|
email: string;
|
|
@@ -118,6 +119,11 @@ export interface Host {
|
|
|
118
119
|
cast?: readonly Cast[];
|
|
119
120
|
/** Every persona Customize › Agents offers to start from, read when Browse opens. Absent, none. */
|
|
120
121
|
personas?: () => Promise<readonly Cast[]>;
|
|
122
|
+
/**
|
|
123
|
+
* The folders of the computer the host runs on, and a run in one of them (local.ts): Hanzo Desktop has them, so New
|
|
124
|
+
* offers This computer with Auto picking the folder used last. A browser page has no folder of its own: absent.
|
|
125
|
+
*/
|
|
126
|
+
local?: Local;
|
|
121
127
|
}
|
|
122
128
|
export declare function HostProvider({ host, children }: {
|
|
123
129
|
host: Host;
|
|
@@ -126,6 +132,8 @@ export declare function HostProvider({ host, children }: {
|
|
|
126
132
|
export declare function useHost(): Host;
|
|
127
133
|
/** The host's way of showing a page, where one is mounted and has one. The side panel is drawn without a host too (hanzo.team's rooms). */
|
|
128
134
|
export declare function useBrowse(): Browse | null;
|
|
135
|
+
/** The host's computer and its folders, where the host runs on one (Hanzo Desktop). */
|
|
136
|
+
export declare function useLocal(): Local | null;
|
|
129
137
|
/** The host's browser, where one is mounted and has one. */
|
|
130
138
|
export declare function useBrowser(): Browser | null;
|
|
131
139
|
/** The call target for this host — stable while the host's api, token reader and org are. */
|
package/lib/host.js
CHANGED
|
@@ -23,6 +23,10 @@ export function useHost() {
|
|
|
23
23
|
export function useBrowse() {
|
|
24
24
|
return useContext(Context)?.browse ?? null;
|
|
25
25
|
}
|
|
26
|
+
/** The host's computer and its folders, where the host runs on one (Hanzo Desktop). */
|
|
27
|
+
export function useLocal() {
|
|
28
|
+
return useContext(Context)?.local ?? null;
|
|
29
|
+
}
|
|
26
30
|
/** The host's browser, where one is mounted and has one. */
|
|
27
31
|
export function useBrowser() {
|
|
28
32
|
return useContext(Context)?.browser ?? null;
|
package/lib/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export { kind, label, said, share, spent, ways, when, type Label, type Share, ty
|
|
|
42
42
|
export type { Limits } from './api/limits.ts';
|
|
43
43
|
export type { Target } from './api/call.ts';
|
|
44
44
|
export type { Browse, Browser, Host, Person, Shown } from './host.tsx';
|
|
45
|
+
export type { Done, Folder, Local } from './local.ts';
|
|
45
46
|
export type { Session, Status } from './api/sessions.ts';
|
|
46
47
|
export { talks } from './api/talk.ts';
|
|
47
48
|
export { detect, type Detected } from './api/skills.ts';
|
package/lib/landing.js
CHANGED
|
@@ -10,8 +10,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
10
10
|
* Sending opens a conversation (api/talk.ts) and goes to it: the agent answers,
|
|
11
11
|
* and decides for itself when the ask needs a sandbox or a coding run — on the
|
|
12
12
|
* repository, branch and machine chosen here, and only planning when Plan is on.
|
|
13
|
-
* A
|
|
14
|
-
*
|
|
13
|
+
* A repository is never a gate: a run with none works in a new folder, in the
|
|
14
|
+
* sandbox or on one of the org's machines (hanzo-inc/cloud issue 779), and
|
|
15
|
+
* GitHub can be connected later. On a host that has the computer (Hanzo
|
|
16
|
+
* Desktop, `host.local`), New also offers This computer: the run works in a
|
|
17
|
+
* folder there, Auto picking the folder used last (local.ts), and needs no
|
|
18
|
+
* repository at all (hanzo-inc/app issues 309 and 310). The choices a person made here are kept in this
|
|
15
19
|
* browser, per org, so the next New starts where the last one did — and a kept
|
|
16
20
|
* repository New can no longer offer is let go, so the next run is not sent
|
|
17
21
|
* back to it. A repository can also be given by its address (Use a git URL).
|
|
@@ -22,7 +26,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
22
26
|
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
23
27
|
import { phrase } from '@hanzo/i18n';
|
|
24
28
|
import { useI18n } from '@hanzo/i18n/react';
|
|
25
|
-
import { CircleDot, Cloud, Code, FolderGit2, GitBranch, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
|
|
29
|
+
import { CircleDot, Cloud, Code, FolderGit2, FolderOpen, GitBranch, Laptop, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
|
|
26
30
|
import { Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@hanzo/ui';
|
|
27
31
|
import { Composer, MEASURE } from '@hanzo/ui/chat';
|
|
28
32
|
import { BranchSelect, ChipSelect, FooterLink, RepoSelect } from '@hanzo/ui/product';
|
|
@@ -44,7 +48,8 @@ import { asHub, gone, isForge, isHub, settle } from './choice.js';
|
|
|
44
48
|
import { useCached, useKept, usePlaces, useRead } from './data.js';
|
|
45
49
|
import { useDevMode } from './dev-mode.js';
|
|
46
50
|
import { takeHandoff } from './handoff.js';
|
|
47
|
-
import { useHost, useTarget } from './host.js';
|
|
51
|
+
import { useHost, useLocal, useTarget } from './host.js';
|
|
52
|
+
import { failed, HERE, recent, where } from './local.js';
|
|
48
53
|
import { level, pacing, useMind } from './mind.js';
|
|
49
54
|
import { usePrefs } from './prefs.js';
|
|
50
55
|
import { Publish } from './publish.js';
|
|
@@ -64,7 +69,9 @@ export const MODES = [
|
|
|
64
69
|
];
|
|
65
70
|
/** The org's repositories before they have been read: no answer, so nothing is judged from it. */
|
|
66
71
|
const NOHOMES = { homes: [], whole: false };
|
|
67
|
-
const FIRST = { repo: null, branch: '', place: '', mode: 'build', ask: '', issue: 0 };
|
|
72
|
+
const FIRST = { repo: null, branch: '', place: '', folder: '', mode: 'build', ask: '', issue: 0 };
|
|
73
|
+
/** This computer, as a place: always there on a host that has it. */
|
|
74
|
+
const HERE_PLACE = { id: HERE, label: 'This computer', kind: 'here', status: 'online', capacity: '' };
|
|
68
75
|
const UNSENT = 'hanzo.build.unsent';
|
|
69
76
|
let held = { draft: '', files: [] };
|
|
70
77
|
function unsent() {
|
|
@@ -91,6 +98,16 @@ export function hold(u) {
|
|
|
91
98
|
/* kept for the life of the page */
|
|
92
99
|
}
|
|
93
100
|
}
|
|
101
|
+
/** A run on this computer: where it works, what it was asked, and once it ends, what the agent printed. */
|
|
102
|
+
function RanHere({ ran }) {
|
|
103
|
+
const { t } = useI18n();
|
|
104
|
+
const head = ran.going
|
|
105
|
+
? t('Working in {name}…', { name: ran.folder.name })
|
|
106
|
+
: ran.ok
|
|
107
|
+
? t('Done in {name}', { name: ran.folder.name })
|
|
108
|
+
: t('Stopped in {name}', { name: ran.folder.name });
|
|
109
|
+
return (_jsxs(YStack, { "data-slot": "ran-here", role: "status", "aria-live": "polite", gap: "$1.5", mx: "$3", px: "$3", py: "$2.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$background", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [_jsx(FolderOpen, { size: 13, color: "$soft" }), _jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "500", numberOfLines: 1, flex: 1, minW: 0, children: head })] }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, "data-i18n-ltr": "", children: ran.folder.path }), ran.output ? (_jsx(YStack, { maxH: 320, overflowY: "auto", minW: 0, children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", whiteSpace: "pre-wrap", wordWrap: "break-word", "data-i18n-ltr": "", children: ran.output }) })) : null] }));
|
|
110
|
+
}
|
|
94
111
|
export function Landing({ onStarted }) {
|
|
95
112
|
const host = useHost();
|
|
96
113
|
const target = useTarget();
|
|
@@ -100,11 +117,13 @@ export function Landing({ onStarted }) {
|
|
|
100
117
|
const signed = Boolean(host.person);
|
|
101
118
|
const [devMode] = useDevMode();
|
|
102
119
|
const { prefs, save: savePrefs } = usePrefs();
|
|
120
|
+
const local = useLocal();
|
|
103
121
|
const [stored, keep] = useKept(`hanzo.build.new.${host.org ?? 'none'}`, null);
|
|
104
122
|
// What was chosen here, over the person's coding defaults (Settings → Code), over
|
|
105
123
|
// the first run's. Field by field: a codebase or an issue handed over from its own
|
|
106
124
|
// screen keeps only the codebase and the words, and the rest still has a value.
|
|
107
|
-
|
|
125
|
+
// On a host that has the computer, the first run's place is This computer.
|
|
126
|
+
const kept = settle(local ? { ...FIRST, place: HERE } : FIRST, prefs.code, stored);
|
|
108
127
|
const set = (patch) => keep({ ...kept, ...patch });
|
|
109
128
|
const [was] = useState(unsent);
|
|
110
129
|
const [draft, setDraft] = useState(kept.ask || was.draft);
|
|
@@ -180,7 +199,15 @@ export function Landing({ onStarted }) {
|
|
|
180
199
|
const found = useRead(signed && codebase && settled && !stranger ? () => read(target, codebase) : null, null, [target, signed, codebase, settled, stranger]);
|
|
181
200
|
// A read kept from the codebase before is not this one's.
|
|
182
201
|
const env = { ...found, value: found.value && found.value.repo === codebase && !stranger ? found.value : null };
|
|
183
|
-
|
|
202
|
+
// This computer, where the host has it: the run goes to a folder here and never to the platform.
|
|
203
|
+
const here = local !== null && kept.place === HERE;
|
|
204
|
+
const place = here ? SANDBOX : (places.value.find((p) => p.id === kept.place) ?? SANDBOX);
|
|
205
|
+
// The folders this computer opened, most recent first, and the one a run here goes to: the one chosen, else Auto's.
|
|
206
|
+
const folders = local ? recent(local.folders()) : [];
|
|
207
|
+
const folderAt = where(folders, kept.folder);
|
|
208
|
+
const [ran, setRan] = useState(null);
|
|
209
|
+
// Why this mode cannot run where it is sent: a plan is the sandbox's, on a machine and on this computer alike.
|
|
210
|
+
const refused = here ? (mode === 'plan' ? t('A plan runs in the cloud workspace. On this computer, switch to Build.') : '') : unhonoured(mode, place.id, t);
|
|
184
211
|
// The kept repository is checked against what New can offer now (choice.ts
|
|
185
212
|
// `gone`): on arrival, and again each time the GitHub connection changes
|
|
186
213
|
// anywhere on the page (api/github.ts `heard`). One that is gone is let go with
|
|
@@ -252,6 +279,9 @@ export function Landing({ onStarted }) {
|
|
|
252
279
|
}, [target, codebase, home]);
|
|
253
280
|
// The composer sends only a draft with words in it, and not while a send is out.
|
|
254
281
|
const send = async (said = draft) => {
|
|
282
|
+
// This computer needs no sign-in to the platform and no repository: the agent runs in the folder, here.
|
|
283
|
+
if (here && local)
|
|
284
|
+
return void (await sendHere(said));
|
|
255
285
|
if (!signed) {
|
|
256
286
|
hold({ draft: said, files, sent: true });
|
|
257
287
|
host.signIn?.();
|
|
@@ -259,11 +289,7 @@ export function Landing({ onStarted }) {
|
|
|
259
289
|
}
|
|
260
290
|
const repo = isForge(kept.repo) ? kept.repo : null;
|
|
261
291
|
const hub = isHub(kept.repo) ? kept.repo : null;
|
|
262
|
-
|
|
263
|
-
setNote(t('Choose the project this run works on: a repository of this organization, or one on its GitHub.'));
|
|
264
|
-
setPicking(true);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
292
|
+
// No repository is no gate: a machine run with none works in a new folder there (cloud issue 779).
|
|
267
293
|
// A plan or a setup routed to a machine is refused here, in its own words, before it leaves the page.
|
|
268
294
|
const why = unhonoured(mode, place.id, t);
|
|
269
295
|
if (why) {
|
|
@@ -307,7 +333,46 @@ export function Landing({ onStarted }) {
|
|
|
307
333
|
onStarted(sent.session);
|
|
308
334
|
}
|
|
309
335
|
catch (e) {
|
|
310
|
-
setNote(plain(e, repo?.name ?? hub?.full_name ?? t('a new project'), 'run', t));
|
|
336
|
+
setNote(plain(e, repo?.name ?? hub?.full_name ?? (place.id ? activePlaceDisplay.title : t('a new project')), 'run', t));
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
setBusy(false);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* A run on this computer: in the folder chosen, else Auto's (the one used last), else one the person picks now, once.
|
|
344
|
+
* The agent reads, edits and runs there and nowhere else; what it printed is shown under the composer when it ends.
|
|
345
|
+
*/
|
|
346
|
+
const sendHere = async (said) => {
|
|
347
|
+
if (!local || busy)
|
|
348
|
+
return;
|
|
349
|
+
if (refused) {
|
|
350
|
+
setNote(refused);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
let folder = folderAt.folder;
|
|
354
|
+
if (!folder) {
|
|
355
|
+
setNote(t('Choose a folder for this run'));
|
|
356
|
+
folder = await local.pick().catch(() => null);
|
|
357
|
+
if (!folder)
|
|
358
|
+
return;
|
|
359
|
+
set({ place: HERE, folder: '' });
|
|
360
|
+
}
|
|
361
|
+
local.use(folder.path);
|
|
362
|
+
const ask = said.trim();
|
|
363
|
+
const prompt = [carry.text, compose(ask, files)].filter(Boolean).join('\n\n');
|
|
364
|
+
setBusy(true);
|
|
365
|
+
setNote('');
|
|
366
|
+
setRan({ folder, ask, going: true, ok: true, output: '' });
|
|
367
|
+
try {
|
|
368
|
+
const done = await local.run(folder.path, prompt);
|
|
369
|
+
setRan({ folder, ask, going: false, ok: done.ok, output: done.output.trim() });
|
|
370
|
+
setDraft('');
|
|
371
|
+
setFiles([]);
|
|
372
|
+
}
|
|
373
|
+
catch (e) {
|
|
374
|
+
setRan(null);
|
|
375
|
+
setNote(failed(e, t));
|
|
311
376
|
}
|
|
312
377
|
finally {
|
|
313
378
|
setBusy(false);
|
|
@@ -390,37 +455,79 @@ export function Landing({ onStarted }) {
|
|
|
390
455
|
set({ repo: row, branch: row.default_branch });
|
|
391
456
|
};
|
|
392
457
|
// Cloud is the managed workspace, set up by the chosen project's environment; the rest are the org's machines.
|
|
393
|
-
const placeItems = useMemo(() =>
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
:
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
458
|
+
const placeItems = useMemo(() => [
|
|
459
|
+
// This computer first, where the host has it: a folder here is the nearest place a run can go.
|
|
460
|
+
...(local
|
|
461
|
+
? [
|
|
462
|
+
{
|
|
463
|
+
id: HERE,
|
|
464
|
+
label: t('This computer'),
|
|
465
|
+
hint: folderAt.folder ? folderAt.folder.name : t('A folder on this computer'),
|
|
466
|
+
detail: undefined,
|
|
467
|
+
icon: _jsx(Laptop, { size: 13, color: "$soft" }),
|
|
468
|
+
disabled: false,
|
|
469
|
+
place: HERE_PLACE,
|
|
470
|
+
},
|
|
471
|
+
]
|
|
472
|
+
: []),
|
|
473
|
+
...(places.value.length ? places.value : [SANDBOX]).map((p) => {
|
|
474
|
+
const display = displayPlace(p, { devMode, say: t, names });
|
|
475
|
+
return {
|
|
476
|
+
id: p.id || 'sandbox',
|
|
477
|
+
label: display.title,
|
|
478
|
+
hint: p.id
|
|
479
|
+
? devMode
|
|
480
|
+
? [p.status, p.capacity].filter(Boolean).join(' · ')
|
|
481
|
+
: p.status === 'online'
|
|
482
|
+
? t('Online')
|
|
483
|
+
: p.status
|
|
484
|
+
: devMode
|
|
485
|
+
? ''
|
|
486
|
+
: t('Cloud workspace'),
|
|
487
|
+
detail: display.detail,
|
|
488
|
+
icon: p.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }),
|
|
489
|
+
disabled: !ready(p),
|
|
490
|
+
place: p,
|
|
491
|
+
};
|
|
492
|
+
}),
|
|
493
|
+
], [places.value, devMode, t, names, local, folderAt.folder]);
|
|
413
494
|
const activePlaceDisplay = useMemo(() => displayPlace(place, { devMode, say: t, names }), [place, devMode, t, names]);
|
|
414
|
-
const placeTooltip =
|
|
415
|
-
? t('Runs
|
|
416
|
-
:
|
|
417
|
-
|
|
495
|
+
const placeTooltip = here
|
|
496
|
+
? t('Runs on this computer, in the folder you choose. No repository needed.')
|
|
497
|
+
: place.id
|
|
498
|
+
? t('Runs on this machine, in a new folder unless you choose a repository')
|
|
499
|
+
: t('Runs automatically in your Hanzo cloud workspace');
|
|
500
|
+
const placeHardwareHint = place.id && !devMode && !here ? activePlaceDisplay.detail : undefined;
|
|
501
|
+
// The place chosen, as the pill and the `+` menu mark it.
|
|
502
|
+
const placeId = here ? HERE : place.id;
|
|
503
|
+
// This computer's folder: Auto (the one used last) and every folder it opened, most recent first.
|
|
504
|
+
const AUTO = '__auto__';
|
|
505
|
+
const folderItems = useMemo(() => [
|
|
506
|
+
{
|
|
507
|
+
id: AUTO,
|
|
508
|
+
label: t('Auto'),
|
|
509
|
+
hint: folders[0] ? t('Last used: {name}', { name: folders[0].name }) : t('The folder you used last'),
|
|
510
|
+
icon: _jsx(FolderOpen, { size: 13, color: "$soft" }),
|
|
511
|
+
},
|
|
512
|
+
...folders.map((f) => ({ id: f.path, label: f.name, hint: f.path, icon: _jsx(FolderOpen, { size: 13, color: "$soft" }) })),
|
|
513
|
+
], [folders, t]);
|
|
514
|
+
const chooseFolder = async () => {
|
|
515
|
+
if (!local)
|
|
516
|
+
return;
|
|
517
|
+
const f = await local.pick().catch(() => null);
|
|
518
|
+
if (f)
|
|
519
|
+
set({ place: HERE, folder: f.path });
|
|
520
|
+
};
|
|
418
521
|
const branch = kept.branch || kept.repo?.default_branch || 'main';
|
|
419
522
|
const forge = isForge(kept.repo);
|
|
420
523
|
const hasRepo = Boolean(isForge(kept.repo) || isHub(kept.repo));
|
|
421
524
|
const screen = (to) => () => host.go(path({ kind: 'screen', screen: to }));
|
|
422
525
|
// The composer's pills: where the run goes, which repository, which branch.
|
|
423
|
-
const pills = (_jsxs(_Fragment, { children: [_jsx(TooltipProvider, { delay: 150, children: _jsxs(Tooltip, { placement: "top", offset: 6, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", minW: 0, maxW: "100%", children: _jsx(ChipSelect, { name: t('Where the run runs'), icon: place.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }), label: activePlaceDisplay.title, chosen: placeItems.find((i) => i.place.id ===
|
|
526
|
+
const pills = (_jsxs(_Fragment, { children: [_jsx(TooltipProvider, { delay: 150, children: _jsxs(Tooltip, { placement: "top", offset: 6, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", minW: 0, maxW: "100%", children: _jsx(ChipSelect, { name: t('Where the run runs'), icon: here ? _jsx(Laptop, { size: 13, color: "$soft" }) : place.id ? _jsx(Monitor, { size: 13, color: "$soft" }) : _jsx(Cloud, { size: 13, color: "$soft" }), label: here ? t('This computer') : activePlaceDisplay.title, chosen: placeItems.find((i) => i.place.id === placeId), items: placeItems, onChange: (i) => set({ place: i.place.id }), placeholder: devMode ? t('Search machines…') : t('Search devices…'), placement: "top-start", loading: places.loading, error: places.error?.message ?? null, footer: _jsx(FooterLink, { label: t('Manage…'), onPress: () => host.go(path({ kind: 'settings', section: 'machines' })) }) }) }) }), _jsx(TooltipContent, { maxW: 280, px: "$3", py: "$2", z: "var(--z-popover)", children: _jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { fontFamily: "$body", size: "$1", color: "$ink", children: placeTooltip }), placeHardwareHint ? (_jsx(SizableText, { fontFamily: "$body", size: "$1", color: "$soft", children: placeHardwareHint })) : null] }) })] }) }), here ? (_jsx(ChipSelect, { name: t('Folder'), icon: _jsx(FolderOpen, { size: 13, color: "$soft" }), label: folderAt.folder
|
|
527
|
+
? folderAt.auto
|
|
528
|
+
? t('Auto · {name}', { name: folderAt.folder.name })
|
|
529
|
+
: folderAt.folder.name
|
|
530
|
+
: t('Choose folder…'), chosen: folderItems.find((i) => i.id === (folderAt.auto ? AUTO : folderAt.folder?.path)), items: folderItems, onChange: (i) => set({ folder: i.id === AUTO ? '' : i.id }), placeholder: t('Search folders…'), placement: "top-start", footer: _jsx(FooterLink, { label: t('Choose folder…'), onPress: () => void chooseFolder() }) })) : null, here ? null : (_jsx(RepoSelect, { open: picking, onOpenChange: setPicking, value: isForge(kept.repo) ? { ...kept.repo, source: 'forge' } : isHub(kept.repo) ? { ...kept.repo, source: 'github' } : null, onChange: (r) => {
|
|
424
531
|
const hub = r.github ? hubs.current.get((r.full_name ?? '').toLowerCase()) : undefined;
|
|
425
532
|
setIssue(0);
|
|
426
533
|
if (hub) {
|
|
@@ -447,7 +554,7 @@ export function Landing({ onStarted }) {
|
|
|
447
554
|
name: r.name,
|
|
448
555
|
});
|
|
449
556
|
},
|
|
450
|
-
}, placeholder: t('Repository'), placement: "top-start", disabled: !signed }), forge ? (_jsx(BranchSelect, { open: branching, onOpenChange: setBranching, value: branch, onChange: (b) => set({ branch: b }), load: loadBranches, placement: "top-start" })) : null] }));
|
|
557
|
+
}, placeholder: t('Repository'), placement: "top-start", disabled: !signed })), forge && !here ? (_jsx(BranchSelect, { open: branching, onOpenChange: setBranching, value: branch, onChange: (b) => set({ branch: b }), load: loadBranches, placement: "top-start" })) : null] }));
|
|
451
558
|
const commands = [
|
|
452
559
|
{ id: 'run', label: t('Run'), keys: 'Ctrl+↵', icon: _jsx(Play, { size: 14, color: "$soft" }), disabled: !draft.trim(), run: () => void send() },
|
|
453
560
|
{ id: 'pick-repo', label: t('Link GitHub project…'), icon: _jsx(FolderGit2, { size: 14, color: "$soft" }), run: () => setPicking(true) },
|
|
@@ -496,8 +603,8 @@ export function Landing({ onStarted }) {
|
|
|
496
603
|
id: i.place.id || 'sandbox',
|
|
497
604
|
label: i.label,
|
|
498
605
|
note: i.hint,
|
|
499
|
-
icon: i.place.id ? _jsx(Monitor, { size: 16 }) : _jsx(Cloud, { size: 16 }),
|
|
500
|
-
on: i.place.id ===
|
|
606
|
+
icon: i.place.id === HERE ? _jsx(Laptop, { size: 16 }) : i.place.id ? _jsx(Monitor, { size: 16 }) : _jsx(Cloud, { size: 16 }),
|
|
607
|
+
on: i.place.id === placeId,
|
|
501
608
|
})),
|
|
502
609
|
pick: (id) => set({ place: id === 'sandbox' ? '' : id }),
|
|
503
610
|
loading: places.loading,
|
|
@@ -510,9 +617,9 @@ export function Landing({ onStarted }) {
|
|
|
510
617
|
gridTemplateRows: wide ? 'minmax(24px, 0.76fr) auto auto minmax(48px, 1.24fr)' : 'minmax(0, 1fr) auto', items: "center", "$platform-web": { justifyItems: 'center' }, width: "100%", flex: 1, minH: 0, overflowX: "hidden", "data-slot": "new", children: [wide ? _jsx(YStack, {}) : null, _jsx(YStack, { display: "grid",
|
|
511
618
|
// One track, its question set at the track's foot, just above the composer: a
|
|
512
619
|
// second `auto` track left the question alone in the first, at the pane's top.
|
|
513
|
-
gridTemplateRows: "minmax(0, 1fr)", items: "flex-end", width: "100%", maxW: MEASURE, height: wide ? undefined : '100%', px: "$4", pb: "$5", overflowY: "auto", children: _jsx(SizableText, { render: "h1", fontFamily: "$heading", fontSize: "$7", lineHeight: "$7", fontWeight: "600", letterSpacing: '-0.025em', color: "$ink", text: "center", children: t('Build what’s next.') }) }), _jsx(YStack, { width: "100%", maxW: MEASURE, gap: "$2", pb: "$3", children: _jsxs(YStack, { gap: "$2", children: [env.value && (env.value.state === 'proposed' || unset(env.value)) && !place.id ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", rowGap: "$2", mx: "$3", px: "$3", py: "$2", flexWrap: "wrap", children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, minW: 180, children: env.value.state === 'proposed'
|
|
620
|
+
gridTemplateRows: "minmax(0, 1fr)", items: "flex-end", width: "100%", maxW: MEASURE, height: wide ? undefined : '100%', px: "$4", pb: "$5", overflowY: "auto", children: _jsx(SizableText, { render: "h1", fontFamily: "$heading", fontSize: "$7", lineHeight: "$7", fontWeight: "600", letterSpacing: '-0.025em', color: "$ink", text: "center", children: t('Build what’s next.') }) }), _jsx(YStack, { width: "100%", maxW: MEASURE, gap: "$2", pb: "$3", children: _jsxs(YStack, { gap: "$2", children: [env.value && (env.value.state === 'proposed' || unset(env.value)) && !place.id && !here ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", rowGap: "$2", mx: "$3", px: "$3", py: "$2", flexWrap: "wrap", children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, minW: 180, children: env.value.state === 'proposed'
|
|
514
621
|
? t('A proposed environment for {repo} is waiting for review.', { repo: codebase })
|
|
515
|
-
: t('{repo} has no environment yet, so every run starts it bare.', { repo: codebase }) }), env.value.state === 'proposed' && env.value.session ? (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => host.go(env.value.session), children: t('Review') })) : (_jsx(Button, { size: "sm", variant: "primary", onPress: () => setOffering(true), children: t('Set up environment') }))] })) : null, note ||
|
|
622
|
+
: t('{repo} has no environment yet, so every run starts it bare.', { repo: codebase }) }), env.value.state === 'proposed' && env.value.session ? (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => host.go(env.value.session), children: t('Review') })) : (_jsx(Button, { size: "sm", variant: "primary", onPress: () => setOffering(true), children: t('Set up environment') }))] })) : null, note || refused || mind.note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", px: "$3", children: note || refused || mind.note })) : null, ran ? _jsx(RanHere, { ran: ran }) : null, _jsx(Composer, { column: true, value: draft, onChange: setDraft, onSend: () => void send(), busy: busy, placeholder: t('Ask, build, or run anything…'), label: t('Describe a task or ask a question'), plus: {
|
|
516
623
|
upload: () => pick(files, setFiles, setNote, t),
|
|
517
624
|
research: { on: carry.gear.gear.research, set: (on) => carry.gear.set({ research: on }) },
|
|
518
625
|
skills: carry.skills,
|
package/lib/local.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Say } from '@hanzo/i18n/react';
|
|
2
|
+
/** A folder on this computer, as the host keeps it. */
|
|
3
|
+
export interface Folder {
|
|
4
|
+
/** The absolute path the agent runs in. */
|
|
5
|
+
path: string;
|
|
6
|
+
/** Its last segment, or the name the person gave it. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** When a run last used it (ms since the epoch); 0 when never. */
|
|
9
|
+
used?: number;
|
|
10
|
+
}
|
|
11
|
+
/** What a run on this computer answers with once it has finished. */
|
|
12
|
+
export interface Done {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
/** What the agent printed: its answer and what it changed. */
|
|
15
|
+
output: string;
|
|
16
|
+
}
|
|
17
|
+
/** What a host with the computer can do with its folders. */
|
|
18
|
+
export interface Local {
|
|
19
|
+
/** The folders this computer has opened in Hanzo, in any order (`recent` sorts them). */
|
|
20
|
+
folders: () => readonly Folder[];
|
|
21
|
+
/** The computer's own folder dialog; null when the person closes it. The folder chosen is kept. */
|
|
22
|
+
pick: () => Promise<Folder | null>;
|
|
23
|
+
/** Mark a folder as the one used now, so Auto picks it next. */
|
|
24
|
+
use: (path: string) => void;
|
|
25
|
+
/** Run the coding agent in `folder` with `prompt`, and answer once it has finished. */
|
|
26
|
+
run: (folder: string, prompt: string) => Promise<Done>;
|
|
27
|
+
}
|
|
28
|
+
/** The place id New keeps for this computer. A machine's is `tgt_…` and the cloud workspace's is ''. */
|
|
29
|
+
export declare const HERE = "here";
|
|
30
|
+
/** The folders, most recently used first; a folder never used goes last, in the order the host gave. */
|
|
31
|
+
export declare function recent(folders: readonly Folder[]): Folder[];
|
|
32
|
+
/** The folder Auto picks: the one used most recently, or null when this computer has opened none. */
|
|
33
|
+
export declare function auto(folders: readonly Folder[]): Folder | null;
|
|
34
|
+
/**
|
|
35
|
+
* The folder a run goes to: the one chosen (`kept`, a path), while this computer still lists it, else Auto's.
|
|
36
|
+
* A chosen folder the host no longer lists was removed, and is not where the next run goes.
|
|
37
|
+
*/
|
|
38
|
+
export declare function where(folders: readonly Folder[], kept: string): {
|
|
39
|
+
folder: Folder | null;
|
|
40
|
+
auto: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** A folder's last segment, for a path the host gave no name. */
|
|
43
|
+
export declare function named(path: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Why a run on this computer stopped before it began, in the reader's words: the agent is not installed, or the
|
|
46
|
+
* host refused. What the agent itself printed is its answer, and is shown as it is.
|
|
47
|
+
*/
|
|
48
|
+
export declare function failed(e: unknown, say?: Say): string;
|
|
49
|
+
/** Words New marks for the reader's language (`phrase`), drawn through `t`. */
|
|
50
|
+
export declare const WORDS: {
|
|
51
|
+
readonly here: string;
|
|
52
|
+
readonly auto: string;
|
|
53
|
+
readonly choose: string;
|
|
54
|
+
readonly pick: string;
|
|
55
|
+
};
|
package/lib/local.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working in a folder on this computer, with no repository (hanzo-inc/app issues 309 and 310).
|
|
3
|
+
*
|
|
4
|
+
* A HOST THAT HAS THE COMPUTER says so. Hanzo Desktop can open a folder dialog and run the coding agent in a folder
|
|
5
|
+
* (`dev exec -C <folder>`), so it hands the builder a `Local` (host.tsx); a browser page has no folder of its own and
|
|
6
|
+
* hands none, and New then offers the cloud workspace and the org's machines as before. Nothing here sniffs a user
|
|
7
|
+
* agent: the host says what it has.
|
|
8
|
+
*
|
|
9
|
+
* AUTO IS THE FOLDER USED LAST. A person who chose no folder works in the one they worked in most recently, on this
|
|
10
|
+
* computer; one who never opened any is asked for one, once, on their first send, and that folder is then the one
|
|
11
|
+
* Auto picks. Choosing a folder in the pill keeps it for the next New; choosing Auto again goes back to the most
|
|
12
|
+
* recent. That is the whole rule, so a person can always say where a run will go before they send it.
|
|
13
|
+
*
|
|
14
|
+
* A run on this computer reads, edits and runs in its folder and nowhere else (the agent's workspace-write sandbox),
|
|
15
|
+
* and it needs no repository: a folder that is a git checkout keeps its history, and one that is not stays one.
|
|
16
|
+
*/
|
|
17
|
+
import { phrase } from '@hanzo/i18n';
|
|
18
|
+
import { english } from './say.js';
|
|
19
|
+
/** The place id New keeps for this computer. A machine's is `tgt_…` and the cloud workspace's is ''. */
|
|
20
|
+
export const HERE = 'here';
|
|
21
|
+
/** The folders, most recently used first; a folder never used goes last, in the order the host gave. */
|
|
22
|
+
export function recent(folders) {
|
|
23
|
+
return folders
|
|
24
|
+
.map((f, i) => ({ f, i }))
|
|
25
|
+
.sort((a, b) => (b.f.used ?? 0) - (a.f.used ?? 0) || a.i - b.i)
|
|
26
|
+
.map(({ f }) => f);
|
|
27
|
+
}
|
|
28
|
+
/** The folder Auto picks: the one used most recently, or null when this computer has opened none. */
|
|
29
|
+
export function auto(folders) {
|
|
30
|
+
return recent(folders)[0] ?? null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The folder a run goes to: the one chosen (`kept`, a path), while this computer still lists it, else Auto's.
|
|
34
|
+
* A chosen folder the host no longer lists was removed, and is not where the next run goes.
|
|
35
|
+
*/
|
|
36
|
+
export function where(folders, kept) {
|
|
37
|
+
const chosen = kept ? folders.find((f) => f.path === kept) : undefined;
|
|
38
|
+
if (chosen)
|
|
39
|
+
return { folder: chosen, auto: false };
|
|
40
|
+
return { folder: auto(folders), auto: true };
|
|
41
|
+
}
|
|
42
|
+
/** A folder's last segment, for a path the host gave no name. */
|
|
43
|
+
export function named(path) {
|
|
44
|
+
return path.replace(/[/\\]+$/, '').split(/[/\\]/).pop() || path;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Why a run on this computer stopped before it began, in the reader's words: the agent is not installed, or the
|
|
48
|
+
* host refused. What the agent itself printed is its answer, and is shown as it is.
|
|
49
|
+
*/
|
|
50
|
+
export function failed(e, say = english) {
|
|
51
|
+
const why = e instanceof Error ? e.message : typeof e === 'string' ? e : '';
|
|
52
|
+
if (/failed to invoke dev|no such file|not found|os error 2|cannot find/i.test(why)) {
|
|
53
|
+
return say('The Hanzo Dev agent is not installed on this computer. Install it with `npm install -g @hanzo/dev`, then send again.');
|
|
54
|
+
}
|
|
55
|
+
return why ? say('The run on this computer could not start: {why}', { why }) : say('The run on this computer could not start. Try again.');
|
|
56
|
+
}
|
|
57
|
+
/** Words New marks for the reader's language (`phrase`), drawn through `t`. */
|
|
58
|
+
export const WORDS = {
|
|
59
|
+
here: phrase('This computer'),
|
|
60
|
+
auto: phrase('Auto'),
|
|
61
|
+
choose: phrase('Choose folder…'),
|
|
62
|
+
pick: phrase('Choose a folder for this run'),
|
|
63
|
+
};
|
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.",
|