merge: resolve conflicts with main (plan_bounce + code_review_command)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-04-11 10:32:20 -04:00
25 changed files with 1870 additions and 144 deletions

View File

@@ -638,6 +638,11 @@ async function runCommand(command, args, cwd, raw, defaultValue) {
break;
}
case 'skill-manifest': {
init.cmdSkillManifest(cwd, args, raw);
break;
}
case 'history-digest': {
commands.cmdHistoryDigest(cwd, raw);
break;

View File

@@ -26,6 +26,9 @@ const VALID_CONFIG_KEYS = new Set([
'workflow.code_review',
'workflow.code_review_depth',
'workflow.code_review_command',
'workflow.plan_bounce',
'workflow.plan_bounce_script',
'workflow.plan_bounce_passes',
'git.branching_strategy', 'git.base_branch', 'git.phase_branch_template', 'git.milestone_branch_template', 'git.quick_branch_template',
'planning.commit_docs', 'planning.search_gitignored',
'workflow.subagent_timeout',
@@ -38,6 +41,7 @@ const VALID_CONFIG_KEYS = new Set([
'manager.flags.discuss', 'manager.flags.plan', 'manager.flags.execute',
'response_language',
'intel.enabled',
'claude_md_path',
]);
/**
@@ -157,6 +161,9 @@ function buildNewProjectConfig(userChoices) {
code_review: true,
code_review_depth: 'standard',
code_review_command: null,
plan_bounce: false,
plan_bounce_script: null,
plan_bounce_passes: 2,
},
hooks: {
context_warnings: true,
@@ -164,6 +171,7 @@ function buildNewProjectConfig(userChoices) {
project_code: null,
phase_naming: 'sequential',
agent_skills: {},
claude_md_path: './CLAUDE.md',
};
// Three-level deep merge: hardcoded <- userDefaults <- choices

View File

@@ -159,14 +159,25 @@ function findProjectRoot(startDir) {
* @param {number} opts.maxAgeMs - max age in ms before removal (default: 5 min)
* @param {boolean} opts.dirsOnly - if true, only remove directories (default: false)
*/
/**
* Dedicated GSD temp directory: path.join(os.tmpdir(), 'gsd').
* Created on first use. Keeps GSD temp files isolated from the system
* temp directory so reap scans only GSD files (#1975).
*/
const GSD_TEMP_DIR = path.join(require('os').tmpdir(), 'gsd');
function ensureGsdTempDir() {
fs.mkdirSync(GSD_TEMP_DIR, { recursive: true });
}
function reapStaleTempFiles(prefix = 'gsd-', { maxAgeMs = 5 * 60 * 1000, dirsOnly = false } = {}) {
try {
const tmpDir = require('os').tmpdir();
ensureGsdTempDir();
const now = Date.now();
const entries = fs.readdirSync(tmpDir);
const entries = fs.readdirSync(GSD_TEMP_DIR);
for (const entry of entries) {
if (!entry.startsWith(prefix)) continue;
const fullPath = path.join(tmpDir, entry);
const fullPath = path.join(GSD_TEMP_DIR, entry);
try {
const stat = fs.statSync(fullPath);
if (now - stat.mtimeMs > maxAgeMs) {
@@ -195,7 +206,8 @@ function output(result, raw, rawValue) {
// Write to tmpfile and output the path prefixed with @file: so callers can detect it.
if (json.length > 50000) {
reapStaleTempFiles();
const tmpPath = path.join(require('os').tmpdir(), `gsd-${Date.now()}.json`);
ensureGsdTempDir();
const tmpPath = path.join(GSD_TEMP_DIR, `gsd-${Date.now()}.json`);
fs.writeFileSync(tmpPath, json, 'utf-8');
data = '@file:' + tmpPath;
} else {
@@ -313,7 +325,7 @@ function loadConfig(cwd) {
// Section containers that hold nested sub-keys
'git', 'workflow', 'planning', 'hooks', 'features',
// Internal keys loadConfig reads but config-set doesn't expose
'model_overrides', 'agent_skills', 'context_window', 'resolve_model_ids',
'model_overrides', 'agent_skills', 'context_window', 'resolve_model_ids', 'claude_md_path',
// Deprecated keys (still accepted for migration, not in config-set)
'depth', 'multiRepo',
]);
@@ -374,6 +386,7 @@ function loadConfig(cwd) {
agent_skills: parsed.agent_skills || {},
manager: parsed.manager || {},
response_language: get('response_language') || null,
claude_md_path: get('claude_md_path') || null,
};
} catch {
// Fall back to ~/.gsd/defaults.json only for truly pre-project contexts (#1683)
@@ -1578,6 +1591,7 @@ module.exports = {
findProjectRoot,
detectSubRepos,
reapStaleTempFiles,
GSD_TEMP_DIR,
MODEL_ALIAS_MAP,
CONFIG_DEFAULTS,
planningDir,

View File

@@ -1513,6 +1513,105 @@ function cmdAgentSkills(cwd, agentType, raw) {
process.exit(0);
}
/**
* Generate a skill manifest from a skills directory.
*
* Scans the given skills directory for subdirectories containing SKILL.md,
* extracts frontmatter (name, description) and trigger conditions from the
* body text, and returns an array of skill descriptors.
*
* @param {string} skillsDir - Absolute path to the skills directory
* @returns {Array<{name: string, description: string, triggers: string[], path: string}>}
*/
function buildSkillManifest(skillsDir) {
const { extractFrontmatter } = require('./frontmatter.cjs');
if (!fs.existsSync(skillsDir)) return [];
let entries;
try {
entries = fs.readdirSync(skillsDir, { withFileTypes: true });
} catch {
return [];
}
const manifest = [];
for (const entry of entries) {
if (!entry.isDirectory()) continue;
const skillMdPath = path.join(skillsDir, entry.name, 'SKILL.md');
if (!fs.existsSync(skillMdPath)) continue;
let content;
try {
content = fs.readFileSync(skillMdPath, 'utf-8');
} catch {
continue;
}
const frontmatter = extractFrontmatter(content);
const name = frontmatter.name || entry.name;
const description = frontmatter.description || '';
// Extract trigger lines from body text (after frontmatter)
const triggers = [];
const bodyMatch = content.match(/^---[\s\S]*?---\s*\n([\s\S]*)$/);
if (bodyMatch) {
const body = bodyMatch[1];
const triggerLines = body.match(/^TRIGGER\s+when:\s*(.+)$/gmi);
if (triggerLines) {
for (const line of triggerLines) {
const m = line.match(/^TRIGGER\s+when:\s*(.+)$/i);
if (m) triggers.push(m[1].trim());
}
}
}
manifest.push({
name,
description,
triggers,
path: entry.name,
});
}
// Sort by name for deterministic output
manifest.sort((a, b) => a.name.localeCompare(b.name));
return manifest;
}
/**
* Command: generate skill manifest JSON.
*
* Options:
* --skills-dir <path> Path to skills directory (required)
* --write Also write to .planning/skill-manifest.json
*/
function cmdSkillManifest(cwd, args, raw) {
const skillsDirIdx = args.indexOf('--skills-dir');
const skillsDir = skillsDirIdx >= 0 && args[skillsDirIdx + 1]
? args[skillsDirIdx + 1]
: null;
if (!skillsDir) {
output([], raw);
return;
}
const manifest = buildSkillManifest(skillsDir);
// Optionally write to .planning/skill-manifest.json
if (args.includes('--write')) {
const planningDir = path.join(cwd, '.planning');
if (fs.existsSync(planningDir)) {
const manifestPath = path.join(planningDir, 'skill-manifest.json');
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
}
}
output(manifest, raw);
}
module.exports = {
cmdInitExecutePhase,
cmdInitPlanPhase,
@@ -1533,4 +1632,6 @@ module.exports = {
detectChildRepos,
buildAgentSkillsBlock,
cmdAgentSkills,
buildSkillManifest,
cmdSkillManifest,
};

View File

@@ -12,7 +12,7 @@
const fs = require('fs');
const path = require('path');
const os = require('os');
const { output, error, safeReadFile } = require('./core.cjs');
const { output, error, safeReadFile, loadConfig } = require('./core.cjs');
// ─── Constants ────────────────────────────────────────────────────────────────
@@ -870,7 +870,13 @@ function cmdGenerateClaudeProfile(cwd, options, raw) {
} else if (options.output) {
targetPath = path.isAbsolute(options.output) ? options.output : path.join(cwd, options.output);
} else {
targetPath = path.join(cwd, 'CLAUDE.md');
// Read claude_md_path from config, default to ./CLAUDE.md
let configClaudeMdPath = './CLAUDE.md';
try {
const config = loadConfig(cwd);
if (config.claude_md_path) configClaudeMdPath = config.claude_md_path;
} catch { /* use default */ }
targetPath = path.isAbsolute(configClaudeMdPath) ? configClaudeMdPath : path.join(cwd, configClaudeMdPath);
}
let action;
@@ -944,7 +950,13 @@ function cmdGenerateClaudeMd(cwd, options, raw) {
let outputPath = options.output;
if (!outputPath) {
outputPath = path.join(cwd, 'CLAUDE.md');
// Read claude_md_path from config, default to ./CLAUDE.md
let configClaudeMdPath = './CLAUDE.md';
try {
const config = loadConfig(cwd);
if (config.claude_md_path) configClaudeMdPath = config.claude_md_path;
} catch { /* use default */ }
outputPath = path.isAbsolute(configClaudeMdPath) ? configClaudeMdPath : path.join(cwd, configClaudeMdPath);
} else if (!path.isAbsolute(outputPath)) {
outputPath = path.join(cwd, outputPath);
}