chainlesschain 0.166.161 → 0.166.163

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 (48) hide show
  1. package/README.md +15 -3
  2. package/package.json +1 -1
  3. package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
  4. package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
  5. package/src/command-help-index.json +1 -1
  6. package/src/commands/agenda.js +23 -2
  7. package/src/commands/agent.js +56 -21
  8. package/src/commands/ccron.js +1 -0
  9. package/src/commands/loop.js +34 -1
  10. package/src/commands/mcp.js +13 -3
  11. package/src/commands/plugin.js +10 -31
  12. package/src/commands/skill.js +31 -6
  13. package/src/commands/tasks.js +20 -2
  14. package/src/data/changelog.json +26 -0
  15. package/src/harness/background-task-command-runner.js +23 -25
  16. package/src/harness/prompt-compressor.js +10 -1
  17. package/src/lib/__tests__/provider-stream.test.js +16 -0
  18. package/src/lib/background-agent-supervisor.js +3 -0
  19. package/src/lib/chat-core.js +10 -3
  20. package/src/lib/coding-task-guidance.js +1 -0
  21. package/src/lib/context-memory-kernel/live-compaction.js +100 -19
  22. package/src/lib/cowork-cron.js +115 -31
  23. package/src/lib/install-command-policy.js +23 -0
  24. package/src/lib/json-schema-output.js +12 -31
  25. package/src/lib/loop.js +30 -11
  26. package/src/lib/lsp/__tests__/code-intelligence.integration.test.js +17 -15
  27. package/src/lib/plan-mode.js +16 -0
  28. package/src/lib/plugin-runtime/install.js +111 -67
  29. package/src/lib/process-execution-broker/index.js +19 -9
  30. package/src/lib/provider-stream.js +7 -3
  31. package/src/lib/public-ide-capability-manifest.js +88 -0
  32. package/src/lib/public-ide-capability-validation.js +24 -0
  33. package/src/lib/read-file-loop-guard.js +9 -1
  34. package/src/lib/repl-denials.js +11 -0
  35. package/src/lib/search-command.js +13 -2
  36. package/src/lib/secret-store.js +30 -5
  37. package/src/lib/session-plan-approval.js +11 -2
  38. package/src/lib/status-line.cjs +3 -2
  39. package/src/lib/stream-retry.js +20 -0
  40. package/src/lib/task-record.js +12 -1
  41. package/src/lib/text-file-search.js +7 -2
  42. package/src/repl/agent-repl.js +195 -33
  43. package/src/runtime/agent-core.js +44 -18
  44. package/src/runtime/coding-agent-contract-shared.cjs +4 -2
  45. package/src/runtime/headless-runner.js +61 -4
  46. package/src/runtime/headless-stream.js +86 -17
  47. package/src/runtime/provider-stream-state.js +3 -1
  48. package/src/workers/background-agent-worker.js +11 -10
package/README.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # chainlesschain CLI
2
2
 
3
- ## CLI 0.166.161 and IDE pairing
3
+ ## CLI 0.166.163 candidate
4
4
 
5
- CLI **0.166.161** refreshes the LK model catalog on demand and includes GPT-6.2 Sol and GPT-6.2 Astra in the offline catalog. Install the release after it appears on public npm with `npm i -g chainlesschain@0.166.161 --registry https://registry.npmjs.org`. The paired IDE versions are Open VSX **0.37.196** and JetBrains **0.4.211**. Each outlet has its own publication gate. Account access and model inference depend on the configured LK key. [LK configuration](../../docs/configuration/lk-api-channel.md).
5
+ The candidate improves file-search diagnostics, retries a timed-out Windows credential read once, and asks coding agents to verify workspace changes before reporting delivery. When the model receives a requested source page, the CLI clears the consecutive delivery failures for that file. Canonical compaction retains full handoffs that fit the conversation budget and can use a shorter local handoff with file read positions when needed. Chat Completions provider errors stop the stream and fail the turn. Interrupting a turn closes its pending approvals. The planned pairing is Open VSX **0.37.198** and JetBrains **0.4.213**. The public pairing and install command are below.
6
6
 
