@damphuquy/agent-init 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +34 -11
  2. package/README.vi.md +34 -11
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +70 -3
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +6 -2
  8. package/dist/config.js.map +1 -1
  9. package/dist/scaffolder.d.ts +8 -1
  10. package/dist/scaffolder.d.ts.map +1 -1
  11. package/dist/scaffolder.js +382 -4
  12. package/dist/scaffolder.js.map +1 -1
  13. package/dist/types.d.ts +41 -0
  14. package/dist/types.d.ts.map +1 -1
  15. package/dist/ui.d.ts.map +1 -1
  16. package/dist/ui.js +9 -0
  17. package/dist/ui.js.map +1 -1
  18. package/package.json +1 -1
  19. package/templates/en/.agents/behavior.md +9 -0
  20. package/templates/en/.agents/guardrails.md +22 -0
  21. package/templates/en/AGENTS.md +28 -11
  22. package/templates/en/instruction-version.json +70 -0
  23. package/templates/en/process/_seeds/_GUIDE.md +10 -1
  24. package/templates/en/process/_seeds/plan-template.md.seed +6 -5
  25. package/templates/en/process/_seeds/review-template.md.seed +2 -0
  26. package/templates/en/process/_seeds/task-lite.md.seed +88 -0
  27. package/templates/en/process/_seeds/task-template.md.seed +8 -0
  28. package/templates/en/process/development-protocols/orchestration.md +19 -0
  29. package/templates/vi/.agents/behavior.md +9 -0
  30. package/templates/vi/.agents/guardrails.md +22 -0
  31. package/templates/vi/AGENTS.md +28 -11
  32. package/templates/vi/instruction-version.json +70 -0
  33. package/templates/vi/process/_seeds/_GUIDE.md +10 -1
  34. package/templates/vi/process/_seeds/plan-template.md.seed +6 -5
  35. package/templates/vi/process/_seeds/review-template.md.seed +2 -0
  36. package/templates/vi/process/_seeds/task-lite.md.seed +88 -0
  37. package/templates/vi/process/_seeds/task-template.md.seed +8 -0
  38. package/templates/vi/process/development-protocols/orchestration.md +19 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@damphuquy/agent-init",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "description": "Scaffolding CLI to bootstrap RIPER-5 Coding Agents & Operational Workspace",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -74,9 +74,18 @@ In continuous autonomous execution (DELEGATED / Fast-Track), the agent opens wit
74
74
  | **`process/general-plans/active/{task-slug}/`** | `/task`<br>`/small-task`<br>`/bug`<br>`/quick-fix` | `small task`, `general changes`, `small changes`, `bug fix`, `quick fix` | Standalone tasks, quick bug fixes, general adjustments (< 5 files). Default mode: **PAIR**. |
75
75
  | **`process/general-plans/active/{task-slug}/`** | `/hotfix` | `hotfix`, `emergency fix`, `production bug` | Emergency production fix. Auto-activates **DELEGATED / Fast-Track** mode (auto-certifies G0–G2, pauses only at G3). |
76
76
  | *(Scope-derived)* | `/fast-track`<br>`/delegated`<br>`/auto` | `fast-track`, `autonomous`, `auto-advance`, `skip permissions` | Full autonomous execution. Sets `<working_mode>DELEGATED</working_mode>` and runs continuously through all phases. |
77
+ | *(Framework Maintenance)* | `/update`<br>`/upgrade` | `update instructions`, `upgrade framework`, `check updates` | Maintenance protocol: queries remote registry for a newer framework version. If a newer version exists, updates the instructions framework while preserving user configs (`preserveUserFiles`) and updates `instruction-version.json`. If already on the latest version, outputs `"nothing changed"`. |
77
78
 
78
79
  *Fallback Rule:* If no explicit keyword or slash command is found in the prompt, infer from scope (< 5 files or localized fix $\rightarrow$ `general-plans/`; new capability or multi-module impact $\rightarrow$ `features/`).
79
80
 
81
+ ### Framework Update Protocol (`/update`):
82
+ When the prompt begins with `/update` or `/upgrade` (or user asks to update instructions/framework):
83
+ 1. **Inspect Local Version:** Read `instruction-version.json` at workspace root to inspect current `version`, `language`, and `updateStrategy`.
84
+ 2. **Query Latest Version:** Query the registry (e.g. `npm view @damphuquy/agent-init version` or execute `npx @damphuquy/agent-init update`).
85
+ 3. **Conditional Update:**
86
+ - **If newer version found:** Execute framework update (e.g. `npx @damphuquy/agent-init update` or `npx @damphuquy/agent-init@latest . --force`), preserving project-specific files defined in `preserveUserFiles` (`AGENTS.md#validation_commands`, active tasks). Update `instruction-version.json` timestamp and version. Report upgrade details.
87
+ - **If no newer version (already up to date):** Respond directly with `"nothing changed"` (e.g. `nothing changed: instruction framework is already at the latest version vX.Y.Z`) and make no file changes.
88
+
80
89
  ### Automated Scaffolding & Activation Steps:
81
90
  1. **Derive Slug:** Generate a concise, kebab-case `{task-slug}` from the prompt (e.g., `CHG-001-change-password`, `AUTH-002-rate-limiting`, or `{TICKET-ID}-{slug}`).
82
91
  2. **Create Directory:** Create `process/features/active/{task-slug}` or `process/general-plans/active/{task-slug}`.
@@ -111,4 +111,26 @@
111
111
  4. **State Finalization:** Ensure `state.md` is cleanly synchronized and generate `handoff.md`.
112
112
  </housekeeping_protocol>
113
113
 
