@flowrunner/cli 0.1.6 → 0.1.7-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/ai-docs/instructions/service-code-format/01-service-structure.md +1 -1
  2. package/ai-docs/instructions/service-code-format/11-output-model.md +2 -1
  3. package/dist/cli.js +63 -10
  4. package/dist/cli.js.map +2 -2
  5. package/dist/index.js +56 -7
  6. package/dist/index.js.map +2 -2
  7. package/dist/types/flow-extension-runner/src/v2/model/model-types.d.ts +1 -0
  8. package/dist/types/flow-extension-runner/src/v2/types.d.ts +1 -1
  9. package/dist/types/packages/cli/src/operations/init/answers.d.ts +12 -1
  10. package/dist/types/packages/cli/src/templates/index.d.ts +2 -2
  11. package/dist/types/packages/cli/src/templates/manifest.d.ts +20 -2
  12. package/dist/types/packages/cli/src/templates/render.d.ts +2 -0
  13. package/dist/types/shared/src/scheme/flowrunner/custom-elements.d.ts +4 -0
  14. package/dist/types/shared/src/scheme/shared-extensions/base.d.ts +1 -0
  15. package/dist/types/shared/src/scheme/shared-extensions/custom-extensions.d.ts +5 -0
  16. package/dist/types/shared/src/scheme/shared-extensions/extension.d.ts +4 -0
  17. package/dist/types/shared/src/scheme/shared-extensions/resolve.d.ts +3 -0
  18. package/dist/types/shared/src/scheme/shared-extensions/search.d.ts +2 -0
  19. package/dist/types/shared/src/scheme/shared-extensions/service-info.d.ts +1 -0
  20. package/package.json +1 -1
  21. package/runtime/index.js +1 -0
  22. package/runtime/index.js.map +2 -2
  23. package/runtime/types/flow-extension-runner/src/v2/model/model-types.d.ts +1 -0
  24. package/runtime/types/flow-extension-runner/src/v2/types.d.ts +1 -1
  25. package/runtime/types/shared/src/scheme/flowrunner/custom-elements.d.ts +4 -0
  26. package/runtime/types/shared/src/scheme/shared-extensions/base.d.ts +1 -0
  27. package/runtime/types/shared/src/scheme/shared-extensions/custom-extensions.d.ts +5 -0
  28. package/runtime/types/shared/src/scheme/shared-extensions/extension.d.ts +4 -0
  29. package/runtime/types/shared/src/scheme/shared-extensions/resolve.d.ts +3 -0
  30. package/runtime/types/shared/src/scheme/shared-extensions/search.d.ts +2 -0
  31. package/runtime/types/shared/src/scheme/shared-extensions/service-info.d.ts +1 -0
  32. package/templates/blank/template.json +9 -9
  33. package/templates/demo-todo-list/template.json +9 -9
  34. package/templates/qa-test/template.json +9 -9
package/dist/index.js CHANGED
@@ -7977,6 +7977,7 @@ var Extension = class {
7977
7977
  serviceClassName: this.props.id,
7978
7978
  integrationName: this.props.name,
7979
7979
  integrationIcon: this.props.logo ?? null,
7980
+ description: this.props.description || null,
7980
7981
  integrationTriggersScope: this.#realtime?.scope ?? null,
7981
7982
  requireOAuth: this.#oauth ? true : void 0
7982
7983
  };
@@ -9086,6 +9087,16 @@ function serviceDirectory(serviceId, projectRoot = process.cwd()) {
9086
9087
 
9087
9088
  // src/templates/manifest.ts
9088
9089
  var SERVICE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
9090
+ function toServiceId(value) {
9091
+ return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "");
9092
+ }
9093
+ function availableServiceId(id, projectRoot) {
9094
+ let candidate = id;
9095
+ for (let suffix = 2; import_fs9.default.existsSync(serviceDirectory(candidate, projectRoot)); suffix++) {
9096
+ candidate = `${id}-${suffix}`;
9097
+ }
9098
+ return candidate;
9099
+ }
9089
9100
  var VALIDATORS = {
9090
9101
  // Both halves of "is this a usable id" live together, so the prompt can re-ask on either. Availability is
9091
9102
  // checked here rather than at write time so the user finds out while they are still on that question.
@@ -9100,15 +9111,20 @@ var VALIDATORS = {
9100
9111
  },
9101
9112
  nonEmpty: (value) => value.trim().length > 0 ? null : "must not be empty"
9102
9113
  };
9114
+ var NORMALIZERS = {
9115
+ serviceId: toServiceId
9116
+ };
9103
9117
  var VALIDATOR_NAMES = Object.keys(VALIDATORS);
9104
9118
  var StringPromptSchema = import_zod5.z.object({
9105
9119
  name: import_zod5.z.string().min(1),
9106
9120
  label: import_zod5.z.string().min(1),
9107
9121
  type: import_zod5.z.literal("string"),
9108
9122
  hint: import_zod5.z.string().optional(),
9109
- // May interpolate a value fixed by `values`, or an answer collected *earlier* in the list:
9110
- // "{{id}}", "{{id|titleCase}}".
9111
- default: import_zod5.z.string().default(""),
9123
+ // May interpolate a value fixed by `values`, a value supplied up front (flag or `--set`), or an answer
9124
+ // collected *earlier* in the list: "{{id}}", "{{name|serviceId}}". A list is a chain of candidates: the
9125
+ // first whose placeholders all resolve to something non-empty wins — `["{{id|titleCase}}", "My Service"]`
9126
+ // follows an `--id` flag when there is one and falls back to the literal when there is not.
9127
+ default: import_zod5.z.union([import_zod5.z.string(), import_zod5.z.array(import_zod5.z.string()).min(1)]).default(""),
9112
9128
  validate: import_zod5.z.enum(VALIDATOR_NAMES).optional()
9113
9129
  });
