Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/.github/seidroid/review-v2"
schedule:
interval: "weekly"
1 change: 1 addition & 0 deletions .github/seidroid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ publishes. The reusable *workflows* that run these features live in `.github/wor
| Feature | What it is | Trigger |
|---|---|---|
| [`ai-review/`](ai-review/) | The workflow-driven seidroid[bot] helpers and their base prompts: an automatic three-pass PR review (OpenAI Codex ∥ Cursor → Claude synthesis, posting one PR review + an `AI Review` check) and the conversational `@seidroid` assistant. Prompts: `scout.md`, `review.md`, `assistant.md`. | `pull_request` (review); `@seidroid` mention (assistant) |
| [`review-v2/`](review-v2/) | The next generation of the seidroid review: the same review contract on [pi](https://pi.dev) running on the GitHub runner, with no session server. In development, alongside `seidroid-review.yml`. | `pull_request`; `@seidroid review` |

`ai-review` passes the diff to models from inside the Actions runner, so it sees the change
but never runs it. A sandbox-backed path that could build and test a PR before reviewing it
Expand Down
1 change: 1 addition & 0 deletions .github/seidroid/review-v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
26 changes: 26 additions & 0 deletions .github/seidroid/review-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# seidroid review v2

The next generation of the seidroid review: the same bot, identity, markers and review
contract as [`seidroid-review.yml`](../../workflows/seidroid-review.yml), on a simpler
engine. The review runs in [pi](https://pi.dev) on the GitHub runner, so there is no
session server, sandbox or teardown, and every part of it is pinned by one uci ref.

It is in development and runs beside v1 without changing it.

## Layout

| Path | What it is |
|---|---|
| `src/verdict.ts` | The review contract: the `submit_review` schema, and how a submission becomes the recorded decision, check conclusion, placeable findings and thread plan. |
| `src/accepted.ts` | The base branch's accepted pre-existing conditions, read from its guidelines. |
| `test/` | Tests, ported from the v1 driver's. |

## Development

Node 24 runs the TypeScript directly, so there is no build step.

```sh
npm ci
npm run typecheck
npm test
```
57 changes: 57 additions & 0 deletions .github/seidroid/review-v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .github/seidroid/review-v2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@sei-protocol/seidroid-review-v2",
"private": true,
"type": "module",
"engines": {
"node": ">=24"
},
"scripts": {
"test": "node --test",
"typecheck": "tsc"
},
"dependencies": {
"typebox": "1.3.27"
},
"devDependencies": {
"@types/node": "24.19.2",
"typescript": "5.9.3"
}
}
79 changes: 79 additions & 0 deletions .github/seidroid/review-v2/src/accepted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const ACCEPTED_HEADING = "accepted";
const MIN_ACCEPTANCE_WORDS = 3;
const MAX_ACCEPTANCES = 100;
const NEGATION_REACH = 3;
const NEGATIONS = new Set(["no", "not", "never", "longer", "without", "stopped", "removed", "dropped", "neither", "nor"]);
const CONJUNCTIONS = [" and ", " but ", " also ", " as well as ", " plus ", "; "];

/**
* parseAccepted returns the bullets under a guidelines heading whose first word is
* "Accepted": the pre-existing conditions the base branch accepts. Bullets in fences,
* and bullets naming fewer than three words, are skipped.
*/
export function parseAccepted(text: string): string[] {
const out: string[] = [];
let inSection = false;
let inFence = false;
for (const line of text.replace(/\r\n?/g, "\n").split("\n")) {
const t = line.trim();
if (t.startsWith("```") || t.startsWith("~~~")) {
inFence = !inFence;
continue;
}
if (inFence) continue;
const title = headingTitle(t);
if (title !== undefined) {
const first = title.toLowerCase().split(/\s+/)[0] ?? "";
inSection = first.replace(/[:.,]+$/, "") === ACCEPTED_HEADING;
continue;
}
if (!inSection || !/^[-+*](\s|$)/.test(t)) continue;
const entry = t.slice(1).trim();
if (words(acceptancePhrase(entry)).length < MIN_ACCEPTANCE_WORDS) continue;
out.push(entry);
if (out.length >= MAX_ACCEPTANCES) break;
}
return out;
}

function headingTitle(line: string): string | undefined {
const m = /^(#{1,6})(?:[ \t]|$)/.exec(line);
if (!m || line[m[1]!.length] === "#") return undefined;
return line.slice(m[1]!.length).trim();
}

const words = (s: string): string[] => s.split(/\s+/).filter((w) => w !== "");

/** acceptancePhrase is an entry without the rationale after its dash. */
function acceptancePhrase(entry: string): string {
for (const sep of [" — ", " -- ", " – "]) {
const at = entry.indexOf(sep);
if (at >= 0) return entry.slice(0, at);
}
return entry;
}

/**
* acceptanceFor returns the accepted entry a finding's body names, or "" when none does.
* A phrase negated just before it, or joined to more after it, does not match.
*/
export function acceptanceFor(body: string, accepted: readonly string[]): string {
const haystack = matchable(body);
for (const entry of accepted) {
const phrase = matchable(acceptancePhrase(entry));
if (phrase === "") continue;
const at = haystack.indexOf(phrase);
if (at < 0) continue;
const before = haystack.slice(0, at);
const after = haystack.slice(at + phrase.length);
if (!negated(before) && !CONJUNCTIONS.some((c) => (" " + after).includes(c))) return entry;
}
return "";
}

const negated = (before: string): boolean =>
words(before)
.slice(-NEGATION_REACH)
.some((w) => NEGATIONS.has(w.replace(/^[.,;:()]+|[.,;:()]+$/g, "")));

const matchable = (s: string): string => words(s.toLowerCase().replace(/[`"'“”‘’]/g, "")).join(" ");
Loading
Loading