@triedotdev/mcp 1.0.44 → 1.0.46
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/README.md +284 -40
- package/dist/{chunk-2I6CFJTR.js → chunk-5AS3BWAZ.js} +128 -30
- package/dist/chunk-5AS3BWAZ.js.map +1 -0
- package/dist/chunk-BAME4KVK.js +533 -0
- package/dist/chunk-BAME4KVK.js.map +1 -0
- package/dist/{chunk-PG3GMCGH.js → chunk-GLC62PGD.js} +1 -1
- package/dist/{chunk-PG3GMCGH.js.map → chunk-GLC62PGD.js.map} +1 -1
- package/dist/chunk-PZDQIFKO.js +1598 -0
- package/dist/chunk-PZDQIFKO.js.map +1 -0
- package/dist/{chunk-GBGONSOR.js → chunk-R5HWHP5N.js} +202 -39
- package/dist/chunk-R5HWHP5N.js.map +1 -0
- package/dist/cli/create-agent.js +1 -1
- package/dist/cli/create-agent.js.map +1 -1
- package/dist/cli/main.js +336 -21
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +3 -3
- package/dist/index.js +794 -68
- package/dist/index.js.map +1 -1
- package/dist/workers/agent-worker.js +2 -2
- package/package.json +2 -1
- package/dist/chunk-2I6CFJTR.js.map +0 -1
- package/dist/chunk-52SSNKXS.js +0 -814
- package/dist/chunk-52SSNKXS.js.map +0 -1
- package/dist/chunk-GBGONSOR.js.map +0 -1
package/dist/cli/create-agent.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/create-agent.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Trie Agent Creator CLI\n * \n * Create custom
|
|
1
|
+
{"version":3,"sources":["../../src/cli/create-agent.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * Trie Agent Creator CLI\n * \n * Create custom skills from PDF, TXT, MD, or RTF documents.\n * \n * Usage:\n * trie-create <file-path> <agent-name> [options]\n * \n * Examples:\n * trie-create ./react-book.pdf react-fundamentals\n * trie-create ~/Documents/gdpr-guide.pdf gdpr-compliance --category legal\n * \n * Drag & Drop:\n * Just drag a file to terminal and add the agent name:\n * trie-create /path/to/dropped/file.pdf my-agent\n */\n\nimport { buildAgentFromDocument } from '../ingest/agent-builder.js';\nimport { existsSync } from 'fs';\nimport { resolve, basename, extname } from 'path';\n\ninterface CLIOptions {\n filePath: string;\n agentName: string;\n displayName?: string;\n description?: string;\n category?: string;\n}\n\nfunction parseArgs(): CLIOptions | null {\n const args = process.argv.slice(2);\n \n // Show help\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\n showHelp();\n return null;\n }\n \n // First arg is file path (handles drag & drop)\n let filePath = args[0];\n if (!filePath) {\n console.error('❌ Error: Please provide a file path');\n showHelp();\n return null;\n }\n \n // Clean up path (remove quotes that might be added by drag & drop)\n filePath = filePath.replace(/^['\"]|['\"]$/g, '').trim();\n filePath = resolve(filePath);\n \n // Second arg is agent name (optional - will auto-generate if not provided)\n let agentName = args[1];\n if (!agentName || agentName.startsWith('--')) {\n // Auto-generate from filename\n const filename = basename(filePath, extname(filePath));\n agentName = filename\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '');\n console.log(`📝 Auto-generated agent name: ${agentName}`);\n }\n \n // Parse options\n const options: CLIOptions = {\n filePath,\n agentName,\n };\n \n for (let i = 2; i < args.length; i++) {\n const arg = args[i];\n const nextArg = args[i + 1];\n \n switch (arg) {\n case '--display-name':\n case '-n':\n if (nextArg) options.displayName = nextArg;\n i++;\n break;\n case '--description':\n case '-d':\n if (nextArg) options.description = nextArg;\n i++;\n break;\n case '--category':\n case '-c':\n if (nextArg) options.category = nextArg;\n i++;\n break;\n }\n }\n \n return options;\n}\n\nfunction showHelp(): void {\n console.log(`\n📚 Trie Agent Creator\nCreate custom code review agents from documents.\n\nUsage:\n trie-create <file-path> [agent-name] [options]\n\nArguments:\n file-path Path to PDF, TXT, MD, or RTF file (drag & drop supported!)\n agent-name Name for the agent (optional - auto-generated from filename)\n\nOptions:\n --display-name, -n Friendly display name for the agent\n --description, -d Description of what the agent does\n --category, -c Category (react, security, compliance, architecture, etc.)\n --help, -h Show this help message\n\nExamples:\n # Basic usage\n trie-create ./react-book.pdf react-fundamentals\n\n # With options\n trie-create ./gdpr-guide.pdf gdpr-compliance --category legal\n\n # Auto-generate name from filename\n trie-create ./clean-code.pdf\n\n # Drag & drop a file to terminal, then add name\n trie-create /Users/you/Downloads/my-book.pdf my-agent\n\nSupported File Types:\n • PDF (.pdf) - Requires pdf-parse: npm install pdf-parse\n • Text (.txt) - Plain text files\n • Markdown (.md, .markdown)\n • RTF (.rtf) - Rich Text Format\n\nAfter Creation:\n The agent is saved to .trie/agents/<name>.json and will automatically\n activate during scans when it detects relevant code patterns.\n`);\n}\n\nasync function main(): Promise<void> {\n console.log('\\n🔮 Trie Agent Creator\\n');\n \n const options = parseArgs();\n if (!options) {\n process.exit(0);\n }\n \n // Validate file exists\n if (!existsSync(options.filePath)) {\n console.error(`❌ File not found: ${options.filePath}`);\n console.error('\\n💡 Tip: Drag & drop the file directly into the terminal!');\n process.exit(1);\n }\n \n // Validate file type\n const ext = extname(options.filePath).toLowerCase();\n const supportedTypes = ['.pdf', '.txt', '.md', '.markdown', '.rtf'];\n if (!supportedTypes.includes(ext)) {\n console.error(`❌ Unsupported file type: ${ext}`);\n console.error(` Supported types: ${supportedTypes.join(', ')}`);\n process.exit(1);\n }\n \n console.log(`📄 File: ${options.filePath}`);\n console.log(`🏷️ Agent: ${options.agentName}`);\n if (options.category) console.log(`📁 Category: ${options.category}`);\n console.log('');\n \n try {\n const createOptions: Parameters<typeof buildAgentFromDocument>[0] = {\n filePath: options.filePath,\n agentName: options.agentName,\n };\n if (options.displayName) createOptions.displayName = options.displayName;\n if (options.description) createOptions.description = options.description;\n if (options.category) createOptions.category = options.category;\n \n const result = await buildAgentFromDocument(createOptions, true);\n \n if (result.success) {\n console.log('\\n' + '━'.repeat(50));\n console.log('✅ Agent created successfully!');\n console.log('━'.repeat(50));\n console.log(`\\n📍 Config saved to: ${result.configPath}`);\n console.log(`\\n📊 Stats:`);\n console.log(` • Document words: ${result.stats.documentWords.toLocaleString()}`);\n console.log(` • Concepts extracted: ${result.stats.conceptsExtracted}`);\n console.log(` • Detection patterns: ${result.stats.patternsGenerated}`);\n console.log(` • Compression ratio: ${result.stats.compressionRatio}:1`);\n console.log('\\n🚀 The agent will now activate during code scans!');\n console.log(' Run: trie_scan to test it\\n');\n } else {\n console.error(`\\n❌ Failed: ${result.error}`);\n process.exit(1);\n }\n } catch (error) {\n console.error(`\\n❌ Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n}\n\nmain();\n\n"],"mappings":";;;;;;;;AAmBA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,UAAU,eAAe;AAU3C,SAAS,YAA+B;AACtC,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAGjC,MAAI,KAAK,WAAW,KAAK,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;AACvE,aAAS;AACT,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,KAAK,CAAC;AACrB,MAAI,CAAC,UAAU;AACb,YAAQ,MAAM,0CAAqC;AACnD,aAAS;AACT,WAAO;AAAA,EACT;AAGA,aAAW,SAAS,QAAQ,gBAAgB,EAAE,EAAE,KAAK;AACrD,aAAW,QAAQ,QAAQ;AAG3B,MAAI,YAAY,KAAK,CAAC;AACtB,MAAI,CAAC,aAAa,UAAU,WAAW,IAAI,GAAG;AAE5C,UAAM,WAAW,SAAS,UAAU,QAAQ,QAAQ,CAAC;AACrD,gBAAY,SACT,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,UAAU,EAAE;AACvB,YAAQ,IAAI,wCAAiC,SAAS,EAAE;AAAA,EAC1D;AAGA,QAAM,UAAsB;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,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
package/dist/cli/main.js
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
completeBootstrap,
|
|
4
|
+
handleCheckpointCommand,
|
|
5
|
+
initializeBootstrapFiles,
|
|
6
|
+
needsBootstrap
|
|
7
|
+
} from "../chunk-BAME4KVK.js";
|
|
8
|
+
import {
|
|
9
|
+
findCrossProjectPatterns,
|
|
10
|
+
getDailyLogs,
|
|
11
|
+
getGlobalMemoryStats,
|
|
12
|
+
getMemoryStats,
|
|
13
|
+
getRecentIssues,
|
|
3
14
|
initProjectInfo,
|
|
4
15
|
installSkill,
|
|
5
16
|
listInstalledSkills,
|
|
17
|
+
listTrackedProjects,
|
|
6
18
|
loadContextState,
|
|
7
19
|
loadProjectInfo,
|
|
20
|
+
markIssueResolved,
|
|
8
21
|
projectInfoExists,
|
|
9
22
|
recordSkillInstalled,
|
|
10
|
-
removeSkill
|
|
11
|
-
|
|
23
|
+
removeSkill,
|
|
24
|
+
searchGlobalPatterns,
|
|
25
|
+
searchIssues,
|
|
26
|
+
updateGlobalMemoryMd
|
|
27
|
+
} from "../chunk-PZDQIFKO.js";
|
|
12
28
|
import {
|
|
13
29
|
getWorkingDirectory
|
|
14
30
|
} from "../chunk-IMFD4SJC.js";
|
|
@@ -155,6 +171,284 @@ Browse available skills: https://skills.sh
|
|
|
155
171
|
}
|
|
156
172
|
}
|
|
157
173
|
|
|
174
|
+
// src/cli/init.ts
|
|
175
|
+
async function handleInitCommand(args) {
|
|
176
|
+
const subcommand = args[0]?.toLowerCase();
|
|
177
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
178
|
+
if (subcommand === "complete") {
|
|
179
|
+
const result2 = await completeBootstrap(workDir);
|
|
180
|
+
if (result2) {
|
|
181
|
+
console.log("Bootstrap completed. BOOTSTRAP.md has been deleted.");
|
|
182
|
+
} else {
|
|
183
|
+
console.log("No BOOTSTRAP.md file found.");
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (subcommand === "status") {
|
|
188
|
+
const needs = needsBootstrap(workDir);
|
|
189
|
+
if (needs) {
|
|
190
|
+
console.log("Bootstrap pending: .trie/BOOTSTRAP.md exists");
|
|
191
|
+
console.log('Run "trie init complete" after finishing setup.');
|
|
192
|
+
} else {
|
|
193
|
+
console.log("Bootstrap complete: No pending setup.");
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const force = args.includes("--force") || args.includes("-f");
|
|
198
|
+
const skipBootstrap = args.includes("--skip-bootstrap");
|
|
199
|
+
console.log(`
|
|
200
|
+
Initializing Trie workspace...
|
|
201
|
+
`);
|
|
202
|
+
const result = await initializeBootstrapFiles({
|
|
203
|
+
workDir,
|
|
204
|
+
force,
|
|
205
|
+
skipBootstrap
|
|
206
|
+
});
|
|
207
|
+
if (result.created.length > 0) {
|
|
208
|
+
console.log("Created files:");
|
|
209
|
+
for (const file of result.created) {
|
|
210
|
+
console.log(` + .trie/${file}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (result.skipped.length > 0 && !force) {
|
|
214
|
+
console.log("\nSkipped (already exist):");
|
|
215
|
+
for (const file of result.skipped) {
|
|
216
|
+
console.log(` - .trie/${file}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
console.log("\nDetected Stack:");
|
|
220
|
+
if (result.stack.framework) console.log(` Framework: ${result.stack.framework}`);
|
|
221
|
+
if (result.stack.language) console.log(` Language: ${result.stack.language}`);
|
|
222
|
+
if (result.stack.database) console.log(` Database: ${result.stack.database}`);
|
|
223
|
+
if (result.stack.auth) console.log(` Auth: ${result.stack.auth}`);
|
|
224
|
+
if (result.stack.packageManager) console.log(` Package Manager: ${result.stack.packageManager}`);
|
|
225
|
+
if (result.stack.suggestedSkills.length > 0) {
|
|
226
|
+
console.log("\nSuggested Skills:");
|
|
227
|
+
for (const skill of result.stack.suggestedSkills) {
|
|
228
|
+
console.log(` trie skills add ${skill}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
console.log(`
|
|
232
|
+
Next Steps:
|
|
233
|
+
1. Edit .trie/PROJECT.md with your project description
|
|
234
|
+
2. Define coding standards in .trie/RULES.md
|
|
235
|
+
3. Run "trie scan" to analyze your codebase
|
|
236
|
+
4. Run "trie init complete" when setup is done
|
|
237
|
+
`);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/cli/memory.ts
|
|
241
|
+
async function handleMemoryCommand(args) {
|
|
242
|
+
const subcommand = args[0]?.toLowerCase();
|
|
243
|
+
const restArgs = args.slice(1);
|
|
244
|
+
switch (subcommand) {
|
|
245
|
+
case "search":
|
|
246
|
+
await handleSearch(restArgs);
|
|
247
|
+
break;
|
|
248
|
+
case "stats":
|
|
249
|
+
await handleStats();
|
|
250
|
+
break;
|
|
251
|
+
case "recent":
|
|
252
|
+
await handleRecent(restArgs);
|
|
253
|
+
break;
|
|
254
|
+
case "logs":
|
|
255
|
+
await handleLogs();
|
|
256
|
+
break;
|
|
257
|
+
case "resolve":
|
|
258
|
+
await handleResolve(restArgs);
|
|
259
|
+
break;
|
|
260
|
+
case "global":
|
|
261
|
+
await handleGlobal(restArgs);
|
|
262
|
+
break;
|
|
263
|
+
default:
|
|
264
|
+
showHelp();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async function handleSearch(args) {
|
|
268
|
+
const query = args.join(" ");
|
|
269
|
+
if (!query) {
|
|
270
|
+
console.log("Usage: trie memory search <query>");
|
|
271
|
+
console.log('Example: trie memory search "SQL injection"');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
275
|
+
const results = await searchIssues(query, { workDir, limit: 10 });
|
|
276
|
+
if (results.length === 0) {
|
|
277
|
+
console.log(`No issues found matching "${query}"`);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
console.log(`Found ${results.length} issue(s) matching "${query}":
|
|
281
|
+
`);
|
|
282
|
+
for (const result of results) {
|
|
283
|
+
const i = result.issue;
|
|
284
|
+
const status = i.resolved ? "[RESOLVED]" : "";
|
|
285
|
+
console.log(`[${i.severity.toUpperCase()}] ${status} ${i.issue.slice(0, 80)}`);
|
|
286
|
+
console.log(` File: ${i.file}${i.line ? `:${i.line}` : ""}`);
|
|
287
|
+
console.log(` Agent: ${i.agent} | Score: ${(result.score * 100).toFixed(0)}%`);
|
|
288
|
+
console.log(` Date: ${new Date(i.timestamp).toLocaleDateString()}`);
|
|
289
|
+
console.log("");
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async function handleStats() {
|
|
293
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
294
|
+
const stats = await getMemoryStats(workDir);
|
|
295
|
+
const globalStats = await getGlobalMemoryStats();
|
|
296
|
+
console.log("Local Issue Memory Stats:");
|
|
297
|
+
console.log(` Total Issues: ${stats.totalIssues}`);
|
|
298
|
+
console.log(` Resolved: ${stats.resolvedCount}`);
|
|
299
|
+
if (stats.oldestIssue) {
|
|
300
|
+
console.log(` Date Range: ${stats.oldestIssue.split("T")[0]} to ${stats.newestIssue?.split("T")[0]}`);
|
|
301
|
+
}
|
|
302
|
+
console.log("\n By Severity:");
|
|
303
|
+
for (const [severity, count] of Object.entries(stats.issuesBySeverity)) {
|
|
304
|
+
console.log(` ${severity}: ${count}`);
|
|
305
|
+
}
|
|
306
|
+
console.log("\n By Agent:");
|
|
307
|
+
const sortedAgents = Object.entries(stats.issuesByAgent).sort((a, b) => b[1] - a[1]);
|
|
308
|
+
for (const [agent, count] of sortedAgents.slice(0, 10)) {
|
|
309
|
+
console.log(` ${agent}: ${count}`);
|
|
310
|
+
}
|
|
311
|
+
console.log("\nGlobal Cross-Project Stats:");
|
|
312
|
+
console.log(` Tracked Projects: ${globalStats.trackedProjects}`);
|
|
313
|
+
console.log(` Total Patterns: ${globalStats.totalPatterns}`);
|
|
314
|
+
console.log(` Cross-Project Patterns: ${globalStats.crossProjectPatterns}`);
|
|
315
|
+
console.log(` Fixed Patterns: ${globalStats.fixedPatterns}`);
|
|
316
|
+
}
|
|
317
|
+
async function handleRecent(args) {
|
|
318
|
+
const limit = parseInt(args[0] || "10", 10);
|
|
319
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
320
|
+
const issues = await getRecentIssues({ workDir, limit });
|
|
321
|
+
if (issues.length === 0) {
|
|
322
|
+
console.log("No recent issues found.");
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
console.log(`Recent Issues (last 7 days):
|
|
326
|
+
`);
|
|
327
|
+
for (const i of issues) {
|
|
328
|
+
const status = i.resolved ? "[RESOLVED]" : "";
|
|
329
|
+
console.log(`[${i.severity.toUpperCase()}] ${status} ${i.issue.slice(0, 70)}`);
|
|
330
|
+
console.log(` ${i.file}${i.line ? `:${i.line}` : ""} | ${i.agent}`);
|
|
331
|
+
console.log("");
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async function handleLogs() {
|
|
335
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
336
|
+
const logs = await getDailyLogs(workDir);
|
|
337
|
+
if (logs.length === 0) {
|
|
338
|
+
console.log("No daily logs found.");
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
console.log("Daily Logs (.trie/memory/):\n");
|
|
342
|
+
for (const log of logs.slice(0, 14)) {
|
|
343
|
+
console.log(` ${log}`);
|
|
344
|
+
}
|
|
345
|
+
if (logs.length > 14) {
|
|
346
|
+
console.log(` ... and ${logs.length - 14} more`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
async function handleResolve(args) {
|
|
350
|
+
const issueId = args[0];
|
|
351
|
+
if (!issueId) {
|
|
352
|
+
console.log("Usage: trie memory resolve <issue-id>");
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
356
|
+
const result = await markIssueResolved(issueId, workDir);
|
|
357
|
+
if (result) {
|
|
358
|
+
console.log(`Issue ${issueId} marked as resolved.`);
|
|
359
|
+
} else {
|
|
360
|
+
console.log(`Issue ${issueId} not found.`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async function handleGlobal(args) {
|
|
364
|
+
const action = args[0]?.toLowerCase();
|
|
365
|
+
if (action === "patterns") {
|
|
366
|
+
const patterns = await findCrossProjectPatterns(2);
|
|
367
|
+
if (patterns.length === 0) {
|
|
368
|
+
console.log("No cross-project patterns found yet.");
|
|
369
|
+
console.log("Patterns appear when the same issue is detected in multiple projects.");
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
console.log(`Cross-Project Patterns (${patterns.length}):
|
|
373
|
+
`);
|
|
374
|
+
for (const p of patterns.slice(0, 10)) {
|
|
375
|
+
console.log(`[${p.severity.toUpperCase()}] ${p.pattern.slice(0, 60)}`);
|
|
376
|
+
console.log(` Occurrences: ${p.occurrences} across ${p.projects.length} projects`);
|
|
377
|
+
console.log(` Agent: ${p.agent}`);
|
|
378
|
+
if (p.fixApplied) {
|
|
379
|
+
console.log(` Fixed in: ${p.fixApplied.project}`);
|
|
380
|
+
}
|
|
381
|
+
console.log("");
|
|
382
|
+
}
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (action === "projects") {
|
|
386
|
+
const projects = await listTrackedProjects();
|
|
387
|
+
if (projects.length === 0) {
|
|
388
|
+
console.log("No projects tracked yet.");
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
console.log(`Tracked Projects (${projects.length}):
|
|
392
|
+
`);
|
|
393
|
+
console.log("| Project | Last Scan | Health | Issues |");
|
|
394
|
+
console.log("|---------|-----------|--------|--------|");
|
|
395
|
+
for (const p of projects) {
|
|
396
|
+
console.log(`| ${p.name.slice(0, 20)} | ${p.lastScan.split("T")[0]} | ${p.healthScore}% | ${p.totalIssues} |`);
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (action === "search") {
|
|
401
|
+
const query = args.slice(1).join(" ");
|
|
402
|
+
if (!query) {
|
|
403
|
+
console.log("Usage: trie memory global search <query>");
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const patterns = await searchGlobalPatterns(query, { limit: 10 });
|
|
407
|
+
if (patterns.length === 0) {
|
|
408
|
+
console.log(`No global patterns found matching "${query}"`);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
console.log(`Global patterns matching "${query}":
|
|
412
|
+
`);
|
|
413
|
+
for (const p of patterns) {
|
|
414
|
+
console.log(`[${p.severity.toUpperCase()}] ${p.pattern.slice(0, 60)}`);
|
|
415
|
+
console.log(` Projects: ${p.projects.slice(0, 3).join(", ")}`);
|
|
416
|
+
console.log("");
|
|
417
|
+
}
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (action === "update") {
|
|
421
|
+
await updateGlobalMemoryMd();
|
|
422
|
+
console.log("Updated ~/.trie/memory/GLOBAL_MEMORY.md");
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
console.log(`
|
|
426
|
+
Global Memory Commands:
|
|
427
|
+
trie memory global patterns Show cross-project patterns
|
|
428
|
+
trie memory global projects Show tracked projects
|
|
429
|
+
trie memory global search <q> Search global patterns
|
|
430
|
+
trie memory global update Update GLOBAL_MEMORY.md
|
|
431
|
+
`);
|
|
432
|
+
}
|
|
433
|
+
function showHelp() {
|
|
434
|
+
console.log(`
|
|
435
|
+
Memory - Search and manage issue memory
|
|
436
|
+
|
|
437
|
+
Commands:
|
|
438
|
+
trie memory search <query> Search issues by keyword
|
|
439
|
+
trie memory stats Show memory statistics
|
|
440
|
+
trie memory recent [limit] Show recent issues
|
|
441
|
+
trie memory logs List daily log files
|
|
442
|
+
trie memory resolve <id> Mark issue as resolved
|
|
443
|
+
trie memory global <action> Cross-project memory
|
|
444
|
+
|
|
445
|
+
Examples:
|
|
446
|
+
trie memory search "SQL injection"
|
|
447
|
+
trie memory recent 20
|
|
448
|
+
trie memory global patterns
|
|
449
|
+
`);
|
|
450
|
+
}
|
|
451
|
+
|
|
158
452
|
// src/cli/main.ts
|
|
159
453
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
160
454
|
var __dirname2 = dirname(__filename2);
|
|
@@ -171,7 +465,7 @@ function showBanner() {
|
|
|
171
465
|
Customizable Parallel Agents
|
|
172
466
|
`);
|
|
173
467
|
}
|
|
174
|
-
function
|
|
468
|
+
function showHelp2() {
|
|
175
469
|
showBanner();
|
|
176
470
|
console.log(`Version: ${VERSION}
|
|
177
471
|
|
|
@@ -180,12 +474,15 @@ USAGE:
|
|
|
180
474
|
|
|
181
475
|
COMMANDS:
|
|
182
476
|
help Show this help message
|
|
477
|
+
init Initialize bootstrap files (.trie/RULES.md, etc.)
|
|
183
478
|
setup Configure API key and environment
|
|
184
479
|
scan Scan codebase once and exit
|
|
480
|
+
checkpoint Save context without running a scan
|
|
185
481
|
watch Watch for changes and scan continuously
|
|
186
482
|
agents List all available agents
|
|
187
483
|
skills Manage external skills from skills.sh
|
|
188
484
|
project View/manage project info (.trie/PROJECT.md)
|
|
485
|
+
memory Search and manage issue memory
|
|
189
486
|
version Show version information
|
|
190
487
|
|
|
191
488
|
EXAMPLES:
|
|
@@ -216,6 +513,12 @@ EXAMPLES:
|
|
|
216
513
|
# List installed skills
|
|
217
514
|
trie-agent skills list
|
|
218
515
|
|
|
516
|
+
# Initialize bootstrap files
|
|
517
|
+
trie-agent init
|
|
518
|
+
|
|
519
|
+
# Search issue memory
|
|
520
|
+
trie-agent memory search "SQL injection"
|
|
521
|
+
|
|
219
522
|
MCP TOOLS (use via Cursor/Claude Desktop):
|
|
220
523
|
trie_scan Intelligent scan with agent selection
|
|
221
524
|
trie_fix Generate high-confidence fix prompts
|
|
@@ -235,9 +538,9 @@ MCP TOOLS (use via Cursor/Claude Desktop):
|
|
|
235
538
|
trie_devops DevOps & deployment
|
|
236
539
|
trie_clean Clean up AI-generated code
|
|
237
540
|
|
|
238
|
-
Custom
|
|
239
|
-
|
|
240
|
-
|
|
541
|
+
Custom Skills:
|
|
542
|
+
trie_create_skill Create skill from PDF/TXT/MD document
|
|
543
|
+
trie_list_skills List all registered skills
|
|
241
544
|
|
|
242
545
|
NOTE: No API key required! Trie uses your AI tool's built-in Claude.
|
|
243
546
|
|
|
@@ -310,34 +613,34 @@ BUILT-IN AGENTS:
|
|
|
310
613
|
moneybags Estimates dollar cost of bugs (IBM/NIST cost models)
|
|
311
614
|
production-ready Production gate: health checks, scaling, security headers
|
|
312
615
|
|
|
313
|
-
Custom
|
|
616
|
+
Custom Skills:
|
|
314
617
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
315
|
-
const
|
|
316
|
-
if (existsSync(
|
|
618
|
+
const skillsDir = join(getWorkingDirectory(void 0, true), ".trie", "agents");
|
|
619
|
+
if (existsSync(skillsDir)) {
|
|
317
620
|
try {
|
|
318
621
|
const { readdirSync } = __require("fs");
|
|
319
|
-
const files = readdirSync(
|
|
622
|
+
const files = readdirSync(skillsDir).filter((f) => f.endsWith(".json"));
|
|
320
623
|
if (files.length > 0) {
|
|
321
624
|
for (const file of files) {
|
|
322
|
-
const config = JSON.parse(readFileSync(join(
|
|
323
|
-
console.log(` ${config.name.padEnd(18)} ${config.description || "Custom
|
|
625
|
+
const config = JSON.parse(readFileSync(join(skillsDir, file), "utf-8"));
|
|
626
|
+
console.log(` ${config.name.padEnd(18)} ${config.description || "Custom skill"}`);
|
|
324
627
|
}
|
|
325
628
|
} else {
|
|
326
|
-
console.log(` (No custom
|
|
629
|
+
console.log(` (No custom skills found)`);
|
|
327
630
|
}
|
|
328
631
|
} catch {
|
|
329
|
-
console.log(` (No custom
|
|
632
|
+
console.log(` (No custom skills found)`);
|
|
330
633
|
}
|
|
331
634
|
} else {
|
|
332
|
-
console.log(` (No custom
|
|
635
|
+
console.log(` (No custom skills found)`);
|
|
333
636
|
}
|
|
334
637
|
console.log(`
|
|
335
|
-
CREATE CUSTOM
|
|
638
|
+
CREATE CUSTOM SKILLS:
|
|
336
639
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
337
|
-
You can create
|
|
640
|
+
You can create skills from PDF, TXT, or MD documents:
|
|
338
641
|
|
|
339
|
-
Via MCP: Use
|
|
340
|
-
CLI: trie-create --file book.pdf --name my-
|
|
642
|
+
Via MCP: Use trie_create_skill tool
|
|
643
|
+
CLI: trie-create --file book.pdf --name my-skill
|
|
341
644
|
|
|
342
645
|
The agent will learn patterns from your document and apply them
|
|
343
646
|
to code reviews. Great for style guides, compliance docs, etc.
|
|
@@ -477,16 +780,28 @@ function main() {
|
|
|
477
780
|
const command = args[0]?.toLowerCase();
|
|
478
781
|
const restArgs = args.slice(1);
|
|
479
782
|
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
480
|
-
|
|
783
|
+
showHelp2();
|
|
481
784
|
process.exit(0);
|
|
482
785
|
}
|
|
483
786
|
switch (command) {
|
|
484
787
|
case "setup":
|
|
485
788
|
case "config":
|
|
486
789
|
case "configure":
|
|
487
|
-
case "init":
|
|
488
790
|
showSetup();
|
|
489
791
|
break;
|
|
792
|
+
case "init":
|
|
793
|
+
case "bootstrap":
|
|
794
|
+
handleInitCommand(restArgs);
|
|
795
|
+
break;
|
|
796
|
+
case "memory":
|
|
797
|
+
case "mem":
|
|
798
|
+
handleMemoryCommand(restArgs);
|
|
799
|
+
break;
|
|
800
|
+
case "checkpoint":
|
|
801
|
+
case "cp":
|
|
802
|
+
case "save":
|
|
803
|
+
handleCheckpointCommand(restArgs);
|
|
804
|
+
break;
|
|
490
805
|
case "agents":
|
|
491
806
|
case "list":
|
|
492
807
|
case "list-agents":
|