@nodaro/cli 1.11.0 → 1.12.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.
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var require_package = __commonJS({
29
29
  "package.json"(exports$1, module) {
30
30
  module.exports = {
31
31
  name: "@nodaro/cli",
32
- version: "1.11.0",
32
+ version: "1.12.0",
33
33
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
34
34
  type: "module",
35
35
  license: "Apache-2.0",
@@ -70,11 +70,11 @@ var require_package = __commonJS({
70
70
  "@inquirer/confirm": "^6.0.12",
71
71
  "@inquirer/input": "^5.0.12",
72
72
  "@inquirer/select": "^5.1.4",
73
- "@nodaro/sdk": "^1.19.0",
74
- "@nodaro/shared": "^2.10.0",
73
+ "@nodaro/sdk": "^1.20.0",
74
+ "@nodaro/shared": "^2.11.0",
75
75
  commander: "^12.1.0",
76
76
  picocolors: "^1.1.1",
77
- "@nodaro/prompts": "^1.7.3"
77
+ "@nodaro/prompts": "^1.8.0"
78
78
  },
79
79
  devDependencies: {
80
80
  tsup: "^8.5.0",
@@ -398,7 +398,7 @@ function saveWorkspace(profileName, workspaceId) {
398
398
  }
399
399
 
400
400
  // src/client.ts
401
- var CLI_VERSION = "1.11.0" ;
401
+ var CLI_VERSION = "1.12.0" ;
402
402
  function buildClient(profileName) {
403
403
  const { name, profile } = getProfile(profileName);
404
404
  if (!profile) {
@@ -744,6 +744,110 @@ function workflowsCommand() {
744
744
  handleError(err);
745
745
  }
746
746
  });
747
+ cmd.command("share <id>").description("set a workflow's visibility: workspace (everyone in its workspace) or private (creator + named collaborators)").option("--visibility <level>", "workspace | private", "workspace").option("--profile <name>").option("--json").action(async (id, opts) => {
748
+ try {
749
+ if (opts.visibility !== "workspace" && opts.visibility !== "private") {
750
+ throw new Error("--visibility must be `workspace` or `private`");
751
+ }
752
+ const client = buildClient(opts.profile);
753
+ const result = await client.workflows.setVisibility(id, opts.visibility);
754
+ if (opts.json) emit(result.data, opts);
755
+ else success(`workflow ${id} is now ${opts.visibility}`);
756
+ } catch (err) {
757
+ handleError(err);
758
+ }
759
+ });
760
+ cmd.command("move <id>").description("move a workflow to another project").requiredOption("--project <projectId>", "destination project id").option("--profile <name>").option("--json").action(async (id, opts) => {
761
+ try {
762
+ const client = buildClient(opts.profile);
763
+ const result = await client.workflows.move(id, { projectId: opts.project });
764
+ if (opts.json) {
765
+ emit(result, opts);
766
+ return;
767
+ }
768
+ success(`moved workflow ${id} \u2192 project ${opts.project}`);
769
+ if (result.droppedCollaborators.length > 0) {
770
+ dim(
771
+ `${result.droppedCollaborators.length} collaborator grant(s) were dropped \u2014 they came from the workspace this workflow just left`
772
+ );
773
+ }
774
+ } catch (err) {
775
+ handleError(err);
776
+ }
777
+ });
778
+ cmd.command("shared-with-me").description("list workflows other people shared with you").option("--profile <name>").option("--json").action(async (opts) => {
779
+ try {
780
+ const client = buildClient(opts.profile);
781
+ const result = await client.workflows.sharedWithMe();
782
+ if (opts.json) {
783
+ emit(result.data, opts);
784
+ return;
785
+ }
786
+ table(
787
+ result.data.map((w) => ({ id: w.id, name: w.name, role: w.grantedRole, updatedAt: w.updatedAt })),
788
+ ["id", "name", "role", "updatedAt"]
789
+ );
790
+ } catch (err) {
791
+ handleError(err);
792
+ }
793
+ });
794
+ cmd.addCommand(collaboratorsCommand());
795
+ return cmd;
796
+ }
797
+ function collaboratorsCommand() {
798
+ const cmd = new Command("collaborators").description("manage who a workflow is shared with");
799
+ cmd.command("list <id>").description("list a workflow's collaborators").option("--profile <name>").option("--json").action(async (id, opts) => {
800
+ try {
801
+ const client = buildClient(opts.profile);
802
+ const result = await client.workflows.collaborators.list(id);
803
+ if (opts.json) emit(result.data, opts);
804
+ else table(result.data.map((c) => ({ userId: c.userId, name: c.name ?? "", role: c.role })), ["userId", "name", "role"]);
805
+ } catch (err) {
806
+ handleError(err);
807
+ }
808
+ });
809
+ cmd.command("add <id>").description("share a workflow with a person by user id or email").option("--user <userId>", "the collaborator's user id").option("--email <email>", "the collaborator's email (any address; they need not have an account yet)").requiredOption("--role <role>", "viewer | editor").option("--profile <name>").option("--json").action(async (id, opts) => {
810
+ try {
811
+ if (opts.user === void 0 === (opts.email === void 0)) {
812
+ throw new Error("provide exactly one of --user or --email");
813
+ }
814
+ if (opts.role !== "viewer" && opts.role !== "editor") {
815
+ throw new Error("--role must be `viewer` or `editor`");
816
+ }
817
+ const client = buildClient(opts.profile);
818
+ const result = await client.workflows.collaborators.add(id, {
819
+ ...opts.user ? { userId: opts.user } : { email: opts.email },
820
+ role: opts.role
821
+ });
822
+ if (opts.json) emit(result.data, opts);
823
+ else success(`shared workflow ${id} with ${opts.user ?? opts.email} as ${opts.role}`);
824
+ } catch (err) {
825
+ handleError(err);
826
+ }
827
+ });
828
+ cmd.command("update <id> <userId>").description("change a collaborator's role").requiredOption("--role <role>", "viewer | editor").option("--profile <name>").option("--json").action(async (id, userId, opts) => {
829
+ try {
830
+ if (opts.role !== "viewer" && opts.role !== "editor") {
831
+ throw new Error("--role must be `viewer` or `editor`");
832
+ }
833
+ const client = buildClient(opts.profile);
834
+ const result = await client.workflows.collaborators.update(id, userId, { role: opts.role });
835
+ if (opts.json) emit(result.data, opts);
836
+ else success(`${userId} is now ${opts.role} on workflow ${id}`);
837
+ } catch (err) {
838
+ handleError(err);
839
+ }
840
+ });
841
+ cmd.command("remove <id> <userId>").description("remove a collaborator (or yourself)").option("--profile <name>").option("--json").action(async (id, userId, opts) => {
842
+ try {
843
+ const client = buildClient(opts.profile);
844
+ await client.workflows.collaborators.remove(id, userId);
845
+ if (opts.json) emit({ workflowId: id, userId, removed: true }, opts);
846
+ else success(`removed ${userId} from workflow ${id}`);
847
+ } catch (err) {
848
+ handleError(err);
849
+ }
850
+ });
747
851
  return cmd;
748
852
  }
749
853
  async function watchExecution(client, executionId, opts) {
@@ -865,10 +969,10 @@ function parseParamPairs(pairs) {
865
969
  if (eq < 0) {
866
970
  throw new Error(`invalid param "${raw}": expected key=value`);
867
971
  }
868
- const key = raw.slice(0, eq).trim();
972
+ const key2 = raw.slice(0, eq).trim();
869
973
  const value = raw.slice(eq + 1);
870
- if (!key) throw new Error(`invalid param "${raw}": empty key`);
871
- out[key] = coerce(value);
974
+ if (!key2) throw new Error(`invalid param "${raw}": empty key`);
975
+ out[key2] = coerce(value);
872
976
  }
873
977
  return out;
874
978
  }
@@ -2865,7 +2969,7 @@ Examples:
2865
2969
  }
2866
2970
  }
2867
2971
  );
2868
- cmd.command("get <nodeType>").description("show one picker's catalog of valid values").option("--full", "include description + the prompt fragment each id injects").option("--category <name>", "single-dim pickers: filter to one category").option("--field <name>", "multi-dim pickers (person/styling/framing): only this dimension").option("--profile <name>").option("--json").addHelpText(
2972
+ cmd.command("get <nodeType>").description("show one picker's catalog of valid values").option("--full", "add description + the prompt fragment each id injects (compact already carries each id's `term`)").option("--category <name>", "single-dim pickers: filter to one category").option("--field <name>", "multi-dim pickers (person/styling/framing): only this dimension").option("--profile <name>").option("--json").addHelpText(
2869
2973
  "after",
2870
2974
  `
2871
2975
  Examples:
@@ -2891,6 +2995,105 @@ Examples:
2891
2995
  );
2892
2996
  return cmd;
2893
2997
  }
2998
+
2999
+ // src/lib/catalog-snapshot.ts
3000
+ function buildCatalogSnapshot(projected, sidecars) {
3001
+ const seen = /* @__PURE__ */ new Map();
3002
+ const push = (opts) => {
3003
+ for (const o of opts ?? []) if (!seen.has(o.id)) seen.set(o.id, o);
3004
+ };
3005
+ if (projected.kind === "single") push(projected.options);
3006
+ else for (const d of projected.dimensions ?? []) push(d.options);
3007
+ const entries = [...seen.values()].sort((a, b) => a.id.localeCompare(b.id));
3008
+ return { catalogId: projected.catalogId, kind: projected.kind, entries, sidecars };
3009
+ }
3010
+
3011
+ // src/lib/catalog-diff.ts
3012
+ var key = (e) => JSON.stringify({ l: e.label, d: e.description, c: e.category, p: e.promptHint, t: e.term });
3013
+ var index = (s) => new Map(s.entries.map((e) => [e.id, e]));
3014
+ function threeWayMergeCatalog(baseline, upstreamNow, pack) {
3015
+ const B = index(baseline), U = index(upstreamNow), P = index(pack);
3016
+ const carried = [];
3017
+ const conflicts = [];
3018
+ const newUpstream = [];
3019
+ const removedUpstream = [];
3020
+ const sidecarsCarried = {};
3021
+ for (const [id, u] of U) {
3022
+ const b = B.get(id), p = P.get(id);
3023
+ if (!b) {
3024
+ newUpstream.push(u);
3025
+ continue;
3026
+ }
3027
+ if (!p) continue;
3028
+ const saiModified = key(p) !== key(b);
3029
+ const upstreamChanged = key(u) !== key(b);
3030
+ if (!upstreamChanged) continue;
3031
+ if (saiModified) {
3032
+ conflicts.push({ id, upstream: u, pack: p });
3033
+ continue;
3034
+ }
3035
+ carried.push(u);
3036
+ for (const [locale, map] of Object.entries(upstreamNow.sidecars)) {
3037
+ if (map[id]) (sidecarsCarried[locale] ??= []).push(id);
3038
+ }
3039
+ }
3040
+ for (const [id] of B) if (!U.has(id) && P.has(id)) removedUpstream.push(id);
3041
+ return { carried, conflicts, newUpstream, removedUpstream, sidecarsCarried, nextBaseline: upstreamNow };
3042
+ }
3043
+
3044
+ // src/lib/catalog-validate.ts
3045
+ function validatePackSidecars(snapshot, locales, exemptLocales) {
3046
+ const exempt = new Set(exemptLocales);
3047
+ const missing = [];
3048
+ const exempted = [];
3049
+ for (const locale of locales) {
3050
+ if (exempt.has(locale)) {
3051
+ exempted.push(locale);
3052
+ continue;
3053
+ }
3054
+ const map = snapshot.sidecars[locale] ?? {};
3055
+ for (const e of snapshot.entries) if (!map[e.id]) missing.push({ id: e.id, locale });
3056
+ }
3057
+ return { catalogId: snapshot.catalogId, missing, exempted, ok: missing.length === 0 };
3058
+ }
3059
+
3060
+ // src/commands/catalog.ts
3061
+ var LOCALES = ["es", "fr", "de", "pt-BR", "ru", "hi", "ja", "ko", "zh-CN", "he", "ar"];
3062
+ var read = (p) => JSON.parse(readFileSync(p, "utf8"));
3063
+ function catalogCommand() {
3064
+ const cmd = new Command("catalog").description(
3065
+ "vendored-pack maintenance: snapshot, diff against upstream, validate sidecars (offline, file-based)"
3066
+ );
3067
+ cmd.command("snapshot").description(
3068
+ "build a catalog snapshot (the diff-upstream/validate input shape) from a detail=full /v1/catalogs projection + its sidecars"
3069
+ ).requiredOption(
3070
+ "--in <file>",
3071
+ 'JSON { "projected": <detail=full /v1/catalogs catalog>, "sidecars"?: <locale -> id -> {label?,description?}> }'
3072
+ ).action((o) => {
3073
+ const input2 = JSON.parse(readFileSync(o.in, "utf8"));
3074
+ const snapshot = buildCatalogSnapshot(input2.projected, input2.sidecars ?? {});
3075
+ process.stdout.write(JSON.stringify(snapshot, null, 2) + "\n");
3076
+ });
3077
+ cmd.command("diff-upstream").description(
3078
+ "three-way merge: carry upstream edits for entries you left unmodified; never auto-admit new upstream entries"
3079
+ ).requiredOption("--baseline <file>", "upstream snapshot at vendoring time").requiredOption("--upstream <file>", "current upstream snapshot").requiredOption("--pack <file>", "your vendored pack snapshot").option("--write <file>", "write the merge plan + next baseline to this path").action((o) => {
3080
+ const plan = threeWayMergeCatalog(read(o.baseline), read(o.upstream), read(o.pack));
3081
+ const out = JSON.stringify(plan, null, 2);
3082
+ if (o.write) writeFileSync(o.write, out);
3083
+ else process.stdout.write(out + "\n");
3084
+ if (plan.conflicts.length) process.exitCode = 2;
3085
+ });
3086
+ cmd.command("validate").description("check a pack snapshot has sidecar coverage across 11 locales (or declared exemptions)").requiredOption("--pack <file>", "your vendored pack snapshot").option("--exempt <locales>", "comma-separated locales exempted from translation", "").action((o) => {
3087
+ const r = validatePackSidecars(
3088
+ read(o.pack),
3089
+ LOCALES,
3090
+ o.exempt.split(",").map((s) => s.trim()).filter(Boolean)
3091
+ );
3092
+ process.stdout.write(JSON.stringify(r, null, 2) + "\n");
3093
+ if (!r.ok) process.exitCode = 1;
3094
+ });
3095
+ return cmd;
3096
+ }
2894
3097
  function modelsCommand() {
2895
3098
  const cmd = new Command("models").description(
2896
3099
  "browse the model catalog \u2014 capability sheets, per-variant credit pricing, prompt tips"
@@ -4154,6 +4357,7 @@ program.addCommand(audioCommand());
4154
4357
  program.addCommand(presetsCommand());
4155
4358
  program.addCommand(communityCommand());
4156
4359
  program.addCommand(pickerCatalogsCommand());
4360
+ program.addCommand(catalogCommand());
4157
4361
  program.addCommand(modelsCommand());
4158
4362
  program.addCommand(shotsCommand());
4159
4363
  program.addCommand(recastCommand());