Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ jobs:
cd "out/$TAG"
for f in gild-*; do shasum -a 256 "$f" | cut -d' ' -f1 > "$f.sha"; done
jq -n --arg version "$VERSION" --arg tag "$TAG" \
--arg arm64 "$(cat gild-darwin-arm64.sha)" --arg x64 "$(cat gild-darwin-x64.sha)" --arg linux "$(cat gild-linux-x64.sha)" \
'{version: $version, tag: $tag, artifacts: {"gild-darwin-arm64": $arm64, "gild-darwin-x64": $x64, "gild-linux-x64": $linux}}' > manifest.json
--arg arm64 "$(cat gild-darwin-arm64.sha)" --arg x64 "$(cat gild-darwin-x64.sha)" --arg linux "$(cat gild-linux-x64.sha)" --arg linuxarm64 "$(cat gild-linux-arm64.sha)" \
'{version: $version, tag: $tag, artifacts: {"gild-darwin-arm64": $arm64, "gild-darwin-x64": $x64, "gild-linux-x64": $linux, "gild-linux-arm64": $linuxarm64}}' > manifest.json
rm -f *.sha
jq -n --arg version "$VERSION" --arg tag "$TAG" '{version: $version, tag: $tag}' > latest.json
cp latest.json "../latest.json"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.6.13

- `gild spawn --vm` works on Apple silicon: gild publishes a linux-arm64 build (`@gildforge/cli-linux-arm64`, with its node-pty prebuild), so the agent inside the arm64 Multipass VM has its own `gild` for git credentials and pull requests. Before, every `gild` call in that VM failed with "no build for linux-arm64".
- Multipass VM: a connection refused with "No route to host" is retried briefly, then reported with the fix (on macOS: allow Multipass in System Settings → Privacy & Security → Local Network) instead of being mistaken for an unfinished VM setup. `gild spawn --detach --vm` returns once the agent has started in the VM, so closing the terminal or SSH session right after no longer kills the session before it starts.
- `gild spawn --vm ./agent.sh` runs the script from the copied working directory; a program inside the working directory was looked up by name on the VM's PATH and never started.

## 0.6.12

- `gild setup` sets up your own gild in your Cloudflare account from a terminal (the same steps as gild desktop): it asks for the API token (not saved), the account, your name and email, and makes your gild key the owner. Running it again upgrades in place.
Expand Down
7 changes: 6 additions & 1 deletion PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Publishing to npm

Names: `gildforge` (umbrella CLI) + `@gildforge/cli-{darwin-arm64,darwin-x64,linux-x64}`
Names: `gildforge` (umbrella CLI) + `@gildforge/cli-{darwin-arm64,darwin-x64,linux-x64,linux-arm64}`
(binaries). The `@gildforge/server[-*]` packages publish from gildforge/server,
not here.

A new platform package (`@gildforge/cli-linux-arm64` from 0.6.13) must exist on
npm and have the trusted publisher (gildforge/cli, `release.yml`, environment
`release`) set before the Release workflow can publish it: publish its first
version by hand, then add the trusted publisher in its npm settings.

