Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(git): derive resume facts from parsed command intent [C7,N19]

Corey Olsona6f144e4f304
diff --git a/src/cli-main.js b/src/cli-main.js
index 18758082..0bad3f05 100644
--- a/src/cli-main.js
+++ b/src/cli-main.js
@@ -255,7 +255,7 @@ export async function main(argv, streams) {
// Version and help ask Git nothing, so they never load it.
if (asksGitNothing(argv)) return runMain(argv, streams);
const { withGitFacts } = await import('./git.js');
- return withGitFacts(() => runMain(argv, streams), { resumeSources: argv[0] === 'resume' });
+ return withGitFacts(() => runMain(argv, streams));
}
/** Parse and execute one CLI command, binding its checkout session and Git-fact scope. */
@@ -279,6 +279,7 @@ async function runMain(argv, streams) {
needsRepo = !(parsed.values.help || parsed.values.version || command === 'help' || command === 'version');
} catch { sync = false; needsRepo = false; }
const git = needsRepo ? await import('./git.js') : null;
+ git?.setResumeSourceFacts(parsed?.positionals[0] === 'resume');
if (parsed) {
try {
// Checkout identity supplies the display role even if a person-channel check refuses first.
diff --git a/src/git.js b/src/git.js
index cbd57945..da0af54f 100644
--- a/src/git.js
+++ b/src/git.js
@@ -46,6 +46,7 @@ export function withGitReadFacts(work) {
/** Reuse facts within one CLI invocation, while isolating concurrent commands and expiring settled ones.
*
* @param {() => unknown} work
+ * @param {{ resumeSources?: boolean }} [options] permit pinned source facts only for an explicit resume scope
* @returns {Promise<unknown>}
*/
export async function withGitFacts(work, { resumeSources = false } = {}) {
@@ -61,6 +62,12 @@ export async function withGitFacts(work, { resumeSources = false } = {}) {
return gitReadFacts.getStore() === true ? gitReadFacts.run(null, run) : run();
}
+/** Set the already parsed command intent before its first repository lookup, without creating a new cache. */
+export function setResumeSourceFacts(enabled) {
+ const cache = gitFacts.getStore();
+ if (cache?.active) cache.resumeSources = enabled === true;
+}
+
/** Drop facts after this command changes Git state such as refs, configuration, or worktrees. */
export function invalidateGitFacts() {
gitFacts.getStore()?.facts.clear();
diff --git a/test/git-calls.test.js b/test/git-calls.test.js
index 50f3444c..2bf100f0 100644
--- a/test/git-calls.test.js
+++ b/test/git-calls.test.js
@@ -147,6 +147,9 @@ test('ordinary resume reads its indexed work card with at most four Git processe
assert.deepEqual(card.stale, []);
assert.equal(typeof card.newWorktreeLocation, 'string');
assert.equal(typeof card.next, 'string');
+ const leading = resetAndCount(box, box.worker, '--json', 'resume');
+ assert.ok(leading.count <= 4, `flag-leading resume started ${leading.count} Git processes`);
+ assert.equal(JSON.parse(leading.result.stdout).me.id, card.me.id, 'global flags before the parsed command retain the same resume card');
mkdirSync(join(box.worker, 'src'), { recursive: true });
writeFileSync(join(box.worker, 'src/ahead.txt'), 'real branch divergence\n');
box.git(box.worker, 'add', 'src/ahead.txt');