@acryldev/blends 1.7.10 → 1.7.12

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.
Files changed (37) hide show
  1. package/dist/index.d.ts +13 -1
  2. package/dist/index.js +24 -5
  3. package/dist/index.js.map +1 -1
  4. package/lib/{audit-B2H3sUfg.d.ts → audit-D0McL8hN.d.ts} +1 -1
  5. package/lib/cordis/door.d.ts +4 -4
  6. package/lib/cordis/door.js +52 -3
  7. package/lib/door/host.d.ts +2 -2
  8. package/lib/door/host.js +1 -1
  9. package/lib/door/page.d.ts +5 -1
  10. package/lib/door/page.js +28 -5
  11. package/lib/door/protocol.d.ts +2 -2
  12. package/lib/door/protocol.js +2 -2
  13. package/lib/{protocol-8HjYa5OX.js → protocol-BKXK53WF.js} +39 -3
  14. package/lib/{protocol-DdQgl224.d.ts → protocol-CbLZdkJ5.d.ts} +31 -2
  15. package/lib/{snapshot-text-Cyl69OKv.js → snapshot-text-BYY2gA98.js} +2 -2
  16. package/pack/lib/create-source.mjs +12 -0
  17. package/pack/pack-blank-mac.mjs +693 -0
  18. package/package.json +3 -2
  19. package/plugins/door/package.json +1 -1
  20. package/plugins/door/src/cli/acryl.ts +12 -1
  21. package/plugins/door/src/host/door.ts +6 -0
  22. package/plugins/door/src/host/verbs.ts +15 -2
  23. package/plugins/door/src/page/driver/driver.ts +23 -2
  24. package/plugins/door/src/page/index.ts +11 -0
  25. package/plugins/door/src/page/protocol.ts +37 -2
  26. package/plugins/door/src/page/snapshot-text.ts +2 -1
  27. package/plugins/plugin-share/package.json +1 -1
  28. package/plugins/plugin-share/plugin.json +1 -1
  29. package/plugins/save/cli.ts +2 -0
  30. package/plugins/save/package.json +1 -1
  31. package/plugins/save/plugin.json +2 -4
  32. package/plugins/save/share-cli.ts +8 -1
  33. package/plugins/save/share.ts +123 -36
  34. package/shared/AGENTS.core.md +9 -0
  35. package/shared/library-history-versions.json +3 -1
  36. package/shared/library-history.json +9 -3
  37. package/shared/skills/acryl-app/SKILL.md +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/blends",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
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",
@@ -407,7 +407,8 @@
407
407
  "templates",
408
408
  "shared",
409
409
  "plugins",
410
- "docs"
410
+ "docs",
411
+ "pack"
411
412
  ],