114
+ ---
115
+
116
+ ## 7. Cross-Harness & Independent Review Principle
117
+
118
+ <cross_harness_review>
119
+ Rule: **The implementer cannot be the sole reviewer.**
120
+ - To eliminate confirmation bias and algorithmic blind spots, the REVIEW phase should be conducted with fresh context, an independent reviewer subagent, or a distinct model harness when available.
121
+ - Reviewers evaluate code strictly against the `<scope_contract>`, security guidelines, and behavioral invariants without inheriting the implementer's speculative reasoning.
122
+ </cross_harness_review>
123
+
124
+ ---
125
+
126
+ ## 8. Graduated Quality Gate Strictness
127
+
128
+ <gate_strictness>
129
+ Quality gates operate under a 3-tier graduated enforcement model:
130
+
131
+ - **Hard-Mandatory (Blocking):** Zero tolerance. Must pass 100% without exception (e.g. typecheck, test suites, zero out-of-scope edits). Failure immediately blocks task completion.
132
+ - **Soft-Mandatory (Overridable with Justification):** Required by default. May only be overridden by the human engineer with a recorded rationale in `<override_reason>` (e.g. temporary performance baseline waiver).
133
+ - **Advisory (Informational):** Non-blocking recommendations, lint hints, or future technical debt observations logged into `review.md`.
134
+ </gate_strictness>
135
+
114
136
  </agent_guardrails>
@@ -10,6 +10,7 @@
10
10
 
11
11
  This file ONLY contains what is unique to this project: toolchain commands,
12
12
  architecture guardrail calibration, and path references.
13
+ Framework versioning and update procedures are managed via [`instruction-version.json`](instruction-version.json).
13
14
  </overview>
14
15
 
15
16
  ---
@@ -21,6 +22,7 @@
21
22
 
22
23
  | File | What it governs |
23
24
  |------|----------------|
25
+ | [`instruction-version.json`](instruction-version.json) | Framework version manifest, compatibility, and update strategy |
24
26
  | [`.agents/behavior.md`](.agents/behavior.md) | Mode declaration, session startup, context priority |
25
27
  | [`.agents/guardrails.md`](.agents/guardrails.md) | Retry budget, escalation triggers, completion gate |
26
28
  | [`.agents/conventions/naming.md`](.agents/conventions/naming.md) | Naming and structural hygiene |
@@ -35,23 +37,32 @@
35
37
  <foundations>
36
38
  <!-- Pillar 1: Task & Specification -->
37
39
  <pillar id="task_spec" title="Task & Specification">
38
- <rule>Single Source of Truth: Active task file in [`process/features/active/{feature}/task.md`](process/features/) or [`process/general-plans/active/{task}/task.md`](process/general-plans/) (instantiated from [`process/_seeds/task-template.md.seed`](process/_seeds/task-template.md.seed)).</rule>
39
- <rule>Prompt & Slash Command Initialization: Users can request and run tasks directly via prompt or pseudo-slash command prefixes. The Agent automatically routes the folder and instantiates `task.md` from [`process/_seeds/task-template.md.seed`](process/_seeds/task-template.md.seed):
40
- - Commands `/feature`, `/big-task`, `/epic` or keywords `big task`, `feature`, `big changes`: routes to `process/features/active/{task-slug}/task.md` (PAIR mode).
41
- - Commands `/task`, `/small-task`, `/bug` or keywords `small task`, `general changes`, `small changes`: routes to `process/general-plans/active/{task-slug}/task.md` (PAIR mode).
42
- - Command `/hotfix`: routes to `process/general-plans/active/{task-slug}/task.md` and runs in DELEGATED mode.
40
+ <rule>Single Source of Truth: Active task file in [`process/features/active/{feature}/task.md`](process/features/) (Full Track) or [`process/general-plans/active/{task}/task-lite.md`](process/general-plans/) (Lite Track).</rule>
41
+ <rule>Dual-Track Routing:
42
+ - **Full Track (7 artifacts):** For complex features, epics, and cross-cutting refactoring. Initiated from [`process/_seeds/task-template.md.seed`](process/_seeds/task-template.md.seed) in `process/features/active/{task-slug}/`. Chain: `task.md research.md → decision.md → plan.md → state.md → review.md → handoff.md`.
43
+ - **Lite Track (1 artifact):** For quick tasks, bugfixes, micro-features, and hotfixes. Initiated from [`process/_seeds/task-lite.md.seed`](process/_seeds/task-lite.md.seed) in `process/general-plans/active/{task-slug}/task-lite.md`. Consolidates spec, allowed files, slices, and verification gates into a single file to eliminate token overhead.</rule>
44
+ <rule>Prompt & Slash Command Initialization: Users can request and run tasks directly via prompt or pseudo-slash command prefixes:
45
+ - Commands `/feature`, `/big-task`, `/epic` or keywords `big task`, `feature`, `big changes`: routes to Full Track in `process/features/active/{task-slug}/task.md` (PAIR mode).
46
+ - Commands `/task`, `/small-task`, `/bug` or keywords `small task`, `bug`: routes to Lite Track in `process/general-plans/active/{task-slug}/task-lite.md` (PAIR mode).
47
+ - Command `/hotfix`: routes to Lite Track in `process/general-plans/active/{task-slug}/task-lite.md` and runs in DELEGATED mode.
43
48
  - Commands `/fast-track`, `/delegated`: executes autonomously through all phases.
44
- The Agent creates the directory, hydrates `<goal>` and `<acceptance_criteria>` from the prompt, and initiates the RESEARCH phase immediately.</rule>
45
- <rule>Define changes via Goal, Current Behavior, Expected Behavior, Invariants, and `<out_of_scope>`.</rule>
46
- <rule>Acceptance Criteria (AC) must be unambiguous, verifiable markdown checkboxes (`- [ ]`).</rule>
47
- <rule>Every task has a master contract (`task.md`) and a full artifact chain: `research.md → decision.md → plan.md → state.md → review.md → handoff.md`.</rule>
49
+ - Command `/sync`: runs `npx @damphuquy/agent-init sync` to mirror `AGENTS.md` to `.cursor/rules/`, `CLAUDE.md`, and `.windsurfrules`.
50
+ - Command `/verify-gate [G2|G3]`: verifies that no modified files in `git diff` violate `<allowed_files>`.
51
+ - Command /update: checks for a new framework version (via `instruction-version.json` and registry); updates instructions if a newer version exists, or outputs "nothing changed" if already on the latest version.</rule>
52
+ <rule>Define changes via Goal, Invariants, `<scope_contract>`, and Acceptance Criteria.</rule>
48
53
  </pillar>
