beadscope 0.5.1 → 0.6.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.
Files changed (120) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/fallback-build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +4 -4
  5. package/.next/required-server-files.js +3 -3
  6. package/.next/required-server-files.json +3 -3
  7. package/.next/server/app/_global-error.html +1 -1
  8. package/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +2 -2
  15. package/.next/server/app/_not-found.rsc +4 -4
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
  18. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/.next/server/app/api/config/route.js.nft.json +1 -1
  20. package/.next/server/app/api/fs/route.js.nft.json +1 -1
  21. package/.next/server/app/api/p/[projectId]/activity/route.js.nft.json +1 -1
  22. package/.next/server/app/api/p/[projectId]/attachments/[...path]/route.js.nft.json +1 -1
  23. package/.next/server/app/api/p/[projectId]/attachments/route.js.nft.json +1 -1
  24. package/.next/server/app/api/p/[projectId]/beads/[id]/archive/route.js.nft.json +1 -1
  25. package/.next/server/app/api/p/[projectId]/beads/[id]/assist/route.js.nft.json +1 -1
  26. package/.next/server/app/api/p/[projectId]/beads/[id]/comments/route.js.nft.json +1 -1
  27. package/.next/server/app/api/p/[projectId]/beads/[id]/deps/route.js.nft.json +1 -1
  28. package/.next/server/app/api/p/[projectId]/beads/[id]/gate/route.js.nft.json +1 -1
  29. package/.next/server/app/api/p/[projectId]/beads/[id]/human/route.js.nft.json +1 -1
  30. package/.next/server/app/api/p/[projectId]/beads/[id]/route.js.nft.json +1 -1
  31. package/.next/server/app/api/p/[projectId]/beads/[id]/status/route.js.nft.json +1 -1
  32. package/.next/server/app/api/p/[projectId]/beads/route.js.nft.json +1 -1
  33. package/.next/server/app/api/p/[projectId]/beads/stream/route.js.nft.json +1 -1
  34. package/.next/server/app/api/p/[projectId]/doctor/route.js.nft.json +1 -1
  35. package/.next/server/app/api/p/[projectId]/gamification/route.js.nft.json +1 -1
  36. package/.next/server/app/api/p/[projectId]/insights/route.js.nft.json +1 -1
  37. package/.next/server/app/api/p/[projectId]/order/route.js.nft.json +1 -1
  38. package/.next/server/app/api/p/[projectId]/publish/route.js.nft.json +1 -1
  39. package/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
  40. package/.next/server/app/api/projects/route.js.nft.json +1 -1
  41. package/.next/server/app/api/telemetry/route.js.nft.json +1 -1
  42. package/.next/server/app/api/update/check/route.js +3 -3
  43. package/.next/server/app/api/update/check/route.js.nft.json +1 -1
  44. package/.next/server/app/api/update/run/route.js +3 -3
  45. package/.next/server/app/api/update/run/route.js.nft.json +1 -1
  46. package/.next/server/app/api/viewer-mode/route.js.nft.json +1 -1
  47. package/.next/server/app/index.html +2 -2
  48. package/.next/server/app/index.rsc +7 -7
  49. package/.next/server/app/index.segments/__PAGE__.segment.rsc +7 -7
  50. package/.next/server/app/index.segments/_full.segment.rsc +7 -7
  51. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  52. package/.next/server/app/p/[projectId]/page.js.nft.json +1 -1
  53. package/.next/server/app/p/[projectId]/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/page.js.nft.json +1 -1
  55. package/.next/server/app/page_client-reference-manifest.js +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__0190u3x31o2kc._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__0190u3x31o2kc._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__1-f7qk3-8a266._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__1zrubp2jc8bi0._.js +1 -1
  60. package/.next/server/chunks/_004qegokrf7fy._.js +1 -1
  61. package/.next/server/chunks/_004qegokrf7fy._.js.map +1 -1
  62. package/.next/server/chunks/_10s9tyeasgb0i._.js +1 -1
  63. package/.next/server/chunks/_10s9tyeasgb0i._.js.map +1 -1
  64. package/.next/server/chunks/_146xyuw6iu78n._.js +1 -1
  65. package/.next/server/chunks/_146xyuw6iu78n._.js.map +1 -1
  66. package/.next/server/chunks/_1n-6yntr59hz-._.js +1 -1
  67. package/.next/server/chunks/_1n-6yntr59hz-._.js.map +1 -1
  68. package/.next/server/chunks/_1tji4d-rsralm._.js +1 -1
  69. package/.next/server/chunks/lib_beads-view_ts_1fvxcrevh9zu_._.js +1 -1
  70. package/.next/server/chunks/lib_beads-view_ts_1fvxcrevh9zu_._.js.map +1 -1
  71. package/.next/server/chunks/lib_config_ts_0zrjxh_mm8sv8._.js +1 -1
  72. package/.next/server/chunks/lib_config_ts_0zrjxh_mm8sv8._.js.map +1 -1
  73. package/.next/server/chunks/ssr/[root-of-the-server]__10sjsc4ko7y98._.js +1 -1
  74. package/.next/server/chunks/ssr/[root-of-the-server]__10sjsc4ko7y98._.js.map +1 -1
  75. package/.next/server/chunks/ssr/[root-of-the-server]__1xizcyi5hek65._.js +7 -7
  76. package/.next/server/chunks/ssr/[root-of-the-server]__1xizcyi5hek65._.js.map +1 -1
  77. package/.next/server/chunks/ssr/_0_ky_k50rh6-9._.js +1 -1
  78. package/.next/server/chunks/ssr/_0_ky_k50rh6-9._.js.map +1 -1
  79. package/.next/server/chunks/ssr/_16j7dxy5pqj44._.js +291 -0
  80. package/.next/server/chunks/ssr/_16j7dxy5pqj44._.js.map +1 -0
  81. package/.next/server/chunks/ssr/_1bulx6_unf6c7._.js +3 -0
  82. package/.next/server/chunks/ssr/_1bulx6_unf6c7._.js.map +1 -0
  83. package/.next/server/chunks/ssr/_1mzldxegsozij._.js +1 -1
  84. package/.next/server/chunks/ssr/_1mzldxegsozij._.js.map +1 -1
  85. package/.next/server/chunks/ssr/_1obdc2e416ry-._.js +3 -0
  86. package/.next/server/chunks/ssr/_1obdc2e416ry-._.js.map +1 -0
  87. package/.next/server/chunks/ssr/components_launcher_tsx_1i40oht1v6miz._.js +1 -1
  88. package/.next/server/chunks/ssr/components_launcher_tsx_1i40oht1v6miz._.js.map +1 -1
  89. package/.next/server/chunks/ssr/components_providers_tsx_0thx-xfvr_dtx._.js.map +1 -1
  90. package/.next/server/middleware-build-manifest.js +3 -3
  91. package/.next/server/middleware.js.nft.json +1 -1
  92. package/.next/server/pages/404.html +2 -2
  93. package/.next/server/pages/500.html +1 -1
  94. package/.next/server/preview-props.json +3 -3
  95. package/.next/server/server-reference-manifest.js +1 -1
  96. package/.next/server/server-reference-manifest.json +1 -1
  97. package/.next/static/chunks/0gexf4-utluu4.js +1 -0
  98. package/.next/static/chunks/23nopl40nheqr.js +1 -0
  99. package/.next/static/chunks/2c10hhzk7mgkf.js +58 -0
  100. package/.next/static/chunks/2n4lv4u0xo5oz.css +3 -0
  101. package/.next/static/chunks/3m8u_309a1_fw.js +1 -0
  102. package/.next/static/chunks/3tepw2noo82tm.js +1 -0
  103. package/README.md +47 -1
  104. package/bin/beadscope.mjs +75 -32
  105. package/package.json +2 -1
  106. package/.next/server/chunks/ssr/_02mwe4ucwaopu._.js +0 -291
  107. package/.next/server/chunks/ssr/_02mwe4ucwaopu._.js.map +0 -1
  108. package/.next/server/chunks/ssr/_1020o02v8ucmf._.js +0 -3
  109. package/.next/server/chunks/ssr/_1020o02v8ucmf._.js.map +0 -1
  110. package/.next/server/chunks/ssr/_1i_x4qkev3tax._.js +0 -3
  111. package/.next/server/chunks/ssr/_1i_x4qkev3tax._.js.map +0 -1
  112. package/.next/static/chunks/07balm4l-kilq.js +0 -1
  113. package/.next/static/chunks/0lf_v5uyq3i9q.js +0 -1
  114. package/.next/static/chunks/1j-4i4b4rc0hy.js +0 -58
  115. package/.next/static/chunks/21v6r4y8vgqng.css +0 -3
  116. package/.next/static/chunks/2xh00k9l33qnb.js +0 -1
  117. package/.next/static/chunks/3yqhmu1hny1_2.js +0 -1
  118. /package/.next/static/{xa_jNrYAvP6guImijiv2P → BoR0CvHf7BXhmN1hRjwWk}/_buildManifest.js +0 -0
  119. /package/.next/static/{xa_jNrYAvP6guImijiv2P → BoR0CvHf7BXhmN1hRjwWk}/_clientMiddlewareManifest.js +0 -0
  120. /package/.next/static/{xa_jNrYAvP6guImijiv2P → BoR0CvHf7BXhmN1hRjwWk}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/config.ts"],"sourcesContent":["import \"server-only\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport { execFileSync } from \"node:child_process\";\n\n/**\n * Local app config (NOT stored in beads). Lives as a small JSON file under the\n * OS config dir. Holds the human actor used to stamp writes, the human allowlist\n * for origin detection, the poll interval, and the registry of beads projects\n * the app knows about.\n *\n * Project identity is per-request (driven by the /p/<projectId> URL), so the\n * \"active\" project is NOT stored here — only the durable list of discovered ones.\n */\nexport interface ProjectEntry {\n id: string;\n name: string;\n path: string;\n /** ISO timestamps. */\n addedAt: string;\n lastOpened: string;\n}\n\nexport interface AppConfig {\n humanActor: string;\n humanAllowlist: string[];\n pollIntervalMs: number;\n projects: ProjectEntry[];\n /**\n * Manual board ordering, kept app-local (NOT in beads): projectId → columnId →\n * ordered bead ids. Lets users drag beads within a column to set work order.\n */\n orders: Record<string, Record<string, string[]>>;\n /** Opt-in: show the gamification XP/level layer (off by default). */\n gamification: boolean;\n /**\n * True once the human actor was saved from Settings. Until then the actor\n * follows the computed default, even if an older version wrote it to disk.\n */\n humanActorChosen?: boolean;\n}\n\n/**\n * The built-in demo dataset, surfaced as an always-available pseudo-project.\n * It has no filesystem path; the store resolver maps it to the in-memory store.\n */\nexport const DEMO_PROJECT = {\n id: \"demo\",\n name: \"Demo\",\n path: null,\n} as const;\nexport type DemoProject = typeof DEMO_PROJECT;\n\nexport class ConfigError extends Error {\n code: string;\n constructor(message: string, code: string) {\n super(message);\n this.name = \"ConfigError\";\n this.code = code;\n }\n}\n\n/**\n * BEADSCOPE_READ_ONLY=1 (or \"true\") supplies the default for new browser sessions.\n * The session cookie overrides that default when the user changes the mode.\n * In the effective read-only mode, project writes are refused server-side and\n * editing controls are disabled. App settings remain available.\n */\nexport const VIEWER_MODE_COOKIE = \"beadscope-viewer-mode\";\n\nexport function isReadOnly(request?: Request): boolean {\n // This is a browser preference, not an authorization boundary. A session\n // cookie lets one browser override the launch default without affecting others.\n const cookie = request?.headers.get(\"cookie\")?.split(\";\").map((v) => v.trim())\n .find((v) => v.startsWith(`${VIEWER_MODE_COOKIE}=`))?.slice(VIEWER_MODE_COOKIE.length + 1);\n if (cookie === \"read-only\") return true;\n if (cookie === \"editing\") return false;\n const v = process.env.BEADSCOPE_READ_ONLY;\n return v === \"1\" || v === \"true\";\n}\n\n/**\n * Focus-view lane chips: BEADSCOPE_LANE_PREFIX names a label prefix (e.g. \"ctx:\")\n * whose values partition work into lanes/teams/areas. When set, the Focus view\n * offers one filter chip per lane label found on the visible beads. Unset →\n * no chips (the feature is invisible).\n */\nexport function lanePrefix(): string | null {\n return process.env.BEADSCOPE_LANE_PREFIX || null;\n}\n\nexport function configDir(): string {\n const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), \".config\");\n return path.join(base, \"beadscope\");\n}\nfunction configFile(): string {\n return path.join(configDir(), \"config.json\");\n}\n\nfunction osUserName(): string {\n try {\n return os.userInfo().username || \"you\";\n } catch {\n return \"you\";\n }\n}\n\n/** git's user.name as seen from the launch directory, or null without git or a name. */\nfunction gitUserName(): string | null {\n try {\n const name = execFileSync(\"git\", [\"config\", \"--get\", \"user.name\"], {\n cwd: process.cwd(),\n encoding: \"utf8\",\n timeout: 2000,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n return name || null;\n } catch {\n return null;\n }\n}\n\nfunction defaults(): AppConfig {\n // Same order as bd's own actor (`bd --help`, --actor): BEADS_ACTOR, then git\n // user.name, then the OS user. If Beadscope stamped writes with the OS name\n // while `bd update --claim` used the git name, bd would refuse to let the UI\n // close beads the user claimed from the CLI.\n const humanActor = process.env.BEADS_ACTOR || gitUserName() || osUserName();\n return {\n humanActor,\n humanAllowlist: [humanActor],\n // Fallback refresh interval. The SSE change stream (see lib/beads-watch)\n // drives fast updates; this interval only backstops a dropped stream.\n pollIntervalMs: 30000,\n projects: [],\n orders: {},\n gamification: false,\n };\n}\n\n// ---- helpers -------------------------------------------------------------\n\nfunction hasBeads(p: string): boolean {\n try {\n return fs.existsSync(path.join(p, \".beads\"));\n } catch {\n return false;\n }\n}\nfunction realpathOrSelf(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return path.resolve(p);\n }\n}\nfunction sameDir(a: string, b: string): boolean {\n return realpathOrSelf(a) === realpathOrSelf(b);\n}\nfunction slug(s: string): string {\n return (\n s\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"project\"\n );\n}\nfunction makeId(absPath: string, taken: Set<string>): string {\n const base = slug(path.basename(absPath));\n let id = base;\n while (taken.has(id) || id === DEMO_PROJECT.id) {\n id = `${base}-${Math.random().toString(36).slice(2, 6)}`;\n }\n return id;\n}\nfunction makeEntry(inputPath: string, taken: Set<string>): ProjectEntry {\n const abs = path.resolve(inputPath);\n const now = new Date().toISOString();\n return {\n id: makeId(abs, taken),\n name: path.basename(abs) || abs,\n path: abs,\n addedAt: now,\n lastOpened: now,\n };\n}\n\n/** Drop malformed registry entries so a bad config file never crashes startup. */\nfunction sanitizeProjects(input: unknown): ProjectEntry[] {\n if (!Array.isArray(input)) return [];\n const out: ProjectEntry[] = [];\n const seen = new Set<string>();\n for (const it of input) {\n if (!it || typeof it !== \"object\") continue;\n const e = it as Record<string, unknown>;\n if (typeof e.id !== \"string\" || typeof e.path !== \"string\") continue;\n if (e.id === DEMO_PROJECT.id || seen.has(e.id)) continue;\n seen.add(e.id);\n out.push({\n id: e.id,\n path: e.path,\n name: typeof e.name === \"string\" && e.name ? e.name : path.basename(e.path) || e.path,\n addedAt: typeof e.addedAt === \"string\" ? e.addedAt : new Date().toISOString(),\n lastOpened: typeof e.lastOpened === \"string\" ? e.lastOpened : new Date().toISOString(),\n });\n }\n return out;\n}\n\n// ---- load / persist ------------------------------------------------------\n\nlet cached: AppConfig | null = null;\n\n/**\n * Persist the config, preserving any unknown keys already on disk (e.g. the\n * legacy `repoPath`/`demo` fields) so older app versions can still read them.\n */\nfunction persist(cfg: AppConfig): void {\n cached = cfg;\n try {\n fs.mkdirSync(configDir(), { recursive: true });\n let base: Record<string, unknown> = {};\n try {\n base = JSON.parse(fs.readFileSync(configFile(), \"utf8\")) as Record<string, unknown>;\n } catch {\n base = {};\n }\n const next = { ...base, ...cfg };\n fs.writeFileSync(configFile(), JSON.stringify(next, null, 2), \"utf8\");\n } catch {\n /* best-effort; config still applies for the session */\n }\n}\n\nexport function getConfig(): AppConfig {\n if (cached) return cached;\n const d = defaults();\n\n let onDisk:\n | (Partial<AppConfig> & { repoPath?: string; demo?: boolean })\n | null = null;\n try {\n onDisk = JSON.parse(fs.readFileSync(configFile(), \"utf8\"));\n } catch {\n onDisk = null;\n }\n\n // Before 0.3.1 the computed default (the OS user) was written to disk along\n // with the first project, so an unchosen OS username on disk is a stale\n // default rather than a preference. Replace it, and keep the new actor in the\n // allowlist so the user's own writes still render as human.\n const staleActor =\n !onDisk?.humanActorChosen && onDisk?.humanActor === osUserName() && d.humanActor !== onDisk.humanActor;\n const storedAllowlist = onDisk?.humanAllowlist && onDisk.humanAllowlist.length ? onDisk.humanAllowlist : null;\n const merged: AppConfig = {\n humanActor: staleActor ? d.humanActor : onDisk?.humanActor || d.humanActor,\n humanAllowlist: !storedAllowlist\n ? d.humanAllowlist\n : staleActor && !storedAllowlist.includes(d.humanActor)\n ? [...storedAllowlist, d.humanActor]\n : storedAllowlist,\n pollIntervalMs:\n typeof onDisk?.pollIntervalMs === \"number\" ? onDisk.pollIntervalMs : d.pollIntervalMs,\n projects: sanitizeProjects(onDisk?.projects),\n orders:\n onDisk?.orders && typeof onDisk.orders === \"object\" && !Array.isArray(onDisk.orders)\n ? (onDisk.orders as Record<string, Record<string, string[]>>)\n : {},\n gamification: typeof onDisk?.gamification === \"boolean\" ? onDisk.gamification : d.gamification,\n humanActorChosen: onDisk?.humanActorChosen === true,\n };\n\n // One-time migration: back-fill the registry from the legacy single repoPath\n // (or BEADS_REPO / cwd) when no projects array exists yet.\n let migrated = false;\n if (!onDisk || onDisk.projects === undefined) {\n const legacyPath = onDisk?.repoPath || process.env.BEADS_REPO || process.cwd();\n if (\n legacyPath &&\n hasBeads(legacyPath) &&\n !merged.projects.some((p) => sameDir(p.path, legacyPath))\n ) {\n merged.projects.push(makeEntry(legacyPath, new Set(merged.projects.map((p) => p.id))));\n migrated = true;\n }\n }\n\n cached = merged;\n // Persist the migrated entry so its id is stable across restarts.\n if (migrated) persist(merged);\n return cached;\n}\n\n/**\n * The actor to close a bead as. bd refuses to close a claimed bead as anyone\n * but its assignee. Before 0.3.1 Beadscope wrote as the OS user, so beads people\n * assigned to themselves then still carry that name. It is the same person on\n * this machine, so close those as it rather than failing — #61 in reverse.\n * Every other assignee (a teammate, an agent) keeps bd's protection.\n */\nexport function closeActor(assignee: string | null | undefined): string {\n const { humanActor } = getConfig();\n return assignee && assignee !== humanActor && assignee === osUserName() ? assignee : humanActor;\n}\n\n/** Update global settings (actor / allowlist / poll). Project registry has its own mutators. */\nexport function saveConfig(\n patch: Partial<Pick<AppConfig, \"humanActor\" | \"humanAllowlist\" | \"pollIntervalMs\" | \"gamification\">>,\n): AppConfig {\n const next = { ...getConfig(), ...patch };\n if (patch.humanActor !== undefined) next.humanActorChosen = true;\n persist(next);\n return next;\n}\n\n// ---- project registry ----------------------------------------------------\n\nexport function listProjects(): ProjectEntry[] {\n return getConfig().projects;\n}\n\nexport function getProject(id: string): ProjectEntry | DemoProject | undefined {\n if (id === DEMO_PROJECT.id) return DEMO_PROJECT;\n return getConfig().projects.find((p) => p.id === id);\n}\n\n/** Add (or re-touch) a project by folder path. Validates a `.beads` dir exists. */\nexport function addProject(inputPath: string): ProjectEntry {\n const cfg = getConfig();\n const abs = path.resolve(inputPath);\n if (!hasBeads(abs)) {\n throw new ConfigError(`No .beads directory found in ${abs}`, \"no_beads\");\n }\n const existing = cfg.projects.find((p) => sameDir(p.path, abs));\n if (existing) {\n existing.lastOpened = new Date().toISOString();\n persist(cfg);\n return existing;\n }\n const entry = makeEntry(abs, new Set(cfg.projects.map((p) => p.id)));\n cfg.projects.push(entry);\n persist(cfg);\n return entry;\n}\n\nexport function removeProject(id: string): void {\n const cfg = getConfig();\n cfg.projects = cfg.projects.filter((p) => p.id !== id);\n // Drop any saved board ordering for the removed project so it can't orphan.\n if (cfg.orders[id]) {\n const rest = { ...cfg.orders };\n delete rest[id];\n cfg.orders = rest;\n }\n persist(cfg);\n}\n\nexport function touchProject(id: string): void {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (p) {\n p.lastOpened = new Date().toISOString();\n persist(cfg);\n }\n}\n\nexport function renameProject(id: string, name: string): ProjectEntry | undefined {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (!p) return undefined;\n p.name = name;\n persist(cfg);\n return p;\n}\n\n// ---- manual board ordering ------------------------------------------------\n\n/** All saved column orders for a project: columnId → ordered bead ids. */\nexport function getColumnOrders(projectId: string): Record<string, string[]> {\n return getConfig().orders[projectId] ?? {};\n}\n\n/** Replace the saved order for one column of one project. */\nexport function setColumnOrder(\n projectId: string,\n columnId: string,\n ids: string[],\n): Record<string, string[]> {\n const cfg = getConfig();\n const proj = { ...(cfg.orders[projectId] ?? {}) };\n proj[columnId] = ids;\n cfg.orders = { ...cfg.orders, [projectId]: proj };\n persist(cfg);\n return proj;\n}\n"],"names":["DEMO_PROJECT","id","name","path","ConfigError","Error","code","message","VIEWER_MODE_COOKIE","isReadOnly","request","cookie","headers","get","split","map","v","trim","find","startsWith","slice","length","process","env","BEADSCOPE_READ_ONLY","lanePrefix","BEADSCOPE_LANE_PREFIX","configDir","base","XDG_CONFIG_HOME","join","homedir","configFile","osUserName","userInfo","username","gitUserName","cwd","encoding","timeout","stdio","defaults","humanActor","BEADS_ACTOR","humanAllowlist","pollIntervalMs","projects","orders","gamification","hasBeads","p","existsSync","realpathOrSelf","realpathSync","resolve","sameDir","a","b","slug","s","toLowerCase","replace","makeId","absPath","taken","basename","has","Math","random","toString","makeEntry","inputPath","abs","now","Date","toISOString","addedAt","lastOpened","sanitizeProjects","input","Array","isArray","out","seen","Set","it","e","add","push","cached","persist","cfg","mkdirSync","recursive","JSON","parse","readFileSync","next","writeFileSync","stringify","getConfig","d","onDisk","staleActor","humanActorChosen","storedAllowlist","merged","includes","migrated","undefined","legacyPath","repoPath","BEADS_REPO","some","closeActor","assignee","saveConfig","patch","listProjects","getProject","addProject","existing","entry","removeProject","filter","rest","touchProject","x","renameProject","getColumnOrders","projectId","setColumnOrder","columnId","ids","proj"],"mappings":"uCACA,IAAA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OA2CO,IAAMA,EAAe,CAC1BC,GAAI,OACJC,KAAM,OACNC,KAAM,IACR,CAGO,OAAMC,UAAoBC,MAC/BC,IAAa,AACbF,aAAYG,CAAe,CAAED,CAAY,CAAE,CACzC,KAAK,CAACC,GACN,IAAI,CAACL,IAAI,CAAG,cACZ,IAAI,CAACI,IAAI,CAAGA,CACd,CACF,CAQO,IAAME,EAAqB,wBAuB3B,SAASmB,IACd,IAAMC,EAAON,QAAQC,GAAG,CAACM,eAAe,EAAI,EAAA,OAAI,CAACC,IAAI,CAAC,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MA,EAAE9H,EAAE,GAAKA,GACxCiD,GAAG,CACLA,EAAE2B,UAAU,CAAG,IAAIH,OAAOC,WAAW,GACrCe,EAAQC,GAEZ"}
