@amykit/plugin-plan-check 0.2.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 ADDED
@@ -0,0 +1,52 @@
1
+ <!-- Generated by `npm run docs:generate` from the package itself. Do not edit by hand. -->
2
+
3
+ # @amykit/plugin-plan-check
4
+
5
+ The quality bar for a drafted plan: the repository's own check, run in its checkout.
6
+
7
+ A plugin for [amy](https://github.com/nicolasmelo1/amy). It provides the `plan-check` port.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install -g @amykit/plugin-plan-check
13
+ ```
14
+
15
+ Then name it in `~/.amy/config.yaml`:
16
+
17
+ ```yaml
18
+ workflows:
19
+ your-profile:
20
+ plugins:
21
+ - "@amykit/plugin-plan-check"
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ ```yaml
27
+ plugins:
28
+ "@amykit/plugin-plan-check":
29
+ commands: {"default":["sf check"]}
30
+ defaultBranch: "main"
31
+ timeoutMs: 600000
32
+ ```
33
+
34
+ | Setting | Type | Required | Default | What it is |
35
+ | :-- | :-- | :-- | :-- | :-- |
36
+ | `commands` | `record` | no | `{"default":["sf check"]}` | the check commands per repository, with a `default` fallback. `sf check` is the whole quality bar in a repository that has one |
37
+ | `defaultBranch` | `string` | no | `main` | the branch a plan branch is cut from, which is not always `main` |
38
+ | `timeoutMs` | `number` | no | `600000` | how long one check may run before it is given up on |
39
+
40
+ Every field is checked at boot against the schema this package declares. A key that is
41
+ not one of the above is a refusal naming the plugin and the key, not a setting that
42
+ silently never applied.
43
+
44
+ ## Where the reasoning is
45
+
46
+ - [Writing a plugin](https://github.com/nicolasmelo1/amy/tree/main/docs/build/write-a-plugin.md)
47
+ - [Reference: plugins](https://github.com/nicolasmelo1/amy/tree/main/docs/reference/plugins.md)
48
+ - [Ports and the registry](https://github.com/nicolasmelo1/amy/tree/main/docs/concepts/ports.md)
49
+
50
+ ## Licence
51
+
52
+ MIT
@@ -0,0 +1,33 @@
1
+ import { CommandRunner, Git } from "@amykit/core";
2
+ import { AttemptOutcome, PlanCheck } from "@amykit/workflow-note-to-plan";
3
+ export interface PlanCommandCheckConfig {
4
+ /**
5
+ * The checks to run, per repository, falling back to the `default` entry.
6
+ * Written as shell command lines, because that is how a repository's own
7
+ * contributor docs write them.
8
+ */
9
+ commands: Readonly<Record<string, readonly string[]>>;
10
+ timeoutMs?: number;
11
+ }
12
+ /**
13
+ * The quality bar for a drafted plan: the repository's own check, run in its
14
+ * checkout.
15
+ *
16
+ * Nobody had to invent a rubric here. The repository being written into
17
+ * already has one — a plan with no exit condition, or one missing from the
18
+ * ordered list, is refused by it — and it is the same one a human contributor
19
+ * meets. What comes back is kept verbatim, because it becomes the finding the
20
+ * agent is sent back with.
21
+ *
22
+ * It stops at the first failure rather than collecting all of them, so the
23
+ * agent gets one clear thing to fix instead of a wall of noise where the
24
+ * second half is caused by the first.
25
+ */
26
+ export declare class PlanCommandCheck implements PlanCheck {
27
+ private readonly runner;
28
+ private readonly git;
29
+ private readonly config;
30
+ constructor(runner: CommandRunner, git: Git, config: PlanCommandCheckConfig);
31
+ check(repo: string): Promise<AttemptOutcome>;
32
+ }
33
+ //# sourceMappingURL=PlanCommandCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanCommandCheck.d.ts","sourceRoot":"","sources":["../src/PlanCommandCheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAE9C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,sBAAsB;IAG3C,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CA+BnD"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The quality bar for a drafted plan: the repository's own check, run in its
3
+ * checkout.
4
+ *
5
+ * Nobody had to invent a rubric here. The repository being written into
6
+ * already has one — a plan with no exit condition, or one missing from the
7
+ * ordered list, is refused by it — and it is the same one a human contributor
8
+ * meets. What comes back is kept verbatim, because it becomes the finding the
9
+ * agent is sent back with.
10
+ *
11
+ * It stops at the first failure rather than collecting all of them, so the
12
+ * agent gets one clear thing to fix instead of a wall of noise where the
13
+ * second half is caused by the first.
14
+ */
15
+ export class PlanCommandCheck {
16
+ runner;
17
+ git;
18
+ config;
19
+ constructor(runner, git, config) {
20
+ this.runner = runner;
21
+ this.git = git;
22
+ this.config = config;
23
+ }
24
+ async check(repo) {
25
+ const commands = this.config.commands[repo] ?? this.config.commands.default ?? [];
26
+ if (commands.length === 0) {
27
+ return {
28
+ ok: false,
29
+ output: `no check is configured for ${repo}, so nothing can vouch for this plan`,
30
+ at: new Date().toISOString(),
31
+ };
32
+ }
33
+ const transcript = [];
34
+ for (const command of commands) {
35
+ const result = await this.runner.run("sh", ["-c", command], {
36
+ cwd: this.git.pathFor(repo),
37
+ timeoutMs: this.config.timeoutMs,
38
+ });
39
+ const output = [result.stdout, result.stderr].filter(Boolean).join("\n").trim();
40
+ if (!result.ok) {
41
+ transcript.push(`$ ${command}\nexited ${result.exitCode}\n\n${output}`);
42
+ return { ok: false, output: transcript.join("\n\n"), at: new Date().toISOString() };
43
+ }
44
+ transcript.push(`$ ${command}\nok`);
45
+ }
46
+ return { ok: true, output: transcript.join("\n"), at: new Date().toISOString() };
47
+ }
48
+ }
49
+ //# sourceMappingURL=PlanCommandCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanCommandCheck.js","sourceRoot":"","sources":["../src/PlanCommandCheck.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,gBAAgB;IAER;IACA;IACA;IAHnB,YACmB,MAAqB,EACrB,GAAQ,EACR,MAA8B;QAF9B,WAAM,GAAN,MAAM,CAAe;QACrB,QAAG,GAAH,GAAG,CAAK;QACR,WAAM,GAAN,MAAM,CAAwB;IAC9C,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,IAAY;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;QAElF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,MAAM,EAAE,8BAA8B,IAAI,sCAAsC;gBAChF,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aAC7B,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAa,EAAE,CAAC;QAEhC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;gBAC1D,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;gBAC3B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;aACjC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAEhF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,OAAO,YAAY,MAAM,CAAC,QAAQ,OAAO,MAAM,EAAE,CAAC,CAAC;gBACxE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;YACtF,CAAC;YAED,UAAU,CAAC,IAAI,CAAC,KAAK,OAAO,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;IACnF,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { ConfigSchema } from "@amykit/core";
2
+ /** What this plugin needs told to it, and nothing more. */
3
+ export declare const configSchema: ConfigSchema;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,2DAA2D;AAC3D,eAAO,MAAM,YAAY,EAAE,YAiB1B,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,19 @@
1
+ /** What this plugin needs told to it, and nothing more. */
2
+ export const configSchema = {
3
+ defaultBranch: {
4
+ type: "string",
5
+ description: "the branch a plan branch is cut from, which is not always `main`",
6
+ default: "main",
7
+ },
8
+ commands: {
9
+ type: "record",
10
+ description: "the check commands per repository, with a `default` fallback. `sf check` is the whole quality bar in a repository that has one",
11
+ default: { default: ["sf check"] },
12
+ },
13
+ timeoutMs: {
14
+ type: "number",
15
+ description: "how long one check may run before it is given up on",
16
+ default: 10 * 60 * 1000,
17
+ },
18
+ };
19
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,2DAA2D;AAC3D,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,aAAa,EAAE;QACb,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,kEAAkE;QAC/E,OAAO,EAAE,MAAM;KAChB;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,gIAAgI;QAClI,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE;KACnC;IACD,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,qDAAqD;QAClE,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;KACxB;CACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { PlanCommandCheck } from "./PlanCommandCheck.js";
2
+ export type { PlanCommandCheckConfig } from "./PlanCommandCheck.js";
3
+ export { configSchema } from "./config.js";
4
+ export { plugin } from "./plugin.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { PlanCommandCheck } from "./PlanCommandCheck.js";
2
+ export { configSchema } from "./config.js";
3
+ export { plugin } from "./plugin.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "@amykit/core";
2
+ export declare const plugin: Plugin;
3
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,eAAO,MAAM,MAAM,EAAE,MAwBpB,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,24 @@
1
+ import { Git } from "@amykit/core";
2
+ import { PlanCommandCheck } from "./PlanCommandCheck.js";
3
+ import { configSchema } from "./config.js";
4
+ export const plugin = {
5
+ name: "@amykit/plugin-plan-check",
6
+ version: "0.1.0",
7
+ configSchema,
8
+ register(registry, ctx) {
9
+ const git = new Git(ctx.runner, {
10
+ workspaceRoot: ctx.paths.workspace,
11
+ defaultBranch: ctx.config.defaultBranch,
12
+ });
13
+ // The action and the port together, which is what the registry asks of a
14
+ // plugin adding an action the core does not ship: an action nobody can
15
+ // execute is a promise the machine cannot keep. `check-plan` is not in
16
+ // the core catalogue because nothing has yet shown it is general — a
17
+ // second workflow needing it is what would move it there.
18
+ registry.action("check-plan", { port: "plan-check", method: "check" }, new PlanCommandCheck(ctx.runner, git, {
19
+ commands: ctx.config.commands,
20
+ timeoutMs: ctx.config.timeoutMs,
21
+ }));
22
+ },
23
+ };
24
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE,OAAO;IAChB,YAAY;IACZ,QAAQ,CAAC,QAAQ,EAAE,GAAG;QACpB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE;YAC9B,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS;YAClC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,aAAuB;SAClD,CAAC,CAAC;QAEH,yEAAyE;QACzE,uEAAuE;QACvE,uEAAuE;QACvE,qEAAqE;QACrE,0DAA0D;QAC1D,QAAQ,CAAC,MAAM,CACb,YAAY,EACZ,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,EACvC,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE;YACpC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,QAAoC;YACzD,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,SAAmB;SAC1C,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@amykit/plugin-plan-check",
3
+ "version": "0.2.0",
4
+ "description": "The quality bar for a drafted plan: the repository's own check, run in its checkout.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Nicolas Melo",
8
+ "homepage": "https://github.com/nicolasmelo1/amy#readme",
9
+ "bugs": "https://github.com/nicolasmelo1/amy/issues",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/nicolasmelo1/amy.git",
13
+ "directory": "plugins/plan-check"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org"
18
+ },
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "dependencies": {
31
+ "@amykit/core": "^0.2.0",
32
+ "@amykit/workflow-note-to-plan": "^0.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@amykit/test-fixtures": "^0.1.0"
36
+ }
37
+ }