Skip to content

The agent that grows with you

fix: harden the metadata-walk probe (directory-named plugin.js regression test, lint)

Teknium0430e3c719ff
diff --git a/apps/desktop/src/contrib/runtime-loader.test.ts b/apps/desktop/src/contrib/runtime-loader.test.ts
index deac8921c35..02d60addf8e 100644
--- a/apps/desktop/src/contrib/runtime-loader.test.ts
+++ b/apps/desktop/src/contrib/runtime-loader.test.ts
@@ -102,6 +102,30 @@ describe('scanDiskPlugins (#66899)', () => {
expect(readFileText).not.toHaveBeenCalled()
})
+ it('a DIRECTORY named plugin.js is not a plugin entry (metadata walk rejects it)', async () => {
+ desktopPluginsRoot.mockResolvedValue('/local/.hermes/desktop-plugins')
+ agentPluginsRoot.mockResolvedValue('')
+ readDir.mockImplementation(async dir => {
+ if (dir === '/local/.hermes/desktop-plugins') {
+ return { entries: [{ isDirectory: true, name: 'odd', path: '/local/.hermes/desktop-plugins/odd' }] }
+ }
+
+ if (dir === '/local/.hermes/desktop-plugins/odd') {
+ // A folder literally named plugin.js — must resolve to "no entry".
+ return {
+ entries: [{ isDirectory: true, name: 'plugin.js', path: '/local/.hermes/desktop-plugins/odd/plugin.js' }]
+ }
+ }
+
+ return { entries: [] }
+ })
+
+ await discoverRuntimePlugins()
+
+ expect(readFileText).not.toHaveBeenCalled()
+ expect($pluginRecords.get().odd).toBeUndefined()
+ })
+
it('still scans the standalone root when agentPluginsRoot is absent (older shell)', async () => {
delete (window.hermesDesktop as unknown as { agentPluginsRoot?: unknown }).agentPluginsRoot
desktopPluginsRoot.mockResolvedValue('/local/.hermes/desktop-plugins')
diff --git a/apps/desktop/src/contrib/runtime-loader.ts b/apps/desktop/src/contrib/runtime-loader.ts
index a4c8d2215d9..a28a84fd053 100644
--- a/apps/desktop/src/contrib/runtime-loader.ts
+++ b/apps/desktop/src/contrib/runtime-loader.ts
@@ -472,6 +472,7 @@ async function scanDiskPlugins(): Promise<void> {
if (!(await loadDiskPlugin(record))) {
disk.delete(file)
+
continue
}