plan-review 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formatter.d.ts +2 -0
- package/dist/formatter.js +45 -0
- package/dist/formatter.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -0
- package/dist/navigator.d.ts +5 -0
- package/dist/navigator.js +93 -0
- package/dist/navigator.js.map +1 -0
- package/dist/output.d.ts +7 -0
- package/dist/output.js +85 -0
- package/dist/output.js.map +1 -0
- package/dist/parser.d.ts +3 -0
- package/dist/parser.js +265 -0
- package/dist/parser.js.map +1 -0
- package/dist/renderer.d.ts +3 -0
- package/dist/renderer.js +78 -0
- package/dist/renderer.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function formatReview(doc) {
|
|
2
|
+
const commentedSectionIds = new Set(doc.comments.map((c) => c.sectionId));
|
|
3
|
+
const reviewableSections = doc.sections.filter((s) => doc.mode === 'plan' ? s.level === 3 : s.level >= 2);
|
|
4
|
+
const commentedSections = reviewableSections.filter((s) => commentedSectionIds.has(s.id));
|
|
5
|
+
const parts = [];
|
|
6
|
+
parts.push(`# Plan Review: ${doc.title}`);
|
|
7
|
+
parts.push('');
|
|
8
|
+
parts.push('## Review Summary');
|
|
9
|
+
parts.push(`- **Sections reviewed:** ${commentedSections.length}/${reviewableSections.length}`);
|
|
10
|
+
parts.push(`- **Comments:** ${doc.comments.length}`);
|
|
11
|
+
parts.push(`- **Skipped:** ${reviewableSections.length - commentedSections.length} sections without comments`);
|
|
12
|
+
parts.push('');
|
|
13
|
+
parts.push('---');
|
|
14
|
+
for (const section of commentedSections) {
|
|
15
|
+
const sectionComments = doc.comments.filter((c) => c.sectionId === section.id);
|
|
16
|
+
parts.push('');
|
|
17
|
+
parts.push(`## Section ${section.id}: ${section.heading}`);
|
|
18
|
+
parts.push('');
|
|
19
|
+
if (doc.mode === 'plan' && section.dependencies) {
|
|
20
|
+
const deps = section.dependencies;
|
|
21
|
+
if (deps.dependsOn.length > 0) {
|
|
22
|
+
parts.push(`Depends on: ${deps.dependsOn.join(', ')}`);
|
|
23
|
+
}
|
|
24
|
+
if (deps.blocks.length > 0) {
|
|
25
|
+
parts.push(`Blocks: ${deps.blocks.join(', ')}`);
|
|
26
|
+
}
|
|
27
|
+
parts.push('');
|
|
28
|
+
}
|
|
29
|
+
parts.push('### Original Content');
|
|
30
|
+
const blockquoted = section.body
|
|
31
|
+
.split('\n')
|
|
32
|
+
.map((line) => `> ${line}`)
|
|
33
|
+
.join('\n');
|
|
34
|
+
parts.push(blockquoted);
|
|
35
|
+
parts.push('');
|
|
36
|
+
for (const comment of sectionComments) {
|
|
37
|
+
parts.push('### Reviewer Comment');
|
|
38
|
+
parts.push(comment.text);
|
|
39
|
+
parts.push('');
|
|
40
|
+
}
|
|
41
|
+
parts.push('---');
|
|
42
|
+
}
|
|
43
|
+
return parts.join('\n');
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAiB;IAC5C,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,MAAM,kBAAkB,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACnD,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CACn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|
+
import { Command } from 'commander';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import * as readline from 'node:readline';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { parse } from './parser.js';
|
|
8
|
+
import { navigate } from './navigator.js';
|
|
9
|
+
import { formatReview } from './formatter.js';
|
|
10
|
+
import { writeOutput, isClaudeAvailable } from './output.js';
|
|
11
|
+
const program = new Command();
|
|
12
|
+
program
|
|
13
|
+
.name('plan-review')
|
|
14
|
+
.description('Interactive CLI for reviewing AI-generated markdown plans')
|
|
15
|
+
.version('0.1.0')
|
|
16
|
+
.argument('[file]', 'Path to markdown file (omit to read stdin)')
|
|
17
|
+
.option('-o, --output <target>', 'Output target: stdout, clipboard, file, claude')
|
|
18
|
+
.option('--output-file <path>', 'Custom output file path (with --output file)')
|
|
19
|
+
.option('--split-by <strategy>', 'Force split strategy: heading, separator')
|
|
20
|
+
.action(async (file, opts) => {
|
|
21
|
+
try {
|
|
22
|
+
await run(file, opts);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof Error) {
|
|
26
|
+
console.error(chalk.red(`Error: ${err.message}`));
|
|
27
|
+
}
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
program.parse();
|
|
32
|
+
async function run(file, opts) {
|
|
33
|
+
// Validate explicit output target early, before the review starts
|
|
34
|
+
const validTargets = ['stdout', 'clipboard', 'file', 'claude'];
|
|
35
|
+
if (opts.output !== undefined) {
|
|
36
|
+
const explicitTarget = opts.output;
|
|
37
|
+
if (!validTargets.includes(explicitTarget)) {
|
|
38
|
+
throw new Error(`Invalid output target: "${opts.output}". Use: ${validTargets.join(', ')}`);
|
|
39
|
+
}
|
|
40
|
+
// Fail fast: check claude availability before starting review
|
|
41
|
+
if (explicitTarget === 'claude' && !isClaudeAvailable()) {
|
|
42
|
+
console.error(chalk.red('Claude CLI not found in PATH.'));
|
|
43
|
+
console.error(chalk.dim('Install: https://docs.anthropic.com/en/docs/claude-code'));
|
|
44
|
+
console.error(chalk.yellow('Will fall back to stdout after review.'));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Read input — track whether it came from stdin
|
|
48
|
+
const inputFromStdin = !file && !process.stdin.isTTY;
|
|
49
|
+
const input = readInput(file);
|
|
50
|
+
if (!input.trim()) {
|
|
51
|
+
console.error(chalk.yellow('Empty file, nothing to review.'));
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
// Parse
|
|
55
|
+
const splitStrategy = opts.splitBy === 'heading' ? 'heading'
|
|
56
|
+
: opts.splitBy === 'separator' ? 'separator'
|
|
57
|
+
: 'auto';
|
|
58
|
+
const doc = parse(input, splitStrategy);
|
|
59
|
+
console.error(chalk.dim(`Detected mode: ${doc.mode} | ${doc.sections.length} sections`));
|
|
60
|
+
// Navigate (interactive review)
|
|
61
|
+
// When input came from stdin, navigator opens /dev/tty for prompts
|
|
62
|
+
const reviewed = await navigate(doc, inputFromStdin);
|
|
63
|
+
// Determine output target after review is complete
|
|
64
|
+
let outputTarget;
|
|
65
|
+
if (opts.output !== undefined) {
|
|
66
|
+
outputTarget = opts.output;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
outputTarget = await promptOutputTarget(inputFromStdin);
|
|
70
|
+
// Check claude availability after prompting
|
|
71
|
+
if (outputTarget === 'claude' && !isClaudeAvailable()) {
|
|
72
|
+
console.error(chalk.red('Claude CLI not found in PATH.'));
|
|
73
|
+
console.error(chalk.dim('Install: https://docs.anthropic.com/en/docs/claude-code'));
|
|
74
|
+
console.error(chalk.yellow('Falling back to stdout.'));
|
|
75
|
+
outputTarget = 'stdout';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Format and output
|
|
79
|
+
const output = formatReview(reviewed);
|
|
80
|
+
writeOutput(output, outputTarget, { outputFile: opts.outputFile, inputFile: file });
|
|
81
|
+
}
|
|
82
|
+
async function promptOutputTarget(inputFromStdin) {
|
|
83
|
+
const ttyInput = inputFromStdin
|
|
84
|
+
? (await import('node:fs')).createReadStream('/dev/tty')
|
|
85
|
+
: process.stdin;
|
|
86
|
+
const rl = readline.createInterface({
|
|
87
|
+
input: ttyInput,
|
|
88
|
+
output: process.stderr,
|
|
89
|
+
});
|
|
90
|
+
const answer = await new Promise((resolve) => {
|
|
91
|
+
rl.question(chalk.cyan('> Output: (s)tdout, (c)lipboard, (f)ile, cl(a)ude? '), (a) => resolve(a.trim().toLowerCase()));
|
|
92
|
+
});
|
|
93
|
+
rl.close();
|
|
94
|
+
switch (answer) {
|
|
95
|
+
case 's':
|
|
96
|
+
case 'stdout': return 'stdout';
|
|
97
|
+
case 'c':
|
|
98
|
+
case 'clipboard': return 'clipboard';
|
|
99
|
+
case 'f':
|
|
100
|
+
case 'file': return 'file';
|
|
101
|
+
case 'a':
|
|
102
|
+
case 'claude': return 'claude';
|
|
103
|
+
default: return 'stdout';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function readInput(file) {
|
|
107
|
+
if (file) {
|
|
108
|
+
if (!existsSync(file)) {
|
|
109
|
+
throw new Error(`File not found: ${file}`);
|
|
110
|
+
}
|
|
111
|
+
return readFileSync(file, 'utf-8');
|
|
112
|
+
}
|
|
113
|
+
// Read from stdin (piped)
|
|
114
|
+
if (!process.stdin.isTTY) {
|
|
115
|
+
return readFileSync('/dev/stdin', 'utf-8');
|
|
116
|
+
}
|
|
117
|
+
// No file, no stdin pipe — show help
|
|
118
|
+
program.help();
|
|
119
|
+
return ''; // unreachable
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACv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AAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,qCAAqC;IACrC,OAAO,CAAC,IAAI,EAAE,CAAC;IACf,OAAO,EAAE,CAAC,CAAC,cAAc;AAC3B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PlanDocument, Section } from './types.js';
|
|
2
|
+
export declare function navigate(doc: PlanDocument, inputFromStdin?: boolean): Promise<PlanDocument>;
|
|
3
|
+
export declare function findSection(doc: PlanDocument, input: string): Section | undefined;
|
|
4
|
+
export declare function getReviewableSections(doc: PlanDocument): Section[];
|
|
5
|
+
export declare function printSummary(doc: PlanDocument): void;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as readline from 'node:readline';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { renderSection, renderToc } from './renderer.js';
|
|
4
|
+
export async function navigate(doc, inputFromStdin = false) {
|
|
5
|
+
// When input was read from stdin, stdin is exhausted.
|
|
6
|
+
// Open /dev/tty directly for interactive prompts.
|
|
7
|
+
const ttyInput = inputFromStdin
|
|
8
|
+
? (await import('node:fs')).createReadStream('/dev/tty')
|
|
9
|
+
: process.stdin;
|
|
10
|
+
const rl = readline.createInterface({
|
|
11
|
+
input: ttyInput,
|
|
12
|
+
output: process.stderr,
|
|
13
|
+
});
|
|
14
|
+
const ask = (prompt) => new Promise((resolve) => {
|
|
15
|
+
rl.question(prompt, (answer) => resolve(answer.trim()));
|
|
16
|
+
});
|
|
17
|
+
const reviewableSections = getReviewableSections(doc);
|
|
18
|
+
let running = true;
|
|
19
|
+
while (running) {
|
|
20
|
+
console.error(renderToc(doc));
|
|
21
|
+
const input = await ask(chalk.cyan('> Enter section (e.g. 1.1), \'all\' for linear review, or \'done\' to finish: '));
|
|
22
|
+
if (input === 'done' || input === 'q') {
|
|
23
|
+
running = false;
|
|
24
|
+
}
|
|
25
|
+
else if (input === 'all') {
|
|
26
|
+
await linearReview(doc, reviewableSections, ask);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const section = findSection(doc, input);
|
|
30
|
+
if (section) {
|
|
31
|
+
const startIdx = reviewableSections.indexOf(section);
|
|
32
|
+
await linearReview(doc, reviewableSections.slice(startIdx), ask);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.error(chalk.red(`Section "${input}" not found. Try again.`));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
rl.close();
|
|
40
|
+
printSummary(doc);
|
|
41
|
+
return doc;
|
|
42
|
+
}
|
|
43
|
+
async function linearReview(doc, sections, ask) {
|
|
44
|
+
for (let i = 0; i < sections.length; i++) {
|
|
45
|
+
const section = sections[i];
|
|
46
|
+
console.error(renderSection(section));
|
|
47
|
+
const input = await ask(chalk.cyan('> Comment (enter to skip, \'toc\' for menu, \'back\' for previous): '));
|
|
48
|
+
if (input === 'toc') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
else if (input === 'back') {
|
|
52
|
+
i -= (i > 0) ? 2 : 1; // -2 to go back (loop increments), -1 to re-show current
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
else if (input !== '') {
|
|
56
|
+
doc.comments.push({
|
|
57
|
+
sectionId: section.id,
|
|
58
|
+
text: input,
|
|
59
|
+
timestamp: new Date(),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function findSection(doc, input) {
|
|
65
|
+
// Try exact ID match first
|
|
66
|
+
const byId = doc.sections.find((s) => s.id === input);
|
|
67
|
+
if (byId)
|
|
68
|
+
return byId;
|
|
69
|
+
// Try numeric index for generic mode
|
|
70
|
+
const num = parseInt(input, 10);
|
|
71
|
+
if (!isNaN(num)) {
|
|
72
|
+
const reviewable = getReviewableSections(doc);
|
|
73
|
+
if (num >= 1 && num <= reviewable.length) {
|
|
74
|
+
return reviewable[num - 1];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
export function getReviewableSections(doc) {
|
|
80
|
+
return doc.sections.filter((s) => doc.mode === 'plan' ? s.level === 3 : s.level >= 2);
|
|
81
|
+
}
|
|
82
|
+
export function printSummary(doc) {
|
|
83
|
+
const reviewable = getReviewableSections(doc);
|
|
84
|
+
const commentedIds = new Set(doc.comments.map((c) => c.sectionId));
|
|
85
|
+
console.error('');
|
|
86
|
+
console.error(chalk.bold('Review Summary'));
|
|
87
|
+
console.error(` Sections: ${reviewable.length}`);
|
|
88
|
+
console.error(` Commented: ${chalk.green(String(commentedIds.size))}`);
|
|
89
|
+
console.error(` Skipped: ${chalk.dim(String(reviewable.length - commentedIds.size))}`);
|
|
90
|
+
console.error(` Total comments: ${doc.comments.length}`);
|
|
91
|
+
console.error('');
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=navigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.js","sourceRoot":"","sources":["../src/navigator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAiB,EAAE,iBAA0B,KAAK;IAC/E,sDAAsD;IACtD,kDAAkD;IAClD,MAAM,QAAQ,GAAG,cAAc;QAC7B,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACxD,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAElB,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CA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AC,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OutputTarget } from './types.js';
|
|
2
|
+
export declare function writeOutput(content: string, target: OutputTarget, options?: {
|
|
3
|
+
outputFile?: string;
|
|
4
|
+
inputFile?: string;
|
|
5
|
+
}): void;
|
|
6
|
+
export declare function getClipboardCommand(platform: string): string | null;
|
|
7
|
+
export declare function isClaudeAvailable(): boolean;
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { execSync, spawn } from 'node:child_process';
|
|
2
|
+
import { writeFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
export function writeOutput(content, target, options = {}) {
|
|
6
|
+
switch (target) {
|
|
7
|
+
case 'stdout':
|
|
8
|
+
process.stdout.write(content + '\n');
|
|
9
|
+
break;
|
|
10
|
+
case 'clipboard':
|
|
11
|
+
writeToClipboard(content);
|
|
12
|
+
break;
|
|
13
|
+
case 'file':
|
|
14
|
+
writeToFile(content, options.outputFile, options.inputFile);
|
|
15
|
+
break;
|
|
16
|
+
case 'claude':
|
|
17
|
+
sendToClaude(content);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function writeToClipboard(content) {
|
|
22
|
+
const cmd = getClipboardCommand(process.platform);
|
|
23
|
+
if (!cmd) {
|
|
24
|
+
console.error(chalk.yellow('Clipboard not supported on this platform. Falling back to stdout.'));
|
|
25
|
+
process.stdout.write(content + '\n');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
execSync(cmd, { input: content, stdio: ['pipe', 'ignore', 'ignore'] });
|
|
30
|
+
console.error(chalk.green('Review copied to clipboard.'));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
console.error(chalk.yellow('Failed to copy to clipboard. Falling back to stdout.'));
|
|
34
|
+
process.stdout.write(content + '\n');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function writeToFile(content, outputFile, inputFile) {
|
|
38
|
+
const filePath = outputFile
|
|
39
|
+
? resolve(outputFile)
|
|
40
|
+
: inputFile
|
|
41
|
+
? resolve(inputFile.replace(/\.md$/, '.review.md'))
|
|
42
|
+
: resolve('review.md');
|
|
43
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
44
|
+
console.error(chalk.green(`Review written to ${filePath}`));
|
|
45
|
+
}
|
|
46
|
+
function sendToClaude(content) {
|
|
47
|
+
if (!isClaudeAvailable()) {
|
|
48
|
+
console.error(chalk.red('Claude CLI not found in PATH.'));
|
|
49
|
+
console.error(chalk.dim('Install: https://docs.anthropic.com/en/docs/claude-code'));
|
|
50
|
+
console.error(chalk.yellow('Falling back to stdout.'));
|
|
51
|
+
process.stdout.write(content + '\n');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const child = spawn('claude', [], {
|
|
55
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
56
|
+
});
|
|
57
|
+
child.stdin.write(content);
|
|
58
|
+
child.stdin.end();
|
|
59
|
+
child.on('error', (err) => {
|
|
60
|
+
console.error(chalk.yellow(`Failed to pipe to claude: ${err.message}. Falling back to stdout.`));
|
|
61
|
+
process.stdout.write(content + '\n');
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function getClipboardCommand(platform) {
|
|
65
|
+
switch (platform) {
|
|
66
|
+
case 'darwin':
|
|
67
|
+
return 'pbcopy';
|
|
68
|
+
case 'linux':
|
|
69
|
+
return 'xclip -selection clipboard';
|
|
70
|
+
case 'win32':
|
|
71
|
+
return 'clip';
|
|
72
|
+
default:
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function isClaudeAvailable() {
|
|
77
|
+
try {
|
|
78
|
+
execSync('which claude', { stdio: 'ignore' });
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,MAAoB,EACpB,UAAuD,EAAE;IAEzD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;YACrC,MAAM;QACR,KAAK,WAAW;YACd,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC1B,MAAM;QACR,KAAK,MAAM;YACT,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5D,MAAM;QACR,KAAK,QAAQ;YACX,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM;IACV,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAe;IACvC,MAAM,GAAG,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,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ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
const MIN_SECTION_CHARS = 5;
|
|
2
|
+
export function parse(input, strategy = 'auto') {
|
|
3
|
+
const lines = input.split('\n');
|
|
4
|
+
const title = extractTitle(lines);
|
|
5
|
+
const metadata = extractMetadata(lines);
|
|
6
|
+
if (strategy === 'auto') {
|
|
7
|
+
if (isPlanDocument(input)) {
|
|
8
|
+
return parsePlan(input, title, metadata);
|
|
9
|
+
}
|
|
10
|
+
return parseGeneric(input, title, metadata);
|
|
11
|
+
}
|
|
12
|
+
if (strategy === 'separator') {
|
|
13
|
+
return parseBySeparator(input, title, metadata);
|
|
14
|
+
}
|
|
15
|
+
return parseGeneric(input, title, metadata);
|
|
16
|
+
}
|
|
17
|
+
function extractTitle(lines) {
|
|
18
|
+
const h1 = lines.find((l) => /^# /.test(l));
|
|
19
|
+
return h1 ? h1.replace(/^# /, '').trim() : 'Untitled';
|
|
20
|
+
}
|
|
21
|
+
function extractMetadata(lines) {
|
|
22
|
+
const meta = {};
|
|
23
|
+
for (const line of lines.slice(0, 20)) {
|
|
24
|
+
const match = line.match(/^\*\*(\w[\w\s]*?):\*\*\s*(.+)/);
|
|
25
|
+
if (match) {
|
|
26
|
+
meta[match[1].trim()] = match[2].trim();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return meta;
|
|
30
|
+
}
|
|
31
|
+
export function isPlanDocument(input) {
|
|
32
|
+
const stripped = input.replace(/```[\s\S]*?```/g, '');
|
|
33
|
+
const hasH2H3Hierarchy = /^## /m.test(stripped) && /^### /m.test(stripped);
|
|
34
|
+
const hasPlanFields = /\*\*Depends On:\*\*/m.test(stripped) ||
|
|
35
|
+
/\*\*Blocks:\*\*/m.test(stripped) ||
|
|
36
|
+
/\*\*Verification:\*\*/m.test(stripped) ||
|
|
37
|
+
/\*\*Related Files:\*\*/m.test(stripped);
|
|
38
|
+
return hasH2H3Hierarchy && hasPlanFields;
|
|
39
|
+
}
|
|
40
|
+
function parseGeneric(input, title, metadata) {
|
|
41
|
+
const sections = splitByHeadings(input);
|
|
42
|
+
if (sections.length === 0) {
|
|
43
|
+
return parseBySeparator(input, title, metadata);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
title,
|
|
47
|
+
metadata,
|
|
48
|
+
mode: 'generic',
|
|
49
|
+
sections: sections.map((s, i) => ({
|
|
50
|
+
id: `section-${i + 1}`,
|
|
51
|
+
heading: s.heading,
|
|
52
|
+
level: s.level,
|
|
53
|
+
body: s.body,
|
|
54
|
+
})),
|
|
55
|
+
comments: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function splitByHeadings(input) {
|
|
59
|
+
const lines = input.split('\n');
|
|
60
|
+
const sections = [];
|
|
61
|
+
let currentHeading = '';
|
|
62
|
+
let currentLevel = 0;
|
|
63
|
+
let currentBody = [];
|
|
64
|
+
// Find the most common heading level (## or ###)
|
|
65
|
+
const h2Count = (input.match(/^## /gm) || []).length;
|
|
66
|
+
const h3Count = (input.match(/^### /gm) || []).length;
|
|
67
|
+
const splitLevel = h2Count > 0 ? 2 : h3Count > 0 ? 3 : 0;
|
|
68
|
+
if (splitLevel === 0)
|
|
69
|
+
return [];
|
|
70
|
+
const headingRegex = new RegExp(`^${'#'.repeat(splitLevel)} (.+)`);
|
|
71
|
+
let inCodeBlock = false;
|
|
72
|
+
for (const line of lines) {
|
|
73
|
+
if (line.startsWith('```')) {
|
|
74
|
+
inCodeBlock = !inCodeBlock;
|
|
75
|
+
if (currentHeading) {
|
|
76
|
+
currentBody.push(line);
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (inCodeBlock) {
|
|
81
|
+
if (currentHeading) {
|
|
82
|
+
currentBody.push(line);
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const match = line.match(headingRegex);
|
|
87
|
+
if (match) {
|
|
88
|
+
if (currentHeading) {
|
|
89
|
+
sections.push({
|
|
90
|
+
heading: currentHeading,
|
|
91
|
+
level: currentLevel,
|
|
92
|
+
body: currentBody.join('\n').trim(),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
currentHeading = match[1].trim();
|
|
96
|
+
currentLevel = splitLevel;
|
|
97
|
+
currentBody = [];
|
|
98
|
+
}
|
|
99
|
+
else if (currentHeading) {
|
|
100
|
+
currentBody.push(line);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (currentHeading) {
|
|
104
|
+
sections.push({
|
|
105
|
+
heading: currentHeading,
|
|
106
|
+
level: currentLevel,
|
|
107
|
+
body: currentBody.join('\n').trim(),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return sections;
|
|
111
|
+
}
|
|
112
|
+
function parseBySeparator(input, title, metadata) {
|
|
113
|
+
const parts = input.split(/\n---\n/).filter((p) => {
|
|
114
|
+
return p.trim().length >= MIN_SECTION_CHARS;
|
|
115
|
+
});
|
|
116
|
+
if (parts.length <= 1) {
|
|
117
|
+
return {
|
|
118
|
+
title,
|
|
119
|
+
metadata,
|
|
120
|
+
mode: 'generic',
|
|
121
|
+
sections: [
|
|
122
|
+
{
|
|
123
|
+
id: 'section-1',
|
|
124
|
+
heading: title,
|
|
125
|
+
level: 1,
|
|
126
|
+
body: input.trim(),
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
comments: [],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
title,
|
|
134
|
+
metadata,
|
|
135
|
+
mode: 'generic',
|
|
136
|
+
sections: parts.map((p, i) => {
|
|
137
|
+
const lines = p.trim().split('\n');
|
|
138
|
+
const firstLine = lines[0].replace(/^#+\s*/, '').trim();
|
|
139
|
+
return {
|
|
140
|
+
id: `section-${i + 1}`,
|
|
141
|
+
heading: firstLine || `Section ${i + 1}`,
|
|
142
|
+
level: 2,
|
|
143
|
+
body: p.trim(),
|
|
144
|
+
};
|
|
145
|
+
}),
|
|
146
|
+
comments: [],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function parsePlan(input, title, metadata) {
|
|
150
|
+
const lines = input.split('\n');
|
|
151
|
+
const sections = [];
|
|
152
|
+
let milestoneIndex = 0;
|
|
153
|
+
let taskIndex = 0;
|
|
154
|
+
let currentMilestoneId = '';
|
|
155
|
+
let currentHeading = '';
|
|
156
|
+
let currentLevel = 0;
|
|
157
|
+
let currentBody = [];
|
|
158
|
+
let inCodeBlock = false;
|
|
159
|
+
function flushSection() {
|
|
160
|
+
if (!currentHeading)
|
|
161
|
+
return;
|
|
162
|
+
const body = currentBody.join('\n').trim();
|
|
163
|
+
if (currentLevel === 2) {
|
|
164
|
+
milestoneIndex++;
|
|
165
|
+
taskIndex = 0;
|
|
166
|
+
currentMilestoneId = `milestone-${milestoneIndex}`;
|
|
167
|
+
sections.push({
|
|
168
|
+
id: currentMilestoneId,
|
|
169
|
+
heading: currentHeading,
|
|
170
|
+
level: 2,
|
|
171
|
+
body,
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
taskIndex++;
|
|
176
|
+
const id = `${milestoneIndex}.${taskIndex}`;
|
|
177
|
+
sections.push({
|
|
178
|
+
id,
|
|
179
|
+
heading: currentHeading,
|
|
180
|
+
level: 3,
|
|
181
|
+
body,
|
|
182
|
+
parent: currentMilestoneId,
|
|
183
|
+
dependencies: extractDependencies(body),
|
|
184
|
+
relatedFiles: extractRelatedFiles(body),
|
|
185
|
+
verification: extractVerification(body),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
for (const line of lines) {
|
|
189
|
+
if (line.startsWith('```')) {
|
|
190
|
+
inCodeBlock = !inCodeBlock;
|
|
191
|
+
currentBody.push(line);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (inCodeBlock) {
|
|
195
|
+
currentBody.push(line);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const h2Match = line.match(/^## (.+)/);
|
|
199
|
+
const h3Match = line.match(/^### (.+)/);
|
|
200
|
+
if (h2Match) {
|
|
201
|
+
flushSection();
|
|
202
|
+
currentHeading = h2Match[1].trim();
|
|
203
|
+
currentLevel = 2;
|
|
204
|
+
currentBody = [];
|
|
205
|
+
}
|
|
206
|
+
else if (h3Match) {
|
|
207
|
+
flushSection();
|
|
208
|
+
currentHeading = h3Match[1].trim();
|
|
209
|
+
currentLevel = 3;
|
|
210
|
+
currentBody = [];
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
currentBody.push(line);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
flushSection();
|
|
217
|
+
return {
|
|
218
|
+
title,
|
|
219
|
+
metadata,
|
|
220
|
+
mode: 'plan',
|
|
221
|
+
sections,
|
|
222
|
+
comments: [],
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function extractDependencies(body) {
|
|
226
|
+
const dependsMatch = body.match(/\*\*Depends On:\*\*\s*(.+)/);
|
|
227
|
+
const blocksMatch = body.match(/\*\*Blocks:\*\*\s*(.+)/);
|
|
228
|
+
const parseList = (raw) => {
|
|
229
|
+
const trimmed = raw.trim();
|
|
230
|
+
if (trimmed === '(none)' || trimmed === '')
|
|
231
|
+
return [];
|
|
232
|
+
return trimmed.split(/,\s*/).map((s) => s.trim());
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
dependsOn: dependsMatch ? parseList(dependsMatch[1]) : [],
|
|
236
|
+
blocks: blocksMatch ? parseList(blocksMatch[1]) : [],
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function extractRelatedFiles(body) {
|
|
240
|
+
const files = [];
|
|
241
|
+
const lines = body.split('\n');
|
|
242
|
+
let inRelatedFiles = false;
|
|
243
|
+
for (const line of lines) {
|
|
244
|
+
if (/\*\*Related Files:\*\*/.test(line)) {
|
|
245
|
+
inRelatedFiles = true;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (inRelatedFiles) {
|
|
249
|
+
const fileMatch = line.match(/^- `(.+)`(.*)$/);
|
|
250
|
+
if (fileMatch) {
|
|
251
|
+
const suffix = fileMatch[2].trim();
|
|
252
|
+
files.push(suffix ? `${fileMatch[1]} ${suffix}` : fileMatch[1]);
|
|
253
|
+
}
|
|
254
|
+
else if (line.trim() === '' || /^\*\*/.test(line.trim())) {
|
|
255
|
+
inRelatedFiles = false;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return files;
|
|
260
|
+
}
|
|
261
|
+
function extractVerification(body) {
|
|
262
|
+
const match = body.match(/\*\*Verification:\*\*\s*`(.+?)`/);
|
|
263
|
+
return match ? match[1] : undefined;
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,WAA0B,MAAM;IACnE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC7B,OAAO,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,YAAY,CAAC,KAAK,EAA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AI,EAAE,CAAC;gBACnC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;gBAC3D,cAAc,GAAG,KAAK,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC"}
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { marked } from 'marked';
|
|
2
|
+
import { markedTerminal } from 'marked-terminal';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
marked.use(markedTerminal());
|
|
5
|
+
export function renderSection(section) {
|
|
6
|
+
const parts = [];
|
|
7
|
+
if (section.level === 3 && section.dependencies) {
|
|
8
|
+
parts.push(renderMetadataHeader(section));
|
|
9
|
+
parts.push('');
|
|
10
|
+
}
|
|
11
|
+
const heading = `${'#'.repeat(section.level)} ${section.heading}`;
|
|
12
|
+
const body = section.body || '';
|
|
13
|
+
const markdown = `${heading}\n\n${body}`;
|
|
14
|
+
parts.push(marked.parse(markdown));
|
|
15
|
+
return parts.join('\n');
|
|
16
|
+
}
|
|
17
|
+
function renderMetadataHeader(section) {
|
|
18
|
+
const deps = section.dependencies;
|
|
19
|
+
const dependsOn = deps.dependsOn.length > 0 ? deps.dependsOn.join(', ') : '(none)';
|
|
20
|
+
const blocks = deps.blocks.length > 0 ? deps.blocks.join(', ') : '(none)';
|
|
21
|
+
const lines = [
|
|
22
|
+
`Task ${section.id}: ${section.heading}`,
|
|
23
|
+
`← Depends on: ${dependsOn}`,
|
|
24
|
+
`→ Blocks: ${blocks}`,
|
|
25
|
+
];
|
|
26
|
+
if (section.relatedFiles && section.relatedFiles.length > 0) {
|
|
27
|
+
const fileList = section.relatedFiles.length <= 2
|
|
28
|
+
? section.relatedFiles.join(', ')
|
|
29
|
+
: `${section.relatedFiles[0]} (+${section.relatedFiles.length - 1} more)`;
|
|
30
|
+
lines.push(`Files: ${fileList}`);
|
|
31
|
+
}
|
|
32
|
+
if (section.verification) {
|
|
33
|
+
lines.push(`Verify: ${section.verification}`);
|
|
34
|
+
}
|
|
35
|
+
const maxLen = Math.max(...lines.map((l) => l.length));
|
|
36
|
+
const width = Math.min(maxLen + 4, process.stdout.columns || 80);
|
|
37
|
+
const innerWidth = width - 2;
|
|
38
|
+
const top = chalk.dim(`┌${'─'.repeat(innerWidth)}┐`);
|
|
39
|
+
const bottom = chalk.dim(`└${'─'.repeat(innerWidth)}┘`);
|
|
40
|
+
const content = lines.map((l) => chalk.dim('│') + ' ' + chalk.cyan(l.slice(0, innerWidth - 2).padEnd(innerWidth - 2)) + ' ' + chalk.dim('│'));
|
|
41
|
+
return [top, ...content, bottom].join('\n');
|
|
42
|
+
}
|
|
43
|
+
export function renderToc(doc) {
|
|
44
|
+
const parts = [];
|
|
45
|
+
const commentedIds = new Set(doc.comments.map((c) => c.sectionId));
|
|
46
|
+
parts.push('');
|
|
47
|
+
parts.push(chalk.bold.underline(doc.title));
|
|
48
|
+
parts.push('');
|
|
49
|
+
if (doc.mode === 'plan') {
|
|
50
|
+
for (const section of doc.sections) {
|
|
51
|
+
if (section.level === 2) {
|
|
52
|
+
parts.push(chalk.bold.yellow(` ${section.heading}`));
|
|
53
|
+
}
|
|
54
|
+
else if (section.level === 3) {
|
|
55
|
+
const marker = commentedIds.has(section.id) ? chalk.green('✓') : ' ';
|
|
56
|
+
parts.push(` ${marker} ${chalk.dim(section.id)} ${section.heading}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const reviewable = doc.sections.filter((s) => s.level >= 2);
|
|
62
|
+
for (let i = 0; i < reviewable.length; i++) {
|
|
63
|
+
const section = reviewable[i];
|
|
64
|
+
const num = String(i + 1).padStart(2);
|
|
65
|
+
const marker = commentedIds.has(section.id) ? chalk.green('✓') : ' ';
|
|
66
|
+
parts.push(` ${marker} ${chalk.dim(num)} ${section.heading}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const commentedCount = commentedIds.size;
|
|
70
|
+
const reviewable = doc.sections.filter((s) => doc.mode === 'plan' ? s.level === 3 : s.level >= 2);
|
|
71
|
+
const remaining = reviewable.length - commentedCount;
|
|
72
|
+
parts.push('');
|
|
73
|
+
parts.push(` ${chalk.green(`${commentedCount} section${commentedCount !== 1 ? 's' : ''} commented`)}` +
|
|
74
|
+
` ${chalk.dim(`${remaining} remaining`)}`);
|
|
75
|
+
parts.push('');
|
|
76
|
+
return parts.join('\n');
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QAChD,KAAK,CAAC,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EAAE;QACzF,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,YAAY,CAAC,EAAE,CAC7C,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface PlanDocument {
|
|
2
|
+
title: string;
|
|
3
|
+
metadata: Record<string, string>;
|
|
4
|
+
mode: 'plan' | 'generic';
|
|
5
|
+
sections: Section[];
|
|
6
|
+
comments: ReviewComment[];
|
|
7
|
+
}
|
|
8
|
+
export interface Section {
|
|
9
|
+
id: string;
|
|
10
|
+
heading: string;
|
|
11
|
+
level: number;
|
|
12
|
+
body: string;
|
|
13
|
+
parent?: string;
|
|
14
|
+
dependencies?: {
|
|
15
|
+
dependsOn: string[];
|
|
16
|
+
blocks: string[];
|
|
17
|
+
};
|
|
18
|
+
relatedFiles?: string[];
|
|
19
|
+
verification?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ReviewComment {
|
|
22
|
+
sectionId: string;
|
|
23
|
+
text: string;
|
|
24
|
+
timestamp: Date;
|
|
25
|
+
}
|
|
26
|
+
export type OutputTarget = 'stdout' | 'clipboard' | 'file' | 'claude';
|
|
27
|
+
export type SplitStrategy = 'heading' | 'separator' | 'auto';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plan-review",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Interactive CLI for reviewing AI-generated markdown plans",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"plan-review": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"markdown",
|
|
23
|
+
"plan",
|
|
24
|
+
"review",
|
|
25
|
+
"cli"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"chalk": "^5.6.2",
|
|
30
|
+
"commander": "^14.0.3",
|
|
31
|
+
"marked": "^15.0.12",
|
|
32
|
+
"marked-terminal": "^7.3.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^25.6.0",
|
|
36
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
37
|
+
"tsx": "^4.21.0",
|
|
38
|
+
"typescript": "^6.0.2",
|
|
39
|
+
"vitest": "^4.1.4"
|
|
40
|
+
}
|
|
41
|
+
}
|