@ghl-ai/aw 0.1.44-beta.3 → 0.1.44-beta.4
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/c4/jsonMerge.mjs +23 -1
- package/c4/slimRouter.mjs +11 -0
- package/package.json +1 -1
package/c4/jsonMerge.mjs
CHANGED
|
@@ -110,9 +110,23 @@ function commandMatchesAnyPattern(command, patterns) {
|
|
|
110
110
|
* @param {object} opts.newEntry Entry to append after dedup.
|
|
111
111
|
* @param {string[]} opts.commandPatterns Substrings; existing entries with
|
|
112
112
|
* a matching `command` field are stripped.
|
|
113
|
+
* @param {object} [opts.ensureTopLevel] Optional map of top-level keys to set
|
|
114
|
+
* on the JSON root (always overwritten).
|
|
115
|
+
* Used to guarantee schema-required
|
|
116
|
+
* markers like `{ version: 1 }` for
|
|
117
|
+
* Cursor's `~/.cursor/hooks.json`.
|
|
118
|
+
* Without this, Cursor's runtime fails
|
|
119
|
+
* open and silently skips the hook
|
|
120
|
+
* (cursor.com/docs/hooks §schema, §979).
|
|
113
121
|
* @returns {{ changed: boolean, prevEntriesRemoved: number }}
|
|
114
122
|
*/
|
|
115
|
-
export function jsonMergeWithDedup({
|
|
123
|
+
export function jsonMergeWithDedup({
|
|
124
|
+
filePath,
|
|
125
|
+
jsonPointer,
|
|
126
|
+
newEntry,
|
|
127
|
+
commandPatterns,
|
|
128
|
+
ensureTopLevel,
|
|
129
|
+
}) {
|
|
116
130
|
if (!filePath || typeof filePath !== 'string') throw new Error('filePath is required');
|
|
117
131
|
if (typeof jsonPointer !== 'string') throw new Error('jsonPointer is required');
|
|
118
132
|
if (newEntry == null || typeof newEntry !== 'object') throw new Error('newEntry must be an object');
|
|
@@ -142,6 +156,14 @@ export function jsonMergeWithDedup({ filePath, jsonPointer, newEntry, commandPat
|
|
|
142
156
|
filtered.push(newEntry);
|
|
143
157
|
parent[key] = filtered;
|
|
144
158
|
|
|
159
|
+
// Apply schema-required top-level keys last, so callers can pin invariants
|
|
160
|
+
// (e.g. `version: 1`) even if a stale on-disk file is missing them.
|
|
161
|
+
if (ensureTopLevel != null && typeof ensureTopLevel === 'object' && !Array.isArray(ensureTopLevel)) {
|
|
162
|
+
for (const [k, v] of Object.entries(ensureTopLevel)) {
|
|
163
|
+
root[k] = v;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
145
167
|
const serialized = JSON.stringify(root, null, 2) + '\n';
|
|
146
168
|
const changed = atomicWriteIfChanged(filePath, serialized);
|
|
147
169
|
|
package/c4/slimRouter.mjs
CHANGED
|
@@ -497,6 +497,14 @@ function installCursorSlim({ home, escaped }) {
|
|
|
497
497
|
// Same rationale as installClaudeSlim — escape mode skips the card write.
|
|
498
498
|
ensureDir(dirname(hooksJsonPath));
|
|
499
499
|
|
|
500
|
+
// Cursor's hooks.json schema requires `"version": 1` at the top level
|
|
501
|
+
// (cursor.com/docs/hooks). Without it, the runtime silently fails open
|
|
502
|
+
// and never invokes our hooks — which is exactly the bug that prevented
|
|
503
|
+
// the slim card from reaching cursor-cloud agents in 0.1.44-beta.3.
|
|
504
|
+
// We pin this on every merge call so the file is always schema-valid,
|
|
505
|
+
// even if a stale or partial file already exists on disk.
|
|
506
|
+
const cursorHooksTopLevel = { version: 1 };
|
|
507
|
+
|
|
500
508
|
// (G1) The Node-adapter wrapper that satisfies Cursor's request-rewrite
|
|
501
509
|
// JSON contract. NEVER delegate to shared/user-prompt-submit.sh directly.
|
|
502
510
|
const promptHookCommand =
|
|
@@ -524,6 +532,7 @@ function installCursorSlim({ home, escaped }) {
|
|
|
524
532
|
'aw-slim-session-start.sh',
|
|
525
533
|
'.cursor/hooks/session-start.sh',
|
|
526
534
|
],
|
|
535
|
+
ensureTopLevel: cursorHooksTopLevel,
|
|
527
536
|
});
|
|
528
537
|
} else {
|
|
529
538
|
const fullEcc =
|
|
@@ -541,6 +550,7 @@ function installCursorSlim({ home, escaped }) {
|
|
|
541
550
|
'aw-slim-session-start.sh',
|
|
542
551
|
'.cursor/hooks/session-start.sh',
|
|
543
552
|
],
|
|
553
|
+
ensureTopLevel: cursorHooksTopLevel,
|
|
544
554
|
});
|
|
545
555
|
}
|
|
546
556
|
|
|
@@ -553,6 +563,7 @@ function installCursorSlim({ home, escaped }) {
|
|
|
553
563
|
description: 'AW per-prompt rules reminder (ECC Node-adapter)',
|
|
554
564
|
},
|
|
555
565
|
commandPatterns: ['before-submit-prompt.sh'],
|
|
566
|
+
ensureTopLevel: cursorHooksTopLevel,
|
|
556
567
|
});
|
|
557
568
|
|
|
558
569
|
return {
|