@aiwg/cli 2026.10.15 → 2026.10.16

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 (180) hide show
  1. package/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
  2. package/dist/src/artifacts/citation-parser.js +7 -6
  3. package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
  4. package/dist/src/artifacts/corpus-tools/cli.js +8 -3
  5. package/dist/src/artifacts/corpus-tools/discovery-log.js +26 -24
  6. package/dist/src/artifacts/corpus-tools/expand-cli.js +3 -2
  7. package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
  8. package/dist/src/artifacts/corpus-tools/expand-queue.js +4 -1
  9. package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
  10. package/dist/src/artifacts/corpus-tools/expand-state.js +17 -1
  11. package/dist/src/artifacts/corpus-tools/expand.js +16 -17
  12. package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
  13. package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
  14. package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
  15. package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
  16. package/dist/src/artifacts/corpus-tools/resolve-cli.js +11 -3
  17. package/dist/src/artifacts/corpus-tools/resolve.js +23 -9
  18. package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
  19. package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
  20. package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
  21. package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
  22. package/dist/src/artifacts/graph-query.js +5 -3
  23. package/dist/src/artifacts/hybrid-query.js +11 -2
  24. package/dist/src/artifacts/index-refresh.js +2 -0
  25. package/dist/src/cli/handlers/daemon.js +17 -1
  26. package/dist/src/cli/handlers/doctor-args.js +10 -5
  27. package/dist/src/cli/handlers/doctor-help.js +4 -1
  28. package/dist/src/cli/handlers/index.js +2 -2
  29. package/dist/src/cli/handlers/models-resource-sample.js +10 -0
  30. package/dist/src/cli/handlers/models.js +3 -2
  31. package/dist/src/cli/handlers/regenerate.js +8 -16
  32. package/dist/src/cli/handlers/sessions.js +7 -7
  33. package/dist/src/cli/handlers/subcommands.js +8 -0
  34. package/dist/src/cli/handlers/update.js +157 -0
  35. package/dist/src/cli/handlers/use.js +14 -4
  36. package/dist/src/cli/handlers/utilities.js +3 -560
  37. package/dist/src/cli/handlers/utility-doctor.js +412 -0
  38. package/dist/src/cli/services/deployment-verification.js +0 -1
  39. package/dist/src/config/aiwg-config.js +2 -1
  40. package/dist/src/config/authorization-cli.js +7 -3
  41. package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
  42. package/dist/src/config/dispatch-thresholds-runtime.mjs +17 -7
  43. package/dist/src/config/framework-aliases.js +12 -0
  44. package/dist/src/config/host-resource-report.d.mts +19 -0
  45. package/dist/src/config/host-resource-report.mjs +80 -0
  46. package/dist/src/config/host-resource-runtime.d.mts +34 -0
  47. package/dist/src/config/host-resource-runtime.mjs +293 -0
  48. package/dist/src/config/installed-selection.js +22 -0
  49. package/dist/src/config/worker-invocation-marker.d.mts +1 -0
  50. package/dist/src/config/worker-invocation-marker.mjs +2 -0
  51. package/dist/src/decision/heldout/access.js +74 -0
  52. package/dist/src/decision/heldout/calibration.js +1 -0
  53. package/dist/src/decision/heldout/collector.js +8 -1
  54. package/dist/src/effects/verifiers/file.js +22 -5
  55. package/dist/src/extensions/claude-attribution.js +82 -0
  56. package/dist/src/extensions/claude-hooks-installer.js +115 -69
  57. package/dist/src/extensions/commands/daemon.js +109 -0
  58. package/dist/src/extensions/commands/definitions.js +5 -89
  59. package/dist/src/gates/heldout.js +17 -7
  60. package/dist/src/lint/check-patterns.js +163 -0
  61. package/dist/src/lint/checks.js +268 -0
  62. package/dist/src/lint/reference-resolution.js +54 -0
  63. package/dist/src/lint/runner.js +3 -465
  64. package/dist/src/mcp/helpers.mjs +11 -1
  65. package/dist/src/memory/project-registry.js +44 -4
  66. package/dist/src/models/worker-plan.js +36 -5
  67. package/dist/src/models/wrapper-deployment.js +25 -12
  68. package/dist/src/models/wrapper-enforcement.js +47 -7
  69. package/dist/src/network-analysis/research.js +2 -1
  70. package/dist/src/policy/hitl-check.js +14 -4
  71. package/dist/src/policy/hitl-consume.js +54 -0
  72. package/dist/src/policy/hitl-receipt.js +2 -0
  73. package/dist/src/policy/hitl.js +11 -3
  74. package/dist/src/providers/provider-context-contracts.js +162 -0
  75. package/dist/src/providers/provider-definition-schema.js +136 -0
  76. package/dist/src/providers/provider-definitions.js +8 -1298
  77. package/dist/src/providers/provider-seeds-1.js +360 -0
  78. package/dist/src/providers/provider-seeds-2.js +387 -0
  79. package/dist/src/providers/provider-seeds-3.js +262 -0
  80. package/dist/src/research/clients/arxiv.js +4 -30
  81. package/dist/src/research/clients/base.js +48 -22
  82. package/dist/src/research/identity.js +34 -2
  83. package/dist/src/research/query-cli.js +3 -87
  84. package/dist/src/research/query-options.js +87 -0
  85. package/dist/src/research/reference-match.js +70 -24
  86. package/dist/src/research/services/acquisition.js +9 -7
  87. package/dist/src/research/services/citation.js +5 -2
  88. package/dist/src/research/types.js +2 -0
  89. package/dist/src/serve/mission-conductor.js +48 -4
  90. package/dist/src/sessions/adapters/grok-build-native.js +23 -0
  91. package/dist/src/sessions/adapters/grok-build.js +14 -7
  92. package/dist/src/sessions/workspace-discovery.js +5 -5
  93. package/dist/src/smiths/context-pipeline/aiwg-md.js +16 -46
  94. package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
  95. package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
  96. package/dist/src/smiths/context-pipeline/finalization.js +81 -51
  97. package/dist/src/smiths/context-pipeline/generator.js +9 -10
  98. package/dist/src/smiths/context-pipeline/managed-hook.js +1 -1
  99. package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
  100. package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
  101. package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
  102. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
  103. package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
  104. package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
  105. package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
  106. package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
  107. package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
  108. package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
  109. package/package.json +10 -1
  110. package/schemas/decision/D29Study.v10.schema.json +65 -0
  111. package/tools/agents/deploy-agents.mjs +10 -0
  112. package/tools/agents/providers/claude-post-deploy.mjs +12 -1
  113. package/tools/agents/providers/context-write.mjs +4 -0
  114. package/tools/agents/providers/pi.mjs +3 -1
  115. package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
  116. package/tools/agents/providers/rule-delivery.mjs +20 -1144
  117. package/tools/agents/providers/rule-deployment-commit.mjs +144 -0
  118. package/tools/agents/providers/rule-deployment-prepare.mjs +452 -0
  119. package/tools/agents/providers/rule-deployment-state.mjs +300 -0
  120. package/tools/daemon/README.md +511 -0
  121. package/tools/daemon/adapters/base-adapter.mjs +84 -0
  122. package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
  123. package/tools/daemon/agent-supervisor.mjs +299 -0
  124. package/tools/daemon/automation-engine.mjs +310 -0
  125. package/tools/daemon/autonomous-engine.mjs +346 -0
  126. package/tools/daemon/behavior-loader.mjs +316 -0
  127. package/tools/daemon/behavior.mjs +174 -0
  128. package/tools/daemon/concierge/intent-router.mjs +401 -0
  129. package/tools/daemon/concierge/orchestrator.mjs +272 -0
  130. package/tools/daemon/concierge/response-translator.mjs +462 -0
  131. package/tools/daemon/config.mjs +377 -0
  132. package/tools/daemon/cron-scheduler.mjs +178 -0
  133. package/tools/daemon/daemon-main.mjs +1169 -0
  134. package/tools/daemon/event-router.mjs +84 -0
  135. package/tools/daemon/file-watcher.mjs +383 -0
  136. package/tools/daemon/index.mjs +1181 -0
  137. package/tools/daemon/init-profile.mjs +124 -0
  138. package/tools/daemon/ipc-client.mjs +197 -0
  139. package/tools/daemon/ipc-ops-handlers.mjs +236 -0
  140. package/tools/daemon/ipc-server.mjs +275 -0
  141. package/tools/daemon/maintenance-owner.mjs +79 -0
  142. package/tools/daemon/memory-manager.mjs +386 -0
  143. package/tools/daemon/message-router.mjs +194 -0
  144. package/tools/daemon/provider-watcher.mjs +585 -0
  145. package/tools/daemon/pty-adapter.mjs +420 -0
  146. package/tools/daemon/repl-chat.mjs +359 -0
  147. package/tools/daemon/resource-bounds.mjs +88 -0
  148. package/tools/daemon/sandbox-transport.mjs +295 -0
  149. package/tools/daemon/scheduled-task-runner.mjs +535 -0
  150. package/tools/daemon/task-store.mjs +450 -0
  151. package/tools/daemon/tmux-manager.mjs +324 -0
  152. package/tools/daemon/update-policy.mjs +517 -0
  153. package/tools/daemon/web-server.mjs +399 -0
  154. package/tools/daemon/web-ui/index.html +585 -0
  155. package/tools/daemon/web-ui/styles.css +156 -0
  156. package/tools/docker/Dockerfile.daemon +35 -0
  157. package/tools/docker/container-manager.mjs +291 -0
  158. package/tools/messaging/adapter-registry.mjs +230 -0
  159. package/tools/messaging/adapters/base.mjs +326 -0
  160. package/tools/messaging/adapters/discord.mjs +462 -0
  161. package/tools/messaging/adapters/slack.mjs +402 -0
  162. package/tools/messaging/adapters/telegram.mjs +552 -0
  163. package/tools/messaging/chat-handler.mjs +297 -0
  164. package/tools/messaging/command-router.mjs +269 -0
  165. package/tools/messaging/event-bus.mjs +199 -0
  166. package/tools/messaging/index.mjs +456 -0
  167. package/tools/messaging/message-formatter.mjs +320 -0
  168. package/tools/messaging/room-manager.mjs +277 -0
  169. package/tools/messaging/types.mjs +94 -0
  170. package/tools/providers/pi-bridge-policy.mjs +4 -0
  171. package/tools/ralph-external/daemon-supervisor.mjs +394 -0
  172. package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
  173. package/tools/ralph-external/lib/worker-invocation-processes.mjs +3 -2
  174. package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
  175. package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
  176. package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
  177. package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
  178. package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
  179. package/tools/ralph-external/session-launcher.mjs +7 -7
  180. package/tools/scripts/resource-preflight.mjs +3 -242
