@fungi.computer/bonsai 0.6.3 → 0.6.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @fungi.computer/bonsai
2
2
 
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Changes since 0.6.3:
8
+
9
+ - fix(bonsai): the copied clone command works as pasted without an exported
10
+ key
11
+
12
+ - Updated dependencies
13
+ - @fungi.computer/oyster@0.19.1
14
+
3
15
  ## 0.6.3
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/bonsai",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "type": "module",
6
6
  "description": "Bonsai: a git platform for many agents working at once, on Workers and Artifacts",
@@ -8,7 +8,7 @@
8
8
  "@fungi.computer/agar": "0.9.0",
9
9
  "@fungi.computer/caps": "0.10.1",
10
10
  "@fungi.computer/issues": "0.2.0",
11
- "@fungi.computer/oyster": "0.19.0",
11
+ "@fungi.computer/oyster": "0.19.1",
12
12
  "@fungi.computer/puffball": "0.5.5",
13
13
  "@fungi.computer/sigils": "0.3.0",
14
14
  "@fungi.computer/stipe": "0.1.1",
@@ -1,14 +1,21 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { gitCommands } from "../web/git-commands.js";
3
3
 
4
+ const url = "http://127.0.0.1:29800/git/bonsai/koi-pond.git";
5
+
4
6
  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
+ it("clones as pasted: the helper reads the saved key and the key is not in the line", () => {
8
+ const { clone } = gitCommands(url, "main");
9
+ expect(clone).toContain("credential.helper=");
10
+ expect(clone).toContain("${OYSTER_OWNER_KEY:-$(cat .oyster-owner)}");
11
+ expect(clone.endsWith(`clone ${url}`)).toBe(true);
12
+ expect(clone).not.toContain("http.extraHeader");
13
+ });
14
+
15
+ it("pushes with the key exported once in the shell", () => {
7
16
  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");
17
+ expect(commands.key).toBe("export OYSTER_OWNER_KEY=$(cat .oyster-owner)");
18
+ expect(commands.push).toContain('echo "password=$OYSTER_OWNER_KEY"');
19
+ expect(commands.push.endsWith(`push ${url} HEAD:main`)).toBe(true);
13
20
  });
14
21
  });
@@ -1,23 +1,30 @@
1
1
  /** Commands a person can paste into a shell to reach one Bonsai repository. */
2
2
 
3
3
  export type GitCommands = {
4
- /** Sets the owner key the Git door checks; run once in the folder Oyster started from. */
4
+ /** Puts the owner key in this shell, for pushing from a project folder. */
5
5
  key: string;
6
+ /** Works as pasted in the folder where Oyster was started. */
6
7
  clone: string;
8
+ /** Works once `key` has been run in the same shell. */
7
9
  push: string;
8
10
  };
9
11
 
10
- const authedGit =
11
- 'git -c http.extraHeader="Authorization: Bearer $OYSTER_OWNER_KEY"';
12
-
13
12
  /**
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.
13
+ * A credential helper hands the key to Git's own Basic-auth challenge, which the
14
+ * Git door already answers. The key is read inside the helper, so it is never in
15
+ * the command line, the shell history or the process list. `.oyster-owner` is
16
+ * where `oyster try` saves it; an exported OYSTER_OWNER_KEY wins, for a
17
+ * deployed Oyster.
16
18
  */
19
+ function helper(key: string): string {
20
+ return `git -c credential.helper='!f() { echo username=oyster; echo "password=${key}"; }; f'`;
21
+ }
22
+
23
+ /** Copy-ready commands; the clone URL is the one the host produced for this Oyster. */
17
24
  export function gitCommands(cloneUrl: string, branch: string): GitCommands {
18
25
  return {
19
26
  key: "export OYSTER_OWNER_KEY=$(cat .oyster-owner)",
20
- clone: `${authedGit} clone ${cloneUrl}`,
21
- push: `${authedGit} push ${cloneUrl} HEAD:${branch}`,
27
+ clone: `${helper("${OYSTER_OWNER_KEY:-$(cat .oyster-owner)}")} clone ${cloneUrl}`,
28
+ push: `${helper("$OYSTER_OWNER_KEY")} push ${cloneUrl} HEAD:${branch}`,
22
29
  };
23
30
  }
@@ -9,22 +9,22 @@ export function QuickSetup({ detail }: { detail: RepoDetail }) {
9
9
  <div className="space-y-6" aria-label="Quick setup">
10
10
  <p>This repository is empty. Push your code to start it.</p>
11
11
  <section className="space-y-2">
12
- <h3 className="text-sm font-semibold">1. Use your owner key</h3>
12
+ <h3 className="text-sm font-semibold">Clone it</h3>
13
13
  <p className="text-sm">
14
14
  Run this in the folder where you started Oyster. On a deployed Oyster,
15
- use the owner key you saved at setup.
15
+ set OYSTER_OWNER_KEY to the owner key you saved at setup first.
16
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
17
  <CopyField value={commands.clone} />
22
18
  </section>
23
19
  <section className="space-y-2">
24
20
  <h3 className="text-sm font-semibold">
25
21
  Or push a project you already have
26
22
  </h3>
27
- <p className="text-sm">Run this inside that project.</p>
23
+ <p className="text-sm">
24
+ First run this in the folder where you started Oyster, then push from
25
+ your project in the same terminal.
26
+ </p>
27
+ <CopyField value={commands.key} />
28
28
  <CopyField value={commands.push} />
29
29
  </section>
30
30
  </div>