Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
The comment surface supports:

- comments: `cyclops audit`, `@decofe cyclops audit`, `derek audit`
- arguments: `fast`, `iterations=N`, `hours=N`, `config=PATH`, `models=...`, `run-label=LABEL`, `dry-run`, `note="..."`
- arguments: `fast`, `perf`, `iterations=N`, `hours=N`, `config=PATH`, `models=...`, `run-label=LABEL`, `dry-run`, `note="..."`

Set `permission-check-mode: org` (with `organization`) for org-membership API
checks. Use `permission-token` when those checks need a token distinct from the
Expand Down
1 change: 1 addition & 0 deletions actions/pr-audit-comment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ Supported arguments:
- `models=...`
- `run-label=LABEL`
- `dry-run`
- `perf`
- `note="..."`
7 changes: 5 additions & 2 deletions actions/pr-audit-comment/pr_audit_comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require("path");
const { spawnSync } = require("child_process");

const usage = [
'**Usage:** `cyclops audit [fast] [iterations=N] [hours=N] [config=pr-review.yaml] ',
'**Usage:** `cyclops audit [fast] [perf] [iterations=N] [hours=N] [config=pr-review.yaml] ',
'[models="anthropic/claude-opus-4-7,openai/gpt-5.5"] [run-label=LABEL] ',
'[dry-run] [note="per-run audit guidance"]`',
].join("");
Expand All @@ -24,11 +24,12 @@ function parseArgs(body, commandRegex) {
models: "",
"run-label": "",
"dry-run": "false",
perf: "false",
note: "",
};
const intArgs = new Set(["iterations", "hours"]);
const stringArgs = new Set(["config", "models", "run-label", "note"]);
const boolArgs = new Set(["dry-run"]);
const boolArgs = new Set(["dry-run", "perf"]);
const unknown = [];
const invalid = [];

Expand Down Expand Up @@ -167,6 +168,7 @@ function buildPayload(context, pr, defaults) {
if (defaults.models) data.models = defaults.models;
if (defaults["run-label"]) data.run_label = defaults["run-label"];
if (defaults.note) data.audit_note_b64 = Buffer.from(defaults.note, "utf8").toString("base64");
if (defaults.perf === "true") data.perf = true;

return {
repository: `${context.repo.owner}/${context.repo.repo}`,
Expand All @@ -184,6 +186,7 @@ function buildSummary(defaults) {
if (defaults.models) summaryParts.push(`models: \`${defaults.models}\``);
if (defaults["run-label"]) summaryParts.push(`run-label: \`${defaults["run-label"]}\``);
if (defaults["dry-run"] === "true") summaryParts.push("dry-run: `true`");
if (defaults.perf === "true") summaryParts.push("perf: `true`");
if (defaults.note) {
const note = defaults.note.replace(/`/g, "'").slice(0, 160);
summaryParts.push(`note: \`${note}${defaults.note.length > 160 ? "..." : ""}\``);
Expand Down
10 changes: 9 additions & 1 deletion actions/pr-audit-comment/pr_audit_comment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ function makeProcessHarness(tmp) {
pythonEnv: path.join(tmp, "python-env"),
curlArgs: path.join(tmp, "curl-args"),
curlEnv: path.join(tmp, "curl-env"),
payload: path.join(tmp, "payload.json"),
};

writeExecutable(path.join(bin, "python3"), `#!/bin/sh
Expand All @@ -244,6 +245,11 @@ exec ${shellQuote(pythonPath)} "$@"
writeExecutable(path.join(bin, "curl"), `#!/bin/sh
printf '%s\n' "$@" > ${shellQuote(files.curlArgs)}
env > ${shellQuote(files.curlEnv)}
for arg in "$@"; do
case "$arg" in
@*) cp "\${arg#@}" ${shellQuote(files.payload)} ;;
esac
done
cat >/dev/null
`);
writeExecutable(path.join(bin, "jq"), `#!/bin/sh
Expand Down Expand Up @@ -576,13 +582,15 @@ test("comment publisher preserves quoted arguments and isolates parser and curl"
process.chdir(hostile);
const result = await runScenario({
mode: "association",
body: "cyclops audit note='quoted guidance'",
body: "cyclops audit perf note='quoted guidance'",
permissionToken: "permission-token-canary",
});

assert.deepEqual(result.core.failures, []);
assert.equal(result.primary.calls.commentUpdates.length, 1);
assert.match(result.primary.calls.commentUpdates[0].body, /event published/);
assert.match(result.primary.calls.commentUpdates[0].body, /perf: `true`/);
assert.equal(JSON.parse(fs.readFileSync(harness.files.payload)).data.perf, true);
assert.deepEqual(readLines(harness.files.pythonArgs).slice(0, 2), ["-I", "-c"]);
assert.deepEqual(readLines(harness.files.curlArgs).slice(5, 9), [
"--url",
Expand Down
Loading