@@ -28,6 +28,7 @@
28
28
  */
29
29
  import { promises as fs } from 'node:fs';
30
30
  import * as path from 'node:path';
31
+ import { mergeClaudeAttribution, undoClaudeAttribution } from './claude-attribution.js';
31
32
  /**
32
33
  * Hook script → Claude Code hook event mapping.
33
34
  *
@@ -113,7 +114,7 @@ export async function installAiwgHooks(opts) {
113
114
  const sourceHooksDir = path.join(opts.frameworkRoot, 'agentic', 'code', 'addons', 'aiwg-hooks', 'hooks');
114
115
  let sourceFiles;
115
116
  try {
116
- sourceFiles = await fs.readdir(sourceHooksDir);
117
+ sourceFiles = opts.hooks === false ? [] : await fs.readdir(sourceHooksDir);
117
118
  }
118
119
  catch (err) {
119
120
  if (err.code === 'ENOENT')
@@ -128,10 +129,10 @@ export async function installAiwgHooks(opts) {
128
129
  };
129
130
  // 1. Copy hook scripts to .claude/hooks/
130
131
  const claudeHooksDir = path.join(opts.projectPath, '.claude', 'hooks');
131
- if (!opts.dryRun) {
132
+ if (!opts.dryRun && opts.hooks !== false) {
132
133
  await fs.mkdir(claudeHooksDir, { recursive: true });
133
134
  }
134
- for (const { file } of HOOK_SCRIPTS) {
135
+ for (const { file } of opts.hooks === false ? [] : HOOK_SCRIPTS) {
135
136
  if (!sourceFiles.includes(file)) {
136
137
  result.warnings.push(`hook script not found in addon source: ${file}`);
137
138
  continue;
@@ -177,76 +178,80 @@ export async function installAiwgHooks(opts) {
177
178
  }
178
179
  }
179
180
  catch (err) {
180
- result.warnings.push(`Backup failed: ${err instanceof Error ? err.message : String(err)}`);
181
+ throw new Error(`Backup failed; settings.json was not changed: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
181
182
  }
182
183
  }
183
- // 4. Normalize (migrate legacy array shape → object shape) and merge
184
- const [hooksObj, migrated] = normalizeHooks(settings.hooks);
185
- if (migrated) {
186
- result.migratedFromLegacy = true;
187
- result.warnings.push('Migrated legacy array-shaped hooks field to object form (#107).');
188
- }
189
- settings.hooks = hooksObj;
190
- for (const { file, events } of HOOK_SCRIPTS) {
191
- if (!sourceFiles.includes(file))
192
- continue;
193
- // Claude Code parses hook commands as shell command strings. Keep the
194
- // embedded script path POSIX-style on every host: native Windows
195
- // backslashes are interpreted as escapes and collapse into a nonexistent
196
- // path such as `.claudehooksaiwg-session.cjs` (#133).
197
- const script = path.posix.join('.claude', 'hooks', file);
198
- const hookId = file.replace(/\.(cjs|js)$/, '');
199
- for (const [event, argument] of Object.entries(events)) {
200
- const command = `node ${script}${argument ? ` ${argument}` : ''}`;
201
- if (!hooksObj[event])
202
- hooksObj[event] = [];
203
- const groups = hooksObj[event];
204
- // Find any existing AIWG-managed entry for this hookId and refresh
205
- // its `command` to the current script path/extension. Required for
206
- // users upgrading from pre-`.cjs` installs where the registered
207
- // command still references `aiwg-{session,trace,permissions}.js` —
208
- // those files no longer exist on disk after refresh, causing
209
- // `MODULE_NOT_FOUND` at `node:internal/modules/cjs/loader` on every
210
- // hook invocation. (Fixes regression report on Claude Code 2.1.157.)
211
- // Match by `_aiwg_id` first, then by the script path. An entry invoking an
212
- // AIWG-owned hook script without the managed tag is AIWG residue from an
213
- // earlier install; appending a managed entry beside it registers the hook
214
- // twice and runs it twice per event. Adopt it instead. (#2543)
215
- let updated = false;
216
- for (const group of groups) {
217
- if (!Array.isArray(group.hooks))
218
- continue;
219
- for (const h of group.hooks) {
220
- const sameId = h._aiwg_id === hookId;
221
- const sameScript = typeof h.command === 'string' && h.command.includes(script);
222
- if (!sameId && !sameScript)
184
+ if (opts.attribution !== false)
185
+ mergeClaudeAttribution(settings, result.warnings);
186
+ if (opts.hooks !== false) {
187
+ // 4. Normalize (migrate legacy array shape → object shape) and merge
188
+ const [hooksObj, migrated] = normalizeHooks(settings.hooks);
189
+ if (migrated) {
190
+ result.migratedFromLegacy = true;
191
+ result.warnings.push('Migrated legacy array-shaped hooks field to object form (#107).');
192
+ }
193
+ settings.hooks = hooksObj;
194
+ for (const { file, events } of HOOK_SCRIPTS) {
195
+ if (!sourceFiles.includes(file))
196
+ continue;
197
+ // Claude Code parses hook commands as shell command strings. Keep the
198
+ // embedded script path POSIX-style on every host: native Windows
199
+ // backslashes are interpreted as escapes and collapse into a nonexistent
200
+ // path such as `.claudehooksaiwg-session.cjs` (#133).
201
+ const script = path.posix.join('.claude', 'hooks', file);
202
+ const hookId = file.replace(/\.(cjs|js)$/, '');
203
+ for (const [event, argument] of Object.entries(events)) {
204
+ const command = `node ${script}${argument ? ` ${argument}` : ''}`;
205
+ if (!hooksObj[event])
206
+ hooksObj[event] = [];
207
+ const groups = hooksObj[event];
208
+ // Find any existing AIWG-managed entry for this hookId and refresh
209
+ // its `command` to the current script path/extension. Required for
210
+ // users upgrading from pre-`.cjs` installs where the registered
211
+ // command still references `aiwg-{session,trace,permissions}.js` —
212
+ // those files no longer exist on disk after refresh, causing
213
+ // `MODULE_NOT_FOUND` at `node:internal/modules/cjs/loader` on every
214
+ // hook invocation. (Fixes regression report on Claude Code 2.1.157.)
215
+ // Match by `_aiwg_id` first, then by the script path. An entry invoking an
216
+ // AIWG-owned hook script without the managed tag is AIWG residue from an
217
+ // earlier install; appending a managed entry beside it registers the hook
218
+ // twice and runs it twice per event. Adopt it instead. (#2543)
219
+ let updated = false;
220
+ for (const group of groups) {
221
+ if (!Array.isArray(group.hooks))
223
222
  continue;
224
- const adopting = !sameId && sameScript;
225
- if (h.command !== command || h.type !== 'command' || h._aiwg_managed !== true || h._aiwg_id !== hookId) {
226
- h.type = 'command';
227
- h.command = command;
228
- h._aiwg_managed = true;
229
- h._aiwg_id = hookId;
230
- result.warnings.push(adopting
231
- ? `Adopted pre-existing untagged ${event} → ${hookId} entry instead of registering a duplicate`
232
- : `Refreshed stale ${event} → ${hookId} command path`);
223
+ for (const h of group.hooks) {
224
+ const sameId = h._aiwg_id === hookId;
225
+ const sameScript = typeof h.command === 'string' && h.command.includes(script);
226
+ if (!sameId && !sameScript)
227
+ continue;
228
+ const adopting = !sameId && sameScript;
229
+ if (h.command !== command || h.type !== 'command' || h._aiwg_managed !== true || h._aiwg_id !== hookId) {
230
+ h.type = 'command';
231
+ h.command = command;
232
+ h._aiwg_managed = true;
233
+ h._aiwg_id = hookId;
234
+ result.warnings.push(adopting
235
+ ? `Adopted pre-existing untagged ${event} → ${hookId} entry instead of registering a duplicate`
236
+ : `Refreshed stale ${event} → ${hookId} command path`);
237
+ }
238
+ updated = true;
233
239
  }
234
- updated = true;
235
240
  }
241
+ if (updated)
242
+ continue;
243
+ groups.push({
244
+ hooks: [
245
+ {
246
+ type: 'command',
247
+ command,
248
+ _aiwg_managed: true,
249
+ _aiwg_id: hookId,
250
+ },
251
+ ],
252
+ });
253
+ result.registeredEvents.push(`${event} → ${hookId}`);
236
254
  }
237
- if (updated)
238
- continue;
239
- groups.push({
240
- hooks: [
241
- {
242
- type: 'command',
243
- command,
244
- _aiwg_managed: true,
245
- _aiwg_id: hookId,
246
- },
247
- ],
248
- });
249
- result.registeredEvents.push(`${event} → ${hookId}`);
250
255
  }
251
256
  }
252
257
  // 5. Atomic write
@@ -278,11 +283,52 @@ export async function restoreSettingsBackup(projectPath) {
278
283
  const backups = entries
279
284
  .filter((e) => e.startsWith('settings.json.bak.'))
280
285
  .sort();
281
- if (backups.length === 0)
286
+ if (backups.length === 0) {
287
+ await removeClaudeAttribution(projectPath);
282
288
  return null;
289
+ }
283
290
  const latest = backups[backups.length - 1];
284
291
  const src = path.join(claudeDir, latest);
285
- await fs.copyFile(src, settingsPath);
292
+ const restored = JSON.parse(await fs.readFile(src, 'utf8'));
293
+ const currentRaw = await fs.readFile(settingsPath, 'utf8').catch((err) => {
294
+ if (err.code === 'ENOENT')
295
+ return null;
296
+ throw err;
297
+ });
298
+ // Attribution rollback is ownership-based; keep later operator edits.
299
+ if (currentRaw !== null) {
300
+ let current;
301
+ try {
302
+ current = JSON.parse(currentRaw);
303
+ }
304
+ catch { /* A corrupt current file must still be recoverable from backup. */ }
305
+ if (current && typeof current === 'object' && !Array.isArray(current)) {
306
+ undoClaudeAttribution(current);
307
+ if ('attribution' in current)
308
+ restored.attribution = current.attribution;
309
+ else
310
+ delete restored.attribution;
311
+ }
312
+ }
313
+ if (restored.aiwg)
314
+ delete restored.aiwg.attributionKeys;
315
+ await atomicWrite(settingsPath, JSON.stringify(restored, null, 2) + '\n');
286
316
  return src;
