mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-19 06:34:43 +01:00
An unattended /autoplan run on Claude Code now says its phase guard is on, instead of saying it is off while the guard blocks it. A phase report written only in reasoning now gets a denial that says so and names the exact command to send. Why: in the day-one eval, two runs were blocked by a guard their own record called off, and one run ended blocked after four publish attempts whose report was invisible. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
30 lines
1.8 KiB
TypeScript
30 lines
1.8 KiB
TypeScript
/**
|
|
* What gstack-skill-start and the gstack-autoplan run record say about the
|
|
* /autoplan publication guard. The guard is the PreToolUse hook that the
|
|
* Claude render of autoplan/SKILL.md declares in its frontmatter
|
|
* (scripts/resolvers/composition.ts). Claude Code runs it whenever /autoplan
|
|
* was started as a skill, whatever GSTACK_SESSION_KIND says, so the line
|
|
* follows the host and the installed skill, never the session kind (GST-3062).
|
|
* bin/gstack-skill-start carries the same rule in bash; test/autoplan-guard-status.test.ts holds them equal.
|
|
*/
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
|
|
export const GUARD_NOT_INSTALLED_LINE = 'autoplan guard: not enforced by this host; publication order is unverified (GUARD_NOT_INSTALLED)';
|
|
export const GUARD_ENFORCED_LINE = "autoplan guard: enforced by Claude Code's /autoplan hook at phase Reads and reviewer dispatch; " +
|
|
'publish each phase report as visible message text, not reasoning, before the next phase (GUARD_ENFORCED)';
|
|
|
|
/** True when the installed autoplan/SKILL.md declares the publication hook in its frontmatter. */
|
|
export function publicationHookDeclared(root: string): boolean {
|
|
let text: string;
|
|
try { text = fs.readFileSync(path.join(root, 'autoplan', 'SKILL.md'), 'utf8'); } catch { return false; }
|
|
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text)?.[1] ?? '';
|
|
return frontmatter.includes('autoplan/bin/phase-publication-hook');
|
|
}
|
|
|
|
/** The one guard line for this process: enforced only on Claude Code with the hook declared. */
|
|
export function autoplanGuardLine(env: Record<string, string | undefined>, root: string): string {
|
|
const claude = !!env.CLAUDECODE && (!env.GSTACK_ACTIVE_HOST || env.GSTACK_ACTIVE_HOST === 'claude');
|
|
return claude && publicationHookDeclared(root) ? GUARD_ENFORCED_LINE : GUARD_NOT_INSTALLED_LINE;
|
|
}
|