tribunal-kit 4.2.0 → 4.3.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 (186) hide show
  1. package/.agent/ARCHITECTURE.md +21 -14
  2. package/.agent/agents/swarm-worker-contracts.md +5 -5
  3. package/.agent/agents/ui-ux-auditor.md +292 -0
  4. package/.agent/rules/GEMINI.md +8 -8
  5. package/.agent/scripts/__pycache__/_colors.cpython-311.pyc +0 -0
  6. package/.agent/scripts/__pycache__/_utils.cpython-311.pyc +0 -0
  7. package/.agent/scripts/__pycache__/case_law_manager.cpython-311.pyc +0 -0
  8. package/.agent/scripts/_colors.js +18 -0
  9. package/.agent/scripts/_utils.js +42 -0
  10. package/.agent/scripts/auto_preview.js +197 -0
  11. package/.agent/scripts/bundle_analyzer.js +290 -0
  12. package/.agent/scripts/case_law_manager.js +684 -0
  13. package/.agent/scripts/checklist.js +266 -0
  14. package/.agent/scripts/colors.js +17 -0
  15. package/.agent/scripts/compress_skills.js +141 -0
  16. package/.agent/scripts/consolidate_skills.js +149 -0
  17. package/.agent/scripts/context_broker.js +609 -0
  18. package/.agent/scripts/deep_compress.js +150 -0
  19. package/.agent/scripts/dependency_analyzer.js +272 -0
  20. package/.agent/scripts/graph_builder.js +199 -0
  21. package/.agent/scripts/graph_zoom.js +154 -0
  22. package/.agent/scripts/inner_loop_validator.js +465 -0
  23. package/.agent/scripts/lint_runner.js +187 -0
  24. package/.agent/scripts/minify_context.js +100 -0
  25. package/.agent/scripts/patch_skills_meta.js +156 -0
  26. package/.agent/scripts/patch_skills_output.js +244 -0
  27. package/.agent/scripts/schema_validator.js +297 -0
  28. package/.agent/scripts/security_scan.js +303 -0
  29. package/.agent/scripts/session_manager.js +276 -0
  30. package/.agent/scripts/skill_evolution.js +644 -0
  31. package/.agent/scripts/skill_integrator.js +313 -0
  32. package/.agent/scripts/strengthen_skills.js +193 -0
  33. package/.agent/scripts/strip_tribunal.js +47 -0
  34. package/.agent/scripts/swarm_dispatcher.js +360 -0
  35. package/.agent/scripts/test_runner.js +193 -0
  36. package/.agent/scripts/utils.js +32 -0
  37. package/.agent/scripts/verify_all.js +256 -0
  38. package/.agent/skills/agent-organizer/SKILL.md +12 -4
  39. package/.agent/skills/agentic-patterns/SKILL.md +12 -4
  40. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +12 -4
  41. package/.agent/skills/api-patterns/SKILL.md +209 -201
  42. package/.agent/skills/api-security-auditor/SKILL.md +12 -4
  43. package/.agent/skills/app-builder/SKILL.md +12 -4
  44. package/.agent/skills/app-builder/templates/SKILL.md +76 -68
  45. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +1 -1
  46. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  47. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +1 -1
  48. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  49. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +1 -1
  50. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +1 -1
  51. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +1 -1
  52. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +1 -1
  53. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
  54. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +1 -1
  55. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +1 -1
  56. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +1 -1
  57. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +1 -1
  58. package/.agent/skills/appflow-wireframe/SKILL.md +12 -4
  59. package/.agent/skills/architecture/SKILL.md +12 -4
  60. package/.agent/skills/authentication-best-practices/SKILL.md +12 -4
  61. package/.agent/skills/bash-linux/SKILL.md +12 -4
  62. package/.agent/skills/behavioral-modes/SKILL.md +12 -4
  63. package/.agent/skills/brainstorming/SKILL.md +12 -4
  64. package/.agent/skills/building-native-ui/SKILL.md +12 -4
  65. package/.agent/skills/clean-code/SKILL.md +12 -4
  66. package/.agent/skills/code-review-checklist/SKILL.md +12 -4
  67. package/.agent/skills/config-validator/SKILL.md +12 -4
  68. package/.agent/skills/csharp-developer/SKILL.md +12 -4
  69. package/.agent/skills/data-validation-schemas/SKILL.md +290 -282
  70. package/.agent/skills/database-design/SKILL.md +202 -194
  71. package/.agent/skills/deployment-procedures/SKILL.md +12 -4
  72. package/.agent/skills/devops-engineer/SKILL.md +12 -4
  73. package/.agent/skills/devops-incident-responder/SKILL.md +12 -4
  74. package/.agent/skills/doc.md +1 -1
  75. package/.agent/skills/documentation-templates/SKILL.md +12 -4
  76. package/.agent/skills/edge-computing/SKILL.md +12 -4
  77. package/.agent/skills/error-resilience/SKILL.md +390 -382
  78. package/.agent/skills/extract-design-system/SKILL.md +12 -4
  79. package/.agent/skills/framer-motion-expert/SKILL.md +206 -199
  80. package/.agent/skills/frontend-design/SKILL.md +163 -155
  81. package/.agent/skills/game-design-expert/SKILL.md +12 -4
  82. package/.agent/skills/game-engineering-expert/SKILL.md +12 -4
  83. package/.agent/skills/geo-fundamentals/SKILL.md +12 -4
  84. package/.agent/skills/github-operations/SKILL.md +12 -4
  85. package/.agent/skills/gsap-core/SKILL.md +54 -48
  86. package/.agent/skills/gsap-frameworks/SKILL.md +54 -48
  87. package/.agent/skills/gsap-performance/SKILL.md +54 -48
  88. package/.agent/skills/gsap-plugins/SKILL.md +54 -48
  89. package/.agent/skills/gsap-react/SKILL.md +54 -48
  90. package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -48
  91. package/.agent/skills/gsap-timeline/SKILL.md +54 -48
  92. package/.agent/skills/gsap-utils/SKILL.md +54 -48
  93. package/.agent/skills/i18n-localization/SKILL.md +12 -4
  94. package/.agent/skills/intelligent-routing/SKILL.md +41 -33
  95. package/.agent/skills/knowledge-graph/SKILL.md +36 -0
  96. package/.agent/skills/lint-and-validate/SKILL.md +12 -4
  97. package/.agent/skills/llm-engineering/SKILL.md +12 -4
  98. package/.agent/skills/local-first/SKILL.md +12 -4
  99. package/.agent/skills/mcp-builder/SKILL.md +12 -4
  100. package/.agent/skills/mobile-design/SKILL.md +225 -217
  101. package/.agent/skills/monorepo-management/SKILL.md +296 -288
  102. package/.agent/skills/motion-engineering/SKILL.md +195 -187
  103. package/.agent/skills/nextjs-react-expert/SKILL.md +196 -188
  104. package/.agent/skills/nodejs-best-practices/SKILL.md +12 -4
  105. package/.agent/skills/observability/SKILL.md +12 -4
  106. package/.agent/skills/parallel-agents/SKILL.md +12 -4
  107. package/.agent/skills/performance-profiling/SKILL.md +12 -4
  108. package/.agent/skills/plan-writing/SKILL.md +12 -4
  109. package/.agent/skills/platform-engineer/SKILL.md +12 -4
  110. package/.agent/skills/playwright-best-practices/SKILL.md +12 -4
  111. package/.agent/skills/powershell-windows/SKILL.md +12 -4
  112. package/.agent/skills/project-idioms/SKILL.md +12 -4
  113. package/.agent/skills/python-patterns/SKILL.md +12 -4
  114. package/.agent/skills/python-pro/SKILL.md +285 -277
  115. package/.agent/skills/react-specialist/SKILL.md +239 -231
  116. package/.agent/skills/readme-builder/SKILL.md +12 -4
  117. package/.agent/skills/realtime-patterns/SKILL.md +12 -4
  118. package/.agent/skills/red-team-tactics/SKILL.md +12 -4
  119. package/.agent/skills/rust-pro/SKILL.md +12 -4
  120. package/.agent/skills/seo-fundamentals/SKILL.md +12 -4
  121. package/.agent/skills/server-management/SKILL.md +12 -4
  122. package/.agent/skills/shadcn-ui-expert/SKILL.md +12 -4
  123. package/.agent/skills/skill-creator/SKILL.md +12 -4
  124. package/.agent/skills/sql-pro/SKILL.md +12 -4
  125. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +12 -4
  126. package/.agent/skills/swiftui-expert/SKILL.md +12 -4
  127. package/.agent/skills/systematic-debugging/SKILL.md +12 -4
  128. package/.agent/skills/tailwind-patterns/SKILL.md +12 -4
  129. package/.agent/skills/tdd-workflow/SKILL.md +12 -4
  130. package/.agent/skills/test-result-analyzer/SKILL.md +12 -4
  131. package/.agent/skills/testing-patterns/SKILL.md +12 -4
  132. package/.agent/skills/trend-researcher/SKILL.md +12 -4
  133. package/.agent/skills/typescript-advanced/SKILL.md +297 -289
  134. package/.agent/skills/ui-ux-pro-max/SKILL.md +12 -4
  135. package/.agent/skills/ui-ux-researcher/SKILL.md +12 -4
  136. package/.agent/skills/vue-expert/SKILL.md +237 -229
  137. package/.agent/skills/vulnerability-scanner/SKILL.md +12 -4
  138. package/.agent/skills/web-accessibility-auditor/SKILL.md +12 -4
  139. package/.agent/skills/web-design-guidelines/SKILL.md +12 -4
  140. package/.agent/skills/webapp-testing/SKILL.md +12 -4
  141. package/.agent/skills/whimsy-injector/SKILL.md +12 -4
  142. package/.agent/skills/workflow-optimizer/SKILL.md +12 -4
  143. package/.agent/workflows/audit.md +6 -6
  144. package/.agent/workflows/deploy.md +1 -1
  145. package/.agent/workflows/generate.md +23 -6
  146. package/.agent/workflows/session.md +5 -5
  147. package/.agent/workflows/swarm.md +2 -2
  148. package/README.md +242 -186
  149. package/bin/tribunal-kit.js +297 -57
  150. package/package.json +81 -77
  151. package/scripts/changelog.js +167 -0
  152. package/scripts/sync-version.js +81 -0
  153. package/scripts/validate-payload.js +73 -0
  154. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  155. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  156. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  157. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  158. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  159. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  160. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  161. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  162. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  163. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  164. package/.agent/scripts/auto_preview.py +0 -180
  165. package/.agent/scripts/bundle_analyzer.py +0 -259
  166. package/.agent/scripts/case_law_manager.py +0 -755
  167. package/.agent/scripts/checklist.py +0 -209
  168. package/.agent/scripts/compress_skills.py +0 -167
  169. package/.agent/scripts/consolidate_skills.py +0 -173
  170. package/.agent/scripts/deep_compress.py +0 -202
  171. package/.agent/scripts/dependency_analyzer.py +0 -247
  172. package/.agent/scripts/lint_runner.py +0 -188
  173. package/.agent/scripts/minify_context.py +0 -80
  174. package/.agent/scripts/patch_skills_meta.py +0 -177
  175. package/.agent/scripts/patch_skills_output.py +0 -285
  176. package/.agent/scripts/schema_validator.py +0 -279
  177. package/.agent/scripts/security_scan.py +0 -224
  178. package/.agent/scripts/session_manager.py +0 -261
  179. package/.agent/scripts/skill_evolution.py +0 -563
  180. package/.agent/scripts/skill_integrator.py +0 -234
  181. package/.agent/scripts/strengthen_skills.py +0 -220
  182. package/.agent/scripts/strip_tribunal.py +0 -41
  183. package/.agent/scripts/swarm_dispatcher.py +0 -350
  184. package/.agent/scripts/test_runner.py +0 -192
  185. package/.agent/scripts/test_swarm_dispatcher.py +0 -163
  186. package/.agent/scripts/verify_all.py +0 -195
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * lint_runner.js — Standalone lint runner for the Tribunal Agent Kit.
4
+ *
5
+ * Usage:
6
+ * node .agent/scripts/lint_runner.js .
7
+ * node .agent/scripts/lint_runner.js . --fix
8
+ * node .agent/scripts/lint_runner.js . --files src/index.ts src/utils.ts
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { spawnSync } = require('child_process');
16
+
17
+ const { RED, GREEN, YELLOW, BLUE, BOLD, RESET } = require('./colors.js');
18
+
19
+ function header(title) {
20
+ console.log(`\n${BOLD}${BLUE}━━━ ${title} ━━━${RESET}`);
21
+ }
22
+
23
+ function ok(msg) {
24
+ console.log(` ${GREEN}✅ ${msg}${RESET}`);
25
+ }
26
+
27
+ function fail(msg) {
28
+ console.log(` ${RED}❌ ${msg}${RESET}`);
29
+ }
30
+
31
+ function skip(msg) {
32
+ console.log(` ${YELLOW}⏭️ ${msg}${RESET}`);
33
+ }
34
+
35
+ function runLinter(label, cmd, cwd) {
36
+ try {
37
+ const executable = process.platform === 'win32' && cmd[0] === 'npx' ? 'npx.cmd' : cmd[0];
38
+ const result = spawnSync(executable, cmd.slice(1), {
39
+ cwd,
40
+ encoding: 'utf8',
41
+ timeout: 120000,
42
+ shell: process.platform === 'win32'
43
+ });
44
+
45
+ if (result.status === 0) {
46
+ ok(`${label} — clean`);
47
+ return true;
48
+ }
49
+
50
+ fail(`${label} — issues found`);
51
+ if (result.error) {
52
+ console.log(` Error: ${result.error.message}`);
53
+ }
54
+ const out = result.stdout ? result.stdout.toString() : '';
55
+ const err = result.stderr ? result.stderr.toString() : '';
56
+ const output = (out + "\n" + err).trim();
57
+ if (output) {
58
+ const lines = output.split('\n');
59
+ for (const line of lines.slice(0, 15)) {
60
+ console.log(` ${line}`);
61
+ }
62
+ if (lines.length > 15) {
63
+ console.log(` ... and ${lines.length - 15} more lines`);
64
+ }
65
+ }
66
+ return false;
67
+ } catch {
68
+ skip(`${label} — tool not installed`);
69
+ return true;
70
+ }
71
+ }
72
+
73
+ function detectLinters(projectRoot) {
74
+ const available = {};
75
+ const pkgJson = path.join(projectRoot, "package.json");
76
+
77
+ if (fs.existsSync(pkgJson)) {
78
+ const eslintFiles = [".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml", "eslint.config.js", "eslint.config.mjs"];
79
+ available.eslint = eslintFiles.some(f => fs.existsSync(path.join(projectRoot, f)));
80
+
81
+ const prettierFiles = [".prettierrc", ".prettierrc.js", ".prettierrc.json", "prettier.config.js"];
82
+ available.prettier = prettierFiles.some(f => fs.existsSync(path.join(projectRoot, f)));
83
+ }
84
+
85
+ available.ruff = fs.existsSync(path.join(projectRoot, "pyproject.toml")) || fs.existsSync(path.join(projectRoot, "ruff.toml"));
86
+ available.flake8 = fs.existsSync(path.join(projectRoot, ".flake8")) || fs.existsSync(path.join(projectRoot, "setup.cfg"));
87
+
88
+ return available;
89
+ }
90
+
91
+ function main() {
92
+ const args = process.argv.slice(2);
93
+ let targetPath = null;
94
+ let fixFlag = false;
95
+ let fileArgs = [];
96
+
97
+ let i = 0;
98
+ while (i < args.length) {
99
+ if (args[i] === '--fix') fixFlag = true;
100
+ else if (args[i] === '--files') {
101
+ i++;
102
+ while (i < args.length && !args[i].startsWith('--')) {
103
+ fileArgs.push(args[i++]);
104
+ }
105
+ continue;
106
+ } else if (!targetPath && !args[i].startsWith('-')) {
107
+ targetPath = args[i];
108
+ }
109
+ i++;
110
+ }
111
+
112
+ if (!targetPath) {
113
+ console.log("Usage: node lint_runner.js <path> [--fix] [--files <file1> <file2> ...]");
114
+ process.exit(1);
115
+ }
116
+
117
+ const projectRoot = path.resolve(targetPath);
118
+ if (!fs.existsSync(projectRoot) || !fs.statSync(projectRoot).isDirectory()) {
119
+ fail(`Directory not found: ${projectRoot}`);
120
+ process.exit(1);
121
+ }
122
+
123
+ console.log(`${BOLD}Tribunal — lint_runner.js${RESET}`);
124
+ console.log(`Project: ${projectRoot}`);
125
+
126
+ const available = detectLinters(projectRoot);
127
+ if (!Object.values(available).some(Boolean)) {
128
+ skip("No linter configuration detected in this project");
129
+ process.exit(0);
130
+ }
131
+
132
+ let failures = 0;
133
+
134
+ if (available.eslint) {
135
+ header("ESLint");
136
+ const cmd = ["npx", "eslint"];
137
+ if (fixFlag) cmd.push("--fix");
138
+ if (fileArgs.length) cmd.push(...fileArgs);
139
+ else cmd.push(".", "--max-warnings=0");
140
+ if (!runLinter("ESLint", cmd, projectRoot)) failures++;
141
+ }
142
+
143
+ if (available.prettier) {
144
+ header("Prettier");
145
+ const cmd = ["npx", "prettier"];
146
+ if (fixFlag) cmd.push("--write");
147
+ else cmd.push("--check");
148
+ if (fileArgs.length) cmd.push(...fileArgs);
149
+ else cmd.push(".");
150
+ if (!runLinter("Prettier", cmd, projectRoot)) failures++;
151
+ }
152
+
153
+ if (available.ruff) {
154
+ header("Ruff (Python)");
155
+ const cmd = ["ruff", "check"];
156
+ if (fixFlag) cmd.push("--fix");
157
+ if (fileArgs.length) cmd.push(...fileArgs);
158
+ else cmd.push(".");
159
+ if (!runLinter("Ruff", cmd, projectRoot)) failures++;
160
+ }
161
+
162
+ if (available.flake8 && !available.ruff) {
163
+ header("Flake8 (Python)");
164
+ const cmd = ["flake8"];
165
+ if (fileArgs.length) cmd.push(...fileArgs);
166
+ else cmd.push(".");
167
+ if (!runLinter("Flake8", cmd, projectRoot)) failures++;
168
+ }
169
+
170
+ if (fs.existsSync(path.join(projectRoot, "tsconfig.json"))) {
171
+ header("TypeScript");
172
+ if (!runLinter("TypeScript", ["npx", "tsc", "--noEmit"], projectRoot)) failures++;
173
+ }
174
+
175
+ console.log(`\n${BOLD}━━━ Lint Summary ━━━${RESET}`);
176
+ if (failures === 0) {
177
+ ok("All linters passed");
178
+ } else {
179
+ fail(`${failures} linter(s) reported issues`);
180
+ }
181
+
182
+ process.exit(failures > 0 ? 1 : 0);
183
+ }
184
+
185
+ if (require.main === module) {
186
+ main();
187
+ }
@@ -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
+ }