@davidbyoung/software-factory 0.0.0-stage → 0.1.1

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.
Files changed (141) hide show
  1. package/.claude-plugin/plugin.json +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +135 -2
  4. package/actions/factory-agent/action.yml +218 -0
  5. package/agents/factory-test-reviewer.md +129 -0
  6. package/agents/factory-ticket-readiness.md +107 -0
  7. package/agents/factory-ui-reviewer.md +160 -0
  8. package/bin/factory.js +45 -0
  9. package/bin/launch.js +67 -0
  10. package/dist/board.d.mts +128 -0
  11. package/dist/board.mjs +456 -0
  12. package/dist/build.d.mts +18 -0
  13. package/dist/build.mjs +60 -0
  14. package/dist/cli.d.mts +17 -0
  15. package/dist/cli.mjs +264 -0
  16. package/dist/code-host/github.d.mts +118 -0
  17. package/dist/code-host/github.mjs +419 -0
  18. package/dist/code-host/index.d.mts +9 -0
  19. package/dist/code-host/index.mjs +18 -0
  20. package/dist/code-host/types.d.mts +205 -0
  21. package/dist/code-host/types.mjs +12 -0
  22. package/dist/config.d.mts +166 -0
  23. package/dist/config.mjs +548 -0
  24. package/dist/deps.d.mts +32 -0
  25. package/dist/deps.mjs +126 -0
  26. package/dist/doctor.d.mts +34 -0
  27. package/dist/doctor.mjs +188 -0
  28. package/dist/guard-commit.d.mts +41 -0
  29. package/dist/guard-commit.mjs +209 -0
  30. package/dist/guard-permission.d.mts +15 -0
  31. package/dist/guard-permission.mjs +52 -0
  32. package/dist/guard-ticket-text.d.mts +27 -0
  33. package/dist/guard-ticket-text.mjs +288 -0
  34. package/dist/guard.d.mts +4 -0
  35. package/dist/guard.mjs +37 -0
  36. package/dist/init.d.mts +58 -0
  37. package/dist/init.mjs +556 -0
  38. package/dist/lib/clock.d.mts +14 -0
  39. package/dist/lib/clock.mjs +36 -0
  40. package/dist/lib/gh.d.mts +28 -0
  41. package/dist/lib/gh.mjs +92 -0
  42. package/dist/lib/glob.d.mts +2 -0
  43. package/dist/lib/glob.mjs +41 -0
  44. package/dist/lib/pricing.d.mts +25 -0
  45. package/dist/lib/pricing.mjs +77 -0
  46. package/dist/lib/usage.d.mts +34 -0
  47. package/dist/lib/usage.mjs +128 -0
  48. package/dist/lib/work-status.d.mts +251 -0
  49. package/dist/lib/work-status.mjs +510 -0
  50. package/dist/merge-policy.d.mts +66 -0
  51. package/dist/merge-policy.mjs +146 -0
  52. package/dist/parts.d.mts +39 -0
  53. package/dist/parts.mjs +138 -0
  54. package/dist/poller.d.mts +61 -0
  55. package/dist/poller.mjs +247 -0
  56. package/dist/pr-watch.d.mts +45 -0
  57. package/dist/pr-watch.mjs +244 -0
  58. package/dist/pr.d.mts +65 -0
  59. package/dist/pr.mjs +571 -0
  60. package/dist/review-cost.d.mts +18 -0
  61. package/dist/review-cost.mjs +95 -0
  62. package/dist/review-tools.d.mts +5 -0
  63. package/dist/review-tools.mjs +46 -0
  64. package/dist/review-verdict.d.mts +50 -0
  65. package/dist/review-verdict.mjs +171 -0
  66. package/dist/reviewers.d.mts +54 -0
  67. package/dist/reviewers.mjs +312 -0
  68. package/dist/runner/github-actions.d.mts +12 -0
  69. package/dist/runner/github-actions.mjs +97 -0
  70. package/dist/runner/index.d.mts +9 -0
  71. package/dist/runner/index.mjs +22 -0
  72. package/dist/runner/types.d.mts +60 -0
  73. package/dist/runner/types.mjs +7 -0
  74. package/dist/session-start.d.mts +20 -0
  75. package/dist/session-start.mjs +115 -0
  76. package/dist/site/capture.d.mts +44 -0
  77. package/dist/site/capture.mjs +114 -0
  78. package/dist/site/measure.d.mts +83 -0
  79. package/dist/site/measure.mjs +225 -0
  80. package/dist/site/pages.d.mts +10 -0
  81. package/dist/site/pages.mjs +71 -0
  82. package/dist/site/pixels.d.mts +47 -0
  83. package/dist/site/pixels.mjs +157 -0
  84. package/dist/site/servers.d.mts +47 -0
  85. package/dist/site/servers.mjs +141 -0
  86. package/dist/site.d.mts +60 -0
  87. package/dist/site.mjs +341 -0
  88. package/dist/status.d.mts +100 -0
  89. package/dist/status.mjs +514 -0
  90. package/dist/sync.d.mts +59 -0
  91. package/dist/sync.mjs +292 -0
  92. package/dist/ticket.d.mts +61 -0
  93. package/dist/ticket.mjs +562 -0
  94. package/dist/tickets/github.d.mts +128 -0
  95. package/dist/tickets/github.mjs +491 -0
  96. package/dist/tickets/index.d.mts +15 -0
  97. package/dist/tickets/index.mjs +27 -0
  98. package/dist/tickets/transport.d.mts +42 -0
  99. package/dist/tickets/transport.mjs +158 -0
  100. package/dist/tickets/types.d.mts +191 -0
  101. package/dist/tickets/types.mjs +76 -0
  102. package/docs/builds.md +227 -0
  103. package/docs/cli.md +221 -0
  104. package/docs/configuration.md +809 -0
  105. package/docs/design.md +106 -0
  106. package/docs/developing.md +400 -0
  107. package/docs/existing-repo.md +138 -0
  108. package/docs/github/reference.md +288 -0
  109. package/docs/github/setup.md +312 -0
  110. package/docs/glossary.md +106 -0
  111. package/docs/limitations.md +115 -0
  112. package/docs/plugins.md +192 -0
  113. package/docs/quick-start.md +222 -0
  114. package/docs/removing.md +76 -0
  115. package/docs/skills.md +270 -0
  116. package/docs/updating.md +108 -0
  117. package/docs/workflow.md +195 -0
  118. package/package.json +67 -4
  119. package/poller.Dockerfile +21 -0
  120. package/review.md +170 -0
  121. package/rules.md +313 -0
  122. package/settings.schema.json +411 -0
  123. package/skills/factory-address-review/SKILL.md +547 -0
  124. package/skills/factory-address-review/patch-coverage.py +68 -0
  125. package/skills/factory-build/SKILL.md +412 -0
  126. package/skills/factory-deps/SKILL.md +185 -0
  127. package/skills/factory-design/SKILL.md +159 -0
  128. package/skills/factory-diagnose/SKILL.md +93 -0
  129. package/skills/factory-mutate/SKILL.md +76 -0
  130. package/skills/factory-refine/SKILL.md +417 -0
  131. package/skills/factory-resolve-conflicts/SKILL.md +235 -0
  132. package/workflows/factory-board-sync.yml +91 -0
  133. package/workflows/factory-build.yml +72 -0
  134. package/workflows/factory-check.yml +37 -0
  135. package/workflows/factory-claude-review.yml +133 -0
  136. package/workflows/factory-conflicts.yml +69 -0
  137. package/workflows/factory-deps-auto-merge.yml +43 -0
  138. package/workflows/factory-deps.yml +59 -0
  139. package/workflows/factory-merge-policy.yml +121 -0
  140. package/workflows/factory-review-verdict.yml +54 -0
  141. package/workflows/factory-review.yml +75 -0
