@wrongstack/cli 1.0.19 → 1.0.26

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 (195) hide show
  1. package/data/providers.json +44 -0
  2. package/dist/{acp-INCNOH42.js → acp-LI665LO2.js} +18 -7
  3. package/dist/arg-parser.d.ts +1 -0
  4. package/dist/ascii-mode-SG4PRNLP.js +7 -0
  5. package/dist/{auth-YXK3EDUL.js → auth-TE55JF4Z.js} +68 -22
  6. package/dist/auth-menu/direct.d.ts +1 -0
  7. package/dist/auth-menu/local.d.ts +2 -0
  8. package/dist/auth-menu/oauth-menu.d.ts +3 -1
  9. package/dist/auth-menu/panel-service.d.ts +20 -0
  10. package/dist/{bench-YBU6BVQP.js → bench-GTLPM22B.js} +2 -2
  11. package/dist/boot/append-system-prompt.d.ts +10 -0
  12. package/dist/boot/ascii-mode.d.ts +12 -0
  13. package/dist/boot/config-backup-recovery.d.ts +2 -1
  14. package/dist/boot/container-wiring.d.ts +4 -2
  15. package/dist/boot/dispatch-singleshot.d.ts +4 -1
  16. package/dist/boot/dispatch-webui.d.ts +11 -0
  17. package/dist/boot/mcp-config-flag.d.ts +22 -0
  18. package/dist/boot/piped-stdin.d.ts +40 -0
  19. package/dist/boot/restricted-mode.d.ts +15 -0
  20. package/dist/boot/safe-mode.d.ts +30 -0
  21. package/dist/boot/short-circuit-desktop.d.ts +1 -0
  22. package/dist/boot/single-shot-budget.d.ts +30 -0
  23. package/dist/boot/stream-json.d.ts +36 -0
  24. package/dist/boot/structured-output.d.ts +16 -0
  25. package/dist/boot/system-prompt-builder.d.ts +2 -0
  26. package/dist/boot/tool-restriction-flags.d.ts +36 -0
  27. package/dist/boot/tui-project-picker-callback.d.ts +1 -1
  28. package/dist/boot/tui-settings-adapter.d.ts +15 -2
  29. package/dist/boot/worktree-sessions.d.ts +21 -0
  30. package/dist/{boot-auto-thin-MANHOYHE.js → boot-auto-thin-6Q56FY3F.js} +3 -2
  31. package/dist/boot-provider-selection.d.ts +67 -0
  32. package/dist/boot.d.ts +1 -38
  33. package/dist/{chunk-JY52HWL6.js → chunk-2EBVTYJR.js} +2 -2
  34. package/dist/{chunk-RDHFXOJM.js → chunk-2ERX3RPN.js} +112 -65
  35. package/dist/chunk-4TVYGG6G.js +62 -0
  36. package/dist/chunk-5JYDKG5B.js +154 -0
  37. package/dist/{chunk-KEPABQYT.js → chunk-5SEYGOCH.js} +8 -82
  38. package/dist/{chunk-3VXYY5JC.js → chunk-5UZBUV2H.js} +3 -19
  39. package/dist/chunk-BBHWW6LR.js +549 -0
  40. package/dist/chunk-BEHGRNOQ.js +58 -0
  41. package/dist/chunk-CZTXF6HY.js +140 -0
  42. package/dist/{chunk-JX6KL7OF.js → chunk-EPR42SWM.js} +39 -8
  43. package/dist/chunk-F5DCFAKI.js +36 -0
  44. package/dist/chunk-HLSHFXTO.js +97 -0
  45. package/dist/{chunk-CJTBLTS4.js → chunk-KJS5543T.js} +4 -3
  46. package/dist/{chunk-DE7BZDNK.js → chunk-KOEO4CJG.js} +27 -4
  47. package/dist/{chunk-SIS37L3W.js → chunk-L2RVEQWO.js} +211 -193
  48. package/dist/chunk-LBPLTTZ6.js +105 -0
  49. package/dist/chunk-LDCGZJTC.js +46 -0
  50. package/dist/chunk-LKPEBZBE.js +143 -0
  51. package/dist/chunk-LUMETJFO.js +171 -0
  52. package/dist/{chunk-KK2LB3ZS.js → chunk-OAVBM55Q.js} +9 -5
  53. package/dist/chunk-PZQBGUVZ.js +18 -0
  54. package/dist/{chunk-C3Z4N6A6.js → chunk-Q4INH2DG.js} +51 -3
  55. package/dist/chunk-R4QGL6GB.js +10 -0
  56. package/dist/{chunk-YLQEGYV4.js → chunk-RZ4ZDRYA.js} +14 -4
  57. package/dist/chunk-S4FFHDJG.js +93 -0
  58. package/dist/chunk-SFBFYIOW.js +271 -0
  59. package/dist/{chunk-RMQNCHGO.js → chunk-TI7KLHYX.js} +136 -11
  60. package/dist/{chunk-2ENZU66X.js → chunk-WQV2NP57.js} +5 -5
  61. package/dist/{chunk-B4JLSXZB.js → chunk-WSTVGC2C.js} +73 -45
  62. package/dist/chunk-X756ZS72.js +329 -0
  63. package/dist/{chunk-XJ7K67PP.js → chunk-YHYINL47.js} +63 -24
  64. package/dist/{chunk-2VMJ3E5Z.js → chunk-YTEOAWOJ.js} +6 -2
  65. package/dist/{chunk-GPPRNAKW.js → chunk-ZMX5HRLI.js} +2 -2
  66. package/dist/{cli-context-33F74CSZ.js → cli-context-UVGAN3NO.js} +496 -384
  67. package/dist/cli-entry-point.d.ts +2 -0
  68. package/dist/{cli-main-FNGMKPBA.js → cli-main-TN3KZ2P6.js} +3561 -2724
  69. package/dist/cli-update-notice.d.ts +2 -1
  70. package/dist/config-doctor.d.ts +10 -2
  71. package/dist/{config-transfer-2YF3CRTN.js → config-transfer-RUWLDCNK.js} +34 -13
  72. package/dist/{diag-doctor-ANPRUYFM.js → diag-doctor-BIZAFIAT.js} +2 -2
  73. package/dist/execute-deps.d.ts +2 -1
  74. package/dist/{execution-A6WJLSOC.js → execution-7QIP6GRY.js} +2384 -2055
  75. package/dist/fleet/host-types.d.ts +3 -1
  76. package/dist/goal-commands.d.ts +47 -0
  77. package/dist/goal-host.d.ts +1 -14
  78. package/dist/{hq-XQWQTRDA.js → hq-GLZ7QESM.js} +277 -261
  79. package/dist/hq-command-controller.d.ts +1 -1
  80. package/dist/{hq-server-IIBZQZU4.js → hq-server-YTKDVQPY.js} +2 -2
  81. package/dist/{hq-service-L5INQFM4.js → hq-service-BMMJAHRT.js} +11 -4
  82. package/dist/import-claude-code-32PCSIQI.js +236 -0
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +19 -10
  85. package/dist/kanban-supervisor-67ECABTD.js +7 -0
  86. package/dist/live-settings-input.d.ts +7 -0
  87. package/dist/{mailbox-serve-3GFOK2I7.js → mailbox-serve-NW5VZG7R.js} +3 -3
  88. package/dist/{mcp-DC5WSBOO.js → mcp-LBS45HWZ.js} +4 -4
  89. package/dist/modeldiag-36VODVIH.js +828 -0
  90. package/dist/{per-subcommand-help-DHTYU524.js → per-subcommand-help-QDAQASPZ.js} +3 -3
  91. package/dist/permission-prompt-mirror.d.ts +1 -1
  92. package/dist/permission-prompt.d.ts +16 -2
  93. package/dist/permission-rules-view.d.ts +18 -0
  94. package/dist/{permissions-CFDLXETM.js → permissions-PL27UHYD.js} +67 -45
  95. package/dist/plugin-config.d.ts +12 -0
  96. package/dist/plugin-management-types.d.ts +31 -0
  97. package/dist/plugin-management.d.ts +2 -30
  98. package/dist/plugin-package-install.d.ts +3 -0
  99. package/dist/{plugin-usage-M6KET4OZ.js → plugin-usage-CIGOOTX3.js} +6 -5
  100. package/dist/{plugins-WJLW6ULV.js → plugins-HQTXUD6A.js} +6 -3
  101. package/dist/preflight.d.ts +1 -1
  102. package/dist/{projects-LMNAGGEU.js → projects-T4CZCA25.js} +3 -6
  103. package/dist/provider-config-utils.d.ts +1 -6
  104. package/dist/provider-helpers.d.ts +7 -11
  105. package/dist/{providers-models-LFNZ5WI7.js → providers-models-5Z2PJTEW.js} +44 -34
  106. package/dist/release-asset-download.d.ts +13 -0
  107. package/dist/release-attestation.d.ts +28 -0
  108. package/dist/remote/remote-session.d.ts +64 -0
  109. package/dist/remote/remote-target.d.ts +69 -0
  110. package/dist/remote-O5WXHLWV.js +561 -0
  111. package/dist/{replay-Z3FTJEMM.js → replay-DEI566CW.js} +2 -2
  112. package/dist/services/commit-message.d.ts +2 -1
  113. package/dist/services/dispatch-classifier.d.ts +39 -5
  114. package/dist/session-move-P2EC2COA.js +44 -0
  115. package/dist/session-move.d.ts +20 -0
  116. package/dist/session-stats.d.ts +10 -0
  117. package/dist/{sessions-config-UL45XKX7.js → sessions-config-SXTTLNXA.js} +47 -9
  118. package/dist/settings-menu.d.ts +2 -0
  119. package/dist/short-circuit-flags-74Y5N6CF.js +10 -0
  120. package/dist/{simpleui-dist-CXSIDAXZ.js → simpleui-dist-7BQISSEP.js} +7 -3
  121. package/dist/skill-suggest-L2EVWB6R.js +290 -0
  122. package/dist/slash-commands/command-context.d.ts +15 -5
  123. package/dist/slash-commands/effort.d.ts +1 -1
  124. package/dist/slash-commands/fallback.d.ts +1 -1
  125. package/dist/slash-commands/gitid.d.ts +1 -1
  126. package/dist/slash-commands/goal-refiner.d.ts +4 -49
  127. package/dist/slash-commands/jev.d.ts +4 -0
  128. package/dist/slash-commands/mcp.d.ts +2 -1
  129. package/dist/slash-commands/openai-quota.d.ts +15 -0
  130. package/dist/slash-commands/permissions.d.ts +4 -0
  131. package/dist/slash-commands/sdd-task-mutations.d.ts +4 -0
  132. package/dist/slash-commands/settings-context-mutations.d.ts +5 -0
  133. package/dist/slash-commands/settings-keys.d.ts +2 -0
  134. package/dist/slash-commands/settings-limits-mutations.d.ts +12 -0
  135. package/dist/slash-commands/settings-reset.d.ts +6 -0
  136. package/dist/standalone-auto-update-TOTRGCSA.js +249 -0
  137. package/dist/standalone-auto-update.d.ts +65 -0
  138. package/dist/standalone-update-LZO3MNLH.js +24 -0
  139. package/dist/standalone-update.d.ts +55 -0
  140. package/dist/subcommands/handlers/hq-alerts.d.ts +3 -0
  141. package/dist/subcommands/handlers/hq-audit.d.ts +46 -0
  142. package/dist/subcommands/handlers/hq-data-dir.d.ts +13 -0
  143. package/dist/subcommands/handlers/import-claude-code.d.ts +42 -0
  144. package/dist/subcommands/handlers/permissions.d.ts +9 -3
  145. package/dist/subcommands/handlers/remote.d.ts +6 -0
  146. package/dist/subcommands/handlers/skill-suggest.d.ts +21 -0
  147. package/dist/subcommands/handlers/typesafe-brain-replay.d.ts +26 -0
  148. package/dist/subcommands/handlers/typesafe-judgment-check.d.ts +3 -0
  149. package/dist/subcommands/handlers/typesafe-topic-replay.d.ts +19 -0
  150. package/dist/subcommands/handlers/typesafe-triage-replay.d.ts +18 -0
  151. package/dist/subcommands/handlers/typesafe.d.ts +23 -0
  152. package/dist/subcommands/handlers/version-help.d.ts +5 -0
  153. package/dist/{subcommands-XSLXMIDP.js → subcommands-Q6ORSB2E.js} +2 -2
  154. package/dist/tui-resume-callback.d.ts +18 -0
  155. package/dist/typesafe-U7YB2RRV.js +316 -0
  156. package/dist/typesafe-brain-replay-C5276FVR.js +222 -0
  157. package/dist/typesafe-judgment-check-GGYYV5UF.js +29 -0
  158. package/dist/typesafe-topic-replay-ZILIU3WS.js +234 -0
  159. package/dist/typesafe-triage-replay-FGAW7QM7.js +215 -0
  160. package/dist/{update-5DPB4YD4.js → update-TDZX4IL2.js} +4 -3
  161. package/dist/{update-check-BS3DHTSI.js → update-check-J5ZVKS73.js} +3 -2
  162. package/dist/update-check.d.ts +1 -1
  163. package/dist/version-JB2UAV2A.js +11 -0
  164. package/dist/version-help-XJJQ7YSH.js +10 -0
  165. package/dist/version.d.ts +3 -2
  166. package/dist/webui-client-observability.d.ts +7 -0
  167. package/dist/webui-server/route-contexts.d.ts +1 -1
  168. package/dist/webui-server/session-start-payload.d.ts +5 -1
  169. package/dist/{webui-server-MRPGTTKL.js → webui-server-YTHLRFD2.js} +577 -370
  170. package/dist/webui-server-lifecycle.d.ts +57 -0
  171. package/dist/webui-server-options.d.ts +11 -0
  172. package/dist/webui-server.d.ts +1 -1
  173. package/dist/wiring/brain-and-orchestration.d.ts +3 -1
  174. package/dist/wiring/cli-prompt-and-tools-setup.d.ts +9 -0
  175. package/dist/wiring/cli-slash-commands-setup.d.ts +1 -0
  176. package/dist/wiring/domain-glossary.d.ts +5 -4
  177. package/dist/wiring/lifecycle-plugins.d.ts +4 -2
  178. package/dist/wiring/metrics.d.ts +9 -1
  179. package/dist/wiring/pipeline.d.ts +2 -7
  180. package/dist/wiring/plugins.d.ts +4 -1
  181. package/dist/wiring/provider-persisters.d.ts +24 -0
  182. package/dist/wiring/provider-runtime.d.ts +9 -1
  183. package/dist/wiring/provider-status.d.ts +1 -0
  184. package/dist/wiring/provider-utility-tools.d.ts +3 -1
  185. package/dist/wiring/runtime-dispatch-state.d.ts +3 -1
  186. package/package.json +28 -28
  187. package/dist/chunk-2CZEORLV.js +0 -54
  188. package/dist/chunk-672UXYL3.js +0 -65
  189. package/dist/chunk-6WRKAACA.js +0 -96
  190. package/dist/chunk-DR2OXU46.js +0 -174
  191. package/dist/chunk-JACOMTIH.js +0 -275
  192. package/dist/chunk-XJXDOF63.js +0 -28
  193. package/dist/modeldiag-CJSFHZ3J.js +0 -1356
  194. package/dist/short-circuit-flags-7GQIGMVD.js +0 -10
  195. package/dist/version-help-WXI42PZ3.js +0 -10
