@iloom/cli 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -18
  3. package/dist/{BranchNamingService-B5PVRR7F.js → BranchNamingService-FLPUUFOB.js} +2 -2
  4. package/dist/ClaudeContextManager-KE5TBZVZ.js +14 -0
  5. package/dist/ClaudeService-CRSETT3A.js +13 -0
  6. package/dist/{GitHubService-S2OGUTDR.js → GitHubService-O7U4UQ7N.js} +3 -3
  7. package/dist/{LoomLauncher-5LFM4LXB.js → LoomLauncher-NL65LSKP.js} +6 -6
  8. package/dist/{MetadataManager-DFI73J3G.js → MetadataManager-XJ2YB762.js} +2 -2
  9. package/dist/PRManager-2ABCWXHW.js +16 -0
  10. package/dist/{ProjectCapabilityDetector-S5FLNCFI.js → ProjectCapabilityDetector-IA56AUE6.js} +3 -3
  11. package/dist/{PromptTemplateManager-C3DK6XZL.js → PromptTemplateManager-7L3HJQQU.js} +2 -2
  12. package/dist/README.md +35 -18
  13. package/dist/{SettingsManager-35F5RUJH.js → SettingsManager-YU4VYPTW.js} +2 -2
  14. package/dist/agents/iloom-framework-detector.md +78 -9
  15. package/dist/agents/iloom-issue-analyze-and-plan.md +42 -17
  16. package/dist/agents/iloom-issue-analyzer.md +14 -14
  17. package/dist/agents/iloom-issue-complexity-evaluator.md +38 -15
  18. package/dist/agents/iloom-issue-enhancer.md +15 -15
  19. package/dist/agents/iloom-issue-implementer.md +44 -15
  20. package/dist/agents/iloom-issue-planner.md +121 -17
  21. package/dist/agents/iloom-issue-reviewer.md +15 -15
  22. package/dist/{build-FJVYP7EV.js → build-HQ5HGA3T.js} +9 -9
  23. package/dist/{chunk-VU3QMIP2.js → chunk-453NC377.js} +91 -15
  24. package/dist/chunk-453NC377.js.map +1 -0
  25. package/dist/{chunk-UQIXZ3BA.js → chunk-5V74K5ZA.js} +2 -2
  26. package/dist/{chunk-7WANFUIK.js → chunk-6TL3BYH6.js} +2 -2
  27. package/dist/{chunk-ZPSTA5PR.js → chunk-7GLZVDPQ.js} +2 -2
  28. package/dist/{chunk-64O2UIWO.js → chunk-AFRICMSW.js} +4 -4
  29. package/dist/{chunk-5TXLVEXT.js → chunk-C3AKFAIR.js} +2 -2
  30. package/dist/{chunk-K7SEEHKO.js → chunk-CNSTXBJ3.js} +7 -419
  31. package/dist/chunk-CNSTXBJ3.js.map +1 -0
  32. package/dist/{chunk-2A7WQKBE.js → chunk-DAOS6EC3.js} +96 -6
  33. package/dist/chunk-DAOS6EC3.js.map +1 -0
  34. package/dist/{chunk-TRQ76ISK.js → chunk-ELJKYFSH.js} +9 -9
  35. package/dist/{chunk-VDA5JMB4.js → chunk-EPPPDVHD.js} +21 -8
  36. package/dist/chunk-EPPPDVHD.js.map +1 -0
  37. package/dist/{chunk-LVBRMTE6.js → chunk-FEAJR6PN.js} +6 -6
  38. package/dist/{chunk-6YSFTPKW.js → chunk-FM4KBPVA.js} +18 -13
  39. package/dist/chunk-FM4KBPVA.js.map +1 -0
  40. package/dist/{chunk-AEIMYF4P.js → chunk-FP7G7DG3.js} +6 -2
  41. package/dist/chunk-FP7G7DG3.js.map +1 -0
  42. package/dist/{chunk-LT3SGBR7.js → chunk-GCPAZSGV.js} +36 -2
  43. package/dist/{chunk-LT3SGBR7.js.map → chunk-GCPAZSGV.js.map} +1 -1
  44. package/dist/chunk-GJMEKEI5.js +517 -0
  45. package/dist/chunk-GJMEKEI5.js.map +1 -0
  46. package/dist/{chunk-7Q66W4OH.js → chunk-HBJITKSZ.js} +37 -1
  47. package/dist/chunk-HBJITKSZ.js.map +1 -0
  48. package/dist/{chunk-7HIRPCKU.js → chunk-HVQNVRAF.js} +2 -2
  49. package/dist/{chunk-6U6VI4SZ.js → chunk-KVS4XGBQ.js} +4 -4
  50. package/dist/{chunk-SN3Z6EZO.js → chunk-N7FVXZNI.js} +2 -2
  51. package/dist/{chunk-I75JMBNB.js → chunk-QQFBMCAH.js} +54 -43
  52. package/dist/chunk-QQFBMCAH.js.map +1 -0
  53. package/dist/{chunk-AXX3QIKK.js → chunk-RD7I2Q2F.js} +2 -2
  54. package/dist/chunk-TIYJEEVO.js +79 -0
  55. package/dist/chunk-TIYJEEVO.js.map +1 -0
  56. package/dist/{chunk-EK3XCAAS.js → chunk-UDRZY65Y.js} +2 -2
  57. package/dist/{chunk-3PT7RKL5.js → chunk-USJSNHGG.js} +2 -2
  58. package/dist/{chunk-CFUWQHCJ.js → chunk-VWGKGNJP.js} +114 -35
  59. package/dist/chunk-VWGKGNJP.js.map +1 -0
  60. package/dist/{chunk-F6WVM437.js → chunk-WFQ5CLTR.js} +6 -3
  61. package/dist/chunk-WFQ5CLTR.js.map +1 -0
  62. package/dist/{chunk-BXCPJJYM.js → chunk-XPKN3QWY.js} +24 -6
  63. package/dist/chunk-XPKN3QWY.js.map +1 -0
  64. package/dist/chunk-YQNSZKKT.js +822 -0
  65. package/dist/chunk-YQNSZKKT.js.map +1 -0
  66. package/dist/{chunk-GEXP5IOF.js → chunk-ZA575VLF.js} +21 -8
  67. package/dist/chunk-ZA575VLF.js.map +1 -0
  68. package/dist/{claude-H33OQMXO.js → claude-6H36IBHO.js} +4 -2
  69. package/dist/{cleanup-BRUAINKE.js → cleanup-77U5ATYI.js} +20 -16
  70. package/dist/cleanup-77U5ATYI.js.map +1 -0
  71. package/dist/cli.js +361 -954
  72. package/dist/cli.js.map +1 -1
  73. package/dist/commit-ONRXU67O.js +237 -0
  74. package/dist/commit-ONRXU67O.js.map +1 -0
  75. package/dist/{compile-ULNO5F7Q.js → compile-CT7IR7O2.js} +9 -9
  76. package/dist/{contribute-Q6GX6AXK.js → contribute-GXKOIA42.js} +5 -5
  77. package/dist/{dev-server-4RCDJ5MU.js → dev-server-UKAPBGUR.js} +22 -74
  78. package/dist/dev-server-UKAPBGUR.js.map +1 -0
  79. package/dist/{feedback-O4Q55SVS.js → feedback-K3A4QUSG.js} +10 -10
  80. package/dist/{git-FVMGBHC2.js → git-ENLT2VNI.js} +6 -4
  81. package/dist/hooks/iloom-hook.js +30 -2
  82. package/dist/{ignite-VHV65WEZ.js → ignite-YUAOJ5PP.js} +20 -20
  83. package/dist/ignite-YUAOJ5PP.js.map +1 -0
  84. package/dist/index.d.ts +71 -27
  85. package/dist/index.js +196 -266
  86. package/dist/index.js.map +1 -1
  87. package/dist/init-XQQMFDM6.js +21 -0
  88. package/dist/{lint-5JMCWE4Y.js → lint-HAVU4U34.js} +9 -9
  89. package/dist/mcp/issue-management-server.js +359 -13
  90. package/dist/mcp/issue-management-server.js.map +1 -1
  91. package/dist/mcp/recap-server.js +13 -4
  92. package/dist/mcp/recap-server.js.map +1 -1
  93. package/dist/{open-WHVUYGPY.js → open-QI63XQ4F.js} +25 -76
  94. package/dist/open-QI63XQ4F.js.map +1 -0
  95. package/dist/{projects-SA76I4TZ.js → projects-TWY4RT2Z.js} +11 -4
  96. package/dist/projects-TWY4RT2Z.js.map +1 -0
  97. package/dist/prompts/init-prompt.txt +119 -51
  98. package/dist/prompts/issue-prompt.txt +132 -63
  99. package/dist/prompts/pr-prompt.txt +3 -3
  100. package/dist/prompts/regular-prompt.txt +16 -18
  101. package/dist/prompts/session-summary-prompt.txt +13 -13
  102. package/dist/{rebase-Y4AS6LQW.js → rebase-QYCRF7JG.js} +53 -8
  103. package/dist/rebase-QYCRF7JG.js.map +1 -0
  104. package/dist/{recap-VOOUXOGP.js → recap-ZKGHZCX6.js} +6 -6
  105. package/dist/{run-NCRK5NPR.js → run-YDVYORT2.js} +25 -76
  106. package/dist/run-YDVYORT2.js.map +1 -0
  107. package/dist/schema/settings.schema.json +14 -3
  108. package/dist/{shell-SBLXVOVJ.js → shell-2NNSIU34.js} +6 -6
  109. package/dist/{summary-CVFAMDOJ.js → summary-G6L3VAKK.js} +11 -10
  110. package/dist/{summary-CVFAMDOJ.js.map → summary-G6L3VAKK.js.map} +1 -1
  111. package/dist/{test-3KIVXI6J.js → test-75WAA6DU.js} +9 -9
  112. package/dist/{test-git-ZB6AGGRW.js → test-git-E2BLXR6M.js} +4 -4
  113. package/dist/{test-prefix-FBGXKMPA.js → test-prefix-A7JGGYAA.js} +4 -4
  114. package/dist/{test-webserver-YVQD42W6.js → test-webserver-NRMGT2HB.js} +29 -8
  115. package/dist/test-webserver-NRMGT2HB.js.map +1 -0
  116. package/package.json +3 -1
  117. package/dist/ClaudeContextManager-6J2EB4QU.js +0 -14
  118. package/dist/ClaudeService-O2PB22GX.js +0 -13
  119. package/dist/PRManager-GB3FOJ2W.js +0 -14
  120. package/dist/chunk-2A7WQKBE.js.map +0 -1
  121. package/dist/chunk-6YSFTPKW.js.map +0 -1
  122. package/dist/chunk-7Q66W4OH.js.map +0 -1
  123. package/dist/chunk-AEIMYF4P.js.map +0 -1
  124. package/dist/chunk-BXCPJJYM.js.map +0 -1
  125. package/dist/chunk-CFUWQHCJ.js.map +0 -1
  126. package/dist/chunk-F6WVM437.js.map +0 -1
  127. package/dist/chunk-GEXP5IOF.js.map +0 -1
  128. package/dist/chunk-I75JMBNB.js.map +0 -1
  129. package/dist/chunk-K7SEEHKO.js.map +0 -1
  130. package/dist/chunk-VDA5JMB4.js.map +0 -1
  131. package/dist/chunk-VU3QMIP2.js.map +0 -1
  132. package/dist/chunk-W6WVRHJ6.js +0 -251
  133. package/dist/chunk-W6WVRHJ6.js.map +0 -1
  134. package/dist/cleanup-BRUAINKE.js.map +0 -1
  135. package/dist/dev-server-4RCDJ5MU.js.map +0 -1
  136. package/dist/ignite-VHV65WEZ.js.map +0 -1
  137. package/dist/init-UTYRHNJJ.js +0 -21
  138. package/dist/open-WHVUYGPY.js.map +0 -1
  139. package/dist/projects-SA76I4TZ.js.map +0 -1
  140. package/dist/rebase-Y4AS6LQW.js.map +0 -1
  141. package/dist/run-NCRK5NPR.js.map +0 -1
  142. package/dist/test-webserver-YVQD42W6.js.map +0 -1
  143. /package/dist/{BranchNamingService-B5PVRR7F.js.map → BranchNamingService-FLPUUFOB.js.map} +0 -0
  144. /package/dist/{ClaudeContextManager-6J2EB4QU.js.map → ClaudeContextManager-KE5TBZVZ.js.map} +0 -0
  145. /package/dist/{ClaudeService-O2PB22GX.js.map → ClaudeService-CRSETT3A.js.map} +0 -0
  146. /package/dist/{GitHubService-S2OGUTDR.js.map → GitHubService-O7U4UQ7N.js.map} +0 -0
  147. /package/dist/{LoomLauncher-5LFM4LXB.js.map → LoomLauncher-NL65LSKP.js.map} +0 -0
  148. /package/dist/{MetadataManager-DFI73J3G.js.map → MetadataManager-XJ2YB762.js.map} +0 -0
  149. /package/dist/{PRManager-GB3FOJ2W.js.map → PRManager-2ABCWXHW.js.map} +0 -0
  150. /package/dist/{ProjectCapabilityDetector-S5FLNCFI.js.map → ProjectCapabilityDetector-IA56AUE6.js.map} +0 -0
  151. /package/dist/{PromptTemplateManager-C3DK6XZL.js.map → PromptTemplateManager-7L3HJQQU.js.map} +0 -0
  152. /package/dist/{SettingsManager-35F5RUJH.js.map → SettingsManager-YU4VYPTW.js.map} +0 -0
  153. /package/dist/{build-FJVYP7EV.js.map → build-HQ5HGA3T.js.map} +0 -0
  154. /package/dist/{chunk-UQIXZ3BA.js.map → chunk-5V74K5ZA.js.map} +0 -0
  155. /package/dist/{chunk-7WANFUIK.js.map → chunk-6TL3BYH6.js.map} +0 -0
  156. /package/dist/{chunk-ZPSTA5PR.js.map → chunk-7GLZVDPQ.js.map} +0 -0
  157. /package/dist/{chunk-64O2UIWO.js.map → chunk-AFRICMSW.js.map} +0 -0
  158. /package/dist/{chunk-5TXLVEXT.js.map → chunk-C3AKFAIR.js.map} +0 -0
  159. /package/dist/{chunk-TRQ76ISK.js.map → chunk-ELJKYFSH.js.map} +0 -0
  160. /package/dist/{chunk-LVBRMTE6.js.map → chunk-FEAJR6PN.js.map} +0 -0
  161. /package/dist/{chunk-7HIRPCKU.js.map → chunk-HVQNVRAF.js.map} +0 -0
  162. /package/dist/{chunk-6U6VI4SZ.js.map → chunk-KVS4XGBQ.js.map} +0 -0
  163. /package/dist/{chunk-SN3Z6EZO.js.map → chunk-N7FVXZNI.js.map} +0 -0
  164. /package/dist/{chunk-AXX3QIKK.js.map → chunk-RD7I2Q2F.js.map} +0 -0
  165. /package/dist/{chunk-EK3XCAAS.js.map → chunk-UDRZY65Y.js.map} +0 -0
  166. /package/dist/{chunk-3PT7RKL5.js.map → chunk-USJSNHGG.js.map} +0 -0
  167. /package/dist/{claude-H33OQMXO.js.map → claude-6H36IBHO.js.map} +0 -0
  168. /package/dist/{compile-ULNO5F7Q.js.map → compile-CT7IR7O2.js.map} +0 -0
  169. /package/dist/{contribute-Q6GX6AXK.js.map → contribute-GXKOIA42.js.map} +0 -0
  170. /package/dist/{feedback-O4Q55SVS.js.map → feedback-K3A4QUSG.js.map} +0 -0
  171. /package/dist/{git-FVMGBHC2.js.map → git-ENLT2VNI.js.map} +0 -0
  172. /package/dist/{init-UTYRHNJJ.js.map → init-XQQMFDM6.js.map} +0 -0
  173. /package/dist/{lint-5JMCWE4Y.js.map → lint-HAVU4U34.js.map} +0 -0
  174. /package/dist/{recap-VOOUXOGP.js.map → recap-ZKGHZCX6.js.map} +0 -0
  175. /package/dist/{shell-SBLXVOVJ.js.map → shell-2NNSIU34.js.map} +0 -0
  176. /package/dist/{test-3KIVXI6J.js.map → test-75WAA6DU.js.map} +0 -0
  177. /package/dist/{test-git-ZB6AGGRW.js.map → test-git-E2BLXR6M.js.map} +0 -0
  178. /package/dist/{test-prefix-FBGXKMPA.js.map → test-prefix-A7JGGYAA.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mcp/GitHubIssueManagementProvider.ts","../src/utils/linear-markup-converter.ts","../src/mcp/LinearIssueManagementProvider.ts","../src/mcp/IssueManagementProviderFactory.ts"],"sourcesContent":["/**\n * GitHub implementation of Issue Management Provider\n * Uses GitHub CLI for all operations\n * Normalizes GitHub-specific fields (login) to provider-agnostic core fields (id, displayName)\n */\n\nimport type {\n\tIssueManagementProvider,\n\tGetIssueInput,\n\tGetCommentInput,\n\tCreateCommentInput,\n\tUpdateCommentInput,\n\tCreateIssueInput,\n\tCreateChildIssueInput,\n\tCreateIssueResult,\n\tIssueResult,\n\tCommentDetailResult,\n\tCommentResult,\n\tFlexibleAuthor,\n} from './types.js'\nimport {\n\texecuteGhCommand,\n\tcreateIssueComment,\n\tupdateIssueComment,\n\tcreatePRComment,\n\tcreateIssue,\n\tgetIssueNodeId,\n\taddSubIssue,\n} from '../utils/github.js'\n\n/**\n * GitHub-specific author structure from API\n */\ninterface GitHubAuthor {\n\tlogin: string\n\tid?: number\n\tavatarUrl?: string\n\turl?: string\n}\n\n/**\n * Normalize GitHub author to FlexibleAuthor format\n */\nfunction normalizeAuthor(author: GitHubAuthor | null | undefined): FlexibleAuthor | null {\n\tif (!author) return null\n\n\treturn {\n\t\tid: author.id ? String(author.id) : author.login,\n\t\tdisplayName: author.login, // GitHub uses login as primary identifier\n\t\tlogin: author.login, // Preserve original GitHub field\n\t\t...(author.avatarUrl && { avatarUrl: author.avatarUrl }),\n\t\t...(author.url && { url: author.url }),\n\t}\n}\n\n/**\n * Extract numeric comment ID from GitHub comment URL\n * URL format: https://github.com/owner/repo/issues/123#issuecomment-3615239386\n */\nexport function extractNumericIdFromUrl(url: string): string {\n\tconst match = url.match(/#issuecomment-(\\d+)$/)\n\tif (!match?.[1]) {\n\t\tthrow new Error(`Cannot extract comment ID from URL: ${url}`)\n\t}\n\treturn match[1]\n}\n\n/**\n * GitHub-specific implementation of IssueManagementProvider\n */\nexport class GitHubIssueManagementProvider implements IssueManagementProvider {\n\treadonly providerName = 'github'\n\treadonly issuePrefix = '#'\n\n\t/**\n\t * Fetch issue details using gh CLI\n\t * Normalizes GitHub-specific fields to provider-agnostic format\n\t */\n\tasync getIssue(input: GetIssueInput): Promise<IssueResult> {\n\t\tconst { number, includeComments = true, repo } = input\n\n\t\t// Convert string ID to number for GitHub CLI\n\t\tconst issueNumber = parseInt(number, 10)\n\t\tif (isNaN(issueNumber)) {\n\t\t\tthrow new Error(`Invalid GitHub issue number: ${number}. GitHub issue IDs must be numeric.`)\n\t\t}\n\n\t\t// Build fields list based on whether we need comments\n\t\tconst fields = includeComments\n\t\t\t? 'body,title,comments,labels,assignees,milestone,author,state,number,url'\n\t\t\t: 'body,title,labels,assignees,milestone,author,state,number,url'\n\n\t\t// Use gh issue view to fetch issue details\n\t\tinterface GitHubIssueResponse {\n\t\t\tnumber: number\n\t\t\ttitle: string\n\t\t\tbody: string\n\t\t\tstate: string\n\t\t\turl: string\n\t\t\tauthor?: GitHubAuthor\n\t\t\tlabels?: Array<{ name: string; color?: string; description?: string }>\n\t\t\tassignees?: Array<GitHubAuthor>\n\t\t\tmilestone?: { title: string; number?: number; state?: string }\n\t\t\tcomments?: Array<{\n\t\t\t\tid: number\n\t\t\t\tauthor: GitHubAuthor\n\t\t\t\tbody: string\n\t\t\t\tcreatedAt: string\n\t\t\t\tupdatedAt?: string\n\t\t\t\turl: string\n\t\t\t}>\n\t\t}\n\n\t\tconst args = [\n\t\t\t'issue',\n\t\t\t'view',\n\t\t\tString(issueNumber),\n\t\t\t'--json',\n\t\t\tfields,\n\t\t]\n\n\t\t// Add --repo flag if repo is provided (gh CLI handles both owner/repo and URL formats)\n\t\tif (repo) {\n\t\t\targs.push('--repo', repo)\n\t\t}\n\n\t\tconst raw = await executeGhCommand<GitHubIssueResponse>(args)\n\n\t\t// Normalize to IssueResult with core fields + passthrough\n\t\tconst result: IssueResult = {\n\t\t\t// Core fields\n\t\t\tid: String(raw.number),\n\t\t\ttitle: raw.title,\n\t\t\tbody: raw.body,\n\t\t\tstate: raw.state,\n\t\t\turl: raw.url,\n\t\t\tprovider: 'github',\n\n\t\t\t// Normalized author\n\t\t\tauthor: normalizeAuthor(raw.author),\n\n\t\t\t// Optional flexible fields\n\t\t\t...(raw.assignees && {\n\t\t\t\tassignees: raw.assignees.map(a => normalizeAuthor(a)).filter((a): a is FlexibleAuthor => a !== null),\n\t\t\t}),\n\t\t\t...(raw.labels && {\n\t\t\t\tlabels: raw.labels,\n\t\t\t}),\n\n\t\t\t// GitHub-specific passthrough fields\n\t\t\t...(raw.milestone && {\n\t\t\t\tmilestone: raw.milestone,\n\t\t\t}),\n\t\t}\n\n\t\t// Handle comments with normalized authors\n\t\t// Use extractNumericIdFromUrl to get REST API-compatible numeric IDs from comment URLs\n\t\t// (GitHub CLI returns GraphQL node IDs in the id field, but REST API expects numeric IDs)\n\t\tif (raw.comments !== undefined) {\n\t\t\tresult.comments = raw.comments.map(comment => ({\n\t\t\t\tid: extractNumericIdFromUrl(comment.url),\n\t\t\t\tbody: comment.body,\n\t\t\t\tcreatedAt: comment.createdAt,\n\t\t\t\tauthor: normalizeAuthor(comment.author),\n\t\t\t\t...(comment.updatedAt && { updatedAt: comment.updatedAt }),\n\t\t\t}))\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Fetch a specific comment by ID using gh API\n\t * Normalizes author to FlexibleAuthor format\n\t */\n\tasync getComment(input: GetCommentInput): Promise<CommentDetailResult> {\n\t\tconst { commentId, repo } = input\n\t\t// Note: GitHub doesn't need the issue number parameter - comment IDs are globally unique\n\t\t// But we accept it for interface compatibility with other providers\n\n\t\t// Convert string ID to number for GitHub API\n\t\tconst numericCommentId = parseInt(commentId, 10)\n\t\tif (isNaN(numericCommentId)) {\n\t\t\tthrow new Error(`Invalid GitHub comment ID: ${commentId}. GitHub comment IDs must be numeric.`)\n\t\t}\n\n\t\t// GitHub API response structure\n\t\tinterface GitHubCommentResponse {\n\t\t\tid: number\n\t\t\tbody: string\n\t\t\tuser: GitHubAuthor\n\t\t\tcreated_at: string\n\t\t\tupdated_at?: string\n\t\t\thtml_url?: string\n\t\t\treactions?: Record<string, unknown>\n\t\t}\n\n\t\t// Use explicit repo path if provided, otherwise use :owner/:repo placeholder\n\t\tconst apiPath = repo\n\t\t\t? `repos/${repo}/issues/comments/${numericCommentId}`\n\t\t\t: `repos/:owner/:repo/issues/comments/${numericCommentId}`\n\n\t\t// Use gh api to fetch specific comment\n\t\tconst raw = await executeGhCommand<GitHubCommentResponse>([\n\t\t\t'api',\n\t\t\tapiPath,\n\t\t\t'--jq',\n\t\t\t'{id: .id, body: .body, user: .user, created_at: .created_at, updated_at: .updated_at, html_url: .html_url, reactions: .reactions}',\n\t\t])\n\n\t\t// Normalize to CommentDetailResult\n\t\treturn {\n\t\t\tid: String(raw.id),\n\t\t\tbody: raw.body,\n\t\t\tauthor: normalizeAuthor(raw.user),\n\t\t\tcreated_at: raw.created_at,\n\t\t\t...(raw.updated_at && { updated_at: raw.updated_at }),\n\t\t\t// Passthrough GitHub-specific fields\n\t\t\t...(raw.html_url && { html_url: raw.html_url }),\n\t\t\t...(raw.reactions && { reactions: raw.reactions }),\n\t\t}\n\t}\n\n\t/**\n\t * Create a new comment on an issue or PR\n\t */\n\tasync createComment(input: CreateCommentInput): Promise<CommentResult> {\n\t\tconst { number, body, type } = input\n\n\t\t// Convert string ID to number for GitHub utilities\n\t\tconst numericId = parseInt(number, 10)\n\t\tif (isNaN(numericId)) {\n\t\t\tthrow new Error(`Invalid GitHub ${type} number: ${number}. GitHub IDs must be numeric.`)\n\t\t}\n\n\t\t// Delegate to existing GitHub utilities\n\t\tconst result =\n\t\t\ttype === 'issue'\n\t\t\t\t? await createIssueComment(numericId, body)\n\t\t\t\t: await createPRComment(numericId, body)\n\n\t\t// Convert numeric ID to string for the interface\n\t\treturn {\n\t\t\t...result,\n\t\t\tid: String(result.id),\n\t\t}\n\t}\n\n\t/**\n\t * Update an existing comment\n\t */\n\tasync updateComment(input: UpdateCommentInput): Promise<CommentResult> {\n\t\tconst { commentId, body } = input\n\t\t// Note: GitHub doesn't need the issue number parameter - comment IDs are globally unique\n\t\t// But we accept it for interface compatibility with other providers\n\n\t\t// Convert string ID to number for GitHub utility\n\t\tconst numericCommentId = parseInt(commentId, 10)\n\t\tif (isNaN(numericCommentId)) {\n\t\t\tthrow new Error(`Invalid GitHub comment ID: ${commentId}. GitHub comment IDs must be numeric.`)\n\t\t}\n\n\t\t// Delegate to existing GitHub utility\n\t\tconst result = await updateIssueComment(numericCommentId, body)\n\n\t\t// Convert numeric ID to string for the interface\n\t\treturn {\n\t\t\t...result,\n\t\t\tid: String(result.id),\n\t\t}\n\t}\n\n\t/**\n\t * Create a new issue\n\t */\n\tasync createIssue(input: CreateIssueInput): Promise<CreateIssueResult> {\n\t\tconst { title, body, labels, repo } = input\n\t\t// teamKey is ignored for GitHub\n\n\t\tconst result = await createIssue(title, body, { labels, repo })\n\n\t\t// Ensure number is numeric\n\t\tconst issueNumber = typeof result.number === 'number'\n\t\t\t? result.number\n\t\t\t: parseInt(String(result.number), 10)\n\n\t\treturn {\n\t\t\tid: String(issueNumber),\n\t\t\turl: result.url,\n\t\t\tnumber: issueNumber,\n\t\t}\n\t}\n\n\t/**\n\t * Create a child issue linked to a parent issue\n\t * GitHub requires two-step process: create issue, then link via GraphQL\n\t */\n\tasync createChildIssue(input: CreateChildIssueInput): Promise<CreateIssueResult> {\n\t\tconst { parentId, title, body, labels, repo } = input\n\t\t// teamKey is ignored for GitHub\n\n\t\t// Convert parent identifier to number\n\t\tconst parentNumber = parseInt(parentId, 10)\n\t\tif (isNaN(parentNumber)) {\n\t\t\tthrow new Error(`Invalid GitHub parent issue number: ${parentId}. GitHub issue IDs must be numeric.`)\n\t\t}\n\n\t\t// Step 1: Get parent issue's GraphQL node ID\n\t\tconst parentNodeId = await getIssueNodeId(parentNumber, repo)\n\n\t\t// Step 2: Create the child issue\n\t\tconst childResult = await createIssue(title, body, { labels, repo })\n\t\tconst childNumber = typeof childResult.number === 'number'\n\t\t\t? childResult.number\n\t\t\t: parseInt(String(childResult.number), 10)\n\n\t\t// Step 3: Get child issue's GraphQL node ID\n\t\tconst childNodeId = await getIssueNodeId(childNumber, repo)\n\n\t\t// Step 4: Link child to parent via GraphQL mutation\n\t\tawait addSubIssue(parentNodeId, childNodeId)\n\n\t\treturn {\n\t\t\tid: String(childNumber),\n\t\t\turl: childResult.url,\n\t\t\tnumber: childNumber,\n\t\t}\n\t}\n}\n","import { appendFileSync } from 'node:fs'\nimport { join, dirname, basename, extname } from 'node:path'\n\n/**\n * Utility class for converting HTML details/summary format to Linear's collapsible format\n *\n * Converts:\n * <details>\n * <summary>Header</summary>\n * CONTENT\n * </details>\n *\n * Into Linear format:\n * +++ Header\n *\n * CONTENT\n *\n * +++\n */\nexport class LinearMarkupConverter {\n\t/**\n\t * Convert HTML details/summary blocks to Linear's collapsible format\n\t * Handles nested details blocks recursively\n\t *\n\t * @param text - Text containing HTML details/summary blocks\n\t * @returns Text with details/summary converted to Linear format\n\t */\n\tstatic convertDetailsToLinear(text: string): string {\n\t\tif (!text) {\n\t\t\treturn text\n\t\t}\n\n\t\t// Process from innermost to outermost to handle nesting correctly\n\t\t// Keep converting until no more details blocks are found\n\t\tlet previousText = ''\n\t\tlet currentText = text\n\n\t\twhile (previousText !== currentText) {\n\t\t\tpreviousText = currentText\n\t\t\tcurrentText = this.convertSinglePass(currentText)\n\t\t}\n\n\t\treturn currentText\n\t}\n\n\t/**\n\t * Perform a single pass of details block conversion\n\t * Converts the innermost details blocks first\n\t */\n\tprivate static convertSinglePass(text: string): string {\n\t\t// Match <details> blocks with optional attributes on the details tag\n\t\t// Supports multiline content between tags\n\t\tconst detailsRegex = /<details[^>]*>\\s*<summary[^>]*>(.*?)<\\/summary>\\s*(.*?)\\s*<\\/details>/gis\n\n\t\treturn text.replace(detailsRegex, (_match, summary, content) => {\n\t\t\t// Clean up the summary - trim whitespace and decode HTML entities\n\t\t\tconst cleanSummary = this.cleanText(summary)\n\n\t\t\t// Clean up the content - preserve internal structure but normalize outer whitespace\n\t\t\t// Note: Don't recursively convert here - the while loop handles that\n\t\t\tconst cleanContent = this.cleanContent(content)\n\n\t\t\t// Build Linear collapsible format\n\t\t\t// Always include blank lines around content for readability\n\t\t\tif (cleanContent) {\n\t\t\t\treturn `+++ ${cleanSummary}\\n\\n${cleanContent}\\n\\n+++`\n\t\t\t} else {\n\t\t\t\t// Empty content - use minimal format\n\t\t\t\treturn `+++ ${cleanSummary}\\n\\n+++`\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Clean text by trimming whitespace and decoding common HTML entities\n\t */\n\tprivate static cleanText(text: string): string {\n\t\treturn text\n\t\t\t.trim()\n\t\t\t.replace(/&lt;/g, '<')\n\t\t\t.replace(/&gt;/g, '>')\n\t\t\t.replace(/&amp;/g, '&')\n\t\t\t.replace(/&quot;/g, '\"')\n\t\t\t.replace(/&#39;/g, \"'\")\n\t}\n\n\t/**\n\t * Clean content while preserving internal structure\n\t * - Removes leading/trailing whitespace\n\t * - Normalizes internal blank lines (max 2 consecutive newlines)\n\t * - Preserves code blocks and other formatting\n\t */\n\tprivate static cleanContent(content: string): string {\n\t\tif (!content) {\n\t\t\treturn ''\n\t\t}\n\n\t\t// Trim outer whitespace\n\t\tlet cleaned = content.trim()\n\n\t\t// Normalize excessive blank lines (3+ newlines -> 2 newlines)\n\t\tcleaned = cleaned.replace(/\\n{3,}/g, '\\n\\n')\n\n\t\treturn cleaned\n\t}\n\n\t/**\n\t * Check if text contains HTML details/summary blocks\n\t * Useful for conditional conversion\n\t */\n\tstatic hasDetailsBlocks(text: string): boolean {\n\t\tif (!text) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst detailsRegex = /<details[^>]*>.*?<summary[^>]*>.*?<\\/summary>.*?<\\/details>/is\n\t\treturn detailsRegex.test(text)\n\t}\n\n\t/**\n\t * Remove wrapper tags from code sample details blocks\n\t * Identifies details blocks where summary contains \"X lines\" pattern\n\t * and removes the details/summary tags while preserving the content\n\t *\n\t * @param text - Text containing potential code sample details blocks\n\t * @returns Text with code sample wrappers removed\n\t */\n\tstatic removeCodeSampleWrappers(text: string): string {\n\t\tif (!text) {\n\t\t\treturn text\n\t\t}\n\n\t\t// Match details blocks where summary contains \"X lines\" (e.g., \"45 lines\", \"120 lines\")\n\t\t// Pattern: <details><summary>...N lines...</summary>CONTENT</details>\n\t\t// Use [^<]* to match summary content without allowing nested tags to interfere\n\t\t// Then use [\\s\\S]*? for the content to allow any characters including newlines\n\t\tconst codeSampleRegex = /<details[^>]*>\\s*<summary[^>]*>([^<]*\\d+\\s+lines[^<]*)<\\/summary>\\s*([\\s\\S]*?)<\\/details>/gi\n\n\t\treturn text.replace(codeSampleRegex, (_match, _summary, content) => {\n\t\t\t// Return just the content, without any wrapper tags\n\t\t\t// Preserve the content exactly as-is\n\t\t\treturn content.trim()\n\t\t})\n\t}\n\n\t/**\n\t * Convert text for Linear - applies all necessary conversions\n\t * Currently only converts details/summary blocks, but can be extended\n\t * for other HTML to Linear markdown conversions\n\t */\n\tstatic convertToLinear(text: string): string {\n\t\tif (!text) {\n\t\t\treturn text\n\t\t}\n\n\t\t// Log input if logging is enabled\n\t\tthis.logConversion('INPUT', text)\n\n\t\t// Apply all conversions\n\t\tlet converted = text\n\n\t\t// First, remove code sample wrappers (details blocks with \"X lines\" pattern)\n\t\t// This prevents them from being converted to Linear's +++ format\n\t\tconverted = this.removeCodeSampleWrappers(converted)\n\n\t\t// Then convert remaining details/summary blocks to Linear format\n\t\tconverted = this.convertDetailsToLinear(converted)\n\n\t\t// Log output if logging is enabled\n\t\tthis.logConversion('OUTPUT', converted)\n\n\t\treturn converted\n\t}\n\n\t/**\n\t * Log conversion input/output if LINEAR_MARKDOWN_LOG_FILE is set\n\t */\n\tprivate static logConversion(label: string, content: string): void {\n\t\tconst logFilePath = process.env.LINEAR_MARKDOWN_LOG_FILE\n\t\tif (!logFilePath) {\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tconst timestampedPath = this.getTimestampedLogPath(logFilePath)\n\t\t\tconst timestamp = new Date().toISOString()\n\t\t\tconst separator = '================================'\n\n\t\t\tconst logEntry = `${separator}\\n[${timestamp}] CONVERSION ${label}\\n${separator}\\n${label}:\\n${content}\\n\\n`\n\n\t\t\tappendFileSync(timestampedPath, logEntry, 'utf-8')\n\t\t} catch {\n\t\t\t// Silently fail - don't crash if logging fails\n\t\t\t// This is a debug feature and shouldn't break the conversion\n\t\t}\n\t}\n\n\t/**\n\t * Generate timestamped log file path\n\t * Example: debug.log -> debug-20231202-161234.log\n\t */\n\tprivate static getTimestampedLogPath(logFilePath: string): string {\n\t\tconst dir = dirname(logFilePath)\n\t\tconst ext = extname(logFilePath)\n\t\tconst base = basename(logFilePath, ext)\n\n\t\t// Generate timestamp: YYYYMMDD-HHMMSS\n\t\tconst now = new Date()\n\t\tconst timestamp = [\n\t\t\tnow.getFullYear(),\n\t\t\tString(now.getMonth() + 1).padStart(2, '0'),\n\t\t\tString(now.getDate()).padStart(2, '0'),\n\t\t].join('') + '-' + [\n\t\t\tString(now.getHours()).padStart(2, '0'),\n\t\t\tString(now.getMinutes()).padStart(2, '0'),\n\t\t\tString(now.getSeconds()).padStart(2, '0'),\n\t\t].join('')\n\n\t\treturn join(dir, `${base}-${timestamp}${ext}`)\n\t}\n}\n","/**\n * Linear implementation of Issue Management Provider\n * Uses @linear/sdk for all operations\n */\n\nimport type {\n\tIssueManagementProvider,\n\tGetIssueInput,\n\tGetCommentInput,\n\tCreateCommentInput,\n\tUpdateCommentInput,\n\tCreateIssueInput,\n\tCreateChildIssueInput,\n\tCreateIssueResult,\n\tIssueResult,\n\tCommentDetailResult,\n\tCommentResult,\n} from './types.js'\nimport {\n\tfetchLinearIssue,\n\tcreateLinearComment,\n\tgetLinearComment,\n\tupdateLinearComment,\n\tfetchLinearIssueComments,\n\tcreateLinearIssue,\n\tcreateLinearChildIssue,\n} from '../utils/linear.js'\nimport { LinearMarkupConverter } from '../utils/linear-markup-converter.js'\n\n/**\n * Linear-specific implementation of IssueManagementProvider\n */\nexport class LinearIssueManagementProvider implements IssueManagementProvider {\n\treadonly providerName = 'linear'\n\treadonly issuePrefix = ''\n\n\t/**\n\t * Cached team key extracted from issue identifiers (e.g., \"ENG-123\" -> \"ENG\")\n\t * Used as fallback when teamKey is not explicitly provided to createIssue()\n\t */\n\tprivate cachedTeamKey: string | undefined = undefined\n\n\t/**\n\t * Fetch issue details using Linear SDK\n\t */\n\tasync getIssue(input: GetIssueInput): Promise<IssueResult> {\n\t\tconst { number, includeComments = true } = input\n\n\t\t// Extract and cache team key from identifier (e.g., \"ENG-123\" -> \"ENG\")\n\t\t// This enables createIssue() to use the team key as a fallback\n\t\tconst match = number.match(/^([A-Z]{2,})-\\d+$/i)\n\t\tif (match?.[1]) {\n\t\t\tthis.cachedTeamKey = match[1].toUpperCase()\n\t\t}\n\n\t\t// Fetch issue - Linear uses alphanumeric identifiers like \"ENG-123\"\n\t\tconst raw = await fetchLinearIssue(number)\n\n\t\t// Map Linear state name to open/closed\n\t\tconst state = raw.state && (raw.state.toLowerCase().includes('done') || raw.state.toLowerCase().includes('completed') || raw.state.toLowerCase().includes('canceled'))\n\t\t\t? 'closed'\n\t\t\t: 'open'\n\n\t\t// Build result\n\t\tconst result: IssueResult = {\n\t\t\tid: raw.identifier,\n\t\t\ttitle: raw.title,\n\t\t\tbody: raw.description ?? '',\n\t\t\tstate,\n\t\t\turl: raw.url,\n\t\t\tprovider: 'linear',\n\t\t\tauthor: null, // Linear SDK doesn't return author in basic fetch\n\n\t\t\t// Linear-specific fields\n\t\t\tlinearState: raw.state,\n\t\t\tcreatedAt: raw.createdAt,\n\t\t\tupdatedAt: raw.updatedAt,\n\t\t}\n\n\t\t// Fetch comments if requested\n\t\tif (includeComments) {\n\t\t\ttry {\n\t\t\t\tconst comments = await this.fetchIssueComments(number)\n\t\t\t\tif (comments) {\n\t\t\t\t\tresult.comments = comments\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// If comments fail, continue without them\n\t\t\t}\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Fetch comments for an issue\n\t */\n\tprivate async fetchIssueComments(identifier: string): Promise<IssueResult['comments']> {\n\t\ttry {\n\t\t\tconst comments = await fetchLinearIssueComments(identifier)\n\n\t\t\treturn comments.map(comment => ({\n\t\t\t\tid: comment.id,\n\t\t\t\tbody: comment.body,\n\t\t\t\tcreatedAt: comment.createdAt,\n\t\t\t\tauthor: null, // Linear SDK doesn't return comment author info in basic fetch\n\t\t\t\t...(comment.updatedAt && { updatedAt: comment.updatedAt }),\n\t\t\t}))\n\t\t} catch {\n\t\t\treturn []\n\t\t}\n\t}\n\n\t/**\n\t * Fetch a specific comment by ID\n\t */\n\tasync getComment(input: GetCommentInput): Promise<CommentDetailResult> {\n\t\tconst { commentId } = input\n\n\t\tconst raw = await getLinearComment(commentId)\n\n\t\treturn {\n\t\t\tid: raw.id,\n\t\t\tbody: raw.body,\n\t\t\tauthor: null, // Linear SDK doesn't return comment author info in basic fetch\n\t\t\tcreated_at: raw.createdAt,\n\t\t}\n\t}\n\n\t/**\n\t * Create a new comment on an issue\n\t */\n\tasync createComment(input: CreateCommentInput): Promise<CommentResult> {\n\t\tconst { number, body } = input\n\t\t// Note: Linear doesn't distinguish between issue and PR comments\n\t\t// (Linear doesn't have PRs - that's GitHub-specific)\n\n\t\t// Convert HTML details/summary blocks to Linear's collapsible format\n\t\tconst convertedBody = LinearMarkupConverter.convertToLinear(body)\n\n\t\tconst result = await createLinearComment(number, convertedBody)\n\n\t\treturn {\n\t\t\tid: result.id,\n\t\t\turl: result.url,\n\t\t\tcreated_at: result.createdAt,\n\t\t}\n\t}\n\n\t/**\n\t * Update an existing comment\n\t */\n\tasync updateComment(input: UpdateCommentInput): Promise<CommentResult> {\n\t\tconst { commentId, body } = input\n\n\t\t// Convert HTML details/summary blocks to Linear's collapsible format\n\t\tconst convertedBody = LinearMarkupConverter.convertToLinear(body)\n\n\t\tconst result = await updateLinearComment(commentId, convertedBody)\n\n\t\treturn {\n\t\t\tid: result.id,\n\t\t\turl: result.url,\n\t\t\tupdated_at: result.updatedAt,\n\t\t}\n\t}\n\n\t/**\n\t * Create a new issue\n\t */\n\tasync createIssue(input: CreateIssueInput): Promise<CreateIssueResult> {\n\t\tconst { title, body, labels, teamKey } = input\n\n\t\t// Fallback chain: explicit param > settings (via env) > cached key from getIssue()\n\t\tconst effectiveTeamKey = teamKey ?? process.env.LINEAR_TEAM_KEY ?? this.cachedTeamKey\n\n\t\tif (!effectiveTeamKey) {\n\t\t\tthrow new Error('teamKey is required for Linear issue creation. Configure issueManagement.linear.teamId in settings, or call getIssue first to extract the team from an issue identifier.')\n\t\t}\n\n\t\tconst result = await createLinearIssue(title, body, effectiveTeamKey, labels)\n\n\t\treturn {\n\t\t\tid: result.identifier,\n\t\t\turl: result.url,\n\t\t}\n\t}\n\n\t/**\n\t * Create a child issue linked to a parent issue\n\t * Linear supports atomic creation with parentId field\n\t */\n\tasync createChildIssue(input: CreateChildIssueInput): Promise<CreateIssueResult> {\n\t\tconst { parentId, title, body, labels, teamKey } = input\n\n\t\t// Fetch parent issue to get UUID (parentId in input is identifier like \"ENG-123\")\n\t\tconst parentIssue = await fetchLinearIssue(parentId)\n\n\t\t// Extract team key from parent identifier if not provided\n\t\tconst match = parentId.match(/^([A-Z]{2,})-\\d+$/i)\n\t\tconst effectiveTeamKey = teamKey ?? match?.[1]?.toUpperCase() ?? process.env.LINEAR_TEAM_KEY ?? this.cachedTeamKey\n\n\t\tif (!effectiveTeamKey) {\n\t\t\tthrow new Error('teamKey is required for Linear child issue creation. Provide teamKey parameter or use a parent identifier with team prefix.')\n\t\t}\n\n\t\t// Create child issue with parent's UUID\n\t\tconst result = await createLinearChildIssue(\n\t\t\ttitle,\n\t\t\tbody,\n\t\t\teffectiveTeamKey,\n\t\t\tparentIssue.id, // UUID, not identifier\n\t\t\tlabels\n\t\t)\n\n\t\treturn {\n\t\t\tid: result.identifier,\n\t\t\turl: result.url,\n\t\t}\n\t}\n}\n","/**\n * Factory for creating issue management providers\n */\n\nimport type { IssueManagementProvider, IssueProvider } from './types.js'\nimport { GitHubIssueManagementProvider } from './GitHubIssueManagementProvider.js'\nimport { LinearIssueManagementProvider } from './LinearIssueManagementProvider.js'\n\n/**\n * Factory class for creating issue management providers\n */\nexport class IssueManagementProviderFactory {\n\t/**\n\t * Create an issue management provider based on the provider type\n\t */\n\tstatic create(provider: IssueProvider): IssueManagementProvider {\n\t\tswitch (provider) {\n\t\t\tcase 'github':\n\t\t\t\treturn new GitHubIssueManagementProvider()\n\t\t\tcase 'linear':\n\t\t\t\treturn new LinearIssueManagementProvider()\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported issue management provider: ${provider}`)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,gBAAgB,QAAgE;AACxF,MAAI,CAAC,OAAQ,QAAO;AAEpB,SAAO;AAAA,IACN,IAAI,OAAO,KAAK,OAAO,OAAO,EAAE,IAAI,OAAO;AAAA,IAC3C,aAAa,OAAO;AAAA;AAAA,IACpB,OAAO,OAAO;AAAA;AAAA,IACd,GAAI,OAAO,aAAa,EAAE,WAAW,OAAO,UAAU;AAAA,IACtD,GAAI,OAAO,OAAO,EAAE,KAAK,OAAO,IAAI;AAAA,EACrC;AACD;AAMO,SAAS,wBAAwB,KAAqB;AAC5D,QAAM,QAAQ,IAAI,MAAM,sBAAsB;AAC9C,MAAI,EAAC,+BAAQ,KAAI;AAChB,UAAM,IAAI,MAAM,uCAAuC,GAAG,EAAE;AAAA,EAC7D;AACA,SAAO,MAAM,CAAC;AACf;AAKO,IAAM,gCAAN,MAAuE;AAAA,EAAvE;AACN,SAAS,eAAe;AACxB,SAAS,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,MAAM,SAAS,OAA4C;AAC1D,UAAM,EAAE,QAAQ,kBAAkB,MAAM,KAAK,IAAI;AAGjD,UAAM,cAAc,SAAS,QAAQ,EAAE;AACvC,QAAI,MAAM,WAAW,GAAG;AACvB,YAAM,IAAI,MAAM,gCAAgC,MAAM,qCAAqC;AAAA,IAC5F;AAGA,UAAM,SAAS,kBACZ,2EACA;AAuBH,UAAM,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,MACA,OAAO,WAAW;AAAA,MAClB;AAAA,MACA;AAAA,IACD;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139
  handleLinearError(error, "createLinearIssue");
140
140
  }
141
141
  }
142
+ async function createLinearChildIssue(title, body, teamKey, parentId, _labels) {
143
+ try {
144
+ logger.debug(`Creating Linear child issue in team ${teamKey}: ${title}`);
145
+ const client = createLinearClient();
146
+ const teams = await client.teams();
147
+ const team = teams.nodes.find((t) => t.key === teamKey);
148
+ if (!team) {
149
+ throw new LinearServiceError("NOT_FOUND", `Linear team ${teamKey} not found`);
150
+ }
151
+ const issueInput = {
152
+ teamId: team.id,
153
+ title,
154
+ parentId
155
+ // UUID of parent issue
156
+ };
157
+ if (body) {
158
+ issueInput.description = body;
159
+ }
160
+ const payload = await client.createIssue(issueInput);
161
+ const issue = await payload.issue;
162
+ if (!issue) {
163
+ throw new LinearServiceError("CLI_ERROR", "Failed to create Linear child issue");
164
+ }
165
+ const url = issue.url ?? buildLinearIssueUrl(issue.identifier, title);
166
+ return {
167
+ identifier: issue.identifier,
168
+ url
169
+ };
170
+ } catch (error) {
171
+ if (error instanceof LinearServiceError) {
172
+ throw error;
173
+ }
174
+ handleLinearError(error, "createLinearChildIssue");
175
+ }
176
+ }
142
177
  async function createLinearComment(identifier, body) {
143
178
  try {
144
179
  logger.debug(`Creating comment on Linear issue ${identifier}`);
@@ -272,10 +307,11 @@ export {
272
307
  LinearServiceError,
273
308
  fetchLinearIssue,
274
309
  createLinearIssue,
310
+ createLinearChildIssue,
275
311
  createLinearComment,
276
312
  updateLinearIssueState,
277
313
  getLinearComment,
278
314
  updateLinearComment,
279
315
  fetchLinearIssueComments
280
316
  };
281
- //# sourceMappingURL=chunk-7Q66W4OH.js.map
317
+ //# sourceMappingURL=chunk-HBJITKSZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/linear.ts","../src/utils/linear.ts"],"sourcesContent":["/**\n * Linear API response types (from @linear/sdk)\n */\n\n/**\n * Linear issue response from SDK\n */\nexport interface LinearIssue {\n /** Linear internal UUID */\n id: string\n /** Issue identifier in TEAM-NUMBER format (e.g., ENG-123) */\n identifier: string\n /** Issue title */\n title: string\n /** Issue description (markdown) */\n description?: string\n /** Current workflow state name */\n state?: string\n /** Linear web URL */\n url: string\n /** Creation timestamp (ISO string) */\n createdAt: string\n /** Last update timestamp (ISO string) */\n updatedAt: string\n}\n\n/**\n * Linear comment response from SDK\n */\nexport interface LinearComment {\n /** Comment UUID */\n id: string\n /** Comment body (markdown) */\n body: string\n /** Creation timestamp (ISO string) */\n createdAt: string\n /** Last update timestamp (ISO string) */\n updatedAt: string\n /** Comment URL */\n url: string\n}\n\n/**\n * Linear error codes\n */\nexport type LinearErrorCode =\n | 'NOT_FOUND'\n | 'UNAUTHORIZED'\n | 'INVALID_STATE'\n | 'RATE_LIMITED'\n | 'CLI_NOT_FOUND'\n | 'CLI_ERROR'\n\n/**\n * Linear error details\n */\nexport interface LinearError {\n code: LinearErrorCode\n message: string\n details?: unknown\n}\n\n/**\n * Custom error class for Linear operations\n */\nexport class LinearServiceError extends Error {\n constructor(\n public code: LinearErrorCode,\n message: string,\n public details?: unknown,\n ) {\n super(message)\n this.name = 'LinearServiceError'\n // Maintain proper stack trace for where error was thrown (V8 only)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, LinearServiceError)\n }\n }\n}\n","/**\n * Linear SDK utilities\n * Wrapper functions for the @linear/sdk\n */\n\nimport { LinearClient } from '@linear/sdk'\nimport type { LinearIssue, LinearComment } from '../types/linear.js'\nimport { LinearServiceError } from '../types/linear.js'\nimport { logger } from './logger.js'\n\n/**\n * Slugify a title for use in Linear URLs\n * Converts to lowercase, replaces non-alphanumeric with hyphens, truncates to reasonable length\n * @param title - Issue title\n * @param maxLength - Maximum slug length (default: 50)\n * @returns Slugified title\n */\nexport function slugifyTitle(title: string, maxLength: number = 50): string {\n // Convert to lowercase, replace non-alphanumeric chars with hyphens\n const slug = title\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '') // trim leading/trailing hyphens\n\n // If already short enough, return as-is\n if (slug.length <= maxLength) {\n return slug\n }\n\n // Split by hyphens and rebuild until we hit the limit\n const parts = slug.split('-')\n let result = ''\n for (const part of parts) {\n const candidate = result ? `${result}-${part}` : part\n if (candidate.length > maxLength) {\n break\n }\n result = candidate\n }\n\n return result || slug.slice(0, maxLength) // fallback if first part is too long\n}\n\n/**\n * Build a Linear issue URL with optional title slug\n * @param identifier - Issue identifier (e.g., \"ENG-123\")\n * @param title - Optional issue title for slug\n * @returns Linear URL\n */\nexport function buildLinearIssueUrl(identifier: string, title?: string): string {\n const base = `https://linear.app/issue/${identifier}`\n if (title) {\n const slug = slugifyTitle(title)\n return slug ? `${base}/${slug}` : base\n }\n return base\n}\n\n/**\n * Get Linear API token from environment\n * @returns API token\n * @throws LinearServiceError if token not found\n */\nfunction getLinearApiToken(): string {\n const token = process.env.LINEAR_API_TOKEN\n if (!token) {\n throw new LinearServiceError(\n 'UNAUTHORIZED',\n 'LINEAR_API_TOKEN not set. Configure in settings.local.json or set environment variable.',\n )\n }\n return token\n}\n\n/**\n * Create a Linear SDK client instance\n * @returns Configured LinearClient\n */\nfunction createLinearClient(): LinearClient {\n return new LinearClient({ apiKey: getLinearApiToken() })\n}\n\n/**\n * Handle SDK errors and convert to LinearServiceError\n * @param error - Error from SDK\n * @param context - Context string for debugging\n * @throws LinearServiceError\n */\nfunction handleLinearError(error: unknown, context: string): never {\n logger.debug(`${context}: Handling error`, { error })\n\n // SDK errors typically have a message property\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n // Map common error patterns\n if (errorMessage.includes('not found') || errorMessage.includes('Not found')) {\n throw new LinearServiceError('NOT_FOUND', 'Linear issue or resource not found', { error })\n }\n\n if (\n errorMessage.includes('unauthorized') ||\n errorMessage.includes('Unauthorized') ||\n errorMessage.includes('Invalid API key')\n ) {\n throw new LinearServiceError(\n 'UNAUTHORIZED',\n 'Linear authentication failed. Check LINEAR_API_TOKEN.',\n { error },\n )\n }\n\n if (errorMessage.includes('rate limit')) {\n throw new LinearServiceError('RATE_LIMITED', 'Linear API rate limit exceeded', { error })\n }\n\n // Generic SDK error\n throw new LinearServiceError('CLI_ERROR', `Linear SDK error: ${errorMessage}`, { error })\n}\n\n/**\n * Fetch a Linear issue by identifier\n * @param identifier - Linear issue identifier (e.g., \"ENG-123\")\n * @returns Linear issue details\n * @throws LinearServiceError if issue not found or SDK error\n */\nexport async function fetchLinearIssue(identifier: string): Promise<LinearIssue> {\n try {\n logger.debug(`Fetching Linear issue: ${identifier}`)\n const client = createLinearClient()\n const issue = await client.issue(identifier)\n\n if (!issue) {\n throw new LinearServiceError('NOT_FOUND', `Linear issue ${identifier} not found`)\n }\n\n // Convert SDK issue to our LinearIssue type\n const result: LinearIssue = {\n id: issue.id,\n identifier: issue.identifier,\n title: issue.title,\n url: issue.url,\n createdAt: issue.createdAt.toISOString(),\n updatedAt: issue.updatedAt.toISOString(),\n }\n\n // Add optional fields if present\n if (issue.description) {\n result.description = issue.description\n }\n\n if (issue.state) {\n const state = await issue.state\n if (state?.name) {\n result.state = state.name\n }\n }\n\n return result\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'fetchLinearIssue')\n }\n}\n\n/**\n * Create a new Linear issue\n * @param title - Issue title\n * @param body - Issue description (markdown)\n * @param teamKey - Team key (e.g., \"ENG\", \"PLAT\")\n * @param labels - Optional label names to apply\n * @returns Created issue identifier and URL\n * @throws LinearServiceError on creation failure\n */\nexport async function createLinearIssue(\n title: string,\n body: string,\n teamKey: string,\n _labels?: string[],\n): Promise<{ identifier: string; url: string }> {\n try {\n logger.debug(`Creating Linear issue in team ${teamKey}: ${title}`)\n const client = createLinearClient()\n\n // Get team by key\n const teams = await client.teams()\n const team = teams.nodes.find((t) => t.key === teamKey)\n\n if (!team) {\n throw new LinearServiceError('NOT_FOUND', `Linear team ${teamKey} not found`)\n }\n\n // Create issue\n const issueInput: { teamId: string; title: string; description?: string } = {\n teamId: team.id,\n title,\n }\n\n if (body) {\n issueInput.description = body\n }\n\n const payload = await client.createIssue(issueInput)\n\n const issue = await payload.issue\n\n if (!issue) {\n throw new LinearServiceError('CLI_ERROR', 'Failed to create Linear issue')\n }\n\n // Construct URL\n const url = issue.url ?? buildLinearIssueUrl(issue.identifier, title)\n\n return {\n identifier: issue.identifier,\n url,\n }\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'createLinearIssue')\n }\n}\n\n/**\n * Create a child issue linked to a parent issue\n * Linear supports atomic creation with parentId field\n * @param title - Issue title\n * @param body - Issue description (markdown)\n * @param teamKey - Team key (e.g., \"ENG\")\n * @param parentId - Parent issue UUID (from issue.id, not identifier)\n * @param labels - Optional label names to apply\n * @returns Created issue identifier and URL\n * @throws LinearServiceError on creation failure\n */\nexport async function createLinearChildIssue(\n title: string,\n body: string,\n teamKey: string,\n parentId: string,\n _labels?: string[],\n): Promise<{ identifier: string; url: string }> {\n try {\n logger.debug(`Creating Linear child issue in team ${teamKey}: ${title}`)\n const client = createLinearClient()\n\n // Get team by key\n const teams = await client.teams()\n const team = teams.nodes.find((t) => t.key === teamKey)\n\n if (!team) {\n throw new LinearServiceError('NOT_FOUND', `Linear team ${teamKey} not found`)\n }\n\n // Create issue with parentId for atomic parent-child relationship\n const issueInput: { teamId: string; title: string; description?: string; parentId: string } = {\n teamId: team.id,\n title,\n parentId, // UUID of parent issue\n }\n\n if (body) {\n issueInput.description = body\n }\n\n const payload = await client.createIssue(issueInput)\n\n const issue = await payload.issue\n\n if (!issue) {\n throw new LinearServiceError('CLI_ERROR', 'Failed to create Linear child issue')\n }\n\n // Construct URL\n const url = issue.url ?? buildLinearIssueUrl(issue.identifier, title)\n\n return {\n identifier: issue.identifier,\n url,\n }\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'createLinearChildIssue')\n }\n}\n\n/**\n * Create a comment on a Linear issue\n * @param identifier - Linear issue identifier (e.g., \"ENG-123\")\n * @param body - Comment body (markdown)\n * @returns Created comment details\n * @throws LinearServiceError on creation failure\n */\nexport async function createLinearComment(\n identifier: string,\n body: string,\n): Promise<LinearComment> {\n try {\n logger.debug(`Creating comment on Linear issue ${identifier}`)\n const client = createLinearClient()\n\n // Get issue by identifier to get its ID\n const issue = await client.issue(identifier)\n if (!issue) {\n throw new LinearServiceError('NOT_FOUND', `Linear issue ${identifier} not found`)\n }\n\n // Create comment using issue ID\n const payload = await client.createComment({\n issueId: issue.id,\n body,\n })\n\n const comment = await payload.comment\n\n if (!comment) {\n throw new LinearServiceError('CLI_ERROR', 'Failed to create Linear comment')\n }\n\n return {\n id: comment.id,\n body: comment.body,\n createdAt: comment.createdAt.toISOString(),\n updatedAt: comment.updatedAt.toISOString(),\n url: comment.url,\n }\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'createLinearComment')\n }\n}\n\n/**\n * Update a Linear issue's workflow state\n * @param identifier - Linear issue identifier (e.g., \"ENG-123\")\n * @param stateName - Target state name (e.g., \"In Progress\", \"Done\")\n * @throws LinearServiceError on update failure\n */\nexport async function updateLinearIssueState(\n identifier: string,\n stateName: string,\n): Promise<void> {\n try {\n logger.debug(`Updating Linear issue ${identifier} state to: ${stateName}`)\n const client = createLinearClient()\n\n // Get issue by identifier\n const issue = await client.issue(identifier)\n if (!issue) {\n throw new LinearServiceError('NOT_FOUND', `Linear issue ${identifier} not found`)\n }\n\n // Get team to find state\n const team = await issue.team\n if (!team) {\n throw new LinearServiceError('CLI_ERROR', 'Issue has no team')\n }\n\n // Find state by name\n const states = await team.states()\n const state = states.nodes.find((s) => s.name === stateName)\n\n if (!state) {\n throw new LinearServiceError(\n 'NOT_FOUND',\n `State \"${stateName}\" not found in team ${team.key}`,\n )\n }\n\n // Update issue state\n await client.updateIssue(issue.id, {\n stateId: state.id,\n })\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'updateLinearIssueState')\n }\n}\n\n/**\n * Get a specific comment by ID\n * @param commentId - Linear comment UUID\n * @returns Comment details\n * @throws LinearServiceError if comment not found\n */\nexport async function getLinearComment(commentId: string): Promise<LinearComment> {\n try {\n logger.debug(`Fetching Linear comment: ${commentId}`)\n const client = createLinearClient()\n const comment = await client.comment({ id: commentId })\n\n if (!comment) {\n throw new LinearServiceError('NOT_FOUND', `Linear comment ${commentId} not found`)\n }\n\n return {\n id: comment.id,\n body: comment.body,\n createdAt: comment.createdAt.toISOString(),\n updatedAt: comment.updatedAt.toISOString(),\n url: comment.url,\n }\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'getLinearComment')\n }\n}\n\n/**\n * Update an existing comment\n * @param commentId - Linear comment UUID\n * @param body - New comment body (markdown)\n * @returns Updated comment details\n * @throws LinearServiceError on update failure\n */\nexport async function updateLinearComment(\n commentId: string,\n body: string,\n): Promise<LinearComment> {\n try {\n logger.debug(`Updating Linear comment: ${commentId}`)\n const client = createLinearClient()\n\n const payload = await client.updateComment(commentId, { body })\n const comment = await payload.comment\n\n if (!comment) {\n throw new LinearServiceError('CLI_ERROR', 'Failed to update Linear comment')\n }\n\n return {\n id: comment.id,\n body: comment.body,\n createdAt: comment.createdAt.toISOString(),\n updatedAt: comment.updatedAt.toISOString(),\n url: comment.url,\n }\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'updateLinearComment')\n }\n}\n\n/**\n * Fetch all comments for a Linear issue\n * @param identifier - Linear issue identifier (e.g., \"ENG-123\")\n * @returns Array of comments\n * @throws LinearServiceError on fetch failure\n */\nexport async function fetchLinearIssueComments(identifier: string): Promise<LinearComment[]> {\n try {\n logger.debug(`Fetching comments for Linear issue: ${identifier}`)\n const client = createLinearClient()\n\n // Get issue by identifier\n const issue = await client.issue(identifier)\n if (!issue) {\n throw new LinearServiceError('NOT_FOUND', `Linear issue ${identifier} not found`)\n }\n\n // Fetch comments\n const comments = await issue.comments({ first: 100 })\n\n return comments.nodes.map((comment) => ({\n id: comment.id,\n body: comment.body,\n createdAt: comment.createdAt.toISOString(),\n updatedAt: comment.updatedAt.toISOString(),\n url: comment.url,\n }))\n } catch (error) {\n if (error instanceof LinearServiceError) {\n throw error\n }\n handleLinearError(error, 'fetchLinearIssueComments')\n }\n}\n"],"mappings":";;;;;;AAiEO,IAAM,qBAAN,MAAM,4BAA2B,MAAM;AAAA,EAC5C,YACS,MACP,SACO,SACP;AACA,UAAM,OAAO;AAJN;AAEA;AAGP,SAAK,OAAO;AAEZ,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,mBAAkB;AAAA,IAClD;AAAA,EACF;AACF;;;ACzEA,SAAS,oBAAoB;AAYtB,SAAS,aAAa,OAAe,YAAoB,IAAY;AAE1E,QAAM,OAAO,MACV,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AAGzB,MAAI,KAAK,UAAU,WAAW;AAC5B,WAAO;AAAA,EACT;AAGA,QAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,UAAM,YAAY,SAAS,GAAG,MAAM,IAAI,IAAI,KAAK;AACjD,QAAI,UAAU,SAAS,WAAW;AAChC;AAAA,IACF;AACA,aAAS;AAAA,EACX;AAEA,SAAO,UAAU,KAAK,MAAM,GAAG,SAAS;AAC1C;AAQO,SAAS,oBAAoB,YAAoB,OAAwB;AAC9E,QAAM,OAAO,4BAA4B,UAAU;AACnD,MAAI,OAAO;AACT,UAAM,OAAO,aAAa,KAAK;AAC/B,WAAO,OAAO,GAAG,IAAI,IAAI,IAAI,KAAK;AAAA,EACpC;AACA,SAAO;AACT;AAOA,SAAS,oBAA4B;AACnC,QAAM,QAAQ,QAAQ,IAAI;AAC1B,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMA,SAAS,qBAAmC;AAC1C,SAAO,IAAI,aAAa,EAAE,QAAQ,k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WAAW,QAAQ,UAAU,YAAY;AAAA,MACzC,KAAK,QAAQ;AAAA,IACf,EAAE;AAAA,EACJ,SAAS,OAAO;AACd,QAAI,iBAAiB,oBAAoB;AACvC,YAAM;AAAA,IACR;AACA,sBAAkB,OAAO,0BAA0B;AAAA,EACrD;AACF;","names":[]}
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-ZX3GTM7O.js";
8
8
  import {
9
9
  launchClaude
10
- } from "./chunk-AEIMYF4P.js";
10
+ } from "./chunk-FP7G7DG3.js";
11
11
  import {
12
12
  getLogger
13
13
  } from "./chunk-6MLEBAYZ.js";
@@ -151,4 +151,4 @@ export {
151
151
  IssueEnhancementService,
152
152
  capitalizeFirstLetter
153
153
  };
154
- //# sourceMappingURL=chunk-7HIRPCKU.js.map
154
+ //# sourceMappingURL=chunk-HVQNVRAF.js.map
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  PromptTemplateManager
4
- } from "./chunk-W6WVRHJ6.js";
4
+ } from "./chunk-TIYJEEVO.js";
5
5
  import {
6
6
  SettingsManager
7
- } from "./chunk-F6WVM437.js";
7
+ } from "./chunk-WFQ5CLTR.js";
8
8
  import {
9
9
  detectClaudeCli,
10
10
  launchClaude,
11
11
  launchClaudeInNewTerminalWindow
12
- } from "./chunk-AEIMYF4P.js";
12
+ } from "./chunk-FP7G7DG3.js";
13
13
  import {
14
14
  logger
15
15
  } from "./chunk-VT4PDUYT.js";
