@miller-tech/uap 1.43.1 → 1.43.3

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 (35) hide show
  1. package/docs/INDEX.md +2 -0
  2. package/docs/guides/AUTOMATIC.md +92 -0
  3. package/docs/guides/LOCAL_MODELS.md +5 -0
  4. package/docs/guides/QWEN36_LLAMACPP.md +110 -0
  5. package/package.json +2 -2
  6. package/scripts/maintenance/ensure-exec-bits.sh +25 -0
  7. package/scripts/setup/install-rtk.sh +0 -0
  8. package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
  9. package/src/policies/enforcers/artifact_hygiene.py +0 -0
  10. package/src/policies/enforcers/cluster_routing.py +0 -0
  11. package/src/policies/enforcers/codebase_read_before_plan.py +0 -0
  12. package/src/policies/enforcers/coord_overlap.py +0 -0
  13. package/src/policies/enforcers/delivery_enforcement.py +0 -0
  14. package/src/policies/enforcers/doc_live_over_report.py +0 -0
  15. package/src/policies/enforcers/expert_review_required.py +0 -0
  16. package/src/policies/enforcers/iac_parity.py +0 -0
  17. package/src/policies/enforcers/mcp_router_first.py +0 -0
  18. package/src/policies/enforcers/memory_before_plan.py +0 -0
  19. package/src/policies/enforcers/parallel_reads.py +0 -0
  20. package/src/policies/enforcers/rtk_wrap.py +0 -0
  21. package/src/policies/enforcers/schema_diff_gate.py +0 -0
  22. package/src/policies/enforcers/session_memory_write.py +0 -0
  23. package/src/policies/enforcers/test_gate.py +0 -0
  24. package/src/policies/enforcers/validate_plan_before_build.py +0 -0
  25. package/src/policies/enforcers/worktree_required.py +0 -0
  26. package/templates/hooks/uap-policy-gate-hermes.sh +0 -0
  27. package/tools/agents/UAP/cli.py +0 -0
  28. package/tools/agents/benchmarks/benchmark_memory_systems.py +0 -0
  29. package/tools/agents/migrations/apply.py +0 -0
  30. package/tools/agents/scripts/tool-choice-proxy.cjs +0 -0
  31. package/tools/agents/tests/test_anthropic_proxy_streaming.py +0 -0
  32. package/tools/agents/tests/test_attractor_detection.py +0 -0
  33. package/tools/agents/tests/test_uap_compliance.py +0 -0
  34. package/tools/agents/uap_agent_install.sh +0 -0
  35. package/docs/AGENTS.md</path>CLAUDE.md</path>/home/cogtek/dev/miller-tech/universal-agent-protocol/docs/INDEX.md</path>/home/cogtek/dev/miller-tech/universal-agent-protocol/docs/reference/API_REFERENCE.md</path>/home/cogtek/dev/miller-tech/universal-agent-protocol/docs/reference/UAP_CLI_REFERENCE.md</path>src/index.ts</path>/src/cli/worktree.ts</path>/src/coordination/deploy-batcher.ts</path>/src/policies/policy-gate.ts</path>/src/memory/model-router.ts</path>/src/memory/embeddings.ts</path>/src/models/types.ts</path>/src/types/coordination.ts</path>/src/utils/logger.ts</path>/src/utils/config-loader.ts</path>/src/utils/performance-monitor.ts</path>/src/utils/concurrency.ts</path>/src/utils/concurrency-pool.ts</path>/src/utils/string-similarity.ts</path>/src/utils/rate-limiter.ts</path>/src/utils/system-resources.ts</path>/src/utils/adaptive-cache.ts</path>/src/utils/lazy-imports.ts</path>/src/utils/merge-claude-md.ts</path>/src/utils/stopwords.ts</path>/src/utils/config-loader.ts</path>/src/utils/performance-monitor.ts</path>/src/utils/concurrency.ts</path>/src/utils/concurrency-pool.ts</path>/src/utils/string-similarity.ts</path>/src/utils/rate-limiter.ts</path>/src/utils/system-resources.ts</path>/src/utils/adaptive-cache.ts</path>/src/utils/lazy-imports.ts</path>/src/utils/merge-claude-md.ts</path>/src/utils/stopwords.ts</path> +0 -433
