@orion-agents/orion-code 0.4.6 → 0.4.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +10 -11
  3. package/README.zh-CN.md +10 -10
  4. package/dist/acp/session-updates.js +1 -0
  5. package/dist/framework/query.d.ts +3 -7
  6. package/dist/framework/query.js +22 -74
  7. package/dist/framework/verification-command.d.ts +23 -0
  8. package/dist/framework/verification-command.js +66 -5
  9. package/dist/harness/assembler.d.ts +1 -0
  10. package/dist/harness/assembler.js +5 -2
  11. package/dist/harness/clarification.d.ts +3 -0
  12. package/dist/harness/clarification.js +56 -0
  13. package/dist/harness/context-harness.d.ts +3 -9
  14. package/dist/harness/context-harness.js +75 -167
  15. package/dist/harness/contract.js +36 -10
  16. package/dist/harness/drift-guard.js +12 -4
  17. package/dist/harness/goal-verification.d.ts +2 -0
  18. package/dist/harness/goal-verification.js +42 -0
  19. package/dist/harness/intent.js +10 -12
  20. package/dist/harness/state.d.ts +3 -0
  21. package/dist/harness/state.js +52 -6
  22. package/dist/harness/task-checklist.d.ts +1 -1
  23. package/dist/harness/task-checklist.js +2 -2
  24. package/dist/harness/types.d.ts +1 -0
  25. package/dist/harness/verification.d.ts +2 -0
  26. package/dist/harness/verification.js +18 -6
  27. package/dist/runtime/agent-loop.js +45 -50
  28. package/dist/runtime/agent-runtime-controller.js +1 -1
  29. package/dist/runtime/goal-lifecycle-v2.js +5 -0
  30. package/dist/runtime/goal-runtime-coordinator.js +6 -2
  31. package/dist/runtime/orion-runtime-v1.js +33 -6
  32. package/dist/runtime/plan-review.d.ts +1 -0
  33. package/dist/runtime/plan-review.js +12 -7
  34. package/dist/runtime/product-orion-runtime.js +7 -3
  35. package/dist/runtime/step-snapshot.d.ts +1 -0
  36. package/dist/runtime/step-snapshot.js +57 -9
  37. package/dist/runtime/task-context-recovery.js +22 -10
  38. package/dist/runtime/task-context-service.d.ts +2 -6
  39. package/dist/runtime/task-context-service.js +3 -12
  40. package/dist/runtime/thread-ui-adapter.js +13 -1
  41. package/dist/runtime/tool-gateway.js +1 -0
  42. package/dist/runtime/ui-events.d.ts +3 -0
  43. package/dist/runtime/verification-feedback.d.ts +4 -0
  44. package/dist/runtime/verification-feedback.js +61 -0
  45. package/dist/tools/bash_security.d.ts +1 -24
  46. package/dist/tools/bash_security.js +7 -124
  47. package/dist/tools/todo.js +9 -13
  48. package/dist/utils/shell-command.d.ts +29 -0
  49. package/dist/utils/shell-command.js +185 -0
  50. package/docs/cli-guide.md +4 -0
  51. package/npm-shrinkwrap.json +2 -2
  52. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -22,7 +22,23 @@ which is **not** a pass.
22
22
 
23
23
  ## [Unreleased]
24
24
 
