@diafunc/cli 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-NSFXPO66.js";
3
+ } from "./chunk-GIWRWVU6.js";
4
4
 
5
5
  // src/index.ts
6
6
  import { Command } from "commander";
@@ -1531,6 +1531,27 @@ function createStorageService(client) {
1531
1531
  path: `/table-exports/supported-formats`
1532
1532
  });
1533
1533
  },
1534
+ /** List all async exports for an entity (see ExportsResource#getExports). */
1535
+ async listExports(ref) {
1536
+ return client.request({
1537
+ method: "GET",
1538
+ service: SERVICE3,
1539
+ path: `/exports${entityPath(ref)}`
1540
+ });
1541
+ },
1542
+ /**
1543
+ * Download the bytes of a completed async export.
1544
+ * Path mirrors ExportsResource#getContent: /exports/{entity}/{exportId}/{filename}.
1545
+ * The {filename} segment is part of the server URL but is not used for lookup —
1546
+ * only exportId determines the row; pass StorageExport.filename verbatim.
1547
+ */
1548
+ async downloadExport(ref, exportId, filename) {
1549
+ return client.requestRaw({
1550
+ method: "GET",
1551
+ service: SERVICE3,
1552
+ path: `/exports${entityPath(ref)}/${enc(exportId)}/${enc(filename)}`
1553
+ });
1554
+ },
1534
1555
  // --- Branches ---