49
54
 
50
- <!-- Pillar 2: Context Navigation -->
51
- <pillar id="context" title="Context Navigation">
55
+ <!-- Pillar 2: Context Navigation & Model Context Protocol (MCP) -->
56
+ <pillar id="context" title="Context Navigation & MCP">
52
57
  <rule>Gather minimum sufficient context. No full-repo scanning or drive-by refactoring.</rule>
53
58
  <rule>Follow information priority defined in [`.agents/behavior.md`](.agents/behavior.md).</rule>
54
59
  <rule>Project context routes via [`process/context/all-context.md`](process/context/all-context.md).</rule>
60
+ <mcp_tools>
61
+ When available, agents must prioritize native Model Context Protocol (MCP) tools:
62
+ - Database MCP: Inspect schemas and run read-only queries instead of hardcoded mock assumptions.
63
+ - Git MCP: Query log/diff cleanly without unconstrained shell parsing.
64
+ - Browser/DevTools MCP: Inspect live DOM/accessibility tree during UI review.
65
+ </mcp_tools>
55
66
  </pillar>
56
67
 
57
68
  <!-- Pillar 3: Engineering Harness & Guardrails -->
@@ -62,6 +73,12 @@
62
73
  # Node/TS: npm run test && npm run typecheck && npm run lint
63
74
  # Go: go test ./... && go vet ./...
64
75
  </validation_commands>
76
+ <action_governance>
77
+ Agents operate under strict containment:
78
+ - Anti-Escape: Never modify files outside `<allowed_files>` or unapproved root configurations (`package.json`, workflow CI files) unless explicitly specified in `plan.md`.
79
+ - Safety Blacklist: Never execute destructive commands (`git push -f`, `git reset --hard`, recursive unconstrained deletes, `DROP TABLE`).
80
+ - Non-Implementer Review: Authors must never unilaterally certify their own work; review requires independent verification.
81
+ </action_governance>
65
82
  <architecture_guardrail>
66
83
  Clean Architecture & Dependency Injection provide structural guidance, NOT an
67
84
  instruction to blindly over-engineer simple utilities.
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "name": "@damphuquy/agent-init",
4
+ "version": "3.0.0",
5
+ "framework": "RIPER-5",
6
+ "frameworkVersion": "3.0.0",
7
+ "language": "en",
8
+ "description": "Instruction and governance template manifest for AI coding agents and operational workspace.",
9
+ "installedAt": "2026-09-09T00:00:00.000Z",
10
+ "updatedAt": "2026-09-09T00:00:00.000Z",
11
+ "manifest": {
12
+ "core": [
13
+ "AGENTS.md",
14
+ "instruction-version.json"
15
+ ],
16
+ "controlLayer": [
17
+ ".agents/README.md",
18
+ ".agents/behavior.md",
19
+ ".agents/guardrails.md",
20
+ ".agents/conventions/naming.md"
21
+ ],
22
+ "seeds": [
23
+ "process/_seeds/_GUIDE.md",
24
+ "process/_seeds/task-template.md.seed",
25
+ "process/_seeds/task-lite.md.seed",
26
+ "process/_seeds/context-group.md.seed",
27
+ "process/_seeds/decision-template.md.seed",
28
+ "process/_seeds/plan-template.md.seed",
29
+ "process/_seeds/state-template.md.seed",
30
+ "process/_seeds/review-template.md.seed",
31
+ "process/_seeds/handoff-template.md.seed",
32
+ "process/_seeds/cancellation-template.md.seed",
33
+ "process/_seeds/pause-template.md.seed",
34
+ "process/_seeds/results-template.tsv.seed",
35
+ "process/_seeds/program-template.md.seed"
36
+ ],
37
+ "context": [
38
+ "process/context/all-context.md",
39
+ "process/context/planning/all-planning.md",
40
+ "process/context/tests/all-tests.md"
41
+ ],
42
+ "protocols": [
43
+ "process/development-protocols/all-development-protocols.md",
44
+ "process/development-protocols/orchestration.md",
45
+ "process/development-protocols/implementation-standards.md"
46
+ ]
47
+ },
48
+ "updateStrategy": {
49
+ "slashCommand": "/update",
50
+ "checkCommand": "npm view @damphuquy/agent-init version",
51
+ "updateCommand": "npx @damphuquy/agent-init update",
52
+ "forceUpdateCommand": "npx @damphuquy/agent-init@latest . --force",
53
+ "preserveUserFiles": [
54
+ "AGENTS.md#validation_commands",
55
+ "process/features/**",
56
+ "process/general-plans/**"
57
+ ],
58
+ "safeToOverwrite": [
59
+ ".agents/**",
60
+ "process/_seeds/**",
61
+ "process/context/**",
62
+ "process/development-protocols/**",
63
+ "instruction-version.json"
64
+ ]
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/DamPhuQuy/agent-instructions"
69
+ }
70
+ }
@@ -23,9 +23,18 @@
23
23
  <catalog>
24
24
 
25
25
  <seed type="task" path="task-template.md.seed">
26
- Master contract and state record for the full RIPER-5 lifecycle.
26
+ Master contract and state record for the full RIPER-5 lifecycle (Full Track: 7 artifacts).
27
27
  Contains: Task Control metadata (working_mode PAIR/DELEGATED), Spec, Context Boundaries, Verification Strategy,
28
28
  Decisions, RIPER-5 Execution Plan (with Gates G0–G3), and Guardrails.
