@damphuquy/agent-init 3.2.0 → 3.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@damphuquy/agent-init",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Scaffolding CLI to bootstrap RIPER-5 Coding Agents & Operational Workspace",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -132,6 +132,7 @@
132
132
  <constraint>One slice at a time. Run verifier after each slice. Inspect diff after each slice.</constraint>
133
133
  <constraint>No unrelated refactoring. No changes to forbidden files.</constraint>
134
134
  <constraint>Update `state.md` after every slice.</constraint>
135
+ <constraint>Cost observability & benchmarking follow strict Trigger Governance: default is OFF (zero-overhead); consolidate section 14 in `state.md` (single-shot) only when `--profile` / `[profile]` is present, and initialize `results.tsv` only when `--bench` / `[benchmark]` is present.</constraint>
135
136
  <output>Source code + tests + updated `state.md` with verification evidence. When all slices pass, advance directly to REVIEW.</output>
136
137
  </phase>
137
138
 
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "name": "@damphuquy/agent-init",
4
- "version": "3.2.0",
4
+ "version": "3.3.0",
5
5
  "framework": "RIPER-5",
6
- "frameworkVersion": "3.2.0",
6
+ "frameworkVersion": "3.3.0",
7
7
  "language": "en",
8
8
  "description": "Instruction and governance template manifest for AI coding agents and operational workspace.",
9
9
  "installedAt": "2026-09-09T00:00:00.000Z",