287
317
  }
318
+ /** Remove only unchanged attribution defaults owned by AIWG. */
319
+ export async function removeClaudeAttribution(projectPath, dryRun = false) {
320
+ const file = path.join(projectPath, '.claude', 'settings.json');
321
+ let settings;
322
+ try {
323
+ settings = JSON.parse(await fs.readFile(file, 'utf8'));
324
+ }
325
+ catch (err) {
326
+ if (err.code === 'ENOENT')
327
+ return;
328
+ throw err;
329
+ }
330
+ if (undoClaudeAttribution(settings) && !dryRun) {
331
+ await atomicWrite(file, JSON.stringify(settings, null, 2) + '\n');
332
+ }
333
+ }
288
334
  //# sourceMappingURL=claude-hooks-installer.js.map
@@ -0,0 +1,109 @@
1
+ export const daemonCommand = {
2
+ id: 'daemon',
3
+ type: 'skill',
4
+ name: 'Daemon',
5
+ description: 'Manage the daemon: start, stop, status, chat, attach and scheduled tasks',
6
+ version: '1.0.0',
7
+ capabilities: ['cli', 'daemon', 'lifecycle'],
8
+ keywords: ['daemon', 'start', 'stop', 'status', 'chat', 'attach'],
9
+ category: 'daemon',
10
+ platforms: { claude: 'full', generic: 'full' },
11
+ deployment: { pathTemplate: '.{platform}/commands/{id}.md', core: false },
12
+ metadata: {
13
+ type: 'skill',
14
+ triggerPhrases: ['daemon', 'daemon start', 'daemon status'],
15
+ commandHint: {
16
+ template: 'utility',
17
+ argumentHint: '<start|stop|status|restart|logs|chat|attach|task|init|rooms|autonomous|schedule|memory|pty> [options]',
18
+ allowedTools: ['Bash', 'Read', 'Write'],
19
+ },
20
+ },
21
+ };
22
+ export const behaviorCommand = {
23
+ id: 'behavior',
24
+ type: 'skill',
25
+ name: 'Behavior',
26
+ description: 'Manage behavior YAML bundles that bind directives and toolsets to agent types',
27
+ version: '1.0.0',
28
+ capabilities: ['cli', 'behavior', 'daemon', 'configuration'],
29
+ keywords: ['behavior', 'directive', 'toolset', 'daemon', 'ops', 'agent-type'],
30
+ category: 'daemon',
31
+ platforms: {
32
+ claude: 'full',
33
+ generic: 'full',
34
+ },
35
+ deployment: {
36
+ pathTemplate: '.{platform}/commands/{id}.md',
37
+ core: false,
38
+ },
39
+ metadata: {
40
+ type: 'skill',
41
+ triggerPhrases: ['behavior', 'list behaviors', 'apply behavior', 'manage behaviors'],
42
+ commandHint: {
43
+ template: 'utility',
44
+ argumentHint: '<list|info|apply|remove> [name] [--to <agent>] [--from <agent>]',
45
+ allowedTools: ['Read', 'Bash', 'Write'],
46
+ },
47
+ },
48
+ };
49
+ export const daemonInitCommand = {
50
+ id: 'daemon-init',
51
+ type: 'skill',
52
+ name: 'Daemon Init',
53
+ description: 'Initialize daemon config from a profile template (default: manager)',
54
+ version: '1.0.0',
55
+ capabilities: ['cli', 'daemon', 'configuration', 'scaffolding'],
56
+ keywords: ['daemon', 'init', 'profile', 'manager', 'orchestrator', 'config'],
57
+ category: 'daemon',
58
+ platforms: {
59
+ claude: 'full',
60
+ generic: 'full',
61
+ },
62
+ deployment: {
63
+ pathTemplate: '.{platform}/commands/{id}.md',
64
+ core: false,
65
+ },
66
+ metadata: {
67
+ type: 'skill',
68
+ triggerPhrases: ['daemon init', 'init daemon', 'initialize daemon', 'daemon setup'],
69
+ commandHint: {
70
+ template: 'utility',
71
+ argumentHint: '[profile-name] [--force]',
72
+ allowedTools: ['Bash', 'Read', 'Write'],
73
+ },
74
+ },
75
+ };
76
+ export const housekeeperCommand = {
77
+ id: 'housekeeper',
78
+ type: 'skill',
79
+ name: 'Housekeeper',
80
+ description: 'Deterministic maintenance daemon: start/stop/status/run-once, jobs, watch roots, autostart units',
81
+ version: '1.0.0',
82
+ capabilities: ['cli', 'daemon', 'maintenance', 'scheduler'],
83
+ keywords: ['housekeeper', 'daemon', 'maintenance', 'schedule', 'run-once', 'autostart'],
84
+ category: 'daemon',
85
+ platforms: {
86
+ claude: 'full',
87
+ generic: 'full',
88
+ },
89
+ deployment: {
90
+ pathTemplate: '.{platform}/commands/{id}.md',
91
+ core: false,
92
+ },
93
+ metadata: {
94
+ type: 'skill',
95
+ triggerPhrases: ['housekeeper', 'housekeeper status', 'housekeeper start', 'maintenance daemon'],
96
+ commandHint: {
97
+ template: 'utility',
98
+ argumentHint: '<start|stop|status|run-once|job|watch|install|uninstall> [options]',
99
+ allowedTools: ['Bash', 'Read', 'Write'],
100
+ executionSteps: [
101
+ 'Parse subcommand and flags',
102
+ 'Start/stop/query the housekeeper-profile daemon or edit its config',
103
+ 'Run one job without a daemon (run-once) or write autostart units (install)',
104
+ 'Display result',
105
+ ],
106
+ },
107
+ },
108
+ };
109
+ //# sourceMappingURL=daemon.js.map
@@ -10,6 +10,8 @@
10
10
  * @tests @test/unit/extensions/commands/definitions.test.ts
