@kaddo/cli 3.86.0 → 3.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>admin</title>
8
- <script type="module" crossorigin src="/assets/index-MJauSqlv.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-D6yaYj2M.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DNkI-1xG.css">
10
10
  </head>
11
11
  <body>
@@ -710,6 +710,16 @@ var WorkItemDetailSchema = WorkItemListItemSchema.extend({
710
710
  graphRevision: z.string().nullable(),
711
711
  graphCoverage: z.enum(["unavailable", "partial", "available"]),
712
712
  source: z.object({ type: z.string(), id: z.string().optional(), inferred: z.boolean() }).passthrough(),
713
+ originalSnapshot: z.object({
714
+ title: z.string(),
715
+ description: z.string().optional(),
716
+ type: z.string().optional(),
717
+ status: z.string().optional(),
718
+ labels: z.array(z.string()).optional(),
719
+ assignee: z.string().optional(),
720
+ created_at: z.string().optional(),
721
+ updated_at: z.string().optional()
722
+ }).nullable(),
713
723
  path: z.string(),
714
724
  refinement: z.object({
715
725
  status: z.enum(["needs-refinement", "refined"]),
@@ -1065,6 +1075,7 @@ async function createAdminServer(opts) {
1065
1075
  async (request, reply) => {
1066
1076
  const q = request.query;
1067
1077
  const filters = {};
1078
+ if (q.projects) filters.projects = q.projects.split(",");
1068
1079
  if (q.statuses) filters.statuses = q.statuses.split(",");
1069
1080
  if (q.types) filters.types = q.types.split(",");
1070
1081
  if (q.labels) filters.labels = q.labels.split(",");
@@ -1098,6 +1109,7 @@ async function createAdminServer(opts) {
1098
1109
  async (request, reply) => {
1099
1110
  const q = request.query;
1100
1111
  const filters = {};
1112
+ if (q.projects) filters.projects = q.projects.split(",");
1101
1113
  if (q.statuses) filters.statuses = q.statuses.split(",");
1102
1114
  if (q.types) filters.types = q.types.split(",");
1103
1115
  if (q.labels) filters.labels = q.labels.split(",");
package/dist/core.js CHANGED
@@ -6590,6 +6590,7 @@ function parseWorkItemSource(frontmatter) {
6590
6590
  integration: optStr(obj.integration) ?? optStr(frontmatter.source_integration),
6591
6591
  url: optStr(obj.url) ?? optStr(frontmatter.source_url),
6592
6592
  imported_at: optStr(obj.imported_at) ?? optStr(frontmatter.source_imported_at),
6593
+ external_updated_at: optStr(obj.external_updated_at) ?? optStr(frontmatter.source_external_updated_at),
6593
6594
  synced_at: optStr(obj.synced_at) ?? optStr(frontmatter.source_synced_at),
6594
6595
  inferred: obj.inferred === true || obj.inferred === "true",
6595
6596
  reason: t && !isValidSource(t) ? `Invalid source type in object: "${t}".` : void 0
@@ -6605,6 +6606,7 @@ function parseWorkItemSource(frontmatter) {
6605
6606
  provider: optStr(frontmatter.source_provider),
6606
6607
  url: optStr(frontmatter.source_url),
6607
6608
  imported_at: optStr(frontmatter.source_imported_at),
6609
+ external_updated_at: optStr(frontmatter.source_external_updated_at),
6608
6610
  synced_at: optStr(frontmatter.source_synced_at),
6609
6611
  inferred: false
6610
6612
  };
@@ -6618,6 +6620,7 @@ function parseWorkItemSource(frontmatter) {
6618
6620
  provider: optStr(frontmatter.source_provider),
6619
6621
  url: optStr(frontmatter.source_url),
6620
6622
  imported_at: optStr(frontmatter.source_imported_at),
6623
+ external_updated_at: optStr(frontmatter.source_external_updated_at),
6621
6624
  synced_at: optStr(frontmatter.source_synced_at),
6622
6625
  inferred: true,
6623
6626
  reason: `Invalid source value: "${raw}".`
@@ -8122,6 +8125,7 @@ function getWorkItem(dir, workItemId) {
8122
8125
  decisions: parseDecisions(match.decisions, knowledgeById),
8123
8126
  relatedKnowledge: parseRelatedKnowledge(fm, knowledgeById),
8124
8127
  source: parseWorkItemSource(fm),
8128
+ originalSnapshot: parseOriginalSnapshot(fm),
8125
8129
  path: match.relPath,
8126
8130
  ...parseSystemImpact(dir, fm)
8127
8131
  };
@@ -8167,6 +8171,23 @@ function parseSystemImpact(dir, fm) {
8167
8171
  const graphCoverage = topology.entities.length === 0 ? "unavailable" : topology.relationships.length > 0 ? "available" : "partial";
8168
8172
  return { affectedSystemEntities: affected, reviewedSystemEntities: reviewed, graphRevision, graphCoverage };
8169
8173
  }
8174
+ function parseOriginalSnapshot(fm) {
8175
+ const raw = fm.original_snapshot;
8176
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
8177
+ const o = raw;
8178
+ const title = typeof o.title === "string" ? o.title : void 0;
8179
+ if (!title) return null;
8180
+ return {
8181
+ title,
8182
+ description: typeof o.description === "string" ? o.description : void 0,
8183
+ type: typeof o.type === "string" ? o.type : void 0,
8184
+ status: typeof o.status === "string" ? o.status : void 0,
8185
+ labels: Array.isArray(o.labels) ? o.labels.map(String) : void 0,
8186
+ assignee: typeof o.assignee === "string" ? o.assignee : void 0,
8187
+ created_at: typeof o.created_at === "string" ? o.created_at : void 0,
8188
+ updated_at: typeof o.updated_at === "string" ? o.updated_at : void 0
8189
+ };
8190
+ }
8170
8191
  function readBody(filePath) {
8171
8192
  try {
8172
8193
  const raw = readFile(filePath);
@@ -8852,6 +8873,7 @@ function createWorkItem(dir, opts) {
8852
8873
  affected_modules: [],
8853
8874
  summary: intent
8854
8875
  };
8876
+ if (opts.originalSnapshot) data.original_snapshot = opts.originalSnapshot;
8855
8877
  const answers = opts.answers ?? {};
8856
8878
  const hasAnswers = Object.values(answers).some((v) => v?.trim());
8857
8879
  const body = hasAnswers ? captureBody(title, type, answers) : freshBody({
@@ -9422,6 +9444,10 @@ function defaultMessageFor(code) {
9422
9444
  function integrationError(code, message) {
9423
9445
  return new IntegrationError(code, message ?? defaultMessageFor(code));
9424
9446
  }
9447
+ function normalizeProviderError(err, fallback = "INTEGRATION_PROVIDER_ERROR") {
9448
+ if (err instanceof IntegrationError) return err;
9449
+ return new IntegrationError(fallback, defaultMessageFor(fallback));
9450
+ }
9425
9451
 
9426
9452
  // ../integrations/src/identity.ts
9427
9453
  function externalIdentityKey(integrationId, externalId) {
@@ -9491,6 +9517,11 @@ function parseFilters(raw) {
9491
9517
  const o = raw;
9492
9518
  const filters = {};
9493
9519
  let hasAny = false;
9520
+ const projects = toStringArray3(o.projects);
9521
+ if (projects?.length) {
9522
+ filters.projects = projects;
9523
+ hasAny = true;
9524
+ }
9494
9525
  const types = toStringArray3(o.types);
9495
9526
  if (types?.length) {
9496
9527
  filters.types = types;
@@ -9664,6 +9695,7 @@ function mergeFilters(base, overlay) {
9664
9695
  if (!base) return { ...overlay };
9665
9696
  if (!overlay) return { ...base };
9666
9697
  return {
9698
+ projects: overlay.projects?.length ? overlay.projects : base.projects,
9667
9699
  types: overlay.types?.length ? overlay.types : base.types,
9668
9700
  statuses: overlay.statuses?.length ? overlay.statuses : base.statuses,
9669
9701
  labels: overlay.labels?.length ? overlay.labels : base.labels,
@@ -10026,10 +10058,259 @@ function createMockAdapter(opts = {}) {
10026
10058
  };
10027
10059
  }
10028
10060
 
10061
+ // ../integrations/src/jira-adapter.ts
10062
+ var JIRA_ADAPTER_ID = "jira";
10063
+ function adfToMarkdown(node) {
10064
+ if (!node) return "";
10065
+ if (node.type === "text") {
10066
+ let t = node.text ?? "";
10067
+ for (const m of node.marks ?? []) {
10068
+ if (m.type === "strong") t = `**${t}**`;
10069
+ else if (m.type === "em") t = `*${t}*`;
10070
+ else if (m.type === "code") t = `\`${t}\``;
10071
+ else if (m.type === "strike") t = `~~${t}~~`;
10072
+ }
10073
+ return t;
10074
+ }
10075
+ const children = (node.content ?? []).map(adfToMarkdown).join("");
10076
+ switch (node.type) {
10077
+ case "doc":
10078
+ return children.trim();
10079
+ case "paragraph":
10080
+ return children + "\n\n";
10081
+ case "heading": {
10082
+ const level = Math.min(Number(node.attrs?.level) || 1, 6);
10083
+ return "#".repeat(level) + " " + children.trim() + "\n\n";
10084
+ }
10085
+ case "bulletList":
10086
+ return children;
10087
+ case "orderedList":
10088
+ return children;
10089
+ case "listItem":
10090
+ return "- " + children.trim() + "\n";
10091
+ case "blockquote":
10092
+ return children.split("\n").filter(Boolean).map((l) => "> " + l).join("\n") + "\n\n";
10093
+ case "codeBlock":
10094
+ return "```\n" + children + "```\n\n";
10095
+ case "rule":
10096
+ return "---\n\n";
10097
+ case "hardBreak":
10098
+ return "\n";
10099
+ case "mediaGroup":
10100
+ case "mediaSingle":
10101
+ case "media":
10102
+ return "";
10103
+ default:
10104
+ return children;
10105
+ }
10106
+ }
10107
+ function normalizeDescription(field) {
10108
+ if (!field) return void 0;
10109
+ if (typeof field === "string") return field || void 0;
10110
+ if (typeof field === "object" && field.type === "doc") {
10111
+ const md = adfToMarkdown(field);
10112
+ return md || void 0;
10113
+ }
10114
+ return void 0;
10115
+ }
10116
+ function escapeJql(value) {
10117
+ return '"' + value.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
10118
+ }
10119
+ function buildJql(filters) {
10120
+ const clauses = [];
10121
+ if (filters?.projects?.length) clauses.push(`project IN (${filters.projects.map(escapeJql).join(", ")})`);
10122
+ if (filters?.types?.length) clauses.push(`issuetype IN (${filters.types.map(escapeJql).join(", ")})`);
10123
+ if (filters?.statuses?.length) clauses.push(`status IN (${filters.statuses.map(escapeJql).join(", ")})`);
10124
+ if (filters?.labels?.length) clauses.push(`labels IN (${filters.labels.map(escapeJql).join(", ")})`);
10125
+ if (filters?.assignees?.length) clauses.push(`assignee IN (${filters.assignees.map(escapeJql).join(", ")})`);
10126
+ if (filters?.updatedAfter) clauses.push(`updated >= ${escapeJql(filters.updatedAfter)}`);
10127
+ if (filters?.search) clauses.push(`(summary ~ ${escapeJql(filters.search)} OR description ~ ${escapeJql(filters.search)})`);
10128
+ if (filters?.providerQuery) clauses.push(`(${filters.providerQuery})`);
10129
+ return clauses.join(" AND ") || "ORDER BY updated DESC";
10130
+ }
10131
+ function normalizeBaseUrl(raw) {
10132
+ let url = raw.trim();
10133
+ if (url.endsWith("/")) url = url.slice(0, -1);
10134
+ return url;
10135
+ }
10136
+ function authHeader(email, token) {
10137
+ const encoded = typeof Buffer !== "undefined" ? Buffer.from(`${email}:${token}`).toString("base64") : btoa(`${email}:${token}`);
10138
+ return `Basic ${encoded}`;
10139
+ }
10140
+ async function jiraFetch(baseUrl, path4, auth, timeoutMs, params) {
10141
+ const url = new URL(path4, baseUrl + "/");
10142
+ if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
10143
+ const controller = new AbortController();
10144
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
10145
+ try {
10146
+ const res = await fetch(url.toString(), {
10147
+ method: "GET",
10148
+ headers: { Authorization: auth, Accept: "application/json" },
10149
+ signal: controller.signal
10150
+ });
10151
+ if (res.status === 401) throw integrationError("INTEGRATION_UNAUTHORIZED");
10152
+ if (res.status === 403) throw integrationError("INTEGRATION_FORBIDDEN");
10153
+ if (res.status === 404) throw integrationError("INTEGRATION_NOT_FOUND");
10154
+ if (res.status === 429) throw integrationError("INTEGRATION_RATE_LIMITED");
10155
+ if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
10156
+ if (!res.ok) throw integrationError("INTEGRATION_PROVIDER_ERROR", `Jira responded with status ${res.status}.`);
10157
+ return await res.json();
10158
+ } catch (err) {
10159
+ if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
10160
+ throw normalizeProviderError(err);
10161
+ } finally {
10162
+ clearTimeout(timer);
10163
+ }
10164
+ }
10165
+ function normalizeIssue(issue, baseUrl, integrationId) {
10166
+ const f = issue.fields;
10167
+ const issueType = f.issuetype;
10168
+ const status = f.status;
10169
+ const assignee = f.assignee;
10170
+ const reporter = f.reporter;
10171
+ const priority = f.priority;
10172
+ const project = f.project;
10173
+ const parent = f.parent;
10174
+ const components = f.components;
10175
+ const labels = f.labels;
10176
+ return {
10177
+ externalId: issue.key,
10178
+ provider: JIRA_ADAPTER_ID,
10179
+ title: f.summary ?? issue.key,
10180
+ description: normalizeDescription(f.description),
10181
+ type: issueType?.name,
10182
+ status: status?.name,
10183
+ url: `${baseUrl}/browse/${issue.key}`,
10184
+ author: reporter ? { name: reporter.displayName, email: reporter.emailAddress, id: reporter.accountId } : void 0,
10185
+ assignees: assignee ? [{ name: assignee.displayName, email: assignee.emailAddress, id: assignee.accountId }] : void 0,
10186
+ labels,
10187
+ createdAt: f.created,
10188
+ updatedAt: f.updated,
10189
+ project: project ? { key: project.key, name: project.name, id: project.id } : void 0,
10190
+ rawMetadata: {
10191
+ ...priority?.name ? { priority: priority.name } : {},
10192
+ ...parent?.key ? { parent: parent.key } : {},
10193
+ ...components?.length ? { components: components.map((c) => c.name).filter(Boolean) } : {}
10194
+ }
10195
+ };
10196
+ }
10197
+ var SEARCH_FIELDS = "summary,description,issuetype,status,assignee,reporter,priority,labels,project,parent,components,created,updated";
10198
+ var DEFAULT_PAGE_SIZE = 50;
10199
+ var metadata = {
10200
+ id: JIRA_ADAPTER_ID,
10201
+ displayName: "Jira",
10202
+ version: "1.0.0",
10203
+ description: "Connect Jira Cloud work items to Kaddo for discovery, import and refinement.",
10204
+ icon: "jira",
10205
+ configSchema: {
10206
+ baseUrl: {
10207
+ type: "url",
10208
+ required: true,
10209
+ label: "Jira Site URL",
10210
+ description: "The URL of the Jira Cloud site.",
10211
+ placeholder: "https://company.atlassian.net"
10212
+ },
10213
+ email: {
10214
+ type: "string",
10215
+ required: true,
10216
+ label: "Email",
10217
+ description: "Email associated with the Jira API token.",
10218
+ placeholder: "user@company.com"
10219
+ }
10220
+ },
10221
+ secretSchema: {
10222
+ apiToken: {
10223
+ type: "password",
10224
+ required: true,
10225
+ label: "API Token",
10226
+ description: "Jira API token for authentication. Generate one at id.atlassian.com."
10227
+ }
10228
+ },
10229
+ filterCapabilities: {
10230
+ projects: { supported: true, multiple: true },
10231
+ types: { supported: true, multiple: true },
10232
+ statuses: { supported: true, multiple: true },
10233
+ labels: { supported: true, multiple: true },
10234
+ assignees: { supported: true, multiple: true },
10235
+ updatedAfter: { supported: true },
10236
+ search: { supported: true },
10237
+ providerQuery: { supported: true, label: "JQL" }
10238
+ }
10239
+ };
10240
+ var capabilities = {
10241
+ workItems: { list: true, read: true, import: true, write: false, statusSync: false, comments: false, webhooks: false }
10242
+ };
10243
+ function resolveConfig(context) {
10244
+ const baseUrl = context.config.baseUrl;
10245
+ const email = context.config.email;
10246
+ const apiToken = context.credentials.apiToken;
10247
+ if (typeof baseUrl !== "string" || !baseUrl) throw integrationError("INTEGRATION_CONFIG_INVALID", "Jira Site URL is required.");
10248
+ if (typeof email !== "string" || !email) throw integrationError("INTEGRATION_CONFIG_INVALID", "Email is required.");
10249
+ if (!apiToken) throw integrationError("INTEGRATION_CONFIG_INVALID", "API Token is required.");
10250
+ return { baseUrl: normalizeBaseUrl(baseUrl), email, apiToken };
10251
+ }
10252
+ function createJiraAdapter() {
10253
+ return {
10254
+ id: JIRA_ADAPTER_ID,
10255
+ metadata,
10256
+ capabilities,
10257
+ async verifyConnection(context) {
10258
+ const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
10259
+ try {
10260
+ const { baseUrl, email, apiToken } = resolveConfig(context);
10261
+ const auth = authHeader(email, apiToken);
10262
+ await jiraFetch(baseUrl, "/rest/api/3/myself", auth, context.timeoutMs);
10263
+ return { status: "available", checkedAt };
10264
+ } catch (err) {
10265
+ const ie = normalizeProviderError(err);
10266
+ if (ie.code === "INTEGRATION_UNAUTHORIZED") return { status: "unauthorized", message: "Check the configured email and API token.", checkedAt };
10267
+ if (ie.code === "INTEGRATION_CONFIG_INVALID") return { status: "invalid-config", message: ie.safeMessage, checkedAt };
10268
+ return { status: "unavailable", message: ie.safeMessage, checkedAt };
10269
+ }
10270
+ },
10271
+ async listWorkItems(request) {
10272
+ const { baseUrl, email, apiToken } = resolveConfig(request.context);
10273
+ const auth = authHeader(email, apiToken);
10274
+ const jql = buildJql(request.filters);
10275
+ const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
10276
+ const startAt = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
10277
+ try {
10278
+ const data = await jiraFetch(baseUrl, "/rest/api/3/search", auth, request.context.timeoutMs, {
10279
+ jql: jql.startsWith("ORDER BY") ? jql : jql + " ORDER BY updated DESC",
10280
+ startAt: String(startAt),
10281
+ maxResults: String(pageSize),
10282
+ fields: SEARCH_FIELDS
10283
+ });
10284
+ const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
10285
+ const nextStart = data.startAt + data.issues.length;
10286
+ const hasMore = nextStart < data.total;
10287
+ return { items, hasMore, ...hasMore ? { nextCursor: String(nextStart) } : {} };
10288
+ } catch (err) {
10289
+ throw normalizeProviderError(err);
10290
+ }
10291
+ },
10292
+ async getWorkItem(request) {
10293
+ const { baseUrl, email, apiToken } = resolveConfig(request.context);
10294
+ const auth = authHeader(email, apiToken);
10295
+ try {
10296
+ const issue = await jiraFetch(baseUrl, `/rest/api/3/issue/${encodeURIComponent(request.externalId)}`, auth, request.context.timeoutMs, {
10297
+ fields: SEARCH_FIELDS
10298
+ });
10299
+ return normalizeIssue(issue, baseUrl, request.context.integrationId);
10300
+ } catch (err) {
10301
+ const ie = normalizeProviderError(err);
10302
+ if (ie.code === "INTEGRATION_NOT_FOUND") return null;
10303
+ throw ie;
10304
+ }
10305
+ }
10306
+ };
10307
+ }
10308
+
10029
10309
  // ../integrations/src/index.ts
10030
10310
  function createDefaultRegistry() {
10031
10311
  const registry2 = new IntegrationRegistry();
10032
10312
  registry2.register(createMockAdapter());
10313
+ registry2.register(createJiraAdapter());
10033
10314
  return registry2;
10034
10315
  }
10035
10316
 
@@ -10305,6 +10586,10 @@ function updateIntegrationFilters(dir, id, filters) {
10305
10586
  if (idx < 0) throw new IntegrationServiceError("INTEGRATION_NOT_CONFIGURED", `No integration "${id}" is configured.`);
10306
10587
  const clean = {};
10307
10588
  let hasAny = false;
10589
+ if (filters.projects?.length) {
10590
+ clean.projects = filters.projects;
10591
+ hasAny = true;
10592
+ }
10308
10593
  if (filters.types?.length) {
10309
10594
  clean.types = filters.types;
10310
10595
  hasAny = true;
@@ -10339,6 +10624,7 @@ function updateIntegrationFilters(dir, id, filters) {
10339
10624
  }
10340
10625
  async function discoverExternalWorkItems(dir, opts = {}, env = process.env) {
10341
10626
  const { integrations, findings } = loadIntegrations(dir);
10627
+ const importIdx = buildImportIndex(dir);
10342
10628
  const candidates = integrations.filter((i) => {
10343
10629
  if (!i.enabled) return false;
10344
10630
  if (configStatus(i, findings) === "invalid-config") return false;
@@ -10346,6 +10632,13 @@ async function discoverExternalWorkItems(dir, opts = {}, env = process.env) {
10346
10632
  const adapter = registry.get(i.adapter);
10347
10633
  return adapter?.capabilities.workItems.list === true;
10348
10634
  });
10635
+ function enrichItems(integrationId, items) {
10636
+ return items.map((item) => {
10637
+ const linked = importIdx.get(`${integrationId}#${item.externalId}`);
10638
+ const importState = linked ? { imported: true, workItemId: linked.workItemId, title: linked.title } : { imported: false };
10639
+ return { ...item, importState };
10640
+ });
10641
+ }
10349
10642
  const settled = await Promise.allSettled(
10350
10643
  candidates.map(async (integration) => {
10351
10644
  const adapter = resolveAdapter(integration);
@@ -10360,7 +10653,7 @@ async function discoverExternalWorkItems(dir, opts = {}, env = process.env) {
10360
10653
  adapter: integration.adapter,
10361
10654
  displayName: adapter.metadata.displayName,
10362
10655
  icon: adapter.metadata.icon,
10363
- items: page.items,
10656
+ items: enrichItems(integration.id, page.items),
10364
10657
  hasMore: page.hasMore,
10365
10658
  nextCursor: page.nextCursor
10366
10659
  };
@@ -10413,6 +10706,22 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
10413
10706
  }
10414
10707
  return null;
10415
10708
  }
10709
+ function buildImportIndex(dir) {
10710
+ const index = /* @__PURE__ */ new Map();
10711
+ for (const art of discoverWorkItems(dir)) {
10712
+ let data;
10713
+ try {
10714
+ data = matter8(readFile(art.filePath)).data;
10715
+ } catch {
10716
+ continue;
10717
+ }
10718
+ const source = parseWorkItemSource(data);
10719
+ if (source.type === "external" && source.integration && source.id) {
10720
+ index.set(`${source.integration}#${source.id}`, { workItemId: String(data.id ?? ""), title: String(data.title ?? "") });
10721
+ }
10722
+ }
10723
+ return index;
10724
+ }
10416
10725
  async function previewImport(dir, id, externalId, opts = {}, env = process.env) {
10417
10726
  const item = await getExternalWorkItem(dir, id, externalId, env);
10418
10727
  if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
@@ -10437,7 +10746,18 @@ ${item.description}` : item.title;
10437
10746
  integration: id,
10438
10747
  id: externalId,
10439
10748
  url: item.url,
10440
- imported_at: (/* @__PURE__ */ new Date()).toISOString()
10749
+ imported_at: (/* @__PURE__ */ new Date()).toISOString(),
10750
+ external_updated_at: item.updatedAt
10751
+ },
10752
+ originalSnapshot: {
10753
+ title: item.title,
10754
+ description: item.description,
10755
+ type: item.type,
10756
+ status: item.status,
10757
+ labels: item.labels,
10758
+ assignee: item.assignees?.[0]?.name,
10759
+ created_at: item.createdAt,
10760
+ updated_at: item.updatedAt
10441
10761
  }
10442
10762
  });
10443
10763
  return { workItemId: created.id, created: true, preview, path: created.path };
@@ -10453,6 +10773,7 @@ export {
10453
10773
  analyzeCrossRepoEvidence,
10454
10774
  analyzeScopeCoverage,
10455
10775
  applyTopologyProposal,
10776
+ buildImportIndex,
10456
10777
  buildProjectExplanation,
10457
10778
  buildProjectRoute,
10458
10779
  buildReadinessReport,