wogiflow 1.0.12 → 1.0.13
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/.workflow/specs/architecture.md.template +24 -0
- package/.workflow/specs/stack.md.template +33 -0
- package/.workflow/specs/testing.md.template +36 -0
- package/README.md +90 -1
- package/package.json +1 -1
- package/scripts/MEMORY-ARCHITECTURE.md +150 -0
- package/scripts/flow +20 -19
- package/scripts/flow-auto-context.js +97 -3
- package/scripts/flow-conflict-resolver.js +735 -0
- package/scripts/flow-context-gatherer.js +520 -0
- package/scripts/flow-context-monitor.js +148 -19
- package/scripts/flow-damage-control.js +5 -1
- package/scripts/flow-export-profile +168 -1
- package/scripts/flow-import-profile +257 -6
- package/scripts/flow-instruction-richness.js +182 -18
- package/scripts/flow-knowledge-router.js +2 -0
- package/scripts/flow-knowledge-sync.js +2 -0
- package/scripts/{flow-transcript-chunking.js → flow-long-input-chunking.js} +4 -2
- package/scripts/{flow-transcript-parsing.js → flow-long-input-parsing.js} +35 -0
- package/scripts/{flow-transcript-stories.js → flow-long-input-stories.js} +86 -38
- package/scripts/{flow-transcript-digest.js → flow-long-input.js} +231 -15
- package/scripts/flow-memory-db.js +386 -1
- package/scripts/flow-memory-sync.js +2 -0
- package/scripts/flow-model-adapter.js +53 -29
- package/scripts/flow-model-router.js +246 -1
- package/scripts/flow-morning.js +94 -0
- package/scripts/flow-onboard +223 -10
- package/scripts/flow-orchestrate-validation.js +539 -0
- package/scripts/flow-orchestrate.js +16 -507
- package/scripts/flow-pattern-extractor.js +1265 -0
- package/scripts/flow-prompt-composer.js +222 -2
- package/scripts/flow-quality-guard.js +594 -0
- package/scripts/flow-section-index.js +713 -0
- package/scripts/flow-section-resolver.js +484 -0
- package/scripts/flow-session-end.js +188 -2
- package/scripts/flow-skill-create.js +19 -3
- package/scripts/flow-skill-matcher.js +122 -7
- package/scripts/flow-statusline-setup.js +218 -0
- package/scripts/flow-step-review.js +19 -0
- package/scripts/flow-tech-debt.js +734 -0
- package/scripts/flow-utils.js +2 -0
- package/scripts/hooks/core/long-input-gate.js +293 -0
- package/scripts/flow-parallel-detector.js +0 -399
- package/scripts/flow-parallel-dispatch.js +0 -987
- /package/scripts/{flow-transcript-language.js → flow-long-input-language.js} +0 -0
|
@@ -28,9 +28,23 @@ const {
|
|
|
28
28
|
dirExists,
|
|
29
29
|
printHeader,
|
|
30
30
|
printSection,
|
|
31
|
-
isPathWithinProject
|
|
31
|
+
isPathWithinProject,
|
|
32
|
+
estimateTokens
|
|
32
33
|
} = require('./flow-utils');
|
|
33
34
|
|
|
35
|
+
// Smart Context System integration
|
|
36
|
+
let sectionResolver = null;
|
|
37
|
+
let contextGatherer = null;
|
|
38
|
+
let instructionRichness = null;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
sectionResolver = require('./flow-section-resolver');
|
|
42
|
+
contextGatherer = require('./flow-context-gatherer');
|
|
43
|
+
instructionRichness = require('./flow-instruction-richness');
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// Smart Context modules not available, will use traditional approach
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
// ============================================================
|
|
35
49
|
// Constants
|
|
36
50
|
// ============================================================
|
|
@@ -340,6 +354,207 @@ function applyTemplate(template, data) {
|
|
|
340
354
|
});
|
|
341
355
|
}
|
|
342
356
|
|
|
357
|
+
// ============================================================
|
|
358
|
+
// Smart Context Composition (Section-Level)
|
|
359
|
+
// ============================================================
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Compose prompt with section-level context (Smart Context System)
|
|
363
|
+
* Instead of including full files, uses targeted section references.
|
|
364
|
+
*
|
|
365
|
+
* @param {Object} params - Composition parameters
|
|
366
|
+
* @returns {Promise<Object>} Composed prompt with section context
|
|
367
|
+
*/
|
|
368
|
+
async function composeWithSections(params) {
|
|
369
|
+
const {
|
|
370
|
+
model,
|
|
371
|
+
taskDescription,
|
|
372
|
+
taskType = 'feature',
|
|
373
|
+
domain = null,
|
|
374
|
+
taskData = null,
|
|
375
|
+
includeCore = true,
|
|
376
|
+
maxTokens = null
|
|
377
|
+
} = params;
|
|
378
|
+
|
|
379
|
+
// Check if Smart Context is available
|
|
380
|
+
if (!sectionResolver || !contextGatherer) {
|
|
381
|
+
// Fall back to traditional composition
|
|
382
|
+
return composePrompt({
|
|
383
|
+
model,
|
|
384
|
+
taskType,
|
|
385
|
+
domain,
|
|
386
|
+
taskData,
|
|
387
|
+
includeCore
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Get model preferences for context density
|
|
392
|
+
const modelPrefs = instructionRichness
|
|
393
|
+
? instructionRichness.getModelContextPreferences(model)
|
|
394
|
+
: { density: 'standard', explicitExamples: true, patternHints: true };
|
|
395
|
+
|
|
396
|
+
// Gather relevant sections using Smart Context
|
|
397
|
+
const contextResult = await contextGatherer.gatherContext({
|
|
398
|
+
task: taskDescription,
|
|
399
|
+
model,
|
|
400
|
+
maxTokens,
|
|
401
|
+
format: modelPrefs.density === 'concise' ? 'summary' : 'full'
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
// Get CLI for model
|
|
405
|
+
const cli = MODEL_CLI_MAP[model] || 'claude-code';
|
|
406
|
+
|
|
407
|
+
// Build sections array for traditional fragment composition
|
|
408
|
+
const allFragments = loadFragments();
|
|
409
|
+
const filtered = filterFragments(allFragments, { model, cli, domain });
|
|
410
|
+
|
|
411
|
+
// Compose sections
|
|
412
|
+
const sections = [];
|
|
413
|
+
|
|
414
|
+
// 1. Smart Context sections (from decisions.md, app-map.md, etc.)
|
|
415
|
+
if (contextResult.sections && contextResult.sections.length > 0) {
|
|
416
|
+
sections.push({
|
|
417
|
+
name: 'Project Rules (Targeted)',
|
|
418
|
+
content: formatSectionsForPrompt(contextResult.sections, modelPrefs),
|
|
419
|
+
fragments: contextResult.sections.map(s => s.id)
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// 2. Traditional fragments (quality guidelines, domain, formatting)
|
|
424
|
+
const qualityFragments = filtered.filter(f => f.metadata.purpose === 'quality');
|
|
425
|
+
const domainFragments = filtered.filter(f => f.metadata.purpose === 'domain');
|
|
426
|
+
const formatFragments = filtered.filter(f => f.metadata.purpose === 'formatting');
|
|
427
|
+
|
|
428
|
+
if (qualityFragments.length > 0) {
|
|
429
|
+
sections.push({
|
|
430
|
+
name: 'Quality Guidelines',
|
|
431
|
+
content: qualityFragments.map(f => f.content).join('\n\n'),
|
|
432
|
+
fragments: qualityFragments.map(f => f.metadata.id || f.file)
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (domainFragments.length > 0) {
|
|
437
|
+
sections.push({
|
|
438
|
+
name: 'Domain Guidelines',
|
|
439
|
+
content: domainFragments.map(f => f.content).join('\n\n'),
|
|
440
|
+
fragments: domainFragments.map(f => f.metadata.id || f.file)
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (formatFragments.length > 0) {
|
|
445
|
+
sections.push({
|
|
446
|
+
name: 'Output Format',
|
|
447
|
+
content: formatFragments.map(f => f.content).join('\n\n'),
|
|
448
|
+
fragments: formatFragments.map(f => f.metadata.id || f.file)
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// 3. Core task context (if requested)
|
|
453
|
+
if (includeCore && taskData) {
|
|
454
|
+
const coreFragments = filtered.filter(f => f.metadata.purpose === 'core');
|
|
455
|
+
if (coreFragments.length > 0) {
|
|
456
|
+
let coreContent = coreFragments.map(f => f.content).join('\n\n');
|
|
457
|
+
coreContent = applyTemplate(coreContent, taskData);
|
|
458
|
+
sections.push({
|
|
459
|
+
name: 'Task Context',
|
|
460
|
+
content: coreContent,
|
|
461
|
+
fragments: coreFragments.map(f => f.metadata.id || f.file)
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Compose full prompt
|
|
467
|
+
let fullPrompt = '';
|
|
468
|
+
for (const section of sections) {
|
|
469
|
+
if (section.content) {
|
|
470
|
+
fullPrompt += `## ${section.name}\n\n${section.content}\n\n`;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Apply template substitution if task data provided
|
|
475
|
+
if (taskData) {
|
|
476
|
+
fullPrompt = applyTemplate(fullPrompt, taskData);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return {
|
|
480
|
+
model,
|
|
481
|
+
cli,
|
|
482
|
+
domain,
|
|
483
|
+
taskType,
|
|
484
|
+
usedSmartContext: true,
|
|
485
|
+
modelDensity: modelPrefs.density,
|
|
486
|
+
sections: sections.map(s => ({
|
|
487
|
+
name: s.name,
|
|
488
|
+
fragments: s.fragments
|
|
489
|
+
})),
|
|
490
|
+
smartContextStats: contextResult.stats,
|
|
491
|
+
fragmentCount: filtered.length,
|
|
492
|
+
sectionCount: contextResult.sections?.length || 0,
|
|
493
|
+
prompt: fullPrompt.trim(),
|
|
494
|
+
tokenEstimate: estimateTokens ? estimateTokens(fullPrompt) : Math.ceil(fullPrompt.length / 4)
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Format sections for inclusion in prompt based on model preferences
|
|
500
|
+
* @param {Object[]} sections - Sections from Smart Context
|
|
501
|
+
* @param {Object} modelPrefs - Model context preferences
|
|
502
|
+
* @returns {string} Formatted section content
|
|
503
|
+
*/
|
|
504
|
+
function formatSectionsForPrompt(sections, modelPrefs) {
|
|
505
|
+
if (!sections || sections.length === 0) return '';
|
|
506
|
+
|
|
507
|
+
const lines = [];
|
|
508
|
+
|
|
509
|
+
for (const section of sections) {
|
|
510
|
+
const source = section.source || 'decisions.md';
|
|
511
|
+
const category = section.category || 'General';
|
|
512
|
+
|
|
513
|
+
if (modelPrefs.patternHints && !modelPrefs.explicitExamples) {
|
|
514
|
+
// Concise format: Just reference the rule
|
|
515
|
+
lines.push(`### ${section.title}`);
|
|
516
|
+
lines.push(`*From: ${source} > ${category}*`);
|
|
517
|
+
// First line or two as a hint
|
|
518
|
+
const firstLines = section.content?.split('\n').slice(0, 2).join(' ').trim() || '';
|
|
519
|
+
if (firstLines) {
|
|
520
|
+
lines.push(firstLines);
|
|
521
|
+
}
|
|
522
|
+
lines.push('');
|
|
523
|
+
} else {
|
|
524
|
+
// Full format: Include complete content
|
|
525
|
+
lines.push(`### ${section.title}`);
|
|
526
|
+
lines.push(`*From: ${source} > ${category}*`);
|
|
527
|
+
lines.push('');
|
|
528
|
+
if (section.content) {
|
|
529
|
+
lines.push(section.content);
|
|
530
|
+
}
|
|
531
|
+
lines.push('');
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return lines.join('\n');
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Compose prompt with automatic format selection
|
|
540
|
+
* Uses Smart Context when available and task description provided,
|
|
541
|
+
* falls back to traditional fragment-based composition otherwise.
|
|
542
|
+
*
|
|
543
|
+
* @param {Object} params - Composition parameters
|
|
544
|
+
* @returns {Promise<Object>} Composed prompt
|
|
545
|
+
*/
|
|
546
|
+
async function composePromptAuto(params) {
|
|
547
|
+
const { taskDescription, useSmartContext = true } = params;
|
|
548
|
+
|
|
549
|
+
// Use Smart Context if available and task description provided
|
|
550
|
+
if (useSmartContext && taskDescription && sectionResolver && contextGatherer) {
|
|
551
|
+
return composeWithSections(params);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Fall back to traditional composition
|
|
555
|
+
return composePrompt(params);
|
|
556
|
+
}
|
|
557
|
+
|
|
343
558
|
// ============================================================
|
|
344
559
|
// CLI Output
|
|
345
560
|
// ============================================================
|
|
@@ -471,12 +686,17 @@ async function main() {
|
|
|
471
686
|
|
|
472
687
|
// Export for use by other scripts
|
|
473
688
|
module.exports = {
|
|
689
|
+
// Traditional composition
|
|
474
690
|
composePrompt,
|
|
475
691
|
loadFragments,
|
|
476
692
|
filterFragments,
|
|
477
693
|
parseFragment,
|
|
478
694
|
applyTemplate,
|
|
479
|
-
MODEL_CLI_MAP
|
|
695
|
+
MODEL_CLI_MAP,
|
|
696
|
+
// Smart Context composition
|
|
697
|
+
composeWithSections,
|
|
698
|
+
composePromptAuto,
|
|
699
|
+
formatSectionsForPrompt
|
|
480
700
|
};
|
|
481
701
|
|
|
482
702
|
if (require.main === module) {
|