@@ -122,4 +122,4 @@ var ClaudeService = class {
122
122
  export {
123
123
  ClaudeService
124
124
  };
125
- //# sourceMappingURL=chunk-6U6VI4SZ.js.map
125
+ //# sourceMappingURL=chunk-KVS4XGBQ.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  PromptTemplateManager
4
- } from "./chunk-W6WVRHJ6.js";
4
+ } from "./chunk-TIYJEEVO.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-VT4PDUYT.js";
@@ -263,4 +263,4 @@ var AgentManager = class {
263
263
  export {
264
264
  AgentManager
265
265
  };
266
- //# sourceMappingURL=chunk-SN3Z6EZO.js.map
266
+ //# sourceMappingURL=chunk-N7FVXZNI.js.map
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- calculatePortForBranch
4
- } from "./chunk-VU3QMIP2.js";
3
+ calculatePortForBranch,
4
+ calculatePortFromIdentifier
5
+ } from "./chunk-453NC377.js";
5
6
  import {
6
7
  installDependencies,
7
8
  runScript
8
- } from "./chunk-AXX3QIKK.js";
9
+ } from "./chunk-RD7I2Q2F.js";
9
10
  import {
10
11
  getPackageConfig,
11
12
  hasScript
12
- } from "./chunk-BXCPJJYM.js";
13
+ } from "./chunk-XPKN3QWY.js";
13
14
  import {
14
15
  branchExists,
15
16
  checkRemoteBranchStatus,
@@ -23,13 +24,13 @@ import {
23
24
  hasUncommittedChanges,
24
25
  isBranchMergedIntoMain,
25
26
  isFileTrackedByGit
26
- } from "./chunk-GEXP5IOF.js";
27
+ } from "./chunk-ZA575VLF.js";
27
28
  import {
28
29
  SettingsManager
29
- } from "./chunk-F6WVM437.js";
30
+ } from "./chunk-WFQ5CLTR.js";
30
31
  import {
31
32
  MetadataManager
32
- } from "./chunk-CFUWQHCJ.js";
33
+ } from "./chunk-VWGKGNJP.js";
33
34
  import {
34
35
  calculateForegroundColor,
35
36
  generateColorFromBranchName,
@@ -39,8 +40,8 @@ import {
39
40
  selectDistinctColor
40
41
  } from "./chunk-433MOLAU.js";
41
42
  import {
42
- generateDeterministicSessionId
43
- } from "./chunk-AEIMYF4P.js";
43
+ generateRandomSessionId
44
+ } from "./chunk-FP7G7DG3.js";
44
45
  import {
45
46
  getLogger
46
47
  } from "./chunk-6MLEBAYZ.js";