@@ -1,14 +1,11 @@
1
1
  import type { OneShotOrchestrator } from '@wrongstack/core/execution';
2
- import type { Config, Provider } from '@wrongstack/core/types';
2
+ import { type RefinedMission } from '@wrongstack/core/goal';
3
+ import type { Provider } from '@wrongstack/core/types';
4
+ export { refineGoalHeuristic, resolveRefinerTarget } from '@wrongstack/core/goal';
3
5
  /**
4
6
  * Result of refining a user's raw goal into a clear, actionable mission.
5
7
  */
6
- interface RefinedGoal {
7
- /** Unambiguous, detailed goal statement. */
8
- refinedGoal: string;
9
- /** Concrete, verifiable deliverables (one per entry). */
10
- deliverables: string[];
11
- }
8
+ type RefinedGoal = RefinedMission;
12
9
  /**
13
10
  * Options for goal refinement with fallback tiers.
14
11
  */
@@ -31,42 +28,6 @@ interface GoalRefinerOptions {
31
28
  */
32
29
  oneShotOrchestrator?: OneShotOrchestrator | undefined;
33
30
  }
34
- /**
35
- * Resolved refiner target after validating against available providers,
36
- * favorite models, and the currently active session model.
37
- * Both `provider` and `model` are defined when a viable dedicated refiner
38
- * is found; otherwise the caller should use the primary session defaults.
39
- */
40
- interface ResolvedRefinerTarget {
41
- /** Resolved provider instance, ready for `provider.complete()`. */
42
- provider: Provider;
43
- /** Resolved model id on that provider. */
44
- model: string;
45
- }
46
- /**
47
- * Validate and resolve a dedicated refiner provider+model from the user
48
- * config. Returns undefined when:
49
- * - refinerFallbackProfile resolves to a valid profile entry (tried first)
50
- * - Neither refinerProvider nor refinerModel is configured
51
- * - The configured provider is unavailable (createProvider returns
52
- * undefined, meaning the provider doesn't exist or has no credentials)
53
- * - The configured model is not a favorite model AND is not the
54
- * currently active session model
55
- *
56
- * Precedence (first wins):
57
- * 1. refinerFallbackProfile → first valid entry from the named profile chain
58
- * 2. refinerProvider + refinerModel (both set)
59
- * 3. refinerModel on the active session provider
60
- *
61
- * When only `refinerModel` is set (no provider), the model is used on
62
- * the active session provider — validated against the same constraints.
63
- *
64
- * @param cfg — live Config from configStore
65
- * @param createProvider— factory: providerId → Provider | undefined
66
- * @param activeProviderId — the session's active provider id (config.provider)
67
- * @param activeModel — the session's active model (config.model)
68
- */
69
- export declare function resolveRefinerTarget(cfg: Config, createProvider: ((providerId: string) => Provider | undefined) | undefined, activeProviderId: string, activeModel: string): ResolvedRefinerTarget | undefined;
70
31
  /**
71
32
  * Refine a raw goal using the best available model/provider, with a
72
33
  * four-tier fallback chain:
@@ -85,10 +46,4 @@ export declare function refineGoalWithFallback(rawGoal: string, opts: GoalRefine
85
46
  * or the call fails.
86
47
  */
