@triedotdev/mcp 1.0.168 → 1.0.170

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.
Files changed (149) hide show
  1. package/README.md +54 -500
  2. package/dist/chunk-2YXOBNKW.js +619 -0
  3. package/dist/chunk-2YXOBNKW.js.map +1 -0
  4. package/dist/chunk-QR64Y5TI.js +363 -0
  5. package/dist/chunk-QR64Y5TI.js.map +1 -0
  6. package/dist/cli/main.d.ts +0 -15
  7. package/dist/cli/main.js +356 -3100
  8. package/dist/cli/main.js.map +1 -1
  9. package/dist/index.js +2 -36
  10. package/dist/index.js.map +1 -1
  11. package/dist/server/mcp-server.js +2 -36
  12. package/package.json +8 -31
  13. package/dist/autonomy-config-FSERX3O3.js +0 -30
  14. package/dist/autonomy-config-FSERX3O3.js.map +0 -1
  15. package/dist/chat-store-JNGNTDSN.js +0 -15
  16. package/dist/chat-store-JNGNTDSN.js.map +0 -1
  17. package/dist/chunk-2HF65EHQ.js +0 -311
  18. package/dist/chunk-2HF65EHQ.js.map +0 -1
  19. package/dist/chunk-43X6JBEM.js +0 -36
  20. package/dist/chunk-43X6JBEM.js.map +0 -1
  21. package/dist/chunk-4MXH2ZPT.js +0 -1827
  22. package/dist/chunk-4MXH2ZPT.js.map +0 -1
  23. package/dist/chunk-575YT2SD.js +0 -737
  24. package/dist/chunk-575YT2SD.js.map +0 -1
  25. package/dist/chunk-5BRRRTN6.js +0 -354
  26. package/dist/chunk-5BRRRTN6.js.map +0 -1
  27. package/dist/chunk-6NLHFIYA.js +0 -344
  28. package/dist/chunk-6NLHFIYA.js.map +0 -1
  29. package/dist/chunk-7WITSO22.js +0 -824
  30. package/dist/chunk-7WITSO22.js.map +0 -1
  31. package/dist/chunk-DGUM43GV.js +0 -11
  32. package/dist/chunk-DGUM43GV.js.map +0 -1
  33. package/dist/chunk-EFWVF6TI.js +0 -267
  34. package/dist/chunk-EFWVF6TI.js.map +0 -1
  35. package/dist/chunk-F6WFNUAY.js +0 -216
  36. package/dist/chunk-F6WFNUAY.js.map +0 -1
  37. package/dist/chunk-FQ45QP5A.js +0 -361
  38. package/dist/chunk-FQ45QP5A.js.map +0 -1
  39. package/dist/chunk-G2TGF6TR.js +0 -573
  40. package/dist/chunk-G2TGF6TR.js.map +0 -1
  41. package/dist/chunk-GTKYBOXL.js +0 -700
  42. package/dist/chunk-GTKYBOXL.js.map +0 -1
  43. package/dist/chunk-HVCDY3AK.js +0 -850
  44. package/dist/chunk-HVCDY3AK.js.map +0 -1
  45. package/dist/chunk-JVMBCWKS.js +0 -348
  46. package/dist/chunk-JVMBCWKS.js.map +0 -1
  47. package/dist/chunk-KDHN2ZQE.js +0 -313
  48. package/dist/chunk-KDHN2ZQE.js.map +0 -1
  49. package/dist/chunk-LQIMKE3P.js +0 -12524
  50. package/dist/chunk-LQIMKE3P.js.map +0 -1
  51. package/dist/chunk-ME2OERF5.js +0 -345
  52. package/dist/chunk-ME2OERF5.js.map +0 -1
  53. package/dist/chunk-MRHKX5M5.js +0 -662
  54. package/dist/chunk-MRHKX5M5.js.map +0 -1
  55. package/dist/chunk-OBQ74FOU.js +0 -27
  56. package/dist/chunk-OBQ74FOU.js.map +0 -1
  57. package/dist/chunk-OMR4YCBS.js +0 -987
  58. package/dist/chunk-OMR4YCBS.js.map +0 -1
  59. package/dist/chunk-Q5EKA5YA.js +0 -254
  60. package/dist/chunk-Q5EKA5YA.js.map +0 -1
  61. package/dist/chunk-Q63FFI6D.js +0 -132
  62. package/dist/chunk-Q63FFI6D.js.map +0 -1
  63. package/dist/chunk-SY6KQG44.js +0 -983
  64. package/dist/chunk-SY6KQG44.js.map +0 -1
  65. package/dist/chunk-T63OHG4Q.js +0 -440
  66. package/dist/chunk-T63OHG4Q.js.map +0 -1
  67. package/dist/chunk-TN5WEKWI.js +0 -173
  68. package/dist/chunk-TN5WEKWI.js.map +0 -1
  69. package/dist/chunk-VUL52BQL.js +0 -402
  70. package/dist/chunk-VUL52BQL.js.map +0 -1
  71. package/dist/chunk-VVITXIHN.js +0 -189
  72. package/dist/chunk-VVITXIHN.js.map +0 -1
  73. package/dist/chunk-WCN7S3EI.js +0 -14
  74. package/dist/chunk-WCN7S3EI.js.map +0 -1
  75. package/dist/chunk-XE6KQRKZ.js +0 -816
  76. package/dist/chunk-XE6KQRKZ.js.map +0 -1
  77. package/dist/chunk-XPZZFPBZ.js +0 -491
  78. package/dist/chunk-XPZZFPBZ.js.map +0 -1
  79. package/dist/chunk-XTFWT2XM.js +0 -727
  80. package/dist/chunk-XTFWT2XM.js.map +0 -1
  81. package/dist/chunk-YDHUCDHM.js +0 -4011
  82. package/dist/chunk-YDHUCDHM.js.map +0 -1
  83. package/dist/chunk-YZ6Y2H3P.js +0 -1289
  84. package/dist/chunk-YZ6Y2H3P.js.map +0 -1
  85. package/dist/chunk-ZJF5FTBX.js +0 -1396
  86. package/dist/chunk-ZJF5FTBX.js.map +0 -1
  87. package/dist/chunk-ZV2K6M7T.js +0 -74
  88. package/dist/chunk-ZV2K6M7T.js.map +0 -1
  89. package/dist/cli/create-agent.d.ts +0 -1
  90. package/dist/cli/create-agent.js +0 -1050
  91. package/dist/cli/create-agent.js.map +0 -1
  92. package/dist/cli/yolo-daemon.d.ts +0 -1
  93. package/dist/cli/yolo-daemon.js +0 -423
  94. package/dist/cli/yolo-daemon.js.map +0 -1
  95. package/dist/client-NJPZE5JT.js +0 -28
  96. package/dist/client-NJPZE5JT.js.map +0 -1
  97. package/dist/codebase-index-VAPF32XX.js +0 -12
  98. package/dist/codebase-index-VAPF32XX.js.map +0 -1
  99. package/dist/fast-analyzer-XXYMOXRK.js +0 -216
  100. package/dist/fast-analyzer-XXYMOXRK.js.map +0 -1
  101. package/dist/git-EO5SRFMN.js +0 -28
  102. package/dist/git-EO5SRFMN.js.map +0 -1
  103. package/dist/github-ingester-ZOKK6GRS.js +0 -11
  104. package/dist/github-ingester-ZOKK6GRS.js.map +0 -1
  105. package/dist/goal-manager-YOB7VWK7.js +0 -25
  106. package/dist/goal-manager-YOB7VWK7.js.map +0 -1
  107. package/dist/goal-validator-ULKIBDPX.js +0 -24
  108. package/dist/goal-validator-ULKIBDPX.js.map +0 -1
  109. package/dist/graph-B3NA4S7I.js +0 -10
  110. package/dist/graph-B3NA4S7I.js.map +0 -1
  111. package/dist/hypothesis-7BFFT5JY.js +0 -23
  112. package/dist/hypothesis-7BFFT5JY.js.map +0 -1
  113. package/dist/incident-index-EFNUSGWL.js +0 -11
  114. package/dist/incident-index-EFNUSGWL.js.map +0 -1
  115. package/dist/insight-store-EC4PLSAW.js +0 -22
  116. package/dist/insight-store-EC4PLSAW.js.map +0 -1
  117. package/dist/issue-store-ZIRP23EP.js +0 -36
  118. package/dist/issue-store-ZIRP23EP.js.map +0 -1
  119. package/dist/ledger-TWZTGDFA.js +0 -58
  120. package/dist/ledger-TWZTGDFA.js.map +0 -1
  121. package/dist/linear-ingester-XXPAZZRW.js +0 -11
  122. package/dist/linear-ingester-XXPAZZRW.js.map +0 -1
  123. package/dist/output-manager-RVJ37XKA.js +0 -13
  124. package/dist/output-manager-RVJ37XKA.js.map +0 -1
  125. package/dist/parse-goal-violation-SACGFG3C.js +0 -8
  126. package/dist/parse-goal-violation-SACGFG3C.js.map +0 -1
  127. package/dist/pattern-discovery-F7LU5K6E.js +0 -8
  128. package/dist/pattern-discovery-F7LU5K6E.js.map +0 -1
  129. package/dist/progress-SRQ2V3BP.js +0 -18
  130. package/dist/progress-SRQ2V3BP.js.map +0 -1
  131. package/dist/project-state-AHPA77SM.js +0 -28
  132. package/dist/project-state-AHPA77SM.js.map +0 -1
  133. package/dist/sync-M2FSWPBC.js +0 -12
  134. package/dist/sync-M2FSWPBC.js.map +0 -1
  135. package/dist/terminal-spawn-5YXDMUCF.js +0 -157
  136. package/dist/terminal-spawn-5YXDMUCF.js.map +0 -1
  137. package/dist/tiered-storage-Z3YCR465.js +0 -12
  138. package/dist/tiered-storage-Z3YCR465.js.map +0 -1
  139. package/dist/trie-agent-3YDPEGHJ.js +0 -28
  140. package/dist/trie-agent-3YDPEGHJ.js.map +0 -1
  141. package/dist/ui/chat.html +0 -1014
  142. package/dist/ui/goals.html +0 -967
  143. package/dist/ui/hypotheses.html +0 -1011
  144. package/dist/ui/ledger.html +0 -954
  145. package/dist/ui/nudges.html +0 -995
  146. package/dist/vibe-code-signatures-F6URTBW3.js +0 -16
  147. package/dist/vibe-code-signatures-F6URTBW3.js.map +0 -1
  148. package/dist/vulnerability-signatures-T7SKHORW.js +0 -18
  149. package/dist/vulnerability-signatures-T7SKHORW.js.map +0 -1
