@leitwerk-dev/jira 0.4.0 → 0.4.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/README.md +1 -1
- package/dist/chunk-VUXLYUPG.js +818 -0
- package/dist/chunk-VUXLYUPG.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +6 -1
- package/dist/testing.js.map +1 -1
- package/dist/ticket-text.d.ts +1 -1
- package/dist/ticket-text.d.ts.map +1 -1
- package/dist/workflow-tools.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/testing.ts +5 -0
- package/src/ticket-text.ts +1 -1
- package/src/workflow-tools.ts +12 -2
- package/dist/chunk-3DM3KSZC.js +0 -6323
- package/dist/chunk-3DM3KSZC.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/markdown.ts","../src/tools.ts","../src/workflow-tools.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\n\n/** @public */\nexport interface JiraProject {\n\t/** @internal */\n\tid: string;\n\n\t/** @internal */\n\tkey: string;\n\n\t/** @internal */\n\tname: string;\n}\n\n/** @public */\nexport interface JiraComponent {\n\t/** @internal */\n\tid: string;\n\n\t/** @internal */\n\tname: string;\n}\n\n/** @public */\nexport interface JiraIssue {\n\t/** @internal */\n\tid: string;\n\n\t/** @internal */\n\tkey: string;\n\n\t/** @internal */\n\tfields: {\n\t\t/** @internal */\n\t\tissuetype?: {\n\t\t\t/** @internal */\n\t\t\tid: string;\n\t\t\t/** @internal */\n\t\t\tname: string;\n\t\t\t/** @internal */\n\t\t\tsubtask?: boolean;\n\t\t};\n\t\t/** @internal */\n\t\tparent?: JiraIssueReceipt;\n\t\t/** @internal */\n\t\tupdated?: string;\n\t\t/** @internal */\n\t\tsummary: string;\n\n\t\t/** @internal */\n\t\tdescription: string | null;\n\n\t\t/** @internal */\n\t\tlabels: string[];\n\n\t\t/** @internal */\n\t\tproject: JiraProject;\n\n\t\t/** @internal */\n\t\tcomponents: JiraComponent[];\n\n\t\t/** @internal */\n\t\tstatus: {\n\t\t\t/** @internal */\n\t\t\tid?: string;\n\t\t\t/** @internal */\n\t\t\tname?: string;\n\t\t\t/** @internal */\n\t\t\tstatusCategory: {\n\t\t\t\t/** @internal */\n\t\t\t\tkey: string;\n\t\t\t};\n\t\t};\n\t};\n}\n\n/** @public */\nexport interface JiraComment {\n\t/** @internal */\n\tid: string;\n\n\t/** @internal */\n\tbody: string;\n}\n\n/** @internal */\nexport interface JiraRemoteLink {\n\t/** @internal */ id: number;\n\t/** @internal */ globalId: string;\n\t/** @internal */ object: {\n\t\t/** @internal */ url: string;\n\t\t/** @internal */ title: string;\n\t};\n}\n\n/** @internal */\nexport interface JiraTransition {\n\t/** @internal */ id: string;\n\t/** @internal */ name: string;\n\t/** @internal */ to: JiraIssue[\"fields\"][\"status\"];\n}\n\n/** @internal */\nexport interface JiraCreateField {\n\t/** @internal */\n\tname: string;\n\t/** @internal */\n\trequired: boolean;\n\t/** @internal */\n\thasDefaultValue?: boolean;\n\t/** @internal */\n\tschema?: Record<string, unknown>;\n\t/** @internal */\n\tallowedValues?: unknown[];\n}\n\n/** @internal */\nexport interface JiraCreateProject extends JiraProject {\n\t/** @internal */\n\tissuetypes: Array<{\n\t\t/** @internal */\n\t\tid: string;\n\t\t/** @internal */\n\t\tname: string;\n\t\t/** @internal */\n\t\tsubtask: boolean;\n\t\t/** @internal */\n\t\tfields: Record<string, JiraCreateField>;\n\t}>;\n}\n\n/** @public */\nexport interface JiraClientLike extends Pick<JiraClient, keyof JiraClient> {}\n\n/** @internal */\nexport interface JiraCreateMetadata {\n\t/** @internal */ epicLinkField: string | null;\n\t/** @internal */\n\tissueTypes: {\n\t\t/** @internal */\n\t\tid: string;\n\t\t/** @internal */\n\t\tname: string;\n\t\t/** @internal */\n\t\tsubtask?: boolean;\n\t\t/** @internal */\n\t\tfields: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\t/** @internal */\n\t\t\t\trequired?: boolean;\n\t\t\t\t/** @internal */\n\t\t\t\thasDefaultValue?: boolean;\n\t\t\t}\n\t\t>;\n\t}[];\n}\n\n/** @internal */\nexport class JiraRequestError extends Error {\n\t/** @internal */\n\treadonly status: number;\n\t/** @internal */\n\tconstructor(status: number) {\n\t\tsuper(`Jira request failed (${status})`);\n\t\tthis.status = status;\n\t}\n}\n\n/** @internal */\nexport interface JiraIssueReceipt {\n\t/** @internal */ id: string;\n\t/** @internal */ key: string;\n}\n\n/** @internal */\nexport function jiraBaseUrl(raw: string): string {\n\tconst url = new URL(raw);\n\tif (url.protocol !== \"https:\" || url.username || url.password || url.search || url.hash)\n\t\tthrow new Error(\"Jira base_url must be HTTPS, without credentials, query, or fragment\");\n\treturn url.href.replace(/\\/+$/, \"\");\n}\n\n/** @internal */\nexport function parseJiraProfiles(raw: unknown): Map<\n\tstring,\n\t{\n\t\t/** @internal */\n\t\tbaseUrl: string;\n\t\t/** @internal */\n\t\ttoken: string;\n\t\t/** @internal */\n\t\tepicLinkField?: string;\n\t\t/** @internal */\n\t\tproject?: string;\n\t}\n> {\n\tconst profiles = asUnknownRecord(asUnknownRecord(raw)?.profiles) ?? {};\n\treturn new Map(\n\t\tObject.entries(profiles).map(([id, value]) => {\n\t\t\tconst profile = asUnknownRecord(value);\n\t\t\tif (\n\t\t\t\ttypeof profile?.base_url !== \"string\" ||\n\t\t\t\ttypeof profile.token !== \"string\" ||\n\t\t\t\t!profile.token.trim()\n\t\t\t)\n\t\t\t\tthrow new Error(`Jira profile '${id}' requires base_url and a PAT`);\n\t\t\tconst token = profile.token.startsWith(\"env:\")\n\t\t\t\t? (process.env[profile.token.slice(4)] ?? \"\")\n\t\t\t\t: profile.token;\n\t\t\tif (!token || /[\\r\\n\\0]/.test(token))\n\t\t\t\tthrow new Error(`Jira profile '${id}' requires a valid PAT`);\n\t\t\tif (\n\t\t\t\tprofile.epic_link_field !== undefined &&\n\t\t\t\t(typeof profile.epic_link_field !== \"string\" ||\n\t\t\t\t\t!/^customfield_\\d+$/.test(profile.epic_link_field))\n\t\t\t)\n\t\t\t\tthrow new Error(\"epic_link_field must identify a Jira custom field\");\n\t\t\tif (\n\t\t\t\tprofile.project !== undefined &&\n\t\t\t\t(typeof profile.project !== \"string\" || !profile.project.trim())\n\t\t\t)\n\t\t\t\tthrow new Error(\"project must identify a Jira project by ID or key\");\n\t\t\treturn [\n\t\t\t\tid,\n\t\t\t\t{\n\t\t\t\t\tbaseUrl: jiraBaseUrl(profile.base_url),\n\t\t\t\t\ttoken,\n\t\t\t\t\t...(typeof profile.project === \"string\" ? { project: profile.project.trim() } : {}),\n\t\t\t\t\t...(typeof profile.epic_link_field === \"string\"\n\t\t\t\t\t\t? { epicLinkField: profile.epic_link_field }\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\t\t];\n\t\t}),\n\t);\n}\n/** Jira Data Center REST v2. Credentials never appear in errors or public fields. @public */\nexport class JiraClient {\n\t/** @internal */\n\treadonly baseUrl: string;\n\t#token: string;\n\t#fetch: typeof fetch;\n\t#epicLinkField: string | undefined;\n\n\t/** @internal */\n\tconstructor(\n\t\tprofile: {\n\t\t\t/** @internal */\n\t\t\tbaseUrl: string;\n\t\t\t/** @internal */\n\t\t\ttoken: string;\n\t\t\t/** @internal */\n\t\t\tepicLinkField?: string;\n\t\t},\n\t\tfetcher: typeof fetch = fetch,\n\t) {\n\t\tthis.#fetch = fetcher;\n\t\tthis.baseUrl = jiraBaseUrl(profile.baseUrl);\n\t\tthis.#token = profile.token;\n\t\tthis.#epicLinkField = profile.epicLinkField;\n\t}\n\tasync #request<T>(path: string, init: RequestInit = {}): Promise<T> {\n\t\tinit.signal?.throwIfAborted();\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await this.#fetch(`${this.baseUrl}/rest/api/2/${path}`, {\n\t\t\t\t...init,\n\t\t\t\tredirect: \"error\",\n\t\t\t\tsignal: init.signal\n\t\t\t\t\t? AbortSignal.any([init.signal, AbortSignal.timeout(30_000)])\n\t\t\t\t\t: AbortSignal.timeout(30_000),\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${this.#token}`,\n\t\t\t\t\tAccept: \"application/json\",\n\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t},\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new Error(\"Jira request unavailable\");\n\t\t}\n\t\tif (!response.ok) throw new JiraRequestError(response.status);\n\t\tif (response.status === 204) return undefined as T;\n\t\ttry {\n\t\t\treturn (await response.json()) as T;\n\t\t} catch {\n\t\t\tthrow new Error(\"Jira returned invalid JSON\");\n\t\t}\n\t}\n\tasync #pages<T>(path: string, field: string, signal?: AbortSignal): Promise<T[]> {\n\t\tconst items: T[] = [];\n\t\tlet startAt = 0;\n\t\tfor (;;) {\n\t\t\tconst page = await this.#request<Record<string, unknown> | T[]>(\n\t\t\t\t`${path}${path.includes(\"?\") ? \"&\" : \"?\"}startAt=${startAt}&maxResults=100`,\n\t\t\t\t{ signal },\n\t\t\t);\n\t\t\t// Data Center's project and component endpoints may return the complete array.\n\t\t\tif (Array.isArray(page)) return page;\n\t\t\tconst batch = page[field];\n\t\t\tif (!Array.isArray(batch)) throw new Error(\"Jira returned an invalid page\");\n\t\t\tconst pageStart = page.startAt ?? page.start;\n\t\t\tif (typeof pageStart === \"number\" && pageStart !== startAt)\n\t\t\t\tthrow new Error(\"Jira pagination did not advance\");\n\t\t\titems.push(...(batch as T[]));\n\t\t\tstartAt += batch.length;\n\t\t\tif (\n\t\t\t\tpage.isLast === true ||\n\t\t\t\tpage.last === true ||\n\t\t\t\t(typeof page.total === \"number\" && startAt >= page.total)\n\t\t\t)\n\t\t\t\treturn items;\n\t\t\tif (!batch.length) {\n\t\t\t\tif (typeof page.total === \"number\" && startAt < page.total)\n\t\t\t\t\tthrow new Error(\"Jira returned an incomplete page\");\n\t\t\t\treturn items;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @internal */\n\tlistProjects(signal?: AbortSignal) {\n\t\treturn this.#pages<JiraProject>(\"project\", \"values\", signal);\n\t}\n\n\t/** @internal */\n\tasync listCreateProjects(projectId?: string, signal?: AbortSignal): Promise<JiraCreateProject[]> {\n\t\tconst projects = projectId\n\t\t\t? [await this.#request<JiraProject>(`project/${encodeURIComponent(projectId)}`, { signal })]\n\t\t\t: await this.listProjects(signal);\n\t\treturn Promise.all(\n\t\t\tprojects.map(async (project) => {\n\t\t\t\tconst path = `issue/createmeta/${encodeURIComponent(project.id)}/issuetypes`;\n\t\t\t\tconst issueTypes = await this.#pages<\n\t\t\t\t\tOmit<JiraCreateProject[\"issuetypes\"][number], \"fields\">\n\t\t\t\t>(path, \"values\", signal);\n\t\t\t\treturn {\n\t\t\t\t\t...project,\n\t\t\t\t\tissuetypes: await Promise.all(\n\t\t\t\t\t\tissueTypes\n\t\t\t\t\t\t\t.filter((issueType) => !issueType.subtask)\n\t\t\t\t\t\t\t.map(async (issueType) => {\n\t\t\t\t\t\t\t\tconst fields = await this.#pages<\n\t\t\t\t\t\t\t\t\tJiraCreateField & { /** @internal */ fieldId: string }\n\t\t\t\t\t\t\t\t>(`${path}/${encodeURIComponent(issueType.id)}`, \"values\", signal);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...issueType,\n\t\t\t\t\t\t\t\t\tfields: Object.fromEntries(\n\t\t\t\t\t\t\t\t\t\tfields.map(({ fieldId, ...field }) => {\n\t\t\t\t\t\t\t\t\t\t\tif (typeof fieldId !== \"string\" || !fieldId)\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Jira returned invalid create field metadata\");\n\t\t\t\t\t\t\t\t\t\t\treturn [fieldId, field];\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** @internal */\n\tlistProjectIssues(projectId: string, signal?: AbortSignal): Promise<JiraIssue[]> {\n\t\tif (!/^\\d+$/.test(projectId)) throw new Error(\"Invalid Jira project ID\");\n\t\treturn this.#pages<JiraIssue>(\n\t\t\t`search?jql=${encodeURIComponent(`project = ${projectId} ORDER BY id ASC`)}&fields=summary,description,labels,project,components,status`,\n\t\t\t\"issues\",\n\t\t\tsignal,\n\t\t);\n\t}\n\n\t/** @internal */\n\tasync createIssue(fields: Record<string, unknown>, signal?: AbortSignal): Promise<JiraIssue> {\n\t\tconst result = await this.createIssueReceipt(fields, signal);\n\t\treturn this.getIssue(result.id, signal);\n\t}\n\n\t/** Return the write receipt without a follow-up read that could obscure a successful POST. @internal */\n\tcreateIssueReceipt(\n\t\tfields: Record<string, unknown>,\n\t\tsignal?: AbortSignal,\n\t): Promise<JiraIssueReceipt> {\n\t\treturn this.#request<JiraIssueReceipt>(\"issue\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ fields }),\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @internal */\n\tlistComponents(projectId: string) {\n\t\treturn this.#pages<JiraComponent>(\n\t\t\t`project/${encodeURIComponent(projectId)}/components`,\n\t\t\t\"values\",\n\t\t);\n\t}\n\n\t/** @internal */\n\tsearchIssues(projectIds: readonly string[], triggerLabel?: string) {\n\t\tif (!projectIds.length || projectIds.some((id) => !/^\\d+$/.test(id)))\n\t\t\tthrow new Error(\"Select explicit Jira project IDs\");\n\t\tconst jql = `project in (${projectIds.join(\",\")}) AND labels = ${JSON.stringify(jiraTriggerLabel(triggerLabel))} AND (labels not in (\"leitwerk-done\")) AND statusCategory != Done ORDER BY id ASC`;\n\t\treturn this.#pages<JiraIssue>(\n\t\t\t`search?jql=${encodeURIComponent(jql)}&fields=summary,description,labels,project,components,status`,\n\t\t\t\"issues\",\n\t\t);\n\t}\n\n\t/** @internal */\n\tgetIssue(id: string, signal?: AbortSignal) {\n\t\treturn this.#request<JiraIssue>(`issue/${encodeURIComponent(id)}?fields=*all`, { signal });\n\t}\n\n\tasync #resolveEpicLinkField(): Promise<string | null> {\n\t\tif (this.#epicLinkField) return this.#epicLinkField;\n\t\tconst fields = await this.#request<{ id: string; schema?: { custom?: string } }[]>(\"field\");\n\t\tconst matches = fields.filter(\n\t\t\t(field) => field.schema?.custom === \"com.pyxis.greenhopper.jira:gh-epic-link\",\n\t\t);\n\t\tif (!matches.length) return null;\n\t\tif (matches.length !== 1)\n\t\t\tthrow new Error(\n\t\t\t\t\"Configure this Jira profile's epic_link_field; Epic Link discovery is ambiguous\",\n\t\t\t);\n\t\tthis.#epicLinkField = matches[0].id;\n\t\treturn this.#epicLinkField;\n\t}\n\n\t/** @internal */\n\tasync getEpic(issue: JiraIssue): Promise<JiraIssue | null> {\n\t\tif (issue.fields.issuetype?.name.toLowerCase() === \"epic\") return issue;\n\t\tconst field = await this.#resolveEpicLinkField();\n\t\tif (!field) return null;\n\t\tconst key = (issue.fields as unknown as Record<string, unknown>)[field];\n\t\treturn typeof key === \"string\" && key ? this.getIssue(key) : null;\n\t}\n\n\t/** @internal */\n\tsearchSplitIssues(projectIds: readonly string[]): Promise<JiraIssue[]> {\n\t\tif (!projectIds.length || projectIds.some((id) => !/^\\d+$/.test(id)))\n\t\t\tthrow new Error(\"Select explicit Jira project IDs\");\n\t\tconst jql = `project in (${projectIds.join(\",\")}) AND labels in (\"leitwerk-issue-split\", \"leitwerk-epic-split\") AND issuetype not in subTaskIssueTypes() AND statusCategory != Done ORDER BY id ASC`;\n\t\treturn this.#pages(`search?jql=${encodeURIComponent(jql)}&fields=*all`, \"issues\");\n\t}\n\n\t/** @internal */\n\tasync createMetadata(projectId: string, includeEpicLink = true): Promise<JiraCreateMetadata> {\n\t\tconst metadata = await this.#request<{\n\t\t\tprojects: { id: string; issuetypes: JiraCreateMetadata[\"issueTypes\"] }[];\n\t\t}>(\n\t\t\t`issue/createmeta?projectIds=${encodeURIComponent(projectId)}&expand=projects.issuetypes.fields`,\n\t\t);\n\t\tconst project = metadata.projects.find((candidate) => candidate.id === projectId);\n\t\tif (!project) throw new Error(\"Jira issue creation is unavailable for this project\");\n\t\tconst epicLinkField = includeEpicLink ? await this.#resolveEpicLinkField() : null;\n\t\tif (includeEpicLink && !epicLinkField)\n\t\t\tthrow new Error(\"Splitting a Jira epic requires an Epic Link field\");\n\t\treturn { epicLinkField, issueTypes: project.issuetypes };\n\t}\n\n\t/** @internal */\n\tasync findSplitIssue(projectId: string, marker: string): Promise<JiraIssue | null> {\n\t\tif (!/^\\d+$/.test(projectId) || !/^leitwerk-split-[a-f0-9]{64}$/.test(marker))\n\t\t\tthrow new Error(\"Invalid split ticket identity\");\n\t\tconst jql = `project = ${projectId} AND labels = \"${marker}\" ORDER BY id ASC`;\n\t\tconst matches = await this.#pages<JiraIssue>(\n\t\t\t`search?jql=${encodeURIComponent(jql)}&fields=*all`,\n\t\t\t\"issues\",\n\t\t);\n\t\tif (matches.length > 1)\n\t\t\tthrow new Error(\n\t\t\t\t\"Multiple Jira tickets share the split identity; operator reconciliation required\",\n\t\t\t);\n\t\treturn matches[0] ?? null;\n\t}\n\n\t/** @internal */\n\tlistComments(id: string) {\n\t\treturn this.#pages<JiraComment>(`issue/${encodeURIComponent(id)}/comment`, \"comments\");\n\t}\n\n\t/** @internal */\n\tlistRemoteLinks(id: string, signal?: AbortSignal) {\n\t\treturn this.#request<JiraRemoteLink[]>(`issue/${encodeURIComponent(id)}/remotelink`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @internal */\n\tupsertRemoteLink(\n\t\tid: string,\n\t\tlink: Omit<JiraRemoteLink, \"id\">,\n\t\tsignal?: AbortSignal,\n\t): Promise<Pick<JiraRemoteLink, \"id\">> {\n\t\treturn this.#request<Pick<JiraRemoteLink, \"id\">>(`issue/${encodeURIComponent(id)}/remotelink`, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify(link),\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync listTransitions(id: string, signal?: AbortSignal): Promise<JiraTransition[]> {\n\t\tconst result = await this.#request<{ transitions: JiraTransition[] }>(\n\t\t\t`issue/${encodeURIComponent(id)}/transitions`,\n\t\t\t{ signal },\n\t\t);\n\t\treturn result.transitions;\n\t}\n\n\t/** @internal */\n\ttransitionIssue(id: string, transitionId: string, signal?: AbortSignal) {\n\t\treturn this.#request<void>(`issue/${encodeURIComponent(id)}/transitions`, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ transition: { id: transitionId } }),\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @internal */\n\taddComment(id: string, body: string) {\n\t\treturn this.#request<JiraComment>(`issue/${encodeURIComponent(id)}/comment`, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ body }),\n\t\t});\n\t}\n\n\t/** @internal */\n\tupdateLabels(id: string, remove: string[], add: string[]) {\n\t\treturn this.#request<void>(`issue/${encodeURIComponent(id)}`, {\n\t\t\tmethod: \"PUT\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tupdate: {\n\t\t\t\t\tlabels: [\n\t\t\t\t\t\t...remove.map((value) => ({ remove: value })),\n\t\t\t\t\t\t...add.map((value) => ({ add: value })),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/** Resolve and validate the change trigger; absent values preserve existing runs. @internal */\nexport function jiraTriggerLabel(value: unknown = undefined): string {\n\tif (value === undefined) return \"use-leitwerk\";\n\tif (typeof value !== \"string\" || !/^[A-Za-z0-9_.-]{1,255}$/.test(value))\n\t\tthrow new Error(\n\t\t\t\"Jira trigger label must contain only letters, digits, dots, underscores or hyphens\",\n\t\t);\n\treturn value;\n}\n\n/** @public */\nexport const jiraEligible = (issue: JiraIssue, triggerLabel?: string) =>\n\tissue.fields.labels.includes(jiraTriggerLabel(triggerLabel)) &&\n\t!issue.fields.labels.includes(\"leitwerk-done\") &&\n\tissue.fields.status.statusCategory.key !== \"done\";\n/** Installation context paths and immutable issue IDs define launch identity. @public */\nexport const jiraIssueExternalId = (baseUrl: string, id: string) =>\n\t`jira:${JSON.stringify([jiraBaseUrl(baseUrl), id])}`;\n\n/** @internal */\nexport const jiraIsEpic = (issue: JiraIssue) =>\n\tissue.fields.issuetype?.name.toLowerCase() === \"epic\";\n\n/** @internal */\nexport const jiraSplitEligible = (issue: JiraIssue) =>\n\tBoolean(issue.fields.issuetype?.id) &&\n\tissue.fields.issuetype?.subtask !== true &&\n\tissue.fields.status.statusCategory.key !== \"done\" &&\n\tissue.fields.labels.some((label) =>\n\t\t[\"leitwerk-issue-split\", \"leitwerk-epic-split\"].includes(label),\n\t);\n\n/** @internal */\nexport async function jiraSplitChildMatches(\n\tclient: JiraClientLike,\n\tissue: JiraIssue,\n\tsourceIssueId: string,\n\trelationship: \"epic\" | \"subtask\",\n): Promise<boolean> {\n\tif (relationship === \"subtask\")\n\t\treturn issue.fields.issuetype?.subtask === true && issue.fields.parent?.id === sourceIssueId;\n\treturn (\n\t\tissue.fields.issuetype?.subtask !== true &&\n\t\t(await client.getEpic?.(issue))?.id === sourceIssueId\n\t);\n}\n","import MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nconst markdownParser = new MarkdownIt({ html: false, linkify: false });\nconst normalizeNewlines = (value: string) => value.replace(/\\r\\n?/g, \"\\n\");\nconst escapeMarkdown = (value: string) => value.replace(/[\\\\`*_[\\]<>|~]/g, \"\\\\$&\");\nconst escapeJira = (value: string) =>\n\tvalue.replace(/[\\\\*_{}[\\]|!+^~]/g, \"\\\\$&\").replace(/(?<!\\w)-(?=\\S)|(?<=\\S)-(?!\\w)/g, \"\\\\-\");\n\nfunction closingToken(tokens: Token[], start: number): number {\n\tlet depth = 0;\n\tfor (let index = start; index < tokens.length; index++) {\n\t\tdepth += tokens[index]?.nesting ?? 0;\n\t\tif (depth === 0) return index;\n\t}\n\treturn tokens.length;\n}\n\nfunction markdownInlineToJira(tokens: Token[]): string {\n\tconst output: string[] = [];\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tconst token = tokens[index];\n\t\tif (!token) continue;\n\t\tif (token.type === \"link_open\") {\n\t\t\tconst end = closingToken(tokens, index);\n\t\t\toutput.push(\n\t\t\t\t`[${markdownInlineToJira(tokens.slice(index + 1, end))}|${token.attrGet(\"href\") ?? \"\"}]`,\n\t\t\t);\n\t\t\tindex = end;\n\t\t} else if (token.type === \"code_inline\") output.push(`{{${token.content}}}`);\n\t\telse if (token.type.startsWith(\"strong_\")) output.push(\"*\");\n\t\telse if (token.type.startsWith(\"em_\")) output.push(\"_\");\n\t\telse if (token.type.startsWith(\"s_\")) output.push(\"-\");\n\t\telse if (token.type === \"softbreak\") output.push(\"\\n\");\n\t\telse if (token.type === \"hardbreak\") output.push(\"\\\\\\\\\\n\");\n\t\telse if (token.type === \"image\")\n\t\t\toutput.push(`[${escapeJira(token.content)}|${token.attrGet(\"src\") ?? \"\"}]`);\n\t\telse\n\t\t\toutput.push(\n\t\t\t\ttoken.children ? markdownInlineToJira(token.children) : escapeJira(token.content),\n\t\t\t);\n\t}\n\treturn output.join(\"\");\n}\n\nfunction markdownTableToJira(tokens: Token[]): string {\n\tconst rows: string[] = [];\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tif (tokens[index]?.type !== \"tr_open\") continue;\n\t\tconst end = closingToken(tokens, index);\n\t\tconst row = tokens.slice(index + 1, end);\n\t\tconst separator = row.some((token) => token.type === \"th_open\") ? \"||\" : \"|\";\n\t\tconst cells = row\n\t\t\t.filter((token) => token.type === \"inline\")\n\t\t\t.map((token) => markdownInlineToJira(token.children ?? []));\n\t\trows.push(`${separator}${cells.join(separator)}${separator}`);\n\t\tindex = end;\n\t}\n\treturn rows.join(\"\\n\");\n}\n\nfunction markdownBlocksToJira(tokens: Token[], listMarkers = \"\"): string[] {\n\tconst output: string[] = [];\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tconst token = tokens[index];\n\t\tif (!token) continue;\n\t\tif (token.type === \"fence\" || token.type === \"code_block\") {\n\t\t\tconst language = /^[\\w+-]+/.exec(token.info.trim())?.[0] ?? \"\";\n\t\t\toutput.push(\n\t\t\t\t`{code${language ? `:${language}` : \"\"}}\\n${token.content.replace(/\\n$/, \"\")}\\n{code}`,\n\t\t\t);\n\t\t} else if (token.type === \"hr\") output.push(\"----\");\n\t\telse if (token.nesting === 1) {\n\t\t\tconst end = closingToken(tokens, index);\n\t\t\tconst inner = tokens.slice(index + 1, end);\n\t\t\tif (token.type === \"bullet_list_open\" || token.type === \"ordered_list_open\") {\n\t\t\t\tconst markers = listMarkers + (token.type === \"bullet_list_open\" ? \"*\" : \"#\");\n\t\t\t\tconst items: string[] = [];\n\t\t\t\tfor (let item = 0; item < inner.length; item++) {\n\t\t\t\t\tif (inner[item]?.type !== \"list_item_open\") continue;\n\t\t\t\t\tconst itemEnd = closingToken(inner, item);\n\t\t\t\t\tconst blocks = markdownBlocksToJira(inner.slice(item + 1, itemEnd), markers);\n\t\t\t\t\titems.push(`${markers} ${blocks.join(\"\\n\")}`);\n\t\t\t\t\titem = itemEnd;\n\t\t\t\t}\n\t\t\t\toutput.push(items.join(\"\\n\"));\n\t\t\t} else if (token.type === \"blockquote_open\")\n\t\t\t\toutput.push(`{quote}\\n${markdownBlocksToJira(inner, listMarkers).join(\"\\n\\n\")}\\n{quote}`);\n\t\t\telse if (token.type === \"table_open\") output.push(markdownTableToJira(inner));\n\t\t\telse {\n\t\t\t\tconst text = markdownBlocksToJira(inner, listMarkers).join(\"\\n\\n\");\n\t\t\t\toutput.push(token.type === \"heading_open\" ? `${token.tag}. ${text}` : text);\n\t\t\t}\n\t\t\tindex = end;\n\t\t} else if (token.type === \"inline\") output.push(markdownInlineToJira(token.children ?? []));\n\t\telse if (token.content) output.push(escapeJira(token.content));\n\t}\n\treturn output;\n}\n\n/** Converts ticket Markdown to Jira Server/Data Center wiki markup. @internal */\nexport function markdownToJira(markdown: string): string {\n\treturn markdownBlocksToJira(markdownParser.parse(normalizeNewlines(markdown ?? \"\"), {})).join(\n\t\t\"\\n\\n\",\n\t);\n}\n\nfunction backtickDelimiter(value: string, minimum: number): string {\n\tconst lengths = [...value.matchAll(/`+/g)].map((match) => match[0].length + 1);\n\treturn \"`\".repeat(Math.max(minimum, ...lengths));\n}\n\nfunction markdownCodeSpan(value: string): string {\n\tconst delimiter = backtickDelimiter(value, 1);\n\tconst pad = /^`|`$|^ .* $/s.test(value) ? \" \" : \"\";\n\treturn `${delimiter}${pad}${value}${pad}${delimiter}`;\n}\n\nfunction literalEnd(value: string, start: number): number | null {\n\tif (value.startsWith(\"{{\", start)) {\n\t\tconst closing = /}{2,}/.exec(value.slice(start + 2));\n\t\treturn closing ? start + 2 + closing.index + closing[0].length : null;\n\t}\n\tif (value[start] === \"[\" || value[start] === \"{\") {\n\t\tconst close = value[start] === \"[\" ? \"]\" : \"}\";\n\t\tfor (let index = start + 1; index < value.length; index++) {\n\t\t\tif (value[index] === \"\\\\\") index++;\n\t\t\telse if (value[index] === close) return index + 1;\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction jiraEmphasisEnd(value: string, start: number, delimiter: string): number | null {\n\tfor (let index = start + 1; index < value.length; index++) {\n\t\tif (value[index] === \"\\\\\") {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst protectedEnd = literalEnd(value, index);\n\t\tif (protectedEnd !== null) {\n\t\t\tindex = protectedEnd - 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tvalue[index] === delimiter &&\n\t\t\tindex > start + 1 &&\n\t\t\t!/\\s/.test(value[index - 1] ?? \"\") &&\n\t\t\t!/[\\w]/.test(value[index + 1] ?? \"\")\n\t\t)\n\t\t\treturn index;\n\t}\n\treturn null;\n}\n\nfunction jiraInlineToMarkdown(value: string): string {\n\tconst output: string[] = [];\n\tfor (let index = 0; index < value.length; index++) {\n\t\tconst char = value[index] ?? \"\";\n\t\tif (value.startsWith(\"\\\\\\\\\", index)) {\n\t\t\toutput.push(\" \\n\");\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"\\\\\" && /[\\\\*_{}[\\]|!+\\-^~]/.test(value[index + 1] ?? \"\")) {\n\t\t\toutput.push(escapeMarkdown(value[++index] ?? \"\"));\n\t\t\tcontinue;\n\t\t}\n\t\tconst end = literalEnd(value, index);\n\t\tif (end !== null && value.startsWith(\"{{\", index)) {\n\t\t\toutput.push(markdownCodeSpan(value.slice(index + 2, end - 2)));\n\t\t\tindex = end - 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (end !== null && char === \"[\") {\n\t\t\tconst link = value.slice(index + 1, end - 1);\n\t\t\tconst separator = link.search(/(?<!\\\\)\\|/);\n\t\t\tconst target = (separator < 0 ? link : link.slice(separator + 1)).trim();\n\t\t\tif (/^(https?:\\/\\/|mailto:)/i.test(target)) {\n\t\t\t\tconst label =\n\t\t\t\t\tseparator < 0 ? escapeMarkdown(link) : jiraInlineToMarkdown(link.slice(0, separator));\n\t\t\t\tconst url = target.replace(/[<>\\s\\\\]/g, (c) => encodeURIComponent(c));\n\t\t\t\toutput.push(`[${label}](${/[()]/.test(url) ? `<${url}>` : url})`);\n\t\t\t} else output.push(escapeMarkdown(value.slice(index, end)));\n\t\t\tindex = end - 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (end !== null && char === \"{\") {\n\t\t\toutput.push(escapeMarkdown(value.slice(index, end)));\n\t\t\tindex = end - 1;\n\t\t\tcontinue;\n\t\t}\n\t\tconst delimiter = char === \"*\" ? \"**\" : char === \"_\" ? \"*\" : char === \"-\" ? \"~~\" : null;\n\t\tif (\n\t\t\tdelimiter &&\n\t\t\t!/[\\w]/.test(value[index - 1] ?? \"\") &&\n\t\t\t!/[\\s]/.test(value[index + 1] ?? \"\") &&\n\t\t\tvalue[index + 1] !== char\n\t\t) {\n\t\t\tconst close = jiraEmphasisEnd(value, index, char);\n\t\t\tif (close !== null) {\n\t\t\t\toutput.push(\n\t\t\t\t\t`${delimiter}${jiraInlineToMarkdown(value.slice(index + 1, close))}${delimiter}`,\n\t\t\t\t);\n\t\t\t\tindex = close;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\toutput.push(escapeMarkdown(char));\n\t}\n\treturn output.join(\"\");\n}\n\nfunction jiraTableRow(line: string): { cells: string[]; header: boolean } | null {\n\tconst row = line.trim();\n\tif (!row.startsWith(\"|\") || !row.endsWith(\"|\")) return null;\n\tconst cells: string[] = [];\n\tlet cell = \"\";\n\tconst start = row.startsWith(\"||\") ? 2 : 1;\n\tconst end = row.length - (row.endsWith(\"||\") ? 2 : 1);\n\tfor (let index = start; index < end; index++) {\n\t\tif (row[index] === \"\\\\\" && index + 1 < end) cell += row[index] + row[++index];\n\t\telse {\n\t\t\tconst protectedEnd = literalEnd(row, index);\n\t\t\tif (protectedEnd !== null) {\n\t\t\t\tcell += row.slice(index, protectedEnd);\n\t\t\t\tindex = protectedEnd - 1;\n\t\t\t} else if (row[index] === \"|\") {\n\t\t\t\tcells.push(cell.trim());\n\t\t\t\tcell = \"\";\n\t\t\t\tif (row[index + 1] === \"|\") index++;\n\t\t\t} else cell += row[index];\n\t\t}\n\t}\n\tcells.push(cell.trim());\n\treturn { cells, header: start === 2 };\n}\n\nfunction jiraTextToMarkdown(value: string): string {\n\tconst lines = value.split(\"\\n\");\n\tconst output: string[] = [];\n\tfor (let index = 0; index < lines.length; index++) {\n\t\tconst line = lines[index] ?? \"\";\n\t\tconst table = jiraTableRow(line);\n\t\tif (table) {\n\t\t\tconst rows = [table];\n\t\t\twhile (index + 1 < lines.length) {\n\t\t\t\tconst next = jiraTableRow(lines[index + 1] ?? \"\");\n\t\t\t\tif (!next) break;\n\t\t\t\trows.push(next);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tconst width = Math.max(...rows.map((row) => row.cells.length));\n\t\t\tconst renderRow = (cells: string[]) =>\n\t\t\t\t`| ${Array.from({ length: width }, (_, column) =>\n\t\t\t\t\tjiraInlineToMarkdown(cells[column] ?? \"\").replace(/(?<!\\\\)\\|/g, \"\\\\|\"),\n\t\t\t\t).join(\" | \")} |`;\n\t\t\tconst header = table.header ? (rows.shift()?.cells ?? []) : [];\n\t\t\toutput.push(\n\t\t\t\trenderRow(header),\n\t\t\t\t`| ${Array(width).fill(\"---\").join(\" | \")} |`,\n\t\t\t\t...rows.map((row) => renderRow(row.cells)),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tconst heading = /^h([1-6])\\.\\s+(.*)$/.exec(line);\n\t\tconst list = /^\\s*([*#]+)\\s+(.*)$/.exec(line);\n\t\tif (heading)\n\t\t\toutput.push(`${\"#\".repeat(Number(heading[1]))} ${jiraInlineToMarkdown(heading[2] ?? \"\")}`);\n\t\telse if (list) {\n\t\t\tconst markers = list[1] ?? \"*\";\n\t\t\toutput.push(\n\t\t\t\t`${\" \".repeat(markers.length - 1)}${markers.endsWith(\"#\") ? \"1.\" : \"-\"} ${jiraInlineToMarkdown(list[2] ?? \"\")}`,\n\t\t\t);\n\t\t} else if (/^bq\\.\\s?/.test(line))\n\t\t\toutput.push(`> ${jiraInlineToMarkdown(line.replace(/^bq\\.\\s?/, \"\"))}`);\n\t\telse if (/^-{4,}\\s*$/.test(line)) output.push(\"---\");\n\t\telse output.push(jiraInlineToMarkdown(line));\n\t}\n\treturn output.join(\"\\n\");\n}\n\n/** Converts Jira wiki markup to Markdown while retaining unsupported macros as text. @internal */\nexport function jiraToMarkdown(markup: string | null | undefined): string {\n\tconst value = normalizeNewlines(markup ?? \"\");\n\tconst output: string[] = [];\n\tlet cursor = 0;\n\tfor (let index = 0; index < value.length; index++) {\n\t\tif (value[index] === \"\\\\\") {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst match = /^\\{(code|noformat|quote)(?::([^}\\n]*))?}/.exec(value.slice(index));\n\t\tif (!match || value.startsWith(\"{{\", index)) {\n\t\t\tconst protectedEnd = literalEnd(value, index);\n\t\t\tif (protectedEnd !== null) index = protectedEnd - 1;\n\t\t\tcontinue;\n\t\t}\n\t\tconst start = index + match[0].length;\n\t\tconst end = value.indexOf(`{${match[1]}}`, start);\n\t\tif (end < 0) continue;\n\t\tconst before = jiraTextToMarkdown(value.slice(cursor, index)).replace(/^\\n+|\\n+$/g, \"\");\n\t\tif (before) output.push(before);\n\t\tconst content = value.slice(start, end).replace(/^\\n|\\n$/g, \"\");\n\t\tif (match[1] === \"quote\")\n\t\t\toutput.push(\n\t\t\t\tjiraToMarkdown(content)\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map((line) => `> ${line}`)\n\t\t\t\t\t.join(\"\\n\"),\n\t\t\t);\n\t\telse {\n\t\t\tconst params = match[2] ?? \"\";\n\t\t\tconst language =\n\t\t\t\t/(?:^|\\|)language=([\\w+-]+)/.exec(params)?.[1] ??\n\t\t\t\t/^([\\w+-]+)(?:\\||$)/.exec(params)?.[1] ??\n\t\t\t\t\"\";\n\t\t\tconst fence = backtickDelimiter(content, 3);\n\t\t\toutput.push(`${fence}${language}\\n${content}\\n${fence}`);\n\t\t}\n\t\tcursor = end + `{${match[1]}}`.length;\n\t\tindex = cursor - 1;\n\t}\n\tconst after = jiraTextToMarkdown(value.slice(cursor)).replace(/^\\n+|\\n+$/g, \"\");\n\tif (after) output.push(after);\n\treturn output.join(\"\\n\\n\");\n}\n","import { createHash } from \"node:crypto\";\nimport { projectParameters, type ServerExtensionAPI, stringArg } from \"@leitwerk-dev/process-sdk\";\nimport { jiraTriggerLabel } from \"./client.js\";\nimport type { JiraIntegration } from \"./index.js\";\nimport { jiraToMarkdown } from \"./markdown.js\";\nimport { registerJiraWorkflowTools, resolveJiraSourceClient } from \"./workflow-tools.js\";\n\n/** @internal */\nexport function registerJiraTools(api: ServerExtensionAPI, integration: JiraIntegration) {\n\tfor (const name of [\n\t\t\"jira_get_source_issue\",\n\t\t\"jira_get_issue\",\n\t\t\"jira_comment\",\n\t\t\"jira_finalize_source_issue\",\n\t] as const)\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription:\n\t\t\t\tname === \"jira_get_source_issue\" || name === \"jira_get_issue\"\n\t\t\t\t\t? name === \"jira_get_source_issue\"\n\t\t\t\t\t\t? \"Read the launch-pinned Jira source issue. Use descriptionMarkdown for its converted Markdown description; fields.description retains the original Jira wiki markup.\"\n\t\t\t\t\t\t: \"Read a Jira issue by key or ID using the current process project's bound Jira profile. Use descriptionMarkdown for converted Markdown; fields.description retains Jira wiki markup.\"\n\t\t\t\t\t: \"Reconcile the launch-pinned Jira source issue\",\n\t\t\tparameters:\n\t\t\t\tname === \"jira_get_source_issue\"\n\t\t\t\t\t? projectParameters()\n\t\t\t\t\t: name === \"jira_get_issue\"\n\t\t\t\t\t\t? projectParameters({ issueKey: { type: \"string\" } })\n\t\t\t\t\t\t: projectParameters({\n\t\t\t\t\t\t\t\tbody: { type: \"string\" },\n\t\t\t\t\t\t\t\twriteKey: { type: \"string\" },\n\t\t\t\t\t\t\t\tdone: { type: \"boolean\" },\n\t\t\t\t\t\t\t}),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst { binding, client, id } = resolveJiraSourceClient(ctx, integration);\n\t\t\t\tif (name === \"jira_get_source_issue\" || name === \"jira_get_issue\") {\n\t\t\t\t\tconst issue = await client.getIssue(\n\t\t\t\t\t\tname === \"jira_get_source_issue\" ? id : stringArg(args, \"issueKey\"),\n\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t);\n\t\t\t\t\treturn { ...issue, descriptionMarkdown: jiraToMarkdown(issue.fields.description) };\n\t\t\t\t}\n\t\t\t\tconst digest = createHash(\"sha256\")\n\t\t\t\t\t.update(JSON.stringify([client.baseUrl, id, ctx.process.id, stringArg(args, \"writeKey\")]))\n\t\t\t\t\t.digest(\"hex\");\n\t\t\t\tif (name === \"jira_comment\") {\n\t\t\t\t\tconst marker = `{noformat}leitwerk:${digest}{noformat}`;\n\t\t\t\t\treturn ctx.externalWrites.ensure(\n\t\t\t\t\t\t{ writeType: name, dedupKey: digest },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t\t\t(await client.listComments(id)).find((comment) => comment.body.includes(marker)) ??\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\texecute: () => client.addComment(id, `${stringArg(args, \"body\")}\\n\\n${marker}`),\n\t\t\t\t\t\t\ttoMetadata: (comment) => ({ commentId: comment.id }),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst done = args.done === true;\n\t\t\t\tconst triggerLabel = jiraTriggerLabel(binding.triggerLabel);\n\t\t\t\treturn ctx.externalWrites.ensure(\n\t\t\t\t\t{ writeType: name, dedupKey: digest },\n\t\t\t\t\t{\n\t\t\t\t\t\treconcile: async () => {\n\t\t\t\t\t\t\tconst issue = await client.getIssue(id);\n\t\t\t\t\t\t\treturn !issue.fields.labels.includes(triggerLabel) &&\n\t\t\t\t\t\t\t\t(!done || issue.fields.labels.includes(\"leitwerk-done\"))\n\t\t\t\t\t\t\t\t? { issueId: id, done }\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute: async () => {\n\t\t\t\t\t\t\tawait client.updateLabels(id, [triggerLabel], done ? [\"leitwerk-done\"] : []);\n\t\t\t\t\t\t\treturn { issueId: id, done };\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoMetadata: (result) => result,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\tregisterJiraWorkflowTools(api, integration);\n}\n","import { createHash } from \"node:crypto\";\nimport { basename } from \"node:path\";\nimport { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\tcoreHostCapabilities,\n\ttype IntegrationToolExecutionContext,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { JiraIntegration } from \"./index.js\";\n\n/** @internal */\nexport function resolveJiraSourceClient(\n\tctx: IntegrationToolExecutionContext,\n\tintegration: JiraIntegration,\n) {\n\tconst binding = asUnknownRecord(ctx.project?.metadata?.jira);\n\tif (\n\t\ttypeof binding?.profile !== \"string\" ||\n\t\ttypeof binding.issueId !== \"string\" ||\n\t\ttypeof binding.baseUrl !== \"string\"\n\t)\n\t\tthrow new Error(\"Missing Jira source binding\");\n\tconst client = integration.client(binding.profile);\n\tif (client.baseUrl !== binding.baseUrl) throw new Error(\"Jira profile installation changed\");\n\treturn { client, id: binding.issueId, binding };\n}\n\nconst digest = (parts: unknown[]) =>\n\tcreateHash(\"sha256\").update(JSON.stringify(parts)).digest(\"hex\");\nconst statusName = (name: string | undefined) => name?.trim().toLowerCase();\n\n/** @internal */\nexport function registerJiraWorkflowTools(api: ServerExtensionAPI, integration: JiraIntegration) {\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"jira_ensure_remote_link\",\n\t\tdescription: \"Link the current Leitwerk process or its pinned merge request to the Jira source\",\n\t\tparameters: projectParameters(\n\t\t\t{ kind: { type: \"string\", enum: [\"process\", \"merge_request\"] } },\n\t\t\t[\"kind\"],\n\t\t),\n\t\tasync execute(ctx, args) {\n\t\t\tconst { client, id } = resolveJiraSourceClient(ctx, integration);\n\t\t\tconst kind = stringArg(args, \"kind\");\n\t\t\tlet url: string;\n\t\t\tlet title: string;\n\t\t\tlet target: string;\n\t\t\tif (kind === \"process\") {\n\t\t\t\tconst deps = api.get?.(coreHostCapabilities.serverSetup);\n\t\t\t\tconst serverBaseUrl = deps && !Array.isArray(deps) ? deps.serverBaseUrl : undefined;\n\t\t\t\tif (!serverBaseUrl) throw new Error(\"Leitwerk public server URL is unavailable\");\n\t\t\t\turl = `${serverBaseUrl.replace(/\\/+$/, \"\")}/processes/${encodeURIComponent(ctx.process.id)}`;\n\t\t\t\ttitle = `Leitwerk process ${ctx.process.id}`;\n\t\t\t\ttarget = ctx.process.id;\n\t\t\t} else if (kind === \"merge_request\") {\n\t\t\t\tconst mr = asUnknownRecord(ctx.project?.metadata?.gitlab);\n\t\t\t\tif (\n\t\t\t\t\t!ctx.project?.externalUrl ||\n\t\t\t\t\t!ctx.project.externalId ||\n\t\t\t\t\ttypeof mr?.iid !== \"number\" ||\n\t\t\t\t\tString(mr.iid) !== ctx.project.externalId\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"A pinned merge request is required for the Jira link\");\n\t\t\t\turl = ctx.project.externalUrl;\n\t\t\t\tconst repositoryName = basename(ctx.project.repoLocator).replace(/\\.git$/, \"\");\n\t\t\t\ttitle = `GitLab ${repositoryName} !${ctx.project.externalId}`;\n\t\t\t\ttarget = JSON.stringify([ctx.project.id, ctx.project.externalId]);\n\t\t\t} else throw new Error(\"Unknown Jira remote link kind\");\n\t\t\tconst key = digest([client.baseUrl, id, kind, target]);\n\t\t\tconst globalId = `leitwerk:${key}`;\n\t\t\tconst intended = { globalId, object: { url, title } };\n\t\t\tconst find = async () =>\n\t\t\t\t(await client.listRemoteLinks(id, ctx.signal)).find((link) => link.globalId === globalId) ??\n\t\t\t\tnull;\n\t\t\tconst link = await ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"jira.remote_link\", dedupKey: key },\n\t\t\t\t{\n\t\t\t\t\treconcile: async (phase) => {\n\t\t\t\t\t\tconst link = await find();\n\t\t\t\t\t\treturn link &&\n\t\t\t\t\t\t\t(phase === \"already_recorded\" ||\n\t\t\t\t\t\t\t\t(link.object.url === url && link.object.title === title))\n\t\t\t\t\t\t\t? link\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\texecute: async () => {\n\t\t\t\t\t\tawait client.upsertRemoteLink(id, intended, ctx.signal);\n\t\t\t\t\t\tconst link = await find();\n\t\t\t\t\t\tif (!link || link.object.url !== url || link.object.title !== title)\n\t\t\t\t\t\t\tthrow new Error(\"Jira remote link read-back did not match\");\n\t\t\t\t\t\treturn link;\n\t\t\t\t\t},\n\t\t\t\t\ttoMetadata: (link) => ({ linkId: link.id, globalId: link.globalId }),\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { linkId: link.id, url };\n\t\t},\n\t});\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"jira_transition_source_issue\",\n\t\tdescription: \"Reconcile the Jira source ticket's work, review or verification status\",\n\t\tparameters: projectParameters(\n\t\t\t{\n\t\t\t\ttargetStatus: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tenum: [\"In Progress\", \"In Review\", \"Ready for Verification\", \"In Verification\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\t[\"targetStatus\"],\n\t\t),\n\t\tasync execute(ctx, args) {\n\t\t\tconst { client, id } = resolveJiraSourceClient(ctx, integration);\n\t\t\tconst targetStatus = stringArg(args, \"targetStatus\");\n\t\t\tif (\n\t\t\t\t![\"In Progress\", \"In Review\", \"Ready for Verification\", \"In Verification\"].includes(\n\t\t\t\t\ttargetStatus,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new Error(\"Unsupported Jira workflow target status\");\n\t\t\tconst target = statusName(targetStatus);\n\t\t\tconst reconcile = async (phase: string) => {\n\t\t\t\tconst { status } = (await client.getIssue(id, ctx.signal)).fields;\n\t\t\t\tconst current = statusName(status.name);\n\t\t\t\treturn phase === \"already_recorded\" ||\n\t\t\t\t\tcurrent === target ||\n\t\t\t\t\tstatus.statusCategory.key === \"done\" ||\n\t\t\t\t\tcurrent === \"in verification\" ||\n\t\t\t\t\t(current === \"ready for verification\" && target !== \"in verification\") ||\n\t\t\t\t\t(target === \"in progress\" && current === \"in review\")\n\t\t\t\t\t? { issueId: id, status: status.name ?? status.statusCategory.key }\n\t\t\t\t\t: null;\n\t\t\t};\n\t\t\treturn ctx.externalWrites.ensure(\n\t\t\t\t{\n\t\t\t\t\twriteType: \"jira.transition\",\n\t\t\t\t\tdedupKey: digest([client.baseUrl, id, ctx.process.id, target]),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\treconcile,\n\t\t\t\t\texecute: async () => {\n\t\t\t\t\t\tconst current = await reconcile(\"before_execute\");\n\t\t\t\t\t\tif (current) return current;\n\t\t\t\t\t\tconst transitions = (await client.listTransitions(id, ctx.signal)).filter(\n\t\t\t\t\t\t\t(transition) => statusName(transition.to.name) === target,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (transitions.length !== 1)\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Jira requires one available transition to ${targetStatus}; found ${transitions.length}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tawait client.transitionIssue(id, transitions[0].id, ctx.signal);\n\t\t\t\t\t\tconst result = await reconcile(\"after_execute_error\");\n\t\t\t\t\t\tif (!result) throw new Error(`Jira did not reach ${targetStatus}`);\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t},\n\t\t\t\t\ttoMetadata: (result) => result,\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t});\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AA+JzB,IAAM,mBAAN,cAA+B,MAAM;AAAA;AAAA,EAElC;AAAA;AAAA,EAET,YAAY,QAAgB;AAC3B,UAAM,wBAAwB,MAAM,GAAG;AACvC,SAAK,SAAS;AAAA,EACf;AACD;AASO,SAAS,YAAY,KAAqB;AAChD,QAAM,MAAM,IAAI,IAAI,GAAG;AACvB,MAAI,IAAI,aAAa,YAAY,IAAI,YAAY,IAAI,YAAY,IAAI,UAAU,IAAI;AAClF,UAAM,IAAI,MAAM,sEAAsE;AACvF,SAAO,IAAI,KAAK,QAAQ,QAAQ,EAAE;AACnC;AAGO,SAAS,kBAAkB,KAYhC;AACD,QAAM,WAAW,gBAAgB,gBAAgB,GAAG,GAAG,QAAQ,KAAK,CAAC;AACrE,SAAO,IAAI;AAAA,IACV,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;AAC7C,YAAM,UAAU,gBAAgB,KAAK;AACrC,UACC,OAAO,SAAS,aAAa,YAC7B,OAAO,QAAQ,U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WAAW,MAAM,UAAUC,QAAO;AAAA,UACpC;AAAA,YACC,WAAW,YAAY;AACtB,oBAAM,QAAQ,MAAM,OAAO,SAAS,EAAE;AACtC,qBAAO,CAAC,MAAM,OAAO,OAAO,SAAS,YAAY,MAC/C,CAAC,QAAQ,MAAM,OAAO,OAAO,SAAS,eAAe,KACpD,EAAE,SAAS,IAAI,KAAK,IACpB;AAAA,YACJ;AAAA,YACA,SAAS,YAAY;AACpB,oBAAM,OAAO,aAAa,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,eAAe,IAAI,CAAC,CAAC;AAC3E,qBAAO,EAAE,SAAS,IAAI,KAAK;AAAA,YAC5B;AAAA,YACA,YAAY,CAAC,WAAW;AAAA,UACzB;AAAA,QACD;AAAA,MACD;AAAA,IACD,CAAC;AACF,4BAA0B,KAAK,WAAW;AAC3C;","names":["createHash","projectParameters","stringArg","asUnknownRecord","link","projectParameters","stringArg","digest","createHash"]}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
markdownToJira,
|
|
13
13
|
parseJiraProfiles,
|
|
14
14
|
registerJiraTools
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VUXLYUPG.js";
|
|
16
16
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
@@ -215,7 +215,7 @@ function registerJiraTicketCreation(api, integration, config) {
|
|
|
215
215
|
|
|
216
216
|
// src/ticket-text.ts
|
|
217
217
|
import { SafeOutcomePlanningError } from "@leitwerk-dev/process-sdk";
|
|
218
|
-
var jiraTicketWritingInstructions = "Write summary and description as a normal standalone Jira task for its assignee, using Markdown for the description. Explain the work and acceptance criteria in plain language; retain concrete file paths, prerequisites, and validation steps when needed. Keep evidence, inspected revisions, repository keys, and other tracking data in the separate evidence fields. Do not put raw commit hashes, internal IDs, split identities, solution-wiki references, or model citation tokens in the summary or description. Refer to repositories by their readable names and Jira issues by their issue keys. The publisher adds repository and source-issue links. When revising an existing ticket, preserve useful task details and human notes, and omit any previous generated tracking footer.";
|
|
218
|
+
var jiraTicketWritingInstructions = "Use plain English following ASD-STE100. Use at most three headings and at most 120 words under each heading; code snippets do not count toward the word limit. Choose headings that fit the work and include only supported details. Link to internal data instead of copying it. Write summary and description as a normal standalone Jira task for its assignee, using Markdown for the description. Explain the work and acceptance criteria in plain language; retain concrete file paths, prerequisites, and validation steps when needed. Keep evidence, inspected revisions, repository keys, and other tracking data in the separate evidence fields. Do not put raw commit hashes, internal IDs, split identities, solution-wiki references, or model citation tokens in the summary or description. Refer to repositories by their readable names and Jira issues by their issue keys. The publisher adds repository and source-issue links. When revising an existing ticket, preserve useful task details and human notes, and omit any previous generated tracking footer.";
|
|
219
219
|
var internalReference = /\bleitwerk-split-[\w-]+\b|\brepo_\d+\b|\bagt_[a-z0-9]+\b|\b[a-f0-9]{40,64}\b|\bturn\d+(?:file|search|view|fetch)\d+\b|[\uE200-\uE202]|【[^】]*(?:†|turn\d+|repo_\d+)[^】]*】|Leitwerk split identity\s*:|(?:Source issue )?solution wiki\s*:/i;
|
|
220
220
|
function jiraTicketTextProblem(summary, description) {
|
|
221
221
|
return internalReference.test(`${summary}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/ticket-creation.ts","../src/ticket-text.ts","../src/wiki.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\tcoreHostCapabilities,\n\tcreateCapabilityToken,\n\tcreateExternalSourcePollReporter,\n\tdefineProcessWatcherSource,\n\ttype ExternalActionSource,\n\ttype LeitwerkExtensionModule,\n\tparseProcessWatcherLaunchModelConfig,\n\tparseTicketCreationConfig,\n\ttype ServerExtensionAPI,\n\tscopedSettingsCapability,\n\ttype TicketCreationConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult, parseDurationMs } from \"@leitwerk-dev/watcher-utils\";\nimport {\n\tJiraClient,\n\ttype JiraClientLike,\n\ttype JiraIssue,\n\tjiraEligible,\n\tjiraIssueExternalId,\n\tjiraTriggerLabel,\n\tparseJiraProfiles,\n} from \"./client.js\";\nimport { registerJiraTicketCreation } from \"./ticket-creation.js\";\nimport { registerJiraTools } from \"./tools.js\";\n\nexport * from \"./client.js\";\nexport { jiraToMarkdown, markdownToJira } from \"./markdown.js\";\nexport {\n\tassertJiraTicketText,\n\tjiraTicketTextProblem,\n\tjiraTicketWritingInstructions,\n\tticketDescriptionMarkdown,\n} from \"./ticket-text.js\";\nexport { ensureIssueWiki, jiraEpicRevision, jiraWikiSource } from \"./wiki.js\";\n\n/** @public */\nexport interface JiraIntegration {\n\t/** @internal */\n\tprofiles(): readonly string[];\n\n\t/** @internal */\n\tclient(profile: string): JiraClientLike;\n}\n\n/** @public */\nexport const jiraIntegration = createCapabilityToken<JiraIntegration>(\n\t\"@leitwerk-dev/jira.integration\",\n);\n\n/** Configured project discovery shared by Jira-backed Settings and launchers. @public */\nexport const jiraProjectDiscovery = createCapabilityToken<{\n\t/** @public */ projects(profile: string): Promise<readonly import(\"./client.js\").JiraProject[]>;\n\t/** @public */ includesProject(\n\t\tsubject: import(\"@leitwerk-dev/domain\").SettingsSubject | undefined,\n\t): boolean;\n}>(\"@leitwerk-dev/jira.project-discovery\");\n\n/** @public */\nexport const jiraSubjectIdentity = (baseUrl: string, id: string) => JSON.stringify([baseUrl, id]);\n\n/** @public */\nexport interface JiraWatcherConfig {\n\t/** @internal */\n\tlabel?: string;\n\t/** @internal */\n\tprofile: string;\n\n\t/** @internal */\n\tprojects: string[];\n\n\t/** @internal */\n\tpollInterval: string;\n}\n\n/** @public */\nexport interface JiraWatcherEvent {\n\t/** @internal */\n\ttriggerLabel?: string;\n\t/** @internal */\n\tprofile: string;\n\n\t/** @internal */\n\tissue: JiraIssue;\n\n\t/** @internal */\n\tprojects: string[];\n}\n\n/** @public */\nexport const jiraIssueWatcherSource = defineProcessWatcherSource<\n\tJiraWatcherConfig,\n\tJiraWatcherEvent\n>({\n\tid: \"@leitwerk-dev/jira.issue\",\n\tlabel: \"Jira issue\",\n\tparseConfig(raw) {\n\t\tconst c = asUnknownRecord(raw);\n\t\tif (\n\t\t\ttypeof c?.enabled !== \"boolean\" ||\n\t\t\ttypeof c.profile !== \"string\" ||\n\t\t\t!c.profile.trim() ||\n\t\t\t!Array.isArray(c.projects) ||\n\t\t\t!c.projects.length ||\n\t\t\tc.projects.some((id) => typeof id !== \"string\" || !/^\\d+$/.test(id))\n\t\t)\n\t\t\tthrow new Error(\"Jira watcher requires enabled, profile, and explicit project IDs\");\n\t\tconst pollInterval = c.poll_interval ?? \"30s\";\n\t\tif (typeof pollInterval !== \"string\" || parseDurationMs(pollInterval, -1) <= 0)\n\t\t\tthrow new Error(\"Invalid Jira poll_interval\");\n\t\treturn {\n\t\t\tenabled: c.enabled,\n\t\t\tconfig: {\n\t\t\t\tprofile: c.profile,\n\t\t\t\tprojects: c.projects as string[],\n\t\t\t\tpollInterval,\n\t\t\t\tlabel: jiraTriggerLabel(c.label),\n\t\t\t},\n\t\t\tlaunchModelConfig: parseProcessWatcherLaunchModelConfig(c.launch),\n\t\t};\n\t},\n\tpresentConfig: (c) => ({\n\t\ttargetSummary: `Jira ${c.profile} · ${c.projects.join(\", \")}`,\n\t\tdetails: [{ label: \"Trigger\", value: jiraTriggerLabel(c.label) }],\n\t}),\n});\n\n/** @public */\nexport interface JiraSourceConfig {\n\t/** @internal */\n\ttriggerLabel?: string;\n\t/** @internal */\n\tprofile: string;\n\t/** @internal */\n\tbaseUrl: string;\n\n\t/** @internal */\n\tissueId: string;\n\n\t/** @internal */\n\tplanRevision?: number;\n\n\t/** @internal */\n\tmode: \"plan_bypass\" | \"cancelled\";\n}\nconst ISSUE_POLICY = \"@leitwerk-dev/jira.issue-policy\";\n\n/** @public */\nexport function jiraIssuePolicy<P, S>(\n\tresolve: (ctx: {\n\t\t/** @internal */\n\t\tparams: P;\n\t\t/** @internal */\n\t\tstate: S;\n\t}) => JiraSourceConfig,\n): ExternalActionSource<P, S, unknown> {\n\treturn {\n\t\tkind: ISSUE_POLICY,\n\t\tlabel: \"Jira source policy\",\n\t\tconfig: {},\n\t\tinputMode: \"none\",\n\t\tresolve,\n\t};\n}\n\n/** @public */\nexport function setupJiraIntegration(\n\tapi: ServerExtensionAPI,\n\tintegration: JiraIntegration,\n\toptions: {\n\t\t/** @public */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tticketCreation?: TicketCreationConfig;\n\t\t/** Project IDs or keys explicitly selected by integration profiles. @internal */\n\t\tprojects?: ReadonlyMap<string, readonly string[]>;\n\t} = {},\n) {\n\tconst now = options.now ?? Date.now;\n\tapi.provide(jiraIntegration, integration);\n\tregisterJiraTools(api, integration);\n\tregisterJiraTicketCreation(\n\t\tapi,\n\t\tintegration,\n\t\toptions.ticketCreation ?? { enabled: false, defaultLabels: [] },\n\t);\n\tconst settings = api.get(scopedSettingsCapability);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tconst configuredProjects = (profile: string) =>\n\t\tnew Set([\n\t\t\t...(options.projects?.get(profile) ?? []),\n\t\t\t...(!deps || Array.isArray(deps)\n\t\t\t\t? []\n\t\t\t\t: (deps.processWatchers?.listBySource(jiraIssueWatcherSource) ?? [])\n\t\t\t\t\t\t.filter((watcher) => watcher.config.profile === profile)\n\t\t\t\t\t\t.flatMap((watcher) => watcher.config.projects)),\n\t\t]);\n\tconst projectsFor = async (profile: string) => {\n\t\tconst selected = configuredProjects(profile);\n\t\tif (!selected.size) return [];\n\t\tconst client = integration.client(profile);\n\t\tconst projects = (await client.listProjects()).filter(\n\t\t\t(project) => selected.has(project.id) || selected.has(project.key),\n\t\t);\n\t\treturn projects;\n\t};\n\tconst includesProject = (subject: import(\"@leitwerk-dev/domain\").SettingsSubject | undefined) => {\n\t\tif (!subject) return false;\n\t\tlet identity: unknown;\n\t\ttry {\n\t\t\tidentity = JSON.parse(subject.identity);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t\tif (!Array.isArray(identity) || identity.length !== 2) return false;\n\t\tconst [origin, id] = identity;\n\t\treturn integration.profiles().some((profile) => {\n\t\t\tif (integration.client(profile).baseUrl !== origin) return false;\n\t\t\tconst configured = configuredProjects(profile);\n\t\t\treturn configured.has(id) || configured.has(subject.label.split(\" · \")[0]);\n\t\t});\n\t};\n\tapi.provide(jiraProjectDiscovery, { projects: projectsFor, includesProject });\n\tif (settings && !Array.isArray(settings)) {\n\t\tsettings.registerDiscovery(\n\t\t\t\"jira.project\",\n\t\t\tasync () => {\n\t\t\t\tconst subjects = [];\n\t\t\t\tfor (const profile of integration.profiles()) {\n\t\t\t\t\tconst client = integration.client(profile);\n\t\t\t\t\tfor (const project of await projectsFor(profile))\n\t\t\t\t\t\tsubjects.push({\n\t\t\t\t\t\t\tscopeType: \"jira.project\",\n\t\t\t\t\t\t\tidentity: jiraSubjectIdentity(client.baseUrl, project.id),\n\t\t\t\t\t\t\tlabel: `${project.key} · ${project.name}`,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn subjects;\n\t\t\t},\n\t\t\t{ includesSubject: (subject) => includesProject(subject) },\n\t\t);\n\t\tsettings.registerDiscovery(\n\t\t\t\"jira.component\",\n\t\t\tasync () => {\n\t\t\t\tconst subjects = [];\n\t\t\t\tfor (const profile of integration.profiles()) {\n\t\t\t\t\tconst client = integration.client(profile);\n\t\t\t\t\tfor (const project of await projectsFor(profile)) {\n\t\t\t\t\t\tconst parent = settings.discover({\n\t\t\t\t\t\t\tscopeType: \"jira.project\",\n\t\t\t\t\t\t\tidentity: jiraSubjectIdentity(client.baseUrl, project.id),\n\t\t\t\t\t\t\tlabel: `${project.key} · ${project.name}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfor (const component of await client.listComponents(project.id))\n\t\t\t\t\t\t\tsubjects.push({\n\t\t\t\t\t\t\t\tscopeType: \"jira.component\",\n\t\t\t\t\t\t\t\tidentity: jiraSubjectIdentity(client.baseUrl, component.id),\n\t\t\t\t\t\t\t\tlabel: `${project.key} / ${component.name}`,\n\t\t\t\t\t\t\t\tcontext: { \"jira.project\": parent.id },\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn subjects;\n\t\t\t},\n\t\t\t{ includesSubject: (_subject, context) => includesProject(context[\"jira.project\"]) },\n\t\t);\n\t}\n\tif (!deps || Array.isArray(deps)) return;\n\tconst shouldPoll = createPollSchedule(now);\n\treturn deps.polling.create({\n\t\tid: \"jira\",\n\t\tpollInterval: () => \"5s\",\n\t\tdefaultIntervalMs: 5000,\n\t\tisEnabled: () => true,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tfor (const watcher of deps.processWatchers?.listBySource(jiraIssueWatcherSource) ?? []) {\n\t\t\t\tconst key = `${watcher.processId}:${watcher.watcherId}`;\n\t\t\t\tif (!watcher.enabled || !shouldPoll(key, watcher.config.pollInterval)) continue;\n\t\t\t\ttry {\n\t\t\t\t\tconst client = integration.client(watcher.config.profile);\n\t\t\t\t\tfor (const issue of await client.searchIssues(\n\t\t\t\t\t\twatcher.config.projects,\n\t\t\t\t\t\twatcher.config.label,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!jiraEligible(issue, watcher.config.label) ||\n\t\t\t\t\t\t\t!watcher.config.projects.includes(issue.fields.project.id)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tconst id = jiraIssueExternalId(client.baseUrl, issue.id);\n\t\t\t\t\t\tconst launch = await deps.launchRuns.startWatcher(\n\t\t\t\t\t\t\twatcher,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tprofile: watcher.config.profile,\n\t\t\t\t\t\t\t\tissue,\n\t\t\t\t\t\t\t\tprojects: watcher.config.projects,\n\t\t\t\t\t\t\t\ttriggerLabel: jiraTriggerLabel(watcher.config.label),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ idempotencyKey: id },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (launch.error)\n\t\t\t\t\t\t\tresult.errors.push(\n\t\t\t\t\t\t\t\t`${issue.key}: admission failed; inspect launch diagnostics and component mappings`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\telse if (launch.process) result.created.push(id);\n\t\t\t\t\t\telse result.skipped.push(id);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresult.errors.push(error instanceof Error ? error.message : \"Jira discovery unavailable\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst report = createExternalSourcePollReporter(deps.externalSources, result, {\n\t\t\t\tforwardGeneration: true,\n\t\t\t\tcurrentKinds: [ISSUE_POLICY],\n\t\t\t});\n\t\t\tawait report.poll(ISSUE_POLICY, async (armed) => {\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation}`;\n\t\t\t\tif (!shouldPoll(key)) return;\n\t\t\t\tconst c = armed.resolved as unknown as JiraSourceConfig;\n\t\t\t\ttry {\n\t\t\t\t\tconst client = integration.client(c.profile);\n\t\t\t\t\tif (client.baseUrl !== c.baseUrl) throw new Error(\"Jira profile installation changed\");\n\t\t\t\t\tconst issue = await client.getIssue(c.issueId);\n\t\t\t\t\tif (issue.id !== c.issueId) throw new Error(\"Uncorrelated Jira issue evidence\");\n\t\t\t\t\tconst fire =\n\t\t\t\t\t\tc.mode === \"plan_bypass\"\n\t\t\t\t\t\t\t? jiraEligible(issue, c.triggerLabel) &&\n\t\t\t\t\t\t\t\tissue.fields.labels.includes(\"leitwerk-skip-plan-decision\")\n\t\t\t\t\t\t\t: !jiraEligible(issue, c.triggerLabel);\n\t\t\t\t\tif (fire)\n\t\t\t\t\t\tawait report.fire(\n\t\t\t\t\t\t\tarmed,\n\t\t\t\t\t\t\t{ issueId: issue.id, planRevision: c.planRevision },\n\t\t\t\t\t\t\t`${issue.id}:${c.mode}:${c.planRevision ?? \"\"}`,\n\t\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait report.observe(armed, { refreshError: \"Jira issue unavailable; policy unchanged\" });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest: { id: \"jira\", version: \"0.3.0\" },\n\tscopedSettings: {\n\t\tscopes: [\n\t\t\t{ id: \"jira.project\", label: \"Jira projects\" },\n\t\t\t{\n\t\t\t\tid: \"jira.component\",\n\t\t\t\tlabel: \"Jira components\",\n\t\t\t\toverview: {\n\t\t\t\t\titemLabel: \"Component\",\n\t\t\t\t\titemLabelPlural: \"Components\",\n\t\t\t\t\tparentLabel: \"Project\",\n\t\t\t\t\tlabelSeparator: \" / \",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tsettings: [],\n\t},\n\tsetupServer(api, config) {\n\t\tconst profiles = parseJiraProfiles(config);\n\t\tconst clients = new Map([...profiles].map(([id, profile]) => [id, new JiraClient(profile)]));\n\t\tsetupJiraIntegration(\n\t\t\tapi,\n\t\t\t{\n\t\t\t\tprofiles: () => [...clients.keys()],\n\t\t\t\tclient: (profile) => {\n\t\t\t\t\tconst client = clients.get(profile);\n\t\t\t\t\tif (!client) throw new Error(`Jira profile '${profile}' is unavailable`);\n\t\t\t\t\treturn client;\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tticketCreation: parseTicketCreationConfig(config, \"Jira\"),\n\t\t\t\tprojects: new Map(\n\t\t\t\t\t[...profiles].map(([id, profile]) => [id, profile.project ? [profile.project] : []]),\n\t\t\t\t),\n\t\t\t},\n\t\t);\n\t},\n};\nexport default extension;\n","import { createHash } from \"node:crypto\";\nimport {\n\tlistTicketDestinations,\n\tobjectArg,\n\tparseTicketDestinationId,\n\ttype ServerExtensionAPI,\n\tstringArg,\n\ttype TicketCreationConfig,\n\ttype TicketCreationDestinationProvider,\n\ttype TicketCreationDestinationSnapshot,\n\tticketDestinationId,\n\tticketLabelNames,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { JiraCreateProject } from \"./client.js\";\nimport type { JiraIntegration } from \"./index.js\";\nimport { markdownToJira } from \"./markdown.js\";\n\nconst reservedFields = [\"project\", \"issuetype\", \"summary\", \"description\", \"labels\"];\n\nfunction destinationData(snapshot: TicketCreationDestinationSnapshot) {\n\tconst data = objectArg(snapshot.data);\n\treturn {\n\t\tprofile: stringArg(data, \"profile\"),\n\t\tbaseUrl: stringArg(data, \"baseUrl\"),\n\t\tprojectId: stringArg(data, \"projectId\"),\n\t\tprojectKey: stringArg(data, \"projectKey\"),\n\t\tissueTypeId: stringArg(data, \"issueTypeId\"),\n\t\tdefaultLabels: ticketLabelNames(data.defaultLabels),\n\t};\n}\n\nfunction validateLabels(issueType: JiraCreateProject[\"issuetypes\"][number], labels: string[]) {\n\tif (labels.length && !Object.hasOwn(issueType.fields, \"labels\"))\n\t\tthrow new Error(\n\t\t\t\"The selected Jira issue type does not support labels on its create screen; omit labels and set ticket_creation.default_labels to []\",\n\t\t);\n}\n\n/** @internal */\nexport function registerJiraTicketCreation(\n\tapi: ServerExtensionAPI,\n\tintegration: JiraIntegration,\n\tconfig: TicketCreationConfig,\n): void {\n\tif (!config.enabled) return;\n\tconst summary = (\n\t\tprofile: string,\n\t\tproject: JiraCreateProject,\n\t\tissueType: JiraCreateProject[\"issuetypes\"][number],\n\t) => ({\n\t\tid: `${ticketDestinationId(profile, project.id)}.${issueType.id}`,\n\t\tdisplayName: `${project.key} · ${project.name} / ${issueType.name}`,\n\t\tgroup: `${profile} · ${new URL(integration.client(profile).baseUrl).host}`,\n\t\tdescription: `Issue type: ${issueType.name}. Default labels: ${config.defaultLabels.join(\", \") || \"none\"}. Additional fields: ${JSON.stringify(Object.fromEntries(Object.entries(issueType.fields).filter(([key]) => !reservedFields.includes(key))))}`,\n\t});\n\tconst currentDestination = async (\n\t\tdata: Omit<ReturnType<typeof destinationData>, \"projectKey\"> & { projectKey?: string },\n\t\tsignal?: AbortSignal,\n\t) => {\n\t\tconst client = integration.client(data.profile);\n\t\tif (client.baseUrl !== data.baseUrl) throw new Error(\"Jira profile installation changed\");\n\t\tconst project = (await client.listCreateProjects(data.projectId, signal)).find(\n\t\t\t(project) => project.id === data.projectId,\n\t\t);\n\t\tconst issueType = project?.issuetypes.find(\n\t\t\t(type) => type.id === data.issueTypeId && !type.subtask,\n\t\t);\n\t\tif (\n\t\t\t!project ||\n\t\t\t(data.projectKey !== undefined && project.key !== data.projectKey) ||\n\t\t\t!issueType\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"The selected Jira project or issue type is no longer available for creation\",\n\t\t\t);\n\t\tvalidateLabels(issueType, data.defaultLabels);\n\t\treturn { client, project, issueType };\n\t};\n\tconst destinations: TicketCreationDestinationProvider = {\n\t\tlist() {\n\t\t\treturn listTicketDestinations(\"Jira\", integration.profiles(), async (profile) =>\n\t\t\t\t(await integration.client(profile).listCreateProjects()).flatMap((project) =>\n\t\t\t\t\tproject.issuetypes\n\t\t\t\t\t\t.filter((type) => !type.subtask)\n\t\t\t\t\t\t.map((type) => summary(profile, project, type)),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t\tasync resolve({ destinationId }) {\n\t\t\tconst separator = destinationId.lastIndexOf(\".\");\n\t\t\tconst { profile, resourceId: projectId } = parseTicketDestinationId(\n\t\t\t\tdestinationId.slice(0, separator),\n\t\t\t);\n\t\t\tconst issueTypeId = destinationId.slice(separator + 1);\n\t\t\tif (!/^[1-9]\\d*$/.test(issueTypeId)) throw new Error(\"Unknown Jira issue type\");\n\t\t\tconst client = integration.client(profile);\n\t\t\tconst data = {\n\t\t\t\tprofile,\n\t\t\t\tbaseUrl: client.baseUrl,\n\t\t\t\tprojectId,\n\t\t\t\tissueTypeId,\n\t\t\t\tdefaultLabels: config.defaultLabels,\n\t\t\t};\n\t\t\tconst { project, issueType } = await currentDestination(data);\n\t\t\tconst destination = summary(profile, project, issueType);\n\t\t\treturn {\n\t\t\t\tsummary: {\n\t\t\t\t\t...destination,\n\t\t\t\t\tdescription: `Default labels: ${config.defaultLabels.join(\", \") || \"none\"}`,\n\t\t\t\t},\n\t\t\t\tdata: { ...data, projectKey: project.key },\n\t\t\t\tagentContext: destination.description,\n\t\t\t};\n\t\t},\n\t\tasync validate(snapshot) {\n\t\t\tawait currentDestination(destinationData(snapshot));\n\t\t},\n\t};\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"jira_create_issue\",\n\t\tdescription:\n\t\t\t\"Create one Jira issue with the selected project's issue type. Write the description in Markdown; the publisher converts it to Jira wiki markup. Supply any required additional fields from its destination metadata; ask the operator when a value is unknown.\",\n\t\tparameters: {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tsummary: { type: \"string\", description: \"Concise issue title\" },\n\t\t\t\tdescription: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescription: \"Complete issue description in Markdown\",\n\t\t\t\t},\n\t\t\t\tlabels: { type: \"array\", items: { type: \"string\" } },\n\t\t\t\tfields: {\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Additional Jira create fields, keyed by metadata field ID, such as components or customfield_10001. Do not include project, issuetype, summary, description or labels.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\trequired: [\"summary\", \"description\"],\n\t\t},\n\t\tcapability: {\n\t\t\tkind: \"ticket_creation\",\n\t\t\tdisplayName: \"Jira\",\n\t\t\tprocessId: \"ticket_creation_process\",\n\t\t\tstartTurnId: \"create_ticket\",\n\t\t\ttitlePath: \"/summary\",\n\t\t\tdescriptionPath: \"/description\",\n\t\t\tdescriptionFormat: \"markdown\",\n\t\t\tdestinations,\n\t\t},\n\t\tasync execute(ctx, args) {\n\t\t\tif (!ctx.ticketDestination) throw new Error(\"A Jira ticket destination is required\");\n\t\t\tctx.signal.throwIfAborted();\n\t\t\tconst target = destinationData(ctx.ticketDestination);\n\t\t\tconst { client, issueType } = await currentDestination(target, ctx.signal);\n\t\t\tctx.signal.throwIfAborted();\n\t\t\tconst summary = stringArg(args, \"summary\");\n\t\t\tconst description = stringArg(args, \"description\");\n\t\t\tconst labels = [...new Set([...target.defaultLabels, ...ticketLabelNames(args.labels)])];\n\t\t\tvalidateLabels(issueType, labels);\n\t\t\tif (labels.some((label) => /\\s/.test(label)))\n\t\t\t\tthrow new Error(\"Jira labels cannot contain spaces\");\n\t\t\tconst fields = args.fields === undefined ? {} : objectArg(args.fields);\n\t\t\tfor (const key of Object.keys(fields)) {\n\t\t\t\tif (reservedFields.includes(key) || !Object.hasOwn(issueType.fields, key))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Jira field '${key}' is not an additional create field for this issue type`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const [key, field] of Object.entries(issueType.fields)) {\n\t\t\t\tif (\n\t\t\t\t\tfield.required &&\n\t\t\t\t\t!field.hasDefaultValue &&\n\t\t\t\t\t!reservedFields.includes(key) &&\n\t\t\t\t\t(fields[key] == null ||\n\t\t\t\t\t\tfields[key] === \"\" ||\n\t\t\t\t\t\t(Array.isArray(fields[key]) && fields[key].length === 0))\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Jira requires ${field.name} (${key}); request this value before creating the issue`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t\tconst digest = createHash(\"sha256\").update(ctx.idempotencyKey).digest(\"hex\");\n\t\t\tconst marker = `leitwerk-ticket-write:${digest}`;\n\t\t\tconst issue = await ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"jira.create_issue\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t{\n\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t(await client.listProjectIssues(target.projectId, ctx.signal)).find((issue) =>\n\t\t\t\t\t\t\tissue.fields.description?.includes(marker),\n\t\t\t\t\t\t) ?? null,\n\t\t\t\t\texecute: () => {\n\t\t\t\t\t\tctx.signal.throwIfAborted();\n\t\t\t\t\t\treturn client.createIssue(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\tproject: { id: target.projectId },\n\t\t\t\t\t\t\t\tissuetype: { id: target.issueTypeId },\n\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\tdescription: `${markdownToJira(description)}\\n\\n{noformat}${marker}{noformat}`,\n\t\t\t\t\t\t\t\t...(labels.length ? { labels } : {}),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\ttoMetadata: (issue) => ({\n\t\t\t\t\t\tid: issue.id,\n\t\t\t\t\t\tkey: issue.key,\n\t\t\t\t\t\turl: `${target.baseUrl}/browse/${encodeURIComponent(issue.key)}`,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\texternalId: issue.key,\n\t\t\t\turl: `${target.baseUrl}/browse/${encodeURIComponent(issue.key)}`,\n\t\t\t\tresult: issue,\n\t\t\t};\n\t\t},\n\t});\n}\n","import { SafeOutcomePlanningError } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport const jiraTicketWritingInstructions =\n\t\"Write summary and description as a normal standalone Jira task for its assignee, using Markdown for the description. Explain the work and acceptance criteria in plain language; retain concrete file paths, prerequisites, and validation steps when needed. Keep evidence, inspected revisions, repository keys, and other tracking data in the separate evidence fields. Do not put raw commit hashes, internal IDs, split identities, solution-wiki references, or model citation tokens in the summary or description. Refer to repositories by their readable names and Jira issues by their issue keys. The publisher adds repository and source-issue links. When revising an existing ticket, preserve useful task details and human notes, and omit any previous generated tracking footer.\";\n\n// These are references produced by the tools and publisher, not task requirements.\nconst internalReference =\n\t/\\bleitwerk-split-[\\w-]+\\b|\\brepo_\\d+\\b|\\bagt_[a-z0-9]+\\b|\\b[a-f0-9]{40,64}\\b|\\bturn\\d+(?:file|search|view|fetch)\\d+\\b|[\\uE200-\\uE202]|【[^】]*(?:†|turn\\d+|repo_\\d+)[^】]*】|Leitwerk split identity\\s*:|(?:Source issue )?solution wiki\\s*:/i;\n\n/** @internal */\nexport function jiraTicketTextProblem(summary: string, description: string): string | null {\n\treturn internalReference.test(`${summary}\\n${description}`)\n\t\t? \"Revise the ticket summary and description to remove internal references; keep evidence and tracking IDs in the separate evidence fields, then review the revised ticket.\"\n\t\t: null;\n}\n\n/** @internal */\nexport function assertJiraTicketText(summary: string, description: string): void {\n\tconst problem = jiraTicketTextProblem(summary, description);\n\tif (problem) throw new SafeOutcomePlanningError(\"jira_ticket_internal_reference\", problem);\n}\n\n/** @internal */\nexport function ticketDescriptionMarkdown(\n\tdescription: string,\n\tlinks: {\n\t\t/** @internal */\n\t\trepositoryName: string;\n\t\t/** @internal */\n\t\trepositoryUrl: string;\n\t\t/** @internal */\n\t\tsourceKey: string;\n\t\t/** @internal */\n\t\tsourceUrl: string;\n\t},\n): string {\n\tconst label = (value: string) => value.replace(/[\\\\[\\]]/g, \"\\\\$&\");\n\treturn `${description.trim()}\\n\\nRepository: [${label(links.repositoryName)}](${links.repositoryUrl})\\n\\nSource issue: [${label(links.sourceKey)}](${links.sourceUrl})`;\n}\n","import { createHash } from \"node:crypto\";\nimport type { TopicWikiStore } from \"@leitwerk-dev/wiki\";\nimport type { WikiSourceResolver } from \"@leitwerk-dev/wiki/integration\";\nimport { type JiraClientLike, type JiraIssue, jiraIsEpic } from \"./client.js\";\nimport type { JiraIntegration } from \"./index.js\";\n\n/** @internal */\nexport function jiraEpicRevision(epic: JiraIssue): string {\n\treturn createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify([\n\t\t\t\tepic.id,\n\t\t\t\tepic.fields.project.id,\n\t\t\t\tepic.fields.summary,\n\t\t\t\tepic.fields.description,\n\t\t\t\tepic.fields.components,\n\t\t\t\tepic.fields.status,\n\t\t\t]),\n\t\t)\n\t\t.digest(\"hex\");\n}\n\n/** @internal */\nexport function ensureIssueWiki(\n\tstore: TopicWikiStore,\n\tclient: JiraClientLike,\n\tissue: JiraIssue,\n\tretainedTopicId?: string,\n) {\n\tlet key = JSON.stringify([\n\t\tjiraIsEpic(issue) ? \"jira.epic\" : \"jira.issue\",\n\t\tclient.baseUrl,\n\t\tissue.id,\n\t]);\n\tif (retainedTopicId !== undefined) {\n\t\t// Only callers with a durable publication receipt or process binding may supply an ID.\n\t\t// Older publishers used their own namespace for the same installation / issue identity.\n\t\tconst topic = store.getTopic(retainedTopicId);\n\t\tlet identity: unknown;\n\t\ttry {\n\t\t\tidentity = topic && JSON.parse(topic.key);\n\t\t} catch {\n\t\t\tidentity = null;\n\t\t}\n\t\tif (\n\t\t\t!topic ||\n\t\t\t!Array.isArray(identity) ||\n\t\t\tidentity.length !== 3 ||\n\t\t\ttypeof identity[0] !== \"string\" ||\n\t\t\t!identity[0] ||\n\t\t\tidentity[1] !== client.baseUrl ||\n\t\t\tidentity[2] !== issue.id\n\t\t)\n\t\t\tthrow new Error(\"Source issue wiki binding mismatch\");\n\t\tkey = topic.key;\n\t}\n\treturn store.ensureTopic({\n\t\tkey,\n\t\ttitle: `${issue.key}: ${issue.fields.summary}`,\n\t\turl: `${client.baseUrl}/browse/${encodeURIComponent(issue.key)}`,\n\t\tsourceRevision: jiraEpicRevision(issue),\n\t});\n}\n\n/** Refreshes retained current and legacy issue bindings; credentials stay in the integration. @internal */\nexport function jiraWikiSource(\n\tstore: TopicWikiStore,\n\tintegration: JiraIntegration,\n): WikiSourceResolver {\n\treturn async (_ctx, binding) => {\n\t\tconst issueId = binding.issueId ?? binding.epicId;\n\t\tif (\n\t\t\ttypeof binding.topicId !== \"string\" ||\n\t\t\ttypeof binding.profile !== \"string\" ||\n\t\t\ttypeof issueId !== \"string\"\n\t\t)\n\t\t\tthrow new Error(\"This process has no source issue wiki binding\");\n\t\tconst client = integration.client(binding.profile);\n\t\tif (client.baseUrl !== binding.baseUrl) throw new Error(\"Jira wiki installation changed\");\n\t\tconst issue = await client.getIssue(issueId);\n\t\tif (issue.id !== issueId) throw new Error(\"Source issue wiki binding mismatch\");\n\t\treturn {\n\t\t\ttopic: ensureIssueWiki(store, client, issue, binding.topicId),\n\t\t\tsourceDescription: issue.fields.description ?? \"\",\n\t\t};\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAEA;AAAA,OAEM;AACP,SAAS,oBAAoB,iBAAiB,uBAAuB;;;ACdrE,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAIA;AAAA,EACA;AAAA,OACM;AAKP,IAAM,iBAAiB,CAAC,WAAW,aAAa,WAAW,eAAe,QAAQ;AAElF,SAAS,gBAAgB,UAA6C;AACrE,QAAM,OAAO,UAAU,SAAS,IAAI;AACpC,SAAO;AAAA,IACN,SAAS,UAAU,MAAM,SAAS;AAAA,IAClC,SAAS,UAAU,MAAM,SAAS;AAAA,IAClC,WAAW,UAAU,MAAM,WAAW;AAAA,IACtC,YAAY,UAAU,MAAM,YAAY;AAAA,IACxC,aAAa,UAAU,MAAM,aAAa;AAAA,IAC1C,eAAe,iBAAiB,KAAK,aAAa;AAAA,EACnD;AACD;AAEA,SAAS,eAAe,WAAoD,QAAkB;AAC7F,MAAI,OAAO,UAAU,CAAC,OAAO,OAAO,UAAU,QAAQ,QAAQ;AAC7D,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AACF;AAGO,SAAS,2BACf,KACA,aACA,QACO;AACP,MAAI,CAAC,OAAO,QAAS;AACrB,QAAM,UAAU,CACf,SACA,SACA,eACK;AAAA,IACL,IAAI,GAAG,oBAAoB,SAAS,QAAQ,EAAE,CAAC,IAAI,UAAU,EAAE;AAAA,IAC/D,aAAa,GAAG,QAAQ,GAAG,SAAM,QAAQ,IAAI,MAAM,UAAU,IAA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AAgB,OAAO,gBAAgB;AAAA,MAC7C;AAAA,QACC,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,UAAU;AAAA,UACT,WAAW;AAAA,UACX,iBAAiB;AAAA,UACjB,aAAa;AAAA,UACb,gBAAgB;AAAA,QACjB;AAAA,MACD;AAAA,IACD;AAAA,IACA,UAAU,CAAC;AAAA,EACZ;AAAA,EACA,YAAY,KAAK,QAAQ;AACxB,UAAM,WAAW,kBAAkB,MAAM;AACzC,UAAM,UAAU,IAAI,IAAI,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,OAAO,MAAM,CAAC,IAAI,IAAI,WAAW,OAAO,CAAC,CAAC,CAAC;AAC3F;AAAA,MACC;AAAA,MACA;AAAA,QACC,UAAU,MAAM,CAAC,GAAG,QAAQ,KAAK,CAAC;AAAA,QAClC,QAAQ,CAAC,YAAY;AACpB,gBAAM,SAAS,QAAQ,IAAI,OAAO;AAClC,cAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,iBAAiB,OAAO,kBAAkB;AACvE,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,MACA;AAAA,QACC,gBAAgB,0BAA0B,QAAQ,MAAM;AAAA,QACxD,UAAU,IAAI;AAAA,UACb,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,OAAO,MAAM,CAAC,IAAI,QAAQ,UAAU,CAAC,QAAQ,OAAO,IAAI,CAAC,CAAC,CAAC;AAAA,QACpF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AACA,IAAO,gBAAQ;","names":["project","summary","issue","createHash","createHash"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/ticket-creation.ts","../src/ticket-text.ts","../src/wiki.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\tcoreHostCapabilities,\n\tcreateCapabilityToken,\n\tcreateExternalSourcePollReporter,\n\tdefineProcessWatcherSource,\n\ttype ExternalActionSource,\n\ttype LeitwerkExtensionModule,\n\tparseProcessWatcherLaunchModelConfig,\n\tparseTicketCreationConfig,\n\ttype ServerExtensionAPI,\n\tscopedSettingsCapability,\n\ttype TicketCreationConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult, parseDurationMs } from \"@leitwerk-dev/watcher-utils\";\nimport {\n\tJiraClient,\n\ttype JiraClientLike,\n\ttype JiraIssue,\n\tjiraEligible,\n\tjiraIssueExternalId,\n\tjiraTriggerLabel,\n\tparseJiraProfiles,\n} from \"./client.js\";\nimport { registerJiraTicketCreation } from \"./ticket-creation.js\";\nimport { registerJiraTools } from \"./tools.js\";\n\nexport * from \"./client.js\";\nexport { jiraToMarkdown, markdownToJira } from \"./markdown.js\";\nexport {\n\tassertJiraTicketText,\n\tjiraTicketTextProblem,\n\tjiraTicketWritingInstructions,\n\tticketDescriptionMarkdown,\n} from \"./ticket-text.js\";\nexport { ensureIssueWiki, jiraEpicRevision, jiraWikiSource } from \"./wiki.js\";\n\n/** @public */\nexport interface JiraIntegration {\n\t/** @internal */\n\tprofiles(): readonly string[];\n\n\t/** @internal */\n\tclient(profile: string): JiraClientLike;\n}\n\n/** @public */\nexport const jiraIntegration = createCapabilityToken<JiraIntegration>(\n\t\"@leitwerk-dev/jira.integration\",\n);\n\n/** Configured project discovery shared by Jira-backed Settings and launchers. @public */\nexport const jiraProjectDiscovery = createCapabilityToken<{\n\t/** @public */ projects(profile: string): Promise<readonly import(\"./client.js\").JiraProject[]>;\n\t/** @public */ includesProject(\n\t\tsubject: import(\"@leitwerk-dev/domain\").SettingsSubject | undefined,\n\t): boolean;\n}>(\"@leitwerk-dev/jira.project-discovery\");\n\n/** @public */\nexport const jiraSubjectIdentity = (baseUrl: string, id: string) => JSON.stringify([baseUrl, id]);\n\n/** @public */\nexport interface JiraWatcherConfig {\n\t/** @internal */\n\tlabel?: string;\n\t/** @internal */\n\tprofile: string;\n\n\t/** @internal */\n\tprojects: string[];\n\n\t/** @internal */\n\tpollInterval: string;\n}\n\n/** @public */\nexport interface JiraWatcherEvent {\n\t/** @internal */\n\ttriggerLabel?: string;\n\t/** @internal */\n\tprofile: string;\n\n\t/** @internal */\n\tissue: JiraIssue;\n\n\t/** @internal */\n\tprojects: string[];\n}\n\n/** @public */\nexport const jiraIssueWatcherSource = defineProcessWatcherSource<\n\tJiraWatcherConfig,\n\tJiraWatcherEvent\n>({\n\tid: \"@leitwerk-dev/jira.issue\",\n\tlabel: \"Jira issue\",\n\tparseConfig(raw) {\n\t\tconst c = asUnknownRecord(raw);\n\t\tif (\n\t\t\ttypeof c?.enabled !== \"boolean\" ||\n\t\t\ttypeof c.profile !== \"string\" ||\n\t\t\t!c.profile.trim() ||\n\t\t\t!Array.isArray(c.projects) ||\n\t\t\t!c.projects.length ||\n\t\t\tc.projects.some((id) => typeof id !== \"string\" || !/^\\d+$/.test(id))\n\t\t)\n\t\t\tthrow new Error(\"Jira watcher requires enabled, profile, and explicit project IDs\");\n\t\tconst pollInterval = c.poll_interval ?? \"30s\";\n\t\tif (typeof pollInterval !== \"string\" || parseDurationMs(pollInterval, -1) <= 0)\n\t\t\tthrow new Error(\"Invalid Jira poll_interval\");\n\t\treturn {\n\t\t\tenabled: c.enabled,\n\t\t\tconfig: {\n\t\t\t\tprofile: c.profile,\n\t\t\t\tprojects: c.projects as string[],\n\t\t\t\tpollInterval,\n\t\t\t\tlabel: jiraTriggerLabel(c.label),\n\t\t\t},\n\t\t\tlaunchModelConfig: parseProcessWatcherLaunchModelConfig(c.launch),\n\t\t};\n\t},\n\tpresentConfig: (c) => ({\n\t\ttargetSummary: `Jira ${c.profile} · ${c.projects.join(\", \")}`,\n\t\tdetails: [{ label: \"Trigger\", value: jiraTriggerLabel(c.label) }],\n\t}),\n});\n\n/** @public */\nexport interface JiraSourceConfig {\n\t/** @internal */\n\ttriggerLabel?: string;\n\t/** @internal */\n\tprofile: string;\n\t/** @internal */\n\tbaseUrl: string;\n\n\t/** @internal */\n\tissueId: string;\n\n\t/** @internal */\n\tplanRevision?: number;\n\n\t/** @internal */\n\tmode: \"plan_bypass\" | \"cancelled\";\n}\nconst ISSUE_POLICY = \"@leitwerk-dev/jira.issue-policy\";\n\n/** @public */\nexport function jiraIssuePolicy<P, S>(\n\tresolve: (ctx: {\n\t\t/** @internal */\n\t\tparams: P;\n\t\t/** @internal */\n\t\tstate: S;\n\t}) => JiraSourceConfig,\n): ExternalActionSource<P, S, unknown> {\n\treturn {\n\t\tkind: ISSUE_POLICY,\n\t\tlabel: \"Jira source policy\",\n\t\tconfig: {},\n\t\tinputMode: \"none\",\n\t\tresolve,\n\t};\n}\n\n/** @public */\nexport function setupJiraIntegration(\n\tapi: ServerExtensionAPI,\n\tintegration: JiraIntegration,\n\toptions: {\n\t\t/** @public */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tticketCreation?: TicketCreationConfig;\n\t\t/** Project IDs or keys explicitly selected by integration profiles. @internal */\n\t\tprojects?: ReadonlyMap<string, readonly string[]>;\n\t} = {},\n) {\n\tconst now = options.now ?? Date.now;\n\tapi.provide(jiraIntegration, integration);\n\tregisterJiraTools(api, integration);\n\tregisterJiraTicketCreation(\n\t\tapi,\n\t\tintegration,\n\t\toptions.ticketCreation ?? { enabled: false, defaultLabels: [] },\n\t);\n\tconst settings = api.get(scopedSettingsCapability);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tconst configuredProjects = (profile: string) =>\n\t\tnew Set([\n\t\t\t...(options.projects?.get(profile) ?? []),\n\t\t\t...(!deps || Array.isArray(deps)\n\t\t\t\t? []\n\t\t\t\t: (deps.processWatchers?.listBySource(jiraIssueWatcherSource) ?? [])\n\t\t\t\t\t\t.filter((watcher) => watcher.config.profile === profile)\n\t\t\t\t\t\t.flatMap((watcher) => watcher.config.projects)),\n\t\t]);\n\tconst projectsFor = async (profile: string) => {\n\t\tconst selected = configuredProjects(profile);\n\t\tif (!selected.size) return [];\n\t\tconst client = integration.client(profile);\n\t\tconst projects = (await client.listProjects()).filter(\n\t\t\t(project) => selected.has(project.id) || selected.has(project.key),\n\t\t);\n\t\treturn projects;\n\t};\n\tconst includesProject = (subject: import(\"@leitwerk-dev/domain\").SettingsSubject | undefined) => {\n\t\tif (!subject) return false;\n\t\tlet identity: unknown;\n\t\ttry {\n\t\t\tidentity = JSON.parse(subject.identity);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t\tif (!Array.isArray(identity) || identity.length !== 2) return false;\n\t\tconst [origin, id] = identity;\n\t\treturn integration.profiles().some((profile) => {\n\t\t\tif (integration.client(profile).baseUrl !== origin) return false;\n\t\t\tconst configured = configuredProjects(profile);\n\t\t\treturn configured.has(id) || configured.has(subject.label.split(\" · \")[0]);\n\t\t});\n\t};\n\tapi.provide(jiraProjectDiscovery, { projects: projectsFor, includesProject });\n\tif (settings && !Array.isArray(settings)) {\n\t\tsettings.registerDiscovery(\n\t\t\t\"jira.project\",\n\t\t\tasync () => {\n\t\t\t\tconst subjects = [];\n\t\t\t\tfor (const profile of integration.profiles()) {\n\t\t\t\t\tconst client = integration.client(profile);\n\t\t\t\t\tfor (const project of await projectsFor(profile))\n\t\t\t\t\t\tsubjects.push({\n\t\t\t\t\t\t\tscopeType: \"jira.project\",\n\t\t\t\t\t\t\tidentity: jiraSubjectIdentity(client.baseUrl, project.id),\n\t\t\t\t\t\t\tlabel: `${project.key} · ${project.name}`,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn subjects;\n\t\t\t},\n\t\t\t{ includesSubject: (subject) => includesProject(subject) },\n\t\t);\n\t\tsettings.registerDiscovery(\n\t\t\t\"jira.component\",\n\t\t\tasync () => {\n\t\t\t\tconst subjects = [];\n\t\t\t\tfor (const profile of integration.profiles()) {\n\t\t\t\t\tconst client = integration.client(profile);\n\t\t\t\t\tfor (const project of await projectsFor(profile)) {\n\t\t\t\t\t\tconst parent = settings.discover({\n\t\t\t\t\t\t\tscopeType: \"jira.project\",\n\t\t\t\t\t\t\tidentity: jiraSubjectIdentity(client.baseUrl, project.id),\n\t\t\t\t\t\t\tlabel: `${project.key} · ${project.name}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfor (const component of await client.listComponents(project.id))\n\t\t\t\t\t\t\tsubjects.push({\n\t\t\t\t\t\t\t\tscopeType: \"jira.component\",\n\t\t\t\t\t\t\t\tidentity: jiraSubjectIdentity(client.baseUrl, component.id),\n\t\t\t\t\t\t\t\tlabel: `${project.key} / ${component.name}`,\n\t\t\t\t\t\t\t\tcontext: { \"jira.project\": parent.id },\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn subjects;\n\t\t\t},\n\t\t\t{ includesSubject: (_subject, context) => includesProject(context[\"jira.project\"]) },\n\t\t);\n\t}\n\tif (!deps || Array.isArray(deps)) return;\n\tconst shouldPoll = createPollSchedule(now);\n\treturn deps.polling.create({\n\t\tid: \"jira\",\n\t\tpollInterval: () => \"5s\",\n\t\tdefaultIntervalMs: 5000,\n\t\tisEnabled: () => true,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tfor (const watcher of deps.processWatchers?.listBySource(jiraIssueWatcherSource) ?? []) {\n\t\t\t\tconst key = `${watcher.processId}:${watcher.watcherId}`;\n\t\t\t\tif (!watcher.enabled || !shouldPoll(key, watcher.config.pollInterval)) continue;\n\t\t\t\ttry {\n\t\t\t\t\tconst client = integration.client(watcher.config.profile);\n\t\t\t\t\tfor (const issue of await client.searchIssues(\n\t\t\t\t\t\twatcher.config.projects,\n\t\t\t\t\t\twatcher.config.label,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!jiraEligible(issue, watcher.config.label) ||\n\t\t\t\t\t\t\t!watcher.config.projects.includes(issue.fields.project.id)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tconst id = jiraIssueExternalId(client.baseUrl, issue.id);\n\t\t\t\t\t\tconst launch = await deps.launchRuns.startWatcher(\n\t\t\t\t\t\t\twatcher,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tprofile: watcher.config.profile,\n\t\t\t\t\t\t\t\tissue,\n\t\t\t\t\t\t\t\tprojects: watcher.config.projects,\n\t\t\t\t\t\t\t\ttriggerLabel: jiraTriggerLabel(watcher.config.label),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ idempotencyKey: id },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (launch.error)\n\t\t\t\t\t\t\tresult.errors.push(\n\t\t\t\t\t\t\t\t`${issue.key}: admission failed; inspect launch diagnostics and component mappings`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\telse if (launch.process) result.created.push(id);\n\t\t\t\t\t\telse result.skipped.push(id);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresult.errors.push(error instanceof Error ? error.message : \"Jira discovery unavailable\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst report = createExternalSourcePollReporter(deps.externalSources, result, {\n\t\t\t\tforwardGeneration: true,\n\t\t\t\tcurrentKinds: [ISSUE_POLICY],\n\t\t\t});\n\t\t\tawait report.poll(ISSUE_POLICY, async (armed) => {\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation}`;\n\t\t\t\tif (!shouldPoll(key)) return;\n\t\t\t\tconst c = armed.resolved as unknown as JiraSourceConfig;\n\t\t\t\ttry {\n\t\t\t\t\tconst client = integration.client(c.profile);\n\t\t\t\t\tif (client.baseUrl !== c.baseUrl) throw new Error(\"Jira profile installation changed\");\n\t\t\t\t\tconst issue = await client.getIssue(c.issueId);\n\t\t\t\t\tif (issue.id !== c.issueId) throw new Error(\"Uncorrelated Jira issue evidence\");\n\t\t\t\t\tconst fire =\n\t\t\t\t\t\tc.mode === \"plan_bypass\"\n\t\t\t\t\t\t\t? jiraEligible(issue, c.triggerLabel) &&\n\t\t\t\t\t\t\t\tissue.fields.labels.includes(\"leitwerk-skip-plan-decision\")\n\t\t\t\t\t\t\t: !jiraEligible(issue, c.triggerLabel);\n\t\t\t\t\tif (fire)\n\t\t\t\t\t\tawait report.fire(\n\t\t\t\t\t\t\tarmed,\n\t\t\t\t\t\t\t{ issueId: issue.id, planRevision: c.planRevision },\n\t\t\t\t\t\t\t`${issue.id}:${c.mode}:${c.planRevision ?? \"\"}`,\n\t\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait report.observe(armed, { refreshError: \"Jira issue unavailable; policy unchanged\" });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest: { id: \"jira\", version: \"0.3.0\" },\n\tscopedSettings: {\n\t\tscopes: [\n\t\t\t{ id: \"jira.project\", label: \"Jira projects\" },\n\t\t\t{\n\t\t\t\tid: \"jira.component\",\n\t\t\t\tlabel: \"Jira components\",\n\t\t\t\toverview: {\n\t\t\t\t\titemLabel: \"Component\",\n\t\t\t\t\titemLabelPlural: \"Components\",\n\t\t\t\t\tparentLabel: \"Project\",\n\t\t\t\t\tlabelSeparator: \" / \",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tsettings: [],\n\t},\n\tsetupServer(api, config) {\n\t\tconst profiles = parseJiraProfiles(config);\n\t\tconst clients = new Map([...profiles].map(([id, profile]) => [id, new JiraClient(profile)]));\n\t\tsetupJiraIntegration(\n\t\t\tapi,\n\t\t\t{\n\t\t\t\tprofiles: () => [...clients.keys()],\n\t\t\t\tclient: (profile) => {\n\t\t\t\t\tconst client = clients.get(profile);\n\t\t\t\t\tif (!client) throw new Error(`Jira profile '${profile}' is unavailable`);\n\t\t\t\t\treturn client;\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tticketCreation: parseTicketCreationConfig(config, \"Jira\"),\n\t\t\t\tprojects: new Map(\n\t\t\t\t\t[...profiles].map(([id, profile]) => [id, profile.project ? [profile.project] : []]),\n\t\t\t\t),\n\t\t\t},\n\t\t);\n\t},\n};\nexport default extension;\n","import { createHash } from \"node:crypto\";\nimport {\n\tlistTicketDestinations,\n\tobjectArg,\n\tparseTicketDestinationId,\n\ttype ServerExtensionAPI,\n\tstringArg,\n\ttype TicketCreationConfig,\n\ttype TicketCreationDestinationProvider,\n\ttype TicketCreationDestinationSnapshot,\n\tticketDestinationId,\n\tticketLabelNames,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { JiraCreateProject } from \"./client.js\";\nimport type { JiraIntegration } from \"./index.js\";\nimport { markdownToJira } from \"./markdown.js\";\n\nconst reservedFields = [\"project\", \"issuetype\", \"summary\", \"description\", \"labels\"];\n\nfunction destinationData(snapshot: TicketCreationDestinationSnapshot) {\n\tconst data = objectArg(snapshot.data);\n\treturn {\n\t\tprofile: stringArg(data, \"profile\"),\n\t\tbaseUrl: stringArg(data, \"baseUrl\"),\n\t\tprojectId: stringArg(data, \"projectId\"),\n\t\tprojectKey: stringArg(data, \"projectKey\"),\n\t\tissueTypeId: stringArg(data, \"issueTypeId\"),\n\t\tdefaultLabels: ticketLabelNames(data.defaultLabels),\n\t};\n}\n\nfunction validateLabels(issueType: JiraCreateProject[\"issuetypes\"][number], labels: string[]) {\n\tif (labels.length && !Object.hasOwn(issueType.fields, \"labels\"))\n\t\tthrow new Error(\n\t\t\t\"The selected Jira issue type does not support labels on its create screen; omit labels and set ticket_creation.default_labels to []\",\n\t\t);\n}\n\n/** @internal */\nexport function registerJiraTicketCreation(\n\tapi: ServerExtensionAPI,\n\tintegration: JiraIntegration,\n\tconfig: TicketCreationConfig,\n): void {\n\tif (!config.enabled) return;\n\tconst summary = (\n\t\tprofile: string,\n\t\tproject: JiraCreateProject,\n\t\tissueType: JiraCreateProject[\"issuetypes\"][number],\n\t) => ({\n\t\tid: `${ticketDestinationId(profile, project.id)}.${issueType.id}`,\n\t\tdisplayName: `${project.key} · ${project.name} / ${issueType.name}`,\n\t\tgroup: `${profile} · ${new URL(integration.client(profile).baseUrl).host}`,\n\t\tdescription: `Issue type: ${issueType.name}. Default labels: ${config.defaultLabels.join(\", \") || \"none\"}. Additional fields: ${JSON.stringify(Object.fromEntries(Object.entries(issueType.fields).filter(([key]) => !reservedFields.includes(key))))}`,\n\t});\n\tconst currentDestination = async (\n\t\tdata: Omit<ReturnType<typeof destinationData>, \"projectKey\"> & { projectKey?: string },\n\t\tsignal?: AbortSignal,\n\t) => {\n\t\tconst client = integration.client(data.profile);\n\t\tif (client.baseUrl !== data.baseUrl) throw new Error(\"Jira profile installation changed\");\n\t\tconst project = (await client.listCreateProjects(data.projectId, signal)).find(\n\t\t\t(project) => project.id === data.projectId,\n\t\t);\n\t\tconst issueType = project?.issuetypes.find(\n\t\t\t(type) => type.id === data.issueTypeId && !type.subtask,\n\t\t);\n\t\tif (\n\t\t\t!project ||\n\t\t\t(data.projectKey !== undefined && project.key !== data.projectKey) ||\n\t\t\t!issueType\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"The selected Jira project or issue type is no longer available for creation\",\n\t\t\t);\n\t\tvalidateLabels(issueType, data.defaultLabels);\n\t\treturn { client, project, issueType };\n\t};\n\tconst destinations: TicketCreationDestinationProvider = {\n\t\tlist() {\n\t\t\treturn listTicketDestinations(\"Jira\", integration.profiles(), async (profile) =>\n\t\t\t\t(await integration.client(profile).listCreateProjects()).flatMap((project) =>\n\t\t\t\t\tproject.issuetypes\n\t\t\t\t\t\t.filter((type) => !type.subtask)\n\t\t\t\t\t\t.map((type) => summary(profile, project, type)),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t\tasync resolve({ destinationId }) {\n\t\t\tconst separator = destinationId.lastIndexOf(\".\");\n\t\t\tconst { profile, resourceId: projectId } = parseTicketDestinationId(\n\t\t\t\tdestinationId.slice(0, separator),\n\t\t\t);\n\t\t\tconst issueTypeId = destinationId.slice(separator + 1);\n\t\t\tif (!/^[1-9]\\d*$/.test(issueTypeId)) throw new Error(\"Unknown Jira issue type\");\n\t\t\tconst client = integration.client(profile);\n\t\t\tconst data = {\n\t\t\t\tprofile,\n\t\t\t\tbaseUrl: client.baseUrl,\n\t\t\t\tprojectId,\n\t\t\t\tissueTypeId,\n\t\t\t\tdefaultLabels: config.defaultLabels,\n\t\t\t};\n\t\t\tconst { project, issueType } = await currentDestination(data);\n\t\t\tconst destination = summary(profile, project, issueType);\n\t\t\treturn {\n\t\t\t\tsummary: {\n\t\t\t\t\t...destination,\n\t\t\t\t\tdescription: `Default labels: ${config.defaultLabels.join(\", \") || \"none\"}`,\n\t\t\t\t},\n\t\t\t\tdata: { ...data, projectKey: project.key },\n\t\t\t\tagentContext: destination.description,\n\t\t\t};\n\t\t},\n\t\tasync validate(snapshot) {\n\t\t\tawait currentDestination(destinationData(snapshot));\n\t\t},\n\t};\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"jira_create_issue\",\n\t\tdescription:\n\t\t\t\"Create one Jira issue with the selected project's issue type. Write the description in Markdown; the publisher converts it to Jira wiki markup. Supply any required additional fields from its destination metadata; ask the operator when a value is unknown.\",\n\t\tparameters: {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tsummary: { type: \"string\", description: \"Concise issue title\" },\n\t\t\t\tdescription: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescription: \"Complete issue description in Markdown\",\n\t\t\t\t},\n\t\t\t\tlabels: { type: \"array\", items: { type: \"string\" } },\n\t\t\t\tfields: {\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Additional Jira create fields, keyed by metadata field ID, such as components or customfield_10001. Do not include project, issuetype, summary, description or labels.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\trequired: [\"summary\", \"description\"],\n\t\t},\n\t\tcapability: {\n\t\t\tkind: \"ticket_creation\",\n\t\t\tdisplayName: \"Jira\",\n\t\t\tprocessId: \"ticket_creation_process\",\n\t\t\tstartTurnId: \"create_ticket\",\n\t\t\ttitlePath: \"/summary\",\n\t\t\tdescriptionPath: \"/description\",\n\t\t\tdescriptionFormat: \"markdown\",\n\t\t\tdestinations,\n\t\t},\n\t\tasync execute(ctx, args) {\n\t\t\tif (!ctx.ticketDestination) throw new Error(\"A Jira ticket destination is required\");\n\t\t\tctx.signal.throwIfAborted();\n\t\t\tconst target = destinationData(ctx.ticketDestination);\n\t\t\tconst { client, issueType } = await currentDestination(target, ctx.signal);\n\t\t\tctx.signal.throwIfAborted();\n\t\t\tconst summary = stringArg(args, \"summary\");\n\t\t\tconst description = stringArg(args, \"description\");\n\t\t\tconst labels = [...new Set([...target.defaultLabels, ...ticketLabelNames(args.labels)])];\n\t\t\tvalidateLabels(issueType, labels);\n\t\t\tif (labels.some((label) => /\\s/.test(label)))\n\t\t\t\tthrow new Error(\"Jira labels cannot contain spaces\");\n\t\t\tconst fields = args.fields === undefined ? {} : objectArg(args.fields);\n\t\t\tfor (const key of Object.keys(fields)) {\n\t\t\t\tif (reservedFields.includes(key) || !Object.hasOwn(issueType.fields, key))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Jira field '${key}' is not an additional create field for this issue type`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const [key, field] of Object.entries(issueType.fields)) {\n\t\t\t\tif (\n\t\t\t\t\tfield.required &&\n\t\t\t\t\t!field.hasDefaultValue &&\n\t\t\t\t\t!reservedFields.includes(key) &&\n\t\t\t\t\t(fields[key] == null ||\n\t\t\t\t\t\tfields[key] === \"\" ||\n\t\t\t\t\t\t(Array.isArray(fields[key]) && fields[key].length === 0))\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Jira requires ${field.name} (${key}); request this value before creating the issue`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t\tconst digest = createHash(\"sha256\").update(ctx.idempotencyKey).digest(\"hex\");\n\t\t\tconst marker = `leitwerk-ticket-write:${digest}`;\n\t\t\tconst issue = await ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"jira.create_issue\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t{\n\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t(await client.listProjectIssues(target.projectId, ctx.signal)).find((issue) =>\n\t\t\t\t\t\t\tissue.fields.description?.includes(marker),\n\t\t\t\t\t\t) ?? null,\n\t\t\t\t\texecute: () => {\n\t\t\t\t\t\tctx.signal.throwIfAborted();\n\t\t\t\t\t\treturn client.createIssue(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\tproject: { id: target.projectId },\n\t\t\t\t\t\t\t\tissuetype: { id: target.issueTypeId },\n\t\t\t\t\t\t\t\tsummary,\n\t\t\t\t\t\t\t\tdescription: `${markdownToJira(description)}\\n\\n{noformat}${marker}{noformat}`,\n\t\t\t\t\t\t\t\t...(labels.length ? { labels } : {}),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\ttoMetadata: (issue) => ({\n\t\t\t\t\t\tid: issue.id,\n\t\t\t\t\t\tkey: issue.key,\n\t\t\t\t\t\turl: `${target.baseUrl}/browse/${encodeURIComponent(issue.key)}`,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\texternalId: issue.key,\n\t\t\t\turl: `${target.baseUrl}/browse/${encodeURIComponent(issue.key)}`,\n\t\t\t\tresult: issue,\n\t\t\t};\n\t\t},\n\t});\n}\n","import { SafeOutcomePlanningError } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport const jiraTicketWritingInstructions =\n\t\"Use plain English following ASD-STE100. Use at most three headings and at most 120 words under each heading; code snippets do not count toward the word limit. Choose headings that fit the work and include only supported details. Link to internal data instead of copying it. Write summary and description as a normal standalone Jira task for its assignee, using Markdown for the description. Explain the work and acceptance criteria in plain language; retain concrete file paths, prerequisites, and validation steps when needed. Keep evidence, inspected revisions, repository keys, and other tracking data in the separate evidence fields. Do not put raw commit hashes, internal IDs, split identities, solution-wiki references, or model citation tokens in the summary or description. Refer to repositories by their readable names and Jira issues by their issue keys. The publisher adds repository and source-issue links. When revising an existing ticket, preserve useful task details and human notes, and omit any previous generated tracking footer.\";\n\n// These are references produced by the tools and publisher, not task requirements.\nconst internalReference =\n\t/\\bleitwerk-split-[\\w-]+\\b|\\brepo_\\d+\\b|\\bagt_[a-z0-9]+\\b|\\b[a-f0-9]{40,64}\\b|\\bturn\\d+(?:file|search|view|fetch)\\d+\\b|[\\uE200-\\uE202]|【[^】]*(?:†|turn\\d+|repo_\\d+)[^】]*】|Leitwerk split identity\\s*:|(?:Source issue )?solution wiki\\s*:/i;\n\n/** @internal */\nexport function jiraTicketTextProblem(summary: string, description: string): string | null {\n\treturn internalReference.test(`${summary}\\n${description}`)\n\t\t? \"Revise the ticket summary and description to remove internal references; keep evidence and tracking IDs in the separate evidence fields, then review the revised ticket.\"\n\t\t: null;\n}\n\n/** @internal */\nexport function assertJiraTicketText(summary: string, description: string): void {\n\tconst problem = jiraTicketTextProblem(summary, description);\n\tif (problem) throw new SafeOutcomePlanningError(\"jira_ticket_internal_reference\", problem);\n}\n\n/** @internal */\nexport function ticketDescriptionMarkdown(\n\tdescription: string,\n\tlinks: {\n\t\t/** @internal */\n\t\trepositoryName: string;\n\t\t/** @internal */\n\t\trepositoryUrl: string;\n\t\t/** @internal */\n\t\tsourceKey: string;\n\t\t/** @internal */\n\t\tsourceUrl: string;\n\t},\n): string {\n\tconst label = (value: string) => value.replace(/[\\\\[\\]]/g, \"\\\\$&\");\n\treturn `${description.trim()}\\n\\nRepository: [${label(links.repositoryName)}](${links.repositoryUrl})\\n\\nSource issue: [${label(links.sourceKey)}](${links.sourceUrl})`;\n}\n","import { createHash } from \"node:crypto\";\nimport type { TopicWikiStore } from \"@leitwerk-dev/wiki\";\nimport type { WikiSourceResolver } from \"@leitwerk-dev/wiki/integration\";\nimport { type JiraClientLike, type JiraIssue, jiraIsEpic } from \"./client.js\";\nimport type { JiraIntegration } from \"./index.js\";\n\n/** @internal */\nexport function jiraEpicRevision(epic: JiraIssue): string {\n\treturn createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify([\n\t\t\t\tepic.id,\n\t\t\t\tepic.fields.project.id,\n\t\t\t\tepic.fields.summary,\n\t\t\t\tepic.fields.description,\n\t\t\t\tepic.fields.components,\n\t\t\t\tepic.fields.status,\n\t\t\t]),\n\t\t)\n\t\t.digest(\"hex\");\n}\n\n/** @internal */\nexport function ensureIssueWiki(\n\tstore: TopicWikiStore,\n\tclient: JiraClientLike,\n\tissue: JiraIssue,\n\tretainedTopicId?: string,\n) {\n\tlet key = JSON.stringify([\n\t\tjiraIsEpic(issue) ? \"jira.epic\" : \"jira.issue\",\n\t\tclient.baseUrl,\n\t\tissue.id,\n\t]);\n\tif (retainedTopicId !== undefined) {\n\t\t// Only callers with a durable publication receipt or process binding may supply an ID.\n\t\t// Older publishers used their own namespace for the same installation / issue identity.\n\t\tconst topic = store.getTopic(retainedTopicId);\n\t\tlet identity: unknown;\n\t\ttry {\n\t\t\tidentity = topic && JSON.parse(topic.key);\n\t\t} catch {\n\t\t\tidentity = null;\n\t\t}\n\t\tif (\n\t\t\t!topic ||\n\t\t\t!Array.isArray(identity) ||\n\t\t\tidentity.length !== 3 ||\n\t\t\ttypeof identity[0] !== \"string\" ||\n\t\t\t!identity[0] ||\n\t\t\tidentity[1] !== client.baseUrl ||\n\t\t\tidentity[2] !== issue.id\n\t\t)\n\t\t\tthrow new Error(\"Source issue wiki binding mismatch\");\n\t\tkey = topic.key;\n\t}\n\treturn store.ensureTopic({\n\t\tkey,\n\t\ttitle: `${issue.key}: ${issue.fields.summary}`,\n\t\turl: `${client.baseUrl}/browse/${encodeURIComponent(issue.key)}`,\n\t\tsourceRevision: jiraEpicRevision(issue),\n\t});\n}\n\n/** Refreshes retained current and legacy issue bindings; credentials stay in the integration. @internal */\nexport function jiraWikiSource(\n\tstore: TopicWikiStore,\n\tintegration: JiraIntegration,\n): WikiSourceResolver {\n\treturn async (_ctx, binding) => {\n\t\tconst issueId = binding.issueId ?? binding.epicId;\n\t\tif (\n\t\t\ttypeof binding.topicId !== \"string\" ||\n\t\t\ttypeof binding.profile !== \"string\" ||\n\t\t\ttypeof issueId !== \"string\"\n\t\t)\n\t\t\tthrow new Error(\"This process has no source issue wiki binding\");\n\t\tconst client = integration.client(binding.profile);\n\t\tif (client.baseUrl !== binding.baseUrl) throw new Error(\"Jira wiki installation changed\");\n\t\tconst issue = await client.getIssue(issueId);\n\t\tif (issue.id !== issueId) throw new Error(\"Source issue wiki binding mismatch\");\n\t\treturn {\n\t\t\ttopic: ensureIssueWiki(store, client, issue, binding.topicId),\n\t\t\tsourceDescription: issue.fields.description ?? \"\",\n\t\t};\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAEA;AAAA,OAEM;AACP,SAAS,oBAAoB,iBAAiB,uBAAuB;;;ACdrE,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAIA;AAAA,EACA;AAAA,OACM;AAKP,IAAM,iBAAiB,CAAC,WAAW,aAAa,WAAW,eAAe,QAAQ;AAElF,SAAS,gBAAgB,UAA6C;AACrE,QAAM,OAAO,UAAU,SAAS,IAAI;AACpC,SAAO;AAAA,IACN,SAAS,UAAU,MAAM,SAAS;AAAA,IAClC,SAAS,UAAU,MAAM,SAAS;AAAA,IAClC,WAAW,UAAU,MAAM,WAAW;AAAA,IACtC,YAAY,UAAU,MAAM,YAAY;AAAA,IACxC,aAAa,UAAU,MAAM,aAAa;AAAA,IAC1C,eAAe,iBAAiB,KAAK,aAAa;AAAA,EACnD;AACD;AAEA,SAAS,eAAe,WAAoD,QAAkB;AAC7F,MAAI,OAAO,UAAU,CAAC,OAAO,OAAO,UAAU,QAAQ,QAAQ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,EACD;AACD;AACA,IAAO,gBAAQ;","names":["project","summary","issue","createHash","createHash"]}
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EAGnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EAGnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkC/C,gBAAgB;AAChB,qBAAa,qBAAsB,YAAW,cAAc;IAC3D,gBAAgB,CAAC,QAAQ,CAAC,OAAO,+BAA+B;IAChE,gBAAgB,CAAC,QAAQ,CAAC,MAAM,yBAAgC;IAChE,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,6BAAoC;IACtE,gBAAgB,CAAC,QAAQ,CAAC,WAAW,gCAAuC;IAC5E,gBAAgB,CAAC,WAAW,mBAAwC;IACpE,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAM;IACpE,gBAAgB,CAAC,sBAAsB,UAAS;IAChD,gBAAgB,CAAC,aA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f,gBAAgB,CAAU,IAAI,EAAE,MAAM;IACtC,gBAAgB,CAAU,OAAO,SAAsB;IAWxD,gBAAgB;IAChB,IAAI,IAAI,IAAI;IAGZ,gBAAgB;IAChB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAKtC,gBAAgB;IAChB,MAAM,IAAI,cAAc;CA0ExB;AAED,gBAAgB;AAChB,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,GAC5D,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,EACxD,IAAI,EAAE,MAAM,IAAI,GACd,IAAI,CACN,cAAc,EACZ,UAAU,GACV,cAAc,GACd,YAAY,GACZ,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,CACnB,CAwCA"}
|
package/dist/testing.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
jiraEligible,
|
|
3
3
|
jiraSplitEligible,
|
|
4
4
|
registerJiraTools
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VUXLYUPG.js";
|
|
6
6
|
|
|
7
7
|
// src/testing.ts
|
|
8
8
|
import { readLocalJson, writeLocalJson } from "@leitwerk-dev/test-support/local-git";
|
|
@@ -29,6 +29,11 @@ var workflowTransitions = [
|
|
|
29
29
|
id: "51",
|
|
30
30
|
name: "Verify change",
|
|
31
31
|
to: { id: "5", name: "In Verification", statusCategory: { key: "indeterminate" } }
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "50",
|
|
35
|
+
name: "Prepare verification",
|
|
36
|
+
to: { id: "6", name: "Ready for Verification", statusCategory: { key: "indeterminate" } }
|
|
32
37
|
}
|
|
33
38
|
];
|
|
34
39
|
var LocalJiraSplitAdapter = class {
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { readLocalJson, writeLocalJson } from \"@leitwerk-dev/test-support/local-git\";\nimport {\n\ttype JiraClientLike,\n\ttype JiraComment,\n\ttype JiraComponent,\n\ttype JiraCreateMetadata,\n\ttype JiraCreateProject,\n\ttype JiraIssue,\n\ttype JiraIssueReceipt,\n\ttype JiraProject,\n\ttype JiraRemoteLink,\n\ttype JiraTransition,\n\tjiraEligible,\n\tjiraSplitEligible,\n} from \"./client.js\";\n\nexport { registerJiraTools } from \"./tools.js\";\n\nfunction upsertRemoteLink(links: JiraRemoteLink[], input: Omit<JiraRemoteLink, \"id\">) {\n\tconst previous = links.find((link) => link.globalId === input.globalId);\n\tconst link = { ...structuredClone(input), id: previous?.id ?? links.length + 1 };\n\tif (previous) links[links.indexOf(previous)] = link;\n\telse links.push(link);\n\tconst result: Pick<JiraRemoteLink, \"id\"> = { id: link.id };\n\treturn result;\n}\n\nconst workflowTransitions: JiraTransition[] = [\n\t{\n\t\tid: \"31\",\n\t\tname: \"Start work\",\n\t\tto: { id: \"3\", name: \"In Progress\", statusCategory: { key: \"indeterminate\" } },\n\t},\n\t{\n\t\tid: \"41\",\n\t\tname: \"Request review\",\n\t\tto: { id: \"4\", name: \"In Review\", statusCategory: { key: \"indeterminate\" } },\n\t},\n\t{\n\t\tid: \"51\",\n\t\tname: \"Verify change\",\n\t\tto: { id: \"5\", name: \"In Verification\", statusCategory: { key: \"indeterminate\" } },\n\t},\n];\n\n/** @internal */\nexport class LocalJiraSplitAdapter implements JiraClientLike {\n\t/** @internal */ readonly baseUrl = \"https://jira.test/context\";\n\t/** @internal */ readonly issues = new Map<string, JiraIssue>();\n\t/** @internal */ readonly comments = new Map<string, JiraComment[]>();\n\t/** @internal */ readonly remoteLinks = new Map<string, JiraRemoteLink[]>();\n\t/** @internal */ transitions = structuredClone(workflowTransitions);\n\t/** @internal */ readonly creations: Record<string, unknown>[] = [];\n\t/** @internal */ loseNextCreateResponse = false;\n\t/** @internal */ searchVisible = true;\n\t/** @internal */ components: JiraComponent[] = [{ id: \"200\", name: \"Service\" }];\n\t/** @internal */ epicLinkField: string | null = \"customfield_100\";\n\t/** @internal */ issueTypes: JiraCreateMetadata[\"issueTypes\"] = [\n\t\t{ id: \"Story\", name: \"Story\", subtask: false, fields: {} },\n\t\t{ id: \"Task\", name: \"Task\", subtask: false, fields: {} },\n\t\t{ id: \"10003\", name: \"Sub-task\", subtask: true, fields: {} },\n\t];\n\n\t/** @internal */ seedIssue(issue: JiraIssue, epicKey?: string): void {\n\t\tconst stored = structuredClone(issue);\n\t\tif (epicKey) Object.assign(stored.fields, { customfield_100: epicKey });\n\t\tthis.issues.set(issue.id, stored);\n\t}\n\t/** @internal */ async getIssue(id: string): Promise<JiraIssue> {\n\t\tconst issue =\n\t\t\tthis.issues.get(id) ?? [...this.issues.values()].find((candidate) => candidate.key === id);\n\t\tif (!issue) throw new Error(\"Jira issue unavailable\");\n\t\treturn structuredClone(issue);\n\t}\n\t/** @internal */ async listProjects(): Promise<JiraProject[]> {\n\t\treturn [\n\t\t\t...new Map(\n\t\t\t\t[...this.issues.values()].map((issue) => [issue.fields.project.id, issue.fields.project]),\n\t\t\t).values(),\n\t\t];\n\t}\n\t/** @internal */ async listCreateProjects(projectId?: string): Promise<JiraCreateProject[]> {\n\t\treturn (await this.listProjects())\n\t\t\t.filter((project) => !projectId || project.id === projectId)\n\t\t\t.map((project) => ({\n\t\t\t\t...project,\n\t\t\t\tissuetypes: this.issueTypes\n\t\t\t\t\t.filter((type) => !type.subtask)\n\t\t\t\t\t.map((type) => ({\n\t\t\t\t\t\t...type,\n\t\t\t\t\t\tsubtask: false,\n\t\t\t\t\t\tfields: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(type.fields).map(([key, field]) => [\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...field,\n\t\t\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\t\t\trequired: field.required ?? false,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t})),\n\t\t\t}));\n\t}\n\t/** @internal */ async listProjectIssues(projectId: string): Promise<JiraIssue[]> {\n\t\treturn structuredClone(\n\t\t\t[...this.issues.values()].filter((issue) => issue.fields.project.id === projectId),\n\t\t);\n\t}\n\t/** @internal */ async listComponents(): Promise<JiraComponent[]> {\n\t\treturn structuredClone(this.components);\n\t}\n\t/** @internal */ async searchIssues(projectIds: readonly string[], triggerLabel?: string) {\n\t\treturn [...this.issues.values()]\n\t\t\t.filter(\n\t\t\t\t(issue) =>\n\t\t\t\t\tprojectIds.includes(issue.fields.project.id) && jiraEligible(issue, triggerLabel),\n\t\t\t)\n\t\t\t.map((issue) => structuredClone(issue));\n\t}\n\t/** @internal */ async searchSplitIssues(projectIds: readonly string[]) {\n\t\treturn [...this.issues.values()]\n\t\t\t.filter((issue) => projectIds.includes(issue.fields.project.id) && jiraSplitEligible(issue))\n\t\t\t.map((issue) => structuredClone(issue));\n\t}\n\t/** @internal */ async getEpic(issue: JiraIssue): Promise<JiraIssue | null> {\n\t\tif (issue.fields.issuetype?.name === \"Epic\") return issue;\n\t\tif (!this.epicLinkField) return null;\n\t\tconst key = (issue.fields as unknown as Record<string, unknown>)[this.epicLinkField];\n\t\treturn typeof key === \"string\" ? this.getIssue(key) : null;\n\t}\n\t/** @internal */ async createMetadata(\n\t\t_projectId: string,\n\t\tincludeEpicLink = true,\n\t): Promise<JiraCreateMetadata> {\n\t\tif (includeEpicLink && !this.epicLinkField)\n\t\t\tthrow new Error(\"Splitting a Jira epic requires an Epic Link field\");\n\t\treturn {\n\t\t\tepicLinkField: includeEpicLink ? this.epicLinkField : null,\n\t\t\tissueTypes: structuredClone(this.issueTypes),\n\t\t};\n\t}\n\t/** @internal */ async createIssueReceipt(\n\t\tfields: Record<string, unknown>,\n\t): Promise<JiraIssueReceipt> {\n\t\tconst { id, key } = await this.createIssue(fields);\n\t\treturn { id, key };\n\t}\n\t/** @internal */ async createIssue(fields: Record<string, unknown>): Promise<JiraIssue> {\n\t\tconst type = this.issueTypes.find(\n\t\t\t(candidate) => candidate.id === (fields.issuetype as { id: string }).id,\n\t\t);\n\t\tif (!type) throw new Error(\"Unknown Jira issue type\");\n\t\tif (Boolean(type.subtask) !== Boolean(fields.parent))\n\t\t\tthrow new Error(\"Jira subtask creation requires its parent\");\n\t\tthis.creations.push(structuredClone(fields));\n\t\tconst id = String(1000 + this.creations.length),\n\t\t\tkey = `APP-${id}`;\n\t\tconst project = (await this.listProjects()).find(\n\t\t\t(candidate) => candidate.id === (fields.project as { id: string }).id,\n\t\t);\n\t\tif (!project) throw new Error(\"Unknown Jira project\");\n\t\tthis.seedIssue(\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tkey,\n\t\t\t\tfields: {\n\t\t\t\t\tsummary: String(fields.summary),\n\t\t\t\t\tdescription: String(fields.description),\n\t\t\t\t\tcomponents: (fields.components as { id: string }[]).map(\n\t\t\t\t\t\t({ id }) => this.components.find((component) => component.id === id)!,\n\t\t\t\t\t),\n\t\t\t\t\tlabels: fields.labels as string[],\n\t\t\t\t\tproject,\n\t\t\t\t\tissuetype: {\n\t\t\t\t\t\tid: (fields.issuetype as { id: string }).id,\n\t\t\t\t\t\tname: type.name,\n\t\t\t\t\t\tsubtask: type.subtask,\n\t\t\t\t\t},\n\t\t\t\t\t...(fields.parent\n\t\t\t\t\t\t? { parent: await this.getIssue((fields.parent as { id: string }).id) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tstatus: { statusCategory: { key: \"new\" } },\n\t\t\t\t},\n\t\t\t},\n\t\t\ttypeof fields.customfield_100 === \"string\" ? fields.customfield_100 : undefined,\n\t\t);\n\t\tif (this.loseNextCreateResponse) {\n\t\t\tthis.loseNextCreateResponse = false;\n\t\t\tthrow new Error(\"Response lost after Jira creation\");\n\t\t}\n\t\treturn this.getIssue(id);\n\t}\n\t/** @internal */ async findSplitIssue(projectId: string, marker: string) {\n\t\treturn this.searchVisible\n\t\t\t? structuredClone(\n\t\t\t\t\t[...this.issues.values()].find(\n\t\t\t\t\t\t(issue) =>\n\t\t\t\t\t\t\tissue.fields.project.id === projectId && issue.fields.labels.includes(marker),\n\t\t\t\t\t) ?? null,\n\t\t\t\t)\n\t\t\t: null;\n\t}\n\t/** @internal */ async listComments(id: string) {\n\t\treturn structuredClone(this.comments.get(id) ?? []);\n\t}\n\t/** @internal */ async addComment(id: string, body: string): Promise<JiraComment> {\n\t\tconst comments = this.comments.get(id) ?? [];\n\t\tconst comment = { id: String(comments.length + 1), body };\n\t\tcomments.push(comment);\n\t\tthis.comments.set(id, comments);\n\t\treturn comment;\n\t}\n\t/** @internal */ async updateLabels(id: string, remove: string[], add: string[]) {\n\t\tconst issue = this.issues.get(id);\n\t\tif (!issue) throw new Error(\"Unknown issue\");\n\t\tissue.fields.labels = [\n\t\t\t...new Set([...issue.fields.labels.filter((label) => !remove.includes(label)), ...add]),\n\t\t];\n\t}\n\t/** @internal */ async listRemoteLinks(id: string) {\n\t\treturn structuredClone(this.remoteLinks.get(id) ?? []);\n\t}\n\t/** @internal */ async upsertRemoteLink(id: string, input: Omit<JiraRemoteLink, \"id\">) {\n\t\tconst links = this.remoteLinks.get(id) ?? [];\n\t\tconst result = upsertRemoteLink(links, input);\n\t\tthis.remoteLinks.set(id, links);\n\t\treturn result;\n\t}\n\t/** @internal */ async listTransitions(_id: string) {\n\t\treturn structuredClone(this.transitions);\n\t}\n\t/** @internal */ async transitionIssue(id: string, transitionId: string) {\n\t\tconst issue = this.issues.get(id);\n\t\tconst transition = this.transitions.find((transition) => transition.id === transitionId);\n\t\tif (!issue || !transition) throw new Error(\"Jira transition unavailable\");\n\t\tissue.fields.status = structuredClone(transition.to);\n\t}\n}\n\n/** @internal */\nexport class LocalJiraAdapter {\n\t/** @internal */\n\treadonly state: {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tprojects: JiraCreateProject[];\n\t\t/** @internal */\n\t\tissues: JiraIssue[];\n\t\t/** @internal */\n\t\tcomments: Record<string, JiraComment[]>;\n\t\t/** @internal */\n\t\tremoteLinks: Record<string, JiraRemoteLink[]>;\n\t};\n\t/** @internal */\n\tloseNextIssueResponse = false;\n\t/** @internal */\n\tconstructor(\n\t\t/** @internal */ readonly root: string,\n\t\t/** @internal */ readonly baseUrl = \"https://jira.test\",\n\t) {\n\t\tthis.state = readLocalJson(root, \"jira.json\", {\n\t\t\tversion: 1,\n\t\t\tprojects: [],\n\t\t\tissues: [],\n\t\t\tcomments: {},\n\t\t\tremoteLinks: {},\n\t\t});\n\t\tthis.state.remoteLinks ??= {};\n\t}\n\t/** @internal */\n\tsave(): void {\n\t\twriteLocalJson(this.root, \"jira.json\", this.state);\n\t}\n\t/** @internal */\n\tseed(project: JiraCreateProject): void {\n\t\tif (this.state.projects.some((candidate) => candidate.id === project.id)) return;\n\t\tthis.state.projects.push(structuredClone(project));\n\t\tthis.save();\n\t}\n\t/** @internal */\n\tclient(): JiraClientLike {\n\t\treturn {\n\t\t\t...localJiraIssueClient(this.state, () => this.save()),\n\t\t\tbaseUrl: this.baseUrl,\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\n\t\t\tlistCreateProjects: async (id) =>\n\t\t\t\tstructuredClone(this.state.projects.filter((project) => !id || project.id === id)),\n\t\t\tlistComponents: async () => [],\n\t\t\tsearchIssues: async (ids) =>\n\t\t\t\tstructuredClone(this.state.issues.filter((issue) => ids.includes(issue.fields.project.id))),\n\t\t\tlistProjectIssues: async (id) =>\n\t\t\t\tstructuredClone(this.state.issues.filter((issue) => issue.fields.project.id === id)),\n\t\t\tsearchSplitIssues: async (ids) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.issues.filter(\n\t\t\t\t\t\t(issue) => ids.includes(issue.fields.project.id) && jiraSplitEligible(issue),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetEpic: async (issue) =>\n\t\t\t\tissue.fields.issuetype?.name === \"Epic\" ? structuredClone(issue) : null,\n\t\t\tcreateMetadata: async (id, includeEpicLink = true) => {\n\t\t\t\tif (includeEpicLink)\n\t\t\t\t\tthrow new Error(\"Local ticket creation does not configure an Epic Link field\");\n\t\t\t\tconst project = this.state.projects.find((project) => project.id === id);\n\t\t\t\tif (!project) throw new Error(\"Unknown local Jira project\");\n\t\t\t\treturn { epicLinkField: null, issueTypes: structuredClone(project.issuetypes) };\n\t\t\t},\n\t\t\tfindSplitIssue: async (id, marker) => {\n\t\t\t\tconst matches = this.state.issues.filter(\n\t\t\t\t\t(issue) => issue.fields.project.id === id && issue.fields.labels.includes(marker),\n\t\t\t\t);\n\t\t\t\tif (matches.length > 1) throw new Error(\"Multiple Jira tickets share the split identity\");\n\t\t\t\treturn structuredClone(matches[0] ?? null);\n\t\t\t},\n\t\t\tcreateIssueReceipt: async (fields, signal) => {\n\t\t\t\tconst { id, key } = await this.client().createIssue(fields, signal);\n\t\t\t\treturn { id, key };\n\t\t\t},\n\t\t\tcreateIssue: async (fields) => {\n\t\t\t\tconst project = this.state.projects.find(\n\t\t\t\t\t(project) => project.id === (fields.project as { id: string }).id,\n\t\t\t\t);\n\t\t\t\tif (!project) throw new Error(\"Unknown local Jira project\");\n\t\t\t\tconst issueType = project.issuetypes.find(\n\t\t\t\t\t(type) => type.id === (fields.issuetype as { id: string }).id,\n\t\t\t\t);\n\t\t\t\tif (!issueType) throw new Error(\"Unknown local Jira issue type\");\n\t\t\t\tfor (const key of Object.keys(fields)) {\n\t\t\t\t\tif (![\"project\", \"issuetype\"].includes(key) && !Object.hasOwn(issueType.fields, key))\n\t\t\t\t\t\tthrow new Error(`Jira field '${key}' is not on the create screen`);\n\t\t\t\t}\n\t\t\t\tconst created: JiraIssue = {\n\t\t\t\t\tid: String(this.state.issues.length + 1),\n\t\t\t\t\tkey: `${project.key}-${this.state.issues.filter((issue) => issue.fields.project.id === project.id).length + 1}`,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\tsummary: String(fields.summary),\n\t\t\t\t\t\tdescription: String(fields.description),\n\t\t\t\t\t\tlabels: (fields.labels as string[] | undefined) ?? [],\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\tcomponents: [],\n\t\t\t\t\t\tstatus: { statusCategory: { key: \"new\" } },\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tthis.state.issues.push(created);\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextIssueResponse) {\n\t\t\t\t\tthis.loseNextIssueResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after issue write\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(created);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** @internal */\nexport function localJiraIssueClient(\n\tstate: Pick<LocalJiraAdapter[\"state\"], \"issues\" | \"comments\"> &\n\t\tPartial<Pick<LocalJiraAdapter[\"state\"], \"remoteLinks\">>,\n\tsave: () => void,\n): Pick<\n\tJiraClientLike,\n\t| \"getIssue\"\n\t| \"listComments\"\n\t| \"addComment\"\n\t| \"updateLabels\"\n\t| \"listRemoteLinks\"\n\t| \"upsertRemoteLink\"\n\t| \"listTransitions\"\n\t| \"transitionIssue\"\n> {\n\tconst issue = (id: string) => {\n\t\tconst found = state.issues.find((issue) => issue.id === id || issue.key === id);\n\t\tif (!found) throw new Error(\"Unknown local Jira issue\");\n\t\treturn found;\n\t};\n\treturn {\n\t\tgetIssue: async (id) => structuredClone(issue(id)),\n\t\tlistComments: async (id) => structuredClone(state.comments[issue(id).id] ?? []),\n\t\taddComment: async (id, body) => {\n\t\t\tstate.comments[issue(id).id] ??= [];\n\t\t\tconst comments = state.comments[issue(id).id];\n\t\t\tconst comment = { id: String(comments.length + 1), body };\n\t\t\tcomments.push(comment);\n\t\t\tsave();\n\t\t\treturn structuredClone(comment);\n\t\t},\n\t\tupdateLabels: async (id, remove, add) => {\n\t\t\tconst current = issue(id);\n\t\t\tcurrent.fields.labels = [\n\t\t\t\t...new Set([...current.fields.labels.filter((label) => !remove.includes(label)), ...add]),\n\t\t\t];\n\t\t\tsave();\n\t\t},\n\t\tlistRemoteLinks: async (id) => structuredClone(state.remoteLinks?.[issue(id).id] ?? []),\n\t\tupsertRemoteLink: async (id, input) => {\n\t\t\tstate.remoteLinks ??= {};\n\t\t\tstate.remoteLinks[issue(id).id] ??= [];\n\t\t\tconst result = upsertRemoteLink(state.remoteLinks[issue(id).id], input);\n\t\t\tsave();\n\t\t\treturn result;\n\t\t},\n\t\tlistTransitions: async () => structuredClone(workflowTransitions),\n\t\ttransitionIssue: async (id, transitionId) => {\n\t\t\tconst transition = workflowTransitions.find((candidate) => candidate.id === transitionId);\n\t\t\tif (!transition) throw new Error(\"Jira transition unavailable\");\n\t\t\tissue(id).fields.status = structuredClone(transition.to);\n\t\t\tsave();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAAA,SAAS,eAAe,sBAAsB;AAkB9C,SAAS,iBAAiB,OAAyB,OAAmC;AACrF,QAAM,WAAW,MAAM,KAAK,CAACA,UAASA,MAAK,aAAa,MAAM,QAAQ;AACtE,QAAM,OAAO,EAAE,GAAG,gBAAgB,KAAK,GAAG,IAAI,UAAU,MAAM,MAAM,SAAS,EAAE;AAC/E,MAAI,SAAU,OAAM,MAAM,QAAQ,QAAQ,CAAC,IAAI;AAAA,MAC1C,OAAM,KAAK,IAAI;AACpB,QAAM,SAAqC,EAAE,IAAI,KAAK,GAAG;AACzD,SAAO;AACR;AAEA,IAAM,sBAAwC;AAAA,EAC7C;AAAA,IACC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,IAAI,EAAE,IAAI,KAAK,MAAM,eAAe,gBAAgB,EAAE,KAAK,gBAAgB,EAAE;AAAA,EAC9E;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,IAAI,EAAE,IAAI,KAAK,MAAM,aAAa,gBAAgB,EAAE,KAAK,gBAAgB,EAAE;AAA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,OAAO,IAAI,iBAAiB;AAC5C,YAAM,aAAa,oBAAoB,KAAK,CAAC,cAAc,UAAU,OAAO,YAAY;AACxF,UAAI,CAAC,WAAY,OAAM,IAAI,MAAM,6BAA6B;AAC9D,YAAM,EAAE,EAAE,OAAO,SAAS,gBAAgB,WAAW,EAAE;AACvD,WAAK;AAAA,IACN;AAAA,EACD;AACD;","names":["link","id","transition","project","issue"]}
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { readLocalJson, writeLocalJson } from \"@leitwerk-dev/test-support/local-git\";\nimport {\n\ttype JiraClientLike,\n\ttype JiraComment,\n\ttype JiraComponent,\n\ttype JiraCreateMetadata,\n\ttype JiraCreateProject,\n\ttype JiraIssue,\n\ttype JiraIssueReceipt,\n\ttype JiraProject,\n\ttype JiraRemoteLink,\n\ttype JiraTransition,\n\tjiraEligible,\n\tjiraSplitEligible,\n} from \"./client.js\";\n\nexport { registerJiraTools } from \"./tools.js\";\n\nfunction upsertRemoteLink(links: JiraRemoteLink[], input: Omit<JiraRemoteLink, \"id\">) {\n\tconst previous = links.find((link) => link.globalId === input.globalId);\n\tconst link = { ...structuredClone(input), id: previous?.id ?? links.length + 1 };\n\tif (previous) links[links.indexOf(previous)] = link;\n\telse links.push(link);\n\tconst result: Pick<JiraRemoteLink, \"id\"> = { id: link.id };\n\treturn result;\n}\n\nconst workflowTransitions: JiraTransition[] = [\n\t{\n\t\tid: \"31\",\n\t\tname: \"Start work\",\n\t\tto: { id: \"3\", name: \"In Progress\", statusCategory: { key: \"indeterminate\" } },\n\t},\n\t{\n\t\tid: \"41\",\n\t\tname: \"Request review\",\n\t\tto: { id: \"4\", name: \"In Review\", statusCategory: { key: \"indeterminate\" } },\n\t},\n\t{\n\t\tid: \"51\",\n\t\tname: \"Verify change\",\n\t\tto: { id: \"5\", name: \"In Verification\", statusCategory: { key: \"indeterminate\" } },\n\t},\n\t{\n\t\tid: \"50\",\n\t\tname: \"Prepare verification\",\n\t\tto: { id: \"6\", name: \"Ready for Verification\", statusCategory: { key: \"indeterminate\" } },\n\t},\n];\n\n/** @internal */\nexport class LocalJiraSplitAdapter implements JiraClientLike {\n\t/** @internal */ readonly baseUrl = \"https://jira.test/context\";\n\t/** @internal */ readonly issues = new Map<string, JiraIssue>();\n\t/** @internal */ readonly comments = new Map<string, JiraComment[]>();\n\t/** @internal */ readonly remoteLinks = new Map<string, JiraRemoteLink[]>();\n\t/** @internal */ transitions = structuredClone(workflowTransitions);\n\t/** @internal */ readonly creations: Record<string, unknown>[] = [];\n\t/** @internal */ loseNextCreateResponse = false;\n\t/** @internal */ searchVisible = true;\n\t/** @internal */ components: JiraComponent[] = [{ id: \"200\", name: \"Service\" }];\n\t/** @internal */ epicLinkField: string | null = \"customfield_100\";\n\t/** @internal */ issueTypes: JiraCreateMetadata[\"issueTypes\"] = [\n\t\t{ id: \"Story\", name: \"Story\", subtask: false, fields: {} },\n\t\t{ id: \"Task\", name: \"Task\", subtask: false, fields: {} },\n\t\t{ id: \"10003\", name: \"Sub-task\", subtask: true, fields: {} },\n\t];\n\n\t/** @internal */ seedIssue(issue: JiraIssue, epicKey?: string): void {\n\t\tconst stored = structuredClone(issue);\n\t\tif (epicKey) Object.assign(stored.fields, { customfield_100: epicKey });\n\t\tthis.issues.set(issue.id, stored);\n\t}\n\t/** @internal */ async getIssue(id: string): Promise<JiraIssue> {\n\t\tconst issue =\n\t\t\tthis.issues.get(id) ?? [...this.issues.values()].find((candidate) => candidate.key === id);\n\t\tif (!issue) throw new Error(\"Jira issue unavailable\");\n\t\treturn structuredClone(issue);\n\t}\n\t/** @internal */ async listProjects(): Promise<JiraProject[]> {\n\t\treturn [\n\t\t\t...new Map(\n\t\t\t\t[...this.issues.values()].map((issue) => [issue.fields.project.id, issue.fields.project]),\n\t\t\t).values(),\n\t\t];\n\t}\n\t/** @internal */ async listCreateProjects(projectId?: string): Promise<JiraCreateProject[]> {\n\t\treturn (await this.listProjects())\n\t\t\t.filter((project) => !projectId || project.id === projectId)\n\t\t\t.map((project) => ({\n\t\t\t\t...project,\n\t\t\t\tissuetypes: this.issueTypes\n\t\t\t\t\t.filter((type) => !type.subtask)\n\t\t\t\t\t.map((type) => ({\n\t\t\t\t\t\t...type,\n\t\t\t\t\t\tsubtask: false,\n\t\t\t\t\t\tfields: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(type.fields).map(([key, field]) => [\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...field,\n\t\t\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\t\t\trequired: field.required ?? false,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t),\n\t\t\t\t\t})),\n\t\t\t}));\n\t}\n\t/** @internal */ async listProjectIssues(projectId: string): Promise<JiraIssue[]> {\n\t\treturn structuredClone(\n\t\t\t[...this.issues.values()].filter((issue) => issue.fields.project.id === projectId),\n\t\t);\n\t}\n\t/** @internal */ async listComponents(): Promise<JiraComponent[]> {\n\t\treturn structuredClone(this.components);\n\t}\n\t/** @internal */ async searchIssues(projectIds: readonly string[], triggerLabel?: string) {\n\t\treturn [...this.issues.values()]\n\t\t\t.filter(\n\t\t\t\t(issue) =>\n\t\t\t\t\tprojectIds.includes(issue.fields.project.id) && jiraEligible(issue, triggerLabel),\n\t\t\t)\n\t\t\t.map((issue) => structuredClone(issue));\n\t}\n\t/** @internal */ async searchSplitIssues(projectIds: readonly string[]) {\n\t\treturn [...this.issues.values()]\n\t\t\t.filter((issue) => projectIds.includes(issue.fields.project.id) && jiraSplitEligible(issue))\n\t\t\t.map((issue) => structuredClone(issue));\n\t}\n\t/** @internal */ async getEpic(issue: JiraIssue): Promise<JiraIssue | null> {\n\t\tif (issue.fields.issuetype?.name === \"Epic\") return issue;\n\t\tif (!this.epicLinkField) return null;\n\t\tconst key = (issue.fields as unknown as Record<string, unknown>)[this.epicLinkField];\n\t\treturn typeof key === \"string\" ? this.getIssue(key) : null;\n\t}\n\t/** @internal */ async createMetadata(\n\t\t_projectId: string,\n\t\tincludeEpicLink = true,\n\t): Promise<JiraCreateMetadata> {\n\t\tif (includeEpicLink && !this.epicLinkField)\n\t\t\tthrow new Error(\"Splitting a Jira epic requires an Epic Link field\");\n\t\treturn {\n\t\t\tepicLinkField: includeEpicLink ? this.epicLinkField : null,\n\t\t\tissueTypes: structuredClone(this.issueTypes),\n\t\t};\n\t}\n\t/** @internal */ async createIssueReceipt(\n\t\tfields: Record<string, unknown>,\n\t): Promise<JiraIssueReceipt> {\n\t\tconst { id, key } = await this.createIssue(fields);\n\t\treturn { id, key };\n\t}\n\t/** @internal */ async createIssue(fields: Record<string, unknown>): Promise<JiraIssue> {\n\t\tconst type = this.issueTypes.find(\n\t\t\t(candidate) => candidate.id === (fields.issuetype as { id: string }).id,\n\t\t);\n\t\tif (!type) throw new Error(\"Unknown Jira issue type\");\n\t\tif (Boolean(type.subtask) !== Boolean(fields.parent))\n\t\t\tthrow new Error(\"Jira subtask creation requires its parent\");\n\t\tthis.creations.push(structuredClone(fields));\n\t\tconst id = String(1000 + this.creations.length),\n\t\t\tkey = `APP-${id}`;\n\t\tconst project = (await this.listProjects()).find(\n\t\t\t(candidate) => candidate.id === (fields.project as { id: string }).id,\n\t\t);\n\t\tif (!project) throw new Error(\"Unknown Jira project\");\n\t\tthis.seedIssue(\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tkey,\n\t\t\t\tfields: {\n\t\t\t\t\tsummary: String(fields.summary),\n\t\t\t\t\tdescription: String(fields.description),\n\t\t\t\t\tcomponents: (fields.components as { id: string }[]).map(\n\t\t\t\t\t\t({ id }) => this.components.find((component) => component.id === id)!,\n\t\t\t\t\t),\n\t\t\t\t\tlabels: fields.labels as string[],\n\t\t\t\t\tproject,\n\t\t\t\t\tissuetype: {\n\t\t\t\t\t\tid: (fields.issuetype as { id: string }).id,\n\t\t\t\t\t\tname: type.name,\n\t\t\t\t\t\tsubtask: type.subtask,\n\t\t\t\t\t},\n\t\t\t\t\t...(fields.parent\n\t\t\t\t\t\t? { parent: await this.getIssue((fields.parent as { id: string }).id) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tstatus: { statusCategory: { key: \"new\" } },\n\t\t\t\t},\n\t\t\t},\n\t\t\ttypeof fields.customfield_100 === \"string\" ? fields.customfield_100 : undefined,\n\t\t);\n\t\tif (this.loseNextCreateResponse) {\n\t\t\tthis.loseNextCreateResponse = false;\n\t\t\tthrow new Error(\"Response lost after Jira creation\");\n\t\t}\n\t\treturn this.getIssue(id);\n\t}\n\t/** @internal */ async findSplitIssue(projectId: string, marker: string) {\n\t\treturn this.searchVisible\n\t\t\t? structuredClone(\n\t\t\t\t\t[...this.issues.values()].find(\n\t\t\t\t\t\t(issue) =>\n\t\t\t\t\t\t\tissue.fields.project.id === projectId && issue.fields.labels.includes(marker),\n\t\t\t\t\t) ?? null,\n\t\t\t\t)\n\t\t\t: null;\n\t}\n\t/** @internal */ async listComments(id: string) {\n\t\treturn structuredClone(this.comments.get(id) ?? []);\n\t}\n\t/** @internal */ async addComment(id: string, body: string): Promise<JiraComment> {\n\t\tconst comments = this.comments.get(id) ?? [];\n\t\tconst comment = { id: String(comments.length + 1), body };\n\t\tcomments.push(comment);\n\t\tthis.comments.set(id, comments);\n\t\treturn comment;\n\t}\n\t/** @internal */ async updateLabels(id: string, remove: string[], add: string[]) {\n\t\tconst issue = this.issues.get(id);\n\t\tif (!issue) throw new Error(\"Unknown issue\");\n\t\tissue.fields.labels = [\n\t\t\t...new Set([...issue.fields.labels.filter((label) => !remove.includes(label)), ...add]),\n\t\t];\n\t}\n\t/** @internal */ async listRemoteLinks(id: string) {\n\t\treturn structuredClone(this.remoteLinks.get(id) ?? []);\n\t}\n\t/** @internal */ async upsertRemoteLink(id: string, input: Omit<JiraRemoteLink, \"id\">) {\n\t\tconst links = this.remoteLinks.get(id) ?? [];\n\t\tconst result = upsertRemoteLink(links, input);\n\t\tthis.remoteLinks.set(id, links);\n\t\treturn result;\n\t}\n\t/** @internal */ async listTransitions(_id: string) {\n\t\treturn structuredClone(this.transitions);\n\t}\n\t/** @internal */ async transitionIssue(id: string, transitionId: string) {\n\t\tconst issue = this.issues.get(id);\n\t\tconst transition = this.transitions.find((transition) => transition.id === transitionId);\n\t\tif (!issue || !transition) throw new Error(\"Jira transition unavailable\");\n\t\tissue.fields.status = structuredClone(transition.to);\n\t}\n}\n\n/** @internal */\nexport class LocalJiraAdapter {\n\t/** @internal */\n\treadonly state: {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tprojects: JiraCreateProject[];\n\t\t/** @internal */\n\t\tissues: JiraIssue[];\n\t\t/** @internal */\n\t\tcomments: Record<string, JiraComment[]>;\n\t\t/** @internal */\n\t\tremoteLinks: Record<string, JiraRemoteLink[]>;\n\t};\n\t/** @internal */\n\tloseNextIssueResponse = false;\n\t/** @internal */\n\tconstructor(\n\t\t/** @internal */ readonly root: string,\n\t\t/** @internal */ readonly baseUrl = \"https://jira.test\",\n\t) {\n\t\tthis.state = readLocalJson(root, \"jira.json\", {\n\t\t\tversion: 1,\n\t\t\tprojects: [],\n\t\t\tissues: [],\n\t\t\tcomments: {},\n\t\t\tremoteLinks: {},\n\t\t});\n\t\tthis.state.remoteLinks ??= {};\n\t}\n\t/** @internal */\n\tsave(): void {\n\t\twriteLocalJson(this.root, \"jira.json\", this.state);\n\t}\n\t/** @internal */\n\tseed(project: JiraCreateProject): void {\n\t\tif (this.state.projects.some((candidate) => candidate.id === project.id)) return;\n\t\tthis.state.projects.push(structuredClone(project));\n\t\tthis.save();\n\t}\n\t/** @internal */\n\tclient(): JiraClientLike {\n\t\treturn {\n\t\t\t...localJiraIssueClient(this.state, () => this.save()),\n\t\t\tbaseUrl: this.baseUrl,\n\t\t\tlistProjects: async () => structuredClone(this.state.projects),\n\t\t\tlistCreateProjects: async (id) =>\n\t\t\t\tstructuredClone(this.state.projects.filter((project) => !id || project.id === id)),\n\t\t\tlistComponents: async () => [],\n\t\t\tsearchIssues: async (ids) =>\n\t\t\t\tstructuredClone(this.state.issues.filter((issue) => ids.includes(issue.fields.project.id))),\n\t\t\tlistProjectIssues: async (id) =>\n\t\t\t\tstructuredClone(this.state.issues.filter((issue) => issue.fields.project.id === id)),\n\t\t\tsearchSplitIssues: async (ids) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\tthis.state.issues.filter(\n\t\t\t\t\t\t(issue) => ids.includes(issue.fields.project.id) && jiraSplitEligible(issue),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tgetEpic: async (issue) =>\n\t\t\t\tissue.fields.issuetype?.name === \"Epic\" ? structuredClone(issue) : null,\n\t\t\tcreateMetadata: async (id, includeEpicLink = true) => {\n\t\t\t\tif (includeEpicLink)\n\t\t\t\t\tthrow new Error(\"Local ticket creation does not configure an Epic Link field\");\n\t\t\t\tconst project = this.state.projects.find((project) => project.id === id);\n\t\t\t\tif (!project) throw new Error(\"Unknown local Jira project\");\n\t\t\t\treturn { epicLinkField: null, issueTypes: structuredClone(project.issuetypes) };\n\t\t\t},\n\t\t\tfindSplitIssue: async (id, marker) => {\n\t\t\t\tconst matches = this.state.issues.filter(\n\t\t\t\t\t(issue) => issue.fields.project.id === id && issue.fields.labels.includes(marker),\n\t\t\t\t);\n\t\t\t\tif (matches.length > 1) throw new Error(\"Multiple Jira tickets share the split identity\");\n\t\t\t\treturn structuredClone(matches[0] ?? null);\n\t\t\t},\n\t\t\tcreateIssueReceipt: async (fields, signal) => {\n\t\t\t\tconst { id, key } = await this.client().createIssue(fields, signal);\n\t\t\t\treturn { id, key };\n\t\t\t},\n\t\t\tcreateIssue: async (fields) => {\n\t\t\t\tconst project = this.state.projects.find(\n\t\t\t\t\t(project) => project.id === (fields.project as { id: string }).id,\n\t\t\t\t);\n\t\t\t\tif (!project) throw new Error(\"Unknown local Jira project\");\n\t\t\t\tconst issueType = project.issuetypes.find(\n\t\t\t\t\t(type) => type.id === (fields.issuetype as { id: string }).id,\n\t\t\t\t);\n\t\t\t\tif (!issueType) throw new Error(\"Unknown local Jira issue type\");\n\t\t\t\tfor (const key of Object.keys(fields)) {\n\t\t\t\t\tif (![\"project\", \"issuetype\"].includes(key) && !Object.hasOwn(issueType.fields, key))\n\t\t\t\t\t\tthrow new Error(`Jira field '${key}' is not on the create screen`);\n\t\t\t\t}\n\t\t\t\tconst created: JiraIssue = {\n\t\t\t\t\tid: String(this.state.issues.length + 1),\n\t\t\t\t\tkey: `${project.key}-${this.state.issues.filter((issue) => issue.fields.project.id === project.id).length + 1}`,\n\t\t\t\t\tfields: {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\tsummary: String(fields.summary),\n\t\t\t\t\t\tdescription: String(fields.description),\n\t\t\t\t\t\tlabels: (fields.labels as string[] | undefined) ?? [],\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\tcomponents: [],\n\t\t\t\t\t\tstatus: { statusCategory: { key: \"new\" } },\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tthis.state.issues.push(created);\n\t\t\t\tthis.save();\n\t\t\t\tif (this.loseNextIssueResponse) {\n\t\t\t\t\tthis.loseNextIssueResponse = false;\n\t\t\t\t\tthrow new Error(\"Response lost after issue write\");\n\t\t\t\t}\n\t\t\t\treturn structuredClone(created);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** @internal */\nexport function localJiraIssueClient(\n\tstate: Pick<LocalJiraAdapter[\"state\"], \"issues\" | \"comments\"> &\n\t\tPartial<Pick<LocalJiraAdapter[\"state\"], \"remoteLinks\">>,\n\tsave: () => void,\n): Pick<\n\tJiraClientLike,\n\t| \"getIssue\"\n\t| \"listComments\"\n\t| \"addComment\"\n\t| \"updateLabels\"\n\t| \"listRemoteLinks\"\n\t| \"upsertRemoteLink\"\n\t| \"listTransitions\"\n\t| \"transitionIssue\"\n> {\n\tconst issue = (id: string) => {\n\t\tconst found = state.issues.find((issue) => issue.id === id || issue.key === id);\n\t\tif (!found) throw new Error(\"Unknown local Jira issue\");\n\t\treturn found;\n\t};\n\treturn {\n\t\tgetIssue: async (id) => structuredClone(issue(id)),\n\t\tlistComments: async (id) => structuredClone(state.comments[issue(id).id] ?? []),\n\t\taddComment: async (id, body) => {\n\t\t\tstate.comments[issue(id).id] ??= [];\n\t\t\tconst comments = state.comments[issue(id).id];\n\t\t\tconst comment = { id: String(comments.length + 1), body };\n\t\t\tcomments.push(comment);\n\t\t\tsave();\n\t\t\treturn structuredClone(comment);\n\t\t},\n\t\tupdateLabels: async (id, remove, add) => {\n\t\t\tconst current = issue(id);\n\t\t\tcurrent.fields.labels = [\n\t\t\t\t...new Set([...current.fields.labels.filter((label) => !remove.includes(label)), ...add]),\n\t\t\t];\n\t\t\tsave();\n\t\t},\n\t\tlistRemoteLinks: async (id) => structuredClone(state.remoteLinks?.[issue(id).id] ?? []),\n\t\tupsertRemoteLink: async (id, input) => {\n\t\t\tstate.remoteLinks ??= {};\n\t\t\tstate.remoteLinks[issue(id).id] ??= [];\n\t\t\tconst result = upsertRemoteLink(state.remoteLinks[issue(id).id], input);\n\t\t\tsave();\n\t\t\treturn result;\n\t\t},\n\t\tlistTransitions: async () => structuredClone(workflowTransitions),\n\t\ttransitionIssue: async (id, transitionId) => {\n\t\t\tconst transition = workflowTransitions.find((candidate) => candidate.id === transitionId);\n\t\t\tif (!transition) throw new Error(\"Jira transition unavailable\");\n\t\t\tissue(id).fields.status = structuredClone(transition.to);\n\t\t\tsave();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAAA,SAAS,eAAe,sBAAsB;AAkB9C,SAAS,iBAAiB,OAAyB,OAAmC;AACrF,QAAM,WAAW,MAAM,KAAK,CAACA,UAASA,MAAK,aAAa,MAAM,QAAQ;AACtE,QAAM,OAAO,EAAE,GAAG,gBAAgB,KAAK,GAAG,IAAI,UAAU,MAAM,MAAM,SAAS,EAAE;AAC/E,MAAI,SAAU,OAAM,MAAM,QAAQ,QAAQ,CAAC,IAAI;AAAA,MAC1C,OAAM,KAAK,IAAI;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O,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,MACzF;AACA,WAAK;AAAA,IACN;AAAA,IACA,iBAAiB,OAAO,OAAO,gBAAgB,MAAM,cAAc,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;AAAA,IACtF,kBAAkB,OAAO,IAAI,UAAU;AACtC,YAAM,gBAAgB,CAAC;AACvB,YAAM,YAAY,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC;AACrC,YAAM,SAAS,iBAAiB,MAAM,YAAY,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK;AACtE,WAAK;AACL,aAAO;AAAA,IACR;AAAA,IACA,iBAAiB,YAAY,gBAAgB,mBAAmB;AAAA,IAChE,iBAAiB,OAAO,IAAI,iBAAiB;AAC5C,YAAM,aAAa,oBAAoB,KAAK,CAAC,cAAc,UAAU,OAAO,YAAY;AACxF,UAAI,CAAC,WAAY,OAAM,IAAI,MAAM,6BAA6B;AAC9D,YAAM,EAAE,EAAE,OAAO,SAAS,gBAAgB,WAAW,EAAE;AACvD,WAAK;AAAA,IACN;AAAA,EACD;AACD;","names":["link","id","transition","project","issue"]}
|
package/dist/ticket-text.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export declare const jiraTicketWritingInstructions = "Write summary and description as a normal standalone Jira task for its assignee, using Markdown for the description. Explain the work and acceptance criteria in plain language; retain concrete file paths, prerequisites, and validation steps when needed. Keep evidence, inspected revisions, repository keys, and other tracking data in the separate evidence fields. Do not put raw commit hashes, internal IDs, split identities, solution-wiki references, or model citation tokens in the summary or description. Refer to repositories by their readable names and Jira issues by their issue keys. The publisher adds repository and source-issue links. When revising an existing ticket, preserve useful task details and human notes, and omit any previous generated tracking footer.";
|
|
2
|
+
export declare const jiraTicketWritingInstructions = "Use plain English following ASD-STE100. Use at most three headings and at most 120 words under each heading; code snippets do not count toward the word limit. Choose headings that fit the work and include only supported details. Link to internal data instead of copying it. Write summary and description as a normal standalone Jira task for its assignee, using Markdown for the description. Explain the work and acceptance criteria in plain language; retain concrete file paths, prerequisites, and validation steps when needed. Keep evidence, inspected revisions, repository keys, and other tracking data in the separate evidence fields. Do not put raw commit hashes, internal IDs, split identities, solution-wiki references, or model citation tokens in the summary or description. Refer to repositories by their readable names and Jira issues by their issue keys. The publisher adds repository and source-issue links. When revising an existing ticket, preserve useful task details and human notes, and omit any previous generated tracking footer.";
|
|
3
3
|
/** @internal */
|
|
4
4
|
export declare function jiraTicketTextProblem(summary: string, description: string): string | null;
|
|
5
5
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticket-text.d.ts","sourceRoot":"","sources":["../src/ticket-text.ts"],"names":[],"mappings":"AAEA,gBAAgB;AAChB,eAAO,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ticket-text.d.ts","sourceRoot":"","sources":["../src/ticket-text.ts"],"names":[],"mappings":"AAEA,gBAAgB;AAChB,eAAO,MAAM,6BAA6B,4hCACg/B,CAAC;AAM3hC,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIzF;AAED,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAG/E;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,CACxC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE;IACN,gBAAgB;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB,GACC,MAAM,CAGR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-tools.d.ts","sourceRoot":"","sources":["../src/workflow-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAEN,KAAK,+BAA+B,EAEpC,KAAK,kBAAkB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,+BAA+B,EACpC,WAAW,EAAE,eAAe;;;;EAY5B;AAMD,gBAAgB;AAChB,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"workflow-tools.d.ts","sourceRoot":"","sources":["../src/workflow-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAEN,KAAK,+BAA+B,EAEpC,KAAK,kBAAkB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,+BAA+B,EACpC,WAAW,EAAE,eAAe;;;;EAY5B;AAMD,gBAAgB;AAChB,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,QA8H9F"}
|