@thinkingai/ae-cli 6.1.42 → 6.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +14 -4
  2. package/README.zh.md +14 -4
  3. package/bin/ae-cli.js +3 -0
  4. package/bin/heari/commander-LICENSE +22 -0
  5. package/bin/heari/engine.mjs +6136 -0
  6. package/bin/heari/package.json +6 -0
  7. package/bin/heari.mjs +29 -0
  8. package/cli-installation-guide.md +3 -5
  9. package/dist/{ai-monitor-E62FT3TT.js → ai-monitor-4VPHXQTL.js} +7 -6
  10. package/dist/ai-monitor.js +10 -9
  11. package/dist/{auth-SDK5OAGP.js → auth-RDSS2LUT.js} +18 -16
  12. package/dist/{automation-IMDCJUML.js → automation-VLIWG2XY.js} +5 -4
  13. package/dist/{capability-F6YWGPZZ.js → capability-CUOEIB5F.js} +5 -4
  14. package/dist/{chunk-KE5WGBXS.js → chunk-3DTMWDJX.js} +1 -1
  15. package/dist/{chunk-KAZ5FWPB.js → chunk-3FSYICDW.js} +6 -5
  16. package/dist/{chunk-ZK6KEGUR.js → chunk-3TV24AVQ.js} +10 -10
  17. package/dist/{chunk-DTODOQ6T.js → chunk-3U75VLCP.js} +1 -1
  18. package/dist/{chunk-N2QILIGH.js → chunk-4MOCV6HU.js} +1 -1
  19. package/dist/{chunk-M2OCZRVX.js → chunk-6VLHJKDD.js} +2 -2
  20. package/dist/{chunk-WG27BD67.js → chunk-7KBENPQF.js} +8 -16
  21. package/dist/{chunk-CDBW5RE6.js → chunk-BFSWGXM2.js} +3 -3
  22. package/dist/{chunk-UK7HQ4IL.js → chunk-CBNE2S44.js} +2 -2
  23. package/dist/{chunk-UWQXGF44.js → chunk-FEYZBUFQ.js} +4 -353
  24. package/dist/chunk-FKTVD63C.js +369 -0
  25. package/dist/{chunk-2H3SFJE3.js → chunk-FKVG7LOP.js} +5 -3
  26. package/dist/{chunk-GTENC5CO.js → chunk-IAZ4AMVY.js} +6 -4
  27. package/dist/{chunk-ZSKLELL7.js → chunk-LSELMDKQ.js} +2 -2
  28. package/dist/{chunk-2RORKIF6.js → chunk-NJGB4YOH.js} +2 -2
  29. package/dist/{chunk-L7MT53VM.js → chunk-PWG5IGCP.js} +1 -1
  30. package/dist/{chunk-DIYDOOBL.js → chunk-TFEGYB4X.js} +2 -2
  31. package/dist/{chunk-DZRQGI2Z.js → chunk-ZPAOEDK7.js} +5 -3
  32. package/dist/{compat-check-J5K3NO5G.js → compat-check-L3C7HCVG.js} +4 -3
  33. package/dist/{config-O3W6XLHO.js → config-LAF5MMYK.js} +6 -5
  34. package/dist/context-E4YKECC4.js +350 -0
  35. package/dist/{evaluation-OZM54MES.js → evaluation-I4IJ25CY.js} +4 -3
  36. package/dist/heari-cli-login.js +83 -0
  37. package/dist/index.js +42 -34
  38. package/dist/{memory-VPOPSU52.js → memory-Y7LPCRP4.js} +5 -4
  39. package/dist/{metadata-3GA2N27I.js → metadata-T6HYAU7E.js} +7 -6
  40. package/dist/{model-2F2354QP.js → model-2BNN72MN.js} +7 -6
  41. package/dist/{personal-semantic-preference-T2HFF2V4.js → personal-semantic-preference-WCZBOA7V.js} +42 -16
  42. package/dist/{project-semantic-WJOP2HGJ.js → project-semantic-WW5AZST3.js} +266 -17
  43. package/dist/{sync-K65X7ODO.js → sync-6PL25V42.js} +13 -12
  44. package/dist/{te-agent-QWZC36YS.js → te-agent-KXLDW4NE.js} +6 -5
  45. package/dist/{te-analysis-7E2GVKOR.js → te-analysis-KKRECQ7F.js} +311 -52
  46. package/dist/{te-community-NQNSLNON.js → te-community-6RGX7IWH.js} +8 -6
  47. package/dist/{te-dataops-PMI7UX36.js → te-dataops-RSPBC6WJ.js} +726 -220
  48. package/dist/{te-engage-EZBV5IPQ.js → te-engage-FIPP5L2Z.js} +6 -5
  49. package/dist/{te-experiment-RDB3TYBG.js → te-experiment-KQ5CBYKI.js} +86 -10
  50. package/dist/{te-kb-OWPJB243.js → te-kb-XYSDXZUG.js} +32 -11
  51. package/dist/{te-system-Z4VEB6PL.js → te-system-QSOHAP7M.js} +7 -6
  52. package/dist/{te-team-NCMN34IL.js → te-team-R6MZ4RK2.js} +6 -5
  53. package/dist/{things-UBMLTY3S.js → things-DEONFUGS.js} +6 -5
  54. package/dist/{update-LYVYF3KJ.js → update-C6G4P3C7.js} +5 -4
  55. package/dist/{web-runtime-XJWDFVP3.js → web-runtime-UGKPTBOK.js} +12 -10
  56. package/dist/{workspace-W5ZPVWJS.js → workspace-OBIIE5FN.js} +5 -4
  57. package/package.json +7 -5
  58. package/skills/ae-analysis/SKILL.md +41 -16
  59. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  60. package/skills/ae-analysis/references/adhoc_run.md +8 -2
  61. package/skills/ae-analysis/references/analysis_drilldown_contract.md +1 -1
  62. package/skills/ae-analysis/references/audience_scheduling.md +30 -0
  63. package/skills/ae-analysis/references/business_semantics_workspace.md +57 -0
  64. package/skills/ae-analysis/references/command_index.md +18 -13
  65. package/skills/ae-analysis/references/context_prepare.md +49 -0
  66. package/skills/ae-analysis/references/drilldown_entities_export.md +1 -1
  67. package/skills/ae-analysis/references/drilldown_entities_run.md +1 -1
  68. package/skills/ae-analysis/references/drilldown_user_events_export.md +3 -1
  69. package/skills/ae-analysis/references/drilldown_user_events_run.md +2 -1
  70. package/skills/ae-analysis/references/governance_recommendation_export.md +1 -1
  71. package/skills/ae-analysis/references/personal_semantic_preference_add.md +5 -1
  72. package/skills/ae-analysis/references/personal_semantic_preference_get.md +4 -2
  73. package/skills/ae-analysis/references/personal_semantic_preference_list.md +7 -6
  74. package/skills/ae-analysis/references/personal_semantic_preference_submit.md +1 -1
  75. package/skills/ae-analysis/references/personal_semantic_preference_update.md +5 -1
  76. package/skills/ae-analysis/references/project_info_get.md +4 -0
  77. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +1 -1
  78. package/skills/ae-analysis/references/project_semantic_setup.md +60 -0
  79. package/skills/ae-analysis/references/report_get.md +2 -0
  80. package/skills/ae-analysis/references/report_presentation.md +55 -0
  81. package/skills/ae-analysis/references/report_update.md +4 -2
  82. package/skills/ae-analysis/references/system_openapi_token_batch_generate.md +20 -0
  83. package/skills/ae-analysis/references/system_openapi_token_get.md +14 -0
  84. package/skills/ae-analysis/references/user_cluster_create.md +3 -1
  85. package/skills/ae-analysis/references/user_cluster_models.md +2 -0
  86. package/skills/ae-analysis/references/user_cluster_update.md +5 -3
  87. package/skills/ae-analysis/references/user_tag_create.md +4 -22
  88. package/skills/ae-analysis/references/user_tag_models.md +8 -0
  89. package/skills/ae-analysis/references/user_tag_update.md +6 -14
  90. package/skills/ae-analysis/scripts/read-semantic-catalog.mjs +40 -0
  91. package/skills/ae-capability/SKILL.md +5 -1
  92. package/skills/ae-dataops/SKILL.md +9 -6
  93. package/skills/ae-dataops/references/dataops-flow-create.md +64 -47
  94. package/skills/ae-dataops/references/dataops-flow-monitor.md +4 -2
  95. package/skills/ae-dataops/references/dataops-flow-python.md +109 -0
  96. package/skills/ae-experiment/SKILL.md +9 -1
  97. package/skills/ae-experiment/references/manage_feature_fixed_value.md +73 -0
  98. package/skills/ae-experiment/references/save_feature.md +14 -1
  99. package/skills/ae-heari-research/SKILL.md +40 -0
  100. package/skills/ae-heari-research/references/design.md +35 -0
  101. package/skills/ae-heari-research/references/examples.md +46 -0
  102. package/skills/ae-heari-research/references/platform-auth.md +35 -0
  103. package/skills/ae-heari-research/references/platform-research.md +74 -0
  104. package/skills/ae-heari-research/references/platform-results.md +73 -0
  105. package/skills/ae-heari-research/references/platform.md +34 -0
  106. package/skills/ae-heari-research/references/probing-screening.md +31 -0
  107. package/skills/ae-heari-research/references/quality.md +44 -0
  108. package/skills/ae-kb/SKILL.md +10 -5
  109. package/skills/ae-kb/references/analysis-workflow.md +19 -10
  110. package/skills/ae-kb/references/query-workflow.md +34 -17
  111. package/skills/ae-kb-discovery/SKILL.md +4 -3
  112. package/skills/ae-onboarding/SKILL.md +3 -3
  113. package/dist/context-WJQGJD6F.js +0 -139
  114. package/dist/{data-integration-KMJWYAKK.js → data-integration-SCYYZLWI.js} +4 -4
