tribunal-kit 4.0.1 → 4.3.0

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 (196) hide show
  1. package/.agent/ARCHITECTURE.md +21 -14
  2. package/.agent/GEMINI.md +4 -2
  3. package/.agent/agents/api-architect.md +66 -0
  4. package/.agent/agents/db-latency-auditor.md +216 -0
  5. package/.agent/agents/precedence-reviewer.md +41 -4
  6. package/.agent/agents/resilience-reviewer.md +88 -0
  7. package/.agent/agents/schema-reviewer.md +67 -0
  8. package/.agent/agents/swarm-worker-contracts.md +5 -5
  9. package/.agent/agents/throughput-optimizer.md +299 -0
  10. package/.agent/agents/ui-ux-auditor.md +292 -0
  11. package/.agent/agents/vitals-reviewer.md +223 -0
  12. package/.agent/history/case-law/cases/case-0001.json +33 -0
  13. package/.agent/history/case-law/index.json +35 -0
  14. package/.agent/rules/GEMINI.md +28 -11
  15. package/.agent/scripts/__pycache__/_colors.cpython-311.pyc +0 -0
  16. package/.agent/scripts/__pycache__/_utils.cpython-311.pyc +0 -0
  17. package/.agent/scripts/__pycache__/case_law_manager.cpython-311.pyc +0 -0
  18. package/.agent/scripts/_colors.js +18 -0
  19. package/.agent/scripts/_utils.js +42 -0
  20. package/.agent/scripts/auto_preview.js +197 -0
  21. package/.agent/scripts/bundle_analyzer.js +290 -0
  22. package/.agent/scripts/case_law_manager.js +684 -0
  23. package/.agent/scripts/checklist.js +266 -0
  24. package/.agent/scripts/colors.js +17 -0
  25. package/.agent/scripts/compress_skills.js +141 -0
  26. package/.agent/scripts/consolidate_skills.js +149 -0
  27. package/.agent/scripts/context_broker.js +609 -0
  28. package/.agent/scripts/deep_compress.js +150 -0
  29. package/.agent/scripts/dependency_analyzer.js +272 -0
  30. package/.agent/scripts/inner_loop_validator.js +465 -0
  31. package/.agent/scripts/lint_runner.js +187 -0
  32. package/.agent/scripts/minify_context.js +100 -0
  33. package/.agent/scripts/patch_skills_meta.js +156 -0
  34. package/.agent/scripts/patch_skills_output.js +244 -0
  35. package/.agent/scripts/schema_validator.js +297 -0
  36. package/.agent/scripts/security_scan.js +303 -0
  37. package/.agent/scripts/session_manager.js +276 -0
  38. package/.agent/scripts/skill_evolution.js +644 -0
  39. package/.agent/scripts/skill_integrator.js +313 -0
  40. package/.agent/scripts/strengthen_skills.js +193 -0
  41. package/.agent/scripts/strip_tribunal.js +47 -0
  42. package/.agent/scripts/swarm_dispatcher.js +360 -0
  43. package/.agent/scripts/test_runner.js +193 -0
  44. package/.agent/scripts/utils.js +32 -0
  45. package/.agent/scripts/verify_all.js +256 -0
  46. package/.agent/skills/agent-organizer/SKILL.md +42 -0
  47. package/.agent/skills/agentic-patterns/SKILL.md +42 -0
  48. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +42 -0
  49. package/.agent/skills/api-patterns/SKILL.md +42 -0
  50. package/.agent/skills/api-security-auditor/SKILL.md +42 -0
  51. package/.agent/skills/app-builder/SKILL.md +42 -0
  52. package/.agent/skills/app-builder/templates/SKILL.md +70 -0
  53. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +1 -1
  54. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  55. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +1 -1
  56. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  57. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +1 -1
  58. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +1 -1
  59. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +1 -1
  60. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +1 -1
  61. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
  62. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +1 -1
  63. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +1 -1
  64. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +1 -1
  65. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +1 -1
  66. package/.agent/skills/appflow-wireframe/SKILL.md +42 -0
  67. package/.agent/skills/architecture/SKILL.md +42 -0
  68. package/.agent/skills/authentication-best-practices/SKILL.md +42 -0
  69. package/.agent/skills/bash-linux/SKILL.md +42 -0
  70. package/.agent/skills/behavioral-modes/SKILL.md +42 -0
  71. package/.agent/skills/brainstorming/SKILL.md +42 -0
  72. package/.agent/skills/building-native-ui/SKILL.md +42 -0
  73. package/.agent/skills/clean-code/SKILL.md +42 -0
  74. package/.agent/skills/code-review-checklist/SKILL.md +42 -0
  75. package/.agent/skills/config-validator/SKILL.md +42 -0
  76. package/.agent/skills/csharp-developer/SKILL.md +42 -0
  77. package/.agent/skills/data-validation-schemas/SKILL.md +320 -0
  78. package/.agent/skills/database-design/SKILL.md +42 -0
  79. package/.agent/skills/deployment-procedures/SKILL.md +42 -0
  80. package/.agent/skills/devops-engineer/SKILL.md +42 -0
  81. package/.agent/skills/devops-incident-responder/SKILL.md +42 -0
  82. package/.agent/skills/doc.md +1 -1
  83. package/.agent/skills/documentation-templates/SKILL.md +42 -0
  84. package/.agent/skills/edge-computing/SKILL.md +42 -0
  85. package/.agent/skills/error-resilience/SKILL.md +420 -0
  86. package/.agent/skills/extract-design-system/SKILL.md +42 -0
  87. package/.agent/skills/framer-motion-expert/SKILL.md +42 -1
  88. package/.agent/skills/frontend-design/SKILL.md +42 -0
  89. package/.agent/skills/game-design-expert/SKILL.md +42 -0
  90. package/.agent/skills/game-engineering-expert/SKILL.md +42 -0
  91. package/.agent/skills/geo-fundamentals/SKILL.md +42 -0
  92. package/.agent/skills/github-operations/SKILL.md +42 -0
  93. package/.agent/skills/gsap-core/SKILL.md +300 -0
  94. package/.agent/skills/gsap-frameworks/SKILL.md +199 -0
  95. package/.agent/skills/gsap-performance/SKILL.md +125 -0
  96. package/.agent/skills/gsap-plugins/SKILL.md +472 -0
  97. package/.agent/skills/gsap-react/SKILL.md +181 -0
  98. package/.agent/skills/gsap-scrolltrigger/SKILL.md +342 -0
  99. package/.agent/skills/gsap-timeline/SKILL.md +153 -0
  100. package/.agent/skills/gsap-utils/SKILL.md +330 -0
  101. package/.agent/skills/i18n-localization/SKILL.md +42 -0
  102. package/.agent/skills/intelligent-routing/SKILL.md +72 -1
  103. package/.agent/skills/lint-and-validate/SKILL.md +42 -0
  104. package/.agent/skills/llm-engineering/SKILL.md +42 -0
  105. package/.agent/skills/local-first/SKILL.md +42 -0
  106. package/.agent/skills/mcp-builder/SKILL.md +42 -0
  107. package/.agent/skills/mobile-design/SKILL.md +42 -0
  108. package/.agent/skills/monorepo-management/SKILL.md +326 -0
  109. package/.agent/skills/motion-engineering/SKILL.md +42 -0
  110. package/.agent/skills/nextjs-react-expert/SKILL.md +42 -0
  111. package/.agent/skills/nodejs-best-practices/SKILL.md +42 -0
  112. package/.agent/skills/observability/SKILL.md +42 -0
  113. package/.agent/skills/parallel-agents/SKILL.md +42 -0
  114. package/.agent/skills/performance-profiling/SKILL.md +42 -0
  115. package/.agent/skills/plan-writing/SKILL.md +42 -0
  116. package/.agent/skills/platform-engineer/SKILL.md +42 -0
  117. package/.agent/skills/playwright-best-practices/SKILL.md +42 -0
  118. package/.agent/skills/powershell-windows/SKILL.md +42 -0
  119. package/.agent/skills/project-idioms/SKILL.md +42 -0
  120. package/.agent/skills/python-patterns/SKILL.md +42 -0
  121. package/.agent/skills/python-pro/SKILL.md +42 -0
  122. package/.agent/skills/react-specialist/SKILL.md +42 -0
  123. package/.agent/skills/readme-builder/SKILL.md +42 -0
  124. package/.agent/skills/realtime-patterns/SKILL.md +42 -0
  125. package/.agent/skills/red-team-tactics/SKILL.md +42 -0
  126. package/.agent/skills/rust-pro/SKILL.md +42 -0
  127. package/.agent/skills/seo-fundamentals/SKILL.md +42 -0
  128. package/.agent/skills/server-management/SKILL.md +42 -0
  129. package/.agent/skills/shadcn-ui-expert/SKILL.md +42 -0
  130. package/.agent/skills/skill-creator/SKILL.md +42 -0
  131. package/.agent/skills/sql-pro/SKILL.md +42 -0
  132. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +42 -0
  133. package/.agent/skills/swiftui-expert/SKILL.md +42 -0
  134. package/.agent/skills/systematic-debugging/SKILL.md +42 -0
  135. package/.agent/skills/tailwind-patterns/SKILL.md +42 -0
  136. package/.agent/skills/tdd-workflow/SKILL.md +42 -0
  137. package/.agent/skills/test-result-analyzer/SKILL.md +42 -0
  138. package/.agent/skills/testing-patterns/SKILL.md +42 -0
  139. package/.agent/skills/trend-researcher/SKILL.md +42 -0
  140. package/.agent/skills/typescript-advanced/SKILL.md +327 -0
  141. package/.agent/skills/ui-ux-pro-max/SKILL.md +42 -0
  142. package/.agent/skills/ui-ux-researcher/SKILL.md +42 -0
  143. package/.agent/skills/vue-expert/SKILL.md +42 -0
  144. package/.agent/skills/vulnerability-scanner/SKILL.md +42 -0
  145. package/.agent/skills/web-accessibility-auditor/SKILL.md +42 -0
  146. package/.agent/skills/web-design-guidelines/SKILL.md +42 -0
  147. package/.agent/skills/webapp-testing/SKILL.md +42 -0
  148. package/.agent/skills/whimsy-injector/SKILL.md +42 -0
  149. package/.agent/skills/workflow-optimizer/SKILL.md +42 -0
  150. package/.agent/workflows/audit.md +6 -6
  151. package/.agent/workflows/deploy.md +1 -1
  152. package/.agent/workflows/generate.md +23 -6
  153. package/.agent/workflows/session.md +5 -5
  154. package/.agent/workflows/swarm.md +2 -2
  155. package/.agent/workflows/tribunal-backend.md +13 -2
  156. package/.agent/workflows/tribunal-full.md +15 -8
  157. package/.agent/workflows/tribunal-speed.md +183 -0
  158. package/README.md +64 -8
  159. package/bin/tribunal-kit.js +281 -41
  160. package/package.json +9 -6
  161. package/scripts/changelog.js +167 -0
  162. package/scripts/sync-version.js +81 -0
  163. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  164. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  165. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  166. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  167. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  168. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  169. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  170. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  171. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  172. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  173. package/.agent/scripts/auto_preview.py +0 -180
  174. package/.agent/scripts/bundle_analyzer.py +0 -259
  175. package/.agent/scripts/case_law_manager.py +0 -525
  176. package/.agent/scripts/checklist.py +0 -209
  177. package/.agent/scripts/compress_skills.py +0 -167
  178. package/.agent/scripts/consolidate_skills.py +0 -173
  179. package/.agent/scripts/deep_compress.py +0 -202
  180. package/.agent/scripts/dependency_analyzer.py +0 -247
  181. package/.agent/scripts/lint_runner.py +0 -188
  182. package/.agent/scripts/minify_context.py +0 -80
  183. package/.agent/scripts/patch_skills_meta.py +0 -177
  184. package/.agent/scripts/patch_skills_output.py +0 -285
  185. package/.agent/scripts/schema_validator.py +0 -279
  186. package/.agent/scripts/security_scan.py +0 -224
  187. package/.agent/scripts/session_manager.py +0 -261
  188. package/.agent/scripts/skill_evolution.py +0 -563
  189. package/.agent/scripts/skill_integrator.py +0 -234
  190. package/.agent/scripts/strengthen_skills.py +0 -220
  191. package/.agent/scripts/strip_tribunal.py +0 -41
  192. package/.agent/scripts/swarm_dispatcher.py +0 -350
  193. package/.agent/scripts/test_runner.py +0 -192
  194. package/.agent/scripts/test_swarm_dispatcher.py +0 -163
  195. package/.agent/scripts/verify_all.py +0 -195
  196. package/.agent/skills/gsap-expert/SKILL.md +0 -194
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * minify_context.js
4
+ * Minifies markdown documentation in the .agent directory to save tokens.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+
12
+ function minifyMarkdown(filePath) {
13
+ let content = fs.readFileSync(filePath, 'utf8');
14
+ const originalLen = content.length;
15
+
16
+ // 1. Strip repetitive Output Format templates
17
+ content = content.replace(/## Output Format\n\n```[\s\S]*?```\n/g, '');
18
+
19
+ // 2. Convert bloated Cross-Workflow Navigation tables to dense YAML lists
20
+ content = content.replace(/## Cross-Workflow Navigation\n\n\|.*?\|[\s\S]*?(?=\n## |\Z)/g, match => {
21
+ const lines = match.trim().split('\n');
22
+ const out = [];
23
+ for (const line of lines) {
24
+ if (line.startsWith('|') && !line.startsWith('|:') && !line.startsWith('| After')) {
25
+ const parts = line.split('|').map(p => p.trim()).filter(Boolean);
26
+ if (parts.length >= 2) {
27
+ out.push(`- ${parts[0]} -> ${parts[1]}`);
28
+ }
29
+ }
30
+ }
31
+ return '## Cross-Workflow Navigation\n' + out.join('\n') + '\n';
32
+ });
33
+
34
+ // 3. Collapse multiple empty lines into a single one
35
+ content = content.replace(/\n{3,}/g, '\n\n');
36
+
37
+ // 4. Remove padding from remaining tables to save space tokens
38
+ content = content.replace(/^\|.+|$/gm, match => {
39
+ let line = match;
40
+ // remove spaces around |
41
+ line = line.replace(/\s+\|\s+/g, '|');
42
+ line = line.replace(/\|\s+/g, '|');
43
+ line = line.replace(/\s+\|/g, '|');
44
+ return line;
45
+ });
46
+
47
+ // 5. Remove conversational blockquotes > if they don't contain WARNING/NOTE/IMPORTANT
48
+ content = content.replace(/^>.*$/gm, match => {
49
+ if (match.includes('⚠️') || match.includes('WARNING') || match.includes('CRITICAL') || match.includes('!')) {
50
+ return match;
51
+ }
52
+ return match.replace(/> /g, '').replace(/>/g, '');
53
+ });
54
+
55
+ // 6. Dense Examples (convert ❌ Bad: and ✅ Good: blocks to single lines)
56
+ content = content.replace(/\n❌ Bad:/g, ' ❌');
57
+ content = content.replace(/\n✅ Good:/g, ' ✅');
58
+
59
+ fs.writeFileSync(filePath, content, 'utf8');
60
+ return [originalLen, content.length];
61
+ }
62
+
63
+ function walkDir(dir, callback) {
64
+ if (!fs.existsSync(dir)) return;
65
+ const items = fs.readdirSync(dir, { withFileTypes: true });
66
+ for (const item of items) {
67
+ const fullPath = path.join(dir, item.name);
68
+ if (item.isDirectory()) {
69
+ walkDir(fullPath, callback);
70
+ } else {
71
+ callback(fullPath);
72
+ }
73
+ }
74
+ }
75
+
76
+ function main() {
77
+ const agentDir = path.join('.agent');
78
+ let totalOriginal = 0;
79
+ let totalNew = 0;
80
+
81
+ walkDir(agentDir, file => {
82
+ if (file.endsWith('.md')) {
83
+ const [orig, newLen] = minifyMarkdown(file);
84
+ totalOriginal += orig;
85
+ totalNew += newLen;
86
+ }
87
+ });
88
+
89
+ const saved = totalOriginal - totalNew;
90
+ const percent = totalOriginal > 0 ? (saved / totalOriginal * 100) : 0;
91
+
92
+ console.log("Minification Complete.");
93
+ console.log(`Original size: ${totalOriginal} bytes`);
94
+ console.log(`New size: ${totalNew} bytes`);
95
+ console.log(`Saved: ${saved} bytes (${percent.toFixed(1)}%)`);
96
+ }
97
+
98
+ if (require.main === module) {
99
+ main();
100
+ }
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * patch_skills_meta.js — Injects version/freshness metadata into SKILL.md frontmatter.
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 META_FIELDS = {
14
+ "version": "1.0.0",
15
+ "last-updated": "2026-03-12",
16
+ "applies-to-model": "gemini-2.5-pro, claude-3-7-sonnet"
17
+ };
18
+
19
+ function header(title) { console.log(`\n${BOLD}${BLUE}━━━ ${title} ━━━${RESET}`); }
20
+ function ok(msg) { console.log(` ${GREEN}✅ ${msg}${RESET}`); }
21
+ function skip(msg) { console.log(` ${YELLOW}⏭️ ${msg}${RESET}`); }
22
+ function warn(msg) { console.log(` ${YELLOW}⚠️ ${msg}${RESET}`); }
23
+ function fail(msg) { console.log(` ${RED}❌ ${msg}${RESET}`); }
24
+
25
+ function patchFrontmatter(content) {
26
+ const added = [];
27
+ const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
28
+
29
+ if (!fmMatch) {
30
+ const newFmLines = ["---"];
31
+ for (const [key, value] of Object.entries(META_FIELDS)) {
32
+ newFmLines.push(`${key}: ${value}`);
33
+ added.push(key);
34
+ }
35
+ newFmLines.push("---");
36
+ return [newFmLines.join("\n") + "\n\n" + content, added];
37
+ }
38
+
39
+ const fmText = fmMatch[1];
40
+ const fmEnd = fmMatch[0].length;
41
+
42
+ const existingKeys = new Set();
43
+ const lines = fmText.split("\n");
44
+ for (const line of lines) {
45
+ const m = line.match(/^([a-zA-Z0-9_-]+)\s*:/);
46
+ if (m) existingKeys.add(m[1]);
47
+ }
48
+
49
+ const newFmLines = fmText.trimEnd().split("\n");
50
+ for (const [key, value] of Object.entries(META_FIELDS)) {
51
+ if (!existingKeys.has(key)) {
52
+ newFmLines.push(`${key}: ${value}`);
53
+ added.push(key);
54
+ }
55
+ }
56
+
57
+ if (added.length === 0) return [content, []];
58
+
59
+ const patched = "---\n" + newFmLines.join("\n") + "\n---" + content.slice(fmEnd);
60
+ return [patched, added];
61
+ }
62
+
63
+ function processSkill(skillPath, dryRun) {
64
+ const skillName = path.basename(path.dirname(skillPath));
65
+ try {
66
+ const content = fs.readFileSync(skillPath, 'utf8');
67
+ const [patched, added] = patchFrontmatter(content);
68
+
69
+ if (added.length === 0) {
70
+ skip(`${skillName} — all meta fields present`);
71
+ return "skipped";
72
+ }
73
+
74
+ const fieldList = added.join(', ');
75
+ if (dryRun) {
76
+ warn(`[DRY RUN] ${skillName} — would add: ${fieldList}`);
77
+ return "updated";
78
+ }
79
+
80
+ fs.writeFileSync(skillPath, patched, 'utf8');
81
+ ok(`${skillName} — added: ${fieldList}`);
82
+ return "updated";
83
+ } catch (e) {
84
+ fail(`${skillName} — ${e.message}`);
85
+ return "error";
86
+ }
87
+ }
88
+
89
+ function main() {
90
+ const args = process.argv.slice(2);
91
+ let targetPath = null;
92
+ let dryRun = false;
93
+ let skillArg = null;
94
+
95
+ let i = 0;
96
+ while (i < args.length) {
97
+ if (args[i] === '--dry-run') dryRun = true;
98
+ else if (args[i] === '--skill' && i + 1 < args.length) skillArg = args[++i];
99
+ else if (args[i] === '-h' || args[i] === '--help') {
100
+ console.log("Usage: node patch_skills_meta.js <path> [--dry-run] [--skill <name>]");
101
+ process.exit(0);
102
+ } else if (!args[i].startsWith('-') && !targetPath) {
103
+ targetPath = args[i];
104
+ }
105
+ i++;
106
+ }
107
+
108
+ if (!targetPath) {
109
+ console.log("Usage: node patch_skills_meta.js <path> [--dry-run] [--skill <name>]");
110
+ process.exit(1);
111
+ }
112
+
113
+ const projectRoot = path.resolve(targetPath);
114
+ const skillsDir = path.join(projectRoot, ".agent", "skills");
115
+
116
+ if (!fs.existsSync(skillsDir) || !fs.statSync(skillsDir).isDirectory()) {
117
+ fail(`Skills directory not found: ${skillsDir}`);
118
+ process.exit(1);
119
+ }
120
+
121
+ console.log(`${BOLD}Tribunal — patch_skills_meta.js${RESET}`);
122
+ if (dryRun) console.log(` ${YELLOW}DRY RUN — no files will be written${RESET}`);
123
+ console.log(`Skills dir: ${skillsDir}\n`);
124
+
125
+ const counts = { updated: 0, skipped: 0, error: 0 };
126
+ header("Patching Frontmatter");
127
+
128
+ const dirs = fs.readdirSync(skillsDir, { withFileTypes: true });
129
+ dirs.sort((a, b) => a.name.localeCompare(b.name));
130
+
131
+ for (const dir of dirs) {
132
+ if (!dir.isDirectory()) continue;
133
+ if (skillArg && dir.name !== skillArg) continue;
134
+
135
+ const skillMd = path.join(skillsDir, dir.name, "SKILL.md");
136
+ if (!fs.existsSync(skillMd)) {
137
+ warn(`${dir.name} — no SKILL.md found`);
138
+ continue;
139
+ }
140
+
141
+ const result = processSkill(skillMd, dryRun);
142
+ counts[result]++;
143
+ }
144
+
145
+ console.log(`\n${BOLD}━━━ Summary ━━━${RESET}`);
146
+ console.log(` ${GREEN}✅ Updated: ${counts.updated}${RESET}`);
147
+ console.log(` ${YELLOW}⏭️ Skipped: ${counts.skipped}${RESET}`);
148
+ if (counts.error > 0) console.log(` ${RED}❌ Errors: ${counts.error}${RESET}`);
149
+ if (dryRun) console.log(` ${YELLOW}(dry-run — nothing written)${RESET}`);
150
+
151
+ process.exit(counts.error > 0 ? 1 : 0);
152
+ }
153
+
154
+ if (require.main === module) {
155
+ main();
156
+ }
@@ -0,0 +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
+ }