@triedotdev/mcp 1.0.110 → 1.0.112
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-OTTR5JX4.js → chunk-6QR6QZIX.js} +70 -1
- package/dist/chunk-6QR6QZIX.js.map +1 -0
- package/dist/chunk-QYOACM2C.js +1923 -0
- package/dist/chunk-QYOACM2C.js.map +1 -0
- package/dist/{chunk-SUHYYM2J.js → chunk-SDS3UVFY.js} +2 -2
- package/dist/chunk-TKMV7JKN.js +1562 -0
- package/dist/chunk-TKMV7JKN.js.map +1 -0
- package/dist/{chunk-OD4SLUIV.js → chunk-WBAWHEYX.js} +3048 -371
- package/dist/chunk-WBAWHEYX.js.map +1 -0
- package/dist/cli/main.js +320 -57
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +4 -4
- package/dist/{guardian-agent-4UJN5QGX.js → guardian-agent-XEYNG7RH.js} +3 -3
- package/dist/index.js +357 -2593
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FLBK5ILJ.js +0 -3729
- package/dist/chunk-FLBK5ILJ.js.map +0 -1
- package/dist/chunk-HIKONDDO.js +0 -26
- package/dist/chunk-HIKONDDO.js.map +0 -1
- package/dist/chunk-OD4SLUIV.js.map +0 -1
- package/dist/chunk-OTTR5JX4.js.map +0 -1
- /package/dist/{chunk-SUHYYM2J.js.map → chunk-SDS3UVFY.js.map} +0 -0
- /package/dist/{guardian-agent-4UJN5QGX.js.map → guardian-agent-XEYNG7RH.js.map} +0 -0
|
@@ -0,0 +1,1562 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTrieDirectory,
|
|
3
|
+
getWorkingDirectory
|
|
4
|
+
} from "./chunk-R4AAPFXC.js";
|
|
5
|
+
import {
|
|
6
|
+
isInteractiveMode
|
|
7
|
+
} from "./chunk-APMV77PU.js";
|
|
8
|
+
import {
|
|
9
|
+
__require
|
|
10
|
+
} from "./chunk-DGUM43GV.js";
|
|
11
|
+
|
|
12
|
+
// src/utils/project-info.ts
|
|
13
|
+
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
14
|
+
import { existsSync } from "fs";
|
|
15
|
+
import { join } from "path";
|
|
16
|
+
var PROJECT_MD_PATH = "PROJECT.md";
|
|
17
|
+
function getProjectTemplate() {
|
|
18
|
+
return `# Project Information
|
|
19
|
+
|
|
20
|
+
> This file stores important project context for AI assistants.
|
|
21
|
+
> Edit freely - this file is yours, not auto-generated.
|
|
22
|
+
> Available via MCP resource: \`trie://project\`
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Project Overview
|
|
27
|
+
|
|
28
|
+
<!-- Describe your project's purpose and goals -->
|
|
29
|
+
|
|
30
|
+
[Add project description here]
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Technology Stack
|
|
35
|
+
|
|
36
|
+
<!-- List frameworks, languages, databases, cloud services, etc. -->
|
|
37
|
+
|
|
38
|
+
- **Language:**
|
|
39
|
+
- **Framework:**
|
|
40
|
+
- **Database:**
|
|
41
|
+
- **Hosting:**
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Architecture
|
|
46
|
+
|
|
47
|
+
<!-- Key patterns, architectural decisions, and system design -->
|
|
48
|
+
|
|
49
|
+
[Describe your architecture here]
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Coding Conventions
|
|
54
|
+
|
|
55
|
+
<!-- Style guidelines, naming conventions, patterns to follow -->
|
|
56
|
+
|
|
57
|
+
-
|
|
58
|
+
-
|
|
59
|
+
-
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Environment
|
|
64
|
+
|
|
65
|
+
<!-- URLs, API endpoints, deployment info -->
|
|
66
|
+
|
|
67
|
+
| Environment | URL | Notes |
|
|
68
|
+
|-------------|-----|-------|
|
|
69
|
+
| Development | | |
|
|
70
|
+
| Staging | | |
|
|
71
|
+
| Production | | |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Team
|
|
76
|
+
|
|
77
|
+
<!-- Ownership, contacts, responsibilities -->
|
|
78
|
+
|
|
79
|
+
- **Owner:**
|
|
80
|
+
- **Team:**
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Compliance
|
|
85
|
+
|
|
86
|
+
<!-- HIPAA, SOC2, GDPR, PCI-DSS requirements if applicable -->
|
|
87
|
+
|
|
88
|
+
- [ ] GDPR
|
|
89
|
+
- [ ] SOC2
|
|
90
|
+
- [ ] HIPAA
|
|
91
|
+
- [ ] PCI-DSS
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## AI Instructions
|
|
96
|
+
|
|
97
|
+
<!-- Special instructions for AI assistants working on this project -->
|
|
98
|
+
|
|
99
|
+
When working on this project, AI assistants should:
|
|
100
|
+
|
|
101
|
+
1.
|
|
102
|
+
2.
|
|
103
|
+
3.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
*This file is read by Trie agents and exposed via \`trie://project\` MCP resource.*
|
|
108
|
+
*Edit this file to provide context to Claude Code, Cursor, GitHub Actions, and other AI tools.*
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
function projectInfoExists(workDir) {
|
|
112
|
+
const dir = workDir || getWorkingDirectory(void 0, true);
|
|
113
|
+
const projectPath = join(getTrieDirectory(dir), PROJECT_MD_PATH);
|
|
114
|
+
return existsSync(projectPath);
|
|
115
|
+
}
|
|
116
|
+
async function loadProjectInfo(workDir) {
|
|
117
|
+
const dir = workDir || getWorkingDirectory(void 0, true);
|
|
118
|
+
const projectPath = join(getTrieDirectory(dir), PROJECT_MD_PATH);
|
|
119
|
+
try {
|
|
120
|
+
if (!existsSync(projectPath)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return await readFile(projectPath, "utf-8");
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function saveProjectInfo(content, workDir) {
|
|
129
|
+
const dir = workDir || getWorkingDirectory(void 0, true);
|
|
130
|
+
const trieDir = getTrieDirectory(dir);
|
|
131
|
+
const projectPath = join(trieDir, PROJECT_MD_PATH);
|
|
132
|
+
await mkdir(trieDir, { recursive: true });
|
|
133
|
+
await writeFile(projectPath, content, "utf-8");
|
|
134
|
+
}
|
|
135
|
+
async function initProjectInfo(workDir) {
|
|
136
|
+
const dir = workDir || getWorkingDirectory(void 0, true);
|
|
137
|
+
const projectPath = join(getTrieDirectory(dir), PROJECT_MD_PATH);
|
|
138
|
+
if (existsSync(projectPath)) {
|
|
139
|
+
return { created: false, path: projectPath };
|
|
140
|
+
}
|
|
141
|
+
await saveProjectInfo(getProjectTemplate(), dir);
|
|
142
|
+
return { created: true, path: projectPath };
|
|
143
|
+
}
|
|
144
|
+
async function getProjectSection(sectionName, workDir) {
|
|
145
|
+
const content = await loadProjectInfo(workDir);
|
|
146
|
+
if (!content) return null;
|
|
147
|
+
const sectionRegex = new RegExp(
|
|
148
|
+
`## ${escapeRegex(sectionName)}\\s*\\n([\\s\\S]*?)(?=\\n## |\\n---\\s*$|$)`,
|
|
149
|
+
"i"
|
|
150
|
+
);
|
|
151
|
+
const match = content.match(sectionRegex);
|
|
152
|
+
if (match?.[1]) {
|
|
153
|
+
return match[1].trim();
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
async function updateProjectSection(sectionName, newContent, workDir) {
|
|
158
|
+
let content = await loadProjectInfo(workDir);
|
|
159
|
+
if (!content) {
|
|
160
|
+
await initProjectInfo(workDir);
|
|
161
|
+
content = await loadProjectInfo(workDir);
|
|
162
|
+
if (!content) return false;
|
|
163
|
+
}
|
|
164
|
+
const sectionRegex = new RegExp(
|
|
165
|
+
`(## ${escapeRegex(sectionName)}\\s*\\n)([\\s\\S]*?)((?=\\n## )|(?=\\n---\\s*$)|$)`,
|
|
166
|
+
"i"
|
|
167
|
+
);
|
|
168
|
+
if (content.match(sectionRegex)) {
|
|
169
|
+
const updatedContent = content.replace(sectionRegex, `$1
|
|
170
|
+
${newContent}
|
|
171
|
+
|
|
172
|
+
$3`);
|
|
173
|
+
await saveProjectInfo(updatedContent, workDir);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
async function appendToSection(sectionName, contentToAdd, workDir) {
|
|
179
|
+
const currentContent = await getProjectSection(sectionName, workDir);
|
|
180
|
+
if (currentContent === null) return false;
|
|
181
|
+
const newContent = currentContent + "\n" + contentToAdd;
|
|
182
|
+
return updateProjectSection(sectionName, newContent, workDir);
|
|
183
|
+
}
|
|
184
|
+
async function getProjectSections(workDir) {
|
|
185
|
+
const content = await loadProjectInfo(workDir);
|
|
186
|
+
if (!content) return [];
|
|
187
|
+
const sectionRegex = /^## (.+)$/gm;
|
|
188
|
+
const sections = [];
|
|
189
|
+
let match;
|
|
190
|
+
while ((match = sectionRegex.exec(content)) !== null) {
|
|
191
|
+
if (match[1]) {
|
|
192
|
+
sections.push(match[1].trim());
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return sections;
|
|
196
|
+
}
|
|
197
|
+
async function getProjectInfoStructured(workDir) {
|
|
198
|
+
const dir = workDir || getWorkingDirectory(void 0, true);
|
|
199
|
+
const projectPath = join(getTrieDirectory(dir), PROJECT_MD_PATH);
|
|
200
|
+
const content = await loadProjectInfo(dir);
|
|
201
|
+
if (!content) {
|
|
202
|
+
return {
|
|
203
|
+
exists: false,
|
|
204
|
+
path: projectPath,
|
|
205
|
+
sections: {},
|
|
206
|
+
raw: null
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const sectionNames = await getProjectSections(dir);
|
|
210
|
+
const sections = {};
|
|
211
|
+
for (const name of sectionNames) {
|
|
212
|
+
const sectionContent = await getProjectSection(name, dir);
|
|
213
|
+
if (sectionContent) {
|
|
214
|
+
sections[name] = sectionContent;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
exists: true,
|
|
219
|
+
path: projectPath,
|
|
220
|
+
sections,
|
|
221
|
+
raw: content
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function escapeRegex(str) {
|
|
225
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/utils/context-state.ts
|
|
229
|
+
import { readFile as readFile2, mkdir as mkdir2 } from "fs/promises";
|
|
230
|
+
import { existsSync as existsSync2 } from "fs";
|
|
231
|
+
import { join as join2, basename } from "path";
|
|
232
|
+
var STATE_JSON_PATH = "state.json";
|
|
233
|
+
async function loadContextState() {
|
|
234
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
235
|
+
const statePath = join2(getTrieDirectory(workDir), STATE_JSON_PATH);
|
|
236
|
+
const defaults = getDefaultState();
|
|
237
|
+
try {
|
|
238
|
+
if (existsSync2(statePath)) {
|
|
239
|
+
const content = await readFile2(statePath, "utf-8");
|
|
240
|
+
const loaded = JSON.parse(content);
|
|
241
|
+
return {
|
|
242
|
+
...defaults,
|
|
243
|
+
...loaded,
|
|
244
|
+
skills: loaded.skills || defaults.skills
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
} catch {
|
|
248
|
+
}
|
|
249
|
+
return defaults;
|
|
250
|
+
}
|
|
251
|
+
function getDefaultState() {
|
|
252
|
+
return {
|
|
253
|
+
lastScan: null,
|
|
254
|
+
healthScore: 0,
|
|
255
|
+
activePriorities: [
|
|
256
|
+
"Initial setup required - run first scan with `trie scan`",
|
|
257
|
+
"Configure agents in `.trie/config.json`",
|
|
258
|
+
"Set up CI/CD integration"
|
|
259
|
+
],
|
|
260
|
+
contextSignals: {},
|
|
261
|
+
agentStatus: {},
|
|
262
|
+
scanHistory: [],
|
|
263
|
+
customAgents: [],
|
|
264
|
+
skills: {},
|
|
265
|
+
environment: detectEnvironment()
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function detectEnvironment() {
|
|
269
|
+
if (process.env.GITHUB_ACTIONS) return "github-actions";
|
|
270
|
+
if (process.env.GITLAB_CI) return "gitlab-ci";
|
|
271
|
+
if (process.env.CI) return "ci";
|
|
272
|
+
const parent = process.env._ || "";
|
|
273
|
+
if (parent.includes("cursor")) return "cursor";
|
|
274
|
+
if (parent.includes("claude")) return "claude-code";
|
|
275
|
+
return "cli";
|
|
276
|
+
}
|
|
277
|
+
async function getContextForAI() {
|
|
278
|
+
const state = await loadContextState();
|
|
279
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
280
|
+
const lines = [];
|
|
281
|
+
if (projectInfoExists(workDir)) {
|
|
282
|
+
const projectInfo = await loadProjectInfo(workDir);
|
|
283
|
+
if (projectInfo) {
|
|
284
|
+
lines.push(projectInfo);
|
|
285
|
+
lines.push("");
|
|
286
|
+
lines.push("---");
|
|
287
|
+
lines.push("");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
lines.push(
|
|
291
|
+
"## Trie Scan Context",
|
|
292
|
+
"",
|
|
293
|
+
`**Health Score:** ${state.healthScore}%`,
|
|
294
|
+
`**Last Scan:** ${state.lastScan ? new Date(state.lastScan.timestamp).toLocaleString() : "Never"}`,
|
|
295
|
+
"",
|
|
296
|
+
"**Active Priorities:**",
|
|
297
|
+
...state.activePriorities.map((p) => `- ${p}`),
|
|
298
|
+
""
|
|
299
|
+
);
|
|
300
|
+
if (state.lastScan) {
|
|
301
|
+
lines.push(
|
|
302
|
+
"**Recent Issues:**",
|
|
303
|
+
`- Critical: ${state.lastScan.issues.critical}`,
|
|
304
|
+
`- Serious: ${state.lastScan.issues.serious}`,
|
|
305
|
+
`- Moderate: ${state.lastScan.issues.moderate}`,
|
|
306
|
+
`- Low: ${state.lastScan.issues.low}`,
|
|
307
|
+
""
|
|
308
|
+
);
|
|
309
|
+
if (state.lastScan.hotFiles.length > 0) {
|
|
310
|
+
lines.push(
|
|
311
|
+
"**Hot Files (most issues):**",
|
|
312
|
+
...state.lastScan.hotFiles.slice(0, 5).map((f) => `- ${f.file}: ${f.issueCount} issues`),
|
|
313
|
+
""
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return lines.join("\n");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/config/loader.ts
|
|
321
|
+
import { readFile as readFile3, writeFile as writeFile2, mkdir as mkdir3 } from "fs/promises";
|
|
322
|
+
import { existsSync as existsSync4 } from "fs";
|
|
323
|
+
import { join as join4, dirname } from "path";
|
|
324
|
+
|
|
325
|
+
// src/config/validation.ts
|
|
326
|
+
import { z } from "zod";
|
|
327
|
+
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
328
|
+
import { resolve, join as join3 } from "path";
|
|
329
|
+
var API_KEY_PATTERNS = {
|
|
330
|
+
anthropic: /^sk-ant-api\d{2}-[\w-]{95}$/,
|
|
331
|
+
openai: /^sk-[\w]{48}$/,
|
|
332
|
+
github: /^ghp_[\w]{36}$/,
|
|
333
|
+
vercel: /^[\w]{24}$/,
|
|
334
|
+
linear: /^lin_api_[\w]{40,60}$/
|
|
335
|
+
};
|
|
336
|
+
var ApiKeysSchema = z.object({
|
|
337
|
+
anthropic: z.string().regex(API_KEY_PATTERNS.anthropic, "Invalid Anthropic API key format").optional(),
|
|
338
|
+
openai: z.string().regex(API_KEY_PATTERNS.openai, "Invalid OpenAI API key format").optional(),
|
|
339
|
+
github: z.string().regex(API_KEY_PATTERNS.github, "Invalid GitHub token format").optional(),
|
|
340
|
+
vercel: z.string().regex(API_KEY_PATTERNS.vercel, "Invalid Vercel token format").optional(),
|
|
341
|
+
linear: z.string().optional()
|
|
342
|
+
// Linear keys can vary, so we'll be flexible but allow storage
|
|
343
|
+
});
|
|
344
|
+
var AgentConfigSchema = z.object({
|
|
345
|
+
enabled: z.array(z.string()).optional().default([]),
|
|
346
|
+
disabled: z.array(z.string()).optional().default([]),
|
|
347
|
+
parallel: z.boolean().optional().default(true),
|
|
348
|
+
maxConcurrency: z.number().int().min(1).max(20).optional().default(4),
|
|
349
|
+
timeout: z.number().int().min(1e3).max(3e5).optional().default(12e4),
|
|
350
|
+
// 2 minutes
|
|
351
|
+
cache: z.boolean().optional().default(true)
|
|
352
|
+
});
|
|
353
|
+
var ComplianceSchema = z.object({
|
|
354
|
+
standards: z.array(z.enum(["SOC2", "GDPR", "HIPAA", "CCPA", "PCI-DSS"])).optional().default(["SOC2"]),
|
|
355
|
+
enforceCompliance: z.boolean().optional().default(false),
|
|
356
|
+
reportFormat: z.enum(["json", "sarif", "csv", "html"]).optional().default("json")
|
|
357
|
+
});
|
|
358
|
+
var OutputSchema = z.object({
|
|
359
|
+
format: z.enum(["console", "json", "sarif", "junit"]).optional().default("console"),
|
|
360
|
+
level: z.enum(["critical", "serious", "moderate", "low", "all"]).optional().default("all"),
|
|
361
|
+
interactive: z.boolean().optional().default(false),
|
|
362
|
+
streaming: z.boolean().optional().default(true),
|
|
363
|
+
colors: z.boolean().optional().default(true)
|
|
364
|
+
});
|
|
365
|
+
var PathsSchema = z.object({
|
|
366
|
+
include: z.array(z.string()).optional().default([]),
|
|
367
|
+
exclude: z.array(z.string()).optional().default(["node_modules", "dist", "build", ".git"]),
|
|
368
|
+
configDir: z.string().optional().default(".trie"),
|
|
369
|
+
outputDir: z.string().optional().default("trie-reports")
|
|
370
|
+
});
|
|
371
|
+
var IntegrationsSchema = z.object({
|
|
372
|
+
github: z.object({
|
|
373
|
+
enabled: z.boolean().optional().default(false),
|
|
374
|
+
token: z.string().optional(),
|
|
375
|
+
webhook: z.string().url().optional()
|
|
376
|
+
}).optional(),
|
|
377
|
+
slack: z.object({
|
|
378
|
+
enabled: z.boolean().optional().default(false),
|
|
379
|
+
webhook: z.string().url().optional(),
|
|
380
|
+
channel: z.string().optional()
|
|
381
|
+
}).optional(),
|
|
382
|
+
jira: z.object({
|
|
383
|
+
enabled: z.boolean().optional().default(false),
|
|
384
|
+
url: z.string().url().optional(),
|
|
385
|
+
token: z.string().optional(),
|
|
386
|
+
project: z.string().optional()
|
|
387
|
+
}).optional()
|
|
388
|
+
});
|
|
389
|
+
var UserSchema = z.object({
|
|
390
|
+
name: z.string().min(1).optional(),
|
|
391
|
+
email: z.string().email().optional(),
|
|
392
|
+
role: z.enum([
|
|
393
|
+
"developer",
|
|
394
|
+
"designer",
|
|
395
|
+
"qa",
|
|
396
|
+
"devops",
|
|
397
|
+
"security",
|
|
398
|
+
"architect",
|
|
399
|
+
"manager",
|
|
400
|
+
"contributor"
|
|
401
|
+
]).optional().default("developer"),
|
|
402
|
+
github: z.string().optional(),
|
|
403
|
+
// GitHub username
|
|
404
|
+
url: z.string().url().optional()
|
|
405
|
+
// Personal/portfolio URL
|
|
406
|
+
});
|
|
407
|
+
var TrieConfigSchema = z.object({
|
|
408
|
+
version: z.string().optional().default("1.0.0"),
|
|
409
|
+
apiKeys: ApiKeysSchema.optional(),
|
|
410
|
+
agents: AgentConfigSchema.optional(),
|
|
411
|
+
compliance: ComplianceSchema.optional(),
|
|
412
|
+
output: OutputSchema.optional(),
|
|
413
|
+
paths: PathsSchema.optional(),
|
|
414
|
+
integrations: IntegrationsSchema.optional(),
|
|
415
|
+
user: UserSchema.optional()
|
|
416
|
+
// User identity for attribution
|
|
417
|
+
});
|
|
418
|
+
var ConfigValidator = class {
|
|
419
|
+
/**
|
|
420
|
+
* Validate configuration object
|
|
421
|
+
*/
|
|
422
|
+
validateConfig(config) {
|
|
423
|
+
try {
|
|
424
|
+
const validated = TrieConfigSchema.parse(config);
|
|
425
|
+
const businessErrors = this.validateBusinessLogic(validated);
|
|
426
|
+
if (businessErrors.length > 0) {
|
|
427
|
+
return { success: false, errors: businessErrors };
|
|
428
|
+
}
|
|
429
|
+
return { success: true, data: validated };
|
|
430
|
+
} catch (error) {
|
|
431
|
+
if (error instanceof z.ZodError) {
|
|
432
|
+
const errors = error.errors.map(
|
|
433
|
+
(err) => `${err.path.join(".")}: ${err.message}`
|
|
434
|
+
);
|
|
435
|
+
return { success: false, errors };
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
success: false,
|
|
439
|
+
errors: [`Configuration validation failed: ${error instanceof Error ? error.message : "Unknown error"}`]
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Validate environment variables for API keys
|
|
445
|
+
*/
|
|
446
|
+
validateEnvironment() {
|
|
447
|
+
const warnings = [];
|
|
448
|
+
const errors = [];
|
|
449
|
+
const exposedPatterns = [
|
|
450
|
+
"NEXT_PUBLIC_ANTHROPIC",
|
|
451
|
+
"REACT_APP_ANTHROPIC",
|
|
452
|
+
"VITE_ANTHROPIC",
|
|
453
|
+
"PUBLIC_ANTHROPIC"
|
|
454
|
+
];
|
|
455
|
+
for (const pattern of exposedPatterns) {
|
|
456
|
+
const envVars = Object.keys(process.env).filter((key) => key.includes(pattern));
|
|
457
|
+
for (const envVar of envVars) {
|
|
458
|
+
errors.push(`[!] Security risk: API key in client-side environment variable: ${envVar}`);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
let anthropicKey = process.env.ANTHROPIC_API_KEY;
|
|
462
|
+
if (!anthropicKey) {
|
|
463
|
+
try {
|
|
464
|
+
const configPath = join3(getTrieDirectory(getWorkingDirectory(void 0, true)), "config.json");
|
|
465
|
+
if (existsSync3(configPath)) {
|
|
466
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
467
|
+
anthropicKey = config.apiKeys?.anthropic;
|
|
468
|
+
}
|
|
469
|
+
} catch {
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (anthropicKey && !API_KEY_PATTERNS.anthropic.test(anthropicKey)) {
|
|
473
|
+
errors.push("ANTHROPIC_API_KEY does not match expected format");
|
|
474
|
+
}
|
|
475
|
+
if (!anthropicKey) {
|
|
476
|
+
warnings.push("ANTHROPIC_API_KEY not set - AI features will be disabled. Set in environment, .trie/config.json, or .env file");
|
|
477
|
+
}
|
|
478
|
+
if (!process.env.GITHUB_TOKEN && process.env.CI) {
|
|
479
|
+
warnings.push("GITHUB_TOKEN not set - GitHub integration disabled");
|
|
480
|
+
}
|
|
481
|
+
return {
|
|
482
|
+
valid: errors.length === 0,
|
|
483
|
+
warnings,
|
|
484
|
+
errors
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Validate file paths in configuration
|
|
489
|
+
*/
|
|
490
|
+
validatePaths(paths) {
|
|
491
|
+
const errors = [];
|
|
492
|
+
if (paths?.include) {
|
|
493
|
+
for (const path of paths.include) {
|
|
494
|
+
const resolvedPath = resolve(path);
|
|
495
|
+
if (!existsSync3(resolvedPath)) {
|
|
496
|
+
errors.push(`Include path does not exist: ${path}`);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
if (paths?.configDir) {
|
|
501
|
+
const configPath = resolve(paths.configDir);
|
|
502
|
+
if (!existsSync3(configPath)) {
|
|
503
|
+
try {
|
|
504
|
+
__require("fs").mkdirSync(configPath, { recursive: true });
|
|
505
|
+
} catch {
|
|
506
|
+
errors.push(`Cannot create config directory: ${paths.configDir}`);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
valid: errors.length === 0,
|
|
512
|
+
errors
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Validate integration configurations
|
|
517
|
+
*/
|
|
518
|
+
validateIntegrations(integrations) {
|
|
519
|
+
const errors = [];
|
|
520
|
+
if (integrations?.github?.enabled) {
|
|
521
|
+
if (!integrations.github.token) {
|
|
522
|
+
errors.push("GitHub integration enabled but no token provided");
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (integrations?.slack?.enabled) {
|
|
526
|
+
if (!integrations.slack.webhook) {
|
|
527
|
+
errors.push("Slack integration enabled but no webhook URL provided");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (integrations?.jira?.enabled) {
|
|
531
|
+
if (!integrations.jira.url || !integrations.jira.token || !integrations.jira.project) {
|
|
532
|
+
errors.push("JIRA integration enabled but missing required fields (url, token, project)");
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
valid: errors.length === 0,
|
|
537
|
+
errors
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Business logic validation
|
|
542
|
+
*/
|
|
543
|
+
validateBusinessLogic(config) {
|
|
544
|
+
const errors = [];
|
|
545
|
+
if (config.agents?.enabled && config.agents?.disabled) {
|
|
546
|
+
const overlap = config.agents.enabled.filter(
|
|
547
|
+
(agent) => config.agents?.disabled?.includes(agent)
|
|
548
|
+
);
|
|
549
|
+
if (overlap.length > 0) {
|
|
550
|
+
errors.push(`Agents cannot be both enabled and disabled: ${overlap.join(", ")}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (config.agents?.maxConcurrency && config.agents.maxConcurrency > 10) {
|
|
554
|
+
errors.push("maxConcurrency should not exceed 10 for optimal performance");
|
|
555
|
+
}
|
|
556
|
+
if (config.compliance?.standards) {
|
|
557
|
+
const invalidStandards = config.compliance.standards.filter(
|
|
558
|
+
(standard) => !["SOC2", "GDPR", "HIPAA", "CCPA", "PCI-DSS"].includes(standard)
|
|
559
|
+
);
|
|
560
|
+
if (invalidStandards.length > 0) {
|
|
561
|
+
errors.push(`Invalid compliance standards: ${invalidStandards.join(", ")}`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (config.paths) {
|
|
565
|
+
const pathValidation = this.validatePaths(config.paths);
|
|
566
|
+
errors.push(...pathValidation.errors);
|
|
567
|
+
}
|
|
568
|
+
if (config.integrations) {
|
|
569
|
+
const integrationValidation = this.validateIntegrations(config.integrations);
|
|
570
|
+
errors.push(...integrationValidation.errors);
|
|
571
|
+
}
|
|
572
|
+
return errors;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Generate configuration template
|
|
576
|
+
*/
|
|
577
|
+
generateTemplate() {
|
|
578
|
+
return {
|
|
579
|
+
version: "1.0.0",
|
|
580
|
+
agents: {
|
|
581
|
+
enabled: ["security", "bugs", "types"],
|
|
582
|
+
disabled: [],
|
|
583
|
+
parallel: true,
|
|
584
|
+
maxConcurrency: 4,
|
|
585
|
+
timeout: 12e4,
|
|
586
|
+
cache: true
|
|
587
|
+
},
|
|
588
|
+
compliance: {
|
|
589
|
+
standards: ["SOC2"],
|
|
590
|
+
enforceCompliance: false,
|
|
591
|
+
reportFormat: "json"
|
|
592
|
+
},
|
|
593
|
+
output: {
|
|
594
|
+
format: "console",
|
|
595
|
+
level: "all",
|
|
596
|
+
interactive: false,
|
|
597
|
+
streaming: true,
|
|
598
|
+
colors: true
|
|
599
|
+
},
|
|
600
|
+
paths: {
|
|
601
|
+
include: [],
|
|
602
|
+
exclude: ["node_modules", "dist", "build", ".git"],
|
|
603
|
+
configDir: ".trie",
|
|
604
|
+
outputDir: "trie-reports"
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Validate and provide suggestions for improvement
|
|
610
|
+
*/
|
|
611
|
+
analyze(config) {
|
|
612
|
+
const suggestions = [];
|
|
613
|
+
const securityIssues = [];
|
|
614
|
+
const optimizations = [];
|
|
615
|
+
let score = 100;
|
|
616
|
+
let hasApiKey = Boolean(config.apiKeys?.anthropic || process.env.ANTHROPIC_API_KEY);
|
|
617
|
+
if (!hasApiKey) {
|
|
618
|
+
try {
|
|
619
|
+
const workDir = getWorkingDirectory(void 0, true);
|
|
620
|
+
const envFiles = [".env", ".env.local", ".env.production"];
|
|
621
|
+
for (const envFile of envFiles) {
|
|
622
|
+
const envPath = join3(workDir, envFile);
|
|
623
|
+
if (existsSync3(envPath)) {
|
|
624
|
+
const envContent = readFileSync(envPath, "utf-8");
|
|
625
|
+
if (envContent.includes("ANTHROPIC_API_KEY=")) {
|
|
626
|
+
hasApiKey = true;
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
} catch {
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
if (!hasApiKey) {
|
|
635
|
+
suggestions.push("Add ANTHROPIC_API_KEY to enable AI-powered analysis for better issue detection. Set in environment, .trie/config.json, or .env file");
|
|
636
|
+
score -= 10;
|
|
637
|
+
}
|
|
638
|
+
if (config.agents?.parallel === false) {
|
|
639
|
+
optimizations.push("Enable parallel agent execution for 3-5x faster scans");
|
|
640
|
+
score -= 15;
|
|
641
|
+
}
|
|
642
|
+
if (config.agents?.cache === false) {
|
|
643
|
+
optimizations.push("Enable result caching to speed up repeated scans");
|
|
644
|
+
score -= 10;
|
|
645
|
+
}
|
|
646
|
+
if (!config.compliance?.standards || config.compliance.standards.length === 0) {
|
|
647
|
+
suggestions.push("Configure compliance standards (SOC2, GDPR, etc.) for regulatory requirements");
|
|
648
|
+
score -= 5;
|
|
649
|
+
}
|
|
650
|
+
const hasIntegrations = config.integrations && (config.integrations.github?.enabled || config.integrations.slack?.enabled || config.integrations.jira?.enabled);
|
|
651
|
+
if (!hasIntegrations) {
|
|
652
|
+
suggestions.push("Consider enabling GitHub/Slack/JIRA integrations for better team collaboration");
|
|
653
|
+
score -= 5;
|
|
654
|
+
}
|
|
655
|
+
if (config.apiKeys) {
|
|
656
|
+
securityIssues.push("API keys in config file - consider using environment variables instead");
|
|
657
|
+
score -= 20;
|
|
658
|
+
}
|
|
659
|
+
return {
|
|
660
|
+
score: Math.max(0, score),
|
|
661
|
+
suggestions,
|
|
662
|
+
securityIssues,
|
|
663
|
+
optimizations
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
var DEFAULT_CONFIG = {
|
|
668
|
+
version: "1.0.0",
|
|
669
|
+
agents: {
|
|
670
|
+
enabled: [],
|
|
671
|
+
disabled: [],
|
|
672
|
+
parallel: true,
|
|
673
|
+
maxConcurrency: 4,
|
|
674
|
+
timeout: 12e4,
|
|
675
|
+
cache: true
|
|
676
|
+
},
|
|
677
|
+
compliance: {
|
|
678
|
+
standards: ["SOC2"],
|
|
679
|
+
enforceCompliance: false,
|
|
680
|
+
reportFormat: "json"
|
|
681
|
+
},
|
|
682
|
+
output: {
|
|
683
|
+
format: "console",
|
|
684
|
+
level: "all",
|
|
685
|
+
interactive: false,
|
|
686
|
+
streaming: true,
|
|
687
|
+
colors: true
|
|
688
|
+
},
|
|
689
|
+
paths: {
|
|
690
|
+
include: [],
|
|
691
|
+
exclude: ["node_modules", "dist", "build", ".git", ".next", ".nuxt", "coverage"],
|
|
692
|
+
configDir: ".trie",
|
|
693
|
+
outputDir: "trie-reports"
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// src/config/loader.ts
|
|
698
|
+
async function loadConfig() {
|
|
699
|
+
const validator = new ConfigValidator();
|
|
700
|
+
const configPath = join4(getTrieDirectory(getWorkingDirectory(void 0, true)), "config.json");
|
|
701
|
+
try {
|
|
702
|
+
if (!existsSync4(configPath)) {
|
|
703
|
+
return DEFAULT_CONFIG;
|
|
704
|
+
}
|
|
705
|
+
const configFile = await readFile3(configPath, "utf-8");
|
|
706
|
+
const userConfig = JSON.parse(configFile);
|
|
707
|
+
const merged = mergeConfig(DEFAULT_CONFIG, userConfig);
|
|
708
|
+
const result = validator.validateConfig(merged);
|
|
709
|
+
if (!result.success) {
|
|
710
|
+
if (!isInteractiveMode()) {
|
|
711
|
+
console.error("Configuration validation failed:");
|
|
712
|
+
for (const error of result.errors) {
|
|
713
|
+
console.error(` - ${error}`);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return DEFAULT_CONFIG;
|
|
717
|
+
}
|
|
718
|
+
if (!isInteractiveMode()) {
|
|
719
|
+
const envValidation = validator.validateEnvironment();
|
|
720
|
+
for (const warning of envValidation.warnings) {
|
|
721
|
+
console.warn(warning);
|
|
722
|
+
}
|
|
723
|
+
for (const error of envValidation.errors) {
|
|
724
|
+
console.error(error);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return result.data;
|
|
728
|
+
} catch (error) {
|
|
729
|
+
if (!isInteractiveMode()) {
|
|
730
|
+
console.error("Failed to load config, using defaults:", error);
|
|
731
|
+
}
|
|
732
|
+
return DEFAULT_CONFIG;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async function saveConfig(config) {
|
|
736
|
+
const configPath = join4(getTrieDirectory(getWorkingDirectory(void 0, true)), "config.json");
|
|
737
|
+
const dir = dirname(configPath);
|
|
738
|
+
if (!existsSync4(dir)) {
|
|
739
|
+
await mkdir3(dir, { recursive: true });
|
|
740
|
+
}
|
|
741
|
+
await writeFile2(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
742
|
+
}
|
|
743
|
+
function mergeConfig(defaults, user) {
|
|
744
|
+
if (typeof user !== "object" || user === null || Array.isArray(user)) {
|
|
745
|
+
return { ...defaults };
|
|
746
|
+
}
|
|
747
|
+
const result = { ...defaults };
|
|
748
|
+
for (const [key, value] of Object.entries(user)) {
|
|
749
|
+
const defaultValue = defaults[key];
|
|
750
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && typeof defaultValue === "object" && defaultValue !== null) {
|
|
751
|
+
result[key] = mergeConfig(defaultValue, value);
|
|
752
|
+
} else {
|
|
753
|
+
result[key] = value;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/bootstrap/stack-detector.ts
|
|
760
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
761
|
+
import { existsSync as existsSync5 } from "fs";
|
|
762
|
+
import { join as join5 } from "path";
|
|
763
|
+
var SKILL_MAPPINGS = {
|
|
764
|
+
// Frontend Frameworks - React/Next.js
|
|
765
|
+
"next": [
|
|
766
|
+
"vercel-labs/agent-skills vercel-react-best-practices",
|
|
767
|
+
"vercel-labs/agent-skills web-design-guidelines",
|
|
768
|
+
"anthropics/skills frontend-design",
|
|
769
|
+
"wshobson/agents nextjs-app-router-patterns"
|
|
770
|
+
],
|
|
771
|
+
"react": [
|
|
772
|
+
"vercel-labs/agent-skills vercel-react-best-practices",
|
|
773
|
+
"anthropics/skills frontend-design",
|
|
774
|
+
"wshobson/agents react-state-management"
|
|
775
|
+
],
|
|
776
|
+
// Vue/Nuxt Ecosystem
|
|
777
|
+
"vue": [
|
|
778
|
+
"hyf0/vue-skills vue-best-practices",
|
|
779
|
+
"hyf0/vue-skills pinia-best-practices",
|
|
780
|
+
"hyf0/vue-skills vueuse-best-practices",
|
|
781
|
+
"onmax/nuxt-skills vue"
|
|
782
|
+
],
|
|
783
|
+
"nuxt": [
|
|
784
|
+
"onmax/nuxt-skills nuxt",
|
|
785
|
+
"onmax/nuxt-skills nuxt-ui",
|
|
786
|
+
"onmax/nuxt-skills nuxt-content",
|
|
787
|
+
"onmax/nuxt-skills nuxt-modules",
|
|
788
|
+
"onmax/nuxt-skills nuxt-better-auth",
|
|
789
|
+
"onmax/nuxt-skills nuxthub"
|
|
790
|
+
],
|
|
791
|
+
"pinia": [
|
|
792
|
+
"hyf0/vue-skills pinia-best-practices"
|
|
793
|
+
],
|
|
794
|
+
"@vueuse/core": [
|
|
795
|
+
"hyf0/vue-skills vueuse-best-practices",
|
|
796
|
+
"onmax/nuxt-skills vueuse"
|
|
797
|
+
],
|
|
798
|
+
// Mobile - Expo
|
|
799
|
+
"expo": [
|
|
800
|
+
"expo/skills building-native-ui",
|
|
801
|
+
"expo/skills upgrading-expo",
|
|
802
|
+
"expo/skills native-data-fetching",
|
|
803
|
+
"expo/skills expo-dev-client",
|
|
804
|
+
"expo/skills expo-deployment",
|
|
805
|
+
"expo/skills expo-api-routes",
|
|
806
|
+
"expo/skills expo-tailwind-setup",
|
|
807
|
+
"expo/skills expo-cicd-workflows",
|
|
808
|
+
"expo/skills use-dom"
|
|
809
|
+
],
|
|
810
|
+
// Mobile - React Native
|
|
811
|
+
"react-native": [
|
|
812
|
+
"callstackincubator/agent-skills react-native-best-practices",
|
|
813
|
+
"wshobson/agents react-native-architecture"
|
|
814
|
+
],
|
|
815
|
+
// Backend Frameworks
|
|
816
|
+
"@nestjs/core": [
|
|
817
|
+
"kadajett/agent-nestjs-skills nestjs-best-practices"
|
|
818
|
+
],
|
|
819
|
+
"nestjs": [
|
|
820
|
+
"kadajett/agent-nestjs-skills nestjs-best-practices"
|
|
821
|
+
],
|
|
822
|
+
"elysia": [
|
|
823
|
+
"elysiajs/skills elysiajs"
|
|
824
|
+
],
|
|
825
|
+
"hono": [
|
|
826
|
+
"elysiajs/skills elysiajs"
|
|
827
|
+
],
|
|
828
|
+
// Database/BaaS
|
|
829
|
+
"@supabase/supabase-js": [
|
|
830
|
+
"supabase/agent-skills supabase-postgres-best-practices"
|
|
831
|
+
],
|
|
832
|
+
"convex": [
|
|
833
|
+
"waynesutton/convexskills convex-best-practices"
|
|
834
|
+
],
|
|
835
|
+
"pg": [
|
|
836
|
+
"wshobson/agents postgresql-table-design"
|
|
837
|
+
],
|
|
838
|
+
"postgres": [
|
|
839
|
+
"wshobson/agents postgresql-table-design"
|
|
840
|
+
],
|
|
841
|
+
// Auth
|
|
842
|
+
"better-auth": [
|
|
843
|
+
"better-auth/skills better-auth-best-practices",
|
|
844
|
+
"better-auth/skills create-auth-skill"
|
|
845
|
+
],
|
|
846
|
+
// Payments
|
|
847
|
+
"stripe": [
|
|
848
|
+
"stripe/ai stripe-best-practices"
|
|
849
|
+
],
|
|
850
|
+
"@stripe/stripe-js": [
|
|
851
|
+
"stripe/ai stripe-best-practices"
|
|
852
|
+
],
|
|
853
|
+
// Media/Graphics
|
|
854
|
+
"remotion": [
|
|
855
|
+
"remotion-dev/skills remotion-best-practices"
|
|
856
|
+
],
|
|
857
|
+
"three": [
|
|
858
|
+
"cloudai-x/threejs-skills threejs-fundamentals",
|
|
859
|
+
"cloudai-x/threejs-skills threejs-animation",
|
|
860
|
+
"cloudai-x/threejs-skills threejs-materials",
|
|
861
|
+
"cloudai-x/threejs-skills threejs-shaders",
|
|
862
|
+
"cloudai-x/threejs-skills threejs-lighting",
|
|
863
|
+
"cloudai-x/threejs-skills threejs-geometry",
|
|
864
|
+
"cloudai-x/threejs-skills threejs-textures",
|
|
865
|
+
"cloudai-x/threejs-skills threejs-loaders",
|
|
866
|
+
"cloudai-x/threejs-skills threejs-interaction",
|
|
867
|
+
"cloudai-x/threejs-skills threejs-postprocessing"
|
|
868
|
+
],
|
|
869
|
+
// UI Libraries
|
|
870
|
+
"tailwindcss": [
|
|
871
|
+
"wshobson/agents tailwind-design-system",
|
|
872
|
+
"jezweb/claude-skills tailwind-v4-shadcn",
|
|
873
|
+
"wshobson/agents responsive-design"
|
|
874
|
+
],
|
|
875
|
+
"@shadcn/ui": [
|
|
876
|
+
"giuseppe-trisciuoglio/developer-kit shadcn-ui"
|
|
877
|
+
],
|
|
878
|
+
"shadcn": [
|
|
879
|
+
"giuseppe-trisciuoglio/developer-kit shadcn-ui"
|
|
880
|
+
],
|
|
881
|
+
"@radix-ui/react-slot": [
|
|
882
|
+
"onmax/nuxt-skills reka-ui"
|
|
883
|
+
],
|
|
884
|
+
// State Management
|
|
885
|
+
"@tanstack/react-query": [
|
|
886
|
+
"jezweb/claude-skills tanstack-query"
|
|
887
|
+
],
|
|
888
|
+
// Testing
|
|
889
|
+
"playwright": [
|
|
890
|
+
"anthropics/skills webapp-testing",
|
|
891
|
+
"wshobson/agents e2e-testing-patterns"
|
|
892
|
+
],
|
|
893
|
+
"puppeteer": [
|
|
894
|
+
"anthropics/skills webapp-testing"
|
|
895
|
+
],
|
|
896
|
+
"vitest": [
|
|
897
|
+
"wshobson/agents e2e-testing-patterns"
|
|
898
|
+
],
|
|
899
|
+
"jest": [
|
|
900
|
+
"wshobson/agents e2e-testing-patterns"
|
|
901
|
+
],
|
|
902
|
+
// DevTools/MCP
|
|
903
|
+
"@modelcontextprotocol/sdk": [
|
|
904
|
+
"anthropics/skills mcp-builder"
|
|
905
|
+
],
|
|
906
|
+
// Security
|
|
907
|
+
"semgrep": [
|
|
908
|
+
"trailofbits/skills semgrep"
|
|
909
|
+
],
|
|
910
|
+
// Monorepos
|
|
911
|
+
"turbo": [
|
|
912
|
+
"wshobson/agents monorepo-management"
|
|
913
|
+
],
|
|
914
|
+
"nx": [
|
|
915
|
+
"wshobson/agents monorepo-management"
|
|
916
|
+
],
|
|
917
|
+
"lerna": [
|
|
918
|
+
"wshobson/agents monorepo-management"
|
|
919
|
+
],
|
|
920
|
+
// TypeScript (handled separately based on tsconfig.json)
|
|
921
|
+
"typescript": [
|
|
922
|
+
"wshobson/agents typescript-advanced-types"
|
|
923
|
+
]
|
|
924
|
+
};
|
|
925
|
+
var SKILL_CATEGORIES = {
|
|
926
|
+
documents: [
|
|
927
|
+
"anthropics/skills pdf",
|
|
928
|
+
"anthropics/skills xlsx",
|
|
929
|
+
"anthropics/skills pptx",
|
|
930
|
+
"anthropics/skills docx",
|
|
931
|
+
"anthropics/skills doc-coauthoring"
|
|
932
|
+
],
|
|
933
|
+
design: [
|
|
934
|
+
"anthropics/skills canvas-design",
|
|
935
|
+
"anthropics/skills theme-factory",
|
|
936
|
+
"anthropics/skills web-artifacts-builder",
|
|
937
|
+
"anthropics/skills algorithmic-art",
|
|
938
|
+
"anthropics/skills brand-guidelines",
|
|
939
|
+
"anthropics/skills slack-gif-creator",
|
|
940
|
+
"nextlevelbuilder/ui-ux-pro-max ui-ux-pro-max",
|
|
941
|
+
"superdesigndev/superdesign-skill superdesign",
|
|
942
|
+
"wshobson/agents design-system-patterns"
|
|
943
|
+
],
|
|
944
|
+
marketing: [
|
|
945
|
+
"coreyhaines31/marketingskills seo-audit",
|
|
946
|
+
"coreyhaines31/marketingskills copywriting",
|
|
947
|
+
"coreyhaines31/marketingskills marketing-psychology",
|
|
948
|
+
"coreyhaines31/marketingskills programmatic-seo",
|
|
949
|
+
"coreyhaines31/marketingskills marketing-ideas",
|
|
950
|
+
"coreyhaines31/marketingskills copy-editing",
|
|
951
|
+
"coreyhaines31/marketingskills pricing-strategy",
|
|
952
|
+
"coreyhaines31/marketingskills social-content",
|
|
953
|
+
"coreyhaines31/marketingskills launch-strategy",
|
|
954
|
+
"coreyhaines31/marketingskills page-cro",
|
|
955
|
+
"coreyhaines31/marketingskills competitor-alternatives",
|
|
956
|
+
"coreyhaines31/marketingskills analytics-tracking",
|
|
957
|
+
"coreyhaines31/marketingskills schema-markup",
|
|
958
|
+
"coreyhaines31/marketingskills onboarding-cro",
|
|
959
|
+
"coreyhaines31/marketingskills email-sequence",
|
|
960
|
+
"coreyhaines31/marketingskills paid-ads",
|
|
961
|
+
"coreyhaines31/marketingskills signup-flow-cro",
|
|
962
|
+
"coreyhaines31/marketingskills free-tool-strategy",
|
|
963
|
+
"coreyhaines31/marketingskills form-cro",
|
|
964
|
+
"coreyhaines31/marketingskills paywall-upgrade-cro",
|
|
965
|
+
"coreyhaines31/marketingskills referral-program",
|
|
966
|
+
"coreyhaines31/marketingskills popup-cro",
|
|
967
|
+
"coreyhaines31/marketingskills ab-test-setup"
|
|
968
|
+
],
|
|
969
|
+
development: [
|
|
970
|
+
"obra/superpowers brainstorming",
|
|
971
|
+
"obra/superpowers test-driven-development",
|
|
972
|
+
"obra/superpowers systematic-debugging",
|
|
973
|
+
"obra/superpowers writing-plans",
|
|
974
|
+
"obra/superpowers executing-plans",
|
|
975
|
+
"obra/superpowers verification-before-completion",
|
|
976
|
+
"obra/superpowers using-superpowers",
|
|
977
|
+
"obra/superpowers subagent-driven-development",
|
|
978
|
+
"obra/superpowers requesting-code-review",
|
|
979
|
+
"obra/superpowers writing-skills",
|
|
980
|
+
"obra/superpowers dispatching-parallel-agents",
|
|
981
|
+
"obra/superpowers receiving-code-review",
|
|
982
|
+
"obra/superpowers using-git-worktrees",
|
|
983
|
+
"obra/superpowers finishing-a-development-branch",
|
|
984
|
+
"wshobson/agents code-review-excellence",
|
|
985
|
+
"wshobson/agents api-design-principles",
|
|
986
|
+
"wshobson/agents architecture-patterns",
|
|
987
|
+
"wshobson/agents error-handling-patterns",
|
|
988
|
+
"wshobson/agents nodejs-backend-patterns",
|
|
989
|
+
"wshobson/agents microservices-patterns",
|
|
990
|
+
"wshobson/agents modern-javascript-patterns",
|
|
991
|
+
"wshobson/agents web-component-design",
|
|
992
|
+
"wshobson/agents async-python-patterns",
|
|
993
|
+
"wshobson/agents python-testing-patterns",
|
|
994
|
+
"boristane/agent-skills logging-best-practices"
|
|
995
|
+
],
|
|
996
|
+
productivity: [
|
|
997
|
+
"softaworks/agent-toolkit daily-meeting-update",
|
|
998
|
+
"softaworks/agent-toolkit agent-md-refactor",
|
|
999
|
+
"softaworks/agent-toolkit session-handoff",
|
|
1000
|
+
"softaworks/agent-toolkit meme-factory",
|
|
1001
|
+
"softaworks/agent-toolkit qa-test-planner",
|
|
1002
|
+
"softaworks/agent-toolkit writing-clearly-and-concisely",
|
|
1003
|
+
"softaworks/agent-toolkit commit-work",
|
|
1004
|
+
"softaworks/agent-toolkit mermaid-diagrams",
|
|
1005
|
+
"softaworks/agent-toolkit dependency-updater",
|
|
1006
|
+
"softaworks/agent-toolkit crafting-effective-readmes",
|
|
1007
|
+
"softaworks/agent-toolkit reducing-entropy",
|
|
1008
|
+
"softaworks/agent-toolkit feedback-mastery",
|
|
1009
|
+
"softaworks/agent-toolkit marp-slide",
|
|
1010
|
+
"softaworks/agent-toolkit professional-communication",
|
|
1011
|
+
"softaworks/agent-toolkit difficult-workplace-conversations",
|
|
1012
|
+
"anthropics/skills internal-comms",
|
|
1013
|
+
"othmanadi/planning-with-files planning-with-files"
|
|
1014
|
+
],
|
|
1015
|
+
security: [
|
|
1016
|
+
"trailofbits/skills semgrep",
|
|
1017
|
+
"trailofbits/skills secure-workflow-guide",
|
|
1018
|
+
"trailofbits/skills codeql",
|
|
1019
|
+
"trailofbits/skills property-based-testing",
|
|
1020
|
+
"trailofbits/skills variant-analysis",
|
|
1021
|
+
"trailofbits/skills guidelines-advisor",
|
|
1022
|
+
"trailofbits/skills sharp-edges",
|
|
1023
|
+
"trailofbits/skills differential-review",
|
|
1024
|
+
"trailofbits/skills ask-questions-if-underspecified",
|
|
1025
|
+
"squirrelscan/skills audit-website"
|
|
1026
|
+
],
|
|
1027
|
+
mobile: [
|
|
1028
|
+
"wshobson/agents mobile-ios-design",
|
|
1029
|
+
"wshobson/agents mobile-android-design",
|
|
1030
|
+
"dimillian/skills swiftui-ui-patterns",
|
|
1031
|
+
"dimillian/skills swiftui-liquid-glass"
|
|
1032
|
+
],
|
|
1033
|
+
obsidian: [
|
|
1034
|
+
"kepano/obsidian-skills obsidian-markdown",
|
|
1035
|
+
"kepano/obsidian-skills obsidian-bases",
|
|
1036
|
+
"kepano/obsidian-skills json-canvas"
|
|
1037
|
+
],
|
|
1038
|
+
prompts: [
|
|
1039
|
+
"f/awesome-chatgpt-prompts skill-lookup",
|
|
1040
|
+
"f/awesome-chatgpt-prompts prompt-lookup",
|
|
1041
|
+
"wshobson/agents prompt-engineering-patterns"
|
|
1042
|
+
],
|
|
1043
|
+
browser: [
|
|
1044
|
+
"vercel-labs/agent-browser agent-browser"
|
|
1045
|
+
],
|
|
1046
|
+
content: [
|
|
1047
|
+
"op7418/humanizer-zh humanizer-zh",
|
|
1048
|
+
"blader/humanizer humanizer",
|
|
1049
|
+
"op7418/youtube-clipper-skill youtube-clipper",
|
|
1050
|
+
"jimliu/baoyu-skills baoyu-slide-deck",
|
|
1051
|
+
"jimliu/baoyu-skills baoyu-article-illustrator",
|
|
1052
|
+
"jimliu/baoyu-skills baoyu-cover-image",
|
|
1053
|
+
"jimliu/baoyu-skills baoyu-comic",
|
|
1054
|
+
"jimliu/baoyu-skills baoyu-infographic",
|
|
1055
|
+
"jimliu/baoyu-skills baoyu-image-gen"
|
|
1056
|
+
],
|
|
1057
|
+
integrations: [
|
|
1058
|
+
"intellectronica/agent-skills context7",
|
|
1059
|
+
"softaworks/agent-toolkit gemini",
|
|
1060
|
+
"softaworks/agent-toolkit codex"
|
|
1061
|
+
]
|
|
1062
|
+
};
|
|
1063
|
+
async function detectStack(projectDir) {
|
|
1064
|
+
const stack = {
|
|
1065
|
+
suggestedSkills: [],
|
|
1066
|
+
suggestedAgents: ["security", "bugs"],
|
|
1067
|
+
dependencies: /* @__PURE__ */ new Set()
|
|
1068
|
+
};
|
|
1069
|
+
if (existsSync5(join5(projectDir, "tsconfig.json"))) {
|
|
1070
|
+
stack.language = "TypeScript";
|
|
1071
|
+
stack.suggestedSkills.push("wshobson/agents typescript-advanced-types");
|
|
1072
|
+
} else if (existsSync5(join5(projectDir, "package.json"))) {
|
|
1073
|
+
stack.language = "JavaScript";
|
|
1074
|
+
} else if (existsSync5(join5(projectDir, "requirements.txt")) || existsSync5(join5(projectDir, "pyproject.toml"))) {
|
|
1075
|
+
stack.language = "Python";
|
|
1076
|
+
} else if (existsSync5(join5(projectDir, "go.mod"))) {
|
|
1077
|
+
stack.language = "Go";
|
|
1078
|
+
} else if (existsSync5(join5(projectDir, "Cargo.toml"))) {
|
|
1079
|
+
stack.language = "Rust";
|
|
1080
|
+
}
|
|
1081
|
+
if (existsSync5(join5(projectDir, "Package.swift")) || existsSync5(join5(projectDir, "project.pbxproj")) || existsSync5(join5(projectDir, "*.xcodeproj"))) {
|
|
1082
|
+
stack.language = "Swift";
|
|
1083
|
+
stack.suggestedSkills.push("dimillian/skills swiftui-ui-patterns");
|
|
1084
|
+
stack.suggestedSkills.push("dimillian/skills swiftui-liquid-glass");
|
|
1085
|
+
}
|
|
1086
|
+
if (existsSync5(join5(projectDir, "pnpm-lock.yaml"))) {
|
|
1087
|
+
stack.packageManager = "pnpm";
|
|
1088
|
+
} else if (existsSync5(join5(projectDir, "yarn.lock"))) {
|
|
1089
|
+
stack.packageManager = "yarn";
|
|
1090
|
+
} else if (existsSync5(join5(projectDir, "bun.lockb"))) {
|
|
1091
|
+
stack.packageManager = "bun";
|
|
1092
|
+
} else if (existsSync5(join5(projectDir, "package-lock.json"))) {
|
|
1093
|
+
stack.packageManager = "npm";
|
|
1094
|
+
}
|
|
1095
|
+
if (existsSync5(join5(projectDir, ".github", "workflows"))) {
|
|
1096
|
+
stack.suggestedSkills.push("wshobson/agents github-actions-templates");
|
|
1097
|
+
}
|
|
1098
|
+
try {
|
|
1099
|
+
const pkgPath = join5(projectDir, "package.json");
|
|
1100
|
+
if (existsSync5(pkgPath)) {
|
|
1101
|
+
const pkgContent = await readFile4(pkgPath, "utf-8");
|
|
1102
|
+
const pkg = JSON.parse(pkgContent);
|
|
1103
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
1104
|
+
for (const dep of Object.keys(deps)) {
|
|
1105
|
+
stack.dependencies.add(dep);
|
|
1106
|
+
}
|
|
1107
|
+
for (const dep of Object.keys(deps)) {
|
|
1108
|
+
const skills = SKILL_MAPPINGS[dep];
|
|
1109
|
+
if (skills) {
|
|
1110
|
+
stack.suggestedSkills.push(...skills);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
if (deps["next"]) {
|
|
1114
|
+
stack.framework = `Next.js ${deps["next"].replace("^", "")}`;
|
|
1115
|
+
stack.suggestedAgents.push("accessibility", "design");
|
|
1116
|
+
} else if (deps["react"]) {
|
|
1117
|
+
stack.framework = `React ${deps["react"].replace("^", "")}`;
|
|
1118
|
+
stack.suggestedAgents.push("accessibility");
|
|
1119
|
+
} else if (deps["vue"]) {
|
|
1120
|
+
stack.framework = `Vue ${deps["vue"].replace("^", "")}`;
|
|
1121
|
+
} else if (deps["nuxt"]) {
|
|
1122
|
+
stack.framework = `Nuxt ${deps["nuxt"].replace("^", "")}`;
|
|
1123
|
+
} else if (deps["svelte"]) {
|
|
1124
|
+
stack.framework = "Svelte";
|
|
1125
|
+
} else if (deps["express"]) {
|
|
1126
|
+
stack.framework = "Express.js";
|
|
1127
|
+
} else if (deps["fastify"]) {
|
|
1128
|
+
stack.framework = "Fastify";
|
|
1129
|
+
} else if (deps["hono"]) {
|
|
1130
|
+
stack.framework = "Hono";
|
|
1131
|
+
} else if (deps["elysia"]) {
|
|
1132
|
+
stack.framework = "Elysia";
|
|
1133
|
+
} else if (deps["@nestjs/core"]) {
|
|
1134
|
+
stack.framework = "NestJS";
|
|
1135
|
+
}
|
|
1136
|
+
if (deps["next-auth"] || deps["@auth/core"]) {
|
|
1137
|
+
stack.auth = "NextAuth.js";
|
|
1138
|
+
} else if (deps["passport"]) {
|
|
1139
|
+
stack.auth = "Passport.js";
|
|
1140
|
+
} else if (deps["@clerk/nextjs"] || deps["@clerk/clerk-react"]) {
|
|
1141
|
+
stack.auth = "Clerk";
|
|
1142
|
+
} else if (deps["better-auth"]) {
|
|
1143
|
+
stack.auth = "Better Auth";
|
|
1144
|
+
}
|
|
1145
|
+
if (deps["prisma"] || deps["@prisma/client"]) {
|
|
1146
|
+
stack.database = "Prisma ORM";
|
|
1147
|
+
} else if (deps["drizzle-orm"]) {
|
|
1148
|
+
stack.database = "Drizzle ORM";
|
|
1149
|
+
} else if (deps["@supabase/supabase-js"]) {
|
|
1150
|
+
stack.database = "Supabase";
|
|
1151
|
+
} else if (deps["mongoose"]) {
|
|
1152
|
+
stack.database = "MongoDB (Mongoose)";
|
|
1153
|
+
} else if (deps["pg"]) {
|
|
1154
|
+
stack.database = "PostgreSQL";
|
|
1155
|
+
} else if (deps["convex"]) {
|
|
1156
|
+
stack.database = "Convex";
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
} catch {
|
|
1160
|
+
}
|
|
1161
|
+
if (!stack.database) {
|
|
1162
|
+
if (existsSync5(join5(projectDir, "prisma", "schema.prisma"))) {
|
|
1163
|
+
stack.database = "Prisma ORM";
|
|
1164
|
+
} else if (existsSync5(join5(projectDir, "drizzle.config.ts"))) {
|
|
1165
|
+
stack.database = "Drizzle ORM";
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
stack.suggestedSkills = [...new Set(stack.suggestedSkills)];
|
|
1169
|
+
stack.suggestedAgents = [...new Set(stack.suggestedAgents)];
|
|
1170
|
+
return stack;
|
|
1171
|
+
}
|
|
1172
|
+
function getSkillCategories() {
|
|
1173
|
+
return Object.entries(SKILL_CATEGORIES).map(([name, skills]) => ({
|
|
1174
|
+
name,
|
|
1175
|
+
count: skills.length
|
|
1176
|
+
}));
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/bootstrap/files.ts
|
|
1180
|
+
import { readFile as readFile5, writeFile as writeFile3, unlink, mkdir as mkdir4 } from "fs/promises";
|
|
1181
|
+
import { existsSync as existsSync6 } from "fs";
|
|
1182
|
+
import { join as join6 } from "path";
|
|
1183
|
+
var BOOTSTRAP_FILES = [
|
|
1184
|
+
{ name: "PROJECT.md", type: "user", description: "Project overview and conventions" },
|
|
1185
|
+
{ name: "RULES.md", type: "user", description: "Coding standards agents enforce" },
|
|
1186
|
+
{ name: "TEAM.md", type: "user", description: "Team ownership and escalation" },
|
|
1187
|
+
{ name: "BOOTSTRAP.md", type: "one-time", description: "First-run setup (deleted after)" },
|
|
1188
|
+
{ name: "AGENTS.md", type: "auto", description: "Auto-generated scan context" }
|
|
1189
|
+
];
|
|
1190
|
+
async function loadBootstrapContext(workDir) {
|
|
1191
|
+
const projectDir = workDir || getWorkingDirectory(void 0, true);
|
|
1192
|
+
const trieDir = getTrieDirectory(projectDir);
|
|
1193
|
+
const files = [];
|
|
1194
|
+
const contentParts = [];
|
|
1195
|
+
let needsBootstrap2 = false;
|
|
1196
|
+
for (const file of BOOTSTRAP_FILES) {
|
|
1197
|
+
const filePath = join6(trieDir, file.name);
|
|
1198
|
+
const exists = existsSync6(filePath);
|
|
1199
|
+
if (file.name === "BOOTSTRAP.md" && exists) {
|
|
1200
|
+
needsBootstrap2 = true;
|
|
1201
|
+
}
|
|
1202
|
+
let content;
|
|
1203
|
+
if (exists) {
|
|
1204
|
+
try {
|
|
1205
|
+
content = await readFile5(filePath, "utf-8");
|
|
1206
|
+
if (content.trim() && file.type !== "one-time") {
|
|
1207
|
+
contentParts.push(`<!-- ${file.name} -->
|
|
1208
|
+
${content}`);
|
|
1209
|
+
}
|
|
1210
|
+
} catch {
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
const fileEntry = {
|
|
1214
|
+
name: file.name,
|
|
1215
|
+
path: filePath,
|
|
1216
|
+
type: file.type,
|
|
1217
|
+
exists
|
|
1218
|
+
};
|
|
1219
|
+
if (content) fileEntry.content = content;
|
|
1220
|
+
files.push(fileEntry);
|
|
1221
|
+
}
|
|
1222
|
+
return {
|
|
1223
|
+
files,
|
|
1224
|
+
injectedContent: contentParts.join("\n\n---\n\n"),
|
|
1225
|
+
needsBootstrap: needsBootstrap2
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
async function initializeBootstrapFiles(options = {}) {
|
|
1229
|
+
const projectDir = options.workDir || getWorkingDirectory(void 0, true);
|
|
1230
|
+
const trieDir = getTrieDirectory(projectDir);
|
|
1231
|
+
await mkdir4(trieDir, { recursive: true });
|
|
1232
|
+
const created = [];
|
|
1233
|
+
const skipped = [];
|
|
1234
|
+
const stack = await detectStack(projectDir);
|
|
1235
|
+
for (const file of BOOTSTRAP_FILES) {
|
|
1236
|
+
const filePath = join6(trieDir, file.name);
|
|
1237
|
+
const exists = existsSync6(filePath);
|
|
1238
|
+
if (exists && !options.force) {
|
|
1239
|
+
skipped.push(file.name);
|
|
1240
|
+
continue;
|
|
1241
|
+
}
|
|
1242
|
+
if (file.name === "BOOTSTRAP.md" && options.skipBootstrap) {
|
|
1243
|
+
skipped.push(file.name);
|
|
1244
|
+
continue;
|
|
1245
|
+
}
|
|
1246
|
+
if (file.name === "AGENTS.md") {
|
|
1247
|
+
skipped.push(file.name);
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
const template = getFileTemplate(file.name, stack);
|
|
1251
|
+
if (template) {
|
|
1252
|
+
await writeFile3(filePath, template);
|
|
1253
|
+
created.push(file.name);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return { created, skipped, stack };
|
|
1257
|
+
}
|
|
1258
|
+
async function completeBootstrap(workDir) {
|
|
1259
|
+
const projectDir = workDir || getWorkingDirectory(void 0, true);
|
|
1260
|
+
const bootstrapPath = join6(getTrieDirectory(projectDir), "BOOTSTRAP.md");
|
|
1261
|
+
try {
|
|
1262
|
+
await unlink(bootstrapPath);
|
|
1263
|
+
return true;
|
|
1264
|
+
} catch {
|
|
1265
|
+
return false;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function needsBootstrap(workDir) {
|
|
1269
|
+
const projectDir = workDir || getWorkingDirectory(void 0, true);
|
|
1270
|
+
const bootstrapPath = join6(getTrieDirectory(projectDir), "BOOTSTRAP.md");
|
|
1271
|
+
return existsSync6(bootstrapPath);
|
|
1272
|
+
}
|
|
1273
|
+
async function loadRules(workDir) {
|
|
1274
|
+
const projectDir = workDir || getWorkingDirectory(void 0, true);
|
|
1275
|
+
const rulesPath = join6(getTrieDirectory(projectDir), "RULES.md");
|
|
1276
|
+
try {
|
|
1277
|
+
if (existsSync6(rulesPath)) {
|
|
1278
|
+
return await readFile5(rulesPath, "utf-8");
|
|
1279
|
+
}
|
|
1280
|
+
} catch {
|
|
1281
|
+
}
|
|
1282
|
+
return null;
|
|
1283
|
+
}
|
|
1284
|
+
async function loadTeamInfo(workDir) {
|
|
1285
|
+
const projectDir = workDir || getWorkingDirectory(void 0, true);
|
|
1286
|
+
const teamPath = join6(getTrieDirectory(projectDir), "TEAM.md");
|
|
1287
|
+
try {
|
|
1288
|
+
if (existsSync6(teamPath)) {
|
|
1289
|
+
return await readFile5(teamPath, "utf-8");
|
|
1290
|
+
}
|
|
1291
|
+
} catch {
|
|
1292
|
+
}
|
|
1293
|
+
return null;
|
|
1294
|
+
}
|
|
1295
|
+
function getFileTemplate(fileName, stack) {
|
|
1296
|
+
switch (fileName) {
|
|
1297
|
+
case "PROJECT.md":
|
|
1298
|
+
return getProjectTemplate2(stack);
|
|
1299
|
+
case "RULES.md":
|
|
1300
|
+
return getRulesTemplate(stack);
|
|
1301
|
+
case "TEAM.md":
|
|
1302
|
+
return getTeamTemplate();
|
|
1303
|
+
case "BOOTSTRAP.md":
|
|
1304
|
+
return getBootstrapTemplate(stack);
|
|
1305
|
+
default:
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
function getProjectTemplate2(stack) {
|
|
1310
|
+
const lines = ["# Project Overview", "", "> Define your project context here. AI assistants read this first.", ""];
|
|
1311
|
+
lines.push("## Description", "", "[Describe what this project does and who it's for]", "");
|
|
1312
|
+
lines.push("## Technology Stack", "");
|
|
1313
|
+
if (stack.framework) lines.push(`- **Framework:** ${stack.framework}`);
|
|
1314
|
+
if (stack.language) lines.push(`- **Language:** ${stack.language}`);
|
|
1315
|
+
if (stack.database) lines.push(`- **Database:** ${stack.database}`);
|
|
1316
|
+
if (stack.auth) lines.push(`- **Auth:** ${stack.auth}`);
|
|
1317
|
+
if (!stack.framework && !stack.language && !stack.database) {
|
|
1318
|
+
lines.push("[Add your technology stack]");
|
|
1319
|
+
}
|
|
1320
|
+
lines.push("");
|
|
1321
|
+
lines.push("## Architecture", "", "[Key patterns and design decisions]", "");
|
|
1322
|
+
lines.push("## Coding Conventions", "", "[Style rules agents should follow]", "");
|
|
1323
|
+
lines.push("## AI Instructions", "", "When working on this project:", "1. [Instruction 1]", "2. [Instruction 2]", "3. [Instruction 3]", "");
|
|
1324
|
+
lines.push("---", "", "*Edit this file to provide project context to AI assistants.*");
|
|
1325
|
+
return lines.join("\n");
|
|
1326
|
+
}
|
|
1327
|
+
function getRulesTemplate(stack) {
|
|
1328
|
+
const packageManager = stack.packageManager || "npm";
|
|
1329
|
+
return `# Project Rules
|
|
1330
|
+
|
|
1331
|
+
> These rules are enforced by Trie agents during scans.
|
|
1332
|
+
> Violations appear as issues with [RULES] prefix.
|
|
1333
|
+
|
|
1334
|
+
## Code Style
|
|
1335
|
+
|
|
1336
|
+
1. Use named exports, not default exports
|
|
1337
|
+
2. Prefer \`${packageManager}\` for package management
|
|
1338
|
+
3. Maximum file length: 300 lines
|
|
1339
|
+
4. Use TypeScript strict mode
|
|
1340
|
+
|
|
1341
|
+
## Testing Requirements
|
|
1342
|
+
|
|
1343
|
+
1. Critical paths require unit tests
|
|
1344
|
+
2. API endpoints require integration tests
|
|
1345
|
+
3. Minimum coverage: 70%
|
|
1346
|
+
|
|
1347
|
+
## Security Rules
|
|
1348
|
+
|
|
1349
|
+
1. Never log sensitive data (passwords, tokens, PII)
|
|
1350
|
+
2. All API routes require authentication
|
|
1351
|
+
3. Rate limiting required on public endpoints
|
|
1352
|
+
4. SQL queries must use parameterized statements
|
|
1353
|
+
|
|
1354
|
+
## Review Requirements
|
|
1355
|
+
|
|
1356
|
+
1. All PRs require at least 1 reviewer
|
|
1357
|
+
2. Security-sensitive changes require security review
|
|
1358
|
+
3. Database migrations require review
|
|
1359
|
+
|
|
1360
|
+
---
|
|
1361
|
+
|
|
1362
|
+
*Edit this file to define your project's coding standards.*
|
|
1363
|
+
`;
|
|
1364
|
+
}
|
|
1365
|
+
function getTeamTemplate() {
|
|
1366
|
+
return `# Team Structure
|
|
1367
|
+
|
|
1368
|
+
## Code Ownership
|
|
1369
|
+
|
|
1370
|
+
| Area | Owner | Backup | Review Required |
|
|
1371
|
+
|------|-------|--------|-----------------|
|
|
1372
|
+
| \`/src/api/\` | @backend-team | - | 1 approver |
|
|
1373
|
+
| \`/src/ui/\` | @frontend-team | - | 1 approver |
|
|
1374
|
+
| \`/src/auth/\` | @security-team | - | Security review |
|
|
1375
|
+
|
|
1376
|
+
## Escalation
|
|
1377
|
+
|
|
1378
|
+
| Severity | First Contact | Escalate To | SLA |
|
|
1379
|
+
|----------|--------------|-------------|-----|
|
|
1380
|
+
| Critical | Team lead | CTO | 1 hour |
|
|
1381
|
+
| Serious | PR reviewer | Team lead | 4 hours |
|
|
1382
|
+
| Moderate | Self-serve | - | 1 day |
|
|
1383
|
+
|
|
1384
|
+
## Contacts
|
|
1385
|
+
|
|
1386
|
+
- **Security:** [email/slack]
|
|
1387
|
+
- **Privacy:** [email/slack]
|
|
1388
|
+
- **Emergencies:** [phone/pager]
|
|
1389
|
+
|
|
1390
|
+
---
|
|
1391
|
+
|
|
1392
|
+
*Edit this file to define your team structure.*
|
|
1393
|
+
`;
|
|
1394
|
+
}
|
|
1395
|
+
function getBootstrapTemplate(stack) {
|
|
1396
|
+
const skillCommands = stack.suggestedSkills.map((s) => `trie skills add ${s}`).join("\n");
|
|
1397
|
+
const agentList = stack.suggestedAgents.join(", ");
|
|
1398
|
+
const lines = [
|
|
1399
|
+
"# Trie Bootstrap Checklist",
|
|
1400
|
+
"",
|
|
1401
|
+
"This file guides your first scan setup. **Delete when complete.**",
|
|
1402
|
+
"",
|
|
1403
|
+
"## Auto-Detected Stack",
|
|
1404
|
+
"",
|
|
1405
|
+
"Based on your project, Trie detected:"
|
|
1406
|
+
];
|
|
1407
|
+
if (stack.framework) lines.push(`- **Framework:** ${stack.framework}`);
|
|
1408
|
+
if (stack.language) lines.push(`- **Language:** ${stack.language}`);
|
|
1409
|
+
if (stack.database) lines.push(`- **Database:** ${stack.database}`);
|
|
1410
|
+
if (stack.auth) lines.push(`- **Auth:** ${stack.auth}`);
|
|
1411
|
+
lines.push("", "## Recommended Actions", "", "### 1. Skills to Install", "Based on your stack, consider installing:", "```bash");
|
|
1412
|
+
lines.push(skillCommands || "# No specific skills detected - browse https://skills.sh");
|
|
1413
|
+
lines.push("```", "", "### 2. Agents to Enable", `Your stack suggests these agents: ${agentList || "security, bugs"}`, "");
|
|
1414
|
+
lines.push("### 3. Configure Rules", "Add your coding standards to `.trie/RULES.md`.", "");
|
|
1415
|
+
lines.push("### 4. Run First Scan", "```bash", "trie scan", "```", "");
|
|
1416
|
+
lines.push("---", "", "**Delete this file after completing setup.** Run:", "```bash", "rm .trie/BOOTSTRAP.md", "```");
|
|
1417
|
+
return lines.join("\n");
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// src/ingest/linear-ingester.ts
|
|
1421
|
+
var LinearIngester = class {
|
|
1422
|
+
graph;
|
|
1423
|
+
constructor(_projectPath, graph) {
|
|
1424
|
+
this.graph = graph;
|
|
1425
|
+
}
|
|
1426
|
+
async syncTickets() {
|
|
1427
|
+
const apiKey = await this.getApiKey();
|
|
1428
|
+
if (!apiKey) {
|
|
1429
|
+
console.warn('Linear API key not found. Run "trie linear auth <key>" to enable ticket sync.');
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
const tickets = await this.fetchActiveTickets(apiKey);
|
|
1433
|
+
for (const ticket of tickets) {
|
|
1434
|
+
await this.ingestTicket(ticket);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
async getApiKey() {
|
|
1438
|
+
const config = await loadConfig();
|
|
1439
|
+
return config.apiKeys?.linear || process.env.LINEAR_API_KEY || null;
|
|
1440
|
+
}
|
|
1441
|
+
async fetchActiveTickets(apiKey) {
|
|
1442
|
+
const query = `
|
|
1443
|
+
query {
|
|
1444
|
+
issues(filter: { state: { type: { in: ["started", "unstarted"] } } }) {
|
|
1445
|
+
nodes {
|
|
1446
|
+
id
|
|
1447
|
+
identifier
|
|
1448
|
+
title
|
|
1449
|
+
description
|
|
1450
|
+
priority
|
|
1451
|
+
status {
|
|
1452
|
+
name
|
|
1453
|
+
}
|
|
1454
|
+
assignee {
|
|
1455
|
+
name
|
|
1456
|
+
}
|
|
1457
|
+
labels {
|
|
1458
|
+
nodes {
|
|
1459
|
+
name
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
createdAt
|
|
1463
|
+
updatedAt
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
`;
|
|
1468
|
+
const response = await fetch("https://api.linear.app/graphql", {
|
|
1469
|
+
method: "POST",
|
|
1470
|
+
headers: {
|
|
1471
|
+
"Content-Type": "application/json",
|
|
1472
|
+
"Authorization": apiKey
|
|
1473
|
+
},
|
|
1474
|
+
body: JSON.stringify({ query })
|
|
1475
|
+
});
|
|
1476
|
+
if (!response.ok) {
|
|
1477
|
+
throw new Error(`Linear API error: ${response.statusText}`);
|
|
1478
|
+
}
|
|
1479
|
+
const data = await response.json();
|
|
1480
|
+
return data.data.issues.nodes;
|
|
1481
|
+
}
|
|
1482
|
+
async ingestTicket(ticket) {
|
|
1483
|
+
const labels = ticket.labels.nodes.map((l) => l.name);
|
|
1484
|
+
const intentVibe = this.extractIntentVibes(ticket.title, ticket.description, labels);
|
|
1485
|
+
const linkedFiles = this.extractLinkedFiles(ticket.description);
|
|
1486
|
+
const data = {
|
|
1487
|
+
ticketId: ticket.identifier,
|
|
1488
|
+
title: ticket.title,
|
|
1489
|
+
description: ticket.description || "",
|
|
1490
|
+
priority: this.mapPriority(ticket.priority),
|
|
1491
|
+
labels,
|
|
1492
|
+
intentVibe,
|
|
1493
|
+
linkedFiles,
|
|
1494
|
+
status: ticket.status.name,
|
|
1495
|
+
assignee: ticket.assignee?.name || null,
|
|
1496
|
+
createdAt: ticket.createdAt,
|
|
1497
|
+
updatedAt: ticket.updatedAt
|
|
1498
|
+
};
|
|
1499
|
+
await this.graph.addNode("linear-ticket", data);
|
|
1500
|
+
for (const file of linkedFiles) {
|
|
1501
|
+
const fileNode = await this.graph.getNode("file", file);
|
|
1502
|
+
if (fileNode) {
|
|
1503
|
+
await this.graph.addEdge(`linear:${ticket.identifier}`, fileNode.id, "relatedTo");
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
extractIntentVibes(title, description, labels) {
|
|
1508
|
+
const vibes = /* @__PURE__ */ new Set();
|
|
1509
|
+
const text = (title + " " + (description || "") + " " + labels.join(" ")).toLowerCase();
|
|
1510
|
+
if (text.includes("performance") || text.includes("slow") || text.includes("optimize")) vibes.add("performance");
|
|
1511
|
+
if (text.includes("security") || text.includes("auth") || text.includes("vulnerability")) vibes.add("security");
|
|
1512
|
+
if (text.includes("refactor") || text.includes("cleanup") || text.includes("debt")) vibes.add("refactor");
|
|
1513
|
+
if (text.includes("feature") || text.includes("new")) vibes.add("feature");
|
|
1514
|
+
if (text.includes("bug") || text.includes("fix") || text.includes("broken")) vibes.add("bug");
|
|
1515
|
+
if (text.includes("breaking") || text.includes("major change")) vibes.add("breaking-change");
|
|
1516
|
+
return Array.from(vibes);
|
|
1517
|
+
}
|
|
1518
|
+
extractLinkedFiles(description) {
|
|
1519
|
+
if (!description) return [];
|
|
1520
|
+
const matches = description.match(/[\\w./_-]+\\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs)/gi);
|
|
1521
|
+
if (!matches) return [];
|
|
1522
|
+
return Array.from(new Set(matches.map((m) => m.replace(/^\.\/+/, ""))));
|
|
1523
|
+
}
|
|
1524
|
+
mapPriority(priority) {
|
|
1525
|
+
switch (priority) {
|
|
1526
|
+
case 1:
|
|
1527
|
+
return "urgent";
|
|
1528
|
+
case 2:
|
|
1529
|
+
return "high";
|
|
1530
|
+
case 3:
|
|
1531
|
+
return "medium";
|
|
1532
|
+
case 4:
|
|
1533
|
+
return "low";
|
|
1534
|
+
default:
|
|
1535
|
+
return "none";
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
export {
|
|
1541
|
+
loadConfig,
|
|
1542
|
+
saveConfig,
|
|
1543
|
+
projectInfoExists,
|
|
1544
|
+
loadProjectInfo,
|
|
1545
|
+
initProjectInfo,
|
|
1546
|
+
getProjectSection,
|
|
1547
|
+
updateProjectSection,
|
|
1548
|
+
appendToSection,
|
|
1549
|
+
getProjectSections,
|
|
1550
|
+
getProjectInfoStructured,
|
|
1551
|
+
getSkillCategories,
|
|
1552
|
+
loadBootstrapContext,
|
|
1553
|
+
initializeBootstrapFiles,
|
|
1554
|
+
completeBootstrap,
|
|
1555
|
+
needsBootstrap,
|
|
1556
|
+
loadRules,
|
|
1557
|
+
loadTeamInfo,
|
|
1558
|
+
LinearIngester,
|
|
1559
|
+
loadContextState,
|
|
1560
|
+
getContextForAI
|
|
1561
|
+
};
|
|
1562
|
+
//# sourceMappingURL=chunk-TKMV7JKN.js.map
|