@nanobpm/urban-pr-review-codefirst 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -0
- package/components/review-round.json +69 -0
- package/db/migrations/001_init.sql +46 -0
- package/db/migrations/002_transcript.sql +7 -0
- package/db/migrations/003_open_escalation.sql +8 -0
- package/deno.json +22 -0
- package/deno.lock +77 -0
- package/main.ts +352 -0
- package/nano-generated/app-pages.ts +676 -0
- package/nano-generated/data-cli.ts +552 -0
- package/nano-generated/data-sdk.ts +536 -0
- package/nano-generated/domain-rows.d.ts +87 -0
- package/nano-generated/domain-types.ts +1418 -0
- package/nano-generated/domain.ts +36 -0
- package/nano-generated/llm-worker.ts +403 -0
- package/nano-generated/message-io.d.ts +17 -0
- package/nano-generated/messages.ts +26 -0
- package/nano-generated/meta.ts +18 -0
- package/nano-generated/node-deno-shim.mjs +250 -0
- package/nano-generated/node-loader.mjs +60 -0
- package/nano-generated/node-register.mjs +11 -0
- package/nano-generated/worker-io.d.ts +28 -0
- package/nano-generated/worker-sdk.ts +468 -0
- package/nano-generated/workers.ts +29 -0
- package/nano.app.json +17 -0
- package/nanobpm.project.json +22 -0
- package/package.json +28 -0
- package/pages/home.page.json +127 -0
- package/prompts/review-round.md +119 -0
- package/scripts/answer.ts +20 -0
- package/scripts/purge-db.ts +70 -0
- package/scripts/review-ready.ts +20 -0
- package/scripts/submit.ts +32 -0
- package/tsconfig.json +14 -0
- package/workflows/convergence-loop.ts +299 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0",
|
|
3
|
+
"title": "PR Review Convergence",
|
|
4
|
+
"nodes": [
|
|
5
|
+
{
|
|
6
|
+
"type": "text",
|
|
7
|
+
"id": "title",
|
|
8
|
+
"props": { "text": "PR Review Convergence", "variant": "heading" }
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "text",
|
|
12
|
+
"id": "subtitle",
|
|
13
|
+
"props": {
|
|
14
|
+
"text": "Submit a pull request to run the autonomous review-convergence loop. Answer escalations inline; cancel a run at any time.",
|
|
15
|
+
"variant": "sub"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "actionForm",
|
|
20
|
+
"id": "submit",
|
|
21
|
+
"props": {
|
|
22
|
+
"title": "Submit a pull request",
|
|
23
|
+
"submitLabel": "Start review",
|
|
24
|
+
"action": { "kind": "startProcess", "process": "convergence-loop" },
|
|
25
|
+
"fields": [
|
|
26
|
+
{ "key": "pr", "label": "owner/repo#123 or a GitHub PR URL", "type": "text" }
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "dataGrid",
|
|
32
|
+
"id": "prs",
|
|
33
|
+
"props": {
|
|
34
|
+
"title": "Pull requests",
|
|
35
|
+
"rowKey": "pr_key",
|
|
36
|
+
"refreshMs": 5000,
|
|
37
|
+
"data": {
|
|
38
|
+
"kind": "datasource",
|
|
39
|
+
"source": "app",
|
|
40
|
+
"table": "pull_requests",
|
|
41
|
+
"orderBy": { "field": "updated_at", "dir": "desc" },
|
|
42
|
+
"filter": [
|
|
43
|
+
{ "field": "status", "in": ["converging", "waiting_review", "escalated"] }
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"tabs": [
|
|
47
|
+
{
|
|
48
|
+
"label": "Active",
|
|
49
|
+
"filter": [
|
|
50
|
+
{ "field": "status", "in": ["converging", "waiting_review", "escalated"] }
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"label": "History",
|
|
55
|
+
"filter": [{ "field": "status", "in": ["converged", "abandoned"] }]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"columns": [
|
|
59
|
+
{ "field": "pr_key", "header": "PR" },
|
|
60
|
+
{ "field": "status", "header": "Status" },
|
|
61
|
+
{ "field": "current_round", "header": "Round" },
|
|
62
|
+
{ "field": "updated_at", "header": "Updated" }
|
|
63
|
+
],
|
|
64
|
+
"rowActions": [
|
|
65
|
+
{
|
|
66
|
+
"label": "Cancel",
|
|
67
|
+
"confirm": "Cancel this PR's review run?",
|
|
68
|
+
"showWhenField": "process_key",
|
|
69
|
+
"action": { "kind": "cancelProcess", "keyField": "process_key" }
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"detail": {
|
|
73
|
+
"linkField": "url",
|
|
74
|
+
"fields": [
|
|
75
|
+
{ "field": "repo", "label": "Repository" },
|
|
76
|
+
{ "field": "number", "label": "PR number" },
|
|
77
|
+
{ "field": "outcome", "label": "Outcome" }
|
|
78
|
+
],
|
|
79
|
+
"children": [
|
|
80
|
+
{
|
|
81
|
+
"title": "Rounds",
|
|
82
|
+
"source": "app",
|
|
83
|
+
"table": "rounds",
|
|
84
|
+
"parentField": "pr_key",
|
|
85
|
+
"childField": "pr_key",
|
|
86
|
+
"orderBy": { "field": "round_no", "dir": "asc" },
|
|
87
|
+
"columns": [
|
|
88
|
+
{ "field": "round_no", "header": "#" },
|
|
89
|
+
{ "field": "status", "header": "Result" },
|
|
90
|
+
{ "field": "summary", "header": "Summary" }
|
|
91
|
+
],
|
|
92
|
+
"lazyField": { "field": "transcript", "label": "Transcript", "lazy": true }
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"title": "Escalations",
|
|
96
|
+
"source": "app",
|
|
97
|
+
"table": "escalations",
|
|
98
|
+
"parentField": "pr_key",
|
|
99
|
+
"childField": "pr_key",
|
|
100
|
+
"orderBy": { "field": "id", "dir": "asc" },
|
|
101
|
+
"columns": [
|
|
102
|
+
{ "field": "round_no", "header": "#" },
|
|
103
|
+
{ "field": "kind", "header": "Kind" },
|
|
104
|
+
{ "field": "question", "header": "Question" },
|
|
105
|
+
{ "field": "status", "header": "Status" },
|
|
106
|
+
{ "field": "answer", "header": "Answer" }
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"form": {
|
|
111
|
+
"showWhenField": "open_escalation_id",
|
|
112
|
+
"title": "Answer the open escalation",
|
|
113
|
+
"promptField": "open_escalation_question",
|
|
114
|
+
"inputKey": "answer",
|
|
115
|
+
"inputLabel": "Your answer",
|
|
116
|
+
"submitLabel": "Send answer",
|
|
117
|
+
"action": {
|
|
118
|
+
"kind": "publishMessage",
|
|
119
|
+
"message": "escalation-answered",
|
|
120
|
+
"correlationKeyField": "pr_key"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# PR Review Convergence — Round Instructions
|
|
2
|
+
|
|
3
|
+
You are an autonomous engineer driving a GitHub pull request to **convergence**
|
|
4
|
+
against an automated reviewer (GitHub Copilot's PR review). You are servicing one
|
|
5
|
+
`senior:pr-review` job: perform **exactly one round**, then return a structured
|
|
6
|
+
result. The Nano process owns the durable wait between rounds — do **not** block
|
|
7
|
+
waiting for the next review.
|
|
8
|
+
|
|
9
|
+
## Job input (`job.variables`)
|
|
10
|
+
|
|
11
|
+
| var | meaning |
|
|
12
|
+
|------------|----------------------------------------------------------------|
|
|
13
|
+
| `prUrl` | canonical PR URL |
|
|
14
|
+
| `repo` | `owner/name` |
|
|
15
|
+
| `prNumber` | PR number |
|
|
16
|
+
| `round` | 1-based round counter |
|
|
17
|
+
| `answer` | present only when resuming from an escalation — a human's reply|
|
|
18
|
+
| `prompt` | this document |
|
|
19
|
+
|
|
20
|
+
## Workspace (host mode) — read this first
|
|
21
|
+
|
|
22
|
+
The worker harness (e.g. `c8ctl nano work`) has **already provisioned an isolated,
|
|
23
|
+
per-job workspace for you**: your **current working directory is a fresh clone of
|
|
24
|
+
the repo, checked out on the PR's head branch**. The harness exposes it via the
|
|
25
|
+
`AGENT_WORKSPACE`, `REPO_URL`, `REPO_BRANCH` and `REPO_REF` environment variables,
|
|
26
|
+
and it **reaps that workspace after the job ends**.
|
|
27
|
+
|
|
28
|
+
Because several agents may run on the same host at once:
|
|
29
|
+
|
|
30
|
+
- **Work only inside your current working directory.** It is yours alone for this
|
|
31
|
+
job — other jobs get their own clones, so you will not collide with them as long
|
|
32
|
+
as you stay in `cwd`.
|
|
33
|
+
- **Do NOT re-clone the repo, `cd` elsewhere, or create a separate `git worktree`.**
|
|
34
|
+
You are already on the right branch; a second checkout only risks a collision.
|
|
35
|
+
- **Do not touch global/host state** — no `git config --global`, no writes outside
|
|
36
|
+
your workspace, no shared temp paths.
|
|
37
|
+
- **Clean up before you return (see step 6).** The harness reaps the workspace it
|
|
38
|
+
gave you, but anything *you* create elsewhere is your responsibility to remove.
|
|
39
|
+
|
|
40
|
+
## What to do in a round
|
|
41
|
+
|
|
42
|
+
1. **Read the latest review.** Fetch the newest Copilot review + its inline
|
|
43
|
+
comments on the PR (`gh pr view`, `gh api .../pulls/{n}/reviews`, `.../comments`).
|
|
44
|
+
If `answer` is present, treat it as the human's decision on the escalation you
|
|
45
|
+
raised last round and act on it first.
|
|
46
|
+
2. **Triage each comment** into: *fix* (correct, worth doing), *nitpick* (apply
|
|
47
|
+
silently), *needs human input* (design/product/tradeoff you can't decide), or
|
|
48
|
+
*push back* (wrong / false positive — reply with evidence, make no change).
|
|
49
|
+
3. **Act.** Make the code changes for all fixes + nitpicks in your workspace (`cwd`)
|
|
50
|
+
in one coherent, signed-off commit (`git commit -s`). Run the repo's
|
|
51
|
+
build/test/lint locally before pushing. Push to the PR's head branch (the branch
|
|
52
|
+
you are already on) — do not open a new branch or PR.
|
|
53
|
+
4. **Reply in-thread** to each comment you addressed or pushed back on, one reply
|
|
54
|
+
per comment, so the trail lives on the PR.
|
|
55
|
+
5. **Re-request review** from Copilot so a fresh review lands (this is what the
|
|
56
|
+
Nano poller waits for).
|
|
57
|
+
6. **Clean up.** Before returning, remove anything you created outside the commit so
|
|
58
|
+
host mode does not leak resources: `git worktree remove` any worktree you added,
|
|
59
|
+
delete scratch branches/clones/checkouts, and remove temp/scratch files and build
|
|
60
|
+
output you generated outside the tracked tree. Leave the host as you found it —
|
|
61
|
+
the harness will reap the workspace it provisioned.
|
|
62
|
+
|
|
63
|
+
## Convergence / stop condition
|
|
64
|
+
|
|
65
|
+
Consider the PR **converged** when the latest review has no actionable comment:
|
|
66
|
+
- Copilot's summary reports nothing new ("Reviewed N files … generated no new
|
|
67
|
+
comments") and there are no new inline comments, **or**
|
|
68
|
+
- every new comment is a nitpick you already handled or intentionally declined,
|
|
69
|
+
**or**
|
|
70
|
+
- Copilot is looping — reiterating a point you already addressed or pushed back
|
|
71
|
+
on (two rounds of the same substantive point = converged).
|
|
72
|
+
|
|
73
|
+
## Return value (job result variables)
|
|
74
|
+
|
|
75
|
+
Return **one** of:
|
|
76
|
+
|
|
77
|
+
| `status` | when | also set |
|
|
78
|
+
|---------------|---------------------------------------------------------------|-----------------|
|
|
79
|
+
| `converged` | nothing actionable left (see above) | `summary` |
|
|
80
|
+
| `addressed` | you made changes + pushed + re-requested review this round | `summary` |
|
|
81
|
+
| `needs_input` | you hit a decision only a human can make | `summary`, `question` |
|
|
82
|
+
| `blocked` | you are stuck on something external (auth, failing push, missing secret) | `summary`, `question` |
|
|
83
|
+
|
|
84
|
+
- `summary` — a short human-readable account of what this round did.
|
|
85
|
+
- `question` — required for `needs_input`/`blocked`: the exact question or blocker
|
|
86
|
+
a human must resolve. Their reply comes back to you as `answer` next round.
|
|
87
|
+
|
|
88
|
+
Never guess on a `needs_input` decision — raise it and let a human answer.
|
|
89
|
+
|
|
90
|
+
### How to return it (the wire mechanism)
|
|
91
|
+
|
|
92
|
+
Your result variables only reach the process if you emit them through the harness's
|
|
93
|
+
result channel. Prose in your normal output is **not** parsed — if you only "say"
|
|
94
|
+
your status in the transcript, the round escalates with an empty question. So:
|
|
95
|
+
|
|
96
|
+
1. **Write a JSON object to the file at `$AGENT_RESULT_FILE`** (an env var the
|
|
97
|
+
harness sets for you). The object's keys become process variables. Example for a
|
|
98
|
+
round that needs a human decision:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
printf '%s' '{"status":"needs_input","summary":"Resolved 3 nits; blocked on API shape","question":"Should getUser() throw or return null when the user is absent?"}' > "$AGENT_RESULT_FILE"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Write this file **once**, at the very end, with your final result. Keep it a flat
|
|
105
|
+
JSON object of exactly the variables in the table above.
|
|
106
|
+
|
|
107
|
+
2. **Fallback** (only if you truly cannot write the file): print a single line to
|
|
108
|
+
stdout of the form `::nano:result:: {json}` — e.g.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
::nano:result:: {"status":"converged","summary":"No actionable comments left"}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The harness reads the **last** such line. A trailing ```json fenced block is also
|
|
115
|
+
accepted as a last resort.
|
|
116
|
+
|
|
117
|
+
Do not put the result file inside the repo checkout or `git add` it — it lives
|
|
118
|
+
outside your workspace. Exit `0` for every status (including `blocked`/`needs_input`);
|
|
119
|
+
a non-zero exit means a genuine crash and the job is retried.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Answer an escalation, resuming a PR parked at `wait-answer` (needs_input,
|
|
2
|
+
// blocked, or round-cap). This is the human-in-the-loop half of the flow — a
|
|
3
|
+
// real, engine-visible catch event a Temporal-style code-first surface cannot draw.
|
|
4
|
+
//
|
|
5
|
+
// deno task answer owner/repo#42 "merge as-is"
|
|
6
|
+
import { WorkflowClient } from "@nanobpm/workflow";
|
|
7
|
+
import { convergenceLoop } from "../workflows/convergence-loop.ts";
|
|
8
|
+
|
|
9
|
+
const baseUrl = (Deno.env.get("NANOBPMN_BASE_URL") ?? "http://localhost:8080").replace(/\/+$/, "");
|
|
10
|
+
const prKey = Deno.args[0] ?? "Magikcraft/nano-bpm#1";
|
|
11
|
+
const answer = Deno.args[1] ?? "proceed";
|
|
12
|
+
|
|
13
|
+
const client = new WorkflowClient({ baseUrl });
|
|
14
|
+
// `correlationKey` is the instance's `prKey`; the message name is derived as
|
|
15
|
+
// `convergence-loop:wait-answer`.
|
|
16
|
+
await client.signal(convergenceLoop, "wait-answer", prKey, {
|
|
17
|
+
answer,
|
|
18
|
+
escalationId: Number(Deno.args[2] ?? 0),
|
|
19
|
+
});
|
|
20
|
+
console.log(`answered ${convergenceLoop.id} (prKey=${prKey}, answer=${JSON.stringify(answer)})`);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// `deno task purge` — reset the app database to a clean, freshly-migrated state.
|
|
2
|
+
//
|
|
3
|
+
// The engine (Zeebe/nano) and the app database are two separate stores: when you
|
|
4
|
+
// wipe the engine's journal (`rm -rf ~/nano-data`) the app's sqlite still holds
|
|
5
|
+
// stale `pull_requests`/`rounds`/`escalations` rows pointing at process instances
|
|
6
|
+
// that no longer exist. This task drops the app's sqlite file(s) and re-applies
|
|
7
|
+
// `db/migrations`, so `deno task start` comes up against an empty, correct schema.
|
|
8
|
+
//
|
|
9
|
+
// It resolves the datasource the same way the app does (the manifest's `app`
|
|
10
|
+
// source + `NANO_APP_DB_URL`), so it always targets the real file — never a guess.
|
|
11
|
+
import { listSources, sqlitePath } from "@nanobpm/data";
|
|
12
|
+
|
|
13
|
+
async function rm(path: string): Promise<boolean> {
|
|
14
|
+
try {
|
|
15
|
+
await Deno.remove(path);
|
|
16
|
+
return true;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
if (e instanceof Deno.errors.NotFound) return false;
|
|
19
|
+
throw e;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const root = Deno.cwd();
|
|
24
|
+
const { default: def, sources } = await listSources();
|
|
25
|
+
const source = sources.find((s) => s.name === def) ?? sources[0];
|
|
26
|
+
if (!source) {
|
|
27
|
+
console.error("purge: no datasource declared in the manifest");
|
|
28
|
+
Deno.exit(1);
|
|
29
|
+
}
|
|
30
|
+
if (source.driver !== "sqlite") {
|
|
31
|
+
console.error(`purge: refusing to purge a non-sqlite datasource (${source.driver})`);
|
|
32
|
+
Deno.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const dbPath = sqlitePath(source.url, root);
|
|
36
|
+
// Remove the main DB and its WAL/SHM sidecars (SQLite in WAL mode).
|
|
37
|
+
const removed: string[] = [];
|
|
38
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
39
|
+
if (await rm(dbPath + suffix)) removed.push(dbPath + suffix);
|
|
40
|
+
}
|
|
41
|
+
console.log(
|
|
42
|
+
removed.length ? `purge: removed ${removed.join(", ")}` : "purge: no existing db files",
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// Re-apply migrations via the generated data gateway (recreates the schema + the
|
|
46
|
+
// `_nano_migrations` ledger), so the next `start` doesn't have to.
|
|
47
|
+
const cmd = new Deno.Command("deno", {
|
|
48
|
+
args: ["run", "--allow-read", "--allow-write", "--allow-env", "nano-generated/data-cli.ts"],
|
|
49
|
+
stdin: "piped",
|
|
50
|
+
stdout: "piped",
|
|
51
|
+
stderr: "inherit",
|
|
52
|
+
});
|
|
53
|
+
const child = cmd.spawn();
|
|
54
|
+
const w = child.stdin.getWriter();
|
|
55
|
+
await w.write(new TextEncoder().encode(JSON.stringify({ op: "migrate" })));
|
|
56
|
+
await w.close();
|
|
57
|
+
const { code, stdout } = await child.output();
|
|
58
|
+
const out = new TextDecoder().decode(stdout).trim();
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(out) as { ok: boolean; applied?: string[]; error?: string };
|
|
61
|
+
if (!parsed.ok) {
|
|
62
|
+
console.error(`purge: migrate failed: ${parsed.error}`);
|
|
63
|
+
Deno.exit(1);
|
|
64
|
+
}
|
|
65
|
+
console.log(`purge: migrated (${(parsed.applied ?? []).length} file(s) applied)`);
|
|
66
|
+
} catch {
|
|
67
|
+
console.error(`purge: unexpected migrate output: ${out}`);
|
|
68
|
+
Deno.exit(code || 1);
|
|
69
|
+
}
|
|
70
|
+
console.log("purge: app database is clean.");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Signal that a fresh review has landed, resuming a PR parked at `wait-review`.
|
|
2
|
+
// A poller (watching GitHub review events) would normally publish this; here it
|
|
3
|
+
// is a manual nudge so you can drive the loop by hand.
|
|
4
|
+
//
|
|
5
|
+
// deno task review-ready owner/repo#42
|
|
6
|
+
import { WorkflowClient } from "@nanobpm/workflow";
|
|
7
|
+
import { convergenceLoop } from "../workflows/convergence-loop.ts";
|
|
8
|
+
|
|
9
|
+
const baseUrl = (Deno.env.get("NANOBPMN_BASE_URL") ?? "http://localhost:8080").replace(/\/+$/, "");
|
|
10
|
+
const prKey = Deno.args[0] ?? "Magikcraft/nano-bpm#1";
|
|
11
|
+
|
|
12
|
+
const client = new WorkflowClient({ baseUrl });
|
|
13
|
+
// `correlationKey` is the instance's `prKey`; the message name is derived as
|
|
14
|
+
// `convergence-loop:wait-review`.
|
|
15
|
+
await client.signal(convergenceLoop, "wait-review", prKey, {
|
|
16
|
+
reviewId: Number(Deno.args[1] ?? 0),
|
|
17
|
+
reviewState: Deno.args[2] ?? "COMMENTED",
|
|
18
|
+
submittedAt: new Date().toISOString(),
|
|
19
|
+
});
|
|
20
|
+
console.log(`review-ready → ${convergenceLoop.id} (prKey=${prKey})`);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Kick off one `convergence-loop` instance against the running app/gateway.
|
|
2
|
+
//
|
|
3
|
+
// deno task start # the worker-host service
|
|
4
|
+
// deno task submit https://github.com/o/r/pull/42 # create an instance
|
|
5
|
+
//
|
|
6
|
+
// The instance runs `review-round` (an EXTERNAL agent job) and then parks at a
|
|
7
|
+
// durable catch event — `wait-review` (re-review) or `wait-answer` (escalation).
|
|
8
|
+
import { WorkflowClient } from "@nanobpm/workflow";
|
|
9
|
+
import { convergenceLoop } from "../workflows/convergence-loop.ts";
|
|
10
|
+
|
|
11
|
+
const baseUrl = (Deno.env.get("NANOBPMN_BASE_URL") ?? "http://localhost:8080").replace(/\/+$/, "");
|
|
12
|
+
|
|
13
|
+
const prUrl = Deno.args[0] ?? "https://github.com/Magikcraft/nano-bpm/pull/1";
|
|
14
|
+
const maxRounds = Number(Deno.args[1] ?? Deno.env.get("MAX_ROUNDS") ?? 5);
|
|
15
|
+
|
|
16
|
+
// Parse "https://github.com/<owner>/<repo>/pull/<n>" into the fields the flow needs.
|
|
17
|
+
const m = prUrl.match(/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/);
|
|
18
|
+
if (!m) throw new Error(`could not parse a GitHub PR URL from "${prUrl}"`);
|
|
19
|
+
const [, owner, repo, prNumber] = m;
|
|
20
|
+
const prKey = `${owner}/${repo}#${prNumber}`;
|
|
21
|
+
|
|
22
|
+
const client = new WorkflowClient({ baseUrl });
|
|
23
|
+
const { processInstanceKey } = await client.start(convergenceLoop, {
|
|
24
|
+
prKey,
|
|
25
|
+
prUrl,
|
|
26
|
+
repo: `${owner}/${repo}`,
|
|
27
|
+
prNumber: Number(prNumber),
|
|
28
|
+
round: 1,
|
|
29
|
+
maxRounds,
|
|
30
|
+
prompt: "Review this PR. Reply converged | addressed | needs_input | blocked with a summary.",
|
|
31
|
+
});
|
|
32
|
+
console.log(`started ${convergenceLoop.id} instance ${processInstanceKey} (prKey=${prKey}, maxRounds=${maxRounds})`);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"moduleResolution": "nodenext",
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"lib": ["esnext", "dom"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["main.ts", "workflows/**/*.ts", "scripts/**/*.ts"],
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|