@kienntpixon/dieu-phoi 0.2.1 → 0.2.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — @kienntpixon/dieu-phoi
2
2
 
3
+ ## 0.2.2
4
+
5
+ - **Trần model hạ xuống `opus/medium`** (trước là `opus/high`). Thang tier bỏ `opus/high`: `haiku/low … sonnet/high < opus/medium`. Mọi (model, effort) cao hơn (opus `high`/`xhigh`/`max`, Fable) bị kẹp về `opus/medium` khi đọc log và profile; `--override opus/high` / `--approved opus/high` bị từ chối (không nằm trên thang, lỗi nêu trần `opus/medium`).
6
+ - Prior mặc định `plan-design` → `opus/medium`. Sàn score ≥ 9 → `tối thiểu opus/medium`.
7
+ - Leo thang quá trần → `ask_user` với ghi chú "hỏi người dùng: làm rõ yêu cầu hoặc đổi kế hoạch" (không còn gợi ý chạy `opus/high`). Bỏ ước tính thô `opus/high` khỏi `ROUGH`.
8
+
3
9
  ## 0.2.1
4
10
 
5
11
  - **Định dạng `task_id` được kiểm:** đúng 8 ký tự `[a-z0-9]`. Một phiên thật đã tự bịa `almanac-cat-1791568325` làm root id mà không gì chặn. `plan-table --approve` (cả `--root` lẫn `task_id` từng bước), `choose --task`, `verdict --task`, `steer --task` giờ từ chối id sai: exit ≠ 0, lỗi tiếng Việt nêu id sai và gợi ý một id mới hợp lệ (`task_id "…" không hợp lệ: cần đúng 8 ký tự a-z0-9 (vd. k3f9x2ab)`), không ghi gì. `plan-table` không `--approve` chỉ cảnh báo trên stderr.
