mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-27 02:14:30 +01:00
fix(health): Health Stack rows stay markdown like /verify reads them; an empty section names why (fix-check)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
e2e4a4d85a
commit
f8eae9d0cc
2 files changed
+10
-9
No files matched your search
+2
-2
@@ -71,7 +71,7 @@ export function healthStack(claudeMd: string, keepTests = false): Check[] {
|
||||
while (taken.has(name)) name = `${key}-${++n + 1}`;
|
||||
seen.set(key, n);
|
||||
taken.add(name);
|
||||
checks.push({ name, command: m[2].replace(/^`([^`]+)`$/, '$1'), source: 'CLAUDE.md Health Stack' });
|
||||
checks.push({ name, command: m[2].replace(/`/g, ''), source: 'CLAUDE.md Health Stack' });
|
||||
}
|
||||
return checks;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ export function healthDimensions(root: string, env: NodeJS.ProcessEnv = process.
|
||||
const stack = healthStack(claude, true);
|
||||
if (/^##\s+Health Stack\s*$/m.test(claude)) {
|
||||
const keys = new Set(stack.map(c => c.name.replace(/-\d+$/, '').replace(/^tests$/, 'test')));
|
||||
return { checks: stack.map(c => ({ dimension: c.name, command: c.command, source: c.source })), missing: HEALTH_DIMENSIONS.filter(d => !keys.has(d)).map(dimension => ({ dimension, reason: 'not in the CLAUDE.md Health Stack section' })) };
|
||||
return { checks: stack.map(c => ({ dimension: c.name, command: c.command, source: c.source })), missing: HEALTH_DIMENSIONS.filter(d => !keys.has(d)).map(dimension => ({ dimension, reason: stack.length ? 'not in the CLAUDE.md Health Stack section' : 'the CLAUDE.md Health Stack section has no "- key: command" rows' })) };
|
||||
}
|
||||
const has = (file: string) => fs.existsSync(path.join(root, file));
|
||||
const which = (bin: string) => Bun.which(bin, { PATH: env.PATH ?? '' }) !== null;
|
||||
|
||||
@@ -142,17 +142,18 @@ describe('/health detection: no check lost (GST-116 PR 2)', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Value: protects=a Health Stack keeps shell syntax, an empty section still turns auto-detection off, and detection runs
|
||||
// where /health runs (a monorepo package); fails_when=backticks inside a command are stripped (a failing checker becomes
|
||||
// a lookup), a section with no rows falls through to auto-detection, or the bin detects from the git top-level;
|
||||
// why_new=review pass 1 outside voice; seam=the bin from a subdirectory
|
||||
test('Health Stack bytes, an empty section, and the working directory', () => {
|
||||
// Value: protects=Health Stack rows read as markdown like gstack:verify: (code-span backticks dropped), an empty section
|
||||
// still turns auto-detection off and says so, and detection runs where /health runs (a monorepo package);
|
||||
// fails_when=a section with no rows falls through to auto-detection, or the bin detects from the git top-level;
|
||||
// why_new=review pass 1 voices; seam=the bin from a subdirectory
|
||||
test('Health Stack spans, an empty section, and the working directory', () => {
|
||||
const tick = String.fromCharCode(96);
|
||||
const subst = healthDimensions(repo('hs-subst', { 'CLAUDE.md': `## Health Stack\n\n- test: test "$(${tick}command -v false${tick})" = x\n- lint: ${tick}eslint .${tick}\n` }), { PATH: '', HOME: bareHome });
|
||||
expect(subst.checks.map(c => c.command)).toEqual([`test "$(${tick}command -v false${tick})" = x`, 'eslint .']);
|
||||
const spans = healthDimensions(repo('hs-spans', { 'CLAUDE.md': `## Health Stack\n\n- lint: ${tick}eslint .${tick} && ${tick}prettier --check .${tick}\n` }), { PATH: '', HOME: bareHome });
|
||||
expect(spans.checks.map(c => c.command)).toEqual(['eslint . && prettier --check .']);
|
||||
const empty = healthDimensions(repo('hs-empty', { 'tsconfig.json': '{}', 'CLAUDE.md': '## Health Stack\n\nNo health tools are configured.\n' }), { PATH: stubs, HOME: gbrainHome });
|
||||
expect(empty.checks).toEqual([]);
|
||||
expect(empty.missing.map(m => m.dimension)).toEqual([...HEALTH_DIMENSIONS]);
|
||||
expect(empty.missing[0].reason).toBe('the CLAUDE.md Health Stack section has no "- key: command" rows');
|
||||
const mono = repo('monorepo', { 'tsconfig.json': '{}', 'packages/app/package.json': JSON.stringify({ scripts: { test: 'vitest run' } }) });
|
||||
expect(spawnSync('git', ['init', '-q'], { cwd: mono, timeout: 30_000 }).status).toBe(0);
|
||||
const env = { ...process.env, PATH: process.env.PATH, HOME: bareHome };
|
||||
|
||||
Reference in new issue
Block a user