Skip to content

Commit 369c1fd

Browse files
Jay GordonCopilot
authored andcommitted
test: replay gallery classification via stdin
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a7a5d40 commit 369c1fd

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎scripts/gallery-audit/copilot.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ export function buildClassificationPrompt({ prompt, candidatePath, auditPath, ca
137137
}
138138

139139
export function buildCopilotArguments({ prompt, candidatePath, auditPath, catalogPath, existingEntries }) {
140+
buildClassificationPrompt({ prompt, candidatePath, auditPath, catalogPath, existingEntries });
140141
return [
141-
'-p', buildClassificationPrompt({ prompt, candidatePath, auditPath, catalogPath, existingEntries }),
142142
'--agent=gallery-curator',
143143
'--silent',
144144
'--stream=off',
@@ -155,6 +155,7 @@ function invokeCopilot(options) {
155155
return spawnSync('copilot', buildCopilotArguments(options), {
156156
encoding: 'utf8',
157157
env: process.env,
158+
input: buildClassificationPrompt(options),
158159
maxBuffer: 2 * 1024 * 1024,
159160
windowsHide: true,
160161
});
@@ -168,6 +169,8 @@ export function runCopilotClassification(options) {
168169
for (let attempt = 1; attempt <= 2; attempt += 1) {
169170
try {
170171
const result = execute(options);
172+
if (result.error) throw result.error;
173+
if (result.signal) throw new Error(`Copilot terminated by signal ${result.signal}`);
171174
if (result.status !== 0) throw new Error(`Copilot exited with status ${result.status}: ${(result.stderr ?? '').trim()}`);
172175
const parsed = JSON.parse(normalizeCopilotJson(result.stdout ?? ''));
173176
return { status: 'complete', attempts: attempt, classification: validateClassification(parsed, options.candidates, existingEntries) };

‎scripts/gallery-audit/test/audit.test.mjs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ test('embeds JSON inputs as untrusted prompt data without native attachments', (
610610
assert.match(prompt, /Keep this/);
611611
const retirementSection = prompt.match(/BEGIN RETIREMENT CANDIDATES ---([\s\S]*?)--- END RETIREMENT CANDIDATES/)?.[1] ?? '';
612612
assert.doesNotMatch(retirementSection, /Keep this/);
613-
assert.equal(argumentsList[0], '-p');
614-
assert.equal(argumentsList[1], prompt);
613+
assert.doesNotMatch(argumentsList.join(' '), /(^| )--prompt( |$)|(^| )-p( |$)/);
615614
assert.ok(argumentsList.includes('--no-color'));
616615
assert.deepEqual(argumentsList.slice(argumentsList.indexOf('--dynamic-retrieval'), argumentsList.indexOf('--dynamic-retrieval') + 2), ['--dynamic-retrieval', 'skills=on']);
617616
assert.equal(argumentsList.some((argument) => argument.startsWith('--attachment')), false);

0 commit comments

Comments
 (0)