@miller-tech/uap 1.40.0 → 1.40.1

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.
Files changed (92) hide show
  1. package/README.md +109 -642
  2. package/docs/INDEX.md +48 -286
  3. package/docs/architecture/OVERVIEW.md +328 -0
  4. package/docs/architecture/PROTOCOL.md +204 -0
  5. package/docs/benchmarks/README.md +17 -192
  6. package/docs/getting-started/CONFIGURATION.md +237 -0
  7. package/docs/getting-started/INSTALLATION.md +125 -0
  8. package/docs/getting-started/QUICKSTART.md +115 -0
  9. package/docs/guides/COORDINATION.md +162 -0
  10. package/docs/guides/DELIVER.md +115 -0
  11. package/docs/guides/DEPLOY_BATCHING.md +212 -0
  12. package/docs/guides/DROIDS_AND_SKILLS.md +202 -0
  13. package/docs/guides/LOCAL_MODELS.md +148 -0
  14. package/docs/guides/MCP_ROUTER.md +195 -0
  15. package/docs/guides/MEMORY.md +235 -0
  16. package/docs/guides/MULTI_MODEL.md +223 -0
  17. package/docs/guides/POLICIES.md +190 -0
  18. package/docs/guides/WORKTREE_WORKFLOW.md +185 -0
  19. package/docs/integrations/MCP_ROUTER.md +147 -0
  20. package/docs/integrations/RTK.md +102 -0
  21. package/docs/reference/API.md +485 -0
  22. package/docs/reference/CLI.md +719 -0
  23. package/docs/reference/CONFIGURATION.md +90 -193
  24. package/docs/reference/DATABASE_SCHEMA.md +110 -344
  25. package/docs/reference/FEATURES.md +176 -472
  26. package/docs/reference/PATTERNS.md +102 -0
  27. package/docs/reference/PLATFORMS.md +83 -0
  28. package/package.json +1 -1
  29. package/docs/AGENTS.md +0 -423
  30. package/docs/DOCUMENTATION_AUDIT_REPORT.md +0 -131
  31. package/docs/GETTING_STARTED.md +0 -288
  32. package/docs/PROJECT_ANALYSIS_REPORT.md +0 -510
  33. package/docs/architecture/COMPLETE_ARCHITECTURE.md +0 -748
  34. package/docs/architecture/EXPERT_STACK.md +0 -137
  35. package/docs/architecture/MULTI_MODEL.md +0 -224
  36. package/docs/architecture/PLATFORM_GATING.md +0 -68
  37. package/docs/architecture/SYSTEM_ANALYSIS.md +0 -334
  38. package/docs/architecture/UAP_COMPLIANCE.md +0 -217
  39. package/docs/architecture/UAP_PROTOCOL.md +0 -339
  40. package/docs/architecture/UAP_STRICT_DROIDS.md +0 -172
  41. package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +0 -260
  42. package/docs/archive/BENCHMARK_GAPS_AND_PLAN.md +0 -146
  43. package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +0 -668
  44. package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +0 -209
  45. package/docs/archive/MODEL_ROUTING_IMPLEMENTATION_SUMMARY.md +0 -281
  46. package/docs/archive/MODEL_ROUTING_OPTIMIZATION_PLAN.md +0 -320
  47. package/docs/archive/NPM-PUBLISH-V0.9.1.md +0 -240
  48. package/docs/archive/OPTIMIZATION_OPTIONS.md +0 -334
  49. package/docs/archive/PARALLELISM_GAPS_AND_OPTIONS.md +0 -422
  50. package/docs/archive/POLICY_GATE_IMPLEMENTATION.md +0 -245
  51. package/docs/archive/SETUP_IMPROVEMENTS.md +0 -213
  52. package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +0 -270
  53. package/docs/archive/UAP_OPTIMIZATION_PLAN.md +0 -701
  54. package/docs/archive/UAP_V103_PATTERN_DESIGN.md +0 -315
  55. package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +0 -223
  56. package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +0 -77
  57. package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +0 -109
  58. package/docs/archive/opencode-integration-guide.md +0 -740
  59. package/docs/archive/opencode-integration-quickref.md +0 -180
  60. package/docs/benchmarks/OVERNIGHT_RUNNER.md +0 -341
  61. package/docs/benchmarks/SPECULATIVE_DECODING_JOURNEY_2026-03.md +0 -221
  62. package/docs/benchmarks/VALIDATION_PLAN.md +0 -568
  63. package/docs/blog/SPECULATIVE_DECODING_PRODUCTION_PLAYBOOK.md +0 -139
  64. package/docs/blog/local-coding-agents.md +0 -266
  65. package/docs/blog/x-thread.md +0 -254
  66. package/docs/deployment/DEPLOYMENT.md +0 -895
  67. package/docs/deployment/DEPLOYMENT_STRATEGIES.md +0 -518
  68. package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +0 -224
  69. package/docs/deployment/DEPLOY_BATCHING.md +0 -273
  70. package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +0 -420
  71. package/docs/deployment/QWEN35_LLAMA_CPP.md +0 -426
  72. package/docs/deployment/UAP_LLAMA_ANTHROPIC_PROXY_BOOTSTRAP.md +0 -279
  73. package/docs/getting-started/INTEGRATION.md +0 -628
  74. package/docs/getting-started/OVERVIEW.md +0 -324
  75. package/docs/getting-started/SETUP.md +0 -377
  76. package/docs/integrations/MCP_ROUTER_SETUP.md +0 -445
  77. package/docs/integrations/RTK_INTEGRATION.md +0 -468
  78. package/docs/operations/TROUBLESHOOTING.md +0 -660
  79. package/docs/pr/PR_SPECULATIVE_DOCS_TEMPLATE.md +0 -146
  80. package/docs/pr/UPSTREAM_PRS.md +0 -424
  81. package/docs/reference/API_REFERENCE.md +0 -903
  82. package/docs/reference/EXPERT_DROIDS.md +0 -219
  83. package/docs/reference/HARNESS-MATRIX.md +0 -318
  84. package/docs/reference/PATTERN_LIBRARY.md +0 -636
  85. package/docs/reference/UAP_CLI_REFERENCE.md +0 -620
  86. package/docs/research/BEHAVIORAL_PATTERNS.md +0 -228
  87. package/docs/research/DOMAIN_STRATEGIES.md +0 -316
  88. package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +0 -812
  89. package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +0 -436
  90. package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +0 -209
  91. package/docs/research/PERFORMANCE_TEST_PLAN.md +0 -383
  92. package/docs/research/TERMINAL_BENCH_LEARNINGS.md +0 -217
