merge: sync Kilo runtime branch with main
Bring the latest main branch updates into feat/kilo-runtime-support while preserving KILO_CONFIG resolution, Kilo agent permission conversion, and relative .claude path rewrites.
This commit is contained in:
@@ -93,6 +93,7 @@
|
||||
* verify commits <h1> [h2] ... Batch verify commit hashes
|
||||
* verify artifacts <plan-file> Check must_haves.artifacts
|
||||
* verify key-links <plan-file> Check must_haves.key_links
|
||||
* verify schema-drift <phase> [--skip] Detect schema file changes without push
|
||||
*
|
||||
* Template Fill:
|
||||
* template fill summary --phase N Create pre-filled SUMMARY.md
|
||||
@@ -133,6 +134,9 @@
|
||||
* init milestone-op All context for milestone operations
|
||||
* init map-codebase All context for map-codebase workflow
|
||||
* init progress All context for progress workflow
|
||||
*
|
||||
* Documentation:
|
||||
* docs-init Project context for docs-update workflow
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
@@ -152,6 +156,7 @@ const frontmatter = require('./lib/frontmatter.cjs');
|
||||
const profilePipeline = require('./lib/profile-pipeline.cjs');
|
||||
const profileOutput = require('./lib/profile-output.cjs');
|
||||
const workstream = require('./lib/workstream.cjs');
|
||||
const docs = require('./lib/docs.cjs');
|
||||
|
||||
// ─── Arg parsing helpers ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -274,7 +279,7 @@ async function main() {
|
||||
const command = args[0];
|
||||
|
||||
if (!command) {
|
||||
error('Usage: gsd-tools <command> [args] [--raw] [--pick <field>] [--cwd <path>] [--ws <name>]\nCommands: state, resolve-model, find-phase, commit, verify-summary, verify, frontmatter, template, generate-slug, current-timestamp, list-todos, verify-path-exists, config-ensure-section, config-new-project, init, workstream');
|
||||
error('Usage: gsd-tools <command> [args] [--raw] [--pick <field>] [--cwd <path>] [--ws <name>]\nCommands: state, resolve-model, find-phase, commit, verify-summary, verify, frontmatter, template, generate-slug, current-timestamp, list-todos, verify-path-exists, config-ensure-section, config-new-project, init, workstream, docs-init');
|
||||
}
|
||||
|
||||
// Multi-repo guard: resolve project root for commands that read/write .planning/.
|
||||
@@ -498,8 +503,11 @@ async function runCommand(command, args, cwd, raw) {
|
||||
verify.cmdVerifyArtifacts(cwd, args[2], raw);
|
||||
} else if (subcommand === 'key-links') {
|
||||
verify.cmdVerifyKeyLinks(cwd, args[2], raw);
|
||||
} else if (subcommand === 'schema-drift') {
|
||||
const skipFlag = args.includes('--skip');
|
||||
verify.cmdVerifySchemaDrift(cwd, args[2], skipFlag, raw);
|
||||
} else {
|
||||
error('Unknown verify subcommand. Available: plan-structure, phase-completeness, references, commits, artifacts, key-links');
|
||||
error('Unknown verify subcommand. Available: plan-structure, phase-completeness, references, commits, artifacts, key-links, schema-drift');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -910,6 +918,13 @@ async function runCommand(command, args, cwd, raw) {
|
||||
break;
|
||||
}
|
||||
|
||||
// ─── Documentation ────────────────────────────────────────────────────
|
||||
|
||||
case 'docs-init': {
|
||||
docs.cmdDocsInit(cwd, raw);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
error(`Unknown command: ${command}`);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,33 @@ const { safeReadFile, loadConfig, isGitIgnored, execGit, normalizePhaseName, com
|
||||
const { extractFrontmatter } = require('./frontmatter.cjs');
|
||||
const { MODEL_PROFILES } = require('./model-profiles.cjs');
|
||||
|
||||
/**
|
||||
* Determine phase status by checking plan/summary counts AND verification state.
|
||||
* Introduces "Executed" for phases with all summaries but no passing verification.
|
||||
*/
|
||||
function determinePhaseStatus(plans, summaries, phaseDir, defaultPending) {
|
||||
if (plans === 0) return defaultPending;
|
||||
if (summaries < plans && summaries > 0) return 'In Progress';
|
||||
if (summaries < plans) return 'Planned';
|
||||
|
||||
// summaries >= plans — check verification
|
||||
try {
|
||||
const files = fs.readdirSync(phaseDir);
|
||||
const verificationFile = files.find(f => f === 'VERIFICATION.md' || f.endsWith('-VERIFICATION.md'));
|
||||
if (verificationFile) {
|
||||
const content = fs.readFileSync(path.join(phaseDir, verificationFile), 'utf-8');
|
||||
if (/status:\s*passed/i.test(content)) return 'Complete';
|
||||
if (/status:\s*human_needed/i.test(content)) return 'Needs Review';
|
||||
if (/status:\s*gaps_found/i.test(content)) return 'Executed';
|
||||
// Verification exists but unrecognized status — treat as executed
|
||||
return 'Executed';
|
||||
}
|
||||
} catch { /* directory read failed — fall through */ }
|
||||
|
||||
// No verification file — executed but not verified
|
||||
return 'Executed';
|
||||
}
|
||||
|
||||
function cmdGenerateSlug(text, raw) {
|
||||
if (!text) {
|
||||
error('text required for slug generation');
|
||||
@@ -16,7 +43,8 @@ function cmdGenerateSlug(text, raw) {
|
||||
const slug = text
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '');
|
||||
.replace(/^-+|-+$/g, '')
|
||||
.substring(0, 60);
|
||||
|
||||
const result = { slug };
|
||||
output(result, raw, slug);
|
||||
@@ -254,7 +282,7 @@ function cmdCommit(cwd, message, files, raw, amend, noVerify) {
|
||||
let branchName = null;
|
||||
if (config.branching_strategy === 'phase') {
|
||||
// Determine which phase we're committing for from the file paths
|
||||
const phaseMatch = (files || []).join(' ').match(/(\d+)-/);
|
||||
const phaseMatch = (files || []).join(' ').match(/(\d+(?:\.\d+)*)-/);
|
||||
if (phaseMatch) {
|
||||
const phaseNum = phaseMatch[1];
|
||||
const phaseInfo = findPhaseInternal(cwd, phaseNum);
|
||||
@@ -528,11 +556,7 @@ function cmdProgressRender(cwd, format, raw) {
|
||||
totalPlans += plans;
|
||||
totalSummaries += summaries;
|
||||
|
||||
let status;
|
||||
if (plans === 0) status = 'Pending';
|
||||
else if (summaries >= plans) status = 'Complete';
|
||||
else if (summaries > 0) status = 'In Progress';
|
||||
else status = 'Planned';
|
||||
const status = determinePhaseStatus(plans, summaries, path.join(phasesDir, dir), 'Pending');
|
||||
|
||||
phases.push({ number: phaseNum, name: phaseName, plans, summaries, status });
|
||||
}
|
||||
@@ -828,18 +852,14 @@ function cmdStats(cwd, format, raw) {
|
||||
totalPlans += plans;
|
||||
totalSummaries += summaries;
|
||||
|
||||
let status;
|
||||
if (plans === 0) status = 'Not Started';
|
||||
else if (summaries >= plans) status = 'Complete';
|
||||
else if (summaries > 0) status = 'In Progress';
|
||||
else status = 'Planned';
|
||||
const status = determinePhaseStatus(plans, summaries, path.join(phasesDir, dir), 'Not Started');
|
||||
|
||||
const existing = phasesByNumber.get(phaseNum);
|
||||
phasesByNumber.set(phaseNum, {
|
||||
number: phaseNum,
|
||||
name: existing?.name || phaseName,
|
||||
plans,
|
||||
summaries,
|
||||
plans: (existing?.plans || 0) + plans,
|
||||
summaries: (existing?.summaries || 0) + summaries,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ const VALID_CONFIG_KEYS = new Set([
|
||||
'workflow.discuss_mode',
|
||||
'workflow.skip_discuss',
|
||||
'workflow._auto_chain_active',
|
||||
'workflow.use_worktrees',
|
||||
'git.branching_strategy', 'git.phase_branch_template', 'git.milestone_branch_template', 'git.quick_branch_template',
|
||||
'planning.commit_docs', 'planning.search_gitignored',
|
||||
'hooks.context_warnings',
|
||||
'project_code', 'phase_naming',
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -132,6 +134,8 @@ function buildNewProjectConfig(userChoices) {
|
||||
hooks: {
|
||||
context_warnings: true,
|
||||
},
|
||||
project_code: null,
|
||||
phase_naming: 'sequential',
|
||||
agent_skills: {},
|
||||
};
|
||||
|
||||
|
||||
@@ -217,6 +217,7 @@ function loadConfig(cwd) {
|
||||
resolve_model_ids: false, // false: return alias as-is | true: map to full Claude model ID | "omit": return '' (runtime uses its default)
|
||||
context_window: 200000, // default 200k; set to 1000000 for Opus/Sonnet 4.6 1M models
|
||||
phase_naming: 'sequential', // 'sequential' (default, auto-increment) or 'custom' (arbitrary string IDs)
|
||||
project_code: null, // optional short prefix for phase dirs (e.g., 'CK' → 'CK-01-foundation')
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -308,6 +309,7 @@ function loadConfig(cwd) {
|
||||
resolve_model_ids: get('resolve_model_ids') ?? defaults.resolve_model_ids,
|
||||
context_window: get('context_window') ?? defaults.context_window,
|
||||
phase_naming: get('phase_naming') ?? defaults.phase_naming,
|
||||
project_code: get('project_code') ?? defaults.project_code,
|
||||
model_overrides: parsed.model_overrides || null,
|
||||
agent_skills: parsed.agent_skills || {},
|
||||
};
|
||||
@@ -619,8 +621,10 @@ function escapeRegex(value) {
|
||||
|
||||
function normalizePhaseName(phase) {
|
||||
const str = String(phase);
|
||||
// Strip optional project_code prefix (e.g., 'CK-01' → '01')
|
||||
const stripped = str.replace(/^[A-Z]{1,6}-(?=\d)/, '');
|
||||
// Standard numeric phases: 1, 01, 12A, 12.1
|
||||
const match = str.match(/^(\d+)([A-Z])?((?:\.\d+)*)/i);
|
||||
const match = stripped.match(/^(\d+)([A-Z])?((?:\.\d+)*)/i);
|
||||
if (match) {
|
||||
const padded = match[1].padStart(2, '0');
|
||||
const letter = match[2] ? match[2].toUpperCase() : '';
|
||||
@@ -632,8 +636,11 @@ function normalizePhaseName(phase) {
|
||||
}
|
||||
|
||||
function comparePhaseNum(a, b) {
|
||||
const pa = String(a).match(/^(\d+)([A-Z])?((?:\.\d+)*)/i);
|
||||
const pb = String(b).match(/^(\d+)([A-Z])?((?:\.\d+)*)/i);
|
||||
// Strip optional project_code prefix before comparing (e.g., 'CK-01-name' → '01-name')
|
||||
const sa = String(a).replace(/^[A-Z]{1,6}-/, '');
|
||||
const sb = String(b).replace(/^[A-Z]{1,6}-/, '');
|
||||
const pa = sa.match(/^(\d+)([A-Z])?((?:\.\d+)*)/i);
|
||||
const pb = sb.match(/^(\d+)([A-Z])?((?:\.\d+)*)/i);
|
||||
// If either is non-numeric (custom ID), fall back to string comparison
|
||||
if (!pa || !pb) return String(a).localeCompare(String(b));
|
||||
const intDiff = parseInt(pa[1], 10) - parseInt(pb[1], 10);
|
||||
@@ -668,12 +675,17 @@ function searchPhaseInDir(baseDir, relBase, normalized) {
|
||||
if (d.startsWith(normalized)) return true;
|
||||
// For custom IDs like PROJ-42, match case-insensitively
|
||||
if (d.toUpperCase().startsWith(normalized.toUpperCase())) return true;
|
||||
// Strip optional project_code prefix (e.g., 'CK-01-name' → '01-name') and retry
|
||||
const stripped = d.replace(/^[A-Z]{1,6}-/, '');
|
||||
if (stripped.startsWith(normalized)) return true;
|
||||
if (stripped.toUpperCase().startsWith(normalized.toUpperCase())) return true;
|
||||
return false;
|
||||
});
|
||||
if (!match) return null;
|
||||
|
||||
// Extract phase number and name — supports both numeric (01-name) and custom (PROJ-42-name)
|
||||
const dirMatch = match.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i)
|
||||
// Extract phase number and name — supports numeric (01-name), project-code-prefixed (CK-01-name), and custom (PROJ-42-name)
|
||||
const dirMatch = match.match(/^(?:[A-Z]{1,6}-)(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i)
|
||||
|| match.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i)
|
||||
|| match.match(/^([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*)-(.+)/i)
|
||||
|| [null, match, null];
|
||||
const phaseNumber = dirMatch ? dirMatch[1] : normalized;
|
||||
@@ -1061,7 +1073,7 @@ function pathExistsInternal(cwd, targetPath) {
|
||||
|
||||
function generateSlugInternal(text) {
|
||||
if (!text) return null;
|
||||
return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
||||
return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').substring(0, 60);
|
||||
}
|
||||
|
||||
function getMilestoneInfo(cwd) {
|
||||
|
||||
267
get-shit-done/bin/lib/docs.cjs
Normal file
267
get-shit-done/bin/lib/docs.cjs
Normal file
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* Docs — Commands for the docs-update workflow
|
||||
*
|
||||
* Provides `cmdDocsInit` which returns project signals, existing doc inventory
|
||||
* with GSD marker detection, doc tooling detection, monorepo awareness, and
|
||||
* model resolution. Used by Phase 2 to route doc generation appropriately.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { output, loadConfig, resolveModelInternal, pathExistsInternal, toPosixPath, checkAgentsInstalled } = require('./core.cjs');
|
||||
|
||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||
|
||||
const GSD_MARKER = '<!-- generated-by: gsd-doc-writer -->';
|
||||
|
||||
const SKIP_DIRS = new Set([
|
||||
'node_modules', '.git', '.planning', '.claude', '__pycache__',
|
||||
'target', 'dist', 'build', '.next', '.nuxt', 'coverage',
|
||||
'.vscode', '.idea',
|
||||
]);
|
||||
|
||||
// ─── Private helpers ──────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Check whether a file begins with the GSD doc writer marker.
|
||||
* Reads the first 500 bytes only — avoids loading large files.
|
||||
*
|
||||
* @param {string} filePath - Absolute path to the file
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function hasGsdMarker(filePath) {
|
||||
try {
|
||||
const buf = Buffer.alloc(500);
|
||||
const fd = fs.openSync(filePath, 'r');
|
||||
const bytesRead = fs.readSync(fd, buf, 0, 500, 0);
|
||||
fs.closeSync(fd);
|
||||
return buf.slice(0, bytesRead).toString('utf-8').includes(GSD_MARKER);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively scan the project root (immediate .md files) and docs/ directory
|
||||
* (up to 4 levels deep) for Markdown files, excluding dirs in SKIP_DIRS.
|
||||
*
|
||||
* @param {string} cwd - Project root
|
||||
* @returns {Array<{path: string, has_gsd_marker: boolean}>}
|
||||
*/
|
||||
function scanExistingDocs(cwd) {
|
||||
const MAX_DEPTH = 4;
|
||||
const results = [];
|
||||
|
||||
/**
|
||||
* Recursively walk a directory for .md files up to MAX_DEPTH levels.
|
||||
* @param {string} dir - Directory to scan
|
||||
* @param {number} depth - Current depth (1-based)
|
||||
*/
|
||||
function walkDir(dir, depth) {
|
||||
if (depth > MAX_DEPTH) return;
|
||||
try {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (SKIP_DIRS.has(entry.name)) continue;
|
||||
const abs = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
walkDir(abs, depth + 1);
|
||||
} else if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
|
||||
const rel = toPosixPath(path.relative(cwd, abs));
|
||||
results.push({ path: rel, has_gsd_marker: hasGsdMarker(abs) });
|
||||
}
|
||||
}
|
||||
} catch { /* directory may not exist — best-effort */ }
|
||||
}
|
||||
|
||||
// Scan root-level .md files (non-recursive)
|
||||
try {
|
||||
const entries = fs.readdirSync(cwd, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
|
||||
const abs = path.join(cwd, entry.name);
|
||||
const rel = toPosixPath(path.relative(cwd, abs));
|
||||
results.push({ path: rel, has_gsd_marker: hasGsdMarker(abs) });
|
||||
}
|
||||
}
|
||||
} catch { /* best-effort */ }
|
||||
|
||||
// Recursively scan docs/ directory
|
||||
const docsDir = path.join(cwd, 'docs');
|
||||
walkDir(docsDir, 1);
|
||||
|
||||
// Fallback: if docs/ does not exist, try documentation/ or doc/
|
||||
try {
|
||||
fs.statSync(docsDir);
|
||||
} catch {
|
||||
const alternatives = ['documentation', 'doc'];
|
||||
for (const alt of alternatives) {
|
||||
const altDir = path.join(cwd, alt);
|
||||
try {
|
||||
const stat = fs.statSync(altDir);
|
||||
if (stat.isDirectory()) {
|
||||
walkDir(altDir, 1);
|
||||
break;
|
||||
}
|
||||
} catch { /* not present */ }
|
||||
}
|
||||
}
|
||||
|
||||
return results.sort((a, b) => a.path.localeCompare(b.path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect project type signals from the filesystem and package.json.
|
||||
* All checks are best-effort and never throw.
|
||||
*
|
||||
* @param {string} cwd - Project root
|
||||
* @returns {Object} Boolean signal fields
|
||||
*/
|
||||
function detectProjectType(cwd) {
|
||||
const exists = (rel) => {
|
||||
try { return pathExistsInternal(cwd, rel); } catch { return false; }
|
||||
};
|
||||
|
||||
// has_cli_bin: package.json has a `bin` field
|
||||
let has_cli_bin = false;
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
|
||||
has_cli_bin = !!(pkg.bin && (typeof pkg.bin === 'string' || Object.keys(pkg.bin).length > 0));
|
||||
} catch { /* no package.json or invalid JSON */ }
|
||||
|
||||
// is_monorepo: pnpm-workspace.yaml, lerna.json, or package.json workspaces
|
||||
let is_monorepo = exists('pnpm-workspace.yaml') || exists('lerna.json');
|
||||
if (!is_monorepo) {
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
|
||||
is_monorepo = Array.isArray(pkg.workspaces) && pkg.workspaces.length > 0;
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
// has_tests: common test directories or test frameworks in devDependencies
|
||||
let has_tests = exists('test') || exists('tests') || exists('__tests__') || exists('spec');
|
||||
if (!has_tests) {
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
|
||||
const devDeps = Object.keys(pkg.devDependencies || {});
|
||||
has_tests = devDeps.some(d => ['vitest', 'jest', 'mocha', 'jasmine', 'ava'].includes(d));
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
// has_deploy_config: various deployment config files
|
||||
const deployFiles = [
|
||||
'Dockerfile', 'docker-compose.yml', 'docker-compose.yaml',
|
||||
'fly.toml', 'render.yaml', 'vercel.json', 'netlify.toml', 'railway.json',
|
||||
'.github/workflows/deploy.yml', '.github/workflows/deploy.yaml',
|
||||
];
|
||||
const has_deploy_config = deployFiles.some(f => exists(f));
|
||||
|
||||
return {
|
||||
has_package_json: exists('package.json'),
|
||||
has_api_routes: (
|
||||
exists('src/app/api') || exists('routes') || exists('src/routes') ||
|
||||
exists('api') || exists('server')
|
||||
),
|
||||
has_cli_bin,
|
||||
is_open_source: exists('LICENSE') || exists('LICENSE.md'),
|
||||
has_deploy_config,
|
||||
is_monorepo,
|
||||
has_tests,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect known documentation tooling in the project.
|
||||
*
|
||||
* @param {string} cwd - Project root
|
||||
* @returns {Object} Boolean detection fields
|
||||
*/
|
||||
function detectDocTooling(cwd) {
|
||||
const exists = (rel) => {
|
||||
try { return pathExistsInternal(cwd, rel); } catch { return false; }
|
||||
};
|
||||
|
||||
return {
|
||||
docusaurus: exists('docusaurus.config.js') || exists('docusaurus.config.ts'),
|
||||
vitepress: (
|
||||
exists('.vitepress/config.js') ||
|
||||
exists('.vitepress/config.ts') ||
|
||||
exists('.vitepress/config.mts')
|
||||
),
|
||||
mkdocs: exists('mkdocs.yml'),
|
||||
storybook: exists('.storybook'),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract monorepo workspace globs from pnpm-workspace.yaml, package.json
|
||||
* workspaces, or lerna.json.
|
||||
*
|
||||
* @param {string} cwd - Project root
|
||||
* @returns {string[]} Array of workspace glob patterns, or [] if not a monorepo
|
||||
*/
|
||||
function detectMonorepoWorkspaces(cwd) {
|
||||
// pnpm-workspace.yaml
|
||||
try {
|
||||
const content = fs.readFileSync(path.join(cwd, 'pnpm-workspace.yaml'), 'utf-8');
|
||||
const lines = content.split('\n');
|
||||
const workspaces = [];
|
||||
for (const line of lines) {
|
||||
const m = line.match(/^\s*-\s+['"]?(.+?)['"]?\s*$/);
|
||||
if (m) workspaces.push(m[1].trim());
|
||||
}
|
||||
if (workspaces.length > 0) return workspaces;
|
||||
} catch { /* not present */ }
|
||||
|
||||
// package.json workspaces
|
||||
try {
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
|
||||
if (Array.isArray(pkg.workspaces) && pkg.workspaces.length > 0) {
|
||||
return pkg.workspaces;
|
||||
}
|
||||
} catch { /* not present or invalid */ }
|
||||
|
||||
// lerna.json
|
||||
try {
|
||||
const lerna = JSON.parse(fs.readFileSync(path.join(cwd, 'lerna.json'), 'utf-8'));
|
||||
if (Array.isArray(lerna.packages) && lerna.packages.length > 0) {
|
||||
return lerna.packages;
|
||||
}
|
||||
} catch { /* not present or invalid */ }
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
// ─── Public commands ──────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Return JSON context for the docs-update workflow: project signals, existing
|
||||
* doc inventory, doc tooling detection, monorepo workspaces, and model
|
||||
* resolution. Follows the cmdInitMapCodebase pattern.
|
||||
*
|
||||
* @example
|
||||
* node gsd-tools.cjs docs-init --raw
|
||||
*
|
||||
* @param {string} cwd - Project root directory
|
||||
* @param {boolean} raw - Pass raw JSON flag through to output()
|
||||
*/
|
||||
function cmdDocsInit(cwd, raw) {
|
||||
const config = loadConfig(cwd);
|
||||
const result = {
|
||||
doc_writer_model: resolveModelInternal(cwd, 'gsd-doc-writer'),
|
||||
commit_docs: config.commit_docs,
|
||||
existing_docs: scanExistingDocs(cwd),
|
||||
project_type: detectProjectType(cwd),
|
||||
doc_tooling: detectDocTooling(cwd),
|
||||
monorepo_workspaces: detectMonorepoWorkspaces(cwd),
|
||||
planning_exists: pathExistsInternal(cwd, '.planning'),
|
||||
};
|
||||
// Inject project_root and agent installation status (mirrors withProjectRoot in init.cjs)
|
||||
result.project_root = cwd;
|
||||
const agentStatus = checkAgentsInstalled();
|
||||
result.agents_installed = agentStatus.agents_installed;
|
||||
result.missing_agents = agentStatus.missing_agents;
|
||||
output(result, raw);
|
||||
}
|
||||
|
||||
module.exports = { cmdDocsInit };
|
||||
@@ -108,6 +108,7 @@ function cmdInitExecutePhase(cwd, phase, raw) {
|
||||
// Branch name (pre-computed)
|
||||
branch_name: config.branching_strategy === 'phase' && phaseInfo
|
||||
? config.phase_branch_template
|
||||
.replace('{project}', config.project_code || '')
|
||||
.replace('{phase}', phaseInfo.phase_number)
|
||||
.replace('{slug}', phaseInfo.phase_slug || 'phase')
|
||||
: config.branching_strategy === 'milestone'
|
||||
|
||||
@@ -22,6 +22,8 @@ const MODEL_PROFILES = {
|
||||
'gsd-ui-researcher': { quality: 'opus', balanced: 'sonnet', budget: 'haiku' },
|
||||
'gsd-ui-checker': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku' },
|
||||
'gsd-ui-auditor': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku' },
|
||||
'gsd-doc-writer': { quality: 'opus', balanced: 'sonnet', budget: 'haiku' },
|
||||
'gsd-doc-verifier': { quality: 'sonnet', balanced: 'sonnet', budget: 'haiku' },
|
||||
};
|
||||
const VALID_PROFILES = Object.keys(MODEL_PROFILES['gsd-planner']);
|
||||
|
||||
|
||||
@@ -163,13 +163,22 @@ function cmdFindPhase(cwd, phase, raw) {
|
||||
const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
|
||||
const dirs = entries.filter(e => e.isDirectory()).map(e => e.name).sort((a, b) => comparePhaseNum(a, b));
|
||||
|
||||
const match = dirs.find(d => d.startsWith(normalized));
|
||||
const match = dirs.find(d => {
|
||||
if (d.startsWith(normalized)) return true;
|
||||
if (d.toUpperCase().startsWith(normalized.toUpperCase())) return true;
|
||||
// Strip optional project_code prefix (e.g., 'CK-01-name' → '01-name') and retry
|
||||
const stripped = d.replace(/^[A-Z]{1,6}-/, '');
|
||||
if (stripped.startsWith(normalized)) return true;
|
||||
return false;
|
||||
});
|
||||
if (!match) {
|
||||
output(notFound, raw, '');
|
||||
return;
|
||||
}
|
||||
|
||||
const dirMatch = match.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i);
|
||||
// Extract phase number — supports project-code-prefixed (CK-01-name), numeric (01-name), and custom IDs
|
||||
const dirMatch = match.match(/^(?:[A-Z]{1,6}-)(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i)
|
||||
|| match.match(/^(\d+[A-Z]?(?:\.\d+)*)-?(.*)/i);
|
||||
const phaseNumber = dirMatch ? dirMatch[1] : normalized;
|
||||
const phaseName = dirMatch && dirMatch[2] ? dirMatch[2] : null;
|
||||
|
||||
@@ -326,11 +335,15 @@ function cmdPhaseAdd(cwd, description, raw, customId) {
|
||||
let newPhaseId;
|
||||
let dirName;
|
||||
|
||||
// Optional project code prefix (e.g., 'CK' → 'CK-01-foundation')
|
||||
const projectCode = config.project_code || '';
|
||||
const prefix = projectCode ? `${projectCode}-` : '';
|
||||
|
||||
if (customId || config.phase_naming === 'custom') {
|
||||
// Custom phase naming: use provided ID or generate from description
|
||||
newPhaseId = customId || slug.toUpperCase().replace(/-/g, '-');
|
||||
if (!newPhaseId) error('--id required when phase_naming is "custom"');
|
||||
dirName = `${newPhaseId}-${slug}`;
|
||||
dirName = `${prefix}${newPhaseId}-${slug}`;
|
||||
} else {
|
||||
// Sequential mode: find highest integer phase number (in current milestone only)
|
||||
const phasePattern = /#{2,4}\s*Phase\s+(\d+)[A-Z]?(?:\.\d+)*:/gi;
|
||||
@@ -343,7 +356,7 @@ function cmdPhaseAdd(cwd, description, raw, customId) {
|
||||
|
||||
newPhaseId = maxPhase + 1;
|
||||
const paddedNum = String(newPhaseId).padStart(2, '0');
|
||||
dirName = `${paddedNum}-${slug}`;
|
||||
dirName = `${prefix}${paddedNum}-${slug}`;
|
||||
}
|
||||
|
||||
const dirPath = path.join(planningDir(cwd), 'phases', dirName);
|
||||
@@ -410,7 +423,7 @@ function cmdPhaseInsert(cwd, afterPhase, description, raw) {
|
||||
try {
|
||||
const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
|
||||
const dirs = entries.filter(e => e.isDirectory()).map(e => e.name);
|
||||
const decimalPattern = new RegExp(`^${normalizedBase}\\.(\\d+)`);
|
||||
const decimalPattern = new RegExp(`^(?:[A-Z]{1,6}-)?${normalizedBase}\\.(\\d+)`);
|
||||
for (const dir of dirs) {
|
||||
const dm = dir.match(decimalPattern);
|
||||
if (dm) existingDecimals.push(parseInt(dm[1], 10));
|
||||
@@ -419,7 +432,12 @@ function cmdPhaseInsert(cwd, afterPhase, description, raw) {
|
||||
|
||||
const nextDecimal = existingDecimals.length === 0 ? 1 : Math.max(...existingDecimals) + 1;
|
||||
const decimalPhase = `${normalizedBase}.${nextDecimal}`;
|
||||
const dirName = `${decimalPhase}-${slug}`;
|
||||
|
||||
// Optional project code prefix
|
||||
const config = loadConfig(cwd);
|
||||
const projectCode = config.project_code || '';
|
||||
const prefix = projectCode ? `${projectCode}-` : '';
|
||||
const dirName = `${prefix}${decimalPhase}-${slug}`;
|
||||
const dirPath = path.join(planningDir(cwd), 'phases', dirName);
|
||||
|
||||
// Create directory with .gitkeep so git tracks empty folders
|
||||
@@ -689,10 +707,12 @@ function cmdPhaseComplete(cwd, phaseNum, raw) {
|
||||
const cells = fullRow.split('|').slice(1, -1);
|
||||
if (cells.length === 5) {
|
||||
// 5-col: Phase | Milestone | Plans | Status | Completed
|
||||
cells[2] = ` ${summaryCount}/${planCount} `;
|
||||
cells[3] = ' Complete ';
|
||||
cells[4] = ` ${today} `;
|
||||
} else if (cells.length === 4) {
|
||||
// 4-col: Phase | Plans | Status | Completed
|
||||
cells[1] = ` ${summaryCount}/${planCount} `;
|
||||
cells[2] = ' Complete ';
|
||||
cells[3] = ` ${today} `;
|
||||
}
|
||||
@@ -709,6 +729,18 @@ function cmdPhaseComplete(cwd, phaseNum, raw) {
|
||||
`$1${summaryCount}/${planCount} plans complete`
|
||||
);
|
||||
|
||||
// Mark completed plan checkboxes (safety net for missed per-plan updates)
|
||||
for (const summaryFile of phaseInfo.summaries) {
|
||||
const planId = summaryFile.replace('-SUMMARY.md', '').replace('SUMMARY.md', '');
|
||||
if (!planId) continue;
|
||||
const planEscaped = escapeRegex(planId);
|
||||
const planCheckboxPattern = new RegExp(
|
||||
`(-\\s*\\[) (\\]\\s*${planEscaped})`,
|
||||
'i'
|
||||
);
|
||||
roadmapContent = roadmapContent.replace(planCheckboxPattern, '$1x$2');
|
||||
}
|
||||
|
||||
fs.writeFileSync(roadmapPath, roadmapContent, 'utf-8');
|
||||
|
||||
// Update REQUIREMENTS.md traceability for this phase's requirements
|
||||
|
||||
@@ -177,8 +177,12 @@ const CLAUDE_MD_FALLBACKS = {
|
||||
stack: 'Technology stack not yet documented. Will populate after codebase mapping or first phase.',
|
||||
conventions: 'Conventions not yet established. Will populate as patterns emerge during development.',
|
||||
architecture: 'Architecture not yet mapped. Follow existing patterns found in the codebase.',
|
||||
skills: 'No project skills found. Add skills to any of: `.claude/skills/`, `.agents/skills/`, `.cursor/skills/`, or `.github/skills/` with a `SKILL.md` index file.',
|
||||
};
|
||||
|
||||
// Directories where project skills may live (checked in order)
|
||||
const SKILL_SEARCH_DIRS = ['.claude/skills', '.agents/skills', '.cursor/skills', '.github/skills'];
|
||||
|
||||
const CLAUDE_MD_WORKFLOW_ENFORCEMENT = [
|
||||
'Before using Edit, Write, or other file-changing tools, start work through a GSD command so planning artifacts and execution context stay in sync.',
|
||||
'',
|
||||
@@ -375,6 +379,96 @@ function generateWorkflowSection() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover project skills from standard directories and extract frontmatter
|
||||
* (name + description) for each. Returns a table summary for CLAUDE.md so
|
||||
* agents know which skills are available at session startup (Layer 1 discovery).
|
||||
*/
|
||||
function generateSkillsSection(cwd) {
|
||||
const discovered = [];
|
||||
|
||||
for (const dir of SKILL_SEARCH_DIRS) {
|
||||
const absDir = path.join(cwd, dir);
|
||||
if (!fs.existsSync(absDir)) continue;
|
||||
|
||||
let entries;
|
||||
try {
|
||||
entries = fs.readdirSync(absDir, { withFileTypes: true });
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const entry of entries) {
|
||||
if (!entry.isDirectory()) continue;
|
||||
// Skip GSD's own installed skills — only surface project-specific skills
|
||||
if (entry.name.startsWith('gsd-')) continue;
|
||||
|
||||
const skillMdPath = path.join(absDir, entry.name, 'SKILL.md');
|
||||
if (!fs.existsSync(skillMdPath)) continue;
|
||||
|
||||
const content = safeReadFile(skillMdPath);
|
||||
if (!content) continue;
|
||||
|
||||
const frontmatter = extractSkillFrontmatter(content);
|
||||
const name = frontmatter.name || entry.name;
|
||||
const description = frontmatter.description || '';
|
||||
|
||||
// Avoid duplicates when same skill dir is symlinked from multiple locations
|
||||
if (discovered.some(s => s.name === name)) continue;
|
||||
|
||||
discovered.push({ name, description, path: `${dir}/${entry.name}` });
|
||||
}
|
||||
}
|
||||
|
||||
if (discovered.length === 0) {
|
||||
return { content: CLAUDE_MD_FALLBACKS.skills, source: 'skills/', hasFallback: true };
|
||||
}
|
||||
|
||||
const lines = ['| Skill | Description | Path |', '|-------|-------------|------|'];
|
||||
for (const skill of discovered) {
|
||||
// Sanitize table cell content (escape pipes)
|
||||
const desc = skill.description.replace(/\|/g, '\\|').replace(/\n/g, ' ').trim();
|
||||
const safeName = skill.name.replace(/\|/g, '\\|');
|
||||
lines.push(`| ${safeName} | ${desc} | \`${skill.path}/SKILL.md\` |`);
|
||||
}
|
||||
|
||||
return { content: lines.join('\n'), source: 'skills/', hasFallback: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract name and description from YAML-like frontmatter in a SKILL.md file.
|
||||
* Handles multi-line description values (continuation lines indented with spaces).
|
||||
*/
|
||||
function extractSkillFrontmatter(content) {
|
||||
const result = { name: '', description: '' };
|
||||
const fmMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
||||
if (!fmMatch) return result;
|
||||
|
||||
const fmBlock = fmMatch[1];
|
||||
const lines = fmBlock.split('\n');
|
||||
|
||||
let currentKey = '';
|
||||
for (const line of lines) {
|
||||
// Top-level key: value
|
||||
const kvMatch = line.match(/^(\w[\w-]*):\s*(.*)/);
|
||||
if (kvMatch) {
|
||||
currentKey = kvMatch[1];
|
||||
const value = kvMatch[2].trim();
|
||||
if (currentKey === 'name') result.name = value;
|
||||
if (currentKey === 'description') result.description = value;
|
||||
continue;
|
||||
}
|
||||
// Continuation line (indented) for multi-line values
|
||||
if (currentKey === 'description' && /^\s+/.test(line)) {
|
||||
result.description += ' ' + line.trim();
|
||||
} else {
|
||||
currentKey = '';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ─── Commands ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function cmdWriteProfile(cwd, options, raw) {
|
||||
@@ -815,12 +909,13 @@ function cmdGenerateClaudeProfile(cwd, options, raw) {
|
||||
}
|
||||
|
||||
function cmdGenerateClaudeMd(cwd, options, raw) {
|
||||
const MANAGED_SECTIONS = ['project', 'stack', 'conventions', 'architecture', 'workflow'];
|
||||
const MANAGED_SECTIONS = ['project', 'stack', 'conventions', 'architecture', 'skills', 'workflow'];
|
||||
const generators = {
|
||||
project: generateProjectSection,
|
||||
stack: generateStackSection,
|
||||
conventions: generateConventionsSection,
|
||||
architecture: generateArchitectureSection,
|
||||
skills: generateSkillsSection,
|
||||
workflow: generateWorkflowSection,
|
||||
};
|
||||
const sectionHeadings = {
|
||||
@@ -828,6 +923,7 @@ function cmdGenerateClaudeMd(cwd, options, raw) {
|
||||
stack: '## Technology Stack',
|
||||
conventions: '## Conventions',
|
||||
architecture: '## Architecture',
|
||||
skills: '## Project Skills',
|
||||
workflow: '## GSD Workflow Enforcement',
|
||||
};
|
||||
|
||||
|
||||
238
get-shit-done/bin/lib/schema-detect.cjs
Normal file
238
get-shit-done/bin/lib/schema-detect.cjs
Normal file
@@ -0,0 +1,238 @@
|
||||
/**
|
||||
* Schema Drift Detection — Detects schema-relevant file changes and verifies
|
||||
* that the appropriate database push command was executed during a phase.
|
||||
*
|
||||
* Prevents false-positive verification when schema files change but no push
|
||||
* occurs — TypeScript types come from config, not the live database, so
|
||||
* build/types pass on a broken state.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// ─── ORM Patterns ────────────────────────────────────────────────────────────
|
||||
//
|
||||
// Each entry maps a glob-like pattern to an ORM name. Patterns use forward
|
||||
// slashes internally — Windows backslash paths are normalized before matching.
|
||||
|
||||
const SCHEMA_PATTERNS = [
|
||||
// Payload CMS
|
||||
{ pattern: /^src\/collections\/.*\.ts$/, orm: 'payload' },
|
||||
{ pattern: /^src\/globals\/.*\.ts$/, orm: 'payload' },
|
||||
|
||||
// Prisma
|
||||
{ pattern: /^prisma\/schema\.prisma$/, orm: 'prisma' },
|
||||
{ pattern: /^prisma\/schema\/.*\.prisma$/, orm: 'prisma' },
|
||||
|
||||
// Drizzle
|
||||
{ pattern: /^drizzle\/schema\.ts$/, orm: 'drizzle' },
|
||||
{ pattern: /^src\/db\/schema\.ts$/, orm: 'drizzle' },
|
||||
{ pattern: /^drizzle\/.*\.ts$/, orm: 'drizzle' },
|
||||
|
||||
// Supabase
|
||||
{ pattern: /^supabase\/migrations\/.*\.sql$/, orm: 'supabase' },
|
||||
|
||||
// TypeORM
|
||||
{ pattern: /^src\/entities\/.*\.ts$/, orm: 'typeorm' },
|
||||
{ pattern: /^src\/migrations\/.*\.ts$/, orm: 'typeorm' },
|
||||
];
|
||||
|
||||
// ─── Push Commands & Evidence Patterns ───────────────────────────────────────
|
||||
//
|
||||
// For each ORM, the push command that agents should run, plus regex patterns
|
||||
// that indicate the push was actually executed (matched against execution logs,
|
||||
// SUMMARY.md content, and git commit messages).
|
||||
|
||||
const ORM_INFO = {
|
||||
payload: {
|
||||
pushCommand: 'npx payload migrate',
|
||||
envHint: 'CI=true PAYLOAD_MIGRATING=true npx payload migrate',
|
||||
interactiveWarning: 'Payload migrate may require interactive prompts — use CI=true PAYLOAD_MIGRATING=true to suppress',
|
||||
evidencePatterns: [
|
||||
/payload\s+migrate/i,
|
||||
/PAYLOAD_MIGRATING/,
|
||||
],
|
||||
},
|
||||
prisma: {
|
||||
pushCommand: 'npx prisma db push',
|
||||
envHint: 'npx prisma db push --accept-data-loss (if destructive changes are intended)',
|
||||
interactiveWarning: 'Prisma db push may prompt for confirmation on destructive changes — use --accept-data-loss to bypass',
|
||||
evidencePatterns: [
|
||||
/prisma\s+db\s+push/i,
|
||||
/prisma\s+migrate\s+deploy/i,
|
||||
/prisma\s+migrate\s+dev/i,
|
||||
],
|
||||
},
|
||||
drizzle: {
|
||||
pushCommand: 'npx drizzle-kit push',
|
||||
envHint: 'npx drizzle-kit push',
|
||||
interactiveWarning: null,
|
||||
evidencePatterns: [
|
||||
/drizzle-kit\s+push/i,
|
||||
/drizzle-kit\s+migrate/i,
|
||||
],
|
||||
},
|
||||
supabase: {
|
||||
pushCommand: 'supabase db push',
|
||||
envHint: 'supabase db push',
|
||||
interactiveWarning: 'Supabase db push may require authentication — ensure SUPABASE_ACCESS_TOKEN is set',
|
||||
evidencePatterns: [
|
||||
/supabase\s+db\s+push/i,
|
||||
/supabase\s+migration\s+up/i,
|
||||
],
|
||||
},
|
||||
typeorm: {
|
||||
pushCommand: 'npx typeorm migration:run',
|
||||
envHint: 'npx typeorm migration:run -d src/data-source.ts',
|
||||
interactiveWarning: null,
|
||||
evidencePatterns: [
|
||||
/typeorm\s+migration:run/i,
|
||||
/typeorm\s+schema:sync/i,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
// ─── Public API ──────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Detect schema-relevant files in a list of file paths.
|
||||
*
|
||||
* @param {string[]} files - List of file paths (relative to project root)
|
||||
* @returns {{ detected: boolean, matches: string[], orms: string[] }}
|
||||
*/
|
||||
function detectSchemaFiles(files) {
|
||||
const matches = [];
|
||||
const orms = new Set();
|
||||
|
||||
for (const rawFile of files) {
|
||||
// Normalize Windows backslash paths
|
||||
const file = rawFile.replace(/\\/g, '/');
|
||||
|
||||
for (const { pattern, orm } of SCHEMA_PATTERNS) {
|
||||
if (pattern.test(file)) {
|
||||
matches.push(rawFile);
|
||||
orms.add(orm);
|
||||
break; // One match per file is enough
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
detected: matches.length > 0,
|
||||
matches,
|
||||
orms: Array.from(orms),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ORM-specific push command info.
|
||||
*
|
||||
* @param {string} ormName - ORM identifier (payload, prisma, drizzle, supabase, typeorm)
|
||||
* @returns {{ pushCommand: string, envHint: string, interactiveWarning: string|null, evidencePatterns: RegExp[] } | null}
|
||||
*/
|
||||
function detectSchemaOrm(ormName) {
|
||||
return ORM_INFO[ormName] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for schema drift: schema files changed but no push evidence found.
|
||||
*
|
||||
* @param {string[]} changedFiles - Files changed during the phase
|
||||
* @param {string} executionLog - Combined text from SUMMARY.md, commit messages, and execution logs
|
||||
* @param {{ skipCheck?: boolean }} [options] - Options
|
||||
* @returns {{ driftDetected: boolean, blocking: boolean, schemaFiles: string[], orms: string[], unpushedOrms: string[], message: string, skipped?: boolean }}
|
||||
*/
|
||||
function checkSchemaDrift(changedFiles, executionLog, options = {}) {
|
||||
const { skipCheck = false } = options;
|
||||
|
||||
const detection = detectSchemaFiles(changedFiles);
|
||||
|
||||
if (!detection.detected) {
|
||||
return {
|
||||
driftDetected: false,
|
||||
blocking: false,
|
||||
schemaFiles: [],
|
||||
orms: [],
|
||||
unpushedOrms: [],
|
||||
message: '',
|
||||
};
|
||||
}
|
||||
|
||||
// Check which ORMs have push evidence in the execution log
|
||||
const pushedOrms = new Set();
|
||||
const unpushedOrms = [];
|
||||
|
||||
for (const orm of detection.orms) {
|
||||
const info = ORM_INFO[orm];
|
||||
if (!info) continue;
|
||||
|
||||
const hasPushEvidence = info.evidencePatterns.some(p => p.test(executionLog));
|
||||
if (hasPushEvidence) {
|
||||
pushedOrms.add(orm);
|
||||
} else {
|
||||
unpushedOrms.push(orm);
|
||||
}
|
||||
}
|
||||
|
||||
const driftDetected = unpushedOrms.length > 0;
|
||||
|
||||
if (!driftDetected) {
|
||||
return {
|
||||
driftDetected: false,
|
||||
blocking: false,
|
||||
schemaFiles: detection.matches,
|
||||
orms: detection.orms,
|
||||
unpushedOrms: [],
|
||||
message: '',
|
||||
};
|
||||
}
|
||||
|
||||
// Build actionable message
|
||||
const pushCommands = unpushedOrms
|
||||
.map(orm => {
|
||||
const info = ORM_INFO[orm];
|
||||
return info ? ` ${orm}: ${info.envHint || info.pushCommand}` : null;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
|
||||
const message = [
|
||||
'Schema drift detected: schema-relevant files changed but no database push was executed.',
|
||||
'',
|
||||
`Schema files changed: ${detection.matches.join(', ')}`,
|
||||
`ORMs requiring push: ${unpushedOrms.join(', ')}`,
|
||||
'',
|
||||
'Required push commands:',
|
||||
pushCommands,
|
||||
'',
|
||||
'Run the appropriate push command, or set GSD_SKIP_SCHEMA_CHECK=true to bypass this gate.',
|
||||
].join('\n');
|
||||
|
||||
if (skipCheck) {
|
||||
return {
|
||||
driftDetected: true,
|
||||
blocking: false,
|
||||
skipped: true,
|
||||
schemaFiles: detection.matches,
|
||||
orms: detection.orms,
|
||||
unpushedOrms,
|
||||
message: 'Schema drift detected but check was skipped (GSD_SKIP_SCHEMA_CHECK=true).',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
driftDetected: true,
|
||||
blocking: true,
|
||||
schemaFiles: detection.matches,
|
||||
orms: detection.orms,
|
||||
unpushedOrms,
|
||||
message,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SCHEMA_PATTERNS,
|
||||
ORM_INFO,
|
||||
detectSchemaFiles,
|
||||
detectSchemaOrm,
|
||||
checkSchemaDrift,
|
||||
};
|
||||
@@ -874,6 +874,84 @@ function cmdValidateAgents(cwd, raw) {
|
||||
}, raw);
|
||||
}
|
||||
|
||||
// ─── Schema Drift Detection ──────────────────────────────────────────────────
|
||||
|
||||
function cmdVerifySchemaDrift(cwd, phaseArg, skipFlag, raw) {
|
||||
const { detectSchemaFiles, checkSchemaDrift } = require('./schema-detect.cjs');
|
||||
|
||||
if (!phaseArg) {
|
||||
error('Usage: verify schema-drift <phase> [--skip]');
|
||||
return;
|
||||
}
|
||||
|
||||
// Find phase directory
|
||||
const pDir = planningDir(cwd);
|
||||
const phasesDir = path.join(pDir, 'phases');
|
||||
if (!fs.existsSync(phasesDir)) {
|
||||
output({ drift_detected: false, blocking: false, message: 'No phases directory' }, raw);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find matching phase directory
|
||||
let phaseDir = null;
|
||||
const entries = fs.readdirSync(phasesDir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isDirectory() && entry.name.includes(phaseArg)) {
|
||||
phaseDir = path.join(phasesDir, entry.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Also try exact match
|
||||
if (!phaseDir) {
|
||||
const exact = path.join(phasesDir, phaseArg);
|
||||
if (fs.existsSync(exact)) phaseDir = exact;
|
||||
}
|
||||
|
||||
if (!phaseDir) {
|
||||
output({ drift_detected: false, blocking: false, message: `Phase directory not found: ${phaseArg}` }, raw);
|
||||
return;
|
||||
}
|
||||
|
||||
// Collect files_modified from all PLAN.md files in the phase
|
||||
const allFiles = [];
|
||||
const planFiles = fs.readdirSync(phaseDir).filter(f => f.endsWith('-PLAN.md'));
|
||||
for (const pf of planFiles) {
|
||||
const content = fs.readFileSync(path.join(phaseDir, pf), 'utf-8');
|
||||
// Extract files_modified from frontmatter
|
||||
const fmMatch = content.match(/files_modified:\s*\[([^\]]*)\]/);
|
||||
if (fmMatch) {
|
||||
const files = fmMatch[1].split(',').map(f => f.trim()).filter(Boolean);
|
||||
allFiles.push(...files);
|
||||
}
|
||||
}
|
||||
|
||||
// Collect execution log from SUMMARY.md files
|
||||
let executionLog = '';
|
||||
const summaryFiles = fs.readdirSync(phaseDir).filter(f => f.endsWith('-SUMMARY.md'));
|
||||
for (const sf of summaryFiles) {
|
||||
executionLog += fs.readFileSync(path.join(phaseDir, sf), 'utf-8') + '\n';
|
||||
}
|
||||
|
||||
// Also check git commit messages for push evidence
|
||||
const gitLog = execGit(cwd, ['log', '--oneline', '--all', '-50']);
|
||||
if (gitLog.exitCode === 0) {
|
||||
executionLog += '\n' + gitLog.stdout;
|
||||
}
|
||||
|
||||
const result = checkSchemaDrift(allFiles, executionLog, { skipCheck: !!skipFlag });
|
||||
|
||||
output({
|
||||
drift_detected: result.driftDetected,
|
||||
blocking: result.blocking,
|
||||
schema_files: result.schemaFiles,
|
||||
orms: result.orms,
|
||||
unpushed_orms: result.unpushedOrms,
|
||||
message: result.message,
|
||||
skipped: result.skipped || false,
|
||||
}, raw);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
cmdVerifySummary,
|
||||
cmdVerifyPlanStructure,
|
||||
@@ -885,4 +963,5 @@ module.exports = {
|
||||
cmdValidateConsistency,
|
||||
cmdValidateHealth,
|
||||
cmdValidateAgents,
|
||||
cmdVerifySchemaDrift,
|
||||
};
|
||||
|
||||
@@ -339,9 +339,13 @@ function cmdWorkstreamComplete(cwd, name, options, raw) {
|
||||
// ─── Active Workstream Commands ──────────────────────────────────────────────
|
||||
|
||||
function cmdWorkstreamSet(cwd, name, raw) {
|
||||
if (!name) {
|
||||
if (!name || name === '--clear') {
|
||||
if (name !== '--clear') {
|
||||
error('Workstream name required. Usage: workstream set <name> (or workstream set --clear to unset)');
|
||||
}
|
||||
const previous = getActiveWorkstream(cwd);
|
||||
setActiveWorkstream(cwd, null);
|
||||
output({ active: null, cleared: true }, raw);
|
||||
output({ active: null, cleared: true, previous: previous || null }, raw);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
---
|
||||
description: Manage parallel workstreams — list, create, switch, status, progress, complete, and resume
|
||||
---
|
||||
|
||||
# /gsd:workstreams
|
||||
|
||||
Manage parallel workstreams for concurrent milestone work.
|
||||
|
||||
## Usage
|
||||
|
||||
`/gsd:workstreams [subcommand] [args]`
|
||||
|
||||
### Subcommands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `list` | List all workstreams with status |
|
||||
| `create <name>` | Create a new workstream |
|
||||
| `status <name>` | Detailed status for one workstream |
|
||||
| `switch <name>` | Set active workstream |
|
||||
| `progress` | Progress summary across all workstreams |
|
||||
| `complete <name>` | Archive a completed workstream |
|
||||
| `resume <name>` | Resume work in a workstream |
|
||||
|
||||
## Step 1: Parse Subcommand
|
||||
|
||||
Parse the user's input to determine which workstream operation to perform.
|
||||
If no subcommand given, default to `list`.
|
||||
|
||||
## Step 2: Execute Operation
|
||||
|
||||
### list
|
||||
Run: `node "$GSD_TOOLS" workstream list --raw --cwd "$CWD"`
|
||||
Display the workstreams in a table format showing name, status, current phase, and progress.
|
||||
|
||||
### create
|
||||
Run: `node "$GSD_TOOLS" workstream create <name> --raw --cwd "$CWD"`
|
||||
After creation, display the new workstream path and suggest next steps:
|
||||
- `/gsd:new-milestone --ws <name>` to set up the milestone
|
||||
|
||||
### status
|
||||
Run: `node "$GSD_TOOLS" workstream status <name> --raw --cwd "$CWD"`
|
||||
Display detailed phase breakdown and state information.
|
||||
|
||||
### switch
|
||||
Run: `node "$GSD_TOOLS" workstream set <name> --raw --cwd "$CWD"`
|
||||
Also set `GSD_WORKSTREAM` env var for the current session.
|
||||
|
||||
### progress
|
||||
Run: `node "$GSD_TOOLS" workstream progress --raw --cwd "$CWD"`
|
||||
Display a progress overview across all workstreams.
|
||||
|
||||
### complete
|
||||
Run: `node "$GSD_TOOLS" workstream complete <name> --raw --cwd "$CWD"`
|
||||
Archive the workstream to milestones/.
|
||||
|
||||
### resume
|
||||
Set the workstream as active and suggest `/gsd:resume-work --ws <name>`.
|
||||
|
||||
## Step 3: Display Results
|
||||
|
||||
Format the JSON output from gsd-tools into a human-readable display.
|
||||
Include the `${GSD_WS}` flag in any routing suggestions.
|
||||
@@ -24,6 +24,7 @@ Configuration options for `.planning/` directory behavior.
|
||||
| `git.phase_branch_template` | `"gsd/phase-{phase}-{slug}"` | Branch template for phase strategy |
|
||||
| `git.milestone_branch_template` | `"gsd/{milestone}-{slug}"` | Branch template for milestone strategy |
|
||||
| `git.quick_branch_template` | `null` | Optional branch template for quick-task runs |
|
||||
| `workflow.use_worktrees` | `true` | Whether executor agents run in isolated git worktrees. Set to `false` to disable worktrees — agents execute sequentially on the main working tree instead. Recommended for solo developers or when worktree merges cause issues. |
|
||||
</config_schema>
|
||||
|
||||
<commit_docs_behavior>
|
||||
|
||||
61
get-shit-done/templates/SECURITY.md
Normal file
61
get-shit-done/templates/SECURITY.md
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
phase: {N}
|
||||
slug: {phase-slug}
|
||||
status: draft
|
||||
threats_open: 0
|
||||
asvs_level: 1
|
||||
created: {date}
|
||||
---
|
||||
|
||||
# Phase {N} — Security
|
||||
|
||||
> Per-phase security contract: threat register, accepted risks, and audit trail.
|
||||
|
||||
---
|
||||
|
||||
## Trust Boundaries
|
||||
|
||||
| Boundary | Description | Data Crossing |
|
||||
|----------|-------------|---------------|
|
||||
| {boundary} | {description} | {data type / sensitivity} |
|
||||
|
||||
---
|
||||
|
||||
## Threat Register
|
||||
|
||||
| Threat ID | Category | Component | Disposition | Mitigation | Status |
|
||||
|-----------|----------|-----------|-------------|------------|--------|
|
||||
| T-{N}-01 | {STRIDE category} | {component} | {mitigate / accept / transfer} | {control or reference} | open |
|
||||
|
||||
*Status: open · closed*
|
||||
*Disposition: mitigate (implementation required) · accept (documented risk) · transfer (third-party)*
|
||||
|
||||
---
|
||||
|
||||
## Accepted Risks Log
|
||||
|
||||
| Risk ID | Threat Ref | Rationale | Accepted By | Date |
|
||||
|---------|------------|-----------|-------------|------|
|
||||
|
||||
*Accepted risks do not resurface in future audit runs.*
|
||||
|
||||
*If none: "No accepted risks."*
|
||||
|
||||
---
|
||||
|
||||
## Security Audit Trail
|
||||
|
||||
| Audit Date | Threats Total | Closed | Open | Run By |
|
||||
|------------|---------------|--------|------|--------|
|
||||
| {YYYY-MM-DD} | {N} | {N} | {N} | {name / agent} |
|
||||
|
||||
---
|
||||
|
||||
## Sign-Off
|
||||
|
||||
- [ ] All threats have a disposition (mitigate / accept / transfer)
|
||||
- [ ] Accepted risks documented in Accepted Risks Log
|
||||
- [ ] `threats_open: 0` confirmed
|
||||
- [ ] `status: verified` set in frontmatter
|
||||
|
||||
**Approval:** {pending / verified YYYY-MM-DD}
|
||||
@@ -36,9 +36,9 @@ created: {date}
|
||||
|
||||
## Per-Task Verification Map
|
||||
|
||||
| Task ID | Plan | Wave | Requirement | Test Type | Automated Command | File Exists | Status |
|
||||
|---------|------|------|-------------|-----------|-------------------|-------------|--------|
|
||||
| {N}-01-01 | 01 | 1 | REQ-{XX} | unit | `{command}` | ✅ / ❌ W0 | ⬜ pending |
|
||||
| Task ID | Plan | Wave | Requirement | Threat Ref | Secure Behavior | Test Type | Automated Command | File Exists | Status |
|
||||
|---------|------|------|-------------|------------|-----------------|-----------|-------------------|-------------|--------|
|
||||
| {N}-01-01 | 01 | 1 | REQ-{XX} | T-{N}-01 / — | {expected secure behavior or "N/A"} | unit | `{command}` | ✅ / ❌ W0 | ⬜ pending |
|
||||
|
||||
*Status: ⬜ pending · ✅ green · ❌ red · ⚠️ flaky*
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
Template for project-root `CLAUDE.md` — auto-generated by `gsd-tools generate-claude-md`.
|
||||
|
||||
Contains 6 marker-bounded sections. Each section is independently updatable.
|
||||
The `generate-claude-md` subcommand manages 5 sections (project, stack, conventions, architecture, workflow enforcement).
|
||||
Contains 7 marker-bounded sections. Each section is independently updatable.
|
||||
The `generate-claude-md` subcommand manages 6 sections (project, stack, conventions, architecture, skills, workflow enforcement).
|
||||
The profile section is managed exclusively by `generate-claude-profile`.
|
||||
|
||||
---
|
||||
@@ -66,6 +66,28 @@ Conventions not yet established. Will populate as patterns emerge during develop
|
||||
Architecture not yet mapped. Follow existing patterns found in the codebase.
|
||||
```
|
||||
|
||||
### Skills Section
|
||||
```
|
||||
<!-- GSD:skills-start source:skills/ -->
|
||||
## Project Skills
|
||||
|
||||
| Skill | Description | Path |
|
||||
| -------------- | --------------------- | ------------------------- |
|
||||
| {{skill_name}} | {{skill_description}} | `{{skill_path}}/SKILL.md` |
|
||||
<!-- GSD:skills-end -->
|
||||
```
|
||||
|
||||
**Fallback text:**
|
||||
```
|
||||
No project skills found. Add skills to any of: `.claude/skills/`, `.agents/skills/`, `.cursor/skills/`, or `.github/skills/` with a `SKILL.md` index file.
|
||||
```
|
||||
|
||||
**Discovery behavior:**
|
||||
- Scans `.claude/skills/`, `.agents/skills/`, `.cursor/skills/`, `.github/skills/` for subdirectories containing `SKILL.md`
|
||||
- Extracts `name` and `description` from YAML frontmatter (supports multi-line descriptions)
|
||||
- Skips GSD's own installed skills (directories starting with `gsd-`)
|
||||
- Deduplicates by skill name across directories
|
||||
|
||||
### Workflow Enforcement Section
|
||||
```
|
||||
<!-- GSD:workflow-start source:GSD defaults -->
|
||||
@@ -104,8 +126,9 @@ CLAUDE.md file and no profile section exists yet.
|
||||
2. **Stack** — Technology choices (what tools are used)
|
||||
3. **Conventions** — Code patterns and rules (how code is written)
|
||||
4. **Architecture** — System structure (how components fit together)
|
||||
5. **Workflow Enforcement** — Default GSD entry points for file-changing work
|
||||
6. **Profile** — Developer behavioral preferences (how to interact)
|
||||
5. **Skills** — Discovered project skills with name and description (what domain knowledge is available)
|
||||
6. **Workflow Enforcement** — Default GSD entry points for file-changing work
|
||||
7. **Profile** — Developer behavioral preferences (how to interact)
|
||||
|
||||
## Marker Format
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
"verifier": true,
|
||||
"auto_advance": false,
|
||||
"nyquist_validation": true,
|
||||
"security_enforcement": true,
|
||||
"security_asvs_level": 1,
|
||||
"security_block_on": "high",
|
||||
"discuss_mode": "discuss",
|
||||
"research_before_questions": false
|
||||
},
|
||||
@@ -40,5 +43,6 @@
|
||||
"hooks": {
|
||||
"context_warnings": true
|
||||
},
|
||||
"project_code": null,
|
||||
"agent_skills": {}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ Extract from init JSON: `commit_docs`, `date`, `timestamp`, `todo_count`, `todos
|
||||
|
||||
Ensure directories exist:
|
||||
```bash
|
||||
mkdir -p .planning/todos/pending .planning/todos/done
|
||||
mkdir -p .planning/todos/pending .planning/todos/completed
|
||||
```
|
||||
|
||||
Note existing areas from the todos array for consistency in infer_area step.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<purpose>
|
||||
|
||||
Drive all remaining milestone phases autonomously. For each incomplete phase: discuss → plan → execute using Skill() flat invocations. Pauses only for explicit user decisions (grey area acceptance, blockers, validation requests). Re-reads ROADMAP.md after each phase to catch dynamically inserted phases.
|
||||
Drive milestone phases autonomously — all remaining phases, or a single phase via `--only N`. For each incomplete phase: discuss → plan → execute using Skill() flat invocations. Pauses only for explicit user decisions (grey area acceptance, blockers, validation requests). Re-reads ROADMAP.md after each phase to catch dynamically inserted phases.
|
||||
|
||||
</purpose>
|
||||
|
||||
@@ -16,15 +16,23 @@ Read all files referenced by the invoking prompt's execution_context before star
|
||||
|
||||
## 1. Initialize
|
||||
|
||||
Parse `$ARGUMENTS` for `--from N` flag:
|
||||
Parse `$ARGUMENTS` for `--from N` and `--only N` flags:
|
||||
|
||||
```bash
|
||||
FROM_PHASE=""
|
||||
if echo "$ARGUMENTS" | grep -qE '\-\-from\s+[0-9]'; then
|
||||
FROM_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-from\s+[0-9]+\.?[0-9]*' | awk '{print $2}')
|
||||
fi
|
||||
|
||||
ONLY_PHASE=""
|
||||
if echo "$ARGUMENTS" | grep -qE '\-\-only\s+[0-9]'; then
|
||||
ONLY_PHASE=$(echo "$ARGUMENTS" | grep -oE '\-\-only\s+[0-9]+\.?[0-9]*' | awk '{print $2}')
|
||||
FROM_PHASE="$ONLY_PHASE"
|
||||
fi
|
||||
```
|
||||
|
||||
When `--only` is set, also set `FROM_PHASE` to the same value so existing filter logic applies.
|
||||
|
||||
Bootstrap via milestone-level init:
|
||||
|
||||
```bash
|
||||
@@ -48,7 +56,8 @@ Display startup banner:
|
||||
Phases: {phase_count} total, {completed_phases} complete
|
||||
```
|
||||
|
||||
If `FROM_PHASE` is set, display: `Starting from phase ${FROM_PHASE}`
|
||||
If `ONLY_PHASE` is set, display: `Single phase mode: Phase ${ONLY_PHASE}`
|
||||
Else if `FROM_PHASE` is set, display: `Starting from phase ${FROM_PHASE}`
|
||||
|
||||
</step>
|
||||
|
||||
@@ -68,6 +77,16 @@ Parse the JSON `phases` array.
|
||||
|
||||
**Apply `--from N` filter:** If `FROM_PHASE` was provided, additionally filter out phases where `number < FROM_PHASE` (use numeric comparison — handles decimal phases like "5.1").
|
||||
|
||||
**Apply `--only N` filter:** If `ONLY_PHASE` was provided, additionally filter OUT phases where `number != ONLY_PHASE`. This means the phase list will contain exactly one phase (or zero if already complete).
|
||||
|
||||
**If `ONLY_PHASE` is set and no phases remain** (phase already complete):
|
||||
|
||||
```
|
||||
Phase ${ONLY_PHASE} is already complete. Nothing to do.
|
||||
```
|
||||
|
||||
Exit cleanly.
|
||||
|
||||
**Sort by `number`** in numeric ascending order.
|
||||
|
||||
**If no incomplete phases remain:**
|
||||
@@ -117,7 +136,9 @@ For the current phase, display the progress banner:
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
Where N = current phase number (from the ROADMAP, e.g., 6), T = total milestone phases (from `phase_count` parsed in initialize step, e.g., 8), P = percentage of all milestone phases completed so far. Calculate P as: (number of phases with `disk_status` "complete" from the latest `roadmap analyze` / T × 100). Use █ for filled and ░ for empty segments in the progress bar (8 characters wide).
|
||||
Where N = current phase number (from the ROADMAP, e.g., 63), T = total milestone phases (from `phase_count` parsed in initialize step, e.g., 67). **Important:** T must be `phase_count` (the total number of phases in this milestone), NOT the count of remaining/incomplete phases. When phases are numbered 61-67, T=7 and the banner should read `Phase 63/7` (phase 63, 7 total in milestone), not `Phase 63/3` (which would confuse 3 remaining with 3 total). P = percentage of all milestone phases completed so far. Calculate P as: (number of phases with `disk_status` "complete" from the latest `roadmap analyze` / T × 100). Use █ for filled and ░ for empty segments in the progress bar (8 characters wide).
|
||||
|
||||
**Alternative display when phase numbers exceed total** (e.g., multi-milestone projects where phases are numbered globally): If N > T (phase number exceeds milestone phase count), use the format `Phase {N} ({position}/{T})` where `position` is the 1-based index of this phase among incomplete phases being processed. This prevents confusing displays like "Phase 63/5".
|
||||
|
||||
**3a. Smart Discuss**
|
||||
|
||||
@@ -211,6 +232,9 @@ Proceed to 3b.
|
||||
|
||||
**If SKIP_DISCUSS is `false` (or unset):** Execute the smart_discuss step for this phase.
|
||||
|
||||
**IMPORTANT — Discuss must be single-pass in autonomous mode.**
|
||||
The discuss step in `--auto` mode MUST NOT loop. If CONTEXT.md already exists after discuss completes, do NOT re-invoke discuss for the same phase. The `has_context` check below is authoritative — once true, discuss is done for this phase regardless of perceived "gaps" in the context file.
|
||||
|
||||
After smart_discuss completes, verify context was written:
|
||||
|
||||
```bash
|
||||
@@ -686,7 +710,9 @@ Decisions captured: {count} across {area_count} areas
|
||||
|
||||
## 4. Iterate
|
||||
|
||||
After each phase completes, re-read ROADMAP.md to catch phases inserted mid-execution (decimal phases like 5.1):
|
||||
**If `ONLY_PHASE` is set:** Do not iterate. Proceed directly to lifecycle step (which exits cleanly per single-phase mode).
|
||||
|
||||
**Otherwise:** After each phase completes, re-read ROADMAP.md to catch phases inserted mid-execution (decimal phases like 5.1):
|
||||
|
||||
```bash
|
||||
ROADMAP=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" roadmap analyze)
|
||||
@@ -715,7 +741,23 @@ If all phases complete, proceed to lifecycle step.
|
||||
|
||||
## 5. Lifecycle
|
||||
|
||||
After all phases complete, run the milestone lifecycle sequence: audit → complete → cleanup.
|
||||
**If `ONLY_PHASE` is set:** Skip lifecycle. A single phase does not trigger audit/complete/cleanup. Display:
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► AUTONOMOUS ▸ PHASE ${ONLY_PHASE} COMPLETE ✓
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Phase ${ONLY_PHASE}: ${PHASE_NAME} — Done
|
||||
Mode: Single phase (--only)
|
||||
|
||||
Lifecycle skipped — run /gsd:autonomous without --only
|
||||
after all phases complete to trigger audit/complete/cleanup.
|
||||
```
|
||||
|
||||
Exit cleanly.
|
||||
|
||||
**Otherwise:** After all phases complete, run the milestone lifecycle sequence: audit → complete → cleanup.
|
||||
|
||||
Display lifecycle transition banner:
|
||||
|
||||
@@ -852,7 +894,7 @@ When any phase operation fails or a blocker is detected, present 3 options via A
|
||||
Skipped: {list of skipped phases}
|
||||
Remaining: {list of remaining phases}
|
||||
|
||||
Resume with: /gsd:autonomous --from {next_phase}
|
||||
Resume with: /gsd:autonomous ${ONLY_PHASE ? "--only " + ONLY_PHASE : "--from " + next_phase}
|
||||
```
|
||||
|
||||
</step>
|
||||
@@ -882,10 +924,15 @@ When any phase operation fails or a blocker is detected, present 3 options via A
|
||||
- [ ] Complete-milestone invoked via Skill() with ${milestone_version} arg
|
||||
- [ ] Cleanup invoked via Skill() — internal confirmation is acceptable (CTRL-01)
|
||||
- [ ] Final completion banner displayed after lifecycle
|
||||
- [ ] Progress bar uses phase number / total milestone phases (not position among incomplete)
|
||||
- [ ] Progress bar uses phase number / total milestone phases (not position among incomplete), with fallback display when phase numbers exceed total
|
||||
- [ ] Smart discuss documents relationship to discuss-phase with CTRL-03 note
|
||||
- [ ] Frontend phases get UI-SPEC generated before planning (step 3a.5) if not already present
|
||||
- [ ] Frontend phases get UI review audit after successful execution (step 3d.5) if UI-SPEC exists
|
||||
- [ ] UI phase and UI review respect workflow.ui_phase and workflow.ui_review config toggles
|
||||
- [ ] UI review is advisory (non-blocking) — phase proceeds to iterate regardless of score
|
||||
- [ ] `--only N` restricts execution to exactly one phase
|
||||
- [ ] `--only N` skips lifecycle step (audit/complete/cleanup)
|
||||
- [ ] `--only N` exits cleanly after single phase completes
|
||||
- [ ] `--only N` on already-complete phase exits with message
|
||||
- [ ] `--only N` handle_blocker resume message uses --only flag
|
||||
</success_criteria>
|
||||
|
||||
@@ -126,7 +126,7 @@ Use AskUserQuestion:
|
||||
<step name="execute_action">
|
||||
**Work on it now:**
|
||||
```bash
|
||||
mv ".planning/todos/pending/[filename]" ".planning/todos/done/"
|
||||
mv ".planning/todos/pending/[filename]" ".planning/todos/completed/"
|
||||
```
|
||||
Update STATE.md todo count. Present problem/solution context. Begin work or ask how to proceed.
|
||||
|
||||
@@ -155,7 +155,7 @@ If todo was moved to done/, commit the change:
|
||||
|
||||
```bash
|
||||
git rm --cached .planning/todos/pending/[filename] 2>/dev/null || true
|
||||
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs: start work on todo - [title]" --files .planning/todos/done/[filename] .planning/STATE.md
|
||||
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs: start work on todo - [title]" --files .planning/todos/completed/[filename] .planning/STATE.md
|
||||
```
|
||||
|
||||
Tool respects `commit_docs` config and gitignore automatically.
|
||||
|
||||
@@ -55,6 +55,12 @@ gaps = [
|
||||
</step>
|
||||
|
||||
<step name="report_plan">
|
||||
**Read worktree config:**
|
||||
|
||||
```bash
|
||||
USE_WORKTREES=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
|
||||
```
|
||||
|
||||
**Report diagnosis plan to user:**
|
||||
|
||||
```
|
||||
@@ -92,7 +98,7 @@ For each gap, fill the debug-subagent-prompt template and spawn:
|
||||
Task(
|
||||
prompt=filled_debug_subagent_prompt + "\n\n<files_to_read>\n- {phase_dir}/{phase_num}-UAT.md\n- .planning/STATE.md\n</files_to_read>\n${AGENT_SKILLS_DEBUGGER}",
|
||||
subagent_type="gsd-debugger",
|
||||
isolation="worktree",
|
||||
${USE_WORKTREES !== "false" ? 'isolation="worktree",' : ''}
|
||||
description="Debug: {truth_short}"
|
||||
)
|
||||
```
|
||||
|
||||
@@ -155,6 +155,11 @@ Exit workflow.
|
||||
- In `discuss_areas`: for each discussion question, choose the recommended option (first option, or the one marked "recommended") without using AskUserQuestion
|
||||
- Log each auto-selected choice inline so the user can review decisions in the context file
|
||||
- After discussion completes, auto-advance to plan-phase (existing behavior)
|
||||
|
||||
**Chain mode** — If `--chain` is present in ARGUMENTS:
|
||||
- Discussion is fully interactive (questions, gray area selection — same as default mode)
|
||||
- After discussion completes, auto-advance to plan-phase → execute-phase (same as `--auto`)
|
||||
- This is the middle ground: user controls the discuss decisions, then plan+execute run autonomously
|
||||
</step>
|
||||
|
||||
<step name="check_existing">
|
||||
@@ -182,6 +187,26 @@ If "Skip": Exit workflow
|
||||
|
||||
**If doesn't exist:**
|
||||
|
||||
**Check for interrupted discussion checkpoint:**
|
||||
|
||||
```bash
|
||||
ls ${phase_dir}/*-DISCUSS-CHECKPOINT.json 2>/dev/null || true
|
||||
```
|
||||
|
||||
If a checkpoint file exists (previous session was interrupted before CONTEXT.md was written):
|
||||
|
||||
**If `--auto`:** Auto-select "Resume" — load checkpoint and continue from last completed area.
|
||||
|
||||
**Otherwise:** Use AskUserQuestion:
|
||||
- header: "Resume"
|
||||
- question: "Found interrupted discussion checkpoint ({N} areas completed out of {M}). Resume from where you left off?"
|
||||
- options:
|
||||
- "Resume" — Load checkpoint, skip completed areas, continue discussion
|
||||
- "Start fresh" — Delete checkpoint, start discussion from scratch
|
||||
|
||||
If "Resume": Parse the checkpoint JSON. Load `decisions` into the internal accumulator. Set `areas_completed` to skip those areas. Continue to `present_gray_areas` with only the remaining areas.
|
||||
If "Start fresh": Delete the checkpoint file. Continue as if no checkpoint existed.
|
||||
|
||||
Check `has_plans` and `plan_count` from init. **If `has_plans` is true:**
|
||||
|
||||
**If `--auto`:** Auto-select "Continue and replan after". Log: `[auto] Plans exist — continuing with context capture, will replan after.`
|
||||
@@ -640,6 +665,16 @@ Each answer (or answer set, in batch mode) should reveal the next question or ne
|
||||
```
|
||||
After all areas are auto-resolved, skip the "Explore more gray areas" prompt and proceed directly to write_context.
|
||||
|
||||
**CRITICAL — Auto-mode pass cap:**
|
||||
In `--auto` mode, the discuss step MUST complete in a **single pass**. After writing CONTEXT.md once, you are DONE — proceed immediately to write_context and then auto_advance. Do NOT re-read your own CONTEXT.md to find "gaps", "undefined types", or "missing decisions" and run additional passes. This creates a self-feeding loop where each pass generates references that the next pass treats as gaps, consuming unbounded time and resources.
|
||||
|
||||
Check the pass cap from config:
|
||||
```bash
|
||||
MAX_PASSES=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.max_discuss_passes 2>/dev/null || echo "3")
|
||||
```
|
||||
|
||||
If you have already written and committed CONTEXT.md, the discuss step is complete. Move on.
|
||||
|
||||
**Interactive mode (no `--auto`):**
|
||||
|
||||
**For each area:**
|
||||
@@ -719,6 +754,44 @@ Back to [current area]: [return to current question]"
|
||||
|
||||
Track deferred ideas internally.
|
||||
|
||||
**Incremental checkpoint — save after each area completes:**
|
||||
|
||||
After each area is resolved (user says "Next area" or area auto-resolves in `--auto` mode), immediately write a checkpoint file with all decisions captured so far. This prevents data loss if the session is interrupted mid-discussion.
|
||||
|
||||
**Checkpoint file:** `${phase_dir}/${padded_phase}-DISCUSS-CHECKPOINT.json`
|
||||
|
||||
Write after each area:
|
||||
```json
|
||||
{
|
||||
"phase": "{PHASE_NUM}",
|
||||
"phase_name": "{phase_name}",
|
||||
"timestamp": "{ISO timestamp}",
|
||||
"areas_completed": ["Area 1", "Area 2"],
|
||||
"areas_remaining": ["Area 3", "Area 4"],
|
||||
"decisions": {
|
||||
"Area 1": [
|
||||
{"question": "...", "answer": "...", "options_presented": ["..."]},
|
||||
{"question": "...", "answer": "...", "options_presented": ["..."]}
|
||||
],
|
||||
"Area 2": [
|
||||
{"question": "...", "answer": "...", "options_presented": ["..."]}
|
||||
]
|
||||
},
|
||||
"deferred_ideas": ["..."],
|
||||
"canonical_refs": ["..."]
|
||||
}
|
||||
```
|
||||
|
||||
This is a structured checkpoint, not the final CONTEXT.md — the `write_context` step still produces the canonical output. But if the session dies, the next `gsd:discuss-phase` invocation can detect this checkpoint and offer to resume from it instead of starting from scratch.
|
||||
|
||||
**On session resume:** In the `check_existing` step, also check for `*-DISCUSS-CHECKPOINT.json`. If found and no CONTEXT.md exists:
|
||||
- Display: "Found interrupted discussion checkpoint ({N} areas completed). Resume from checkpoint?"
|
||||
- Options: "Resume" / "Start fresh"
|
||||
- On "Resume": Load the checkpoint, skip completed areas, continue from where it left off
|
||||
- On "Start fresh": Delete the checkpoint, proceed as normal
|
||||
|
||||
**After write_context completes successfully:** Delete the checkpoint file — the canonical CONTEXT.md now has all decisions.
|
||||
|
||||
**Track discussion log data internally:**
|
||||
For each question asked, accumulate:
|
||||
- Area name
|
||||
@@ -880,6 +953,7 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
|
||||
---
|
||||
|
||||
**Also available:**
|
||||
- `/gsd:discuss-phase ${PHASE} --chain ${GSD_WS}` — re-run with auto plan+execute after
|
||||
- `/gsd:plan-phase ${PHASE} --skip-research ${GSD_WS}` — plan without research
|
||||
- `/gsd:ui-phase ${PHASE} ${GSD_WS}` — generate UI design contract before planning (if phase has frontend work)
|
||||
- Review/edit CONTEXT.md before continuing
|
||||
@@ -933,6 +1007,12 @@ Created: .planning/phases/${PADDED_PHASE}-${SLUG}/${PADDED_PHASE}-CONTEXT.md
|
||||
|
||||
Write file.
|
||||
|
||||
**Clean up checkpoint file** — CONTEXT.md is now the canonical record:
|
||||
|
||||
```bash
|
||||
rm -f "${phase_dir}/${padded_phase}-DISCUSS-CHECKPOINT.json"
|
||||
```
|
||||
|
||||
Commit phase context and discussion log:
|
||||
|
||||
```bash
|
||||
@@ -961,10 +1041,10 @@ node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs(state): record
|
||||
<step name="auto_advance">
|
||||
Check for auto-advance trigger:
|
||||
|
||||
1. Parse `--auto` flag from $ARGUMENTS
|
||||
2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
|
||||
1. Parse `--auto` and `--chain` flags from $ARGUMENTS
|
||||
2. **Sync chain flag with intent** — if user invoked manually (no `--auto` and no `--chain`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
|
||||
```bash
|
||||
if [[ ! "$ARGUMENTS" =~ --auto ]]; then
|
||||
if [[ ! "$ARGUMENTS" =~ --auto ]] && [[ ! "$ARGUMENTS" =~ --chain ]]; then
|
||||
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
|
||||
fi
|
||||
```
|
||||
@@ -974,12 +1054,12 @@ Check for auto-advance trigger:
|
||||
AUTO_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
|
||||
```
|
||||
|
||||
**If `--auto` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct `--auto` usage without new-project):
|
||||
**If `--auto` or `--chain` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct usage without new-project):
|
||||
```bash
|
||||
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-set workflow._auto_chain_active true
|
||||
```
|
||||
|
||||
**If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
|
||||
**If `--auto` flag present OR `--chain` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
|
||||
|
||||
Display banner:
|
||||
```
|
||||
@@ -1006,7 +1086,7 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
|
||||
|
||||
Auto-advance pipeline finished: discuss → plan → execute
|
||||
|
||||
Next: /gsd:discuss-phase ${NEXT_PHASE} --auto ${GSD_WS}
|
||||
Next: /gsd:discuss-phase ${NEXT_PHASE} ${WAS_CHAIN ? "--chain" : "--auto"} ${GSD_WS}
|
||||
<sub>/clear first → fresh context window</sub>
|
||||
```
|
||||
- **PLANNING COMPLETE** → Planning done, execution didn't complete:
|
||||
@@ -1025,7 +1105,7 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
|
||||
Continue: /gsd:plan-phase ${PHASE} --gaps ${GSD_WS}
|
||||
```
|
||||
|
||||
**If neither `--auto` nor config enabled:**
|
||||
**If none of `--auto`, `--chain`, nor config enabled:**
|
||||
Route to `confirm_creation` step (existing behavior — show manual next steps).
|
||||
</step>
|
||||
|
||||
@@ -1046,4 +1126,9 @@ Route to `confirm_creation` step (existing behavior — show manual next steps).
|
||||
- Deferred ideas preserved for future phases
|
||||
- STATE.md updated with session info
|
||||
- User knows next steps
|
||||
- Checkpoint file written after each area completes (incremental save)
|
||||
- Interrupted sessions can be resumed from checkpoint (no re-answering completed areas)
|
||||
- Checkpoint file cleaned up after successful CONTEXT.md write
|
||||
- `--chain` triggers interactive discuss followed by auto plan+execute (no auto-answering)
|
||||
- `--chain` and `--auto` both persist chain flag and auto-advance to plan-phase
|
||||
</success_criteria>
|
||||
|
||||
1153
get-shit-done/workflows/docs-update.md
Normal file
1153
get-shit-done/workflows/docs-update.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -68,6 +68,14 @@ AGENT_SKILLS=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" agent-skills
|
||||
|
||||
Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`.
|
||||
|
||||
Read worktree config:
|
||||
|
||||
```bash
|
||||
USE_WORKTREES=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
|
||||
```
|
||||
|
||||
When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees.
|
||||
|
||||
**If `phase_found` is false:** Error — phase directory not found.
|
||||
**If `plan_count` is 0:** Error — no plans found in phase.
|
||||
**If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
|
||||
@@ -223,6 +231,8 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
||||
For 200k models, this keeps orchestrator context lean (~10-15%).
|
||||
For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
|
||||
|
||||
**Worktree mode** (`USE_WORKTREES` is not `false`):
|
||||
|
||||
```
|
||||
Task(
|
||||
subagent_type="gsd-executor",
|
||||
@@ -279,6 +289,19 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
||||
)
|
||||
```
|
||||
|
||||
**Sequential mode** (`USE_WORKTREES` is `false`):
|
||||
|
||||
Omit `isolation="worktree"` from the Task call. Replace the `<parallel_execution>` block with:
|
||||
|
||||
```
|
||||
<sequential_execution>
|
||||
You are running as a SEQUENTIAL executor agent on the main working tree.
|
||||
Use normal git commits (with hooks). Do NOT use --no-verify.
|
||||
</sequential_execution>
|
||||
```
|
||||
|
||||
When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting — multiple agents writing to the same working tree concurrently would cause conflicts.
|
||||
|
||||
3. **Wait for all agents in wave to complete.**
|
||||
|
||||
**Completion signal fallback (Copilot and runtimes where Task() may not return):**
|
||||
@@ -313,6 +336,39 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
||||
```
|
||||
If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
|
||||
|
||||
4.5. **Worktree cleanup (when `isolation="worktree"` was used):**
|
||||
|
||||
When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
|
||||
|
||||
```bash
|
||||
# List worktrees created by this wave's agents
|
||||
WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
|
||||
|
||||
for WT in $WORKTREES; do
|
||||
# Get the branch name for this worktree
|
||||
WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||
if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# Merge the worktree branch into the current branch
|
||||
git merge "$WT_BRANCH" --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
|
||||
echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
|
||||
continue
|
||||
}
|
||||
|
||||
# Remove the worktree
|
||||
git worktree remove "$WT" --force 2>/dev/null || true
|
||||
|
||||
# Delete the temporary branch
|
||||
git branch -D "$WT_BRANCH" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
**If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
|
||||
|
||||
**If no worktrees found:** Skip silently — agents may have been spawned without worktree isolation.
|
||||
|
||||
5. **Report completion — spot-check claims first:**
|
||||
|
||||
For each SUMMARY.md:
|
||||
@@ -436,6 +492,27 @@ After all waves:
|
||||
### Issues Encountered
|
||||
[Aggregate from SUMMARYs, or "None"]
|
||||
```
|
||||
|
||||
**Security gate check:**
|
||||
```bash
|
||||
SECURITY_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
|
||||
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
|
||||
```
|
||||
|
||||
If `SECURITY_CFG` is `false`: skip.
|
||||
|
||||
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
|
||||
Include in the next-steps routing output:
|
||||
```
|
||||
⚠ Security enforcement enabled — run before advancing:
|
||||
/gsd:secure-phase {PHASE} ${GSD_WS}
|
||||
```
|
||||
|
||||
If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
|
||||
```
|
||||
⚠ Security gate: {threats_open} threats open
|
||||
/gsd:secure-phase {PHASE} — resolve before advancing
|
||||
```
|
||||
</step>
|
||||
|
||||
<step name="handle_partial_wave_execution">
|
||||
@@ -580,6 +657,72 @@ Options:
|
||||
Use AskUserQuestion to present the options.
|
||||
</step>
|
||||
|
||||
<step name="schema_drift_gate">
|
||||
Post-execution schema drift detection. Catches false-positive verification where
|
||||
build/types pass because TypeScript types come from config, not the live database.
|
||||
|
||||
**Run after execution completes but BEFORE verification marks success.**
|
||||
|
||||
```bash
|
||||
SCHEMA_DRIFT=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
|
||||
```
|
||||
|
||||
Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
|
||||
|
||||
**If `drift_detected` is false:** Skip to verify_phase_goal.
|
||||
|
||||
**If `drift_detected` is true AND `blocking` is true:**
|
||||
|
||||
Check for override:
|
||||
```bash
|
||||
SKIP_SCHEMA=$(echo "${GSD_SKIP_SCHEMA_CHECK:-false}")
|
||||
```
|
||||
|
||||
**If `SKIP_SCHEMA` is `true`:**
|
||||
|
||||
Display:
|
||||
```
|
||||
⚠ Schema drift detected but GSD_SKIP_SCHEMA_CHECK=true — bypassing gate.
|
||||
|
||||
Schema files changed: {schema_files}
|
||||
ORMs requiring push: {unpushed_orms}
|
||||
|
||||
Proceeding to verification (database may be out of sync).
|
||||
```
|
||||
→ Continue to verify_phase_goal.
|
||||
|
||||
**If `SKIP_SCHEMA` is not `true`:**
|
||||
|
||||
BLOCK verification. Display:
|
||||
|
||||
```
|
||||
## BLOCKED: Schema Drift Detected
|
||||
|
||||
Schema-relevant files changed during this phase but no database push command
|
||||
was executed. Build and type checks pass because TypeScript types come from
|
||||
config, not the live database — verification would produce a false positive.
|
||||
|
||||
Schema files changed: {schema_files}
|
||||
ORMs requiring push: {unpushed_orms}
|
||||
|
||||
Required push commands:
|
||||
{For each unpushed ORM, show the push command from the message}
|
||||
|
||||
Options:
|
||||
1. Run push command now (recommended) — execute the push, then re-verify
|
||||
2. Skip schema check (GSD_SKIP_SCHEMA_CHECK=true) — bypass this gate
|
||||
3. Abort — stop execution and investigate
|
||||
```
|
||||
|
||||
If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
|
||||
|
||||
**If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
|
||||
|
||||
**If user selects option 2:** Set override and continue to verify_phase_goal.
|
||||
|
||||
**If user selects option 3:** Stop execution. Report partial completion.
|
||||
</step>
|
||||
|
||||
<step name="verify_phase_goal">
|
||||
Verify phase achieved its GOAL, not just completed tasks.
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
|
||||
| Verify-only | B (segmented) | Segments between checkpoints. After none/human-verify → SUBAGENT. After decision/human-action → MAIN |
|
||||
| Decision | C (main) | Execute entirely in main context |
|
||||
|
||||
**Pattern A:** init_agent_tracking → spawn Task(subagent_type="gsd-executor", model=executor_model, isolation="worktree") with prompt: execute plan at [path], autonomous, all tasks + SUMMARY + commit, follow deviation/auth rules, report: plan name, tasks, SUMMARY path, commit hash → track agent_id → wait → update tracking → report.
|
||||
**Pattern A:** init_agent_tracking → spawn Task(subagent_type="gsd-executor", model=executor_model) with prompt: execute plan at [path], autonomous, all tasks + SUMMARY + commit, follow deviation/auth rules, report: plan name, tasks, SUMMARY path, commit hash → track agent_id → wait → update tracking → report. **Include `isolation="worktree"` only if `workflow.use_worktrees` is not `false`** (read via `config-get workflow.use_worktrees`).
|
||||
|
||||
**Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, create SUMMARY, commit. See segment_execution.
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ Usage: `/gsd:do I want to start a new milestone`
|
||||
|
||||
### Quick Mode
|
||||
|
||||
**`/gsd:quick [--full] [--discuss] [--research]`**
|
||||
**`/gsd:quick [--full] [--validate] [--discuss] [--research]`**
|
||||
Execute small, ad-hoc tasks with GSD guarantees but skip optional agents.
|
||||
|
||||
Quick mode uses the same system with a shorter path:
|
||||
@@ -143,14 +143,16 @@ Quick mode uses the same system with a shorter path:
|
||||
- Updates STATE.md tracking (not ROADMAP.md)
|
||||
|
||||
Flags enable additional quality steps:
|
||||
- `--full` — Complete quality pipeline: discussion + research + plan-checking + verification
|
||||
- `--validate` — Plan-checking (max 2 iterations) and post-execution verification only
|
||||
- `--discuss` — Lightweight discussion to surface gray areas before planning
|
||||
- `--research` — Focused research agent investigates approaches before planning
|
||||
- `--full` — Adds plan-checking (max 2 iterations) and post-execution verification
|
||||
|
||||
Flags are composable: `--discuss --research --full` gives the complete quality pipeline for a single task.
|
||||
Granular flags are composable: `--discuss --research --validate` gives the same as `--full`.
|
||||
|
||||
Usage: `/gsd:quick`
|
||||
Usage: `/gsd:quick --research --full`
|
||||
Usage: `/gsd:quick --full`
|
||||
Usage: `/gsd:quick --research --validate`
|
||||
Result: Creates `.planning/quick/NNN-slug/PLAN.md`, `.planning/quick/NNN-slug/SUMMARY.md`
|
||||
|
||||
---
|
||||
@@ -343,11 +345,12 @@ Usage: `/gsd:ship 4` or `/gsd:ship 4 --draft`
|
||||
|
||||
---
|
||||
|
||||
**`/gsd:review --phase N [--gemini] [--claude] [--codex] [--all]`**
|
||||
**`/gsd:review --phase N [--gemini] [--claude] [--codex] [--coderabbit] [--all]`**
|
||||
Cross-AI peer review — invoke external AI CLIs to independently review phase plans.
|
||||
|
||||
- Detects available CLIs (gemini, claude, codex)
|
||||
- Detects available CLIs (gemini, claude, codex, coderabbit)
|
||||
- Each CLI reviews plans independently with the same structured prompt
|
||||
- CodeRabbit reviews the current git diff (not a prompt) — may take up to 5 minutes
|
||||
- Produces REVIEWS.md with per-reviewer feedback and consensus summary
|
||||
- Feed reviews back into planning: `/gsd:plan-phase N --reviews`
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ After discuss completes, loop back to dashboard step.
|
||||
|
||||
### Plan Phase N
|
||||
|
||||
Planning runs autonomously. Spawn a background agent:
|
||||
Planning runs autonomously. Spawn a background agent that delegates to the Skill pipeline:
|
||||
|
||||
```
|
||||
Task(
|
||||
@@ -222,16 +222,12 @@ Working directory: {cwd}
|
||||
Phase: {N} — {phase_name}
|
||||
Goal: {goal}
|
||||
|
||||
Steps:
|
||||
1. Read the plan-phase workflow: cat ~/.claude/get-shit-done/workflows/plan-phase.md
|
||||
2. Run: node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" init plan-phase {N}
|
||||
3. Follow the workflow steps to produce PLAN.md files for this phase.
|
||||
4. If research is enabled in config, run the research step first.
|
||||
5. Spawn a gsd-planner subagent via Task() to create the plans.
|
||||
6. If plan-checker is enabled, spawn a gsd-plan-checker subagent to verify.
|
||||
7. Commit plan files when complete.
|
||||
Run the plan-phase Skill:
|
||||
Skill(skill=\"gsd:plan-phase\", args=\"{N} --auto\")
|
||||
|
||||
Important: You are running in the background. Do NOT use AskUserQuestion — make autonomous decisions based on project context. If you hit a blocker, write it to STATE.md as a blocker and stop. Do NOT silently work around permission or file access errors — let them fail so the manager can surface them with resolution hints."
|
||||
This delegates to the full plan-phase pipeline including local patches, research, plan-checker, and all quality gates.
|
||||
|
||||
Important: You are running in the background. Do NOT use AskUserQuestion — make autonomous decisions based on project context. If you hit a blocker, write it to STATE.md as a blocker and stop. Do NOT silently work around permission or file access errors — let them fail so the manager can surface them with resolution hints. Do NOT use --no-verify on git commits."
|
||||
)
|
||||
```
|
||||
|
||||
@@ -245,7 +241,7 @@ Loop back to dashboard step.
|
||||
|
||||
### Execute Phase N
|
||||
|
||||
Execution runs autonomously. Spawn a background agent:
|
||||
Execution runs autonomously. Spawn a background agent that delegates to the Skill pipeline:
|
||||
|
||||
```
|
||||
Task(
|
||||
@@ -257,16 +253,12 @@ Working directory: {cwd}
|
||||
Phase: {N} — {phase_name}
|
||||
Goal: {goal}
|
||||
|
||||
Steps:
|
||||
1. Read the execute-phase workflow: cat ~/.claude/get-shit-done/workflows/execute-phase.md
|
||||
2. Run: node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" init execute-phase {N}
|
||||
3. Follow the workflow steps: discover plans, analyze dependencies, group into waves.
|
||||
4. For each wave, spawn gsd-executor subagents via Task() to execute plans in parallel.
|
||||
5. After all waves complete, spawn a gsd-verifier subagent if verifier is enabled.
|
||||
6. Update ROADMAP.md and STATE.md with progress.
|
||||
7. Commit all changes.
|
||||
Run the execute-phase Skill:
|
||||
Skill(skill=\"gsd:execute-phase\", args=\"{N}\")
|
||||
|
||||
Important: You are running in the background. Do NOT use AskUserQuestion — make autonomous decisions. Use --no-verify on git commits. If you hit a permission error, file lock, or any access issue, do NOT work around it — let it fail and write the error to STATE.md as a blocker so the manager can surface it with resolution guidance."
|
||||
This delegates to the full execute-phase pipeline including local patches, branching, wave-based execution, verification, and all quality gates.
|
||||
|
||||
Important: You are running in the background. Do NOT use AskUserQuestion — make autonomous decisions. Do NOT use --no-verify on git commits — let pre-commit hooks run normally. If you hit a permission error, file lock, or any access issue, do NOT work around it — let it fail and write the error to STATE.md as a blocker so the manager can surface it with resolution guidance."
|
||||
)
|
||||
```
|
||||
|
||||
@@ -306,7 +298,7 @@ Classify the error:
|
||||
- **question:** "Phase {N} failed — permission denied for `{tool_or_command}`. Want me to add it to settings.local.json so it's allowed?"
|
||||
- **options:** "Add permission and retry" / "Run this phase inline instead" / "Skip and continue"
|
||||
- "Add permission and retry": Use `Skill(skill="update-config")` to add the permission to `settings.local.json`, then re-spawn the background agent. Loop to dashboard.
|
||||
- "Run this phase inline instead": Dispatch the same action (plan/execute) inline via `Skill()` instead of a background Task. Loop to dashboard after.
|
||||
- "Run this phase inline instead": Dispatch the same action inline via the appropriate Skill — use `Skill(skill="gsd:plan-phase", args="{N}")` if the failed action was planning, or `Skill(skill="gsd:execute-phase", args="{N}")` if the failed action was execution. Loop to dashboard after.
|
||||
- "Skip and continue": Loop to dashboard (phase stays in current state).
|
||||
|
||||
**Other errors** (git lock, file conflict, logic error, etc.):
|
||||
@@ -314,7 +306,7 @@ Classify the error:
|
||||
- **question:** "Background agent for Phase {N} encountered an issue: {error}. What next?"
|
||||
- **options:** "Retry" / "Run inline instead" / "Skip and continue" / "View details"
|
||||
- "Retry": Re-spawn the same background agent. Loop to dashboard.
|
||||
- "Run inline instead": Dispatch the action inline via `Skill()`. Loop to dashboard after.
|
||||
- "Run inline instead": Dispatch the action inline via the appropriate Skill — use `Skill(skill="gsd:plan-phase", args="{N}")` if the failed action was planning, or `Skill(skill="gsd:execute-phase", args="{N}")` if the failed action was execution. Loop to dashboard after.
|
||||
- "Skip and continue": Loop to dashboard (phase stays in current state).
|
||||
- "View details": Read STATE.md blockers section, display, then re-present options.
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ If plans exist but not all have matching summaries:
|
||||
|
||||
**Route 5: All plans have summaries → verify and complete**
|
||||
If all plans in the current phase have summaries:
|
||||
→ Next action: `/gsd:verify-work` then `/gsd:complete-phase`
|
||||
→ Next action: `/gsd:verify-work`
|
||||
|
||||
**Route 6: Phase complete, next phase exists → advance**
|
||||
If the current phase is complete and the next phase exists in ROADMAP:
|
||||
|
||||
@@ -101,7 +101,7 @@ If a scope has no directory or no entries, show: `(no notes)`
|
||||
3. If N is invalid or refers to an already-promoted note, tell the user and stop
|
||||
4. **Requires `.planning/` directory** — if it doesn't exist, warn: "Todos require a GSD project. Run `/gsd:new-project` to initialize one."
|
||||
5. Ensure `.planning/todos/pending/` directory exists
|
||||
6. Generate todo ID: `{NNN}-{slug}` where NNN is the next sequential number (scan both `.planning/todos/pending/` and `.planning/todos/done/` for the highest existing number, increment by 1, zero-pad to 3 digits) and slug is the first ~4 meaningful words of the note text
|
||||
6. Generate todo ID: `{NNN}-{slug}` where NNN is the next sequential number (scan both `.planning/todos/pending/` and `.planning/todos/completed/` for the highest existing number, increment by 1, zero-pad to 3 digits) and slug is the first ~4 meaningful words of the note text
|
||||
7. Extract the note text from the source file (body after frontmatter)
|
||||
8. Create `.planning/todos/pending/{id}.md`:
|
||||
|
||||
|
||||
@@ -360,6 +360,32 @@ test -f "${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md" && echo "VALIDATION_CREATED
|
||||
|
||||
**If not found:** Warn and continue — plans may fail Dimension 8.
|
||||
|
||||
## 5.55. Security Threat Model Gate
|
||||
|
||||
> Skip if `workflow.security_enforcement` is explicitly `false`. Absent = enabled.
|
||||
|
||||
```bash
|
||||
SECURITY_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
|
||||
SECURITY_ASVS=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_asvs_level --raw 2>/dev/null || echo "1")
|
||||
SECURITY_BLOCK=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_block_on --raw 2>/dev/null || echo "high")
|
||||
```
|
||||
|
||||
**If `SECURITY_CFG` is `false`:** Skip to step 5.6.
|
||||
|
||||
**If `SECURITY_CFG` is `true`:** Display banner:
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► SECURITY THREAT MODEL REQUIRED (ASVS L{SECURITY_ASVS})
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Each PLAN.md must include a <threat_model> block.
|
||||
Block on: {SECURITY_BLOCK} severity threats.
|
||||
Opt out: set security_enforcement: false in .planning/config.json
|
||||
```
|
||||
|
||||
Continue to step 5.6. Security config is passed to the planner in step 8.
|
||||
|
||||
## 5.6. UI Design Contract Gate
|
||||
|
||||
> Skip if `workflow.ui_phase` is explicitly `false` AND `workflow.ui_safety_gate` is explicitly `false` in `.planning/config.json`. If keys are absent, treat as enabled.
|
||||
@@ -409,7 +435,69 @@ Otherwise use AskUserQuestion:
|
||||
- "Continue without UI-SPEC" → Continue to step 6.
|
||||
- "Not a frontend phase" → Continue to step 6.
|
||||
|
||||
**If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 6.
|
||||
**If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 5.7.
|
||||
|
||||
## 5.7. Schema Push Detection Gate
|
||||
|
||||
> Detects schema-relevant files in the phase scope and injects a mandatory `[BLOCKING]` schema push task into the plan. Prevents false-positive verification where build/types pass because TypeScript types come from config, not the live database.
|
||||
|
||||
Check if any files in the phase scope match schema patterns:
|
||||
|
||||
```bash
|
||||
PHASE_SECTION=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" roadmap get-phase "${PHASE}" --pick section 2>/dev/null)
|
||||
```
|
||||
|
||||
Scan `PHASE_SECTION`, `CONTEXT.md` (if loaded), and `RESEARCH.md` (if exists) for file paths matching these ORM patterns:
|
||||
|
||||
| ORM | File Patterns |
|
||||
|-----|--------------|
|
||||
| Payload CMS | `src/collections/**/*.ts`, `src/globals/**/*.ts` |
|
||||
| Prisma | `prisma/schema.prisma`, `prisma/schema/*.prisma` |
|
||||
| Drizzle | `drizzle/schema.ts`, `src/db/schema.ts`, `drizzle/*.ts` |
|
||||
| Supabase | `supabase/migrations/*.sql` |
|
||||
| TypeORM | `src/entities/**/*.ts`, `src/migrations/**/*.ts` |
|
||||
|
||||
Also check if any existing PLAN.md files for this phase already reference these file patterns in `files_modified`.
|
||||
|
||||
**If schema-relevant files detected:**
|
||||
|
||||
Set `SCHEMA_PUSH_REQUIRED=true` and `SCHEMA_ORM={detected_orm}`.
|
||||
|
||||
Determine the push command for the detected ORM:
|
||||
|
||||
| ORM | Push Command | Non-TTY Workaround |
|
||||
|-----|-------------|-------------------|
|
||||
| Payload CMS | `npx payload migrate` | `CI=true PAYLOAD_MIGRATING=true npx payload migrate` |
|
||||
| Prisma | `npx prisma db push` | `npx prisma db push --accept-data-loss` (if destructive) |
|
||||
| Drizzle | `npx drizzle-kit push` | `npx drizzle-kit push` |
|
||||
| Supabase | `supabase db push` | Set `SUPABASE_ACCESS_TOKEN` env var |
|
||||
| TypeORM | `npx typeorm migration:run` | `npx typeorm migration:run -d src/data-source.ts` |
|
||||
|
||||
Inject the following into the planner prompt (step 8) as an additional constraint:
|
||||
|
||||
```markdown
|
||||
<schema_push_requirement>
|
||||
**[BLOCKING] Schema Push Required**
|
||||
|
||||
This phase modifies schema-relevant files ({detected_files}). The planner MUST include
|
||||
a `[BLOCKING]` task that runs the database schema push command AFTER all schema file
|
||||
modifications are complete but BEFORE verification.
|
||||
|
||||
- ORM detected: {SCHEMA_ORM}
|
||||
- Push command: {push_command}
|
||||
- Non-TTY workaround: {env_hint}
|
||||
- If push requires interactive prompts that cannot be suppressed, flag the task for
|
||||
manual intervention with `autonomous: false`
|
||||
|
||||
This task is mandatory — the phase CANNOT pass verification without it. Build and
|
||||
type checks will pass without the push (types come from config, not the live database),
|
||||
creating a false-positive verification state.
|
||||
</schema_push_requirement>
|
||||
```
|
||||
|
||||
Display: `Schema files detected ({SCHEMA_ORM}) — [BLOCKING] push task will be injected into plans`
|
||||
|
||||
**If no schema-relevant files detected:** Skip silently to step 6.
|
||||
|
||||
## 6. Check Existing Plans
|
||||
|
||||
@@ -496,6 +584,7 @@ ${AGENT_SKILLS_PLANNER}
|
||||
|
||||
**Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
|
||||
**Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, plans should account for project skill rules
|
||||
|
||||
</planning_context>
|
||||
|
||||
<downstream_consumer>
|
||||
@@ -560,9 +649,42 @@ Task(
|
||||
## 9. Handle Planner Return
|
||||
|
||||
- **`## PLANNING COMPLETE`:** Display plan count. If `--skip-verify` or `plan_checker_enabled` is false (from init): skip to step 13. Otherwise: step 10.
|
||||
- **`## PHASE SPLIT RECOMMENDED`:** The planner determined the phase is too complex to implement all user decisions without simplifying them. Handle in step 9b.
|
||||
- **`## CHECKPOINT REACHED`:** Present to user, get response, spawn continuation (step 12)
|
||||
- **`## PLANNING INCONCLUSIVE`:** Show attempts, offer: Add context / Retry / Manual
|
||||
|
||||
## 9b. Handle Phase Split Recommendation
|
||||
|
||||
When the planner returns `## PHASE SPLIT RECOMMENDED`, it means the phase has too many decisions to implement at full fidelity within the plan budget. The planner proposes groupings.
|
||||
|
||||
**Extract from planner return:**
|
||||
- Proposed sub-phases (e.g., "17a: processing core (D-01 to D-19)", "17b: billing + config UX (D-20 to D-27)")
|
||||
- Which D-XX decisions go in each sub-phase
|
||||
- Why the split is necessary (decision count, complexity estimate)
|
||||
|
||||
**Present to user:**
|
||||
```
|
||||
## Phase {X} is too complex for full-fidelity implementation
|
||||
|
||||
The planner found {N} decisions that cannot all be implemented without
|
||||
simplifying some. Instead of reducing your decisions, we recommend splitting:
|
||||
|
||||
**Option 1: Split into sub-phases**
|
||||
- Phase {X}a: {name} — {D-XX to D-YY} ({N} decisions)
|
||||
- Phase {X}b: {name} — {D-XX to D-YY} ({M} decisions)
|
||||
|
||||
**Option 2: Proceed anyway** (planner will attempt all, quality may degrade)
|
||||
|
||||
**Option 3: Prioritize** — you choose which decisions to implement now,
|
||||
rest become a follow-up phase
|
||||
```
|
||||
|
||||
Use AskUserQuestion with these 3 options.
|
||||
|
||||
**If "Split":** Use `/gsd:insert-phase` to create the sub-phases, then replan each.
|
||||
**If "Proceed":** Return to planner with instruction to attempt all decisions at full fidelity, accepting more plans/tasks.
|
||||
**If "Prioritize":** Use AskUserQuestion (multiSelect) to let user pick which D-XX are "now" vs "later". Create CONTEXT.md for each sub-phase with the selected decisions.
|
||||
|
||||
## 10. Spawn gsd-plan-checker Agent
|
||||
|
||||
Display banner:
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<purpose>
|
||||
Execute small, ad-hoc tasks with GSD guarantees (atomic commits, STATE.md tracking). Quick mode spawns gsd-planner (quick mode) + gsd-executor(s), tracks tasks in `.planning/quick/`, and updates STATE.md's "Quick Tasks Completed" table.
|
||||
|
||||
With `--discuss` flag: lightweight discussion phase before planning. Surfaces assumptions, clarifies gray areas, captures decisions in CONTEXT.md so the planner treats them as locked.
|
||||
With `--full` flag: enables the complete quality pipeline — discussion + research + plan-checking + verification. One flag for everything.
|
||||
|
||||
With `--full` flag: enables plan-checking (max 2 iterations) and post-execution verification for quality guarantees without full milestone ceremony.
|
||||
With `--validate` flag: enables plan-checking (max 2 iterations) and post-execution verification only. Use when you want quality guarantees without discussion or research.
|
||||
|
||||
With `--discuss` flag: lightweight discussion phase before planning. Surfaces assumptions, clarifies gray areas, captures decisions in CONTEXT.md so the planner treats them as locked.
|
||||
|
||||
With `--research` flag: spawns a focused research agent before planning. Investigates implementation approaches, library options, and pitfalls. Use when you're unsure how to approach a task.
|
||||
|
||||
Flags are composable: `--discuss --research --full` gives discussion + research + plan-checking + verification.
|
||||
Granular flags are composable: `--discuss --research --validate` gives the same result as `--full`.
|
||||
</purpose>
|
||||
|
||||
<required_reading>
|
||||
@@ -27,9 +29,10 @@ Valid GSD subagent types (use exact names — do not fall back to 'general-purpo
|
||||
**Step 1: Parse arguments and get task description**
|
||||
|
||||
Parse `$ARGUMENTS` for:
|
||||
- `--full` flag → store as `$FULL_MODE` (true/false)
|
||||
- `--discuss` flag → store as `$DISCUSS_MODE` (true/false)
|
||||
- `--research` flag → store as `$RESEARCH_MODE` (true/false)
|
||||
- `--full` flag → store `$FULL_MODE=true`, `$DISCUSS_MODE=true`, `$RESEARCH_MODE=true`, `$VALIDATE_MODE=true`
|
||||
- `--validate` flag → store `$VALIDATE_MODE=true`
|
||||
- `--discuss` flag → store `$DISCUSS_MODE=true`
|
||||
- `--research` flag → store `$RESEARCH_MODE=true`
|
||||
- Remaining text → use as `$DESCRIPTION` if non-empty
|
||||
|
||||
If `$DESCRIPTION` is empty after parsing, prompt user interactively:
|
||||
@@ -48,25 +51,34 @@ If still empty, re-prompt: "Please provide a task description."
|
||||
|
||||
Display banner based on active flags:
|
||||
|
||||
If `$DISCUSS_MODE` and `$RESEARCH_MODE` and `$FULL_MODE`:
|
||||
If `$FULL_MODE` (all phases enabled — `--full` or all granular flags):
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► QUICK TASK (DISCUSS + RESEARCH + FULL)
|
||||
GSD ► QUICK TASK (FULL)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
◆ Discussion + research + plan checking + verification enabled
|
||||
```
|
||||
|
||||
If `$DISCUSS_MODE` and `$FULL_MODE` (no research):
|
||||
If `$DISCUSS_MODE` and `$RESEARCH_MODE` and `$VALIDATE_MODE` (no `$FULL_MODE` — composed granularly):
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► QUICK TASK (DISCUSS + FULL)
|
||||
GSD ► QUICK TASK (DISCUSS + RESEARCH + VALIDATE)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
◆ Discussion + research + plan checking + verification enabled
|
||||
```
|
||||
|
||||
If `$DISCUSS_MODE` and `$VALIDATE_MODE` (no research):
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► QUICK TASK (DISCUSS + VALIDATE)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
◆ Discussion + plan checking + verification enabled
|
||||
```
|
||||
|
||||
If `$DISCUSS_MODE` and `$RESEARCH_MODE` (no full):
|
||||
If `$DISCUSS_MODE` and `$RESEARCH_MODE` (no validate):
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► QUICK TASK (DISCUSS + RESEARCH)
|
||||
@@ -75,10 +87,10 @@ If `$DISCUSS_MODE` and `$RESEARCH_MODE` (no full):
|
||||
◆ Discussion + research enabled
|
||||
```
|
||||
|
||||
If `$RESEARCH_MODE` and `$FULL_MODE` (no discuss):
|
||||
If `$RESEARCH_MODE` and `$VALIDATE_MODE` (no discuss):
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► QUICK TASK (RESEARCH + FULL)
|
||||
GSD ► QUICK TASK (RESEARCH + VALIDATE)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
◆ Research + plan checking + verification enabled
|
||||
@@ -102,10 +114,10 @@ If `$RESEARCH_MODE` only:
|
||||
◆ Research phase enabled — investigating approaches before planning
|
||||
```
|
||||
|
||||
If `$FULL_MODE` only:
|
||||
If `$VALIDATE_MODE` only:
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
GSD ► QUICK TASK (FULL MODE)
|
||||
GSD ► QUICK TASK (VALIDATE)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
◆ Plan checking + verification enabled
|
||||
@@ -126,6 +138,10 @@ AGENT_SKILLS_VERIFIER=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" age
|
||||
|
||||
Parse JSON for: `planner_model`, `executor_model`, `checker_model`, `verifier_model`, `commit_docs`, `branch_name`, `quick_id`, `slug`, `date`, `timestamp`, `quick_dir`, `task_dir`, `roadmap_exists`, `planning_exists`.
|
||||
|
||||
```bash
|
||||
USE_WORKTREES=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
|
||||
```
|
||||
|
||||
**If `roadmap_exists` is false:** Error — Quick mode requires an active project with ROADMAP.md. Run `/gsd:new-project` first.
|
||||
|
||||
Quick tasks can run mid-phase - validation only checks ROADMAP.md exists, not phase status.
|
||||
@@ -367,16 +383,16 @@ If research file not found, warn but continue: "Research agent did not produce o
|
||||
|
||||
**Step 5: Spawn planner (quick mode)**
|
||||
|
||||
**If `$FULL_MODE`:** Use `quick-full` mode with stricter constraints.
|
||||
**If `$VALIDATE_MODE`:** Use `quick-full` mode with stricter constraints.
|
||||
|
||||
**If NOT `$FULL_MODE`:** Use standard `quick` mode.
|
||||
**If NOT `$VALIDATE_MODE`:** Use standard `quick` mode.
|
||||
|
||||
```
|
||||
Task(
|
||||
prompt="
|
||||
<planning_context>
|
||||
|
||||
**Mode:** ${FULL_MODE ? 'quick-full' : 'quick'}
|
||||
**Mode:** ${VALIDATE_MODE ? 'quick-full' : 'quick'}
|
||||
**Directory:** ${QUICK_DIR}
|
||||
**Description:** ${DESCRIPTION}
|
||||
|
||||
@@ -397,9 +413,9 @@ ${AGENT_SKILLS_PLANNER}
|
||||
- Create a SINGLE plan with 1-3 focused tasks
|
||||
- Quick tasks should be atomic and self-contained
|
||||
${RESEARCH_MODE ? '- Research findings are available — use them to inform library/pattern choices' : '- No research phase'}
|
||||
${FULL_MODE ? '- Target ~40% context usage (structured for verification)' : '- Target ~30% context usage (simple, focused)'}
|
||||
${FULL_MODE ? '- MUST generate `must_haves` in plan frontmatter (truths, artifacts, key_links)' : ''}
|
||||
${FULL_MODE ? '- Each task MUST have `files`, `action`, `verify`, `done` fields' : ''}
|
||||
${VALIDATE_MODE ? '- Target ~40% context usage (structured for verification)' : '- Target ~30% context usage (simple, focused)'}
|
||||
${VALIDATE_MODE ? '- MUST generate `must_haves` in plan frontmatter (truths, artifacts, key_links)' : ''}
|
||||
${VALIDATE_MODE ? '- Each task MUST have `files`, `action`, `verify`, `done` fields' : ''}
|
||||
</constraints>
|
||||
|
||||
<output>
|
||||
@@ -422,9 +438,9 @@ If plan not found, error: "Planner failed to create ${quick_id}-PLAN.md"
|
||||
|
||||
---
|
||||
|
||||
**Step 5.5: Plan-checker loop (only when `$FULL_MODE`)**
|
||||
**Step 5.5: Plan-checker loop (only when `$VALIDATE_MODE`)**
|
||||
|
||||
Skip this step entirely if NOT `$FULL_MODE`.
|
||||
Skip this step entirely if NOT `$VALIDATE_MODE`.
|
||||
|
||||
Display banner:
|
||||
```
|
||||
@@ -552,22 +568,37 @@ ${AGENT_SKILLS_EXECUTOR}
|
||||
|
||||
<constraints>
|
||||
- Execute all tasks in the plan
|
||||
- Commit each task atomically
|
||||
- Commit each task atomically (code changes only)
|
||||
- Create summary at: ${QUICK_DIR}/${quick_id}-SUMMARY.md
|
||||
- Do NOT commit docs artifacts (SUMMARY.md, STATE.md, PLAN.md) — the orchestrator handles the docs commit in Step 8
|
||||
- Do NOT update ROADMAP.md (quick tasks are separate from planned phases)
|
||||
</constraints>
|
||||
",
|
||||
subagent_type="gsd-executor",
|
||||
model="{executor_model}",
|
||||
isolation="worktree",
|
||||
${USE_WORKTREES !== "false" ? 'isolation="worktree",' : ''}
|
||||
description="Execute: ${DESCRIPTION}"
|
||||
)
|
||||
```
|
||||
|
||||
After executor returns:
|
||||
1. Verify summary exists at `${QUICK_DIR}/${quick_id}-SUMMARY.md`
|
||||
2. Extract commit hash from executor output
|
||||
3. Report completion status
|
||||
1. **Worktree cleanup:** If the executor ran with `isolation="worktree"`, merge the worktree branch back and clean up:
|
||||
```bash
|
||||
# Find worktrees created by the executor
|
||||
WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
|
||||
for WT in $WORKTREES; do
|
||||
WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||
if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
|
||||
git merge "$WT_BRANCH" --no-edit -m "chore: merge quick task worktree ($WT_BRANCH)" 2>&1 || echo "⚠ Merge conflict — resolve manually"
|
||||
git worktree remove "$WT" --force 2>/dev/null || true
|
||||
git branch -D "$WT_BRANCH" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
```
|
||||
If `workflow.use_worktrees` is `false`, skip this step.
|
||||
2. Verify summary exists at `${QUICK_DIR}/${quick_id}-SUMMARY.md`
|
||||
3. Extract commit hash from executor output
|
||||
4. Report completion status
|
||||
|
||||
**Known Claude Code bug (classifyHandoffIfNeeded):** If executor reports "failed" with error `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a real failure. Check if summary file exists and git log shows commits. If so, treat as successful.
|
||||
|
||||
@@ -577,9 +608,9 @@ Note: For quick tasks producing multiple plans (rare), spawn executors in parall
|
||||
|
||||
---
|
||||
|
||||
**Step 6.5: Verification (only when `$FULL_MODE`)**
|
||||
**Step 6.5: Verification (only when `$VALIDATE_MODE`)**
|
||||
|
||||
Skip this step entirely if NOT `$FULL_MODE`.
|
||||
Skip this step entirely if NOT `$VALIDATE_MODE`.
|
||||
|
||||
Display banner:
|
||||
```
|
||||
@@ -636,7 +667,7 @@ Read STATE.md and check for `### Quick Tasks Completed` section.
|
||||
|
||||
Insert after `### Blockers/Concerns` section:
|
||||
|
||||
**If `$FULL_MODE`:**
|
||||
**If `$VALIDATE_MODE`:**
|
||||
```markdown
|
||||
### Quick Tasks Completed
|
||||
|
||||
@@ -644,7 +675,7 @@ Insert after `### Blockers/Concerns` section:
|
||||
|---|-------------|------|--------|--------|-----------|
|
||||
```
|
||||
|
||||
**If NOT `$FULL_MODE`:**
|
||||
**If NOT `$VALIDATE_MODE`:**
|
||||
```markdown
|
||||
### Quick Tasks Completed
|
||||
|
||||
@@ -652,18 +683,18 @@ Insert after `### Blockers/Concerns` section:
|
||||
|---|-------------|------|--------|-----------|
|
||||
```
|
||||
|
||||
**Note:** If the table already exists, match its existing column format. If adding `--full` to a project that already has quick tasks without a Status column, add the Status column to the header and separator rows, and leave Status empty for the new row's predecessors.
|
||||
**Note:** If the table already exists, match its existing column format. If adding `--validate` (or `--full`) to a project that already has quick tasks without a Status column, add the Status column to the header and separator rows, and leave Status empty for the new row's predecessors.
|
||||
|
||||
**7c. Append new row to table:**
|
||||
|
||||
Use `date` from init:
|
||||
|
||||
**If `$FULL_MODE` (or table has Status column):**
|
||||
**If `$VALIDATE_MODE` (or table has Status column):**
|
||||
```markdown
|
||||
| ${quick_id} | ${DESCRIPTION} | ${date} | ${commit_hash} | ${VERIFICATION_STATUS} | [${quick_id}-${slug}](./quick/${quick_id}-${slug}/) |
|
||||
```
|
||||
|
||||
**If NOT `$FULL_MODE` (and table has no Status column):**
|
||||
**If NOT `$VALIDATE_MODE` (and table has no Status column):**
|
||||
```markdown
|
||||
| ${quick_id} | ${DESCRIPTION} | ${date} | ${commit_hash} | [${quick_id}-${slug}](./quick/${quick_id}-${slug}/) |
|
||||
```
|
||||
@@ -681,7 +712,7 @@ Use Edit tool to make these changes atomically
|
||||
|
||||
**Step 8: Final commit and completion**
|
||||
|
||||
Stage and commit quick task artifacts:
|
||||
Stage and commit quick task artifacts. This step MUST always run — even if the executor already committed some files (e.g. when running without worktree isolation). The `gsd-tools commit` command handles already-committed files gracefully.
|
||||
|
||||
Build file list:
|
||||
- `${QUICK_DIR}/${quick_id}-PLAN.md`
|
||||
@@ -689,9 +720,12 @@ Build file list:
|
||||
- `.planning/STATE.md`
|
||||
- If `$DISCUSS_MODE` and context file exists: `${QUICK_DIR}/${quick_id}-CONTEXT.md`
|
||||
- If `$RESEARCH_MODE` and research file exists: `${QUICK_DIR}/${quick_id}-RESEARCH.md`
|
||||
- If `$FULL_MODE` and verification file exists: `${QUICK_DIR}/${quick_id}-VERIFICATION.md`
|
||||
- If `$VALIDATE_MODE` and verification file exists: `${QUICK_DIR}/${quick_id}-VERIFICATION.md`
|
||||
|
||||
```bash
|
||||
# Explicitly stage all artifacts before commit — PLAN.md may be untracked
|
||||
# if the executor ran without worktree isolation and committed docs early
|
||||
git add ${file_list} 2>/dev/null
|
||||
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs(quick-${quick_id}): ${DESCRIPTION}" --files ${file_list}
|
||||
```
|
||||
|
||||
@@ -702,11 +736,11 @@ commit_hash=$(git rev-parse --short HEAD)
|
||||
|
||||
Display completion output:
|
||||
|
||||
**If `$FULL_MODE`:**
|
||||
**If `$VALIDATE_MODE`:**
|
||||
```
|
||||
---
|
||||
|
||||
GSD > QUICK TASK COMPLETE (FULL MODE)
|
||||
GSD > QUICK TASK COMPLETE (VALIDATED)
|
||||
|
||||
Quick Task ${quick_id}: ${DESCRIPTION}
|
||||
|
||||
@@ -720,7 +754,7 @@ Commit: ${commit_hash}
|
||||
Ready for next task: /gsd:quick ${GSD_WS}
|
||||
```
|
||||
|
||||
**If NOT `$FULL_MODE`:**
|
||||
**If NOT `$VALIDATE_MODE`:**
|
||||
```
|
||||
---
|
||||
|
||||
@@ -742,16 +776,17 @@ Ready for next task: /gsd:quick ${GSD_WS}
|
||||
<success_criteria>
|
||||
- [ ] ROADMAP.md validation passes
|
||||
- [ ] User provides task description
|
||||
- [ ] `--full`, `--discuss`, and `--research` flags parsed from arguments when present
|
||||
- [ ] `--full`, `--validate`, `--discuss`, and `--research` flags parsed from arguments when present
|
||||
- [ ] `--full` sets all booleans (`$FULL_MODE`, `$DISCUSS_MODE`, `$RESEARCH_MODE`, `$VALIDATE_MODE`)
|
||||
- [ ] Slug generated (lowercase, hyphens, max 40 chars)
|
||||
- [ ] Quick ID generated (YYMMDD-xxx format, 2s Base36 precision)
|
||||
- [ ] Directory created at `.planning/quick/YYMMDD-xxx-slug/`
|
||||
- [ ] (--discuss) Gray areas identified and presented, decisions captured in `${quick_id}-CONTEXT.md`
|
||||
- [ ] (--research) Research agent spawned, `${quick_id}-RESEARCH.md` created
|
||||
- [ ] `${quick_id}-PLAN.md` created by planner (honors CONTEXT.md decisions when --discuss, uses RESEARCH.md findings when --research)
|
||||
- [ ] (--full) Plan checker validates plan, revision loop capped at 2
|
||||
- [ ] (--validate) Plan checker validates plan, revision loop capped at 2
|
||||
- [ ] `${quick_id}-SUMMARY.md` created by executor
|
||||
- [ ] (--full) `${quick_id}-VERIFICATION.md` created by verifier
|
||||
- [ ] STATE.md updated with quick task row (Status column when --full)
|
||||
- [ ] (--validate) `${quick_id}-VERIFICATION.md` created by verifier
|
||||
- [ ] STATE.md updated with quick task row (Status column when --validate)
|
||||
- [ ] Artifacts committed
|
||||
</success_criteria>
|
||||
|
||||
@@ -18,12 +18,14 @@ Check which AI CLIs are available on the system:
|
||||
command -v gemini >/dev/null 2>&1 && echo "gemini:available" || echo "gemini:missing"
|
||||
command -v claude >/dev/null 2>&1 && echo "claude:available" || echo "claude:missing"
|
||||
command -v codex >/dev/null 2>&1 && echo "codex:available" || echo "codex:missing"
|
||||
command -v coderabbit >/dev/null 2>&1 && echo "coderabbit:available" || echo "coderabbit:missing"
|
||||
```
|
||||
|
||||
Parse flags from `$ARGUMENTS`:
|
||||
- `--gemini` → include Gemini
|
||||
- `--claude` → include Claude
|
||||
- `--codex` → include Codex
|
||||
- `--coderabbit` → include CodeRabbit
|
||||
- `--all` → include all available
|
||||
- No flags → include all available
|
||||
|
||||
@@ -131,6 +133,14 @@ claude -p "$(cat /tmp/gsd-review-prompt-{phase}.md)" --no-input 2>/dev/null > /t
|
||||
codex exec --skip-git-repo-check "$(cat /tmp/gsd-review-prompt-{phase}.md)" 2>/dev/null > /tmp/gsd-review-codex-{phase}.md
|
||||
```
|
||||
|
||||
**CodeRabbit:**
|
||||
|
||||
Note: CodeRabbit reviews the current git diff/working tree — it does not accept a prompt. It may take up to 5 minutes. Use `timeout: 360000` on the Bash tool call.
|
||||
|
||||
```bash
|
||||
coderabbit review --prompt-only 2>/dev/null > /tmp/gsd-review-coderabbit-{phase}.md
|
||||
```
|
||||
|
||||
If a CLI fails, log the error and continue with remaining CLIs.
|
||||
|
||||
Display progress:
|
||||
@@ -150,7 +160,7 @@ Combine all review responses into `{phase_dir}/{padded_phase}-REVIEWS.md`:
|
||||
```markdown
|
||||
---
|
||||
phase: {N}
|
||||
reviewers: [gemini, claude, codex]
|
||||
reviewers: [gemini, claude, codex, coderabbit]
|
||||
reviewed_at: {ISO timestamp}
|
||||
plans_reviewed: [{list of PLAN.md files}]
|
||||
---
|
||||
@@ -175,6 +185,12 @@ plans_reviewed: [{list of PLAN.md files}]
|
||||
|
||||
---
|
||||
|
||||
## CodeRabbit Review
|
||||
|
||||
{coderabbit review content}
|
||||
|
||||
---
|
||||
|
||||
## Consensus Summary
|
||||
|
||||
{synthesize common concerns across all reviewers}
|
||||
|
||||
164
get-shit-done/workflows/secure-phase.md
Normal file
164
get-shit-done/workflows/secure-phase.md
Normal file
@@ -0,0 +1,164 @@
|
||||
<purpose>
|
||||
Verify threat mitigations for a completed phase. Confirm PLAN.md threat register dispositions are resolved. Update SECURITY.md.
|
||||
</purpose>
|
||||
|
||||
<required_reading>
|
||||
@~/.claude/get-shit-done/references/ui-brand.md
|
||||
</required_reading>
|
||||
|
||||
<available_agent_types>
|
||||
Valid GSD subagent types (use exact names — do not fall back to 'general-purpose'):
|
||||
- gsd-security-auditor — Verifies threat mitigation coverage
|
||||
</available_agent_types>
|
||||
|
||||
<process>
|
||||
|
||||
## 0. Initialize
|
||||
|
||||
```bash
|
||||
INIT=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" init phase-op "${PHASE_ARG}")
|
||||
if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
|
||||
AGENT_SKILLS_AUDITOR=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" agent-skills gsd-security-auditor 2>/dev/null)
|
||||
```
|
||||
|
||||
Parse: `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`.
|
||||
|
||||
```bash
|
||||
AUDITOR_MODEL=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" resolve-model gsd-security-auditor --raw)
|
||||
SECURITY_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
|
||||
```
|
||||
|
||||
If `SECURITY_CFG` is `false`: exit with "Security enforcement disabled. Enable via /gsd:settings."
|
||||
|
||||
Display banner: `GSD > SECURE PHASE {N}: {name}`
|
||||
|
||||
## 1. Detect Input State
|
||||
|
||||
```bash
|
||||
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
|
||||
PLAN_FILES=$(ls "${PHASE_DIR}"/*-PLAN.md 2>/dev/null)
|
||||
SUMMARY_FILES=$(ls "${PHASE_DIR}"/*-SUMMARY.md 2>/dev/null)
|
||||
```
|
||||
|
||||
- **State A** (`SECURITY_FILE` non-empty): Audit existing
|
||||
- **State B** (`SECURITY_FILE` empty, `PLAN_FILES` and `SUMMARY_FILES` non-empty): Run from artifacts
|
||||
- **State C** (`SUMMARY_FILES` empty): Exit — "Phase {N} not executed. Run /gsd:execute-phase {N} first."
|
||||
|
||||
## 2. Discovery
|
||||
|
||||
### 2a. Read Phase Artifacts
|
||||
|
||||
Read PLAN.md — extract `<threat_model>` block: trust boundaries, STRIDE register (`threat_id`, `category`, `component`, `disposition`, `mitigation_plan`).
|
||||
|
||||
### 2b. Read Summary Threat Flags
|
||||
|
||||
Read SUMMARY.md — extract `## Threat Flags` entries.
|
||||
|
||||
### 2c. Build Threat Register
|
||||
|
||||
Per threat: `{ threat_id, category, component, disposition, mitigation_pattern, files_to_check }`
|
||||
|
||||
## 3. Threat Classification
|
||||
|
||||
Classify each threat:
|
||||
|
||||
| Status | Criteria |
|
||||
|--------|----------|
|
||||
| CLOSED | mitigation found OR accepted risk documented in SECURITY.md OR transfer documented |
|
||||
| OPEN | none of the above |
|
||||
|
||||
Build: `{ threat_id, category, component, disposition, status, evidence }`
|
||||
|
||||
If `threats_open: 0` → skip to Step 6 directly.
|
||||
|
||||
## 4. Present Threat Plan
|
||||
|
||||
Call AskUserQuestion with threat table and options:
|
||||
1. "Verify all open threats" → Step 5
|
||||
2. "Accept all open — document in accepted risks log" → add to SECURITY.md accepted risks, set all CLOSED, Step 6
|
||||
3. "Cancel" → exit
|
||||
|
||||
## 5. Spawn gsd-security-auditor
|
||||
|
||||
```
|
||||
Task(
|
||||
prompt="Read ~/.claude/agents/gsd-security-auditor.md for instructions.\n\n" +
|
||||
"<files_to_read>{PLAN, SUMMARY, impl files, SECURITY.md}</files_to_read>" +
|
||||
"<threat_register>{threat register}</threat_register>" +
|
||||
"<config>asvs_level: {SECURITY_ASVS}, block_on: {SECURITY_BLOCK_ON}</config>" +
|
||||
"<constraints>Never modify implementation files. Verify mitigations exist — do not scan for new threats. Escalate implementation gaps.</constraints>" +
|
||||
"${AGENT_SKILLS_AUDITOR}",
|
||||
subagent_type="gsd-security-auditor",
|
||||
model="{AUDITOR_MODEL}",
|
||||
description="Verify threat mitigations for Phase {N}"
|
||||
)
|
||||
```
|
||||
|
||||
Handle return:
|
||||
- `## SECURED` → record closures → Step 6
|
||||
- `## OPEN_THREATS` → record closed + open, present user with accept/block choice → Step 6
|
||||
- `## ESCALATE` → present to user → Step 6
|
||||
|
||||
## 6. Write/Update SECURITY.md
|
||||
|
||||
**State B (create):**
|
||||
1. Read template from `~/.claude/get-shit-done/templates/SECURITY.md`
|
||||
2. Fill: frontmatter, threat register, accepted risks, audit trail
|
||||
3. Write to `${PHASE_DIR}/${PADDED_PHASE}-SECURITY.md`
|
||||
|
||||
**State A (update):**
|
||||
1. Update threat register statuses, append to audit trail:
|
||||
|
||||
```markdown
|
||||
## Security Audit {date}
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| Threats found | {N} |
|
||||
| Closed | {M} |
|
||||
| Open | {K} |
|
||||
```
|
||||
|
||||
**ENFORCING GATE:** If `threats_open > 0` after all options exhausted (user did not accept, not all verified closed):
|
||||
|
||||
```
|
||||
GSD > PHASE {N} SECURITY BLOCKED
|
||||
{K} threats open — phase advancement blocked until threats_open: 0
|
||||
▶ Fix mitigations then re-run: /gsd:secure-phase {N}
|
||||
▶ Or document accepted risks in SECURITY.md and re-run.
|
||||
```
|
||||
|
||||
Do NOT emit next-phase routing. Stop here.
|
||||
|
||||
## 7. Commit
|
||||
|
||||
```bash
|
||||
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" commit "docs(phase-${PHASE}): add/update security threat verification"
|
||||
```
|
||||
|
||||
## 8. Results + Routing
|
||||
|
||||
**Secured (threats_open: 0):**
|
||||
```
|
||||
GSD > PHASE {N} THREAT-SECURE
|
||||
threats_open: 0 — all threats have dispositions.
|
||||
▶ /gsd:validate-phase {N} validate test coverage
|
||||
▶ /gsd:verify-work {N} run UAT
|
||||
```
|
||||
|
||||
Display `/clear` reminder.
|
||||
|
||||
</process>
|
||||
|
||||
<success_criteria>
|
||||
- [ ] Security enforcement checked — exit if false
|
||||
- [ ] Input state detected (A/B/C) — state C exits cleanly
|
||||
- [ ] PLAN.md threat model parsed, register built
|
||||
- [ ] SUMMARY.md threat flags incorporated
|
||||
- [ ] threats_open: 0 → skip directly to Step 6
|
||||
- [ ] User gate with threat table presented
|
||||
- [ ] Auditor spawned with complete context
|
||||
- [ ] All three return formats (SECURED/OPEN_THREATS/ESCALATE) handled
|
||||
- [ ] SECURITY.md created or updated
|
||||
- [ ] threats_open > 0 BLOCKS advancement (no next-phase routing emitted)
|
||||
- [ ] Results with routing presented on success
|
||||
</success_criteria>
|
||||
@@ -199,11 +199,18 @@ Format each as: Test Name → What to do → Expected result → Why can't verif
|
||||
</step>
|
||||
|
||||
<step name="determine_status">
|
||||
**passed:** All truths VERIFIED, all artifacts pass levels 1-3, all key links WIRED, no blocker anti-patterns.
|
||||
Classify status using this decision tree IN ORDER (most restrictive first):
|
||||
|
||||
**gaps_found:** Any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, or blocker found.
|
||||
1. IF any truth FAILED, artifact MISSING/STUB, key link NOT_WIRED, or blocker found:
|
||||
→ **gaps_found**
|
||||
|
||||
**human_needed:** All automated checks pass but human verification items remain.
|
||||
2. IF the previous step produced ANY human verification items:
|
||||
→ **human_needed** (even if all truths VERIFIED and score is N/N)
|
||||
|
||||
3. IF all checks pass AND no human verification items:
|
||||
→ **passed**
|
||||
|
||||
**passed is ONLY valid when no human verification items exist.**
|
||||
|
||||
**Score:** `verified_truths / total_truths`
|
||||
</step>
|
||||
|
||||
@@ -375,11 +375,38 @@ Present summary:
|
||||
**If issues > 0:** Proceed to `diagnose_issues`
|
||||
|
||||
**If issues == 0:**
|
||||
|
||||
```bash
|
||||
SECURITY_CFG=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
|
||||
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
|
||||
```
|
||||
|
||||
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty:
|
||||
```
|
||||
⚠ Security enforcement enabled — /gsd:secure-phase {phase} has not run.
|
||||
Run before advancing to the next phase.
|
||||
|
||||
All tests passed. Ready to continue.
|
||||
|
||||
- `/gsd:secure-phase {phase}` — security review (required before advancing)
|
||||
- `/gsd:plan-phase {next}` — Plan next phase
|
||||
- `/gsd:execute-phase {next}` — Execute next phase
|
||||
- `/gsd:ui-review {phase}` — visual quality audit (if frontend files were modified)
|
||||
```
|
||||
|
||||
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` exists: check frontmatter `threats_open`. If > 0:
|
||||
```
|
||||
⚠ Security gate: {threats_open} threats open
|
||||
/gsd:secure-phase {phase} — resolve before advancing
|
||||
```
|
||||
|
||||
If `SECURITY_CFG` is `false` OR (`SECURITY_FILE` exists AND `threats_open` is `0`):
|
||||
```
|
||||
All tests passed. Ready to continue.
|
||||
|
||||
- `/gsd:plan-phase {next}` — Plan next phase
|
||||
- `/gsd:execute-phase {next}` — Execute next phase
|
||||
- `/gsd:secure-phase {phase}` — security review
|
||||
- `/gsd:ui-review {phase}` — visual quality audit (if frontend files were modified)
|
||||
```
|
||||
</step>
|
||||
|
||||
Reference in New Issue
Block a user