brainclaw 0.24.0 → 0.27.0

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.
@@ -245,6 +245,8 @@ export async function runInit(options = {}) {
245
245
  if (initMemoryRepo(cwd)) {
246
246
  console.log('✔ Initialized memory git repo for versioning');
247
247
  }
248
+ // Install post-merge hook for auto-release of claims after merge
249
+ installPostMergeHookIfMissing(cwd);
248
250
  const onboardingPreflight = runBootstrapProfile({ cwd, refresh: true });
249
251
  console.log('');
250
252
  console.log('Onboarding preflight:');
@@ -268,6 +270,45 @@ export async function runInit(options = {}) {
268
270
  console.log('');
269
271
  console.log(`Tip: run 'brainclaw context --json' to load the shared memory into your agent session.`);
270
272
  }
273
+ function installPostMergeHookIfMissing(cwd) {
274
+ try {
275
+ let dir = path.resolve(cwd);
276
+ let gitRoot;
277
+ while (true) {
278
+ if (fs.existsSync(path.join(dir, '.git'))) {
279
+ gitRoot = dir;
280
+ break;
281
+ }
282
+ const parent = path.dirname(dir);
283
+ if (parent === dir)
284
+ break;
285
+ dir = parent;
286
+ }
287
+ if (!gitRoot)
288
+ return;
289
+ const hooksDir = path.join(gitRoot, '.git', 'hooks');
290
+ const hookPath = path.join(hooksDir, 'post-merge');
291
+ if (fs.existsSync(hookPath))
292
+ return; // don't overwrite existing hooks
293
+ if (!fs.existsSync(hooksDir))
294
+ fs.mkdirSync(hooksDir, { recursive: true });
295
+ const script = [
296
+ '#!/bin/sh',
297
+ '# brainclaw post-merge hook — auto-release claims on merged files',
298
+ 'BCLAW_CMD=""',
299
+ 'if command -v brainclaw >/dev/null 2>&1; then BCLAW_CMD="brainclaw"',
300
+ 'elif command -v bclaw >/dev/null 2>&1; then BCLAW_CMD="bclaw"',
301
+ 'else BCLAW_CMD="npx --no brainclaw"; fi',
302
+ '$BCLAW_CMD release-claims --from-git-diff 2>/dev/null || true',
303
+ '',
304
+ ].join('\n');
305
+ fs.writeFileSync(hookPath, script, { encoding: 'utf-8', mode: 0o755 });
306
+ console.log('✔ Installed post-merge hook for auto-release of claims');
307
+ }
308
+ catch {
309
+ // Non-critical — skip silently
310
+ }
311
+ }
271
312
  function resolveStorageDir(storageDir) {
272
313
  const candidate = (storageDir ?? MEMORY_DIR).trim();
273
314
  if (candidate !== MEMORY_DIR) {