fix(commands): resolve active plugin root in /instinct-status (#2037) (#2059)

The `/instinct-status` slash command template expanded
`${CLAUDE_PLUGIN_ROOT}` directly and documented a manual-install
fallback to `~/.claude/skills/continuous-learning-v2/scripts/instinct-cli.py`.
When users had both an active plugin install (under
`~/.claude/plugins/cache/<slug>/<org>/<version>/`) and a legacy
`~/.claude/skills/continuous-learning-v2/` directory left over from a
previous manual install, an empty `CLAUDE_PLUGIN_ROOT` (which Claude
Code does not always populate in slash-command shell contexts) silently
made the command read the stale legacy install while the active plugin
hooks and observer wrote to the new XDG path. The user saw "No
instincts found" while the system was actively learning — exactly the
divergence the bug reporter spent hours diagnosing.

Replace the brittle two-block template with the same inline resolver
pattern that `hooks/hooks.json` and `/sessions` / `/skill-health`
already use: env var → standard install → known plugin roots → plugin
cache walk → fallback. The resolver is the canonical `INLINE_RESOLVE`
constant from `scripts/lib/resolve-ecc-root.js`, so no new code is
introduced — just consistent adoption of the existing pattern.

Apply the same fix to all five copies of the command:
  - commands/instinct-status.md (canonical)
  - .opencode/commands/instinct-status.md
  - docs/zh-CN/commands/instinct-status.md
  - docs/ja-JP/commands/instinct-status.md
  - docs/tr/commands/instinct-status.md

Extend tests/lib/command-plugin-root.test.js with an assertion that the
canonical instinct-status.md uses the inline resolver and no longer
hard-codes the legacy `~/.claude/skills/...` fallback (regression
guard).

zh-CN copy: polish the Chinese phrasing per LanguageTool feedback
(`使用与 ... 相同的解析器` → `以与 ... 相同的解析器`) so the verb is
introduced by an explicit preposition instead of reading as an awkward
verb-object construction.
This commit is contained in:
fxdv
2026-06-07 08:27:05 +03:00
committed by GitHub
parent d7dcd10c8a
commit 8eedcff5ac
6 changed files with 51 additions and 40 deletions

View File

@@ -22,6 +22,7 @@ function test(name, fn) {
const sessionsDoc = fs.readFileSync(path.join(__dirname, '..', '..', 'commands', 'sessions.md'), 'utf8');
const skillHealthDoc = fs.readFileSync(path.join(__dirname, '..', '..', 'commands', 'skill-health.md'), 'utf8');
const instinctStatusDoc = fs.readFileSync(path.join(__dirname, '..', '..', 'commands', 'instinct-status.md'), 'utf8');
test('sessions command uses shared inline resolver in all node scripts', () => {
assert.strictEqual((sessionsDoc.match(/const _r = /g) || []).length, 6);
@@ -37,6 +38,19 @@ test('skill-health command uses shared inline resolver in all shell snippets', (
assert.strictEqual((skillHealthDoc.match(/\['ecc','everything-claude-code'\]/g) || []).length, 3);
});
test('instinct-status command uses shared inline resolver (no stale legacy fallback) (#2037)', () => {
assert.strictEqual((instinctStatusDoc.match(/var r=/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/\['marketplaces','ecc'\]/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/\['marketplaces','everything-claude-code'\]/g) || []).length, 1);
assert.strictEqual((instinctStatusDoc.match(/\['ecc','everything-claude-code'\]/g) || []).length, 1);
// The pre-fix template hard-coded the legacy path as a fallback when
// CLAUDE_PLUGIN_ROOT was unset. Asserting its absence prevents regression.
assert.ok(
!instinctStatusDoc.includes('python3 ~/.claude/skills/continuous-learning-v2/scripts/instinct-cli.py'),
'instinct-status should not hard-code the legacy ~/.claude install path as a fallback'
);
});
test('inline resolver covers current and legacy marketplace plugin roots', () => {
assert.ok(INLINE_RESOLVE.includes("'marketplaces','ecc'"));
assert.ok(INLINE_RESOLVE.includes("'marketplaces','everything-claude-code'"));