brain-dev 1.1.0 → 1.1.1
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.
|
@@ -165,7 +165,7 @@ function handleInit(args, brainDir, state) {
|
|
|
165
165
|
output_dir: taskDir,
|
|
166
166
|
phase_number_padded: String(nextNum).padStart(3, '0'),
|
|
167
167
|
phase_slug: slug,
|
|
168
|
-
stack_expertise: generateExpertise(brainDir, '
|
|
168
|
+
stack_expertise: generateExpertise(brainDir, 'planner')
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
const quickConstraints = [
|
|
@@ -10,6 +10,7 @@ const { output, error, success } = require('../core.cjs');
|
|
|
10
10
|
const antiPatterns = require('../anti-patterns.cjs');
|
|
11
11
|
const { buildDebuggerSpawnInstructions } = require('./execute.cjs');
|
|
12
12
|
const { isPathWithinRoot } = require('../security.cjs');
|
|
13
|
+
const { generateExpertise } = require('../stack-expert.cjs');
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Find a phase directory under .brain/phases/ matching a phase number.
|
|
@@ -271,7 +272,8 @@ async function run(args = [], opts = {}) {
|
|
|
271
272
|
must_haves: mustHavesFormatted,
|
|
272
273
|
output_path: outputPath,
|
|
273
274
|
anti_pattern_results: formatAntiPatternResults(apResults),
|
|
274
|
-
nyquist_section: nyquistSection
|
|
275
|
+
nyquist_section: nyquistSection,
|
|
276
|
+
stack_expertise: generateExpertise(brainDir, 'verifier')
|
|
275
277
|
});
|
|
276
278
|
|
|
277
279
|
// Read depth config from state (defaults to 'deep' for backward compatibility)
|
package/bin/lib/stack-expert.cjs
CHANGED
|
@@ -201,22 +201,27 @@ function generateExpertise(brainDir, role = 'general') {
|
|
|
201
201
|
const conventions = fs.readFileSync(conventionsPath, 'utf8');
|
|
202
202
|
const excerpt = conventions.slice(0, 2000); // Keep concise
|
|
203
203
|
sections.push('### Project-Specific Conventions (from codebase analysis)');
|
|
204
|
+
sections.push('```conventions');
|
|
204
205
|
sections.push(excerpt);
|
|
206
|
+
sections.push('```');
|
|
205
207
|
sections.push('');
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
if (role === 'planner' && fs.existsSync(stackPath)) {
|
|
210
|
+
if ((role === 'planner' || role === 'executor') && fs.existsSync(stackPath)) {
|
|
209
211
|
const stackAnalysis = fs.readFileSync(stackPath, 'utf8');
|
|
210
212
|
const excerpt = stackAnalysis.slice(0, 1500);
|
|
211
213
|
sections.push('### Existing Stack Details');
|
|
214
|
+
sections.push('```stack');
|
|
212
215
|
sections.push(excerpt);
|
|
216
|
+
sections.push('```');
|
|
213
217
|
sections.push('');
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
220
|
|
|
217
221
|
// LAYER 3: Context7 live documentation queries
|
|
218
222
|
if (framework || lang) {
|
|
219
|
-
|
|
223
|
+
const ctx7 = generateContext7Queries(detection);
|
|
224
|
+
if (ctx7) sections.push(ctx7);
|
|
220
225
|
}
|
|
221
226
|
|
|
222
227
|
// Unknown framework: Context7 becomes PRIMARY (not fallback)
|
|
@@ -262,10 +267,15 @@ function generateExpertise(brainDir, role = 'general') {
|
|
|
262
267
|
* @returns {object|null} Framework pattern object or null
|
|
263
268
|
*/
|
|
264
269
|
function findFrameworkPattern(name) {
|
|
265
|
-
|
|
270
|
+
if (!name) return null;
|
|
271
|
+
const lower = name.toLowerCase();
|
|
272
|
+
// Exact match first
|
|
266
273
|
for (const [key, value] of Object.entries(STACK_PATTERNS.frameworks)) {
|
|
267
|
-
if (key.toLowerCase() ===
|
|
268
|
-
|
|
274
|
+
if (key.toLowerCase() === lower) return value;
|
|
275
|
+
}
|
|
276
|
+
// startsWith match (e.g., "Next.js 15" matches "Next.js")
|
|
277
|
+
for (const [key, value] of Object.entries(STACK_PATTERNS.frameworks)) {
|
|
278
|
+
if (lower.startsWith(key.toLowerCase()) || key.toLowerCase().startsWith(lower)) {
|
|
269
279
|
return value;
|
|
270
280
|
}
|
|
271
281
|
}
|
|
@@ -274,11 +284,13 @@ function findFrameworkPattern(name) {
|
|
|
274
284
|
|
|
275
285
|
/**
|
|
276
286
|
* Generate Context7 lookup instructions for the detected stack.
|
|
277
|
-
* @param {string} brainDir
|
|
287
|
+
* @param {object|string} detectionOrBrainDir - Parsed detection object or brainDir path
|
|
278
288
|
* @returns {string} Context7 query instructions
|
|
279
289
|
*/
|
|
280
|
-
function generateContext7Queries(
|
|
281
|
-
const detection =
|
|
290
|
+
function generateContext7Queries(detectionOrBrainDir) {
|
|
291
|
+
const detection = typeof detectionOrBrainDir === 'string'
|
|
292
|
+
? readDetection(detectionOrBrainDir)
|
|
293
|
+
: detectionOrBrainDir;
|
|
282
294
|
if (!detection) return '';
|
|
283
295
|
|
|
284
296
|
const framework = detection.stack?.framework || detection.stack?.primary?.framework;
|