29
+ Recommended for: Complex features, architectural refactors, and Epics in `process/features/`.
30
+ </seed>
31
+
32
+ <seed type="task-lite" path="task-lite.md.seed">
33
+ Consolidated single-file contract for RIPER-5 Lite Track (1 artifact).
34
+ Combines: Intent, Invariants, Scope Contract (<allowed_files>), Compact Vertical Slices,
35
+ and Consolidated Verification Gates (G1/G2/G3).
36
+ Recommended for: Small tasks, bugfixes, micro-features, and hotfixes in `process/general-plans/`.
37
+ Reduces token tax and context overhead by over 70%.
29
38
  </seed>
30
39
 
31
40
  <seed type="research" path="context-group.md.seed">
@@ -109,11 +109,11 @@
109
109
  <!-- Populated during and after Execute phase -->
110
110
  <verification_matrix>
111
111
 
112
- | AC / Risk | Test / Command | Expected Evidence | Actual Result |
113
- |---|---|---|---|
114
- | AC-1 | | | |
115
- | AC-2 | | | |
116
- | AC-3 | | | |
112
+ | AC / Risk | Test / Command | Expected Evidence | Strictness (hard-mandatory / soft-mandatory / advisory) | Actual Result |
113
+ |---|---|---|---|---|
114
+ | AC-1 | | | hard-mandatory | |
115
+ | AC-2 | | | hard-mandatory | |
116
+ | AC-3 | | | advisory | |
117
117
 
118
118
  </verification_matrix>
119
119
 
@@ -124,6 +124,7 @@
124
124
  <gate id="G2">
125
125
  - [ ] Every slice has a defined verifier.
126
126
  - [ ] Scope contract (allowed / forbidden) approved.
127
+ - [ ] Enforcement strictness assigned per AC/verification item.
127
128
  - [ ] Stop conditions defined per slice.
128
129
  - [ ] Rollback point defined per slice.
129
130
  - [ ] Allowed commands listed.
@@ -7,6 +7,7 @@
7
7
  <phase>REVIEW</phase>
8
8
  <mode>READ-ONLY</mode>
9
9
  <reviewer></reviewer>
10
+ <reviewer_harness></reviewer_harness> <!-- e.g. human-pair / independent-subagent / cross-model-harness -->
10
11
  <last_updated></last_updated>
11
12
  </review_status>
12
13
 
@@ -136,6 +137,7 @@
136
137
 
137
138
  <gate id="G3">
138
139
  - [ ] Full diff reviewed (zero extraneous changes).
140
+ - [ ] Independent review verified (implementer was not sole reviewer).
139
141
  - [ ] Housekeeping complete: all transient debug logs, print statements, and scratch files removed.
140
142
  - [ ] All required evidence exists and is attached.
141
143
  - [ ] All findings triaged (Confirmed Defects resolved or risk-accepted).
@@ -0,0 +1,88 @@
1
+ # Task Lite: [TASK-ID] [Task Title]
2
+
3
+ <task_lite version="3.0" framework="RIPER-5-Lite">
4
+
5
+ <!-- ════════════════════════════════════════════
6
+ SECTION 0 — TASK CONTROL
7
+ ════════════════════════════════════════════ -->
8
+ <task_control>
9
+ <track>LITE</track> <!-- LITE: Single-file artifact for fast iteration, bugfixes, micro-tasks -->
10
+ <status>ACTIVE</status> <!-- ACTIVE | REVIEW | COMPLETED | CANCELLED -->
11
+ <priority>P2</priority> <!-- P0=urgent | P1=high | P2=normal | P3=low -->
12
+ <working_mode>PAIR</working_mode> <!-- PAIR (review at gates) | DELEGATED (autonomous run) -->
13
+ <current_phase>PLAN</current_phase> <!-- PLAN | EXECUTE | REVIEW -->
14
+ <owner>@engineer</owner>
15
+ </task_control>
16
+
17
+ ---
18
+
19
+ ## 1. Intent & Specification
20
+
21
+ <specification>
22
+ <goal>
23
+ [Clear description of the fix, enhancement, or micro-feature]
24
+ </goal>
25
+
26
+ <invariants>
27
+ - [Key constraint that must NOT be broken during this task]
28
+ </invariants>
29
+
30
+ <acceptance_criteria>
31
+ - [ ] AC-1: [Specific verifiable outcome with expected behavior]
32
+ - [ ] AC-2: [Automated tests or lint checks passing]
33
+ </acceptance_criteria>
34
+
35
+ <!-- Definition-of-Ready (DoR): Do not begin coding if problem or allowed files are vague -->
36
+ <definition_of_ready>
37
+ - [ ] Intent and acceptance criteria are clear without assumptions.
38
+ - [ ] Allowed files in Section 2 are identified.
39
+ </definition_of_ready>
40
+ </specification>
41
+
42
+ ---
43
+
44
+ ## 2. Scope Contract & File Whitelist
45
+
46
+ <scope_contract>
47
+ <allowed_files>
48
+ <file>[exact/path/to/file1.ts]</file>
49
+ <file>[exact/path/to/file1.test.ts]</file>
50
+ </allowed_files>
51
+
52
+ <forbidden_files>
53
+ <file>[any/file/outside/the/scope]</file>
54
+ </forbidden_files>
55
+ </scope_contract>
56
+
57
+ ---
58
+
59
+ ## 3. Execution Plan (Compact Slices)
60
+
61
+ <execution_plan>
62
+ ### Slice 1: [Core Change Title]
63
+ - **Action:** [What code or test to write]
64
+ - **Verifier:** [e.g., npm test path/to/test.ts || pytest path/to/test.py]
65
+ - **Status:** [ ] PENDING / IN_PROGRESS / DONE
66
+
67
+ ### Slice 2 (Optional): [Secondary / Integration Change]
68
+ - **Action:** [What code or test to write]
69
+ - **Verifier:** [Command to run]
70
+ - **Status:** [ ] PENDING / IN_PROGRESS / DONE
71
+ </execution_plan>
72
+
73
+ ---
74
+
75
+ ## 4. Consolidated Verification & Gates
76
+
77
+ <verification_gates>
78
+ <!-- Gate G1/G2: Scope & Architecture check (pre-execution) -->
79
+ - [ ] **Gate G1/G2 (Plan Approved):** Allowed files confirmed, test verifiers defined.
80
+
81
+ <!-- Gate G3: Verification evidence (post-execution) -->
82
+ - [ ] **Gate G3 (Ready for Handoff):**
83
+ - [ ] Verifier commands executed cleanly (Zero errors).
84
+ - [ ] Git diff inspected — NO files touched outside `<allowed_files>`.
85
+ - [ ] No temporary debug logs or unintended changes.
86
+ </verification_gates>
87
+
88
+ </task_lite>
@@ -53,6 +53,14 @@
53
53
  - [ ] AC-2: [Edge cases, validation rules, or error handling]
