@triedotdev/mcp 1.0.136 → 1.0.137
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/dist/{chunk-DFHMB44X.js → chunk-4JQ6W7LW.js} +3 -4
- package/dist/chunk-4JQ6W7LW.js.map +1 -0
- package/dist/{chunk-WS6OA7H6.js → chunk-4MJ52WBH.js} +2 -3
- package/dist/chunk-4MJ52WBH.js.map +1 -0
- package/dist/{chunk-UHMMANC2.js → chunk-6EP2VTHC.js} +15 -15
- package/dist/chunk-6EP2VTHC.js.map +1 -0
- package/dist/{chunk-T4THB2OR.js → chunk-A6PWS6ZV.js} +38 -27
- package/dist/chunk-A6PWS6ZV.js.map +1 -0
- package/dist/{chunk-POHBQUG7.js → chunk-AXYNWBME.js} +272 -187
- package/dist/chunk-AXYNWBME.js.map +1 -0
- package/dist/{chunk-AJ34GCMD.js → chunk-DPZLABUC.js} +32 -32
- package/dist/chunk-DPZLABUC.js.map +1 -0
- package/dist/{chunk-UHX4462X.js → chunk-G74XEI7K.js} +13 -14
- package/dist/chunk-G74XEI7K.js.map +1 -0
- package/dist/{goal-validator-PDKYZSNP.js → chunk-HUR67JXG.js} +71 -33
- package/dist/chunk-HUR67JXG.js.map +1 -0
- package/dist/{chunk-6OUWNVLX.js → chunk-K6NTRSDF.js} +4 -4
- package/dist/{chunk-G5PRBQIQ.js → chunk-QM5VIDFN.js} +75 -71
- package/dist/chunk-QM5VIDFN.js.map +1 -0
- package/dist/{chunk-4YJ6KLGI.js → chunk-QNKBXOIQ.js} +7 -5
- package/dist/chunk-QNKBXOIQ.js.map +1 -0
- package/dist/{chunk-JAKMZI5S.js → chunk-R3WZI6QZ.js} +290 -179
- package/dist/chunk-R3WZI6QZ.js.map +1 -0
- package/dist/{chunk-VRLMTOB6.js → chunk-TIMIKBY2.js} +1 -1
- package/dist/chunk-TIMIKBY2.js.map +1 -0
- package/dist/cli/main.js +104 -100
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +13 -13
- package/dist/cli/yolo-daemon.js.map +1 -1
- package/dist/{goal-manager-FAK7H4RR.js → goal-manager-62IL6WGY.js} +6 -7
- package/dist/goal-validator-HPPBSDXD.js +22 -0
- package/dist/guardian-agent-YKG5XURG.js +30 -0
- package/dist/{hypothesis-L5446W36.js → hypothesis-W37VG6DA.js} +6 -7
- package/dist/index.js +265 -259
- package/dist/index.js.map +1 -1
- package/dist/{insight-store-F5KDBY5Y.js → insight-store-U3NYTOJE.js} +5 -3
- package/dist/issue-store-EZMBHOVN.js +32 -0
- package/dist/{output-manager-BOTMXSND.js → output-manager-DZO5LGSG.js} +2 -2
- package/dist/output-manager-DZO5LGSG.js.map +1 -0
- package/dist/ui/chat.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-4YJ6KLGI.js.map +0 -1
- package/dist/chunk-AJ34GCMD.js.map +0 -1
- package/dist/chunk-DFHMB44X.js.map +0 -1
- package/dist/chunk-G5PRBQIQ.js.map +0 -1
- package/dist/chunk-JAKMZI5S.js.map +0 -1
- package/dist/chunk-PEJEYWVR.js +0 -135
- package/dist/chunk-PEJEYWVR.js.map +0 -1
- package/dist/chunk-POHBQUG7.js.map +0 -1
- package/dist/chunk-T4THB2OR.js.map +0 -1
- package/dist/chunk-UHMMANC2.js.map +0 -1
- package/dist/chunk-UHX4462X.js.map +0 -1
- package/dist/chunk-VRLMTOB6.js.map +0 -1
- package/dist/chunk-WS6OA7H6.js.map +0 -1
- package/dist/goal-validator-PDKYZSNP.js.map +0 -1
- package/dist/guardian-agent-4RHGIXUD.js +0 -27
- package/dist/ledger-WKVJWHBX.js +0 -17
- /package/dist/{chunk-6OUWNVLX.js.map → chunk-K6NTRSDF.js.map} +0 -0
- /package/dist/{goal-manager-FAK7H4RR.js.map → goal-manager-62IL6WGY.js.map} +0 -0
- /package/dist/{guardian-agent-4RHGIXUD.js.map → goal-validator-HPPBSDXD.js.map} +0 -0
- /package/dist/{hypothesis-L5446W36.js.map → guardian-agent-YKG5XURG.js.map} +0 -0
- /package/dist/{insight-store-F5KDBY5Y.js.map → hypothesis-W37VG6DA.js.map} +0 -0
- /package/dist/{ledger-WKVJWHBX.js.map → insight-store-U3NYTOJE.js.map} +0 -0
- /package/dist/{output-manager-BOTMXSND.js.map → issue-store-EZMBHOVN.js.map} +0 -0
package/dist/cli/main.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
needsBootstrap,
|
|
12
12
|
projectInfoExists,
|
|
13
13
|
saveConfig
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-4JQ6W7LW.js";
|
|
15
15
|
import {
|
|
16
16
|
getAutonomyConfig,
|
|
17
17
|
recordBypass,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
isTrieInitialized,
|
|
35
35
|
perceiveCurrentChanges,
|
|
36
36
|
reasonAboutChangesHumanReadable
|
|
37
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-K6NTRSDF.js";
|
|
38
38
|
import {
|
|
39
39
|
IncidentIndex
|
|
40
40
|
} from "../chunk-WHIQAGB7.js";
|
|
@@ -46,20 +46,14 @@ import {
|
|
|
46
46
|
listTrackedProjects,
|
|
47
47
|
searchGlobalPatterns,
|
|
48
48
|
updateGlobalMemoryMd
|
|
49
|
-
} from "../chunk-
|
|
50
|
-
import "../chunk-O6OTJI3W.js";
|
|
49
|
+
} from "../chunk-G74XEI7K.js";
|
|
51
50
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
markIssueResolved,
|
|
56
|
-
purgeIssues,
|
|
57
|
-
searchIssues
|
|
58
|
-
} from "../chunk-JAKMZI5S.js";
|
|
51
|
+
measureInitialGoalValue
|
|
52
|
+
} from "../chunk-HUR67JXG.js";
|
|
53
|
+
import "../chunk-O6OTJI3W.js";
|
|
59
54
|
import {
|
|
60
|
-
|
|
61
|
-
} from "../chunk-
|
|
62
|
-
import "../chunk-WS6OA7H6.js";
|
|
55
|
+
getProjectState
|
|
56
|
+
} from "../chunk-6EP2VTHC.js";
|
|
63
57
|
import "../chunk-F4NJ4CBP.js";
|
|
64
58
|
import "../chunk-IXO4G4D3.js";
|
|
65
59
|
import "../chunk-6NLHFIYA.js";
|
|
@@ -67,7 +61,15 @@ import "../chunk-Z4DN527J.js";
|
|
|
67
61
|
import {
|
|
68
62
|
ContextGraph
|
|
69
63
|
} from "../chunk-55CBWOEZ.js";
|
|
70
|
-
import
|
|
64
|
+
import {
|
|
65
|
+
getDailyLogs,
|
|
66
|
+
getMemoryStats,
|
|
67
|
+
getRecentIssues,
|
|
68
|
+
markIssueResolved,
|
|
69
|
+
purgeIssues,
|
|
70
|
+
searchIssues
|
|
71
|
+
} from "../chunk-R3WZI6QZ.js";
|
|
72
|
+
import "../chunk-4MJ52WBH.js";
|
|
71
73
|
import "../chunk-43X6JBEM.js";
|
|
72
74
|
import {
|
|
73
75
|
getTrieDirectory,
|
|
@@ -180,16 +182,16 @@ ${content}`);
|
|
|
180
182
|
}
|
|
181
183
|
fs.chmodSync(targetPath, 493);
|
|
182
184
|
}
|
|
183
|
-
function installGitHooks(
|
|
184
|
-
const gitDir = path.join(
|
|
185
|
+
function installGitHooks(projectPath2) {
|
|
186
|
+
const gitDir = path.join(projectPath2, ".git");
|
|
185
187
|
if (!fs.existsSync(gitDir)) {
|
|
186
188
|
return [];
|
|
187
189
|
}
|
|
188
|
-
ensureHookDir(
|
|
190
|
+
ensureHookDir(projectPath2);
|
|
189
191
|
const installed = [];
|
|
190
192
|
Object.keys(HOOK_BUILDERS).forEach((name) => {
|
|
191
193
|
const content = HOOK_BUILDERS[name]();
|
|
192
|
-
const target = hookPath(
|
|
194
|
+
const target = hookPath(projectPath2, name);
|
|
193
195
|
appendHookFile(target, content);
|
|
194
196
|
installed.push(name);
|
|
195
197
|
});
|
|
@@ -247,7 +249,7 @@ async function handleInitCommand(args) {
|
|
|
247
249
|
\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2551
|
|
248
250
|
\u2551 \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u2551
|
|
249
251
|
\u2551 \u2551
|
|
250
|
-
\u2551 Your
|
|
252
|
+
\u2551 Your code quality agent and skills registry \u2551
|
|
251
253
|
\u2551 \u2551
|
|
252
254
|
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
253
255
|
|
|
@@ -311,10 +313,10 @@ async function handleInitCommand(args) {
|
|
|
311
313
|
console.log(`
|
|
312
314
|
Quick Start:
|
|
313
315
|
1. trie scan # Analyze your codebase now
|
|
314
|
-
2. trie watch # Start
|
|
316
|
+
2. trie watch # Start watching (nudges as you code)
|
|
315
317
|
3. trie tell "what broke" # Teach Trie about past incidents
|
|
316
318
|
|
|
317
|
-
|
|
319
|
+
Trie is now active via git hooks (pre-commit, pre-push).
|
|
318
320
|
For real-time nudges while coding, run "trie watch" in a terminal.
|
|
319
321
|
|
|
320
322
|
Customize Later:
|
|
@@ -542,10 +544,10 @@ async function handleGlobal(args) {
|
|
|
542
544
|
}
|
|
543
545
|
console.log(`Tracked Projects (${projects.length}):
|
|
544
546
|
`);
|
|
545
|
-
console.log("| Project | Last Scan |
|
|
546
|
-
console.log("
|
|
547
|
+
console.log("| Project | Last Scan | Issues |");
|
|
548
|
+
console.log("|---------|-----------|--------|");
|
|
547
549
|
for (const p of projects) {
|
|
548
|
-
console.log(`| ${p.name.slice(0, 20)} | ${p.lastScan.split("T")[0]} | ${p.
|
|
550
|
+
console.log(`| ${p.name.slice(0, 20)} | ${p.lastScan.split("T")[0]} | ${p.totalIssues} |`);
|
|
549
551
|
}
|
|
550
552
|
return;
|
|
551
553
|
}
|
|
@@ -701,10 +703,10 @@ Risk: ${result.original.riskLevel.toUpperCase()} (${result.original.shouldBlock
|
|
|
701
703
|
async function handleCheckCommand(args) {
|
|
702
704
|
try {
|
|
703
705
|
const options = parseArgs(args);
|
|
704
|
-
const
|
|
706
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
705
707
|
let files = options.files;
|
|
706
708
|
if (!files || files.length === 0) {
|
|
707
|
-
const perception = await perceiveCurrentChanges(
|
|
709
|
+
const perception = await perceiveCurrentChanges(projectPath2);
|
|
708
710
|
files = perception.diffSummary.files.map((f) => f.filePath);
|
|
709
711
|
if (files.length === 0) {
|
|
710
712
|
console.log("No changes detected. Provide files with --files=path1,path2 or make a change first.");
|
|
@@ -712,7 +714,7 @@ async function handleCheckCommand(args) {
|
|
|
712
714
|
}
|
|
713
715
|
}
|
|
714
716
|
const runAgents = options.mode === "full";
|
|
715
|
-
const reasoning = await reasonAboutChangesHumanReadable(
|
|
717
|
+
const reasoning = await reasonAboutChangesHumanReadable(projectPath2, files, {
|
|
716
718
|
runAgents,
|
|
717
719
|
scanContext: {
|
|
718
720
|
config: { timeoutMs: options.mode === "quick" ? 15e3 : 6e4 }
|
|
@@ -736,14 +738,14 @@ function parseArgs2(args) {
|
|
|
736
738
|
}
|
|
737
739
|
async function handlePrePushCommand(args) {
|
|
738
740
|
const options = parseArgs2(args);
|
|
739
|
-
const
|
|
741
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
740
742
|
try {
|
|
741
|
-
const autonomyConfig = await getAutonomyConfig(
|
|
743
|
+
const autonomyConfig = await getAutonomyConfig(projectPath2);
|
|
742
744
|
if (options.bypassed) {
|
|
743
745
|
console.error(pc.yellow("Pre-push check bypassed by user"));
|
|
744
746
|
if (autonomyConfig.pushBlocking.logBypasses) {
|
|
745
747
|
await recordBypass(
|
|
746
|
-
|
|
748
|
+
projectPath2,
|
|
747
749
|
"git-push",
|
|
748
750
|
void 0,
|
|
749
751
|
"pre-push-bypass",
|
|
@@ -753,7 +755,7 @@ async function handlePrePushCommand(args) {
|
|
|
753
755
|
}
|
|
754
756
|
process.exit(0);
|
|
755
757
|
}
|
|
756
|
-
const perception = await perceiveCurrentChanges(
|
|
758
|
+
const perception = await perceiveCurrentChanges(projectPath2);
|
|
757
759
|
const files = perception.diffSummary.files.map((f) => f.filePath);
|
|
758
760
|
if (files.length === 0) {
|
|
759
761
|
console.error(pc.green("\u2713 No changes to check"));
|
|
@@ -762,7 +764,7 @@ async function handlePrePushCommand(args) {
|
|
|
762
764
|
console.error(pc.cyan(`
|
|
763
765
|
\u{1F50D} Checking ${files.length} file(s) before push...
|
|
764
766
|
`));
|
|
765
|
-
const reasoning = await reasonAboutChangesHumanReadable(
|
|
767
|
+
const reasoning = await reasonAboutChangesHumanReadable(projectPath2, files, {
|
|
766
768
|
runAgents: !options.quick,
|
|
767
769
|
scanContext: {
|
|
768
770
|
config: { timeoutMs: options.quick ? 15e3 : 3e4 }
|
|
@@ -772,7 +774,7 @@ async function handlePrePushCommand(args) {
|
|
|
772
774
|
const issues = collectIssuesForBlocking(reasoning);
|
|
773
775
|
for (const issue of issues) {
|
|
774
776
|
await trackIssueOccurrence(
|
|
775
|
-
|
|
777
|
+
projectPath2,
|
|
776
778
|
issue.file,
|
|
777
779
|
issue.line,
|
|
778
780
|
issue.severity,
|
|
@@ -992,8 +994,8 @@ async function loadFixContent(fixes) {
|
|
|
992
994
|
return enrichedFixes;
|
|
993
995
|
}
|
|
994
996
|
async function handleAutoFixCommand(args, issues) {
|
|
995
|
-
const
|
|
996
|
-
const config = await getAutonomyConfig(
|
|
997
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
998
|
+
const config = await getAutonomyConfig(projectPath2);
|
|
997
999
|
if (!config.autoFix.enabled) {
|
|
998
1000
|
console.error(pc2.yellow("Auto-fix is disabled in config."));
|
|
999
1001
|
console.error(pc2.dim("Enable it with: trie config set autoFix.enabled true"));
|
|
@@ -1111,37 +1113,37 @@ async function handleAutoFixCommand(args, issues) {
|
|
|
1111
1113
|
// src/cli/goal.ts
|
|
1112
1114
|
import pc3 from "picocolors";
|
|
1113
1115
|
async function handleGoalCommand(args) {
|
|
1114
|
-
const
|
|
1115
|
-
const
|
|
1116
|
-
await
|
|
1116
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
1117
|
+
const projectState = getProjectState(projectPath2);
|
|
1118
|
+
await projectState.load();
|
|
1117
1119
|
const subcommand = args[0];
|
|
1118
1120
|
const restArgs = args.slice(1);
|
|
1119
1121
|
switch (subcommand) {
|
|
1120
1122
|
case "add":
|
|
1121
1123
|
case "create":
|
|
1122
|
-
await addGoal(
|
|
1124
|
+
await addGoal(projectState, restArgs);
|
|
1123
1125
|
break;
|
|
1124
1126
|
case "list":
|
|
1125
1127
|
case "ls":
|
|
1126
|
-
await listGoals(
|
|
1128
|
+
await listGoals(projectState);
|
|
1127
1129
|
break;
|
|
1128
1130
|
case "complete":
|
|
1129
1131
|
case "done":
|
|
1130
|
-
await completeGoal(
|
|
1132
|
+
await completeGoal(projectState, restArgs[0]);
|
|
1131
1133
|
break;
|
|
1132
1134
|
case "delete":
|
|
1133
1135
|
case "rm":
|
|
1134
|
-
await deleteGoal(
|
|
1136
|
+
await deleteGoal(projectState, restArgs[0]);
|
|
1135
1137
|
break;
|
|
1136
1138
|
default:
|
|
1137
1139
|
if (subcommand && !subcommand.startsWith("-")) {
|
|
1138
|
-
await addGoal(
|
|
1140
|
+
await addGoal(projectState, [subcommand, ...restArgs]);
|
|
1139
1141
|
} else {
|
|
1140
1142
|
printGoalHelp();
|
|
1141
1143
|
}
|
|
1142
1144
|
}
|
|
1143
1145
|
}
|
|
1144
|
-
async function addGoal(
|
|
1146
|
+
async function addGoal(projectState, args) {
|
|
1145
1147
|
const description = args.join(" ").replace(/^["']|["']$/g, "");
|
|
1146
1148
|
if (!description) {
|
|
1147
1149
|
console.error(pc3.red("Please provide a goal description."));
|
|
@@ -1182,14 +1184,15 @@ async function addGoal(guardianState, args) {
|
|
|
1182
1184
|
} else {
|
|
1183
1185
|
deadline.setDate(deadline.getDate() + 14);
|
|
1184
1186
|
}
|
|
1187
|
+
const initialValue = await measureInitialGoalValue(cleanDesc, projectPath);
|
|
1185
1188
|
const goal = {
|
|
1186
1189
|
id: `goal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
1187
1190
|
description: cleanDesc,
|
|
1188
1191
|
type: goalType,
|
|
1189
1192
|
metric,
|
|
1190
1193
|
target,
|
|
1191
|
-
currentValue:
|
|
1192
|
-
startValue:
|
|
1194
|
+
currentValue: initialValue,
|
|
1195
|
+
startValue: initialValue,
|
|
1193
1196
|
status: "active",
|
|
1194
1197
|
autoGenerated: false,
|
|
1195
1198
|
// User-created
|
|
@@ -1198,19 +1201,22 @@ async function addGoal(guardianState, args) {
|
|
|
1198
1201
|
deadline: deadline.toISOString(),
|
|
1199
1202
|
category
|
|
1200
1203
|
};
|
|
1201
|
-
await
|
|
1204
|
+
await projectState.addGoal(goal);
|
|
1202
1205
|
console.error("");
|
|
1203
1206
|
console.error(pc3.green("\u2713 Goal created"));
|
|
1204
1207
|
console.error("");
|
|
1205
1208
|
console.error(pc3.bold(cleanDesc));
|
|
1206
1209
|
console.error(pc3.dim(`ID: ${goal.id}`));
|
|
1207
1210
|
console.error(pc3.dim(`Type: ${goalType} | Target: ${target} | Category: ${category}`));
|
|
1211
|
+
if (initialValue > 0) {
|
|
1212
|
+
console.error(pc3.dim(`Starting value: ${initialValue} issues found`));
|
|
1213
|
+
}
|
|
1208
1214
|
console.error(pc3.dim(`Deadline: ${deadline.toLocaleDateString()}`));
|
|
1209
1215
|
console.error("");
|
|
1210
|
-
console.error(pc3.cyan("
|
|
1216
|
+
console.error(pc3.cyan("Progress will be tracked and you'll be notified when you achieve it!"));
|
|
1211
1217
|
}
|
|
1212
|
-
async function listGoals(
|
|
1213
|
-
const goals =
|
|
1218
|
+
async function listGoals(projectState) {
|
|
1219
|
+
const goals = projectState.getAllGoals();
|
|
1214
1220
|
if (goals.length === 0) {
|
|
1215
1221
|
console.error(pc3.dim("No goals yet."));
|
|
1216
1222
|
console.error(pc3.dim('Create one: trie goal add "Reduce auth issues by 50%"'));
|
|
@@ -1248,19 +1254,19 @@ async function listGoals(guardianState) {
|
|
|
1248
1254
|
}
|
|
1249
1255
|
}
|
|
1250
1256
|
}
|
|
1251
|
-
async function completeGoal(
|
|
1257
|
+
async function completeGoal(projectState, goalId) {
|
|
1252
1258
|
if (!goalId) {
|
|
1253
1259
|
console.error(pc3.red("Please provide a goal ID."));
|
|
1254
1260
|
console.error(pc3.dim('Run "trie goal list" to see IDs.'));
|
|
1255
1261
|
return;
|
|
1256
1262
|
}
|
|
1257
|
-
const goals =
|
|
1258
|
-
const goal = goals.find((g) => g.id === goalId || g.id.
|
|
1263
|
+
const goals = projectState.getAllGoals();
|
|
1264
|
+
const goal = goals.find((g) => g.id === goalId || g.id.startsWith(goalId));
|
|
1259
1265
|
if (!goal) {
|
|
1260
1266
|
console.error(pc3.red(`Goal not found: ${goalId}`));
|
|
1261
1267
|
return;
|
|
1262
1268
|
}
|
|
1263
|
-
await
|
|
1269
|
+
await projectState.updateGoal(goal.id, {
|
|
1264
1270
|
status: "achieved",
|
|
1265
1271
|
currentValue: goal.target,
|
|
1266
1272
|
achievedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1270,18 +1276,18 @@ async function completeGoal(guardianState, goalId) {
|
|
|
1270
1276
|
console.error(pc3.bold(goal.description));
|
|
1271
1277
|
console.error("");
|
|
1272
1278
|
}
|
|
1273
|
-
async function deleteGoal(
|
|
1279
|
+
async function deleteGoal(projectState, goalId) {
|
|
1274
1280
|
if (!goalId) {
|
|
1275
1281
|
console.error(pc3.red("Please provide a goal ID."));
|
|
1276
1282
|
return;
|
|
1277
1283
|
}
|
|
1278
|
-
const goals =
|
|
1279
|
-
const goal = goals.find((g) => g.id === goalId || g.id.
|
|
1284
|
+
const goals = projectState.getAllGoals();
|
|
1285
|
+
const goal = goals.find((g) => g.id === goalId || g.id.startsWith(goalId));
|
|
1280
1286
|
if (!goal) {
|
|
1281
1287
|
console.error(pc3.red(`Goal not found: ${goalId}`));
|
|
1282
1288
|
return;
|
|
1283
1289
|
}
|
|
1284
|
-
await
|
|
1290
|
+
await projectState.updateGoal(goal.id, { status: "rejected" });
|
|
1285
1291
|
console.error(pc3.dim(`Removed goal: ${goal.description}`));
|
|
1286
1292
|
}
|
|
1287
1293
|
function calculateGoalProgress(goal) {
|
|
@@ -1289,6 +1295,7 @@ function calculateGoalProgress(goal) {
|
|
|
1289
1295
|
const startValue = goal.startValue ?? goal.currentValue;
|
|
1290
1296
|
if (startValue > goal.target) {
|
|
1291
1297
|
const totalReduction = startValue - goal.target;
|
|
1298
|
+
if (totalReduction === 0) return 100;
|
|
1292
1299
|
const actualReduction = startValue - goal.currentValue;
|
|
1293
1300
|
return Math.round(actualReduction / totalReduction * 100);
|
|
1294
1301
|
}
|
|
@@ -1331,39 +1338,39 @@ function printGoalHelp() {
|
|
|
1331
1338
|
console.error("");
|
|
1332
1339
|
}
|
|
1333
1340
|
async function handleHypothesisCommand(args) {
|
|
1334
|
-
const
|
|
1335
|
-
const
|
|
1336
|
-
await
|
|
1341
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
1342
|
+
const projectState = getGuardianState(projectPath2);
|
|
1343
|
+
await projectState.load();
|
|
1337
1344
|
const subcommand = args[0];
|
|
1338
1345
|
const restArgs = args.slice(1);
|
|
1339
1346
|
switch (subcommand) {
|
|
1340
1347
|
case "add":
|
|
1341
1348
|
case "create":
|
|
1342
|
-
await addHypothesis(
|
|
1349
|
+
await addHypothesis(projectState, restArgs);
|
|
1343
1350
|
break;
|
|
1344
1351
|
case "list":
|
|
1345
1352
|
case "ls":
|
|
1346
|
-
await listHypotheses(
|
|
1353
|
+
await listHypotheses(projectState);
|
|
1347
1354
|
break;
|
|
1348
1355
|
case "validate":
|
|
1349
|
-
await validateHypothesis(
|
|
1356
|
+
await validateHypothesis(projectState, restArgs[0]);
|
|
1350
1357
|
break;
|
|
1351
1358
|
case "invalidate":
|
|
1352
|
-
await invalidateHypothesis(
|
|
1359
|
+
await invalidateHypothesis(projectState, restArgs[0]);
|
|
1353
1360
|
break;
|
|
1354
1361
|
case "delete":
|
|
1355
1362
|
case "rm":
|
|
1356
|
-
await deleteHypothesis(
|
|
1363
|
+
await deleteHypothesis(projectState, restArgs[0]);
|
|
1357
1364
|
break;
|
|
1358
1365
|
default:
|
|
1359
1366
|
if (subcommand && !subcommand.startsWith("-")) {
|
|
1360
|
-
await addHypothesis(
|
|
1367
|
+
await addHypothesis(projectState, [subcommand, ...restArgs]);
|
|
1361
1368
|
} else {
|
|
1362
1369
|
printHypothesisHelp();
|
|
1363
1370
|
}
|
|
1364
1371
|
}
|
|
1365
1372
|
}
|
|
1366
|
-
async function addHypothesis(
|
|
1373
|
+
async function addHypothesis(projectState, args) {
|
|
1367
1374
|
const statement = args.join(" ").replace(/^["']|["']$/g, "");
|
|
1368
1375
|
if (!statement) {
|
|
1369
1376
|
console.error(pc3.red("Please provide a hypothesis statement."));
|
|
@@ -1387,7 +1394,7 @@ async function addHypothesis(guardianState, args) {
|
|
|
1387
1394
|
testCriteria,
|
|
1388
1395
|
category
|
|
1389
1396
|
};
|
|
1390
|
-
await
|
|
1397
|
+
await projectState.addHypothesis(hypothesis);
|
|
1391
1398
|
console.error("");
|
|
1392
1399
|
console.error(pc3.green("\u2713 Hypothesis created"));
|
|
1393
1400
|
console.error("");
|
|
@@ -1398,8 +1405,8 @@ async function addHypothesis(guardianState, args) {
|
|
|
1398
1405
|
console.error(pc3.cyan("The guardian will collect evidence and update confidence over time."));
|
|
1399
1406
|
console.error(pc3.dim(`Test criteria: ${testCriteria}`));
|
|
1400
1407
|
}
|
|
1401
|
-
async function listHypotheses(
|
|
1402
|
-
const hypotheses =
|
|
1408
|
+
async function listHypotheses(projectState) {
|
|
1409
|
+
const hypotheses = projectState.getAllHypotheses();
|
|
1403
1410
|
if (hypotheses.length === 0) {
|
|
1404
1411
|
console.error(pc3.dim("No hypotheses yet."));
|
|
1405
1412
|
console.error(pc3.dim('Create one: trie hypothesis add "Mondays have more bugs"'));
|
|
@@ -1435,53 +1442,53 @@ async function listHypotheses(guardianState) {
|
|
|
1435
1442
|
}
|
|
1436
1443
|
}
|
|
1437
1444
|
}
|
|
1438
|
-
async function validateHypothesis(
|
|
1445
|
+
async function validateHypothesis(projectState, hypoId) {
|
|
1439
1446
|
if (!hypoId) {
|
|
1440
1447
|
console.error(pc3.red("Please provide a hypothesis ID."));
|
|
1441
1448
|
return;
|
|
1442
1449
|
}
|
|
1443
|
-
const hypotheses =
|
|
1444
|
-
const hypo = hypotheses.find((h) => h.id === hypoId || h.id.
|
|
1450
|
+
const hypotheses = projectState.getAllHypotheses();
|
|
1451
|
+
const hypo = hypotheses.find((h) => h.id === hypoId || h.id.startsWith(hypoId));
|
|
1445
1452
|
if (!hypo) {
|
|
1446
1453
|
console.error(pc3.red(`Hypothesis not found: ${hypoId}`));
|
|
1447
1454
|
return;
|
|
1448
1455
|
}
|
|
1449
|
-
await
|
|
1456
|
+
await projectState.updateHypothesis(hypo.id, {
|
|
1450
1457
|
status: "validated",
|
|
1451
1458
|
confidence: 0.9,
|
|
1452
1459
|
validatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1453
1460
|
});
|
|
1454
1461
|
console.error(pc3.green(`Hypothesis validated: "${hypo.statement}"`));
|
|
1455
1462
|
}
|
|
1456
|
-
async function invalidateHypothesis(
|
|
1463
|
+
async function invalidateHypothesis(projectState, hypoId) {
|
|
1457
1464
|
if (!hypoId) {
|
|
1458
1465
|
console.error(pc3.red("Please provide a hypothesis ID."));
|
|
1459
1466
|
return;
|
|
1460
1467
|
}
|
|
1461
|
-
const hypotheses =
|
|
1462
|
-
const hypo = hypotheses.find((h) => h.id === hypoId || h.id.
|
|
1468
|
+
const hypotheses = projectState.getAllHypotheses();
|
|
1469
|
+
const hypo = hypotheses.find((h) => h.id === hypoId || h.id.startsWith(hypoId));
|
|
1463
1470
|
if (!hypo) {
|
|
1464
1471
|
console.error(pc3.red(`Hypothesis not found: ${hypoId}`));
|
|
1465
1472
|
return;
|
|
1466
1473
|
}
|
|
1467
|
-
await
|
|
1474
|
+
await projectState.updateHypothesis(hypo.id, {
|
|
1468
1475
|
status: "invalidated",
|
|
1469
1476
|
confidence: 0.1
|
|
1470
1477
|
});
|
|
1471
1478
|
console.error(pc3.red(`Hypothesis invalidated: "${hypo.statement}"`));
|
|
1472
1479
|
}
|
|
1473
|
-
async function deleteHypothesis(
|
|
1480
|
+
async function deleteHypothesis(projectState, hypoId) {
|
|
1474
1481
|
if (!hypoId) {
|
|
1475
1482
|
console.error(pc3.red("Please provide a hypothesis ID."));
|
|
1476
1483
|
return;
|
|
1477
1484
|
}
|
|
1478
|
-
const hypotheses =
|
|
1479
|
-
const hypo = hypotheses.find((h) => h.id === hypoId || h.id.
|
|
1485
|
+
const hypotheses = projectState.getAllHypotheses();
|
|
1486
|
+
const hypo = hypotheses.find((h) => h.id === hypoId || h.id.startsWith(hypoId));
|
|
1480
1487
|
if (!hypo) {
|
|
1481
1488
|
console.error(pc3.red(`Hypothesis not found: ${hypoId}`));
|
|
1482
1489
|
return;
|
|
1483
1490
|
}
|
|
1484
|
-
await
|
|
1491
|
+
await projectState.updateHypothesis(hypo.id, { status: "retired" });
|
|
1485
1492
|
console.error(pc3.dim(`Removed hypothesis: "${hypo.statement}"`));
|
|
1486
1493
|
}
|
|
1487
1494
|
function detectHypothesisCategory(statement) {
|
|
@@ -1547,13 +1554,13 @@ function extractFilePathsFromDescription(description) {
|
|
|
1547
1554
|
}
|
|
1548
1555
|
async function handleTellCommand(args) {
|
|
1549
1556
|
try {
|
|
1550
|
-
const
|
|
1557
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
1551
1558
|
const description = args.join(" ").trim();
|
|
1552
1559
|
if (!description) {
|
|
1553
1560
|
console.log('Usage: trie tell "<incident description>"');
|
|
1554
1561
|
return;
|
|
1555
1562
|
}
|
|
1556
|
-
const graph = new ContextGraph(
|
|
1563
|
+
const graph = new ContextGraph(projectPath2);
|
|
1557
1564
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1558
1565
|
const change = (await graph.getRecentChanges(1))[0];
|
|
1559
1566
|
const incident = await graph.addNode("incident", {
|
|
@@ -1573,7 +1580,7 @@ async function handleTellCommand(args) {
|
|
|
1573
1580
|
await graph.addEdge(incident.id, change.id, "causedBy");
|
|
1574
1581
|
for (const filePath of change.data.files) {
|
|
1575
1582
|
linkedFiles.add(filePath);
|
|
1576
|
-
const fileNode = await graph.getNode("file", path3.resolve(
|
|
1583
|
+
const fileNode = await graph.getNode("file", path3.resolve(projectPath2, filePath));
|
|
1577
1584
|
if (fileNode) {
|
|
1578
1585
|
const data = fileNode.data;
|
|
1579
1586
|
await graph.updateNode("file", fileNode.id, {
|
|
@@ -1585,7 +1592,7 @@ async function handleTellCommand(args) {
|
|
|
1585
1592
|
}
|
|
1586
1593
|
const mentionedFiles = extractFilePathsFromDescription(description);
|
|
1587
1594
|
mentionedFiles.forEach((f) => linkedFiles.add(f));
|
|
1588
|
-
const incidentIndex = new IncidentIndex(graph,
|
|
1595
|
+
const incidentIndex = new IncidentIndex(graph, projectPath2);
|
|
1589
1596
|
incidentIndex.addIncidentToTrie(incident, Array.from(linkedFiles));
|
|
1590
1597
|
await exportToJson(graph);
|
|
1591
1598
|
console.log("Incident recorded.");
|
|
@@ -1617,9 +1624,9 @@ async function removeOrphanEdges(graph) {
|
|
|
1617
1624
|
}
|
|
1618
1625
|
async function handleReconcileCommand(args) {
|
|
1619
1626
|
try {
|
|
1620
|
-
const
|
|
1621
|
-
const source = args.find((a) => a.startsWith("--from="))?.replace("--from=", "") ?? path4.join(getTrieDirectory(
|
|
1622
|
-
const graph = new ContextGraph(
|
|
1627
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
1628
|
+
const source = args.find((a) => a.startsWith("--from="))?.replace("--from=", "") ?? path4.join(getTrieDirectory(projectPath2), "context.json");
|
|
1629
|
+
const graph = new ContextGraph(projectPath2);
|
|
1623
1630
|
await importFromJson(graph, "", source);
|
|
1624
1631
|
const removed = await removeOrphanEdges(graph);
|
|
1625
1632
|
console.log(`Reconciled context from ${source}. Removed ${removed} orphaned edges.`);
|
|
@@ -1633,8 +1640,8 @@ async function handleReconcileCommand(args) {
|
|
|
1633
1640
|
import fs3 from "fs";
|
|
1634
1641
|
import path5 from "path";
|
|
1635
1642
|
async function handleQuietCommand() {
|
|
1636
|
-
const
|
|
1637
|
-
const quietPath = path5.join(getTrieDirectory(
|
|
1643
|
+
const projectPath2 = getWorkingDirectory(void 0, true);
|
|
1644
|
+
const quietPath = path5.join(getTrieDirectory(projectPath2), "quiet.json");
|
|
1638
1645
|
const until = new Date(Date.now() + 60 * 60 * 1e3).toISOString();
|
|
1639
1646
|
const payload = { until };
|
|
1640
1647
|
try {
|
|
@@ -2407,7 +2414,7 @@ USAGE:
|
|
|
2407
2414
|
COMMANDS:
|
|
2408
2415
|
init Initialize Trie in your project
|
|
2409
2416
|
scan Scan codebase once and exit
|
|
2410
|
-
watch Start
|
|
2417
|
+
watch Start watching (nudges as you code)
|
|
2411
2418
|
Use screen/tmux to run in background
|
|
2412
2419
|
check Run risk check before pushing
|
|
2413
2420
|
|
|
@@ -2436,7 +2443,7 @@ COMMANDS:
|
|
|
2436
2443
|
|
|
2437
2444
|
EXAMPLES:
|
|
2438
2445
|
trie init # Initialize Trie in your project
|
|
2439
|
-
trie watch # Start
|
|
2446
|
+
trie watch # Start watching (nudges as you code)
|
|
2440
2447
|
trie watch # Run in background: screen -S trie-watch
|
|
2441
2448
|
trie scan # Scan your codebase now
|
|
2442
2449
|
|
|
@@ -2522,9 +2529,6 @@ async function handleStatusCommand() {
|
|
|
2522
2529
|
console.log("\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
|
|
2523
2530
|
console.log("\u2551 PROJECT STATUS \u2551");
|
|
2524
2531
|
console.log("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n");
|
|
2525
|
-
const healthIndicator = state.healthScore >= 80 ? "\u25CF" : state.healthScore >= 60 ? "\u25C9" : "\u25CB";
|
|
2526
|
-
const healthColor = state.healthScore >= 80 ? pc5.green(healthIndicator) : state.healthScore >= 60 ? pc5.yellow(healthIndicator) : pc5.red(healthIndicator);
|
|
2527
|
-
console.log(`${healthColor} Health Score: ${pc5.bold(state.healthScore + "%")}`);
|
|
2528
2532
|
if (state.lastScan) {
|
|
2529
2533
|
const lastScanDate = new Date(state.lastScan.timestamp);
|
|
2530
2534
|
const daysAgo = Math.floor((Date.now() - lastScanDate.getTime()) / (1e3 * 60 * 60 * 24));
|
|
@@ -2612,13 +2616,13 @@ Next steps:
|
|
|
2612
2616
|
}
|
|
2613
2617
|
if (subcommand === "edit") {
|
|
2614
2618
|
const editor = process.env.EDITOR || process.env.VISUAL || "nano";
|
|
2615
|
-
const
|
|
2619
|
+
const projectPath2 = join3(getTrieDirectory(workDir), "PROJECT.md");
|
|
2616
2620
|
if (!projectInfoExists(workDir)) {
|
|
2617
2621
|
console.log("No PROJECT.md found. Creating one first...");
|
|
2618
2622
|
await initProjectInfo(workDir);
|
|
2619
2623
|
}
|
|
2620
2624
|
const { spawn } = await import("child_process");
|
|
2621
|
-
const child = spawn(editor, [
|
|
2625
|
+
const child = spawn(editor, [projectPath2], { stdio: "inherit" });
|
|
2622
2626
|
child.on("close", (code) => {
|
|
2623
2627
|
process.exit(code || 0);
|
|
2624
2628
|
});
|