@@ -3,22 +3,24 @@ import {
3
3
  assertOutputPathAvailable,
4
4
  downloadAnalysisArtifact,
5
5
  withAsyncArtifactLifecycle
6
- } from "./chunk-ZSKLELL7.js";
6
+ } from "./chunk-LSELMDKQ.js";
7
7
  import {
8
8
  registerCapabilityGatewayRoute,
9
9
  resolveGatewayDomain
10
10
  } from "./chunk-AWW2T2WL.js";
11
11
  import {
12
+ unwrapOutputData,
12
13
  withOutputMetadata
13
- } from "./chunk-N2QILIGH.js";
14
- import "./chunk-GTENC5CO.js";
14
+ } from "./chunk-4MOCV6HU.js";
15
+ import "./chunk-IAZ4AMVY.js";
15
16
  import {
16
17
  CapabilityGatewayError,
17
18
  dryRunCapabilityWithEnvelope,
18
19
  executeCapabilityWithEnvelope,
19
20
  validateCapabilityWithEnvelope
20
- } from "./chunk-WG27BD67.js";
21
- import "./chunk-UWQXGF44.js";
21
+ } from "./chunk-7KBENPQF.js";
22
+ import "./chunk-FKTVD63C.js";
23
+ import "./chunk-FEYZBUFQ.js";
22
24
  import "./chunk-IGU3R2JD.js";