54
54
  - [ ] AC-3: [Automated tests added/updated and passing]
55
55
  </acceptance_criteria>
56
+
57
+ <!-- Definition-of-Ready (DoR) Gate — Frontload the thinking before dispatch -->
58
+ <definition_of_ready>
59
+ - [ ] Target outcome and acceptance criteria are verifiable without guessing.
60
+ - [ ] Invariants and <out_of_scope> boundaries are explicit.
61
+ - [ ] Open questions resolved or scheduled in decision.md (No speculative coding).
62
+ <!-- STOP: If any DoR item is unchecked, halt and ask clarifying questions first! -->
63
+ </definition_of_ready>
56
64
  </specification>
57
65
 
58
66
  ---
@@ -98,4 +98,23 @@
98
98
  </rule>
99
99
  </coordination_and_recovery>
100
100
 
101
+ ---
102
+
103
+ ## 6. Cross-Harness & Independent Review Protocol
104
+
105
+ <cross_harness_review>
106
+ <rule id="implementer_cannot_review">
107
+ The subagent or harness that authored an implementation must NEVER act as the sole approver of that slice.
108
+ To prevent confirmation bias, delegate the verification of complex or security-sensitive slices to an independent review subagent, or require human gate sign-off.
109
+ </rule>
110
+
111
+ <rule id="adversarial_verification">
112
+ Review subagents must be tasked with finding edge-case regressions, compliance violations, and scope breaches against `<scope_contract>`, rather than merely validating the author's declared success.
113
+ </rule>
114
+
115
+ <rule id="fresh_context_mandate">
116
+ Independent review subagents should operate with clean context: they receive the task requirements, the git diff, and the test command, without the conversational baggage or speculative rationale of the implementation loop.
117
+ </rule>
118
+ </cross_harness_review>
119
+
101
120
  </orchestration_protocol>
@@ -74,9 +74,18 @@ Trong chế độ chạy liên tục (DELEGATED / Fast-Track), Agent mở đầu
74
74
  | **`process/general-plans/active/{task-slug}/`** | `/task`<br>`/small-task`<br>`/bug`<br>`/quick-fix` | `small task`, `general changes`, `small changes`, `bug fix`, `quick fix` (hoặc: `task nhỏ`, `thay đổi chung`, `thay đổi nhỏ`, `sửa lỗi`) | Tác vụ độc lập, sửa bug nhanh, thay đổi nhỏ (< 5 files). Chế độ mặc định: **PAIR**. |
75
75
  | **`process/general-plans/active/{task-slug}/`** | `/hotfix` | `hotfix`, `khẩn cấp`, `emergency fix` | Sửa lỗi khẩn cấp production. Tự động kích hoạt chế độ **DELEGATED / Fast-Track** (vượt tự động G0–G2, dừng ở G3). |
76
76
  | *(Theo phạm vi)* | `/fast-track`<br>`/delegated`<br>`/auto` | `fast-track`, `autonomous`, `tự động chạy`, `skip permissions` | Chạy tự trị hoàn toàn. Tự động đặt `<working_mode>DELEGATED</working_mode>` và thực thi liên tục qua toàn bộ chu trình. |
77
+ | *(Bảo trì Framework)* | `/update`<br>`/upgrade` | `update instructions`, `cập nhật instruction`, `nâng cấp framework`, `kiểm tra bản mới` | Giao thức bảo trì: kiểm tra phiên bản framework mới nhất từ registry. Nếu phát hiện version mới hơn, cập nhật bộ quy chuẩn chỉ dẫn (bảo toàn tệp cấu hình dự án `preserveUserFiles`) và cập nhật `instruction-version.json`. Nếu đang ở bản mới nhất, thông báo `"nothing changed"`. |
77
78
 
78
79
  *Quy tắc suy luận dự phòng (Fallback):* Nếu prompt không chứa từ khóa hay slash command rõ ràng, Agent tự động ước lượng quy mô công việc (< 5 files hoặc sửa lỗi cục bộ $\rightarrow$ `general-plans/`; tính năng mới hoặc ảnh hưởng diện rộng $\rightarrow$ `features/`).
79
80
 
81
+ ### Giao Thức Cập Nhật Framework (`/update`):
82
+ Khi prompt bắt đầu bằng lệnh `/update` hoặc `/upgrade` (hoặc người dùng yêu cầu cập nhật instruction/framework):
83
+ 1. **Đọc phiên bản hiện hành:** Đọc tệp `instruction-version.json` tại thư mục gốc của dự án để lấy `version`, `language`, và `updateStrategy`.
84
+ 2. **Tra cứu phiên bản mới:** Kiểm tra phiên bản mới nhất trên registry (`npm view @damphuquy/agent-init version` hoặc chạy lệnh `npx @damphuquy/agent-init update`).
85
+ 3. **Xử lý có điều kiện:**
86
+ - **Nếu có phiên bản mới hơn:** Chạy lệnh cập nhật (ví dụ: `npx @damphuquy/agent-init update` hoặc `npx @damphuquy/agent-init@latest . --force`), bảo toàn các tệp dự án theo danh mục `preserveUserFiles` trong `instruction-version.json` (như lệnh test trong `AGENTS.md`, các task đang làm). Cập nhật `version` và `updatedAt` trong `instruction-version.json`. Báo cáo tóm tắt nâng cấp từ bản cũ lên bản mới.
87
+ - **Nếu không có bản mới hơn (đang là mới nhất):** Phản hồi trực tiếp `"nothing changed"` (ví dụ: `nothing changed: quy chuẩn chỉ dẫn đang ở phiên bản mới nhất vX.Y.Z`) và tuyệt đối không sửa đổi file nào.
88
+
80
89
  ### Quy Trình Khởi Tạo & Kích Hoạt Tự Động:
81
90
  1. **Đặt tên slug:** Đặt `{task-slug}` ngắn gọn, chuẩn kebab-case dựa theo yêu cầu (ví dụ: `CHG-001-change-password`, `AUTH-002-rate-limiting`, hoặc `{TICKET-ID}-{slug}`).
82
91
  2. **Tạo thư mục:** Tạo thư mục `process/features/active/{task-slug}` hoặc `process/general-plans/active/{task-slug}`.
@@ -111,4 +111,26 @@
111
111
  4. **Chốt Trạng Thái:** Đảm bảo `state.md` được đồng bộ sạch sẽ và tạo tệp `handoff.md`.
112
112
  </housekeeping_protocol>
113
113
 
114
+ ---
115
+
116
+ ## 7. Nguyên Tắc Đánh Giá Độc Lập & Đa Harness (Cross-Harness Review)
117
+
118
+ <cross_harness_review>
119
+ Quy tắc: **Người thực hiện không thể là người đánh giá duy nhất (The implementer cannot be the sole reviewer).**
120
+ - Nhằm triệt tiêu thiên kiến xác nhận (confirmation bias) và điểm mù thuật toán, giai đoạn REVIEW nên được thực hiện với ngữ cảnh mới, subagent reviewer độc lập hoặc harness mô hình tách biệt khi có thể.
121
+ - Reviewer đánh giá mã nguồn nghiêm ngặt dựa trên `<scope_contract>`, hướng dẫn bảo mật và các bất biến hành vi mà không kế thừa các suy luận chủ quan của người thực hiện.
122
+ </cross_harness_review>
123
+
124
+ ---
125
+
126
+ ## 8. Phân Cấp Độ Nghiêm Ngặt Của Quality Gate (Graduated Gate Strictness)
127
+
128
+ <gate_strictness>
129
+ Quality gate vận hành theo mô hình phân cấp 3 tầng nghiêm ngặt:
130
+
131
+ - **Hard-Mandatory (Bắt Buộc Tuyệt Đối - Chặn):** Không có ngoại lệ. Phải vượt qua 100% (ví dụ: typecheck, test suite, không có chỉnh sửa ngoài phạm vi). Thất bại sẽ lập tức chặn hoàn thành task.
132
+ - **Soft-Mandatory (Bắt Buộc Mềm - Ghi Đè Khi Có Lý Do):** Mặc định bắt buộc. Chỉ có thể được ghi đè bởi kỹ sư con người kèm lý do hợp lý được ghi nhận trong `<override_reason>` (ví dụ: miễn giảm tạm thời baseline hiệu năng).
133
+ - **Advisory (Khuyến Nghị - Thông Tin):** Đóng góp khuyến nghị không chặn, gợi ý linter hoặc ghi nhận nợ kỹ thuật tương lai vào `review.md`.
134
+ </gate_strictness>
135
+
114
136
  </agent_guardrails>
@@ -10,6 +10,7 @@
10
10
 
11
11
  Tệp này CHỈ chứa những gì đặc thù của dự án: lệnh kiểm thử/build,
12
12
  hiệu chỉnh ranh giới kiến trúc và tham chiếu đường dẫn.
13
+ Phiên bản framework và quy trình cập nhật chỉ dẫn được quản lý qua [`instruction-version.json`](instruction-version.json).
13
14
  </overview>
14
15
 
15
16
  ---
@@ -21,6 +22,7 @@
21
22
 
22
23
  | Tệp | Phạm vi quản lý |
23
24
  |-----|----------------|
25
+ | [`instruction-version.json`](instruction-version.json) | Định danh phiên bản framework, tính tương thích và chiến lược cập nhật |
24
26
  | [`.agents/behavior.md`](.agents/behavior.md) | Khai báo chế độ (Mode), khởi động session, thứ tự ưu tiên ngữ cảnh |
25
27
  | [`.agents/guardrails.md`](.agents/guardrails.md) | Ngân sách thử lại (Retry budget), điều kiện kích hoạt dừng khẩn cấp, cổng hoàn thành |
26
28
  | [`.agents/conventions/naming.md`](.agents/conventions/naming.md) | Quy chuẩn đặt tên và vệ sinh cấu trúc mã nguồn |
@@ -35,23 +37,32 @@
35
37
  <foundations>
36
38
  <!-- Trụ cột 1: Task & Specification -->
37
39
  <pillar id="task_spec" title="Task & Đặc tả (Specification)">
