tribunal-kit 4.4.3 → 4.4.4

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/README.md CHANGED
@@ -1,242 +1,113 @@
1
- <div align="center">
2
- <picture>
3
- <img src="./docs/tribunalkit_no_bg.png" alt="TribunalKit — Code Without Hallucinations" width="480">
4
- </picture>
5
-
6
- <br><br>
7
-
8
- [![NPM](https://img.shields.io/npm/v/tribunal-kit?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/tribunal-kit)
9
- [![License](https://img.shields.io/badge/License-MIT-8b5cf6?style=for-the-badge)](LICENSE)
10
- [![Version](https://img.shields.io/badge/Version-4.3.1_Supreme_Court-black?style=for-the-badge)](CHANGELOG.md)
11
- </div>
12
-
13
-
14
- <br><br>
15
-
16
- > 🚨 **AI GENERATES CODE. TRIBUNAL ENSURES IT WORKS.**
17
- > A plug-in `.agent/` intelligence payload that upgrades your IDE with **41 specialist agents**, **31 slash commands**, **91 hardened skills**, and a **16-reviewer Tribunal pipeline** — zero hallucinations, zero configuration.
18
-
19
- ---
20
-
21
- <br>
22
-
23
- ## ▓▒░ INITIATION SEQUENCE
24
-
25
- Drop Tribunal into any project. Global or local.
26
-
27
- ```bash
28
- # Pull the intelligence payload into your project
29
- npx tribunal-kit init
30
- ```
31
- *(Installs the `.agent/` architecture directly. No bloat. Pure capability.)*
32
-
33
- <details>
34
- <summary><b>📺 Quick Demo — What happens when you run it</b></summary>
35
- <br>
36
-
37
- ```
38
- $ npx tribunal-kit init
39
-
40
- ████████╗██████╗ ██╗██████╗ ██╗ ██╗███╗ ██╗ █████╗ ██╗
41
- ╚══██╔══╝██╔══██╗██║██╔══██╗██║ ██║████╗ ██║██╔══██╗██║
42
- ██║ ██████╔╝██║██████╔╝██║ ██║██╔██╗ ██║███████║██║
43
- ██║ ██╔══██╗██║██╔══██╗██║ ██║██║╚██╗██║██╔══██║██║
44
- ██║ ██║ ██║██║██████╔╝╚██████╔╝██║ ╚████║██║ ██║███████╗
45
- ╚═╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝
46
-
47
- ╔══════════════════════════════════════════════════════════════╗
48
- ║ Anti-Hallucination Agent System ║
49
- ╚══════════════════════════════════════════════════════════════╝
50
-
51
- Installed .agent/
52
-
53
- ╔══════════════════════════════════════════════════════════════╗
54
- ║ 🤖 Agents 41 installed ║
55
- ║ ⚡ Workflows 32 installed ║
56
- ║ 🧠 Skills 91 installed ║
57
- ║ 🔧 Scripts 27 installed ║
58
- ╚══════════════════════════════════════════════════════════════╝
59
-
60
- 700+ files installed. 16 parallel Tribunal reviewers armed.
61
-
62
- $ npx tribunal-kit status
63
-
64
- Installed at .agent/
65
- 🤖 agents 40 files
66
- ⚡ workflows 31 files
67
- 🧠 skills 90 files
68
- 🔧 scripts 27 files
69
- ```
70
-
71
- > 💡 **Lighter install?** Use `npx tribunal-kit init --minimal` for just 13 core agents + 15 essential skills.
72
-
73
- </details>
74
-
75
- > ✅ **IDE Auto-Detection:** `init` automatically generates bridge files for every major AI coding IDE:
76
- >
77
- > | IDE | Bridge File Generated |
78
- > | :--- | :--- |
79
- > | **Cursor** | `.cursorrules` |
80
- > | **Windsurf** | `.windsurfrules` |
81
- > | **Gemini / Antigravity** | `.gemini/settings.json` + `.gemini/GEMINI.md` |
82
- > | **GitHub Copilot** | `.github/copilot-instructions.md` |
83
- > | **Claude** | `.claude/CLAUDE.md` |
84
- >
85
- > Bridge files are never overwritten on re-init — your customizations are safe.
86
-
87
- **Prerequisites:** Node.js 18
88
-
89
- > 💡 **Shorthand alias:** You can use `tk` instead of `tribunal-kit` for all commands (e.g., `tk init`, `tk status`).
90
-
91
- <br>
92
-
93
- ## ▓▒░ THE PIPELINE // HOW IT WORKS
94
-
95
- **Code generation is solved. Code correctness is the frontier.** We enforce a strict **Evidence-Based Closeout**.
96
-
97
- ```diff
98
- - AI Generates -> Commits to Disk -> You Find Bugs Later
99
- + AI Generates -> Parallel Tribunal Review -> Human Gate -> Commits to Disk
100
- ```
101
-
102
- ### 🎯 Auto-Routing Intelligence
103
- No manual tagging required. The system self-organizes.
104
-
105
- <p>
106
- <kbd>User</kbd> "Add JWT authentication" <br>
107
- <kbd>System</kbd> <code>🤖 Applying @security-auditor + @backend-specialist...</code> <br><br>
108
-
109
- <kbd>User</kbd> "Fix the dark mode button" <br>
110
- <kbd>System</kbd> <code>🤖 Applying @ui-ux-pro-max + @frontend-specialist...</code> <br><br>
111
-
112
- <kbd>User</kbd> "/swarm build a API" <br>
113
- <kbd>System</kbd> <code>🤖 supervisor-agent → Dispatching 3 Workers...</code>
114
- </p>
115
-
116
- <br>
117
-
118
- ## ▓▒░ THE SUPREME COURT (v4.0)
119
-
120
- *(New in v4)* The Tribunal Kit now features persistent memory so the AI **never makes the same mistake twice** and automatically learns your team's coding style.
121
-
122
- **1. The Case Law Engine (Never repeat mistakes)**
123
- If an agent makes a mistake, you can record it as a legal precedent. Before writing any future code, the `precedence-reviewer` checks this database locally to forcefully block the AI from repeating that mistake.
124
- - `npx tribunal-kit case add` *(Record an AI hallucination)*
125
- - `npx tribunal-kit case search "query"` *(Search your precedents)*
126
-
127
- **2. Skill Evolution Forge (Auto-learns your style)**
128
- You no longer need to write manual rules. The system reads your Git commits, strips out the noise to save tokens, and automatically extracts your project's unique architectural patterns to teach the AI.
129
- - `npx tribunal-kit learn` *(Run a learning digest on staged files)*
130
- - `npx tribunal-kit hook` *(Automate learning every time you `git push`)*
131
-
132
- <br>
133
-
134
- ## ▓▒░ CAPABILITY MATRIX
135
-
136
- | System Asset | Count | Operational Scope |
137
- | :--- | :---: | :--- |
138
- | 🤖 **Agents** | `40` | Specialist personas — 16 reviewers + 24 domain specialists |
139
- | 🧠 **Skills** | `90` | Domain modules (Edge Computing, Red Team Tactics, GSAP, Framer Motion, TypeScript Advanced) |
140
- | ⚡ **Workflows** | `31` | Slash command procedures including `/swarm`, `/tribunal-full`, `/ui-ux-pro-max` |
141
- | 🛠️ **Scripts** | `25` | CI/CD, linting, payload dispatching, security scanning, case law, skill evolution |
142
-
143
-
144
- <br>
145
-
146
- ## ▓▒░ COMMAND TERMINAL
147
-
148
- Expand the accordions to view the operational commands at your disposal.
149
-
150
- <details open>
151
- <summary><b>🔥 CORE EXECUTION</b></summary>
152
- <br>
153
-
154
- | Command | Action |
155
- | :--- | :--- |
156
- | <code>/generate</code> | Trigger full Tribunal: Generate → Audit → Approve. |
157
- | <code>/create</code> | Scaffold major features or apps, routed by App Builder. |
158
- | <code>/enhance</code> | Safely extend existing structures without regression. |
159
- | <code>/deploy</code> | Force the 3-gate production release sequence. |
160
-
161
- </details>
162
-
163
- <details>
164
- <summary><b>⚖️ THE TRIBUNAL GAUNTLET (REVIEWERS)</b></summary>
165
- <br>
166
- Unleash parallel reviewers on existing code.
167
-
168
- | Command | Action |
169
- | :--- | :--- |
170
- | <code>/review</code> | Audit code for silent degradation and logic holes. |
171
- | <code>/tribunal-full</code> | Unleash **ALL 16** reviewers simultaneously. Maximum scrutiny. |
172
- | <code>/tribunal-backend</code> | Summons <code>[ Logic + Security + Dependency + Types ]</code> |
173
- | <code>/tribunal-frontend</code> | Summons <code>[ Logic + Security + Frontend + Types ]</code> |
174
- | <code>/tribunal-database</code> | Summons <code>[ Logic + Security + SQL ]</code> |
175
- | <code>/tribunal-mobile</code> | Summons <code>[ Logic + Security + Mobile ]</code> |
176
-
177
- </details>
178
-
179
- <details>
180
- <summary><b>🧠 SWARM & ORCHESTRATION</b></summary>
181
- <br>
182
-
183
- | Command | Action |
184
- | :--- | :--- |
185
- | <code>/swarm</code> | Supervisor breaks goal → sends to isolated workers → synthesizes. |
186
- | <code>/orchestrate</code> | Manual multi-agent sync for complex integrations. |
187
- | <code>/plan</code> | Architectural mapping before a single line is written. |
188
- | <code>/ui-ux-pro-max</code>| Triggers peak aesthetic frontend design. |
189
-
190
- </details>
191
-
192
- <details>
193
- <summary><b>⚖️ SUPREME COURT / MEMORY</b></summary>
194
- <br>
195
-
196
- | Command | Action |
197
- | :--- | :--- |
198
- | <code>npx tribunal-kit case add</code> | Record an AI hallucination to ban it forever. |
199
- | <code>npx tribunal-kit case search</code> | Search your local database of banned code. |
200
- | <code>npx tribunal-kit learn</code> | Auto-extract project idioms from your git diffs. |
201
- | <code>npx tribunal-kit hook</code> | Install a git hook to auto-learn the moment you push. |
202
-
203
- </details>
204
-
205
- <details>
206
- <summary><b>🔧 TROUBLESHOOTING & OPS</b></summary>
207
- <br>
208
-
209
- | Command | Action |
210
- | :--- | :--- |
211
- | <code>/debug</code> | Systematic root-cause investigation. |
212
- | <code>/preview</code> | Local development server control. |
213
- | <code>/status</code> | View Tribunal session status. |
214
-
215
- </details>
216
-
217
- <br>
218
-
219
- ## ▓▒░ POST-INSTALL TELEMETRY
220
-
221
- After initialization, utility scripts unlock local ops:
222
-
223
- ```bash
224
- # 01. Pre-commit audit
225
- node .agent/scripts/checklist.js .
226
-
227
- # 02. Pre-deploy full suite verification
228
- node .agent/scripts/verify_all.js
229
-
230
- # 03. Start local development environment
231
- node .agent/scripts/auto_preview.js start
232
- ```
233
-
234
- <br>
235
-
236
- <div align="center">
237
- <br>
238
- <img src="https://img.shields.io/badge/Status-Active_&_Secured-00e5ff?style=for-the-badge" alt="Status" />
239
- <br><br>
240
- <i>"Never guess database column names. Error handling on every async function. Evidence-based closeouts. Welcome to the Tribunal."</i><br>
241
- <sub><b>MIT Licensed</b> • Hand-forged for high-performance agentic engineering.</sub>
242
- </div>
1
+ <div align="center">
2
+ <picture>
3
+ <img src="./docs/tribunalkit_no_bg.png" alt="TribunalKit — Code Without Hallucinations" width="480">
4
+ </picture>
5
+
6
+ <br>
7
+
8
+ <h1>TRIBUNAL KIT</h1>
9
+ <p><b>Anti-Hallucination Agent Architecture • Long-Running Autonomy • Pipeline Scrutiny</b></p>
10
+
11
+ [![NPM](https://img.shields.io/npm/v/tribunal-kit?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/tribunal-kit)
12
+ [![License](https://img.shields.io/badge/License-MIT-8b5cf6?style=for-the-badge)](LICENSE)
13
+ [![Version](https://img.shields.io/badge/Version-4.4.4_Marathon-black?style=for-the-badge)](CHANGELOG.md)
14
+ </div>
15
+
16
+ ---
17
+
18
+ > [!IMPORTANT]
19
+ > **AI GENERATES CODE. TRIBUNAL ENSURES IT WORKS.**
20
+ > A zero-bloat `.agent/` intelligence payload that upgrades your IDE with **41 specialist agents**, **31 workflows**, and a **16-reviewer Tribunal pipeline**. Zero hallucinations. Absolute execution certainty.
21
+
22
+ ## ▓▒░ QUICK START
23
+
24
+ Drop Tribunal into any existing project to instantly weaponize your IDE.
25
+
26
+ ```bash
27
+ # Pull the intelligence payload into your project directory
28
+ npx tribunal-kit init
29
+ ```
30
+
31
+ > [!NOTE]
32
+ > `init` automatically generates bridge rules for **Cursor**, **Windsurf**, **Gemini**, **Copilot**, and **Claude**. No configuration required.
33
+
34
+ <br>
35
+
36
+ ## ▓▒░ THE MARATHON HARNESS (v4.4.4)
37
+
38
+ The v4.4 update introduces the **Marathon Harness**—an engine designed to keep autonomous agents on track during long-running, multi-session projects without looping or losing context.
39
+
40
+ ### ⛓️ Directed Acyclic Graph (DAG) Support
41
+ Cascade failures are obsolete. Features can now be declared with dependencies (`--deps=1,2`). If a database schema task fails, the API route task is automatically flagged as **Deadlocked** and bypassed until the root issue is resolved.
42
+
43
+ ### 🧠 Failure Context & Attempt Tracking
44
+ Agents no longer blindly retry failed approaches. When a feature fails, the reason and attempt count are permanently logged into the state matrix. The next agent to attempt the feature receives the exact failure history to course-correct immediately.
45
+
46
+ ### 🔮 Memory Distillation
47
+ Context windows dilute over time. The new `distill` command allows agents to forge crucial architectural decisions into a permanent `distilled_context.md` memory matrix, bridging the amnesia gap between long work sessions.
48
+
49
+ <br>
50
+
51
+ ## ▓▒░ THE PIPELINE // EVIDENCE-BASED CLOSEOUT
52
+
53
+ Code generation is solved. **Code correctness is the frontier.**
54
+
55
+ ```mermaid
56
+ graph TD
57
+ A[User Request] -->|Intent Parsed| B(Context Broker)
58
+ B --> C{Inner-Loop Validator}
59
+
60
+ C -->|Syntax & Secrets Check| D[Parallel Tribunal Review]
61
+ C -.->|Failed| E[Maker Auto-Correction]
62
+ E -.-> C
63
+
64
+ D -->|16 Domain Reviewers| F[Human Gate]
65
+ F -->|Approved| G((Committed to Disk))
66
+
67
+ classDef default fill:#1a1a1a,stroke:#333,stroke-width:2px,color:#fff;
68
+ classDef critical fill:#ff1637,stroke:#fff,stroke-width:2px,color:#fff;
69
+ classDef success fill:#00e5ff,stroke:#fff,stroke-width:2px,color:#1a1a1a;
70
+
71
+ class D critical;
72
+ class G success;
73
+ ```
74
+
75
+ <br>
76
+
77
+ ## ▓▒░ THE SUPREME COURT (CASE LAW ENGINE)
78
+
79
+ The Tribunal Kit features persistent memory. The AI **never makes the same mistake twice** and auto-learns your engineering culture.
80
+
81
+ > [!WARNING]
82
+ > **1. The Case Law Engine**
83
+ > Record mistakes as legal precedent. The `precedence-reviewer` checks this database locally to forcefully block the AI from repeating banned patterns.
84
+ > - `npx tribunal-kit case add` *(Record an AI hallucination)*
85
+
86
+ > [!TIP]
87
+ > **2. Skill Evolution Forge**
88
+ > Stop writing manual rules. The system reads your Git diffs, strips token bloat, and auto-extracts your project's architectural idioms.
89
+ > - `npx tribunal-kit learn` *(Digest staged files)*
90
+
91
+ <br>
92
+
93
+ ## ▓▒░ COMMAND ARSENAL
94
+
95
+ | Slash Command | Operational Scope |
96
+ | :--- | :--- |
97
+ | `/generate` | Full Tribunal sequence: Generate → Audit → Human Gate. |
98
+ | `/create` | Scaffold major applications via App Builder routing. |
99
+ | `/enhance` | Safely extend existing codebases with zero regression. |
100
+ | `/swarm` | Fan-out orchestrator. Dispatch isolated workers, synthesize output. |
101
+ | `/tribunal-full` | Unleash **ALL 16** domain reviewers simultaneously for maximum scrutiny. |
102
+ | `/debug` | Systematic 4-phase root-cause investigation. No guessing. |
103
+ | `/ui-ux-pro-max` | Advanced visual aesthetic engine. No generic AI slop. |
104
+
105
+ <br>
106
+
107
+ <div align="center">
108
+ <br>
109
+ <img src="https://img.shields.io/badge/Status-Active_&_Secured-00e5ff?style=for-the-badge" alt="Status" />
110
+ <br><br>
111
+ <i>"Never guess database column names. Error handling on every async function. Evidence-based closeouts. Welcome to the Tribunal."</i><br>
112
+ <sub><b>MIT Licensed</b> Engineered for maximum autonomy and precision.</sub>
113
+ </div>
@@ -1117,5 +1117,5 @@ runWithUpdateCheck(command, flags);
1117
1117
 
1118
1118
  // -- Exports (for testing) -- do not remove
1119
1119
  if (require.main !== module) {
1120
- module.exports = { parseArgs, compareSemver, copyDir, countDir, isSelfInstall, CORE_AGENTS, CORE_SKILLS, generateIDEBridges };
1121
- }
1120
+ module.exports = { parseArgs, compareSemver, copyDir, countDir, isSelfInstall, CORE_AGENTS, CORE_SKILLS, generateIDEBridges, cmdMarathon };
1121
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tribunal-kit",
3
- "version": "4.4.3",
3
+ "version": "4.4.4",
4
4
  "description": "Anti-Hallucination AI Agent Kit — 40 specialist agents, 32 slash commands, 16 parallel Tribunal reviewers, Performance Swarm engine, Supreme Court case law pipeline, and long-running agent harness.",
5
5
  "keywords": [
6
6
  "ai",
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
- // append_flow.js — append Supreme Court section to AGENT_FLOW.md
3
- const fs = require('fs');
4
- const f = 'AGENT_FLOW.md';
5
-
6
- const appendix = [
7
- '',
8
- '---',
9
- '',
10
- '## Supreme Court Edition — Self-Learning Engine',
11
- '',
12
- 'Tribunal Kit v4.0+ ships two industry-first features that transform the',
13
- 'agent kit from a reactive reviewer into a **persistent engineering authority**.',
14
- '',
15
- '### 1 — Case Law Engine',
16
- '',
17
- 'Every rejected pattern becomes binding legal precedent.',
18
- '',
19
- '| Step | What Happens |',
20
- '|:-----|:-------------|',
21
- '| 1 | Developer rejects AI proposal |',
22
- '| 2 | Runs `case_law_manager.py add-case` |',
23
- '| 3 | diff + tags + reason stored in `.agent/history/case-law/` |',
24
- '| 4 | `precedence-reviewer` queries index on every future `/generate` or `/review` |',
25
- '| 5 | Jaccard tag match score >= 0.4 → PRECEDENCE HOLD |',
26
- '',
27
- '### 2 — Skill Evolution Forge',
28
- '',
29
- 'The agent kit writes its own skills by learning from your commits.',
30
- '',
31
- '| Step | What Happens |',
32
- '|:-----|:-------------|',
33
- '| 1 | Developer commits code different from AI proposal |',
34
- '| 2 | `tribunal-kit learn` (or `skill_evolution.py digest`) |',
35
- '| 3 | Semantic Delta Filter strips trivial noise (70-90% token reduction) |',
36
- '| 4 | Minimal LLM Reflection Prompt (< 500 tokens) |',
37
- '| 5 | YAML idioms merged into `.agent/skills/project-idioms/SKILL.md` |',
38
- '| 6 | All agents inherit these idioms on next activation |',
39
- '',
40
- '### CLI Commands (Supreme Court)',
41
- '',
42
- '| Command | Action |',
43
- '|:--------|:-------|',
44
- '| `tribunal-kit learn` | Run Skill Evolution + Case Law prompt |',
45
- '| `tribunal-kit learn --dry-run` | Preview delta without writing |',
46
- '| `tribunal-kit learn --head` | Diff last commit instead of staged |',
47
- '| `python .agent/scripts/case_law_manager.py add-case` | Record a rejection |',
48
- '| `python .agent/scripts/case_law_manager.py search-cases --query "..."` | Find precedents |',
49
- '| `python .agent/scripts/skill_evolution.py digest` | Run evolution cycle |',
50
- '| `python .agent/scripts/skill_evolution.py status` | Token savings report |',
51
- '',
52
- '### Review Order (Updated)',
53
- '',
54
- '```',
55
- '1. precedence-reviewer <- FIRST (Case Law check, zero LLM tokens)',
56
- '2. logic-reviewer',
57
- '3. security-auditor',
58
- '4. domain-specific reviewers',
59
- '5. Human Gate',
60
- '```',
61
- '',
62
- '### New Reviewer',
63
- '',
64
- '| Reviewer | Activates for | Catches |',
65
- '|:---------|:-------------|:--------|',
66
- '| `precedence-reviewer` | All domains | Violations of previously rejected patterns |',
67
- '',
68
- ].join('\n');
69
-
70
- let existing = fs.readFileSync(f, 'utf8').trimEnd();
71
- fs.writeFileSync(f, existing + appendix + '\n', 'utf8');
72
- console.log('AGENT_FLOW.md updated.');
@@ -1,11 +0,0 @@
1
- /**
2
- * colors.js — Backward-compatible re-export of _colors.js
3
- * ════════════════════════════════════════════════════════
4
- * All color constants and helpers are defined in _colors.js.
5
- * This file re-exports them for scripts that import from './colors.js'.
6
- *
7
- * New scripts should import from './_colors' directly.
8
- */
9
- 'use strict';
10
-
11
- module.exports = require('./_colors');
@@ -1,141 +0,0 @@
1
- #!/usr/bin/env node
2
- // compress_skills.js - Aggressive token reduction for .agent/skills/**/*.md files
3
-
4
- 'use strict';
5
-
6
- const fs = require('fs');
7
- const path = require('path');
8
-
9
- const SECTION_PATTERNS = [
10
- /^## 🏛️ Tribunal Integration[\s\S]*?(?=\n## |\n# |$)/gm,
11
- /^## Tribunal Integration[\s\S]*?(?=\n## |\n# |$)/gm,
12
- /^### ✅ Pre-Flight Self-Audit[\s\S]*?(?=\n## |\n### |\n# |$)/gm,
13
- /^## Pre-Flight Self-Audit[\s\S]*?(?=\n## |\n# |$)/gm,
14
- /^## Cross-Workflow Navigation[\s\S]*?(?=\n## |\n# |$)/gm,
15
- /^## Output Format\s*\n```[\s\S]*?```\s*\n/gm,
16
- /^## VBC Protocol[\s\S]*?(?=\n## |\n# |$)/gm,
17
- /^## LLM Traps[\s\S]*?(?=\n## |\n# |$)/gm,
18
- ];
19
-
20
- const CHATTY_INTRO = /(^# .+\n)\n[A-Z][^#\n]{60,}\n[A-Z][^#\n]{40,}\n\n---/gm;
21
-
22
- function stripChattyIntro(content) {
23
- return content.replace(CHATTY_INTRO, '$1\n---');
24
- }
25
-
26
- const OBVIOUS_COMMENT = /^(\s*)(\/\/ (default for most properties|shorthand|number of repeats|default: \d+|spring tension|resistance|weight|approximate duration|deceleration rate)[^\n]*)\n/gm;
27
-
28
- function stripObviousComments(content) {
29
- return content.replace(OBVIOUS_COMMENT, '');
30
- }
31
-
32
- const PERF_TEXT_BLOCK = /^```\n(✅ Use \w[^\n]*\n → [^\n]*\n\n?){3,}```\n/gm;
33
-
34
- function compressPerfBlocks(content) {
35
- return content.replace(PERF_TEXT_BLOCK, (match) => {
36
- const lines = match.replace(/`|\n$/g, '').split('\n');
37
- const bullets = [];
38
- for (const line of lines) {
39
- const stripped = line.trim();
40
- if (stripped.startsWith('✅') || stripped.startsWith('❌')) {
41
- bullets.push(`- ${stripped}`);
42
- } else if (stripped.startsWith('→')) {
43
- bullets[bullets.length - 1] += ` (${stripped.substring(1).trim()})`;
44
- }
45
- }
46
- return bullets.join('\n') + '\n';
47
- });
48
- }
49
-
50
- function collapseBlanks(content) {
51
- return content.replace(/\n{3,}/g, '\n\n');
52
- }
53
-
54
- const FILLER_BEFORE_SECTION = /(^# .+\n\n)([A-Z][^\n]+\n){1,4}(\n---\n)/gm;
55
-
56
- function removeFillerBetweenTitleAndHr(content) {
57
- return content.replace(FILLER_BEFORE_SECTION, '$1$3');
58
- }
59
-
60
- const REDUNDANT_NOTE = /^\/\/ (motion\.\w+|Any HTML|Note:|Variant names propagate|\/\/ )[^\n]*\n/gm;
61
-
62
- function stripRedundantNotes(content) {
63
- return content.replace(REDUNDANT_NOTE, '');
64
- }
65
-
66
- function compressFile(filePath) {
67
- const original = fs.readFileSync(filePath, 'utf8');
68
- let content = original;
69
-
70
- for (const pattern of SECTION_PATTERNS) {
71
- content = content.replace(pattern, '');
72
- }
73
-
74
- content = stripChattyIntro(content);
75
- content = removeFillerBetweenTitleAndHr(content);
76
- content = stripObviousComments(content);
77
- content = stripRedundantNotes(content);
78
- content = compressPerfBlocks(content);
79
- content = collapseBlanks(content);
80
-
81
- const originalLen = Buffer.byteLength(original, 'utf8');
82
- const newLen = Buffer.byteLength(content.trim() + '\n', 'utf8');
83
-
84
- fs.writeFileSync(filePath, content.trim() + '\n', 'utf8');
85
- return [originalLen, newLen, originalLen - newLen];
86
- }
87
-
88
- function main() {
89
- const base = '.agent/skills';
90
- if (!fs.existsSync(base)) {
91
- console.error(`ERROR: '${base}' not found. Run from tribunal-kit root.`);
92
- process.exit(1);
93
- }
94
-
95
- let totalOrig = 0;
96
- let totalNew = 0;
97
- const results = [];
98
-
99
- function walkDir(dir) {
100
- const items = fs.readdirSync(dir, { withFileTypes: true });
101
- for (const item of items) {
102
- const fpath = path.join(dir, item.name);
103
- if (item.isDirectory()) {
104
- walkDir(fpath);
105
- } else if (item.name.endsWith('.md')) {
106
- const [orig, newL, saved] = compressFile(fpath);
107
- totalOrig += orig;
108
- totalNew += newL;
109
- if (saved > 0) {
110
- results.push([saved, fpath]);
111
- }
112
- }
113
- }
114
- }
115
-
116
- walkDir(base);
117
- results.sort((a, b) => b[0] - a[0]);
118
-
119
- console.log(`\n${'='.repeat(55)}`);
120
- console.log(` Skill Compression Complete`);
121
- console.log(`${'='.repeat(55)}`);
122
- console.log(` Original : ${totalOrig} bytes (${Math.floor(totalOrig / 1024)}KB)`);
123
- console.log(` After : ${totalNew} bytes (${Math.floor(totalNew / 1024)}KB)`);
124
-
125
- const savedTotal = totalOrig - totalNew;
126
- const pct = totalOrig ? (savedTotal / totalOrig * 100) : 0;
127
- console.log(` Saved : ${savedTotal} bytes (${Math.floor(savedTotal / 1024)}KB) — ${pct.toFixed(1)}%`);
128
- console.log(`\n Top savings:`);
129
-
130
- for (const [saved, filePath] of results.slice(0, 15)) {
131
- const parts = filePath.split(path.sep);
132
- const skill = parts[parts.length - 2];
133
- const fname = parts[parts.length - 1];
134
- console.log(` -${Math.floor(saved / 1024).toString().padStart(2, ' ')}KB ${skill}/${fname}`);
135
- }
136
- console.log();
137
- }
138
-
139
- if (require.main === module) {
140
- main();
141
- }