9114
9130
  var BooleanPromptSchema = import_zod5.z.object({
@@ -9235,7 +9251,8 @@ var IF_CLOSE = /^\s*(?:\/\/|#|<!--)\s*\{\{\/if\s*\}\}/;
9235
9251
  var FILTERS = {
9236
9252
  titleCase: (value) => value.split(/[-_\s]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" "),
9237
9253
  upperCase: (value) => value.toUpperCase(),
9238
- lowerCase: (value) => value.toLowerCase()
9254
+ lowerCase: (value) => value.toLowerCase(),
9255
+ serviceId: toServiceId
9239
9256
  };
9240
9257
  function applyFilter(name, value) {
9241
9258
  const filter = FILTERS[name];
@@ -9244,6 +9261,9 @@ function applyFilter(name, value) {
9244
9261
  }
9245
9262
  return filter(value);
9246
9263
  }
9264
+ function canInterpolate(source, answers) {
9265
+ return [...source.matchAll(PLACEHOLDER)].every(([, name]) => name in answers);
9266
+ }
9247
9267
  function interpolate(source, answers, origin) {
9248
9268
  return source.replace(PLACEHOLDER, (_match, name, filter) => {
9249
9269
  if (!(name in answers)) {
@@ -9336,7 +9356,15 @@ function resolveDefault(prompt, answers) {
9336
9356
  if (prompt.type === "boolean" || prompt.type === "choice") {
9337
9357
  return prompt.default;
9338
9358
  }
9339
- return interpolate(prompt.default, answers, `default of "${prompt.name}"`);
9359
+ const origin = `default of "${prompt.name}"`;
9360
+ const candidates = Array.isArray(prompt.default) ? prompt.default : [prompt.default];
9361
+ for (const candidate of candidates) {
9362
+ const value = canInterpolate(candidate, answers) ? interpolate(candidate, answers, origin) : "";
9363
+ if (value) {
9364
+ return value;
9365
+ }
9366
+ }
9367
+ return interpolate(candidates[candidates.length - 1], answers, origin);
9340
9368
  }
9341
9369
  function coerceBoolean(label, value) {
9342
9370
  if (typeof value === "boolean") {
@@ -9360,6 +9388,16 @@ function validator(prompt, context) {
9360
9388
  return failure && `${prompt.label} ${failure}`;
9361
9389
  };
9362
9390
  }
9391
+ function normalizer(prompt) {
9392
+ const normalize = prompt.type === "string" && prompt.validate ? NORMALIZERS[prompt.validate] : void 0;
9393
+ return normalize ?? ((value) => value);
9394
+ }
9395
+ function offeredDefault(prompt, fallback, context) {
9396
+ if (prompt.type === "string" && prompt.validate === "serviceId" && typeof fallback === "string" && fallback) {
9397
+ return availableServiceId(fallback, context.projectRoot);
9398
+ }
9399
+ return fallback;
9400
+ }
9363
9401
  async function resolveAnswers(prompts, {
9364
9402
  prefilled = {},
9365
9403
  constants = {},
@@ -9369,6 +9407,7 @@ async function resolveAnswers(prompts, {
9369
9407
  } = {}) {
9370
9408
  const context = { projectRoot };
9371
9409
  const answers = { ...constants };
9410
+ const prefilledDefaults = {};
9372
9411
  const known = [...prompts.map((prompt) => prompt.name), ...Object.keys(constants)];
9373
9412
  const unknown = Object.keys(prefilled).filter((name) => !known.includes(name));
9374
9413
  if (unknown.length > 0) {
@@ -9377,7 +9416,12 @@ async function resolveAnswers(prompts, {
9377
9416
  );
9378
9417
  }
9379
9418
  for (const prompt of prompts) {
9380
- const fallback = resolveDefault(prompt, answers);
9419
+ if (prompt.name in prefilled && prompt.type === "string") {
9420
+ prefilledDefaults[prompt.name] = String(prefilled[prompt.name]);
9421
+ }
9422
+ }
9423
+ for (const prompt of prompts) {
9424
+ const fallback = resolveDefault(prompt, { ...prefilledDefaults, ...answers });
9381
9425
  const validate2 = validator(prompt, context);
9382
9426
  if (prompt.name in prefilled) {
9383
9427
  const supplied = prefilled[prompt.name];
@@ -9414,7 +9458,12 @@ async function resolveAnswers(prompts, {
9414
9458
  `"${prompt.name}" has no answer and there is no way to ask for one. Supply it up front, or accept the defaults.`
9415
9459
  );
9416
9460
  }
9417
- answers[prompt.name] = await ask({ prompt, fallback, validate: validate2 });
9461
+ answers[prompt.name] = await ask({
9462
+ prompt,
9463
+ fallback: offeredDefault(prompt, fallback, context),
9464
+ validate: validate2,
9465
+ normalize: normalizer(prompt)
9466
+ });
9418
9467
  }
9419
9468
  for (const [name, value] of Object.entries(prefilled)) {
9420
9469
  if (prompts.some((prompt) => prompt.name === name)) {