@@ -1,1050 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- getTrieDirectory,
4
- getWorkingDirectory
5
- } from "../chunk-VVITXIHN.js";
6
- import "../chunk-KDHN2ZQE.js";
7
- import "../chunk-DGUM43GV.js";
8
-
9
- // src/ingest/agent-builder.ts
10
- import Anthropic2 from "@anthropic-ai/sdk";
11
-
12
- // src/ingest/document-parser.ts
13
- import { readFile } from "fs/promises";
14
- import { extname, basename } from "path";
15
- async function parseDocument(filePath) {
16
- const ext = extname(filePath).toLowerCase();
17
- const fileType = getFileType(ext);
18
- if (!fileType) {
19
- throw new Error(`Unsupported file type: ${ext}. Supported: .txt, .md, .rtf`);
20
- }
21
- let rawText;
22
- let metadata = {
23
- fileType,
24
- originalPath: filePath,
25
- parsedAt: (/* @__PURE__ */ new Date()).toISOString()
26
- };
27
- switch (fileType) {
28
- case "txt":
29
- rawText = await parseTXT(filePath);
30
- break;
31
- case "md":
32
- rawText = await parseMarkdown(filePath);
33
- break;
34
- case "rtf":
35
- rawText = await parseRTF(filePath);
36
- break;
37
- default:
38
- throw new Error(`Unsupported file type: ${fileType}`);
39
- }
40
- metadata.wordCount = countWords(rawText);
41
- const sections = extractSections(rawText, fileType);
42
- if (!metadata.title) {
43
- metadata.title = extractTitle(rawText, sections) || basename(filePath, ext);
44
- }
45
- return {
46
- rawText,
47
- metadata,
48
- sections
49
- };
50
- }
51
- function getFileType(ext) {
52
- const typeMap = {
53
- ".txt": "txt",
54
- ".md": "md",
55
- ".markdown": "md",
56
- ".rtf": "rtf"
57
- };
58
- return typeMap[ext] || null;
59
- }
60
- async function parseTXT(filePath) {
61
- return await readFile(filePath, "utf-8");
62
- }
63
- async function parseMarkdown(filePath) {
64
- const content = await readFile(filePath, "utf-8");
65
- return content.replace(/^[-*_]{3,}$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
66
- }
67
- async function parseRTF(filePath) {
68
- const content = await readFile(filePath, "utf-8");
69
- return stripRTF(content);
70
- }
71
- function stripRTF(rtf) {
72
- let text = rtf.replace(/^{\\rtf1[^}]*}/i, "");
73
- text = text.replace(/\\[a-z]+(-?\d+)?[ ]?/gi, "");
74
- text = text.replace(/{[^{}]*}/g, "");
75
- text = text.replace(/\\'([0-9a-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))).replace(/\\par\b/g, "\n").replace(/\\tab\b/g, " ").replace(/\\line\b/g, "\n").replace(/[{}\\]/g, "");
76
- text = text.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
77
- return text;
78
- }
79
- function countWords(text) {
80
- return text.split(/\s+/).filter((word) => word.length > 0).length;
81
- }
82
- function extractSections(text, fileType) {
83
- const sections = [];
84
- if (fileType === "md") {
85
- const headingRegex = /^(#{1,6})\s+(.+)$/gm;
86
- let match;
87
- while ((match = headingRegex.exec(text)) !== null) {
88
- const level = match[1].length;
89
- const title = match[2].trim();
90
- const startIndex = match.index;
91
- if (sections.length > 0) {
92
- const lastSection = sections[sections.length - 1];
93
- lastSection.endIndex = startIndex;
94
- lastSection.content = text.slice(
95
- lastSection.startIndex,
96
- startIndex
97
- ).trim();
98
- }
99
- sections.push({
100
- title,
101
- level,
102
- startIndex,
103
- endIndex: text.length,
104
- content: ""
105
- });
106
- }
107
- if (sections.length > 0) {
108
- const lastSection = sections[sections.length - 1];
109
- lastSection.content = text.slice(
110
- lastSection.startIndex
111
- ).trim();
112
- }
113
- } else {
114
- const chapterPatterns = [
115
- /^chapter\s+(\d+|[ivxlc]+)[:\.\s]+(.*)$/gim,
116
- /^section\s+(\d+|[ivxlc]+)[:\.\s]+(.*)$/gim,
117
- /^part\s+(\d+|[ivxlc]+)[:\.\s]+(.*)$/gim,
118
- /^(\d+)\.\s+([A-Z][^.]+)$/gm,
119
- /^([A-Z][A-Z\s]+)$/gm
120
- // ALL CAPS headings
121
- ];
122
- for (const pattern of chapterPatterns) {
123
- let match;
124
- pattern.lastIndex = 0;
125
- while ((match = pattern.exec(text)) !== null) {
126
- const title = match[2] || match[1] || match[0];
127
- sections.push({
128
- title: title.trim(),
129
- level: 1,
130
- startIndex: match.index,
131
- endIndex: text.length,
132
- content: ""
133
- });
134
- }
135
- if (sections.length > 0) break;
136
- }
137
- sections.sort((a, b) => a.startIndex - b.startIndex);
138
- for (let i = 0; i < sections.length; i++) {
139
- const section = sections[i];
140
- const nextSection = sections[i + 1];
141
- const endIndex = nextSection !== void 0 ? nextSection.startIndex : text.length;
142
- section.endIndex = endIndex;
143
- section.content = text.slice(section.startIndex, endIndex).trim();
144
- }
145
- }
146
- if (sections.length === 0) {
147
- sections.push({
148
- title: "Document Content",
149
- level: 1,
150
- startIndex: 0,
151
- endIndex: text.length,
152
- content: text.trim()
153
- });
154
- }
155
- return sections;
156
- }
157
- function extractTitle(text, sections) {
158
- const firstSection = sections[0];
159
- if (firstSection !== void 0 && firstSection.title !== "Document Content") {
160
- return firstSection.title;
161
- }
162
- const firstLine = text.split("\n")[0]?.trim();
163
- if (firstLine && firstLine.length < 100 && !firstLine.includes(".")) {
164
- return firstLine;
165
- }
166
- return null;
167
- }
168
- function chunkDocument(result, maxChunkSize = 4e3) {
169
- const chunks = [];
170
- if (result.rawText.length <= maxChunkSize) {
171
- return [result.rawText];
172
- }
173
- if (result.sections.length > 1) {
174
- let currentChunk = "";
175
- for (const section of result.sections) {
176
- const sectionText = `## ${section.title}
177
-
178
- ${section.content}
179
-
180
- `;
181
- if (currentChunk.length + sectionText.length > maxChunkSize) {
182
- if (currentChunk) chunks.push(currentChunk.trim());
183
- if (sectionText.length > maxChunkSize) {
184
- chunks.push(...splitByParagraphs(sectionText, maxChunkSize));
185
- currentChunk = "";
186
- } else {
187
- currentChunk = sectionText;
188
- }
189
- } else {
190
- currentChunk += sectionText;
191
- }
192
- }
193
- if (currentChunk) chunks.push(currentChunk.trim());
194
- } else {
195
- chunks.push(...splitByParagraphs(result.rawText, maxChunkSize));
196
- }
197
- return chunks;
198
- }
199
- function splitByParagraphs(text, maxSize) {
200
- const chunks = [];
201
- const paragraphs = text.split(/\n\s*\n/);
202
- let currentChunk = "";
203
- for (const para of paragraphs) {
204
- if (currentChunk.length + para.length + 2 > maxSize) {
205
- if (currentChunk) chunks.push(currentChunk.trim());
206
- if (para.length > maxSize) {
207
- chunks.push(...splitBySentences(para, maxSize));
208
- currentChunk = "";
209
- } else {
210
- currentChunk = para;
211
- }
212
- } else {
213
- currentChunk += (currentChunk ? "\n\n" : "") + para;
214
- }
215
- }
216
- if (currentChunk) chunks.push(currentChunk.trim());
217
- return chunks;
218
- }
219
- function splitBySentences(text, maxSize) {
220
- const chunks = [];
221
- const sentences = text.match(/[^.!?]+[.!?]+/g) || [text];
222
- let currentChunk = "";
223
- for (const sentence of sentences) {
224
- if (currentChunk.length + sentence.length > maxSize) {
225
- if (currentChunk) chunks.push(currentChunk.trim());
226
- currentChunk = sentence;
227
- } else {
228
- currentChunk += sentence;
229
- }
230
- }
231
- if (currentChunk) chunks.push(currentChunk.trim());
232
- return chunks;
233
- }
234
-
235
- // src/ingest/knowledge-compressor.ts
236
- import Anthropic from "@anthropic-ai/sdk";
237
-
238
- // src/ingest/compression-prompts.ts
239
- var COMPRESSION_PROMPTS = {
240
- /**
241
- * System prompt for the knowledge extractor
242
- */
243
- system: `You are an expert knowledge extraction system. Your job is to analyze documents and extract structured, actionable knowledge that can be used by a code review agent.
244
-
245
- You must output valid JSON that matches the required schema exactly. Be thorough but concise - extract the essence of the knowledge without unnecessary verbosity.
246
-
247
- Focus on:
248
- 1. Core concepts that are fundamental to understand the material
249
- 2. Best practices that should be followed
250
- 3. Anti-patterns and mistakes to avoid
251
- 4. Detection patterns that could identify issues in code
252
- 5. Key terminology and definitions`,
253
- /**
254
- * Prompt for extracting knowledge from a chunk
255
- */
256
- extractChunk: `Analyze this document chunk and extract structured knowledge.
257
-
258
- ## Document Chunk:
259
- {{chunk}}
260
-
261
- ## Instructions:
262
- Extract the following from this chunk:
263
-
264
- 1. **Core Concepts**: Key ideas, principles, or rules that are taught
265
- 2. **Best Practices**: Recommended approaches or patterns
266
- 3. **Anti-Patterns**: Things to avoid, common mistakes
267
- 4. **Code Patterns**: Any code patterns or detection rules that could identify issues
268
- 5. **Terminology**: Important terms and their definitions
269
-
270
- Output as JSON:
271
- {
272
- "coreConcepts": [
273
- {
274
- "name": "string",
275
- "description": "string",
276
- "importance": "critical" | "important" | "supplementary",
277
- "keywords": ["string"]
278
- }
279
- ],
280
- "bestPractices": [
281
- {
282
- "name": "string",
283
- "description": "string",
284
- "rationale": "string",
285
- "codeExample": "string or null"
286
- }
287
- ],
288
- "antiPatterns": [
289
- {
290
- "name": "string",
291
- "description": "string",
292
- "whyBad": "string",
293
- "betterAlternative": "string"
294
- }
295
- ],
296
- "codePatterns": [
297
- {
298
- "name": "string",
299
- "description": "string",
300
- "type": "best-practice" | "anti-pattern" | "security" | "compliance",
301
- "regexHint": "string (a regex pattern that might detect this, or null)",
302
- "keywords": ["string"]
303
- }
304
- ],
305
- "terminology": {
306
- "term": "definition"
307
- }
308
- }
309
-
310
- Only include items that are clearly present in the chunk. Quality over quantity.`,
311
- /**
312
- * Prompt for merging extracted knowledge
313
- */
314
- mergeKnowledge: `Merge and deduplicate these knowledge extractions into a cohesive summary.
315
-
316
- ## Extractions to Merge:
317
- {{extractions}}
318
-
319
- ## Instructions:
320
- 1. Combine similar concepts
321
- 2. Remove duplicates
322
- 3. Prioritize the most important items
323
- 4. Ensure consistency in terminology
324
- 5. Rank items by importance
325
-
326
- Output a single merged JSON with the same structure, keeping only the most valuable and distinct items.
327
- Limit to top 20 core concepts, 15 best practices, 15 anti-patterns, and 25 code patterns.`,
328
- /**
329
- * Prompt for generating detection rules
330
- */
331
- generateDetectionRules: `Based on this knowledge base, generate detection rules for a code review agent.
332
-
333
- ## Knowledge Base:
334
- {{knowledge}}
335
-
336
- ## Document Context:
337
- - Title: {{title}}
338
- - Domain: {{domain}}
339
- - Word Count: {{wordCount}}
340
-
341
- ## Instructions:
342
- For each anti-pattern and best practice, generate detection rules that could find violations in code.
343
-
344
- For each rule, provide:
345
- 1. A unique ID (format: {{prefix}}-XXX)
346
- 2. Clear name and description
347
- 3. Severity (critical, serious, moderate, low, info)
348
- 4. Detection patterns:
349
- - regex: Array of regex patterns (JavaScript-compatible)
350
- - keywords: Words that might indicate this issue
351
- - semantic: Natural language description for AI-based detection
352
- 5. Fix information:
353
- - description: How to fix
354
- - example: Code example if applicable
355
- - autoFixable: boolean
356
-
357
- Output as JSON array of detection rules:
358
- [
359
- {
360
- "id": "string",
361
- "name": "string",
362
- "description": "string",
363
- "severity": "critical" | "serious" | "moderate" | "low" | "info",
364
- "patterns": {
365
- "regex": ["string"],
366
- "keywords": ["string"],
367
- "semantic": "string"
368
- },
369
- "fix": {
370
- "description": "string",
371
- "example": "string or null",
372
- "autoFixable": boolean
373
- },
374
- "regulation": "string or null (for legal/compliance rules)",
375
- "category": "string"
376
- }
377
- ]
378
-
379
- Generate 15-30 detection rules prioritizing the most impactful issues.`,
380
- /**
381
- * Prompt for generating agent prompts
382
- */
383
- generateAgentPrompts: `Generate system and analysis prompts for a code review agent based on this knowledge.
384
-
385
- ## Knowledge Base Summary:
386
- {{summary}}
387
-
388
- ## Core Concepts:
389
- {{concepts}}
390
-
391
- ## Detection Focus:
392
- {{patterns}}
393
-
394
- ## Agent Info:
395
- - Name: {{agentName}}
396
- - Category: {{category}}
397
- - Domain: {{domain}}
398
-
399
- ## Instructions:
400
- Generate:
401
- 1. A system prompt that gives the agent its persona and expertise
402
- 2. An analysis prompt template for reviewing code
403
- 3. A fix prompt template for suggesting fixes
404
-
405
- The prompts should:
406
- - Reference the specific knowledge from the document
407
- - Be authoritative but helpful
408
- - Include the key concepts and terminology
409
- - Guide the agent to look for the specific patterns
410
-
411
- Output as JSON:
412
- {
413
- "systemPrompt": "string",
414
- "analysisPrompt": "string (use {{code}}, {{filePath}}, {{language}} as placeholders)",
415
- "fixPrompt": "string (use {{issue}}, {{code}}, {{filePath}} as placeholders)"
416
- }`,
417
- /**
418
- * Prompt for detecting document domain
419
- */
420
- detectDomain: `Analyze this document and determine its primary domain/category.
421
-
422
- ## Document Title:
423
- {{title}}
424
-
425
- ## Sample Content:
426
- {{sample}}
427
-
428
- ## Instructions:
429
- Determine the primary domain of this document. Choose ONE:
430
- - "technical": Programming, frameworks, libraries, code patterns
431
- - "legal": Laws, regulations, compliance (GDPR, HIPAA, etc.)
432
- - "policy": Company policies, internal rules, guidelines
433
- - "security": Security practices, vulnerability prevention
434
- - "architecture": System design, patterns, architecture principles
435
- - "general": General knowledge, doesn't fit other categories
436
-
437
- Also determine:
438
- 1. What types of code/files this knowledge applies to
439
- 2. What context signals should trigger this agent
440
- 3. Key content patterns to look for
441
-
442
- Output as JSON:
443
- {
444
- "domain": "technical" | "legal" | "policy" | "security" | "architecture" | "general",
445
- "filePatterns": ["*.ext", ...],
446
- "contentPatterns": ["regex pattern", ...],
447
- "contextSignals": ["touchesAuth", "touchesUI", ...],
448
- "reasoning": "Brief explanation of why this domain was chosen"
449
- }`,
450
- /**
451
- * Prompt for generating a summary
452
- */
453
- generateSummary: `Create a concise executive summary of this document for use in an AI agent's context.
454
-
455
- ## Document:
456
- {{content}}
457
-
458
- ## Instructions:
459
- Write a 2-3 paragraph summary that:
460
- 1. Explains what the document covers
461
- 2. Highlights the most important takeaways
462
- 3. Describes how this knowledge applies to code review
463
-
464
- The summary will be used as context for an AI code review agent, so focus on actionable insights.
465
-
466
- Keep it under 500 words.`
467
- };
468
-
469
- // src/ingest/knowledge-compressor.ts
470
- async function compressKnowledge(document, options) {
471
- const { agentName, maxChunkSize = 4e3, verbose = false } = options;
472
- const client = new Anthropic();
473
- const log = verbose ? console.error.bind(console) : () => {
474
- };
475
- log("\u{1F4DA} Starting knowledge compression...");
476
- log(" \u251C\u2500 Detecting document domain...");
477
- const domainInfo = await detectDomain(client, document);
478
- log(` \u2502 \u2514\u2500 Domain: ${domainInfo.domain}`);
479
- const chunks = chunkDocument(document, maxChunkSize);
480
- log(` \u251C\u2500 Document chunked into ${chunks.length} pieces`);
481
- log(" \u251C\u2500 Extracting knowledge from chunks...");
482
- const extractions = [];
483
- for (let i = 0; i < chunks.length; i++) {
484
- log(` \u2502 \u251C\u2500 Processing chunk ${i + 1}/${chunks.length}...`);
485
- try {
486
- const chunk = chunks[i];
487
- if (chunk !== void 0) {
488
- const extraction = await extractFromChunk(client, chunk);
489
- extractions.push(extraction);
490
- }
491
- } catch (error) {
492
- log(` \u2502 \u2502 \u2514\u2500 Warning: Failed to extract from chunk ${i + 1}`);
493
- }
494
- }
495
- log(" \u251C\u2500 Merging and deduplicating knowledge...");
496
- const mergedKnowledge = await mergeExtractions(client, extractions);
497
- log(" \u251C\u2500 Generating detection rules...");
498
- const detectionRules = await generateDetectionRules(
499
- client,
500
- mergedKnowledge,
501
- document.metadata.title || agentName,
502
- domainInfo.domain,
503
- agentName
504
- );
505
- log(` \u2502 \u2514\u2500 Generated ${detectionRules.length} detection rules`);
506
- log(" \u2514\u2500 Generating knowledge summary...");
507
- const summary = await generateSummary(client, document.rawText.slice(0, 8e3));
508
- const compressed = {
509
- domain: domainInfo.domain,
510
- summary,
511
- coreConcepts: mergedKnowledge.coreConcepts,
512
- bestPractices: mergedKnowledge.bestPractices,
513
- antiPatterns: mergedKnowledge.antiPatterns,
514
- detectionRules,
515
- glossary: mergedKnowledge.terminology,
516
- sourceDocument: {
517
- title: document.metadata.title || agentName,
518
- wordCount: document.metadata.wordCount,
519
- compressionRatio: Math.round(document.metadata.wordCount / (summary.length + JSON.stringify(detectionRules).length / 5))
520
- }
521
- };
522
- return compressed;
523
- }
524
- async function detectDomain(client, document) {
525
- const sampleSize = Math.min(document.rawText.length, 3e3);
526
- const sample = document.rawText.slice(0, sampleSize);
527
- const prompt = COMPRESSION_PROMPTS.detectDomain.replace("{{title}}", document.metadata.title || "Unknown").replace("{{sample}}", sample);
528
- const response = await client.messages.create({
529
- model: "claude-sonnet-4-20250514",
530
- max_tokens: 1e3,
531
- system: COMPRESSION_PROMPTS.system,
532
- messages: [{ role: "user", content: prompt }]
533
- });
534
- const firstContent = response.content[0];
535
- const text = firstContent !== void 0 && firstContent.type === "text" ? firstContent.text : "";
536
- try {
537
- const jsonMatch = text.match(/\{[\s\S]*\}/);
538
- if (jsonMatch) {
539
- return JSON.parse(jsonMatch[0]);
540
- }
541
- } catch (e) {
542
- }
543
- return {
544
- domain: "general",
545
- filePatterns: ["*"],
546
- contentPatterns: [],
547
- contextSignals: [],
548
- reasoning: "Could not determine domain, using general"
549
- };
550
- }
551
- async function extractFromChunk(client, chunk) {
552
- const prompt = COMPRESSION_PROMPTS.extractChunk.replace("{{chunk}}", chunk);
553
- const response = await client.messages.create({
554
- model: "claude-sonnet-4-20250514",
555
- max_tokens: 4e3,
556
- system: COMPRESSION_PROMPTS.system,
557
- messages: [{ role: "user", content: prompt }]
558
- });
559
- const firstContent = response.content[0];
560
- const text = firstContent !== void 0 && firstContent.type === "text" ? firstContent.text : "";
561
- try {
562
- const jsonMatch = text.match(/\{[\s\S]*\}/);
563
- if (jsonMatch) {
564
- const parsed = JSON.parse(jsonMatch[0]);
565
- return {
566
- coreConcepts: parsed.coreConcepts || [],
567
- bestPractices: parsed.bestPractices || [],
568
- antiPatterns: parsed.antiPatterns || [],
569
- codePatterns: parsed.codePatterns || [],
570
- terminology: parsed.terminology || {}
571
- };
572
- }
573
- } catch (e) {
574
- }
575
- return {
576
- coreConcepts: [],
577
- bestPractices: [],
578
- antiPatterns: [],
579
- codePatterns: [],
580
- terminology: {}
581
- };
582
- }
583
- async function mergeExtractions(client, extractions) {
584
- if (extractions.length <= 2) {
585
- return combineExtractions(extractions);
586
- }
587
- const prompt = COMPRESSION_PROMPTS.mergeKnowledge.replace("{{extractions}}", JSON.stringify(extractions, null, 2));
588
- const response = await client.messages.create({
589
- model: "claude-sonnet-4-20250514",
590
- max_tokens: 8e3,
591
- system: COMPRESSION_PROMPTS.system,
592
- messages: [{ role: "user", content: prompt }]
593
- });
594
- const firstContent = response.content[0];
595
- const text = firstContent !== void 0 && firstContent.type === "text" ? firstContent.text : "";
596
- try {
597
- const jsonMatch = text.match(/\{[\s\S]*\}/);
598
- if (jsonMatch) {
599
- return JSON.parse(jsonMatch[0]);
600
- }
601
- } catch (e) {
602
- }
603
- return combineExtractions(extractions);
604
- }
605
- function combineExtractions(extractions) {
606
- const combined = {
607
- coreConcepts: [],
608
- bestPractices: [],
609
- antiPatterns: [],
610
- codePatterns: [],
611
- terminology: {}
612
- };
613
- const seenConcepts = /* @__PURE__ */ new Set();
614
- const seenPractices = /* @__PURE__ */ new Set();
615
- const seenAntiPatterns = /* @__PURE__ */ new Set();
616
- const seenPatterns = /* @__PURE__ */ new Set();
617
- for (const extraction of extractions) {
618
- for (const concept of extraction.coreConcepts) {
619
- const key = concept.name.toLowerCase();
620
- if (!seenConcepts.has(key)) {
621
- seenConcepts.add(key);
622
- combined.coreConcepts.push(concept);
623
- }
624
- }
625
- for (const practice of extraction.bestPractices) {
626
- const key = practice.name.toLowerCase();
627
- if (!seenPractices.has(key)) {
628
- seenPractices.add(key);
629
- combined.bestPractices.push(practice);
630
- }
631
- }
632
- for (const anti of extraction.antiPatterns) {
633
- const key = anti.name.toLowerCase();
634
- if (!seenAntiPatterns.has(key)) {
635
- seenAntiPatterns.add(key);
636
- combined.antiPatterns.push(anti);
637
- }
638
- }
639
- for (const pattern of extraction.codePatterns) {
640
- const key = pattern.name.toLowerCase();
641
- if (!seenPatterns.has(key)) {
642
- seenPatterns.add(key);
643
- combined.codePatterns.push(pattern);
644
- }
645
- }
646
- Object.assign(combined.terminology, extraction.terminology);
647
- }
648
- return combined;
649
- }
650
- async function generateDetectionRules(client, knowledge, title, domain, agentName) {
651
- const prefix = agentName.toUpperCase().replace(/[^A-Z]/g, "").slice(0, 4) || "CUST";
652
- const prompt = COMPRESSION_PROMPTS.generateDetectionRules.replace("{{knowledge}}", JSON.stringify(knowledge, null, 2)).replace("{{title}}", title).replace("{{domain}}", domain).replace("{{wordCount}}", String(knowledge.coreConcepts.length * 100)).replace(/\{\{prefix\}\}/g, prefix);
653
- const response = await client.messages.create({
654
- model: "claude-sonnet-4-20250514",
655
- max_tokens: 8e3,
656
- system: COMPRESSION_PROMPTS.system,
657
- messages: [{ role: "user", content: prompt }]
658
- });
659
- const firstContent = response.content[0];
660
- const text = firstContent !== void 0 && firstContent.type === "text" ? firstContent.text : "";
661
- try {
662
- const jsonMatch = text.match(/\[[\s\S]*\]/);
663
- if (jsonMatch) {
664
- const rules = JSON.parse(jsonMatch[0]);
665
- return rules.map((rule, i) => ({
666
- id: rule.id || `${prefix}-${String(i + 1).padStart(3, "0")}`,
667
- name: rule.name || "Unknown Rule",
668
- description: rule.description || "",
669
- severity: rule.severity || "moderate",
670
- patterns: {
671
- regex: rule.patterns?.regex || [],
672
- keywords: rule.patterns?.keywords || [],
673
- semantic: rule.patterns?.semantic || ""
674
- },
675
- fix: {
676
- description: rule.fix?.description || "Review and fix manually",
677
- example: rule.fix?.example || void 0,
678
- autoFixable: rule.fix?.autoFixable || false
679
- },
680
- regulation: rule.regulation || void 0,
681
- category: rule.category || domain
682
- }));
683
- }
684
- } catch (e) {
685
- console.error("Failed to parse detection rules:", e);
686
- }
687
- return [];
688
- }
689
- async function generateSummary(client, content) {
690
- const prompt = COMPRESSION_PROMPTS.generateSummary.replace("{{content}}", content);
691
- const response = await client.messages.create({
692
- model: "claude-sonnet-4-20250514",
693
- max_tokens: 1e3,
694
- system: COMPRESSION_PROMPTS.system,
695
- messages: [{ role: "user", content: prompt }]
696
- });
697
- const firstContent = response.content[0];
698
- return firstContent !== void 0 && firstContent.type === "text" ? firstContent.text : "";
699
- }
700
- async function generateAgentPrompts(client, knowledge, agentName, category) {
701
- const prompt = COMPRESSION_PROMPTS.generateAgentPrompts.replace("{{summary}}", knowledge.summary).replace("{{concepts}}", JSON.stringify(knowledge.coreConcepts.slice(0, 10), null, 2)).replace("{{patterns}}", JSON.stringify(knowledge.detectionRules.slice(0, 10), null, 2)).replace("{{agentName}}", agentName).replace("{{category}}", category).replace("{{domain}}", knowledge.domain);
702
- const response = await client.messages.create({
703
- model: "claude-sonnet-4-20250514",
704
- max_tokens: 4e3,
705
- system: COMPRESSION_PROMPTS.system,
706
- messages: [{ role: "user", content: prompt }]
707
- });
708
- const firstContent = response.content[0];
709
- const text = firstContent !== void 0 && firstContent.type === "text" ? firstContent.text : "";
710
- try {
711
- const jsonMatch = text.match(/\{[\s\S]*\}/);
712
- if (jsonMatch) {
713
- return JSON.parse(jsonMatch[0]);
714
- }
715
- } catch (e) {
716
- }
717
- return {
718
- systemPrompt: `You are an expert code reviewer specializing in ${category}. Review code based on best practices and patterns from "${agentName}".`,
719
- analysisPrompt: `Review this code for issues related to ${category}:
720
-
721
- \`\`\`{{language}}
722
- {{code}}
723
- \`\`\`
724
-
725
- File: {{filePath}}`,
726
- fixPrompt: `Fix this issue: {{issue}}
727
-
728
- Code:
729
- \`\`\`{{language}}
730
- {{code}}
731
- \`\`\`
732
-
733
- File: {{filePath}}`
734
- };
735
- }
736
-
737
- // src/ingest/agent-builder.ts
738
- import { mkdir, writeFile, readFile as readFile2 } from "fs/promises";
739
- import { join } from "path";
740
- async function buildAgentFromDocument(options, verbose = true) {
741
- const { filePath, agentName, category } = options;
742
- const log = verbose ? console.error.bind(console) : () => {
743
- };
744
- try {
745
- log("\u{1F4DA} Parsing document...");
746
- const document = await parseDocument(filePath);
747
- log(` \u251C\u2500 File type: ${document.metadata.fileType}`);
748
- log(` \u251C\u2500 Words: ${document.metadata.wordCount.toLocaleString()}`);
749
- log(` \u2514\u2500 Sections: ${document.sections.length}`);
750
- log("\n\u{1F9E0} Compressing knowledge...");
751
- const compressOptions = {
752
- agentName,
753
- verbose
754
- };
755
- if (category !== void 0) {
756
- compressOptions.category = category;
757
- }
758
- const knowledge = await compressKnowledge(document, compressOptions);
759
- log(` \u251C\u2500 Core concepts: ${knowledge.coreConcepts.length}`);
760
- log(` \u251C\u2500 Best practices: ${knowledge.bestPractices.length}`);
761
- log(` \u251C\u2500 Anti-patterns: ${knowledge.antiPatterns.length}`);
762
- log(` \u2514\u2500 Detection rules: ${knowledge.detectionRules.length}`);
763
- log("\n\u{1F4DD} Generating agent prompts...");
764
- const client = new Anthropic2();
765
- const prompts = await generateAgentPrompts(
766
- client,
767
- knowledge,
768
- agentName,
769
- category || knowledge.domain
770
- );
771
- log("\n\u{1F916} Building agent configuration...");
772
- const agentConfig = buildAgentConfig(
773
- document,
774
- knowledge,
775
- prompts,
776
- options
777
- );
778
- const configPath = await saveAgentConfig(agentConfig);
779
- log(` \u2514\u2500 Saved to: ${configPath}`);
780
- return {
781
- success: true,
782
- agentName: agentConfig.name,
783
- configPath,
784
- stats: {
785
- documentWords: document.metadata.wordCount,
786
- conceptsExtracted: knowledge.coreConcepts.length,
787
- patternsGenerated: knowledge.detectionRules.length,
788
- compressionRatio: knowledge.sourceDocument.compressionRatio
789
- }
790
- };
791
- } catch (error) {
792
- const errorMessage = error instanceof Error ? error.message : String(error);
793
- log(`
794
- \u274C Error: ${errorMessage}`);
795
- return {
796
- success: false,
797
- agentName,
798
- configPath: "",
799
- stats: {
800
- documentWords: 0,
801
- conceptsExtracted: 0,
802
- patternsGenerated: 0,
803
- compressionRatio: 0
804
- },
805
- error: errorMessage
806
- };
807
- }
808
- }
809
- function buildAgentConfig(document, knowledge, prompts, options) {
810
- const { agentName, displayName, description, category } = options;
811
- const docTitle = document.metadata.title;
812
- const activationRules = buildActivationRules(knowledge);
813
- return {
814
- name: sanitizeAgentName(agentName),
815
- displayName: displayName || formatDisplayName(agentName),
816
- description: description || `Code review agent based on "${document.metadata.title || agentName}"`,
817
- version: "1.0.0",
818
- category: category || knowledge.domain,
819
- source: {
820
- type: "document",
821
- originalFile: document.metadata.originalPath,
822
- fileType: document.metadata.fileType,
823
- compressedAt: (/* @__PURE__ */ new Date()).toISOString(),
824
- ...docTitle !== void 0 && { documentTitle: docTitle }
825
- },
826
- systemPrompt: prompts.systemPrompt,
827
- analysisPrompt: prompts.analysisPrompt,
828
- fixPrompt: prompts.fixPrompt,
829
- activationRules,
830
- patterns: knowledge.detectionRules,
831
- knowledge
832
- };
833
- }
834
- function buildActivationRules(knowledge) {
835
- const domainRules = {
836
- technical: {
837
- filePatterns: ["*.ts", "*.tsx", "*.js", "*.jsx", "*.py", "*.go", "*.rs"],
838
- contextSignals: ["touchesUI", "touchesAPI"],
839
- priority: 2
840
- },
841
- legal: {
842
- filePatterns: ["*"],
843
- contextSignals: ["touchesUserData", "touchesAuth", "touchesPayments"],
844
- priority: 2
845
- },
846
- policy: {
847
- filePatterns: ["*"],
848
- contextSignals: ["touchesAuth", "touchesAPI", "touchesDatabase"],
849
- priority: 3
850
- },
851
- security: {
852
- filePatterns: ["*"],
853
- contextSignals: ["touchesAuth", "touchesCrypto", "touchesAPI", "touchesDatabase"],
854
- priority: 1
855
- },
856
- architecture: {
857
- filePatterns: ["*.ts", "*.tsx", "*.js", "*.jsx", "*.py", "*.go"],
858
- contextSignals: ["touchesAPI", "touchesDatabase"],
859
- priority: 2
860
- },
861
- general: {
862
- filePatterns: ["*"],
863
- contextSignals: [],
864
- priority: 3
865
- }
866
- };
867
- const domainDefaults = domainRules[knowledge.domain] ?? domainRules.general;
868
- const contentPatterns = [];
869
- for (const rule of knowledge.detectionRules) {
870
- if (rule.patterns.keywords) {
871
- contentPatterns.push(...rule.patterns.keywords.slice(0, 3));
872
- }
873
- }
874
- for (const concept of knowledge.coreConcepts.slice(0, 5)) {
875
- if (concept.keywords) {
876
- contentPatterns.push(...concept.keywords.slice(0, 2));
877
- }
878
- }
879
- const uniquePatterns = [...new Set(contentPatterns)].slice(0, 20);
880
- return {
881
- filePatterns: domainDefaults.filePatterns ?? ["*"],
882
- contentPatterns: uniquePatterns,
883
- contextSignals: domainDefaults.contextSignals ?? [],
884
- minConfidence: 0.3,
885
- priority: domainDefaults.priority ?? 2
886
- };
887
- }
888
- async function saveAgentConfig(config) {
889
- const trieDir = join(getTrieDirectory(getWorkingDirectory(void 0, true)), "agents");
890
- await mkdir(trieDir, { recursive: true });
891
- const configPath = join(trieDir, `${config.name}.json`);
892
- await writeFile(configPath, JSON.stringify(config, null, 2));
893
- return configPath;
894
- }
895
- function sanitizeAgentName(name) {
896
- return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
897
- }
898
- function formatDisplayName(name) {
899
- return name.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
900
- }
901
-
902
- // src/cli/create-agent.ts
903
- import { existsSync } from "fs";
904
- import { resolve, basename as basename2, extname as extname2 } from "path";
905
- function parseArgs() {
906
- const args = process.argv.slice(2);
907
- if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
908
- showHelp();
909
- return null;
910
- }
911
- let filePath = args[0];
912
- if (!filePath) {
913
- console.error("Error: Please provide a file path");
914
- showHelp();
915
- return null;
916
- }
917
- filePath = filePath.replace(/^['"]|['"]$/g, "").trim();
918
- filePath = resolve(filePath);
919
- let agentName = args[1];
920
- if (!agentName || agentName.startsWith("--")) {
921
- const filename = basename2(filePath, extname2(filePath));
922
- agentName = filename.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
923
- console.log(`Auto-generated agent name: ${agentName}`);
924
- }
925
- const options = {
926
- filePath,
927
- agentName
928
- };
929
- for (let i = 2; i < args.length; i++) {
930
- const arg = args[i];
931
- const nextArg = args[i + 1];
932
- switch (arg) {
933
- case "--display-name":
934
- case "-n":
935
- if (nextArg) options.displayName = nextArg;
936
- i++;
937
- break;
938
- case "--description":
939
- case "-d":
940
- if (nextArg) options.description = nextArg;
941
- i++;
942
- break;
943
- case "--category":
944
- case "-c":
945
- if (nextArg) options.category = nextArg;
946
- i++;
947
- break;
948
- }
949
- }
950
- return options;
951
- }
952
- function showHelp() {
953
- console.log(`
954
- \u{1F4DA} Trie Agent Creator
955
- Create custom code review agents from documents.
956
-
957
- Usage:
958
- trie-create <file-path> [agent-name] [options]
959
-
960
- Arguments:
961
- file-path Path to TXT, MD, or RTF file (drag & drop supported!)
962
- agent-name Name for the agent (optional - auto-generated from filename)
963
-
964
- Options:
965
- --display-name, -n Friendly display name for the agent
966
- --description, -d Description of what the agent does
967
- --category, -c Category (react, security, compliance, architecture, etc.)
968
- --help, -h Show this help message
969
-
970
- Examples:
971
- # Basic usage
972
- trie-create ./react-guide.md react-fundamentals
973
-
974
- # With options
975
- trie-create ./gdpr-guide.txt gdpr-compliance --category legal
976
-
977
- # Auto-generate name from filename
978
- trie-create ./clean-code.txt
979
-
980
- # Drag & drop a file to terminal, then add name
981
- trie-create /Users/you/Downloads/my-guide.md my-agent
982
-
983
- Supported File Types:
984
- \u2022 Text (.txt) - Plain text files
985
- \u2022 Markdown (.md, .markdown)
986
- \u2022 RTF (.rtf) - Rich Text Format
987
-
988
- After Creation:
989
- The agent is saved to .trie/agents/<name>.json and will automatically
990
- activate during scans when it detects relevant code patterns.
991
- `);
992
- }
993
- async function main() {
994
- console.log("\nTrie Agent Creator\n");
995
- const options = parseArgs();
996
- if (!options) {
997
- process.exit(0);
998
- }
999
- if (!existsSync(options.filePath)) {
1000
- console.error(`File not found: ${options.filePath}`);
1001
- console.error("\nTip: Drag & drop the file directly into the terminal!");
1002
- process.exit(1);
1003
- }
1004
- const ext = extname2(options.filePath).toLowerCase();
1005
- const supportedTypes = [".txt", ".md", ".markdown", ".rtf"];
1006
- if (!supportedTypes.includes(ext)) {
1007
- console.error(`Unsupported file type: ${ext}`);
1008
- console.error(` Supported types: ${supportedTypes.join(", ")}`);
1009
- process.exit(1);
1010
- }
1011
- console.log(`File: ${options.filePath}`);
1012
- console.log(`Agent: ${options.agentName}`);
1013
- if (options.category) console.log(`Category: ${options.category}`);
1014
- console.log("");
1015
- try {
1016
- const createOptions = {
1017
- filePath: options.filePath,
1018
- agentName: options.agentName
1019
- };
1020
- if (options.displayName) createOptions.displayName = options.displayName;
1021
- if (options.description) createOptions.description = options.description;
1022
- if (options.category) createOptions.category = options.category;
1023
- const result = await buildAgentFromDocument(createOptions, true);
1024
- if (result.success) {
1025
- console.log("\n" + "\u2501".repeat(50));
1026
- console.log("Agent created successfully!");
1027
- console.log("\u2501".repeat(50));
1028
- console.log(`
1029
- Config saved to: ${result.configPath}`);
1030
- console.log(`
1031
- Stats:`);
1032
- console.log(` \u2022 Document words: ${result.stats.documentWords.toLocaleString()}`);
1033
- console.log(` \u2022 Concepts extracted: ${result.stats.conceptsExtracted}`);
1034
- console.log(` \u2022 Detection patterns: ${result.stats.patternsGenerated}`);
1035
- console.log(` \u2022 Compression ratio: ${result.stats.compressionRatio}:1`);
1036
- console.log("\nThe agent will now activate during code scans!");
1037
- console.log(" Run: trie watch to test it\n");
1038
- } else {
1039
- console.error(`
1040
- Failed: ${result.error}`);
1041
- process.exit(1);
1042
- }
1043
- } catch (error) {
1044
- console.error(`
1045
- Error: ${error instanceof Error ? error.message : String(error)}`);
1046
- process.exit(1);
1047
- }
1048
- }
1049
- main();
1050
- //# sourceMappingURL=create-agent.js.map