11
11
  * @issue #42
12
12
  */
13
+ import { daemonCommand, behaviorCommand, daemonInitCommand, housekeeperCommand } from './daemon.js';
14
+ export { daemonCommand, behaviorCommand, daemonInitCommand, housekeeperCommand } from './daemon.js';
13
15
  // ============================================
14
16
  // Individual Command Definitions
15
17
  // ============================================
@@ -3124,93 +3126,6 @@ export const reproducibilityValidateCommand = {
3124
3126
  },
3125
3127
  },
3126
3128
  };
3127
- export const behaviorCommand = {
3128
- id: 'behavior',
3129
- type: 'skill',
3130
- name: 'Behavior',
3131
- description: 'Manage behavior YAML bundles that bind directives and toolsets to agent types',
3132
- version: '1.0.0',
3133
- capabilities: ['cli', 'behavior', 'daemon', 'configuration'],
3134
- keywords: ['behavior', 'directive', 'toolset', 'daemon', 'ops', 'agent-type'],
3135
- category: 'daemon',
3136
- platforms: {
3137
- claude: 'full',
3138
- generic: 'full',
3139
- },
3140
- deployment: {
3141
- pathTemplate: '.{platform}/commands/{id}.md',
3142
- core: false,
3143
- },
3144
- metadata: {
3145
- type: 'skill',
3146
- triggerPhrases: ['behavior', 'list behaviors', 'apply behavior', 'manage behaviors'],
3147
- commandHint: {
3148
- template: 'utility',
3149
- argumentHint: '<list|info|apply|remove> [name] [--to <agent>] [--from <agent>]',
3150
- allowedTools: ['Read', 'Bash', 'Write'],
3151
- },
3152
- },
3153
- };
3154
- export const daemonInitCommand = {
3155
- id: 'daemon-init',
3156
- type: 'skill',
3157
- name: 'Daemon Init',
3158
- description: 'Initialize daemon config from a profile template (default: manager)',
3159
- version: '1.0.0',
3160
- capabilities: ['cli', 'daemon', 'configuration', 'scaffolding'],
3161
- keywords: ['daemon', 'init', 'profile', 'manager', 'orchestrator', 'config'],
3162
- category: 'daemon',
3163
- platforms: {
3164
- claude: 'full',
3165
- generic: 'full',
3166
- },
3167
- deployment: {
3168
- pathTemplate: '.{platform}/commands/{id}.md',
3169
- core: false,
3170
- },
3171
- metadata: {
3172
- type: 'skill',
3173
- triggerPhrases: ['daemon init', 'init daemon', 'initialize daemon', 'daemon setup'],
3174
- commandHint: {
3175
- template: 'utility',
3176
- argumentHint: '[profile-name] [--force]',
3177
- allowedTools: ['Bash', 'Read', 'Write'],
3178
- },
3179
- },
3180
- };
3181
- export const housekeeperCommand = {
3182
- id: 'housekeeper',
3183
- type: 'skill',
3184
- name: 'Housekeeper',
3185
- description: 'Deterministic maintenance daemon: start/stop/status/run-once, jobs, watch roots, autostart units',
3186
- version: '1.0.0',
3187
- capabilities: ['cli', 'daemon', 'maintenance', 'scheduler'],
3188
- keywords: ['housekeeper', 'daemon', 'maintenance', 'schedule', 'run-once', 'autostart'],
3189
- category: 'daemon',
3190
- platforms: {
3191
- claude: 'full',
3192
- generic: 'full',
3193
- },
3194
- deployment: {
3195
- pathTemplate: '.{platform}/commands/{id}.md',
3196
- core: false,
3197
- },
3198
- metadata: {
3199
- type: 'skill',
3200
- triggerPhrases: ['housekeeper', 'housekeeper status', 'housekeeper start', 'maintenance daemon'],
3201
- commandHint: {
3202
- template: 'utility',
3203
- argumentHint: '<start|stop|status|run-once|job|watch|install|uninstall> [options]',
3204
- allowedTools: ['Bash', 'Read', 'Write'],
3205
- executionSteps: [
3206
- 'Parse subcommand and flags',
3207
- 'Start/stop/query the housekeeper-profile daemon or edit its config',
3208
- 'Run one job without a daemon (run-once) or write autostart units (install)',
3209
- 'Display result',
3210
- ],
3211
- },
3212
- },
3213
- };
3214
3129
  // Config Commands
