Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(skillpack): shared-skills migration ignores shared deps once no owned slug remains (#6922)

time-attackca5809c2ace8
diff --git a/docs/guides/skillpacks-as-scaffolding.md b/docs/guides/skillpacks-as-scaffolding.md
index 9379f89487..440bf5022d 100644
--- a/docs/guides/skillpacks-as-scaffolding.md
+++ b/docs/guides/skillpacks-as-scaffolding.md
@@ -219,8 +219,11 @@ gbrain skillpack remove --harness claude-code --skill query
install-time hash in the ledger reports **unknown** provenance and is
never auto-applied — patch by hand, or remove and re-scaffold.
- **`remove --harness`** deletes ONLY files the bridge wrote (the ledger) —
- never your own files. Workspace scaffolds have no `uninstall` at all;
- they stay user-owned outright.
+ never your own files. Shared convention files stay on disk even after the
+ last skill is removed; once no owned skill is left at that destination,
+ the v0.53.0 shared-skills migration no longer counts them as legacy
+ copies. Workspace scaffolds have no `uninstall` at all; they stay
+ user-owned outright.
- **`--stub`** installs cold-pull pointer SKILL.md files whose body fetches
the real instructions via the gbrain MCP `get_skill` op. Preflight-gated:
it refuses unless `mcp.publish_skills` is on and every slug is servable
diff --git a/src/commands/skillpack/harness.ts b/src/commands/skillpack/harness.ts
index f06b0c73f9..f221abd21a 100644
--- a/src/commands/skillpack/harness.ts
+++ b/src/commands/skillpack/harness.ts
@@ -619,7 +619,9 @@ export async function cmdRemove(args: string[]): Promise<void> {
'Remove files the harness bridge WROTE (the bridge-state ledger) — never\n' +
'your own files: pre-existing and locally-created files were never\n' +
'recorded as owned. Without --skill, removes every owned skill for the\n' +
- '(harness, dest). Shared convention files stay (other skills use them).\n\n' +
+ '(harness, dest). Shared convention files stay (other skills use them);\n' +
+ 'once no owned skill is left, the shared-skills migration no longer\n' +
+ 'counts them as legacy copies.\n\n' +
'This is NOT the removed-in-v0.33 workspace uninstall: workspace scaffolds\n' +
'are user-owned outright (delete their directories yourself).',
);
diff --git a/src/core/skillpack/shared-brain-bridge.ts b/src/core/skillpack/shared-brain-bridge.ts
index 6f8d7a81c0..b461341f3c 100644
--- a/src/core/skillpack/shared-brain-bridge.ts
+++ b/src/core/skillpack/shared-brain-bridge.ts
@@ -5,6 +5,7 @@ import type { BrainEngine } from '../engine.ts';
import { configDir, type GBrainConfig } from '../config.ts';
import { checkedRoot, confinedPath, sha256, privateWrite, readFileConfigState } from '../agent-install/state.ts';
import { findBridgeEntry, loadBridgeState } from './bridge-state.ts';
+import { ownedBridgeSlugs, SHARED_DEP_LEDGER_KEY } from './harness-bridge.ts';
import { isMissingSchemaObject } from '../utils.ts';
import { createSharedSkillsAdapter, type SharedSkillsToolCaller } from '../shared-skills/adapter.ts';
import { verifyLocalWriter, withVerifiedLocalRegistration, type LocalRegistration } from '../persistence/identity.ts';
@@ -104,7 +105,9 @@ export async function sharedBrainBridgePlan(options: {
const entry = findBridgeEntry(loadBridgeState({ statePath: options.statePath }), { harness: options.harness, dest: options.dest });
if (entry) {
migration.ownership = 'ledger';
- const files = new Map(Object.values(entry.written).flatMap(record => Object.entries(record.files)));
+ // #6922: remove --harness keeps the shared deps (_shared), so once no owned slug is left they are not a legacy copy to migrate.
+ const owned = ownedBridgeSlugs(entry).length > 0;
+ const files = new Map(Object.entries(entry.written).filter(([slug]) => owned || slug !== SHARED_DEP_LEDGER_KEY).flatMap(([, record]) => Object.entries(record.files)));
if (files.size > 2048) migration.modified.push('(inventory limit exceeded)');
else for (const [relative, expected] of files) {
try {
diff --git a/test/skillpack-shared-brain-bridge.test.ts b/test/skillpack-shared-brain-bridge.test.ts
index ffb7cbfc9e..a0447fb371 100644
--- a/test/skillpack-shared-brain-bridge.test.ts
+++ b/test/skillpack-shared-brain-bridge.test.ts
@@ -34,6 +34,22 @@ test('active shared brains inventory unchanged owned copies without installing o
expect(readFileSync(f.statePath, 'utf8')).toBe(before);
});
+test('#6922: shared deps a remove --harness kept are not a pending legacy copy once no owned slug remains', async () => {
+ const f = fixture();
+ mkdirSync(join(f.dest, 'conventions'));
+ writeFileSync(join(f.dest, 'conventions', 'style.md'), 'shared convention');
+ const ledger = JSON.parse(readFileSync(f.statePath, 'utf8'));
+ ledger.entries[0].written._shared = { mode: 'full', files: { 'conventions/style.md': sha256('shared convention') } };
+ writeFileSync(f.statePath, JSON.stringify(ledger));
+ expect((await sharedBrainBridgePlan(f))?.migration.owned_unchanged).toEqual(['recall/SKILL.md', 'conventions/style.md']);
+ delete ledger.entries[0].written.recall;
+ writeFileSync(f.statePath, JSON.stringify(ledger));
+ const result = await sharedBrainBridgePlan(f);
+ expect(result?.reason).toBe('follow_approval_required');
+ expect(result?.migration).toEqual({ owned_unchanged: [], modified: [], missing: [], ownership: 'ledger' });
+ expect(readFileSync(join(f.dest, 'conventions', 'style.md'), 'utf8')).toBe('shared convention');
+});
+
test('edited and escaping ledger paths remain visible conflicts without modifying user files', async () => {
const f = fixture(); writeFileSync(join(f.dest, 'recall', 'SKILL.md'), 'local user changes');
const ledger = JSON.parse(readFileSync(f.statePath, 'utf8'));