open-multi-agent-kit 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +41 -9
  3. package/dist/cli/args.d.ts +2 -3
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +13 -189
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/help.d.ts +3 -0
  8. package/dist/cli/help.d.ts.map +1 -0
  9. package/dist/cli/help.js +194 -0
  10. package/dist/cli/help.js.map +1 -0
  11. package/dist/cli/initial-message.d.ts.map +1 -1
  12. package/dist/cli/initial-message.js +2 -1
  13. package/dist/cli/initial-message.js.map +1 -1
  14. package/dist/cli/resource-paths.d.ts +4 -0
  15. package/dist/cli/resource-paths.d.ts.map +1 -0
  16. package/dist/cli/resource-paths.js +59 -0
  17. package/dist/cli/resource-paths.js.map +1 -0
  18. package/dist/commands/adaptorch-doctor-cli.d.ts +13 -0
  19. package/dist/commands/adaptorch-doctor-cli.d.ts.map +1 -0
  20. package/dist/commands/adaptorch-doctor-cli.js +115 -0
  21. package/dist/commands/adaptorch-doctor-cli.js.map +1 -0
  22. package/dist/commands/resource-doctor-cli.d.ts +4 -0
  23. package/dist/commands/resource-doctor-cli.d.ts.map +1 -1
  24. package/dist/commands/resource-doctor-cli.js +35 -5
  25. package/dist/commands/resource-doctor-cli.js.map +1 -1
  26. package/dist/core/adaptorch-bridge.d.ts +11 -13
  27. package/dist/core/adaptorch-bridge.d.ts.map +1 -1
  28. package/dist/core/adaptorch-bridge.js +11 -13
  29. package/dist/core/adaptorch-bridge.js.map +1 -1
  30. package/dist/core/agent-session-snapshot.d.ts +16 -0
  31. package/dist/core/agent-session-snapshot.d.ts.map +1 -0
  32. package/dist/core/agent-session-snapshot.js +111 -0
  33. package/dist/core/agent-session-snapshot.js.map +1 -0
  34. package/dist/core/agent-session.d.ts +5 -9
  35. package/dist/core/agent-session.d.ts.map +1 -1
  36. package/dist/core/agent-session.js +27 -219
  37. package/dist/core/agent-session.js.map +1 -1
  38. package/dist/core/agent-tool-settings.d.ts +10 -0
  39. package/dist/core/agent-tool-settings.d.ts.map +1 -1
  40. package/dist/core/agent-tool-settings.js +10 -1
  41. package/dist/core/agent-tool-settings.js.map +1 -1
  42. package/dist/core/compaction/compaction.d.ts +7 -0
  43. package/dist/core/compaction/compaction.d.ts.map +1 -1
  44. package/dist/core/compaction/compaction.js +25 -61
  45. package/dist/core/compaction/compaction.js.map +1 -1
  46. package/dist/core/compaction/index.d.ts +1 -0
  47. package/dist/core/compaction/index.d.ts.map +1 -1
  48. package/dist/core/compaction/index.js +1 -0
  49. package/dist/core/compaction/index.js.map +1 -1
  50. package/dist/core/compaction/knowledge-triage-format.d.ts +9 -0
  51. package/dist/core/compaction/knowledge-triage-format.d.ts.map +1 -0
  52. package/dist/core/compaction/knowledge-triage-format.js +71 -0
  53. package/dist/core/compaction/knowledge-triage-format.js.map +1 -0
  54. package/dist/core/compaction/knowledge-triage-types.d.ts +7 -0
  55. package/dist/core/compaction/knowledge-triage-types.d.ts.map +1 -0
  56. package/dist/core/compaction/knowledge-triage-types.js +2 -0
  57. package/dist/core/compaction/knowledge-triage-types.js.map +1 -0
  58. package/dist/core/compaction/knowledge-triage.d.ts +29 -0
  59. package/dist/core/compaction/knowledge-triage.d.ts.map +1 -0
  60. package/dist/core/compaction/knowledge-triage.js +189 -0
  61. package/dist/core/compaction/knowledge-triage.js.map +1 -0
  62. package/dist/core/compaction/transaction.d.ts.map +1 -1
  63. package/dist/core/compaction/transaction.js +1 -1
  64. package/dist/core/compaction/transaction.js.map +1 -1
  65. package/dist/core/compaction/utils.d.ts +4 -0
  66. package/dist/core/compaction/utils.d.ts.map +1 -1
  67. package/dist/core/compaction/utils.js +37 -0
  68. package/dist/core/compaction/utils.js.map +1 -1
  69. package/dist/core/completion-sound-io.d.ts +14 -0
  70. package/dist/core/completion-sound-io.d.ts.map +1 -0
  71. package/dist/core/completion-sound-io.js +64 -0
  72. package/dist/core/completion-sound-io.js.map +1 -0
  73. package/dist/core/completion-sound.d.ts +4 -10
  74. package/dist/core/completion-sound.d.ts.map +1 -1
  75. package/dist/core/completion-sound.js +28 -58
  76. package/dist/core/completion-sound.js.map +1 -1
  77. package/dist/core/context-budget-relevance.d.ts +15 -2
  78. package/dist/core/context-budget-relevance.d.ts.map +1 -1
  79. package/dist/core/context-budget-relevance.js +21 -9
  80. package/dist/core/context-budget-relevance.js.map +1 -1
  81. package/dist/core/context-budget-system-prompt-items.d.ts +1 -1
  82. package/dist/core/context-budget-system-prompt-items.d.ts.map +1 -1
  83. package/dist/core/context-budget-system-prompt-items.js.map +1 -1
  84. package/dist/core/context-budget-system-prompt.d.ts +1 -1
  85. package/dist/core/context-budget-system-prompt.d.ts.map +1 -1
  86. package/dist/core/context-budget-system-prompt.js.map +1 -1
  87. package/dist/core/context-file.d.ts +23 -0
  88. package/dist/core/context-file.d.ts.map +1 -0
  89. package/dist/core/context-file.js +17 -0
  90. package/dist/core/context-file.js.map +1 -0
  91. package/dist/core/keybindings.d.ts +1 -1
  92. package/dist/core/keybindings.d.ts.map +1 -1
  93. package/dist/core/keybindings.js +6 -1
  94. package/dist/core/keybindings.js.map +1 -1
  95. package/dist/core/model-prompt-policy.d.ts +1 -1
  96. package/dist/core/model-prompt-policy.d.ts.map +1 -1
  97. package/dist/core/model-prompt-policy.js.map +1 -1
  98. package/dist/core/prompt-settlement.d.ts +6 -3
  99. package/dist/core/prompt-settlement.d.ts.map +1 -1
  100. package/dist/core/prompt-settlement.js +10 -14
  101. package/dist/core/prompt-settlement.js.map +1 -1
  102. package/dist/core/reasoning-router-promotion.d.ts +41 -1
  103. package/dist/core/reasoning-router-promotion.d.ts.map +1 -1
  104. package/dist/core/reasoning-router-promotion.js +31 -2
  105. package/dist/core/reasoning-router-promotion.js.map +1 -1
  106. package/dist/core/reasoning-router-replay-stability.d.ts +65 -0
  107. package/dist/core/reasoning-router-replay-stability.d.ts.map +1 -0
  108. package/dist/core/reasoning-router-replay-stability.js +67 -0
  109. package/dist/core/reasoning-router-replay-stability.js.map +1 -0
  110. package/dist/core/reasoning-router-v4-weights.d.ts +6 -6
  111. package/dist/core/reasoning-router-v4-weights.d.ts.map +1 -1
  112. package/dist/core/reasoning-router-v4-weights.js +3 -3
  113. package/dist/core/reasoning-router-v4-weights.js.map +1 -1
  114. package/dist/core/reasoning-router-v4.d.ts.map +1 -1
  115. package/dist/core/reasoning-router-v4.js +6 -6
  116. package/dist/core/reasoning-router-v4.js.map +1 -1
  117. package/dist/core/redaction.d.ts.map +1 -1
  118. package/dist/core/redaction.js +1 -1
  119. package/dist/core/redaction.js.map +1 -1
  120. package/dist/core/resource-admission.d.ts +2 -1
  121. package/dist/core/resource-admission.d.ts.map +1 -1
  122. package/dist/core/resource-admission.js +11 -0
  123. package/dist/core/resource-admission.js.map +1 -1
  124. package/dist/core/resource-governor-format.d.ts +1 -1
  125. package/dist/core/resource-governor-format.d.ts.map +1 -1
  126. package/dist/core/resource-governor-format.js.map +1 -1
  127. package/dist/core/resource-governor-settings.d.ts +6 -12
  128. package/dist/core/resource-governor-settings.d.ts.map +1 -1
  129. package/dist/core/resource-governor-settings.js.map +1 -1
  130. package/dist/core/resource-governor-types.d.ts +24 -0
  131. package/dist/core/resource-governor-types.d.ts.map +1 -0
  132. package/dist/core/resource-governor-types.js +15 -0
  133. package/dist/core/resource-governor-types.js.map +1 -0
  134. package/dist/core/resource-loader.d.ts +1 -7
  135. package/dist/core/resource-loader.d.ts.map +1 -1
  136. package/dist/core/resource-loader.js.map +1 -1
  137. package/dist/core/resource-observation-journal.d.ts +2 -1
  138. package/dist/core/resource-observation-journal.d.ts.map +1 -1
  139. package/dist/core/resource-observation-journal.js +4 -3
  140. package/dist/core/resource-observation-journal.js.map +1 -1
  141. package/dist/core/resource-observation-report-reader.d.ts +7 -0
  142. package/dist/core/resource-observation-report-reader.d.ts.map +1 -0
  143. package/dist/core/resource-observation-report-reader.js +157 -0
  144. package/dist/core/resource-observation-report-reader.js.map +1 -0
  145. package/dist/core/resource-observation-report.d.ts +24 -0
  146. package/dist/core/resource-observation-report.d.ts.map +1 -0
  147. package/dist/core/resource-observation-report.js +101 -0
  148. package/dist/core/resource-observation-report.js.map +1 -0
  149. package/dist/core/router-feedback-collector.d.ts +1 -1
  150. package/dist/core/router-feedback-collector.d.ts.map +1 -1
  151. package/dist/core/router-feedback-collector.js.map +1 -1
  152. package/dist/core/session-failure-cause.d.ts +33 -0
  153. package/dist/core/session-failure-cause.d.ts.map +1 -0
  154. package/dist/core/session-failure-cause.js +141 -0
  155. package/dist/core/session-failure-cause.js.map +1 -0
  156. package/dist/core/session-system-prompt.d.ts +1 -1
  157. package/dist/core/session-system-prompt.d.ts.map +1 -1
  158. package/dist/core/session-system-prompt.js.map +1 -1
  159. package/dist/core/settings-manager.d.ts +1 -1
  160. package/dist/core/settings-manager.d.ts.map +1 -1
  161. package/dist/core/settings-manager.js.map +1 -1
  162. package/dist/core/system-prompt.d.ts +1 -1
  163. package/dist/core/system-prompt.d.ts.map +1 -1
  164. package/dist/core/system-prompt.js.map +1 -1
  165. package/dist/core/tools/bash.d.ts.map +1 -1
  166. package/dist/core/tools/bash.js +7 -7
  167. package/dist/core/tools/bash.js.map +1 -1
  168. package/dist/core/workload-classifier.d.ts +2 -10
  169. package/dist/core/workload-classifier.d.ts.map +1 -1
  170. package/dist/core/workload-classifier.js +17 -0
  171. package/dist/core/workload-classifier.js.map +1 -1
  172. package/dist/core/workload-family-matcher.d.ts +1 -1
  173. package/dist/core/workload-family-matcher.d.ts.map +1 -1
  174. package/dist/core/workload-family-matcher.js.map +1 -1
  175. package/dist/core/workload-shard-execution-types.d.ts +40 -0
  176. package/dist/core/workload-shard-execution-types.d.ts.map +1 -0
  177. package/dist/core/workload-shard-execution-types.js +14 -0
  178. package/dist/core/workload-shard-execution-types.js.map +1 -0
  179. package/dist/core/workload-shard-executor.d.ts +3 -27
  180. package/dist/core/workload-shard-executor.d.ts.map +1 -1
  181. package/dist/core/workload-shard-executor.js.map +1 -1
  182. package/dist/core/workload-shard-runner.d.ts +1 -1
  183. package/dist/core/workload-shard-runner.d.ts.map +1 -1
  184. package/dist/core/workload-shard-runner.js.map +1 -1
  185. package/dist/core/workload-types.d.ts +24 -0
  186. package/dist/core/workload-types.d.ts.map +1 -0
  187. package/dist/core/workload-types.js +15 -0
  188. package/dist/core/workload-types.js.map +1 -0
  189. package/dist/main.d.ts +2 -0
  190. package/dist/main.d.ts.map +1 -1
  191. package/dist/main.js +27 -47
  192. package/dist/main.js.map +1 -1
  193. package/dist/modes/interactive/theme/omk-control-panel.json +1 -1
  194. package/dist/utils/clipboard-image.d.ts.map +1 -1
  195. package/dist/utils/clipboard-image.js +42 -33
  196. package/dist/utils/clipboard-image.js.map +1 -1
  197. package/dist/utils/clipboard.d.ts.map +1 -1
  198. package/dist/utils/clipboard.js +14 -2
  199. package/dist/utils/clipboard.js.map +1 -1
  200. package/docs/adaptorch-preview-spec.md +20 -18
  201. package/docs/adaptorch-preview.md +9 -9
  202. package/docs/compaction.md +24 -3
  203. package/docs/correctness-wall.md +10 -10
  204. package/docs/docs.json +12 -0
  205. package/docs/environment-variables.md +9 -2
  206. package/docs/index.md +3 -0
  207. package/docs/runtime-algorithms.md +359 -0
  208. package/docs/sdk.md +2 -2
  209. package/docs/settings.md +11 -10
  210. package/docs/usage.md +18 -2
  211. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  212. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  213. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  214. package/examples/extensions/gondolin/package-lock.json +2 -2
  215. package/examples/extensions/gondolin/package.json +1 -1
  216. package/examples/extensions/sandbox/package-lock.json +2 -2
  217. package/examples/extensions/sandbox/package.json +1 -1
  218. package/examples/extensions/with-deps/package-lock.json +2 -2
  219. package/examples/extensions/with-deps/package.json +1 -1
  220. package/npm-shrinkwrap.json +18 -18
  221. package/package.json +6 -6
  222. package/dist/core/context-budget-governor.d.ts +0 -67
  223. package/dist/core/context-budget-governor.d.ts.map +0 -1
  224. package/dist/core/context-budget-governor.js +0 -224
  225. package/dist/core/context-budget-governor.js.map +0 -1
  226. package/dist/core/lean-ctx.d.ts +0 -99
  227. package/dist/core/lean-ctx.d.ts.map +0 -1
  228. package/dist/core/lean-ctx.js +0 -225
  229. package/dist/core/lean-ctx.js.map +0 -1
  230. package/dist/core/read-anchors.d.ts +0 -110
  231. package/dist/core/read-anchors.d.ts.map +0 -1
  232. package/dist/core/read-anchors.js +0 -193
  233. package/dist/core/read-anchors.js.map +0 -1
  234. package/dist/core/recovery-checkpoint.d.ts +0 -196
  235. package/dist/core/recovery-checkpoint.d.ts.map +0 -1
  236. package/dist/core/recovery-checkpoint.js +0 -382
  237. package/dist/core/recovery-checkpoint.js.map +0 -1
  238. package/dist/core/sandbox-policy-v2.d.ts +0 -49
  239. package/dist/core/sandbox-policy-v2.d.ts.map +0 -1
  240. package/dist/core/sandbox-policy-v2.js +0 -368
  241. package/dist/core/sandbox-policy-v2.js.map +0 -1
  242. package/dist/guardrails/audit-logger.d.ts +0 -4
  243. package/dist/guardrails/audit-logger.d.ts.map +0 -1
  244. package/dist/guardrails/audit-logger.js +0 -28
  245. package/dist/guardrails/audit-logger.js.map +0 -1
  246. package/dist/guardrails/freedomd-adapter.d.ts +0 -16
  247. package/dist/guardrails/freedomd-adapter.d.ts.map +0 -1
  248. package/dist/guardrails/freedomd-adapter.js +0 -87
  249. package/dist/guardrails/freedomd-adapter.js.map +0 -1
  250. package/dist/orchestration/lane-grant-auditor.d.ts +0 -4
  251. package/dist/orchestration/lane-grant-auditor.d.ts.map +0 -1
  252. package/dist/orchestration/lane-grant-auditor.js +0 -87
  253. package/dist/orchestration/lane-grant-auditor.js.map +0 -1
  254. package/dist/types/guardrails.d.ts +0 -61
  255. package/dist/types/guardrails.d.ts.map +0 -1
  256. package/dist/types/guardrails.js +0 -9
  257. package/dist/types/guardrails.js.map +0 -1
  258. package/dist/types/lane-grant.d.ts +0 -58
  259. package/dist/types/lane-grant.d.ts.map +0 -1
  260. package/dist/types/lane-grant.js +0 -9
  261. package/dist/types/lane-grant.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ import type { ExtensionFlag } from "../core/extensions/types.ts";