@@ -252,6 +253,7 @@ var LoomManager = class {
252
253
  const { capabilities, binEntries } = await this.capabilityDetector.detectCapabilities(worktreePath);
253
254
  await this.copyEnvironmentFiles(worktreePath);
254
255
  await this.copyIloomSettings(worktreePath);
256
+ await this.copyIloomPackageLocal(worktreePath);
255
257
  await this.copyClaudeSettings(worktreePath);
256
258
  await this.copyGitIgnoredFiles(worktreePath);
257
259
  const settingsData = await this.settings.loadSettings();
@@ -326,21 +328,21 @@ var LoomManager = class {
326
328
  );
327
329
  }
328
330
  getLogger().info("Creating placeholder commit for draft PR...");
329
- const { executeGitCommand: executeGitCommand2, PLACEHOLDER_COMMIT_PREFIX, pushBranchToRemote } = await import("./git-FVMGBHC2.js");
331
+ const { executeGitCommand: executeGitCommand2, PLACEHOLDER_COMMIT_PREFIX, pushBranchToRemote } = await import("./git-ENLT2VNI.js");
330
332
  await executeGitCommand2(
331
333
  [
332
334
  "commit",
333
335
  "--allow-empty",
334
336
  "--no-verify",
335
337
  "-m",
336
- `${PLACEHOLDER_COMMIT_PREFIX} Temporary commit for draft PR (will be removed on finish) - issue #${input.identifier}`
338
+ `${PLACEHOLDER_COMMIT_PREFIX} Temporary commit for draft PR (will be removed on finish)`
337
339
  ],
338
340
  { cwd: worktreePath }
339
341
  );
