Harden the shared console install, launcher, Loop staging, spec state and prompts

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-08 13:48:28 -08:00
1 parent 120c259d9c
commit 3ee96834bf
130 files changed
+5988 -1434

No files matched your search

+31
View File
@@ -186,6 +186,37 @@ describe('installSkillsForBot', () => {
expect(content).toContain('name: doc');
});
it('copies the whole skill folder, references and scripts included', () => {
const srcDir = path.join(fakeHome, '.claude', 'skills', 'plan2code-3-implement');
fs.ensureDirSync(path.join(srcDir, 'references', 'web-console', 'notes'));
fs.ensureDirSync(path.join(srcDir, 'scripts'));
fs.writeFileSync(path.join(srcDir, 'SKILL.md'), 'disable-model-invocation: true\n---\nname: impl\n---\nBody');
fs.writeFileSync(path.join(srcDir, 'references', 'implement.md'), 'implement rules');
fs.writeFileSync(path.join(srcDir, 'references', 'web-console', 'notes', 'implement.md'), 'console notes');
fs.writeFileSync(path.join(srcDir, 'scripts', 'specs.mjs'), 'export {};');
installSkillsForBot(projectDir);
const dest = path.join(projectDir, '.claude', 'skills', 'plan2code-3-implement');
expect(fs.readFileSync(path.join(dest, 'references', 'implement.md'), 'utf-8')).toBe('implement rules');
expect(fs.readFileSync(path.join(dest, 'references', 'web-console', 'notes', 'implement.md'), 'utf-8')).toBe('console notes');
expect(fs.readFileSync(path.join(dest, 'scripts', 'specs.mjs'), 'utf-8')).toBe('export {};');
expect(fs.readFileSync(path.join(dest, 'SKILL.md'), 'utf-8')).not.toContain('disable-model-invocation');
});
it('copies only its five skills, not every installed plan2code skill', () => {
for (const name of ['plan2code-init', 'plan2code-git', 'plan2code-quick-task']) {
const dir = path.join(fakeHome, '.claude', 'skills', name);
fs.ensureDirSync(dir);
fs.writeFileSync(path.join(dir, 'SKILL.md'), 'content');
}
installSkillsForBot(projectDir);
const skills = fs.readdirSync(path.join(projectDir, '.claude', 'skills'));
expect(skills).toEqual(['plan2code-init']);
});
it('skips gracefully when source skill does not exist', () => {
// No skills in fakeHome — should not throw
expect(() => installSkillsForBot(projectDir)).not.toThrow();
+10 -6
View File
@@ -33,7 +33,9 @@ const SKILL_MAP: Record<StepName, string> = {
* Install bot-friendly copies of plan2code skills into the project's .claude/skills/.
* The global skills have `disable-model-invocation: true` which prevents the autonomous
* session from invoking them via the Skill tool. We copy them with that flag removed
* so the session can invoke the real workflow prompts instead of guessing.
* so the session can open and follow the real workflow prompts instead of guessing.
* The whole skill folder is copied (its references and scripts too), because a skill
* reads its references and runs its shipped scripts by path from beside SKILL.md.
*/
export function installSkillsForBot(projectDir: string): void {
const userSkillsDir = path.join(
@@ -44,15 +46,17 @@ export function installSkillsForBot(projectDir: string): void {
const projectSkillsDir = path.join(projectDir, '.claude', 'skills');
for (const skillName of Object.values(SKILL_MAP)) {
const srcFile = path.join(userSkillsDir, skillName, 'SKILL.md');
const srcDir = path.join(userSkillsDir, skillName);
const srcFile = path.join(srcDir, 'SKILL.md');
if (!fs.existsSync(srcFile)) continue;
const content = fs.readFileSync(srcFile, 'utf-8');
// Remove the disable-model-invocation line so the bot session can invoke the skill
const patched = content.replace(/^disable-model-invocation:\s*true\n?/m, '');
const destDir = path.join(projectSkillsDir, skillName);
fs.ensureDirSync(destDir);
fs.copySync(srcDir, destDir, { overwrite: true });
// Remove the disable-model-invocation line so the bot session can use the skill
const content = fs.readFileSync(srcFile, 'utf-8');
const patched = content.replace(/^disable-model-invocation:\s*true\n?/m, '');
fs.writeFileSync(path.join(destDir, 'SKILL.md'), patched);
}
}
@@ -24,14 +24,16 @@ describe('buildStepPrompt', () => {
expect(prompt).toContain('/plan2code-init');
});
it('plan prompt includes /plan2code-1-plan skill invocation', () => {
it('plan prompt says to open the skill file and follow it', () => {
const prompt = buildStepPrompt('plan', config);
expect(prompt).toContain('/plan2code-1-plan');
expect(prompt).toContain('Open the skill file .claude/skills/plan2code-1-plan/SKILL.md and follow it');
expect(prompt).not.toContain('Run the /plan2code');
});
it('document prompt includes /plan2code-2-document skill invocation', () => {
it('document prompt says to open the skill file and follow it', () => {
const prompt = buildStepPrompt('document', config);
expect(prompt).toContain('/plan2code-2-document');
expect(prompt).toContain('Open the skill file .claude/skills/plan2code-2-document/SKILL.md and follow it');
expect(prompt).not.toContain('Run the /plan2code');
});
it('implement prompt instructs direct tool usage without skill invocation', () => {
@@ -39,9 +41,10 @@ describe('buildStepPrompt', () => {
expect(prompt).toContain('Do NOT use the Skill tool');
});
it('finalize prompt includes /plan2code-4-finalize skill invocation', () => {
it('finalize prompt says to open the skill file and follow it', () => {
const prompt = buildStepPrompt('finalize', config);
expect(prompt).toContain('/plan2code-4-finalize');
expect(prompt).toContain('Open the skill file .claude/skills/plan2code-4-finalize/SKILL.md and follow it');
expect(prompt).not.toContain('Run the /plan2code');
});
it('plan prompt includes project name and description', () => {
@@ -56,7 +56,7 @@ If IDEA.md does not already exist, create it with the project name and descripti
function buildPlanPrompt(config: BotConfig): string {
return `${AUTONOMOUS_PREAMBLE}
Run the /plan2code-1-plan skill to create a plan for this project.
Open the skill file .claude/skills/plan2code-1-plan/SKILL.md and follow it to create a plan for this project.
Read the IDEA.md file first to understand the project. The project is: ${config.ideaDescription}
@@ -72,7 +72,7 @@ When making decisions during planning:
function buildDocumentPrompt(config: BotConfig): string {
return `${AUTONOMOUS_PREAMBLE}
Run the /plan2code-2-document skill to transform the plan into implementation specs.
Open the skill file .claude/skills/plan2code-2-document/SKILL.md and follow it to transform the plan into implementation specs.
Read the existing plan output in specs/ first to understand what was planned.
@@ -121,7 +121,7 @@ You are a senior software engineer implementing a project phase. Do NOT use the
function buildFinalizePrompt(config: BotConfig): string {
return `${AUTONOMOUS_PREAMBLE}
Run the /plan2code-4-finalize skill to validate and archive the completed project.
Open the skill file .claude/skills/plan2code-4-finalize/SKILL.md and follow it to validate and archive the completed project.
When making decisions:
- Approve all documentation updates