@livespace/plugin-cli 0.2.0 → 0.3.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/README.md CHANGED
@@ -1,27 +1,53 @@
1
1
  # @livespace/plugin-cli
2
2
 
3
- Sets up a Livespace plugin's catalog manifest, `plugin-manifest.json`, its key pairs included.
3
+ Starts a Livespace plugin project, and sets up its catalog manifest and keys.
4
4
 
5
5
  ```sh
6
- npx @livespace/plugin-cli manifest init
6
+ npx @livespace/plugin-cli create my-plugin
7
7
  ```
8
8
 
9
- In a terminal, it asks for each field. Fields with a fixed set of values are pickers, and defaults
10
- come from the project's `package.json` when there is one. It checks the manifest the way the
11
- catalog will before writing anything.
9
+ `create` writes a TypeScript project on Vite or Bun with the SDK wired in, runs `git init` and the
10
+ install, and asks:
11
+
12
+ - whether the plugin's backend serves one Livespace account or many, and, for many, whether
13
+ accounts add it from the plugin catalog or by URL;
14
+ - whether admins enter secrets (API tokens and the like) in its settings.
15
+
16
+ From those answers it writes the catalog manifest (`manifest init`), or just the keys (`keys
17
+ init`), or nothing: the SDK's
18
+ [Do you need keys?](https://cdn.jsdelivr.net/npm/@livespace/plugin-sdk@1/dist/docs/backend.md#do-you-need-keys)
19
+ explains why. Last, it offers the `livespace-plugin` skill, which teaches coding agents how to build
20
+ a plugin (`skill install`).
21
+
22
+ Each step is also a command of its own, for a project you already have. In a terminal they ask
23
+ for each answer, as pickers where there's a fixed set; `manifest init` takes its defaults from
24
+ `package.json` and checks the manifest the way the catalog will before writing it.
12
25
 
13
26
  ## Commands
14
27
 
15
28
  | Command | What it does |
16
29
  |---|---|
30
+ | `create [dir]` | Start a plugin project in `dir` (default: the current directory), as above. Refuses a directory that isn't empty unless `--force`. `--template vite\|bun` (default: Bun when run with `bunx`, else Vite), `--pm npm\|pnpm\|yarn\|bun` (default: whichever ran it), `--no-install`. |
17
31
  | `manifest init` | Create `plugin-manifest.json`, and optionally the key pairs. Never overwrites a manifest: its `id` is the catalog key. |
18
32
  | `manifest set <field> [value]` | Change one field: `version`, `origin`, `object-types`, `name-<lang>`, `description-<lang>`, `details-<lang>`, `categories`, `icon-url`, `illustration-url`, `accent-color`, `info-url`, `additional-images`, `secret-keys`. |
19
33
  | `manifest check` | Check the manifest the way the catalog will. Exits 1 on a failure; warnings don't fail. |
20
- | `keys init [--use sig\|enc\|both]` | Create the key pairs: a signing key, plus an encryption key when the manifest has `secretKeys`. |
34
+ | `keys init [--use sig\|enc\|both]` | Create the key pairs: a signing key, plus an encryption key when the manifest has `secretKeys`. With no manifest, both, into a `jwks.json` (see Keys). |
21
35
  | `keys rotate --use sig\|enc` | Add a key for a rotation. At most two of each; a new encryption key goes first, as the browser encrypts with the first. |
22
36
  | `keys retire <kid>` | Remove a key from the manifest. The private half stays on disk until you destroy it. |
23
- | `keys jwks [--out <path>]` | Write `.well-known/livespace/jwks.json` from the keys, for a plugin that's also installed by URL. |
37
+ | `keys jwks [--out <path>]` | Write `.well-known/livespace/jwks.json` from the manifest's keys, for a catalog plugin that's also added by URL. |
24
38
  | `client-id` | Print `plugin:<id>`, what your backend checks a plugin token's `aud` against. |
39
+ | `skill install` | Copy the `livespace-plugin` agent skill into the project: `.claude/skills/` for Claude Code, `.agents/skills/` for Codex, Gemini CLI and others (Cursor and Copilot read either). `--harness` picks the agents, `--gitignore` keeps the copies out of git. Replaces a copy that's there: run `npx @livespace/plugin-cli@latest skill install` to take the newest skill. The skill reads the SDK's documentation from `node_modules`, so it matches the installed SDK. |
40
+
41
+ ## Try it locally
42
+
43
+ [Plugin Studio](https://www.npmjs.com/package/@livespace/plugin-studio) embeds your plugin's page
44
+ the way Livespace does, and acts as the account your backend calls. Projects `create` makes have
45
+ it as a dev dependency, with a `studio` script:
46
+
47
+ ```sh
48
+ npm run dev # your plugin's dev server, in one terminal
49
+ npm run studio # Plugin Studio, in another
50
+ ```
25
51
 
26
52
  ## Keys
27
53
 
@@ -31,7 +57,15 @@ Your backend needs two RSA key pairs, and Livespace only ever holds their public
31
57
  - an **encryption** key (RSA-OAEP-256) is what an admin's browser encrypts your plugin's secrets
32
58
  with, so only your backend can read them.
33
59
 
34
- The public halves go into the manifest's `publicKeys`. The private halves go to
60
+ The public halves go where Livespace reads them. For a catalog plugin, that's the manifest's
61
+ `publicKeys`. For a plugin added by URL, which has no manifest, it's the `jwks.json` it publishes:
62
+ `public/.well-known/livespace/jwks.json` when the project has a `public/` directory (its build
63
+ then serves it at `/.well-known/livespace/jwks.json`), otherwise `.well-known/livespace/jwks.json`,
64
+ or `--out`. `keys rotate` and `keys retire` edit whichever file holds them. Whether you need keys
65
+ at all is explained in the SDK's
66
+ [Do you need keys?](https://cdn.jsdelivr.net/npm/@livespace/plugin-sdk@1/dist/docs/backend.md#do-you-need-keys).
67
+
68
+ The private halves go to
35
69
  `keys/<kid>.pem` (PKCS#8): the directory is mode `0700`, each file `0600`, and they're never
36
70
  overwritten. `keys/` is added to `.gitignore`. Nothing is printed, and nothing goes over the
37
71
  network. Move the private keys into your backend's secret storage, and back up the encryption key:
@@ -45,6 +79,10 @@ dependency.
45
79
  For scripts, CI and coding agents, every answer has a flag:
46
80
 
47
81
  ```sh
82
+ npx @livespace/plugin-cli create my-plugin --yes --json \
83
+ --tenancy multi --distribution url --secrets \
84
+ --harness claude-code,codex --no-gitignore
85
+
48
86
  npx @livespace/plugin-cli manifest init --yes --json \
49
87
  --origin https://deal-scoring.example.com \
50
88
  --object-types deal,company \
@@ -54,9 +92,11 @@ npx @livespace/plugin-cli manifest init --yes --json \
54
92
  --keys
55
93
  ```
56
94
 
57
- - `--yes` takes the defaults (`package.json`'s name and version among them).
95
+ - `--yes` takes the defaults (`package.json`'s name and version among them). `create`'s
96
+ `--tenancy`, `--distribution` and `--secrets | --no-secrets` have none: they decide the keys.
58
97
  - `--json` prints only a JSON result.
59
- - `--object-types any` means no requirements: any type, the apps menu included.
98
+ - `--object-types any` means no requirements: every type, and the apps menu with no record. It
99
+ goes alone, never with a type: `any,deal` is refused.
60
100
 
61
101
  Without a terminal, a missing answer is never waited for: the command exits 1 and lists every flag
62
102
  it still needs. See `--help` for them all.
package/dist/cli.js CHANGED
@@ -6,12 +6,15 @@
6
6
  * missing one is an error that lists them all; it never waits on input. See `--help`.
7
7
  */
8
8
  import { readFileSync } from "node:fs";
9
+ import { homedir } from "node:os";
9
10
  import { resolve } from "node:path";
10
11
  import { parseArgs } from "node:util";
11
12
  import { clientId } from "./commands/client-id.js";
12
13
  import { UsageError } from "./commands/context.js";
14
+ import { DO_YOU_NEED_KEYS, create, spawnExec } from "./commands/create.js";
13
15
  import { keysInit, keysJwks, keysRetire, keysRotate } from "./commands/keys.js";
14
16
  import { manifestCheck, manifestInit, manifestSet, } from "./commands/manifest.js";
17
+ import { skillInstall } from "./commands/skill.js";
15
18
  import { LOCALES } from "./manifest/schema.js";
16
19
  import { Cancelled, clackBackend } from "./ui/clack.js";
17
20
  import { clackOutput, jsonOutput, plainOutput } from "./ui/output.js";
@@ -36,6 +39,11 @@ const STRING_FLAGS = [
36
39
  "use",
37
40
  "bits",
38
41
  "out",
42
+ "harness",
43
+ "template",
44
+ "pm",
45
+ "tenancy",
46
+ "distribution",
39
47
  ...TEXT_FLAGS,
40
48
  ];
41
49
  const BOOLEAN_FLAGS = [
@@ -46,12 +54,21 @@ const BOOLEAN_FLAGS = [
46
54
  "no-secrets",
47
55
  "keys",
48
56
  "no-keys",
57
+ "gitignore",
58
+ "no-gitignore",
59
+ "force",
60
+ "no-install",
61
+ "skill",
62
+ "no-skill",
49
63
  ];
50
- const HELP = `livespace-plugin ${CLI_VERSION} — set up a Livespace plugin's catalog manifest
64
+ const HELP = `livespace-plugin ${CLI_VERSION} — start a Livespace plugin, and set up its manifest and keys
51
65
 
52
66
  Usage: npx @livespace/plugin-cli <command> [flags]
53
67
 
54
68
  Commands:
69
+ create [dir] Start a plugin project: a Vite or Bun template, git init,
70
+ the install, then the manifest or keys it needs, and
71
+ the agent skill. Refuses a non-empty dir unless --force.
55
72
  manifest init Create plugin-manifest.json, asking for each field.
56
73
  Defaults come from package.json when there is one.
57
74
  manifest set <field> [value]
@@ -61,23 +78,44 @@ Commands:
61
78
  info-url, additional-images, secret-keys).
62
79
  manifest check Check the manifest the way the catalog will. Exit 1 on
63
80
  a failure.
64
- keys init [--use sig|enc|both]
81
+ keys init [--use sig|enc|both] [--out <path>]
65
82
  Create the key pairs: a signing key, and an encryption
66
83
  key when there are secretKeys. Private halves go to
67
84
  keys/<kid>.pem (0600, gitignored); never printed.
85
+ Public halves go in the manifest; with no manifest (a
86
+ plugin added by URL), in [public/].well-known/livespace/
87
+ jwks.json, both keys by default.
68
88
  keys rotate --use sig|enc
69
89
  Add a key for a rotation (at most two per use).
70
- keys retire <kid> Remove a key from the manifest.
71
- keys jwks [--out <path>] Write .well-known/livespace/jwks.json from the keys, for
72
- a plugin that's also installed by URL.
90
+ keys retire <kid> Remove a key from the manifest, or the jwks.json.
91
+ keys jwks [--out <path>] Write .well-known/livespace/jwks.json from the
92
+ manifest's keys, for a catalog plugin that's also
93
+ added by URL.
73
94
  client-id Print plugin:<id>, what the backend checks "aud" against.
95
+ skill install Copy the livespace-plugin agent skill into the project,
96
+ into .claude/skills and/or .agents/skills, whichever
97
+ the chosen agents read. Replaces a copy that's there:
98
+ run it again to take a newer CLI's skill.
99
+
100
+ To try a plugin locally, embedded as Livespace embeds it, run Plugin Studio: the studio
101
+ script in a project create made, or npx @livespace/plugin-studio.
74
102
 
75
103
  Answers as flags (for scripts and agents; without a terminal, a missing one is an error):
76
- --id, --version, --origin, --object-types deal,company|any, --languages en,pl,
77
- --name-<lang>, --description-<lang>, --categories "Deal,Finance",
78
- --icon-url, --illustration-url, --accent-color, --info-url,
79
- --secrets | --no-secrets, --secret-keys apiToken,webhookSecret,
80
- --keys | --no-keys, --bits 2048 (<lang>: ${LOCALES.join(", ")})
104
+ create --template vite|bun, --pm npm|pnpm|yarn|bun, --no-install, --force,
105
+ --tenancy single|multi, --distribution catalog|url,
106
+ --secrets | --no-secrets, --skill | --no-skill,
107
+ then manifest init's and skill install's. --tenancy, --distribution
108
+ and --secrets have no default: they decide the keys. Why:
109
+ ${DO_YOU_NEED_KEYS}
110
+ manifest init --id, --version, --origin, --object-types deal,company|any,
111
+ --languages en,pl, --name-<lang>, --description-<lang>,
112
+ --categories "Deal,Finance", --icon-url, --illustration-url,
113
+ --accent-color, --info-url, --secrets | --no-secrets,
114
+ --secret-keys apiToken,webhookSecret, --keys | --no-keys
115
+ (<lang>: ${LOCALES.join(", ")})
116
+ keys --bits 2048
117
+ skill install --harness claude-code,codex,cursor,copilot,gemini,other,
118
+ --gitignore | --no-gitignore
81
119
 
82
120
  Other flags:
83
121
  --dir <path> The plugin project (default: the current directory).
@@ -117,6 +155,7 @@ async function run(argv) {
117
155
  process.stdout.isTTY === true;
118
156
  const ctx = {
119
157
  dir: resolve(typeof flags.dir === "string" ? flags.dir : process.cwd()),
158
+ home: homedir(),
120
159
  now: new Date(),
121
160
  flags,
122
161
  interactive,
@@ -127,6 +166,13 @@ async function run(argv) {
127
166
  backend: interactive ? clackBackend : undefined,
128
167
  }),
129
168
  };
169
+ if (group === "create") {
170
+ await create(ctx, command, {
171
+ exec: spawnExec,
172
+ userAgent: process.env.npm_config_user_agent,
173
+ });
174
+ return 0;
175
+ }
130
176
  switch (`${group} ${command ?? ""}`.trim()) {
131
177
  case "manifest init":
132
178
  await manifestInit(ctx);
@@ -148,6 +194,9 @@ async function run(argv) {
148
194
  case "keys jwks":
149
195
  await keysJwks(ctx);
150
196
  return 0;
197
+ case "skill install":
198
+ await skillInstall(ctx);
199
+ return 0;
151
200
  case "client-id":
152
201
  await clientId(ctx);
153
202
  return 0;
@@ -1,8 +1,15 @@
1
- import { ID_PATTERN, clientIdOf } from "../manifest/schema.js";
1
+ import { readManifestText } from "../manifest/file.js";
2
+ import { ID_PATTERN, MANIFEST_FILE, clientIdOf } from "../manifest/schema.js";
2
3
  import { UsageError } from "./context.js";
3
4
  import { loadManifest } from "./load.js";
4
- /** Prints `plugin:<id>`: what a plugin token's `aud` carries, and what the backend checks. */
5
+ /**
6
+ * Prints `plugin:<id>`: what a plugin token's `aud` carries, and what the backend checks. Only a
7
+ * catalog plugin's can be worked out here; a plugin added by URL is given one by Livespace.
8
+ */
5
9
  export async function clientId(ctx) {
10
+ if ((await readManifestText(ctx.dir)) === undefined) {
11
+ throw new UsageError(`no ${MANIFEST_FILE} here. A catalog plugin's client id is plugin:<id> from its manifest; a plugin added by URL gets its client id from Livespace, shown in the plugin's settings once its jwks.json is published.`);
12
+ }
6
13
  const { id } = await loadManifest(ctx);
7
14
  if (typeof id !== "string" || !ID_PATTERN.test(id)) {
8
15
  throw new UsageError('the manifest has no valid "id" — `manifest check` says why');
@@ -0,0 +1,243 @@
1
+ /**
2
+ * `create [dir]`: starts a plugin project. It writes a template, runs `git init` and the install,
3
+ * asks how the plugin reaches accounts and whether admins enter secrets in its settings, and from that runs `manifest
4
+ * init` or `keys init` (docs/adr/0005-tenancy-and-distribution-decide-keys.md). Then it offers the
5
+ * skill. Every step is an existing command, run in the new directory.
6
+ */
7
+ import { spawn } from "node:child_process";
8
+ import { mkdir, readdir } from "node:fs/promises";
9
+ import { basename, isAbsolute, relative, resolve, sep } from "node:path";
10
+ import { TEMPLATES, writeTemplate } from "../create/template.js";
11
+ import { SUPPORTED_SDK_MAJOR } from "../sdk/range.js";
12
+ import { MissingAnswers } from "../ui/prompter.js";
13
+ import { UsageError } from "./context.js";
14
+ import { keysInit } from "./keys.js";
15
+ import { manifestInit } from "./manifest.js";
16
+ import { skillInstall } from "./skill.js";
17
+ export const PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
18
+ const RUN = {
19
+ npm: "npm run",
20
+ pnpm: "pnpm",
21
+ yarn: "yarn",
22
+ bun: "bun run",
23
+ };
24
+ export const DO_YOU_NEED_KEYS = `https://cdn.jsdelivr.net/npm/@livespace/plugin-sdk@${SUPPORTED_SDK_MAJOR}/dist/docs/backend.md#do-you-need-keys`;
25
+ export const spawnExec = (command, args, { cwd, quiet }) => new Promise((resolve, reject) => {
26
+ // Under --json, stdout carries only the result, so a child's output goes to stderr.
27
+ const child = spawn(command, args, {
28
+ cwd,
29
+ stdio: quiet
30
+ ? ["ignore", process.stderr, process.stderr]
31
+ : ["ignore", "inherit", "inherit"],
32
+ shell: process.platform === "win32",
33
+ });
34
+ child.on("error", reject);
35
+ child.on("close", (code) => resolve(code ?? 1));
36
+ });
37
+ /** `bun/1.3.9 npm/? node/v24…` → bun. Anything unrecognised is npm. */
38
+ export function packageManagerFrom(userAgent) {
39
+ const name = userAgent?.split("/")[0];
40
+ return PACKAGE_MANAGERS.includes(name ?? "")
41
+ ? name
42
+ : "npm";
43
+ }
44
+ /** A directory's name as an npm package name. */
45
+ export function packageNameFrom(dir) {
46
+ const name = basename(dir)
47
+ .toLowerCase()
48
+ .replace(/[^a-z0-9._~-]+/g, "-")
49
+ .replace(/^[._-]+|-+$/g, "");
50
+ return name === "" ? "livespace-plugin" : name;
51
+ }
52
+ /** The target as the author will recognise it: relative when nearby, otherwise absolute. */
53
+ export function shownPath(dir, cwd = process.cwd()) {
54
+ const near = relative(cwd, dir);
55
+ if (near === "") {
56
+ return ".";
57
+ }
58
+ return isAbsolute(near) || near.startsWith(`..${sep}..`) ? dir : near;
59
+ }
60
+ /** What may already be in the target: an empty `git init` or Finder's litter isn't a project. */
61
+ const HARMLESS = new Set([".git", ".DS_Store"]);
62
+ /** A command run as one step of `create`: its own result collected, its framing folded in. */
63
+ function step(ctx, results, key) {
64
+ const out = {
65
+ ...ctx.out,
66
+ start: () => { },
67
+ end: (message) => ctx.out.success(message),
68
+ result: (value) => {
69
+ results[key] = value;
70
+ },
71
+ };
72
+ return { ...ctx, out };
73
+ }
74
+ export async function create(ctx, target, deps) {
75
+ const dir = target === undefined ? ctx.dir : resolve(ctx.dir, target);
76
+ const shown = shownPath(dir);
77
+ const present = await readdir(dir).catch((error) => {
78
+ if (error.code === "ENOENT") {
79
+ return [];
80
+ }
81
+ throw error;
82
+ });
83
+ const clutter = present.filter((entry) => !HARMLESS.has(entry));
84
+ if (clutter.length > 0 && ctx.flags.force !== true) {
85
+ throw new UsageError(`${shown} isn't empty (${clutter.slice(0, 3).join(", ")}${clutter.length > 3 ? ", …" : ""}). Pick a new directory, or pass --force to write the template over it.`);
86
+ }
87
+ ctx.out.start("New Livespace plugin");
88
+ const p = ctx.prompter;
89
+ const pmFlag = ctx.flags.pm;
90
+ if (typeof pmFlag === "string" &&
91
+ !PACKAGE_MANAGERS.includes(pmFlag)) {
92
+ throw new UsageError(`--pm is one of ${PACKAGE_MANAGERS.join(", ")}`);
93
+ }
94
+ const pm = typeof pmFlag === "string"
95
+ ? pmFlag
96
+ : packageManagerFrom(deps.userAgent);
97
+ const template = await p.select({
98
+ name: "template",
99
+ message: "Build tool?",
100
+ options: TEMPLATES.map((value) => ({
101
+ value,
102
+ label: value === "vite" ? "Vite" : "Bun",
103
+ hint: value === "vite"
104
+ ? "TypeScript, Vite's dev server"
105
+ : "TypeScript, Bun's dev server and bundler",
106
+ })),
107
+ initial: pm === "bun" ? "bun" : "vite",
108
+ });
109
+ ctx.out.info(`Next: how the plugin reaches Livespace accounts, and whether admins enter secrets in its settings. Together they decide whether it needs keys of its own. Why: ${DO_YOU_NEED_KEYS}`);
110
+ const tenancy = await p.select({
111
+ name: "tenancy",
112
+ message: "Does its backend serve one Livespace account, or many?",
113
+ options: [
114
+ {
115
+ value: "single",
116
+ label: "One: my own (single-tenant)",
117
+ hint: "added to the account by URL",
118
+ },
119
+ {
120
+ value: "multi",
121
+ label: "Many (multi-tenant)",
122
+ hint: "each account brings its own settings and secrets",
123
+ },
124
+ ],
125
+ });
126
+ const distribution = tenancy === "single"
127
+ ? "url"
128
+ : await p.select({
129
+ name: "distribution",
130
+ message: "How do accounts add it?",
131
+ options: [
132
+ {
133
+ value: "catalog",
134
+ label: "From the plugin catalog",
135
+ hint: "a plugin-manifest.json; keys go in it",
136
+ },
137
+ {
138
+ value: "url",
139
+ label: "By URL",
140
+ hint: "keys are published at /.well-known/livespace/jwks.json",
141
+ },
142
+ ],
143
+ });
144
+ ctx.out.info("Secrets you hardcode in the backend don't count here. Ones admins enter in the plugin's settings go in secret fields, never ordinary ones: an ordinary field's value reaches the browser of everyone who opens the plugin.");
145
+ // The same question, and flag, as `manifest init`'s, so a catalog plugin's answer carries over.
146
+ const secretFields = await p.confirm({
147
+ name: "secrets",
148
+ message: "Will admins enter secrets (API tokens and the like) in its settings?",
149
+ });
150
+ const wantsSkill = await p.confirm({
151
+ name: "skill",
152
+ message: "Add the livespace-plugin skill, so coding agents know how to build it?",
153
+ initial: true,
154
+ });
155
+ p.assertComplete();
156
+ const results = {};
157
+ await mkdir(dir, { recursive: true });
158
+ const files = await writeTemplate(dir, template, {
159
+ name: packageNameFrom(dir),
160
+ run: RUN[pm],
161
+ });
162
+ ctx.out.success(`Wrote the ${template === "vite" ? "Vite" : "Bun"} template into ${shown}.`);
163
+ const quiet = ctx.flags.json === true;
164
+ let git;
165
+ try {
166
+ const inside = await deps.exec("git", ["rev-parse", "--is-inside-work-tree"], { cwd: dir, quiet: true });
167
+ git =
168
+ inside === 0
169
+ ? "existing"
170
+ : (await deps.exec("git", ["init", "--quiet"], { cwd: dir, quiet })) ===
171
+ 0
172
+ ? "initialised"
173
+ : "failed";
174
+ }
175
+ catch {
176
+ git = "unavailable";
177
+ }
178
+ if (git === "initialised") {
179
+ ctx.out.success("Initialised a git repository.");
180
+ }
181
+ else if (git === "failed" || git === "unavailable") {
182
+ ctx.out.warn("Couldn't run `git init`; the project isn't in a repository.");
183
+ }
184
+ let install = "skipped";
185
+ if (ctx.flags["no-install"] !== true) {
186
+ ctx.out.info(`Installing with ${pm}…`);
187
+ const code = await deps
188
+ .exec(pm, ["install"], { cwd: dir, quiet })
189
+ .catch(() => -1);
190
+ install = code === 0 ? "done" : "failed";
191
+ if (install === "done") {
192
+ ctx.out.success("Installed the dependencies, the SDK among them.");
193
+ }
194
+ else {
195
+ ctx.out.warn(`\`${pm} install\` failed. Run it in ${shown} yourself; the rest of the setup doesn't need it.`);
196
+ }
197
+ }
198
+ const inProject = (key) => ({ ...step(ctx, results, key), dir });
199
+ if (distribution === "catalog") {
200
+ // `manifest init` asks about secret fields and keys itself; what was answered here is its answer.
201
+ ctx.flags[secretFields ? "secrets" : "no-secrets"] = true;
202
+ if (secretFields &&
203
+ ctx.flags.keys === undefined &&
204
+ ctx.flags["no-keys"] === undefined) {
205
+ ctx.flags.keys = true;
206
+ }
207
+ try {
208
+ await manifestInit(inProject("manifest"));
209
+ }
210
+ catch (error) {
211
+ // The project is written by now: say how to finish, rather than to start again.
212
+ if (error instanceof MissingAnswers) {
213
+ throw new MissingAnswers([
214
+ ...error.problems,
215
+ `(The project is in ${shown}. Finish with \`manifest init\` there, passing these.)`,
216
+ ]);
217
+ }
218
+ throw error;
219
+ }
220
+ }
221
+ else if (secretFields) {
222
+ await keysInit(inProject("keys"));
223
+ }
224
+ else {
225
+ ctx.out.info("No secret fields, so no keys: there's nothing to publish.");
226
+ }
227
+ if (wantsSkill) {
228
+ await skillInstall(inProject("skill"));
229
+ }
230
+ ctx.out.end(`Done. In ${shown}: \`${RUN[pm]} dev\` to see it, and ${wantsSkill ? "ask your coding agent to build it" : "edit src/main.ts"}.`);
231
+ ctx.out.result({
232
+ dir: shown,
233
+ template,
234
+ packageManager: pm,
235
+ files,
236
+ git,
237
+ install,
238
+ tenancy,
239
+ distribution,
240
+ secretFields,
241
+ ...results,
242
+ });
243
+ }