package/docs/INDEX.md CHANGED
@@ -18,6 +18,7 @@ New here? Start with the [project README](../README.md), then [Getting Started](
18
18
 
19
19
  | Doc | What it covers |
20
20
  |---|---|
21
+ | [**What UAP Does Automatically**](guides/AUTOMATIC.md) | Every feature in benefit / when-it-kicks-in terms — install once, it all self-applies ⭐ |
21
22
  | [**`uap deliver`**](guides/DELIVER.md) | The delivery harness — convergence loop to verified completion ⭐ |
22
23
  | [Memory](guides/MEMORY.md) | The 4-tier memory system, write-gates, semantic recall |
23
24
  | [MCP Router](guides/MCP_ROUTER.md) | Token-optimizing tool proxy + FTS5 output compression |
@@ -28,6 +29,7 @@ New here? Start with the [project README](../README.md), then [Getting Started](
28
29
  | [Deploy Batching](guides/DEPLOY_BATCHING.md) | Conflict-free batched git/deploy actions |
29
30
  | [Coordination](guides/COORDINATION.md) | Multi-agent overlap detection |
30
31
  | [Local Models](guides/LOCAL_MODELS.md) | Running agents against local llama.cpp / Qwen models |
32
+ | [Qwen3.6 on llama.cpp by VRAM](guides/QWEN36_LLAMACPP.md) | Tiered 8/12/16/24/32 GB setup; how `uap deliver` uplifts small local models |
31
33
 
32
34
  ## Architecture
33
35
 
@@ -0,0 +1,92 @@
1
+ # What UAP Does For You — Automatically
2
+
3
+ > The whole point of UAP: **you install it once, and every feature applies itself
4
+ > as you code.** You don't call commands or remember protocols. UAP watches the
5
+ > coding agent's lifecycle (session start, every prompt, every tool call, every
6
+ > stop) and injects the right help or enforces the right guardrail *at the moment
7
+ > it's needed*.
8
+
9
+ ```bash
10
+ npx @miller-tech/uap init # one-time, per project
11
+ # …that's it. Open your coding agent and everything below is live.
12
+ ```
13
+
14
+ `init`/`setup` wire UAP into whichever agent you use — Claude Code, Cursor,
15
+ OpenCode, Factory, VSCode, Codex — by installing lifecycle hooks and the MCP
16
+ router. After that the features are **on by default and apply themselves as
17
+ appropriate**. Nothing here needs to be invoked by hand.
18
+
19
+ ---
20
+
21
+ ## How to read this
22
+
23
+ Two kinds of automatic behaviour, and they're deliberately different:
24
+
25
+ - **Assist** (dynamic, *helps* you): surfaces the right context — experts,
26
+ skills, patterns, memories — by *injecting* it where the model will see it.
27
+ It's confidence-gated, so quiet on conversational turns and rich on real
28
+ coding tasks. It never blocks; worst case it stays silent.
29
+ - **Enforce** (deterministic, *protects* you): hard guardrails that *block* a
30
+ tool call when it would violate a rule (edit outside a worktree, skip
31
+ delivery, run a dangerous command). Each has an escape hatch for the rare
32
+ sanctioned exception.
33
+
34
+ For every feature below: **what it does for you**, and **when it kicks in**.
35
+
36
+ ---
37
+
38
+ ## Assist — the right help shows up on its own
39
+
40
+ | Feature | What it does for you | When it kicks in |
41
+ |---|---|---|
42
+ | **Reactor** (dynamic routing) | On every prompt, surfaces the expert droids, skills, and enforcement patterns relevant to *this* task, so the agent works like it already knows the domain. | Every substantive prompt (`UserPromptSubmit` / per-message). Confidence-gated — silent on "thanks"/"merge it", rich on "fix the auth race condition". |
43
+ | **Memory recall** | Pulls back the lessons, decisions, and gotchas you (or another agent) learned before, so mistakes aren't repeated and context survives across sessions. | Session start (recent + high-importance memories) and per-prompt semantic recall on the task text. |
44
+ | **Pattern RAG** | Injects battle-tested execution patterns (Output-Existence, Decoder-First, Round-Trip verify, …) mined from Terminal-Bench, so the agent uses the approach that actually passes. | Per-prompt, matched to the task; full set retrievable on demand via Qdrant. |
45
+ | **Expert droids** | Routes domain work (security, performance, data, testing, …) to a specialist persona instead of a generalist guess. | When the capability router matches the task's type/files — recommended automatically, with optional auto-spawn above a confidence threshold. |
46
+ | **Skills** | Surfaces the right *procedure* (git-forensics, compression, SQLite-WAL recovery, polyglot, …) for the task at hand. | Per-prompt match against the task; top-N surfaced. |
47
+ | **Model routing** | Picks the right model tier per step (plan with the strong model, execute with the fast one) instead of one model for everything. | On task classification, by complexity and role. |
48
+
49
+ You don't ask for any of this. It appears in the agent's context the moment the
50
+ task warrants it, and stays out of the way when it doesn't.
51
+
52
+ ---
53
+
54
+ ## Enforce — the guardrails that keep work safe and verified
55
+
56
+ | Feature | What it does for you | When it kicks in |
57
+ |---|---|---|
58
+ | **Delivery enforcement** (`uap deliver`, **block by default**) | Routes substantive coding through the **convergence loop** — which iterates a model against your real gates (build, type-check, tests) until the change is *verified*, not just plausible. This is what **uplifts small local models well above their weight**: a 3B-active model that would flail on one shot succeeds when driven to green against the gates. | The moment the agent tries to edit a **source** file directly. Docs/configs/scripts/tests are exempt — only real implementation work is gated. Escape: `UAP_DELIVER_BYPASS=1`, or relax with `UAP_ENFORCE_DELIVERY=advisory`. |
59
+ | **Worktree isolation** | Forces code changes into an isolated `.worktrees/NNN-slug/` branch so you never clobber your working tree and every change is a clean, reviewable branch with an auto-PR. | Any source edit outside a worktree is blocked (`PreToolUse`). |
60
+ | **Policy / compliance gates** | Block non-compliant tool calls before they run — dangerous shell (force-push, `terraform apply`), edits that skip a schema diff, plan-before-read violations, etc. | `PreToolUse` on every Edit/Write/Bash/Task call. |
61
+ | **Schema-diff gate** | Flags breaking API/contract changes so you diff-and-verify consumers before shipping them. | After editing a schema/contract file (`*.schema.ts`, `types.ts`, `.proto`, `.graphql`, …). |
62
+ | **Completion gates** | Won't let the agent declare "done" until build/type-check/tests actually pass and a version bump happened. | On `Stop` (end of turn). |
63
+ | **Coordination** | Detects when multiple agents would touch the same files and prevents them stepping on each other. | Session start (register) + work announcement before claiming a task. |
64
+ | **rtk token-optimization** | Rewrites heavy CLI output (git/docker/npm/…) into compact form so the agent burns far fewer tokens reading command output. | Every wrapped CLI command. |
65
+ | **Deploy batching** | Queues changes into conflict-free batched commits/deploys instead of racy one-off pushes. | On `uap deliver --deploy` success. |
66
+
67
+ Each enforce-gate has a sanctioned escape hatch (an env var) for the rare case
68
+ you genuinely need to bypass it — so the guardrail is firm, not a cage.
69
+
70
+ ---
71
+
72
+ ## Behind it all
73
+
74
+ | Feature | What it does for you | When it kicks in |
75
+ |---|---|---|
76
+ | **MCP router** | Exposes a tiny meta-tool surface (`discover_tools`/`execute_tool`/`deliver`/`react`) instead of 150+ tools, cutting tool-schema tokens by ~98%. | Wired at install; used whenever the agent discovers/runs a tool. |
77
+ | **HALO trace analysis** | Mines your execution traces for systemic failure modes (loops, stalls) so the harness gets better over time. | Session end / on demand (`uap harness analyze`). |
78
+ | **4-tier memory** | Short-term (recent), long-term (semantic Qdrant), coordination, and patterns — the substrate the recall/pattern features draw from. | Continuously; written on significant decisions, read on recall. |
79
+
80
+ ---
81
+
82
+ ## The one-liner
83
+
84
+ **Install UAP, then just code.** The assist layer makes your agent act like a
85
+ domain expert with perfect recall; the enforce layer makes sure whatever it
86
+ produces is isolated, verified, and safe — and it drives even small local models
87
+ to *verified* results they couldn't reach in one shot. You never invoke any of
88
+ it; it applies itself, in the right place, at the right time.
89
+
90
+ See also: [`uap deliver`](DELIVER.md) · [Local Models](LOCAL_MODELS.md) ·
91
+ [Droids & Skills](DROIDS_AND_SKILLS.md) · [Policies](POLICIES.md) ·
92
+ the [Reactor design](../design/UAP_REACTOR.md).
@@ -7,6 +7,11 @@ UAP can drive its coding/convergence loop against **local models** served by
7
7
  This keeps inference on your own hardware (zero per-token cost) and works with
8
8
  quantized open-weight models such as Qwen 3.x.
9
9
 
10
+ > **Just want the recommended local setup?** See
11
+ > [Qwen3.6 35B-A3B on llama.cpp, by VRAM tier](QWEN36_LLAMACPP.md) for
12
+ > copy-paste launch commands for 8 / 12 / 16 / 24 / 32 GB GPUs, and how
13
+ > `uap deliver` uplifts a small local model to *verified* results.
14
+
10
15
  There are two endpoint shapes involved, and it matters which client speaks
11
16
  which protocol:
12
17
 
@@ -0,0 +1,110 @@
1
+ # Qwen3.6 35B-A3B on llama.cpp, by VRAM tier — with UAP
2
+
3
+ This is the recommended local stack for UAP: **Qwen3.6 35B-A3B** (a Mixture-of-
4
+ Experts model with only **~3B active parameters** per token) served by
5
+ **llama.cpp**, driven by **UAP's automatic features** — above all `uap deliver`,
6
+ which iterates the model against your real build/test gates until the change is
7
+ *verified*. That convergence loop is what lets a small, cheap, local model
8
+ **punch well above its weight**: one-shot it would flail; driven to green it
9
+ delivers.
10
+
11
+ Because the active footprint is ~3B, this model runs usefully even on modest
12
+ GPUs by **offloading the (sparse, mostly-idle) expert tensors to system RAM**
13
+ while keeping attention on the GPU. The knob for that is `--n-cpu-moe`.
14
+
15
+ ## Get the model
16
+
17
+ A 4-bit quant is the sweet spot for coding (quality vs. size). The full weights
18
+ are ~18–19 GB at IQ4_XS:
19
+
20
+ ```
21
+ Qwen3.6-35B-A3B-UD-IQ4_XS.gguf # ~18–19 GB on disk
22
+ # (a *-MTP.gguf build adds multi-token prediction for faster decode — use it if you have it)
23
+ ```
24
+
25
+ ## The base llama-server command
26
+
27
+ UAP speaks the OpenAI-compatible endpoint, so serve on `:8080/v1`. The flags
28
+ below are the ones that matter; the per-tier table just changes `--n-cpu-moe`,
29
+ `--ctx-size`, and the KV-cache type.
30
+
31
+ ```bash
32
+ llama-server \
33
+ --model Qwen3.6-35B-A3B-UD-IQ4_XS.gguf \
34
+ --host 0.0.0.0 --port 8080 \
35
+ --gpu-layers 99 \ # put all layers on GPU; experts get pulled back by --n-cpu-moe
36
+ --n-cpu-moe <PER TIER> \ # how many layers keep their MoE experts in CPU RAM
37
+ --ctx-size <PER TIER> \
38
+ --cache-type-k <q4_0|q8_0> --cache-type-v <q4_0|q8_0> \ # quantize KV cache to save VRAM
39
+ --flash-attn on \ # faster + less VRAM
40
+ --jinja \ # use the model's chat template (REQUIRED for tool calls)
41
+ --parallel 1
42
+ ```
43
+
44
+ > **`--jinja` / the chat template is non-negotiable for agent use.** Qwen3.6
45
+ > emits *native* OpenAI tool calls, but only when its chat template is active.
46
+ > If tools silently never fire, that's the cause — run `uap tool-calls setup`
47
+ > to install/repair the template, and `uap tool-calls status` to check.
48
+
49
+ ## VRAM tiers
50
+
51
+ Values are **starting points** — exact `--n-cpu-moe` depends on your build and
52
+ layer count. Rule of thumb: **raise `--n-cpu-moe` if you OOM, lower it for more
53
+ speed.** "System RAM" is what the offloaded experts need *in addition* to the
54
+ GPU.
55
+
56
+ | VRAM | `--n-cpu-moe` | `--ctx-size` | KV cache | System RAM | What to expect |
57
+ |---|---|---|---|---|---|
58
+ | **8 GB** | `99` (all experts → CPU) | `8192` | `q4_0` | ≥ 32 GB | Attention on GPU, all experts on CPU. Decode is CPU-bandwidth-bound (a few tok/s) — slow but *real*. `uap deliver` makes it productive by driving to verified completion instead of needing a strong one-shot. |
59
+ | **12 GB** | `~36` | `16384` | `q4_0` | ≥ 32 GB | Keep ~the top experts on GPU, rest on CPU. Noticeably faster than 8 GB. |
60
+ | **16 GB** | `~24` | `24576` | `q4_0` | ≥ 24 GB | Roughly half the experts on GPU. Comfortable for most coding tasks. |
61
+ | **24 GB** | *omit* (full model on GPU) | `32768`–`65536` | `q8_0` | 16 GB | **Sweet spot** (RTX 3090/4090). Weights + KV fit on-GPU; use `q8_0` KV for quality, `q4_0` if you want more context. Add `--flash-attn on`. |
62
+ | **32 GB** | *omit* | `131072` | `q8_0`/`f16` | 16 GB | Full model + large context. Add `--parallel 2–4` for concurrent sessions, bump `--batch-size`/`--ubatch-size`. |
63
+
64
+ Speed extras (any tier): `--flash-attn on` (always), and if your build supports
65
+ it, **self-speculation / MTP** (the `*-MTP.gguf` model, or `--draft-*` flags with
66
+ a tiny draft model) for materially faster decode.
67
+
68
+ ## Point UAP at it
69
+
70
+ ```bash
71
+ # 1) Tell UAP where the model lives (OpenAI-compatible endpoint)
72
+ export UAP_INFERENCE_ENDPOINT="http://localhost:8080/v1"
73
+ # (or set the endpoint on the model preset in .uap.json / src/models/types.ts)
74
+
75
+ # 2) Make sure tool calls work
76
+ uap tool-calls setup # install the chat template + helpers
77
+ uap tool-calls status # verify
78
+
79
+ # 3) That's it — code as normal. Everything is automatic from here.
80
+ ```
81
+
82
+ Once installed, **you don't run `uap deliver` by hand** — delivery enforcement
83
+ is on by default, so when your agent goes to implement something it's routed
84
+ through the convergence loop automatically (see
85
+ [What UAP Does For You, Automatically](AUTOMATIC.md)). If you *want* to drive a
86
+ task explicitly:
87
+
88
+ ```bash
89
+ uap deliver "implement a token-bucket rate limiter with tests"
90
+ ```
91
+
92
+ ## Why this punches above its weight
93
+
94
+ A 3B-active model rarely nails a non-trivial change in one shot. UAP changes the
95
+ game without changing the model:
96
+
97
+ - **`uap deliver`** loops execute → run-the-gates → fix → re-run until build,
98
+ type-check, and tests all pass — turning "plausible" into "verified".
99
+ - **Pattern RAG + expert routing** (automatic) put the right approach and the
100
+ right specialist persona in front of the model before it starts.
101
+ - **Memory** stops it re-making the same mistakes across turns and sessions.
102
+ - **Worktree + completion gates** keep every attempt isolated and only let
103
+ "done" mean *actually done*.
104
+
105
+ Net effect: a local, zero-per-token, 4-bit MoE model produces verified results
106
+ that a naive one-shot of a much larger model often won't — and it runs on a GPU
107
+ you already own.
108
+
109
+ See also: [Local Models](LOCAL_MODELS.md) · [`uap deliver`](DELIVER.md) ·
110
+ [Automatic features](AUTOMATIC.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miller-tech/uap",
3
- "version": "1.43.1",
3
+ "version": "1.43.3",
4
4
  "description": "Autonomous AI agent memory system with CLAUDE.md protocol enforcement",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "lint": "eslint src --ext .ts",
26
26
  "lint:fix": "eslint src --ext .ts --fix",
27
27
  "format": "prettier --write src/**/*.ts",
28
- "prepublishOnly": "npm run build && npm test",
28
+ "prepublishOnly": "npm run build && npm test && bash scripts/maintenance/ensure-exec-bits.sh",
29
29
  "install:web": "bash scripts/setup/install-web.sh",
30
30
  "install:desktop": "bash scripts/setup/install-desktop.sh",
31
31
  "install:cloakbrowser": "tsx scripts/setup/install-cloakbrowser.ts",
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # ensure-exec-bits.sh — guarantee that shipped shebang scripts are executable
3
+ # before publish. npm packs files with their filesystem mode, so a tracked
4
+ # script committed as 100644 ships non-executable. Runs in prepublishOnly.
5
+ #
6
+ # Scope: shipped dirs only (must match package.json "files"). Only files that
7
+ # begin with a shebang (#!) are touched; imported .ts/.cjs modules and .j2
8
+ # templates are left alone (a leading shebang on a module is ignored at import).
9
+ set -euo pipefail
10
+ cd "$(dirname "$0")/../.."
11
+
12
+ SHIPPED=(src/policies/enforcers tools/agents templates config scripts/setup scripts/maintenance dist)
13
+ fixed=0
14
+ while IFS= read -r f; do
15
+ [ -f "$f" ] || continue
16
+ case "$f" in *.ts|*.j2|*.d.ts) continue ;; esac
17
+ if head -c2 "$f" 2>/dev/null | grep -q '#!' && [ ! -x "$f" ]; then
18
+ chmod +x "$f"
19
+ echo "ensure-exec-bits: +x $f"
20
+ fixed=$((fixed + 1))
21
+ fi
22
+ done < <(git ls-files -- "${SHIPPED[@]}" 2>/dev/null | grep -E '\.(sh|py|cjs)$')
23
+
24
+ echo "ensure-exec-bits: ${fixed} script(s) made executable"
25
+ exit 0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,433 +0,0 @@
1
- # UAP Project Code Analysis and Documentation Audit Report
2
-
3
- ## Executive Summary
4
-
5
- The Universal Agent Protocol (UAP) is a comprehensive AI agent framework with extensive functionality for persistent memory, multi-agent coordination, pattern-based workflows, and policy enforcement. The project contains approximately 143 TypeScript source files, 74 test files, and over 9 total files (including benchmark results and agent sessions).
6
-
7
- ## Documentation Quality Assessment
8
-
9
- ### Current State: GOOD TO VERY GOOD
10
-
11
- **Strengths:**
12
- - Comprehensive README.md (542 lines) with feature overview, CLI reference, and architecture diagrams
13
- - Extensive CLI reference documentation (620 lines in UAP_CLI_REFERENCE.md)
14
- - Architecture documentation covering system design and components
15
- - Benchmark results and validation plans documented
16
- - Integration guides for multiple platforms (Claude, Factory, OpenCode, etc.)
17
- - Documentation version mismatch (README shows v1.20.32, INDEX.md shows v1.18.0)
18
- - Some CLI commands in code don't match documentation
19
- - Limited inline JSDoc comments in source files
20
- - Outdated architecture diagrams with placeholder text
21
- - Missing documentation for several internal modules
22
-
23
- ## Feature Inventory
24
-
25
- ### 1. Memory System (27+ modules)
26
- **Well-documented:**
27
- - Hierarchical memory (Hot/Warm/Cold tiers)
28
- - Embedding service with multiple providers
29
- - Knowledge graph implementation
30
- - Semantic compression
31
- - Write gate quality filtering
32
- - Daily log staging area
33
-
34
- **Under-documented:**
35
- - Predictive memory service
36
- - Context pruner (token-budget-aware)
37
- - Ambiguity detector (P37 pattern)
38
- - Prepopulation from docs/git history
39
- - Memory maintenance routines
40
- - Correction propagator for cross-tier updates
41
-
42
- ### 2. Multi-Agent Coordination (8 modules)
43
- **Well-documented:**
44
- - Coordination service and database
45
- - Agent lifecycle management
46
- - Work claims and announcements
47
- - Messaging system with channels
48
- - Deploy batching with configurable windows
49
-
50
- **Under-documented:**
51
- - Capability router (18 capability types)
52
- - Auto-agent registration
53
- - Pattern router implementation
54
- - Adaptive patterns with success tracking
55
-
56
- ### 3. Policy Enforcement (8 modules)
57
- **Well-documented:**
58
- - Policy schema and database manager
59
- - Policy memory CRUD operations
60
- - Enforcement levels (REQUIRED/RECOMMENDED/OPTIONAL)
61
- - Audit trail functionality
62
-
63
- **Under-documented:**
64
- - Policy gate middleware implementation
65
- - Enforced tool router
66
- - Python enforcement tools
67
- - Policy converter to CLAUDE.md format
68
-
69
- ### 4. Pattern System (23+ patterns)
70
- **Well-documented:**
71
- - Pattern list with descriptions
72
- - Critical patterns (P12, P35) always active
73
- - Pattern RAG management
74
-
75
- **Under-documented:**
76
- - Pattern matching algorithm
77
- - Pattern library storage format
78
- - Pattern success tracking metrics
79
- - Custom pattern creation guide
80
-
81
- ### 5. Worktree System
82
- **Well-documented:**
83
- - CLI commands (create, list, pr, cleanup, finish)
84
- - Git workflow integration
85
- - Exempt paths documentation
86
-
87
- **Under-documented:**
88
- - Worktree file guard enforcement mechanism
89
- - Branch naming conventions
90
- - Conflict resolution strategies
91
- - Prune functionality details
92
-
93
- ### 6. Hooks System
94
- **Well-documented:**
95
- - Session start hook (5 steps)
96
- - Pre-compact hook (4 steps)
97
- - Platform-specific installations
98
- - Hook status checking
99
-
100
- **Under-documented:**
101
- - Pre-tool-use hooks (mentioned but not detailed)
102
- - Post-tool-use hooks
103
- - Custom hook creation guide
104
- - Hook failure recovery
105
-
106
- ### 7. MCP Router
107
- **Well-documented:**
108
- - 98% token reduction claim
109
- - Meta-tool routing concept
110
- - Config parser and fuzzy search
111
-
112
- **Under-documented:**
113
- - Client pool management
114
- - Output compression algorithm
115
- - Session statistics tracking
116
- - Tool discover/execute definitions
117
-
118
- ### 8. Multi-Model Architecture
119
- **Well-documented:**
120
- - 3-tier execution model
121
- - 13 model profiles
122
- - Dynamic temperature and rate limiting
123
- - Model analytics
124
-
125
- **Under-documented:**
126
- - Task planner decomposition algorithm
127
- - Plan validator cycle detection
128
- - Unified router logic
129
- - Execution profile loading
130
-
131
- ### 9. Browser Automation
132
- **Well-documented:**
133
- - CloakBrowser integration
134
- - Playwright drop-in compatibility
135
- - Basic usage example
136
-
137
- **Under-documented:**
138
- - Stealth techniques
139
- - Humanize mode details
140
- - Error handling
141
- - Performance characteristics
142
-
143
- ### 10. Task Management
144
- **Well-documented:**
145
- - Task types and statuses
146
- - Priority levels (P0-P4)
147
- - Dependencies and claims
148
- - JSONL sync format
149
-
150
- **Under-documented:**
151
- - Event bus implementation
152
- - Decoder gate mechanism
153
- - Task classifier (9 categories)
154
- - Compaction/archive logic
155
-
156
- ### 11. Droids & Skills
157
- **Well-documented:**
158
- - 8 expert droids listed
159
- - 33 skills categorized
160
- - Skill documentation command
161
-
162
- **Under-documented:**
163
- - Droid creation process
164
- - Skill loading mechanism
165
- - Custom droid development
166
- - Skill composition patterns
167
-
168
- ## Documentation Gaps by Priority
169
-
170
- ### CRITICAL (Must-Have)
171
-
172
- 1. **Inline JSDoc for Public APIs**
173
- - Missing from src/index.ts exports (340 lines of exports)
174
- - Affects: Memory system, coordination, policies, models, MCP router
175
- - autocomplete and API documentation generation
176
-
177
- 2. **CLI Command Completeness**
178
- - Dashboard has 11 views but only partially documented
179
- - Model commands (8 subcommands) under-documented
180
- - Policy commands (15 subcommands) need examples
181
- - Worktree finish command behavior not explained
182
-
183
- 3. **Configuration Schema Documentation**
184
- - .uap.json schema incomplete
185
- - Missing validation rules
186
- - Environment variables not fully listed
187
-
188
- 4. **Database Schema Accuracy**
189
- - API_REFERENCE.md shows outdated table structures
190
- - Missing tables: deploy_queue, pattern_index, task_events
191
- - Qdrant collection schemas not documented
192
-
193
- 5. **Hook System Implementation Details**
194
- - Pre-edit build gate enforcement mechanism
195
- - Worktree file guard blocking logic
196
- - Completion gate verification steps
197
-
198
- ### HIGH PRIORITY (Should-Have)
199
-
200
- 6. **Memory System Architecture Diagram**
201
- - Current diagram has placeholder text
202
- - 4-layer architecture needs visual representation
203
- - Data flow between tiers unclear
204
-
205
- 7. **Pattern Library Reference**
206
- - All 23+ patterns need detailed descriptions
207
- - Pattern selection criteria missing
208
- - Pattern composition examples
209
-
210
- 8. **Multi-Agent Coordination Flow**
211
- - Heartbeat mechanism details
212
- - Overlap detection algorithm
213
- - Message priority handling
214
- - Deadlock prevention
215
-
216
- 9. **Policy Enforcement Workflow**
217
- - Policy evaluation order
218
- - Violation handling procedures
219
- - Audit trail query examples
220
-
221
- 10. **Testing and Quality Gates**
222
- - Test coverage requirements (50% threshold)
223
- - Build gate enforcement
224
- - Completion gate verification steps
225
-
226
- ### MEDIUM PRIORITY (Nice-to-Have)
227
-
228
- 11. **Benchmark Methodology**
229
- - Terminal-Bench adapter details
230
- - Harbor integration workflow
231
- - A/B comparison methodology
232
-
233
- 12. **Deployment Guides**
234
- - Production Qdrant setup
235
- - CI/CD pipeline configuration
236
- - Horizontal scaling patterns
237
-
238
- 13. **Troubleshooting Matrix**
239
- - Error code reference
240
- - Common failure modes
241
- - Recovery procedures
242
-
243
- 14. **Integration Patterns**
244
- - RTK token compression details
245
- - Platform-specific optimizations
246
- - Custom adapter development
247
-
248
- 15. **Performance Optimization Guide**
249
- - Token budget management
250
- - Cache warm strategies
251
- - Memory pruning thresholds
252
-
253
- ## Specific Recommendations
254
-
255
- ### Immediate Actions (Week 1-2)
256
-
257
- 1. **Add JSDoc to src/index.ts**
258
- ```typescript
259
- /**
260
- * Hierarchical memory manager with hot/warm/cold tiering
261
- * @see src/memory/hierarchical-memory.ts for implementation details
262
- */
263
- export { HierarchicalMemoryManager } from './memory/hierarchical-memory.js';
264
- documentation/architecture diagrams**
265
- - Replace placeholder text in docs/INDEX.md
266
- - Create Mermaid diagrams for memory flow
267
- - Document data persistence layers
268
-
269
- 3. **Complete CLI Reference**
270
- - Add all 109 commands with examples
271
- - Include exit codes and error messages
272
- - Document shell completion setup
273
-
274
- 4. **Fix Version Mismatch**
275
- - Update INDEX.md to v1.20.32
276
- - Ensure CHANGELOG.md is current
277
- - Sync README version numbers
278
-
279
- 5. **Document Database Schemas**
280
- - Update API_REFERENCE.md with actual tables
281
- - Add Qdrant collection schemas
282
- - Include migration guides
283
-
284
- ### Short-Term Actions (Week 3-4)
285
-
286
- 6. **Create Module-Level Documentation**
287
- - Add README.md to each src/ subdirectory
288
- - Document module responsibilities and dependencies
289
- - Include usage examples
290
-
291
- 7. **Build Pattern Library Reference**
292
- - Document all 23+ patterns with use cases
293
- - Add pattern selection decision tree
294
- - Create pattern composition examples
295
-
296
- 8. **Enhance Hook Documentation**
297
- - Document all hook types (pre/post tool-use)
298
- - Add hook failure recovery guide
299
- - Include custom hook templates
300
-
301
- 9. **Complete Configuration Guide**
302
- - Full .uap.json schema with validation
303
- - Environment variable reference
304
- - Platform-specific configs
305
-
306
- 10. **Add Testing Documentation**
307
- - Test coverage requirements
308
- - Build gate enforcement
309
- - Completion gate checklist
310
-
311
- ### Long-Term Actions (Month 2+)
312
-
313
- 11. **Generate API Documentation**
314
- - Use TypeDoc for TypeScript APIs
315
- - Integrate with GitHub Pages
316
- - Keep in sync with code changes
317
-
318
- 12. **Create Video Tutorials**
319
- - Quick start walkthrough
320
- - Advanced feature demonstrations
321
- - Troubleshooting guides
322
-
323
- 13. **Develop Interactive Examples**
324
- - Code sandbox for CLI commands
325
- - Memory system visualization
326
- - Multi-agent simulation
327
-
328
- 14. **Establish Documentation Review Process**
329
- - Require docs updates with PRs
330
- - Add docs linting to CI
331
- - Schedule quarterly reviews
332
-
333
- 15. **Create Contribution Guide**
334
- - Documentation standards
335
- - Template examples
336
- - Review process
337
-
338
- ## Proposed Documentation Structure
339
-
340
- ### Current Structure (Adequate)
341
- ```
342
- docs/
343
- ├── getting-started/ ✓ Good coverage
344
- ├── architecture/ ⚠ Needs updates
345
- ├── reference/ ✓ CLI ref good, API ref outdated
346
- ├── deployment/ ⚠ Incomplete
347
- ├── benchmarks/ ✓ Comprehensive
348
- ├── operations/ ⚠ Minimal
349
- ├── integrations/ ✓ Good coverage
350
- ├── research/ ⚠ Academic focus
351
- └── archive/ ℹ Historical reference
352
- ```
353
-
354
- ### Proposed Enhanced Structure
355
- ```
356
- docs/
357
- ├── getting-started/
358
- │ ├── QUICKSTART.md ← New: 5-minute setup
359
- │ ├── INSTALLATION.md ← Updated: Platform-specific
360
- │ └── TROUBLESHOOTING.md ← Merged from operations/
361
- │ ├── memory-system.md
362
- │ ├── coordination.md
363
- │ ├── patterns.md
364
- │ └── policies.md
365
- ├── architecture/
366
- │ ├── OVERVIEW.md ← Updated with diagrams
367
- │ ├── COMPONENTS.md ← New: Module details
368
- │ ├── DATA_FLOW.md ← New: Data persistence
369
- │ └── SCHEMAS.md ← Updated: Database specs
370
- ├── reference/
371
- │ ├── CLI_REFERENCE.md ✓ Complete
372
- │ ├── API_REFERENCE.md ← Updated with JSDoc
373
- │ ├── CONFIG_SCHEMA.md ← New: Full schema
374
- │ └── ERROR_CODES.md ← New: Error reference
375
- ├── guides/ ← New: Practical tutorials
376
- │ ├── memory-best-practices.md
377
- │ ├── multi-agent-setup.md
378
- │ ├── policy-enforcement.md
379
- │ ├── pattern-library.md
380
- │ └── worktree-workflow.md
381
- ├── deployment/
382
- │ ├── PRODUCTION.md ← Updated
383
- │ ├── CI_CD.md ← Updated
384
- │ ├── SCALING.md ← New: Horizontal scaling
385
- │ └── MONITORING.md ← New: Observability
386
- ├── benchmarks/ ✓ Comprehensive
387
- ├── operations/
388
- │ ├── MAINTENANCE.md ← New: Routine tasks
389
- │ ├── BACKUP_RESTORE.md ← New: Disaster recovery
390
- │ └── DEBUGGING.md ← Updated: Debug modes
391
- ├── integrations/ ✓ Good coverage
392
- ├── contributed/ ← New: Community content
393
- └── archive/ ℹ Historical reference
394
- ```
395
-
396
- ## Test Coverage Analysis
397
-
398
- ### Current State
399
- - 74 test files covering major components
400
- - Tests for: policies, memory, coordination, models, benchmarks, CLI
401
- - Vitest configuration with coverage thresholds (50%)
402
-
403
- ### Gaps
404
- 1. **Browser module** - Minimal test coverage
405
- 2. **MCP router** - Only output-compressor tested
406
- 3. **Dashboard** - Server and event-stream not tested
407
- 4. **Telemetry** - Session telemetry untested
408
- 5. **Benchmarks** - Agent implementations not tested
409
-
410
- ### Recommendations
411
- 1. Add JSDoc to test files for clarity
412
- 2. Create integration test suite
413
- 3. Document test coverage requirements
414
- 4. Add performance test benchmarks
415
-
416
- ## Conclusion
417
-
418
- The UAP project has **solid foundational documentation** with comprehensive CLI references and good architectural overviews. However, there are significant gaps in:
419
- - Inline code documentation (JSDoc)
420
- 2. Module-level documentation for internal components
421
- 3. Accurate database schemas
422
- 4. Configuration schema completeness
423
- 5. Hook system implementation details
424
-
425
- **Priority Ranking:**
426
- - **Must-Have**: JSDoc, CLI completeness, config schema, DB schemas, hook docs
427
- - Architecture diagrams, pattern library, coordination flows, policy workflows, testing docs
428
- - **Nice-to-Have**: Video tutorials, interactive examples, contribution guide, API generation
429
- - Critical fixes: 2-3 weeks
430
- - High priority: 4-6 weeks
431
- - Medium priority: 8-12 weeks
432
-
433
- The documentation quality is sufficient for current users but needs improvement to support new contributors and maintain long-term project health.