340
342
  getLogger().debug("Placeholder commit created");
341
343
  getLogger().info("Pushing branch to remote for draft PR...");
342
344
  await pushBranchToRemote(branchName, worktreePath, { dryRun: false });
343
- const { PRManager } = await import("./PRManager-GB3FOJ2W.js");
345
+ const { PRManager } = await import("./PRManager-2ABCWXHW.js");
344
346
  const prManager = new PRManager(settingsData);
345
347
  const prTitle = (issueData == null ? void 0 : issueData.title) ?? `Work on ${branchName}`;
346
348
  const prBody = `Draft PR for issue #${input.identifier}
@@ -391,8 +393,8 @@ This PR was created automatically by iloom.`;
391
393
  const setArguments = (_j = input.options) == null ? void 0 : _j.setArguments;
392
394
  const executablePath = (_k = input.options) == null ? void 0 : _k.executablePath;
393
395
  if (enableClaude || enableCode || enableDevServer || enableTerminal) {
394
- const { LoomLauncher } = await import("./LoomLauncher-5LFM4LXB.js");
395
- const { ClaudeContextManager } = await import("./ClaudeContextManager-6J2EB4QU.js");
396
+ const { LoomLauncher } = await import("./LoomLauncher-NL65LSKP.js");
397
+ const { ClaudeContextManager } = await import("./ClaudeContextManager-KE5TBZVZ.js");
396
398
  const claudeContext = new ClaudeContextManager(void 0, void 0, this.settings);
397
399
  const launcher = new LoomLauncher(claudeContext, this.settings);
398
400
  await launcher.launchLoom({
@@ -427,7 +429,7 @@ This PR was created automatically by iloom.`;
427
429
  }
428
430
  }
429
431
  const pr_numbers = input.type === "pr" ? [String(input.identifier)] : [];
430
- const sessionId = generateDeterministicSessionId(worktreePath);
432
+ const sessionId = generateRandomSessionId();
431
433
  let issueUrls = {};
432
434
  if (input.type === "issue" && (issueData == null ? void 0 : issueData.url)) {
433
435
  issueUrls = { [String(input.identifier)]: issueData.url };
@@ -449,6 +451,7 @@ This PR was created automatically by iloom.`;
449
451
  projectPath: this.gitWorktree.workingDirectory,
450
452
  issueUrls,
451
453
  prUrls,
454
+ capabilities,
452
455
  ...draftPrNumber && { draftPrNumber },
453
456
  ...input.parentLoom && { parentLoom: input.parentLoom }
454
457
  };
@@ -538,7 +541,7 @@ This PR was created automatically by iloom.`;
538
541
  async checkAndWarnChildLooms(branchName) {
539
542
  let targetBranch = branchName;
540
543
  if (!targetBranch) {
541
- const { getCurrentBranch } = await import("./git-FVMGBHC2.js");
544
+ const { getCurrentBranch } = await import("./git-ENLT2VNI.js");
542
545
  targetBranch = await getCurrentBranch();
543
546
  }
544
547
  if (!targetBranch) {
@@ -716,6 +719,27 @@ This PR was created automatically by iloom.`;
716
719
  getLogger().warn(`Warning: Failed to copy settings.local.json: ${error instanceof Error ? error.message : "Unknown error"}`);
717
720
  }
718
721
  }
