tribunal-kit 6.0.0 → 7.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/.manifest.json +78 -0
- package/.agent/ARCHITECTURE.md +19 -241
- package/.agent/agents/accessibility-reviewer.md +23 -16
- package/.agent/agents/ai-code-reviewer.md +25 -21
- package/.agent/agents/anti-pattern-reviewer.md +12 -7
- package/.agent/agents/api-architect.md +1 -0
- package/.agent/agents/backend-specialist.md +23 -22
- package/.agent/agents/cloud-engineer.md +1 -0
- package/.agent/agents/code-archaeologist.md +1 -0
- package/.agent/agents/complexity-reviewer.md +10 -7
- package/.agent/agents/database-architect.md +3 -2
- package/.agent/agents/db-latency-auditor.md +6 -2
- package/.agent/agents/debugger.md +3 -2
- package/.agent/agents/dependency-reviewer.md +1 -0
- package/.agent/agents/devops-engineer.md +9 -8
- package/.agent/agents/documentation-writer.md +6 -5
- package/.agent/agents/explorer-agent.md +1 -0
- package/.agent/agents/frontend-reviewer.md +21 -17
- package/.agent/agents/frontend-specialist.md +23 -20
- package/.agent/agents/game-developer.md +1 -0
- package/.agent/agents/interaction-reviewer.md +10 -5
- package/.agent/agents/logic-reviewer.md +3 -0
- package/.agent/agents/minimalist-reviewer.md +6 -0
- package/.agent/agents/mobile-developer.md +7 -6
- package/.agent/agents/mobile-reviewer.md +14 -13
- package/.agent/agents/orchestrator.md +3 -0
- package/.agent/agents/penetration-tester.md +1 -0
- package/.agent/agents/performance-optimizer.md +6 -5
- package/.agent/agents/performance-reviewer.md +6 -6
- package/.agent/agents/pipeline-reviewer.md +144 -0
- package/.agent/agents/precedence-reviewer.md +1 -0
- package/.agent/agents/product-manager.md +1 -0
- package/.agent/agents/product-owner.md +1 -0
- package/.agent/agents/product-reviewer.md +12 -7
- package/.agent/agents/project-planner.md +3 -0
- package/.agent/agents/qa-automation-engineer.md +50 -43
- package/.agent/agents/resilience-reviewer.md +1 -0
- package/.agent/agents/schema-reviewer.md +1 -0
- package/.agent/agents/security-auditor.md +24 -24
- package/.agent/agents/seo-specialist.md +33 -23
- package/.agent/agents/sql-reviewer.md +5 -4
- package/.agent/agents/supervisor-agent.md +12 -2
- package/.agent/agents/swarm-worker-contracts.md +13 -13
- package/.agent/agents/swarm-worker-registry.md +51 -51
- package/.agent/agents/system-architect.md +1 -0
- package/.agent/agents/test-coverage-reviewer.md +25 -22
- package/.agent/agents/test-engineer.md +12 -11
- package/.agent/agents/throughput-optimizer.md +45 -40
- package/.agent/agents/type-safety-reviewer.md +5 -4
- package/.agent/agents/ui-ux-auditor.md +6 -4
- package/.agent/agents/ui-visual-auditor.md +3 -0
- package/.agent/agents/ux-reviewer.md +11 -6
- package/.agent/agents/visual-reviewer.md +11 -6
- package/.agent/agents/vitals-reviewer.md +5 -4
- package/.agent/history/memory/.memory.idx +3716 -1
- package/.agent/history/memory/MEMORY.md +246 -1
- package/.agent/mcp_config.json +1 -6
- package/.agent/routing_index.json +2034 -263
- package/.agent/rules/GEMINI.md +12 -10
- package/.agent/rules/GEMINI_PLANNER.md +19 -21
- package/.agent/scripts/_colors.js +52 -54
- package/.agent/scripts/_utils.js +52 -53
- package/.agent/scripts/auto_preview.js +39 -43
- package/.agent/scripts/bundle_analyzer.js +47 -60
- package/.agent/scripts/case_law_manager.js +200 -294
- package/.agent/scripts/checklist.js +73 -94
- package/.agent/scripts/cicd_validator.js +305 -0
- package/.agent/scripts/compile_router.py +4 -111
- package/.agent/scripts/context_broker.js +317 -412
- package/.agent/scripts/contract_engine.js +402 -0
- package/.agent/scripts/dependency_analyzer.js +112 -124
- package/.agent/scripts/graph_builder.js +75 -103
- package/.agent/scripts/graph_visualizer.js +10 -12
- package/.agent/scripts/graph_zoom.js +38 -55
- package/.agent/scripts/guardrail_engine.js +195 -145
- package/.agent/scripts/impact_classifier.js +55 -30
- package/.agent/scripts/inner_loop_validator.js +108 -159
- package/.agent/scripts/integrity_manifest.js +59 -67
- package/.agent/scripts/lint_runner.js +65 -75
- package/.agent/scripts/marathon_harness.js +131 -208
- package/.agent/scripts/migrate_skills_frontmatter.py +4 -63
- package/.agent/scripts/minify_context.js +29 -33
- package/.agent/scripts/minimal_change_engine.js +95 -87
- package/.agent/scripts/mutation_runner.js +46 -62
- package/.agent/scripts/pipeline_engine.js +320 -209
- package/.agent/scripts/prompt_compiler.js +118 -93
- package/.agent/scripts/schema_validator.js +73 -121
- package/.agent/scripts/security_scan.js +88 -117
- package/.agent/scripts/session_manager.js +52 -69
- package/.agent/scripts/signal_detector.js +24 -22
- package/.agent/scripts/skill_evolution.js +184 -245
- package/.agent/scripts/skill_integrator.js +35 -48
- package/.agent/scripts/socratic_gate_policy.js +15 -12
- package/.agent/scripts/strengthen_skills.js +29 -33
- package/.agent/scripts/swarm_dispatcher.js +120 -151
- package/.agent/scripts/test_runner.js +54 -56
- package/.agent/scripts/token_budget_broker.js +9 -7
- package/.agent/scripts/trace_engine.js +126 -0
- package/.agent/scripts/verify_all.js +76 -93
- package/.agent/scripts/visual_audit.js +16 -21
- package/.agent/skill_topic_map.json +237 -0
- package/.agent/skills/12-principles-of-animation/SKILL.md +7 -0
- package/.agent/skills/60fps-animation/SKILL.md +7 -0
- package/.agent/skills/accessible-animation/SKILL.md +5 -1
- package/.agent/skills/adapt/SKILL.md +7 -1
- package/.agent/skills/advanced-rag-pipelines/SKILL.md +1 -0
- package/.agent/skills/agent-organizer/SKILL.md +1 -0
- package/.agent/skills/agentic-patterns/SKILL.md +33 -25
- package/.agent/skills/agentic-workflows-2026/SKILL.md +80 -0
- package/.agent/skills/ai-app-hardening/SKILL.md +59 -0
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +7 -6
- package/.agent/skills/animation-on-scroll/SKILL.md +24 -15
- package/.agent/skills/animation-systems/SKILL.md +11 -10
- package/.agent/skills/antfu-conventions/SKILL.md +7 -2
- package/.agent/skills/api-patterns/SKILL.md +14 -10
- package/.agent/skills/api-security-auditor/SKILL.md +15 -14
- package/.agent/skills/app-builder/SKILL.md +1 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +2 -2
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +12 -12
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +3 -3
- package/.agent/skills/apple-design/SKILL.md +8 -7
- package/.agent/skills/architecture/SKILL.md +3 -2
- package/.agent/skills/audit-and-fix/SKILL.md +8 -5
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -8
- package/.agent/skills/backend-security-expert/SKILL.md +1 -0
- package/.agent/skills/baseline-ui/SKILL.md +8 -7
- package/.agent/skills/bash-linux/SKILL.md +1 -0
- package/.agent/skills/behavioral-modes/SKILL.md +1 -0
- package/.agent/skills/better-colors/SKILL.md +11 -7
- package/.agent/skills/better-typography/SKILL.md +30 -16
- package/.agent/skills/better-ui/SKILL.md +17 -10
- package/.agent/skills/bolder/SKILL.md +6 -0
- package/.agent/skills/brainstorming/SKILL.md +6 -4
- package/.agent/skills/browser-native-ai/SKILL.md +5 -4
- package/.agent/skills/build-primitive/SKILL.md +5 -0
- package/.agent/skills/building-native-ui/SKILL.md +1 -0
- package/.agent/skills/cicd-pro/SKILL.md +2 -1
- package/.agent/skills/clarify/SKILL.md +19 -14
- package/.agent/skills/clean-code/SKILL.md +16 -15
- package/.agent/skills/cloud-architect/SKILL.md +1 -0
- package/.agent/skills/cobejs/SKILL.md +7 -9
- package/.agent/skills/code-review-checklist/SKILL.md +1 -0
- package/.agent/skills/codebase-design/SKILL.md +7 -2
- package/.agent/skills/colorize/SKILL.md +8 -3
- package/.agent/skills/compact-landing/SKILL.md +8 -3
- package/.agent/skills/company-logos/SKILL.md +6 -0
- package/.agent/skills/config-validator/SKILL.md +10 -9
- package/.agent/skills/containerization-pro/SKILL.md +6 -5
- package/.agent/skills/context-engineering-pro/SKILL.md +70 -0
- package/.agent/skills/create-design-md/SKILL.md +13 -5
- package/.agent/skills/critique/SKILL.md +10 -8
- package/.agent/skills/csharp-developer/SKILL.md +1 -0
- package/.agent/skills/data-validation-schemas/SKILL.md +28 -23
- package/.agent/skills/database-design/SKILL.md +2 -1
- package/.agent/skills/delight/SKILL.md +6 -0
- package/.agent/skills/deployment-procedures/SKILL.md +2 -1
- package/.agent/skills/design-lab/SKILL.md +5 -0
- package/.agent/skills/devops-engineer/SKILL.md +3 -2
- package/.agent/skills/devops-incident-responder/SKILL.md +2 -1
- package/.agent/skills/diagnosing-bugs/SKILL.md +12 -2
- package/.agent/skills/distill/SKILL.md +7 -2
- package/.agent/skills/documentation-templates/SKILL.md +3 -2
- package/.agent/skills/domain-modeling/SKILL.md +12 -4
- package/.agent/skills/duckdb-analytical-sql/SKILL.md +59 -0
- package/.agent/skills/edge-ai-mobile/SKILL.md +50 -0
- package/.agent/skills/edge-computing/SKILL.md +9 -8
- package/.agent/skills/emil-design-eng/SKILL.md +43 -27
- package/.agent/skills/error-resilience/SKILL.md +34 -16
- package/.agent/skills/expo-router-v4/SKILL.md +81 -0
- package/.agent/skills/extract-design-system/SKILL.md +12 -11
- package/.agent/skills/fabel-protocol/SKILL.md +24 -17
- package/.agent/skills/fixing-accessibility/SKILL.md +23 -16
- package/.agent/skills/fixing-metadata/SKILL.md +24 -13
- package/.agent/skills/fixing-motion-performance/SKILL.md +7 -5
- package/.agent/skills/framer-motion-expert/SKILL.md +29 -15
- package/.agent/skills/frontend-design/SKILL.md +21 -13
- package/.agent/skills/frontend-security-expert/SKILL.md +1 -0
- package/.agent/skills/game-design-expert/SKILL.md +1 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +1 -0
- package/.agent/skills/generative-ui-expert/SKILL.md +3 -2
- package/.agent/skills/geo-fundamentals/SKILL.md +2 -1
- package/.agent/skills/git-pro/SKILL.md +10 -9
- package/.agent/skills/github-operations/SKILL.md +2 -1
- package/.agent/skills/gpt-taste/SKILL.md +7 -0
- package/.agent/skills/gsap-core/SKILL.md +26 -22
- package/.agent/skills/gsap-frameworks/SKILL.md +6 -5
- package/.agent/skills/gsap-performance/SKILL.md +4 -3
- package/.agent/skills/gsap-plugins/SKILL.md +34 -33
- package/.agent/skills/gsap-react/SKILL.md +9 -8
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +34 -33
- package/.agent/skills/gsap-timeline/SKILL.md +18 -15
- package/.agent/skills/gsap-utils/SKILL.md +25 -24
- package/.agent/skills/harden/SKILL.md +9 -3
- package/.agent/skills/harness-protocol/SKILL.md +1 -0
- package/.agent/skills/i18n-localization/SKILL.md +10 -9
- package/.agent/skills/impeccable/SKILL.md +5 -0
- package/.agent/skills/improve-codebase-architecture/SKILL.md +10 -5
- package/.agent/skills/improve-ui/SKILL.md +12 -5
- package/.agent/skills/intelligent-routing/SKILL.md +7 -6
- package/.agent/skills/knowledge-graph/SKILL.md +1 -0
- package/.agent/skills/landing-page/SKILL.md +1 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -4
- package/.agent/skills/llm-engineering/SKILL.md +55 -54
- package/.agent/skills/local-first/SKILL.md +20 -19
- package/.agent/skills/local-first-architecture/SKILL.md +6 -1
- package/.agent/skills/lottie-animation/SKILL.md +7 -3
- package/.agent/skills/marquee-loop/SKILL.md +1 -0
- package/.agent/skills/masked-reveal/SKILL.md +17 -4
- package/.agent/skills/mcp-builder/SKILL.md +13 -10
- package/.agent/skills/micro-interaction/SKILL.md +20 -5
- package/.agent/skills/mobile-design/SKILL.md +26 -15
- package/.agent/skills/monorepo-management/SKILL.md +3 -2
- package/.agent/skills/morphing-icons/SKILL.md +16 -6
- package/.agent/skills/motion-engineering/SKILL.md +19 -15
- package/.agent/skills/nextjs-react-expert/SKILL.md +26 -21
- package/.agent/skills/nodejs-best-practices/SKILL.md +89 -76
- package/.agent/skills/observability/SKILL.md +45 -44
- package/.agent/skills/opentelemetry-observability/SKILL.md +59 -0
- package/.agent/skills/page-transition-animation/SKILL.md +6 -3
- package/.agent/skills/parallel-agents/SKILL.md +7 -2
- package/.agent/skills/performance-profiling/SKILL.md +24 -13
- package/.agent/skills/plan-writing/SKILL.md +1 -0
- package/.agent/skills/platform-engineer/SKILL.md +3 -2
- package/.agent/skills/platform-engineering-opentofu/SKILL.md +68 -0
- package/.agent/skills/playwright-ai-e2e/SKILL.md +60 -0
- package/.agent/skills/playwright-best-practices/SKILL.md +29 -28
- package/.agent/skills/polish/SKILL.md +13 -12
- package/.agent/skills/powershell-windows/SKILL.md +1 -0
- package/.agent/skills/pricing-page/SKILL.md +8 -3
- package/.agent/skills/product-aware-heuristics/SKILL.md +122 -72
- package/.agent/skills/progressive-blur/SKILL.md +9 -4
- package/.agent/skills/project-idioms/SKILL.md +1 -0
- package/.agent/skills/property-based-testing/SKILL.md +58 -0
- package/.agent/skills/python-patterns/SKILL.md +1 -0
- package/.agent/skills/python-pro/SKILL.md +1 -0
- package/.agent/skills/quieter/SKILL.md +6 -0
- package/.agent/skills/react-doctor/SKILL.md +6 -0
- package/.agent/skills/react-specialist/SKILL.md +32 -28
- package/.agent/skills/readme-builder/SKILL.md +1 -0
- package/.agent/skills/realtime-patterns/SKILL.md +34 -33
- package/.agent/skills/red-team-tactics/SKILL.md +1 -0
- package/.agent/skills/redesign-skill/SKILL.md +6 -0
- package/.agent/skills/review-animations/SKILL.md +5 -2
- package/.agent/skills/review-animations/STANDARDS.md +37 -23
- package/.agent/skills/rust-pro/SKILL.md +1 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +4 -3
- package/.agent/skills/server-management/SKILL.md +1 -0
- package/.agent/skills/shadcn-ui-expert/SKILL.md +28 -22
- package/.agent/skills/shape/SKILL.md +9 -2
- package/.agent/skills/skill-creator/SKILL.md +1 -0
- package/.agent/skills/soft-skill/SKILL.md +6 -0
- package/.agent/skills/sounds-on-the-web/SKILL.md +1 -0
- package/.agent/skills/sql-pro/SKILL.md +1 -0
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +1 -0
- package/.agent/skills/svg-animation/SKILL.md +16 -7
- package/.agent/skills/swiftui-expert/SKILL.md +1 -0
- package/.agent/skills/swiss-design/SKILL.md +5 -0
- package/.agent/skills/system-design-pro/SKILL.md +1 -0
- package/.agent/skills/systematic-debugging/SKILL.md +1 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +25 -11
- package/.agent/skills/taste-skill/SKILL.md +6 -0
- package/.agent/skills/tdd-workflow/SKILL.md +5 -0
- package/.agent/skills/test-result-analyzer/SKILL.md +1 -0
- package/.agent/skills/testing-patterns/SKILL.md +123 -115
- package/.agent/skills/thermo-nuclear-code-quality-review/SKILL.md +5 -0
- package/.agent/skills/thinking-protocol/SKILL.md +3 -0
- package/.agent/skills/to-spring-or-not-to-spring/SKILL.md +9 -8
- package/.agent/skills/transitions-dev/SKILL.md +19 -6
- package/.agent/skills/trend-researcher/SKILL.md +1 -0
- package/.agent/skills/typescript-advanced/SKILL.md +23 -18
- package/.agent/skills/typeset/SKILL.md +10 -1
- package/.agent/skills/ui-reasoning-engine/SKILL.md +67 -48
- package/.agent/skills/ui-skill-packs/SKILL.md +6 -1
- package/.agent/skills/ui-skills-root/SKILL.md +39 -38
- package/.agent/skills/ui-ux-pro-max/SKILL.md +34 -26
- package/.agent/skills/ui-ux-researcher/SKILL.md +1 -0
- package/.agent/skills/vector-search-pgvector/SKILL.md +78 -0
- package/.agent/skills/vue-expert/SKILL.md +22 -19
- package/.agent/skills/vulnerability-scanner/SKILL.md +22 -21
- package/.agent/skills/web-accessibility-auditor/SKILL.md +2 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +16 -10
- package/.agent/skills/web-quality-audit/SKILL.md +5 -0
- package/.agent/skills/webapp-testing/SKILL.md +14 -13
- package/.agent/skills/webgpu-performance/SKILL.md +1 -0
- package/.agent/skills/whimsy-injector/SKILL.md +9 -5
- package/.agent/skills/workflow-optimizer/SKILL.md +1 -0
- package/.agent/skills/zero-trust-passkeys/SKILL.md +90 -0
- package/.agent/templates/DESIGN.md +119 -110
- package/.agent/templates/design-tokens.json +9 -6
- package/.agent/workflows/acf.md +1 -0
- package/.agent/workflows/api-tester.md +1 -0
- package/.agent/workflows/audit.md +1 -0
- package/.agent/workflows/brainstorm.md +1 -0
- package/.agent/workflows/changelog.md +1 -0
- package/.agent/workflows/contract.md +60 -0
- package/.agent/workflows/create.md +1 -0
- package/.agent/workflows/debug.md +1 -0
- package/.agent/workflows/deploy.md +1 -0
- package/.agent/workflows/enhance.md +1 -0
- package/.agent/workflows/fix-ci.md +89 -0
- package/.agent/workflows/fix.md +1 -0
- package/.agent/workflows/generate.md +1 -0
- package/.agent/workflows/marathon.md +1 -0
- package/.agent/workflows/migrate.md +1 -0
- package/.agent/workflows/minimal.md +9 -7
- package/.agent/workflows/orchestrate.md +1 -0
- package/.agent/workflows/performance-benchmarker.md +1 -0
- package/.agent/workflows/pipeline.md +26 -21
- package/.agent/workflows/plan.md +1 -0
- package/.agent/workflows/preview.md +1 -0
- package/.agent/workflows/refactor.md +3 -2
- package/.agent/workflows/review-ai.md +4 -3
- package/.agent/workflows/review.md +1 -0
- package/.agent/workflows/session.md +1 -0
- package/.agent/workflows/status.md +1 -0
- package/.agent/workflows/strengthen-skills.md +1 -0
- package/.agent/workflows/super-prompt.md +1 -0
- package/.agent/workflows/swarm.md +15 -3
- package/.agent/workflows/test.md +8 -7
- package/.agent/workflows/tribunal-backend.md +3 -2
- package/.agent/workflows/tribunal-cicd.md +104 -0
- package/.agent/workflows/tribunal-database.md +1 -0
- package/.agent/workflows/tribunal-frontend.md +8 -6
- package/.agent/workflows/tribunal-full.md +15 -14
- package/.agent/workflows/tribunal-mobile.md +6 -5
- package/.agent/workflows/tribunal-performance.md +1 -0
- package/.agent/workflows/tribunal-speed.md +1 -0
- package/.agent/workflows/tribunal-ui.md +29 -21
- package/.agent/workflows/ui-ux-pro-max.md +19 -15
- package/CONTRIBUTING.md +3 -3
- package/README.md +160 -88
- package/SECURITY.md +11 -11
- package/bin/mcp-server.js +512 -233
- package/bin/tribunal-kit.js +29 -30
- package/bin/wrapper.js +45 -48
- package/dist/cli.js +26 -0
- package/dist/commands/case.js +2 -0
- package/dist/commands/contract.js +440 -0
- package/dist/commands/memory.js +3 -2
- package/dist/commands/native.js +36 -0
- package/dist/commands/status.js +6 -0
- package/dist/esm/index.mjs +32 -0
- package/dist/index.d.ts +58 -3
- package/package.json +20 -16
- package/scripts/benchmark.js +62 -86
- package/scripts/changelog.js +67 -73
- package/scripts/fix-vbc.js +13 -15
- package/scripts/fix-vbc.ps1 +2 -118
- package/scripts/stress_benchmark.js +358 -0
- package/scripts/sync-version.js +71 -41
- package/scripts/validate-payload.js +23 -30
- package/scripts/visual_audit.js +23 -13
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* contract.js — CLI command handler for `tk contract`
|
|
5
|
+
*
|
|
6
|
+
* Commands:
|
|
7
|
+
* tk contract init → Scaffold .tribunal/contracts/ with starter rules
|
|
8
|
+
* tk contract verify → Run contract checks against target/modified files
|
|
9
|
+
* tk contract verify --file <path> → Run contract checks against a single file
|
|
10
|
+
* tk contract list → List loaded contracts and details
|
|
11
|
+
* tk contract trace list → List captured failure context snapshots
|
|
12
|
+
* tk contract replay <id> → Replay failure trace snapshot in CLI
|
|
13
|
+
* tk contract generate --from-case <id> → Auto-generate a contract from a Case Law entry
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.cmdContract = cmdContract;
|
|
18
|
+
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const logger_1 = require("../utils/logger");
|
|
22
|
+
|
|
23
|
+
async function cmdContract(flags, argv, quiet = false) {
|
|
24
|
+
const projectRoot = flags.path ? path.resolve(flags.path) : process.cwd();
|
|
25
|
+
const rawArgs = argv.slice(3);
|
|
26
|
+
const subCmd = rawArgs[0] || "verify";
|
|
27
|
+
|
|
28
|
+
if (subCmd === "help" || subCmd === "--help" || subCmd === "-h") {
|
|
29
|
+
showContractHelp(quiet);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const contractEngineScript = path.join(
|
|
34
|
+
projectRoot,
|
|
35
|
+
".agent",
|
|
36
|
+
"scripts",
|
|
37
|
+
"contract_engine.js",
|
|
38
|
+
);
|
|
39
|
+
const traceEngineScript = path.join(
|
|
40
|
+
projectRoot,
|
|
41
|
+
".agent",
|
|
42
|
+
"scripts",
|
|
43
|
+
"trace_engine.js",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const contractEngine = fs.existsSync(contractEngineScript)
|
|
47
|
+
? require(contractEngineScript)
|
|
48
|
+
: null;
|
|
49
|
+
const traceEngine = fs.existsSync(traceEngineScript)
|
|
50
|
+
? require(traceEngineScript)
|
|
51
|
+
: null;
|
|
52
|
+
|
|
53
|
+
switch (subCmd) {
|
|
54
|
+
case "init":
|
|
55
|
+
scaffoldContracts(projectRoot, quiet);
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case "list":
|
|
59
|
+
if (!contractEngine) {
|
|
60
|
+
(0, logger_1.err)("contract_engine.js not found. Run `tk init` first.");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
listContracts(projectRoot, contractEngine, quiet);
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case "verify":
|
|
67
|
+
if (!contractEngine) {
|
|
68
|
+
(0, logger_1.err)("contract_engine.js not found. Run `tk init` first.");
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
runVerify(projectRoot, contractEngine, traceEngine, argv, flags, quiet);
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case "trace":
|
|
75
|
+
if (!traceEngine) {
|
|
76
|
+
(0, logger_1.err)("trace_engine.js not found. Run `tk init` first.");
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
runTraceList(projectRoot, traceEngine, quiet);
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case "replay":
|
|
83
|
+
if (!traceEngine) {
|
|
84
|
+
(0, logger_1.err)("trace_engine.js not found. Run `tk init` first.");
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
runReplay(projectRoot, traceEngine, rawArgs[1], quiet);
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case "generate":
|
|
91
|
+
generateFromCase(projectRoot, rawArgs, quiet);
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
default:
|
|
95
|
+
if (fs.existsSync(subCmd) || subCmd.startsWith("--")) {
|
|
96
|
+
// Treat as verify with arguments
|
|
97
|
+
runVerify(projectRoot, contractEngine, traceEngine, argv, flags, quiet);
|
|
98
|
+
} else {
|
|
99
|
+
(0, logger_1.err)(`Unknown contract subcommand: "${subCmd}"`);
|
|
100
|
+
showContractHelp(quiet);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ── Subcommand Implementations ───────────────────────────────────────────────
|
|
107
|
+
|
|
108
|
+
function scaffoldContracts(projectRoot, quiet) {
|
|
109
|
+
const contractsDir = path.join(projectRoot, ".tribunal", "contracts");
|
|
110
|
+
if (!fs.existsSync(contractsDir)) {
|
|
111
|
+
fs.mkdirSync(contractsDir, { recursive: true });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const starters = [
|
|
115
|
+
{
|
|
116
|
+
file: "no-console-log.yaml",
|
|
117
|
+
content: `name: "No console.log in production code"
|
|
118
|
+
description: "Prevents debug logging from reaching production"
|
|
119
|
+
scope: "src/**/*.ts, src/**/*.tsx, src/**/*.js"
|
|
120
|
+
exclude: "**/*.test.*, **/*.spec.*, scripts/**"
|
|
121
|
+
when: file_modified
|
|
122
|
+
severity: warn
|
|
123
|
+
must_not:
|
|
124
|
+
- pattern: "console.log"
|
|
125
|
+
message: "Use a structured logger instead of console.log"
|
|
126
|
+
`,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
file: "no-any-type.yaml",
|
|
130
|
+
content: `name: "No TypeScript 'any' escape hatch"
|
|
131
|
+
description: "Enforces strict typing in TypeScript files"
|
|
132
|
+
scope: "src/**/*.ts, src/**/*.tsx"
|
|
133
|
+
exclude: "**/*.d.ts"
|
|
134
|
+
when: file_modified
|
|
135
|
+
severity: warn
|
|
136
|
+
must_not:
|
|
137
|
+
- pattern: "regex:: any[;,\\\\s\\\\)\\\\]]"
|
|
138
|
+
message: "Avoid 'any' type annotations — use unknown or a specific type"
|
|
139
|
+
`,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
file: "require-error-handling.yaml",
|
|
143
|
+
content: `name: "Async functions must handle errors"
|
|
144
|
+
description: "Every async function should have error handling"
|
|
145
|
+
scope: "src/**/*.ts, src/**/*.tsx"
|
|
146
|
+
when: file_modified
|
|
147
|
+
severity: info
|
|
148
|
+
must:
|
|
149
|
+
- pattern: "regex:(try\\\\s*\\\\{|.catch\\\\(|\\\\.catch\\\\s*\\\\()"
|
|
150
|
+
message: "Async functions should include try/catch or .catch() for error handling"
|
|
151
|
+
metadata:
|
|
152
|
+
tags: ["resilience", "error-handling"]
|
|
153
|
+
`,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
let createdCount = 0;
|
|
158
|
+
for (const starter of starters) {
|
|
159
|
+
const filePath = path.join(contractsDir, starter.file);
|
|
160
|
+
if (!fs.existsSync(filePath)) {
|
|
161
|
+
fs.writeFileSync(filePath, starter.content, "utf8");
|
|
162
|
+
createdCount++;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!quiet) {
|
|
167
|
+
console.log();
|
|
168
|
+
(0, logger_1.log)(
|
|
169
|
+
` ${(0, logger_1.c)("green", "✔")} Scaffolded .tribunal/contracts/ with ${createdCount} starter behavioral contracts.`,
|
|
170
|
+
);
|
|
171
|
+
(0, logger_1.log)(
|
|
172
|
+
` ${(0, logger_1.c)("gray", "▸")} Edit files in .tribunal/contracts/ or run \`tk contract verify\` to enforce.`,
|
|
173
|
+
);
|
|
174
|
+
console.log();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function listContracts(projectRoot, contractEngine, quiet) {
|
|
179
|
+
const contracts = contractEngine.loadContracts(projectRoot);
|
|
180
|
+
if (quiet) return;
|
|
181
|
+
|
|
182
|
+
console.log();
|
|
183
|
+
(0, logger_1.log)(
|
|
184
|
+
` ${(0, logger_1.c)("cyan", "📜")} ${(0, logger_1.bold)("Loaded Behavioral Contracts")}`,
|
|
185
|
+
);
|
|
186
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
187
|
+
|
|
188
|
+
if (contracts.length === 0) {
|
|
189
|
+
(0, logger_1.log)(
|
|
190
|
+
` No contracts found in .tribunal/contracts/. Run \`tk contract init\` to create starter rules.`,
|
|
191
|
+
);
|
|
192
|
+
console.log();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
for (const c of contracts) {
|
|
197
|
+
const sevColor =
|
|
198
|
+
c.severity === "block" ? "red" : c.severity === "warn" ? "yellow" : "blue";
|
|
199
|
+
const rulesCount = (c.must?.length || 0) + (c.must_not?.length || 0);
|
|
200
|
+
|
|
201
|
+
(0, logger_1.log)(
|
|
202
|
+
` ${(0, logger_1.c)("cyan", "•")} ${(0, logger_1.bold)(c.name)} [${(0, logger_1.c)(sevColor, c.severity.toUpperCase())}]`,
|
|
203
|
+
);
|
|
204
|
+
(0, logger_1.log)(` Scope: ${(0, logger_1.c)("gray", c.scope || "*")}`);
|
|
205
|
+
(0, logger_1.log)(
|
|
206
|
+
` Rules: ${(0, logger_1.c)("white", String(rulesCount))} (${c.must?.length || 0} must, ${c.must_not?.length || 0} must_not)`,
|
|
207
|
+
);
|
|
208
|
+
if (c.description) {
|
|
209
|
+
(0, logger_1.log)(` Note: ${(0, logger_1.c)("gray", c.description)}`);
|
|
210
|
+
}
|
|
211
|
+
console.log();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function runVerify(projectRoot, contractEngine, traceEngine, argv, flags, quiet) {
|
|
216
|
+
const jsonMode = argv.includes("--json");
|
|
217
|
+
const fileArg = extractFileArg(argv);
|
|
218
|
+
|
|
219
|
+
let targetFiles = null;
|
|
220
|
+
if (fileArg) {
|
|
221
|
+
const resolved = path.resolve(fileArg);
|
|
222
|
+
if (!fs.existsSync(resolved)) {
|
|
223
|
+
(0, logger_1.err)(`File not found: ${fileArg}`);
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
targetFiles = [resolved];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const results = contractEngine.verifyWorkspace(projectRoot, targetFiles);
|
|
230
|
+
|
|
231
|
+
// Capture failure context snapshots for block/warn violations if traceEngine exists
|
|
232
|
+
if (traceEngine && results.violations.length > 0) {
|
|
233
|
+
for (const v of results.violations) {
|
|
234
|
+
if (v.severity === "block" || v.severity === "warn") {
|
|
235
|
+
try {
|
|
236
|
+
traceEngine.captureSnapshot(projectRoot, v);
|
|
237
|
+
} catch {
|
|
238
|
+
// Non-critical snapshot capture fallback
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (jsonMode) {
|
|
245
|
+
console.log(JSON.stringify(results, null, 2));
|
|
246
|
+
process.exit(results.blocked ? 1 : 0);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (quiet) {
|
|
250
|
+
process.exit(results.blocked ? 1 : 0);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
console.log();
|
|
254
|
+
(0, logger_1.log)(
|
|
255
|
+
` ${(0, logger_1.c)("cyan", "📜")} ${(0, logger_1.bold)("Contract Verification Report")}`,
|
|
256
|
+
);
|
|
257
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
258
|
+
(0, logger_1.log)(
|
|
259
|
+
` Contracts loaded: ${(0, logger_1.c)("white", String(results.contracts_loaded))}`,
|
|
260
|
+
);
|
|
261
|
+
(0, logger_1.log)(
|
|
262
|
+
` Files scanned: ${(0, logger_1.c)("white", String(results.files_checked))}`,
|
|
263
|
+
);
|
|
264
|
+
(0, logger_1.log)(
|
|
265
|
+
` Total violations: ${results.violations.length > 0 ? (0, logger_1.c)("yellow", String(results.violations.length)) : (0, logger_1.c)("green", "0")}`,
|
|
266
|
+
);
|
|
267
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
268
|
+
|
|
269
|
+
if (results.violations.length > 0) {
|
|
270
|
+
for (const v of results.violations) {
|
|
271
|
+
const icon =
|
|
272
|
+
v.severity === "block"
|
|
273
|
+
? (0, logger_1.c)("red", "✖ BLOCK")
|
|
274
|
+
: v.severity === "warn"
|
|
275
|
+
? (0, logger_1.c)("yellow", "⚠ WARN")
|
|
276
|
+
: (0, logger_1.c)("blue", "ℹ INFO");
|
|
277
|
+
|
|
278
|
+
const lineInfo = v.line ? `:${v.line}` : "";
|
|
279
|
+
(0, logger_1.log)(
|
|
280
|
+
` ${icon} [${(0, logger_1.bold)(v.contract)}] ${(0, logger_1.c)("cyan", v.file + lineInfo)}`,
|
|
281
|
+
);
|
|
282
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("white", v.message)}`);
|
|
283
|
+
if (v.snippet) {
|
|
284
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "Snippet:")} ${(0, logger_1.c)("gray", v.snippet)}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
(0, logger_1.log)(
|
|
289
|
+
` ${(0, logger_1.c)("green", "✅")} All contracts satisfied. Zero behavioral violations detected.`,
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
console.log();
|
|
294
|
+
process.exit(results.blocked ? 1 : 0);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function runTraceList(projectRoot, traceEngine, quiet) {
|
|
298
|
+
const snapshots = traceEngine.listSnapshots(projectRoot);
|
|
299
|
+
if (quiet) return;
|
|
300
|
+
|
|
301
|
+
console.log();
|
|
302
|
+
(0, logger_1.log)(
|
|
303
|
+
` ${(0, logger_1.c)("cyan", "🎥")} ${(0, logger_1.bold)("Failure Context Snapshots")}`,
|
|
304
|
+
);
|
|
305
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
306
|
+
|
|
307
|
+
if (snapshots.length === 0) {
|
|
308
|
+
(0, logger_1.log)(` No failure context snapshots recorded.`);
|
|
309
|
+
console.log();
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
for (const s of snapshots.slice(0, 10)) {
|
|
314
|
+
const sevColor = s.severity === "block" ? "red" : "yellow";
|
|
315
|
+
(0, logger_1.log)(
|
|
316
|
+
` ${(0, logger_1.c)("cyan", "•")} ${(0, logger_1.bold)(s.id)} [${(0, logger_1.c)(sevColor, s.severity.toUpperCase())}]`,
|
|
317
|
+
);
|
|
318
|
+
(0, logger_1.log)(` Contract: ${s.contract}`);
|
|
319
|
+
(0, logger_1.log)(` Target: ${(0, logger_1.c)("gray", s.target_file)}`);
|
|
320
|
+
(0, logger_1.log)(` Time: ${(0, logger_1.c)("gray", s.timestamp)}`);
|
|
321
|
+
console.log();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function runReplay(projectRoot, traceEngine, traceId, quiet) {
|
|
326
|
+
if (!traceId) {
|
|
327
|
+
(0, logger_1.err)("Missing trace ID. Usage: tk contract replay <trace_id>");
|
|
328
|
+
process.exit(1);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const snapshot = traceEngine.replaySnapshot(projectRoot, traceId);
|
|
332
|
+
if (!snapshot) {
|
|
333
|
+
(0, logger_1.err)(`Trace snapshot not found: "${traceId}"`);
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (quiet) return;
|
|
338
|
+
|
|
339
|
+
console.log();
|
|
340
|
+
(0, logger_1.log)(
|
|
341
|
+
` ${(0, logger_1.c)("cyan", "🎬")} ${(0, logger_1.bold)("Replaying Failure Trace Snapshot")}`,
|
|
342
|
+
);
|
|
343
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
344
|
+
(0, logger_1.log)(` ID: ${(0, logger_1.c)("white", snapshot.id)}`);
|
|
345
|
+
(0, logger_1.log)(` Contract: ${(0, logger_1.bold)(snapshot.contract)}`);
|
|
346
|
+
(0, logger_1.log)(` Severity: ${(0, logger_1.c)(snapshot.severity === "block" ? "red" : "yellow", snapshot.severity.toUpperCase())}`);
|
|
347
|
+
(0, logger_1.log)(` Target: ${(0, logger_1.c)("cyan", snapshot.target_file)}`);
|
|
348
|
+
(0, logger_1.log)(` Time: ${snapshot.timestamp}`);
|
|
349
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
350
|
+
(0, logger_1.log)(
|
|
351
|
+
` ${(0, logger_1.c)("red", "Violation:")} ${snapshot.violation.message}`,
|
|
352
|
+
);
|
|
353
|
+
if (snapshot.violation.snippet) {
|
|
354
|
+
(0, logger_1.log)(
|
|
355
|
+
` ${(0, logger_1.c)("yellow", "Code Snippet:")} ${snapshot.violation.snippet}`,
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
console.log();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function generateFromCase(projectRoot, rawArgs, quiet) {
|
|
362
|
+
const caseIdx = rawArgs.indexOf("--from-case");
|
|
363
|
+
const caseId = caseIdx !== -1 ? rawArgs[caseIdx + 1] : null;
|
|
364
|
+
|
|
365
|
+
if (!caseId) {
|
|
366
|
+
(0, logger_1.err)(
|
|
367
|
+
"Missing case ID. Usage: tk contract generate --from-case <id>",
|
|
368
|
+
);
|
|
369
|
+
process.exit(1);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const contractsDir = path.join(projectRoot, ".tribunal", "contracts");
|
|
373
|
+
if (!fs.existsSync(contractsDir)) {
|
|
374
|
+
fs.mkdirSync(contractsDir, { recursive: true });
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const contractFileName = `case-${caseId}-rule.yaml`;
|
|
378
|
+
const contractPath = path.join(contractsDir, contractFileName);
|
|
379
|
+
|
|
380
|
+
const content = `name: "Contract from Case #${caseId}"
|
|
381
|
+
description: "Auto-generated behavioral contract to prevent recurrence of Case #${caseId}"
|
|
382
|
+
scope: "src/**/*.ts, src/**/*.js"
|
|
383
|
+
when: file_modified
|
|
384
|
+
severity: block
|
|
385
|
+
must_not:
|
|
386
|
+
- pattern: "UNVERIFIED_API_PATTERN"
|
|
387
|
+
message: "Precedent Case #${caseId} violation prevented by contract"
|
|
388
|
+
metadata:
|
|
389
|
+
generated_from_case: "${caseId}"
|
|
390
|
+
created: "${new Date().toISOString().split("T")[0]}"
|
|
391
|
+
`;
|
|
392
|
+
|
|
393
|
+
fs.writeFileSync(contractPath, content, "utf8");
|
|
394
|
+
|
|
395
|
+
if (!quiet) {
|
|
396
|
+
console.log();
|
|
397
|
+
(0, logger_1.log)(
|
|
398
|
+
` ${(0, logger_1.c)("green", "✔")} Auto-generated contract template from Case #${caseId}:`,
|
|
399
|
+
);
|
|
400
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("cyan", contractPath)}`);
|
|
401
|
+
console.log();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function extractFileArg(argv) {
|
|
406
|
+
const idx = argv.indexOf("--file");
|
|
407
|
+
if (idx !== -1 && argv[idx + 1]) return argv[idx + 1];
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function showContractHelp(quiet) {
|
|
412
|
+
if (quiet) return;
|
|
413
|
+
console.log();
|
|
414
|
+
(0, logger_1.log)(
|
|
415
|
+
` ${(0, logger_1.bold)("Tribunal Behavioral Contract Engine (tk contract)")}`,
|
|
416
|
+
);
|
|
417
|
+
(0, logger_1.log)(` ${(0, logger_1.c)("gray", "─".repeat(50))}`);
|
|
418
|
+
(0, logger_1.log)(
|
|
419
|
+
` ${(0, logger_1.c)("cyan", "init")} Scaffold .tribunal/contracts/ with starter rules`,
|
|
420
|
+
);
|
|
421
|
+
(0, logger_1.log)(
|
|
422
|
+
` ${(0, logger_1.c)("cyan", "verify")} Verify code against loaded contracts`,
|
|
423
|
+
);
|
|
424
|
+
(0, logger_1.log)(
|
|
425
|
+
` ${(0, logger_1.c)("cyan", "verify --file <path>")} Verify a specific target file`,
|
|
426
|
+
);
|
|
427
|
+
(0, logger_1.log)(
|
|
428
|
+
` ${(0, logger_1.c)("cyan", "list")} List all active contracts`,
|
|
429
|
+
);
|
|
430
|
+
(0, logger_1.log)(
|
|
431
|
+
` ${(0, logger_1.c)("cyan", "trace list")} List recorded failure context snapshots`,
|
|
432
|
+
);
|
|
433
|
+
(0, logger_1.log)(
|
|
434
|
+
` ${(0, logger_1.c)("cyan", "replay <id>")} Replay failure context trace snapshot`,
|
|
435
|
+
);
|
|
436
|
+
(0, logger_1.log)(
|
|
437
|
+
` ${(0, logger_1.c)("cyan", "generate --from-case <id>")} Generate contract template from Case Law`,
|
|
438
|
+
);
|
|
439
|
+
console.log();
|
|
440
|
+
}
|
package/dist/commands/memory.js
CHANGED
|
@@ -43,8 +43,9 @@ function acquireLock(agentDest) {
|
|
|
43
43
|
if (err.code !== 'EEXIST') {
|
|
44
44
|
throw err;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// Non-blocking sleep — avoids busy-wait event loop blocking
|
|
47
|
+
const waitBuf = new Int32Array(new SharedArrayBuffer(4));
|
|
48
|
+
Atomics.wait(waitBuf, 0, 0, 50);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
try {
|
package/dist/commands/native.js
CHANGED
|
@@ -219,10 +219,46 @@ function cmdOptimizeStep(processArgs, quiet = false) {
|
|
|
219
219
|
console.log(JSON.stringify(result));
|
|
220
220
|
return true;
|
|
221
221
|
}
|
|
222
|
+
function cmdImpactTier(processArgs, quiet = false) {
|
|
223
|
+
const args = processArgs.slice(3);
|
|
224
|
+
const files = getOption(args, ["--files"]) || "";
|
|
225
|
+
const lines = parseInt(getOption(args, ["--lines"]) || "0", 10);
|
|
226
|
+
const task = getOption(args, ["--task"]) || "";
|
|
227
|
+
|
|
228
|
+
const fileList = files ? files.split(",").map(f => f.trim()).filter(Boolean) : [];
|
|
229
|
+
const fileCount = fileList.length;
|
|
230
|
+
|
|
231
|
+
// Tier classification heuristics (mirrors Rust ImpactTier logic)
|
|
232
|
+
let tier = 0;
|
|
233
|
+
if (fileCount === 0 && lines <= 5) tier = 0;
|
|
234
|
+
else if (fileCount <= 1 && lines <= 50) tier = 1;
|
|
235
|
+
else if (fileCount <= 5 && lines <= 200) tier = 2;
|
|
236
|
+
else tier = 3;
|
|
237
|
+
|
|
238
|
+
// Check for high-risk patterns that force Tier 3
|
|
239
|
+
const highRiskPatterns = /\b(auth|migration|schema|security|password|token|jwt|rbac|permissions)\b/i;
|
|
240
|
+
const highRiskExtensions = /\.(sql|prisma|tf|tofu)$/i;
|
|
241
|
+
if (highRiskPatterns.test(task) || fileList.some(f => highRiskExtensions.test(f))) {
|
|
242
|
+
tier = Math.max(tier, 3);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const tierNames = ["Fast-Pass", "Express Pass", "Targeted Audit", "Full Gauntlet"];
|
|
246
|
+
const result = {
|
|
247
|
+
tier,
|
|
248
|
+
tier_name: tierNames[tier],
|
|
249
|
+
file_count: fileCount,
|
|
250
|
+
line_count: lines,
|
|
251
|
+
socratic_gate: tier >= 3 ? "required" : tier >= 2 ? "conditional" : "bypass",
|
|
252
|
+
};
|
|
253
|
+
if (!quiet) console.error(`✓ Impact Tier: ${tier} (${tierNames[tier]})`);
|
|
254
|
+
console.log(JSON.stringify(result));
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
222
257
|
|
|
223
258
|
module.exports = {
|
|
224
259
|
cmdMinContext,
|
|
225
260
|
cmdDagSchedule,
|
|
226
261
|
cmdContextCompress,
|
|
227
262
|
cmdOptimizeStep,
|
|
263
|
+
cmdImpactTier,
|
|
228
264
|
};
|
package/dist/commands/status.js
CHANGED
|
@@ -31,5 +31,11 @@ function cmdStatus(flags, quiet = false) {
|
|
|
31
31
|
(0, logger_1.log)(` ${icons[sub]} ${(0, logger_1.c)(colors[sub], sub.padEnd(12))}${(0, logger_1.c)('white', String(count).padStart(3))} files`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
const contractsPath = path_1.default.join(targetDir, '.tribunal', 'contracts');
|
|
36
|
+
if (fs_1.default.existsSync(contractsPath)) {
|
|
37
|
+
const contractFiles = fs_1.default.readdirSync(contractsPath).filter(f => f.endsWith('.yaml') || f.endsWith('.yml')).length;
|
|
38
|
+
(0, logger_1.log)(` 📜 ${(0, logger_1.c)('cyan', 'contracts'.padEnd(12))}${(0, logger_1.c)('white', String(contractFiles).padStart(3))} active rules`);
|
|
39
|
+
}
|
|
34
40
|
console.log();
|
|
35
41
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -108,3 +108,35 @@ export function cmdUninstall(flags, quiet) {
|
|
|
108
108
|
export async function generateIDEBridges(cwd, agentDest, quiet) {
|
|
109
109
|
return loadCommand('../commands/init.js', 'generateIDEBridges', cwd, agentDest, quiet);
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
export async function cmdGuardrail(flags, argv, quiet) {
|
|
113
|
+
return loadCommand('../commands/guardrail.js', 'cmdGuardrail', flags, argv, quiet);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function cmdOptimizeSkill(flags, argv, quiet) {
|
|
117
|
+
return loadCommand('../commands/optimize.js', 'cmdOptimizeSkill', flags, argv, quiet);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function cmdMinimal(flags, quiet) {
|
|
121
|
+
return loadCommand('../commands/minimal.js', 'cmdMinimal', flags, quiet);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function cmdValidate(flags, argv, quiet) {
|
|
125
|
+
return loadCommand('../commands/validate.js', 'cmdValidate', flags, argv, quiet);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function cmdMinContext(argv, quiet) {
|
|
129
|
+
return loadCommand('../commands/native.js', 'cmdMinContext', argv, quiet);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function cmdDagSchedule(argv, quiet) {
|
|
133
|
+
return loadCommand('../commands/native.js', 'cmdDagSchedule', argv, quiet);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function cmdContextCompress(argv, quiet) {
|
|
137
|
+
return loadCommand('../commands/native.js', 'cmdContextCompress', argv, quiet);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function cmdOptimizeStep(argv, quiet) {
|
|
141
|
+
return loadCommand('../commands/native.js', 'cmdOptimizeStep', argv, quiet);
|
|
142
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -37,8 +37,8 @@ export interface CliFlags {
|
|
|
37
37
|
log?: string;
|
|
38
38
|
/** Memory mutation strategy: 'balanced' | 'harden' | 'repair-only'. */
|
|
39
39
|
strategy?: string;
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/** Install profile: 'full' | 'minimal' | 'web' | 'mobile' | 'backend' | 'ai'. */
|
|
41
|
+
profile?: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/** Parsed CLI arguments returned by the internal arg parser. */
|
|
@@ -145,6 +145,60 @@ export function cmdUninstall(flags: CliFlags, quiet?: boolean): void;
|
|
|
145
145
|
*/
|
|
146
146
|
export function generateIDEBridges(cwd: string, agentDest: string, quiet?: boolean): Promise<void>;
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Validate `.agent/` integrity (phantom refs, count mismatches, drift).
|
|
150
|
+
* Equivalent to `npx tribunal-kit guardrail`.
|
|
151
|
+
*/
|
|
152
|
+
export function cmdGuardrail(flags: CliFlags, argv: string[], quiet?: boolean): Promise<void>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* AI Agent Behavioral Contract Testing (init, verify, list, trace, replay).
|
|
156
|
+
* Equivalent to `npx tribunal-kit contract`.
|
|
157
|
+
*/
|
|
158
|
+
export function cmdContract(flags: CliFlags, argv: string[], quiet?: boolean): Promise<void>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Optimize project skills using SkillOpt validation gates.
|
|
162
|
+
* Equivalent to `npx tribunal-kit optimize-skill`.
|
|
163
|
+
*/
|
|
164
|
+
export function cmdOptimizeSkill(flags: CliFlags, argv: string[], quiet?: boolean): Promise<void>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Show minimal change analysis for the current project.
|
|
168
|
+
* Equivalent to `npx tribunal-kit minimal`.
|
|
169
|
+
*/
|
|
170
|
+
export function cmdMinimal(flags: CliFlags, quiet?: boolean): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Validate a JSON payload against a Tribunal schema.
|
|
174
|
+
* Equivalent to `npx tribunal-kit validate`.
|
|
175
|
+
*/
|
|
176
|
+
export function cmdValidate(flags: CliFlags, argv: string[], quiet?: boolean): void;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Remove empty lines from a context file.
|
|
180
|
+
* Equivalent to `npx tribunal-kit min-context`.
|
|
181
|
+
*/
|
|
182
|
+
export function cmdMinContext(argv: string[], quiet?: boolean): void;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Compute parallel execution waves from task dependencies.
|
|
186
|
+
* Equivalent to `npx tribunal-kit dag-schedule`.
|
|
187
|
+
*/
|
|
188
|
+
export function cmdDagSchedule(argv: string[], quiet?: boolean): void;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Compress a context file while retaining VERIFY comments.
|
|
192
|
+
* Equivalent to `npx tribunal-kit context-compress`.
|
|
193
|
+
*/
|
|
194
|
+
export function cmdContextCompress(argv: string[], quiet?: boolean): void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Apply bounded SkillOpt edits from a JSON payload.
|
|
198
|
+
* Equivalent to `npx tribunal-kit optimize-step`.
|
|
199
|
+
*/
|
|
200
|
+
export function cmdOptimizeStep(argv: string[], quiet?: boolean): void;
|
|
201
|
+
|
|
148
202
|
// ── Logger Utilities ─────────────────────────────────────────────────────────
|
|
149
203
|
|
|
150
204
|
/** ANSI color code map. */
|
|
@@ -277,7 +331,8 @@ export type McpToolName =
|
|
|
277
331
|
| 'recall_memory'
|
|
278
332
|
| 'store_memory'
|
|
279
333
|
| 'get_sparse_context'
|
|
280
|
-
| 'align_output'
|
|
334
|
+
| 'align_output'
|
|
335
|
+
| 'verify_contracts';
|
|
281
336
|
|
|
282
337
|
// ── Main Entry Point ─────────────────────────────────────────────────────────
|
|
283
338
|
|