1535
1556
  async getProjectBranches(projectId) {
1536
1557
  return client.request({
@@ -2707,8 +2728,31 @@ function registerProjectCommands(program) {
2707
2728
  }
2708
2729
 
2709
2730
  // src/commands/entity/index.ts
2710
- import chalk10 from "chalk";
2731
+ import chalk11 from "chalk";
2711
2732
  import * as fs3 from "fs";
2733
+
2734
+ // src/util/confirm.ts
2735
+ import * as readline from "readline";
2736
+ import chalk10 from "chalk";
2737
+ async function confirmDestructive(message, opts = {}) {
2738
+ if (!process.stdin.isTTY || opts.yes) return;
2739
+ const expected = opts.resourceId ?? "yes";
2740
+ const hint = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
2741
+ console.log(chalk10.yellow(`! ${message}`));
2742
+ const answer = await new Promise((resolve) => {
2743
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2744
+ rl.question(` Type ${hint} to confirm: `, (ans) => {
2745
+ rl.close();
2746
+ resolve(ans);
2747
+ });
2748
+ });
2749
+ if (answer.trim() !== expected) {
2750
+ console.log(chalk10.dim("Aborted."));
2751
+ process.exit(1);
2752
+ }
2753
+ }
2754
+
2755
+ // src/commands/entity/index.ts
2712
2756
  function getOutputFormat2(cmd) {
2713
2757
  const config = loadConfig();
2714
2758
  const globalOpts = cmd.optsWithGlobals();
@@ -2778,13 +2822,14 @@ function registerEntityCommands(program) {
2778
2822
  handleError(error);
2779
2823
  }
2780
2824
  });
2781
- entity.command("delete").description("Delete an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
2825
+ entity.command("delete").description("Delete an entity").argument("<ref>", "Entity reference").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (ref, options, cmd) => {
2782
2826
  try {
2827
+ await confirmDestructive(`This will permanently delete entity "${ref}".`, { yes: options.yes, resourceId: ref });
2783
2828
  const overrides = getOverrides2(cmd);
2784
2829
  const resolved = parseEntityReference(ref, overrides);
2785
2830
  const api = createApiClient();
2786
2831
  await api.storage.deleteEntity(resolved);
2787
- console.log(chalk10.green(`Entity "${resolved.entityId}" deleted.`));
2832
+ console.log(chalk11.green(`Entity "${resolved.entityId}" deleted.`));
2788
2833
  } catch (error) {
2789
2834
  handleError(error);
2790
2835
  }
@@ -2825,7 +2870,7 @@ function registerEntityCommands(program) {
2825
2870
  const resolved = parseEntityReference(ref, overrides);
2826
2871
  const api = createApiClient();
2827
2872
  await api.storage.revertEntity(resolved, parseInt(version, 10));
2828
- console.log(chalk10.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
2873
+ console.log(chalk11.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
2829
2874
  } catch (error) {
2830
2875
  handleError(error);
2831
2876
  }
@@ -2836,7 +2881,7 @@ function registerEntityCommands(program) {
2836
2881
  const resolved = parseEntityReference(ref, overrides);
2837
2882
  const api = createApiClient();
2838
2883
  await api.storage.renameEntity(resolved, newId);
2839
- console.log(chalk10.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
2884
+ console.log(chalk11.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
2840
2885
  } catch (error) {
2841
2886
  handleError(error);
2842
2887
  }
@@ -2851,7 +2896,7 @@ function registerEntityCommands(program) {
2851
2896
  if (options.out) {
2852
2897
  const buffer = Buffer.from(await response.arrayBuffer());
2853
2898
  fs3.writeFileSync(options.out, buffer);
2854
- console.log(chalk10.green(`Content saved to ${options.out}`));
2899
+ console.log(chalk11.green(`Content saved to ${options.out}`));
2855
2900
  } else {
2856
2901
  const text = await response.text();
2857
2902
  process.stdout.write(text);
@@ -2868,18 +2913,19 @@ function registerEntityCommands(program) {
2868
2913
  const fileBuffer = fs3.readFileSync(file);
2869
2914
  const base64 = fileBuffer.toString("base64");
2870
2915
  await api.storage.saveEntityContentBase64(resolved, base64);
2871
- console.log(chalk10.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
2916
+ console.log(chalk11.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
2872
2917
  } catch (error) {
2873
2918
  handleError(error);
2874
2919
  }
2875
2920
  });
2876
- content.command("delete").description("Delete entity content").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
2921
+ content.command("delete").description("Delete entity content").argument("<ref>", "Entity reference").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (ref, options, cmd) => {
2877
2922
  try {
2923
+ await confirmDestructive(`This will permanently delete the content of entity "${ref}".`, { yes: options.yes, resourceId: ref });
2878
2924
  const overrides = getOverrides2(cmd);
2879
2925
  const resolved = parseEntityReference(ref, overrides);
2880
2926
  const api = createApiClient();
2881
2927
  await api.storage.deleteEntityContent(resolved);
2882
- console.log(chalk10.green(`Content deleted from entity "${resolved.entityId}".`));
2928
+ console.log(chalk11.green(`Content deleted from entity "${resolved.entityId}".`));
2883
2929
  } catch (error) {
2884
2930
  handleError(error);
2885
2931
  }
@@ -2892,14 +2938,14 @@ function registerEntityCommands(program) {
2892
2938
  const request = { rootEntityIds: entityIds, dataFormat: options.data };
2893
2939
  if (options.async) {
2894
2940
  const bundleId = await api.storage.exportEntitySubset(ref.projectId, ref.projectBranch, request);
2895
- console.log(chalk10.green(`Export queued (bundle ID: ${bundleId}).`));
2941
+ console.log(chalk11.green(`Export queued (bundle ID: ${bundleId}).`));
2896
2942
  console.log(`Poll progress: diafunc notebook bundles ${project}`);
2897
2943
  return;
2898
2944
  }
2899
2945
  const response = await api.storage.streamEntitySubset(ref.projectId, ref.projectBranch, request);
2900
2946
  const outFile = options.out ?? "entities.dfset";
2901
2947
  const bytes = await streamResponseToFile(response, outFile);
2902
- console.log(chalk10.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
2948
+ console.log(chalk11.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
2903
2949
  } catch (error) {
2904
2950
  handleError(error);
2905
2951
  }
@@ -2918,7 +2964,7 @@ function registerEntityCommands(program) {
2918
2964
  }
2919
2965
 
2920
2966
  // src/commands/link/index.ts
2921
- import chalk11 from "chalk";
2967
+ import chalk12 from "chalk";
2922
2968
  function getOutputFormat3(cmd) {
2923
2969
  const config = loadConfig();
2924
2970
  const globalOpts = cmd.optsWithGlobals();
@@ -2968,7 +3014,7 @@ function registerLinkCommands(program) {
2968
3014
  target.entityId,
2969
3015
  target.entityBranch
2970
3016
  );
2971
- console.log(chalk11.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
3017
+ console.log(chalk12.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
2972
3018
  } catch (error) {
2973
3019
  handleError(error);
2974
3020
  }
@@ -2989,7 +3035,7 @@ function registerLinkCommands(program) {
2989
3035
  target.entityId,
2990
3036
  target.entityBranch
2991
3037
  );
2992
- console.log(chalk11.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
3038
+ console.log(chalk12.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
2993
3039
  } else {
2994
3040
  await api.storage.deleteLink(
2995
3041
  source.projectId,
@@ -2998,7 +3044,7 @@ function registerLinkCommands(program) {
2998
3044
  source.entityBranch,
2999
3045
  linkId
3000
3046
  );
3001
- console.log(chalk11.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
3047
+ console.log(chalk12.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
3002
3048
  }
3003
3049
  } catch (error) {
3004
3050
  handleError(error);
@@ -3007,7 +3053,7 @@ function registerLinkCommands(program) {
3007
3053
  }
3008
3054
 
3009
3055
  // src/commands/event/index.ts
3010
- import chalk12 from "chalk";
3056
+ import chalk13 from "chalk";
3011
3057
  function getOutputFormat4(cmd) {
3012
3058
  const config = loadConfig();
3013
3059
  const globalOpts = cmd.optsWithGlobals();
@@ -3069,7 +3115,7 @@ function registerEventCommands(program) {
3069
3115
  const api = createApiClient();
3070
3116
  const arr = Array.isArray(events) ? events : [events];
3071
3117
  await api.storage.createEvents(arr);
3072
- console.log(chalk12.green(`${arr.length} event(s) created.`));
3118
+ console.log(chalk13.green(`${arr.length} event(s) created.`));
3073
3119
  } catch (error) {
3074
3120
  handleError(error);
3075
3121
  }
@@ -3096,7 +3142,7 @@ function registerEventCommands(program) {
3096
3142
  const resolved = parseEntityReference(ref, overrides);
3097
3143
  const api = createApiClient();
3098
3144
  await api.storage.deleteEvent(resolved, eventId, occurrenceId);
3099
- console.log(chalk12.green(`Event "${eventId}/${occurrenceId}" deleted.`));
3145
+ console.log(chalk13.green(`Event "${eventId}/${occurrenceId}" deleted.`));
3100
3146
  } catch (error) {
3101
3147
  handleError(error);
3102
3148
  }
@@ -3104,7 +3150,7 @@ function registerEventCommands(program) {
3104
3150
  }
3105
3151
 
3106
3152
  // src/commands/branch/index.ts
3107
- import chalk13 from "chalk";
3153
+ import chalk14 from "chalk";
3108
3154
  function getOutputFormat5(cmd) {
3109
3155
  const config = loadConfig();
3110
3156
  const globalOpts = cmd.optsWithGlobals();
@@ -3123,7 +3169,7 @@ function registerBranchCommands(program) {
3123
3169
  const config = loadConfig();
3124
3170
  const pid = projectId ?? overrides.project ?? config.defaults.project;
3125
3171
  if (!pid) {
3126
- console.error(chalk13.red("No project specified. Pass a project ID or set defaults.project."));
3172
+ console.error(chalk14.red("No project specified. Pass a project ID or set defaults.project."));
3127
3173
  process.exit(1);
3128
3174
  }
3129
3175
  const api = createApiClient();
@@ -3147,7 +3193,7 @@ function registerBranchCommands(program) {
3147
3193
  sourceProjectBranch: options.source,
3148
3194
  targetProjectBranch: branchName
3149
3195
  });
3150
- console.log(chalk13.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
3196
+ console.log(chalk14.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
3151
3197
  } catch (error) {
3152
3198
  handleError(error);
3153
3199
  }
@@ -3156,7 +3202,7 @@ function registerBranchCommands(program) {
3156
3202
  try {
3157
3203
  const api = createApiClient();
3158
3204
  await api.storage.deleteProjectBranch(projectId, branchName);
3159
- console.log(chalk13.green(`Branch "${branchName}" deleted from project "${projectId}".`));
3205
+ console.log(chalk14.green(`Branch "${branchName}" deleted from project "${projectId}".`));
3160
3206
  } catch (error) {
3161
3207
  handleError(error);
3162
3208
  }
@@ -3177,7 +3223,7 @@ function registerBranchCommands(program) {
3177
3223
  linkId: options.linkId,
3178
3224
  deepMerge: options.deep
3179
3225
  });
3180
- console.log(chalk13.green("Merge completed."));
3226
+ console.log(chalk14.green("Merge completed."));
3181
3227
  } catch (error) {
3182
3228
  handleError(error);
3183
3229
  }
@@ -3192,7 +3238,7 @@ function registerBranchCommands(program) {
3192
3238
  forkProjectName: options.name ?? forkProjectId,
3193
3239
  forkProjectDescription: options.description
3194
3240
  });
3195
- console.log(chalk13.green(`Project "${projectId}" forked to "${forkProjectId}".`));
3241
+ console.log(chalk14.green(`Project "${projectId}" forked to "${forkProjectId}".`));
3196
3242
  } catch (error) {
3197
3243
  handleError(error);
3198
3244
  }
@@ -3200,7 +3246,7 @@ function registerBranchCommands(program) {
3200
3246
  }
3201
3247
 
3202
3248
  // src/commands/table/index.ts
3203
- import chalk14 from "chalk";
3249
+ import chalk15 from "chalk";
3204
3250
  import * as fs4 from "fs";
3205
3251
  import * as path3 from "path";
3206
3252
  function getOutputFormat6(cmd) {
@@ -3270,7 +3316,7 @@ function registerTableCommands(program) {
3270
3316
  console.log(colNames.map((c) => row2[c] ?? "").join(" "));
3271
3317
  }
3272
3318
  } else {
3273
- console.log(chalk14.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
3319
+ console.log(chalk15.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
3274
3320
  format(tableData, { format: outputFormat, columns: colNames });
3275
3321
  }
3276
3322
  } catch (error) {
@@ -3282,7 +3328,7 @@ function registerTableCommands(program) {
3282
3328
  const overrides = getOverrides6(cmd);
3283
3329
  const resolved = parseEntityReference(ref, overrides);
3284
3330
  if (!fs4.existsSync(file)) {
3285
- console.error(chalk14.red(`File not found: ${file}`));
3331
+ console.error(chalk15.red(`File not found: ${file}`));
3286
3332
  process.exit(1);
3287
3333
  }
3288
3334
  const api = createApiClient();
@@ -3300,15 +3346,15 @@ function registerTableCommands(program) {
3300
3346
  const imp = await api.storage.getImport(resolved, importId);
3301
3347
  if (imp.finished !== null) {
3302
3348
  if (imp.succeeded) {
3303
- console.log(chalk14.green(`Import completed successfully (${imp.duration}ms).`));
3349
+ console.log(chalk15.green(`Import completed successfully (${imp.duration}ms).`));
3304
3350
  } else {
3305
- console.error(chalk14.red(`Import failed: ${imp.error}`));
3351
+ console.error(chalk15.red(`Import failed: ${imp.error}`));
3306
3352
  process.exit(1);
3307
3353
  }
3308
3354
  return;
3309
3355
  }
3310
3356
  }
3311
- console.error(chalk14.yellow("Import still in progress. Check status later."));
3357
+ console.error(chalk15.yellow("Import still in progress. Check status later."));
3312
3358
  } catch (error) {
3313
3359
  handleError(error);
3314
3360
  }
@@ -3344,15 +3390,15 @@ function registerTableCommands(program) {
3344
3390
  const formats = await api.storage.getSupportedExportFormats();
3345
3391
  const format2 = formats.formats.find((f) => f.id.toLowerCase() === fmt.toLowerCase());
3346
3392
  if (!format2) {
3347
- console.error(chalk14.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
3393
+ console.error(chalk15.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
3348
3394
  process.exit(1);
3349
3395
  }
3350
3396
  if (options.compression && !formats.compressionAlgorithms.includes(options.compression)) {
3351
- console.error(chalk14.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
3397
+ console.error(chalk15.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
3352
3398
  process.exit(1);
3353
3399
  }
3354
3400
  if (options.archive && !formats.archiveAlgorithms.includes(options.archive)) {
3355
- console.error(chalk14.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
3401
+ console.error(chalk15.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
3356
3402
  process.exit(1);
3357
3403
  }
3358
3404
  const exportOptions = {
@@ -3382,10 +3428,10 @@ function registerTableCommands(program) {
3382
3428
  const outFile = options.out ?? deriveOutFile(resolved.entityId, format2.extension, options.archive, options.compression);
3383
3429
  const buffer = Buffer.from(await response.arrayBuffer());
3384
3430
  fs4.writeFileSync(outFile, buffer);
3385
- console.log(chalk14.green(`Table streamed to ${outFile}`));
3431
+ console.log(chalk15.green(`Table streamed to ${outFile}`));
3386
3432
  } else {
3387
3433
  const exportId = await api.storage.exportTable(resolved, format2.id, exportOptions);
3388
- console.log(chalk14.green(`Export queued (ID: ${exportId}).`));
3434
+ console.log(chalk15.green(`Export queued (ID: ${exportId}).`));
3389
3435
  console.log(`Poll progress: diafunc table exports get ${exportId} --ref ${ref}`);
3390
3436
  }
3391
3437
  } catch (error) {
@@ -3410,8 +3456,72 @@ function registerTableCommands(program) {
3410
3456
  knownLimitations: f.knownLimitations.join(" / ")
3411
3457
  }));
3412
3458
  format(rows, { format: outputFormat, columns: ["id", "displayName", "category", "extension", "mimeType", "knownLimitations"] });
3413
- console.log(chalk14.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
3414
- console.log(chalk14.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
3459
+ console.log(chalk15.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
3460
+ console.log(chalk15.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
3461
+ } catch (error) {
3462
+ handleError(error);
3463
+ }
3464
+ });
3465
+ const exportsCmd = table.command("exports").description("Track and download async table exports");
3466
+ exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
3467
+ try {
3468
+ const outputFormat = getOutputFormat6(cmd);
3469
+ const overrides = getOverrides6(cmd);
3470
+ const resolved = parseEntityReference(ref, overrides);
3471
+ const api = createApiClient();
3472
+ const exports = await api.storage.listExports(resolved);
3473
+ if (outputFormat === "json") {
3474
+ format(exports, { format: outputFormat });
3475
+ return;
3476
+ }
3477
+ if (exports.length === 0) {
3478
+ console.log(chalk15.dim("No exports found."));
3479
+ return;
3480
+ }
3481
+ const rows = exports.map((e) => ({
3482
+ exportId: e.exportId,
3483
+ filename: e.filename,
3484
+ progress: `${Math.round((e.progress ?? 0) * 100)}%`,
3485
+ succeeded: e.succeeded === true ? "yes" : e.succeeded === false ? "no" : "\u2014",
3486
+ duration: e.duration != null ? `${e.duration}ms` : "\u2014",
3487
+ error: e.error ?? ""
3488
+ }));
3489
+ format(rows, { format: outputFormat, columns: ["exportId", "filename", "progress", "succeeded", "duration", "error"] });
3490
+ } catch (error) {
3491
+ handleError(error);
3492
+ }
3493
+ });
3494
+ exportsCmd.command("get").description("Get async export status; download the file once the export has succeeded").argument("<exportId>", "Export ID returned by `table export --async`").requiredOption("--ref <ref>", "Table entity reference").option("--out <file>", "Output file path (defaults to the original export filename)").action(async (exportId, options, cmd) => {
3495
+ try {
3496
+ const outputFormat = getOutputFormat6(cmd);
3497
+ const overrides = getOverrides6(cmd);
3498
+ const resolved = parseEntityReference(options.ref, overrides);
3499
+ const api = createApiClient();
3500
+ const exports = await api.storage.listExports(resolved);
3501
+ const exp = exports.find((e) => e.exportId === exportId);
3502
+ if (!exp) {
3503
+ console.error(chalk15.red(`Export ${exportId} not found for ref ${options.ref}.`));
3504
+ process.exit(1);
3505
+ }
3506
+ if (outputFormat === "json") {
3507
+ format(exp, { format: outputFormat });
3508
+ return;
3509
+ }
3510
+ if (exp.finished === null) {
3511
+ const pct = Math.round((exp.progress ?? 0) * 100);
3512
+ console.log(chalk15.dim(`Export in progress: ${pct}% \u2014 check again later.`));
3513
+ return;
3514
+ }
3515
+ if (!exp.succeeded) {
3516
+ console.error(chalk15.red(`Export failed: ${exp.error}`));
3517
+ process.exit(1);
3518
+ }
3519
+ const outFile = options.out ?? exp.filename;
3520
+ console.log(`Downloading ${exp.filename} ...`);
3521
+ const response = await api.storage.downloadExport(resolved, exportId, exp.filename);
3522
+ const buffer = Buffer.from(await response.arrayBuffer());
3523
+ fs4.writeFileSync(outFile, buffer);
3524
+ console.log(chalk15.green(`Export saved to ${outFile}`));
3415
3525
  } catch (error) {
3416
3526
  handleError(error);
3417
3527
  }
@@ -3423,7 +3533,7 @@ function registerTableCommands(program) {
3423
3533
  const resolved = parseEntityReference(ref, overrides);
3424
3534
  const api = createApiClient();
3425
3535
  await api.storage.appendRow(resolved);
3426
- console.log(chalk14.green("Row appended."));
3536
+ console.log(chalk15.green("Row appended."));
3427
3537
  } catch (error) {
3428
3538
  handleError(error);
3429
3539
  }
@@ -3434,7 +3544,7 @@ function registerTableCommands(program) {
3434
3544
  const resolved = parseEntityReference(ref, overrides);
3435
3545
  const api = createApiClient();
3436
3546
  await api.storage.insertRow(resolved, parseInt(index, 10));
3437
- console.log(chalk14.green(`Row inserted at index ${index}.`));
3547
+ console.log(chalk15.green(`Row inserted at index ${index}.`));
3438
3548
  } catch (error) {
3439
3549
  handleError(error);
3440
3550
  }
@@ -3445,7 +3555,7 @@ function registerTableCommands(program) {
3445
3555
  const resolved = parseEntityReference(ref, overrides);
3446
3556
  const api = createApiClient();
3447
3557
  await api.storage.removeRow(resolved, parseInt(index, 10));
3448
- console.log(chalk14.green(`Row ${index} removed.`));
3558
+ console.log(chalk15.green(`Row ${index} removed.`));
3449
3559
  } catch (error) {
3450
3560
  handleError(error);
3451
3561
  }
@@ -3456,7 +3566,7 @@ function registerTableCommands(program) {
3456
3566
  const resolved = parseEntityReference(ref, overrides);
3457
3567
  const api = createApiClient();
3458
3568
  await api.storage.deleteRow(resolved, parseInt(index, 10));
3459
- console.log(chalk14.green(`Row ${index} deleted.`));
3569
+ console.log(chalk15.green(`Row ${index} deleted.`));
3460
3570
  } catch (error) {
3461
3571
  handleError(error);
3462
3572
  }
@@ -3468,7 +3578,7 @@ function registerTableCommands(program) {
3468
3578
  const resolved = parseEntityReference(ref, overrides);
3469
3579
  const api = createApiClient();
3470
3580
  await api.storage.appendColumn(resolved);
3471
- console.log(chalk14.green("Column appended."));
3581
+ console.log(chalk15.green("Column appended."));
3472
3582
  } catch (error) {
3473
3583
  handleError(error);
3474
3584
  }
@@ -3479,7 +3589,7 @@ function registerTableCommands(program) {
3479
3589
  const resolved = parseEntityReference(ref, overrides);
3480
3590
  const api = createApiClient();
3481
3591
  await api.storage.insertColumn(resolved, parseInt(index, 10));
3482
- console.log(chalk14.green(`Column inserted at index ${index}.`));
3592
+ console.log(chalk15.green(`Column inserted at index ${index}.`));
3483
3593
  } catch (error) {
3484
3594
  handleError(error);
3485
3595
  }
@@ -3490,7 +3600,7 @@ function registerTableCommands(program) {
3490
3600
  const resolved = parseEntityReference(ref, overrides);
3491
3601
  const api = createApiClient();
3492
3602
  await api.storage.removeColumn(resolved, parseInt(index, 10));
3493
- console.log(chalk14.green(`Column ${index} removed.`));
3603
+ console.log(chalk15.green(`Column ${index} removed.`));
3494
3604
  } catch (error) {
3495
3605
  handleError(error);
3496
3606
  }
@@ -3501,7 +3611,7 @@ function registerTableCommands(program) {
3501
3611
  const resolved = parseEntityReference(ref, overrides);
3502
3612
  const api = createApiClient();
3503
3613
  await api.storage.deleteColumn(resolved, parseInt(index, 10));
3504
- console.log(chalk14.green(`Column ${index} deleted.`));
3614
+ console.log(chalk15.green(`Column ${index} deleted.`));
3505
3615
  } catch (error) {
3506
3616
  handleError(error);
3507
3617
  }
@@ -3518,7 +3628,7 @@ function registerTableCommands(program) {
3518
3628
  value,
3519
3629
  type: "text"
3520
3630
  }]);
3521
- console.log(chalk14.green(`Cell [${row2}, ${col}] set to "${value}".`));
3631
+ console.log(chalk15.green(`Cell [${row2}, ${col}] set to "${value}".`));
3522
3632
  } catch (error) {
3523
3633
  handleError(error);
3524
3634
  }
@@ -3529,18 +3639,19 @@ function registerTableCommands(program) {
3529
3639
  const resolved = parseEntityReference(ref, overrides);
3530
3640
  const api = createApiClient();
3531
3641
  await api.storage.removeCell(resolved, parseInt(row2, 10), parseInt(col, 10));
3532
- console.log(chalk14.green(`Cell [${row2}, ${col}] deleted.`));
3642
+ console.log(chalk15.green(`Cell [${row2}, ${col}] deleted.`));
3533
3643
  } catch (error) {
3534
3644
  handleError(error);
3535
3645
  }
3536
3646
  });
3537
- table.command("clear").description("Clear all data from a table").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
3647
+ table.command("clear").description("Clear all data from a table").argument("<ref>", "Table entity reference").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (ref, options, cmd) => {
3538
3648
  try {
3649
+ await confirmDestructive(`This will permanently delete all data in table "${ref}".`, { yes: options.yes, resourceId: ref });
3539
3650
  const overrides = getOverrides6(cmd);
3540
3651
  const resolved = parseEntityReference(ref, overrides);
3541
3652
  const api = createApiClient();
3542
3653
  await api.storage.clearTable(resolved);
3543
- console.log(chalk14.green("Table cleared."));
3654
+ console.log(chalk15.green("Table cleared."));
3544
3655
  } catch (error) {
3545
3656
  handleError(error);
3546
3657
  }
@@ -3548,7 +3659,7 @@ function registerTableCommands(program) {
3548
3659
  }
3549
3660
 
3550
3661
  // src/commands/notebook/index.ts
3551
- import chalk15 from "chalk";
3662
+ import chalk16 from "chalk";
3552
3663
  import * as fs5 from "fs";
3553
3664
  import * as path4 from "path";
3554
3665
  function getOutputFormat7(cmd) {
@@ -3570,7 +3681,7 @@ function registerNotebookCommands(program) {
3570
3681
  const request = { rootEntityIds: notebookIds, dataFormat: options.data };
3571
3682
  if (options.async) {
3572
3683
  const bundleId = await api.storage.exportBundle(ref.projectId, ref.projectBranch, request);
3573
- console.log(chalk15.green(`Export queued (bundle ID: ${bundleId}).`));
3684
+ console.log(chalk16.green(`Export queued (bundle ID: ${bundleId}).`));
3574
3685
  console.log(`Poll progress: diafunc notebook bundles ${project}`);
3575
3686
  return;
3576
3687
  }
@@ -3578,7 +3689,7 @@ function registerNotebookCommands(program) {
3578
3689
  const outFile = options.out ?? "notebooks.dfnb";
3579
3690
  const buffer = Buffer.from(await response.arrayBuffer());
3580
3691
  fs5.writeFileSync(outFile, buffer);
3581
- console.log(chalk15.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
3692
+ console.log(chalk16.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
3582
3693
  } catch (error) {
3583
3694
  handleError(error);
3584
3695
  }
@@ -3599,9 +3710,9 @@ function registerNotebookCommands(program) {
3599
3710
  format(preview, { format: outputFormat });
3600
3711
  return;
3601
3712
  }
3602
- console.log(chalk15.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
3713
+ console.log(chalk16.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
3603
3714
  if (preview.sourceProjectId) {
3604
- console.log(chalk15.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
3715
+ console.log(chalk16.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
3605
3716
  }
3606
3717
  const counts = /* @__PURE__ */ new Map();
3607
3718
  for (const e of preview.entities ?? []) {
@@ -3611,9 +3722,9 @@ function registerNotebookCommands(program) {
3611
3722
  console.log(` ${type}: ${count}`);
3612
3723
  }
3613
3724
  if (preview.lossinessNotes && preview.lossinessNotes.length > 0) {
3614
- console.log(chalk15.yellow("Lossiness:"));
3725
+ console.log(chalk16.yellow("Lossiness:"));
3615
3726
  for (const note of preview.lossinessNotes) {
3616
- console.log(chalk15.yellow(` - ${note}`));
3727
+ console.log(chalk16.yellow(` - ${note}`));
3617
3728
  }
3618
3729
  }
3619
3730
  return;
@@ -3623,7 +3734,7 @@ function registerNotebookCommands(program) {
3623
3734
  format(result, { format: outputFormat });
3624
3735
  return;
3625
3736
  }
3626
- console.log(chalk15.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
3737
+ console.log(chalk16.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
3627
3738
  console.log(`Notebook id(s): ${result.rootEntityIds.join(", ")}`);
3628
3739
  } catch (error) {
3629
3740
  handleError(error);
@@ -3660,7 +3771,7 @@ function registerNotebookCommands(program) {
3660
3771
  }
3661
3772
 
3662
3773
  // src/commands/function/index.ts
3663
- import chalk16 from "chalk";
3774
+ import chalk17 from "chalk";
3664
3775
  import * as fs6 from "fs";
3665
3776
  import * as os2 from "os";
3666
3777
  import * as path5 from "path";
@@ -3782,7 +3893,7 @@ function registerFunctionCommands(program) {
3782
3893
  }, isAsync);
3783
3894
  if (isAsync) {
3784
3895
  if (outputFormat === "human") {
3785
- console.log(chalk16.green("Function launched."));
3896
+ console.log(chalk17.green("Function launched."));
3786
3897
  console.log(` Evaluation ID: ${result.evaluationId}`);
3787
3898
  } else {
3788
3899
  format({ evaluationId: result.evaluationId }, { format: outputFormat });
@@ -3790,14 +3901,14 @@ function registerFunctionCommands(program) {
3790
3901
  } else {
3791
3902
  if (outputFormat === "human") {
3792
3903
  if (result.successful) {
3793
- console.log(chalk16.green("Function completed successfully."));
3904
+ console.log(chalk17.green("Function completed successfully."));
3794
3905
  if (result.result) {
3795
3906
  console.log(` Result: ${result.result}`);
3796
3907
  }
3797
3908
  const duration = result.completed - result.started;
3798
3909
  console.log(` Duration: ${duration}ms`);
3799
3910
  } else {
3800
- console.log(chalk16.red("Function failed."));
3911
+ console.log(chalk17.red("Function failed."));
3801
3912
  console.log(` Error: ${result.error}`);
3802
3913
  if (result.lineNumber > 0) {
3803
3914
  console.log(` Line: ${result.lineNumber}, Column: ${result.columnNumber}`);
@@ -3805,7 +3916,7 @@ function registerFunctionCommands(program) {
3805
3916
  }
3806
3917
  if (result.outputs?.length) {
3807
3918
  console.log();
3808
- console.log(chalk16.bold("Outputs:"));
3919
+ console.log(chalk17.bold("Outputs:"));
3809
3920
  for (const out of result.outputs) {
3810
3921
  console.log(` [${out.type}] ${out.output}`);
3811
3922
  }
@@ -3859,11 +3970,11 @@ function registerFunctionCommands(program) {
3859
3970
  const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
3860
3971
  if (outputFormat === "human") {
3861
3972
  if (outputs.length === 0) {
3862
- console.log(chalk16.dim("No outputs."));
3973
+ console.log(chalk17.dim("No outputs."));
3863
3974
  }
3864
3975
  for (const out of outputs) {
3865
3976
  const time = new Date(out.timestamp).toISOString();
3866
- console.log(`${chalk16.dim(time)} [${out.type}] ${out.output}`);
3977
+ console.log(`${chalk17.dim(time)} [${out.type}] ${out.output}`);
3867
3978
  }
3868
3979
  } else {
3869
3980
  format(outputs, { format: outputFormat });
@@ -3913,7 +4024,7 @@ function registerFunctionCommands(program) {
3913
4024
  hour,
3914
4025
  evaluationId
3915
4026
  );
3916
- console.log(chalk16.green(`Evaluation ${evaluationId} stopped.`));
4027
+ console.log(chalk17.green(`Evaluation ${evaluationId} stopped.`));
3917
4028
  } catch (error) {
3918
4029
  handleError(error);
3919
4030
  }
@@ -3961,7 +4072,7 @@ function registerFunctionCommands(program) {
3961
4072
  sourceCode
3962
4073
  });
3963
4074
  await api.storage.saveEntities([entity]);
3964
- console.log(chalk16.green(`Function "${resolved.entityId}" created (${options.language}).`));
4075
+ console.log(chalk17.green(`Function "${resolved.entityId}" created (${options.language}).`));
3965
4076
  } catch (error) {
3966
4077
  handleError(error);
3967
4078
  }
@@ -3976,7 +4087,7 @@ function registerFunctionCommands(program) {
3976
4087
  const sourceCode = decodeFunctionSource(entity);
3977
4088
  if (options.out) {
3978
4089
  fs6.writeFileSync(options.out, sourceCode);
3979
- console.log(chalk16.green(`Source written to ${options.out}`));
4090
+ console.log(chalk17.green(`Source written to ${options.out}`));
3980
4091
  } else {
3981
4092
  process.stdout.write(sourceCode);
3982
4093
  if (!sourceCode.endsWith("\n")) process.stdout.write("\n");
@@ -4000,7 +4111,7 @@ function registerFunctionCommands(program) {
4000
4111
  process.stdin.on("error", reject);
4001
4112
  });
4002
4113
  await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(sourceCode));
4003
- console.log(chalk16.green(`Source updated for "${resolved.entityId}".`));
4114
+ console.log(chalk17.green(`Source updated for "${resolved.entityId}".`));
4004
4115
  } catch (error) {
4005
4116
  handleError(error);
4006
4117
  }
@@ -4025,11 +4136,11 @@ function registerFunctionCommands(program) {
4025
4136
  const newSource = fs6.readFileSync(tmpFile, "utf-8");
4026
4137
  fs6.unlinkSync(tmpFile);
4027
4138
  if (newSource === currentSource) {
4028
- console.log(chalk16.dim("No changes."));
4139
+ console.log(chalk17.dim("No changes."));
4029
4140
  return;
4030
4141
  }
4031
4142
  await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(newSource));
4032
- console.log(chalk16.green(`Source updated for "${resolved.entityId}".`));
4143
+ console.log(chalk17.green(`Source updated for "${resolved.entityId}".`));
4033
4144
  } catch (error) {
4034
4145
  handleError(error);
4035
4146
  }
@@ -4046,7 +4157,7 @@ function extensionFor(language) {
4046
4157
  }
4047
4158
 
4048
4159
  // src/commands/trigger/index.ts
4049
- import chalk17 from "chalk";
4160
+ import chalk18 from "chalk";
4050
4161
  function getOutputFormat9(cmd) {
4051
4162
  const config = loadConfig();
4052
4163
  const globalOpts = cmd.optsWithGlobals();
@@ -4116,7 +4227,7 @@ function registerTriggerCommands(program) {
4116
4227
  resolved.entityBranch,
4117
4228
  triggerId
4118
4229
  );
4119
- console.log(chalk17.green(`Trigger "${triggerId}" deleted.`));
4230
+ console.log(chalk18.green(`Trigger "${triggerId}" deleted.`));
4120
4231
  } catch (error) {
4121
4232
  handleError(error);
4122
4233
  }
@@ -4164,7 +4275,7 @@ function registerTriggerCommands(program) {
4164
4275
  scheduler: null,
4165
4276
  heartbeat: null
4166
4277
  });
4167
- console.log(chalk17.green("Trigger saved."));
4278
+ console.log(chalk18.green("Trigger saved."));
4168
4279
  } catch (error) {
4169
4280
  handleError(error);
4170
4281
  }
@@ -4172,7 +4283,7 @@ function registerTriggerCommands(program) {
4172
4283
  }
4173
4284
 
4174
4285
  // src/commands/schedule/index.ts
4175
- import chalk18 from "chalk";
4286
+ import chalk19 from "chalk";
4176
4287
  import { randomUUID as randomUUID2 } from "crypto";
4177
4288
  function getOutputFormat10(cmd) {
4178
4289
  const config = loadConfig();
@@ -4224,7 +4335,7 @@ function registerScheduleCommands(program) {
4224
4335
  removeFunction: false
4225
4336
  });
4226
4337
  if (outputFormat === "human") {
4227
- console.log(chalk18.green("Function scheduled."));
4338
+ console.log(chalk19.green("Function scheduled."));
4228
4339
  } else {
4229
4340
  format(result, { format: outputFormat });
4230
4341
  }
@@ -4249,7 +4360,7 @@ function registerScheduleCommands(program) {
4249
4360
  hour,
4250
4361
  evaluationId
4251
4362
  );
4252
- console.log(chalk18.green(`Scheduled evaluation ${evaluationId} stopped.`));
4363
+ console.log(chalk19.green(`Scheduled evaluation ${evaluationId} stopped.`));
4253
4364
  } catch (error) {
4254
4365
  handleError(error);
4255
4366
  }
@@ -4286,7 +4397,7 @@ function registerScheduleCommands(program) {
4286
4397
  }
4287
4398
 
4288
4399
  // src/commands/chat/index.ts
4289
- import chalk19 from "chalk";
4400
+ import chalk20 from "chalk";
4290
4401
  import * as fs7 from "fs";
4291
4402
  import * as path6 from "path";
4292
4403
  function getOutputFormat11(cmd) {
@@ -4327,7 +4438,7 @@ async function streamOneTurn(message, sessionId, projectId, branch) {
4327
4438
  input = event.inputTokens;
4328
4439
  output = event.outputTokens;
4329
4440
  } else if (event.type === "error") {
4330
- console.error(chalk19.red(`
4441
+ console.error(chalk20.red(`
4331
4442
  Error: ${event.content}`));
4332
4443
  }
4333
4444
  } catch {
@@ -4338,19 +4449,19 @@ Error: ${event.content}`));
4338
4449
  }
4339
4450
  async function runChatRepl(options) {
4340
4451
  const { input: promptInput } = await import("@inquirer/prompts");
4341
- const { getUpdateNotice } = await import("./update-check-KL3CHODI.js");
4452
+ const { getUpdateNotice } = await import("./update-check-2X2AIL52.js");
4342
4453
  let sessionId = options.session;
4343
- console.log(chalk19.bold("Diafunc chat") + chalk19.dim(" \xB7 /help for commands, /quit to exit"));
4454
+ console.log(chalk20.bold("Diafunc chat") + chalk20.dim(" \xB7 /help for commands, /quit to exit"));
4344
4455
  if (sessionId) {
4345
- console.log(chalk19.dim(`Continuing session ${sessionId}`));
4456
+ console.log(chalk20.dim(`Continuing session ${sessionId}`));
4346
4457
  }
4347
4458
  const notice = await getUpdateNotice();
4348
- if (notice) console.log(chalk19.dim(notice));
4459
+ if (notice) console.log(chalk20.dim(notice));
4349
4460
  console.log();
4350
4461
  for (; ; ) {
4351
4462
  let line;
4352
4463
  try {
4353
- line = await promptInput({ message: chalk19.cyan.bold("you >") });
4464
+ line = await promptInput({ message: chalk20.cyan.bold("you >") });
4354
4465
  } catch {
4355
4466
  console.log();
4356
4467
  return;
@@ -4367,37 +4478,37 @@ async function runChatRepl(options) {
4367
4478
  return;
4368
4479
  case "new":
4369
4480
  sessionId = void 0;
4370
- console.log(chalk19.dim("Started a new session."));
4481
+ console.log(chalk20.dim("Started a new session."));
4371
4482
  continue;
4372
4483
  case "session":
4373
4484
  if (!arg) {
4374
- console.log(chalk19.dim(`Current session: ${sessionId ?? "(new)"}`));
4485
+ console.log(chalk20.dim(`Current session: ${sessionId ?? "(new)"}`));
4375
4486
  } else {
4376
4487
  sessionId = arg;
4377
- console.log(chalk19.dim(`Switched to session ${sessionId}`));
4488
+ console.log(chalk20.dim(`Switched to session ${sessionId}`));
4378
4489
  }
4379
4490
  continue;
4380
4491
  case "help":
4381
4492
  case "h":
4382
4493
  case "?":
4383
- console.log(chalk19.dim(" /new start a new session"));
4384
- console.log(chalk19.dim(" /session [id] switch to a session (no id = show current)"));
4385
- console.log(chalk19.dim(" /quit exit the REPL"));
4494
+ console.log(chalk20.dim(" /new start a new session"));
4495
+ console.log(chalk20.dim(" /session [id] switch to a session (no id = show current)"));
4496
+ console.log(chalk20.dim(" /quit exit the REPL"));
4386
4497
  continue;
4387
4498
  default:
4388
- console.log(chalk19.dim(`Unknown command: /${cmd}. Try /help.`));
4499
+ console.log(chalk20.dim(`Unknown command: /${cmd}. Try /help.`));
4389
4500
  continue;
4390
4501
  }
4391
4502
  }
4392
- process.stdout.write(chalk19.magenta.bold("diafunc > "));
4503
+ process.stdout.write(chalk20.magenta.bold("diafunc > "));
4393
4504
  try {
4394
4505
  const result = await streamOneTurn(trimmed, sessionId, options.project, options.branch);
4395
4506
  sessionId = result.sessionId || sessionId;
4396
4507
  console.log();
4397
- console.log(chalk19.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
4508
+ console.log(chalk20.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
4398
4509
  console.log();
4399
4510
  } catch (error) {
4400
- console.error(chalk19.red(`
4511
+ console.error(chalk20.red(`
4401
4512
  Request failed: ${error.message}`));
4402
4513
  }
4403
4514
  }
@@ -4424,7 +4535,7 @@ function registerChatCommands(program) {
4424
4535
  if (outputFormat === "human") {
4425
4536
  console.log(response.content);
4426
4537
  console.log();
4427
- console.log(chalk19.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
4538
+ console.log(chalk20.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
4428
4539
  } else {
4429
4540
  format(response, { format: outputFormat });
4430
4541
  }
@@ -4489,9 +4600,9 @@ function registerChatCommands(program) {
4489
4600
  sessionId = event.sessionId ?? "";
4490
4601
  console.log();
4491
4602
  console.log();
4492
- console.log(chalk19.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
4603
+ console.log(chalk20.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
4493
4604
  } else if (event.type === "error") {
4494
- console.error(chalk19.red(`
4605
+ console.error(chalk20.red(`
4495
4606
  Error: ${event.content}`));
4496
4607
  }
4497
4608
  } catch {
@@ -4507,7 +4618,7 @@ Error: ${event.content}`));
4507
4618
  chat.command("upload").description("Upload a file for chat context").argument("<file>", "File to upload").action(async (file) => {
4508
4619
  try {
4509
4620
  if (!fs7.existsSync(file)) {
4510
- console.error(chalk19.red(`File not found: ${file}`));
4621
+ console.error(chalk20.red(`File not found: ${file}`));
4511
4622
  process.exit(1);
4512
4623
  }
4513
4624
  const api = createApiClient();
@@ -4516,7 +4627,7 @@ Error: ${event.content}`));
4516
4627
  const formData = new FormData();
4517
4628
  formData.append("file", blob, path6.basename(file));
4518
4629
  const result = await api.language.upload(formData);
4519
- console.log(chalk19.green(`File uploaded: ${result}`));
4630
+ console.log(chalk20.green(`File uploaded: ${result}`));
4520
4631
  } catch (error) {
4521
4632
  handleError(error);
4522
4633
  }
@@ -4539,7 +4650,7 @@ Error: ${event.content}`));
4539
4650
  try {
4540
4651
  const api = createApiClient();
4541
4652
  await api.language.deleteSession(sessionId);
4542
- console.log(chalk19.green(`Session "${sessionId}" deleted.`));
4653
+ console.log(chalk20.green(`Session "${sessionId}" deleted.`));
4543
4654
  } catch (error) {
4544
4655
  handleError(error);
4545
4656
  }
@@ -4550,11 +4661,11 @@ Error: ${event.content}`));
4550
4661
  const api = createApiClient();
4551
4662
  const detail = await api.language.getSession(sessionId);
4552
4663
  if (outputFormat === "human") {
4553
- console.log(chalk19.bold(detail.title) + chalk19.dim(` (${detail.sessionId})`));
4664
+ console.log(chalk20.bold(detail.title) + chalk20.dim(` (${detail.sessionId})`));
4554
4665
  console.log();
4555
4666
  for (const msg of detail.messages) {
4556
- const role = msg.role === "user" ? chalk19.cyan.bold("You") : chalk19.magenta.bold("Diafunc");
4557
- console.log(`${role} ${chalk19.dim(msg.created)}`);
4667
+ const role = msg.role === "user" ? chalk20.cyan.bold("You") : chalk20.magenta.bold("Diafunc");
4668
+ console.log(`${role} ${chalk20.dim(msg.created)}`);
4558
4669
  console.log(msg.content);
4559
4670
  console.log();
4560
4671
  }
@@ -4569,7 +4680,7 @@ Error: ${event.content}`));
4569
4680
  try {
4570
4681
  const api = createApiClient();
4571
4682
  await api.language.renameSession(sessionId, title);
4572
- console.log(chalk19.green(`Session "${sessionId}" renamed to "${title}".`));
4683
+ console.log(chalk20.green(`Session "${sessionId}" renamed to "${title}".`));
4573
4684
  } catch (error) {
4574
4685
  handleError(error);
4575
4686
  }
@@ -4626,7 +4737,7 @@ function registerSearchCommands(program) {
4626
4737
  }
4627
4738
 
4628
4739
  // src/commands/group/index.ts
4629
- import chalk20 from "chalk";
4740
+ import chalk21 from "chalk";
4630
4741
  function getOutputFormat13(cmd) {
4631
4742
  const config = loadConfig();
4632
4743
  const globalOpts = cmd.optsWithGlobals();
@@ -4658,7 +4769,7 @@ function registerGroupCommands(program) {
4658
4769
  try {
4659
4770
  const api = createApiClient();
4660
4771
  await api.admin.createGroup({ groupId, name: options.name ?? groupId });
4661
- console.log(chalk20.green(`Group "${groupId}" created.`));
4772
+ console.log(chalk21.green(`Group "${groupId}" created.`));
4662
4773
  } catch (error) {
4663
4774
  handleError(error);
4664
4775
  }
@@ -4667,7 +4778,7 @@ function registerGroupCommands(program) {
4667
4778
  try {
4668
4779
  const api = createApiClient();
4669
4780
  await api.admin.updateGroup({ groupId, name: options.name });
4670
- console.log(chalk20.green(`Group "${groupId}" updated.`));
4781
+ console.log(chalk21.green(`Group "${groupId}" updated.`));
4671
4782
  } catch (error) {
4672
4783
  handleError(error);
4673
4784
  }
@@ -4676,7 +4787,7 @@ function registerGroupCommands(program) {
4676
4787
  try {
4677
4788
  const api = createApiClient();
4678
4789
  await api.admin.deleteGroup(groupId);
4679
- console.log(chalk20.green(`Group "${groupId}" deleted.`));
4790
+ console.log(chalk21.green(`Group "${groupId}" deleted.`));
4680
4791
  } catch (error) {
4681
4792
  handleError(error);
4682
4793
  }
@@ -4696,7 +4807,7 @@ function registerGroupCommands(program) {
4696
4807
  try {
4697
4808
  const api = createApiClient();
4698
4809
  await api.admin.inviteGroupMember(groupId, userId, role.toUpperCase());
4699
- console.log(chalk20.green(`Invited ${userId} to group "${groupId}" as ${role.toUpperCase()}.`));
4810
+ console.log(chalk21.green(`Invited ${userId} to group "${groupId}" as ${role.toUpperCase()}.`));
4700
4811
  } catch (error) {
4701
4812
  handleError(error);
4702
4813
  }
@@ -4705,7 +4816,7 @@ function registerGroupCommands(program) {
4705
4816
  try {
4706
4817
  const api = createApiClient();
4707
4818
  await api.admin.removeGroupMember(groupId, userId);
4708
- console.log(chalk20.green(`Removed ${userId} from group "${groupId}".`));
4819
+ console.log(chalk21.green(`Removed ${userId} from group "${groupId}".`));
4709
4820
  } catch (error) {
4710
4821
  handleError(error);
4711
4822
  }
@@ -4725,7 +4836,7 @@ function registerGroupCommands(program) {
4725
4836
  try {
4726
4837
  const api = createApiClient();
4727
4838
  await api.admin.addGroupProject(groupId, projectId);
4728
- console.log(chalk20.green(`Project "${projectId}" added to group "${groupId}".`));
4839
+ console.log(chalk21.green(`Project "${projectId}" added to group "${groupId}".`));
4729
4840
  } catch (error) {
4730
4841
  handleError(error);
4731
4842
  }
@@ -4734,7 +4845,7 @@ function registerGroupCommands(program) {
4734
4845
  try {
4735
4846
  const api = createApiClient();
4736
4847
  await api.admin.removeGroupProject(groupId, projectId);
4737
- console.log(chalk20.green(`Project "${projectId}" removed from group "${groupId}".`));
4848
+ console.log(chalk21.green(`Project "${projectId}" removed from group "${groupId}".`));
4738
4849
  } catch (error) {
4739
4850
  handleError(error);
4740
4851
  }
@@ -4742,7 +4853,7 @@ function registerGroupCommands(program) {
4742
4853
  }
4743
4854
 
4744
4855
  // src/commands/admin/index.ts
4745
- import chalk21 from "chalk";
4856
+ import chalk22 from "chalk";
4746
4857
  function getOutputFormat14(cmd) {
4747
4858
  const config = loadConfig();
4748
4859
  const globalOpts = cmd.optsWithGlobals();
@@ -4806,7 +4917,7 @@ function registerAdminCommands(program) {
4806
4917
  try {
4807
4918
  const api = createApiClient();
4808
4919
  await api.admin.mergeSetting({ [key]: value });
4809
- console.log(chalk21.green(`Setting "${key}" updated.`));
4920
+ console.log(chalk22.green(`Setting "${key}" updated.`));
4810
4921
  } catch (error) {
4811
4922
  handleError(error);
4812
4923
  }
@@ -4817,10 +4928,10 @@ function registerAdminCommands(program) {
4817
4928
  const api = createApiClient();
4818
4929
  if (options.longTerm) {
4819
4930
  await api.storage.createLongTermFullBackup();
4820
- console.log(chalk21.green("Full long-term backup initiated."));
4931
+ console.log(chalk22.green("Full long-term backup initiated."));
4821
4932
  } else {
4822
4933
  await api.storage.createShortTermFullBackup();
4823
- console.log(chalk21.green("Full short-term backup initiated."));
4934
+ console.log(chalk22.green("Full short-term backup initiated."));
4824
4935
  }
4825
4936
  } catch (error) {
4826
4937
  handleError(error);
@@ -4831,29 +4942,37 @@ function registerAdminCommands(program) {
4831
4942
  const api = createApiClient();
4832
4943
  if (options.longTerm) {
4833
4944
  await api.storage.createLongTermProjectBackup();
4834
- console.log(chalk21.green("Project long-term backup initiated."));
4945
+ console.log(chalk22.green("Project long-term backup initiated."));
4835
4946
  } else {
4836
4947
  await api.storage.createShortTermProjectBackup();
4837
- console.log(chalk21.green("Project short-term backup initiated."));
4948
+ console.log(chalk22.green("Project short-term backup initiated."));
4838
4949
  }
4839
4950
  } catch (error) {
4840
4951
  handleError(error);
4841
4952
  }
4842
4953
  });
4843
- backup.command("restore-project").description("Restore a project from a backup bucket+object").argument("<projectId>", "Project ID").argument("<projectBranch>", "Project branch").argument("<bucketName>", "Backup bucket name").argument("<objectName>", "Backup object name").action(async (projectId, projectBranch, bucketName, objectName) => {
4954
+ backup.command("restore-project").description("Restore a project from a backup bucket+object").argument("<projectId>", "Project ID").argument("<projectBranch>", "Project branch").argument("<bucketName>", "Backup bucket name").argument("<objectName>", "Backup object name").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (projectId, projectBranch, bucketName, objectName, options) => {
4844
4955
  try {
4956
+ await confirmDestructive(
4957
+ `This will overwrite project "${projectId}/${projectBranch}" with backup ${bucketName}/${objectName}.`,
4958
+ { yes: options.yes }
4959
+ );
4845
4960
  const api = createApiClient();
4846
4961
  await api.storage.restoreProjectBackup({ projectId, projectBranch, bucketName, objectName });
4847
- console.log(chalk21.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
4962
+ console.log(chalk22.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
4848
4963
  } catch (error) {
4849
4964
  handleError(error);
4850
4965
  }
4851
4966
  });
4852
- backup.command("restore-full").description("Restore a full system backup from a bucket+object").argument("<bucketName>", "Backup bucket name").argument("<objectName>", "Backup object name").action(async (bucketName, objectName) => {
4967
+ backup.command("restore-full").description("Restore a full system backup from a bucket+object").argument("<bucketName>", "Backup bucket name").argument("<objectName>", "Backup object name").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (bucketName, objectName, options) => {
4853
4968
  try {
4969
+ await confirmDestructive(
4970
+ `This will overwrite the ENTIRE system with backup ${bucketName}/${objectName}.`,
4971
+ { yes: options.yes }
4972
+ );
4854
4973
  const api = createApiClient();
4855
4974
  await api.storage.restoreFullBackup({ bucketName, objectName });
4856
- console.log(chalk21.green(`Full restore initiated from ${bucketName}/${objectName}.`));
4975
+ console.log(chalk22.green(`Full restore initiated from ${bucketName}/${objectName}.`));
4857
4976
  } catch (error) {
4858
4977
  handleError(error);
4859
4978
  }
@@ -4863,10 +4982,10 @@ function registerAdminCommands(program) {
4863
4982
  const api = createApiClient();
4864
4983
  if (options.project) {
4865
4984
  await api.index.rebuildProject(options.project);
4866
- console.log(chalk21.green(`Index rebuild initiated for project "${options.project}".`));
4985
+ console.log(chalk22.green(`Index rebuild initiated for project "${options.project}".`));
4867
4986
  } else {
4868
4987
  await api.index.rebuildAll();
4869
- console.log(chalk21.green("Index rebuild initiated for all projects."));
4988
+ console.log(chalk22.green("Index rebuild initiated for all projects."));
4870
4989
  }
4871
4990
  } catch (error) {
4872
4991
  handleError(error);
@@ -4885,7 +5004,7 @@ function registerAdminCommands(program) {
4885
5004
  }
4886
5005
 
4887
5006
  // src/commands/status/summary.ts
4888
- import chalk22 from "chalk";
5007
+ import chalk23 from "chalk";
4889
5008
 
4890
5009
  // src/client/services/status.ts
4891
5010
  function createStatusService() {
@@ -4911,24 +5030,24 @@ function createStatusService() {
4911
5030
 
4912
5031
  // src/commands/status/summary.ts
4913
5032
  var STATE_COLORS = {
4914
- UP: chalk22.green,
4915
- DEGRADED: chalk22.yellow,
4916
- DOWN: chalk22.red,
4917
- UNKNOWN: chalk22.gray
5033
+ UP: chalk23.green,
5034
+ DEGRADED: chalk23.yellow,
5035
+ DOWN: chalk23.red,
5036
+ UNKNOWN: chalk23.gray
4918
5037
  };
4919
5038
  function stateColor(state) {
4920
- return STATE_COLORS[state] ?? chalk22.gray;
5039
+ return STATE_COLORS[state] ?? chalk23.gray;
4921
5040
  }
4922
5041
  function stateSymbol(state) {
4923
5042
  switch (state) {
4924
5043
  case "UP":
4925
- return chalk22.green("\u25CF");
5044
+ return chalk23.green("\u25CF");
4926
5045
  case "DEGRADED":
4927
- return chalk22.yellow("\u25CF");
5046
+ return chalk23.yellow("\u25CF");
4928
5047
  case "DOWN":
4929
- return chalk22.red("\u25CF");
5048
+ return chalk23.red("\u25CF");
4930
5049
  default:
4931
- return chalk22.gray("\u25CB");
5050
+ return chalk23.gray("\u25CB");
4932
5051
  }
4933
5052
  }
4934
5053
  function registerSummaryCommand(parent) {
@@ -4955,11 +5074,11 @@ function registerSummaryCommand(parent) {
4955
5074
  }
4956
5075
  console.log();
4957
5076
  if (summary.openIncidents > 0) {
4958
- console.log(chalk22.yellow(` ${summary.openIncidents} active incident(s)`));
5077
+ console.log(chalk23.yellow(` ${summary.openIncidents} active incident(s)`));
4959
5078
  } else {
4960
- console.log(chalk22.dim(" No active incidents"));
5079
+ console.log(chalk23.dim(" No active incidents"));
4961
5080
  }
4962
- console.log(chalk22.dim(`
5081
+ console.log(chalk23.dim(`
4963
5082
  Platform v${version.platformVersion} \u2022 ${new Date(summary.timestamp).toLocaleString()}`));
4964
5083
  console.log();
4965
5084
  } catch (error) {
@@ -4969,17 +5088,17 @@ function registerSummaryCommand(parent) {
4969
5088
  }
4970
5089
 
4971
5090
  // src/commands/status/component.ts
4972
- import chalk23 from "chalk";
5091
+ import chalk24 from "chalk";
4973
5092
  function stateSymbol2(state) {
4974
5093
  switch (state) {
4975
5094
  case "UP":
4976
- return chalk23.green("\u25CF");
5095
+ return chalk24.green("\u25CF");
4977
5096
  case "DEGRADED":
4978
- return chalk23.yellow("\u25CF");
5097
+ return chalk24.yellow("\u25CF");
4979
5098
  case "DOWN":
4980
- return chalk23.red("\u25CF");
5099
+ return chalk24.red("\u25CF");
4981
5100
  default:
4982
- return chalk23.gray("\u25CB");
5101
+ return chalk24.gray("\u25CB");
4983
5102
  }
4984
5103
  }
4985
5104
  function registerComponentCommand(parent) {
@@ -4992,7 +5111,7 @@ function registerComponentCommand(parent) {
4992
5111
  const match = components.find((c) => c.id === id || c.id === id + "-service");
4993
5112
  if (!match) {
4994
5113
  const available = components.map((c) => c.id).join(", ");
4995
- console.error(chalk23.red(`Component "${id}" not found. Available: ${available}`));
5114
+ console.error(chalk24.red(`Component "${id}" not found. Available: ${available}`));
4996
5115
  process.exit(1);
4997
5116
  }
4998
5117
  if (outputFormat !== "human") {
@@ -5000,7 +5119,7 @@ function registerComponentCommand(parent) {
5000
5119
  return;
5001
5120
  }
5002
5121
  console.log();
5003
- console.log(` ${stateSymbol2(match.state)} ${chalk23.bold(match.id)} ${match.version ? chalk23.dim("v" + match.version) : ""}`);
5122
+ console.log(` ${stateSymbol2(match.state)} ${chalk24.bold(match.id)} ${match.version ? chalk24.dim("v" + match.version) : ""}`);
5004
5123
  console.log(` State: ${match.state}`);
5005
5124
  if (match.lastCheckAt) {
5006
5125
  console.log(` Last check: ${new Date(match.lastCheckAt).toLocaleString()}`);
@@ -5009,7 +5128,7 @@ function registerComponentCommand(parent) {
5009
5128
  console.log();
5010
5129
  console.log(" Checks:");
5011
5130
  for (const check of match.checks) {
5012
- const cat = check.category ? chalk23.dim(` (${check.category})`) : "";
5131
+ const cat = check.category ? chalk24.dim(` (${check.category})`) : "";
5013
5132
  console.log(` ${stateSymbol2(check.state)} ${check.name}${cat}`);
5014
5133
  }
5015
5134
  }
@@ -5021,12 +5140,12 @@ function registerComponentCommand(parent) {
5021
5140
  }
5022
5141
 
5023
5142
  // src/commands/status/incidents.ts
5024
- import chalk24 from "chalk";
5143
+ import chalk25 from "chalk";
5025
5144
  var SEVERITY_COLORS = {
5026
- ERROR: chalk24.red,
5027
- WARNING: chalk24.yellow,
5028
- INFO: chalk24.blue,
5029
- MAINTENANCE: chalk24.cyan
5145
+ ERROR: chalk25.red,
5146
+ WARNING: chalk25.yellow,
5147
+ INFO: chalk25.blue,
5148
+ MAINTENANCE: chalk25.cyan
5030
5149
  };
5031
5150
  function registerIncidentsCommand(parent) {
5032
5151
  parent.command("incidents").description("List recent incidents").option("-w, --window <window>", "Time window (e.g. 24h, 48h)", "24h").action(async (options, cmd) => {
@@ -5040,22 +5159,22 @@ function registerIncidentsCommand(parent) {
5040
5159
  return;
5041
5160
  }
5042
5161
  if (incidents.length === 0) {
5043
- console.log(chalk24.dim(`
5162
+ console.log(chalk25.dim(`
5044
5163
  No incidents in the last ${options.window}.
5045
5164
  `));
5046
5165
  return;
5047
5166
  }
5048
5167
  console.log();
5049
5168
  for (const incident of incidents) {
5050
- const color = SEVERITY_COLORS[incident.severity] ?? chalk24.gray;
5169
+ const color = SEVERITY_COLORS[incident.severity] ?? chalk25.gray;
5051
5170
  const severity = color(incident.severity.padEnd(8));
5052
5171
  const time = incident.startedAt ? new Date(incident.startedAt).toLocaleString() : "";
5053
- const resolved = incident.resolvedAt ? chalk24.green(" [resolved]") : chalk24.yellow(" [open]");
5172
+ const resolved = incident.resolvedAt ? chalk25.green(" [resolved]") : chalk25.yellow(" [open]");
5054
5173
  console.log(` ${severity} ${incident.summary}${resolved}`);
5055
- console.log(chalk24.dim(` ${time}`));
5174
+ console.log(chalk25.dim(` ${time}`));
5056
5175
  for (const update of incident.updates) {
5057
5176
  const updateTime = new Date(update.at).toLocaleTimeString();
5058
- console.log(chalk24.dim(` ${updateTime} ${update.status} ${update.message}`));
5177
+ console.log(chalk25.dim(` ${updateTime} ${update.status} ${update.message}`));
5059
5178
  }
5060
5179
  console.log();
5061
5180
  }
@@ -5074,7 +5193,7 @@ function registerStatusCommands(program) {
5074
5193
  }
5075
5194
 
5076
5195
  // src/commands/analyze/index.ts
5077
- import chalk25 from "chalk";
5196
+ import chalk26 from "chalk";
5078
5197
  import * as fs8 from "fs";
5079
5198
  import * as path7 from "path";
5080
5199
  import { spawn as spawn2 } from "child_process";
@@ -5119,9 +5238,25 @@ function multipartFromFile(file) {
5119
5238
  }
5120
5239
  async function runAnalysis(file, options, cmd) {
5121
5240
  if (!fs8.existsSync(file)) {
5122
- console.error(chalk25.red(`File not found: ${file}`));
5241
+ console.error(chalk26.red(`File not found: ${file}`));
5123
5242
  process.exit(1);
5124
5243
  }
5244
+ if (options.preset) {
5245
+ const api2 = createApiClient();
5246
+ const opt = await api2.analysis.getPreset(options.preset);
5247
+ if (!opt.preset) {
5248
+ console.error(chalk26.red(`Preset not found: ${options.preset}`));
5249
+ process.exit(1);
5250
+ }
5251
+ const p = opt.preset;
5252
+ if (options.targets === void 0 && p.targetKeys.length > 0) options.targets = p.targetKeys.join(",");
5253
+ if (options.questions === void 0 && p.questions.length > 0) options.questions = p.questions.join(",");
5254
+ if (options.segment === void 0 && p.segmentKey) options.segment = p.segmentKey;
5255
+ if (options.hours === void 0) options.hours = p.time;
5256
+ if (options.budget === void 0) options.budget = p.budget;
5257
+ }
5258
+ const hours = options.hours ?? "4";
5259
+ const budget = options.budget ?? "400";
5125
5260
  const api = createApiClient();
5126
5261
  const visibility = parseVisibility(options.visibility);
5127
5262
  const name = options.name ?? path7.basename(file, path7.extname(file));
@@ -5130,25 +5265,25 @@ async function runAnalysis(file, options, cmd) {
5130
5265
  description: options.description || null,
5131
5266
  visibility,
5132
5267
  introduction: options.introduction ?? null,
5133
- hours: options.hours,
5134
- budget: options.budget,
5268
+ hours,
5269
+ budget,
5135
5270
  targets: parseCsv(options.targets),
5136
5271
  questions: parseCsv(options.questions),
5137
5272
  segment: options.segment ?? null
5138
5273
  };
5139
5274
  process.stdout.write(`Creating analysis "${name}" ...`);
5140
5275
  const created = await api.analysis.create(request);
5141
- console.log(chalk25.green(" done"));
5142
- console.log(chalk25.dim(` analysisId: ${created.analysisId}`));
5276
+ console.log(chalk26.green(" done"));
5277
+ console.log(chalk26.dim(` analysisId: ${created.analysisId}`));
5143
5278
  process.stdout.write(`Uploading ${path7.basename(file)} ...`);
5144
5279
  await api.analysis.uploadDataMultipart(created.analysisId, multipartFromFile(file));
5145
- console.log(chalk25.green(" done"));
5280
+ console.log(chalk26.green(" done"));
5146
5281
  process.stdout.write("Queuing analysis run ...");
5147
5282
  const run = await api.analysis.runAnalysis(created.analysisId);
5148
- console.log(chalk25.green(" done"));
5149
- console.log(chalk25.dim(` runId: ${run.runId}`));
5283
+ console.log(chalk26.green(" done"));
5284
+ console.log(chalk26.dim(` runId: ${run.runId}`));
5150
5285
  console.log();
5151
- await monitorRun(api, created.analysisId, run.runId, parseFloat(options.hours), cmd);
5286
+ await monitorRun(api, created.analysisId, run.runId, parseFloat(hours), cmd);
5152
5287
  }
5153
5288
  async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5154
5289
  const config = loadConfig();
@@ -5171,7 +5306,11 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5171
5306
  if (!seenOutputIds.has(out.outputId)) {
5172
5307
  seenOutputIds.add(out.outputId);
5173
5308
  if (outputFormat === "human") {
5174
- console.log(` ${chalk25.dim("Output:")} ${out.output}`);
5309
+ console.log(` ${chalk26.dim("Output:")} ${out.output}`);
5310
+ } else {
5311
+ process.stdout.write(
5312
+ JSON.stringify({ type: "output", outputId: out.outputId, output: out.output }) + "\n"
5313
+ );
5175
5314
  }
5176
5315
  }
5177
5316
  }
@@ -5184,7 +5323,7 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5184
5323
  const durationStr = formatDuration(duration);
5185
5324
  if (run.state === "COMPLETED") {
5186
5325
  if (outputFormat === "human") {
5187
- console.log(chalk25.green(`Analysis complete! (${durationStr})`));
5326
+ console.log(chalk26.green(`Analysis complete! (${durationStr})`));
5188
5327
  try {
5189
5328
  const nav = await api.analysis.getNavigation(analysisId);
5190
5329
  const endpoint = config.profiles[config.currentProfile]?.endpoint ?? "https://diafunc.com";
@@ -5196,13 +5335,13 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5196
5335
  }
5197
5336
  } else if (run.state === "CANCELLED") {
5198
5337
  if (outputFormat === "human") {
5199
- console.log(chalk25.yellow("Analysis cancelled."));
5338
+ console.log(chalk26.yellow("Analysis cancelled."));
5200
5339
  } else {
5201
5340
  format({ status: "cancelled", runId, analysisId }, { format: outputFormat });
5202
5341
  }
5203
5342
  } else {
5204
5343
  if (outputFormat === "human") {
5205
- console.log(chalk25.red("Analysis failed."));
5344
+ console.log(chalk26.red("Analysis failed."));
5206
5345
  if (run.errorMessage) console.log(` Error: ${run.errorMessage}`);
5207
5346
  } else {
5208
5347
  format({ status: "failed", runId, analysisId, error: run.errorMessage }, { format: outputFormat });
@@ -5244,7 +5383,7 @@ async function getAnalysisDetails(analysisId, cmd) {
5244
5383
  const api = createApiClient();
5245
5384
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5246
5385
  if (!result.analysis) {
5247
- console.log(chalk25.dim("No analysis found."));
5386
+ console.log(chalk26.dim("No analysis found."));
5248
5387
  return;
5249
5388
  }
5250
5389
  format(result.analysis, { format: outputFormat });
@@ -5253,18 +5392,18 @@ async function watchAnalysis(analysisId, cmd) {
5253
5392
  const api = createApiClient();
5254
5393
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5255
5394
  if (!result.analysis) {
5256
- console.log(chalk25.dim("No analysis found."));
5395
+ console.log(chalk26.dim("No analysis found."));
5257
5396
  return;
5258
5397
  }
5259
5398
  const recipe = result.analysis;
5260
5399
  const runs = await api.analysis.getRunsForAnalysis(recipe.analysisId, 1);
5261
5400
  if (runs.length === 0) {
5262
- console.log(chalk25.dim("No runs for this analysis."));
5401
+ console.log(chalk26.dim("No runs for this analysis."));
5263
5402
  return;
5264
5403
  }
5265
5404
  const latest = runs[0];
5266
5405
  if (isTerminalState(latest.state)) {
5267
- console.log(chalk25.green(`Latest run already in terminal state: ${latest.state}`));
5406
+ console.log(chalk26.green(`Latest run already in terminal state: ${latest.state}`));
5268
5407
  try {
5269
5408
  const nav = await api.analysis.getNavigation(recipe.analysisId);
5270
5409
  const config = loadConfig();
@@ -5280,16 +5419,16 @@ async function watchAnalysis(analysisId, cmd) {
5280
5419
  async function rerunAnalysis(analysisId) {
5281
5420
  const api = createApiClient();
5282
5421
  const run = await api.analysis.runAnalysis(analysisId);
5283
- console.log(chalk25.green(`\u2713 Queued new run ${run.runId} for analysis ${analysisId}`));
5284
- console.log(chalk25.dim(` State: ${run.state}`));
5422
+ console.log(chalk26.green(`\u2713 Queued new run ${run.runId} for analysis ${analysisId}`));
5423
+ console.log(chalk26.dim(` State: ${run.state}`));
5285
5424
  console.log();
5286
- console.log(chalk25.dim("Track progress: diafunc analyze watch " + analysisId));
5425
+ console.log(chalk26.dim("Track progress: diafunc analyze watch " + analysisId));
5287
5426
  }
5288
5427
  async function openAnalysis(analysisId) {
5289
5428
  const api = createApiClient();
5290
5429
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5291
5430
  if (!result.analysis) {
5292
- console.log(chalk25.dim("No analysis found."));
5431
+ console.log(chalk26.dim("No analysis found."));
5293
5432
  return;
5294
5433
  }
5295
5434
  const config = loadConfig();
@@ -5300,7 +5439,7 @@ async function openAnalysis(analysisId) {
5300
5439
  console.log(`Opening ${url} ...`);
5301
5440
  openUrl(url);
5302
5441
  } catch {
5303
- console.log(chalk25.dim("Notebook not yet provisioned \u2014 run the analysis first."));
5442
+ console.log(chalk26.dim("Notebook not yet provisioned \u2014 run the analysis first."));
5304
5443
  }
5305
5444
  }
5306
5445
  async function createRecipe(options, cmd) {
@@ -5324,14 +5463,14 @@ async function createRecipe(options, cmd) {
5324
5463
  async function deleteAnalysis(analysisId) {
5325
5464
  const api = createApiClient();
5326
5465
  await api.analysis.delete(analysisId);
5327
- console.log(chalk25.green(`\u2713 Deleted analysis ${analysisId}`));
5466
+ console.log(chalk26.green(`\u2713 Deleted analysis ${analysisId}`));
5328
5467
  }
5329
5468
  async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
5330
5469
  const outputFormat = getOutputFormat15(cmd);
5331
5470
  const api = createApiClient();
5332
5471
  const updated = await handler(api, analysisId, value);
5333
5472
  if (outputFormat === "human") {
5334
- console.log(chalk25.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
5473
+ console.log(chalk26.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
5335
5474
  } else {
5336
5475
  format(updated, { format: outputFormat });
5337
5476
  }
@@ -5340,32 +5479,32 @@ async function uploadData(analysisId, file, options) {
5340
5479
  const api = createApiClient();
5341
5480
  if (options.url) {
5342
5481
  if (file) {
5343
- console.error(chalk25.red("Provide either a file or --url, not both."));
5482
+ console.error(chalk26.red("Provide either a file or --url, not both."));
5344
5483
  process.exit(1);
5345
5484
  }
5346
5485
  process.stdout.write(`Uploading from ${options.url} ...`);
5347
5486
  await api.analysis.uploadDataUrl(analysisId, { dataUrl: options.url });
5348
- console.log(chalk25.green(" done"));
5487
+ console.log(chalk26.green(" done"));
5349
5488
  return;
5350
5489
  }
5351
5490
  if (!file) {
5352
- console.error(chalk25.red("Provide a file path or --url <URL>."));
5491
+ console.error(chalk26.red("Provide a file path or --url <URL>."));
5353
5492
  process.exit(1);
5354
5493
  }
5355
5494
  if (!fs8.existsSync(file)) {
5356
- console.error(chalk25.red(`File not found: ${file}`));
5495
+ console.error(chalk26.red(`File not found: ${file}`));
5357
5496
  process.exit(1);
5358
5497
  }
5359
5498
  process.stdout.write(`Uploading ${path7.basename(file)} ...`);
5360
5499
  await api.analysis.uploadDataMultipart(analysisId, multipartFromFile(file));
5361
- console.log(chalk25.green(" done"));
5500
+ console.log(chalk26.green(" done"));
5362
5501
  }
5363
5502
  async function listColumns(analysisId, cmd) {
5364
5503
  const outputFormat = getOutputFormat15(cmd);
5365
5504
  const api = createApiClient();
5366
5505
  const columns = await api.analysis.getColumns(analysisId);
5367
5506
  if (columns.length === 0) {
5368
- console.log(chalk25.dim("No columns yet \u2014 upload data first."));
5507
+ console.log(chalk26.dim("No columns yet \u2014 upload data first."));
5369
5508
  return;
5370
5509
  }
5371
5510
  format(columns, { format: outputFormat, columns: ["name", "valueType"] });
@@ -5391,7 +5530,7 @@ async function cancelRun(runId, cmd) {
5391
5530
  const api = createApiClient();
5392
5531
  const run = await api.analysis.cancelRun(runId);
5393
5532
  if (outputFormat === "human") {
5394
- console.log(chalk25.green(`\u2713 Run ${run.runId} state: ${run.state}`));
5533
+ console.log(chalk26.green(`\u2713 Run ${run.runId} state: ${run.state}`));
5395
5534
  } else {
5396
5535
  format(run, { format: outputFormat });
5397
5536
  }
@@ -5418,7 +5557,7 @@ async function getPreset(presetId, cmd) {
5418
5557
  const api = createApiClient();
5419
5558
  const opt = await api.analysis.getPreset(presetId);
5420
5559
  if (!opt.preset) {
5421
- console.log(chalk25.dim("Preset not found."));
5560
+ console.log(chalk26.dim("Preset not found."));
5422
5561
  return;
5423
5562
  }
5424
5563
  format(opt.preset, { format: outputFormat });
@@ -5441,7 +5580,7 @@ async function savePreset(options, cmd) {
5441
5580
  async function deletePreset(presetId) {
5442
5581
  const api = createApiClient();
5443
5582
  await api.analysis.deletePreset(presetId);
5444
- console.log(chalk25.green(`\u2713 Deleted preset ${presetId}`));
5583
+ console.log(chalk26.green(`\u2713 Deleted preset ${presetId}`));
5445
5584
  }
5446
5585
  async function listTriggers(analysisId, cmd) {
5447
5586
  const outputFormat = getOutputFormat15(cmd);
@@ -5462,7 +5601,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
5462
5601
  const outputFormat = getOutputFormat15(cmd);
5463
5602
  const upper = kind.toUpperCase();
5464
5603
  if (upper !== "ONCE" && upper !== "CRON") {
5465
- console.error(chalk25.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
5604
+ console.error(chalk26.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
5466
5605
  process.exit(1);
5467
5606
  }
5468
5607
  const api = createApiClient();
@@ -5475,7 +5614,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
5475
5614
  async function deleteTrigger(triggerId) {
5476
5615
  const api = createApiClient();
5477
5616
  await api.analysis.deleteTrigger(triggerId);
5478
- console.log(chalk25.green(`\u2713 Deleted trigger ${triggerId}`));
5617
+ console.log(chalk26.green(`\u2713 Deleted trigger ${triggerId}`));
5479
5618
  }
5480
5619
  async function updateTriggerCmd(triggerId, options, cmd) {
5481
5620
  const outputFormat = getOutputFormat15(cmd);
@@ -5483,13 +5622,13 @@ async function updateTriggerCmd(triggerId, options, cmd) {
5483
5622
  if (options.active !== void 0) {
5484
5623
  const lc = options.active.toLowerCase();
5485
5624
  if (lc !== "true" && lc !== "false") {
5486
- console.error(chalk25.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
5625
+ console.error(chalk26.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
5487
5626
  process.exit(1);
5488
5627
  }
5489
5628
  activeFlag = lc === "true";
5490
5629
  }
5491
5630
  if (activeFlag === void 0 && !options.schedule) {
5492
- console.error(chalk25.red("Pass at least one of --active or --schedule."));
5631
+ console.error(chalk26.red("Pass at least one of --active or --schedule."));
5493
5632
  process.exit(1);
5494
5633
  }
5495
5634
  const api = createApiClient();
@@ -5501,7 +5640,7 @@ async function updateTriggerCmd(triggerId, options, cmd) {
5501
5640
  }
5502
5641
  function registerAnalyzeCommand(program) {
5503
5642
  const analyze = program.command("analyze").description("Run and manage automatic analyses");
5504
- analyze.argument("[file]", "CSV or Excel file to analyze").option("--name <name>", "Analysis name (derived from filename if omitted)").option("--description <text>", "Analysis description", "").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <hours>", "Computation time in hours", "4").option("--budget <credits>", "Credit budget", "400").option("--targets <csv>", "Comma-separated target column names").option("--questions <csv>", "Comma-separated questions to answer").option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction at notebook position 0").action(async (file, options, cmd) => {
5643
+ analyze.argument("[file]", "CSV or Excel file to analyze").option("--name <name>", "Analysis name (derived from filename if omitted)").option("--description <text>", "Analysis description", "").option("--visibility <vis>", "PRIVATE or PUBLIC", "PRIVATE").option("--hours <hours>", "Computation time in hours (default: 4; preset value used when --preset set)").option("--budget <credits>", "Credit budget (default: 400; preset value used when --preset set)").option("--targets <csv>", "Comma-separated target column names").option("--questions <csv>", "Comma-separated questions to answer").option("--segment <name>", "Column to segment the analysis by").option("--introduction <markdown>", "Markdown introduction at notebook position 0").option("--preset <id>", "Apply a saved preset as defaults (explicit flags override preset values)").action(async (file, options, cmd) => {
5505
5644
  try {
5506
5645
  if (!file) {
5507
5646
  analyze.help();
@@ -5554,8 +5693,9 @@ function registerAnalyzeCommand(program) {
5554
5693
  handleError(error);
5555
5694
  }
5556
5695
  });
5557
- analyze.command("delete").description("Delete an analysis (cancels in-flight run; removes underlying project)").argument("<id>", "Analysis ID").action(async (id) => {
5696
+ analyze.command("delete").description("Delete an analysis (cancels in-flight run; removes underlying project)").argument("<id>", "Analysis ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (id, options) => {
5558
5697
  try {
5698
+ await confirmDestructive(`This will permanently delete analysis "${id}".`, { yes: options.yes, resourceId: id });
5559
5699
  await deleteAnalysis(id);
5560
5700
  } catch (error) {
5561
5701
  handleError(error);
@@ -5681,7 +5821,7 @@ function registerAnalyzeCommand(program) {
5681
5821
  handleError(error);
5682
5822
  }
5683
5823
  });
5684
- analyze.command("upload").description("Replace the analysis raw-data table with a new CSV (file path or --url)").argument("<id>", "Analysis ID").argument("[file]", "CSV file to upload").option("--url <url>", "HTTPS URL to fetch the CSV from (mutually exclusive with file)").action(async (id, file, options) => {
5824
+ analyze.command("upload").description("Replace the analysis raw-data table with a new data table (any supported format \u2014 see `table import-formats`)").argument("<id>", "Analysis ID").argument("[file]", "CSV file to upload").option("--url <url>", "HTTPS URL to fetch the CSV from (mutually exclusive with file)").action(async (id, file, options) => {
5685
5825
  try {
5686
5826
  await uploadData(id, file, options);
5687
5827
  } catch (error) {
@@ -5731,8 +5871,9 @@ function registerAnalyzeCommand(program) {
5731
5871
  handleError(error);
5732
5872
  }
5733
5873
  });
5734
- presets.command("delete").description("Delete a preset").argument("<id>", "Preset ID").action(async (id) => {
5874
+ presets.command("delete").description("Delete a preset").argument("<id>", "Preset ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (id, options) => {
5735
5875
  try {
5876
+ await confirmDestructive(`This will permanently delete preset "${id}".`, { yes: options.yes, resourceId: id });
5736
5877
  await deletePreset(id);
5737
5878
  } catch (error) {
5738
5879
  handleError(error);
@@ -5753,8 +5894,9 @@ function registerAnalyzeCommand(program) {
5753
5894
  handleError(error);
5754
5895
  }
5755
5896
  });
5756
- triggers.command("delete").description("Delete a trigger").argument("<triggerId>", "Trigger ID").action(async (triggerId) => {
5897
+ triggers.command("delete").description("Delete a trigger").argument("<triggerId>", "Trigger ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (triggerId, options) => {
5757
5898
  try {
5899
+ await confirmDestructive(`This will permanently delete trigger "${triggerId}".`, { yes: options.yes, resourceId: triggerId });
5758
5900
  await deleteTrigger(triggerId);
5759
5901
  } catch (error) {
5760
5902
  handleError(error);
@@ -5770,7 +5912,7 @@ function registerAnalyzeCommand(program) {
5770
5912
  }
5771
5913
 
5772
5914
  // src/commands/data-sources/index.ts
5773
- import chalk26 from "chalk";
5915
+ import chalk27 from "chalk";
5774
5916
  function getOutputFormat16(cmd) {
5775
5917
  const config = loadConfig();
5776
5918
  const globalOpts = cmd.optsWithGlobals();
@@ -5864,7 +6006,7 @@ async function listDataSources(projectId, cmd) {
5864
6006
  const api = createApiClient();
5865
6007
  const sources = await api.storage.listDataSources(projectId);
5866
6008
  if (outputFormat === "human" && sources.length === 0) {
5867
- console.log(chalk26.dim("No data sources found."));
6009
+ console.log(chalk27.dim("No data sources found."));
5868
6010
  return;
5869
6011
  }
5870
6012
  format(sources.map(dataSourceTableRow), {
@@ -5887,11 +6029,11 @@ async function showDashboard(projectId, cmd) {
5887
6029
  return;
5888
6030
  }
5889
6031
  const r = dashboard.rollup;
5890
- let line = chalk26.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
6032
+ let line = chalk27.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
5891
6033
  if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
5892
6034
  console.log(line);
5893
6035
  if (dashboard.sources.length === 0) {
5894
- console.log(chalk26.dim("No data sources."));
6036
+ console.log(chalk27.dim("No data sources."));
5895
6037
  return;
5896
6038
  }
5897
6039
  format(dashboard.sources.map(dashboardTableRow), {
@@ -5914,9 +6056,9 @@ async function createDataSource(options, cmd) {
5914
6056
  };
5915
6057
  const ds = await api.storage.createDataSource(request);
5916
6058
  if (outputFormat === "human") {
5917
- console.log(chalk26.green(`\u2713 Created data source ${ds.id}`));
5918
- console.log(chalk26.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
5919
- if (ds.lastRunError) console.log(chalk26.dim(` Error: ${ds.lastRunError}`));
6059
+ console.log(chalk27.green(`\u2713 Created data source ${ds.id}`));
6060
+ console.log(chalk27.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
6061
+ if (ds.lastRunError) console.log(chalk27.dim(` Error: ${ds.lastRunError}`));
5920
6062
  } else {
5921
6063
  format(ds, { format: outputFormat });
5922
6064
  }
@@ -5946,7 +6088,7 @@ async function updateDataSource(id, options, cmd) {
5946
6088
  const api = createApiClient();
5947
6089
  const ds = await api.storage.updateDataSource(id, request);
5948
6090
  if (outputFormat === "human") {
5949
- console.log(chalk26.green(`\u2713 Updated data source ${ds.id}`));
6091
+ console.log(chalk27.green(`\u2713 Updated data source ${ds.id}`));
5950
6092
  } else {
5951
6093
  format(ds, { format: outputFormat });
5952
6094
  }
@@ -5954,15 +6096,15 @@ async function updateDataSource(id, options, cmd) {
5954
6096
  async function deleteDataSource(id) {
5955
6097
  const api = createApiClient();
5956
6098
  await api.storage.deleteDataSource(id);
5957
- console.log(chalk26.green(`\u2713 Deleted data source ${id}`));
6099
+ console.log(chalk27.green(`\u2713 Deleted data source ${id}`));
5958
6100
  }
5959
6101
  async function refreshDataSource(id, cmd) {
5960
6102
  const outputFormat = getOutputFormat16(cmd);
5961
6103
  const api = createApiClient();
5962
6104
  const run = await api.storage.refreshDataSource(id);
5963
6105
  if (outputFormat === "human") {
5964
- console.log(chalk26.green(`\u2713 Refresh queued \u2014 run ${run.runId}, status ${run.status}`));
5965
- if (run.errorMessage) console.log(chalk26.red(` Error: ${run.errorMessage}`));
6106
+ console.log(chalk27.green(`\u2713 Refresh queued \u2014 run ${run.runId}, status ${run.status}`));
6107
+ if (run.errorMessage) console.log(chalk27.red(` Error: ${run.errorMessage}`));
5966
6108
  } else {
5967
6109
  format(run, { format: outputFormat });
5968
6110
  }
@@ -5972,7 +6114,7 @@ async function listRuns2(id, limit, cmd) {
5972
6114
  const api = createApiClient();
5973
6115
  const runs = await api.storage.listDataSourceRuns(id, limit);
5974
6116
  if (outputFormat === "human" && runs.length === 0) {
5975
- console.log(chalk26.dim("No runs yet."));
6117
+ console.log(chalk27.dim("No runs yet."));
5976
6118
  return;
5977
6119
  }
5978
6120
  format(runs.map(runTableRow), {
@@ -5992,7 +6134,7 @@ async function listConnectorTypes(cmd) {
5992
6134
  const types = await api.storage.listDataSourceConnectorTypes();
5993
6135
  if (outputFormat === "human") {
5994
6136
  if (types.length === 0) {
5995
- console.log(chalk26.dim("No connector types registered."));
6137
+ console.log(chalk27.dim("No connector types registered."));
5996
6138
  return;
5997
6139
  }
5998
6140
  for (const t of types) console.log(t);
@@ -6037,8 +6179,9 @@ function registerDataSourcesCommands(program) {
6037
6179
  handleError(error);
6038
6180
  }
6039
6181
  });
6040
- dataSources.command("delete").description("Delete a data source (existing imported rows are kept)").argument("<id>", "Data source ID").action(async (id) => {
6182
+ dataSources.command("delete").description("Delete a data source (existing imported rows are kept)").argument("<id>", "Data source ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (id, options) => {
6041
6183
  try {
6184
+ await confirmDestructive(`This will permanently delete data source "${id}".`, { yes: options.yes, resourceId: id });
6042
6185
  await deleteDataSource(id);
6043
6186
  } catch (error) {
6044
6187
  handleError(error);
@@ -6075,7 +6218,7 @@ function registerDataSourcesCommands(program) {
6075
6218
  }
6076
6219
 
6077
6220
  // src/commands/table-exporters/index.ts
6078
- import chalk27 from "chalk";
6221
+ import chalk28 from "chalk";
6079
6222
  function getOutputFormat17(cmd) {
6080
6223
  const config = loadConfig();
6081
6224
  const globalOpts = cmd.optsWithGlobals();
@@ -6106,7 +6249,7 @@ function registerTableExportersCommands(program) {
6106
6249
  format: outputFormat,
6107
6250
  columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
6108
6251
  });
6109
- console.log(chalk27.dim(`${list.length} exporter(s)`));
6252
+ console.log(chalk28.dim(`${list.length} exporter(s)`));
6110
6253
  } catch (error) {
6111
6254
  handleError(error);
6112
6255
  }
@@ -6118,7 +6261,7 @@ function registerTableExportersCommands(program) {
6118
6261
  const list = await api.storage.listUserDefinedExporters();
6119
6262
  const exporter = list.find((e) => e.id === id);
6120
6263
  if (!exporter) {
6121
- console.error(chalk27.red(`No exporter with id="${id}".`));
6264
+ console.error(chalk28.red(`No exporter with id="${id}".`));
6122
6265
  process.exit(1);
6123
6266
  }
6124
6267
  format(exporter, { format: outputFormat });
@@ -6147,7 +6290,7 @@ function registerTableExportersCommands(program) {
6147
6290
  format(created, { format: outputFormat });
6148
6291
  return;
6149
6292
  }
6150
- console.log(chalk27.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
6293
+ console.log(chalk28.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
6151
6294
  } catch (error) {
6152
6295
  handleError(error);
6153
6296
  }
@@ -6156,7 +6299,7 @@ function registerTableExportersCommands(program) {
6156
6299
  try {
6157
6300
  const api = createApiClient();
6158
6301
  await api.storage.deleteUserDefinedExporter(id);
6159
- console.log(chalk27.green(`Deleted exporter id=${id}`));
6302
+ console.log(chalk28.green(`Deleted exporter id=${id}`));
6160
6303
  } catch (error) {
6161
6304
  handleError(error);
6162
6305
  }
@@ -6164,7 +6307,7 @@ function registerTableExportersCommands(program) {
6164
6307
  }
6165
6308
 
6166
6309
  // src/commands/skeleton/index.ts
6167
- import chalk28 from "chalk";
6310
+ import chalk29 from "chalk";
6168
6311
  import * as fs9 from "fs";
6169
6312
  function getOutputFormat18(cmd) {
6170
6313
  const config = loadConfig();
@@ -6230,11 +6373,11 @@ async function createSkeleton(options, cmd) {
6230
6373
  const api = createApiClient();
6231
6374
  const skeleton = await api.storage.createSkeleton(request);
6232
6375
  if (outputFormat === "human") {
6233
- console.log(chalk28.green(`\u2713 Created skeleton ${skeleton.id}`));
6234
- console.log(chalk28.dim(` name: ${skeleton.name}`));
6235
- console.log(chalk28.dim(` template: ${skeleton.template}`));
6236
- console.log(chalk28.dim(` paramCount: ${skeleton.paramCount}`));
6237
- console.log(chalk28.dim(` weight: ${skeleton.weight}`));
6376
+ console.log(chalk29.green(`\u2713 Created skeleton ${skeleton.id}`));
6377
+ console.log(chalk29.dim(` name: ${skeleton.name}`));
6378
+ console.log(chalk29.dim(` template: ${skeleton.template}`));
6379
+ console.log(chalk29.dim(` paramCount: ${skeleton.paramCount}`));
6380
+ console.log(chalk29.dim(` weight: ${skeleton.weight}`));
6238
6381
  } else {
6239
6382
  format(skeleton, { format: outputFormat });
6240
6383
  }
@@ -6245,7 +6388,7 @@ async function listSkeletons(localProject, cmd) {
6245
6388
  const api = createApiClient();
6246
6389
  const skeletons = await api.storage.listSkeletons(projectId);
6247
6390
  if (outputFormat === "human" && skeletons.length === 0) {
6248
- console.log(chalk28.dim(`No skeletons in project ${projectId}.`));
6391
+ console.log(chalk29.dim(`No skeletons in project ${projectId}.`));
6249
6392
  return;
6250
6393
  }
6251
6394
  format(skeletons.map(skeletonTableRow), {
@@ -6272,11 +6415,11 @@ async function updateSkeleton(id, options, cmd) {
6272
6415
  const api = createApiClient();
6273
6416
  const skeleton = await api.storage.updateSkeleton(id, request);
6274
6417
  if (outputFormat === "human") {
6275
- console.log(chalk28.green(`\u2713 Updated skeleton ${skeleton.id}`));
6276
- console.log(chalk28.dim(` name: ${skeleton.name}`));
6277
- console.log(chalk28.dim(` template: ${skeleton.template}`));
6278
- console.log(chalk28.dim(` paramCount: ${skeleton.paramCount}`));
6279
- console.log(chalk28.dim(` weight: ${skeleton.weight}`));
6418
+ console.log(chalk29.green(`\u2713 Updated skeleton ${skeleton.id}`));
6419
+ console.log(chalk29.dim(` name: ${skeleton.name}`));
6420
+ console.log(chalk29.dim(` template: ${skeleton.template}`));
6421
+ console.log(chalk29.dim(` paramCount: ${skeleton.paramCount}`));
6422
+ console.log(chalk29.dim(` weight: ${skeleton.weight}`));
6280
6423
  } else {
6281
6424
  format(skeleton, { format: outputFormat });
6282
6425
  }
@@ -6284,7 +6427,7 @@ async function updateSkeleton(id, options, cmd) {
6284
6427
  async function deleteSkeleton(id) {
6285
6428
  const api = createApiClient();
6286
6429
  await api.storage.deleteSkeleton(id);
6287
- console.log(chalk28.green(`\u2713 Deleted skeleton ${id}`));
6430
+ console.log(chalk29.green(`\u2713 Deleted skeleton ${id}`));
6288
6431
  }
6289
6432
  function registerSkeletonCommands(program) {
6290
6433
  const skeleton = program.command("skeleton").description("Manage user-provided skeleton templates (project-scoped, capped at 100/project)");
@@ -6319,8 +6462,9 @@ function registerSkeletonCommands(program) {
6319
6462
  handleError(error);
6320
6463
  }
6321
6464
  });
6322
- skeleton.command("delete").description("Delete a skeleton").argument("<id>", "Skeleton ID").action(async (id) => {
6465
+ skeleton.command("delete").description("Delete a skeleton").argument("<id>", "Skeleton ID").option("-y, --yes", "Skip confirmation prompt (for CI / scripted use)").action(async (id, options) => {
6323
6466
  try {
6467
+ await confirmDestructive(`This will permanently delete skeleton "${id}".`, { yes: options.yes, resourceId: id });
6324
6468
  await deleteSkeleton(id);
6325
6469
  } catch (error) {
6326
6470
  handleError(error);
@@ -6582,7 +6726,7 @@ function registerCompletionCommand(program) {
6582
6726
  }
6583
6727
 
6584
6728
  // src/commands/whoami/index.ts
6585
- import chalk29 from "chalk";
6729
+ import chalk30 from "chalk";
6586
6730
  function registerWhoamiCommand(program) {
6587
6731
  program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
6588
6732
  try {
@@ -6592,8 +6736,8 @@ function registerWhoamiCommand(program) {
6592
6736
  const api = createApiClient();
6593
6737
  const user = await api.admin.getMyUser();
6594
6738
  if (outputFormat === "human") {
6595
- console.log(chalk29.bold(user.name) + chalk29.dim(` <${user.email}>`));
6596
- console.log(chalk29.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
6739
+ console.log(chalk30.bold(user.name) + chalk30.dim(` <${user.email}>`));
6740
+ console.log(chalk30.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
6597
6741
  } else {
6598
6742
  format(user, { format: outputFormat });
6599
6743
  }
@@ -6604,7 +6748,7 @@ function registerWhoamiCommand(program) {
6604
6748
  }
6605
6749
 
6606
6750
  // src/commands/utilization/index.ts
6607
- import chalk30 from "chalk";
6751
+ import chalk31 from "chalk";
6608
6752
  function getOutputFormat19(cmd) {
6609
6753
  const config = loadConfig();
6610
6754
  const globalOpts = cmd.optsWithGlobals();
@@ -6613,21 +6757,21 @@ function getOutputFormat19(cmd) {
6613
6757
  function printUtilizationHuman(u, label) {
6614
6758
  const when = u.day !== null && u.day !== void 0 ? `${u.year}-${String(u.month).padStart(2, "0")}-${String(u.day).padStart(2, "0")}` : `${u.year}-${String(u.month).padStart(2, "0")}`;
6615
6759
  if (label) {
6616
- console.log(chalk30.bold(label) + " " + chalk30.dim(when));
6760
+ console.log(chalk31.bold(label) + " " + chalk31.dim(when));
6617
6761
  } else {
6618
- console.log(chalk30.bold(when));
6762
+ console.log(chalk31.bold(when));
6619
6763
  }
6620
6764
  if (u.types.length === 0) {
6621
- console.log(chalk30.dim(" (no usage)"));
6765
+ console.log(chalk31.dim(" (no usage)"));
6622
6766
  return;
6623
6767
  }
6624
6768
  for (const t of u.types) {
6625
6769
  console.log(
6626
- ` ${t.type.padEnd(24)} ${chalk30.cyan(String(t.quantity).padStart(10))} ${chalk30.dim("credits:")} ${t.credits.toFixed(2)}`
6770
+ ` ${t.type.padEnd(24)} ${chalk31.cyan(String(t.quantity).padStart(10))} ${chalk31.dim("credits:")} ${t.credits.toFixed(2)}`
6627
6771
  );
6628
6772
  }
6629
6773
  const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
6630
- console.log(chalk30.bold(` Total credits: ${total.toFixed(2)}`));
6774
+ console.log(chalk31.bold(` Total credits: ${total.toFixed(2)}`));
6631
6775
  }
6632
6776
  function registerUtilizationCommand(program) {
6633
6777
  const util = program.command("utilization").description("Show credit utilization");
@@ -6652,7 +6796,7 @@ function registerUtilizationCommand(program) {
6652
6796
  const history = await api.admin.getUtilizationHistory();
6653
6797
  if (outputFormat === "human") {
6654
6798
  if (history.length === 0) {
6655
- console.log(chalk30.dim("No usage recorded."));
6799
+ console.log(chalk31.dim("No usage recorded."));
6656
6800
  return;
6657
6801
  }
6658
6802
  for (const u of history) {
@@ -6669,7 +6813,7 @@ function registerUtilizationCommand(program) {
6669
6813
  }
6670
6814
 
6671
6815
  // src/commands/entity-branch/index.ts
6672
- import chalk31 from "chalk";
6816
+ import chalk32 from "chalk";
6673
6817
  function getOutputFormat20(cmd) {
6674
6818
  const config = loadConfig();
6675
6819
  const globalOpts = cmd.optsWithGlobals();
@@ -6713,7 +6857,7 @@ function registerEntityBranchCommands(program) {
6713
6857
  sourceEntityBranch: resolved.entityBranch,
6714
6858
  targetEntityBranch: targetBranch
6715
6859
  });
6716
- console.log(chalk31.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
6860
+ console.log(chalk32.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
6717
6861
  } catch (error) {
6718
6862
  handleError(error);
6719
6863
  }
@@ -6758,7 +6902,7 @@ function registerSubscriptionCommand(program) {
6758
6902
  }
6759
6903
 
6760
6904
  // src/commands/invoice/index.ts
6761
- import chalk32 from "chalk";
6905
+ import chalk33 from "chalk";
6762
6906
  import * as fs10 from "fs";
6763
6907
  function getOutputFormat22(cmd) {
6764
6908
  const config = loadConfig();
@@ -6786,7 +6930,7 @@ function registerInvoiceCommand(program) {
6786
6930
  const buffer = Buffer.from(await response.arrayBuffer());
6787
6931
  const outPath = options.out ?? fileName;
6788
6932
  fs10.writeFileSync(outPath, buffer);
6789
- console.log(chalk32.green(`Invoice saved to ${outPath}`));
6933
+ console.log(chalk33.green(`Invoice saved to ${outPath}`));
6790
6934
  } catch (error) {
6791
6935
  handleError(error);
6792
6936
  }
@@ -6794,7 +6938,7 @@ function registerInvoiceCommand(program) {
6794
6938
  }
6795
6939
 
6796
6940
  // src/commands/shell/index.ts
6797
- import chalk33 from "chalk";
6941
+ import chalk34 from "chalk";
6798
6942
  import * as fs11 from "fs";
6799
6943
  import * as os3 from "os";
6800
6944
  import * as path8 from "path";
@@ -6860,21 +7004,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
6860
7004
  }, false);
6861
7005
  if (result.outputs?.length) {
6862
7006
  for (const out of result.outputs) {
6863
- console.log(chalk33.dim(` [${out.type}]`) + " " + out.output);
7007
+ console.log(chalk34.dim(` [${out.type}]`) + " " + out.output);
6864
7008
  }
6865
7009
  }
6866
7010
  if (result.successful) {
6867
7011
  if (result.result) {
6868
- console.log(chalk33.green("=> ") + result.result);
7012
+ console.log(chalk34.green("=> ") + result.result);
6869
7013
  } else {
6870
- console.log(chalk33.dim("=> (no value)"));
7014
+ console.log(chalk34.dim("=> (no value)"));
6871
7015
  }
6872
7016
  const duration = result.completed - result.started;
6873
- console.log(chalk33.dim(` [${duration}ms \xB7 ${evaluationId}]`));
7017
+ console.log(chalk34.dim(` [${duration}ms \xB7 ${evaluationId}]`));
6874
7018
  } else {
6875
- console.log(chalk33.red("error: ") + result.error);
7019
+ console.log(chalk34.red("error: ") + result.error);
6876
7020
  if (result.lineNumber > 0) {
6877
- console.log(chalk33.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
7021
+ console.log(chalk34.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
6878
7022
  }
6879
7023
  }
6880
7024
  }
@@ -6882,9 +7026,9 @@ function registerShellCommand(program) {
6882
7026
  program.command("shell").description("Interactive REPL for function code evaluation").option("--function <ref>", "Function entity reference to use as scratch (required)").option("--language <lang>", "Source language", "JavaScript").action(async (options, cmd) => {
6883
7027
  try {
6884
7028
  if (!options.function) {
6885
- console.error(chalk33.red("Missing --function <ref>."));
6886
- console.error(chalk33.dim("Pass an existing or new function entity reference to use as the shell target."));
6887
- console.error(chalk33.dim("Example: diafunc shell --function my-project/main/scratch/main --language JavaScript"));
7029
+ console.error(chalk34.red("Missing --function <ref>."));
7030
+ console.error(chalk34.dim("Pass an existing or new function entity reference to use as the shell target."));
7031
+ console.error(chalk34.dim("Example: diafunc shell --function my-project/main/scratch/main --language JavaScript"));
6888
7032
  process.exit(1);
6889
7033
  }
6890
7034
  const config = loadConfig();
@@ -6895,18 +7039,18 @@ function registerShellCommand(program) {
6895
7039
  });
6896
7040
  const api = createApiClient();
6897
7041
  const { input: promptInput } = await import("@inquirer/prompts");
6898
- const { getUpdateNotice } = await import("./update-check-KL3CHODI.js");
6899
- console.log(chalk33.bold("Diafunc shell") + chalk33.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
6900
- console.log(chalk33.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
6901
- console.log(chalk33.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
7042
+ const { getUpdateNotice } = await import("./update-check-2X2AIL52.js");
7043
+ console.log(chalk34.bold("Diafunc shell") + chalk34.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
7044
+ console.log(chalk34.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
7045
+ console.log(chalk34.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
6902
7046
  const notice = await getUpdateNotice();
6903
- if (notice) console.log(chalk33.dim(notice));
7047
+ if (notice) console.log(chalk34.dim(notice));
6904
7048
  console.log();
6905
7049
  let language = options.language;
6906
7050
  for (; ; ) {
6907
7051
  let line;
6908
7052
  try {
6909
- line = await promptInput({ message: chalk33.cyan.bold(`${language} >`) });
7053
+ line = await promptInput({ message: chalk34.cyan.bold(`${language} >`) });
6910
7054
  } catch {
6911
7055
  console.log();
6912
7056
  return;
@@ -6924,54 +7068,54 @@ function registerShellCommand(program) {
6924
7068
  case "help":
6925
7069
  case "h":
6926
7070
  case "?":
6927
- console.log(chalk33.dim(" /edit open $EDITOR for multi-line code"));
6928
- console.log(chalk33.dim(" /file <path> evaluate the contents of a file"));
6929
- console.log(chalk33.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
6930
- console.log(chalk33.dim(" /quit exit the shell"));
7071
+ console.log(chalk34.dim(" /edit open $EDITOR for multi-line code"));
7072
+ console.log(chalk34.dim(" /file <path> evaluate the contents of a file"));
7073
+ console.log(chalk34.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
7074
+ console.log(chalk34.dim(" /quit exit the shell"));
6931
7075
  continue;
6932
7076
  case "lang":
6933
7077
  if (arg) language = arg;
6934
- console.log(chalk33.dim(`Language: ${language}`));
7078
+ console.log(chalk34.dim(`Language: ${language}`));
6935
7079
  continue;
6936
7080
  case "edit": {
6937
7081
  const sourceCode = await openInEditor("", extensionFor2(language));
6938
7082
  if (!sourceCode.trim()) {
6939
- console.log(chalk33.dim("(empty \u2014 not evaluated)"));
7083
+ console.log(chalk34.dim("(empty \u2014 not evaluated)"));
6940
7084
  continue;
6941
7085
  }
6942
7086
  try {
6943
7087
  await evaluate(api, fnRef, language, sourceCode);
6944
7088
  } catch (e) {
6945
- console.error(chalk33.red(e.message));
7089
+ console.error(chalk34.red(e.message));
6946
7090
  }
6947
7091
  continue;
6948
7092
  }
6949
7093
  case "file": {
6950
7094
  if (!arg) {
6951
- console.log(chalk33.dim("usage: /file <path>"));
7095
+ console.log(chalk34.dim("usage: /file <path>"));
6952
7096
  continue;
6953
7097
  }
6954
7098
  if (!fs11.existsSync(arg)) {
6955
- console.log(chalk33.red(`file not found: ${arg}`));
7099
+ console.log(chalk34.red(`file not found: ${arg}`));
6956
7100
  continue;
6957
7101
  }
6958
7102
  const sourceCode = fs11.readFileSync(arg, "utf-8");
6959
7103
  try {
6960
7104
  await evaluate(api, fnRef, language, sourceCode);
6961
7105
  } catch (e) {
6962
- console.error(chalk33.red(e.message));
7106
+ console.error(chalk34.red(e.message));
6963
7107
  }
6964
7108
  continue;
6965
7109
  }
6966
7110
  default:
6967
- console.log(chalk33.dim(`Unknown command: /${cmd2}. Try /help.`));
7111
+ console.log(chalk34.dim(`Unknown command: /${cmd2}. Try /help.`));
6968
7112
  continue;
6969
7113
  }
6970
7114
  }
6971
7115
  try {
6972
7116
  await evaluate(api, fnRef, language, trimmed);
6973
7117
  } catch (e) {
6974
- console.error(chalk33.red(e.message));
7118
+ console.error(chalk34.red(e.message));
6975
7119
  }
6976
7120
  }
6977
7121
  } catch (error) {
@@ -6981,7 +7125,7 @@ function registerShellCommand(program) {
6981
7125
  }
6982
7126
 
6983
7127
  // src/commands/update/index.ts
6984
- import chalk34 from "chalk";
7128
+ import chalk35 from "chalk";
6985
7129
  import * as path9 from "path";
6986
7130
  import { spawn as spawn4 } from "child_process";
6987
7131
 
@@ -7027,14 +7171,14 @@ function registerUpdateCommand(program) {
7027
7171
  const install = detectInstall();
7028
7172
  const latest = await fetchLatestVersion();
7029
7173
  if (latest === package_default.version) {
7030
- console.log(chalk34.dim(`diafunc is already at the latest version (${package_default.version}).`));
7174
+ console.log(chalk35.dim(`diafunc is already at the latest version (${package_default.version}).`));
7031
7175
  return;
7032
7176
  }
7033
- console.log(chalk34.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
7177
+ console.log(chalk35.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
7034
7178
  if (install.method === "npm") {
7035
7179
  console.log();
7036
7180
  console.log("Installed via npm. Upgrade with:");
7037
- console.log(chalk34.bold(` npm install -g @diafunc/cli@${latest}`));
7181
+ console.log(chalk35.bold(` npm install -g @diafunc/cli@${latest}`));
7038
7182
  return;
7039
7183
  }
7040
7184
  const installDir = path9.dirname(install.binaryPath);
@@ -7048,7 +7192,7 @@ function registerUpdateCommand(program) {
7048
7192
  }
7049
7193
 
7050
7194
  // src/commands/uninstall/index.ts
7051
- import chalk35 from "chalk";
7195
+ import chalk36 from "chalk";
7052
7196
  import { spawn as spawn5 } from "child_process";
7053
7197
  import * as fs13 from "fs";
7054
7198
  import * as os4 from "os";
@@ -7060,11 +7204,11 @@ function registerUninstallCommand(program) {
7060
7204
  const configDir = path10.join(os4.homedir(), ".diafunc");
7061
7205
  if (install.method === "npm") {
7062
7206
  console.log("Installed via npm. Remove with:");
7063
- console.log(chalk35.bold(" npm uninstall -g @diafunc/cli"));
7207
+ console.log(chalk36.bold(" npm uninstall -g @diafunc/cli"));
7064
7208
  if (fs13.existsSync(configDir)) {
7065
7209
  console.log();
7066
7210
  console.log(`Config + credentials live at ${configDir} \u2014 remove manually with:`);
7067
- console.log(chalk35.bold(` rm -rf ${configDir}`));
7211
+ console.log(chalk36.bold(` rm -rf ${configDir}`));
7068
7212
  }
7069
7213
  return;
7070
7214
  }
@@ -7074,7 +7218,7 @@ function registerUninstallCommand(program) {
7074
7218
  default: false
7075
7219
  });
7076
7220
  if (!removeBinary) {
7077
- console.log(chalk35.dim("Aborted."));
7221
+ console.log(chalk36.dim("Aborted."));
7078
7222
  return;
7079
7223
  }
7080
7224
  let removeConfig = options.purge ?? false;
@@ -7086,7 +7230,7 @@ function registerUninstallCommand(program) {
7086
7230
  }
7087
7231
  if (removeConfig && fs13.existsSync(configDir)) {
7088
7232
  fs13.rmSync(configDir, { recursive: true, force: true });
7089
- console.log(chalk35.dim(`Removed ${configDir}`));
7233
+ console.log(chalk36.dim(`Removed ${configDir}`));
7090
7234
  }
7091
7235
  if (process.platform === "win32") {
7092
7236
  const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
@@ -7096,13 +7240,13 @@ function registerUninstallCommand(program) {
7096
7240
  windowsHide: true
7097
7241
  });
7098
7242
  child.unref();
7099
- console.log(chalk35.dim(`Removing ${install.binaryPath} on exit...`));
7243
+ console.log(chalk36.dim(`Removing ${install.binaryPath} on exit...`));
7100
7244
  console.log();
7101
7245
  console.log("diafunc uninstalled.");
7102
7246
  return;
7103
7247
  }
7104
7248
  fs13.rmSync(install.binaryPath, { force: true });
7105
- console.log(chalk35.dim(`Removed ${install.binaryPath}`));
7249
+ console.log(chalk36.dim(`Removed ${install.binaryPath}`));
7106
7250
  console.log();
7107
7251
  console.log("diafunc uninstalled.");
7108
7252
  } catch (error) {
@@ -7156,4 +7300,4 @@ function createProgram() {
7156
7300
  export {
7157
7301
  createProgram
7158
7302
  };
7159
- //# sourceMappingURL=chunk-E4O67FMQ.js.map
7303
+ //# sourceMappingURL=chunk-WHWVHDRF.js.map