@ngockhoale/ukit 3.5.7 → 3.5.8

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
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to UKit are documented here.
4
4
 
5
+ ## 3.5.8 - 2026-11-16
6
+
7
+ Bug-fix release: one defect seen right after 3.5.7 shipped, fixed at its cause. No host (Claude Code, Codex, omp) was run live and nothing was run on Windows; the checks are unit tests and real hook processes (prompt router, evidence recorder, Stop gate) in a temporary project.
8
+
9
+ - **Fix: asking how the work is going is no longer treated as an order to change code.** A prompt such as "Chạy có vẻ lâu rồi nè, không biết có tiến triển gì không … nếu có tiến triển thì tiếp tục làm, nếu lặp lại vô nghĩa thì báo tôi" was routed as a code task, and when it arrived after the task had finished, the Stop gate refused a correct progress report and asked for an edit and a test run. Two things caused it and both are fixed:
10
+ - The Vietnamese syllables "triển" and "khai" on their own were expanded to implement/build/ship, so "tiến triển" (progress) selected the delivery skill. Only the full words are expanded now: "triển khai" (implement/deploy/ship), "phát triển" (develop/build), "khai báo" (declare).
11
+ - "chạy", "tạo" and "cài/cải" counted as orders wherever they appeared. They now count only in an order position — with an object or an imperative particle ("chạy lại test", "tạo file x", "cài lodash đi") — and not as a description ("chạy có vẻ lâu rồi", "đang chạy", "mục tiêu của tạo ra UKit là cải tiến …"). In English, a change word used as a noun after the/a/this/my/… ("How is the progress on the build?", "Any update on the fix?") is no longer an order either; "fix the build", "run the build and fix failures", "do that update now" and "do the fix" behave as in 3.5.7. Delete/remove words are never softened.
12
+ - **Fix: "tiếp tục …" with a remark attached keeps the running task.** "tiếp tục. không dừng, nhớ check cái idle cho tôi" or "nếu có tiến triển thì tiếp tục làm, …" sent while a task was in flight started a new task and parked the running one's obligations. A continuation clause inside a longer prompt now binds to the live task, the same as a bare "tiếp tục". It never revives a parked task, and it does not apply when any part of the prompt orders something: "tiếp tục, push luôn", "tiếp tục, commit đi" or "nếu ok thì push rồi tiếp tục" start a new task with the checks that order needs, as in 3.5.7.
13
+ - **Known limits, not fixed here.**
14
+ - Some plain statements that order nothing ("Đã làm phải có hiệu quả.") still print a code-task route line, because the classifier's default kind is "code change". The Stop gate does not demand an edit for them when nothing was ordered and nothing was written.
15
+ - Some English questions whose change word is not behind the/a/this/… as a noun — "did you get the build?", "when did you start the build?" — are still read as an order, and the Stop gate asks for edit and test evidence, exactly as in 3.5.7.
16
+ - "để chạy test" on its own is not counted as an order (the purpose-clause rule strips it) although it still owes test evidence; "tiếp tục push lên main" written as one clause starts a new task that asks for edit evidence instead of push evidence. Both behave exactly as in 3.5.7.
17
+ - A noun that is also an operation word ("cái tag v3.5.7", "release notes", "giá đang lên") after "tiếp tục," starts a new task instead of continuing — the same result as 3.5.7, and it never drops an obligation.
18
+ - A prompt with no skill match can still be labelled a broader edit mode than it deserves (a tie between zero scores is pushed upward); the routed and the no-route paths use two slightly different "is this informational" checks.
19
+
5
20
  ## 3.5.7 - 2026-11-16
6
21
 
7
22
  Bug-fix release: eight defects found while shipping 3.5.6, each fixed at its cause. No host (Claude Code, Codex, omp) was run live and nothing was run on Windows; the checks are unit tests and real hook processes on this repository.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngockhoale/ukit",
3
- "version": "3.5.7",
3
+ "version": "3.5.8",
4
4
  "description": "Install/update an index-first AI workspace for Claude Code, OpenAI Codex and omp (Oh My Pi).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -6,6 +6,11 @@ const GENERIC_STOPWORDS = new Set([
6
6
  ]);
7
7
 