722
+ /**
723
+ * Copy iloom package local config (package.iloom.local.json) from main repo to worktree
724
+ * Always called regardless of project capabilities
725
+ * Follows the same pattern as copyIloomSettings()
726
+ * @param worktreePath Path to the worktree
727
+ */
728
+ async copyIloomPackageLocal(worktreePath) {
729
+ const mainPackageLocalPath = path2.join(process.cwd(), ".iloom", "package.iloom.local.json");
730
+ try {
731
+ const worktreeIloomDir = path2.join(worktreePath, ".iloom");
732
+ await fs2.ensureDir(worktreeIloomDir);
733
+ const worktreePackageLocalPath = path2.join(worktreeIloomDir, "package.iloom.local.json");
734
+ if (await fs2.pathExists(worktreePackageLocalPath)) {
735
+ getLogger().debug("package.iloom.local.json already exists in worktree, skipping copy");
736
+ } else {
737
+ await this.environment.copyIfExists(mainPackageLocalPath, worktreePackageLocalPath);
738
+ }
739
+ } catch (error) {
740
+ getLogger().warn(`Warning: Failed to copy package.iloom.local.json: ${error instanceof Error ? error.message : "Unknown error"}`);
741
+ }
742
+ }
719
743
  /**
720
744
  * Copy Claude settings (settings.local.json) from main repo to worktree
721
745
  * Always called regardless of project capabilities
@@ -846,7 +870,7 @@ This PR was created automatically by iloom.`;
846
870
  if (typeof input.identifier === "number") {
847
871
  return this.environment.calculatePort({ basePort, issueNumber: input.identifier });
848
872
  } else if (typeof input.identifier === "string") {
849
- return this.environment.calculatePort({ basePort, branchName: input.identifier });
873
+ return this.environment.calculatePort({ basePort, issueNumber: input.identifier });
850
874
  }
851
875
  }
852
876
  if (input.type === "pr" && typeof input.identifier === "number") {
@@ -966,6 +990,7 @@ This PR was created automatically by iloom.`;
966
990
  const { capabilities, binEntries } = await this.capabilityDetector.detectCapabilities(worktreePath);
967
991
  await this.copyEnvironmentFiles(worktreePath);
968
992
  await this.copyIloomSettings(worktreePath);
993
+ await this.copyIloomPackageLocal(worktreePath);
969
994
  await this.copyClaudeSettings(worktreePath);
970
995
  await this.copyGitIgnoredFiles(worktreePath);
971
996
  const settingsData = await this.settings.loadSettings();
@@ -1018,8 +1043,8 @@ This PR was created automatically by iloom.`;
1018
1043
  const executablePath = (_i = input.options) == null ? void 0 : _i.executablePath;
1019
1044
  if (enableClaude || enableCode || enableDevServer || enableTerminal) {
1020
1045
  getLogger().info("Launching workspace components...");
1021
- const { LoomLauncher } = await import("./LoomLauncher-5LFM4LXB.js");
1022
- const { ClaudeContextManager } = await import("./ClaudeContextManager-6J2EB4QU.js");
1046
+ const { LoomLauncher } = await import("./LoomLauncher-NL65LSKP.js");
1047
+ const { ClaudeContextManager } = await import("./ClaudeContextManager-KE5TBZVZ.js");
1023
1048
  const claudeContext = new ClaudeContextManager(void 0, void 0, this.settings);
1024
1049
  const launcher = new LoomLauncher(claudeContext, this.settings);
1025
1050
  await launcher.launchLoom({
@@ -1055,7 +1080,7 @@ This PR was created automatically by iloom.`;
1055
1080
  }
1056
1081
  }
1057
1082
  const pr_numbers = input.type === "pr" ? [String(input.identifier)] : [];
1058
- const sessionId = generateDeterministicSessionId(worktreePath);
1083
+ const sessionId = generateRandomSessionId();
1059
1084
  let issueUrls = {};
1060
1085
  if (input.type === "issue" && (issueData == null ? void 0 : issueData.url)) {
1061
1086
  issueUrls = { [String(input.identifier)]: issueData.url };
@@ -1077,6 +1102,7 @@ This PR was created automatically by iloom.`;
1077
1102
  projectPath: this.gitWorktree.workingDirectory,
1078
1103
  issueUrls,
1079
1104
  prUrls,
1105
+ capabilities,
1080
1106
  ...input.parentLoom && { parentLoom: input.parentLoom }
1081
1107
  };
1082
1108
  await this.metadataManager.writeMetadata(worktreePath, metadataInput);
@@ -1214,30 +1240,15 @@ var EnvironmentManager = class {
1214
1240
  * Implements:
1215
1241
  * - Issue/PR: 3000 + issue/PR number
1216
1242
  * - Branch: 3000 + deterministic hash offset (1-999)
1243
+ * Delegates to calculatePortFromIdentifier for the core calculation.
1217
1244
  */
