@ngockhoale/ukit 2.7.10 → 2.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/manifests/instructionRules.yaml +2 -2
- package/package.json +1 -1
- package/src/core/executionContracts.js +0 -2
- package/src/core/output/index.js +10 -6
- package/src/core/runtimeConfig.js +11 -16
- package/src/core/status.js +1 -2
- package/src/index/taskRouting.js +0 -5
- package/templates/.claude/agents/code-reviewer.md +1 -42
- package/templates/.claude/ukit/index/route-task.mjs +0 -2
- package/templates/.claude/ukit/runtime/output-compression.mjs +33 -5
- package/templates/.claude/ukit/runtime/reinject-context.mjs +1 -1
- package/templates/.codex/settings.json +0 -1
- package/templates/.omp/agents/code-reviewer.md +1 -42
- package/templates/.omp/hooks/pre/ukit-bridge.js +21 -0
- package/templates/AGENTS.md +54 -76
- package/templates/CLAUDE.md +54 -76
- package/templates/docs/UKIT_INTERNALS.md +78 -16
- package/templates/instructions/core.md +54 -76
- package/templates/ukit/storage/config.json +12 -23
package/templates/AGENTS.md
CHANGED
|
@@ -3,142 +3,126 @@
|
|
|
3
3
|
|
|
4
4
|
## Core Rule
|
|
5
5
|
<!-- RULES: CORE-01 CORE-02 -->
|
|
6
|
-
-
|
|
7
|
-
- After install, default to natural-language work inside **Claude Code / Codex / omp**.
|
|
6
|
+
- One command: `ukit install`; then work in natural language inside **Claude Code / Codex / omp**.
|
|
8
7
|
- **Quality first, then speed, then token discipline.**
|
|
9
|
-
- **Never stop after read-only steps** — implement/apply/fix
|
|
8
|
+
- **Never stop after read-only steps** — implement/apply/fix continues to Edit/Write + verification same turn.
|
|
10
9
|
|
|
11
10
|
## Fast Classification
|
|
12
11
|
<!-- RULE: CLS-01 -->
|
|
13
|
-
- **Trivial** — typo, label,
|
|
12
|
+
- **Trivial** — typo, label, rename, spacing, flag, obvious config. Act directly; no docs/index/agents.
|
|
14
13
|
<!-- RULE: CLS-02 -->
|
|
15
|
-
- **Simple** — 1-2 files, clear scope, existing pattern.
|
|
14
|
+
- **Simple** — 1-2 files, clear scope, existing pattern. Act directly; smallest useful context only.
|
|
16
15
|
<!-- RULE: CLS-03 -->
|
|
17
|
-
- **Non-trivial / Risky** — auth, security, migration, uninstall, shared runtime, race/flaky, data-loss.
|
|
16
|
+
- **Non-trivial / Risky** — auth, security, migration, uninstall, shared runtime, race/flaky, data-loss. Index-first → skill → targeted verification.
|
|
18
17
|
|
|
19
18
|
## Execution Contract (mandatory)
|
|
20
19
|
<!-- RULE: EXEC-01 -->
|
|
21
|
-
-
|
|
20
|
+
- Implement/apply/fix: continue until the actual edit is made or a real blocker — never stop after read-only inspection.
|
|
22
21
|
<!-- RULE: EXEC-03 -->
|
|
23
|
-
- Routed states
|
|
22
|
+
- Routed states (`pull-indexed-context`, `continuation required`): treat it as an internal continuation step, not a stopping point; finish the named milestone first.
|
|
24
23
|
<!-- RULE: EXEC-02 -->
|
|
25
|
-
- **
|
|
24
|
+
- **No "done"/"applied"/"fixed" after Read/Grep/analysis alone** — needs concrete Edit/Write evidence this turn, plus verification when risky.
|
|
26
25
|
<!-- RULE: EXEC-04 -->
|
|
27
|
-
- **Every stop says why — no silent idle.**
|
|
26
|
+
- **Every stop says why — no silent idle.** User-only-action stops open with `WAITING ON YOU: <command/action>` + one-shot wakeup (~20-30 min) when available; report errors verbatim.
|
|
28
27
|
|
|
29
28
|
## Stall & Wait Reporting
|
|
30
29
|
<!-- RULE: STALL-01 -->
|
|
31
|
-
- Announce long waits
|
|
30
|
+
- Announce long waits: `Waiting for API response / tool result — will keep retrying; check your network/API provider if this persists`. Surface errors verbatim; suspect network/API — **never blame UKit**.
|
|
32
31
|
<!-- RULE: STALL-02 -->
|
|
33
|
-
-
|
|
32
|
+
- Stall rules extend EXEC-04 (every stop says why); they do not replace it.
|
|
34
33
|
<!-- RULE: STALL-03 -->
|
|
35
|
-
- **Conditional workaround only:**
|
|
34
|
+
- **Conditional workaround only:** one tool call per assistant message only when malformed/concatenated tool-input errors are observed or the harness is known-affected — healthy hosts keep parallel calls.
|
|
36
35
|
|
|
37
36
|
## Long-Run Continuity
|
|
38
37
|
<!-- RULES: LONG-01 LONG-02 -->
|
|
39
|
-
- Near token-cap: **LAND one thing** end-to-end (edit + verify, ≤3 tool calls), **DEFER** the rest
|
|
40
|
-
- After
|
|
41
|
-
- A run ends only on completion evidence, a genuine blocker, or a user-only action — every stop names its reason.
|
|
38
|
+
- Near token-cap: **LAND one thing** end-to-end (edit + verify, ≤3 tool calls), **DEFER** the rest to `docs/STATUS.md` or bounded `docs/AI_HANDOFF/` tasks, **DELEGATE** broad work to subagents. Then compact.
|
|
39
|
+
- After compact/handoff: continue from persisted disk state — never reread pre-compact context; delegate broadly, keep replies short.
|
|
40
|
+
- A run ends only on completion evidence, a genuine blocker, or a user-only action — every stop names its reason.
|
|
42
41
|
|
|
43
42
|
## Index-First Loop
|
|
44
|
-
For any task needing code context:
|
|
45
|
-
|
|
46
43
|
<!-- RULE: IDX-01 -->
|
|
47
|
-
1. Check the index is fresh (`.cache/index/`);
|
|
48
|
-
2. Query files: `node .claude/ukit/index/query-index.mjs "<error|symbol|path>"`; bug signatures: `triage.mjs "<error signature>"`.
|
|
44
|
+
1. Check the index is fresh (`.cache/index/`); stale/missing → `node .claude/ukit/index/refresh-index.mjs`. Query: `query-index.mjs "<error|symbol|path>"`; bugs: `triage.mjs "<error>"`.
|
|
49
45
|
<!-- RULE: IDX-02 -->
|
|
50
|
-
|
|
46
|
+
2. Open only the **top 1-3 suspect files first**, then widen — `outline:` jumps to `Read(file, offset=<line>)`.
|
|
51
47
|
<!-- RULE: IDX-03 -->
|
|
52
|
-
The outline locates code
|
|
53
|
-
4. For analog/reuse patterns, check `resolve-context`. Non-code lanes (docs-only, status, task queue) skip the source-code index.
|
|
48
|
+
The outline locates code, not behaviour — **code you are about to change must still be read**. Analog/reuse → `resolve-context`; non-code lanes skip.
|
|
54
49
|
|
|
55
50
|
## Automatic Skill Activation (mandatory)
|
|
56
51
|
<!-- RULE: SKILL-01 -->
|
|
57
|
-
- On every non-trivial task — and again after the first relevant tool calls —
|
|
52
|
+
- On every non-trivial task — and again after the first relevant tool calls — **auto-activate the matching skill immediately**; users never name skills. Match from prompt wording and tool/file evidence.
|
|
58
53
|
<!-- RULES: SKILL-02 SKILL-03 -->
|
|
59
|
-
-
|
|
60
|
-
- Prefer routed context/verification over ad-hoc broad reading; reuse `.claude/ukit/skill-router-state.json` compact route memory.
|
|
54
|
+
- Smallest effective set (1-2 skills); upgrade as evidence sharpens. Prefer routed context/verification over broad reading; reuse `.claude/ukit/skill-router-state.json` route memory.
|
|
61
55
|
|
|
62
56
|
### Common skill triggers
|
|
63
|
-
|
|
64
|
-
- review / audit / diff / PR feedback → `code-review` · bug / error / crash / triage → `debugging-toolkit` · test / spec / coverage / fixture → `testing-quality`
|
|
65
|
-
- 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`
|
|
66
|
-
- auth / security / token / permission / risky work → `discover-security` · stale workspace / reinstall / cleanup → `repo-maintenance` (all under `.claude/skills/<name>/SKILL.md`)
|
|
57
|
+
- review/audit/diff → `code-review` · bug/error/crash → `debugging-toolkit` · test/coverage → `testing-quality` · docs/README/`docs/` → `docs-quality` (`.claude/skills/docs-quality/SKILL.md`) · open-ended/continue → `next-step` · wrap-up/`docs/STATUS.md` → `update-status` · auth/security/risky → `discover-security` · stale workspace/cleanup → `repo-maintenance`
|
|
67
58
|
|
|
68
59
|
## Internal Helper Policy
|
|
69
60
|
<!-- RULES: HELP-01 HELP-02 -->
|
|
70
|
-
- Prefer the internal index helpers (`node .claude/ukit/index/route-task.mjs`, `resolve-context.mjs`, `verify-context.mjs`) for routing,
|
|
61
|
+
- Prefer the internal index helpers (`node .claude/ukit/index/route-task.mjs`, `resolve-context.mjs`, `verify-context.mjs`) for routing, context, verification.
|
|
71
62
|
- **Do not ask normal contributors to run internal helper commands** or memorize maintainer commands (`ukit doctor`, `ukit diff`, `ukit uninstall`) — run them yourself.
|
|
72
63
|
<!-- RULE: FALLBACK-01 -->
|
|
73
|
-
- Missing/corrupt runtime
|
|
64
|
+
- Missing/corrupt runtime or stale workspace → rerun `ukit install`.
|
|
74
65
|
|
|
75
66
|
## Skill Quality (maintainer-only)
|
|
76
|
-
-
|
|
67
|
+
- Editing `templates/.claude/` skills/agents → read `.claude/skills/skill-quality/SKILL.md` first.
|
|
77
68
|
|
|
78
69
|
## UKit v{{ukit.version}} Shared Runtime
|
|
79
|
-
- Runtime state
|
|
80
|
-
- Reuse `.ukit/storage/memory/` + `ukit memory recall "<current task>"` before asking users to restate decisions; `ukit memory learn` surfaces pending proposals, `ukit memory promote` writes approved rules to MEMORY.md, `ukit memory episode` records session episodes; inspect via `ukit status` / `ukit memory export`.
|
|
81
|
-
- Route memory: `.claude/ukit/skill-router-state.json` — reuse compact `previous-context`/`recent-output` first. Cache state: `.ukit/storage/cache/output-history.json`, `retriever-lanes.jsonl`, `tee/`. Lifecycle hooks all degrade to exit 0 (SessionEnd `session-episode.sh` auto-writes episodes; full map: `docs/UKIT_INTERNALS.md`). Missing/corrupt runtime or old `ukit/` root → rerun `ukit install`. Detail: `docs/UKIT_INTERNALS.md`.
|
|
82
|
-
|
|
70
|
+
- Runtime state: `.ukit/storage/`; `config.json` holds toggles (compact, token pipeline, router, memory, validation, Safe Patch). `ukit memory recall "<task>"` before asking users to restate decisions; `learn`/`promote`/`episode` manage memory; inspect via `ukit status` / `ukit memory export`. Route memory: `.claude/ukit/skill-router-state.json` (`previous-context`/`recent-output` first); cache: `.ukit/storage/cache/output-history.json` + `retriever-lanes.jsonl` + `tee/`. Hooks degrade to exit 0; missing/corrupt runtime → rerun `ukit install`.
|
|
83
71
|
## Prompt Caching
|
|
84
72
|
<!-- RULES: CTX-01 CTX-02 CTX-03 CTX-04 CTX-05 CTX-06 CTX-07 CTX-08 CTX-09 CTX-10 -->
|
|
85
|
-
- Full ruleset: `docs/PROMPT_CACHING.md` (read on demand
|
|
86
|
-
- 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.
|
|
73
|
+
- Full ruleset: `docs/PROMPT_CACHING.md` (read on demand).
|
|
87
74
|
|
|
88
75
|
## Safe Patch Protocol
|
|
89
76
|
<!-- RULES: SAFE-02 SAFE-03 SAFE-01 -->
|
|
90
|
-
- Risky/shared/large edits: prefer unique current-file anchors over line numbers or stale pasted blocks;
|
|
91
|
-
- Preserve UTF-8 BOM/no-BOM and LF/CRLF
|
|
77
|
+
- Risky/shared/large edits: prefer unique current-file anchors over line numbers or stale pasted blocks; missing/ambiguous `old_string` → re-read source, then apply, adapt, or skip.
|
|
78
|
+
- Preserve UTF-8 BOM/no-BOM and LF/CRLF on existing files. Helper: `node .claude/ukit/index/safe-patch.mjs`.
|
|
92
79
|
|
|
93
80
|
## Handoff Quality Gate — OPT-IN
|
|
94
81
|
<!-- RULE: HAND-01 -->
|
|
95
|
-
|
|
82
|
+
Chỉ active khi task đi qua `docs/AI_HANDOFF/` ("execute task TASK-xxx" hoặc `docs/AI_HANDOFF/tasks/*.md`); daily prompt giữ flow cũ. Khi active: đọc `docs/AI_HANDOFF/RULES.md` (4 phase + state machine + self-report). Config: `.ukit/storage/config.json` → `handoff.*`.
|
|
96
83
|
|
|
97
84
|
## Context + Verification Budget
|
|
98
85
|
<!-- RULE: BUDGET-01 -->
|
|
99
|
-
- **Trivial**: no docs, no index query unless the
|
|
86
|
+
- **Trivial**: no docs, no index query unless the target is unclear. **Simple**: `docs/MEMORY.md` + resolver-selected files/tests. **Non-trivial**: + `docs/PROJECT.md` + `docs/CODE_MAP.md`.
|
|
100
87
|
<!-- RULES: BUDGET-02 BUDGET-03 -->
|
|
101
|
-
- `docs/STATUS.md` for open-ended/continue
|
|
88
|
+
- `docs/STATUS.md` for open-ended/continue; `docs/TASKS.md` only for queued-task prompts; `docs/WORKLOG.md` recent entries only. Verification: targeted first, widen on risk/shared scope, ask before broad runs.
|
|
102
89
|
|
|
103
90
|
## Living Status Workflow
|
|
104
91
|
<!-- RULE: STATUS-01 -->
|
|
105
|
-
- `docs/STATUS.md`
|
|
106
|
-
- "What next?"/"continue" → `next-step
|
|
92
|
+
- `docs/STATUS.md` = compact current state — not source truth, never replaces index-first investigation.
|
|
93
|
+
- "What next?"/"continue" → `next-step`; after meaningful work → `update-status`. `docs/TASKS.md` = local AI task queue — prefer `Ready for AI`.
|
|
107
94
|
|
|
108
95
|
## Subagent Lanes (internal)
|
|
109
96
|
<!-- RULE: SUBAG-02 -->
|
|
110
|
-
-
|
|
111
|
-
- 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`.
|
|
97
|
+
- `ukit-small-task-maintainer` (`subagents.smallTaskModel`, default `unic-lite`) = sidecar lane for safe/reversible UKit chores — never block the user task; risky work hands back.
|
|
112
98
|
<!-- RULE: SUBAG-01 -->
|
|
113
|
-
- Direct execution is default for trivial/simple work; delegate only on
|
|
99
|
+
- Direct execution is default for trivial/simple work; delegate only on real context shrink or parallel gains. Never ask users to name agents or agent commands.
|
|
114
100
|
|
|
115
101
|
## Adaptive Autonomy
|
|
116
102
|
<!-- RULE: AUTO-01 -->
|
|
117
|
-
- `autonomy.level` in `.ukit/storage/config.json
|
|
103
|
+
- `autonomy.level` in `.ukit/storage/config.json`: `conservative` | `balanced` (default) | `free-run` | `vibecode` (one prompt to a finished result; stops only on completion evidence, a genuine blocker, or a dangerous-command decision).
|
|
118
104
|
|
|
119
105
|
## Unattended Completion Loop
|
|
120
106
|
<!-- RULE: UNATTENDED-01 -->
|
|
121
|
-
-
|
|
107
|
+
- `orchestration.permissionMode: unattended` = no human in the loop — UNDERSTAND → PLAN → IMPLEMENT → VERIFY → FIX → REVERIFY → COMPLETE. A turn ends only on COMPLETE evidence, a real external blocker, or a deny.
|
|
122
108
|
<!-- RULE: UNATTENDED-02 -->
|
|
123
|
-
- `maxAttemptsPerFailure:
|
|
109
|
+
- `maxAttemptsPerFailure: 2`, `maxRecoveryStrategies: 2` distinct fix strategies before reassessing — retry the same edit, then fix the cause differently; never loop one strategy.
|
|
124
110
|
<!-- RULE: UNATTENDED-03 -->
|
|
125
|
-
- BLOCKED only on true external blockers: missing credentials, dead service, unreachable network/API. Test failures, lint errors, review findings,
|
|
111
|
+
- BLOCKED only on true external blockers: missing credentials, dead service, unreachable network/API. Test failures, lint errors, review findings, ambiguity are NOT blockers — feed FIX.
|
|
126
112
|
<!-- RULE: UNATTENDED-04 -->
|
|
127
|
-
- A deny (hook/gate/permission) never becomes a question: pick the next safer alternative
|
|
113
|
+
- A deny (hook/gate/permission) never becomes a question: pick the next safer alternative satisfying the intent, record the substitution. Never emit "do you want me to…" — decide and proceed.
|
|
128
114
|
|
|
129
115
|
## 3-Tier Model Routing
|
|
130
116
|
<!-- RULES: TIER-01 TIER-02 -->
|
|
131
|
-
**Internal orchestration only — end users still
|
|
117
|
+
**Internal orchestration only — end users still use natural language. No new commands.**
|
|
132
118
|
|
|
133
|
-
| Tier |
|
|
134
|
-
|
|
135
|
-
| lite | `unic-lite` | claude-haiku |
|
|
136
|
-
| code | `unic-code` | claude-sonnet |
|
|
137
|
-
| smart | `unic-smart` | claude-opus |
|
|
119
|
+
| Tier | Alias | Claude model |
|
|
120
|
+
|------|-------|--------------|
|
|
121
|
+
| lite | `unic-lite` | claude-haiku |
|
|
122
|
+
| code | `unic-code` | claude-sonnet |
|
|
123
|
+
| smart | `unic-smart` | claude-opus |
|
|
138
124
|
|
|
139
|
-
- A tier
|
|
140
|
-
- 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`.
|
|
141
|
-
- `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`.
|
|
125
|
+
- A tier binds only via an agent's `model:` field (`.claude/agents/*.md`; `.omp/agents/*.md` `@smol`/`@default`/`@slow`/`@vision` via `modelRoles`) — the session model never changes mid-turn. 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` (2) → one tier up, cap `smart`. `unic-vision` = capability lane (not cost) — never guess images; route to `ukit-vision-analyst`.
|
|
142
126
|
|
|
143
127
|
## Project Owner Instructions — Codex
|
|
144
128
|
|
|
@@ -149,31 +133,25 @@ If it is missing or unreadable, state that limitation and continue with the
|
|
|
149
133
|
remaining project instructions.
|
|
150
134
|
<!-- RULE: OWN-01 -->
|
|
151
135
|
## Skills
|
|
152
|
-
- Canonical skills
|
|
136
|
+
- Canonical skills: `.claude/skills/`; adapter mirrors may exist (`.codex/skills/` → symlink). **omp** reads `.claude/skills/` via its `claude` provider.
|
|
153
137
|
|
|
154
138
|
## Project Snapshot
|
|
155
|
-
- Project: {{project.name}} | Root: {{project.root}}
|
|
156
|
-
- Packs: {{project.stack}} | Frontend: {{stack.frontend}} | Backend API: {{stack.backendApi}} | PostgreSQL: {{stack.postgres}}
|
|
157
|
-
- Package manager: {{runtime.packageManager}} | OS: {{runtime.os}} | Node: {{runtime.nodeVersion}} | Provider: {{providers.unic}}
|
|
139
|
+
- Project: {{project.name}} | Root: {{project.root}} | Packs: {{project.stack}} | PM: {{runtime.packageManager}} | OS: {{runtime.os}} | Node: {{runtime.nodeVersion}} | Provider: {{providers.unic}}
|
|
158
140
|
|
|
159
141
|
## Working Rules
|
|
160
|
-
- Keep scope tight
|
|
161
|
-
- Update `docs/WORKLOG.md` after significant work; if source contradicts docs, update docs immediately.
|
|
162
|
-
- Use `{{runtime.packageManager}}`.
|
|
142
|
+
- Keep scope tight; smallest correct change set; reuse existing code. Update `docs/WORKLOG.md` after significant work; source contradicts docs → update docs. Use `{{runtime.packageManager}}`.
|
|
163
143
|
|
|
164
144
|
## DuraOne Skill — Conditional Activation
|
|
165
145
|
<!-- RULE: DURA-01 -->
|
|
166
|
-
DuraOne skill chỉ active khi pack `duraone` được cài hoặc `.claude/skills/duraone/SKILL.md` tồn tại — khi active,
|
|
146
|
+
DuraOne skill chỉ active khi pack `duraone` được cài hoặc `.claude/skills/duraone/SKILL.md` tồn tại — khi active, đọc SKILL.md + references trước khi code; khi không, dùng generic standards + index patterns.
|
|
167
147
|
|
|
168
148
|
## Completion Checklist
|
|
169
|
-
- Requirements implemented · No unrelated changes · Verification executed
|
|
149
|
+
- Requirements implemented · No unrelated changes · Verification executed + reported · Docs updated when source truth changed.
|
|
170
150
|
|
|
171
151
|
## Handoff Fullstack Rules
|
|
172
152
|
<!-- RULE: HAND-02 -->
|
|
173
|
-
- `docs/AI_HANDOFF/RUN.md` là run cursor có thẩm quyền; `Phase:` ≠ `done`/`blocked`
|
|
174
|
-
- 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>`).
|
|
175
|
-
- 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`.
|
|
153
|
+
- `docs/AI_HANDOFF/RUN.md` là run cursor có thẩm quyền; `Phase:` ≠ `done`/`blocked` = run còn sống — Stop gate từ chối stop, trả về `Next:`. Chỉ `HANDOFF FULLSTACK COMPLETE`/`BLOCKED` kết thúc run — recap/checkpoint không phải completion; resume tự động mọi task chưa xong. Kết thúc cycle: docs sync → archive `archive/cycle-NN/` → `Phase: done`; `handoff-clear` bắt buộc đóng RUN.md. Full rules: `docs/AI_HANDOFF/RULES.md`.
|
|
176
154
|
|
|
177
155
|
## Compact Instructions
|
|
178
|
-
|
|
156
|
+
Compact giữa handoff run: giữ goal, RUN.md path + phase, task inventory + task đang làm, `Next:` step, blockers, verification evidence, commits, worktree/copy-back state, "compact không phải completion". Sau compact: đọc lại RUN.md + INDEX.md rồi chạy `Next:`.
|
|
179
157
|
{{codegraphSection}}
|
package/templates/CLAUDE.md
CHANGED
|
@@ -3,169 +3,147 @@
|
|
|
3
3
|
|
|
4
4
|
## Core Rule
|
|
5
5
|
<!-- RULES: CORE-01 CORE-02 -->
|
|
6
|
-
-
|
|
7
|
-
- After install, default to natural-language work inside **Claude Code / Codex / omp**.
|
|
6
|
+
- One command: `ukit install`; then work in natural language inside **Claude Code / Codex / omp**.
|
|
8
7
|
- **Quality first, then speed, then token discipline.**
|
|
9
|
-
- **Never stop after read-only steps** — implement/apply/fix
|
|
8
|
+
- **Never stop after read-only steps** — implement/apply/fix continues to Edit/Write + verification same turn.
|
|
10
9
|
|
|
11
10
|
## Fast Classification
|
|
12
11
|
<!-- RULE: CLS-01 -->
|
|
13
|
-
- **Trivial** — typo, label,
|
|
12
|
+
- **Trivial** — typo, label, rename, spacing, flag, obvious config. Act directly; no docs/index/agents.
|
|
14
13
|
<!-- RULE: CLS-02 -->
|
|
15
|
-
- **Simple** — 1-2 files, clear scope, existing pattern.
|
|
14
|
+
- **Simple** — 1-2 files, clear scope, existing pattern. Act directly; smallest useful context only.
|
|
16
15
|
<!-- RULE: CLS-03 -->
|
|
17
|
-
- **Non-trivial / Risky** — auth, security, migration, uninstall, shared runtime, race/flaky, data-loss.
|
|
16
|
+
- **Non-trivial / Risky** — auth, security, migration, uninstall, shared runtime, race/flaky, data-loss. Index-first → skill → targeted verification.
|
|
18
17
|
|
|
19
18
|
## Execution Contract (mandatory)
|
|
20
19
|
<!-- RULE: EXEC-01 -->
|
|
21
|
-
-
|
|
20
|
+
- Implement/apply/fix: continue until the actual edit is made or a real blocker — never stop after read-only inspection.
|
|
22
21
|
<!-- RULE: EXEC-03 -->
|
|
23
|
-
- Routed states
|
|
22
|
+
- Routed states (`pull-indexed-context`, `continuation required`): treat it as an internal continuation step, not a stopping point; finish the named milestone first.
|
|
24
23
|
<!-- RULE: EXEC-02 -->
|
|
25
|
-
- **
|
|
24
|
+
- **No "done"/"applied"/"fixed" after Read/Grep/analysis alone** — needs concrete Edit/Write evidence this turn, plus verification when risky.
|
|
26
25
|
<!-- RULE: EXEC-04 -->
|
|
27
|
-
- **Every stop says why — no silent idle.**
|
|
26
|
+
- **Every stop says why — no silent idle.** User-only-action stops open with `WAITING ON YOU: <command/action>` + one-shot wakeup (~20-30 min) when available; report errors verbatim.
|
|
28
27
|
|
|
29
28
|
## Stall & Wait Reporting
|
|
30
29
|
<!-- RULE: STALL-01 -->
|
|
31
|
-
- Announce long waits
|
|
30
|
+
- Announce long waits: `Waiting for API response / tool result — will keep retrying; check your network/API provider if this persists`. Surface errors verbatim; suspect network/API — **never blame UKit**.
|
|
32
31
|
<!-- RULE: STALL-02 -->
|
|
33
|
-
-
|
|
32
|
+
- Stall rules extend EXEC-04 (every stop says why); they do not replace it.
|
|
34
33
|
<!-- RULE: STALL-03 -->
|
|
35
|
-
- **Conditional workaround only:**
|
|
34
|
+
- **Conditional workaround only:** one tool call per assistant message only when malformed/concatenated tool-input errors are observed or the harness is known-affected — healthy hosts keep parallel calls.
|
|
36
35
|
|
|
37
36
|
## Long-Run Continuity
|
|
38
37
|
<!-- RULES: LONG-01 LONG-02 -->
|
|
39
|
-
- Near token-cap: **LAND one thing** end-to-end (edit + verify, ≤3 tool calls), **DEFER** the rest
|
|
40
|
-
- After
|
|
41
|
-
- A run ends only on completion evidence, a genuine blocker, or a user-only action — every stop names its reason.
|
|
38
|
+
- Near token-cap: **LAND one thing** end-to-end (edit + verify, ≤3 tool calls), **DEFER** the rest to `docs/STATUS.md` or bounded `docs/AI_HANDOFF/` tasks, **DELEGATE** broad work to subagents. Then compact.
|
|
39
|
+
- After compact/handoff: continue from persisted disk state — never reread pre-compact context; delegate broadly, keep replies short.
|
|
40
|
+
- A run ends only on completion evidence, a genuine blocker, or a user-only action — every stop names its reason.
|
|
42
41
|
|
|
43
42
|
## Index-First Loop
|
|
44
|
-
For any task needing code context:
|
|
45
|
-
|
|
46
43
|
<!-- RULE: IDX-01 -->
|
|
47
|
-
1. Check the index is fresh (`.cache/index/`);
|
|
48
|
-
2. Query files: `node .claude/ukit/index/query-index.mjs "<error|symbol|path>"`; bug signatures: `triage.mjs "<error signature>"`.
|
|
44
|
+
1. Check the index is fresh (`.cache/index/`); stale/missing → `node .claude/ukit/index/refresh-index.mjs`. Query: `query-index.mjs "<error|symbol|path>"`; bugs: `triage.mjs "<error>"`.
|
|
49
45
|
<!-- RULE: IDX-02 -->
|
|
50
|
-
|
|
46
|
+
2. Open only the **top 1-3 suspect files first**, then widen — `outline:` jumps to `Read(file, offset=<line>)`.
|
|
51
47
|
<!-- RULE: IDX-03 -->
|
|
52
|
-
The outline locates code
|
|
53
|
-
4. For analog/reuse patterns, check `resolve-context`. Non-code lanes (docs-only, status, task queue) skip the source-code index.
|
|
48
|
+
The outline locates code, not behaviour — **code you are about to change must still be read**. Analog/reuse → `resolve-context`; non-code lanes skip.
|
|
54
49
|
|
|
55
50
|
## Automatic Skill Activation (mandatory)
|
|
56
51
|
<!-- RULE: SKILL-01 -->
|
|
57
|
-
- On every non-trivial task — and again after the first relevant tool calls —
|
|
52
|
+
- On every non-trivial task — and again after the first relevant tool calls — **auto-activate the matching skill immediately**; users never name skills. Match from prompt wording and tool/file evidence.
|
|
58
53
|
<!-- RULES: SKILL-02 SKILL-03 -->
|
|
59
|
-
-
|
|
60
|
-
- Prefer routed context/verification over ad-hoc broad reading; reuse `.claude/ukit/skill-router-state.json` compact route memory.
|
|
54
|
+
- Smallest effective set (1-2 skills); upgrade as evidence sharpens. Prefer routed context/verification over broad reading; reuse `.claude/ukit/skill-router-state.json` route memory.
|
|
61
55
|
|
|
62
56
|
### Common skill triggers
|
|
63
|
-
|
|
64
|
-
- review / audit / diff / PR feedback → `code-review` · bug / error / crash / triage → `debugging-toolkit` · test / spec / coverage / fixture → `testing-quality`
|
|
65
|
-
- 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`
|
|
66
|
-
- auth / security / token / permission / risky work → `discover-security` · stale workspace / reinstall / cleanup → `repo-maintenance` (all under `.claude/skills/<name>/SKILL.md`)
|
|
57
|
+
- review/audit/diff → `code-review` · bug/error/crash → `debugging-toolkit` · test/coverage → `testing-quality` · docs/README/`docs/` → `docs-quality` (`.claude/skills/docs-quality/SKILL.md`) · open-ended/continue → `next-step` · wrap-up/`docs/STATUS.md` → `update-status` · auth/security/risky → `discover-security` · stale workspace/cleanup → `repo-maintenance`
|
|
67
58
|
|
|
68
59
|
## Internal Helper Policy
|
|
69
60
|
<!-- RULES: HELP-01 HELP-02 -->
|
|
70
|
-
- Prefer the internal index helpers (`node .claude/ukit/index/route-task.mjs`, `resolve-context.mjs`, `verify-context.mjs`) for routing,
|
|
61
|
+
- Prefer the internal index helpers (`node .claude/ukit/index/route-task.mjs`, `resolve-context.mjs`, `verify-context.mjs`) for routing, context, verification.
|
|
71
62
|
- **Do not ask normal contributors to run internal helper commands** or memorize maintainer commands (`ukit doctor`, `ukit diff`, `ukit uninstall`) — run them yourself.
|
|
72
63
|
<!-- RULE: FALLBACK-01 -->
|
|
73
|
-
- Missing/corrupt runtime
|
|
64
|
+
- Missing/corrupt runtime or stale workspace → rerun `ukit install`.
|
|
74
65
|
|
|
75
66
|
## Skill Quality (maintainer-only)
|
|
76
|
-
-
|
|
67
|
+
- Editing `templates/.claude/` skills/agents → read `.claude/skills/skill-quality/SKILL.md` first.
|
|
77
68
|
|
|
78
69
|
## UKit v{{ukit.version}} Shared Runtime
|
|
79
|
-
- Runtime state
|
|
80
|
-
- Reuse `.ukit/storage/memory/` + `ukit memory recall "<current task>"` before asking users to restate decisions; `ukit memory learn` surfaces pending proposals, `ukit memory promote` writes approved rules to MEMORY.md, `ukit memory episode` records session episodes; inspect via `ukit status` / `ukit memory export`.
|
|
81
|
-
- Route memory: `.claude/ukit/skill-router-state.json` — reuse compact `previous-context`/`recent-output` first. Cache state: `.ukit/storage/cache/output-history.json`, `retriever-lanes.jsonl`, `tee/`. Lifecycle hooks all degrade to exit 0 (SessionEnd `session-episode.sh` auto-writes episodes; full map: `docs/UKIT_INTERNALS.md`). Missing/corrupt runtime or old `ukit/` root → rerun `ukit install`. Detail: `docs/UKIT_INTERNALS.md`.
|
|
82
|
-
|
|
70
|
+
- Runtime state: `.ukit/storage/`; `config.json` holds toggles (compact, token pipeline, router, memory, validation, Safe Patch). `ukit memory recall "<task>"` before asking users to restate decisions; `learn`/`promote`/`episode` manage memory; inspect via `ukit status` / `ukit memory export`. Route memory: `.claude/ukit/skill-router-state.json` (`previous-context`/`recent-output` first); cache: `.ukit/storage/cache/output-history.json` + `retriever-lanes.jsonl` + `tee/`. Hooks degrade to exit 0; missing/corrupt runtime → rerun `ukit install`.
|
|
83
71
|
## Prompt Caching
|
|
84
72
|
<!-- RULES: CTX-01 CTX-02 CTX-03 CTX-04 CTX-05 CTX-06 CTX-07 CTX-08 CTX-09 CTX-10 -->
|
|
85
|
-
- Full ruleset: `docs/PROMPT_CACHING.md` (read on demand
|
|
86
|
-
- 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.
|
|
73
|
+
- Full ruleset: `docs/PROMPT_CACHING.md` (read on demand).
|
|
87
74
|
|
|
88
75
|
## Safe Patch Protocol
|
|
89
76
|
<!-- RULES: SAFE-02 SAFE-03 SAFE-01 -->
|
|
90
|
-
- Risky/shared/large edits: prefer unique current-file anchors over line numbers or stale pasted blocks;
|
|
91
|
-
- Preserve UTF-8 BOM/no-BOM and LF/CRLF
|
|
77
|
+
- Risky/shared/large edits: prefer unique current-file anchors over line numbers or stale pasted blocks; missing/ambiguous `old_string` → re-read source, then apply, adapt, or skip.
|
|
78
|
+
- Preserve UTF-8 BOM/no-BOM and LF/CRLF on existing files. Helper: `node .claude/ukit/index/safe-patch.mjs`.
|
|
92
79
|
|
|
93
80
|
## Handoff Quality Gate — OPT-IN
|
|
94
81
|
<!-- RULE: HAND-01 -->
|
|
95
|
-
|
|
82
|
+
Chỉ active khi task đi qua `docs/AI_HANDOFF/` ("execute task TASK-xxx" hoặc `docs/AI_HANDOFF/tasks/*.md`); daily prompt giữ flow cũ. Khi active: đọc `docs/AI_HANDOFF/RULES.md` (4 phase + state machine + self-report). Config: `.ukit/storage/config.json` → `handoff.*`.
|
|
96
83
|
|
|
97
84
|
## Context + Verification Budget
|
|
98
85
|
<!-- RULE: BUDGET-01 -->
|
|
99
|
-
- **Trivial**: no docs, no index query unless the
|
|
86
|
+
- **Trivial**: no docs, no index query unless the target is unclear. **Simple**: `docs/MEMORY.md` + resolver-selected files/tests. **Non-trivial**: + `docs/PROJECT.md` + `docs/CODE_MAP.md`.
|
|
100
87
|
<!-- RULES: BUDGET-02 BUDGET-03 -->
|
|
101
|
-
- `docs/STATUS.md` for open-ended/continue
|
|
88
|
+
- `docs/STATUS.md` for open-ended/continue; `docs/TASKS.md` only for queued-task prompts; `docs/WORKLOG.md` recent entries only. Verification: targeted first, widen on risk/shared scope, ask before broad runs.
|
|
102
89
|
|
|
103
90
|
## Living Status Workflow
|
|
104
91
|
<!-- RULE: STATUS-01 -->
|
|
105
|
-
- `docs/STATUS.md`
|
|
106
|
-
- "What next?"/"continue" → `next-step
|
|
92
|
+
- `docs/STATUS.md` = compact current state — not source truth, never replaces index-first investigation.
|
|
93
|
+
- "What next?"/"continue" → `next-step`; after meaningful work → `update-status`. `docs/TASKS.md` = local AI task queue — prefer `Ready for AI`.
|
|
107
94
|
|
|
108
95
|
## Subagent Lanes (internal)
|
|
109
96
|
<!-- RULE: SUBAG-02 -->
|
|
110
|
-
-
|
|
111
|
-
- 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`.
|
|
97
|
+
- `ukit-small-task-maintainer` (`subagents.smallTaskModel`, default `unic-lite`) = sidecar lane for safe/reversible UKit chores — never block the user task; risky work hands back.
|
|
112
98
|
<!-- RULE: SUBAG-01 -->
|
|
113
|
-
- Direct execution is default for trivial/simple work; delegate only on
|
|
99
|
+
- Direct execution is default for trivial/simple work; delegate only on real context shrink or parallel gains. Never ask users to name agents or agent commands.
|
|
114
100
|
|
|
115
101
|
## Adaptive Autonomy
|
|
116
102
|
<!-- RULE: AUTO-01 -->
|
|
117
|
-
- `autonomy.level` in `.ukit/storage/config.json
|
|
103
|
+
- `autonomy.level` in `.ukit/storage/config.json`: `conservative` | `balanced` (default) | `free-run` | `vibecode` (one prompt to a finished result; stops only on completion evidence, a genuine blocker, or a dangerous-command decision).
|
|
118
104
|
|
|
119
105
|
## Unattended Completion Loop
|
|
120
106
|
<!-- RULE: UNATTENDED-01 -->
|
|
121
|
-
-
|
|
107
|
+
- `orchestration.permissionMode: unattended` = no human in the loop — UNDERSTAND → PLAN → IMPLEMENT → VERIFY → FIX → REVERIFY → COMPLETE. A turn ends only on COMPLETE evidence, a real external blocker, or a deny.
|
|
122
108
|
<!-- RULE: UNATTENDED-02 -->
|
|
123
|
-
- `maxAttemptsPerFailure:
|
|
109
|
+
- `maxAttemptsPerFailure: 2`, `maxRecoveryStrategies: 2` distinct fix strategies before reassessing — retry the same edit, then fix the cause differently; never loop one strategy.
|
|
124
110
|
<!-- RULE: UNATTENDED-03 -->
|
|
125
|
-
- BLOCKED only on true external blockers: missing credentials, dead service, unreachable network/API. Test failures, lint errors, review findings,
|
|
111
|
+
- BLOCKED only on true external blockers: missing credentials, dead service, unreachable network/API. Test failures, lint errors, review findings, ambiguity are NOT blockers — feed FIX.
|
|
126
112
|
<!-- RULE: UNATTENDED-04 -->
|
|
127
|
-
- A deny (hook/gate/permission) never becomes a question: pick the next safer alternative
|
|
113
|
+
- A deny (hook/gate/permission) never becomes a question: pick the next safer alternative satisfying the intent, record the substitution. Never emit "do you want me to…" — decide and proceed.
|
|
128
114
|
|
|
129
115
|
## 3-Tier Model Routing
|
|
130
116
|
<!-- RULES: TIER-01 TIER-02 -->
|
|
131
|
-
**Internal orchestration only — end users still
|
|
117
|
+
**Internal orchestration only — end users still use natural language. No new commands.**
|
|
132
118
|
|
|
133
|
-
| Tier |
|
|
134
|
-
|
|
135
|
-
| lite | `unic-lite` | claude-haiku |
|
|
136
|
-
| code | `unic-code` | claude-sonnet |
|
|
137
|
-
| smart | `unic-smart` | claude-opus |
|
|
119
|
+
| Tier | Alias | Claude model |
|
|
120
|
+
|------|-------|--------------|
|
|
121
|
+
| lite | `unic-lite` | claude-haiku |
|
|
122
|
+
| code | `unic-code` | claude-sonnet |
|
|
123
|
+
| smart | `unic-smart` | claude-opus |
|
|
138
124
|
|
|
139
|
-
- A tier
|
|
140
|
-
- 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`.
|
|
141
|
-
- `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`.
|
|
125
|
+
- A tier binds only via an agent's `model:` field (`.claude/agents/*.md`; `.omp/agents/*.md` `@smol`/`@default`/`@slow`/`@vision` via `modelRoles`) — the session model never changes mid-turn. 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` (2) → one tier up, cap `smart`. `unic-vision` = capability lane (not cost) — never guess images; route to `ukit-vision-analyst`.
|
|
142
126
|
|
|
143
127
|
## Skills
|
|
144
|
-
- Canonical skills
|
|
128
|
+
- Canonical skills: `.claude/skills/`; adapter mirrors may exist (`.codex/skills/` → symlink). **omp** reads `.claude/skills/` via its `claude` provider.
|
|
145
129
|
|
|
146
130
|
## Project Snapshot
|
|
147
|
-
- Project: {{project.name}} | Root: {{project.root}}
|
|
148
|
-
- Packs: {{project.stack}} | Frontend: {{stack.frontend}} | Backend API: {{stack.backendApi}} | PostgreSQL: {{stack.postgres}}
|
|
149
|
-
- Package manager: {{runtime.packageManager}} | OS: {{runtime.os}} | Node: {{runtime.nodeVersion}} | Provider: {{providers.unic}}
|
|
131
|
+
- Project: {{project.name}} | Root: {{project.root}} | Packs: {{project.stack}} | PM: {{runtime.packageManager}} | OS: {{runtime.os}} | Node: {{runtime.nodeVersion}} | Provider: {{providers.unic}}
|
|
150
132
|
|
|
151
133
|
## Working Rules
|
|
152
|
-
- Keep scope tight
|
|
153
|
-
- Update `docs/WORKLOG.md` after significant work; if source contradicts docs, update docs immediately.
|
|
154
|
-
- Use `{{runtime.packageManager}}`.
|
|
134
|
+
- Keep scope tight; smallest correct change set; reuse existing code. Update `docs/WORKLOG.md` after significant work; source contradicts docs → update docs. Use `{{runtime.packageManager}}`.
|
|
155
135
|
|
|
156
136
|
## DuraOne Skill — Conditional Activation
|
|
157
137
|
<!-- RULE: DURA-01 -->
|
|
158
|
-
DuraOne skill chỉ active khi pack `duraone` được cài hoặc `.claude/skills/duraone/SKILL.md` tồn tại — khi active,
|
|
138
|
+
DuraOne skill chỉ active khi pack `duraone` được cài hoặc `.claude/skills/duraone/SKILL.md` tồn tại — khi active, đọc SKILL.md + references trước khi code; khi không, dùng generic standards + index patterns.
|
|
159
139
|
|
|
160
140
|
## Completion Checklist
|
|
161
|
-
- Requirements implemented · No unrelated changes · Verification executed
|
|
141
|
+
- Requirements implemented · No unrelated changes · Verification executed + reported · Docs updated when source truth changed.
|
|
162
142
|
|
|
163
143
|
## Handoff Fullstack Rules
|
|
164
144
|
<!-- RULE: HAND-02 -->
|
|
165
|
-
- `docs/AI_HANDOFF/RUN.md` là run cursor có thẩm quyền; `Phase:` ≠ `done`/`blocked`
|
|
166
|
-
- 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>`).
|
|
167
|
-
- 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`.
|
|
145
|
+
- `docs/AI_HANDOFF/RUN.md` là run cursor có thẩm quyền; `Phase:` ≠ `done`/`blocked` = run còn sống — Stop gate từ chối stop, trả về `Next:`. Chỉ `HANDOFF FULLSTACK COMPLETE`/`BLOCKED` kết thúc run — recap/checkpoint không phải completion; resume tự động mọi task chưa xong. Kết thúc cycle: docs sync → archive `archive/cycle-NN/` → `Phase: done`; `handoff-clear` bắt buộc đóng RUN.md. Full rules: `docs/AI_HANDOFF/RULES.md`.
|
|
168
146
|
|
|
169
147
|
## Compact Instructions
|
|
170
|
-
|
|
148
|
+
Compact giữa handoff run: giữ goal, RUN.md path + phase, task inventory + task đang làm, `Next:` step, blockers, verification evidence, commits, worktree/copy-back state, "compact không phải completion". Sau compact: đọc lại RUN.md + INDEX.md rồi chạy `Next:`.
|
|
171
149
|
{{codegraphSection}}
|