@davidbyoung/software-factory 0.1.2 → 0.1.4

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 (120) hide show
  1. package/README.md +20 -20
  2. package/actions/factory-agent/action.yml +1 -1
  3. package/agents/factory-e2e-reviewer.md +102 -0
  4. package/agents/factory-test-reviewer.md +26 -64
  5. package/agents/factory-ticket-readiness.md +14 -6
  6. package/dist/agent/claude-code.d.mts +3 -0
  7. package/dist/agent/claude-code.mjs +89 -0
  8. package/dist/agent/index.d.mts +2 -0
  9. package/dist/agent/index.mjs +5 -0
  10. package/dist/board.mjs +1 -1
  11. package/dist/cli.mjs +46 -4
  12. package/dist/code-host/github-setup.d.mts +5 -0
  13. package/dist/code-host/github-setup.mjs +133 -0
  14. package/dist/code-host/github.mjs +4 -0
  15. package/dist/code-host/index.d.mts +1 -1
  16. package/dist/code-host/index.mjs +2 -1
  17. package/dist/code-host/types.d.mts +2 -0
  18. package/dist/commands.d.mts +16 -0
  19. package/dist/commands.mjs +129 -0
  20. package/dist/config.d.mts +87 -20
  21. package/dist/config.mjs +344 -89
  22. package/dist/deps.d.mts +7 -4
  23. package/dist/deps.mjs +20 -9
  24. package/dist/doctor.d.mts +9 -16
  25. package/dist/doctor.mjs +71 -68
  26. package/dist/explain.d.mts +4 -0
  27. package/dist/explain.mjs +174 -0
  28. package/dist/guard-commit.d.mts +7 -2
  29. package/dist/guard-commit.mjs +58 -21
  30. package/dist/init.d.mts +12 -14
  31. package/dist/init.mjs +194 -136
  32. package/dist/lib/default-branch.d.mts +35 -0
  33. package/dist/lib/default-branch.mjs +117 -0
  34. package/dist/lib/has-command.d.mts +5 -0
  35. package/dist/lib/has-command.mjs +8 -0
  36. package/dist/lib/listed.d.mts +2 -0
  37. package/dist/lib/listed.mjs +4 -0
  38. package/dist/lib/refined-check.d.mts +7 -0
  39. package/dist/lib/refined-check.mjs +76 -0
  40. package/dist/lib/work-status.d.mts +12 -2
  41. package/dist/lib/work-status.mjs +14 -3
  42. package/dist/parts.d.mts +18 -15
  43. package/dist/parts.mjs +15 -43
  44. package/dist/patch-coverage.d.mts +13 -0
  45. package/dist/patch-coverage.mjs +73 -0
  46. package/dist/poller.d.mts +20 -3
  47. package/dist/poller.mjs +62 -15
  48. package/dist/pr-watch.d.mts +3 -2
  49. package/dist/pr-watch.mjs +22 -5
  50. package/dist/pr.mjs +34 -2
  51. package/dist/remove.d.mts +11 -0
  52. package/dist/remove.mjs +156 -0
  53. package/dist/runner/github-actions.d.mts +1 -1
  54. package/dist/runner/github-actions.mjs +12 -0
  55. package/dist/runner/index.d.mts +1 -1
  56. package/dist/runner/index.mjs +2 -1
  57. package/dist/runner/setup.d.mts +2 -0
  58. package/dist/runner/setup.mjs +22 -0
  59. package/dist/runner/types.d.mts +3 -0
  60. package/dist/runner/types.mjs +0 -2
  61. package/dist/session-start.d.mts +23 -13
  62. package/dist/session-start.mjs +56 -44
  63. package/dist/setup.d.mts +98 -0
  64. package/dist/setup.mjs +3 -0
  65. package/dist/site/servers.d.mts +6 -2
  66. package/dist/site/servers.mjs +14 -9
  67. package/dist/site.mjs +2 -2
  68. package/dist/status.d.mts +4 -4
  69. package/dist/status.mjs +8 -7
  70. package/dist/sync.d.mts +26 -2
  71. package/dist/sync.mjs +177 -13
  72. package/dist/ticket.mjs +19 -1
  73. package/dist/tickets/github-setup.d.mts +2 -0
  74. package/dist/tickets/github-setup.mjs +50 -0
  75. package/dist/tickets/github.mjs +0 -2
  76. package/dist/tickets/index.mjs +2 -1
  77. package/dist/tickets/transport.mjs +1 -3
  78. package/dist/tickets/types.mjs +0 -2
  79. package/dist/tool-names.d.mts +11 -0
  80. package/dist/tool-names.mjs +20 -0
  81. package/dist/tools.d.mts +56 -0
  82. package/dist/tools.mjs +76 -0
  83. package/docs/builds.md +111 -59
  84. package/docs/cli.md +106 -69
  85. package/docs/configuration.md +489 -171
  86. package/docs/design.md +18 -5
  87. package/docs/developing.md +179 -73
  88. package/docs/existing-repo.md +25 -12
  89. package/docs/github/by-hand.md +334 -0
  90. package/docs/github/reference.md +76 -67
  91. package/docs/github/setup.md +105 -286
  92. package/docs/glossary.md +18 -7
  93. package/docs/limitations.md +39 -12
  94. package/docs/plugins.md +305 -56
  95. package/docs/quick-start.md +85 -100
  96. package/docs/removing.md +37 -17
  97. package/docs/skills.md +121 -62
  98. package/docs/updating.md +150 -9
  99. package/docs/workflow.md +23 -19
  100. package/package.json +1 -1
  101. package/poller.Dockerfile +10 -18
  102. package/review.md +20 -11
  103. package/rules.md +36 -30
  104. package/settings.schema.json +313 -69
  105. package/skills/factory-address-review/SKILL.md +50 -30
  106. package/skills/factory-build/SKILL.md +76 -23
  107. package/skills/factory-deps/SKILL.md +46 -21
  108. package/skills/factory-design/SKILL.md +17 -8
  109. package/skills/factory-diagnose/SKILL.md +22 -20
  110. package/skills/factory-mutate/SKILL.md +38 -24
  111. package/skills/factory-refine/SKILL.md +55 -31
  112. package/skills/factory-resolve-conflicts/SKILL.md +76 -34
  113. package/skills/factory-trace/SKILL.md +80 -0
  114. package/workflows/factory-build.yml +6 -5
  115. package/workflows/factory-conflicts.yml +8 -8
  116. package/workflows/factory-deps-auto-merge.yml +3 -2
  117. package/workflows/factory-deps.yml +1 -1
  118. package/workflows/factory-poller.yml +46 -0
  119. package/workflows/factory-review.yml +1 -1
  120. package/skills/factory-address-review/patch-coverage.py +0 -68
