codehere 2.0.3 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codehere",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "A git-native team brain for vibe coders. Silent fixes for AI coding agents: breaks doom loops, verifies 'done', blocks test tampering, and shares what your team learned.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/brain.js CHANGED
@@ -286,6 +286,16 @@ export function git(root, args, raw = false) {
286
286
  }
287
287
  }
288
288
 
289
+ // A diff can be far larger than execFileSync's 1 MiB default, and an unread diff must never look
290
+ // like an empty one: this reads it whole and returns null when git fails.
291
+ export function gitDiff(root, args) {
292
+ try {
293
+ return execFileSync('git', ['--literal-pathspecs', ...args], { cwd: root, stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 512 * 1024 * 1024 }).toString();
294
+ } catch {
295
+ return null;
296
+ }
297
+ }
298
+
289
299
  // Files with uncommitted changes, relative to root, which may be a subfolder of the repo.
290
300
  export function statusFiles(root) {
291
301
  const prefix = git(root, ['rev-parse', '--show-prefix']);
package/src/hooks.js CHANGED
@@ -7,7 +7,7 @@ import crypto from 'node:crypto';
7
7
  import { spawnSync } from 'node:child_process';
8
8
  import {
9
9
  findRoot, paths, readConfig, readState, writeState, session, readRules, renderDoc,
10
- listDocs, git, isGitRepo, me, slug, today, isApproved, readApprovals, printable, commitId, statusFiles, gitHashes, noTick,
10
+ listDocs, git, gitDiff, isGitRepo, me, slug, today, isApproved, readApprovals, printable, commitId, statusFiles, gitHashes, noTick,
11
11
  removedAt,
12
12
  } from './brain.js';
13
13
  import {
@@ -604,9 +604,12 @@ function stop(root, input) {
604
604
 
605
605
  // 1. tampering with tests or checks (only in files changed this session)
606
606
  let findings = [];
607
+ let unread = false; // the session's diff could not be read, so weakened tests were not checked: never proven
607
608
  if (changed.length) {
608
609
  const nameStatus = git(root, ['diff', base, '--relative', '--name-status', '--', ...changed]);
609
- findings = tamperFindings(nameStatus, git(root, ['diff', base, '--relative', '-U0', '--', ...changed]));
610
+ const diff = gitDiff(root, ['diff', base, '--relative', '-U0', '--', ...changed]);
611
+ unread = diff === null;
612
+ findings = tamperFindings(nameStatus, diff || '');
610
613
  }
611
614
  const key = findings.join('|');
612
615
  if (findings.length && s.tamperReported !== key && mayBlock) {
@@ -651,6 +654,7 @@ function stop(root, input) {
651
654
  `codehere ⊘ ${noTick(cfg.testCommand)} · not run · not approved on this machine${last ? ` · last approved: ${noTick(last.command)}` : ''} › run codehere approve in your terminal`
652
655
  );
653
656
  }
657
+ if (unread && !(cfg.verifyOnStop && approved)) lines.push("codehere ✕ this session's diff could not be read · weakened tests not checked");
654
658
  const configChanged = settings.includes('.codehere/config.json');
655
659
  const cmd = noTick(cfg.testCommand || '');
656
660
  let passLine = null;
@@ -679,9 +683,10 @@ function stop(root, input) {
679
683
  }
680
684
  // ✓ only for intact evidence (DESIGN.md §1): not after a weakened test, nor after the
681
685
  // config that names the test command changed.
682
- proven = !findings.length && !configChanged;
686
+ proven = !findings.length && !configChanged && !unread;
683
687
  if (findings.length) passLine = `codehere ✕ ${cmd} passed, but a check was weakened · ${noTick(findings.join(' · '))}`;
684
688
  else if (configChanged) passLine = `codehere ✕ ${cmd} passed, but .codehere/config.json changed during this session`;
689
+ else if (unread) passLine = `codehere ✕ ${cmd} passed, but this session's diff could not be read · weakened tests not checked`;
685
690
  else passLine = `codehere ✓ ${cmd} · ${runResult(t)} · re-run here · ${t.seconds.toFixed(1)} s`;
686
691
  if (proven) {
687
692
  state.lastGreen = { commit: git(root, 'rev-parse HEAD'), at: new Date().toISOString() };