@davidbyoung/software-factory 0.1.5 → 0.1.6
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 +9 -8
- package/dist/cli.mjs +12 -0
- package/dist/config.d.mts +57 -3
- package/dist/config.mjs +268 -18
- package/dist/deps.d.mts +6 -4
- package/dist/deps.mjs +29 -7
- package/dist/doctor.d.mts +3 -0
- package/dist/doctor.mjs +7 -4
- package/dist/explain.d.mts +12 -1
- package/dist/explain.mjs +47 -32
- package/dist/init.mjs +6 -4
- package/dist/lib/default-branch.d.mts +1 -1
- package/dist/lib/default-branch.mjs +2 -2
- package/dist/preset-commands.d.mts +65 -0
- package/dist/preset-commands.mjs +1148 -0
- package/dist/preset.d.mts +169 -0
- package/dist/preset.mjs +550 -0
- package/dist/remove.mjs +34 -1
- package/dist/session-start.d.mts +3 -0
- package/dist/session-start.mjs +12 -1
- package/dist/sync.d.mts +42 -7
- package/dist/sync.mjs +165 -31
- package/docs/builds.md +12 -11
- package/docs/cli.md +21 -2
- package/docs/configuration.md +65 -13
- package/docs/developing.md +9 -2
- package/docs/github/by-hand.md +5 -5
- package/docs/github/reference.md +2 -17
- package/docs/github/setup.md +1 -1
- package/docs/glossary.md +12 -2
- package/docs/limitations.md +3 -0
- package/docs/plugins.md +16 -5
- package/docs/presets.md +410 -0
- package/docs/quick-start.md +20 -17
- package/docs/skills.md +21 -16
- package/docs/updating.md +14 -7
- package/docs/workflow.md +12 -13
- package/package.json +1 -1
- package/settings.schema.json +52 -3
- package/skills/factory-deps/SKILL.md +23 -12
- package/skills/factory-design/SKILL.md +1 -1
- package/skills/factory-resolve-conflicts/SKILL.md +6 -0
- package/workflows/factory-claude-review.yml +7 -2
package/dist/explain.mjs
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
// `factory config explain`: the settings as `.claude/factory.yaml` would
|
|
2
|
-
// read with every default written out, each line
|
|
3
|
-
//
|
|
2
|
+
// read with every default written out, each line marked with where its
|
|
3
|
+
// value came from: `# default`, a preset's name, or nothing for a value
|
|
4
|
+
// only `.claude/factory.yaml` sets. `factory sync` writes the same lines
|
|
5
|
+
// into the lock.
|
|
4
6
|
import { PHASES, pluginsOf, ROLE_SHAPE, ROLES, } from "./config.mjs";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
7
|
+
import { itemKey, markText } from "./preset.mjs";
|
|
8
|
+
/** The marks of the values a resolution combined. */
|
|
9
|
+
export function markerOf(r) {
|
|
10
|
+
const at = (key) => r.sources.get(key) ?? r.sources.get(`${key}.type`);
|
|
11
|
+
return {
|
|
12
|
+
value: (path) => markText(at(path.join("."))),
|
|
13
|
+
item: (path, item) => {
|
|
14
|
+
const key = path.join(".");
|
|
15
|
+
return markText(r.sources.get(itemKey(key, item)) ?? at(key));
|
|
16
|
+
},
|
|
17
|
+
plugin: (path, name) => markText(r.sources.get(`${path.join(".")}.${name}`)),
|
|
18
|
+
};
|
|
18
19
|
}
|
|
20
|
+
/** The value lists that add up across layers, whose items each carry
|
|
21
|
+
* their own mark. */
|
|
22
|
+
const ADDS_UP = new Set([
|
|
23
|
+
"pr-review.commands",
|
|
24
|
+
"auto-merge.allow",
|
|
25
|
+
"auto-merge.deny",
|
|
26
|
+
"auto-merge.commands",
|
|
27
|
+
"site.pages",
|
|
28
|
+
"site.widths",
|
|
29
|
+
"site.checks",
|
|
30
|
+
"site.hide",
|
|
31
|
+
]);
|
|
19
32
|
/** `exists` says whether a path from the root exists, for the plugins the
|
|
20
33
|
* factory uses where the settings name none. */
|
|
21
|
-
export async function explainLines(s,
|
|
34
|
+
export async function explainLines(s, marks, exists) {
|
|
22
35
|
const { stringify } = await import("yaml");
|
|
23
36
|
const value = (v) => stringify(v, { lineWidth: 0 }).trim();
|
|
24
37
|
const lines = [];
|
|
@@ -26,20 +39,21 @@ export async function explainLines(s, raw, exists) {
|
|
|
26
39
|
/** One key, its value printed under it when it is a list or a block. */
|
|
27
40
|
const put = (path, v, depth = path.length - 1) => {
|
|
28
41
|
const key = path.at(-1);
|
|
29
|
-
const
|
|
42
|
+
const mark = marks.value(path);
|
|
30
43
|
if (Array.isArray(v) && v.length && typeof v[0] !== "object") {
|
|
31
|
-
|
|
44
|
+
const each = ADDS_UP.has(path.join("."));
|
|
45
|
+
lines.push({ text: `${pad(depth)}${key}:`, mark });
|
|
32
46
|
for (const item of v)
|
|
33
|
-
lines.push({
|
|
47
|
+
lines.push({
|
|
48
|
+
text: `${pad(depth + 1)}- ${value(item)}`,
|
|
49
|
+
mark: each ? marks.item(path, item) : mark,
|
|
50
|
+
});
|
|
34
51
|
return;
|
|
35
52
|
}
|
|
36
|
-
lines.push({ text: `${pad(depth)}${key}: ${value(v)}`,
|
|
53
|
+
lines.push({ text: `${pad(depth)}${key}: ${value(v)}`, mark });
|
|
37
54
|
};
|
|
38
|
-
const block = (path) => lines.push({
|
|
39
|
-
|
|
40
|
-
byDefault: false,
|
|
41
|
-
});
|
|
42
|
-
const comment = (depth, text) => lines.push({ text: `${pad(depth)}# ${text}`, byDefault: false });
|
|
55
|
+
const block = (path) => lines.push({ text: `${pad(path.length - 1)}${path.at(-1)}:`, mark: null });
|
|
56
|
+
const comment = (depth, text) => lines.push({ text: `${pad(depth)}# ${text}`, mark: null });
|
|
43
57
|
put(["version"], s.version);
|
|
44
58
|
put(["repository"], s.repository);
|
|
45
59
|
block(["tickets"]);
|
|
@@ -109,10 +123,11 @@ export async function explainLines(s, raw, exists) {
|
|
|
109
123
|
comment(2, `${key}: none (default)`);
|
|
110
124
|
continue;
|
|
111
125
|
}
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
add(2, `${key}:`);
|
|
126
|
+
const roleMark = marks.value(path);
|
|
127
|
+
lines.push({ text: `${pad(2)}${key}:`, mark: roleMark });
|
|
115
128
|
for (const p of found) {
|
|
129
|
+
const mark = list ? marks.plugin(path, p.name) : marks.value(path);
|
|
130
|
+
const add = (depth, text) => lines.push({ text: `${pad(depth)}${text}`, mark });
|
|
116
131
|
add(3, `${list ? "- " : ""}${p.kind}: ${value(p.name)}`);
|
|
117
132
|
const under = list ? 4 : 3;
|
|
118
133
|
for (const [k, items] of [
|
|
@@ -166,9 +181,9 @@ export async function explainLines(s, raw, exists) {
|
|
|
166
181
|
block(["rules"]);
|
|
167
182
|
put(["rules", "small-change-lines"], s.rules.smallChangeLines);
|
|
168
183
|
put(["rules", "review-rounds"], s.rules.reviewRounds);
|
|
169
|
-
// Each
|
|
170
|
-
//
|
|
171
|
-
const marked = lines.filter((l) => l.
|
|
184
|
+
// Each mark lines up with the others, two spaces past the longest line
|
|
185
|
+
// that carries one.
|
|
186
|
+
const marked = lines.filter((l) => l.mark !== null);
|
|
172
187
|
const at = Math.max(0, ...marked.map((l) => l.text.length)) + 2;
|
|
173
|
-
return lines.map((l) => l.
|
|
188
|
+
return lines.map((l) => l.mark !== null ? `${l.text.padEnd(at)}# ${l.mark}` : l.text);
|
|
174
189
|
}
|
package/dist/init.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { dirname, join } from "node:path";
|
|
|
13
13
|
import { isMap, parseDocument } from "yaml";
|
|
14
14
|
import { builtOf, secretSteps, TOOLS, } from "./tools.mjs";
|
|
15
15
|
import { NeedsScopeError } from "./code-host/types.mjs";
|
|
16
|
-
import { columnsOf, fieldNamesOf, parseSettings, POLL_MINUTES, repoRoot, SETTINGS_FILE, SettingsError, } from "./config.mjs";
|
|
16
|
+
import { columnsOf, fieldNamesOf, filesDeps, parseSettings, resolveFiles, POLL_MINUTES, repoRoot, SETTINGS_FILE, SettingsError, } from "./config.mjs";
|
|
17
17
|
import { checks as doctorChecks, doctorDeps, line } from "./doctor.mjs";
|
|
18
18
|
import { branchDeps, needDefaultBranch, NoDefaultBranch, } from "./lib/default-branch.mjs";
|
|
19
19
|
import { hasCommand, noTerminal } from "./lib/has-command.mjs";
|
|
@@ -557,10 +557,12 @@ export async function run(argv) {
|
|
|
557
557
|
// The settings are not written yet, so the code host asked is the one
|
|
558
558
|
// setup has just opened, not the one a settings file names.
|
|
559
559
|
syncChanges: async (text, host) => {
|
|
560
|
-
const
|
|
561
|
-
|
|
560
|
+
const r = await resolveFiles({
|
|
561
|
+
...filesDeps(root),
|
|
562
|
+
readFile: () => text,
|
|
563
|
+
});
|
|
562
564
|
const branch = await needDefaultBranch({ ...branchDeps(root), host });
|
|
563
|
-
return differences(root, syncPlan(PACKAGE, root,
|
|
565
|
+
return differences(root, await syncPlan(PACKAGE, root, r, branch));
|
|
564
566
|
},
|
|
565
567
|
interactive: async (argv2) => spawnSync(argv2[0], argv2.slice(1), { stdio: "inherit" }).status ?? 1,
|
|
566
568
|
hasCommand,
|
|
@@ -29,7 +29,7 @@ export declare function needDefaultBranch(d: Deps, sources?: Sources): Promise<s
|
|
|
29
29
|
/** The sources of the checkout at `root`. The code host is the one the
|
|
30
30
|
* checkout's settings name, and is loaded only when it is asked, so a
|
|
31
31
|
* caller that runs before every command stays quick. */
|
|
32
|
-
export declare const branchDeps: (root: string, env?: Record<string, string | undefined>) => Deps;
|
|
32
|
+
export declare const branchDeps: (root: string, env?: Record<string, string | undefined>, settings?: () => Promise<import("../config.mts").Settings>) => Deps;
|
|
33
33
|
export declare function main(argv: string[], d: Deps, out: (line: string) => void, err: (line: string) => void): Promise<number>;
|
|
34
34
|
/** `factory default-branch`. */
|
|
35
35
|
export declare function run(argv: string[]): Promise<number>;
|
|
@@ -86,14 +86,14 @@ export async function needDefaultBranch(d, sources = "all") {
|
|
|
86
86
|
/** The sources of the checkout at `root`. The code host is the one the
|
|
87
87
|
* checkout's settings name, and is loaded only when it is asked, so a
|
|
88
88
|
* caller that runs before every command stays quick. */
|
|
89
|
-
export const branchDeps = (root, env = process.env) => ({
|
|
89
|
+
export const branchDeps = (root, env = process.env, settings) => ({
|
|
90
90
|
env,
|
|
91
91
|
readFile: (path) => readFileSync(path, "utf8"),
|
|
92
92
|
git: gitIn(root),
|
|
93
93
|
host: async () => {
|
|
94
94
|
const { defaultDeps, loadSettings, reachOf } = await import("../config.mjs");
|
|
95
95
|
const { openCodeHost } = await import("../code-host/index.mjs");
|
|
96
|
-
const { repository, codeHost } = await reachOf(env, () => loadSettings(defaultDeps(root)));
|
|
96
|
+
const { repository, codeHost } = await reachOf(env, settings ?? (() => loadSettings(defaultDeps(root))));
|
|
97
97
|
return openCodeHost(repository, codeHost).defaultBranch();
|
|
98
98
|
},
|
|
99
99
|
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Resolved } from "./config.mts";
|
|
2
|
+
import type { Check } from "./setup.mts";
|
|
3
|
+
export type PresetDeps = {
|
|
4
|
+
root: string;
|
|
5
|
+
/** Where `preset check` looks for a package, the folder it runs in. */
|
|
6
|
+
cwd: string;
|
|
7
|
+
out: (line: string) => void;
|
|
8
|
+
err: (line: string) => void;
|
|
9
|
+
/** Whether the questions can be asked. */
|
|
10
|
+
terminal: boolean;
|
|
11
|
+
/** Asks one question and gives the answer typed. */
|
|
12
|
+
ask: (question: string) => Promise<string>;
|
|
13
|
+
/** Runs npm with these arguments in the root. */
|
|
14
|
+
npm: (args: string[]) => {
|
|
15
|
+
status: number;
|
|
16
|
+
stdout: string;
|
|
17
|
+
stderr: string;
|
|
18
|
+
};
|
|
19
|
+
/** Runs `factory sync`, giving each line it prints to `out`. */
|
|
20
|
+
sync: (out: (line: string) => void) => Promise<number>;
|
|
21
|
+
/** A file's text at a git revision, or null when it has none there. */
|
|
22
|
+
show: (ref: string, path: string) => string | null;
|
|
23
|
+
/** The settings resolved from the files, as `factory sync` resolves them,
|
|
24
|
+
* with `.claude/factory.yaml` and the choices file as given. */
|
|
25
|
+
resolve: (own: string, choices: string | null) => Promise<Resolved>;
|
|
26
|
+
write: (path: string, text: string | null) => void;
|
|
27
|
+
read: (path: string) => string | null;
|
|
28
|
+
};
|
|
29
|
+
/** A value as the summaries show it: a list's items joined, a plugin by its
|
|
30
|
+
* name. */
|
|
31
|
+
export declare function show(v: unknown): string;
|
|
32
|
+
/** npm's failure in the factory's words. */
|
|
33
|
+
export declare function installError(name: string, stderr: string, registry: string): string[];
|
|
34
|
+
/** Whether a group in `.github/dependabot.yml` has the package as its only
|
|
35
|
+
* pattern. */
|
|
36
|
+
export declare function hasOwnGroup(text: string | null, pkg: string): Promise<boolean>;
|
|
37
|
+
/** The registry `.npmrc` sends a package's scope to, or null. */
|
|
38
|
+
export declare function npmrcRegistry(text: string | null, pkg: string): string | null;
|
|
39
|
+
/** The lines `preset add` ends with for what Dependabot still needs. */
|
|
40
|
+
export declare function nextLines(dependabot: string | null, npmrc: string | null, pkg: string): Promise<string[]>;
|
|
41
|
+
export declare function add(argv: string[], d: PresetDeps): Promise<number>;
|
|
42
|
+
export declare function remove(argv: string[], d: PresetDeps): Promise<number>;
|
|
43
|
+
export declare function choices(_argv: string[], d: PresetDeps): Promise<number>;
|
|
44
|
+
export declare function chooseOne(argv: string[], d: PresetDeps): Promise<number>;
|
|
45
|
+
export declare function check(_argv: string[], d: PresetDeps): Promise<number>;
|
|
46
|
+
type Mark = {
|
|
47
|
+
from: string;
|
|
48
|
+
state?: "chosen" | "not-chosen";
|
|
49
|
+
};
|
|
50
|
+
/** A mark's text read back: who a value came from, and whether it was
|
|
51
|
+
* chosen. No mark is `.claude/factory.yaml`'s own. */
|
|
52
|
+
export declare function readMark(text: string | undefined | null): Mark;
|
|
53
|
+
/** Each setting's mark in a lock, by the key `combine` gives it. */
|
|
54
|
+
export declare function lockMarks(text: string): Promise<Map<string, Mark>>;
|
|
55
|
+
/** `factory preset changes REF`: what the presets' update changed here,
|
|
56
|
+
* as `factory-deps` comments it. */
|
|
57
|
+
export declare function changes(argv: string[], d: PresetDeps): Promise<number>;
|
|
58
|
+
/** Doctor's lines for the lock and the presets it records. */
|
|
59
|
+
export declare function presetChecks(root: string, stale: string | null): Promise<Check[]>;
|
|
60
|
+
export declare function main(argv: string[], d: PresetDeps): Promise<number>;
|
|
61
|
+
/** The preset commands' dependencies in the repository at `root`. */
|
|
62
|
+
export declare function presetDeps(root?: string): PresetDeps;
|
|
63
|
+
/** `factory preset ...`. */
|
|
64
|
+
export declare function run(argv: string[]): Promise<number>;
|
|
65
|
+
export {};
|