Scripts Directory Cleanup
Consolidate scripts/ layout so capability boundaries match the architecture rules in docs/ARCHITECTURE.md: compose through public surfaces, keep root entrypoints thin, and use business-named capability directories.
Traceability
- Spec ID: 2026-07-20-scripts-directory-cleanup
- Status: Implemented
Intent
A structure review of scripts/ found rule violations that grow maintenance cost:
- Ten files across
agent-customize,agent-lint, andcoding-agent-practicesimportsession-analysisprivate helpers (fs.mjs,paths.mjs,cli.mjs) directly, andharness-analysis/task-loop-source.mjsimports six more deepsession-analysismodules. - Root
scripts/session-analysis.mjsowns the real CLI andSessionAnalyzerwhilescripts/session-analysis/modules import the root file back — a reverse-layering cycle. scripts/findings-recommend.mjs+.jsonandscripts/doc-link-graph.mjsare loose root files consumed by multiple capabilities, against thescripts/<capability>/convention.scripts/package/andscripts/packaging/are near-identical names with different owners (npm bundle/verify vs host-plugin assembly).scripts/coding-agent-practices/checkup.mjsis a re-export shim overcheckup/cli.mjswith no external import consumers.
Acceptance Scenarios
- AC-1:
scripts/session-analysis/index.mjsis the only import path other capabilities use for session-analysis helpers; no file outsidescripts/session-analysis/importssession-analysis/<private>.mjsmodules directly. - AC-2:
scripts/session-analysis.mjsstays a thin compatibility shim (re-export + CLI dispatch) so documentednode scripts/session-analysis.mjscommands keep working; the class/dispatch logic lives inscripts/session-analysis/analyzer.mjsand no module insidescripts/session-analysis/imports the root file. - AC-3:
findings-recommendmoves toscripts/findings-recommend/(index.mjs+findings-recommend.json);agent-lint,review-trigger, and tests import the new path; behavior is unchanged. - AC-4:
doc-link-graphmoves toscripts/doc-link-graph/cli.mjs;AGENTS.mdandtest/doc-link-graph.test.mjsreference the new path and the generateddocs/harness-doc-links.mmdstays fresh. - AC-5:
scripts/package/is renamed toscripts/npm-package/;package.jsonscripts, tests, and directory-ownership docs reference the new name;npm run pack:verifypasses. - AC-6:
scripts/coding-agent-practices/checkup.mjsis removed; theharness checkupregistry entry dispatches tocoding-agent-practices/checkup/cli.mjs, which owns its own CLI gate. - AC-7:
npm testpasses with no behavioral output change from any CLI.
Non-Goals
- No split or refactor of
scripts/harness-analysis/internals (tracked as a future spec; it needs its own evidence review). - No command renames, flag changes, or output-format changes.
- No changes to
hooks/,skills/, or host plugin shells beyond path references. - Historical
docs/specs/*.mdfiles keep their original command strings.
Plan
- Move root
session-analysis.mjslogic intoscripts/session-analysis/analyzer.mjs; keep the root file as shim. - Add
scripts/session-analysis/index.mjsexporting the cross-capability surface:parseArgs,parseBooleanFlag,pathExists,walkFiles,isDirectory,expandHome,normalizeWorkspace, semantic-facet, episode-contract, observation-manifest, privacy-safe-text, session-ref, selection, selection-plan exports,SessionAnalyzer,createAnalyzer. - Rewrite external importers to use
session-analysis/index.mjs. - Relocate
findings-recommendanddoc-link-graph; update importers, tests, andAGENTS.md. - Rename
scripts/package/toscripts/npm-package/; updatepackage.json, tests,docs/community.md,docs/adrs/directory-structure.md. - Remove the checkup shim and repoint the registry.
Test / Review Evidence
npm run pack:verifypassed: npm pack and runtime zip entries include the renamedscripts/npm-package/andscripts/findings-recommend/paths.NO_COLOR=1 node --test test/better-harness-cli.test.mjs test/doc-link-graph.test.mjs test/findings-recommend.test.mjs test/agent-lint.test.mjs test/plugin-manifests.test.mjs test/host-plugin-artifact.test.mjspassed.NO_COLOR=1 node --test test/session-analysis.test.mjs test/session-analysis-claude-facets.test.mjs test/coding-agent-practices-inventory.test.mjs test/harness-report-quality.test.mjs test/task-loop-repository-evidence.test.mjspassed.node scripts/better-harness.mjs --help,node scripts/session-analysis.mjs --help, andnode scripts/better-harness.mjs harness checkup --helppassed.npm testcurrently reports 762 pass / 1 fail; the failingtest/legacy-product-names.test.mjsreproduces on cleanHEADand is unrelated to this directory cleanup.