87
48
  export declare function refineGoal(rawGoal: string, provider: Provider, model: string, oneShotOrchestrator?: OneShotOrchestrator | undefined): Promise<RefinedGoal | null>;
88
- /**
89
- * Heuristic-only refinement — used when no LLM is available.
90
- * Produces a basic structure from the raw goal.
91
- */
92
- export declare function refineGoalHeuristic(rawGoal: string): RefinedGoal;
93
- export {};
94
49
  //# sourceMappingURL=goal-refiner.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { SlashCommand } from '@wrongstack/core/types';
2
+ import type { SlashCommandContext } from './command-context.js';
3
+ export declare function buildJevCommand(opts: SlashCommandContext): SlashCommand;
4
+ //# sourceMappingURL=jev.d.ts.map
@@ -18,7 +18,8 @@ export { parseMcpArgs, runMcpManagementCommand } from '../services/mcp-managemen
18
18
  * /mcp prompts <name> — discover cached/live prompts
19
19
  * /mcp read <name> <uri> — explicitly insert a selected resource
20
20
  * /mcp get <name> <prompt> [key=value...] — explicitly insert a selected prompt
21
- * /mcp auth start <name> <client-id> <redirect-uri> [scopes...] — begin OAuth
21
+ * /mcp auth login <name> [--client-id <id>] [--port <n>] [scopes...] — one-step OAuth
22
+ * /mcp auth start <name> --redirect-uri <url> [--client-id <id>] [scopes...] — manual OAuth
22
23
  * /mcp auth complete <name> <callback-url> — finish OAuth from a callback URL
