@indigoai-us/hq-cli 5.345.267 → 5.345.269
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 +29 -0
- package/README.md +12 -0
- package/contracts/host-canary-release.json +7 -7
- package/dist/commands/core-job-notify-native.d.ts +6 -0
- package/dist/commands/core-job-notify-native.js +64 -4
- package/dist/commands/core-jobs-native.js +3 -16
- package/dist/commands/install-global.js +54 -17
- package/dist/lib/daemon/machine-check-owner.js +1 -1
- package/dist/lib/daemon/machine-checks.d.ts +3 -11
- package/dist/lib/daemon/machine-checks.js +4 -15
- package/dist/lib/daemon/run.js +12 -0
- package/dist/lib/doctor/checks/codex-wiring.d.ts +4 -2
- package/dist/lib/doctor/checks/codex-wiring.js +70 -13
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +4 -4
- package/dist/lib/doctor/checks/fleet-hook-core.js +5 -10
- package/dist/lib/doctor/checks/grok-wiring.js +38 -0
- package/dist/lib/doctor/checks/hook-engine.js +0 -2
- package/dist/lib/doctor/checks/host-core.d.ts +1 -1
- package/dist/lib/doctor/checks/host-core.js +8 -38
- package/dist/lib/hook-engine/coverage.d.ts +10 -1
- package/dist/lib/hook-engine/coverage.js +63 -8
- package/dist/lib/hook-engine/fleet-registration.js +7 -4
- package/dist/lib/hook-engine/native-precompact-compatibility.json +7 -1
- package/dist/lib/hook-engine/native-stop-compatibility.json +30 -11
- package/dist/lib/hook-engine/reconcile.d.ts +10 -1
- package/dist/lib/hook-engine/reconcile.js +339 -42
- package/dist/lib/hook-engine/stable-gate.d.ts +43 -0
- package/dist/lib/hook-engine/stable-gate.js +276 -0
- package/dist/lib/hot-channels/fleet-complete.js +2 -2
- package/dist/lib/install/antigravity-targets.js +2 -1
- package/dist/lib/install/claude-targets.d.ts +6 -6
- package/dist/lib/install/claude-targets.js +13 -9
- package/dist/lib/install/codex-targets.d.ts +4 -4
- package/dist/lib/install/codex-targets.js +26 -16
- package/dist/lib/install/hook-target.d.ts +23 -2
- package/dist/lib/install/hook-target.js +89 -16
- package/dist/lib/outpost-identity-env.d.ts +18 -0
- package/dist/lib/outpost-identity-env.js +29 -0
- package/dist/lib/signals/steps/extract.js +46 -12
- package/dist/utils/core-next-kill.d.ts +2 -15
- package/dist/utils/core-next-kill.js +5 -36
- package/dist/utils/hook-engine-crash.d.ts +86 -0
- package/dist/utils/hook-engine-crash.js +325 -0
- package/dist/utils/hook-engine-rollup.d.ts +8 -3
- package/dist/utils/hook-engine-rollup.js +0 -1
- package/dist/utils/hook-trust.d.ts +2 -0
- package/dist/utils/hook-trust.js +156 -13
- package/dist/utils/host-registration.d.ts +158 -4
- package/dist/utils/host-registration.js +500 -17
- package/dist/utils/version-gate.d.ts +42 -4
- package/dist/utils/version-gate.js +84 -25
- package/package.json +7 -7
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
"f2d442586a1d09ddd79cb259253a773192fc17763d7cc6c1b586a86d4d7df787"
|
|
64
64
|
],
|
|
65
65
|
".claude/hooks/hq-autocommit-bash-sweep.sh": [
|
|
66
|
-
"01b9669c41dcdb438295aea52545ec9306b8ed8c83c30c7560798bdc06b50aed"
|
|
66
|
+
"01b9669c41dcdb438295aea52545ec9306b8ed8c83c30c7560798bdc06b50aed",
|
|
67
|
+
"4c3c104f2e22680f9cb0be442e44daba06c0c3c0aaf4918e87c73a06ec13a117"
|
|
67
68
|
],
|
|
68
69
|
".claude/hooks/checkpoint-stop-gate.sh": [
|
|
69
70
|
"1fc121ad2d0d3acfd13c8daee9215013d9a01bd1856aa716154739f18506c3ce"
|
|
@@ -100,14 +101,17 @@
|
|
|
100
101
|
"b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70"
|
|
101
102
|
],
|
|
102
103
|
".claude/hooks/hq-autocommit-bash-flag.cjs": [
|
|
103
|
-
"419c65157c0167473ace808bacc7cb5902afa4336f8281f7e7f9c228d74a77a4"
|
|
104
|
+
"419c65157c0167473ace808bacc7cb5902afa4336f8281f7e7f9c228d74a77a4",
|
|
105
|
+
"absent"
|
|
104
106
|
],
|
|
105
107
|
".claude/hooks/hq-autocommit-failure-context-flag.cjs": [
|
|
106
|
-
"9e6fa4930830624fd588241b24315f6e6b5f3ae6778e8f61020bf237490ac30c"
|
|
108
|
+
"9e6fa4930830624fd588241b24315f6e6b5f3ae6778e8f61020bf237490ac30c",
|
|
109
|
+
"absent"
|
|
107
110
|
],
|
|
108
111
|
".claude/hooks/hq-autocommit.sh": [
|
|
109
112
|
"f7c01bc6de7f79e51eedc9806a7c903fdf0947e540ba226d1b37fc3667919304",
|
|
110
|
-
"66f5c09b16364e07c659c22d0b6c5519a05894918ea9d0749340023c00e231c2"
|
|
113
|
+
"66f5c09b16364e07c659c22d0b6c5519a05894918ea9d0749340023c00e231c2",
|
|
114
|
+
"dffe923274db253856fa34045e2aae5f58271f3d11202341ba7c22f2c368e04a"
|
|
111
115
|
],
|
|
112
116
|
".claude/hooks/lib/parse-estimates.pl": [
|
|
113
117
|
"absent"
|
|
@@ -116,7 +120,8 @@
|
|
|
116
120
|
"e7ae5c522075b8535672fc2c8642c220282aa5cd91a19accc1072aff304be63e"
|
|
117
121
|
],
|
|
118
122
|
".codex/hooks/codex-explicit-path-flag.cjs": [
|
|
119
|
-
"85e3c00b1f879bfc695c32714129d00554674bce7a139c4386d07f01a63ef83f"
|
|
123
|
+
"85e3c00b1f879bfc695c32714129d00554674bce7a139c4386d07f01a63ef83f",
|
|
124
|
+
"absent"
|
|
120
125
|
],
|
|
121
126
|
"core/hooks/SessionStart/35-work-mesh-session-start.sh": [
|
|
122
127
|
"865e5855c72c5ac0d503efbbc095a2d2835396418a12b20fa0ce3bd2f66d8d27",
|
|
@@ -124,7 +129,8 @@
|
|
|
124
129
|
"4ab85c27d7b78c7a4ccbf76b4f7e3e3ca6b4fdf14f09a63aac49d0c4dc44c8f1"
|
|
125
130
|
],
|
|
126
131
|
"core/scripts/board-project-id.sh": [
|
|
127
|
-
"b3c80668460c556267b06a0869e41e0088963ba2a709ac459d14bb8bd08252a7"
|
|
132
|
+
"b3c80668460c556267b06a0869e41e0088963ba2a709ac459d14bb8bd08252a7",
|
|
133
|
+
"6f623e9ba4886d35df2c9cd28414bb9fe5ddfa40fdefc456414aa9f68c7f3add"
|
|
128
134
|
],
|
|
129
135
|
"core/scripts/conduct-runner-resolve.sh": [
|
|
130
136
|
"1510f360bb6773206fb2bd2d07091c15c1018ee1910f992e60fa7df6d49c845b",
|
|
@@ -155,7 +161,8 @@
|
|
|
155
161
|
"core/scripts/hq-session.sh": [
|
|
156
162
|
"db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7",
|
|
157
163
|
"a0dd3e603c201150e6f2bf4de9f2d01c822978dcf40b3ed03a547a8f070da2de",
|
|
158
|
-
"e686c5a5a477d2640c4056122223d1cbf85e71c5dce965776c15dfee86232c6b"
|
|
164
|
+
"e686c5a5a477d2640c4056122223d1cbf85e71c5dce965776c15dfee86232c6b",
|
|
165
|
+
"02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded"
|
|
159
166
|
],
|
|
160
167
|
"core/scripts/hqd-hook-flag-cache-lib.sh": [
|
|
161
168
|
"061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a"
|
|
@@ -189,7 +196,8 @@
|
|
|
189
196
|
"d6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71"
|
|
190
197
|
],
|
|
191
198
|
"core/scripts/lib/session-scope-capability.sh": [
|
|
192
|
-
"388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead"
|
|
199
|
+
"388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead",
|
|
200
|
+
"498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38"
|
|
193
201
|
],
|
|
194
202
|
"core/scripts/lib/transcript-tail.sh": [
|
|
195
203
|
"73eadafdd8e7c375bd12383947ac73c43e7dfe79b29e6553da1cb5b2746bb217"
|
|
@@ -209,6 +217,11 @@
|
|
|
209
217
|
"fdce833824a8e387a50f0dd3020f5c5c0535af6372242e391ab99518d2fa5fc4",
|
|
210
218
|
"b65670de9a5aa063f88694fb1cf44239725f0e71bd6245972aa093ef31f09114"
|
|
211
219
|
],
|
|
220
|
+
"core/scripts/setup-path-flag.cjs": [
|
|
221
|
+
"absent",
|
|
222
|
+
"7eb46bbcfeab9cf66a276c2ab2f0e452685e31c98c3d2a9c7f10a165509bee3d",
|
|
223
|
+
"c75e44c353549338dd09d76f5db7b71a3cdf076926b6dd36e55d1a8e59e54c8a"
|
|
224
|
+
],
|
|
212
225
|
"core/scripts/share-suggestion-state.sh": [
|
|
213
226
|
"d2a8ba30f7650b89f0ed221f840ef2c8e731b9df35d57e0f4576feadad6f7597"
|
|
214
227
|
]
|
|
@@ -217,7 +230,8 @@
|
|
|
217
230
|
".claude/hooks/hq-autocommit-bash-sweep.sh": [
|
|
218
231
|
".claude/hooks/hq-autocommit-bash-flag.cjs",
|
|
219
232
|
".claude/hooks/hq-autocommit.sh",
|
|
220
|
-
"core/scripts/lib/hook-stop-async.sh"
|
|
233
|
+
"core/scripts/lib/hook-stop-async.sh",
|
|
234
|
+
"core/scripts/setup-path-flag.cjs"
|
|
221
235
|
],
|
|
222
236
|
".claude/hooks/checkpoint-stop-gate.sh": [
|
|
223
237
|
"core/scripts/hq-hidden-run.sh"
|
|
@@ -260,7 +274,8 @@
|
|
|
260
274
|
"core/scripts/lib/work-mesh-enqueue.sh"
|
|
261
275
|
],
|
|
262
276
|
".claude/hooks/hq-autocommit.sh": [
|
|
263
|
-
".claude/hooks/hq-autocommit-failure-context-flag.cjs"
|
|
277
|
+
".claude/hooks/hq-autocommit-failure-context-flag.cjs",
|
|
278
|
+
"core/scripts/setup-path-flag.cjs"
|
|
264
279
|
],
|
|
265
280
|
".claude/hooks/hq-autocommit-bash-flag.cjs": [
|
|
266
281
|
"core/scripts/hq-session.sh"
|
|
@@ -306,7 +321,11 @@
|
|
|
306
321
|
],
|
|
307
322
|
"core/scripts/lib/session-scope-capability.sh": [
|
|
308
323
|
".codex/hooks/codex-explicit-path-flag.cjs",
|
|
309
|
-
"core/scripts/hqd-hook-flag-cache-lib.sh"
|
|
324
|
+
"core/scripts/hqd-hook-flag-cache-lib.sh",
|
|
325
|
+
"core/scripts/setup-path-flag.cjs"
|
|
326
|
+
],
|
|
327
|
+
"core/scripts/setup-path-flag.cjs": [
|
|
328
|
+
"core/scripts/hq-session.sh"
|
|
310
329
|
],
|
|
311
330
|
"core/scripts/lib/work-mesh-enqueue.sh": [
|
|
312
331
|
"core/scripts/lib/epochrealtime.sh"
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/** Every Claude Code project event that shipped a master-hook.sh entry in `.claude/settings.json`. */
|
|
2
|
+
export declare const PROJECT_CLAUDE_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PreCompact", "Stop", "SessionStart", "UserPromptSubmit", "Notification", "SubagentStart", "SubagentStop", "SessionEnd"];
|
|
3
|
+
/** Every Codex project event that shipped a `[[hooks.<Event>]]` block in `.codex/config.toml`. */
|
|
4
|
+
export declare const PROJECT_CODEX_HOOK_EVENTS: ReadonlyArray<{
|
|
5
|
+
event: string;
|
|
6
|
+
matcher?: string;
|
|
7
|
+
timeout: number;
|
|
8
|
+
statusMessage: string;
|
|
9
|
+
}>;
|
|
1
10
|
export interface ReconcileResult {
|
|
2
11
|
/** Codex user-scope trust keys for the HQ entries in the global hooks.json. */
|
|
3
12
|
codexUserKeys: string[];
|
|
@@ -5,5 +14,5 @@ export interface ReconcileResult {
|
|
|
5
14
|
failures: string[];
|
|
6
15
|
}
|
|
7
16
|
/** Reconcile existing registrations only; reindex must not install a runtime. */
|
|
8
|
-
export declare function reconcileHookRegistrations(root: string, home?: string, env?: NodeJS.ProcessEnv, daemonInstalled?: boolean): ReconcileResult;
|
|
17
|
+
export declare function reconcileHookRegistrations(root: string, home?: string, env?: NodeJS.ProcessEnv, daemonInstalled?: boolean, platform?: NodeJS.Platform): ReconcileResult;
|
|
9
18
|
//# sourceMappingURL=reconcile.d.ts.map
|
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
import { existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { writeConfigAtomic, jsonFormat } from '../../commands/mcp-registration.js';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { addHqHooks, removeHqHooks, shimPath } from '../install/claude-targets.js';
|
|
5
|
+
import { addHqHooks, isHqHookEntry, removeHqHooks, shimPath } from '../install/claude-targets.js';
|
|
6
6
|
import { legacyHookTarget } from '../install/hook-target.js';
|
|
7
|
-
import { addCodexHooks, removeCodexHooks, codexHookEntry, codexHookTrustKeys } from '../install/codex-targets.js';
|
|
7
|
+
import { addCodexHooks, isAdapterEntry, removeCodexHooks, codexHookEntry, codexHookTrustKeys } from '../install/codex-targets.js';
|
|
8
8
|
import { ANTIGRAVITY_HOOK_EVENTS, ANTIGRAVITY_HOOK_NAME, antigravityTargets, buildAntigravityHqHookSpec, detectAntigravity, removeAntigravityHqHooks, } from '../install/antigravity-targets.js';
|
|
9
|
-
import {
|
|
9
|
+
import { isCoreNextEntry, isNativeEntry } from './registration.js';
|
|
10
10
|
import { userHookSettingsFile } from './registration-identity.js';
|
|
11
|
-
import { coreNextArgs, coreNextCommand, coreNextTargetOrWarn, placeEvent } from '../../utils/host-registration.js';
|
|
12
|
-
import { claudeProjectTarget, forHost, stopCompatibilityHold } from './coverage.js';
|
|
13
|
-
|
|
11
|
+
import { coreNextArgs, coreNextCommand, coreNextCommandWindows, coreNextOffReason, coreNextTargetOrWarn, getCoreNextCandidate, isPortableNativeEntry, isShippedPortableClaudeCommand, placeEvent, portableNativeCommandForPlatform, replaceFileNoFollow, resolvePortableEngineForNativeOnly, shippedPortableClaudeCommand, STABLE_LINK_NAME, } from '../../utils/host-registration.js';
|
|
12
|
+
import { claudeProjectTarget, forHost, isNativeOnlyCoreRoot, stopCompatibilityHold } from './coverage.js';
|
|
13
|
+
import { detectMachineHookHosts, evaluateStableCommit } from './stable-gate.js';
|
|
14
|
+
import { HQ_CLI_NPM_REPAIR_COMMAND } from '../../utils/npm-install-flags.js';
|
|
15
|
+
/** Every Claude Code project event that shipped a master-hook.sh entry in `.claude/settings.json`. */
|
|
16
|
+
export const PROJECT_CLAUDE_HOOK_EVENTS = [
|
|
17
|
+
'PreToolUse',
|
|
18
|
+
'PostToolUse',
|
|
19
|
+
'PreCompact',
|
|
20
|
+
'Stop',
|
|
21
|
+
'SessionStart',
|
|
22
|
+
'UserPromptSubmit',
|
|
23
|
+
'Notification',
|
|
24
|
+
'SubagentStart',
|
|
25
|
+
'SubagentStop',
|
|
26
|
+
'SessionEnd',
|
|
27
|
+
];
|
|
28
|
+
/** Every Codex project event that shipped a `[[hooks.<Event>]]` block in `.codex/config.toml`. */
|
|
29
|
+
export const PROJECT_CODEX_HOOK_EVENTS = [
|
|
30
|
+
{ event: 'SessionStart', matcher: 'startup|resume|clear|compact', timeout: 30, statusMessage: 'Loading HQ context' },
|
|
31
|
+
{ event: 'UserPromptSubmit', timeout: 30, statusMessage: 'Routing HQ prompt' },
|
|
32
|
+
{ event: 'PreToolUse', matcher: '.*', timeout: 30, statusMessage: 'Checking HQ safety rails' },
|
|
33
|
+
{ event: 'PostToolUse', matcher: '.*', timeout: 30, statusMessage: 'Running HQ post-tool hooks' },
|
|
34
|
+
{ event: 'Stop', timeout: 30, statusMessage: 'Wrapping HQ session state' },
|
|
35
|
+
{ event: 'PreCompact', timeout: 30, statusMessage: 'Running HQ pre-compact hooks' },
|
|
36
|
+
{ event: 'SessionEnd', timeout: 3, statusMessage: 'Running HQ session-end hooks' },
|
|
37
|
+
{ event: 'SubagentStop', timeout: 30, statusMessage: 'Running HQ subagent-stop hooks' },
|
|
38
|
+
];
|
|
39
|
+
const CODEX_NATIVE_BEGIN = '# BEGIN HQ NATIVE HOOKS (managed by `hq reindex`)';
|
|
40
|
+
const CODEX_NATIVE_END = '# END HQ NATIVE HOOKS';
|
|
41
|
+
/** The project master-hook command shipped in pre-US-027 HQ's .claude/settings.json. */
|
|
14
42
|
function projectClaudeCommand(event) {
|
|
15
43
|
return 'env BASH_ENV=/dev/null bash "$CLAUDE_PROJECT_DIR/.claude/hooks/master-hook.sh" ' + event;
|
|
16
44
|
}
|
|
@@ -122,27 +150,140 @@ function writeMerged(file, home, merge) {
|
|
|
122
150
|
return written;
|
|
123
151
|
}
|
|
124
152
|
/** Reconcile existing registrations only; reindex must not install a runtime. */
|
|
125
|
-
export function reconcileHookRegistrations(root, home = homedir(), env = process.env, daemonInstalled) {
|
|
153
|
+
export function reconcileHookRegistrations(root, home = homedir(), env = process.env, daemonInstalled, platform = process.platform) {
|
|
126
154
|
const result = { codexUserKeys: [], failures: [] };
|
|
127
155
|
// `core.next` (hq-core-rust US-017) wins over the pinned launcher flag.
|
|
128
156
|
// With it on, an event switches on a host only when the engine covers every
|
|
129
157
|
// hook the old dispatcher runs for it there (`coverage.ts`); its new-core
|
|
130
158
|
// entry then replaces the shell entry, so the engine owns the whole event.
|
|
131
159
|
// Every other event stays on the shell with no new-core entry. With the flag
|
|
132
|
-
// off,
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
160
|
+
// off, the new-core entries are removed and the shell registrations are what
|
|
161
|
+
// they were before the switch (on roots that still ship shell scripts). A
|
|
162
|
+
// failure to set up the new core is one warning and the flag-off path.
|
|
163
|
+
const nativeOnly = isNativeOnlyCoreRoot(root);
|
|
164
|
+
let pointedNativeOnly = false;
|
|
165
|
+
if (!nativeOnly) {
|
|
166
|
+
try {
|
|
167
|
+
const pointed = readFileSync(join(home, '.hq', 'root'), 'utf8').trim();
|
|
168
|
+
if (pointed && isNativeOnlyCoreRoot(pointed))
|
|
169
|
+
pointedNativeOnly = true;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// No ~/.hq/root pointer.
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const deferNativeLink = nativeOnly || pointedNativeOnly;
|
|
176
|
+
const rawCoreNext = coreNextTargetOrWarn(home, env, { platform, deferLink: deferNativeLink });
|
|
177
|
+
let claudeNext = null;
|
|
178
|
+
let claudeProjectNext = null;
|
|
179
|
+
let codexNext = null;
|
|
180
|
+
let antigravityNext = null;
|
|
181
|
+
let coreNext = rawCoreNext;
|
|
182
|
+
let stableEngine = !deferNativeLink && rawCoreNext ? rawCoreNext.coreNext : null;
|
|
183
|
+
let stableError = null;
|
|
184
|
+
if (!deferNativeLink) {
|
|
185
|
+
claudeNext = forHost(rawCoreNext, root, 'claude', env);
|
|
186
|
+
claudeProjectNext = claudeProjectTarget(rawCoreNext, claudeNext, root, env);
|
|
187
|
+
codexNext = forHost(rawCoreNext, root, 'codex', env);
|
|
188
|
+
antigravityNext = rawCoreNext;
|
|
189
|
+
}
|
|
190
|
+
else if (rawCoreNext) {
|
|
191
|
+
const candidate = getCoreNextCandidate(rawCoreNext);
|
|
192
|
+
const requiredHosts = [];
|
|
193
|
+
if (existsSync(join(root, '.claude/settings.json')))
|
|
194
|
+
requiredHosts.push('claude');
|
|
195
|
+
const existingHosts = detectMachineHookHosts(root, home, env);
|
|
196
|
+
if (requiredHosts.length === 0 && existingHosts.length === 0)
|
|
197
|
+
requiredHosts.push('claude');
|
|
198
|
+
const optionalHosts = [];
|
|
199
|
+
if (existsSync(join(root, '.codex/config.toml')))
|
|
200
|
+
optionalHosts.push('codex');
|
|
201
|
+
if (detectAntigravity({ home, env, platform }).detected)
|
|
202
|
+
optionalHosts.push('antigravity');
|
|
203
|
+
const decision = evaluateStableCommit({
|
|
204
|
+
rawCoreNext,
|
|
205
|
+
root,
|
|
206
|
+
home,
|
|
207
|
+
env,
|
|
208
|
+
engineVersion: candidate?.engineVersion,
|
|
209
|
+
requiredHosts,
|
|
210
|
+
optionalHosts,
|
|
211
|
+
});
|
|
212
|
+
if (decision.allowed) {
|
|
213
|
+
claudeNext = decision.targets.claude ?? null;
|
|
214
|
+
claudeProjectNext = decision.claudeProject;
|
|
215
|
+
codexNext = decision.targets.codex ?? null;
|
|
216
|
+
antigravityNext = decision.targets.antigravity ?? null;
|
|
217
|
+
try {
|
|
218
|
+
stableEngine = candidate?.commitStable ? candidate.commitStable(decision.acceptedHosts) : rawCoreNext.coreNext;
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
stableError = error.message;
|
|
222
|
+
coreNext = null;
|
|
223
|
+
claudeNext = null;
|
|
224
|
+
claudeProjectNext = null;
|
|
225
|
+
codexNext = null;
|
|
226
|
+
antigravityNext = null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// M-1 / M-2: at least one host with HQ hook entries on this machine
|
|
231
|
+
// refused the new engine. Never move `stable` to that engine: emit a
|
|
232
|
+
// clear warning naming the refusing host(s), and fall back only to a
|
|
233
|
+
// previously canary-accepted engine already linked at `stable`, or refuse.
|
|
234
|
+
if (decision.refusalSummary)
|
|
235
|
+
process.stderr.write(`${decision.refusalSummary}\n`);
|
|
236
|
+
coreNext = null;
|
|
237
|
+
claudeNext = null;
|
|
238
|
+
claudeProjectNext = null;
|
|
239
|
+
codexNext = null;
|
|
240
|
+
antigravityNext = null;
|
|
241
|
+
const refusedHost = decision.refusedHosts[0] ?? 'claude';
|
|
242
|
+
const resolution = resolvePortableEngineForNativeOnly(home, {
|
|
243
|
+
platform,
|
|
244
|
+
env,
|
|
245
|
+
host: refusedHost,
|
|
246
|
+
root,
|
|
247
|
+
candidate: candidate
|
|
248
|
+
? {
|
|
249
|
+
...candidate,
|
|
250
|
+
refusedHosts: decision.refusedHosts,
|
|
251
|
+
checkedHosts: decision.checkedHosts,
|
|
252
|
+
}
|
|
253
|
+
: null,
|
|
254
|
+
});
|
|
255
|
+
stableEngine = resolution.stable;
|
|
256
|
+
if (!stableEngine)
|
|
257
|
+
stableError = resolution.refusalReason ?? 'canary gate refused new engine';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
const existingHosts = detectMachineHookHosts(root, home, env);
|
|
262
|
+
const resolution = resolvePortableEngineForNativeOnly(home, {
|
|
263
|
+
platform,
|
|
264
|
+
env,
|
|
265
|
+
host: existingHosts[0] ?? 'claude',
|
|
266
|
+
root,
|
|
267
|
+
candidate: null,
|
|
268
|
+
requiredHosts: existingHosts,
|
|
269
|
+
});
|
|
270
|
+
stableEngine = resolution.stable;
|
|
271
|
+
if (!stableEngine)
|
|
272
|
+
stableError = resolution.refusalReason ?? 'not installed';
|
|
273
|
+
}
|
|
274
|
+
if (nativeOnly && !stableEngine) {
|
|
275
|
+
result.failures.push(stableError
|
|
276
|
+
? `hook-engine: ${stableError}`
|
|
277
|
+
: `hook-engine: native hook engine unavailable; cannot create ${join(home, '.hq', 'bin', 'hq-hook', STABLE_LINK_NAME)}. Repair: ${HQ_CLI_NPM_REPAIR_COMMAND}`);
|
|
278
|
+
}
|
|
279
|
+
const canWritePortable = Boolean(stableEngine);
|
|
280
|
+
// US-027 M1: legacy shell launcher argv (`hq-hook <Event> --runtime ...`) was
|
|
281
|
+
// removed from `hq-hook` and exits 2 on every event; never write launcher
|
|
282
|
+
// entries from `hq reindex`.
|
|
283
|
+
const native = coreNext;
|
|
143
284
|
const ours = (entry) => isNativeEntry(entry, root) || isCoreNextEntry(entry, root);
|
|
144
285
|
// The shell target install would choose for each host: master-hook for
|
|
145
|
-
// Claude, the adapter for Codex
|
|
286
|
+
// Claude, the adapter for Codex.
|
|
146
287
|
// Resolved only when a registration is rewritten, so the default-off path
|
|
147
288
|
// reads no daemon state.
|
|
148
289
|
const shell = {};
|
|
@@ -151,15 +292,23 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
151
292
|
const next = host === 'codex' ? codexNext : claudeNext;
|
|
152
293
|
return next ? { ...next, fallback: shellTarget(host) } : shellTarget(host);
|
|
153
294
|
};
|
|
154
|
-
const codexBash = (event) => [codexHookEntry(root, event, 'master').command, codexHookEntry(root, event, 'shim').command];
|
|
295
|
+
const codexBash = (event) => [codexHookEntry(root, event, 'master', platform).command, codexHookEntry(root, event, 'shim', platform).command];
|
|
155
296
|
// Claude Code project files: settings.json and the settings.local.json
|
|
156
297
|
// Claude Code merges over it, together.
|
|
157
298
|
try {
|
|
158
|
-
result.failures.push(...reconcileClaudeProject(root, home, claudeProjectNext,
|
|
299
|
+
result.failures.push(...reconcileClaudeProject(root, home, claudeProjectNext, ours, !!native, canWritePortable));
|
|
159
300
|
}
|
|
160
301
|
catch (error) {
|
|
161
302
|
result.failures.push(`${join(root, '.claude/settings.json')}: ${error.message}`);
|
|
162
303
|
}
|
|
304
|
+
// Codex project config: `.codex/config.toml` (native-only roots whose bash
|
|
305
|
+
// adapter was deleted in US-027, or roots that already carry our managed block).
|
|
306
|
+
try {
|
|
307
|
+
reconcileCodexProject(root, home, codexNext);
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
result.failures.push(`${join(root, '.codex/config.toml')}: ${error.message}`);
|
|
311
|
+
}
|
|
163
312
|
for (const [file, runtime, global] of [
|
|
164
313
|
[userHookSettingsFile('claude', home, env), 'claude', true],
|
|
165
314
|
[userHookSettingsFile('codex', home, env), 'codex', true],
|
|
@@ -170,6 +319,8 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
170
319
|
try {
|
|
171
320
|
if (!existsSync(file))
|
|
172
321
|
continue;
|
|
322
|
+
if (nativeOnly && !canWritePortable)
|
|
323
|
+
continue;
|
|
173
324
|
const merge = (doc) => {
|
|
174
325
|
if (!hooksOf(doc))
|
|
175
326
|
return doc;
|
|
@@ -178,12 +329,20 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
178
329
|
// path with JSON.stringify, Claude with single quotes.
|
|
179
330
|
const onShim = (entry) => typeof entry.command === 'string'
|
|
180
331
|
&& (entry.command.includes(JSON.stringify(shimPath(root))) || entry.command.includes(`'${shimPath(root)}'`));
|
|
181
|
-
|
|
332
|
+
const scope = global && runtime === 'claude' ? 'global' : 'project';
|
|
333
|
+
const legacyOnNativeOnly = (entry) => {
|
|
334
|
+
if (!nativeOnly)
|
|
335
|
+
return false;
|
|
336
|
+
if (isCoreNextEntry(entry, root) || isPortableNativeEntry(entry, runtime, root, scope))
|
|
337
|
+
return false;
|
|
338
|
+
return runtime === 'codex' ? isAdapterEntry(entry, root) : isHqHookEntry(entry, root);
|
|
339
|
+
};
|
|
340
|
+
if (!native && !allEntries(doc).some((entry) => ours(entry) || onShim(entry) || legacyOnNativeOnly(entry)))
|
|
182
341
|
return doc;
|
|
183
342
|
if (global) {
|
|
184
343
|
if ((runtime === 'codex' ? removeCodexHooks(doc, root) : removeHqHooks(doc, root)) === doc)
|
|
185
344
|
return doc;
|
|
186
|
-
return runtime === 'codex' ? addCodexHooks(doc, root, globalTarget('codex')) : addHqHooks(doc, root, globalTarget('claude'));
|
|
345
|
+
return runtime === 'codex' ? addCodexHooks(doc, root, globalTarget('codex'), platform) : addHqHooks(doc, root, globalTarget('claude'), platform);
|
|
187
346
|
}
|
|
188
347
|
// Project hooks.json: only an entry install itself writes is
|
|
189
348
|
// converted. HQ's own project file routes through hook-gate.sh and
|
|
@@ -196,18 +355,23 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
196
355
|
return { ...kept, command: want.command, ...(want.commandWindows ? { commandWindows: want.commandWindows } : {}) };
|
|
197
356
|
};
|
|
198
357
|
return mapEvents(doc, [], (event, groups) => groups && placeEvent(groups, {
|
|
199
|
-
isShell: (entry) => isNativeEntry(entry, root)
|
|
358
|
+
isShell: (entry) => isNativeEntry(entry, root)
|
|
359
|
+
|| codexBash(event).includes(entry.command)
|
|
360
|
+
|| isPortableNativeEntry(entry, 'codex', root, 'project'),
|
|
200
361
|
isNative: (entry) => isCoreNextEntry(entry, root),
|
|
201
362
|
toShell: (entry) => {
|
|
363
|
+
const target = shellTarget('codex');
|
|
364
|
+
if (target === 'portable' && isCoreNextEntry(entry, root))
|
|
365
|
+
return entry;
|
|
202
366
|
const { command: _command, commandWindows: _windows, ...rest } = entry;
|
|
203
|
-
const want = codexHookEntry(root, event,
|
|
367
|
+
const want = codexHookEntry(root, event, target, platform);
|
|
204
368
|
if (entry.command === want.command && entry.commandWindows === want.commandWindows)
|
|
205
369
|
return entry;
|
|
206
370
|
if (isCoreNextEntry(entry, root) || coreNext)
|
|
207
371
|
return inPlace(entry, want);
|
|
208
372
|
return { ...rest, command: want.command, ...(want.commandWindows ? { commandWindows: want.commandWindows } : {}) };
|
|
209
373
|
},
|
|
210
|
-
toNative: codexNext?.events.includes(event) ? (entry) => inPlace(entry, codexHookEntry(root, event, codexNext)) : null,
|
|
374
|
+
toNative: codexNext?.events.includes(event) ? (entry) => inPlace(entry, codexHookEntry(root, event, codexNext, platform)) : null,
|
|
211
375
|
}));
|
|
212
376
|
};
|
|
213
377
|
// Nothing to change: no write lock, no backup. A file we cannot parse
|
|
@@ -233,7 +397,7 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
233
397
|
}
|
|
234
398
|
}
|
|
235
399
|
try {
|
|
236
|
-
reconcileAntigravity(root, home, env,
|
|
400
|
+
reconcileAntigravity(root, home, env, antigravityNext, canWritePortable, platform);
|
|
237
401
|
}
|
|
238
402
|
catch (error) {
|
|
239
403
|
result.failures.push(`${antigravityTargets(home).hooksFile}: ${error.message}`);
|
|
@@ -255,7 +419,7 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
255
419
|
* turn. When `core.next` is off or killed, it removes
|
|
256
420
|
* the `"hq"` entry (if HQ-owned for this root) without creating the file.
|
|
257
421
|
*/
|
|
258
|
-
function reconcileAntigravity(root, home, env, coreNext) {
|
|
422
|
+
function reconcileAntigravity(root, home, env, coreNext, canWritePortable, platform) {
|
|
259
423
|
const hooksFile = antigravityTargets(home).hooksFile;
|
|
260
424
|
const fileExists = existsSync(hooksFile);
|
|
261
425
|
const events = coreNext && coreNext.registrationHosts?.includes('antigravity')
|
|
@@ -279,9 +443,32 @@ function reconcileAntigravity(root, home, env, coreNext) {
|
|
|
279
443
|
const current = fileExists ? readJson(hooksFile) : undefined;
|
|
280
444
|
if (current && merge(current) === current)
|
|
281
445
|
return;
|
|
446
|
+
mkdirSync(dirname(hooksFile), { recursive: true });
|
|
282
447
|
writeMerged(hooksFile, home, merge);
|
|
283
448
|
return;
|
|
284
449
|
}
|
|
450
|
+
if (isNativeOnlyCoreRoot(root)) {
|
|
451
|
+
if (!canWritePortable)
|
|
452
|
+
return;
|
|
453
|
+
const current = fileExists ? readJson(hooksFile) : undefined;
|
|
454
|
+
if (current && current[ANTIGRAVITY_HOOK_NAME] !== undefined)
|
|
455
|
+
return;
|
|
456
|
+
if (coreNextOffReason(home, env, platform) === null)
|
|
457
|
+
return;
|
|
458
|
+
if (!fileExists && !detectAntigravity({ home, env, platform }).detected)
|
|
459
|
+
return;
|
|
460
|
+
const portableEvents = stopCompatibilityHold(root, env) !== null
|
|
461
|
+
? ANTIGRAVITY_HOOK_EVENTS.filter((event) => event !== 'Stop')
|
|
462
|
+
: ANTIGRAVITY_HOOK_EVENTS;
|
|
463
|
+
const hqSpec = buildAntigravityHqHookSpec(portableEvents, (event) => portableNativeCommandForPlatform('antigravity', event, root, 'project', platform));
|
|
464
|
+
mkdirSync(dirname(hooksFile), { recursive: true });
|
|
465
|
+
writeMerged(hooksFile, home, (doc) => {
|
|
466
|
+
if (doc[ANTIGRAVITY_HOOK_NAME] !== undefined)
|
|
467
|
+
return doc;
|
|
468
|
+
return { ...doc, [ANTIGRAVITY_HOOK_NAME]: hqSpec };
|
|
469
|
+
});
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
285
472
|
if (!fileExists)
|
|
286
473
|
return;
|
|
287
474
|
const current = readJson(hooksFile);
|
|
@@ -299,6 +486,12 @@ function hasMasterHook(docs, event) {
|
|
|
299
486
|
const pattern = new RegExp(`master-hook\\.sh["']?\\s+["']?${event}(?![A-Za-z])`);
|
|
300
487
|
return docs.some((doc) => entriesOf(hooksOf(doc)?.[event]).some((entry) => typeof entry.command === 'string' && pattern.test(entry.command)));
|
|
301
488
|
}
|
|
489
|
+
/** Shipped post-US-027 portable `hq-hook` shell command for `event` in `.claude/settings.json`. */
|
|
490
|
+
function isShippedPortableClaudeHook(entry, event) {
|
|
491
|
+
return (typeof entry.command === 'string'
|
|
492
|
+
&& !Array.isArray(entry.args)
|
|
493
|
+
&& isShippedPortableClaudeCommand(entry.command, event));
|
|
494
|
+
}
|
|
302
495
|
/**
|
|
303
496
|
* `.claude/settings.json` and `.claude/settings.local.json` of the HQ root.
|
|
304
497
|
*
|
|
@@ -321,20 +514,28 @@ function hasMasterHook(docs, event) {
|
|
|
321
514
|
*
|
|
322
515
|
* Returns one failure line per file left alone for a reason the user must see.
|
|
323
516
|
*/
|
|
324
|
-
function reconcileClaudeProject(root, home, target,
|
|
517
|
+
function reconcileClaudeProject(root, home, target, ours, active, canWritePortable) {
|
|
325
518
|
const failures = [];
|
|
326
519
|
const file = join(root, '.claude/settings.json');
|
|
327
520
|
const localFile = join(root, '.claude/settings.local.json');
|
|
328
521
|
if (!existsSync(file))
|
|
329
522
|
return failures;
|
|
523
|
+
const nativeOnly = isNativeOnlyCoreRoot(root);
|
|
524
|
+
const noMasterHook = nativeOnly;
|
|
330
525
|
const toShell = (event) => (entry) => {
|
|
331
526
|
const { args, commandWindows: _windows, ...rest } = entry;
|
|
332
527
|
// The event an existing native entry was written for: the first
|
|
333
528
|
// launcher argument, or the one after `run --host claude`.
|
|
334
529
|
const written = Array.isArray(args) ? (args[0] === 'run' ? args[3] : args[0]) : undefined;
|
|
335
530
|
const original = typeof written === 'string' ? written : event;
|
|
336
|
-
if (
|
|
337
|
-
|
|
531
|
+
if (noMasterHook) {
|
|
532
|
+
// Never write deleted master-hook.sh or removed launcher argv on a root
|
|
533
|
+
// without master-hook.sh; preserve an existing core.next entry or fall
|
|
534
|
+
// back to the shipped fail-closed portable sh -c wrapper when stable exists.
|
|
535
|
+
if (isCoreNextEntry(entry, root) || !canWritePortable)
|
|
536
|
+
return entry;
|
|
537
|
+
return { ...rest, command: shippedPortableClaudeCommand(original) };
|
|
538
|
+
}
|
|
338
539
|
return { ...rest, command: projectClaudeCommand(original) };
|
|
339
540
|
};
|
|
340
541
|
// The new-core entry takes the shell entry's place and keeps its other
|
|
@@ -344,17 +545,51 @@ function reconcileClaudeProject(root, home, target, launcher, ours, active) {
|
|
|
344
545
|
return { ...rest, command: target.coreNext, args: coreNextArgs('claude', event, root, 'project') };
|
|
345
546
|
};
|
|
346
547
|
const project = (doc, local, moved) => {
|
|
347
|
-
|
|
548
|
+
const seedNative = nativeOnly && !!target;
|
|
549
|
+
if (!hooksOf(doc) && moved.size === 0 && !seedNative)
|
|
550
|
+
return doc;
|
|
551
|
+
const hasLegacyProjectEntry = noMasterHook && canWritePortable && Object.entries(hooksOf(doc) ?? {}).some(([event, groups]) => entriesOf(groups).some((entry) => entry.command === projectClaudeCommand(event) || isNativeEntry(entry, root)));
|
|
552
|
+
if (!active && moved.size === 0 && !allEntries(doc).some(ours) && !hasLegacyProjectEntry)
|
|
348
553
|
return doc;
|
|
349
|
-
|
|
554
|
+
// When master-hook.sh is absent (US-027) and core.next is off or
|
|
555
|
+
// unavailable, never rewrite existing native entries back to the deleted
|
|
556
|
+
// bash script. If rescue relocated entries into settings.local.json or
|
|
557
|
+
// left legacy master-hook/launcher entries behind, replace them with
|
|
558
|
+
// native/portable entries (never master-hook.sh).
|
|
559
|
+
if (noMasterHook && !target && moved.size === 0 && !hasLegacyProjectEntry)
|
|
350
560
|
return doc;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
561
|
+
const events = seedNative
|
|
562
|
+
? [...moved.keys(), ...PROJECT_CLAUDE_HOOK_EVENTS]
|
|
563
|
+
: moved.keys();
|
|
564
|
+
return mapEvents(doc, events, (event, groups) => {
|
|
565
|
+
const covered = !!target?.events.includes(event);
|
|
566
|
+
const existing = groups ?? [];
|
|
567
|
+
const hasLegacyInEvent = canWritePortable && entriesOf(existing).some((entry) => entry.command === projectClaudeCommand(event) || isNativeEntry(entry, root));
|
|
568
|
+
if (nativeOnly && !covered && !moved.has(event) && !hasLegacyInEvent)
|
|
569
|
+
return groups;
|
|
570
|
+
const hasNative = entriesOf(existing).some((entry) => isCoreNextEntry(entry, root));
|
|
571
|
+
const isShellEntry = (entry) => entry.command === projectClaudeCommand(event)
|
|
572
|
+
|| isNativeEntry(entry, root)
|
|
573
|
+
|| isShippedPortableClaudeHook(entry, event);
|
|
574
|
+
const hasShell = entriesOf(existing).some(isShellEntry);
|
|
575
|
+
const seededRestore = seedNative && covered && !hasNative && !hasShell && !hasMasterHook([doc, local], event)
|
|
576
|
+
? { type: 'command', command: shippedPortableClaudeCommand(event), timeout: 300 }
|
|
577
|
+
: null;
|
|
578
|
+
const movedRestore = moved.has(event) && !hasMasterHook([doc, local], event)
|
|
579
|
+
? (noMasterHook
|
|
580
|
+
? (isCoreNextEntry(moved.get(event), root)
|
|
581
|
+
? moved.get(event)
|
|
582
|
+
: (canWritePortable ? { type: 'command', command: shippedPortableClaudeCommand(event), timeout: 300 } : null))
|
|
583
|
+
: toShell(event)(moved.get(event)))
|
|
584
|
+
: null;
|
|
585
|
+
return placeEvent(existing, {
|
|
586
|
+
isShell: isShellEntry,
|
|
587
|
+
isNative: (entry) => isCoreNextEntry(entry, root),
|
|
588
|
+
toShell: toShell(event),
|
|
589
|
+
toNative: covered ? toNative(event) : null,
|
|
590
|
+
restore: movedRestore ?? seededRestore,
|
|
591
|
+
});
|
|
592
|
+
});
|
|
358
593
|
};
|
|
359
594
|
// settings.local.json as it can be used: parsed, not a link.
|
|
360
595
|
const readLocal = (report) => {
|
|
@@ -403,4 +638,66 @@ function reconcileClaudeProject(root, home, target, launcher, ours, active) {
|
|
|
403
638
|
}
|
|
404
639
|
return failures;
|
|
405
640
|
}
|
|
641
|
+
/** Format a TOML basic string (escaping `\` and `"`) for `.codex/config.toml`. */
|
|
642
|
+
function tomlString(value) {
|
|
643
|
+
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Reconcile `<root>/.codex/config.toml` for post-US-027 native-only roots whose
|
|
647
|
+
* `.codex/hooks/hq-codex-hook-adapter.sh` was removed (or roots already carrying
|
|
648
|
+
* our managed native block). Writes `[[hooks.<Event>]]` entries calling
|
|
649
|
+
* `hq-hook run --host codex <Event> --hq-root <root>` for every covered event in
|
|
650
|
+
* {@link PROJECT_CODEX_HOOK_EVENTS}, preserving all other TOML tables and comments.
|
|
651
|
+
*/
|
|
652
|
+
function reconcileCodexProject(root, home, codexNext) {
|
|
653
|
+
const configToml = join(root, '.codex', 'config.toml');
|
|
654
|
+
if (!existsSync(configToml))
|
|
655
|
+
return;
|
|
656
|
+
const nativeOnly = isNativeOnlyCoreRoot(root);
|
|
657
|
+
const current = readFileSync(configToml, 'utf8');
|
|
658
|
+
const hasManaged = current.includes(CODEX_NATIVE_BEGIN) && current.includes(CODEX_NATIVE_END);
|
|
659
|
+
if (!nativeOnly && !hasManaged)
|
|
660
|
+
return;
|
|
661
|
+
if (!codexNext || codexNext.events.length === 0)
|
|
662
|
+
return;
|
|
663
|
+
const blocks = [];
|
|
664
|
+
for (const spec of PROJECT_CODEX_HOOK_EVENTS) {
|
|
665
|
+
if (!codexNext.events.includes(spec.event))
|
|
666
|
+
continue;
|
|
667
|
+
const command = coreNextCommand(codexNext.coreNext, 'codex', spec.event, root, 'project');
|
|
668
|
+
const lines = [`[[hooks.${spec.event}]]`];
|
|
669
|
+
if (spec.matcher)
|
|
670
|
+
lines.push(`matcher = ${tomlString(spec.matcher)}`);
|
|
671
|
+
lines.push('');
|
|
672
|
+
lines.push(`[[hooks.${spec.event}.hooks]]`);
|
|
673
|
+
lines.push('type = "command"');
|
|
674
|
+
lines.push(`command = ${tomlString(command)}`);
|
|
675
|
+
if (codexNext.coreNext.endsWith('.exe')) {
|
|
676
|
+
const winCmd = coreNextCommandWindows(codexNext.coreNext, 'codex', spec.event, root, 'project');
|
|
677
|
+
lines.push(`commandWindows = ${tomlString(winCmd)}`);
|
|
678
|
+
}
|
|
679
|
+
lines.push(`timeout = ${spec.timeout}`);
|
|
680
|
+
lines.push(`statusMessage = ${tomlString(spec.statusMessage)}`);
|
|
681
|
+
blocks.push(lines.join('\n'));
|
|
682
|
+
}
|
|
683
|
+
if (blocks.length === 0)
|
|
684
|
+
return;
|
|
685
|
+
const managed = `${CODEX_NATIVE_BEGIN}\n${blocks.join('\n\n')}\n${CODEX_NATIVE_END}\n`;
|
|
686
|
+
let base = current;
|
|
687
|
+
if (hasManaged) {
|
|
688
|
+
const start = current.indexOf(CODEX_NATIVE_BEGIN);
|
|
689
|
+
const endIdx = current.indexOf(CODEX_NATIVE_END, start);
|
|
690
|
+
let end = endIdx + CODEX_NATIVE_END.length;
|
|
691
|
+
if (current[end] === '\r' && current[end + 1] === '\n')
|
|
692
|
+
end += 2;
|
|
693
|
+
else if (current[end] === '\n')
|
|
694
|
+
end += 1;
|
|
695
|
+
base = current.slice(0, start) + current.slice(end);
|
|
696
|
+
}
|
|
697
|
+
const trimmed = base.replace(/\s+$/, '');
|
|
698
|
+
const next = trimmed ? `${trimmed}\n\n${managed}` : managed;
|
|
699
|
+
if (next === current)
|
|
700
|
+
return;
|
|
701
|
+
replaceFileNoFollow(configToml, next, home);
|
|
702
|
+
}
|
|
406
703
|
//# sourceMappingURL=reconcile.js.map
|