claude-mycelium 2.0.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/.claude/settings.local.json +14 -0
- package/README.md +304 -0
- package/dist/coordination/gradient-cache.d.ts +48 -0
- package/dist/coordination/gradient-cache.d.ts.map +1 -0
- package/dist/coordination/gradient-cache.js +145 -0
- package/dist/coordination/gradient-cache.js.map +1 -0
- package/dist/coordination/index.d.ts +10 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +10 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/core/agent-executor.d.ts +31 -0
- package/dist/core/agent-executor.d.ts.map +1 -0
- package/dist/core/agent-executor.js +257 -0
- package/dist/core/agent-executor.js.map +1 -0
- package/dist/core/change-applier.d.ts +10 -0
- package/dist/core/change-applier.d.ts.map +1 -0
- package/dist/core/change-applier.js +32 -0
- package/dist/core/change-applier.js.map +1 -0
- package/dist/core/gradient.d.ts +60 -0
- package/dist/core/gradient.d.ts.map +1 -0
- package/dist/core/gradient.js +191 -0
- package/dist/core/gradient.js.map +1 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +24 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/mode-selector.d.ts +44 -0
- package/dist/core/mode-selector.d.ts.map +1 -0
- package/dist/core/mode-selector.js +208 -0
- package/dist/core/mode-selector.js.map +1 -0
- package/dist/core/signals/centrality.d.ts +44 -0
- package/dist/core/signals/centrality.d.ts.map +1 -0
- package/dist/core/signals/centrality.js +264 -0
- package/dist/core/signals/centrality.js.map +1 -0
- package/dist/core/signals/churn.d.ts +41 -0
- package/dist/core/signals/churn.d.ts.map +1 -0
- package/dist/core/signals/churn.js +188 -0
- package/dist/core/signals/churn.js.map +1 -0
- package/dist/core/signals/complexity.d.ts +29 -0
- package/dist/core/signals/complexity.d.ts.map +1 -0
- package/dist/core/signals/complexity.js +169 -0
- package/dist/core/signals/complexity.js.map +1 -0
- package/dist/core/signals/debt.d.ts +27 -0
- package/dist/core/signals/debt.d.ts.map +1 -0
- package/dist/core/signals/debt.js +80 -0
- package/dist/core/signals/debt.js.map +1 -0
- package/dist/core/signals/errors.d.ts +32 -0
- package/dist/core/signals/errors.d.ts.map +1 -0
- package/dist/core/signals/errors.js +73 -0
- package/dist/core/signals/errors.js.map +1 -0
- package/dist/core/signals/index.d.ts +19 -0
- package/dist/core/signals/index.d.ts.map +1 -0
- package/dist/core/signals/index.js +19 -0
- package/dist/core/signals/index.js.map +1 -0
- package/dist/cost/cost-tracker.d.ts +90 -0
- package/dist/cost/cost-tracker.d.ts.map +1 -0
- package/dist/cost/cost-tracker.js +305 -0
- package/dist/cost/cost-tracker.js.map +1 -0
- package/dist/cost/index.d.ts +56 -0
- package/dist/cost/index.d.ts.map +1 -0
- package/dist/cost/index.js +111 -0
- package/dist/cost/index.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/anthropic-client.d.ts +52 -0
- package/dist/llm/anthropic-client.d.ts.map +1 -0
- package/dist/llm/anthropic-client.js +310 -0
- package/dist/llm/anthropic-client.js.map +1 -0
- package/dist/llm/index.d.ts +27 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +34 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/prompts/complexity-reducer.d.ts +7 -0
- package/dist/prompts/complexity-reducer.d.ts.map +1 -0
- package/dist/prompts/complexity-reducer.js +55 -0
- package/dist/prompts/complexity-reducer.js.map +1 -0
- package/dist/prompts/debt-payer.d.ts +7 -0
- package/dist/prompts/debt-payer.d.ts.map +1 -0
- package/dist/prompts/debt-payer.js +55 -0
- package/dist/prompts/debt-payer.js.map +1 -0
- package/dist/prompts/error-reducer.d.ts +7 -0
- package/dist/prompts/error-reducer.d.ts.map +1 -0
- package/dist/prompts/error-reducer.js +54 -0
- package/dist/prompts/error-reducer.js.map +1 -0
- package/dist/prompts/index.d.ts +22 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +112 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/stabilizer.d.ts +7 -0
- package/dist/prompts/stabilizer.d.ts.map +1 -0
- package/dist/prompts/stabilizer.js +55 -0
- package/dist/prompts/stabilizer.js.map +1 -0
- package/dist/prompts/types.d.ts +14 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +5 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/trace/index.d.ts +51 -0
- package/dist/trace/index.d.ts.map +1 -0
- package/dist/trace/index.js +60 -0
- package/dist/trace/index.js.map +1 -0
- package/dist/trace/trace-event.d.ts +72 -0
- package/dist/trace/trace-event.d.ts.map +1 -0
- package/dist/trace/trace-event.js +244 -0
- package/dist/trace/trace-event.js.map +1 -0
- package/dist/types/index.d.ts +206 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/ci-provider.d.ts +43 -0
- package/dist/utils/ci-provider.d.ts.map +1 -0
- package/dist/utils/ci-provider.js +130 -0
- package/dist/utils/ci-provider.js.map +1 -0
- package/dist/utils/config.d.ts +31 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +85 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/error-provider.d.ts +51 -0
- package/dist/utils/error-provider.d.ts.map +1 -0
- package/dist/utils/error-provider.js +123 -0
- package/dist/utils/error-provider.js.map +1 -0
- package/dist/utils/file-utils.d.ts +18 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +95 -0
- package/dist/utils/file-utils.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +36 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +74 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/IMPLEMENTATION-STATUS.md +199 -0
- package/docs/PHASE-0-COMPLETE.md +252 -0
- package/docs/PHASE-1-COMPLETE.md +204 -0
- package/docs/PHASE-2-COMPLETE.md +233 -0
- package/docs/PHASE2_COMPLETION_CHECKLIST.md +290 -0
- package/docs/PHASE2_INTEGRATION_SUMMARY.md +255 -0
- package/docs/PHASE2_QUICK_REFERENCE.md +365 -0
- package/docs/PHASE2_TEST_RESULTS.md +282 -0
- package/docs/ROADMAP.md +746 -0
- package/docs/SNAPSHOT.md +376 -0
- package/docs/adrs/ADR-001-signal-computation.md +76 -0
- package/docs/adrs/ADR-002-inhibitor-signals.md +108 -0
- package/docs/adrs/ADR-003-llm-integration.md +156 -0
- package/docs/adrs/ADR-004-process-architecture.md +175 -0
- package/docs/adrs/ADR-005-testing-strategy.md +243 -0
- package/docs/pitch.md +94 -0
- package/docs/specs/fourth-spec.md +1973 -0
- package/docs/specs/initial-spec.md +2096 -0
- package/docs/specs/second-spec.md +2690 -0
- package/package.json +50 -0
- package/src/coordination/gradient-cache.ts +185 -0
- package/src/coordination/index.ts +10 -0
- package/src/core/agent-executor.ts +327 -0
- package/src/core/change-applier.ts +338 -0
- package/src/core/gradient.ts +258 -0
- package/src/core/index.ts +24 -0
- package/src/core/mode-selector.ts +243 -0
- package/src/core/signals/centrality.ts +328 -0
- package/src/core/signals/churn.ts +239 -0
- package/src/core/signals/complexity.ts +206 -0
- package/src/core/signals/debt.ts +111 -0
- package/src/core/signals/errors.ts +93 -0
- package/src/core/signals/index.ts +19 -0
- package/src/cost/cost-tracker.ts +410 -0
- package/src/cost/index.ts +143 -0
- package/src/index.ts +43 -0
- package/src/llm/anthropic-client.ts +415 -0
- package/src/llm/index.ts +43 -0
- package/src/prompts/complexity-reducer.ts +59 -0
- package/src/prompts/debt-payer.ts +59 -0
- package/src/prompts/error-reducer.ts +58 -0
- package/src/prompts/index.ts +128 -0
- package/src/prompts/stabilizer.ts +59 -0
- package/src/prompts/types.ts +15 -0
- package/src/trace/README.md +178 -0
- package/src/trace/index.ts +88 -0
- package/src/trace/trace-event.ts +324 -0
- package/src/types/index.ts +271 -0
- package/src/utils/ci-provider.ts +145 -0
- package/src/utils/config.ts +95 -0
- package/src/utils/error-provider.ts +138 -0
- package/src/utils/file-utils.ts +111 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/logger.ts +94 -0
- package/test-8d713cc8-f4b7-403d-8153-57573172b94c.ts +3 -0
- package/tests/coordination/gradient-cache.test.ts +270 -0
- package/tests/core/agent-executor.test.ts +217 -0
- package/tests/core/change-applier.test.ts +336 -0
- package/tests/core/gradient.test.ts +263 -0
- package/tests/core/mode-selector.test.ts +239 -0
- package/tests/core/signals/centrality.test.ts +512 -0
- package/tests/core/signals/churn.test.ts +355 -0
- package/tests/core/signals/complexity.test.ts +284 -0
- package/tests/core/signals/debt.test.ts +437 -0
- package/tests/core/signals/errors.test.ts +350 -0
- package/tests/cost/cost-tracker.test.ts +475 -0
- package/tests/integration/phase2.test.ts +405 -0
- package/tests/llm/anthropic-client.test.ts +437 -0
- package/tests/prompts/prompts.test.ts +266 -0
- package/tests/trace/trace-event.test.ts +666 -0
- package/tests/utils/file-utils.test.ts +148 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +28 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Reducer Prompt
|
|
3
|
+
* Focus: Fix bugs and add error handling
|
|
4
|
+
*/
|
|
5
|
+
import { getModeInstructions } from '../core/mode-selector.js';
|
|
6
|
+
export function generatePrompt(context) {
|
|
7
|
+
const { file, content, gradient, rank, totalFiles } = context;
|
|
8
|
+
const { dominantSignal, signals, score } = gradient;
|
|
9
|
+
const rankInfo = rank && totalFiles
|
|
10
|
+
? `(ranked #${rank} of ${totalFiles})`
|
|
11
|
+
: '';
|
|
12
|
+
return `# Task
|
|
13
|
+
You are improving \`${file}\` in mode \`error_reducer\`.
|
|
14
|
+
|
|
15
|
+
## File Context
|
|
16
|
+
**Current gradient**: ${score.toFixed(3)} ${rankInfo}
|
|
17
|
+
**Dominant issue**: ${dominantSignal.name} = ${dominantSignal.value.toFixed(3)}
|
|
18
|
+
|
|
19
|
+
${getModeInstructions('error_reducer')}
|
|
20
|
+
|
|
21
|
+
## Current File Content
|
|
22
|
+
\`\`\`typescript
|
|
23
|
+
${content}
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
## Your Task
|
|
27
|
+
Fix bugs and improve error handling in this file:
|
|
28
|
+
|
|
29
|
+
1. Analyze the code for potential errors:
|
|
30
|
+
- Null/undefined access patterns
|
|
31
|
+
- Missing error handling
|
|
32
|
+
- Type errors or mismatches
|
|
33
|
+
- Edge cases and off-by-one errors
|
|
34
|
+
- Input validation issues
|
|
35
|
+
|
|
36
|
+
2. Make minimal, focused fixes:
|
|
37
|
+
- Add try/catch blocks where appropriate
|
|
38
|
+
- Add null checks before accessing properties
|
|
39
|
+
- Improve error messages
|
|
40
|
+
- Add input validation
|
|
41
|
+
|
|
42
|
+
3. Preserve existing functionality:
|
|
43
|
+
- Do NOT refactor for style
|
|
44
|
+
- Do NOT change the public API
|
|
45
|
+
- Do NOT add new features
|
|
46
|
+
|
|
47
|
+
**Important**:
|
|
48
|
+
- Make minimal, focused changes
|
|
49
|
+
- Preserve existing functionality
|
|
50
|
+
- Add tests if removing code
|
|
51
|
+
- Keep the same file structure
|
|
52
|
+
- Explain what you changed and why`;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=error-reducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-reducer.js","sourceRoot":"","sources":["../../src/prompts/error-reducer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,UAAU,cAAc,CAAC,OAAsB;IACnD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC9D,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;IAEpD,MAAM,QAAQ,GAAG,IAAI,IAAI,UAAU;QACjC,CAAC,CAAC,YAAY,IAAI,OAAO,UAAU,GAAG;QACtC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;sBACa,IAAI;;;wBAGF,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ;sBAC9B,cAAc,CAAC,IAAI,MAAM,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;;EAE5E,mBAAmB,CAAC,eAAe,CAAC;;;;EAIpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA6B0B,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Templates
|
|
3
|
+
* Per initial-spec §4.1
|
|
4
|
+
*
|
|
5
|
+
* Mode-specific prompts for guiding agents.
|
|
6
|
+
* Each prompt provides context and instructions for a specific improvement mode.
|
|
7
|
+
*/
|
|
8
|
+
import type { Mode, GradientScore } from '../types/index.js';
|
|
9
|
+
export { generatePrompt as generateErrorReducerPrompt } from './error-reducer.js';
|
|
10
|
+
export { generatePrompt as generateComplexityReducerPrompt } from './complexity-reducer.js';
|
|
11
|
+
export { generatePrompt as generateDebtPayerPrompt } from './debt-payer.js';
|
|
12
|
+
export { generatePrompt as generateStabilizerPrompt } from './stabilizer.js';
|
|
13
|
+
export type { PromptContext } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Build complete prompt for agent (system + user)
|
|
16
|
+
* Used by agent-executor
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildPrompt(file: string, mode: Mode, gradient: GradientScore): Promise<{
|
|
19
|
+
system: string;
|
|
20
|
+
user: string;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,cAAc,IAAI,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,cAAc,IAAI,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,cAAc,IAAI,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,cAAc,IAAI,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAkE3C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Templates
|
|
3
|
+
* Per initial-spec §4.1
|
|
4
|
+
*
|
|
5
|
+
* Mode-specific prompts for guiding agents.
|
|
6
|
+
* Each prompt provides context and instructions for a specific improvement mode.
|
|
7
|
+
*/
|
|
8
|
+
import { readFile } from 'fs/promises';
|
|
9
|
+
export { generatePrompt as generateErrorReducerPrompt } from './error-reducer.js';
|
|
10
|
+
export { generatePrompt as generateComplexityReducerPrompt } from './complexity-reducer.js';
|
|
11
|
+
export { generatePrompt as generateDebtPayerPrompt } from './debt-payer.js';
|
|
12
|
+
export { generatePrompt as generateStabilizerPrompt } from './stabilizer.js';
|
|
13
|
+
/**
|
|
14
|
+
* Build complete prompt for agent (system + user)
|
|
15
|
+
* Used by agent-executor
|
|
16
|
+
*/
|
|
17
|
+
export async function buildPrompt(file, mode, gradient) {
|
|
18
|
+
// Read file content
|
|
19
|
+
const content = await readFile(file, 'utf-8');
|
|
20
|
+
// Build context
|
|
21
|
+
const context = {
|
|
22
|
+
file,
|
|
23
|
+
content,
|
|
24
|
+
gradient,
|
|
25
|
+
mode,
|
|
26
|
+
};
|
|
27
|
+
// Generate mode-specific prompt
|
|
28
|
+
let userPrompt;
|
|
29
|
+
switch (mode) {
|
|
30
|
+
case 'error_reducer': {
|
|
31
|
+
const { generatePrompt } = await import('./error-reducer.js');
|
|
32
|
+
userPrompt = generatePrompt(context);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case 'complexity_reducer': {
|
|
36
|
+
const { generatePrompt } = await import('./complexity-reducer.js');
|
|
37
|
+
userPrompt = generatePrompt(context);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'debt_payer': {
|
|
41
|
+
const { generatePrompt } = await import('./debt-payer.js');
|
|
42
|
+
userPrompt = generatePrompt(context);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'stabilizer': {
|
|
46
|
+
const { generatePrompt } = await import('./stabilizer.js');
|
|
47
|
+
userPrompt = generatePrompt(context);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case 'explorer': {
|
|
51
|
+
// Explorer mode - use generic improvement prompt
|
|
52
|
+
userPrompt = buildExplorerPrompt(context);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Unknown mode: ${mode}`);
|
|
57
|
+
}
|
|
58
|
+
// System prompt is common across all modes
|
|
59
|
+
const systemPrompt = `You are a code improvement agent. Your task is to analyze and improve code files.
|
|
60
|
+
|
|
61
|
+
CRITICAL OUTPUT FORMAT:
|
|
62
|
+
1. Brief analysis (2-3 sentences)
|
|
63
|
+
2. Complete modified file in code fence:
|
|
64
|
+
|
|
65
|
+
\`\`\`typescript
|
|
66
|
+
// complete modified code here
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
RULES:
|
|
70
|
+
- Output COMPLETE file, not just changes
|
|
71
|
+
- Make MINIMAL changes for your mode's focus
|
|
72
|
+
- PRESERVE all existing functionality
|
|
73
|
+
- Do NOT add comments explaining changes
|
|
74
|
+
- Do NOT introduce new dependencies`;
|
|
75
|
+
return {
|
|
76
|
+
system: systemPrompt,
|
|
77
|
+
user: userPrompt,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build explorer mode prompt
|
|
82
|
+
*/
|
|
83
|
+
function buildExplorerPrompt(context) {
|
|
84
|
+
const { file, content, gradient } = context;
|
|
85
|
+
return `# Task
|
|
86
|
+
You are exploring \`${file}\` to find novel improvement opportunities.
|
|
87
|
+
|
|
88
|
+
## File Context
|
|
89
|
+
**Gradient**: ${gradient.score.toFixed(3)}
|
|
90
|
+
**Dominant issue**: ${gradient.dominantSignal.name} = ${gradient.dominantSignal.value.toFixed(3)}
|
|
91
|
+
|
|
92
|
+
## Explorer Mode Instructions
|
|
93
|
+
This file has resisted conventional improvements. You have permission to:
|
|
94
|
+
- Challenge fundamental assumptions
|
|
95
|
+
- Suggest structural changes (within limits)
|
|
96
|
+
- Try unconventional approaches
|
|
97
|
+
|
|
98
|
+
**Constraints**:
|
|
99
|
+
- Maximum 50 lines changed
|
|
100
|
+
- Cannot change public API signatures
|
|
101
|
+
- Cannot remove validation logic
|
|
102
|
+
- Changes will be flagged for human review
|
|
103
|
+
|
|
104
|
+
## Current File Content
|
|
105
|
+
\`\`\`typescript
|
|
106
|
+
${content}
|
|
107
|
+
\`\`\`
|
|
108
|
+
|
|
109
|
+
## Your Task
|
|
110
|
+
Explore creative improvements to this file while respecting the constraints.`;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","s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|
+
/**
|
|
2
|
+
* Stabilizer Prompt
|
|
3
|
+
* Focus: Reduce churn with tests and documentation
|
|
4
|
+
*/
|
|
5
|
+
import { getModeInstructions } from '../core/mode-selector.js';
|
|
6
|
+
export function generatePrompt(context) {
|
|
7
|
+
const { file, content, gradient, rank, totalFiles } = context;
|
|
8
|
+
const { dominantSignal, signals, score } = gradient;
|
|
9
|
+
const rankInfo = rank && totalFiles
|
|
10
|
+
? `(ranked #${rank} of ${totalFiles})`
|
|
11
|
+
: '';
|
|
12
|
+
return `# Task
|
|
13
|
+
You are improving \`${file}\` in mode \`stabilizer\`.
|
|
14
|
+
|
|
15
|
+
## File Context
|
|
16
|
+
**Current gradient**: ${score.toFixed(3)} ${rankInfo}
|
|
17
|
+
**Dominant issue**: ${dominantSignal.name} = ${dominantSignal.value.toFixed(3)}
|
|
18
|
+
|
|
19
|
+
${getModeInstructions('stabilizer')}
|
|
20
|
+
|
|
21
|
+
## Current File Content
|
|
22
|
+
\`\`\`typescript
|
|
23
|
+
${content}
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
## Your Task
|
|
27
|
+
Improve stability to reduce future changes:
|
|
28
|
+
|
|
29
|
+
1. Identify stability issues:
|
|
30
|
+
- Missing tests
|
|
31
|
+
- Unclear behavior that requires frequent changes
|
|
32
|
+
- Weak interfaces that allow misuse
|
|
33
|
+
- Magic numbers without constants
|
|
34
|
+
- Poor encapsulation
|
|
35
|
+
|
|
36
|
+
2. Make stability improvements:
|
|
37
|
+
- Add unit tests for untested code
|
|
38
|
+
- Document unclear behavior
|
|
39
|
+
- Improve interfaces to prevent misuse
|
|
40
|
+
- Extract constants from magic numbers
|
|
41
|
+
- Improve encapsulation
|
|
42
|
+
|
|
43
|
+
3. Avoid major changes:
|
|
44
|
+
- Do NOT refactor internals (use complexity_reducer for that)
|
|
45
|
+
- Do NOT change public APIs without good reason
|
|
46
|
+
- Do NOT remove existing tests
|
|
47
|
+
|
|
48
|
+
**Important**:
|
|
49
|
+
- Make minimal, focused changes
|
|
50
|
+
- Preserve existing functionality
|
|
51
|
+
- Add tests if removing code
|
|
52
|
+
- Keep the same file structure
|
|
53
|
+
- Explain what you changed and why`;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=stabilizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stabilizer.js","sourceRoot":"","sources":["../../src/prompts/stabilizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,UAAU,cAAc,CAAC,OAAsB;IACnD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC9D,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;IAEpD,MAAM,QAAQ,GAAG,IAAI,IAAI,UAAU;QACjC,CAAC,CAAC,YAAY,IAAI,OAAO,UAAU,GAAG;QACtC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;sBACa,IAAI;;;wBAGF,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ;sBAC9B,cAAc,CAAC,IAAI,MAAM,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;;EAE5E,mBAAmB,CAAC,YAAY,CAAC;;;;EAIjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA8B0B,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Template Types
|
|
3
|
+
*/
|
|
4
|
+
import type { Mode } from '../types/index.js';
|
|
5
|
+
import type { GradientScore } from '../core/gradient.js';
|
|
6
|
+
export interface PromptContext {
|
|
7
|
+
file: string;
|
|
8
|
+
content: string;
|
|
9
|
+
gradient: GradientScore;
|
|
10
|
+
mode: Mode;
|
|
11
|
+
rank?: number;
|
|
12
|
+
totalFiles?: number;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace Module - Event Tracking System
|
|
3
|
+
*
|
|
4
|
+
* Per Phase 2 specification, this tracks:
|
|
5
|
+
* - Agent execution traces with timing
|
|
6
|
+
* - File changes (additions, deletions, modifications)
|
|
7
|
+
* - Gradient measurements (before/after)
|
|
8
|
+
* - Cost metrics (tokens, USD)
|
|
9
|
+
* - CI pass/fail status
|
|
10
|
+
*
|
|
11
|
+
* Traces are stored as JSON Lines format for efficient querying.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { recordTraceEvent } from './trace/index.js';
|
|
16
|
+
* await recordTraceEvent({ ... });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import type { TraceEvent, ChangeSet } from '../types/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* Create a trace event for an agent execution
|
|
22
|
+
*/
|
|
23
|
+
export declare function createTraceEvent(data: {
|
|
24
|
+
filePath: string;
|
|
25
|
+
mode: string;
|
|
26
|
+
gradientBefore: number;
|
|
27
|
+
gradientAfter: number;
|
|
28
|
+
metabolicCost: number;
|
|
29
|
+
efficiency: number;
|
|
30
|
+
ciPassed: boolean;
|
|
31
|
+
changes: ChangeSet;
|
|
32
|
+
costRecord: {
|
|
33
|
+
tokens_in: number;
|
|
34
|
+
tokens_out: number;
|
|
35
|
+
model: string;
|
|
36
|
+
estimated_usd: number;
|
|
37
|
+
};
|
|
38
|
+
notes?: string[];
|
|
39
|
+
taskId?: string;
|
|
40
|
+
agentId?: string;
|
|
41
|
+
}): TraceEvent;
|
|
42
|
+
/**
|
|
43
|
+
* Record a trace event to the trace log
|
|
44
|
+
* In Phase 2, we store this in memory; in Phase 3+ it goes to persistent storage
|
|
45
|
+
*/
|
|
46
|
+
export declare function recordTraceEvent(event: TraceEvent): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Export trace event type and utilities for Phase 2 integration
|
|
49
|
+
*/
|
|
50
|
+
export type { TraceEvent, ChangeSet } from '../types/index.js';
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trace/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;IACnB,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,UAAU,CAoBb;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvE;AAED;;GAEG;AACH,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace Module - Event Tracking System
|
|
3
|
+
*
|
|
4
|
+
* Per Phase 2 specification, this tracks:
|
|
5
|
+
* - Agent execution traces with timing
|
|
6
|
+
* - File changes (additions, deletions, modifications)
|
|
7
|
+
* - Gradient measurements (before/after)
|
|
8
|
+
* - Cost metrics (tokens, USD)
|
|
9
|
+
* - CI pass/fail status
|
|
10
|
+
*
|
|
11
|
+
* Traces are stored as JSON Lines format for efficient querying.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { recordTraceEvent } from './trace/index.js';
|
|
16
|
+
* await recordTraceEvent({ ... });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
20
|
+
import { logDebug } from '../utils/logger.js';
|
|
21
|
+
/**
|
|
22
|
+
* Create a trace event for an agent execution
|
|
23
|
+
*/
|
|
24
|
+
export function createTraceEvent(data) {
|
|
25
|
+
const now = new Date().toISOString();
|
|
26
|
+
return {
|
|
27
|
+
id: uuidv4(),
|
|
28
|
+
timestamp: now,
|
|
29
|
+
file_path: data.filePath,
|
|
30
|
+
mode: data.mode,
|
|
31
|
+
gradient_before: data.gradientBefore,
|
|
32
|
+
gradient_after: data.gradientAfter,
|
|
33
|
+
gradient_delta: data.gradientAfter - data.gradientBefore,
|
|
34
|
+
metabolic_cost: data.metabolicCost,
|
|
35
|
+
efficiency: data.efficiency,
|
|
36
|
+
ci_passed: data.ciPassed,
|
|
37
|
+
changes: data.changes,
|
|
38
|
+
notes: data.notes || [],
|
|
39
|
+
task_id: data.taskId,
|
|
40
|
+
agent_id: data.agentId,
|
|
41
|
+
cost: data.costRecord,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Record a trace event to the trace log
|
|
46
|
+
* In Phase 2, we store this in memory; in Phase 3+ it goes to persistent storage
|
|
47
|
+
*/
|
|
48
|
+
export async function recordTraceEvent(event) {
|
|
49
|
+
logDebug('Trace event recorded', {
|
|
50
|
+
event_id: event.id,
|
|
51
|
+
file: event.file_path,
|
|
52
|
+
mode: event.mode,
|
|
53
|
+
gradient_delta: event.gradient_delta.toFixed(3),
|
|
54
|
+
cost_usd: event.cost.estimated_usd.toFixed(4),
|
|
55
|
+
});
|
|
56
|
+
// In Phase 2, trace events are collected in memory
|
|
57
|
+
// In Phase 3+, they will be written to persistent storage (JSON Lines format)
|
|
58
|
+
// For now, this is a no-op that validates the event structure
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/trace/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAkBhC;IACC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAErC,OAAO;QACL,EAAE,EAAE,MAAM,EAAE;QACZ,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,IAAI,CAAC,QAAQ;QACxB,IAAI,EAAE,IAAI,CAAC,IAAW;QACtB,eAAe,EAAE,IAAI,CAAC,cAAc;QACpC,cAAc,EAAE,IAAI,CAAC,aAAa;QAClC,cAAc,EAAE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,cAAc;QACxD,cAAc,EAAE,IAAI,CAAC,aAAa;QAClC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,QAAQ;QACxB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;QACvB,OAAO,EAAE,IAAI,CAAC,MAAM;QACpB,QAAQ,EAAE,IAAI,CAAC,OAAO;QACtB,IAAI,EAAE,IAAI,CAAC,UAAU;KACtB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAiB;IACtD,QAAQ,CAAC,sBAAsB,EAAE;QAC/B,QAAQ,EAAE,KAAK,CAAC,EAAE;QAClB,IAAI,EAAE,KAAK,CAAC,SAAS;QACrB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9C,CAAC,CAAC;IAEH,mDAAmD;IACnD,8EAA8E;IAC9E,8DAA8D;AAChE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace Event System for Claude-Mycelium
|
|
3
|
+
* Records agent actions for learning and analysis
|
|
4
|
+
* Storage: .agent-meta/traces.jsonl (JSON Lines format)
|
|
5
|
+
*/
|
|
6
|
+
export type Mode = 'error_reducer' | 'complexity_reducer' | 'debt_payer' | 'stabilizer' | 'explorer';
|
|
7
|
+
export interface TraceEvent {
|
|
8
|
+
id: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
agent_id: string;
|
|
11
|
+
file_path: string;
|
|
12
|
+
mode: Mode;
|
|
13
|
+
gradient_before: number;
|
|
14
|
+
gradient_after: number;
|
|
15
|
+
gradient_delta: number;
|
|
16
|
+
changes_made: string[];
|
|
17
|
+
tokens_used: number;
|
|
18
|
+
cost_usd: number;
|
|
19
|
+
duration_ms: number;
|
|
20
|
+
success: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TraceFilters {
|
|
24
|
+
file?: string;
|
|
25
|
+
mode?: Mode;
|
|
26
|
+
since?: Date;
|
|
27
|
+
limit?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TraceStats {
|
|
30
|
+
totalCost: number;
|
|
31
|
+
avgDelta: number;
|
|
32
|
+
successRate: number;
|
|
33
|
+
totalTraces: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Record a trace event to the append-only log
|
|
37
|
+
*/
|
|
38
|
+
export declare function recordTrace(event: TraceEvent): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Read traces with optional filters
|
|
41
|
+
* Returns traces sorted by timestamp (newest first)
|
|
42
|
+
*/
|
|
43
|
+
export declare function readTraces(filters?: TraceFilters): Promise<TraceEvent[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate recent efficiency for a file
|
|
46
|
+
* Efficiency = gradient improvement per dollar spent
|
|
47
|
+
* Returns null if insufficient data
|
|
48
|
+
*/
|
|
49
|
+
export declare function getRecentEfficiency(file: string, lastN?: number): Promise<number | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate efficiency from traces
|
|
52
|
+
* Efficiency = sum(gradient_delta) / sum(cost_usd)
|
|
53
|
+
*/
|
|
54
|
+
export declare function calculateEfficiency(traces: TraceEvent[]): number;
|
|
55
|
+
/**
|
|
56
|
+
* Get statistics from traces
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTraceStats(traces: TraceEvent[]): TraceStats;
|
|
59
|
+
/**
|
|
60
|
+
* Generate a unique trace ID
|
|
61
|
+
*/
|
|
62
|
+
export declare function generateTraceId(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Calculate cost from token usage
|
|
65
|
+
* Based on model pricing (Claude Sonnet 4)
|
|
66
|
+
*/
|
|
67
|
+
export declare function calculateCost(tokensIn: number, tokensOut: number, model?: string): number;
|
|
68
|
+
/**
|
|
69
|
+
* Create a trace event with defaults
|
|
70
|
+
*/
|
|
71
|
+
export declare function createTraceEvent(partial: Omit<TraceEvent, 'id' | 'timestamp' | 'gradient_delta'>): TraceEvent;
|
|
72
|
+
//# sourceMappingURL=trace-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-event.d.ts","sourceRoot":"","sources":["../../src/trace/trace-event.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,MAAM,IAAI,GAAG,eAAe,GAAG,oBAAoB,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,CAAC;AAErG,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;I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