compact-agent 1.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/README.md +394 -0
- package/bin/anycode.js +2 -0
- package/bin/crowcoder.js +19 -0
- package/bin/ecc-hooks.cjs +138 -0
- package/dist/agents.d.ts +17 -0
- package/dist/agents.js +1603 -0
- package/dist/agents.js.map +1 -0
- package/dist/api.d.ts +16 -0
- package/dist/api.js +115 -0
- package/dist/api.js.map +1 -0
- package/dist/autonomous-loops.d.ts +108 -0
- package/dist/autonomous-loops.js +526 -0
- package/dist/autonomous-loops.js.map +1 -0
- package/dist/codemaps.d.ts +53 -0
- package/dist/codemaps.js +325 -0
- package/dist/codemaps.js.map +1 -0
- package/dist/compaction.d.ts +30 -0
- package/dist/compaction.js +125 -0
- package/dist/compaction.js.map +1 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +79 -0
- package/dist/config.js.map +1 -0
- package/dist/content-engine.d.ts +97 -0
- package/dist/content-engine.js +721 -0
- package/dist/content-engine.js.map +1 -0
- package/dist/cost-tracker.d.ts +49 -0
- package/dist/cost-tracker.js +150 -0
- package/dist/cost-tracker.js.map +1 -0
- package/dist/counter-button.d.ts +35 -0
- package/dist/counter-button.js +48 -0
- package/dist/counter-button.js.map +1 -0
- package/dist/counter.d.ts +21 -0
- package/dist/counter.js +31 -0
- package/dist/counter.js.map +1 -0
- package/dist/coverage.d.ts +23 -0
- package/dist/coverage.js +215 -0
- package/dist/coverage.js.map +1 -0
- package/dist/docs-sync.d.ts +23 -0
- package/dist/docs-sync.js +266 -0
- package/dist/docs-sync.js.map +1 -0
- package/dist/ecc.d.ts +41 -0
- package/dist/ecc.js +644 -0
- package/dist/ecc.js.map +1 -0
- package/dist/evaluation.d.ts +24 -0
- package/dist/evaluation.js +412 -0
- package/dist/evaluation.js.map +1 -0
- package/dist/export.d.ts +22 -0
- package/dist/export.js +109 -0
- package/dist/export.js.map +1 -0
- package/dist/git-workflow.d.ts +22 -0
- package/dist/git-workflow.js +197 -0
- package/dist/git-workflow.js.map +1 -0
- package/dist/hook-controls.d.ts +34 -0
- package/dist/hook-controls.js +90 -0
- package/dist/hook-controls.js.map +1 -0
- package/dist/hooks.d.ts +30 -0
- package/dist/hooks.js +130 -0
- package/dist/hooks.js.map +1 -0
- package/dist/html-parser.d.ts +18 -0
- package/dist/html-parser.js +101 -0
- package/dist/html-parser.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1230 -0
- package/dist/index.js.map +1 -0
- package/dist/learning.d.ts +35 -0
- package/dist/learning.js +238 -0
- package/dist/learning.js.map +1 -0
- package/dist/login.d.ts +37 -0
- package/dist/login.js +191 -0
- package/dist/login.js.map +1 -0
- package/dist/memory.d.ts +39 -0
- package/dist/memory.js +183 -0
- package/dist/memory.js.map +1 -0
- package/dist/model-router.d.ts +23 -0
- package/dist/model-router.js +145 -0
- package/dist/model-router.js.map +1 -0
- package/dist/modes.d.ts +17 -0
- package/dist/modes.js +217 -0
- package/dist/modes.js.map +1 -0
- package/dist/orchestration.d.ts +37 -0
- package/dist/orchestration.js +139 -0
- package/dist/orchestration.js.map +1 -0
- package/dist/package-detect.d.ts +36 -0
- package/dist/package-detect.js +529 -0
- package/dist/package-detect.js.map +1 -0
- package/dist/permissions.d.ts +25 -0
- package/dist/permissions.js +50 -0
- package/dist/permissions.js.map +1 -0
- package/dist/pm2-manager.d.ts +40 -0
- package/dist/pm2-manager.js +127 -0
- package/dist/pm2-manager.js.map +1 -0
- package/dist/query.d.ts +15 -0
- package/dist/query.js +278 -0
- package/dist/query.js.map +1 -0
- package/dist/refactor.d.ts +22 -0
- package/dist/refactor.js +226 -0
- package/dist/refactor.js.map +1 -0
- package/dist/retry.d.ts +20 -0
- package/dist/retry.js +88 -0
- package/dist/retry.js.map +1 -0
- package/dist/rules.d.ts +34 -0
- package/dist/rules.js +942 -0
- package/dist/rules.js.map +1 -0
- package/dist/schema.d.ts +23 -0
- package/dist/schema.js +12 -0
- package/dist/schema.js.map +1 -0
- package/dist/search-first.d.ts +17 -0
- package/dist/search-first.js +301 -0
- package/dist/search-first.js.map +1 -0
- package/dist/security.d.ts +10 -0
- package/dist/security.js +145 -0
- package/dist/security.js.map +1 -0
- package/dist/sessions.d.ts +21 -0
- package/dist/sessions.js +112 -0
- package/dist/sessions.js.map +1 -0
- package/dist/skill-create.d.ts +38 -0
- package/dist/skill-create.js +389 -0
- package/dist/skill-create.js.map +1 -0
- package/dist/skills.d.ts +34 -0
- package/dist/skills.js +161 -0
- package/dist/skills.js.map +1 -0
- package/dist/strategic-compaction.d.ts +24 -0
- package/dist/strategic-compaction.js +144 -0
- package/dist/strategic-compaction.js.map +1 -0
- package/dist/system-prompt.d.ts +3 -0
- package/dist/system-prompt.js +101 -0
- package/dist/system-prompt.js.map +1 -0
- package/dist/theme.d.ts +60 -0
- package/dist/theme.js +220 -0
- package/dist/theme.js.map +1 -0
- package/dist/tools/bash.d.ts +2 -0
- package/dist/tools/bash.js +49 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.js +76 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/glob.d.ts +2 -0
- package/dist/tools/glob.js +54 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +2 -0
- package/dist/tools/grep.js +64 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.js +27 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-dir.d.ts +2 -0
- package/dist/tools/list-dir.js +51 -0
- package/dist/tools/list-dir.js.map +1 -0
- package/dist/tools/read.d.ts +2 -0
- package/dist/tools/read.js +56 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/types.d.ts +45 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +2 -0
- package/dist/tools/web-fetch.js +41 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +27 -0
- package/dist/tools/web-search.js +139 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/write.d.ts +2 -0
- package/dist/tools/write.js +36 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +57 -0
- package/dist/types.js.map +1 -0
- package/dist/users.d.ts +51 -0
- package/dist/users.js +193 -0
- package/dist/users.js.map +1 -0
- package/dist/verification.d.ts +73 -0
- package/dist/verification.js +269 -0
- package/dist/verification.js.map +1 -0
- package/dist/walkthrough.d.ts +10 -0
- package/dist/walkthrough.js +121 -0
- package/dist/walkthrough.js.map +1 -0
- package/package.json +58 -0
- package/resources/ecc/agents/architect.json +16 -0
- package/resources/ecc/agents/architect.md +212 -0
- package/resources/ecc/agents/build-error-resolver.json +17 -0
- package/resources/ecc/agents/build-error-resolver.md +116 -0
- package/resources/ecc/agents/chief-of-staff.json +17 -0
- package/resources/ecc/agents/chief-of-staff.md +153 -0
- package/resources/ecc/agents/code-reviewer.json +16 -0
- package/resources/ecc/agents/code-reviewer.md +238 -0
- package/resources/ecc/agents/database-reviewer.json +16 -0
- package/resources/ecc/agents/database-reviewer.md +92 -0
- package/resources/ecc/agents/doc-updater.json +16 -0
- package/resources/ecc/agents/doc-updater.md +108 -0
- package/resources/ecc/agents/e2e-runner.json +17 -0
- package/resources/ecc/agents/e2e-runner.md +109 -0
- package/resources/ecc/agents/go-build-resolver.json +17 -0
- package/resources/ecc/agents/go-build-resolver.md +96 -0
- package/resources/ecc/agents/go-reviewer.json +16 -0
- package/resources/ecc/agents/go-reviewer.md +77 -0
- package/resources/ecc/agents/harness-optimizer.json +15 -0
- package/resources/ecc/agents/harness-optimizer.md +34 -0
- package/resources/ecc/agents/loop-operator.json +16 -0
- package/resources/ecc/agents/loop-operator.md +36 -0
- package/resources/ecc/agents/planner.json +15 -0
- package/resources/ecc/agents/planner.md +212 -0
- package/resources/ecc/agents/python-reviewer.json +16 -0
- package/resources/ecc/agents/python-reviewer.md +99 -0
- package/resources/ecc/agents/refactor-cleaner.json +17 -0
- package/resources/ecc/agents/refactor-cleaner.md +87 -0
- package/resources/ecc/agents/security-reviewer.json +16 -0
- package/resources/ecc/agents/security-reviewer.md +109 -0
- package/resources/ecc/agents/tdd-guide.json +17 -0
- package/resources/ecc/agents/tdd-guide.md +93 -0
- package/resources/ecc/commands/add-language-rules.md +39 -0
- package/resources/ecc/commands/database-migration.md +36 -0
- package/resources/ecc/commands/feature-development.md +38 -0
- package/resources/ecc/prompts/build-fix.prompt.md +47 -0
- package/resources/ecc/prompts/code-review.prompt.md +56 -0
- package/resources/ecc/prompts/plan.prompt.md +52 -0
- package/resources/ecc/prompts/refactor.prompt.md +50 -0
- package/resources/ecc/prompts/security-review.prompt.md +70 -0
- package/resources/ecc/prompts/tdd.prompt.md +47 -0
- package/resources/ecc/rules/common-agents.md +53 -0
- package/resources/ecc/rules/common-coding-style.md +52 -0
- package/resources/ecc/rules/common-development-workflow.md +33 -0
- package/resources/ecc/rules/common-git-workflow.md +28 -0
- package/resources/ecc/rules/common-hooks.md +34 -0
- package/resources/ecc/rules/common-patterns.md +35 -0
- package/resources/ecc/rules/common-performance.md +59 -0
- package/resources/ecc/rules/common-security.md +33 -0
- package/resources/ecc/rules/common-testing.md +33 -0
- package/resources/ecc/rules/golang-coding-style.md +31 -0
- package/resources/ecc/rules/golang-hooks.md +16 -0
- package/resources/ecc/rules/golang-patterns.md +44 -0
- package/resources/ecc/rules/golang-security.md +33 -0
- package/resources/ecc/rules/golang-testing.md +30 -0
- package/resources/ecc/rules/kotlin-coding-style.md +39 -0
- package/resources/ecc/rules/kotlin-hooks.md +16 -0
- package/resources/ecc/rules/kotlin-patterns.md +50 -0
- package/resources/ecc/rules/kotlin-security.md +58 -0
- package/resources/ecc/rules/kotlin-testing.md +38 -0
- package/resources/ecc/rules/php-coding-style.md +25 -0
- package/resources/ecc/rules/php-hooks.md +21 -0
- package/resources/ecc/rules/php-patterns.md +23 -0
- package/resources/ecc/rules/php-security.md +24 -0
- package/resources/ecc/rules/php-testing.md +26 -0
- package/resources/ecc/rules/python-coding-style.md +42 -0
- package/resources/ecc/rules/python-hooks.md +19 -0
- package/resources/ecc/rules/python-patterns.md +39 -0
- package/resources/ecc/rules/python-security.md +30 -0
- package/resources/ecc/rules/python-testing.md +38 -0
- package/resources/ecc/rules/swift-coding-style.md +47 -0
- package/resources/ecc/rules/swift-hooks.md +20 -0
- package/resources/ecc/rules/swift-patterns.md +66 -0
- package/resources/ecc/rules/swift-security.md +33 -0
- package/resources/ecc/rules/swift-testing.md +45 -0
- package/resources/ecc/rules/typescript-coding-style.md +63 -0
- package/resources/ecc/rules/typescript-hooks.md +20 -0
- package/resources/ecc/rules/typescript-patterns.md +50 -0
- package/resources/ecc/rules/typescript-security.md +26 -0
- package/resources/ecc/rules/typescript-testing.md +16 -0
- package/resources/ecc/skills/agent-introspection-debugging/SKILL.md +152 -0
- package/resources/ecc/skills/agent-introspection-debugging/agents/openai.yaml +7 -0
- package/resources/ecc/skills/agent-sort/SKILL.md +214 -0
- package/resources/ecc/skills/agent-sort/agents/openai.yaml +7 -0
- package/resources/ecc/skills/api-design/SKILL.md +522 -0
- package/resources/ecc/skills/api-design/agents/openai.yaml +7 -0
- package/resources/ecc/skills/article-writing/SKILL.md +78 -0
- package/resources/ecc/skills/article-writing/agents/openai.yaml +7 -0
- package/resources/ecc/skills/backend-patterns/SKILL.md +597 -0
- package/resources/ecc/skills/backend-patterns/agents/openai.yaml +7 -0
- package/resources/ecc/skills/brand-voice/SKILL.md +96 -0
- package/resources/ecc/skills/brand-voice/agents/openai.yaml +7 -0
- package/resources/ecc/skills/brand-voice/references/voice-profile-schema.md +55 -0
- package/resources/ecc/skills/bun-runtime/SKILL.md +83 -0
- package/resources/ecc/skills/bun-runtime/agents/openai.yaml +7 -0
- package/resources/ecc/skills/coding-standards/SKILL.md +548 -0
- package/resources/ecc/skills/coding-standards/agents/openai.yaml +7 -0
- package/resources/ecc/skills/content-engine/SKILL.md +130 -0
- package/resources/ecc/skills/content-engine/agents/openai.yaml +7 -0
- package/resources/ecc/skills/crosspost/SKILL.md +110 -0
- package/resources/ecc/skills/crosspost/agents/openai.yaml +7 -0
- package/resources/ecc/skills/deep-research/SKILL.md +154 -0
- package/resources/ecc/skills/deep-research/agents/openai.yaml +7 -0
- package/resources/ecc/skills/dmux-workflows/SKILL.md +143 -0
- package/resources/ecc/skills/dmux-workflows/agents/openai.yaml +7 -0
- package/resources/ecc/skills/documentation-lookup/SKILL.md +89 -0
- package/resources/ecc/skills/documentation-lookup/agents/openai.yaml +7 -0
- package/resources/ecc/skills/e2e-testing/SKILL.md +325 -0
- package/resources/ecc/skills/e2e-testing/agents/openai.yaml +7 -0
- package/resources/ecc/skills/eval-harness/SKILL.md +235 -0
- package/resources/ecc/skills/eval-harness/agents/openai.yaml +7 -0
- package/resources/ecc/skills/everything-claude-code/SKILL.md +442 -0
- package/resources/ecc/skills/everything-claude-code/agents/openai.yaml +7 -0
- package/resources/ecc/skills/exa-search/SKILL.md +169 -0
- package/resources/ecc/skills/exa-search/agents/openai.yaml +7 -0
- package/resources/ecc/skills/fal-ai-media/SKILL.md +276 -0
- package/resources/ecc/skills/fal-ai-media/agents/openai.yaml +7 -0
- package/resources/ecc/skills/frontend-patterns/SKILL.md +647 -0
- package/resources/ecc/skills/frontend-patterns/agents/openai.yaml +7 -0
- package/resources/ecc/skills/frontend-slides/SKILL.md +183 -0
- package/resources/ecc/skills/frontend-slides/STYLE_PRESETS.md +330 -0
- package/resources/ecc/skills/frontend-slides/agents/openai.yaml +7 -0
- package/resources/ecc/skills/investor-materials/SKILL.md +95 -0
- package/resources/ecc/skills/investor-materials/agents/openai.yaml +7 -0
- package/resources/ecc/skills/investor-outreach/SKILL.md +90 -0
- package/resources/ecc/skills/investor-outreach/agents/openai.yaml +7 -0
- package/resources/ecc/skills/market-research/SKILL.md +74 -0
- package/resources/ecc/skills/market-research/agents/openai.yaml +7 -0
- package/resources/ecc/skills/mcp-server-patterns/SKILL.md +66 -0
- package/resources/ecc/skills/mcp-server-patterns/agents/openai.yaml +7 -0
- package/resources/ecc/skills/mle-workflow/SKILL.md +346 -0
- package/resources/ecc/skills/mle-workflow/agents/openai.yaml +7 -0
- package/resources/ecc/skills/nextjs-turbopack/SKILL.md +43 -0
- package/resources/ecc/skills/nextjs-turbopack/agents/openai.yaml +7 -0
- package/resources/ecc/skills/product-capability/SKILL.md +140 -0
- package/resources/ecc/skills/product-capability/agents/openai.yaml +7 -0
- package/resources/ecc/skills/security-review/SKILL.md +494 -0
- package/resources/ecc/skills/security-review/agents/openai.yaml +7 -0
- package/resources/ecc/skills/strategic-compact/SKILL.md +102 -0
- package/resources/ecc/skills/strategic-compact/agents/openai.yaml +7 -0
- package/resources/ecc/skills/tdd-workflow/SKILL.md +409 -0
- package/resources/ecc/skills/tdd-workflow/agents/openai.yaml +7 -0
- package/resources/ecc/skills/verification-loop/SKILL.md +125 -0
- package/resources/ecc/skills/verification-loop/agents/openai.yaml +7 -0
- package/resources/ecc/skills/video-editing/SKILL.md +307 -0
- package/resources/ecc/skills/video-editing/agents/openai.yaml +7 -0
- package/resources/ecc/skills/x-api/SKILL.md +229 -0
- package/resources/ecc/skills/x-api/agents/openai.yaml +7 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autonomous loop execution system for iterative workflows.
|
|
3
|
+
* Inspired by everything-claude-code: enables VerificationLoop, PRReviewLoop,
|
|
4
|
+
* SequentialPipeline, and DAGOrchestration patterns.
|
|
5
|
+
*/
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
/**
|
|
8
|
+
* Build a prompt for iterative PR review.
|
|
9
|
+
* Instructs the agent to review the PR, address comments, and re-review until approved.
|
|
10
|
+
*/
|
|
11
|
+
export function buildPRLoopPrompt(cwd) {
|
|
12
|
+
return `You are a thorough code reviewer in an autonomous PR review loop.
|
|
13
|
+
|
|
14
|
+
Working directory: ${cwd}
|
|
15
|
+
|
|
16
|
+
Your task is to:
|
|
17
|
+
1. Review the current PR changes
|
|
18
|
+
2. Identify issues, improvements, or feedback
|
|
19
|
+
3. Suggest fixes or clarifications
|
|
20
|
+
4. After fixes are applied, re-review until you approve
|
|
21
|
+
|
|
22
|
+
Loop Instructions:
|
|
23
|
+
- On each iteration, provide clear, actionable feedback
|
|
24
|
+
- Mark feedback as CRITICAL, MAJOR, or MINOR
|
|
25
|
+
- Track which issues have been resolved
|
|
26
|
+
- When all issues are resolved, respond with: "PR_APPROVED"
|
|
27
|
+
- If no changes are made after feedback, respond with: "NO_CHANGES_DETECTED"
|
|
28
|
+
- Maximum 5 iterations allowed
|
|
29
|
+
|
|
30
|
+
Format your response as:
|
|
31
|
+
\`\`\`
|
|
32
|
+
## Review Iteration [N]
|
|
33
|
+
### Issues Found:
|
|
34
|
+
- [issue]: [description]
|
|
35
|
+
|
|
36
|
+
### Approved: [yes/no]
|
|
37
|
+
### Next Steps: [what needs fixing]
|
|
38
|
+
\`\`\``;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build a prompt for sequential pipeline execution.
|
|
42
|
+
* Each task can reference the output of prior tasks.
|
|
43
|
+
*/
|
|
44
|
+
export function buildSequentialPipelinePrompt(tasks) {
|
|
45
|
+
const taskList = tasks
|
|
46
|
+
.map((task, i) => `${i + 1}. ${task}`)
|
|
47
|
+
.join('\n');
|
|
48
|
+
return `Execute the following tasks sequentially. Each task can reference the output of prior tasks.
|
|
49
|
+
|
|
50
|
+
## Tasks:
|
|
51
|
+
${taskList}
|
|
52
|
+
|
|
53
|
+
## Execution Rules:
|
|
54
|
+
- Run tasks in the specified order
|
|
55
|
+
- Each task sees all prior outputs
|
|
56
|
+
- After completing each task, summarize the result
|
|
57
|
+
- If a task fails, explain the error and attempt recovery
|
|
58
|
+
- Continue to the next task even if recovery is partial (unless critical)
|
|
59
|
+
|
|
60
|
+
For each task, format your response:
|
|
61
|
+
\`\`\`
|
|
62
|
+
## Task [N]: [name]
|
|
63
|
+
### Input from prior tasks: [summary or "none"]
|
|
64
|
+
### Execution:
|
|
65
|
+
[your work here]
|
|
66
|
+
|
|
67
|
+
### Result:
|
|
68
|
+
[clear summary of what was accomplished]
|
|
69
|
+
|
|
70
|
+
### Status: [success/partial/failed]
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
After all tasks, provide a final summary of the entire pipeline.`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Build a prompt for DAG (directed acyclic graph) execution.
|
|
77
|
+
* Steps run in dependency order, potentially in parallel where possible.
|
|
78
|
+
*/
|
|
79
|
+
export function buildDAGPrompt(dag) {
|
|
80
|
+
const stepList = dag.steps
|
|
81
|
+
.map((step) => `- ${step.id} (${step.name}): ${step.task}${step.dependsOn.length > 0 ? ` [depends on: ${step.dependsOn.join(', ')}]` : ''}`)
|
|
82
|
+
.join('\n');
|
|
83
|
+
const strategyDescription = dag.strategy === 'parallel-max'
|
|
84
|
+
? 'Run steps in parallel whenever dependencies allow.'
|
|
85
|
+
: dag.strategy === 'sequential'
|
|
86
|
+
? 'Run steps one at a time in dependency order.'
|
|
87
|
+
: 'Run steps in topological layers for optimal parallelism.';
|
|
88
|
+
return `Execute the following task graph (DAG). Each step may depend on prior steps.
|
|
89
|
+
|
|
90
|
+
## Task Graph:
|
|
91
|
+
${stepList}
|
|
92
|
+
|
|
93
|
+
## Strategy: ${dag.strategy}
|
|
94
|
+
${strategyDescription}
|
|
95
|
+
|
|
96
|
+
## Execution Rules:
|
|
97
|
+
- Respect all dependency relationships
|
|
98
|
+
- Skip a step if its dependency failed (mark as skipped)
|
|
99
|
+
- For parallel execution, run independent steps concurrently
|
|
100
|
+
- Capture the result of each step for dependent steps to use
|
|
101
|
+
- On error, log clearly and continue (unless critical)
|
|
102
|
+
|
|
103
|
+
For each step, format your response:
|
|
104
|
+
\`\`\`
|
|
105
|
+
## Step: [id] - [name]
|
|
106
|
+
### Dependencies: [list of completed prior steps or "none"]
|
|
107
|
+
### Execution:
|
|
108
|
+
[your work here]
|
|
109
|
+
|
|
110
|
+
### Result:
|
|
111
|
+
[clear output]
|
|
112
|
+
|
|
113
|
+
### Status: [success/skipped/failed]
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
After all steps, provide a final summary of the DAG execution.`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Topological sort of PipelineStep array.
|
|
120
|
+
* Returns an array of arrays, where each inner array is an execution layer.
|
|
121
|
+
* Steps in the same layer have no inter-dependencies and can run in parallel.
|
|
122
|
+
*/
|
|
123
|
+
export function topologicalSort(steps) {
|
|
124
|
+
const layers = [];
|
|
125
|
+
const stepMap = new Map(steps.map((s) => [s.id, s]));
|
|
126
|
+
const visited = new Set();
|
|
127
|
+
const inProgress = new Set();
|
|
128
|
+
function visit(step, depth) {
|
|
129
|
+
if (visited.has(step.id)) {
|
|
130
|
+
// Already processed; find which layer it's in
|
|
131
|
+
for (let i = 0; i < layers.length; i++) {
|
|
132
|
+
if (layers[i].some((s) => s.id === step.id)) {
|
|
133
|
+
return i;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
if (inProgress.has(step.id)) {
|
|
139
|
+
throw new Error(`Circular dependency detected at step ${step.id}`);
|
|
140
|
+
}
|
|
141
|
+
inProgress.add(step.id);
|
|
142
|
+
// Visit all dependencies first
|
|
143
|
+
let maxDepth = depth;
|
|
144
|
+
for (const depId of step.dependsOn) {
|
|
145
|
+
const dep = stepMap.get(depId);
|
|
146
|
+
if (dep) {
|
|
147
|
+
const depDepth = visit(dep, depth + 1);
|
|
148
|
+
maxDepth = Math.max(maxDepth, depDepth + 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
inProgress.delete(step.id);
|
|
152
|
+
visited.add(step.id);
|
|
153
|
+
// Ensure we have enough layers
|
|
154
|
+
while (layers.length <= maxDepth) {
|
|
155
|
+
layers.push([]);
|
|
156
|
+
}
|
|
157
|
+
// Add this step to its layer
|
|
158
|
+
layers[maxDepth].push(step);
|
|
159
|
+
return maxDepth;
|
|
160
|
+
}
|
|
161
|
+
for (const step of steps) {
|
|
162
|
+
if (!visited.has(step.id)) {
|
|
163
|
+
visit(step, 0);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return layers;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Pretty-print the status of a DAG using chalk colors.
|
|
170
|
+
*/
|
|
171
|
+
export function printDAGStatus(dag) {
|
|
172
|
+
console.log(chalk.cyan('\n ═══ DAG Execution Status ═══\n'));
|
|
173
|
+
const stepMap = new Map(dag.steps.map((s) => [s.id, s]));
|
|
174
|
+
const layers = topologicalSort(dag.steps);
|
|
175
|
+
for (let layerIdx = 0; layerIdx < layers.length; layerIdx++) {
|
|
176
|
+
const layer = layers[layerIdx];
|
|
177
|
+
console.log(chalk.blue(` Layer ${layerIdx + 1}:`));
|
|
178
|
+
for (const step of layer) {
|
|
179
|
+
const icon = step.status === 'done'
|
|
180
|
+
? chalk.green('✓')
|
|
181
|
+
: step.status === 'error'
|
|
182
|
+
? chalk.red('✗')
|
|
183
|
+
: step.status === 'running'
|
|
184
|
+
? chalk.yellow('⟳')
|
|
185
|
+
: step.status === 'skipped'
|
|
186
|
+
? chalk.dim('─')
|
|
187
|
+
: chalk.dim('○');
|
|
188
|
+
const elapsed = step.startedAt && step.finishedAt
|
|
189
|
+
? `${((step.finishedAt - step.startedAt) / 1000).toFixed(1)}s`
|
|
190
|
+
: '';
|
|
191
|
+
const deps = step.dependsOn.length > 0 ? ` [deps: ${step.dependsOn.join(', ')}]` : '';
|
|
192
|
+
console.log(` ${icon} ${step.id.padEnd(20)} ${step.name.padEnd(25)} ${elapsed.padEnd(8)}${deps}`);
|
|
193
|
+
if (step.error) {
|
|
194
|
+
console.log(chalk.red(` Error: ${step.error.slice(0, 60)}`));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
console.log();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Build a prompt for multi-agent task decomposition.
|
|
202
|
+
* Instructs the agent to break down a task into subtasks for parallel/sequential execution.
|
|
203
|
+
*/
|
|
204
|
+
export function buildMultiPlanPrompt(task) {
|
|
205
|
+
return `Decompose the following task into 2-5 independent subtasks that can be executed in parallel or sequence:
|
|
206
|
+
|
|
207
|
+
Task: ${task}
|
|
208
|
+
|
|
209
|
+
For each subtask, provide:
|
|
210
|
+
1. Subtask ID (e.g., "backend-setup")
|
|
211
|
+
2. Subtask name
|
|
212
|
+
3. Clear description of what to do
|
|
213
|
+
4. Any dependencies on other subtasks (or "none")
|
|
214
|
+
5. Estimated complexity: low/medium/high
|
|
215
|
+
|
|
216
|
+
Format as JSON array:
|
|
217
|
+
[
|
|
218
|
+
{
|
|
219
|
+
"id": "subtask-id",
|
|
220
|
+
"name": "Subtask Name",
|
|
221
|
+
"description": "What this subtask does",
|
|
222
|
+
"dependsOn": ["other-id"] or [],
|
|
223
|
+
"complexity": "low|medium|high"
|
|
224
|
+
},
|
|
225
|
+
...
|
|
226
|
+
]
|
|
227
|
+
|
|
228
|
+
Only output the JSON, no explanation.`;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Build a prompt for executing a multi-agent plan.
|
|
232
|
+
* Takes a JSON plan and generates execution instructions.
|
|
233
|
+
*/
|
|
234
|
+
export function buildMultiExecutePrompt(plan) {
|
|
235
|
+
return `Execute the following task plan. Each subtask may have dependencies.
|
|
236
|
+
|
|
237
|
+
## Plan:
|
|
238
|
+
${plan}
|
|
239
|
+
|
|
240
|
+
## Execution Instructions:
|
|
241
|
+
1. Parse the plan to understand subtask dependencies
|
|
242
|
+
2. Execute subtasks in order (respecting dependencies)
|
|
243
|
+
3. For independent subtasks, you may mention running them in parallel
|
|
244
|
+
4. After completing each subtask, summarize its result
|
|
245
|
+
5. If a subtask fails, attempt recovery or skip dependent tasks
|
|
246
|
+
6. Provide a final summary of all subtask results
|
|
247
|
+
|
|
248
|
+
Format each subtask execution as:
|
|
249
|
+
\`\`\`
|
|
250
|
+
## Subtask: [id] - [name]
|
|
251
|
+
### Execution:
|
|
252
|
+
[your work]
|
|
253
|
+
|
|
254
|
+
### Result:
|
|
255
|
+
[output]
|
|
256
|
+
|
|
257
|
+
### Status: [success/failed/skipped]
|
|
258
|
+
\`\`\``;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Build a prompt for orchestrating backend service changes.
|
|
262
|
+
* Useful for coordinating changes across multiple backend services.
|
|
263
|
+
*/
|
|
264
|
+
export function buildMultiBackendPrompt(services) {
|
|
265
|
+
const serviceList = services.map((s, i) => `${i + 1}. ${s}`).join('\n');
|
|
266
|
+
return `You are orchestrating changes across multiple backend services.
|
|
267
|
+
|
|
268
|
+
## Services to coordinate:
|
|
269
|
+
${serviceList}
|
|
270
|
+
|
|
271
|
+
## Coordination Rules:
|
|
272
|
+
1. Identify dependencies between services (if service A depends on service B, B must be updated first)
|
|
273
|
+
2. Group changes by update type (API changes, database migrations, configuration)
|
|
274
|
+
3. Create a safe update sequence that minimizes downtime
|
|
275
|
+
4. For each service, specify:
|
|
276
|
+
- What changes are needed
|
|
277
|
+
- Any pre-requisites or migrations
|
|
278
|
+
- Testing strategy
|
|
279
|
+
- Rollback plan
|
|
280
|
+
|
|
281
|
+
5. Consider:
|
|
282
|
+
- API compatibility (version gates if needed)
|
|
283
|
+
- Database schema compatibility
|
|
284
|
+
- Gradual rollout vs. big bang
|
|
285
|
+
- Health checks and monitoring
|
|
286
|
+
|
|
287
|
+
Format your response:
|
|
288
|
+
\`\`\`
|
|
289
|
+
## Update Plan
|
|
290
|
+
|
|
291
|
+
### Phase 1: Preparation
|
|
292
|
+
- Service changes to make
|
|
293
|
+
- Migrations to run
|
|
294
|
+
- Infrastructure checks
|
|
295
|
+
|
|
296
|
+
### Phase 2: Gradual Rollout
|
|
297
|
+
- Service update order
|
|
298
|
+
- Health checks between updates
|
|
299
|
+
- Rollback triggers
|
|
300
|
+
|
|
301
|
+
### Phase 3: Validation
|
|
302
|
+
- Integration tests to run
|
|
303
|
+
- Metrics to monitor
|
|
304
|
+
- Success criteria
|
|
305
|
+
\`\`\``;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Build a prompt for orchestrating frontend component changes.
|
|
309
|
+
* Useful for coordinating changes across multiple frontend components.
|
|
310
|
+
*/
|
|
311
|
+
export function buildMultiFrontendPrompt(components) {
|
|
312
|
+
const componentList = components.map((c, i) => `${i + 1}. ${c}`).join('\n');
|
|
313
|
+
return `You are orchestrating changes across multiple frontend components.
|
|
314
|
+
|
|
315
|
+
## Components to coordinate:
|
|
316
|
+
${componentList}
|
|
317
|
+
|
|
318
|
+
## Coordination Rules:
|
|
319
|
+
1. Map component dependencies (if ComponentA uses ComponentB, B must be updated first)
|
|
320
|
+
2. Identify shared state or context that multiple components use
|
|
321
|
+
3. Plan the update sequence to maintain app stability
|
|
322
|
+
4. For each component, specify:
|
|
323
|
+
- Props/API changes needed
|
|
324
|
+
- State management updates
|
|
325
|
+
- CSS/styling updates
|
|
326
|
+
- Test coverage needed
|
|
327
|
+
|
|
328
|
+
5. Consider:
|
|
329
|
+
- Backward compatibility (graceful degradation)
|
|
330
|
+
- Build system impact
|
|
331
|
+
- Bundle size implications
|
|
332
|
+
- Visual regression testing
|
|
333
|
+
|
|
334
|
+
Format your response:
|
|
335
|
+
\`\`\`
|
|
336
|
+
## Component Update Plan
|
|
337
|
+
|
|
338
|
+
### Dependency Graph
|
|
339
|
+
[List component dependencies]
|
|
340
|
+
|
|
341
|
+
### Update Sequence
|
|
342
|
+
[Order of component updates]
|
|
343
|
+
|
|
344
|
+
### Per-Component Changes
|
|
345
|
+
For each component:
|
|
346
|
+
- Props/API changes
|
|
347
|
+
- State updates
|
|
348
|
+
- Styling updates
|
|
349
|
+
- Tests to add/update
|
|
350
|
+
|
|
351
|
+
### Integration Testing
|
|
352
|
+
[How to verify components work together]
|
|
353
|
+
|
|
354
|
+
### Rollback Plan
|
|
355
|
+
[If something breaks]
|
|
356
|
+
\`\`\``;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Build a general autonomous loop prompt.
|
|
360
|
+
* Supports various loop types: verification, review, exploration, convergence, etc.
|
|
361
|
+
*/
|
|
362
|
+
export function buildLoopOperatorPrompt(task, loopType) {
|
|
363
|
+
const loopInstructions = getLoopTypeInstructions(loopType);
|
|
364
|
+
return `You are running an autonomous loop of type: ${loopType}
|
|
365
|
+
|
|
366
|
+
Task: ${task}
|
|
367
|
+
|
|
368
|
+
## Loop Operating System:
|
|
369
|
+
${loopInstructions}
|
|
370
|
+
|
|
371
|
+
## General Loop Rules:
|
|
372
|
+
1. Each iteration, perform the loop action and evaluate the stopping condition
|
|
373
|
+
2. If the stopping condition is met, output "LOOP_COMPLETE" and summarize
|
|
374
|
+
3. If the stopping condition is not met, iterate again
|
|
375
|
+
4. Maximum 10 iterations allowed (unless specified otherwise)
|
|
376
|
+
5. After each iteration, provide a status update
|
|
377
|
+
|
|
378
|
+
Format each iteration as:
|
|
379
|
+
\`\`\`
|
|
380
|
+
## Iteration [N]
|
|
381
|
+
### Action:
|
|
382
|
+
[what you did]
|
|
383
|
+
|
|
384
|
+
### Evaluation:
|
|
385
|
+
[did the stopping condition pass?]
|
|
386
|
+
|
|
387
|
+
### Status:
|
|
388
|
+
[continue/complete]
|
|
389
|
+
\`\`\`
|
|
390
|
+
|
|
391
|
+
After loop completion, provide a final summary.`;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Helper function to generate loop-type-specific instructions.
|
|
395
|
+
*/
|
|
396
|
+
function getLoopTypeInstructions(loopType) {
|
|
397
|
+
const instructions = {
|
|
398
|
+
verification: `
|
|
399
|
+
This is a VERIFICATION LOOP:
|
|
400
|
+
1. Run tests for the target code
|
|
401
|
+
2. If tests pass, stopping condition is met (LOOP_COMPLETE)
|
|
402
|
+
3. If tests fail, identify the issue and propose a fix
|
|
403
|
+
4. Apply the fix and re-run tests
|
|
404
|
+
5. Iterate until tests pass or max iterations reached
|
|
405
|
+
`,
|
|
406
|
+
review: `
|
|
407
|
+
This is a REVIEW LOOP:
|
|
408
|
+
1. Review the current state/code/design
|
|
409
|
+
2. Identify issues, gaps, or improvements
|
|
410
|
+
3. If no issues found, stopping condition is met (LOOP_COMPLETE)
|
|
411
|
+
4. If issues found, address them one by one
|
|
412
|
+
5. Re-review after fixes and iterate until all issues resolved
|
|
413
|
+
`,
|
|
414
|
+
exploration: `
|
|
415
|
+
This is an EXPLORATION LOOP:
|
|
416
|
+
1. Explore the current state to understand it
|
|
417
|
+
2. Ask clarifying questions or gather information
|
|
418
|
+
3. If sufficient understanding is achieved, stopping condition is met (LOOP_COMPLETE)
|
|
419
|
+
4. If gaps remain, dig deeper or investigate specific areas
|
|
420
|
+
5. Repeat until you have a complete mental model
|
|
421
|
+
`,
|
|
422
|
+
convergence: `
|
|
423
|
+
This is a CONVERGENCE LOOP:
|
|
424
|
+
1. Generate or refine a solution
|
|
425
|
+
2. Evaluate it against criteria
|
|
426
|
+
3. If it meets all criteria, stopping condition is met (LOOP_COMPLETE)
|
|
427
|
+
4. If gaps remain, identify what needs improvement
|
|
428
|
+
5. Refine the solution and re-evaluate
|
|
429
|
+
6. Iterate until solution converges to acceptable quality
|
|
430
|
+
`,
|
|
431
|
+
debugging: `
|
|
432
|
+
This is a DEBUGGING LOOP:
|
|
433
|
+
1. Identify the symptom or error
|
|
434
|
+
2. Form a hypothesis about the root cause
|
|
435
|
+
3. Test the hypothesis with evidence
|
|
436
|
+
4. If confirmed, stopping condition is met (LOOP_COMPLETE)
|
|
437
|
+
5. If not confirmed, form a new hypothesis
|
|
438
|
+
6. Iterate until root cause is identified and explained
|
|
439
|
+
`,
|
|
440
|
+
optimization: `
|
|
441
|
+
This is an OPTIMIZATION LOOP:
|
|
442
|
+
1. Measure the current performance or quality metric
|
|
443
|
+
2. Identify opportunities to improve
|
|
444
|
+
3. Apply an optimization
|
|
445
|
+
4. Re-measure and check for improvement
|
|
446
|
+
5. If metric reaches target, stopping condition is met (LOOP_COMPLETE)
|
|
447
|
+
6. If not, apply another optimization
|
|
448
|
+
7. Iterate until target is reached or diminishing returns found
|
|
449
|
+
`,
|
|
450
|
+
default: `
|
|
451
|
+
This is a GENERIC AUTONOMOUS LOOP:
|
|
452
|
+
1. On each iteration, work toward the task goal
|
|
453
|
+
2. Evaluate progress: Are you closer to completion?
|
|
454
|
+
3. If task is complete, stopping condition is met (LOOP_COMPLETE)
|
|
455
|
+
4. If not, identify next steps and continue
|
|
456
|
+
5. Iterate until task is complete or max iterations reached
|
|
457
|
+
`,
|
|
458
|
+
};
|
|
459
|
+
return instructions[loopType] || instructions['default'];
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Helper function to compute the status of all steps in a DAG.
|
|
463
|
+
* Returns a summary string for logging.
|
|
464
|
+
*/
|
|
465
|
+
export function summarizeDAGStatus(dag) {
|
|
466
|
+
const totalSteps = dag.steps.length;
|
|
467
|
+
const doneSteps = dag.steps.filter((s) => s.status === 'done').length;
|
|
468
|
+
const errorSteps = dag.steps.filter((s) => s.status === 'error').length;
|
|
469
|
+
const skippedSteps = dag.steps.filter((s) => s.status === 'skipped').length;
|
|
470
|
+
const runningSteps = dag.steps.filter((s) => s.status === 'running').length;
|
|
471
|
+
const pendingSteps = dag.steps.filter((s) => s.status === 'pending').length;
|
|
472
|
+
const parts = [];
|
|
473
|
+
if (doneSteps > 0)
|
|
474
|
+
parts.push(chalk.green(`${doneSteps} done`));
|
|
475
|
+
if (errorSteps > 0)
|
|
476
|
+
parts.push(chalk.red(`${errorSteps} error`));
|
|
477
|
+
if (skippedSteps > 0)
|
|
478
|
+
parts.push(chalk.dim(`${skippedSteps} skipped`));
|
|
479
|
+
if (runningSteps > 0)
|
|
480
|
+
parts.push(chalk.yellow(`${runningSteps} running`));
|
|
481
|
+
if (pendingSteps > 0)
|
|
482
|
+
parts.push(chalk.dim(`${pendingSteps} pending`));
|
|
483
|
+
return `DAG: ${totalSteps} total steps [${parts.join(', ')}]`;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Helper function to check if a DAG has completed successfully.
|
|
487
|
+
*/
|
|
488
|
+
export function isDAGComplete(dag) {
|
|
489
|
+
return (dag.steps.every((s) => s.status === 'done' || s.status === 'skipped' || s.status === 'error') &&
|
|
490
|
+
dag.steps.some((s) => s.status === 'done'));
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Helper function to check if a DAG has failed.
|
|
494
|
+
*/
|
|
495
|
+
export function hasDAGFailed(dag) {
|
|
496
|
+
return dag.steps.some((s) => s.status === 'error');
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Helper function to collect all results from a completed DAG.
|
|
500
|
+
*/
|
|
501
|
+
export function collectDAGResults(dag) {
|
|
502
|
+
const results = {};
|
|
503
|
+
for (const step of dag.steps) {
|
|
504
|
+
results[step.id] = step.result;
|
|
505
|
+
}
|
|
506
|
+
return results;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Helper function to format a DAG as a readable plan.
|
|
510
|
+
*/
|
|
511
|
+
export function formatDAGAsPlan(dag) {
|
|
512
|
+
const layers = topologicalSort(dag.steps);
|
|
513
|
+
const lines = ['# Execution Plan\n'];
|
|
514
|
+
for (let i = 0; i < layers.length; i++) {
|
|
515
|
+
const layer = layers[i];
|
|
516
|
+
lines.push(`## Layer ${i + 1} (Parallel Execution Possible)\n`);
|
|
517
|
+
for (const step of layer) {
|
|
518
|
+
const deps = step.dependsOn.length > 0 ? ` depends on [${step.dependsOn.join(', ')}]` : '';
|
|
519
|
+
lines.push(`- **${step.id}**: ${step.name}${deps}`);
|
|
520
|
+
lines.push(` - Task: ${step.task}`);
|
|
521
|
+
}
|
|
522
|
+
lines.push('');
|
|
523
|
+
}
|
|
524
|
+
return lines.join('\n');
|
|
525
|
+
}
|
|
526
|
+
//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AAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3F,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;YACpD,KAAK,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Map System — Project structure tracking and context injection.
|
|
3
|
+
* Maintains a map of project structure, modules, and file relationships.
|
|
4
|
+
*/
|
|
5
|
+
export interface FileEntry {
|
|
6
|
+
path: string;
|
|
7
|
+
language: string;
|
|
8
|
+
lineCount: number;
|
|
9
|
+
exports: string[];
|
|
10
|
+
imports: string[];
|
|
11
|
+
size: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ModuleEntry {
|
|
14
|
+
name: string;
|
|
15
|
+
files: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CodeMap {
|
|
19
|
+
projectRoot: string;
|
|
20
|
+
files: FileEntry[];
|
|
21
|
+
modules: ModuleEntry[];
|
|
22
|
+
generatedAt: string;
|
|
23
|
+
totalFiles: number;
|
|
24
|
+
totalLines: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generate a code map by scanning the project
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateCodeMap(cwd: string): CodeMap;
|
|
30
|
+
/**
|
|
31
|
+
* Save code map to disk
|
|
32
|
+
*/
|
|
33
|
+
export declare function saveCodeMap(cwd: string, map: CodeMap): void;
|
|
34
|
+
/**
|
|
35
|
+
* Load code map from disk
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadCodeMap(cwd: string): CodeMap | null;
|
|
38
|
+
/**
|
|
39
|
+
* Check if code map is stale (any source files modified since generation)
|
|
40
|
+
*/
|
|
41
|
+
export declare function isCodeMapStale(cwd: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Pretty-print the code map
|
|
44
|
+
*/
|
|
45
|
+
export declare function printCodeMap(map: CodeMap): void;
|
|
46
|
+
/**
|
|
47
|
+
* Build a code map context string for system prompt injection
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildCodemapContext(cwd: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Print code map generation status
|
|
52
|
+
*/
|
|
53
|
+
export declare function printCodemapStatus(cwd: string): void;
|