@acryldev/blends 1.7.17 → 1.7.19

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/index.js CHANGED
@@ -95,7 +95,7 @@ var packages = {
95
95
  "path": "../plugins/versions"
96
96
  },
97
97
  "@acryldev/blends-frame": {
98
- "version": "0.2.10",
98
+ "version": "0.2.11",
99
99
  "path": "../plugins/blends-frame"
100
100
  }
101
101
  };
@@ -54,6 +54,7 @@ They are enabled as they are built.
54
54
  | Look up a call | [API](api/index.md), [Routing](api/routing.md), [Context](api/context.md), [Request](api/request.md), [API summary](api/summary.md) |
55
55
  | Understand the design | [Concepts](concepts/motivation.md) |
56
56
  | Copy a pattern | [Guides](guides/best-practices.md), [Validation](guides/validation.md), [Testing](guides/testing.md), [Data, migrations and choosing a store](guides/data.md), [Forms, sessions and a database](guides/forms-and-sessions.md), [Client components without a bundler](guides/client-modules.md), [Bring your own tool](guides/bring-your-own-tool.md) |
57
+ | Share a plugin with other people: publish, pull from GitHub or the registry, update | [Share a plugin](guides/share-plugins.md) |
57
58
  | Run the 90-minute workshop | [Workshop](workshop/README.md), and the room around it in [Facilitator notes](workshop/facilitator.md) |
58
59
  | Use Acryl inside a Cordis app | [Acryl in a Cordis app](cordis/acryl-in-a-cordis-app.md), [Plugin lifecycle](cordis/plugin-lifecycle.md), [Mounting](cordis/mounting.md) |
59
60
  | Move from the 0.3 router calls | [Migration from 0.3](cordis/migration-from-0-3.md) |