23
25
  import "./chunk-MTK4ZE7W.js";
24
26
  import "./chunk-3ZQY7SLZ.js";
@@ -207,7 +209,7 @@ async function verifyDetailLocators(root, schemaVersion) {
207
209
  await verifyContentLocator(root, detail.raw_locator, "Raw detail", { skipHash: schemaVersion === "3.0" });
208
210
  }
209
211
  }
210
- async function verifyContentLocator(root, value, label, options = {}) {
212
+ async function verifyContentLocator(root, value, label, options2 = {}) {
211
213
  const locator = asObject(value);
212
214
  if (!locator || typeof locator.path !== "string" || typeof locator.content_hash !== "string" || !SHA256_PATTERN.test(locator.content_hash)) {
213
215
  throw packageError(
@@ -223,7 +225,7 @@ async function verifyContentLocator(root, value, label, options = {}) {
223
225
  if (!content) {
224
226
  throw packageError(`${label} file is not a JSON object: ${locator.path}.`, "ASSET_PACKAGE_MANIFEST_INVALID");
225
227
  }
226
- if (!options.skipHash) {
228
+ if (!options2.skipHash) {
227
229
  const actualHash = createHash("sha256").update(JSON.stringify(content), "utf8").digest("hex");
228
230
  if (actualHash !== locator.content_hash) {
229
231
  throw packageError(`${label} content hash mismatch for ${locator.path}.`, "ASSET_PACKAGE_HASH_MISMATCH");
@@ -291,15 +293,40 @@ function packageError(message, code) {
291
293
 
292
294
  // src/commands/project-semantic/asset-package/export.ts
293
295
  var ASSET_PACKAGE_EXPORT_CAPABILITY = "business_semantics.asset_package.export";
294
- var ASSET_SCOPES = /* @__PURE__ */ new Set(["governed", "collaborative", "all_visible"]);
296
+ var ASSET_SCOPES = /* @__PURE__ */ new Set(["governed", "collaborative", "all_visible", "certified", "frequent", "all", "specified"]);
295
297
  var GATEWAY_DOMAIN = "analysis";
296
298
  function assetScope(ctx) {
297
299
  const value = ctx.str("asset-scope") || "governed";
298
300
  if (!ASSET_SCOPES.has(value)) {
299
- throw new Error("asset-scope must be one of: governed, collaborative, all_visible");
301
+ throw new Error(
302
+ "asset-scope must be one of: governed, collaborative, all_visible, certified, frequent, all, specified"
303
+ );
300
304
  }
301
305
  return value;
302
306
  }
307
+ function buildAssetPackageInput(ctx) {
308
+ const scope = assetScope(ctx);
309
+ const refs = ctx.json("asset-refs");
310
+ if (scope === "specified") {
311
+ if (!Array.isArray(refs) || refs.length < 1 || refs.length > 1e3)
312
+ throw new Error("specified scope requires 1 to 1000 asset-refs.");
313
+ const seen = /* @__PURE__ */ new Set();
314
+ for (const ref of refs) {
315
+ if (!ref || typeof ref !== "object" || Array.isArray(ref) || Object.keys(ref).length !== 2 || !["dashboard", "report", "metric", "event", "event_prop", "user_prop", "user_tag", "user_cluster"].includes(
316
+ ref.resource_type
317
+ ) || typeof ref.resource_key !== "string" || !ref.resource_key.trim())
318
+ throw new Error("Each asset reference requires a supported resource_type and a non-empty string resource_key.");
319
+ const key = `${ref.resource_type}:${ref.resource_key}`;
320
+ if (seen.has(key)) throw new Error("Duplicate asset reference.");
321
+ seen.add(key);
322
+ }
323
+ } else if (refs !== void 0 && refs !== null) throw new Error("asset-refs is only supported for specified scope.");
324
+ return {
325
+ project_id: ctx.num("project-id"),
326
+ asset_scope: scope,
327
+ ...refs ? { asset_refs: refs } : {}
328
+ };
329
+ }
303
330
  var assetPackageExportCommand = {
304
331
  service: "project-semantic",
305
332
  resource: "asset-package",
@@ -307,12 +334,24 @@ var assetPackageExportCommand = {
307
334
  description: "Export and materialize a knowledge-ready project asset package for CLI Agent consumption.",
308
335
  helpText: "Requires access to the target project. Explicit asset-package export is independent of automatic knowledge-base discovery.",
309
336
  flags: [
310
- { name: "project-id", type: "number", required: true, desc: "Numeric project ID.", alias: "p", min: 1 },
337
+ {
338
+ name: "project-id",
339
+ type: "number",
340
+ required: true,
341
+ desc: "Numeric project ID.",
342
+ alias: "p",
343
+ min: 1
344
+ },
311
345
  {
312
346
  name: "asset-scope",
313
347
  type: "string",
314
348
  required: false,
315
- desc: "Asset scope: governed, collaborative, or all_visible. Defaults to governed."
349
+ desc: "Legacy scopes: governed (default), collaborative, all_visible. Manager setup scopes: certified, frequent (positive 90-day query count, ranked), all, specified."
350
+ },
351
+ {
352
+ name: "asset-refs",
353
+ type: "json",
354
+ desc: "Exact [{resource_type,resource_key}] references for specified scope; JSON or @file. Keys must be strings."
316
355
  }
317
356
  ],
318
357
  risk: "read",
@@ -320,22 +359,20 @@ var assetPackageExportCommand = {
320
359
  ctx.host(),
321
360
  resolveGatewayDomain(GATEWAY_DOMAIN, GATEWAY_DOMAIN),
322
361
  ASSET_PACKAGE_EXPORT_CAPABILITY,
323
- { project_id: ctx.num("project-id"), asset_scope: assetScope(ctx) }
362
+ buildAssetPackageInput(ctx)
324
363
  ).then((response) => withOutputMetadata(response.data, response.meta)),
325
364
  dryRun: (ctx) => dryRunCapabilityWithEnvelope(
326
365
  ctx.host(),
327
366
  resolveGatewayDomain(GATEWAY_DOMAIN, GATEWAY_DOMAIN),
328
367
  ASSET_PACKAGE_EXPORT_CAPABILITY,
329
- { project_id: ctx.num("project-id"), asset_scope: assetScope(ctx) }
368
+ buildAssetPackageInput(ctx)
330
369
  ).then((response) => withOutputMetadata(response.data, response.meta)),
331
370
  execute: async (ctx) => {
332
- const projectId = ctx.num("project-id");
333
- const scope = assetScope(ctx);
334
371
  const response = await executeCapabilityWithEnvelope(
335
372
  ctx.host(),
336
373
  resolveGatewayDomain(GATEWAY_DOMAIN, GATEWAY_DOMAIN),
337
374
  ASSET_PACKAGE_EXPORT_CAPABILITY,
338
- { project_id: projectId, asset_scope: scope }
375
+ buildAssetPackageInput(ctx)
339
376
  );
340
377
  return withOutputMetadata(response.data, response.meta);
341
378
  }
@@ -345,13 +382,225 @@ var projectSemanticAssetPackageExport = withAsyncArtifactLifecycle(assetPackageE
345
382
  materialize: materializeProjectSemanticAssetPackage
346
383
  });
347
384
 
385
+ // src/commands/project-semantic/setup.ts
386
+ import { createHash as createHash2 } from "crypto";
387
+ import { mkdir as mkdir2, readFile as readFile2, stat as stat2, writeFile as writeFile2 } from "fs/promises";
388
+ import { basename as basename2, resolve as resolve2 } from "path";
389
+ var scopes = /* @__PURE__ */ new Set(["none", "certified", "frequent", "all", "specified"]);
390
+ function options(ctx) {
391
+ const scope = ctx.str("asset-scope") || "certified";
392
+ if (!scopes.has(scope)) throw new Error("asset-scope must be none, certified, frequent, all, or specified.");
393
+ const materials = ctx.json("materials");
394
+ if (materials !== void 0 && (!Array.isArray(materials) || materials.some((file) => typeof file !== "string" || !file.trim())))
395
+ throw new Error("materials must be an array of local file paths.");
396
+ if (scope === "none" && (!Array.isArray(materials) || !materials.length))
397
+ throw new Error("Provide materials or select an asset scope.");
398
+ const output = ctx.str("output");
399
+ if (!output) throw new Error("output must name a new private setup directory.");
400
+ if (!Number.isInteger(ctx.num("project-id")) || ctx.num("project-id") <= 0)
401
+ throw new Error("project-id must be a positive integer.");
402
+ if (scope !== "none")
403
+ buildAssetPackageInput({
404
+ ...ctx,
405
+ str: (name) => name === "asset-scope" ? scope : ctx.str(name)
406
+ });
407
+ else if (ctx.json("asset-refs") !== void 0) throw new Error("asset-refs requires specified asset scope.");
408
+ return {
409
+ scope,
410
+ materials: materials || [],
411
+ output: resolve2(output)
412
+ };
413
+ }
414
+ var reference = "skills/ae-analysis/references/project_semantic_setup.md";
415
+ var nextSteps = [
416
+ "Read the complete retained semantic catalogs with the bundled catalog pager; do not mark use during management.",
417
+ "Read every input material and the selected asset indexes; inspect exact definitions and necessary dependencies. File inventory is not evidence extraction.",
418
+ "Synthesize one project background draft, distinct semantic candidates, source locators, conflicts and unanswered questions. Do not mechanically create one entry per file or asset.",
419
+ "Read likely existing matches by exact ID without marking use; propose CREATE, UPDATE or KEEP with scope, revision and source evidence.",
420
+ "Present all proposed writes for user confirmation. Persist an approved local import plan and reuse unchanged request IDs when resuming.",
421
+ "Save confirmed project entries through existing project_context capabilities and the background as a draft. Publish background only with separate explicit intent."
422
+ ];
423
+ var projectSemanticSetup = {
424
+ service: "project-semantic",
425
+ command: "setup",
426
+ description: "Prepare a private evidence workspace for the CLI Agent project-semantics setup workflow; never generates or saves business facts automatically.",
427
+ helpText: `This read-only L1 workflow reuses asset-package export and existing background/catalog reads. Continue with ${reference}.`,
428
+ risk: "read",
429
+ sensitiveOutput: true,
430
+ flags: [
431
+ {
432
+ name: "project-id",
433
+ type: "number",
434
+ required: true,
435
+ min: 1,
436
+ desc: "Target project ID; semantic management permission is required."
437
+ },
438
+ {
439
+ name: "asset-scope",
440
+ type: "string",
441
+ desc: "certified (default), frequent, all, specified, or none for materials only. frequent uses positive query counts from the latest 90-day usage snapshot."
442
+ },
443
+ {
444
+ name: "asset-refs",
445
+ type: "json",
446
+ desc: "Exact asset references for specified scope; resolve supplied names or links before running."
447
+ },
448
+ {
449
+ name: "materials",
450
+ type: "json",
451
+ sensitive: true,
452
+ desc: "Optional array of local source file paths. The command inventories bytes; the calling Agent reads and interprets them."
453
+ },
454
+ {
455
+ name: "output",
456
+ type: "string",
457
+ required: true,
458
+ desc: "New private evidence directory. Existing directories are refused; retain it for review and recovery."
459
+ }
460
+ ],
461
+ validate: (ctx) => {
462
+ options(ctx);
463
+ },
464
+ dryRun: async (ctx) => ({
465
+ workflow: "project_semantic_setup",
466
+ project_id: ctx.num("project-id"),
467
+ asset_scope: options(ctx).scope,
468
+ remote_writes: false,
469
+ agent_synthesis_required: true,
470
+ reference
471
+ }),
472
+ execute: async (ctx) => {
473
+ const selected = options(ctx);
474
+ try {
475
+ await stat2(selected.output);
476
+ throw new Error("Setup output already exists. Continue from its manifest or choose another output directory.");
477
+ } catch (error) {
478
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
479
+ }
480
+ const materials = [];
481
+ for (const file of selected.materials) {
482
+ const path = resolve2(file);
483
+ const info = await stat2(path);
484
+ if (!info.isFile() || info.size > 20 * 1024 * 1024)
485
+ throw new Error("Each material must be a regular file no larger than 20 MiB.");
486
+ const bytes = await readFile2(path);
487
+ materials.push({
488
+ path,
489
+ name: basename2(path),
490
+ bytes: bytes.length,
491
+ sha256: createHash2("sha256").update(bytes).digest("hex"),
492
+ parse_status: "not_read_by_agent"
493
+ });
494
+ }
495
+ const call = async (operation, projectId) => (await executeCapabilityWithEnvelope(ctx.host(), "analysis", `business_semantics.${operation}`, {
496
+ project_id: projectId
497
+ })).data;
498
+ const company = await call("background.get", 0);
499
+ const project = await call("background.get", ctx.num("project-id"));
500
+ const draft = await call("background.draft_get", ctx.num("project-id"));
501
+ const globalPersonal = await call("global_personal_context.list", -1);
502
+ const personal = await call("personal_context.list", ctx.num("project-id"));
503
+ const publicCatalog = await call("project_context.list", ctx.num("project-id"));
504
+ for (const catalog of [globalPersonal, personal, publicCatalog]) {
505
+ if (catalog?.complete !== true || catalog.truncated === true || !Array.isArray(catalog.items) || catalog.items.length !== catalog.total) {
506
+ throw new Error("A complete semantic catalog is required; do not silently continue with partial evidence.");
507
+ }
508
+ const seen = /* @__PURE__ */ new Set();
509
+ for (const row of catalog.items) {
510
+ if (!row || typeof row.id !== "string" || typeof row.title !== "string" || typeof row.summary !== "string" || !Number.isSafeInteger(row.revision) || seen.has(row.id) || row.keywords !== void 0 && (!Array.isArray(row.keywords) || row.keywords.some((keyword) => typeof keyword !== "string"))) {
511
+ throw new Error("Catalog row identity, revision, summary or keywords is invalid.");
512
+ }
513
+ seen.add(row.id);
514
+ }
515
+ }
516
+ await mkdir2(selected.output, { recursive: false, mode: 448 });
517
+ const save = (name, data) => writeFile2(resolve2(selected.output, name), JSON.stringify(data, null, 2) + "\n", { flag: "wx", mode: 384 });
518
+ await save("context.json", {
519
+ company_background: company,
520
+ project_background: project,
521
+ project_draft: draft
522
+ });
523
+ await save("global-personal-catalog.json", {
524
+ ok: true,
525
+ data: globalPersonal
526
+ });
527
+ await save("project-personal-catalog.json", { ok: true, data: personal });
528
+ await save("project-public-catalog.json", {
529
+ ok: true,
530
+ data: publicCatalog
531
+ });
532
+ await save("materials.json", materials);
533
+ const pending = {
534
+ workflow: "project_semantic_setup",
535
+ status: "preparing_assets",
536
+ project_id: ctx.num("project-id"),
537
+ asset_scope: selected.scope,
538
+ remote_writes: false,
539
+ agent_synthesis_required: true,
540
+ reference
541
+ };
542
+ await save("setup.json", pending);
543
+ let assetPackage;
544
+ try {
545
+ if (selected.scope !== "none") {
546
+ const packageContext = {
547
+ ...ctx,
548
+ str: (name) => name === "asset-scope" ? selected.scope : name === "output" ? resolve2(selected.output, "assets") : ctx.str(name),
549
+ bool: (name) => name === "force" ? false : ctx.bool(name)
550
+ };
551
+ assetPackage = unwrapOutputData(await projectSemanticAssetPackageExport.execute(packageContext));
552
+ const manifest2 = JSON.parse(await readFile2(resolve2(selected.output, "assets", "manifest.json"), "utf8"));
553
+ if (manifest2.truncated === true || manifest2.project_id !== ctx.num("project-id") || manifest2.asset_scope !== selected.scope)
554
+ throw new Error(
555
+ "Exported asset evidence is partial or belongs to another project/scope. Keep the workspace for diagnosis; do not synthesize from it."
556
+ );
557
+ }
558
+ } catch (error) {
559
+ await writeFile2(
560
+ resolve2(selected.output, "setup.json"),
561
+ JSON.stringify(
562
+ {
563
+ ...pending,
564
+ status: "evidence_failed",
565
+ failed_step: "asset_export",
566
+ ...error instanceof CapabilityGatewayError ? {
567
+ error_code: error.code,
568
+ ...typeof error.meta?.run_id === "string" ? { run_id: error.meta.run_id } : {},
569
+ ...typeof error.meta?.artifact_id === "string" ? { artifact_id: error.meta.artifact_id } : {}
570
+ } : {}
571
+ },
572
+ null,
573
+ 2
574
+ ) + "\n",
575
+ { mode: 384 }
576
+ );
577
+ throw error;
578
+ }
579
+ const manifest = {
580
+ workflow: "project_semantic_setup",
581
+ status: "evidence_ready",
582
+ project_id: ctx.num("project-id"),
583
+ asset_scope: selected.scope,
584
+ materials: materials.length,
585
+ asset_package: assetPackage,
586
+ remote_writes: false,
587
+ agent_synthesis_required: true,
588
+ reference,
589
+ next_steps: nextSteps
590
+ };
591
+ await writeFile2(resolve2(selected.output, "setup.json"), JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
592
+ return { ...manifest, output_path: selected.output };
593
+ }
594
+ };
595
+
348
596
  // src/commands/project-semantic/index.ts
349
597
  registerCapabilityGatewayRoute("project-semantic", {
350
598
  gatewayDomain: "analysis",
351
599
  capabilityPrefixes: ["business_semantics.asset_package"]
352
600
  });
353
601
  var commands = [
354
- projectSemanticAssetPackageExport
602
+ projectSemanticAssetPackageExport,
603
+ projectSemanticSetup
355
604
  ];
356
605
  var project_semantic_default = commands;
357
606
  export {
@@ -17,6 +17,14 @@ import {
17
17
  import {
18
18
  assertLegacyWorkspaceCommand
19
19
  } from "./chunk-RK6GLDGI.js";
20
+ import {
21
+ TeAgentApiError,
22
+ TeAgentCredentialsError,
23
+ getSandboxSyncPullCandidates,
24
+ postSandboxSyncPull,
25
+ postToMainApp,
26
+ uploadToMainApp
27
+ } from "./chunk-3DTMWDJX.js";
20
28
  import {
21
29
  require_lib
22
30
  } from "./chunk-EQMGH32F.js";
@@ -28,18 +36,11 @@ import {
28
36
  } from "./chunk-7K24F7T2.js";
29
37
  import {
30
38
  printError
31
- } from "./chunk-N2QILIGH.js";
32
- import {
33
- TeAgentApiError,
34
- TeAgentCredentialsError,
35
- getSandboxSyncPullCandidates,
36
- postSandboxSyncPull,
37
- postToMainApp,
38
- uploadToMainApp
39
- } from "./chunk-KE5WGBXS.js";
40
- import "./chunk-GTENC5CO.js";
41
- import "./chunk-WG27BD67.js";
42
- import "./chunk-UWQXGF44.js";
39
+ } from "./chunk-4MOCV6HU.js";
40
+ import "./chunk-IAZ4AMVY.js";
41
+ import "./chunk-7KBENPQF.js";
42
+ import "./chunk-FKTVD63C.js";
43
+ import "./chunk-FEYZBUFQ.js";
43
44
  import "./chunk-IGU3R2JD.js";
44
45
  import "./chunk-MTK4ZE7W.js";
45
46
  import {
@@ -11,7 +11,7 @@ import {
11
11
  workspaceResourcePath,
12
12
  workspaceTargetFlags,
13
13
  workspaceTargetPath
14
- } from "./chunk-2RORKIF6.js";
14
+ } from "./chunk-NJGB4YOH.js";
15
15
  import {
16
16
  currentAgentSpaceId
17
17
  } from "./chunk-RK6GLDGI.js";
@@ -27,19 +27,20 @@ import {
27
27
  requestResourcePackageRaw,
28
28
  resourcePackagePreflightChange,
29
29
  uploadAgentApi
30
- } from "./chunk-UK7HQ4IL.js";
30
+ } from "./chunk-CBNE2S44.js";
31
31
  import {
32
32
  TeAgentApiError,
33
33
  resolveTeClaudeBaseUrl
34
- } from "./chunk-KE5WGBXS.js";
34
+ } from "./chunk-3DTMWDJX.js";
35
35
  import {
36
36
  buildCapabilityGatewayUrl,
37
37
  callCapabilityApi
38
- } from "./chunk-WG27BD67.js";
38
+ } from "./chunk-7KBENPQF.js";
39
39
  import {
40
40
  clearCliTokenCache,
41
41
  getCliToken
42
- } from "./chunk-UWQXGF44.js";
42
+ } from "./chunk-FKTVD63C.js";
43
+ import "./chunk-FEYZBUFQ.js";
43
44
  import {
44
45
  getConfigDir
45
46
  } from "./chunk-IGU3R2JD.js";