tuna-agent 0.1.60 → 0.1.62
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 = {};
|
|
@@ -879,7 +889,7 @@ export class ClaudeCodeAdapter {
|
|
|
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');
|
|
@@ -973,7 +983,7 @@ export class ClaudeCodeAdapter {
|
|
|
973
983
|
const nextSection = sectionContent.indexOf('\n## ');
|
|
974
984
|
const rulesText = nextSection !== -1 ? sectionContent.substring(0, nextSection) : sectionContent;
|
|
975
985
|
const rules = [];
|
|
976
|
-
const ruleRegex = /^-
|
|
986
|
+
const ruleRegex = /^-{1,2}\s+(.+?)(?:\s*\(confidence:\s*([\d.]+)\))?$/;
|
|
977
987
|
// First pass: collect raw confidence values
|
|
978
988
|
const rawEntries = [];
|
|
979
989
|
for (const line of rulesText.split('\n')) {
|