tribunal-kit 5.8.0 → 5.8.2

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
@@ -12,7 +12,7 @@
12
12
 
13
13
  [![NPM](https://img.shields.io/npm/v/tribunal-kit?style=for-the-badge&logo=npm&logoColor=white&color=ff1637)](https://www.npmjs.com/package/tribunal-kit)
14
14
  [![License](https://img.shields.io/badge/License-MIT-1a1a1a?style=for-the-badge)](LICENSE)
15
- [![Version](https://img.shields.io/badge/Version-5.8.0-1a1a1a?style=for-the-badge)](CHANGELOG.md)
15
+ [![Version](https://img.shields.io/badge/Version-5.8.1-1a1a1a?style=for-the-badge)](CHANGELOG.md)
16
16
  [![MCP](https://img.shields.io/badge/MCP-Ready-ccff00?style=for-the-badge&logo=openai&logoColor=1a1a1a)](mcp_config.json)
17
17
  [![Code Quality](https://img.shields.io/badge/Hallucination_Mitigation-ff1637?style=for-the-badge)](AGENT_FLOW.md)
18
18
  [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y6C122DUQJ)
@@ -23,13 +23,30 @@
23
23
 
24
24
  > [!IMPORTANT]
25
25
  > **AI GENERATES CODE. TRIBUNAL ENSURES IT WORKS.**
26
- > A zero-bloat `.agent/` intelligence payload that upgrades your IDE with **43 specialist agents**, **34 workflows**, and a **19-reviewer Tribunal pipeline**. Maximizes execution reliability and heavily mitigates hallucinations.
26
+ > A zero-bloat `.agent/` intelligence payload and **Model Context Protocol (MCP) server** that upgrades your IDE (**Cursor**, **VSCode**, **Windsurf**) and terminal AI coding assistants (**Claude Code**, **Aider**) with **43 specialist agents**, **34 workflows**, and a parallel **20-reviewer Tribunal pipeline**. Maximizes execution reliability, optimizes context windows, and heavily mitigates AI code hallucinations.
27
27
 
28
28
  <br>
29
29
  <hr style="border: 1px solid #222; margin: 40px 0;">
30
30
  <br>
31
31
 
32
- ## 🚀 QUICK START
32
+ ## 📋 Table of Contents
33
+
34
+ - [🚀 Quick Start — Setting Up your AI Agent Code Review Engine](#-quick-start--setting-up-your-ai-agent-code-review-engine)
35
+ - [⚡ State-of-the-Art Performance (Tokio Rust Core)](#-state-of-the-art-performance-tokio-rust-core)
36
+ - [⚔️ The Command Arsenal — Swarms & Agentic Workflows](#️-the-command-arsenal--swarms--agentic-workflows)
37
+ - [💻 CLI Command Reference](#-cli-command-reference)
38
+ - [⚖️ The Tribunal Pipeline — Mitigating AI Code Hallucinations](#️-the-tribunal-pipeline--mitigating-ai-code-hallucinations)
39
+ - [🏛️ The Supreme Court Case Law Engine — Persistent Memory for AI Coding](#️-the-supreme-court-case-law-engine--persistent-memory-for-ai-coding)
40
+ - [🏃 The Marathon Harness — Long-Running Autonomous AI Agents](#-the-marathon-harness--long-running-autonomous-ai-agents)
41
+ - [🧠 Advanced Capabilities & System Prompt Rules (v5.8)](#-advanced-capabilities--system-prompt-rules-v58)
42
+ - [🔌 Model Context Protocol (MCP) Server for Cursor, VSCode & Windsurf](#-model-context-protocol-mcp-server-for-cursor-vscode--windsurf)
43
+ - [❓ Frequently Asked Questions (FAQ)](#-frequently-asked-questions-faq)
44
+
45
+ <br>
46
+ <hr style="border: 1px solid #222; margin: 40px 0;">
47
+ <br>
48
+
49
+ ## 🚀 Quick Start — Setting Up your AI Agent Code Review Engine
33
50
 
34
51
  Drop Tribunal into any existing project to instantly weaponize your IDE.
35
52
 
@@ -53,7 +70,7 @@ Tribunal Kit breaks out of the IDE with first-class support for terminal-based A
53
70
  <hr style="border: 1px solid #222; margin: 40px 0;">
54
71
  <br>
55
72
 
56
- ## ⚡ STATE-OF-THE-ART PERFORMANCE (v5.0)
73
+ ## ⚡ State-of-the-Art Performance (Tokio Rust Core)
57
74
 
58
75
  Tribunal-Kit v5 is rebuilt from the ground up to be blazingly fast. We've eliminated initialization latency and blocking I/O:
59
76
 
@@ -67,7 +84,7 @@ Tribunal-Kit v5 is rebuilt from the ground up to be blazingly fast. We've elimin
67
84
  <hr style="border: 1px solid #222; margin: 40px 0;">
68
85
  <br>
69
86
 
70
- ## ⚔️ THE COMMAND ARSENAL
87
+ ## ⚔️ The Command Arsenal — Swarms & Agentic Workflows
71
88
 
72
89
  | Workflow Command | Operational Scope |
73
90
  | :------------------------ | :----------------------------------------------------------------------- |
@@ -75,7 +92,7 @@ Tribunal-Kit v5 is rebuilt from the ground up to be blazingly fast. We've elimin
75
92
  | <kbd>/create</kbd> | Scaffold major applications via App Builder routing. |
76
93
  | <kbd>/enhance</kbd> | Safely extend existing codebases with zero regression. |
77
94
  | <kbd>/swarm</kbd> | Fan-out orchestrator. Dispatch isolated workers, synthesize output. |
78
- | <kbd>/tribunal-full</kbd> | Unleash **ALL 19** domain reviewers simultaneously for maximum scrutiny. |
95
+ | <kbd>/tribunal-full</kbd> | Unleash **ALL 20** domain reviewers simultaneously for maximum scrutiny. |
79
96
  | <kbd>/debug</kbd> | Systematic 4-phase root-cause investigation. No guessing. |
80
97
  | <kbd>/ui-ux-pro-max</kbd> | Advanced visual aesthetic engine. No generic AI slop. |
81
98
 
@@ -83,7 +100,98 @@ Tribunal-Kit v5 is rebuilt from the ground up to be blazingly fast. We've elimin
83
100
  <hr style="border: 1px solid #222; margin: 40px 0;">
84
101
  <br>
85
102
 
86
- ## ⚖️ THE PIPELINE // EVIDENCE-BASED CLOSEOUT
103
+ ## 💻 CLI Command Reference
104
+
105
+ You can run Tribunal commands using `npx tribunal-kit <command>` (or the short alias `tk <command>` if installed globally/locally).
106
+
107
+ ### Core Commands
108
+ * **`init`**: Initialize the `.agent/` configuration payload in the current directory.
109
+ ```bash
110
+ npx tribunal-kit init [--force] [--path <dir>] [--minimal] [--dry-run]
111
+ ```
112
+ * **`status`**: Check the status and integrity of the `.agent/` directory.
113
+ ```bash
114
+ npx tribunal-kit status
115
+ ```
116
+ * **`update`**: Re-install or refresh to pull the latest agent configurations into the project.
117
+ ```bash
118
+ npx tribunal-kit update
119
+ ```
120
+ * **`sync`**: Instantly synchronize the latest `.agent` rules directly with local IDE config files (Cursor, Windsurf, Copilot, VSCode, Gemini).
121
+ ```bash
122
+ npx tribunal-kit sync
123
+ ```
124
+ * **`hook`**: Install or configure Git `pre-push` hooks to auto-sync rules on push.
125
+ ```bash
126
+ npx tribunal-kit hook
127
+ ```
128
+ * **`compile`**: Compile static context rules into a `.tribunal-compiled.md` file for terminal agents.
129
+ ```bash
130
+ npx tribunal-kit compile
131
+ ```
132
+ * **`uninstall`**: Cleanly remove `.agent/` from the target project.
133
+ ```bash
134
+ npx tribunal-kit uninstall [--path <dir>]
135
+ ```
136
+
137
+ ### Case Law Engine (`case`)
138
+ Manage the Supreme Court Case Law database to prevent AI hallucinations.
139
+ * **`case add`**: Interactively record a new AI mistake/precedent.
140
+ * **`case list`**: List all recorded precedence entries.
141
+ * **`case search "<query>"`**: Search historical cases.
142
+ * **`case show --id <id>`**: Show details of a specific case.
143
+ * **`case stats`**: Display statistics on case counts and types.
144
+ * **`case export`**: Export database to a readable `.agent/history/case-law/CASE_LAW.md`.
145
+ * **`case overrule --id <id>`**: Remove/overrule a case entry.
146
+
147
+ ### Memory Engine (`memory`)
148
+ Manage the 4-Type Taxonomy Persistent Memory Engine.
149
+ * **`memory store`**: Store a tagged memory (`semantic`, `procedural`, `episodic`, or `working`).
150
+ ```bash
151
+ npx tribunal-kit memory store --type semantic --content "Uses PostgreSQL" --tags "db"
152
+ ```
153
+ * **`memory recall`**: Recall budget-gated memories.
154
+ ```bash
155
+ npx tribunal-kit memory recall --query "postgres" --budget 1000
156
+ ```
157
+ * **`memory gc`**: Garbage collect expired episodic and all working memories.
158
+ * **`memory stats`**: Show memory index statistics.
159
+ * **`memory export`**: Export the human-readable `MEMORY.md` index projection.
160
+
161
+ ### Codebase Graphs & Context
162
+ * **`graph`**: Analyze codebase dependencies, generate architecture graphs, and build context snapshots.
163
+ ```bash
164
+ npx tribunal-kit graph
165
+ ```
166
+ * **`context <file>`**: Read and inspect a specific context snapshot for a given file.
167
+ ```bash
168
+ npx tribunal-kit context src/utils.js
169
+ ```
170
+ * **`mutate <file> "<test-cmd>"`**: Run mutation testing on a file to verify test suite robustness.
171
+ ```bash
172
+ npx tribunal-kit mutate src/utils.js "npm test"
173
+ ```
174
+
175
+ ### Learning & Evolving
176
+ * **`learn`**: Evolve your project's custom skills and architectural idioms by reading git diffs.
177
+ ```bash
178
+ npx tribunal-kit learn [--dry-run] [--head]
179
+ ```
180
+
181
+ ### Marathon Long-Running Harness (`marathon`)
182
+ Run long-running, multi-session tasks tracked inside the feature DAG.
183
+ * **`marathon init "<spec>"`**: Start a new long-running task.
184
+ * **`marathon status`**: Show interactive progress dashboard.
185
+ * **`marathon next`**: Print next incomplete feature task.
186
+ * **`marathon mark <id> <pass|fail>`**: Mark a specific feature status.
187
+ * **`marathon log "<note>"`**: Append a progress log.
188
+ * **`marathon session-start` / `session-end`**: Manage session contexts.
189
+
190
+ <br>
191
+ <hr style="border: 1px solid #222; margin: 40px 0;">
192
+ <br>
193
+
194
+ ## ⚖️ The Tribunal Pipeline — Mitigating AI Code Hallucinations
87
195
 
88
196
  Code generation is solved. **Code correctness is the frontier.**
89
197
 
@@ -96,7 +204,7 @@ graph TD
96
204
  C -.->|Failed| E[Maker Auto-Correction]
97
205
  E -.-> C
98
206
 
99
- D -->|19 Domain Reviewers| F[Human Gate]
207
+ D -->|20 Domain Reviewers| F[Human Gate]
100
208
  F -->|Approved| G((Committed to Disk))
101
209
 
102
210
  classDef default fill:#1a1a1a,stroke:#333,stroke-width:2px,color:#fff;
@@ -111,7 +219,7 @@ graph TD
111
219
  <hr style="border: 1px solid #222; margin: 40px 0;">
112
220
  <br>
113
221
 
114
- ## 🏛️ THE SUPREME COURT (CASE LAW ENGINE)
222
+ ## 🏛️ The Supreme Court Case Law Engine — Persistent Memory for AI Coding
115
223
 
116
224
  The Tribunal Kit features persistent memory. The AI **never makes the same mistake twice** and auto-learns your engineering culture.
117
225
 
@@ -129,7 +237,7 @@ The Tribunal Kit features persistent memory. The AI **never makes the same mista
129
237
  <hr style="border: 1px solid #222; margin: 40px 0;">
130
238
  <br>
131
239
 
132
- ## 🏃 THE MARATHON HARNESS (v4.4+)
240
+ ## 🏃 The Marathon Harness — Long-Running Autonomous AI Agents
133
241
 
134
242
  The **Marathon Harness** is an engine designed to keep autonomous agents on track during long-running, multi-session projects without looping or losing context.
135
243
 
@@ -160,7 +268,7 @@ The **Marathon Harness** is an engine designed to keep autonomous agents on trac
160
268
  <hr style="border: 1px solid #222; margin: 40px 0;">
161
269
  <br>
162
270
 
163
- ## 🧠 ADVANCED CAPABILITIES (v5.8)
271
+ ## 🧠 Advanced Capabilities & System Prompt Rules (v5.8)
164
272
 
165
273
  The 5.8 update introduces a massive leap in long-running agent capabilities and code correctness:
166
274
 
@@ -173,7 +281,7 @@ The 5.8 update introduces a massive leap in long-running agent capabilities and
173
281
  <hr style="border: 1px solid #222; margin: 40px 0;">
174
282
  <br>
175
283
 
176
- ## 🔌 NATIVE MCP SERVER
284
+ ## 🔌 Model Context Protocol (MCP) Server for Cursor, VSCode & Windsurf
177
285
 
178
286
  Tribunal-Kit functions as a standalone **Model Context Protocol (MCP)** server via `stdio`.
179
287
 
@@ -184,6 +292,24 @@ Bind your AI IDE directly to `tribunal-kit` to unlock autonomous tool execution:
184
292
  - `sync_ide_bridges`: Force rule alignment directly from the AI chat.
185
293
  - `list_tribunal_agents` & `get_tribunal_skill`: Terminal agents can dynamically fetch specific skills without overloading their context windows.
186
294
 
295
+ <br>
296
+ <hr style="border: 1px solid #222; margin: 40px 0;">
297
+ <br>
298
+
299
+ ## ❓ Frequently Asked Questions (FAQ)
300
+
301
+ ### How does Tribunal-Kit prevent AI hallucinations?
302
+ Tribunal-Kit introduces a systematic, multi-reviewer pipeline called the **Tribunal Review**. When an AI agent generates code, it routes that code through up to 20 specialized domain reviewers (e.g., security, logic, schema) and verifies it against local tests and lint rules before presenting it to the developer.
303
+
304
+ ### Which IDEs and AI tools are supported by Tribunal-Kit?
305
+ Tribunal-Kit natively supports and automatically syncs rules with **Cursor**, **Windsurf**, **VSCode**, **Gemini**, **Copilot**, and **Claude Desktop**. It also supports terminal-based agents like **Claude Code**, **Aider**, and **OpenCode** via Model Context Protocol (MCP) or compiled static context files.
306
+
307
+ ### How do I connect Claude Code or Aider to Tribunal-Kit via MCP?
308
+ Tribunal-Kit includes a built-in Model Context Protocol (MCP) server. You can configure your AI assistant (like Claude Desktop or Claude Code) to spawn `node bin/wrapper.js` as an MCP server. This allows the AI agent to dynamically fetch custom skills, search the local case law precedence database, and run audits on demand.
309
+
310
+ ### What is the Supreme Court Case Law Engine?
311
+ It is a local, lightweight database that records past AI mistakes as legal precedent. Before code generation is committed, the `precedence-reviewer` queries this database to prevent the AI from repeating known codebase anti-patterns.
312
+
187
313
  <br>
188
314
  <br>
189
315
 
package/SECURITY.md ADDED
@@ -0,0 +1,52 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 5.x | ✅ Active support |
8
+ | 4.x | ⚠️ Critical fixes only |
9
+ | < 4.0 | ❌ End of life |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ **Do not open a public GitHub issue for security vulnerabilities.**
14
+
15
+ Instead, please report vulnerabilities privately using one of these methods:
16
+
17
+ 1. **GitHub Security Advisory** (preferred): Use [GitHub's private vulnerability reporting](https://github.com/Harmitx7/tribunal-kit/security/advisories/new) to submit a confidential report.
18
+
19
+ 2. **Email**: Send details to the maintainer via the email listed in the npm package.
20
+
21
+ ### What to include
22
+
23
+ - Description of the vulnerability
24
+ - Steps to reproduce
25
+ - Affected versions
26
+ - Potential impact
27
+ - Suggested fix (if any)
28
+
29
+ ### Response timeline
30
+
31
+ | Action | Timeline |
32
+ | --- | --- |
33
+ | Acknowledgment | Within 48 hours |
34
+ | Initial assessment | Within 5 business days |
35
+ | Fix release (critical) | Within 7 days |
36
+ | Fix release (moderate) | Within 30 days |
37
+
38
+ ## Security Design
39
+
40
+ Tribunal Kit follows these security principles:
41
+
42
+ - **No network requests at runtime** — The CLI operates entirely offline. The only network call is an optional npm registry version check during `init`/`update`, which can be skipped with `--skip-update-check`.
43
+ - **No code execution from user input** — CLI arguments are parsed without `eval()` or shell interpolation. All subprocess spawning uses array-based arguments (never string concatenation).
44
+ - **No secrets stored** — Tribunal Kit does not store, read, or transmit API keys, tokens, or credentials.
45
+ - **Minimal dependencies** — Zero production dependencies. Only `jest`, `eslint`, and `typescript` as devDependencies.
46
+ - **Platform binaries are optional** — The Rust core binary is distributed as optional dependencies. The CLI falls back to pure JavaScript if binaries are unavailable.
47
+
48
+ ## Supply Chain
49
+
50
+ - All releases are published from CI via GitHub Actions
51
+ - Platform binaries are built in GitHub-hosted runners with pinned action versions
52
+ - The package uses `npm provenance` for verifiable supply chain attestation
package/bin/mcp-server.js CHANGED
@@ -272,6 +272,21 @@ function handleRequest(req) {
272
272
  additionalProperties: false,
273
273
  },
274
274
  },
275
+ {
276
+ name: "align_output",
277
+ description: "Align model outputs to Fabel-5 constraints: strips conversational introductions and conclusions, collapses single/double bullet items to prose, and checks for code traps (unawaited dynamic functions in Next.js 15, deprecated hooks in React 19, or non-existent models).",
278
+ inputSchema: {
279
+ type: "object",
280
+ properties: {
281
+ text: {
282
+ type: "string",
283
+ description: "The raw output text generated by the model to be aligned.",
284
+ },
285
+ },
286
+ required: ["text"],
287
+ additionalProperties: false,
288
+ },
289
+ },
275
290
  ],
276
291
  };
277
292
  }
@@ -455,6 +470,29 @@ function handleRequest(req) {
455
470
  }
456
471
  }
457
472
 
473
+ if (toolName === "align_output") {
474
+ const text = req.params?.arguments?.text;
475
+ if (typeof text !== "string") {
476
+ throw { code: -32602, message: "Missing or invalid required argument: text (string)" };
477
+ }
478
+ try {
479
+ const { alignText, validateCodeContent } = require("../dist/commands/align.js");
480
+ const aligned = alignText(text);
481
+ const warnings = validateCodeContent(aligned);
482
+
483
+ let outputText = aligned;
484
+ if (warnings.length > 0) {
485
+ outputText += "\n\n⚠️ OCAE Alignment Validator Warnings:\n";
486
+ for (const warnMsg of warnings) {
487
+ outputText += `● ${warnMsg}\n`;
488
+ }
489
+ }
490
+ return { content: [{ type: "text", text: outputText }] };
491
+ } catch (e) {
492
+ return { content: [{ type: "text", text: `Alignment failed: ${e.message}` }] };
493
+ }
494
+ }
495
+
458
496
  throw { code: -32601, message: `Unknown tool: ${toolName}` };
459
497
  }
460
498
 
@@ -158,6 +158,34 @@ function parseArgs(argv) {
158
158
  if (arg.startsWith("--branch=")) {
159
159
  args.flags.branch = arg.split("=").slice(1).join("=");
160
160
  }
161
+ if (arg.startsWith("--log=")) {
162
+ args.flags.log = arg.split("=").slice(1).join("=");
163
+ }
164
+ if (arg === "--log") {
165
+ const idx = raw.indexOf("--log");
166
+ const nextVal = raw[idx + 1];
167
+ if (!nextVal || nextVal.startsWith("--")) {
168
+ console.error(
169
+ ` \x1b[91m✖ --log requires a file path argument\x1b[0m`,
170
+ );
171
+ process.exit(1);
172
+ }
173
+ args.flags.log = nextVal;
174
+ }
175
+ if (arg.startsWith("--strategy=")) {
176
+ args.flags.strategy = arg.split("=").slice(1).join("=");
177
+ }
178
+ if (arg === "--strategy") {
179
+ const idx = raw.indexOf("--strategy");
180
+ const nextVal = raw[idx + 1];
181
+ if (!nextVal || nextVal.startsWith("--")) {
182
+ console.error(
183
+ ` \x1b[91m✖ --strategy requires a strategy value (balanced/harden/repair-only)\x1b[0m`,
184
+ );
185
+ process.exit(1);
186
+ }
187
+ args.flags.strategy = nextVal;
188
+ }
161
189
  }
162
190
 
163
191
  return args;
@@ -412,8 +440,19 @@ function banner() {
412
440
  const _maxLen = Math.max(...art.map((line) => line.length));
413
441
  for (const line of art) {
414
442
  let gradientLine = " " + C.bold;
415
- for (let i = 0; i < line.length; i++) {
416
- gradientLine += `\x1b[38;2;255;22;55m${line[i]}`;
443
+ const len = line.length;
444
+ for (let i = 0; i < len; i++) {
445
+ const char = line[i];
446
+ if (char === ' ') {
447
+ gradientLine += ' ';
448
+ continue;
449
+ }
450
+ // Horizontal gradient: flame red (left) to coral/orange (right)
451
+ const ratio = i / len;
452
+ const r = 255;
453
+ const g = Math.floor(30 + ratio * 100);
454
+ const b = Math.floor(60 - ratio * 40);
455
+ gradientLine += `\x1b[38;2;${r};${g};${b}m${char}`;
417
456
  }
418
457
  gradientLine += C.reset;
419
458
  log(gradientLine);
@@ -421,16 +460,13 @@ function banner() {
421
460
  console.log();
422
461
  // Subtitle strip
423
462
  const W = 84;
424
- const sub = "Anti-Hallucination Agent System";
425
- const sp = Math.max(0, W - sub.length);
426
- const centred =
427
- " ".repeat(Math.floor(sp / 2)) + sub + " ".repeat(Math.ceil(sp / 2));
428
- const RED_ANSI = "\x1b[38;2;255;22;55m";
429
- console.log(` ${RED_ANSI}╔${"═".repeat(W)}╗${C.reset}`);
430
- console.log(
431
- ` ${RED_ANSI}║${C.reset}${c("gray", centred)}${RED_ANSI}║${C.reset}`,
432
- );
433
- console.log(` ${RED_ANSI}╚${"═".repeat(W)}╝${C.reset}`);
463
+ const plainSub = '🛡️ ANTI-HALLUCINATION AGENT SYSTEM';
464
+ const coloredSub = `${bold(c('white', '🛡️ ANTI-HALLUCINATION AGENT SYSTEM'))}`;
465
+ const sp = Math.max(0, W - plainSub.length);
466
+ const centred = ' '.repeat(Math.floor(sp / 2)) + coloredSub + ' '.repeat(Math.ceil(sp / 2));
467
+ log(` ${c('gray', `✦ ${'━'.repeat(W - 6)} ✦`)}`);
468
+ log(` ${centred}`);
469
+ log(` ${c('gray', `✦ ${'━'.repeat(W - 6)} ✦`)}`);
434
470
  console.log();
435
471
  }
436
472
 
@@ -560,6 +596,7 @@ async function cmdInit(flags) {
560
596
  } else {
561
597
  // ── Success card — W=62, rows padded by plain-text length ──
562
598
  const W = 62;
599
+ const borderCol = "red";
563
600
  const agentsCount = fs.readdirSync(path.join(agentDest, "agents")).length;
564
601
  const workflowsCount = fs.readdirSync(
565
602
  path.join(agentDest, "workflows"),
@@ -569,23 +606,28 @@ async function cmdInit(flags) {
569
606
  path.join(agentDest, "scripts"),
570
607
  ).length;
571
608
 
572
- // Stat rows: compute trailing spaces from plain text so right ║ aligns
573
- const statRow = (icon, label, val, col) => {
574
- // emoji JS .length===2 == terminal display width 2 ✓
575
- const plain = ` ${icon} ${label.padEnd(10)}${String(val).padStart(3)} installed`;
576
- const trail = " ".repeat(Math.max(0, W - plain.length));
577
- return ` ${c("cyan", "║")} ${icon} ${c("white", label.padEnd(10))}${c(col, String(val).padStart(3))} ${c("gray", "installed")}${trail}${c("cyan", "║")}`;
609
+ const drawRow = (plainText, styledText) => {
610
+ const trail = " ".repeat(Math.max(0, W - plainText.length));
611
+ return ` ${c(borderCol, "│")}${styledText}${trail}${c(borderCol, "│")}`;
578
612
  };
579
- // Plain-text rows (header / blank)
580
- const plainRow = (text, wrapFn) => {
581
- const trail = " ".repeat(Math.max(0, W - text.length));
582
- return ` ${c("cyan", "║")}${wrapFn(text)}${trail}${c("cyan", "║")}`;
613
+
614
+ const compRow = (icon, label, count, color) => {
615
+ const leftPlain = ` ${icon} ${label.padEnd(10)} `;
616
+ const rightPlain = ` [ ${String(count).padStart(3)} ]`;
617
+ const numDots = W - leftPlain.length - rightPlain.length - 4; // 4 spaces margin
618
+ const dots = ".".repeat(Math.max(0, numDots));
619
+
620
+ const plain = `${leftPlain}${dots}${rightPlain}`;
621
+ const styled = ` ${icon} ${c("white", label.padEnd(10))} ${c("gray", dots)} ${c("gray", "[")} ${c(color, String(count).padStart(3))} ${c("gray", "]")}`;
622
+ return drawRow(plain, styled);
583
623
  };
584
- // Next-step rows: fixed cmd column + description
624
+
585
625
  const stepRow = (cmd, desc) => {
586
- const plain = ` ${cmd.padEnd(16)}${desc}`;
587
- const trail = " ".repeat(Math.max(0, W - plain.length));
588
- return ` ${c("cyan", "║")} ${c("white", cmd.padEnd(16))}${c("gray", desc)}${trail}${c("cyan", "║")}`;
626
+ const leftPlain = ` ${cmd.padEnd(16)}`;
627
+ const rightPlain = `▸ ${desc}`;
628
+ const plain = `${leftPlain}${rightPlain}`;
629
+ const styled = ` ${c("white", cmd.padEnd(16))}${c("gray", "▸")} ${c("gray", desc)}`;
630
+ return drawRow(plain, styled);
589
631
  };
590
632
 
591
633
  console.log(
@@ -593,27 +635,25 @@ async function cmdInit(flags) {
593
635
  );
594
636
  console.log(` ${c("gray", " ╰─")} ${c("gray", agentDest)}`);
595
637
  console.log();
596
- console.log(` ${c("cyan", "" + "".repeat(W) + "")}`);
597
- console.log(
598
- plainRow(` What's inside:`, (s) => c("bold", c("white", s))),
599
- );
600
- console.log(` ${c("cyan", "" + "".repeat(W) + "")}`);
601
- console.log(statRow("🤖", "Agents", agentsCount, "magenta"));
602
- console.log(statRow("", "Workflows", workflowsCount, "yellow"));
603
- console.log(statRow("🧠", "Skills", skillsCount, "blue"));
604
- console.log(statRow("🔧", "Scripts", scriptsCount, "green"));
605
- console.log(` ${c("cyan", "" + "".repeat(W) + "╣")}`);
606
- console.log(plainRow("", () => ""));
607
- console.log(plainRow(` Next steps:`, (s) => c("gray", s)));
608
- console.log(
609
- stepRow("/generate", "Generate code with anti-hallucination"),
610
- );
638
+ console.log(` ${c(borderCol, "" + "".repeat(W) + "")}`);
639
+ console.log(drawRow(" TRIBUNAL ENVIRONMENT SYNCHRONIZED", `${bold(c("white", " TRIBUNAL ENVIRONMENT SYNCHRONIZED"))}`));
640
+ console.log(` ${c(borderCol, "├" + "─".repeat(W) + "")}`);
641
+ console.log(drawRow(" Guarding: Active & Enforcing", `${c("gray", " Guarding:")} ${c("green", "Active & Enforcing")}`));
642
+ console.log(drawRow(" Manifest: Verified", `${c("gray", " Manifest:")} ${c("cyan", "Verified")}`));
643
+ console.log(drawRow("", ""));
644
+ console.log(drawRow(" Installed Components:", bold(c("white", " Installed Components:"))));
645
+ console.log(compRow("🤖", "Agents", agentsCount, "magenta"));
646
+ console.log(compRow("", "Workflows", workflowsCount, "yellow"));
647
+ console.log(compRow("🧠", "Skills", skillsCount, "blue"));
648
+ console.log(compRow("🔧", "Scripts", scriptsCount, "green"));
649
+ console.log(` ${c(borderCol, "├" + "─".repeat(W) + "")}`);
650
+ console.log(drawRow("", ""));
651
+ console.log(drawRow(" Next Steps:", c("gray", " Next Steps:")));
652
+ console.log(stepRow("/generate", "Generate code with reviews"));
611
653
  console.log(stepRow("/review", "Audit existing code for issues"));
612
- console.log(
613
- stepRow("/tribunal-full", "Run all 16 reviewers in parallel"),
614
- );
615
- console.log(plainRow("", () => ""));
616
- console.log(` ${c("cyan", "╚" + "═".repeat(W) + "╝")}`);
654
+ console.log(stepRow("/tribunal-full", "Run all 20 reviewers in parallel"));
655
+ console.log(drawRow("", ""));
656
+ console.log(` ${c(borderCol, "└" + "─".repeat(W) + "┘")}`);
617
657
  console.log();
618
658
  log(` ${c("gray", "✦ Updating .gitignore...")}`);
619
659
  await updateGitignore(targetDir, dryRun);
@@ -912,6 +952,8 @@ async function cmdLearn(flags) {
912
952
  const evoArgs = ["digest"];
913
953
  if (flags.dryRun) evoArgs.push("--dry-run");
914
954
  if (flags.head) evoArgs.push("--head");
955
+ if (flags.log) evoArgs.push(`--log=${flags.log}`);
956
+ if (flags.strategy) evoArgs.push(`--strategy=${flags.strategy}`);
915
957
 
916
958
  // Phase 1: Skill Evolution
917
959
  log(
@@ -1287,6 +1329,8 @@ function cmdHelp() {
1287
1329
  log(opt("--minimal", "Install core agents/skills only (~13 agents)"));
1288
1330
  log(opt("--skip-update-check", "Skip auto-update version check"));
1289
1331
  log(opt("--head", "(learn) Diff against last commit instead of staged"));
1332
+ log(opt("--log <file>", "(learn) Extract signals and evolve from a log/transcript file"));
1333
+ log(opt("--strategy <val>", "(learn) Evolution strategy: balanced, harden, repair-only"));
1290
1334
  console.log();
1291
1335
  log(bold(" Aliases"));
1292
1336
  log(` ${c("gray", "─".repeat(40))}`);
@@ -1305,6 +1349,8 @@ function cmdHelp() {
1305
1349
  log(ex("tk learn"));
1306
1350
  log(ex("tk learn --dry-run"));
1307
1351
  log(ex("tk learn --head"));
1352
+ log(ex("tk learn --log=run.log"));
1353
+ log(ex("tk learn --log=eslint.log --strategy=harden"));
1308
1354
  log(ex("tk case add"));
1309
1355
  log(ex('tk case search "useEffect"'));
1310
1356
  log(ex("tk case list"));
package/bin/wrapper.js CHANGED
@@ -20,12 +20,16 @@ const RUST_COMMANDS = new Set([
20
20
  "sync",
21
21
  "hook",
22
22
  "uninstall",
23
+ "memory",
23
24
  ]);
24
25
 
25
26
  // Determine the path to the compiled Rust binary
26
27
  // In a full production release, this checks optionalDependencies in node_modules
27
28
  // For development, it checks the local target/release folder
28
29
  function getBinaryPath() {
30
+ if (process.env.TRIBUNAL_FORCE_JS === "1") {
31
+ return null;
32
+ }
29
33
  const isWindows = os.platform() === "win32";
30
34
  const ext = isWindows ? ".exe" : "";
31
35
  const platform = os.platform();
@@ -77,7 +81,7 @@ function getBinaryPath() {
77
81
  function runRustBinary(binPath, args) {
78
82
  const stdio = [
79
83
  "inherit",
80
- process.stdout.isTTY ? "ignore" : "inherit",
84
+ "inherit",
81
85
  "inherit",
82
86
  ];
83
87
  const result = spawnSync(binPath, args, {
package/dist/cli.js CHANGED
@@ -46,6 +46,10 @@ function parseArgs(argv) {
46
46
  args.flags.skipUpdateCheck = true;
47
47
  continue;
48
48
  }
49
+ if (arg === '--write') {
50
+ args.flags.write = true;
51
+ continue;
52
+ }
49
53
  if (arg === '--head') {
50
54
  args.flags.head = true;
51
55
  continue;
@@ -96,6 +100,7 @@ function cmdHelp(quiet = false) {
96
100
  (0, logger_1.log)(cmd('mutate', 'Run the Mutation Engine to test test-suite reliability'));
97
101
  (0, logger_1.log)(cmd('context', 'Retrieve a highly-optimized Context Snapshot for a file'));
98
102
  (0, logger_1.log)(cmd('sync', 'Synchronize IDE bridge files with current rules'));
103
+ (0, logger_1.log)(cmd('align', 'Clean AI outputs (strip slop, collapse lists, validate code traps)'));
99
104
  (0, logger_1.log)(cmd('marathon', 'Long-running agent harness (init, status, next, mark)'));
100
105
  (0, logger_1.log)(cmd('hook', 'Install pre-push git hook for auto-learning'));
101
106
  (0, logger_1.log)(cmd('compile', 'Compile rules into a static instruction file for terminal agents'));
@@ -113,6 +118,7 @@ function cmdHelp(quiet = false) {
113
118
  (0, logger_1.log)(opt('--minimal', 'Install core agents/skills only (~13 agents)'));
114
119
  (0, logger_1.log)(opt('--skip-update-check', 'Skip auto-update version check'));
115
120
  (0, logger_1.log)(opt('--head', '(learn) Diff against last commit instead of staged'));
121
+ (0, logger_1.log)(opt('--write', '(align) Write aligned output in-place to the target file'));
116
122
  console.log();
117
123
  (0, logger_1.log)((0, logger_1.bold)(' Aliases'));
118
124
  (0, logger_1.log)(` ${(0, logger_1.c)('gray', '─'.repeat(40))}`);
@@ -144,6 +150,8 @@ function cmdHelp(quiet = false) {
144
150
  (0, logger_1.log)(ex('tk marathon mark 5 pass'));
145
151
  (0, logger_1.log)(ex('tk hook'));
146
152
  (0, logger_1.log)(ex('tk compile'));
153
+ (0, logger_1.log)(ex('echo "Certainly! Here is - item 1" | tk align'));
154
+ (0, logger_1.log)(ex('tk align output.md --write'));
147
155
  (0, logger_1.log)(ex('tk memory store --type semantic --content "Uses PostgreSQL" --tags db,orm'));
148
156
  (0, logger_1.log)(ex('tk memory recall --query "database" --budget 2000'));
149
157
  (0, logger_1.log)(ex('tk memory gc'));
@@ -221,6 +229,11 @@ async function runWithUpdateCheck(command, flags) {
221
229
  await cmdSync();
222
230
  break;
223
231
  }
232
+ case 'align': {
233
+ const cmdAlign = loadCmd('./commands/align', 'cmdAlign');
234
+ await cmdAlign(flags, process.argv, quiet);
235
+ break;
236
+ }
224
237
  case 'marathon': {
225
238
  const cmdMarathon = loadCmd('./commands/marathon', 'cmdMarathon');
226
239
  await cmdMarathon(flags, process.argv, quiet);