@niwa-labs/pstack 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +260 -2
- package/package.json +28 -4
- package/scripts/upstream-map.ts +90 -0
- package/src/author.ts +57 -0
- package/src/binding.ts +32 -0
- package/src/catalog.ts +86 -0
- package/src/composition.ts +66 -0
- package/src/index.ts +50 -0
- package/src/mapping/analyze.ts +223 -0
- package/src/mapping/assemble.ts +96 -0
- package/src/mapping/diff.ts +139 -0
- package/src/mapping/format.ts +67 -0
- package/src/mapping/git.ts +69 -0
- package/src/mapping/index.ts +18 -0
- package/src/mapping/maintain.ts +36 -0
- package/src/mapping/schema.ts +50 -0
- package/src/mapping/sources.ts +108 -0
- package/src/mapping/tool.ts +77 -0
- package/src/mapping/verify.ts +130 -0
- package/src/plugin.ts +136 -0
- package/src/policy.ts +115 -0
- package/src/ports.ts +184 -0
- package/src/pr-binding.ts +88 -0
- package/src/records.ts +61 -0
- package/src/roles.ts +49 -0
- package/src/trunk.ts +59 -0
- package/src/upstream-actions.ts +135 -0
- package/src/upstream-records.ts +71 -0
- package/src/upstream.ts +151 -0
- package/src/workflows/adapted.md +780 -0
- package/src/workflows/authoring-a-skill.ts +52 -0
- package/src/workflows/autonomous-run.ts +56 -0
- package/src/workflows/autopilot-full.ts +90 -0
- package/src/workflows/autopilot-stack.ts +125 -0
- package/src/workflows/babysit.ts +124 -0
- package/src/workflows/benny-reproduce.ts +122 -0
- package/src/workflows/benny-triage.ts +89 -0
- package/src/workflows/bug-fix.ts +54 -0
- package/src/workflows/entry.ts +130 -0
- package/src/workflows/eval.ts +63 -0
- package/src/workflows/feature.ts +54 -0
- package/src/workflows/hillclimb.ts +78 -0
- package/src/workflows/investigation.ts +41 -0
- package/src/workflows/lib/catalog.ts +45 -0
- package/src/workflows/lib/change.ts +70 -0
- package/src/workflows/lib/forensics.ts +37 -0
- package/src/workflows/lib/git.ts +30 -0
- package/src/workflows/lib/go.ts +58 -0
- package/src/workflows/lib/inputs.ts +34 -0
- package/src/workflows/lib/lane.ts +170 -0
- package/src/workflows/lib/measure.ts +34 -0
- package/src/workflows/lib/plan.ts +24 -0
- package/src/workflows/lib/script.ts +79 -0
- package/src/workflows/lib/ship.ts +110 -0
- package/src/workflows/lib/texts.ts +18 -0
- package/src/workflows/lib/trunk.ts +91 -0
- package/src/workflows/multi-phase-plan.ts +83 -0
- package/src/workflows/opening-a-pr.ts +62 -0
- package/src/workflows/pause-safely.ts +50 -0
- package/src/workflows/perf-issue.ts +87 -0
- package/src/workflows/prototype.ts +76 -0
- package/src/workflows/refactoring.ts +54 -0
- package/src/workflows/runtime-forensics.ts +26 -0
- package/src/workflows/scenarios.ts +380 -0
- package/src/workflows/session-pickup.ts +57 -0
- package/src/workflows/shipping.ts +63 -0
- package/src/workflows/suite.ts +129 -0
- package/src/workflows/texts/authoring-a-skill.json +5 -0
- package/src/workflows/texts/autonomous-run.json +5 -0
- package/src/workflows/texts/autopilot-full.json +5 -0
- package/src/workflows/texts/autopilot-stack.json +5 -0
- package/src/workflows/texts/babysit.json +5 -0
- package/src/workflows/texts/benny-reproduce.json +5 -0
- package/src/workflows/texts/benny-triage.json +5 -0
- package/src/workflows/texts/bug-fix.json +5 -0
- package/src/workflows/texts/bugbot-triage.json +5 -0
- package/src/workflows/texts/eval.json +5 -0
- package/src/workflows/texts/feature.json +5 -0
- package/src/workflows/texts/hillclimb.json +5 -0
- package/src/workflows/texts/investigation.json +5 -0
- package/src/workflows/texts/multi-phase-plan.json +5 -0
- package/src/workflows/texts/opening-a-pr.json +5 -0
- package/src/workflows/texts/pause-safely.json +5 -0
- package/src/workflows/texts/perf-issue.json +5 -0
- package/src/workflows/texts/prototype.json +5 -0
- package/src/workflows/texts/refactoring.json +5 -0
- package/src/workflows/texts/runtime-forensics.json +5 -0
- package/src/workflows/texts/session-pickup.json +5 -0
- package/src/workflows/texts/trace-forensics.json +5 -0
- package/src/workflows/texts/visual-parity.json +5 -0
- package/src/workflows/texts/worker.json +5 -0
- package/src/workflows/trace-forensics.ts +27 -0
- package/src/workflows/upstream-sync.ts +182 -0
- package/src/workflows/visual-parity.ts +52 -0
- package/src/workflows/worktree-cleanup.ts +57 -0
- package/test/author.test.ts +61 -0
- package/test/benny.test.ts +138 -0
- package/test/binding.test.ts +54 -0
- package/test/catalog-helpers.test.ts +49 -0
- package/test/closure.test.ts +45 -0
- package/test/composition.test.ts +23 -0
- package/test/eval.test.ts +23 -0
- package/test/lanes.test.ts +334 -0
- package/test/mapping-diff.test.ts +64 -0
- package/test/mapping-support.ts +110 -0
- package/test/mapping-texts.test.ts +106 -0
- package/test/mapping.test.ts +276 -0
- package/test/package-layout.ts +68 -0
- package/test/policy.test.ts +98 -0
- package/test/ports.test.ts +45 -0
- package/test/ports.ts +173 -0
- package/test/roles.test.ts +21 -0
- package/test/suite.test.ts +167 -0
- package/test/support.ts +541 -0
- package/test/texts.test.ts +174 -0
- package/test/tool.test.ts +48 -0
- package/test/trunk-helpers.test.ts +149 -0
- package/test/trunk.test.ts +24 -0
- package/test/upstream-sync.test.ts +246 -0
- package/test/upstream.test.ts +106 -0
- package/test/worktree-cleanup.test.ts +107 -0
- package/tsconfig.json +7 -0
- package/upstream/LICENSE +21 -0
- package/upstream/SOURCE.json +5 -0
- package/upstream/benny/FOR_AGENTS.md +89 -0
- package/upstream/benny/README.md +23 -0
- package/upstream/benny/skills/reproduce-and-fix-issues/SKILL.md +310 -0
- package/upstream/benny/skills/reproduce-and-fix-issues/references/control-adapter.md +169 -0
- package/upstream/benny/skills/reproduce-and-fix-issues/references/feature-map.example.md +205 -0
- package/upstream/benny/skills/reproduce-and-fix-issues/references/verify-existing-fix.md +93 -0
- package/upstream/benny/skills/setup-benny/SKILL.md +265 -0
- package/upstream/benny/skills/triage-issue-reports/SKILL.md +240 -0
- package/upstream/benny/skills/triage-issue-reports/references/routing.example.md +61 -0
- package/upstream/benny/templates/configuration.example.yaml +84 -0
- package/upstream/benny/templates/reproduce-automation-prompt.md +33 -0
- package/upstream/benny/templates/triage-automation-prompt.md +39 -0
- package/upstream/mapping.json +699 -0
- package/upstream/poteto-mode/SKILL.md +110 -0
- package/upstream/poteto-mode/playbooks/authoring-a-skill.md +12 -0
- package/upstream/poteto-mode/playbooks/autonomous-run.md +13 -0
- package/upstream/poteto-mode/playbooks/autopilot-full.md +25 -0
- package/upstream/poteto-mode/playbooks/autopilot-stack.md +8 -0
- package/upstream/poteto-mode/playbooks/babysit.md +10 -0
- package/upstream/poteto-mode/playbooks/bug-fix.md +15 -0
- package/upstream/poteto-mode/playbooks/eval.md +25 -0
- package/upstream/poteto-mode/playbooks/feature.md +21 -0
- package/upstream/poteto-mode/playbooks/hillclimb.md +21 -0
- package/upstream/poteto-mode/playbooks/investigation.md +14 -0
- package/upstream/poteto-mode/playbooks/multi-phase-plan.md +11 -0
- package/upstream/poteto-mode/playbooks/opening-a-pr.md +9 -0
- package/upstream/poteto-mode/playbooks/pause-safely.md +10 -0
- package/upstream/poteto-mode/playbooks/perf-issue.md +25 -0
- package/upstream/poteto-mode/playbooks/prototype.md +14 -0
- package/upstream/poteto-mode/playbooks/refactoring.md +16 -0
- package/upstream/poteto-mode/playbooks/runtime-forensics.md +11 -0
- package/upstream/poteto-mode/playbooks/session-pickup.md +11 -0
- package/upstream/poteto-mode/playbooks/shipping.md +12 -0
- package/upstream/poteto-mode/playbooks/trace-forensics.md +14 -0
- package/upstream/poteto-mode/playbooks/visual-parity.md +11 -0
- package/upstream/poteto-mode/playbooks/worktree-cleanup.md +12 -0
- package/upstream/poteto-mode/references/bugbot-triage.md +142 -0
- package/upstream/poteto-mode/worker.md +11 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// The snapshot of the upstream playbooks: a refresh takes a commit of a checkout through git and replaces the
|
|
2
|
+
// snapshot whole, and keeps the mapping that belongs to it.
|
|
3
|
+
|
|
4
|
+
import { expect, test } from "bun:test";
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { tempDir } from "@niwa-labs/testing";
|
|
9
|
+
|
|
10
|
+
import { checkoutPathOf, playbookNames, refreshUpstream, snapshotPathOf } from "../src/upstream.ts";
|
|
11
|
+
import { commitFiles, git } from "./mapping-support.ts";
|
|
12
|
+
|
|
13
|
+
/** An upstream checkout with two playbooks, a reference and a Benny skill, committed. */
|
|
14
|
+
async function checkout(): Promise<string> {
|
|
15
|
+
const dir = await tempDir("upstream");
|
|
16
|
+
git(dir, "init", "-q", "-b", "main");
|
|
17
|
+
commitFiles(
|
|
18
|
+
dir,
|
|
19
|
+
{
|
|
20
|
+
LICENSE: "MIT License\n",
|
|
21
|
+
"skills/poteto-mode/SKILL.md": "# Mode\n",
|
|
22
|
+
"skills/poteto-mode/worker.md": "Work for the operator.\n",
|
|
23
|
+
"skills/poteto-mode/playbooks/bug-fix.md": "### Bug fix\n\nReproduce it.\n",
|
|
24
|
+
"skills/poteto-mode/playbooks/shipping.md": "### Shipping\n\nLand it.\n",
|
|
25
|
+
"skills/poteto-mode/references/triage.md": "Judge each claim.\n",
|
|
26
|
+
"skills/poteto-mode/assets/logo.txt": "not kept\n",
|
|
27
|
+
"automations/benny/skills/triage-issue-reports/SKILL.md": "# Triage\n",
|
|
28
|
+
"README.md": "not part of the snapshot\n",
|
|
29
|
+
},
|
|
30
|
+
"start",
|
|
31
|
+
);
|
|
32
|
+
return dir;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
test("a refresh copies the snapshot with its commit", async () => {
|
|
36
|
+
const from = await checkout();
|
|
37
|
+
const into = join(await tempDir("snapshot"), "upstream");
|
|
38
|
+
const source = refreshUpstream(from, { upstream: into });
|
|
39
|
+
|
|
40
|
+
expect(source.commit).toBe(git(from, "rev-parse", "HEAD"));
|
|
41
|
+
expect(JSON.parse(readFileSync(join(into, "SOURCE.json"), "utf8"))).toEqual(source);
|
|
42
|
+
expect(readFileSync(join(into, "LICENSE"), "utf8")).toBe("MIT License\n");
|
|
43
|
+
expect(readFileSync(join(into, "poteto-mode", "references", "triage.md"), "utf8")).toBe("Judge each claim.\n");
|
|
44
|
+
expect(existsSync(join(into, "benny", "skills", "triage-issue-reports", "SKILL.md"))).toBe(true);
|
|
45
|
+
expect(existsSync(join(into, "poteto-mode", "assets"))).toBe(false);
|
|
46
|
+
expect(existsSync(join(into, "README.md"))).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("a playbook removed upstream leaves the snapshot with the next refresh", async () => {
|
|
50
|
+
const from = await checkout();
|
|
51
|
+
const into = join(await tempDir("snapshot"), "upstream");
|
|
52
|
+
refreshUpstream(from, { upstream: into });
|
|
53
|
+
commitFiles(from, { "skills/poteto-mode/playbooks/shipping.md": null }, "drop shipping");
|
|
54
|
+
refreshUpstream(from, { upstream: into });
|
|
55
|
+
expect(playbookNames(into)).toEqual(["bug-fix"]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("a refresh reads the commit it is asked for, not the working tree, and leaves the checkout alone", async () => {
|
|
59
|
+
const from = await checkout();
|
|
60
|
+
const first = git(from, "rev-parse", "HEAD");
|
|
61
|
+
commitFiles(from, { "skills/poteto-mode/playbooks/bug-fix.md": "### Bug fix\n\nChanged.\n" }, "later");
|
|
62
|
+
writeFileSync(join(from, "skills", "poteto-mode", "worker.md"), "edited, not committed\n");
|
|
63
|
+
const into = join(await tempDir("snapshot"), "upstream");
|
|
64
|
+
const source = refreshUpstream(from, { upstream: into, commit: first });
|
|
65
|
+
|
|
66
|
+
expect(source.commit).toBe(first);
|
|
67
|
+
expect(readFileSync(join(into, "poteto-mode", "playbooks", "bug-fix.md"), "utf8")).toBe("### Bug fix\n\nReproduce it.\n");
|
|
68
|
+
expect(readFileSync(join(into, "poteto-mode", "worker.md"), "utf8")).toBe("Work for the operator.\n");
|
|
69
|
+
expect(git(from, "status", "--short")).toBe("M skills/poteto-mode/worker.md");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("a refresh keeps the mapping of the snapshot", async () => {
|
|
73
|
+
const from = await checkout();
|
|
74
|
+
const into = join(await tempDir("snapshot"), "upstream");
|
|
75
|
+
refreshUpstream(from, { upstream: into });
|
|
76
|
+
writeFileSync(join(into, "mapping.json"), '{"entries":[]}\n');
|
|
77
|
+
refreshUpstream(from, { upstream: into });
|
|
78
|
+
expect(readFileSync(join(into, "mapping.json"), "utf8")).toBe('{"entries":[]}\n');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("a folder that is not an upstream checkout is refused before anything is replaced", async () => {
|
|
82
|
+
const into = await tempDir("snapshot");
|
|
83
|
+
mkdirSync(join(into, "upstream"));
|
|
84
|
+
writeFileSync(join(into, "upstream", "kept.txt"), "x");
|
|
85
|
+
const notGit = await tempDir("plain");
|
|
86
|
+
expect(() => refreshUpstream(notGit, { upstream: join(into, "upstream") })).toThrow("not a git checkout");
|
|
87
|
+
const empty = await tempDir("empty");
|
|
88
|
+
git(empty, "init", "-q", "-b", "main");
|
|
89
|
+
commitFiles(empty, { "README.md": "x\n" });
|
|
90
|
+
expect(() => refreshUpstream(empty, { upstream: join(into, "upstream") })).toThrow("is not an upstream pstack checkout");
|
|
91
|
+
expect(existsSync(join(into, "upstream", "kept.txt"))).toBe(true);
|
|
92
|
+
rmSync(join(into, "upstream"), { recursive: true });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("a snapshot path and the path it comes from in a checkout name each other", () => {
|
|
96
|
+
expect(checkoutPathOf("poteto-mode/playbooks/bug-fix.md")).toBe("skills/poteto-mode/playbooks/bug-fix.md");
|
|
97
|
+
expect(checkoutPathOf("benny/README.md")).toBe("automations/benny/README.md");
|
|
98
|
+
expect(checkoutPathOf("LICENSE")).toBe("LICENSE");
|
|
99
|
+
expect(snapshotPathOf("skills/poteto-mode/references/x.md")).toBe("poteto-mode/references/x.md");
|
|
100
|
+
expect(snapshotPathOf("skills/poteto-mode/assets/logo.png")).toBeUndefined();
|
|
101
|
+
expect(snapshotPathOf("README.md")).toBeUndefined();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("the package carries the 22 upstream playbooks", () => {
|
|
105
|
+
expect(playbookNames()).toHaveLength(22);
|
|
106
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { existsSync, mkdirSync, realpathSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
import { action, actionName, record } from "@niwa-labs/core";
|
|
7
|
+
import { PrMerged } from "@niwa-labs/forge/records";
|
|
8
|
+
import { BUILTIN_WORKFLOW, SCRIPT_PACKAGE, plugin } from "@niwa-labs/plugin";
|
|
9
|
+
import { createNiwa, eventually, git, tempHome, workflow } from "@niwa-labs/testing";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
|
|
12
|
+
import { commitFile, gitIn } from "./support.ts";
|
|
13
|
+
|
|
14
|
+
const project = { host: "example.invalid", path: "team/repo" };
|
|
15
|
+
const forgeRoot = realpathSync(join(dirname(fileURLToPath(import.meta.resolve("@niwa-labs/forge/records"))), ".."));
|
|
16
|
+
const source = fileURLToPath(new URL("../src/workflows/worktree-cleanup.ts", import.meta.url));
|
|
17
|
+
|
|
18
|
+
const Worktree = z.object({ id: z.string(), path: z.string(), repo: z.string(), branch: z.string(), baseSha: z.string() });
|
|
19
|
+
const BindingQuery = z.object({ repo: z.object({ host: z.string(), path: z.string() }), number: z.number(), head: z.string(), before: z.number().optional() });
|
|
20
|
+
const Binding = record("fixture.binding", BindingQuery.omit({ before: true }).extend({ worktree: Worktree }));
|
|
21
|
+
|
|
22
|
+
test("an observed merge removes only its bound unchanged checkout", async () => {
|
|
23
|
+
const temp = await tempHome();
|
|
24
|
+
const home = join(temp.path, "home");
|
|
25
|
+
const repo = join(realpathSync(temp.path), "repo");
|
|
26
|
+
const host = createNiwa({ home });
|
|
27
|
+
const lookup: Array<z.infer<typeof BindingQuery>> = [];
|
|
28
|
+
try {
|
|
29
|
+
symlinkSync(realpathSync(join(import.meta.dir, "..", "node_modules")), join(temp.path, "node_modules"), "dir");
|
|
30
|
+
mkdirSync(repo);
|
|
31
|
+
gitIn(repo, "init", "-q", "-b", "main");
|
|
32
|
+
commitFile(repo, "README.md", "test\n");
|
|
33
|
+
gitIn(repo, "remote", "add", "origin", `https://${project.host}/${project.path}.git`);
|
|
34
|
+
host.use(git({ cleanup: false }), plugin("cleanup-fixture", (api) => {
|
|
35
|
+
api.declare(PrMerged, Binding);
|
|
36
|
+
api.offer(SCRIPT_PACKAGE, { name: "@niwa-labs/forge", root: forgeRoot });
|
|
37
|
+
api.offer(BUILTIN_WORKFLOW, { name: "cleanup", description: "Clean the checkout for a merge", file: source, triggers: [PrMerged] });
|
|
38
|
+
api.action(action("pstack.pr.binding", {
|
|
39
|
+
description: "Find the fixture checkout bound to a merge.",
|
|
40
|
+
input: BindingQuery,
|
|
41
|
+
output: z.object({ binding: Binding.schema.optional() }),
|
|
42
|
+
recovery: "repeat",
|
|
43
|
+
effect: "read",
|
|
44
|
+
world: "niwa",
|
|
45
|
+
run(query) {
|
|
46
|
+
lookup.push(query);
|
|
47
|
+
const rows = api.journal?.()?.find({ type: Binding.name, field: "number", equals: query.number }) ?? [];
|
|
48
|
+
const match = rows.find((row) => {
|
|
49
|
+
const data = Binding.schema.parse(row.data);
|
|
50
|
+
return row.seq < (query.before ?? Infinity) && data.head === query.head && data.repo.host === query.repo.host && data.repo.path === query.repo.path;
|
|
51
|
+
});
|
|
52
|
+
return { binding: match === undefined ? undefined : Binding.schema.parse(match.data) };
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
}), workflow());
|
|
56
|
+
await host.serve();
|
|
57
|
+
|
|
58
|
+
let workflowId: string | undefined;
|
|
59
|
+
await eventually(async () => {
|
|
60
|
+
const response = await host.call(actionName("workflow.installation.list"), {}) as { items: Array<{ workflow: string }> };
|
|
61
|
+
workflowId = response.items[0]?.workflow;
|
|
62
|
+
return workflowId !== undefined;
|
|
63
|
+
}, 8_000, "cleanup should install on the merge event");
|
|
64
|
+
const make = async (description: string, local = repo) => Worktree.parse(await host.call(actionName("git.worktree.create"), { repo: local, description }));
|
|
65
|
+
const target = await make("selected checkout");
|
|
66
|
+
const twin = await make("different checkout with the same HEAD");
|
|
67
|
+
const clone = join(realpathSync(temp.path), "clone");
|
|
68
|
+
gitIn(repo, "clone", "-q", repo, clone);
|
|
69
|
+
const otherRepo = await make("different repository with the same HEAD", clone);
|
|
70
|
+
expect([twin.baseSha, otherRepo.baseSha]).toEqual([target.baseSha, target.baseSha]);
|
|
71
|
+
const binding = await host.emit(Binding, { repo: project, number: 4, head: target.baseSha, worktree: target });
|
|
72
|
+
const merged = { pr: { repo: { ...project, projectId: 42 }, number: 4 }, base: "main", head: target.baseSha, source: { kind: "observed" as const, version: 1 } };
|
|
73
|
+
const manual = await host.call(actionName("workflow.start"), {
|
|
74
|
+
id: workflowId, args: { id: "fabricated", type: PrMerged.name, data: merged }, wait: true, timeoutMs: 8_000,
|
|
75
|
+
}) as { outcome?: unknown };
|
|
76
|
+
expect(manual.outcome).toMatchObject({ status: "done", result: { removed: [], kept: [] } });
|
|
77
|
+
expect(lookup).toEqual([]);
|
|
78
|
+
expect(existsSync(target.path)).toBe(true);
|
|
79
|
+
|
|
80
|
+
const recorded = await host.emit(PrMerged, merged);
|
|
81
|
+
expect(recorded.seq).toBeGreaterThan(binding.seq);
|
|
82
|
+
await eventually(async () => (await host.records.read()).some((row) =>
|
|
83
|
+
row.type === "workflow.run.finished" && JSON.stringify(row.data).includes(`"removed":["${target.id}"]`)), 8_000, "the observed merge should remove the selected checkout");
|
|
84
|
+
expect(lookup).toEqual([{ repo: project, number: 4, head: target.baseSha, before: recorded.seq }]);
|
|
85
|
+
expect(existsSync(target.path)).toBe(false);
|
|
86
|
+
expect(existsSync(twin.path)).toBe(true);
|
|
87
|
+
expect(existsSync(otherRepo.path)).toBe(true);
|
|
88
|
+
expect(gitIn(repo, "rev-parse", target.branch)).toBe(target.baseSha);
|
|
89
|
+
const removes = (await host.records.read()).filter((row) => row.type === "git.worktree.removed");
|
|
90
|
+
expect(removes.map((row) => row.data)).toEqual([{ id: target.id, forced: false, branchKept: true }]);
|
|
91
|
+
|
|
92
|
+
const unbound = await host.emit(PrMerged, { ...merged, pr: { ...merged.pr, number: 5 } });
|
|
93
|
+
await eventually(() => lookup.some((query) => query.before === unbound.seq), 8_000, "the unbound merge should query its own receipt");
|
|
94
|
+
expect(existsSync(twin.path)).toBe(true);
|
|
95
|
+
|
|
96
|
+
await host.emit(Binding, { repo: project, number: 6, head: twin.baseSha, worktree: twin });
|
|
97
|
+
writeFileSync(join(twin.path, "uncommitted.txt"), "keep this\n");
|
|
98
|
+
await host.emit(PrMerged, { ...merged, pr: { ...merged.pr, number: 6 } });
|
|
99
|
+
await eventually(async () => (await host.records.read()).some((row) =>
|
|
100
|
+
row.type === "workflow.run.finished" && JSON.stringify(row.data).includes(`"kept":[{"id":"${twin.id}"`)), 8_000, "the modified checkout should be reported as kept");
|
|
101
|
+
expect(existsSync(join(twin.path, "uncommitted.txt"))).toBe(true);
|
|
102
|
+
expect((await host.records.read()).filter((row) => row.type === "git.worktree.removed")).toHaveLength(1);
|
|
103
|
+
} finally {
|
|
104
|
+
await host.close();
|
|
105
|
+
await temp.cleanup();
|
|
106
|
+
}
|
|
107
|
+
}, 30_000);
|
package/tsconfig.json
ADDED
package/upstream/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lauren Tan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# benny automation intent
|
|
2
|
+
|
|
3
|
+
## what i want to automate
|
|
4
|
+
|
|
5
|
+
i want two cursor automations that work together in one slack issue channel.
|
|
6
|
+
|
|
7
|
+
### automation 1: triage issue reports
|
|
8
|
+
|
|
9
|
+
- trigger: when someone posts a new top-level report in my configured source slack channel, i want this automation to start on that report and keep its original thread coordinates.
|
|
10
|
+
- behavior: i want it to read the thread and attachments, classify the report as a bug or performance issue, feature request, question or feedback, or reroute, and trace the likely owning layer before routing.
|
|
11
|
+
- tracker: i want it to search my configured tracker for duplicates, update a confident duplicate, and create a ticket only for a clear net-new bug.
|
|
12
|
+
- tools: i want slack thread read and reply access, my configured tracker integration, and my optional routing map.
|
|
13
|
+
- outcome: i want exactly one reply in the source thread with a short verdict and `[benny:bug]`, `[benny:performance]`, or `[benny:other]`. a bug or performance marker may include the tracker url.
|
|
14
|
+
- boundary: i never want this automation to post a root message in the source channel.
|
|
15
|
+
|
|
16
|
+
### automation 2: reproduce and fix confirmed bugs
|
|
17
|
+
|
|
18
|
+
- trigger: i want this automation to start from the same new top-level report, or another supported trigger chosen during setup, then wait for the trusted triage marker in the original thread.
|
|
19
|
+
- gates: i want it to stop when someone clearly owns the fix. if an existing pull request or merged commit may fix the report, i want verification instead of a competing change.
|
|
20
|
+
- behavior: i want it to use my configured control adapter and feature map, reproduce the exact symptom twice through the real ui, and capture screenshots, video, and a read-only state cross-check.
|
|
21
|
+
- fix: i want it to verify existing pull requests without authoring over them. after a confirmed repro, it may attempt one bounded root-cause fix, use tdd when the test is cheap, smoke the blast radius, and open a draft pull request only when before-and-after proof passes.
|
|
22
|
+
- tools: i want slack thread read and reply access, repository and history access, draft pull request creation, my configured tracker, and my control adapter.
|
|
23
|
+
- outcome: i want evidence and a verified result in the source or optional operations threads, plus an optional draft pull request. updates should be concise.
|
|
24
|
+
- boundary: i never want this automation to post a root message in the source channel.
|
|
25
|
+
|
|
26
|
+
### shared rules
|
|
27
|
+
|
|
28
|
+
- i want the source channel and root thread coordinates to stay immutable for the whole run.
|
|
29
|
+
- i treat utility and debug bots as evidence, not delegation or fix ownership.
|
|
30
|
+
- i allow subagents to help, but they cannot post to slack or receive slack credentials.
|
|
31
|
+
- i want this entire pack committed at `.cursor/automations/benny/` in the target repository. its `SKILL.md` files are direct automation instructions, not registered plugin skills.
|
|
32
|
+
- i want pstack enabled through the target repository's committed `.cursor/settings.json` only for shared dependencies such as `why`, `tdd`, `unslop`, and the required principle skills.
|
|
33
|
+
- i want each live automation prompt to read its committed operational file directly. i do not want plugin cache paths, copied excerpts, or slash-skill discovery.
|
|
34
|
+
- i keep user-owned configuration, feature maps, routing maps, and secrets outside `.cursor/automations/benny/` so pack refreshes cannot overwrite them.
|
|
35
|
+
- i want both automations to fail closed when channel coordinates, tracker access, the control adapter, or the feature map are missing or uncertain.
|
|
36
|
+
- i want draft pull requests only. do not merge or deploy.
|
|
37
|
+
|
|
38
|
+
### my configuration
|
|
39
|
+
|
|
40
|
+
- source slack channel: `<channel>`
|
|
41
|
+
- optional operations channel: `<channel or none>`
|
|
42
|
+
- repository and default branch: `<repo>`, `<branch>`
|
|
43
|
+
- tracker: `<type, team, project, labels, intake status>`
|
|
44
|
+
- routing map: `<path or none>`
|
|
45
|
+
- triage identity: `<slack identity>`
|
|
46
|
+
- control skill: `<configured skill or adapter>`
|
|
47
|
+
- feature map: `<committed same-repo path outside the copied pack, or behavior to paraphrase>`
|
|
48
|
+
- models: `<triage, reproduce, code, media review>`
|
|
49
|
+
- status emoji strings: `<seen, reproducing, reproduced, blocked, fixing, failed, pull request opened>`
|
|
50
|
+
- budgets: `<polling, verdict wait, follow-up, repro, rejection, fix>`
|
|
51
|
+
- optional bot token capability: `<none, file download, or editable operations status>`
|
|
52
|
+
|
|
53
|
+
start from [`configuration.example.yaml`](./templates/configuration.example.yaml) and [`feature-map.example.md`](./skills/reproduce-and-fix-issues/references/feature-map.example.md). copy and fill them outside this pack, for example under `.cursor/benny/`. keep secret values in a secret manager or environment.
|
|
54
|
+
|
|
55
|
+
## for the agent
|
|
56
|
+
|
|
57
|
+
the human enters setup by pointing cursor at this file. do not look for or invoke a discovered benny slash skill.
|
|
58
|
+
|
|
59
|
+
1. ask which repository will run the automations.
|
|
60
|
+
2. treat the directory containing this `FOR_AGENTS.md` as the source pack.
|
|
61
|
+
3. merge the entire source pack into `<target-repository>/.cursor/automations/benny/`.
|
|
62
|
+
4. preserve every destination-only file. never delete unrelated files or overwrite user-owned configuration, feature maps, or routing maps.
|
|
63
|
+
5. when an existing destination file at a source-managed path differs, review the diff and merge without discarding local edits. if ownership is ambiguous, stop and ask before replacing it.
|
|
64
|
+
6. verify that the copied `FOR_AGENTS.md` and `skills/setup-benny/SKILL.md` exist in the target repository.
|
|
65
|
+
7. read and follow `.cursor/automations/benny/skills/setup-benny/SKILL.md` directly from the target repository.
|
|
66
|
+
|
|
67
|
+
i want you to merge this entry into the target repository's `.cursor/settings.json`:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"plugins": {
|
|
72
|
+
"pstack": { "enabled": true }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
preserve every unrelated setting and plugin. preserve comments and valid jsonc syntax when the existing file uses jsonc.
|
|
78
|
+
|
|
79
|
+
i want verification from a fresh agent rooted in the target repository. confirm that pstack's `why`, `tdd`, `unslop`, and the principle skills used by benny resolve in project scope. do not count skills loaded from the current session or a user-scoped install.
|
|
80
|
+
|
|
81
|
+
if project-scoped plugins are unavailable or any shared dependency does not resolve, stop and explain what failed. do not add `.cursor/automations/benny/skills/` to a plugin manifest or expect its files to appear in the slash-skill list.
|
|
82
|
+
|
|
83
|
+
tell me that `.cursor/settings.json`, `.cursor/automations/benny/`, and any referenced secret-free configuration must be committed before either automation is enabled. do not create or update an automation until i explicitly ask.
|
|
84
|
+
|
|
85
|
+
for first-time creation, use built-in `/automate` once for triage and once for repro and fix. complete the draft review, approval, readiness check, and Automations editor handoff for the first automation before starting the second.
|
|
86
|
+
|
|
87
|
+
paraphrase this intent and the finished configuration into each draft. the triage prompt must read and follow `.cursor/automations/benny/skills/triage-issue-reports/SKILL.md`. the repro prompt must read and follow `.cursor/automations/benny/skills/reproduce-and-fix-issues/SKILL.md`. use these repo-relative paths only after `/automate` confirms they are committed in the repository where the automation will run.
|
|
88
|
+
|
|
89
|
+
for existing automations, do not use `/automate` to inspect or update them. validate the configuration, then use the concise field checklist in the copied setup file so i can edit each automation directly in its editor. do not create duplicates.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# benny
|
|
2
|
+
|
|
3
|
+
benny gives you two cursor automations for slack issue reports. one triages each report. the other reproduces confirmed bugs and may prepare a small draft fix.
|
|
4
|
+
|
|
5
|
+
the files in this directory are dormant setup and automation sources. they do not appear as slash skills.
|
|
6
|
+
|
|
7
|
+
## set it up
|
|
8
|
+
|
|
9
|
+
1. point cursor at [`FOR_AGENTS.md`](./FOR_AGENTS.md) and name the target repository.
|
|
10
|
+
2. let setup merge this whole directory into the target at `.cursor/automations/benny/`. it must preserve destination-only files and review conflicts instead of overwriting local edits.
|
|
11
|
+
3. let setup enable pstack in the target repository's `.cursor/settings.json` for shared dependencies:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"plugins": {
|
|
16
|
+
"pstack": { "enabled": true }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
4. keep user-owned configuration outside the copied pack, for example in `.cursor/benny/`. adapt [`configuration.example.yaml`](./templates/configuration.example.yaml) and [`feature-map.example.md`](./skills/reproduce-and-fix-issues/references/feature-map.example.md).
|
|
22
|
+
5. commit `.cursor/settings.json`, `.cursor/automations/benny/`, and any secret-free configuration before enabling either automation.
|
|
23
|
+
6. review each new automation draft or update existing automations in their editors. then send a harmless test report and verify every source-channel post stays in the original thread.
|