2026-03-01 21:30:45 -08:00
|
|
|
import { runCLI } from '../cli.js';
|
|
|
|
|
|
2026-05-11 13:14:28 -07:00
|
|
|
function showHelp(): void {
|
|
|
|
|
console.log(`
|
|
|
|
|
+----------------------------------------------------------------+
|
2026-05-23 06:58:20 -07:00
|
|
|
— PLAN2CODEDE-BOT —
|
|
|
|
|
—----------------------------------------------------------------—
|
|
|
|
|
— Autonomous workflow test runner foplan2codede —
|
|
|
|
|
— Features LLM-as-judge for honest quality evaluation —
|
2026-05-11 13:14:28 -07:00
|
|
|
+----------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
plan2code-bot [options]
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
--help Show this help message
|
|
|
|
|
--idea <string> Seed the idea generator with a specific concept
|
|
|
|
|
Example: --idea "web app for weather"
|
|
|
|
|
Example: --idea="CLI tool for CSV conversion"
|
|
|
|
|
--resume Resume a previous incomplete run
|
|
|
|
|
|
|
|
|
|
Modes:
|
2026-05-23 06:58:20 -07:00
|
|
|
— New Project Mode - Run from empty directory
|
2026-05-11 13:14:28 -07:00
|
|
|
The bot generates an app idea, creates a subdirectory, writes
|
|
|
|
|
IDEA.md, runs init, then all 4 workflow steps.
|
|
|
|
|
|
2026-05-23 06:58:20 -07:00
|
|
|
— Enhancement Mode - Run from directory with AGENTS.md
|
2026-05-11 13:14:28 -07:00
|
|
|
The bot scans the existing codebase, proposes an enhancement,
|
|
|
|
|
writes IDEA.md, then runs plan through finalize.
|
|
|
|
|
|
|
|
|
|
Evaluation:
|
|
|
|
|
The bot acts as an authentic QA agent, using LLM-based decision
|
|
|
|
|
making during execution and providing honest quality assessments
|
|
|
|
|
after each step. Results are written to specs/<feature>/BOT-EVALUATION.md
|
|
|
|
|
and specs/<feature>/BOT-NOTES.md for metrics analysis.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
# New project (from empty directory)
|
|
|
|
|
plan2code-bot
|
|
|
|
|
|
|
|
|
|
# Enhancement (from existing project)
|
|
|
|
|
cd my-project && plan2code-bot
|
|
|
|
|
|
|
|
|
|
# With specific idea
|
|
|
|
|
plan2code-bot --idea "markdown editor with live preview"
|
|
|
|
|
|
|
|
|
|
# Resume incomplete run
|
|
|
|
|
plan2code-bot --resume
|
|
|
|
|
|
|
|
|
|
Documentation:
|
2026-08-08 12:39:52 -07:00
|
|
|
https://github.com/jparkerweb/plan2code
|
2026-05-11 13:14:28 -07:00
|
|
|
`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stripQuotes(str: string): string {
|
|
|
|
|
// Remove surrounding quotes if present (both single and double)
|
|
|
|
|
if ((str.startsWith('"') && str.endsWith('"')) ||
|
|
|
|
|
(str.startsWith("'") && str.endsWith("'"))) {
|
|
|
|
|
return str.slice(1, -1);
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseArgs(): { idea?: string; resume?: boolean; help?: boolean } {
|
2026-03-01 21:30:45 -08:00
|
|
|
const args = process.argv.slice(2);
|
2026-05-11 13:14:28 -07:00
|
|
|
|
|
|
|
|
// Check for --help
|
|
|
|
|
if (args.includes('--help') || args.includes('-h')) {
|
|
|
|
|
return { help: true };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parse --idea (supports both --idea="value" and --idea "value")
|
|
|
|
|
let idea: string | undefined;
|
|
|
|
|
for (let i = 0; i < args.length; i++) {
|
|
|
|
|
const arg = args[i];
|
|
|
|
|
|
|
|
|
|
// Format: --idea="value"
|
|
|
|
|
if (arg.startsWith('--idea=')) {
|
|
|
|
|
idea = stripQuotes(arg.substring('--idea='.length));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Format: --idea "value"
|
|
|
|
|
if (arg === '--idea' && i + 1 < args.length) {
|
|
|
|
|
idea = stripQuotes(args[i + 1]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parse --resume
|
2026-03-01 21:30:45 -08:00
|
|
|
const resume = args.includes('--resume');
|
2026-05-11 13:14:28 -07:00
|
|
|
|
2026-03-01 21:30:45 -08:00
|
|
|
return { idea, resume: resume || undefined };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
|
try {
|
2026-05-11 13:14:28 -07:00
|
|
|
const { idea, resume, help } = parseArgs();
|
|
|
|
|
|
|
|
|
|
if (help) {
|
|
|
|
|
showHelp();
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-01 21:30:45 -08:00
|
|
|
await runCLI({ idea, resume });
|
|
|
|
|
process.exit(0);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (err instanceof Error && err.message.includes('User force closed')) {
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}
|
|
|
|
|
console.error(err instanceof Error ? err.message : String(err));
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main();
|