tribunal-kit 5.7.0 → 5.8.1

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 (59) hide show
  1. package/.agent/ARCHITECTURE.md +6 -7
  2. package/.agent/agents/frontend-reviewer.md +13 -0
  3. package/.agent/agents/frontend-specialist.md +14 -0
  4. package/.agent/agents/logic-reviewer.md +11 -0
  5. package/.agent/agents/orchestrator.md +15 -0
  6. package/.agent/agents/project-planner.md +5 -0
  7. package/.agent/agents/security-auditor.md +13 -0
  8. package/.agent/agents/ui-ux-auditor.md +7 -31
  9. package/.agent/history/memory/.memory.idx +1693 -0
  10. package/.agent/history/memory/MEMORY.md +123 -0
  11. package/.agent/routing_index.json +694 -714
  12. package/.agent/rules/GEMINI.md +88 -13
  13. package/.agent/scripts/_colors.js +131 -89
  14. package/.agent/scripts/_utils.js +163 -128
  15. package/.agent/scripts/auto_preview.js +207 -197
  16. package/.agent/scripts/bundle_analyzer.js +227 -192
  17. package/.agent/scripts/case_law_manager.js +991 -689
  18. package/.agent/scripts/checklist.js +233 -190
  19. package/.agent/scripts/context_broker.js +930 -605
  20. package/.agent/scripts/dependency_analyzer.js +275 -184
  21. package/.agent/scripts/graph_builder.js +412 -341
  22. package/.agent/scripts/graph_visualizer.js +392 -390
  23. package/.agent/scripts/graph_zoom.js +198 -156
  24. package/.agent/scripts/inner_loop_validator.js +523 -445
  25. package/.agent/scripts/lint_runner.js +199 -157
  26. package/.agent/scripts/marathon_harness.js +819 -661
  27. package/.agent/scripts/minify_context.js +115 -100
  28. package/.agent/scripts/mutation_runner.js +321 -280
  29. package/.agent/scripts/prompt_compiler.js +62 -42
  30. package/.agent/scripts/schema_validator.js +373 -280
  31. package/.agent/scripts/security_scan.js +333 -190
  32. package/.agent/scripts/session_manager.js +306 -270
  33. package/.agent/scripts/skill_evolution.js +810 -637
  34. package/.agent/scripts/skill_integrator.js +327 -307
  35. package/.agent/scripts/strengthen_skills.js +203 -193
  36. package/.agent/scripts/swarm_dispatcher.js +558 -457
  37. package/.agent/scripts/test_runner.js +178 -152
  38. package/.agent/scripts/verify_all.js +200 -168
  39. package/.agent/skills/fabel-protocol/SKILL.md +271 -0
  40. package/.agent/skills/thinking-protocol/SKILL.md +27 -0
  41. package/.agent/workflows/generate.md +2 -1
  42. package/.agent/workflows/tribunal-full.md +4 -3
  43. package/.agent/workflows/tribunal-speed.md +1 -1
  44. package/README.md +184 -58
  45. package/bin/mcp-server.js +496 -173
  46. package/bin/tribunal-kit.js +1245 -987
  47. package/bin/wrapper.js +108 -74
  48. package/dist/cli.js +44 -0
  49. package/dist/commands/align.js +201 -0
  50. package/dist/commands/case.js +23 -0
  51. package/dist/commands/compile.js +84 -0
  52. package/dist/commands/init.js +42 -0
  53. package/dist/commands/learn.js +57 -0
  54. package/dist/commands/memory.js +456 -0
  55. package/package.json +22 -10
  56. package/scripts/benchmark.js +162 -125
  57. package/scripts/changelog.js +196 -168
  58. package/scripts/sync-version.js +94 -81
  59. package/scripts/validate-payload.js +85 -78
