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,31 @@
|
|
|
1
|
+
import type { SystemConfig } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration per spec §13
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CONFIG: SystemConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Load configuration from .agent-meta/config.json
|
|
8
|
+
* Creates default config if file doesn't exist
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadConfig(): SystemConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Save configuration to .agent-meta/config.json
|
|
13
|
+
*/
|
|
14
|
+
export declare function saveConfig(config: SystemConfig): void;
|
|
15
|
+
/**
|
|
16
|
+
* Update specific config fields
|
|
17
|
+
*/
|
|
18
|
+
export declare function updateConfig(updates: Partial<SystemConfig>): SystemConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Increment spawn counter and check if GC should run
|
|
21
|
+
* GC runs every 100 spawns (per spec §8)
|
|
22
|
+
*/
|
|
23
|
+
export declare function incrementSpawnCount(): {
|
|
24
|
+
count: number;
|
|
25
|
+
shouldRunGC: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Mark that GC has been run
|
|
29
|
+
*/
|
|
30
|
+
export declare function markGCRun(): void;
|
|
31
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,YAQ5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,UAAU,IAAI,YAAY,CAoBzC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAOrD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAQzE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAY7E;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAIhC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { fileExists, readJsonFile, writeJsonFile } from './file-utils.js';
|
|
2
|
+
const CONFIG_PATH = '.agent-meta/config.json';
|
|
3
|
+
/**
|
|
4
|
+
* Default configuration per spec §13
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_CONFIG = {
|
|
7
|
+
version: '2.0.0',
|
|
8
|
+
created_at: new Date().toISOString(),
|
|
9
|
+
error_provider: 'file',
|
|
10
|
+
error_file: '.agent-meta/_errors.json',
|
|
11
|
+
ci_command: 'npm test && npm run lint',
|
|
12
|
+
spawn_count: 0,
|
|
13
|
+
last_gc_at_spawn: 0,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Load configuration from .agent-meta/config.json
|
|
17
|
+
* Creates default config if file doesn't exist
|
|
18
|
+
*/
|
|
19
|
+
export function loadConfig() {
|
|
20
|
+
if (!fileExists(CONFIG_PATH)) {
|
|
21
|
+
// Initialize with defaults
|
|
22
|
+
writeJsonFile(CONFIG_PATH, DEFAULT_CONFIG);
|
|
23
|
+
return DEFAULT_CONFIG;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const config = readJsonFile(CONFIG_PATH);
|
|
27
|
+
// Merge with defaults to handle missing fields
|
|
28
|
+
return {
|
|
29
|
+
...DEFAULT_CONFIG,
|
|
30
|
+
...config,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error(`Failed to load config from ${CONFIG_PATH}:`, error);
|
|
35
|
+
console.error('Using default configuration');
|
|
36
|
+
return DEFAULT_CONFIG;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Save configuration to .agent-meta/config.json
|
|
41
|
+
*/
|
|
42
|
+
export function saveConfig(config) {
|
|
43
|
+
try {
|
|
44
|
+
writeJsonFile(CONFIG_PATH, config);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error(`Failed to save config to ${CONFIG_PATH}:`, error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Update specific config fields
|
|
53
|
+
*/
|
|
54
|
+
export function updateConfig(updates) {
|
|
55
|
+
const config = loadConfig();
|
|
56
|
+
const updated = {
|
|
57
|
+
...config,
|
|
58
|
+
...updates,
|
|
59
|
+
};
|
|
60
|
+
saveConfig(updated);
|
|
61
|
+
return updated;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Increment spawn counter and check if GC should run
|
|
65
|
+
* GC runs every 100 spawns (per spec §8)
|
|
66
|
+
*/
|
|
67
|
+
export function incrementSpawnCount() {
|
|
68
|
+
const config = loadConfig();
|
|
69
|
+
config.spawn_count += 1;
|
|
70
|
+
const shouldRunGC = config.spawn_count - config.last_gc_at_spawn >= 100;
|
|
71
|
+
saveConfig(config);
|
|
72
|
+
return {
|
|
73
|
+
count: config.spawn_count,
|
|
74
|
+
shouldRunGC,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Mark that GC has been run
|
|
79
|
+
*/
|
|
80
|
+
export function markGCRun() {
|
|
81
|
+
const config = loadConfig();
|
|
82
|
+
config.last_gc_at_spawn = config.spawn_count;
|
|
83
|
+
saveConfig(config);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG1E,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IACpC,cAAc,EAAE,MAAM;IACtB,UAAU,EAAE,0BAA0B;IACtC,UAAU,EAAE,0BAA0B;IACtC,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,E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OAAO;QACL,KAAK,EAAE,MAAM,CAAC,WAAW;QACzB,WAAW;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC;IAC7C,UAAU,CAAC,MAAM,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ErrorProvider, ErrorProviderData } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* File-based error provider implementation
|
|
4
|
+
* Per spec §2.5 (second-spec.md lines 665-705)
|
|
5
|
+
*
|
|
6
|
+
* Users populate .agent-meta/_errors.json manually or via external tools
|
|
7
|
+
* Format:
|
|
8
|
+
* {
|
|
9
|
+
* "updated_at": "2026-01-30T17:00:00Z",
|
|
10
|
+
* "errors": [
|
|
11
|
+
* {
|
|
12
|
+
* "file": "src/auth.ts",
|
|
13
|
+
* "count": 6,
|
|
14
|
+
* "types": ["TypeError", "ReferenceError"]
|
|
15
|
+
* }
|
|
16
|
+
* ]
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export declare class FileErrorProvider implements ErrorProvider {
|
|
20
|
+
private errorFilePath;
|
|
21
|
+
constructor(errorFilePath?: string);
|
|
22
|
+
/**
|
|
23
|
+
* Get error count and types for a specific file
|
|
24
|
+
*/
|
|
25
|
+
getErrors(file: string): Promise<{
|
|
26
|
+
count: number;
|
|
27
|
+
types: string[];
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Initialize error file with empty data
|
|
31
|
+
*/
|
|
32
|
+
initializeErrorFile(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Update errors for a specific file
|
|
35
|
+
* Helper for manual error tracking
|
|
36
|
+
*/
|
|
37
|
+
updateErrors(file: string, count: number, types: string[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Clear all error data
|
|
40
|
+
*/
|
|
41
|
+
clearErrors(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get all errors (for reporting)
|
|
44
|
+
*/
|
|
45
|
+
getAllErrors(): ErrorProviderData['errors'];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Default error provider instance
|
|
49
|
+
*/
|
|
50
|
+
export declare const errorProvider: FileErrorProvider;
|
|
51
|
+
//# sourceMappingURL=error-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-provider.d.ts","sourceRoot":"","sources":["../../src/utils/error-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAK1E;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,aAAa,CAAS;gBAElB,aAAa,GAAE,MAAwB;IAInD;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IA2B1E;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAU3B;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IA0BhE;;OAEG;IACH,WAAW,IAAI,IAAI;IAQnB;;OAEG;IACH,YAAY,IAAI,iBAAiB,CAAC,QAAQ,CAAC;CAe5C;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,mBAA0B,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { fileExists, readJsonFile, writeJsonFile } from './file-utils.js';
|
|
2
|
+
import { logWarn } from './logger.js';
|
|
3
|
+
const ERROR_FILE_PATH = '.agent-meta/_errors.json';
|
|
4
|
+
/**
|
|
5
|
+
* File-based error provider implementation
|
|
6
|
+
* Per spec §2.5 (second-spec.md lines 665-705)
|
|
7
|
+
*
|
|
8
|
+
* Users populate .agent-meta/_errors.json manually or via external tools
|
|
9
|
+
* Format:
|
|
10
|
+
* {
|
|
11
|
+
* "updated_at": "2026-01-30T17:00:00Z",
|
|
12
|
+
* "errors": [
|
|
13
|
+
* {
|
|
14
|
+
* "file": "src/auth.ts",
|
|
15
|
+
* "count": 6,
|
|
16
|
+
* "types": ["TypeError", "ReferenceError"]
|
|
17
|
+
* }
|
|
18
|
+
* ]
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export class FileErrorProvider {
|
|
22
|
+
errorFilePath;
|
|
23
|
+
constructor(errorFilePath = ERROR_FILE_PATH) {
|
|
24
|
+
this.errorFilePath = errorFilePath;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get error count and types for a specific file
|
|
28
|
+
*/
|
|
29
|
+
async getErrors(file) {
|
|
30
|
+
if (!fileExists(this.errorFilePath)) {
|
|
31
|
+
// No error file exists - return zero errors
|
|
32
|
+
return { count: 0, types: [] };
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const data = readJsonFile(this.errorFilePath);
|
|
36
|
+
const entry = data.errors.find((e) => e.file === file);
|
|
37
|
+
if (!entry) {
|
|
38
|
+
return { count: 0, types: [] };
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
count: entry.count,
|
|
42
|
+
types: entry.types,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logWarn(`Failed to read error file: ${this.errorFilePath}`, {
|
|
47
|
+
error: error instanceof Error ? error.message : String(error),
|
|
48
|
+
});
|
|
49
|
+
return { count: 0, types: [] };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Initialize error file with empty data
|
|
54
|
+
*/
|
|
55
|
+
initializeErrorFile() {
|
|
56
|
+
if (!fileExists(this.errorFilePath)) {
|
|
57
|
+
const initialData = {
|
|
58
|
+
updated_at: new Date().toISOString(),
|
|
59
|
+
errors: [],
|
|
60
|
+
};
|
|
61
|
+
writeJsonFile(this.errorFilePath, initialData);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Update errors for a specific file
|
|
66
|
+
* Helper for manual error tracking
|
|
67
|
+
*/
|
|
68
|
+
updateErrors(file, count, types) {
|
|
69
|
+
let data;
|
|
70
|
+
if (fileExists(this.errorFilePath)) {
|
|
71
|
+
data = readJsonFile(this.errorFilePath);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
data = {
|
|
75
|
+
updated_at: new Date().toISOString(),
|
|
76
|
+
errors: [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Update or add entry
|
|
80
|
+
const existingIndex = data.errors.findIndex((e) => e.file === file);
|
|
81
|
+
if (existingIndex >= 0) {
|
|
82
|
+
data.errors[existingIndex] = { file, count, types };
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
data.errors.push({ file, count, types });
|
|
86
|
+
}
|
|
87
|
+
data.updated_at = new Date().toISOString();
|
|
88
|
+
writeJsonFile(this.errorFilePath, data);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Clear all error data
|
|
92
|
+
*/
|
|
93
|
+
clearErrors() {
|
|
94
|
+
const data = {
|
|
95
|
+
updated_at: new Date().toISOString(),
|
|
96
|
+
errors: [],
|
|
97
|
+
};
|
|
98
|
+
writeJsonFile(this.errorFilePath, data);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get all errors (for reporting)
|
|
102
|
+
*/
|
|
103
|
+
getAllErrors() {
|
|
104
|
+
if (!fileExists(this.errorFilePath)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const data = readJsonFile(this.errorFilePath);
|
|
109
|
+
return data.errors;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
logWarn(`Failed to read error file: ${this.errorFilePath}`, {
|
|
113
|
+
error: error instanceof Error ? error.message : String(error),
|
|
114
|
+
});
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Default error provider instance
|
|
121
|
+
*/
|
|
122
|
+
export const errorProvider = new FileErrorProvider();
|
|
123
|
+
//# sourceMappingURL=error-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-provider.js","sourceRoot":"","sources":["../../src/utils/error-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,iBAAiB;IACpB,aAAa,CAAS;IAE9B,YAAY,gBAAwB,eAAe;QACjD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,IAAY;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YACpC,4CAA4C;YAC5C,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QACjC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,YAAY,CAAoB,IAAI,CAAC,aAAa,CAAC,CAAC;YAEjE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YAEvD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;YAC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 +1,18 @@
|
|
|
1
|
+
export declare function pathToSafeFilename(filePath: string): string;
|
|
2
|
+
export declare function safeFilenameToPath(safeFilename: string): string;
|
|
3
|
+
export declare function fileExists(filePath: string): boolean;
|
|
4
|
+
export declare function readFile(filePath: string): string;
|
|
5
|
+
export declare function writeFile(filePath: string, content: string): void;
|
|
6
|
+
export declare function appendFile(filePath: string, content: string): void;
|
|
7
|
+
export declare function readJsonFile<T>(filePath: string): T;
|
|
8
|
+
export declare function writeJsonFile<T>(filePath: string, data: T, indent?: number): void;
|
|
9
|
+
export declare function listFilesRecursive(dirPath: string): string[];
|
|
10
|
+
export declare function getLineCount(filePath: string): number;
|
|
11
|
+
export declare function isTypeScriptFile(filePath: string): boolean;
|
|
12
|
+
export declare function isTestFile(filePath: string): boolean;
|
|
13
|
+
export declare function ensureDir(dirPath: string): void;
|
|
14
|
+
export declare function deleteFile(filePath: string): void;
|
|
15
|
+
export declare function copyFile(sourcePath: string, destPath: string): void;
|
|
16
|
+
export declare function getFileModTime(filePath: string): number;
|
|
17
|
+
export declare function getFileSize(filePath: string): number;
|
|
18
|
+
//# sourceMappingURL=file-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMjE;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMlE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAGnD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI,CAGpF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAiB5D;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAI/C;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAMnE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGpD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export function pathToSafeFilename(filePath) {
|
|
4
|
+
return filePath.replace(/[/\\]+/g, '__');
|
|
5
|
+
}
|
|
6
|
+
export function safeFilenameToPath(safeFilename) {
|
|
7
|
+
return safeFilename.replace(/__/g, '/');
|
|
8
|
+
}
|
|
9
|
+
export function fileExists(filePath) {
|
|
10
|
+
try {
|
|
11
|
+
fs.accessSync(filePath, fs.constants.F_OK);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function readFile(filePath) {
|
|
19
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
20
|
+
}
|
|
21
|
+
export function writeFile(filePath, content) {
|
|
22
|
+
const dir = path.dirname(filePath);
|
|
23
|
+
if (!fs.existsSync(dir)) {
|
|
24
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
27
|
+
}
|
|
28
|
+
export function appendFile(filePath, content) {
|
|
29
|
+
const dir = path.dirname(filePath);
|
|
30
|
+
if (!fs.existsSync(dir)) {
|
|
31
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
fs.appendFileSync(filePath, content, 'utf-8');
|
|
34
|
+
}
|
|
35
|
+
export function readJsonFile(filePath) {
|
|
36
|
+
const content = readFile(filePath);
|
|
37
|
+
return JSON.parse(content);
|
|
38
|
+
}
|
|
39
|
+
export function writeJsonFile(filePath, data, indent = 2) {
|
|
40
|
+
const content = JSON.stringify(data, null, indent);
|
|
41
|
+
writeFile(filePath, content);
|
|
42
|
+
}
|
|
43
|
+
export function listFilesRecursive(dirPath) {
|
|
44
|
+
const files = [];
|
|
45
|
+
function traverse(currentPath) {
|
|
46
|
+
const entries = fs.readdirSync(currentPath, { withFileTypes: true });
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const fullPath = path.join(currentPath, entry.name);
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
traverse(fullPath);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
files.push(fullPath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
traverse(dirPath);
|
|
58
|
+
return files;
|
|
59
|
+
}
|
|
60
|
+
export function getLineCount(filePath) {
|
|
61
|
+
const content = readFile(filePath);
|
|
62
|
+
return content.split('\n').length;
|
|
63
|
+
}
|
|
64
|
+
export function isTypeScriptFile(filePath) {
|
|
65
|
+
return /\.ts$/.test(filePath) && !/\.d\.ts$/.test(filePath);
|
|
66
|
+
}
|
|
67
|
+
export function isTestFile(filePath) {
|
|
68
|
+
return /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filePath);
|
|
69
|
+
}
|
|
70
|
+
export function ensureDir(dirPath) {
|
|
71
|
+
if (!fs.existsSync(dirPath)) {
|
|
72
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function deleteFile(filePath) {
|
|
76
|
+
if (fileExists(filePath)) {
|
|
77
|
+
fs.unlinkSync(filePath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function copyFile(sourcePath, destPath) {
|
|
81
|
+
const dir = path.dirname(destPath);
|
|
82
|
+
if (!fs.existsSync(dir)) {
|
|
83
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
86
|
+
}
|
|
87
|
+
export function getFileModTime(filePath) {
|
|
88
|
+
const stats = fs.statSync(filePath);
|
|
89
|
+
return stats.mtimeMs;
|
|
90
|
+
}
|
|
91
|
+
export function getFileSize(filePath) {
|
|
92
|
+
const stats = fs.statSync(filePath);
|
|
93
|
+
return stats.size;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=file-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACrD,OAAO,YAA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
|
+
* Centralized exports for cleaner imports
|
|
4
|
+
*/
|
|
5
|
+
export * from './file-utils.js';
|
|
6
|
+
export * from './config.js';
|
|
7
|
+
export * from './logger.js';
|
|
8
|
+
export * from './error-provider.js';
|
|
9
|
+
export * from './ci-provider.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for Claude-Mycelium
|
|
3
|
+
* Centralized exports for cleaner imports
|
|
4
|
+
*/
|
|
5
|
+
export * from './file-utils.js';
|
|
6
|
+
export * from './config.js';
|
|
7
|
+
export * from './logger.js';
|
|
8
|
+
export * from './error-provider.js';
|
|
9
|
+
export * from './ci-provider.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging utility for Claude-Mycelium
|
|
3
|
+
* Simple console-based logging with timestamp and context
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
6
|
+
interface LogContext {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Log debug message (lowest priority)
|
|
11
|
+
*/
|
|
12
|
+
export declare function logDebug(message: string, context?: LogContext): void;
|
|
13
|
+
/**
|
|
14
|
+
* Log info message (normal priority)
|
|
15
|
+
*/
|
|
16
|
+
export declare function logInfo(message: string, context?: LogContext): void;
|
|
17
|
+
/**
|
|
18
|
+
* Log warning message (high priority)
|
|
19
|
+
*/
|
|
20
|
+
export declare function logWarn(message: string, context?: LogContext): void;
|
|
21
|
+
/**
|
|
22
|
+
* Log error message (highest priority)
|
|
23
|
+
*/
|
|
24
|
+
export declare function logError(message: string, error?: Error, context?: LogContext): void;
|
|
25
|
+
/**
|
|
26
|
+
* Create a child logger with fixed context
|
|
27
|
+
* Useful for agent-specific or file-specific logging
|
|
28
|
+
*/
|
|
29
|
+
export declare function createLogger(baseContext: LogContext): {
|
|
30
|
+
debug: (message: string, context?: LogContext) => void;
|
|
31
|
+
info: (message: string, context?: LogContext) => void;
|
|
32
|
+
warn: (message: string, context?: LogContext) => void;
|
|
33
|
+
error: (message: string, error?: Error, context?: LogContext) => void;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAyBD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAIpE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAInE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAInE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAYnF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,UAAU;qBAE/B,MAAM,YAAY,UAAU;oBAE7B,MAAM,YAAY,UAAU;oBAE5B,MAAM,YAAY,UAAU;qBAE3B,MAAM,UAAU,KAAK,YAAY,UAAU;EAG/D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging utility for Claude-Mycelium
|
|
3
|
+
* Simple console-based logging with timestamp and context
|
|
4
|
+
*/
|
|
5
|
+
const LOG_LEVEL = process.env.LOG_LEVEL || 'info';
|
|
6
|
+
const LEVEL_PRIORITY = {
|
|
7
|
+
debug: 0,
|
|
8
|
+
info: 1,
|
|
9
|
+
warn: 2,
|
|
10
|
+
error: 3,
|
|
11
|
+
};
|
|
12
|
+
function shouldLog(level) {
|
|
13
|
+
return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[LOG_LEVEL];
|
|
14
|
+
}
|
|
15
|
+
function formatTimestamp() {
|
|
16
|
+
return new Date().toISOString();
|
|
17
|
+
}
|
|
18
|
+
function formatMessage(level, message, context) {
|
|
19
|
+
const timestamp = formatTimestamp();
|
|
20
|
+
const contextStr = context ? ` ${JSON.stringify(context)}` : '';
|
|
21
|
+
return `[${timestamp}] [${level.toUpperCase()}] ${message}${contextStr}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Log debug message (lowest priority)
|
|
25
|
+
*/
|
|
26
|
+
export function logDebug(message, context) {
|
|
27
|
+
if (shouldLog('debug')) {
|
|
28
|
+
console.debug(formatMessage('debug', message, context));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Log info message (normal priority)
|
|
33
|
+
*/
|
|
34
|
+
export function logInfo(message, context) {
|
|
35
|
+
if (shouldLog('info')) {
|
|
36
|
+
console.info(formatMessage('info', message, context));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Log warning message (high priority)
|
|
41
|
+
*/
|
|
42
|
+
export function logWarn(message, context) {
|
|
43
|
+
if (shouldLog('warn')) {
|
|
44
|
+
console.warn(formatMessage('warn', message, context));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Log error message (highest priority)
|
|
49
|
+
*/
|
|
50
|
+
export function logError(message, error, context) {
|
|
51
|
+
if (shouldLog('error')) {
|
|
52
|
+
const errorContext = error
|
|
53
|
+
? {
|
|
54
|
+
...context,
|
|
55
|
+
error: error.message,
|
|
56
|
+
stack: error.stack,
|
|
57
|
+
}
|
|
58
|
+
: context;
|
|
59
|
+
console.error(formatMessage('error', message, errorContext));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a child logger with fixed context
|
|
64
|
+
* Useful for agent-specific or file-specific logging
|
|
65
|
+
*/
|
|
66
|
+
export function createLogger(baseContext) {
|
|
67
|
+
return {
|
|
68
|
+
debug: (message, context) => logDebug(message, { ...baseContext, ...context }),
|
|
69
|
+
info: (message, context) => logInfo(message, { ...baseContext, ...context }),
|
|
70
|
+
warn: (message, context) => logWarn(message, { ...baseContext, ...context }),
|
|
71
|
+
error: (message, error, context) => logError(message, error, { ...baseContext, ...context }),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,SAAS,GAAc,OAAO,CAAC,GAAG,CAAC,SAAsB,IAAI,MAAM,CAAC;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