tribunal-kit 5.8.5 → 6.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/ARCHITECTURE.md +219 -215
- package/.agent/agents/accessibility-reviewer.md +66 -151
- package/.agent/agents/ai-code-reviewer.md +22 -2
- package/.agent/agents/anti-pattern-reviewer.md +99 -0
- package/.agent/agents/api-architect.md +19 -2
- package/.agent/agents/backend-specialist.md +25 -3
- package/.agent/agents/cloud-engineer.md +21 -0
- package/.agent/agents/code-archaeologist.md +20 -3
- package/.agent/agents/complexity-reviewer.md +22 -2
- package/.agent/agents/database-architect.md +24 -3
- package/.agent/agents/db-latency-auditor.md +22 -2
- package/.agent/agents/debugger.md +19 -3
- package/.agent/agents/dependency-reviewer.md +19 -2
- package/.agent/agents/devops-engineer.md +24 -3
- package/.agent/agents/documentation-writer.md +21 -3
- package/.agent/agents/explorer-agent.md +21 -3
- package/.agent/agents/frontend-reviewer.md +19 -3
- package/.agent/agents/frontend-specialist.md +72 -224
- package/.agent/agents/game-developer.md +22 -3
- package/.agent/agents/interaction-reviewer.md +118 -0
- package/.agent/agents/logic-reviewer.md +18 -3
- package/.agent/agents/minimalist-reviewer.md +98 -0
- package/.agent/agents/mobile-developer.md +21 -3
- package/.agent/agents/mobile-reviewer.md +22 -2
- package/.agent/agents/orchestrator.md +19 -3
- package/.agent/agents/penetration-tester.md +22 -3
- package/.agent/agents/performance-optimizer.md +21 -3
- package/.agent/agents/performance-reviewer.md +2 -0
- package/.agent/agents/precedence-reviewer.md +19 -5
- package/.agent/agents/product-manager.md +20 -3
- package/.agent/agents/product-owner.md +22 -1
- package/.agent/agents/product-reviewer.md +98 -0
- package/.agent/agents/project-planner.md +19 -3
- package/.agent/agents/qa-automation-engineer.md +24 -3
- package/.agent/agents/resilience-reviewer.md +21 -2
- package/.agent/agents/schema-reviewer.md +21 -2
- package/.agent/agents/security-auditor.md +7 -1
- package/.agent/agents/seo-specialist.md +18 -3
- package/.agent/agents/sql-reviewer.md +22 -2
- package/.agent/agents/supervisor-agent.md +22 -3
- package/.agent/agents/swarm-worker-registry.md +7 -0
- package/.agent/agents/system-architect.md +19 -0
- package/.agent/agents/test-coverage-reviewer.md +22 -2
- package/.agent/agents/test-engineer.md +21 -2
- package/.agent/agents/throughput-optimizer.md +22 -2
- package/.agent/agents/type-safety-reviewer.md +21 -2
- package/.agent/agents/ui-ux-auditor.md +44 -242
- package/.agent/agents/ui-visual-auditor.md +99 -0
- package/.agent/agents/ux-reviewer.md +104 -0
- package/.agent/agents/visual-reviewer.md +98 -0
- package/.agent/agents/vitals-reviewer.md +23 -2
- package/.agent/history/README.md +53 -0
- package/.agent/history/case-law/cases/template-case.json +19 -0
- package/.agent/history/integrity_manifest.json +63 -33
- package/.agent/history/memory/.memory.idx +517 -1
- package/.agent/history/memory/MEMORY.md +35 -1
- package/.agent/routing_index.json +272 -690
- package/.agent/rules/GEMINI.md +10 -12
- package/.agent/rules/GEMINI_PLANNER.md +84 -0
- package/.agent/scripts/case_law_manager.js +2 -0
- package/.agent/scripts/context_broker.js +152 -0
- package/.agent/scripts/guardrail_engine.js +59 -4
- package/.agent/scripts/impact_classifier.js +167 -0
- package/.agent/scripts/minimal_change_engine.js +437 -0
- package/.agent/scripts/pipeline_engine.js +856 -0
- package/.agent/scripts/socratic_gate_policy.js +60 -0
- package/.agent/scripts/token_budget_broker.js +52 -0
- package/.agent/scripts/verify_all.js +13 -0
- package/.agent/scripts/visual_audit.js +92 -0
- package/.agent/skills/12-principles-of-animation/SKILL.md +19 -10
- package/.agent/skills/60fps-animation/SKILL.md +19 -10
- package/.agent/skills/accessible-animation/SKILL.md +19 -10
- package/.agent/skills/adapt/SKILL.md +19 -10
- package/.agent/skills/advanced-rag-pipelines/SKILL.md +21 -3
- package/.agent/skills/agent-organizer/SKILL.md +21 -7
- package/.agent/skills/agentic-patterns/SKILL.md +19 -7
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +21 -7
- package/.agent/skills/animation-on-scroll/SKILL.md +19 -10
- package/.agent/skills/animation-systems/SKILL.md +19 -10
- package/.agent/skills/antfu-conventions/SKILL.md +21 -10
- package/.agent/skills/api-patterns/SKILL.md +21 -7
- package/.agent/skills/api-security-auditor/SKILL.md +21 -7
- package/.agent/skills/app-builder/SKILL.md +21 -7
- package/.agent/skills/apple-design/SKILL.md +19 -10
- package/.agent/skills/architecture/SKILL.md +21 -7
- package/.agent/skills/audit-and-fix/SKILL.md +19 -10
- package/.agent/skills/authentication-best-practices/SKILL.md +21 -7
- package/.agent/skills/backend-security-expert/SKILL.md +21 -7
- package/.agent/skills/baseline-ui/SKILL.md +19 -10
- package/.agent/skills/bash-linux/SKILL.md +21 -7
- package/.agent/skills/behavioral-modes/SKILL.md +19 -7
- package/.agent/skills/better-colors/SKILL.md +19 -10
- package/.agent/skills/better-ui/SKILL.md +19 -10
- package/.agent/skills/bolder/SKILL.md +19 -10
- package/.agent/skills/brainstorming/SKILL.md +17 -7
- package/.agent/skills/browser-native-ai/SKILL.md +19 -3
- package/.agent/skills/build-primitive/SKILL.md +19 -10
- package/.agent/skills/building-native-ui/SKILL.md +21 -7
- package/.agent/skills/cicd-pro/SKILL.md +21 -10
- package/.agent/skills/clarify/SKILL.md +19 -10
- package/.agent/skills/clean-code/SKILL.md +21 -7
- package/.agent/skills/cloud-architect/SKILL.md +21 -10
- package/.agent/skills/cobejs/SKILL.md +19 -10
- package/.agent/skills/code-review-checklist/SKILL.md +21 -7
- package/.agent/skills/codebase-design/SKILL.md +21 -10
- package/.agent/skills/colorize/SKILL.md +19 -10
- package/.agent/skills/compact-landing/SKILL.md +19 -10
- package/.agent/skills/company-logos/SKILL.md +19 -10
- package/.agent/skills/config-validator/SKILL.md +21 -7
- package/.agent/skills/containerization-pro/SKILL.md +21 -10
- package/.agent/skills/create-design-md/SKILL.md +19 -10
- package/.agent/skills/critique/SKILL.md +19 -10
- package/.agent/skills/csharp-developer/SKILL.md +21 -7
- package/.agent/skills/data-validation-schemas/SKILL.md +21 -7
- package/.agent/skills/database-design/SKILL.md +21 -7
- package/.agent/skills/delight/SKILL.md +19 -10
- package/.agent/skills/deployment-procedures/SKILL.md +21 -7
- package/.agent/skills/design-lab/SKILL.md +21 -10
- package/.agent/skills/devops-engineer/SKILL.md +21 -7
- package/.agent/skills/devops-incident-responder/SKILL.md +21 -7
- package/.agent/skills/diagnosing-bugs/SKILL.md +21 -10
- package/.agent/skills/distill/SKILL.md +19 -10
- package/.agent/skills/documentation-templates/SKILL.md +21 -7
- package/.agent/skills/domain-modeling/SKILL.md +21 -10
- package/.agent/skills/edge-computing/SKILL.md +21 -7
- package/.agent/skills/emil-design-eng/SKILL.md +19 -10
- package/.agent/skills/error-resilience/SKILL.md +21 -7
- package/.agent/skills/extract-design-system/SKILL.md +21 -7
- package/.agent/skills/fabel-protocol/SKILL.md +19 -2
- package/.agent/skills/fixing-accessibility/SKILL.md +19 -10
- package/.agent/skills/fixing-metadata/SKILL.md +19 -10
- package/.agent/skills/fixing-motion-performance/SKILL.md +19 -10
- package/.agent/skills/framer-motion-expert/SKILL.md +19 -6
- package/.agent/skills/frontend-design/SKILL.md +64 -201
- package/.agent/skills/frontend-security-expert/SKILL.md +21 -7
- package/.agent/skills/game-design-expert/SKILL.md +21 -7
- package/.agent/skills/game-engineering-expert/SKILL.md +21 -7
- package/.agent/skills/generative-ui-expert/SKILL.md +19 -3
- package/.agent/skills/geo-fundamentals/SKILL.md +21 -7
- package/.agent/skills/git-pro/SKILL.md +21 -10
- package/.agent/skills/github-operations/SKILL.md +21 -7
- package/.agent/skills/gpt-taste/SKILL.md +19 -10
- package/.agent/skills/gsap-core/SKILL.md +21 -4
- package/.agent/skills/gsap-frameworks/SKILL.md +21 -4
- package/.agent/skills/gsap-performance/SKILL.md +20 -5
- package/.agent/skills/gsap-plugins/SKILL.md +20 -5
- package/.agent/skills/gsap-react/SKILL.md +20 -5
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +21 -4
- package/.agent/skills/gsap-timeline/SKILL.md +20 -5
- package/.agent/skills/gsap-utils/SKILL.md +20 -5
- package/.agent/skills/harden/SKILL.md +19 -10
- package/.agent/skills/harness-protocol/SKILL.md +20 -4
- package/.agent/skills/i18n-localization/SKILL.md +21 -7
- package/.agent/skills/impeccable/SKILL.md +19 -10
- package/.agent/skills/improve-codebase-architecture/SKILL.md +21 -10
- package/.agent/skills/improve-ui/SKILL.md +19 -10
- package/.agent/skills/intelligent-routing/SKILL.md +19 -7
- package/.agent/skills/knowledge-graph/SKILL.md +20 -4
- package/.agent/skills/landing-page/SKILL.md +20 -10
- package/.agent/skills/lint-and-validate/SKILL.md +21 -7
- package/.agent/skills/llm-engineering/SKILL.md +21 -7
- package/.agent/skills/local-first/SKILL.md +21 -7
- package/.agent/skills/local-first-architecture/SKILL.md +19 -10
- package/.agent/skills/lottie-animation/SKILL.md +19 -10
- package/.agent/skills/marquee-loop/SKILL.md +19 -10
- package/.agent/skills/masked-reveal/SKILL.md +19 -10
- package/.agent/skills/mcp-builder/SKILL.md +21 -7
- package/.agent/skills/micro-interaction/SKILL.md +19 -10
- package/.agent/skills/mobile-design/SKILL.md +21 -6
- package/.agent/skills/monorepo-management/SKILL.md +21 -7
- package/.agent/skills/morphing-icons/SKILL.md +19 -10
- package/.agent/skills/motion-engineering/SKILL.md +20 -7
- package/.agent/skills/nextjs-react-expert/SKILL.md +19 -7
- package/.agent/skills/nodejs-best-practices/SKILL.md +21 -7
- package/.agent/skills/observability/SKILL.md +21 -7
- package/.agent/skills/page-transition-animation/SKILL.md +19 -10
- package/.agent/skills/parallel-agents/SKILL.md +23 -7
- package/.agent/skills/performance-profiling/SKILL.md +21 -7
- package/.agent/skills/plan-writing/SKILL.md +21 -7
- package/.agent/skills/platform-engineer/SKILL.md +21 -7
- package/.agent/skills/playwright-best-practices/SKILL.md +21 -7
- package/.agent/skills/polish/SKILL.md +19 -10
- package/.agent/skills/powershell-windows/SKILL.md +21 -7
- package/.agent/skills/pricing-page/SKILL.md +19 -10
- package/.agent/skills/product-aware-heuristics/SKILL.md +358 -0
- package/.agent/skills/progressive-blur/SKILL.md +19 -10
- package/.agent/skills/project-idioms/SKILL.md +20 -8
- package/.agent/skills/python-patterns/SKILL.md +21 -7
- package/.agent/skills/python-pro/SKILL.md +21 -6
- package/.agent/skills/quieter/SKILL.md +19 -10
- package/.agent/skills/react-doctor/SKILL.md +19 -10
- package/.agent/skills/react-specialist/SKILL.md +19 -6
- package/.agent/skills/readme-builder/SKILL.md +21 -7
- package/.agent/skills/realtime-patterns/SKILL.md +21 -7
- package/.agent/skills/red-team-tactics/SKILL.md +21 -7
- package/.agent/skills/redesign-skill/SKILL.md +19 -10
- package/.agent/skills/review-animations/SKILL.md +21 -10
- package/.agent/skills/rust-pro/SKILL.md +21 -7
- package/.agent/skills/seo-fundamentals/SKILL.md +21 -7
- package/.agent/skills/server-management/SKILL.md +21 -7
- package/.agent/skills/shadcn-ui-expert/SKILL.md +21 -7
- package/.agent/skills/shape/SKILL.md +19 -10
- package/.agent/skills/skill-creator/SKILL.md +21 -7
- package/.agent/skills/soft-skill/SKILL.md +19 -10
- package/.agent/skills/sounds-on-the-web/SKILL.md +19 -10
- package/.agent/skills/sql-pro/SKILL.md +21 -7
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +21 -7
- package/.agent/skills/svg-animation/SKILL.md +19 -10
- package/.agent/skills/swiftui-expert/SKILL.md +21 -7
- package/.agent/skills/swiss-design/SKILL.md +19 -10
- package/.agent/skills/system-design-pro/SKILL.md +21 -9
- package/.agent/skills/systematic-debugging/SKILL.md +21 -7
- package/.agent/skills/tailwind-patterns/SKILL.md +21 -7
- package/.agent/skills/taste-skill/SKILL.md +19 -10
- package/.agent/skills/tdd-workflow/SKILL.md +21 -10
- package/.agent/skills/test-result-analyzer/SKILL.md +18 -6
- package/.agent/skills/testing-patterns/SKILL.md +21 -7
- package/.agent/skills/thermo-nuclear-code-quality-review/SKILL.md +21 -10
- package/.agent/skills/thinking-protocol/SKILL.md +20 -8
- package/.agent/skills/to-spring-or-not-to-spring/SKILL.md +19 -10
- package/.agent/skills/transitions-dev/SKILL.md +19 -10
- package/.agent/skills/trend-researcher/SKILL.md +17 -6
- package/.agent/skills/typescript-advanced/SKILL.md +21 -7
- package/.agent/skills/typeset/SKILL.md +19 -10
- package/.agent/skills/ui-reasoning-engine/SKILL.md +154 -0
- package/.agent/skills/ui-skill-packs/SKILL.md +77 -0
- package/.agent/skills/ui-skills-root/SKILL.md +21 -9
- package/.agent/skills/ui-ux-pro-max/SKILL.md +62 -583
- package/.agent/skills/ui-ux-researcher/SKILL.md +17 -6
- package/.agent/skills/vue-expert/SKILL.md +19 -6
- package/.agent/skills/vulnerability-scanner/SKILL.md +21 -7
- package/.agent/skills/web-accessibility-auditor/SKILL.md +21 -7
- package/.agent/skills/web-design-guidelines/SKILL.md +32 -206
- package/.agent/skills/web-quality-audit/SKILL.md +19 -10
- package/.agent/skills/webapp-testing/SKILL.md +21 -7
- package/.agent/skills/webgpu-performance/SKILL.md +19 -3
- package/.agent/skills/whimsy-injector/SKILL.md +20 -10
- package/.agent/skills/workflow-optimizer/SKILL.md +16 -6
- package/.agent/templates/DESIGN.md +292 -0
- package/.agent/templates/design-tokens.json +137 -0
- package/.agent/workflows/acf.md +13 -6
- package/.agent/workflows/api-tester.md +15 -8
- package/.agent/workflows/audit.md +19 -8
- package/.agent/workflows/brainstorm.md +14 -9
- package/.agent/workflows/changelog.md +14 -8
- package/.agent/workflows/create.md +16 -8
- package/.agent/workflows/debug.md +15 -10
- package/.agent/workflows/deploy.md +16 -8
- package/.agent/workflows/enhance.md +15 -10
- package/.agent/workflows/fix.md +15 -8
- package/.agent/workflows/generate.md +17 -11
- package/.agent/workflows/marathon.md +15 -8
- package/.agent/workflows/migrate.md +16 -8
- package/.agent/workflows/minimal.md +94 -0
- package/.agent/workflows/orchestrate.md +15 -8
- package/.agent/workflows/performance-benchmarker.md +15 -8
- package/.agent/workflows/pipeline.md +155 -0
- package/.agent/workflows/plan.md +14 -10
- package/.agent/workflows/preview.md +14 -7
- package/.agent/workflows/refactor.md +16 -8
- package/.agent/workflows/review-ai.md +15 -7
- package/.agent/workflows/review.md +15 -7
- package/.agent/workflows/session.md +14 -7
- package/.agent/workflows/status.md +13 -7
- package/.agent/workflows/strengthen-skills.md +15 -6
- package/.agent/workflows/super-prompt.md +19 -10
- package/.agent/workflows/swarm.md +15 -7
- package/.agent/workflows/test.md +15 -8
- package/.agent/workflows/tribunal-backend.md +16 -9
- package/.agent/workflows/tribunal-database.md +15 -8
- package/.agent/workflows/tribunal-frontend.md +26 -11
- package/.agent/workflows/tribunal-full.md +29 -14
- package/.agent/workflows/tribunal-mobile.md +15 -8
- package/.agent/workflows/tribunal-performance.md +15 -8
- package/.agent/workflows/tribunal-speed.md +16 -9
- package/.agent/workflows/tribunal-ui.md +82 -0
- package/.agent/workflows/ui-ux-pro-max.md +51 -107
- package/CONTRIBUTING.md +2 -2
- package/README.md +5 -5
- package/bin/mcp-server.js +81 -31
- package/bin/wrapper.js +17 -6
- package/dist/cli.js +9 -1
- package/dist/commands/compile.js +7 -0
- package/dist/commands/context.js +8 -3
- package/dist/commands/graph.js +8 -2
- package/dist/commands/init.js +13 -2
- package/dist/commands/memory.js +119 -68
- package/dist/commands/minimal.js +71 -0
- package/dist/commands/optimize.js +15 -5
- package/dist/esm/index.mjs +26 -32
- package/dist/utils/fs.js +10 -4
- package/dist/utils/helpers.js +10 -1
- package/dist/utils/version.js +9 -2
- package/mcp_config.json +10 -1
- package/package.json +17 -14
- package/scripts/benchmark.js +16 -0
- package/scripts/sync-version.js +1 -1
- package/scripts/visual_audit.js +126 -0
package/.agent/rules/GEMINI.md
CHANGED
|
@@ -135,25 +135,23 @@ Did I load the agent's required skills? → If no: check frontmatter skills: fi
|
|
|
135
135
|
|
|
136
136
|
---
|
|
137
137
|
|
|
138
|
-
## Step 3 — Socratic Gate (
|
|
138
|
+
## Step 3 — Socratic Gate (Adaptive Governance Policy)
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
The Socratic Gate is **adaptive** based on the task's **Impact Tier** evaluated by `impact_classifier.js`:
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
| Vague request | 1 question about the core goal, then infer the rest |
|
|
149
|
-
| Full orchestration | Block all subagents until plan is confirmed |
|
|
142
|
+
| Impact Tier | Scope | Socratic Gate Policy |
|
|
143
|
+
| ----------- | ----- | --------------------- |
|
|
144
|
+
| **Tier 0 (Fast-Pass)** | Typo, CSS, markdown, formatting | **BYPASS** — 0 questions, 0 LLM calls |
|
|
145
|
+
| **Tier 1 (Express Pass)** | Single-file component or function logic edit | **BYPASS** — 0 questions, single specialist pass |
|
|
146
|
+
| **Tier 2 (Targeted Audit)** | Multi-file feature edit | **CONDITIONAL** — Ask 1 question ONLY if ambiguity score > 0.5 |
|
|
147
|
+
| **Tier 3 (Full Gauntlet)** | Auth, schema, migration, breaking architectural changes | **REQUIRED** — 1-2 targeted questions before execution (bypassable via `--no-gate` / `--express`) |
|
|
150
148
|
|
|
151
149
|
**Rules:**
|
|
152
150
|
|
|
153
151
|
- Ask only what you cannot infer from context. Check the conversation first.
|
|
154
152
|
- Max 2 questions per response. If you need more, prioritize the most blocking one.
|
|
155
153
|
- Never ask what the user already told you. Never ask generic "what stack?" if the repo shows it.
|
|
156
|
-
-
|
|
154
|
+
- Bypass gate automatically on Tier 0 and Tier 1 tasks to preserve rapid developer flow.
|
|
157
155
|
|
|
158
156
|
---
|
|
159
157
|
|
|
@@ -222,7 +220,7 @@ The Human Gate is never skipped. No code is written to a file without explicit u
|
|
|
222
220
|
| Database/SQL | logic + security + sql + schema + complexity-reviewer |
|
|
223
221
|
| Mobile/Cross-platform | logic + security + mobile-reviewer + type-safety + complexity-reviewer |
|
|
224
222
|
| Any domain | + performance (if optimization) |
|
|
225
|
-
| Before merge | /tribunal-full (all
|
|
223
|
+
| Before merge | /tribunal-full (all 27 reviewers) |
|
|
226
224
|
|
|
227
225
|
---
|
|
228
226
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: pipeline_only
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Tribunal Planner Rules — Condensed
|
|
6
|
+
|
|
7
|
+
Minimal rules for Pass 1 (Planning) of the Hybrid Pipeline.
|
|
8
|
+
These are the ONLY rules active during the planning phase.
|
|
9
|
+
Full rules (GEMINI.md) are NOT loaded — this saves ~4,800 tokens.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Task Classification
|
|
14
|
+
|
|
15
|
+
| Type | Signals | Output |
|
|
16
|
+
| -------------- | -------------------------------------------------- | ------------------- |
|
|
17
|
+
| Question | "what is", "how does", "explain" | Text only — no code |
|
|
18
|
+
| Simple edit | "fix", "change", "update" (single file) | Direct edit |
|
|
19
|
+
| Complex build | "build", "create", "implement", "design" | Structured spec |
|
|
20
|
+
| Refactor | "refactor", "clean", "extract", "split" | Structured spec |
|
|
21
|
+
| Test | "test", "spec", "e2e" | Test spec |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Stack Detection
|
|
26
|
+
|
|
27
|
+
| Keywords | Stack |
|
|
28
|
+
| ------------------------------------------- | -------------- |
|
|
29
|
+
| react, jsx, tsx, component, hook | react |
|
|
30
|
+
| next, nextjs, server component | nextjs |
|
|
31
|
+
| vue, nuxt, composition api | vue |
|
|
32
|
+
| typescript, interface, generic | typescript |
|
|
33
|
+
| python, fastapi, django, flask | python |
|
|
34
|
+
| express, hono, koa, node | node |
|
|
35
|
+
| sql, postgres, prisma, drizzle | sql |
|
|
36
|
+
| rust, cargo, tokio, axum | rust |
|
|
37
|
+
| css, tailwind, responsive | css |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Skill Selection Rules
|
|
42
|
+
|
|
43
|
+
1. Match task keywords against skill descriptions
|
|
44
|
+
2. Match file extensions against stack affinities
|
|
45
|
+
3. Select TOP 3 skills by relevance score
|
|
46
|
+
4. Never load more than 3 skills for a single pass
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Output: Structured Spec Schema
|
|
51
|
+
|
|
52
|
+
The planner MUST output a JSON object matching this schema:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"task_type": "frontend_component | api_endpoint | database_query | auth_flow | test_suite | refactor | animation | general",
|
|
57
|
+
"stack": ["react", "typescript", "css"],
|
|
58
|
+
"target_file": "path/to/file.tsx",
|
|
59
|
+
"essential_skills": [
|
|
60
|
+
{ "name": "skill-name", "score": 5.0 }
|
|
61
|
+
],
|
|
62
|
+
"constraints": {
|
|
63
|
+
"accessibility": true,
|
|
64
|
+
"responsive": true,
|
|
65
|
+
"dark_mode": false,
|
|
66
|
+
"animation": false,
|
|
67
|
+
"tests_required": false,
|
|
68
|
+
"type_safe": true
|
|
69
|
+
},
|
|
70
|
+
"spec": "Original user task description"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Planner Anti-Patterns
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
❌ Do not load full GEMINI.md — use this condensed file only
|
|
80
|
+
❌ Do not load agent persona .md files — those are for generation, not planning
|
|
81
|
+
❌ Do not generate code in the planning phase — output spec JSON only
|
|
82
|
+
❌ Do not select more than 3 essential skills
|
|
83
|
+
❌ Do not include tribunal review rules — those run in Pass 3 (validator)
|
|
84
|
+
```
|
|
@@ -58,6 +58,7 @@ const VALID_DOMAINS = new Set([
|
|
|
58
58
|
"mobile",
|
|
59
59
|
"testing",
|
|
60
60
|
"devops",
|
|
61
|
+
"minimal_change",
|
|
61
62
|
"general",
|
|
62
63
|
]);
|
|
63
64
|
const VALID_VERDICTS = new Set([
|
|
@@ -65,6 +66,7 @@ const VALID_VERDICTS = new Set([
|
|
|
65
66
|
"APPROVED_WITH_CONDITIONS",
|
|
66
67
|
"PRECEDENT_SET",
|
|
67
68
|
"OVERRULED",
|
|
69
|
+
"MINIMALITY_REJECTED",
|
|
68
70
|
]);
|
|
69
71
|
|
|
70
72
|
// ── Noise filter ────────────────────────────────────────────────────────────
|
|
@@ -49,11 +49,43 @@
|
|
|
49
49
|
|
|
50
50
|
const fs = require("fs");
|
|
51
51
|
const path = require("path");
|
|
52
|
+
const { execFileSync } = require("child_process");
|
|
52
53
|
|
|
53
54
|
// ── Colours & Shared Utilities ────────────────────────────────────────────────
|
|
54
55
|
const { GREEN, YELLOW, CYAN, RED, BOLD, DIM, RESET } = require("./_colors");
|
|
55
56
|
const { findAgentDir } = require("./_utils");
|
|
56
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Attempt native Rust context resolution for sub-15ms execution
|
|
60
|
+
*/
|
|
61
|
+
function tryNativeContextBroker(repoPath, targetFile) {
|
|
62
|
+
if (process.env.TK_DISABLE_RUST === "1") return null;
|
|
63
|
+
|
|
64
|
+
const candidates = [
|
|
65
|
+
path.join(__dirname, "../../target/release/tribunal-core.exe"),
|
|
66
|
+
path.join(__dirname, "../../target/release/tribunal-core"),
|
|
67
|
+
path.join(__dirname, "../../target/debug/tribunal-core.exe"),
|
|
68
|
+
path.join(__dirname, "../../target/debug/tribunal-core"),
|
|
69
|
+
"tribunal-core"
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
for (const bin of candidates) {
|
|
73
|
+
try {
|
|
74
|
+
if (bin.includes(path.sep) && !fs.existsSync(bin)) continue;
|
|
75
|
+
const args = ["context-broker", "--repo-path", repoPath];
|
|
76
|
+
if (targetFile) args.push("--target-file", targetFile);
|
|
77
|
+
const out = execFileSync(bin, args, { encoding: "utf8", timeout: 2000, stdio: ["ignore", "pipe", "ignore"] });
|
|
78
|
+
if (out && out.trim().startsWith("{")) {
|
|
79
|
+
return JSON.parse(out);
|
|
80
|
+
}
|
|
81
|
+
} catch (_) {
|
|
82
|
+
// Continue to next candidate or fallback
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
57
89
|
|
|
58
90
|
// ── Domain → Skill affinity map ───────────────────────────────────────────────
|
|
59
91
|
// Keywords in the user's task that strongly indicate specific skills.
|
|
@@ -812,13 +844,119 @@ function broker(task, files = [], model = "large", agentDir = null) {
|
|
|
812
844
|
return { ...selection, promptText };
|
|
813
845
|
}
|
|
814
846
|
|
|
847
|
+
/**
|
|
848
|
+
* Pipeline-specific broker for the 3-pass hybrid architecture.
|
|
849
|
+
* Returns context tailored to each pipeline phase:
|
|
850
|
+
* - "plan": Skill names + descriptions only (for task classification)
|
|
851
|
+
* - "build": Top 2-3 essential skills' keyRules only (for code generation)
|
|
852
|
+
* - "validate": Validator configuration (which patterns to check)
|
|
853
|
+
*
|
|
854
|
+
* @param {string} task - User task description
|
|
855
|
+
* @param {string[]} files - Files being touched
|
|
856
|
+
* @param {string} phase - 'plan' | 'build' | 'validate'
|
|
857
|
+
* @param {string} agentDir - Path to .agent/ directory
|
|
858
|
+
* @returns {object} Phase-specific context
|
|
859
|
+
*/
|
|
860
|
+
function brokerForPipeline(task, files = [], phase = "build", agentDir = null) {
|
|
861
|
+
const resolvedAgentDir = agentDir || findAgentDir();
|
|
862
|
+
const skills = loadSkills(resolvedAgentDir);
|
|
863
|
+
// Always use "small" model tier for aggressive pruning in pipeline mode
|
|
864
|
+
const selection = selectSkills(task, files, "small", skills);
|
|
865
|
+
|
|
866
|
+
if (phase === "plan") {
|
|
867
|
+
// Plan phase: skill names and descriptions only — no content, no keyRules
|
|
868
|
+
return {
|
|
869
|
+
phase: "plan",
|
|
870
|
+
skills: selection.essential.slice(0, 6).map(s => ({
|
|
871
|
+
name: s.name,
|
|
872
|
+
description: s.description,
|
|
873
|
+
score: selection.scores.get(s.name) || 0,
|
|
874
|
+
})),
|
|
875
|
+
total_matched: selection.essential.length + selection.available.length,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (phase === "build") {
|
|
880
|
+
// Build phase: top 3 essential keyRules — maximum density, minimum tokens
|
|
881
|
+
return {
|
|
882
|
+
phase: "build",
|
|
883
|
+
skills: selection.essential.slice(0, 3).map(s => ({
|
|
884
|
+
name: s.name,
|
|
885
|
+
keyRules: s.keyRules || "",
|
|
886
|
+
score: selection.scores.get(s.name) || 0,
|
|
887
|
+
})),
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
if (phase === "validate") {
|
|
892
|
+
// Validate phase: return detected stack for targeted pattern matching
|
|
893
|
+
const fileExts = files.map(f => path.extname(f).toLowerCase()).filter(Boolean);
|
|
894
|
+
return {
|
|
895
|
+
phase: "validate",
|
|
896
|
+
detectedExtensions: fileExts,
|
|
897
|
+
essentialSkillNames: selection.essential.slice(0, 3).map(s => s.name),
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// Fallback: return full selection
|
|
902
|
+
return { phase, ...selection };
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Format pipeline-plan output: compact skill list for planner context.
|
|
907
|
+
* @param {string} task
|
|
908
|
+
* @param {object} pipelineResult - Output of brokerForPipeline(task, files, "plan")
|
|
909
|
+
* @returns {string}
|
|
910
|
+
*/
|
|
911
|
+
function formatPipelinePlan(task, pipelineResult) {
|
|
912
|
+
const lines = [
|
|
913
|
+
"# Pipeline Planner Context",
|
|
914
|
+
`# Task: ${task}`,
|
|
915
|
+
"",
|
|
916
|
+
"## Matched Skills (by relevance)",
|
|
917
|
+
"",
|
|
918
|
+
];
|
|
919
|
+
for (const s of pipelineResult.skills) {
|
|
920
|
+
lines.push(`- **${s.name}** (score: ${s.score.toFixed(1)}): ${(s.description || "").slice(0, 120)}`);
|
|
921
|
+
}
|
|
922
|
+
lines.push("");
|
|
923
|
+
lines.push(`Total matched: ${pipelineResult.total_matched}`);
|
|
924
|
+
return lines.join("\n");
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Format pipeline-build output: condensed keyRules for builder prompt injection.
|
|
929
|
+
* @param {string} task
|
|
930
|
+
* @param {object} pipelineResult - Output of brokerForPipeline(task, files, "build")
|
|
931
|
+
* @returns {string}
|
|
932
|
+
*/
|
|
933
|
+
function formatPipelineBuild(task, pipelineResult) {
|
|
934
|
+
const lines = [
|
|
935
|
+
"# Builder Context — Essential Rules Only",
|
|
936
|
+
`# Task: ${task}`,
|
|
937
|
+
"",
|
|
938
|
+
];
|
|
939
|
+
for (const s of pipelineResult.skills) {
|
|
940
|
+
lines.push(`## ${s.name}`);
|
|
941
|
+
lines.push("");
|
|
942
|
+
lines.push(s.keyRules || "(no key rules extracted)");
|
|
943
|
+
lines.push("");
|
|
944
|
+
lines.push("---");
|
|
945
|
+
lines.push("");
|
|
946
|
+
}
|
|
947
|
+
return lines.join("\n");
|
|
948
|
+
}
|
|
949
|
+
|
|
815
950
|
module.exports = {
|
|
816
951
|
broker,
|
|
952
|
+
brokerForPipeline,
|
|
817
953
|
selectSkills,
|
|
818
954
|
loadSkills,
|
|
819
955
|
scoreSkill,
|
|
820
956
|
tokenize,
|
|
821
957
|
findAgentDir,
|
|
958
|
+
extractKeyRules,
|
|
959
|
+
tryNativeContextBroker,
|
|
822
960
|
};
|
|
823
961
|
|
|
824
962
|
// ── CLI Entry ─────────────────────────────────────────────────────────────────
|
|
@@ -906,8 +1044,22 @@ ${BOLD}Examples:${RESET}
|
|
|
906
1044
|
case "prompt":
|
|
907
1045
|
console.log(formatPrompt(task, effectiveModel, selection));
|
|
908
1046
|
break;
|
|
1047
|
+
case "pipeline-plan": {
|
|
1048
|
+
const pipelinePlan = brokerForPipeline(task, files, "plan", agentDir);
|
|
1049
|
+
console.log(formatPipelinePlan(task, pipelinePlan));
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
case "pipeline-build": {
|
|
1053
|
+
const pipelineBuild = brokerForPipeline(task, files, "build", agentDir);
|
|
1054
|
+
console.log(formatPipelineBuild(task, pipelineBuild));
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
909
1057
|
default: // 'report'
|
|
910
1058
|
formatReport(task, effectiveModel, selection, elapsed);
|
|
911
1059
|
break;
|
|
912
1060
|
}
|
|
913
1061
|
}
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
@@ -35,6 +35,9 @@ const path = require("path");
|
|
|
35
35
|
*/
|
|
36
36
|
function ruleFileExists(content, manifest, _ctx) {
|
|
37
37
|
const violations = [];
|
|
38
|
+
if (_ctx && _ctx.filePath && (_ctx.filePath.endsWith(".js") || _ctx.filePath.endsWith(".py") || _ctx.filePath.endsWith(".json"))) {
|
|
39
|
+
return violations;
|
|
40
|
+
}
|
|
38
41
|
const refs = manifest.cross_references || [];
|
|
39
42
|
|
|
40
43
|
const agentDir = path.join(_ctx.projectRoot, ".agent");
|
|
@@ -132,6 +135,9 @@ function ruleReviewerCount(content, manifest, _ctx) {
|
|
|
132
135
|
*/
|
|
133
136
|
function ruleSkillExists(content, manifest, _ctx) {
|
|
134
137
|
const violations = [];
|
|
138
|
+
if (_ctx && _ctx.filePath && (_ctx.filePath.endsWith(".js") || _ctx.filePath.endsWith(".py") || _ctx.filePath.endsWith(".json"))) {
|
|
139
|
+
return violations;
|
|
140
|
+
}
|
|
135
141
|
const skillNames = new Set(manifest.skills ? manifest.skills.names : []);
|
|
136
142
|
if (skillNames.size === 0) return violations;
|
|
137
143
|
|
|
@@ -195,6 +201,9 @@ function ruleSkillExists(content, manifest, _ctx) {
|
|
|
195
201
|
*/
|
|
196
202
|
function ruleAgentExists(content, manifest, _ctx) {
|
|
197
203
|
const violations = [];
|
|
204
|
+
if (_ctx && _ctx.filePath && (_ctx.filePath.endsWith(".js") || _ctx.filePath.endsWith(".py") || _ctx.filePath.endsWith(".json"))) {
|
|
205
|
+
return violations;
|
|
206
|
+
}
|
|
198
207
|
const agentNames = new Set(manifest.agents ? manifest.agents.all : []);
|
|
199
208
|
if (agentNames.size === 0) return violations;
|
|
200
209
|
|
|
@@ -225,9 +234,9 @@ function ruleAgentExists(content, manifest, _ctx) {
|
|
|
225
234
|
function ruleUnresolvedVerify(content, _manifest, ctx) {
|
|
226
235
|
const violations = [];
|
|
227
236
|
|
|
228
|
-
// Skip this check for the internal .agent
|
|
229
|
-
// because they contain instructions ABOUT the VERIFY tag.
|
|
230
|
-
if (ctx && ctx.filePath && ctx.filePath.includes(".agent")
|
|
237
|
+
// Skip this check for the internal .agent files themselves
|
|
238
|
+
// because they contain instructions/comments ABOUT the VERIFY tag.
|
|
239
|
+
if (ctx && ctx.filePath && ctx.filePath.includes(".agent")) {
|
|
231
240
|
return violations;
|
|
232
241
|
}
|
|
233
242
|
|
|
@@ -360,6 +369,51 @@ function ruleImportPhantom(content, _manifest, ctx) {
|
|
|
360
369
|
return violations;
|
|
361
370
|
}
|
|
362
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Rule 9: rust-module-registration
|
|
374
|
+
* Validates that Rust modules in crates/core/src/commands are declared in mod.rs
|
|
375
|
+
* and registered in wrapper.js RUST_COMMANDS set.
|
|
376
|
+
*/
|
|
377
|
+
function ruleRustModuleRegistration(content, manifest, _ctx) {
|
|
378
|
+
const violations = [];
|
|
379
|
+
const root = _ctx.projectRoot || process.cwd();
|
|
380
|
+
|
|
381
|
+
const modRs = path.join(root, "crates", "core", "src", "commands", "mod.rs");
|
|
382
|
+
if (fs.existsSync(modRs)) {
|
|
383
|
+
const modContent = fs.readFileSync(modRs, "utf8");
|
|
384
|
+
const requiredMods = ["context_broker", "dag_scheduler", "context_compress"];
|
|
385
|
+
for (const m of requiredMods) {
|
|
386
|
+
if (!modContent.includes(`pub mod ${m};`)) {
|
|
387
|
+
violations.push({
|
|
388
|
+
rule: "rust-module-registration",
|
|
389
|
+
severity: "warning",
|
|
390
|
+
location: "crates/core/src/commands/mod.rs",
|
|
391
|
+
message: `Rust command module "${m}" not declared in mod.rs`,
|
|
392
|
+
suggestion: `Add "pub mod ${m};" to crates/core/src/commands/mod.rs`,
|
|
393
|
+
autoFixable: false,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const wrapperJs = path.join(root, "bin", "wrapper.js");
|
|
400
|
+
if (fs.existsSync(wrapperJs)) {
|
|
401
|
+
const wrapperContent = fs.readFileSync(wrapperJs, "utf8");
|
|
402
|
+
if (!wrapperContent.includes('"context-broker"')) {
|
|
403
|
+
violations.push({
|
|
404
|
+
rule: "rust-module-registration",
|
|
405
|
+
severity: "warning",
|
|
406
|
+
location: "bin/wrapper.js",
|
|
407
|
+
message: 'Command "context-broker" not registered in RUST_COMMANDS in bin/wrapper.js',
|
|
408
|
+
suggestion: 'Add "context-broker" to RUST_COMMANDS set in bin/wrapper.js',
|
|
409
|
+
autoFixable: false,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return violations;
|
|
415
|
+
}
|
|
416
|
+
|
|
363
417
|
// ── Rule Registry ─────────────────────────────────────────────────────────────
|
|
364
418
|
|
|
365
419
|
const RULES = {
|
|
@@ -371,6 +425,7 @@ const RULES = {
|
|
|
371
425
|
"unresolved-verify": ruleUnresolvedVerify,
|
|
372
426
|
"numeric-consistency": ruleNumericConsistency,
|
|
373
427
|
"import-phantom": ruleImportPhantom,
|
|
428
|
+
"rust-module-registration": ruleRustModuleRegistration,
|
|
374
429
|
};
|
|
375
430
|
|
|
376
431
|
// ── Main Validate Function ────────────────────────────────────────────────────
|
|
@@ -527,7 +582,7 @@ function main() {
|
|
|
527
582
|
const content = fs.readFileSync(file, "utf8");
|
|
528
583
|
const result = validate(content, manifest, {
|
|
529
584
|
autoFix: fixMode,
|
|
530
|
-
context: { projectRoot },
|
|
585
|
+
context: { projectRoot, filePath: file },
|
|
531
586
|
});
|
|
532
587
|
|
|
533
588
|
totalViolations += result.violations.length;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* impact_classifier.js — Adaptive Governance Impact Classifier
|
|
4
|
+
* ===============================================================
|
|
5
|
+
* Analyzes diffs, file extensions, and structural changes to classify
|
|
6
|
+
* tasks into Governance Impact Tiers (Tier 0 to Tier 3).
|
|
7
|
+
*
|
|
8
|
+
* Impact Tiers:
|
|
9
|
+
* Tier 0 (Fast-Pass): Score < 0.15. Typo, pure CSS, markdown, comments, <10 lines.
|
|
10
|
+
* 0 LLM calls, 0 Socratic gate, <10ms execution.
|
|
11
|
+
* Tier 1 (Express Pass): Score 0.15 - 0.35. Single file logic change.
|
|
12
|
+
* 1 domain specialist reviewer, 0 Socratic gate.
|
|
13
|
+
* Tier 2 (Targeted Audit): Score 0.35 - 0.70. Multi-file edits, non-critical domain logic.
|
|
14
|
+
* 2 reviewers, Socratic gate if ambiguity > 0.5.
|
|
15
|
+
* Tier 3 (Full Gauntlet): Score > 0.70 or critical paths (auth, schema, security, payment).
|
|
16
|
+
* Full multi-agent gauntlet + strict Human Gate.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* node .agent/scripts/impact_classifier.js --files "src/app.css" --diff "+color: red;"
|
|
20
|
+
* node .agent/scripts/impact_classifier.js --task "Fix typo in comment"
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
"use strict";
|
|
24
|
+
|
|
25
|
+
const path = require("path");
|
|
26
|
+
const { parseArgs } = require("./_utils");
|
|
27
|
+
|
|
28
|
+
// Critical file patterns that automatically force Tier 3
|
|
29
|
+
const CRITICAL_PATTERNS = [
|
|
30
|
+
/auth/i,
|
|
31
|
+
/security/i,
|
|
32
|
+
/payment/i,
|
|
33
|
+
/billing/i,
|
|
34
|
+
/schema/i,
|
|
35
|
+
/migration/i,
|
|
36
|
+
/permission/i,
|
|
37
|
+
/jwt/i,
|
|
38
|
+
/crypto/i,
|
|
39
|
+
/secret/i,
|
|
40
|
+
/eval/i
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// Low-impact extensions / patterns for Tier 0
|
|
44
|
+
const FAST_PASS_EXTENSIONS = [".css", ".scss", ".less", ".md", ".txt", ".json", ".svg", ".png", ".jpg"];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Classify impact based on files, diff content, and task description
|
|
48
|
+
* @param {Object} opts - Options { files, diff, task, lineCount }
|
|
49
|
+
* @returns {Object} Tier payload { tier, score, reasoning, maxReviewers, requireGate }
|
|
50
|
+
*/
|
|
51
|
+
function classifyImpact(opts = {}) {
|
|
52
|
+
if (!opts || typeof opts !== "object") opts = {};
|
|
53
|
+
const rawFiles = opts.files;
|
|
54
|
+
const files = Array.isArray(rawFiles)
|
|
55
|
+
? rawFiles.filter(f => typeof f === "string" && f.length > 0)
|
|
56
|
+
: (typeof rawFiles === "string" && rawFiles.length > 0 ? [rawFiles] : []);
|
|
57
|
+
const diff = typeof opts.diff === "string" ? opts.diff : "";
|
|
58
|
+
const task = typeof opts.task === "string" ? opts.task : "";
|
|
59
|
+
const lineCount = typeof opts.lineCount === "number" && Number.isFinite(opts.lineCount) && opts.lineCount >= 0
|
|
60
|
+
? opts.lineCount
|
|
61
|
+
: (diff.length > 0 ? diff.split("\n").length : 0);
|
|
62
|
+
|
|
63
|
+
let score = 0.2; // Base baseline score
|
|
64
|
+
const reasoning = [];
|
|
65
|
+
|
|
66
|
+
// Check 1: Critical File Patterns
|
|
67
|
+
const isCriticalFile = files.some(file => CRITICAL_PATTERNS.some(pat => pat.test(file)));
|
|
68
|
+
const isCriticalTask = CRITICAL_PATTERNS.some(pat => pat.test(task));
|
|
69
|
+
|
|
70
|
+
if (isCriticalFile || isCriticalTask) {
|
|
71
|
+
score += 0.6;
|
|
72
|
+
reasoning.push("Critical path detected (auth/security/schema/payment)");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Check 2: File Extensions & Types
|
|
76
|
+
if (files.length > 0) {
|
|
77
|
+
const allFastPass = files.every(f => FAST_PASS_EXTENSIONS.includes(path.extname(f).toLowerCase()));
|
|
78
|
+
if (allFastPass) {
|
|
79
|
+
score -= 0.25;
|
|
80
|
+
reasoning.push("All modified files are low-risk assets (styles/docs/assets)");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Check 3: Line Count & Diff Size
|
|
85
|
+
if (lineCount <= 10) {
|
|
86
|
+
score -= 0.15;
|
|
87
|
+
reasoning.push("Small diff size (<= 10 lines)");
|
|
88
|
+
} else if (lineCount > 100) {
|
|
89
|
+
score += 0.3;
|
|
90
|
+
reasoning.push("Large diff size (> 100 lines)");
|
|
91
|
+
} else if (lineCount > 30) {
|
|
92
|
+
score += 0.15;
|
|
93
|
+
reasoning.push("Medium diff size (30-100 lines)");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Check 4: Task Keywords
|
|
97
|
+
const taskLower = task.toLowerCase();
|
|
98
|
+
if (/typo|fix comment|format|lint|rename|css|style|docs|readme/i.test(taskLower)) {
|
|
99
|
+
score -= 0.2;
|
|
100
|
+
reasoning.push("Task signals simple edit or formatting");
|
|
101
|
+
}
|
|
102
|
+
if (/refactor|rewrite|architecture|redesign|migration|overhaul|security/i.test(taskLower)) {
|
|
103
|
+
score += 0.35;
|
|
104
|
+
reasoning.push("Task signals structural refactor or security review");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Clamp score between 0.0 and 1.0
|
|
108
|
+
score = Math.max(0.0, Math.min(1.0, score));
|
|
109
|
+
|
|
110
|
+
// Determine Impact Tier
|
|
111
|
+
let tier = 1;
|
|
112
|
+
let maxReviewers = 1;
|
|
113
|
+
let requireGate = false;
|
|
114
|
+
|
|
115
|
+
if (score < 0.15 && !isCriticalFile && !isCriticalTask) {
|
|
116
|
+
tier = 0;
|
|
117
|
+
maxReviewers = 0;
|
|
118
|
+
requireGate = false;
|
|
119
|
+
} else if (score < 0.35 && !isCriticalFile && !isCriticalTask) {
|
|
120
|
+
tier = 1;
|
|
121
|
+
maxReviewers = 1;
|
|
122
|
+
requireGate = false;
|
|
123
|
+
} else if (score < 0.70 && !isCriticalFile) {
|
|
124
|
+
tier = 2;
|
|
125
|
+
maxReviewers = 2;
|
|
126
|
+
requireGate = true; // Conditional gate
|
|
127
|
+
} else {
|
|
128
|
+
tier = 3;
|
|
129
|
+
maxReviewers = 8;
|
|
130
|
+
requireGate = true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
tier,
|
|
135
|
+
score: parseFloat(score.toFixed(2)),
|
|
136
|
+
maxReviewers,
|
|
137
|
+
requireGate,
|
|
138
|
+
reasoning,
|
|
139
|
+
fastPass: tier === 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Direct CLI Execution
|
|
144
|
+
if (require.main === module) {
|
|
145
|
+
const args = parseArgs(process.argv);
|
|
146
|
+
const files = args.files ? args.files.split(",") : [];
|
|
147
|
+
const result = classifyImpact({
|
|
148
|
+
files,
|
|
149
|
+
diff: args.diff || "",
|
|
150
|
+
task: args.task || "",
|
|
151
|
+
lineCount: args.lines ? parseInt(args.lines, 10) : undefined
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (args.json) {
|
|
155
|
+
console.log(JSON.stringify(result, null, 2));
|
|
156
|
+
} else {
|
|
157
|
+
console.log(`\n━━━ Adaptive Governance Impact Tier ━━━━━━━━━━━━━`);
|
|
158
|
+
console.log(` Tier: Tier ${result.tier} (${result.fastPass ? "FAST-PASS" : result.tier === 1 ? "EXPRESS" : result.tier === 2 ? "TARGETED" : "GAUNTLET"})`);
|
|
159
|
+
console.log(` Score: ${result.score}`);
|
|
160
|
+
console.log(` Max Reviewers:${result.maxReviewers}`);
|
|
161
|
+
console.log(` Require Gate: ${result.requireGate}`);
|
|
162
|
+
console.log(` Reasoning: ${result.reasoning.join(" | ") || "Baseline assessment"}`);
|
|
163
|
+
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = { classifyImpact };
|