@@ -1,45 +1,43 @@
1
1
  // The SessionStart hook, run as `factory session-start`. Its output opens
2
2
  // the session's context, so work left on another branch is visible before
3
3
  // anything new starts: the checkout's state, the local branches with work
4
- // not on origin/main, then each ticket's state.
5
- import { spawnSync } from "node:child_process";
4
+ // not on the default branch, then each ticket's state.
6
5
  import { readFileSync } from "node:fs";
7
6
  import { join } from "node:path";
8
- export const gitIn = (cwd) => (args) => {
9
- const r = spawnSync("git", args, {
10
- cwd,
11
- encoding: "utf8",
12
- stdio: ["ignore", "pipe", "ignore"],
13
- });
14
- return { ok: r.status === 0, out: r.stdout ?? "" };
15
- };
16
- /** Each local branch but main with work origin/main lacks, as
17
- * "NAME (N commits not on origin/main)". Pull requests are squash-merged, so
18
- * a merged branch still has commits main lacks: it counts as merged when
19
- * merging it into main would change nothing. */
20
- export function unmergedBranches(git) {
21
- const mainTree = git(["rev-parse", "origin/main^{tree}"]).out.trim();
7
+ import { branchDeps, CANNOT_TELL, defaultBranch, gitIn, } from "./lib/default-branch.mjs";
8
+ export { gitIn };
9
+ /** Each local branch but the default one, `branch`, with work
10
+ * origin/BRANCH lacks, as "NAME (N commits not on origin/BRANCH)". Pull
11
+ * requests are squash-merged, so a merged branch still has commits the
12
+ * default branch lacks: it counts as merged when merging it into the
13
+ * default branch would change nothing. */
14
+ export function unmergedBranches(git, branch) {
15
+ const base = `origin/${branch}`;
16
+ const baseTree = git(["rev-parse", `${base}^{tree}`]).out.trim();
22
17
  const branches = git([
23
18
  "for-each-ref",
24
19
  "--format=%(refname:short)",
25
20
  "refs/heads",
26
21
  ])
27
22
  .out.split("\n")
28
- .filter((b) => b && b !== "main");
23
+ .filter((b) => b && b !== branch);
29
24
  const found = [];
30
25
  for (const b of branches) {
31
- const merged = git(["merge-tree", "--write-tree", "origin/main", b]);
32
- if (merged.ok && merged.out.split("\n")[0] === mainTree)
26
+ const merged = git(["merge-tree", "--write-tree", base, b]);
27
+ if (merged.ok && merged.out.split("\n")[0] === baseTree)
33
28
  continue;
34
- const count = Number(git(["rev-list", "--count", `origin/main..${b}`]).out.trim() || 0);
29
+ const count = Number(git(["rev-list", "--count", `${base}..${b}`]).out.trim() || 0);
35
30
  if (count > 0)
36
- found.push(`${b} (${count} commits not on origin/main)`);
31
+ found.push(`${b} (${count} commits not on ${base})`);
37
32
  }
38
33
  return found;
39
34
  }
40
- /** What the hook prints before the tickets' state. */
41
- export function repositoryState(git) {
42
- git(["fetch", "-q", "origin", "main"]);
35
+ /** What the hook prints before the tickets' state. `branch` is the default
36
+ * branch, or null when it could not be told: then no branch is compared
37
+ * with anything, and the line that names the fix stands in for the list. */
38
+ export function repositoryState(git, branch) {
39
+ if (branch !== null)
40
+ git(["fetch", "-q", "origin", branch]);
43
41
  const lines = [
44
42
  "## Repository state at session start",
45
43
  "",
@@ -48,9 +46,11 @@ export function repositoryState(git) {
48
46
  "```",
49
47
  "",
50
48
  ];
51
- const unmerged = unmergedBranches(git);
49
+ if (branch === null)
50
+ return [...lines, CANNOT_TELL];
51
+ const unmerged = unmergedBranches(git, branch);
52
52
  if (unmerged.length) {
53
- lines.push("Local branches with work not on origin/main:", "", ...unmerged.map((b) => `- ${b}`), "", "Mention any of these to the user before starting work on another branch.");
53
+ lines.push(`Local branches with work not on origin/${branch}:`, "", ...unmerged.map((b) => `- ${b}`), "", "Mention any of these to the user before starting work on another branch.");
54
54
  }
55
55
  return lines;
56
56
  }
@@ -86,6 +86,15 @@ export function installBehind(dir) {
86
86
  }
87
87
  return null;
88
88
  }
89
+ export async function main(d) {
90
+ const branch = await defaultBranch(d.branch).catch(() => null);
91
+ d.out(repositoryState(gitIn(d.dir), branch).join("\n"));
92
+ const behind = installBehind(d.dir);
93
+ if (behind)
94
+ d.out(`\n${behind}\n`);
95
+ return d.tickets();
96
+ }
97
+ /** `factory session-start`. */
89
98
  export async function run() {
90
99
  const dir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
91
100
  try {
@@ -94,22 +103,25 @@ export async function run() {
94
103
  catch {
95
104
  return 0;
96
105
  }
97
- console.log(repositoryState(gitIn(dir)).join("\n"));
98
- const behind = installBehind(dir);
99
- if (behind)
100
- console.log(`\n${behind}\n`);
101
- // What each ticket's board card says, and who is working on it. The status
102
- // command enforces its own time limit, since a hook the harness kills
103
- // prints nothing.
104
- const error = console.error;
105
- console.error = () => { };
106
- try {
107
- return await (await import("./status.mjs")).run(["--hook"]);
108
- }
109
- catch {
110
- return 0;
111
- }
112
- finally {
113
- console.error = error;
114
- }
106
+ return main({
107
+ dir,
108
+ branch: branchDeps(dir),
109
+ out: (text) => console.log(text),
110
+ // What each ticket's board card says, and who is working on it. The
111
+ // status command enforces its own time limit, since a hook the harness
112
+ // kills prints nothing.
113
+ tickets: async () => {
114
+ const error = console.error;
115
+ console.error = () => { };
116
+ try {
117
+ return await (await import("./status.mjs")).run(["--hook"]);
118
+ }
119
+ catch {
120
+ return 0;
121
+ }
122
+ finally {
123
+ console.error = error;
124
+ }
125
+ },
126
+ });
115
127
  }
@@ -0,0 +1,98 @@
1
+ import type { CodeHost } from "./code-host/types.mts";
2
+ import type { Settings } from "./config.mts";
3
+ import type { Part } from "./parts.mts";
4
+ import type { Runner } from "./runner/types.mts";
5
+ import type { Tickets } from "./tickets/types.mts";
6
+ /** The repository rule that requires the review's verdict, by name, so
7
+ * removing it is deleting that one rule. */
8
+ export declare const RULE = "Software factory";
9
+ export type Check = {
10
+ state: "pass" | "fail" | "off";
11
+ text: string;
12
+ /** What to do about a failure. */
13
+ fix?: string;
14
+ };
15
+ /** A secret is needed for a part that is on, or always when `part` is
16
+ * null, and any one of `anyOf` being set meets it. */
17
+ export type Need = {
18
+ part: Part | null;
19
+ anyOf: string[];
20
+ };
21
+ /** A value written under the tool's kind's block of the settings. */
22
+ export type ValueStep = {
23
+ kind: "value";
24
+ /** Its key, such as `site` under `tickets`. */
25
+ key: string;
26
+ part: Part | null;
27
+ ask: string;
28
+ fallback?: string;
29
+ };
30
+ export type SecretStep = {
31
+ kind: "secret";
32
+ needs: Need[];
33
+ /** The names a pasted value is stored under. */
34
+ storeAs: string[];
35
+ /** Printed before the value is read. */
36
+ intro: string[];
37
+ get?: {
38
+ page: string;
39
+ } | {
40
+ command: string[];
41
+ };
42
+ /** The masked prompt. */
43
+ prompt: string;
44
+ /** Printed when nothing is pasted, before "Run ... init again". */
45
+ skipped: string;
46
+ /** Resolves to lines to print, and the account the value belongs to
47
+ * when the tool knows it; rejects with the line to print before asking
48
+ * again. */
49
+ verify?: (value: string) => Promise<{
50
+ lines: string[];
51
+ account?: string;
52
+ }>;
53
+ /** Printed once it is stored. */
54
+ stored: (names: string[], account?: string) => string;
55
+ };
56
+ export type SetupStep = ValueStep | SecretStep;
57
+ /** The name of each kind's tool in use. */
58
+ export type Chosen = {
59
+ codeHost: string;
60
+ tickets: string;
61
+ runner: string;
62
+ agent: string;
63
+ };
64
+ export type Opened = {
65
+ codeHost: CodeHost;
66
+ runner: Runner;
67
+ tickets: Tickets;
68
+ };
69
+ export type SetupContext = {
70
+ repository: string;
71
+ root: string;
72
+ parts: ReadonlySet<Part>;
73
+ chosen: Chosen;
74
+ settings: Settings | null;
75
+ hasCommand: (name: string) => boolean;
76
+ opened: Opened;
77
+ };
78
+ /** The secrets set, or null when the runner could not list them. */
79
+ export type WithSecrets = SetupContext & {
80
+ secrets: string[] | null;
81
+ };
82
+ /** A file of the tool's own, as it reads with the factory's part taken
83
+ * out: null to delete it. */
84
+ export type Unconfigured = {
85
+ path: string;
86
+ text: string | null;
87
+ };
88
+ export type ToolSetup = {
89
+ /** Its row under Found, when it says more than its label. */
90
+ found?(c: Pick<SetupContext, "hasCommand">): string;
91
+ steps?(c: SetupContext): SetupStep[];
92
+ checks?(c: WithSecrets): Promise<Check[]>;
93
+ /** What `remove` prints as left to remove by hand. */
94
+ leftovers?(c: WithSecrets): string[];
95
+ /** Its own files with the factory's part taken out, for `remove`: only
96
+ * those the factory's part is in. */
97
+ unconfigure?(c: SetupContext): Unconfigured[];
98
+ };
package/dist/setup.mjs ADDED
@@ -0,0 +1,3 @@
1
+ /** The repository rule that requires the review's verdict, by name, so
2
+ * removing it is deleting that one rule. */
3
+ export const RULE = "Software factory";
@@ -1,3 +1,4 @@
1
+ import { type Deps as BranchDeps } from "../lib/default-branch.mts";
1
2
  export declare class SiteError extends Error {
2
3
  }
3
4
  export type Running = {
@@ -25,8 +26,11 @@ export declare function startSite(opts: {
25
26
  * that stops the others. */
26
27
  export declare function startSites(sites: Parameters<typeof startSite>[0][], pids: number[]): Promise<Running[]>;
27
28
  export declare function stopProcess(pid: number): void;
28
- /** Whether the repository is a git checkout with this ref. */
29
- export declare const defaultBranch: (root: string) => string;
29
+ /** The ref a comparison's base is started from when none is given: the
30
+ * default branch, as `origin` has it, or the checkout's own branch of that
31
+ * name where there is no such ref, as in a checkout with no remote. It
32
+ * fails, naming the fix, when the default branch cannot be told. */
33
+ export declare function defaultBase(root: string, d?: BranchDeps): Promise<string>;
30
34
  /** A detached worktree of `ref` in a temporary folder, with its dependencies
31
35
  * installed when it has a lockfile. Returns its path. */
32
36
  export declare function addWorktree(root: string, ref: string): string;
@@ -6,6 +6,7 @@ import { createServer } from "node:net";
6
6
  import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
7
7
  import { tmpdir } from "node:os";
8
8
  import { join } from "node:path";
9
+ import { branchDeps, CANNOT_TELL, defaultBranch, } from "../lib/default-branch.mjs";
9
10
  export class SiteError extends Error {
10
11
  }
11
12
  /** A port nothing is listening on. */
@@ -80,15 +81,19 @@ export function stopProcess(pid) {
80
81
  }
81
82
  }
82
83
  }
83
- /** Whether the repository is a git checkout with this ref. */
84
- export const defaultBranch = (root) => {
85
- try {
86
- return execFileSync("git", ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
87
- }
88
- catch {
89
- return "origin/main";
90
- }
91
- };
84
+ /** The ref a comparison's base is started from when none is given: the
85
+ * default branch, as `origin` has it, or the checkout's own branch of that
86
+ * name where there is no such ref, as in a checkout with no remote. It
87
+ * fails, naming the fix, when the default branch cannot be told. */
88
+ export async function defaultBase(root, d = branchDeps(root)) {
89
+ const name = await defaultBranch(d);
90
+ if (name === null)
91
+ throw new SiteError(CANNOT_TELL);
92
+ const remote = `refs/remotes/origin/${name}`;
93
+ return d.git(["rev-parse", "--verify", "--quiet", remote]).ok
94
+ ? `origin/${name}`
95
+ : name;
96
+ }
92
97
  /** A detached worktree of `ref` in a temporary folder, with its dependencies
93
98
  * installed when it has a lockfile. Returns its path. */
94
99
  export function addWorktree(root, ref) {
package/dist/site.mjs CHANGED
@@ -17,7 +17,7 @@ import { crawl, normalize, sitemapPaths } from "./site/pages.mjs";
17
17
  import { changedWithoutNoise, classify, diff, } from "./site/pixels.mjs";
18
18
  import { encode, launch, measureView, shoot, } from "./site/capture.mjs";
19
19
  import { addToCensus, AXE_TAGS, emptyCensus, formatFinding, newValues, newViolations, sidewaysScroll, } from "./site/measure.mjs";
20
- import { addWorktree, defaultBranch, freePort, keep, removeWorktree, SiteError, startSites, stopKept, stopProcess, } from "./site/servers.mjs";
20
+ import { addWorktree, defaultBase, freePort, keep, removeWorktree, SiteError, startSites, stopKept, stopProcess, } from "./site/servers.mjs";
21
21
  const slug = (p) => p.replace(/^\/|\/$/g, "").replace(/\W+/g, "-") || "home";
22
22
  async function text(url) {
23
23
  try {
@@ -261,7 +261,7 @@ async function compare(argv) {
261
261
  after = given.after;
262
262
  }
263
263
  else {
264
- const base = flag(argv, "--base") ?? defaultBranch(root);
264
+ const base = flag(argv, "--base") ?? (await defaultBase(root));
265
265
  const [pa, pb] = [await freePort(), await freePort()];
266
266
  worktree = addWorktree(root, base);
267
267
  const common = { start: site.start, minutes: site.startMinutes };
package/dist/status.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { type Settings, type Target } from "./config.mts";
3
- import { type Columns, type Board, type Derived, type PullRequest, type Issue, type RepoSnapshot, type ReviewerRun } from "./lib/work-status.mts";
3
+ import { type Columns, type Watch, type Board, type Derived, type PullRequest, type Issue, type RepoSnapshot, type ReviewerRun } from "./lib/work-status.mts";
4
4
  import { type Tickets } from "./tickets/types.mts";
5
5
  import { type CodeHost } from "./code-host/index.mts";
6
6
  import { type Runner } from "./runner/index.mts";
@@ -27,9 +27,9 @@ export declare function isWatching(body: string, now: Date): boolean;
27
27
  /** One row per open issue, and one per open pull request that closes no
28
28
  * issue and builds no part of the follow-ups, such as Dependabot's. */
29
29
  export declare function toRows(snapshot: RepoSnapshot, board: Board, blockers: Map<number, number[]>, now: Date,
30
- /** Whether something starts builds from the board, so that a card left
31
- * in Ready is worth flagging. False when builds.trigger is manual. */
32
- watched?: boolean, columns?: Columns): {
30
+ /** What starts builds from the board, so that a card left in Ready is
31
+ * worth flagging; null when builds.trigger is manual. */
32
+ watch?: Watch | null, columns?: Columns): {
33
33
  rows: Row[];
34
34
  closed: Row[];
35
35
  };
package/dist/status.mjs CHANGED
@@ -14,7 +14,7 @@
14
14
  import { setTimeout as sleep } from "node:timers/promises";
15
15
  import { NO_DEPENDENCIES, SettingsError, loadSettings, targetOf, } from "./config.mjs";
16
16
  import { appSessionLink } from "./lib/gh.mjs";
17
- import { DEFAULT_COLUMNS, cardOf, derive, isNotStarted, isStale, isStuck, actionsRunLink, buildsPartOf, markedComments, parseRuns, toSnapshot, } from "./lib/work-status.mjs";
17
+ import { DEFAULT_COLUMNS, cardOf, derive, isNotStarted, watchOf, isStale, isStuck, actionsRunLink, buildsPartOf, markedComments, parseRuns, toSnapshot, } from "./lib/work-status.mjs";
18
18
  import { boardOf, readAll } from "./tickets/types.mjs";
19
19
  import { openTickets } from "./tickets/index.mjs";
20
20
  import { openCodeHost } from "./code-host/index.mjs";
@@ -66,9 +66,9 @@ export function isWatching(body, now) {
66
66
  /** One row per open issue, and one per open pull request that closes no
67
67
  * issue and builds no part of the follow-ups, such as Dependabot's. */
68
68
  export function toRows(snapshot, board, blockers, now,
69
- /** Whether something starts builds from the board, so that a card left
70
- * in Ready is worth flagging. False when builds.trigger is manual. */
71
- watched = true, columns = DEFAULT_COLUMNS) {
69
+ /** What starts builds from the board, so that a card left in Ready is
70
+ * worth flagging; null when builds.trigger is manual. */
71
+ watch = watchOf("own-server", 5), columns = DEFAULT_COLUMNS) {
72
72
  const rows = [];
73
73
  const closed = [];
74
74
  const claimed = new Set();
@@ -79,8 +79,9 @@ watched = true, columns = DEFAULT_COLUMNS) {
79
79
  const flags = [];
80
80
  if (isStale(derived, now))
81
81
  flags.push("stale");
82
- if (watched && isNotStarted(derived, blockers.get(issue.number) ?? [], now))
83
- flags.push("not started, is the poller running?");
82
+ if (watch &&
83
+ isNotStarted(derived, blockers.get(issue.number) ?? [], now, watch.minutes))
84
+ flags.push(watch.flag);
84
85
  const row = {
85
86
  number: issue.number,
86
87
  kind: "issue",
@@ -404,7 +405,7 @@ async function snapshotLines(source, target, now, hook, style = PLAIN) {
404
405
  const list = await source.tickets.blockers.list(issue.number);
405
406
  blockers.set(issue.number, list.filter((b) => b.state === "open").map((b) => b.number));
406
407
  }
407
- return formatRows(toRows(snapshot, board, blockers, now, target.watched, target.columns), now, !hook, { ...style, links, columns: target.columns });
408
+ return formatRows(toRows(snapshot, board, blockers, now, target.watch, target.columns), now, !hook, { ...style, links, columns: target.columns });
408
409
  }
409
410
  const WATCH_MS = 15_000;
410
411
  // The alternate screen with the cursor hidden, and back.
package/dist/sync.d.mts CHANGED
@@ -8,10 +8,20 @@ export declare const CLAUDE_MD = "CLAUDE.md";
8
8
  export declare const IMPORT_LINE = "@.claude/factory/rules.md";
9
9
  /** Whether the repository has a file, by its path from the root. */
10
10
  type Has = (path: string) => boolean;
11
+ /** The scheduled poller's workflow, its one `cron` line set to run every
12
+ * `minutes`: on the hour for 60, every N minutes past it otherwise. */
13
+ export declare function withSchedule(text: string, minutes: number, file: string): string;
14
+ /** A workflow with the one `branches:` line of its push trigger naming the
15
+ * default branch and nothing else. */
16
+ export declare function withDefaultBranch(text: string, name: string, file: string): string;
11
17
  /** A session workflow with the minutes its session may run, and its job 10
12
18
  * more, so the steps after the session still run before the job is
13
19
  * stopped. */
14
20
  export declare function withMinutes(text: string, minutes: number, file: string): string;
21
+ /** A copy with the rules' numbers the settings give in place of the
22
+ * defaults. A phrase is replaced only when its number is not the default,
23
+ * and must then match exactly once. */
24
+ export declare function withRules(text: string, r: Settings["rules"], file: string): string;
15
25
  /** Each copy, as [path in the package, path in the repository]. */
16
26
  export declare function copies(pkg: string, s: Settings, has: Has): [string, string][];
17
27
  /** The launcher's path from the repository's root: the root's own, where
@@ -35,8 +45,19 @@ export declare function factoryHooks(launcher: string): [string, HookGroup][];
35
45
  * replaced by the five above, and attribution turned off unless the file
36
46
  * sets its own. Every other entry stays, in its order. */
37
47
  export declare function withHooks(text: string | null, launcher: string): string;
48
+ /** Whether every event of the five has the factory's entry. */
49
+ export declare function hasFactoryHooks(text: string | null): boolean;
50
+ /** Whether any hook entry is the factory's. */
51
+ export declare function hasAnyFactoryHook(text: string | null): boolean;
52
+ /** `.claude/settings.json` with the factory's entries taken out and an
53
+ * emptied `hooks` dropped, or null when nothing is left. */
54
+ export declare function withoutHooks(text: string): string | null;
55
+ export declare const hasImport: (text: string | null) => boolean;
38
56
  /** `CLAUDE.md` with the rules' import added when no line is that import. */
39
57
  export declare function withImport(text: string | null): string;
58
+ /** `CLAUDE.md` without the rules' import, nor the blank line `withImport`
59
+ * put before it, or null when nothing else is left. */
60
+ export declare function withoutImport(text: string): string | null;
40
61
  export declare function lockText(version: string, files: string[]): string;
41
62
  export declare function lockedFiles(text: string | null): string[];
42
63
  export type Plan = {
@@ -45,14 +66,17 @@ export type Plan = {
45
66
  /** Paths the lock lists that this version no longer writes. */
46
67
  remove: string[];
47
68
  };
48
- /** What a sync of `root` from `pkg` writes and deletes. */
49
- export declare function plan(pkg: string, root: string, s: Settings): Plan;
69
+ /** What a sync of `root` from `pkg` writes and deletes, in a repository
70
+ * whose default branch is `branch`. */
71
+ export declare function plan(pkg: string, root: string, s: Settings, branch: string): Plan;
50
72
  /** The paths whose content a sync would change, in the plan's order. */
51
73
  export declare function differences(root: string, p: Plan): string[];
52
74
  export declare function main(argv: string[], d: {
53
75
  root: string;
54
76
  pkg: string;
55
77
  settings: () => Promise<Settings>;
78
+ /** The repository's default branch, or null when it cannot be told. */
79
+ defaultBranch: () => Promise<string | null>;
56
80
  out: (line: string) => void;
57
81
  err: (line: string) => void;
58
82
  }): Promise<number>;