tribunal-kit 7.0.0 → 8.0.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.
- package/.agent/config/claude.json +18 -0
- package/.agent/config/plugin.json +102 -0
- package/.agent/config/slash-commands.json +103 -0
- package/.agent/config/specialist-registry.json +415 -0
- package/.agent/config/system-prompt.md +191 -0
- package/.agent/history/architecture-graph.yaml +302 -3
- package/.agent/history/graph-cache.json +515 -45
- package/.agent/history/memory.db +0 -0
- package/.agent/history/snapshots/bin__adapter-install.js.json +13 -0
- package/.agent/history/snapshots/bin__global-store.js.json +15 -0
- package/.agent/history/snapshots/bin__mcp-server.js.json +19 -0
- package/.agent/history/snapshots/bin__proxy-server.js.json +20 -0
- package/.agent/history/snapshots/bin__spawn-agent.js.json +12 -0
- package/.agent/history/snapshots/bin__tk-proxy.js.json +21 -0
- package/.agent/history/snapshots/bin__tribunal-kit.js.json +9 -7
- package/.agent/history/snapshots/bin__wrapper.js.json +14 -0
- package/.agent/history/snapshots/eslint.config.js.json +1 -2
- package/.agent/history/snapshots/scripts__benchmark.js.json +14 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +1 -2
- package/.agent/history/snapshots/scripts__fix-vbc.js.json +11 -0
- package/.agent/history/snapshots/scripts__stress_benchmark.js.json +15 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +1 -2
- package/.agent/history/snapshots/scripts__validate-payload.js.json +1 -2
- package/.agent/history/snapshots/scripts__visual_audit.js.json +11 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +1 -2
- package/.agent/history/snapshots/test__integration__graceful_degradation.test.js.json +12 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +1 -2
- package/.agent/history/snapshots/test__integration__minimal_change_pipeline.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__parallel_tribunal.test.js.json +12 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +1 -2
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +1 -2
- package/.agent/history/snapshots/test__integration__sync_status.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +1 -2
- package/.agent/history/snapshots/test__integration__wrapper.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__align.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +3 -3
- package/.agent/history/snapshots/test__unit__audit_release.test.js.json +16 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +1 -2
- package/.agent/history/snapshots/test__unit__cicd_validator.test.js.json +12 -0
- package/.agent/history/snapshots/test__unit__compile.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__context_broker.test.js.json +1 -2
- package/.agent/history/snapshots/test__unit__contract_engine.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +3 -3
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +1 -2
- package/.agent/history/snapshots/test__unit__guardrail_engine.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__impact_classifier.test.js.json +12 -0
- package/.agent/history/snapshots/test__unit__init.test.js.json +14 -0
- package/.agent/history/snapshots/test__unit__inner_loop_validator.test.js.json +1 -2
- package/.agent/history/snapshots/test__unit__integrity_manifest.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__learn.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__marathon.test.js.json +22 -0
- package/.agent/history/snapshots/test__unit__mcp_server.test.js.json +16 -0
- package/.agent/history/snapshots/test__unit__memory.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__minimal_change.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__native.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__optimize.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__path_resolution.test.js.json +14 -0
- package/.agent/history/snapshots/test__unit__production_readiness_evidence.test.js.json +21 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +3 -3
- package/.agent/history/snapshots/test__unit__semver.test.js.json +3 -3
- package/.agent/history/snapshots/test__unit__skill_evolution.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__stress.test.js.json +15 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +3 -3
- package/.agent/history/snapshots/test__unit__utils.test.js.json +10 -0
- package/.agent/scripts/ast_context_loader.js +137 -0
- package/.agent/scripts/memory_engine.js +581 -0
- package/.agent/scripts/payload_schemas.js +146 -0
- package/.agent/scripts/prompt_compiler.js +59 -11
- package/.agent/scripts/swarm_dispatcher.js +295 -67
- package/.agent/scripts/token_budget_broker.js +117 -6
- package/.claude/CLAUDE.md +442 -0
- package/README.md +22 -12
- package/SECURITY.md +3 -3
- package/bin/adapter-install.js +240 -0
- package/bin/global-store.js +48 -0
- package/bin/mcp-server.js +568 -252
- package/bin/proxy-server.js +113 -0
- package/bin/spawn-agent.js +39 -0
- package/bin/tk-proxy.js +34 -0
- package/dist/commands/init.js +8 -51
- package/dist/commands/status.js +61 -36
- package/dist/commands/validate.js +22 -31
- package/dist/tui/banner.js +77 -0
- package/dist/tui/index.js +21 -0
- package/dist/tui/reviewer-grid.js +90 -0
- package/dist/tui/shimmer.js +91 -0
- package/dist/tui/theme.js +130 -0
- package/dist/tui/tree.js +93 -0
- package/dist/tui/wizard.js +148 -0
- package/dist/utils/helpers.js +5 -41
- package/package.json +27 -10
- package/scripts/build-graph.js +71 -0
- package/.agent/history/snapshots/migrate_refs.js.json +0 -11
- package/.agent/scripts/compile_router.py +0 -5
- package/.agent/scripts/migrate_skills_frontmatter.py +0 -5
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tribunal Kit — Universal CLI Agent Adapter
|
|
5
|
+
*
|
|
6
|
+
* Auto-detects installed CLI agents and configures Tribunal Kit
|
|
7
|
+
* for each one. Supports Claude Code, Aider, Codex, Gemini CLI,
|
|
8
|
+
* OpenCode, Copilot CLI, Cursor, Windsurf, and Cline.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* node bin/adapter-install.js # Auto-detect and install all
|
|
12
|
+
* node bin/adapter-install.js claude # Install for Claude Code only
|
|
13
|
+
* node bin/adapter-install.js --global # Install to ~/.tribunal-kit/
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const os = require('os');
|
|
19
|
+
const { execSync } = require('child_process');
|
|
20
|
+
|
|
21
|
+
const ADAPTERS = {
|
|
22
|
+
'claude-code': {
|
|
23
|
+
detect: () => commandExists('claude'),
|
|
24
|
+
rulesFile: '.claude/CLAUDE.md',
|
|
25
|
+
description: 'Claude Code CLI',
|
|
26
|
+
setup: (projectRoot, _globalMode) => {
|
|
27
|
+
const rulesDir = path.join(projectRoot, '.claude');
|
|
28
|
+
ensureDir(rulesDir);
|
|
29
|
+
const source = path.join(__dirname, '..', '.claude', 'CLAUDE.md');
|
|
30
|
+
const target = path.join(rulesDir, 'CLAUDE.md');
|
|
31
|
+
if (fs.existsSync(source)) {
|
|
32
|
+
fs.copyFileSync(source, target);
|
|
33
|
+
}
|
|
34
|
+
// Also install MCP server config
|
|
35
|
+
installMcpConfig(projectRoot, 'claude');
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
aider: {
|
|
40
|
+
detect: () => commandExists('aider'),
|
|
41
|
+
rulesFile: '.aider.conf.yml',
|
|
42
|
+
description: 'Aider CLI',
|
|
43
|
+
setup: projectRoot => {
|
|
44
|
+
const conventionsPath = path.join(projectRoot, 'CONVENTIONS.md');
|
|
45
|
+
const systemPrompt = fs.readFileSync(
|
|
46
|
+
path.join(__dirname, '..', '.agent', 'config', 'system-prompt.md'),
|
|
47
|
+
'utf8',
|
|
48
|
+
);
|
|
49
|
+
fs.writeFileSync(conventionsPath, systemPrompt);
|
|
50
|
+
console.log(` ✓ Wrote ${conventionsPath}`);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
codex: {
|
|
55
|
+
detect: () => commandExists('codex'),
|
|
56
|
+
rulesFile: 'AGENTS.md',
|
|
57
|
+
description: 'OpenAI Codex CLI',
|
|
58
|
+
setup: projectRoot => {
|
|
59
|
+
const agentsPath = path.join(projectRoot, 'AGENTS.md');
|
|
60
|
+
const systemPrompt = fs.readFileSync(
|
|
61
|
+
path.join(__dirname, '..', '.agent', 'config', 'system-prompt.md'),
|
|
62
|
+
'utf8',
|
|
63
|
+
);
|
|
64
|
+
fs.writeFileSync(agentsPath, systemPrompt);
|
|
65
|
+
console.log(` ✓ Wrote ${agentsPath}`);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
'gemini-cli': {
|
|
70
|
+
detect: () => commandExists('gemini'),
|
|
71
|
+
rulesFile: '.gemini/rules/GEMINI.md',
|
|
72
|
+
description: 'Google Gemini CLI',
|
|
73
|
+
setup: projectRoot => {
|
|
74
|
+
const geminiDir = path.join(projectRoot, '.gemini', 'rules');
|
|
75
|
+
ensureDir(geminiDir);
|
|
76
|
+
const systemPrompt = fs.readFileSync(
|
|
77
|
+
path.join(__dirname, '..', '.agent', 'config', 'system-prompt.md'),
|
|
78
|
+
'utf8',
|
|
79
|
+
);
|
|
80
|
+
fs.writeFileSync(path.join(geminiDir, 'GEMINI.md'), systemPrompt);
|
|
81
|
+
console.log(` ✓ Wrote ${path.join(geminiDir, 'GEMINI.md')}`);
|
|
82
|
+
// Also install MCP config
|
|
83
|
+
installMcpConfig(projectRoot, 'gemini');
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
opencode: {
|
|
88
|
+
detect: () => commandExists('opencode'),
|
|
89
|
+
rulesFile: '.opencode/rules.md',
|
|
90
|
+
description: 'OpenCode CLI',
|
|
91
|
+
setup: projectRoot => {
|
|
92
|
+
const opencodeDir = path.join(projectRoot, '.opencode');
|
|
93
|
+
ensureDir(opencodeDir);
|
|
94
|
+
const systemPrompt = fs.readFileSync(
|
|
95
|
+
path.join(__dirname, '..', '.agent', 'config', 'system-prompt.md'),
|
|
96
|
+
'utf8',
|
|
97
|
+
);
|
|
98
|
+
fs.writeFileSync(path.join(opencodeDir, 'rules.md'), systemPrompt);
|
|
99
|
+
console.log(` ✓ Wrote ${path.join(opencodeDir, 'rules.md')}`);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
'copilot-cli': {
|
|
104
|
+
detect: () => commandExists('gh') && hasGhExtension('copilot'),
|
|
105
|
+
rulesFile: '.github/copilot-instructions.md',
|
|
106
|
+
description: 'GitHub Copilot CLI',
|
|
107
|
+
setup: projectRoot => {
|
|
108
|
+
const ghDir = path.join(projectRoot, '.github');
|
|
109
|
+
ensureDir(ghDir);
|
|
110
|
+
const systemPrompt = fs.readFileSync(
|
|
111
|
+
path.join(__dirname, '..', '.agent', 'config', 'system-prompt.md'),
|
|
112
|
+
'utf8',
|
|
113
|
+
);
|
|
114
|
+
fs.writeFileSync(path.join(ghDir, 'copilot-instructions.md'), systemPrompt);
|
|
115
|
+
console.log(` ✓ Wrote ${path.join(ghDir, 'copilot-instructions.md')}`);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// --- Utility Functions ---
|
|
121
|
+
|
|
122
|
+
function commandExists(cmd) {
|
|
123
|
+
try {
|
|
124
|
+
const isWin = os.platform() === 'win32';
|
|
125
|
+
const check = isWin ? `where ${cmd}` : `which ${cmd}`;
|
|
126
|
+
execSync(check, { stdio: 'ignore' });
|
|
127
|
+
return true;
|
|
128
|
+
} catch {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function hasGhExtension(ext) {
|
|
134
|
+
try {
|
|
135
|
+
const output = execSync('gh extension list', { encoding: 'utf8' });
|
|
136
|
+
return output.includes(ext);
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function ensureDir(dirPath) {
|
|
143
|
+
if (!fs.existsSync(dirPath)) {
|
|
144
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function installMcpConfig(projectRoot, target) {
|
|
149
|
+
const mcpConfig = {
|
|
150
|
+
mcpServers: {
|
|
151
|
+
'tribunal-kit': {
|
|
152
|
+
command: 'node',
|
|
153
|
+
args: [path.join(__dirname, '..', 'bin', 'mcp-server.js')],
|
|
154
|
+
env: { NODE_ENV: 'production' },
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
let configPath;
|
|
160
|
+
if (target === 'claude') {
|
|
161
|
+
configPath = path.join(projectRoot, '.claude', 'mcp.json');
|
|
162
|
+
} else if (target === 'gemini') {
|
|
163
|
+
configPath = path.join(projectRoot, '.gemini', 'settings.json');
|
|
164
|
+
} else {
|
|
165
|
+
configPath = path.join(projectRoot, 'mcp_config.json');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
fs.writeFileSync(configPath, JSON.stringify(mcpConfig, null, 2));
|
|
169
|
+
console.log(` ✓ MCP server registered at ${configPath}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// --- Main ---
|
|
173
|
+
|
|
174
|
+
function main() {
|
|
175
|
+
const args = process.argv.slice(2);
|
|
176
|
+
const globalMode = args.includes('--global');
|
|
177
|
+
const targetAgent = args.find(a => !a.startsWith('-'));
|
|
178
|
+
const projectRoot = globalMode ? path.join(os.homedir(), '.tribunal-kit') : process.cwd();
|
|
179
|
+
|
|
180
|
+
console.log('');
|
|
181
|
+
console.log('┌─────────────────────────────────────────────┐');
|
|
182
|
+
console.log('│ 🔱 Tribunal Kit — Universal Agent Adapter │');
|
|
183
|
+
console.log('│ v7.0.0 · 52 specialists · 186 skills │');
|
|
184
|
+
console.log('└─────────────────────────────────────────────┘');
|
|
185
|
+
console.log('');
|
|
186
|
+
|
|
187
|
+
if (globalMode) {
|
|
188
|
+
ensureDir(projectRoot);
|
|
189
|
+
console.log(`📁 Global mode: Installing to ${projectRoot}`);
|
|
190
|
+
} else {
|
|
191
|
+
console.log(`📁 Project mode: Installing to ${projectRoot}`);
|
|
192
|
+
}
|
|
193
|
+
console.log('');
|
|
194
|
+
|
|
195
|
+
let installed = 0;
|
|
196
|
+
let detected = 0;
|
|
197
|
+
|
|
198
|
+
for (const [name, adapter] of Object.entries(ADAPTERS)) {
|
|
199
|
+
if (targetAgent && name !== targetAgent) continue;
|
|
200
|
+
|
|
201
|
+
const isDetected = adapter.detect();
|
|
202
|
+
if (isDetected) detected++;
|
|
203
|
+
|
|
204
|
+
if (targetAgent || isDetected) {
|
|
205
|
+
console.log(`⚡ ${adapter.description} ${isDetected ? '(detected)' : '(manual)'}`);
|
|
206
|
+
try {
|
|
207
|
+
adapter.setup(projectRoot, globalMode);
|
|
208
|
+
installed++;
|
|
209
|
+
console.log(` ✅ Tribunal Kit configured for ${adapter.description}`);
|
|
210
|
+
} catch (err) {
|
|
211
|
+
console.error(` ❌ Failed: ${err.message}`);
|
|
212
|
+
}
|
|
213
|
+
console.log('');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (installed === 0 && !targetAgent) {
|
|
218
|
+
console.log('⚠️ No CLI agents detected on this machine.');
|
|
219
|
+
console.log('');
|
|
220
|
+
console.log(' Supported agents:');
|
|
221
|
+
for (const [name, adapter] of Object.entries(ADAPTERS)) {
|
|
222
|
+
console.log(` • ${name.padEnd(15)} → ${adapter.description}`);
|
|
223
|
+
}
|
|
224
|
+
console.log('');
|
|
225
|
+
console.log(' Install one, then run this command again.');
|
|
226
|
+
console.log(' Or specify manually: node bin/adapter-install.js claude-code');
|
|
227
|
+
} else {
|
|
228
|
+
console.log('─────────────────────────────────────────────');
|
|
229
|
+
console.log(`✅ Configured ${installed} agent(s) (${detected} auto-detected)`);
|
|
230
|
+
console.log('');
|
|
231
|
+
console.log(' Next steps:');
|
|
232
|
+
console.log(' 1. Open your CLI agent normally');
|
|
233
|
+
console.log(' 2. The Tribunal rules are now enforced automatically');
|
|
234
|
+
console.log(' 3. Use /tribunal, /summon, /audit, /debug commands');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
console.log('');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
main();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
const GLOBAL_STORE_PATH = path.join(os.homedir(), '.tribunal-kit');
|
|
6
|
+
const LOCAL_AGENT_PATH = path.join(__dirname, '..', '.agent');
|
|
7
|
+
|
|
8
|
+
function initializeGlobalStore() {
|
|
9
|
+
if (!fs.existsSync(GLOBAL_STORE_PATH)) {
|
|
10
|
+
console.log(`[Tribunal Kit] Initializing global knowledge base at ${GLOBAL_STORE_PATH}...`);
|
|
11
|
+
fs.mkdirSync(GLOBAL_STORE_PATH, { recursive: true });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Copy .agent folder if it doesn't exist in the global store or if we want to force update
|
|
15
|
+
const globalAgentPath = path.join(GLOBAL_STORE_PATH, '.agent');
|
|
16
|
+
if (!fs.existsSync(globalAgentPath)) {
|
|
17
|
+
console.log(`[Tribunal Kit] Copying specialists and skills to global store...`);
|
|
18
|
+
copyDirectoryRecursiveSync(LOCAL_AGENT_PATH, globalAgentPath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function copyDirectoryRecursiveSync(source, target) {
|
|
23
|
+
if (!fs.existsSync(target)) {
|
|
24
|
+
fs.mkdirSync(target, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const files = fs.readdirSync(source);
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
const sourcePath = path.join(source, file);
|
|
30
|
+
const targetPath = path.join(target, file);
|
|
31
|
+
|
|
32
|
+
if (fs.lstatSync(sourcePath).isDirectory()) {
|
|
33
|
+
copyDirectoryRecursiveSync(sourcePath, targetPath);
|
|
34
|
+
} else {
|
|
35
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getGlobalAgentPath() {
|
|
41
|
+
return path.join(GLOBAL_STORE_PATH, '.agent');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
initializeGlobalStore,
|
|
46
|
+
getGlobalAgentPath,
|
|
47
|
+
GLOBAL_STORE_PATH,
|
|
48
|
+
};
|