10
- "updatedAt": "2026-09-13T00:00:00.000Z",
10
+ "updatedAt": "2026-09-14T00:00:00.000Z",
11
11
  "manifest": {
12
12
  "core": [
13
13
  "AGENTS.md",
@@ -98,6 +98,7 @@
98
98
 
99
99
  <seed type="results" path="results-template.tsv.seed">
100
100
  Benchmark and quantitative metrics evaluation registry.
101
+ Trigger-based activation (--bench, [benchmark], or <observability_mode>BENCHMARK</observability_mode>).
101
102
  Use for tracking latency, throughput, memory, or eval scores across iterations and vertical slices.
102
103
  </seed>
103
104
 
@@ -150,7 +150,8 @@
150
150
 
151
151
  ## 14. Cost & Resource Observability
152
152
 
153
- <cost_observability>
153
+ <!-- Triggered via flags (--profile, [profile], or <observability_mode>PROFILE|BENCHMARK</observability_mode>). Defaults to status="OFF" for lean execution; updated once at EXECUTE completion before REVIEW. -->
154
+ <cost_observability status="OFF">
154
155
  <total_tool_calls>0</total_tool_calls>
155
156
  <estimated_tokens_consumed></estimated_tokens_consumed>
156
157
  <total_retries_used>0</total_retries_used> <!-- maximum 3 per unique symptom -->
@@ -10,6 +10,7 @@
10
10
  <status>ACTIVE</status> <!-- ACTIVE | REVIEW | COMPLETED | CANCELLED -->
11
11
  <priority>P2</priority> <!-- P0=urgent | P1=high | P2=normal | P3=low -->
12
12
  <working_mode>PAIR</working_mode> <!-- PAIR (review at gates) | DELEGATED (autonomous run) -->
13
+ <observability_mode>OFF</observability_mode> <!-- OFF (default: lean, zero-overhead) | PROFILE (single-shot cost tally at review) | BENCHMARK (with results.tsv) -->
13
14
  <current_phase>PLAN</current_phase> <!-- PLAN | EXECUTE | REVIEW -->
14
15
  <owner>@engineer</owner>
15
16
  </task_control>
@@ -12,6 +12,7 @@
12
12
  <risk>MEDIUM</risk> <!-- LOW | MEDIUM | HIGH -->
13
13
  <estimated_story_points>2</estimated_story_points> <!-- 1 SP ≈ 2-4 focused engineering hours -->
14
14
  <working_mode>PAIR</working_mode> <!-- PAIR (default: halts at each gate for review) | DELEGATED (fast-track: continuous autonomous run) | MANUAL | DIAGNOSE-ONLY -->
15
+ <observability_mode>OFF</observability_mode> <!-- OFF (default: lean, zero-overhead) | PROFILE (single-shot cost tally at review) | BENCHMARK (with results.tsv) -->
15
16
  <current_phase>RESEARCH</current_phase> <!-- RESEARCH | INNOVATE | PLAN | EXECUTE | REVIEW -->
16
17
  <owner>@engineer</owner>
17
18
  <decision_owner>@engineer</decision_owner>
@@ -9,7 +9,37 @@
9
9
 
10
10
  ---
11
11
 
12
- ## 1. Cost & Token Observability Governance
12
+ ## 1. Trigger-Based Observability & Evals Governance
13
+
14
+ <trigger_governance>
15
+ To prevent token bloat and eliminate wasted tool calls, the system implements a strict trigger-based activation model:
16
+
17
+ ### 1. Default Mode — Lean & Zero-Overhead:
18
+ - **Default is OFF (Zero-Overhead):** For standard routine engineering tasks (CRUD, UI tweaks, bugfixes, docs), the agent MUST NOT consume tool calls or context window measuring tokens, counting intermediate tool calls, or generating benchmark tables. The `<cost_observability>` block in `state.md` remains in its default template values.
19
+
20
+ ### 2. Explicit Trigger Mechanisms:
21
+ The agent activates tracking if and only if one of the following triggers is present:
22
+ - **Prompt Flags:**
23
+ - `--profile` or `[profile]`: Activates execution cost and resource monitoring for the task.
24
+ - `--bench` or `[benchmark]`: Activates the quantitative benchmarking lifecycle and creates `results.tsv`.
25
+ - `--eval` or `[eval]`: Activates deterministic governance evaluation fixtures (`process/evals/`).
26
+ - **Task Spec Control Field (`task.md` / `task-lite.md`):**
27
+ - `<observability_mode>PROFILE</observability_mode>`: Activates cost and resource profiling.
28
+ - `<observability_mode>BENCHMARK</observability_mode>`: Activates dual-run A/B benchmarking (baseline vs candidate).
29
+
30
+ ### 3. End-of-Task Single-Shot Finalization:
31
+ - When `--profile` is triggered, the agent **MUST NOT** perform repetitive updates to `state.md` after each slice.
32
+ - The agent consolidates metrics (total tool calls, retry count, wall-clock duration) and updates section 14 `<cost_observability>` in `state.md` **exactly once at the end of the EXECUTE phase**, immediately prior to generating `review.md`.
33
+
34
+ ### 4. Adaptive Fallback Trigger (Risk-Based):
35
+ The agent automatically activates cost tracking and `<failure_memory>` recording without explicit flags if:
36
+ - A vertical slice fails verification more than once (`retries >= 2`).
37
+ - The task consumes more than 30 tool calls without slice completion.
38
+ </trigger_governance>
39
+
40
+ ---
41
+
42
+ ## 2. Cost & Token Observability Governance
13
43
 
14
44
  <token_cost_governance>
15
45
  Every agent session operates under finite token budgets and computational resource limits.
@@ -28,7 +58,7 @@
28
58
 
29
59
  ---
30
60
 
31
- ## 2. Git-Atomic Commits & Sandboxing Policy
61
+ ## 3. Git-Atomic Commits & Sandboxing Policy
32
62
 
33
63
  <atomic_commits_and_sandboxing>
34
64
  ### Git-Atomic Commit Convention:
@@ -52,7 +82,7 @@
52
82
 
53
83
  ---
54
84
 
55
- ## 3. Benchmark & Quantitative Evaluation (Evals Framework)
85
+ ## 4. Benchmark & Quantitative Evaluation (Evals Framework)
56
86
 
57
87
  <evals_framework>
58
88
  For performance optimization, architectural refactoring, or algorithmic upgrades:
@@ -65,7 +95,7 @@
65
95
 
66
96
  ---
67
97
 
68
- ## 4. Deterministic Governance Evals & Evidence Hygiene
98
+ ## 5. Deterministic Governance Evals & Evidence Hygiene
69
99
 
70
100
  <governance_evals>
71
101
  Use `process/evals/eval-case.json` as an offline, deterministic fixture. A case records input as data, expected policy verdict, expected side effects, and evidence references; it must never cause a command or MCP call to execute.
@@ -132,6 +132,7 @@
132
132
  <constraint>Thực hiện từng lát cắt một. Chạy verifier sau mỗi slice. Kiểm tra diff sau mỗi slice.</constraint>
133
133
  <constraint>Không refactor lan man. Không sửa các file bị cấm.</constraint>
134
134
  <constraint>Cập nhật `state.md` ngay sau mỗi slice hoàn thành.</constraint>
135
+ <constraint>Giám sát chi phí & benchmark tuân thủ cơ chế Trigger: mặc định OFF (zero-overhead); chỉ tổng kết mục 14 state.md (single-shot) khi có cờ `--profile` / `[profile]`, và chỉ khởi tạo `results.tsv` khi có cờ `--bench` / `[benchmark]`.</constraint>
135
136
  <output>Mã nguồn + kiểm thử + cập nhật `state.md` kèm bằng chứng kiểm chứng. Khi hoàn tất toàn bộ lát cắt, tự động chuyển ngay sang REVIEW.</output>
136
137
  </phase>
137
138
 
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "name": "@damphuquy/agent-init",
4
- "version": "3.2.0",
4
+ "version": "3.3.0",
5
5
  "framework": "RIPER-5",
6
- "frameworkVersion": "3.2.0",
6
+ "frameworkVersion": "3.3.0",
7
7
  "language": "vi",
8
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
9
  "installedAt": "2026-09-09T00:00:00.000Z",
10
- "updatedAt": "2026-09-13T00:00:00.000Z",
10
+ "updatedAt": "2026-09-14T00:00:00.000Z",
11
11
  "manifest": {
12
12
  "core": [
13
13
  "AGENTS.md",
@@ -98,6 +98,7 @@
98
98
 
99
99
  <seed type="results" path="results-template.tsv.seed">
100
100
  Bảng đăng ký đánh giá số liệu benchmark và định lượng.
101
+ Kích hoạt theo trigger (--bench, [benchmark], hoặc <observability_mode>BENCHMARK</observability_mode>).
101
102
  Dùng để theo dõi latency, throughput, bộ nhớ hoặc điểm đánh giá qua các vòng lặp và lát cắt dọc.
102
103
  </seed>
103
104
 
@@ -140,7 +140,8 @@
140
140
 
141
141
  ## 14. Quan Sát Chi Phí & Tài Nguyên (Cost & Resource Observability)
142
142
 
143
- <cost_observability>
143
+ <!-- Kích hoạt khi có trigger (--profile, [profile], hoặc <observability_mode>PROFILE|BENCHMARK</observability_mode>). Mặc định status="OFF" để tiết kiệm token; tổng kết đúng 1 lần trước khi sang REVIEW. -->
144
+ <cost_observability status="OFF">
144
145
  <total_tool_calls>0</total_tool_calls>
145
146
  <estimated_tokens_consumed></estimated_tokens_consumed>
146
147
  <total_retries_used>0</total_retries_used> <!-- tối đa 3 cho mỗi lỗi -->
@@ -10,6 +10,7 @@
10
10
  <status>ACTIVE</status> <!-- ACTIVE | REVIEW | COMPLETED | CANCELLED -->
11
11
  <priority>P2</priority> <!-- P0=khẩn | P1=cao | P2=bình thường | P3=thấp -->
12
12
  <working_mode>PAIR</working_mode> <!-- PAIR (duyệt tại cổng) | DELEGATED (chạy tự trị liên tục) -->
13
+ <observability_mode>OFF</observability_mode> <!-- OFF (mặc định: tinh gọn, không tốn token giám sát) | PROFILE (tổng kết chi phí khi review) | BENCHMARK (kèm results.tsv) -->
13
14
  <current_phase>PLAN</current_phase> <!-- PLAN | EXECUTE | REVIEW -->
14
15
  <owner>@engineer</owner>
15
16
  </task_control>
@@ -12,6 +12,7 @@
12
12
  <risk>MEDIUM</risk> <!-- LOW | MEDIUM | HIGH -->
13
13
  <estimated_story_points>2</estimated_story_points> <!-- 1 SP ≈ 2-4 giờ làm việc kỹ thuật tập trung -->
14
14
  <working_mode>PAIR</working_mode> <!-- PAIR (mặc định: dừng chờ duyệt từng gate) | DELEGATED (fast-track: tự động chạy liên tục qua các phase) | MANUAL | DIAGNOSE-ONLY -->
15
+ <observability_mode>OFF</observability_mode> <!-- OFF (mặc định: tiết kiệm token) | PROFILE (đo chi phí cuối task) | BENCHMARK (kèm results.tsv) -->
15
16
  <current_phase>RESEARCH</current_phase> <!-- RESEARCH | INNOVATE | PLAN | EXECUTE | REVIEW -->
16
17
  <owner>@engineer</owner>
17
18
  <decision_owner>@engineer</decision_owner>
@@ -9,7 +9,37 @@
9
9
 
10
10
  ---
11
11
 
12
- ## 1. Quan Sát Chi Phí Token & Ngân Sách Thực Thi (Cost & Token Observability)
12
+ ## 1. Chế Kích Hoạt Điều Kiện (Trigger-Based Observability & Evals)
13
+
14
+ <trigger_governance>
15
+ Để đảm bảo tối ưu chi phí token và không lãng phí lượt gọi công cụ (tool calls), hệ thống áp dụng cơ chế kích hoạt theo trigger:
16
+
17
+ ### 1. Trạng Thái Mặc Định — Tinh Gọn (Default LEAN Mode):
18
+ - **Mặc định là OFF (Zero-Overhead):** Đối với hầu hết các task phát triển thông thường (CRUD, sửa lỗi nhỏ, thêm UI, chỉnh sửa tài liệu), Agent KHÔNG cần đo đạc chi phí token, không tự đếm tool calls giữa chừng và không tạo bảng benchmark. Khối `<cost_observability>` trong `state.md` được giữ nguyên giá trị mặc định.
19
+
20
+ ### 2. Các Trigger Kích Hoạt Tường Minh (Explicit Triggers):
21
+ Agent chỉ kích hoạt theo dõi khi phát hiện một trong các trigger sau:
22
+ - **Cờ Prompt:**
23
+ - `--profile` hoặc `[profile]`: Kích hoạt theo dõi chi phí và hiệu suất thực thi task.
24
+ - `--bench` hoặc `[benchmark]`: Kích hoạt vòng đời Benchmark định lượng và tạo bảng `results.tsv`.
25
+ - `--eval` hoặc `[eval]`: Kích hoạt bộ kiểm thử đánh giá bảo mật / ranh giới tin cậy (`process/evals/`).
26
+ - **Thẻ Điều Khiển Trong Task Spec (`task.md` / `task-lite.md`):**
27
+ - `<observability_mode>PROFILE</observability_mode>`: Kích hoạt theo dõi chi phí.
28
+ - `<observability_mode>BENCHMARK</observability_mode>`: Kích hoạt đo lường hiệu năng kép (A/B baseline vs candidate).
29
+
30
+ ### 3. Quy Tắc Tổng Kết Cuối Task (Single-Shot Finalization):
31
+ - Khi có trigger `--profile`, Agent **TUYỆT ĐỐI KHÔNG** cập nhật liên tục sau mỗi lát cắt nhỏ làm phình to context window.
32
+ - Agent chỉ thực hiện tổng kết số liệu (đếm tool calls, số retry, thời gian hoàn thành) và ghi vào mục 14 `<cost_observability>` trong `state.md` **đúng 1 lần duy nhất khi kết thúc phase EXECUTE**, ngay trước khi tạo `review.md`.
33
+
34
+ ### 4. Trigger Tự Động Theo Ngưỡng Rủi Ro (Adaptive Fallback Trigger):
35
+ Agent tự động kích hoạt ghi nhận chi phí và bộ nhớ lỗi `<failure_memory>` mà không cần cờ báo trước nếu:
36
+ - Một lát cắt thất bại kiểm chứng từ lần thứ 2 trở lên (`retries >= 2`).
37
+ - Task vượt quá 30 tool calls mà chưa hoàn tất lát cắt.
38
+ </trigger_governance>
39
+
40
+ ---
41
+
42
+ ## 2. Quan Sát Chi Phí Token & Ngân Sách Thực Thi (Cost & Token Observability)
13
43
 
14
44
  <token_cost_governance>
15
45
  Mọi phiên làm việc của Agent đều chịu sự chi phối của ngân sách token và tài nguyên tính toán.
@@ -28,7 +58,7 @@
28
58
 
29
59
  ---
30
60
 
31
- ## 2. Chuẩn Hóa Git-Atomic Commits & Môi Trường Cách Ly (Sandboxing)
61
+ ## 3. Chuẩn Hóa Git-Atomic Commits & Môi Trường Cách Ly (Sandboxing)
32
62
 
33
63
  <atomic_commits_and_sandboxing>
34
64
  ### Quy Ước Commit Nguyên Tử (Git-Atomic Commit Convention):
@@ -52,7 +82,7 @@
52
82
 
53
83
  ---
54
84
 
55
- ## 3. Khung Đánh Giá Benchmark & Đo Lường Định Lượng (Evals Framework)
85
+ ## 4. Khung Đánh Giá Benchmark & Đo Lường Định Lượng (Evals Framework)
56
86
 
57
87
  <evals_framework>
58
88
  Đối với các task tối ưu hóa hiệu năng, refactor kiến trúc hoặc nâng cấp thuật toán:
@@ -65,7 +95,7 @@
65
95
 
66
96
  ---
67
97
 
68
- ## 4. Evals Governance Xác Định & Vệ Sinh Bằng Chứng
98
+ ## 5. Evals Governance Xác Định & Vệ Sinh Bằng Chứng
69
99
 
70
100
  <governance_evals>
71
101
  Dùng `process/evals/eval-case.json` làm fixture offline, có tính xác định. Mỗi case ghi input như dữ liệu, policy verdict, side effect và evidence reference kỳ vọng; nó không bao giờ được khiến lệnh hay MCP call thực thi.