@indigoai-us/hq-cli 5.345.208 → 5.345.211

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 (133) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/assets/scaffold/core/scripts/derive-trigger-facts.sh +22 -3
  3. package/assets/scaffold/core/scripts/lib/trigger-fact-text.awk +152 -41
  4. package/dist/command-catalog.generated.d.ts +33 -8
  5. package/dist/command-catalog.generated.js +40 -8
  6. package/dist/command-registration-plan.d.ts +2 -2
  7. package/dist/command-registration-plan.js +1 -1
  8. package/dist/commands/access.js +11 -5
  9. package/dist/commands/agents.d.ts +8 -0
  10. package/dist/commands/agents.js +5 -0
  11. package/dist/commands/bot.d.ts +8 -0
  12. package/dist/commands/bot.js +67 -7
  13. package/dist/commands/channels.js +4 -0
  14. package/dist/commands/cloud.d.ts +83 -2
  15. package/dist/commands/cloud.js +161 -31
  16. package/dist/commands/company.d.ts +9 -0
  17. package/dist/commands/company.js +44 -14
  18. package/dist/commands/core-checkpoint-native.js +21 -0
  19. package/dist/commands/core-derive-trigger-facts-native.d.ts +1 -0
  20. package/dist/commands/core-derive-trigger-facts-native.js +75 -14
  21. package/dist/commands/core-generate-workers-registry-fast.d.ts +1 -1
  22. package/dist/commands/core-generate-workers-registry-fast.js +7 -1
  23. package/dist/commands/core-job-run-native.d.ts +8 -0
  24. package/dist/commands/core-job-run-native.js +11 -3
  25. package/dist/commands/core-jobs-native.js +1 -1
  26. package/dist/commands/core-register-project-native.js +31 -1
  27. package/dist/commands/core-scan-packages-fast.d.ts +1 -1
  28. package/dist/commands/core-scan-packages-fast.js +8 -1
  29. package/dist/commands/core-work-mesh-bind-trusted-native.d.ts +14 -2
  30. package/dist/commands/core-work-mesh-bind-trusted-native.js +62 -8
  31. package/dist/commands/core.js +12 -3
  32. package/dist/commands/dm-attach.d.ts +10 -0
  33. package/dist/commands/dm-attach.js +33 -5
  34. package/dist/commands/integrations-connect.d.ts +16 -0
  35. package/dist/commands/integrations-connect.js +70 -6
  36. package/dist/commands/lanes-session-start.d.ts +17 -0
  37. package/dist/commands/lanes-session-start.js +281 -13
  38. package/dist/commands/lanes-watch.js +11 -3
  39. package/dist/commands/lanes.d.ts +4 -0
  40. package/dist/commands/lanes.js +95 -22
  41. package/dist/commands/library.d.ts +10 -0
  42. package/dist/commands/library.js +30 -3
  43. package/dist/commands/meetings.d.ts +42 -0
  44. package/dist/commands/meetings.js +157 -12
  45. package/dist/commands/mesh.js +3 -0
  46. package/dist/commands/monitor.d.ts +6 -0
  47. package/dist/commands/monitor.js +29 -19
  48. package/dist/commands/onboard.js +8 -1
  49. package/dist/commands/sources.js +7 -3
  50. package/dist/index.js +9 -0
  51. package/dist/lanes-monitor-check-argv.d.ts +1 -1
  52. package/dist/lanes-monitor-check-argv.js +2 -2
  53. package/dist/lanes-session-start-argv.d.ts +4 -1
  54. package/dist/lanes-session-start-argv.js +5 -2
  55. package/dist/lib/bot/fleet-daemon.d.ts +101 -0
  56. package/dist/lib/bot/fleet-daemon.js +227 -0
  57. package/dist/lib/bot/fleet-local.d.ts +26 -0
  58. package/dist/lib/bot/fleet-local.js +51 -2
  59. package/dist/lib/bot/index.d.ts +1 -0
  60. package/dist/lib/bot/index.js +1 -0
  61. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +4 -0
  62. package/dist/lib/bot/jobs/hot-signal-sync.js +8 -1
  63. package/dist/lib/bot/log.js +3 -1
  64. package/dist/lib/bot/probe.js +2 -0
  65. package/dist/lib/bot/run.js +28 -3
  66. package/dist/lib/bot/runtime-failure.d.ts +4 -2
  67. package/dist/lib/bot/runtime-failure.js +9 -1
  68. package/dist/lib/bot/status.d.ts +17 -0
  69. package/dist/lib/bot/status.js +53 -2
  70. package/dist/lib/capacity/collectors/claude-oauth.d.ts +5 -5
  71. package/dist/lib/capacity/collectors/claude-oauth.js +6 -6
  72. package/dist/lib/core-utils/native-scaffold-help.d.ts +16 -0
  73. package/dist/lib/core-utils/native-scaffold-help.js +26 -0
  74. package/dist/lib/core-utils/session-company.d.ts +25 -8
  75. package/dist/lib/core-utils/session-company.js +59 -17
  76. package/dist/lib/daemon/catalog.d.ts +34 -1
  77. package/dist/lib/daemon/catalog.js +42 -3
  78. package/dist/lib/daemon/run.d.ts +5 -4
  79. package/dist/lib/daemon/run.js +40 -16
  80. package/dist/lib/daemon/server.js +26 -7
  81. package/dist/lib/daemon/supervisor.d.ts +2 -0
  82. package/dist/lib/daemon/supervisor.js +60 -1
  83. package/dist/lib/daemon/tools.js +17 -1
  84. package/dist/lib/db/sqlite-binding.js +2 -1
  85. package/dist/lib/doctor/checks/bots.d.ts +2 -0
  86. package/dist/lib/doctor/checks/bots.js +11 -0
  87. package/dist/lib/doctor/checks/runtime-health.js +3 -2
  88. package/dist/lib/doctor/checks/work-context.js +5 -2
  89. package/dist/lib/hook-engine/resolve.d.ts +1 -1
  90. package/dist/lib/hook-engine/resolve.js +4 -1
  91. package/dist/lib/hot-channels/adapters/meeting-providers.d.ts +2 -0
  92. package/dist/lib/hot-channels/adapters/meeting-providers.js +13 -2
  93. package/dist/lib/lanes/index.d.ts +1 -1
  94. package/dist/lib/lanes/index.js +1 -1
  95. package/dist/lib/lanes/monitor.d.ts +14 -0
  96. package/dist/lib/lanes/monitor.js +51 -10
  97. package/dist/lib/lanes/outpost-dispatch.d.ts +3 -0
  98. package/dist/lib/lanes/outpost-dispatch.js +1 -0
  99. package/dist/lib/lanes/store.d.ts +1 -1
  100. package/dist/lib/lanes/store.js +2 -1
  101. package/dist/lib/mesh/client.js +7 -1
  102. package/dist/lib/mesh/live/backfill-held.d.ts +3 -0
  103. package/dist/lib/mesh/live/backfill-held.js +167 -7
  104. package/dist/lib/mesh/live/flush.d.ts +7 -0
  105. package/dist/lib/mesh/live/flush.js +10 -1
  106. package/dist/lib/monitor.d.ts +9 -0
  107. package/dist/lib/monitor.js +33 -7
  108. package/dist/lib/onboarding/orchestrator.js +269 -132
  109. package/dist/lib/onboarding/types.d.ts +2 -0
  110. package/dist/lib/scaffold-cli-floor.js +2 -1
  111. package/dist/lib/signals/failure-alert.js +3 -1
  112. package/dist/lib/sync-core/reconcile.js +15 -11
  113. package/dist/lib/work-context/organize.d.ts +6 -0
  114. package/dist/lib/work-context/organize.js +28 -0
  115. package/dist/lib/work-context/paths.d.ts +9 -0
  116. package/dist/lib/work-context/paths.js +15 -0
  117. package/dist/lib/work-context/prd-sync.js +2 -1
  118. package/dist/runners-alias.d.ts +54 -0
  119. package/dist/runners-alias.js +86 -0
  120. package/dist/utils/install-tree-torn.js +5 -3
  121. package/dist/utils/npm-install-flags.d.ts +27 -0
  122. package/dist/utils/npm-install-flags.js +68 -0
  123. package/dist/utils/package-use-lease.js +1 -1
  124. package/dist/utils/qmd-native-binding-error.js +2 -1
  125. package/dist/utils/self-update.js +2 -1
  126. package/dist/utils/staged-install.js +2 -1
  127. package/dist/utils/staged-npm-install.js +2 -1
  128. package/dist/utils/upload-author.d.ts +2 -1
  129. package/dist/utils/upload-author.js +9 -5
  130. package/dist/utils/version-check.js +2 -1
  131. package/dist/utils/version-gate.js +7 -6
  132. package/package.json +7 -7
  133. package/scripts/install-hook-engine.mjs +7 -3
