chore(debug,ci): add .debug workspace tooling and hygiene checks
Ignore .debug/ locally and add scripts/debug/ helpers (tmp, work, worktree, check, and tests) to enforce workspace hygiene. Run the hygiene check and self-test in CI, and document the .debug/ contract in AGENTS.md and docs/architecture.md.
This commit is contained in:
1 parent
0802f77705
commit
c91f5901a7
13 files changed
+1599
-3
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Declared homes under `.debug/`. Every debug tool writes through one of these,
|
||||
* and `node scripts/debug/check.mjs` refuses any other entry at the top of `.debug/`.
|
||||
*
|
||||
* tmp/ one-off session scratch, owned and collected by `scripts/debug/tmp.mjs`
|
||||
* work/ cross-session work orders, owned by `scripts/debug/work.mjs`
|
||||
* cache/ rebuildable local tool caches
|
||||
* runs/ run outputs: logs, captures, reports, traces, isolated test runs
|
||||
* worktrees/ scratch git worktrees, owned by `scripts/debug/worktree.mjs`
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import path from 'node:path'
|
||||
|
||||
export const REPO_ROOT = path.resolve(import.meta.dirname, '..', '..')
|
||||
|
||||
export const DEBUG_HOMES = ['tmp', 'work', 'cache', 'runs', 'worktrees']
|
||||
|
||||
/**
|
||||
* Resolve the main repository tree so linked worktrees share `.debug/`.
|
||||
* Falls back to `root` when executed outside a git repository (e.g. isolated tests).
|
||||
*/
|
||||
export function resolveStorageRoot(root = REPO_ROOT) {
|
||||
const resolved = path.resolve(root)
|
||||
try {
|
||||
const common = execFileSync(
|
||||
'git',
|
||||
['rev-parse', '--path-format=absolute', '--git-common-dir'],
|
||||
{ cwd: resolved, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] },
|
||||
).trim()
|
||||
if (common !== '') return path.dirname(path.resolve(resolved, common))
|
||||
} catch {
|
||||
// Non-git directories (e.g. synthetic test sandboxes) use the directory directly.
|
||||
}
|
||||
return resolved
|
||||
}
|
||||
|
||||
export const debugPath = (root, ...parts) => path.join(root, '.debug', ...parts)
|
||||
export const tmpPath = (root, ...parts) => debugPath(root, 'tmp', ...parts)
|
||||
export const workPath = (root, ...parts) => debugPath(root, 'work', ...parts)
|
||||
export const cachePath = (root, ...parts) => debugPath(root, 'cache', ...parts)
|
||||
export const runsPath = (root, ...parts) => debugPath(root, 'runs', ...parts)
|
||||
export const worktreesPath = (root, ...parts) => debugPath(root, 'worktrees', ...parts)
|
||||
Reference in new issue
Block a user