popeye-cli 1.4.7 → 1.5.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/README.md +222 -63
- package/dist/adapters/gemini.d.ts +1 -0
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +9 -4
- package/dist/adapters/gemini.js.map +1 -1
- package/dist/adapters/grok.d.ts +1 -0
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +9 -4
- package/dist/adapters/grok.js.map +1 -1
- package/dist/adapters/openai.d.ts +1 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +35 -9
- package/dist/adapters/openai.js.map +1 -1
- package/dist/cli/interactive.d.ts.map +1 -1
- package/dist/cli/interactive.js +42 -0
- package/dist/cli/interactive.js.map +1 -1
- package/dist/generators/all.d.ts +4 -1
- package/dist/generators/all.d.ts.map +1 -1
- package/dist/generators/all.js +2 -1
- package/dist/generators/all.js.map +1 -1
- package/dist/generators/doc-parser.d.ts +49 -0
- package/dist/generators/doc-parser.d.ts.map +1 -0
- package/dist/generators/doc-parser.js +336 -0
- package/dist/generators/doc-parser.js.map +1 -0
- package/dist/generators/templates/index.d.ts +4 -0
- package/dist/generators/templates/index.d.ts.map +1 -1
- package/dist/generators/templates/index.js +4 -0
- package/dist/generators/templates/index.js.map +1 -1
- package/dist/generators/templates/website-components.d.ts +33 -0
- package/dist/generators/templates/website-components.d.ts.map +1 -0
- package/dist/generators/templates/website-components.js +278 -0
- package/dist/generators/templates/website-components.js.map +1 -0
- package/dist/generators/templates/website-config.d.ts +41 -0
- package/dist/generators/templates/website-config.d.ts.map +1 -0
- package/dist/generators/templates/website-config.js +283 -0
- package/dist/generators/templates/website-config.js.map +1 -0
- package/dist/generators/templates/website-conversion.d.ts +27 -0
- package/dist/generators/templates/website-conversion.d.ts.map +1 -0
- package/dist/generators/templates/website-conversion.js +326 -0
- package/dist/generators/templates/website-conversion.js.map +1 -0
- package/dist/generators/templates/website-seo.d.ts +76 -0
- package/dist/generators/templates/website-seo.d.ts.map +1 -0
- package/dist/generators/templates/website-seo.js +326 -0
- package/dist/generators/templates/website-seo.js.map +1 -0
- package/dist/generators/templates/website.d.ts +14 -47
- package/dist/generators/templates/website.d.ts.map +1 -1
- package/dist/generators/templates/website.js +412 -499
- package/dist/generators/templates/website.js.map +1 -1
- package/dist/generators/website-context.d.ts +83 -0
- package/dist/generators/website-context.d.ts.map +1 -0
- package/dist/generators/website-context.js +190 -0
- package/dist/generators/website-context.js.map +1 -0
- package/dist/generators/website.d.ts +3 -0
- package/dist/generators/website.d.ts.map +1 -1
- package/dist/generators/website.js +73 -10
- package/dist/generators/website.js.map +1 -1
- package/dist/state/index.d.ts +27 -0
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +30 -0
- package/dist/state/index.js.map +1 -1
- package/dist/types/consensus.d.ts +3 -0
- package/dist/types/consensus.d.ts.map +1 -1
- package/dist/types/consensus.js +1 -0
- package/dist/types/consensus.js.map +1 -1
- package/dist/types/website-strategy.d.ts +263 -0
- package/dist/types/website-strategy.d.ts.map +1 -0
- package/dist/types/website-strategy.js +105 -0
- package/dist/types/website-strategy.js.map +1 -0
- package/dist/types/workflow.d.ts +15 -0
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/types/workflow.js +6 -0
- package/dist/types/workflow.js.map +1 -1
- package/dist/workflow/consensus.d.ts.map +1 -1
- package/dist/workflow/consensus.js +2 -0
- package/dist/workflow/consensus.js.map +1 -1
- package/dist/workflow/execution-mode.d.ts.map +1 -1
- package/dist/workflow/execution-mode.js +18 -0
- package/dist/workflow/execution-mode.js.map +1 -1
- package/dist/workflow/index.d.ts +3 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +25 -0
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/overview.d.ts +89 -0
- package/dist/workflow/overview.d.ts.map +1 -0
- package/dist/workflow/overview.js +354 -0
- package/dist/workflow/overview.js.map +1 -0
- package/dist/workflow/plan-mode.d.ts +2 -1
- package/dist/workflow/plan-mode.d.ts.map +1 -1
- package/dist/workflow/plan-mode.js +83 -5
- package/dist/workflow/plan-mode.js.map +1 -1
- package/dist/workflow/website-strategy.d.ts +70 -0
- package/dist/workflow/website-strategy.d.ts.map +1 -0
- package/dist/workflow/website-strategy.js +238 -0
- package/dist/workflow/website-strategy.js.map +1 -0
- package/dist/workflow/website-updater.d.ts +17 -0
- package/dist/workflow/website-updater.d.ts.map +1 -0
- package/dist/workflow/website-updater.js +105 -0
- package/dist/workflow/website-updater.js.map +1 -0
- package/dist/workflow/workflow-logger.d.ts +1 -1
- package/dist/workflow/workflow-logger.d.ts.map +1 -1
- package/dist/workflow/workflow-logger.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/gemini.ts +10 -4
- package/src/adapters/grok.ts +10 -4
- package/src/adapters/openai.ts +38 -6
- package/src/cli/interactive.ts +47 -0
- package/src/generators/all.ts +6 -1
- package/src/generators/doc-parser.ts +372 -0
- package/src/generators/templates/index.ts +4 -0
- package/src/generators/templates/website-components.ts +305 -0
- package/src/generators/templates/website-config.ts +291 -0
- package/src/generators/templates/website-conversion.ts +341 -0
- package/src/generators/templates/website-seo.ts +370 -0
- package/src/generators/templates/website.ts +451 -505
- package/src/generators/website-context.ts +265 -0
- package/src/generators/website.ts +109 -19
- package/src/state/index.ts +42 -0
- package/src/types/consensus.ts +3 -0
- package/src/types/website-strategy.ts +243 -0
- package/src/types/workflow.ts +15 -0
- package/src/workflow/consensus.ts +2 -0
- package/src/workflow/execution-mode.ts +21 -0
- package/src/workflow/index.ts +25 -0
- package/src/workflow/overview.ts +469 -0
- package/src/workflow/plan-mode.ts +115 -4
- package/src/workflow/website-strategy.ts +305 -0
- package/src/workflow/website-updater.ts +131 -0
- package/src/workflow/workflow-logger.ts +1 -0
- package/tests/adapters/persona-switching.test.ts +63 -0
- package/tests/generators/website-components.test.ts +159 -0
- package/tests/generators/website-context.test.ts +222 -0
- package/tests/generators/website-seo-quality.test.ts +246 -0
- package/tests/workflow/overview.test.ts +392 -0
- package/tests/workflow/website-strategy.test.ts +191 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project overview generator
|
|
3
|
+
* Provides a comprehensive view of project state, plan, and progress
|
|
4
|
+
* with analysis of issues and ability to fix them
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { loadProject, getProgress, storeUserDocs, storeBrandContext } from '../state/index.js';
|
|
9
|
+
import type { ProjectState } from '../types/workflow.js';
|
|
10
|
+
import {
|
|
11
|
+
discoverProjectDocs,
|
|
12
|
+
readProjectDocs,
|
|
13
|
+
findBrandAssets,
|
|
14
|
+
} from '../generators/website-context.js';
|
|
15
|
+
import { updateWebsiteContent } from './website-updater.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Detected issue in project analysis
|
|
19
|
+
*/
|
|
20
|
+
export interface OverviewIssue {
|
|
21
|
+
severity: 'warning' | 'error';
|
|
22
|
+
category: string;
|
|
23
|
+
message: string;
|
|
24
|
+
fix?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Structured project overview
|
|
29
|
+
*/
|
|
30
|
+
export interface ProjectOverview {
|
|
31
|
+
name: string;
|
|
32
|
+
idea: string;
|
|
33
|
+
language: string;
|
|
34
|
+
phase: string;
|
|
35
|
+
status: string;
|
|
36
|
+
specification: {
|
|
37
|
+
summary: string;
|
|
38
|
+
keyFeatures: string[];
|
|
39
|
+
};
|
|
40
|
+
plan: {
|
|
41
|
+
totalMilestones: number;
|
|
42
|
+
totalTasks: number;
|
|
43
|
+
milestones: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
status: string;
|
|
46
|
+
taskCount: number;
|
|
47
|
+
completedTasks: number;
|
|
48
|
+
tasks: Array<{ name: string; status: string }>;
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
progress: {
|
|
52
|
+
completedMilestones: number;
|
|
53
|
+
completedTasks: number;
|
|
54
|
+
percentComplete: number;
|
|
55
|
+
};
|
|
56
|
+
userDocs?: string[];
|
|
57
|
+
brandContext?: { logoPath?: string; primaryColor?: string };
|
|
58
|
+
/** Detected issues and recommendations */
|
|
59
|
+
issues: OverviewIssue[];
|
|
60
|
+
/** Available docs in CWD that are not yet discovered */
|
|
61
|
+
availableDocs: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Result of an overview fix operation
|
|
66
|
+
*/
|
|
67
|
+
export interface OverviewFixResult {
|
|
68
|
+
docsDiscovered: number;
|
|
69
|
+
docsStored: boolean;
|
|
70
|
+
brandFound: boolean;
|
|
71
|
+
websiteUpdated: boolean;
|
|
72
|
+
messages: string[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generate a complete project overview from state
|
|
77
|
+
*
|
|
78
|
+
* @param projectDir - The project directory
|
|
79
|
+
* @returns Structured project overview with analysis
|
|
80
|
+
*/
|
|
81
|
+
export async function generateOverview(
|
|
82
|
+
projectDir: string
|
|
83
|
+
): Promise<ProjectOverview> {
|
|
84
|
+
const state = await loadProject(projectDir);
|
|
85
|
+
const progress = await getProgress(projectDir);
|
|
86
|
+
|
|
87
|
+
// Extract specification summary
|
|
88
|
+
const specSummary = extractSpecSummary(state);
|
|
89
|
+
const keyFeatures = extractKeyFeatures(state);
|
|
90
|
+
|
|
91
|
+
// Build milestone details
|
|
92
|
+
const milestones = state.milestones.map((m) => ({
|
|
93
|
+
name: m.name,
|
|
94
|
+
status: m.status,
|
|
95
|
+
taskCount: m.tasks.length,
|
|
96
|
+
completedTasks: m.tasks.filter((t) => t.status === 'complete').length,
|
|
97
|
+
tasks: m.tasks.map((t) => ({
|
|
98
|
+
name: t.name,
|
|
99
|
+
status: t.status,
|
|
100
|
+
})),
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
// Extract user doc file names if available
|
|
104
|
+
const userDocs = state.userDocs
|
|
105
|
+
? extractDocNames(state.userDocs)
|
|
106
|
+
: undefined;
|
|
107
|
+
|
|
108
|
+
// Check for available docs in CWD that haven't been discovered
|
|
109
|
+
const parentDir = path.dirname(projectDir);
|
|
110
|
+
const availableDocPaths = await discoverProjectDocs(parentDir);
|
|
111
|
+
const availableDocs = availableDocPaths.map((p) => path.basename(p));
|
|
112
|
+
|
|
113
|
+
// Run analysis to detect issues
|
|
114
|
+
const issues = analyzeProject(state, availableDocs, progress);
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
name: state.name,
|
|
118
|
+
idea: state.idea,
|
|
119
|
+
language: state.language,
|
|
120
|
+
phase: state.phase,
|
|
121
|
+
status: state.status,
|
|
122
|
+
specification: {
|
|
123
|
+
summary: specSummary,
|
|
124
|
+
keyFeatures,
|
|
125
|
+
},
|
|
126
|
+
plan: {
|
|
127
|
+
totalMilestones: state.milestones.length,
|
|
128
|
+
totalTasks: state.milestones.reduce((sum, m) => sum + m.tasks.length, 0),
|
|
129
|
+
milestones,
|
|
130
|
+
},
|
|
131
|
+
progress: {
|
|
132
|
+
completedMilestones: progress.completedMilestones,
|
|
133
|
+
completedTasks: progress.completedTasks,
|
|
134
|
+
percentComplete: progress.percentComplete,
|
|
135
|
+
},
|
|
136
|
+
userDocs,
|
|
137
|
+
brandContext: state.brandContext,
|
|
138
|
+
issues,
|
|
139
|
+
availableDocs,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Fix detected issues by re-discovering docs and updating website content
|
|
145
|
+
*
|
|
146
|
+
* @param projectDir - The project directory
|
|
147
|
+
* @param onProgress - Optional progress callback
|
|
148
|
+
* @returns Fix result with summary of actions taken
|
|
149
|
+
*/
|
|
150
|
+
export async function fixOverviewIssues(
|
|
151
|
+
projectDir: string,
|
|
152
|
+
onProgress?: (message: string) => void
|
|
153
|
+
): Promise<OverviewFixResult> {
|
|
154
|
+
const result: OverviewFixResult = {
|
|
155
|
+
docsDiscovered: 0,
|
|
156
|
+
docsStored: false,
|
|
157
|
+
brandFound: false,
|
|
158
|
+
websiteUpdated: false,
|
|
159
|
+
messages: [],
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
let state = await loadProject(projectDir);
|
|
163
|
+
const parentDir = path.dirname(projectDir);
|
|
164
|
+
|
|
165
|
+
// Step 1: Re-discover project documentation
|
|
166
|
+
onProgress?.('Scanning for project documentation...');
|
|
167
|
+
const docPaths = await discoverProjectDocs(parentDir);
|
|
168
|
+
|
|
169
|
+
if (docPaths.length > 0) {
|
|
170
|
+
const userDocs = await readProjectDocs(docPaths);
|
|
171
|
+
state = await storeUserDocs(projectDir, userDocs);
|
|
172
|
+
result.docsDiscovered = docPaths.length;
|
|
173
|
+
result.docsStored = true;
|
|
174
|
+
const docNames = docPaths.map((p) => path.basename(p)).join(', ');
|
|
175
|
+
result.messages.push(`Discovered ${docPaths.length} doc(s): ${docNames}`);
|
|
176
|
+
onProgress?.(`Found ${docPaths.length} doc(s): ${docNames}`);
|
|
177
|
+
} else {
|
|
178
|
+
result.messages.push('No project documentation found in parent directory');
|
|
179
|
+
onProgress?.('No project documentation found in parent directory');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Step 2: Find brand assets
|
|
183
|
+
onProgress?.('Scanning for brand assets...');
|
|
184
|
+
const brandAssets = await findBrandAssets(parentDir);
|
|
185
|
+
|
|
186
|
+
if (brandAssets.logoPath) {
|
|
187
|
+
state = await storeBrandContext(projectDir, {
|
|
188
|
+
...state.brandContext,
|
|
189
|
+
logoPath: brandAssets.logoPath,
|
|
190
|
+
});
|
|
191
|
+
result.brandFound = true;
|
|
192
|
+
result.messages.push(`Found logo: ${path.basename(brandAssets.logoPath)}`);
|
|
193
|
+
onProgress?.(`Found logo: ${path.basename(brandAssets.logoPath)}`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Extract primary/accent color from docs if not already set
|
|
197
|
+
// Use smart extraction: look for accent/primary CTA color tokens first,
|
|
198
|
+
// then fall back to brightness-filtered colors (skip very dark/light)
|
|
199
|
+
if (!state.brandContext?.primaryColor && state.userDocs) {
|
|
200
|
+
const accentMatch = state.userDocs.match(/accent[_-]?primary[^#]{0,40}(#[0-9a-fA-F]{6})/i)
|
|
201
|
+
|| state.userDocs.match(/(?:primary\s+(?:brand\s+)?(?:accent|color|CTA))[^#]{0,40}(#[0-9a-fA-F]{6})/i);
|
|
202
|
+
const color = accentMatch ? accentMatch[1] : findBrightColor(state.userDocs);
|
|
203
|
+
if (color) {
|
|
204
|
+
state = await storeBrandContext(projectDir, {
|
|
205
|
+
...state.brandContext,
|
|
206
|
+
primaryColor: color,
|
|
207
|
+
});
|
|
208
|
+
result.messages.push(`Extracted brand color: ${color}`);
|
|
209
|
+
onProgress?.(`Extracted brand color: ${color}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Step 3: Update website content if applicable
|
|
214
|
+
const language = state.language;
|
|
215
|
+
if (language === 'website' || language === 'all' || language === 'fullstack') {
|
|
216
|
+
onProgress?.('Updating website content with discovered context...');
|
|
217
|
+
try {
|
|
218
|
+
await updateWebsiteContent(projectDir, state, language, onProgress);
|
|
219
|
+
result.websiteUpdated = true;
|
|
220
|
+
result.messages.push('Website content files updated with project context');
|
|
221
|
+
} catch (err) {
|
|
222
|
+
result.messages.push(`Website update failed: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Summary
|
|
227
|
+
if (result.docsDiscovered === 0 && !result.brandFound) {
|
|
228
|
+
result.messages.push(
|
|
229
|
+
'Tip: Place project docs (spec, pricing, color-scheme, etc.) as .md files in the parent directory, then run /overview fix again'
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Analyze project state and detect issues */
|
|
237
|
+
function analyzeProject(
|
|
238
|
+
state: ProjectState,
|
|
239
|
+
availableDocs: string[],
|
|
240
|
+
progress: { totalTasks: number; completedTasks: number; percentComplete: number }
|
|
241
|
+
): OverviewIssue[] {
|
|
242
|
+
const issues: OverviewIssue[] = [];
|
|
243
|
+
const push = (severity: 'warning' | 'error', category: string, message: string, fix?: string) =>
|
|
244
|
+
issues.push({ severity, category, message, fix });
|
|
245
|
+
|
|
246
|
+
if (!state.userDocs && availableDocs.length > 0) {
|
|
247
|
+
push('warning', 'docs',
|
|
248
|
+
`Found ${availableDocs.length} doc(s) in CWD (${availableDocs.join(', ')}) but project has no user docs stored`,
|
|
249
|
+
'Run /overview fix to discover and apply project documentation');
|
|
250
|
+
}
|
|
251
|
+
if (!state.userDocs && availableDocs.length === 0) {
|
|
252
|
+
push('warning', 'docs',
|
|
253
|
+
'No project documentation found. Website will use generic placeholder content.',
|
|
254
|
+
'Add .md files (spec, pricing, brand, etc.) to the project parent directory, then run /overview fix');
|
|
255
|
+
}
|
|
256
|
+
if (progress.totalTasks > 0 && progress.totalTasks <= 3) {
|
|
257
|
+
push('warning', 'plan',
|
|
258
|
+
`Project has only ${progress.totalTasks} task(s) - this may indicate an incomplete or oversimplified plan`,
|
|
259
|
+
'Consider resetting to plan phase with richer specification');
|
|
260
|
+
}
|
|
261
|
+
if (!state.brandContext?.primaryColor && !state.brandContext?.logoPath) {
|
|
262
|
+
push('warning', 'brand',
|
|
263
|
+
'No brand context (colors, logo) detected. Website uses default styling.',
|
|
264
|
+
'Add a color-scheme.md or logo file to the project parent directory, then run /overview fix');
|
|
265
|
+
}
|
|
266
|
+
if (state.specification) {
|
|
267
|
+
const specStart = state.specification.trim().slice(0, 200).toLowerCase();
|
|
268
|
+
const genericPats = ["here's a comprehensive", "here is a comprehensive",
|
|
269
|
+
"here's a detailed", "here is a detailed", 'based on your idea', 'based on the idea'];
|
|
270
|
+
if (genericPats.some((p) => specStart.includes(p))) {
|
|
271
|
+
push('warning', 'spec',
|
|
272
|
+
'Specification appears to be generic AI-generated content without project-specific documentation input',
|
|
273
|
+
'Add project docs to CWD and run /overview fix to re-enrich. For a full re-spec, reset to plan phase.');
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const hasWebsite = state.language === 'website' || state.language === 'all' || state.language === 'fullstack';
|
|
277
|
+
if (hasWebsite && !state.userDocs && state.phase === 'complete') {
|
|
278
|
+
push('error', 'website',
|
|
279
|
+
'Project includes a website but was completed without any user documentation. Website likely has placeholder content.',
|
|
280
|
+
'Run /overview fix to discover docs and update website template files');
|
|
281
|
+
}
|
|
282
|
+
return issues;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Format a project overview for terminal display
|
|
287
|
+
*
|
|
288
|
+
* @param overview - The project overview to format
|
|
289
|
+
* @returns Formatted string for terminal output
|
|
290
|
+
*/
|
|
291
|
+
export function formatOverview(overview: ProjectOverview): string {
|
|
292
|
+
const l: string[] = [''];
|
|
293
|
+
l.push(` PROJECT OVERVIEW: ${overview.name}`);
|
|
294
|
+
l.push(` ${'='.repeat(40 + overview.name.length)}`, '');
|
|
295
|
+
l.push(` Language: ${overview.language}`);
|
|
296
|
+
l.push(` Phase: ${overview.phase}`);
|
|
297
|
+
l.push(` Status: ${overview.status}`, '');
|
|
298
|
+
|
|
299
|
+
if (overview.specification.summary) {
|
|
300
|
+
l.push(' SPECIFICATION', ` ${overview.specification.summary}`);
|
|
301
|
+
if (overview.specification.keyFeatures.length > 0) {
|
|
302
|
+
l.push('', ' Key Features:');
|
|
303
|
+
for (const f of overview.specification.keyFeatures.slice(0, 8)) l.push(` - ${f}`);
|
|
304
|
+
}
|
|
305
|
+
l.push('');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const barWidth = 30;
|
|
309
|
+
const filled = Math.round((overview.progress.percentComplete / 100) * barWidth);
|
|
310
|
+
const bar = `[${'='.repeat(filled)}${filled < barWidth ? '>' : ''}${' '.repeat(Math.max(0, barWidth - filled - 1))}]`;
|
|
311
|
+
l.push(` Progress: ${bar} ${overview.progress.percentComplete}% (${overview.progress.completedTasks}/${overview.plan.totalTasks} tasks)`, '');
|
|
312
|
+
|
|
313
|
+
if (overview.plan.milestones.length > 0) {
|
|
314
|
+
l.push(' MILESTONES', ` ${'-'.repeat(50)}`);
|
|
315
|
+
for (const m of overview.plan.milestones) {
|
|
316
|
+
l.push(` ${getStatusIcon(m.status)} ${m.name} (${m.completedTasks}/${m.taskCount} tasks)`);
|
|
317
|
+
for (const t of m.tasks) l.push(` ${getStatusIcon(t.status)} ${t.name}`);
|
|
318
|
+
l.push('');
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
l.push(' No milestones defined yet.', '');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (overview.userDocs && overview.userDocs.length > 0) {
|
|
325
|
+
l.push(' DISCOVERED DOCS');
|
|
326
|
+
for (const doc of overview.userDocs) l.push(` - ${doc}`);
|
|
327
|
+
l.push('');
|
|
328
|
+
}
|
|
329
|
+
if (overview.brandContext) {
|
|
330
|
+
l.push(' BRAND CONTEXT');
|
|
331
|
+
if (overview.brandContext.primaryColor) l.push(` Primary Color: ${overview.brandContext.primaryColor}`);
|
|
332
|
+
if (overview.brandContext.logoPath) l.push(` Logo: ${path.basename(overview.brandContext.logoPath)}`);
|
|
333
|
+
l.push('');
|
|
334
|
+
}
|
|
335
|
+
if (overview.issues.length > 0) {
|
|
336
|
+
l.push(' ANALYSIS', ` ${'-'.repeat(50)}`);
|
|
337
|
+
for (const issue of overview.issues) {
|
|
338
|
+
const icon = issue.severity === 'error' ? '[!!]' : '[!]';
|
|
339
|
+
l.push(` ${icon} ${issue.category.toUpperCase()}: ${issue.message}`);
|
|
340
|
+
if (issue.fix) l.push(` -> ${issue.fix}`);
|
|
341
|
+
}
|
|
342
|
+
l.push('');
|
|
343
|
+
}
|
|
344
|
+
if (overview.availableDocs.length > 0 && !overview.userDocs) {
|
|
345
|
+
l.push(' AVAILABLE DOCS (not yet imported)');
|
|
346
|
+
for (const doc of overview.availableDocs) l.push(` - ${doc}`);
|
|
347
|
+
l.push('');
|
|
348
|
+
}
|
|
349
|
+
if (overview.issues.length > 0) {
|
|
350
|
+
l.push(' Run /overview fix to auto-discover docs, detect brand assets, and update website content.', '');
|
|
351
|
+
}
|
|
352
|
+
return l.join('\n');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Extract a summary from the specification
|
|
357
|
+
*/
|
|
358
|
+
function extractSpecSummary(state: ProjectState): string {
|
|
359
|
+
if (!state.specification) return '';
|
|
360
|
+
|
|
361
|
+
const lines = state.specification.split('\n');
|
|
362
|
+
// Find first non-empty, non-heading line that isn't a generic AI preamble
|
|
363
|
+
const genericPrefixes = [
|
|
364
|
+
"here's a comprehensive",
|
|
365
|
+
"here is a comprehensive",
|
|
366
|
+
"here's a detailed",
|
|
367
|
+
'based on your idea',
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
for (const line of lines) {
|
|
371
|
+
const trimmed = line.trim();
|
|
372
|
+
if (trimmed && !trimmed.startsWith('#') && trimmed.length > 20) {
|
|
373
|
+
const lower = trimmed.toLowerCase();
|
|
374
|
+
if (!genericPrefixes.some((p) => lower.startsWith(p))) {
|
|
375
|
+
return trimmed.slice(0, 500);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return state.specification.slice(0, 500);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Extract key features from specification
|
|
385
|
+
*/
|
|
386
|
+
function extractKeyFeatures(state: ProjectState): string[] {
|
|
387
|
+
if (!state.specification) return [];
|
|
388
|
+
|
|
389
|
+
const features: string[] = [];
|
|
390
|
+
const lines = state.specification.split('\n');
|
|
391
|
+
let inFeatures = false;
|
|
392
|
+
|
|
393
|
+
for (const line of lines) {
|
|
394
|
+
const trimmed = line.trim();
|
|
395
|
+
|
|
396
|
+
// Detect feature section headers
|
|
397
|
+
if (/^#{1,3}\s*(core\s+)?features/i.test(trimmed)) {
|
|
398
|
+
inFeatures = true;
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Stop at next heading
|
|
403
|
+
if (inFeatures && /^#{1,3}\s/.test(trimmed) && !/feature/i.test(trimmed)) {
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Collect bullet points in feature section
|
|
408
|
+
if (inFeatures && /^[-*+]\s+/.test(trimmed)) {
|
|
409
|
+
const feature = trimmed.replace(/^[-*+]\s+/, '').replace(/^\*\*(.+?)\*\*:?\s*/, '$1: ');
|
|
410
|
+
if (feature.length > 5) {
|
|
411
|
+
features.push(feature.slice(0, 100));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return features.slice(0, 10);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Extract doc file names from raw docs string
|
|
421
|
+
*/
|
|
422
|
+
function extractDocNames(rawDocs: string): string[] {
|
|
423
|
+
const names: string[] = [];
|
|
424
|
+
const headerPattern = /^--- (.+) ---$/gm;
|
|
425
|
+
let match;
|
|
426
|
+
|
|
427
|
+
while ((match = headerPattern.exec(rawDocs)) !== null) {
|
|
428
|
+
names.push(match[1]);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return names;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Get a status icon for terminal display
|
|
436
|
+
*/
|
|
437
|
+
function getStatusIcon(status: string): string {
|
|
438
|
+
switch (status) {
|
|
439
|
+
case 'complete':
|
|
440
|
+
return '[x]';
|
|
441
|
+
case 'in-progress':
|
|
442
|
+
return '[~]';
|
|
443
|
+
case 'failed':
|
|
444
|
+
return '[!]';
|
|
445
|
+
case 'paused':
|
|
446
|
+
return '[-]';
|
|
447
|
+
default:
|
|
448
|
+
return '[ ]';
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Find first hex color that isn't very dark or very light
|
|
454
|
+
* Skips background/neutral colors to find a reasonable brand accent
|
|
455
|
+
*/
|
|
456
|
+
function findBrightColor(text: string): string | undefined {
|
|
457
|
+
const allColors = [...text.matchAll(/#([0-9a-fA-F]{6})/g)];
|
|
458
|
+
for (const match of allColors) {
|
|
459
|
+
const hex = match[1];
|
|
460
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
461
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
462
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
463
|
+
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
464
|
+
if (brightness > 60 && brightness < 210) {
|
|
465
|
+
return '#' + hex;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return undefined;
|
|
469
|
+
}
|
|
@@ -17,11 +17,27 @@ import {
|
|
|
17
17
|
setPhase,
|
|
18
18
|
storePlan,
|
|
19
19
|
storeSpecification,
|
|
20
|
+
storeUserDocs,
|
|
21
|
+
storeBrandContext,
|
|
22
|
+
storeWebsiteStrategyPath,
|
|
20
23
|
addMilestones,
|
|
21
24
|
} from '../state/index.js';
|
|
25
|
+
import {
|
|
26
|
+
discoverProjectDocs,
|
|
27
|
+
readProjectDocs,
|
|
28
|
+
findBrandAssets,
|
|
29
|
+
resolveBrandAssets,
|
|
30
|
+
} from '../generators/website-context.js';
|
|
22
31
|
import { iterateUntilConsensus, type ConsensusProcessResult } from './consensus.js';
|
|
23
32
|
import { getWorkflowLogger } from './workflow-logger.js';
|
|
24
33
|
import { designUI, saveUISpecification } from './ui-designer.js';
|
|
34
|
+
import {
|
|
35
|
+
generateWebsiteStrategy,
|
|
36
|
+
formatStrategyForPlanContext,
|
|
37
|
+
storeWebsiteStrategy,
|
|
38
|
+
loadWebsiteStrategy,
|
|
39
|
+
} from './website-strategy.js';
|
|
40
|
+
import type { WebsiteStrategyDocument } from '../types/website-strategy.js';
|
|
25
41
|
|
|
26
42
|
/**
|
|
27
43
|
* Options for plan mode
|
|
@@ -49,16 +65,18 @@ export interface PlanModeResult {
|
|
|
49
65
|
* @param idea - The brief project idea
|
|
50
66
|
* @param language - Target programming language
|
|
51
67
|
* @param onProgress - Progress callback
|
|
68
|
+
* @param userDocs - Optional user documentation for context
|
|
52
69
|
* @returns Expanded specification
|
|
53
70
|
*/
|
|
54
71
|
export async function expandIdea(
|
|
55
72
|
idea: string,
|
|
56
73
|
language: OutputLanguage,
|
|
57
|
-
onProgress?: (message: string) => void
|
|
74
|
+
onProgress?: (message: string) => void,
|
|
75
|
+
userDocs?: string
|
|
58
76
|
): Promise<string> {
|
|
59
77
|
onProgress?.('Expanding idea into specification...');
|
|
60
78
|
|
|
61
|
-
const specification = await openaiExpandIdea(idea, language);
|
|
79
|
+
const specification = await openaiExpandIdea(idea, language, userDocs);
|
|
62
80
|
|
|
63
81
|
onProgress?.('Specification created');
|
|
64
82
|
return specification;
|
|
@@ -890,6 +908,27 @@ export async function runPlanMode(
|
|
|
890
908
|
});
|
|
891
909
|
}
|
|
892
910
|
|
|
911
|
+
// Discover user documentation from the CWD (parent of project dir)
|
|
912
|
+
let userDocs = state.userDocs || '';
|
|
913
|
+
if (!userDocs) {
|
|
914
|
+
const parentDir = path.dirname(projectDir);
|
|
915
|
+
const docPaths = await discoverProjectDocs(parentDir);
|
|
916
|
+
if (docPaths.length > 0) {
|
|
917
|
+
userDocs = await readProjectDocs(docPaths);
|
|
918
|
+
onProgress?.('doc-discovery', `Found ${docPaths.length} project doc(s)`);
|
|
919
|
+
state = await storeUserDocs(projectDir, userDocs);
|
|
920
|
+
await logger.info('init', 'docs_found', `Found ${docPaths.length} project docs`, {
|
|
921
|
+
docCount: docPaths.length,
|
|
922
|
+
docPaths: docPaths.map((p) => path.basename(p)),
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
const brandAssets = await findBrandAssets(parentDir);
|
|
926
|
+
if (brandAssets.logoPath) {
|
|
927
|
+
state = await storeBrandContext(projectDir, { logoPath: brandAssets.logoPath });
|
|
928
|
+
onProgress?.('doc-discovery', `Found brand logo: ${path.basename(brandAssets.logoPath)}`);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
893
932
|
// Expand idea if we don't have a specification
|
|
894
933
|
if (!state.specification) {
|
|
895
934
|
onProgress?.('expand-idea', 'Expanding idea into specification...');
|
|
@@ -898,7 +937,8 @@ export async function runPlanMode(
|
|
|
898
937
|
const specification = await expandIdea(
|
|
899
938
|
spec.idea,
|
|
900
939
|
spec.language,
|
|
901
|
-
(msg) => onProgress?.('expand-idea', msg)
|
|
940
|
+
(msg) => onProgress?.('expand-idea', msg),
|
|
941
|
+
userDocs || undefined
|
|
902
942
|
);
|
|
903
943
|
|
|
904
944
|
state = await storeSpecification(projectDir, specification);
|
|
@@ -928,6 +968,61 @@ export async function runPlanMode(
|
|
|
928
968
|
});
|
|
929
969
|
}
|
|
930
970
|
|
|
971
|
+
// Generate website strategy for website projects (after spec, before plan)
|
|
972
|
+
const isWebsiteProject = spec.language === 'website' || spec.language === 'all';
|
|
973
|
+
let websiteStrategy: WebsiteStrategyDocument | undefined;
|
|
974
|
+
|
|
975
|
+
if (isWebsiteProject && state.specification) {
|
|
976
|
+
try {
|
|
977
|
+
onProgress?.('get-context', 'Generating website marketing strategy...');
|
|
978
|
+
await logger.stageStart('website-strategy', 'Generating website marketing strategy');
|
|
979
|
+
|
|
980
|
+
const parentDir = path.dirname(projectDir);
|
|
981
|
+
const brandAssets = await resolveBrandAssets(parentDir, state.brandContext);
|
|
982
|
+
|
|
983
|
+
const strategyInput = {
|
|
984
|
+
productContext: (userDocs || '') + '\n\n' + (state.specification || ''),
|
|
985
|
+
projectName: spec.name || state.name,
|
|
986
|
+
brandAssets,
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
// Check for cached strategy
|
|
990
|
+
const cached = await loadWebsiteStrategy(projectDir);
|
|
991
|
+
if (cached) {
|
|
992
|
+
websiteStrategy = cached.strategy;
|
|
993
|
+
onProgress?.('get-context', `Loaded cached strategy: ${cached.strategy.siteArchitecture.pages.length} pages`);
|
|
994
|
+
} else {
|
|
995
|
+
const result = await generateWebsiteStrategy(
|
|
996
|
+
strategyInput,
|
|
997
|
+
(msg) => onProgress?.('get-context', msg)
|
|
998
|
+
);
|
|
999
|
+
websiteStrategy = result.strategy;
|
|
1000
|
+
await storeWebsiteStrategy(projectDir, result.strategy, result.metadata);
|
|
1001
|
+
state = await storeWebsiteStrategyPath(projectDir, '.popeye/website-strategy.json');
|
|
1002
|
+
|
|
1003
|
+
onProgress?.(
|
|
1004
|
+
'get-context',
|
|
1005
|
+
`Strategy: ${result.strategy.siteArchitecture.pages.length} pages, ` +
|
|
1006
|
+
`${result.strategy.seoStrategy.primaryKeywords.length} keywords`
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
await logger.stageComplete('website-strategy', 'Website strategy generated', {
|
|
1011
|
+
pageCount: websiteStrategy.siteArchitecture.pages.length,
|
|
1012
|
+
keywordCount: websiteStrategy.seoStrategy.primaryKeywords.length,
|
|
1013
|
+
});
|
|
1014
|
+
} catch (strategyError) {
|
|
1015
|
+
// Non-blocking: strategy generation failure should not stop the workflow
|
|
1016
|
+
onProgress?.(
|
|
1017
|
+
'get-context',
|
|
1018
|
+
`Website strategy skipped: ${strategyError instanceof Error ? strategyError.message : 'Unknown error'}`
|
|
1019
|
+
);
|
|
1020
|
+
await logger.warn('website-strategy', 'strategy_skipped', 'Website strategy was skipped', {
|
|
1021
|
+
error: strategyError instanceof Error ? strategyError.message : 'Unknown error',
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
931
1026
|
// Get project context
|
|
932
1027
|
onProgress?.('get-context', 'Gathering project context...');
|
|
933
1028
|
let context = await getProjectContext(
|
|
@@ -941,6 +1036,12 @@ export async function runPlanMode(
|
|
|
941
1036
|
context = `${context}\n\nADDITIONAL GUIDANCE FROM USER:\n${additionalContext}`;
|
|
942
1037
|
}
|
|
943
1038
|
|
|
1039
|
+
// Inject website strategy as a separate context block (not appended to specification)
|
|
1040
|
+
if (websiteStrategy) {
|
|
1041
|
+
const strategyContext = formatStrategyForPlanContext(websiteStrategy);
|
|
1042
|
+
context = `${context}\n\n## WEBSITE STRATEGY (authoritative reference)\n${strategyContext}`;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
944
1045
|
// Create initial plan if we don't have one
|
|
945
1046
|
if (!state.plan) {
|
|
946
1047
|
onProgress?.('create-plan', 'Creating development plan...');
|
|
@@ -986,12 +1087,22 @@ export async function runPlanMode(
|
|
|
986
1087
|
onProgress?.('consensus', 'Starting consensus review...');
|
|
987
1088
|
await logger.stageStart('consensus', 'Starting consensus review process');
|
|
988
1089
|
|
|
1090
|
+
// Set marketing persona for website project reviews
|
|
1091
|
+
const resolvedConsensusConfig = { ...consensusConfig };
|
|
1092
|
+
if (isWebsiteProject && !resolvedConsensusConfig.reviewerPersona) {
|
|
1093
|
+
resolvedConsensusConfig.reviewerPersona =
|
|
1094
|
+
'a Senior Product Marketing Strategist, SEO expert, and Fullstack Web Architect. ' +
|
|
1095
|
+
'Evaluate for: conversion optimization, messaging clarity, SEO best practices ' +
|
|
1096
|
+
'(JSON-LD, heading hierarchy, meta tags), Lighthouse 95+ performance, WCAG 2.1 AA accessibility. ' +
|
|
1097
|
+
'Reject generic template structures. Every section must connect to real product capabilities.';
|
|
1098
|
+
}
|
|
1099
|
+
|
|
989
1100
|
const consensusResult = await iterateUntilConsensus(
|
|
990
1101
|
state.plan!,
|
|
991
1102
|
context,
|
|
992
1103
|
{
|
|
993
1104
|
projectDir,
|
|
994
|
-
config:
|
|
1105
|
+
config: resolvedConsensusConfig,
|
|
995
1106
|
isFullstack: isWorkspace(spec.language),
|
|
996
1107
|
language: spec.language,
|
|
997
1108
|
onIteration: (iteration, result) => {
|