@indigoai-us/hq-cli 5.345.212-beta.0 → 5.345.214
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.
- package/CHANGELOG.md +40 -1
- package/dist/bin/hq-auth-refresh.js +2 -1
- package/dist/command-catalog.generated.d.ts +308 -43
- package/dist/command-catalog.generated.js +373 -43
- package/dist/command-registration-plan.d.ts +15 -0
- package/dist/command-registration-plan.js +20 -1
- package/dist/commands/agent-inbox.d.ts +11 -1
- package/dist/commands/agent-inbox.js +128 -38
- package/dist/commands/agent-kit.js +2 -2
- package/dist/commands/agents.js +6 -1
- package/dist/commands/billing.js +17 -4
- package/dist/commands/core-handoff.js +1 -0
- package/dist/commands/core-hq-session-native.js +2 -2
- package/dist/commands/core-pin-native.js +1 -1
- package/dist/commands/core-policy.js +1 -1
- package/dist/commands/core-resolve-company-native.js +1 -1
- package/dist/commands/core-sentry-report-fast.d.ts +2 -0
- package/dist/commands/core-sentry-report-fast.js +3 -1
- package/dist/commands/daemon.js +68 -6
- package/dist/commands/files.js +2 -2
- package/dist/commands/integrations-api.d.ts +11 -0
- package/dist/commands/integrations-connect.d.ts +9 -1
- package/dist/commands/integrations-connect.js +154 -18
- package/dist/commands/integrations-core.d.ts +1 -1
- package/dist/commands/integrations-core.js +18 -10
- package/dist/commands/integrations.js +1 -1
- package/dist/commands/lanes-link.js +10 -5
- package/dist/commands/lanes.js +34 -16
- package/dist/commands/rescue.js +13 -0
- package/dist/commands/secrets.d.ts +11 -0
- package/dist/commands/secrets.js +41 -7
- package/dist/index.js +2 -0
- package/dist/lazy-commands.js +6 -1
- package/dist/lib/agent-kit/inbox-fetch.d.ts +122 -1
- package/dist/lib/agent-kit/inbox-fetch.js +215 -3
- package/dist/lib/agent-kit/inbox-redact.js +1 -1
- package/dist/lib/agent-kit/inbox-state.d.ts +98 -1
- package/dist/lib/agent-kit/inbox-state.js +261 -4
- package/dist/lib/agent-kit/mcp/tools.d.ts +3 -3
- package/dist/lib/agent-kit/mcp/tools.js +68 -25
- package/dist/lib/agent-kit/run/inbox.js +4 -2
- package/dist/lib/agent-kit/skills.js +4 -1
- package/dist/lib/agent-kit/wake.d.ts +9 -1
- package/dist/lib/agent-kit/wake.js +10 -3
- package/dist/lib/billing/usage-only.d.ts +4 -1
- package/dist/lib/billing/usage-only.js +7 -2
- package/dist/lib/bot/fleet-cron.js +193 -14
- package/dist/lib/bot/fleet-download.d.ts +2 -0
- package/dist/lib/bot/fleet-download.js +23 -0
- package/dist/lib/bot/fleet-local.d.ts +1 -0
- package/dist/lib/bot/fleet-local.js +41 -8
- package/dist/lib/capacity/ledger.d.ts +7 -0
- package/dist/lib/capacity/ledger.js +31 -1
- package/dist/lib/capacity/project.d.ts +1 -1
- package/dist/lib/capacity/project.js +13 -4
- package/dist/lib/capacity/route.d.ts +10 -0
- package/dist/lib/capacity/route.js +16 -0
- package/dist/lib/core-utils/session-id.d.ts +1 -1
- package/dist/lib/core-utils/session-id.js +4 -0
- package/dist/lib/daemon/install.d.ts +15 -0
- package/dist/lib/daemon/install.js +31 -0
- package/dist/lib/daemon/migrate.js +29 -4
- package/dist/lib/daemon/run.js +9 -1
- package/dist/lib/daemon/updater.d.ts +34 -2
- package/dist/lib/daemon/updater.js +51 -2
- package/dist/lib/doctor/__testing__/run-doctor.js +4 -0
- package/dist/lib/doctor/checks/jq.d.ts +27 -0
- package/dist/lib/doctor/checks/jq.js +82 -0
- package/dist/lib/doctor/checks/release-links.d.ts +50 -8
- package/dist/lib/doctor/checks/release-links.js +260 -24
- package/dist/lib/doctor/fix/apply.js +24 -8
- package/dist/lib/doctor/fix/remediation.js +15 -5
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/flag-snapshot-file.js +36 -8
- package/dist/lib/install/codex-targets.d.ts +52 -1
- package/dist/lib/install/codex-targets.js +77 -2
- package/dist/lib/lanes/autopilot-registry.d.ts +14 -0
- package/dist/lib/lanes/autopilot-registry.js +59 -7
- package/dist/lib/lanes/links.d.ts +14 -0
- package/dist/lib/lanes/links.js +320 -25
- package/dist/lib/lanes/monitor.d.ts +4 -1
- package/dist/lib/lanes/monitor.js +47 -10
- package/dist/lib/lanes/outpost-pruner-install.d.ts +10 -0
- package/dist/lib/lanes/outpost-pruner-install.js +4 -3
- package/dist/lib/lanes/spawn.js +8 -1
- package/dist/lib/lanes/watch.js +31 -0
- package/dist/lib/onboarding/checkpoint.d.ts +6 -0
- package/dist/lib/onboarding/checkpoint.js +6 -0
- package/dist/lib/onboarding/orchestrator.d.ts +3 -1
- package/dist/lib/onboarding/orchestrator.js +62 -9
- package/dist/lib/onboarding/types.d.ts +8 -0
- package/dist/lib/work-context/organize.d.ts +23 -1
- package/dist/lib/work-context/organize.js +25 -3
- package/dist/lib/work-context/reconcile.js +3 -2
- package/dist/main.js +3 -1
- package/dist/secrets-env-action.js +7 -5
- package/dist/sentry-init.d.ts +2 -0
- package/dist/sentry-init.js +13 -2
- package/dist/sentry.d.ts +2 -0
- package/dist/sentry.js +5 -1
- package/dist/startup-registration.js +7 -2
- package/dist/utils/billing-gate.d.ts +12 -16
- package/dist/utils/billing-gate.js +17 -18
- package/dist/utils/cli-network-lifecycle.d.ts +9 -0
- package/dist/utils/cli-network-lifecycle.js +52 -0
- package/dist/utils/install-tree-torn.d.ts +22 -4
- package/dist/utils/install-tree-torn.js +24 -0
- package/dist/utils/registration-plan-error.d.ts +22 -0
- package/dist/utils/registration-plan-error.js +27 -0
- package/dist/utils/safe-link.d.ts +63 -0
- package/dist/utils/safe-link.js +246 -0
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/dist/utils/sentry-keepalive-transport.d.ts +28 -0
- package/dist/utils/sentry-keepalive-transport.js +70 -0
- package/dist/utils/unauthorized-error.d.ts +36 -0
- package/dist/utils/unauthorized-error.js +105 -0
- package/dist/utils/vault-api.js +7 -5
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +17 -0
|
@@ -262,6 +262,21 @@ export declare function startDaemonUnit(host: DaemonHost, deps: InstallDeps & {
|
|
|
262
262
|
daemonPid: () => number | null;
|
|
263
263
|
waitMs?: number;
|
|
264
264
|
}): StartDaemonResult;
|
|
265
|
+
/** How long `hq daemon install` waits for a live daemon before taking over the older mesh unit. */
|
|
266
|
+
export declare const DAEMON_ALIVE_WAIT_MS = 10000;
|
|
267
|
+
/**
|
|
268
|
+
* Wait up to `maxMs` for a running daemon to hold the lock (the same lock
|
|
269
|
+
* check the Windows path uses). launchd and systemd report a unit as loaded
|
|
270
|
+
* even when the daemon exits at once and crash-loops, so "installed and
|
|
271
|
+
* started" alone cannot gate a takeover (feedback_c85ad51b review).
|
|
272
|
+
*
|
|
273
|
+
* A daemon started after `previous` counts once the same live record is seen
|
|
274
|
+
* on two polls in a row, so a process that takes the lock and dies at startup
|
|
275
|
+
* does not count. The daemon from before the install counts only if it is
|
|
276
|
+
* still alive at the end of the wait (the service manager kept the previous
|
|
277
|
+
* definition running). Returns the live record, or null when none appeared.
|
|
278
|
+
*/
|
|
279
|
+
export declare function waitForLiveDaemon(runningDaemon: () => PidLockRecord | null, previous: PidLockRecord | null, sleep?: SleepFn, maxMs?: number): PidLockRecord | null;
|
|
265
280
|
/**
|
|
266
281
|
* PowerShell script that lists Windows sessions as `id|state|DOMAIN\user`
|
|
267
282
|
* lines through WTSEnumerateSessions and WTSQuerySessionInformation. State is
|
|
@@ -835,6 +835,37 @@ function waitForNewDaemon(runningDaemon, previous, sleep) {
|
|
|
835
835
|
sleep(WINDOWS_START_POLL_MS);
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
|
+
/** How long `hq daemon install` waits for a live daemon before taking over the older mesh unit. */
|
|
839
|
+
export const DAEMON_ALIVE_WAIT_MS = 10_000;
|
|
840
|
+
/**
|
|
841
|
+
* Wait up to `maxMs` for a running daemon to hold the lock (the same lock
|
|
842
|
+
* check the Windows path uses). launchd and systemd report a unit as loaded
|
|
843
|
+
* even when the daemon exits at once and crash-loops, so "installed and
|
|
844
|
+
* started" alone cannot gate a takeover (feedback_c85ad51b review).
|
|
845
|
+
*
|
|
846
|
+
* A daemon started after `previous` counts once the same live record is seen
|
|
847
|
+
* on two polls in a row, so a process that takes the lock and dies at startup
|
|
848
|
+
* does not count. The daemon from before the install counts only if it is
|
|
849
|
+
* still alive at the end of the wait (the service manager kept the previous
|
|
850
|
+
* definition running). Returns the live record, or null when none appeared.
|
|
851
|
+
*/
|
|
852
|
+
export function waitForLiveDaemon(runningDaemon, previous, sleep = blockingSleep, maxMs = DAEMON_ALIVE_WAIT_MS) {
|
|
853
|
+
let seen = null;
|
|
854
|
+
for (let waited = 0;; waited += WINDOWS_START_POLL_MS) {
|
|
855
|
+
const now = runningDaemon();
|
|
856
|
+
if (now && isNewDaemon(now, previous)) {
|
|
857
|
+
if (seen && seen.pid === now.pid && seen.ts === now.ts)
|
|
858
|
+
return now;
|
|
859
|
+
seen = now;
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
seen = null;
|
|
863
|
+
}
|
|
864
|
+
if (waited >= maxMs)
|
|
865
|
+
return now && previous && !isNewDaemon(now, previous) ? now : null;
|
|
866
|
+
sleep(WINDOWS_START_POLL_MS);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
838
869
|
/**
|
|
839
870
|
* PowerShell script that lists Windows sessions as `id|state|DOMAIN\user`
|
|
840
871
|
* lines through WTSEnumerateSessions and WTSQuerySessionInformation. State is
|
|
@@ -84,12 +84,19 @@ function moveFile(from, to) {
|
|
|
84
84
|
fs.rmSync(from);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
function isFile(p) {
|
|
88
|
+
try {
|
|
89
|
+
return fs.lstatSync(p).isFile();
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
87
95
|
/** schtasks /Create /XML reads UTF-16LE with a BOM, the format /Query /XML declares. */
|
|
88
96
|
function encodeTaskXml(xml) {
|
|
89
97
|
return Buffer.from(`\uFEFF${xml.replace(/^\uFEFF/, "")}`, "utf16le");
|
|
90
98
|
}
|
|
91
|
-
function adoptOne(unit, deps) {
|
|
92
|
-
const to = path.join(storeFor(unit.kind, deps).dir, savedName(unit));
|
|
99
|
+
function adoptOne(unit, deps, to) {
|
|
93
100
|
switch (unit.kind) {
|
|
94
101
|
case "launchd": {
|
|
95
102
|
if (!unit.path)
|
|
@@ -154,16 +161,34 @@ export function adoptLegacyUnits(units, deps) {
|
|
|
154
161
|
continue;
|
|
155
162
|
}
|
|
156
163
|
const store = storeFor(unit.kind, deps);
|
|
164
|
+
// A unit taken over before can come back (a manual `hq mesh daemon
|
|
165
|
+
// install`), and `hq daemon install` now takes it over again. Keep the
|
|
166
|
+
// first saved definition and its record entry: the new definition goes to
|
|
167
|
+
// a timestamped file next to it, so the saved copy is never overwritten
|
|
168
|
+
// and the record never lists the unit twice (feedback_c85ad51b review).
|
|
169
|
+
const sameUnit = (r) => r.kind === unit.kind && r.name === unit.name;
|
|
170
|
+
const prior = recordOf(store).find((r) => sameUnit(r) && !r.definitionMissing && fs.existsSync(r.movedTo));
|
|
171
|
+
const savedTo = path.join(store.dir, savedName(unit));
|
|
172
|
+
const to = prior ? `${savedTo}.${now()}` : savedTo;
|
|
157
173
|
let adoptedFields;
|
|
158
174
|
try {
|
|
159
|
-
|
|
175
|
+
// A stray saved file with no record entry is kept too, renamed aside, so
|
|
176
|
+
// the canonical name (which a system-unit restore checks) stays free.
|
|
177
|
+
if (!prior && isFile(savedTo))
|
|
178
|
+
moveFile(savedTo, `${savedTo}.${now()}`);
|
|
179
|
+
adoptedFields = adoptOne(unit, deps, to);
|
|
160
180
|
}
|
|
161
181
|
catch (err) {
|
|
162
182
|
result.failed.push({ unit, error: err.message });
|
|
163
183
|
continue;
|
|
164
184
|
}
|
|
185
|
+
if (prior) {
|
|
186
|
+
// Stopped and moved aside; the existing record still restores the first copy.
|
|
187
|
+
result.adopted.push(prior);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
165
190
|
const adopted = { ...unit, ...adoptedFields, adoptedAt: now() };
|
|
166
|
-
const next = [...recordOf(store), adopted];
|
|
191
|
+
const next = [...recordOf(store).filter((r) => !sameUnit(r)), adopted];
|
|
167
192
|
try {
|
|
168
193
|
// Record each unit as soon as it is moved, so a failure later in the
|
|
169
194
|
// list never loses track of one already taken over.
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -575,7 +575,15 @@ export function prepareUnitStart(unit, log, alive) {
|
|
|
575
575
|
* an on-failure unit down. The daemon's updater handles CLI updates.
|
|
576
576
|
*/
|
|
577
577
|
export function unitProcessEnv(base, unit) {
|
|
578
|
-
|
|
578
|
+
// HQ_DAEMON_CLI_VERSION tells the updater unit which release this daemon
|
|
579
|
+
// runs when hqd (HQ Anywhere) is off, so it can replace an older daemon.
|
|
580
|
+
const env = {
|
|
581
|
+
...base,
|
|
582
|
+
...unit.env,
|
|
583
|
+
HQ_DAEMON_UNIT: unit.id,
|
|
584
|
+
HQ_DAEMON_CLI_VERSION: CLI_VERSION,
|
|
585
|
+
HQ_NO_UPDATE_CHECK: "1",
|
|
586
|
+
};
|
|
579
587
|
for (const key of DAEMON_CHILD_ONE_SHOT_KEYS)
|
|
580
588
|
delete env[key];
|
|
581
589
|
// Scheduled hq commands stay eligible for Sentry. The resident mark goes only
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* 3. Install or update the daemon's own hq-cloud (sync and the outpost
|
|
12
12
|
* heartbeat run from it when it is newer than the CLI's bundled copy), and
|
|
13
13
|
* restart sync and the heartbeat right after it changes.
|
|
14
|
-
* 4. After a CLI update,
|
|
15
|
-
*
|
|
14
|
+
* 4. After a CLI update, or when the running daemon reports an older version
|
|
15
|
+
* than the CLI on disk, ask the daemon to restart itself so the supervisor
|
|
16
|
+
* and every service run the new version. The remote-control hosts notice an
|
|
16
17
|
* updated Claude or Codex on disk themselves and restart once idle.
|
|
17
18
|
*/
|
|
18
19
|
import type { SelfUpdateOutcome } from "../../utils/self-update.js";
|
|
@@ -36,6 +37,15 @@ export interface UpdaterDeps {
|
|
|
36
37
|
/** The units on this machine that run hq-cloud code, restarted after it updates. */
|
|
37
38
|
hqCloudUnits: readonly string[];
|
|
38
39
|
requestDaemonRestart: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* The version of the hq CLI on disk (this process's own; the daemon starts
|
|
42
|
+
* each unit from the installed CLI) and a probe for the version the running
|
|
43
|
+
* daemon reports. When the daemon is older it is restarted even though this
|
|
44
|
+
* run updated nothing: the CLI may have been replaced by the desktop app,
|
|
45
|
+
* `hq update` or npm while a daemon from an older release kept running.
|
|
46
|
+
*/
|
|
47
|
+
installedCliVersion?: string;
|
|
48
|
+
runningDaemonVersion?: () => Promise<string | null>;
|
|
39
49
|
/** Restart one unit (a restart request to the running daemon). */
|
|
40
50
|
requestRestart: (unit: string) => void;
|
|
41
51
|
log: (line: string) => void;
|
|
@@ -45,6 +55,28 @@ export interface UpdaterResult {
|
|
|
45
55
|
/** Tools whose version changed in this run. */
|
|
46
56
|
updated: ToolName[];
|
|
47
57
|
}
|
|
58
|
+
/** Only a strictly older, parseable daemon version triggers a restart, so a dev build never loops. */
|
|
59
|
+
export declare function daemonIsOlderThanCli(running: string, installed: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The version a daemon handed to the staged child bootstrap that started this
|
|
62
|
+
* unit: `<node> <...>/hq-child-bootstrap.mjs <prefix> <version> [args]`.
|
|
63
|
+
* Daemons have started units this way since 2026-10-05 (#1541).
|
|
64
|
+
*/
|
|
65
|
+
export declare function daemonVersionFromBootstrapCommandLine(line: string | null): string | null;
|
|
66
|
+
export interface RunningDaemonVersionDeps {
|
|
67
|
+
/** Ask hqd; it listens only while HQ Anywhere is on, so this often fails. */
|
|
68
|
+
ping: () => Promise<string>;
|
|
69
|
+
env: NodeJS.ProcessEnv;
|
|
70
|
+
/** The command line of this unit's parent process (the child bootstrap). */
|
|
71
|
+
parentCommandLine: () => string | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The hq-cli version the running daemon was started from. hqd first; then the
|
|
75
|
+
* version a newer daemon puts in the unit's environment; then the version an
|
|
76
|
+
* older daemon passed to the child bootstrap, which covers daemons from before
|
|
77
|
+
* this release on machines with HQ Anywhere off.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveRunningDaemonVersion(deps: RunningDaemonVersionDeps): Promise<string | null>;
|
|
48
80
|
export declare function runDaemonUpdater(deps: UpdaterDeps): Promise<UpdaterResult>;
|
|
49
81
|
/**
|
|
50
82
|
* The variables for the updater's own CLI update. Every supervised service
|
|
@@ -11,13 +11,55 @@
|
|
|
11
11
|
* 3. Install or update the daemon's own hq-cloud (sync and the outpost
|
|
12
12
|
* heartbeat run from it when it is newer than the CLI's bundled copy), and
|
|
13
13
|
* restart sync and the heartbeat right after it changes.
|
|
14
|
-
* 4. After a CLI update,
|
|
15
|
-
*
|
|
14
|
+
* 4. After a CLI update, or when the running daemon reports an older version
|
|
15
|
+
* than the CLI on disk, ask the daemon to restart itself so the supervisor
|
|
16
|
+
* and every service run the new version. The remote-control hosts notice an
|
|
16
17
|
* updated Claude or Codex on disk themselves and restart once idle.
|
|
17
18
|
*/
|
|
18
19
|
import { spawnSync } from "node:child_process";
|
|
19
20
|
import * as fs from "node:fs";
|
|
21
|
+
import semver from "semver";
|
|
20
22
|
import { locateTool, toolUpdateCommand } from "./tools.js";
|
|
23
|
+
/** Only a strictly older, parseable daemon version triggers a restart, so a dev build never loops. */
|
|
24
|
+
export function daemonIsOlderThanCli(running, installed) {
|
|
25
|
+
const r = semver.valid(running);
|
|
26
|
+
const i = semver.valid(installed);
|
|
27
|
+
return r !== null && i !== null && semver.lt(r, i);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The version a daemon handed to the staged child bootstrap that started this
|
|
31
|
+
* unit: `<node> <...>/hq-child-bootstrap.mjs <prefix> <version> [args]`.
|
|
32
|
+
* Daemons have started units this way since 2026-10-05 (#1541).
|
|
33
|
+
*/
|
|
34
|
+
export function daemonVersionFromBootstrapCommandLine(line) {
|
|
35
|
+
if (!line)
|
|
36
|
+
return null;
|
|
37
|
+
const match = /hq-child-bootstrap\.m?js\s.*?(?:^|\s)(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?=\s|$)/.exec(line);
|
|
38
|
+
return match?.[1] ?? null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The hq-cli version the running daemon was started from. hqd first; then the
|
|
42
|
+
* version a newer daemon puts in the unit's environment; then the version an
|
|
43
|
+
* older daemon passed to the child bootstrap, which covers daemons from before
|
|
44
|
+
* this release on machines with HQ Anywhere off.
|
|
45
|
+
*/
|
|
46
|
+
export async function resolveRunningDaemonVersion(deps) {
|
|
47
|
+
try {
|
|
48
|
+
return await deps.ping();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// fall through to the local sources
|
|
52
|
+
}
|
|
53
|
+
const fromEnv = deps.env.HQ_DAEMON_CLI_VERSION?.trim();
|
|
54
|
+
if (fromEnv)
|
|
55
|
+
return fromEnv;
|
|
56
|
+
try {
|
|
57
|
+
return daemonVersionFromBootstrapCommandLine(deps.parentCommandLine());
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
21
63
|
export async function runDaemonUpdater(deps) {
|
|
22
64
|
let ok = true;
|
|
23
65
|
// The restart stops this process too, so it is requested only once all the
|
|
@@ -42,6 +84,13 @@ export async function runDaemonUpdater(deps) {
|
|
|
42
84
|
deps.log(`hq CLI: ${cli.action === "current" ? "up to date" : cli.action}`);
|
|
43
85
|
}
|
|
44
86
|
}
|
|
87
|
+
if (!restart && deps.installedCliVersion && deps.runningDaemonVersion) {
|
|
88
|
+
const running = await deps.runningDaemonVersion().catch(() => null);
|
|
89
|
+
if (running && daemonIsOlderThanCli(running, deps.installedCliVersion)) {
|
|
90
|
+
deps.log(`hqd still runs hq-cli ${running}, older than the installed ${deps.installedCliVersion}; the daemon restarts onto it once the tools are checked`);
|
|
91
|
+
restart = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
45
94
|
if (deps.updateHqCloud) {
|
|
46
95
|
const cloud = await deps.updateHqCloud().catch((err) => ({
|
|
47
96
|
ok: false,
|
|
@@ -3,6 +3,7 @@ import * as os from "node:os";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { runDoctor as runDoctorCommand, } from "../../../commands/doctor.js";
|
|
5
5
|
import { createAnywhereFamily } from "../checks/anywhere.js";
|
|
6
|
+
import { createJqFamily } from "../checks/jq.js";
|
|
6
7
|
import { createTempHomesFamily } from "../checks/temp-homes.js";
|
|
7
8
|
import { createDefaultRegistry } from "../registry.js";
|
|
8
9
|
/**
|
|
@@ -49,6 +50,9 @@ export async function runDoctorForTest(options = {}) {
|
|
|
49
50
|
// The temp-homes family walks the machine's real temp folders; scan
|
|
50
51
|
// none here. Its behaviour is covered with fake trees in its own tests.
|
|
51
52
|
registry.register(createTempHomesFamily({ roots: [] }));
|
|
53
|
+
// The jq family reads the machine's real PATH; stub a present jq so
|
|
54
|
+
// full-doctor tests do not depend on jq being installed here.
|
|
55
|
+
registry.register(createJqFamily({ platform: process.platform, findJq: () => "/usr/bin/jq", readVersion: () => "jq-1.8.2" }));
|
|
52
56
|
}
|
|
53
57
|
return await runDoctorCommand({ ...options, registry, integrations: false });
|
|
54
58
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
|
|
2
|
+
export declare const JQ_FAMILY_ID = "jq";
|
|
3
|
+
export declare const JQ_CHECK_ID = "jq.on-path";
|
|
4
|
+
/**
|
|
5
|
+
* Windows install hint for a missing jq. hq-core-staging PR 1882 makes
|
|
6
|
+
* master-hook block every tool call without jq. The npm postinstall
|
|
7
|
+
* (scripts/install-hook-engine.mjs) prints the same line; a test keeps them equal.
|
|
8
|
+
*/
|
|
9
|
+
export declare const JQ_WINDOWS_INSTALL_HINT = "Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.";
|
|
10
|
+
/** Per-platform install guidance for a missing jq. */
|
|
11
|
+
export declare function jqInstallHint(platform: NodeJS.Platform): string;
|
|
12
|
+
export interface JqCheckDeps {
|
|
13
|
+
platform: NodeJS.Platform;
|
|
14
|
+
/** Absolute path of the first `jq` on PATH, or undefined when there is none. */
|
|
15
|
+
findJq: () => string | undefined;
|
|
16
|
+
/** `jq --version` output for the binary at `file`; throws when it cannot run. */
|
|
17
|
+
readVersion: (file: string) => string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* HQ's master-hook needs jq to parse every hook payload. Since hq-core-staging
|
|
21
|
+
* PR 1882 it blocks every PreToolUse call when jq is missing, and no installer
|
|
22
|
+
* puts jq on PATH on Windows. This check only reads: it never installs jq.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createJqFamily(deps?: JqCheckDeps): CheckFamily;
|
|
25
|
+
export declare const jqFamily: CheckFamily;
|
|
26
|
+
export declare function checkJq(_context: CheckContext, deps?: JqCheckDeps): CheckResult[];
|
|
27
|
+
//# sourceMappingURL=jq.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { findExecutableOnPath } from "../../../utils/resolve-executable.js";
|
|
3
|
+
export const JQ_FAMILY_ID = "jq";
|
|
4
|
+
export const JQ_CHECK_ID = "jq.on-path";
|
|
5
|
+
/**
|
|
6
|
+
* Windows install hint for a missing jq. hq-core-staging PR 1882 makes
|
|
7
|
+
* master-hook block every tool call without jq. The npm postinstall
|
|
8
|
+
* (scripts/install-hook-engine.mjs) prints the same line; a test keeps them equal.
|
|
9
|
+
*/
|
|
10
|
+
export const JQ_WINDOWS_INSTALL_HINT = "Install jq (Windows: winget install jqlang.jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.";
|
|
11
|
+
/** Per-platform install guidance for a missing jq. */
|
|
12
|
+
export function jqInstallHint(platform) {
|
|
13
|
+
if (platform === "win32")
|
|
14
|
+
return JQ_WINDOWS_INSTALL_HINT;
|
|
15
|
+
if (platform === "darwin") {
|
|
16
|
+
return "Install jq (macOS: brew install jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.";
|
|
17
|
+
}
|
|
18
|
+
return "Install jq (Debian/Ubuntu: sudo apt-get install jq; Fedora: sudo dnf install jq) and open a new terminal; HQ hooks block tool calls until jq is on PATH.";
|
|
19
|
+
}
|
|
20
|
+
const defaultDeps = {
|
|
21
|
+
platform: process.platform,
|
|
22
|
+
// Git Bash runs the hooks: it can run jq.exe but not a jq.cmd or jq.bat.
|
|
23
|
+
findJq: () => findExecutableOnPath("jq", process.env.PATH ?? "", process.platform, ".EXE"),
|
|
24
|
+
readVersion: (file) => execFileSync(file, ["--version"], {
|
|
25
|
+
encoding: "utf8",
|
|
26
|
+
timeout: 5_000,
|
|
27
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
28
|
+
windowsHide: true,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* HQ's master-hook needs jq to parse every hook payload. Since hq-core-staging
|
|
33
|
+
* PR 1882 it blocks every PreToolUse call when jq is missing, and no installer
|
|
34
|
+
* puts jq on PATH on Windows. This check only reads: it never installs jq.
|
|
35
|
+
*/
|
|
36
|
+
export function createJqFamily(deps = defaultDeps) {
|
|
37
|
+
return {
|
|
38
|
+
id: JQ_FAMILY_ID,
|
|
39
|
+
title: "jq for HQ hooks",
|
|
40
|
+
run: (context) => Promise.resolve(checkJq(context, deps)),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export const jqFamily = createJqFamily();
|
|
44
|
+
export function checkJq(_context, deps = defaultDeps) {
|
|
45
|
+
const hint = jqInstallHint(deps.platform);
|
|
46
|
+
const file = deps.findJq();
|
|
47
|
+
if (!file) {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
status: "FAIL",
|
|
51
|
+
checkId: JQ_CHECK_ID,
|
|
52
|
+
message: "jq is not on PATH. HQ hooks block every tool call until it is.",
|
|
53
|
+
remediation: hint,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
let version;
|
|
58
|
+
try {
|
|
59
|
+
version = deps.readVersion(file).trim();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
status: "FAIL",
|
|
65
|
+
checkId: JQ_CHECK_ID,
|
|
66
|
+
target: file,
|
|
67
|
+
message: `jq is on PATH at ${file} but \`jq --version\` failed: ${(error instanceof Error ? error.message : String(error)).split("\n")[0]}`,
|
|
68
|
+
remediation: hint,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
status: "PASS",
|
|
75
|
+
checkId: JQ_CHECK_ID,
|
|
76
|
+
target: file,
|
|
77
|
+
message: `${version || "jq"} is on PATH at ${file}.`,
|
|
78
|
+
details: { version },
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=jq.js.map
|
|
@@ -9,9 +9,24 @@ import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
|
|
|
9
9
|
export declare const RELEASE_LINKS_FAMILY_ID = "release-links";
|
|
10
10
|
export declare const RELEASE_LINKS_FAMILY_TITLE = "Release links";
|
|
11
11
|
export declare const RELEASE_LINKS_CHECK_ID = "release-links.resolve";
|
|
12
|
-
export declare const RELEASE_LINK_REMEDIATION = "Run `hq doctor --fix` (or `hq rescue -y`) to restore the shipped link. A dangling link that points outside the HQ root and the temp folder is treated as your own and left alone. On Windows, a directory link is written as a junction and a file link as a copy when symlinks are not allowed.";
|
|
12
|
+
export declare const RELEASE_LINK_REMEDIATION = "Run `hq doctor --fix` (or `hq rescue -y`) to restore the shipped link. A dangling link that points outside the HQ root and the temp folder is treated as your own and left alone. On Windows, a directory link is written as a junction and a file link as a copy when symlinks are not allowed. A junction Windows will not list through is replaced by a copy of its target.";
|
|
13
13
|
/** Message prefix for a link whose target is missing; `--fix` keys off it. */
|
|
14
14
|
export declare const DANGLING_RELEASE_LINK_PROBLEM = "does not resolve.";
|
|
15
|
+
/**
|
|
16
|
+
* Message prefix for a directory link that resolves to its shipped target but
|
|
17
|
+
* cannot be listed through (a junction a standard Windows user created on
|
|
18
|
+
* some machines); `--fix` keys off it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const UNLISTABLE_RELEASE_LINK_PROBLEM = "is a link Windows will not list through.";
|
|
21
|
+
/**
|
|
22
|
+
* Message prefix for an HQ fallback copy whose target changed since the copy
|
|
23
|
+
* was made and that the user has not edited; `--fix` keys off it.
|
|
24
|
+
*/
|
|
25
|
+
export declare const STALE_RELEASE_LINK_COPY_PROBLEM = "is an out-of-date copy of its target.";
|
|
26
|
+
/** Remediation for a fallback copy that is current or out of date. */
|
|
27
|
+
export declare const RELEASE_LINK_COPY_REMEDIATION = "Copies do not follow updates. `hq doctor --fix` or `hq rescue -y` refreshes the copy from its target when the target changes. Make changes in the target folder, not in the copy: a copy with changes made inside it is not refreshed, and a refresh would replace them.";
|
|
28
|
+
/** Every message prefix the `repair-release-link` fix acts on. */
|
|
29
|
+
export declare const REPAIRABLE_RELEASE_LINK_PROBLEMS: readonly string[];
|
|
15
30
|
interface ReleaseLink {
|
|
16
31
|
rel: string;
|
|
17
32
|
linkText: string;
|
|
@@ -21,6 +36,13 @@ interface ReleaseLink {
|
|
|
21
36
|
export declare const RELEASE_LINKS: readonly ReleaseLink[];
|
|
22
37
|
export declare const releaseLinksFamily: CheckFamily;
|
|
23
38
|
export declare function checkReleaseLinks(context: CheckContext): CheckResult[];
|
|
39
|
+
/**
|
|
40
|
+
* Whether listing a directory through `link` works and shows as many entries
|
|
41
|
+
* as listing `target` directly. False when the link listing throws (EPERM,
|
|
42
|
+
* EACCES, ENOENT, ...) or the counts differ. When `target` itself cannot be
|
|
43
|
+
* listed the link is not blamed, so this returns true.
|
|
44
|
+
*/
|
|
45
|
+
export declare function linkListsLikeTarget(link: string, target: string): boolean;
|
|
24
46
|
/** Where a rescue may stage its extraction folder. */
|
|
25
47
|
export interface RescueStagingDeps {
|
|
26
48
|
/** The system temp folder. Default `os.tmpdir()`. */
|
|
@@ -32,18 +54,25 @@ export interface RescueStagingDeps {
|
|
|
32
54
|
export interface ReleaseLinkRepair {
|
|
33
55
|
rel: string;
|
|
34
56
|
/**
|
|
35
|
-
* `repointed`: the link was rewritten (see `linkText`). `
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* `
|
|
57
|
+
* `repointed`: the link was rewritten (see `linkText`). `copied`: on
|
|
58
|
+
* Windows the junction was written but could not be listed through, so it
|
|
59
|
+
* was removed and the target folder copied in its place (see `target`,
|
|
60
|
+
* `reason`). `refreshed`: an out-of-date HQ copy was replaced with a fresh
|
|
61
|
+
* copy of its target. `kept`: an HQ copy is out of date but files inside it
|
|
62
|
+
* changed, so it was left alone (see `reason`). `removed`: the shipped
|
|
63
|
+
* target is missing too, so the dangling link was deleted. `skipped`: the
|
|
64
|
+
* link points outside the HQ root and the temp folder, so it is treated as
|
|
65
|
+
* the user's own link and left alone (see `reason`). `failed`: the repair
|
|
66
|
+
* threw for this link only (see `reason`).
|
|
40
67
|
*/
|
|
41
|
-
action: "repointed" | "removed" | "skipped" | "failed";
|
|
42
|
-
/** The absolute target the link now resolves to
|
|
68
|
+
action: "repointed" | "copied" | "refreshed" | "kept" | "removed" | "skipped" | "failed";
|
|
69
|
+
/** The absolute target the link now resolves to, or the copy's source. */
|
|
43
70
|
target?: string;
|
|
44
71
|
/** The text written into the link (repointed only). */
|
|
45
72
|
linkText?: string;
|
|
46
73
|
reason?: string;
|
|
74
|
+
/** Links inside the target that resolve outside the HQ root; left out of a copy. */
|
|
75
|
+
skippedOutside?: string[];
|
|
47
76
|
}
|
|
48
77
|
export interface RepairReleaseLinksDeps {
|
|
49
78
|
platform?: NodeJS.Platform;
|
|
@@ -78,6 +107,19 @@ export interface RepairReleaseLinksDeps {
|
|
|
78
107
|
* is created. The old entry is removed with {@link removeLinkOnly}, which never
|
|
79
108
|
* follows it. A failure on one link is reported as `failed` and the remaining
|
|
80
109
|
* links are still repaired.
|
|
110
|
+
*
|
|
111
|
+
* Windows junctions that cannot be listed through: on some Windows machines a
|
|
112
|
+
* junction a standard user creates has the right target but nobody can list
|
|
113
|
+
* through it (hq-core-staging PR 1883, Beaker). After writing a directory
|
|
114
|
+
* junction this lists through it and compares the entry count with the
|
|
115
|
+
* target; on a mismatch the junction is removed and the target copied in its
|
|
116
|
+
* place, marked with `.hq-link-copy` (`copied`). A link that already resolves
|
|
117
|
+
* to the shipped target but cannot be listed through is rewritten the same
|
|
118
|
+
* way. A link that lists correctly is never replaced.
|
|
119
|
+
*
|
|
120
|
+
* HQ copies: an unedited copy whose target changed is refreshed (`refreshed`).
|
|
121
|
+
* A copy whose files changed after HQ made it is left alone (`kept`), because
|
|
122
|
+
* a refresh would replace those changes. A current copy is not touched.
|
|
81
123
|
*/
|
|
82
124
|
export declare function repairDanglingReleaseLinks(hqRoot: string, deps?: RepairReleaseLinksDeps): ReleaseLinkRepair[];
|
|
83
125
|
export {};
|