38
- <rule>Nguồn sự thật duy nhất (Single Source of Truth): Tệp task đang thực thi trong [`process/features/active/{feature}/task.md`](process/features/) hoặc [`process/general-plans/active/{task}/task.md`](process/general-plans/) (khởi tạo từ [`process/_seeds/task-template.md.seed`](process/_seeds/task-template.md.seed)).</rule>
39
- <rule>Khởi tạo qua Prompt & Lệnh Gạch Chéo (Prompt & Slash Command Initialization): Người dùng có thể yêu cầu tạo và chạy task trực tiếp bằng prompt hoặc tiền tố lệnh gạch chéo (Pseudo-Slash Commands). Agent tự động định tuyến thư mục và khởi tạo `task.md` từ [`process/_seeds/task-template.md.seed`](process/_seeds/task-template.md.seed):
40
- - pháp `/feature`, `/big-task`, `/epic` hoặc các từ khóa `big task`, `feature`, `big changes`: định tuyến vào `process/features/active/{task-slug}/task.md` (chế độ PAIR).
41
- - pháp `/task`, `/small-task`, `/bug` hoặc các từ khóa `small task`, `general changes`, `small changes`: định tuyến vào `process/general-plans/active/{task-slug}/task.md` (chế độ PAIR).
42
- - pháp `/hotfix`: định tuyến vào `process/general-plans/active/{task-slug}/task.md` và chạy chế độ DELEGATED.
40
+ <rule>Nguồn sự thật duy nhất (Single Source of Truth): Tệp task đang thực thi trong [`process/features/active/{feature}/task.md`](process/features/) (Full Track) hoặc [`process/general-plans/active/{task}/task-lite.md`](process/general-plans/) (Lite Track).</rule>
41
+ <rule> chế Định tuyến Đôi (Dual-Track Routing):
42
+ - **Full Track (7 artifacts):** Dành cho tính năng phức tạp, epic lớn, tái cấu trúc kiến trúc. Khởi tạo từ [`process/_seeds/task-template.md.seed`](process/_seeds/task-template.md.seed) tại `process/features/active/{task-slug}/`. Chuỗi: `task.md research.md → decision.md → plan.md → state.md → review.md → handoff.md`.
43
+ - **Lite Track (1 artifact):** Dành cho tác vụ nhanh, sửa lỗi (bugfix), micro-tasks, hotfix. Khởi tạo từ [`process/_seeds/task-lite.md.seed`](process/_seeds/task-lite.md.seed) tại `process/general-plans/active/{task-slug}/task-lite.md`. Gom toàn bộ spec, phạm vi file, kế hoạch cắt lát và cổng kiểm chứng vào duy nhất 1 file để triệt tiêu chi phí ngữ cảnh (token tax).</rule>
44
+ <rule>Khởi tạo qua Prompt & Lệnh Gạch Chéo (Prompt & Slash Command Initialization): Người dùng có thể yêu cầu tạo và chạy task trực tiếp:
45
+ - Cú pháp `/feature`, `/big-task`, `/epic` hoặc từ khóa `big task`, `feature`, `big changes`: định tuyến Full Track vào `process/features/active/{task-slug}/task.md` (chế độ PAIR).
46
+ - Cú pháp `/task`, `/small-task`, `/bug` hoặc từ khóa `small task`, `bug`: định tuyến Lite Track vào `process/general-plans/active/{task-slug}/task-lite.md` (chế độ PAIR).
47
+ - Cú pháp `/hotfix`: định tuyến Lite Track vào `process/general-plans/active/{task-slug}/task-lite.md` và chạy chế độ DELEGATED.
43
48
  - Cú pháp `/fast-track`, `/delegated`: chạy tự trị liên tục qua toàn bộ chu trình.
44
- Agent tự tạo thư mục, điền mục tiêu & tiêu chí AC từ prompt vào `task.md`bắt đầu ngay pha RESEARCH.</rule>
45
- <rule>Định nghĩa thay đổi thông qua Mục tiêu (Goal), Hành vi hiện tại (Current Behavior), Hành vi kỳ vọng (Expected Behavior), Bất biến (Invariants) và Ngoài phạm vi (`<out_of_scope>`).</rule>
46
- <rule>Tiêu chí nghiệm thu (Acceptance Criteria - AC) phải ràng, kiểm chứng được dưới dạng checkbox markdown (`- [ ]`).</rule>
47
- <rule>Mỗi task đều bản hợp đồng master (`task.md`) chuỗi artifact hoàn chỉnh: `research.md decision.md plan.md state.md review.md → handoff.md`.</rule>
49
+ - pháp `/sync`: thực thi `npx @damphuquy/agent-init sync` để ánh xạ `AGENTS.md` sang `.cursor/rules/`, `CLAUDE.md`,`.windsurfrules`.
50
+ - pháp `/verify-gate [G2|G3]`: kiểm tra git diff, đảm bảo không file nào bị sửa ngoài `<allowed_files>`.
51
+ - pháp `/update`: kiểm tra nâng cấp phiên bản quy chuẩn chỉ dẫn (qua `instruction-version.json`); nếu đã bản mới nhất thì xuất ra "nothing changed".</rule>
52
+ <rule>Định nghĩa thay đổi thông qua Mục tiêu (Goal), Bất biến (Invariants), Hợp đồng phạm vi (`<scope_contract>`), Tiêu chí nghiệm thu (AC).</rule>
48
53
  </pillar>
49
54
 
50
- <!-- Trụ cột 2: Context Navigation -->
51
- <pillar id="context" title="Điều hướng & Nạp ngữ cảnh (Context Navigation)">
55
+ <!-- Trụ cột 2: Context Navigation & Model Context Protocol (MCP) -->
56
+ <pillar id="context" title="Điều hướng ngữ cảnh & MCP">
52
57
  <rule>Chỉ thu thập ngữ cảnh tối thiểu đủ dùng (Minimum Sufficient Context). Tuyệt đối không quét toàn bộ repo hay tự ý refactor ngoài phạm vi.</rule>
53
58
  <rule>Tuân thủ thứ tự ưu tiên thông tin được định nghĩa trong [`.agents/behavior.md`](.agents/behavior.md).</rule>
54
59
  <rule>Định tuyến ngữ cảnh dự án thông qua [`process/context/all-context.md`](process/context/all-context.md).</rule>
60
+ <mcp_tools>
61
+ Khi môi trường có sẵn Model Context Protocol (MCP), agent phải ưu tiên sử dụng MCP tools:
62
+ - Database MCP: Truy vấn schema và dữ liệu trực tiếp, không giả định schema mò mẫm.
63
+ - Git MCP: Đọc log/diff chính xác, tránh parsing lệnh shell tự do.
64
+ - Browser/DevTools MCP: Khảo sát live DOM / cây accessibility khi nghiệm thu giao diện.
65
+ </mcp_tools>
55
66
  </pillar>
56
67
 
57
68
  <!-- Trụ cột 3: Engineering Harness & Guardrails -->
@@ -62,6 +73,12 @@
62
73
  # Node/TS: npm run test && npm run typecheck && npm run lint