@@ -107,19 +107,23 @@ export async function reconcileSyncCore(deps) {
107
107
  if (personUid)
108
108
  desired.push({ uid: personUid, kind: "personal" });
109
109
  }
110
- const skipped = [];
110
+ let skips;
111
111
  try {
112
- const skips = readSyncCoreSkips(deps.home);
113
- for (let i = desired.length - 1; i >= 0; i -= 1) {
114
- const skip = skips.find((entry) => entry.uid === desired[i]?.uid);
115
- if (!skip)
116
- continue;
117
- skipped.unshift(skip);
118
- desired.splice(i, 1);
119
- }
112
+ skips = readSyncCoreSkips(deps.home);
120
113
  }
121
114
  catch (error) {
122
- warnings.push(message(error));
115
+ skips = previous?.skipped ?? [];
116
+ warnings.push(`${message(error)}; ${skips.length > 0
117
+ ? `keeping last run's skips (${skips.map((skip) => skip.uid).join(", ")})`
118
+ : "no vault was skipped last run, so none is skipped now"}`);
119
+ }
120
+ const skipped = [];
121
+ for (let i = desired.length - 1; i >= 0; i -= 1) {
122
+ const skip = skips.find((entry) => entry.uid === desired[i]?.uid);
123
+ if (!skip)
124
+ continue;
125
+ skipped.unshift(skip);
126
+ desired.splice(i, 1);
123
127
  }
124
128
  let binaryPath = syncCoreBinaryPath(deps.home, platform);
125
129
  let installedRelease = installedSyncCoreRelease(deps.home, platform);
@@ -181,7 +185,7 @@ export async function reconcileSyncCore(deps) {
181
185
  ? switchesBefore.personalOff
182
186
  : switchesBefore.offCompanies.has(vault.slug ?? "");
183
187
  const legacyAlreadyOff = wasFull ? before.legacyAlreadyOff === true : alreadyOff;
184
- const legacyOffSince = (wasFull ? before.legacyOffSince : undefined) ?? at;
188
+ const legacyOffSince = (wasFull && alreadyOff ? before.legacyOffSince : undefined) ?? at;
185
189
  const recorded = wasFull ? before.firstCycle : undefined;
186
190
  const firstCycle = recorded && recorded.planned > 0
187
191
  ? recorded
@@ -126,6 +126,12 @@ export declare function submitOrganizeDecision(input: {
126
126
  untracked?: boolean;
127
127
  now?: () => Date;
128
128
  postOrganize?: PostOrganizeFn;
129
+ /**
130
+ * Lists server candidates before an explicit create. The server stamps the
131
+ * per-actor decision window only when candidates are listed, and refuses an
132
+ * organize without one (409 DECISION_WINDOW_MISSING).
133
+ */
134
+ fetchCandidates?: FetchCandidatesFn;
129
135
  }): Promise<OrganizeSubmitResult>;
130
136
  export {};
131
137
  //# sourceMappingURL=organize.d.ts.map
@@ -426,6 +426,27 @@ export async function submitOrganizeDecision(input) {
426
426
  message: "No organize transport; server receipt required for success",
427
427
  };
428
428
  }
429
+ // An explicit --create-project / --create-task does not come from a listed
430
+ // decision, so nothing has opened the server's decision window yet: `--list`
431
+ // only lists candidates once the work-signal threshold is crossed. Open the
432
+ // window here so the create is not refused with DECISION_WINDOW_MISSING.
433
+ if ((decision.kind === "create_project" || decision.kind === "create_task") &&
434
+ input.fetchCandidates) {
435
+ try {
436
+ await input.fetchCandidates({
437
+ sessionId: input.sessionId,
438
+ companyUid: state.companyUid,
439
+ });
440
+ }
441
+ catch (err) {
442
+ const message = err instanceof Error ? err.message : String(err);
443
+ return {
444
+ ok: false,
445
+ errorCode: "CANDIDATES_UNAVAILABLE",
446
+ message: `could not open the organize decision window: ${message}`,
447
+ };
448
+ }
449
+ }
429
450
  // Stale decision → typed error (caller may refresh candidates).
430
451
  if (decisionExpiresAt) {
431
452
  const exp = Date.parse(decisionExpiresAt);
@@ -459,6 +480,13 @@ export async function submitOrganizeDecision(input) {
459
480
  }
460
481
  catch (err) {
461
482
  const message = err instanceof Error ? err.message : String(err);
483
+ if (/DECISION_WINDOW_MISSING/.test(message)) {
484
+ return {
485
+ ok: false,
486
+ errorCode: "DECISION_WINDOW_MISSING",
487
+ message: `${message} (the server opens the decision window when candidates are listed for this session)`,
488
+ };
489
+ }
462
490
  if (/DECISION_EXPIRED|409/.test(message)) {
463
491
  return { ok: false, errorCode: "DECISION_EXPIRED", message };
464
492
  }
@@ -7,6 +7,15 @@ export declare function workContextRoot(home?: string, env?: NodeJS.ProcessEnv):
7
7
  export declare function workContextConfigPath(root?: string): string;
8
8
  export declare function workContextSessionsDir(root?: string): string;
9
9
  export declare function workContextSessionPath(sessionId: string, root?: string): string;
10
+ /**
11
+ * Per-session sidecar files kept beside `<sessionId>.json` in the sessions
12
+ * directory. They are not session state files, so readers that scan the
13
+ * directory for session state (doctor state-file health) must skip them.
14
+ */
15
+ export declare const WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX = ".prd-snapshot.json";
16
+ export declare const WORK_CONTEXT_SESSION_SIDECAR_SUFFIXES: readonly string[];
17
+ /** True for `<sessionId>.json`, false for sidecars and non-JSON entries. */
18
+ export declare function isWorkContextSessionStateFileName(name: string): boolean;
10
19
  export declare function workContextOutboxDir(root?: string): string;
11
20
  export declare function workContextOutboxPath(operationId: string, root?: string): string;
12
21
  /** Safe path segment for session/operation ids (no traversal). */
@@ -20,6 +20,21 @@ export function workContextSessionsDir(root) {
20
20
  export function workContextSessionPath(sessionId, root) {
21
21
  return path.join(workContextSessionsDir(root), `${sessionId}.json`);
22
22
  }
23
+ /**
24
+ * Per-session sidecar files kept beside `<sessionId>.json` in the sessions
25
+ * directory. They are not session state files, so readers that scan the
26
+ * directory for session state (doctor state-file health) must skip them.
27
+ */
28
+ export const WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX = ".prd-snapshot.json";
29
+ export const WORK_CONTEXT_SESSION_SIDECAR_SUFFIXES = [
30
+ WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX,
31
+ ];
32
+ /** True for `<sessionId>.json`, false for sidecars and non-JSON entries. */
33
+ export function isWorkContextSessionStateFileName(name) {
34
+ if (!name.endsWith(".json"))
35
+ return false;
36
+ return !WORK_CONTEXT_SESSION_SIDECAR_SUFFIXES.some((suffix) => name.endsWith(suffix));
37
+ }
23
38
  export function workContextOutboxDir(root) {
24
39
  return path.join(root ?? workContextRoot(), "outbox");
25
40
  }
@@ -9,8 +9,9 @@ import * as fs from "node:fs";
9
9
  import * as path from "node:path";
10
10
  import { readSessionState, updateSessionState } from "./state.js";
11
11
  import { mapReaderStoryStatus } from "../mesh/story-status.js";
12
+ import { WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX } from "./paths.js";
12
13
  export function prdSnapshotPath(sessionId, root) {
13
- return path.join(root, "sessions", `${sessionId}.prd-snapshot.json`);
14
+ return path.join(root, "sessions", `${sessionId}${WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX}`);
14
15
  }
15
16
  export function readPrdSnapshot(sessionId, root) {
16
17
  try {
@@ -0,0 +1,54 @@
1
+ /**
2
+ * `hq runners` is the primary name of the detached-execution command group;
3
+ * `hq lanes` is a deprecated compatibility alias (US-013). HQ core still calls
4
+ * `hq lanes`, so the alias has no scheduled removal; it goes in a later
5
+ * release, once HQ core no longer uses it.
6
+ *
7
+ * Dependency-free: imported statically by src/index.ts for the fast routes,
8
+ * so it must not import anything.
9
+ */
10
+ /** The primary command-group name. */
11
+ export declare const RUNNERS_COMMAND = "runners";
12
+ /** The deprecated alias, kept until HQ core stops calling it. */
13
+ export declare const LANES_ALIAS = "lanes";
14
+ export declare const LANES_ALIAS_DEPRECATION_LINE = "hq lanes is deprecated; use hq runners instead. The hq lanes name will be removed in a later release, after HQ core stops using it.";
15
+ /** True for either name of the command group. */
16
+ export declare function isRunnersGroupToken(token: string | undefined): boolean;
17
+ /**
18
+ * Subcommands that hooks, monitors and scripts run. HQ core's hooks treat any
19
+ * stderr from them as a failure, so the alias never prints the line for them.
20
+ */
21
+ export declare const MACHINE_SUBCOMMANDS: ReadonlySet<string>;
22
+ /** Whether stdout and stderr are terminals. */
23
+ export interface TerminalStreams {
24
+ stdoutIsTTY: boolean;
25
+ stderrIsTTY: boolean;
26
+ }
27
+ /**
28
+ * Write the deprecation line to stderr once per process. The fast routes and
29
+ * the Commander path can both see one invocation (monitor-check falls back to
30
+ * the full command graph), so the guard keeps it to one line. Callers decide
31
+ * whether a person is reading; see shouldWriteLanesAliasDeprecation.
32
+ */
33
+ export declare function writeLanesAliasDeprecation(write?: (text: string) => void): void;
34
+ /**
35
+ * True when Commander argv (`node hq ...`) names the group through the alias:
36
+ * `hq lanes ...`, `hq --verbose lanes ...`, or `hq help lanes ...`. Mirrors the
37
+ * root-token rules of findLazyCommand so both agree on which root was asked for.
38
+ */
39
+ export declare function argvUsesLanesAlias(argv: readonly string[]): boolean;
40
+ /**
41
+ * True when the line should print for this alias invocation. `groupArgs`
42
+ * starts at the group token (`["lanes", "list", ...]`). The line is for a
43
+ * person at a terminal only: never for a machine subcommand, never with
44
+ * `--json`, and never when stdout or stderr is not a terminal.
45
+ */
46
+ export declare function shouldWriteLanesAliasDeprecation(groupArgs: readonly string[], streams?: TerminalStreams): boolean;
47
+ /**
48
+ * Write the deprecation line when Commander argv invokes the group through
49
+ * the alias and a person is reading (see shouldWriteLanesAliasDeprecation).
50
+ */
51
+ export declare function writeLanesAliasDeprecationForArgv(argv: readonly string[], streams?: TerminalStreams): void;
52
+ /** Test seam: clear the once-per-process guard. */
53
+ export declare function resetLanesAliasDeprecationForTests(): void;
54
+ //# sourceMappingURL=runners-alias.d.ts.map
@@ -0,0 +1,86 @@
1
+ /**
2
+ * `hq runners` is the primary name of the detached-execution command group;
3
+ * `hq lanes` is a deprecated compatibility alias (US-013). HQ core still calls
4
+ * `hq lanes`, so the alias has no scheduled removal; it goes in a later
5
+ * release, once HQ core no longer uses it.
6
+ *
7
+ * Dependency-free: imported statically by src/index.ts for the fast routes,
8
+ * so it must not import anything.
9
+ */
10
+ /** The primary command-group name. */
11
+ export const RUNNERS_COMMAND = "runners";
12
+ /** The deprecated alias, kept until HQ core stops calling it. */
13
+ export const LANES_ALIAS = "lanes";
14
+ export const LANES_ALIAS_DEPRECATION_LINE = "hq lanes is deprecated; use hq runners instead. The hq lanes name will be removed in a later release, after HQ core stops using it.";
15
+ /** True for either name of the command group. */
16
+ export function isRunnersGroupToken(token) {
17
+ return token === RUNNERS_COMMAND || token === LANES_ALIAS;
18
+ }
19
+ let deprecationWritten = false;
20
+ /**
21
+ * Subcommands that hooks, monitors and scripts run. HQ core's hooks treat any
22
+ * stderr from them as a failure, so the alias never prints the line for them.
23
+ */
24
+ export const MACHINE_SUBCOMMANDS = new Set(["monitor-check", "session-start", "link", "watch", "wait"]);
25
+ function processTerminalStreams() {
26
+ return { stdoutIsTTY: process.stdout.isTTY === true, stderrIsTTY: process.stderr.isTTY === true };
27
+ }
28
+ /**
29
+ * Write the deprecation line to stderr once per process. The fast routes and
30
+ * the Commander path can both see one invocation (monitor-check falls back to
31
+ * the full command graph), so the guard keeps it to one line. Callers decide
32
+ * whether a person is reading; see shouldWriteLanesAliasDeprecation.
33
+ */
34
+ export function writeLanesAliasDeprecation(write = (text) => {
35
+ process.stderr.write(text);
36
+ }) {
37
+ if (deprecationWritten)
38
+ return;
39
+ deprecationWritten = true;
40
+ write(`${LANES_ALIAS_DEPRECATION_LINE}\n`);
41
+ }
42
+ /**
43
+ * True when Commander argv (`node hq ...`) names the group through the alias:
44
+ * `hq lanes ...`, `hq --verbose lanes ...`, or `hq help lanes ...`. Mirrors the
45
+ * root-token rules of findLazyCommand so both agree on which root was asked for.
46
+ */
47
+ export function argvUsesLanesAlias(argv) {
48
+ let commandIndex = 2;
49
+ while (argv[commandIndex] === "--verbose")
50
+ commandIndex += 1;
51
+ const first = argv[commandIndex];
52
+ const token = first === "help" ? argv[commandIndex + 1] : first;
53
+ return token === LANES_ALIAS;
54
+ }
55
+ /**
56
+ * True when the line should print for this alias invocation. `groupArgs`
57
+ * starts at the group token (`["lanes", "list", ...]`). The line is for a
58
+ * person at a terminal only: never for a machine subcommand, never with
59
+ * `--json`, and never when stdout or stderr is not a terminal.
60
+ */
61
+ export function shouldWriteLanesAliasDeprecation(groupArgs, streams = processTerminalStreams()) {
62
+ if (groupArgs[0] !== LANES_ALIAS)
63
+ return false;
64
+ if (!streams.stdoutIsTTY || !streams.stderrIsTTY)
65
+ return false;
66
+ const subcommand = groupArgs[1];
67
+ if (subcommand !== undefined && MACHINE_SUBCOMMANDS.has(subcommand))
68
+ return false;
69
+ return !groupArgs.some((arg) => arg === "--json" || arg.startsWith("--json="));
70
+ }
71
+ /**
72
+ * Write the deprecation line when Commander argv invokes the group through
73
+ * the alias and a person is reading (see shouldWriteLanesAliasDeprecation).
74
+ */
75
+ export function writeLanesAliasDeprecationForArgv(argv, streams = processTerminalStreams()) {
76
+ if (!argvUsesLanesAlias(argv))
77
+ return;
78
+ const groupIndex = argv.indexOf(LANES_ALIAS, 2);
79
+ if (shouldWriteLanesAliasDeprecation(argv.slice(groupIndex), streams))
80
+ writeLanesAliasDeprecation();
81
+ }
82
+ /** Test seam: clear the once-per-process guard. */
83
+ export function resetLanesAliasDeprecationForTests() {
84
+ deprecationWritten = false;
85
+ }
86
+ //# sourceMappingURL=runners-alias.js.map
@@ -36,6 +36,7 @@ import { fileURLToPath } from "node:url";
36
36
  import { CLI_NAME } from "../cli-version.js";
37
37
  import { boundedDiagnosticValue } from "./package-root-diagnostics.js";
38
38
  import { isLockStale, UPDATE_LOCK_STALE_MS } from "./update-lock.js";
39
+ import { HQ_CLI_NPM_UPDATE_COMMAND } from "./npm-install-flags.js";
39
40
  /** Byte caps for the (hq-derived, path-shaped) diagnostic strings. */
40
41
  const SPECIFIER_BYTES = 256;
41
42
  const IMPORTER_BYTES = 256;
@@ -1298,16 +1299,17 @@ export function scrubHomeDirectoryPrefix(value, homeDirectory = homedir()) {
1298
1299
  * appended by {@link installTreeTornStderrLine}.
1299
1300
  */
1300
1301
  export const INSTALL_TREE_TORN_REMEDY = "hq-cli could not finish automatic install-tree recovery. Re-run your command; " +
1301
- "if it still fails, reinstall with `npm install -g @indigoai-us/hq-cli@latest` " +
1302
+ `if it still fails, reinstall with \`${HQ_CLI_NPM_UPDATE_COMMAND}\` ` +
1302
1303
  "(or `pnpm add -g @indigoai-us/hq-cli@latest` / `bun add -g @indigoai-us/hq-cli@latest` " +
1303
1304
  "when that manager owns your install).";
1304
1305
  /** Fixed repair guidance for an unchanged tree with no active updater signal. */
1305
1306
  export const INSTALL_TREE_STALE_REMEDY = "hq-cli's install tree is incomplete and no active updater was detected. " +
1306
- "Reinstall with `npm install -g @indigoai-us/hq-cli@latest` " +
1307
+ `Reinstall with \`${HQ_CLI_NPM_UPDATE_COMMAND}\` ` +
1307
1308
  "(or `pnpm add -g @indigoai-us/hq-cli@latest` / `bun add -g @indigoai-us/hq-cli@latest` " +
1308
1309
  "when that manager owns your install), then run the command again.";
1309
1310
  /** Guidance when a retired package sibling's activity could not be verified. */
1310
- export const INSTALL_TREE_RETIRED_UNVERIFIED_REMEDY = "hq-cli found a retired install sibling but could not verify whether an installer is still using it. Wait for any npm or desktop CLI update to finish, then run the command again. If no install is running, repair with `npm install -g @indigoai-us/hq-cli@latest` " +
1311
+ export const INSTALL_TREE_RETIRED_UNVERIFIED_REMEDY = "hq-cli found a retired install sibling but could not verify whether an installer is still using it. Wait for any npm or desktop CLI update to finish, then run the command again. " +
1312
+ `If no install is running, repair with \`${HQ_CLI_NPM_UPDATE_COMMAND}\` ` +
1311
1313
  "(or `pnpm add -g @indigoai-us/hq-cli@latest` / `bun add -g @indigoai-us/hq-cli@latest` " +
1312
1314
  "when that manager owns your install).";
1313
1315
  /**
@@ -0,0 +1,27 @@
1
+ /** Packages in hq-cli's install tree whose install scripts must run. */
2
+ export declare const HQ_CLI_INSTALL_SCRIPT_PACKAGES: readonly string[];
3
+ /** `--allow-scripts=<name>` for each package, then `--include=optional`. */
4
+ export declare function npmInstallScriptFlags(allowScripts: readonly string[]): string[];
5
+ /** The flags for an hq-cli install. */
6
+ export declare const HQ_CLI_NPM_INSTALL_FLAGS: readonly string[];
7
+ /**
8
+ * `install -g [--prefix <prefix>] <spec> <flags>` for npm. `allowScripts`
9
+ * defaults to hq-cli's list; pass another list for another package.
10
+ */
11
+ export declare function npmGlobalInstallArgv(spec: string, options?: {
12
+ prefix?: string;
13
+ allowScripts?: readonly string[];
14
+ }): string[];
15
+ /**
16
+ * An `npm install -g` command line for hq-cli to print to users. `prefixArg`
17
+ * is placed as given, so a caller that needs shell quoting passes it quoted.
18
+ */
19
+ export declare function hqCliNpmInstallCommand(options?: {
20
+ spec?: string;
21
+ prefixArg?: string;
22
+ }): string;
23
+ /** The repair command printed to users: reinstall hq-cli with every flag. */
24
+ export declare const HQ_CLI_NPM_REPAIR_COMMAND: string;
25
+ /** The update command printed to users: install hq-cli@latest with every flag. */
26
+ export declare const HQ_CLI_NPM_UPDATE_COMMAND: string;
27
+ //# sourceMappingURL=npm-install-flags.d.ts.map
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The npm flags every hq-cli install and repair command must carry.
3
+ *
4
+ * npm 12 blocks dependency install scripts unless the package is named in
5
+ * `--allow-scripts`, and npm 11.16 to 11.x runs them but warns. Without the
6
+ * names below, a self-update or rescue install leaves better-sqlite3,
7
+ * node-llama-cpp and the tree-sitter grammars unbuilt and skips hq-cli's own
8
+ * postinstall (which installs the native hook engine). `--include=optional`
9
+ * keeps the platform hook-engine package when the user's npm config omits
10
+ * optional dependencies.
11
+ *
12
+ * Older npm accepts both flags without failing: npm 10 accepts the unknown
13
+ * `allow-scripts` key silently and npm 11 before 11.16 accepts it with an
14
+ * "Unknown cli config" warning, and both run install scripts anyway. `--include` exists
15
+ * since npm 7. So the flags are passed on every npm version, with no
16
+ * `npm --version` probe.
17
+ *
18
+ * The package list matches the HQ desktop app's allow-list
19
+ * (`managed_npm_allow_scripts` in hq-desktop-app-src
20
+ * apps/sync/src-tauri/src/commands/install_deps.rs) and the build list in this
21
+ * repo's pnpm-workspace.yaml `allowBuilds`. Keep the three in step.
22
+ */
23
+ // No imports, on purpose: staged installers and resident processes load this
24
+ // file while an update may be replacing the package tree, so it must not read
25
+ // package.json when it loads. npm-install-flags.test.ts checks this name
26
+ // against package.json.
27
+ const CLI_NAME = "@indigoai-us/hq-cli";
28
+ /** Packages in hq-cli's install tree whose install scripts must run. */
29
+ export const HQ_CLI_INSTALL_SCRIPT_PACKAGES = [
30
+ CLI_NAME,
31
+ "better-sqlite3",
32
+ "node-llama-cpp",
33
+ "tree-sitter-go",
34
+ "tree-sitter-python",
35
+ "tree-sitter-rust",
36
+ "tree-sitter-typescript",
37
+ "tree-sitter-javascript",
38
+ ];
39
+ /** `--allow-scripts=<name>` for each package, then `--include=optional`. */
40
+ export function npmInstallScriptFlags(allowScripts) {
41
+ return [...allowScripts.map((name) => `--allow-scripts=${name}`), "--include=optional"];
42
+ }
43
+ /** The flags for an hq-cli install. */
44
+ export const HQ_CLI_NPM_INSTALL_FLAGS = npmInstallScriptFlags(HQ_CLI_INSTALL_SCRIPT_PACKAGES);
45
+ /**
46
+ * `install -g [--prefix <prefix>] <spec> <flags>` for npm. `allowScripts`
47
+ * defaults to hq-cli's list; pass another list for another package.
48
+ */
49
+ export function npmGlobalInstallArgv(spec, options = {}) {
50
+ const prefixArgs = options.prefix ? ["--prefix", options.prefix] : [];
51
+ const flags = options.allowScripts
52
+ ? npmInstallScriptFlags(options.allowScripts)
53
+ : HQ_CLI_NPM_INSTALL_FLAGS;
54
+ return ["install", "-g", ...prefixArgs, spec, ...flags];
55
+ }
56
+ /**
57
+ * An `npm install -g` command line for hq-cli to print to users. `prefixArg`
58
+ * is placed as given, so a caller that needs shell quoting passes it quoted.
59
+ */
60
+ export function hqCliNpmInstallCommand(options = {}) {
61
+ const spec = options.spec ?? `${CLI_NAME}@latest`;
62
+ return `npm ${npmGlobalInstallArgv(spec, { prefix: options.prefixArg }).join(" ")}`;
63
+ }
64
+ /** The repair command printed to users: reinstall hq-cli with every flag. */
65
+ export const HQ_CLI_NPM_REPAIR_COMMAND = hqCliNpmInstallCommand({ spec: CLI_NAME });
66
+ /** The update command printed to users: install hq-cli@latest with every flag. */
67
+ export const HQ_CLI_NPM_UPDATE_COMMAND = hqCliNpmInstallCommand();
68
+ //# sourceMappingURL=npm-install-flags.js.map
@@ -79,7 +79,7 @@ export function packageUseLeasePurposeForArgv(argv) {
79
79
  (args[0] === "bot" && (args[1] === "run" || (args[1] === "logs" && hasOption("--follow", "-f")))) ||
80
80
  (args[0] === "daemon" && args[1] === "logs" && hasOption("--follow", "-f")) ||
81
81
  (args[0] === "integrations" && args[1] === "connect") ||
82
- (args[0] === "lanes" && ["watch", "message", "resume"].includes(args[1] ?? "")) ||
82
+ ((args[0] === "runners" || args[0] === "lanes") && ["watch", "message", "resume"].includes(args[1] ?? "")) ||
83
83
  (args[0] === "monitor" && ["wait", "_run"].includes(args[1] ?? "")) ||
84
84
  (args[0] === "pack" && args[1] === "install") ||
85
85
  (args[0] === "pkg" && args[1] === "update") ||
@@ -27,6 +27,7 @@
27
27
  // 2. SHAPE: the distinctive "Could not locate the bindings file" text, OR a
28
28
  // `better_sqlite3.node` reference that co-occurs with a genuine
29
29
  // module-load failure. Either alone would be too loose.
30
+ import { HQ_CLI_NPM_REPAIR_COMMAND } from "./npm-install-flags.js";
30
31
  /** The `bindings` module's exact "not found" text — sufficient on its own. */
31
32
  const BINDINGS_NOT_LOCATED = /could not locate the bindings file/i;
32
33
  /** A reference to the compiled better-sqlite3 module. */
@@ -49,7 +50,7 @@ export const QMD_NATIVE_BINDING_REMEDY = "hq's local search index can't start: i
49
50
  "which leaves better-sqlite3 uncompiled. Approve the build and reinstall — for " +
50
51
  "a global install run `pnpm approve-builds -g better-sqlite3` (drop -g for a " +
51
52
  "local project). npm 11.16 and later skip install scripts unless you opt in; reinstall with " +
52
- "`npm install -g @indigoai-us/hq-cli --allow-scripts=better-sqlite3`. " +
53
+ `\`${HQ_CLI_NPM_REPAIR_COMMAND}\`. ` +
53
54
  "Or reinstall hq with npm, then run the command again.";
54
55
  /**
55
56
  * The text to inspect. For a QmdExitError the captured stderr/stdout is the qmd
@@ -67,6 +67,7 @@ import { isCliTelemetryDisabled } from "./cli-telemetry.js";
67
67
  import { CLI_NAME, CLI_VERSION } from "../cli-version.js";
68
68
  import { buildBunInstallArgv, buildPnpmInstallArgv, buildPrefixedInstallArgv, buildSpawnPlan, canWriteNpmInstall, captureNonWritableNpmPrefixNotice, claimNonWritableNpmPrefixNotice, checkUpdateConvergence, derivePnpmHome, detachUpdateSupervisor, isBunManagedPackageDir, isLocalDependencyInstall, isPnpmManagedPackageDir, normalizeRunningInstall, nonWritablePrefixNote, openInstallOutput, resolvePnpmPathInstall, pnpmUpdateEnv, pnpmInstalledVersion, performPnpmUpdate, resolveRunningInstall, runUpdateCommand, runSupervisedUpdateCommand, UPDATE_RECURSION_GUARD_ENV, } from "./version-gate.js";
69
69
  import { canStageInstall, stagedNpmInstall } from "./staged-install.js";
70
+ import { npmGlobalInstallArgv } from "./npm-install-flags.js";
70
71
  import { acquireUpdateLock as acquireSharedUpdateLock } from "./update-lock.js";
71
72
  import { markLatestIneffective } from "./version-check.js";
72
73
  import { fileSelfUpdateBackoff } from "./self-update-backoff.js";
@@ -696,7 +697,7 @@ export function buildSelfUpdatePlan(install) {
696
697
  return { cmd: "bun", args: buildBunInstallArgv() };
697
698
  if (install.prefix)
698
699
  return { cmd: "npm", args: buildPrefixedInstallArgv(install.prefix) };
699
- return { cmd: "npm", args: ["install", "-g", `${CLI_NAME}@latest`] };
700
+ return { cmd: "npm", args: npmGlobalInstallArgv(`${CLI_NAME}@latest`) };
700
701
  }
701
702
  /**
702
703
  * Install without letting the package manager write to OUR stdout. The startup
@@ -17,6 +17,7 @@ import { randomBytes } from "node:crypto";
17
17
  import * as fs from "node:fs";
18
18
  import * as path from "node:path";
19
19
  import { CLI_NAME } from "../cli-version.js";
20
+ import { npmGlobalInstallArgv } from "./npm-install-flags.js";
20
21
  import { runUpdateCommand } from "./version-gate.js";
21
22
  /** Set for the staging install; hq-cli's own postinstall skips itself on it. */
22
23
  export const STAGED_INSTALL_ENV = "HQ_STAGED_INSTALL";
@@ -57,7 +58,7 @@ export function stagedNpmInstall(install, version, deps = {}) {
57
58
  const backup = path.join(path.dirname(live), `.hq-cli-backup-${tag}`);
58
59
  let keepBackup = false;
59
60
  try {
60
- const result = run("npm", ["install", "-g", "--prefix", staging, `${CLI_NAME}@${version}`], { ...env, [STAGED_INSTALL_ENV]: "1" });
61
+ const result = run("npm", npmGlobalInstallArgv(`${CLI_NAME}@${version}`, { prefix: staging }), { ...env, [STAGED_INSTALL_ENV]: "1" });
61
62
  if (!result.ok)
62
63
  return result;
63
64
  const reported = probe(staged);
@@ -4,6 +4,7 @@ import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { isMainModule } from "./is-main-module.js";
7
+ import { npmGlobalInstallArgv } from "./npm-install-flags.js";
7
8
  import { removeHqCliPs1Shims } from "../lib/windows/ps1-shims.js";
8
9
  const PACKAGE_NAME = "@indigoai-us/hq-cli";
9
10
  const RANDOM_HEX_BYTES = 6;
@@ -84,7 +85,7 @@ export function installNpmPackageStaged(prefix, packageSpec, runner, platform =
84
85
  let stagePrefix;
85
86
  try {
86
87
  stagePrefix = temporaryRoot();
87
- const npmResult = runner("npm", ["install", "-g", "--prefix", stagePrefix, packageSpec], { ...process.env, HQ_STAGED_INSTALL: "1" });
88
+ const npmResult = runner("npm", npmGlobalInstallArgv(packageSpec, { prefix: stagePrefix }), { ...process.env, HQ_STAGED_INSTALL: "1" });
88
89
  if (!npmResult.ok)
89
90
  return npmResult;
90
91
  const activation = activate(prefix, stagePrefix, platform);
@@ -9,7 +9,8 @@ import type { UploadAuthor } from "@indigoai-us/hq-cloud";
9
9
  * Resolve the upload author from the cached id token of the session the push
10
10
  * uses. Decoded, not verified: Cognito verified it at issuance and no auth
11
11
  * decision rides on the label. Returns undefined when that session has no
12
- * cached token or the token lacks `sub`/`email`; share() then skips the stamp.
12
+ * cached token or the token lacks `sub`; share() then skips the stamp. A token
13
+ * with `sub` and no `email` yields an author with an empty email (sub only).
13
14
  */
14
15
  export declare function resolveUploadAuthor(env?: NodeJS.ProcessEnv, home?: string): UploadAuthor | undefined;
15
16
  //# sourceMappingURL=upload-author.d.ts.map
@@ -14,10 +14,13 @@ function authorFromIdToken(idToken) {
14
14
  return undefined;
15
15
  try {
16
16
  const claims = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
17
- if (claims.sub && claims.email) {
18
- return { userSub: claims.sub, email: claims.email };
19
- }
20
- return undefined;
17
+ if (!claims.sub)
18
+ return undefined;
19
+ // feedback_65ee9e51: a machine token (agent, Outpost) can carry no email.
20
+ // Stamp its sub alone, as hq-sync-runner does, so the files it creates
21
+ // carry `created-by-sub` and the unattended delete hold lets it delete
22
+ // them later. hq-cloud writes no `created-by` for the empty email.
23
+ return { userSub: claims.sub, email: claims.email ?? "" };
21
24
  }
22
25
  catch {
23
26
  // Unparseable claims only mean no author label; share() skips the stamp.
@@ -28,7 +31,8 @@ function authorFromIdToken(idToken) {
28
31
  * Resolve the upload author from the cached id token of the session the push
29
32
  * uses. Decoded, not verified: Cognito verified it at issuance and no auth
30
33
  * decision rides on the label. Returns undefined when that session has no
31
- * cached token or the token lacks `sub`/`email`; share() then skips the stamp.
34
+ * cached token or the token lacks `sub`; share() then skips the stamp. A token
35
+ * with `sub` and no `email` yields an author with an empty email (sub only).
32
36
  */
33
37
  export function resolveUploadAuthor(env = process.env, home = os.homedir()) {
34
38
  const tokens = wantsMachineCognitoTokens({}, env)
@@ -3,6 +3,7 @@ import * as os from "os";
3
3
  import * as path from "path";
4
4
  import semver from "semver";
5
5
  import { CLI_VERSION } from "../cli-version.js";
6
+ import { HQ_CLI_NPM_UPDATE_COMMAND } from "./npm-install-flags.js";
6
7
  const PACKAGE_NAME = "@indigoai-us/hq-cli";
7
8
  const REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
8
9
  const CACHE_TTL_MS = 60 * 60 * 1000; // 1h — catch fresh releases within the hour
@@ -228,7 +229,7 @@ export async function printCachedVersionNudge(stderr = process.stderr) {
228
229
  return;
229
230
  const latest = staleAgainstCachedLatest();
230
231
  if (latest) {
231
- stderr.write(`Update available: ${latest}. Update with npm install -g @indigoai-us/hq-cli@latest, pnpm add -g @indigoai-us/hq-cli@latest, or bun add -g @indigoai-us/hq-cli@latest.\n`);
232
+ stderr.write(`Update available: ${latest}. Update with ${HQ_CLI_NPM_UPDATE_COMMAND}, pnpm add -g @indigoai-us/hq-cli@latest, or bun add -g @indigoai-us/hq-cli@latest.\n`);
232
233
  }
233
234
  }
234
235
  export async function printVersionAndNudge(stdout = process.stdout, stderr = process.stderr) {
@@ -43,6 +43,7 @@ import { Sentry } from "../sentry.js";
43
43
  import { isCliTelemetryDisabled } from "./cli-telemetry.js";
44
44
  import { DEFAULT_VAULT_API_URL } from "./cognito-session.js";
45
45
  import { acquireUpdateLock, } from "./update-lock.js";
46
+ import { HQ_CLI_NPM_UPDATE_COMMAND, hqCliNpmInstallCommand, npmGlobalInstallArgv } from "./npm-install-flags.js";
46
47
  /** Prevent an update package manager's lifecycle child from starting another updater. */
47
48
  export const UPDATE_RECURSION_GUARD_ENV = "HQ_RESCUE_SELF_UPDATED";
48
49
  const CLIENT_ID = "hq-cli";
@@ -668,14 +669,14 @@ export function nonWritablePrefixNote(prefix, platform = process.platform) {
668
669
  if (platform === "win32") {
669
670
  const windowsPrefixArg = `"${prefix.replace(/"/g, '""')}"`;
670
671
  return (`The npm global prefix ${prefix} is not writable by the current user, so hq-cli was not updated. ` +
671
- `Open PowerShell as Administrator and run \`npm install -g --prefix ${windowsPrefixArg} ${CLI_NAME}@latest\`, ` +
672
+ `Open PowerShell as Administrator and run \`${hqCliNpmInstallCommand({ prefixArg: windowsPrefixArg })}\`, ` +
672
673
  `or set a user-owned prefix with \`npm config set prefix "$env:APPDATA\\npm"\` and run ` +
673
- `\`npm install -g ${CLI_NAME}@latest\` from that PowerShell session.`);
674
+ `\`${HQ_CLI_NPM_UPDATE_COMMAND}\` from that PowerShell session.`);
674
675
  }
675
676
  return (`The npm global prefix ${prefix} is not writable by the current user, so hq-cli was not updated. ` +
676
- `Run \`sudo npm install -g --prefix ${prefixArg} ${CLI_NAME}@latest\` to update this install, ` +
677
+ `Run \`sudo ${hqCliNpmInstallCommand({ prefixArg })}\` to update this install, ` +
677
678
  `or switch to a user-owned prefix with \`npm config set prefix ~/.npm-global\`, then run ` +
678
- `\`npm install -g ${CLI_NAME}@latest\` after adding ~/.npm-global/bin to PATH.`);
679
+ `\`${HQ_CLI_NPM_UPDATE_COMMAND}\` after adding ~/.npm-global/bin to PATH.`);
679
680
  }
680
681
  /**
681
682
  * Derive `PNPM_HOME` from a pnpm-managed install's own path. pnpm resolves its
@@ -750,7 +751,7 @@ export function pnpmUpdateEnv(install, base = process.env) {
750
751
  return Object.keys(result).some((key) => result[key] !== base[key]) ? result : undefined;
751
752
  }
752
753
  export function buildPrefixedInstallArgv(prefix) {
753
- return ["install", "-g", "--prefix", prefix, LATEST_PACKAGE_SPEC];
754
+ return npmGlobalInstallArgv(LATEST_PACKAGE_SPEC, { prefix });
754
755
  }
755
756
  /**
756
757
  * Argv for updating a pnpm-managed global install. `pnpm add -g` rewrites the
@@ -2083,7 +2084,7 @@ export function shouldSkipGate(argv) {
2083
2084
  // Hook-time deliveries must finish inside the provider's timeout budget.
2084
2085
  // process.argv slots 0 and 1 are the runtime and CLI entry point. Inspect
2085
2086
  // command positions only; user arguments may legitimately contain these words.
2086
- const hookTimeLinkDelivery = argv[2] === "lanes" && argv[3] === "link" && argv[4] === "_deliver";
2087
+ const hookTimeLinkDelivery = (argv[2] === "runners" || argv[2] === "lanes") && argv[3] === "link" && argv[4] === "_deliver";
2087
2088
  return hookTimeLinkDelivery || isVersionRequest(argv) || argv.some((a) => a === "--version" ||
2088
2089
  a === "-V" ||
2089
2090
  a === "-v" ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.208",
3
+ "version": "5.345.211",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -117,11 +117,11 @@
117
117
  "*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
118
118
  },
119
119
  "optionalDependencies": {
120
- "@indigoai-us/hq-hook-win32-x64": "5.345.208",
121
- "@indigoai-us/hq-hook-win32-arm64": "5.345.208",
122
- "@indigoai-us/hq-hook-darwin-x64": "5.345.208",
123
- "@indigoai-us/hq-hook-darwin-arm64": "5.345.208",
124
- "@indigoai-us/hq-hook-linux-x64": "5.345.208",
125
- "@indigoai-us/hq-hook-linux-arm64": "5.345.208"
120
+ "@indigoai-us/hq-hook-win32-x64": "5.345.211",
121
+ "@indigoai-us/hq-hook-win32-arm64": "5.345.211",
122
+ "@indigoai-us/hq-hook-darwin-x64": "5.345.211",
123
+ "@indigoai-us/hq-hook-darwin-arm64": "5.345.211",
124
+ "@indigoai-us/hq-hook-linux-x64": "5.345.211",
125
+ "@indigoai-us/hq-hook-linux-arm64": "5.345.211"
126
126
  }
127
127
  }