@ngockhoale/ukit 2.6.7 → 2.6.9

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 (55) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/manifests/documentation.yaml +77 -6
  3. package/manifests/hostCapabilities.yaml +49 -0
  4. package/manifests/instructionRules.yaml +7 -0
  5. package/package.json +1 -1
  6. package/scripts/bench/goldTasks.json +38 -0
  7. package/scripts/bench/runGold.mjs +220 -0
  8. package/scripts/index/build-index.mjs +2 -1
  9. package/scripts/index/query-index.mjs +2 -0
  10. package/scripts/release/verify-release.mjs +6 -0
  11. package/src/cli/commands/code.js +182 -0
  12. package/src/cli/commands/doctor.js +35 -3
  13. package/src/cli/commands/indexTools.js +107 -1
  14. package/src/cli/commands/install.js +2 -1
  15. package/src/cli/commands/memory.js +137 -0
  16. package/src/cli/index.js +7 -0
  17. package/src/core/codeintel/analogy.js +197 -0
  18. package/src/core/codeintel/cochange.js +205 -0
  19. package/src/core/codeintel/compiler.js +389 -0
  20. package/src/core/codeintel/diagnostics.js +114 -0
  21. package/src/core/codeintel/freshness.js +295 -0
  22. package/src/core/codeintel/graph.js +291 -0
  23. package/src/core/codeintel/impact.js +274 -0
  24. package/src/core/codeintel/invalidation.js +150 -0
  25. package/src/core/codeintel/manifest.js +176 -0
  26. package/src/core/codeintel/packet.js +147 -0
  27. package/src/core/codeintel/providers.js +201 -0
  28. package/src/core/codeintel/retriever.js +418 -0
  29. package/src/core/codeintel/router.js +149 -0
  30. package/src/core/codeintel/semanticProvider.js +235 -0
  31. package/src/core/codeintel/summaries.js +194 -0
  32. package/src/core/codeintel/vectorProvider.js +213 -0
  33. package/src/core/docContracts.js +723 -0
  34. package/src/core/memory/migrate.js +324 -0
  35. package/src/core/memory/records.js +172 -0
  36. package/src/core/memory/retrieval.js +161 -11
  37. package/src/core/memory/store.js +398 -0
  38. package/src/core/memory/storeV2.js +171 -0
  39. package/src/core/memory/storeV2Loader.js +22 -0
  40. package/src/core/runtimeConfig.js +173 -0
  41. package/src/core/runtimePaths.js +3 -0
  42. package/src/index/buildIndex.js +29 -0
  43. package/src/index/paths.js +2 -0
  44. package/src/index/taskRouting.js +39 -0
  45. package/templates/.claude/ukit/index/route-task.mjs +40 -0
  46. package/templates/AGENTS.md +46 -99
  47. package/templates/CLAUDE.md +46 -99
  48. package/templates/docs/AI_HANDOFF/tasks/_TEMPLATE.md +5 -0
  49. package/templates/docs/BUGFIX.md +2 -19
  50. package/templates/docs/BUG_INDEX.md +43 -0
  51. package/templates/docs/BUG_METRICS.md +1 -5
  52. package/templates/docs/BUG_TEMPLATE.md +1 -11
  53. package/templates/docs/UKIT_INTERNALS.md +4 -0
  54. package/templates/instructions/core.md +46 -99
  55. package/templates/ukit/storage/config.json +35 -0
@@ -10,3 +10,46 @@ Append-only recurring bug signatures.
10
10
  - Files changed:
11
11
  - Tests used:
12
12
  - Commit/PR:
13
+
14
+ ## Bugfix SOP
15
+
16
+ ### Objective
17
+ Giảm thời gian fix bug bằng cách ưu tiên bằng chứng + index codebase trước khi đọc sâu docs/source.
18
+
19
+ ### Required Commands
20
+ - `node .claude/ukit/index/build-index.mjs`
21
+ - `node .claude/ukit/index/query-index.mjs "<error|symbol|path>"`
22
+ - `node .claude/ukit/index/triage.mjs "<error signature>"`
23
+
24
+ ### Decision Tree
25
+ 1. Có repro command rõ ràng -> chạy triage index.
26
+ 2. Lane fast: mở tối đa 1-3 suspect files, patch nhỏ, verify test mục tiêu.
27
+ 3. Fail 2 vòng 15 phút liên tiếp -> chuyển lane deep.
28
+ 4. Lane deep: instrumentation + root-cause tracing trước khi sửa.
29
+
30
+ ### Hard Rules
31
+ - Không sửa khi chưa có evidence (failing test / stack trace / logs).
32
+ - Không refactor lớn trong bug ticket.
33
+ - Verify tối thiểu: test fail ban đầu + test liên quan.
34
+
35
+ ## Intake Template
36
+
37
+ - Title:
38
+ - Priority: P0/P1/P2/P3
39
+ - Repro command:
40
+ - Expected vs Actual:
41
+ - Error signature:
42
+ - Stack trace excerpt:
43
+ - Index triage output (`node .claude/ukit/index/triage.mjs "..."`):
44
+ - Suspect files (top 3):
45
+ - Lane (fast/deep):
46
+ - Hypothesis:
47
+ - Verify commands:
48
+
49
+ ## Metrics Baseline
50
+
51
+ Track weekly:
52
+ - MTTR P2/P3
53
+ - First-pass fix rate
54
+ - Avg files opened per simple bug
55
+ - Fast-lane usage rate
@@ -1,7 +1,3 @@
1
1
  # Bug Metrics