8
8
  const VIETNAMESE_PHRASE_ALIASES = [
9
+ // Bigrams only: the unigrams "trien"/"khai" also fold "tiến triển" (progress) / "khai" in unrelated
10
+ // words onto implement/build/ship, which selected the delivery skill for progress questions (3.5.8).
11
+ { regex: /\btrien khai\b/gu, expansions: ['implement', 'deploy', 'ship'] },
12
+ { regex: /\bphat trien\b/gu, expansions: ['develop', 'build'] },
13
+ { regex: /\bkhai bao\b/gu, expansions: ['declare'] },
9
14
  { regex: /\bbo nho dem\b/gu, expansions: ['cache'] },
10
15
  { regex: /\bduong dan\b/gu, expansions: ['route', 'path'] },
11
16
  { regex: /\bxac thuc\b/gu, expansions: ['auth', 'authentication'] },
@@ -78,8 +83,6 @@ const VIETNAMESE_TOKEN_ALIASES = new Map([
78
83
  ['component', ['component']],
79
84
  ['test', ['test', 'testing']],
80
85
  ['soat', ['review', 'audit']],
81
- ['trien', ['implement', 'build', 'ship']],
82
- ['khai', ['implement', 'build', 'ship']],
83
86
  ['kho', ['store', 'storage']],
84
87
  ['ghi', ['write', 'record']],
85
88
  ['doc', ['read']],
@@ -1017,7 +1017,9 @@ function isInformationalPrompt({
1017
1017
  }
1018
1018
  // C85-019: consult-shape also overrides the vocabulary vetoes — the
1019
1019
  // mutation/debug/lỗi words are the question's SUBJECT, not the ask.
1020
- const implementWords = /(?<![A-Za-z0-9_])(implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|tạo|xóa|đổi|thay thế|cập nhật|viết|build|chạy|cài)(?![A-Za-z0-9_])/.test(raw);
1020
+ // chạy/tạo/cài are judged by the shared position rule (ambiguousVerbOrder), not by bare presence.
1021
+ const implementWords = /(?<![A-Za-z0-9_])(implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|xóa|đổi|thay thế|cập nhật|viết|build)(?![A-Za-z0-9_])/.test(softenEnglishNouns(raw))
1022
+ || ambiguousVerbOrder(raw);
1021
1023
  if (implementWords && !consultShape) return false;
1022
1024
  const investigationWords = /\b(why|debug|triage|root cause|investigate|tại sao)\b/.test(raw);
1023
1025
  if (investigationWords && !consultShape) return false;
@@ -1211,7 +1213,51 @@ export function classifyAdvisorRequest({ promptText = '', commandText = '' } = {
1211
1213
  // folding, so "Cái này là gì, tại sao…" is not read as an install order (3.4.81 telemetry audit).
1212
1214
  function maskTonedNonVerbs(text = '') {
1213
1215
  return String(text ?? '').normalize('NFC')
1214
- .replace(/(?<![\p{L}\p{N}_])(?:cái|chính|việt|cháy|chảy|đợi|đời|đối|đội|đôi|đói|sữa|thèm)(?![\p{L}\p{N}_])/giu, ' _ ');
1216
+ .replace(/(?<![\p{L}\p{N}_])(?:cái|cải|cãi|chính|việt|cháy|chảy|đợi|đời|đối|đội|đôi|đói|sữa|thèm)(?![\p{L}\p{N}_])/giu, ' _ ');
1217
+ }
1218
+ // Position rule for the closed set of verbs that tone-fold onto an order verb but are ordinary
1219
+ // aspect/nominal words in progress talk: ch\u1ea1y (run / is running), t\u1ea1o (create / the creation of),
1220
+ // c\u1ea3i/c\u00e0i (improve / install). Input is folded (accent-free, lowercase) text. A verb is an ORDER when it
1221
+ // has an object or an imperative particle; it is NOT an order after a nominaliser/preposition/copula/
1222
+ // aspect marker (PREV = cua, viec, su, khi, dang) or when only a stative/degree complement follows
1223
+ // (co ve + lau, mai, hoai, cham, nhanh, xong, roi, duoc, qua, rat, hoi, ne, then end of clause or a conjunction).
1224
+ // Imperative particles (di, luon, ngay, giup, gium, ho, nhe) within 3 tokens always keep it an order.
1225
+ // Non-orders become " _ "; orders are untouched. English: a mutation word right after a determiner/possessive is
1226
+ // a noun ("the build"), unless a light verb stands before the determiner ("do the build", "finish that update").
1227
+ // Destructive verbs (x\u00f3a, delete, drop, reset) are deliberately not in this set.
1228
+ // Three copies (taskRouting.js, route-task.mjs, skill-router.sh) \u2014 keep them identical.
1229
+ function softenEnglishNouns(text = '') {
1230
+ return String(text).replace(/(?<!\b(?:do|does|doing|perform|finish|complete|handle|start|get|try)\s+)\b(the|a|an|any|this|that|these|those|my|our|your|its|their|his|her)\s+(?:implement|apply|update|modify|add|create|ship|deliver|fix|refactor|rename|change|write|build|make|install|run|deploy|execute|edit)\b/gi, '$1 _ ');
1231
+ }
1232
+ function softenAmbiguousVerbs(folded = '') {
1233
+ const PREV = new Set(['cua', 'viec', 'su', 'khi', 'dang']);
1234
+ const PARTICLE = new Set(['di', 'luon', 'ngay', 'giup', 'gium', 'ho', 'nhe']);
1235
+ const COMPLEMENT = new Set(['lau', 'mai', 'hoai', 'cham', 'nhanh', 'xong', 'roi', 'duoc', 'qua', 'rat', 'hoi', 'ne']);
1236
+ const CONJ = new Set(['ma', 'nhung', 'va', 'thi', 'hay', 'nen', 'khong', 'chua', 'but', 'and', 'so']);
1237
+ // Each occurrence is judged on its own (a clause can hold several: "tạo ra Ukit là cải tiến ...").
1238
+ // English: a mutation token right after a determiner/possessive is a noun ("the build", "my fix"), never an
1239
+ // order. Only that token is softened, so "run the build" / "fix the build" still order through the verb.
1240
+ // delete/remove are never softened.
1241
+ return softenEnglishNouns(folded).replace(/\b(chay|tao|cai)\b/g, (match, verb, offset, whole) => {
1242
+ const prev = whole.slice(0, offset).trimEnd().split(/\s+/).pop() || '';
1243
+ const tokens = (whole.slice(offset + match.length).split(/[.,;!?\n]/)[0] || '').split(/\s+/).filter(Boolean);
1244
+ if (tokens.slice(0, 3).some((token) => PARTICLE.has(token))) return match;
1245
+ if (PREV.has(prev)) return ' _ ';
1246
+ let index = 0;
1247
+ let consumed = 0;
1248
+ while (index < tokens.length) {
1249
+ if (tokens[index] === 'co' && tokens[index + 1] === 've') { index += 2; consumed += 1; continue; }
1250
+ if (COMPLEMENT.has(tokens[index])) { index += 1; consumed += 1; continue; }
1251
+ break;
1252
+ }
1253
+ if (consumed > 0 && (index >= tokens.length || CONJ.has(tokens[index]))) return ' _ ';
1254
+ return match;
1255
+ });
1256
+ }
1257
+ // The shared predicate: does any ambiguous verb in this text still stand as an order?
1258
+ function ambiguousVerbOrder(text = '') {
1259
+ const folded = maskTonedNonVerbs(text).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/\u0111/g, 'd');
1260
+ return /\b(?:chay|tao|cai)\b/.test(softenAmbiguousVerbs(folded));
1215
1261
  }
1216
1262
  function hasMutationOrder({ promptText = '', commandText = '' } = {}) {
1217
1263
  const folded = `${maskTonedNonVerbs(promptText)}\n${commandText ?? ''}`
@@ -1219,7 +1265,7 @@ function hasMutationOrder({ promptText = '', commandText = '' } = {}) {
1219
1265
  .normalize('NFD')
1220
1266
  .replace(/[\u0300-\u036f]/g, '')
1221
1267
  .replace(/\u0111/g, 'd');
1222
- const trimmed = folded.trim();
1268
+ const trimmed = softenAmbiguousVerbs(folded.trim());
1223
1269
  if (!trimmed) return false;
1224
1270
  // C85-019c: clause strips must stop BEFORE a conjunction-joined imperative
1225
1271
  // — "giữ nguyên header và sửa lỗi login" keeps 'và sửa lỗi' as a surviving
@@ -3109,7 +3109,9 @@ function applyTaskSemantics(contract, semantic) {
3109
3109
  return false;
3110
3110
  }
3111
3111
  }
3112
- const implementWords = /(?<![A-Za-z0-9_])(implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|tạo|xóa|đổi|thay thế|cập nhật|viết|build|chạy|cài)(?![A-Za-z0-9_])/.test(raw);
3112
+ // chạy/tạo/cài are judged by the shared position rule (ambiguousVerbOrder), not by bare presence.
3113
+ const implementWords = /(?<![A-Za-z0-9_])(implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|xóa|đổi|thay thế|cập nhật|viết|build)(?![A-Za-z0-9_])/.test(softenEnglishNouns(raw))
3114
+ || ambiguousVerbOrder(raw);
3113
3115
  if (implementWords && !consultShape) return false;
3114
3116
  const investigationWords = /\b(why|debug|triage|root cause|investigate|tại sao)\b/.test(raw);
3115
3117
  if (investigationWords && !consultShape) return false;
@@ -3229,7 +3231,51 @@ function applyTaskSemantics(contract, semantic) {
3229
3231
  // folding, so "Cái này là gì, tại sao…" is not read as an install order (3.4.81 telemetry audit).
3230
3232
  function maskTonedNonVerbs(text = '') {
3231
3233
  return String(text ?? '').normalize('NFC')
3232
- .replace(/(?<![\p{L}\p{N}_])(?:cái|chính|việt|cháy|chảy|đợi|đời|đối|đội|đôi|đói|sữa|thèm)(?![\p{L}\p{N}_])/giu, ' _ ');
3234
+ .replace(/(?<![\p{L}\p{N}_])(?:cái|cải|cãi|chính|việt|cháy|chảy|đợi|đời|đối|đội|đôi|đói|sữa|thèm)(?![\p{L}\p{N}_])/giu, ' _ ');
3235
+ }
3236
+ // Position rule for the closed set of verbs that tone-fold onto an order verb but are ordinary
3237
+ // aspect/nominal words in progress talk: ch\u1ea1y (run / is running), t\u1ea1o (create / the creation of),
3238
+ // c\u1ea3i/c\u00e0i (improve / install). Input is folded (accent-free, lowercase) text. A verb is an ORDER when it
3239
+ // has an object or an imperative particle; it is NOT an order after a nominaliser/preposition/copula/
3240
+ // aspect marker (PREV = cua, viec, su, khi, dang) or when only a stative/degree complement follows
3241
+ // (co ve + lau, mai, hoai, cham, nhanh, xong, roi, duoc, qua, rat, hoi, ne, then end of clause or a conjunction).
3242
+ // Imperative particles (di, luon, ngay, giup, gium, ho, nhe) within 3 tokens always keep it an order.
3243
+ // Non-orders become " _ "; orders are untouched. English: a mutation word right after a determiner/possessive is
3244
+ // a noun ("the build"), unless a light verb stands before the determiner ("do the build", "finish that update").
3245
+ // Destructive verbs (x\u00f3a, delete, drop, reset) are deliberately not in this set.
3246
+ // Three copies (taskRouting.js, route-task.mjs, skill-router.sh) \u2014 keep them identical.
3247
+ function softenEnglishNouns(text = '') {
3248
+ return String(text).replace(/(?<!\b(?:do|does|doing|perform|finish|complete|handle|start|get|try)\s+)\b(the|a|an|any|this|that|these|those|my|our|your|its|their|his|her)\s+(?:implement|apply|update|modify|add|create|ship|deliver|fix|refactor|rename|change|write|build|make|install|run|deploy|execute|edit)\b/gi, '$1 _ ');
3249
+ }
3250
+ function softenAmbiguousVerbs(folded = '') {
3251
+ const PREV = new Set(['cua', 'viec', 'su', 'khi', 'dang']);
3252
+ const PARTICLE = new Set(['di', 'luon', 'ngay', 'giup', 'gium', 'ho', 'nhe']);
3253
+ const COMPLEMENT = new Set(['lau', 'mai', 'hoai', 'cham', 'nhanh', 'xong', 'roi', 'duoc', 'qua', 'rat', 'hoi', 'ne']);
3254
+ const CONJ = new Set(['ma', 'nhung', 'va', 'thi', 'hay', 'nen', 'khong', 'chua', 'but', 'and', 'so']);
3255
+ // Each occurrence is judged on its own (a clause can hold several: "tạo ra Ukit là cải tiến ...").
3256
+ // English: a mutation token right after a determiner/possessive is a noun ("the build", "my fix"), never an
3257
+ // order. Only that token is softened, so "run the build" / "fix the build" still order through the verb.
3258
+ // delete/remove are never softened.
3259
+ return softenEnglishNouns(folded).replace(/\b(chay|tao|cai)\b/g, (match, verb, offset, whole) => {
3260
+ const prev = whole.slice(0, offset).trimEnd().split(/\s+/).pop() || '';
3261
+ const tokens = (whole.slice(offset + match.length).split(/[.,;!?\n]/)[0] || '').split(/\s+/).filter(Boolean);
3262
+ if (tokens.slice(0, 3).some((token) => PARTICLE.has(token))) return match;
3263
+ if (PREV.has(prev)) return ' _ ';
3264
+ let index = 0;
3265
+ let consumed = 0;
3266
+ while (index < tokens.length) {
3267
+ if (tokens[index] === 'co' && tokens[index + 1] === 've') { index += 2; consumed += 1; continue; }
3268
+ if (COMPLEMENT.has(tokens[index])) { index += 1; consumed += 1; continue; }
3269
+ break;
3270
+ }
3271
+ if (consumed > 0 && (index >= tokens.length || CONJ.has(tokens[index]))) return ' _ ';
3272
+ return match;
3273
+ });
3274
+ }
3275
+ // The shared predicate: does any ambiguous verb in this text still stand as an order?
3276
+ function ambiguousVerbOrder(text = '') {
3277
+ const folded = maskTonedNonVerbs(text).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/\u0111/g, 'd');
3278
+ return /\b(?:chay|tao|cai)\b/.test(softenAmbiguousVerbs(folded));
3233
3279
  }
3234
3280
  function hasMutationOrder({ promptText = '', commandText = '' } = {}) {
3235
3281
  const folded = `${publicationScope(maskTonedNonVerbs(promptText)).text}\n${commandText ?? ''}`
@@ -3237,7 +3283,7 @@ function applyTaskSemantics(contract, semantic) {
3237
3283
  .normalize('NFD')
3238
3284
  .replace(/[\u0300-\u036f]/g, '')
3239
3285
  .replace(/\u0111/g, 'd');
3240
- const trimmed = folded.trim();
3286
+ const trimmed = softenAmbiguousVerbs(folded.trim());
3241
3287
  if (!trimmed) return false;
3242
3288
  if (ordersPublication(promptText)) return true;
3243
3289
  if (!String(commandText ?? '').trim() && (declaredReadOnly(promptText, classifyTaskSemantics({ promptText }).releasePolicy)
@@ -3465,7 +3511,6 @@ function applyTaskSemantics(contract, semantic) {
3465
3511
  // it with hasMutationOrder keeps "sửa file cho tôi?" mutating while
3466
3512
  // "lỗi này chưa nhỉ" / "should I fix the hook?" consult. A targetFile
3467
3513
  // still vetoes.
3468
- const consultationImplementWords = /(?<![A-Za-z0-9_])(?:implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|tạo|xóa|đổi|thay thế|cập nhật|viết|chạy|cài)(?![A-Za-z0-9_])/.test(trimmedPromptText);
3469
3514
  const consultationOnlySignal = questionShapedPrompt
3470
3515
  && !hasMutationOrder({ promptText, commandText })
3471
3516
  && !targetFile;
@@ -4760,7 +4805,7 @@ function applyTaskSemantics(contract, semantic) {
4760
4805
  // its own: mutationOrder recomputed from a file path / the word "continue" / guidance
4761
4806
  // wording says nothing about what the user ordered, so the original prompt's stamp
4762
4807
  // stays authoritative.
4763
- if ((!extractPrompt(payload) || continuationPrompt || systemOriginTurn || guidanceTurn) && typeof previous.routingContext.mutationOrder === 'boolean') {
4808
+ if ((!extractPrompt(payload) || continuationPrompt || embeddedContinuationPrompt || systemOriginTurn || guidanceTurn) && typeof previous.routingContext.mutationOrder === 'boolean') {
4764
4809
  persisted.routingContext.mutationOrder = previous.routingContext.mutationOrder;
4765
4810
  }
4766
4811
  }
@@ -5443,7 +5488,45 @@ function applyTaskSemantics(contract, semantic) {
5443
5488
  const owned = targets(previous.routingContext?.lastExplicitUserPromptText);
5444
5489
  return wanted.size > 0 && [...wanted].every((target) => owned.has(target));
5445
5490
  })();
5446
- const continuingTask = Boolean(previous.taskInstanceId && (payload.tool_name || handoffExpansion || continuationPrompt || ownerResumeTurn || systemOriginTurn || guidanceTurn));
5491
+ // Clause-level continuation ("nếu có tiến triển thì tiếp tục làm", "tiếp tục. không dừng, nhớ check ..."):
5492
+ // at least one clause is a bare continuation (optionally behind a conditional head) and EVERY other
5493
+ // clause is a non-order by the same predicate that stamps mutationOrder. It binds only to a LIVE contract
5494
+ // of this session (never to suspendedContract: only the whole-string explicit continuation restores that),
5495
+ // mints nothing when there is none, and never overrides an owner STOP. Any ordering clause -> fresh task.
5496
+ const embeddedContinuationPrompt = (() => {
5497
+ if (explicitContinuationPrompt || payload.tool_name || ownerControlTurn || !sessionId || !previous.taskInstanceId) return false;
5498
+ if (!previous.routeSummary?.executionContract?.completionEvidence?.length || previous.routeSummary.executionContract.statusReport) return false;
5499
+ const raw = extractPrompt(payload);
5500
+ if (!raw.trim() || raw.length > 1200) return false;
5501
+ const fold = (text) => String(text ?? '').normalize('NFD').replace(/\p{M}+/gu, '').replace(/đ/gi, 'd').toLowerCase();
5502
+ const CONT ='(?:continue|resume|keep going|go on|proceed|tiep tuc|lam tiep)(?:\\s+(?:lam|viec|di|nhe|nao|nua|a|ha|please|pls|now|then|it|that|going|on|working))*';
5503
+ // Group 1 = the conditional head. A head that itself carries an order ("neu xong thi sua ham login roi
5504
+ // tiep tuc") is not a bare continuation: the head is checked WITHOUT the conditional strip hasMutationOrder applies.
5505
+ const bare = new RegExp(`^(?:(?:neu|if|khi|when)\\s+(.{1,80}?)\\s+(?:(?:thi|then)\\s+)?)?${CONT}\\s*$`);
5506
+ const clauses = raw.split(/[.!?;\n,]+/).map((clause) => clause.trim()).filter(Boolean);
5507
+ if (clauses.length < 2 && !clauses.some((clause) => !new RegExp(`^${CONT}\\s*$`).test(fold(clause)) && bare.test(fold(clause)))) return false;
5508
+ let continuation = false;
5509
+ // Any mutation verb in the head disqualifies it (hasMutationOrder would strip a conditional tail, and reads
5510
+ // "xong thi sua ham login roi" as already done). Ambiguous verbs go through the same position rule.
5511
+ // The head is a CONDITION only: a consequent inside it ("thi ..."/"then ...") is an action riding the old task,
5512
+ // and publication/operation verbs (push, commit, publish, release, merge, tag, restart) count as orders too.
5513
+ const HEAD_VERB = /\b(?:implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|edit|push|commit|publish|release|merge|tag|rebase|restart|sua|them|tao|xoa|doi|cap\s+nhat|viet|chay|cai|chinh|trien\s+khai|cau\s+hinh|dang\s+len)\b/;
5514
+ // ONE predicate for "this text carries an order": a mutation order, a publication order, or an operation verb.
5515
+ // It judges the head AND every non-continuation clause (a plain "push luon" is OPERATIONAL, not a bare continuation).
5516
+ const OP_VERB = /\b(?:push|commit|publish|release|merge|tag|rebase|restart|dang\s+len)\b/;
5517
+ const carriesOrder = (text) => hasMutationOrder({ promptText: text, commandText: '' }) || ordersPublication(text) || OP_VERB.test(softenAmbiguousVerbs(fold(text)));
5518
+ for (const clause of clauses) {
5519
+ const match = bare.exec(fold(maskTonedNonVerbs(clause)));
5520
+ if (match) {
5521
+ if (match[1] && (/\b(?:thi|then)\b/.test(match[1]) || HEAD_VERB.test(softenAmbiguousVerbs(match[1])) || carriesOrder(match[1]))) return false;
5522
+ continuation = true;
5523
+ continue;
5524
+ }
5525
+ if (carriesOrder(clause)) return false;
5526
+ }
5527
+ return continuation && !carriesOrder(raw);
5528
+ })();
5529
+ const continuingTask = Boolean(previous.taskInstanceId && (payload.tool_name || handoffExpansion || continuationPrompt || embeddedContinuationPrompt || ownerResumeTurn || systemOriginTurn || guidanceTurn));
5447
5530
  // An owner prompt that explicitly resumes the previous checkpoint (names its background job id or commit)
5448
5531
  // still mints a fresh task id - the contract may legitimately differ (e.g. a new deploy authorization) -
5449
5532
  // but records a bounded single-hop predecessor link so the ledger can reconcile current evidence. A
@@ -201,6 +201,11 @@ const GENERIC_STOPWORDS = new Set([
201
201
  'neu', 'nhung', 'nua', 'roi', 'toi', 'tren', 'truoc', 'va', 'voi',
202
202
  ]);
203
203
  const VIETNAMESE_PHRASE_ALIASES = [
204
+ // Bigrams only: the unigrams "trien"/"khai" also fold "tiến triển" (progress) / "khai" in unrelated
205
+ // words onto implement/build/ship, which selected the delivery skill for progress questions (3.5.8).
206
+ { regex: /\btrien khai\b/gu, expansions: ['implement', 'deploy', 'ship'] },
207
+ { regex: /\bphat trien\b/gu, expansions: ['develop', 'build'] },
208
+ { regex: /\bkhai bao\b/gu, expansions: ['declare'] },
204
209
  { regex: /\bbo nho dem\b/gu, expansions: ['cache'] },
205
210
  { regex: /\bduong dan\b/gu, expansions: ['route', 'path'] },
206
211
  { regex: /\bxac thuc\b/gu, expansions: ['auth', 'authentication'] },
@@ -272,8 +277,6 @@ const VIETNAMESE_TOKEN_ALIASES = new Map([
272
277
  ['component', ['component']],
273
278
  ['test', ['test', 'testing']],
274
279
  ['soat', ['review', 'audit']],
275
- ['trien', ['implement', 'build', 'ship']],
276
- ['khai', ['implement', 'build', 'ship']],
277
280
  ['kho', ['store', 'storage']],
278
281
  ['ghi', ['write', 'record']],
279
282
  ['doc', ['read']],
@@ -4703,7 +4703,9 @@ function isInformationalPrompt({
4703
4703
  }
4704
4704
  // C85-019: consult-shape also overrides the vocabulary vetoes — the
4705
4705
  // mutation/debug/lỗi words are the question's SUBJECT, not the ask.
4706
- const implementWords = /(?<![A-Za-z0-9_])(implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|tạo|xóa|đổi|thay thế|cập nhật|viết|build|chạy|cài)(?![A-Za-z0-9_])/.test(raw);
4706
+ // chạy/tạo/cài are judged by the shared position rule (ambiguousVerbOrder), not by bare presence.
4707
+ const implementWords = /(?<![A-Za-z0-9_])(implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|xóa|đổi|thay thế|cập nhật|viết|build)(?![A-Za-z0-9_])/.test(softenEnglishNouns(raw))
4708
+ || ambiguousVerbOrder(raw);
4707
4709
  if (implementWords && !consultShape) return false;
4708
4710
  const investigationWords = /\b(why|debug|triage|root cause|investigate|tại sao)\b/.test(raw);
4709
4711
  if (investigationWords && !consultShape) return false;
@@ -4901,7 +4903,51 @@ export function classifyAdvisorRequest({ promptText = '', commandText = '' } = {
4901
4903
  // folding, so "Cái này là gì, tại sao…" is not read as an install order (3.4.81 telemetry audit).
4902
4904
  function maskTonedNonVerbs(text = '') {
4903
4905
  return String(text ?? '').normalize('NFC')
4904
- .replace(/(?<![\p{L}\p{N}_])(?:cái|chính|việt|cháy|chảy|đợi|đời|đối|đội|đôi|đói|sữa|thèm)(?![\p{L}\p{N}_])/giu, ' _ ');
4906
+ .replace(/(?<![\p{L}\p{N}_])(?:cái|cải|cãi|chính|việt|cháy|chảy|đợi|đời|đối|đội|đôi|đói|sữa|thèm)(?![\p{L}\p{N}_])/giu, ' _ ');
4907
+ }
4908
+ // Position rule for the closed set of verbs that tone-fold onto an order verb but are ordinary
4909
+ // aspect/nominal words in progress talk: ch\u1ea1y (run / is running), t\u1ea1o (create / the creation of),
4910
+ // c\u1ea3i/c\u00e0i (improve / install). Input is folded (accent-free, lowercase) text. A verb is an ORDER when it
4911
+ // has an object or an imperative particle; it is NOT an order after a nominaliser/preposition/copula/
4912
+ // aspect marker (PREV = cua, viec, su, khi, dang) or when only a stative/degree complement follows
4913
+ // (co ve + lau, mai, hoai, cham, nhanh, xong, roi, duoc, qua, rat, hoi, ne, then end of clause or a conjunction).
4914
+ // Imperative particles (di, luon, ngay, giup, gium, ho, nhe) within 3 tokens always keep it an order.
4915
+ // Non-orders become " _ "; orders are untouched. English: a mutation word right after a determiner/possessive is
4916
+ // a noun ("the build"), unless a light verb stands before the determiner ("do the build", "finish that update").
4917
+ // Destructive verbs (x\u00f3a, delete, drop, reset) are deliberately not in this set.
4918
+ // Three copies (taskRouting.js, route-task.mjs, skill-router.sh) \u2014 keep them identical.
4919
+ function softenEnglishNouns(text = '') {
4920
+ return String(text).replace(/(?<!\b(?:do|does|doing|perform|finish|complete|handle|start|get|try)\s+)\b(the|a|an|any|this|that|these|those|my|our|your|its|their|his|her)\s+(?:implement|apply|update|modify|add|create|ship|deliver|fix|refactor|rename|change|write|build|make|install|run|deploy|execute|edit)\b/gi, '$1 _ ');
4921
+ }
4922
+ function softenAmbiguousVerbs(folded = '') {
4923
+ const PREV = new Set(['cua', 'viec', 'su', 'khi', 'dang']);
4924
+ const PARTICLE = new Set(['di', 'luon', 'ngay', 'giup', 'gium', 'ho', 'nhe']);
4925
+ const COMPLEMENT = new Set(['lau', 'mai', 'hoai', 'cham', 'nhanh', 'xong', 'roi', 'duoc', 'qua', 'rat', 'hoi', 'ne']);
4926
+ const CONJ = new Set(['ma', 'nhung', 'va', 'thi', 'hay', 'nen', 'khong', 'chua', 'but', 'and', 'so']);
4927
+ // Each occurrence is judged on its own (a clause can hold several: "tạo ra Ukit là cải tiến ...").
4928
+ // English: a mutation token right after a determiner/possessive is a noun ("the build", "my fix"), never an
4929
+ // order. Only that token is softened, so "run the build" / "fix the build" still order through the verb.
4930
+ // delete/remove are never softened.
4931
+ return softenEnglishNouns(folded).replace(/\b(chay|tao|cai)\b/g, (match, verb, offset, whole) => {
4932
+ const prev = whole.slice(0, offset).trimEnd().split(/\s+/).pop() || '';
4933
+ const tokens = (whole.slice(offset + match.length).split(/[.,;!?\n]/)[0] || '').split(/\s+/).filter(Boolean);
4934
+ if (tokens.slice(0, 3).some((token) => PARTICLE.has(token))) return match;
4935
+ if (PREV.has(prev)) return ' _ ';
4936
+ let index = 0;
4937
+ let consumed = 0;
4938
+ while (index < tokens.length) {
4939
+ if (tokens[index] === 'co' && tokens[index + 1] === 've') { index += 2; consumed += 1; continue; }
4940
+ if (COMPLEMENT.has(tokens[index])) { index += 1; consumed += 1; continue; }
4941
+ break;
4942
+ }
4943
+ if (consumed > 0 && (index >= tokens.length || CONJ.has(tokens[index]))) return ' _ ';
4944
+ return match;
4945
+ });
4946
+ }
4947
+ // The shared predicate: does any ambiguous verb in this text still stand as an order?
4948
+ function ambiguousVerbOrder(text = '') {
4949
+ const folded = maskTonedNonVerbs(text).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/\u0111/g, 'd');
4950
+ return /\b(?:chay|tao|cai)\b/.test(softenAmbiguousVerbs(folded));
4905
4951
  }
4906
4952
  function hasMutationOrder({ promptText = '', commandText = '' } = {}) {
4907
4953
  const folded = `${maskTonedNonVerbs(promptText)}\n${commandText ?? ''}`
@@ -4909,7 +4955,7 @@ function hasMutationOrder({ promptText = '', commandText = '' } = {}) {
4909
4955
  .normalize('NFD')
4910
4956
  .replace(/[\u0300-\u036f]/g, '')
4911
4957
  .replace(/\u0111/g, 'd');
4912
- const trimmed = folded.trim();
4958
+ const trimmed = softenAmbiguousVerbs(folded.trim());
4913
4959
  if (!trimmed) return false;
4914
4960
  // C85-019c: clause strips must stop BEFORE a conjunction-joined imperative
4915
4961
  // — "giữ nguyên header và sửa lỗi login" keeps 'và sửa lỗi' as a surviving
@@ -5077,7 +5123,6 @@ function deriveExecutionMode({
5077
5123
  // an edit order, not a consultation). A leading interrogative overrides them:
5078
5124
  // "Lam sao ma do duoc khi toi cai…?" asks HOW something is done, it does not order
5079
5125
  // the action performed.
5080
- const consultationImplementWords = /(?<![A-Za-z0-9_])(?:implement|apply|update|modify|add|create|ship|deliver|fix|refactor|remove|delete|rename|change|write|build|make|install|run|deploy|execute|sửa|thêm|tạo|xóa|đổi|thay thế|cập nhật|viết|chạy|cài)(?![A-Za-z0-9_])/.test(trimmedPromptText);
5081
5126
  // C85-019: question shape + no surviving imperative = consult. The
5082
5127
  // pre-C85-019 all-zero-scores clause consulted only when NOTHING in the
5083
5128
  // prompt resembled work — impossible for a question about code. Replacing