63
74
  # Go: go test ./... && go vet ./...
64
75
  </validation_commands>
76
+ <action_governance>
77
+ Agent vận hành dưới cơ chế kiểm soát và ngăn chặn vi phạm nghiêm ngặt:
78
+ - Chống vượt ranh giới (Anti-Escape): Tuyệt đối không sửa đổi file ngoài danh sách `<allowed_files>` hoặc cấu hình gốc dự án chưa được duyệt (`package.json`, CI workflow) trừ khi được chỉ định rõ trong `plan.md`.
79
+ - Danh sách cấm an toàn (Safety Blacklist): Tuyệt đối không thực thi các lệnh phá hủy (`git push -f`, `git reset --hard`, xóa đệ quy không giới hạn, `DROP TABLE`).
80
+ - Nghiệm thu phi triển khai (Non-Implementer Review): Người trực tiếp viết code không được tự ý đơn phương nghiệm thu; việc nghiệm thu bắt buộc phải qua thẩm định độc lập.
81
+ </action_governance>
65
82
  <architecture_guardrail>
66
83
  Clean Architecture & Dependency Injection cung cấp định hướng cấu trúc, KHÔNG PHẢI
67
84
  chỉ thị để làm phức tạp hóa quá mức các hàm tiện ích đơn giản.
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "name": "@damphuquy/agent-init",
4
+ "version": "3.0.0",
5
+ "framework": "RIPER-5",
6
+ "frameworkVersion": "3.0.0",
7
+ "language": "vi",
8
+ "description": "Tệp định danh và kiểm soát phiên bản quy chuẩn chỉ dẫn (instructions) cho AI Coding Agents và Workspace.",
9
+ "installedAt": "2026-09-09T00:00:00.000Z",
10
+ "updatedAt": "2026-09-09T00:00:00.000Z",
11
+ "manifest": {
12
+ "core": [
13
+ "AGENTS.md",
14
+ "instruction-version.json"
15
+ ],
16
+ "controlLayer": [
17
+ ".agents/README.md",
18
+ ".agents/behavior.md",
19
+ ".agents/guardrails.md",
20
+ ".agents/conventions/naming.md"
21
+ ],
22
+ "seeds": [
23
+ "process/_seeds/_GUIDE.md",
24
+ "process/_seeds/task-template.md.seed",
25
+ "process/_seeds/task-lite.md.seed",
26
+ "process/_seeds/context-group.md.seed",
27
+ "process/_seeds/decision-template.md.seed",
28
+ "process/_seeds/plan-template.md.seed",
29
+ "process/_seeds/state-template.md.seed",
30
+ "process/_seeds/review-template.md.seed",
31
+ "process/_seeds/handoff-template.md.seed",
32
+ "process/_seeds/cancellation-template.md.seed",
33
+ "process/_seeds/pause-template.md.seed",
34
+ "process/_seeds/results-template.tsv.seed",
35
+ "process/_seeds/program-template.md.seed"
36
+ ],
37
+ "context": [
38
+ "process/context/all-context.md",
39
+ "process/context/planning/all-planning.md",
40
+ "process/context/tests/all-tests.md"
41
+ ],
42
+ "protocols": [
43
+ "process/development-protocols/all-development-protocols.md",
44
+ "process/development-protocols/orchestration.md",
45
+ "process/development-protocols/implementation-standards.md"
46
+ ]
47
+ },
48
+ "updateStrategy": {
49
+ "slashCommand": "/update",
50
+ "checkCommand": "npm view @damphuquy/agent-init version",
51
+ "updateCommand": "npx @damphuquy/agent-init update --lang vi",
52
+ "forceUpdateCommand": "npx @damphuquy/agent-init@latest . --lang vi --force",
53
+ "preserveUserFiles": [
54
+ "AGENTS.md#validation_commands",
55
+ "process/features/**",
56
+ "process/general-plans/**"
57
+ ],
58
+ "safeToOverwrite": [
59
+ ".agents/**",
60
+ "process/_seeds/**",
61
+ "process/context/**",
62
+ "process/development-protocols/**",
63
+ "instruction-version.json"
64
+ ]
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/DamPhuQuy/agent-instructions"
69
+ }
70
+ }
@@ -23,9 +23,18 @@
23
23
  <catalog>
24
24
 
25
25
  <seed type="task" path="task-template.md.seed">
26
- Hợp đồng master và bản lưu vết trạng thái xuyên suốt toàn bộ vòng đời RIPER-5.
26
+ Hợp đồng master và bản lưu vết trạng thái xuyên suốt toàn bộ vòng đời RIPER-5 (Full Track: 7 artifacts).
27
27
  Bao gồm: Metadata kiểm soát task (working_mode PAIR/DELEGATED), Đặc tả (Spec), Ranh giới ngữ cảnh, Chiến lược kiểm chứng,
28
28
  Quyết định kỹ thuật, Kế hoạch thực thi RIPER-5 (kèm Gates G0–G3), và Ranh giới an toàn (Guardrails).
29
+ Khuyến nghị cho: Các tính năng phức tạp, tái cấu trúc kiến trúc, và Epic tại `process/features/`.
30
+ </seed>
31
+
32
+ <seed type="task-lite" path="task-lite.md.seed">
33
+ Hợp đồng tinh gọn gom vào duy nhất 1 artifact cho RIPER-5 Lite Track (1 artifact).
34
+ Bao gồm: Ý định, Ràng buộc bất biến, Hợp đồng phạm vi (<allowed_files>), Kế hoạch cắt lát tinh gọn,
35
+ và Cổng kiểm chứng nghiệm thu tổng hợp (G1/G2/G3).
36
+ Khuyến nghị cho: Tác vụ nhỏ, sửa lỗi (bugfix), tính năng nhỏ (micro-tasks), và hotfix tại `process/general-plans/`.
37
+ Giảm hơn 70% chi phí token và overhead khởi tạo.
29
38
  </seed>
30
39
 
31
40
  <seed type="research" path="context-group.md.seed">