mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-29 03:15:05 +01:00
browse --session before the command, Gemini AQ. keys, /verify trust across worktrees, and two more fixes from outside reports (#4684)
Five bugs reported by outside contributors are fixed, each with a test that fails on main: `browse --session` before the command, a stray blank tab in the handoff window, new Gemini keys refused by `$D setup`, `/verify` asking for trust again in every worktree, and `/context-restore` missing a second Claude profile's transcripts. Nothing to do after merge. Co-authored-by: Basim Rauf <22585821+Simba3696@users.noreply.github.com> Co-authored-by: Lockyer <135391289+Lockyer228@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1v/outside-voice#1 reader=outside-voice Review-Finding: p1v/outside-voice#2 reader=outside-voice Review-Finding: p1v/outside-voice#3 reader=outside-voice Review-Finding: p1v/outside-voice#4 reader=outside-voice
This commit is contained in:
19 files changed
+171
-29
No files matched your search
@@ -72,7 +72,8 @@ describe('context-restore carve: the transcript fallback', () => {
|
||||
const sources = generateTranscriptSources(ctx);
|
||||
if (host.transcripts) {
|
||||
expect(sources, host.name).toContain(host.transcripts.root);
|
||||
expect(discovery, host.name).toContain('TRANSCRIPT_DIR="' + host.transcripts.root.replace(/^~/, '$HOME').split(/\/(?=<|\*)/)[0]);
|
||||
const dir = host.transcripts.root.replace(/^~\/\.claude/, '${CLAUDE_CONFIG_DIR:-$HOME/.claude}').replace(/^~\/\.codex/, '${CODEX_HOME:-$HOME/.codex}').replace(/^~/, '$HOME');
|
||||
expect(discovery, host.name).toContain('TRANSCRIPT_DIR="' + dir.split(/\/(?=<|\*)/)[0]);
|
||||
expect(discovery, host.name).not.toContain('declares no transcript store');
|
||||
} else {
|
||||
expect(sources, host.name).toContain('| ' + host.displayName + ' | none |');
|
||||
@@ -98,8 +99,8 @@ describe('context-restore carve: the transcript fallback', () => {
|
||||
test('hosts with no declared store render a one-line none; Claude and Codex render their own discovery', () => {
|
||||
const ctx = (host: string) => ({ host, skillName: 'context-restore', paths: { binDir: '$GSTACK_BIN' } }) as never;
|
||||
expect(generateTranscriptDiscovery(ctx('cursor'))).toContain('TRANSCRIPTS: none (Cursor declares no transcript store');
|
||||
expect(generateTranscriptDiscovery(ctx('claude'))).toContain('$HOME/.claude/projects/');
|
||||
expect(generateTranscriptDiscovery(ctx('codex'))).toContain('$HOME/.codex/sessions');
|
||||
expect(generateTranscriptDiscovery(ctx('claude'))).toContain('${CLAUDE_CONFIG_DIR:-$HOME/.claude}/projects/');
|
||||
expect(generateTranscriptDiscovery(ctx('codex'))).toContain('${CODEX_HOME:-$HOME/.codex}/sessions');
|
||||
for (const host of ['claude', 'codex', 'cursor']) expect(generateTranscriptDiscovery(ctx(host))).toContain('if [ -n "${GSTACK_CAPY:-}" ]');
|
||||
});
|
||||
});
|
||||
@@ -113,7 +114,7 @@ describe('the discovery block against fixture transcripts', () => {
|
||||
|
||||
function sh(script: string, extra: Record<string, string> = {}, cwd = project) {
|
||||
const env: Record<string, string> = {};
|
||||
for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !k.startsWith('GSTACK_') && k !== 'CLAUDE_PROJECT_DIR') env[k] = v;
|
||||
for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !k.startsWith('GSTACK_') && !['CLAUDE_PROJECT_DIR', 'CLAUDE_CONFIG_DIR', 'CODEX_HOME'].includes(k)) env[k] = v;
|
||||
const r = spawnSync('bash', ['-c', script], { cwd, env: { ...env, HOME: home, ...extra }, encoding: 'utf8', timeout: 30_000 });
|
||||
return { out: (r.stdout ?? '') + (r.stderr ?? ''), status: r.status ?? -1 };
|
||||
}
|
||||
@@ -157,6 +158,18 @@ describe('the discovery block against fixture transcripts', () => {
|
||||
expect(r.out).toMatch(/TRANSCRIPTS: .*\(1 files in the last 7 days\)/);
|
||||
});
|
||||
|
||||
// #4559: a second Claude Code profile (CLAUDE_CONFIG_DIR) keeps its transcripts under its own folder.
|
||||
test('Claude Code: reads the CLAUDE_CONFIG_DIR profile when one is set', () => {
|
||||
const profile = path.join(tmp, 'claude-work');
|
||||
fs.mkdirSync(path.join(profile, 'projects', slug(project)), { recursive: true });
|
||||
fs.copyFileSync(FIXTURE, path.join(profile, 'projects', slug(project), 'w0rk.jsonl'));
|
||||
const r = sh(block, { CLAUDE_CONFIG_DIR: profile });
|
||||
expect(r.status, r.out).toBe(0);
|
||||
expect(r.out).toContain('/w0rk.jsonl');
|
||||
expect(r.out).not.toContain('/7c2f.jsonl');
|
||||
expect(r.out).toMatch(/TRANSCRIPTS: .*\(1 files in the last 7 days\)/);
|
||||
});
|
||||
|
||||
test('a wider window admits the old file; a missing folder and Capy both print none', () => {
|
||||
expect(sh(block, { TRANSCRIPT_DAYS: '30' }).out).toContain('/old.jsonl');
|
||||
const empty = path.join(tmp, 'work', 'fresh');
|
||||
|
||||
@@ -122,6 +122,28 @@ describe('gstack-checks on a fixture repo', () => {
|
||||
// Value: protects=nothing runs before consent, including pregate's selection manifest command, and any change to a check or a
|
||||
// selection command needs consent again; fails_when=an untrusted or edited command executes; why_new=the boundary is new;
|
||||
// seam=the fixture's selection command writes a marker when it runs; no_claim=the trust grant log's contents
|
||||
// #4407: an agent app that starts every session in a fresh git worktree asked for trust every time.
|
||||
test('trust covers every worktree of the repository while the command set matches', () => {
|
||||
const s = setup();
|
||||
expect(s.checks(['trust']).status).toBe(0);
|
||||
const wt = path.join(s.repo.root, 'wt-two');
|
||||
s.repo.git('worktree', 'add', '-q', wt, '-b', 'scratch');
|
||||
const inWorktree = (args: string[]) => runBin(s.repo, 'gstack-checks', [...args, '--base', 'main'], { SELECTION_MARK: s.mark }, wt);
|
||||
expect(inWorktree(['detect']).out).toContain('TRUST trusted');
|
||||
write(wt, 'package.json', JSON.stringify({ name: 'fixture', version: '1.0.0', scripts: { test: 'node --test test/*.test.js', typecheck: 'node scripts/other.js' } }, null, 2) + '\n');
|
||||
expect(inWorktree(['detect']).out).toContain('TRUST untrusted');
|
||||
expect(s.checks(['detect']).out).toContain('TRUST trusted');
|
||||
});
|
||||
|
||||
test('a folder whose .git file points at a trusted repository, without being its worktree, still asks', () => {
|
||||
const s = setup();
|
||||
expect(s.checks(['trust']).status).toBe(0);
|
||||
const forged = path.join(s.repo.root, 'forged');
|
||||
fs.cpSync(s.repo.work, forged, { recursive: true, filter: src => path.basename(src) !== '.git' });
|
||||
fs.writeFileSync(path.join(forged, '.git'), `gitdir: ${path.join(s.repo.work, '.git')}\n`);
|
||||
expect(runBin(s.repo, 'gstack-checks', ['detect', '--base', 'main'], { SELECTION_MARK: s.mark }, forged).out).toContain('TRUST untrusted');
|
||||
});
|
||||
|
||||
test('consent covers the checks and the selection manifest commands', () => {
|
||||
const s = setup();
|
||||
commit(s.repo, { 'lib/util.js': 'exports.add = (a, b) => b + a;\n' });
|
||||
|
||||
@@ -190,6 +190,12 @@ describe("MEDIUM demoted credential-shaped patterns (TENSION-1)", () => {
|
||||
);
|
||||
expect(f?.tier).toBe("MEDIUM");
|
||||
});
|
||||
test("an AQ. Gemini key from Google AI Studio is google.api_key", () => {
|
||||
const f = scan("AQ.Ab" + "c".repeat(40), { repoVisibility: "private" }).findings.find(
|
||||
(x) => x.id === "google.api_key",
|
||||
);
|
||||
expect(f?.tier).toBe("MEDIUM");
|
||||
});
|
||||
test("jwt is MEDIUM", () => {
|
||||
const jwt = "eyJhbGciOiJ.eyJzdWIiOiI." + "x".repeat(20);
|
||||
const f = scan(jwt, { repoVisibility: "private" }).findings.find((x) => x.id === "jwt");
|
||||
|
||||
Reference in new issue
Block a user