@takuhon/cli 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -34,15 +34,16 @@ npx create-takuhon my-profile --license CC-BY-4.0 # non-interactive license
|
|
|
34
34
|
|
|
35
35
|
Each command operates on a local `takuhon.json` (default `./takuhon.json`) and reuses `@takuhon/core`. Pure-data commands return an exit code (`0` success, `1` invalid profile, `2` operational error).
|
|
36
36
|
|
|
37
|
-
| Command | Description
|
|
38
|
-
| -------------------------------------- |
|
|
39
|
-
| `takuhon validate [path]` | Validate a `takuhon.json` against the schema, reporting each failure as a JSON Pointer.
|
|
40
|
-
| `takuhon migrate [path] [--to <v>]` | Forward-migrate to a newer schema version (default: latest). Backs up first; supports `--out`, `--dry-run`.
|
|
41
|
-
| `takuhon restore --from <backup>` | Restore a profile from a backup (prompts before overwriting; pass `--yes` to skip).
|
|
42
|
-
| `takuhon export [path] [--output <f>]` | Serialise a `takuhon.json` to stdout (or to `--output`).
|
|
43
|
-
| `takuhon import <file> [path]` | Import an exported profile, migrating it to the current schema version. Backs up first.
|
|
44
|
-
| `takuhon build [path] [--output <d>]` | Render the profile into a static site — one HTML page per locale with build-time JSON-LD. `--base-url` adds absolute canonical/hreflang links.
|
|
45
|
-
| `takuhon dev [path] [--port <n>]` | Serve the profile as a local static preview, re-rendered on each request (default port `4321`, loopback only). `--base-url` adds canonical/hreflang links.
|
|
37
|
+
| Command | Description |
|
|
38
|
+
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `takuhon validate [path]` | Validate a `takuhon.json` against the schema, reporting each failure as a JSON Pointer. |
|
|
40
|
+
| `takuhon migrate [path] [--to <v>]` | Forward-migrate to a newer schema version (default: latest). Backs up first; supports `--out`, `--dry-run`. |
|
|
41
|
+
| `takuhon restore --from <backup>` | Restore a profile from a backup (prompts before overwriting; pass `--yes` to skip). |
|
|
42
|
+
| `takuhon export [path] [--output <f>]` | Serialise a `takuhon.json` to stdout (or to `--output`). |
|
|
43
|
+
| `takuhon import <file> [path]` | Import an exported profile, migrating it to the current schema version. Backs up first. |
|
|
44
|
+
| `takuhon build [path] [--output <d>]` | Render the profile into a static site — one HTML page per locale with build-time JSON-LD. `--base-url` adds absolute canonical/hreflang links. |
|
|
45
|
+
| `takuhon dev [path] [--port <n>]` | Serve the profile as a local static preview, re-rendered on each request (default port `4321`, loopback only). `--base-url` adds canonical/hreflang links. |
|
|
46
|
+
| `takuhon mcp [path]` | Serve the profile over the Model Context Protocol on stdio (read-only), so an MCP client such as Claude Desktop can read it. Re-reads the file per request. |
|
|
46
47
|
|
|
47
48
|
Run `takuhon --help`, or `takuhon <command> --help` for a command's full usage. The `sync` subcommand (mirror a local `takuhon.json` to a remote instance) is planned for a future release.
|
|
48
49
|
|
|
@@ -157,9 +157,9 @@ function buildPackageJson(opts) {
|
|
|
157
157
|
deploy: "wrangler deploy"
|
|
158
158
|
},
|
|
159
159
|
dependencies: {
|
|
160
|
-
"@takuhon/api": "^0.
|
|
161
|
-
"@takuhon/cloudflare": "^0.
|
|
162
|
-
"@takuhon/core": "^0.
|
|
160
|
+
"@takuhon/api": "^0.15.0",
|
|
161
|
+
"@takuhon/cloudflare": "^0.15.0",
|
|
162
|
+
"@takuhon/core": "^0.15.0",
|
|
163
163
|
hono: "^4.0.0"
|
|
164
164
|
},
|
|
165
165
|
devDependencies: {
|
|
@@ -278,6 +278,30 @@ Show your GitHub language mix / contribution calendar and WakaTime coding time o
|
|
|
278
278
|
|
|
279
279
|
The snapshot is served at \`GET /api/activity\` while enabled; a failed sync keeps the last-known data.
|
|
280
280
|
|
|
281
|
+
### GitHub profile badge
|
|
282
|
+
|
|
283
|
+
The activity card is also available as a standalone SVG you can embed as an image \u2014 e.g. in your GitHub profile \`README.md\`:
|
|
284
|
+
|
|
285
|
+
\`\`\`md
|
|
286
|
+

|
|
287
|
+
\`\`\`
|
|
288
|
+
|
|
289
|
+
Two ways to host it (both require \`settings.activity.enabled\`):
|
|
290
|
+
|
|
291
|
+
- **Dynamic (Worker):** \`GET /activity.svg\` renders the latest snapshot on every request. Add \`?theme=dark\` for the dark card.
|
|
292
|
+
- **Static (\`takuhon build\`):** writes \`dist/activity.svg\` and \`dist/activity-dark.svg\` beside the pages, so a static deploy can serve the badge too.
|
|
293
|
+
|
|
294
|
+
The card carries an opaque background, so it stays readable on either GitHub theme. To follow the viewer's OS colour scheme automatically, use \`<picture>\`:
|
|
295
|
+
|
|
296
|
+
\`\`\`html
|
|
297
|
+
<picture>
|
|
298
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://your-worker.example/activity.svg?theme=dark">
|
|
299
|
+
<img alt="My developer activity" src="https://your-worker.example/activity.svg">
|
|
300
|
+
</picture>
|
|
301
|
+
\`\`\`
|
|
302
|
+
|
|
303
|
+
GitHub proxies the image through Camo and caches it for a few hours, so a fresh sync can take a little while to appear in your README.
|
|
304
|
+
|
|
281
305
|
## R\xE9sum\xE9 / CV (optional)
|
|
282
306
|
|
|
283
307
|
Generate a print-ready CV from the same \`takuhon.json\` \u2014 no re-entry:
|
|
@@ -288,6 +312,24 @@ npx takuhon build --cv
|
|
|
288
312
|
|
|
289
313
|
This writes \`dist/cv.html\` (and \`dist/<locale>/cv.html\` for each locale) alongside the profile pages. Open it in a browser and use **Print \u2192 Save as PDF** to produce a r\xE9sum\xE9 PDF. \`npx takuhon dev\` also serves it at \`/cv\` for previewing.
|
|
290
314
|
|
|
315
|
+
## AI agents (MCP)
|
|
316
|
+
|
|
317
|
+
Your profile is readable over the [Model Context Protocol](https://modelcontextprotocol.io) \u2014 read-only, the same data the public API exposes (with the privacy filter applied), no write access.
|
|
318
|
+
|
|
319
|
+
- **Deployed:** the Worker serves a stateless MCP endpoint at \`POST /mcp\` (no extra binding or setup). Point an MCP client at \`https://your-worker.example/mcp\`. It is also advertised as \`mcp\` in \`/.well-known/takuhon.json\`.
|
|
320
|
+
- **Local:** run an MCP server over stdio against your \`takuhon.json\`, e.g. for Claude Desktop:
|
|
321
|
+
|
|
322
|
+
\`\`\`jsonc
|
|
323
|
+
// claude_desktop_config.json
|
|
324
|
+
{
|
|
325
|
+
"mcpServers": {
|
|
326
|
+
"my-profile": { "command": "npx", "args": ["takuhon", "mcp", "/path/to/takuhon.json"] }
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
\`\`\`
|
|
330
|
+
|
|
331
|
+
Both expose the tools \`get_profile\`, \`get_section\`, \`get_jsonld\`, \`list_locales\` and the resources \`takuhon://profile\`, \`takuhon://schema\`.
|
|
332
|
+
|
|
291
333
|
## Deploy
|
|
292
334
|
|
|
293
335
|
\`\`\`sh
|
|
@@ -482,4 +524,4 @@ export {
|
|
|
482
524
|
resolveAdminBundleDir,
|
|
483
525
|
copyAdminBundle
|
|
484
526
|
};
|
|
485
|
-
//# sourceMappingURL=chunk-
|
|
527
|
+
//# sourceMappingURL=chunk-DKOAVXLZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scaffold/wrangler-toml.ts","../src/scaffold/index.ts","../src/scaffold/env-example.ts","../src/scaffold/gitignore.ts","../src/scaffold/package-json.ts","../src/scaffold/readme.ts","../src/scaffold/takuhon-json.ts","../src/scaffold/tsconfig-json.ts","../src/scaffold/worker-index-ts.ts"],"sourcesContent":["/**\n * Generator for `wrangler.toml` in a freshly scaffolded project.\n *\n * The layout mirrors the reference Cloudflare adapter shipped in this\n * monorepo: a single KV namespace `TAKUHON_KV`, placeholder ids the user\n * fills in after running `wrangler kv namespace create`, and the\n * `TAKUHON_ADMIN_ORIGIN` var defaulting to \"\" (disabled). The admin bearer\n * token is provisioned as a Wrangler secret and is therefore not in this file.\n */\n\n/**\n * Validate a Cloudflare Worker name.\n *\n * Cloudflare itself accepts mixed-case DNS labels (1–63 chars, must not\n * start or end with a hyphen). This validator additionally enforces a\n * lowercase convention chosen for the scaffolder so that the resulting\n * `workers.dev` subdomain is predictable and matches the npm `name` field.\n */\nexport function isValidWorkerName(name: string): boolean {\n return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(name);\n}\n\n/**\n * In-project directory the admin SPA bundle is copied into and the scaffolded\n * `wrangler.toml` binds as `ASSETS`. Shared so the copy destination and the\n * `[assets] directory` value cannot drift apart. Defined in this leaf module\n * (which `scaffold/index.ts` already imports) to avoid an import cycle.\n */\nexport const ADMIN_DIST_DIRNAME = 'admin-dist';\n\n/**\n * Render `wrangler.toml` for the given project name.\n *\n * Throws if `projectName` is not a valid Cloudflare Worker name. Callers are\n * responsible for sanitising/validating earlier in the prompt flow.\n */\nexport function renderWranglerToml(projectName: string): string {\n if (!isValidWorkerName(projectName)) {\n throw new Error(\n `Invalid Cloudflare Worker name: \"${projectName}\". Names must be lowercase, ` +\n `start with a letter or digit, and contain only letters, digits, and hyphens (max 63 chars).`,\n );\n }\n return `name = \"${projectName}\"\nmain = \"src/index.ts\"\ncompatibility_date = \"2026-05-01\"\ncompatibility_flags = [\"nodejs_compat\"]\n\n# Admin SPA bundle. The React admin UI is committed in ./${ADMIN_DIST_DIRNAME}\n# (copied here when this project was created with create-takuhon) and served at\n# /admin.\n#\n# run_worker_first = true makes the Worker mediate every request: the bundle's\n# files sit at the assets root, so without this they would shadow the public \"/\"\n# route. The Worker serves the bundle only for /admin/* (attaching the strict\n# admin CSP) and handles everything else itself.\n#\n# SECURITY-CRITICAL: do not set run_worker_first to false or remove it. The\n# Worker is the only thing that attaches the strict admin CSP (plus HSTS /\n# no-store) to the admin assets; serving them directly would expose the admin UI\n# with no policy. To deploy without the form UI, remove this whole [assets]\n# block — the Worker then falls back to a minimal inline editor.\n[assets]\ndirectory = \"${ADMIN_DIST_DIRNAME}\"\nbinding = \"ASSETS\"\nrun_worker_first = true\nnot_found_handling = \"single-page-application\"\n\n# Replace the placeholder ids after running:\n# wrangler kv namespace create TAKUHON_KV\n# wrangler kv namespace create TAKUHON_KV --preview\n[[kv_namespaces]]\nbinding = \"TAKUHON_KV\"\nid = \"REPLACE_WITH_PRODUCTION_NAMESPACE_ID\"\npreview_id = \"REPLACE_WITH_PREVIEW_NAMESPACE_ID\"\n\n# Admin Origin allowlist (comma-separated). Empty value disables the check.\n# Example for production: TAKUHON_ADMIN_ORIGIN = \"https://admin.example.com\"\n#\n# The admin bearer token MUST be provisioned as a Wrangler secret, never in\n# this file:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# Use 32+ bytes of entropy, e.g. \\`openssl rand -base64 32\\`.\n[vars]\nTAKUHON_ADMIN_ORIGIN = \"\"\n\n# Image uploads (optional). Bind an R2 bucket to enable \\`POST /api/admin/assets\\`\n# and \\`GET /assets/*\\` delivery; without it the upload endpoint stays\n# unregistered (404) and avatars remain URL-only. Create the bucket, then\n# uncomment:\n# wrangler r2 bucket create ${projectName}-assets\n# [[r2_buckets]]\n# binding = \"TAKUHON_R2\"\n# bucket_name = \"${projectName}-assets\"\n\n# Developer-activity dashboard (optional). Enable settings.activity in your\n# takuhon.json, then uncomment the cron below to refresh the snapshot daily:\n# the Worker's scheduled handler fetches GitHub / WakaTime and stores the\n# result in the TAKUHON_KV namespace (a failed run keeps the last-known\n# snapshot). Secrets MUST be Wrangler secrets, never this file:\n# wrangler secret put TAKUHON_GITHUB_TOKEN # optional (contribution calendar)\n# wrangler secret put TAKUHON_WAKATIME_KEY # required for WakaTime\n# [triggers]\n# crons = [\"17 3 * * *\"]\n`;\n}\n","/**\n * Top-level scaffolding orchestrator for `create-takuhon`.\n *\n * `writeProject` creates the target directory (must not already exist), then\n * writes the eight files that make up the scaffold: `takuhon.json`,\n * `wrangler.toml`, `package.json`, `README.md`, `.gitignore`, `.env.example`,\n * `tsconfig.json`, and `src/index.ts` (the Cloudflare Worker entry composed via\n * `createTakuhonWorker` from `@takuhon/cloudflare`).\n *\n * `copyAdminBundle` then copies the bundled admin SPA into the project's\n * `admin-dist/` so the Worker can serve the form UI at `/admin`. `init.ts`\n * calls both in sequence.\n */\n\nimport { cp, mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nimport { renderEnvExample } from './env-example.js';\nimport { renderGitignore } from './gitignore.js';\nimport { renderPackageJson } from './package-json.js';\nimport { renderReadme } from './readme.js';\nimport { renderTakuhonJson } from './takuhon-json.js';\nimport { renderTsconfigJson } from './tsconfig-json.js';\nimport { renderWorkerIndexTs } from './worker-index-ts.js';\nimport { ADMIN_DIST_DIRNAME, renderWranglerToml } from './wrangler-toml.js';\n\nexport interface WriteProjectOptions {\n /** Absolute path of the directory to create. Must not exist. */\n readonly targetDir: string;\n /** Used for the npm `name`, Worker name, and README header. */\n readonly projectName: string;\n /** Chosen content license (already mapped via `buildContentLicense`). */\n readonly license: ContentLicenseFragment;\n}\n\nexport interface WriteProjectResult {\n /** Relative paths of files that were written (in the order written). */\n readonly files: readonly string[];\n}\n\n/**\n * Error thrown when the target directory already exists. The caller is\n * expected to render a friendly message that references the user-supplied\n * path; the `code` is stable for tests. The absolute `targetDir` is exposed\n * as a field rather than embedded in the message so that bubbling the error\n * up through generic logging does not leak filesystem layout.\n */\nexport class TargetDirectoryExistsError extends Error {\n override readonly name = 'TargetDirectoryExistsError';\n readonly code = 'TARGET_EXISTS' as const;\n constructor(readonly targetDir: string) {\n super('Target directory already exists.');\n }\n}\n\n/**\n * Create the project directory and write the scaffolded files. Order is\n * deterministic so callers (and tests) can rely on it.\n */\nexport async function writeProject(opts: WriteProjectOptions): Promise<WriteProjectResult> {\n const { targetDir, projectName, license } = opts;\n\n // mkdir with recursive: false fails if the directory exists; we surface a\n // typed error so the CLI entry can render a friendly message.\n try {\n await mkdir(targetDir, { recursive: false });\n } catch (err) {\n if (isNodeErrnoException(err) && err.code === 'EEXIST') {\n throw new TargetDirectoryExistsError(targetDir);\n }\n throw err;\n }\n\n const files: { readonly path: string; readonly content: string }[] = [\n { path: 'takuhon.json', content: renderTakuhonJson(license) },\n { path: 'wrangler.toml', content: renderWranglerToml(projectName) },\n { path: 'package.json', content: renderPackageJson({ projectName }) },\n { path: 'README.md', content: renderReadme({ projectName, license }) },\n { path: '.gitignore', content: renderGitignore() },\n { path: '.env.example', content: renderEnvExample() },\n { path: 'tsconfig.json', content: renderTsconfigJson() },\n { path: 'src/index.ts', content: renderWorkerIndexTs() },\n ];\n\n for (const { path, content } of files) {\n const fullPath = join(targetDir, path);\n const parent = dirname(fullPath);\n if (parent !== targetDir) {\n await mkdir(parent, { recursive: true });\n }\n await writeFile(fullPath, content, 'utf8');\n }\n\n return { files: files.map((f) => f.path) };\n}\n\nfunction isNodeErrnoException(err: unknown): err is NodeJS.ErrnoException {\n return err instanceof Error && typeof (err as NodeJS.ErrnoException).code === 'string';\n}\n\n/**\n * Resolve the admin SPA bundle that ships inside this package. The bundle is\n * copied here from `apps/admin/dist` at build time (see\n * `scripts/copy-admin-bundle.mjs`) and listed in the package's `files`, so it\n * is present in the published `@takuhon/cli` tarball. Resolved relative to the\n * compiled module (`dist/init.js` or `dist/index.js`), whose sibling is\n * `admin-bundle/`.\n */\nexport function resolveAdminBundleDir(): string {\n return fileURLToPath(new URL('../admin-bundle', import.meta.url));\n}\n\nexport interface CopyAdminBundleOptions {\n /** Project directory previously created by {@link writeProject}. */\n readonly targetDir: string;\n /**\n * Source bundle directory. Defaults to the bundle shipped in this package\n * ({@link resolveAdminBundleDir}); overridable for tests.\n */\n readonly bundleDir?: string;\n}\n\nexport interface CopyAdminBundleResult {\n /** Absolute path of the directory the bundle was copied into. */\n readonly dest: string;\n}\n\n/**\n * Copy the admin SPA bundle into the scaffolded project's\n * `{@link ADMIN_DIST_DIRNAME}` directory. The generated `wrangler.toml` binds\n * this directory as `ASSETS`, and the Cloudflare Worker serves it at `/admin`\n * under a strict CSP (falling back to an inline editor when the binding is\n * absent). Kept separate from {@link writeProject} so the static-asset copy and\n * the generated-file rendering are independently testable.\n */\nexport async function copyAdminBundle(\n opts: CopyAdminBundleOptions,\n): Promise<CopyAdminBundleResult> {\n const bundleDir = opts.bundleDir ?? resolveAdminBundleDir();\n const dest = join(opts.targetDir, ADMIN_DIST_DIRNAME);\n try {\n await cp(bundleDir, dest, { recursive: true });\n } catch (err) {\n // The bundle ships inside @takuhon/cli, so a failure here means a broken\n // or incomplete install. Surface a sanitized message — the raw error would\n // embed the absolute node_modules path of this package.\n const code = isNodeErrnoException(err) ? ` (${err.code})` : '';\n throw new Error(\n `Failed to copy the admin UI bundle from @takuhon/cli${code}. ` +\n `Reinstall or upgrade @takuhon/cli and try again.`,\n { cause: err },\n );\n }\n return { dest };\n}\n","/**\n * Generator for the `.env.example` file in a freshly scaffolded project.\n *\n * The Wrangler-managed secrets (admin bearer token) are *not* read from `.env`\n * at deploy time — `wrangler secret put` is the source of truth. The\n * `.env.example` is therefore documentation: it lists the variables a developer\n * may want locally (e.g. for scripting or for the wrangler CLI itself) and\n * links each to its production provisioning path.\n */\n\nexport function renderEnvExample(): string {\n return `# ----------------------------------------------------------------\n# Local development variables for this Takuhon deployment.\n#\n# Production secrets (admin token) are provisioned via:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# This file is a hint for local tooling, not a runtime source.\n# ----------------------------------------------------------------\n\n# Admin bearer token for /api/admin/* endpoints.\n# Generate with: openssl rand -base64 32\n# Then provision with:\n# echo \"$TAKUHON_ADMIN_TOKEN\" | wrangler secret put TAKUHON_ADMIN_TOKEN\nTAKUHON_ADMIN_TOKEN=\n\n# Comma-separated Origin allowlist for browser-originating admin requests.\n# Set in wrangler.toml [vars] for production. Local example:\n# TAKUHON_ADMIN_ORIGIN=https://admin.example.com,https://localhost:8787\nTAKUHON_ADMIN_ORIGIN=\n\n# Developer-activity sync secrets (only needed when settings.activity is\n# enabled in takuhon.json). Used by \\`takuhon activity sync\\` locally; for a\n# deployed Worker provision them as Wrangler secrets instead:\n# wrangler secret put TAKUHON_GITHUB_TOKEN\n# wrangler secret put TAKUHON_WAKATIME_KEY\n# Never commit the real values.\n#\n# Optional GitHub token: languages work without it; the contribution calendar\n# requires it (minimal read-only scope is enough).\nTAKUHON_GITHUB_TOKEN=\n# WakaTime API key (https://wakatime.com/settings/api-key); required to read\n# coding time.\nTAKUHON_WAKATIME_KEY=\n\n# Cloudflare account id (look up via \\`wrangler whoami\\`). Only needed if you\n# script Cloudflare API calls outside Wrangler itself.\nCLOUDFLARE_ACCOUNT_ID=\n`;\n}\n","/**\n * Generator for the scaffolded project's `.gitignore`.\n *\n * Covers Node, Wrangler local cache, and environment files. Kept conservative\n * — no opinions about lockfile preferences (the user picks their package\n * manager) or editor folders (per-editor patterns belong in a global ignore).\n */\n\nexport function renderGitignore(): string {\n return `# Dependencies\nnode_modules/\n\n# Wrangler local cache (do not commit; contains bundled output and tmp files)\n.wrangler/\n\n# Environment variables (commit \\`.env.example\\` instead)\n.env\n.env.local\n.env.*.local\n\n# Logs\n*.log\nnpm-debug.log*\npnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# macOS\n.DS_Store\n`;\n}\n","/**\n * Generator for the scaffolded project's `package.json`.\n *\n * Pinned dependency versions are caret ranges matched to the current\n * minor of the published `@takuhon/*` packages. Under 0.x semver, a caret\n * does not span minor versions, so the range must move forward with each\n * `@takuhon/core` minor release to keep scaffolded projects on the\n * matching schema generation. A guard test (`scaffold.test.ts`) asserts these\n * pins track the published minor, so a missed bump fails CI rather than\n * silently shipping a stale range. `hono` is included as a direct dependency for\n * projects that extend the Worker with their own Hono routes; the generated\n * `src/index.ts` reaches Takuhon's handlers through `@takuhon/cloudflare`\n * rather than importing `hono` directly. `wrangler` is a devDependency since\n * it's the deploy / dev-server tool.\n */\n\nexport interface PackageJsonOptions {\n /** Used for the npm `name` field. */\n readonly projectName: string;\n}\n\nexport function buildPackageJson(opts: PackageJsonOptions): Record<string, unknown> {\n return {\n name: opts.projectName,\n version: '0.0.0',\n private: true,\n type: 'module',\n description: 'Takuhon profile deployment.',\n scripts: {\n dev: 'wrangler dev',\n deploy: 'wrangler deploy',\n },\n dependencies: {\n '@takuhon/api': '^0.13.0',\n '@takuhon/cloudflare': '^0.13.0',\n '@takuhon/core': '^0.13.0',\n hono: '^4.0.0',\n },\n devDependencies: {\n wrangler: '^4.0.0',\n },\n engines: {\n node: '>=22.0.0',\n },\n };\n}\n\nexport function renderPackageJson(opts: PackageJsonOptions): string {\n return `${JSON.stringify(buildPackageJson(opts), null, 2)}\\n`;\n}\n","/**\n * Generator for the README.md placed in a freshly scaffolded project.\n *\n * Aims to give a first-time user enough to (1) install dependencies,\n * (2) fill in their profile data, (3) provision Cloudflare KV + admin\n * secret, and (4) `pnpm dev` / `pnpm deploy`. Cross-references the published\n * `@takuhon/cloudflare` adapter README as the next-step reference for the\n * route map.\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nexport interface ReadmeOptions {\n readonly projectName: string;\n readonly license: ContentLicenseFragment;\n}\n\n/**\n * Human-readable license attribution line for the README footer. Uses the\n * canonical URL when available; falls back to plain SPDX (or\n * \"All rights reserved\" for Proprietary).\n */\nfunction formatLicenseLine(license: ContentLicenseFragment): string {\n if (license.spdxId === 'Proprietary') {\n return '**Proprietary** — all rights reserved.';\n }\n if (license.url !== undefined) {\n return `[\\`${license.spdxId}\\`](${license.url})`;\n }\n return `\\`${license.spdxId}\\``;\n}\n\nexport function renderReadme(opts: ReadmeOptions): string {\n const { projectName, license } = opts;\n const licenseLine = formatLicenseLine(license);\n return `# ${projectName}\n\nA [Takuhon](https://github.com/takuhon-dev/takuhon) profile deployment, running on Cloudflare Workers.\n\n> **Status**: pre-deploy. Edit \\`takuhon.json\\`, provision Cloudflare KV, then \\`pnpm deploy\\`.\n\n## What is Takuhon?\n\nTakuhon lets you own your profile as a portable JSON document and publish it as a mobile-first profile page plus a public API (JSON-LD for AI agents and search engines included).\n\n## Setup\n\n1. **Install dependencies.**\n\n \\`\\`\\`sh\n pnpm install\n \\`\\`\\`\n\n2. **Edit your profile.** Open \\`takuhon.json\\` and replace the sample fields (\\`profile.displayName\\`, \\`links\\`, \\`careers\\`, \\`projects\\`, \\`skills\\`) with your own.\n\n3. **Create the Cloudflare KV namespaces** and copy the returned ids into \\`wrangler.toml\\`:\n\n \\`\\`\\`sh\n npx wrangler kv namespace create TAKUHON_KV\n npx wrangler kv namespace create TAKUHON_KV --preview\n \\`\\`\\`\n\n4. **Provision the admin token** as a Wrangler secret (used by \\`/api/admin/*\\`):\n\n \\`\\`\\`sh\n openssl rand -base64 32 | npx wrangler secret put TAKUHON_ADMIN_TOKEN\n \\`\\`\\`\n\n Leaving the secret unset disables admin writes entirely (every \\`PUT\\` / \\`DELETE\\` returns 401).\n\n## Develop\n\nThe Worker entry at \\`src/index.ts\\` composes the takuhon adapter via\n\\`createTakuhonWorker\\` and serves your \\`takuhon.json\\` as the fallback when\nKV has no stored profile yet.\n\n\\`\\`\\`sh\npnpm dev # runs \\`wrangler dev\\` locally\n\\`\\`\\`\n\nThe full route map (public + admin) is documented in the [\\`@takuhon/cloudflare\\` README](https://github.com/takuhon-dev/takuhon/tree/main/adapters/cloudflare#readme).\n\n## Admin\n\nThe admin form UI is served at \\`/admin\\` under a strict Content-Security-Policy. Its compiled bundle is committed in \\`admin-dist/\\` and bound as Workers Assets in \\`wrangler.toml\\`. Sign in with the admin token you set as the \\`TAKUHON_ADMIN_TOKEN\\` Wrangler secret.\n\nThe bundle is a snapshot taken when this project was created. To pick up a newer admin UI, upgrade your \\`takuhon\\` CLI and run \\`takuhon admin update\\` in this project — it replaces \\`admin-dist/\\` with the bundle shipped in your installed \\`@takuhon/cli\\` (keep your \\`@takuhon/*\\` dependencies on a matching version). To deploy without the form UI, remove the \\`[assets]\\` block from \\`wrangler.toml\\`; the Worker then falls back to a minimal inline editor.\n\n### Image uploads (optional)\n\nImage uploads are off until you bind an R2 bucket. Create one and uncomment the \\`[[r2_buckets]]\\` block in \\`wrangler.toml\\`:\n\n\\`\\`\\`sh\nnpx wrangler r2 bucket create ${projectName}-assets\n\\`\\`\\`\n\nThe Worker then accepts uploads at \\`POST /api/admin/assets\\` (magic-byte check, 5 MB / 4096px limits, EXIF/metadata stripping) and serves them at \\`GET /assets/*\\` with \\`X-Content-Type-Options: nosniff\\`. Without the binding, avatars stay URL-only.\n\n### Developer-activity dashboard (optional)\n\nShow your GitHub language mix / contribution calendar and WakaTime coding time on the profile. The data is synced into a snapshot ahead of time — rendering never calls GitHub or WakaTime, and the API keys never leave the sync step.\n\n1. Opt in by adding \\`settings.activity\\` to \\`takuhon.json\\`:\n\n \\`\\`\\`jsonc\n \"settings\": {\n \"activity\": {\n \"enabled\": true,\n \"github\": { \"username\": \"your-github-login\" },\n \"wakatime\": { \"username\": \"your-wakatime-username\" }\n }\n }\n \\`\\`\\`\n\n2. Provision the sync secrets (see \\`.env.example\\`): \\`TAKUHON_WAKATIME_KEY\\` is required for coding time; \\`TAKUHON_GITHUB_TOKEN\\` is optional — languages work without it, the contribution calendar needs it.\n\n \\`\\`\\`sh\n npx wrangler secret put TAKUHON_GITHUB_TOKEN\n npx wrangler secret put TAKUHON_WAKATIME_KEY\n \\`\\`\\`\n\n3. Uncomment the \\`[triggers]\\` cron block in \\`wrangler.toml\\` so the Worker refreshes the snapshot daily, or run \\`takuhon activity sync\\` locally to write an \\`activity.json\\` next to your profile for \\`takuhon build\\` / \\`dev\\`.\n\nThe snapshot is served at \\`GET /api/activity\\` while enabled; a failed sync keeps the last-known data.\n\n## Résumé / CV (optional)\n\nGenerate a print-ready CV from the same \\`takuhon.json\\` — no re-entry:\n\n\\`\\`\\`sh\nnpx takuhon build --cv\n\\`\\`\\`\n\nThis writes \\`dist/cv.html\\` (and \\`dist/<locale>/cv.html\\` for each locale) alongside the profile pages. Open it in a browser and use **Print → Save as PDF** to produce a résumé PDF. \\`npx takuhon dev\\` also serves it at \\`/cv\\` for previewing.\n\n## Deploy\n\n\\`\\`\\`sh\npnpm deploy # runs \\`wrangler deploy\\`\n\\`\\`\\`\n\n## License\n\nProfile content (\\`takuhon.json\\`) is licensed under ${licenseLine}\n\nThe deployment code is your own; pick a license appropriate for it.\n`;\n}\n","/**\n * Generator for the `takuhon.json` file written into a freshly scaffolded\n * project.\n *\n * The template is a copy of `examples/minimal-profile/takuhon.json` from the\n * monorepo. It is inlined here as a TypeScript constant rather than imported\n * from `examples/` so the published `@takuhon/cli` npm package does not need\n * to ship the examples directory.\n *\n * Only `meta.contentLicense` is rewritten per the user's choice; everything\n * else is the canonical minimal profile (one career, one project, three\n * skills, `en` locale only) that downstream `@takuhon/core` validation\n * already accepts (see `packages/core/src/__tests__/examples-fixtures.test.ts`).\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\n/**\n * Build the `takuhon.json` payload as a deterministic, schema-valid object.\n * `meta.contentLicense` is filled from the supplied fragment so each\n * generated project carries the user's chosen SPDX identifier (and `url` /\n * `rights` where applicable).\n */\nexport function buildTakuhonJson(license: ContentLicenseFragment): unknown {\n return {\n schemaVersion: '0.5.0',\n profile: {\n displayName: {\n en: 'Sam Lee',\n },\n },\n links: [\n {\n id: 'github',\n type: 'github',\n url: 'https://example.com/github/sam-lee',\n featured: true,\n },\n ],\n careers: [\n {\n id: 'first-job',\n organization: {\n en: 'Example Co.',\n },\n role: {\n en: 'Junior Software Engineer',\n },\n startDate: '2026-04',\n endDate: null,\n isCurrent: true,\n },\n ],\n projects: [\n {\n id: 'personal-homepage',\n title: {\n en: 'Personal homepage',\n },\n },\n ],\n skills: [\n { id: 'html', label: 'HTML' },\n { id: 'css', label: 'CSS' },\n { id: 'javascript', label: 'JavaScript' },\n ],\n contact: {},\n settings: {\n defaultLocale: 'en',\n availableLocales: ['en'],\n },\n meta: {\n contentLicense: { ...license },\n },\n };\n}\n\n/** Serialise to a UTF-8 string with trailing newline (POSIX-friendly). */\nexport function renderTakuhonJson(license: ContentLicenseFragment): string {\n return `${JSON.stringify(buildTakuhonJson(license), null, 2)}\\n`;\n}\n","/**\n * Generator for the scaffolded project's `tsconfig.json`.\n *\n * Minimal configuration that makes the generated `src/index.ts` typecheck\n * with `tsc --noEmit` in a freshly scaffolded directory. The settings\n * mirror the upstream takuhon monorepo defaults (ES2022 target, ESNext\n * modules, strict mode, `noUncheckedIndexedAccess`) and explicitly enable\n * the two flags the Worker entry depends on:\n *\n * - `resolveJsonModule` — so `import takuhonJson from '../takuhon.json'`\n * resolves at type-check time.\n * - `moduleResolution: \"Bundler\"` — so the Wrangler / esbuild-style\n * resolution (no need for explicit file extensions) is the source of\n * truth that matches what `wrangler dev` actually runs.\n *\n * `noEmit: true` keeps `tsc` purely a type-checker; Wrangler's bundler\n * produces the deployable artifact.\n */\n\nexport function renderTsconfigJson(): string {\n const config = {\n compilerOptions: {\n target: 'ES2022',\n lib: ['ES2022'],\n module: 'ESNext',\n moduleResolution: 'Bundler',\n esModuleInterop: true,\n resolveJsonModule: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n strict: true,\n noUncheckedIndexedAccess: true,\n noImplicitOverride: true,\n noFallthroughCasesInSwitch: true,\n skipLibCheck: true,\n noEmit: true,\n },\n include: ['src/**/*'],\n exclude: ['node_modules'],\n };\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n","/**\n * Generator for `src/index.ts` — the Cloudflare Worker entry file written\n * into a freshly scaffolded project.\n *\n * The generated file uses `createTakuhonWorker()` from `@takuhon/cloudflare`\n * so the scaffolded project does not need to know the internal wiring\n * (Hono router, KV-backed storage, edge cache purger, console audit logger).\n * The user's own `takuhon.json` is loaded via an ES module JSON import,\n * validated once at module load, and the resulting `Takuhon` value is\n * served as the fallback when KV has no stored profile yet.\n *\n * `wrangler.toml`'s `main` field already points at `src/index.ts`, and\n * `nodejs_compat` is enabled, so the file works under `wrangler dev` /\n * `wrangler deploy` without further configuration.\n */\n\nexport function renderWorkerIndexTs(): string {\n return `import { createTakuhonWorker } from '@takuhon/cloudflare';\nimport { validate } from '@takuhon/core';\n\n// Use the project's own takuhon.json as the fallback served when KV has no\n// stored profile yet. Validated once at module load so a malformed profile\n// fails fast rather than at first request.\nimport takuhonJson from '../takuhon.json' with { type: 'json' };\n\nconst fallback = validate(takuhonJson);\nif (!fallback.ok) {\n throw new Error(\n 'Project takuhon.json failed validation: ' +\n fallback.errors.map((e) => \\`\\${e.pointer}: \\${e.message}\\`).join('; '),\n );\n}\n\nconst fallbackTakuhon = fallback.data;\n\nexport default createTakuhonWorker({\n fallback: () => fallbackTakuhon,\n});\n`;\n}\n"],"mappings":";AAkBO,SAAS,kBAAkB,MAAuB;AACvD,SAAO,yCAAyC,KAAK,IAAI;AAC3D;AAQO,IAAM,qBAAqB;AAQ3B,SAAS,mBAAmB,aAA6B;AAC9D,MAAI,CAAC,kBAAkB,WAAW,GAAG;AACnC,UAAM,IAAI;AAAA,MACR,oCAAoC,WAAW;AAAA,IAEjD;AAAA,EACF;AACA,SAAO,WAAW,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,2DAK4B,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAe9D,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCA2BD,WAAW;AAAA;AAAA;AAAA,mBAGxB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAY9B;;;AC3FA,SAAS,IAAI,OAAO,iBAAiB;AACrC,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;;;ACNvB,SAAS,mBAA2B;AACzC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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sBAAsB;AAC1D,QAAM,OAAO,KAAK,KAAK,WAAW,kBAAkB;AACpD,MAAI;AACF,UAAM,GAAG,WAAW,MAAM,EAAE,WAAW,KAAK,CAAC;AAAA,EAC/C,SAAS,KAAK;AAIZ,UAAM,OAAO,qBAAqB,GAAG,IAAI,KAAK,IAAI,IAAI,MAAM;AAC5D,UAAM,IAAI;AAAA,MACR,uDAAuD,IAAI;AAAA,MAE3D,EAAE,OAAO,IAAI;AAAA,IACf;AAAA,EACF;AACA,SAAO,EAAE,KAAK;AAChB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/scaffold/wrangler-toml.ts","../src/scaffold/index.ts","../src/scaffold/env-example.ts","../src/scaffold/gitignore.ts","../src/scaffold/package-json.ts","../src/scaffold/readme.ts","../src/scaffold/takuhon-json.ts","../src/scaffold/tsconfig-json.ts","../src/scaffold/worker-index-ts.ts"],"sourcesContent":["/**\n * Generator for `wrangler.toml` in a freshly scaffolded project.\n *\n * The layout mirrors the reference Cloudflare adapter shipped in this\n * monorepo: a single KV namespace `TAKUHON_KV`, placeholder ids the user\n * fills in after running `wrangler kv namespace create`, and the\n * `TAKUHON_ADMIN_ORIGIN` var defaulting to \"\" (disabled). The admin bearer\n * token is provisioned as a Wrangler secret and is therefore not in this file.\n */\n\n/**\n * Validate a Cloudflare Worker name.\n *\n * Cloudflare itself accepts mixed-case DNS labels (1–63 chars, must not\n * start or end with a hyphen). This validator additionally enforces a\n * lowercase convention chosen for the scaffolder so that the resulting\n * `workers.dev` subdomain is predictable and matches the npm `name` field.\n */\nexport function isValidWorkerName(name: string): boolean {\n return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(name);\n}\n\n/**\n * In-project directory the admin SPA bundle is copied into and the scaffolded\n * `wrangler.toml` binds as `ASSETS`. Shared so the copy destination and the\n * `[assets] directory` value cannot drift apart. Defined in this leaf module\n * (which `scaffold/index.ts` already imports) to avoid an import cycle.\n */\nexport const ADMIN_DIST_DIRNAME = 'admin-dist';\n\n/**\n * Render `wrangler.toml` for the given project name.\n *\n * Throws if `projectName` is not a valid Cloudflare Worker name. Callers are\n * responsible for sanitising/validating earlier in the prompt flow.\n */\nexport function renderWranglerToml(projectName: string): string {\n if (!isValidWorkerName(projectName)) {\n throw new Error(\n `Invalid Cloudflare Worker name: \"${projectName}\". Names must be lowercase, ` +\n `start with a letter or digit, and contain only letters, digits, and hyphens (max 63 chars).`,\n );\n }\n return `name = \"${projectName}\"\nmain = \"src/index.ts\"\ncompatibility_date = \"2026-05-01\"\ncompatibility_flags = [\"nodejs_compat\"]\n\n# Admin SPA bundle. The React admin UI is committed in ./${ADMIN_DIST_DIRNAME}\n# (copied here when this project was created with create-takuhon) and served at\n# /admin.\n#\n# run_worker_first = true makes the Worker mediate every request: the bundle's\n# files sit at the assets root, so without this they would shadow the public \"/\"\n# route. The Worker serves the bundle only for /admin/* (attaching the strict\n# admin CSP) and handles everything else itself.\n#\n# SECURITY-CRITICAL: do not set run_worker_first to false or remove it. The\n# Worker is the only thing that attaches the strict admin CSP (plus HSTS /\n# no-store) to the admin assets; serving them directly would expose the admin UI\n# with no policy. To deploy without the form UI, remove this whole [assets]\n# block — the Worker then falls back to a minimal inline editor.\n[assets]\ndirectory = \"${ADMIN_DIST_DIRNAME}\"\nbinding = \"ASSETS\"\nrun_worker_first = true\nnot_found_handling = \"single-page-application\"\n\n# Replace the placeholder ids after running:\n# wrangler kv namespace create TAKUHON_KV\n# wrangler kv namespace create TAKUHON_KV --preview\n[[kv_namespaces]]\nbinding = \"TAKUHON_KV\"\nid = \"REPLACE_WITH_PRODUCTION_NAMESPACE_ID\"\npreview_id = \"REPLACE_WITH_PREVIEW_NAMESPACE_ID\"\n\n# Admin Origin allowlist (comma-separated). Empty value disables the check.\n# Example for production: TAKUHON_ADMIN_ORIGIN = \"https://admin.example.com\"\n#\n# The admin bearer token MUST be provisioned as a Wrangler secret, never in\n# this file:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# Use 32+ bytes of entropy, e.g. \\`openssl rand -base64 32\\`.\n[vars]\nTAKUHON_ADMIN_ORIGIN = \"\"\n\n# Image uploads (optional). Bind an R2 bucket to enable \\`POST /api/admin/assets\\`\n# and \\`GET /assets/*\\` delivery; without it the upload endpoint stays\n# unregistered (404) and avatars remain URL-only. Create the bucket, then\n# uncomment:\n# wrangler r2 bucket create ${projectName}-assets\n# [[r2_buckets]]\n# binding = \"TAKUHON_R2\"\n# bucket_name = \"${projectName}-assets\"\n\n# Developer-activity dashboard (optional). Enable settings.activity in your\n# takuhon.json, then uncomment the cron below to refresh the snapshot daily:\n# the Worker's scheduled handler fetches GitHub / WakaTime and stores the\n# result in the TAKUHON_KV namespace (a failed run keeps the last-known\n# snapshot). Secrets MUST be Wrangler secrets, never this file:\n# wrangler secret put TAKUHON_GITHUB_TOKEN # optional (contribution calendar)\n# wrangler secret put TAKUHON_WAKATIME_KEY # required for WakaTime\n# [triggers]\n# crons = [\"17 3 * * *\"]\n`;\n}\n","/**\n * Top-level scaffolding orchestrator for `create-takuhon`.\n *\n * `writeProject` creates the target directory (must not already exist), then\n * writes the eight files that make up the scaffold: `takuhon.json`,\n * `wrangler.toml`, `package.json`, `README.md`, `.gitignore`, `.env.example`,\n * `tsconfig.json`, and `src/index.ts` (the Cloudflare Worker entry composed via\n * `createTakuhonWorker` from `@takuhon/cloudflare`).\n *\n * `copyAdminBundle` then copies the bundled admin SPA into the project's\n * `admin-dist/` so the Worker can serve the form UI at `/admin`. `init.ts`\n * calls both in sequence.\n */\n\nimport { cp, mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nimport { renderEnvExample } from './env-example.js';\nimport { renderGitignore } from './gitignore.js';\nimport { renderPackageJson } from './package-json.js';\nimport { renderReadme } from './readme.js';\nimport { renderTakuhonJson } from './takuhon-json.js';\nimport { renderTsconfigJson } from './tsconfig-json.js';\nimport { renderWorkerIndexTs } from './worker-index-ts.js';\nimport { ADMIN_DIST_DIRNAME, renderWranglerToml } from './wrangler-toml.js';\n\nexport interface WriteProjectOptions {\n /** Absolute path of the directory to create. Must not exist. */\n readonly targetDir: string;\n /** Used for the npm `name`, Worker name, and README header. */\n readonly projectName: string;\n /** Chosen content license (already mapped via `buildContentLicense`). */\n readonly license: ContentLicenseFragment;\n}\n\nexport interface WriteProjectResult {\n /** Relative paths of files that were written (in the order written). */\n readonly files: readonly string[];\n}\n\n/**\n * Error thrown when the target directory already exists. The caller is\n * expected to render a friendly message that references the user-supplied\n * path; the `code` is stable for tests. The absolute `targetDir` is exposed\n * as a field rather than embedded in the message so that bubbling the error\n * up through generic logging does not leak filesystem layout.\n */\nexport class TargetDirectoryExistsError extends Error {\n override readonly name = 'TargetDirectoryExistsError';\n readonly code = 'TARGET_EXISTS' as const;\n constructor(readonly targetDir: string) {\n super('Target directory already exists.');\n }\n}\n\n/**\n * Create the project directory and write the scaffolded files. Order is\n * deterministic so callers (and tests) can rely on it.\n */\nexport async function writeProject(opts: WriteProjectOptions): Promise<WriteProjectResult> {\n const { targetDir, projectName, license } = opts;\n\n // mkdir with recursive: false fails if the directory exists; we surface a\n // typed error so the CLI entry can render a friendly message.\n try {\n await mkdir(targetDir, { recursive: false });\n } catch (err) {\n if (isNodeErrnoException(err) && err.code === 'EEXIST') {\n throw new TargetDirectoryExistsError(targetDir);\n }\n throw err;\n }\n\n const files: { readonly path: string; readonly content: string }[] = [\n { path: 'takuhon.json', content: renderTakuhonJson(license) },\n { path: 'wrangler.toml', content: renderWranglerToml(projectName) },\n { path: 'package.json', content: renderPackageJson({ projectName }) },\n { path: 'README.md', content: renderReadme({ projectName, license }) },\n { path: '.gitignore', content: renderGitignore() },\n { path: '.env.example', content: renderEnvExample() },\n { path: 'tsconfig.json', content: renderTsconfigJson() },\n { path: 'src/index.ts', content: renderWorkerIndexTs() },\n ];\n\n for (const { path, content } of files) {\n const fullPath = join(targetDir, path);\n const parent = dirname(fullPath);\n if (parent !== targetDir) {\n await mkdir(parent, { recursive: true });\n }\n await writeFile(fullPath, content, 'utf8');\n }\n\n return { files: files.map((f) => f.path) };\n}\n\nfunction isNodeErrnoException(err: unknown): err is NodeJS.ErrnoException {\n return err instanceof Error && typeof (err as NodeJS.ErrnoException).code === 'string';\n}\n\n/**\n * Resolve the admin SPA bundle that ships inside this package. The bundle is\n * copied here from `apps/admin/dist` at build time (see\n * `scripts/copy-admin-bundle.mjs`) and listed in the package's `files`, so it\n * is present in the published `@takuhon/cli` tarball. Resolved relative to the\n * compiled module (`dist/init.js` or `dist/index.js`), whose sibling is\n * `admin-bundle/`.\n */\nexport function resolveAdminBundleDir(): string {\n return fileURLToPath(new URL('../admin-bundle', import.meta.url));\n}\n\nexport interface CopyAdminBundleOptions {\n /** Project directory previously created by {@link writeProject}. */\n readonly targetDir: string;\n /**\n * Source bundle directory. Defaults to the bundle shipped in this package\n * ({@link resolveAdminBundleDir}); overridable for tests.\n */\n readonly bundleDir?: string;\n}\n\nexport interface CopyAdminBundleResult {\n /** Absolute path of the directory the bundle was copied into. */\n readonly dest: string;\n}\n\n/**\n * Copy the admin SPA bundle into the scaffolded project's\n * `{@link ADMIN_DIST_DIRNAME}` directory. The generated `wrangler.toml` binds\n * this directory as `ASSETS`, and the Cloudflare Worker serves it at `/admin`\n * under a strict CSP (falling back to an inline editor when the binding is\n * absent). Kept separate from {@link writeProject} so the static-asset copy and\n * the generated-file rendering are independently testable.\n */\nexport async function copyAdminBundle(\n opts: CopyAdminBundleOptions,\n): Promise<CopyAdminBundleResult> {\n const bundleDir = opts.bundleDir ?? resolveAdminBundleDir();\n const dest = join(opts.targetDir, ADMIN_DIST_DIRNAME);\n try {\n await cp(bundleDir, dest, { recursive: true });\n } catch (err) {\n // The bundle ships inside @takuhon/cli, so a failure here means a broken\n // or incomplete install. Surface a sanitized message — the raw error would\n // embed the absolute node_modules path of this package.\n const code = isNodeErrnoException(err) ? ` (${err.code})` : '';\n throw new Error(\n `Failed to copy the admin UI bundle from @takuhon/cli${code}. ` +\n `Reinstall or upgrade @takuhon/cli and try again.`,\n { cause: err },\n );\n }\n return { dest };\n}\n","/**\n * Generator for the `.env.example` file in a freshly scaffolded project.\n *\n * The Wrangler-managed secrets (admin bearer token) are *not* read from `.env`\n * at deploy time — `wrangler secret put` is the source of truth. The\n * `.env.example` is therefore documentation: it lists the variables a developer\n * may want locally (e.g. for scripting or for the wrangler CLI itself) and\n * links each to its production provisioning path.\n */\n\nexport function renderEnvExample(): string {\n return `# ----------------------------------------------------------------\n# Local development variables for this Takuhon deployment.\n#\n# Production secrets (admin token) are provisioned via:\n# wrangler secret put TAKUHON_ADMIN_TOKEN\n# This file is a hint for local tooling, not a runtime source.\n# ----------------------------------------------------------------\n\n# Admin bearer token for /api/admin/* endpoints.\n# Generate with: openssl rand -base64 32\n# Then provision with:\n# echo \"$TAKUHON_ADMIN_TOKEN\" | wrangler secret put TAKUHON_ADMIN_TOKEN\nTAKUHON_ADMIN_TOKEN=\n\n# Comma-separated Origin allowlist for browser-originating admin requests.\n# Set in wrangler.toml [vars] for production. Local example:\n# TAKUHON_ADMIN_ORIGIN=https://admin.example.com,https://localhost:8787\nTAKUHON_ADMIN_ORIGIN=\n\n# Developer-activity sync secrets (only needed when settings.activity is\n# enabled in takuhon.json). Used by \\`takuhon activity sync\\` locally; for a\n# deployed Worker provision them as Wrangler secrets instead:\n# wrangler secret put TAKUHON_GITHUB_TOKEN\n# wrangler secret put TAKUHON_WAKATIME_KEY\n# Never commit the real values.\n#\n# Optional GitHub token: languages work without it; the contribution calendar\n# requires it (minimal read-only scope is enough).\nTAKUHON_GITHUB_TOKEN=\n# WakaTime API key (https://wakatime.com/settings/api-key); required to read\n# coding time.\nTAKUHON_WAKATIME_KEY=\n\n# Cloudflare account id (look up via \\`wrangler whoami\\`). Only needed if you\n# script Cloudflare API calls outside Wrangler itself.\nCLOUDFLARE_ACCOUNT_ID=\n`;\n}\n","/**\n * Generator for the scaffolded project's `.gitignore`.\n *\n * Covers Node, Wrangler local cache, and environment files. Kept conservative\n * — no opinions about lockfile preferences (the user picks their package\n * manager) or editor folders (per-editor patterns belong in a global ignore).\n */\n\nexport function renderGitignore(): string {\n return `# Dependencies\nnode_modules/\n\n# Wrangler local cache (do not commit; contains bundled output and tmp files)\n.wrangler/\n\n# Environment variables (commit \\`.env.example\\` instead)\n.env\n.env.local\n.env.*.local\n\n# Logs\n*.log\nnpm-debug.log*\npnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# macOS\n.DS_Store\n`;\n}\n","/**\n * Generator for the scaffolded project's `package.json`.\n *\n * Pinned dependency versions are caret ranges matched to the current\n * minor of the published `@takuhon/*` packages. Under 0.x semver, a caret\n * does not span minor versions, so the range must move forward with each\n * `@takuhon/core` minor release to keep scaffolded projects on the\n * matching schema generation. A guard test (`scaffold.test.ts`) asserts these\n * pins track the published minor, so a missed bump fails CI rather than\n * silently shipping a stale range. `hono` is included as a direct dependency for\n * projects that extend the Worker with their own Hono routes; the generated\n * `src/index.ts` reaches Takuhon's handlers through `@takuhon/cloudflare`\n * rather than importing `hono` directly. `wrangler` is a devDependency since\n * it's the deploy / dev-server tool.\n */\n\nexport interface PackageJsonOptions {\n /** Used for the npm `name` field. */\n readonly projectName: string;\n}\n\nexport function buildPackageJson(opts: PackageJsonOptions): Record<string, unknown> {\n return {\n name: opts.projectName,\n version: '0.0.0',\n private: true,\n type: 'module',\n description: 'Takuhon profile deployment.',\n scripts: {\n dev: 'wrangler dev',\n deploy: 'wrangler deploy',\n },\n dependencies: {\n '@takuhon/api': '^0.15.0',\n '@takuhon/cloudflare': '^0.15.0',\n '@takuhon/core': '^0.15.0',\n hono: '^4.0.0',\n },\n devDependencies: {\n wrangler: '^4.0.0',\n },\n engines: {\n node: '>=22.0.0',\n },\n };\n}\n\nexport function renderPackageJson(opts: PackageJsonOptions): string {\n return `${JSON.stringify(buildPackageJson(opts), null, 2)}\\n`;\n}\n","/**\n * Generator for the README.md placed in a freshly scaffolded project.\n *\n * Aims to give a first-time user enough to (1) install dependencies,\n * (2) fill in their profile data, (3) provision Cloudflare KV + admin\n * secret, and (4) `pnpm dev` / `pnpm deploy`. Cross-references the published\n * `@takuhon/cloudflare` adapter README as the next-step reference for the\n * route map.\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\nexport interface ReadmeOptions {\n readonly projectName: string;\n readonly license: ContentLicenseFragment;\n}\n\n/**\n * Human-readable license attribution line for the README footer. Uses the\n * canonical URL when available; falls back to plain SPDX (or\n * \"All rights reserved\" for Proprietary).\n */\nfunction formatLicenseLine(license: ContentLicenseFragment): string {\n if (license.spdxId === 'Proprietary') {\n return '**Proprietary** — all rights reserved.';\n }\n if (license.url !== undefined) {\n return `[\\`${license.spdxId}\\`](${license.url})`;\n }\n return `\\`${license.spdxId}\\``;\n}\n\nexport function renderReadme(opts: ReadmeOptions): string {\n const { projectName, license } = opts;\n const licenseLine = formatLicenseLine(license);\n return `# ${projectName}\n\nA [Takuhon](https://github.com/takuhon-dev/takuhon) profile deployment, running on Cloudflare Workers.\n\n> **Status**: pre-deploy. Edit \\`takuhon.json\\`, provision Cloudflare KV, then \\`pnpm deploy\\`.\n\n## What is Takuhon?\n\nTakuhon lets you own your profile as a portable JSON document and publish it as a mobile-first profile page plus a public API (JSON-LD for AI agents and search engines included).\n\n## Setup\n\n1. **Install dependencies.**\n\n \\`\\`\\`sh\n pnpm install\n \\`\\`\\`\n\n2. **Edit your profile.** Open \\`takuhon.json\\` and replace the sample fields (\\`profile.displayName\\`, \\`links\\`, \\`careers\\`, \\`projects\\`, \\`skills\\`) with your own.\n\n3. **Create the Cloudflare KV namespaces** and copy the returned ids into \\`wrangler.toml\\`:\n\n \\`\\`\\`sh\n npx wrangler kv namespace create TAKUHON_KV\n npx wrangler kv namespace create TAKUHON_KV --preview\n \\`\\`\\`\n\n4. **Provision the admin token** as a Wrangler secret (used by \\`/api/admin/*\\`):\n\n \\`\\`\\`sh\n openssl rand -base64 32 | npx wrangler secret put TAKUHON_ADMIN_TOKEN\n \\`\\`\\`\n\n Leaving the secret unset disables admin writes entirely (every \\`PUT\\` / \\`DELETE\\` returns 401).\n\n## Develop\n\nThe Worker entry at \\`src/index.ts\\` composes the takuhon adapter via\n\\`createTakuhonWorker\\` and serves your \\`takuhon.json\\` as the fallback when\nKV has no stored profile yet.\n\n\\`\\`\\`sh\npnpm dev # runs \\`wrangler dev\\` locally\n\\`\\`\\`\n\nThe full route map (public + admin) is documented in the [\\`@takuhon/cloudflare\\` README](https://github.com/takuhon-dev/takuhon/tree/main/adapters/cloudflare#readme).\n\n## Admin\n\nThe admin form UI is served at \\`/admin\\` under a strict Content-Security-Policy. Its compiled bundle is committed in \\`admin-dist/\\` and bound as Workers Assets in \\`wrangler.toml\\`. Sign in with the admin token you set as the \\`TAKUHON_ADMIN_TOKEN\\` Wrangler secret.\n\nThe bundle is a snapshot taken when this project was created. To pick up a newer admin UI, upgrade your \\`takuhon\\` CLI and run \\`takuhon admin update\\` in this project — it replaces \\`admin-dist/\\` with the bundle shipped in your installed \\`@takuhon/cli\\` (keep your \\`@takuhon/*\\` dependencies on a matching version). To deploy without the form UI, remove the \\`[assets]\\` block from \\`wrangler.toml\\`; the Worker then falls back to a minimal inline editor.\n\n### Image uploads (optional)\n\nImage uploads are off until you bind an R2 bucket. Create one and uncomment the \\`[[r2_buckets]]\\` block in \\`wrangler.toml\\`:\n\n\\`\\`\\`sh\nnpx wrangler r2 bucket create ${projectName}-assets\n\\`\\`\\`\n\nThe Worker then accepts uploads at \\`POST /api/admin/assets\\` (magic-byte check, 5 MB / 4096px limits, EXIF/metadata stripping) and serves them at \\`GET /assets/*\\` with \\`X-Content-Type-Options: nosniff\\`. Without the binding, avatars stay URL-only.\n\n### Developer-activity dashboard (optional)\n\nShow your GitHub language mix / contribution calendar and WakaTime coding time on the profile. The data is synced into a snapshot ahead of time — rendering never calls GitHub or WakaTime, and the API keys never leave the sync step.\n\n1. Opt in by adding \\`settings.activity\\` to \\`takuhon.json\\`:\n\n \\`\\`\\`jsonc\n \"settings\": {\n \"activity\": {\n \"enabled\": true,\n \"github\": { \"username\": \"your-github-login\" },\n \"wakatime\": { \"username\": \"your-wakatime-username\" }\n }\n }\n \\`\\`\\`\n\n2. Provision the sync secrets (see \\`.env.example\\`): \\`TAKUHON_WAKATIME_KEY\\` is required for coding time; \\`TAKUHON_GITHUB_TOKEN\\` is optional — languages work without it, the contribution calendar needs it.\n\n \\`\\`\\`sh\n npx wrangler secret put TAKUHON_GITHUB_TOKEN\n npx wrangler secret put TAKUHON_WAKATIME_KEY\n \\`\\`\\`\n\n3. Uncomment the \\`[triggers]\\` cron block in \\`wrangler.toml\\` so the Worker refreshes the snapshot daily, or run \\`takuhon activity sync\\` locally to write an \\`activity.json\\` next to your profile for \\`takuhon build\\` / \\`dev\\`.\n\nThe snapshot is served at \\`GET /api/activity\\` while enabled; a failed sync keeps the last-known data.\n\n### GitHub profile badge\n\nThe activity card is also available as a standalone SVG you can embed as an image — e.g. in your GitHub profile \\`README.md\\`:\n\n\\`\\`\\`md\n\n\\`\\`\\`\n\nTwo ways to host it (both require \\`settings.activity.enabled\\`):\n\n- **Dynamic (Worker):** \\`GET /activity.svg\\` renders the latest snapshot on every request. Add \\`?theme=dark\\` for the dark card.\n- **Static (\\`takuhon build\\`):** writes \\`dist/activity.svg\\` and \\`dist/activity-dark.svg\\` beside the pages, so a static deploy can serve the badge too.\n\nThe card carries an opaque background, so it stays readable on either GitHub theme. To follow the viewer's OS colour scheme automatically, use \\`<picture>\\`:\n\n\\`\\`\\`html\n<picture>\n <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://your-worker.example/activity.svg?theme=dark\">\n <img alt=\"My developer activity\" src=\"https://your-worker.example/activity.svg\">\n</picture>\n\\`\\`\\`\n\nGitHub proxies the image through Camo and caches it for a few hours, so a fresh sync can take a little while to appear in your README.\n\n## Résumé / CV (optional)\n\nGenerate a print-ready CV from the same \\`takuhon.json\\` — no re-entry:\n\n\\`\\`\\`sh\nnpx takuhon build --cv\n\\`\\`\\`\n\nThis writes \\`dist/cv.html\\` (and \\`dist/<locale>/cv.html\\` for each locale) alongside the profile pages. Open it in a browser and use **Print → Save as PDF** to produce a résumé PDF. \\`npx takuhon dev\\` also serves it at \\`/cv\\` for previewing.\n\n## AI agents (MCP)\n\nYour profile is readable over the [Model Context Protocol](https://modelcontextprotocol.io) — read-only, the same data the public API exposes (with the privacy filter applied), no write access.\n\n- **Deployed:** the Worker serves a stateless MCP endpoint at \\`POST /mcp\\` (no extra binding or setup). Point an MCP client at \\`https://your-worker.example/mcp\\`. It is also advertised as \\`mcp\\` in \\`/.well-known/takuhon.json\\`.\n- **Local:** run an MCP server over stdio against your \\`takuhon.json\\`, e.g. for Claude Desktop:\n\n \\`\\`\\`jsonc\n // claude_desktop_config.json\n {\n \"mcpServers\": {\n \"my-profile\": { \"command\": \"npx\", \"args\": [\"takuhon\", \"mcp\", \"/path/to/takuhon.json\"] }\n }\n }\n \\`\\`\\`\n\nBoth expose the tools \\`get_profile\\`, \\`get_section\\`, \\`get_jsonld\\`, \\`list_locales\\` and the resources \\`takuhon://profile\\`, \\`takuhon://schema\\`.\n\n## Deploy\n\n\\`\\`\\`sh\npnpm deploy # runs \\`wrangler deploy\\`\n\\`\\`\\`\n\n## License\n\nProfile content (\\`takuhon.json\\`) is licensed under ${licenseLine}\n\nThe deployment code is your own; pick a license appropriate for it.\n`;\n}\n","/**\n * Generator for the `takuhon.json` file written into a freshly scaffolded\n * project.\n *\n * The template is a copy of `examples/minimal-profile/takuhon.json` from the\n * monorepo. It is inlined here as a TypeScript constant rather than imported\n * from `examples/` so the published `@takuhon/cli` npm package does not need\n * to ship the examples directory.\n *\n * Only `meta.contentLicense` is rewritten per the user's choice; everything\n * else is the canonical minimal profile (one career, one project, three\n * skills, `en` locale only) that downstream `@takuhon/core` validation\n * already accepts (see `packages/core/src/__tests__/examples-fixtures.test.ts`).\n */\n\nimport type { ContentLicenseFragment } from '../licenses.js';\n\n/**\n * Build the `takuhon.json` payload as a deterministic, schema-valid object.\n * `meta.contentLicense` is filled from the supplied fragment so each\n * generated project carries the user's chosen SPDX identifier (and `url` /\n * `rights` where applicable).\n */\nexport function buildTakuhonJson(license: ContentLicenseFragment): unknown {\n return {\n schemaVersion: '0.5.0',\n profile: {\n displayName: {\n en: 'Sam Lee',\n },\n },\n links: [\n {\n id: 'github',\n type: 'github',\n url: 'https://example.com/github/sam-lee',\n featured: true,\n },\n ],\n careers: [\n {\n id: 'first-job',\n organization: {\n en: 'Example Co.',\n },\n role: {\n en: 'Junior Software Engineer',\n },\n startDate: '2026-04',\n endDate: null,\n isCurrent: true,\n },\n ],\n projects: [\n {\n id: 'personal-homepage',\n title: {\n en: 'Personal homepage',\n },\n },\n ],\n skills: [\n { id: 'html', label: 'HTML' },\n { id: 'css', label: 'CSS' },\n { id: 'javascript', label: 'JavaScript' },\n ],\n contact: {},\n settings: {\n defaultLocale: 'en',\n availableLocales: ['en'],\n },\n meta: {\n contentLicense: { ...license },\n },\n };\n}\n\n/** Serialise to a UTF-8 string with trailing newline (POSIX-friendly). */\nexport function renderTakuhonJson(license: ContentLicenseFragment): string {\n return `${JSON.stringify(buildTakuhonJson(license), null, 2)}\\n`;\n}\n","/**\n * Generator for the scaffolded project's `tsconfig.json`.\n *\n * Minimal configuration that makes the generated `src/index.ts` typecheck\n * with `tsc --noEmit` in a freshly scaffolded directory. The settings\n * mirror the upstream takuhon monorepo defaults (ES2022 target, ESNext\n * modules, strict mode, `noUncheckedIndexedAccess`) and explicitly enable\n * the two flags the Worker entry depends on:\n *\n * - `resolveJsonModule` — so `import takuhonJson from '../takuhon.json'`\n * resolves at type-check time.\n * - `moduleResolution: \"Bundler\"` — so the Wrangler / esbuild-style\n * resolution (no need for explicit file extensions) is the source of\n * truth that matches what `wrangler dev` actually runs.\n *\n * `noEmit: true` keeps `tsc` purely a type-checker; Wrangler's bundler\n * produces the deployable artifact.\n */\n\nexport function renderTsconfigJson(): string {\n const config = {\n compilerOptions: {\n target: 'ES2022',\n lib: ['ES2022'],\n module: 'ESNext',\n moduleResolution: 'Bundler',\n esModuleInterop: true,\n resolveJsonModule: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n strict: true,\n noUncheckedIndexedAccess: true,\n noImplicitOverride: true,\n noFallthroughCasesInSwitch: true,\n skipLibCheck: true,\n noEmit: true,\n },\n include: ['src/**/*'],\n exclude: ['node_modules'],\n };\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n","/**\n * Generator for `src/index.ts` — the Cloudflare Worker entry file written\n * into a freshly scaffolded project.\n *\n * The generated file uses `createTakuhonWorker()` from `@takuhon/cloudflare`\n * so the scaffolded project does not need to know the internal wiring\n * (Hono router, KV-backed storage, edge cache purger, console audit logger).\n * The user's own `takuhon.json` is loaded via an ES module JSON import,\n * validated once at module load, and the resulting `Takuhon` value is\n * served as the fallback when KV has no stored profile yet.\n *\n * `wrangler.toml`'s `main` field already points at `src/index.ts`, and\n * `nodejs_compat` is enabled, so the file works under `wrangler dev` /\n * `wrangler deploy` without further configuration.\n */\n\nexport function renderWorkerIndexTs(): string {\n return `import { createTakuhonWorker } from '@takuhon/cloudflare';\nimport { validate } from '@takuhon/core';\n\n// Use the project's own takuhon.json as the fallback served when KV has no\n// stored profile yet. Validated once at module load so a malformed profile\n// fails fast rather than at first request.\nimport takuhonJson from '../takuhon.json' with { type: 'json' };\n\nconst fallback = validate(takuhonJson);\nif (!fallback.ok) {\n throw new Error(\n 'Project takuhon.json failed validation: ' +\n fallback.errors.map((e) => \\`\\${e.pointer}: \\${e.message}\\`).join('; '),\n );\n}\n\nconst fallbackTakuhon = fallback.data;\n\nexport default createTakuhonWorker({\n fallback: () => fallbackTakuhon,\n});\n`;\n}\n"],"mappings":";AAkBO,SAAS,kBAAkB,MAAuB;AACvD,SAAO,yCAAyC,KAAK,IAAI;AAC3D;AAQO,IAAM,qBAAqB;AAQ3B,SAAS,mBAAmB,aAA6B;AAC9D,MAAI,CAAC,kBAAkB,W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