@@ -1,307 +1,327 @@
1
- #!/usr/bin/env node
2
- /**
3
- * skill_integrator.js — Automated Skill-Script Integration Analyzer
4
- *
5
- * This script scans active skills in `.agent/skills/` and maps them to their
6
- * corresponding executable scripts in `.agent/scripts/`. It helps the Orchestrator
7
- * and other agents know which skills have automated CLI actions available.
8
- *
9
- * Usage:
10
- * node .agent/scripts/skill_integrator.js
11
- * node .agent/scripts/skill_integrator.js --skill <skill-name>
12
- * node .agent/scripts/skill_integrator.js --report
13
- * node .agent/scripts/skill_integrator.js --verify
14
- * node .agent/scripts/skill_integrator.js --report --verify
15
- */
16
-
17
- 'use strict';
18
-
19
- const fs = require('fs');
20
- const path = require('path');
21
- const { execFileSync } = require('child_process');
22
-
23
- const { CYAN, GREEN, YELLOW, RED, BOLD, RESET } = require('./_colors');
24
-
25
- const REPORT_FILE = 'skill-integration-report.md';
26
-
27
- function findAgentDir(startPathStr) {
28
- let current = path.resolve(startPathStr);
29
- const root = path.parse(current).root;
30
- while (current !== root) {
31
- const agentDir = path.join(current, '.agent');
32
- if (fs.existsSync(agentDir) && fs.statSync(agentDir).isDirectory()) {
33
- return agentDir;
34
- }
35
- current = path.dirname(current);
36
- }
37
- return null;
38
- }
39
-
40
- function getAssociatedScript(skillDir, scriptsDir) {
41
- /** Check if the skill has an explicit frontmatter script or an implicit script file. */
42
- const skillName = path.basename(skillDir);
43
-
44
- // 1. Implicit check: does a script with the same name exist? (Check for both .js and .py)
45
- const implicitJsScript = path.join(scriptsDir, `${skillName}.js`);
46
- if (fs.existsSync(implicitJsScript)) {
47
- return `.agent/scripts/${skillName}.js`;
48
- }
49
-
50
- const implicitPyScript = path.join(scriptsDir, `${skillName}.py`);
51
- if (fs.existsSync(implicitPyScript)) {
52
- return `.agent/scripts/${skillName}.py`;
53
- }
54
-
55
- // 2. Explicit check: does the SKILL.md define 'script:' in its frontmatter?
56
- const skillMd = path.join(skillDir, 'SKILL.md');
57
- if (fs.existsSync(skillMd)) {
58
- try {
59
- const content = fs.readFileSync(skillMd, 'utf8');
60
- const match = content.match(/---([\s\S]*?)---/);
61
- if (match) {
62
- const frontmatter = match[1];
63
- const scriptMatch = frontmatter.match(/(?:^|\n)script:\s*([^\n]+)/);
64
- if (scriptMatch) {
65
- return scriptMatch[1].trim();
66
- }
67
- }
68
- } catch {
69
- // ignore
70
- }
71
- }
72
-
73
- return null;
74
- }
75
-
76
- function scanAllSkills(agentDir) {
77
- const skillsDir = path.join(agentDir, 'skills');
78
- const scriptsDir = path.join(agentDir, 'scripts');
79
-
80
- if (!fs.existsSync(skillsDir) || !fs.existsSync(scriptsDir)) {
81
- console.log(`${YELLOW}Warning: '.agent/skills' or '.agent/scripts' directory not found.${RESET}`);
82
- return {};
83
- }
84
-
85
- const integratedSkills = {};
86
- const items = fs.readdirSync(skillsDir, { withFileTypes: true });
87
-
88
- // sort items by name
89
- items.sort((a, b) => a.name.localeCompare(b.name));
90
-
91
- for (const item of items) {
92
- if (item.isDirectory()) {
93
- const skillDir = path.join(skillsDir, item.name);
94
- const scriptPath = getAssociatedScript(skillDir, scriptsDir);
95
- if (scriptPath) {
96
- integratedSkills[item.name] = scriptPath;
97
- }
98
- }
99
- }
100
-
101
- return integratedSkills;
102
- }
103
-
104
- function verifyScript(scriptPathStr, workspaceRoot) {
105
- /**
106
- * Verify a mapped script exists on disk and has valid syntax.
107
- * Returns { valid: boolean, message: string }.
108
- */
109
- const fullPath = path.resolve(workspaceRoot, scriptPathStr);
110
-
111
- if (!fs.existsSync(fullPath)) {
112
- return { valid: false, message: `File not found: ${fullPath}` };
113
- }
114
-
115
- try {
116
- if (fullPath.endsWith('.js')) {
117
- // use node to syntax check
118
- execFileSync('node', ['-c', fullPath], { stdio: 'pipe' });
119
- } else if (fullPath.endsWith('.py')) {
120
- // use python to syntax check
121
- execFileSync('python', ['-m', 'py_compile', fullPath], { stdio: 'pipe' });
122
- }
123
- return { valid: true, message: 'Syntax OK' };
124
- } catch (e) {
125
- let msg = e.message;
126
- if (e.stderr) {
127
- msg = e.stderr.toString().trim();
128
- }
129
- return { valid: false, message: `Syntax error: ${msg.split('\n')[0]}` };
130
- }
131
- }
132
-
133
- function checkSkill(skillName, agentDir) {
134
- const skillDir = path.join(agentDir, 'skills', skillName);
135
- const scriptsDir = path.join(agentDir, 'scripts');
136
-
137
- if (!fs.existsSync(skillDir)) {
138
- console.log(`${YELLOW}Skill '${skillName}' not found in .agent/skills/${RESET}`);
139
- return;
140
- }
141
-
142
- const scriptPath = getAssociatedScript(skillDir, scriptsDir);
143
- if (scriptPath) {
144
- console.log(`${GREEN}✓ Associated script found:${RESET} ${scriptPath}`);
145
- const runner = scriptPath.endsWith('.py') ? 'python' : 'node';
146
- console.log(`\nTo execute:\n ${runner} ${scriptPath}`);
147
- } else {
148
- console.log(`No executable script mapped for '${skillName}'.`);
149
- }
150
- }
151
-
152
- function cmdReport(integratedSkills, workspaceRoot) {
153
- /** Write a Markdown integration report to REPORT_FILE. */
154
- const keys = Object.keys(integratedSkills).sort();
155
- const generated = new Date().toISOString().slice(0, 16);
156
-
157
- let content = `# Skill-Script Integration Report\n\n`;
158
- content += `Generated: ${generated}\n`;
159
- content += `Integrated skills: ${keys.length}\n\n`;
160
- content += `---\n\n`;
161
- content += `| Skill | Script | Exists |\n`;
162
- content += `|---|---|---|\n`;
163
-
164
- for (const skill of keys) {
165
- const script = integratedSkills[skill];
166
- const scriptPath = path.resolve(workspaceRoot, script);
167
- const exists = fs.existsSync(scriptPath) ? '✅' : '❌ Missing';
168
- content += `| \`${skill}\` | \`${script}\` | ${exists} |\n`;
169
- }
170
-
171
- content += `\n---\n\n`;
172
- content += `_Run \`node .agent/scripts/skill_integrator.js --verify\` to validate syntax of all mapped scripts._\n`;
173
-
174
- const reportPath = path.join(workspaceRoot, REPORT_FILE);
175
- fs.writeFileSync(reportPath, content, 'utf8');
176
-
177
- console.log(`${GREEN}✅ Report written to:${RESET} ${reportPath}`);
178
- }
179
-
180
- function cmdVerify(integratedSkills, workspaceRoot) {
181
- /**
182
- * Validate each mapped script: check existence and syntax.
183
- * Returns true if all pass, false if any fail.
184
- */
185
- const keys = Object.keys(integratedSkills).sort();
186
- if (keys.length === 0) {
187
- console.log(`${YELLOW}No integrated scripts found to verify.${RESET}`);
188
- return true;
189
- }
190
-
191
- console.log(`\n${BOLD}${CYAN}━━━ Skill-Script Verification (${keys.length} scripts) ━━━${RESET}\n`);
192
-
193
- let allPassed = true;
194
- const failures = [];
195
-
196
- for (const skill of keys) {
197
- const script = integratedSkills[skill];
198
- const res = verifyScript(script, workspaceRoot);
199
- if (res.valid) {
200
- console.log(` ${GREEN}✅ PASS${RESET} ${BOLD}${skill}${RESET} ${script}`);
201
- } else {
202
- console.log(` ${RED}❌ FAIL${RESET} ${BOLD}${skill}${RESET} ${script}`);
203
- console.log(` ${RED}${res.message}${RESET}`);
204
- allPassed = false;
205
- failures.push(skill);
206
- }
207
- }
208
-
209
- console.log(`\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}`);
210
- if (allPassed) {
211
- console.log(`${GREEN}All ${keys.length} mapped scripts passed verification.${RESET}\n`);
212
- } else {
213
- console.log(`${RED}${failures.length} script(s) failed verification. Fix before deploying.${RESET}\n`);
214
- }
215
-
216
- return allPassed;
217
- }
218
-
219
- function main() {
220
- const rawArgs = process.argv.slice(2);
221
-
222
- if (rawArgs.length > 0 && ['-h', '--help', 'help'].includes(rawArgs[0])) {
223
- console.log(`
224
- ${BOLD}skill_integrator.js${RESET} Skill-Script Integrator
225
-
226
- ${BOLD}Usage:${RESET}
227
- node .agent/scripts/skill_integrator.js
228
- node .agent/scripts/skill_integrator.js --skill <skill-name>
229
- node .agent/scripts/skill_integrator.js --report
230
- node .agent/scripts/skill_integrator.js --verify
231
- node .agent/scripts/skill_integrator.js --report --verify
232
-
233
- ${BOLD}Options:${RESET}
234
- --skill <name> Validate a specific skill by name
235
- --workspace <dir> Workspace root directory (default: current dir)
236
- --report Generate a Markdown integration report (skill-integration-report.md)
237
- --verify Validate syntax of all mapped scripts (exits 1 on any failure)
238
- `);
239
- return;
240
- }
241
-
242
- // Parse args
243
- let skillArg = null;
244
- let workspaceArg = '.';
245
- let reportArg = false;
246
- let verifyArg = false;
247
-
248
- for (let i = 0; i < rawArgs.length; i++) {
249
- if (rawArgs[i] === '--skill' && i + 1 < rawArgs.length) {
250
- skillArg = rawArgs[++i];
251
- } else if (rawArgs[i] === '--workspace' && i + 1 < rawArgs.length) {
252
- workspaceArg = rawArgs[++i];
253
- } else if (rawArgs[i] === '--report') {
254
- reportArg = true;
255
- } else if (rawArgs[i] === '--verify') {
256
- verifyArg = true;
257
- }
258
- }
259
-
260
- const workspaceRoot = path.resolve(workspaceArg);
261
- const agentDir = findAgentDir(workspaceRoot);
262
-
263
- if (!agentDir) {
264
- console.log(`${YELLOW}Error: Could not find .agent directory starting from ${workspaceRoot}${RESET}`);
265
- process.exit(1);
266
- }
267
-
268
- if (skillArg) {
269
- checkSkill(skillArg, agentDir);
270
- return;
271
- }
272
-
273
- const integratedSkills = scanAllSkills(agentDir);
274
-
275
- if (reportArg) {
276
- cmdReport(integratedSkills, workspaceRoot);
277
- }
278
-
279
- if (verifyArg) {
280
- const passed = cmdVerify(integratedSkills, workspaceRoot);
281
- if (!passed) {
282
- process.exit(1);
283
- }
284
- return;
285
- }
286
-
287
- if (!reportArg && !verifyArg) {
288
- const keys = Object.keys(integratedSkills).sort();
289
- if (keys.length === 0) {
290
- console.log("No integrated scripts found for any active skills.");
291
- } else {
292
- console.log(`\n${BOLD}${CYAN}--- Skill-Script Integrations (${keys.length}) ---${RESET}\n`);
293
- for (const skill of keys) {
294
- const script = integratedSkills[skill];
295
- console.log(` ${BOLD}${skill}${RESET}`);
296
- console.log(` ↳ ${GREEN}${script}${RESET}\n`);
297
- }
298
- console.log(`${CYAN}To run a skill script, use: python <path> or node <path>${RESET}\n`);
299
- }
300
- }
301
- }
302
-
303
- module.exports = { getAssociatedScript, verifyScript };
304
-
305
- if (require.main === module) {
306
- main();
307
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * skill_integrator.js — Automated Skill-Script Integration Analyzer
4
+ *
5
+ * This script scans active skills in `.agent/skills/` and maps them to their
6
+ * corresponding executable scripts in `.agent/scripts/`. It helps the Orchestrator
7
+ * and other agents know which skills have automated CLI actions available.
8
+ *
9
+ * Usage:
10
+ * node .agent/scripts/skill_integrator.js
11
+ * node .agent/scripts/skill_integrator.js --skill <skill-name>
12
+ * node .agent/scripts/skill_integrator.js --report
13
+ * node .agent/scripts/skill_integrator.js --verify
14
+ * node .agent/scripts/skill_integrator.js --report --verify
15
+ */
16
+
17
+ "use strict";
18
+
19
+ const fs = require("fs");
20
+ const path = require("path");
21
+ const { execFileSync } = require("child_process");
22
+
23
+ const { CYAN, GREEN, YELLOW, RED, BOLD, RESET } = require("./_colors");
24
+
25
+ const REPORT_FILE = "skill-integration-report.md";
26
+
27
+ function findAgentDir(startPathStr) {
28
+ let current = path.resolve(startPathStr);
29
+ const root = path.parse(current).root;
30
+ while (current !== root) {
31
+ const agentDir = path.join(current, ".agent");
32
+ if (fs.existsSync(agentDir) && fs.statSync(agentDir).isDirectory()) {
33
+ return agentDir;
34
+ }
35
+ current = path.dirname(current);
36
+ }
37
+ return null;
38
+ }
39
+
40
+ function getAssociatedScript(skillDir, scriptsDir) {
41
+ /** Check if the skill has an explicit frontmatter script or an implicit script file. */
42
+ const skillName = path.basename(skillDir);
43
+
44
+ // 1. Implicit check: does a script with the same name exist? (Check for both .js and .py)
45
+ const implicitJsScript = path.join(scriptsDir, `${skillName}.js`);
46
+ if (fs.existsSync(implicitJsScript)) {
47
+ return `.agent/scripts/${skillName}.js`;
48
+ }
49
+
50
+ const implicitPyScript = path.join(scriptsDir, `${skillName}.py`);
51
+ if (fs.existsSync(implicitPyScript)) {
52
+ return `.agent/scripts/${skillName}.py`;
53
+ }
54
+
55
+ // 2. Explicit check: does the SKILL.md define 'script:' in its frontmatter?
56
+ const skillMd = path.join(skillDir, "SKILL.md");
57
+ if (fs.existsSync(skillMd)) {
58
+ try {
59
+ const content = fs.readFileSync(skillMd, "utf8");
60
+ const match = content.match(/---([\s\S]*?)---/);
61
+ if (match) {
62
+ const frontmatter = match[1];
63
+ const scriptMatch = frontmatter.match(/(?:^|\n)script:\s*([^\n]+)/);
64
+ if (scriptMatch) {
65
+ return scriptMatch[1].trim();
66
+ }
67
+ }
68
+ } catch {
69
+ // ignore
70
+ }
71
+ }
72
+
73
+ return null;
74
+ }
75
+
76
+ function scanAllSkills(agentDir) {
77
+ const skillsDir = path.join(agentDir, "skills");
78
+ const scriptsDir = path.join(agentDir, "scripts");
79
+
80
+ if (!fs.existsSync(skillsDir) || !fs.existsSync(scriptsDir)) {
81
+ console.log(
82
+ `${YELLOW}Warning: '.agent/skills' or '.agent/scripts' directory not found.${RESET}`,
83
+ );
84
+ return {};
85
+ }
86
+
87
+ const integratedSkills = {};
88
+ const items = fs.readdirSync(skillsDir, { withFileTypes: true });
89
+
90
+ // sort items by name
91
+ items.sort((a, b) => a.name.localeCompare(b.name));
92
+
93
+ for (const item of items) {
94
+ if (item.isDirectory()) {
95
+ const skillDir = path.join(skillsDir, item.name);
96
+ const scriptPath = getAssociatedScript(skillDir, scriptsDir);
97
+ if (scriptPath) {
98
+ integratedSkills[item.name] = scriptPath;
99
+ }
100
+ }
101
+ }
102
+
103
+ return integratedSkills;
104
+ }
105
+
106
+ function verifyScript(scriptPathStr, workspaceRoot) {
107
+ /**
108
+ * Verify a mapped script exists on disk and has valid syntax.
109
+ * Returns { valid: boolean, message: string }.
110
+ */
111
+ const fullPath = path.resolve(workspaceRoot, scriptPathStr);
112
+
113
+ if (!fs.existsSync(fullPath)) {
114
+ return { valid: false, message: `File not found: ${fullPath}` };
115
+ }
116
+
117
+ try {
118
+ if (fullPath.endsWith(".js")) {
119
+ // use node to syntax check
120
+ execFileSync("node", ["-c", fullPath], { stdio: "pipe" });
121
+ } else if (fullPath.endsWith(".py")) {
122
+ // use python to syntax check
123
+ execFileSync("python", ["-m", "py_compile", fullPath], { stdio: "pipe" });
124
+ }
125
+ return { valid: true, message: "Syntax OK" };
126
+ } catch (e) {
127
+ let msg = e.message;
128
+ if (e.stderr) {
129
+ msg = e.stderr.toString().trim();
130
+ }
131
+ return { valid: false, message: `Syntax error: ${msg.split("\n")[0]}` };
132
+ }
133
+ }
134
+
135
+ function checkSkill(skillName, agentDir) {
136
+ const skillDir = path.join(agentDir, "skills", skillName);
137
+ const scriptsDir = path.join(agentDir, "scripts");
138
+
139
+ if (!fs.existsSync(skillDir)) {
140
+ console.log(
141
+ `${YELLOW}Skill '${skillName}' not found in .agent/skills/${RESET}`,
142
+ );
143
+ return;
144
+ }
145
+
146
+ const scriptPath = getAssociatedScript(skillDir, scriptsDir);
147
+ if (scriptPath) {
148
+ console.log(`${GREEN}✓ Associated script found:${RESET} ${scriptPath}`);
149
+ const runner = scriptPath.endsWith(".py") ? "python" : "node";
150
+ console.log(`\nTo execute:\n ${runner} ${scriptPath}`);
151
+ } else {
152
+ console.log(`No executable script mapped for '${skillName}'.`);
153
+ }
154
+ }
155
+
156
+ function cmdReport(integratedSkills, workspaceRoot) {
157
+ /** Write a Markdown integration report to REPORT_FILE. */
158
+ const keys = Object.keys(integratedSkills).sort();
159
+ const generated = new Date().toISOString().slice(0, 16);
160
+
161
+ let content = `# Skill-Script Integration Report\n\n`;
162
+ content += `Generated: ${generated}\n`;
163
+ content += `Integrated skills: ${keys.length}\n\n`;
164
+ content += `---\n\n`;
165
+ content += `| Skill | Script | Exists |\n`;
166
+ content += `|---|---|---|\n`;
167
+
168
+ for (const skill of keys) {
169
+ const script = integratedSkills[skill];
170
+ const scriptPath = path.resolve(workspaceRoot, script);
171
+ const exists = fs.existsSync(scriptPath) ? "✅" : "❌ Missing";
172
+ content += `| \`${skill}\` | \`${script}\` | ${exists} |\n`;
173
+ }
174
+
175
+ content += `\n---\n\n`;
176
+ content += `_Run \`node .agent/scripts/skill_integrator.js --verify\` to validate syntax of all mapped scripts._\n`;
177
+
178
+ const reportPath = path.join(workspaceRoot, REPORT_FILE);
179
+ fs.writeFileSync(reportPath, content, "utf8");
180
+
181
+ console.log(`${GREEN}✅ Report written to:${RESET} ${reportPath}`);
182
+ }
183
+
184
+ function cmdVerify(integratedSkills, workspaceRoot) {
185
+ /**
186
+ * Validate each mapped script: check existence and syntax.
187
+ * Returns true if all pass, false if any fail.
188
+ */
189
+ const keys = Object.keys(integratedSkills).sort();
190
+ if (keys.length === 0) {
191
+ console.log(`${YELLOW}No integrated scripts found to verify.${RESET}`);
192
+ return true;
193
+ }
194
+
195
+ console.log(
196
+ `\n${BOLD}${CYAN}━━━ Skill-Script Verification (${keys.length} scripts) ━━━${RESET}\n`,
197
+ );
198
+
199
+ let allPassed = true;
200
+ const failures = [];
201
+
202
+ for (const skill of keys) {
203
+ const script = integratedSkills[skill];
204
+ const res = verifyScript(script, workspaceRoot);
205
+ if (res.valid) {
206
+ console.log(
207
+ ` ${GREEN}✅ PASS${RESET} ${BOLD}${skill}${RESET} → ${script}`,
208
+ );
209
+ } else {
210
+ console.log(
211
+ ` ${RED} FAIL${RESET} ${BOLD}${skill}${RESET} ${script}`,
212
+ );
213
+ console.log(` ${RED}${res.message}${RESET}`);
214
+ allPassed = false;
215
+ failures.push(skill);
216
+ }
217
+ }
218
+
219
+ console.log(`\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}`);
220
+ if (allPassed) {
221
+ console.log(
222
+ `${GREEN}All ${keys.length} mapped scripts passed verification.${RESET}\n`,
223
+ );
224
+ } else {
225
+ console.log(
226
+ `${RED}${failures.length} script(s) failed verification. Fix before deploying.${RESET}\n`,
227
+ );
228
+ }
229
+
230
+ return allPassed;
231
+ }
232
+
233
+ function main() {
234
+ const rawArgs = process.argv.slice(2);
235
+
236
+ if (rawArgs.length > 0 && ["-h", "--help", "help"].includes(rawArgs[0])) {
237
+ console.log(`
238
+ ${BOLD}skill_integrator.js${RESET} — Skill-Script Integrator
239
+
240
+ ${BOLD}Usage:${RESET}
241
+ node .agent/scripts/skill_integrator.js
242
+ node .agent/scripts/skill_integrator.js --skill <skill-name>
243
+ node .agent/scripts/skill_integrator.js --report
244
+ node .agent/scripts/skill_integrator.js --verify
245
+ node .agent/scripts/skill_integrator.js --report --verify
246
+
247
+ ${BOLD}Options:${RESET}
248
+ --skill <name> Validate a specific skill by name
249
+ --workspace <dir> Workspace root directory (default: current dir)
250
+ --report Generate a Markdown integration report (skill-integration-report.md)
251
+ --verify Validate syntax of all mapped scripts (exits 1 on any failure)
252
+ `);
253
+ return;
254
+ }
255
+
256
+ // Parse args
257
+ let skillArg = null;
258
+ let workspaceArg = ".";
259
+ let reportArg = false;
260
+ let verifyArg = false;
261
+
262
+ for (let i = 0; i < rawArgs.length; i++) {
263
+ if (rawArgs[i] === "--skill" && i + 1 < rawArgs.length) {
264
+ skillArg = rawArgs[++i];
265
+ } else if (rawArgs[i] === "--workspace" && i + 1 < rawArgs.length) {
266
+ workspaceArg = rawArgs[++i];
267
+ } else if (rawArgs[i] === "--report") {
268
+ reportArg = true;
269
+ } else if (rawArgs[i] === "--verify") {
270
+ verifyArg = true;
271
+ }
272
+ }
273
+
274
+ const workspaceRoot = path.resolve(workspaceArg);
275
+ const agentDir = findAgentDir(workspaceRoot);
276
+
277
+ if (!agentDir) {
278
+ console.log(
279
+ `${YELLOW}Error: Could not find .agent directory starting from ${workspaceRoot}${RESET}`,
280
+ );
281
+ process.exit(1);
282
+ }
283
+
284
+ if (skillArg) {
285
+ checkSkill(skillArg, agentDir);
286
+ return;
287
+ }
288
+
289
+ const integratedSkills = scanAllSkills(agentDir);
290
+
291
+ if (reportArg) {
292
+ cmdReport(integratedSkills, workspaceRoot);
293
+ }
294
+
295
+ if (verifyArg) {
296
+ const passed = cmdVerify(integratedSkills, workspaceRoot);
297
+ if (!passed) {
298
+ process.exit(1);
299
+ }
300
+ return;
301
+ }
302
+
303
+ if (!reportArg && !verifyArg) {
304
+ const keys = Object.keys(integratedSkills).sort();
305
+ if (keys.length === 0) {
306
+ console.log("No integrated scripts found for any active skills.");
307
+ } else {
308
+ console.log(
309
+ `\n${BOLD}${CYAN}--- Skill-Script Integrations (${keys.length}) ---${RESET}\n`,
310
+ );
311
+ for (const skill of keys) {
312
+ const script = integratedSkills[skill];
313
+ console.log(` ${BOLD}${skill}${RESET}`);
314
+ console.log(` ↳ ${GREEN}${script}${RESET}\n`);
315
+ }
316
+ console.log(
317
+ `${CYAN}To run a skill script, use: python <path> or node <path>${RESET}\n`,
318
+ );
319
+ }
320
+ }
321
+ }
322
+
323
+ module.exports = { getAssociatedScript, verifyScript };
324
+
325
+ if (require.main === module) {
326
+ main();
327
+ }