@fungi.computer/bonsai 0.5.2 → 0.6.0
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/CHANGELOG.md +12 -1
- package/package.json +1 -1
- package/test/browser/capture.browser.mjs +4 -2
- package/test/git-commands.test.ts +14 -0
- package/test/home-page.test.ts +9 -2
- package/web/bonsai.css +41 -0
- package/web/code-tab.tsx +2 -9
- package/web/git-commands.ts +23 -0
- package/web/home-page.tsx +67 -12
- package/web/new-repository.tsx +4 -1
- package/web/overview.tsx +2 -11
- package/web/quick-setup.tsx +32 -0
- package/web/repo-navigation.tsx +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# @fungi.computer/bonsai
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Changes since 0.5.1:
|
|
8
|
+
|
|
9
|
+
- feat(bonsai): the empty home suggests names and shows what happens next
|
|
10
|
+
- fix(bonsai): use the host clone url and copy the working command from the
|
|
11
|
+
header
|
|
12
|
+
- fix(bonsai): keep the clone header a plain URL and tighten Quick setup
|
|
13
|
+
headings
|
|
14
|
+
- fix(bonsai): clone and push commands work as copied
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
6
17
|
|
package/package.json
CHANGED
|
@@ -26,8 +26,10 @@ try {
|
|
|
26
26
|
await page.goto(`${origin}/test/browser/visual.html?tab=changes&scene5`);
|
|
27
27
|
await page.locator('[data-tile="changes"]').waitFor();
|
|
28
28
|
assert.equal(
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
(
|
|
30
|
+
await page.locator(".caps-copy-field code").first().textContent()
|
|
31
|
+
).endsWith("https://oyster.shiit.app/git/bonsai/koi-pond.git"),
|
|
32
|
+
true,
|
|
31
33
|
"capture serves this branch's scene5 fixture",
|
|
32
34
|
);
|
|
33
35
|
await page.evaluate(() => globalThis.document.fonts.ready);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { gitCommands } from "../web/git-commands.js";
|
|
3
|
+
|
|
4
|
+
describe("git commands", () => {
|
|
5
|
+
it("carries the credential in the clone and push lines, on the host's URL", () => {
|
|
6
|
+
const url = "http://127.0.0.1:29800/git/bonsai/koi-pond.git";
|
|
7
|
+
const commands = gitCommands(url, "main");
|
|
8
|
+
expect(commands.clone).toBe(
|
|
9
|
+
`git -c http.extraHeader="Authorization: Bearer $OYSTER_OWNER_KEY" clone ${url}`,
|
|
10
|
+
);
|
|
11
|
+
expect(commands.push).toContain(`push ${url} HEAD:main`);
|
|
12
|
+
expect(commands.push).toContain("http.extraHeader");
|
|
13
|
+
});
|
|
14
|
+
});
|
package/test/home-page.test.ts
CHANGED
|
@@ -165,7 +165,7 @@ describe("Bonsai home page", () => {
|
|
|
165
165
|
[...container.querySelectorAll("h2")].map(
|
|
166
166
|
(heading) => heading.textContent,
|
|
167
167
|
),
|
|
168
|
-
).toEqual(["Start your first repository"]);
|
|
168
|
+
).toEqual(["Start your first repository", "What happens next"]);
|
|
169
169
|
expect(container.textContent).toContain(
|
|
170
170
|
"Every Agent gets its own fork; watch them merge back here.",
|
|
171
171
|
);
|
|
@@ -174,6 +174,12 @@ describe("Bonsai home page", () => {
|
|
|
174
174
|
(button) => button.textContent === "New repository",
|
|
175
175
|
),
|
|
176
176
|
).toHaveLength(1);
|
|
177
|
+
expect(
|
|
178
|
+
[...container.querySelectorAll("ul[aria-label] button")].map(
|
|
179
|
+
(button) => button.textContent,
|
|
180
|
+
),
|
|
181
|
+
).toEqual(["notes", "website", "experiments"]);
|
|
182
|
+
expect(container.textContent).toContain("What happens next");
|
|
177
183
|
expect(container.textContent).not.toContain("Loading repositories");
|
|
178
184
|
});
|
|
179
185
|
|
|
@@ -230,7 +236,8 @@ describe("Bonsai home page", () => {
|
|
|
230
236
|
git: ["git.repository"],
|
|
231
237
|
events: ["app.events.emit"],
|
|
232
238
|
});
|
|
233
|
-
expect(labels()).
|
|
239
|
+
expect(labels()[0]).toBe("New repository");
|
|
240
|
+
expect(container.textContent).not.toContain("Approve Git access");
|
|
234
241
|
});
|
|
235
242
|
|
|
236
243
|
it("shows no Live activity before the first repository exists", async () => {
|
package/web/bonsai.css
CHANGED
|
@@ -645,3 +645,44 @@ body {
|
|
|
645
645
|
animation: none;
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
|
+
|
|
649
|
+
/* The empty home's three steps: a row on wide screens, a stack on phones. */
|
|
650
|
+
.bonsai-next-steps {
|
|
651
|
+
display: grid;
|
|
652
|
+
gap: var(--spacing-md);
|
|
653
|
+
margin-block-start: var(--spacing-xl);
|
|
654
|
+
}
|
|
655
|
+
.bonsai-next-steps ol {
|
|
656
|
+
display: grid;
|
|
657
|
+
gap: var(--spacing-lg);
|
|
658
|
+
margin: 0;
|
|
659
|
+
padding: 0;
|
|
660
|
+
list-style: none;
|
|
661
|
+
}
|
|
662
|
+
@media (min-width: 720px) {
|
|
663
|
+
.bonsai-next-steps ol {
|
|
664
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
.bonsai-next-steps li {
|
|
668
|
+
display: flex;
|
|
669
|
+
gap: var(--spacing-sm);
|
|
670
|
+
align-items: flex-start;
|
|
671
|
+
}
|
|
672
|
+
.bonsai-next-steps li > span {
|
|
673
|
+
display: inline-grid;
|
|
674
|
+
flex: none;
|
|
675
|
+
place-items: center;
|
|
676
|
+
width: 1.5rem;
|
|
677
|
+
height: 1.5rem;
|
|
678
|
+
border: 1px solid var(--stipe-hairline);
|
|
679
|
+
border-radius: 999px;
|
|
680
|
+
color: var(--stipe-fg-muted);
|
|
681
|
+
font-size: var(--text-xs);
|
|
682
|
+
}
|
|
683
|
+
.bonsai-next-steps p {
|
|
684
|
+
margin: 0;
|
|
685
|
+
}
|
|
686
|
+
.bonsai-next-steps li p + p {
|
|
687
|
+
color: var(--stipe-fg-muted);
|
|
688
|
+
}
|
package/web/code-tab.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { Button } from "@fungi.computer/caps/components/button";
|
|
3
3
|
import { CopyField } from "@fungi.computer/caps/components/copy-field";
|
|
4
4
|
import { Disclosure } from "@fungi.computer/caps/components/disclosure";
|
|
5
|
-
import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
|
|
6
5
|
import { fileSyncResult } from "@fungi.computer/agar/roles/files";
|
|
7
6
|
import { editInFilesEditor, callMethod } from "./transport.js";
|
|
8
7
|
import type { RepoDetail } from "../shared/contract.js";
|
|
@@ -10,6 +9,7 @@ import { useFiles, useFile, useFilesEditor } from "./api.js";
|
|
|
10
9
|
import { BonsaiBoard } from "./board.js";
|
|
11
10
|
import { firstLine, formatBytes, relativeTime, shortHash } from "./format.js";
|
|
12
11
|
import { Loading, Failure } from "./parts.js";
|
|
12
|
+
import { QuickSetup } from "./quick-setup.js";
|
|
13
13
|
import { href, Link, useRouter, type Route } from "./router.js";
|
|
14
14
|
import { FileView, Markdown, RepoTree } from "./views.js";
|
|
15
15
|
|
|
@@ -51,14 +51,7 @@ export function CodeTab({
|
|
|
51
51
|
const shown = route.file ?? readme;
|
|
52
52
|
const file = useFile(route.repo, ref, shown);
|
|
53
53
|
const shownText = file.data?.pending?.text ?? file.data?.text ?? null;
|
|
54
|
-
if (detail.empty)
|
|
55
|
-
return (
|
|
56
|
-
<EmptyState
|
|
57
|
-
variant="panel"
|
|
58
|
-
title="Empty repository"
|
|
59
|
-
description={`Push a first commit: git push ${detail.cloneUrl} main`}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
54
|
+
if (detail.empty) return <QuickSetup detail={detail} />;
|
|
62
55
|
const tree = files.isPending ? (
|
|
63
56
|
<Loading label="Loading files" />
|
|
64
57
|
) : files.isError ? (
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Commands a person can paste into a shell to reach one Bonsai repository. */
|
|
2
|
+
|
|
3
|
+
export type GitCommands = {
|
|
4
|
+
/** Sets the owner key the Git door checks; run once in the folder Oyster started from. */
|
|
5
|
+
key: string;
|
|
6
|
+
clone: string;
|
|
7
|
+
push: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const authedGit =
|
|
11
|
+
'git -c http.extraHeader="Authorization: Bearer $OYSTER_OWNER_KEY"';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Copy-ready commands that carry the credential the Git door requires. The
|
|
15
|
+
* clone URL is the one the host produced for this Oyster.
|
|
16
|
+
*/
|
|
17
|
+
export function gitCommands(cloneUrl: string, branch: string): GitCommands {
|
|
18
|
+
return {
|
|
19
|
+
key: "export OYSTER_OWNER_KEY=$(cat .oyster-owner)",
|
|
20
|
+
clone: `${authedGit} clone ${cloneUrl}`,
|
|
21
|
+
push: `${authedGit} push ${cloneUrl} HEAD:${branch}`,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/web/home-page.tsx
CHANGED
|
@@ -94,6 +94,38 @@ function HomeNetwork({
|
|
|
94
94
|
/>
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
|
+
const nextSteps = [
|
|
98
|
+
[
|
|
99
|
+
"Create a repository",
|
|
100
|
+
"Name it. Bonsai commits a README so it has content.",
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
"Agents fork it",
|
|
104
|
+
"Each Agent works on its own fork and never touches main.",
|
|
105
|
+
],
|
|
106
|
+
["You merge", "Review a change, merge it, and watch the network graph grow."],
|
|
107
|
+
] as const;
|
|
108
|
+
|
|
109
|
+
/** What happens after the first repository, so the empty state shows its product. */
|
|
110
|
+
function NextSteps() {
|
|
111
|
+
return (
|
|
112
|
+
<section aria-label="What happens next" className="bonsai-next-steps">
|
|
113
|
+
<h2 className="text-sm font-semibold">What happens next</h2>
|
|
114
|
+
<ol>
|
|
115
|
+
{nextSteps.map(([title, text], index) => (
|
|
116
|
+
<li key={title}>
|
|
117
|
+
<span aria-hidden="true">{index + 1}</span>
|
|
118
|
+
<div>
|
|
119
|
+
<p className="font-semibold">{title}</p>
|
|
120
|
+
<p className="text-sm">{text}</p>
|
|
121
|
+
</div>
|
|
122
|
+
</li>
|
|
123
|
+
))}
|
|
124
|
+
</ol>
|
|
125
|
+
</section>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
97
129
|
/** The card's facts, saying only what is true of this repository. */
|
|
98
130
|
function repoMeta(repo: RepoSummary, openChanges: number): string {
|
|
99
131
|
const forks = repo.forks.length;
|
|
@@ -146,6 +178,15 @@ function RepoCard({
|
|
|
146
178
|
export function HomePage({ live }: { live: LiveState }) {
|
|
147
179
|
const [wide, setWide] = useState(false);
|
|
148
180
|
const [creating, setCreating] = useState(false);
|
|
181
|
+
// A suggested name from the empty state; each choice restarts the dialog.
|
|
182
|
+
const [preset, setPreset] = useState<{ name: string; count: number }>({
|
|
183
|
+
name: "",
|
|
184
|
+
count: 0,
|
|
185
|
+
});
|
|
186
|
+
const startWith = (name: string) => {
|
|
187
|
+
setPreset((current) => ({ name, count: current.count + 1 }));
|
|
188
|
+
setCreating(true);
|
|
189
|
+
};
|
|
149
190
|
const [asking, setAsking] = useState(false);
|
|
150
191
|
const hostGit = useHostGitAccess();
|
|
151
192
|
const [approved, setApproved] = useState(false);
|
|
@@ -312,17 +353,26 @@ export function HomePage({ live }: { live: LiveState }) {
|
|
|
312
353
|
waitingFor="your answer"
|
|
313
354
|
/>
|
|
314
355
|
) : (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
356
|
+
<>
|
|
357
|
+
<EmptyState
|
|
358
|
+
variant="panel"
|
|
359
|
+
title="Start your first repository"
|
|
360
|
+
description="Every Agent gets its own fork; watch them merge back here."
|
|
361
|
+
primaryAction={{
|
|
362
|
+
label: "New repository",
|
|
363
|
+
onSelect: () => {
|
|
364
|
+
startWith("");
|
|
365
|
+
},
|
|
366
|
+
}}
|
|
367
|
+
suggestions={["notes", "website", "experiments"].map((label) => ({
|
|
368
|
+
label,
|
|
369
|
+
onSelect: () => {
|
|
370
|
+
startWith(label);
|
|
371
|
+
},
|
|
372
|
+
}))}
|
|
373
|
+
/>
|
|
374
|
+
<NextSteps />
|
|
375
|
+
</>
|
|
326
376
|
)
|
|
327
377
|
) : (
|
|
328
378
|
<div className="flex items-center justify-between gap-3">
|
|
@@ -340,7 +390,12 @@ export function HomePage({ live }: { live: LiveState }) {
|
|
|
340
390
|
</Button>
|
|
341
391
|
</div>
|
|
342
392
|
)}
|
|
343
|
-
<NewRepositoryDialog
|
|
393
|
+
<NewRepositoryDialog
|
|
394
|
+
key={preset.count}
|
|
395
|
+
open={creating}
|
|
396
|
+
onOpenChange={setCreating}
|
|
397
|
+
initialName={preset.name}
|
|
398
|
+
/>
|
|
344
399
|
<BonsaiBoard
|
|
345
400
|
rowHeight={0}
|
|
346
401
|
placements={placements}
|
package/web/new-repository.tsx
CHANGED
|
@@ -23,13 +23,16 @@ import { isPermissionDenied, requestGitAccess } from "./transport.js";
|
|
|
23
23
|
export function NewRepositoryDialog({
|
|
24
24
|
open,
|
|
25
25
|
onOpenChange,
|
|
26
|
+
initialName = "",
|
|
26
27
|
}: {
|
|
27
28
|
open: boolean;
|
|
28
29
|
onOpenChange: (open: boolean) => void;
|
|
30
|
+
/** A suggested name to start from, chosen from the empty state. */
|
|
31
|
+
initialName?: string;
|
|
29
32
|
}) {
|
|
30
33
|
const client = useQueryClient();
|
|
31
34
|
const { go } = useRouter();
|
|
32
|
-
const [name, setName] = useState(
|
|
35
|
+
const [name, setName] = useState(initialName);
|
|
33
36
|
const [readme, setReadme] = useState(true);
|
|
34
37
|
const [touched, setTouched] = useState(false);
|
|
35
38
|
const [creating, setCreating] = useState(false);
|
package/web/overview.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
|
|
3
|
-
import { CopyField } from "@fungi.computer/caps/components/copy-field";
|
|
4
3
|
import {
|
|
5
4
|
DataList,
|
|
6
5
|
DataListHeading,
|
|
@@ -25,6 +24,7 @@ import { NetworkGraph } from "./network-graph.js";
|
|
|
25
24
|
import { ActivityFeed, Failure, Loading, type AgentColors } from "./parts.js";
|
|
26
25
|
import { WorkingNow, workingNow } from "./working-now.js";
|
|
27
26
|
import { ChangeGroups } from "./change-rows.js";
|
|
27
|
+
import { QuickSetup } from "./quick-setup.js";
|
|
28
28
|
import { Markdown } from "./views.js";
|
|
29
29
|
import { href, Link, useRouter, type Route } from "./router.js";
|
|
30
30
|
import type { BoardTile } from "./board.js";
|
|
@@ -80,16 +80,7 @@ export function Overview({
|
|
|
80
80
|
tab: Extract<Route, { page: "repo" }>["tab"],
|
|
81
81
|
file: string | null = null,
|
|
82
82
|
) => href({ ...route, tab, file, path: "" });
|
|
83
|
-
if (detail.empty)
|
|
84
|
-
return (
|
|
85
|
-
<div className="space-y-3">
|
|
86
|
-
<p>
|
|
87
|
-
Push a first commit to start this repository. Add a README to
|
|
88
|
-
introduce the project.
|
|
89
|
-
</p>
|
|
90
|
-
<CopyField value={`git clone ${detail.cloneUrl}`} />
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
83
|
+
if (detail.empty) return <QuickSetup detail={detail} />;
|
|
93
84
|
const tiles: BoardTile[] = [];
|
|
94
85
|
const add = (
|
|
95
86
|
id: TileId,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CopyField } from "@fungi.computer/caps/components/copy-field";
|
|
2
|
+
import type { RepoDetail } from "../shared/contract.js";
|
|
3
|
+
import { gitCommands } from "./git-commands.js";
|
|
4
|
+
|
|
5
|
+
/** GitHub-style Quick setup for an empty repository: every line works as copied. */
|
|
6
|
+
export function QuickSetup({ detail }: { detail: RepoDetail }) {
|
|
7
|
+
const commands = gitCommands(detail.cloneUrl, detail.defaultBranch);
|
|
8
|
+
return (
|
|
9
|
+
<div className="space-y-6" aria-label="Quick setup">
|
|
10
|
+
<p>This repository is empty. Push your code to start it.</p>
|
|
11
|
+
<section className="space-y-2">
|
|
12
|
+
<h3 className="text-sm font-semibold">1. Use your owner key</h3>
|
|
13
|
+
<p className="text-sm">
|
|
14
|
+
Run this in the folder where you started Oyster. On a deployed Oyster,
|
|
15
|
+
use the owner key you saved at setup.
|
|
16
|
+
</p>
|
|
17
|
+
<CopyField value={commands.key} />
|
|
18
|
+
</section>
|
|
19
|
+
<section className="space-y-2">
|
|
20
|
+
<h3 className="text-sm font-semibold">2. Start from this repository</h3>
|
|
21
|
+
<CopyField value={commands.clone} />
|
|
22
|
+
</section>
|
|
23
|
+
<section className="space-y-2">
|
|
24
|
+
<h3 className="text-sm font-semibold">
|
|
25
|
+
Or push a project you already have
|
|
26
|
+
</h3>
|
|
27
|
+
<p className="text-sm">Run this inside that project.</p>
|
|
28
|
+
<CopyField value={commands.push} />
|
|
29
|
+
</section>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
package/web/repo-navigation.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "@fungi.computer/caps/components/popover";
|
|
11
11
|
import { Select } from "@fungi.computer/caps/components/select";
|
|
12
12
|
import { inspectIssueTree } from "@fungi.computer/issues";
|
|
13
|
+
import { gitCommands } from "./git-commands.js";
|
|
13
14
|
import type { RepoDetail } from "../shared/contract.js";
|
|
14
15
|
import { useIssueFiles } from "./api.js";
|
|
15
16
|
import { href, Link, useRouter, type Route } from "./router.js";
|
|
@@ -53,6 +54,7 @@ export function RepoNavigation({
|
|
|
53
54
|
const anchor = useRef<HTMLDivElement>(null);
|
|
54
55
|
const cloneButton = useRef<HTMLButtonElement>(null);
|
|
55
56
|
const refName = route.ref ?? detail.defaultBranch;
|
|
57
|
+
const clone = gitCommands(detail.cloneUrl, detail.defaultBranch).clone;
|
|
56
58
|
const navigate = (tab: Extract<Route, { page: "repo" }>["tab"]) => {
|
|
57
59
|
go(href({ ...route, tab, file: null, path: "" }));
|
|
58
60
|
};
|
|
@@ -189,7 +191,7 @@ export function RepoNavigation({
|
|
|
189
191
|
</Select>
|
|
190
192
|
</div>
|
|
191
193
|
<div className="hidden max-w-sm md:block" ref={desktopClone}>
|
|
192
|
-
<CopyField value={
|
|
194
|
+
<CopyField value={clone} label="Clone" />
|
|
193
195
|
</div>
|
|
194
196
|
<PopoverAnchor className="md:hidden" ref={anchor}>
|
|
195
197
|
<Button
|
|
@@ -213,7 +215,7 @@ export function RepoNavigation({
|
|
|
213
215
|
aria-label="Clone repository"
|
|
214
216
|
>
|
|
215
217
|
<div ref={phoneClone}>
|
|
216
|
-
<CopyField value={
|
|
218
|
+
<CopyField value={clone} />
|
|
217
219
|
</div>
|
|
218
220
|
</Popover>
|
|
219
221
|
</PopoverAnchor>
|