2
2
 
3
- Track weekly:
4
- - MTTR P2/P3
5
- - First-pass fix rate
6
- - Avg files opened per simple bug
7
- - Fast-lane usage rate
3
+ Consolidated into `docs/BUG_INDEX.md` — see section "Metrics Baseline" (DOC-205).
@@ -1,13 +1,3 @@
1
1
  # Bug Intake Template
2
2
 
3
- - Title:
4
- - Priority: P0/P1/P2/P3
5
- - Repro command:
6
- - Expected vs Actual:
7
- - Error signature:
8
- - Stack trace excerpt:
9
- - Index triage output (`node .claude/ukit/index/triage.mjs "..."`):
10
- - Suspect files (top 3):
11
- - Lane (fast/deep):
12
- - Hypothesis:
13
- - Verify commands:
3
+ Consolidated into `docs/BUG_INDEX.md` — see section "Intake Template" (DOC-205).
@@ -48,6 +48,10 @@ the root contract is the only carrier — keep both in sync with
48
48
  [--target <file>]` when routing is complex or ambiguous.
49
49
  - Prefer `node .claude/ukit/index/resolve-context.mjs ...` for indexed related-file context.
50
50
  - Prefer `node .claude/ukit/index/verify-context.mjs ...` for concrete verification lanes.
51
+ - Context-layer docs are declared in `manifests/documentation.yaml` (`context_layers`) and
52
+ surfaced in the route summary line via the `docs=[...]` basename segment
53
+ (`routeSummary.contextDocs`; DOC-201). The routing-side copy is `CONTEXT_LAYER_DOCS` in
54
+ `src/index/taskRouting.js` / `route-task.mjs` — keep it in sync with the manifest.
51
55
  - Do not ask normal contributors to memorize `ukit doctor`, `ukit diff`, `ukit uninstall`,
52
56
  or `ukit index ...` unless they explicitly need maintainer/debug help.
53
57
  - If the workspace needs a refresh, prefer telling them to rerun `ukit install`.
@@ -1,210 +1,157 @@
1
1
  ## Core Rule
2
2
  <!-- RULES: CORE-01 CORE-02 -->
3
-
4
- - Human-facing UKit workflow should collapse to one remembered command: `ukit install`.
3
+ - Human-facing UKit workflow collapses to one remembered command: `ukit install`.
5
4
  - After install, default to natural-language work inside **Claude Code / Codex / OpenCode / omp**.
6
5
  - **Quality first, then speed, then token discipline.**
7
- - **Never stop after read-only steps.** For implement/apply/fix requests, continue to actual Edit/Write and verification in the same turn.
6
+ - **Never stop after read-only steps** — implement/apply/fix requests continue to Edit/Write + verification in the same turn.
8
7
 
9
8
  ## Fast Classification
10
-
11
9
  <!-- RULE: CLS-01 -->
12
- - **Trivial** — typo, label, small rename, spacing, toggle flag, obvious config change.
13
- - Act directly. No doc reads. No planning. No index. No agents.
10
+ - **Trivial** — typo, label, small rename, spacing, toggle flag, obvious config change. Act directly. No doc reads, planning, index, or agents.
14
11
  <!-- RULE: CLS-02 -->
15
- - **Simple** — 1-2 files, clear scope, existing pattern.
16
- - Handle directly. Pull only the smallest useful context via resolver or targeted read.
12
+ - **Simple** — 1-2 files, clear scope, existing pattern. Handle directly; pull only the smallest useful context via resolver or targeted read.
17
13
  <!-- RULE: CLS-03 -->
18
- - **Non-trivial / Risky** — auth, security, migration, uninstall, shared runtime, race/flaky, data-loss.
19
- - Read deeper, verify harder, and avoid shortcuts.
20
- - Use index-first loop, then skill activation, then targeted verification.
14
+ - **Non-trivial / Risky** — auth, security, migration, uninstall, shared runtime, race/flaky, data-loss. Read deeper, verify harder; index-first loop → skill activation → targeted verification.
21
15
 
22
16
  ## Execution Contract (mandatory)
23
-
24
17
  <!-- RULE: EXEC-01 -->
25
- - For explicit implement/apply/fix requests, **continue until the actual edit is made** or a real blocker is found.
26
- - Do NOT stop after a read-only inspection step (Read/Grep/Glob/search).
18
+ - For explicit implement/apply/fix requests, **continue until the actual edit is made** or a real blocker is found — never stop after a read-only inspection step.
27
19
  <!-- RULE: EXEC-03 -->
28
- - If routed state says `pull-indexed-context`, treat it as an internal continuation step, not a stopping point — after the bounded read, **continue to edit/verify in the same turn** when safe.
29
- - If routed state shows `continuation required` or a stuck-lane rescue mode, finish the named milestone before widening reads or repeating analysis.
20
+ - Routed states like `pull-indexed-context` or `continuation required` — treat it as an internal continuation step, not a stopping point; finish the named milestone before widening reads.
30
21
  <!-- RULE: EXEC-02 -->
31
- - **Do NOT say "done", "applied", or "fixed" after Read/Grep/analysis alone.** Completion wording requires concrete Edit/Write evidence in the current turn, and verification when the scope is risky.
22
+ - **Do NOT say "done"/"applied"/"fixed" after Read/Grep/analysis alone** — completion wording requires concrete Edit/Write evidence this turn, plus verification when scope is risky.
32
23
  <!-- RULE: EXEC-04 -->
33
- - **Every stop says why — no silent idle.** When a turn ends because only the user can act (login, approval, protected-file edit), open the reply with one line naming the exact action: `WAITING ON YOU: <command/action>`, and schedule a one-shot wakeup (~20-30 min) when the harness provides one so the session re-checks and auto-continues once the user has acted. An ended turn cannot observe external/auth changes by itself, so without that line (and the wakeup) the idle session looks identical to a stall. Any error — failed command, hook, test, publish — is reported verbatim in the same turn, never silently retried past the user.
24
+ - **Every stop says why — no silent idle.** Turns ending on a user-only action open with `WAITING ON YOU: <command/action>` plus a one-shot wakeup (~20-30 min) when available — an ended turn cannot observe external changes, so without it idle looks identical to a stall. Report any error verbatim the same turn.
34
25
 
35
26
  ## Long-Run Continuity
36
27
  <!-- RULES: LONG-01 LONG-02 -->
37
-
38
28
  - Near token-cap: **LAND one thing** end-to-end (edit + verify, ≤3 tool calls), **DEFER** the rest into `docs/STATUS.md` or bounded `docs/AI_HANDOFF/` tasks, **DELEGATE** broad work to subagents. Only then compact.
39
- - After any compact or handoff: continue from the persisted disk state — never reread pre-compact context; delegate broad work, keep replies short.
40
- - A run ends only on completion evidence, a genuine blocker, or a user-only action — every such stop names its reason (Execution Contract). Detail: `docs/UKIT_INTERNALS.md`.
29
+ - After any compact or handoff: continue from persisted disk state — never reread pre-compact context; delegate broad work, keep replies short.
30
+ - A run ends only on completion evidence, a genuine blocker, or a user-only action — every stop names its reason. Detail: `docs/UKIT_INTERNALS.md`.
41
31
 
42
32
  ## Index-First Loop
43
-
44
- For any task that needs code context:
33
+ For any task needing code context:
45
34
 
46
35
  <!-- RULE: IDX-01 -->
47
- 1. Check if index is fresh (`.cache/index/` artifacts). If stale or missing, refresh (`node .claude/ukit/index/refresh-index.mjs`).
48
- 2. Query likely files: `node .claude/ukit/index/query-index.mjs "<error|symbol|path>"`.
49
- 3. For bug signatures: `node .claude/ukit/index/triage.mjs "<error signature>"`.
36
+ 1. Check the index is fresh (`.cache/index/`); if stale/missing, refresh via `node .claude/ukit/index/refresh-index.mjs`.
37
+ 2. Query files: `node .claude/ukit/index/query-index.mjs "<error|symbol|path>"`; bug signatures: `triage.mjs "<error signature>"`.
50
38
  <!-- RULE: IDX-02 -->
51
- 4. Open only the **top 1-3 suspect files first**, then widen if needed. `query-index`/`resolve-context` print an `outline:` block — jump straight to `Read(file, offset=<line>)`.
39
+ 3. Open only the **top 1-3 suspect files first**, then widen if needed — the `outline:` block lets you jump straight to `Read(file, offset=<line>)`.
52
40
  <!-- RULE: IDX-03 -->
53
- The outline locates code; it does not describe behaviour. **Any code you are about to change must still be read.**
54
- 5. For analog/reuse patterns, check if `resolve-context` returns related existing patterns.
55
-
56
- For clearly non-code specialist lanes (docs-only, status, task queue), skip the source-code index.
41
+ The outline locates code; it does not describe behaviour — **any code you are about to change must still be read**.
42
+ 4. For analog/reuse patterns, check `resolve-context`. Non-code lanes (docs-only, status, task queue) skip the source-code index.
57
43
 
58
44
  ## Automatic Skill Activation (mandatory)
59
-
60
- - End users should not need to know skill names.
61
45
  <!-- RULE: SKILL-01 -->
62
- - On every non-trivial task — and again after the first relevant tool calls — inspect installed project-local skills and **auto-activate the matching skill immediately**.
63
- - Match from both prompt wording and tool/file evidence.
46
+ - On every non-trivial task — and again after the first relevant tool calls — inspect installed project-local skills and **auto-activate the matching skill immediately**; end users should not need skill names. Match from prompt wording and tool/file evidence.
64
47
  <!-- RULES: SKILL-02 SKILL-03 -->
65
- - Use the smallest effective set, usually 1-2 skills; if evidence becomes more specific than the original prompt, upgrade the active skill choice immediately.
66
- - Prefer routed context and routed verification over ad-hoc broad reading; reuse `.claude/ukit/skill-router-state.json` when it already carries compact route memory.
48
+ - Use the smallest effective set (usually 1-2 skills); if evidence sharpens, upgrade the active skill choice immediately.
49
+ - Prefer routed context/verification over ad-hoc broad reading; reuse `.claude/ukit/skill-router-state.json` compact route memory.
67
50
 
68
51
  ### Common skill triggers
69
52
 
70
- - review / audit / diff / PR feedback → `.claude/skills/code-review/SKILL.md`
71
- - bug / error / crash / triage / failing path → `.claude/skills/debugging-toolkit/SKILL.md`
72
- - test / spec / coverage / fixture → `.claude/skills/testing-quality/SKILL.md`
73
- - docs / README / changelog / handoff / editing `docs/` / cleaning `docs/TASKS.md` → `.claude/skills/docs-quality/SKILL.md`
74
- - open-ended next step / project status / continue with no concrete target / choose queued task → `.claude/skills/next-step/SKILL.md`
75
- - explicit handoff / wrap up / update `docs/STATUS.md` → `.claude/skills/update-status/SKILL.md`
76
- - auth / security / token / permission / validation / risky shell-path-delete-db work → `.claude/skills/discover-security/SKILL.md`
77
- - stale workspace / reinstall / cleanup / maintenance → `.claude/skills/repo-maintenance/SKILL.md`
53
+ - review / audit / diff / PR feedback → `code-review` · bug / error / crash / triage → `debugging-toolkit` · test / spec / coverage / fixture → `testing-quality`
54
+ - docs / README / changelog / handoff / `docs/` edits → `docs-quality` (`.claude/skills/docs-quality/SKILL.md`) · open-ended / status / continue / queued task → `next-step` · wrap up / `docs/STATUS.md` update → `update-status`
55
+ - auth / security / token / permission / risky work → `discover-security` · stale workspace / reinstall / cleanup → `repo-maintenance` (all under `.claude/skills/<name>/SKILL.md`)
78
56
 
79
57
  ## Internal Helper Policy
80
-
81
58
  <!-- RULES: HELP-01 HELP-02 -->
82
- - Prefer the internal index helpers (`node .claude/ukit/index/route-task.mjs`, `resolve-context.mjs`, `verify-context.mjs`) for routing, related-file context, and verification lanes.
59
+ - Prefer the internal index helpers (`node .claude/ukit/index/route-task.mjs`, `resolve-context.mjs`, `verify-context.mjs`) for routing, related-file context, and verification.
83
60
  - **Do not ask normal contributors to run internal helper commands** or memorize maintainer commands (`ukit doctor`, `ukit diff`, `ukit uninstall`) — run them yourself.
84
61
  <!-- RULE: FALLBACK-01 -->
85
- - If the workspace needs a refresh or runtime files are missing/corrupt, tell maintainers to rerun `ukit install`. Detail: `docs/UKIT_INTERNALS.md`.
62
+ - Missing/corrupt runtime files or stale workspace → tell maintainers to rerun `ukit install`. Detail: `docs/UKIT_INTERNALS.md`.
86
63
 
87
64
  ## Skill Quality (maintainer-only)
88
-
89
- - When editing a template skill/agent under `templates/.claude/`, read `.claude/skills/skill-quality/SKILL.md` before shipping the change.
65
+ - When editing a template skill/agent under `templates/.claude/`, read `.claude/skills/skill-quality/SKILL.md` before shipping.
90
66
 
91
67
  ## UKit v{{ukit.version}} Shared Runtime
92
-
93
- - Shared runtime state lives in `.ukit/storage/`; `.ukit/storage/config.json` is the source of runtime toggles (compact, token pipeline, router, memory, validation, Safe Patch).
94
- - Reuse `.ukit/storage/memory/` and `ukit memory recall "<current task>"` before asking users to restate decisions or widening doc reads; maintainers can inspect state with `ukit status` / `ukit memory export`.
95
- - Shared route memory lives in `.claude/ukit/skill-router-state.json`; reuse compact `previous-context`/`recent-output` first.
96
- - If runtime files are missing/corrupt or an old visible `ukit/` root remains, rerun `ukit install`. Cache state (`.ukit/storage/cache/output-history.json`, tee/) + Codex handoff detail: `docs/UKIT_INTERNALS.md`.
68
+ - Runtime state lives in `.ukit/storage/`; `.ukit/storage/config.json` holds runtime toggles (compact, token pipeline, router, memory, validation, Safe Patch).
69
+ - Reuse `.ukit/storage/memory/` + `ukit memory recall "<current task>"` before asking users to restate decisions; inspect via `ukit status` / `ukit memory export`.
70
+ - Route memory: `.claude/ukit/skill-router-state.json` — reuse compact `previous-context`/`recent-output` first. Cache state: `.ukit/storage/cache/output-history.json`, tee/. Missing/corrupt runtime or old `ukit/` root → rerun `ukit install`. Detail: `docs/UKIT_INTERNALS.md`.
97
71
 
98
72
  ## Prompt Caching
99
73
  <!-- RULES: CTX-01 CTX-02 CTX-03 CTX-04 CTX-05 CTX-06 CTX-07 CTX-08 CTX-09 CTX-10 -->
100
-
101
- - Full ruleset: `docs/PROMPT_CACHING.md` (read on demand; it is not loaded into every session).
74
+ - Full ruleset: `docs/PROMPT_CACHING.md` (read on demand; not loaded every session).
102
75
  - CTX-01 deterministic segment bytes · CTX-02 keep roles and order · CTX-03 keep tool IDs and continuation state · CTX-04 no clock/random IDs in static blocks · CTX-05 compaction starts a new epoch · CTX-06 never change data to match a cache · CTX-07 no unconfirmed cache fields · CTX-08 tool-result reuse needs valid freshness · CTX-09 missing usage is unknown, not zero · CTX-10 never cut a required check to reduce calls.
103
76
 
104
77
  ## Safe Patch Protocol
105
78
  <!-- RULES: SAFE-02 SAFE-03 SAFE-01 -->
106
-
107
- - For risky/shared/large edits, prefer unique current-file anchors over line numbers or stale pasted blocks; if `old_string` is missing or ambiguous, re-read current source and ask whether to apply as-is, adapt, or skip.
108
- - Preserve UTF-8 BOM/no-BOM and LF/CRLF for existing multilingual/user-authored files.
109
- - Internal helper + detail: `docs/UKIT_INTERNALS.md` (`node .claude/ukit/index/safe-patch.mjs`).
79
+ - Risky/shared/large edits: prefer unique current-file anchors over line numbers or stale pasted blocks; if `old_string` is missing/ambiguous, re-read current source and ask whether to apply as-is, adapt, or skip.
80
+ - Preserve UTF-8 BOM/no-BOM and LF/CRLF for existing multilingual/user-authored files. Helper: `node .claude/ukit/index/safe-patch.mjs`; detail: `docs/UKIT_INTERNALS.md`.
110
81
 
111
82
  ## Handoff Quality Gate — OPT-IN
112
83
  <!-- RULE: HAND-01 -->
113
-
114
84
  CHỈ kích hoạt khi task đi qua `docs/AI_HANDOFF/` (user nói "execute task TASK-xxx" hoặc target là `docs/AI_HANDOFF/tasks/*.md`). Daily prompt → KHÔNG đụng, flow cũ giữ nguyên.
115
85
 
116
- Khi Handoff mode: đọc `docs/AI_HANDOFF/RULES.md` để biết 4 phase (Idea+Plan → Create Tasks → Implement+Test → Review+Test) + state machine + comment thread + self-report model. Config: `.ukit/storage/config.json` → `handoff.*`.
86
+ Khi Handoff mode: đọc `docs/AI_HANDOFF/RULES.md` để biết 4 phase (Idea+Plan → Create Tasks → Implement+Test → Review+Test) + state machine + self-report model. Config: `.ukit/storage/config.json` → `handoff.*`.
117
87
 
118
88
  ## Context + Verification Budget
119
89
  <!-- RULE: BUDGET-01 -->
120
-
121
- - **Trivial**: no docs, and no index query unless the file target is unclear.
122
- - **Simple**: `docs/MEMORY.md` only, plus resolver-selected files/tests.
123
- - **Non-trivial**: `docs/MEMORY.md` + `docs/PROJECT.md` + `docs/CODE_MAP.md`.
90
+ - **Trivial**: no docs, no index query unless the file target is unclear. **Simple**: `docs/MEMORY.md` only + resolver-selected files/tests. **Non-trivial**: `docs/MEMORY.md` + `docs/PROJECT.md` + `docs/CODE_MAP.md`.
124
91
  <!-- RULES: BUDGET-02 BUDGET-03 -->
125
- - `docs/STATUS.md` for open-ended/continue prompts; `docs/TASKS.md` only for queued-task prompts; `docs/WORKLOG.md` recent entries only (archive overflow).
126
- - Follow routed verification policy: targeted first, widen only when risk/shared scope justifies it, ask before blanket broad runs.
92
+ - `docs/STATUS.md` for open-ended/continue prompts; `docs/TASKS.md` only for queued-task prompts; `docs/WORKLOG.md` recent entries only (archive overflow). Verification: targeted first, widen only on risk/shared scope, ask before blanket broad runs.
127
93
 
128
94
  ## Living Status Workflow
129
95
  <!-- RULE: STATUS-01 -->
130
-
131
- - `docs/STATUS.md` captures compact current state; it is not source truth and must not replace source/index-first investigation.
132
- - For "what next?" / "continue" prompts, use `next-step` with a freshness cue; after meaningful work use `update-status`. `docs/TASKS.md` is the local AI task queue — prefer `Ready for AI`. Detail: `docs/UKIT_INTERNALS.md`.
96
+ - `docs/STATUS.md` captures compact current state — not source truth, never replaces source/index-first investigation.
97
+ - "What next?"/"continue" → `next-step` with a freshness cue; after meaningful work → `update-status`. `docs/TASKS.md` is the local AI task queue — prefer `Ready for AI`. Detail: `docs/UKIT_INTERNALS.md`.
133
98
 
134
99
  ## Small-Task Maintainer (internal)
135
100
  <!-- RULE: SUBAG-02 -->
136
-
137
101
  - The `ukit-small-task-maintainer` subagent (`subagents.smallTaskModel`, default `unic-lite`) handles safe/reversible UKit chores as a sidecar lane — never block or slow the user task; risky work hands back to the main model. Detail: `docs/UKIT_INTERNALS.md`.
138
102
 
139
103
  ## Post-Edit Sidecar Review (internal)
140
-
141
- - When routed state's `routeSummary.line` carries `review=code-reviewer(diff)`, launch the `code-reviewer` agent in the background (`smart` tier) **only after** write + verification evidence exists; findings are advisory — never block the already-reported completion. Detail: `docs/UKIT_INTERNALS.md`.
104
+ - When routed state's `routeSummary.line` carries `review=code-reviewer(diff)`, launch `code-reviewer` in background (`smart` tier) **only after** write + verification evidence; findings advisory — never block the reported completion. Detail: `docs/UKIT_INTERNALS.md`.
142
105
 
143
106
  ## Selective Subagent Policy (internal only)
144
107
  <!-- RULE: SUBAG-01 -->
145
-
146
- - Keep direct execution as the default for trivial/simple work; delegate only when it meaningfully shrinks context or enables useful parallel progress (noisy side lanes, 3+ independent failures, batch plans, broad debug lanes).
147
- - Do not ask end users to name agents or remember agent commands.
108
+ - Direct execution is default for trivial/simple work; delegate only on meaningful context shrink or parallel gains (noisy side lanes, 3+ independent failures, batch plans). Never ask end users to name agents or remember agent commands.
148
109
 
149
110
  ## Adaptive Autonomy
150
111
  <!-- RULE: AUTO-01 -->
151
-
152
- - `autonomy.level` in `.ukit/storage/config.json` controls how much UKit acts without asking first: `conservative` (ask more), `balanced` (default), `free-run` (auto-run more), `vibecode` (run one prompt to a finished result; the completion gate stops only on completion evidence, a genuine blocker, or a dangerous-command decision).
153
- - End users should not need to change this; maintainers may tune it per-project.
112
+ - `autonomy.level` in `.ukit/storage/config.json` controls how much UKit acts without asking: `conservative` (ask more), `balanced` (default), `free-run` (auto-run more), `vibecode` (one prompt to a finished result; the gate stops only on completion evidence, a genuine blocker, or a dangerous-command decision). End users should not need to change it.
154
113
 
155
114
  ## 3-Tier Model Routing
156
115
  <!-- RULES: TIER-01 TIER-02 -->
157
-
158
116
  **Internal orchestration only — end users still just use natural language. No new commands.**
159
117
 
160
118
  | Tier | Generic alias | Claude model | Typical tasks |
161
119
  |------|--------------|--------------|---------------|
162
120
  | lite | `unic-lite` | claude-haiku | Reads, git queries, bash summaries, small doc edits |
163
121
  | code | `unic-code` | claude-sonnet | Normal coding, local fixes, shared edits, builds, debugging, impact mapping |
164
- | smart | `unic-smart` | claude-opus | Release review/audit, and escalated deep reasoning after repeated failure |
122
+ | smart | `unic-smart` | claude-opus | Release review/audit, escalated deep reasoning after repeated failure |
165
123
 
166
- - The main session model never changes mid-turn: a tier takes effect only when work is handed to an agent whose own definition binds that model (`model:` frontmatter in `.claude/agents/*.md`; `model:` `@lite`/`@code`/`@smart`/`@vision` in `.omp/agents/*.md` resolved via `modelRoles`).
167
- - Contract map: `tiny-fix` → lite · `local-fix`, `local-build`, `shared-edit`, `find-cause`, `map-impact` → code · `review-release` → smart.
168
- - Escalation: same file/symbol failing `debugLoopThreshold` (default 2) times in one session routes the next attempt one tier higher, capped at `smart`.
169
- - `unic-vision` is a capability lane, not a cost tier — unverified vision must never guess at image contents; route images to `ukit-vision-analyst`. Full harness table + gateway detection detail: `docs/UKIT_INTERNALS.md`.
124
+ - A tier takes effect only when work is handed to an agent whose definition binds that model (`model:` frontmatter in `.claude/agents/*.md`; `model:` `@lite`/`@code`/`@smart`/`@vision` in `.omp/agents/*.md` via `modelRoles`) — the main session model never changes mid-turn.
125
+ - Contract map: `tiny-fix` → lite · `local-fix`, `local-build`, `shared-edit`, `find-cause`, `map-impact` → code · `review-release` → smart. Escalation: same file/symbol failing `debugLoopThreshold` (default 2) times routes the next attempt one tier higher, capped at `smart`.
126
+ - `unic-vision` is a capability lane, not a cost tier — unverified vision must never guess image contents; route images to `ukit-vision-analyst`. Harness table: `docs/UKIT_INTERNALS.md`.
170
127
 
171
128
  ## Skills
172
-
173
- - Canonical skills live in `.claude/skills/`; adapter mirrors may exist (`.codex/skills/` → symlink). **omp** reads `.claude/skills/` directly via its `claude` discovery provider.
129
+ - Canonical skills live in `.claude/skills/`; adapter mirrors may exist (`.codex/skills/` → symlink). **omp** reads `.claude/skills/` via its `claude` discovery provider.
174
130
  - **OpenCode**: reads `AGENTS.md` at session start only — it does NOT auto-load skills; the model must explicitly read the triggered SKILL.md.
175
131
  - `ukit-*` commands in `opencode.json` are internal helper entrypoints — never ask end users to run them.
176
132
 
177
133
  ## Project Snapshot
178
-
179
134
  - Project: {{project.name}} | Root: {{project.root}}
180
135
  - Packs: {{project.stack}} | Frontend: {{stack.frontend}} | Backend API: {{stack.backendApi}} | PostgreSQL: {{stack.postgres}}
181
136
  - Package manager: {{runtime.packageManager}} | OS: {{runtime.os}} | Node: {{runtime.nodeVersion}} | Provider: {{providers.unic}}
182
137
 
183
138
  ## Working Rules
184
-
185
139
  - Keep scope tight, prefer the smallest correct change set, and reuse existing code.
186
140
  - Update `docs/WORKLOG.md` after significant work; if source contradicts docs, update docs immediately.
187
141
  - Use `{{runtime.packageManager}}`.
188
142
 
189
143
  ## DuraOne Skill — Conditional Activation
190
144
  <!-- RULE: DURA-01 -->
191
-
192
145
  DuraOne skill chỉ active khi pack `duraone` được cài hoặc `.claude/skills/duraone/SKILL.md` tồn tại — khi active, luôn đọc SKILL.md + references trước khi code; khi không, dùng generic standards + index patterns. Chi tiết: `docs/UKIT_INTERNALS.md`.
193
146
 
194
147
  ## Completion Checklist
195
-
196
- - Requirements implemented
197
- - No unrelated changes
198
- - Verification executed and reported
199
- - Docs updated when source truth changed
148
+ - Requirements implemented · No unrelated changes · Verification executed and reported · Docs updated when source truth changed.
200
149
 
201
150
  ## Handoff Fullstack Rules
202
151
  <!-- RULE: HAND-02 -->
203
-
204
152
  - `docs/AI_HANDOFF/RUN.md` là run cursor có thẩm quyền; `Phase:` ≠ `done`/`blocked` nghĩa là run còn sống — Stop gate từ chối stop và trả về `Next:` step.
205
153
  - Recap/checkpoint không bao giờ là completion — chỉ `HANDOFF FULLSTACK COMPLETE` (sau `Phase: done`) hoặc `HANDOFF FULLSTACK BLOCKED` (sau `Phase: blocked`) mới kết thúc run. Resume tự động mọi task chưa xong (current, legacy, pending, interrupted, recovery `-R<n>`).
206
154
  - Kết thúc cycle: docs sync → archive `docs/AI_HANDOFF/archive/cycle-NN/` → `Phase: done`. `handoff-clear` bắt buộc đóng RUN.md. Full rules: `docs/AI_HANDOFF/RULES.md`.
207
155
 
208
156
  ## Compact Instructions
209
-
210
157
  Khi compact giữa một handoff run: giữ lại goal, RUN.md path + phase hiện tại, task inventory, task đang làm, `Next:` step, blockers, verification evidence, commits, worktree/copy-back state, và quy tắc "compact không phải completion". Sau compact: đọc lại RUN.md + INDEX.md rồi chạy tiếp `Next:` ngay.
@@ -175,6 +175,41 @@
175
175
  "cap": "smart"
176
176
  }
177
177
  },
178
+ "codeIntel": {
179
+ "enabled": true,
180
+ "router": { "enabled": true, "defaultMode": "auto" },
181
+ "budgets": {
182
+ "peek": 500,
183
+ "targeted": 2000,
184
+ "impact": 3000,
185
+ "explore": 4000,
186
+ "deep_flow": 6000,
187
+ "analogy": 4000
188
+ },
189
+ "freshness": { "guardLevel": "L0", "autoRefresh": false, "incremental": true },
190
+ "retriever": {
191
+ "limit": 20,
192
+ "bm25": { "k1": 1.2, "b": 0.75 },
193
+ "merge": "rrf",
194
+ "rrfK": 60,
195
+ "weights": { "exact": 1.0, "symbol": 1.2, "bm25": 0.8, "semantic": 1.0, "vector": 0.6 }
196
+ },
197
+ "impact": { "defaultDepth": 2, "maxDepth": 4, "maxNodes": 200 },
198
+ "diagnostics": { "enabled": true, "timeoutMs": 8000 },
199
+ "providers": { "semantic": "null" },
200
+ "embedding": { "provider": "hashed", "dimensions": 256 },
201
+ "analogy": { "enabled": true, "limit": 5 },
202
+ "cochange": { "enabled": true, "maxCommits": 500, "minCount": 2, "timeoutMs": 5000 },
203
+ "summaries": { "enabled": true, "maxItems": 5 },
204
+ "graph": { "enabled": true, "store": "json" }
205
+ },
206
+ "memoryV2": {
207
+ "enabled": true,
208
+ "autoMigrate": true,
209
+ "episodeTtlDays": 90,
210
+ "promotion": { "episodeToRuleRequiresApproval": true },
211
+ "recall": { "maxRecords": 8 }
212
+ },
178
213
  "memory": {
179
214
  "enabled": true,
180
215
  "autoCapture": true,