fix(verify): resolve plugin paths from source-tree when running locally

When `ruflo verify` runs from a checked-out repo (maintainer's working
copy), packages like `@claude-flow/plugin-agent-federation` live at
`v3/@claude-flow/plugin-*/dist/...` rather than under
`node_modules/@claude-flow/plugin-*/`. The previous resolution path
only knew about node_modules layouts, so the plugin's witness entry
reported `missing` for source-tree runs (cosmetic — installed copies
still resolved correctly).

Added a third resolution lane: walk up from the script's location
looking for the literal repo-relative path itself. End users still
hit the node_modules paths first; maintainers now get clean 27/27
pass instead of 26/27 + 1 missing.

Verified: `node bin/cli.js verify --manifest verification.md.json`
from the repo root reports pass: 27 / drift: 0 / regressed: 0 /
missing: 0.

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ReuvenandRuFlo committed 2026-05-03 20:03:15 -04:00
1 parent f514495c81
commit 87cc2f323c
1 file changed
+19 -2
+19 -2
View File
@@ -85,12 +85,13 @@ function repoPathToInstalledPath(repoPath: string): string | null {
if (match) {
const pkg = match[1];
const rest = match[2];
// Try several anchors: cwd/node_modules, the dirname of this script's package
const candidates: string[] = [];
// 1. cwd/node_modules/<pkg>/<rest> (typical end-user install)
candidates.push(join(process.cwd(), 'node_modules', pkg, rest));
// 2. Walk up from this script looking for node_modules/<pkg>/<rest>
// Covers cases where verify runs from inside a nested module.
try {
const __filename = fileURLToPath(import.meta.url);
// Walk up looking for node_modules
let dir = dirname(__filename);
for (let i = 0; i < 10; i++) {
candidates.push(join(dir, 'node_modules', pkg, rest));
@@ -99,6 +100,22 @@ function repoPathToInstalledPath(repoPath: string): string | null {
dir = parent;
}
} catch { /* ignore */ }
// 3. Source-tree resolution: when verify runs against a checked-out
// repo (the developer's working copy), packages live at
// `<repoRoot>/v3/<pkg>/<rest>` rather than under node_modules.
// Walk up looking for the literal repo-relative path so the verify
// command works for maintainers running it from the repo itself.
try {
const __filename = fileURLToPath(import.meta.url);
let dir = dirname(__filename);
for (let i = 0; i < 10; i++) {
candidates.push(join(dir, repoPath));
const parent = dirname(dir);
if (parent === dir) break;
dir = parent;
}
} catch { /* ignore */ }
candidates.push(join(process.cwd(), repoPath));
for (const c of candidates) {
if (existsSync(c)) return c;
}