1
+ {"version":3,"sources":["../../../lib/config.ts","../../../lib/agents.ts"],"sourcesContent":["import \"server-only\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport { execFileSync } from \"node:child_process\";\nimport { defaultAgents, normalizeAgents, validateAgents, type AgentIdentity } from \"./agents.ts\";\n\n/**\n * Local app config (NOT stored in beads). Lives as a small JSON file under the\n * OS config dir. Holds the human actor used to stamp writes, the human allowlist\n * for origin detection, the poll interval, and the registry of beads projects\n * the app knows about.\n *\n * Project identity is per-request (driven by the /p/<projectId> URL), so the\n * \"active\" project is NOT stored here — only the durable list of discovered ones.\n */\nexport interface ProjectEntry {\n id: string;\n name: string;\n path: string;\n /** ISO timestamps. */\n addedAt: string;\n lastOpened: string;\n}\n\nexport interface AppConfig {\n humanActor: string;\n humanAllowlist: string[];\n /** Agent identities (the assignee picker choices); see lib/agents.ts. */\n agents: AgentIdentity[];\n pollIntervalMs: number;\n projects: ProjectEntry[];\n /**\n * Manual board ordering, kept app-local (NOT in beads): projectId → columnId →\n * ordered bead ids. Lets users drag beads within a column to set work order.\n */\n orders: Record<string, Record<string, string[]>>;\n /** Opt-in: show the gamification XP/level layer (off by default). */\n gamification: boolean;\n /**\n * True once the human actor was saved from Settings. Until then the actor\n * follows the computed default, even if an older version wrote it to disk.\n */\n humanActorChosen?: boolean;\n}\n\n/**\n * The built-in demo dataset, surfaced as an always-available pseudo-project.\n * It has no filesystem path; the store resolver maps it to the in-memory store.\n */\nexport const DEMO_PROJECT = {\n id: \"demo\",\n name: \"Demo\",\n path: null,\n} as const;\nexport type DemoProject = typeof DEMO_PROJECT;\n\nexport class ConfigError extends Error {\n code: string;\n constructor(message: string, code: string) {\n super(message);\n this.name = \"ConfigError\";\n this.code = code;\n }\n}\n\n/**\n * BEADSCOPE_READ_ONLY=1 (or \"true\") supplies the default for new browser sessions.\n * The session cookie overrides that default when the user changes the mode.\n * In the effective read-only mode, project writes are refused server-side and\n * editing controls are disabled. App settings remain available.\n */\nexport const VIEWER_MODE_COOKIE = \"beadscope-viewer-mode\";\n\nexport function isReadOnly(request?: Request): boolean {\n // This is a browser preference, not an authorization boundary. A session\n // cookie lets one browser override the launch default without affecting others.\n const cookie = request?.headers.get(\"cookie\")?.split(\";\").map((v) => v.trim())\n .find((v) => v.startsWith(`${VIEWER_MODE_COOKIE}=`))?.slice(VIEWER_MODE_COOKIE.length + 1);\n if (cookie === \"read-only\") return true;\n if (cookie === \"editing\") return false;\n const v = process.env.BEADSCOPE_READ_ONLY;\n return v === \"1\" || v === \"true\";\n}\n\n/**\n * Focus-view lane chips: BEADSCOPE_LANE_PREFIX names a label prefix (e.g. \"ctx:\")\n * whose values partition work into lanes/teams/areas. When set, the Focus view\n * offers one filter chip per lane label found on the visible beads. Unset →\n * no chips (the feature is invisible).\n */\nexport function lanePrefix(): string | null {\n return process.env.BEADSCOPE_LANE_PREFIX || null;\n}\n\nexport function configDir(): string {\n const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), \".config\");\n return path.join(base, \"beadscope\");\n}\nfunction configFile(): string {\n return path.join(configDir(), \"config.json\");\n}\n\nfunction osUserName(): string {\n try {\n return os.userInfo().username || \"you\";\n } catch {\n return \"you\";\n }\n}\n\n/** git's user.name as seen from the launch directory, or null without git or a name. */\nfunction gitUserName(): string | null {\n try {\n const name = execFileSync(\"git\", [\"config\", \"--get\", \"user.name\"], {\n cwd: process.cwd(),\n encoding: \"utf8\",\n timeout: 2000,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n return name || null;\n } catch {\n return null;\n }\n}\n\nfunction defaults(): AppConfig {\n // Same order as bd's own actor (`bd --help`, --actor): BEADS_ACTOR, then git\n // user.name, then the OS user. If Beadscope stamped writes with the OS name\n // while `bd update --claim` used the git name, bd would refuse to let the UI\n // close beads the user claimed from the CLI.\n const humanActor = process.env.BEADS_ACTOR || gitUserName() || osUserName();\n return {\n humanActor,\n humanAllowlist: [humanActor],\n agents: defaultAgents(),\n // Fallback refresh interval. The SSE change stream (see lib/beads-watch)\n // drives fast updates; this interval only backstops a dropped stream.\n pollIntervalMs: 30000,\n projects: [],\n orders: {},\n gamification: false,\n };\n}\n\n// ---- helpers -------------------------------------------------------------\n\n/**\n * Whether `p` holds a beads workspace. bd also keeps per-user state (a machine-id\n * and an event queue) in `~/.beads`; that folder is not a workspace, so it must not\n * make the home directory look like a project. A workspace has a config.yaml or\n * metadata.json next to its database.\n */\nexport function hasBeads(p: string): boolean {\n try {\n const dir = path.join(p, \".beads\");\n if (!fs.existsSync(dir)) return false;\n const isUserStateDir =\n fs.existsSync(path.join(dir, \"machine-id\")) &&\n !fs.existsSync(path.join(dir, \"config.yaml\")) &&\n !fs.existsSync(path.join(dir, \"metadata.json\"));\n return !isUserStateDir;\n } catch {\n return false;\n }\n}\nfunction realpathOrSelf(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return path.resolve(p);\n }\n}\nfunction sameDir(a: string, b: string): boolean {\n return realpathOrSelf(a) === realpathOrSelf(b);\n}\nfunction slug(s: string): string {\n return (\n s\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"project\"\n );\n}\nfunction makeId(absPath: string, taken: Set<string>): string {\n const base = slug(path.basename(absPath));\n let id = base;\n while (taken.has(id) || id === DEMO_PROJECT.id) {\n id = `${base}-${Math.random().toString(36).slice(2, 6)}`;\n }\n return id;\n}\nfunction makeEntry(inputPath: string, taken: Set<string>): ProjectEntry {\n const abs = path.resolve(inputPath);\n const now = new Date().toISOString();\n return {\n id: makeId(abs, taken),\n name: path.basename(abs) || abs,\n path: abs,\n addedAt: now,\n lastOpened: now,\n };\n}\n\n/** Drop malformed registry entries so a bad config file never crashes startup. */\nfunction sanitizeProjects(input: unknown): ProjectEntry[] {\n if (!Array.isArray(input)) return [];\n const out: ProjectEntry[] = [];\n const seen = new Set<string>();\n for (const it of input) {\n if (!it || typeof it !== \"object\") continue;\n const e = it as Record<string, unknown>;\n if (typeof e.id !== \"string\" || typeof e.path !== \"string\") continue;\n if (e.id === DEMO_PROJECT.id || seen.has(e.id)) continue;\n seen.add(e.id);\n out.push({\n id: e.id,\n path: e.path,\n name: typeof e.name === \"string\" && e.name ? e.name : path.basename(e.path) || e.path,\n addedAt: typeof e.addedAt === \"string\" ? e.addedAt : new Date().toISOString(),\n lastOpened: typeof e.lastOpened === \"string\" ? e.lastOpened : new Date().toISOString(),\n });\n }\n return out;\n}\n\n// ---- load / persist ------------------------------------------------------\n\n// Keyed off globalThis, not module scope: the page renderer (generateMetadata) and the API route\n// handlers are separate bundles with their own copy of this module, so a module-level cache would\n// leave the page showing the old project name after a rename.\nconst CACHE_KEY = Symbol.for(\"beadscope.config.cache\");\ntype CacheHolder = Record<symbol, AppConfig | null | undefined>;\nfunction readCache(): AppConfig | null {\n return (globalThis as unknown as CacheHolder)[CACHE_KEY] ?? null;\n}\nfunction writeCache(cfg: AppConfig | null): void {\n (globalThis as unknown as CacheHolder)[CACHE_KEY] = cfg;\n}\n\n/**\n * Persist the config, preserving any unknown keys already on disk (e.g. the\n * legacy `repoPath`/`demo` fields) so older app versions can still read them.\n */\nfunction persist(cfg: AppConfig): void {\n writeCache(cfg);\n try {\n fs.mkdirSync(configDir(), { recursive: true });\n let base: Record<string, unknown> = {};\n try {\n base = JSON.parse(fs.readFileSync(configFile(), \"utf8\")) as Record<string, unknown>;\n } catch {\n base = {};\n }\n const next = { ...base, ...cfg };\n fs.writeFileSync(configFile(), JSON.stringify(next, null, 2), \"utf8\");\n } catch {\n /* best-effort; config still applies for the session */\n }\n}\n\nexport function getConfig(): AppConfig {\n const hit = readCache();\n if (hit) return hit;\n const d = defaults();\n\n let onDisk:\n | (Partial<AppConfig> & { repoPath?: string; demo?: boolean })\n | null = null;\n try {\n onDisk = JSON.parse(fs.readFileSync(configFile(), \"utf8\"));\n } catch {\n onDisk = null;\n }\n\n // Before 0.3.1 the computed default (the OS user) was written to disk along\n // with the first project, so an unchosen OS username on disk is a stale\n // default rather than a preference. Replace it, and keep the new actor in the\n // allowlist so the user's own writes still render as human.\n const staleActor =\n !onDisk?.humanActorChosen && onDisk?.humanActor === osUserName() && d.humanActor !== onDisk.humanActor;\n const storedAllowlist = onDisk?.humanAllowlist && onDisk.humanAllowlist.length ? onDisk.humanAllowlist : null;\n const merged: AppConfig = {\n humanActor: staleActor ? d.humanActor : onDisk?.humanActor || d.humanActor,\n humanAllowlist: !storedAllowlist\n ? d.humanAllowlist\n : staleActor && !storedAllowlist.includes(d.humanActor)\n ? [...storedAllowlist, d.humanActor]\n : storedAllowlist,\n agents: normalizeAgents(onDisk?.agents),\n pollIntervalMs:\n typeof onDisk?.pollIntervalMs === \"number\" ? onDisk.pollIntervalMs : d.pollIntervalMs,\n projects: sanitizeProjects(onDisk?.projects),\n orders:\n onDisk?.orders && typeof onDisk.orders === \"object\" && !Array.isArray(onDisk.orders)\n ? (onDisk.orders as Record<string, Record<string, string[]>>)\n : {},\n gamification: typeof onDisk?.gamification === \"boolean\" ? onDisk.gamification : d.gamification,\n humanActorChosen: onDisk?.humanActorChosen === true,\n };\n\n // One-time migration: back-fill the registry from the legacy single repoPath\n // (or BEADS_REPO / cwd) when no projects array exists yet.\n let migrated = false;\n if (!onDisk || onDisk.projects === undefined) {\n const legacyPath = onDisk?.repoPath || process.env.BEADS_REPO || process.cwd();\n if (\n legacyPath &&\n hasBeads(legacyPath) &&\n !merged.projects.some((p) => sameDir(p.path, legacyPath))\n ) {\n merged.projects.push(makeEntry(legacyPath, new Set(merged.projects.map((p) => p.id))));\n migrated = true;\n }\n }\n\n writeCache(merged);\n // Persist the migrated entry so its id is stable across restarts.\n if (migrated) persist(merged);\n return merged;\n}\n\n/**\n * The actor to close a bead as. bd refuses to close a claimed bead as anyone\n * but its assignee. Before 0.3.1 Beadscope wrote as the OS user, so beads people\n * assigned to themselves then still carry that name. It is the same person on\n * this machine, so close those as it rather than failing — #61 in reverse.\n * Every other assignee (a teammate, an agent) keeps bd's protection.\n */\nexport function closeActor(assignee: string | null | undefined): string {\n const { humanActor } = getConfig();\n return assignee && assignee !== humanActor && assignee === osUserName() ? assignee : humanActor;\n}\n\n/** Update global settings (actor / allowlist / poll). Project registry has its own mutators. */\nexport function saveConfig(\n patch: Partial<Pick<AppConfig, \"humanActor\" | \"humanAllowlist\" | \"agents\" | \"pollIntervalMs\" | \"gamification\">>,\n): AppConfig {\n const current = getConfig();\n const next = { ...current, ...patch };\n if (patch.humanActor !== undefined) next.humanActorChosen = true;\n // Check the names as sent (before normalizing quietly repairs an empty one), against\n // the humans being saved, so an agent cannot take a human name.\n if (patch.agents !== undefined || patch.humanActor !== undefined || patch.humanAllowlist !== undefined) {\n const problem = validateAgents(patch.agents ?? next.agents, [next.humanActor, ...next.humanAllowlist]);\n if (problem) throw new ConfigError(problem, \"invalid_agents\");\n }\n if (patch.agents !== undefined) next.agents = normalizeAgents(patch.agents);\n persist(next);\n return next;\n}\n\n// ---- project registry ----------------------------------------------------\n\nexport function listProjects(): ProjectEntry[] {\n return getConfig().projects;\n}\n\nexport function getProject(id: string): ProjectEntry | DemoProject | undefined {\n if (id === DEMO_PROJECT.id) return DEMO_PROJECT;\n return getConfig().projects.find((p) => p.id === id);\n}\n\n/** Add (or re-touch) a project by folder path. Validates a `.beads` dir exists. */\nexport function addProject(inputPath: string): ProjectEntry {\n const cfg = getConfig();\n const abs = path.resolve(inputPath);\n if (!hasBeads(abs)) {\n throw new ConfigError(`No .beads directory found in ${abs}`, \"no_beads\");\n }\n const existing = cfg.projects.find((p) => sameDir(p.path, abs));\n if (existing) {\n existing.lastOpened = new Date().toISOString();\n persist(cfg);\n return existing;\n }\n const entry = makeEntry(abs, new Set(cfg.projects.map((p) => p.id)));\n cfg.projects.push(entry);\n persist(cfg);\n return entry;\n}\n\nexport function removeProject(id: string): void {\n const cfg = getConfig();\n cfg.projects = cfg.projects.filter((p) => p.id !== id);\n // Drop any saved board ordering for the removed project so it can't orphan.\n if (cfg.orders[id]) {\n const rest = { ...cfg.orders };\n delete rest[id];\n cfg.orders = rest;\n }\n persist(cfg);\n}\n\nexport function touchProject(id: string): void {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (p) {\n p.lastOpened = new Date().toISOString();\n persist(cfg);\n }\n}\n\nexport function renameProject(id: string, name: string): ProjectEntry | undefined {\n const cfg = getConfig();\n const p = cfg.projects.find((x) => x.id === id);\n if (!p) return undefined;\n p.name = name;\n persist(cfg);\n return p;\n}\n\n// ---- manual board ordering ------------------------------------------------\n\n/** All saved column orders for a project: columnId → ordered bead ids. */\nexport function getColumnOrders(projectId: string): Record<string, string[]> {\n return getConfig().orders[projectId] ?? {};\n}\n\n/** Replace the saved order for one column of one project. */\nexport function setColumnOrder(\n projectId: string,\n columnId: string,\n ids: string[],\n): Record<string, string[]> {\n const cfg = getConfig();\n const proj = { ...(cfg.orders[projectId] ?? {}) };\n proj[columnId] = ids;\n cfg.orders = { ...cfg.orders, [projectId]: proj };\n persist(cfg);\n return proj;\n}\n","/**\n * Agent identities: the names an AI agent works under (the `bd` actor string),\n * managed in Settings. Shared by the server (config) and the UI, so this file\n * must not import anything server-only.\n *\n * An identity only labels and offers a name. `bd` stores the plain string in\n * `assignee` / `created_by`; Beadscope already treats any name that is not on the\n * human allowlist as an agent (lib/attribution.ts), so identities do not change\n * that rule. They give the assignee picker its choices and give those names an icon.\n */\n\n/** What is stored in config.json. */\nexport interface AgentIdentity {\n /**\n * Stable key. Renaming an identity changes `name`, never `id`. Pre-defined\n * identities use their preset key (\"claude-code\"); user-added ones \"custom-…\".\n */\n id: string;\n /** The actor name: what `bd` records as the assignee. Editable. */\n name: string;\n /** Only enabled identities are offered in the assignee picker. */\n enabled: boolean;\n /** User-added identities only: a stock emoji from AGENT_EMOJIS. Wins over `color`. */\n emoji?: string;\n /** User-added identities only: a colour from AGENT_COLORS. */\n color?: string;\n}\n\nexport interface AgentPreset {\n id: string;\n /** The default actor name. */\n name: string;\n /** Product name shown beside the name in Settings. */\n label: string;\n /** Brand colour behind the icon. */\n color: string;\n /** Enabled the first time Beadscope sees it. */\n enabled: boolean;\n}\n\n/** Pre-defined identities, in display order. They can be disabled and renamed, not deleted. */\nexport const AGENT_PRESETS: AgentPreset[] = [\n { id: \"claude-code\", name: \"claude-code\", label: \"Claude Code\", color: \"#d97757\", enabled: true },\n { id: \"codex\", name: \"codex\", label: \"Codex\", color: \"#10a37f\", enabled: false },\n { id: \"cursor\", name: \"cursor-agent\", label: \"Cursor\", color: \"#4b5563\", enabled: false },\n { id: \"gemini\", name: \"gemini\", label: \"Gemini CLI\", color: \"#4285f4\", enabled: false },\n { id: \"copilot\", name: \"copilot\", label: \"GitHub Copilot\", color: \"#8957e5\", enabled: false },\n];\n\n/** Stock emoji for identities the user adds. */\nexport const AGENT_EMOJIS = [\n \"🤖\", \"🧠\", \"⚡\", \"🛠️\", \"🚀\", \"🦾\", \"🔮\", \"🛰️\",\n \"🦉\", \"🐙\", \"🦊\", \"🐱\", \"🧪\", \"🎯\", \"🌟\", \"🧩\",\n];\n\n/** Colours for identities the user adds (shown behind the initials). */\nexport const AGENT_COLORS = [\n \"#ef4444\", \"#f97316\", \"#eab308\", \"#22c55e\",\n \"#14b8a6\", \"#3b82f6\", \"#8b5cf6\", \"#ec4899\",\n];\n\nexport const DEFAULT_AGENT_COLOR = AGENT_COLORS[5];\nexport const MAX_AGENT_NAME = 64;\n\nexport function presetOf(id: string): AgentPreset | undefined {\n return AGENT_PRESETS.find((p) => p.id === id);\n}\n\nexport function defaultAgents(): AgentIdentity[] {\n return AGENT_PRESETS.map((p) => ({ id: p.id, name: p.name, enabled: p.enabled }));\n}\n\n/**\n * Turn whatever is on disk (or in a request) into a clean list: every preset\n * present and in order, then the user's own, with unknown fields dropped.\n * Never throws, so a bad config file cannot break startup.\n */\nexport function normalizeAgents(input: unknown): AgentIdentity[] {\n const stored = new Map<string, Record<string, unknown>>();\n const custom: AgentIdentity[] = [];\n if (Array.isArray(input)) {\n for (const item of input) {\n if (!item || typeof item !== \"object\") continue;\n const e = item as Record<string, unknown>;\n if (typeof e.id !== \"string\" || !e.id || stored.has(e.id)) continue;\n stored.set(e.id, e);\n }\n }\n const nameOf = (e: Record<string, unknown> | undefined, fallback: string) => {\n const n = typeof e?.name === \"string\" ? e.name.trim().slice(0, MAX_AGENT_NAME) : \"\";\n return n || fallback;\n };\n const out: AgentIdentity[] = AGENT_PRESETS.map((p) => {\n const e = stored.get(p.id);\n return {\n id: p.id,\n name: nameOf(e, p.name),\n enabled: typeof e?.enabled === \"boolean\" ? e.enabled : p.enabled,\n };\n });\n for (const [id, e] of stored) {\n if (presetOf(id) || !id.startsWith(\"custom-\")) continue;\n const name = nameOf(e, \"\");\n if (!name) continue;\n const agent: AgentIdentity = { id, name, enabled: e.enabled !== false };\n if (typeof e.emoji === \"string\" && AGENT_EMOJIS.includes(e.emoji)) agent.emoji = e.emoji;\n if (typeof e.color === \"string\" && AGENT_COLORS.includes(e.color)) agent.color = e.color;\n custom.push(agent);\n }\n return [...out, ...custom];\n}\n\n/**\n * Check a list a user is saving. Returns a message for the first problem, or\n * null. Names must be unique (ignoring case) and must not collide with a human\n * name, which would make the agent's work render as human's.\n */\nexport function validateAgents(agents: AgentIdentity[], humanNames: string[]): string | null {\n const seen = new Set<string>();\n const humans = new Set(humanNames.map((n) => n.trim().toLowerCase()).filter(Boolean));\n for (const a of agents) {\n const name = a.name.trim();\n if (!name) return \"Every agent needs a name.\";\n if (name.length > MAX_AGENT_NAME) return `Agent names are at most ${MAX_AGENT_NAME} characters.`;\n if (/[\\u0000-\\u001f\\u007f]/.test(name)) return \"Agent names cannot contain control characters.\";\n const key = name.toLowerCase();\n if (humans.has(key)) return `\"${name}\" is a human name (the human actor or allowlist); agents need their own.`;\n if (seen.has(key)) return `\"${name}\" is used twice. Agent names must be unique.`;\n seen.add(key);\n }\n return null;\n}\n\n/** Enabled identities' names, in list order: what the assignee picker offers. */\nexport function enabledAgentNames(agents: AgentIdentity[] | undefined): string[] {\n return (agents ?? []).filter((a) => a.enabled).map((a) => a.name);\n}\n\n/** The identity an assignee name belongs to, enabled or not (so old beads keep their icon). */\nexport function agentByName(agents: AgentIdentity[] | undefined, name: string | null | undefined): AgentIdentity | undefined {\n const key = name?.trim().toLowerCase();\n if (!key) return undefined;\n return (agents ?? []).find((a) => a.name.trim().toLowerCase() === key);\n}\n\nexport function newCustomAgentId(): string {\n return `custom-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;\n}\n"],"names":["AGENT_PRESETS","id","name","label","color","enabled","AGENT_EMOJIS","AGENT_COLORS","DEFAULT_AGENT_COLOR","MAX_AGENT_NAME","presetOf","find","p","defaultAgents","map","normalizeAgents","input","stored","Map","custom","Array","isArray","item","e","has","set","nameOf","fallback","n","trim","slice","out","get","startsWith","agent","emoji","includes","push","validateAgents","agents","humanNames","seen","Set","humans","toLowerCase","filter","Boolean","a","length","test","key","add","enabledAgentNames","agentByName","undefined","newCustomAgentId","Date","now","toString","Math","random"],"mappings":"uCACA,IAAA,EAAA,EAAA,CAAA,CAAA,MACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OCqCO,IAAMA,EAA+B,CAC1C,CAAEC,GAAI,cAAeC,KAAM,cAAeC,MAAO,cAAeC,MAAO,UAAWC,SAAS,CAAK,EAChG,CAAEJ,GAAI,QAASC,KAAM,QAASC,MAAO,QAASC,MAAO,UAAWC,QAAS,EAAM,EAC/E,CAAEJ,GAAI,SAAUC,KAAM,eAAgBC,MAAO,SAAUC,MAAO,UAAWC,SAAS,CAAM,EACxF,CAAEJ,GAAI,SAAUC,KAAM,SAAUC,MAAO,aAAcC,MAAO,UAAWC,SAAS,CAAM,EACtF,CAAEJ,GAAI,UAAWC,KAAM,UAAWC,MAAO,iBAAkBC,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S,iBAC9C,CAGA,YAFqB,IAAjB,EAAM,MAAM,GAAgB,EAAK,MAAM,CAAG,EAAgB,EAAM,OAAM,EAC1E,EAAQ,GACD,CACT,QAsEO,SACL,AADc,CACG,CACjB,CAAgB,CAChB,CAAa,EAEb,IAAM,EAAM,IACN,EAAO,CAAE,GAAI,EAAI,MAAM,CAAC,EAAU,EAAI,CAAC,CAAC,AAAE,EAIhD,OAHA,CAAI,CAAC,EAAS,CAAG,EACjB,EAAI,MAAM,CAAG,CAAE,GAAG,EAAI,MAAM,CAAE,CAAC,EAAU,CAAE,CAAK,EAChD,EAAQ,GACD,CACT,QArCO,SAAS,AAAa,CAAU,EACrC,IAAM,EAAM,IACN,EAAI,EAAI,QAAQ,CAAC,IAAI,CAAC,AAAC,GAAM,EAAE,EAAE,GAAK,GACxC,GAAG,CACL,EAAE,UAAU,CAAG,IAAI,OAAO,WAAW,GACrC,EAAQ,GAEZ"}
@@ -9,6 +9,6 @@ if(c==="${j}")id=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"ligh
9
9
  var d=document.documentElement;