@@ -1,334 +0,0 @@
1
- # UAP - Universal Agent Protocol
2
-
3
- > **Version:** 1.20.32
4
- > **Last Updated:** 2026-04-08
5
- > \*\*License: AI agents to maintain persistent context, learn from past interactions, and apply proven patterns across tasks.
6
-
7
- ---
8
-
9
- ## Quick Start
10
-
11
- ```bash
12
- npm install -g @miller-tech/uap
13
- uap init
14
- uap setup -p all
15
- ```
16
-
17
- ---
18
-
19
- ## Architecture
20
-
21
- ### Four-Layer Memory System
22
-
23
- ```mermaid
24
- graph TB
25
- subgraph "L4: Knowledge Graph"
26
- K1[Entities]
27
- K2[Relationships]
28
- end
29
-
30
- subgraph "L3: Semantic Memory"
31
- S1[Qdrant Vectors]
32
- S2[Similarity Search]
33
- end
34
-
35
- subgraph "L2: Session Memory"
36
- SE1[High-Importance Decisions]
37
- SE2[Per-Session State]
38
- end
39
-
40
- subgraph "L1: Working Memory"
41
- W1[SQLite + FTS5]
42
- W2[Recent Actions]
43
- end
44
-
45
- K1 --> S1
46
- S1 --> SE1
47
- SE1 --> W1
48
-
49
- style K1 fill:#e3f2fd,stroke:#1976d2
50
- style S1 fill:#fff3e0,stroke:#f57c00
51
- style SE1 fill:#f3e5f5,stroke:#7b1fa2
52
- style W1 fill:#c8e6c9,stroke:#388e3c
53
- ```
54
-
55
- | Layer | Storage | Capacity | Latency |
56
- | ------------- | ------------------------- | ---------- | ------- |
57
- | L1: Working | SQLite `memories` | 50 entries | <1ms |
58
- | L2: Session | SQLite `session_memories` | Unlimited | <5ms |
59
- | L3: Semantic | Qdrant vectors | Unlimited | ~50ms |
60
- | L4: Knowledge | SQLite entities/rels | Unlimited | <20ms |
61
-
62
- ### Multi-Agent Coordination**Agent Registry**: Track active agents with heartbeat monitoring
63
-
64
- - **Work Announcements**: Declare intent before editing resources
65
- - **Overlap Detection**: Prevent conflicts via resource analysis
66
- - **Inter-Agent Messaging**: Broadcast, direct, and channel-based communication
67
- - **Deploy Batching**: Squash, merge, parallelize deploy actions
68
-
69
- ### Task Management (7 modules)
70
-
71
- ````mermaid
72
- stateDiagram-v2
73
- [*] --> open: create()
74
- open --> in_progress: update(status)
75
- open --> blocked: dependency added
76
-
77
- in_progress --> done: close()
78
- in_progress --> wont_do: close(reason)
79
-
80
- blocked --> in_progress: blockers resolved
81
- blocked --> wont_do: abandoned
82
-
83
- done --> [*]
84
- wont_do --> [*]
85
-
86
- style open fill:#c8e6c9,stroke:#388e3c
87
- | Storage | Capacity | Latency |
88
- |----------|--------------------------|---------------|---------|
89
- | L1: Working | SQLite `memories` | 50 entries | <1ms |
90
- | L2: Session | SQLite `session_memories`| Unlimited | <5ms |
91
- | L3: Semantic | Qdrant vectors | Unlimited | ~50ms |
92
- | L4: Knowledge | SQLite entities/rels | Unlimited | <20ms |
93
-
94
- ---
95
-
96
- ## CLI Reference
97
-
98
- ### 25 Top-Level Commands
99
-
100
- | Command | Description |
101
- |---------|-------------|
102
- | `uap init` | Initialize UAP in a project |
103
- | `uap setup -p all` | Full setup (memory, Qdrant, hooks, patterns) |
104
- | `uap memory <action>` | Memory management (9 subcommands) |
105
- | `uap worktree <action>` | Git worktree management (5 subcommands) |
106
- | `uap agent <action>` | Agent lifecycle (10 subcommands) |
107
- | `uap deploy <action>` | Deploy batching (8 subcommands) |
108
- | `uap task <action>` | Task management (15 subcommands) |
109
- | `uap policy <action>` | Policy management (15 subcommands) |
110
- | `uap model <action>` | Multi-model management (8 subcommands) |
111
- | `uap patterns <action>` | Pattern RAG management (4 subcommands) |
112
-
113
- **Total: 109 commands and subcommands.**
114
-
115
- ### Common Operations
116
-
117
- ```bash
118
- # Query semantic memory
119
- uap memory query "authentication errors"
120
-
121
- # Create tracked task
122
- uap task create --title "Fix login bug" --type bug
123
-
124
- # Check for agent overlaps
125
- uap agent overlaps --resource src/auth.ts
126
-
127
- # Queue deploy action
128
- uap deploy queue --action commit --target main --message> View dashboard
129
- uap dashboard
130
- ````
131
-
132
- ---
133
-
134
- ## Pattern System (23 Patterns)
135
-
136
- Battle-tested patterns from Terminal-Bench 2.0:
137
-
138
- | Pattern | ID | Missing output files (37% of failures) |
139
- | Iterative Refinement | P13 | First-attempt acceptance |
140
- | Output Format | P14 | Wrong format/encoding |
141
- | Task-First | P16 | Over-planning before doing |
142
- | Constraint Extraction | P17 | Missing hidden requirements |
143
- | Impossible Refusal | P19 | Attempting impossible tasks |
144
- | Chess Engine | P21 | Reinventing Stockfish |
145
- | Git Recovery | P22 | Data loss during git ops |
146
- | Compression Check | P23 | Lossy compression errors |
147
- | Polyglot | P24 | Single-language thinking |
148
- | Near-Miss | P26 | Almost-correct solutions |
149
- | Smoke Test | P28 | Untested changes |
150
- | Performance Threshold | P30 | Missing perf targets |
151
- | Round-Trip | P31 | Encode/decode mismatches |
152
- | CLI Verify | P32 | Broken CLI commands |
153
- | Numerical Stability | P33 | Floating point errors |
154
- | Image Pipeline | P34 | Image processing errors |
155
- | Decoder-First | P35 | Wrong problem decomposition |
156
- | Competition Domain | P36 | Missing domain knowledge |
157
- | Ambiguity Detection | P37 | Ambiguous task descriptions |
158
- | IaC Parity | IaC | Config drift |
159
-
160
- ---
161
-
162
- ## Multi-Model Architecture
163
-
164
- ### 3-Tier Execution
165
-
166
- ```mermaid
167
- flowchart LR
168
- subgraph "Tier 1: TaskPlanner"
169
- P1[Decompose task]
170
- P2[Analyze dependencies]
171
- end
172
-
173
- subgraph "Tier 2: ModelRouter"
174
- R1[Assign optimal model]
175
- R2[Cost optimization]
176
- end
177
-
178
- subgraph "Tier 3: TaskExecutor"
179
- E1[Execute with validation]
180
- E2[Dynamic temperature]
181
- E3[Rate limiting]
182
- end
183
-
184
- P1 --> R1
185
- P2 --> R2
186
- R1 --> E1
187
- R2 --> E2
188
- E2 --> E3
189
-
190
- style P1 fill:#e3f2fd,stroke:#1976d2
191
- style R1 fill:#fff3e0,stroke:#f57c00
192
- style E1 fill:#c8e6c9,stroke:#388e3c
193
- ```
194
-
195
- ---
196
-
197
- ## MCP Router
198
-
199
- Replaces N tool definitions with 2 meta-tools for **98% token reduction**.
200
-
201
- ### Components (10 modules)
202
-
203
- | Component | Purpose |
204
- | ------------- | ------------------------------------------- |
205
- | MCP Server | Exposes `discover_tools` and `execute_tool` |
206
- | Config Parser | Loads MCP configs from standard paths |
207
- | Fuzzy Search | Tool discovery with fuzzy matching |
208
- | Client Pool | Manages connections to MCP servers |
209
- | Tool Execute | Tool execution with policy gate |
210
-
211
- ---
212
-
213
- ## Policy Enforcement (8 modules)
214
-
215
- ### Enforcement Levels
216
-
217
- | Level | Behavior |
218
- | ----------- | ----------------------------------------------- |
219
- | REQUIRED | Blocks execution, throws `PolicyViolationError` |
220
- | RECOMMENDED | Logged but does not block |
221
- | OPTIONAL | Informational only |
222
-
223
- ### CLI Commands
224
-
225
- ```bash
226
- uap policy list # List all policies
227
- uap policy install <name> # Install built-in policy
228
- uap policy enable <id> # Enable a policy
229
- uap policy disable <id> # Disable a policy
230
- uap policy check -o <operation> # Check if allowed
231
- uap policy audit # View audit trail
232
- ```
233
-
234
- ---
235
-
236
- ## Browser Automation
237
-
238
- Stealth web browser via CloakBrowser (Playwright drop-in):
239
-
240
- ```typescript
241
- import { createWebBrowser } from '@miller-tech/uap/browser';
242
-
243
- const browser = createWebBrowser();
244
- await browser.launch({ headless: true, humanize: true });
245
- await browser.goto('https://example.com');
246
- const content = await browser.getContent();
247
- await browser.close();
248
- ```
249
-
250
- ---
251
-
252
- ## Testing & Quality
253
-
254
- ```bash
255
- npm test # 693 tests across 45 test files
256
- npm run build # TypeScript compilation
257
- npm run lint # ESLint
258
- npm run format # Prettier
259
- npm run test:coverage # Coverage report (50% thresholds)
260
- ```
261
-
262
- ---
263
-
264
- ## Configuration
265
-
266
- ### .uap.json (Project Settings)
267
-
268
- ```json
269
- {
270
- "version": "1.0.0",
271
- "project": { "name": "my-project", "defaultBranch": "main" },
272
- "memory": {
273
- "shortTerm": { "enabled": true, "path": "./agents/data/memory/short_term.db" },
274
- "longTerm": { "enabled": true, "provider": "qdrant" }
275
- },
276
- "multiModel": {
277
- "enabled": true,
278
- "models": ["opus-4.6", "qwen35"],
279
- "roles": { "planner": "opus-4.6", "executor": "qwen35" },
280
- "routingStrategy": "balanced"
281
- },
282
- "worktrees": { "enabled": true, "directory": ".worktrees" }
283
- }
284
- ```
285
-
286
- ---
287
-
288
- ## Requirements
289
-
290
- | Dependency | Version | Required | Purpose |
291
- | ---------- | --------- | -------- | -------------------------- |
292
- | Node.js | >= 18.0.0 | Yes | Runtime |
293
- | git | Latest | Yes | Version control, worktrees |
294
- | Docker | Latest | No | Local Qdrant |
295
- | Python 3 | Latest | No | Embeddings, Pattern RAG |
296
-
297
- ---
298
-
299
- ## Performance Impact
300
-
301
- | Feature | Token Savings | Task Completion Impact |
302
- | --------------------- | ------------- | --------------------------- |
303
- | Memory query (cached) | ~50 tokens | High (avoids re-learning) |
304
- | Worktree create | ~60 tokens | Very High (safe isolation) |
305
- | Agent announce | ~40 tokens | High (conflict prevention) |
306
- | Overlap check | ~30 tokens | Very High (merge avoidance) |
307
- | Deploy batch | ~50 tokens | Very High (CI/CD savings) |
308
-
309
- **Overall Impact:**
310
-
311
- - **60-80%** reduction in context repetition
312
- - **50-80%** reduction in CI/CD minutes
313
- - **Near-zero** merge conflicts in multi-agent scenarios
314
-
315
- ---
316
-
317
- ## Documentation
318
-
319
- - **[Getting Started](docs/getting-started/OVERVIEW.md)**: Core concepts and setup
320
- - **[Architecture](docs/architecture/SYSTEM_ANALYSIS.md)**: Complete system analysis
321
- - **[CLI Reference](docs/reference/UAP_CLI_REFERENCE.md)**: Full command reference
322
- - **[Deployment](docs/deployment/DEPLOYMENT.md)**: Production deployment guide
323
- - **[Benchmarks](docs/benchmarks/README.md)**: Performance analysis
324
-
325
- ---
326
-
327
- ## Attribution
328
-
329
- - Terminal-Bench patterns from [Terminal-Bench 2.0](https://github.com/aptx432/terminal-bench)
330
- - CloakBrowser from [CloakHQ/CloakBrowser](https://github.com/CloakHQ/CloakBrowser)
331
-
332
- ---
333
-
334
- **[Documentation](docs/INDEX.md)** | **[npm](https://www.npmjs.com/package/@miller-tech/uap)** | **[GitHub](https://github.com/DammianMiller/universal-agent-protocol)**
@@ -1,217 +0,0 @@
1
- # UAP Deviation Fixes - Implementation Plan
2
-
3
- ## Overview
4
- This document outlines options to fix minor deviations from strict UAP compliance identified in the qwen35-a3b-iq4xs implementation.
5
-
6
- ---
7
-
8
- ## Deviation #1: Markdown Frontmatter vs JSON Schema
9
-
10
- ### Current State (Non-Compliant)
11
- Droids use YAML frontmatter for metadata:
12
- ```yaml
13
- ---
14
- name: code-quality-guardian
15
- description: Proactive code quality enforcer...
16
- model: inherit
17
- coordination:
18
- channels: ["review", "broadcast"]
19
- claims: ["exclusive"]
20
- ---
21
- # Instructions here...
22
- ```
23
-
24
- ### Option A: Strict JSON Schema (Recommended) ✅
25
- **Pros:** Machine-parsable, type-safe, validates against schema
26
- **Cons:** Less human-readable for quick edits
27
-
28
- **Implementation:**
29
- - Convert `.factory/droids/*.md` to use embedded JSON in frontmatter
30
- - Add schema validation during droid discovery via `discoverDroids()`
31
- - Example:
32
- ```json
33
- ---
34
- {
35
- "name": "code-quality-guardian",
36
- "description": "...",
37
- "model": "inherit",
38
- "coordination": {
39
- "channels": ["review", "broadcast"],
40
- "claims": ["exclusive"]
41
- }
42
- }
43
- ---
44
- ```
45
-
46
- **Files to modify:**
47
- - `src/cli/droids.ts` - Add JSON validation in `addDroid()`
48
- - `.opencode/plugin/uap-droids.ts` - Update parser with Zod schema
49
- - Existing droids: Migrate one at a time as template for others
50
-
51
- ---
52
-
53
- ### Option B: Hybrid Format (Balanced) ⚠️
54
- **Pros:** Retains YAML readability, adds JSON validation layer
55
- **Cons:** Slightly more complex parsing
56
-
57
- **Implementation:**
58
- - Keep YAML frontmatter but add required `@schema` directive in body
59
- - Example:
60
- ```yaml
61
- ---
62
- name: code-quality-guardian
63
- description: ...
64
- model: inherit
65
- coordination:
66
- channels: ["review", "broadcast"]
67
- ---
68
-
69
- @schema {
70
- "$ref": "#/definitions/DroidSchema"
71
- }
72
-
73
- # Instructions here...
74
- ```
75
-
76
- **Files to modify:**
77
- - `.opencode/plugin/uap-droids.ts` - Add schema directive parser
78
- - `src/types/config.ts` - Define DroidSchema in TypeScript
79
-
80
- ---
81
-
82
- ## Deviation #2: Missing Decoder-First Gate
83
-
84
- ### Current State (Partial Implementation)
85
- CLAUDE.md mentions "DECODER-FIRST GATE" but no explicit implementation exists. The system relies on implicit validation via memory checks and worktrees.
86
-
87
- ### Option A: Explicit Pre-Execution Validator ✅
88
- **Pros:** Clear separation of concerns, easy to test
89
- **Cons:** Adds one extra step before task execution
90
-
91
- **Implementation:**
92
- ```typescript
93
- // src/tasks/decoder-gate.ts
94
- export async function validateDecoderFirst(
95
- droidName: string,
96
- taskContext: TaskContext
97
- ): Promise<ValidationResult> {
98
- // Step 1: Verify model can parse droid instructions
99
- const schemaValid = await validateSchema(droidMeta);
100
-
101
- // Step 2: Check required tools are available
102
- const toolAvailability = checkToolAccess(droidMeta.tools);
103
-
104
- // Step 3: Validate coordination claims don't conflict
105
- const conflicts = await detectCoordinationConflicts(
106
- droidName,
107
- taskContext.agentId
108
- );
109
-
110
- return { valid: schemaValid && toolAvailability && !conflicts };
111
- }
112
- ```
113
-
114
- **Files to modify:**
115
- - `src/tasks/decoder-gate.ts` (new file)
116
- - `.opencode/plugin/uap-droids.ts` - Call gate before invocation
117
- - Add test in `tests/droids-parallel.test.ts`
118
-
119
- ---
120
-
121
- ### Option B: Implicit Gate via Memory Pre-check ⚠️
122
- **Pros:** No new code, leverages existing memory system
123
- **Cons:** Less explicit, harder to trace failures
124
-
125
- **Implementation:**
126
- ```typescript
127
- // Modify uap_droid_invoke in .opencode/plugin/uap-droids.ts
128
- async execute({ droid, task }) {
129
- const validation = await validateMemoryContext(droid);
130
- if (!validation.valid) return validation.error;
131
-
132
- // Proceed with normal invocation...
133
- }
134
- ```
135
-
136
- ---
137
-
138
- ## Deviation #3: Optional Worktree Creation ✅ (Already Compliant-ish)
139
-
140
- ### Current State
141
- Worktrees are recommended but not enforced (`[ ] MANDATORY` in droid instructions).
142
-
143
- ### Option A: Enforce via Pre-Check Hook 🔧
144
- **Pros:** Ensures consistency, prevents race conditions
145
- **Cons:** Slightly slower execution
146
-
147
- **Implementation:**
148
- ```typescript
149
- // In .opencode/plugin/uap-droids.ts - before invoke
150
- const worktree = await ensureWorktree(droidName);
151
- if (!worktree) {
152
- throw new Error(`Droid ${droid} requires active worktree`);
153
- }
154
- ```
155
-
156
- ---
157
-
158
- ## Recommended Implementation Path
159
-
160
- ### Phase 1: JSON Schema Enforcement (Week 1)
161
- 1. Update `discoverDroids()` with Zod schema validation
162
- 2. Convert code-quality-guardian to strict format as template
163
- 3. Add migration script for existing droids
164
-
165
- **Files:**
166
- - `.opencode/plugin/uap-droids.ts`
167
- - `src/cli/droids.ts` (add --strict flag)
168
-
169
- ### Phase 2: Decoder Gate Implementation (Week 1-2)
170
- 1. Create `src/tasks/decoder-gate.ts` with validation logic
171
- 2. Integrate into droid invocation flow
172
- 3. Add unit tests for gate scenarios
173
-
174
- **Files:**
175
- - New file: `src/tasks/decoder-gate.ts`
176
- - `.opencode/plugin/uap-droids.ts` (integration)
177
-
178
- ### Phase 3: Worktree Enforcement (Week 2)
179
- 1. Modify `claim()` in coordination to require worktree
180
- 2. Add warning for optional droids without enforcement
181
- 3. Update CLI help text
182
-
183
- **Files:**
184
- - `src/tasks/coordination.ts` - update claim() logic
185
- - `src/cli/droids.ts` - add --require-worktree flag
186
-
187
- ---
188
-
189
- ## Testing Strategy
190
-
191
- ### Parallel Droid Test Enhancement
192
- ```typescript
193
- // Add to tests/droids-parallel.test.ts
194
- it('validates decoder-first gate for all droids', async () => {
195
- const invalidDroid = 'non-existent-droid';
196
- await expect(validateDecoderFirst(invalidDroid)).rejects.toThrow();
197
-
198
- const validDroid = 'code-quality-guardian';
199
- await expect(validateDecoderFirst(validDroid)).resolves.toBe(true);
200
- });
201
-
202
- it('enforces worktree creation for strict droids', async () => {
203
- await expect(claimTaskWithoutWorktree()).rejects.toThrow();
204
- });
205
- ```
206
-
207
- ---
208
-
209
- ## Compliance Score After Fixes
210
-
211
- | Metric | Current | Target | Gap |
212
- |--------|---------|--------|-----|
213
- | Schema validation | YAML frontmatter | JSON + Zod | ✅ Fixable in Phase 1 |
214
- | Decoder-first gate | Implicit | Explicit validator | ⚠️ Needs implementation |
215
- | Worktree enforcement | Optional → Recommended | Mandatory (configurable) | 🔧 Easy fix |
216
-
217
- **Overall: ~85% compliant now, will reach 95-98% after fixes.**