mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-10 02:30:39 +01:00
fix: pre-landing review fixes (Step 11): linear passive-pitch clause scan, tokenized grep operands, harness diagnostic reset and early stderr
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
8daf48d5ea
commit
abb347ed6f
4 files changed
+11
-3
No files matched your search
@@ -1282,5 +1282,10 @@ describe('coverage audit native evidence: an escaped grep over two literal files
|
||||
expect(reads(capture.call.command, capture.call.output.replace(nonce, nonce.slice(1) + '0'))).toMatchObject({ sourceRead: false });
|
||||
expect(reads(capture.call.command.replace('cat -n test/billing.test.ts', 'cat -n test/other.test.ts'))).toMatchObject({ testsRead: false });
|
||||
});
|
||||
|
||||
test('a quoted grep operand with a space stays one literal file operand', () => {
|
||||
expect(reads(capture.call.command.replace('review/SKILL.md review/sections/review-army.md', 'review/SKILL.md "docs/design notes.md"'))).toEqual(both);
|
||||
expect(reads(capture.call.command.replace('review/SKILL.md review/sections/review-army.md', '"docs/design notes.md" -f/tmp/foreign'))).toEqual(neither);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -80,8 +80,9 @@ function stagePieces(stage: string[], scope: ShellScope, alone: boolean): Piece[
|
||||
if (!name || (discarded && name === 'echo')) return undefined;
|
||||
// Backslashes are data only in these closed grep/awk display patterns.
|
||||
const grepRange = /^grep\s+-n(?:\s+-i)?(?:\s+-B\d{1,4})?(?:\s+-A\d{1,4})?\s+(?:"(?:[^"\\$`]|\\[|.])*"|'(?:[^'\\$`]|\\[|.])*')\s+(.+)$/.exec(text);
|
||||
// One or more literal file operands, none of them an option.
|
||||
const displayGrep = Boolean(grepRange?.[1]!.split(' ').every(operand => literal(operand) !== undefined && !literal(operand)!.startsWith('-')));
|
||||
// One or more literal file operands (the tokens after the quoted pattern), none of them an option.
|
||||
const grepOperands = grepRange ? words.slice(words.findIndex((word, index) => index > 0 && /^["']/.test(word)) + 1) : [];
|
||||
const displayGrep = grepOperands.length > 0 && grepOperands.every(operand => literal(operand) !== undefined && !literal(operand)!.startsWith('-'));
|
||||
const awkRange = /^awk\s+'\/(?:[^/\\]|\\[./|])*\/,\/(?:[^/\\]|\\[./|])*\/'\s+(.+)$/.exec(text)
|
||||
?? /^awk\s+'\/(?:[^/\\]|\\[./|])*\/\{f=1\} f&&\/(?:[^/\\]|\\[./|])*\/\{exit\} f'\s+(.+)$/.exec(text);
|
||||
const displayAwk = Boolean(awkRange && literal(awkRange[1]!) && !literal(awkRange[1]!)!.startsWith('-'));
|
||||
|
||||
@@ -68,6 +68,7 @@ export function budgetHarness(): Harness {
|
||||
const run = (bin: string, args: string[], extraEnv: NodeJS.ProcessEnv = {}): Run => {
|
||||
const argv = bin === REVIEW_LOG_BIN ? ['bash', bin] : [process.execPath, ...bunIsolationArgs(), bin];
|
||||
const started = Date.now();
|
||||
abnormal = '';
|
||||
const r = spawnSync(argv[0], [...argv.slice(1), ...args], { cwd: repo, env: { ...env, ...extraEnv }, encoding: 'utf8', timeout: 60_000 });
|
||||
const result = { code: r.status ?? -1, out: r.stdout ?? '', err: r.stderr ?? '' };
|
||||
if (r.status !== null) return result;
|
||||
@@ -79,6 +80,7 @@ export function budgetHarness(): Harness {
|
||||
abnormal += `; children of ${r.pid}: ${children.stdout?.trim() || (children.error ? `unavailable (${children.error.message})` : 'none')}`;
|
||||
}
|
||||
result.err += `\n[harness] ${abnormal}`;
|
||||
process.stderr.write(`[harness] ${abnormal}\n`);
|
||||
return result;
|
||||
};
|
||||
let records = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* predicate's own coordinate clause holds no negation: "Aside is not installed but can be downloaded at aside.com"
|
||||
* counts, "Aside is not something that can be downloaded" and "... but cannot be downloaded" never do.
|
||||
*/
|
||||
const ASIDE_DOWNLOAD_PITCH = String.raw`(?:^|[.!?;:]\s*|\n)\s*(?:[>*-]\s*)*["\u201C]?download (?:it|Aside) at aside\.com\b|(?:^|[.!?;:,\u2014\u2013\n])[\s>*_-]*(?<!(?:\b(?:not|never|no|cannot)|n['\u2019]t)\s+)(?:(?:then|please|just|so|first|now)\s+)?(?:you\s+(?:can|could|may|should|need\s+to)\s+)?download (?:Aside|it) \(macOS 15\+\) at aside\.com\b|(?:^|[.!?;:,\u2014\u2013\n])[\s>*_-]*(?:Aside|it)\b(?:[^.!?;:,\n]*?\b(?:but|and|yet)\b)?(?:(?!\b(?:not|never|no)\b|n['\u2019]t\b)[^.!?;:,\n])*?\b(?:can|may)\s+be\s+downloaded\s+(?:at|from)\s+aside\.com\b`;
|
||||
const ASIDE_DOWNLOAD_PITCH = String.raw`(?:^|[.!?;:]\s*|\n)\s*(?:[>*-]\s*)*["\u201C]?download (?:it|Aside) at aside\.com\b|(?:^|[.!?;:,\u2014\u2013\n])[\s>*_-]*(?<!(?:\b(?:not|never|no|cannot)|n['\u2019]t)\s+)(?:(?:then|please|just|so|first|now)\s+)?(?:you\s+(?:can|could|may|should|need\s+to)\s+)?download (?:Aside|it) \(macOS 15\+\) at aside\.com\b|(?:^|[.!?;:,\u2014\u2013\n])[\s>*_-]*(?:Aside|it)\b(?:(?=(?<clause>(?:(?!\b(?:can|may)\s+be\s+downloaded\b)[^.!?;:,\n])*\b(?:but|and|yet)\b))\k<clause>)?(?:(?!\b(?:not|never|no)\b|n['\u2019]t\b)[^.!?;:,\n])*?\b(?:can|may)\s+be\s+downloaded\s+(?:at|from)\s+aside\.com\b`;
|
||||
export const asideDownloadPitch = new RegExp(ASIDE_DOWNLOAD_PITCH, 'im');
|
||||
export const asideDownloadPitchCount = (text: string): number => [...text.matchAll(new RegExp(ASIDE_DOWNLOAD_PITCH, 'gim'))].length;
|
||||
|
||||
|
||||
Reference in new issue
Block a user