@acryldev/harness-runtime 0.0.0-stage → 0.2.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 (167) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +14 -2
  3. package/lib/index.mjs +5693 -0
  4. package/lib/index.mjs.map +1 -0
  5. package/lib/types/acryl-home.d.ts +81 -0
  6. package/lib/types/app/new-app.d.ts +65 -0
  7. package/lib/types/app/start-source.d.ts +47 -0
  8. package/lib/types/blueprint/blueprint.d.ts +74 -0
  9. package/lib/types/blueprint/brand-identity.d.ts +26 -0
  10. package/lib/types/blueprint/compose.d.ts +53 -0
  11. package/lib/types/blueprint/definition.d.ts +22 -0
  12. package/lib/types/blueprint/index.d.ts +7 -0
  13. package/lib/types/blueprint/manifest.d.ts +35 -0
  14. package/lib/types/blueprint/selection.d.ts +19 -0
  15. package/lib/types/cli-market-install.d.ts +97 -0
  16. package/lib/types/cli-market-plugins.d.ts +81 -0
  17. package/lib/types/coding-capabilities.d.ts +29 -0
  18. package/lib/types/durable-message.d.ts +18 -0
  19. package/lib/types/engine-dsh.d.ts +181 -0
  20. package/lib/types/engine-files.d.ts +8 -0
  21. package/lib/types/engine-host.d.ts +32 -0
  22. package/lib/types/engine-tools.d.ts +11 -0
  23. package/lib/types/index.d.ts +67 -0
  24. package/lib/types/instance/announce-self.d.ts +38 -0
  25. package/lib/types/instance/app-instance.d.ts +125 -0
  26. package/lib/types/instance/index.d.ts +6 -0
  27. package/lib/types/instance/offline-lock.d.ts +29 -0
  28. package/lib/types/instance/online-secret.d.ts +29 -0
  29. package/lib/types/instance/registry.d.ts +26 -0
  30. package/lib/types/instance/select.d.ts +43 -0
  31. package/lib/types/module-hooks.d.ts +19 -0
  32. package/lib/types/module-resolution.d.ts +31 -0
  33. package/lib/types/package-overlay.d.ts +41 -0
  34. package/lib/types/pinned-pnpm.d.ts +15 -0
  35. package/lib/types/plugin-acryl-workspace-status.d.ts +24 -0
  36. package/lib/types/plugin-doctor.d.ts +49 -0
  37. package/lib/types/plugin-lifecycle-state.d.ts +92 -0
  38. package/lib/types/plugin-lifecycle.d.ts +87 -0
  39. package/lib/types/profile-layout.d.ts +17 -0
  40. package/lib/types/profile-owner.d.ts +25 -0
  41. package/lib/types/profile-repair/backup.d.ts +37 -0
  42. package/lib/types/profile-repair/findings.d.ts +29 -0
  43. package/lib/types/profile-repair/index.d.ts +9 -0
  44. package/lib/types/profile-repair/inspector.d.ts +11 -0
  45. package/lib/types/profile-repair/repair.d.ts +38 -0
  46. package/lib/types/profile-resolution/moved-framework.d.ts +21 -0
  47. package/lib/types/profile-resolution/resolver.d.ts +41 -0
  48. package/lib/types/profile-resolution/service.d.ts +22 -0
  49. package/lib/types/prompt-budget.d.ts +44 -0
  50. package/lib/types/session-bridge.d.ts +57 -0
  51. package/lib/types/session-log-exporter.d.ts +31 -0
  52. package/lib/types/system-prompt-capture.d.ts +29 -0
  53. package/lib/types/web-favicon-data.d.ts +5 -0
  54. package/lib/types/web-favicon.d.ts +23 -0
  55. package/lib/types/web-market-install.d.ts +114 -0
  56. package/lib/types/web-market-plugins.d.ts +106 -0
  57. package/lib/types/web-port.d.ts +15 -0
  58. package/package.json +211 -3
  59. package/src/acryl-home.ts +103 -0
  60. package/src/app/new-app.ts +239 -0
  61. package/src/app/start-source.ts +110 -0
  62. package/src/blueprint/blueprint.ts +141 -0
  63. package/src/blueprint/brand-identity.ts +75 -0
  64. package/src/blueprint/compose.ts +222 -0
  65. package/src/blueprint/definition.ts +92 -0
  66. package/src/blueprint/index.ts +20 -0
  67. package/src/blueprint/manifest.ts +145 -0
  68. package/src/blueprint/selection.ts +74 -0
  69. package/src/cli-market-install.ts +181 -0
  70. package/src/cli-market-plugins.ts +176 -0
  71. package/src/coding-capabilities.ts +61 -0
  72. package/src/durable-message.ts +23 -0
  73. package/src/engine-dsh.ts +856 -0
  74. package/src/engine-files.ts +9 -0
  75. package/src/engine-host.ts +128 -0
  76. package/src/engine-tools.ts +26 -0
  77. package/src/index.ts +436 -0
  78. package/src/instance/announce-self.ts +88 -0
  79. package/src/instance/app-instance.ts +240 -0
  80. package/src/instance/index.ts +45 -0
  81. package/src/instance/offline-lock.ts +71 -0
  82. package/src/instance/online-secret.ts +55 -0
  83. package/src/instance/registry.ts +53 -0
  84. package/src/instance/select.ts +134 -0
  85. package/src/module-hooks.ts +41 -0
  86. package/src/module-resolution.ts +187 -0
  87. package/src/package-overlay.ts +160 -0
  88. package/src/pinned-pnpm.ts +67 -0
  89. package/src/plugin-acryl-workspace-status.ts +99 -0
  90. package/src/plugin-doctor.ts +141 -0
  91. package/src/plugin-lifecycle-state.ts +347 -0
  92. package/src/plugin-lifecycle.ts +223 -0
  93. package/src/profile-layout.ts +97 -0
  94. package/src/profile-owner.ts +52 -0
  95. package/src/profile-repair/backup.ts +119 -0
  96. package/src/profile-repair/findings.ts +43 -0
  97. package/src/profile-repair/index.ts +10 -0
  98. package/src/profile-repair/inspector.ts +156 -0
  99. package/src/profile-repair/repair.ts +137 -0
  100. package/src/profile-resolution/moved-framework.ts +64 -0
  101. package/src/profile-resolution/resolver.ts +876 -0
  102. package/src/profile-resolution/service.ts +99 -0
  103. package/src/prompt-budget.ts +118 -0
  104. package/src/session-bridge.ts +350 -0
  105. package/src/session-log-exporter.ts +68 -0
  106. package/src/system-prompt-capture.ts +99 -0
  107. package/src/web-favicon-data.ts +6 -0
  108. package/src/web-favicon.ts +43 -0
  109. package/src/web-market-install.ts +206 -0
  110. package/src/web-market-plugins.ts +215 -0
  111. package/src/web-port.ts +39 -0
  112. package/tests/account-callback.spec.ts +173 -0
  113. package/tests/acryl-home.spec.ts +39 -0
  114. package/tests/agent-self-hosting.spec.ts +101 -0
  115. package/tests/announce-self.spec.ts +84 -0
  116. package/tests/app-lifecycle.spec.ts +99 -0
  117. package/tests/blank-blueprint.spec.ts +110 -0
  118. package/tests/blueprint-definition.spec.ts +128 -0
  119. package/tests/blueprint.spec.ts +138 -0
  120. package/tests/bulkhead.spec.ts +187 -0
  121. package/tests/coding-vocabulary.spec.ts +15 -0
  122. package/tests/dump-system-prompt.spec.ts +65 -0
  123. package/tests/e2e-real-model.spec.ts +71 -0
  124. package/tests/e2e-restart-real-model.spec.ts +77 -0
  125. package/tests/engine-dsh.spec.ts +340 -0
  126. package/tests/engine-host-mount-root-include.spec.ts +118 -0
  127. package/tests/engine-host.spec.ts +176 -0
  128. package/tests/engine-optional.spec.ts +81 -0
  129. package/tests/extension-examples.spec.ts +261 -0
  130. package/tests/hooks-thread-stack.ts +27 -0
  131. package/tests/instance-patches.spec.ts +25 -0
  132. package/tests/instance.spec.ts +235 -0
  133. package/tests/live/community-plugins.spec.ts +83 -0
  134. package/tests/module-hooks.spec.ts +35 -0
  135. package/tests/module-resolution.spec.ts +265 -0
  136. package/tests/moved-framework.spec.ts +61 -0
  137. package/tests/new-app.spec.ts +132 -0
  138. package/tests/organizer-growth.spec.ts +117 -0
  139. package/tests/pinned-pnpm.spec.ts +34 -0
  140. package/tests/plugin-acryl-workspace-status.spec.ts +63 -0
  141. package/tests/plugin-context.spec.ts +640 -0
  142. package/tests/plugin-doctor.spec.ts +183 -0
  143. package/tests/plugin-enablement-one-store.spec.ts +130 -0
  144. package/tests/plugin-lifecycle-state.spec.ts +169 -0
  145. package/tests/profile-layout.spec.ts +58 -0
  146. package/tests/profile-owner.spec.ts +38 -0
  147. package/tests/profile-repair/profile-repair.spec.ts +231 -0
  148. package/tests/profile-resolution-port.spec.ts +30 -0
  149. package/tests/profile-resolution-service.spec.ts +273 -0
  150. package/tests/profile-resolution-swap.spec.ts +69 -0
  151. package/tests/profile-resolution.spec.ts +2535 -0
  152. package/tests/profile.spec.ts +70 -0
  153. package/tests/project-registry.spec.ts +81 -0
  154. package/tests/prompt-budget.spec.ts +58 -0
  155. package/tests/real-home-guard.spec.ts +178 -0
  156. package/tests/session-bridge.spec.ts +316 -0
  157. package/tests/start-source.spec.ts +65 -0
  158. package/tests/system-prompt-shape.spec.ts +95 -0
  159. package/tests/three-levels.spec.ts +84 -0
  160. package/tests/tool-gateway.spec.ts +116 -0
  161. package/tests/tool-schemas.spec.ts +41 -0
  162. package/tests/web-favicon.spec.ts +42 -0
  163. package/tests/web-port.spec.ts +38 -0
  164. package/tests/web-startup-hold.spec.ts +79 -0
  165. package/tsconfig.json +24 -0
  166. package/tsdown.config.ts +2 -0
  167. package/vitest.config.ts +18 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Where a new app starts from (`acryl new --from`, spec 036 `persistence-and-registries.md`): an app or captured Blend folder, a git repository (public or
3
+ * private, reached with the user's own git credentials), or a starter id in a registry (a git repository or folder with `index.json`). Everything is
4
+ * resolved to a local folder that has `blend.yaml`, which `planNewApp` / `writeNewApp` take from there.
5
+ *
6
+ * Git is a port (`GitClone`): the rules here are pure; `gitClone` below is the adapter that shells out to the user's git, never prompting for credentials.
7
+ *
8
+ * @module @acryldev/harness-runtime/app/start-source
9
+ */
10
+
11
+ import { spawnSync } from 'node:child_process'
12
+ import { existsSync, mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs'
13
+ import { tmpdir } from 'node:os'
14
+ import { join, resolve } from 'node:path'
15
+ import { parseRegistryIndex } from '@acryldev/blends-core'
16
+
17
+ /** The public registry: a folder of the acrylblends.github.io repository. `#<folder>` names the folder inside a repository. */
18
+ export const PUBLIC_REGISTRY = 'https://github.com/acrylblends/acrylblends.github.io.git#registry'
19
+
20
+ export type StartSource =
21
+ | { readonly kind: 'folder', readonly path: string }
22
+ | { readonly kind: 'git', readonly url: string, readonly subdir?: string }
23
+ | { readonly kind: 'registry', readonly id: string }
24
+
25
+ export class StartSourceError extends Error {
26
+ constructor(message: string) {
27
+ super(message)
28
+ this.name = 'StartSourceError'
29
+ }
30
+ }
31
+
32
+ /** Clone `url` (shallow) into `into`. Throws with git's own message on failure. */
33
+ export type GitClone = (url: string, into: string) => void
34
+
35
+ const GIT_URL = /^(?:https?:\/\/|ssh:\/\/|git@|file:\/\/)|\.git(?:#.*)?$/u
36
+ const STARTER_ID = /^[a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)+$/u
37
+
38
+ function splitSubdir(reference: string): { url: string, subdir?: string } {
39
+ const hash = reference.lastIndexOf('#')
40
+ if (hash <= 0) return { url: reference }
41
+ const subdir = reference.slice(hash + 1)
42
+ if (subdir === '' || subdir.split('/').some(part => part === '..' || part === '')) throw new StartSourceError(`"${subdir}" is not a folder inside the repository`)
43
+ return { url: reference.slice(0, hash), subdir }
44
+ }
45
+
46
+ /** Pure: what `--from` names. A path that exists is a folder; a git URL is a repository; a dotted id is a registry starter. */
47
+ export function classifyStartSource(from: string, isDirectory: (path: string) => boolean): StartSource {
48
+ if (isDirectory(from)) return { kind: 'folder', path: resolve(from) }
49
+ if (GIT_URL.test(from)) return { kind: 'git', ...splitSubdir(from) }
50
+ if (STARTER_ID.test(from)) return { kind: 'registry', id: from }
51
+ throw new StartSourceError(`--from "${from}" is not a folder, a git URL or a starter id (such as acme.accounting)`)
52
+ }
53
+
54
+ /** The adapter: the user's git, shallow, and never waiting on a credentials prompt (a private repository needs the user's own git login). */
55
+ export const gitClone: GitClone = (url, into) => {
56
+ const result = spawnSync('git', ['clone', '--depth', '1', '--quiet', url, into], { env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }, encoding: 'utf8' })
57
+ if (result.error !== undefined) throw new StartSourceError(`git is not available: ${result.error.message}`)
58
+ if (result.status !== 0) throw new StartSourceError(`git could not clone ${url}: ${(result.stderr || '').trim().split('\n').at(-1) ?? 'failed'}. A private repository needs your own git login (for GitHub: gh auth login).`)
59
+ }
60
+
61
+ const isDirectory = (path: string): boolean => existsSync(path) && statSync(path).isDirectory()
62
+
63
+ export interface ResolvedStartSource {
64
+ /** A local folder with `blend.yaml`. */
65
+ readonly folder: string
66
+ /** Where it came from, for the new app's description and the user's report. */
67
+ readonly origin: string
68
+ /** Remove the temporary clone, if any. */
69
+ dispose(): void
70
+ }
71
+
72
+ /**
73
+ * Resolve `--from` to a local folder. `registry` is a folder or git URL (`#<folder>` allowed) holding `index.json`; the public registry by default.
74
+ * The caller disposes the result when the new app is written.
75
+ */
76
+ export function resolveStartSource(from: string, options: { readonly registry?: string, readonly clone?: GitClone } = {}): ResolvedStartSource {
77
+ const clone = options.clone ?? gitClone
78
+ const temporary: string[] = []
79
+ const dispose = (): void => { for (const dir of temporary.splice(0)) rmSync(dir, { recursive: true, force: true }) }
80
+ const fetch = (reference: string): string => {
81
+ const { url, subdir } = splitSubdir(reference)
82
+ if (isDirectory(url)) return subdir === undefined ? resolve(url) : join(resolve(url), subdir)
83
+ const into = mkdtempSync(join(tmpdir(), 'acryl-source-'))
84
+ temporary.push(into)
85
+ clone(url, join(into, 'repo'))
86
+ return subdir === undefined ? join(into, 'repo') : join(into, 'repo', subdir)
87
+ }
88
+ try {
89
+ const source = classifyStartSource(from, isDirectory)
90
+ let folder: string
91
+ let origin: string
92
+ if (source.kind === 'folder') { folder = source.path; origin = source.path }
93
+ else if (source.kind === 'git') { folder = fetch(source.subdir === undefined ? source.url : `${source.url}#${source.subdir}`); origin = source.url }
94
+ else {
95
+ const registry = options.registry ?? PUBLIC_REGISTRY
96
+ const root = fetch(registry)
97
+ const indexFile = join(root, 'index.json')
98
+ if (!existsSync(indexFile)) throw new StartSourceError(`${registry} has no index.json; it is not a registry`)
99
+ const entry = parseRegistryIndex(readFileSync(indexFile, 'utf8')).entries.find(candidate => candidate.id === source.id)
100
+ if (entry === undefined) throw new StartSourceError(`${registry} has no starter "${source.id}"`)
101
+ folder = join(root, entry.path)
102
+ origin = `${source.id} (${registry})`
103
+ }
104
+ if (!existsSync(join(folder, 'blend.yaml'))) throw new StartSourceError(`${origin} has no blend.yaml; it is not an app or a starter`)
105
+ return { folder, origin, dispose }
106
+ } catch (error) {
107
+ dispose()
108
+ throw error
109
+ }
110
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Blueprint: a named, minimal starting composition of ACRYL. The stem cell of the framework: `blank` is the smallest
3
+ * thing that is still a working agent, and everything else is grown from it by adding Cordis plugins (locally first,
4
+ * published when worth sharing). `acryl.ide`, the agentic coding IDE the team ships, is not a separate product: it is one
5
+ * Blend grown from `acryl.blank` (the flagship example of what the framework builds), and `grewFrom` records that lineage.
6
+ *
7
+ * A Blueprint is pure data, keyed by the ubiquitous language of the Blends spec: it names capabilities and optional
8
+ * rows, never Loader mechanics. Turning it into Loader patches is `compose.ts`; choosing one is `selection.ts`.
9
+ * Nothing here is special-cased in the runtime: every row a Blueprint names is an ordinary Cordis plugin, so adding
10
+ * one later, or disabling one, is the same reversible row edit for a human, an agent or a Blend file.
11
+ *
12
+ * @module @acryldev/harness-runtime/blueprint/blueprint
13
+ */
14
+
15
+ import { ACRYL_CODING_CAPABILITIES, type AcrylCodingCapabilityId, type AcrylShellMode } from '../coding-capabilities.ts'
16
+ import { brandIdentity, type BrandIdentity } from './brand-identity.ts'
17
+
18
+ /** ACRYL-owned rows a Blueprint may include on top of the capabilities. Each is one independently replaceable plugin. */
19
+ export type BlueprintRowId =
20
+ | 'plugin-context'
21
+ | 'system-prompt'
22
+ | 'ui-library'
23
+ | 'community-market'
24
+ | 'shortcuts'
25
+ | 'mount-anchors'
26
+ | 'app-save'
27
+ | 'plugin-hub'
28
+ | 'app-shell'
29
+ | 'framework-kit'
30
+ | 'command-reply'
31
+
32
+ /** Every row id, as data: what a Blueprint file may name. Kept next to the type so the two cannot drift (a test asserts it). */
33
+ export const BLUEPRINT_ROW_IDS: readonly BlueprintRowId[] = ['plugin-context', 'system-prompt', 'ui-library', 'app-save', 'plugin-hub', 'community-market', 'shortcuts', 'mount-anchors', 'app-shell', 'framework-kit', 'command-reply']
34
+
35
+ /** Row ids a Blueprint file once used, read as their current names (spec 044 step 1b); never written. */
36
+ export const RENAMED_BLUEPRINT_ROW_IDS: Readonly<Record<string, BlueprintRowId>> = Object.freeze({ 'extension-context': 'plugin-context' })
37
+
38
+ /** `acryl`: the stock ACRYL brand plugin. `custom`: the configurable `@acryldev/brand` plugin carrying this identity. */
39
+ export type BlueprintBrand =
40
+ | { readonly kind: 'acryl' }
41
+ | { readonly kind: 'custom', readonly identity: BrandIdentity }
42
+
43
+ export interface Blueprint {
44
+ readonly id: string
45
+ readonly name: string
46
+ readonly description: string
47
+ readonly capabilities: readonly AcrylCodingCapabilityId[]
48
+ readonly rows: readonly BlueprintRowId[]
49
+ readonly brand: BlueprintBrand
50
+ readonly shell: AcrylShellMode
51
+ /**
52
+ * Whether the DeepSeek Harness chat (its agent loop and model providers) is part of this composition. Off, the app keeps its frame
53
+ * (tab stripe, workspaces, canvas, terminals, Agent Control) and other agents work in it; the DSH chat is one agent, not the foundation.
54
+ * Applies to the Web and Desktop surfaces: the terminal UI is the DSH chat.
55
+ */
56
+ readonly dshChat: boolean
57
+ /** The Blueprint this one was grown from, when it is a Blend of another (the IDE grew from the blank canvas). */
58
+ readonly grewFrom?: string
59
+ }
60
+
61
+ function freezeBlueprint(blueprint: Blueprint): Blueprint {
62
+ return Object.freeze(blueprint)
63
+ }
64
+
65
+ /**
66
+ * The stem cell: an agent to talk to, a model chooser (authorization), an input, and the plugin context pack so the agent can
67
+ * grow the rest. No workspace, no Market, no admin panel. The brand is configurable so it can be renamed without code.
68
+ */
69
+ export const BLANK_BLUEPRINT: Blueprint = freezeBlueprint({
70
+ id: 'acryl.blank',
71
+ name: 'Blank',
72
+ description: 'The smallest working agent that can grow itself: chat, model choice, and the plugin context pack.',
73
+ // `@acryldev/settings` is essential: surface plugins (Desktop's shell, notifications) keep their preferences there.
74
+ capabilities: ['persona', 'agent-roster', 'session-stats', 'authorization', 'acryl-settings'],
75
+ rows: ['plugin-context', 'system-prompt', 'ui-library', 'app-save', 'plugin-hub', 'framework-kit', 'command-reply'],
76
+ brand: { kind: 'custom', identity: brandIdentity({ name: 'Blank', tagline: 'Ask for what you need. It builds it.', accent: '#3b6ef5', accentDark: '#7c9dff' }) },
77
+ shell: 'compatibility',
78
+ dshChat: true,
79
+ })
80
+
81
+ /**
82
+ * ACRYL the agentic coding IDE: the blank canvas grown into a development environment (workspace, plugin admin, Market, shortcuts, mount anchors, the
83
+ * advanced shell, the ACRYL brand). Written as blank plus what it added, so the lineage is the definition, not a comment. Still the default when no
84
+ * Blueprint is selected, because it is what ACRYL's own installs are.
85
+ */
86
+ export const IDE_BLUEPRINT: Blueprint = freezeBlueprint({
87
+ id: 'acryl.ide',
88
+ name: 'ACRYL',
89
+ description: 'The agentic coding IDE: a Blend grown from acryl.blank with the workspace, Market, plugin admin, shortcuts and mount anchors.',
90
+ // Every declared capability, derived so a capability added to the table is part of the IDE without a second edit here.
91
+ capabilities: ACRYL_CODING_CAPABILITIES.map(capability => capability.id),
92
+ rows: [...BLANK_BLUEPRINT.rows, 'community-market', 'shortcuts', 'mount-anchors'],
93
+ brand: { kind: 'acryl' },
94
+ shell: 'advanced',
95
+ dshChat: true,
96
+ grewFrom: BLANK_BLUEPRINT.id,
97
+ })
98
+
99
+ /**
100
+ * The IDE for people who bring their own agents: the same frame and rows, with the DeepSeek Harness chat switched off. Claude Code, Codex or any
101
+ * agent in a terminal tab (or driving the page through Agent Control) works in it; turning the chat back on is one row edit, not a rebuild.
102
+ */
103
+ export const AGENTS_BLUEPRINT: Blueprint = freezeBlueprint({
104
+ ...IDE_BLUEPRINT,
105
+ id: 'acryl.agents',
106
+ name: 'ACRYL (bring your own agents)',
107
+ description: 'The agentic coding IDE with the DeepSeek Harness chat off: the frame, workspaces, canvas, terminals and Agent Control, for other agents.',
108
+ dshChat: false,
109
+ grewFrom: IDE_BLUEPRINT.id,
110
+ })
111
+
112
+ /** Read-only port: where Blueprints come from. Built-ins today; a hub, a Blend lock or a private registry later. */
113
+ export interface BlueprintCatalog {
114
+ get(id: string): Blueprint | undefined
115
+ list(): readonly Blueprint[]
116
+ }
117
+
118
+ export function builtInCatalog(): BlueprintCatalog {
119
+ const all = [BLANK_BLUEPRINT, IDE_BLUEPRINT, AGENTS_BLUEPRINT]
120
+ return { get: id => all.find(blueprint => blueprint.id === id), list: () => all }
121
+ }
122
+
123
+ export class UnknownBlueprintError extends Error {
124
+ constructor(id: string, known: readonly Blueprint[]) {
125
+ super(`Unknown blueprint ${JSON.stringify(id)}. Known: ${known.map(blueprint => blueprint.id).join(', ')}`)
126
+ this.name = 'UnknownBlueprintError'
127
+ }
128
+ }
129
+
130
+ /** Use case: pick the Blueprint a surface boots with. No selection means the IDE, what ACRYL's own installs are. */
131
+ export function selectBlueprint(id: string | undefined, catalog: BlueprintCatalog = builtInCatalog()): Blueprint {
132
+ if (id === undefined || id.trim() === '') return IDE_BLUEPRINT
133
+ const found = catalog.get(id.trim())
134
+ if (found === undefined) throw new UnknownBlueprintError(id, catalog.list())
135
+ return found
136
+ }
137
+
138
+ /** A copy of a Blueprint under a different brand. Immutable: the original is untouched. */
139
+ export function withBrand(blueprint: Blueprint, identity: BrandIdentity): Blueprint {
140
+ return freezeBlueprint({ ...blueprint, brand: { kind: 'custom', identity } })
141
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * BrandIdentity: the value object a Blueprint carries so anyone who builds on ACRYL can ship it under their own name
3
+ * (a private, closed-source product or an internal tool). Pure: no I/O, no framework types. Every invariant is
4
+ * enforced at construction, so a Blueprint can never hold a brand the client cannot render.
5
+ *
6
+ * @module @acryldev/harness-runtime/blueprint/brand-identity
7
+ */
8
+
9
+ const HEX_COLOR = /^#[0-9a-fA-F]{6}$/u
10
+ const MAX_NAME = 40
11
+ const MAX_TAGLINE = 120
12
+ const MAX_FONT_FAMILY = 200
13
+ const MAX_MARK = 3
14
+
15
+ export interface BrandIdentity {
16
+ /** Product name shown in the sidebar, the tab or window title and the agent's own identity line. */
17
+ readonly name: string
18
+ readonly tagline?: string
19
+ /** Accent color as `#rrggbb`; `accentDark` is the dark-mode variant (defaults to `accent`). */
20
+ readonly accent?: string
21
+ readonly accentDark?: string
22
+ /** A CSS font-family list. */
23
+ readonly fontFamily?: string
24
+ /** One to three characters drawn as the logo mark when no image is supplied (defaults to the name's first letter). */
25
+ readonly mark?: string
26
+ }
27
+
28
+ export class InvalidBrandIdentityError extends Error {
29
+ constructor(detail: string) {
30
+ super(`Invalid brand identity: ${detail}`)
31
+ this.name = 'InvalidBrandIdentityError'
32
+ }
33
+ }
34
+
35
+ function optionalText(record: Record<string, unknown>, key: string, max: number): string | undefined {
36
+ const value = record[key]
37
+ if (value === undefined) return undefined
38
+ if (typeof value !== 'string' || value.trim() === '' || value.length > max) {
39
+ throw new InvalidBrandIdentityError(`"${key}" must be a non-empty string of at most ${String(max)} characters`)
40
+ }
41
+ return value.trim()
42
+ }
43
+
44
+ function optionalColor(record: Record<string, unknown>, key: string): string | undefined {
45
+ const value = optionalText(record, key, 7)
46
+ if (value !== undefined && !HEX_COLOR.test(value)) throw new InvalidBrandIdentityError(`"${key}" must be a #rrggbb color`)
47
+ return value
48
+ }
49
+
50
+ /** Validate untrusted input (a YAML row config, an environment value) into a BrandIdentity. */
51
+ export function brandIdentity(input: unknown): BrandIdentity {
52
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) throw new InvalidBrandIdentityError('expected an object')
53
+ const record = input as Record<string, unknown>
54
+ const name = optionalText(record, 'name', MAX_NAME)
55
+ if (name === undefined) throw new InvalidBrandIdentityError('"name" is required')
56
+ const tagline = optionalText(record, 'tagline', MAX_TAGLINE)
57
+ const accent = optionalColor(record, 'accent')
58
+ const accentDark = optionalColor(record, 'accentDark')
59
+ const fontFamily = optionalText(record, 'fontFamily', MAX_FONT_FAMILY)
60
+ const mark = optionalText(record, 'mark', MAX_MARK)
61
+ return {
62
+ name,
63
+ ...(tagline === undefined ? {} : { tagline }),
64
+ ...(accent === undefined ? {} : { accent }),
65
+ ...(accentDark === undefined ? {} : { accentDark }),
66
+ ...(fontFamily === undefined ? {} : { fontFamily }),
67
+ ...(mark === undefined ? {} : { mark }),
68
+ }
69
+ }
70
+
71
+ /** The agent's opening identity line under this brand (what the system prompt says the agent is). */
72
+ export function identityLine(brand: BrandIdentity): string {
73
+ // Domain-neutral on purpose: the app may be a music editor, an accounting tool or an IDE. It is the user's product, so it is named, not ACRYL.
74
+ return `You are the assistant inside ${brand.name}. You help its users with what they ask, and you can extend ${brand.name} itself from the inside: when asked, you build, change and remove its plugins (tools, screens, commands) while it runs, and you can read files, run commands and write code to do so.`
75
+ }
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Compose: the pure translation from a Blueprint to what a surface's Loader needs: which ACRYL-owned packages must be
3
+ * resolvable, and which Loader patches to apply. No I/O and no framework handles; the composition root
4
+ * (`engine-dsh.ts`) does the materializing and mounting. The row table below is the single place a row's package, id
5
+ * and surfaces are declared, in the order the rows must mount (the shortcut registry before anything that reads it).
6
+ *
7
+ * @module @acryldev/harness-runtime/blueprint/compose
8
+ */
9
+
10
+ import type { PatchOptions } from '@deepseek-ai/cordis-plugin-include'
11
+ import type { AcrylSurface } from '../coding-capabilities.ts'
12
+ import { identityLine } from './brand-identity.ts'
13
+ import type { Blueprint, BlueprintRowId } from './blueprint.ts'
14
+
15
+ /** One Loader row: its id, the module it loads (`name`), and the package that module lives in, which the profile must resolve. */
16
+ interface RowModule {
17
+ readonly rowId: string
18
+ readonly module: string
19
+ readonly packageName: string
20
+ }
21
+
22
+ interface RowDeclaration extends RowModule {
23
+ readonly id: BlueprintRowId
24
+ readonly surfaces: readonly AcrylSurface[]
25
+ /** A library a plugin imports rather than mounts: the package must resolve, but there is no Loader row. */
26
+ readonly libraryOnly?: readonly AcrylSurface[]
27
+ /**
28
+ * Rows this row's plugin injects services from, mounted just before it (and once, however many rows name them). They are not
29
+ * Blueprint rows of their own: a Blueprint names capabilities, and which plugin provides a service is this table's business.
30
+ */
31
+ readonly needs?: readonly RowModule[]
32
+ }
33
+
34
+ /** The framework's package (spec 049 slice 17): its Cordis plugins are subpaths. The package moved into the scope (spec 051 T038); row ids stay as they were. */
35
+ const FRAMEWORK_PACKAGE = '@acryldev/blends'
36
+ /** The framework's package name before spec 051 T038: a row id is persisted, so it keeps this name while the module moves. */
37
+ const LEGACY_FRAMEWORK_PACKAGE = 'acrylblends'
38
+
39
+ function frameworkRow(plugin: string): RowModule {
40
+ const module = `${FRAMEWORK_PACKAGE}/cordis/${plugin}`
41
+ return { rowId: `${LEGACY_FRAMEWORK_PACKAGE}/cordis/${plugin}`, module, packageName: FRAMEWORK_PACKAGE }
42
+ }
43
+
44
+ /**
45
+ * The row id each package-backed row had before spec 051 T038 renamed the packages: a row id is persisted (a composition
46
+ * override names it), so it keeps the name the row was mounted under while the module it loads moves to the scoped package.
47
+ */
48
+ const LEGACY_PACKAGE_ROW_IDS: Readonly<Record<string, string>> = Object.freeze({
49
+ '@acryldev/plugin-context': 'acryl-plugin-context',
50
+ '@acryldev/system-prompt': 'acryl-system-prompt',
51
+ '@acryldev/ui': '@acryl/ui',
52
+ '@acryldev/app-save': 'acryl-app-save',
53
+ '@acryldev/plugin-hub': 'acryl-plugin-hub',
54
+ '@acryldev/shortcuts': 'acryl-shortcuts',
55
+ '@acryldev/mount-anchors': 'acryl-mount-anchors',
56
+ '@acryldev/command-reply': 'acryl-command-reply',
57
+ '@acryldev/app-shell': 'acryl-app-shell',
58
+ })
59
+
60
+ /** A row whose module is its own package, under the package's name; its row id is the one it had before the rename. */
61
+ function packageRow(packageName: string): RowModule {
62
+ return { rowId: LEGACY_PACKAGE_ROW_IDS[packageName] ?? packageName, module: packageName, packageName }
63
+ }
64
+
65
+ /** The router (`ctx.router`) and its Web adapter (`ctx.routerHttp`), which the Market injects (spec 046). */
66
+ const ROUTER_ROWS: readonly RowModule[] = [frameworkRow('router'), frameworkRow('router-http')]
67
+
68
+ /** The framework base kit (spec 046): routes, shared state and the inspector, served over HTTP on the Web surface. The inspector row pulls in the rest. */
69
+ const FRAMEWORK_NEEDS: readonly RowModule[] = [...ROUTER_ROWS, frameworkRow('state')]
70
+
71
+ /** Declaration order is mount order. The Market is Web-only here: Desktop owns its own provider switch. */
72
+ const ROWS: readonly RowDeclaration[] = [
73
+ { id: 'community-market', surfaces: ['web'], rowId: 'community-market', module: '@acryldev/cordis-plugin-market', packageName: '@acryldev/cordis-plugin-market', needs: ROUTER_ROWS },
74
+ { id: 'framework-kit', surfaces: ['web', 'desktop'], ...frameworkRow('inspect'), needs: FRAMEWORK_NEEDS },
75
+ { id: 'plugin-context', surfaces: ['tui', 'web', 'desktop'], ...packageRow('@acryldev/plugin-context') },
76
+ { id: 'system-prompt', surfaces: ['tui', 'web', 'desktop'], ...packageRow('@acryldev/system-prompt') },
77
+ { id: 'ui-library', surfaces: ['tui', 'web', 'desktop'], ...packageRow('@acryldev/ui'), libraryOnly: ['tui'] },
78
+ // Saving an app to its own repository (/app save, /app connect): a command, so it works on every surface.
79
+ { id: 'app-save', surfaces: ['tui', 'web', 'desktop'], ...packageRow('@acryldev/app-save') },
80
+ // Saving, sharing and pulling plugins (spec 044): the pluginHub service and /plugin, part of every Blend's base kit.
81
+ { id: 'plugin-hub', surfaces: ['tui', 'web', 'desktop'], ...packageRow('@acryldev/plugin-hub') },
82
+ // ACRYL's keyboard commands on DSH 0.2's own shortcut service (`ctx.shortcuts.register`): upstream owns the registry, persisted rebinding and the
83
+ // editor, so this package no longer provides a service of its own (a second provider fails the client boot).
84
+ { id: 'shortcuts', surfaces: ['web', 'desktop'], ...packageRow('@acryldev/shortcuts') },
85
+ { id: 'mount-anchors', surfaces: ['web', 'desktop'], ...packageRow('@acryldev/mount-anchors') },
86
+ // A host command's reply on the start page, where the conversation that would show it is not drawn yet (spec 049 T002).
87
+ { id: 'command-reply', surfaces: ['web', 'desktop'], ...packageRow('@acryldev/command-reply') },
88
+ // The three-column app frame a domain plugin claims for its own main UI (`desktop.main`), with the conversation beside it, instead of the stock
89
+ // chat frame (blend-instance-design.md 0a). The IDE composes the same frame through its coding capabilities.
90
+ { id: 'app-shell', surfaces: ['web', 'desktop'], ...packageRow('@acryldev/app-shell') },
91
+ ]
92
+
93
+ /**
94
+ * The DSH rows that make it a chat: the agent, the model registry and the pi-ai provider. Disabling them leaves the web server, the session
95
+ * store, the client and every ACRYL row running; Cordis parks the consumers that need them as PENDING (measured on 0.2.0-rc.2: 17 rows, among them
96
+ * the chat session controller and the model providers) and reactivates them when the rows come back.
97
+ */
98
+ export const DSH_CHAT_ROW_IDS: readonly string[] = ['agent', 'llm', 'llm-pi-ai']
99
+
100
+ /** DSH's base-bundle row providing `pluginManager`, and the hub's row that takes its place (its id is its module, by the row-naming rule). */
101
+ export const DSH_PLUGIN_MANAGER_ROW_ID = 'plugin-manager'
102
+ /** The plugin manager row's id, from before the rename (persisted); the module it mounts is the scoped package's subpath. */
103
+ export const PLUGIN_MANAGER_ROW_ID = 'acryl-plugin-hub/manager'
104
+ const PLUGIN_MANAGER_MODULE = '@acryldev/plugin-hub/manager'
105
+
106
+ /** The terminal library is a differently named package than the browser one. */
107
+ const TUI_LIBRARY_PACKAGE = '@acryldev/ui-tui'
108
+
109
+ /**
110
+ * Modules a Blend once named, read as their current names and never written: `@acryldev/plugin-context`'s old name (spec 044 step 1b), and the
111
+ * framework packages that became subpaths of `acrylblends` when the framework moved to its own repository (spec 049 slice 17).
112
+ */
113
+ export const RENAMED_MODULES: Readonly<Record<string, string>> = Object.freeze({
114
+ 'acryl-extension-context': '@acryldev/plugin-context',
115
+ '@acryldev/router': frameworkRow('router').module,
116
+ '@acryldev/router-http': frameworkRow('router-http').module,
117
+ '@acryldev/state': frameworkRow('state').module,
118
+ '@acryldev/inspect': frameworkRow('inspect').module,
119
+ '@acryldev/node-server': frameworkRow('node-server').module,
120
+ '@acryldev/door': frameworkRow('door').module,
121
+ '@acryldev/db': frameworkRow('db').module,
122
+ '@acryldev/db-sqlite': frameworkRow('db-sqlite').module,
123
+ '@acryldev/kv': frameworkRow('kv').module,
124
+ '@acryldev/kv-json': frameworkRow('kv-json').module,
125
+ '@acryldev/kv-db': frameworkRow('kv-db').module,
126
+ })
127
+
128
+ /** A module as it is named today: a renamed one under its current name, anything else unchanged. */
129
+ export function currentModule(module: string): string {
130
+ return RENAMED_MODULES[module] ?? module
131
+ }
132
+
133
+ /** The package a module specifier lives in: `acrylblends/cordis/router` is in `acrylblends`, `@acryldev/ui` in itself. */
134
+ export function packageOfModule(module: string): string {
135
+ const parts = module.split('/')
136
+ return module.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0] ?? module
137
+ }
138
+
139
+ /** Which Blueprint row a module is, if it is one of ACRYL's own rows (used to read a Blends manifest's rows back into a Blueprint). */
140
+ export function blueprintRowForModule(module: string): BlueprintRowId | undefined {
141
+ const current = currentModule(module)
142
+ return ROWS.find(row => row.module === current)?.id
143
+ }
144
+
145
+ /** The row that fills a Blueprint row (used to write a Blueprint as a Blends manifest). */
146
+ export function rowForBlueprintRow(id: BlueprintRowId): RowModule {
147
+ const row = ROWS.find(candidate => candidate.id === id)
148
+ if (row === undefined) throw new Error(`no row declaration for ${id}`)
149
+ return { rowId: row.rowId, module: row.module, packageName: row.packageName }
150
+ }
151
+
152
+ export interface BlueprintComposition {
153
+ /** ACRYL-owned packages to make resolvable from the profile. */
154
+ readonly packages: readonly string[]
155
+ readonly patches: readonly PatchOptions[]
156
+ }
157
+
158
+ /**
159
+ * The ACRYL-owned rows and brand for one surface. `existingRowIds` are rows the profile's own bundle already composes:
160
+ * an `insert` of the same id would throw at boot, so those rows are skipped rather than composed twice.
161
+ */
162
+ export function composeBlueprintRows(
163
+ blueprint: Blueprint,
164
+ surface: AcrylSurface,
165
+ existingRowIds: ReadonlySet<string> = new Set(),
166
+ /** The rows the advanced shell replaces, from the surface's composition (`@acryldev/coding-capabilities`' `ADVANCED_SHELL_PATCHES`). */
167
+ appFramePatches: readonly PatchOptions[] = [],
168
+ ): BlueprintComposition {
169
+ const packages: string[] = []
170
+ const patches: PatchOptions[] = []
171
+ const mountedNeeds = new Set<string>()
172
+
173
+ // Brand first: it swaps the stock identity row and must exist before any client row reads it.
174
+ if (surface === 'web' || surface === 'desktop') {
175
+ if (blueprint.brand.kind === 'acryl') {
176
+ packages.push('@acryldev/brand-client')
177
+ patches.push(
178
+ { id: 'ui-brand-official', disabled: true },
179
+ { insert: [{ id: 'ui-acryl', name: '@acryldev/brand-client', disabled: false }] },
180
+ )
181
+ } else {
182
+ packages.push('@acryldev/brand')
183
+ patches.push(
184
+ { id: 'ui-brand-official', disabled: true },
185
+ { insert: [{ id: 'brand', name: '@acryldev/brand', config: { ...blueprint.brand.identity } }] },
186
+ )
187
+ }
188
+ }
189
+
190
+ // After the brand and before ACRYL's own rows: a disabled stock row must not be re-enabled by anything composed later.
191
+ if (!blueprint.dshChat && (surface === 'web' || surface === 'desktop')) {
192
+ for (const id of DSH_CHAT_ROW_IDS) patches.push({ id, disabled: true })
193
+ }
194
+
195
+ for (const row of ROWS) {
196
+ if (!blueprint.rows.includes(row.id) || !row.surfaces.includes(surface)) continue
197
+ if (row.libraryOnly?.includes(surface) === true) {
198
+ packages.push(TUI_LIBRARY_PACKAGE)
199
+ continue
200
+ }
201
+ for (const need of row.needs ?? []) {
202
+ if (existingRowIds.has(need.rowId) || mountedNeeds.has(need.rowId)) continue
203
+ mountedNeeds.add(need.rowId)
204
+ packages.push(need.packageName)
205
+ patches.push({ insert: [{ id: need.rowId, name: need.module }] })
206
+ }
207
+ if (existingRowIds.has(row.rowId)) continue
208
+ packages.push(row.packageName)
209
+ const identityConfig = row.id === 'system-prompt' && blueprint.brand.kind === 'custom'
210
+ ? { config: { identity: identityLine(blueprint.brand.identity) } }
211
+ : {}
212
+ patches.push({ insert: [{ id: row.rowId, name: row.module, ...identityConfig }] })
213
+ }
214
+ // A Blend that owns its frame turns the stock layout off and the sidebar and conversation rows on, for its domain plugin to render into.
215
+ if (blueprint.rows.includes('app-shell') && (surface === 'web' || surface === 'desktop')) patches.push(...appFramePatches)
216
+ // With the plugin hub, DSH's own plugin manager is replaced by the hub's subclass of it, so DSH's "Add plugin" box installs a git address as
217
+ // that repository's released, checked version (spec 044 D7). Swapped, never doubled: Cordis refuses a second `pluginManager` provider.
218
+ if (blueprint.rows.includes('plugin-hub') && !existingRowIds.has(PLUGIN_MANAGER_ROW_ID)) {
219
+ patches.push({ id: DSH_PLUGIN_MANAGER_ROW_ID, disabled: true }, { insert: [{ id: PLUGIN_MANAGER_ROW_ID, name: PLUGIN_MANAGER_MODULE }] })
220
+ }
221
+ return { packages: [...new Set(packages)], patches: structuredClone(patches) }
222
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Blueprint definition: the pure translation from untrusted data (a parsed YAML or JSON file) into a Blueprint, so a team can
3
+ * define its own starter and brand it without writing code. No I/O here; `selection.ts` reads the file.
4
+ *
5
+ * ```yaml
6
+ * id: acme.notes
7
+ * name: Acme Notes
8
+ * extends: acryl.blank # optional: start from a known Blueprint, then override
9
+ * brand: { name: Acme Notes, accent: '#0a7d4b' }
10
+ * rows: [plugin-context, system-prompt, ui-library, community-market]
11
+ * ```
12
+ *
13
+ * Unknown keys, unknown capabilities and unknown rows are rejected, so a typo is an error at start-up, not a silently missing feature.
14
+ *
15
+ * @module @acryldev/harness-runtime/blueprint/definition
16
+ */
17
+
18
+ import { ACRYL_CODING_CAPABILITIES, type AcrylCodingCapabilityId, type AcrylShellMode } from '../coding-capabilities.ts'
19
+ import { brandIdentity } from './brand-identity.ts'
20
+ import { BLUEPRINT_ROW_IDS, builtInCatalog, RENAMED_BLUEPRINT_ROW_IDS, type Blueprint, type BlueprintCatalog, type BlueprintRowId } from './blueprint.ts'
21
+
22
+ const ID = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/u
23
+ const KEYS = new Set(['id', 'name', 'description', 'extends', 'capabilities', 'rows', 'brand', 'shell', 'dshChat'])
24
+ const SHELLS: readonly AcrylShellMode[] = ['compatibility', 'advanced']
25
+
26
+ export class InvalidBlueprintError extends Error {
27
+ constructor(detail: string) {
28
+ super(`Invalid blueprint: ${detail}`)
29
+ this.name = 'InvalidBlueprintError'
30
+ }
31
+ }
32
+
33
+ function text(record: Record<string, unknown>, key: string, max: number): string | undefined {
34
+ const value = record[key]
35
+ if (value === undefined) return undefined
36
+ if (typeof value !== 'string' || value.trim() === '' || value.length > max) throw new InvalidBlueprintError(`"${key}" must be a non-empty string of at most ${String(max)} characters`)
37
+ return value.trim()
38
+ }
39
+
40
+ function oneOf<T extends string>(record: Record<string, unknown>, key: string, allowed: readonly T[]): readonly T[] | undefined {
41
+ const value = record[key]
42
+ if (value === undefined) return undefined
43
+ if (!Array.isArray(value)) throw new InvalidBlueprintError(`"${key}" must be a list`)
44
+ const unknown = value.filter(entry => typeof entry !== 'string' || !allowed.includes(entry as T))
45
+ if (unknown.length > 0) throw new InvalidBlueprintError(`"${key}" names ${unknown.map(entry => JSON.stringify(entry)).join(', ')}; known: ${allowed.join(', ')}`)
46
+ return [...new Set(value as T[])]
47
+ }
48
+
49
+ /** Turn parsed data into a Blueprint. `extends` resolves against `catalog` (built-ins by default). */
50
+ export function parseBlueprint(input: unknown, catalog: BlueprintCatalog = builtInCatalog()): Blueprint {
51
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) throw new InvalidBlueprintError('expected an object')
52
+ const record = input as Record<string, unknown>
53
+ const stray = Object.keys(record).filter(key => !KEYS.has(key))
54
+ if (stray.length > 0) throw new InvalidBlueprintError(`unknown key ${stray.map(key => JSON.stringify(key)).join(', ')}; known: ${[...KEYS].join(', ')}`)
55
+
56
+ const id = text(record, 'id', 80)
57
+ if (id === undefined || !ID.test(id)) throw new InvalidBlueprintError('"id" is required and must look like acme.notes (lowercase letters, digits, dots and dashes)')
58
+ const parentId = text(record, 'extends', 80)
59
+ const parent = parentId === undefined ? undefined : catalog.get(parentId)
60
+ if (parentId !== undefined && parent === undefined) throw new InvalidBlueprintError(`"extends" names ${JSON.stringify(parentId)}, which is not a known blueprint`)
61
+
62
+ const capabilities = oneOf(record, 'capabilities', ACRYL_CODING_CAPABILITIES.map(capability => capability.id) as readonly AcrylCodingCapabilityId[])
63
+ // A renamed row is read as its current name, so a Blueprint written before the rename still loads.
64
+ const rows = oneOf({ rows: Array.isArray(record.rows) ? record.rows.map(row => RENAMED_BLUEPRINT_ROW_IDS[String(row)] ?? row) : record.rows }, 'rows', BLUEPRINT_ROW_IDS as readonly BlueprintRowId[])
65
+ const shell = text(record, 'shell', 20)
66
+ if (shell !== undefined && !SHELLS.includes(shell as AcrylShellMode)) throw new InvalidBlueprintError(`"shell" must be one of ${SHELLS.join(', ')}`)
67
+ if (record.dshChat !== undefined && typeof record.dshChat !== 'boolean') throw new InvalidBlueprintError('"dshChat" must be true or false')
68
+ const brand = record.brand === undefined
69
+ ? undefined
70
+ : { kind: 'custom', identity: brandIdentity(record.brand) } as const
71
+
72
+ const base: Blueprint = parent ?? {
73
+ id, name: id, description: '', capabilities: ['authorization', 'acryl-settings'], rows: ['plugin-context', 'system-prompt'], brand: { kind: 'acryl' }, shell: 'compatibility', dshChat: true,
74
+ }
75
+ const composedCapabilities = capabilities ?? base.capabilities
76
+ const composedRows = rows ?? base.rows
77
+ // A capability that serves its routes through the router needs the framework kit, which brings it; without it the plugin would wait (PENDING) silently.
78
+ const needsRouter = ACRYL_CODING_CAPABILITIES.find(capability => capability.needsRouter === true && composedCapabilities.includes(capability.id))
79
+ if (needsRouter !== undefined && !composedRows.includes('framework-kit')) {
80
+ throw new InvalidBlueprintError(`the ${JSON.stringify(needsRouter.id)} capability needs the "framework-kit" row, which serves its routes`)
81
+ }
82
+ return Object.freeze({
83
+ id,
84
+ name: text(record, 'name', 80) ?? (parent === undefined ? base.name : id),
85
+ description: text(record, 'description', 300) ?? base.description,
86
+ capabilities: composedCapabilities,
87
+ rows: composedRows,
88
+ brand: brand ?? base.brand,
89
+ shell: (shell as AcrylShellMode | undefined) ?? base.shell,
90
+ dshChat: record.dshChat === undefined ? base.dshChat : record.dshChat,
91
+ })
92
+ }