tribunal-kit 9.2.6 → 9.2.7
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/ARCHITECTURE.md +2 -2
- package/.agent/history/architecture-intelligence.html +1487 -401
- package/.agent/history/architecture-model.json +9365 -5697
- package/.agent/history/architecture-verification.json +37 -9
- package/.agent/routing_index.json +2069 -3340
- package/.agent/rules/GEMINI.md +1 -1
- package/.agent/scripts/adaptive_execution.js +511 -0
- package/.agent/scripts/architecture_diff.js +303 -260
- package/.agent/scripts/architecture_extractor.js +792 -753
- package/.agent/scripts/architecture_health.js +293 -256
- package/.agent/scripts/architecture_intelligence.js +3100 -0
- package/.agent/scripts/architecture_verifier.js +303 -270
- package/.agent/scripts/architecture_visualizer.js +880 -873
- package/.agent/scripts/blast_radius_engine.js +274 -234
- package/.agent/scripts/capability_evolution.js +453 -0
- package/.agent/scripts/concept_extractor.js +240 -0
- package/.agent/scripts/consideration_engine.js +284 -0
- package/.agent/scripts/coverage_engine.js +102 -0
- package/.agent/scripts/cross_domain_engine.js +1883 -0
- package/.agent/scripts/engineering_memory.js +1313 -0
- package/.agent/scripts/integrity_manifest.js +1 -5
- package/.agent/scripts/judgment_engine.js +790 -0
- package/.agent/scripts/materiality_engine.js +251 -0
- package/.agent/scripts/outcome_engine.js +624 -0
- package/.agent/scripts/outcome_optimization_engine.js +1632 -0
- package/.agent/scripts/simulation_engine.js +1478 -0
- package/.agent/scripts/skill_intelligence.js +1371 -0
- package/.agent/scripts/validation_engine.js +236 -236
- package/.agent/scripts/verification_auditor.js +266 -0
- package/.agent/skill-intelligence/taxonomy/engineering-concepts.json +555 -0
- package/.agent/skill_topic_map.json +301 -341
- package/.agent/skills_inventory.json +4272 -6922
- package/.agent/workflows/arch.md +96 -80
- package/.agent/workflows/skill-intelligence.md +216 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +24 -24
- package/bin/adapter-install.js +1 -1
- package/package.json +8 -9
- package/plugins/core-plugin.json +1 -1
- package/plugins/gemini/extension.json +1 -1
- package/src/browser/index.js +2 -1
- package/src/browser/launcher.js +41 -1
- package/src/cli.js +3 -1
- package/src/commands/arch.js +261 -172
- package/src/commands/context.js +27 -8
- package/src/commands/learn.js +21 -6
- package/src/commands/memory.js +10 -1
- package/src/commands/native.js +12 -3
- package/src/commands/skill-intelligence.js +1165 -0
- package/src/commands/system1.js +105 -4
- package/src/context/ranker.js +337 -339
- package/src/evolution/engine.js +296 -295
- package/src/synthesis/claim_check_separator.js +294 -271
- package/src/system1/browser_intelligence.js +300 -0
- package/src/system1/constants.js +49 -0
- package/src/system1/decision_engine.js +498 -0
- package/src/system1/evidence_engine.js +602 -0
- package/src/system1/evolution_pipeline.js +581 -0
- package/src/system1/index.d.ts +114 -0
- package/src/system1/index.js +102 -0
- package/src/system1/reviewer_orchestrator.js +477 -0
- package/src/tui/banner.js +1 -1
- package/src/utils/fs.js +27 -0
package/src/commands/arch.js
CHANGED
|
@@ -1,172 +1,261 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const __importDefault =
|
|
4
|
-
(this && this.__importDefault) ||
|
|
5
|
-
function (mod) {
|
|
6
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
-
exports.cmdArch = cmdArch;
|
|
10
|
-
|
|
11
|
-
const fs_1 = __importDefault(require('fs'));
|
|
12
|
-
const path_1 = __importDefault(require('path'));
|
|
13
|
-
const child_process_1 = require('child_process');
|
|
14
|
-
const logger_1 = require('../utils/logger');
|
|
15
|
-
const helpers_1 = require('../utils/helpers');
|
|
16
|
-
|
|
17
|
-
async function cmdArch(flags, rawArgv, quiet = false) {
|
|
18
|
-
const targetDir = flags.path ? path_1.default.resolve(flags.path) : process.cwd();
|
|
19
|
-
const subCommand = rawArgv[3] || 'help';
|
|
20
|
-
|
|
21
|
-
(0, helpers_1.banner)(quiet);
|
|
22
|
-
|
|
23
|
-
const scriptsDir = path_1.default.join(targetDir, '.agent', 'scripts');
|
|
24
|
-
const historyDir = path_1.default.join(targetDir, '.agent', 'history');
|
|
25
|
-
const modelFile = path_1.default.join(historyDir, 'architecture-model.json');
|
|
26
|
-
|
|
27
|
-
switch (subCommand) {
|
|
28
|
-
case 'map': {
|
|
29
|
-
(0, logger_1.log)(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
(0, logger_1.log)(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(0, logger_1.log)(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
(0, logger_1.log)(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const __importDefault =
|
|
4
|
+
(this && this.__importDefault) ||
|
|
5
|
+
function (mod) {
|
|
6
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
exports.cmdArch = cmdArch;
|
|
10
|
+
|
|
11
|
+
const fs_1 = __importDefault(require('fs'));
|
|
12
|
+
const path_1 = __importDefault(require('path'));
|
|
13
|
+
const child_process_1 = require('child_process');
|
|
14
|
+
const logger_1 = require('../utils/logger');
|
|
15
|
+
const helpers_1 = require('../utils/helpers');
|
|
16
|
+
|
|
17
|
+
async function cmdArch(flags, rawArgv, quiet = false) {
|
|
18
|
+
const targetDir = flags.path ? path_1.default.resolve(flags.path) : process.cwd();
|
|
19
|
+
const subCommand = rawArgv[3] || 'help';
|
|
20
|
+
|
|
21
|
+
(0, helpers_1.banner)(quiet);
|
|
22
|
+
|
|
23
|
+
const scriptsDir = path_1.default.join(targetDir, '.agent', 'scripts');
|
|
24
|
+
const historyDir = path_1.default.join(targetDir, '.agent', 'history');
|
|
25
|
+
const modelFile = path_1.default.join(historyDir, 'architecture-model.json');
|
|
26
|
+
|
|
27
|
+
switch (subCommand) {
|
|
28
|
+
case 'map': {
|
|
29
|
+
(0, logger_1.log)(
|
|
30
|
+
` ${(0, logger_1.c)('cyan', '▸')} Extracting architectural facts from source...`,
|
|
31
|
+
);
|
|
32
|
+
const { ArchitectureExtractor } = require(
|
|
33
|
+
path_1.default.join(scriptsDir, 'architecture_extractor.js'),
|
|
34
|
+
);
|
|
35
|
+
const extractor = new ArchitectureExtractor(targetDir);
|
|
36
|
+
const model = extractor.scan();
|
|
37
|
+
const outPath = extractor.save();
|
|
38
|
+
(0, logger_1.ok)(
|
|
39
|
+
`Fact Extraction Complete: ${model.summary.totalEntities} entities, ${model.summary.totalRelations} relations.`,
|
|
40
|
+
);
|
|
41
|
+
(0, logger_1.log)(
|
|
42
|
+
` ${(0, logger_1.c)('gray', 'Model saved to:')} ${(0, logger_1.c)('cyan', outPath)}`,
|
|
43
|
+
);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
case 'verify': {
|
|
48
|
+
(0, logger_1.log)(
|
|
49
|
+
` ${(0, logger_1.c)('cyan', '▸')} Executing Zero-Trust Architecture Verification...`,
|
|
50
|
+
);
|
|
51
|
+
if (!fs_1.default.existsSync(modelFile)) {
|
|
52
|
+
const { ArchitectureExtractor } = require(
|
|
53
|
+
path_1.default.join(scriptsDir, 'architecture_extractor.js'),
|
|
54
|
+
);
|
|
55
|
+
new ArchitectureExtractor(targetDir).scan().save();
|
|
56
|
+
}
|
|
57
|
+
const model = JSON.parse(fs_1.default.readFileSync(modelFile, 'utf8'));
|
|
58
|
+
const { ArchitectureVerifier } = require(
|
|
59
|
+
path_1.default.join(scriptsDir, 'architecture_verifier.js'),
|
|
60
|
+
);
|
|
61
|
+
const verifier = new ArchitectureVerifier(targetDir);
|
|
62
|
+
const results = verifier.verifyModel(model);
|
|
63
|
+
const repPath = verifier.saveReport();
|
|
64
|
+
|
|
65
|
+
if (results.verified) {
|
|
66
|
+
(0, logger_1.ok)(
|
|
67
|
+
`Architecture Verified: ${results.stats.verifiedEntities}/${results.stats.totalEntities} entities confirmed against ground truth.`,
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
(0, logger_1.warn)(
|
|
71
|
+
`Verification completed with warnings: ${results.contradictions.length} contradictions surfaced.`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
(0, logger_1.log)(
|
|
75
|
+
` ${(0, logger_1.c)('gray', 'Verification report:')} ${(0, logger_1.c)('cyan', repPath)}`,
|
|
76
|
+
);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
case 'impact': {
|
|
81
|
+
const targetQuery = rawArgv[4];
|
|
82
|
+
if (!targetQuery) {
|
|
83
|
+
(0, logger_1.err)('Usage: tk arch impact <component-id-or-filepath>');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
if (!fs_1.default.existsSync(modelFile)) {
|
|
87
|
+
const { ArchitectureExtractor } = require(
|
|
88
|
+
path_1.default.join(scriptsDir, 'architecture_extractor.js'),
|
|
89
|
+
);
|
|
90
|
+
const ext = new ArchitectureExtractor(targetDir);
|
|
91
|
+
ext.scan();
|
|
92
|
+
ext.save();
|
|
93
|
+
}
|
|
94
|
+
const model = JSON.parse(fs_1.default.readFileSync(modelFile, 'utf8'));
|
|
95
|
+
const { BlastRadiusEngine } = require(
|
|
96
|
+
path_1.default.join(scriptsDir, 'blast_radius_engine.js'),
|
|
97
|
+
);
|
|
98
|
+
const engine = new BlastRadiusEngine(model);
|
|
99
|
+
const res = engine.computeBlastRadius(targetQuery);
|
|
100
|
+
|
|
101
|
+
if (!res.found) {
|
|
102
|
+
(0, logger_1.err)(res.error);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
(0, logger_1.log)(
|
|
107
|
+
` ${(0, logger_1.bold)('Target:')} ${(0, logger_1.c)('cyan', res.target.name)} (${res.target.id})`,
|
|
108
|
+
);
|
|
109
|
+
(0, logger_1.log)(
|
|
110
|
+
` ${(0, logger_1.bold)('Risk Tier:')} ${(0, logger_1.c)(res.metrics.riskTier === 'CRITICAL' ? 'red' : 'yellow', res.metrics.riskTier)} (${res.metrics.riskScore})`,
|
|
111
|
+
);
|
|
112
|
+
(0, logger_1.log)(
|
|
113
|
+
` ${(0, logger_1.bold)('Direct Callers:')} ${res.metrics.directDependentsCount}`,
|
|
114
|
+
);
|
|
115
|
+
(0, logger_1.log)(
|
|
116
|
+
` ${(0, logger_1.bold)('Transitive Blast:')} ${res.metrics.transitiveDependentsCount} across ${res.metrics.maxDepthReached} rings`,
|
|
117
|
+
);
|
|
118
|
+
(0, logger_1.log)(
|
|
119
|
+
` ${(0, logger_1.bold)('Impacted Endpoints:')} ${res.impactBreakdown.endpoints.length}`,
|
|
120
|
+
);
|
|
121
|
+
(0, logger_1.log)(
|
|
122
|
+
` ${(0, logger_1.bold)('Impacted Test Suites:')} ${res.impactBreakdown.testSuites.length}`,
|
|
123
|
+
);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case 'diff': {
|
|
128
|
+
const baseFile = rawArgv[4];
|
|
129
|
+
const headFile = rawArgv[5];
|
|
130
|
+
if (!baseFile || !headFile) {
|
|
131
|
+
(0, logger_1.err)('Usage: tk arch diff <base-model.json> <head-model.json>');
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
const { ArchitectureDiffer } = require(
|
|
135
|
+
path_1.default.join(scriptsDir, 'architecture_diff.js'),
|
|
136
|
+
);
|
|
137
|
+
const baseModel = JSON.parse(
|
|
138
|
+
fs_1.default.readFileSync(path_1.default.resolve(baseFile), 'utf8'),
|
|
139
|
+
);
|
|
140
|
+
const headModel = JSON.parse(
|
|
141
|
+
fs_1.default.readFileSync(path_1.default.resolve(headFile), 'utf8'),
|
|
142
|
+
);
|
|
143
|
+
const differ = new ArchitectureDiffer(baseModel, headModel);
|
|
144
|
+
const diff = differ.compare();
|
|
145
|
+
|
|
146
|
+
(0, logger_1.log)(
|
|
147
|
+
` ${(0, logger_1.bold)('Architectural Risk:')} ${(0, logger_1.c)(diff.summary.riskLevel === 'CRITICAL' ? 'red' : 'yellow', diff.summary.riskLevel)} (${diff.summary.architecturalImpactScore})`,
|
|
148
|
+
);
|
|
149
|
+
(0, logger_1.log)(
|
|
150
|
+
` ${(0, logger_1.bold)('Entities Changed:')} +${diff.summary.entitiesAdded} / -${diff.summary.entitiesRemoved} / ~${diff.summary.entitiesModified}`,
|
|
151
|
+
);
|
|
152
|
+
(0, logger_1.log)(
|
|
153
|
+
` ${(0, logger_1.bold)('Trust Violations:')} ${diff.trustBoundaryViolations.length}`,
|
|
154
|
+
);
|
|
155
|
+
(0, logger_1.log)(
|
|
156
|
+
` ${(0, logger_1.bold)('Resilience Regressions:')} ${diff.resilienceRegressions.length}`,
|
|
157
|
+
);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
case 'audit': {
|
|
162
|
+
(0, logger_1.log)(
|
|
163
|
+
` ${(0, logger_1.c)('cyan', '▸')} Auditing architectural health, SPOFs & circular dependencies...`,
|
|
164
|
+
);
|
|
165
|
+
if (!fs_1.default.existsSync(modelFile)) {
|
|
166
|
+
const { ArchitectureExtractor } = require(
|
|
167
|
+
path_1.default.join(scriptsDir, 'architecture_extractor.js'),
|
|
168
|
+
);
|
|
169
|
+
new ArchitectureExtractor(targetDir).scan().save();
|
|
170
|
+
}
|
|
171
|
+
const model = JSON.parse(fs_1.default.readFileSync(modelFile, 'utf8'));
|
|
172
|
+
const { ArchitectureHealthAuditor } = require(
|
|
173
|
+
path_1.default.join(scriptsDir, 'architecture_health.js'),
|
|
174
|
+
);
|
|
175
|
+
const auditor = new ArchitectureHealthAuditor(model);
|
|
176
|
+
const report = auditor.audit();
|
|
177
|
+
|
|
178
|
+
(0, logger_1.log)(
|
|
179
|
+
` ${(0, logger_1.bold)('Total Signals:')} ${report.summary.totalSignals}`,
|
|
180
|
+
);
|
|
181
|
+
(0, logger_1.log)(
|
|
182
|
+
` ${(0, logger_1.bold)('Critical Violations:')} ${report.summary.critical}`,
|
|
183
|
+
);
|
|
184
|
+
(0, logger_1.log)(` ${(0, logger_1.bold)('High Risk Issues:')} ${report.summary.high}`);
|
|
185
|
+
for (const s of report.signals.slice(0, 5)) {
|
|
186
|
+
(0, logger_1.log)(
|
|
187
|
+
` ${(0, logger_1.c)('yellow', '!')} ${(0, logger_1.bold)(s.title)}: ${(0, logger_1.c)('gray', s.message)}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
case 'project': {
|
|
194
|
+
(0, logger_1.log)(
|
|
195
|
+
` ${(0, logger_1.c)('cyan', '▸')} Building interactive architecture projections...`,
|
|
196
|
+
);
|
|
197
|
+
if (!fs_1.default.existsSync(modelFile)) {
|
|
198
|
+
const { ArchitectureExtractor } = require(
|
|
199
|
+
path_1.default.join(scriptsDir, 'architecture_extractor.js'),
|
|
200
|
+
);
|
|
201
|
+
const ext = new ArchitectureExtractor(targetDir);
|
|
202
|
+
ext.scan();
|
|
203
|
+
ext.save();
|
|
204
|
+
}
|
|
205
|
+
const model = JSON.parse(fs_1.default.readFileSync(modelFile, 'utf8'));
|
|
206
|
+
const { ArchitectureVisualizer } = require(
|
|
207
|
+
path_1.default.join(scriptsDir, 'architecture_visualizer.js'),
|
|
208
|
+
);
|
|
209
|
+
const visualizer = new ArchitectureVisualizer(model);
|
|
210
|
+
const htmlPath = visualizer.saveHtml();
|
|
211
|
+
(0, logger_1.ok)(`Interactive Explorer Generated: ${htmlPath}`);
|
|
212
|
+
|
|
213
|
+
if (rawArgv.includes('--open') || flags.open) {
|
|
214
|
+
(0, logger_1.log)(` ${(0, logger_1.c)('cyan', '▸')} Opening in browser...`);
|
|
215
|
+
if (process.platform === 'win32') {
|
|
216
|
+
(0, child_process_1.spawn)('cmd.exe', ['/c', 'start', '', htmlPath], {
|
|
217
|
+
stdio: 'ignore',
|
|
218
|
+
detached: true,
|
|
219
|
+
}).unref();
|
|
220
|
+
} else if (process.platform === 'darwin') {
|
|
221
|
+
(0, child_process_1.spawn)('open', [htmlPath], {
|
|
222
|
+
stdio: 'ignore',
|
|
223
|
+
detached: true,
|
|
224
|
+
}).unref();
|
|
225
|
+
} else {
|
|
226
|
+
(0, child_process_1.spawn)('xdg-open', [htmlPath], {
|
|
227
|
+
stdio: 'ignore',
|
|
228
|
+
detached: true,
|
|
229
|
+
}).unref();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
case 'help':
|
|
236
|
+
default: {
|
|
237
|
+
(0, logger_1.log)((0, logger_1.bold)(' Tribunal Architecture Intelligence Commands'));
|
|
238
|
+
(0, logger_1.log)(` ${(0, logger_1.c)('gray', '─'.repeat(45))}`);
|
|
239
|
+
(0, logger_1.log)(
|
|
240
|
+
` ${(0, logger_1.c)('cyan', 'tk arch map')} Extract fact model from codebase AST`,
|
|
241
|
+
);
|
|
242
|
+
(0, logger_1.log)(
|
|
243
|
+
` ${(0, logger_1.c)('cyan', 'tk arch verify')} Zero-trust verify code evidence & confidence`,
|
|
244
|
+
);
|
|
245
|
+
(0, logger_1.log)(
|
|
246
|
+
` ${(0, logger_1.c)('cyan', 'tk arch impact <x>')} Simulate change blast radius and affected tests`,
|
|
247
|
+
);
|
|
248
|
+
(0, logger_1.log)(
|
|
249
|
+
` ${(0, logger_1.c)('cyan', 'tk arch diff <a> <b>')} Semantic diff: trust boundary & resilience shifts`,
|
|
250
|
+
);
|
|
251
|
+
(0, logger_1.log)(
|
|
252
|
+
` ${(0, logger_1.c)('cyan', 'tk arch audit')} Detect circular deps, SPOFs, test gaps`,
|
|
253
|
+
);
|
|
254
|
+
(0, logger_1.log)(
|
|
255
|
+
` ${(0, logger_1.c)('cyan', 'tk arch project')} Generate standalone multi-projection HTML explorer`,
|
|
256
|
+
);
|
|
257
|
+
console.log();
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
package/src/commands/context.js
CHANGED
|
@@ -24,13 +24,27 @@ function cmdContextRank(flags, processArgs, quiet = false) {
|
|
|
24
24
|
for (let i = 0; i < args.length; i++) {
|
|
25
25
|
const arg = args[i];
|
|
26
26
|
if (arg === '--target' && args[i + 1]) {
|
|
27
|
-
targetFiles = args[++i]
|
|
27
|
+
targetFiles = args[++i]
|
|
28
|
+
.split(',')
|
|
29
|
+
.map(f => f.trim())
|
|
30
|
+
.filter(Boolean);
|
|
28
31
|
} else if (arg.startsWith('--target=')) {
|
|
29
|
-
targetFiles = arg
|
|
32
|
+
targetFiles = arg
|
|
33
|
+
.split('=')[1]
|
|
34
|
+
.split(',')
|
|
35
|
+
.map(f => f.trim())
|
|
36
|
+
.filter(Boolean);
|
|
30
37
|
} else if (arg === '--candidates' && args[i + 1]) {
|
|
31
|
-
candidateFiles = args[++i]
|
|
38
|
+
candidateFiles = args[++i]
|
|
39
|
+
.split(',')
|
|
40
|
+
.map(f => f.trim())
|
|
41
|
+
.filter(Boolean);
|
|
32
42
|
} else if (arg.startsWith('--candidates=')) {
|
|
33
|
-
candidateFiles = arg
|
|
43
|
+
candidateFiles = arg
|
|
44
|
+
.split('=')[1]
|
|
45
|
+
.split(',')
|
|
46
|
+
.map(f => f.trim())
|
|
47
|
+
.filter(Boolean);
|
|
34
48
|
} else if (arg === '--max-tokens' && args[i + 1]) {
|
|
35
49
|
maxTokens = parseInt(args[++i], 10);
|
|
36
50
|
} else if (arg.startsWith('--max-tokens=')) {
|
|
@@ -59,9 +73,15 @@ function cmdContextRank(flags, processArgs, quiet = false) {
|
|
|
59
73
|
|
|
60
74
|
if (!quiet) {
|
|
61
75
|
console.log(`\n━━━ Deterministic Context Ranking ━━━━━━━━━━━━━━━━━━━━━━━━`);
|
|
62
|
-
console.log(
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
console.log(
|
|
77
|
+
` Items Evaluated: ${result.metrics.context_items_before} -> ${result.metrics.context_items_after} retained`,
|
|
78
|
+
);
|
|
79
|
+
console.log(
|
|
80
|
+
` Token Budget: ~${result.metrics.estimated_tokens_before} -> ~${result.metrics.estimated_tokens_after} tokens`,
|
|
81
|
+
);
|
|
82
|
+
console.log(
|
|
83
|
+
` Critical Evidence: ${result.metrics.critical_evidence_retained} mandatory file(s) retained\n`,
|
|
84
|
+
);
|
|
65
85
|
|
|
66
86
|
console.log(` Ranked Evidence Items:`);
|
|
67
87
|
for (const item of result.ranked_items) {
|
|
@@ -153,4 +173,3 @@ function cmdContext(flags, processArgs) {
|
|
|
153
173
|
process.exit(1);
|
|
154
174
|
}
|
|
155
175
|
}
|
|
156
|
-
|
package/src/commands/learn.js
CHANGED
|
@@ -28,7 +28,10 @@ async function cmdLearn(flags, quiet = false) {
|
|
|
28
28
|
if (flags.approve) {
|
|
29
29
|
try {
|
|
30
30
|
const p = approveEvolutionProposal(String(flags.approve), 'Human Developer', agentDest);
|
|
31
|
-
if (!quiet)
|
|
31
|
+
if (!quiet)
|
|
32
|
+
(0, logger_1.log)(
|
|
33
|
+
` ${(0, logger_1.c)('green', '✓')} Approved evolution proposal: ${(0, logger_1.bold)(p.proposal_id)} [${p.target}]`,
|
|
34
|
+
);
|
|
32
35
|
return;
|
|
33
36
|
} catch (e) {
|
|
34
37
|
(0, logger_1.err)(`Failed to approve proposal: ${e.message}`);
|
|
@@ -38,8 +41,15 @@ async function cmdLearn(flags, quiet = false) {
|
|
|
38
41
|
|
|
39
42
|
if (flags.reject) {
|
|
40
43
|
try {
|
|
41
|
-
const p = rejectEvolutionProposal(
|
|
42
|
-
|
|
44
|
+
const p = rejectEvolutionProposal(
|
|
45
|
+
String(flags.reject),
|
|
46
|
+
flags.reason || 'Rejected by developer',
|
|
47
|
+
agentDest,
|
|
48
|
+
);
|
|
49
|
+
if (!quiet)
|
|
50
|
+
(0, logger_1.log)(
|
|
51
|
+
` ${(0, logger_1.c)('yellow', '✓')} Rejected evolution proposal: ${(0, logger_1.bold)(p.proposal_id)}`,
|
|
52
|
+
);
|
|
43
53
|
return;
|
|
44
54
|
} catch (e) {
|
|
45
55
|
(0, logger_1.err)(`Failed to reject proposal: ${e.message}`);
|
|
@@ -49,14 +59,19 @@ async function cmdLearn(flags, quiet = false) {
|
|
|
49
59
|
|
|
50
60
|
if (flags.status || flags.proposals) {
|
|
51
61
|
const proposals = loadEvolutionProposals(agentDest);
|
|
52
|
-
(0, logger_1.log)(
|
|
62
|
+
(0, logger_1.log)(
|
|
63
|
+
`\n ${(0, logger_1.bold)('Tribunal Evolution Proposals')} (${proposals.length} total)`,
|
|
64
|
+
);
|
|
53
65
|
(0, logger_1.dim)(' ──────────────────────────────────────────────────');
|
|
54
66
|
if (proposals.length === 0) {
|
|
55
67
|
(0, logger_1.dim)(' No evolution proposals recorded yet.');
|
|
56
68
|
} else {
|
|
57
69
|
for (const p of proposals) {
|
|
58
|
-
const color =
|
|
59
|
-
|
|
70
|
+
const color =
|
|
71
|
+
p.status === 'APPROVED' ? 'green' : p.status === 'REJECTED' ? 'red' : 'yellow';
|
|
72
|
+
(0, logger_1.log)(
|
|
73
|
+
` ${(0, logger_1.c)(color, `[${p.status}]`)} ${(0, logger_1.bold)(p.proposal_id)} — Target: ${(0, logger_1.c)('cyan', p.target)} (Risk: ${p.risk})`,
|
|
74
|
+
);
|
|
60
75
|
(0, logger_1.dim)(` Evidence: ${p.observed_evidence}`);
|
|
61
76
|
(0, logger_1.dim)(` Change: ${p.proposed_change}`);
|
|
62
77
|
}
|
package/src/commands/memory.js
CHANGED
|
@@ -210,12 +210,21 @@ function memoryStore(agentDest, type, content, tags, sessionId) {
|
|
|
210
210
|
|
|
211
211
|
// ── Recall ──────────────────────────────────────────────────────────────────
|
|
212
212
|
|
|
213
|
-
function memoryRecall(agentDest, query, budget = 2000) {
|
|
213
|
+
function memoryRecall(agentDest, query, budget = 2000, options = {}) {
|
|
214
214
|
const lockPath = acquireLock(agentDest);
|
|
215
215
|
try {
|
|
216
216
|
const index = loadIndex(agentDest);
|
|
217
|
+
const targetSessionId = options && typeof options === 'object' ? options.sessionId : null;
|
|
217
218
|
|
|
218
219
|
const scored = index.entries
|
|
220
|
+
.filter(entry => {
|
|
221
|
+
if (entry.memory_type === 'working') {
|
|
222
|
+
if (entry.session_id) {
|
|
223
|
+
if (!targetSessionId || entry.session_id !== targetSessionId) return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
})
|
|
219
228
|
.map(entry => ({ entry, score: computeScore(entry, query) }))
|
|
220
229
|
.filter(s => s.score > 0)
|
|
221
230
|
.sort((a, b) => b.score - a.score);
|
package/src/commands/native.js
CHANGED
|
@@ -252,9 +252,15 @@ function resolveMonotonicImpactTier(options = {}) {
|
|
|
252
252
|
const files = Array.isArray(rawFiles)
|
|
253
253
|
? rawFiles.filter(Boolean)
|
|
254
254
|
: typeof rawFiles === 'string' && rawFiles.length > 0
|
|
255
|
-
? rawFiles
|
|
255
|
+
? rawFiles
|
|
256
|
+
.split(',')
|
|
257
|
+
.map(f => f.trim())
|
|
258
|
+
.filter(Boolean)
|
|
256
259
|
: [];
|
|
257
|
-
const lines =
|
|
260
|
+
const lines =
|
|
261
|
+
typeof opts.lines === 'number' && !isNaN(opts.lines)
|
|
262
|
+
? opts.lines
|
|
263
|
+
: parseInt(opts.lines, 10) || 0;
|
|
258
264
|
const task = typeof opts.task === 'string' ? opts.task : '';
|
|
259
265
|
const diff = typeof opts.diff === 'string' ? opts.diff : '';
|
|
260
266
|
const layaTier = opts.layaTier;
|
|
@@ -283,7 +289,10 @@ function resolveMonotonicImpactTier(options = {}) {
|
|
|
283
289
|
const secretOrExecPatterns =
|
|
284
290
|
/(?:-----BEGIN [A-Z ]+KEY-----|eyJ[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+|(?:api[_-]?key|secret|password|bearer|auth[_-]?token)\s*[:=]\s*['"][^'"]{6,}['"])/i;
|
|
285
291
|
|
|
286
|
-
const diffHasCode =
|
|
292
|
+
const diffHasCode =
|
|
293
|
+
/^\+[ \t]*(?:const|let|var|function|def|import|require|class|export|db\.|SELECT|UPDATE|DELETE|INSERT|jwt\.|auth\.)/im.test(
|
|
294
|
+
diff,
|
|
295
|
+
);
|
|
287
296
|
const diffMatchesHighRiskCode = diffHasCode && HIGH_RISK_PATTERNS.test(diff);
|
|
288
297
|
|
|
289
298
|
const diffHasHighRisk =
|