412
413
  "engines": {
413
414
  "node": ">=22.19.0"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/door",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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": {
@@ -4,7 +4,7 @@
4
4
  * `.acryl/door.json` upward, or `--dir`), never through PATH or a machine-wide registry, so it reaches only the app running from that
5
5
  * folder. The secret is read from that file and sent as a `Bearer` header; it is never printed.
6
6
  *
7
- * acryl brief | look | act <op> ... | plugin list|add|remove|reload | tool list|call | window list|open|focus|close|resize | menu list|click | verbs (--json for the raw value)
7
+ * acryl brief | look | act <op> ... | frame ... | plugin list|add|remove|reload | tool list|call | window list|open|focus|close|resize | menu list|click | verbs (--json for the raw value)
8
8
  * acryl control <...> the same, the ACRYL Host form (`control snapshot`, `control click`, ... are look and act)
9
9
  *
10
10
  * Exit codes: 0 done, 1 the verb failed (its code and message are printed), 2 a usage error, 3 no running app in this folder.
@@ -43,6 +43,7 @@ const USAGE = `usage: acryl <verb> [options] [--json] [--dir <app folder>]
43
43
  act navigate --path <path of the app, e.g. /demo>
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
+ frame [open|close|toggle left|right | settings [<section>] | build | preview] (the ACRYL frame around the app; alone, what is open)
46
47
  plugin list | plugin add <folder> | plugin pull <source> | plugin publish <name> [--owner <account>] [--license <id>] | plugin remove <name> | plugin reload
47
48
  window list | window open [--path <p>] | window focus --id <n> | window close --id <n> [--force]
48
49
  window resize --id <n> --width <px> --height <px>
@@ -136,6 +137,16 @@ export function parseInvocation(argv: readonly string[], env: NodeJS.ProcessEnv
136
137
  ...(set.has('--gone') ? { gone: true } : {}),
137
138
  })
138
139
  }
140
+ case 'frame': {
141
+ const action = second ?? 'state'
142
+ if (action === 'open' || action === 'close' || action === 'toggle') {
143
+ if (third !== 'left' && third !== 'right') throw new UsageError(`frame ${action} needs left (branches and versions) or right (the agents)`)
144
+ return make('frame', { action, panel: third })
145
+ }
146
+ if (action === 'settings') return make('frame', { action, ...(third === undefined ? {} : { section: words.slice(2).join(' ') }) })
147
+ if (action === 'state' || action === 'build' || action === 'preview') return make('frame', { action })
148
+ throw new UsageError(`frame needs open|close|toggle left|right, settings [section], build or preview\n${USAGE}`)
149
+ }
139
150
  case 'plugin': {
140
151
  if (second === 'list' || second === 'reload') return make(`plugin-${second}`)
141
152
  if (second === 'add') { if (third === undefined) throw new UsageError('plugin add needs a folder, e.g. plugin add plugins/pomodoro'); return make('plugin-add', { folder: third }) }
@@ -191,6 +191,11 @@ export class Door {
191
191
  const result = await this.act(input, signal, scope)
192
192
  return { value: result, text: `done${result.target === undefined ? '' : `: ${result.target.role} "${result.target.name}"`}${result.detail === undefined ? '' : ` (${result.detail})`}; look again before the next act` }
193
193
  }
194
+ case 'frame': {
195
+ const { window, rest } = this.windowOf(input, scope)
196
+ const result = await this.callPage('frame', this.parse({ ...rest, op: 'frame' }), signal, window, scope.page) as UiActionResult
197
+ return { value: result, text: result.detail ?? 'done' }
198
+ }
194
199
  case 'plugin-list': return this.plugin(plugins => plugins.list(), false, this.installed())
195
200
  case 'plugin-add': return this.plugin(extensions => extensions.install(this.insideApp(input.folder)))
196
201
  case 'plugin-pull': return input.from === undefined ? this.pull(input.source) : this.pullList(input.from, input.source)
@@ -230,6 +235,7 @@ export class Door {
230
235
  read.length === 0 ? 'No AGENTS.md or skill in the folder.' : `Read first: ${read.join(', ')}.`,
231
236
  `Page: ${value.page}${value.page === 'not open' ? ' (open the app in a browser to look and act)' : ''}.`,
232
237
  `Live plugins: ${value.plugins}.`,
238
+ 'Asked to click, open, close, collapse, show or type on screen? Operate the interface (look, then act inside the page, frame for the ACRYL frame around it); never edit code for it unless the person asks to change the app.',
233
239
  'Verbs:',
234
240
  ...value.verbs.map(line => ` ${line}`),
235
241
  ].join('\n')
@@ -7,9 +7,9 @@ import { MAX_SNAPSHOT_NODES, MAX_WAIT_MS } from '../page/protocol.ts'
7
7
 
8
8
  /** Every verb, in the order `brief` lists them. */
9
9
  /** The verbs that only use the page: what a page-only door (a production assistant) offers. */
10
- export const PAGE_VERBS = ['look', 'act'] as const satisfies readonly Verb[]
10
+ export const PAGE_VERBS = ['look', 'act', 'frame'] as const satisfies readonly Verb[]
11
11
 
12
- export const VERBS = ['brief', 'look', 'act', 'plugin-list', 'plugin-add', 'plugin-pull', 'plugin-publish', 'plugin-remove', 'plugin-reload', 'tool-list', 'tool-call', 'window-list', 'window-open', 'window-focus', 'window-close', 'window-resize', 'menu-list', 'menu-click'] as const
12
+ export const VERBS = ['brief', 'look', 'act', 'frame', 'plugin-list', 'plugin-add', 'plugin-pull', 'plugin-publish', 'plugin-remove', 'plugin-reload', 'tool-list', 'tool-call', 'window-list', 'window-open', 'window-focus', 'window-close', 'window-resize', 'menu-list', 'menu-click'] as const
13
13
  export type Verb = (typeof VERBS)[number]
14
14
 
15
15
  /** The JSON Schema of a verb's arguments, as MCP lists it. */
@@ -76,6 +76,19 @@ export const VERB_SPECS: Readonly<Record<Verb, VerbSpec>> = {
76
76
  additionalProperties: false,
77
77
  },
78
78
  },
79
+ 'frame': {
80
+ usage: 'frame [open|close|toggle left|right | settings [<section>] | build | preview]: the ACRYL frame around the app (its panels, mode, Settings); alone, its state',
81
+ description: 'Operate the ACRYL frame around the app, which is not part of the app\'s page: open, close or toggle its left panel (branches and versions) or right panel (the agents), open Settings (optionally at a section such as App or Share), or switch Build and Preview. Without an action it says what is open (look says it too). A request to collapse, open or show these is done here, never by editing the app.',
82
+ arguments: {
83
+ type: 'object',
84
+ properties: {
85
+ action: { type: 'string', enum: ['state', 'open', 'close', 'toggle', 'settings', 'build', 'preview'], description: 'default: state' },
86
+ panel: { type: 'string', enum: ['left', 'right'], description: 'open, close, toggle: left is branches and versions, right is the agents' },
87
+ section: { type: 'string', description: 'settings: the section to show, e.g. App, Share, Plugins' },
88
+ },
89
+ additionalProperties: false,
90
+ },
91
+ },
79
92
  'plugin-list': {
80
93
  usage: 'plugin list: the plugins installed while the app runs',
81
94
  description: 'The plugins installed into the running app.',
@@ -5,7 +5,7 @@
5
5
  * shows. It touches only the document it is given, never another window and never the OS.
6
6
  */
7
7
 
8
- import { UiControlError, MUTATING_OPS, type UiActionResult, type UiRequest, type UiResult } from '../protocol.ts'
8
+ import { UiControlError, MUTATING_OPS, type FrameControl, type FrameState, type UiActionResult, type UiRequest, type UiResult } from '../protocol.ts'
9
9
  import { click, pressKey, scroll, selectOption, typeText, wait, type ActionEnvironment } from './actions.ts'
10
10
  import { RefTable } from './ref-table.ts'
11
11
  import { SnapshotBuilder } from './snapshot.ts'
@@ -39,6 +39,8 @@ export interface UiDriverOptions {
39
39
  readonly touched?: (element: Element) => void
40
40
  /** Leave the page: reload it, or go to a path of the app. Default: the document's own `location`, a moment after the answer is sent. */
41
41
  readonly leave?: (to: { readonly reload: true } | { readonly path: string }) => void
42
+ /** The ACRYL frame around the page, when there is one: `look` reports it and `frame` operates it. */
43
+ readonly frame?: () => FrameControl | undefined
42
44
  }
43
45
 
44
46
  function realSleep(ms: number, signal: AbortSignal): Promise<void> {
@@ -151,7 +153,17 @@ export class UiDriver {
151
153
 
152
154
  private async run(request: UiRequest, signal: AbortSignal): Promise<UiResult> {
153
155
  switch (request.op) {
154
- case 'snapshot': return this.snapshots.snapshot({ ...(request.cursor === undefined ? {} : { cursor: request.cursor }), ...(request.maxNodes === undefined ? {} : { maxNodes: request.maxNodes }) })
156
+ case 'snapshot': {
157
+ const snapshot = this.snapshots.snapshot({ ...(request.cursor === undefined ? {} : { cursor: request.cursor }), ...(request.maxNodes === undefined ? {} : { maxNodes: request.maxNodes }) })
158
+ const frame = this.frameState()
159
+ return frame === undefined ? snapshot : { ...snapshot, frame }
160
+ }
161
+ case 'frame': {
162
+ const control = this.options.frame?.()
163
+ if (control === undefined) throw new UiControlError('not-actionable', 'this page is not inside the ACRYL frame (it runs on its own), so there is no frame to operate')
164
+ const detail = await control.run(request)
165
+ return { ok: true, detail }
166
+ }
155
167
  case 'click': return await this.watchLeaving(() => click(this.env, request), signal)
156
168
  case 'type': return await this.watchLeaving(() => typeText(this.env, request), signal)
157
169
  case 'select': return selectOption(this.env, request)
@@ -163,6 +175,15 @@ export class UiDriver {
163
175
  }
164
176
  }
165
177
 
178
+ /** The frame's state, or undefined when the page is not in a frame or the frame cannot be read. */
179
+ private frameState(): FrameState | undefined {
180
+ try {
181
+ return this.options.frame?.()?.state()
182
+ } catch {
183
+ return undefined
184
+ }
185
+ }
186
+
166
187
  /**
167
188
  * Run an act that may start a navigation (a click on a link, Enter in a form) and say so: the browser asks `beforeunload` when a navigation starts, during the act or a
168
189
  * moment after it. The answer is sent before the page goes; the Host then waits for the next page instead of reading this one again.
@@ -10,6 +10,7 @@ import { UiDriver } from './driver/driver.ts'
10
10
  import { mountIndicator } from './indicator.ts'
11
11
  import { mountOutlines } from './outline.ts'
12
12
  import { UserInputClock } from './user-input.ts'
13
+ import { FRAME_CONTROL_KEY, type FrameControl } from './protocol.ts'
13
14
 
14
15
  export const DOOR_BASE = '/api/acryl-door'
15
16
 
@@ -48,6 +49,16 @@ export function startDoor(document: Document, base: string = DOOR_BASE): () => v
48
49
  document: () => document,
49
50
  msSinceUserInput: clock.msSince,
50
51
  touched: (element) => { outlines.touched(element) },
52
+ // The ACRYL frame publishes its control on its own window; this page is its canvas (same origin). A page on its own has no parent and no frame.
53
+ frame: () => {
54
+ try {
55
+ if (view.parent === view) return undefined
56
+ const control = (view.parent as unknown as Record<symbol, FrameControl | undefined>)[FRAME_CONTROL_KEY]
57
+ return typeof control?.run === 'function' && typeof control.state === 'function' ? control : undefined
58
+ } catch {
59
+ return undefined
60
+ }
61
+ },
51
62
  // A host that serves the app under a prefix (the ACRYL frame's canvas) marks its pages: an app path navigates under that prefix, so the same
52
63
  // `act navigate --path /board` reaches the app's /board in the frame and on the app's own server.
53
64
  ...(appBase === '' ? {} : {
@@ -6,12 +6,33 @@
6
6
  * lives with the page code and has no Node imports.
7
7
  */
8
8
 
9
+ /**
10
+ * The ACRYL frame around a canvas page: its own panels, mode and Settings, which are not part of the app's page. The frame publishes a
11
+ * {@link FrameControl} on its window under {@link FRAME_CONTROL_KEY}; the door's page script, running in the canvas, reaches it as `window.parent`.
12
+ */
13
+ export const FRAME_CONTROL_KEY: symbol = Symbol.for('acryl.frame.control')
14
+ export const FRAME_ACTIONS = ['state', 'open', 'close', 'toggle', 'settings', 'build', 'preview'] as const
15
+ export type FrameAction = (typeof FRAME_ACTIONS)[number]
16
+ export type FramePanel = 'left' | 'right'
17
+ /** What the frame shows: its left panel (branches and versions), its right panel (the agents), its mode, and whether Settings is open. */
18
+ export interface FrameState {
19
+ readonly left: boolean
20
+ readonly right: boolean
21
+ readonly mode: 'build' | 'preview'
22
+ readonly settings: boolean
23
+ }
24
+ export interface FrameControl {
25
+ state(): FrameState
26
+ /** Do one frame action; the answer says what changed. @throws Error with a reason a person can read. */
27
+ run(request: Extract<UiRequest, { readonly op: 'frame' }>): string | Promise<string>
28
+ }
29
+
9
30
  /** The operations the driver performs on the page. */
10
- export const UI_OPS = ['snapshot', 'click', 'type', 'select', 'press', 'scroll', 'wait', 'reload', 'navigate'] as const
31
+ export const UI_OPS = ['snapshot', 'click', 'type', 'select', 'press', 'scroll', 'wait', 'reload', 'navigate', 'frame'] as const
11
32
  export type UiOp = (typeof UI_OPS)[number]
12
33
 
13
34
  /** Operations that change the page, so each call needs approval. `snapshot`, `scroll` and `wait` only look. */
14
- export const MUTATING_OPS: readonly UiOp[] = ['click', 'type', 'select', 'press', 'reload', 'navigate']
35
+ export const MUTATING_OPS: readonly UiOp[] = ['click', 'type', 'select', 'press', 'reload', 'navigate', 'frame']
15
36
 
16
37
  /** A place in the app to go to: a path on the page's own origin (`/demo`, `/notes?q=a#top`), never another site and never a `//host` address. */
17
38
  export const APP_PATH = /^\/(?![/\\])[^\0\\]{0,2000}$/u
@@ -72,6 +93,8 @@ export interface UiSnapshot {
72
93
  readonly total: number
73
94
  /** Pass to the next snapshot call to continue, or absent when this is everything. */
74
95
  readonly nextCursor?: number
96
+ /** The ACRYL frame around this page, when the page is in one. */
97
+ readonly frame?: FrameState
75
98
  }
76
99
 
77
100
  export type UiRequest =
@@ -84,6 +107,7 @@ export type UiRequest =
84
107
  | { readonly op: 'wait'; readonly text?: string; readonly role?: string; readonly name?: string; readonly gone?: boolean; readonly timeoutMs?: number }
85
108
  | { readonly op: 'reload' }
86
109
  | { readonly op: 'navigate'; readonly path: string }
110
+ | { readonly op: 'frame'; readonly action: FrameAction; readonly panel?: FramePanel; readonly section?: string }
87
111
 
88
112
  /** What the page did, and to which control (for the audit log and the approval prompt). */
89
113
  export interface UiActionResult {
@@ -181,6 +205,17 @@ export function parseUiRequest(value: unknown): UiRequest {
181
205
  if (typeof value.path !== 'string' || !APP_PATH.test(value.path)) return invalid('path must be a path of this app, such as /demo (it starts with one /, and names no other site)')
182
206
  return { op, path: value.path }
183
207
  }
208
+ case 'frame': {
209
+ only(['action', 'panel', 'section'])
210
+ const action = value.action === undefined ? 'state' : value.action
211
+ if (!FRAME_ACTIONS.includes(action as FrameAction)) return invalid(`frame action must be one of ${FRAME_ACTIONS.join(', ')}`)
212
+ const panel = value.panel
213
+ if (panel !== undefined && panel !== 'left' && panel !== 'right') return invalid('panel must be left or right')
214
+ if ((action === 'open' || action === 'close' || action === 'toggle') && panel === undefined) return invalid(`frame ${String(action)} needs a panel: left (branches and versions) or right (the agents)`)
215
+ const section = value.section === undefined ? undefined : text(value.section, 80)
216
+ if (section !== undefined && action !== 'settings') return invalid('section goes with settings')
217
+ return { op, action: action as FrameAction, ...(panel === undefined ? {} : { panel }), ...(section === undefined ? {} : { section }) }
218
+ }
184
219
  default: return invalid(`unknown op ${String(op)}`)
185
220
  }
186
221
  }
