heartbeads 0.6.1 → 0.6.2
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/beads/route.js.nft.json +1 -1
- package/.next/server/app/api/beads/stream/route.js.nft.json +1 -1
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/docs.html +2 -2
- package/.next/server/app/api/docs.rsc +1 -1
- package/.next/server/app/api/docs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/api/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/api/docs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/api/docs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/docs.segments/api/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/api/docs.segments/api/docs.segment.rsc +1 -1
- package/.next/server/app/api/docs.segments/api.segment.rsc +1 -1
- package/.next/server/app/api/v1/graph/route.js.nft.json +1 -1
- package/.next/server/app/api/v1/issues/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/v1/ready/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +1 -1
- package/.next/server/app/login.segments/_full.segment.rsc +1 -1
- package/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/server/app/login.segments/_index.segment.rsc +1 -1
- package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/48cc8_next_dist_esm_build_templates_app-route_1d3b72ae.js +1 -1
- package/.next/server/chunks/48cc8_next_dist_esm_build_templates_app-route_1d3b72ae.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__2d60806f._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__2d60806f._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__3cb3ed30._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__3cb3ed30._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__6125c4e2._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__6125c4e2._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__67c802f8._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__67c802f8._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__77e35ba8._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__77e35ba8._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__8261fec1._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__8261fec1._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__04e6e565._.js +2 -2
- package/.next/server/chunks/ssr/[root-of-the-server]__04e6e565._.js.map +1 -1
- package/.next/server/edge/chunks/48cc8_next_dist_5a0b8a90._.js +1 -1
- package/.next/server/edge/chunks/48cc8_next_dist_5a0b8a90._.js.map +1 -1
- package/.next/server/middleware/middleware-manifest.json +3 -3
- package/.next/server/middleware-manifest.json +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/static/chunks/7e4fcecd4ca504d5.js +24 -0
- package/.next/static/zq8Ew2hci2YIJ61-i832n/_clientMiddlewareManifest.json +6 -0
- package/app/api/login/route.ts +15 -0
- package/app/page.tsx +46 -35
- package/components/BeadsGraph.tsx +15 -1
- package/components/NodeDetail.tsx +15 -7
- package/lib/activity.ts +22 -2
- package/lib/parse-beads.ts +24 -10
- package/lib/types.ts +82 -1
- package/package.json +1 -1
- package/.next/static/bc2EgBqgYtYOdWusC2URO/_clientMiddlewareManifest.json +0 -6
- package/.next/static/chunks/6cdcba7fb18f6f79.js +0 -24
- /package/.next/static/{bc2EgBqgYtYOdWusC2URO → zq8Ew2hci2YIJ61-i832n}/_buildManifest.js +0 -0
- /package/.next/static/{bc2EgBqgYtYOdWusC2URO → zq8Ew2hci2YIJ61-i832n}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/parse-beads.ts","../../../app/api/beads/stream/route.ts","../../../lib/watch-beads.ts","../../../node_modules/.pnpm/next%4016.1.6_react-dom%4018.3.1_react%4018.3.1__react%4018.3.1/node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\";\nimport { join, resolve } from \"path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { discoverBeadsDir } from \"./discover\";\nimport type {\n BeadIssue,\n BeadDependency,\n GraphNode,\n GraphLink,\n GraphData,\n BeadsApiResponse,\n} from \"./types\";\n\n/**\n * Extract the prefix from a bead ID (e.g. \"my-app-5gw\" -> \"my-app\")\n */\nexport function extractPrefix(id: string): string {\n const lastDash = id.lastIndexOf(\"-\");\n if (lastDash === -1) return id;\n return id.substring(0, lastDash);\n}\n\n/**\n * Read repos.additional paths from .beads/config.yaml\n */\nexport function getAdditionalRepoPaths(beadsDir: string): string[] {\n const configPath = join(beadsDir, \"config.yaml\");\n try {\n const content = readFileSync(configPath, \"utf-8\");\n const config = parseYaml(content);\n const additional = config?.repos?.additional;\n if (Array.isArray(additional)) {\n return additional\n .map((p: string) => resolve(beadsDir, \"..\", p))\n .filter((p: string) => existsSync(join(p, \".beads\", \"issues.jsonl\")));\n }\n } catch (err) {\n console.error(\"Failed to read config.yaml:\", err);\n }\n return [];\n}\n\n/**\n * Parse a single issues.jsonl file and return issues\n */\nfunction parseJsonlFile(filePath: string): BeadIssue[] {\n let content: string;\n try {\n content = readFileSync(filePath, \"utf-8\");\n } catch (err) {\n console.error(`Failed to read ${filePath}:`, err);\n return [];\n }\n\n const lines = content.split(\"\\n\").filter((line) => line.trim().length > 0);\n const issues: BeadIssue[] = [];\n\n for (let i = 0; i < lines.length; i++) {\n try {\n issues.push(JSON.parse(lines[i]) as BeadIssue);\n } catch (err) {\n console.warn(`Skipping malformed line ${i + 1} in ${filePath}:`, err);\n }\n }\n\n return issues;\n}\n\n/**\n * Parse issues.jsonl from the primary .beads directory and all additional repos\n */\nexport function parseIssuesJsonl(beadsDir?: string): BeadIssue[] {\n const dir = beadsDir || discoverBeadsDir().beadsDir;\n\n // Load primary repo issues\n const primaryPath = join(dir, \"issues.jsonl\");\n const issues = parseJsonlFile(primaryPath);\n\n // Load additional repo issues from config.yaml\n const additionalRepos = getAdditionalRepoPaths(dir);\n for (const repoPath of additionalRepos) {\n const repoJsonl = join(repoPath, \".beads\", \"issues.jsonl\");\n const repoIssues = parseJsonlFile(repoJsonl);\n issues.push(...repoIssues);\n }\n\n // Deduplicate by issue ID (primary repo wins) and filter out tombstones.\n // bd delete marks issues with status \"tombstone\" rather than removing them\n // from the JSONL file — we must exclude these from the graph.\n const seen = new Set<string>();\n return issues.filter((issue) => {\n if (seen.has(issue.id)) return false;\n seen.add(issue.id);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((issue as any).status === \"tombstone\") return false;\n return true;\n });\n}\n\n/**\n * Extract all dependencies from issues (they're embedded in each issue)\n */\nexport function extractDependencies(issues: BeadIssue[]): BeadDependency[] {\n const deps: BeadDependency[] = [];\n const seen = new Set<string>();\n\n for (const issue of issues) {\n if (issue.dependencies) {\n for (const dep of issue.dependencies) {\n const key = `${dep.issue_id}->${dep.depends_on_id}:${dep.type}`;\n if (!seen.has(key)) {\n seen.add(key);\n deps.push(dep);\n }\n }\n }\n }\n\n return deps;\n}\n\n/**\n * Build graph data from issues and dependencies\n */\nexport function buildGraphData(\n issues: BeadIssue[],\n dependencies: BeadDependency[]\n): GraphData {\n const issueMap = new Map(issues.map((i) => [i.id, i]));\n\n // Count blockers and dependents for each issue\n const blockerCounts = new Map<string, string[]>(); // issue -> issues it blocks\n const dependentCounts = new Map<string, string[]>(); // issue -> issues that block it\n\n for (const dep of dependencies) {\n if (dep.type === \"blocks\" || dep.type === \"parent-child\") {\n // For blocks: depends_on_id blocks issue_id\n // For parent-child: depends_on_id is parent of issue_id\n // Both count as connections for node sizing\n if (!blockerCounts.has(dep.depends_on_id)) {\n blockerCounts.set(dep.depends_on_id, []);\n }\n blockerCounts.get(dep.depends_on_id)!.push(dep.issue_id);\n\n if (!dependentCounts.has(dep.issue_id)) {\n dependentCounts.set(dep.issue_id, []);\n }\n dependentCounts.get(dep.issue_id)!.push(dep.depends_on_id);\n }\n }\n\n const nodes: GraphNode[] = issues.map((issue) => ({\n id: issue.id,\n title: issue.title,\n description: issue.description,\n status: issue.status,\n priority: issue.priority,\n issueType: issue.issue_type,\n owner: issue.owner,\n assignee: issue.assignee,\n createdBy: issue.created_by,\n createdAt: issue.created_at,\n updatedAt: issue.updated_at,\n closedAt: issue.closed_at,\n closeReason: issue.close_reason,\n acceptanceCriteria: issue.acceptance_criteria,\n estimatedMinutes: issue.estimated_minutes,\n prefix: extractPrefix(issue.id),\n labels: issue.labels || [],\n\n blockerCount: blockerCounts.get(issue.id)?.length || 0,\n dependentCount: dependentCounts.get(issue.id)?.length || 0,\n blockerIds: blockerCounts.get(issue.id) || [],\n dependentIds: dependentCounts.get(issue.id) || [],\n }));\n\n // Build links: include blocking AND parent-child dependencies where both nodes exist\n const links: GraphLink[] = dependencies\n .filter(\n (d) =>\n (d.type === \"blocks\" || d.type === \"parent-child\") &&\n issueMap.has(d.issue_id) &&\n issueMap.has(d.depends_on_id)\n )\n .map((d) => ({\n // For both types: depends_on_id is the \"upstream\" node (blocker or parent)\n // blocks: blocker -> blocked\n // parent-child: parent -> child\n source: d.depends_on_id,\n target: d.issue_id,\n type: d.type,\n createdAt: d.created_at,\n }));\n\n return { nodes, links };\n}\n\n/**\n * Compute stats from issues and dependencies\n */\nexport function computeStats(\n issues: BeadIssue[],\n dependencies: BeadDependency[],\n graphData: GraphData\n) {\n const prefixes = [...new Set(issues.map((i) => extractPrefix(i.id)))];\n\n // An issue is \"actionable\" if it's open and has no open blockers\n const openIssueIds = new Set(\n issues.filter((i) => i.status !== \"closed\").map((i) => i.id)\n );\n\n const blockedByOpen = new Set<string>();\n for (const dep of dependencies) {\n if (dep.type === \"blocks\" && openIssueIds.has(dep.depends_on_id)) {\n // issue_id is blocked by depends_on_id which is still open\n blockedByOpen.add(dep.issue_id);\n }\n }\n\n const actionable = issues.filter(\n (i) =>\n (i.status === \"open\" || i.status === \"in_progress\") &&\n !blockedByOpen.has(i.id)\n ).length;\n\n return {\n total: issues.length,\n open: issues.filter((i) => i.status === \"open\").length,\n inProgress: issues.filter((i) => i.status === \"in_progress\").length,\n blocked: issues.filter((i) => i.status === \"blocked\").length,\n closed: issues.filter((i) => i.status === \"closed\").length,\n actionable,\n edges: graphData.links.length,\n prefixes,\n };\n}\n\n/**\n * Full pipeline: parse, extract, build, compute\n */\nexport function loadBeadsData(beadsDir?: string): BeadsApiResponse {\n const issues = parseIssuesJsonl(beadsDir);\n const dependencies = extractDependencies(issues);\n const graphData = buildGraphData(issues, dependencies);\n const stats = computeStats(issues, dependencies, graphData);\n\n return { issues, dependencies, graphData, stats };\n}\n","import { discoverBeadsDir } from \"@/lib/discover\";\nimport { loadBeadsData } from \"@/lib/parse-beads\";\nimport { watchBeadsFiles } from \"@/lib/watch-beads\";\n\n// Prevent Next.js from statically optimizing this route\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(request: Request) {\n let cleanup: (() => void) | null = null;\n\n const stream = new ReadableStream({\n start(controller) {\n const encoder = new TextEncoder();\n\n function send(data: unknown) {\n try {\n controller.enqueue(\n encoder.encode(`data: ${JSON.stringify(data)}\\n\\n`)\n );\n } catch {\n // Stream closed — cleanup will handle\n }\n }\n\n try {\n const { beadsDir } = discoverBeadsDir();\n\n // Send initial data\n const initialData = loadBeadsData(beadsDir);\n send(initialData);\n\n // Watch for changes and push updates\n cleanup = watchBeadsFiles(beadsDir, () => {\n try {\n const newData = loadBeadsData(beadsDir);\n send(newData);\n } catch (err) {\n console.error(\"Failed to reload beads data:\", err);\n }\n });\n\n // Heartbeat every 30s to keep connection alive through proxies/firewalls\n const heartbeat = setInterval(() => {\n try {\n controller.enqueue(encoder.encode(\": heartbeat\\n\\n\"));\n } catch {\n clearInterval(heartbeat);\n }\n }, 30000);\n\n // Clean up when client disconnects\n request.signal.addEventListener(\"abort\", () => {\n clearInterval(heartbeat);\n if (cleanup) cleanup();\n try {\n controller.close();\n } catch {\n /* already closed */\n }\n });\n } catch (err: unknown) {\n // Discovery failed — send error and close\n const message =\n err instanceof Error ? err.message : \"Unknown error\";\n send({ error: message });\n controller.close();\n }\n },\n\n cancel() {\n if (cleanup) cleanup();\n },\n });\n\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n \"X-Accel-Buffering\": \"no\", // Disable Nginx buffering\n },\n });\n}\n","import { watch, existsSync } from \"fs\";\nimport { join, dirname, basename } from \"path\";\nimport { getAdditionalRepoPaths } from \"./parse-beads\";\n\n/**\n * Get all issues.jsonl file paths that should be watched.\n * Returns the primary path plus any additional repo paths from config.yaml.\n */\nexport function getWatchPaths(beadsDir: string): string[] {\n const paths: string[] = [];\n\n // Primary JSONL\n const primary = join(beadsDir, \"issues.jsonl\");\n if (existsSync(primary)) paths.push(primary);\n\n // Additional repo JSONLs\n const additionalRepos = getAdditionalRepoPaths(beadsDir);\n for (const repoPath of additionalRepos) {\n const jsonlPath = join(repoPath, \".beads\", \"issues.jsonl\");\n if (existsSync(jsonlPath)) paths.push(jsonlPath);\n }\n\n return paths;\n}\n\n/**\n * Watch all issues.jsonl files for a beads project.\n * Discovers files from the primary .beads dir and config.yaml repos.additional.\n * Debounces rapid changes (bd often writes multiple times per command).\n *\n * @param beadsDir - Absolute path to the primary .beads/ directory\n * @param onChange - Callback fired when any watched file changes (after debounce)\n * @param debounceMs - Debounce interval in milliseconds (default: 300)\n * @returns Cleanup function that closes all watchers\n */\nexport function watchBeadsFiles(\n beadsDir: string,\n onChange: () => void,\n debounceMs = 300\n): () => void {\n const filePaths = getWatchPaths(beadsDir);\n let timer: ReturnType<typeof setTimeout> | null = null;\n const watchers: ReturnType<typeof watch>[] = [];\n\n // Deduplicate directories — multiple files may share the same .beads/ dir\n const dirToFiles = new Map<string, Set<string>>();\n for (const filePath of filePaths) {\n const dir = dirname(filePath);\n const file = basename(filePath);\n if (!dirToFiles.has(dir)) dirToFiles.set(dir, new Set());\n dirToFiles.get(dir)!.add(file);\n }\n\n console.log(\n `[heartbeads] Watching ${filePaths.length} file(s) in ${dirToFiles.size} dir(s) for changes`\n );\n\n const debouncedOnChange = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n console.log(\"[heartbeads] File change detected, pushing update\");\n onChange();\n }, debounceMs);\n };\n\n // Watch directories instead of individual files.\n // This is far more reliable on macOS: fs.watch on a file breaks when the\n // file is atomically replaced (write-tmp + rename), which is how bd and\n // many editors write. Watching the directory catches renames reliably.\n for (const [dir, fileNames] of dirToFiles) {\n try {\n const watcher = watch(dir, { persistent: true }, (_eventType, filename) => {\n // Filter: only react to changes to our target files\n if (filename && fileNames.has(filename)) {\n debouncedOnChange();\n }\n });\n watchers.push(watcher);\n console.log(`[heartbeads] Watching dir: ${dir} for [${[...fileNames].join(\", \")}]`);\n } catch (err) {\n console.warn(`[heartbeads] Failed to watch ${dir}:`, err);\n }\n }\n\n if (filePaths.length === 0) {\n console.warn(\"[heartbeads] No issues.jsonl files found to watch\");\n }\n\n // Return cleanup function\n return () => {\n if (timer) clearTimeout(timer);\n for (const w of watchers) {\n w.close();\n }\n console.log(\"[heartbeads] File watchers closed\");\n };\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/beads/stream/route\",\n pathname: \"/api/beads/stream\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/app/api/beads/stream/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/beads/stream/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"23BAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAaO,SAAS,EAAc,CAAU,EACtC,IAAM,EAAW,EAAG,WAAW,CAAC,YAChC,AAAiB,CAAC,GAAG,CAAjB,EAAwB,EACrB,EAAG,SAAS,CAAC,EAAG,EACzB,CAKO,SAAS,EAAuB,CAAgB,EACrD,IAAM,EAAa,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,EAAU,eAClC,GAAI,CACF,IAAM,EAAU,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAY,SACnC,EAAS,CAAA,EAAA,EAAA,KAAA,AAAS,EAAC,GACnB,EAAa,GAAQ,OAAO,WAClC,GAAI,MAAM,OAAO,CAAC,GAChB,OAAO,EACJ,CAF0B,EAEvB,CAAC,AAAC,GAAc,CAAA,EAAA,EAAA,OAAA,AAAO,EAAC,EAAU,KAAM,IAC3C,MAAM,CAAC,AAAC,GAAc,CAAA,EAAA,EAAA,UAAA,AAAU,EAAC,CAAA,EAAA,EAA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AM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[3]}
|
|
1
|
+
{"version":3,"sources":["../../../lib/parse-beads.ts","../../../app/api/beads/stream/route.ts","../../../lib/watch-beads.ts","../../../node_modules/.pnpm/next%4016.1.6_react-dom%4018.3.1_react%4018.3.1__react%4018.3.1/node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\";\nimport { join, resolve } from \"path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { discoverBeadsDir } from \"./discover\";\nimport type {\n BeadIssue,\n BeadDependency,\n GraphNode,\n GraphLink,\n GraphData,\n BeadsApiResponse,\n} from \"./types\";\n\n/**\n * Extract the prefix from a bead ID (e.g. \"my-app-5gw\" -> \"my-app\")\n */\nexport function extractPrefix(id: string): string {\n const lastDash = id.lastIndexOf(\"-\");\n if (lastDash === -1) return id;\n return id.substring(0, lastDash);\n}\n\n/**\n * Read repos.additional paths from .beads/config.yaml\n */\nexport function getAdditionalRepoPaths(beadsDir: string): string[] {\n const configPath = join(beadsDir, \"config.yaml\");\n try {\n const content = readFileSync(configPath, \"utf-8\");\n const config = parseYaml(content);\n const additional = config?.repos?.additional;\n if (Array.isArray(additional)) {\n return additional\n .map((p: string) => resolve(beadsDir, \"..\", p))\n .filter((p: string) => existsSync(join(p, \".beads\", \"issues.jsonl\")));\n }\n } catch (err) {\n console.error(\"Failed to read config.yaml:\", err);\n }\n return [];\n}\n\n/**\n * Parse a single issues.jsonl file and return issues\n */\nfunction parseJsonlFile(filePath: string): BeadIssue[] {\n let content: string;\n try {\n content = readFileSync(filePath, \"utf-8\");\n } catch (err) {\n console.error(`Failed to read ${filePath}:`, err);\n return [];\n }\n\n const lines = content.split(\"\\n\").filter((line) => line.trim().length > 0);\n const issues: BeadIssue[] = [];\n\n for (let i = 0; i < lines.length; i++) {\n try {\n issues.push(JSON.parse(lines[i]) as BeadIssue);\n } catch (err) {\n console.warn(`Skipping malformed line ${i + 1} in ${filePath}:`, err);\n }\n }\n\n return issues;\n}\n\n/**\n * Parse issues.jsonl from the primary .beads directory and all additional repos\n */\nexport function parseIssuesJsonl(beadsDir?: string): BeadIssue[] {\n const dir = beadsDir || discoverBeadsDir().beadsDir;\n\n // Load primary repo issues\n const primaryPath = join(dir, \"issues.jsonl\");\n const issues = parseJsonlFile(primaryPath);\n\n // Load additional repo issues from config.yaml\n const additionalRepos = getAdditionalRepoPaths(dir);\n for (const repoPath of additionalRepos) {\n const repoJsonl = join(repoPath, \".beads\", \"issues.jsonl\");\n const repoIssues = parseJsonlFile(repoJsonl);\n issues.push(...repoIssues);\n }\n\n // Deduplicate by issue ID (primary repo wins for non-empty fields).\n // When a duplicate is found, merge any empty fields from the duplicate into the first copy.\n // This handles the case where the hub DB lost created_by/owner during import\n // but individual repos have them.\n const seen = new Map<string, BeadIssue>();\n const result: BeadIssue[] = [];\n for (const issue of issues) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((issue as any).status === \"tombstone\") continue;\n const existing = seen.get(issue.id);\n if (existing) {\n // Merge: fill empty fields from duplicate\n if (!existing.created_by && issue.created_by) existing.created_by = issue.created_by;\n if (!existing.owner && issue.owner) existing.owner = issue.owner;\n if (!existing.assignee && issue.assignee) existing.assignee = issue.assignee;\n if (!existing.close_reason && issue.close_reason) existing.close_reason = issue.close_reason;\n if (!existing.acceptance_criteria && issue.acceptance_criteria) existing.acceptance_criteria = issue.acceptance_criteria;\n if (existing.estimated_minutes == null && issue.estimated_minutes != null) existing.estimated_minutes = issue.estimated_minutes;\n if ((!existing.labels || existing.labels.length === 0) && issue.labels && issue.labels.length > 0) existing.labels = issue.labels;\n } else {\n seen.set(issue.id, issue);\n result.push(issue);\n }\n }\n return result;\n}\n\n/**\n * Extract all dependencies from issues (they're embedded in each issue)\n */\nexport function extractDependencies(issues: BeadIssue[]): BeadDependency[] {\n const deps: BeadDependency[] = [];\n const seen = new Set<string>();\n\n for (const issue of issues) {\n if (issue.dependencies) {\n for (const dep of issue.dependencies) {\n const key = `${dep.issue_id}->${dep.depends_on_id}:${dep.type}`;\n if (!seen.has(key)) {\n seen.add(key);\n deps.push(dep);\n }\n }\n }\n }\n\n return deps;\n}\n\n/**\n * Build graph data from issues and dependencies\n */\nexport function buildGraphData(\n issues: BeadIssue[],\n dependencies: BeadDependency[]\n): GraphData {\n const issueMap = new Map(issues.map((i) => [i.id, i]));\n\n // Count blockers and dependents for each issue\n const blockerCounts = new Map<string, string[]>(); // issue -> issues it blocks\n const dependentCounts = new Map<string, string[]>(); // issue -> issues that block it\n\n for (const dep of dependencies) {\n if (dep.type === \"blocks\" || dep.type === \"parent-child\") {\n // For blocks: depends_on_id blocks issue_id\n // For parent-child: depends_on_id is parent of issue_id\n // Both count as connections for node sizing\n if (!blockerCounts.has(dep.depends_on_id)) {\n blockerCounts.set(dep.depends_on_id, []);\n }\n blockerCounts.get(dep.depends_on_id)!.push(dep.issue_id);\n\n if (!dependentCounts.has(dep.issue_id)) {\n dependentCounts.set(dep.issue_id, []);\n }\n dependentCounts.get(dep.issue_id)!.push(dep.depends_on_id);\n }\n }\n\n const nodes: GraphNode[] = issues.map((issue) => ({\n id: issue.id,\n title: issue.title,\n description: issue.description,\n status: issue.status,\n priority: issue.priority,\n issueType: issue.issue_type,\n owner: issue.owner,\n assignee: issue.assignee,\n createdBy: issue.created_by,\n createdAt: issue.created_at,\n updatedAt: issue.updated_at,\n closedAt: issue.closed_at,\n closeReason: issue.close_reason,\n acceptanceCriteria: issue.acceptance_criteria,\n estimatedMinutes: issue.estimated_minutes,\n prefix: extractPrefix(issue.id),\n labels: issue.labels || [],\n\n blockerCount: blockerCounts.get(issue.id)?.length || 0,\n dependentCount: dependentCounts.get(issue.id)?.length || 0,\n blockerIds: blockerCounts.get(issue.id) || [],\n dependentIds: dependentCounts.get(issue.id) || [],\n }));\n\n // Build links: include blocking AND parent-child dependencies where both nodes exist\n const links: GraphLink[] = dependencies\n .filter(\n (d) =>\n (d.type === \"blocks\" || d.type === \"parent-child\") &&\n issueMap.has(d.issue_id) &&\n issueMap.has(d.depends_on_id)\n )\n .map((d) => ({\n // For both types: depends_on_id is the \"upstream\" node (blocker or parent)\n // blocks: blocker -> blocked\n // parent-child: parent -> child\n source: d.depends_on_id,\n target: d.issue_id,\n type: d.type,\n createdAt: d.created_at,\n }));\n\n return { nodes, links };\n}\n\n/**\n * Compute stats from issues and dependencies\n */\nexport function computeStats(\n issues: BeadIssue[],\n dependencies: BeadDependency[],\n graphData: GraphData\n) {\n const prefixes = [...new Set(issues.map((i) => extractPrefix(i.id)))];\n\n // An issue is \"actionable\" if it's open and has no open blockers\n const openIssueIds = new Set(\n issues.filter((i) => i.status !== \"closed\").map((i) => i.id)\n );\n\n const blockedByOpen = new Set<string>();\n for (const dep of dependencies) {\n if (dep.type === \"blocks\" && openIssueIds.has(dep.depends_on_id)) {\n // issue_id is blocked by depends_on_id which is still open\n blockedByOpen.add(dep.issue_id);\n }\n }\n\n const actionable = issues.filter(\n (i) =>\n (i.status === \"open\" || i.status === \"in_progress\") &&\n !blockedByOpen.has(i.id)\n ).length;\n\n return {\n total: issues.length,\n open: issues.filter((i) => i.status === \"open\").length,\n inProgress: issues.filter((i) => i.status === \"in_progress\").length,\n blocked: issues.filter((i) => i.status === \"blocked\").length,\n closed: issues.filter((i) => i.status === \"closed\").length,\n actionable,\n edges: graphData.links.length,\n prefixes,\n };\n}\n\n/**\n * Full pipeline: parse, extract, build, compute\n */\nexport function loadBeadsData(beadsDir?: string): BeadsApiResponse {\n const issues = parseIssuesJsonl(beadsDir);\n const dependencies = extractDependencies(issues);\n const graphData = buildGraphData(issues, dependencies);\n const stats = computeStats(issues, dependencies, graphData);\n\n return { issues, dependencies, graphData, stats };\n}\n","import { discoverBeadsDir } from \"@/lib/discover\";\nimport { loadBeadsData } from \"@/lib/parse-beads\";\nimport { watchBeadsFiles } from \"@/lib/watch-beads\";\n\n// Prevent Next.js from statically optimizing this route\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(request: Request) {\n let cleanup: (() => void) | null = null;\n\n const stream = new ReadableStream({\n start(controller) {\n const encoder = new TextEncoder();\n\n function send(data: unknown) {\n try {\n controller.enqueue(\n encoder.encode(`data: ${JSON.stringify(data)}\\n\\n`)\n );\n } catch {\n // Stream closed — cleanup will handle\n }\n }\n\n try {\n const { beadsDir } = discoverBeadsDir();\n\n // Send initial data\n const initialData = loadBeadsData(beadsDir);\n send(initialData);\n\n // Watch for changes and push updates\n cleanup = watchBeadsFiles(beadsDir, () => {\n try {\n const newData = loadBeadsData(beadsDir);\n send(newData);\n } catch (err) {\n console.error(\"Failed to reload beads data:\", err);\n }\n });\n\n // Heartbeat every 30s to keep connection alive through proxies/firewalls\n const heartbeat = setInterval(() => {\n try {\n controller.enqueue(encoder.encode(\": heartbeat\\n\\n\"));\n } catch {\n clearInterval(heartbeat);\n }\n }, 30000);\n\n // Clean up when client disconnects\n request.signal.addEventListener(\"abort\", () => {\n clearInterval(heartbeat);\n if (cleanup) cleanup();\n try {\n controller.close();\n } catch {\n /* already closed */\n }\n });\n } catch (err: unknown) {\n // Discovery failed — send error and close\n const message =\n err instanceof Error ? err.message : \"Unknown error\";\n send({ error: message });\n controller.close();\n }\n },\n\n cancel() {\n if (cleanup) cleanup();\n },\n });\n\n return new Response(stream, {\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n \"X-Accel-Buffering\": \"no\", // Disable Nginx buffering\n },\n });\n}\n","import { watch, existsSync } from \"fs\";\nimport { join, dirname, basename } from \"path\";\nimport { getAdditionalRepoPaths } from \"./parse-beads\";\n\n/**\n * Get all issues.jsonl file paths that should be watched.\n * Returns the primary path plus any additional repo paths from config.yaml.\n */\nexport function getWatchPaths(beadsDir: string): string[] {\n const paths: string[] = [];\n\n // Primary JSONL\n const primary = join(beadsDir, \"issues.jsonl\");\n if (existsSync(primary)) paths.push(primary);\n\n // Additional repo JSONLs\n const additionalRepos = getAdditionalRepoPaths(beadsDir);\n for (const repoPath of additionalRepos) {\n const jsonlPath = join(repoPath, \".beads\", \"issues.jsonl\");\n if (existsSync(jsonlPath)) paths.push(jsonlPath);\n }\n\n return paths;\n}\n\n/**\n * Watch all issues.jsonl files for a beads project.\n * Discovers files from the primary .beads dir and config.yaml repos.additional.\n * Debounces rapid changes (bd often writes multiple times per command).\n *\n * @param beadsDir - Absolute path to the primary .beads/ directory\n * @param onChange - Callback fired when any watched file changes (after debounce)\n * @param debounceMs - Debounce interval in milliseconds (default: 300)\n * @returns Cleanup function that closes all watchers\n */\nexport function watchBeadsFiles(\n beadsDir: string,\n onChange: () => void,\n debounceMs = 300\n): () => void {\n const filePaths = getWatchPaths(beadsDir);\n let timer: ReturnType<typeof setTimeout> | null = null;\n const watchers: ReturnType<typeof watch>[] = [];\n\n // Deduplicate directories — multiple files may share the same .beads/ dir\n const dirToFiles = new Map<string, Set<string>>();\n for (const filePath of filePaths) {\n const dir = dirname(filePath);\n const file = basename(filePath);\n if (!dirToFiles.has(dir)) dirToFiles.set(dir, new Set());\n dirToFiles.get(dir)!.add(file);\n }\n\n console.log(\n `[heartbeads] Watching ${filePaths.length} file(s) in ${dirToFiles.size} dir(s) for changes`\n );\n\n const debouncedOnChange = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n console.log(\"[heartbeads] File change detected, pushing update\");\n onChange();\n }, debounceMs);\n };\n\n // Watch directories instead of individual files.\n // This is far more reliable on macOS: fs.watch on a file breaks when the\n // file is atomically replaced (write-tmp + rename), which is how bd and\n // many editors write. Watching the directory catches renames reliably.\n for (const [dir, fileNames] of dirToFiles) {\n try {\n const watcher = watch(dir, { persistent: true }, (_eventType, filename) => {\n // Filter: only react to changes to our target files\n if (filename && fileNames.has(filename)) {\n debouncedOnChange();\n }\n });\n watchers.push(watcher);\n console.log(`[heartbeads] Watching dir: ${dir} for [${[...fileNames].join(\", \")}]`);\n } catch (err) {\n console.warn(`[heartbeads] Failed to watch ${dir}:`, err);\n }\n }\n\n if (filePaths.length === 0) {\n console.warn(\"[heartbeads] No issues.jsonl files found to watch\");\n }\n\n // Return cleanup function\n return () => {\n if (timer) clearTimeout(timer);\n for (const w of watchers) {\n w.close();\n }\n console.log(\"[heartbeads] File watchers closed\");\n };\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/beads/stream/route\",\n pathname: \"/api/beads/stream\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/app/api/beads/stream/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/beads/stream/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"23BAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAaO,SAAS,EAAc,CAAU,EACtC,IAAM,EAAW,EAAG,WAAW,CAAC,YAChC,AAAiB,CAAC,GAAG,CAAjB,EAAwB,EACrB,EAAG,SAAS,CAAC,EAAG,EACzB,CAKO,SAAS,EAAuB,CAAgB,EACrD,IAAM,EAAa,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,EAAU,eAClC,GAAI,CACF,IAAM,EAAU,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAY,SACnC,EAAS,CAAA,EAAA,EAAA,KAAA,AAAS,EAAC,GACnB,EAAa,GAAQ,OAAO,WAClC,GAAI,MAAM,OAAO,CAAC,GAChB,OAAO,EACJ,CAF0B,EAEvB,CAAC,AAAC,GAAc,CAAA,EAAA,EAAA,OAAA,AAAO,EAAC,EAAU,KAAM,IAC3C,MAAM,CAAC,AAAC,GAAc,CAAA,EAAA,EAAA,UAAU,AAAV,EAAW,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,EAAG,SAAU,iBAE1D,CAAE,MAAO,EAAK,CACZ,QAAQ,KAAK,CAAC,8BAA+B,EAC/C,CACA,MAAO,EAAE,AACX,CAKA,SAAS,EAAe,CAAgB,MAClC,EACJ,GAAI,CACF,EAAU,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAU,QACnC,CAAE,MAAO,EAAK,CAEZ,OADA,QAAQ,KAAK,CAAC,CAAC,eAAe,EAAE,EAAS,CAAC,CAAC,CA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AE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GACvB,AAD0B,CAE9B,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[3]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports=[32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},48676,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(24863),n=e.i(63846);function
|
|
1
|
+
module.exports=[32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},48676,e=>{"use strict";var t=e.i(22734),r=e.i(14747),a=e.i(24863),n=e.i(63846);function s(e){let t=e.lastIndexOf("-");return -1===t?e:e.substring(0,t)}function i(e){let n=(0,r.join)(e,"config.yaml");try{let s=(0,t.readFileSync)(n,"utf-8"),i=(0,a.parse)(s),o=i?.repos?.additional;if(Array.isArray(o))return o.map(t=>(0,r.resolve)(e,"..",t)).filter(e=>(0,t.existsSync)((0,r.join)(e,".beads","issues.jsonl")))}catch(e){console.error("Failed to read config.yaml:",e)}return[]}function o(e){let r;try{r=(0,t.readFileSync)(e,"utf-8")}catch(t){return console.error(`Failed to read ${e}:`,t),[]}let a=r.split("\n").filter(e=>e.trim().length>0),n=[];for(let t=0;t<a.length;t++)try{n.push(JSON.parse(a[t]))}catch(r){console.warn(`Skipping malformed line ${t+1} in ${e}:`,r)}return n}function l(e){let t=function(e){let t=e||(0,n.discoverBeadsDir)().beadsDir,a=o((0,r.join)(t,"issues.jsonl"));for(let e of i(t)){let t=o((0,r.join)(e,".beads","issues.jsonl"));a.push(...t)}let s=new Map,l=[];for(let e of a){if("tombstone"===e.status)continue;let t=s.get(e.id);t?(!t.created_by&&e.created_by&&(t.created_by=e.created_by),!t.owner&&e.owner&&(t.owner=e.owner),!t.assignee&&e.assignee&&(t.assignee=e.assignee),!t.close_reason&&e.close_reason&&(t.close_reason=e.close_reason),!t.acceptance_criteria&&e.acceptance_criteria&&(t.acceptance_criteria=e.acceptance_criteria),null==t.estimated_minutes&&null!=e.estimated_minutes&&(t.estimated_minutes=e.estimated_minutes),(!t.labels||0===t.labels.length)&&e.labels&&e.labels.length>0&&(t.labels=e.labels)):(s.set(e.id,e),l.push(e))}return l}(e),a=function(e){let t=[],r=new Set;for(let a of e)if(a.dependencies)for(let e of a.dependencies){let a=`${e.issue_id}->${e.depends_on_id}:${e.type}`;r.has(a)||(r.add(a),t.push(e))}return t}(t),l=function(e,t){let r=new Map(e.map(e=>[e.id,e])),a=new Map,n=new Map;for(let e of t)("blocks"===e.type||"parent-child"===e.type)&&(a.has(e.depends_on_id)||a.set(e.depends_on_id,[]),a.get(e.depends_on_id).push(e.issue_id),n.has(e.issue_id)||n.set(e.issue_id,[]),n.get(e.issue_id).push(e.depends_on_id));return{nodes:e.map(e=>({id:e.id,title:e.title,description:e.description,status:e.status,priority:e.priority,issueType:e.issue_type,owner:e.owner,assignee:e.assignee,createdBy:e.created_by,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at,closeReason:e.close_reason,acceptanceCriteria:e.acceptance_criteria,estimatedMinutes:e.estimated_minutes,prefix:s(e.id),labels:e.labels||[],blockerCount:a.get(e.id)?.length||0,dependentCount:n.get(e.id)?.length||0,blockerIds:a.get(e.id)||[],dependentIds:n.get(e.id)||[]})),links:t.filter(e=>("blocks"===e.type||"parent-child"===e.type)&&r.has(e.issue_id)&&r.has(e.depends_on_id)).map(e=>({source:e.depends_on_id,target:e.issue_id,type:e.type,createdAt:e.created_at}))}}(t,a),d=function(e,t,r){let a=[...new Set(e.map(e=>s(e.id)))],n=new Set(e.filter(e=>"closed"!==e.status).map(e=>e.id)),i=new Set;for(let e of t)"blocks"===e.type&&n.has(e.depends_on_id)&&i.add(e.issue_id);let o=e.filter(e=>("open"===e.status||"in_progress"===e.status)&&!i.has(e.id)).length;return{total:e.length,open:e.filter(e=>"open"===e.status).length,inProgress:e.filter(e=>"in_progress"===e.status).length,blocked:e.filter(e=>"blocked"===e.status).length,closed:e.filter(e=>"closed"===e.status).length,actionable:o,edges:r.links.length,prefixes:a}}(t,a,l);return{issues:t,dependencies:a,graphData:l,stats:d}}e.s(["getAdditionalRepoPaths",()=>i,"loadBeadsData",()=>l])},83814,93308,e=>{"use strict";let t=new Map,r=new Map;async function a(e){let a=t.get(e);if(a)return a;let n=r.get(e);if(n)return n;let s=(async()=>{try{let r=await fetch(`https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(e)}`);if(!r.ok)throw Error(`Profile fetch failed: ${r.status}`);let a=await r.json(),n={did:e,handle:a.handle||e,displayName:a.displayName||void 0,avatar:a.avatar||void 0};return t.set(e,n),n}catch{let r={did:e,handle:e.slice(0,20)+"..."};return t.set(e,r),r}finally{r.delete(e)}})();return r.set(e,s),s}let n=process.env.INDEXER_URL||"https://hypergoat-app-production.up.railway.app/graphql",s=`
|
|
2
2
|
query FetchRecords($collection: String!, $first: Int, $after: String) {
|
|
3
3
|
records(collection: $collection, first: $first, after: $after) {
|
|
4
4
|
edges {
|
|
@@ -17,6 +17,6 @@ module.exports=[32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
`;async function s(e){let t,r=[],a=!0,s=0;for(;a&&s<5;){let o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:i,variables:{collection:e,first:100,after:t}})});if(!o.ok)throw Error(`Indexer fetch failed: ${o.status}`);let l=await o.json();if(l.errors?.length)throw Error(l.errors[0].message);let d=l.data?.records;if(!d)break;for(let e of d.edges)r.push(e.node);a=d.pageInfo.hasNextPage,t=d.pageInfo.endCursor,s++}return r}async function o(){let[e,t]=await Promise.all([s("org.impactindexer.review.comment"),s("org.impactindexer.review.like")]),r=e.filter(e=>{let t=e.value.subject;return t?.uri&&"string"==typeof t.uri&&t.uri.startsWith("beads:")}),n=new Map;for(let e of t){let t=e.value.subject;if(t?.uri&&"string"==typeof t.uri&&t.uri.startsWith("at://")){let r=n.get(t.uri)||[];r.push(e),n.set(t.uri,r)}}let i=new Set;for(let e of r)i.add(e.did);for(let e of t)i.add(e.did);let o=new Map((await Promise.all([...i].map(e=>a(e)))).map(e=>[e.did,e])),l=[];for(let e of r){let t=e.value,r=t.subject.uri.replace(/^beads:/,""),a=t.text||"",i=t.createdAt||"",s=t.replyTo||void 0,d=o.get(e.did),p=(n.get(e.uri)||[]).map(e=>{let t=o.get(e.did),r=e.value;return{did:e.did,handle:t?.handle||e.did.slice(0,20)+"...",displayName:t?.displayName,avatar:t?.avatar,createdAt:r.createdAt||"",uri:e.uri,rkey:e.rkey}}),u={did:e.did,handle:d?.handle||e.did.slice(0,20)+"...",displayName:d?.displayName,avatar:d?.avatar,text:a,createdAt:i,uri:e.uri,rkey:e.rkey,nodeId:r,replyTo:s,likes:p,replies:[]};l.push(u)}let d=new Map;for(let e of l)d.set(e.uri,e);let p=[];for(let e of l){if(e.replyTo){let t=d.get(e.replyTo);if(t){t.replies.push(e);continue}}p.push(e)}p.sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()),!function e(t){for(let r of t)r.replies.sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),e(r.replies)}(p);let u=new Map;for(let e of p){let t=u.get(e.nodeId)||[];t.push(e),u.set(e.nodeId,t)}let c=new Map;for(let e of l)c.set(e.nodeId,(c.get(e.nodeId)||0)+1);return{commentsByNode:u,commentedNodeIds:c,allComments:[...l].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())}}function l(e){let t=new Map;for(let r of[...e].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime())){if(t.has(r.nodeId))continue;let e=r.text.trim();e.startsWith("@")&&-1===e.indexOf(" ")&&t.set(r.nodeId,{handle:r.handle,did:r.did,displayName:r.displayName,avatar:r.avatar,claimedAt:r.createdAt})}return t}e.s(["fetchBeadsComments",()=>o,"getClaimedNodes",()=>l],83814);var d=e.i(69817);let p={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, OPTIONS","Access-Control-Allow-Headers":"Content-Type"};function u(e,t=200){return d.NextResponse.json(e,{status:t,headers:{...p,"Cache-Control":"public, max-age=30"}})}function c(e,t,r){return d.NextResponse.json({error:e,...r?{hint:r}:{}},{status:t,headers:p})}function f(){return new d.NextResponse(null,{status:204,headers:p})}e.s(["OPTIONS",()=>f,"errorResponse",()=>c,"jsonResponse",()=>u],93308)},77333,e=>{"use strict";var t=e.i(39776),r=e.i(76160),a=e.i(74151),n=e.i(8392),i=e.i(27644),s=e.i(15766),o=e.i(18404),l=e.i(68924),d=e.i(9942),p=e.i(77753),u=e.i(45771),c=e.i(31838),f=e.i(89953),h=e.i(17045),g=e.i(21874),y=e.i(93695);e.i(86257);var m=e.i(87875),w=e.i(48676),x=e.i(63846),v=e.i(83814),R=e.i(93308),_=e.i(22734),b=e.i(14747);let A="force-dynamic",N="0.0.0";try{N=JSON.parse((0,_.readFileSync)((0,b.join)(process.cwd(),"package.json"),"utf-8")).version||N}catch{}function C(e){return{author:{handle:e.handle,did:e.did,...e.displayName?{displayName:e.displayName}:{}},text:e.text,createdAt:e.createdAt,likes:e.likes.length,replies:e.replies.map(C)}}async function E(e){try{let t=(0,x.discoverBeadsDir)(),r=new URL(e.url).searchParams,a="true"===r.get("unclaimed"),n=r.get("type")?.split(",").filter(Boolean),i=r.get("assignee")||null,s=r.get("prefix")||null,o=r.get("limit"),l=o?Math.max(parseInt(o)||0,1):null,[d,p]=await Promise.all([Promise.resolve((0,w.loadBeadsData)(t.beadsDir)),(0,v.fetchBeadsComments)().catch(e=>(console.error("[api/v1/ready] Failed to fetch comments:",e),null))]),u=p?(0,v.getClaimedNodes)(p.allComments):new Map,c=new Map(d.graphData.nodes.map(e=>[e.id,e])),f=d.graphData.nodes.filter(e=>{if("open"!==e.status&&"in_progress"!==e.status)return!1;for(let t of e.dependentIds){let e=c.get(t);if(e&&"closed"!==e.status)return!1}return!0});n&&(f=f.filter(e=>n.includes(e.issueType))),i&&(f=f.filter(e=>e.assignee===i)),s&&(f=f.filter(e=>e.prefix===s)),a&&(f=f.filter(e=>!u.has(e.id))),f.sort((e,t)=>e.priority!==t.priority?e.priority-t.priority:new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),l&&(f=f.slice(0,l));let h=f.map(e=>{let t=p?.commentsByNode.get(e.id)||[],r=u.get(e.id)||null;return{id:e.id,title:e.title,description:e.description||null,status:e.status,priority:e.priority,issue_type:e.issueType,owner:e.owner||null,assignee:e.assignee||null,labels:e.labels,created_at:e.createdAt,updated_at:e.updatedAt,prefix:e.prefix,blockers:e.dependentIds,dependents:e.blockerIds,comments:t.map(C),claimed_by:r?{handle:r.handle,did:r.did,...r.displayName?{displayName:r.displayName}:{},claimed_at:r.claimedAt}:null}}),g={},y={},m=0;for(let e of f){let t=String(e.priority);g[t]=(g[t]||0)+1,y[e.issueType]=(y[e.issueType]||0)+1,!u.has(e.id)&&m++}let _=[];return p||_.push("Failed to fetch comments from indexer"),(0,R.jsonResponse)({issues:h,stats:{total_ready:h.length,unclaimed:m,by_priority:g,by_type:y},_meta:{generated_at:new Date().toISOString(),api_version:"v1",heartbeads_version:N,..._.length?{warnings:_}:{}}})}catch(e){if((e instanceof Error?e.message:"Unknown error").includes("No .beads/ directory found"))return(0,R.errorResponse)("No .beads directory found",404,"Run bd init in your project first, or set BEADS_DIR.");return console.error("[api/v1/ready] Error:",e),(0,R.errorResponse)("Internal server error",500)}}e.s(["GET",()=>E,"dynamic",0,A],36857),e.i(36857),e.s(["GET",()=>E,"OPTIONS",()=>R.OPTIONS,"dynamic",0,A],58887);var T=e.i(58887);let k=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/v1/ready/route",pathname:"/api/v1/ready",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/v1/ready/route.ts",nextConfigOutput:"",userland:T}),{workAsyncStorage:S,workUnitAsyncStorage:I,serverHooks:P}=k;function j(){return(0,a.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:I})}async function O(e,t,a){k.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let w="/api/v1/ready/route";w=w.replace(/\/index$/,"")||"/";let x=await k.prepare(e,t,{srcPage:w,multiZoneDraftMode:!1});if(!x)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:v,params:R,nextConfig:_,parsedUrl:b,isDraftMode:A,prerenderManifest:N,routerServerContext:C,isOnDemandRevalidate:E,revalidateOnlyGenerated:T,resolvedPathname:S,clientReferenceManifest:I,serverActionsManifest:P}=x,j=(0,o.normalizeAppPath)(w),O=!!(N.dynamicRoutes[j]||N.routes[S]),D=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,b,!1):t.end("This page could not be found"),null);if(O&&!A){let e=!!N.routes[S],t=N.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(_.experimental.adapterPath)return await D();throw new y.NoFallbackError}}let M=null;!O||k.isDev||A||(M="/index"===(M=S)?"/":M);let q=!0===k.isDev||!O,$=O&&!q;P&&I&&(0,s.setManifestsSingleton)({page:w,clientReferenceManifest:I,serverActionsManifest:P});let U=e.method||"GET",H=(0,i.getTracer)(),F=H.getActiveScopeSpan(),B={params:R,prerenderManifest:N,renderOpts:{experimental:{authInterrupts:!!_.experimental.authInterrupts},cacheComponents:!!_.cacheComponents,supportsDynamicResponse:q,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:_.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>k.onRequestError(e,t,a,n,C)},sharedContext:{buildId:v}},K=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let s=async e=>k.handle(G,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=H.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==p.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${U} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${U} ${w}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var i,l;let d=async({previousCacheEntry:r})=>{try{if(!o&&E&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await s(n);e.fetchMetrics=B.renderOpts.fetchMetrics;let l=B.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let d=B.renderOpts.collectedTags;if(!O)return await (0,c.sendResponse)(K,L,i,B.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(i.headers);d&&(t[g.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,a=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:m.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await k.onRequestError(e,t,{routerKind:"App Router",routePath:w,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,C),t}},p=await k.handleResponse({req:e,nextConfig:_,cacheKey:M,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:E,revalidateOnlyGenerated:T,responseGenerator:d,waitUntil:a.waitUntil,isMinimalMode:o});if(!O)return null;if((null==p||null==(i=p.value)?void 0:i.kind)!==m.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==p||null==(l=p.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",E?"REVALIDATED":p.isMiss?"MISS":p.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let y=(0,f.fromNodeOutgoingHttpHeaders)(p.value.headers);return o&&O||y.delete(g.NEXT_CACHE_TAGS_HEADER),!p.cacheControl||t.getHeader("Cache-Control")||y.get("Cache-Control")||y.set("Cache-Control",(0,h.getCacheControlHeader)(p.cacheControl)),await (0,c.sendResponse)(K,L,new Response(p.value.body,{headers:y,status:p.value.status||200})),null};F?await l(F):await H.withPropagatedContext(e.headers,()=>H.trace(p.BaseServerSpan.handleRequest,{spanName:`${U} ${w}`,kind:i.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},l))}catch(t){if(t instanceof y.NoFallbackError||await k.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,C),O)throw t;return await (0,c.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>O,"patchFetch",()=>j,"routeModule",()=>k,"serverHooks",()=>P,"workAsyncStorage",()=>S,"workUnitAsyncStorage",()=>I],77333)}];
|
|
20
|
+
`;async function i(e){let t,r=[],a=!0,i=0;for(;a&&i<5;){let o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,variables:{collection:e,first:100,after:t}})});if(!o.ok)throw Error(`Indexer fetch failed: ${o.status}`);let l=await o.json();if(l.errors?.length)throw Error(l.errors[0].message);let d=l.data?.records;if(!d)break;for(let e of d.edges)r.push(e.node);a=d.pageInfo.hasNextPage,t=d.pageInfo.endCursor,i++}return r}async function o(){let[e,t]=await Promise.all([i("org.impactindexer.review.comment"),i("org.impactindexer.review.like")]),r=e.filter(e=>{let t=e.value.subject;return t?.uri&&"string"==typeof t.uri&&t.uri.startsWith("beads:")}),n=new Map;for(let e of t){let t=e.value.subject;if(t?.uri&&"string"==typeof t.uri&&t.uri.startsWith("at://")){let r=n.get(t.uri)||[];r.push(e),n.set(t.uri,r)}}let s=new Set;for(let e of r)s.add(e.did);for(let e of t)s.add(e.did);let o=new Map((await Promise.all([...s].map(e=>a(e)))).map(e=>[e.did,e])),l=[];for(let e of r){let t=e.value,r=t.subject.uri.replace(/^beads:/,""),a=t.text||"",s=t.createdAt||"",i=t.replyTo||void 0,d=o.get(e.did),p=(n.get(e.uri)||[]).map(e=>{let t=o.get(e.did),r=e.value;return{did:e.did,handle:t?.handle||e.did.slice(0,20)+"...",displayName:t?.displayName,avatar:t?.avatar,createdAt:r.createdAt||"",uri:e.uri,rkey:e.rkey}}),c={did:e.did,handle:d?.handle||e.did.slice(0,20)+"...",displayName:d?.displayName,avatar:d?.avatar,text:a,createdAt:s,uri:e.uri,rkey:e.rkey,nodeId:r,replyTo:i,likes:p,replies:[]};l.push(c)}let d=new Map;for(let e of l)d.set(e.uri,e);let p=[];for(let e of l){if(e.replyTo){let t=d.get(e.replyTo);if(t){t.replies.push(e);continue}}p.push(e)}p.sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()),!function e(t){for(let r of t)r.replies.sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),e(r.replies)}(p);let c=new Map;for(let e of p){let t=c.get(e.nodeId)||[];t.push(e),c.set(e.nodeId,t)}let u=new Map;for(let e of l)u.set(e.nodeId,(u.get(e.nodeId)||0)+1);return{commentsByNode:c,commentedNodeIds:u,allComments:[...l].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())}}function l(e){let t=new Map;for(let r of[...e].sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime())){if(t.has(r.nodeId))continue;let e=r.text.trim();e.startsWith("@")&&-1===e.indexOf(" ")&&t.set(r.nodeId,{handle:r.handle,did:r.did,displayName:r.displayName,avatar:r.avatar,claimedAt:r.createdAt})}return t}e.s(["fetchBeadsComments",()=>o,"getClaimedNodes",()=>l],83814);var d=e.i(69817);let p={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, OPTIONS","Access-Control-Allow-Headers":"Content-Type"};function c(e,t=200){return d.NextResponse.json(e,{status:t,headers:{...p,"Cache-Control":"public, max-age=30"}})}function u(e,t,r){return d.NextResponse.json({error:e,...r?{hint:r}:{}},{status:t,headers:p})}function f(){return new d.NextResponse(null,{status:204,headers:p})}e.s(["OPTIONS",()=>f,"errorResponse",()=>u,"jsonResponse",()=>c],93308)},77333,e=>{"use strict";var t=e.i(39776),r=e.i(76160),a=e.i(74151),n=e.i(8392),s=e.i(27644),i=e.i(15766),o=e.i(18404),l=e.i(68924),d=e.i(9942),p=e.i(77753),c=e.i(45771),u=e.i(31838),f=e.i(89953),h=e.i(17045),g=e.i(21874),m=e.i(93695);e.i(86257);var y=e.i(87875),w=e.i(48676),x=e.i(63846),v=e.i(83814),_=e.i(93308),b=e.i(22734),R=e.i(14747);let A="force-dynamic",N="0.0.0";try{N=JSON.parse((0,b.readFileSync)((0,R.join)(process.cwd(),"package.json"),"utf-8")).version||N}catch{}function C(e){return{author:{handle:e.handle,did:e.did,...e.displayName?{displayName:e.displayName}:{}},text:e.text,createdAt:e.createdAt,likes:e.likes.length,replies:e.replies.map(C)}}async function E(e){try{let t=(0,x.discoverBeadsDir)(),r=new URL(e.url).searchParams,a="true"===r.get("unclaimed"),n=r.get("type")?.split(",").filter(Boolean),s=r.get("assignee")||null,i=r.get("prefix")||null,o=r.get("limit"),l=o?Math.max(parseInt(o)||0,1):null,[d,p]=await Promise.all([Promise.resolve((0,w.loadBeadsData)(t.beadsDir)),(0,v.fetchBeadsComments)().catch(e=>(console.error("[api/v1/ready] Failed to fetch comments:",e),null))]),c=p?(0,v.getClaimedNodes)(p.allComments):new Map,u=new Map(d.graphData.nodes.map(e=>[e.id,e])),f=d.graphData.nodes.filter(e=>{if("open"!==e.status&&"in_progress"!==e.status)return!1;for(let t of e.dependentIds){let e=u.get(t);if(e&&"closed"!==e.status)return!1}return!0});n&&(f=f.filter(e=>n.includes(e.issueType))),s&&(f=f.filter(e=>e.assignee===s)),i&&(f=f.filter(e=>e.prefix===i)),a&&(f=f.filter(e=>!c.has(e.id))),f.sort((e,t)=>e.priority!==t.priority?e.priority-t.priority:new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),l&&(f=f.slice(0,l));let h=f.map(e=>{let t=p?.commentsByNode.get(e.id)||[],r=c.get(e.id)||null;return{id:e.id,title:e.title,description:e.description||null,status:e.status,priority:e.priority,issue_type:e.issueType,owner:e.owner||null,assignee:e.assignee||null,labels:e.labels,created_at:e.createdAt,updated_at:e.updatedAt,prefix:e.prefix,blockers:e.dependentIds,dependents:e.blockerIds,comments:t.map(C),claimed_by:r?{handle:r.handle,did:r.did,...r.displayName?{displayName:r.displayName}:{},claimed_at:r.claimedAt}:null}}),g={},m={},y=0;for(let e of f){let t=String(e.priority);g[t]=(g[t]||0)+1,m[e.issueType]=(m[e.issueType]||0)+1,!c.has(e.id)&&y++}let b=[];return p||b.push("Failed to fetch comments from indexer"),(0,_.jsonResponse)({issues:h,stats:{total_ready:h.length,unclaimed:y,by_priority:g,by_type:m},_meta:{generated_at:new Date().toISOString(),api_version:"v1",heartbeads_version:N,...b.length?{warnings:b}:{}}})}catch(e){if((e instanceof Error?e.message:"Unknown error").includes("No .beads/ directory found"))return(0,_.errorResponse)("No .beads directory found",404,"Run bd init in your project first, or set BEADS_DIR.");return console.error("[api/v1/ready] Error:",e),(0,_.errorResponse)("Internal server error",500)}}e.s(["GET",()=>E,"dynamic",0,A],36857),e.i(36857),e.s(["GET",()=>E,"OPTIONS",()=>_.OPTIONS,"dynamic",0,A],58887);var T=e.i(58887);let k=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/v1/ready/route",pathname:"/api/v1/ready",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/v1/ready/route.ts",nextConfigOutput:"",userland:T}),{workAsyncStorage:S,workUnitAsyncStorage:I,serverHooks:P}=k;function j(){return(0,a.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:I})}async function O(e,t,a){k.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let w="/api/v1/ready/route";w=w.replace(/\/index$/,"")||"/";let x=await k.prepare(e,t,{srcPage:w,multiZoneDraftMode:!1});if(!x)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:v,params:_,nextConfig:b,parsedUrl:R,isDraftMode:A,prerenderManifest:N,routerServerContext:C,isOnDemandRevalidate:E,revalidateOnlyGenerated:T,resolvedPathname:S,clientReferenceManifest:I,serverActionsManifest:P}=x,j=(0,o.normalizeAppPath)(w),O=!!(N.dynamicRoutes[j]||N.routes[S]),D=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,R,!1):t.end("This page could not be found"),null);if(O&&!A){let e=!!N.routes[S],t=N.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(b.experimental.adapterPath)return await D();throw new m.NoFallbackError}}let M=null;!O||k.isDev||A||(M="/index"===(M=S)?"/":M);let q=!0===k.isDev||!O,$=O&&!q;P&&I&&(0,i.setManifestsSingleton)({page:w,clientReferenceManifest:I,serverActionsManifest:P});let U=e.method||"GET",H=(0,s.getTracer)(),F=H.getActiveScopeSpan(),B={params:_,prerenderManifest:N,renderOpts:{experimental:{authInterrupts:!!b.experimental.authInterrupts},cacheComponents:!!b.cacheComponents,supportsDynamicResponse:q,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:b.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>k.onRequestError(e,t,a,n,C)},sharedContext:{buildId:v}},K=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let i=async e=>k.handle(G,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=H.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==p.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${U} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${U} ${w}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let d=async({previousCacheEntry:r})=>{try{if(!o&&E&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=B.renderOpts.fetchMetrics;let l=B.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let d=B.renderOpts.collectedTags;if(!O)return await (0,u.sendResponse)(K,L,s,B.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[g.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,a=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await k.onRequestError(e,t,{routerKind:"App Router",routePath:w,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,C),t}},p=await k.handleResponse({req:e,nextConfig:b,cacheKey:M,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:E,revalidateOnlyGenerated:T,responseGenerator:d,waitUntil:a.waitUntil,isMinimalMode:o});if(!O)return null;if((null==p||null==(s=p.value)?void 0:s.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==p||null==(l=p.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",E?"REVALIDATED":p.isMiss?"MISS":p.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,f.fromNodeOutgoingHttpHeaders)(p.value.headers);return o&&O||m.delete(g.NEXT_CACHE_TAGS_HEADER),!p.cacheControl||t.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,h.getCacheControlHeader)(p.cacheControl)),await (0,u.sendResponse)(K,L,new Response(p.value.body,{headers:m,status:p.value.status||200})),null};F?await l(F):await H.withPropagatedContext(e.headers,()=>H.trace(p.BaseServerSpan.handleRequest,{spanName:`${U} ${w}`,kind:s.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},l))}catch(t){if(t instanceof m.NoFallbackError||await k.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,C),O)throw t;return await (0,u.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>O,"patchFetch",()=>j,"routeModule",()=>k,"serverHooks",()=>P,"workAsyncStorage",()=>S,"workUnitAsyncStorage",()=>I],77333)}];
|
|
21
21
|
|
|
22
22
|
//# sourceMappingURL=%5Broot-of-the-server%5D__77e35ba8._.js.map
|