@ngockhoale/ckit 0.4.1 → 0.4.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.
@@ -33,7 +33,7 @@ export declare function ruleDecision(text: string): {
33
33
  decision: 'continue' | 'redirect' | 'stop';
34
34
  note: string;
35
35
  };
36
- /** Last `VERDICT: PASS|FAIL` wins; no verdict at all counts as FAIL (conservative). */
36
+ /** Last `VERDICT: PASS|FAIL` line wins; no verdict at all counts as FAIL (conservative). */
37
37
  export declare function parseVerdict(text: string): 'PASS' | 'FAIL';
38
38
  export interface DirectorDecision {
39
39
  readonly kind: 'proceed' | 'need' | 'cannot';
@@ -36,7 +36,7 @@ class NodeCancelled extends Error {
36
36
  } // a PARALLEL_EXECUTE node stopped because a sibling node redirected or halted the flow // run already finished (stop) or failed; unwinds the pipeline
37
37
  const oneLine = (s, max = 200) => { const t = s.replace(/\s+/g, ' ').trim(); return t.length > max ? `${t.slice(0, max - 1)}…` : t; };
38
38
  const clip = (s, max) => s.length > max ? `${s.slice(0, max)}\n[...truncated]` : s;
39
- const STOP_RE = /^\s*(stop|dừng)/i, REDIRECT_RE = /^\s*(redirect|đổi hướng)[:\s]\s*/i;
39
+ const STOP_RE = /^\s*(stop|dừng)(?![\p{L}\p{N}_])/iu, REDIRECT_RE = /^\s*(redirect|đổi hướng)[:\s]\s*/i;
40
40
  /** Pure rule-based owner-chat decision (director cli 'auto', and the fallback for model directors). */
41
41
  export function ruleDecision(text) {
42
42
  if (STOP_RE.test(text))
@@ -45,11 +45,20 @@ export function ruleDecision(text) {
45
45
  return { decision: 'redirect', note: text.replace(REDIRECT_RE, '').trim() || text.trim() };
46
46
  return { decision: 'continue', note: text.trim() };
47
47
  }
48
- /** Last `VERDICT: PASS|FAIL` wins; no verdict at all counts as FAIL (conservative). */
49
- export function parseVerdict(text) {
50
- const all = [...text.matchAll(/VERDICT\s*[:\-]?\s*\**\s*(PASS|FAIL)/gi)];
48
+ /** The last `<LABEL>: PASS|FAIL` verdict line wins. Lines that start with the label (after Markdown bullets/bold/headings) take precedence, so prose that
49
+ * merely mentions the syntax ("No VERDICT: PASS because ...") never overrides a real verdict line; mid-line matches are the fallback only. */
50
+ const lastVerdict = (text, label) => {
51
+ const line = new RegExp(`^[ \\t>*_#-]*(?:(?:QC|FINAL|OVERALL|DIRECTOR)[ \\t]+)?${label}[ \\t]*(?:\\*\\*|__)?[ \\t]*[:\\-–]?[ \\t]*(?:\\*\\*|__)?[ \\t]*(PASS|FAIL)\\b`, 'gim');
52
+ const any = new RegExp(`\\b${label}\\s*[:\\-]?\\s*\\**\\s*(PASS|FAIL)\\b`, 'gi');
53
+ let all = [...text.matchAll(line)];
54
+ if (!all.length)
55
+ all = [...text.matchAll(any)];
51
56
  const last = all[all.length - 1]?.[1];
52
- return last && last.toUpperCase() === 'PASS' ? 'PASS' : 'FAIL';
57
+ return last ? last.toUpperCase() : null;
58
+ };
59
+ /** Last `VERDICT: PASS|FAIL` line wins; no verdict at all counts as FAIL (conservative). */
60
+ export function parseVerdict(text) {
61
+ return lastVerdict(text, 'VERDICT') === 'PASS' ? 'PASS' : 'FAIL';
53
62
  }
54
63
  /** The Director's first-turn decision line (lenient: case, bullets, bold, dashes). No decision line = PROCEED. Never throws. */
55
64
  export function parseDirectorDecision(text) {
@@ -99,8 +108,7 @@ export function parseHandoff(text) {
99
108
  const AGREED_RE = /^[ \t>*_#-]*AGREED\b[^\n]*$/im;
100
109
  /** Last `REVIEW: PASS|FAIL` wins; null when no verdict line exists. */
101
110
  export function parseReview(text) {
102
- const all = [...text.matchAll(/REVIEW\s*[:\-]?\s*\**\s*(PASS|FAIL)/gi)], last = all[all.length - 1]?.[1];
103
- return last ? last.toUpperCase() : null;
111
+ return lastVerdict(text, 'REVIEW');
104
112
  }
105
113
  /** Parses a Director checkpoint reply. decision null = unreadable (callers accept). Consults: first 2 `CONSULT <agent id>: <question>` lines. */
106
114
  export function parseCheckpoint(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngockhoale/ckit",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CKit — local Agent Company: a Director plus BA / Implement / QC teams running your own codex, claude and omp CLIs, with a web Mission Control (ckit gui).",
5
5
  "type": "module",
6
6
  "bin": {