@@ -15,5 +15,6 @@ export function renderSnapshot(snapshot: UiSnapshot, more: (cursor: number) => s
15
15
  return `${' '.repeat(Math.min(node.depth, 8))}- ${node.role}${node.name === '' ? '' : ` ${JSON.stringify(node.name)}`}${level}${states}${value}${options} [ref=${node.ref}]`
16
16
  })
17
17
  const rest = snapshot.nextCursor === undefined ? '' : `\n(${String(snapshot.total - snapshot.nextCursor)} more elements; ${more(snapshot.nextCursor)})`
18
- return `Page: ${snapshot.title || '(untitled)'}\nSnapshot ${String(snapshot.generation)}, ${String(snapshot.nodes.length)} of ${String(snapshot.total)} elements:\n${lines.join('\n')}${rest}`
18
+ const frame = snapshot.frame === undefined ? '' : `Frame (the ACRYL window around the app, not part of the app): left panel (branches, versions) ${snapshot.frame.left ? 'open' : 'closed'}, right panel (agents) ${snapshot.frame.right ? 'open' : 'closed'}, ${snapshot.frame.mode} mode${snapshot.frame.settings ? ', Settings open' : ''}. Operate it with frame (open|close|toggle left|right, settings [section], build, preview), never by editing code.\n`
19
+ return `${frame}Page: ${snapshot.title || '(untitled)'}\nSnapshot ${String(snapshot.generation)}, ${String(snapshot.nodes.length)} of ${String(snapshot.total)} elements:\n${lines.join('\n')}${rest}`
19
20
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/plugin-share",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Share plugins between people. Pull one someone released into the running app: fetched without running anything, checked by digest and for every OS, then installed live. Publish one, only as a plan a person confirmed.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -6,7 +6,7 @@
6
6
  "provides": ["pluginShare"],