23
24
  * /mcp auth status <name> — show non-secret authorization state
24
25
  * /mcp auth logout <name> — remove stored OAuth credentials
@@ -28,4 +28,19 @@ import type { SlashCommand } from '@wrongstack/core/types';
28
28
  */
29
29
  export declare function renderQuotaSnapshot(snapshot: ProviderQuotaSnapshot): string[];
30
30
  export declare function buildOpenAIQuotaCommand(): SlashCommand;
31
+ /**
32
+ * `/provider-quota` — every metered subscription this session has heard from.
33
+ *
34
+ * The narrow `/openai-quota` above stays because it answers one question
35
+ * without making the user read past other providers; this one exists because
36
+ * the reporters are no longer Codex-only. Claude Pro/Max and GitHub Copilot
37
+ * report into the same store, and a session that is signed into two metered
38
+ * plans has no other way to see which one is about to run out.
39
+ *
40
+ * The name says `provider` on purpose. A bare `/quota` would read as "what
41
+ * this project costs" — an account-wide spend view that does not exist here —
42
+ * and would occupy the name if one is ever built. What this shows is exactly
43
+ * the provider plane's readings, so that is what it is called.
44
+ */
45
+ export declare function buildProviderQuotaCommand(): SlashCommand;
31
46
  //# sourceMappingURL=openai-quota.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { SlashCommand } from '@wrongstack/core/types';