1218
1245
  calculatePort(options) {
1219
1246
  const basePort = options.basePort ?? 3e3;
1220
1247
  if (options.issueNumber !== void 0) {
1221
- const numericIssue = typeof options.issueNumber === "number" ? options.issueNumber : parseInt(String(options.issueNumber), 10);
1222
- if (!isNaN(numericIssue) && String(numericIssue) === String(options.issueNumber)) {
1223
- const port = basePort + numericIssue;
1224
- if (port > 65535) {
1225
- throw new Error(
1226
- `Calculated port ${port} exceeds maximum (65535). Use a lower base port or issue number.`
1227
- );
1228
- }
1229
- return port;
1230
- }
1231
- return calculatePortForBranch(String(options.issueNumber), basePort);
1248
+ return calculatePortFromIdentifier(options.issueNumber, basePort);
1232
1249
  }
1233
1250
  if (options.prNumber !== void 0) {
1234
- const port = basePort + options.prNumber;
1235
- if (port > 65535) {
1236
- throw new Error(
1237
- `Calculated port ${port} exceeds maximum (65535). Use a lower base port or PR number.`
1238
- );
1239
- }
1240
- return port;
1251
+ return calculatePortFromIdentifier(options.prNumber, basePort);
1241
1252
  }
1242
1253
  if (options.branchName !== void 0) {
1243
1254
  return calculatePortForBranch(options.branchName, basePort);
@@ -1785,14 +1796,16 @@ var ResourceCleanup = class {
1785
1796
  * @param options - Cleanup options
1786
1797
  */
1787
1798
  async cleanupWorktree(parsed, options = {}) {
1788
- var _a;
1799
+ var _a, _b, _c;
1789
1800
  const operations = [];
1790
1801
  const errors = [];
1791
1802
  const displayIdentifier = parsed.branchName ?? ((_a = parsed.number) == null ? void 0 : _a.toString()) ?? parsed.originalInput;
1792
1803
  getLogger().info(`Starting cleanup for: ${displayIdentifier}`);
1793
1804
  const number = parsed.number;
1794
1805
  if (number !== void 0) {
1795
- const port = this.processManager.calculatePort(number);
1806
+ const settings = await this.settingsManager.loadSettings();
1807
+ const basePort = ((_c = (_b = settings == null ? void 0 : settings.capabilities) == null ? void 0 : _b.web) == null ? void 0 : _c.basePort) ?? 3e3;
1808
+ const port = calculatePortFromIdentifier(number, basePort);
1796
1809
  if (options.dryRun) {
1797
1810
  operations.push({
1798
1811
  type: "dev-server",
@@ -1922,8 +1935,6 @@ ${blockerMessage}`);
1922
1935
  success: true,
1923
1936
  message: `Worktree removed: ${worktree.path}`
1924
1937
  });
1925
- await this.metadataManager.deleteMetadata(worktree.path);
1926
- getLogger().debug(`Metadata file cleanup attempted for: ${worktree.path}`);
1927
1938
  } catch (error) {
1928
1939
  const err = error instanceof Error ? error : new Error("Unknown error");
1929
1940
  errors.push(err);
@@ -2425,4 +2436,4 @@ export {
2425
2436
  DatabaseManager,
2426
2437
  ResourceCleanup
2427
2438
  };
2428
- //# sourceMappingURL=chunk-I75JMBNB.js.map
2439
+ //# sourceMappingURL=chunk-QQFBMCAH.js.map