@mesh-tech/mesh-cli 0.18.2 → 0.20.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.
Files changed (72) hide show
  1. package/README.md +111 -56
  2. package/dist/bin/mesh.js +5158 -4302
  3. package/dist/bin/mesh.js.map +4 -4
  4. package/dist/build-info.json +2 -2
  5. package/dist/src/commands/create-app.d.ts +28 -0
  6. package/dist/src/commands/create-app.d.ts.map +1 -1
  7. package/dist/src/commands/create-app.js +45 -1
  8. package/dist/src/commands/create-app.js.map +1 -1
  9. package/dist/src/commands/dev-doctor.js +2 -2
  10. package/dist/src/commands/dev-doctor.js.map +1 -1
  11. package/dist/src/commands/dev.d.ts +7 -0
  12. package/dist/src/commands/dev.d.ts.map +1 -1
  13. package/dist/src/commands/dev.js +1 -0
  14. package/dist/src/commands/dev.js.map +1 -1
  15. package/dist/src/commands/hub/index.d.ts.map +1 -1
  16. package/dist/src/commands/hub/index.js +5 -0
  17. package/dist/src/commands/hub/index.js.map +1 -1
  18. package/dist/src/commands/init/wizard.d.ts +216 -0
  19. package/dist/src/commands/init/wizard.d.ts.map +1 -0
  20. package/dist/src/commands/init/wizard.js +471 -0
  21. package/dist/src/commands/init/wizard.js.map +1 -0
  22. package/dist/src/commands/init.d.ts +14 -6
  23. package/dist/src/commands/init.d.ts.map +1 -1
  24. package/dist/src/commands/init.js +41 -15
  25. package/dist/src/commands/init.js.map +1 -1
  26. package/dist/src/commands/local/auth-provision.d.ts +4 -0
  27. package/dist/src/commands/local/auth-provision.d.ts.map +1 -1
  28. package/dist/src/commands/local/auth-provision.js +20 -0
  29. package/dist/src/commands/local/auth-provision.js.map +1 -1
  30. package/dist/src/commands/local/dev-local.d.ts +32 -0
  31. package/dist/src/commands/local/dev-local.d.ts.map +1 -1
  32. package/dist/src/commands/local/dev-local.js +88 -2
  33. package/dist/src/commands/local/dev-local.js.map +1 -1
  34. package/dist/src/commands/local/seed.d.ts +9 -0
  35. package/dist/src/commands/local/seed.d.ts.map +1 -1
  36. package/dist/src/commands/local/seed.js +49 -10
  37. package/dist/src/commands/local/seed.js.map +1 -1
  38. package/dist/src/commands/login.d.ts +76 -5
  39. package/dist/src/commands/login.d.ts.map +1 -1
  40. package/dist/src/commands/login.js +161 -60
  41. package/dist/src/commands/login.js.map +1 -1
  42. package/dist/src/commands/registry.d.ts +133 -10
  43. package/dist/src/commands/registry.d.ts.map +1 -1
  44. package/dist/src/commands/registry.js +238 -86
  45. package/dist/src/commands/registry.js.map +1 -1
  46. package/dist/src/commands/temporal.js +54 -24
  47. package/dist/src/commands/temporal.js.map +3 -3
  48. package/dist/src/docs/registry-docs.d.ts.map +1 -1
  49. package/dist/src/docs/registry-docs.js +8 -3
  50. package/dist/src/docs/registry-docs.js.map +1 -1
  51. package/dist/src/program.d.ts.map +1 -1
  52. package/dist/src/program.js +5 -1
  53. package/dist/src/program.js.map +1 -1
  54. package/dist/src/utils/auth-preflight.d.ts +51 -20
  55. package/dist/src/utils/auth-preflight.d.ts.map +1 -1
  56. package/dist/src/utils/auth-preflight.js +48 -21
  57. package/dist/src/utils/auth-preflight.js.map +1 -1
  58. package/dist/src/utils/mesh-json.d.ts +58 -0
  59. package/dist/src/utils/mesh-json.d.ts.map +1 -0
  60. package/dist/src/utils/mesh-json.js +85 -0
  61. package/dist/src/utils/mesh-json.js.map +1 -0
  62. package/dist/src/utils/registry-broker.d.ts +12 -29
  63. package/dist/src/utils/registry-broker.d.ts.map +1 -1
  64. package/dist/src/utils/registry-broker.js +12 -29
  65. package/dist/src/utils/registry-broker.js.map +1 -1
  66. package/dist/src/utils/registry-identity.d.ts +170 -0
  67. package/dist/src/utils/registry-identity.d.ts.map +1 -0
  68. package/dist/src/utils/registry-identity.js +273 -0
  69. package/dist/src/utils/registry-identity.js.map +1 -0
  70. package/package.json +3 -2
  71. package/skills/core/SKILL.md +8 -7
  72. package/templates/apps-repo/gitignore +4 -0
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Bare `mesh init` — the guided setup of a machine and a repo for one tenant.
3
+ *
4
+ * Four questions and four steps, in order:
5
+ *
6
+ * 1. tenant — which tenant this repo belongs to
7
+ * 2. mode — local only (`mesh start` / `mesh dev`) or a deployed platform
8
+ * 3. registry — package-registry access, signing in if the machine has none
9
+ * 4. platform — (deployed only) `mesh login <tenant>.<env>` in-process
10
+ * 5. repo — bootstrap an empty apps repo, or check an existing one
11
+ * 6. skills — the agent skills the repo's packages ship
12
+ *
13
+ * Two identities never mix: the registry step talks to the ONE global package
14
+ * registry and never needs a context; the platform step is the only place a
15
+ * `<tenant>.<env>` context appears, and the local branch never mentions it.
16
+ *
17
+ * Every step is data (`WizardStep` → `StepResult`) so the summary, the exit
18
+ * code and the `--json` document are one reducer over one list, and a step
19
+ * that fails without blocking (a registry 403 — the user needs the summary to
20
+ * know whom to ask) lets the rest run. Every prompt has a flag, so a runner
21
+ * with `--tenant … --local --yes` sees no prompt at all.
22
+ */
23
+ import { probeRegistryToken } from "../../utils/auth-preflight.js";
24
+ import { type RegistryLoginOptions } from "../registry.js";
25
+ import { type MeshJson } from "../../utils/mesh-json.js";
26
+ /** The flags — one per wizard answer, so a headless run needs no prompt. */
27
+ export interface WizardOptions {
28
+ tenant?: string;
29
+ /** Local only: `mesh start` / `mesh dev`, no deployed platform. */
30
+ local?: boolean;
31
+ /** A deployed platform's environment (`dev`, `uat`, …) → context `<tenant>.<env>`. */
32
+ platform?: string;
33
+ /** Device-code sign-in for the registry and platform steps (headless / SSH). */
34
+ device?: boolean;
35
+ /** Deployers only: an AWS profile that can read the registry (skips the broker). */
36
+ profile?: string;
37
+ /** Do not touch the repo (no bootstrap, no doctor, no skills). */
38
+ skipRepo?: boolean;
39
+ /** Accept every default and never prompt. */
40
+ yes?: boolean;
41
+ /** One JSON document on stdout; human output on stderr. */
42
+ json?: boolean;
43
+ }
44
+ export type StepStatus = "pass" | "fail" | "warn" | "skip";
45
+ /** One step's verdict — what the summary, the exit code and `--json` all read. */
46
+ export interface StepResult {
47
+ name: string;
48
+ status: StepStatus;
49
+ detail: string;
50
+ /** The exact command (or, for a grant, the person to ask) that fixes it. */
51
+ fix?: string;
52
+ /** `false` = a failure the wizard carries on past (a registry 403). */
53
+ blocking?: boolean;
54
+ }
55
+ /** Where the tenant runs. */
56
+ export type WizardMode = "local" | {
57
+ platform: string;
58
+ };
59
+ /** The wizard's answers, shared by every step. */
60
+ export interface WizardCtx {
61
+ cwd: string;
62
+ tenant: string;
63
+ mode: WizardMode;
64
+ /** The `<tenant>.<env>` context — only in deployed mode. */
65
+ context: string | null;
66
+ device?: boolean;
67
+ profile?: string;
68
+ /** True when a prompt or a browser can be used on this run. */
69
+ interactive: boolean;
70
+ /**
71
+ * True when no browser can open here (SSH, a container, no TTY), so the
72
+ * device code is the sign-in that works and every remediation names it.
73
+ */
74
+ remote: boolean;
75
+ yes: boolean;
76
+ skipRepo: boolean;
77
+ prompts: Prompts;
78
+ /** Test seams for the steps' side effects; production leaves them unset. */
79
+ seams?: WizardSeams;
80
+ }
81
+ /** The impure calls a step makes, injectable so the real steps run under test. */
82
+ export interface WizardSeams {
83
+ /** The `~/.npmrc` token probe — defaults to `probeRegistryToken`. */
84
+ probe?: typeof probeRegistryToken;
85
+ /** The in-process registry login — defaults to `runRegistryLogin(undefined, opts)`. */
86
+ runRegistryLogin?: (opts: RegistryLoginOptions) => Promise<void>;
87
+ }
88
+ /** A step: a name and a runner. */
89
+ export interface WizardStep {
90
+ name: "registry" | "platform" | "repo" | "skills";
91
+ run(ctx: WizardCtx): Promise<StepResult>;
92
+ }
93
+ /** The final document — rendered for a terminal or emitted as `--json`. */
94
+ export interface WizardOutcome {
95
+ tenant: string;
96
+ mode: WizardMode;
97
+ steps: StepResult[];
98
+ next: string[];
99
+ }
100
+ /** The prompt surface, injectable so the flow is testable without a TTY. */
101
+ export interface Prompts {
102
+ input(args: {
103
+ message: string;
104
+ default?: string;
105
+ validate?: (v: string) => true | string;
106
+ }): Promise<string>;
107
+ select<T extends string>(args: {
108
+ message: string;
109
+ choices: Array<{
110
+ name: string;
111
+ value: T;
112
+ }>;
113
+ default?: T;
114
+ }): Promise<T>;
115
+ confirm(args: {
116
+ message: string;
117
+ default?: boolean;
118
+ }): Promise<boolean>;
119
+ }
120
+ /** Printed when the registry step has no session and no way to sign in. */
121
+ export declare const NO_SESSION_NO_TTY_MESSAGE: string;
122
+ /** Printed when a non-TTY run has no `--tenant`. */
123
+ export declare const TENANT_REQUIRED_MESSAGE = "--tenant is required (no TTY for interactive mode)";
124
+ /** Exit code for a Ctrl-C at a prompt: nothing half-written, conventional SIGINT code. */
125
+ export declare const INTERRUPTED_EXIT_CODE = 130;
126
+ /**
127
+ * The exit code for a finished run: 1 when any step failed (blocking or not
128
+ * — a registry 403 still means the machine is not set up), else 0.
129
+ *
130
+ * @example
131
+ * wizardExitCode([{ name: "Registry access", status: "fail", detail: "…", blocking: false }]); // → 1
132
+ */
133
+ export declare function wizardExitCode(steps: ReadonlyArray<Pick<StepResult, "status">>): number;
134
+ /**
135
+ * The commands to run next, by mode.
136
+ *
137
+ * @example
138
+ * wizardNextCommands({ platform: "dev" }); // → ["mesh create-app", "mesh deploy up # from the app directory"]
139
+ */
140
+ export declare function wizardNextCommands(mode: WizardMode): string[];
141
+ /**
142
+ * Whether the wizard should stop after `result`: a failing step that did not
143
+ * opt out of blocking.
144
+ */
145
+ export declare function stepBlocks(result: StepResult): boolean;
146
+ /** The mode as a short phrase for the summary heading. */
147
+ export declare function describeMode(mode: WizardMode): string;
148
+ /**
149
+ * Render the summary check-list — the same lines for a terminal and for the
150
+ * stderr side of `--json`.
151
+ *
152
+ * @example
153
+ * renderWizardSummary({ tenant: "acme", mode: "local", steps: [], next: ["mesh create-app"] });
154
+ */
155
+ export declare function renderWizardSummary(outcome: WizardOutcome, opts?: {
156
+ color?: boolean;
157
+ }): string;
158
+ /**
159
+ * Resolve the answers that need no prompt: flags first, then `--yes`
160
+ * defaults, then what the repo already records. Returns the questions still
161
+ * open so the caller prompts for exactly those.
162
+ *
163
+ * @example
164
+ * resolveAnswers({ tenant: "acme", local: true }, null, false)
165
+ * // → { tenant: "acme", mode: "local", open: [] }
166
+ */
167
+ export declare function resolveAnswers(opts: WizardOptions, recorded: MeshJson | null, interactive: boolean): {
168
+ tenant?: string;
169
+ mode?: WizardMode;
170
+ open: Array<"tenant" | "mode">;
171
+ };
172
+ /** The registry step, exported so a test can drive the real thing through its seams. */
173
+ export declare const registryStep: WizardStep;
174
+ /** What kind of directory the wizard is standing in. */
175
+ export type RepoKind = "platform-monorepo" | "empty-apps-repo" | "apps-repo" | "other-repo" | "no-repo";
176
+ /**
177
+ * Classify `cwd` for the repo step. Pure over the filesystem; exported for
178
+ * tests.
179
+ *
180
+ * @example
181
+ * classifyRepo("/tmp/empty-git-clone"); // → "empty-apps-repo"
182
+ */
183
+ export declare function classifyRepo(cwd: string): {
184
+ kind: RepoKind;
185
+ root: string;
186
+ };
187
+ /** The steps in run order. Exported so tests can drive the reducer with fakes. */
188
+ export declare const WIZARD_STEPS: readonly WizardStep[];
189
+ /**
190
+ * Run `steps` in order, stopping after the first blocking failure. Pure over
191
+ * the steps' results — the reducer the CLI and the tests share.
192
+ *
193
+ * @example
194
+ * const steps = await runWizardSteps(ctx, WIZARD_STEPS);
195
+ */
196
+ export declare function runWizardSteps(ctx: WizardCtx, steps: readonly WizardStep[]): Promise<StepResult[]>;
197
+ /**
198
+ * The wizard entry point behind bare `mesh init`.
199
+ *
200
+ * Returns the process exit code instead of exiting, so the caller decides
201
+ * (and a test can assert on it). Ctrl-C at a prompt returns 130 with nothing
202
+ * written. All human output goes to stderr under `--json`, leaving stdout for
203
+ * the one document.
204
+ *
205
+ * @example
206
+ * process.exitCode = await runInitWizard({ tenant: "acme", local: true, yes: true });
207
+ */
208
+ export declare function runInitWizard(opts: WizardOptions, deps?: {
209
+ cwd?: string;
210
+ prompts?: Prompts;
211
+ steps?: readonly WizardStep[];
212
+ interactive?: boolean;
213
+ remote?: boolean;
214
+ seams?: WizardSeams;
215
+ }): Promise<number>;
216
+ //# sourceMappingURL=wizard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/wizard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAA8B,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAkD,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAazG,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,2DAA2D;IAC3D,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3D,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,6BAA6B;AAC7B,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,kDAAkD;AACl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