@indigoai-us/hq-cli 5.345.218 → 5.345.219
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 +78 -0
- package/dist/command-catalog.generated.d.ts +69 -0
- package/dist/command-catalog.generated.js +83 -0
- package/dist/commands/agents.d.ts +22 -0
- package/dist/commands/agents.js +92 -1
- package/dist/commands/core-hook-registration-plan.d.ts +8 -0
- package/dist/commands/core-hook-registration-plan.js +21 -0
- package/dist/commands/core.js +9 -0
- package/dist/commands/doctor.js +4 -0
- package/dist/commands/lanes-shared.d.ts +2 -0
- package/dist/commands/lanes-watch.js +28 -1
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +99 -9
- package/dist/commands/reindex.js +6 -0
- package/dist/index.js +8 -0
- package/dist/lib/anywhere-person-setting.d.ts +2 -2
- package/dist/lib/anywhere-person-setting.js +2 -2
- package/dist/lib/daemon/anywhere-listener.d.ts +33 -1
- package/dist/lib/daemon/anywhere-listener.js +86 -4
- package/dist/lib/daemon/machine-check-owner.d.ts +21 -0
- package/dist/lib/daemon/machine-check-owner.js +95 -0
- package/dist/lib/daemon/machine-check-registration.d.ts +4 -0
- package/dist/lib/daemon/machine-check-registration.js +64 -0
- package/dist/lib/daemon/machine-checks.d.ts +144 -0
- package/dist/lib/daemon/machine-checks.js +412 -0
- package/dist/lib/daemon/run.js +30 -4
- package/dist/lib/daemon/server.d.ts +2 -0
- package/dist/lib/daemon/server.js +6 -0
- package/dist/lib/daemon/state-file.d.ts +12 -1
- package/dist/lib/daemon/state-file.js +23 -1
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +4 -0
- package/dist/lib/doctor/checks/fleet-hook-core.js +103 -0
- package/dist/lib/doctor/checks/host-core.js +3 -1
- package/dist/lib/doctor/checks/machine-checks.d.ts +16 -0
- package/dist/lib/doctor/checks/machine-checks.js +103 -0
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/doctor/types.d.ts +4 -0
- package/dist/lib/hook-engine/canary-gate.d.ts +64 -0
- package/dist/lib/hook-engine/canary-gate.js +147 -0
- package/dist/lib/hook-engine/coverage.d.ts +3 -1
- package/dist/lib/hook-engine/coverage.js +8 -2
- package/dist/lib/hook-engine/fleet-registration.d.ts +30 -0
- package/dist/lib/hook-engine/fleet-registration.js +132 -0
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hook-engine/registration-identity.d.ts +33 -0
- package/dist/lib/hook-engine/registration-identity.js +97 -0
- package/dist/lib/hook-engine/registration.d.ts +1 -30
- package/dist/lib/hook-engine/registration.js +1 -88
- package/dist/lib/hook-engine/resolve.d.ts +2 -0
- package/dist/lib/hook-engine/resolve.js +7 -3
- package/dist/lib/lanes/canonical-host.d.ts +8 -1
- package/dist/lib/lanes/canonical-host.js +9 -3
- package/dist/lib/lanes/machine-identity.d.ts +15 -0
- package/dist/lib/lanes/machine-identity.js +26 -0
- package/dist/lib/lanes/spawn.js +17 -3
- package/dist/utils/core-next-flag.d.ts +4 -0
- package/dist/utils/core-next-flag.js +22 -0
- package/dist/utils/core-next-kill.d.ts +16 -0
- package/dist/utils/core-next-kill.js +35 -0
- package/dist/utils/host-registration.d.ts +33 -23
- package/dist/utils/host-registration.js +86 -66
- package/package.json +8 -8
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Engine-side kill switch: environment variable and file under the home folder. */
|
|
2
|
+
export declare const CORE_NEXT_KILL_ENV = "HQ_CORE_NEXT";
|
|
3
|
+
export declare const CORE_NEXT_KILL_FILE: string;
|
|
4
|
+
/** The engine-wide kill switch the bridge already honors; the engine checks it too. */
|
|
5
|
+
export declare const ENGINE_KILL_ENV = "HQ_HOOK_ENGINE";
|
|
6
|
+
export declare const ENGINE_KILL_FILE: string;
|
|
7
|
+
/**
|
|
8
|
+
* Why the new core is switched off on this machine, or null. The same four
|
|
9
|
+
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
10
|
+
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
11
|
+
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
12
|
+
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
13
|
+
* entries it added, so the registrations are what they were before the switch.
|
|
14
|
+
*/
|
|
15
|
+
export declare function coreNextKillReason(home: string, env?: NodeJS.ProcessEnv): string | null;
|
|
16
|
+
//# sourceMappingURL=core-next-kill.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Shared offline kill switches without installer imports. */
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
/** Engine-side kill switch: environment variable and file under the home folder. */
|
|
5
|
+
export const CORE_NEXT_KILL_ENV = 'HQ_CORE_NEXT';
|
|
6
|
+
export const CORE_NEXT_KILL_FILE = path.join('.hq', 'state', 'core-next.off');
|
|
7
|
+
/** The engine-wide kill switch the bridge already honors; the engine checks it too. */
|
|
8
|
+
export const ENGINE_KILL_ENV = 'HQ_HOOK_ENGINE';
|
|
9
|
+
export const ENGINE_KILL_FILE = path.join('.hq', 'hook-engine.off');
|
|
10
|
+
/**
|
|
11
|
+
* Why the new core is switched off on this machine, or null. The same four
|
|
12
|
+
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
13
|
+
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
14
|
+
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
15
|
+
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
16
|
+
* entries it added, so the registrations are what they were before the switch.
|
|
17
|
+
*/
|
|
18
|
+
export function coreNextKillReason(home, env = process.env) {
|
|
19
|
+
const coreNextEnv = (env[CORE_NEXT_KILL_ENV] ?? '').trim();
|
|
20
|
+
if (/^(off|0|false|no)$/i.test(coreNextEnv))
|
|
21
|
+
return `${CORE_NEXT_KILL_ENV}=${env[CORE_NEXT_KILL_ENV]}`;
|
|
22
|
+
if (/^off$/i.test((env[ENGINE_KILL_ENV] ?? '').trim()))
|
|
23
|
+
return `${ENGINE_KILL_ENV}=${env[ENGINE_KILL_ENV]}`;
|
|
24
|
+
for (const file of [path.join(home, CORE_NEXT_KILL_FILE), path.join(home, ENGINE_KILL_FILE)]) {
|
|
25
|
+
try {
|
|
26
|
+
fs.lstatSync(file);
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Absent: this switch is off.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=core-next-kill.js.map
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import { type EngineOptions } from '../lib/hook-engine/resolve.js';
|
|
1
2
|
import { type NativeTarget } from '../lib/hook-engine/registration.js';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export declare const CORE_NEXT_KILL_ENV = "HQ_CORE_NEXT";
|
|
5
|
-
export declare const CORE_NEXT_KILL_FILE: string;
|
|
6
|
-
/** The engine-wide kill switch the bridge already honors; the engine checks it too. */
|
|
7
|
-
export declare const ENGINE_KILL_ENV = "HQ_HOOK_ENGINE";
|
|
8
|
-
export declare const ENGINE_KILL_FILE: string;
|
|
3
|
+
export { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
4
|
+
export { coreNextKillReason, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE } from './core-next-kill.js';
|
|
9
5
|
/** Name of the release-stable link next to the pinned engine versions. */
|
|
10
6
|
export declare const STABLE_LINK_NAME = "stable";
|
|
11
|
-
export type CoreNextHost = 'claude' | 'codex' | 'grok';
|
|
7
|
+
export type CoreNextHost = 'claude' | 'codex' | 'grok' | 'fleet-local';
|
|
12
8
|
/**
|
|
13
9
|
* `project`: the HQ root's own registration, always answers.
|
|
14
10
|
* `global`: the user-scope Claude Code entry; answers nothing inside an HQ
|
|
@@ -30,6 +26,12 @@ export interface CoreNextTarget {
|
|
|
30
26
|
fallback?: FallbackTarget;
|
|
31
27
|
/** The old dispatcher's hooks the engine does in full, per event (`capabilities --json` `covers`). */
|
|
32
28
|
covers?: Readonly<Record<string, readonly string[]>>;
|
|
29
|
+
/**
|
|
30
|
+
* The host canary gate (US-019 criterion 4): true when `host` may switch
|
|
31
|
+
* events in `root` to this engine. Set by [`coreNextTarget`]; checked by
|
|
32
|
+
* `forHost` (`hook-engine/coverage.ts`) before any event switches.
|
|
33
|
+
*/
|
|
34
|
+
canary?: (root: string, host: CoreNextHost) => boolean;
|
|
33
35
|
}
|
|
34
36
|
/** The target one event is registered to: the new core only for an event it can take. */
|
|
35
37
|
export declare function targetForEvent(target: FallbackTarget | CoreNextTarget, event: string): FallbackTarget | CoreNextTarget;
|
|
@@ -45,6 +47,7 @@ export declare const CAPABILITIES_SCHEMA = "hq-hook.capabilities.v1";
|
|
|
45
47
|
/** What an engine reported: its version and the evaluators it runs per event. */
|
|
46
48
|
export interface EngineCapabilities {
|
|
47
49
|
version: string;
|
|
50
|
+
registrationHosts?: string[];
|
|
48
51
|
events: Record<string, string[]>;
|
|
49
52
|
/** The old dispatcher's hooks the engine does in full, per event; empty for an engine that does not say. */
|
|
50
53
|
covers?: Record<string, string[]>;
|
|
@@ -66,17 +69,6 @@ export declare function probeEngine(engine: string): EngineCapabilities;
|
|
|
66
69
|
* new-core registration with nothing to run.
|
|
67
70
|
*/
|
|
68
71
|
export declare function checkStableEngine(stable: string, pinned: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* Why the new core is switched off on this machine, or null. The same four
|
|
71
|
-
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
72
|
-
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
73
|
-
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
74
|
-
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
75
|
-
* entries it added, so the registrations are what they were before the switch.
|
|
76
|
-
*/
|
|
77
|
-
export declare function coreNextKillReason(home: string, env?: NodeJS.ProcessEnv): string | null;
|
|
78
|
-
/** `core.next` for this machine, person or company, offline. */
|
|
79
|
-
export declare function coreNextEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
80
72
|
/** The stable path that stands for a pinned engine path. */
|
|
81
73
|
export declare function stableEnginePath(pinned: string, home: string): string;
|
|
82
74
|
/**
|
|
@@ -91,7 +83,28 @@ export interface CoreNextOptions {
|
|
|
91
83
|
platform?: NodeJS.Platform;
|
|
92
84
|
/** Reads the engine's capabilities; `probeEngine` by default. */
|
|
93
85
|
probe?: (engine: string) => EngineCapabilities;
|
|
86
|
+
/** Where gate warnings go (once each); standard error by default. */
|
|
87
|
+
warn?: (message: string) => void;
|
|
88
|
+
}
|
|
89
|
+
/** Why this home stays on shell registrations, or null when engine selection may run. */
|
|
90
|
+
export declare function coreNextOffReason(home: string, env: NodeJS.ProcessEnv, platform: NodeJS.Platform): string | null;
|
|
91
|
+
export type CoreNextEngineLookup = Pick<EngineOptions, 'platform' | 'arch' | 'version' | 'resolvePackage'>;
|
|
92
|
+
export interface CoreNextEngineOptions {
|
|
93
|
+
mode: 'install' | 'read-only';
|
|
94
|
+
platform?: NodeJS.Platform;
|
|
95
|
+
probe?: (engine: string) => EngineCapabilities;
|
|
96
|
+
lookup?: CoreNextEngineLookup;
|
|
97
|
+
}
|
|
98
|
+
export interface CoreNextEngine {
|
|
99
|
+
stable: string;
|
|
100
|
+
pinned: string;
|
|
101
|
+
caps: EngineCapabilities;
|
|
94
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The one engine selection. Install links the stable path. Read-only never
|
|
105
|
+
* writes. Both fail when the pinned bundle or the stable link is wrong.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveCoreNextEngine(home: string, options: CoreNextEngineOptions): CoreNextEngine;
|
|
95
108
|
/**
|
|
96
109
|
* The new-core target when `core.next` is on, the engine for this CLI is
|
|
97
110
|
* installed, the stable link resolves to it, it runs, and it has every
|
|
@@ -108,9 +121,7 @@ export declare function coreNextTarget(home: string, env?: NodeJS.ProcessEnv, op
|
|
|
108
121
|
* [`coreNextTarget`], with any failure turned into one warning and null, so
|
|
109
122
|
* `hq install` and `hq reindex` go on with the old registrations.
|
|
110
123
|
*/
|
|
111
|
-
export declare function coreNextTargetOrWarn(home: string, env?: NodeJS.ProcessEnv, options?: CoreNextOptions
|
|
112
|
-
warn?: (message: string) => void;
|
|
113
|
-
}): CoreNextTarget | null;
|
|
124
|
+
export declare function coreNextTargetOrWarn(home: string, env?: NodeJS.ProcessEnv, options?: CoreNextOptions): CoreNextTarget | null;
|
|
114
125
|
/** Test hook: forget which warnings were printed. */
|
|
115
126
|
export declare function _resetCoreNextWarningsForTests(): void;
|
|
116
127
|
/** Arguments after the engine path for one host, event and scope. */
|
|
@@ -175,5 +186,4 @@ export declare function grokBridgeJson(source: string, root: string, target: Cor
|
|
|
175
186
|
* Throws on any refusal; the caller keeps the current file.
|
|
176
187
|
*/
|
|
177
188
|
export declare function replaceFileNoFollow(file: string, content: string, home?: string): void;
|
|
178
|
-
export {};
|
|
179
189
|
//# sourceMappingURL=host-registration.d.ts.map
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* which carries the server's person, company and machine targeting. No network
|
|
22
22
|
* call: reindex runs from lifecycle hooks.
|
|
23
23
|
*
|
|
24
|
+
* The switch is gated by the host canary (US-019 criterion 4,
|
|
25
|
+
* `hook-engine/canary-gate.ts`): Claude Code, Codex and Grok Build move an
|
|
26
|
+
* event to the new core only with a current passing canary for the engine's
|
|
27
|
+
* version and the root's hq-core gate, unless `HQ_SKIP_HOST_CANARY_GATE=1`.
|
|
28
|
+
*
|
|
24
29
|
* The switch is per event. Before an event is pointed at the new core, the
|
|
25
30
|
* engine behind the stable path is started (`--version`, then `capabilities
|
|
26
31
|
* --json`), and the event switches only when every evaluator it needs
|
|
@@ -37,19 +42,16 @@
|
|
|
37
42
|
import { execFileSync } from 'node:child_process';
|
|
38
43
|
import * as fs from 'node:fs';
|
|
39
44
|
import * as path from 'node:path';
|
|
40
|
-
import { readLocalOverride } from '@indigoai-us/hq-flags-client';
|
|
41
|
-
import { readFlagSnapshotFile, readPersonFlagSnapshotFile } from '../lib/flag-snapshot-file.js';
|
|
42
|
-
import { resolveProcessFlagCompanyContext } from '../lib/process-flag-company-context.js';
|
|
43
45
|
import { installHookEngine } from '../lib/hook-engine/resolve.js';
|
|
46
|
+
// Read-only names stay on this namespace. host-registration.test.ts mocks a module that exports only installHookEngine.
|
|
47
|
+
import * as hookEngineResolve from '../lib/hook-engine/resolve.js';
|
|
44
48
|
import { launcherRoot, quotePosix, quoteWindows } from '../lib/hook-engine/registration.js';
|
|
45
49
|
import { openStoreDir } from '../lib/safe-store.js';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
export const ENGINE_KILL_ENV = 'HQ_HOOK_ENGINE';
|
|
52
|
-
export const ENGINE_KILL_FILE = path.join('.hq', 'hook-engine.off');
|
|
50
|
+
import { SKIP_CANARY_GATE_ENV, checkHostCanary } from '../lib/hook-engine/canary-gate.js';
|
|
51
|
+
export { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
52
|
+
import { CORE_NEXT_FLAG, coreNextEnabled } from './core-next-flag.js';
|
|
53
|
+
export { coreNextKillReason, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE } from './core-next-kill.js';
|
|
54
|
+
import { coreNextKillReason } from './core-next-kill.js';
|
|
53
55
|
/** Name of the release-stable link next to the pinned engine versions. */
|
|
54
56
|
export const STABLE_LINK_NAME = 'stable';
|
|
55
57
|
/** The target one event is registered to: the new core only for an event it can take. */
|
|
@@ -130,7 +132,7 @@ export function probeEngine(engine) {
|
|
|
130
132
|
covers[event] = Array.isArray(ids) ? ids.filter((id) => typeof id === 'string') : [];
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
return { version: version.slice('hq-hook '.length), events, covers };
|
|
135
|
+
return { version: version.slice('hq-hook '.length), events, covers, registrationHosts: doc.registration_hosts };
|
|
134
136
|
}
|
|
135
137
|
/**
|
|
136
138
|
* Check that the stable path resolves to the pinned engine before a
|
|
@@ -150,43 +152,6 @@ export function checkStableEngine(stable, pinned) {
|
|
|
150
152
|
if (!fs.statSync(resolved).isFile())
|
|
151
153
|
throw new Error(`${resolved} is not a file`);
|
|
152
154
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Why the new core is switched off on this machine, or null. The same four
|
|
155
|
-
* switches the engine reads (`crates/hq-hook/src/core_next.rs` `kill_reason`):
|
|
156
|
-
* `HQ_CORE_NEXT=off|0|false|no`, `HQ_HOOK_ENGINE=off`, and the files
|
|
157
|
-
* `~/.hq/state/core-next.off` and `~/.hq/hook-engine.off` (a link counts, as
|
|
158
|
-
* for the engine). With any of them on, `hq reindex` removes the new-core
|
|
159
|
-
* entries it added, so the registrations are what they were before the switch.
|
|
160
|
-
*/
|
|
161
|
-
export function coreNextKillReason(home, env = process.env) {
|
|
162
|
-
const coreNextEnv = (env[CORE_NEXT_KILL_ENV] ?? '').trim();
|
|
163
|
-
if (/^(off|0|false|no)$/i.test(coreNextEnv))
|
|
164
|
-
return `${CORE_NEXT_KILL_ENV}=${env[CORE_NEXT_KILL_ENV]}`;
|
|
165
|
-
if (/^off$/i.test((env[ENGINE_KILL_ENV] ?? '').trim()))
|
|
166
|
-
return `${ENGINE_KILL_ENV}=${env[ENGINE_KILL_ENV]}`;
|
|
167
|
-
for (const file of [path.join(home, CORE_NEXT_KILL_FILE), path.join(home, ENGINE_KILL_FILE)]) {
|
|
168
|
-
try {
|
|
169
|
-
fs.lstatSync(file);
|
|
170
|
-
return file;
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
// Absent: this switch is off.
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
/** `core.next` for this machine, person or company, offline. */
|
|
179
|
-
export function coreNextEnabled(env = process.env) {
|
|
180
|
-
const override = readLocalOverride(CORE_NEXT_FLAG, env);
|
|
181
|
-
if (override !== null)
|
|
182
|
-
return override;
|
|
183
|
-
const { companyUid: uid, companySlug } = resolveProcessFlagCompanyContext(env);
|
|
184
|
-
// An explicit company slug that does not resolve stays off, as for the launcher flag.
|
|
185
|
-
if (!uid && companySlug)
|
|
186
|
-
return false;
|
|
187
|
-
const snapshot = uid ? readFlagSnapshotFile(uid, { env }) : readPersonFlagSnapshotFile({ env });
|
|
188
|
-
return snapshot?.flags[CORE_NEXT_FLAG] === true;
|
|
189
|
-
}
|
|
190
155
|
function hookEngineDir(home) {
|
|
191
156
|
return path.join(home, '.hq', 'bin', 'hq-hook');
|
|
192
157
|
}
|
|
@@ -294,6 +259,44 @@ function pointsAt(link, folder) {
|
|
|
294
259
|
return false;
|
|
295
260
|
}
|
|
296
261
|
}
|
|
262
|
+
/** Why this home stays on shell registrations, or null when engine selection may run. */
|
|
263
|
+
export function coreNextOffReason(home, env, platform) {
|
|
264
|
+
const killed = coreNextKillReason(home, env);
|
|
265
|
+
if (killed)
|
|
266
|
+
return killed;
|
|
267
|
+
if (platform === 'win32')
|
|
268
|
+
return 'Windows keeps shell registration';
|
|
269
|
+
if (!coreNextEnabled({ ...env, HOME: home, USERPROFILE: home }))
|
|
270
|
+
return 'core.next is off';
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The one engine selection. Install links the stable path. Read-only never
|
|
275
|
+
* writes. Both fail when the pinned bundle or the stable link is wrong.
|
|
276
|
+
*/
|
|
277
|
+
export function resolveCoreNextEngine(home, options) {
|
|
278
|
+
const platform = options.platform ?? process.platform;
|
|
279
|
+
let pinned;
|
|
280
|
+
let stable;
|
|
281
|
+
if (options.mode === 'install') {
|
|
282
|
+
const installed = installHookEngine(options.lookup ? { ...options.lookup, home } : { home });
|
|
283
|
+
if (!installed)
|
|
284
|
+
throw new Error('the hook engine for this CLI is not installed');
|
|
285
|
+
pinned = installed;
|
|
286
|
+
stable = linkStableEngine(pinned, home, platform);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
const found = hookEngineResolve.findHookEngine({ ...options.lookup, home });
|
|
290
|
+
if (!found)
|
|
291
|
+
throw new Error('the pinned hook engine is unavailable');
|
|
292
|
+
hookEngineResolve.assertPinnedHookEngineMatches(found);
|
|
293
|
+
pinned = found.pinned;
|
|
294
|
+
stable = stableEnginePath(found.pinned, home);
|
|
295
|
+
}
|
|
296
|
+
checkStableEngine(stable, pinned);
|
|
297
|
+
const caps = (options.probe ?? probeEngine)(stable);
|
|
298
|
+
return { stable, pinned, caps };
|
|
299
|
+
}
|
|
297
300
|
/**
|
|
298
301
|
* The new-core target when `core.next` is on, the engine for this CLI is
|
|
299
302
|
* installed, the stable link resolves to it, it runs, and it has every
|
|
@@ -307,23 +310,44 @@ function pointsAt(link, folder) {
|
|
|
307
310
|
*/
|
|
308
311
|
export function coreNextTarget(home, env = process.env, options = {}) {
|
|
309
312
|
const platform = options.platform ?? process.platform;
|
|
310
|
-
if (
|
|
311
|
-
return null;
|
|
312
|
-
// The kill switch rolls the registrations back as well as the next event.
|
|
313
|
-
if (coreNextKillReason(home, env))
|
|
313
|
+
if (coreNextOffReason(home, env, platform))
|
|
314
314
|
return null;
|
|
315
|
-
|
|
316
|
-
return null;
|
|
317
|
-
const pinned = installHookEngine({ home });
|
|
318
|
-
if (!pinned)
|
|
319
|
-
throw new Error('the hook engine for this CLI is not installed');
|
|
320
|
-
const stable = linkStableEngine(pinned, home, platform);
|
|
321
|
-
checkStableEngine(stable, pinned);
|
|
322
|
-
const caps = (options.probe ?? probeEngine)(stable);
|
|
315
|
+
const { stable, caps } = resolveCoreNextEngine(home, { mode: 'install', platform, probe: options.probe });
|
|
323
316
|
const events = capableEvents(caps);
|
|
324
|
-
|
|
317
|
+
if (!events.length)
|
|
318
|
+
return null;
|
|
319
|
+
return { coreNext: stable, events, covers: caps.covers ?? {}, canary: hostCanaryGate(home, env, caps.version, platform, options.warn) };
|
|
325
320
|
}
|
|
326
321
|
const warned = new Set();
|
|
322
|
+
function warnOnce(message, warn) {
|
|
323
|
+
if (warned.has(message))
|
|
324
|
+
return;
|
|
325
|
+
warned.add(message);
|
|
326
|
+
(warn ?? ((text) => process.stderr.write(`${text}\n`)))(message);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The host canary gate for an engine at `version` (hq-core-rust US-019
|
|
330
|
+
* criterion 4, `hook-engine/canary-gate.ts`): Claude Code, Codex and Grok
|
|
331
|
+
* Build switch an event only with a current passing canary for this engine
|
|
332
|
+
* version and the root's hq-core gate. A refusal is one warning and the old
|
|
333
|
+
* registrations on that host. `HQ_SKIP_HOST_CANARY_GATE=1` lets the switch go
|
|
334
|
+
* on, with a warning that names what it bypassed. `fleet-local` is not a host
|
|
335
|
+
* the canary runs and is not gated here.
|
|
336
|
+
*/
|
|
337
|
+
function hostCanaryGate(home, env, version, platform, warn) {
|
|
338
|
+
return (root, host) => {
|
|
339
|
+
if (host === 'fleet-local')
|
|
340
|
+
return true;
|
|
341
|
+
const gate = checkHostCanary({ home, root, host, engineVersion: version, env, platform });
|
|
342
|
+
if (gate.skipped) {
|
|
343
|
+
warnOnce(`hq: warning: ${SKIP_CANARY_GATE_ENV} is set: bypassing the host canary gate and switching ${host} hook events to the new core (hq-hook ${version}) without a passing host canary (${gate.reason})`, warn);
|
|
344
|
+
}
|
|
345
|
+
else if (!gate.allowed) {
|
|
346
|
+
warnOnce(`hq: warning: flag ${CORE_NEXT_FLAG} is on, but ${host} has no passing host canary for hq-hook ${version} and this HQ root (${gate.reason}); keeping the old hook registrations on ${host}. Run scripts/host-canary.mjs --host ${host}, or bypass the gate with hq reindex --skip-host-canary-gate`, warn);
|
|
347
|
+
}
|
|
348
|
+
return gate.allowed;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
327
351
|
/**
|
|
328
352
|
* [`coreNextTarget`], with any failure turned into one warning and null, so
|
|
329
353
|
* `hq install` and `hq reindex` go on with the old registrations.
|
|
@@ -333,11 +357,7 @@ export function coreNextTargetOrWarn(home, env = process.env, options = {}) {
|
|
|
333
357
|
return coreNextTarget(home, env, options);
|
|
334
358
|
}
|
|
335
359
|
catch (error) {
|
|
336
|
-
|
|
337
|
-
if (!warned.has(message)) {
|
|
338
|
-
warned.add(message);
|
|
339
|
-
(options.warn ?? ((text) => process.stderr.write(`${text}\n`)))(message);
|
|
340
|
-
}
|
|
360
|
+
warnOnce(`hq: warning: flag ${CORE_NEXT_FLAG} is on, but the new hook core cannot be used (${error.message}); keeping the old hook registrations`, options.warn);
|
|
341
361
|
return null;
|
|
342
362
|
}
|
|
343
363
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.219",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"gen:hq-mcp-tools": "node scripts/generate-hq-mcp-tools.mjs",
|
|
43
43
|
"test:db": "vitest run src/lib/db test/commands/db.test.ts test/commands/db-tenant-isolation.test.ts",
|
|
44
44
|
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
45
|
-
"coverage": "vitest run --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary",
|
|
45
|
+
"coverage": "vitest run --coverage --coverage.reporter=text-summary --coverage.reporter=json-summary --reporter=default --reporter=./scripts/ci/coverage-timing-reporter.mjs",
|
|
46
46
|
"check:lanes-module-cycles": "node scripts/check-lanes-module-cycles.mjs",
|
|
47
47
|
"vitest": "vitest",
|
|
48
48
|
"clean": "rm -rf dist",
|
|
@@ -119,11 +119,11 @@
|
|
|
119
119
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
120
120
|
},
|
|
121
121
|
"optionalDependencies": {
|
|
122
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
123
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
124
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
125
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
126
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
127
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
122
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.219",
|
|
123
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.219",
|
|
124
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.219",
|
|
125
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.219",
|
|
126
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.219",
|
|
127
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.219"
|
|
128
128
|
}
|
|
129
129
|
}
|