acrylblends 0.9.0 → 0.9.1

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
@@ -167,7 +167,7 @@ function copyPlugin(plugin, appDir, root = libraryRoot()) {
167
167
  if (existsSync(target)) throw new LibraryError(`${relativeName(appDir, target)} already exists; remove it first to copy a fresh one`);
168
168
  const source = join(root, plugin.name);
169
169
  const isPackage = existsSync(join(source, "package.json"));
170
- const entries = isPackage ? entryTable(readLibrary(root)) : void 0;
170
+ const entries = plugin.entries === void 0 ? void 0 : entryTable(readLibrary(root));
171
171
  cpSync(source, target, {
172
172
  recursive: true,
173
173
  filter: (path) => {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["parse","parse"],"sources":["../src/rewrite.ts","../src/library.ts","../src/version.ts","../src/project.ts","../src/templates.ts","../src/init.ts","../src/add.ts","../src/build-client.ts","../src/check-deps.ts","../src/spawn.ts","../src/io.ts","../src/kv-import.ts","../src/cli.ts"],"sourcesContent":["import { dirname, posix } from 'node:path'\n\n/**\n * The framework plugins import each other by package name (`acryl-router`, `acryl-router/middleware`): inside this repository they are workspace packages. An app has\n * no such packages, only the copied source, so `acrylblends init` and `add` rewrite those specifiers to relative paths when they copy a plugin. The file each name stands\n * for is the `entries` table of the plugin's `plugin.json`.\n */\n\n/** `acryl-router/middleware` to `acryl-router/src/middleware/index.ts`: every importable name of every library plugin. */\nexport type EntryTable = ReadonlyMap<string, string>\n\nexport function entryTable(\n library: ReadonlyMap<string, { readonly entries?: Readonly<Record<string, string>> | undefined }>,\n): EntryTable {\n const table = new Map<string, string>()\n for (const [plugin, { entries }] of library)\n for (const [subpath, file] of Object.entries(entries ?? {}))\n table.set(`${plugin}${subpath}`, `${plugin}/${file}`)\n return table\n}\n\n/** For every character of a TypeScript source: 0 = code, 1 = inside a comment, 2 = inside a string or template literal. */\nfunction classify(source: string): Uint8Array {\n const kind = new Uint8Array(source.length)\n let i = 0\n while (i < source.length) {\n const c = source[i]\n const next = source[i + 1]\n if (c === '/' && next === '/') {\n const end = source.indexOf('\\n', i)\n const stop = end === -1 ? source.length : end\n kind.fill(1, i, stop)\n i = stop\n } else if (c === '/' && next === '*') {\n const end = source.indexOf('*/', i + 2)\n const stop = end === -1 ? source.length : end + 2\n kind.fill(1, i, stop)\n i = stop\n } else if (c === \"'\" || c === '\"' || c === '`') {\n let j = i + 1\n while (j < source.length && source[j] !== c) {\n if (source[j] === '\\\\') j += 1\n else if (c !== '`' && source[j] === '\\n') break\n j += 1\n }\n kind.fill(2, i, Math.min(j + 1, source.length))\n i = j + 1\n } else i += 1\n }\n return kind\n}\n\nconst SPECIFIER =\n /(\\bfrom\\s+|\\bimport\\s*\\(\\s*|\\bimport\\s+)(['\"])(acryl-[A-Za-z0-9-]+(?:\\/[A-Za-z0-9./-]+)?)\\2/gu\n\n/**\n * Rewrite the specifiers that name another library plugin to relative paths. `file` is the path of the file inside the plugins folder (for example\n * `acryl-state/src/service.ts`). Only real import and export statements are touched: a specifier named in a comment or in a string (a documentation example) is text,\n * not a dependency. Any other `acryl-*` specifier in code is an error: a library plugin may depend only on the others and on public packages.\n */\nexport function rewriteSpecifiers(source: string, file: string, entries: EntryTable): string {\n const kind = classify(source)\n return source.replace(\n SPECIFIER,\n (match, lead: string, quote: string, specifier: string, offset: number) => {\n if (kind[offset] !== 0) return match\n const target = entries.get(specifier)\n if (target === undefined)\n throw new Error(`${file}: imports \"${specifier}\", which is not a library plugin`)\n let path = posix.relative(dirname(file), target)\n if (!path.startsWith('.')) path = `./${path}`\n return `${lead}${quote}${path}${quote}`\n },\n )\n}\n","import { cpSync, existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { dirname, join, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { type EntryTable, entryTable, rewriteSpecifiers } from './rewrite'\n\n/** One entry of the plugin library: `plugins/<name>/plugin.json` in this repository. */\nexport interface LibraryPlugin {\n readonly name: string\n readonly description: string\n /** Library plugins this one imports; they are copied with it. */\n readonly requires: readonly string[]\n /** npm packages an app needs at run time for this plugin. */\n readonly dependencies: Readonly<Record<string, string>>\n /** npm packages an app needs only to develop or run this plugin's tooling (for example `electron` for the desktop shell). */\n readonly devDependencies?: Readonly<Record<string, string>>\n /** `package.json` scripts the plugin adds; a script the app already has is kept. */\n readonly scripts?: Readonly<Record<string, string>>\n /** Lines the app's `.gitignore` needs for this plugin (added when missing, if the app has a `.gitignore`). */\n readonly gitignore?: readonly string[]\n /** The port's conformance suite, a path inside the plugin: shipped in the package, but copied into an app only by `acrylblends add <plugin> --suite` (it needs vitest). */\n readonly suite?: string\n /** What other library plugins may import from this one: the import name after the plugin's own (`''`, `/middleware`) and the file it stands for. Used to rewrite `acryl-*` imports when a plugin is copied. */\n readonly entries?: Readonly<Record<string, string>>\n /** `package.json` \"imports\" entries the app gets (`#acryl-kv`): a path below the plugins folder. A plugin of your own imports the port by that name, in tests and the type-check as well as when installed live. */\n readonly imports?: Readonly<Record<string, string>>\n /** How to mount it, shown after `acrylblends add`. */\n readonly mount?: string\n /**\n * Paths inside the plugin folder that are not copied into an app (for example a React hook an app without React cannot type-check, or colocated test\n * files). A pattern is an exact path or a glob: `*` matches within one folder name, `**` across folders, `?` one character; `**` followed by a slash also matches no folder.\n */\n readonly omit?: readonly string[]\n}\n\n/** A glob as a regular expression: `*` within a name, `**` across folders, `**` plus a slash may match no folder, `?` one character. */\nfunction globToRegExp(glob: string): RegExp {\n let source = ''\n for (let i = 0; i < glob.length; i += 1) {\n const c = glob[i] as string\n if (c === '*' && glob[i + 1] === '*') {\n if (glob[i + 2] === '/') {\n source += '(?:.*/)?'\n i += 2\n } else {\n source += '.*'\n i += 1\n }\n } else if (c === '*') source += '[^/]*'\n else if (c === '?') source += '[^/]'\n else source += c.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&')\n }\n return new RegExp(`^${source}$`)\n}\n\n/** Whether a path inside a plugin folder (relative, any separator) is named by one of its `omit` patterns. */\nexport function isOmitted(inside: string, patterns: readonly string[] | undefined): boolean {\n if (!patterns || patterns.length === 0) return false\n const path = inside.split(sep).join('/')\n return patterns.some((pattern) =>\n /[*?]/.test(pattern) ? globToRegExp(pattern).test(path) : pattern === path,\n )\n}\n\n/** Files of a library plugin that stay in the repository: its manifest and its tests. */\nconst LIBRARY_ONLY = new Set(['plugin.json', 'test', 'tests'])\n\nexport class LibraryError extends Error {\n override name = 'LibraryError'\n}\n\n/** The library folder (`plugins/` at the repository root): walk up from this module, in source or in the build. */\nexport function libraryRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const candidate = join(dir, 'plugins')\n if (existsSync(join(candidate, 'instance', 'plugin.json'))) return candidate\n const parent = dirname(dir)\n if (parent === dir)\n throw new LibraryError('acrylblends cannot find its plugin library (plugins/)')\n dir = parent\n }\n}\n\n/** Every plugin in the library, by name. */\nexport function readLibrary(root: string = libraryRoot()): Map<string, LibraryPlugin> {\n const plugins = new Map<string, LibraryPlugin>()\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n const manifest = join(root, entry.name, 'plugin.json')\n if (!entry.isDirectory() || !existsSync(manifest)) continue\n const plugin = JSON.parse(readFileSync(manifest, 'utf8')) as LibraryPlugin\n if (plugin.name !== entry.name)\n throw new LibraryError(`plugins/${entry.name}/plugin.json names \"${plugin.name}\"`)\n plugins.set(plugin.name, {\n ...plugin,\n requires: plugin.requires ?? [],\n dependencies: plugin.dependencies ?? {},\n })\n }\n return plugins\n}\n\n/** The plugins to copy for `names`: each one after everything it requires, no duplicates. */\nexport function closure(\n names: readonly string[],\n library: Map<string, LibraryPlugin>,\n): LibraryPlugin[] {\n const ordered: LibraryPlugin[] = []\n const visiting = new Set<string>()\n const visit = (name: string, trail: string[]) => {\n if (ordered.some((plugin) => plugin.name === name)) return\n const plugin = library.get(name)\n if (!plugin)\n throw new LibraryError(\n `no plugin \"${name}\" in the library${trail.length ? ` (required by ${trail.at(-1)})` : ''}`,\n )\n if (visiting.has(name))\n throw new LibraryError(\n `plugins require each other in a cycle: ${[...trail, name].join(' -> ')}`,\n )\n visiting.add(name)\n for (const required of plugin.requires) visit(required, [...trail, name])\n visiting.delete(name)\n ordered.push(plugin)\n }\n for (const name of names) visit(name, [])\n return ordered\n}\n\n/** The one folder every plugin of an app lives in, library copies and the ones an agent writes. */\nexport const PLUGINS_DIR = 'plugins'\n/** Where apps made before 0.7.8 kept library copies; still understood for one release. */\nexport const LEGACY_PLUGINS_DIR = join('src', 'plugins')\n/** The list of library copies in the plugins folder; the extensions plugin installs every other folder there. */\nexport const LIBRARY_LIST = 'library.json'\n\n/** The plugins folder of an app: `plugins/`, or `src/plugins/` for an app that still has the old layout (and no `plugins/`). */\nexport function pluginsFolder(appDir: string): { dir: string; legacy: boolean } {\n const legacy =\n existsSync(join(appDir, LEGACY_PLUGINS_DIR)) && !existsSync(join(appDir, PLUGINS_DIR))\n return { dir: join(appDir, legacy ? LEGACY_PLUGINS_DIR : PLUGINS_DIR), legacy }\n}\n\n/** The warning for an app with the old layout. */\nexport const LEGACY_WARNING =\n 'warning: this app keeps its plugins in src/plugins/ (and extensions/); plugins now live in one folder, plugins/. Move them with \"git mv src/plugins plugins\", fix the paths in tsconfig.json, package.json and src/, and see docs/framework/agents/index.md. The old layout is read for this release only.'\n\nfunction recordLibraryCopy(folder: string, name: string): void {\n const file = join(folder, LIBRARY_LIST)\n const names: string[] = existsSync(file)\n ? (JSON.parse(readFileSync(file, 'utf8')) as { plugins: string[] }).plugins\n : []\n if (!names.includes(name)) names.push(name)\n writeFileSync(file, `${JSON.stringify({ plugins: names.sort() }, null, 2)}\\n`)\n}\n\n/** Copy one library plugin's source into `<app>/plugins/<name>/`. Throws when that folder already exists. */\nexport function copyPlugin(\n plugin: LibraryPlugin,\n appDir: string,\n root: string = libraryRoot(),\n): string {\n const folder = pluginsFolder(appDir)\n const target = join(folder.dir, plugin.name)\n if (existsSync(target))\n throw new LibraryError(\n `${relativeName(appDir, target)} already exists; remove it first to copy a fresh one`,\n )\n const source = join(root, plugin.name)\n // A framework package (it has a package.json) is copied as its source: `src/` and the licence. Its build files, tests and manifest are the repository's own.\n const isPackage = existsSync(join(source, 'package.json'))\n const entries = isPackage ? entryTable(readLibrary(root)) : undefined\n cpSync(source, target, {\n recursive: true,\n filter: (path) => {\n const inside = path\n .slice(source.length + 1)\n .split(sep)\n .join('/')\n if (\n isPackage &&\n inside !== '' &&\n inside !== 'LICENSE' &&\n inside !== 'src' &&\n !inside.startsWith('src/')\n )\n return false\n return (\n !(dirname(path) === source && LIBRARY_ONLY.has(inside)) &&\n !isOmitted(inside, plugin.omit) &&\n inside !== plugin.suite\n )\n },\n })\n if (entries) rewriteTree(join(target, 'src'), plugin.name, 'src', entries)\n if (!folder.legacy) recordLibraryCopy(folder.dir, plugin.name)\n return target\n}\n\n/** Rewrite the `acryl-*` imports of every TypeScript file below `dir` (the plugin's `src/`) to relative paths. */\nfunction rewriteTree(dir: string, plugin: string, inside: string, entries: EntryTable): void {\n for (const entry of readdirSync(dir)) {\n const path = join(dir, entry)\n if (statSync(path).isDirectory()) rewriteTree(path, plugin, `${inside}/${entry}`, entries)\n else if (/\\.(?:ts|tsx|mts)$/u.test(entry))\n writeFileSync(\n path,\n rewriteSpecifiers(readFileSync(path, 'utf8'), `${plugin}/${inside}/${entry}`, entries),\n )\n }\n}\n\n/** Copy one file of a library plugin (a conformance suite) with its `acryl-*` imports rewritten, as `copyPlugin` does for the rest. */\nexport function copyRewritten(\n from: string,\n to: string,\n plugin: string,\n inside: string,\n root: string = libraryRoot(),\n): void {\n writeFileSync(\n to,\n rewriteSpecifiers(\n readFileSync(from, 'utf8'),\n `${plugin}/${inside}`,\n entryTable(readLibrary(root)),\n ),\n )\n}\n\nconst relativeName = (appDir: string, path: string) =>\n path\n .slice(appDir.length + 1)\n .split(sep)\n .join('/')\n","import { createRequire } from 'node:module'\n\n/** The version of this package. */\nexport const VERSION: string = (\n createRequire(import.meta.url)('../package.json') as { version: string }\n).version\n","import {\n cpSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { join } from 'node:path'\nimport { VERSION } from './version'\n\n/** Thrown when the target directory exists and is not empty. Nothing has been written. */\nexport class TargetNotEmptyError extends Error {\n constructor(readonly target: string) {\n super(\n `refusing to write into \"${target}\": the directory is not empty. Choose an empty or new directory.`,\n )\n this.name = 'TargetNotEmptyError'\n }\n}\n\n/** A project name npm accepts: lower case letters, digits and dashes, starting with a letter. */\nexport function isValidName(name: string): boolean {\n return /^[a-z][a-z0-9-]*$/.test(name) && name.length <= 214\n}\n\n/** A valid default project name derived from a directory path. */\nexport function nameFrom(directory: string): string {\n const base = directory.split(/[\\\\/]/).filter(Boolean).pop() ?? ''\n const cleaned = base\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, '-')\n .replace(/^[^a-z]+/, '')\n .replace(/-+$/, '')\n return cleaned || 'my-app'\n}\n\n/** Refuse a target that exists and is not an empty directory. A missing target is fine: it is created. */\nexport function assertTargetFree(target: string): void {\n if (!existsSync(target)) return\n if (!statSync(target).isDirectory() || readdirSync(target).length > 0)\n throw new TargetNotEmptyError(target)\n}\n\n/**\n * Copy a template into `target`, replacing `__APP_NAME__` with `name` and `__ACRYLBLENDS_RANGE__` with the range of this release. Checks the target before writing anything.\n *\n * @returns the copied files, relative to `target`\n */\nexport function copyTemplate(source: string, target: string, name: string): string[] {\n assertTargetFree(target)\n mkdirSync(target, { recursive: true })\n const written: string[] = []\n const walk = (from: string, to: string, prefix: string) => {\n for (const entry of readdirSync(from, { withFileTypes: true })) {\n if (\n entry.name === 'node_modules' ||\n (prefix === '' &&\n (entry.name === TEMPLATE_MANIFEST ||\n entry.name === 'upstream.json' ||\n entry.name === 'AGENTS.md'))\n )\n continue\n const sourcePath = join(from, entry.name)\n // npm and git treat a file named .gitignore specially, so templates keep it as `gitignore` (and `dockerignore`).\n const targetName =\n prefix === '' && (entry.name === 'gitignore' || entry.name === 'dockerignore')\n ? `.${entry.name}`\n : entry.name\n const targetPath = join(to, targetName)\n if (entry.isDirectory()) {\n mkdirSync(targetPath, { recursive: true })\n walk(sourcePath, targetPath, `${prefix}${entry.name}/`)\n continue\n }\n const text = readFileSync(sourcePath, 'utf8')\n if (text.includes('__APP_NAME__') || text.includes('__ACRYLBLENDS_RANGE__'))\n writeFileSync(\n targetPath,\n text.replaceAll('__APP_NAME__', name).replaceAll('__ACRYLBLENDS_RANGE__', `^${VERSION}`),\n )\n else cpSync(sourcePath, targetPath)\n written.push(`${prefix}${targetName}`)\n }\n }\n walk(source, target, '')\n return written\n}\n\n/** A template's own manifest, `template.json`: the library plugins it is built from. Never copied (nor is `upstream.json`, the record of what was synced from ACRYL, nor the template's `AGENTS.md`, which `writeAgentFiles` joins to the shared core). */\nexport const TEMPLATE_MANIFEST = 'template.json'\n\n/** The address a template's desktop window opens on, when it is not the root (`template.json`: `desktopPath`). */\nexport function readTemplateDesktopPath(templateDir: string): string | undefined {\n const file = join(templateDir, TEMPLATE_MANIFEST)\n if (!existsSync(file)) return undefined\n return (JSON.parse(readFileSync(file, 'utf8')) as { desktopPath?: string }).desktopPath\n}\n\n/** Record where the desktop window opens in package.json (`acrylblends.desktopPath`), read by `plugins/desktop/main.ts`. */\nexport function writeDesktopPath(appDir: string, path: string): void {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n acrylblends?: Record<string, unknown>\n }\n manifest.acrylblends = { ...manifest.acrylblends, desktopPath: path }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\nexport function readTemplatePlugins(templateDir: string): string[] {\n const file = join(templateDir, TEMPLATE_MANIFEST)\n if (!existsSync(file)) return []\n const { plugins } = JSON.parse(readFileSync(file, 'utf8')) as { plugins?: string[] }\n return plugins ?? []\n}\n\n/** Add run-time dependencies to an app's package.json, keeping what is there and sorting the keys. Returns the names added. */\nexport function mergeDependencies(\n appDir: string,\n dependencies: Readonly<Record<string, string>>,\n): string[] {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n dependencies?: Record<string, string>\n }\n const current = manifest.dependencies ?? {}\n const added = Object.keys(dependencies).filter((name) => !(name in current))\n const merged = { ...dependencies, ...current }\n manifest.dependencies = Object.fromEntries(\n Object.entries(merged).sort(([a], [b]) => a.localeCompare(b)),\n )\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n return added\n}\n\n/** Add `package.json` \"imports\" entries (`#acryl-kv`: `./plugins/acryl-kv/src/index.ts`); an entry the app already has is kept. Returns the names added. */\nexport function mergeImports(\n appDir: string,\n imports: Readonly<Record<string, string>>,\n pluginsDir: string,\n): string[] {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as { imports?: Record<string, string> }\n const current = manifest.imports ?? {}\n const added = Object.keys(imports).filter((name) => !(name in current))\n manifest.imports = {\n ...Object.fromEntries(\n Object.entries(imports).map(([name, path]) => [name, `./${pluginsDir}/${path}`]),\n ),\n ...current,\n }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n return added\n}\n\n/** Declare a file as an opener in package.json (`\"acryl\": { \"opener\": [...] }`): the one place that may import a database provider. */\nexport function mergeOpener(appDir: string, opener: string): void {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n acryl?: { opener?: string | string[] }\n }\n const current = manifest.acryl?.opener\n const list = typeof current === 'string' ? [current] : (current ?? [])\n if (list.includes(opener)) return\n manifest.acryl = { ...manifest.acryl, opener: [...list, opener] }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\n/**\n * Add a plugin's development dependencies and scripts to an app's package.json: nothing the app already has is replaced. Returns the names of the development dependencies\n * and scripts added.\n */\nexport function mergeTooling(\n appDir: string,\n tooling: {\n devDependencies?: Readonly<Record<string, string>> | undefined\n scripts?: Readonly<Record<string, string>> | undefined\n },\n): { devDependencies: string[]; scripts: string[] } {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n devDependencies?: Record<string, string>\n scripts?: Record<string, string>\n }\n const dev = manifest.devDependencies ?? {}\n const scripts = manifest.scripts ?? {}\n const addedDev = Object.keys(tooling.devDependencies ?? {}).filter((name) => !(name in dev))\n const addedScripts = Object.keys(tooling.scripts ?? {}).filter((name) => !(name in scripts))\n manifest.devDependencies = Object.fromEntries(\n Object.entries({ ...tooling.devDependencies, ...dev }).sort(([a], [b]) => a.localeCompare(b)),\n )\n manifest.scripts = { ...tooling.scripts, ...scripts }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n return { devDependencies: addedDev, scripts: addedScripts }\n}\n\n/** Add the lines a plugin needs to the app's `.gitignore` when it has one and they are missing. Returns the lines added. */\nexport function appendGitignore(appDir: string, lines: readonly string[] | undefined): string[] {\n const file = join(appDir, '.gitignore')\n if (!lines || lines.length === 0 || !existsSync(file)) return []\n const current = readFileSync(file, 'utf8')\n const present = new Set(current.split('\\n').map((line) => line.trim()))\n const missing = lines.filter((line) => !present.has(line))\n if (missing.length > 0)\n writeFileSync(\n file,\n `${current}${current.endsWith('\\n') || current === '' ? '' : '\\n'}${missing.join('\\n')}\\n`,\n )\n return missing\n}\n\n/** The generated app's guide for a coding agent: the shared core, then the template's own part. `CLAUDE.md` is only an import of it. */\nexport function writeAgentFiles(\n sharedDir: string,\n templateDir: string,\n target: string,\n name: string,\n): string[] {\n const core = readFileSync(join(sharedDir, 'AGENTS.core.md'), 'utf8')\n const own = existsSync(join(templateDir, 'AGENTS.md'))\n ? readFileSync(join(templateDir, 'AGENTS.md'), 'utf8')\n : ''\n const defaults = readFileSync(join(sharedDir, 'DEFAULTS.md'), 'utf8')\n const text = `${core}${defaults}${own}`.replaceAll('__APP_NAME__', name)\n // AGENTS.md and CLAUDE.md are the same text; the one skill is written where each kind of agent looks for skills.\n writeFileSync(join(target, 'AGENTS.md'), text)\n writeFileSync(join(target, 'CLAUDE.md'), text)\n const skill = readFileSync(join(sharedDir, 'SKILL.md'), 'utf8').replaceAll('__APP_NAME__', name)\n const written = ['AGENTS.md', 'CLAUDE.md']\n for (const folder of ['.claude/skills/app-guide', '.agents/skills/app-guide']) {\n mkdirSync(join(target, folder), { recursive: true })\n writeFileSync(join(target, folder, 'SKILL.md'), skill)\n written.push(`${folder}/SKILL.md`)\n }\n return written\n}\n\n/**\n * Copy the framework's docs (a generated copy of ACRYL's `docs/framework`, already checked against its digest) into `<app>/docs/framework/`,\n * so a coding agent working in the app reads the API from the folder it is in. The generated-copy notes and the digest record stay behind.\n *\n * @returns the copied files, relative to `target`\n */\nexport function copyFrameworkDocs(source: string, target: string): string[] {\n const written: string[] = []\n const walk = (from: string, to: string, prefix: string) => {\n for (const entry of readdirSync(from, { withFileTypes: true })) {\n if (entry.name === 'upstream.json' || entry.name === 'UPSTREAM.md') continue\n const sourcePath = join(from, entry.name)\n const targetPath = join(to, entry.name)\n if (entry.isDirectory()) {\n mkdirSync(targetPath, { recursive: true })\n walk(sourcePath, targetPath, `${prefix}${entry.name}/`)\n continue\n }\n cpSync(sourcePath, targetPath)\n written.push(`docs/framework/${prefix}${entry.name}`)\n }\n }\n mkdirSync(join(target, 'docs', 'framework'), { recursive: true })\n walk(source, join(target, 'docs', 'framework'), '')\n return written\n}\n","import { existsSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/** The templates, all Cordis apps: a web app with a page and a client component (nodejs), a notes app and a chat app on the db port (notes, chat), a blank app on the router, a todo list on the router and state, and the blank app with the offline agent. */\nexport const TEMPLATES = ['nodejs', 'notes', 'chat', 'blank', 'todo', 'agent'] as const\nexport type Template = (typeof TEMPLATES)[number]\n\nexport function isTemplate(value: string): value is Template {\n return (TEMPLATES as readonly string[]).includes(value)\n}\n\n/**\n * The `templates/` folder of this package. The module sits at different depths in source (`src/`) and in the build\n * (`dist/`), so walk up until a `templates` folder holds the `blank` template.\n */\nexport function templatesRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const candidate = join(dir, 'templates')\n if (existsSync(join(candidate, 'blank'))) return candidate\n const parent = dirname(dir)\n if (parent === dir) throw new Error('acrylblends cannot find its templates folder')\n dir = parent\n }\n}\n\n/** Absolute path of a template folder. */\nexport function templateDir(template: Template): string {\n return join(templatesRoot(), template)\n}\n\n/** The text every generated app's `AGENTS.md` starts with (`shared/`, beside `templates/`). */\nexport function sharedDir(): string {\n return join(dirname(templatesRoot()), 'shared')\n}\n\n/**\n * The framework's docs, as ACRYL wrote them: `docs/framework` of the repository, or the copy `prepack` puts inside the package. The module sits at\n * different depths in source and in the build, so walk up until a `docs/framework` folder holds the README.\n */\nexport function frameworkDocsRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const candidate = join(dir, 'docs', 'framework')\n if (existsSync(join(candidate, 'README.md'))) return candidate\n const parent = dirname(dir)\n if (parent === dir)\n throw new Error('acrylblends cannot find the framework docs (docs/framework)')\n dir = parent\n }\n}\n","import { resolve } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport type { Io } from './io'\nimport { closure, copyPlugin, readLibrary } from './library'\nimport {\n copyFrameworkDocs,\n copyTemplate,\n isValidName,\n mergeDependencies,\n mergeImports,\n mergeTooling,\n nameFrom,\n readTemplateDesktopPath,\n readTemplatePlugins,\n TargetNotEmptyError,\n writeAgentFiles,\n writeDesktopPath,\n} from './project'\nimport {\n frameworkDocsRoot,\n isTemplate,\n sharedDir,\n TEMPLATES,\n type Template,\n templateDir,\n} from './templates'\n\n/** A command line mistake. The CLI prints it with the help text and exits 2. */\nexport class UsageError extends Error {\n override name = 'UsageError'\n}\n\n/** What `init` was asked for. Anything left undefined is asked for on a terminal, or defaulted. */\nexport interface InitOptions {\n directory: string | undefined\n name: string | undefined\n template: Template | undefined\n install: boolean | undefined\n /** Also add the desktop shell (`add desktop`): an Electron window on the app's own server. */\n desktop: boolean\n yes: boolean\n}\n\n/** Parse `init [dir] [--template t] [--agent|--no-agent] [--name n] [--install] [-y]`. `--agent` means `--template agent`, `--no-agent` means `--template blank`. */\nexport function parseInitOptions(argv: readonly string[]): InitOptions {\n let parsed: ReturnType<typeof parse>\n try {\n parsed = parse(argv)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n const { values, positionals } = parsed\n if (positionals.length > 1) throw new UsageError('init takes at most one directory')\n if (values.agent && values['no-agent'])\n throw new UsageError('use --agent or --no-agent, not both')\n if (values.template !== undefined && !isTemplate(values.template))\n throw new UsageError(`unknown template \"${values.template}\" (${TEMPLATES.join(', ')})`)\n const alias: Template | undefined = values.agent\n ? 'agent'\n : values['no-agent']\n ? 'blank'\n : undefined\n if (values.template !== undefined && alias !== undefined && values.template !== alias)\n throw new UsageError(\n `--template ${values.template} contradicts --${alias === 'agent' ? 'agent' : 'no-agent'}`,\n )\n return {\n directory: positionals[0],\n name: values.name,\n template: (values.template as Template | undefined) ?? alias,\n install: values.install,\n desktop: values.desktop === true,\n yes: values.yes === true,\n }\n}\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n name: { type: 'string' },\n template: { type: 'string' },\n agent: { type: 'boolean' },\n 'no-agent': { type: 'boolean' },\n install: { type: 'boolean' },\n desktop: { type: 'boolean' },\n yes: { type: 'boolean', short: 'y' },\n },\n })\n\nconst yes = (answer: string) => ['y', 'yes'].includes(answer.trim().toLowerCase())\n\nasync function askTemplate(ask: (question: string) => Promise<string>): Promise<Template> {\n const answer = (await ask(`Template (${TEMPLATES.join(', ')}) [blank]: `)).trim().toLowerCase()\n if (answer === '') return 'blank'\n if (isTemplate(answer)) return answer\n throw new UsageError(`unknown template \"${answer}\" (${TEMPLATES.join(', ')})`)\n}\n\n/** Scaffold a Cordis app. Returns the exit code: 0 done, 1 refused or failed. Never overwrites anything. */\nexport async function init(options: InitOptions, io: Io): Promise<number> {\n const relative = options.directory ?? '.'\n const directory = resolve(io.cwd, relative)\n const ask = options.yes ? undefined : io.ask\n\n let name = options.name ?? nameFrom(directory)\n if (options.name === undefined && ask)\n name = (await ask(`Project name (${name}): `)).trim() || name\n if (!isValidName(name)) {\n throw new UsageError(\n `\"${name}\" is not a valid project name (lower case letters, digits and dashes, starting with a letter)`,\n )\n }\n const template = options.template ?? (ask ? await askTemplate(ask) : 'blank')\n const install =\n options.install ?? (ask ? yes(await ask('Install dependencies with npm now? (y/N): ')) : false)\n\n let files: string[]\n try {\n files = copyTemplate(templateDir(template), directory, name)\n files.push(...writeAgentFiles(sharedDir(), templateDir(template), directory, name))\n files.push(...copyFrameworkDocs(frameworkDocsRoot(), directory))\n } catch (error) {\n if (!(error instanceof TargetNotEmptyError)) throw error\n io.stderr.write(`error: ${error.message}\\n`)\n return 1\n }\n const plugins = closure(\n [...readTemplatePlugins(templateDir(template)), ...(options.desktop ? ['desktop'] : [])],\n readLibrary(),\n )\n for (const plugin of plugins) {\n copyPlugin(plugin, directory)\n if (plugin.imports) mergeImports(directory, plugin.imports, 'plugins')\n mergeDependencies(directory, plugin.dependencies)\n mergeTooling(directory, plugin)\n }\n const desktopPath = options.desktop ? readTemplateDesktopPath(templateDir(template)) : undefined\n if (desktopPath !== undefined) writeDesktopPath(directory, desktopPath)\n io.stdout.write(\n `created ${name} (${template}) in ${directory}: ${files.length} files, plugins ${plugins.map((plugin) => plugin.name).join(', ')}\\n`,\n )\n\n if (install && (await io.install(directory)) !== 0) {\n io.stderr.write('error: npm install failed; run it yourself in the new directory\\n')\n return 1\n }\n const steps = [\n relative === '.' ? '' : ` cd ${relative}\\n`,\n install ? '' : ' npm install\\n',\n ' npm run dev\\n npm test\\n',\n ]\n io.stdout.write(`\\nNext:\\n${steps.join('')}`)\n return 0\n}\n","import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, dirname, join, relative, resolve, sep } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport { UsageError } from './init'\nimport type { Io } from './io'\nimport {\n closure,\n copyPlugin,\n copyRewritten,\n LEGACY_WARNING,\n type LibraryPlugin,\n libraryRoot,\n PLUGINS_DIR,\n pluginsFolder,\n readLibrary,\n} from './library'\nimport {\n appendGitignore,\n mergeDependencies,\n mergeImports,\n mergeOpener,\n mergeTooling,\n} from './project'\n\nexport interface AddOptions {\n readonly names: readonly string[]\n readonly directory: string | undefined\n /** Also copy the port's conformance suite (`src/conformance.ts`) and the `vitest` it runs on: what a provider of your own must pass. */\n readonly suite: boolean\n}\n\n/** Parse `add <plugin...> [--dir <app>] [--suite]`. */\nexport function parseAddOptions(argv: readonly string[]): AddOptions {\n let parsed: ReturnType<typeof parse>\n try {\n parsed = parse(argv)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n if (parsed.positionals.length === 0)\n throw new UsageError('add needs at least one plugin name (see \"acrylblends plugins\")')\n return {\n names: parsed.positionals,\n directory: parsed.values.dir,\n suite: parsed.values.suite === true,\n }\n}\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: { dir: { type: 'string' }, suite: { type: 'boolean' } },\n })\n\nconst present = (appDir: string, name: string) => existsSync(join(pluginsFolder(appDir).dir, name))\n\n/**\n * Copy library plugins into an existing app, with the plugins they require, and add their npm packages to its package.json.\n * Refuses a plugin the app already has. Returns the exit code.\n */\nexport async function add(options: AddOptions, io: Io): Promise<number> {\n const appDir = resolve(io.cwd, options.directory ?? '.')\n if (!existsSync(join(appDir, 'package.json')) || !existsSync(join(appDir, 'src'))) {\n io.stderr.write(\n `error: ${appDir} is not an app (no package.json and src/); run \"acrylblends init\" first\\n`,\n )\n return 1\n }\n if (pluginsFolder(appDir).legacy) io.stderr.write(`${LEGACY_WARNING}\\n`)\n // A path is an external plugin folder; anything else is a library plugin name.\n const external = options.names.filter((name) => /[\\\\/]/.test(name) || name.startsWith('.'))\n for (const folder of external) {\n const code = addExternal(resolve(io.cwd, folder), appDir, io)\n if (code !== 0) return code\n }\n // The desktop shell has two forms: the Blend app (it needs the `instance` plugin) and a plain Acryl app (`export default app`); `desktop` means the one that fits.\n const plain = !existsSync(join(pluginsFolder(appDir).dir, 'instance'))\n if (plain && options.names.includes('db')) {\n io.stderr.write(\n 'error: \"db\" is the Cordis plugin for a Blend app. A plain Acryl app opens its database with openDb from \"acrylblends/db/sqlite\" (see docs/framework/guides/data.md)\\n',\n )\n return 1\n }\n if (plain && options.names.includes('kv')) {\n io.stderr.write(\n 'error: \"kv\" is the Cordis plugin for a Blend app. A plain Acryl app opens its store with openKv from \"acrylblends/kv/json\" (see docs/framework/guides/data.md#a-tiny-app-kv)\\n',\n )\n return 1\n }\n const names = options.names\n .filter((name) => !external.includes(name))\n // `db` is the SQLite provider of the db port (it brings the port); a plain app opens its database with `acrylblends/db/sqlite` instead.\n .map((name) => (name === 'db' ? 'acryl-db-sqlite' : name))\n // `kv` is the JSON-file provider of the kv port (it brings the port); `acryl-kv-db` is the one over db.\n .map((name) => (name === 'kv' ? 'acryl-kv-json' : name))\n .map((name) => (name === 'desktop' && plain ? 'desktop-web' : name))\n if (names.length === 0) return 0\n const already = options.suite ? [] : names.filter((name) => present(appDir, name))\n if (already.length > 0) {\n io.stderr.write(\n `error: the app already has ${already\n .map(\n (name) =>\n `${relative(appDir, join(pluginsFolder(appDir).dir, name))\n .split(sep)\n .join('/')}`,\n )\n .join(', ')}\\n`,\n )\n return 1\n }\n const toCopy: LibraryPlugin[] = closure(names, readLibrary()).filter(\n (plugin) => !present(appDir, plugin.name),\n )\n const addedDependencies: string[] = []\n for (const plugin of toCopy) {\n copyPlugin(plugin, appDir)\n if (plugin.imports)\n mergeImports(\n appDir,\n plugin.imports,\n relative(appDir, pluginsFolder(appDir).dir).split(sep).join('/'),\n )\n addedDependencies.push(...mergeDependencies(appDir, plugin.dependencies))\n const tooling = mergeTooling(appDir, plugin)\n appendGitignore(appDir, plugin.gitignore)\n // The provider is mounted from src/app.ts, which is therefore the one file that may import it (`acrylblends check-deps`).\n if (plugin.name === 'acryl-db-sqlite') mergeOpener(appDir, 'src/app.ts')\n addedDependencies.push(...tooling.devDependencies)\n if (tooling.scripts.length > 0)\n io.stdout.write(\n `new scripts: ${tooling.scripts.map((name) => `npm run ${name}`).join(', ')}\\n`,\n )\n }\n if (options.suite) {\n const refused = copySuites(names, appDir, addedDependencies, io)\n if (refused !== 0) return refused\n }\n io.stdout.write(`added ${toCopy.map((plugin) => plugin.name).join(', ')} to ${appDir}\\n`)\n if (addedDependencies.length > 0)\n io.stdout.write(`new dependencies: ${addedDependencies.join(', ')} (run npm install)\\n`)\n for (const plugin of toCopy.filter((plugin) => names.includes(plugin.name))) {\n io.stdout.write(\n `\\n${plugin.name}: ${plugin.mount ?? `import it from '../plugins/${plugin.name}/index.ts' and mount it in src/app.ts`}\\n`,\n )\n }\n return 0\n}\n\n/**\n * The vitest the suites run on. 3.2.x, not the newest: npm 10 (the npm of Node 22) crashes on the dependency tree of vitest 4 and 5 (\"Cannot read properties of null (reading\n * 'edgesOut')\"), and the suites use only `describe`, `it` and `expect`, which are the same in all of them. An app on a newer npm may raise it.\n */\nconst SUITE_RUNNER = { vitest: '3.2.4' }\n\n/**\n * Copy the conformance suite of each named port next to its source (`plugins/<name>/src/conformance.ts`), and add `vitest` to the app's development\n * dependencies. The suite is left out of a normal copy because an app that only uses a port has no use for it. Returns the exit code: 1 when a plugin has none.\n */\nfunction copySuites(names: readonly string[], appDir: string, added: string[], io: Io): number {\n const copies: Array<{ from: string; to: string }> = []\n // The suite belongs to the port: `add kv --suite` (acryl-kv-json, or acryl-kv-db) brings the suite of acryl-kv.\n const ports = [\n ...new Set(names.map((name) => name.replace(/^(acryl-(?:kv|db))(?:-.*)?$/u, '$1'))),\n ]\n const library = readLibrary()\n for (const name of ports) {\n const suite = library.get(name)?.suite\n const from = suite === undefined ? '' : join(libraryRoot(), name, suite)\n if (suite === undefined || !existsSync(from)) {\n io.stderr.write(`error: ${name} has no conformance suite (the ports db and kv do)\\n`)\n return 1\n }\n copies.push({ from, to: join(pluginsFolder(appDir).dir, name, suite) })\n }\n for (const { from, to } of copies) {\n mkdirSync(dirname(to), { recursive: true })\n copyRewritten(from, to, pluginOf(to), suiteOf(to))\n io.stdout.write(`added the conformance suite ${relative(appDir, to).split(sep).join('/')}\\n`)\n }\n added.push(...mergeTooling(appDir, { devDependencies: SUITE_RUNNER }).devDependencies)\n return 0\n}\n\n/** The plugin folder name and the file inside it, from a path below the plugins folder (`.../plugins/acryl-kv/src/conformance.ts`). */\nconst pluginOf = (path: string): string => path.split(sep).slice(-3, -2)[0] ?? ''\nconst suiteOf = (path: string): string => path.split(sep).slice(-2).join('/')\n\nconst PLUGIN_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/\n\n/**\n * Bring an external plugin folder (a package made with the builder's package_plugin, or any folder with an index.ts that exports a\n * Cordis plugin) into the app's `plugins/`, where the extensions plugin installs it like any other: checked, staged, started,\n * verified. Its runtime dependencies are not installed here; they are reported so the user adds them deliberately.\n */\nfunction addExternal(folder: string, appDir: string, io: Io): number {\n if (!existsSync(folder) || !statSync(folder).isDirectory()) {\n io.stderr.write(`error: ${folder} is not a folder\\n`)\n return 1\n }\n if (!['index.ts', 'index.js', 'index.mjs'].some((entry) => existsSync(join(folder, entry)))) {\n io.stderr.write(`error: ${folder} has no index.ts that exports a Cordis plugin\\n`)\n return 1\n }\n const manifestFile = join(folder, 'package.json')\n const manifest = existsSync(manifestFile)\n ? (JSON.parse(readFileSync(manifestFile, 'utf8')) as {\n name?: string\n dependencies?: Record<string, string>\n })\n : {}\n const name = (manifest.name ?? basename(folder)).replace(/^@[^/]+\\//, '')\n if (!PLUGIN_NAME.test(name)) {\n io.stderr.write(\n `error: \"${name}\" is not a plugin name (lowercase letters, digits and dashes)\\n`,\n )\n return 1\n }\n const target = join(\n pluginsFolder(appDir).legacy ? join(appDir, 'extensions') : join(appDir, PLUGINS_DIR),\n name,\n )\n if (existsSync(target)) {\n io.stderr.write(`error: the app already has ${relative(appDir, target).split(sep).join('/')}\\n`)\n return 1\n }\n cpSync(folder, target, {\n recursive: true,\n filter: (path) => !/[\\\\/](node_modules|\\.git)([\\\\/]|$)/.test(path.slice(folder.length)),\n })\n io.stdout.write(\n `added external plugin ${name} to ${dirname(target)}; it installs at the next start\\n`,\n )\n const dependencies = Object.keys(manifest.dependencies ?? {})\n if (dependencies.length > 0)\n io.stdout.write(\n `it uses ${dependencies.join(', ')}: add them to the app with npm install first\\n`,\n )\n return 0\n}\n\n/** `acrylblends plugins`: the library, one line per plugin. */\nexport function listPlugins(io: Io): number {\n for (const plugin of readLibrary().values()) {\n const requires = plugin.requires.length > 0 ? ` (requires ${plugin.requires.join(', ')})` : ''\n io.stdout.write(`${plugin.name.padEnd(12)} ${plugin.description}${requires}\\n`)\n }\n return 0\n}\n","import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { relative, resolve } from 'node:path'\nimport { UsageError } from './init'\nimport type { Io } from './io'\n\n/** Parse `build-client [root] [outDir]`. */\nexport function parseBuildClientOptions(argv: readonly string[]): { root: string; outDir: string } {\n const args = argv.filter((a) => !a.startsWith('-'))\n if (args.length !== argv.length)\n throw new UsageError('build-client takes [root] [outDir] and no options')\n if (args.length > 2)\n throw new UsageError('build-client takes at most two arguments: [root] [outDir]')\n return { root: args[0] ?? 'src/client', outDir: args[1] ?? 'dist/client' }\n}\n\n/**\n * Compile the app's client modules once (`buildClientModules` of the framework), for a production install that has no compiler at run time.\n * The framework is the one installed in the app (so the compiled files match the server that serves them), else this package's own.\n */\nexport async function buildClient(\n options: { root: string; outDir: string },\n io: Io,\n): Promise<number> {\n const root = resolve(io.cwd, options.root)\n if (!existsSync(root)) {\n io.stderr.write(\n `error: ${root} does not exist; the client modules live in src/client by default\\n`,\n )\n return 1\n }\n const outDir = resolve(io.cwd, options.outDir)\n const here = createRequire(resolve(io.cwd, 'package.json'))\n let specifier = 'acrylblends/node-server'\n try {\n here.resolve(specifier)\n } catch {\n specifier = new URL('../lib/node-server.js', import.meta.url).href\n }\n const mod = (await import(\n specifier.startsWith('file:') ? specifier : here.resolve(specifier)\n )) as typeof import('../lib/node-server')\n const written = mod.buildClientModules({ root, outDir })\n for (const file of written) io.stdout.write(`${relative(io.cwd, resolve(outDir, file))}\\n`)\n io.stdout.write(`built ${written.length} files in ${relative(io.cwd, outDir) || '.'}\\n`)\n return 0\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { Io } from './io'\n\n/**\n * The dependency rule (spec 049): app code imports a port, never a provider. A port is `acrylblends/db` (the `Db` type); a provider is a\n * driver or the one function that opens a database. Only the opener, a file the app names once in package.json, may import a provider.\n */\n\n/** A package that is a database driver. An import of it, or of anything below it, is a provider import. */\nconst DRIVERS = [\n 'node:sqlite',\n 'sqlite',\n 'sqlite3',\n 'better-sqlite3',\n '@libsql/client',\n 'libsql',\n 'pg',\n 'pg-pool',\n 'pg-native',\n 'postgres',\n '@electric-sql/pglite',\n '@neondatabase/serverless',\n '@vercel/postgres',\n 'mysql',\n 'mysql2',\n]\n/** The openers a provider ships: importing one of them is opening a database. */\nconst OPENERS = ['acrylblends/db/sqlite', 'acryl-db-sqlite']\n/** The desktop shell is where Electron lives (`acrylblends add desktop` copies it). */\nconst ELECTRON = 'electron'\nconst ELECTRON_HOMES = [\n 'plugins/desktop/',\n 'plugins/desktop-web/',\n 'src/plugins/desktop/',\n 'src/plugins/desktop-web/',\n]\n/** The provider plugins themselves may import what they wrap. */\nconst PROVIDER_HOMES = ['plugins/acryl-db-sqlite/', 'src/plugins/acryl-db-sqlite/']\n\nconst SOURCE = /\\.(?:[cm]?[jt]s|[jt]sx)$/u\nconst SKIP_DIRS = new Set(['node_modules', 'dist', 'lib', 'build', 'coverage'])\nconst ROOTS = ['src', 'test', 'tests', 'plugins', 'extensions']\n\nexport interface Violation {\n readonly file: string\n readonly line: number\n readonly specifier: string\n readonly kind: 'driver' | 'opener' | 'electron'\n}\n\nconst matches = (specifier: string, name: string): boolean =>\n specifier === name || specifier.startsWith(`${name}/`)\n\n/** What a specifier is to the rule, or undefined when it is not a provider. */\nexport function classifySpecifier(specifier: string): Violation['kind'] | undefined {\n if (DRIVERS.some((name) => matches(specifier, name))) return 'driver'\n if (OPENERS.some((name) => matches(specifier, name))) return 'opener'\n if (matches(specifier, ELECTRON)) return 'electron'\n return undefined\n}\n\n/** The source with every comment replaced by spaces (newlines kept), so a line number still means what it did and a commented import is not an import. */\nexport function blankComments(source: string): string {\n let out = ''\n let i = 0\n while (i < source.length) {\n const c = source[i] as string\n const next = source[i + 1]\n if (c === '/' && next === '/') {\n const end = source.indexOf('\\n', i)\n const stop = end === -1 ? source.length : end\n out += ' '.repeat(stop - i)\n i = stop\n } else if (c === '/' && next === '*') {\n const end = source.indexOf('*/', i + 2)\n const stop = end === -1 ? source.length : end + 2\n out += source.slice(i, stop).replace(/[^\\n]/gu, ' ')\n i = stop\n } else if (c === \"'\" || c === '\"' || c === '`') {\n let j = i + 1\n while (j < source.length && source[j] !== c) {\n if (source[j] === '\\\\') j += 1\n else if (c !== '`' && source[j] === '\\n') break\n j += 1\n }\n out += source.slice(i, Math.min(j + 1, source.length))\n i = j + 1\n } else {\n out += c\n i += 1\n }\n }\n return out\n}\n\n/** `import x from 'a'`, `export * from 'a'`, `import 'a'`, `import('a')` and `require('a')`, with the line of each. */\nconst IMPORT =\n /(?:^|[\\s;{}()])(?:import\\s*(?:type\\s+)?(?:[\\w*${},\\s]*?\\s*from\\s*)?|export\\s*(?:type\\s+)?[\\w*${},\\s]*?\\s*from\\s*|import\\s*\\(\\s*|require\\s*\\(\\s*)(['\"])([^'\"\\n]+)\\1/gu\n\nexport function importsOf(source: string): { specifier: string; line: number }[] {\n const code = blankComments(source)\n const found: { specifier: string; line: number }[] = []\n for (const match of code.matchAll(IMPORT)) {\n const specifier = match[2] as string\n const at = (match.index ?? 0) + match[0].length - specifier.length - 2\n found.push({ specifier, line: code.slice(0, at).split('\\n').length })\n }\n return found\n}\n\nfunction listSources(dir: string, out: string[] = []): string[] {\n if (!existsSync(dir)) return out\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name)) continue\n const path = join(dir, entry.name)\n if (entry.isDirectory()) listSources(path, out)\n else if (SOURCE.test(entry.name) && !entry.name.endsWith('.d.ts')) out.push(path)\n }\n return out\n}\n\n/** The opener files the app declares: `\"acryl\": { \"opener\": \"src/db.ts\" }` (or a list) in package.json. */\nexport function openersOf(appDir: string): string[] {\n const file = join(appDir, 'package.json')\n if (!existsSync(file)) return []\n const declared = (JSON.parse(readFileSync(file, 'utf8')) as { acryl?: { opener?: unknown } })\n .acryl?.opener\n const list = typeof declared === 'string' ? [declared] : Array.isArray(declared) ? declared : []\n return list.filter((entry): entry is string => typeof entry === 'string')\n}\n\n/** Every provider import outside the declared opener (and the homes that may hold one), in file and line order. */\nexport function findViolations(appDir: string): Violation[] {\n const openers = new Set(openersOf(appDir).map((entry) => entry.split(sep).join('/')))\n const violations: Violation[] = []\n for (const root of ROOTS) {\n for (const path of listSources(join(appDir, root)).sort()) {\n const file = relative(appDir, path).split(sep).join('/')\n if (openers.has(file)) continue\n for (const { specifier, line } of importsOf(readFileSync(path, 'utf8'))) {\n const kind = classifySpecifier(specifier)\n if (kind === undefined) continue\n if (kind === 'electron' && ELECTRON_HOMES.some((home) => file.startsWith(home))) continue\n if (kind !== 'electron' && PROVIDER_HOMES.some((home) => file.startsWith(home))) continue\n violations.push({ file, line, specifier, kind })\n }\n }\n }\n return violations\n}\n\nconst GUIDE = 'docs/framework/guides/data.md#why-the-database-is-opened-in-one-place'\n\nfunction advice(violation: Violation, openers: readonly string[]): string {\n if (violation.kind === 'electron')\n return `\"${violation.specifier}\" is the desktop shell's: only plugins/desktop (added with \"acrylblends add desktop\") imports electron`\n const where =\n openers.length > 0\n ? openers.join(', ')\n : 'a file named in package.json \"acryl\": { \"opener\": \"...\" }'\n return violation.kind === 'driver'\n ? `\"${violation.specifier}\" is a database driver; take a Db (import type { Db } from \"acrylblends/db\") as an argument and let ${where} open the database`\n : `\"${violation.specifier}\" opens a database, and only ${where} may; take a Db (import type { Db } from \"acrylblends/db\") as an argument`\n}\n\n/** Parse `check-deps [dir]`. */\nexport function parseCheckDepsOptions(argv: readonly string[]): { directory: string | undefined } {\n const args = argv.filter((a) => !a.startsWith('-'))\n if (args.length !== argv.length || args.length > 1)\n throw new Error('check-deps takes at most one argument: the app folder')\n return { directory: args[0] }\n}\n\n/** Report each provider import outside the opener, as `file:line: why`. Returns the exit code: 1 when there is one. */\nexport function checkDeps(options: { directory: string | undefined }, io: Io): number {\n const appDir = resolve(io.cwd, options.directory ?? '.')\n const violations = findViolations(appDir)\n if (violations.length === 0) {\n io.stdout.write('check-deps: no app code imports a database provider outside the opener\\n')\n return 0\n }\n const openers = openersOf(appDir)\n for (const violation of violations)\n io.stderr.write(`${violation.file}:${violation.line}: ${advice(violation, openers)}\\n`)\n io.stderr.write(`See ${GUIDE}\\n`)\n return 1\n}\n","import { existsSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\n\nexport interface Invocation {\n file: string\n args: string[]\n}\n\n/**\n * How to start a package manager without the shell option (Node warns about passing args to a shell, DEP0190, and a `.cmd` shim cannot be spawned directly).\n * Off Windows the command runs as it is. On Windows npm runs as `node npm-cli.js` (the one npm is running from, else the one beside `node`); any other\n * manager goes through `cmd.exe /d /s /c <name>.cmd`, whose arguments stay an array.\n */\nexport function packageManagerInvocation(\n command: string,\n args: readonly string[],\n platform: NodeJS.Platform = process.platform,\n env: NodeJS.ProcessEnv = process.env,\n exists: (path: string) => boolean = existsSync,\n execPath: string = process.execPath,\n): Invocation {\n if (platform !== 'win32') return { file: command, args: [...args] }\n if (command === 'npm') {\n const running = env.npm_execpath\n const cli =\n running !== undefined && /npm-cli\\.c?js$/.test(running)\n ? running\n : join(dirname(execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js')\n if (exists(cli)) return { file: execPath, args: [cli, ...args] }\n }\n return { file: env.ComSpec ?? 'cmd.exe', args: ['/d', '/s', '/c', `${command}.cmd`, ...args] }\n}\n","import { spawn } from 'node:child_process'\nimport { createInterface } from 'node:readline/promises'\nimport { packageManagerInvocation } from './spawn'\n\n/** Everything the CLI touches outside the filesystem. Tests pass their own. */\nexport interface Io {\n stdout: { write(text: string): unknown }\n stderr: { write(text: string): unknown }\n cwd: string\n /** Ask one question; `undefined` when there is no terminal to ask on. */\n ask: ((question: string) => Promise<string>) | undefined\n /** Install dependencies in a directory; resolves to the exit code. */\n install(directory: string): Promise<number>\n}\n\n/** The real terminal and `npm install`. */\nexport function processIo(): Io {\n const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY)\n return {\n stdout: process.stdout,\n stderr: process.stderr,\n cwd: process.cwd(),\n ask: interactive\n ? async (question) => {\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n try {\n return await rl.question(question)\n } finally {\n rl.close()\n }\n }\n : undefined,\n install: (directory) =>\n new Promise((done) => {\n const { file, args } = packageManagerInvocation('npm', ['install'])\n const child = spawn(file, args, { cwd: directory, stdio: 'inherit' })\n child.on('error', () => done(1))\n child.on('exit', (code) => done(code ?? 1))\n }),\n }\n}\n","import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { resolve } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport { UsageError } from './init'\nimport type { Io } from './io'\n\nexport interface KvImportOptions {\n readonly from: string\n readonly to: string\n readonly overwrite: boolean\n readonly table: string | undefined\n readonly migrations: string | undefined\n}\n\n/** Parse `kv import <kv.json> <database.sqlite> [--overwrite] [--table name] [--migrations dir]`. */\nexport function parseKvOptions(argv: readonly string[]): KvImportOptions {\n let parsed: ReturnType<typeof parse>\n try {\n parsed = parse(argv)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n const [action, from, to, ...rest] = parsed.positionals\n if (action !== 'import')\n throw new UsageError('kv takes one subcommand: kv import <kv.json> <database.sqlite>')\n if (from === undefined || to === undefined || rest.length > 0)\n throw new UsageError('kv import takes two arguments: the JSON file and the SQLite file')\n return {\n from,\n to,\n overwrite: parsed.values.overwrite ?? false,\n table: parsed.values.table,\n migrations: parsed.values.migrations,\n }\n}\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n overwrite: { type: 'boolean' },\n table: { type: 'string' },\n migrations: { type: 'string' },\n },\n })\n\n/** The framework as the app has it installed (so the code that reads the file is the code the app runs), else this package's own. */\nasync function framework<T>(io: Io, subpath: string, own: string): Promise<T> {\n const here = createRequire(resolve(io.cwd, 'package.json'))\n try {\n return (await import(here.resolve(`acrylblends/${subpath}`))) as T\n } catch {\n return (await import(new URL(`../lib/${own}`, import.meta.url).href)) as T\n }\n}\n\n/**\n * Import a JSON-file kv store into the `kv` table of an app's SQLite database: the move from `acryl-kv-json` to SQL. The file is not changed.\n * The database is opened with the app's `migrations/` folder when it has one (a database whose schema is newer than the files given is refused),\n * and the table is created when missing. Refuses to overwrite a key the table already has unless `--overwrite`.\n */\nexport async function kvImport(options: KvImportOptions, io: Io): Promise<number> {\n const from = resolve(io.cwd, options.from)\n const to = resolve(io.cwd, options.to)\n if (!existsSync(from)) {\n io.stderr.write(`error: ${from} does not exist\\n`)\n return 1\n }\n const kvCore = await framework<typeof import('../lib/kv')>(io, 'kv', 'kv.js')\n const json = await framework<typeof import('../lib/kv/json')>(io, 'kv/json', 'kv/json.js')\n const onDb = await framework<typeof import('../lib/kv/db')>(io, 'kv/db', 'kv/db.js')\n const sqlite = await framework<typeof import('../lib/db/sqlite')>(io, 'db/sqlite', 'db/sqlite.js')\n const migrations =\n options.migrations !== undefined\n ? resolve(io.cwd, options.migrations)\n : existsSync(resolve(io.cwd, 'migrations'))\n ? resolve(io.cwd, 'migrations')\n : undefined\n const source = await json.openKv({ path: from })\n try {\n const database = await sqlite.openDb({\n path: to,\n ...(migrations === undefined ? {} : { migrations }),\n })\n try {\n const target = onDb.kvOnDb(\n database.db,\n options.table === undefined ? {} : { table: options.table },\n )\n const result = await kvCore.copyKv(source.kv, target, { overwrite: options.overwrite })\n io.stdout.write(\n `imported ${result.copied} ${result.copied === 1 ? 'key' : 'keys'} from ${options.from} into ${options.to}` +\n `${options.table === undefined ? '' : ` (table ${options.table})`}` +\n `${result.overwritten > 0 ? `, ${result.overwritten} overwritten` : ''}\\n`,\n )\n return 0\n } finally {\n await database.close()\n }\n } finally {\n await source.close()\n }\n}\n","import { add, listPlugins, parseAddOptions } from './add'\nimport { buildClient, parseBuildClientOptions } from './build-client'\nimport { checkDeps, parseCheckDepsOptions } from './check-deps'\nimport { init, parseInitOptions, UsageError } from './init'\nimport { type Io, processIo } from './io'\nimport { kvImport, parseKvOptions } from './kv-import'\nimport { VERSION } from './version'\n\nexport { VERSION }\n\nexport const HELP = `acrylblends ${VERSION} - scaffold Cordis apps\n\nUsage:\n acrylblends init [dir] [options] Create a Cordis app in an empty or new directory\n acrylblends add <plugin...> [--dir d] [--suite] Copy library plugins (and what they require) into an app;\n a folder path brings an external plugin into its plugins/;\n --suite also copies the port's conformance suite and vitest (add kv --suite)\n acrylblends plugins List the plugin library\n acrylblends build-client [root] [out] Compile the client modules once for production (src/client to dist/client)\n acrylblends kv import <kv.json> <db> Move a JSON-file kv store into the kv table of a SQLite database [--overwrite] [--table t] [--migrations dir]\n acrylblends check-deps [dir] Fail when app code imports a database driver or opener outside the file named in\n package.json \"acryl\": { \"opener\": \"src/db.ts\" } (a port is imported, a provider is not)\n\nOptions for init:\n --template <name> blank or agent (asked when not given); --agent means --template agent,\n --no-agent means --template blank\n --name <name> the project name (default: the directory name)\n --desktop also add the desktop shell: npm run desktop opens a window on the app\n --install run npm install after copying\n -y, --yes ask nothing; use defaults (the blank template, no install)\n\n -h, --help show this help\n -v, --version show the version\n`\n\n/**\n * Run the CLI and return the exit code: 0 done, 1 failed or refused, 2 a usage error. Never calls `process.exit`.\n */\nexport async function runCli(argv: readonly string[], io: Io = processIo()): Promise<number> {\n const [command, ...args] = argv\n try {\n if (command === undefined || command === 'help' || command === '-h' || command === '--help') {\n io.stdout.write(HELP)\n return command === undefined ? 2 : 0\n }\n if (command === 'version' || command === '-v' || command === '--version') {\n io.stdout.write(`${VERSION}\\n`)\n return 0\n }\n if (command === 'init') return await init(parseInitOptions(args), io)\n if (command === 'add') return await add(parseAddOptions(args), io)\n if (command === 'build-client') return await buildClient(parseBuildClientOptions(args), io)\n if (command === 'kv') return await kvImport(parseKv(args), io)\n if (command === 'check-deps') return checkDeps(parseCheckDeps(args), io)\n if (command === 'plugins') return listPlugins(io)\n throw new UsageError(`unknown command \"${command}\"`)\n } catch (error) {\n if (error instanceof UsageError) {\n io.stderr.write(`error: ${error.message}\\n\\n${HELP}`)\n return 2\n }\n io.stderr.write(`error: ${error instanceof Error ? error.message : String(error)}\\n`)\n return 1\n }\n}\n\nfunction parseCheckDeps(args: readonly string[]) {\n try {\n return parseCheckDepsOptions(args)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n}\n\nfunction parseKv(args: readonly string[]) {\n return parseKvOptions(args)\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,WACd,SACY;CACZ,MAAM,wBAAQ,IAAI,IAAoB;CACtC,KAAK,MAAM,CAAC,QAAQ,EAAE,cAAc,SAClC,KAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,WAAW,CAAC,CAAC,GACxD,MAAM,IAAI,GAAG,SAAS,WAAW,GAAG,OAAO,GAAG,MAAM;CACxD,OAAO;AACT;;AAGA,SAAS,SAAS,QAA4B;CAC5C,MAAM,OAAO,IAAI,WAAW,OAAO,MAAM;CACzC,IAAI,IAAI;CACR,OAAO,IAAI,OAAO,QAAQ;EACxB,MAAM,IAAI,OAAO;EACjB,MAAM,OAAO,OAAO,IAAI;EACxB,IAAI,MAAM,OAAO,SAAS,KAAK;GAC7B,MAAM,MAAM,OAAO,QAAQ,MAAM,CAAC;GAClC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F,OAAO;CACT;AACF;AAEA,SAAS,eAAe,MAAyB;CAC/C,IAAI;EACF,OAAO,sBAAsB,IAAI;CACnC,SAAS,OAAO;EACd,MAAM,IAAI,WAAY,MAAgB,OAAO;CAC/C;AACF;AAEA,SAAS,QAAQ,MAAyB;CACxC,OAAO,eAAe,IAAI;AAC5B"}
1
+ {"version":3,"file":"index.js","names":["parse","parse"],"sources":["../src/rewrite.ts","../src/library.ts","../src/version.ts","../src/project.ts","../src/templates.ts","../src/init.ts","../src/add.ts","../src/build-client.ts","../src/check-deps.ts","../src/spawn.ts","../src/io.ts","../src/kv-import.ts","../src/cli.ts"],"sourcesContent":["import { dirname, posix } from 'node:path'\n\n/**\n * The framework plugins import each other by package name (`acryl-router`, `acryl-router/middleware`): inside this repository they are workspace packages. An app has\n * no such packages, only the copied source, so `acrylblends init` and `add` rewrite those specifiers to relative paths when they copy a plugin. The file each name stands\n * for is the `entries` table of the plugin's `plugin.json`.\n */\n\n/** `acryl-router/middleware` to `acryl-router/src/middleware/index.ts`: every importable name of every library plugin. */\nexport type EntryTable = ReadonlyMap<string, string>\n\nexport function entryTable(\n library: ReadonlyMap<string, { readonly entries?: Readonly<Record<string, string>> | undefined }>,\n): EntryTable {\n const table = new Map<string, string>()\n for (const [plugin, { entries }] of library)\n for (const [subpath, file] of Object.entries(entries ?? {}))\n table.set(`${plugin}${subpath}`, `${plugin}/${file}`)\n return table\n}\n\n/** For every character of a TypeScript source: 0 = code, 1 = inside a comment, 2 = inside a string or template literal. */\nfunction classify(source: string): Uint8Array {\n const kind = new Uint8Array(source.length)\n let i = 0\n while (i < source.length) {\n const c = source[i]\n const next = source[i + 1]\n if (c === '/' && next === '/') {\n const end = source.indexOf('\\n', i)\n const stop = end === -1 ? source.length : end\n kind.fill(1, i, stop)\n i = stop\n } else if (c === '/' && next === '*') {\n const end = source.indexOf('*/', i + 2)\n const stop = end === -1 ? source.length : end + 2\n kind.fill(1, i, stop)\n i = stop\n } else if (c === \"'\" || c === '\"' || c === '`') {\n let j = i + 1\n while (j < source.length && source[j] !== c) {\n if (source[j] === '\\\\') j += 1\n else if (c !== '`' && source[j] === '\\n') break\n j += 1\n }\n kind.fill(2, i, Math.min(j + 1, source.length))\n i = j + 1\n } else i += 1\n }\n return kind\n}\n\nconst SPECIFIER =\n /(\\bfrom\\s+|\\bimport\\s*\\(\\s*|\\bimport\\s+)(['\"])(acryl-[A-Za-z0-9-]+(?:\\/[A-Za-z0-9./-]+)?)\\2/gu\n\n/**\n * Rewrite the specifiers that name another library plugin to relative paths. `file` is the path of the file inside the plugins folder (for example\n * `acryl-state/src/service.ts`). Only real import and export statements are touched: a specifier named in a comment or in a string (a documentation example) is text,\n * not a dependency. Any other `acryl-*` specifier in code is an error: a library plugin may depend only on the others and on public packages.\n */\nexport function rewriteSpecifiers(source: string, file: string, entries: EntryTable): string {\n const kind = classify(source)\n return source.replace(\n SPECIFIER,\n (match, lead: string, quote: string, specifier: string, offset: number) => {\n if (kind[offset] !== 0) return match\n const target = entries.get(specifier)\n if (target === undefined)\n throw new Error(`${file}: imports \"${specifier}\", which is not a library plugin`)\n let path = posix.relative(dirname(file), target)\n if (!path.startsWith('.')) path = `./${path}`\n return `${lead}${quote}${path}${quote}`\n },\n )\n}\n","import { cpSync, existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { dirname, join, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { type EntryTable, entryTable, rewriteSpecifiers } from './rewrite'\n\n/** One entry of the plugin library: `plugins/<name>/plugin.json` in this repository. */\nexport interface LibraryPlugin {\n readonly name: string\n readonly description: string\n /** Library plugins this one imports; they are copied with it. */\n readonly requires: readonly string[]\n /** npm packages an app needs at run time for this plugin. */\n readonly dependencies: Readonly<Record<string, string>>\n /** npm packages an app needs only to develop or run this plugin's tooling (for example `electron` for the desktop shell). */\n readonly devDependencies?: Readonly<Record<string, string>>\n /** `package.json` scripts the plugin adds; a script the app already has is kept. */\n readonly scripts?: Readonly<Record<string, string>>\n /** Lines the app's `.gitignore` needs for this plugin (added when missing, if the app has a `.gitignore`). */\n readonly gitignore?: readonly string[]\n /** The port's conformance suite, a path inside the plugin: shipped in the package, but copied into an app only by `acrylblends add <plugin> --suite` (it needs vitest). */\n readonly suite?: string\n /** What other library plugins may import from this one: the import name after the plugin's own (`''`, `/middleware`) and the file it stands for. Used to rewrite `acryl-*` imports when a plugin is copied. */\n readonly entries?: Readonly<Record<string, string>>\n /** `package.json` \"imports\" entries the app gets (`#acryl-kv`): a path below the plugins folder. A plugin of your own imports the port by that name, in tests and the type-check as well as when installed live. */\n readonly imports?: Readonly<Record<string, string>>\n /** How to mount it, shown after `acrylblends add`. */\n readonly mount?: string\n /**\n * Paths inside the plugin folder that are not copied into an app (for example a React hook an app without React cannot type-check, or colocated test\n * files). A pattern is an exact path or a glob: `*` matches within one folder name, `**` across folders, `?` one character; `**` followed by a slash also matches no folder.\n */\n readonly omit?: readonly string[]\n}\n\n/** A glob as a regular expression: `*` within a name, `**` across folders, `**` plus a slash may match no folder, `?` one character. */\nfunction globToRegExp(glob: string): RegExp {\n let source = ''\n for (let i = 0; i < glob.length; i += 1) {\n const c = glob[i] as string\n if (c === '*' && glob[i + 1] === '*') {\n if (glob[i + 2] === '/') {\n source += '(?:.*/)?'\n i += 2\n } else {\n source += '.*'\n i += 1\n }\n } else if (c === '*') source += '[^/]*'\n else if (c === '?') source += '[^/]'\n else source += c.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&')\n }\n return new RegExp(`^${source}$`)\n}\n\n/** Whether a path inside a plugin folder (relative, any separator) is named by one of its `omit` patterns. */\nexport function isOmitted(inside: string, patterns: readonly string[] | undefined): boolean {\n if (!patterns || patterns.length === 0) return false\n const path = inside.split(sep).join('/')\n return patterns.some((pattern) =>\n /[*?]/.test(pattern) ? globToRegExp(pattern).test(path) : pattern === path,\n )\n}\n\n/** Files of a library plugin that stay in the repository: its manifest and its tests. */\nconst LIBRARY_ONLY = new Set(['plugin.json', 'test', 'tests'])\n\nexport class LibraryError extends Error {\n override name = 'LibraryError'\n}\n\n/** The library folder (`plugins/` at the repository root): walk up from this module, in source or in the build. */\nexport function libraryRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const candidate = join(dir, 'plugins')\n if (existsSync(join(candidate, 'instance', 'plugin.json'))) return candidate\n const parent = dirname(dir)\n if (parent === dir)\n throw new LibraryError('acrylblends cannot find its plugin library (plugins/)')\n dir = parent\n }\n}\n\n/** Every plugin in the library, by name. */\nexport function readLibrary(root: string = libraryRoot()): Map<string, LibraryPlugin> {\n const plugins = new Map<string, LibraryPlugin>()\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n const manifest = join(root, entry.name, 'plugin.json')\n if (!entry.isDirectory() || !existsSync(manifest)) continue\n const plugin = JSON.parse(readFileSync(manifest, 'utf8')) as LibraryPlugin\n if (plugin.name !== entry.name)\n throw new LibraryError(`plugins/${entry.name}/plugin.json names \"${plugin.name}\"`)\n plugins.set(plugin.name, {\n ...plugin,\n requires: plugin.requires ?? [],\n dependencies: plugin.dependencies ?? {},\n })\n }\n return plugins\n}\n\n/** The plugins to copy for `names`: each one after everything it requires, no duplicates. */\nexport function closure(\n names: readonly string[],\n library: Map<string, LibraryPlugin>,\n): LibraryPlugin[] {\n const ordered: LibraryPlugin[] = []\n const visiting = new Set<string>()\n const visit = (name: string, trail: string[]) => {\n if (ordered.some((plugin) => plugin.name === name)) return\n const plugin = library.get(name)\n if (!plugin)\n throw new LibraryError(\n `no plugin \"${name}\" in the library${trail.length ? ` (required by ${trail.at(-1)})` : ''}`,\n )\n if (visiting.has(name))\n throw new LibraryError(\n `plugins require each other in a cycle: ${[...trail, name].join(' -> ')}`,\n )\n visiting.add(name)\n for (const required of plugin.requires) visit(required, [...trail, name])\n visiting.delete(name)\n ordered.push(plugin)\n }\n for (const name of names) visit(name, [])\n return ordered\n}\n\n/** The one folder every plugin of an app lives in, library copies and the ones an agent writes. */\nexport const PLUGINS_DIR = 'plugins'\n/** Where apps made before 0.7.8 kept library copies; still understood for one release. */\nexport const LEGACY_PLUGINS_DIR = join('src', 'plugins')\n/** The list of library copies in the plugins folder; the extensions plugin installs every other folder there. */\nexport const LIBRARY_LIST = 'library.json'\n\n/** The plugins folder of an app: `plugins/`, or `src/plugins/` for an app that still has the old layout (and no `plugins/`). */\nexport function pluginsFolder(appDir: string): { dir: string; legacy: boolean } {\n const legacy =\n existsSync(join(appDir, LEGACY_PLUGINS_DIR)) && !existsSync(join(appDir, PLUGINS_DIR))\n return { dir: join(appDir, legacy ? LEGACY_PLUGINS_DIR : PLUGINS_DIR), legacy }\n}\n\n/** The warning for an app with the old layout. */\nexport const LEGACY_WARNING =\n 'warning: this app keeps its plugins in src/plugins/ (and extensions/); plugins now live in one folder, plugins/. Move them with \"git mv src/plugins plugins\", fix the paths in tsconfig.json, package.json and src/, and see docs/framework/agents/index.md. The old layout is read for this release only.'\n\nfunction recordLibraryCopy(folder: string, name: string): void {\n const file = join(folder, LIBRARY_LIST)\n const names: string[] = existsSync(file)\n ? (JSON.parse(readFileSync(file, 'utf8')) as { plugins: string[] }).plugins\n : []\n if (!names.includes(name)) names.push(name)\n writeFileSync(file, `${JSON.stringify({ plugins: names.sort() }, null, 2)}\\n`)\n}\n\n/** Copy one library plugin's source into `<app>/plugins/<name>/`. Throws when that folder already exists. */\nexport function copyPlugin(\n plugin: LibraryPlugin,\n appDir: string,\n root: string = libraryRoot(),\n): string {\n const folder = pluginsFolder(appDir)\n const target = join(folder.dir, plugin.name)\n if (existsSync(target))\n throw new LibraryError(\n `${relativeName(appDir, target)} already exists; remove it first to copy a fresh one`,\n )\n const source = join(root, plugin.name)\n // A framework package (it has a package.json in the repository) is copied as its source: `src/` and the licence; the package shipped by npm already holds only that. Its\n // `plugin.json` lists `entries`, and the imports of such a plugin are rewritten to relative paths, in the repository and in the installed package alike.\n const isPackage = existsSync(join(source, 'package.json'))\n const entries = plugin.entries === undefined ? undefined : entryTable(readLibrary(root))\n cpSync(source, target, {\n recursive: true,\n filter: (path) => {\n const inside = path\n .slice(source.length + 1)\n .split(sep)\n .join('/')\n if (\n isPackage &&\n inside !== '' &&\n inside !== 'LICENSE' &&\n inside !== 'src' &&\n !inside.startsWith('src/')\n )\n return false\n return (\n !(dirname(path) === source && LIBRARY_ONLY.has(inside)) &&\n !isOmitted(inside, plugin.omit) &&\n inside !== plugin.suite\n )\n },\n })\n if (entries) rewriteTree(join(target, 'src'), plugin.name, 'src', entries)\n if (!folder.legacy) recordLibraryCopy(folder.dir, plugin.name)\n return target\n}\n\n/** Rewrite the `acryl-*` imports of every TypeScript file below `dir` (the plugin's `src/`) to relative paths. */\nfunction rewriteTree(dir: string, plugin: string, inside: string, entries: EntryTable): void {\n for (const entry of readdirSync(dir)) {\n const path = join(dir, entry)\n if (statSync(path).isDirectory()) rewriteTree(path, plugin, `${inside}/${entry}`, entries)\n else if (/\\.(?:ts|tsx|mts)$/u.test(entry))\n writeFileSync(\n path,\n rewriteSpecifiers(readFileSync(path, 'utf8'), `${plugin}/${inside}/${entry}`, entries),\n )\n }\n}\n\n/** Copy one file of a library plugin (a conformance suite) with its `acryl-*` imports rewritten, as `copyPlugin` does for the rest. */\nexport function copyRewritten(\n from: string,\n to: string,\n plugin: string,\n inside: string,\n root: string = libraryRoot(),\n): void {\n writeFileSync(\n to,\n rewriteSpecifiers(\n readFileSync(from, 'utf8'),\n `${plugin}/${inside}`,\n entryTable(readLibrary(root)),\n ),\n )\n}\n\nconst relativeName = (appDir: string, path: string) =>\n path\n .slice(appDir.length + 1)\n .split(sep)\n .join('/')\n","import { createRequire } from 'node:module'\n\n/** The version of this package. */\nexport const VERSION: string = (\n createRequire(import.meta.url)('../package.json') as { version: string }\n).version\n","import {\n cpSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { join } from 'node:path'\nimport { VERSION } from './version'\n\n/** Thrown when the target directory exists and is not empty. Nothing has been written. */\nexport class TargetNotEmptyError extends Error {\n constructor(readonly target: string) {\n super(\n `refusing to write into \"${target}\": the directory is not empty. Choose an empty or new directory.`,\n )\n this.name = 'TargetNotEmptyError'\n }\n}\n\n/** A project name npm accepts: lower case letters, digits and dashes, starting with a letter. */\nexport function isValidName(name: string): boolean {\n return /^[a-z][a-z0-9-]*$/.test(name) && name.length <= 214\n}\n\n/** A valid default project name derived from a directory path. */\nexport function nameFrom(directory: string): string {\n const base = directory.split(/[\\\\/]/).filter(Boolean).pop() ?? ''\n const cleaned = base\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, '-')\n .replace(/^[^a-z]+/, '')\n .replace(/-+$/, '')\n return cleaned || 'my-app'\n}\n\n/** Refuse a target that exists and is not an empty directory. A missing target is fine: it is created. */\nexport function assertTargetFree(target: string): void {\n if (!existsSync(target)) return\n if (!statSync(target).isDirectory() || readdirSync(target).length > 0)\n throw new TargetNotEmptyError(target)\n}\n\n/**\n * Copy a template into `target`, replacing `__APP_NAME__` with `name` and `__ACRYLBLENDS_RANGE__` with the range of this release. Checks the target before writing anything.\n *\n * @returns the copied files, relative to `target`\n */\nexport function copyTemplate(source: string, target: string, name: string): string[] {\n assertTargetFree(target)\n mkdirSync(target, { recursive: true })\n const written: string[] = []\n const walk = (from: string, to: string, prefix: string) => {\n for (const entry of readdirSync(from, { withFileTypes: true })) {\n if (\n entry.name === 'node_modules' ||\n (prefix === '' &&\n (entry.name === TEMPLATE_MANIFEST ||\n entry.name === 'upstream.json' ||\n entry.name === 'AGENTS.md'))\n )\n continue\n const sourcePath = join(from, entry.name)\n // npm and git treat a file named .gitignore specially, so templates keep it as `gitignore` (and `dockerignore`).\n const targetName =\n prefix === '' && (entry.name === 'gitignore' || entry.name === 'dockerignore')\n ? `.${entry.name}`\n : entry.name\n const targetPath = join(to, targetName)\n if (entry.isDirectory()) {\n mkdirSync(targetPath, { recursive: true })\n walk(sourcePath, targetPath, `${prefix}${entry.name}/`)\n continue\n }\n const text = readFileSync(sourcePath, 'utf8')\n if (text.includes('__APP_NAME__') || text.includes('__ACRYLBLENDS_RANGE__'))\n writeFileSync(\n targetPath,\n text.replaceAll('__APP_NAME__', name).replaceAll('__ACRYLBLENDS_RANGE__', `^${VERSION}`),\n )\n else cpSync(sourcePath, targetPath)\n written.push(`${prefix}${targetName}`)\n }\n }\n walk(source, target, '')\n return written\n}\n\n/** A template's own manifest, `template.json`: the library plugins it is built from. Never copied (nor is `upstream.json`, the record of what was synced from ACRYL, nor the template's `AGENTS.md`, which `writeAgentFiles` joins to the shared core). */\nexport const TEMPLATE_MANIFEST = 'template.json'\n\n/** The address a template's desktop window opens on, when it is not the root (`template.json`: `desktopPath`). */\nexport function readTemplateDesktopPath(templateDir: string): string | undefined {\n const file = join(templateDir, TEMPLATE_MANIFEST)\n if (!existsSync(file)) return undefined\n return (JSON.parse(readFileSync(file, 'utf8')) as { desktopPath?: string }).desktopPath\n}\n\n/** Record where the desktop window opens in package.json (`acrylblends.desktopPath`), read by `plugins/desktop/main.ts`. */\nexport function writeDesktopPath(appDir: string, path: string): void {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n acrylblends?: Record<string, unknown>\n }\n manifest.acrylblends = { ...manifest.acrylblends, desktopPath: path }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\nexport function readTemplatePlugins(templateDir: string): string[] {\n const file = join(templateDir, TEMPLATE_MANIFEST)\n if (!existsSync(file)) return []\n const { plugins } = JSON.parse(readFileSync(file, 'utf8')) as { plugins?: string[] }\n return plugins ?? []\n}\n\n/** Add run-time dependencies to an app's package.json, keeping what is there and sorting the keys. Returns the names added. */\nexport function mergeDependencies(\n appDir: string,\n dependencies: Readonly<Record<string, string>>,\n): string[] {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n dependencies?: Record<string, string>\n }\n const current = manifest.dependencies ?? {}\n const added = Object.keys(dependencies).filter((name) => !(name in current))\n const merged = { ...dependencies, ...current }\n manifest.dependencies = Object.fromEntries(\n Object.entries(merged).sort(([a], [b]) => a.localeCompare(b)),\n )\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n return added\n}\n\n/** Add `package.json` \"imports\" entries (`#acryl-kv`: `./plugins/acryl-kv/src/index.ts`); an entry the app already has is kept. Returns the names added. */\nexport function mergeImports(\n appDir: string,\n imports: Readonly<Record<string, string>>,\n pluginsDir: string,\n): string[] {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as { imports?: Record<string, string> }\n const current = manifest.imports ?? {}\n const added = Object.keys(imports).filter((name) => !(name in current))\n manifest.imports = {\n ...Object.fromEntries(\n Object.entries(imports).map(([name, path]) => [name, `./${pluginsDir}/${path}`]),\n ),\n ...current,\n }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n return added\n}\n\n/** Declare a file as an opener in package.json (`\"acryl\": { \"opener\": [...] }`): the one place that may import a database provider. */\nexport function mergeOpener(appDir: string, opener: string): void {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n acryl?: { opener?: string | string[] }\n }\n const current = manifest.acryl?.opener\n const list = typeof current === 'string' ? [current] : (current ?? [])\n if (list.includes(opener)) return\n manifest.acryl = { ...manifest.acryl, opener: [...list, opener] }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\n/**\n * Add a plugin's development dependencies and scripts to an app's package.json: nothing the app already has is replaced. Returns the names of the development dependencies\n * and scripts added.\n */\nexport function mergeTooling(\n appDir: string,\n tooling: {\n devDependencies?: Readonly<Record<string, string>> | undefined\n scripts?: Readonly<Record<string, string>> | undefined\n },\n): { devDependencies: string[]; scripts: string[] } {\n const file = join(appDir, 'package.json')\n const manifest = JSON.parse(readFileSync(file, 'utf8')) as {\n devDependencies?: Record<string, string>\n scripts?: Record<string, string>\n }\n const dev = manifest.devDependencies ?? {}\n const scripts = manifest.scripts ?? {}\n const addedDev = Object.keys(tooling.devDependencies ?? {}).filter((name) => !(name in dev))\n const addedScripts = Object.keys(tooling.scripts ?? {}).filter((name) => !(name in scripts))\n manifest.devDependencies = Object.fromEntries(\n Object.entries({ ...tooling.devDependencies, ...dev }).sort(([a], [b]) => a.localeCompare(b)),\n )\n manifest.scripts = { ...tooling.scripts, ...scripts }\n writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\\n`)\n return { devDependencies: addedDev, scripts: addedScripts }\n}\n\n/** Add the lines a plugin needs to the app's `.gitignore` when it has one and they are missing. Returns the lines added. */\nexport function appendGitignore(appDir: string, lines: readonly string[] | undefined): string[] {\n const file = join(appDir, '.gitignore')\n if (!lines || lines.length === 0 || !existsSync(file)) return []\n const current = readFileSync(file, 'utf8')\n const present = new Set(current.split('\\n').map((line) => line.trim()))\n const missing = lines.filter((line) => !present.has(line))\n if (missing.length > 0)\n writeFileSync(\n file,\n `${current}${current.endsWith('\\n') || current === '' ? '' : '\\n'}${missing.join('\\n')}\\n`,\n )\n return missing\n}\n\n/** The generated app's guide for a coding agent: the shared core, then the template's own part. `CLAUDE.md` is only an import of it. */\nexport function writeAgentFiles(\n sharedDir: string,\n templateDir: string,\n target: string,\n name: string,\n): string[] {\n const core = readFileSync(join(sharedDir, 'AGENTS.core.md'), 'utf8')\n const own = existsSync(join(templateDir, 'AGENTS.md'))\n ? readFileSync(join(templateDir, 'AGENTS.md'), 'utf8')\n : ''\n const defaults = readFileSync(join(sharedDir, 'DEFAULTS.md'), 'utf8')\n const text = `${core}${defaults}${own}`.replaceAll('__APP_NAME__', name)\n // AGENTS.md and CLAUDE.md are the same text; the one skill is written where each kind of agent looks for skills.\n writeFileSync(join(target, 'AGENTS.md'), text)\n writeFileSync(join(target, 'CLAUDE.md'), text)\n const skill = readFileSync(join(sharedDir, 'SKILL.md'), 'utf8').replaceAll('__APP_NAME__', name)\n const written = ['AGENTS.md', 'CLAUDE.md']\n for (const folder of ['.claude/skills/app-guide', '.agents/skills/app-guide']) {\n mkdirSync(join(target, folder), { recursive: true })\n writeFileSync(join(target, folder, 'SKILL.md'), skill)\n written.push(`${folder}/SKILL.md`)\n }\n return written\n}\n\n/**\n * Copy the framework's docs (a generated copy of ACRYL's `docs/framework`, already checked against its digest) into `<app>/docs/framework/`,\n * so a coding agent working in the app reads the API from the folder it is in. The generated-copy notes and the digest record stay behind.\n *\n * @returns the copied files, relative to `target`\n */\nexport function copyFrameworkDocs(source: string, target: string): string[] {\n const written: string[] = []\n const walk = (from: string, to: string, prefix: string) => {\n for (const entry of readdirSync(from, { withFileTypes: true })) {\n if (entry.name === 'upstream.json' || entry.name === 'UPSTREAM.md') continue\n const sourcePath = join(from, entry.name)\n const targetPath = join(to, entry.name)\n if (entry.isDirectory()) {\n mkdirSync(targetPath, { recursive: true })\n walk(sourcePath, targetPath, `${prefix}${entry.name}/`)\n continue\n }\n cpSync(sourcePath, targetPath)\n written.push(`docs/framework/${prefix}${entry.name}`)\n }\n }\n mkdirSync(join(target, 'docs', 'framework'), { recursive: true })\n walk(source, join(target, 'docs', 'framework'), '')\n return written\n}\n","import { existsSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/** The templates, all Cordis apps: a web app with a page and a client component (nodejs), a notes app and a chat app on the db port (notes, chat), a blank app on the router, a todo list on the router and state, and the blank app with the offline agent. */\nexport const TEMPLATES = ['nodejs', 'notes', 'chat', 'blank', 'todo', 'agent'] as const\nexport type Template = (typeof TEMPLATES)[number]\n\nexport function isTemplate(value: string): value is Template {\n return (TEMPLATES as readonly string[]).includes(value)\n}\n\n/**\n * The `templates/` folder of this package. The module sits at different depths in source (`src/`) and in the build\n * (`dist/`), so walk up until a `templates` folder holds the `blank` template.\n */\nexport function templatesRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const candidate = join(dir, 'templates')\n if (existsSync(join(candidate, 'blank'))) return candidate\n const parent = dirname(dir)\n if (parent === dir) throw new Error('acrylblends cannot find its templates folder')\n dir = parent\n }\n}\n\n/** Absolute path of a template folder. */\nexport function templateDir(template: Template): string {\n return join(templatesRoot(), template)\n}\n\n/** The text every generated app's `AGENTS.md` starts with (`shared/`, beside `templates/`). */\nexport function sharedDir(): string {\n return join(dirname(templatesRoot()), 'shared')\n}\n\n/**\n * The framework's docs, as ACRYL wrote them: `docs/framework` of the repository, or the copy `prepack` puts inside the package. The module sits at\n * different depths in source and in the build, so walk up until a `docs/framework` folder holds the README.\n */\nexport function frameworkDocsRoot(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const candidate = join(dir, 'docs', 'framework')\n if (existsSync(join(candidate, 'README.md'))) return candidate\n const parent = dirname(dir)\n if (parent === dir)\n throw new Error('acrylblends cannot find the framework docs (docs/framework)')\n dir = parent\n }\n}\n","import { resolve } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport type { Io } from './io'\nimport { closure, copyPlugin, readLibrary } from './library'\nimport {\n copyFrameworkDocs,\n copyTemplate,\n isValidName,\n mergeDependencies,\n mergeImports,\n mergeTooling,\n nameFrom,\n readTemplateDesktopPath,\n readTemplatePlugins,\n TargetNotEmptyError,\n writeAgentFiles,\n writeDesktopPath,\n} from './project'\nimport {\n frameworkDocsRoot,\n isTemplate,\n sharedDir,\n TEMPLATES,\n type Template,\n templateDir,\n} from './templates'\n\n/** A command line mistake. The CLI prints it with the help text and exits 2. */\nexport class UsageError extends Error {\n override name = 'UsageError'\n}\n\n/** What `init` was asked for. Anything left undefined is asked for on a terminal, or defaulted. */\nexport interface InitOptions {\n directory: string | undefined\n name: string | undefined\n template: Template | undefined\n install: boolean | undefined\n /** Also add the desktop shell (`add desktop`): an Electron window on the app's own server. */\n desktop: boolean\n yes: boolean\n}\n\n/** Parse `init [dir] [--template t] [--agent|--no-agent] [--name n] [--install] [-y]`. `--agent` means `--template agent`, `--no-agent` means `--template blank`. */\nexport function parseInitOptions(argv: readonly string[]): InitOptions {\n let parsed: ReturnType<typeof parse>\n try {\n parsed = parse(argv)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n const { values, positionals } = parsed\n if (positionals.length > 1) throw new UsageError('init takes at most one directory')\n if (values.agent && values['no-agent'])\n throw new UsageError('use --agent or --no-agent, not both')\n if (values.template !== undefined && !isTemplate(values.template))\n throw new UsageError(`unknown template \"${values.template}\" (${TEMPLATES.join(', ')})`)\n const alias: Template | undefined = values.agent\n ? 'agent'\n : values['no-agent']\n ? 'blank'\n : undefined\n if (values.template !== undefined && alias !== undefined && values.template !== alias)\n throw new UsageError(\n `--template ${values.template} contradicts --${alias === 'agent' ? 'agent' : 'no-agent'}`,\n )\n return {\n directory: positionals[0],\n name: values.name,\n template: (values.template as Template | undefined) ?? alias,\n install: values.install,\n desktop: values.desktop === true,\n yes: values.yes === true,\n }\n}\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n name: { type: 'string' },\n template: { type: 'string' },\n agent: { type: 'boolean' },\n 'no-agent': { type: 'boolean' },\n install: { type: 'boolean' },\n desktop: { type: 'boolean' },\n yes: { type: 'boolean', short: 'y' },\n },\n })\n\nconst yes = (answer: string) => ['y', 'yes'].includes(answer.trim().toLowerCase())\n\nasync function askTemplate(ask: (question: string) => Promise<string>): Promise<Template> {\n const answer = (await ask(`Template (${TEMPLATES.join(', ')}) [blank]: `)).trim().toLowerCase()\n if (answer === '') return 'blank'\n if (isTemplate(answer)) return answer\n throw new UsageError(`unknown template \"${answer}\" (${TEMPLATES.join(', ')})`)\n}\n\n/** Scaffold a Cordis app. Returns the exit code: 0 done, 1 refused or failed. Never overwrites anything. */\nexport async function init(options: InitOptions, io: Io): Promise<number> {\n const relative = options.directory ?? '.'\n const directory = resolve(io.cwd, relative)\n const ask = options.yes ? undefined : io.ask\n\n let name = options.name ?? nameFrom(directory)\n if (options.name === undefined && ask)\n name = (await ask(`Project name (${name}): `)).trim() || name\n if (!isValidName(name)) {\n throw new UsageError(\n `\"${name}\" is not a valid project name (lower case letters, digits and dashes, starting with a letter)`,\n )\n }\n const template = options.template ?? (ask ? await askTemplate(ask) : 'blank')\n const install =\n options.install ?? (ask ? yes(await ask('Install dependencies with npm now? (y/N): ')) : false)\n\n let files: string[]\n try {\n files = copyTemplate(templateDir(template), directory, name)\n files.push(...writeAgentFiles(sharedDir(), templateDir(template), directory, name))\n files.push(...copyFrameworkDocs(frameworkDocsRoot(), directory))\n } catch (error) {\n if (!(error instanceof TargetNotEmptyError)) throw error\n io.stderr.write(`error: ${error.message}\\n`)\n return 1\n }\n const plugins = closure(\n [...readTemplatePlugins(templateDir(template)), ...(options.desktop ? ['desktop'] : [])],\n readLibrary(),\n )\n for (const plugin of plugins) {\n copyPlugin(plugin, directory)\n if (plugin.imports) mergeImports(directory, plugin.imports, 'plugins')\n mergeDependencies(directory, plugin.dependencies)\n mergeTooling(directory, plugin)\n }\n const desktopPath = options.desktop ? readTemplateDesktopPath(templateDir(template)) : undefined\n if (desktopPath !== undefined) writeDesktopPath(directory, desktopPath)\n io.stdout.write(\n `created ${name} (${template}) in ${directory}: ${files.length} files, plugins ${plugins.map((plugin) => plugin.name).join(', ')}\\n`,\n )\n\n if (install && (await io.install(directory)) !== 0) {\n io.stderr.write('error: npm install failed; run it yourself in the new directory\\n')\n return 1\n }\n const steps = [\n relative === '.' ? '' : ` cd ${relative}\\n`,\n install ? '' : ' npm install\\n',\n ' npm run dev\\n npm test\\n',\n ]\n io.stdout.write(`\\nNext:\\n${steps.join('')}`)\n return 0\n}\n","import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, dirname, join, relative, resolve, sep } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport { UsageError } from './init'\nimport type { Io } from './io'\nimport {\n closure,\n copyPlugin,\n copyRewritten,\n LEGACY_WARNING,\n type LibraryPlugin,\n libraryRoot,\n PLUGINS_DIR,\n pluginsFolder,\n readLibrary,\n} from './library'\nimport {\n appendGitignore,\n mergeDependencies,\n mergeImports,\n mergeOpener,\n mergeTooling,\n} from './project'\n\nexport interface AddOptions {\n readonly names: readonly string[]\n readonly directory: string | undefined\n /** Also copy the port's conformance suite (`src/conformance.ts`) and the `vitest` it runs on: what a provider of your own must pass. */\n readonly suite: boolean\n}\n\n/** Parse `add <plugin...> [--dir <app>] [--suite]`. */\nexport function parseAddOptions(argv: readonly string[]): AddOptions {\n let parsed: ReturnType<typeof parse>\n try {\n parsed = parse(argv)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n if (parsed.positionals.length === 0)\n throw new UsageError('add needs at least one plugin name (see \"acrylblends plugins\")')\n return {\n names: parsed.positionals,\n directory: parsed.values.dir,\n suite: parsed.values.suite === true,\n }\n}\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: { dir: { type: 'string' }, suite: { type: 'boolean' } },\n })\n\nconst present = (appDir: string, name: string) => existsSync(join(pluginsFolder(appDir).dir, name))\n\n/**\n * Copy library plugins into an existing app, with the plugins they require, and add their npm packages to its package.json.\n * Refuses a plugin the app already has. Returns the exit code.\n */\nexport async function add(options: AddOptions, io: Io): Promise<number> {\n const appDir = resolve(io.cwd, options.directory ?? '.')\n if (!existsSync(join(appDir, 'package.json')) || !existsSync(join(appDir, 'src'))) {\n io.stderr.write(\n `error: ${appDir} is not an app (no package.json and src/); run \"acrylblends init\" first\\n`,\n )\n return 1\n }\n if (pluginsFolder(appDir).legacy) io.stderr.write(`${LEGACY_WARNING}\\n`)\n // A path is an external plugin folder; anything else is a library plugin name.\n const external = options.names.filter((name) => /[\\\\/]/.test(name) || name.startsWith('.'))\n for (const folder of external) {\n const code = addExternal(resolve(io.cwd, folder), appDir, io)\n if (code !== 0) return code\n }\n // The desktop shell has two forms: the Blend app (it needs the `instance` plugin) and a plain Acryl app (`export default app`); `desktop` means the one that fits.\n const plain = !existsSync(join(pluginsFolder(appDir).dir, 'instance'))\n if (plain && options.names.includes('db')) {\n io.stderr.write(\n 'error: \"db\" is the Cordis plugin for a Blend app. A plain Acryl app opens its database with openDb from \"acrylblends/db/sqlite\" (see docs/framework/guides/data.md)\\n',\n )\n return 1\n }\n if (plain && options.names.includes('kv')) {\n io.stderr.write(\n 'error: \"kv\" is the Cordis plugin for a Blend app. A plain Acryl app opens its store with openKv from \"acrylblends/kv/json\" (see docs/framework/guides/data.md#a-tiny-app-kv)\\n',\n )\n return 1\n }\n const names = options.names\n .filter((name) => !external.includes(name))\n // `db` is the SQLite provider of the db port (it brings the port); a plain app opens its database with `acrylblends/db/sqlite` instead.\n .map((name) => (name === 'db' ? 'acryl-db-sqlite' : name))\n // `kv` is the JSON-file provider of the kv port (it brings the port); `acryl-kv-db` is the one over db.\n .map((name) => (name === 'kv' ? 'acryl-kv-json' : name))\n .map((name) => (name === 'desktop' && plain ? 'desktop-web' : name))\n if (names.length === 0) return 0\n const already = options.suite ? [] : names.filter((name) => present(appDir, name))\n if (already.length > 0) {\n io.stderr.write(\n `error: the app already has ${already\n .map(\n (name) =>\n `${relative(appDir, join(pluginsFolder(appDir).dir, name))\n .split(sep)\n .join('/')}`,\n )\n .join(', ')}\\n`,\n )\n return 1\n }\n const toCopy: LibraryPlugin[] = closure(names, readLibrary()).filter(\n (plugin) => !present(appDir, plugin.name),\n )\n const addedDependencies: string[] = []\n for (const plugin of toCopy) {\n copyPlugin(plugin, appDir)\n if (plugin.imports)\n mergeImports(\n appDir,\n plugin.imports,\n relative(appDir, pluginsFolder(appDir).dir).split(sep).join('/'),\n )\n addedDependencies.push(...mergeDependencies(appDir, plugin.dependencies))\n const tooling = mergeTooling(appDir, plugin)\n appendGitignore(appDir, plugin.gitignore)\n // The provider is mounted from src/app.ts, which is therefore the one file that may import it (`acrylblends check-deps`).\n if (plugin.name === 'acryl-db-sqlite') mergeOpener(appDir, 'src/app.ts')\n addedDependencies.push(...tooling.devDependencies)\n if (tooling.scripts.length > 0)\n io.stdout.write(\n `new scripts: ${tooling.scripts.map((name) => `npm run ${name}`).join(', ')}\\n`,\n )\n }\n if (options.suite) {\n const refused = copySuites(names, appDir, addedDependencies, io)\n if (refused !== 0) return refused\n }\n io.stdout.write(`added ${toCopy.map((plugin) => plugin.name).join(', ')} to ${appDir}\\n`)\n if (addedDependencies.length > 0)\n io.stdout.write(`new dependencies: ${addedDependencies.join(', ')} (run npm install)\\n`)\n for (const plugin of toCopy.filter((plugin) => names.includes(plugin.name))) {\n io.stdout.write(\n `\\n${plugin.name}: ${plugin.mount ?? `import it from '../plugins/${plugin.name}/index.ts' and mount it in src/app.ts`}\\n`,\n )\n }\n return 0\n}\n\n/**\n * The vitest the suites run on. 3.2.x, not the newest: npm 10 (the npm of Node 22) crashes on the dependency tree of vitest 4 and 5 (\"Cannot read properties of null (reading\n * 'edgesOut')\"), and the suites use only `describe`, `it` and `expect`, which are the same in all of them. An app on a newer npm may raise it.\n */\nconst SUITE_RUNNER = { vitest: '3.2.4' }\n\n/**\n * Copy the conformance suite of each named port next to its source (`plugins/<name>/src/conformance.ts`), and add `vitest` to the app's development\n * dependencies. The suite is left out of a normal copy because an app that only uses a port has no use for it. Returns the exit code: 1 when a plugin has none.\n */\nfunction copySuites(names: readonly string[], appDir: string, added: string[], io: Io): number {\n const copies: Array<{ from: string; to: string }> = []\n // The suite belongs to the port: `add kv --suite` (acryl-kv-json, or acryl-kv-db) brings the suite of acryl-kv.\n const ports = [\n ...new Set(names.map((name) => name.replace(/^(acryl-(?:kv|db))(?:-.*)?$/u, '$1'))),\n ]\n const library = readLibrary()\n for (const name of ports) {\n const suite = library.get(name)?.suite\n const from = suite === undefined ? '' : join(libraryRoot(), name, suite)\n if (suite === undefined || !existsSync(from)) {\n io.stderr.write(`error: ${name} has no conformance suite (the ports db and kv do)\\n`)\n return 1\n }\n copies.push({ from, to: join(pluginsFolder(appDir).dir, name, suite) })\n }\n for (const { from, to } of copies) {\n mkdirSync(dirname(to), { recursive: true })\n copyRewritten(from, to, pluginOf(to), suiteOf(to))\n io.stdout.write(`added the conformance suite ${relative(appDir, to).split(sep).join('/')}\\n`)\n }\n added.push(...mergeTooling(appDir, { devDependencies: SUITE_RUNNER }).devDependencies)\n return 0\n}\n\n/** The plugin folder name and the file inside it, from a path below the plugins folder (`.../plugins/acryl-kv/src/conformance.ts`). */\nconst pluginOf = (path: string): string => path.split(sep).slice(-3, -2)[0] ?? ''\nconst suiteOf = (path: string): string => path.split(sep).slice(-2).join('/')\n\nconst PLUGIN_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/\n\n/**\n * Bring an external plugin folder (a package made with the builder's package_plugin, or any folder with an index.ts that exports a\n * Cordis plugin) into the app's `plugins/`, where the extensions plugin installs it like any other: checked, staged, started,\n * verified. Its runtime dependencies are not installed here; they are reported so the user adds them deliberately.\n */\nfunction addExternal(folder: string, appDir: string, io: Io): number {\n if (!existsSync(folder) || !statSync(folder).isDirectory()) {\n io.stderr.write(`error: ${folder} is not a folder\\n`)\n return 1\n }\n if (!['index.ts', 'index.js', 'index.mjs'].some((entry) => existsSync(join(folder, entry)))) {\n io.stderr.write(`error: ${folder} has no index.ts that exports a Cordis plugin\\n`)\n return 1\n }\n const manifestFile = join(folder, 'package.json')\n const manifest = existsSync(manifestFile)\n ? (JSON.parse(readFileSync(manifestFile, 'utf8')) as {\n name?: string\n dependencies?: Record<string, string>\n })\n : {}\n const name = (manifest.name ?? basename(folder)).replace(/^@[^/]+\\//, '')\n if (!PLUGIN_NAME.test(name)) {\n io.stderr.write(\n `error: \"${name}\" is not a plugin name (lowercase letters, digits and dashes)\\n`,\n )\n return 1\n }\n const target = join(\n pluginsFolder(appDir).legacy ? join(appDir, 'extensions') : join(appDir, PLUGINS_DIR),\n name,\n )\n if (existsSync(target)) {\n io.stderr.write(`error: the app already has ${relative(appDir, target).split(sep).join('/')}\\n`)\n return 1\n }\n cpSync(folder, target, {\n recursive: true,\n filter: (path) => !/[\\\\/](node_modules|\\.git)([\\\\/]|$)/.test(path.slice(folder.length)),\n })\n io.stdout.write(\n `added external plugin ${name} to ${dirname(target)}; it installs at the next start\\n`,\n )\n const dependencies = Object.keys(manifest.dependencies ?? {})\n if (dependencies.length > 0)\n io.stdout.write(\n `it uses ${dependencies.join(', ')}: add them to the app with npm install first\\n`,\n )\n return 0\n}\n\n/** `acrylblends plugins`: the library, one line per plugin. */\nexport function listPlugins(io: Io): number {\n for (const plugin of readLibrary().values()) {\n const requires = plugin.requires.length > 0 ? ` (requires ${plugin.requires.join(', ')})` : ''\n io.stdout.write(`${plugin.name.padEnd(12)} ${plugin.description}${requires}\\n`)\n }\n return 0\n}\n","import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { relative, resolve } from 'node:path'\nimport { UsageError } from './init'\nimport type { Io } from './io'\n\n/** Parse `build-client [root] [outDir]`. */\nexport function parseBuildClientOptions(argv: readonly string[]): { root: string; outDir: string } {\n const args = argv.filter((a) => !a.startsWith('-'))\n if (args.length !== argv.length)\n throw new UsageError('build-client takes [root] [outDir] and no options')\n if (args.length > 2)\n throw new UsageError('build-client takes at most two arguments: [root] [outDir]')\n return { root: args[0] ?? 'src/client', outDir: args[1] ?? 'dist/client' }\n}\n\n/**\n * Compile the app's client modules once (`buildClientModules` of the framework), for a production install that has no compiler at run time.\n * The framework is the one installed in the app (so the compiled files match the server that serves them), else this package's own.\n */\nexport async function buildClient(\n options: { root: string; outDir: string },\n io: Io,\n): Promise<number> {\n const root = resolve(io.cwd, options.root)\n if (!existsSync(root)) {\n io.stderr.write(\n `error: ${root} does not exist; the client modules live in src/client by default\\n`,\n )\n return 1\n }\n const outDir = resolve(io.cwd, options.outDir)\n const here = createRequire(resolve(io.cwd, 'package.json'))\n let specifier = 'acrylblends/node-server'\n try {\n here.resolve(specifier)\n } catch {\n specifier = new URL('../lib/node-server.js', import.meta.url).href\n }\n const mod = (await import(\n specifier.startsWith('file:') ? specifier : here.resolve(specifier)\n )) as typeof import('../lib/node-server')\n const written = mod.buildClientModules({ root, outDir })\n for (const file of written) io.stdout.write(`${relative(io.cwd, resolve(outDir, file))}\\n`)\n io.stdout.write(`built ${written.length} files in ${relative(io.cwd, outDir) || '.'}\\n`)\n return 0\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join, relative, resolve, sep } from 'node:path'\nimport type { Io } from './io'\n\n/**\n * The dependency rule (spec 049): app code imports a port, never a provider. A port is `acrylblends/db` (the `Db` type); a provider is a\n * driver or the one function that opens a database. Only the opener, a file the app names once in package.json, may import a provider.\n */\n\n/** A package that is a database driver. An import of it, or of anything below it, is a provider import. */\nconst DRIVERS = [\n 'node:sqlite',\n 'sqlite',\n 'sqlite3',\n 'better-sqlite3',\n '@libsql/client',\n 'libsql',\n 'pg',\n 'pg-pool',\n 'pg-native',\n 'postgres',\n '@electric-sql/pglite',\n '@neondatabase/serverless',\n '@vercel/postgres',\n 'mysql',\n 'mysql2',\n]\n/** The openers a provider ships: importing one of them is opening a database. */\nconst OPENERS = ['acrylblends/db/sqlite', 'acryl-db-sqlite']\n/** The desktop shell is where Electron lives (`acrylblends add desktop` copies it). */\nconst ELECTRON = 'electron'\nconst ELECTRON_HOMES = [\n 'plugins/desktop/',\n 'plugins/desktop-web/',\n 'src/plugins/desktop/',\n 'src/plugins/desktop-web/',\n]\n/** The provider plugins themselves may import what they wrap. */\nconst PROVIDER_HOMES = ['plugins/acryl-db-sqlite/', 'src/plugins/acryl-db-sqlite/']\n\nconst SOURCE = /\\.(?:[cm]?[jt]s|[jt]sx)$/u\nconst SKIP_DIRS = new Set(['node_modules', 'dist', 'lib', 'build', 'coverage'])\nconst ROOTS = ['src', 'test', 'tests', 'plugins', 'extensions']\n\nexport interface Violation {\n readonly file: string\n readonly line: number\n readonly specifier: string\n readonly kind: 'driver' | 'opener' | 'electron'\n}\n\nconst matches = (specifier: string, name: string): boolean =>\n specifier === name || specifier.startsWith(`${name}/`)\n\n/** What a specifier is to the rule, or undefined when it is not a provider. */\nexport function classifySpecifier(specifier: string): Violation['kind'] | undefined {\n if (DRIVERS.some((name) => matches(specifier, name))) return 'driver'\n if (OPENERS.some((name) => matches(specifier, name))) return 'opener'\n if (matches(specifier, ELECTRON)) return 'electron'\n return undefined\n}\n\n/** The source with every comment replaced by spaces (newlines kept), so a line number still means what it did and a commented import is not an import. */\nexport function blankComments(source: string): string {\n let out = ''\n let i = 0\n while (i < source.length) {\n const c = source[i] as string\n const next = source[i + 1]\n if (c === '/' && next === '/') {\n const end = source.indexOf('\\n', i)\n const stop = end === -1 ? source.length : end\n out += ' '.repeat(stop - i)\n i = stop\n } else if (c === '/' && next === '*') {\n const end = source.indexOf('*/', i + 2)\n const stop = end === -1 ? source.length : end + 2\n out += source.slice(i, stop).replace(/[^\\n]/gu, ' ')\n i = stop\n } else if (c === \"'\" || c === '\"' || c === '`') {\n let j = i + 1\n while (j < source.length && source[j] !== c) {\n if (source[j] === '\\\\') j += 1\n else if (c !== '`' && source[j] === '\\n') break\n j += 1\n }\n out += source.slice(i, Math.min(j + 1, source.length))\n i = j + 1\n } else {\n out += c\n i += 1\n }\n }\n return out\n}\n\n/** `import x from 'a'`, `export * from 'a'`, `import 'a'`, `import('a')` and `require('a')`, with the line of each. */\nconst IMPORT =\n /(?:^|[\\s;{}()])(?:import\\s*(?:type\\s+)?(?:[\\w*${},\\s]*?\\s*from\\s*)?|export\\s*(?:type\\s+)?[\\w*${},\\s]*?\\s*from\\s*|import\\s*\\(\\s*|require\\s*\\(\\s*)(['\"])([^'\"\\n]+)\\1/gu\n\nexport function importsOf(source: string): { specifier: string; line: number }[] {\n const code = blankComments(source)\n const found: { specifier: string; line: number }[] = []\n for (const match of code.matchAll(IMPORT)) {\n const specifier = match[2] as string\n const at = (match.index ?? 0) + match[0].length - specifier.length - 2\n found.push({ specifier, line: code.slice(0, at).split('\\n').length })\n }\n return found\n}\n\nfunction listSources(dir: string, out: string[] = []): string[] {\n if (!existsSync(dir)) return out\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name)) continue\n const path = join(dir, entry.name)\n if (entry.isDirectory()) listSources(path, out)\n else if (SOURCE.test(entry.name) && !entry.name.endsWith('.d.ts')) out.push(path)\n }\n return out\n}\n\n/** The opener files the app declares: `\"acryl\": { \"opener\": \"src/db.ts\" }` (or a list) in package.json. */\nexport function openersOf(appDir: string): string[] {\n const file = join(appDir, 'package.json')\n if (!existsSync(file)) return []\n const declared = (JSON.parse(readFileSync(file, 'utf8')) as { acryl?: { opener?: unknown } })\n .acryl?.opener\n const list = typeof declared === 'string' ? [declared] : Array.isArray(declared) ? declared : []\n return list.filter((entry): entry is string => typeof entry === 'string')\n}\n\n/** Every provider import outside the declared opener (and the homes that may hold one), in file and line order. */\nexport function findViolations(appDir: string): Violation[] {\n const openers = new Set(openersOf(appDir).map((entry) => entry.split(sep).join('/')))\n const violations: Violation[] = []\n for (const root of ROOTS) {\n for (const path of listSources(join(appDir, root)).sort()) {\n const file = relative(appDir, path).split(sep).join('/')\n if (openers.has(file)) continue\n for (const { specifier, line } of importsOf(readFileSync(path, 'utf8'))) {\n const kind = classifySpecifier(specifier)\n if (kind === undefined) continue\n if (kind === 'electron' && ELECTRON_HOMES.some((home) => file.startsWith(home))) continue\n if (kind !== 'electron' && PROVIDER_HOMES.some((home) => file.startsWith(home))) continue\n violations.push({ file, line, specifier, kind })\n }\n }\n }\n return violations\n}\n\nconst GUIDE = 'docs/framework/guides/data.md#why-the-database-is-opened-in-one-place'\n\nfunction advice(violation: Violation, openers: readonly string[]): string {\n if (violation.kind === 'electron')\n return `\"${violation.specifier}\" is the desktop shell's: only plugins/desktop (added with \"acrylblends add desktop\") imports electron`\n const where =\n openers.length > 0\n ? openers.join(', ')\n : 'a file named in package.json \"acryl\": { \"opener\": \"...\" }'\n return violation.kind === 'driver'\n ? `\"${violation.specifier}\" is a database driver; take a Db (import type { Db } from \"acrylblends/db\") as an argument and let ${where} open the database`\n : `\"${violation.specifier}\" opens a database, and only ${where} may; take a Db (import type { Db } from \"acrylblends/db\") as an argument`\n}\n\n/** Parse `check-deps [dir]`. */\nexport function parseCheckDepsOptions(argv: readonly string[]): { directory: string | undefined } {\n const args = argv.filter((a) => !a.startsWith('-'))\n if (args.length !== argv.length || args.length > 1)\n throw new Error('check-deps takes at most one argument: the app folder')\n return { directory: args[0] }\n}\n\n/** Report each provider import outside the opener, as `file:line: why`. Returns the exit code: 1 when there is one. */\nexport function checkDeps(options: { directory: string | undefined }, io: Io): number {\n const appDir = resolve(io.cwd, options.directory ?? '.')\n const violations = findViolations(appDir)\n if (violations.length === 0) {\n io.stdout.write('check-deps: no app code imports a database provider outside the opener\\n')\n return 0\n }\n const openers = openersOf(appDir)\n for (const violation of violations)\n io.stderr.write(`${violation.file}:${violation.line}: ${advice(violation, openers)}\\n`)\n io.stderr.write(`See ${GUIDE}\\n`)\n return 1\n}\n","import { existsSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\n\nexport interface Invocation {\n file: string\n args: string[]\n}\n\n/**\n * How to start a package manager without the shell option (Node warns about passing args to a shell, DEP0190, and a `.cmd` shim cannot be spawned directly).\n * Off Windows the command runs as it is. On Windows npm runs as `node npm-cli.js` (the one npm is running from, else the one beside `node`); any other\n * manager goes through `cmd.exe /d /s /c <name>.cmd`, whose arguments stay an array.\n */\nexport function packageManagerInvocation(\n command: string,\n args: readonly string[],\n platform: NodeJS.Platform = process.platform,\n env: NodeJS.ProcessEnv = process.env,\n exists: (path: string) => boolean = existsSync,\n execPath: string = process.execPath,\n): Invocation {\n if (platform !== 'win32') return { file: command, args: [...args] }\n if (command === 'npm') {\n const running = env.npm_execpath\n const cli =\n running !== undefined && /npm-cli\\.c?js$/.test(running)\n ? running\n : join(dirname(execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js')\n if (exists(cli)) return { file: execPath, args: [cli, ...args] }\n }\n return { file: env.ComSpec ?? 'cmd.exe', args: ['/d', '/s', '/c', `${command}.cmd`, ...args] }\n}\n","import { spawn } from 'node:child_process'\nimport { createInterface } from 'node:readline/promises'\nimport { packageManagerInvocation } from './spawn'\n\n/** Everything the CLI touches outside the filesystem. Tests pass their own. */\nexport interface Io {\n stdout: { write(text: string): unknown }\n stderr: { write(text: string): unknown }\n cwd: string\n /** Ask one question; `undefined` when there is no terminal to ask on. */\n ask: ((question: string) => Promise<string>) | undefined\n /** Install dependencies in a directory; resolves to the exit code. */\n install(directory: string): Promise<number>\n}\n\n/** The real terminal and `npm install`. */\nexport function processIo(): Io {\n const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY)\n return {\n stdout: process.stdout,\n stderr: process.stderr,\n cwd: process.cwd(),\n ask: interactive\n ? async (question) => {\n const rl = createInterface({ input: process.stdin, output: process.stdout })\n try {\n return await rl.question(question)\n } finally {\n rl.close()\n }\n }\n : undefined,\n install: (directory) =>\n new Promise((done) => {\n const { file, args } = packageManagerInvocation('npm', ['install'])\n const child = spawn(file, args, { cwd: directory, stdio: 'inherit' })\n child.on('error', () => done(1))\n child.on('exit', (code) => done(code ?? 1))\n }),\n }\n}\n","import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { resolve } from 'node:path'\nimport { parseArgs } from 'node:util'\nimport { UsageError } from './init'\nimport type { Io } from './io'\n\nexport interface KvImportOptions {\n readonly from: string\n readonly to: string\n readonly overwrite: boolean\n readonly table: string | undefined\n readonly migrations: string | undefined\n}\n\n/** Parse `kv import <kv.json> <database.sqlite> [--overwrite] [--table name] [--migrations dir]`. */\nexport function parseKvOptions(argv: readonly string[]): KvImportOptions {\n let parsed: ReturnType<typeof parse>\n try {\n parsed = parse(argv)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n const [action, from, to, ...rest] = parsed.positionals\n if (action !== 'import')\n throw new UsageError('kv takes one subcommand: kv import <kv.json> <database.sqlite>')\n if (from === undefined || to === undefined || rest.length > 0)\n throw new UsageError('kv import takes two arguments: the JSON file and the SQLite file')\n return {\n from,\n to,\n overwrite: parsed.values.overwrite ?? false,\n table: parsed.values.table,\n migrations: parsed.values.migrations,\n }\n}\n\nconst parse = (argv: readonly string[]) =>\n parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n overwrite: { type: 'boolean' },\n table: { type: 'string' },\n migrations: { type: 'string' },\n },\n })\n\n/** The framework as the app has it installed (so the code that reads the file is the code the app runs), else this package's own. */\nasync function framework<T>(io: Io, subpath: string, own: string): Promise<T> {\n const here = createRequire(resolve(io.cwd, 'package.json'))\n try {\n return (await import(here.resolve(`acrylblends/${subpath}`))) as T\n } catch {\n return (await import(new URL(`../lib/${own}`, import.meta.url).href)) as T\n }\n}\n\n/**\n * Import a JSON-file kv store into the `kv` table of an app's SQLite database: the move from `acryl-kv-json` to SQL. The file is not changed.\n * The database is opened with the app's `migrations/` folder when it has one (a database whose schema is newer than the files given is refused),\n * and the table is created when missing. Refuses to overwrite a key the table already has unless `--overwrite`.\n */\nexport async function kvImport(options: KvImportOptions, io: Io): Promise<number> {\n const from = resolve(io.cwd, options.from)\n const to = resolve(io.cwd, options.to)\n if (!existsSync(from)) {\n io.stderr.write(`error: ${from} does not exist\\n`)\n return 1\n }\n const kvCore = await framework<typeof import('../lib/kv')>(io, 'kv', 'kv.js')\n const json = await framework<typeof import('../lib/kv/json')>(io, 'kv/json', 'kv/json.js')\n const onDb = await framework<typeof import('../lib/kv/db')>(io, 'kv/db', 'kv/db.js')\n const sqlite = await framework<typeof import('../lib/db/sqlite')>(io, 'db/sqlite', 'db/sqlite.js')\n const migrations =\n options.migrations !== undefined\n ? resolve(io.cwd, options.migrations)\n : existsSync(resolve(io.cwd, 'migrations'))\n ? resolve(io.cwd, 'migrations')\n : undefined\n const source = await json.openKv({ path: from })\n try {\n const database = await sqlite.openDb({\n path: to,\n ...(migrations === undefined ? {} : { migrations }),\n })\n try {\n const target = onDb.kvOnDb(\n database.db,\n options.table === undefined ? {} : { table: options.table },\n )\n const result = await kvCore.copyKv(source.kv, target, { overwrite: options.overwrite })\n io.stdout.write(\n `imported ${result.copied} ${result.copied === 1 ? 'key' : 'keys'} from ${options.from} into ${options.to}` +\n `${options.table === undefined ? '' : ` (table ${options.table})`}` +\n `${result.overwritten > 0 ? `, ${result.overwritten} overwritten` : ''}\\n`,\n )\n return 0\n } finally {\n await database.close()\n }\n } finally {\n await source.close()\n }\n}\n","import { add, listPlugins, parseAddOptions } from './add'\nimport { buildClient, parseBuildClientOptions } from './build-client'\nimport { checkDeps, parseCheckDepsOptions } from './check-deps'\nimport { init, parseInitOptions, UsageError } from './init'\nimport { type Io, processIo } from './io'\nimport { kvImport, parseKvOptions } from './kv-import'\nimport { VERSION } from './version'\n\nexport { VERSION }\n\nexport const HELP = `acrylblends ${VERSION} - scaffold Cordis apps\n\nUsage:\n acrylblends init [dir] [options] Create a Cordis app in an empty or new directory\n acrylblends add <plugin...> [--dir d] [--suite] Copy library plugins (and what they require) into an app;\n a folder path brings an external plugin into its plugins/;\n --suite also copies the port's conformance suite and vitest (add kv --suite)\n acrylblends plugins List the plugin library\n acrylblends build-client [root] [out] Compile the client modules once for production (src/client to dist/client)\n acrylblends kv import <kv.json> <db> Move a JSON-file kv store into the kv table of a SQLite database [--overwrite] [--table t] [--migrations dir]\n acrylblends check-deps [dir] Fail when app code imports a database driver or opener outside the file named in\n package.json \"acryl\": { \"opener\": \"src/db.ts\" } (a port is imported, a provider is not)\n\nOptions for init:\n --template <name> blank or agent (asked when not given); --agent means --template agent,\n --no-agent means --template blank\n --name <name> the project name (default: the directory name)\n --desktop also add the desktop shell: npm run desktop opens a window on the app\n --install run npm install after copying\n -y, --yes ask nothing; use defaults (the blank template, no install)\n\n -h, --help show this help\n -v, --version show the version\n`\n\n/**\n * Run the CLI and return the exit code: 0 done, 1 failed or refused, 2 a usage error. Never calls `process.exit`.\n */\nexport async function runCli(argv: readonly string[], io: Io = processIo()): Promise<number> {\n const [command, ...args] = argv\n try {\n if (command === undefined || command === 'help' || command === '-h' || command === '--help') {\n io.stdout.write(HELP)\n return command === undefined ? 2 : 0\n }\n if (command === 'version' || command === '-v' || command === '--version') {\n io.stdout.write(`${VERSION}\\n`)\n return 0\n }\n if (command === 'init') return await init(parseInitOptions(args), io)\n if (command === 'add') return await add(parseAddOptions(args), io)\n if (command === 'build-client') return await buildClient(parseBuildClientOptions(args), io)\n if (command === 'kv') return await kvImport(parseKv(args), io)\n if (command === 'check-deps') return checkDeps(parseCheckDeps(args), io)\n if (command === 'plugins') return listPlugins(io)\n throw new UsageError(`unknown command \"${command}\"`)\n } catch (error) {\n if (error instanceof UsageError) {\n io.stderr.write(`error: ${error.message}\\n\\n${HELP}`)\n return 2\n }\n io.stderr.write(`error: ${error instanceof Error ? error.message : String(error)}\\n`)\n return 1\n }\n}\n\nfunction parseCheckDeps(args: readonly string[]) {\n try {\n return parseCheckDepsOptions(args)\n } catch (error) {\n throw new UsageError((error as Error).message)\n }\n}\n\nfunction parseKv(args: readonly string[]) {\n return parseKvOptions(args)\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,WACd,SACY;CACZ,MAAM,wBAAQ,IAAI,IAAoB;CACtC,KAAK,MAAM,CAAC,QAAQ,EAAE,cAAc,SAClC,KAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,WAAW,CAAC,CAAC,GACxD,MAAM,IAAI,GAAG,SAAS,WAAW,GAAG,OAAO,GAAG,MAAM;CACxD,OAAO;AACT;;AAGA,SAAS,SAAS,QAA4B;CAC5C,MAAM,OAAO,IAAI,WAAW,OAAO,MAAM;CACzC,IAAI,IAAI;CACR,OAAO,IAAI,OAAO,QAAQ;EACxB,MAAM,IAAI,OAAO;EACjB,MAAM,OAAO,OAAO,IAAI;EACxB,IAAI,MAAM,OAAO,SAAS,KAAK;GAC7B,MAAM,MAAM,OAAO,QAAQ,MAAM,CAAC;GAClC,MAAM,OAAO,QAAQ,KAAK,OAAO,SAAS;GAC1C,KAAK,KAAK,GAAG,GAAG,IAAI;GACpB,IAAI;EACN,OAAO,IAAI,MAAM,OAAO,SAAS,KAAK;GACpC,MAAM,MAAM,OAAO,QAAQ,MAAM,IAAI,CAAC;GACtC,MAAM,OAA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ACxC,OAAO,eAAe,IAAI;AAC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acrylblends",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
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",