7
- The current public CLI is **0.166.160** and pairs with public Open VSX **0.37.195**. JetBrains **0.4.210** is its candidate pairing. Public JetBrains **0.4.209** recommends CLI **0.166.159**. [Upgrade guide and release limits](../../docs-site/docs/chainlesschain/cli-ide-update-2026-11-22-160.md)
7
+ ## Public CLI 0.166.162 and IDE pairing
8
+
9
+ CLI **0.166.162** is public on npm from exact source `03cb502b0e0e3facfbce79ef336fec7861a5554c`. GitHub Actions verified the public archive and signed provenance after CLI CI, Strict Sandbox, and the child package checks passed. Install `npm i -g chainlesschain@0.166.162 --registry https://registry.npmjs.org`, restart the CLI and IDE hosts, then run `cc --version` and `cc doctor`. [OIDC publication](https://github.com/longfa/chainlesschain/actions/runs/45306343051)
10
+
11
+ This release preserves approved plan permissions across resumes, reports headless persistence failures in JSON, and records Git installation outcomes. Open VSX **0.37.197** and JetBrains **0.4.212** are publicly downloadable and recommend this CLI version. [Upgrade guide](https://docs.chainlesschain.com/chainlesschain/cli-ide-update-2026-11-24-162.html)
12
+
13
+ Release limits are `NOT_PAID_READY` for paid readiness, `NOT_ADMITTED` for native admission, and `HOLD` for automatic promotion. This pairing covers the CLI and IDE extensions.
14
+
15
+ ## Public CLI 0.166.161 and IDE pairing
16
+
17
+ CLI **0.166.161** is public on npm from exact source `22f4dfea080546d586f75652fd5075671019ffb8`. GitHub Actions verified the public archive and signed provenance after CLI CI, Strict Sandbox and the child-package checks passed. Install `npm i -g chainlesschain@0.166.161 --registry https://registry.npmjs.org` and check `cc --version`. [OIDC publication](https://github.com/longfa/chainlesschain/actions/runs/45084688787)
18
+
19
+ Run `cc llm models --provider lk --json` to read the online LK catalog or the bundled snapshot, which includes GPT‑6.2 Sol and Astra. Use `cc tasks --json` to inspect task states, deadlines, waiting dependencies, and stop paths. Open VSX **0.37.196** and JetBrains **0.4.211** are publicly available and recommend this CLI version. [Upgrade guide and release limits](https://docs.chainlesschain.com/chainlesschain/cli-ide-update-2026-11-23-161.html)
8
20
 
9
21
  Command-line interface for installing, configuring, and managing [ChainlessChain](https://www.chainlesschain.com), including the coding agent, governed tools, sessions, memory, and IDE integrations.
10
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chainlesschain",
3
- "version": "0.166.161",
3
+ "version": "0.166.163",
4
4
  "description": "CLI for ChainlessChain - install, configure, and manage your personal AI management system",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,5 +6,5 @@
6
6
  "imageDigest": "sha256:29035535f96301d26ccf9f1cd8757f450b052b81b1c5cf47fd401f24042904b2",
7
7
  "bytes": 778760,
8
8
  "linkage": "static",
9
- "commit": "22f4dfea080546d586f75652fd5075671019ffb8"
9
+ "commit": "b06b3bfe0f1bf91d40617f3a0c83d918795d4fe6"
10
10
  }
@@ -6,5 +6,5 @@
6
6
  "imageDigest": "sha256:051b817c5f4e4849a98c55f64d1ee8dee980ec92decc23c2829b9bce217a8d47",
7
7
  "bytes": 934112,
8
8
  "linkage": "static",
9
- "commit": "22f4dfea080546d586f75652fd5075671019ffb8"
9
+ "commit": "b06b3bfe0f1bf91d40617f3a0c83d918795d4fe6"
10
10
  }
@@ -84,7 +84,7 @@
84
84
  "learning": "Usage: chainlesschain learning [options] [command]\n\nLearning records — trajectories, reflection, and governed candidate attempts\n\nOptions:\n -h, --help display help for command\n\nCommands:\n stats [options] Show learning loop statistics\n trajectories [options] List recent trajectories\n export [options] Export all learning trajectories as JSON (module 101\n §8.3 backup)\n import [options] Import learning trajectories from a JSON array file\n (idempotent upsert by id; §8.3)\n reflect [options] Run a reflection cycle and generate report\n synthesize [options] Attempt a governed Skill candidate from eligible\n trajectories\n cleanup [options] Delete old trajectories beyond retention period\n help [command] display help for command\n",
85
85
  "llm": "Usage: chainlesschain llm [options] [command]\n\nLLM provider management\n\nOptions:\n -h, --help display help for command\n\nCommands:\n connections [options] Read saved connection metadata without\n credentials\n account [options] Query fresh LK prices, account balance,\n Key quota and actual API charges\n capabilities [options] Inspect a static model capability\n profile without network or runtime\n verification\n configure [options] Atomically save an LLM connection from\n stdin JSON (secrets never enter argv)\n models [options] List available models from the current\n provider\n test [options] Test LLM provider connectivity\n (defaults to configured provider)\n providers [options] List all available LLM providers\n add-provider [options] <name> Add a custom LLM provider\n switch [options] <name> Switch the active LLM provider\n provider-maturities-v2 List V2 provider maturity states\n request-lifecycles-v2 List V2 request lifecycle states\n stats-v2 V2 llm-providers stats\n get-max-active-profiles-v2 Get max active profiles per owner (V2)\n set-max-active-profiles-v2 <n> Set max active profiles per owner (V2)\n get-max-pending-requests-v2 Get max pending requests per profile\n (V2)\n set-max-pending-requests-v2 <n> Set max pending requests per profile\n (V2)\n get-profile-idle-ms-v2 Get profile idle threshold (V2)\n set-profile-idle-ms-v2 <ms> Set profile idle threshold (V2)\n get-request-stuck-ms-v2 Get request stuck threshold (V2)\n set-request-stuck-ms-v2 <ms> Set request stuck threshold (V2)\n active-profile-count-v2 <ownerId> Active profile count for owner (V2)\n pending-request-count-v2 <profileId> Pending request count for profile (V2)\n register-profile-v2 [options] <id> Register a V2 profile\n get-profile-v2 <id> Get a V2 profile\n list-profiles-v2 [options] List V2 profiles\n set-profile-status-v2 <id> <next> Set V2 profile status\n activate-profile-v2 <id> Activate a V2 profile\n suspend-profile-v2 <id> Suspend a V2 profile\n retire-profile-v2 <id> Retire a V2 profile\n touch-profile-v2 <id> Touch a V2 profile\n create-request-v2 [options] <id> Create a V2 request\n get-request-v2 <id> Get a V2 request\n list-requests-v2 [options] List V2 requests\n set-request-status-v2 <id> <next> Set V2 request status\n start-request-v2 <id> Start a V2 request\n complete-request-v2 <id> Complete a V2 request\n fail-request-v2 <id> Fail a V2 request\n cancel-request-v2 <id> Cancel a V2 request\n auto-suspend-idle-profiles-v2 Auto-suspend idle V2 profiles\n auto-fail-stuck-requests-v2 Auto-fail stuck V2 requests\n help [command] display help for command\n",
86
86
  "logs": "Usage: chainlesschain logs [options] <id>\n\nPrint recent output from a background agent\n\nOptions:\n -n, --lines <n> Number of lines (default: \"100\")\n -h, --help display help for command\n",
87
- "loop": "Usage: chainlesschain loop [options] [parts...]\n\nRepeatedly run an agent prompt or `-- <command>` on a fixed interval\n\nOptions:\n --every <dur> Interval between iterations (e.g. 30s, 5m, 1.5h;\n bare number = seconds) (default: \"5m\")\n -n, --max-iterations <n> Stop after N iterations\n --until-exit-zero Stop once an iteration exits with code 0 (e.g.\n tests pass)\n --until <regex> Stop once an iteration's output matches this JS\n regex\n --dynamic Let each iteration self-pace via [[loop:next\n <dur>]] / [[loop:stop]] directives (prompt mode\n augments the prompt)\n --save [id] Persist this loop to a resumable session\n (auto-generates an id if omitted)\n --resume <id> Continue a previously --save'd loop session\n --json Print a JSON summary when the loop ends\n -h, --help display help for command\n",
87
+ "loop": "Usage: chainlesschain loop [options] [parts...]\n\nRepeatedly run an agent prompt or `-- <command>` on a fixed interval\n\nOptions:\n --every <dur> Interval between iterations (e.g. 30s, 5m, 1.5h;\n bare number = seconds) (default: \"5m\")\n -n, --max-iterations <n> Stop after N iterations\n --ends-at <timestamp> Stop scheduling iterations at this timestamp\n --until-exit-zero Stop once an iteration exits with code 0 (e.g.\n tests pass)\n --until <regex> Stop once an iteration's output matches this JS\n regex\n --dynamic Let each iteration self-pace via [[loop:next\n <dur>]] / [[loop:stop]] directives (prompt mode\n augments the prompt)\n --save [id] Persist this loop to a resumable session\n (auto-generates an id if omitted)\n --resume <id> Continue a previously --save'd loop session\n --json Print a JSON summary when the loop ends\n -h, --help display help for command\n",
88
88
  "lowcode": "Usage: chainlesschain lowcode [options] [command]\n\nLow-code application platform\n\nOptions:\n -h, --help display help for command\n\nCommands:\n create [options] <name> Create a new low-code application\n list [options] List all low-code applications\n preview <app-id> Preview application info\n publish <app-id> Publish an application\n components [options] List available built-in components\n datasource [options] <app-id> <name> <type> Add a data source to an application\n versions [options] <app-id> Show version history for an application\n rollback <app-id> <version> Rollback application to a previous version\n export [options] <app-id> Export application definition\n categories [options] List component categories (V2)\n datasource-types [options] List supported data source types (V2)\n statuses [options] List canonical app statuses (V2)\n components-v2 [options] List built-in components with category filter (V2)\n datasource-v2 [options] <app-id> <name> <type> Register a validated data source (V2)\n test-connection [options] <datasource-id> Heuristic connection check for a data source (V2)\n set-status <app-id> <status> Update app status with validated transition (V2)\n archive <app-id> Archive an application (V2)\n status-history [options] <app-id> Show status transition history for an app (V2)\n clone [options] <source-id> Clone an application (V2)\n export-json [options] <app-id> Export an app as canonical JSON (V2)\n import-json <file> Import an app from a canonical JSON file (V2)\n stats-v2 [options] Low-code platform statistics (V2)\n deploy [options] <app-id> Deploy application as static HTML bundle\n enums-v2 Show V2 enums (app maturity + build lifecycle)\n config-v2 Show V2 config thresholds\n set-max-active-apps-v2 <n> Set max active apps per owner\n set-max-pending-builds-v2 <n> Set max pending builds per app\n set-app-idle-ms-v2 <n> Set app idle threshold (ms)\n set-build-stuck-ms-v2 <n> Set build stuck threshold (ms)\n register-app-v2 [options] <id> <owner> Register V2 app\n activate-app-v2 <id> Activate app\n pause-app-v2 <id> Pause app\n archive-app-v2 <id> Archive app (terminal)\n touch-app-v2 <id> Touch app lastTouchedAt\n get-app-v2 <id> Get V2 app\n list-apps-v2 List V2 apps\n create-build-v2 [options] <id> <appId> Create V2 app build (queued)\n start-build-v2 <id> Start build\n succeed-build-v2 <id> Succeed build\n fail-build-v2 <id> [reason] Fail build\n cancel-build-v2 <id> [reason] Cancel build\n get-build-v2 <id> Get V2 build\n list-builds-v2 List V2 builds\n auto-pause-idle-v2 Auto-pause idle active apps\n auto-fail-stuck-v2 Auto-fail stuck building builds\n gov-stats-v2 V2 governance aggregate stats\n help [command] display help for command\n",
89
89
  "marketplace": "Usage: chainlesschain marketplace [options] [command]\n\nSkill marketplace — publish skill services, record invocations, view stats\n\nOptions:\n -h, --help display help for command\n\nCommands:\n serve-badge [options] <skill-name> Serve a read-only public Eval badge for one explicitly pinned listing\n inspect [options] <skill-name> Verify a signed Skill listing for the deployment's fixed target\n install [options] <skill-name> Persist verified candidate files and governance state; does not activate the Skill\n state <skill-name> Read the verified durable governed Skill state\n rollout [options] <skill-name> Advance exactly one stage using a verified Pilot receipt\n revoke [options] <skill-name> Roll back using a verified revocation receipt\n status-types [options] List known service statuses\n invocation-statuses [options] List known invocation statuses\n publish [options] <name> Publish a skill service\n list [options] List skill services\n show [options] <service-id> Show full details of a skill service\n status [options] <service-id> <new-status> Transition service status (draft|published|deprecated|suspended)\n record [options] <service-id> Record a skill invocation against a published service\n invocations [options] List skill invocations\n stats [options] Aggregate invocation stats (optionally scoped to a service)\n service-statuses-v2 [options] List V2 service statuses (frozen enum)\n invocation-statuses-v2 [options] List V2 invocation statuses (frozen enum)\n pricing-models [options] List V2 pricing models (frozen enum)\n default-max-concurrent Show default per-service concurrency cap\n max-concurrent Show current per-service concurrency cap\n active-invocation-count [service-id] Show count of PENDING + RUNNING invocations (all services by default)\n set-max-concurrent <n> Set the per-service concurrency cap\n begin-v2 [options] <service-id> Begin a V2 invocation (creates PENDING, enforces cap)\n start-invocation [options] <invocation-id> Start a V2 invocation (PENDING → RUNNING)\n complete-invocation [options] <invocation-id> Complete a V2 invocation (RUNNING → SUCCESS)\n fail-invocation [options] <invocation-id> Fail a V2 invocation\n timeout-invocation [options] <invocation-id> Timeout a V2 invocation\n set-invocation-status [options] <invocation-id> <status> Set V2 invocation status via the state machine\n stats-v2 [options] V2 aggregated stats\n purchase [options] <itemId> Initiate a purchase. Large orders (≥ threshold) route through M-of-N multisig.\n consume [options] <proposalId> Execute a multisig-gated purchase after threshold reached (marks proposal consumed)\n help [command] display help for command\n",
90
90
  "matrix": "Usage: chainlesschain matrix [options] [command]\n\nMatrix bridge — rooms, messaging, E2EE\n\nOptions:\n -h, --help display help for command\n\nCommands:\n login [options] Login to a Matrix homeserver\n rooms [options] List joined rooms\n send [options] <room-id> <message> Send a message to a room\n messages [options] <room-id> Get messages from a room\n join <room-id> Join a Matrix room\n thread Matrix threaded replies (m.thread\n relation)\n space Matrix Spaces — hierarchical room\n grouping (m.space)\n enums-v2 Show V2 enums\n register-room-v2 [options] Register a matrix room profile (pending)\n activate-room-v2 <id> Activate room\n mute-room-v2 <id> Mute room\n archive-room-v2 <id> Archive room (terminal)\n touch-room-v2 <id> Refresh lastTouchedAt\n get-room-v2 <id> Get a room\n list-rooms-v2 List rooms\n create-msg-v2 [options] Create a matrix message (queued)\n start-msg-v2 <id> Transition msg to sending\n deliver-msg-v2 <id> Transition msg to delivered\n fail-msg-v2 [options] <id> Fail msg\n cancel-msg-v2 [options] <id> Cancel msg\n get-msg-v2 <id> Get msg\n list-msgs-v2 List msgs\n set-max-active-rooms-v2 <n> Set per-owner active cap\n set-max-pending-msgs-v2 <n> Set per-room pending cap\n set-room-idle-ms-v2 <n> Set idle threshold\n set-msg-stuck-ms-v2 <n> Set stuck threshold\n auto-mute-idle-rooms-v2 Auto-mute idle rooms\n auto-fail-stuck-msgs-v2 Auto-fail stuck sending msgs\n stats-v2 V2 aggregate stats\n help [command] display help for command\n",
@@ -277,7 +277,26 @@ export function runAgendaList(options = {}, _deps = {}) {
277
277
  const now = _deps.now ? _deps.now() : Date.now();
278
278
  const nextAt = nextWakeupAt(entries, { now });
279
279
  if (options.json) {
280
- log(JSON.stringify({ entries, nextWakeupAt: nextAt }, null, 2));
280
+ const entriesWithTiming = entries.map((entry) => {
281
+ const { expiresAt } = entry;
282
+ const endsAt = expiresAt == null ? null : new Date(expiresAt).toJSON();
283
+ const next = nextWakeupAt([entry], { now });
284
+ const canRunBeforeExpiry =
285
+ next != null && (expiresAt == null || next < expiresAt);
286
+ return {
287
+ ...entry,
288
+ endsAt,
289
+ expiresAction: endsAt ? "retire" : null,
290
+ nextRunAt: canRunBeforeExpiry ? new Date(next).toJSON() : null,
291
+ };
292
+ });
293
+ log(
294
+ JSON.stringify(
295
+ { entries: entriesWithTiming, nextWakeupAt: nextAt },
296
+ null,
297
+ 2,
298
+ ),
299
+ );
281
300
  return 0;
282
301
  }
283
302
  if (entries.length === 0) {
@@ -301,7 +320,9 @@ export function runAgendaList(options = {}, _deps = {}) {
301
320
  : `${monitorWhat} (next ${new Date(e.nextAt).toISOString()})`;
302
321
  const expiry =
303
322
  e.expiresAt != null
304
- ? chalk.dim(` · expires ${new Date(e.expiresAt).toISOString()}`)
323
+ ? chalk.dim(
324
+ ` · expires ${new Date(e.expiresAt).toISOString()} (retire)`,
325
+ )
305
326
  : "";
306
327
  const policy = e.runPolicy
307
328
  ? chalk.dim(` · ${describePolicy(e.runPolicy)}`)
@@ -65,6 +65,19 @@ import {
65
65
  validateClaudeStorageLaunchEnvironment,
66
66
  } from "../lib/claude-project-auto-memory.js";
67
67
 
68
+ function writeStartupResult(options, failure) {
69
+ if (!["json", "stream-json"].includes(options.outputFormat)) return false;
70
+ process.stdout.write(
71
+ `${JSON.stringify({
72
+ type: "result",
73
+ is_error: true,
74
+ session_id: options.session,
75
+ ...failure,
76
+ })}\n`,
77
+ );
78
+ return true;
79
+ }
80
+
68
81
  /**
69
82
  * Resolve + validate `--add-dir` values into absolute, existing, de-duped
70
83
  * directories. Relative paths resolve against the invocation cwd. When the
@@ -1236,22 +1249,15 @@ export function registerAgentCommand(program, dependencies = {}) {
1236
1249
  }),
1237
1250
  { phase: "before-model" },
1238
1251
  );
1239
- if (!persistence) throw error;
1240
1252
  // Emit after withQuietStdout restores stdout, so a machine client
1241
1253
  // receives the failure even when preparation never reaches a runner.
1242
- if (["json", "stream-json"].includes(options.outputFormat)) {
1243
- process.stdout.write(
1244
- `${JSON.stringify({
1245
- type: "result",
1246
- subtype: "error_persistence",
1247
- is_error: true,
1248
- code: persistence.code,
1249
- error: "Canonical session preparation failed",
1250
- session_id: options.session,
1251
- persistence,
1252
- })}\n`,
1253
- );
1254
- }
1254
+ writeStartupResult(options, {
1255
+ subtype: persistence ? "error_persistence" : "error_startup",
1256
+ code: persistence?.code || "CC_AGENT_SESSION_PREPARATION_FAILED",
1257
+ error: "Canonical session preparation failed",
1258
+ ...(persistence ? { persistence } : {}),
1259
+ });
1260
+ if (!persistence) throw error;
1255
1261
  process.stderr.write(
1256
1262
  `${persistence.code}: canonical session preparation was refused\n`,
1257
1263
  );
@@ -1399,13 +1405,38 @@ export function registerAgentCommand(program, dependencies = {}) {
1399
1405
  // policy-only sandbox choice into repeated Windows ACL initialization;
1400
1406
  // the normal user-facing audit path remains unchanged.
1401
1407
  if (!formalQualityHermetic) {
1402
- appendSecurityAuditEvent("sandbox_mode_off", {
1403
- details: {
1404
- command: "agent",
1405
- permissionMode: options.permissionMode || "default",
1406
- isolation: "policy-only",
1407
- },
1408
- });
1408
+ try {
1409
+ appendSecurityAuditEvent("sandbox_mode_off", {
1410
+ details: {
1411
+ command: "agent",
1412
+ permissionMode: options.permissionMode || "default",
1413
+ isolation: "policy-only",
1414
+ },
1415
+ });
1416
+ } catch (error) {
1417
+ const persistence = projectSessionPersistenceFailure(
1418
+ createSessionPersistenceFailure(error, {
1419
+ sessionId: options.session,
1420
+ operation: "session-start",
1421
+ }),
1422
+ { phase: "before-model" },
1423
+ );
1424
+ if (
1425
+ !persistence ||
1426
+ !writeStartupResult(options, {
1427
+ subtype: "error_persistence",
1428
+ code: persistence.code,
1429
+ error: "Security audit write failed",
1430
+ persistence,
1431
+ })
1432
+ ) {
1433
+ throw error;
1434
+ }
1435
+ process.stderr.write(`Error: ${error.message}\n`);
1436
+ await _finishWorktree();
1437
+ process.exitCode = 6;
1438
+ return;
1439
+ }
1409
1440
  process.stderr.write(
1410
1441
  "Warning: sandbox mode is explicitly off; shell commands use policy checks without OS isolation.\n",
1411
1442
  );
@@ -2187,6 +2218,10 @@ export function registerAgentCommand(program, dependencies = {}) {
2187
2218
  .filter(Boolean)
2188
2219
  .join("\n\n"),
2189
2220
  });
2221
+ if (outcome.exitCode) {
2222
+ await _finishWorktree();
2223
+ process.exit(outcome.exitCode);
2224
+ }
2190
2225
  // The normal stream (init … result) has already been written to
2191
2226
  // stdout by the runner. Append the structured verdict as the final
2192
2227
  // NDJSON line, built from the run's final text.
@@ -50,6 +50,7 @@ export function registerCcronCommand(program) {
50
50
  .requiredOption("--id <id>")
51
51
  .requiredOption("--owner <owner>")
52
52
  .option("--expr <expr>", "cron expression", "0 0 * * *")
53
+ .option("--ends-at <timestamp>", "Retire the profile at this timestamp")
53
54
  .action((o) =>
54
55
  console.log(JSON.stringify(registerCcronProfileV2(o), null, 2)),
55
56
  );
@@ -252,6 +252,10 @@ export function registerLoopCommand(program) {
252
252
  "5m",
253
253
  )
254
254
  .option("-n, --max-iterations <n>", "Stop after N iterations")
255
+ .option(
256
+ "--ends-at <timestamp>",
257
+ "Stop scheduling iterations at this timestamp",
258
+ )
255
259
  .option(
256
260
  "--until-exit-zero",
257
261
  "Stop once an iteration exits with code 0 (e.g. tests pass)",
@@ -382,6 +386,17 @@ export function registerLoopCommand(program) {
382
386
  savedConfig && !fromCli("untilExitZero")
383
387
  ? Boolean(savedConfig.untilExitZero)
384
388
  : Boolean(options.untilExitZero);
389
+ const deadlineInput = fromCli("endsAt")
390
+ ? options.endsAt
391
+ : savedConfig?.endsAt;
392
+ const deadline =
393
+ deadlineInput == null ? null : Date.parse(deadlineInput);
394
+ if (deadline != null && !Number.isFinite(deadline)) {
395
+ throw new Error("--ends-at must be a valid timestamp");
396
+ }
397
+ const endsAt =
398
+ deadline == null ? null : new Date(deadline).toISOString();
399
+ const expiresAction = endsAt == null ? null : "retire";
385
400
  const executionCwd = savedConfig?.cwd || process.cwd();
386
401
 
387
402
  // --- build the child invocation (shared with resume) ---
@@ -409,6 +424,7 @@ export function registerLoopCommand(program) {
409
424
  untilExitZero,
410
425
  until: untilRaw || null,
411
426
  cwd: executionCwd,
427
+ ...(endsAt == null ? {} : { endsAt }),
412
428
  };
413
429
  appendEvent(sessionId, "loop_config", savedConfig);
414
430
  }
@@ -441,7 +457,7 @@ export function registerLoopCommand(program) {
441
457
  intervalMs,
442
458
  )}${maxIterations ? `, max ${maxIterations}` : ""}${
443
459
  startIndex ? `, resuming from ${startIndex}` : ""
444
- }${persist ? `, session ${sessionId}` : ""})`,
460
+ }${endsAt == null ? "" : `, retires at ${endsAt}`}${persist ? `, session ${sessionId}` : ""})`,
445
461
  )}`,
446
462
  ),
447
463
  );
@@ -511,11 +527,25 @@ export function registerLoopCommand(program) {
511
527
  summary = await runLoop({
512
528
  intervalMs,
513
529
  maxIterations,
530
+ endsAt: deadline,
514
531
  untilExitZero,
515
532
  untilRegex,
516
533
  startIndex,
517
534
  sleep: makeSleep(controller.signal),
518
535
  shouldStop: () => controller.signal.aborted,
536
+ onWait: (next) => {
537
+ const nextRunAt = next == null ? null : new Date(next).toJSON();
538
+ if (persist) {
539
+ appendEvent(sessionId, "loop_wait", {
540
+ nextRunAt,
541
+ endsAt,
542
+ expiresAction,
543
+ });
544
+ }
545
+ if (!options.json && nextRunAt != null) {
546
+ logger.log(chalk.gray(` next run at ${nextRunAt}`));
547
+ }
548
+ },
519
549
  onIteration: (n, res) => {
520
550
  const tag =
521
551
  res.exitCode === 0
@@ -567,11 +597,13 @@ export function registerLoopCommand(program) {
567
597
  ? summary.results[summary.results.length - 1].exitCode
568
598
  : null;
569
599
  const stoppedBy = interrupted ? "signal" : summary.stoppedBy;
600
+ const timing = { endsAt, expiresAction, nextRunAt: null };
570
601
 
571
602
  if (persist) {
572
603
  appendEvent(sessionId, "loop_end", {
573
604
  stoppedBy,
574
605
  iterations: summary.iterations,
606
+ ...timing,
575
607
  });
576
608
  }
577
609
 
@@ -583,6 +615,7 @@ export function registerLoopCommand(program) {
583
615
  stoppedBy,
584
616
  lastExitCode: lastExit,
585
617
  elapsed,
618
+ ...timing,
586
619
  ...(persist ? { sessionId } : {}),
587
620
  },
588
621
  null,
@@ -11,6 +11,7 @@ import chalk from "chalk";
11
11
  import ora from "ora";
12
12
  import { logger } from "../lib/logger.js";
13
13
  import { bootstrap, shutdown } from "../runtime/bootstrap.js";
14
+ import { withQuietStdout } from "../runtime/quiet-stdout.js";
14
15
  import {
15
16
  MCPClient,
16
17
  MCPServerConfig,
@@ -28,6 +29,7 @@ import {
28
29
  SUPPORTED_TRANSPORTS,
29
30
  } from "../lib/mcp-scaffold.js";
30
31
  import { parseJsonOption } from "../lib/parse-json-option.js";
32
+ import { normalizeInstallCommandResult } from "../lib/install-command-policy.js";
31
33
  import { resolveMcpAuthTarget, isUrlLike } from "../lib/mcp-auth-target.js";
32
34
  import { notFoundWithSuggestion } from "../lib/suggest-name.js";
33
35
  import { findGitProjectRoot } from "../lib/project-root.cjs";
@@ -1291,7 +1293,8 @@ export function registerMcpCommand(program) {
1291
1293
  );
1292
1294
  }
1293
1295
 
1294
- const ctx = await bootstrap({ verbose: program.opts().verbose });
1296
+ const boot = () => bootstrap({ verbose: program.opts().verbose });
1297
+ const ctx = await (options.json ? withQuietStdout(boot) : boot());
1295
1298
  if (!ctx.db) {
1296
1299
  logger.error("Database not available");
1297
1300
  process.exit(1);
@@ -1471,7 +1474,14 @@ export function registerMcpCommand(program) {
1471
1474
  };
1472
1475
 
1473
1476
  if (options.json) {
1474
- console.log(JSON.stringify(payload));
1477
+ console.log(
1478
+ JSON.stringify({
1479
+ ...payload,
1480
+ ...(options.command
1481
+ ? { installCommand: normalizeInstallCommandResult() }
1482
+ : {}),
1483
+ }),
1484
+ );
1475
1485
  } else {
1476
1486
  logger.success(`MCP server "${chalk.cyan(name)}" configured`);
1477
1487
  if (options.url) {
@@ -1503,7 +1513,7 @@ export function registerMcpCommand(program) {
1503
1513
  }
1504
1514
  }
1505
1515
 
1506
- await shutdown();
1516
+ await (options.json ? withQuietStdout(shutdown) : shutdown());
1507
1517
  } catch (err) {
1508
1518
  logger.error(`Failed: ${err.message}`);
1509
1519
  process.exit(1);
@@ -6,8 +6,8 @@
6
6
  import chalk from "chalk";
7
7
  import fs from "node:fs";
8
8
  import path from "node:path";
9
- import { createHash } from "node:crypto";
10
9
  import { logger } from "../lib/logger.js";
10
+ import { normalizeInstallCommandResult } from "../lib/install-command-policy.js";
11
11
  import {
12
12
  enforcePluginPolicy,
13
13
  loadPluginManagedPolicy,
@@ -40,28 +40,7 @@ function collectRepeatableOption(value, previous = []) {
40
40
  return [...previous, value];
41
41
  }
42
42
 
43
- /** Normalize installer side effects into a stable machine-readable receipt. */
44
- export function normalizeInstallCommandResult(value = null) {
45
- const input = value && typeof value === "object" ? value : {};
46
- const stderr = typeof input.stderr === "string" ? input.stderr : "";
47
- const digest =
48
- typeof input.stderrDigest === "string" && input.stderrDigest
49
- ? input.stderrDigest
50
- : createHash("sha256").update(stderr, "utf8").digest("hex");
51
- const exitCode = Number.isSafeInteger(input.exitCode) ? input.exitCode : null;
52
- const ran = input.ran === true || exitCode !== null || input.started === true;
53
- return {
54
- ran,
55
- exitCode,
56
- timedOut: input.timedOut === true,
57
- signaled: input.signaled === true || input.signal != null,
58
- printedToStderr:
59
- input.printedToStderr === true ||
60
- stderr.length > 0 ||
61
- input.stderrBytes > 0,
62
- stderrDigest: digest,
63
- };
64
- }
43
+ export { normalizeInstallCommandResult };
65
44
 
66
45
  function normalizeRegistryUrls(value) {
67
46
  if (Array.isArray(value)) return value.filter(Boolean);
@@ -2316,13 +2295,13 @@ export function registerPluginCommand(program) {
2316
2295
  }
2317
2296
  }
2318
2297
  logger.error(`Install failed: ${err.message}${recoveryNote}`);
2319
- if (options.json && (err.installCommand || installCommand)) {
2298
+ const receipt =
2299
+ err.installCommand || res?.installCommand || installCommand;
2300
+ if (options.json && receipt) {
2320
2301
  console.log(
2321
2302
  JSON.stringify({
2322
2303
  error: { code: err.code || "CC_PLUGIN_INSTALL_FAILED" },
2323
- installCommand: normalizeInstallCommandResult(
2324
- err.installCommand || installCommand,
2325
- ),
2304
+ installCommand: normalizeInstallCommandResult(receipt),
2326
2305
  }),
2327
2306
  );
2328
2307
  }
@@ -4167,13 +4146,13 @@ export function registerPluginCommand(program) {
4167
4146
  }
4168
4147
  }
4169
4148
  logger.error(`Upgrade failed: ${err.message}${recoveryNote}`);
4170
- if (options.json && (err.installCommand || installCommand)) {
4149
+ const receipt =
4150
+ err.installCommand || res?.installCommand || installCommand;
4151
+ if (options.json && receipt) {
4171
4152
  console.log(
4172
4153
  JSON.stringify({
4173
4154
  error: { code: err.code || "CC_PLUGIN_UPGRADE_FAILED" },
4174
- installCommand: normalizeInstallCommandResult(
4175
- err.installCommand || installCommand,
4176
- ),
4155
+ installCommand: normalizeInstallCommandResult(receipt),
4177
4156
  }),
4178
4157
  );
4179
4158
  }
@@ -49,6 +49,7 @@ import {
49
49
  import { raceWithAbort, throwIfAborted } from "../lib/abort-utils.js";
50
50
  import { getElectronUserDataDir } from "../lib/paths.js";
51
51
  import { findProjectRoot } from "../lib/project-detector.js";
52
+ import { normalizeInstallCommandResult } from "../lib/install-command-policy.js";
52
53
  import { loadConfig } from "../lib/config-manager.js";
53
54
  import { applyConfigLlmDefaults } from "../lib/llm-config-defaults.js";
54
55
  import { BUILT_IN_PROVIDERS } from "../lib/llm-providers.js";
@@ -714,7 +715,21 @@ export function registerSkillCommand(program, dependencies = {}) {
714
715
  "--global",
715
716
  "Create as a global (managed) skill instead of project-level",
716
717
  )
718
+ .option("--json", "Output the scaffold and install command receipt as JSON")
717
719
  .action(async (name, options) => {
720
+ const fail = (message) => {
721
+ if (options.json) {
722
+ console.log(
723
+ JSON.stringify({
724
+ error: { message },
725
+ installCommand: normalizeInstallCommandResult(),
726
+ }),
727
+ );
728
+ } else {
729
+ logger.error(message);
730
+ }
731
+ process.exitCode = 1;
732
+ };
718
733
  let targetDir;
719
734
 
720
735
  if (options.global) {
@@ -723,23 +738,34 @@ export function registerSkillCommand(program, dependencies = {}) {
723
738
  } else {
724
739
  const projectRoot = findProjectRoot();
725
740
  if (!projectRoot) {
726
- logger.error(
741
+ fail(
727
742
  'Not inside a ChainlessChain project. Run "chainlesschain init" first, or use --global.',
728
743
  );
729
- process.exit(1);
744
+ return;
730
745
  }
731
746
  targetDir = path.join(projectRoot, ".chainlesschain", "skills", name);
732
747
  }
733
748
 
734
749
  if (fs.existsSync(targetDir)) {
735
- logger.error(`Skill already exists: ${targetDir}`);
736
- process.exit(1);
750
+ fail(`Skill already exists: ${targetDir}`);
751
+ return;
737
752
  }
738
753
 
739
754
  try {
740
755
  createControlledSkillScaffold(name, targetDir);
741
756
 
742
757
  const scope = options.global ? "global" : "project";
758
+ if (options.json) {
759
+ console.log(
760
+ JSON.stringify({
761
+ name,
762
+ scope,
763
+ targetDir,
764
+ installCommand: normalizeInstallCommandResult(),
765
+ }),
766
+ );
767
+ return;
768
+ }
743
769
  logger.success(`Created ${scope} skill: ${chalk.cyan(name)}`);
744
770
  logger.log(` ${chalk.gray(targetDir)}`);
745
771
  logger.log("");
@@ -755,8 +781,7 @@ export function registerSkillCommand(program, dependencies = {}) {
755
781
  `Edit these files, then run: ${chalk.cyan(`chainlesschain skill run ${name} "test input"`)}`,
756
782
  );
757
783
  } catch (err) {
758
- logger.error(`Failed to create skill: ${err.message}`);
759
- process.exit(1);
784
+ fail(`Failed to create skill: ${err.message}`);
760
785
  }
761
786
  });
762
787
 
@@ -5,7 +5,7 @@ async function readTaskSources({ session, cwd }) {
5
5
  const { listJsonlSessions, resolveSessionAuthority } =
6
6
  await import("../harness/jsonl-session-store.js");
7
7
  const { listMcpTaskRecords } = await import("../lib/mcp-task-journal.js");
8
- const { listBackgroundAgents } =
8
+ const { hasValidBackgroundAgentStopCleanupProof, listBackgroundAgents } =
9
9
  await import("../lib/background-agent-supervisor.js");
10
10
  const { listDynamicWorkflowWorkbenchStates } =
11
11
  await import("../lib/dynamic-workflow-runtime.js");
@@ -29,6 +29,19 @@ async function readTaskSources({ session, cwd }) {
29
29
  return {
30
30
  mcp,
31
31
  agent: listBackgroundAgents({ all: true }).map((agent) => {
32
+ const stopRequestedAt = Number(agent.stopRequestedAt);
33
+ const stopEvents = [];
34
+ if (Number.isFinite(stopRequestedAt) && stopRequestedAt > 0) {
35
+ stopEvents.push({ type: "stop_requested", at: stopRequestedAt });
36
+ }
37
+ const stopConfirmed = hasValidBackgroundAgentStopCleanupProof(agent);
38
+ if (stopConfirmed) {
39
+ stopEvents.push({
40
+ type: "stop_confirmed",
41
+ at: Number(agent.stopCleanupConfirmedAt),
42
+ });
43
+ }
44
+ const orphanRisk = !stopConfirmed && agent.stopPending === true;
32
45
  const waitingOn = agent.pendingQuestion
33
46
  ? "user-input"
34
47
  : agent.lifecycleState === "waitingApproval"
@@ -47,7 +60,12 @@ async function readTaskSources({ session, cwd }) {
47
60
  lastEventAt: agent.endedAt ?? agent.heartbeatAt ?? agent.startedAt,
48
61
  startedAt: agent.startedAt,
49
62
  label: agent.title,
50
- stopPath: agent.status === "running" ? `cc stop ${agent.id}` : null,
63
+ stopPath:
64
+ agent.status === "running" || orphanRisk
65
+ ? `cc agents stop ${agent.id}`
66
+ : null,
67
+ stopEvents,
68
+ orphanRisk,
51
69
  };
52
70
  }),
53
71
  cowork: listDynamicWorkflowWorkbenchStates(cwd ?? process.cwd()).runs.map(
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "source": "CHANGELOG.md",
3
3
  "releases": [
4
+ {
5
+ "productVersion": null,
6
+ "cliVersion": "0.166.163",
7
+ "cliVersions": ["0.166.163"],
8
+ "date": "2026-11-24",
9
+ "title": "",
10
+ "sections": [
11
+ {
12
+ "heading": "Fixed - cc CLI 0.166.163 and IDE pairing (candidate, 2026-11-24)",
13
+ "body": "- Require a nonempty file search pattern and direct coding sessions to paginated reads when inspecting a file without a search term.\n- Preserve OS credential command failures and retry a timed-out Windows DPAPI read once.\n- Ask coding sessions to verify workspace changes against tool receipts before reporting delivery.\n- Let canonical compaction retain a handoff that fits the available conversation budget while enforcing the total context limit.\n- Use a bounded local handoff when a deterministic compaction summary exceeds the context budget, and retain file read positions.\n- Reset the failed file-read delivery streak when the model receives a requested source page.\n- Retire pending approvals on interruption and accept decisions only during their originating turn.\n- Report Chat Completions stream errors in the agent, chat, and token-stream commands and stop the failed response.\n- Pair with Open VSX 0.37.198 and JetBrains 0.4.213 after the exact-source release gates pass."
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "productVersion": null,
19
+ "cliVersion": "0.166.162",
20
+ "cliVersions": ["0.166.162"],
21
+ "date": "2026-11-23",
22
+ "title": "",
23
+ "sections": [
24
+ {
25
+ "heading": "Fixed - cc CLI 0.166.162 and IDE pairing (candidate, 2026-11-23)",
26
+ "body": "- Preserve approved plan permissions across interactive and background resumes. Report headless storage failures and destructive-action denials with nonzero exit codes.\n- Record Git installer outcomes, background stop receipts, and orphan risk. Keep VS Code forks in separate tabs with independent transcripts and side-effect ledgers.\n- Return the shared install command receipt from `cc skill add --json`. Add CLI automation fields and guide links to the public IDE capability manifest.\n- Pair with Open VSX 0.37.197 and JetBrains 0.4.212 after the exact-source release gates pass."
27
+ }
28
+ ]
29
+ },
4
30
  {
5
31
  "productVersion": null,
6
32
  "cliVersion": "0.166.161",