tribunal-kit 4.4.0 → 4.4.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.
- package/.agent/agents/api-architect.md +66 -66
- package/.agent/agents/db-latency-auditor.md +216 -216
- package/.agent/agents/precedence-reviewer.md +250 -250
- package/.agent/agents/resilience-reviewer.md +88 -88
- package/.agent/agents/schema-reviewer.md +67 -67
- package/.agent/agents/throughput-optimizer.md +299 -299
- package/.agent/agents/ui-ux-auditor.md +292 -292
- package/.agent/agents/vitals-reviewer.md +223 -223
- package/.agent/scripts/_colors.js +18 -18
- package/.agent/scripts/_utils.js +42 -42
- package/.agent/scripts/append_flow.js +72 -72
- package/.agent/scripts/auto_preview.js +197 -197
- package/.agent/scripts/bundle_analyzer.js +290 -290
- package/.agent/scripts/case_law_manager.js +17 -6
- package/.agent/scripts/checklist.js +266 -266
- package/.agent/scripts/colors.js +17 -17
- package/.agent/scripts/compress_skills.js +141 -141
- package/.agent/scripts/consolidate_skills.js +149 -149
- package/.agent/scripts/context_broker.js +611 -609
- package/.agent/scripts/deep_compress.js +150 -150
- package/.agent/scripts/dependency_analyzer.js +272 -272
- package/.agent/scripts/graph_builder.js +313 -311
- package/.agent/scripts/graph_visualizer.js +384 -384
- package/.agent/scripts/inner_loop_validator.js +451 -465
- package/.agent/scripts/lint_runner.js +187 -187
- package/.agent/scripts/minify_context.js +100 -100
- package/.agent/scripts/mutation_runner.js +280 -280
- package/.agent/scripts/patch_skills_meta.js +156 -156
- package/.agent/scripts/patch_skills_output.js +244 -244
- package/.agent/scripts/schema_validator.js +297 -297
- package/.agent/scripts/security_scan.js +303 -303
- package/.agent/scripts/session_manager.js +276 -276
- package/.agent/scripts/skill_evolution.js +644 -644
- package/.agent/scripts/skill_integrator.js +313 -313
- package/.agent/scripts/strengthen_skills.js +193 -193
- package/.agent/scripts/strip_tribunal.js +47 -47
- package/.agent/scripts/swarm_dispatcher.js +360 -360
- package/.agent/scripts/test_runner.js +193 -193
- package/.agent/scripts/utils.js +32 -32
- package/.agent/scripts/verify_all.js +257 -256
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +1 -1
- package/.agent/skills/doc.md +1 -1
- package/.agent/skills/knowledge-graph/SKILL.md +52 -52
- package/.agent/skills/ui-ux-pro-max/SKILL.md +562 -562
- package/.agent/workflows/generate.md +183 -183
- package/.agent/workflows/tribunal-speed.md +183 -183
- package/README.md +1 -1
- package/bin/tribunal-kit.js +76 -87
- package/package.json +6 -3
- package/scripts/changelog.js +167 -167
- package/scripts/sync-version.js +81 -81
- package/.agent/history/architecture-explorer.html +0 -352
- package/.agent/history/architecture-graph.yaml +0 -109
- package/.agent/history/graph-cache.json +0 -215
- package/.agent/history/snapshots/migrate_refs.js.json +0 -11
- package/.agent/history/snapshots/scripts__changelog.js.json +0 -12
- package/.agent/history/snapshots/scripts__sync-version.js.json +0 -11
- package/.agent/history/snapshots/scripts__validate-payload.js.json +0 -11
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +0 -13
- package/.agent/history/snapshots/test__integration__init.test.js.json +0 -13
- package/.agent/history/snapshots/test__integration__routing.test.js.json +0 -11
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +0 -13
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +0 -13
- package/.agent/history/snapshots/test__unit__args.test.js.json +0 -10
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +0 -10
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +0 -13
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +0 -11
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +0 -13
- package/.agent/history/snapshots/test__unit__semver.test.js.json +0 -10
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +0 -11
- package/.agent/scripts/__pycache__/_colors.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/_utils.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/case_law_manager.cpython-311.pyc +0 -0
|
@@ -1,244 +1,244 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* patch_skills_output.js — Adds structured Output Format sections to SKILL.md files.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
|
|
11
|
-
const { RED, GREEN, YELLOW, BLUE, BOLD, RESET } = require('./colors.js');
|
|
12
|
-
|
|
13
|
-
const CODE_QUALITY_TEMPLATE = `\\
|
|
14
|
-
## Output Format
|
|
15
|
-
|
|
16
|
-
When this skill produces or reviews code, structure your output as follows:
|
|
17
|
-
|
|
18
|
-
\`\`\`
|
|
19
|
-
━━━ {skill_name} Report ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
20
|
-
Skill: {skill_name}
|
|
21
|
-
Language: [detected language / framework]
|
|
22
|
-
Scope: [N files · N functions]
|
|
23
|
-
─────────────────────────────────────────────────
|
|
24
|
-
✅ Passed: [checks that passed, or "All clean"]
|
|
25
|
-
⚠️ Warnings: [non-blocking issues, or "None"]
|
|
26
|
-
❌ Blocked: [blocking issues requiring fix, or "None"]
|
|
27
|
-
─────────────────────────────────────────────────
|
|
28
|
-
VBC status: PENDING → VERIFIED
|
|
29
|
-
Evidence: [test output / lint pass / compile success]
|
|
30
|
-
\`\`\`
|
|
31
|
-
|
|
32
|
-
**VBC (Verification-Before-Completion) is mandatory.**
|
|
33
|
-
Do not mark status as VERIFIED until concrete terminal evidence is provided.
|
|
34
|
-
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
const DECISION_CARD_TEMPLATE = `\\
|
|
38
|
-
## Output Format
|
|
39
|
-
|
|
40
|
-
When this skill produces a recommendation or design decision, structure your output as:
|
|
41
|
-
|
|
42
|
-
\`\`\`
|
|
43
|
-
━━━ {skill_name} Recommendation ━━━━━━━━━━━━━━━━
|
|
44
|
-
Decision: [what was chosen / proposed]
|
|
45
|
-
Rationale: [why — one concise line]
|
|
46
|
-
Trade-offs: [what is consciously accepted]
|
|
47
|
-
Next action: [concrete next step for the user]
|
|
48
|
-
─────────────────────────────────────────────────
|
|
49
|
-
Pre-Flight: ✅ All checks passed
|
|
50
|
-
or ❌ [blocking item that must be resolved first]
|
|
51
|
-
\`\`\`
|
|
52
|
-
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
const GENERIC_TEMPLATE = `\\
|
|
56
|
-
## Output Format
|
|
57
|
-
|
|
58
|
-
When this skill completes a task, structure your output as:
|
|
59
|
-
|
|
60
|
-
\`\`\`
|
|
61
|
-
━━━ {skill_name} Output ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
62
|
-
Task: [what was performed]
|
|
63
|
-
Result: [outcome summary — one line]
|
|
64
|
-
─────────────────────────────────────────────────
|
|
65
|
-
Checks: ✅ [N passed] · ⚠️ [N warnings] · ❌ [N blocked]
|
|
66
|
-
VBC status: PENDING → VERIFIED
|
|
67
|
-
Evidence: [link to terminal output, test result, or file diff]
|
|
68
|
-
\`\`\`
|
|
69
|
-
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
|
-
const CODE_GEN_SKILLS = new Set([
|
|
73
|
-
"python-pro", "clean-code", "dotnet-core-expert", "rust-pro",
|
|
74
|
-
"nextjs-react-expert", "vue-expert", "react-specialist",
|
|
75
|
-
"csharp-developer", "nodejs-best-practices", "python-patterns",
|
|
76
|
-
"tailwind-patterns", "bash-linux", "powershell-windows",
|
|
77
|
-
"llm-engineering", "mcp-builder", "game-development",
|
|
78
|
-
"edge-computing", "local-first", "realtime-patterns",
|
|
79
|
-
"tdd-workflow", "testing-patterns", "lint-and-validate",
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
const DECISION_SKILLS = new Set([
|
|
83
|
-
"api-patterns", "database-design", "architecture", "observability",
|
|
84
|
-
"devops-engineer", "platform-engineer", "deployment-procedures",
|
|
85
|
-
"server-management", "security-auditor", "vulnerability-scanner",
|
|
86
|
-
"red-team-tactics", "performance-profiling", "i18n-localization",
|
|
87
|
-
"geo-fundamentals", "seo-fundamentals", "sql-pro",
|
|
88
|
-
"brainstorming", "plan-writing", "behavioral-modes",
|
|
89
|
-
"app-builder", "intelligent-routing", "mobile-design",
|
|
90
|
-
"frontend-design", "ui-ux-pro-max", "ui-ux-researcher",
|
|
91
|
-
"web-design-guidelines", "trend-researcher",
|
|
92
|
-
]);
|
|
93
|
-
|
|
94
|
-
const ALREADY_HAVE_OUTPUT = new Set([
|
|
95
|
-
"whimsy-injector", "workflow-optimizer",
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
const EXISTING_OUTPUT_MARKERS = [
|
|
99
|
-
"## Output Format",
|
|
100
|
-
"## Output\n",
|
|
101
|
-
"## Report Format",
|
|
102
|
-
"## Output Card",
|
|
103
|
-
"Whimsy Injection Report",
|
|
104
|
-
"Workflow Optimization Report",
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
function getTemplate(skillName) {
|
|
108
|
-
if (CODE_GEN_SKILLS.has(skillName)) return CODE_QUALITY_TEMPLATE;
|
|
109
|
-
if (DECISION_SKILLS.has(skillName)) return DECISION_CARD_TEMPLATE;
|
|
110
|
-
return GENERIC_TEMPLATE;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function hasOutputSection(content) {
|
|
114
|
-
return EXISTING_OUTPUT_MARKERS.some(m => content.includes(m));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function getSkillNameFromFrontmatter(content) {
|
|
118
|
-
const match = content.match(/^name:\s*(.+)$/m);
|
|
119
|
-
return match ? match[1].trim() : null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function buildBlock(template, skillName) {
|
|
123
|
-
const display = skillName.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
124
|
-
// Handle the slash escaping issue using regular replace
|
|
125
|
-
const tplStr = template.replace(/^\\/, '');
|
|
126
|
-
return tplStr.replace(/{skill_name}/g, display);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function injectOutputBlock(content, block) {
|
|
130
|
-
const tribunalMarkers = [
|
|
131
|
-
"## 🏛️ Tribunal Integration",
|
|
132
|
-
"## Tribunal Integration",
|
|
133
|
-
];
|
|
134
|
-
for (const marker of tribunalMarkers) {
|
|
135
|
-
const idx = content.indexOf(marker);
|
|
136
|
-
if (idx !== -1) {
|
|
137
|
-
return content.substring(0, idx) + block + "\n---\n\n" + content.substring(idx);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return content.trimEnd() + "\n\n---\n\n" + block;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function header(title) { console.log(`\n${BOLD}${BLUE}━━━ ${title} ━━━${RESET}`); }
|
|
144
|
-
function ok(msg) { console.log(` ${GREEN}✅ ${msg}${RESET}`); }
|
|
145
|
-
function skip(msg) { console.log(` ${YELLOW}⏭️ ${msg}${RESET}`); }
|
|
146
|
-
function warn(msg) { console.log(` ${YELLOW}⚠️ ${msg}${RESET}`); }
|
|
147
|
-
function fail(msg) { console.log(` ${RED}❌ ${msg}${RESET}`); }
|
|
148
|
-
|
|
149
|
-
function processSkill(skillDir, dryRun) {
|
|
150
|
-
const skillName = path.basename(skillDir);
|
|
151
|
-
const skillMd = path.join(skillDir, "SKILL.md");
|
|
152
|
-
|
|
153
|
-
if (!fs.existsSync(skillMd)) return "skipped";
|
|
154
|
-
|
|
155
|
-
try {
|
|
156
|
-
const content = fs.readFileSync(skillMd, 'utf8');
|
|
157
|
-
|
|
158
|
-
if (ALREADY_HAVE_OUTPUT.has(skillName) || hasOutputSection(content)) {
|
|
159
|
-
skip(`${skillName} — output format already present`);
|
|
160
|
-
return "skipped";
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const displayName = getSkillNameFromFrontmatter(content) || skillName;
|
|
164
|
-
const template = getTemplate(skillName);
|
|
165
|
-
const block = buildBlock(template, displayName);
|
|
166
|
-
const patched = injectOutputBlock(content, block);
|
|
167
|
-
|
|
168
|
-
const templateType = CODE_GEN_SKILLS.has(skillName) ? "Code Quality" : (DECISION_SKILLS.has(skillName) ? "Decision Card" : "Generic");
|
|
169
|
-
|
|
170
|
-
if (dryRun) {
|
|
171
|
-
warn(`[DRY RUN] ${skillName} — would add Output Format (${templateType})`);
|
|
172
|
-
return "updated";
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
fs.writeFileSync(skillMd, patched, 'utf8');
|
|
176
|
-
ok(`${skillName} — added Output Format (${templateType})`);
|
|
177
|
-
return "updated";
|
|
178
|
-
} catch (e) {
|
|
179
|
-
fail(`${skillName} — ${e.message}`);
|
|
180
|
-
return "error";
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function main() {
|
|
185
|
-
const args = process.argv.slice(2);
|
|
186
|
-
let targetPath = null;
|
|
187
|
-
let dryRun = false;
|
|
188
|
-
let skillArg = null;
|
|
189
|
-
|
|
190
|
-
let i = 0;
|
|
191
|
-
while (i < args.length) {
|
|
192
|
-
if (args[i] === '--dry-run') dryRun = true;
|
|
193
|
-
else if (args[i] === '--skill' && i + 1 < args.length) skillArg = args[++i];
|
|
194
|
-
else if (args[i] === '-h' || args[i] === '--help') {
|
|
195
|
-
console.log("Usage: node patch_skills_output.js <path> [--dry-run] [--skill <name>]");
|
|
196
|
-
process.exit(0);
|
|
197
|
-
} else if (!args[i].startsWith('-') && !targetPath) {
|
|
198
|
-
targetPath = args[i];
|
|
199
|
-
}
|
|
200
|
-
i++;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (!targetPath) {
|
|
204
|
-
console.log("Usage: node patch_skills_output.js <path> [--dry-run] [--skill <name>]");
|
|
205
|
-
process.exit(1);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const projectRoot = path.resolve(targetPath);
|
|
209
|
-
const skillsDir = path.join(projectRoot, ".agent", "skills");
|
|
210
|
-
|
|
211
|
-
if (!fs.existsSync(skillsDir) || !fs.statSync(skillsDir).isDirectory()) {
|
|
212
|
-
fail(`Skills directory not found: ${skillsDir}`);
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
console.log(`${BOLD}Tribunal — patch_skills_output.js${RESET}`);
|
|
217
|
-
if (dryRun) console.log(` ${YELLOW}DRY RUN — no files will be written${RESET}`);
|
|
218
|
-
console.log(`Skills dir: ${skillsDir}\n`);
|
|
219
|
-
|
|
220
|
-
const counts = { updated: 0, skipped: 0, error: 0 };
|
|
221
|
-
header("Patching Output Format Sections");
|
|
222
|
-
|
|
223
|
-
const dirs = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
224
|
-
dirs.sort((a, b) => a.name.localeCompare(b.name));
|
|
225
|
-
|
|
226
|
-
for (const dir of dirs) {
|
|
227
|
-
if (!dir.isDirectory()) continue;
|
|
228
|
-
if (skillArg && dir.name !== skillArg) continue;
|
|
229
|
-
const result = processSkill(path.join(skillsDir, dir.name), dryRun);
|
|
230
|
-
counts[result]++;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
console.log(`\n${BOLD}━━━ Summary ━━━${RESET}`);
|
|
234
|
-
console.log(` ${GREEN}✅ Updated: ${counts.updated}${RESET}`);
|
|
235
|
-
console.log(` ${YELLOW}⏭️ Skipped: ${counts.skipped}${RESET}`);
|
|
236
|
-
if (counts.error > 0) console.log(` ${RED}❌ Errors: ${counts.error}${RESET}`);
|
|
237
|
-
if (dryRun) console.log(` ${YELLOW}(dry-run — nothing written)${RESET}`);
|
|
238
|
-
|
|
239
|
-
process.exit(counts.error > 0 ? 1 : 0);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (require.main === module) {
|
|
243
|
-
main();
|
|
244
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* patch_skills_output.js — Adds structured Output Format sections to SKILL.md files.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
const { RED, GREEN, YELLOW, BLUE, BOLD, RESET } = require('./colors.js');
|
|
12
|
+
|
|
13
|
+
const CODE_QUALITY_TEMPLATE = `\\
|
|
14
|
+
## Output Format
|
|
15
|
+
|
|
16
|
+
When this skill produces or reviews code, structure your output as follows:
|
|
17
|
+
|
|
18
|
+
\`\`\`
|
|
19
|
+
━━━ {skill_name} Report ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
20
|
+
Skill: {skill_name}
|
|
21
|
+
Language: [detected language / framework]
|
|
22
|
+
Scope: [N files · N functions]
|
|
23
|
+
─────────────────────────────────────────────────
|
|
24
|
+
✅ Passed: [checks that passed, or "All clean"]
|
|
25
|
+
⚠️ Warnings: [non-blocking issues, or "None"]
|
|
26
|
+
❌ Blocked: [blocking issues requiring fix, or "None"]
|
|
27
|
+
─────────────────────────────────────────────────
|
|
28
|
+
VBC status: PENDING → VERIFIED
|
|
29
|
+
Evidence: [test output / lint pass / compile success]
|
|
30
|
+
\`\`\`
|
|
31
|
+
|
|
32
|
+
**VBC (Verification-Before-Completion) is mandatory.**
|
|
33
|
+
Do not mark status as VERIFIED until concrete terminal evidence is provided.
|
|
34
|
+
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const DECISION_CARD_TEMPLATE = `\\
|
|
38
|
+
## Output Format
|
|
39
|
+
|
|
40
|
+
When this skill produces a recommendation or design decision, structure your output as:
|
|
41
|
+
|
|
42
|
+
\`\`\`
|
|
43
|
+
━━━ {skill_name} Recommendation ━━━━━━━━━━━━━━━━
|
|
44
|
+
Decision: [what was chosen / proposed]
|
|
45
|
+
Rationale: [why — one concise line]
|
|
46
|
+
Trade-offs: [what is consciously accepted]
|
|
47
|
+
Next action: [concrete next step for the user]
|
|
48
|
+
─────────────────────────────────────────────────
|
|
49
|
+
Pre-Flight: ✅ All checks passed
|
|
50
|
+
or ❌ [blocking item that must be resolved first]
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
const GENERIC_TEMPLATE = `\\
|
|
56
|
+
## Output Format
|
|
57
|
+
|
|
58
|
+
When this skill completes a task, structure your output as:
|
|
59
|
+
|
|
60
|
+
\`\`\`
|
|
61
|
+
━━━ {skill_name} Output ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
62
|
+
Task: [what was performed]
|
|
63
|
+
Result: [outcome summary — one line]
|
|
64
|
+
─────────────────────────────────────────────────
|
|
65
|
+
Checks: ✅ [N passed] · ⚠️ [N warnings] · ❌ [N blocked]
|
|
66
|
+
VBC status: PENDING → VERIFIED
|
|
67
|
+
Evidence: [link to terminal output, test result, or file diff]
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
const CODE_GEN_SKILLS = new Set([
|
|
73
|
+
"python-pro", "clean-code", "dotnet-core-expert", "rust-pro",
|
|
74
|
+
"nextjs-react-expert", "vue-expert", "react-specialist",
|
|
75
|
+
"csharp-developer", "nodejs-best-practices", "python-patterns",
|
|
76
|
+
"tailwind-patterns", "bash-linux", "powershell-windows",
|
|
77
|
+
"llm-engineering", "mcp-builder", "game-development",
|
|
78
|
+
"edge-computing", "local-first", "realtime-patterns",
|
|
79
|
+
"tdd-workflow", "testing-patterns", "lint-and-validate",
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
const DECISION_SKILLS = new Set([
|
|
83
|
+
"api-patterns", "database-design", "architecture", "observability",
|
|
84
|
+
"devops-engineer", "platform-engineer", "deployment-procedures",
|
|
85
|
+
"server-management", "security-auditor", "vulnerability-scanner",
|
|
86
|
+
"red-team-tactics", "performance-profiling", "i18n-localization",
|
|
87
|
+
"geo-fundamentals", "seo-fundamentals", "sql-pro",
|
|
88
|
+
"brainstorming", "plan-writing", "behavioral-modes",
|
|
89
|
+
"app-builder", "intelligent-routing", "mobile-design",
|
|
90
|
+
"frontend-design", "ui-ux-pro-max", "ui-ux-researcher",
|
|
91
|
+
"web-design-guidelines", "trend-researcher",
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
const ALREADY_HAVE_OUTPUT = new Set([
|
|
95
|
+
"whimsy-injector", "workflow-optimizer",
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
const EXISTING_OUTPUT_MARKERS = [
|
|
99
|
+
"## Output Format",
|
|
100
|
+
"## Output\n",
|
|
101
|
+
"## Report Format",
|
|
102
|
+
"## Output Card",
|
|
103
|
+
"Whimsy Injection Report",
|
|
104
|
+
"Workflow Optimization Report",
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
function getTemplate(skillName) {
|
|
108
|
+
if (CODE_GEN_SKILLS.has(skillName)) return CODE_QUALITY_TEMPLATE;
|
|
109
|
+
if (DECISION_SKILLS.has(skillName)) return DECISION_CARD_TEMPLATE;
|
|
110
|
+
return GENERIC_TEMPLATE;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function hasOutputSection(content) {
|
|
114
|
+
return EXISTING_OUTPUT_MARKERS.some(m => content.includes(m));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function getSkillNameFromFrontmatter(content) {
|
|
118
|
+
const match = content.match(/^name:\s*(.+)$/m);
|
|
119
|
+
return match ? match[1].trim() : null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function buildBlock(template, skillName) {
|
|
123
|
+
const display = skillName.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
124
|
+
// Handle the slash escaping issue using regular replace
|
|
125
|
+
const tplStr = template.replace(/^\\/, '');
|
|
126
|
+
return tplStr.replace(/{skill_name}/g, display);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function injectOutputBlock(content, block) {
|
|
130
|
+
const tribunalMarkers = [
|
|
131
|
+
"## 🏛️ Tribunal Integration",
|
|
132
|
+
"## Tribunal Integration",
|
|
133
|
+
];
|
|
134
|
+
for (const marker of tribunalMarkers) {
|
|
135
|
+
const idx = content.indexOf(marker);
|
|
136
|
+
if (idx !== -1) {
|
|
137
|
+
return content.substring(0, idx) + block + "\n---\n\n" + content.substring(idx);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return content.trimEnd() + "\n\n---\n\n" + block;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function header(title) { console.log(`\n${BOLD}${BLUE}━━━ ${title} ━━━${RESET}`); }
|
|
144
|
+
function ok(msg) { console.log(` ${GREEN}✅ ${msg}${RESET}`); }
|
|
145
|
+
function skip(msg) { console.log(` ${YELLOW}⏭️ ${msg}${RESET}`); }
|
|
146
|
+
function warn(msg) { console.log(` ${YELLOW}⚠️ ${msg}${RESET}`); }
|
|
147
|
+
function fail(msg) { console.log(` ${RED}❌ ${msg}${RESET}`); }
|
|
148
|
+
|
|
149
|
+
function processSkill(skillDir, dryRun) {
|
|
150
|
+
const skillName = path.basename(skillDir);
|
|
151
|
+
const skillMd = path.join(skillDir, "SKILL.md");
|
|
152
|
+
|
|
153
|
+
if (!fs.existsSync(skillMd)) return "skipped";
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
const content = fs.readFileSync(skillMd, 'utf8');
|
|
157
|
+
|
|
158
|
+
if (ALREADY_HAVE_OUTPUT.has(skillName) || hasOutputSection(content)) {
|
|
159
|
+
skip(`${skillName} — output format already present`);
|
|
160
|
+
return "skipped";
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const displayName = getSkillNameFromFrontmatter(content) || skillName;
|
|
164
|
+
const template = getTemplate(skillName);
|
|
165
|
+
const block = buildBlock(template, displayName);
|
|
166
|
+
const patched = injectOutputBlock(content, block);
|
|
167
|
+
|
|
168
|
+
const templateType = CODE_GEN_SKILLS.has(skillName) ? "Code Quality" : (DECISION_SKILLS.has(skillName) ? "Decision Card" : "Generic");
|
|
169
|
+
|
|
170
|
+
if (dryRun) {
|
|
171
|
+
warn(`[DRY RUN] ${skillName} — would add Output Format (${templateType})`);
|
|
172
|
+
return "updated";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fs.writeFileSync(skillMd, patched, 'utf8');
|
|
176
|
+
ok(`${skillName} — added Output Format (${templateType})`);
|
|
177
|
+
return "updated";
|
|
178
|
+
} catch (e) {
|
|
179
|
+
fail(`${skillName} — ${e.message}`);
|
|
180
|
+
return "error";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function main() {
|
|
185
|
+
const args = process.argv.slice(2);
|
|
186
|
+
let targetPath = null;
|
|
187
|
+
let dryRun = false;
|
|
188
|
+
let skillArg = null;
|
|
189
|
+
|
|
190
|
+
let i = 0;
|
|
191
|
+
while (i < args.length) {
|
|
192
|
+
if (args[i] === '--dry-run') dryRun = true;
|
|
193
|
+
else if (args[i] === '--skill' && i + 1 < args.length) skillArg = args[++i];
|
|
194
|
+
else if (args[i] === '-h' || args[i] === '--help') {
|
|
195
|
+
console.log("Usage: node patch_skills_output.js <path> [--dry-run] [--skill <name>]");
|
|
196
|
+
process.exit(0);
|
|
197
|
+
} else if (!args[i].startsWith('-') && !targetPath) {
|
|
198
|
+
targetPath = args[i];
|
|
199
|
+
}
|
|
200
|
+
i++;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!targetPath) {
|
|
204
|
+
console.log("Usage: node patch_skills_output.js <path> [--dry-run] [--skill <name>]");
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const projectRoot = path.resolve(targetPath);
|
|
209
|
+
const skillsDir = path.join(projectRoot, ".agent", "skills");
|
|
210
|
+
|
|
211
|
+
if (!fs.existsSync(skillsDir) || !fs.statSync(skillsDir).isDirectory()) {
|
|
212
|
+
fail(`Skills directory not found: ${skillsDir}`);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
console.log(`${BOLD}Tribunal — patch_skills_output.js${RESET}`);
|
|
217
|
+
if (dryRun) console.log(` ${YELLOW}DRY RUN — no files will be written${RESET}`);
|
|
218
|
+
console.log(`Skills dir: ${skillsDir}\n`);
|
|
219
|
+
|
|
220
|
+
const counts = { updated: 0, skipped: 0, error: 0 };
|
|
221
|
+
header("Patching Output Format Sections");
|
|
222
|
+
|
|
223
|
+
const dirs = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
224
|
+
dirs.sort((a, b) => a.name.localeCompare(b.name));
|
|
225
|
+
|
|
226
|
+
for (const dir of dirs) {
|
|
227
|
+
if (!dir.isDirectory()) continue;
|
|
228
|
+
if (skillArg && dir.name !== skillArg) continue;
|
|
229
|
+
const result = processSkill(path.join(skillsDir, dir.name), dryRun);
|
|
230
|
+
counts[result]++;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
console.log(`\n${BOLD}━━━ Summary ━━━${RESET}`);
|
|
234
|
+
console.log(` ${GREEN}✅ Updated: ${counts.updated}${RESET}`);
|
|
235
|
+
console.log(` ${YELLOW}⏭️ Skipped: ${counts.skipped}${RESET}`);
|
|
236
|
+
if (counts.error > 0) console.log(` ${RED}❌ Errors: ${counts.error}${RESET}`);
|
|
237
|
+
if (dryRun) console.log(` ${YELLOW}(dry-run — nothing written)${RESET}`);
|
|
238
|
+
|
|
239
|
+
process.exit(counts.error > 0 ? 1 : 0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (require.main === module) {
|
|
243
|
+
main();
|
|
244
|
+
}
|