package/README.md CHANGED
@@ -51,13 +51,13 @@ Khởi động lại Claude Code sau khi cài. Kiểm tra bằng `dieu-phoi doct
51
51
 
52
52
  ### `choose`
53
53
 
54
- 1. **Luật an toàn** (cố định trong core): trần `opus/high`, không Fable. Sàn: score ≥ 9 → opus/high; `--verifiable n` → tối thiểu opus/medium; `--reversible n` → tối thiểu opus/medium (role exec). Score ≥ 9, `--verifiable n`, `--reversible n` hoặc `urgent` → không thăm dò xuống tier thấp. Sàn được ghi rõ trong `reason`.
54
+ 1. **Luật an toàn** (cố định trong core): trần `opus/medium` (opus/high, xhigh, max, Fable bị kẹp về opus/medium; `--override opus/high` bị từ chối). Sàn: score ≥ 9 → opus/medium; `--verifiable n` → tối thiểu opus/medium; `--reversible n` → tối thiểu opus/medium (role exec). Score ≥ 9, `--verifiable n`, `--reversible n` hoặc `urgent` → không thăm dò xuống tier thấp. Sàn được ghi rõ trong `reason`.
55
55
  2. **Leo thang** với `--task <task_id>`: fail 1 lần → cùng tier (làm lại kèm lỗi); fail 2 lần cùng tier → lên một tier; tier kế vượt opus/medium (role exec) → **không tự lập lại kế hoạch**, trả `action: "ask_user"` kèm `fails` và `tried` để hỏi người dùng. Fail = agent `fail|timeout` hoặc người dùng `reject --cause quality`. Lượt bị steer `plan`/`redirect` không tính.
56
56
  3. **Prior** từ `<skill-dir>/profile/profile.json` (không thấy thì dùng bản sao dựng sẵn của `skill/profile/profile.json` v1.0.0). `profile_source` trong kết quả cho biết đang dùng file nào (`builtin` hoặc đường dẫn).
57
57
  4. **Thompson sampling** khi ô của prior có ≥ 5 task đã xong + có verdict: rút p ~ Beta(1+pass, 1+fail) cho từng tier đủ dữ liệu, điểm = E[cost]/p + λ·E[time_phút]/p (urgent dùng p75 thời gian), chọn điểm thấp nhất. Tier có p75 vượt `time_cap_min` của loại task bị loại.
58
58
  5. **Thăm dò** một tier thấp hơn với xác suất `explore_rate` (mặc định 0.1) khi luật an toàn cho phép.
59
59
 
60
- Thang tier: `haiku/low < haiku/medium < haiku/high < sonnet/medium < sonnet/high < opus/medium < opus/high`.
60
+ Thang tier: `haiku/low < haiku/medium < haiku/high < sonnet/medium < sonnet/high < opus/medium` (trần).
61
61
 
62
62
  Kết quả `--json`: `{"action":"dispatch","model":"sonnet","model_id":"claude-sonnet-5-5","effort":"high","reason":"…","explored":false,"tier":"sonnet/high","budget_s":900,"est_cost_usd":0.2,"est_time_min":6,"est_source":"rough","profile_source":"builtin"}`. `model` là tên ngắn dùng thẳng cho tham số `model` của Agent tool; `budget_s` = 2 × trung vị thời gian của ô (chưa đủ dữ liệu thì lấy `time_cap_min`). `--seed` cho kết quả lặp lại được.
63
63
 
@@ -77,7 +77,6 @@ Kết quả `--json`: `{"action":"dispatch","model":"sonnet","model_id":"claude-
77
77
  | sonnet/medium | 55k | 6k | 4 | 0.17 |
78
78
  | sonnet/high | 60k | 8k | 6 | 0.20 |
79
79
  | opus/medium | 60k | 8k | 8 | 0.40 |
80
- | opus/high | 80k | 12k | 12 | 0.56 |
81
80
 
82
81
  ### `plan-table`
83
82
 
package/hook.cjs CHANGED
@@ -19,7 +19,7 @@ const path = require('path');
19
19
  const os = require('os');
20
20
  const crypto = require('crypto');
21
21
 
22
- const CORE_VERSION = '0.2.1';
22
+ const CORE_VERSION = '0.2.2';
23
23
  const SCHEMA = 1;
24
24
  const TASK_TYPES = [
25
25
  'search', 'extract', 'mechanical-edit', 'feature-impl', 'debug', 'refactor',
package/lib/choose.cjs CHANGED
@@ -6,7 +6,8 @@ const crypto = require('crypto');
6
6
  const core = require('../hook.cjs');
7
7
  const agg = require('./aggregate.cjs');
8
8
 
9
- // Tier ladder, cheapest first. Ceiling = opus/high (core safety rule).
9
+ // Tier ladder, cheapest first. Ceiling = opus/medium (core safety rule): anything above
10
+ // (opus/high, xhigh, max, Fable) clamps to opus/medium in tierIndex().
10
11
  const LADDER = [
11
12
  { model: 'haiku', effort: 'low' },
12
13
  { model: 'haiku', effort: 'medium' },
@@ -14,7 +15,6 @@ const LADDER = [
14
15
  { model: 'sonnet', effort: 'medium' },
15
16
  { model: 'sonnet', effort: 'high' },
16
17
  { model: 'opus', effort: 'medium' },
17
- { model: 'opus', effort: 'high' },
18
18
  ];
19
19
  const TOP = LADDER.length - 1;
20
20
  const EFFORT_RANK = { low: 0, medium: 1, high: 2, xhigh: 3, max: 4 };
@@ -31,7 +31,7 @@ const DEFAULT_PRIORS = {
31
31
  review: 'opus/medium',
32
32
  'research-synth': 'opus/medium',
33
33
  'content-write': 'sonnet/high',
34
- 'plan-design': 'opus/high',
34
+ 'plan-design': 'opus/medium',
35
35
  'data-analysis': 'sonnet/high',
36
36
  };
37
37
  const DEFAULT_TIME_CAP_MIN = {
@@ -186,7 +186,7 @@ const OPUS_MEDIUM = 5;
186
186
  * Escalation within one task_id (CONTRACT "Luật an toàn"):
187
187
  * - one fail at a tier -> same tier again (retry with the error);
188
188
  * - two fails at the same tier -> next tier up;
189
- * - if that next tier would exceed opus/medium for role=exec -> ask the user (no auto re-plan).
189
+ * - if that next tier would exceed the opus/medium ceiling -> ask the user (no auto re-plan).
190
190
  * Fail = agent fail|timeout or user reject cause=quality (eff_outcome). Attempts steered
191
191
  * plan/redirect by the user are ignored.
192
192
  */
@@ -213,7 +213,7 @@ function escalation(task, role) {
213
213
  if (((role || 'exec') === 'exec' && next > OPUS_MEDIUM) || next > TOP) {
214
214
  return Object.assign(base, {
215
215
  floor: Math.min(TOP, next), ask: true,
216
- note: `task đã fail ${totalFails} lần (đã thử ${tried.join(', ')}); tier kế vượt opus/medium — hỏi người dùng: làm rõ yêu cầu, đổi kế hoạch hay chạy opus/high`,
216
+ note: `task đã fail ${totalFails} lần (đã thử ${tried.join(', ')}); tier kế vượt trần opus/medium — hỏi người dùng: làm rõ yêu cầu hoặc đổi kế hoạch`,
217
217
  });
218
218
  }
219
219
  return Object.assign(base, { floor: next, note: `task fail ${fails} lần ở ${tierName(cur)} → lên ${tierName(next)}` });
@@ -264,7 +264,6 @@ const ROUGH = {
264
264
  'sonnet/medium': { input: 55000, output: 6000, minutes: 4 },
265
265
  'sonnet/high': { input: 60000, output: 8000, minutes: 6 },
266
266
  'opus/medium': { input: 60000, output: 8000, minutes: 8 },
267
- 'opus/high': { input: 80000, output: 12000, minutes: 12 },
268
267
  };
269
268
 
270
269
  function roughEstimate(idx, pricing) {
@@ -311,7 +310,7 @@ function choose(opts) {
311
310
  if (opts.override !== undefined && opts.override !== null) {
312
311
  overrideIdx = parseTier(String(opts.override));
313
312
  if (overrideIdx === null) {
314
- throw new Error(`--override "${opts.override}" không nằm trên thang tier (trần opus/high, không Fable): ${ladderList}`);
313
+ throw new Error(`--override "${opts.override}" không nằm trên thang tier (trần opus/medium, không Fable): ${ladderList}`);
315
314
  }
316
315
  }
317
316
  let approvedIdx = null;
@@ -345,7 +344,7 @@ function choose(opts) {
345
344
  // Safety floors (core only; a profile can never lower them).
346
345
  let safetyFloor = 0;
347
346
  const floorWhy = [];
348
- if (score >= 9) { safetyFloor = Math.max(safetyFloor, TOP); floorWhy.push(`score ${score}≥9 → tối thiểu opus/high`); }
347
+ if (score >= 9) { safetyFloor = Math.max(safetyFloor, TOP); floorWhy.push(`score ${score}≥9 → tối thiểu opus/medium`); }
349
348
  if (!verifiable) { safetyFloor = Math.max(safetyFloor, OPUS_MEDIUM); floorWhy.push('không kiểm chứng bằng máy → tối thiểu opus/medium'); }
350
349
  if (!reversible && role === 'exec') { safetyFloor = Math.max(safetyFloor, OPUS_MEDIUM); floorWhy.push('khó hoàn tác → tối thiểu opus/medium'); }
351
350
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kienntpixon/dieu-phoi",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Hook + CLI ghi log subagent của Claude Code và chọn model/effort theo chi phí + thời gian tới lúc nghiệm thu.",
5
5
  "license": "MIT",
6
6
  "author": "kiennt <kiennt@pixon.games>",