The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): stamp the package marker when installing a unified plugin from git
Austin Pickett0d914a0652db
diff --git a/apps/desktop/electron/desktop-plugin-install.test.ts b/apps/desktop/electron/desktop-plugin-install.test.tsindex 4aefbccd80f..deab5f7b4a2 100644--- a/apps/desktop/electron/desktop-plugin-install.test.ts+++ b/apps/desktop/electron/desktop-plugin-install.test.ts@@ -10,10 +10,12 @@ import {desktopPluginFolderName,detectPluginComponents,findDesktopEntry,+ installDesktopPluginFromGit,probePluginRepo,resolvePluginGitUrl,resolveSubdirWithin} from './desktop-plugin-install'+import { PACKAGE_MARKER } from './desktop-plugins-root'const here = path.dirname(fileURLToPath(import.meta.url))@@ -150,3 +152,64 @@ describe('probePluginRepo', () => {expect(result).toMatchObject({ ok: true, agent: true, agentName: 'nested-agent' })})})++describe('installDesktopPluginFromGit', () => {+ const roots: string[] = []++ afterEach(() => {+ for (const root of roots.splice(0)) {+ fs.rmSync(root, { recursive: true, force: true })+ }+ })++ /** A git repo whose root is one plugin: `desktop/plugin.js` plus, when+ * `agentName` is given, the agent half that makes it a unified package. */+ function pluginRepo(agentName: null | string): string {+ const repo = mkdtemp('hermes-plugin-install-')+ roots.push(repo)+ const git = (...args: string[]) => execFileSync('git', args, { cwd: repo, stdio: 'pipe' })++ fs.mkdirSync(path.join(repo, 'desktop'), { recursive: true })+ fs.writeFileSync(path.join(repo, 'desktop', 'plugin.js'), 'export function register() {}\n')++ if (agentName) {+ fs.writeFileSync(path.join(repo, 'plugin.yaml'), `name: ${agentName}\n`)+ fs.writeFileSync(path.join(repo, '__init__.py'), 'def register(ctx): pass\n')+ }++ git('init', '-q')+ git('add', '.')+ git('-c', '[email protected]', '-c', 'user.name=Fixture', 'commit', '-qm', 'init')++ return repo+ }++ it('stamps the package marker on a unified package half and names the folder after the agent package', async () => {+ // Without the marker the Plugins page has no evidence that this copy is the+ // agent row's desktop half: the row sits on "copying…" while the copy shows+ // up as a second, default-enabled standalone row, and reconcile refuses to+ // re-copy the folder ever again.+ const repo = pluginRepo('hermes-talk')+ const appRoot = mkdtemp('hermes-plugin-root-')+ roots.push(appRoot)++ const result = await installDesktopPluginFromGit('git', pathToFileURL(repo).href, appRoot)++ expect(result).toMatchObject({ ok: true, pluginName: 'hermes-talk' })+ const marker = JSON.parse(fs.readFileSync(path.join(appRoot, 'hermes-talk', PACKAGE_MARKER), 'utf8'))+ expect(marker.package).toBe('hermes-talk')+ expect(marker.repo).toBe(pathToFileURL(repo).href)+ })++ it('leaves a desktop-only repo unmarked so it stays a standalone plugin', async () => {+ const repo = pluginRepo(null)+ const appRoot = mkdtemp('hermes-plugin-root-')+ roots.push(appRoot)++ const result = await installDesktopPluginFromGit('git', pathToFileURL(repo).href, appRoot)++ expect(result.ok).toBe(true)+ expect(fs.existsSync(path.join(appRoot, String(result.pluginName), 'plugin.js'))).toBe(true)+ expect(fs.existsSync(path.join(appRoot, String(result.pluginName), PACKAGE_MARKER))).toBe(false)+ })+})diff --git a/apps/desktop/electron/desktop-plugin-install.ts b/apps/desktop/electron/desktop-plugin-install.tsindex abdc538bf5c..f384db7caf5 100644--- a/apps/desktop/electron/desktop-plugin-install.ts+++ b/apps/desktop/electron/desktop-plugin-install.ts@@ -10,7 +10,7 @@ import fsp from 'node:fs/promises'import os from 'node:os'import path from 'node:path'-import { publishDesktopTree } from './desktop-plugins-root'+import { publishDesktopTree, writeDesktopHalfMarker } from './desktop-plugins-root'const GITHUB_BROWSER_SEGMENTS = new Set(['tree', 'blob', 'commit'])@@ -428,7 +428,13 @@ export async function installDesktopPluginFromGit(const sourceDir =detected.desktopSourceSubdir === '.' ? pluginRoot : path.join(pluginRoot, detected.desktopSourceSubdir)- const pluginName = desktopPluginFolderName(gitUrl, subdir)+ // A repo carrying BOTH halves is one package: land its desktop half under+ // the AGENT package name, so the copy this app makes and the one+ // `reconcileUnifiedDesktopHalves` would make are the same folder (#100412)+ // and the Plugins page pairs them into one row. A desktop-only repo keeps+ // the git-derived folder name and stays a standalone plugin.+ const packageName = detected.agent ? (detected.agentName ?? desktopPluginFolderName(gitUrl, subdir)) : null+ const pluginName = packageName ?? desktopPluginFolderName(gitUrl, subdir)const targetDir = path.join(desktopPluginsRoot, pluginName)const targetPlugin = path.join(targetDir, 'plugin.js')@@ -445,7 +451,26 @@ export async function installDesktopPluginFromGit(// Staged copy + rename: a failed copy must not leave an empty `targetDir`// that turns every retry into "already exists. Enable force reinstall".- await publishDesktopTree(sourceDir, targetDir)+ // The half of a unified package is stamped with the package marker as+ // part of that publication — without it the Plugins page cannot tell this+ // copy belongs to the agent row (it sits on "copying…" forever) and the+ // half loads default-enabled instead of opt-in.+ await publishDesktopTree(sourceDir, targetDir, async staged => {+ if (!packageName) {+ return+ }++ await writeDesktopHalfMarker(staged, {+ package: packageName,+ repo: gitUrl,+ // The clone is deleted below, so this source never matches a local+ // package's `desktop/` dir: the first reconcile that finds the agent+ // half re-copies from there and the package folder takes over as the+ // single source of truth.+ source: sourceDir,+ sourceMtimeMs: (await fsp.stat(path.join(sourceDir, 'plugin.js'))).mtimeMs+ })+ })if (!(await pathIsFile(targetPlugin))) {return { ok: false, error: `Install completed but ${targetPlugin} is missing.` }diff --git a/apps/desktop/src/app/capabilities/plugins/plugin-packages.test.ts b/apps/desktop/src/app/capabilities/plugins/plugin-packages.test.tsindex 4416b4687ac..d51e6916474 100644--- a/apps/desktop/src/app/capabilities/plugins/plugin-packages.test.ts+++ b/apps/desktop/src/app/capabilities/plugins/plugin-packages.test.ts@@ -49,16 +49,20 @@ describe('mergePluginPackages', () => {expect(rows[0]).toMatchObject({ kind: 'both', desktop: null, desktopMissing: true })})- // Catalog install can land the desktop half at desktop-plugins/<name>/plugin.js- // with no .hermes-package.json. That copy is already loaded; the agent row- // must not stay on "copying…" as a second row.- it('pairs a marker-less app-root desktop copy with the agent package of the same folder name', () => {+ // A catalog install used to land the desktop half at+ // desktop-plugins/<name>/plugin.js with no .hermes-package.json, and the row+ // sat on "copying…" beside a second, already-enabled desktop row. The join is+ // the marker, not the folder name: Electron stamps it on install and adopts+ // marker-less copies on reconcile (see desktop-plugins-root.ts), so the page+ // pairs on evidence instead of guessing from a path.+ it('pairs a desktop half with its agent row through the package marker', () => {const rows = mergePluginPackages([desktop({id: 'hermes-talk',name: 'Hermes Talk',description: 'GPT-Live subscription or explicit API voice, with Hermes task delegation.',+ packageName: 'hermes-talk',file: '/Users/me/.hermes/desktop-plugins/hermes-talk/plugin.js'})],@@ -77,6 +81,24 @@ describe('mergePluginPackages', () => {expect(rows[0].agent?.name).toBe('hermes-talk')})+ it('keeps an unmarked app-root copy its own row rather than guessing from the folder name', () => {+ const rows = mergePluginPackages(+ [+ desktop({+ id: 'hermes-talk',+ name: 'Hermes Talk',+ file: '/Users/me/.hermes/desktop-plugins/hermes-talk/plugin.js'+ })+ ],+ [agent({ name: 'hermes-talk', has_desktop_half: true })]+ )++ expect(rows.map(row => [row.key, row.kind])).toEqual([+ ['hermes-talk', 'both'],+ ['desktop:hermes-talk', 'desktop']+ ])+ })+it('leaves a same-named standalone desktop plugin alone when the agent package has no desktop half', () => {const rows = mergePluginPackages([desktop({ id: 'clock', name: 'Clock', file: '/Users/me/.hermes/desktop-plugins/clock/plugin.js' })],