7
7
  "dependencies": {
8
8
  "@deepseek-ai/cordis": "4.0.4",
9
- "@acryldev/app-persistence": "0.1.4",
9
+ "@acryldev/app-persistence": "0.1.5",
10
10
  "@acryldev/blends-core": "0.6.0",
11
11
  "@acryldev/plugin-hub-core": "0.2.3",
12
12
  "yaml": "2.9.0"
@@ -1,10 +1,12 @@
1
1
  /** `npm run save -- "message"`: save the app folder this file lives in. Prints the result; exits 1 when the save was refused. */
2
2
  import { resolve } from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
+ import { adoptGithubToken } from '@acryldev/app-persistence'
4
5
  import { saveFolder } from './index.ts'
5
6
 
6
7
  if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
7
8
  const appRoot = fileURLToPath(new URL('../..', import.meta.url))
9
+ adoptGithubToken()
8
10
  const result = saveFolder(appRoot, process.argv.slice(2).join(' ').trim() || 'save the app')
9
11
  if (result.status === 'refused') {
10
12
  console.error(`not saved: ${result.reason}`)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/save",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Save the app to its own git repository, and share it: a repository of its own on GitHub, created and pushed only after a person confirms the plan. Refuses a file that holds a secret, and a private app going to a public remote.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -2,13 +2,11 @@
2
2
  "name": "save",
3
3
  "description": "Save the app to its own git repository, and share it: a repository of its own on GitHub, created and pushed only after a person confirms the plan. Refuses a file that holds a secret, and a private app going to a public remote.",
4
4
  "requires": [],
5
- "inject": [
6
- "appInstance"
7
- ],
5
+ "inject": ["appInstance"],
8
6
  "provides": [],
9
7
  "dependencies": {
10
8
  "@deepseek-ai/cordis": "4.0.4",
11
- "@acryldev/app-persistence": "0.1.4"
9
+ "@acryldev/app-persistence": "0.1.5"
12
10
  },
13
11
  "mount": "mount the plugin to give the agent a save_app tool; its scripts (npm run save, npm run share) are added to package.json with it",
14
12
  "entries": {
@@ -13,7 +13,12 @@ import { realpathSync } from 'node:fs'
13
13
  import { createInterface } from 'node:readline/promises'
14
14
  import { fileURLToPath } from 'node:url'
15
15
  import { parseArgs } from 'node:util'
16
- import { CATEGORIES_URL, type CatalogCategory, readCategories } from '@acryldev/app-persistence'
16
+ import {
17
+ adoptGithubToken,
18
+ CATEGORIES_URL,
19
+ type CatalogCategory,
20
+ readCategories,
21
+ } from '@acryldev/app-persistence'
17
22
  import { planShare, renderSharePlan, type SharePlan, type ShareResult, shareApp } from './share.ts'
18
23
 
19
24
  function report(result: ShareResult): number {
@@ -79,6 +84,8 @@ const HELP = `npm run share [-- options]: send this app to a GitHub repository o
79
84
  Example: npm run share -- --visibility public --list --category business --subcategory crm`
80
85
 
81
86
  async function main(argv: readonly string[]): Promise<number> {
87
+ // The GitHub sign-in made in Control Center or in an app (`~/.acryl/github.json`) is this share's login: gh and git start with it, and fall back to their own login without it.
88
+ adoptGithubToken()
82
89
  const appRoot = fileURLToPath(new URL('../..', import.meta.url))
83
90
  const { values } = parseArgs({
84
91
  args: [...argv],
@@ -11,8 +11,8 @@ import {
11
11
  type AppIdentity,
12
12
  type CatalogCategory,
13
13
  connectRemote,
14
- type GitPort,
15
14
  GITHUB_VIA_GH,
15
+ type GitPort,
16
16
  gitCli,
17
17
  githubHosting,
18
18
  type HostingPort,
@@ -82,7 +82,11 @@ export interface ShareOptions {
82
82
  /** Who may see a new repository; blend.yaml's metadata.visibility when absent. A share with it records it there, so later saves agree. */
83
83
  readonly visibility?: Visibility
84
84
  /** List it in the Blends store. Any part not given is taken from the app: its earlier listing, else its starter's category; licence MIT. */
85
- readonly list?: { readonly category?: string; readonly subcategory?: string; readonly license?: string }
85
+ readonly list?: {
86
+ readonly category?: string
87
+ readonly subcategory?: string
88
+ readonly license?: string
89
+ }
86
90
  /** The published category list (acrylblends.github.io/categories.json), to check the place against; unchecked when absent. */
87
91
  readonly categories?: readonly CatalogCategory[]
88
92
  }
@@ -119,12 +123,21 @@ export function sharePorts(appRoot: string): SharePorts {
119
123
  list: (repository, tag) => {
120
124
  const must = (command: string, args: readonly string[], what: string) => {
121
125
  const result = run(command, args)
122
- if (result.status !== 0) throw new PersistenceError(`${what}: ${(result.stderr || result.stdout).trim()}`)
126
+ if (result.status !== 0)
127
+ throw new PersistenceError(`${what}: ${(result.stderr || result.stdout).trim()}`)
123
128
  }
124
- must('gh', ['repo', 'edit', repository, '--add-topic', BLEND_TOPIC], 'could not label the repository for the Blends store')
129
+ must(
130
+ 'gh',
131
+ ['repo', 'edit', repository, '--add-topic', BLEND_TOPIC],
132
+ 'could not label the repository for the Blends store',
133
+ )
125
134
  if (run('git', ['rev-parse', '-q', '--verify', `refs/tags/${tag}`]).status === 0) return false
126
135
  must('git', ['tag', tag], `could not tag ${tag}`)
127
- must('git', [...GITHUB_VIA_GH, 'push', '--quiet', 'origin', `refs/tags/${tag}`], `could not push ${tag}`)
136
+ must(
137
+ 'git',
138
+ [...GITHUB_VIA_GH, 'push', '--quiet', 'origin', `refs/tags/${tag}`],
139
+ `could not push ${tag}`,
140
+ )
128
141
  return true
129
142
  },
130
143
  }
@@ -145,10 +158,23 @@ const repositoryName = (name: string): string =>
145
158
  export const githubRepository = (remote: string): string | undefined =>
146
159
  /github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?\/?$/u.exec(remote)?.[1]
147
160
 
148
- const INSTALL_SCRIPTS = ['preinstall', 'install', 'postinstall', 'prepublish', 'preprepare', 'prepare', 'postprepare']
161
+ const INSTALL_SCRIPTS = [
162
+ 'preinstall',
163
+ 'install',
164
+ 'postinstall',
165
+ 'prepublish',
166
+ 'preprepare',
167
+ 'prepare',
168
+ 'postprepare',
169
+ ]
149
170
  const LICENSE_ID = /^[A-Za-z0-9][A-Za-z0-9.+-]*$/u
150
171
 
151
- interface PackageJson { version?: unknown; keywords?: unknown; scripts?: Record<string, unknown>; [key: string]: unknown }
172
+ interface PackageJson {
173
+ version?: unknown
174
+ keywords?: unknown
175
+ scripts?: Record<string, unknown>
176
+ [key: string]: unknown
177
+ }
152
178
  const packageOf = (appRoot: string): PackageJson | undefined => {
153
179
  try {
154
180
  return JSON.parse(readFileSync(join(appRoot, 'package.json'), 'utf8')) as PackageJson
@@ -158,26 +184,48 @@ const packageOf = (appRoot: string): PackageJson | undefined => {
158
184
  }
159
185
 
160
186
  /** The store listing a share asked for, as the person will read it, or why it cannot be listed. */
161
- function planListing(appRoot: string, identity: AppIdentity, visibility: Visibility, repository: string | undefined, options: ShareOptions): StoreListing | ShareRefused | undefined {
187
+ function planListing(
188
+ appRoot: string,
189
+ identity: AppIdentity,
190
+ visibility: Visibility,
191
+ repository: string | undefined,
192
+ options: ShareOptions,
193
+ ): StoreListing | ShareRefused | undefined {
162
194
  const asked = options.list
163
195
  if (asked === undefined) return undefined
164
- if (visibility !== 'public') return refused('only a public app can be listed in the Blends store: choose public')
165
- if (repository === undefined) return refused('only an app on GitHub can be listed in the Blends store')
166
- if (identity.description === undefined) return refused('the store lists an app with its description: add one to blend.yaml (metadata.description)')
196
+ if (visibility !== 'public')
197
+ return refused('only a public app can be listed in the Blends store: choose public')
198
+ if (repository === undefined)
199
+ return refused('only an app on GitHub can be listed in the Blends store')
200
+ if (identity.description === undefined)
201
+ return refused(
202
+ 'the store lists an app with its description: add one to blend.yaml (metadata.description)',
203
+ )
167
204
  const pkg = packageOf(appRoot)
168
205
  if (pkg === undefined) return refused('the app has no readable package.json')
169
- const script = INSTALL_SCRIPTS.find(name => typeof pkg.scripts?.[name] === 'string')
170
- if (script !== undefined) return refused(`package.json defines the install script "${script}", which a listed app may not`)
206
+ const script = INSTALL_SCRIPTS.find((name) => typeof pkg.scripts?.[name] === 'string')
207
+ if (script !== undefined)
208
+ return refused(
209
+ `package.json defines the install script "${script}", which a listed app may not`,
210
+ )
171
211
  const categories = options.categories ?? []
172
- const placement: Placement | undefined = asked.category !== undefined
173
- ? { category: asked.category, ...(asked.subcategory === undefined ? {} : { subcategory: asked.subcategory }) }
174
- : placementOf(pkg.keywords) ?? suggestPlacement(identity.category, categories)
175
- if (placement === undefined) return refused('choose its category, one of acrylblends.github.io/blends (for example --category gaming)')
212
+ const placement: Placement | undefined =
213
+ asked.category !== undefined
214
+ ? {
215
+ category: asked.category,
216
+ ...(asked.subcategory === undefined ? {} : { subcategory: asked.subcategory }),
217
+ }
218
+ : (placementOf(pkg.keywords) ?? suggestPlacement(identity.category, categories))
219
+ if (placement === undefined)
220
+ return refused(
221
+ 'choose its category, one of acrylblends.github.io/blends (for example --category gaming)',
222
+ )
176
223
  const problem = categories.length > 0 ? placementProblem(placement, categories) : undefined
177
224
  if (problem !== undefined) return refused(problem)
178
225
  const license = asked.license ?? identity.license ?? 'MIT'
179
- if (!LICENSE_ID.test(license)) return refused(`"${license}" is not a licence id (such as MIT or Apache-2.0)`)
180
- const version = typeof pkg.version === 'string' ? pkg.version : identity.version ?? '0.1.0'
226
+ if (!LICENSE_ID.test(license))
227
+ return refused(`"${license}" is not a licence id (such as MIT or Apache-2.0)`)
228
+ const version = typeof pkg.version === 'string' ? pkg.version : (identity.version ?? '0.1.0')
181
229
  const name = (identity.id ?? '').split('.').slice(1).join('.') || repository.split('/')[1] || ''
182
230
  const id = `${(repository.split('/')[0] ?? '').toLowerCase()}.${name.toLowerCase()}`
183
231
  return { id, placement, license, tag: `v${version}` }
@@ -210,20 +258,44 @@ SOFTWARE.
210
258
  * The files the store reads, written into the app before it is saved: the licence in blend.yaml (and an MIT LICENSE file when it has none),
211
259
  * the marker and placement keywords in package.json, and the acryl.template.json that lets people start an app from it. Returns blend.yaml's text.
212
260
  */
213
- function writeListing(appRoot: string, manifestText: string, listing: StoreListing, repository: string): string {
261
+ function writeListing(
262
+ appRoot: string,
263
+ manifestText: string,
264
+ listing: StoreListing,
265
+ repository: string,
266
+ ): string {
214
267
  const identity = readAppIdentity(manifestText)
215
268
  let text = manifestText
216
269
  if (identity.id !== listing.id) text = withId(text, listing.id)
217
270
  if (identity.license !== listing.license) text = withLicense(text, listing.license)
218
271
  if (text !== manifestText) writeFileSync(join(appRoot, 'blend.yaml'), text)
219
272
  const pkg = packageOf(appRoot) ?? {}
220
- const before = Array.isArray(pkg.keywords) ? pkg.keywords.filter((word): word is string => typeof word === 'string') : []
221
- const keywords = withPlacement(before.includes(BLEND_TOPIC) ? before : [...before, BLEND_TOPIC], listing.placement)
222
- if (JSON.stringify(keywords) !== JSON.stringify(pkg.keywords)) writeFileSync(join(appRoot, 'package.json'), `${JSON.stringify({ ...pkg, keywords }, null, 2)}\n`)
273
+ const before = Array.isArray(pkg.keywords)
274
+ ? pkg.keywords.filter((word): word is string => typeof word === 'string')
275
+ : []
276
+ const keywords = withPlacement(
277
+ before.includes(BLEND_TOPIC) ? before : [...before, BLEND_TOPIC],
278
+ listing.placement,
279
+ )
280
+ if (JSON.stringify(keywords) !== JSON.stringify(pkg.keywords))
281
+ writeFileSync(
282
+ join(appRoot, 'package.json'),
283
+ `${JSON.stringify({ ...pkg, keywords }, null, 2)}\n`,
284
+ )
223
285
  const template = join(appRoot, 'acryl.template.json')
224
- if (!existsSync(template)) writeFileSync(template, `${JSON.stringify({ name: identity.name ?? basename(appRoot), description: identity.description ?? '' }, null, 2)}\n`)
225
- if (listing.license === 'MIT' && !['LICENSE', 'LICENSE.md', 'LICENSE.txt'].some(file => existsSync(join(appRoot, file))))
226
- writeFileSync(join(appRoot, 'LICENSE'), MIT(new Date().getFullYear(), repository.split('/')[0] ?? ''))
286
+ if (!existsSync(template))
287
+ writeFileSync(
288
+ template,
289
+ `${JSON.stringify({ name: identity.name ?? basename(appRoot), description: identity.description ?? '' }, null, 2)}\n`,
290
+ )
291
+ if (
292
+ listing.license === 'MIT' &&
293
+ !['LICENSE', 'LICENSE.md', 'LICENSE.txt'].some((file) => existsSync(join(appRoot, file)))
294
+ )
295
+ writeFileSync(
296
+ join(appRoot, 'LICENSE'),
297
+ MIT(new Date().getFullYear(), repository.split('/')[0] ?? ''),
298
+ )
227
299
  return text
228
300
  }
229
301
 
@@ -235,12 +307,22 @@ export function planShare(
235
307
  ): SharePlan | ShareRefused {
236
308
  const plan = planRepository(appRoot, options, ports)
237
309
  if ('ok' in plan) return plan
238
- const listing = planListing(appRoot, readAppIdentity(manifestOf(appRoot)), plan.visibility, plan.create ? plan.repository : githubRepository(plan.repository), options)
310
+ const listing = planListing(
311
+ appRoot,
312
+ readAppIdentity(manifestOf(appRoot)),
313
+ plan.visibility,
314
+ plan.create ? plan.repository : githubRepository(plan.repository),
315
+ options,
316
+ )
239
317
  if (listing !== undefined && 'ok' in listing) return listing
240
318
  return listing === undefined ? plan : { ...plan, listing }
241
319
  }
242
320
 
243
- function planRepository(appRoot: string, options: ShareOptions, ports: SharePorts): SharePlan | ShareRefused {
321
+ function planRepository(
322
+ appRoot: string,
323
+ options: ShareOptions,
324
+ ports: SharePorts,
325
+ ): SharePlan | ShareRefused {
244
326
  const identity = readAppIdentity(manifestOf(appRoot))
245
327
  const visibility = options.visibility ?? identity.visibility
246
328
  const changes = ports.pending()
@@ -301,7 +383,8 @@ export function shareApp(
301
383
  }
302
384
  const repository = now.create ? now.repository : githubRepository(now.repository)
303
385
  try {
304
- if (now.listing !== undefined && repository !== undefined) manifestText = writeListing(appRoot, manifestText, now.listing, repository)
386
+ if (now.listing !== undefined && repository !== undefined)
387
+ manifestText = writeListing(appRoot, manifestText, now.listing, repository)
305
388
  let remote = now.repository
306
389
  if (now.create) {
307
390
  const connected = connectRemote(
@@ -321,9 +404,10 @@ export function shareApp(
321
404
  }
322
405
  // Nothing new to save: the versions already saved still have to reach the remote.
323
406
  if (saved.status === 'nothing-to-save') ports.git.push()
324
- const listed = now.listing !== undefined && repository !== undefined
325
- ? { tag: now.listing.tag, created: ports.list(repository, now.listing.tag) }
326
- : undefined
407
+ const listed =
408
+ now.listing !== undefined && repository !== undefined
409
+ ? { tag: now.listing.tag, created: ports.list(repository, now.listing.tag) }
410
+ : undefined
327
411
  return {
328
412
  ok: true,
329
413
  remote,
@@ -346,11 +430,14 @@ export function renderSharePlan(plan: SharePlan): string {
346
430
  plan.changes === 0
347
431
  ? 'the versions saved so far'
348
432
  : `${String(plan.changes)} changed ${plan.changes === 1 ? 'file' : 'files'}, saved first, and the versions saved so far`
349
- const listed = plan.listing === undefined
350
- ? ''
351
- : ` Listed in the Blends store as ${plan.listing.id}, Community, under ${placementWords(plan.listing.placement)} (licence ${plan.listing.license}, people start from ${plan.listing.tag}).`
433
+ const listed =
434
+ plan.listing === undefined
435
+ ? ''
436
+ : ` Listed in the Blends store as ${plan.listing.id}, Community, under ${placementWords(plan.listing.placement)} (licence ${plan.listing.license}, people start from ${plan.listing.tag}).`
352
437
  return `Share this app to ${where}: ${what}.${listed}`
353
438
  }
354
439
 
355
440
  const placementWords = (placement: Placement): string =>
356
- placement.subcategory === undefined ? placement.category : `${placement.category} › ${placement.subcategory}`
441
+ placement.subcategory === undefined
442
+ ? placement.category
443
+ : `${placement.category} › ${placement.subcategory}`
@@ -3,6 +3,15 @@
3
3
  A Cordis app on the ACRYL framework: TypeScript that Node 22.19 or newer runs directly (no build step; erasable syntax only, so no enums and no
4
4
  parameter properties). Every part of it is a Cordis plugin.
5
5
 
6
+ ## Using the interface is not changing the app
7
+
8
+ A request to click, open, close, collapse, expand, show, hide, scroll, select or type something on screen ("collapse the left panel", "open Settings",
9
+ "click Save", "show the chart", "type milk in the search") is done by operating the interface, never by changing code. Use `.acryl/bin/acryl`:
10
+ `look` first (it also says what the ACRYL frame shows), then `act` for anything inside the app's page, and `frame` for the ACRYL frame around the
11
+ app, which is not part of the app: its left panel (branches and versions), its right panel (the agents), Build and Preview, and Settings
12
+ (`frame close left`, `frame open right`, `frame settings Share`, `frame preview`). Change code only when the person asks to change the app
13
+ ("add", "build", "make it", "fix", "change how it works").
14
+
6
15
  ## The framework's API is in `docs/framework/`
7
16
 
8
17
  Start at `docs/framework/README.md`; `api/summary.md` is the one-page summary. Read before you write routes: `api/routing.md` (the `Acryl` app), `api/request.md` (`c.req`),