10
10
  d.dataset.theme=id;
11
11
  d.classList.toggle("dark",P[id]==="dark");
12
- }catch(e){}})();`)}})}),(0,b.jsx)("body",{className:"h-full",children:(0,b.jsx)(g.Providers,{children:a})})]})},"metadata",0,k],33290)},34062,a=>{let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call Providers() from the server but Providers is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/components/providers.tsx","Providers");a.s(["Providers",0,b])},17950,a=>{var b=a.i(34062);a.n(b)}],89578,a=>{a.v({className:"T19VSG_className",variable:"T19VSG_variable"})},35214,a=>{a.v({className:"_8Li5zG_className",variable:"_8Li5zG_variable"})},70864,function(a){a.n(a.i(33290))}];
12
+ }catch(e){}})();`)}})}),(0,b.jsx)("body",{className:"h-full",children:(0,b.jsx)(g.Providers,{children:a})})]})},"metadata",0,k,"viewport",0,{width:"device-width",initialScale:1}],33290)},34062,a=>{let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call Providers() from the server but Providers is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/components/providers.tsx","Providers");a.s(["Providers",0,b])},17950,a=>{var b=a.i(34062);a.n(b)}],89578,a=>{a.v({className:"T19VSG_className",variable:"T19VSG_variable"})},35214,a=>{a.v({className:"_8Li5zG_className",variable:"_8Li5zG_variable"})},70864,function(a){a.n(a.i(33290))}];
13
13
 
14
14
  //# sourceMappingURL=%5Broot-of-the-server%5D__10sjsc4ko7y98._.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["turbopack:///[next]/internal/font/google/geist_a71539c9.js","turbopack:///[next]/internal/font/google/geist_mono_8d43a2aa.js","../../../../app/layout.tsx","../../../../lib/themes.ts","../../../../lib/theme-init-script.ts","../../../../components/providers.tsx/__nextjs-internal-proxy.mjs%20%7B%20server%20%3D%3E%20%22%5Bproject%5D/components/providers.tsx%22%20%7D","turbopack:///[next]/internal/font/google/geist_a71539c9.module.css [app-rsc] (css module)","turbopack:///[next]/internal/font/google/geist_mono_8d43a2aa.module.css [app-rsc] (css module)"],"sourcesContent":["import cssModule from \"@vercel/turbopack-next/internal/font/google/cssmodule.module.css?{%22path%22:%22layout.tsx%22,%22import%22:%22Geist%22,%22arguments%22:[{%22variable%22:%22--font-geist-sans%22,%22subsets%22:[%22latin%22]}],%22variableName%22:%22geistSans%22}\";\nconst fontData = {\n className: cssModule.className,\n style: {\n fontFamily: \"'Geist', 'Geist Fallback'\",\n fontStyle: \"normal\",\n\n },\n};\n\nif (cssModule.variable != null) {\n fontData.variable = cssModule.variable;\n}\n\nexport default fontData;\n","import cssModule from \"@vercel/turbopack-next/internal/font/google/cssmodule.module.css?{%22path%22:%22layout.tsx%22,%22import%22:%22Geist_Mono%22,%22arguments%22:[{%22variable%22:%22--font-geist-mono%22,%22subsets%22:[%22latin%22]}],%22variableName%22:%22geistMono%22}\";\nconst fontData = {\n className: cssModule.className,\n style: {\n fontFamily: \"'Geist Mono', 'Geist Mono Fallback'\",\n fontStyle: \"normal\",\n\n },\n};\n\nif (cssModule.variable != null) {\n fontData.variable = cssModule.variable;\n}\n\nexport default fontData;\n","import type { Metadata } from \"next\";\nimport { Geist, Geist_Mono } from \"next/font/google\";\nimport \"./globals.css\";\nimport { Providers } from \"@/components/providers\";\nimport { APP_TITLE } from \"@/lib/app-title\";\nimport { themeInitScript } from \"@/lib/theme-init-script\";\n\nconst geistSans = Geist({ variable: \"--font-geist-sans\", subsets: [\"latin\"] });\nconst geistMono = Geist_Mono({ variable: \"--font-geist-mono\", subsets: [\"latin\"] });\n\nexport const metadata: Metadata = {\n title: APP_TITLE,\n description: \"A local web UI for the beads (bd) issue tracker\",\n};\n\nexport default function RootLayout({\n children,\n}: Readonly<{ children: React.ReactNode }>) {\n return (\n <html\n lang=\"en\"\n suppressHydrationWarning\n className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}\n >\n <head>\n {/* Applies the saved theme before first paint (no flash for System/dark). */}\n <script dangerouslySetInnerHTML={{ __html: themeInitScript() }} />\n </head>\n <body className=\"h-full\">\n <Providers>{children}</Providers>\n </body>\n </html>\n );\n}\n","/**\n * Theme registry — metadata only. The actual colors live in app/globals.css as\n * `html[data-theme=\"<id>\"]` blocks; this module is what the provider and pickers\n * use to enumerate themes, validate ids, and render swatches. `mode` decides\n * whether the `.dark` class is applied (so Tailwind `dark:` + shadcn tokens work).\n */\nexport type ThemeMode = \"light\" | \"dark\";\n\nexport interface ThemeDef {\n /** Stable id — also the html[data-theme] value and the localStorage value. */\n id: string;\n /** Human label for the picker. */\n name: string;\n /** Drives the `.dark` class. All custom themes here are dark; only Light is light. */\n mode: ThemeMode;\n /** Three representative hexes [bg, surface, accent] for the picker preview. */\n swatch: [string, string, string];\n}\n\nexport const THEMES: ThemeDef[] = [\n { id: \"light\", name: \"Light\", mode: \"light\", swatch: [\"#f6f6f8\", \"#ffffff\", \"#6d5ef0\"] },\n { id: \"dark\", name: \"Dark\", mode: \"dark\", swatch: [\"#0c0c0f\", \"#1d1d22\", \"#8b7cf8\"] },\n { id: \"dracula\", name: \"Dracula\", mode: \"dark\", swatch: [\"#282a36\", \"#44475a\", \"#bd93f9\"] },\n { id: \"nord\", name: \"Nord\", mode: \"dark\", swatch: [\"#2e3440\", \"#3b4252\", \"#88c0d0\"] },\n { id: \"solarized-dark\", name: \"Solarized Dark\", mode: \"dark\", swatch: [\"#002b36\", \"#073642\", \"#268bd2\"] },\n { id: \"gruvbox-dark\", name: \"Gruvbox Dark\", mode: \"dark\", swatch: [\"#282828\", \"#3c3836\", \"#fabd2f\"] },\n { id: \"tokyo-night\", name: \"Tokyo Night\", mode: \"dark\", swatch: [\"#1a1b26\", \"#24283b\", \"#7aa2f7\"] },\n { id: \"catppuccin-mocha\", name: \"Catppuccin Mocha\", mode: \"dark\", swatch: [\"#1e1e2e\", \"#313244\", \"#cba6f7\"] },\n { id: \"rose-pine\", name: \"Rosé Pine\", mode: \"dark\", swatch: [\"#191724\", \"#26233a\", \"#c4a7e7\"] },\n];\n\nexport const DEFAULT_THEME_ID = \"light\";\n\nconst BY_ID = new Map(THEMES.map((t) => [t.id, t]));\n\nexport function isThemeId(id: string): boolean {\n return BY_ID.has(id);\n}\n\n/** Returns the theme for `id`, or the default theme for unknown/empty ids. */\nexport function getTheme(id: string | null | undefined): ThemeDef {\n return (id ? BY_ID.get(id) : undefined) ?? BY_ID.get(DEFAULT_THEME_ID)!;\n}\n\n/**\n * \"System\" is a *choice*, not a palette: it has no `html[data-theme]` block of\n * its own and resolves to Light or Dark from the OS `prefers-color-scheme`.\n * It lives outside THEMES so palette enumerations stay palettes-only; the\n * picker prepends it explicitly.\n */\nexport const SYSTEM_CHOICE_ID = \"system\";\n\nexport const SYSTEM_CHOICE: ThemeDef = {\n id: SYSTEM_CHOICE_ID,\n name: \"System\",\n mode: \"light\",\n // Left half light, right half dark so the swatch reads as \"follows the OS\".\n swatch: [\"#f6f6f8\", \"#1d1d22\", \"#6d5ef0\"],\n};\n\n/** What a project uses until the user picks something. */\nexport const DEFAULT_CHOICE_ID = SYSTEM_CHOICE_ID;\n\n/** Normalizes a stored value to a valid choice id (palette id or \"system\"). */\nexport function getChoiceId(stored: string | null | undefined): string {\n if (stored === SYSTEM_CHOICE_ID) return SYSTEM_CHOICE_ID;\n return stored && BY_ID.has(stored) ? stored : DEFAULT_CHOICE_ID;\n}\n\n/** Resolves a choice to a concrete palette, given the OS preference. */\nexport function resolveChoice(choice: string, prefersDark: boolean): ThemeDef {\n return choice === SYSTEM_CHOICE_ID\n ? BY_ID.get(prefersDark ? \"dark\" : \"light\")!\n : getTheme(choice);\n}\n","import { THEMES, SYSTEM_CHOICE_ID, DEFAULT_CHOICE_ID } from \"@/lib/themes\";\n\n/**\n * Inline <head> script that applies the saved theme before first paint, so a\n * dark-OS user on the default \"System\" choice doesn't see a light flash while\n * React hydrates. Mirrors the storage keys and resolution in\n * components/theme-provider.tsx — keep the two in sync.\n */\nexport function themeInitScript(): string {\n const palettes = Object.fromEntries(THEMES.map((t) => [t.id, t.mode]));\n return `(function(){try{\nvar P=${JSON.stringify(palettes)};\nvar m=location.pathname.match(/^\\\\/p\\\\/([^/]+)/);\nvar s=localStorage,k=m?\"beadscope.theme.\"+decodeURIComponent(m[1]):\"beadscope.theme\";\nvar c=s.getItem(k);\nif(c!==\"${SYSTEM_CHOICE_ID}\"&&!(c in P))c=\"${DEFAULT_CHOICE_ID}\";\nvar id=c;\nif(c===\"${SYSTEM_CHOICE_ID}\")id=matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";\nvar d=document.documentElement;\nd.dataset.theme=id;\nd.classList.toggle(\"dark\",P[id]===\"dark\");\n}catch(e){}})();`;\n}\n","// This file is generated by next-core EcmascriptClientReferenceModule.\nimport { registerClientReference } from \"react-server-dom-turbopack/server\";\nexport const Providers = registerClientReference(\n function() { throw new Error(\"Attempted to call Providers() from the server but Providers is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.\"); },\n \"[project]/components/providers.tsx\",\n \"Providers\",\n);\n","__turbopack_context__.v({\n \"className\": \"T19VSG_className\",\n \"variable\": \"T19VSG_variable\",\n});\n","__turbopack_context__.v({\n \"className\": \"_8Li5zG_className\",\n \"variable\": \"_8Li5zG_variable\",\n});\n"],"names":["fontData","className","style","fontFamily","fontStyle","variable","Providers","Error"],"mappings":"2CAAA,EAAA,EAAA,CAAA,CAAA,OACA,IAAMA,EAAW,CACbC,UAAW,EAAA,OAAS,CAACA,SAAS,CAC9BC,MAAO,CACHC,WAAY,4BACZC,UAAW,QAEf,CACJ,CAE0B,AAAtB,MAA4B,GAA5B,OAAS,CAACC,QAAQ,GAClBL,EAASK,QAAQ,CAAG,EAAA,OAAS,CAACA,QAAAA,AAAQ,ECX1C,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,IAAM,EAAW,CACb,UAAW,EAAA,OAAS,CAAC,SAAS,CAC9B,MAAO,CACH,WAAY,sCACZ,UAAW,QAEf,CACJ,CAE0B,MAAMA,CAA5B,EAAA,OAAS,CAAC,QAAQ,GAClB,EAAS,QAAQ,CAAG,EAAA,OAAS,CAAC,QAAA,AAAQ,ECR1C,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,KCeO,IAAM,EAAqB,CAChC,CAAE,GAAI,QAAS,KAAM,QAAS,KAAM,QAAS,OAAQ,CAAC,UAAW,UAAW,UAAU,AAAC,EACvF,CAAE,GAAI,OAAQ,KAAM,OAAQ,KAAM,OAAQ,OAAQ,CAAC,UAAW,UAAW,UAAU,AAAC,EACpF,CAAE,GAAI,UAAW,KAAM,UAAW,KAAM,OAAQ,OAAQ,CAAC,UAAW,UAAW,UAAU,AAAC,EAC1F,CAAE,GAAI,OAAQ,KAAM,OAAQ,KAAM,OAAQ,OAAQ,CAAC,UAAW,UAAW,UAAU,AAAC,EACpF,CAAE,GAAI,iBAAkB,KAA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OAAA,CAAK,UAAU,kBACd,CAAA,EAAA,EAAA,GAAA,EAAC,EAAA,SAAS,CAAA,UAAE,QAIpB,oCG/BO,IAAMM,EAAY,CAAA,EADzB,AACyB,EADzB,CAAA,CAAA,OACyB,uBAAA,AAAuB,EAC5C,WAAa,MAAM,AAAIC,MAAM,gOAAkO,EAC/P,qCACA,mFCLJ,EAAA,CAAA,CAAA,CACA,UAAA,mBACA,SAAA,iBACA,cCHA,EAAA,CAAA,CAAA,CACA,UAAA,oBACA,SAAA,kBACA","ignoreList":[0,1,5,6,7]}
1
+ {"version":3,"sources":["turbopack:///[next]/internal/font/google/geist_a71539c9.js","turbopack:///[next]/internal/font/google/geist_mono_8d43a2aa.js","../../../../app/layout.tsx","../../../../lib/themes.ts","../../../../lib/theme-init-script.ts","../../../../components/providers.tsx/__nextjs-internal-proxy.mjs%20%7B%20server%20%3D%3E%20%22%5Bproject%5D/components/providers.tsx%22%20%7D","turbopack:///[next]/internal/font/google/geist_a71539c9.module.css [app-rsc] (css module)","turbopack:///[next]/internal/font/google/geist_mono_8d43a2aa.module.css [app-rsc] (css module)"],"sourcesContent":["import cssModule from \"@vercel/turbopack-next/internal/font/google/cssmodule.module.css?{%22path%22:%22layout.tsx%22,%22import%22:%22Geist%22,%22arguments%22:[{%22variable%22:%22--font-geist-sans%22,%22subsets%22:[%22latin%22]}],%22variableName%22:%22geistSans%22}\";\nconst fontData = {\n className: cssModule.className,\n style: {\n fontFamily: \"'Geist', 'Geist Fallback'\",\n fontStyle: \"normal\",\n\n },\n};\n\nif (cssModule.variable != null) {\n fontData.variable = cssModule.variable;\n}\n\nexport default fontData;\n","import cssModule from \"@vercel/turbopack-next/internal/font/google/cssmodule.module.css?{%22path%22:%22layout.tsx%22,%22import%22:%22Geist_Mono%22,%22arguments%22:[{%22variable%22:%22--font-geist-mono%22,%22subsets%22:[%22latin%22]}],%22variableName%22:%22geistMono%22}\";\nconst fontData = {\n className: cssModule.className,\n style: {\n fontFamily: \"'Geist Mono', 'Geist Mono Fallback'\",\n fontStyle: \"normal\",\n\n },\n};\n\nif (cssModule.variable != null) {\n fontData.variable = cssModule.variable;\n}\n\nexport default fontData;\n","import type { Metadata, Viewport } from \"next\";\nimport { Geist, Geist_Mono } from \"next/font/google\";\nimport \"./globals.css\";\nimport { Providers } from \"@/components/providers\";\nimport { APP_TITLE } from \"@/lib/app-title\";\nimport { themeInitScript } from \"@/lib/theme-init-script\";\n\nconst geistSans = Geist({ variable: \"--font-geist-sans\", subsets: [\"latin\"] });\nconst geistMono = Geist_Mono({ variable: \"--font-geist-mono\", subsets: [\"latin\"] });\n\n// Explicit so phones render at device width. Zoom stays allowed (no maximum-scale).\nexport const viewport: Viewport = { width: \"device-width\", initialScale: 1 };\n\nexport const metadata: Metadata = {\n title: APP_TITLE,\n description: \"A local web UI for the beads (bd) issue tracker\",\n};\n\nexport default function RootLayout({\n children,\n}: Readonly<{ children: React.ReactNode }>) {\n return (\n <html\n lang=\"en\"\n suppressHydrationWarning\n className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}\n >\n <head>\n {/* Applies the saved theme before first paint (no flash for System/dark). */}\n <script dangerouslySetInnerHTML={{ __html: themeInitScript() }} />\n </head>\n <body className=\"h-full\">\n <Providers>{children}</Providers>\n </body>\n </html>\n );\n}\n","/**\n * Theme registry — metadata only. The actual colors live in app/globals.css as\n * `html[data-theme=\"<id>\"]` blocks; this module is what the provider and pickers\n * use to enumerate themes, validate ids, and render swatches. `mode` decides\n * whether the `.dark` class is applied (so Tailwind `dark:` + shadcn tokens work).\n */\nexport type ThemeMode = \"light\" | \"dark\";\n\nexport interface ThemeDef {\n /** Stable id — also the html[data-theme] value and the localStorage value. */\n id: string;\n /** Human label for the picker. */\n name: string;\n /** Drives the `.dark` class. All custom themes here are dark; only Light is light. */\n mode: ThemeMode;\n /** Three representative hexes [bg, surface, accent] for the picker preview. */\n swatch: [string, string, string];\n}\n\nexport const THEMES: ThemeDef[] = [\n { id: \"light\", name: \"Light\", mode: \"light\", swatch: [\"#f6f6f8\", \"#ffffff\", \"#6d5ef0\"] },\n { id: \"dark\", name: \"Dark\", mode: \"dark\", swatch: [\"#0c0c0f\", \"#1d1d22\", \"#8b7cf8\"] },\n { id: \"dracula\", name: \"Dracula\", mode: \"dark\", swatch: [\"#282a36\", \"#44475a\", \"#bd93f9\"] },\n { id: \"nord\", name: \"Nord\", mode: \"dark\", swatch: [\"#2e3440\", \"#3b4252\", \"#88c0d0\"] },\n { id: \"solarized-dark\", name: \"Solarized Dark\", mode: \"dark\", swatch: [\"#002b36\", \"#073642\", \"#268bd2\"] },\n { id: \"gruvbox-dark\", name: \"Gruvbox Dark\", mode: \"dark\", swatch: [\"#282828\", \"#3c3836\", \"#fabd2f\"] },\n { id: \"tokyo-night\", name: \"Tokyo Night\", mode: \"dark\", swatch: [\"#1a1b26\", \"#24283b\", \"#7aa2f7\"] },\n { id: \"catppuccin-mocha\", name: \"Catppuccin Mocha\", mode: \"dark\", swatch: [\"#1e1e2e\", \"#313244\", \"#cba6f7\"] },\n { id: \"rose-pine\", name: \"Rosé Pine\", mode: \"dark\", swatch: [\"#191724\", \"#26233a\", \"#c4a7e7\"] },\n];\n\nexport const DEFAULT_THEME_ID = \"light\";\n\nconst BY_ID = new Map(THEMES.map((t) => [t.id, t]));\n\nexport function isThemeId(id: string): boolean {\n return BY_ID.has(id);\n}\n\n/** Returns the theme for `id`, or the default theme for unknown/empty ids. */\nexport function getTheme(id: string | null | undefined): ThemeDef {\n return (id ? BY_ID.get(id) : undefined) ?? BY_ID.get(DEFAULT_THEME_ID)!;\n}\n\n/**\n * \"System\" is a *choice*, not a palette: it has no `html[data-theme]` block of\n * its own and resolves to Light or Dark from the OS `prefers-color-scheme`.\n * It lives outside THEMES so palette enumerations stay palettes-only; the\n * picker prepends it explicitly.\n */\nexport const SYSTEM_CHOICE_ID = \"system\";\n\nexport const SYSTEM_CHOICE: ThemeDef = {\n id: SYSTEM_CHOICE_ID,\n name: \"System\",\n mode: \"light\",\n // Left half light, right half dark so the swatch reads as \"follows the OS\".\n swatch: [\"#f6f6f8\", \"#1d1d22\", \"#6d5ef0\"],\n};\n\n/** What a project uses until the user picks something. */\nexport const DEFAULT_CHOICE_ID = SYSTEM_CHOICE_ID;\n\n/** Normalizes a stored value to a valid choice id (palette id or \"system\"). */\nexport function getChoiceId(stored: string | null | undefined): string {\n if (stored === SYSTEM_CHOICE_ID) return SYSTEM_CHOICE_ID;\n return stored && BY_ID.has(stored) ? stored : DEFAULT_CHOICE_ID;\n}\n\n/** Resolves a choice to a concrete palette, given the OS preference. */\nexport function resolveChoice(choice: string, prefersDark: boolean): ThemeDef {\n return choice === SYSTEM_CHOICE_ID\n ? BY_ID.get(prefersDark ? \"dark\" : \"light\")!\n : getTheme(choice);\n}\n\n/** The quick-switch order: follow the OS, then Light, then Dark, then back to the OS. */\nconst THEME_CYCLE = [SYSTEM_CHOICE_ID, \"light\", \"dark\"];\n\n/**\n * The choice the quick-switch button saves next. Any other palette (Nord,\n * Dracula, ...) is outside the cycle, so it moves on to System; pick a palette\n * again in Settings.\n */\nexport function nextChoiceId(choice: string): string {\n return THEME_CYCLE[(THEME_CYCLE.indexOf(choice) + 1) % THEME_CYCLE.length];\n}\n\n/** Display name of a choice id (\"System\", \"Light\", \"Nord\", ...). */\nexport function choiceName(choice: string): string {\n return choice === SYSTEM_CHOICE_ID ? SYSTEM_CHOICE.name : getTheme(choice).name;\n}\n\n/**\n * What the quick-switch button shows: an icon for the current choice (a monitor\n * for System, otherwise a sun or moon for the painted palette) and a tooltip\n * naming it and the next one.\n */\nexport function themeButtonInfo(choice: string, mode: ThemeMode) {\n return {\n icon: choice === SYSTEM_CHOICE_ID ? \"monitor\" : mode === \"dark\" ? \"moon\" : \"sun\",\n title: `Theme: ${choiceName(choice)} — click for ${choiceName(nextChoiceId(choice))}`,\n };\n}\n","import { THEMES, SYSTEM_CHOICE_ID, DEFAULT_CHOICE_ID } from \"@/lib/themes\";\n\n/**\n * Inline <head> script that applies the saved theme before first paint, so a\n * dark-OS user on the default \"System\" choice doesn't see a light flash while\n * React hydrates. Mirrors the storage keys and resolution in\n * components/theme-provider.tsx — keep the two in sync.\n */\nexport function themeInitScript(): string {\n const palettes = Object.fromEntries(THEMES.map((t) => [t.id, t.mode]));\n return `(function(){try{\nvar P=${JSON.stringify(palettes)};\nvar m=location.pathname.match(/^\\\\/p\\\\/([^/]+)/);\nvar s=localStorage,k=m?\"beadscope.theme.\"+decodeURIComponent(m[1]):\"beadscope.theme\";\nvar c=s.getItem(k);\nif(c!==\"${SYSTEM_CHOICE_ID}\"&&!(c in P))c=\"${DEFAULT_CHOICE_ID}\";\nvar id=c;\nif(c===\"${SYSTEM_CHOICE_ID}\")id=matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";\nvar d=document.documentElement;\nd.dataset.theme=id;\nd.classList.toggle(\"dark\",P[id]===\"dark\");\n}catch(e){}})();`;\n}\n","// This file is generated by next-core EcmascriptClientReferenceModule.\nimport { registerClientReference } from \"react-server-dom-turbopack/server\";\nexport const Providers = registerClientReference(\n function() { throw new Error(\"Attempted to call Providers() from the server but Providers is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.\"); },\n \"[project]/components/providers.tsx\",\n \"Providers\",\n);\n","__turbopack_context__.v({\n \"className\": \"T19VSG_className\",\n \"variable\": \"T19VSG_variable\",\n});\n","__turbopack_context__.v({\n \"className\": \"_8Li5zG_className\",\n \"variable\": \"_8Li5zG_variable\",\n});\n"],"names":["fontData","className","style","fontFamily","fontStyle","variable","Providers","Error"],"mappings":"2CAAA,EAAA,EAAA,CAAA,CAAA,OACA,IAAMA,EAAW,CACbC,UAAW,EAAA,OAAS,CAACA,SAAS,CAC9BC,MAAO,CACHC,WAAY,4BACZC,UAAW,QAEf,CACJ,CAE0B,AAAtB,MAA4B,GAA5B,OAAS,CAACC,QAAQ,GAClBL,EAASK,QAAQ,CAAG,EAAA,OAAS,CAACA,QAAAA,AAAQ,ECX1C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