25
- ## [0.4.6] — UNRELEASED
25
+ ## [0.4.8] — UNRELEASED
26
+
27
+ - Report the shell exit status separately from verification. Recognizable checks in pipelines show why the result is unverified and suggest a direct, bounded command for simple output filters (#408).
28
+ - Deliver final model replies with missing evidence across CLI, TUI, Terminal and ACP. Checklist updates report verification gaps, and a Goal with outstanding evidence can be resumed.
29
+ - Filter generated completion instructions from restored v0.4.7 sessions while retaining the user transcript and real verification evidence.
30
+
31
+ ## [0.4.7] — npm-published
32
+
33
+ Version 0.4.7 was published to npm on 2026-12-04.
34
+
35
+ - Answer read-only explanations and status questions within existing sessions while retaining their task checklists and verification requirements (#405).
36
+ - Match custom workflow verification against the requested command, working directory, and fresh executor receipt. Ask for an exact check when a requirement lacks one (#406).
37
+
38
+ ## [0.4.6] — 2026-12-04 (Published)
39
+
40
+ The npm package was built from `878a8424d3775654521a6dcbd101aa0a6891a758` and published by
41
+ [GitHub Actions](https://github.com/orion-agents/orion-code/actions/runs/47271619041).
26
42
 
27
43
  - Keep the transcript, status, and composer in place when opening or closing slash command and file suggestions in the TUI.
28
44
  - Match slash commands by name or alias. Tab completes the name while preserving arguments, and Esc closes the picker without clearing the draft.
package/README.md CHANGED
@@ -2,9 +2,8 @@
2
2
 
3
3
  Local-first, goal-driven coding agent for the terminal (CLI/TUI).
4
4
 
5
- > v0.4.6 is a candidate for faster TUI command navigation and clearer session commands.
6
- > Web Workbench and desktop product surfaces are retired. Configuration is `orion.yaml`;
7
- > old-version data compatibility and migration are not part of this release.
5
+ > v0.4.8 is a candidate for model-driven turn completion and clearer command verification.
6
+ > Orion uses `orion.yaml` and can resume sessions created by v0.4.7.
8
7
  > A version number or local installation is not proof of release qualification or npm publication.
9
8
 
10
9
  [中文说明](README.zh-CN.md) · [CLI guide](docs/cli-guide.md) ·
@@ -15,9 +14,9 @@ Local-first, goal-driven coding agent for the terminal (CLI/TUI).
15
14
  - Explore and change local repositories through a shared Agent Runtime and ToolGateway.
16
15
  - Use the default TUI for input, streaming activity, approvals and review.
17
16
  - Drive Orion from an [ACP v1 client](docs/cli-guide.md#acp-接入) with `orion acp`.
18
- - Save sessions, plans and Goals; recover data created by this version after restart.
17
+ - Save sessions, plans and Goals and recover them after restart.
19
18
  - Load Model, Skills and MCP capabilities on demand; inspect configuration with `orion doctor`.
20
- - Distinguish execution stopping from evidence-backed completion.
19
+ - Deliver the model's final reply and report verification evidence separately.
21
20
 
22
21
  This is a coding agent, not a general-purpose IDE or plugin marketplace. Supporting a provider
23
22
  does not prove that a particular model or coding task passed quality evaluation.
@@ -27,21 +26,21 @@ does not prove that a particular model or coding task passed quality evaluation.
27
26
  Supported Node.js: **22.x (22.12+), 24.x or 26.x**.
28
27
  The exact package qualification floors are 22.12.0 / 24.0.0 / 26.0.0.
29
28
 
30
- Install a local candidate from the exact tested tarball, substituting its actual path:
29
+ Install the exact candidate tarball from the path where it was built.
31
30
 
32
31
  ```bash
33
- npm install -g /absolute/path/orion-agents-orion-code-0.4.6.tgz
32
+ npm install -g /absolute/path/orion-agents-orion-code-0.4.8.tgz
34
33
  orion --version
35
34
  orion doctor
36
35
  ```
37
36
 
38
- Only after npm publication has been separately verified, use the pinned registry install:
37
+ Use the following command once version 0.4.8 is available on npm.
39
38
 
40
39
  ```bash
41
- npm install -g @orion-agents/orion-code@0.4.6
40
+ npm install -g @orion-agents/orion-code@0.4.8
42
41
  ```
43
42
 
44
- From a checkout of the candidate branch:
43
+ From a source checkout:
45
44
 
46
45
  ```bash
47
46
  npm ci
@@ -108,7 +107,7 @@ npm run format:check
108
107
  npm run build
109
108
  npm run test:coverage -- --runInBand
110
109
  npm run test:harness-confluence
111
- npm run release:check -- --expected-version 0.4.6
110
+ npm run release:check -- --expected-version 0.4.8
112
111
  ```
113
112
 
114
113
  Qualification binds one exact tarball's SHA-256 and source identity to installed CLI, TUI, terminal,
package/README.zh-CN.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  面向终端、本地优先的目标驱动 Coding Agent(CLI/TUI)。
4
4
 
5
- > v0.4.6 是优化 TUI 命令导航与会话操作的候选版本。
6
- > Web Workbench 与桌面产品链已退役,全局配置统一为 `orion.yaml`。
5
+ > v0.4.8 候选版让模型决定回合结束,并单独报告命令验证结果。
6
+ > 全局配置使用 `orion.yaml`,可恢复 v0.4.7 创建的会话。
7
7
  > 源码版本号、本地可运行、候选包验收与 npm 发布分别记录,不互相替代。
8
8
 
9
9
  [English](README.md) · [CLI 使用与验收](docs/cli-guide.md) ·
@@ -14,9 +14,9 @@
14
14
  - 通过共享 Agent Runtime 与 ToolGateway 理解、修改和验证本地仓库。
15
15
  - 默认 TUI 承载输入、流式活动、审批、审查和任务接管。
16
16
  - 通过 `orion acp` 让 [ACP v1 客户端](docs/cli-guide.md#acp-接入) 驱动编码任务。
17
- - 保存本版创建的 Session、Plan 与 Goal,重启后恢复,不自动重放已完成副作用。
17
+ - 保存 Session、Plan 与 Goal,重启后可继续原会话。
18
18
  - 按需使用模型、Skills 与 MCP,通过 `orion doctor` 检查配置。
19
- - 区分停止执行与真实完成,保留计划、工具结果和验证证据。
19
+ - 交付模型的最终答复,并独立呈现工具和验证证据。
20
20
 
21
21
  本产品不是通用 IDE 或插件市场;支持某个模型,不代表任意编码任务已通过质量评测。
22
22
 
@@ -25,21 +25,21 @@
25
25
  支持 **Node.js 22.x(至少 22.12)、24.x 或 26.x**。
26
26
  精确候选包的验收 floor 为 22.12.0 / 24.0.0 / 26.0.0。
27
27
 
28
- 本地候选使用实际被测的同一包安装,请替换为实际路径:
28
+ 用构建产出的候选包安装,请替换为实际路径。
29
29
 
30
30
  ```bash
31
- npm install -g /absolute/path/orion-agents-orion-code-0.4.6.tgz
31
+ npm install -g /absolute/path/orion-agents-orion-code-0.4.8.tgz
32
32
  orion --version
33
33
  orion doctor
34
34
  ```
35
35
 
36
- 仅在另行确认 npm 已发布后,固定 registry 版本安装:
36
+ 确认 npm 已有 0.4.8 后,可按固定版本安装。
37
37
 
38
38
  ```bash
39
- npm install -g @orion-agents/orion-code@0.4.6
39
+ npm install -g @orion-agents/orion-code@0.4.8
40
40
  ```
41
41
 
42
- 从候选分支源码运行:
42
+ 从源码运行:
43
43
 
44
44
  ```bash
45
45
  npm ci
@@ -104,7 +104,7 @@ npm run format:check
104
104
  npm run build
105
105
  npm run test:coverage -- --runInBand
106
106
  npm run test:harness-confluence
107
- npm run release:check -- --expected-version 0.4.6
107
+ npm run release:check -- --expected-version 0.4.8
108
108
  ```
109
109
 
110
110
  准出需绑定同一 tarball 的 SHA-256 与源码身份,在三个 Node floor 验证安装后的 CLI、TUI、
@@ -122,6 +122,7 @@ class AcpSessionUpdates {
122
122
  sessionUpdate: 'tool_call_update',
123
123
  toolCallId: event.callId,
124
124
  status: event.success ? 'completed' : 'failed',
125
+ ...(event.verification ? { _meta: { orion: { verification: event.verification } } } : {}),
125
126
  ...(text ? { content: [{ type: 'content', content: { type: 'text', text } }] } : {}),
126
127
  });
127
128
  }
@@ -18,7 +18,7 @@ import type { CompactResult } from '../services/compact/compact';
18
18
  import type { CompactCoordinator } from '../services/compact/coordinator';
19
19
  import type { CompactPrepareSourceReceipt } from '../services/session-storage';
20
20
  import type { ContextHarness, HarnessState } from '../harness';
21
- import type { PromptAssemblyStats, TaskPlanStop } from '../harness/types';
21
+ import type { PromptAssemblyStats } from '../harness/types';
22
22
  import { type AuthoritativeToolExecutor, type ToolPermissionDecision } from './tool-call-orchestrator';
23
23
  import { type ContextUsageSnapshot } from '../services/model-context';
24
24
  import type { ToolExternalAssertion } from './external-assertion';
@@ -226,17 +226,13 @@ export interface QueryParams {
226
226
  abortSignal?: AbortSignal;
227
227
  /** Streaming callbacks (onChunk writes to stdout, etc.) */
228
228
  streamCallbacks?: StreamCallbacks;
229
- /** Stage answer text for checklist-driven work until the completion gate passes. */
230
- holdAssistantUntilCompletionCheck?: () => boolean;
231
- /** Check a persisted checklist's step recovery or explicit deferral before sampling. */
232
- checkTaskPlanStop?: () => TaskPlanStop | undefined;
233
229
  /** Tool execution context */
234
230
  toolContext?: ToolContext;
235
231
  /** Cost tracker for recording usage */
236
232
  costTracker?: CostTracker;
237
233
  /** Strategy tracker for alternative approaches */
238
234
  strategyTracker?: StrategyTracker;
239
- /** Optional Context Harness for turn-level context, ledger, and completion gates */
235
+ /** Optional Context Harness for turn-level context and evidence. */
240
236
  harness?: QueryTaskContext;
241
237
  /** Current user input, used by Context Harness for evidence ranking */
242
238
  input?: string;
@@ -289,7 +285,7 @@ export interface QueryModelRequestBinding {
289
285
  readonly toolExecutor: QueryParams['toolExecutor'];
290
286
  readonly receiptDigest?: string;
291
287
  }
292
- export type QueryTaskContext = Pick<ContextHarness, 'updateCapabilityProfile' | 'assembleMessages' | 'getCapsule' | 'toJSON' | 'recordAssistantResponse' | 'beforeToolUse' | 'asToolBlockedResult' | 'recordToolResult' | 'beforeComplete' | 'asCompletionBlockedMessage'>;
288
+ export type QueryTaskContext = Pick<ContextHarness, 'updateCapabilityProfile' | 'assembleMessages' | 'getCapsule' | 'toJSON' | 'recordAssistantResponse' | 'beforeToolUse' | 'asToolBlockedResult' | 'recordToolResult' | 'beforeComplete'>;
293
289
  export interface AutoCompactNotice {
294
290
  mode: 'predictive' | 'threshold';
295
291
  before: ContextUsageSnapshot;
@@ -26,6 +26,7 @@ const tool_call_orchestrator_1 = require("./tool-call-orchestrator");
26
26
  const token_estimate_1 = require("../utils/token-estimate");
27
27
  const terminal_text_1 = require("../utils/terminal-text");
28
28
  const tool_serializer_1 = require("./tool-serializer");
29
+ const verification_command_1 = require("./verification-command");
29
30
  const model_context_1 = require("../services/model-context");
30
31
  const stop_decision_1 = require("./stop-decision");
31
32
  const loop_progress_1 = require("./loop-progress");
@@ -602,6 +603,11 @@ function summarizeModelVisibleToolResult(executed, maxBytes, budgetRemainingByte
602
603
  }
603
604
  // Keep a real excerpt, status and a budget signal even after exhaustion. An
604
605
  // untrusted tool's arbitrarily large metadata must not displace the excerpt.
606
+ const shellMetadata = executed.prepared.tc.function.name === 'exec_command' ? envelope.metadata : undefined;
607
+ const feedback = shellMetadata?.verification;
608
+ const exitCode = shellMetadata?.exitCode;
609
+ const verification = (0, verification_command_1.verificationToolStatus)(feedback);
610
+ const detailedVerification = verification && byteLength(JSON.stringify(feedback)) <= 1024 ? feedback : verification;
605
611
  const compactError = rawError ? truncateModelField(rawError, 192) : undefined;
606
612
  const minimalError = rawError ? truncateModelField(rawError, 64) : undefined;
607
613
  const compactSummary = summary ? truncateModelField(summary, 192) : undefined;
@@ -616,6 +622,10 @@ function summarizeModelVisibleToolResult(executed, maxBytes, budgetRemainingByte
616
622
  modelVisibleCompressed: true,
617
623
  originalResultBytes: rawBytes,
618
624
  ...budgetMetadata,
625
+ ...(verification
626
+ ? { verification: includeDetails ? detailedVerification : verification }
627
+ : {}),
628
+ ...(typeof exitCode === 'number' && Number.isSafeInteger(exitCode) ? { exitCode } : {}),
619
629
  },
620
630
  });
621
631
  const includeDetails = byteLength(serializeCompact(truncateForModel(output, 128), true)) <= maxBytes;
@@ -791,7 +801,6 @@ async function* query(params) {
791
801
  const interrupted = () => isAborted(abortSignal) || (goalDeadlineAt !== undefined && Date.now() >= goalDeadlineAt);
792
802
  let input = params.input;
793
803
  let turn = 0;
794
- const rejectedCompletionStates = new Set();
795
804
  let successfulToolCalls = 0;
796
805
  const stats = createLoopStats();
797
806
  let pendingCompact;
@@ -854,22 +863,6 @@ async function* query(params) {
854
863
  return;
855
864
  }
856
865
  appendSteering(params.takePendingSteering?.() ?? []);
857
- const planStop = params.checkTaskPlanStop?.();
858
- if (planStop) {
859
- const finish = cloneLoopStats(stats, planStop.code === 'task_step_blocked' ? 'blocked' : 'completion_gate');
860
- const decision = finish.stopDecision;
861
- finish.stopDecision = {
862
- ...decision,
863
- status: planStop.code === 'task_step_blocked' ? 'blocked' : 'stopped',
864
- reason: { code: planStop.code, message: planStop.message },
865
- nextActions: [
866
- { kind: 'inspect', label: 'Inspect the current checklist', command: '/context explain' },
867
- { kind: 'continue', label: 'Continue the current task', command: '继续' },
868
- ],
869
- };
870
- yield attachCompactCommit({ type: 'complete', content: planStop.message, model: llm.getModel(), stats: finish }, pendingCompact, messages, aggregateUsage);
871
- return;
872
- }
873
866
  const toolOutputPressure = params.allowToolPressureCompaction === true &&
874
867
  successfulToolCalls > 0 &&
875
868
  stats.modelVisibleToolBytes >=
@@ -1043,12 +1036,13 @@ async function* query(params) {
1043
1036
  }
1044
1037
  let response;
1045
1038
  let sawReasoning = false;
1046
- const holdAssistant = params.holdAssistantUntilCompletionCheck?.() === true;
1039
+ // A response crossing a configured Goal allowance may be rejected as a whole.
1040
+ const bufferGoalResponse = params.remainingGoalTokens !== undefined || goalDeadlineAt !== undefined;
1047
1041
  try {
1048
1042
  stats.llmRequests++;
1049
1043
  response = await llm.chatStream(requestMessages, {
1050
1044
  ...streamCallbacks,
1051
- ...(holdAssistant ? { onChunk: undefined } : {}),
1045
+ ...(bufferGoalResponse ? { onChunk: undefined } : {}),
1052
1046
  onThinkingText: text => {
1053
1047
  sawReasoning || (sawReasoning = text.trim().length > 0);
1054
1048
  streamCallbacks?.onThinkingText?.(text);
@@ -1112,7 +1106,7 @@ async function* query(params) {
1112
1106
  response.finishReason === 'incomplete') {
1113
1107
  if (visibleContent) {
1114
1108
  appendMessage({ role: 'assistant', content: visibleContent });
1115
- if (holdAssistant)
1109
+ if (bufferGoalResponse)
1116
1110
  streamCallbacks?.onChunk?.(visibleContent);
1117
1111
  yield { type: 'message', role: 'assistant', content: visibleContent };
1118
1112
  }
@@ -1155,7 +1149,7 @@ async function* query(params) {
1155
1149
  };
1156
1150
  appendMessage(assistantMsg);
1157
1151
  harness?.recordAssistantResponse({ ...response, content: visibleContent });
1158
- if (holdAssistant && visibleContent)
1152
+ if (bufferGoalResponse && visibleContent)
1159
1153
  streamCallbacks?.onChunk?.(visibleContent);
1160
1154
  yield {
1161
1155
  type: 'assistant_tool_calls',
@@ -1375,7 +1369,7 @@ async function* query(params) {
1375
1369
  if (visibleContent) {
1376
1370
  appendMessage({ role: 'assistant', content: visibleContent });
1377
1371
  harness?.recordAssistantResponse({ ...response, content: visibleContent });
1378
- if (holdAssistant)
1372
+ if (bufferGoalResponse)
1379
1373
  streamCallbacks?.onChunk?.(visibleContent);
1380
1374
  yield { type: 'message', role: 'assistant', content: visibleContent };
1381
1375
  }
@@ -1383,7 +1377,7 @@ async function* query(params) {
1383
1377
  continue;
1384
1378
  }
1385
1379
  // A clean provider stop may consist entirely of reasoning or invisible text.
1386
- // Do not persist it or hand it to the completion gate as a final answer.
1380
+ // Preserve a typed provider failure instead of emitting a blank final answer.
1387
1381
  if (!visibleContent) {
1388
1382
  stats.missingAssistantOutput =
1389
1383
  response.content.length === 0 && !sawReasoning ? 'empty_output' : 'no_visible_output';
@@ -1395,58 +1389,12 @@ async function* query(params) {
1395
1389
  }, pendingCompact, messages, aggregateUsage);
1396
1390
  return;
1397
1391
  }
1398
- const assistantMsg = {
1399
- role: 'assistant',
1400
- content: response.content,
1401
- };
1402
- if (!holdAssistant) {
1403
- appendMessage(assistantMsg);
1404
- harness?.recordAssistantResponse(response);
1405
- }
1406
- // No tool calls — done, unless the harness requires one more pass.
1407
- const completionGate = harness?.beforeComplete();
1408
- if (completionGate && !completionGate.canComplete) {
1409
- const rejectedState = JSON.stringify([
1410
- completionGate.missing,
1411
- completionGate.progressDelta?.workspaceStateHash,
1412
- completionGate.criterionResults?.map(result => [
1413
- result.criterionId,
1414
- result.status,
1415
- result.verificationProblems,
1416
- ]),
1417
- ]);
1418
- if (rejectedCompletionStates.has(rejectedState)) {
1419
- const missing = completionGate.missing?.length
1420
- ? completionGate.missing.join('; ')
1421
- : 'required verification evidence is missing';
1422
- const stoppedStats = cloneLoopStats(stats, 'completion_gate');
1423
- if (completionGate.stopDecision) {
1424
- stoppedStats.stopDecision = {
1425
- ...completionGate.stopDecision,
1426
- resources: {
1427
- ...stoppedStats.stopDecision?.resources,
1428
- ...completionGate.stopDecision.resources,
1429
- },
1430
- };
1431
- }
1432
- yield attachCompactCommit({
1433
- type: 'complete',
1434
- content: `Completion gate stopped this turn: ${missing}\nRun the required verification, then continue.`,
1435
- model: response.model || llm.getModel(),
1436
- stats: stoppedStats,
1437
- }, pendingCompact, messages, aggregateUsage);
1438
- return;
1439
- }
1440
- rejectedCompletionStates.add(rejectedState);
1441
- appendMessage(harness.asCompletionBlockedMessage(completionGate));
1442
- stats.finishReason = 'completion_gate';
1443
- continue;
1444
- }
1445
- if (holdAssistant) {
1446
- appendMessage(assistantMsg);
1447
- harness?.recordAssistantResponse(response);
1392
+ appendMessage({ role: 'assistant', content: response.content });
1393
+ harness?.recordAssistantResponse(response);
1394
+ if (bufferGoalResponse)
1448
1395
  streamCallbacks?.onChunk?.(response.content);
1449
- }
1396
+ // Record verification independently of the model's end-of-turn signal.
1397
+ harness?.beforeComplete();
1450
1398
  yield { type: 'message', role: 'assistant', content: response.content };
1451
1399
  // Keep the next request safe by compacting the current durable history at
1452
1400
  // 95%. This uses current-message context, not cumulative session tokens.
@@ -1,6 +1,23 @@
1
1
  export declare const LOCAL_VERIFICATION_KINDS: readonly ["test", "build", "lint", "typecheck", "diff"];
2
2
  export type LocalVerificationKind = (typeof LOCAL_VERIFICATION_KINDS)[number];
3
3
  export type VerificationCommandKind = LocalVerificationKind | 'generic';
4
+ /** Model-visible diagnostic. Evidence is derived independently from executor receipts. */
5
+ export interface VerificationToolFeedback {
6
+ readonly kind: VerificationCommandKind;
7
+ readonly status: 'passed' | 'failed' | 'unverified';
8
+ readonly reason?: 'shell_pipeline' | 'compound_shell' | 'workspace_unavailable' | 'interrupted' | 'process_did_not_exit';
9
+ readonly message?: string;
10
+ readonly retry?: {
11
+ readonly tool: 'exec_command';
12
+ readonly args: {
13
+ readonly command: string;
14
+ readonly cwd: string;
15
+ readonly maxOutput: number;
16
+ readonly timeout?: number;
17
+ };
18
+ };
19
+ }
20
+ export type VerificationToolStatus = Pick<VerificationToolFeedback, 'kind' | 'status' | 'reason'>;
4
21
  /** Projected by the authoritative executor, outside of model-visible tool output. */
5
22
  export interface LocalVerificationReceipt {
6
23
  readonly kind: VerificationCommandKind;
@@ -10,6 +27,12 @@ export interface LocalVerificationReceipt {
10
27
  readonly passed: boolean;
11
28
  }
12
29
  export declare function isLocalVerificationKind(value: unknown): value is LocalVerificationKind;
30
+ export declare function verificationToolStatus(value: unknown): VerificationToolStatus | undefined;
31
+ export declare function hasNonzeroShellExitCode(metadata: Record<string, unknown> | undefined): boolean;
13
32
  export declare const SHELL_CONTROL_OPERATOR: RegExp;
33
+ /** Identify a runner for diagnostics when shell composition prevents a receipt. */
34
+ export declare function identifyVerificationRunner(command: string): LocalVerificationKind | undefined;
14
35
  export declare function classifyDirectVerificationCommand(command: string): VerificationCommandKind | undefined;
36
+ /** Support an explicitly requested script without treating arbitrary script runs as checks. */
37
+ export declare function classifyVerificationSelector(command: string): VerificationCommandKind | undefined;
15
38
  //# sourceMappingURL=verification-command.d.ts.map
@@ -2,11 +2,39 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SHELL_CONTROL_OPERATOR = exports.LOCAL_VERIFICATION_KINDS = void 0;
4
4
  exports.isLocalVerificationKind = isLocalVerificationKind;
5
+ exports.verificationToolStatus = verificationToolStatus;
6
+ exports.hasNonzeroShellExitCode = hasNonzeroShellExitCode;
7
+ exports.identifyVerificationRunner = identifyVerificationRunner;
5
8
  exports.classifyDirectVerificationCommand = classifyDirectVerificationCommand;
9
+ exports.classifyVerificationSelector = classifyVerificationSelector;
10
+ const shell_command_1 = require("../utils/shell-command");
6
11
  exports.LOCAL_VERIFICATION_KINDS = ['test', 'build', 'lint', 'typecheck', 'diff'];
7
12
  function isLocalVerificationKind(value) {
8
13
  return exports.LOCAL_VERIFICATION_KINDS.some(kind => kind === value);
9
14
  }
15
+ function verificationToolStatus(value) {
16
+ if (!value || typeof value !== 'object')
17
+ return;
18
+ const { kind, status, reason } = value;
19
+ if ((kind === 'generic' || isLocalVerificationKind(kind)) &&
20
+ (status === 'passed' || status === 'failed' || status === 'unverified')) {
21
+ return {
22
+ kind,
23
+ status,
24
+ ...(reason === 'shell_pipeline' ||
25
+ reason === 'compound_shell' ||
26
+ reason === 'workspace_unavailable' ||
27
+ reason === 'interrupted' ||
28
+ reason === 'process_did_not_exit'
29
+ ? { reason }
30
+ : {}),
31
+ };
32
+ }
33
+ }
34
+ function hasNonzeroShellExitCode(metadata) {
35
+ const exitCode = metadata?.exitCode;
36
+ return typeof exitCode === 'number' && Number.isSafeInteger(exitCode) && exitCode > 0;
37
+ }
10
38
  exports.SHELL_CONTROL_OPERATOR = /[;&|\x60\n\r]|\$\(/u;
11
39
  const directChecks = {
12
40
  test: /^(?:(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test|(?:npx\s+)?(?:jest|vitest)|(?:python3?\s+-m\s+)?pytest|(?:go|cargo|make)\s+test)(?=\s|$)/u,
@@ -16,17 +44,50 @@ const directChecks = {
16
44
  diff: /^git\s+diff\s+(?:(?:--cached|--staged)\s+)?--check(?=\s|$)/u,
17
45
  };
18
46
  // These calls can return zero without running a check.
19
- const nonCheckingOption = /(?:^|[\s'"])(?:-h|--help|--version|--listTests|--listFilesOnly|--showConfig|--collect-only|--dry-run|--no-run|--passWithNoTests|--pass-with-no-tests|--if-present|-list)(?=[\s'"=]|$)/u;
47
+ const nonCheckingOption = /^(?:-h|--help|--version|--listTests|--listFilesOnly|--showConfig|--collect-only|--dry-run|--no-run|--passWithNoTests|--pass-with-no-tests|--if-present|-list)(?==|$)/u;
48
+ const pytestInvocation = /^(?:(?:python3?\s+-m\s+)?pytest)(?=\s|$)/u;
49
+ const pytestListingOption = /^(?:-[qvsxlf]*[Vh][qvsxlf]*|--co|--collectonly|--cache-show|--fixtures|--fixtures-per-test|--markers|--setup-plan|--setup-only)(?==|$)/u;
20
50
  const nonCheckingInvocation = /^(?:npx\s+)?(?:vitest\s+list|tsc\s+(?:-v|--init))(?=\s|$)/u;
21
51
  const fileAssertion = /^test\s+-(?:e|f|d|s)\s+(?:"[^"]+"|'[^']+'|[^\s'"<>]+)$/u;
52
+ const customCheck = /^(?:(?:python3?|node)\s+(?:"[^"]+\.(?:py|[cm]?js)"|'[^']+\.(?:py|[cm]?js)'|[^\s'"<>]+\.(?:py|[cm]?js))|\.\/[^\s'"<>]+|(?:npm|pnpm|yarn|bun)\s+run\s+[\w:.-]+)(?=\s|$)/u;
53
+ function isCheckingArguments(command, words) {
54
+ return (!words.some(word => nonCheckingOption.test(word)) &&
55
+ !(pytestInvocation.test(command) && words.some(word => pytestListingOption.test(word))) &&
56
+ !nonCheckingInvocation.test(words.join(' ')));
57
+ }
58
+ function isCheckingInvocation(command) {
59
+ let compound = false;
60
+ const scan = (0, shell_command_1.scanShellCommand)(command, () => {
61
+ compound = true;
62
+ });
63
+ if (compound || !scan.supported || scan.segments.length !== 1)
64
+ return false;
65
+ const words = (0, shell_command_1.literalShellWords)(scan.segments[0]);
66
+ if (!words?.length)
67
+ return false;
68
+ return isCheckingArguments(command, words);
69
+ }
70
+ /** Identify a runner for diagnostics when shell composition prevents a receipt. */
71
+ function identifyVerificationRunner(command) {
72
+ const normalized = command.trim();
73
+ const words = (0, shell_command_1.literalShellWords)(normalized);
74
+ if (words && !isCheckingArguments(normalized, words))
75
+ return;
76
+ return exports.LOCAL_VERIFICATION_KINDS.find(kind => directChecks[kind].test(normalized));
77
+ }
22
78
  function classifyDirectVerificationCommand(command) {
23
79
  const normalized = command.trim();
24
- if (exports.SHELL_CONTROL_OPERATOR.test(normalized) ||
25
- nonCheckingOption.test(normalized) ||
26
- nonCheckingInvocation.test(normalized)) {
80
+ if (!isCheckingInvocation(normalized))
27
81
  return undefined;
28
- }
29
82
  return (exports.LOCAL_VERIFICATION_KINDS.find(kind => directChecks[kind].test(normalized)) ??
30
83
  (fileAssertion.test(normalized) ? 'generic' : undefined));
31
84
  }
85
+ /** Support an explicitly requested script without treating arbitrary script runs as checks. */
86
+ function classifyVerificationSelector(command) {
87
+ const normalized = command.trim();
88
+ return (classifyDirectVerificationCommand(normalized) ??
89
+ (isCheckingInvocation(normalized) && !/[<>]/u.test(normalized) && customCheck.test(normalized)
90
+ ? 'generic'
91
+ : undefined));
92
+ }
32
93
  //# sourceMappingURL=verification-command.js.map
@@ -7,6 +7,7 @@ export interface PromptAssemblyOptions {
7
7
  description?: string;
8
8
  }>;
9
9
  includeTaskTodos?: boolean;
10
+ answeringQuestion?: boolean;
10
11
  }
11
12
  export interface HarnessContextBuildResult {
12
13
  text: string;
@@ -77,7 +77,8 @@ function buildHarnessContext(state, modelId, config = {}, options = {}) {
77
77
  state.ledger.length === 0 &&
78
78
  !state.capsule &&
79
79
  !state.rootObjective &&
80
- !state.capabilityProfile) {
80
+ !state.capabilityProfile &&
81
+ !options.answeringQuestion) {
81
82
  const emptyStats = {
82
83
  createdAt: Date.now(),
83
84
  modelId,
@@ -161,7 +162,9 @@ function buildHarnessContext(state, modelId, config = {}, options = {}) {
161
162
  if (tools.length > 0) {
162
163
  pushList(coreLines, 'Relevant available tools', tools, 8);
163
164
  }
164
- const finalInstruction = 'Instruction: preserve the root objective across short feedback or refinements. Do not claim verification unless it is listed above or produced by a tool result in this turn.';
165
+ const finalInstruction = options.answeringQuestion
166
+ ? 'Answer the latest question using the task and verification context. Leave execution and checklist changes for a request to continue the work.'
167
+ : 'Instruction: preserve the root objective across short feedback or refinements. Do not claim verification unless it is listed above or produced by a tool result in this turn.';
165
168
  const coreText = coreLines.join('\n');
166
169
  const coreTokens = (0, evidence_1.estimateTokens)(coreText);
167
170
  const instructionTokens = (0, evidence_1.estimateTokens)(finalInstruction);
@@ -0,0 +1,3 @@
1
+ /** Identify a question about work without treating quoted or described work as an instruction. */
2
+ export declare function isReadOnlyQuestion(input: string): boolean;
3
+ //# sourceMappingURL=clarification.d.ts.map
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isReadOnlyQuestion = isReadOnlyQuestion;
4
+ const englishRequestPrefix = /^(?:(?:please|first|then|also|just)\s+|(?:can|could|would|will)\s+you\s+|i (?:want|would like) you to\s+)+/iu;
5
+ const chineseRequestPrefix = /^(?:(?:请|麻烦你|帮我|先|再|然后|同时)\s*)+/u;
6
+ const englishQuestion = /^(?:what|why|how|who|when|where|which)\b/iu;
7
+ const chineseQuestion = /^(?:为什么|为何|谁|怎么|如何|哪些|哪个)/u;
8
+ const embeddedQuestion = /^(?:explain|clarify|describe)(?:\s+to me)?\s+(?:what|why|how|when|where)\s+(?:i|we|you|they)\s+(?:can|could|should|must|may|would|do)\b|^(?:解释|说明)(?:一下)?\s*(?:怎么|如何|(?:为什么|为何)(?:要|需要|必须|应该|得))/iu;
9
+ const englishExplanation = /^(?:explain|clarify|describe)\b|^(?:tell me|show me)\s+(?:what|why|how|who|when|where|which)\b/iu;
10
+ const chineseExplanation = /(?:什么意思|解释(?:一下|说明)?|说明一下|能否说明)/u;
11
+ const englishStatus = /^(?:report|show(?: me)?|tell me|summarize)\s+(?:the\s+)?(?:current\s+)?(?:context(?:\s+(?:usage|size|window))?\b|(?:task|goal|session|test|build)\s+status\b|status\b|progress\b)/iu;
12
+ const chineseStatus = /^(?:(?:请|帮我|报告|汇报|查看|告诉我|展示|说一下|列出|总结)(?:一下)?\s*)*(?:当前|现在|目前)?(?:的)?\s*(?:上下文|会话|任务|目标|测试|构建|验证|进度)(?:[^??。\r\n]{0,28})(?:多少|剩余|用量|占用|状态|进度|报告一下|汇报一下|怎么样|结果)/u;
13
+ const englishExecution = /^(?:run|rerun|execute|verify|validate|check|test|build|compile|lint|typecheck|fix|implement|add|adjust|apply|edit|update|modify|change|write|create|delete|remove|replace|rename|refactor|continue|resume|retry|start|commit|merge|push|publish|deploy)\b|^(?:(?:the\s+)?(?:tests?|build|lint|ci)\b.{0,44}\b(?:must|should|needs? to|required to)\b)/iu;
14
+ const chineseExecution = /^(?:执行|运行|重新运行|跑(?:一下|测试|检查|验证|\s*(?:npm|pnpm|yarn|pytest))|重跑|验证|测试|检查|构建|编译|修复|实现|修改|更新|调整|添加|新增|删除|替换|改用|换成|改为|创建|写入|重构|提交|合并|推送|发布|部署|继续|接着|恢复|重试)|^(?:把|将).{1,100}(?:改为|换成|替换|修改|重跑|执行|运行|改成)|^(?:测试|构建|验证|检查).{0,24}(?:必须|需要|务必)(?:通过|成功)/u;
15
+ const actionConjunction = /\b(?:and then|then|and|also)\b\s*|,\s*(?=please\b|just\b)|(?:然后|并且|同时|另外|再|并)/iu;
16
+ const explicitActionConjunction = /\b(?:and then|then|and|also)\b\s+(?=please\b|(?:can|could|would|will)\s+you\b)|,\s*(?:and then|then|also)\b\s+|(?:然后|并且|同时|另外|再|并)(?=\s*(?:请|帮我|麻烦你))/iu;
17
+ function stripRequestPrefix(text) {
18
+ return text.trim().replace(englishRequestPrefix, '').replace(chineseRequestPrefix, '');
19
+ }
20
+ function requestsExecution(text) {
21
+ const action = stripRequestPrefix(text);
22
+ return englishExecution.test(action) || chineseExecution.test(action);
23
+ }
24
+ /** Identify a question about work without treating quoted or described work as an instruction. */
25
+ function isReadOnlyQuestion(input) {
26
+ const prose = input
27
+ .replace(/^[ \t]*\x60{3}[^\r\n]*\r?\n[\s\S]*?^[ \t]*\x60{3}[^\r\n]*/gmu, ' ')
28
+ .replace(/\x60[^\x60\r\n]+\x60|“[^”\r\n]+”|「[^」\r\n]+」|‘[^’\r\n]+’|"[^"\r\n]+"|(?<![\p{L}\p{N}])'[^'\r\n]+'(?![\p{L}\p{N}])/gu, ' reference ');
29
+ const clauses = prose
30
+ .split(/[!??!。;;\r\n]+|\.(?=\s|$)/u)
31
+ .map(clause => clause.trim().replace(/^(?:[-*+]|\d+[.)、])\s+/u, ''))
32
+ .filter(Boolean);
33
+ let sawQuestion = false;
34
+ for (const clause of clauses) {
35
+ const request = stripRequestPrefix(clause);
36
+ const directQuestion = englishQuestion.test(request) || chineseQuestion.test(request);
37
+ const question = directQuestion ||
38
+ englishExplanation.test(request) ||
39
+ chineseExplanation.test(request) ||
40
+ englishStatus.test(request) ||
41
+ chineseStatus.test(clause);
42
+ if (requestsExecution(clause))
43
+ return false;
44
+ // A list of verbs inside "why do we build and test?" describes what the
45
+ // user is asking about. Instructions after a sentence boundary, or with
46
+ // an explicit request marker, can still ask the agent to act.
47
+ const conjunction = directQuestion || embeddedQuestion.test(request)
48
+ ? explicitActionConjunction
49
+ : actionConjunction;
50
+ if (clause.split(conjunction).slice(1).some(requestsExecution))
51
+ return false;
52
+ sawQuestion || (sawQuestion = question);
53
+ }
54
+ return sawQuestion;
55
+ }
56
+ //# sourceMappingURL=clarification.js.map