@diafunc/cli 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-NSFXPO66.js";
3
+ } from "./chunk-GQBGVUCT.js";
4
4
 
5
5
  // src/index.ts
6
6
  import { Command } from "commander";
@@ -411,91 +411,194 @@ function createAdminService(client) {
411
411
  path: `/api-tokens/${encodeURIComponent(tokenId)}`
412
412
  });
413
413
  },
414
- // Groups
415
- async getGroups() {
414
+ // Teams
415
+ async listMyTeams() {
416
416
  return client.request({
417
417
  method: "GET",
418
418
  service: SERVICE,
419
- path: "/groups/"
419
+ path: "/me/teams"
420
420
  });
421
421
  },
422
- async getAllGroups() {
422
+ async getTeam(teamId) {
423
423
  return client.request({
424
424
  method: "GET",
425
425
  service: SERVICE,
426
- path: "/groups/all"
426
+ path: `/teams/${encodeURIComponent(teamId)}`
427
427
  });
428
428
  },
429
- async getGroup(groupId) {
429
+ async setActiveTeam(teamId) {
430
430
  return client.request({
431
- method: "GET",
431
+ method: "POST",
432
432
  service: SERVICE,
433
- path: `/groups/${encodeURIComponent(groupId)}`
433
+ path: `/me/active-team/${encodeURIComponent(teamId)}`
434
434
  });
435
435
  },
436
- async createGroup(group) {
436
+ async startTeamCheckout(request) {
437
437
  return client.request({
438
438
  method: "POST",
439
439
  service: SERVICE,
440
- path: "/groups/",
441
- body: group
440
+ path: "/teams/checkout",
441
+ body: request
442
442
  });
443
443
  },
444
- async updateGroup(group) {
444
+ async createTeamPortalSession(teamId, returnUrl) {
445
445
  return client.request({
446
- method: "PUT",
446
+ method: "POST",
447
447
  service: SERVICE,
448
- path: "/groups/",
449
- body: group
448
+ path: `/teams/${encodeURIComponent(teamId)}/portal-session`,
449
+ body: { returnUrl }
450
450
  });
451
451
  },
452
- async deleteGroup(groupId) {
452
+ async cancelTeam(teamId) {
453
453
  return client.request({
454
454
  method: "DELETE",
455
455
  service: SERVICE,
456
- path: `/groups/${encodeURIComponent(groupId)}`
456
+ path: `/teams/${encodeURIComponent(teamId)}`
457
+ });
458
+ },
459
+ async getTeamUsage(teamId) {
460
+ return client.request({
461
+ method: "GET",
462
+ service: SERVICE,
463
+ path: `/teams/${encodeURIComponent(teamId)}/usage`
457
464
  });
458
465
  },
459
- async getGroupMembers(groupId) {
466
+ // Team members
467
+ async listTeamMembers(teamId) {
460
468
  return client.request({
461
469
  method: "GET",
462
470
  service: SERVICE,
463
- path: `/groups/members/${encodeURIComponent(groupId)}`
471
+ path: `/teams/${encodeURIComponent(teamId)}/members`
464
472
  });
465
473
  },
466
- async inviteGroupMember(groupId, userId, role) {
474
+ async inviteTeamMember(teamId, email, role) {
467
475
  return client.request({
468
476
  method: "POST",
469
477
  service: SERVICE,
470
- path: `/groups/members/invitations/${encodeURIComponent(groupId)}/${encodeURIComponent(userId)}/${encodeURIComponent(role)}`
478
+ path: `/teams/${encodeURIComponent(teamId)}/members/invite`,
479
+ body: { email, role }
471
480
  });
472
481
  },
473
- async removeGroupMember(groupId, userId) {
482
+ async removeTeamMember(teamId, userId) {
474
483
  return client.request({
475
484
  method: "DELETE",
476
485
  service: SERVICE,
477
- path: `/groups/members/${encodeURIComponent(groupId)}/${encodeURIComponent(userId)}`
486
+ path: `/teams/${encodeURIComponent(teamId)}/members/${encodeURIComponent(userId)}`
487
+ });
488
+ },
489
+ async leaveTeam(teamId) {
490
+ return client.request({
491
+ method: "DELETE",
492
+ service: SERVICE,
493
+ path: `/me/teams/${encodeURIComponent(teamId)}`
494
+ });
495
+ },
496
+ // Team invitations
497
+ async listTeamInvitations(teamId) {
498
+ return client.request({
499
+ method: "GET",
500
+ service: SERVICE,
501
+ path: `/teams/${encodeURIComponent(teamId)}/invitations`
502
+ });
503
+ },
504
+ async revokeTeamInvitation(teamId, invitationId) {
505
+ return client.request({
506
+ method: "DELETE",
507
+ service: SERVICE,
508
+ path: `/teams/${encodeURIComponent(teamId)}/invitations/${encodeURIComponent(invitationId)}`
509
+ });
510
+ },
511
+ async resendTeamInvitation(teamId, invitationId) {
512
+ return client.request({
513
+ method: "POST",
514
+ service: SERVICE,
515
+ path: `/teams/${encodeURIComponent(teamId)}/invitations/${encodeURIComponent(invitationId)}/resend`
516
+ });
517
+ },
518
+ async acceptTeamInvitation(token) {
519
+ return client.request({
520
+ method: "POST",
521
+ service: SERVICE,
522
+ path: `/invitations/${encodeURIComponent(token)}/accept`
523
+ });
524
+ },
525
+ // Seats and extension packs
526
+ async previewTeamSeatCount(teamId, seatCount) {
527
+ return client.request({
528
+ method: "POST",
529
+ service: SERVICE,
530
+ path: `/teams/${encodeURIComponent(teamId)}/seat-count/preview`,
531
+ body: { seatCount }
532
+ });
533
+ },
534
+ async updateTeamSeatCount(teamId, seatCount) {
535
+ return client.request({
536
+ method: "POST",
537
+ service: SERVICE,
538
+ path: `/teams/${encodeURIComponent(teamId)}/seat-count`,
539
+ body: { seatCount }
540
+ });
541
+ },
542
+ async previewTeamPackCount(teamId, packCount) {
543
+ return client.request({
544
+ method: "POST",
545
+ service: SERVICE,
546
+ path: `/teams/${encodeURIComponent(teamId)}/pack-count/preview`,
547
+ body: { packCount }
548
+ });
549
+ },
550
+ async updateTeamPackCount(teamId, packCount) {
551
+ return client.request({
552
+ method: "POST",
553
+ service: SERVICE,
554
+ path: `/teams/${encodeURIComponent(teamId)}/pack-count`,
555
+ body: { packCount }
478
556
  });
479
557
  },
480
- async getGroupProjects(groupId) {
558
+ // Ownership transfer
559
+ async initiateOwnershipTransfer(teamId, newOwnerUserId) {
560
+ return client.request({
561
+ method: "POST",
562
+ service: SERVICE,
563
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`,
564
+ body: { newOwnerUserId }
565
+ });
566
+ },
567
+ async getOwnershipTransfer(teamId) {
481
568
  return client.request({
482
569
  method: "GET",
483
570
  service: SERVICE,
484
- path: `/groups/projects/${encodeURIComponent(groupId)}`
571
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
485
572
  });
486
573
  },
487
- async addGroupProject(groupId, projectId) {
574
+ async acceptOwnershipTransfer(teamId) {
488
575
  return client.request({
489
576
  method: "POST",
490
577
  service: SERVICE,
491
- path: `/groups/projects/${encodeURIComponent(groupId)}/${encodeURIComponent(projectId)}`
578
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer/accept`
492
579
  });
493
580
  },
494
- async removeGroupProject(groupId, projectId) {
581
+ async cancelOwnershipTransfer(teamId) {
495
582
  return client.request({
496
583
  method: "DELETE",
497
584
  service: SERVICE,
498
- path: `/groups/projects/${encodeURIComponent(groupId)}/${encodeURIComponent(projectId)}`
585
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
586
+ });
587
+ },
588
+ // Team contracts (super-admin only)
589
+ async issueTeamContract(teamId, request) {
590
+ return client.request({
591
+ method: "POST",
592
+ service: SERVICE,
593
+ path: `/teams/${encodeURIComponent(teamId)}/contract`,
594
+ body: request
595
+ });
596
+ },
597
+ async getTeamContract(teamId) {
598
+ return client.request({
599
+ method: "GET",
600
+ service: SERVICE,
601
+ path: `/teams/${encodeURIComponent(teamId)}/contract`
499
602
  });
500
603
  },
501
604
  // Settings
@@ -774,6 +877,9 @@ function registerLogoutCommand(parent) {
774
877
  }
775
878
 
776
879
  // src/commands/auth/status.ts
880
+ import chalk6 from "chalk";
881
+
882
+ // src/output/formatter.ts
777
883
  import chalk5 from "chalk";
778
884
 
779
885
  // src/output/human.ts
@@ -855,6 +961,13 @@ function format(data, options) {
855
961
  break;
856
962
  }
857
963
  }
964
+ function formatMessage(message, options) {
965
+ if (options.format === "json") {
966
+ formatJson({ message });
967
+ } else {
968
+ console.log(chalk5.green(message));
969
+ }
970
+ }
858
971
 
859
972
  // src/commands/auth/status.ts
860
973
  function registerStatusCommand(parent) {
@@ -868,7 +981,7 @@ function registerStatusCommand(parent) {
868
981
  if (outputFormat === "json") {
869
982
  console.log(JSON.stringify({ authenticated: false, profile: config.currentProfile }));
870
983
  } else {
871
- console.log(chalk5.yellow("Not authenticated."), `Run 'diafunc auth login' to configure credentials.`);
984
+ console.log(chalk6.yellow("Not authenticated."), `Run 'diafunc auth login' to configure credentials.`);
872
985
  console.log(` Profile: ${config.currentProfile}`);
873
986
  console.log(` Endpoint: ${profile?.endpoint ?? "not configured"}`);
874
987
  }
@@ -896,7 +1009,7 @@ function registerStatusCommand(parent) {
896
1009
  }
897
1010
 
898
1011
  // src/commands/auth/token.ts
899
- import chalk6 from "chalk";
1012
+ import chalk7 from "chalk";
900
1013
 
901
1014
  // src/client/services/analysis.ts
902
1015
  var SERVICE2 = "analyses";
@@ -1531,6 +1644,27 @@ function createStorageService(client) {
1531
1644
  path: `/table-exports/supported-formats`
1532
1645
  });
1533
1646
  },
1647
+ /** List all async exports for an entity (see ExportsResource#getExports). */
1648
+ async listExports(ref) {
1649
+ return client.request({
1650
+ method: "GET",
1651
+ service: SERVICE3,
1652
+ path: `/exports${entityPath(ref)}`
1653
+ });
1654
+ },
1655
+ /**
1656
+ * Download the bytes of a completed async export.
1657
+ * Path mirrors ExportsResource#getContent: /exports/{entity}/{exportId}/{filename}.
1658
+ * The {filename} segment is part of the server URL but is not used for lookup —
1659
+ * only exportId determines the row; pass StorageExport.filename verbatim.
1660
+ */
1661
+ async downloadExport(ref, exportId, filename) {
1662
+ return client.requestRaw({
1663
+ method: "GET",
1664
+ service: SERVICE3,
1665
+ path: `/exports${entityPath(ref)}/${enc(exportId)}/${enc(filename)}`
1666
+ });
1667
+ },
1534
1668
  // --- Branches ---
1535
1669
  async getProjectBranches(projectId) {
1536
1670
  return client.request({
@@ -2131,6 +2265,7 @@ function createApiClient(options = {}) {
2131
2265
  }
2132
2266
 
2133
2267
  // src/commands/auth/token.ts
2268
+ var VALID_RESOURCE_TYPES = ["project", "team"];
2134
2269
  var VALID_SCOPES = [
2135
2270
  "project:read",
2136
2271
  "project:write",
@@ -2141,15 +2276,23 @@ var VALID_SCOPES = [
2141
2276
  ];
2142
2277
  function registerTokenCommands(parent) {
2143
2278
  const token = parent.command("token").description("Manage API tokens");
2144
- token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Resource ID (project or group)").requiredOption("--scopes <scopes>", `Comma-separated scopes: ${VALID_SCOPES.join(", ")}`).option("--resource-type <type>", "Resource type (project or group)", "project").option("--days <days>", "Validity in days (default: 365)", "365").action(async (options, cmd) => {
2279
+ token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Resource ID (project or team)").requiredOption("--scopes <scopes>", `Comma-separated scopes: ${VALID_SCOPES.join(", ")}`).option("--resource-type <type>", `Resource type: ${VALID_RESOURCE_TYPES.join(", ")}`, "project").option("--days <days>", "Validity in days (default: 365)", "365").action(async (options, cmd) => {
2145
2280
  try {
2146
2281
  const config = loadConfig();
2147
2282
  const globalOpts = cmd.optsWithGlobals();
2148
2283
  const outputFormat = globalOpts.output ?? config.defaults.output ?? "human";
2284
+ const resourceType = options.resourceType.trim().toLowerCase();
2285
+ if (!VALID_RESOURCE_TYPES.includes(resourceType)) {
2286
+ console.error(
2287
+ chalk7.red(`Invalid resource type: "${options.resourceType}".`),
2288
+ `Valid resource types: ${VALID_RESOURCE_TYPES.join(", ")}`
2289
+ );
2290
+ process.exit(1);
2291
+ }
2149
2292
  const scopes = options.scopes.split(",").map((s) => s.trim());
2150
2293
  for (const scope of scopes) {
2151
2294
  if (!VALID_SCOPES.includes(scope)) {
2152
- console.error(chalk6.red(`Invalid scope: "${scope}".`), `Valid scopes: ${VALID_SCOPES.join(", ")}`);
2295
+ console.error(chalk7.red(`Invalid scope: "${scope}".`), `Valid scopes: ${VALID_SCOPES.join(", ")}`);
2153
2296
  process.exit(1);
2154
2297
  }
2155
2298
  }
@@ -2157,19 +2300,19 @@ function registerTokenCommands(parent) {
2157
2300
  const result = await api.admin.createApiToken({
2158
2301
  name: options.name,
2159
2302
  resourceId: options.resource,
2160
- resourceType: options.resourceType,
2303
+ resourceType,
2161
2304
  scopes,
2162
2305
  validityDays: parseInt(options.days, 10)
2163
2306
  });
2164
2307
  if (outputFormat === "human") {
2165
- console.log(chalk6.green("API token created successfully."));
2308
+ console.log(chalk7.green("API token created successfully."));
2166
2309
  console.log();
2167
- console.log(` Token: ${chalk6.bold(result.token)}`);
2310
+ console.log(` Token: ${chalk7.bold(result.token)}`);
2168
2311
  console.log(` Token ID: ${result.tokenId}`);
2169
2312
  console.log(` Name: ${result.name}`);
2170
2313
  console.log(` Expires: ${result.expiresAt}`);
2171
2314
  console.log();
2172
- console.log(chalk6.yellow("Save this token \u2014 it will not be shown again."));
2315
+ console.log(chalk7.yellow("Save this token \u2014 it will not be shown again."));
2173
2316
  } else {
2174
2317
  format(result, { format: outputFormat });
2175
2318
  }
@@ -2196,7 +2339,7 @@ function registerTokenCommands(parent) {
2196
2339
  try {
2197
2340
  const api = createApiClient();
2198
2341
  await api.admin.revokeApiToken(tokenId);
2199
- console.log(chalk6.green(`Token ${tokenId} revoked.`));
2342
+ console.log(chalk7.green(`Token ${tokenId} revoked.`));
2200
2343
  } catch (error) {
2201
2344
  handleError(error);
2202
2345
  }
@@ -2213,20 +2356,20 @@ function registerAuthCommands(program) {
2213
2356
  }
2214
2357
 
2215
2358
  // src/commands/config/index.ts
2216
- import chalk7 from "chalk";
2359
+ import chalk8 from "chalk";
2217
2360
  function registerConfigCommands(program) {
2218
2361
  const config = program.command("config").description("Manage CLI configuration");
2219
2362
  config.command("set").description("Set a configuration value").argument("<key>", "Config key (e.g., defaults.project, defaults.branch, defaults.output)").argument("<value>", "Config value").action((key, value) => {
2220
2363
  const cfg = loadConfig();
2221
2364
  setNestedValue(cfg, key, value);
2222
2365
  saveConfig(cfg);
2223
- console.log(chalk7.green(`Set ${key} = ${value}`));
2366
+ console.log(chalk8.green(`Set ${key} = ${value}`));
2224
2367
  });
2225
2368
  config.command("get").description("Get a configuration value").argument("<key>", "Config key").action((key) => {
2226
2369
  const cfg = loadConfig();
2227
2370
  const value = getNestedValue(cfg, key);
2228
2371
  if (value === void 0) {
2229
- console.log(chalk7.dim("(not set)"));
2372
+ console.log(chalk8.dim("(not set)"));
2230
2373
  } else {
2231
2374
  console.log(String(value));
2232
2375
  }
@@ -2236,20 +2379,20 @@ function registerConfigCommands(program) {
2236
2379
  const globalOpts = cmd.optsWithGlobals();
2237
2380
  const outputFormat = globalOpts.output ?? "human";
2238
2381
  if (outputFormat === "human") {
2239
- console.log(chalk7.bold("Config file:"), CONFIG_FILE);
2240
- console.log(chalk7.bold("Active profile:"), cfg.currentProfile);
2382
+ console.log(chalk8.bold("Config file:"), CONFIG_FILE);
2383
+ console.log(chalk8.bold("Active profile:"), cfg.currentProfile);
2241
2384
  console.log();
2242
- console.log(chalk7.bold("Profiles:"));
2385
+ console.log(chalk8.bold("Profiles:"));
2243
2386
  for (const [name, profile2] of Object.entries(cfg.profiles)) {
2244
- const active = name === cfg.currentProfile ? chalk7.green(" (active)") : "";
2387
+ const active = name === cfg.currentProfile ? chalk8.green(" (active)") : "";
2245
2388
  const authType = profile2.auth?.type ?? "none";
2246
- console.log(` ${chalk7.bold(name)}${active}`);
2389
+ console.log(` ${chalk8.bold(name)}${active}`);
2247
2390
  console.log(` Endpoint: ${profile2.endpoint}`);
2248
2391
  console.log(` Auth: ${authType}`);
2249
2392
  }
2250
2393
  if (Object.keys(cfg.defaults).length > 0) {
2251
2394
  console.log();
2252
- console.log(chalk7.bold("Defaults:"));
2395
+ console.log(chalk8.bold("Defaults:"));
2253
2396
  for (const [key, value] of Object.entries(cfg.defaults)) {
2254
2397
  console.log(` ${key}: ${value}`);
2255
2398
  }
@@ -2262,7 +2405,7 @@ function registerConfigCommands(program) {
2262
2405
  profile.command("add").description("Add a new profile").argument("<name>", "Profile name").option("--endpoint <url>", "API endpoint URL", "https://diafunc.com").option("--token <token>", "API token to store").action((name, options) => {
2263
2406
  const cfg = loadConfig();
2264
2407
  if (cfg.profiles[name]) {
2265
- console.error(chalk7.red(`Profile "${name}" already exists. Use 'diafunc config profile use' to switch to it.`));
2408
+ console.error(chalk8.red(`Profile "${name}" already exists. Use 'diafunc config profile use' to switch to it.`));
2266
2409
  process.exit(1);
2267
2410
  }
2268
2411
  cfg.profiles[name] = {
@@ -2270,18 +2413,18 @@ function registerConfigCommands(program) {
2270
2413
  ...options.token ? { auth: { type: "api-token", token: options.token } } : {}
2271
2414
  };
2272
2415
  saveConfig(cfg);
2273
- console.log(chalk7.green(`Profile "${name}" added.`));
2416
+ console.log(chalk8.green(`Profile "${name}" added.`));
2274
2417
  });
2275
2418
  profile.command("use").description("Switch to a profile").argument("<name>", "Profile name").action((name) => {
2276
2419
  const cfg = loadConfig();
2277
2420
  if (!cfg.profiles[name]) {
2278
- console.error(chalk7.red(`Profile "${name}" not found.`));
2421
+ console.error(chalk8.red(`Profile "${name}" not found.`));
2279
2422
  console.log(`Available profiles: ${Object.keys(cfg.profiles).join(", ")}`);
2280
2423
  process.exit(1);
2281
2424
  }
2282
2425
  cfg.currentProfile = name;
2283
2426
  saveConfig(cfg);
2284
- console.log(chalk7.green(`Switched to profile "${name}".`));
2427
+ console.log(chalk8.green(`Switched to profile "${name}".`));
2285
2428
  });
2286
2429
  profile.command("list").description("List all profiles").action((_options, cmd) => {
2287
2430
  const cfg = loadConfig();
@@ -2301,16 +2444,16 @@ function registerConfigCommands(program) {
2301
2444
  profile.command("remove").description("Remove a profile").argument("<name>", "Profile name").action((name) => {
2302
2445
  const cfg = loadConfig();
2303
2446
  if (!cfg.profiles[name]) {
2304
- console.error(chalk7.red(`Profile "${name}" not found.`));
2447
+ console.error(chalk8.red(`Profile "${name}" not found.`));
2305
2448
  process.exit(1);
2306
2449
  }
2307
2450
  if (name === cfg.currentProfile) {
2308
- console.error(chalk7.red(`Cannot remove the active profile. Switch to another profile first.`));
2451
+ console.error(chalk8.red(`Cannot remove the active profile. Switch to another profile first.`));
2309
2452
  process.exit(1);
2310
2453
  }
2311
2454
  delete cfg.profiles[name];
2312
2455
  saveConfig(cfg);
2313
- console.log(chalk7.green(`Profile "${name}" removed.`));
2456
+ console.log(chalk8.green(`Profile "${name}" removed.`));
2314
2457
  });
2315
2458
  }
2316
2459
  function setNestedValue(obj, path11, value) {
@@ -2338,7 +2481,7 @@ function getNestedValue(obj, path11) {
2338
2481
  }
2339
2482
 
2340
2483
  // src/commands/project/index.ts
2341
- import chalk9 from "chalk";
2484
+ import chalk10 from "chalk";
2342
2485
 
2343
2486
  // src/util/references.ts
2344
2487
  function parseEntityReference(ref, overrides) {
@@ -2423,7 +2566,7 @@ function parseProjectReference(ref, overrides) {
2423
2566
  }
2424
2567
 
2425
2568
  // src/commands/bundle-helpers.ts
2426
- import chalk8 from "chalk";
2569
+ import chalk9 from "chalk";
2427
2570
  import * as fs2 from "fs";
2428
2571
  import * as path2 from "path";
2429
2572
  async function streamResponseToFile(response, outFile) {
@@ -2433,19 +2576,19 @@ async function streamResponseToFile(response, outFile) {
2433
2576
  }
2434
2577
  function printLossiness(notes) {
2435
2578
  if (notes && notes.length > 0) {
2436
- console.log(chalk8.yellow("Lossiness:"));
2579
+ console.log(chalk9.yellow("Lossiness:"));
2437
2580
  for (const note of notes) {
2438
- console.log(chalk8.yellow(` - ${note}`));
2581
+ console.log(chalk9.yellow(` - ${note}`));
2439
2582
  }
2440
2583
  }
2441
2584
  }
2442
2585
  function printImportPreview(preview) {
2443
- console.log(chalk8.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
2586
+ console.log(chalk9.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
2444
2587
  if (preview.projectName) {
2445
- console.log(chalk8.dim(preview.projectName));
2588
+ console.log(chalk9.dim(preview.projectName));
2446
2589
  }
2447
2590
  if (preview.sourceProjectId) {
2448
- console.log(chalk8.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
2591
+ console.log(chalk9.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
2449
2592
  }
2450
2593
  const counts = /* @__PURE__ */ new Map();
2451
2594
  for (const e of preview.entities ?? []) {
@@ -2466,7 +2609,7 @@ function printImportPreview(preview) {
2466
2609
  printLossiness(preview.lossinessNotes);
2467
2610
  }
2468
2611
  function printImportResult(result) {
2469
- console.log(chalk8.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
2612
+ console.log(chalk9.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
2470
2613
  if (result.skeletonCount) {
2471
2614
  console.log(`Skeletons: ${result.skeletonCount}`);
2472
2615
  }
@@ -2537,7 +2680,7 @@ function registerProjectCommands(program) {
2537
2680
  const projects = options.all ? await api.admin.getAllProjects() : await api.admin.getProjects();
2538
2681
  format(projects, {
2539
2682
  format: outputFormat,
2540
- columns: ["projectId", "groupId", "visibility", "language", "active", "locked"]
2683
+ columns: ["projectId", "teamName", "visibility", "language", "active", "locked"]
2541
2684
  });
2542
2685
  } catch (error) {
2543
2686
  handleError(error);
@@ -2563,8 +2706,8 @@ function registerProjectCommands(program) {
2563
2706
  active: true
2564
2707
  });
2565
2708
  if (outputFormat === "human") {
2566
- console.log(chalk9.green("Project created."));
2567
- console.log(` Project ID: ${chalk9.bold(p.projectId)}`);
2709
+ console.log(chalk10.green("Project created."));
2710
+ console.log(` Project ID: ${chalk10.bold(p.projectId)}`);
2568
2711
  console.log(` Visibility: ${p.visibility}`);
2569
2712
  console.log(` Language: ${p.language}`);
2570
2713
  } else {
@@ -2574,7 +2717,7 @@ function registerProjectCommands(program) {
2574
2717
  handleError(error);
2575
2718
  }
2576
2719
  });
2577
- project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--group <groupId>", "Group ID (empty string to unset)").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
2720
+ project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
2578
2721
  try {
2579
2722
  const api = createApiClient();
2580
2723
  const current = await api.admin.getProject(projectId);
@@ -2582,11 +2725,10 @@ function registerProjectCommands(program) {
2582
2725
  ...current,
2583
2726
  ...options.visibility ? { visibility: options.visibility.toUpperCase() } : {},
2584
2727
  ...options.language ? { language: options.language } : {},
2585
- ...options.group !== void 0 ? { groupId: options.group || null } : {},
2586
2728
  ...options.active !== void 0 ? { active: options.active === "true" } : {}
2587
2729
  };
2588
2730
  await api.admin.updateProject(updated);
2589
- console.log(chalk9.green(`Project "${projectId}" updated.`));
2731
+ console.log(chalk10.green(`Project "${projectId}" updated.`));
2590
2732
  } catch (error) {
2591
2733
  handleError(error);
2592
2734
  }
@@ -2608,7 +2750,7 @@ function registerProjectCommands(program) {
2608
2750
  try {
2609
2751
  const api = createApiClient();
2610
2752
  await api.admin.deleteProject(projectId);
2611
- console.log(chalk9.green(`Project "${projectId}" deleted.`));
2753
+ console.log(chalk10.green(`Project "${projectId}" deleted.`));
2612
2754
  } catch (error) {
2613
2755
  handleError(error);
2614
2756
  }
@@ -2617,7 +2759,7 @@ function registerProjectCommands(program) {
2617
2759
  try {
2618
2760
  const api = createApiClient();
2619
2761
  await api.admin.lockProject(projectId);
2620
- console.log(chalk9.green(`Project "${projectId}" locked.`));
2762
+ console.log(chalk10.green(`Project "${projectId}" locked.`));
2621
2763
  } catch (error) {
2622
2764
  handleError(error);
2623
2765
  }
@@ -2626,7 +2768,7 @@ function registerProjectCommands(program) {
2626
2768
  try {
2627
2769
  const api = createApiClient();
2628
2770
  await api.admin.unlockProject(projectId);
2629
- console.log(chalk9.green(`Project "${projectId}" unlocked.`));
2771
+ console.log(chalk10.green(`Project "${projectId}" unlocked.`));
2630
2772
  } catch (error) {
2631
2773
  handleError(error);
2632
2774
  }
@@ -2649,7 +2791,7 @@ function registerProjectCommands(program) {
2649
2791
  try {
2650
2792
  const api = createApiClient();
2651
2793
  await api.admin.inviteProjectMember(projectId, userId, role.toUpperCase());
2652
- console.log(chalk9.green(`Invited ${userId} to "${projectId}" as ${role.toUpperCase()}.`));
2794
+ console.log(chalk10.green(`Invited ${userId} to "${projectId}" as ${role.toUpperCase()}.`));
2653
2795
  } catch (error) {
2654
2796
  handleError(error);
2655
2797
  }
@@ -2658,7 +2800,7 @@ function registerProjectCommands(program) {
2658
2800
  try {
2659
2801
  const api = createApiClient();
2660
2802
  await api.admin.joinProject(projectId, userId);
2661
- console.log(chalk9.green(`Joined project "${projectId}".`));
2803
+ console.log(chalk10.green(`Joined project "${projectId}".`));
2662
2804
  } catch (error) {
2663
2805
  handleError(error);
2664
2806
  }
@@ -2667,7 +2809,7 @@ function registerProjectCommands(program) {
2667
2809
  try {
2668
2810
  const api = createApiClient();
2669
2811
  await api.admin.removeProjectMember(projectId, userId);
2670
- console.log(chalk9.green(`Removed ${userId} from "${projectId}".`));
2812
+ console.log(chalk10.green(`Removed ${userId} from "${projectId}".`));
2671
2813
  } catch (error) {
2672
2814
  handleError(error);
2673
2815
  }
@@ -2679,16 +2821,16 @@ function registerProjectCommands(program) {
2679
2821
  const api = createApiClient();
2680
2822
  const bundleId = await api.storage.exportProjectBundle(ref.projectId, ref.projectBranch);
2681
2823
  if (options.async) {
2682
- console.log(chalk9.green(`Project export queued (bundle ID: ${bundleId}).`));
2824
+ console.log(chalk10.green(`Project export queued (bundle ID: ${bundleId}).`));
2683
2825
  console.log(`Poll progress: diafunc notebook bundles ${project2}`);
2684
2826
  return;
2685
2827
  }
2686
- console.log(chalk9.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
2828
+ console.log(chalk10.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
2687
2829
  const job = await pollUntilFinished(api.storage, ref.projectId, ref.projectBranch, bundleId);
2688
2830
  const response = await api.storage.getBundleContent(ref.projectId, ref.projectBranch, bundleId, job.filename);
2689
2831
  const outFile = options.out ?? "project.dfproj";
2690
2832
  const bytes = await streamResponseToFile(response, outFile);
2691
- console.log(chalk9.green(`Bundle written to ${outFile} (${bytes} bytes, ${job.entityCount ?? "?"} entities).`));
2833
+ console.log(chalk10.green(`Bundle written to ${outFile} (${bytes} bytes, ${job.entityCount ?? "?"} entities).`));
2692
2834
  } catch (error) {
2693
2835
  handleError(error);
2694
2836
  }
@@ -2706,10 +2848,391 @@ function registerProjectCommands(program) {
2706
2848
  });
2707
2849
  }
2708
2850
 
2851
+ // src/commands/team/index.ts
2852
+ import chalk12 from "chalk";
2853
+
2854
+ // src/util/confirm.ts
2855
+ import * as readline from "readline";
2856
+ import chalk11 from "chalk";
2857
+ async function confirmDestructive(message, opts = {}) {
2858
+ if (!process.stdin.isTTY || opts.yes) return;
2859
+ const expected = opts.resourceId ?? "yes";
2860
+ const hint = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
2861
+ console.log(chalk11.yellow(`! ${message}`));
2862
+ const answer = await new Promise((resolve) => {
2863
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2864
+ rl.question(` Type ${hint} to confirm: `, (ans) => {
2865
+ rl.close();
2866
+ resolve(ans);
2867
+ });
2868
+ });
2869
+ if (answer.trim() !== expected) {
2870
+ console.log(chalk11.dim("Aborted."));
2871
+ process.exit(1);
2872
+ }
2873
+ }
2874
+
2875
+ // src/commands/team/index.ts
2876
+ var ROLES = ["OWNER", "ADMIN", "MEMBER"];
2877
+ var INTERVALS = ["MONTHLY", "YEARLY"];
2878
+ function getOutputFormat2(cmd) {
2879
+ const config = loadConfig();
2880
+ const globalOpts = cmd.optsWithGlobals();
2881
+ return globalOpts.output ?? config.defaults.output ?? "human";
2882
+ }
2883
+ function parseRole(value) {
2884
+ const role = value.trim().toUpperCase();
2885
+ if (!ROLES.includes(role)) {
2886
+ throw new Error(`Invalid role "${value}". Expected one of: ${ROLES.join(", ")}.`);
2887
+ }
2888
+ return role;
2889
+ }
2890
+ function parseInterval(value) {
2891
+ const interval = value.trim().toUpperCase();
2892
+ if (!INTERVALS.includes(interval)) {
2893
+ throw new Error(`Invalid billing interval "${value}". Expected one of: ${INTERVALS.join(", ")}.`);
2894
+ }
2895
+ return interval;
2896
+ }
2897
+ function parseCount(value, label) {
2898
+ const count = Number(value);
2899
+ if (!Number.isInteger(count) || count < 0) {
2900
+ throw new Error(`Invalid ${label} "${value}". Expected a non-negative whole number.`);
2901
+ }
2902
+ return count;
2903
+ }
2904
+ function registerTeamCommands(program) {
2905
+ const team = program.command("team").description("Manage teams: membership, invitations, seats, billing, and ownership");
2906
+ team.command("list", { isDefault: true }).description("List the teams you belong to").action(async (_options, cmd) => {
2907
+ try {
2908
+ const api = createApiClient();
2909
+ const teams = await api.admin.listMyTeams();
2910
+ format(teams, {
2911
+ format: getOutputFormat2(cmd),
2912
+ columns: ["id", "name", "planId", "seatCount", "packCount", "renewal"]
2913
+ });
2914
+ } catch (error) {
2915
+ handleError(error);
2916
+ }
2917
+ });
2918
+ team.command("get").description("Show a team").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
2919
+ try {
2920
+ const api = createApiClient();
2921
+ format(await api.admin.getTeam(teamId), { format: getOutputFormat2(cmd) });
2922
+ } catch (error) {
2923
+ handleError(error);
2924
+ }
2925
+ });
2926
+ team.command("use").description("Set your active team (new projects are created under it)").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
2927
+ try {
2928
+ const api = createApiClient();
2929
+ await api.admin.setActiveTeam(teamId);
2930
+ formatMessage(`Active team set to "${teamId}".`, { format: getOutputFormat2(cmd) });
2931
+ } catch (error) {
2932
+ handleError(error);
2933
+ }
2934
+ });
2935
+ team.command("usage").description("Show credit usage for a team, broken down by member").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
2936
+ try {
2937
+ const outputFormat = getOutputFormat2(cmd);
2938
+ const api = createApiClient();
2939
+ const usage = await api.admin.getTeamUsage(teamId);
2940
+ if (outputFormat === "json") {
2941
+ format(usage, { format: outputFormat });
2942
+ return;
2943
+ }
2944
+ console.log(
2945
+ `${usage.year}-${String(usage.month).padStart(2, "0")} ${usage.totalCredits} credits used of ${usage.baselineCredits} included`
2946
+ );
2947
+ format(usage.members, {
2948
+ format: outputFormat,
2949
+ columns: ["userId", "name", "email", "credits"]
2950
+ });
2951
+ } catch (error) {
2952
+ handleError(error);
2953
+ }
2954
+ });
2955
+ team.command("create").description("Start checkout for a new team and print the URL to complete it in a browser").requiredOption("--name <name>", "Team name").requiredOption("--plan <planId>", "Plan ID").requiredOption("--seats <count>", "Number of seats").option("--interval <interval>", "Billing interval (MONTHLY, YEARLY)", "MONTHLY").option("--packs <count>", "Number of credit extension packs").option("--currency <currency>", "Billing currency (e.g. EUR, USD)").action(async (options, cmd) => {
2956
+ try {
2957
+ const api = createApiClient();
2958
+ const session = await api.admin.startTeamCheckout({
2959
+ name: options.name,
2960
+ planId: options.plan,
2961
+ billingInterval: parseInterval(options.interval),
2962
+ seatCount: parseCount(options.seats, "seat count"),
2963
+ ...options.packs !== void 0 ? { packCount: parseCount(options.packs, "pack count") } : {},
2964
+ ...options.currency !== void 0 ? { currency: options.currency.toUpperCase() } : {}
2965
+ });
2966
+ const outputFormat = getOutputFormat2(cmd);
2967
+ if (outputFormat === "json") {
2968
+ format(session, { format: outputFormat });
2969
+ return;
2970
+ }
2971
+ console.log("Open this URL to complete checkout:");
2972
+ console.log(chalk12.cyan(session.url));
2973
+ } catch (error) {
2974
+ handleError(error);
2975
+ }
2976
+ });
2977
+ team.command("portal").description("Open the billing portal for a team and print the URL").argument("<teamId>", "Team ID").option("--return-url <url>", "Where the portal returns to when done", "https://diafunc.com/team").action(async (teamId, options, cmd) => {
2978
+ try {
2979
+ const api = createApiClient();
2980
+ const session = await api.admin.createTeamPortalSession(teamId, options.returnUrl);
2981
+ const outputFormat = getOutputFormat2(cmd);
2982
+ if (outputFormat === "json") {
2983
+ format(session, { format: outputFormat });
2984
+ return;
2985
+ }
2986
+ console.log("Open this URL to manage billing:");
2987
+ console.log(chalk12.cyan(session.url));
2988
+ } catch (error) {
2989
+ handleError(error);
2990
+ }
2991
+ });
2992
+ team.command("cancel").description("Cancel a team's subscription at the end of the current period").argument("<teamId>", "Team ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
2993
+ try {
2994
+ await confirmDestructive(
2995
+ `This will cancel team "${teamId}" at the end of the current billing period.`,
2996
+ { yes: options.yes, resourceId: teamId }
2997
+ );
2998
+ const api = createApiClient();
2999
+ const response = await api.admin.cancelTeam(teamId);
3000
+ formatMessage(
3001
+ `Team "${teamId}" cancelled. Access ends ${response.endsAt ?? "at the end of the period"}.`,
3002
+ { format: getOutputFormat2(cmd) }
3003
+ );
3004
+ } catch (error) {
3005
+ handleError(error);
3006
+ }
3007
+ });
3008
+ team.command("leave").description("Leave a team you are a member of").argument("<teamId>", "Team ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
3009
+ try {
3010
+ await confirmDestructive(`This will remove you from team "${teamId}".`, {
3011
+ yes: options.yes,
3012
+ resourceId: teamId
3013
+ });
3014
+ const api = createApiClient();
3015
+ await api.admin.leaveTeam(teamId);
3016
+ formatMessage(`Left team "${teamId}".`, { format: getOutputFormat2(cmd) });
3017
+ } catch (error) {
3018
+ handleError(error);
3019
+ }
3020
+ });
3021
+ registerMemberCommands(team);
3022
+ registerInvitationCommands(team);
3023
+ registerSeatCommands(team);
3024
+ registerPackCommands(team);
3025
+ registerOwnershipCommands(team);
3026
+ }
3027
+ function registerMemberCommands(team) {
3028
+ const members = team.command("members").description("Manage team members");
3029
+ members.command("list", { isDefault: true }).description("List team members").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3030
+ try {
3031
+ const api = createApiClient();
3032
+ format(await api.admin.listTeamMembers(teamId), {
3033
+ format: getOutputFormat2(cmd),
3034
+ columns: ["userId", "name", "email", "role", "joinedAt"]
3035
+ });
3036
+ } catch (error) {
3037
+ handleError(error);
3038
+ }
3039
+ });
3040
+ members.command("invite").description("Invite someone to the team by email").argument("<teamId>", "Team ID").argument("<email>", "Email address to invite").option("--role <role>", "Team role (OWNER, ADMIN, MEMBER)", "MEMBER").action(async (teamId, email, options, cmd) => {
3041
+ try {
3042
+ const role = parseRole(options.role);
3043
+ const api = createApiClient();
3044
+ await api.admin.inviteTeamMember(teamId, email, role);
3045
+ formatMessage(`Invited ${email} to team "${teamId}" as ${role}.`, {
3046
+ format: getOutputFormat2(cmd)
3047
+ });
3048
+ } catch (error) {
3049
+ handleError(error);
3050
+ }
3051
+ });
3052
+ members.command("remove").description("Remove a member from the team").argument("<teamId>", "Team ID").argument("<userId>", "User ID to remove").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, userId, options, cmd) => {
3053
+ try {
3054
+ await confirmDestructive(`This will remove ${userId} from team "${teamId}".`, {
3055
+ yes: options.yes,
3056
+ resourceId: userId
3057
+ });
3058
+ const api = createApiClient();
3059
+ await api.admin.removeTeamMember(teamId, userId);
3060
+ formatMessage(`Removed ${userId} from team "${teamId}".`, {
3061
+ format: getOutputFormat2(cmd)
3062
+ });
3063
+ } catch (error) {
3064
+ handleError(error);
3065
+ }
3066
+ });
3067
+ }
3068
+ function registerInvitationCommands(team) {
3069
+ const invitations = team.command("invitations").description("Manage pending team invitations");
3070
+ invitations.command("list", { isDefault: true }).description("List pending invitations").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3071
+ try {
3072
+ const api = createApiClient();
3073
+ format(await api.admin.listTeamInvitations(teamId), {
3074
+ format: getOutputFormat2(cmd),
3075
+ columns: ["invitationId", "email", "role", "invitedBy", "expiresAt"]
3076
+ });
3077
+ } catch (error) {
3078
+ handleError(error);
3079
+ }
3080
+ });
3081
+ invitations.command("revoke").description("Revoke a pending invitation").argument("<teamId>", "Team ID").argument("<invitationId>", "Invitation ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, invitationId, options, cmd) => {
3082
+ try {
3083
+ await confirmDestructive(`This will revoke invitation "${invitationId}".`, {
3084
+ yes: options.yes,
3085
+ resourceId: invitationId
3086
+ });
3087
+ const api = createApiClient();
3088
+ await api.admin.revokeTeamInvitation(teamId, invitationId);
3089
+ formatMessage(`Revoked invitation "${invitationId}".`, {
3090
+ format: getOutputFormat2(cmd)
3091
+ });
3092
+ } catch (error) {
3093
+ handleError(error);
3094
+ }
3095
+ });
3096
+ invitations.command("resend").description("Resend a pending invitation email").argument("<teamId>", "Team ID").argument("<invitationId>", "Invitation ID").action(async (teamId, invitationId, _options, cmd) => {
3097
+ try {
3098
+ const api = createApiClient();
3099
+ await api.admin.resendTeamInvitation(teamId, invitationId);
3100
+ formatMessage(`Resent invitation "${invitationId}".`, {
3101
+ format: getOutputFormat2(cmd)
3102
+ });
3103
+ } catch (error) {
3104
+ handleError(error);
3105
+ }
3106
+ });
3107
+ invitations.command("accept").description("Accept a team invitation you received by email").argument("<token>", "Invitation token from the email link").action(async (token, _options, cmd) => {
3108
+ try {
3109
+ const api = createApiClient();
3110
+ const member = await api.admin.acceptTeamInvitation(token);
3111
+ formatMessage(`Joined the team as ${member.role}.`, {
3112
+ format: getOutputFormat2(cmd)
3113
+ });
3114
+ } catch (error) {
3115
+ handleError(error);
3116
+ }
3117
+ });
3118
+ }
3119
+ function registerSeatCommands(team) {
3120
+ const seats = team.command("seats").description("Change a team's seat count");
3121
+ seats.command("preview").description("Preview the invoice for a seat-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New seat count").action(async (teamId, count, _options, cmd) => {
3122
+ try {
3123
+ const api = createApiClient();
3124
+ format(await api.admin.previewTeamSeatCount(teamId, parseCount(count, "seat count")), {
3125
+ format: getOutputFormat2(cmd)
3126
+ });
3127
+ } catch (error) {
3128
+ handleError(error);
3129
+ }
3130
+ });
3131
+ seats.command("set").description("Change the seat count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New seat count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count, options, cmd) => {
3132
+ try {
3133
+ const seatCount = parseCount(count, "seat count");
3134
+ await confirmDestructive(
3135
+ `This will change the seat count of team "${teamId}" to ${seatCount} and adjust billing.`,
3136
+ { yes: options.yes, resourceId: teamId }
3137
+ );
3138
+ const api = createApiClient();
3139
+ const change = await api.admin.updateTeamSeatCount(teamId, seatCount);
3140
+ formatMessage(`Seats changed from ${change.oldSeatCount} to ${change.newSeatCount}.`, {
3141
+ format: getOutputFormat2(cmd)
3142
+ });
3143
+ } catch (error) {
3144
+ handleError(error);
3145
+ }
3146
+ });
3147
+ }
3148
+ function registerPackCommands(team) {
3149
+ const packs = team.command("packs").description("Change a team's credit extension packs");
3150
+ packs.command("preview").description("Preview the invoice for a pack-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New pack count").action(async (teamId, count, _options, cmd) => {
3151
+ try {
3152
+ const api = createApiClient();
3153
+ format(await api.admin.previewTeamPackCount(teamId, parseCount(count, "pack count")), {
3154
+ format: getOutputFormat2(cmd)
3155
+ });
3156
+ } catch (error) {
3157
+ handleError(error);
3158
+ }
3159
+ });
3160
+ packs.command("set").description("Change the pack count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New pack count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count, options, cmd) => {
3161
+ try {
3162
+ const packCount = parseCount(count, "pack count");
3163
+ await confirmDestructive(
3164
+ `This will change the extension packs of team "${teamId}" to ${packCount} and adjust billing.`,
3165
+ { yes: options.yes, resourceId: teamId }
3166
+ );
3167
+ const api = createApiClient();
3168
+ const change = await api.admin.updateTeamPackCount(teamId, packCount);
3169
+ formatMessage(`Packs changed from ${change.oldPackCount} to ${change.newPackCount}.`, {
3170
+ format: getOutputFormat2(cmd)
3171
+ });
3172
+ } catch (error) {
3173
+ handleError(error);
3174
+ }
3175
+ });
3176
+ }
3177
+ function registerOwnershipCommands(team) {
3178
+ const transfer = team.command("transfer").description("Transfer ownership of a team to another member");
3179
+ transfer.command("start").description("Offer ownership to another member").argument("<teamId>", "Team ID").argument("<userId>", "User ID of the new owner").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, userId, options, cmd) => {
3180
+ try {
3181
+ await confirmDestructive(
3182
+ `This will offer ownership of team "${teamId}" to ${userId}.`,
3183
+ { yes: options.yes, resourceId: teamId }
3184
+ );
3185
+ const api = createApiClient();
3186
+ format(await api.admin.initiateOwnershipTransfer(teamId, userId), {
3187
+ format: getOutputFormat2(cmd)
3188
+ });
3189
+ } catch (error) {
3190
+ handleError(error);
3191
+ }
3192
+ });
3193
+ transfer.command("status", { isDefault: true }).description("Show the pending ownership transfer").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3194
+ try {
3195
+ const api = createApiClient();
3196
+ format(await api.admin.getOwnershipTransfer(teamId), { format: getOutputFormat2(cmd) });
3197
+ } catch (error) {
3198
+ handleError(error);
3199
+ }
3200
+ });
3201
+ transfer.command("accept").description("Accept an ownership transfer offered to you").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3202
+ try {
3203
+ const api = createApiClient();
3204
+ const response = await api.admin.acceptOwnershipTransfer(teamId);
3205
+ const outputFormat = getOutputFormat2(cmd);
3206
+ if (outputFormat === "json") {
3207
+ format(response, { format: outputFormat });
3208
+ return;
3209
+ }
3210
+ console.log(chalk12.green(`Ownership transfer ${response.status}.`));
3211
+ if (response.checkoutUrl) {
3212
+ console.log("Open this URL to complete the billing handover:");
3213
+ console.log(chalk12.cyan(response.checkoutUrl));
3214
+ }
3215
+ } catch (error) {
3216
+ handleError(error);
3217
+ }
3218
+ });
3219
+ transfer.command("cancel").description("Cancel a pending ownership transfer").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3220
+ try {
3221
+ const api = createApiClient();
3222
+ await api.admin.cancelOwnershipTransfer(teamId);
3223
+ formatMessage(`Cancelled the ownership transfer for team "${teamId}".`, {
3224
+ format: getOutputFormat2(cmd)
3225
+ });
3226
+ } catch (error) {
3227
+ handleError(error);
3228
+ }
3229
+ });
3230
+ }
3231
+
2709
3232
  // src/commands/entity/index.ts
2710
- import chalk10 from "chalk";
3233
+ import chalk13 from "chalk";
2711
3234
  import * as fs3 from "fs";
2712
- function getOutputFormat2(cmd) {
3235
+ function getOutputFormat3(cmd) {
2713
3236
  const config = loadConfig();
2714
3237
  const globalOpts = cmd.optsWithGlobals();
2715
3238
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -2722,7 +3245,7 @@ function registerEntityCommands(program) {
2722
3245
  const entity = program.command("entity").description("Manage entities");
2723
3246
  entity.command("list").description("List entities in a project (via linked entities from project root)").argument("<projectRef>", "Project reference (projectId or projectId/branch)").action(async (projectRef, _options, cmd) => {
2724
3247
  try {
2725
- const outputFormat = getOutputFormat2(cmd);
3248
+ const outputFormat = getOutputFormat3(cmd);
2726
3249
  const overrides = getOverrides2(cmd);
2727
3250
  const ref = parseEntityReference(projectRef + "/" + projectRef, overrides);
2728
3251
  const api = createApiClient();
@@ -2749,7 +3272,7 @@ function registerEntityCommands(program) {
2749
3272
  });
2750
3273
  entity.command("get").description("Get entity metadata").argument("<ref>", "Entity reference").option("--content", "Include content").action(async (ref, options, cmd) => {
2751
3274
  try {
2752
- const outputFormat = getOutputFormat2(cmd);
3275
+ const outputFormat = getOutputFormat3(cmd);
2753
3276
  const overrides = getOverrides2(cmd);
2754
3277
  const resolved = parseEntityReference(ref, overrides);
2755
3278
  const api = createApiClient();
@@ -2778,20 +3301,21 @@ function registerEntityCommands(program) {
2778
3301
  handleError(error);
2779
3302
  }
2780
3303
  });
2781
- entity.command("delete").description("Delete an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
3304
+ 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
3305
  try {
3306
+ await confirmDestructive(`This will permanently delete entity "${ref}".`, { yes: options.yes, resourceId: ref });
2783
3307
  const overrides = getOverrides2(cmd);
2784
3308
  const resolved = parseEntityReference(ref, overrides);
2785
3309
  const api = createApiClient();
2786
3310
  await api.storage.deleteEntity(resolved);
2787
- console.log(chalk10.green(`Entity "${resolved.entityId}" deleted.`));
3311
+ console.log(chalk13.green(`Entity "${resolved.entityId}" deleted.`));
2788
3312
  } catch (error) {
2789
3313
  handleError(error);
2790
3314
  }
2791
3315
  });
2792
3316
  entity.command("history").description("Get entity version history").argument("<ref>", "Entity reference").option("--from <version>", "From version").option("--to <version>", "To version").action(async (ref, options, cmd) => {
2793
3317
  try {
2794
- const outputFormat = getOutputFormat2(cmd);
3318
+ const outputFormat = getOutputFormat3(cmd);
2795
3319
  const overrides = getOverrides2(cmd);
2796
3320
  const resolved = parseEntityReference(ref, overrides);
2797
3321
  const api = createApiClient();
@@ -2825,7 +3349,7 @@ function registerEntityCommands(program) {
2825
3349
  const resolved = parseEntityReference(ref, overrides);
2826
3350
  const api = createApiClient();
2827
3351
  await api.storage.revertEntity(resolved, parseInt(version, 10));
2828
- console.log(chalk10.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
3352
+ console.log(chalk13.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
2829
3353
  } catch (error) {
2830
3354
  handleError(error);
2831
3355
  }
@@ -2836,7 +3360,7 @@ function registerEntityCommands(program) {
2836
3360
  const resolved = parseEntityReference(ref, overrides);
2837
3361
  const api = createApiClient();
2838
3362
  await api.storage.renameEntity(resolved, newId);
2839
- console.log(chalk10.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
3363
+ console.log(chalk13.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
2840
3364
  } catch (error) {
2841
3365
  handleError(error);
2842
3366
  }
@@ -2851,7 +3375,7 @@ function registerEntityCommands(program) {
2851
3375
  if (options.out) {
2852
3376
  const buffer = Buffer.from(await response.arrayBuffer());
2853
3377
  fs3.writeFileSync(options.out, buffer);
2854
- console.log(chalk10.green(`Content saved to ${options.out}`));
3378
+ console.log(chalk13.green(`Content saved to ${options.out}`));
2855
3379
  } else {
2856
3380
  const text = await response.text();
2857
3381
  process.stdout.write(text);
@@ -2868,18 +3392,19 @@ function registerEntityCommands(program) {
2868
3392
  const fileBuffer = fs3.readFileSync(file);
2869
3393
  const base64 = fileBuffer.toString("base64");
2870
3394
  await api.storage.saveEntityContentBase64(resolved, base64);
2871
- console.log(chalk10.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
3395
+ console.log(chalk13.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
2872
3396
  } catch (error) {
2873
3397
  handleError(error);
2874
3398
  }
2875
3399
  });
2876
- content.command("delete").description("Delete entity content").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
3400
+ 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
3401
  try {
3402
+ await confirmDestructive(`This will permanently delete the content of entity "${ref}".`, { yes: options.yes, resourceId: ref });
2878
3403
  const overrides = getOverrides2(cmd);
2879
3404
  const resolved = parseEntityReference(ref, overrides);
2880
3405
  const api = createApiClient();
2881
3406
  await api.storage.deleteEntityContent(resolved);
2882
- console.log(chalk10.green(`Content deleted from entity "${resolved.entityId}".`));
3407
+ console.log(chalk13.green(`Content deleted from entity "${resolved.entityId}".`));
2883
3408
  } catch (error) {
2884
3409
  handleError(error);
2885
3410
  }
@@ -2892,21 +3417,21 @@ function registerEntityCommands(program) {
2892
3417
  const request = { rootEntityIds: entityIds, dataFormat: options.data };
2893
3418
  if (options.async) {
2894
3419
  const bundleId = await api.storage.exportEntitySubset(ref.projectId, ref.projectBranch, request);
2895
- console.log(chalk10.green(`Export queued (bundle ID: ${bundleId}).`));
3420
+ console.log(chalk13.green(`Export queued (bundle ID: ${bundleId}).`));
2896
3421
  console.log(`Poll progress: diafunc notebook bundles ${project}`);
2897
3422
  return;
2898
3423
  }
2899
3424
  const response = await api.storage.streamEntitySubset(ref.projectId, ref.projectBranch, request);
2900
3425
  const outFile = options.out ?? "entities.dfset";
2901
3426
  const bytes = await streamResponseToFile(response, outFile);
2902
- console.log(chalk10.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
3427
+ console.log(chalk13.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
2903
3428
  } catch (error) {
2904
3429
  handleError(error);
2905
3430
  }
2906
3431
  });
2907
3432
  entity.command("import").description("Import a .dfset (or any) bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
2908
3433
  try {
2909
- const outputFormat = getOutputFormat2(cmd);
3434
+ const outputFormat = getOutputFormat3(cmd);
2910
3435
  const overrides = getOverrides2(cmd);
2911
3436
  const ref = parseProjectReference(project, overrides);
2912
3437
  const api = createApiClient();
@@ -2918,8 +3443,8 @@ function registerEntityCommands(program) {
2918
3443
  }
2919
3444
 
2920
3445
  // src/commands/link/index.ts
2921
- import chalk11 from "chalk";
2922
- function getOutputFormat3(cmd) {
3446
+ import chalk14 from "chalk";
3447
+ function getOutputFormat4(cmd) {
2923
3448
  const config = loadConfig();
2924
3449
  const globalOpts = cmd.optsWithGlobals();
2925
3450
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -2932,7 +3457,7 @@ function registerLinkCommands(program) {
2932
3457
  const link = program.command("link").description("Manage links between entities");
2933
3458
  link.command("list").description("List links for an entity").argument("<ref>", "Source entity reference").option("--direction <dir>", "Link direction: FORWARD or BACKWARD", "FORWARD").action(async (ref, options, cmd) => {
2934
3459
  try {
2935
- const outputFormat = getOutputFormat3(cmd);
3460
+ const outputFormat = getOutputFormat4(cmd);
2936
3461
  const overrides = getOverrides3(cmd);
2937
3462
  const resolved = parseEntityReference(ref, overrides);
2938
3463
  const api = createApiClient();
@@ -2968,7 +3493,7 @@ function registerLinkCommands(program) {
2968
3493
  target.entityId,
2969
3494
  target.entityBranch
2970
3495
  );
2971
- console.log(chalk11.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
3496
+ console.log(chalk14.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
2972
3497
  } catch (error) {
2973
3498
  handleError(error);
2974
3499
  }
@@ -2989,7 +3514,7 @@ function registerLinkCommands(program) {
2989
3514
  target.entityId,
2990
3515
  target.entityBranch
2991
3516
  );
2992
- console.log(chalk11.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
3517
+ console.log(chalk14.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
2993
3518
  } else {
2994
3519
  await api.storage.deleteLink(
2995
3520
  source.projectId,
@@ -2998,7 +3523,7 @@ function registerLinkCommands(program) {
2998
3523
  source.entityBranch,
2999
3524
  linkId
3000
3525
  );
3001
- console.log(chalk11.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
3526
+ console.log(chalk14.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
3002
3527
  }
3003
3528
  } catch (error) {
3004
3529
  handleError(error);
@@ -3007,8 +3532,8 @@ function registerLinkCommands(program) {
3007
3532
  }
3008
3533
 
3009
3534
  // src/commands/event/index.ts
3010
- import chalk12 from "chalk";
3011
- function getOutputFormat4(cmd) {
3535
+ import chalk15 from "chalk";
3536
+ function getOutputFormat5(cmd) {
3012
3537
  const config = loadConfig();
3013
3538
  const globalOpts = cmd.optsWithGlobals();
3014
3539
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3021,7 +3546,7 @@ function registerEventCommands(program) {
3021
3546
  const event = program.command("event").description("Manage events");
3022
3547
  event.command("list").description("List events for an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
3023
3548
  try {
3024
- const outputFormat = getOutputFormat4(cmd);
3549
+ const outputFormat = getOutputFormat5(cmd);
3025
3550
  const overrides = getOverrides4(cmd);
3026
3551
  const resolved = parseEntityReference(ref, overrides);
3027
3552
  const api = createApiClient();
@@ -3043,7 +3568,7 @@ function registerEventCommands(program) {
3043
3568
  });
3044
3569
  event.command("get").description("Get a specific event").argument("<ref>", "Entity reference").argument("<eventId>", "Event ID").argument("<occurrenceId>", "Occurrence ID").action(async (ref, eventId, occurrenceId, _options, cmd) => {
3045
3570
  try {
3046
- const outputFormat = getOutputFormat4(cmd);
3571
+ const outputFormat = getOutputFormat5(cmd);
3047
3572
  const overrides = getOverrides4(cmd);
3048
3573
  const resolved = parseEntityReference(ref, overrides);
3049
3574
  const api = createApiClient();
@@ -3069,7 +3594,7 @@ function registerEventCommands(program) {
3069
3594
  const api = createApiClient();
3070
3595
  const arr = Array.isArray(events) ? events : [events];
3071
3596
  await api.storage.createEvents(arr);
3072
- console.log(chalk12.green(`${arr.length} event(s) created.`));
3597
+ console.log(chalk15.green(`${arr.length} event(s) created.`));
3073
3598
  } catch (error) {
3074
3599
  handleError(error);
3075
3600
  }
@@ -3096,7 +3621,7 @@ function registerEventCommands(program) {
3096
3621
  const resolved = parseEntityReference(ref, overrides);
3097
3622
  const api = createApiClient();
3098
3623
  await api.storage.deleteEvent(resolved, eventId, occurrenceId);
3099
- console.log(chalk12.green(`Event "${eventId}/${occurrenceId}" deleted.`));
3624
+ console.log(chalk15.green(`Event "${eventId}/${occurrenceId}" deleted.`));
3100
3625
  } catch (error) {
3101
3626
  handleError(error);
3102
3627
  }
@@ -3104,8 +3629,8 @@ function registerEventCommands(program) {
3104
3629
  }
3105
3630
 
3106
3631
  // src/commands/branch/index.ts
3107
- import chalk13 from "chalk";
3108
- function getOutputFormat5(cmd) {
3632
+ import chalk16 from "chalk";
3633
+ function getOutputFormat6(cmd) {
3109
3634
  const config = loadConfig();
3110
3635
  const globalOpts = cmd.optsWithGlobals();
3111
3636
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3118,12 +3643,12 @@ function registerBranchCommands(program) {
3118
3643
  const branch = program.command("branch").description("Manage branches");
3119
3644
  branch.command("list").description("List branches for a project").argument("[projectId]", "Project ID (uses default if omitted)").action(async (projectId, _options, cmd) => {
3120
3645
  try {
3121
- const outputFormat = getOutputFormat5(cmd);
3646
+ const outputFormat = getOutputFormat6(cmd);
3122
3647
  const overrides = getOverrides5(cmd);
3123
3648
  const config = loadConfig();
3124
3649
  const pid = projectId ?? overrides.project ?? config.defaults.project;
3125
3650
  if (!pid) {
3126
- console.error(chalk13.red("No project specified. Pass a project ID or set defaults.project."));
3651
+ console.error(chalk16.red("No project specified. Pass a project ID or set defaults.project."));
3127
3652
  process.exit(1);
3128
3653
  }
3129
3654
  const api = createApiClient();
@@ -3147,7 +3672,7 @@ function registerBranchCommands(program) {
3147
3672
  sourceProjectBranch: options.source,
3148
3673
  targetProjectBranch: branchName
3149
3674
  });
3150
- console.log(chalk13.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
3675
+ console.log(chalk16.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
3151
3676
  } catch (error) {
3152
3677
  handleError(error);
3153
3678
  }
@@ -3156,7 +3681,7 @@ function registerBranchCommands(program) {
3156
3681
  try {
3157
3682
  const api = createApiClient();
3158
3683
  await api.storage.deleteProjectBranch(projectId, branchName);
3159
- console.log(chalk13.green(`Branch "${branchName}" deleted from project "${projectId}".`));
3684
+ console.log(chalk16.green(`Branch "${branchName}" deleted from project "${projectId}".`));
3160
3685
  } catch (error) {
3161
3686
  handleError(error);
3162
3687
  }
@@ -3177,7 +3702,7 @@ function registerBranchCommands(program) {
3177
3702
  linkId: options.linkId,
3178
3703
  deepMerge: options.deep
3179
3704
  });
3180
- console.log(chalk13.green("Merge completed."));
3705
+ console.log(chalk16.green("Merge completed."));
3181
3706
  } catch (error) {
3182
3707
  handleError(error);
3183
3708
  }
@@ -3192,7 +3717,7 @@ function registerBranchCommands(program) {
3192
3717
  forkProjectName: options.name ?? forkProjectId,
3193
3718
  forkProjectDescription: options.description
3194
3719
  });
3195
- console.log(chalk13.green(`Project "${projectId}" forked to "${forkProjectId}".`));
3720
+ console.log(chalk16.green(`Project "${projectId}" forked to "${forkProjectId}".`));
3196
3721
  } catch (error) {
3197
3722
  handleError(error);
3198
3723
  }
@@ -3200,10 +3725,10 @@ function registerBranchCommands(program) {
3200
3725
  }
3201
3726
 
3202
3727
  // src/commands/table/index.ts
3203
- import chalk14 from "chalk";
3728
+ import chalk17 from "chalk";
3204
3729
  import * as fs4 from "fs";
3205
3730
  import * as path3 from "path";
3206
- function getOutputFormat6(cmd) {
3731
+ function getOutputFormat7(cmd) {
3207
3732
  const config = loadConfig();
3208
3733
  const globalOpts = cmd.optsWithGlobals();
3209
3734
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3229,7 +3754,7 @@ function registerTableCommands(program) {
3229
3754
  const table = program.command("table").description("Manage tables");
3230
3755
  table.command("view").description("View table data").argument("<ref>", "Table entity reference").option("--rows <range>", "Row range (e.g., 0:10)").option("--cols <range>", "Column range (e.g., 0:5)").action(async (ref, options, cmd) => {
3231
3756
  try {
3232
- const outputFormat = getOutputFormat6(cmd);
3757
+ const outputFormat = getOutputFormat7(cmd);
3233
3758
  const overrides = getOverrides6(cmd);
3234
3759
  const resolved = parseEntityReference(ref, overrides);
3235
3760
  const api = createApiClient();
@@ -3270,7 +3795,7 @@ function registerTableCommands(program) {
3270
3795
  console.log(colNames.map((c) => row2[c] ?? "").join(" "));
3271
3796
  }
3272
3797
  } else {
3273
- console.log(chalk14.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
3798
+ console.log(chalk17.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
3274
3799
  format(tableData, { format: outputFormat, columns: colNames });
3275
3800
  }
3276
3801
  } catch (error) {
@@ -3282,7 +3807,7 @@ function registerTableCommands(program) {
3282
3807
  const overrides = getOverrides6(cmd);
3283
3808
  const resolved = parseEntityReference(ref, overrides);
3284
3809
  if (!fs4.existsSync(file)) {
3285
- console.error(chalk14.red(`File not found: ${file}`));
3810
+ console.error(chalk17.red(`File not found: ${file}`));
3286
3811
  process.exit(1);
3287
3812
  }
3288
3813
  const api = createApiClient();
@@ -3300,22 +3825,22 @@ function registerTableCommands(program) {
3300
3825
  const imp = await api.storage.getImport(resolved, importId);
3301
3826
  if (imp.finished !== null) {
3302
3827
  if (imp.succeeded) {
3303
- console.log(chalk14.green(`Import completed successfully (${imp.duration}ms).`));
3828
+ console.log(chalk17.green(`Import completed successfully (${imp.duration}ms).`));
3304
3829
  } else {
3305
- console.error(chalk14.red(`Import failed: ${imp.error}`));
3830
+ console.error(chalk17.red(`Import failed: ${imp.error}`));
3306
3831
  process.exit(1);
3307
3832
  }
3308
3833
  return;
3309
3834
  }
3310
3835
  }
3311
- console.error(chalk14.yellow("Import still in progress. Check status later."));
3836
+ console.error(chalk17.yellow("Import still in progress. Check status later."));
3312
3837
  } catch (error) {
3313
3838
  handleError(error);
3314
3839
  }
3315
3840
  });
3316
3841
  table.command("import-formats").description("List supported import formats").action(async (_options, cmd) => {
3317
3842
  try {
3318
- const outputFormat = getOutputFormat6(cmd);
3843
+ const outputFormat = getOutputFormat7(cmd);
3319
3844
  const api = createApiClient();
3320
3845
  const response = await api.storage.getSupportedImportFormats();
3321
3846
  if (outputFormat === "json") {
@@ -3344,15 +3869,15 @@ function registerTableCommands(program) {
3344
3869
  const formats = await api.storage.getSupportedExportFormats();
3345
3870
  const format2 = formats.formats.find((f) => f.id.toLowerCase() === fmt.toLowerCase());
3346
3871
  if (!format2) {
3347
- console.error(chalk14.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
3872
+ console.error(chalk17.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
3348
3873
  process.exit(1);
3349
3874
  }
3350
3875
  if (options.compression && !formats.compressionAlgorithms.includes(options.compression)) {
3351
- console.error(chalk14.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
3876
+ console.error(chalk17.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
3352
3877
  process.exit(1);
3353
3878
  }
3354
3879
  if (options.archive && !formats.archiveAlgorithms.includes(options.archive)) {
3355
- console.error(chalk14.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
3880
+ console.error(chalk17.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
3356
3881
  process.exit(1);
3357
3882
  }
3358
3883
  const exportOptions = {
@@ -3382,10 +3907,10 @@ function registerTableCommands(program) {
3382
3907
  const outFile = options.out ?? deriveOutFile(resolved.entityId, format2.extension, options.archive, options.compression);
3383
3908
  const buffer = Buffer.from(await response.arrayBuffer());
3384
3909
  fs4.writeFileSync(outFile, buffer);
3385
- console.log(chalk14.green(`Table streamed to ${outFile}`));
3910
+ console.log(chalk17.green(`Table streamed to ${outFile}`));
3386
3911
  } else {
3387
3912
  const exportId = await api.storage.exportTable(resolved, format2.id, exportOptions);
3388
- console.log(chalk14.green(`Export queued (ID: ${exportId}).`));
3913
+ console.log(chalk17.green(`Export queued (ID: ${exportId}).`));
3389
3914
  console.log(`Poll progress: diafunc table exports get ${exportId} --ref ${ref}`);
3390
3915
  }
3391
3916
  } catch (error) {
@@ -3394,7 +3919,7 @@ function registerTableCommands(program) {
3394
3919
  });
3395
3920
  table.command("export-formats").description("List supported export formats").action(async (_options, cmd) => {
3396
3921
  try {
3397
- const outputFormat = getOutputFormat6(cmd);
3922
+ const outputFormat = getOutputFormat7(cmd);
3398
3923
  const api = createApiClient();
3399
3924
  const response = await api.storage.getSupportedExportFormats();
3400
3925
  if (outputFormat === "json") {
@@ -3410,8 +3935,72 @@ function registerTableCommands(program) {
3410
3935
  knownLimitations: f.knownLimitations.join(" / ")
3411
3936
  }));
3412
3937
  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(", ")}`));
3938
+ console.log(chalk17.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
3939
+ console.log(chalk17.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
3940
+ } catch (error) {
3941
+ handleError(error);
3942
+ }
3943
+ });
3944
+ const exportsCmd = table.command("exports").description("Track and download async table exports");
3945
+ exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
3946
+ try {
3947
+ const outputFormat = getOutputFormat7(cmd);
3948
+ const overrides = getOverrides6(cmd);
3949
+ const resolved = parseEntityReference(ref, overrides);
3950
+ const api = createApiClient();
3951
+ const exports = await api.storage.listExports(resolved);
3952
+ if (outputFormat === "json") {
3953
+ format(exports, { format: outputFormat });
3954
+ return;
3955
+ }
3956
+ if (exports.length === 0) {
3957
+ console.log(chalk17.dim("No exports found."));
3958
+ return;
3959
+ }
3960
+ const rows = exports.map((e) => ({
3961
+ exportId: e.exportId,
3962
+ filename: e.filename,
3963
+ progress: `${Math.round((e.progress ?? 0) * 100)}%`,
3964
+ succeeded: e.succeeded === true ? "yes" : e.succeeded === false ? "no" : "\u2014",
3965
+ duration: e.duration != null ? `${e.duration}ms` : "\u2014",
3966
+ error: e.error ?? ""
3967
+ }));
3968
+ format(rows, { format: outputFormat, columns: ["exportId", "filename", "progress", "succeeded", "duration", "error"] });
3969
+ } catch (error) {
3970
+ handleError(error);
3971
+ }
3972
+ });
3973
+ 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) => {
3974
+ try {
3975
+ const outputFormat = getOutputFormat7(cmd);
3976
+ const overrides = getOverrides6(cmd);
3977
+ const resolved = parseEntityReference(options.ref, overrides);
3978
+ const api = createApiClient();
3979
+ const exports = await api.storage.listExports(resolved);
3980
+ const exp = exports.find((e) => e.exportId === exportId);
3981
+ if (!exp) {
3982
+ console.error(chalk17.red(`Export ${exportId} not found for ref ${options.ref}.`));
3983
+ process.exit(1);
3984
+ }
3985
+ if (outputFormat === "json") {
3986
+ format(exp, { format: outputFormat });
3987
+ return;
3988
+ }
3989
+ if (exp.finished === null) {
3990
+ const pct = Math.round((exp.progress ?? 0) * 100);
3991
+ console.log(chalk17.dim(`Export in progress: ${pct}% \u2014 check again later.`));
3992
+ return;
3993
+ }
3994
+ if (!exp.succeeded) {
3995
+ console.error(chalk17.red(`Export failed: ${exp.error}`));
3996
+ process.exit(1);
3997
+ }
3998
+ const outFile = options.out ?? exp.filename;
3999
+ console.log(`Downloading ${exp.filename} ...`);
4000
+ const response = await api.storage.downloadExport(resolved, exportId, exp.filename);
4001
+ const buffer = Buffer.from(await response.arrayBuffer());
4002
+ fs4.writeFileSync(outFile, buffer);
4003
+ console.log(chalk17.green(`Export saved to ${outFile}`));
3415
4004
  } catch (error) {
3416
4005
  handleError(error);
3417
4006
  }
@@ -3423,7 +4012,7 @@ function registerTableCommands(program) {
3423
4012
  const resolved = parseEntityReference(ref, overrides);
3424
4013
  const api = createApiClient();
3425
4014
  await api.storage.appendRow(resolved);
3426
- console.log(chalk14.green("Row appended."));
4015
+ console.log(chalk17.green("Row appended."));
3427
4016
  } catch (error) {
3428
4017
  handleError(error);
3429
4018
  }
@@ -3434,7 +4023,7 @@ function registerTableCommands(program) {
3434
4023
  const resolved = parseEntityReference(ref, overrides);
3435
4024
  const api = createApiClient();
3436
4025
  await api.storage.insertRow(resolved, parseInt(index, 10));
3437
- console.log(chalk14.green(`Row inserted at index ${index}.`));
4026
+ console.log(chalk17.green(`Row inserted at index ${index}.`));
3438
4027
  } catch (error) {
3439
4028
  handleError(error);
3440
4029
  }
@@ -3445,7 +4034,7 @@ function registerTableCommands(program) {
3445
4034
  const resolved = parseEntityReference(ref, overrides);
3446
4035
  const api = createApiClient();
3447
4036
  await api.storage.removeRow(resolved, parseInt(index, 10));
3448
- console.log(chalk14.green(`Row ${index} removed.`));
4037
+ console.log(chalk17.green(`Row ${index} removed.`));
3449
4038
  } catch (error) {
3450
4039
  handleError(error);
3451
4040
  }
@@ -3456,7 +4045,7 @@ function registerTableCommands(program) {
3456
4045
  const resolved = parseEntityReference(ref, overrides);
3457
4046
  const api = createApiClient();
3458
4047
  await api.storage.deleteRow(resolved, parseInt(index, 10));
3459
- console.log(chalk14.green(`Row ${index} deleted.`));
4048
+ console.log(chalk17.green(`Row ${index} deleted.`));
3460
4049
  } catch (error) {
3461
4050
  handleError(error);
3462
4051
  }
@@ -3468,7 +4057,7 @@ function registerTableCommands(program) {
3468
4057
  const resolved = parseEntityReference(ref, overrides);
3469
4058
  const api = createApiClient();
3470
4059
  await api.storage.appendColumn(resolved);
3471
- console.log(chalk14.green("Column appended."));
4060
+ console.log(chalk17.green("Column appended."));
3472
4061
  } catch (error) {
3473
4062
  handleError(error);
3474
4063
  }
@@ -3479,7 +4068,7 @@ function registerTableCommands(program) {
3479
4068
  const resolved = parseEntityReference(ref, overrides);
3480
4069
  const api = createApiClient();
3481
4070
  await api.storage.insertColumn(resolved, parseInt(index, 10));
3482
- console.log(chalk14.green(`Column inserted at index ${index}.`));
4071
+ console.log(chalk17.green(`Column inserted at index ${index}.`));
3483
4072
  } catch (error) {
3484
4073
  handleError(error);
3485
4074
  }
@@ -3490,7 +4079,7 @@ function registerTableCommands(program) {
3490
4079
  const resolved = parseEntityReference(ref, overrides);
3491
4080
  const api = createApiClient();
3492
4081
  await api.storage.removeColumn(resolved, parseInt(index, 10));
3493
- console.log(chalk14.green(`Column ${index} removed.`));
4082
+ console.log(chalk17.green(`Column ${index} removed.`));
3494
4083
  } catch (error) {
3495
4084
  handleError(error);
3496
4085
  }
@@ -3501,7 +4090,7 @@ function registerTableCommands(program) {
3501
4090
  const resolved = parseEntityReference(ref, overrides);
3502
4091
  const api = createApiClient();
3503
4092
  await api.storage.deleteColumn(resolved, parseInt(index, 10));
3504
- console.log(chalk14.green(`Column ${index} deleted.`));
4093
+ console.log(chalk17.green(`Column ${index} deleted.`));
3505
4094
  } catch (error) {
3506
4095
  handleError(error);
3507
4096
  }
@@ -3518,7 +4107,7 @@ function registerTableCommands(program) {
3518
4107
  value,
3519
4108
  type: "text"
3520
4109
  }]);
3521
- console.log(chalk14.green(`Cell [${row2}, ${col}] set to "${value}".`));
4110
+ console.log(chalk17.green(`Cell [${row2}, ${col}] set to "${value}".`));
3522
4111
  } catch (error) {
3523
4112
  handleError(error);
3524
4113
  }
@@ -3529,18 +4118,19 @@ function registerTableCommands(program) {
3529
4118
  const resolved = parseEntityReference(ref, overrides);
3530
4119
  const api = createApiClient();
3531
4120
  await api.storage.removeCell(resolved, parseInt(row2, 10), parseInt(col, 10));
3532
- console.log(chalk14.green(`Cell [${row2}, ${col}] deleted.`));
4121
+ console.log(chalk17.green(`Cell [${row2}, ${col}] deleted.`));
3533
4122
  } catch (error) {
3534
4123
  handleError(error);
3535
4124
  }
3536
4125
  });
3537
- table.command("clear").description("Clear all data from a table").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
4126
+ 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
4127
  try {
4128
+ await confirmDestructive(`This will permanently delete all data in table "${ref}".`, { yes: options.yes, resourceId: ref });
3539
4129
  const overrides = getOverrides6(cmd);
3540
4130
  const resolved = parseEntityReference(ref, overrides);
3541
4131
  const api = createApiClient();
3542
4132
  await api.storage.clearTable(resolved);
3543
- console.log(chalk14.green("Table cleared."));
4133
+ console.log(chalk17.green("Table cleared."));
3544
4134
  } catch (error) {
3545
4135
  handleError(error);
3546
4136
  }
@@ -3548,10 +4138,10 @@ function registerTableCommands(program) {
3548
4138
  }
3549
4139
 
3550
4140
  // src/commands/notebook/index.ts
3551
- import chalk15 from "chalk";
4141
+ import chalk18 from "chalk";
3552
4142
  import * as fs5 from "fs";
3553
4143
  import * as path4 from "path";
3554
- function getOutputFormat7(cmd) {
4144
+ function getOutputFormat8(cmd) {
3555
4145
  const config = loadConfig();
3556
4146
  const globalOpts = cmd.optsWithGlobals();
3557
4147
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3570,7 +4160,7 @@ function registerNotebookCommands(program) {
3570
4160
  const request = { rootEntityIds: notebookIds, dataFormat: options.data };
3571
4161
  if (options.async) {
3572
4162
  const bundleId = await api.storage.exportBundle(ref.projectId, ref.projectBranch, request);
3573
- console.log(chalk15.green(`Export queued (bundle ID: ${bundleId}).`));
4163
+ console.log(chalk18.green(`Export queued (bundle ID: ${bundleId}).`));
3574
4164
  console.log(`Poll progress: diafunc notebook bundles ${project}`);
3575
4165
  return;
3576
4166
  }
@@ -3578,14 +4168,14 @@ function registerNotebookCommands(program) {
3578
4168
  const outFile = options.out ?? "notebooks.dfnb";
3579
4169
  const buffer = Buffer.from(await response.arrayBuffer());
3580
4170
  fs5.writeFileSync(outFile, buffer);
3581
- console.log(chalk15.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
4171
+ console.log(chalk18.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
3582
4172
  } catch (error) {
3583
4173
  handleError(error);
3584
4174
  }
3585
4175
  });
3586
4176
  notebook.command("import").description("Import a .dfnb bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the .dfnb bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
3587
4177
  try {
3588
- const outputFormat = getOutputFormat7(cmd);
4178
+ const outputFormat = getOutputFormat8(cmd);
3589
4179
  const overrides = getOverrides7(cmd);
3590
4180
  const ref = parseProjectReference(project, overrides);
3591
4181
  const api = createApiClient();
@@ -3599,9 +4189,9 @@ function registerNotebookCommands(program) {
3599
4189
  format(preview, { format: outputFormat });
3600
4190
  return;
3601
4191
  }
3602
- console.log(chalk15.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
4192
+ console.log(chalk18.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
3603
4193
  if (preview.sourceProjectId) {
3604
- console.log(chalk15.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
4194
+ console.log(chalk18.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
3605
4195
  }
3606
4196
  const counts = /* @__PURE__ */ new Map();
3607
4197
  for (const e of preview.entities ?? []) {
@@ -3611,9 +4201,9 @@ function registerNotebookCommands(program) {
3611
4201
  console.log(` ${type}: ${count}`);
3612
4202
  }
3613
4203
  if (preview.lossinessNotes && preview.lossinessNotes.length > 0) {
3614
- console.log(chalk15.yellow("Lossiness:"));
4204
+ console.log(chalk18.yellow("Lossiness:"));
3615
4205
  for (const note of preview.lossinessNotes) {
3616
- console.log(chalk15.yellow(` - ${note}`));
4206
+ console.log(chalk18.yellow(` - ${note}`));
3617
4207
  }
3618
4208
  }
3619
4209
  return;
@@ -3623,7 +4213,7 @@ function registerNotebookCommands(program) {
3623
4213
  format(result, { format: outputFormat });
3624
4214
  return;
3625
4215
  }
3626
- console.log(chalk15.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
4216
+ console.log(chalk18.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
3627
4217
  console.log(`Notebook id(s): ${result.rootEntityIds.join(", ")}`);
3628
4218
  } catch (error) {
3629
4219
  handleError(error);
@@ -3631,7 +4221,7 @@ function registerNotebookCommands(program) {
3631
4221
  });
3632
4222
  notebook.command("bundles").description("List notebook-bundle export jobs for a project").argument("<project>", "Project reference (projectId or projectId/branch)").action(async (project, _options, cmd) => {
3633
4223
  try {
3634
- const outputFormat = getOutputFormat7(cmd);
4224
+ const outputFormat = getOutputFormat8(cmd);
3635
4225
  const overrides = getOverrides7(cmd);
3636
4226
  const ref = parseProjectReference(project, overrides);
3637
4227
  const api = createApiClient();
@@ -3660,7 +4250,7 @@ function registerNotebookCommands(program) {
3660
4250
  }
3661
4251
 
3662
4252
  // src/commands/function/index.ts
3663
- import chalk16 from "chalk";
4253
+ import chalk19 from "chalk";
3664
4254
  import * as fs6 from "fs";
3665
4255
  import * as os2 from "os";
3666
4256
  import * as path5 from "path";
@@ -3716,7 +4306,7 @@ function buildFunctionEntity(args) {
3716
4306
  }
3717
4307
 
3718
4308
  // src/commands/function/index.ts
3719
- function getOutputFormat8(cmd) {
4309
+ function getOutputFormat9(cmd) {
3720
4310
  const config = loadConfig();
3721
4311
  const globalOpts = cmd.optsWithGlobals();
3722
4312
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3739,7 +4329,7 @@ function registerFunctionCommands(program) {
3739
4329
  const fn = program.command("function").description("Execute and manage functions");
3740
4330
  fn.command("call").description("Execute a function").argument("<ref>", "Function entity reference").option("--async", "Execute asynchronously").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
3741
4331
  try {
3742
- const outputFormat = getOutputFormat8(cmd);
4332
+ const outputFormat = getOutputFormat9(cmd);
3743
4333
  const overrides = getOverrides8(cmd);
3744
4334
  const resolved = parseEntityReference(ref, overrides);
3745
4335
  const api = createApiClient();
@@ -3782,7 +4372,7 @@ function registerFunctionCommands(program) {
3782
4372
  }, isAsync);
3783
4373
  if (isAsync) {
3784
4374
  if (outputFormat === "human") {
3785
- console.log(chalk16.green("Function launched."));
4375
+ console.log(chalk19.green("Function launched."));
3786
4376
  console.log(` Evaluation ID: ${result.evaluationId}`);
3787
4377
  } else {
3788
4378
  format({ evaluationId: result.evaluationId }, { format: outputFormat });
@@ -3790,14 +4380,14 @@ function registerFunctionCommands(program) {
3790
4380
  } else {
3791
4381
  if (outputFormat === "human") {
3792
4382
  if (result.successful) {
3793
- console.log(chalk16.green("Function completed successfully."));
4383
+ console.log(chalk19.green("Function completed successfully."));
3794
4384
  if (result.result) {
3795
4385
  console.log(` Result: ${result.result}`);
3796
4386
  }
3797
4387
  const duration = result.completed - result.started;
3798
4388
  console.log(` Duration: ${duration}ms`);
3799
4389
  } else {
3800
- console.log(chalk16.red("Function failed."));
4390
+ console.log(chalk19.red("Function failed."));
3801
4391
  console.log(` Error: ${result.error}`);
3802
4392
  if (result.lineNumber > 0) {
3803
4393
  console.log(` Line: ${result.lineNumber}, Column: ${result.columnNumber}`);
@@ -3805,7 +4395,7 @@ function registerFunctionCommands(program) {
3805
4395
  }
3806
4396
  if (result.outputs?.length) {
3807
4397
  console.log();
3808
- console.log(chalk16.bold("Outputs:"));
4398
+ console.log(chalk19.bold("Outputs:"));
3809
4399
  for (const out of result.outputs) {
3810
4400
  console.log(` [${out.type}] ${out.output}`);
3811
4401
  }
@@ -3820,7 +4410,7 @@ function registerFunctionCommands(program) {
3820
4410
  });
3821
4411
  fn.command("evaluations").description("List evaluations for a function").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
3822
4412
  try {
3823
- const outputFormat = getOutputFormat8(cmd);
4413
+ const outputFormat = getOutputFormat9(cmd);
3824
4414
  const overrides = getOverrides8(cmd);
3825
4415
  const resolved = parseEntityReference(ref, overrides);
3826
4416
  const api = createApiClient();
@@ -3854,16 +4444,16 @@ function registerFunctionCommands(program) {
3854
4444
  });
3855
4445
  fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
3856
4446
  try {
3857
- const outputFormat = getOutputFormat8(cmd);
4447
+ const outputFormat = getOutputFormat9(cmd);
3858
4448
  const api = createApiClient();
3859
4449
  const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
3860
4450
  if (outputFormat === "human") {
3861
4451
  if (outputs.length === 0) {
3862
- console.log(chalk16.dim("No outputs."));
4452
+ console.log(chalk19.dim("No outputs."));
3863
4453
  }
3864
4454
  for (const out of outputs) {
3865
4455
  const time = new Date(out.timestamp).toISOString();
3866
- console.log(`${chalk16.dim(time)} [${out.type}] ${out.output}`);
4456
+ console.log(`${chalk19.dim(time)} [${out.type}] ${out.output}`);
3867
4457
  }
3868
4458
  } else {
3869
4459
  format(outputs, { format: outputFormat });
@@ -3874,7 +4464,7 @@ function registerFunctionCommands(program) {
3874
4464
  });
3875
4465
  fn.command("logs").description("Get logs for a function evaluation").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
3876
4466
  try {
3877
- const outputFormat = getOutputFormat8(cmd);
4467
+ const outputFormat = getOutputFormat9(cmd);
3878
4468
  const overrides = getOverrides8(cmd);
3879
4469
  const resolved = parseEntityReference(ref, overrides);
3880
4470
  const api = createApiClient();
@@ -3913,14 +4503,14 @@ function registerFunctionCommands(program) {
3913
4503
  hour,
3914
4504
  evaluationId
3915
4505
  );
3916
- console.log(chalk16.green(`Evaluation ${evaluationId} stopped.`));
4506
+ console.log(chalk19.green(`Evaluation ${evaluationId} stopped.`));
3917
4507
  } catch (error) {
3918
4508
  handleError(error);
3919
4509
  }
3920
4510
  });
3921
4511
  fn.command("engines").description("List available engines").action(async (_options, cmd) => {
3922
4512
  try {
3923
- const outputFormat = getOutputFormat8(cmd);
4513
+ const outputFormat = getOutputFormat9(cmd);
3924
4514
  const api = createApiClient();
3925
4515
  const engines = await api.evaluation.getEngines();
3926
4516
  format(engines, { format: outputFormat });
@@ -3930,7 +4520,7 @@ function registerFunctionCommands(program) {
3930
4520
  });
3931
4521
  fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
3932
4522
  try {
3933
- const outputFormat = getOutputFormat8(cmd);
4523
+ const outputFormat = getOutputFormat9(cmd);
3934
4524
  const overrides = getOverrides8(cmd);
3935
4525
  const resolved = parseEntityReference(ref, overrides);
3936
4526
  const api = createApiClient();
@@ -3961,7 +4551,7 @@ function registerFunctionCommands(program) {
3961
4551
  sourceCode
3962
4552
  });
3963
4553
  await api.storage.saveEntities([entity]);
3964
- console.log(chalk16.green(`Function "${resolved.entityId}" created (${options.language}).`));
4554
+ console.log(chalk19.green(`Function "${resolved.entityId}" created (${options.language}).`));
3965
4555
  } catch (error) {
3966
4556
  handleError(error);
3967
4557
  }
@@ -3976,7 +4566,7 @@ function registerFunctionCommands(program) {
3976
4566
  const sourceCode = decodeFunctionSource(entity);
3977
4567
  if (options.out) {
3978
4568
  fs6.writeFileSync(options.out, sourceCode);
3979
- console.log(chalk16.green(`Source written to ${options.out}`));
4569
+ console.log(chalk19.green(`Source written to ${options.out}`));
3980
4570
  } else {
3981
4571
  process.stdout.write(sourceCode);
3982
4572
  if (!sourceCode.endsWith("\n")) process.stdout.write("\n");
@@ -4000,7 +4590,7 @@ function registerFunctionCommands(program) {
4000
4590
  process.stdin.on("error", reject);
4001
4591
  });
4002
4592
  await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(sourceCode));
4003
- console.log(chalk16.green(`Source updated for "${resolved.entityId}".`));
4593
+ console.log(chalk19.green(`Source updated for "${resolved.entityId}".`));
4004
4594
  } catch (error) {
4005
4595
  handleError(error);
4006
4596
  }
@@ -4025,11 +4615,11 @@ function registerFunctionCommands(program) {
4025
4615
  const newSource = fs6.readFileSync(tmpFile, "utf-8");
4026
4616
  fs6.unlinkSync(tmpFile);
4027
4617
  if (newSource === currentSource) {
4028
- console.log(chalk16.dim("No changes."));
4618
+ console.log(chalk19.dim("No changes."));
4029
4619
  return;
4030
4620
  }
4031
4621
  await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(newSource));
4032
- console.log(chalk16.green(`Source updated for "${resolved.entityId}".`));
4622
+ console.log(chalk19.green(`Source updated for "${resolved.entityId}".`));
4033
4623
  } catch (error) {
4034
4624
  handleError(error);
4035
4625
  }
@@ -4046,8 +4636,8 @@ function extensionFor(language) {
4046
4636
  }
4047
4637
 
4048
4638
  // src/commands/trigger/index.ts
4049
- import chalk17 from "chalk";
4050
- function getOutputFormat9(cmd) {
4639
+ import chalk20 from "chalk";
4640
+ function getOutputFormat10(cmd) {
4051
4641
  const config = loadConfig();
4052
4642
  const globalOpts = cmd.optsWithGlobals();
4053
4643
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4060,7 +4650,7 @@ function registerTriggerCommands(program) {
4060
4650
  const trigger = program.command("trigger").description("Manage function triggers");
4061
4651
  trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
4062
4652
  try {
4063
- const outputFormat = getOutputFormat9(cmd);
4653
+ const outputFormat = getOutputFormat10(cmd);
4064
4654
  const overrides = getOverrides9(cmd);
4065
4655
  const resolved = parseEntityReference(ref, overrides);
4066
4656
  const api = createApiClient();
@@ -4088,7 +4678,7 @@ function registerTriggerCommands(program) {
4088
4678
  });
4089
4679
  trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
4090
4680
  try {
4091
- const outputFormat = getOutputFormat9(cmd);
4681
+ const outputFormat = getOutputFormat10(cmd);
4092
4682
  const overrides = getOverrides9(cmd);
4093
4683
  const resolved = parseEntityReference(ref, overrides);
4094
4684
  const api = createApiClient();
@@ -4116,7 +4706,7 @@ function registerTriggerCommands(program) {
4116
4706
  resolved.entityBranch,
4117
4707
  triggerId
4118
4708
  );
4119
- console.log(chalk17.green(`Trigger "${triggerId}" deleted.`));
4709
+ console.log(chalk20.green(`Trigger "${triggerId}" deleted.`));
4120
4710
  } catch (error) {
4121
4711
  handleError(error);
4122
4712
  }
@@ -4164,7 +4754,7 @@ function registerTriggerCommands(program) {
4164
4754
  scheduler: null,
4165
4755
  heartbeat: null
4166
4756
  });
4167
- console.log(chalk17.green("Trigger saved."));
4757
+ console.log(chalk20.green("Trigger saved."));
4168
4758
  } catch (error) {
4169
4759
  handleError(error);
4170
4760
  }
@@ -4172,9 +4762,9 @@ function registerTriggerCommands(program) {
4172
4762
  }
4173
4763
 
4174
4764
  // src/commands/schedule/index.ts
4175
- import chalk18 from "chalk";
4765
+ import chalk21 from "chalk";
4176
4766
  import { randomUUID as randomUUID2 } from "crypto";
4177
- function getOutputFormat10(cmd) {
4767
+ function getOutputFormat11(cmd) {
4178
4768
  const config = loadConfig();
4179
4769
  const globalOpts = cmd.optsWithGlobals();
4180
4770
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4187,7 +4777,7 @@ function registerScheduleCommands(program) {
4187
4777
  const schedule = program.command("schedule").description("Schedule function execution");
4188
4778
  schedule.command("call").description("Schedule a function call").argument("<ref>", "Function entity reference").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
4189
4779
  try {
4190
- const outputFormat = getOutputFormat10(cmd);
4780
+ const outputFormat = getOutputFormat11(cmd);
4191
4781
  const overrides = getOverrides10(cmd);
4192
4782
  const resolved = parseEntityReference(ref, overrides);
4193
4783
  const api = createApiClient();
@@ -4224,7 +4814,7 @@ function registerScheduleCommands(program) {
4224
4814
  removeFunction: false
4225
4815
  });
4226
4816
  if (outputFormat === "human") {
4227
- console.log(chalk18.green("Function scheduled."));
4817
+ console.log(chalk21.green("Function scheduled."));
4228
4818
  } else {
4229
4819
  format(result, { format: outputFormat });
4230
4820
  }
@@ -4249,14 +4839,14 @@ function registerScheduleCommands(program) {
4249
4839
  hour,
4250
4840
  evaluationId
4251
4841
  );
4252
- console.log(chalk18.green(`Scheduled evaluation ${evaluationId} stopped.`));
4842
+ console.log(chalk21.green(`Scheduled evaluation ${evaluationId} stopped.`));
4253
4843
  } catch (error) {
4254
4844
  handleError(error);
4255
4845
  }
4256
4846
  });
4257
4847
  schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
4258
4848
  try {
4259
- const outputFormat = getOutputFormat10(cmd);
4849
+ const outputFormat = getOutputFormat11(cmd);
4260
4850
  const overrides = getOverrides10(cmd);
4261
4851
  const resolved = parseEntityReference(ref, overrides);
4262
4852
  const api = createApiClient();
@@ -4286,10 +4876,10 @@ function registerScheduleCommands(program) {
4286
4876
  }
4287
4877
 
4288
4878
  // src/commands/chat/index.ts
4289
- import chalk19 from "chalk";
4879
+ import chalk22 from "chalk";
4290
4880
  import * as fs7 from "fs";
4291
4881
  import * as path6 from "path";
4292
- function getOutputFormat11(cmd) {
4882
+ function getOutputFormat12(cmd) {
4293
4883
  const config = loadConfig();
4294
4884
  const globalOpts = cmd.optsWithGlobals();
4295
4885
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4327,7 +4917,7 @@ async function streamOneTurn(message, sessionId, projectId, branch) {
4327
4917
  input = event.inputTokens;
4328
4918
  output = event.outputTokens;
4329
4919
  } else if (event.type === "error") {
4330
- console.error(chalk19.red(`
4920
+ console.error(chalk22.red(`
4331
4921
  Error: ${event.content}`));
4332
4922
  }
4333
4923
  } catch {
@@ -4338,19 +4928,19 @@ Error: ${event.content}`));
4338
4928
  }
4339
4929
  async function runChatRepl(options) {
4340
4930
  const { input: promptInput } = await import("@inquirer/prompts");
4341
- const { getUpdateNotice } = await import("./update-check-KL3CHODI.js");
4931
+ const { getUpdateNotice } = await import("./update-check-UOHMHDN6.js");
4342
4932
  let sessionId = options.session;
4343
- console.log(chalk19.bold("Diafunc chat") + chalk19.dim(" \xB7 /help for commands, /quit to exit"));
4933
+ console.log(chalk22.bold("Diafunc chat") + chalk22.dim(" \xB7 /help for commands, /quit to exit"));
4344
4934
  if (sessionId) {
4345
- console.log(chalk19.dim(`Continuing session ${sessionId}`));
4935
+ console.log(chalk22.dim(`Continuing session ${sessionId}`));
4346
4936
  }
4347
4937
  const notice = await getUpdateNotice();
4348
- if (notice) console.log(chalk19.dim(notice));
4938
+ if (notice) console.log(chalk22.dim(notice));
4349
4939
  console.log();
4350
4940
  for (; ; ) {
4351
4941
  let line;
4352
4942
  try {
4353
- line = await promptInput({ message: chalk19.cyan.bold("you >") });
4943
+ line = await promptInput({ message: chalk22.cyan.bold("you >") });
4354
4944
  } catch {
4355
4945
  console.log();
4356
4946
  return;
@@ -4367,37 +4957,37 @@ async function runChatRepl(options) {
4367
4957
  return;
4368
4958
  case "new":
4369
4959
  sessionId = void 0;
4370
- console.log(chalk19.dim("Started a new session."));
4960
+ console.log(chalk22.dim("Started a new session."));
4371
4961
  continue;
4372
4962
  case "session":
4373
4963
  if (!arg) {
4374
- console.log(chalk19.dim(`Current session: ${sessionId ?? "(new)"}`));
4964
+ console.log(chalk22.dim(`Current session: ${sessionId ?? "(new)"}`));
4375
4965
  } else {
4376
4966
  sessionId = arg;
4377
- console.log(chalk19.dim(`Switched to session ${sessionId}`));
4967
+ console.log(chalk22.dim(`Switched to session ${sessionId}`));
4378
4968
  }
4379
4969
  continue;
4380
4970
  case "help":
4381
4971
  case "h":
4382
4972
  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"));
4973
+ console.log(chalk22.dim(" /new start a new session"));
4974
+ console.log(chalk22.dim(" /session [id] switch to a session (no id = show current)"));
4975
+ console.log(chalk22.dim(" /quit exit the REPL"));
4386
4976
  continue;
4387
4977
  default:
4388
- console.log(chalk19.dim(`Unknown command: /${cmd}. Try /help.`));
4978
+ console.log(chalk22.dim(`Unknown command: /${cmd}. Try /help.`));
4389
4979
  continue;
4390
4980
  }
4391
4981
  }
4392
- process.stdout.write(chalk19.magenta.bold("diafunc > "));
4982
+ process.stdout.write(chalk22.magenta.bold("diafunc > "));
4393
4983
  try {
4394
4984
  const result = await streamOneTurn(trimmed, sessionId, options.project, options.branch);
4395
4985
  sessionId = result.sessionId || sessionId;
4396
4986
  console.log();
4397
- console.log(chalk19.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
4987
+ console.log(chalk22.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
4398
4988
  console.log();
4399
4989
  } catch (error) {
4400
- console.error(chalk19.red(`
4990
+ console.error(chalk22.red(`
4401
4991
  Request failed: ${error.message}`));
4402
4992
  }
4403
4993
  }
@@ -4413,7 +5003,7 @@ function registerChatCommands(program) {
4413
5003
  });
4414
5004
  chat.command("send").description("Send a chat message (blocking)").argument("<message>", "Message to send").option("--project <id>", "Project context").option("--branch <branch>", "Project branch", "main").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
4415
5005
  try {
4416
- const outputFormat = getOutputFormat11(cmd);
5006
+ const outputFormat = getOutputFormat12(cmd);
4417
5007
  const api = createApiClient();
4418
5008
  const response = await api.language.chat({
4419
5009
  message,
@@ -4424,7 +5014,7 @@ function registerChatCommands(program) {
4424
5014
  if (outputFormat === "human") {
4425
5015
  console.log(response.content);
4426
5016
  console.log();
4427
- console.log(chalk19.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
5017
+ console.log(chalk22.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
4428
5018
  } else {
4429
5019
  format(response, { format: outputFormat });
4430
5020
  }
@@ -4434,7 +5024,7 @@ function registerChatCommands(program) {
4434
5024
  });
4435
5025
  chat.command("stream").description("Send a chat message (streaming)").argument("<message>", "Message to send").option("--project <id>", "Project context").option("--branch <branch>", "Project branch", "main").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
4436
5026
  try {
4437
- const outputFormat = getOutputFormat11(cmd);
5027
+ const outputFormat = getOutputFormat12(cmd);
4438
5028
  const api = createApiClient();
4439
5029
  const response = await api.language.chatStream({
4440
5030
  message,
@@ -4489,9 +5079,9 @@ function registerChatCommands(program) {
4489
5079
  sessionId = event.sessionId ?? "";
4490
5080
  console.log();
4491
5081
  console.log();
4492
- console.log(chalk19.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
5082
+ console.log(chalk22.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
4493
5083
  } else if (event.type === "error") {
4494
- console.error(chalk19.red(`
5084
+ console.error(chalk22.red(`
4495
5085
  Error: ${event.content}`));
4496
5086
  }
4497
5087
  } catch {
@@ -4507,7 +5097,7 @@ Error: ${event.content}`));
4507
5097
  chat.command("upload").description("Upload a file for chat context").argument("<file>", "File to upload").action(async (file) => {
4508
5098
  try {
4509
5099
  if (!fs7.existsSync(file)) {
4510
- console.error(chalk19.red(`File not found: ${file}`));
5100
+ console.error(chalk22.red(`File not found: ${file}`));
4511
5101
  process.exit(1);
4512
5102
  }
4513
5103
  const api = createApiClient();
@@ -4516,7 +5106,7 @@ Error: ${event.content}`));
4516
5106
  const formData = new FormData();
4517
5107
  formData.append("file", blob, path6.basename(file));
4518
5108
  const result = await api.language.upload(formData);
4519
- console.log(chalk19.green(`File uploaded: ${result}`));
5109
+ console.log(chalk22.green(`File uploaded: ${result}`));
4520
5110
  } catch (error) {
4521
5111
  handleError(error);
4522
5112
  }
@@ -4524,7 +5114,7 @@ Error: ${event.content}`));
4524
5114
  const session = chat.command("session").description("Manage chat sessions");
4525
5115
  session.command("list").description("List chat sessions").action(async (_options, cmd) => {
4526
5116
  try {
4527
- const outputFormat = getOutputFormat11(cmd);
5117
+ const outputFormat = getOutputFormat12(cmd);
4528
5118
  const api = createApiClient();
4529
5119
  const sessions = await api.language.getSessions();
4530
5120
  format(sessions, {
@@ -4539,22 +5129,22 @@ Error: ${event.content}`));
4539
5129
  try {
4540
5130
  const api = createApiClient();
4541
5131
  await api.language.deleteSession(sessionId);
4542
- console.log(chalk19.green(`Session "${sessionId}" deleted.`));
5132
+ console.log(chalk22.green(`Session "${sessionId}" deleted.`));
4543
5133
  } catch (error) {
4544
5134
  handleError(error);
4545
5135
  }
4546
5136
  });
4547
5137
  session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
4548
5138
  try {
4549
- const outputFormat = getOutputFormat11(cmd);
5139
+ const outputFormat = getOutputFormat12(cmd);
4550
5140
  const api = createApiClient();
4551
5141
  const detail = await api.language.getSession(sessionId);
4552
5142
  if (outputFormat === "human") {
4553
- console.log(chalk19.bold(detail.title) + chalk19.dim(` (${detail.sessionId})`));
5143
+ console.log(chalk22.bold(detail.title) + chalk22.dim(` (${detail.sessionId})`));
4554
5144
  console.log();
4555
5145
  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)}`);
5146
+ const role = msg.role === "user" ? chalk22.cyan.bold("You") : chalk22.magenta.bold("Diafunc");
5147
+ console.log(`${role} ${chalk22.dim(msg.created)}`);
4558
5148
  console.log(msg.content);
4559
5149
  console.log();
4560
5150
  }
@@ -4569,14 +5159,14 @@ Error: ${event.content}`));
4569
5159
  try {
4570
5160
  const api = createApiClient();
4571
5161
  await api.language.renameSession(sessionId, title);
4572
- console.log(chalk19.green(`Session "${sessionId}" renamed to "${title}".`));
5162
+ console.log(chalk22.green(`Session "${sessionId}" renamed to "${title}".`));
4573
5163
  } catch (error) {
4574
5164
  handleError(error);
4575
5165
  }
4576
5166
  });
4577
5167
  chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
4578
5168
  try {
4579
- const outputFormat = getOutputFormat11(cmd);
5169
+ const outputFormat = getOutputFormat12(cmd);
4580
5170
  const api = createApiClient();
4581
5171
  const usage = await api.language.getUsage();
4582
5172
  format(usage, { format: outputFormat });
@@ -4587,7 +5177,7 @@ Error: ${event.content}`));
4587
5177
  }
4588
5178
 
4589
5179
  // src/commands/search/index.ts
4590
- function getOutputFormat12(cmd) {
5180
+ function getOutputFormat13(cmd) {
4591
5181
  const config = loadConfig();
4592
5182
  const globalOpts = cmd.optsWithGlobals();
4593
5183
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4595,7 +5185,7 @@ function getOutputFormat12(cmd) {
4595
5185
  function registerSearchCommands(program) {
4596
5186
  program.command("search").description("Search entities across projects").argument("<query>", "Search query").option("--project <id>", "Limit search to a project").option("--branch <branch>", "Project branch", "main").action(async (query, options, cmd) => {
4597
5187
  try {
4598
- const outputFormat = getOutputFormat12(cmd);
5188
+ const outputFormat = getOutputFormat13(cmd);
4599
5189
  const api = createApiClient();
4600
5190
  if (options.project) {
4601
5191
  const results = await api.storage.searchProject(
@@ -4625,124 +5215,9 @@ function registerSearchCommands(program) {
4625
5215
  });
4626
5216
  }
4627
5217
 
4628
- // src/commands/group/index.ts
4629
- import chalk20 from "chalk";
4630
- function getOutputFormat13(cmd) {
4631
- const config = loadConfig();
4632
- const globalOpts = cmd.optsWithGlobals();
4633
- return globalOpts.output ?? config.defaults.output ?? "human";
4634
- }
4635
- function registerGroupCommands(program) {
4636
- const group = program.command("group").description("Manage groups");
4637
- group.command("list").description("List groups").option("--all", "List all groups (admin)").action(async (options, cmd) => {
4638
- try {
4639
- const outputFormat = getOutputFormat13(cmd);
4640
- const api = createApiClient();
4641
- const groups = options.all ? await api.admin.getAllGroups() : await api.admin.getGroups();
4642
- format(groups, { format: outputFormat, columns: ["groupId", "name"] });
4643
- } catch (error) {
4644
- handleError(error);
4645
- }
4646
- });
4647
- group.command("get").description("Get group details").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
4648
- try {
4649
- const outputFormat = getOutputFormat13(cmd);
4650
- const api = createApiClient();
4651
- const g = await api.admin.getGroup(groupId);
4652
- format(g, { format: outputFormat });
4653
- } catch (error) {
4654
- handleError(error);
4655
- }
4656
- });
4657
- group.command("create").description("Create a new group").argument("<groupId>", "Group ID").option("--name <name>", "Group name").action(async (groupId, options) => {
4658
- try {
4659
- const api = createApiClient();
4660
- await api.admin.createGroup({ groupId, name: options.name ?? groupId });
4661
- console.log(chalk20.green(`Group "${groupId}" created.`));
4662
- } catch (error) {
4663
- handleError(error);
4664
- }
4665
- });
4666
- group.command("update").description("Update a group").argument("<groupId>", "Group ID").requiredOption("--name <name>", "New group name").action(async (groupId, options) => {
4667
- try {
4668
- const api = createApiClient();
4669
- await api.admin.updateGroup({ groupId, name: options.name });
4670
- console.log(chalk20.green(`Group "${groupId}" updated.`));
4671
- } catch (error) {
4672
- handleError(error);
4673
- }
4674
- });
4675
- group.command("delete").description("Delete a group").argument("<groupId>", "Group ID").action(async (groupId) => {
4676
- try {
4677
- const api = createApiClient();
4678
- await api.admin.deleteGroup(groupId);
4679
- console.log(chalk20.green(`Group "${groupId}" deleted.`));
4680
- } catch (error) {
4681
- handleError(error);
4682
- }
4683
- });
4684
- const members = group.command("members").description("Manage group members");
4685
- members.command("list").description("List group members").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
4686
- try {
4687
- const outputFormat = getOutputFormat13(cmd);
4688
- const api = createApiClient();
4689
- const memberList = await api.admin.getGroupMembers(groupId);
4690
- format(memberList, { format: outputFormat, columns: ["userId", "role", "joined"] });
4691
- } catch (error) {
4692
- handleError(error);
4693
- }
4694
- });
4695
- members.command("invite").description("Invite a user to a group").argument("<groupId>", "Group ID").argument("<userId>", "User ID").argument("<role>", "Role").action(async (groupId, userId, role) => {
4696
- try {
4697
- const api = createApiClient();
4698
- await api.admin.inviteGroupMember(groupId, userId, role.toUpperCase());
4699
- console.log(chalk20.green(`Invited ${userId} to group "${groupId}" as ${role.toUpperCase()}.`));
4700
- } catch (error) {
4701
- handleError(error);
4702
- }
4703
- });
4704
- members.command("remove").description("Remove a member from a group").argument("<groupId>", "Group ID").argument("<userId>", "User ID").action(async (groupId, userId) => {
4705
- try {
4706
- const api = createApiClient();
4707
- await api.admin.removeGroupMember(groupId, userId);
4708
- console.log(chalk20.green(`Removed ${userId} from group "${groupId}".`));
4709
- } catch (error) {
4710
- handleError(error);
4711
- }
4712
- });
4713
- const projects = group.command("projects").description("Manage group projects");
4714
- projects.command("list").description("List group projects").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
4715
- try {
4716
- const outputFormat = getOutputFormat13(cmd);
4717
- const api = createApiClient();
4718
- const projectList = await api.admin.getGroupProjects(groupId);
4719
- format(projectList, { format: outputFormat, columns: ["projectId", "visibility", "language"] });
4720
- } catch (error) {
4721
- handleError(error);
4722
- }
4723
- });
4724
- projects.command("add").description("Add a project to a group").argument("<groupId>", "Group ID").argument("<projectId>", "Project ID").action(async (groupId, projectId) => {
4725
- try {
4726
- const api = createApiClient();
4727
- await api.admin.addGroupProject(groupId, projectId);
4728
- console.log(chalk20.green(`Project "${projectId}" added to group "${groupId}".`));
4729
- } catch (error) {
4730
- handleError(error);
4731
- }
4732
- });
4733
- projects.command("remove").description("Remove a project from a group").argument("<groupId>", "Group ID").argument("<projectId>", "Project ID").action(async (groupId, projectId) => {
4734
- try {
4735
- const api = createApiClient();
4736
- await api.admin.removeGroupProject(groupId, projectId);
4737
- console.log(chalk20.green(`Project "${projectId}" removed from group "${groupId}".`));
4738
- } catch (error) {
4739
- handleError(error);
4740
- }
4741
- });
4742
- }
4743
-
4744
5218
  // src/commands/admin/index.ts
4745
- import chalk21 from "chalk";
5219
+ import { readFile } from "fs/promises";
5220
+ import chalk23 from "chalk";
4746
5221
  function getOutputFormat14(cmd) {
4747
5222
  const config = loadConfig();
4748
5223
  const globalOpts = cmd.optsWithGlobals();
@@ -4806,7 +5281,7 @@ function registerAdminCommands(program) {
4806
5281
  try {
4807
5282
  const api = createApiClient();
4808
5283
  await api.admin.mergeSetting({ [key]: value });
4809
- console.log(chalk21.green(`Setting "${key}" updated.`));
5284
+ console.log(chalk23.green(`Setting "${key}" updated.`));
4810
5285
  } catch (error) {
4811
5286
  handleError(error);
4812
5287
  }
@@ -4817,10 +5292,10 @@ function registerAdminCommands(program) {
4817
5292
  const api = createApiClient();
4818
5293
  if (options.longTerm) {
4819
5294
  await api.storage.createLongTermFullBackup();
4820
- console.log(chalk21.green("Full long-term backup initiated."));
5295
+ console.log(chalk23.green("Full long-term backup initiated."));
4821
5296
  } else {
4822
5297
  await api.storage.createShortTermFullBackup();
4823
- console.log(chalk21.green("Full short-term backup initiated."));
5298
+ console.log(chalk23.green("Full short-term backup initiated."));
4824
5299
  }
4825
5300
  } catch (error) {
4826
5301
  handleError(error);
@@ -4831,29 +5306,37 @@ function registerAdminCommands(program) {
4831
5306
  const api = createApiClient();
4832
5307
  if (options.longTerm) {
4833
5308
  await api.storage.createLongTermProjectBackup();
4834
- console.log(chalk21.green("Project long-term backup initiated."));
5309
+ console.log(chalk23.green("Project long-term backup initiated."));
4835
5310
  } else {
4836
5311
  await api.storage.createShortTermProjectBackup();
4837
- console.log(chalk21.green("Project short-term backup initiated."));
5312
+ console.log(chalk23.green("Project short-term backup initiated."));
4838
5313
  }
4839
5314
  } catch (error) {
4840
5315
  handleError(error);
4841
5316
  }
4842
5317
  });
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) => {
5318
+ 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
5319
  try {
5320
+ await confirmDestructive(
5321
+ `This will overwrite project "${projectId}/${projectBranch}" with backup ${bucketName}/${objectName}.`,
5322
+ { yes: options.yes }
5323
+ );
4845
5324
  const api = createApiClient();
4846
5325
  await api.storage.restoreProjectBackup({ projectId, projectBranch, bucketName, objectName });
4847
- console.log(chalk21.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
5326
+ console.log(chalk23.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
4848
5327
  } catch (error) {
4849
5328
  handleError(error);
4850
5329
  }
4851
5330
  });
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) => {
5331
+ 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
5332
  try {
5333
+ await confirmDestructive(
5334
+ `This will overwrite the ENTIRE system with backup ${bucketName}/${objectName}.`,
5335
+ { yes: options.yes }
5336
+ );
4854
5337
  const api = createApiClient();
4855
5338
  await api.storage.restoreFullBackup({ bucketName, objectName });
4856
- console.log(chalk21.green(`Full restore initiated from ${bucketName}/${objectName}.`));
5339
+ console.log(chalk23.green(`Full restore initiated from ${bucketName}/${objectName}.`));
4857
5340
  } catch (error) {
4858
5341
  handleError(error);
4859
5342
  }
@@ -4863,10 +5346,10 @@ function registerAdminCommands(program) {
4863
5346
  const api = createApiClient();
4864
5347
  if (options.project) {
4865
5348
  await api.index.rebuildProject(options.project);
4866
- console.log(chalk21.green(`Index rebuild initiated for project "${options.project}".`));
5349
+ console.log(chalk23.green(`Index rebuild initiated for project "${options.project}".`));
4867
5350
  } else {
4868
5351
  await api.index.rebuildAll();
4869
- console.log(chalk21.green("Index rebuild initiated for all projects."));
5352
+ console.log(chalk23.green("Index rebuild initiated for all projects."));
4870
5353
  }
4871
5354
  } catch (error) {
4872
5355
  handleError(error);
@@ -4882,10 +5365,33 @@ function registerAdminCommands(program) {
4882
5365
  handleError(error);
4883
5366
  }
4884
5367
  });
5368
+ const team = admin.command("team").description("Team administration");
5369
+ const contract = team.command("contract").description("Issue and inspect negotiated team contracts");
5370
+ contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
5371
+ try {
5372
+ const api = createApiClient();
5373
+ format(await api.admin.getTeamContract(teamId), { format: getOutputFormat14(cmd) });
5374
+ } catch (error) {
5375
+ handleError(error);
5376
+ }
5377
+ });
5378
+ contract.command("issue").description("Issue or replace a negotiated contract for a team").argument("<teamId>", "Team ID").requiredOption("--file <path>", "JSON file holding the contract request").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
5379
+ try {
5380
+ const request = JSON.parse(await readFile(options.file, "utf8"));
5381
+ await confirmDestructive(
5382
+ `This will replace the contract of team "${teamId}" with the terms in ${options.file}.`,
5383
+ { yes: options.yes, resourceId: teamId }
5384
+ );
5385
+ const api = createApiClient();
5386
+ format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat14(cmd) });
5387
+ } catch (error) {
5388
+ handleError(error);
5389
+ }
5390
+ });
4885
5391
  }
4886
5392
 
4887
5393
  // src/commands/status/summary.ts
4888
- import chalk22 from "chalk";
5394
+ import chalk24 from "chalk";
4889
5395
 
4890
5396
  // src/client/services/status.ts
4891
5397
  function createStatusService() {
@@ -4911,24 +5417,24 @@ function createStatusService() {
4911
5417
 
4912
5418
  // src/commands/status/summary.ts
4913
5419
  var STATE_COLORS = {
4914
- UP: chalk22.green,
4915
- DEGRADED: chalk22.yellow,
4916
- DOWN: chalk22.red,
4917
- UNKNOWN: chalk22.gray
5420
+ UP: chalk24.green,
5421
+ DEGRADED: chalk24.yellow,
5422
+ DOWN: chalk24.red,
5423
+ UNKNOWN: chalk24.gray
4918
5424
  };
4919
5425
  function stateColor(state) {
4920
- return STATE_COLORS[state] ?? chalk22.gray;
5426
+ return STATE_COLORS[state] ?? chalk24.gray;
4921
5427
  }
4922
5428
  function stateSymbol(state) {
4923
5429
  switch (state) {
4924
5430
  case "UP":
4925
- return chalk22.green("\u25CF");
5431
+ return chalk24.green("\u25CF");
4926
5432
  case "DEGRADED":
4927
- return chalk22.yellow("\u25CF");
5433
+ return chalk24.yellow("\u25CF");
4928
5434
  case "DOWN":
4929
- return chalk22.red("\u25CF");
5435
+ return chalk24.red("\u25CF");
4930
5436
  default:
4931
- return chalk22.gray("\u25CB");
5437
+ return chalk24.gray("\u25CB");
4932
5438
  }
4933
5439
  }
4934
5440
  function registerSummaryCommand(parent) {
@@ -4955,11 +5461,11 @@ function registerSummaryCommand(parent) {
4955
5461
  }
4956
5462
  console.log();
4957
5463
  if (summary.openIncidents > 0) {
4958
- console.log(chalk22.yellow(` ${summary.openIncidents} active incident(s)`));
5464
+ console.log(chalk24.yellow(` ${summary.openIncidents} active incident(s)`));
4959
5465
  } else {
4960
- console.log(chalk22.dim(" No active incidents"));
5466
+ console.log(chalk24.dim(" No active incidents"));
4961
5467
  }
4962
- console.log(chalk22.dim(`
5468
+ console.log(chalk24.dim(`
4963
5469
  Platform v${version.platformVersion} \u2022 ${new Date(summary.timestamp).toLocaleString()}`));
4964
5470
  console.log();
4965
5471
  } catch (error) {
@@ -4969,17 +5475,17 @@ function registerSummaryCommand(parent) {
4969
5475
  }
4970
5476
 
4971
5477
  // src/commands/status/component.ts
4972
- import chalk23 from "chalk";
5478
+ import chalk25 from "chalk";
4973
5479
  function stateSymbol2(state) {
4974
5480
  switch (state) {
4975
5481
  case "UP":
4976
- return chalk23.green("\u25CF");
5482
+ return chalk25.green("\u25CF");
4977
5483
  case "DEGRADED":
4978
- return chalk23.yellow("\u25CF");
5484
+ return chalk25.yellow("\u25CF");
4979
5485
  case "DOWN":
4980
- return chalk23.red("\u25CF");
5486
+ return chalk25.red("\u25CF");
4981
5487
  default:
4982
- return chalk23.gray("\u25CB");
5488
+ return chalk25.gray("\u25CB");
4983
5489
  }
4984
5490
  }
4985
5491
  function registerComponentCommand(parent) {
@@ -4992,7 +5498,7 @@ function registerComponentCommand(parent) {
4992
5498
  const match = components.find((c) => c.id === id || c.id === id + "-service");
4993
5499
  if (!match) {
4994
5500
  const available = components.map((c) => c.id).join(", ");
4995
- console.error(chalk23.red(`Component "${id}" not found. Available: ${available}`));
5501
+ console.error(chalk25.red(`Component "${id}" not found. Available: ${available}`));
4996
5502
  process.exit(1);
4997
5503
  }
4998
5504
  if (outputFormat !== "human") {
@@ -5000,7 +5506,7 @@ function registerComponentCommand(parent) {
5000
5506
  return;
5001
5507
  }
5002
5508
  console.log();
5003
- console.log(` ${stateSymbol2(match.state)} ${chalk23.bold(match.id)} ${match.version ? chalk23.dim("v" + match.version) : ""}`);
5509
+ console.log(` ${stateSymbol2(match.state)} ${chalk25.bold(match.id)} ${match.version ? chalk25.dim("v" + match.version) : ""}`);
5004
5510
  console.log(` State: ${match.state}`);
5005
5511
  if (match.lastCheckAt) {
5006
5512
  console.log(` Last check: ${new Date(match.lastCheckAt).toLocaleString()}`);
@@ -5009,7 +5515,7 @@ function registerComponentCommand(parent) {
5009
5515
  console.log();
5010
5516
  console.log(" Checks:");
5011
5517
  for (const check of match.checks) {
5012
- const cat = check.category ? chalk23.dim(` (${check.category})`) : "";
5518
+ const cat = check.category ? chalk25.dim(` (${check.category})`) : "";
5013
5519
  console.log(` ${stateSymbol2(check.state)} ${check.name}${cat}`);
5014
5520
  }
5015
5521
  }
@@ -5021,12 +5527,12 @@ function registerComponentCommand(parent) {
5021
5527
  }
5022
5528
 
5023
5529
  // src/commands/status/incidents.ts
5024
- import chalk24 from "chalk";
5530
+ import chalk26 from "chalk";
5025
5531
  var SEVERITY_COLORS = {
5026
- ERROR: chalk24.red,
5027
- WARNING: chalk24.yellow,
5028
- INFO: chalk24.blue,
5029
- MAINTENANCE: chalk24.cyan
5532
+ ERROR: chalk26.red,
5533
+ WARNING: chalk26.yellow,
5534
+ INFO: chalk26.blue,
5535
+ MAINTENANCE: chalk26.cyan
5030
5536
  };
5031
5537
  function registerIncidentsCommand(parent) {
5032
5538
  parent.command("incidents").description("List recent incidents").option("-w, --window <window>", "Time window (e.g. 24h, 48h)", "24h").action(async (options, cmd) => {
@@ -5040,22 +5546,22 @@ function registerIncidentsCommand(parent) {
5040
5546
  return;
5041
5547
  }
5042
5548
  if (incidents.length === 0) {
5043
- console.log(chalk24.dim(`
5549
+ console.log(chalk26.dim(`
5044
5550
  No incidents in the last ${options.window}.
5045
5551
  `));
5046
5552
  return;
5047
5553
  }
5048
5554
  console.log();
5049
5555
  for (const incident of incidents) {
5050
- const color = SEVERITY_COLORS[incident.severity] ?? chalk24.gray;
5556
+ const color = SEVERITY_COLORS[incident.severity] ?? chalk26.gray;
5051
5557
  const severity = color(incident.severity.padEnd(8));
5052
5558
  const time = incident.startedAt ? new Date(incident.startedAt).toLocaleString() : "";
5053
- const resolved = incident.resolvedAt ? chalk24.green(" [resolved]") : chalk24.yellow(" [open]");
5559
+ const resolved = incident.resolvedAt ? chalk26.green(" [resolved]") : chalk26.yellow(" [open]");
5054
5560
  console.log(` ${severity} ${incident.summary}${resolved}`);
5055
- console.log(chalk24.dim(` ${time}`));
5561
+ console.log(chalk26.dim(` ${time}`));
5056
5562
  for (const update of incident.updates) {
5057
5563
  const updateTime = new Date(update.at).toLocaleTimeString();
5058
- console.log(chalk24.dim(` ${updateTime} ${update.status} ${update.message}`));
5564
+ console.log(chalk26.dim(` ${updateTime} ${update.status} ${update.message}`));
5059
5565
  }
5060
5566
  console.log();
5061
5567
  }
@@ -5074,7 +5580,7 @@ function registerStatusCommands(program) {
5074
5580
  }
5075
5581
 
5076
5582
  // src/commands/analyze/index.ts
5077
- import chalk25 from "chalk";
5583
+ import chalk27 from "chalk";
5078
5584
  import * as fs8 from "fs";
5079
5585
  import * as path7 from "path";
5080
5586
  import { spawn as spawn2 } from "child_process";
@@ -5119,9 +5625,25 @@ function multipartFromFile(file) {
5119
5625
  }
5120
5626
  async function runAnalysis(file, options, cmd) {
5121
5627
  if (!fs8.existsSync(file)) {
5122
- console.error(chalk25.red(`File not found: ${file}`));
5628
+ console.error(chalk27.red(`File not found: ${file}`));
5123
5629
  process.exit(1);
5124
5630
  }
5631
+ if (options.preset) {
5632
+ const api2 = createApiClient();
5633
+ const opt = await api2.analysis.getPreset(options.preset);
5634
+ if (!opt.preset) {
5635
+ console.error(chalk27.red(`Preset not found: ${options.preset}`));
5636
+ process.exit(1);
5637
+ }
5638
+ const p = opt.preset;
5639
+ if (options.targets === void 0 && p.targetKeys.length > 0) options.targets = p.targetKeys.join(",");
5640
+ if (options.questions === void 0 && p.questions.length > 0) options.questions = p.questions.join(",");
5641
+ if (options.segment === void 0 && p.segmentKey) options.segment = p.segmentKey;
5642
+ if (options.hours === void 0) options.hours = p.time;
5643
+ if (options.budget === void 0) options.budget = p.budget;
5644
+ }
5645
+ const hours = options.hours ?? "4";
5646
+ const budget = options.budget ?? "400";
5125
5647
  const api = createApiClient();
5126
5648
  const visibility = parseVisibility(options.visibility);
5127
5649
  const name = options.name ?? path7.basename(file, path7.extname(file));
@@ -5130,25 +5652,25 @@ async function runAnalysis(file, options, cmd) {
5130
5652
  description: options.description || null,
5131
5653
  visibility,
5132
5654
  introduction: options.introduction ?? null,
5133
- hours: options.hours,
5134
- budget: options.budget,
5655
+ hours,
5656
+ budget,
5135
5657
  targets: parseCsv(options.targets),
5136
5658
  questions: parseCsv(options.questions),
5137
5659
  segment: options.segment ?? null
5138
5660
  };
5139
5661
  process.stdout.write(`Creating analysis "${name}" ...`);
5140
5662
  const created = await api.analysis.create(request);
5141
- console.log(chalk25.green(" done"));
5142
- console.log(chalk25.dim(` analysisId: ${created.analysisId}`));
5663
+ console.log(chalk27.green(" done"));
5664
+ console.log(chalk27.dim(` analysisId: ${created.analysisId}`));
5143
5665
  process.stdout.write(`Uploading ${path7.basename(file)} ...`);
5144
5666
  await api.analysis.uploadDataMultipart(created.analysisId, multipartFromFile(file));
5145
- console.log(chalk25.green(" done"));
5667
+ console.log(chalk27.green(" done"));
5146
5668
  process.stdout.write("Queuing analysis run ...");
5147
5669
  const run = await api.analysis.runAnalysis(created.analysisId);
5148
- console.log(chalk25.green(" done"));
5149
- console.log(chalk25.dim(` runId: ${run.runId}`));
5670
+ console.log(chalk27.green(" done"));
5671
+ console.log(chalk27.dim(` runId: ${run.runId}`));
5150
5672
  console.log();
5151
- await monitorRun(api, created.analysisId, run.runId, parseFloat(options.hours), cmd);
5673
+ await monitorRun(api, created.analysisId, run.runId, parseFloat(hours), cmd);
5152
5674
  }
5153
5675
  async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5154
5676
  const config = loadConfig();
@@ -5171,7 +5693,11 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5171
5693
  if (!seenOutputIds.has(out.outputId)) {
5172
5694
  seenOutputIds.add(out.outputId);
5173
5695
  if (outputFormat === "human") {
5174
- console.log(` ${chalk25.dim("Output:")} ${out.output}`);
5696
+ console.log(` ${chalk27.dim("Output:")} ${out.output}`);
5697
+ } else {
5698
+ process.stdout.write(
5699
+ JSON.stringify({ type: "output", outputId: out.outputId, output: out.output }) + "\n"
5700
+ );
5175
5701
  }
5176
5702
  }
5177
5703
  }
@@ -5184,7 +5710,7 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5184
5710
  const durationStr = formatDuration(duration);
5185
5711
  if (run.state === "COMPLETED") {
5186
5712
  if (outputFormat === "human") {
5187
- console.log(chalk25.green(`Analysis complete! (${durationStr})`));
5713
+ console.log(chalk27.green(`Analysis complete! (${durationStr})`));
5188
5714
  try {
5189
5715
  const nav = await api.analysis.getNavigation(analysisId);
5190
5716
  const endpoint = config.profiles[config.currentProfile]?.endpoint ?? "https://diafunc.com";
@@ -5196,13 +5722,13 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5196
5722
  }
5197
5723
  } else if (run.state === "CANCELLED") {
5198
5724
  if (outputFormat === "human") {
5199
- console.log(chalk25.yellow("Analysis cancelled."));
5725
+ console.log(chalk27.yellow("Analysis cancelled."));
5200
5726
  } else {
5201
5727
  format({ status: "cancelled", runId, analysisId }, { format: outputFormat });
5202
5728
  }
5203
5729
  } else {
5204
5730
  if (outputFormat === "human") {
5205
- console.log(chalk25.red("Analysis failed."));
5731
+ console.log(chalk27.red("Analysis failed."));
5206
5732
  if (run.errorMessage) console.log(` Error: ${run.errorMessage}`);
5207
5733
  } else {
5208
5734
  format({ status: "failed", runId, analysisId, error: run.errorMessage }, { format: outputFormat });
@@ -5244,7 +5770,7 @@ async function getAnalysisDetails(analysisId, cmd) {
5244
5770
  const api = createApiClient();
5245
5771
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5246
5772
  if (!result.analysis) {
5247
- console.log(chalk25.dim("No analysis found."));
5773
+ console.log(chalk27.dim("No analysis found."));
5248
5774
  return;
5249
5775
  }
5250
5776
  format(result.analysis, { format: outputFormat });
@@ -5253,18 +5779,18 @@ async function watchAnalysis(analysisId, cmd) {
5253
5779
  const api = createApiClient();
5254
5780
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5255
5781
  if (!result.analysis) {
5256
- console.log(chalk25.dim("No analysis found."));
5782
+ console.log(chalk27.dim("No analysis found."));
5257
5783
  return;
5258
5784
  }
5259
5785
  const recipe = result.analysis;
5260
5786
  const runs = await api.analysis.getRunsForAnalysis(recipe.analysisId, 1);
5261
5787
  if (runs.length === 0) {
5262
- console.log(chalk25.dim("No runs for this analysis."));
5788
+ console.log(chalk27.dim("No runs for this analysis."));
5263
5789
  return;
5264
5790
  }
5265
5791
  const latest = runs[0];
5266
5792
  if (isTerminalState(latest.state)) {
5267
- console.log(chalk25.green(`Latest run already in terminal state: ${latest.state}`));
5793
+ console.log(chalk27.green(`Latest run already in terminal state: ${latest.state}`));
5268
5794
  try {
5269
5795
  const nav = await api.analysis.getNavigation(recipe.analysisId);
5270
5796
  const config = loadConfig();
@@ -5280,16 +5806,16 @@ async function watchAnalysis(analysisId, cmd) {
5280
5806
  async function rerunAnalysis(analysisId) {
5281
5807
  const api = createApiClient();
5282
5808
  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}`));
5809
+ console.log(chalk27.green(`\u2713 Queued new run ${run.runId} for analysis ${analysisId}`));
5810
+ console.log(chalk27.dim(` State: ${run.state}`));
5285
5811
  console.log();
5286
- console.log(chalk25.dim("Track progress: diafunc analyze watch " + analysisId));
5812
+ console.log(chalk27.dim("Track progress: diafunc analyze watch " + analysisId));
5287
5813
  }
5288
5814
  async function openAnalysis(analysisId) {
5289
5815
  const api = createApiClient();
5290
5816
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5291
5817
  if (!result.analysis) {
5292
- console.log(chalk25.dim("No analysis found."));
5818
+ console.log(chalk27.dim("No analysis found."));
5293
5819
  return;
5294
5820
  }
5295
5821
  const config = loadConfig();
@@ -5300,7 +5826,7 @@ async function openAnalysis(analysisId) {
5300
5826
  console.log(`Opening ${url} ...`);
5301
5827
  openUrl(url);
5302
5828
  } catch {
5303
- console.log(chalk25.dim("Notebook not yet provisioned \u2014 run the analysis first."));
5829
+ console.log(chalk27.dim("Notebook not yet provisioned \u2014 run the analysis first."));
5304
5830
  }
5305
5831
  }
5306
5832
  async function createRecipe(options, cmd) {
@@ -5324,14 +5850,14 @@ async function createRecipe(options, cmd) {
5324
5850
  async function deleteAnalysis(analysisId) {
5325
5851
  const api = createApiClient();
5326
5852
  await api.analysis.delete(analysisId);
5327
- console.log(chalk25.green(`\u2713 Deleted analysis ${analysisId}`));
5853
+ console.log(chalk27.green(`\u2713 Deleted analysis ${analysisId}`));
5328
5854
  }
5329
5855
  async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
5330
5856
  const outputFormat = getOutputFormat15(cmd);
5331
5857
  const api = createApiClient();
5332
5858
  const updated = await handler(api, analysisId, value);
5333
5859
  if (outputFormat === "human") {
5334
- console.log(chalk25.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
5860
+ console.log(chalk27.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
5335
5861
  } else {
5336
5862
  format(updated, { format: outputFormat });
5337
5863
  }
@@ -5340,32 +5866,32 @@ async function uploadData(analysisId, file, options) {
5340
5866
  const api = createApiClient();
5341
5867
  if (options.url) {
5342
5868
  if (file) {
5343
- console.error(chalk25.red("Provide either a file or --url, not both."));
5869
+ console.error(chalk27.red("Provide either a file or --url, not both."));
5344
5870
  process.exit(1);
5345
5871
  }
5346
5872
  process.stdout.write(`Uploading from ${options.url} ...`);
5347
5873
  await api.analysis.uploadDataUrl(analysisId, { dataUrl: options.url });
5348
- console.log(chalk25.green(" done"));
5874
+ console.log(chalk27.green(" done"));
5349
5875
  return;
5350
5876
  }
5351
5877
  if (!file) {
5352
- console.error(chalk25.red("Provide a file path or --url <URL>."));
5878
+ console.error(chalk27.red("Provide a file path or --url <URL>."));
5353
5879
  process.exit(1);
5354
5880
  }
5355
5881
  if (!fs8.existsSync(file)) {
5356
- console.error(chalk25.red(`File not found: ${file}`));
5882
+ console.error(chalk27.red(`File not found: ${file}`));
5357
5883
  process.exit(1);
5358
5884
  }
5359
5885
  process.stdout.write(`Uploading ${path7.basename(file)} ...`);
5360
5886
  await api.analysis.uploadDataMultipart(analysisId, multipartFromFile(file));
5361
- console.log(chalk25.green(" done"));
5887
+ console.log(chalk27.green(" done"));
5362
5888
  }
5363
5889
  async function listColumns(analysisId, cmd) {
5364
5890
  const outputFormat = getOutputFormat15(cmd);
5365
5891
  const api = createApiClient();
5366
5892
  const columns = await api.analysis.getColumns(analysisId);
5367
5893
  if (columns.length === 0) {
5368
- console.log(chalk25.dim("No columns yet \u2014 upload data first."));
5894
+ console.log(chalk27.dim("No columns yet \u2014 upload data first."));
5369
5895
  return;
5370
5896
  }
5371
5897
  format(columns, { format: outputFormat, columns: ["name", "valueType"] });
@@ -5391,7 +5917,7 @@ async function cancelRun(runId, cmd) {
5391
5917
  const api = createApiClient();
5392
5918
  const run = await api.analysis.cancelRun(runId);
5393
5919
  if (outputFormat === "human") {
5394
- console.log(chalk25.green(`\u2713 Run ${run.runId} state: ${run.state}`));
5920
+ console.log(chalk27.green(`\u2713 Run ${run.runId} state: ${run.state}`));
5395
5921
  } else {
5396
5922
  format(run, { format: outputFormat });
5397
5923
  }
@@ -5418,7 +5944,7 @@ async function getPreset(presetId, cmd) {
5418
5944
  const api = createApiClient();
5419
5945
  const opt = await api.analysis.getPreset(presetId);
5420
5946
  if (!opt.preset) {
5421
- console.log(chalk25.dim("Preset not found."));
5947
+ console.log(chalk27.dim("Preset not found."));
5422
5948
  return;
5423
5949
  }
5424
5950
  format(opt.preset, { format: outputFormat });
@@ -5441,7 +5967,7 @@ async function savePreset(options, cmd) {
5441
5967
  async function deletePreset(presetId) {
5442
5968
  const api = createApiClient();
5443
5969
  await api.analysis.deletePreset(presetId);
5444
- console.log(chalk25.green(`\u2713 Deleted preset ${presetId}`));
5970
+ console.log(chalk27.green(`\u2713 Deleted preset ${presetId}`));
5445
5971
  }
5446
5972
  async function listTriggers(analysisId, cmd) {
5447
5973
  const outputFormat = getOutputFormat15(cmd);
@@ -5462,7 +5988,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
5462
5988
  const outputFormat = getOutputFormat15(cmd);
5463
5989
  const upper = kind.toUpperCase();
5464
5990
  if (upper !== "ONCE" && upper !== "CRON") {
5465
- console.error(chalk25.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
5991
+ console.error(chalk27.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
5466
5992
  process.exit(1);
5467
5993
  }
5468
5994
  const api = createApiClient();
@@ -5475,7 +6001,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
5475
6001
  async function deleteTrigger(triggerId) {
5476
6002
  const api = createApiClient();
5477
6003
  await api.analysis.deleteTrigger(triggerId);
5478
- console.log(chalk25.green(`\u2713 Deleted trigger ${triggerId}`));
6004
+ console.log(chalk27.green(`\u2713 Deleted trigger ${triggerId}`));
5479
6005
  }
5480
6006
  async function updateTriggerCmd(triggerId, options, cmd) {
5481
6007
  const outputFormat = getOutputFormat15(cmd);
@@ -5483,13 +6009,13 @@ async function updateTriggerCmd(triggerId, options, cmd) {
5483
6009
  if (options.active !== void 0) {
5484
6010
  const lc = options.active.toLowerCase();
5485
6011
  if (lc !== "true" && lc !== "false") {
5486
- console.error(chalk25.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
6012
+ console.error(chalk27.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
5487
6013
  process.exit(1);
5488
6014
  }
5489
6015
  activeFlag = lc === "true";
5490
6016
  }
5491
6017
  if (activeFlag === void 0 && !options.schedule) {
5492
- console.error(chalk25.red("Pass at least one of --active or --schedule."));
6018
+ console.error(chalk27.red("Pass at least one of --active or --schedule."));
5493
6019
  process.exit(1);
5494
6020
  }
5495
6021
  const api = createApiClient();
@@ -5501,7 +6027,7 @@ async function updateTriggerCmd(triggerId, options, cmd) {
5501
6027
  }
5502
6028
  function registerAnalyzeCommand(program) {
5503
6029
  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) => {
6030
+ 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
6031
  try {
5506
6032
  if (!file) {
5507
6033
  analyze.help();
@@ -5554,8 +6080,9 @@ function registerAnalyzeCommand(program) {
5554
6080
  handleError(error);
5555
6081
  }
5556
6082
  });
5557
- analyze.command("delete").description("Delete an analysis (cancels in-flight run; removes underlying project)").argument("<id>", "Analysis ID").action(async (id) => {
6083
+ 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
6084
  try {
6085
+ await confirmDestructive(`This will permanently delete analysis "${id}".`, { yes: options.yes, resourceId: id });
5559
6086
  await deleteAnalysis(id);
5560
6087
  } catch (error) {
5561
6088
  handleError(error);
@@ -5681,7 +6208,7 @@ function registerAnalyzeCommand(program) {
5681
6208
  handleError(error);
5682
6209
  }
5683
6210
  });
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) => {
6211
+ 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
6212
  try {
5686
6213
  await uploadData(id, file, options);
5687
6214
  } catch (error) {
@@ -5731,8 +6258,9 @@ function registerAnalyzeCommand(program) {
5731
6258
  handleError(error);
5732
6259
  }
5733
6260
  });
5734
- presets.command("delete").description("Delete a preset").argument("<id>", "Preset ID").action(async (id) => {
6261
+ 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
6262
  try {
6263
+ await confirmDestructive(`This will permanently delete preset "${id}".`, { yes: options.yes, resourceId: id });
5736
6264
  await deletePreset(id);
5737
6265
  } catch (error) {
5738
6266
  handleError(error);
@@ -5753,8 +6281,9 @@ function registerAnalyzeCommand(program) {
5753
6281
  handleError(error);
5754
6282
  }
5755
6283
  });
5756
- triggers.command("delete").description("Delete a trigger").argument("<triggerId>", "Trigger ID").action(async (triggerId) => {
6284
+ 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
6285
  try {
6286
+ await confirmDestructive(`This will permanently delete trigger "${triggerId}".`, { yes: options.yes, resourceId: triggerId });
5758
6287
  await deleteTrigger(triggerId);
5759
6288
  } catch (error) {
5760
6289
  handleError(error);
@@ -5770,7 +6299,7 @@ function registerAnalyzeCommand(program) {
5770
6299
  }
5771
6300
 
5772
6301
  // src/commands/data-sources/index.ts
5773
- import chalk26 from "chalk";
6302
+ import chalk28 from "chalk";
5774
6303
  function getOutputFormat16(cmd) {
5775
6304
  const config = loadConfig();
5776
6305
  const globalOpts = cmd.optsWithGlobals();
@@ -5864,7 +6393,7 @@ async function listDataSources(projectId, cmd) {
5864
6393
  const api = createApiClient();
5865
6394
  const sources = await api.storage.listDataSources(projectId);
5866
6395
  if (outputFormat === "human" && sources.length === 0) {
5867
- console.log(chalk26.dim("No data sources found."));
6396
+ console.log(chalk28.dim("No data sources found."));
5868
6397
  return;
5869
6398
  }
5870
6399
  format(sources.map(dataSourceTableRow), {
@@ -5887,11 +6416,11 @@ async function showDashboard(projectId, cmd) {
5887
6416
  return;
5888
6417
  }
5889
6418
  const r = dashboard.rollup;
5890
- let line = chalk26.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
6419
+ let line = chalk28.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
5891
6420
  if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
5892
6421
  console.log(line);
5893
6422
  if (dashboard.sources.length === 0) {
5894
- console.log(chalk26.dim("No data sources."));
6423
+ console.log(chalk28.dim("No data sources."));
5895
6424
  return;
5896
6425
  }
5897
6426
  format(dashboard.sources.map(dashboardTableRow), {
@@ -5914,9 +6443,9 @@ async function createDataSource(options, cmd) {
5914
6443
  };
5915
6444
  const ds = await api.storage.createDataSource(request);
5916
6445
  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}`));
6446
+ console.log(chalk28.green(`\u2713 Created data source ${ds.id}`));
6447
+ console.log(chalk28.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
6448
+ if (ds.lastRunError) console.log(chalk28.dim(` Error: ${ds.lastRunError}`));
5920
6449
  } else {
5921
6450
  format(ds, { format: outputFormat });
5922
6451
  }
@@ -5946,7 +6475,7 @@ async function updateDataSource(id, options, cmd) {
5946
6475
  const api = createApiClient();
5947
6476
  const ds = await api.storage.updateDataSource(id, request);
5948
6477
  if (outputFormat === "human") {
5949
- console.log(chalk26.green(`\u2713 Updated data source ${ds.id}`));
6478
+ console.log(chalk28.green(`\u2713 Updated data source ${ds.id}`));
5950
6479
  } else {
5951
6480
  format(ds, { format: outputFormat });
5952
6481
  }
@@ -5954,15 +6483,15 @@ async function updateDataSource(id, options, cmd) {
5954
6483
  async function deleteDataSource(id) {
5955
6484
  const api = createApiClient();
5956
6485
  await api.storage.deleteDataSource(id);
5957
- console.log(chalk26.green(`\u2713 Deleted data source ${id}`));
6486
+ console.log(chalk28.green(`\u2713 Deleted data source ${id}`));
5958
6487
  }
5959
6488
  async function refreshDataSource(id, cmd) {
5960
6489
  const outputFormat = getOutputFormat16(cmd);
5961
6490
  const api = createApiClient();
5962
6491
  const run = await api.storage.refreshDataSource(id);
5963
6492
  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}`));
6493
+ console.log(chalk28.green(`\u2713 Refresh queued \u2014 run ${run.runId}, status ${run.status}`));
6494
+ if (run.errorMessage) console.log(chalk28.red(` Error: ${run.errorMessage}`));
5966
6495
  } else {
5967
6496
  format(run, { format: outputFormat });
5968
6497
  }
@@ -5972,7 +6501,7 @@ async function listRuns2(id, limit, cmd) {
5972
6501
  const api = createApiClient();
5973
6502
  const runs = await api.storage.listDataSourceRuns(id, limit);
5974
6503
  if (outputFormat === "human" && runs.length === 0) {
5975
- console.log(chalk26.dim("No runs yet."));
6504
+ console.log(chalk28.dim("No runs yet."));
5976
6505
  return;
5977
6506
  }
5978
6507
  format(runs.map(runTableRow), {
@@ -5992,7 +6521,7 @@ async function listConnectorTypes(cmd) {
5992
6521
  const types = await api.storage.listDataSourceConnectorTypes();
5993
6522
  if (outputFormat === "human") {
5994
6523
  if (types.length === 0) {
5995
- console.log(chalk26.dim("No connector types registered."));
6524
+ console.log(chalk28.dim("No connector types registered."));
5996
6525
  return;
5997
6526
  }
5998
6527
  for (const t of types) console.log(t);
@@ -6037,8 +6566,9 @@ function registerDataSourcesCommands(program) {
6037
6566
  handleError(error);
6038
6567
  }
6039
6568
  });
6040
- dataSources.command("delete").description("Delete a data source (existing imported rows are kept)").argument("<id>", "Data source ID").action(async (id) => {
6569
+ 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
6570
  try {
6571
+ await confirmDestructive(`This will permanently delete data source "${id}".`, { yes: options.yes, resourceId: id });
6042
6572
  await deleteDataSource(id);
6043
6573
  } catch (error) {
6044
6574
  handleError(error);
@@ -6075,7 +6605,7 @@ function registerDataSourcesCommands(program) {
6075
6605
  }
6076
6606
 
6077
6607
  // src/commands/table-exporters/index.ts
6078
- import chalk27 from "chalk";
6608
+ import chalk29 from "chalk";
6079
6609
  function getOutputFormat17(cmd) {
6080
6610
  const config = loadConfig();
6081
6611
  const globalOpts = cmd.optsWithGlobals();
@@ -6106,7 +6636,7 @@ function registerTableExportersCommands(program) {
6106
6636
  format: outputFormat,
6107
6637
  columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
6108
6638
  });
6109
- console.log(chalk27.dim(`${list.length} exporter(s)`));
6639
+ console.log(chalk29.dim(`${list.length} exporter(s)`));
6110
6640
  } catch (error) {
6111
6641
  handleError(error);
6112
6642
  }
@@ -6118,7 +6648,7 @@ function registerTableExportersCommands(program) {
6118
6648
  const list = await api.storage.listUserDefinedExporters();
6119
6649
  const exporter = list.find((e) => e.id === id);
6120
6650
  if (!exporter) {
6121
- console.error(chalk27.red(`No exporter with id="${id}".`));
6651
+ console.error(chalk29.red(`No exporter with id="${id}".`));
6122
6652
  process.exit(1);
6123
6653
  }
6124
6654
  format(exporter, { format: outputFormat });
@@ -6147,7 +6677,7 @@ function registerTableExportersCommands(program) {
6147
6677
  format(created, { format: outputFormat });
6148
6678
  return;
6149
6679
  }
6150
- console.log(chalk27.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
6680
+ console.log(chalk29.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
6151
6681
  } catch (error) {
6152
6682
  handleError(error);
6153
6683
  }
@@ -6156,7 +6686,7 @@ function registerTableExportersCommands(program) {
6156
6686
  try {
6157
6687
  const api = createApiClient();
6158
6688
  await api.storage.deleteUserDefinedExporter(id);
6159
- console.log(chalk27.green(`Deleted exporter id=${id}`));
6689
+ console.log(chalk29.green(`Deleted exporter id=${id}`));
6160
6690
  } catch (error) {
6161
6691
  handleError(error);
6162
6692
  }
@@ -6164,7 +6694,7 @@ function registerTableExportersCommands(program) {
6164
6694
  }
6165
6695
 
6166
6696
  // src/commands/skeleton/index.ts
6167
- import chalk28 from "chalk";
6697
+ import chalk30 from "chalk";
6168
6698
  import * as fs9 from "fs";
6169
6699
  function getOutputFormat18(cmd) {
6170
6700
  const config = loadConfig();
@@ -6230,11 +6760,11 @@ async function createSkeleton(options, cmd) {
6230
6760
  const api = createApiClient();
6231
6761
  const skeleton = await api.storage.createSkeleton(request);
6232
6762
  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}`));
6763
+ console.log(chalk30.green(`\u2713 Created skeleton ${skeleton.id}`));
6764
+ console.log(chalk30.dim(` name: ${skeleton.name}`));
6765
+ console.log(chalk30.dim(` template: ${skeleton.template}`));
6766
+ console.log(chalk30.dim(` paramCount: ${skeleton.paramCount}`));
6767
+ console.log(chalk30.dim(` weight: ${skeleton.weight}`));
6238
6768
  } else {
6239
6769
  format(skeleton, { format: outputFormat });
6240
6770
  }
@@ -6245,7 +6775,7 @@ async function listSkeletons(localProject, cmd) {
6245
6775
  const api = createApiClient();
6246
6776
  const skeletons = await api.storage.listSkeletons(projectId);
6247
6777
  if (outputFormat === "human" && skeletons.length === 0) {
6248
- console.log(chalk28.dim(`No skeletons in project ${projectId}.`));
6778
+ console.log(chalk30.dim(`No skeletons in project ${projectId}.`));
6249
6779
  return;
6250
6780
  }
6251
6781
  format(skeletons.map(skeletonTableRow), {
@@ -6272,11 +6802,11 @@ async function updateSkeleton(id, options, cmd) {
6272
6802
  const api = createApiClient();
6273
6803
  const skeleton = await api.storage.updateSkeleton(id, request);
6274
6804
  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}`));
6805
+ console.log(chalk30.green(`\u2713 Updated skeleton ${skeleton.id}`));
6806
+ console.log(chalk30.dim(` name: ${skeleton.name}`));
6807
+ console.log(chalk30.dim(` template: ${skeleton.template}`));
6808
+ console.log(chalk30.dim(` paramCount: ${skeleton.paramCount}`));
6809
+ console.log(chalk30.dim(` weight: ${skeleton.weight}`));
6280
6810
  } else {
6281
6811
  format(skeleton, { format: outputFormat });
6282
6812
  }
@@ -6284,7 +6814,7 @@ async function updateSkeleton(id, options, cmd) {
6284
6814
  async function deleteSkeleton(id) {
6285
6815
  const api = createApiClient();
6286
6816
  await api.storage.deleteSkeleton(id);
6287
- console.log(chalk28.green(`\u2713 Deleted skeleton ${id}`));
6817
+ console.log(chalk30.green(`\u2713 Deleted skeleton ${id}`));
6288
6818
  }
6289
6819
  function registerSkeletonCommands(program) {
6290
6820
  const skeleton = program.command("skeleton").description("Manage user-provided skeleton templates (project-scoped, capped at 100/project)");
@@ -6319,8 +6849,9 @@ function registerSkeletonCommands(program) {
6319
6849
  handleError(error);
6320
6850
  }
6321
6851
  });
6322
- skeleton.command("delete").description("Delete a skeleton").argument("<id>", "Skeleton ID").action(async (id) => {
6852
+ 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
6853
  try {
6854
+ await confirmDestructive(`This will permanently delete skeleton "${id}".`, { yes: options.yes, resourceId: id });
6324
6855
  await deleteSkeleton(id);
6325
6856
  } catch (error) {
6326
6857
  handleError(error);
@@ -6335,7 +6866,7 @@ _diafunc_completions() {
6335
6866
  cur="\${COMP_WORDS[COMP_CWORD]}"
6336
6867
  prev="\${COMP_WORDS[COMP_CWORD-1]}"
6337
6868
 
6338
- commands="auth config project entity link event branch table function trigger schedule chat search group admin analyze help"
6869
+ commands="auth config project team entity link event branch table function trigger schedule chat search admin analyze help"
6339
6870
 
6340
6871
  case "\${COMP_WORDS[1]}" in
6341
6872
  auth)
@@ -6405,11 +6936,13 @@ _diafunc_completions() {
6405
6936
  COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}"))
6406
6937
  fi
6407
6938
  ;;
6408
- group)
6409
- subcommands="list get create delete members projects"
6939
+ team)
6940
+ subcommands="list get use usage create portal cancel leave members invitations seats packs transfer"
6410
6941
  case "\${COMP_WORDS[2]}" in
6411
6942
  members) COMPREPLY=($(compgen -W "list invite remove" -- "\${cur}")) ;;
6412
- projects) COMPREPLY=($(compgen -W "list add remove" -- "\${cur}")) ;;
6943
+ invitations) COMPREPLY=($(compgen -W "list revoke resend accept" -- "\${cur}")) ;;
6944
+ seats|packs) COMPREPLY=($(compgen -W "preview set" -- "\${cur}")) ;;
6945
+ transfer) COMPREPLY=($(compgen -W "start status accept cancel" -- "\${cur}")) ;;
6413
6946
  *) COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}")) ;;
6414
6947
  esac
6415
6948
  ;;
@@ -6436,6 +6969,7 @@ _diafunc() {
6436
6969
  'auth:Authentication and credential management'
6437
6970
  'config:Manage CLI configuration'
6438
6971
  'project:Manage projects'
6972
+ 'team:Manage teams'
6439
6973
  'entity:Manage entities'
6440
6974
  'link:Manage links between entities'
6441
6975
  'event:Manage events'
@@ -6446,7 +6980,6 @@ _diafunc() {
6446
6980
  'schedule:Schedule function execution'
6447
6981
  'chat:AI chat'
6448
6982
  'search:Search entities across projects'
6449
- 'group:Manage groups'
6450
6983
  'admin:Administration commands'
6451
6984
  'analyze:Run an automatic analysis on a data file'
6452
6985
  )
@@ -6470,6 +7003,7 @@ _diafunc() {
6470
7003
  auth) _diafunc_auth ;;
6471
7004
  config) _diafunc_config ;;
6472
7005
  project) _diafunc_project ;;
7006
+ team) _diafunc_team ;;
6473
7007
  entity) _diafunc_entity ;;
6474
7008
  link) _values 'subcommand' list create delete ;;
6475
7009
  event) _values 'subcommand' list get delete ;;
@@ -6479,7 +7013,6 @@ _diafunc() {
6479
7013
  trigger) _values 'subcommand' list get delete ;;
6480
7014
  schedule) _values 'subcommand' call ;;
6481
7015
  chat) _diafunc_chat ;;
6482
- group) _diafunc_group ;;
6483
7016
  admin) _diafunc_admin ;;
6484
7017
  analyze) _files '*.csv' '*.xlsx' '*.xls' ;;
6485
7018
  esac
@@ -6490,15 +7023,15 @@ _diafunc() {
6490
7023
  _diafunc_auth() { _values 'subcommand' login logout status token; }
6491
7024
  _diafunc_config() { _values 'subcommand' set get list profile; }
6492
7025
  _diafunc_project() { _values 'subcommand' list get create delete lock unlock members; }
7026
+ _diafunc_team() { _values 'subcommand' list get use usage create portal cancel leave members invitations seats packs transfer; }
6493
7027
  _diafunc_entity() { _values 'subcommand' list get delete history revert rename content; }
6494
7028
  _diafunc_table() { _values 'subcommand' view import export row column cell clear; }
6495
7029
  _diafunc_chat() { _values 'subcommand' send stream upload session usage; }
6496
- _diafunc_group() { _values 'subcommand' list get create delete members projects; }
6497
7030
  _diafunc_admin() { _values 'subcommand' users subscription settings backup; }
6498
7031
 
6499
7032
  _diafunc "$@"`;
6500
7033
  var FISH_COMPLETION = `# Fish completions for diafunc
6501
- set -l commands auth config project entity link event branch table function trigger schedule chat search group admin analyze
7034
+ set -l commands auth config project team entity link event branch table function trigger schedule chat search admin analyze
6502
7035
 
6503
7036
  # Disable file completions by default
6504
7037
  complete -c diafunc -f
@@ -6507,6 +7040,7 @@ complete -c diafunc -f
6507
7040
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a auth -d "Authentication and credential management"
6508
7041
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a config -d "Manage CLI configuration"
6509
7042
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a project -d "Manage projects"
7043
+ complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a team -d "Manage teams"
6510
7044
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a entity -d "Manage entities"
6511
7045
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a link -d "Manage links between entities"
6512
7046
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a event -d "Manage events"
@@ -6517,7 +7051,6 @@ complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a trigger -d
6517
7051
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a schedule -d "Schedule function execution"
6518
7052
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a chat -d "AI chat"
6519
7053
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a search -d "Search entities"
6520
- complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a group -d "Manage groups"
6521
7054
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a admin -d "Administration commands"
6522
7055
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a analyze -d "Run automatic analysis"
6523
7056
 
@@ -6554,8 +7087,11 @@ complete -c diafunc -n "__fish_seen_subcommand_from function; and not __fish_see
6554
7087
  # chat
6555
7088
  complete -c diafunc -n "__fish_seen_subcommand_from chat; and not __fish_seen_subcommand_from send stream upload session usage" -a "send stream upload session usage"
6556
7089
 
6557
- # group
6558
- complete -c diafunc -n "__fish_seen_subcommand_from group; and not __fish_seen_subcommand_from list get create delete members projects" -a "list get create delete members projects"
7090
+ # team
7091
+ complete -c diafunc -n "__fish_seen_subcommand_from team; and not __fish_seen_subcommand_from list get use usage create portal cancel leave members invitations seats packs transfer" -a "list get use usage create portal cancel leave members invitations seats packs transfer"
7092
+ complete -c diafunc -n "__fish_seen_subcommand_from invitations; and not __fish_seen_subcommand_from list revoke resend accept" -a "list revoke resend accept"
7093
+ complete -c diafunc -n "__fish_seen_subcommand_from seats packs; and not __fish_seen_subcommand_from preview set" -a "preview set"
7094
+ complete -c diafunc -n "__fish_seen_subcommand_from transfer; and not __fish_seen_subcommand_from start status accept cancel" -a "start status accept cancel"
6559
7095
 
6560
7096
  # admin
6561
7097
  complete -c diafunc -n "__fish_seen_subcommand_from admin; and not __fish_seen_subcommand_from users subscription settings backup" -a "users subscription settings backup"
@@ -6582,7 +7118,7 @@ function registerCompletionCommand(program) {
6582
7118
  }
6583
7119
 
6584
7120
  // src/commands/whoami/index.ts
6585
- import chalk29 from "chalk";
7121
+ import chalk31 from "chalk";
6586
7122
  function registerWhoamiCommand(program) {
6587
7123
  program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
6588
7124
  try {
@@ -6592,8 +7128,8 @@ function registerWhoamiCommand(program) {
6592
7128
  const api = createApiClient();
6593
7129
  const user = await api.admin.getMyUser();
6594
7130
  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}`));
7131
+ console.log(chalk31.bold(user.name) + chalk31.dim(` <${user.email}>`));
7132
+ console.log(chalk31.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
6597
7133
  } else {
6598
7134
  format(user, { format: outputFormat });
6599
7135
  }
@@ -6604,7 +7140,7 @@ function registerWhoamiCommand(program) {
6604
7140
  }
6605
7141
 
6606
7142
  // src/commands/utilization/index.ts
6607
- import chalk30 from "chalk";
7143
+ import chalk32 from "chalk";
6608
7144
  function getOutputFormat19(cmd) {
6609
7145
  const config = loadConfig();
6610
7146
  const globalOpts = cmd.optsWithGlobals();
@@ -6613,21 +7149,21 @@ function getOutputFormat19(cmd) {
6613
7149
  function printUtilizationHuman(u, label) {
6614
7150
  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
7151
  if (label) {
6616
- console.log(chalk30.bold(label) + " " + chalk30.dim(when));
7152
+ console.log(chalk32.bold(label) + " " + chalk32.dim(when));
6617
7153
  } else {
6618
- console.log(chalk30.bold(when));
7154
+ console.log(chalk32.bold(when));
6619
7155
  }
6620
7156
  if (u.types.length === 0) {
6621
- console.log(chalk30.dim(" (no usage)"));
7157
+ console.log(chalk32.dim(" (no usage)"));
6622
7158
  return;
6623
7159
  }
6624
7160
  for (const t of u.types) {
6625
7161
  console.log(
6626
- ` ${t.type.padEnd(24)} ${chalk30.cyan(String(t.quantity).padStart(10))} ${chalk30.dim("credits:")} ${t.credits.toFixed(2)}`
7162
+ ` ${t.type.padEnd(24)} ${chalk32.cyan(String(t.quantity).padStart(10))} ${chalk32.dim("credits:")} ${t.credits.toFixed(2)}`
6627
7163
  );
6628
7164
  }
6629
7165
  const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
6630
- console.log(chalk30.bold(` Total credits: ${total.toFixed(2)}`));
7166
+ console.log(chalk32.bold(` Total credits: ${total.toFixed(2)}`));
6631
7167
  }
6632
7168
  function registerUtilizationCommand(program) {
6633
7169
  const util = program.command("utilization").description("Show credit utilization");
@@ -6652,7 +7188,7 @@ function registerUtilizationCommand(program) {
6652
7188
  const history = await api.admin.getUtilizationHistory();
6653
7189
  if (outputFormat === "human") {
6654
7190
  if (history.length === 0) {
6655
- console.log(chalk30.dim("No usage recorded."));
7191
+ console.log(chalk32.dim("No usage recorded."));
6656
7192
  return;
6657
7193
  }
6658
7194
  for (const u of history) {
@@ -6669,7 +7205,7 @@ function registerUtilizationCommand(program) {
6669
7205
  }
6670
7206
 
6671
7207
  // src/commands/entity-branch/index.ts
6672
- import chalk31 from "chalk";
7208
+ import chalk33 from "chalk";
6673
7209
  function getOutputFormat20(cmd) {
6674
7210
  const config = loadConfig();
6675
7211
  const globalOpts = cmd.optsWithGlobals();
@@ -6713,7 +7249,7 @@ function registerEntityBranchCommands(program) {
6713
7249
  sourceEntityBranch: resolved.entityBranch,
6714
7250
  targetEntityBranch: targetBranch
6715
7251
  });
6716
- console.log(chalk31.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
7252
+ console.log(chalk33.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
6717
7253
  } catch (error) {
6718
7254
  handleError(error);
6719
7255
  }
@@ -6758,7 +7294,7 @@ function registerSubscriptionCommand(program) {
6758
7294
  }
6759
7295
 
6760
7296
  // src/commands/invoice/index.ts
6761
- import chalk32 from "chalk";
7297
+ import chalk34 from "chalk";
6762
7298
  import * as fs10 from "fs";
6763
7299
  function getOutputFormat22(cmd) {
6764
7300
  const config = loadConfig();
@@ -6786,7 +7322,7 @@ function registerInvoiceCommand(program) {
6786
7322
  const buffer = Buffer.from(await response.arrayBuffer());
6787
7323
  const outPath = options.out ?? fileName;
6788
7324
  fs10.writeFileSync(outPath, buffer);
6789
- console.log(chalk32.green(`Invoice saved to ${outPath}`));
7325
+ console.log(chalk34.green(`Invoice saved to ${outPath}`));
6790
7326
  } catch (error) {
6791
7327
  handleError(error);
6792
7328
  }
@@ -6794,7 +7330,7 @@ function registerInvoiceCommand(program) {
6794
7330
  }
6795
7331
 
6796
7332
  // src/commands/shell/index.ts
6797
- import chalk33 from "chalk";
7333
+ import chalk35 from "chalk";
6798
7334
  import * as fs11 from "fs";
6799
7335
  import * as os3 from "os";
6800
7336
  import * as path8 from "path";
@@ -6860,21 +7396,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
6860
7396
  }, false);
6861
7397
  if (result.outputs?.length) {
6862
7398
  for (const out of result.outputs) {
6863
- console.log(chalk33.dim(` [${out.type}]`) + " " + out.output);
7399
+ console.log(chalk35.dim(` [${out.type}]`) + " " + out.output);
6864
7400
  }
6865
7401
  }
6866
7402
  if (result.successful) {
6867
7403
  if (result.result) {
6868
- console.log(chalk33.green("=> ") + result.result);
7404
+ console.log(chalk35.green("=> ") + result.result);
6869
7405
  } else {
6870
- console.log(chalk33.dim("=> (no value)"));
7406
+ console.log(chalk35.dim("=> (no value)"));
6871
7407
  }
6872
7408
  const duration = result.completed - result.started;
6873
- console.log(chalk33.dim(` [${duration}ms \xB7 ${evaluationId}]`));
7409
+ console.log(chalk35.dim(` [${duration}ms \xB7 ${evaluationId}]`));
6874
7410
  } else {
6875
- console.log(chalk33.red("error: ") + result.error);
7411
+ console.log(chalk35.red("error: ") + result.error);
6876
7412
  if (result.lineNumber > 0) {
6877
- console.log(chalk33.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
7413
+ console.log(chalk35.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
6878
7414
  }
6879
7415
  }
6880
7416
  }
@@ -6882,9 +7418,9 @@ function registerShellCommand(program) {
6882
7418
  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
7419
  try {
6884
7420
  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"));
7421
+ console.error(chalk35.red("Missing --function <ref>."));
7422
+ console.error(chalk35.dim("Pass an existing or new function entity reference to use as the shell target."));
7423
+ console.error(chalk35.dim("Example: diafunc shell --function my-project/main/scratch/main --language JavaScript"));
6888
7424
  process.exit(1);
6889
7425
  }
6890
7426
  const config = loadConfig();
@@ -6895,18 +7431,18 @@ function registerShellCommand(program) {
6895
7431
  });
6896
7432
  const api = createApiClient();
6897
7433
  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"));
7434
+ const { getUpdateNotice } = await import("./update-check-UOHMHDN6.js");
7435
+ console.log(chalk35.bold("Diafunc shell") + chalk35.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
7436
+ console.log(chalk35.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
7437
+ console.log(chalk35.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
6902
7438
  const notice = await getUpdateNotice();
6903
- if (notice) console.log(chalk33.dim(notice));
7439
+ if (notice) console.log(chalk35.dim(notice));
6904
7440
  console.log();
6905
7441
  let language = options.language;
6906
7442
  for (; ; ) {
6907
7443
  let line;
6908
7444
  try {
6909
- line = await promptInput({ message: chalk33.cyan.bold(`${language} >`) });
7445
+ line = await promptInput({ message: chalk35.cyan.bold(`${language} >`) });
6910
7446
  } catch {
6911
7447
  console.log();
6912
7448
  return;
@@ -6924,54 +7460,54 @@ function registerShellCommand(program) {
6924
7460
  case "help":
6925
7461
  case "h":
6926
7462
  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"));
7463
+ console.log(chalk35.dim(" /edit open $EDITOR for multi-line code"));
7464
+ console.log(chalk35.dim(" /file <path> evaluate the contents of a file"));
7465
+ console.log(chalk35.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
7466
+ console.log(chalk35.dim(" /quit exit the shell"));
6931
7467
  continue;
6932
7468
  case "lang":
6933
7469
  if (arg) language = arg;
6934
- console.log(chalk33.dim(`Language: ${language}`));
7470
+ console.log(chalk35.dim(`Language: ${language}`));
6935
7471
  continue;
6936
7472
  case "edit": {
6937
7473
  const sourceCode = await openInEditor("", extensionFor2(language));
6938
7474
  if (!sourceCode.trim()) {
6939
- console.log(chalk33.dim("(empty \u2014 not evaluated)"));
7475
+ console.log(chalk35.dim("(empty \u2014 not evaluated)"));
6940
7476
  continue;
6941
7477
  }
6942
7478
  try {
6943
7479
  await evaluate(api, fnRef, language, sourceCode);
6944
7480
  } catch (e) {
6945
- console.error(chalk33.red(e.message));
7481
+ console.error(chalk35.red(e.message));
6946
7482
  }
6947
7483
  continue;
6948
7484
  }
6949
7485
  case "file": {
6950
7486
  if (!arg) {
6951
- console.log(chalk33.dim("usage: /file <path>"));
7487
+ console.log(chalk35.dim("usage: /file <path>"));
6952
7488
  continue;
6953
7489
  }
6954
7490
  if (!fs11.existsSync(arg)) {
6955
- console.log(chalk33.red(`file not found: ${arg}`));
7491
+ console.log(chalk35.red(`file not found: ${arg}`));
6956
7492
  continue;
6957
7493
  }
6958
7494
  const sourceCode = fs11.readFileSync(arg, "utf-8");
6959
7495
  try {
6960
7496
  await evaluate(api, fnRef, language, sourceCode);
6961
7497
  } catch (e) {
6962
- console.error(chalk33.red(e.message));
7498
+ console.error(chalk35.red(e.message));
6963
7499
  }
6964
7500
  continue;
6965
7501
  }
6966
7502
  default:
6967
- console.log(chalk33.dim(`Unknown command: /${cmd2}. Try /help.`));
7503
+ console.log(chalk35.dim(`Unknown command: /${cmd2}. Try /help.`));
6968
7504
  continue;
6969
7505
  }
6970
7506
  }
6971
7507
  try {
6972
7508
  await evaluate(api, fnRef, language, trimmed);
6973
7509
  } catch (e) {
6974
- console.error(chalk33.red(e.message));
7510
+ console.error(chalk35.red(e.message));
6975
7511
  }
6976
7512
  }
6977
7513
  } catch (error) {
@@ -6981,7 +7517,7 @@ function registerShellCommand(program) {
6981
7517
  }
6982
7518
 
6983
7519
  // src/commands/update/index.ts
6984
- import chalk34 from "chalk";
7520
+ import chalk36 from "chalk";
6985
7521
  import * as path9 from "path";
6986
7522
  import { spawn as spawn4 } from "child_process";
6987
7523
 
@@ -7027,14 +7563,14 @@ function registerUpdateCommand(program) {
7027
7563
  const install = detectInstall();
7028
7564
  const latest = await fetchLatestVersion();
7029
7565
  if (latest === package_default.version) {
7030
- console.log(chalk34.dim(`diafunc is already at the latest version (${package_default.version}).`));
7566
+ console.log(chalk36.dim(`diafunc is already at the latest version (${package_default.version}).`));
7031
7567
  return;
7032
7568
  }
7033
- console.log(chalk34.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
7569
+ console.log(chalk36.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
7034
7570
  if (install.method === "npm") {
7035
7571
  console.log();
7036
7572
  console.log("Installed via npm. Upgrade with:");
7037
- console.log(chalk34.bold(` npm install -g @diafunc/cli@${latest}`));
7573
+ console.log(chalk36.bold(` npm install -g @diafunc/cli@${latest}`));
7038
7574
  return;
7039
7575
  }
7040
7576
  const installDir = path9.dirname(install.binaryPath);
@@ -7048,7 +7584,7 @@ function registerUpdateCommand(program) {
7048
7584
  }
7049
7585
 
7050
7586
  // src/commands/uninstall/index.ts
7051
- import chalk35 from "chalk";
7587
+ import chalk37 from "chalk";
7052
7588
  import { spawn as spawn5 } from "child_process";
7053
7589
  import * as fs13 from "fs";
7054
7590
  import * as os4 from "os";
@@ -7060,11 +7596,11 @@ function registerUninstallCommand(program) {
7060
7596
  const configDir = path10.join(os4.homedir(), ".diafunc");
7061
7597
  if (install.method === "npm") {
7062
7598
  console.log("Installed via npm. Remove with:");
7063
- console.log(chalk35.bold(" npm uninstall -g @diafunc/cli"));
7599
+ console.log(chalk37.bold(" npm uninstall -g @diafunc/cli"));
7064
7600
  if (fs13.existsSync(configDir)) {
7065
7601
  console.log();
7066
7602
  console.log(`Config + credentials live at ${configDir} \u2014 remove manually with:`);
7067
- console.log(chalk35.bold(` rm -rf ${configDir}`));
7603
+ console.log(chalk37.bold(` rm -rf ${configDir}`));
7068
7604
  }
7069
7605
  return;
7070
7606
  }
@@ -7074,7 +7610,7 @@ function registerUninstallCommand(program) {
7074
7610
  default: false
7075
7611
  });
7076
7612
  if (!removeBinary) {
7077
- console.log(chalk35.dim("Aborted."));
7613
+ console.log(chalk37.dim("Aborted."));
7078
7614
  return;
7079
7615
  }
7080
7616
  let removeConfig = options.purge ?? false;
@@ -7086,7 +7622,7 @@ function registerUninstallCommand(program) {
7086
7622
  }
7087
7623
  if (removeConfig && fs13.existsSync(configDir)) {
7088
7624
  fs13.rmSync(configDir, { recursive: true, force: true });
7089
- console.log(chalk35.dim(`Removed ${configDir}`));
7625
+ console.log(chalk37.dim(`Removed ${configDir}`));
7090
7626
  }
7091
7627
  if (process.platform === "win32") {
7092
7628
  const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
@@ -7096,13 +7632,13 @@ function registerUninstallCommand(program) {
7096
7632
  windowsHide: true
7097
7633
  });
7098
7634
  child.unref();
7099
- console.log(chalk35.dim(`Removing ${install.binaryPath} on exit...`));
7635
+ console.log(chalk37.dim(`Removing ${install.binaryPath} on exit...`));
7100
7636
  console.log();
7101
7637
  console.log("diafunc uninstalled.");
7102
7638
  return;
7103
7639
  }
7104
7640
  fs13.rmSync(install.binaryPath, { force: true });
7105
- console.log(chalk35.dim(`Removed ${install.binaryPath}`));
7641
+ console.log(chalk37.dim(`Removed ${install.binaryPath}`));
7106
7642
  console.log();
7107
7643
  console.log("diafunc uninstalled.");
7108
7644
  } catch (error) {
@@ -7123,6 +7659,7 @@ function createProgram() {
7123
7659
  registerAuthCommands(program);
7124
7660
  registerConfigCommands(program);
7125
7661
  registerProjectCommands(program);
7662
+ registerTeamCommands(program);
7126
7663
  registerEntityCommands(program);
7127
7664
  registerLinkCommands(program);
7128
7665
  registerEventCommands(program);
@@ -7134,7 +7671,6 @@ function createProgram() {
7134
7671
  registerScheduleCommands(program);
7135
7672
  registerChatCommands(program);
7136
7673
  registerSearchCommands(program);
7137
- registerGroupCommands(program);
7138
7674
  registerAdminCommands(program);
7139
7675
  registerStatusCommands(program);
7140
7676
  registerAnalyzeCommand(program);
@@ -7156,4 +7692,4 @@ function createProgram() {
7156
7692
  export {
7157
7693
  createProgram
7158
7694
  };
7159
- //# sourceMappingURL=chunk-E4O67FMQ.js.map
7695
+ //# sourceMappingURL=chunk-LTQLKVDU.js.map