2
+ import type { SlashCommandContext } from './command-context.js';
3
+ export declare function buildPermissionsCommand(opts: SlashCommandContext): SlashCommand;
4
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare function executeSddTaskMutation(cmd: string, restJoined: string): {
2
+ message: string;
3
+ };
4
+ //# sourceMappingURL=sdd-task-mutations.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { persistConfigSetting } from '../settings-menu.js';
2
+ export declare function executeContextSettings(sub: string, rest: string[], persistDeps: Parameters<typeof persistConfigSetting>[0]): Promise<{
3
+ message: string;
4
+ } | undefined>;
5
+ //# sourceMappingURL=settings-context-mutations.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const ALL_SETTINGS_KEYS: string[];
2
+ //# sourceMappingURL=settings-keys.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { type LimitsConfig } from '@wrongstack/core/types';
2
+ import { persistConfigSetting } from '../settings-menu.js';
3
+ /** Render `/settings limits` — every limit, whether the user set it, and its range. */
4
+ export declare function renderLimitsView(limits: LimitsConfig | undefined): string;
5
+ /**
6
+ * `/settings limits [<name> <n|off>]`. Limits are user config only (denied to
7
+ * in-project config), so writes always go to the active profile.
8
+ */
9
+ export declare function executeLimitsSettings(sub: string, rest: string[], persistDeps: Parameters<typeof persistConfigSetting>[0], current: LimitsConfig | undefined): Promise<{
10
+ message: string;
11
+ } | undefined>;
12
+ //# sourceMappingURL=settings-limits-mutations.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { persistConfigSetting } from '../settings-menu.js';
2
+ import type { SlashCommandContext } from './command-context.js';
3
+ export declare function executeSettingsReset(rest: string[], persistDeps: Parameters<typeof persistConfigSetting>[0], opts: SlashCommandContext, profileName: string): Promise<{
4
+ message: string;
5
+ }>;
6
+ //# sourceMappingURL=settings-reset.d.ts.map
@@ -0,0 +1,249 @@
1
+ import {
2
+ MAX_BINARY_BYTES,
3
+ downloadReleaseAssetToFile,
4
+ findStandaloneRelease,
5
+ installExecutableFrom,
6
+ verifyStandaloneDigest
7
+ } from "./chunk-X756ZS72.js";
8
+ import {
9
+ isNewer
10
+ } from "./chunk-RZ4ZDRYA.js";
11
+ import {
12
+ CLI_VERSION,
13
+ STANDALONE_TARGET
14
+ } from "./chunk-F5DCFAKI.js";
15
+
16
+ // src/standalone-auto-update.ts
17
+ import { randomBytes } from "node:crypto";
18
+ import * as fs from "node:fs";
19
+ import * as path from "node:path";
20
+ import { isStandaloneBinary, wstackGlobalRoot } from "@wrongstack/core/utils";
21
+ var PENDING_FILE = "pending.json";
22
+ var APPLIED_FILE = "last-applied.json";
23
+ var LOCK_FILE = "update.lock";
24
+ var LOCK_STALE_MS = 45 * 6e4;
25
+ var DOWNLOAD_TIMEOUT_MS = 30 * 6e4;
26
+ function updatesDir(root = wstackGlobalRoot()) {
27
+ return path.join(root, "updates");
28
+ }
29
+ function autoUpdateEnabled(config, env = process.env) {
30
+ const off = env["WRONGSTACK_NO_AUTO_UPDATE"];
31
+ if (off !== void 0 && off !== "" && off !== "0") return false;
32
+ return config?.update?.autoDownload !== false;
33
+ }
34
+ function readPendingUpdate(dir = updatesDir()) {
35
+ let raw;
36
+ try {
37
+ raw = JSON.parse(fs.readFileSync(path.join(dir, PENDING_FILE), "utf8"));
38
+ } catch {
39
+ return void 0;
40
+ }
41
+ const p = raw;
42
+ if (!p || typeof p.version !== "string" || typeof p.file !== "string" || typeof p.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(p.sha256) || typeof p.target !== "string" || typeof p.executable !== "string" || // Only ever install from the staging directory itself.
43
+ path.dirname(path.resolve(p.file)) !== path.resolve(dir) || !fs.existsSync(p.file)) {
44
+ return void 0;
45
+ }
46
+ return {
47
+ version: p.version,
48
+ file: p.file,
49
+ sha256: p.sha256,
50
+ target: p.target,
51
+ executable: p.executable,
52
+ stagedAt: typeof p.stagedAt === "string" ? p.stagedAt : ""
53
+ };
54
+ }
55
+ function discardPending(dir, pending) {
56
+ fs.rmSync(path.join(dir, PENDING_FILE), { force: true });
57
+ if (pending) fs.rmSync(pending.file, { force: true });
58
+ }
59
+ function writeJsonAtomic(file, value) {
60
+ const tmp = `${file}.${randomBytes(6).toString("hex")}.tmp`;
61
+ fs.writeFileSync(tmp, `${JSON.stringify(value, null, 2)}
62
+ `, { mode: 384, flag: "wx" });
63
+ fs.renameSync(tmp, file);
64
+ }
65
+ function pidAlive(pid) {
66
+ try {
67
+ process.kill(pid, 0);
68
+ return true;
69
+ } catch (err) {
70
+ return err.code === "EPERM";
71
+ }
72
+ }
73
+ function acquireLock(dir) {
74
+ const lock = path.join(dir, LOCK_FILE);
75
+ for (let attempt = 0; attempt < 2; attempt++) {
76
+ try {
77
+ fs.writeFileSync(lock, JSON.stringify({ pid: process.pid, at: Date.now() }), { flag: "wx" });
78
+ return () => fs.rmSync(lock, { force: true });
79
+ } catch (err) {
80
+ if (err.code !== "EEXIST") throw err;
81
+ let owner = {};
82
+ try {
83
+ owner = JSON.parse(fs.readFileSync(lock, "utf8"));
84
+ } catch {
85
+ }
86
+ const fresh = typeof owner.pid === "number" && pidAlive(owner.pid) && typeof owner.at === "number" && Date.now() - owner.at < LOCK_STALE_MS;
87
+ if (fresh) return void 0;
88
+ fs.rmSync(lock, { force: true });
89
+ }
90
+ }
91
+ return void 0;
92
+ }
93
+ function applyPending(install, platform) {
94
+ const { dir, current, executable } = install;
95
+ const pending = readPendingUpdate(dir);
96
+ if (!pending) return void 0;
97
+ if (!isNewer(pending.version, current)) {
98
+ discardPending(dir, pending);
99
+ return void 0;
100
+ }
101
+ if (pending.executable !== executable) return void 0;
102
+ const release = acquireLock(dir);
103
+ if (!release) return void 0;
104
+ try {
105
+ try {
106
+ installExecutableFrom(executable, pending.file, pending.sha256, platform);
107
+ } catch (err) {
108
+ if (/does not match its digest/.test(String(err))) discardPending(dir, pending);
109
+ throw err;
110
+ }
111
+ discardPending(dir, pending);
112
+ writeJsonAtomic(path.join(dir, APPLIED_FILE), {
113
+ from: current,
114
+ to: pending.version,
115
+ at: (/* @__PURE__ */ new Date()).toISOString()
116
+ });
117
+ return pending.version;
118
+ } finally {
119
+ release();
120
+ }
121
+ }
122
+ function takeAppliedUpdate(dir = updatesDir()) {
123
+ const file = path.join(dir, APPLIED_FILE);
124
+ try {
125
+ const raw = JSON.parse(fs.readFileSync(file, "utf8"));
126
+ fs.rmSync(file, { force: true });
127
+ if (typeof raw.from === "string" && typeof raw.to === "string") {
128
+ return { from: raw.from, to: raw.to };
129
+ }
130
+ } catch {
131
+ }
132
+ return void 0;
133
+ }
134
+ async function stageLatest(install, signal) {
135
+ const { dir } = install;
136
+ const release = await findStandaloneRelease(install.target, signal);
137
+ if (!isNewer(release.version, install.current)) return void 0;
138
+ const already = readPendingUpdate(dir);
139
+ if (already?.version === release.version && already.target === install.target && already.executable === install.executable) {
140
+ return already;
141
+ }
142
+ fs.mkdirSync(dir, { recursive: true, mode: 448 });
143
+ const unlock = acquireLock(dir);
144
+ if (!unlock) return void 0;
145
+ const partial = path.join(dir, `.partial-${randomBytes(9).toString("hex")}`);
146
+ try {
147
+ const sha256 = await downloadReleaseAssetToFile(release.asset.browser_download_url, partial, {
148
+ timeoutMs: DOWNLOAD_TIMEOUT_MS,
149
+ maxBytes: MAX_BINARY_BYTES,
150
+ signal
151
+ });
152
+ await verifyStandaloneDigest(release, sha256, signal);
153
+ const file = path.join(dir, `${release.version}-${release.assetName}`);
154
+ fs.rmSync(file, { force: true });
155
+ fs.renameSync(partial, file);
156
+ const pending = {
157
+ version: release.version,
158
+ file,
159
+ sha256,
160
+ target: install.target,
161
+ executable: install.executable,
162
+ stagedAt: (/* @__PURE__ */ new Date()).toISOString()
163
+ };
164
+ writeJsonAtomic(path.join(dir, PENDING_FILE), pending);
165
+ for (const name of fs.readdirSync(dir)) {
166
+ const keep = [PENDING_FILE, APPLIED_FILE, LOCK_FILE, path.basename(file)];
167
+ if (!keep.includes(name)) fs.rmSync(path.join(dir, name), { force: true, recursive: true });
168
+ }
169
+ return pending;
170
+ } finally {
171
+ fs.rmSync(partial, { force: true });
172
+ unlock();
173
+ }
174
+ }
175
+ function standaloneUpdater(install) {
176
+ const bound = { ...install, dir: install.dir ?? updatesDir() };
177
+ const pending = () => {
178
+ const found = readPendingUpdate(bound.dir);
179
+ return found?.executable === bound.executable ? found : void 0;
180
+ };
181
+ return {
182
+ pending,
183
+ stage: (signal) => stageLatest(bound, signal),
184
+ apply: (platform) => applyPending(bound, platform),
185
+ clear: () => {
186
+ const found = pending();
187
+ if (found) discardPending(bound.dir, found);
188
+ }
189
+ };
190
+ }
191
+ function startStandaloneAutoUpdate(options) {
192
+ if (!isStandaloneBinary() || !STANDALONE_TARGET) return void 0;
193
+ if (!autoUpdateEnabled(options.getConfig())) return void 0;
194
+ let updater;
195
+ try {
196
+ updater = standaloneUpdater({
197
+ executable: fs.realpathSync(process.execPath),
198
+ target: STANDALONE_TARGET,
199
+ current: CLI_VERSION
200
+ });
201
+ } catch {
202
+ return void 0;
203
+ }
204
+ const listeners = /* @__PURE__ */ new Set();
205
+ let ready;
206
+ const markReady = (version) => {
207
+ ready = version;
208
+ for (const listener of listeners) listener(version);
209
+ };
210
+ process.once("exit", () => {
211
+ if (!autoUpdateEnabled(options.getConfig())) return;
212
+ try {
213
+ updater.apply();
214
+ } catch {
215
+ }
216
+ });
217
+ const found = updater.pending();
218
+ const pending = found && isNewer(found.version, CLI_VERSION) ? found : void 0;
219
+ const latest = options.updateInfo?.outdated ? options.updateInfo.latest : void 0;
220
+ const controller = new AbortController();
221
+ if (pending && (latest === void 0 || !isNewer(latest, pending.version))) {
222
+ ready = pending.version;
223
+ } else if (latest !== void 0) {
224
+ void updater.stage(controller.signal).then((staged) => {
225
+ if (staged) markReady(staged.version);
226
+ }).catch((err) => {
227
+ if (controller.signal.aborted) return;
228
+ options.onError?.(err instanceof Error ? err.message : String(err));
229
+ });
230
+ }
231
+ return {
232
+ subscribe(listener) {
233
+ listeners.add(listener);
234
+ if (ready) listener(ready);
235
+ return () => listeners.delete(listener);
236
+ },
237
+ dispose() {
238
+ controller.abort();
239
+ listeners.clear();
240
+ }
241
+ };
242
+ }
243
+ export {
244
+ autoUpdateEnabled,
245
+ standaloneUpdater,
246
+ startStandaloneAutoUpdate,
247
+ takeAppliedUpdate
248
+ };
249
+ //# sourceMappingURL=standalone-auto-update-TOTRGCSA.js.map
@@ -0,0 +1,65 @@
1
+ import type { Config } from '@wrongstack/core/types';
2
+ import { type StagedStandaloneUpdate } from './standalone-update.js';
3
+ import { type UpdateInfo } from './update-check.js';
4
+ /** A verified build waiting to be swapped in. */
5
+ export interface PendingUpdate extends StagedStandaloneUpdate {
6
+ /** `bun build --target` it was built for. */
7
+ target: string;
8
+ /** Real path of the executable it replaces. */
9
+ executable: string;
10
+ stagedAt: string;
11
+ }
12
+ /** `update.autoDownload` (default on) and the `WRONGSTACK_NO_AUTO_UPDATE` switch. */
13
+ export declare function autoUpdateEnabled(config: Config | undefined, env?: NodeJS.ProcessEnv): boolean;
14
+ /** The swap a previous session made, reported once. */
15
+ export declare function takeAppliedUpdate(dir?: string): {
16
+ from: string;
17
+ to: string;
18
+ } | undefined;
19
+ /** The updates of one install of the executable. */
20
+ export interface StandaloneUpdater {
21
+ /** Its verified build waiting to be swapped in, if any. */
22
+ pending(): PendingUpdate | undefined;
23
+ /**
24
+ * Download, verify and stage the latest release when it is newer. Returns
25
+ * the pending update (possibly one staged earlier), or undefined when there
26
+ * is nothing newer or another session is downloading.
27
+ */
28
+ stage(signal?: AbortSignal): Promise<PendingUpdate | undefined>;
29
+ /**
30
+ * Swap the pending build in over the executable. Synchronous (it runs from
31
+ * the process `exit` handler); returns the installed version, or undefined
32
+ * when there was nothing to install. A pending build that is not newer, or
33
+ * whose file no longer matches its digest, is thrown away.
34
+ */
35
+ apply(platform?: NodeJS.Platform): string | undefined;
36
+ /**
37
+ * Drop the pending build after `wstack update` brought the executable to
38
+ * the latest release: it is either the build just installed or an older one.
39
+ */
40
+ clear(): void;
41
+ }
42
+ export declare function standaloneUpdater(install: {
43
+ executable: string;
44
+ target: string;
45
+ current: string;
46
+ dir?: string | undefined;
47
+ }): StandaloneUpdater;
48
+ /** What an interactive session sees of the background update. */
49
+ export interface StandaloneAutoUpdate {
50
+ /** Called once the update is ready (immediately, when it already is). */
51
+ subscribe(listener: (version: string) => void): () => void;
52
+ /** Stop a download in progress. The exit swap stays armed. */
53
+ dispose(): void;
54
+ }
55
+ /**
56
+ * Start the background update for an interactive session: arm the exit swap,
57
+ * and download the latest release when `updateInfo` says one is newer.
58
+ * Undefined for the npm install or when switched off.
59
+ */
60
+ export declare function startStandaloneAutoUpdate(options: {
61
+ getConfig: () => Config | undefined;
62
+ updateInfo: UpdateInfo | undefined;
63
+ onError?: ((message: string) => void) | undefined;
64
+ }): StandaloneAutoUpdate | undefined;
65
+ //# sourceMappingURL=standalone-auto-update.d.ts.map
@@ -0,0 +1,24 @@
1
+ import {
2
+ MAX_BINARY_BYTES,
3
+ fetchLatestStandaloneVersion,
4
+ findStandaloneRelease,
5
+ installExecutableFrom,
6
+ parseSha256Sums,
7
+ replaceExecutable,
8
+ standaloneAssetName,
9
+ updateStandaloneBinary,
10
+ verifyStandaloneDigest
11
+ } from "./chunk-X756ZS72.js";
12
+ import "./chunk-F5DCFAKI.js";
13
+ export {
14
+ MAX_BINARY_BYTES,
15
+ fetchLatestStandaloneVersion,
16
+ findStandaloneRelease,
17
+ installExecutableFrom,
18
+ parseSha256Sums,
19
+ replaceExecutable,
20
+ standaloneAssetName,
21
+ updateStandaloneBinary,
22
+ verifyStandaloneDigest
23
+ };
24
+ //# sourceMappingURL=standalone-update-LZO3MNLH.js.map
@@ -0,0 +1,55 @@
1
+ import type { TerminalRenderer } from './renderer.js';
2
+ export declare const MAX_BINARY_BYTES: number;
3
+ interface ReleaseAsset {
4
+ name: string;
5
+ browser_download_url: string;
6
+ /** `sha256:<hex>`, computed by GitHub when the asset was uploaded. */
7
+ digest?: string | null | undefined;
8
+ }
9
+ /** Asset name a build target publishes under (mirrors build-binaries.mjs `outputName`). */
10
+ export declare function standaloneAssetName(target: string): string;
11
+ /** The latest release's executable for `target`, with its SHA256SUMS. */
12
+ export interface StandaloneRelease {
13
+ version: string;
14
+ assetName: string;
15
+ asset: ReleaseAsset;
16
+ sums: ReleaseAsset;
17
+ }
18
+ /** Throws when the latest release has no build for `target`. */
19
+ export declare function findStandaloneRelease(target: string, signal?: AbortSignal): Promise<StandaloneRelease>;
20
+ /**
21
+ * Throws unless `sha256` is the release's own build of the asset: listed in
22
+ * its SHA256SUMS, equal to the digest GitHub computed at upload, and vouched
23
+ * for by the release workflow's build attestation.
24
+ */
25
+ export declare function verifyStandaloneDigest(release: StandaloneRelease, sha256: string, signal?: AbortSignal): Promise<void>;
26
+ /** Latest released version, for the update check. */
27
+ export declare function fetchLatestStandaloneVersion(timeoutMs?: number, signal?: AbortSignal): Promise<string>;
28
+ /** `<sha256> <name>` lines → map. */
29
+ export declare function parseSha256Sums(text: string): Map<string, string>;
30
+ /**
31
+ * Replace `target` with `bytes`. Staged next to the target so the final step
32
+ * is a same-filesystem rename.
33
+ */
34
+ export declare function replaceExecutable(target: string, bytes: Buffer, platform?: NodeJS.Platform): void;
35
+ /**
36
+ * Replace `target` with the file at `source` (a downloaded update), refusing
37
+ * unless the copy that is about to become the executable hashes to `sha256`.
38
+ * Synchronous: it runs from the process `exit` handler.
39
+ */
40
+ export declare function installExecutableFrom(target: string, source: string, sha256: string, platform?: NodeJS.Platform): void;
41
+ /** A verified download the background updater left waiting (standalone-auto-update.ts). */
42
+ export interface StagedStandaloneUpdate {
43
+ version: string;
44
+ file: string;
45
+ sha256: string;
46
+ }
47
+ /** `wstack update` for the standalone binary. Returns the process exit code. */
48
+ export declare function updateStandaloneBinary(options: {
49
+ current: string;
50
+ renderer: Pick<TerminalRenderer, 'write'>;
51
+ /** Installed instead of downloading again when it is the latest release. */
52
+ staged?: StagedStandaloneUpdate | undefined;
53
+ }): Promise<number>;
54
+ export {};
55
+ //# sourceMappingURL=standalone-update.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { SubcommandDeps } from '../contracts.js';
2
+ export declare function hqAlertsCmd(args: string[], deps: SubcommandDeps): Promise<number>;
3
+ //# sourceMappingURL=hq-alerts.d.ts.map
@@ -0,0 +1,46 @@
1
+ import type { SubcommandDeps } from '../contracts.js';
2
+ /**
3
+ * `wstack hq audit verify` — re-derive the contentHash from the current
4
+ * on-disk `auth.json` and print it so an operator can compare against a
5
+ * `contentHash` field in an audit entry. This closes the forensic
6
+ * tie-back loop without requiring the operator to write a script: copy
7
+ * the hash from the audit log, run this command, eyeball (or `diff`)
8
+ * the two values.
9
+ *
10
+ * Prints:
11
+ * - the resolved `auth.json` path (so the operator knows which file
12
+ * was hashed)
13
+ * - the SHA-256 contentHash, or `(unavailable)` if the file is
14
+ * missing/unreadable
15
+ * - the `auth-audit.jsonl` path (so the operator knows where to look
16
+ * for entries to compare against)
17
+ *
18
+ * Exit codes:
19
+ * 0 — hash computed and printed
20
+ * 1 — `auth.json` missing or unreadable (hash unavailable); the
21
+ * audit-log path is still printed so the operator can inspect
22
+ * historical entries
23
+ */
24
+ export declare function hqAuditCmd(args: string[], deps: SubcommandDeps): Promise<number>;
25
+ /**
26
+ * Re-read the persisted `auth.json` and return a conditional
27
+ * `contentHash` field for embedding in an audit entry. This closes the
28
+ * forensic tie-back loop: an operator reviewing `auth-audit.jsonl` can
29
+ * compare the `contentHash` against the current on-disk file via
30
+ * `wstack hq audit verify`.
31
+ *
32
+ * Re-reads rather than hashing the in-memory post-mutation snapshot
33
+ * because `writeHqAuthFile` re-stamps `updatedAt` on the persisted
34
+ * payload — hashing the in-memory `next` would diverge from what
35
+ * `verify` computes. Matches the pattern established by the `first-run`
36
+ * and `expired-prune` emitters in `auth-store.ts` / `hq-server.ts`.
37
+ *
38
+ * Returns `{}` (no `contentHash` key) when the file is unreadable, so
39
+ * the audit entry still records the event without a tie-back — the
40
+ * absence itself is meaningful. Conditional spread preserves
41
+ * `exactOptionalPropertyTypes`.
42
+ */
43
+ export declare function computeAuditHashField(dataDir: string, warn: (msg: string) => void): Promise<{
44
+ contentHash?: string;
45
+ }>;
46
+ //# sourceMappingURL=hq-audit.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { SubcommandDeps } from '../contracts.js';
2
+ /**
3
+ * Build a free-form actor string for the auth audit log. Combines the OS
4
+ * username (best-effort) with the hostname so an operator reviewing the
5
+ * log can see "who minted this token" without parsing environment
6
+ * variables. Never includes the token string.
7
+ *
8
+ * Shared by the `wstack hq token` create/revoke handlers and by
9
+ * `startHqServer`'s first-run bootstrap so every audit entry point
10
+ * produces the same actor shape.
11
+ */
12
+ export declare function resolveDataDir(deps: SubcommandDeps): string;
13
+ //# sourceMappingURL=hq-data-dir.d.ts.map
@@ -0,0 +1,42 @@
1
+ import type { MCPServerConfig } from '@wrongstack/core/types';
2
+ import type { SubcommandHandler } from '../contracts.js';
3
+ export type McpImportSource = 'claude-user' | 'claude-project-local' | 'repository';
4
+ export interface McpImportCandidate {
5
+ name: string;
6
+ source: McpImportSource;
7
+ config: Partial<MCPServerConfig>;
8
+ action: 'add' | 'overwrite' | 'skip-exists' | 'skip-invalid';
9
+ enabled: boolean;
10
+ note?: string | undefined;
11
+ }
12
+ export interface ClaudeCodeImportPlan {
13
+ mcp: McpImportCandidate[];
14
+ notes: string[];
15
+ }
16
+ export interface ClaudeCodeSources {
17
+ /** Parsed `~/.claude.json`, or undefined when absent. */
18
+ userState?: Record<string, unknown> | undefined;
19
+ /** Parsed `<project>/.mcp.json`, or undefined when absent. */
20
+ projectMcp?: Record<string, unknown> | undefined;
21
+ /** Settings files that exist, with their parsed content. */
22
+ settings: Array<{
23
+ file: string;
24
+ content: Record<string, unknown>;
25
+ }>;
26
+ /** CLAUDE.md files that exist. */
27
+ instructionFiles: string[];
28
+ /** Skill directories that exist. */
29
+ skillDirs: string[];
30
+ }
31
+ /** Decide what an import would do. Pure: no reads, no writes. */
32
+ export declare function planClaudeCodeImport(opts: {
33
+ sources: ClaudeCodeSources;
34
+ projectRoot: string;
35
+ existingServers: Readonly<Record<string, unknown>>;
36
+ overwrite: boolean;
37
+ enableProjectServers: boolean;
38
+ }): ClaudeCodeImportPlan;
39
+ /** Read everything the importer looks at. Missing files are simply absent. */
40
+ export declare function readClaudeCodeSources(projectRoot: string, userHome?: string): Promise<ClaudeCodeSources>;
41
+ export declare const importClaudeCodeCmd: SubcommandHandler;
42
+ //# sourceMappingURL=import-claude-code.d.ts.map