@webpieces/agent-workflow-rules 0.4.1024 → 0.4.1026
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/package.json +9 -8
- package/src/bin/hook-registration.d.ts +22 -48
- package/src/bin/hook-registration.js +58 -54
- package/src/bin/hook-registration.js.map +1 -1
- package/src/bin/session-env-hook.d.ts +31 -0
- package/src/bin/session-env-hook.js +89 -0
- package/src/bin/session-env-hook.js.map +1 -0
- package/src/bin/session-env-registration.d.ts +63 -0
- package/src/bin/session-env-registration.js +111 -0
- package/src/bin/session-env-registration.js.map +1 -0
- package/src/bin/setup.js +8 -31
- package/src/bin/setup.js.map +1 -1
- package/src/bin/upgrade-shim.js +11 -46
- package/src/bin/upgrade-shim.js.map +1 -1
- package/src/core/l0-matrix.js +3 -2
- package/src/core/l0-matrix.js.map +1 -1
- package/src/core/l0-tooling-doc.js +2 -0
- package/src/core/l0-tooling-doc.js.map +1 -1
- package/templates/claude-settings-hook.json +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/agent-workflow-rules",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1026",
|
|
4
4
|
"description": "Independent workflow guards, guard hook, installation and shim management for AI coding agents.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -24,25 +24,26 @@
|
|
|
24
24
|
"directory": "packages/tooling/agent-workflow-rules"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@webpieces/hook-runtime": "0.4.
|
|
28
|
-
"@webpieces/rules-config": "0.4.
|
|
27
|
+
"@webpieces/hook-runtime": "0.4.1026",
|
|
28
|
+
"@webpieces/rules-config": "0.4.1026",
|
|
29
29
|
"inversify": "7.10.4",
|
|
30
30
|
"reflect-metadata": "0.2.2",
|
|
31
|
-
"@webpieces/tooling-common": "0.4.
|
|
32
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
31
|
+
"@webpieces/tooling-common": "0.4.1026",
|
|
32
|
+
"@webpieces/repo-workflow-core": "0.4.1026",
|
|
33
33
|
"tslib": "2.8.1",
|
|
34
|
-
"@webpieces/rules-sdk": "0.4.
|
|
34
|
+
"@webpieces/rules-sdk": "0.4.1026"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
40
|
+
"@webpieces/tooling-testkit": "0.4.1026"
|
|
41
41
|
},
|
|
42
42
|
"types": "./src/index.d.ts",
|
|
43
43
|
"bin": {
|
|
44
44
|
"wp-ai-guards-hook": "./src/adapters/guards-hook.js",
|
|
45
45
|
"wp-install-ai-hooks": "./src/bin/install-entry.js",
|
|
46
|
-
"wp-upgrade-shim": "./src/bin/upgrade-shim.js"
|
|
46
|
+
"wp-upgrade-shim": "./src/bin/upgrade-shim.js",
|
|
47
|
+
"wp-session-env-hook": "./src/bin/session-env-hook.js"
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -49,39 +49,13 @@ import type { ClaudeSettings } from './settings-shape';
|
|
|
49
49
|
*
|
|
50
50
|
* ─── Why the registration is a DRIFT SURFACE, not just an install step ─────────────────────────────
|
|
51
51
|
* Nothing used to validate `.claude/settings.json` at all, so a settings file left on a superseded form
|
|
52
|
-
* silently changed who governs. The installed surface is
|
|
53
|
-
* managed `env` entry — see managed-env.ts —
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* silently changed who governs. The installed surface is FIVE things (ai-hook.sh, the registration, the
|
|
53
|
+
* managed `env` entry — see managed-env.ts — the SessionStart process-name hook — see
|
|
54
|
+
* session-env-registration.ts (#1493) — and the ANCHORING of the NEIGHBOUR hook commands the consumer
|
|
55
|
+
* registers beside ours, see neighbour-hooks.ts), all five are compared against this release, and
|
|
56
|
+
* `wp-upgrade-shim` repairs all five. A cure that fixes three of four is worse than no cure, because
|
|
56
57
|
* it reports success.
|
|
57
58
|
*/
|
|
58
|
-
/**
|
|
59
|
-
* The RETIRED L-1 hook's committed path. Named here, in the one module that must still recognise it, and
|
|
60
|
-
* matched ONLY by isManagedCommand() so repairRegistration() can delete the stale entry. There is no
|
|
61
|
-
* guarantee-root.ts any more — this literal is all that remains of it, deliberately.
|
|
62
|
-
*
|
|
63
|
-
* It is a one-way RECOGNISER, not a shim: nothing emits it, `expectedEntries()` never returns it, and a
|
|
64
|
-
* settings file carrying it is reported STALE. Its only job is to make the retired entry findable so it
|
|
65
|
-
* can be REMOVED.
|
|
66
|
-
*/
|
|
67
|
-
export declare const LEGACY_GUARANTEE_ROOT_MARKER = ".claude/webpieces/guarantee-root.sh";
|
|
68
|
-
/**
|
|
69
|
-
* When this recogniser may be deleted, as a value rather than a comment nobody re-reads.
|
|
70
|
-
*
|
|
71
|
-
* A removal-only migration is still dead weight once no consumer can be carrying the old shape. The
|
|
72
|
-
* hazard of deleting it EARLY is severe and silent — repair would stop stripping the retired entry, and
|
|
73
|
-
* a hook registered against a deleted file exits 127, which the Claude Code hooks reference defines as a
|
|
74
|
-
* NON-BLOCKING error, i.e. every `cd` unjudged while the cure reports success. So it gets a stated date
|
|
75
|
-
* and a test that fails once the date passes, instead of an intention.
|
|
76
|
-
*
|
|
77
|
-
* `legacy-marker-expiry.spec.ts` reads this and fails after it, which is the reminder.
|
|
78
|
-
*
|
|
79
|
-
* MOVED from 2026-12-01 (issue #1475): the first deadline passed with no one able to confirm that every
|
|
80
|
-
* consumer has left the release that wrote `guarantee-root.sh`, and an agent cannot see their machines.
|
|
81
|
-
* Deleting early is the severe, silent failure described above, so the date moved and #1475 holds the
|
|
82
|
-
* human decision.
|
|
83
|
-
*/
|
|
84
|
-
export declare const LEGACY_MARKER_REMOVE_AFTER = "2027-03-01";
|
|
85
59
|
/** One PreToolUse hook entry as webpieces registers it. Data-only → a class, per CLAUDE.md. */
|
|
86
60
|
export declare class HookRegistrationEntry {
|
|
87
61
|
readonly matcher: string;
|
|
@@ -250,15 +224,8 @@ export declare const CODEX_REGISTRATION: HarnessRegistration;
|
|
|
250
224
|
*/
|
|
251
225
|
export declare const HARNESS_REGISTRATIONS: readonly HarnessRegistration[];
|
|
252
226
|
/**
|
|
253
|
-
* True when this PreToolUse command is one webpieces owns —
|
|
254
|
-
*
|
|
255
|
-
* THE SINGLE MOST IMPORTANT LINE IN THIS RELEASE. `LEGACY_GUARANTEE_ROOT_MARKER` is matched here and
|
|
256
|
-
* NOWHERE else: it is how `repairRegistration()` finds and REMOVES the retired H1 entry from a settings
|
|
257
|
-
* file written by an older release. Drop it and the repair silently leaves a live L-1 hook registered
|
|
258
|
-
* against a file this release deletes — exit 127, which the Claude Code hooks reference defines as a
|
|
259
|
-
* NON-BLOCKING error, so every `cd` goes unjudged while `wp-upgrade-shim` reports success and no drift
|
|
260
|
-
* check can name it. Removal-only, never emitted: it appears in no `expectedEntries()` result, so it is
|
|
261
|
-
* a one-way migration and not a second accepted spelling.
|
|
227
|
+
* True when this PreToolUse command is one webpieces owns — any command that runs the managed shim,
|
|
228
|
+
* relative or absolute, so `repairRegistration()` can find a superseded spelling and rewrite it.
|
|
262
229
|
*/
|
|
263
230
|
export declare function isManagedCommand(command: string): boolean;
|
|
264
231
|
/** Every webpieces-managed entry of one settings file, flattened to matcher + command pairs. */
|
|
@@ -272,14 +239,12 @@ export declare function registeredBins(settings: ClaudeSettings): readonly strin
|
|
|
272
239
|
/**
|
|
273
240
|
* The exact set of entries THIS RELEASE expects in a settings file that registers `bins`.
|
|
274
241
|
*
|
|
275
|
-
* ONE entry per registered bin, and nothing else.
|
|
276
|
-
* whenever the GUARDS bin was present; it is retired, and a settings file still carrying it is STALE —
|
|
277
|
-
* `repairRegistration()` removes it via isManagedCommand()'s legacy marker.
|
|
242
|
+
* ONE entry per registered bin, and nothing else.
|
|
278
243
|
*/
|
|
279
244
|
export declare function expectedEntries(harness: HarnessRegistration, bins: readonly string[]): readonly HookRegistrationEntry[];
|
|
280
245
|
/**
|
|
281
246
|
* True when a settings file registers webpieces hooks in a shape this release does not expect: a
|
|
282
|
-
* RELATIVE shim command, a
|
|
247
|
+
* RELATIVE shim command, a stray duplicate, or a wrong matcher.
|
|
283
248
|
*
|
|
284
249
|
* Compared as a SET, not a sequence: Claude Code runs all matching hooks in parallel, so array order
|
|
285
250
|
* carries no meaning and reordering must not read as drift.
|
|
@@ -331,6 +296,13 @@ export declare function applyManagedEnv(settings: ClaudeSettings): boolean;
|
|
|
331
296
|
* that skips half the surface is the failure mode `upgrade-shim.ts`'s header exists to prevent.
|
|
332
297
|
*/
|
|
333
298
|
export declare function repairRegistration(harness: HarnessRegistration, settings: ClaudeSettings): boolean;
|
|
299
|
+
/**
|
|
300
|
+
* True when a Claude settings file that registers webpieces hooks lacks the managed SessionStart
|
|
301
|
+
* process-name hook (#1493) in this release's spelling. Gated on `registeredBins()` exactly like `envStale`.
|
|
302
|
+
*/
|
|
303
|
+
export declare function sessionEnvStale(settings: ClaudeSettings): boolean;
|
|
304
|
+
/** True when either Claude project settings file under `root` lacks the current SessionStart hook. Claude-only, like envStaleAt. */
|
|
305
|
+
export declare function sessionEnvStaleAt(root: string | null): boolean;
|
|
334
306
|
export declare function readSettings(settingsPath: string): ClaudeSettings;
|
|
335
307
|
export declare function writeSettings(settingsPath: string, settings: ClaudeSettings): void;
|
|
336
308
|
/**
|
|
@@ -383,6 +355,8 @@ export declare class SettingsRepair {
|
|
|
383
355
|
* it changed in their file, or it is a silent edit to somebody else's hooks.
|
|
384
356
|
*/
|
|
385
357
|
readonly anchoredNeighbours: readonly string[];
|
|
358
|
+
/** True when the SessionStart process-name hook (#1493) was added or rewritten. */
|
|
359
|
+
readonly sessionEnv: boolean;
|
|
386
360
|
constructor(settingsPath: string, registration: boolean, env: boolean,
|
|
387
361
|
/**
|
|
388
362
|
* The NEW spelling of every NEIGHBOUR hook command this repair anchored — the consumer's own
|
|
@@ -392,7 +366,9 @@ export declare class SettingsRepair {
|
|
|
392
366
|
* edits lines webpieces did not write: the cure has to be able to show the consumer exactly what
|
|
393
367
|
* it changed in their file, or it is a silent edit to somebody else's hooks.
|
|
394
368
|
*/
|
|
395
|
-
anchoredNeighbours: readonly string[]
|
|
369
|
+
anchoredNeighbours: readonly string[],
|
|
370
|
+
/** True when the SessionStart process-name hook (#1493) was added or rewritten. */
|
|
371
|
+
sessionEnv: boolean);
|
|
396
372
|
}
|
|
397
373
|
/**
|
|
398
374
|
* Rewrite every stale settings file under `root`, for EVERY harness; returns what changed, per file.
|
|
@@ -407,9 +383,7 @@ export declare function repairRegistrationAt(root: string): readonly SettingsRep
|
|
|
407
383
|
*
|
|
408
384
|
* There were four, then three, and there are now FOUR again — but the fourth is not the one that was
|
|
409
385
|
* deleted. `GUARANTEE_ROOT_SURFACE` went with L-1 itself: an absolutely-registered shim resolves from
|
|
410
|
-
* any cwd, so there is no launch guarantee left to police and no second .sh file to keep byte-locked.
|
|
411
|
-
* settings file still carrying the retired H1 entry is not its own surface — it is ordinary REGISTRATION
|
|
412
|
-
* drift, which `registrationStaleAt()` reports and `repairRegistration()` fixes by removing it.
|
|
386
|
+
* any cwd, so there is no launch guarantee left to police and no second .sh file to keep byte-locked.
|
|
413
387
|
*
|
|
414
388
|
* The new fourth is `.codex/hooks.json`, and it is here because of what happened while it was NOT a
|
|
415
389
|
* managed surface: something else wrote it, with a matcher that matched no Codex file tool and a shim
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REVIEWER_AGENT_SURFACE = exports.ENV_SURFACE = exports.CODEX_REGISTRATION_SURFACE = exports.REGISTRATION_SURFACE = exports.SHIM_SURFACE = exports.SettingsRepair = exports.HARNESS_REGISTRATIONS = exports.CODEX_REGISTRATION = exports.CLAUDE_REGISTRATION = exports.HarnessRegistration = exports.GUARDS_BIN = exports.RULES_BIN = exports.HookRegistrationEntry =
|
|
3
|
+
exports.REVIEWER_AGENT_SURFACE = exports.ENV_SURFACE = exports.CODEX_REGISTRATION_SURFACE = exports.REGISTRATION_SURFACE = exports.SHIM_SURFACE = exports.SettingsRepair = exports.HARNESS_REGISTRATIONS = exports.CODEX_REGISTRATION = exports.CLAUDE_REGISTRATION = exports.HarnessRegistration = exports.GUARDS_BIN = exports.RULES_BIN = exports.HookRegistrationEntry = void 0;
|
|
4
4
|
exports.isManagedCommand = isManagedCommand;
|
|
5
5
|
exports.managedEntries = managedEntries;
|
|
6
6
|
exports.registeredBins = registeredBins;
|
|
@@ -11,6 +11,8 @@ exports.addHookEntry = addHookEntry;
|
|
|
11
11
|
exports.envStale = envStale;
|
|
12
12
|
exports.applyManagedEnv = applyManagedEnv;
|
|
13
13
|
exports.repairRegistration = repairRegistration;
|
|
14
|
+
exports.sessionEnvStale = sessionEnvStale;
|
|
15
|
+
exports.sessionEnvStaleAt = sessionEnvStaleAt;
|
|
14
16
|
exports.readSettings = readSettings;
|
|
15
17
|
exports.writeSettings = writeSettings;
|
|
16
18
|
exports.neighbourHooksStaleAt = neighbourHooksStaleAt;
|
|
@@ -26,6 +28,8 @@ const shim_1 = require("./shim");
|
|
|
26
28
|
const reviewer_agent_1 = require("./reviewer-agent");
|
|
27
29
|
const neighbour_hooks_1 = require("./neighbour-hooks");
|
|
28
30
|
const managed_env_1 = require("./managed-env");
|
|
31
|
+
const session_env_registration_1 = require("./session-env-registration");
|
|
32
|
+
const SESSION_ENV = new session_env_registration_1.SessionEnvRegistration();
|
|
29
33
|
/**
|
|
30
34
|
* THE INSTALLED HOOK SURFACE — two hooks per harness, all ABSOLUTE, and the ONE place their spelling is
|
|
31
35
|
* defined. See `HarnessRegistration` below, which is what makes "per harness" data rather than four
|
|
@@ -75,39 +79,13 @@ const managed_env_1 = require("./managed-env");
|
|
|
75
79
|
*
|
|
76
80
|
* ─── Why the registration is a DRIFT SURFACE, not just an install step ─────────────────────────────
|
|
77
81
|
* Nothing used to validate `.claude/settings.json` at all, so a settings file left on a superseded form
|
|
78
|
-
* silently changed who governs. The installed surface is
|
|
79
|
-
* managed `env` entry — see managed-env.ts —
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
+
* silently changed who governs. The installed surface is FIVE things (ai-hook.sh, the registration, the
|
|
83
|
+
* managed `env` entry — see managed-env.ts — the SessionStart process-name hook — see
|
|
84
|
+
* session-env-registration.ts (#1493) — and the ANCHORING of the NEIGHBOUR hook commands the consumer
|
|
85
|
+
* registers beside ours, see neighbour-hooks.ts), all five are compared against this release, and
|
|
86
|
+
* `wp-upgrade-shim` repairs all five. A cure that fixes three of four is worse than no cure, because
|
|
82
87
|
* it reports success.
|
|
83
88
|
*/
|
|
84
|
-
/**
|
|
85
|
-
* The RETIRED L-1 hook's committed path. Named here, in the one module that must still recognise it, and
|
|
86
|
-
* matched ONLY by isManagedCommand() so repairRegistration() can delete the stale entry. There is no
|
|
87
|
-
* guarantee-root.ts any more — this literal is all that remains of it, deliberately.
|
|
88
|
-
*
|
|
89
|
-
* It is a one-way RECOGNISER, not a shim: nothing emits it, `expectedEntries()` never returns it, and a
|
|
90
|
-
* settings file carrying it is reported STALE. Its only job is to make the retired entry findable so it
|
|
91
|
-
* can be REMOVED.
|
|
92
|
-
*/
|
|
93
|
-
exports.LEGACY_GUARANTEE_ROOT_MARKER = '.claude/webpieces/guarantee-root.sh';
|
|
94
|
-
/**
|
|
95
|
-
* When this recogniser may be deleted, as a value rather than a comment nobody re-reads.
|
|
96
|
-
*
|
|
97
|
-
* A removal-only migration is still dead weight once no consumer can be carrying the old shape. The
|
|
98
|
-
* hazard of deleting it EARLY is severe and silent — repair would stop stripping the retired entry, and
|
|
99
|
-
* a hook registered against a deleted file exits 127, which the Claude Code hooks reference defines as a
|
|
100
|
-
* NON-BLOCKING error, i.e. every `cd` unjudged while the cure reports success. So it gets a stated date
|
|
101
|
-
* and a test that fails once the date passes, instead of an intention.
|
|
102
|
-
*
|
|
103
|
-
* `legacy-marker-expiry.spec.ts` reads this and fails after it, which is the reminder.
|
|
104
|
-
*
|
|
105
|
-
* MOVED from 2026-12-01 (issue #1475): the first deadline passed with no one able to confirm that every
|
|
106
|
-
* consumer has left the release that wrote `guarantee-root.sh`, and an agent cannot see their machines.
|
|
107
|
-
* Deleting early is the severe, silent failure described above, so the date moved and #1475 holds the
|
|
108
|
-
* human decision.
|
|
109
|
-
*/
|
|
110
|
-
exports.LEGACY_MARKER_REMOVE_AFTER = '2027-03-01';
|
|
111
89
|
/** One PreToolUse hook entry as webpieces registers it. Data-only → a class, per CLAUDE.md. */
|
|
112
90
|
class HookRegistrationEntry {
|
|
113
91
|
matcher;
|
|
@@ -274,19 +252,12 @@ exports.CODEX_REGISTRATION = new HarnessRegistration('codex', 'Codex', 'apply_pa
|
|
|
274
252
|
*/
|
|
275
253
|
exports.HARNESS_REGISTRATIONS = [exports.CLAUDE_REGISTRATION, exports.CODEX_REGISTRATION];
|
|
276
254
|
/**
|
|
277
|
-
* True when this PreToolUse command is one webpieces owns —
|
|
278
|
-
*
|
|
279
|
-
* THE SINGLE MOST IMPORTANT LINE IN THIS RELEASE. `LEGACY_GUARANTEE_ROOT_MARKER` is matched here and
|
|
280
|
-
* NOWHERE else: it is how `repairRegistration()` finds and REMOVES the retired H1 entry from a settings
|
|
281
|
-
* file written by an older release. Drop it and the repair silently leaves a live L-1 hook registered
|
|
282
|
-
* against a file this release deletes — exit 127, which the Claude Code hooks reference defines as a
|
|
283
|
-
* NON-BLOCKING error, so every `cd` goes unjudged while `wp-upgrade-shim` reports success and no drift
|
|
284
|
-
* check can name it. Removal-only, never emitted: it appears in no `expectedEntries()` result, so it is
|
|
285
|
-
* a one-way migration and not a second accepted spelling.
|
|
255
|
+
* True when this PreToolUse command is one webpieces owns — any command that runs the managed shim,
|
|
256
|
+
* relative or absolute, so `repairRegistration()` can find a superseded spelling and rewrite it.
|
|
286
257
|
*/
|
|
287
258
|
// webpieces-disable no-function-outside-class -- module-scope for the same dependency-free reason as shimCommand above
|
|
288
259
|
function isManagedCommand(command) {
|
|
289
|
-
return command.includes(shim_1.SHIM_MARKER)
|
|
260
|
+
return command.includes(shim_1.SHIM_MARKER);
|
|
290
261
|
}
|
|
291
262
|
// webpieces-disable no-function-outside-class -- module-scope for the same dependency-free reason as shimCommand above
|
|
292
263
|
function preToolUse(settings) {
|
|
@@ -317,9 +288,7 @@ function registeredBins(settings) {
|
|
|
317
288
|
/**
|
|
318
289
|
* The exact set of entries THIS RELEASE expects in a settings file that registers `bins`.
|
|
319
290
|
*
|
|
320
|
-
* ONE entry per registered bin, and nothing else.
|
|
321
|
-
* whenever the GUARDS bin was present; it is retired, and a settings file still carrying it is STALE —
|
|
322
|
-
* `repairRegistration()` removes it via isManagedCommand()'s legacy marker.
|
|
291
|
+
* ONE entry per registered bin, and nothing else.
|
|
323
292
|
*/
|
|
324
293
|
// webpieces-disable no-function-outside-class -- module-scope for the same dependency-free reason as HarnessRegistration's siblings
|
|
325
294
|
function expectedEntries(harness, bins) {
|
|
@@ -327,7 +296,7 @@ function expectedEntries(harness, bins) {
|
|
|
327
296
|
}
|
|
328
297
|
/**
|
|
329
298
|
* True when a settings file registers webpieces hooks in a shape this release does not expect: a
|
|
330
|
-
* RELATIVE shim command, a
|
|
299
|
+
* RELATIVE shim command, a stray duplicate, or a wrong matcher.
|
|
331
300
|
*
|
|
332
301
|
* Compared as a SET, not a sequence: Claude Code runs all matching hooks in parallel, so array order
|
|
333
302
|
* carries no meaning and reordering must not read as drift.
|
|
@@ -453,8 +422,38 @@ function repairRegistration(harness, settings) {
|
|
|
453
422
|
// a surface that can drift with no consequence and no way to notice.
|
|
454
423
|
if (harness.managesEnv && applyManagedEnv(settings))
|
|
455
424
|
changed = true;
|
|
425
|
+
// The SessionStart process-name hook (#1493) rides the same gate: Claude Code only, because only its
|
|
426
|
+
// SessionStart hooks get a `$CLAUDE_ENV_FILE` to change later commands' PATH through.
|
|
427
|
+
if (harness.managesEnv && SESSION_ENV.apply(settings))
|
|
428
|
+
changed = true;
|
|
456
429
|
return changed;
|
|
457
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* True when a Claude settings file that registers webpieces hooks lacks the managed SessionStart
|
|
433
|
+
* process-name hook (#1493) in this release's spelling. Gated on `registeredBins()` exactly like `envStale`.
|
|
434
|
+
*/
|
|
435
|
+
// webpieces-disable no-function-outside-class -- module-scope for the same dependency-free reason as shimCommand above
|
|
436
|
+
function sessionEnvStale(settings) {
|
|
437
|
+
if (registeredBins(settings).length === 0)
|
|
438
|
+
return false;
|
|
439
|
+
return SESSION_ENV.stale(settings);
|
|
440
|
+
}
|
|
441
|
+
/** True when either Claude project settings file under `root` lacks the current SessionStart hook. Claude-only, like envStaleAt. */
|
|
442
|
+
// webpieces-disable no-function-outside-class -- module-scope for the same dependency-free reason as HarnessRegistration's siblings
|
|
443
|
+
function sessionEnvStaleAt(root) {
|
|
444
|
+
if (root === null)
|
|
445
|
+
return false;
|
|
446
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
447
|
+
try {
|
|
448
|
+
return exports.CLAUDE_REGISTRATION.settingsPaths(root).some((p) => sessionEnvStale(readSettings(p)));
|
|
449
|
+
// webpieces-disable catch-must-propagate -- a drift check on every tool call must never wedge on unreadable settings; invalid JSON is reported by the registration check's own cure
|
|
450
|
+
}
|
|
451
|
+
catch (err) {
|
|
452
|
+
const error = (0, to_error_1.toError)(err);
|
|
453
|
+
void error; // best-effort: unreadable/invalid settings counts as "not stale" so it never wedges a call
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
458
457
|
// webpieces-disable no-function-outside-class -- module-scope for the same dependency-free reason as shimCommand above
|
|
459
458
|
function readSettings(settingsPath) {
|
|
460
459
|
if (!fs.existsSync(settingsPath))
|
|
@@ -560,6 +559,7 @@ class SettingsRepair {
|
|
|
560
559
|
registration;
|
|
561
560
|
env;
|
|
562
561
|
anchoredNeighbours;
|
|
562
|
+
sessionEnv;
|
|
563
563
|
constructor(settingsPath, registration, env,
|
|
564
564
|
/**
|
|
565
565
|
* The NEW spelling of every NEIGHBOUR hook command this repair anchored — the consumer's own
|
|
@@ -569,11 +569,14 @@ class SettingsRepair {
|
|
|
569
569
|
* edits lines webpieces did not write: the cure has to be able to show the consumer exactly what
|
|
570
570
|
* it changed in their file, or it is a silent edit to somebody else's hooks.
|
|
571
571
|
*/
|
|
572
|
-
anchoredNeighbours
|
|
572
|
+
anchoredNeighbours,
|
|
573
|
+
/** True when the SessionStart process-name hook (#1493) was added or rewritten. */
|
|
574
|
+
sessionEnv) {
|
|
573
575
|
this.settingsPath = settingsPath;
|
|
574
576
|
this.registration = registration;
|
|
575
577
|
this.env = env;
|
|
576
578
|
this.anchoredNeighbours = anchoredNeighbours;
|
|
579
|
+
this.sessionEnv = sessionEnv;
|
|
577
580
|
}
|
|
578
581
|
}
|
|
579
582
|
exports.SettingsRepair = SettingsRepair;
|
|
@@ -594,10 +597,11 @@ function repairRegistrationAt(root) {
|
|
|
594
597
|
const settings = readSettings(settingsPath);
|
|
595
598
|
const neededRegistration = registrationStale(harness, settings);
|
|
596
599
|
const neededEnv = harness.managesEnv && envStale(settings);
|
|
600
|
+
const neededSessionEnv = harness.managesEnv && sessionEnvStale(settings);
|
|
597
601
|
const changedManaged = repairRegistration(harness, settings);
|
|
598
|
-
// AFTER the managed repair, never before: repairRegistration()
|
|
599
|
-
//
|
|
600
|
-
//
|
|
602
|
+
// AFTER the managed repair, never before: repairRegistration() rewrites the two managed
|
|
603
|
+
// commands, so by the time the neighbour pass runs there is nothing webpieces-owned left for
|
|
604
|
+
// it to look at. Gated on
|
|
601
605
|
// registeredBins() for the same reason every other judgement here is — a settings file that
|
|
602
606
|
// registers no webpieces hooks is not a webpieces install, and rewriting somebody's
|
|
603
607
|
// unrelated hook lines in it would be webpieces editing a file it was never given.
|
|
@@ -605,7 +609,7 @@ function repairRegistrationAt(root) {
|
|
|
605
609
|
if (!changedManaged && anchored.length === 0)
|
|
606
610
|
continue;
|
|
607
611
|
writeSettings(settingsPath, settings);
|
|
608
|
-
repairs.push(new SettingsRepair(settingsPath, neededRegistration, neededEnv, anchored));
|
|
612
|
+
repairs.push(new SettingsRepair(settingsPath, neededRegistration, neededEnv, anchored, neededSessionEnv));
|
|
609
613
|
}
|
|
610
614
|
}
|
|
611
615
|
return repairs;
|
|
@@ -615,9 +619,7 @@ function repairRegistrationAt(root) {
|
|
|
615
619
|
*
|
|
616
620
|
* There were four, then three, and there are now FOUR again — but the fourth is not the one that was
|
|
617
621
|
* deleted. `GUARANTEE_ROOT_SURFACE` went with L-1 itself: an absolutely-registered shim resolves from
|
|
618
|
-
* any cwd, so there is no launch guarantee left to police and no second .sh file to keep byte-locked.
|
|
619
|
-
* settings file still carrying the retired H1 entry is not its own surface — it is ordinary REGISTRATION
|
|
620
|
-
* drift, which `registrationStaleAt()` reports and `repairRegistration()` fixes by removing it.
|
|
622
|
+
* any cwd, so there is no launch guarantee left to police and no second .sh file to keep byte-locked.
|
|
621
623
|
*
|
|
622
624
|
* The new fourth is `.codex/hooks.json`, and it is here because of what happened while it was NOT a
|
|
623
625
|
* managed surface: something else wrote it, with a matcher that matched no Codex file tool and a shim
|
|
@@ -659,6 +661,8 @@ function managedSurfaceDrift(root) {
|
|
|
659
661
|
}
|
|
660
662
|
if (envStaleAt(root))
|
|
661
663
|
drifted.push(exports.ENV_SURFACE);
|
|
664
|
+
if (sessionEnvStaleAt(root))
|
|
665
|
+
drifted.push(session_env_registration_1.SESSION_ENV_SURFACE);
|
|
662
666
|
if ((0, reviewer_agent_1.reviewerAgentStale)(root))
|
|
663
667
|
drifted.push(exports.REVIEWER_AGENT_SURFACE);
|
|
664
668
|
return drifted;
|