package/dist/cli.mjs ADDED
@@ -0,0 +1,264 @@
1
+ // The `factory` command: reads the command and loads only that command's
2
+ // module, so a hook that runs before every shell command loads one file
3
+ // and what it imports, not the whole tool.
4
+ //
5
+ // factory COMMAND [ARGS]
6
+ //
7
+ // An unknown command, or none, prints the usage and exits 2.
8
+ const TICKET_STEPS = [
9
+ "refining",
10
+ "waiting",
11
+ "refined",
12
+ "ready",
13
+ "claim",
14
+ "still-live",
15
+ "stop",
16
+ "end",
17
+ "cost",
18
+ "view",
19
+ "list",
20
+ "edit",
21
+ "comment",
22
+ "open",
23
+ "label",
24
+ "link",
25
+ "blockers",
26
+ "block",
27
+ "unblock",
28
+ "supports",
29
+ ];
30
+ const PR_STEPS = [
31
+ "state",
32
+ "threads",
33
+ "reply",
34
+ "resolve",
35
+ "ready",
36
+ "closes",
37
+ "comments",
38
+ "comment",
39
+ "comment-view",
40
+ "label",
41
+ "review-pending",
42
+ "conflicts",
43
+ "open",
44
+ "view",
45
+ "review",
46
+ "unverified",
47
+ "failed",
48
+ "review-again",
49
+ ];
50
+ const ticket = (sub, args) => ({
51
+ words: ["ticket", sub],
52
+ args,
53
+ run: async (argv) => (await import("./ticket.mjs")).run([sub, ...argv]),
54
+ });
55
+ const pr = (sub, args) => ({
56
+ words: ["pr", sub],
57
+ args,
58
+ run: async (argv) => (await import("./pr.mjs")).run([sub, ...argv]),
59
+ });
60
+ const TICKET_ARGS = {
61
+ refined: "N [--before-file FILE]",
62
+ stop: 'N "reason"',
63
+ view: "N [--field title|state|labels|body] [--json]",
64
+ list: '[--label LABEL] [--title "TITLE"] [--json]',
65
+ edit: "N --body-file FILE [--attach FILE]",
66
+ comment: "N --body-file FILE [--attach FILE]",
67
+ open: "--title TITLE --body-file FILE [--label LABEL]",
68
+ label: "N --add LABEL | --remove LABEL | --was-removed LABEL",
69
+ block: "N --by M",
70
+ unblock: "N --by M",
71
+ supports: "GROUP",
72
+ };
73
+ const PR_ARGS = {
74
+ state: "[N] [--wait]",
75
+ threads: "N [--all]",
76
+ open: "--title TITLE --body-file FILE [--base BRANCH] [--ready]",
77
+ view: "N --field FIELD",
78
+ review: "N REVIEW",
79
+ reply: "N COMMENT --body-file FILE",
80
+ resolve: "N COMMENT",
81
+ comments: "N [--author LOGIN] [--contains TEXT] [--json]",
82
+ comment: "N --body-file FILE",
83
+ "comment-view": "ID",
84
+ label: "N --add LABEL | --remove LABEL",
85
+ "review-pending": "N REVIEW",
86
+ conflicts: "",
87
+ };
88
+ export const COMMANDS = [
89
+ ...TICKET_STEPS.map((s) => ticket(s, TICKET_ARGS[s] ?? "N")),
90
+ {
91
+ words: ["follow-up"],
92
+ args: 'FILE "what is wrong"',
93
+ run: async (argv) => (await import("./ticket.mjs")).run(["follow-up", ...argv]),
94
+ },
95
+ ...PR_STEPS.map((s) => pr(s, PR_ARGS[s] ?? "N")),
96
+ pr("wait-checks", "N"),
97
+ {
98
+ words: ["pr", "watch"],
99
+ args: "N [--release]",
100
+ run: async (argv) => (await import("./pr-watch.mjs")).run(argv),
101
+ },
102
+ {
103
+ words: ["build"],
104
+ args: "N",
105
+ run: async (argv) => (await import("./build.mjs")).run(argv),
106
+ },
107
+ {
108
+ words: ["deps"],
109
+ args: "[--any]",
110
+ run: async (argv) => (await import("./deps.mjs")).run(argv),
111
+ },
112
+ {
113
+ words: ["status"],
114
+ args: "[--watch]",
115
+ run: async (argv) => (await import("./status.mjs")).run(argv),
116
+ },
117
+ {
118
+ words: ["session-start"],
119
+ args: "",
120
+ run: async () => (await import("./session-start.mjs")).run(),
121
+ },
122
+ {
123
+ words: ["sync"],
124
+ args: "[--check]",
125
+ run: async (argv) => (await import("./sync.mjs")).run(argv),
126
+ },
127
+ {
128
+ words: ["init"],
129
+ args: "",
130
+ run: async (argv) => (await import("./init.mjs")).run(argv),
131
+ },
132
+ {
133
+ words: ["doctor"],
134
+ args: "",
135
+ run: async (argv) => (await import("./doctor.mjs")).run(argv),
136
+ },
137
+ {
138
+ words: ["config", "get"],
139
+ args: "KEY",
140
+ run: async (argv) => (await import("./config.mjs")).run(argv.slice(0, 1)),
141
+ },
142
+ {
143
+ words: ["site", "compare"],
144
+ args: "[--before URL --after URL] [--base REF] [--keep]",
145
+ run: async (argv) => (await import("./site.mjs")).run(["compare", ...argv]),
146
+ },
147
+ {
148
+ words: ["site", "stop"],
149
+ args: "",
150
+ run: async () => (await import("./site.mjs")).run(["stop"]),
151
+ },
152
+ {
153
+ words: ["config", "check"],
154
+ args: "",
155
+ run: async () => (await import("./config.mjs")).run(["check"]),
156
+ },
157
+ {
158
+ words: ["plugins"],
159
+ args: "[ROLE]",
160
+ run: async (argv) => (await import("./config.mjs")).run(["plugins", ...argv]),
161
+ },
162
+ {
163
+ words: ["board", "collect"],
164
+ args: "--out FILE [--event FILE --event-name NAME]",
165
+ run: async (argv) => (await import("./board.mjs")).run(["collect", ...argv]),
166
+ },
167
+ {
168
+ words: ["board", "apply"],
169
+ args: "--in FILE",
170
+ run: async (argv) => (await import("./board.mjs")).run(["apply", ...argv]),
171
+ },
172
+ {
173
+ words: ["board", "check"],
174
+ args: "",
175
+ run: async (argv) => (await import("./board.mjs")).run(["check", ...argv]),
176
+ },
177
+ {
178
+ words: ["poller"],
179
+ args: "",
180
+ run: async () => (await import("./poller.mjs")).run(),
181
+ },
182
+ {
183
+ words: ["merge-policy"],
184
+ args: "N",
185
+ run: async (argv) => (await import("./merge-policy.mjs")).run(argv),
186
+ },
187
+ {
188
+ words: ["review", "verdict"],
189
+ args: "",
190
+ run: async () => (await import("./review-verdict.mjs")).run(),
191
+ },
192
+ {
193
+ words: ["review", "cost"],
194
+ args: "",
195
+ run: async () => (await import("./review-cost.mjs")).run(),
196
+ },
197
+ {
198
+ words: ["review", "tools"],
199
+ args: "",
200
+ run: async () => (await import("./review-tools.mjs")).run(),
201
+ },
202
+ {
203
+ words: ["reviewers", "start"],
204
+ args: "",
205
+ run: async () => (await import("./reviewers.mjs")).run(["start"]),
206
+ },
207
+ {
208
+ words: ["reviewers", "stop"],
209
+ args: "",
210
+ run: async () => (await import("./reviewers.mjs")).run(["stop"]),
211
+ },
212
+ {
213
+ words: ["guard"],
214
+ args: "",
215
+ run: async () => (await import("./guard.mjs")).run("all"),
216
+ },
217
+ {
218
+ words: ["guard", "commit"],
219
+ args: "",
220
+ run: async () => (await import("./guard.mjs")).run("commit"),
221
+ },
222
+ {
223
+ words: ["guard", "permission"],
224
+ args: "",
225
+ run: async () => (await import("./guard-permission.mjs")).run(),
226
+ },
227
+ {
228
+ words: ["guard", "ticket-text"],
229
+ args: "",
230
+ run: async () => (await import("./guard.mjs")).run("ticket-text"),
231
+ },
232
+ ];
233
+ export function usage() {
234
+ const width = Math.max(...COMMANDS.map((c) => c.words.join(" ").length + 1 + c.args.length));
235
+ return [
236
+ "Usage: factory COMMAND [ARGS]",
237
+ "",
238
+ "Commands:",
239
+ ...COMMANDS.map((c) => ` factory ${`${c.words.join(" ")} ${c.args}`.padEnd(width)}`).map((line) => line.trimEnd()),
240
+ ].join("\n");
241
+ }
242
+ /** The command `argv` names, the longest match first, with the arguments
243
+ * left after its words; null when none matches. */
244
+ export function resolveCommand(argv) {
245
+ let best = null;
246
+ for (const c of COMMANDS) {
247
+ if (c.words.every((w, i) => argv[i] === w)) {
248
+ if (!best || c.words.length > best.words.length)
249
+ best = c;
250
+ }
251
+ }
252
+ return best ? { command: best, rest: argv.slice(best.words.length) } : null;
253
+ }
254
+ export async function main(argv) {
255
+ const found = resolveCommand(argv);
256
+ // `guard` alone runs both guards, but `guard WORD` with a word that is
257
+ // not a guard is a mistake, not a request for both.
258
+ if (!found || (found.command.words.join(" ") === "guard" && found.rest[0])) {
259
+ console.error(usage());
260
+ return 2;
261
+ }
262
+ return (await found.command.run(found.rest)) ?? 0;
263
+ }
264
+ process.exitCode = await main(process.argv.slice(2));
@@ -0,0 +1,118 @@
1
+ import type { Gh } from "../lib/gh.mts";
2
+ import type { PullRequest } from "../lib/work-status.mts";
3
+ import { type Transport } from "../tickets/transport.mts";
4
+ import type { CodeHost, Thread } from "./types.mts";
5
+ type GraphThread = {
6
+ id: string;
7
+ isResolved: boolean;
8
+ isOutdated: boolean;
9
+ path: string;
10
+ line: number | null;
11
+ comments: {
12
+ nodes: {
13
+ databaseId: number;
14
+ author: {
15
+ login: string;
16
+ } | null;
17
+ body: string;
18
+ }[];
19
+ };
20
+ };
21
+ export declare function fromGraph(nodes: GraphThread[]): Thread[];
22
+ export declare const OPEN_PULLS_QUERY = "\nquery OpenPulls(\n $owner: String!\n $name: String!\n $checks: Boolean = false\n $costs: Boolean = false\n) {\n repository(owner: $owner, name: $name) {\n pullRequests(states: OPEN, first: 100) {\n nodes {\n ...pull\n reviewThreads(first: 100) { nodes { isResolved } }\n commits(last: 1) @include(if: $checks) {\n nodes { commit { statusCheckRollup { state } } }\n }\n }\n }\n }\n}\nfragment pull on PullRequest {\n number createdAt body isDraft\n author { login }\n closingIssuesReferences(first: 25) {\n nodes { number repository { nameWithOwner } }\n }\n comments(last: 100) @include(if: $costs) {\n nodes { databaseId createdAt body author { login } }\n }\n}";
23
+ export declare const LINKING_PULLS_QUERY = "\nquery LinkingPulls($owner: String!, $name: String!, $after: String) {\n repository(owner: $owner, name: $name) {\n open: issues(states: OPEN, first: 100, after: $after) {\n pageInfo { hasNextPage endCursor }\n nodes { ...links }\n }\n closed: issues(states: CLOSED, first: 30, orderBy: {field: UPDATED_AT, direction: DESC}) {\n nodes { ...links }\n }\n }\n}\nfragment links on Issue {\n builders: timelineItems(itemTypes: [CROSS_REFERENCED_EVENT], last: 20) {\n nodes { ... on CrossReferencedEvent { source { ... on PullRequest {\n number createdAt body isDraft\n author { login }\n closingIssuesReferences(first: 25) {\n nodes { number repository { nameWithOwner } }\n }\n comments(last: 100) {\n nodes { databaseId createdAt body author { login } }\n }\n } } } }\n }\n}";
24
+ type RawComments = {
25
+ nodes: {
26
+ databaseId: number;
27
+ createdAt: string;
28
+ body: string;
29
+ author: {
30
+ login: string;
31
+ } | null;
32
+ }[];
33
+ };
34
+ export type RawPull = {
35
+ number: number;
36
+ createdAt: string;
37
+ body: string;
38
+ isDraft: boolean;
39
+ author: {
40
+ login: string;
41
+ } | null;
42
+ closingIssuesReferences: {
43
+ nodes: {
44
+ number: number;
45
+ repository: {
46
+ nameWithOwner: string;
47
+ };
48
+ }[];
49
+ };
50
+ comments?: RawComments;
51
+ /** Absent on closed and merged pull requests. */
52
+ reviewThreads?: {
53
+ nodes: {
54
+ isResolved: boolean;
55
+ }[];
56
+ };
57
+ /** Present only when the read asked for check state, which needs the
58
+ * checks and statuses permissions the sync's token does not have. */
59
+ commits?: {
60
+ nodes: {
61
+ commit: {
62
+ statusCheckRollup: {
63
+ state: string;
64
+ } | null;
65
+ };
66
+ }[];
67
+ };
68
+ };
69
+ export type OpenPullsPage = {
70
+ data: {
71
+ repository: {
72
+ pullRequests: {
73
+ nodes: RawPull[];
74
+ };
75
+ };
76
+ };
77
+ };
78
+ export type LinkingPage = {
79
+ data: {
80
+ repository: {
81
+ open: {
82
+ pageInfo: {
83
+ hasNextPage: boolean;
84
+ endCursor: string | null;
85
+ };
86
+ nodes: {
87
+ builders: {
88
+ nodes: {
89
+ source?: Partial<RawPull>;
90
+ }[];
91
+ };
92
+ }[];
93
+ };
94
+ closed: {
95
+ nodes: {
96
+ builders: {
97
+ nodes: {
98
+ source?: Partial<RawPull>;
99
+ }[];
100
+ };
101
+ }[];
102
+ };
103
+ };
104
+ };
105
+ };
106
+ export declare function toPull(raw: RawPull, repository: string): PullRequest;
107
+ /** The pull requests in every page of LINKING_PULLS_QUERY, less those in
108
+ * `skip`, which the caller already has. */
109
+ export declare function fromLinkingPages(pages: LinkingPage[], repository: string, skip?: number[]): PullRequest[];
110
+ export declare function githubCodeHost(o: {
111
+ transport: Transport;
112
+ repository: string;
113
+ /** The GitHub CLI, for `gh pr ready`. */
114
+ cli?: Gh;
115
+ /** For asking GitHub about a token other than the transport's. */
116
+ fetch?: typeof fetch;
117
+ }): CodeHost;
118
+ export {};