@getmonoceros/workbench 1.9.0 → 1.9.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.
package/dist/bin.js CHANGED
@@ -4428,7 +4428,7 @@ async function persistPromptedIdentity(prompted, ymlPath, home, logger) {
4428
4428
  }
4429
4429
 
4430
4430
  // src/version.ts
4431
- var CLI_VERSION = true ? "1.9.0" : "dev";
4431
+ var CLI_VERSION = true ? "1.9.1" : "dev";
4432
4432
 
4433
4433
  // src/commands/_dispatch.ts
4434
4434
  import { consola as consola12 } from "consola";
@@ -4709,7 +4709,6 @@ function isShellWhitespace(ch) {
4709
4709
  function dispatchCommand(spec, argTokens, ctx) {
4710
4710
  const dashDashIdx = argTokens.indexOf("--");
4711
4711
  const preDash = dashDashIdx < 0 ? argTokens : argTokens.slice(0, dashDashIdx);
4712
- const postDash = dashDashIdx < 0 ? [] : argTokens.slice(dashDashIdx + 1);
4713
4712
  const inPostDash = dashDashIdx >= 0;
4714
4713
  if (inPostDash && spec.innerArgs) {
4715
4714
  return resolveValues(spec.innerArgs, ctx, ctx.current);
@@ -4728,14 +4727,7 @@ async function resolvePreDash(spec, preDash, ctx) {
4728
4727
  return completions.map((v) => `${flagName}=${v}`);
4729
4728
  }
4730
4729
  if (current.startsWith("-")) {
4731
- const flags = spec.flags ?? {};
4732
- const names = Object.keys(flags);
4733
- const all = [];
4734
- for (const n of names) {
4735
- all.push(n);
4736
- for (const a of flags[n].aliases ?? []) all.push(a);
4737
- }
4738
- return filterPrefix(all, current);
4730
+ return listFlagNames(spec.flags ?? {}, current);
4739
4731
  }
4740
4732
  const lastPrev = preDash[preDash.length - 1];
4741
4733
  if (lastPrev && lastPrev.startsWith("--") && !lastPrev.includes("=")) {
@@ -4745,12 +4737,25 @@ async function resolvePreDash(spec, preDash, ctx) {
4745
4737
  }
4746
4738
  }
4747
4739
  const positionalIdx = countCompletedPositionals(preDash, spec.flags ?? {});
4748
- const positional = spec.positionals?.[positionalIdx];
4749
- if (positional) {
4750
- return resolveValues(positional, ctx, current);
4740
+ const positionals = spec.positionals ?? [];
4741
+ const expectedPositionalCount = spec.positionalCount ?? positionals.length;
4742
+ if (positionalIdx < positionals.length) {
4743
+ const positional = positionals[positionalIdx];
4744
+ if (positional) return resolveValues(positional, ctx, current);
4745
+ }
4746
+ if (positionalIdx >= expectedPositionalCount) {
4747
+ return listFlagNames(spec.flags ?? {}, current);
4751
4748
  }
4752
4749
  return [];
4753
4750
  }
4751
+ function listFlagNames(flags, fragment) {
4752
+ const names = [];
4753
+ for (const [name, spec] of Object.entries(flags)) {
4754
+ names.push(name);
4755
+ for (const alias of spec.aliases ?? []) names.push(alias);
4756
+ }
4757
+ return filterPrefix(names, fragment);
4758
+ }
4754
4759
  function countCompletedPositionals(preDash, flags) {
4755
4760
  let count = 0;
4756
4761
  for (let i = 0; i < preDash.length; i++) {
@@ -4892,8 +4897,11 @@ var ALL_COMMANDS = [
4892
4897
  var containerName = (ctx) => listContainerNames(ctx);
4893
4898
  var COMMAND_SPECS = {
4894
4899
  init: {
4895
- // First positional is a FRESH name → no suggestions from existing
4896
- // container-configs (would invite collisions).
4900
+ // First positional is a FRESH name → no suggestion source, but
4901
+ // the slot exists. Once the cursor is past it (after the name +
4902
+ // space), `--with` / `--with-repo` / `--with-ports` surface as
4903
+ // flag suggestions.
4904
+ positionalCount: 1,
4897
4905
  flags: {
4898
4906
  "--with": { type: "value", values: () => listAllCatalogComponents() },
4899
4907
  "--with-repo": { type: "value" },
@@ -4984,7 +4992,9 @@ var COMMAND_SPECS = {
4984
4992
  "list-components": {},
4985
4993
  restore: {
4986
4994
  // First positional is a backup-path; no value suggestions today
4987
- // (could plug filesystem completion later).
4995
+ // (could plug filesystem completion later). Slot still exists so
4996
+ // Tab is silent inside it rather than offering flags prematurely.
4997
+ positionalCount: 1
4988
4998
  }
4989
4999
  };
4990
5000
  var COMPLETION_COMMAND_SPEC_KEYS = Object.keys(COMMAND_SPECS);