Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(store): recognize updates after the official repository rename (#223)

Dee49b2fa3f995c
diff --git a/cli/src/dsh/update.spec.ts b/cli/src/dsh/update.spec.ts
index a7005ed70..1a0c7a359 100644
--- a/cli/src/dsh/update.spec.ts
+++ b/cli/src/dsh/update.spec.ts
@@ -8,7 +8,7 @@ import { env } from '../config/env.js'
import { dshInstallDir, installedDsh, invalidateInstalledDsh, readInstalledIndex, upsertInstalledRecord } from './installed.js'
import { installDsh, removeDsh, type DshInstallProgress } from './install.js'
import { materializeWorkspace } from './materialize.js'
-import { dshUpdateInfo } from './updates.js'
+import { dshUpdateInfo, samePackageSource } from './updates.js'
import { type DshRegistryEntry } from './registry.js'
import { dshListRows } from './wire.js'
@@ -213,6 +213,51 @@ describe('package updates', { timeout: 30_000 }, () => {
expect(installedDsh(id)?.commit).toBe(ref)
})
+ it('offers the official repository rename as an update without treating other sources or folders as aliases', async () => {
+ const repo = create('store/agents/thing')
+ await installDsh({ source: repo, path: 'store/agents/thing' })
+ const record = { ...installedDsh(id)!, source: 'https://github.com/autonomous-ai/autonomous-harness.git/', revision: 'a'.repeat(40) }
+ const entry = { ...catalog(repo, record.commit!, record.path ?? undefined), repo: 'https://github.com/autonomous-ai/openharness', ref: 'b'.repeat(40), revision: 'c'.repeat(40) }
+ expect(dshUpdateInfo(record, entry)).toMatchObject({ updateAvailable: true, availableCommit: entry.ref })
+ expect(samePackageSource({ ...record, source: entry.repo }, { ...entry, repo: record.source })).toBe(true)
+ for (const source of [
+ 'https://github.com/someone/autonomous-harness',
+ 'https://github.com/someone/openharness',
+ 'https://example.test/autonomous-ai/autonomous-harness',
+ 'https://github.com/autonomous-ai/autonomous-harness-extra',
+ ]) expect(dshUpdateInfo({ ...record, source }, entry).updateAvailable).toBe(false)
+ expect(dshUpdateInfo(record, { ...entry, path: 'store/agents/other' }).updateAvailable).toBe(false)
+ expect(dshUpdateInfo({ ...record, linked: true }, entry).updateAvailable).toBe(false)
+ })
+
+ it('updates a legacy official install from the canonical catalog source and preserves its workspace', async () => {
+ const path = 'store/agents/thing'
+ const repo = create(path)
+ await installDsh({ source: repo, path, ref: 'main' })
+ const before = installedDsh(id)!
+ const workspace = join(root, 'my-project')
+ mkdirSync(workspace)
+ await materializeWorkspace(before, workspace)
+ write(workspace, { 'project.txt': 'my authored work\n' })
+ const legacy = 'https://github.com/autonomous-ai/autonomous-harness'
+ const canonical = 'https://github.com/autonomous-ai/openharness'
+ upsertInstalledRecord({ ...before, source: legacy, ref: 'viewer-packages' })
+ write(join(repo, path), { 'AGENTS.md': '# Current featured experience\n' })
+ const entry = { ...catalog(repo, commit(repo), path), repo: canonical }
+ // Exercise real clone/setup/doctor without the network. Using the legacy URL would fail.
+ vi.stubEnv('GIT_CONFIG_COUNT', '2')
+ vi.stubEnv('GIT_CONFIG_KEY_0', `url.${repo}.insteadOf`)
+ vi.stubEnv('GIT_CONFIG_VALUE_0', canonical)
+ vi.stubEnv('GIT_CONFIG_KEY_1', `url.${join(root, 'retired-repo')}.insteadOf`)
+ vi.stubEnv('GIT_CONFIG_VALUE_1', legacy)
+ const result = await update(entry)
+ expect(result.ok, JSON.stringify(result)).toBe(true)
+ expect(installedDsh(id)).toMatchObject({ source: canonical, ref: entry.ref, commit: entry.ref, revision: entry.revision })
+ expect(readFileSync(join(before.dir, 'AGENTS.md'), 'utf8')).toBe('# Current featured experience\n')
+ expect(readFileSync(join(workspace, 'project.txt'), 'utf8')).toBe('my authored work\n')
+ expect(dshUpdateInfo(installedDsh(id)!, entry).updateAvailable).toBe(false)
+ })
+
it('records local clone sources absolutely so updates do not depend on the original working directory', async () => {
const repo = create()
await installDsh({ source: relative(process.cwd(), repo) })
diff --git a/cli/src/dsh/update.ts b/cli/src/dsh/update.ts
index 573f00aaf..025cb4b88 100644
--- a/cli/src/dsh/update.ts
+++ b/cli/src/dsh/update.ts
@@ -40,8 +40,9 @@ async function updatePackage(opts: DshUpdateOptions): Promise<DshInstallResult>
const entry = catalog && samePackageSource(record, catalog) ? catalog : undefined
const ref = entry?.ref ?? record.ref ?? undefined
const path = record.path ?? undefined
- opts.onProgress?.({ id: opts.id, phase: 'clone', detail: `fetching ${record.source}` })
- const cloned = await cloneInstall(record.source, ref, path, opts.onLine, opts.cloneRetryDelaysMs)
+ const source = entry?.repo ?? record.source
+ opts.onProgress?.({ id: opts.id, phase: 'clone', detail: `fetching ${source}` })
+ const cloned = await cloneInstall(source, ref, path, opts.onLine, opts.cloneRetryDelaysMs)
if (!cloned.ok) return cloned
staged = cloned.tmpDir
if (cloned.manifest.id !== record.id) {
@@ -66,10 +67,10 @@ async function updatePackage(opts: DshUpdateOptions): Promise<DshInstallResult>
mkdirSync(dirname(record.dir), { recursive: true, mode: 0o700 })
renameSync(staged, record.dir)
placed = true
- const installed: InstalledDsh = { ...record, ref: ref ?? null, commit: cloned.commit, revision: cloned.revision,
+ const installed: InstalledDsh = { ...record, source, ref: ref ?? null, commit: cloned.commit, revision: cloned.revision,
updatedAt: Date.now(), manifest: cloned.manifest, realDir: realpathSync(record.dir) }
const result = await finishInstall(installed, {
- ...opts, source: record.source,
+ ...opts, source,
onProgress: p => { if (p.phase !== 'done' && p.phase !== 'failed') opts.onProgress?.(p) },
}, false)
committed = result.ok
diff --git a/cli/src/dsh/updates.ts b/cli/src/dsh/updates.ts
index de6f17a03..ef894a445 100644
--- a/cli/src/dsh/updates.ts
+++ b/cli/src/dsh/updates.ts
@@ -1,11 +1,16 @@
/** Version facts only: reading the Store never fetches or executes package code. */
import type { InstalledDshRecord } from './installed.js'
-import type { DshRegistryEntry } from './registry.js'
+import { HARNESS_MONOREPO, type DshRegistryEntry } from './registry.js'
export const GIT_REVISION_RE = /^[a-f0-9]{40}$/i
export function samePackageSource(installed: InstalledDshRecord, entry: DshRegistryEntry): boolean {
- const normalize = (source: string): string => source.replace(/\/$/, '').replace(/\.git$/, '')
+ const normalize = (source: string): string => {
+ const repo = source.replace(/\/$/, '').replace(/\.git$/, '')
+ // This is the same official repository before its rename. Do not infer aliases from ids
+ // or follow arbitrary redirects: a catalog entry must never replace a private fork.
+ return repo === 'https://github.com/autonomous-ai/autonomous-harness' ? HARNESS_MONOREPO : repo
+ }
return normalize(installed.source) === normalize(entry.repo) && (installed.path ?? '') === (entry.path ?? '')
}