```sh
npm login

Expand Down
1 change: 1 addition & 0 deletions scripts/node-pty.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"prebuilds/darwin-arm64/spawn-helper": "08bc83a084651d095645010d34783f94b9af443614747e953e66d6578027e999",
"prebuilds/darwin-x64/pty.node": "811f4a357e260fc0e520c250a3de5990483761d82afd635effbdf4b793b8a0e9",
"prebuilds/darwin-x64/spawn-helper": "a3bed36ae3ed83b2ac2fce475bd578c51f5b536041f0b2dfe116987f565e9758",
"prebuilds/linux-arm64/pty.node": "5a3b8930d62535edabec2eac79fe8eca70a178d93fbb76b1ae875dd60ee8f825",
"prebuilds/linux-x64/pty.node": "123792d8f22f36d519b21dfb6f4b716f9b18b9e579085ea2840d0773d88d35fd"
}
}
11 changes: 10 additions & 1 deletion scripts/pack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// packages/gild-darwin-arm64 — the compiled binary per platform
// packages/gild-darwin-x64
// packages/gild-linux-x64
// packages/gild-linux-arm64 — the CLI inside an arm64 Linux VM (Multipass on Apple silicon)
// No postinstall anywhere: npm's optionalDependencies + os/cpu fields pick the
// right package, and the launcher just execs the binary it finds.
import {
Expand All @@ -26,6 +27,14 @@ const TARGETS = [
},
{ name: 'cli-darwin-x64', bun: 'bun-darwin-x64', os: 'darwin', cpu: 'x64' },
{ name: 'cli-linux-x64', bun: 'bun-linux-x64', os: 'linux', cpu: 'x64' },
// No gild-server build for linux-arm64 yet: no server optionalDependency.
{
name: 'cli-linux-arm64',
bun: 'bun-linux-arm64',
os: 'linux',
cpu: 'arm64',
server: false,
},
]

rmSync(join(ROOT, 'packages'), { recursive: true, force: true })
Expand Down Expand Up @@ -136,7 +145,7 @@ writeFileSync(
TARGETS.map((t) => [`@gildforge/${t.name}`, pkg.version]),
),
...Object.fromEntries(
TARGETS.map((t) => [
TARGETS.filter((t) => t.server !== false).map((t) => [
`@gildforge/server-${t.name.replace('cli-', '')}`,
'*',
]),
Expand Down
87 changes: 87 additions & 0 deletions src/isolation/multipass.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { describe, expect, test } from 'bun:test'
import { join } from 'node:path'
import {
guestProgram,
noRoute,
noRouteError,
readiness,
retryNoRoute,
} from './multipass'

const NO_ROUTE =
"exec failed: ssh connection failed: 'Failed to connect: No route to host'\n"

describe('guestProgram', () => {
const cwd = '/Users/me/work'
test('a script inside the working directory runs by its relative path', () => {
expect(guestProgram(join(cwd, 'agent.sh'), cwd)).toBe('./agent.sh')
expect(guestProgram(join(cwd, 'bin', 'run'), cwd)).toBe('./bin/run')
})
test('a program from PATH runs by name from the VM PATH', () => {
expect(guestProgram('/opt/homebrew/bin/claude', cwd)).toBe('claude')
expect(guestProgram('/bin/sh', cwd)).toBe('sh')
})
test('a sibling directory with the same prefix is not inside', () => {
expect(guestProgram('/Users/me/work2/agent.sh', cwd)).toBe('agent.sh')
expect(guestProgram('/Users/me/agent.sh', cwd)).toBe('agent.sh')
})
})

describe('No route to host', () => {
test('is recognised in Multipass output', () => {
expect(noRoute(NO_ROUTE)).toBe(true)
expect(noRoute('exec failed: instance "gild" is not running')).toBe(false)
})
test('on macOS the error names the Local Network setting', () => {
const message = noRouteError('darwin').message
expect(message).toContain('No route to host')
expect(message).toContain(
'System Settings → Privacy & Security → Local Network',
)
})
test('is retried, then returned when it persists', () => {
let calls = 0
const slept: number[] = []
const r = retryNoRoute(
() => (calls++, { status: 2, stdout: '', stderr: NO_ROUTE }),
{ tries: 3, delayMs: 7, sleep: (ms) => slept.push(ms) },
)
expect(calls).toBe(3)
expect(slept).toEqual([7, 7])
expect(r.status).toBe(2)
})
test('a retry that connects returns its result', () => {
const results = [
{ status: 2, stdout: '', stderr: NO_ROUTE },
{ status: 0, stdout: 'ready\n', stderr: '' },
]
let calls = 0
const r = retryNoRoute(() => results[calls++], { sleep: () => {} })
expect(calls).toBe(2)
expect(r.stdout).toBe('ready\n')
})
test('other failures are not retried', () => {
let calls = 0
retryNoRoute(() => (calls++, { status: 1, stdout: '', stderr: 'nope' }), {
sleep: () => {},
})
expect(calls).toBe(1)
})
})

describe('readiness', () => {
test('only the marker answer decides set up or not', () => {
expect(readiness({ status: 0, stdout: 'ready\n', stderr: '' })).toBe(true)
expect(readiness({ status: 0, stdout: 'missing\n', stderr: '' })).toBe(
false,
)
})
test('an unreachable VM is an error, not "not set up yet"', () => {
expect(() =>
readiness({ status: 2, stdout: '', stderr: NO_ROUTE }),
).toThrow('No route to host')
expect(() =>
readiness({ status: 2, stdout: '', stderr: 'exec failed: boom' }),
).toThrow('checking the gild VM: exec failed: boom')
})
})
Loading
Loading