zelari-code 2.38.0 → 2.40.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/dist/cli/headless/runOneTurn.js +7 -0
- package/dist/cli/headless/runOneTurn.js.map +1 -1
- package/dist/cli/hooks/useChatTurn.js +56 -10
- package/dist/cli/hooks/useChatTurn.js.map +1 -1
- package/dist/cli/hooks/useSlashDispatch.js +16 -1
- package/dist/cli/hooks/useSlashDispatch.js.map +1 -1
- package/dist/cli/kraken/executor.js +126 -11
- package/dist/cli/kraken/executor.js.map +1 -1
- package/dist/cli/kraken/exploreCoverage.js +201 -0
- package/dist/cli/kraken/exploreCoverage.js.map +1 -0
- package/dist/cli/kraken/exploreFlipGate.js +197 -0
- package/dist/cli/kraken/exploreFlipGate.js.map +1 -0
- package/dist/cli/kraken/planner.js.map +1 -1
- package/dist/cli/kraken/verifyReask.js +134 -0
- package/dist/cli/kraken/verifyReask.js.map +1 -0
- package/dist/cli/main.bundled.js +4315 -3605
- package/dist/cli/main.bundled.js.map +4 -4
- package/dist/cli/memory/opsKnowledge.js +284 -0
- package/dist/cli/memory/opsKnowledge.js.map +1 -0
- package/dist/cli/memory/promotion.js +20 -0
- package/dist/cli/memory/promotion.js.map +1 -1
- package/dist/cli/memory/repeatFailure.js +60 -0
- package/dist/cli/memory/repeatFailure.js.map +1 -0
- package/dist/cli/runHeadless.js +6 -1
- package/dist/cli/runHeadless.js.map +1 -1
- package/dist/cli/slashCommands.js +18 -2
- package/dist/cli/slashCommands.js.map +1 -1
- package/dist/cli/slashHandlers/memory.js +1 -0
- package/dist/cli/slashHandlers/memory.js.map +1 -1
- package/dist/cli/slashHandlers/missionResume.js +54 -0
- package/dist/cli/slashHandlers/missionResume.js.map +1 -0
- package/dist/cli/tools/taskTool.js +22 -0
- package/dist/cli/tools/taskTool.js.map +1 -1
- package/dist/cli/zelariMission.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* verifyReask — t56: minimal one-shot re-ask for an `unknown` verify verdict.
|
|
3
|
+
*
|
|
4
|
+
* Problem
|
|
5
|
+
* -------
|
|
6
|
+
* When a reviewer's reply has no parseable verdict trailer, the executor
|
|
7
|
+
* records the node as `unresolved` (reason 'unknown') and moves on — correct
|
|
8
|
+
* per "unknown ≠ pass", but expensive in one specific way: the verdict was
|
|
9
|
+
* almost certainly FORMULATED in the reply and only the trailer line got
|
|
10
|
+
* mangled by prompt drift. Re-running the whole verify sub-agent pays a
|
|
11
|
+
* second full review for one missing line.
|
|
12
|
+
*
|
|
13
|
+
* What this module does instead
|
|
14
|
+
* -----------------------------
|
|
15
|
+
* A single non-streaming chat completion, no tools, against the same
|
|
16
|
+
* provider channel the CLI already uses (same resolution as the weakness
|
|
17
|
+
* meter): hand the model its own prior output (tail-capped) and ask it to
|
|
18
|
+
* emit ONLY the trailer it already supports. The reply is parsed with the
|
|
19
|
+
* SAME single-source parser as the original verdict (`parseVerifyVerdict`
|
|
20
|
+
* from @zelari/core) — no second grammar to drift.
|
|
21
|
+
*
|
|
22
|
+
* Guarantees:
|
|
23
|
+
* - capped at ONE call per unknown verdict (the caller enforces this);
|
|
24
|
+
* - default ON, opt-out via ZELARI_KRAKEN_VERIFY_REASK=0;
|
|
25
|
+
* - any failure (disabled, no key, HTTP error, unparseable reply)
|
|
26
|
+
* returns null and the existing unknown-flow is unchanged;
|
|
27
|
+
* - the verify node's raw `result` is NEVER rewritten by this module —
|
|
28
|
+
* audit sees what the reviewer actually emitted.
|
|
29
|
+
*
|
|
30
|
+
* Pattern follows `./weaknessMeter.ts` (provider resolution, timeout,
|
|
31
|
+
* silent failure). No I/O at import time.
|
|
32
|
+
*
|
|
33
|
+
* @since v2.x — t56 re-ask minimal su verdetto unknown
|
|
34
|
+
*/
|
|
35
|
+
import { parseVerifyVerdict } from '@zelari/core';
|
|
36
|
+
import { getProviderConfig, getModelForProvider, getCustomEndpoint } from '../providerConfig.js';
|
|
37
|
+
import { resolveApiKeyWithMeta } from '../keyStore.js';
|
|
38
|
+
/** Env flag. Default ON ('0' | 'false' | 'no' disables). */
|
|
39
|
+
export const VERIFY_REASK_ENV = 'ZELARI_KRAKEN_VERIFY_REASK';
|
|
40
|
+
/** Wall-clock budget for the single re-ask call. */
|
|
41
|
+
const REASK_TIMEOUT_MS = 12_000;
|
|
42
|
+
/** How much of the prior verify output we forward (trailer lives at the end). */
|
|
43
|
+
const PRIOR_OUTPUT_CAP_CHARS = 8_000;
|
|
44
|
+
const REASK_SYSTEM_PROMPT = [
|
|
45
|
+
'You are a verdict-normalization helper.',
|
|
46
|
+
'The message below is a code-review verify report whose final verdict trailer line is missing or malformed.',
|
|
47
|
+
'Re-read the report and emit, as the LAST line, ONLY the verdict the report already supports:',
|
|
48
|
+
'`VERDICT: PASS` or `VERDICT: FAIL`.',
|
|
49
|
+
'Do not re-review the work, do not add commentary.',
|
|
50
|
+
'If the report genuinely supports neither verdict, emit `VERDICT: UNKNOWN`.',
|
|
51
|
+
].join(' ');
|
|
52
|
+
/**
|
|
53
|
+
* Whether the re-ask is enabled. Cheap; read per call (no memoization —
|
|
54
|
+
* unlike the weakness meter this is not on a hot path).
|
|
55
|
+
*/
|
|
56
|
+
export function isVerifyReaskEnabled(env = process.env) {
|
|
57
|
+
const raw = env[VERIFY_REASK_ENV];
|
|
58
|
+
if (raw === undefined || raw === '')
|
|
59
|
+
return true; // default ON
|
|
60
|
+
return !(raw === '0' || raw === 'false' || raw === 'no');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One-shot trailer recovery. Returns `'pass' | 'fail'` when the model
|
|
64
|
+
* restated a usable verdict, `null` otherwise (disabled / failed /
|
|
65
|
+
* still unknown). Never throws.
|
|
66
|
+
*/
|
|
67
|
+
export async function reaskVerifyTrailer(priorOutput, options = {}) {
|
|
68
|
+
const env = options.env ?? process.env;
|
|
69
|
+
if (!isVerifyReaskEnabled(env))
|
|
70
|
+
return null;
|
|
71
|
+
if (typeof priorOutput !== 'string' || priorOutput.trim() === '')
|
|
72
|
+
return null;
|
|
73
|
+
const provider = options.providerOverride ?? (await resolveActiveProvider(env));
|
|
74
|
+
if (!provider)
|
|
75
|
+
return null;
|
|
76
|
+
// Tail-cap: the verdict trailer sits at the end of the report.
|
|
77
|
+
const capped = priorOutput.length > PRIOR_OUTPUT_CAP_CHARS
|
|
78
|
+
? priorOutput.slice(priorOutput.length - PRIOR_OUTPUT_CAP_CHARS)
|
|
79
|
+
: priorOutput;
|
|
80
|
+
try {
|
|
81
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
82
|
+
const ac = new AbortController();
|
|
83
|
+
const timer = setTimeout(() => ac.abort(), REASK_TIMEOUT_MS);
|
|
84
|
+
let response;
|
|
85
|
+
try {
|
|
86
|
+
response = await fetchImpl(provider.endpoint, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
headers: {
|
|
89
|
+
'Content-Type': 'application/json',
|
|
90
|
+
Authorization: `Bearer ${provider.apiKey}`,
|
|
91
|
+
},
|
|
92
|
+
body: JSON.stringify({
|
|
93
|
+
model: provider.model,
|
|
94
|
+
messages: [
|
|
95
|
+
{ role: 'system', content: REASK_SYSTEM_PROMPT },
|
|
96
|
+
{ role: 'user', content: capped },
|
|
97
|
+
],
|
|
98
|
+
temperature: 0,
|
|
99
|
+
stream: false,
|
|
100
|
+
}),
|
|
101
|
+
signal: ac.signal,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
}
|
|
107
|
+
if (!response.ok)
|
|
108
|
+
return null;
|
|
109
|
+
const json = (await response.json());
|
|
110
|
+
const raw = json.choices?.[0]?.message?.content;
|
|
111
|
+
if (typeof raw !== 'string')
|
|
112
|
+
return null;
|
|
113
|
+
// Same single-source parser as the executor — no second grammar.
|
|
114
|
+
const { verdict } = parseVerifyVerdict(raw);
|
|
115
|
+
return verdict === 'pass' || verdict === 'fail' ? verdict : null;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Same on-disk provider resolution the weakness meter uses. */
|
|
122
|
+
async function resolveActiveProvider(env) {
|
|
123
|
+
const cfg = await getProviderConfig();
|
|
124
|
+
if (!cfg)
|
|
125
|
+
return null;
|
|
126
|
+
const providerId = cfg.activeProviderId;
|
|
127
|
+
const key = await resolveApiKeyWithMeta(providerId, env);
|
|
128
|
+
if (!key?.apiKey)
|
|
129
|
+
return null;
|
|
130
|
+
const model = getModelForProvider(providerId) ?? cfg.modelByProvider[providerId] ?? '';
|
|
131
|
+
const endpoint = getCustomEndpoint(providerId) ?? `https://api.openai.com/v1/chat/completions`;
|
|
132
|
+
return { providerId, model, endpoint, apiKey: key.apiKey };
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=verifyReask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyReask.js","sourceRoot":"","sources":["../../../src/cli/kraken/verifyReask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAqB,MAAM,gBAAgB,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAE7D,oDAAoD;AACpD,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,iFAAiF;AACjF,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAErC,MAAM,mBAAmB,GAAG;IAC1B,yCAAyC;IACzC,4GAA4G;IAC5G,8FAA8F;IAC9F,qCAAqC;IACrC,mDAAmD;IACnD,4EAA4E;CAC7E,CAAC,IAAI,CAAC,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