@@ -0,0 +1,117 @@
1
+ # Share a plugin: publish it, pull it, update it
2
+
3
+ A plugin is a folder in `plugins/`. Another person's app takes it from a GitHub release, from the public plugin registry, or from a list your group
4
+ keeps. Every command below was run, as two people with their own apps and their own home folders (Ana publishes, Ben pulls), against a real GitHub
5
+ organization. They run in the app's folder, with the app running (`npm run dev`, or the desktop app): a pull installs into the running app.
6
+
7
+ You need `gh` signed in (`gh auth login`) to publish, and nothing to pull a public plugin.
8
+
9
+ ## 1. Make the plugin
10
+
11
+ `plugins/hello-ana/package.json` (the name and a version; the folder name is the plugin's name):
12
+
13
+ ```json
14
+ { "name": "hello-ana", "version": "0.1.0", "description": "A greeting.", "type": "module", "main": "index.ts" }
15
+ ```
16
+
17
+ `plugins/hello-ana/index.ts`:
18
+
19
+ ```ts
20
+ import type { Context } from '@deepseek-ai/cordis'
21
+ import { Acryl } from 'acrylblends'
22
+
23
+ export const name = 'hello-ana'
24
+ export const inject = ['router']
25
+
26
+ export function apply(ctx: Context): void {
27
+ ctx.router.route('/hello-ana', new Acryl().get('/', (c) => c.json({ text: 'hello from Ana, v0.1.0' })))
28
+ }
29
+ ```
30
+
31
+ Saving the folder starts the plugin in the running app: in the frame it answers at `/app/hello-ana` (under `npm start` at `/hello-ana`). A syntax error
32
+ leaves the previous version running and says so in the log.
33
+
34
+ ## 2. Publish it
35
+
36
+ ```sh
37
+ npm run acryl -- plugin publish hello-ana --owner <your GitHub account or organization>
38
+ ```
39
+
40
+ It prints the plan and sends nothing: the repository (new or not), the version, the license (`--license <id>`, MIT by default), the files, and that the
41
+ repository gets the topic `cordis-plugin`, which is how the public registry finds it. Only a person's `yes` at the terminal publishes; an agent gets the
42
+ plan and cannot answer. It ends with the line to give a friend:
43
+
44
+ ```
45
+ npm run acryl -- plugin pull github:<owner>/hello-ana@0.1.0@sha256:<digest>
46
+ ```
47
+
48
+ The same in the app: Settings > Plugins > My plugins > **Share...** on the plugin, then one of **Save here** (this computer only), **Share privately**,
49
+ **Share publicly**, **Publish to npm** or **List in the registry**. It shows the plan and asks again before it sends anything; the account field is empty for your own account.
50
+
51
+ | Target | How | Result |
52
+ | --- | --- | --- |
53
+ | GitHub | `plugin publish`, or Share publicly / Share privately | a repository and a release holding exactly the plugin's files, and the pull line |
54
+ | The public registry | `plugin publish` (always public), or **List in the registry** | the repository has the topic `cordis-plugin`; cordisplugins.github.io lists it at its next sync (hourly) |
55
+ | npm | `plugin publish <name> --to npm` | the package `@<scope>/<name>` on the npm registry (see below) |
56
+
57
+ A plugin that holds a secret is refused, naming the file.
58
+
59
+ ### To npm
60
+
61
+ ```sh
62
+ npm run acryl -- plugin publish hello-ana --to npm # as @<the account npm is signed in as>/hello-ana
63
+ npm run acryl -- plugin publish hello-ana --to npm --scope acme # as @acme/hello-ana
64
+ npm run acryl -- plugin publish hello-ana --to npm --registry https://npm.example.com/ # another registry
65
+ ```
66
+
67
+ It uses **your own** npm login and nothing else: it asks `npm whoami`, and when you are not signed in the plan is refused with `npm login`. The plan shows
68
+ the package, the registry, the version and the license before the `yes`; a version npm already has makes it the next patch. The package is public, named
69
+ `@scope/name` (the plugin's folder name is `name`). The same is the **Publish to npm** button of Share... (the account field is the scope; blank is your npm login's account). To try it without publishing, run the same command with `npm_config_dry_run=true` in the environment of
70
+ the running app: npm then stops before sending the package.
71
+
72
+ ## 3. Pull it
73
+
74
+ ```sh
75
+ npm run acryl -- plugin pull github:<owner>/hello-ana # the latest release
76
+ npm run acryl -- plugin pull github:<owner>/hello-ana@0.1.0 # one version
77
+ npm run acryl -- plugin pull github:<owner>/hello-ana@0.1.0@sha256:<digest> # exactly these bytes (the line the publisher gave)
78
+ npm run acryl -- plugin pull registry:hello-ana # the registry's id, checked against the integrity the registry lists
79
+ npm run acryl -- plugin pull npm:@acme/hello-ana # from npm: the latest version, or @0.1.1, and @sha256:<digest> to name the bytes
80
+ ```
81
+
82
+ An npm package `@acme/hello-ana` is installed in the folder `plugins/hello-ana`; the checksum npm lists for the version must match the bytes that arrive. A
83
+ public package needs no login; a private scope or registry is read through your own npm configuration.
84
+
85
+ In the app: Settings > Plugins > **Registry**, search, **Add to my app** (it says it runs someone else's code and asks first); or **Add by address** for
86
+ a `github:` line from a colleague. The plugin is live at once; `blend.yaml` records where it came from, so a copy of the app fetches the same bytes.
87
+
88
+ A group's plugins in one command: put one source per line in a file (`#` starts a comment), then `npm run acryl -- plugin pull --from group.txt`. Each
89
+ line is pulled on its own; a refused one is named with its reason while the others run.
90
+
91
+ ```sh
92
+ npm run acryl -- plugin list # what is installed, where each pulled one came from and who released it
93
+ npm run acryl -- plugin remove hello-ana
94
+ ```
95
+
96
+ ## 4. Update it, and keep your own edits
97
+
98
+ Ana changes the plugin and runs the same `plugin publish` again: the version that is already released is not released twice, so the plan names the next
99
+ patch (0.1.1) and says so. Ben runs the same pull line he used before:
100
+
101
+ ```sh
102
+ npm run acryl -- plugin pull github:<owner>/hello-ana@0.1.1
103
+ ```
104
+
105
+ In the app, Settings > Plugins > Registry shows **Update to v0.1.1** instead of "Added" when the registry lists a newer release than the one pulled; it asks first and does the same as the command.
106
+
107
+ - A folder Ben never touched is replaced by the new release, live.
108
+ - A folder Ben changed is merged: the release he pulled is fetched again as the common ancestor, a file only he changed keeps his change, a file of his own stays, and
109
+ a file both changed is merged line by line. The answer names the files that kept something of his (`kept`).
110
+ - When Ben and the release changed the same lines, nothing is written: the pull is refused naming the file, and his folder is exactly as it was. Move the folder
111
+ out of `plugins/`, pull again, and bring his change back by hand.
112
+ - A plugin another account released under the same name is never merged: it is refused naming where the copy in the app came from.
113
+
114
+ ## Try it without touching your own account
115
+
116
+ Use a throwaway GitHub organization and a second app with its own home folder, so the two people never share files. Publishing as the organization needs
117
+ `gh` signed in as one of its members: `--owner <organization>`.
@@ -141,9 +141,16 @@ type PullListView = {
141
141
  interface PublishOptionsView {
142
142
  readonly owner?: string;
143
143
  readonly license?: string;
144
+ /** `npm`: publish to an npm registry with the person's own npm login. */
145
+ readonly to?: 'npm';
146
+ readonly scope?: string;
147
+ readonly registry?: string;
144
148
  }
145
149
  /** A plan as the door shows it. The service owns it; the door passes it back unchanged. */
146
150
  interface PublishPlanView {
151
+ readonly target?: 'npm';
152
+ readonly package?: string;
153
+ readonly registry?: string;
147
154
  readonly owner: string;
148
155
  readonly repo: string;
149
156
  readonly version: string;
@@ -519,7 +519,7 @@ const VERB_SPECS = {
519
519
  }
520
520
  },
521
521
  "plugin-publish": {
522
- usage: "plugin publish <name> [--owner <account>] [--license <id>]: show what publishing this plugin would send; in a person's own terminal, ask them",
522
+ usage: "plugin publish <name> [--owner <account>] [--license <id>] [--to npm [--scope <scope>] [--registry <address>]]: show what publishing this plugin would send; in a person's own terminal, ask them",
523
523
  description: "Show what publishing a plugin would send: the account, repository, version, license, files and the line a friend pulls it with. Sends nothing. Only a person can say yes, in their own terminal or with Share in the frame; tell them the plan and how.",
524
524
  arguments: {
525
525
  type: "object",
@@ -535,6 +535,19 @@ const VERB_SPECS = {
535
535
  license: {
536
536
  type: "string",
537
537
  description: "an SPDX license id; MIT when absent"
538
+ },
539
+ to: {
540
+ type: "string",
541
+ enum: ["npm"],
542
+ description: "npm: publish to an npm registry with the person's own npm login instead of GitHub"
543
+ },
544
+ scope: {
545
+ type: "string",
546
+ description: "with to npm: the package scope; the npm login's account when absent"
547
+ },
548
+ registry: {
549
+ type: "string",
550
+ description: "with to npm: the registry address; the public one when absent"
538
551
  }
539
552
  },
540
553
  required: ["name"],
@@ -698,8 +711,9 @@ var DoorError = class extends Error {
698
711
  /** What a plan says, for a person deciding. */
699
712
  function renderPublishPlan(plan) {
700
713
  return [
701
- `Publish to ${plan.owner}/${plan.repo}${plan.createsRepository ? " (a new repository)" : ""}, ${plan.visibility}, version ${plan.version}, license ${plan.license}.`,
714
+ plan.target === "npm" ? `Publish to npm as ${plan.package ?? plan.repo} (registry ${plan.registry ?? "https://registry.npmjs.org/"}, signed in as the account of your own npm login), ${plan.visibility}, version ${plan.version}, license ${plan.license}.` : `Publish to ${plan.owner}/${plan.repo}${plan.createsRepository ? " (a new repository)" : ""}, ${plan.visibility}, version ${plan.version}, license ${plan.license}.`,
702
715
  `Files: ${plan.files.join(", ")}.`,
716
+ ...plan.target === "npm" ? [] : [`The repository gets the topic cordis-plugin, so the public plugin registry (cordisplugins.github.io) lists it within about an hour.`],
703
717
  `A friend gets exactly these bytes with: ${plan.pullLine}`
704
718
  ].join("\n");
705
719
  }
@@ -1025,11 +1039,14 @@ var Door = class {
1025
1039
  }
1026
1040
  /** Only a plan: no argument of any verb can publish, so an agent never says yes for a person. */
1027
1041
  async planPublish(input) {
1028
- const { name, owner, license } = input;
1042
+ const { name, owner, license, to, scope, registry } = input;
1029
1043
  if (typeof name !== "string" || name === "") throw new DoorError("invalid", "plugin publish needs a plugin name, e.g. plugin publish pomodoro");
1030
1044
  const value = await this.share().planPublish(name, {
1031
1045
  ...typeof owner === "string" && owner !== "" ? { owner } : {},
1032
- ...typeof license === "string" && license !== "" ? { license } : {}
1046
+ ...typeof license === "string" && license !== "" ? { license } : {},
1047
+ ...to === "npm" ? { to } : {},
1048
+ ...typeof scope === "string" && scope !== "" ? { scope } : {},
1049
+ ...typeof registry === "string" && registry !== "" ? { registry } : {}
1033
1050
  });
1034
1051
  if ("ok" in value) throw new DoorError("refused", `${value.reason}. ${value.next}.`);
1035
1052
  return {
@@ -1045,7 +1062,7 @@ var Door = class {
1045
1062
  tool: "plugin-publish",
1046
1063
  target: {
1047
1064
  role: "plugin",
1048
- name: `${confirmed.owner}/${confirmed.repo}@${confirmed.version}`
1065
+ name: `${confirmed.package ?? `${confirmed.owner}/${confirmed.repo}`}@${confirmed.version}`
1049
1066
  },
1050
1067
  outcome: value.ok ? "ok" : "refused",
1051
1068
  approval: "token"
@@ -1418,7 +1435,7 @@ function operatorRoutes(prefix, secret, door, reportError) {
1418
1435
  }
1419
1436
  }).post(`${prefix}/publish-confirmed`, operatorOnly(secret), jsonBody, async (c) => {
1420
1437
  const body = await readJson(c);
1421
- const { name, confirm, owner, license } = body === INVALID_JSON || typeof body !== "object" || body === null ? {} : body;
1438
+ const { name, confirm, owner, license, to, scope, registry } = body === INVALID_JSON || typeof body !== "object" || body === null ? {} : body;
1422
1439
  if (typeof name !== "string" || typeof confirm !== "object" || confirm === null) return c.json({
1423
1440
  ok: false,
1424
1441
  code: "invalid",
@@ -1427,7 +1444,10 @@ function operatorRoutes(prefix, secret, door, reportError) {
1427
1444
  try {
1428
1445
  const value = await door.publishConfirmed(name, confirm, {
1429
1446
  ...typeof owner === "string" ? { owner } : {},
1430
- ...typeof license === "string" ? { license } : {}
1447
+ ...typeof license === "string" ? { license } : {},
1448
+ ...to === "npm" ? { to } : {},
1449
+ ...typeof scope === "string" ? { scope } : {},
1450
+ ...typeof registry === "string" ? { registry } : {}
1431
1451
  });
1432
1452
  return c.json({
1433
1453
  ok: true,
@@ -483,10 +483,14 @@ if (shell === undefined)
483
483
  throw new Error(
484
484
  `pack-blank-mac: ${app} has no desktop shell (plugins/desktop-shell, or the @acryldev/desktop-shell package)`,
485
485
  )
486
+ // The app's own icon, else ACRYL Blends' (the published desktop-shell carries it in lib/assets, its source in assets). Without one, electron-builder
487
+ // silently used Electron's own icon on every OS.
486
488
  const appIcon = [
487
489
  join(app, 'assets', 'icon.png'),
490
+ join(shell.root, 'lib', 'assets', 'acrylblends-logo.png'),
488
491
  join(shell.root, 'assets', 'acrylblends-logo.png'),
489
492
  ].find((file) => existsSync(file))
493
+ if (appIcon === undefined) throw new Error(`no icon: neither ${join(app, 'assets', 'icon.png')} nor ACRYL Blends' logo in ${shell.root}`)
490
494
  manifest.main = shell.main
491
495
  manifest.productName = PRODUCT
492
496
  manifest.description = DESCRIPTION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/blends",
3
- "version": "1.7.17",
3
+ "version": "1.7.19",
4
4
  "description": "The Acryl web framework (import { Acryl } from \"acrylblends\") and the acrylblends command that scaffolds Cordis apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,7 +11,17 @@
11
11
  import { mkdirSync, readFileSync, unwatchFile, watchFile } from 'node:fs'
12
12
  import { join } from 'node:path'
13
13
  import { fileURLToPath, pathToFileURL } from 'node:url'
14
- import { app, BrowserWindow, dialog, ipcMain, Menu, MenuItem, screen, shell } from 'electron'
14
+ import {
15
+ app,
16
+ BrowserWindow,
17
+ dialog,
18
+ ipcMain,
19
+ Menu,
20
+ MenuItem,
21
+ screen,
22
+ session,
23
+ shell,
24
+ } from 'electron'
15
25
  import '@acryldev/node-server/register'
16
26
  import { type AppInstance, instanceEnv, selectInstance, withRunEnv } from '@acryldev/instance'
17
27
  import { readProduct } from '@acryldev/instance/bundle'
@@ -126,8 +136,17 @@ if (!app.requestSingleInstanceLock()) {
126
136
  await running?.stop()
127
137
  // The frame host this window started (never one it attached to) goes with the window, with every terminal it runs.
128
138
  await host?.stop()
139
+ // What the window stored is written now: the process may end at `quit`, before Chromium's own late teardown would write it.
140
+ session.defaultSession.flushStorageData()
141
+ await session.defaultSession.cookies.flushStore()
129
142
  },
130
143
  (code) => {
144
+ // Electron emits `quit` as its last step and then ends its message loop; on macOS that loop sometimes keeps running with nothing left (no
145
+ // window, no helper process, every disposer done), about one SIGTERM in six for ACRYL ADE, so the process stayed up forever. It ends here
146
+ // instead. process.exit in Electron's main process goes back into app.exit, which is already under way; reallyExit is Node's plain exit.
147
+ app.once('quit', () => {
148
+ ;(process as NodeJS.Process & { reallyExit(code: number): never }).reallyExit(code)
149
+ })
131
150
  app.exit(code)
132
151
  },
133
152
  )
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/desktop-shell",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Run the app as a desktop app: an Electron window on the app's own server. `npm run desktop`; the app's code never imports electron.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/door",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "The door of an ACRYL framework app, one Cordis plugin: an agent working in the app folder looks at the running page (snapshots with refs), acts on it (click, type, select, press, scroll, wait) and installs plugins live, through .acryl/bin/acryl; loopback only, with a per-run secret in .acryl/door.json, an audit log, and an in-page indicator with a kill switch",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,7 +17,7 @@ import { fileURLToPath } from 'node:url'
17
17
  import { readDoorFile, STATE_DIR, DOOR_FILE } from '../host/door-file.ts'
18
18
 
19
19
  const ACT_OPS = new Set(['click', 'type', 'select', 'press', 'scroll', 'wait', 'reload', 'navigate'])
20
- const VALUED = new Set(['--dir', '--owner', '--license', '--ref', '--text', '--option', '--key', '--direction', '--amount', '--cursor', '--max-nodes', '--role', '--name', '--timeout-ms', '--id', '--width', '--height', '--window', '--tool', '--args', '--path', '--from'])
20
+ const VALUED = new Set(['--dir', '--owner', '--license', '--to', '--scope', '--registry', '--ref', '--text', '--option', '--key', '--direction', '--amount', '--cursor', '--max-nodes', '--role', '--name', '--timeout-ms', '--id', '--width', '--height', '--window', '--tool', '--args', '--path', '--from'])
21
21
  const FLAGS = new Set(['--json', '--submit', '--no-clear', '--gone', '--force', '--help'])
22
22
 
23
23
  export class UsageError extends Error {}
@@ -44,7 +44,7 @@ const USAGE = `usage: acryl <verb> [options] [--json] [--dir <app folder>]
44
44
  act wait (--text <t> | --role <role> [--name <n>]) [--gone] [--timeout-ms <ms>]
45
45
  (look and every act take --window <n>: the desktop window whose page it is for; window list prints the numbers)
46
46
  frame [open|close|toggle left|right | settings [<section>] | build | preview] (the ACRYL frame around the app; alone, what is open)
47
- plugin list | plugin add <folder> | plugin pull <source> | plugin publish <name> [--owner <account>] [--license <id>] | plugin remove <name> | plugin reload
47
+ plugin list | plugin add <folder> | plugin pull <source> | plugin publish <name> [--owner <account>] [--license <id>] [--to npm [--scope <scope>] [--registry <address>]] | plugin remove <name> | plugin reload
48
48
  window list | window open [--path <p>] | window focus --id <n> | window close --id <n> [--force]
49
49
  window resize --id <n> --width <px> --height <px>
50
50
  menu list | menu click --path "File>New Note" [--force]
@@ -160,7 +160,11 @@ export function parseInvocation(argv: readonly string[], env: NodeJS.ProcessEnv
160
160
  if (third === undefined) throw new UsageError('plugin publish needs a plugin name, e.g. plugin publish pomodoro')
161
161
  const owner = values.get('--owner')
162
162
  const license = values.get('--license')
163
- return make('plugin-publish', { name: third, ...(owner === undefined ? {} : { owner }), ...(license === undefined ? {} : { license }) })
163
+ const to = values.get('--to')
164
+ if (to !== undefined && to !== 'npm') throw new UsageError('plugin publish --to takes npm (GitHub is the default), e.g. plugin publish pomodoro --to npm')
165
+ const scope = values.get('--scope')
166
+ const registry = values.get('--registry')
167
+ return make('plugin-publish', { name: third, ...(owner === undefined ? {} : { owner }), ...(license === undefined ? {} : { license }), ...(to === undefined ? {} : { to }), ...(scope === undefined ? {} : { scope }), ...(registry === undefined ? {} : { registry }) })
164
168
  }
165
169
  if (second === 'remove') { if (third === undefined) throw new UsageError('plugin remove needs a plugin name'); return make('plugin-remove', { name: third }) }
166
170
  throw new UsageError(`plugin needs list, add, pull, publish, remove or reload\n${USAGE}`)
@@ -285,6 +289,8 @@ const isPlan = (value: unknown): value is PlanAsked =>
285
289
 
286
290
  /** What the prompt names. */
287
291
  interface PlanAsked {
292
+ /** npm: the package it publishes. */
293
+ readonly package?: string
288
294
  readonly owner: string
289
295
  readonly repo: string
290
296
  readonly version: string
@@ -300,9 +306,9 @@ async function confirmPublish(
300
306
  url: string,
301
307
  headers: Record<string, string>,
302
308
  ): Promise<number> {
303
- const yes = await io.ask?.(`Publish ${plan.owner}/${plan.repo} v${plan.version} under ${plan.license}? Type yes to send it: `)
309
+ const yes = await io.ask?.(`Publish ${plan.package ?? `${plan.owner}/${plan.repo}`} v${plan.version} under ${plan.license}? Type yes to send it: `)
304
310
  if (yes !== true) { io.out('Nothing was sent.\n'); return 0 }
305
- const response = await request(url, { method: 'POST', headers, body: JSON.stringify({ name: invocation.args.name, owner: invocation.args.owner, license: invocation.args.license, confirm: plan }) })
311
+ const response = await request(url, { method: 'POST', headers, body: JSON.stringify({ name: invocation.args.name, owner: invocation.args.owner, license: invocation.args.license, to: invocation.args.to, scope: invocation.args.scope, registry: invocation.args.registry, confirm: plan }) })
306
312
  const body = await response.json().catch(() => undefined) as { ok?: boolean; message?: string; value?: { ok?: boolean; releaseUrl?: string; pullLine?: string; reason?: string; next?: string } } | undefined
307
313
  const result = body?.value
308
314
  if (body?.ok !== true || result?.ok !== true) {
@@ -60,10 +60,17 @@ export type PullListView =
60
60
  export interface PublishOptionsView {
61
61
  readonly owner?: string
62
62
  readonly license?: string
63
+ /** `npm`: publish to an npm registry with the person's own npm login. */
64
+ readonly to?: 'npm'
65
+ readonly scope?: string
66
+ readonly registry?: string
63
67
  }
64
68
 
65
69
  /** A plan as the door shows it. The service owns it; the door passes it back unchanged. */
66
70
  export interface PublishPlanView {
71
+ readonly target?: 'npm'
72
+ readonly package?: string
73
+ readonly registry?: string
67
74
  readonly owner: string
68
75
  readonly repo: string
69
76
  readonly version: string
@@ -77,9 +84,19 @@ export interface PublishPlanView {
77
84
 
78
85
  /** What a plan says, for a person deciding. */
79
86
  export function renderPublishPlan(plan: PublishPlanView): string {
87
+ const where =
88
+ plan.target === 'npm'
89
+ ? `Publish to npm as ${plan.package ?? plan.repo} (registry ${plan.registry ?? 'https://registry.npmjs.org/'}, signed in as the account of your own npm login), ${plan.visibility}, version ${plan.version}, license ${plan.license}.`
90
+ : `Publish to ${plan.owner}/${plan.repo}${plan.createsRepository ? ' (a new repository)' : ''}, ${plan.visibility}, version ${plan.version}, license ${plan.license}.`
80
91
  return [
81
- `Publish to ${plan.owner}/${plan.repo}${plan.createsRepository ? ' (a new repository)' : ''}, ${plan.visibility}, version ${plan.version}, license ${plan.license}.`,
92
+ where,
82
93
  `Files: ${plan.files.join(', ')}.`,
94
+ // A public repository carries the topic the plugin registry (cordisplugins.github.io) lists by: said before the yes, not found out after.
95
+ ...(plan.target === 'npm'
96
+ ? []
97
+ : [
98
+ `The repository gets the topic cordis-plugin, so the public plugin registry (cordisplugins.github.io) lists it within about an hour.`,
99
+ ]),
83
100
  `A friend gets exactly these bytes with: ${plan.pullLine}`,
84
101
  ].join('\n')
85
102
  }
@@ -407,11 +424,14 @@ export class Door {
407
424
 
408
425
  /** Only a plan: no argument of any verb can publish, so an agent never says yes for a person. */
409
426
  private async planPublish(input: Record<string, unknown>): Promise<VerbAnswer> {
410
- const { name, owner, license } = input
427
+ const { name, owner, license, to, scope, registry } = input
411
428
  if (typeof name !== 'string' || name === '') throw new DoorError('invalid', 'plugin publish needs a plugin name, e.g. plugin publish pomodoro')
412
429
  const value = await this.share().planPublish(name, {
413
430
  ...(typeof owner === 'string' && owner !== '' ? { owner } : {}),
414
431
  ...(typeof license === 'string' && license !== '' ? { license } : {}),
432
+ ...(to === 'npm' ? { to } : {}),
433
+ ...(typeof scope === 'string' && scope !== '' ? { scope } : {}),
434
+ ...(typeof registry === 'string' && registry !== '' ? { registry } : {}),
415
435
  })
416
436
  if ('ok' in value) throw new DoorError('refused', `${value.reason}. ${value.next}.`)
417
437
  return { value, text: `${renderPublishPlan(value)}\nNothing was sent. Only a person can say yes: they run \`npm run acryl -- plugin publish ${name}\` in their own terminal, or press Share in the frame. \`--license <id>\` changes the license before the yes.` }
@@ -420,7 +440,7 @@ export class Door {
420
440
  /** The person's yes, from their own terminal. Not a verb: MCP and the chat do not have it. */
421
441
  async publishConfirmed(name: string, confirmed: PublishPlanView, options: PublishOptionsView): Promise<unknown> {
422
442
  const value = await this.share().publish(name, confirmed, options)
423
- this.deps.audit.record({ at: new Date().toISOString(), tool: 'plugin-publish', target: { role: 'plugin', name: `${confirmed.owner}/${confirmed.repo}@${confirmed.version}` }, outcome: value.ok ? 'ok' : 'refused', approval: 'token' })
443
+ this.deps.audit.record({ at: new Date().toISOString(), tool: 'plugin-publish', target: { role: 'plugin', name: `${confirmed.package ?? `${confirmed.owner}/${confirmed.repo}`}@${confirmed.version}` }, outcome: value.ok ? 'ok' : 'refused', approval: 'token' })
424
444
  return value
425
445
  }
426
446
 
@@ -39,7 +39,7 @@ export function operatorRoutes(prefix: string, secret: string, door: Door, repor
39
39
  // secret could still reach it: the door keeps honest agents from publishing by accident, the person's account is the real boundary.
40
40
  .post(`${prefix}/publish-confirmed`, operatorOnly(secret), jsonBody, async (c) => {
41
41
  const body = await readJson(c)
42
- const { name, confirm, owner, license } = (body === INVALID_JSON || typeof body !== 'object' || body === null ? {} : body) as { name?: unknown; confirm?: unknown; owner?: unknown; license?: unknown }
42
+ const { name, confirm, owner, license, to, scope, registry } = (body === INVALID_JSON || typeof body !== 'object' || body === null ? {} : body) as { name?: unknown; confirm?: unknown; owner?: unknown; license?: unknown; to?: unknown; scope?: unknown; registry?: unknown }
43
43
  if (typeof name !== 'string' || typeof confirm !== 'object' || confirm === null) {
44
44
  return c.json({ ok: false, code: 'invalid', message: 'the body is { name, confirm }' } satisfies CallResponse, 400)
45
45
  }
@@ -47,6 +47,9 @@ export function operatorRoutes(prefix: string, secret: string, door: Door, repor
47
47
  const value = await door.publishConfirmed(name, confirm as PublishPlanView, {
48
48
  ...(typeof owner === 'string' ? { owner } : {}),
49
49
  ...(typeof license === 'string' ? { license } : {}),
50
+ ...(to === 'npm' ? { to } : {}),
51
+ ...(typeof scope === 'string' ? { scope } : {}),
52
+ ...(typeof registry === 'string' ? { registry } : {}),
50
53
  })
51
54
  return c.json({ ok: true, value, text: JSON.stringify(value, null, 2) } satisfies CallResponse)
52
55
  } catch (cause) {
@@ -105,9 +105,9 @@ export const VERB_SPECS: Readonly<Record<Verb, VerbSpec>> = {
105
105
  arguments: { type: 'object', properties: { source: { type: 'string', description: 'github:<owner>/<repo>[@<version>][@sha256:<digest>], or a .tgz path or https address' }, from: { type: 'string', description: 'instead of source: a list of sources, a file in the app (e.g. group.txt) or an https address' } }, additionalProperties: false },
106
106
  },
107
107
  'plugin-publish': {
108
- usage: 'plugin publish <name> [--owner <account>] [--license <id>]: show what publishing this plugin would send; in a person\'s own terminal, ask them',
108
+ usage: 'plugin publish <name> [--owner <account>] [--license <id>] [--to npm [--scope <scope>] [--registry <address>]]: show what publishing this plugin would send; in a person\'s own terminal, ask them',
109
109
  description: 'Show what publishing a plugin would send: the account, repository, version, license, files and the line a friend pulls it with. Sends nothing. Only a person can say yes, in their own terminal or with Share in the frame; tell them the plan and how.',
110
- arguments: { type: 'object', properties: { name: { type: 'string', description: 'a plugin of plugins/' }, owner: { type: 'string', description: 'the GitHub account or organization; the signed-in one when absent' }, license: { type: 'string', description: 'an SPDX license id; MIT when absent' } }, required: ['name'], additionalProperties: false },
110
+ arguments: { type: 'object', properties: { name: { type: 'string', description: 'a plugin of plugins/' }, owner: { type: 'string', description: 'the GitHub account or organization; the signed-in one when absent' }, license: { type: 'string', description: 'an SPDX license id; MIT when absent' }, to: { type: 'string', enum: ['npm'], description: 'npm: publish to an npm registry with the person\'s own npm login instead of GitHub' }, scope: { type: 'string', description: 'with to npm: the package scope; the npm login\'s account when absent' }, registry: { type: 'string', description: 'with to npm: the registry address; the public one when absent' } }, required: ['name'], additionalProperties: false },
111
111
  },
112
112
  'plugin-remove': {
113
113
  usage: 'plugin remove <name>: stop and remove an installed plugin',
@@ -214,8 +214,15 @@ export function validate(document: unknown, known?: Iterable<string>): Diagnosti
214
214
  metadata.visibility !== 'public'
215
215
  )
216
216
  add('schema-error', 'metadata.visibility', "must be 'private' or 'public'")
217
- if (metadata.from !== undefined && (typeof metadata.from !== 'string' || metadata.from.trim() === ''))
218
- add('schema-error', 'metadata.from', "must name a source such as 'acrylblends.notes#0.3.1' or 'github:ana/notes#v0.2.0'")
217
+ if (
218
+ metadata.from !== undefined &&
219
+ (typeof metadata.from !== 'string' || metadata.from.trim() === '')
220
+ )
221
+ add(
222
+ 'schema-error',
223
+ 'metadata.from',
224
+ "must name a source such as 'acrylblends.notes#0.3.1' or 'github:ana/notes#v0.2.0'",
225
+ )
219
226
  }
220
227
 
221
228
  const spec = document.spec
@@ -8,8 +8,14 @@ Share plugins between people. Pull a plugin someone released into your running a
8
8
  npm run acryl -- plugin pull github:<owner>/<repo>@<version>
9
9
  ```
10
10
 
11
+ `registry:<id>` pulls what the public plugin registry (cordisplugins.github.io) lists under that id, checked against the integrity it lists.
12
+
11
13
  The line someone gives you after publishing also carries `@sha256:<digest>`. Then a release with different bytes is refused, with exit 1, and nothing changes.
12
14
 
15
+ A newer release of a plugin you already pulled updates it in place. A folder you never touched is replaced. A folder you changed is merged three ways
16
+ (the release you pulled, your folder, the new release; `merge-edits.ts`): a file only you changed keeps your change, a file both changed is merged line by
17
+ line with git, and when the same lines changed nothing is written and the pull is refused naming the file. The answer lists the files that kept your changes (`kept`).
18
+
13
19
  The app must be running (`npm run dev`), because the pull installs into it live. A stopped app never installs offline: the line exits 3 and asks you to start the app and run the same line again.
14
20
 
15
21
  The app remembers where each pulled plugin came from, in the `plugin-share` row of `blend.yaml`. A copy of the app fetches the same bytes at its next start.