tuna-agent 0.1.61 → 0.1.63
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.
|
@@ -39,6 +39,8 @@ export declare class ClaudeCodeAdapter implements AgentAdapter {
|
|
|
39
39
|
/** Returns metrics for the currently active agent, initializing if needed. */
|
|
40
40
|
private get metrics();
|
|
41
41
|
constructor(config: AgentConfig);
|
|
42
|
+
/** Resolve CLAUDE.md path — check root first, then .claude/ subfolder. */
|
|
43
|
+
static resolveClaudeMdPath(folder: string): string;
|
|
42
44
|
/** Get all per-agent metrics for heartbeat. */
|
|
43
45
|
getMetrics(): Record<string, unknown>;
|
|
44
46
|
/** Register an agent folder path for rules parsing (called from daemon). */
|
|
@@ -47,13 +47,23 @@ export class ClaudeCodeAdapter {
|
|
|
47
47
|
constructor(config) {
|
|
48
48
|
this.agentConfig = config;
|
|
49
49
|
}
|
|
50
|
+
/** Resolve CLAUDE.md path — check root first, then .claude/ subfolder. */
|
|
51
|
+
static resolveClaudeMdPath(folder) {
|
|
52
|
+
const rootPath = path.join(folder, 'CLAUDE.md');
|
|
53
|
+
if (fs.existsSync(rootPath))
|
|
54
|
+
return rootPath;
|
|
55
|
+
const dotClaudePath = path.join(folder, '.claude', 'CLAUDE.md');
|
|
56
|
+
if (fs.existsSync(dotClaudePath))
|
|
57
|
+
return dotClaudePath;
|
|
58
|
+
return rootPath; // default to root (will be created here if needed)
|
|
59
|
+
}
|
|
50
60
|
/** Get all per-agent metrics for heartbeat. */
|
|
51
61
|
getMetrics() {
|
|
52
62
|
// Re-parse rules from CLAUDE.md for all known agents
|
|
53
63
|
this.agentFolderMap.forEach((folder, agentId) => {
|
|
54
64
|
const savedId = this.currentAgentId;
|
|
55
65
|
this.currentAgentId = agentId;
|
|
56
|
-
this.parseLearnedRules(
|
|
66
|
+
this.parseLearnedRules(ClaudeCodeAdapter.resolveClaudeMdPath(folder));
|
|
57
67
|
this.currentAgentId = savedId;
|
|
58
68
|
});
|
|
59
69
|
const agentMetricsMap = {};
|
|
@@ -873,13 +883,13 @@ export class ClaudeCodeAdapter {
|
|
|
873
883
|
try {
|
|
874
884
|
console.log(`[Self-Improve] Running pattern detection (every ${ClaudeCodeAdapter.PATTERN_CHECK_INTERVAL} tasks, count=${this.taskCount})`);
|
|
875
885
|
const { callMem0Patterns } = await import('../mcp/setup.js');
|
|
876
|
-
const patterns = await callMem0Patterns(this.currentAgentName,
|
|
886
|
+
const patterns = await callMem0Patterns(this.currentAgentName, 2);
|
|
877
887
|
if (patterns.length === 0) {
|
|
878
888
|
console.log(`[Self-Improve] No patterns detected yet`);
|
|
879
889
|
return;
|
|
880
890
|
}
|
|
881
891
|
// Read current CLAUDE.md and extract existing rules
|
|
882
|
-
const claudeMdPath =
|
|
892
|
+
const claudeMdPath = ClaudeCodeAdapter.resolveClaudeMdPath(cwd);
|
|
883
893
|
let existingContent = '';
|
|
884
894
|
if (fs.existsSync(claudeMdPath)) {
|
|
885
895
|
existingContent = fs.readFileSync(claudeMdPath, 'utf-8');
|