@intentius/chant 0.110.0 → 0.112.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/dist/cli/main.d.ts.map +1 -1
- package/dist/op/activities/factory.d.ts.map +1 -1
- package/dist/op/steward.d.ts +1 -1
- package/dist/op/steward.d.ts.map +1 -1
- package/dist/workspace/box-cli.d.ts +3 -2
- package/dist/workspace/box-cli.d.ts.map +1 -1
- package/dist/workspace/box-factory-write.d.ts +71 -0
- package/dist/workspace/box-factory-write.d.ts.map +1 -0
- package/dist/workspace/box-intent.d.ts +6 -0
- package/dist/workspace/box-intent.d.ts.map +1 -1
- package/dist/workspace/declaration-write-cli.d.ts +11 -0
- package/dist/workspace/declaration-write-cli.d.ts.map +1 -0
- package/dist/workspace/declaration-write.d.ts +78 -0
- package/dist/workspace/declaration-write.d.ts.map +1 -0
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/json-edit.d.ts +11 -0
- package/dist/workspace/json-edit.d.ts.map +1 -1
- package/dist/workspace/ls.d.ts +8 -0
- package/dist/workspace/ls.d.ts.map +1 -1
- package/dist/workspace/reason-codes.d.ts +4 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/status-stewards.d.ts +4 -1
- package/dist/workspace/status-stewards.d.ts.map +1 -1
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/steward-index.d.ts +89 -0
- package/dist/workspace/steward-index.d.ts.map +1 -0
- package/dist/workspace/write-scope.d.ts +10 -0
- package/dist/workspace/write-scope.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/main.test.ts +2 -0
- package/src/cli/main.ts +18 -0
- package/src/op/activities/factory.ts +3 -1
- package/src/op/factory.e2e.test.ts +3 -1
- package/src/op/steward.ts +1 -1
- package/src/workspace/box-cli.ts +35 -4
- package/src/workspace/box-factory-write.schema.json +342 -0
- package/src/workspace/box-factory-write.test.ts +108 -0
- package/src/workspace/box-factory-write.ts +226 -0
- package/src/workspace/box-intent.test.ts +14 -4
- package/src/workspace/box-intent.ts +9 -1
- package/src/workspace/declaration-extensions.test.ts +79 -0
- package/src/workspace/declaration-write-cli.ts +82 -0
- package/src/workspace/declaration-write.test.ts +155 -0
- package/src/workspace/declaration-write.ts +275 -0
- package/src/workspace/declaration.ts +19 -1
- package/src/workspace/json-edit.ts +71 -0
- package/src/workspace/ls-contract.test.ts +53 -0
- package/src/workspace/ls.schema.json +11 -0
- package/src/workspace/ls.ts +18 -0
- package/src/workspace/member-write.schema.json +193 -0
- package/src/workspace/reason-codes.test.ts +4 -0
- package/src/workspace/reason-codes.ts +6 -0
- package/src/workspace/status-stewards.ts +23 -35
- package/src/workspace/status.schema.json +10 -1
- package/src/workspace/status.ts +25 -6
- package/src/workspace/steward-index.test.ts +171 -0
- package/src/workspace/steward-index.ts +226 -0
- package/src/workspace/write-scope.ts +17 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `chant workspace status` reads of a project's stewards and Ops
|
|
3
|
+
* (#3636), kept per tree so a status doesn't import every `*.op.ts` file
|
|
4
|
+
* each time it runs.
|
|
5
|
+
*
|
|
6
|
+
* Discovery (`../op/discover.ts`) has to import the Op modules, and an Op
|
|
7
|
+
* module may do work when it is imported: run git, read files, even start
|
|
8
|
+
* another chant. Status needs only plain fields of what it finds: each
|
|
9
|
+
* steward's name, file, form, vault, capabilities and Ops, and of each Op
|
|
10
|
+
* its name, schedule, labels, work lease kind and `changesCheckout`. The
|
|
11
|
+
* first status on a tree discovers them and writes that index to
|
|
12
|
+
* `<cache dir>/workspace-stewards/<checkout>/<key>.json`; later ones read
|
|
13
|
+
* it back, until the tree changes. The cache dir is the one the graph cache
|
|
14
|
+
* uses (`./graph-cache.ts`): `$CHANT_CACHE_DIR`, else
|
|
15
|
+
* `$XDG_CACHE_HOME/chant`, else `~/.cache/chant`, outside the workspace,
|
|
16
|
+
* since a read never changes the workspace it reads.
|
|
17
|
+
*
|
|
18
|
+
* The tree is the checkout's `HEAD` tree plus every changed or untracked
|
|
19
|
+
* file `git status` lists (its path and contents), and the chant version,
|
|
20
|
+
* so a commit, an edit or a new file anywhere in the checkout discovers
|
|
21
|
+
* again. Files git ignores (`node_modules`) are not part of it. An index is
|
|
22
|
+
* only written when every Op file imported, so an import that failed is
|
|
23
|
+
* tried again by the next status. `CHANT_STEWARD_INDEX=0` turns the index
|
|
24
|
+
* off, for an Op module whose declaration depends on more than its tree.
|
|
25
|
+
*/
|
|
26
|
+
import { type StewardForm } from "../op/steward.js";
|
|
27
|
+
/** What status reads of an Op. */
|
|
28
|
+
export interface IndexedOp {
|
|
29
|
+
name: string;
|
|
30
|
+
schedule: {
|
|
31
|
+
cron: string;
|
|
32
|
+
} | null;
|
|
33
|
+
/** Absent when the Op has none. */
|
|
34
|
+
labels?: Record<string, string>;
|
|
35
|
+
workLease: {
|
|
36
|
+
kind: string | null;
|
|
37
|
+
} | null;
|
|
38
|
+
changesCheckout: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** What status reads of a steward. */
|
|
41
|
+
export interface IndexedSteward {
|
|
42
|
+
name: string;
|
|
43
|
+
/** The `*.op.ts` file declaring it, absolute. */
|
|
44
|
+
filePath: string;
|
|
45
|
+
/** Every Op it runs: its turns' Ops, then those beside them. */
|
|
46
|
+
ops: IndexedOp[];
|
|
47
|
+
/** The Ops it runs beside its turns (#2861), and whether each declares a ready step. */
|
|
48
|
+
beside: {
|
|
49
|
+
op: string;
|
|
50
|
+
ready: boolean;
|
|
51
|
+
}[];
|
|
52
|
+
form: {
|
|
53
|
+
default: StewardForm;
|
|
54
|
+
environments: Record<string, StewardForm>;
|
|
55
|
+
};
|
|
56
|
+
capabilities: string[];
|
|
57
|
+
vault: string | null;
|
|
58
|
+
}
|
|
59
|
+
export interface StewardIndex {
|
|
60
|
+
/** In discovery's order. */
|
|
61
|
+
stewards: IndexedSteward[];
|
|
62
|
+
/** Files that could not be imported. */
|
|
63
|
+
errors: string[];
|
|
64
|
+
/** Stewards dropped as second writers. */
|
|
65
|
+
conflicts: string[];
|
|
66
|
+
/** The project's Ops that no steward lists, or null when they couldn't be discovered. */
|
|
67
|
+
otherOps: IndexedOp[] | null;
|
|
68
|
+
}
|
|
69
|
+
/** Discover the stewards and Ops under `memberDir`, importing every Op file. Throws as `discoverStewards` does. */
|
|
70
|
+
export declare function discoverStewardIndex(memberDir: string): Promise<StewardIndex>;
|
|
71
|
+
/**
|
|
72
|
+
* The key of the tree `memberDir` is in: its `HEAD` tree, each changed or
|
|
73
|
+
* untracked file's path and contents, the chant version and `memberDir`.
|
|
74
|
+
* Null outside a checkout, or when git can't say.
|
|
75
|
+
*/
|
|
76
|
+
export declare function treeKey(memberDir: string): Promise<{
|
|
77
|
+
key: string;
|
|
78
|
+
dir: string;
|
|
79
|
+
checkout: string;
|
|
80
|
+
} | null>;
|
|
81
|
+
/**
|
|
82
|
+
* The stewards and Ops under `memberDir`: from the index for its tree when
|
|
83
|
+
* there is one, else discovered and indexed. Throws as `discoverStewards`
|
|
84
|
+
* does.
|
|
85
|
+
*/
|
|
86
|
+
export declare function readStewardIndex(memberDir: string, deps?: {
|
|
87
|
+
discover?: typeof discoverStewardIndex;
|
|
88
|
+
}): Promise<StewardIndex>;
|
|
89
|
+
//# sourceMappingURL=steward-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steward-index.d.ts","sourceRoot":"","sources":["../../src/workspace/steward-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAUH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAuBlE,kCAAkC;AAClC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAClC,mCAAmC;IACnC,MAAM,CAAC,EA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AAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,oBAAoB,CAAA;CAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CA0BtI"}
|
|
@@ -178,6 +178,16 @@ export declare function scopeSource(cwd: string): ScopeSource;
|
|
|
178
178
|
* name, the member holding `recordsDir`.
|
|
179
179
|
*/
|
|
180
180
|
export declare function scopedKind(source: ScopeSource, kindName: string, kindFile: string, recordsDir: string): ScopedKind;
|
|
181
|
+
/**
|
|
182
|
+
* The agent sessions as `chant workspace agent` and the write paths read
|
|
183
|
+
* them (#3615): the declaration at base, else the working tree's. Null when
|
|
184
|
+
* neither has a declaration. Lighter than {@link scopeSource}: no trust
|
|
185
|
+
* policy and no principal classes.
|
|
186
|
+
*/
|
|
187
|
+
export declare function declaredSessions(cwd: string): {
|
|
188
|
+
agents: AgentDeclaration[];
|
|
189
|
+
from: "base" | "working-tree";
|
|
190
|
+
} | null;
|
|
181
191
|
/**
|
|
182
192
|
* Refuse a record write outside the writer's scope (#2548): throws a
|
|
183
193
|
* {@link WriteScopeError}. `agent` is the session the write names
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-scope.d.ts","sourceRoot":"","sources":["../../src/workspace/write-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAOH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EAIT,UAAU,EAEV,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAO7B,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,4EAA4E;AAC5E,eAAO,M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,CAAC;CAC1B;AAED,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gFAAgF;IAChF,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1E,MAAM,EAAE,MAAM,CAAC;CAChB;AAkCD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,sGAAsG;IACtG,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAuE9B"}
|
package/package.json
CHANGED
package/src/cli/main.test.ts
CHANGED
|
@@ -775,12 +775,14 @@ describe("workspace init and ls (#2534)", () => {
|
|
|
775
775
|
"workspace export",
|
|
776
776
|
"workspace graph",
|
|
777
777
|
"workspace hash-index",
|
|
778
|
+
"workspace host",
|
|
778
779
|
"workspace import",
|
|
779
780
|
"workspace init",
|
|
780
781
|
"workspace lineage",
|
|
781
782
|
"workspace lint",
|
|
782
783
|
"workspace lock",
|
|
783
784
|
"workspace ls",
|
|
785
|
+
"workspace member",
|
|
784
786
|
"workspace member-run",
|
|
785
787
|
"workspace patch",
|
|
786
788
|
"workspace pin",
|
package/src/cli/main.ts
CHANGED
|
@@ -1119,6 +1119,21 @@ Workspace (level 1, #2524):
|
|
|
1119
1119
|
and comments; --cover copies a PNG, JPEG or WebP into
|
|
1120
1120
|
the repository. Judged by the write scope at base.
|
|
1121
1121
|
Prints the box-listing-write document; never commits
|
|
1122
|
+
workspace member add <name> --from <file|-> [--by <principal>] [--dry-run]
|
|
1123
|
+
workspace member remove <name> [--by <principal>] [--dry-run]
|
|
1124
|
+
workspace host set <name> --from <file|-> [--by <principal>] [--dry-run]
|
|
1125
|
+
Add or remove a member's entry, or add or replace a
|
|
1126
|
+
host's, in the declaration, in place, keeping its
|
|
1127
|
+
formatting and comments. Refuses a declaration that
|
|
1128
|
+
doesn't read, or two boxes sharing a port. Judged by
|
|
1129
|
+
the write scope at base. Prints the member-write
|
|
1130
|
+
document; never commits
|
|
1131
|
+
workspace box factory set <member> --from <file|-> [--by <principal>] [--dry-run]
|
|
1132
|
+
Change a box's factory (builds, check, checks,
|
|
1133
|
+
builders, tiers, publish) in the declaration, in
|
|
1134
|
+
place, such as where a planted box publishes. Judged
|
|
1135
|
+
by the write scope at base. Prints the
|
|
1136
|
+
box-factory-write document; never commits
|
|
1122
1137
|
workspace box publish <member> (<item> | --records) [--by <principal>] [--head <owner/name>] [--dry-run]
|
|
1123
1138
|
Publish a built work item, or the records kept
|
|
1124
1139
|
uncommitted, through the publisher the box block names:
|
|
@@ -1850,6 +1865,9 @@ export const commandRegistry: CommandDef[] = [
|
|
|
1850
1865
|
{ name: "workspace member-run", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/member-run")).runWorkspaceMemberRun(ctx, runCommandInProcess) },
|
|
1851
1866
|
// #3308 — a box's listing, written through chant so a tool never edits the declaration itself (ws-074).
|
|
1852
1867
|
{ name: "workspace box", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/box-cli")).runWorkspaceBox(ctx) },
|
|
1868
|
+
// #3596 — a declaration's members and hosts, written through chant so a lobby never edits the declaration itself (ws-074).
|
|
1869
|
+
{ name: "workspace member", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/declaration-write-cli")).runWorkspaceMember(ctx) },
|
|
1870
|
+
{ name: "workspace host", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/declaration-write-cli")).runWorkspaceHost(ctx) },
|
|
1853
1871
|
// #3173 — the working tree's write lock, held across chant calls for a batch of writes (ws-089).
|
|
1854
1872
|
{ name: "workspace lock", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/write-lock-cli")).runWorkspaceLock(ctx) },
|
|
1855
1873
|
// #3172 — work in progress under refs/chant/wip/<branch>, replicated under the box's policy (ws-085).
|
|
@@ -22,6 +22,7 @@ import { spawn } from "node:child_process";
|
|
|
22
22
|
import { mkdirSync, realpathSync, writeFileSync } from "node:fs";
|
|
23
23
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
24
24
|
import type { FactoryClaim, FactoryContext, FactoryItem } from "../../workspace/factory-rules";
|
|
25
|
+
import { liveRunEnv } from "../run-live";
|
|
25
26
|
|
|
26
27
|
/** The run's work lease, as `workLeaseOutput()` hands it to a step. */
|
|
27
28
|
export interface FactoryLease {
|
|
@@ -263,7 +264,8 @@ interface Ran {
|
|
|
263
264
|
/** Run argv in cwd, without a shell, asynchronously. */
|
|
264
265
|
function run(argv: readonly string[], cwd: string, env: NodeJS.ProcessEnv): Promise<Ran> {
|
|
265
266
|
return new Promise((settle) => {
|
|
266
|
-
|
|
267
|
+
// The run's activity file, as a shell step gets it, so a builder's lines reach its in-flight record (#3637).
|
|
268
|
+
const child = spawn(argv[0], argv.slice(1), { cwd, env: { ...process.env, ...liveRunEnv(), ...env }, stdio: ["ignore", "pipe", "pipe"] });
|
|
267
269
|
let stdout = "";
|
|
268
270
|
let stderr = "";
|
|
269
271
|
child.stdout.on("data", (b: Buffer) => (stdout += b.toString("utf8")));
|
|
@@ -184,7 +184,7 @@ describe("the factory Op's seams for an orchestrator (studio#382)", () => {
|
|
|
184
184
|
// A builder that reports a run and a check that reports per criterion.
|
|
185
185
|
writeFileSync(join(dir, "hooks", "builder2.cjs"), `${BUILDER}\nconsole.log(JSON.stringify({ ok: true, run: { id: "run-7" }, agent: "builder-small", chantAgent: "factory", records: ["contract:C-1"] }));\n`);
|
|
186
186
|
writeFileSync(join(dir, "hooks", "check2.cjs"), `console.log(JSON.stringify({ criteria: { "AC-1": "pass", "AC-2": "fail" }, built: JSON.parse(process.env.FACTORY_BUILD).agent }));`);
|
|
187
|
-
writeFileSync(join(dir, "hooks", "after.cjs"), `require("node:fs").writeFileSync(require("node:path").join(process.env.FACTORY_FAIL_DIR, "after.json"), JSON.stringify({ outcome: process.env.FACTORY_OUTCOME, commit: process.env.FACTORY_COMMIT, reason: process.env.FACTORY_REASON, check: JSON.parse(process.env.FACTORY_CHECK) }));`);
|
|
187
|
+
writeFileSync(join(dir, "hooks", "after.cjs"), `require("node:fs").writeFileSync(require("node:path").join(process.env.FACTORY_FAIL_DIR, "after.json"), JSON.stringify({ outcome: process.env.FACTORY_OUTCOME, commit: process.env.FACTORY_COMMIT, reason: process.env.FACTORY_REASON, check: JSON.parse(process.env.FACTORY_CHECK), activity: process.env.CHANT_RUN_ACTIVITY ?? null }));`);
|
|
188
188
|
// The prepare hook writes W-110 in the checkout and leaves it uncommitted; the others are taken out of the way.
|
|
189
189
|
writeFileSync(
|
|
190
190
|
join(dir, "hooks", "prepare.cjs"),
|
|
@@ -204,6 +204,8 @@ describe("the factory Op's seams for an orchestrator (studio#382)", () => {
|
|
|
204
204
|
expect(result.workLease).toMatchObject({ item: "W-110", outcome: "not_done" });
|
|
205
205
|
const after = JSON.parse(readFileSync(join(dir, "after.json"), "utf-8"));
|
|
206
206
|
expect(after).toMatchObject({ outcome: "not_done", reason: "criteria AC-2 have no passing evidence", check: { built: "builder-small" } });
|
|
207
|
+
// A hook gets the run's activity file, as a shell step does (#3637).
|
|
208
|
+
expect(after.activity).toMatch(/\.activity\.jsonl$/);
|
|
207
209
|
// The attempt was committed with why, and the run kept that commit.
|
|
208
210
|
expect(after.commit).toMatch(/^[0-9a-f]{40}$/);
|
|
209
211
|
// The kept attempt holds the carried item with AC-1 ticked and AC-2 failed.
|
package/src/op/steward.ts
CHANGED
|
@@ -352,7 +352,7 @@ export function readinessKeys(result: unknown): { ready: boolean; keys: string[]
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
/** The form a steward takes in `env` (`local` when none is named). */
|
|
355
|
-
export function stewardFormFor(steward: StewardDeclaration, env: string = DEFAULT_STEWARD_ENV): StewardForm {
|
|
355
|
+
export function stewardFormFor(steward: Pick<StewardDeclaration, "form">, env: string = DEFAULT_STEWARD_ENV): StewardForm {
|
|
356
356
|
return steward.form.environments[env] ?? steward.form.default;
|
|
357
357
|
}
|
|
358
358
|
|
package/src/workspace/box-cli.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* `chant workspace box`: a member's box block. Two verbs:
|
|
3
3
|
*
|
|
4
4
|
* - `box listing set <member>` (#3308) changes the box's listing
|
|
5
|
-
* (`box-listing.ts`)
|
|
6
|
-
*
|
|
5
|
+
* (`box-listing.ts`), and `box factory set <member>` (#3600) its factory,
|
|
6
|
+
* such as where it publishes (`box-factory-write.ts`). A box's other
|
|
7
|
+
* configuration is changed by editing the declaration in a reviewed change.
|
|
7
8
|
* - `box publish <member> <item> | --records` (#3165, ws-088) runs the
|
|
8
9
|
* publisher the box block names and checks what it did (`box-publish.ts`).
|
|
9
10
|
*/
|
|
@@ -12,12 +13,14 @@ import { readFileSync } from "node:fs";
|
|
|
12
13
|
import { resolve } from "node:path";
|
|
13
14
|
import { formatError } from "../cli/format";
|
|
14
15
|
import type { CommandContext } from "../cli/registry";
|
|
16
|
+
import { BOX_FACTORY_CONTRACT_VERSION, BOX_FACTORY_WRITE_SCHEMA_ID, boxFactorySet, type BoxFactoryWriteDocument } from "./box-factory-write";
|
|
15
17
|
import { BOX_LISTING_CONTRACT_VERSION, BOX_LISTING_WRITE_SCHEMA_ID, boxListingSet, type BoxListingWriteDocument } from "./box-listing";
|
|
16
18
|
import { BOX_PUBLISH_CONTRACT_VERSION, BOX_PUBLISH_SCHEMA_ID, boxPublish, type BoxPublishDocument } from "./box-publish";
|
|
17
19
|
import { readerVersion } from "./declaration";
|
|
18
20
|
import { AGENT_ENV } from "./write-scope";
|
|
19
21
|
|
|
20
22
|
const USAGE = "chant workspace box listing set <member> [--from <file|->] [--cover <image> [--cover-path <path>]] [--by <principal>] [--dry-run] [--json]";
|
|
23
|
+
const FACTORY_USAGE = "chant workspace box factory set <member> --from <file|-> [--by <principal>] [--dry-run] [--json]";
|
|
21
24
|
const PUBLISH_USAGE = "chant workspace box publish <member> (<item> | --records) [--by <principal>] [--head <owner/name>] [--dry-run] [--json]";
|
|
22
25
|
|
|
23
26
|
export async function runWorkspaceBox(ctx: CommandContext): Promise<number> {
|
|
@@ -27,11 +30,13 @@ export async function runWorkspaceBox(ctx: CommandContext): Promise<number> {
|
|
|
27
30
|
const [, noun, verb, member, ...extra] = args.positionals ?? [];
|
|
28
31
|
// For publish, the third positional is the member and the fourth the item.
|
|
29
32
|
if (noun === "publish") return runPublish(ctx, verb, member === undefined ? [] : [member, ...extra]);
|
|
33
|
+
if (noun === "factory" && verb === "set") return runFactorySet(ctx, member, extra);
|
|
30
34
|
if (noun !== "listing" || verb !== "set") {
|
|
35
|
+
const verbs = "listing set <member>, factory set <member> or publish <member>";
|
|
31
36
|
console.error(
|
|
32
37
|
formatError({
|
|
33
|
-
message: noun === undefined ?
|
|
34
|
-
hint: `${USAGE}\n${PUBLISH_USAGE}`,
|
|
38
|
+
message: noun === undefined ? `chant workspace box takes ${verbs}` : `chant workspace box takes ${verbs}, not ${[noun, verb].filter(Boolean).join(" ")}`,
|
|
39
|
+
hint: `${USAGE}\n${FACTORY_USAGE}\n${PUBLISH_USAGE}`,
|
|
35
40
|
}),
|
|
36
41
|
);
|
|
37
42
|
return 1;
|
|
@@ -75,6 +80,32 @@ export async function runWorkspaceBox(ctx: CommandContext): Promise<number> {
|
|
|
75
80
|
);
|
|
76
81
|
}
|
|
77
82
|
|
|
83
|
+
/** `box factory set <member> --from <file|->` (#3600). */
|
|
84
|
+
function runFactorySet(ctx: CommandContext, member: string | undefined, extra: string[]): number {
|
|
85
|
+
const { args } = ctx;
|
|
86
|
+
const cwd = process.cwd();
|
|
87
|
+
const print = (doc: BoxFactoryWriteDocument): number => {
|
|
88
|
+
console.log(JSON.stringify(doc, null, 2));
|
|
89
|
+
return "error" in doc ? 1 : 0;
|
|
90
|
+
};
|
|
91
|
+
const fail = (code: "write-usage-invalid" | "write-input-invalid", message: string) =>
|
|
92
|
+
print({ $schema: BOX_FACTORY_WRITE_SCHEMA_ID, contract: BOX_FACTORY_CONTRACT_VERSION, chant: readerVersion(), member: member ?? null, error: { code, message } });
|
|
93
|
+
if (member === undefined) return fail("write-usage-invalid", `box factory set needs the member whose box builds; ${FACTORY_USAGE}`);
|
|
94
|
+
if (extra.length > 0) return fail("write-usage-invalid", `box factory set takes one member, and was also given ${extra.join(" ")}`);
|
|
95
|
+
for (const [flag, v] of [["--set", args.set], ["--kind", args.kind], ["--at", args.at], ["--cover", args.cover]] as const) {
|
|
96
|
+
if (v !== undefined) return fail("write-usage-invalid", `box factory set takes its fields with --from, not ${flag}`);
|
|
97
|
+
}
|
|
98
|
+
let fields: string | undefined;
|
|
99
|
+
if (args.migrateFrom !== undefined) {
|
|
100
|
+
try {
|
|
101
|
+
fields = readFileSync(args.migrateFrom === "-" ? 0 : resolve(cwd, args.migrateFrom), "utf-8");
|
|
102
|
+
} catch (err) {
|
|
103
|
+
return fail("write-input-invalid", `--from ${args.migrateFrom} could not be read: ${err instanceof Error ? err.message : String(err)}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return print(boxFactorySet({ cwd, member, fields, by: args.by, agent: process.env[AGENT_ENV] || undefined, dryRun: args.dryRun === true }));
|
|
107
|
+
}
|
|
108
|
+
|
|
78
109
|
/** `box publish <member> <item>` or `box publish <member> --records`. */
|
|
79
110
|
function runPublish(ctx: CommandContext, member: string | undefined, rest: string[]): number {
|
|
80
111
|
const { args } = ctx;
|