2
+ export declare function printHelp(extensionFlags?: ExtensionFlag[]): void;
3
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,wBAAgB,SAAS,CAAC,cAAc,CAAC,EAAE,aAAa,EAAE,GAAG,IAAI,CA8LhE","sourcesContent":["import chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from \"../config.ts\";\nimport type { ExtensionFlag } from \"../core/extensions/types.ts\";\n\nexport function printHelp(extensionFlags?: ExtensionFlag[]): void {\n\tlet extensionFlagsText = \"\";\n\tif (extensionFlags && extensionFlags.length > 0) {\n\t\textensionFlagsText = `\\n${chalk.bold(\"Extension CLI Flags:\")}\\n${extensionFlags\n\t\t\t.map((flag) => {\n\t\t\t\tconst value = flag.type === \"string\" ? \" <value>\" : \"\";\n\t\t\t\tconst description = flag.description ?? `Registered by ${flag.extensionPath}`;\n\t\t\t\treturn ` --${flag.name}${value}`.padEnd(30) + description;\n\t\t\t})\n\t\t\t.join(\"\\n\")}\\n`;\n\t}\n\t// CLI help is intentional stdout, not application debug logging.\n\t// pi-lens-ignore: no-console-except-error\n\tconsole.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools\n\n${chalk.bold(\"Usage:\")}\n ${APP_NAME} [options] [@files...] [messages...]\n\n${chalk.bold(\"Commands:\")}\n ${APP_NAME} install <source> [-l] Install extension source and add to settings\n ${APP_NAME} remove <source> [-l] Remove extension source from settings\n ${APP_NAME} uninstall <source> [-l] Alias for remove\n ${APP_NAME} update [source|self|omk] Update OMK and installed extensions\n ${APP_NAME} list List installed extensions from settings\n ${APP_NAME} package doctor <source> Diagnose omk/pi manifest and runtime compatibility as JSON\n ${APP_NAME} config Open TUI to enable/disable package resources\n ${APP_NAME} quota Manage CodexBar quota connector and summaries\n ${APP_NAME} provider doctor <id> Diagnose a provider as sanitized JSON (--probe-model adds an\n opt-in Level-2 generative probe that may incur provider costs)\n ${APP_NAME} session doctor Inspect or safely repair one session (--session, --repair, --dry-run)\n ${APP_NAME} doctor resources [--json] [--report] Inspect current pressure or aggregate local observations\n ${APP_NAME} doctor adaptorch [--json] Verify ADAPTORCH_API_KEY reaches the AdaptOrch API (0 ok, 1 unset, 2 failed)\n ${APP_NAME} router-feedback compile-bias Compile this repository's bounded router bias snapshot\n ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list\n\n${chalk.bold(\"Options:\")}\n --provider <name> Provider name (default: google)\n --model <pattern> Model pattern or ID (supports \"provider/id\" and optional \":<thinking>\")\n --api-key <key> API key (defaults to env vars)\n --system-prompt <text> System prompt (default: coding assistant prompt)\n --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)\n --mode <mode> Output mode: text (default), json, or rpc\n --print, -p Non-interactive mode: process prompt and exit\n --continue, -c Continue previous session\n --resume, -r Select a session to resume\n --session <path|id> Use specific session file or partial UUID\n --session-id <id> Use exact project session ID, creating it if missing\n --fork <path|id> Fork specific session file or partial UUID into a new session\n --session-dir <dir> Directory for session storage and lookup\n --no-session Don't save session (ephemeral)\n --name, -n <name> Set session display name\n --models <patterns> Comma-separated model patterns for Ctrl+P cycling\n Supports globs (anthropic/*, *sonnet*) and fuzzy matching\n --no-tools, -nt Disable all tools by default (built-in and extension)\n --no-builtin-tools, -nbt Disable built-in tools by default but keep extension/custom tools enabled\n --tools, -t <tools> Comma-separated allowlist of tool names to enable\n Applies to built-in, extension, and custom tools\n --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable\n Applies to built-in, extension, and custom tools\n --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max, ultra\n --extension, -e <path> Load an extension file (can be used multiple times)\n --no-extensions, -ne Disable extension discovery (explicit -e paths still work)\n --skill <path> Load a skill file or directory (can be used multiple times)\n --no-skills, -ns Disable skills discovery and loading\n --prompt-template <path> Load a prompt template file or directory (can be used multiple times)\n --no-prompt-templates, -np Disable prompt template discovery and loading\n --theme <path> Load a theme file or directory (can be used multiple times)\n --no-themes Disable theme discovery and loading\n --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading\n --export <file> Export session file to HTML and exit\n --list-models [search] List available models (with optional fuzzy search)\n --verbose Force verbose startup (overrides quietStartup setting)\n --offline Disable startup network operations (same as OMK_OFFLINE=1)\n --help, -h Show this help\n --version, -v Show version number\n\nExtensions can register additional flags (e.g., --plan from plan-mode extension).${extensionFlagsText}\n\n${chalk.bold(\"Examples:\")}\n # Interactive mode\n ${APP_NAME}\n\n # Interactive mode with initial prompt\n ${APP_NAME} \"List all .ts files in src/\"\n\n # Include files in initial message\n ${APP_NAME} @prompt.md @image.png \"What color is the sky?\"\n\n # Non-interactive mode (process and exit)\n ${APP_NAME} -p \"List all .ts files in src/\"\n\n # Multiple messages (interactive)\n ${APP_NAME} \"Read package.json\" \"What dependencies do we have?\"\n\n # Continue previous session\n ${APP_NAME} --continue \"What did we discuss?\"\n\n # Start a named session\n ${APP_NAME} --name \"Refactor auth module\"\n\n # Use different model\n ${APP_NAME} --provider openai --model gpt-4o-mini \"Help me refactor this code\"\n\n # Use model with provider prefix (no --provider needed)\n ${APP_NAME} --model openai/gpt-4o \"Help me refactor this code\"\n\n # Use model with thinking level shorthand\n ${APP_NAME} --model sonnet:high \"Solve this complex problem\"\n\n # Limit model cycling to specific models\n ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o\n\n # Limit to a specific provider with glob pattern\n ${APP_NAME} --models \"github-copilot/*\"\n\n # Cycle models with fixed thinking levels\n ${APP_NAME} --models sonnet:high,haiku:low\n\n # Start with a specific thinking level\n ${APP_NAME} --thinking high \"Solve this complex problem\"\n\n # Read-only mode (no file modifications possible)\n ${APP_NAME} --tools read,grep,find,ls -p \"Review the code in src/\"\n\n # Disable one tool while keeping the rest available\n ${APP_NAME} --exclude-tools ask_question\n\n # Export a session file to HTML\n ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl\n ${APP_NAME} --export session.jsonl output.html\n\n${chalk.bold(\"Environment Variables:\")}\n ANTHROPIC_API_KEY - Anthropic Claude API key\n ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)\n ANT_LING_API_KEY - Ant Ling API key\n OPENAI_API_KEY - OpenAI GPT API key\n AZURE_OPENAI_API_KEY - Azure OpenAI API key\n AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)\n AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)\n AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)\n AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)\n DEEPSEEK_API_KEY - DeepSeek API key\n NVIDIA_API_KEY - NVIDIA NIM API key\n GEMINI_API_KEY - Google Gemini API key\n GROQ_API_KEY - Groq API key\n CEREBRAS_API_KEY - Cerebras API key\n XAI_API_KEY - xAI Grok API key\n FIREWORKS_API_KEY - Fireworks API key\n TOGETHER_API_KEY - Together AI API key\n OPENROUTER_API_KEY - OpenRouter API key\n AI_GATEWAY_API_KEY - Vercel AI Gateway API key\n ZAI_API_KEY - ZAI API key\n ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)\n MISTRAL_API_KEY - Mistral API key\n MINIMAX_API_KEY - MiniMax API key\n MOONSHOT_API_KEY - Moonshot AI API key\n OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key\n KIMI_API_KEY - Kimi For Coding API key\n CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)\n CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)\n CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)\n XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)\n XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)\n XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)\n XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)\n ZYLOO_API_KEY - Zyloo API key\n AWS_PROFILE - AWS profile for Amazon Bedrock\n AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock\n AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock\n AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)\n AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)\n ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)\n ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)\n OMK_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)\n OMK_TOOL_SCHEDULER - Tool scheduler override: dag-v2 or waves-v1 rollback\n OMK_OFFLINE - Disable startup network operations when set to 1/true/yes\n OMK_TELEMETRY - Override install telemetry when set to 1/true/yes or 0/false/no\n OMK_SHARE_VIEWER_URL - Base URL for /share command (default: https://omk.dev/session/)\n ADAPTORCH_API_KEY - AdaptOrch API key (optional; enables the doctor adaptorch check)\n ADAPTORCH_API_URL - AdaptOrch API base URL (default: https://api.adaptorch.com)\n\n${chalk.bold(\"Built-in Tool Names:\")}\n read - Read file contents\n bash - Execute bash commands\n edit - Edit files with find/replace\n write - Write files (creates/overwrites)\n grep - Search file contents (read-only, off by default)\n find - Find files by glob pattern (read-only, off by default)\n ls - List directory contents (read-only, off by default)\n`);\n}\n"]}
@@ -0,0 +1,194 @@
1
+ import chalk from "chalk";
2
+ import { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from "../config.js";
3
+ export function printHelp(extensionFlags) {
4
+ let extensionFlagsText = "";
5
+ if (extensionFlags && extensionFlags.length > 0) {
6
+ extensionFlagsText = `\n${chalk.bold("Extension CLI Flags:")}\n${extensionFlags
7
+ .map((flag) => {
8
+ const value = flag.type === "string" ? " <value>" : "";
9
+ const description = flag.description ?? `Registered by ${flag.extensionPath}`;
10
+ return ` --${flag.name}${value}`.padEnd(30) + description;
11
+ })
12
+ .join("\n")}\n`;
13
+ }
14
+ // CLI help is intentional stdout, not application debug logging.
15
+ // pi-lens-ignore: no-console-except-error
16
+ console.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools
17
+
18
+ ${chalk.bold("Usage:")}
19
+ ${APP_NAME} [options] [@files...] [messages...]
20
+
21
+ ${chalk.bold("Commands:")}
22
+ ${APP_NAME} install <source> [-l] Install extension source and add to settings
23
+ ${APP_NAME} remove <source> [-l] Remove extension source from settings
24
+ ${APP_NAME} uninstall <source> [-l] Alias for remove
25
+ ${APP_NAME} update [source|self|omk] Update OMK and installed extensions
26
+ ${APP_NAME} list List installed extensions from settings
27
+ ${APP_NAME} package doctor <source> Diagnose omk/pi manifest and runtime compatibility as JSON
28
+ ${APP_NAME} config Open TUI to enable/disable package resources
29
+ ${APP_NAME} quota Manage CodexBar quota connector and summaries
30
+ ${APP_NAME} provider doctor <id> Diagnose a provider as sanitized JSON (--probe-model adds an
31
+ opt-in Level-2 generative probe that may incur provider costs)
32
+ ${APP_NAME} session doctor Inspect or safely repair one session (--session, --repair, --dry-run)
33
+ ${APP_NAME} doctor resources [--json] [--report] Inspect current pressure or aggregate local observations
34
+ ${APP_NAME} doctor adaptorch [--json] Verify ADAPTORCH_API_KEY reaches the AdaptOrch API (0 ok, 1 unset, 2 failed)
35
+ ${APP_NAME} router-feedback compile-bias Compile this repository's bounded router bias snapshot
36
+ ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list
37
+
38
+ ${chalk.bold("Options:")}
39
+ --provider <name> Provider name (default: google)
40
+ --model <pattern> Model pattern or ID (supports "provider/id" and optional ":<thinking>")
41
+ --api-key <key> API key (defaults to env vars)
42
+ --system-prompt <text> System prompt (default: coding assistant prompt)
43
+ --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)
44
+ --mode <mode> Output mode: text (default), json, or rpc
45
+ --print, -p Non-interactive mode: process prompt and exit
46
+ --continue, -c Continue previous session
47
+ --resume, -r Select a session to resume
48
+ --session <path|id> Use specific session file or partial UUID
49
+ --session-id <id> Use exact project session ID, creating it if missing
50
+ --fork <path|id> Fork specific session file or partial UUID into a new session
51
+ --session-dir <dir> Directory for session storage and lookup
52
+ --no-session Don't save session (ephemeral)
53
+ --name, -n <name> Set session display name
54
+ --models <patterns> Comma-separated model patterns for Ctrl+P cycling
55
+ Supports globs (anthropic/*, *sonnet*) and fuzzy matching
56
+ --no-tools, -nt Disable all tools by default (built-in and extension)
57
+ --no-builtin-tools, -nbt Disable built-in tools by default but keep extension/custom tools enabled
58
+ --tools, -t <tools> Comma-separated allowlist of tool names to enable
59
+ Applies to built-in, extension, and custom tools
60
+ --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable
61
+ Applies to built-in, extension, and custom tools
62
+ --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max, ultra
63
+ --extension, -e <path> Load an extension file (can be used multiple times)
64
+ --no-extensions, -ne Disable extension discovery (explicit -e paths still work)
65
+ --skill <path> Load a skill file or directory (can be used multiple times)
66
+ --no-skills, -ns Disable skills discovery and loading
67
+ --prompt-template <path> Load a prompt template file or directory (can be used multiple times)
68
+ --no-prompt-templates, -np Disable prompt template discovery and loading
69
+ --theme <path> Load a theme file or directory (can be used multiple times)
70
+ --no-themes Disable theme discovery and loading
71
+ --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading
72
+ --export <file> Export session file to HTML and exit
73
+ --list-models [search] List available models (with optional fuzzy search)
74
+ --verbose Force verbose startup (overrides quietStartup setting)
75
+ --offline Disable startup network operations (same as OMK_OFFLINE=1)
76
+ --help, -h Show this help
77
+ --version, -v Show version number
78
+
79
+ Extensions can register additional flags (e.g., --plan from plan-mode extension).${extensionFlagsText}
80
+
81
+ ${chalk.bold("Examples:")}
82
+ # Interactive mode
83
+ ${APP_NAME}
84
+
85
+ # Interactive mode with initial prompt
86
+ ${APP_NAME} "List all .ts files in src/"
87
+
88
+ # Include files in initial message
89
+ ${APP_NAME} @prompt.md @image.png "What color is the sky?"
90
+
91
+ # Non-interactive mode (process and exit)
92
+ ${APP_NAME} -p "List all .ts files in src/"
93
+
94
+ # Multiple messages (interactive)
95
+ ${APP_NAME} "Read package.json" "What dependencies do we have?"
96
+
97
+ # Continue previous session
98
+ ${APP_NAME} --continue "What did we discuss?"
99
+
100
+ # Start a named session
101
+ ${APP_NAME} --name "Refactor auth module"
102
+
103
+ # Use different model
104
+ ${APP_NAME} --provider openai --model gpt-4o-mini "Help me refactor this code"
105
+
106
+ # Use model with provider prefix (no --provider needed)
107
+ ${APP_NAME} --model openai/gpt-4o "Help me refactor this code"
108
+
109
+ # Use model with thinking level shorthand
110
+ ${APP_NAME} --model sonnet:high "Solve this complex problem"
111
+
112
+ # Limit model cycling to specific models
113
+ ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o
114
+
115
+ # Limit to a specific provider with glob pattern
116
+ ${APP_NAME} --models "github-copilot/*"
117
+
118
+ # Cycle models with fixed thinking levels
119
+ ${APP_NAME} --models sonnet:high,haiku:low
120
+
121
+ # Start with a specific thinking level
122
+ ${APP_NAME} --thinking high "Solve this complex problem"
123
+
124
+ # Read-only mode (no file modifications possible)
125
+ ${APP_NAME} --tools read,grep,find,ls -p "Review the code in src/"
126
+
127
+ # Disable one tool while keeping the rest available
128
+ ${APP_NAME} --exclude-tools ask_question
129
+
130
+ # Export a session file to HTML
131
+ ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl
132
+ ${APP_NAME} --export session.jsonl output.html
133
+
134
+ ${chalk.bold("Environment Variables:")}
135
+ ANTHROPIC_API_KEY - Anthropic Claude API key
136
+ ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)
137
+ ANT_LING_API_KEY - Ant Ling API key
138
+ OPENAI_API_KEY - OpenAI GPT API key
139
+ AZURE_OPENAI_API_KEY - Azure OpenAI API key
140
+ AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)
141
+ AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)
142
+ AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)
143
+ AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)
144
+ DEEPSEEK_API_KEY - DeepSeek API key
145
+ NVIDIA_API_KEY - NVIDIA NIM API key
146
+ GEMINI_API_KEY - Google Gemini API key
147
+ GROQ_API_KEY - Groq API key
148
+ CEREBRAS_API_KEY - Cerebras API key
149
+ XAI_API_KEY - xAI Grok API key
150
+ FIREWORKS_API_KEY - Fireworks API key
151
+ TOGETHER_API_KEY - Together AI API key
152
+ OPENROUTER_API_KEY - OpenRouter API key
153
+ AI_GATEWAY_API_KEY - Vercel AI Gateway API key
154
+ ZAI_API_KEY - ZAI API key
155
+ ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)
156
+ MISTRAL_API_KEY - Mistral API key
157
+ MINIMAX_API_KEY - MiniMax API key
158
+ MOONSHOT_API_KEY - Moonshot AI API key
159
+ OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key
160
+ KIMI_API_KEY - Kimi For Coding API key
161
+ CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)
162
+ CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)
163
+ CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)
164
+ XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)
165
+ XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)
166
+ XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)
167
+ XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)
168
+ ZYLOO_API_KEY - Zyloo API key
169
+ AWS_PROFILE - AWS profile for Amazon Bedrock
170
+ AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock
171
+ AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock
172
+ AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)
173
+ AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)
174
+ ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)
175
+ ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)
176
+ OMK_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)
177
+ OMK_TOOL_SCHEDULER - Tool scheduler override: dag-v2 or waves-v1 rollback
178
+ OMK_OFFLINE - Disable startup network operations when set to 1/true/yes
179
+ OMK_TELEMETRY - Override install telemetry when set to 1/true/yes or 0/false/no
180
+ OMK_SHARE_VIEWER_URL - Base URL for /share command (default: https://omk.dev/session/)
181
+ ADAPTORCH_API_KEY - AdaptOrch API key (optional; enables the doctor adaptorch check)
182
+ ADAPTORCH_API_URL - AdaptOrch API base URL (default: https://api.adaptorch.com)
183
+
184
+ ${chalk.bold("Built-in Tool Names:")}
185
+ read - Read file contents
186
+ bash - Execute bash commands
187
+ edit - Edit files with find/replace
188
+ write - Write files (creates/overwrites)
189
+ grep - Search file contents (read-only, off by default)
190
+ find - Find files by glob pattern (read-only, off by default)
191
+ ls - List directory contents (read-only, off by default)
192
+ `);
193
+ }
194
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGzF,MAAM,UAAU,SAAS,CAAC,cAAgC,EAAQ;IACjE,IAAI,kBAAkB,GAAG,EAAE,CAAC;IAC5B,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,kBAAkB,GAAG,KAAK,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,KAAK,cAAc;aAC7E,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACd,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,iBAAiB,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9E,OAAO,OAAO,IAAI,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;QAAA,CAC3D,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,iEAAiE;IACjE,0CAA0C;IAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;;EAElC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;IAClB,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;IACrB,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;;IAER,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mFAyC2D,kBAAkB;;EAEnG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;;IAErB,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ;;;IAGR,QAAQ,eAAe,eAAe;IACtC,QAAQ;;EAEV,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwClC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,mCAAmC,eAAe;IAC1E,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;;;;;;;;;EAS5B,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;;;;;;;;CAQnC,CAAC,CAAC;AAAA,CACF","sourcesContent":["import chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_SESSION_DIR } from \"../config.ts\";\nimport type { ExtensionFlag } from \"../core/extensions/types.ts\";\n\nexport function printHelp(extensionFlags?: ExtensionFlag[]): void {\n\tlet extensionFlagsText = \"\";\n\tif (extensionFlags && extensionFlags.length > 0) {\n\t\textensionFlagsText = `\\n${chalk.bold(\"Extension CLI Flags:\")}\\n${extensionFlags\n\t\t\t.map((flag) => {\n\t\t\t\tconst value = flag.type === \"string\" ? \" <value>\" : \"\";\n\t\t\t\tconst description = flag.description ?? `Registered by ${flag.extensionPath}`;\n\t\t\t\treturn ` --${flag.name}${value}`.padEnd(30) + description;\n\t\t\t})\n\t\t\t.join(\"\\n\")}\\n`;\n\t}\n\t// CLI help is intentional stdout, not application debug logging.\n\t// pi-lens-ignore: no-console-except-error\n\tconsole.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools\n\n${chalk.bold(\"Usage:\")}\n ${APP_NAME} [options] [@files...] [messages...]\n\n${chalk.bold(\"Commands:\")}\n ${APP_NAME} install <source> [-l] Install extension source and add to settings\n ${APP_NAME} remove <source> [-l] Remove extension source from settings\n ${APP_NAME} uninstall <source> [-l] Alias for remove\n ${APP_NAME} update [source|self|omk] Update OMK and installed extensions\n ${APP_NAME} list List installed extensions from settings\n ${APP_NAME} package doctor <source> Diagnose omk/pi manifest and runtime compatibility as JSON\n ${APP_NAME} config Open TUI to enable/disable package resources\n ${APP_NAME} quota Manage CodexBar quota connector and summaries\n ${APP_NAME} provider doctor <id> Diagnose a provider as sanitized JSON (--probe-model adds an\n opt-in Level-2 generative probe that may incur provider costs)\n ${APP_NAME} session doctor Inspect or safely repair one session (--session, --repair, --dry-run)\n ${APP_NAME} doctor resources [--json] [--report] Inspect current pressure or aggregate local observations\n ${APP_NAME} doctor adaptorch [--json] Verify ADAPTORCH_API_KEY reaches the AdaptOrch API (0 ok, 1 unset, 2 failed)\n ${APP_NAME} router-feedback compile-bias Compile this repository's bounded router bias snapshot\n ${APP_NAME} <command> --help Show help for install/remove/uninstall/update/list\n\n${chalk.bold(\"Options:\")}\n --provider <name> Provider name (default: google)\n --model <pattern> Model pattern or ID (supports \"provider/id\" and optional \":<thinking>\")\n --api-key <key> API key (defaults to env vars)\n --system-prompt <text> System prompt (default: coding assistant prompt)\n --append-system-prompt <text> Append text or file contents to the system prompt (can be used multiple times)\n --mode <mode> Output mode: text (default), json, or rpc\n --print, -p Non-interactive mode: process prompt and exit\n --continue, -c Continue previous session\n --resume, -r Select a session to resume\n --session <path|id> Use specific session file or partial UUID\n --session-id <id> Use exact project session ID, creating it if missing\n --fork <path|id> Fork specific session file or partial UUID into a new session\n --session-dir <dir> Directory for session storage and lookup\n --no-session Don't save session (ephemeral)\n --name, -n <name> Set session display name\n --models <patterns> Comma-separated model patterns for Ctrl+P cycling\n Supports globs (anthropic/*, *sonnet*) and fuzzy matching\n --no-tools, -nt Disable all tools by default (built-in and extension)\n --no-builtin-tools, -nbt Disable built-in tools by default but keep extension/custom tools enabled\n --tools, -t <tools> Comma-separated allowlist of tool names to enable\n Applies to built-in, extension, and custom tools\n --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable\n Applies to built-in, extension, and custom tools\n --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max, ultra\n --extension, -e <path> Load an extension file (can be used multiple times)\n --no-extensions, -ne Disable extension discovery (explicit -e paths still work)\n --skill <path> Load a skill file or directory (can be used multiple times)\n --no-skills, -ns Disable skills discovery and loading\n --prompt-template <path> Load a prompt template file or directory (can be used multiple times)\n --no-prompt-templates, -np Disable prompt template discovery and loading\n --theme <path> Load a theme file or directory (can be used multiple times)\n --no-themes Disable theme discovery and loading\n --no-context-files, -nc Disable AGENTS.md and CLAUDE.md discovery and loading\n --export <file> Export session file to HTML and exit\n --list-models [search] List available models (with optional fuzzy search)\n --verbose Force verbose startup (overrides quietStartup setting)\n --offline Disable startup network operations (same as OMK_OFFLINE=1)\n --help, -h Show this help\n --version, -v Show version number\n\nExtensions can register additional flags (e.g., --plan from plan-mode extension).${extensionFlagsText}\n\n${chalk.bold(\"Examples:\")}\n # Interactive mode\n ${APP_NAME}\n\n # Interactive mode with initial prompt\n ${APP_NAME} \"List all .ts files in src/\"\n\n # Include files in initial message\n ${APP_NAME} @prompt.md @image.png \"What color is the sky?\"\n\n # Non-interactive mode (process and exit)\n ${APP_NAME} -p \"List all .ts files in src/\"\n\n # Multiple messages (interactive)\n ${APP_NAME} \"Read package.json\" \"What dependencies do we have?\"\n\n # Continue previous session\n ${APP_NAME} --continue \"What did we discuss?\"\n\n # Start a named session\n ${APP_NAME} --name \"Refactor auth module\"\n\n # Use different model\n ${APP_NAME} --provider openai --model gpt-4o-mini \"Help me refactor this code\"\n\n # Use model with provider prefix (no --provider needed)\n ${APP_NAME} --model openai/gpt-4o \"Help me refactor this code\"\n\n # Use model with thinking level shorthand\n ${APP_NAME} --model sonnet:high \"Solve this complex problem\"\n\n # Limit model cycling to specific models\n ${APP_NAME} --models claude-sonnet,claude-haiku,gpt-4o\n\n # Limit to a specific provider with glob pattern\n ${APP_NAME} --models \"github-copilot/*\"\n\n # Cycle models with fixed thinking levels\n ${APP_NAME} --models sonnet:high,haiku:low\n\n # Start with a specific thinking level\n ${APP_NAME} --thinking high \"Solve this complex problem\"\n\n # Read-only mode (no file modifications possible)\n ${APP_NAME} --tools read,grep,find,ls -p \"Review the code in src/\"\n\n # Disable one tool while keeping the rest available\n ${APP_NAME} --exclude-tools ask_question\n\n # Export a session file to HTML\n ${APP_NAME} --export ~/${CONFIG_DIR_NAME}/agent/sessions/--path--/session.jsonl\n ${APP_NAME} --export session.jsonl output.html\n\n${chalk.bold(\"Environment Variables:\")}\n ANTHROPIC_API_KEY - Anthropic Claude API key\n ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth token (alternative to API key)\n ANT_LING_API_KEY - Ant Ling API key\n OPENAI_API_KEY - OpenAI GPT API key\n AZURE_OPENAI_API_KEY - Azure OpenAI API key\n AZURE_OPENAI_BASE_URL - Azure OpenAI/Cognitive Services base URL (e.g. https://{resource}.openai.azure.com)\n AZURE_OPENAI_RESOURCE_NAME - Azure OpenAI resource name (alternative to base URL)\n AZURE_OPENAI_API_VERSION - Azure OpenAI API version (default: v1)\n AZURE_OPENAI_DEPLOYMENT_NAME_MAP - Azure OpenAI model=deployment map (comma-separated)\n DEEPSEEK_API_KEY - DeepSeek API key\n NVIDIA_API_KEY - NVIDIA NIM API key\n GEMINI_API_KEY - Google Gemini API key\n GROQ_API_KEY - Groq API key\n CEREBRAS_API_KEY - Cerebras API key\n XAI_API_KEY - xAI Grok API key\n FIREWORKS_API_KEY - Fireworks API key\n TOGETHER_API_KEY - Together AI API key\n OPENROUTER_API_KEY - OpenRouter API key\n AI_GATEWAY_API_KEY - Vercel AI Gateway API key\n ZAI_API_KEY - ZAI API key\n ZAI_CODING_CN_API_KEY - ZAI Coding Plan API key (China)\n MISTRAL_API_KEY - Mistral API key\n MINIMAX_API_KEY - MiniMax API key\n MOONSHOT_API_KEY - Moonshot AI API key\n OPENCODE_API_KEY - OpenCode Zen/OpenCode Go API key\n KIMI_API_KEY - Kimi For Coding API key\n CLOUDFLARE_API_KEY - Cloudflare API token (Workers AI and AI Gateway)\n CLOUDFLARE_ACCOUNT_ID - Cloudflare account id (required for both)\n CLOUDFLARE_GATEWAY_ID - Cloudflare AI Gateway slug (required for AI Gateway)\n XIAOMI_API_KEY - Xiaomi MiMo API key (api.xiaomimimo.com billing)\n XIAOMI_TOKEN_PLAN_CN_API_KEY - Xiaomi MiMo Token Plan API key (China region)\n XIAOMI_TOKEN_PLAN_AMS_API_KEY - Xiaomi MiMo Token Plan API key (Amsterdam region)\n XIAOMI_TOKEN_PLAN_SGP_API_KEY - Xiaomi MiMo Token Plan API key (Singapore region)\n ZYLOO_API_KEY - Zyloo API key\n AWS_PROFILE - AWS profile for Amazon Bedrock\n AWS_ACCESS_KEY_ID - AWS access key for Amazon Bedrock\n AWS_SECRET_ACCESS_KEY - AWS secret key for Amazon Bedrock\n AWS_BEARER_TOKEN_BEDROCK - Bedrock API key (bearer token)\n AWS_REGION - AWS region for Amazon Bedrock (e.g., us-east-1)\n ${ENV_AGENT_DIR.padEnd(32)} - Config directory (default: ~/${CONFIG_DIR_NAME}/agent)\n ${ENV_SESSION_DIR.padEnd(32)} - Session storage directory (overridden by --session-dir)\n OMK_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)\n OMK_TOOL_SCHEDULER - Tool scheduler override: dag-v2 or waves-v1 rollback\n OMK_OFFLINE - Disable startup network operations when set to 1/true/yes\n OMK_TELEMETRY - Override install telemetry when set to 1/true/yes or 0/false/no\n OMK_SHARE_VIEWER_URL - Base URL for /share command (default: https://omk.dev/session/)\n ADAPTORCH_API_KEY - AdaptOrch API key (optional; enables the doctor adaptorch check)\n ADAPTORCH_API_URL - AdaptOrch API base URL (default: https://api.adaptorch.com)\n\n${chalk.bold(\"Built-in Tool Names:\")}\n read - Read file contents\n bash - Execute bash commands\n edit - Edit files with find/replace\n write - Write files (creates/overwrites)\n grep - Search file contents (read-only, off by default)\n find - Find files by glob pattern (read-only, off by default)\n ls - List directory contents (read-only, off by default)\n`);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initial-message.d.ts","sourceRoot":"","sources":["../../src/cli/initial-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,MAAM,EACN,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,EAAE,mBAAmB,GAAG,oBAAoB,CAkB5C","sourcesContent":["import type { ImageContent } from \"omk-ai\";\nimport type { Args } from \"./args.ts\";\n\nexport interface InitialMessageInput {\n\tparsed: Args;\n\tfileText?: string;\n\tfileImages?: ImageContent[];\n\tstdinContent?: string;\n}\n\nexport interface InitialMessageResult {\n\tinitialMessage?: string;\n\tinitialImages?: ImageContent[];\n}\n\n/**\n * Combine stdin content, @file text, and the first CLI message into a single\n * initial prompt for non-interactive mode.\n */\nexport function buildInitialMessage({\n\tparsed,\n\tfileText,\n\tfileImages,\n\tstdinContent,\n}: InitialMessageInput): InitialMessageResult {\n\tconst parts: string[] = [];\n\tif (stdinContent !== undefined) {\n\t\tparts.push(stdinContent);\n\t}\n\tif (fileText) {\n\t\tparts.push(fileText);\n\t}\n\n\tif (parsed.messages.length > 0) {\n\t\tparts.push(parsed.messages[0]);\n\t\tparsed.messages.shift();\n\t}\n\n\treturn {\n\t\tinitialMessage: parts.length > 0 ? parts.join(\"\") : undefined,\n\t\tinitialImages: fileImages && fileImages.length > 0 ? fileImages : undefined,\n\t};\n}\n"]}
1
+ {"version":3,"file":"initial-message.d.ts","sourceRoot":"","sources":["../../src/cli/initial-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,MAAM,EACN,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,EAAE,mBAAmB,GAAG,oBAAoB,CAmB5C","sourcesContent":["import type { ImageContent } from \"omk-ai\";\nimport type { Args } from \"./args.ts\";\n\nexport interface InitialMessageInput {\n\tparsed: Args;\n\tfileText?: string;\n\tfileImages?: ImageContent[];\n\tstdinContent?: string;\n}\n\nexport interface InitialMessageResult {\n\tinitialMessage?: string;\n\tinitialImages?: ImageContent[];\n}\n\n/**\n * Combine stdin content, @file text, and the first CLI message into a single\n * initial prompt for non-interactive mode.\n */\nexport function buildInitialMessage({\n\tparsed,\n\tfileText,\n\tfileImages,\n\tstdinContent,\n}: InitialMessageInput): InitialMessageResult {\n\tconst parts: string[] = [];\n\tif (stdinContent !== undefined) {\n\t\tconst trailingNewline = stdinContent.endsWith(\"\\n\") ? \"\" : \"\\n\";\n\t\tparts.push(`<stdin>\\n${stdinContent}${trailingNewline}</stdin>\\n`);\n\t}\n\tif (fileText) {\n\t\tparts.push(fileText);\n\t}\n\n\tif (parsed.messages.length > 0) {\n\t\tparts.push(parsed.messages[0]);\n\t\tparsed.messages.shift();\n\t}\n\n\treturn {\n\t\tinitialMessage: parts.length > 0 ? parts.join(\"\") : undefined,\n\t\tinitialImages: fileImages && fileImages.length > 0 ? fileImages : undefined,\n\t};\n}\n"]}
@@ -5,7 +5,8 @@
5
5
  export function buildInitialMessage({ parsed, fileText, fileImages, stdinContent, }) {
6
6
  const parts = [];
7
7
  if (stdinContent !== undefined) {
8
- parts.push(stdinContent);
8
+ const trailingNewline = stdinContent.endsWith("\n") ? "" : "\n";
9
+ parts.push(`<stdin>\n${stdinContent}${trailingNewline}</stdin>\n`);
9
10
  }
10
11
  if (fileText) {
11
12
  parts.push(fileText);
@@ -1 +1 @@
1
- {"version":3,"file":"initial-message.js","sourceRoot":"","sources":["../../src/cli/initial-message.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EACnC,MAAM,EACN,QAAQ,EACR,UAAU,EACV,YAAY,GACS,EAAwB;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,OAAO;QACN,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7D,aAAa,EAAE,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KAC3E,CAAC;AAAA,CACF","sourcesContent":["import type { ImageContent } from \"omk-ai\";\nimport type { Args } from \"./args.ts\";\n\nexport interface InitialMessageInput {\n\tparsed: Args;\n\tfileText?: string;\n\tfileImages?: ImageContent[];\n\tstdinContent?: string;\n}\n\nexport interface InitialMessageResult {\n\tinitialMessage?: string;\n\tinitialImages?: ImageContent[];\n}\n\n/**\n * Combine stdin content, @file text, and the first CLI message into a single\n * initial prompt for non-interactive mode.\n */\nexport function buildInitialMessage({\n\tparsed,\n\tfileText,\n\tfileImages,\n\tstdinContent,\n}: InitialMessageInput): InitialMessageResult {\n\tconst parts: string[] = [];\n\tif (stdinContent !== undefined) {\n\t\tparts.push(stdinContent);\n\t}\n\tif (fileText) {\n\t\tparts.push(fileText);\n\t}\n\n\tif (parsed.messages.length > 0) {\n\t\tparts.push(parsed.messages[0]);\n\t\tparsed.messages.shift();\n\t}\n\n\treturn {\n\t\tinitialMessage: parts.length > 0 ? parts.join(\"\") : undefined,\n\t\tinitialImages: fileImages && fileImages.length > 0 ? fileImages : undefined,\n\t};\n}\n"]}
1
+ {"version":3,"file":"initial-message.js","sourceRoot":"","sources":["../../src/cli/initial-message.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EACnC,MAAM,EACN,QAAQ,EACR,UAAU,EACV,YAAY,GACS,EAAwB;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,eAAe,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAChE,KAAK,CAAC,IAAI,CAAC,YAAY,YAAY,GAAG,eAAe,YAAY,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,OAAO;QACN,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7D,aAAa,EAAE,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KAC3E,CAAC;AAAA,CACF","sourcesContent":["import type { ImageContent } from \"omk-ai\";\nimport type { Args } from \"./args.ts\";\n\nexport interface InitialMessageInput {\n\tparsed: Args;\n\tfileText?: string;\n\tfileImages?: ImageContent[];\n\tstdinContent?: string;\n}\n\nexport interface InitialMessageResult {\n\tinitialMessage?: string;\n\tinitialImages?: ImageContent[];\n}\n\n/**\n * Combine stdin content, @file text, and the first CLI message into a single\n * initial prompt for non-interactive mode.\n */\nexport function buildInitialMessage({\n\tparsed,\n\tfileText,\n\tfileImages,\n\tstdinContent,\n}: InitialMessageInput): InitialMessageResult {\n\tconst parts: string[] = [];\n\tif (stdinContent !== undefined) {\n\t\tconst trailingNewline = stdinContent.endsWith(\"\\n\") ? \"\" : \"\\n\";\n\t\tparts.push(`<stdin>\\n${stdinContent}${trailingNewline}</stdin>\\n`);\n\t}\n\tif (fileText) {\n\t\tparts.push(fileText);\n\t}\n\n\tif (parsed.messages.length > 0) {\n\t\tparts.push(parsed.messages[0]);\n\t\tparsed.messages.shift();\n\t}\n\n\treturn {\n\t\tinitialMessage: parts.length > 0 ? parts.join(\"\") : undefined,\n\t\tinitialImages: fileImages && fileImages.length > 0 ? fileImages : undefined,\n\t};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare function resolveCliPaths(cwd: string, paths: readonly string[] | undefined): string[] | undefined;
2
+ /** Classify an extension load error against explicit CLI sources, failing closed for opaque package sources. */
3
+ export declare function isExplicitExtensionDiagnostic(errorPath: string, explicitSources: readonly string[] | undefined): boolean;
4
+ //# sourceMappingURL=resource-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-paths.d.ts","sourceRoot":"","sources":["../../src/cli/resource-paths.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAEvG;AAED,gHAAgH;AAChH,wBAAgB,6BAA6B,CAC5C,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAC5C,OAAO,CAyBT","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { isLocalPath, resolvePath } from \"../utils/paths.ts\";\n\nexport function resolveCliPaths(cwd: string, paths: readonly string[] | undefined): string[] | undefined {\n\treturn paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));\n}\n\n/** Classify an extension load error against explicit CLI sources, failing closed for opaque package sources. */\nexport function isExplicitExtensionDiagnostic(\n\terrorPath: string,\n\texplicitSources: readonly string[] | undefined,\n): boolean {\n\tif (/^<inline:\\d+>$/u.test(errorPath)) return true;\n\tif (!explicitSources || explicitSources.length === 0) return false;\n\tconst error = canonicalPath(errorPath);\n\tlet hasOpaqueSource = false;\n\tfor (const source of explicitSources) {\n\t\tif (!isLocalPath(source)) {\n\t\t\thasOpaqueSource = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolvedSource = resolvePath(source);\n\t\tconst sourceStat = statOrNull(resolvedSource);\n\t\tif (sourceStat?.isDirectory()) {\n\t\t\tif (isWithin(canonicalPath(resolvedSource), error)) return true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (sourceStat?.isFile() && path.basename(resolvedSource) === \"package.json\") {\n\t\t\tif (isWithin(canonicalPath(path.dirname(resolvedSource)), error)) return true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (canonicalPath(resolvedSource) === error) return true;\n\t}\n\t// Provenance is unavailable for unmatched loader paths. When the user supplied\n\t// any explicit source, fail closed rather than downgrading its error.\n\treturn hasOpaqueSource || explicitSources.length > 0;\n}\n\nfunction canonicalPath(value: string): string {\n\ttry {\n\t\treturn fs.realpathSync(value);\n\t} catch {\n\t\treturn resolvePath(value);\n\t}\n}\n\nfunction statOrNull(value: string): fs.Stats | null {\n\ttry {\n\t\treturn fs.statSync(value);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n\tconst relative = path.relative(root, candidate);\n\treturn relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n"]}
@@ -0,0 +1,59 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { isLocalPath, resolvePath } from "../utils/paths.js";
4
+ export function resolveCliPaths(cwd, paths) {
5
+ return paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));
6
+ }
7
+ /** Classify an extension load error against explicit CLI sources, failing closed for opaque package sources. */
8
+ export function isExplicitExtensionDiagnostic(errorPath, explicitSources) {
9
+ if (/^<inline:\d+>$/u.test(errorPath))
10
+ return true;
11
+ if (!explicitSources || explicitSources.length === 0)
12
+ return false;
13
+ const error = canonicalPath(errorPath);
14
+ let hasOpaqueSource = false;
15
+ for (const source of explicitSources) {
16
+ if (!isLocalPath(source)) {
17
+ hasOpaqueSource = true;
18
+ continue;
19
+ }
20
+ const resolvedSource = resolvePath(source);
21
+ const sourceStat = statOrNull(resolvedSource);
22
+ if (sourceStat?.isDirectory()) {
23
+ if (isWithin(canonicalPath(resolvedSource), error))
24
+ return true;
25
+ continue;
26
+ }
27
+ if (sourceStat?.isFile() && path.basename(resolvedSource) === "package.json") {
28
+ if (isWithin(canonicalPath(path.dirname(resolvedSource)), error))
29
+ return true;
30
+ continue;
31
+ }
32
+ if (canonicalPath(resolvedSource) === error)
33
+ return true;
34
+ }
35
+ // Provenance is unavailable for unmatched loader paths. When the user supplied
36
+ // any explicit source, fail closed rather than downgrading its error.
37
+ return hasOpaqueSource || explicitSources.length > 0;
38
+ }
39
+ function canonicalPath(value) {
40
+ try {
41
+ return fs.realpathSync(value);
42
+ }
43
+ catch {
44
+ return resolvePath(value);
45
+ }
46
+ }
47
+ function statOrNull(value) {
48
+ try {
49
+ return fs.statSync(value);
50
+ }
51
+ catch {
52
+ return null;
53
+ }
54
+ }
55
+ function isWithin(root, candidate) {
56
+ const relative = path.relative(root, candidate);
57
+ return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
58
+ }
59
+ //# sourceMappingURL=resource-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-paths.js","sourceRoot":"","sources":["../../src/cli/resource-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,KAAoC,EAAwB;IACxG,OAAO,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAAA,CACrF;AAED,gHAAgH;AAChH,MAAM,UAAU,6BAA6B,CAC5C,SAAiB,EACjB,eAA8C,EACpC;IACV,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnE,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;QACtC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,eAAe,GAAG,IAAI,CAAC;YACvB,SAAS;QACV,CAAC;QACD,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC;YAC/B,IAAI,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAChE,SAAS;QACV,CAAC;QACD,IAAI,UAAU,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,cAAc,EAAE,CAAC;YAC9E,IAAI,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC9E,SAAS;QACV,CAAC;QACD,IAAI,aAAa,CAAC,cAAc,CAAC,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC;IAC1D,CAAC;IACD,+EAA+E;IAC/E,sEAAsE;IACtE,OAAO,eAAe,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AAAA,CACrD;AAED,SAAS,aAAa,CAAC,KAAa,EAAU;IAC7C,IAAI,CAAC;QACJ,OAAO,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AAAA,CACD;AAED,SAAS,UAAU,CAAC,KAAa,EAAmB;IACnD,IAAI,CAAC;QACJ,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AAAA,CACD;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,SAAiB,EAAW;IAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChD,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AAAA,CACrF","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { isLocalPath, resolvePath } from \"../utils/paths.ts\";\n\nexport function resolveCliPaths(cwd: string, paths: readonly string[] | undefined): string[] | undefined {\n\treturn paths?.map((value) => (isLocalPath(value) ? resolvePath(value, cwd) : value));\n}\n\n/** Classify an extension load error against explicit CLI sources, failing closed for opaque package sources. */\nexport function isExplicitExtensionDiagnostic(\n\terrorPath: string,\n\texplicitSources: readonly string[] | undefined,\n): boolean {\n\tif (/^<inline:\\d+>$/u.test(errorPath)) return true;\n\tif (!explicitSources || explicitSources.length === 0) return false;\n\tconst error = canonicalPath(errorPath);\n\tlet hasOpaqueSource = false;\n\tfor (const source of explicitSources) {\n\t\tif (!isLocalPath(source)) {\n\t\t\thasOpaqueSource = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolvedSource = resolvePath(source);\n\t\tconst sourceStat = statOrNull(resolvedSource);\n\t\tif (sourceStat?.isDirectory()) {\n\t\t\tif (isWithin(canonicalPath(resolvedSource), error)) return true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (sourceStat?.isFile() && path.basename(resolvedSource) === \"package.json\") {\n\t\t\tif (isWithin(canonicalPath(path.dirname(resolvedSource)), error)) return true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (canonicalPath(resolvedSource) === error) return true;\n\t}\n\t// Provenance is unavailable for unmatched loader paths. When the user supplied\n\t// any explicit source, fail closed rather than downgrading its error.\n\treturn hasOpaqueSource || explicitSources.length > 0;\n}\n\nfunction canonicalPath(value: string): string {\n\ttry {\n\t\treturn fs.realpathSync(value);\n\t} catch {\n\t\treturn resolvePath(value);\n\t}\n}\n\nfunction statOrNull(value: string): fs.Stats | null {\n\ttry {\n\t\treturn fs.statSync(value);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n\tconst relative = path.relative(root, candidate);\n\treturn relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { type AdaptOrchFetch } from "omk-adaptorch-wpl";
2
+ export interface AdaptOrchDoctorCliOverrides {
3
+ readonly env?: NodeJS.ProcessEnv;
4
+ readonly writeLine?: (line: string) => void;
5
+ /** Test seam: replaces the injected HTTP boundary (defaults to global fetch). */
6
+ readonly fetch?: AdaptOrchFetch;
7
+ }
8
+ export interface AdaptOrchDoctorCliOutcome {
9
+ readonly handled: boolean;
10
+ readonly exitCode: number;
11
+ }
12
+ export declare function runAdaptOrchDoctorCli(args: readonly string[], overrides?: AdaptOrchDoctorCliOverrides): Promise<AdaptOrchDoctorCliOutcome>;
13
+ //# sourceMappingURL=adaptorch-doctor-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptorch-doctor-cli.d.ts","sourceRoot":"","sources":["../../src/commands/adaptorch-doctor-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,cAAc,EAEnB,MAAM,mBAAmB,CAAC;AA+B3B,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,iFAAiF;IACjF,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AA0DD,wBAAsB,qBAAqB,CAC1C,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,GAAE,2BAAgC,GACzC,OAAO,CAAC,yBAAyB,CAAC,CA2CpC","sourcesContent":["import {\n\ttype AdaptOrchApiClient,\n\tAdaptOrchApiError,\n\ttype AdaptOrchFetch,\n\tcreateAdaptOrchApiClientFromEnv,\n} from \"omk-adaptorch-wpl\";\n\n/**\n * Headless AdaptOrch connectivity check:\n *\n * omk doctor adaptorch [--json]\n *\n * One command answers the only question that blocks getting started: does the\n * configured key reach the hosted API? It calls `GET /v1/whoami`, which is the\n * cheapest authenticated read in the contract, and reports the principal it\n * resolved to.\n *\n * The exit code carries the verdict so a script can branch without parsing\n * prose: 0 verified, 1 not configured, 2 configured but unreachable. Those are\n * genuinely different states — \"no key\" is a setup step, while \"key rejected\"\n * is a broken setup, and collapsing them would make the command useless in CI.\n *\n * The credential is never printed. `omk-adaptorch-wpl` already scrubs it from\n * its own errors; this command additionally never echoes the configured value.\n */\n\nconst USAGE = \"Usage: omk doctor adaptorch [--json]\";\n\n/**\n * Where to obtain a key. This is the one moment in the CLI where the reader has\n * explicitly asked about AdaptOrch, so answering \"which key, from where\" here\n * is help rather than promotion. It carries its own attribution so this\n * touchpoint stays distinguishable from the README links.\n */\nconst ADAPTORCH_SIGNUP_URL = \"https://adaptorch.com/?utm_source=omk-cli&utm_medium=doctor&utm_campaign=omk#pricing\";\n\nexport interface AdaptOrchDoctorCliOverrides {\n\treadonly env?: NodeJS.ProcessEnv;\n\treadonly writeLine?: (line: string) => void;\n\t/** Test seam: replaces the injected HTTP boundary (defaults to global fetch). */\n\treadonly fetch?: AdaptOrchFetch;\n}\n\nexport interface AdaptOrchDoctorCliOutcome {\n\treadonly handled: boolean;\n\treadonly exitCode: number;\n}\n\n/** Bounded report shape. Carries no credential, URL credentials, or raw error bodies. */\ninterface AdaptOrchDoctorReport {\n\treadonly configured: boolean;\n\treadonly reachable: boolean;\n\treadonly subjectId?: string;\n\treadonly projectId?: string;\n\treadonly status?: number;\n\treadonly code?: string;\n\treadonly error?: string;\n}\n\nfunction describe(report: AdaptOrchDoctorReport): string[] {\n\tif (!report.configured) {\n\t\treturn [\n\t\t\t\"AdaptOrch: not configured\",\n\t\t\t\" Set ADAPTORCH_API_KEY to enable it. Optionally set ADAPTORCH_API_URL.\",\n\t\t\t` Get a key: ${ADAPTORCH_SIGNUP_URL}`,\n\t\t\t\" AdaptOrch is a separate product; OMK does not require it.\",\n\t\t];\n\t}\n\tif (!report.reachable) {\n\t\tconst detail =\n\t\t\treport.status === undefined ? \"\" : ` (HTTP ${report.status}${report.code ? ` ${report.code}` : \"\"})`;\n\t\treturn [`AdaptOrch: unreachable${detail}`, ` ${report.error ?? \"the request did not complete\"}`];\n\t}\n\tconst scope = report.projectId ? `, project ${report.projectId}` : \"\";\n\treturn [`AdaptOrch: verified`, ` Authenticated as ${report.subjectId ?? \"(unknown subject)\"}${scope}`];\n}\n\nasync function probe(client: AdaptOrchApiClient): Promise<AdaptOrchDoctorReport> {\n\ttry {\n\t\tconst principal = await client.whoami();\n\t\treturn {\n\t\t\tconfigured: true,\n\t\t\treachable: true,\n\t\t\tsubjectId: principal.subject_id,\n\t\t\t...(principal.project_id === undefined ? {} : { projectId: principal.project_id }),\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof AdaptOrchApiError) {\n\t\t\treturn {\n\t\t\t\tconfigured: true,\n\t\t\t\treachable: false,\n\t\t\t\tstatus: error.status,\n\t\t\t\t...(error.code === undefined ? {} : { code: error.code }),\n\t\t\t\terror: error.message,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tconfigured: true,\n\t\t\treachable: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n}\n\nexport async function runAdaptOrchDoctorCli(\n\targs: readonly string[],\n\toverrides: AdaptOrchDoctorCliOverrides = {},\n): Promise<AdaptOrchDoctorCliOutcome> {\n\tif (args[0] !== \"doctor\" || args[1] !== \"adaptorch\") {\n\t\treturn { handled: false, exitCode: 0 };\n\t}\n\tconst writeLine = overrides.writeLine ?? ((line: string) => console.log(line));\n\n\tlet json = false;\n\tfor (const arg of args.slice(2)) {\n\t\tif (arg === \"--json\") {\n\t\t\tjson = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--help\" || arg === \"-h\") {\n\t\t\twriteLine(USAGE);\n\t\t\treturn { handled: true, exitCode: 0 };\n\t\t}\n\t\twriteLine(`Unknown option: ${arg}`);\n\t\twriteLine(USAGE);\n\t\treturn { handled: true, exitCode: 2 };\n\t}\n\n\tconst env = overrides.env ?? process.env;\n\tconst fetchImpl = overrides.fetch ?? (globalThis.fetch as unknown as AdaptOrchFetch);\n\n\tlet report: AdaptOrchDoctorReport;\n\ttry {\n\t\tconst client = createAdaptOrchApiClientFromEnv(fetchImpl, env);\n\t\treport = client ? await probe(client) : { configured: false, reachable: false };\n\t} catch (error) {\n\t\t// A configured but invalid setup (an unsafe ADAPTORCH_API_URL, for\n\t\t// example) is a broken setup, not an absent one.\n\t\treport = {\n\t\t\tconfigured: true,\n\t\t\treachable: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n\n\tif (json) writeLine(JSON.stringify(report, null, 2));\n\telse for (const line of describe(report)) writeLine(line);\n\n\tif (!report.configured) return { handled: true, exitCode: 1 };\n\treturn { handled: true, exitCode: report.reachable ? 0 : 2 };\n}\n"]}
@@ -0,0 +1,115 @@
1
+ import { AdaptOrchApiError, createAdaptOrchApiClientFromEnv, } from "omk-adaptorch-wpl";
2
+ /**
3
+ * Headless AdaptOrch connectivity check:
4
+ *
5
+ * omk doctor adaptorch [--json]
6
+ *
7
+ * One command answers the only question that blocks getting started: does the
8
+ * configured key reach the hosted API? It calls `GET /v1/whoami`, which is the
9
+ * cheapest authenticated read in the contract, and reports the principal it
10
+ * resolved to.
11
+ *
12
+ * The exit code carries the verdict so a script can branch without parsing
13
+ * prose: 0 verified, 1 not configured, 2 configured but unreachable. Those are
14
+ * genuinely different states — "no key" is a setup step, while "key rejected"
15
+ * is a broken setup, and collapsing them would make the command useless in CI.
16
+ *
17
+ * The credential is never printed. `omk-adaptorch-wpl` already scrubs it from
18
+ * its own errors; this command additionally never echoes the configured value.
19
+ */
20
+ const USAGE = "Usage: omk doctor adaptorch [--json]";
21
+ /**
22
+ * Where to obtain a key. This is the one moment in the CLI where the reader has
23
+ * explicitly asked about AdaptOrch, so answering "which key, from where" here
24
+ * is help rather than promotion. It carries its own attribution so this
25
+ * touchpoint stays distinguishable from the README links.
26
+ */
27
+ const ADAPTORCH_SIGNUP_URL = "https://adaptorch.com/?utm_source=omk-cli&utm_medium=doctor&utm_campaign=omk#pricing";
28
+ function describe(report) {
29
+ if (!report.configured) {
30
+ return [
31
+ "AdaptOrch: not configured",
32
+ " Set ADAPTORCH_API_KEY to enable it. Optionally set ADAPTORCH_API_URL.",
33
+ ` Get a key: ${ADAPTORCH_SIGNUP_URL}`,
34
+ " AdaptOrch is a separate product; OMK does not require it.",
35
+ ];
36
+ }
37
+ if (!report.reachable) {
38
+ const detail = report.status === undefined ? "" : ` (HTTP ${report.status}${report.code ? ` ${report.code}` : ""})`;
39
+ return [`AdaptOrch: unreachable${detail}`, ` ${report.error ?? "the request did not complete"}`];
40
+ }
41
+ const scope = report.projectId ? `, project ${report.projectId}` : "";
42
+ return [`AdaptOrch: verified`, ` Authenticated as ${report.subjectId ?? "(unknown subject)"}${scope}`];
43
+ }
44
+ async function probe(client) {
45
+ try {
46
+ const principal = await client.whoami();
47
+ return {
48
+ configured: true,
49
+ reachable: true,
50
+ subjectId: principal.subject_id,
51
+ ...(principal.project_id === undefined ? {} : { projectId: principal.project_id }),
52
+ };
53
+ }
54
+ catch (error) {
55
+ if (error instanceof AdaptOrchApiError) {
56
+ return {
57
+ configured: true,
58
+ reachable: false,
59
+ status: error.status,
60
+ ...(error.code === undefined ? {} : { code: error.code }),
61
+ error: error.message,
62
+ };
63
+ }
64
+ return {
65
+ configured: true,
66
+ reachable: false,
67
+ error: error instanceof Error ? error.message : String(error),
68
+ };
69
+ }
70
+ }
71
+ export async function runAdaptOrchDoctorCli(args, overrides = {}) {
72
+ if (args[0] !== "doctor" || args[1] !== "adaptorch") {
73
+ return { handled: false, exitCode: 0 };
74
+ }
75
+ const writeLine = overrides.writeLine ?? ((line) => console.log(line));
76
+ let json = false;
77
+ for (const arg of args.slice(2)) {
78
+ if (arg === "--json") {
79
+ json = true;
80
+ continue;
81
+ }
82
+ if (arg === "--help" || arg === "-h") {
83
+ writeLine(USAGE);
84
+ return { handled: true, exitCode: 0 };
85
+ }
86
+ writeLine(`Unknown option: ${arg}`);
87
+ writeLine(USAGE);
88
+ return { handled: true, exitCode: 2 };
89
+ }
90
+ const env = overrides.env ?? process.env;
91
+ const fetchImpl = overrides.fetch ?? globalThis.fetch;
92
+ let report;
93
+ try {
94
+ const client = createAdaptOrchApiClientFromEnv(fetchImpl, env);
95
+ report = client ? await probe(client) : { configured: false, reachable: false };
96
+ }
97
+ catch (error) {
98
+ // A configured but invalid setup (an unsafe ADAPTORCH_API_URL, for
99
+ // example) is a broken setup, not an absent one.
100
+ report = {
101
+ configured: true,
102
+ reachable: false,
103
+ error: error instanceof Error ? error.message : String(error),
104
+ };
105
+ }
106
+ if (json)
107
+ writeLine(JSON.stringify(report, null, 2));
108
+ else
109
+ for (const line of describe(report))
110
+ writeLine(line);
111
+ if (!report.configured)
112
+ return { handled: true, exitCode: 1 };
113
+ return { handled: true, exitCode: report.reachable ? 0 : 2 };
114
+ }
115
+ //# sourceMappingURL=adaptorch-doctor-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptorch-doctor-cli.js","sourceRoot":"","sources":["../../src/commands/adaptorch-doctor-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,iBAAiB,EAEjB,+BAA+B,GAC/B,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,KAAK,GAAG,sCAAsC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,sFAAsF,CAAC;AAyBpH,SAAS,QAAQ,CAAC,MAA6B,EAAY;IAC1D,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO;YACN,2BAA2B;YAC3B,yEAAyE;YACzE,gBAAgB,oBAAoB,EAAE;YACtC,6DAA6D;SAC7D,CAAC;IACH,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,MAAM,GACX,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACtG,OAAO,CAAC,yBAAyB,MAAM,EAAE,EAAE,KAAK,MAAM,CAAC,KAAK,IAAI,8BAA8B,EAAE,CAAC,CAAC;IACnG,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,qBAAqB,EAAE,sBAAsB,MAAM,CAAC,SAAS,IAAI,mBAAmB,GAAG,KAAK,EAAE,CAAC,CAAC;AAAA,CACxG;AAED,KAAK,UAAU,KAAK,CAAC,MAA0B,EAAkC;IAChF,IAAI,CAAC;QACJ,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QACxC,OAAO;YACN,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,SAAS,CAAC,UAAU;YAC/B,GAAG,CAAC,SAAS,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC;SAClF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;YACxC,OAAO;gBACN,UAAU,EAAE,IAAI;gBAChB,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;gBACzD,KAAK,EAAE,KAAK,CAAC,OAAO;aACpB,CAAC;QACH,CAAC;QACD,OAAO;YACN,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC7D,CAAC;IACH,CAAC;AAAA,CACD;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,IAAuB,EACvB,SAAS,GAAgC,EAAE,EACN;IACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,EAAE,CAAC;QACrD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAE/E,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;YACtB,IAAI,GAAG,IAAI,CAAC;YACZ,SAAS;QACV,CAAC;QACD,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACtC,SAAS,CAAC,KAAK,CAAC,CAAC;YACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QACvC,CAAC;QACD,SAAS,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;QACpC,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACzC,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,IAAK,UAAU,CAAC,KAAmC,CAAC;IAErF,IAAI,MAA6B,CAAC;IAClC,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,+BAA+B,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAC/D,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACjF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,mEAAmE;QACnE,iDAAiD;QACjD,MAAM,GAAG;YACR,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC7D,CAAC;IACH,CAAC;IAED,IAAI,IAAI;QAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;;QAChD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC;YAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAE1D,IAAI,CAAC,MAAM,CAAC,UAAU;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAAA,CAC7D","sourcesContent":["import {\n\ttype AdaptOrchApiClient,\n\tAdaptOrchApiError,\n\ttype AdaptOrchFetch,\n\tcreateAdaptOrchApiClientFromEnv,\n} from \"omk-adaptorch-wpl\";\n\n/**\n * Headless AdaptOrch connectivity check:\n *\n * omk doctor adaptorch [--json]\n *\n * One command answers the only question that blocks getting started: does the\n * configured key reach the hosted API? It calls `GET /v1/whoami`, which is the\n * cheapest authenticated read in the contract, and reports the principal it\n * resolved to.\n *\n * The exit code carries the verdict so a script can branch without parsing\n * prose: 0 verified, 1 not configured, 2 configured but unreachable. Those are\n * genuinely different states — \"no key\" is a setup step, while \"key rejected\"\n * is a broken setup, and collapsing them would make the command useless in CI.\n *\n * The credential is never printed. `omk-adaptorch-wpl` already scrubs it from\n * its own errors; this command additionally never echoes the configured value.\n */\n\nconst USAGE = \"Usage: omk doctor adaptorch [--json]\";\n\n/**\n * Where to obtain a key. This is the one moment in the CLI where the reader has\n * explicitly asked about AdaptOrch, so answering \"which key, from where\" here\n * is help rather than promotion. It carries its own attribution so this\n * touchpoint stays distinguishable from the README links.\n */\nconst ADAPTORCH_SIGNUP_URL = \"https://adaptorch.com/?utm_source=omk-cli&utm_medium=doctor&utm_campaign=omk#pricing\";\n\nexport interface AdaptOrchDoctorCliOverrides {\n\treadonly env?: NodeJS.ProcessEnv;\n\treadonly writeLine?: (line: string) => void;\n\t/** Test seam: replaces the injected HTTP boundary (defaults to global fetch). */\n\treadonly fetch?: AdaptOrchFetch;\n}\n\nexport interface AdaptOrchDoctorCliOutcome {\n\treadonly handled: boolean;\n\treadonly exitCode: number;\n}\n\n/** Bounded report shape. Carries no credential, URL credentials, or raw error bodies. */\ninterface AdaptOrchDoctorReport {\n\treadonly configured: boolean;\n\treadonly reachable: boolean;\n\treadonly subjectId?: string;\n\treadonly projectId?: string;\n\treadonly status?: number;\n\treadonly code?: string;\n\treadonly error?: string;\n}\n\nfunction describe(report: AdaptOrchDoctorReport): string[] {\n\tif (!report.configured) {\n\t\treturn [\n\t\t\t\"AdaptOrch: not configured\",\n\t\t\t\" Set ADAPTORCH_API_KEY to enable it. Optionally set ADAPTORCH_API_URL.\",\n\t\t\t` Get a key: ${ADAPTORCH_SIGNUP_URL}`,\n\t\t\t\" AdaptOrch is a separate product; OMK does not require it.\",\n\t\t];\n\t}\n\tif (!report.reachable) {\n\t\tconst detail =\n\t\t\treport.status === undefined ? \"\" : ` (HTTP ${report.status}${report.code ? ` ${report.code}` : \"\"})`;\n\t\treturn [`AdaptOrch: unreachable${detail}`, ` ${report.error ?? \"the request did not complete\"}`];\n\t}\n\tconst scope = report.projectId ? `, project ${report.projectId}` : \"\";\n\treturn [`AdaptOrch: verified`, ` Authenticated as ${report.subjectId ?? \"(unknown subject)\"}${scope}`];\n}\n\nasync function probe(client: AdaptOrchApiClient): Promise<AdaptOrchDoctorReport> {\n\ttry {\n\t\tconst principal = await client.whoami();\n\t\treturn {\n\t\t\tconfigured: true,\n\t\t\treachable: true,\n\t\t\tsubjectId: principal.subject_id,\n\t\t\t...(principal.project_id === undefined ? {} : { projectId: principal.project_id }),\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof AdaptOrchApiError) {\n\t\t\treturn {\n\t\t\t\tconfigured: true,\n\t\t\t\treachable: false,\n\t\t\t\tstatus: error.status,\n\t\t\t\t...(error.code === undefined ? {} : { code: error.code }),\n\t\t\t\terror: error.message,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tconfigured: true,\n\t\t\treachable: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n}\n\nexport async function runAdaptOrchDoctorCli(\n\targs: readonly string[],\n\toverrides: AdaptOrchDoctorCliOverrides = {},\n): Promise<AdaptOrchDoctorCliOutcome> {\n\tif (args[0] !== \"doctor\" || args[1] !== \"adaptorch\") {\n\t\treturn { handled: false, exitCode: 0 };\n\t}\n\tconst writeLine = overrides.writeLine ?? ((line: string) => console.log(line));\n\n\tlet json = false;\n\tfor (const arg of args.slice(2)) {\n\t\tif (arg === \"--json\") {\n\t\t\tjson = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--help\" || arg === \"-h\") {\n\t\t\twriteLine(USAGE);\n\t\t\treturn { handled: true, exitCode: 0 };\n\t\t}\n\t\twriteLine(`Unknown option: ${arg}`);\n\t\twriteLine(USAGE);\n\t\treturn { handled: true, exitCode: 2 };\n\t}\n\n\tconst env = overrides.env ?? process.env;\n\tconst fetchImpl = overrides.fetch ?? (globalThis.fetch as unknown as AdaptOrchFetch);\n\n\tlet report: AdaptOrchDoctorReport;\n\ttry {\n\t\tconst client = createAdaptOrchApiClientFromEnv(fetchImpl, env);\n\t\treport = client ? await probe(client) : { configured: false, reachable: false };\n\t} catch (error) {\n\t\t// A configured but invalid setup (an unsafe ADAPTORCH_API_URL, for\n\t\t// example) is a broken setup, not an absent one.\n\t\treport = {\n\t\t\tconfigured: true,\n\t\t\treachable: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n\n\tif (json) writeLine(JSON.stringify(report, null, 2));\n\telse for (const line of describe(report)) writeLine(line);\n\n\tif (!report.configured) return { handled: true, exitCode: 1 };\n\treturn { handled: true, exitCode: report.reachable ? 0 : 2 };\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  import { captureHostResourceSnapshot } from "../core/host-resource-snapshot.ts";
2
2
  import { type ResourceGovernorSettings } from "../core/resource-governor-settings.ts";
3
+ import { collectResourceObservationReport, RESOURCE_REPORT_MIN_ADMISSIONS, type ResourceObservationReport } from "../core/resource-observation-report.ts";
4
+ export { collectResourceObservationReport, RESOURCE_REPORT_MIN_ADMISSIONS, type ResourceObservationReport };
3
5
  export interface ResourceDoctorCliOverrides {
4
6
  readonly cwd?: string;
5
7
  readonly env?: NodeJS.ProcessEnv;
@@ -13,6 +15,8 @@ export interface ResourceDoctorCliOverrides {
13
15
  readonly capture?: typeof captureHostResourceSnapshot;
14
16
  /** Test seam: monotonic clock for probeDurationMs. */
15
17
  readonly now?: () => number;
18
+ /** Test seam: replaces local observation aggregation. */
19
+ readonly collectReport?: (cwd: string) => ResourceObservationReport;
16
20
  }
17
21
  export interface ResourceDoctorCliOutcome {
18
22
  readonly handled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-doctor-cli.d.ts","sourceRoot":"","sources":["../../src/commands/resource-doctor-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAA6B,MAAM,mCAAmC,CAAC;AAE3G,OAAO,EAIN,KAAK,wBAAwB,EAE7B,MAAM,uCAAuC,CAAC;AAiB/C,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,sFAAsF;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM;QAC7B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;QACrD,QAAQ,CAAC,4BAA4B,CAAC,EAAE,MAAM,CAAC;KAC/C,CAAC;IACF,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,2BAA2B,CAAC;IACtD,sDAAsD;IACtD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,GAAE,0BAA+B,GACxC,OAAO,CAAC,wBAAwB,CAAC,CAsCnC","sourcesContent":["import { captureHostResourceSnapshot, type HostResourceSnapshot } from \"../core/host-resource-snapshot.ts\";\nimport { decideResourceAdmission } from \"../core/resource-admission.ts\";\nimport {\n\tbuildResourceDoctorReport,\n\tformatResourceProbeLines,\n\tformatResourceSummaryLines,\n\ttype ResourceGovernorSettings,\n\tresolveResourceGovernorSettings,\n} from \"../core/resource-governor-settings.ts\";\nimport { SettingsManager } from \"../core/settings-manager.ts\";\n\n/**\n * Headless resource diagnostic (OMK v0.97.x roadmap §19.2, M1/PR2):\n *\n * omk doctor resources [--json]\n *\n * Observe-only: probes the host, evaluates the admission policy, and prints\n * either aligned human output or the bounded §19.2 JSON schema. This command\n * is the sanctioned local surface for raw capacity values (§11.3); it still\n * never prints usernames, hostnames, or paths (§6.2). The doctor probes even\n * when the governor mode is `off` because it only runs on explicit request.\n */\n\nconst USAGE = \"Usage: omk doctor resources [--json]\";\n\nexport interface ResourceDoctorCliOverrides {\n\treadonly cwd?: string;\n\treadonly env?: NodeJS.ProcessEnv;\n\treadonly writeLine?: (line: string) => void;\n\t/** Test seam: replaces settings loading (defaults to SettingsManager.create(cwd)). */\n\treadonly loadSettings?: () => {\n\t\treadonly resourceGovernor?: ResourceGovernorSettings;\n\t\treadonly configuredMaxToolConcurrency?: number;\n\t};\n\t/** Test seam: replaces the host probe. */\n\treadonly capture?: typeof captureHostResourceSnapshot;\n\t/** Test seam: monotonic clock for probeDurationMs. */\n\treadonly now?: () => number;\n}\n\nexport interface ResourceDoctorCliOutcome {\n\treadonly handled: boolean;\n\treadonly exitCode: number;\n}\n\nexport async function runResourceDoctorCli(\n\targs: readonly string[],\n\toverrides: ResourceDoctorCliOverrides = {},\n): Promise<ResourceDoctorCliOutcome> {\n\tif (args[0] !== \"doctor\" || args[1] !== \"resources\") {\n\t\treturn { handled: false, exitCode: 0 };\n\t}\n\tconst writeLine = overrides.writeLine ?? ((line: string) => console.log(line));\n\n\tconst flags = parseDoctorFlags(args.slice(2), writeLine);\n\tif (flags.exit !== null) {\n\t\treturn { handled: true, exitCode: flags.exit };\n\t}\n\tconst json = flags.json;\n\n\tconst settings = (overrides.loadSettings ?? (() => loadSettingsFromDisk(overrides.cwd)))();\n\tconst resolved = resolveResourceGovernorSettings(settings.resourceGovernor, overrides.env ?? process.env);\n\n\tconst capture = overrides.capture ?? captureHostResourceSnapshot;\n\tconst now = overrides.now ?? (() => performance.now());\n\tconst startedAt = now();\n\tconst snapshot: HostResourceSnapshot = await capture({\n\t\tcwd: overrides.cwd,\n\t\tmaxProbeMs: resolved.maxProbeMs,\n\t\tcpuSampleMs: resolved.cpuSampleMs,\n\t});\n\tconst probeDurationMs = Math.max(0, now() - startedAt);\n\n\tconst decision = decideResourceAdmission({\n\t\tsnapshot,\n\t\tconfig: resolved.admission,\n\t\tconfiguredCaps: { maxToolConcurrency: settings.configuredMaxToolConcurrency },\n\t});\n\n\tif (json) {\n\t\tconst report = buildResourceDoctorReport({ snapshot, decision, resolved, probeDurationMs });\n\t\twriteLine(JSON.stringify(report, null, 2));\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\trenderHumanReport({ writeLine, resolved, decision, snapshot, probeDurationMs });\n\treturn { handled: true, exitCode: 0 };\n}\n\nfunction parseDoctorFlags(\n\targs: readonly string[],\n\twriteLine: (line: string) => void,\n): { readonly json: boolean; readonly exit: number | null } {\n\tlet json = false;\n\tfor (const arg of args) {\n\t\tif (arg === \"--json\") {\n\t\t\tjson = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--help\" || arg === \"-h\") {\n\t\t\twriteLine(USAGE);\n\t\t\treturn { json, exit: 0 };\n\t\t}\n\t\twriteLine(`Unknown argument: ${arg}`);\n\t\twriteLine(USAGE);\n\t\treturn { json, exit: 2 };\n\t}\n\treturn { json, exit: null };\n}\n\nfunction renderHumanReport(input: {\n\treadonly writeLine: (line: string) => void;\n\treadonly resolved: ReturnType<typeof resolveResourceGovernorSettings>;\n\treadonly decision: ReturnType<typeof decideResourceAdmission>;\n\treadonly snapshot: HostResourceSnapshot;\n\treadonly probeDurationMs: number;\n}): void {\n\tconst { writeLine, resolved, decision, snapshot, probeDurationMs } = input;\n\twriteLine(\"Resource doctor\");\n\twriteLine(\"\");\n\tfor (const line of formatResourceSummaryLines(resolved.mode, decision)) {\n\t\twriteLine(line);\n\t}\n\twriteLine(\"\");\n\tfor (const line of formatResourceProbeLines(snapshot)) {\n\t\twriteLine(line);\n\t}\n\twriteLine(\"\");\n\twriteLine(`probe duration: ${Math.round(probeDurationMs)} ms`);\n\tfor (const error of resolved.errors) {\n\t\twriteLine(`settings error: ${error}`);\n\t}\n}\n\nfunction loadSettingsFromDisk(cwd: string | undefined): {\n\treadonly resourceGovernor?: ResourceGovernorSettings;\n\treadonly configuredMaxToolConcurrency?: number;\n} {\n\ttry {\n\t\tconst manager = SettingsManager.create(cwd ?? process.cwd());\n\t\treturn {\n\t\t\tresourceGovernor: manager.getResourceGovernorSettings(),\n\t\t\tconfiguredMaxToolConcurrency: manager.getAgentRuntimeSettings().maxToolConcurrency,\n\t\t};\n\t} catch {\n\t\t// A broken settings file must not block the diagnostic; defaults apply.\n\t\treturn {};\n\t}\n}\n"]}
1
+ {"version":3,"file":"resource-doctor-cli.d.ts","sourceRoot":"","sources":["../../src/commands/resource-doctor-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAA6B,MAAM,mCAAmC,CAAC;AAE3G,OAAO,EAIN,KAAK,wBAAwB,EAE7B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,gCAAgC,EAChC,8BAA8B,EAC9B,KAAK,yBAAyB,EAC9B,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,KAAK,yBAAyB,EAAE,CAAC;AAgB5G,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,sFAAsF;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM;QAC7B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;QACrD,QAAQ,CAAC,4BAA4B,CAAC,EAAE,MAAM,CAAC;KAC/C,CAAC;IACF,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,2BAA2B,CAAC;IACtD,sDAAsD;IACtD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,yBAAyB,CAAC;CACpE;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,GAAE,0BAA+B,GACxC,OAAO,CAAC,wBAAwB,CAAC,CA4CnC","sourcesContent":["import { captureHostResourceSnapshot, type HostResourceSnapshot } from \"../core/host-resource-snapshot.ts\";\nimport { decideResourceAdmission } from \"../core/resource-admission.ts\";\nimport {\n\tbuildResourceDoctorReport,\n\tformatResourceProbeLines,\n\tformatResourceSummaryLines,\n\ttype ResourceGovernorSettings,\n\tresolveResourceGovernorSettings,\n} from \"../core/resource-governor-settings.ts\";\nimport {\n\tcollectResourceObservationReport,\n\tRESOURCE_REPORT_MIN_ADMISSIONS,\n\ttype ResourceObservationReport,\n} from \"../core/resource-observation-report.ts\";\nimport { SettingsManager } from \"../core/settings-manager.ts\";\n\nexport { collectResourceObservationReport, RESOURCE_REPORT_MIN_ADMISSIONS, type ResourceObservationReport };\n\n/**\n * Headless resource diagnostic (OMK v0.97.x roadmap §19.2, M1/PR2):\n *\n * omk doctor resources [--json] [--report]\n *\n * Observe-only: probes the host, evaluates the admission policy, and prints\n * either aligned human output or the bounded §19.2 JSON schema. This command\n * is the sanctioned local surface for raw capacity values (§11.3); it still\n * never prints usernames, hostnames, or paths (§6.2). The doctor probes even\n * when the governor mode is `off` because it only runs on explicit request.\n */\n\nconst USAGE = \"Usage: omk doctor resources [--json] [--report]\";\n\nexport interface ResourceDoctorCliOverrides {\n\treadonly cwd?: string;\n\treadonly env?: NodeJS.ProcessEnv;\n\treadonly writeLine?: (line: string) => void;\n\t/** Test seam: replaces settings loading (defaults to SettingsManager.create(cwd)). */\n\treadonly loadSettings?: () => {\n\t\treadonly resourceGovernor?: ResourceGovernorSettings;\n\t\treadonly configuredMaxToolConcurrency?: number;\n\t};\n\t/** Test seam: replaces the host probe. */\n\treadonly capture?: typeof captureHostResourceSnapshot;\n\t/** Test seam: monotonic clock for probeDurationMs. */\n\treadonly now?: () => number;\n\t/** Test seam: replaces local observation aggregation. */\n\treadonly collectReport?: (cwd: string) => ResourceObservationReport;\n}\n\nexport interface ResourceDoctorCliOutcome {\n\treadonly handled: boolean;\n\treadonly exitCode: number;\n}\n\nexport async function runResourceDoctorCli(\n\targs: readonly string[],\n\toverrides: ResourceDoctorCliOverrides = {},\n): Promise<ResourceDoctorCliOutcome> {\n\tif (args[0] !== \"doctor\" || args[1] !== \"resources\") {\n\t\treturn { handled: false, exitCode: 0 };\n\t}\n\tconst writeLine = overrides.writeLine ?? ((line: string) => console.log(line));\n\n\tconst flags = parseDoctorFlags(args.slice(2), writeLine);\n\tif (flags.exit !== null) {\n\t\treturn { handled: true, exitCode: flags.exit };\n\t}\n\tconst json = flags.json;\n\tif (flags.report) {\n\t\tconst report = (overrides.collectReport ?? collectResourceObservationReport)(overrides.cwd ?? process.cwd());\n\t\tif (json) writeLine(JSON.stringify(report, null, 2));\n\t\telse renderObservationReport(report, writeLine);\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\n\tconst settings = (overrides.loadSettings ?? (() => loadSettingsFromDisk(overrides.cwd)))();\n\tconst resolved = resolveResourceGovernorSettings(settings.resourceGovernor, overrides.env ?? process.env);\n\n\tconst capture = overrides.capture ?? captureHostResourceSnapshot;\n\tconst now = overrides.now ?? (() => performance.now());\n\tconst startedAt = now();\n\tconst snapshot: HostResourceSnapshot = await capture({\n\t\tcwd: overrides.cwd,\n\t\tmaxProbeMs: resolved.maxProbeMs,\n\t\tcpuSampleMs: resolved.cpuSampleMs,\n\t});\n\tconst probeDurationMs = Math.max(0, now() - startedAt);\n\n\tconst decision = decideResourceAdmission({\n\t\tsnapshot,\n\t\tconfig: resolved.admission,\n\t\tconfiguredCaps: { maxToolConcurrency: settings.configuredMaxToolConcurrency },\n\t});\n\n\tif (json) {\n\t\tconst report = buildResourceDoctorReport({ snapshot, decision, resolved, probeDurationMs });\n\t\twriteLine(JSON.stringify(report, null, 2));\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\trenderHumanReport({ writeLine, resolved, decision, snapshot, probeDurationMs });\n\treturn { handled: true, exitCode: 0 };\n}\n\nfunction parseDoctorFlags(\n\targs: readonly string[],\n\twriteLine: (line: string) => void,\n): { readonly json: boolean; readonly report: boolean; readonly exit: number | null } {\n\tlet json = false;\n\tlet report = false;\n\tfor (const arg of args) {\n\t\tif (arg === \"--json\") {\n\t\t\tjson = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--report\") {\n\t\t\treport = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--help\" || arg === \"-h\") {\n\t\t\twriteLine(USAGE);\n\t\t\treturn { json, report, exit: 0 };\n\t\t}\n\t\twriteLine(`Unknown argument: ${arg}`);\n\t\twriteLine(USAGE);\n\t\treturn { json, report, exit: 2 };\n\t}\n\treturn { json, report, exit: null };\n}\n\nfunction renderObservationReport(report: ResourceObservationReport, writeLine: (line: string) => void): void {\n\twriteLine(\"Resource observation report\");\n\twriteLine(`journals scanned: ${report.journalsScanned}${report.truncated ? \" (truncated)\" : \"\"}`);\n\twriteLine(`admission records: ${report.admissionRecords}`);\n\twriteLine(`reason-qualified records: ${report.reasonRecords}`);\n\twriteLine(\n\t\t`pressure: normal ${report.pressure.normal}, constrained ${report.pressure.constrained}, critical ${report.pressure.critical}`,\n\t);\n\twriteLine(\n\t\t`actions: allow ${report.actions.allow}, throttle ${report.actions.throttle}, defer-heavy ${report.actions[\"defer-heavy\"]}`,\n\t);\n\twriteLine(`would have throttled: ${report.wouldHaveThrottled}`);\n\twriteLine(`probe partial/timeout: ${report.probePartial}/${report.probeTimeout}`);\n\twriteLine(\n\t\t`minimum sample: ${report.reasonRecords}/${report.minimumSampleSize} (${report.minimumSampleMet ? \"met\" : \"not met\"})`,\n\t);\n\twriteLine(`reason coverage complete: ${report.reasonCoverageComplete ? \"yes\" : \"no\"}`);\n\twriteLine(\"human review: required\");\n\tif (report.diagnostics > 0) writeLine(`diagnostics: ${report.diagnostics}`);\n}\n\nfunction renderHumanReport(input: {\n\treadonly writeLine: (line: string) => void;\n\treadonly resolved: ReturnType<typeof resolveResourceGovernorSettings>;\n\treadonly decision: ReturnType<typeof decideResourceAdmission>;\n\treadonly snapshot: HostResourceSnapshot;\n\treadonly probeDurationMs: number;\n}): void {\n\tconst { writeLine, resolved, decision, snapshot, probeDurationMs } = input;\n\twriteLine(\"Resource doctor\");\n\twriteLine(\"\");\n\tfor (const line of formatResourceSummaryLines(resolved.mode, decision)) {\n\t\twriteLine(line);\n\t}\n\twriteLine(\"\");\n\tfor (const line of formatResourceProbeLines(snapshot)) {\n\t\twriteLine(line);\n\t}\n\twriteLine(\"\");\n\twriteLine(`probe duration: ${Math.round(probeDurationMs)} ms`);\n\tfor (const error of resolved.errors) {\n\t\twriteLine(`settings error: ${error}`);\n\t}\n}\n\nfunction loadSettingsFromDisk(cwd: string | undefined): {\n\treadonly resourceGovernor?: ResourceGovernorSettings;\n\treadonly configuredMaxToolConcurrency?: number;\n} {\n\ttry {\n\t\tconst manager = SettingsManager.create(cwd ?? process.cwd());\n\t\treturn {\n\t\t\tresourceGovernor: manager.getResourceGovernorSettings(),\n\t\t\tconfiguredMaxToolConcurrency: manager.getAgentRuntimeSettings().maxToolConcurrency,\n\t\t};\n\t} catch {\n\t\t// A broken settings file must not block the diagnostic; defaults apply.\n\t\treturn {};\n\t}\n}\n"]}