3215
3130
  export const configCommand = {
3216
3131
  id: 'config',
@@ -3794,7 +3709,7 @@ export const rlmCacheCommand = {
3794
3709
  * - SDLC Orchestration (1): sdlc-accelerate
3795
3710
  * - Index (1): index
3796
3711
  * - Reproducibility (4): execution-mode, snapshot, checkpoint, reproducibility-validate
3797
- * - Daemon (3): behavior, daemon-init, housekeeper
3712
+ * - Daemon (4): daemon, behavior, daemon-init, housekeeper
3798
3713
  * - Config (1): config
3799
3714
  * - Ops (1): ops
3800
3715
  * - Agentic Tools (5): chunk, fanout, rlm-prep, rlm-search, rlm-status
@@ -3925,7 +3840,8 @@ export const commandDefinitions = [
3925
3840
  snapshotCommand,
3926
3841
  checkpointCommand,
3927
3842
  reproducibilityValidateCommand,
3928
- // Daemon (3)
3843
+ // Daemon (4)
3844
+ daemonCommand,
3929
3845
  behaviorCommand,
3930
3846
  daemonInitCommand,
3931
3847
  housekeeperCommand,
@@ -1,19 +1,19 @@
1
1
  // Verify the frozen bundle, its pinned analysis and the independently anchored first-access record.
2
2
  import { heldoutDigest } from '../decision/heldout/contract.js';
3
3
  import { artifactDigest } from '../decision/validate.js';
4
+ import { verifyHeldoutAccess } from '../decision/heldout/access.js';
4
5
  import { evaluateGates, GateEvaluationError, sealGateHoldout } from './evaluate.js';
5
6
  /**
6
7
  * Derive gate inputs from HeldoutFrozen without altering its historical bytes.
7
8
  * The existing bundle contains only corpus, preregistration and approval, so
8
9
  * its studyAnalysisDigest must first verify the supplied analysis containing
9
10
  * the binding. The access record pins that same analysis (and hence binding).
10
- * Its timestamp is covered by the independently trusted access digest.
11
- * Neither an unkeyed digest nor the access record alone authenticates a clock:
12
- * D29 access/v1 has no signature or frozen-bundle digest. The host must retain
13
- * the access anchor independently, just as for the existing D29 scorer.
11
+ * Its signed body covers both digests, run ID and first-access time. The host
12
+ * selects the keyring independently; the retained access digest is an extra
13
+ * integrity check, never a substitute for signature verification.
14
14
  */
15
15
  export function sealGateHoldoutFromFrozen(input) {
16
- const { frozen, analysis, access, trustedAccessDigest } = input;
16
+ const { frozen, analysis, access, trustedAccessDigest, keyring } = input;
17
17
  if (!frozen?.bundle || frozen.digest !== heldoutDigest(frozen.bundle)) {
18
18
  throw new GateEvaluationError('frozen bundle digest does not match its content');
19
19
  }
@@ -25,11 +25,21 @@ export function sealGateHoldoutFromFrozen(input) {
25
25
  || heldoutDigest(access) !== trustedAccessDigest) {
26
26
  throw new GateEvaluationError('first-access digest does not match its trusted pin');
27
27
  }
28
+ if (!access.signature)
29
+ throw new GateEvaluationError('first-access signature missing');
28
30
  if (access.analysisDigest !== analysisDigest) {
29
31
  throw new GateEvaluationError('first-access record does not belong to the frozen analysis and binding');
30
32
  }
31
- if (typeof access.firstTestAccessAt !== 'string' || !Number.isFinite(Date.parse(access.firstTestAccessAt))) {
32
- throw new GateEvaluationError('first-access timestamp is not a valid date-time');
33
+ if (access.frozenBundleDigest !== frozen.digest) {
34
+ throw new GateEvaluationError('first-access frozen-bundle digest does not match the frozen record');
35
+ }
36
+ if (access.runId !== frozen.bundle.approval.runId)
37
+ throw new GateEvaluationError('first-access run ID does not match the frozen approval');
38
+ try {
39
+ verifyHeldoutAccess(access, keyring);
40
+ }
41
+ catch (error) {
42
+ throw new GateEvaluationError(error.message);
33
43
  }
34
44
  const trustedBindingDigest = artifactDigest(analysis.gateBinding);
35
45
  return { trustedBindingDigest,