@granular-software/fractory 0.0.0-stage → 0.1.25
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 +4 -0
- package/README.md +28 -2
- package/dist/activity-volume.d.ts +18 -0
- package/dist/activity-volume.js +94 -0
- package/dist/annotations.d.ts +122 -0
- package/dist/annotations.js +304 -0
- package/dist/benchmark-cli.d.ts +1 -0
- package/dist/benchmark-cli.js +95 -0
- package/dist/benchmark-worker.d.ts +2 -0
- package/dist/benchmark-worker.js +22 -0
- package/dist/benchmarks.d.ts +19 -0
- package/dist/benchmarks.js +414 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +63 -0
- package/dist/block-cli.d.ts +1 -0
- package/dist/block-cli.js +88 -0
- package/dist/block-documents.d.ts +35 -0
- package/dist/block-documents.js +84 -0
- package/dist/change-impact.d.ts +55 -0
- package/dist/change-impact.js +223 -0
- package/dist/check-source.d.ts +2 -0
- package/dist/check-source.js +66 -0
- package/dist/checks-model.d.ts +64 -0
- package/dist/checks-model.js +36 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +359 -0
- package/dist/code-model.d.ts +38 -0
- package/dist/code-model.js +94 -0
- package/dist/code-store.d.ts +9 -0
- package/dist/code-store.js +79 -0
- package/dist/compare-artifact.d.ts +6 -0
- package/dist/compare-artifact.js +277 -0
- package/dist/compare.d.ts +81 -0
- package/dist/compare.js +291 -0
- package/dist/compiler.d.ts +10 -0
- package/dist/compiler.js +1240 -0
- package/dist/compose.d.ts +9 -0
- package/dist/compose.js +72 -0
- package/dist/core.d.ts +87 -0
- package/dist/core.js +207 -0
- package/dist/coverage-cli.d.ts +1 -0
- package/dist/coverage-cli.js +42 -0
- package/dist/declaration-sources.d.ts +3 -0
- package/dist/declaration-sources.js +51 -0
- package/dist/declared-graph.d.ts +3 -0
- package/dist/declared-graph.js +67 -0
- package/dist/display-name.d.ts +2 -0
- package/dist/display-name.js +8 -0
- package/dist/error-heat.d.ts +58 -0
- package/dist/error-heat.js +96 -0
- package/dist/evidence.d.ts +3 -0
- package/dist/evidence.js +68 -0
- package/dist/factory-graph.d.ts +7 -0
- package/dist/factory-graph.js +389 -0
- package/dist/factory-model.d.ts +111 -0
- package/dist/factory-model.js +1 -0
- package/dist/git-code.d.ts +47 -0
- package/dist/git-code.js +352 -0
- package/dist/git-refs.d.ts +4 -0
- package/dist/git-refs.js +37 -0
- package/dist/history-activity.d.ts +4 -0
- package/dist/history-activity.js +129 -0
- package/dist/history-churn.d.ts +36 -0
- package/dist/history-churn.js +302 -0
- package/dist/history-git.d.ts +21 -0
- package/dist/history-git.js +125 -0
- package/dist/history-ledger.d.ts +43 -0
- package/dist/history-ledger.js +450 -0
- package/dist/history-ownership.d.ts +10 -0
- package/dist/history-ownership.js +75 -0
- package/dist/history-source.d.ts +13 -0
- package/dist/history-source.js +100 -0
- package/dist/integrations-cli.d.ts +2 -0
- package/dist/integrations-cli.js +159 -0
- package/dist/interface-map.d.ts +15 -0
- package/dist/interface-map.js +125 -0
- package/dist/issue-cache.d.ts +9 -0
- package/dist/issue-cache.js +68 -0
- package/dist/issue-cli.d.ts +1 -0
- package/dist/issue-cli.js +89 -0
- package/dist/issue-links.d.ts +15 -0
- package/dist/issue-links.js +125 -0
- package/dist/linear-issues.d.ts +19 -0
- package/dist/linear-issues.js +124 -0
- package/dist/local-runtime.d.ts +8 -0
- package/dist/local-runtime.js +59 -0
- package/dist/map-activity.d.ts +73 -0
- package/dist/map-activity.js +234 -0
- package/dist/map-model.d.ts +5 -0
- package/dist/map-model.js +166 -0
- package/dist/map-quality.d.ts +20 -0
- package/dist/map-quality.js +61 -0
- package/dist/mapping-coverage.d.ts +87 -0
- package/dist/mapping-coverage.js +404 -0
- package/dist/model.d.ts +186 -0
- package/dist/model.js +66 -0
- package/dist/operation-benchmark-worker.d.ts +2 -0
- package/dist/operation-benchmark-worker.js +60 -0
- package/dist/operation-benchmark.d.ts +29 -0
- package/dist/operation-benchmark.js +1 -0
- package/dist/otel-metrics.d.ts +21 -0
- package/dist/otel-metrics.js +146 -0
- package/dist/performance-model.d.ts +185 -0
- package/dist/performance-model.js +396 -0
- package/dist/product-map.d.ts +71 -0
- package/dist/product-map.js +197 -0
- package/dist/provider-access.cjs +207 -0
- package/dist/provider-access.d.cts +14 -0
- package/dist/public-boundaries.d.ts +13 -0
- package/dist/public-boundaries.js +115 -0
- package/dist/reports-cli.d.ts +1 -0
- package/dist/reports-cli.js +111 -0
- package/dist/reports-model.d.ts +27 -0
- package/dist/reports-model.js +39 -0
- package/dist/reports.d.ts +23 -0
- package/dist/reports.js +223 -0
- package/dist/repository-map.d.ts +22 -0
- package/dist/repository-map.js +153 -0
- package/dist/resource-cache.d.ts +17 -0
- package/dist/resource-cache.js +65 -0
- package/dist/review-cli.d.ts +19 -0
- package/dist/review-cli.js +224 -0
- package/dist/review.d.ts +48 -0
- package/dist/review.js +289 -0
- package/dist/runtime-metrics.d.ts +26 -0
- package/dist/runtime-metrics.js +290 -0
- package/dist/scope.d.ts +14 -0
- package/dist/scope.js +168 -0
- package/dist/sentry-activity.d.ts +39 -0
- package/dist/sentry-activity.js +174 -0
- package/dist/sentry.d.ts +130 -0
- package/dist/sentry.js +369 -0
- package/dist/service-release.d.ts +16 -0
- package/dist/service-release.js +14 -0
- package/dist/setup-cli.d.ts +2 -0
- package/dist/setup-cli.js +52 -0
- package/dist/setup-kit.cjs +163 -0
- package/dist/setup-kit.d.cts +32 -0
- package/dist/source-index.d.ts +37 -0
- package/dist/source-index.js +170 -0
- package/dist/source-review-git.d.ts +7 -0
- package/dist/source-review-git.js +105 -0
- package/dist/source-review.d.ts +18 -0
- package/dist/source-review.js +573 -0
- package/dist/telemetry.d.ts +17 -0
- package/dist/telemetry.js +51 -0
- package/dist/time-window.d.ts +9 -0
- package/dist/time-window.js +35 -0
- package/dist/trace-evidence.d.ts +23 -0
- package/dist/trace-evidence.js +55 -0
- package/dist/trace-model.d.ts +26 -0
- package/dist/trace-model.js +1 -0
- package/dist/tracing.d.ts +44 -0
- package/dist/tracing.js +123 -0
- package/dist/work-check.d.ts +18 -0
- package/dist/work-check.js +115 -0
- package/dist/work-cli.d.ts +1 -0
- package/dist/work-cli.js +176 -0
- package/dist/work-context.d.ts +59 -0
- package/dist/work-context.js +594 -0
- package/dist/work-intents.d.ts +6 -0
- package/dist/work-intents.js +140 -0
- package/dist/work-items.d.ts +58 -0
- package/dist/work-items.js +86 -0
- package/dist/work-lock-check.d.ts +12 -0
- package/dist/work-lock-check.js +339 -0
- package/dist/work-locks.d.ts +10 -0
- package/dist/work-locks.js +98 -0
- package/dist/work-model.d.ts +119 -0
- package/dist/work-model.js +310 -0
- package/dist/work-review-git.d.ts +8 -0
- package/dist/work-review-git.js +111 -0
- package/dist/work-review.d.ts +26 -0
- package/dist/work-review.js +426 -0
- package/dist/work-switcher-model.d.ts +43 -0
- package/dist/work-switcher-model.js +79 -0
- package/dist/work-switcher.d.ts +6 -0
- package/dist/work-switcher.js +171 -0
- package/dist/working-cli.d.ts +1 -0
- package/dist/working-cli.js +33 -0
- package/dist/working-code.d.ts +74 -0
- package/dist/working-code.js +421 -0
- package/dist/workspace-notes.d.ts +71 -0
- package/dist/workspace-notes.js +177 -0
- package/dist/workspace-tests.d.ts +21 -0
- package/dist/workspace-tests.js +573 -0
- package/package.json +547 -4
- package/src/activity-volume.ts +149 -0
- package/src/annotations.ts +485 -0
- package/src/benchmark-cli.ts +118 -0
- package/src/benchmark-worker.ts +22 -0
- package/src/benchmarks.ts +493 -0
- package/src/bin.ts +54 -0
- package/src/block-cli.ts +106 -0
- package/src/block-documents.ts +117 -0
- package/src/change-impact.ts +280 -0
- package/src/check-source.ts +82 -0
- package/src/checks-model.ts +108 -0
- package/src/cli.ts +440 -0
- package/src/code-model.ts +159 -0
- package/src/code-store.ts +98 -0
- package/src/compare-artifact.ts +314 -0
- package/src/compare.ts +440 -0
- package/src/compiler.ts +1512 -0
- package/src/compose.ts +94 -0
- package/src/core.ts +361 -0
- package/src/coverage-cli.ts +52 -0
- package/src/declaration-sources.ts +69 -0
- package/src/declared-graph.ts +75 -0
- package/src/display-name.ts +8 -0
- package/src/error-heat.ts +161 -0
- package/src/evidence.ts +94 -0
- package/src/factory-graph.ts +462 -0
- package/src/factory-model.ts +82 -0
- package/src/git-code.ts +461 -0
- package/src/git-refs.ts +43 -0
- package/src/history-activity.ts +146 -0
- package/src/history-churn.ts +416 -0
- package/src/history-git.ts +163 -0
- package/src/history-ledger.ts +636 -0
- package/src/history-ownership.ts +116 -0
- package/src/history-source.ts +117 -0
- package/src/integrations-cli.ts +187 -0
- package/src/interface-map.ts +166 -0
- package/src/issue-cache.ts +96 -0
- package/src/issue-cli.ts +137 -0
- package/src/issue-links.ts +153 -0
- package/src/linear-issues.ts +154 -0
- package/src/local-runtime.ts +70 -0
- package/src/map-activity.ts +309 -0
- package/src/map-model.ts +213 -0
- package/src/map-quality.ts +66 -0
- package/src/mapping-coverage.ts +570 -0
- package/src/model.ts +228 -0
- package/src/operation-benchmark-worker.ts +60 -0
- package/src/operation-benchmark.ts +28 -0
- package/src/otel-metrics.ts +176 -0
- package/src/performance-model.ts +575 -0
- package/src/product-map.ts +271 -0
- package/src/provider-access.cjs +207 -0
- package/src/provider-access.d.cts +14 -0
- package/src/public-boundaries.ts +143 -0
- package/src/reports-cli.ts +125 -0
- package/src/reports-model.ts +73 -0
- package/src/reports.ts +276 -0
- package/src/repository-map.ts +191 -0
- package/src/resource-cache.ts +76 -0
- package/src/review-cli.ts +256 -0
- package/src/review.ts +376 -0
- package/src/runtime-metrics.ts +386 -0
- package/src/scope.ts +192 -0
- package/src/sentry-activity.ts +234 -0
- package/src/sentry.ts +545 -0
- package/src/service-release.ts +18 -0
- package/src/setup-cli.ts +58 -0
- package/src/setup-kit.cjs +163 -0
- package/src/setup-kit.d.cts +32 -0
- package/src/source-index.ts +208 -0
- package/src/source-review-git.ts +131 -0
- package/src/source-review.ts +736 -0
- package/src/telemetry.ts +68 -0
- package/src/time-window.ts +51 -0
- package/src/trace-evidence.ts +80 -0
- package/src/trace-model.ts +26 -0
- package/src/tracing.ts +165 -0
- package/src/work-check.ts +149 -0
- package/src/work-cli.ts +229 -0
- package/src/work-context.ts +753 -0
- package/src/work-intents.ts +196 -0
- package/src/work-items.ts +151 -0
- package/src/work-lock-check.ts +549 -0
- package/src/work-locks.ts +108 -0
- package/src/work-model.ts +466 -0
- package/src/work-review-git.ts +130 -0
- package/src/work-review.ts +573 -0
- package/src/work-switcher-model.ts +121 -0
- package/src/work-switcher.ts +191 -0
- package/src/working-cli.ts +38 -0
- package/src/working-code.ts +582 -0
- package/src/workspace-notes.ts +203 -0
- package/src/workspace-tests.ts +654 -0
- package/toolkit/GUIDE.md +354 -0
- package/toolkit/SKILL.md +142 -0
- package/toolkit/bin/fractory +2 -0
- package/toolkit/build.json +1 -0
package/src/work-cli.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
createWorkContext,
|
|
6
|
+
adoptWorkContext,
|
|
7
|
+
listWorkContexts,
|
|
8
|
+
mainReference,
|
|
9
|
+
readFactoryMap,
|
|
10
|
+
resolveWorkContext,
|
|
11
|
+
updateWorkPlan,
|
|
12
|
+
workBaseline,
|
|
13
|
+
workDeepLink,
|
|
14
|
+
workHandoff,
|
|
15
|
+
updateWorkIntent,
|
|
16
|
+
} from "./work-context";
|
|
17
|
+
import { lockBrief } from "./work-locks";
|
|
18
|
+
import { workIntentStates } from "./work-intents";
|
|
19
|
+
import { readGit } from "./git-refs";
|
|
20
|
+
import { checkWorkScope } from "./work-check";
|
|
21
|
+
|
|
22
|
+
export async function runWork(args: string[]) {
|
|
23
|
+
if (args.includes("--help"))
|
|
24
|
+
return `fractory work list\nfractory work create --title TITLE --block ID [--block ID] [--from REF]\nfractory work adopt ID --block ID [--block ID] [--title TITLE]\nfractory work show ID\nfractory work handoff ID\nfractory work open ID\nfractory work plan ID --file PLAN.json --revision REVISION\nfractory work check ID\nfractory work lock ID --block BLOCK_ID --revision REVISION [--note REASON]\nfractory work unlock ID --block BLOCK_ID --revision REVISION\nfractory work review ID\nfractory work intent ID --proposal PROPOSAL_ID --status planned|done|dropped --revision REV [--implementation BLOCK_OR_CONNECTION_ID]\nfractory work pr ID --url URL --title TITLE\nUse --root PATH to select a repository. Creating a work adds a worktree; it never switches the current checkout. Plan JSON contains a proposals array and optional scope. Shared or unknown file ownership makes check fail.`;
|
|
25
|
+
const option = (name: string) => {
|
|
26
|
+
const i = args.indexOf(name);
|
|
27
|
+
if (i < 0) return undefined;
|
|
28
|
+
if (!args[i + 1] || args[i + 1].startsWith("--"))
|
|
29
|
+
throw Error(`${name} needs a value.`);
|
|
30
|
+
return args[i + 1];
|
|
31
|
+
};
|
|
32
|
+
const root = readGit(resolve(option("--root") || process.cwd()), [
|
|
33
|
+
"rev-parse",
|
|
34
|
+
"--show-toplevel",
|
|
35
|
+
]).trim();
|
|
36
|
+
const action = args[1] || "list";
|
|
37
|
+
if (action === "list")
|
|
38
|
+
return JSON.stringify(
|
|
39
|
+
{ main: mainReference(root), targets: listWorkContexts(root) },
|
|
40
|
+
null,
|
|
41
|
+
2,
|
|
42
|
+
);
|
|
43
|
+
if (action === "create") {
|
|
44
|
+
const graph = await readFactoryMap(root);
|
|
45
|
+
if (!graph)
|
|
46
|
+
throw Error("Map this repository before starting block-scoped work.");
|
|
47
|
+
const scope = args.flatMap((value, index) =>
|
|
48
|
+
value === "--block" ? [args[index + 1]] : [],
|
|
49
|
+
);
|
|
50
|
+
const work = await createWorkContext(root, graph, {
|
|
51
|
+
title: option("--title") || "",
|
|
52
|
+
scope,
|
|
53
|
+
from: option("--from"),
|
|
54
|
+
});
|
|
55
|
+
return JSON.stringify(
|
|
56
|
+
{
|
|
57
|
+
...work,
|
|
58
|
+
url: workDeepLink(root, work.id),
|
|
59
|
+
handoff: workHandoff(work, graph),
|
|
60
|
+
},
|
|
61
|
+
null,
|
|
62
|
+
2,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const id = args[2];
|
|
66
|
+
if (!id || id.startsWith("--"))
|
|
67
|
+
throw Error("Choose a work context from fractory work list.");
|
|
68
|
+
let work = resolveWorkContext(root, id);
|
|
69
|
+
const graph =
|
|
70
|
+
(await readFactoryMap(work.root)) ||
|
|
71
|
+
(work.plan ? workBaseline(root, id) : await readFactoryMap(root));
|
|
72
|
+
if (!graph) throw Error("No factory map is available for this work context.");
|
|
73
|
+
if (action === "adopt") {
|
|
74
|
+
const scope = args.flatMap((value, index) =>
|
|
75
|
+
value === "--block" ? [args[index + 1]] : [],
|
|
76
|
+
);
|
|
77
|
+
const adopted = await adoptWorkContext(root, id, graph, {
|
|
78
|
+
scope,
|
|
79
|
+
title: option("--title"),
|
|
80
|
+
});
|
|
81
|
+
return JSON.stringify(
|
|
82
|
+
{
|
|
83
|
+
...adopted,
|
|
84
|
+
url: workDeepLink(root, adopted.id),
|
|
85
|
+
handoff: workHandoff(adopted, graph),
|
|
86
|
+
},
|
|
87
|
+
null,
|
|
88
|
+
2,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const intents = () =>
|
|
92
|
+
workIntentStates(
|
|
93
|
+
work.root,
|
|
94
|
+
graph,
|
|
95
|
+
work.plan,
|
|
96
|
+
work.plan ? workBaseline(root, id) : undefined,
|
|
97
|
+
);
|
|
98
|
+
if (action === "show")
|
|
99
|
+
return JSON.stringify(
|
|
100
|
+
{ ...work, intents: intents(), url: workDeepLink(root, id) },
|
|
101
|
+
null,
|
|
102
|
+
2,
|
|
103
|
+
);
|
|
104
|
+
if (action === "intent") {
|
|
105
|
+
if (
|
|
106
|
+
!option("--proposal") ||
|
|
107
|
+
!option("--revision") ||
|
|
108
|
+
!["planned", "done", "dropped"].includes(option("--status") || "")
|
|
109
|
+
)
|
|
110
|
+
throw Error(
|
|
111
|
+
"Use --proposal ID --status planned|done|dropped --revision REVISION, with --implementation ID to link actual code.",
|
|
112
|
+
);
|
|
113
|
+
work = updateWorkIntent(root, id, graph, {
|
|
114
|
+
revision: option("--revision")!,
|
|
115
|
+
proposal: option("--proposal")!,
|
|
116
|
+
status: option("--status") as "planned" | "done" | "dropped",
|
|
117
|
+
implementation: option("--implementation"),
|
|
118
|
+
});
|
|
119
|
+
return JSON.stringify({ ...work, intents: intents() }, null, 2);
|
|
120
|
+
}
|
|
121
|
+
if (action === "handoff") return workHandoff(work, graph);
|
|
122
|
+
if (action === "lock" || action === "unlock") {
|
|
123
|
+
if (!work.plan || !option("--revision") || !option("--block"))
|
|
124
|
+
throw Error("Use --block ID and --revision from work show.");
|
|
125
|
+
const target = option("--block")!;
|
|
126
|
+
const node = graph.elements.find((n) => n.id === target);
|
|
127
|
+
if (action === "lock" && !node)
|
|
128
|
+
throw Error("Choose a mapped block or interface.");
|
|
129
|
+
const locks = (work.plan.locks || []).filter((l) => l.target !== target);
|
|
130
|
+
if (action === "lock")
|
|
131
|
+
locks.push({
|
|
132
|
+
target,
|
|
133
|
+
kind: node!.kind === "interface" ? "contract" : "subtree",
|
|
134
|
+
...(option("--note") ? { note: option("--note") } : {}),
|
|
135
|
+
});
|
|
136
|
+
return JSON.stringify(
|
|
137
|
+
updateWorkPlan(root, id, graph, {
|
|
138
|
+
revision: option("--revision")!,
|
|
139
|
+
locks,
|
|
140
|
+
}),
|
|
141
|
+
null,
|
|
142
|
+
2,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (action === "open") {
|
|
146
|
+
const url = workDeepLink(root, id);
|
|
147
|
+
execFileSync("open", [url], { stdio: "ignore", timeout: 5000 });
|
|
148
|
+
return url;
|
|
149
|
+
}
|
|
150
|
+
if (action === "review") {
|
|
151
|
+
const report = await checkWorkScope(root, id, graph);
|
|
152
|
+
const states = intents();
|
|
153
|
+
const labels = new Map(graph.elements.map((n) => [n.id, n.label]));
|
|
154
|
+
return [
|
|
155
|
+
`## ${work.title}`,
|
|
156
|
+
"",
|
|
157
|
+
`[Open the factory work view](${workDeepLink(root, id)})`,
|
|
158
|
+
"",
|
|
159
|
+
`Base: ${work.baseCommit} · Head: ${work.head}`,
|
|
160
|
+
"",
|
|
161
|
+
`Scope: ${(work.plan?.scope || []).map((id) => labels.get(id) || id).join(", ")}`,
|
|
162
|
+
"",
|
|
163
|
+
`Scope check: ${report.pass ? "passed" : `${report.outside} outside; ${report.uncertain} shared or unmapped`}`,
|
|
164
|
+
...lockBrief(graph, work.plan?.locks || []),
|
|
165
|
+
...report.locks.flatMap((l) =>
|
|
166
|
+
l.status === "unchanged"
|
|
167
|
+
? []
|
|
168
|
+
: [
|
|
169
|
+
`Lock ${l.target}: ${l.status}`,
|
|
170
|
+
...l.issues.map((i) => `- ${i.file || "Map"}: ${i.message}`),
|
|
171
|
+
],
|
|
172
|
+
),
|
|
173
|
+
"",
|
|
174
|
+
"| Change | Files |",
|
|
175
|
+
"| --- | ---: |",
|
|
176
|
+
...["inside", "outside", "shared", "unassigned"].map(
|
|
177
|
+
(status) =>
|
|
178
|
+
`| ${status} | ${report.files.filter((f) => f.status === status).length} |`,
|
|
179
|
+
),
|
|
180
|
+
"",
|
|
181
|
+
...(work.plan?.proposals.length
|
|
182
|
+
? [
|
|
183
|
+
"### Intended changes",
|
|
184
|
+
...work.plan.proposals.map(
|
|
185
|
+
(p) =>
|
|
186
|
+
`- [${states[p.id]?.status === "changed" ? "needs recheck" : states[p.id]?.status || "planned"}] ${p.kind}: ${p.label}${p.kind === "connection" ? ` (${labels.get(p.source!) || p.source} → ${labels.get(p.target!) || p.target})` : ""}${p.implementation ? ` → ${labels.get(p.implementation) || p.implementation}` : ""} — ${p.note.replace(/\n/g, " ")}`,
|
|
187
|
+
),
|
|
188
|
+
]
|
|
189
|
+
: []),
|
|
190
|
+
"",
|
|
191
|
+
"The plan shows intent. File ownership is checked against the pinned map; this is not test evidence or merge protection.",
|
|
192
|
+
].join("\n");
|
|
193
|
+
}
|
|
194
|
+
if (action === "check") {
|
|
195
|
+
const report = await checkWorkScope(root, id, graph);
|
|
196
|
+
if (!report.pass) process.exitCode = 1;
|
|
197
|
+
return JSON.stringify(report, null, 2);
|
|
198
|
+
}
|
|
199
|
+
if (action === "plan" || action === "pr") {
|
|
200
|
+
if (!work.plan || !work.revision)
|
|
201
|
+
throw Error("Start a block-scoped work context first.");
|
|
202
|
+
const file = option("--file");
|
|
203
|
+
if (action === "plan" && (!file || !option("--revision")))
|
|
204
|
+
throw Error("Choose --file and --revision from work show.");
|
|
205
|
+
if (file && statSync(resolve(file)).size > 150000)
|
|
206
|
+
throw Error("Keep the plan below 150 KB.");
|
|
207
|
+
const value =
|
|
208
|
+
action === "plan" && file
|
|
209
|
+
? JSON.parse(readFileSync(resolve(file), "utf8"))
|
|
210
|
+
: {};
|
|
211
|
+
work = updateWorkPlan(root, id, graph, {
|
|
212
|
+
revision: option("--revision") || work.revision,
|
|
213
|
+
proposals: value.proposals || work.plan.proposals,
|
|
214
|
+
scope: value.scope,
|
|
215
|
+
excluded: value.excluded,
|
|
216
|
+
locks: value.locks,
|
|
217
|
+
...(action === "pr"
|
|
218
|
+
? {
|
|
219
|
+
pullRequest: {
|
|
220
|
+
url: option("--url") || "",
|
|
221
|
+
title: option("--title") || "Pull request",
|
|
222
|
+
},
|
|
223
|
+
}
|
|
224
|
+
: {}),
|
|
225
|
+
});
|
|
226
|
+
return JSON.stringify(work, null, 2);
|
|
227
|
+
}
|
|
228
|
+
throw Error(`Unknown work command: ${action}`);
|
|
229
|
+
}
|