The design language that makes your AI harness better at design.
JavaScript
Cover every remote in each candidate's rev list
Paul Bakaus386d3e70517d
diff --git a/skill/scripts/context-signals.mjs b/skill/scripts/context-signals.mjsindex 743130a3c..fd3613e48 100644--- a/skill/scripts/context-signals.mjs+++ b/skill/scripts/context-signals.mjs@@ -131,6 +131,13 @@ function gitSignals(cwd) {let baseRev = null;if (!onIntegrationBranch) {const upstream = asUpstream(run(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']));+ // Every named candidate tries the local branch first, then that name on+ // every remote (origin first). Covering all remotes up front is what+ // makes the name-level dedup below safe: a develop or main that exists+ // only as upstream/<name> still resolves even though origin's candidate+ // claimed the name first.+ const remoteOrder = ['origin', ...remotes.filter((name) => name !== 'origin')];+ const revsFor = (name) => [name, ...remoteOrder.map((r) => `${r}/${name}`)];const candidates = [];const seen = new Set();const addCandidate = (name, revs) => {@@ -145,9 +152,9 @@ function gitSignals(cwd) {// even when the platform default (origin/HEAD) was never flipped off// main; an existing develop therefore outranks the remote default. This// is #302's own repro shape, and repos without develop are unaffected.- addCandidate('develop', ['develop', 'origin/develop']);- for (const head of remoteHeads) addCandidate(head.name, [head.name, head.rev]);- for (const name of ['main', 'master']) addCandidate(name, [name, `origin/${name}`]);+ addCandidate('develop', revsFor('develop'));+ for (const head of remoteHeads) addCandidate(head.name, revsFor(head.name));+ for (const name of ['main', 'master']) addCandidate(name, revsFor(name));for (const c of candidates) {const rev = c.revs.find((r) => run(['rev-parse', '--verify', '--quiet', r]) !== null);if (rev) {diff --git a/tests/context-signals.test.mjs b/tests/context-signals.test.mjsindex a0ce8e959..43daf8975 100644--- a/tests/context-signals.test.mjs+++ b/tests/context-signals.test.mjs@@ -436,6 +436,52 @@ describe('gatherSignals', () => {assert.deepEqual(s.git.changedFiles, ['src/App.tsx']);});+ it('finds a develop that exists only on a non-origin remote (#302)', async () => {+ const { execFileSync } = await import('node:child_process');+ const git = (...args) => execFileSync('git', args, { cwd: scratch, stdio: 'ignore' });+ git('init', '-q', '-b', 'feature/f');+ git('config', 'user.email', '[email protected]');+ git('config', 'user.name', 'Test');+ write('src/App.tsx', 'export default 1;\n');+ git('add', '.');+ git('commit', '-qm', 'init');+ // Fork-parent layout: develop lives only as upstream/develop, no local+ // copy, no origin remote, and the feature branch has no upstream.+ git('remote', 'add', 'upstream', '.');+ git('update-ref', 'refs/remotes/upstream/develop', 'HEAD');+ write('src/Hero.tsx', 'export const Hero = () => null;\n');+ git('add', '.');+ git('commit', '-qm', 'feature work');+ const s = await gatherSignals(scratch);+ assert.equal(s.git.base, 'develop');+ assert.deepEqual(s.git.changedFiles, ['src/Hero.tsx']);+ });++ it('a same-name default on a second remote still resolves (#302)', async () => {+ const { execFileSync } = await import('node:child_process');+ const git = (...args) => execFileSync('git', args, { cwd: scratch, stdio: 'ignore' });+ git('init', '-q', '-b', 'feature/h');+ git('config', 'user.email', '[email protected]');+ git('config', 'user.name', 'Test');+ write('src/App.tsx', 'export default 1;\n');+ git('add', '.');+ git('commit', '-qm', 'init');+ git('remote', 'add', 'origin', '.');+ git('remote', 'add', 'upstream', '.');+ // origin advertises main but its tracking ref is gone (pruned); the+ // real main lives only as upstream/main. Name-level dedup must not+ // discard the upstream rev.+ git('symbolic-ref', 'refs/remotes/origin/HEAD', 'refs/remotes/origin/main');+ git('update-ref', 'refs/remotes/upstream/main', 'HEAD');+ git('symbolic-ref', 'refs/remotes/upstream/HEAD', 'refs/remotes/upstream/main');+ write('src/Hero.tsx', 'export const Hero = () => null;\n');+ git('add', '.');+ git('commit', '-qm', 'feature work');+ const s = await gatherSignals(scratch);+ assert.equal(s.git.base, 'main');+ assert.deepEqual(s.git.changedFiles, ['src/Hero.tsx']);+ });+it('never diffs one integration branch against another (#302)', async () => {const { execFileSync } = await import('node:child_process');const git = (...args) => execFileSync('git', args, { cwd: scratch, stdio: 'ignore' });