@hs-x/cli 0.1.1 → 0.1.3

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 (143) hide show
  1. package/README.md +59 -33
  2. package/dist/cli/index.d.ts.map +1 -1
  3. package/dist/cli/index.js +152 -334
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/cli/kit.d.ts +36 -0
  6. package/dist/cli/kit.d.ts.map +1 -0
  7. package/dist/cli/kit.js +64 -0
  8. package/dist/cli/kit.js.map +1 -0
  9. package/dist/cli-error.d.ts +19 -1
  10. package/dist/cli-error.d.ts.map +1 -1
  11. package/dist/cli-error.js +19 -4
  12. package/dist/cli-error.js.map +1 -1
  13. package/dist/commands/account.d.ts +55 -6
  14. package/dist/commands/account.d.ts.map +1 -1
  15. package/dist/commands/account.js +254 -252
  16. package/dist/commands/account.js.map +1 -1
  17. package/dist/commands/api.d.ts +16 -0
  18. package/dist/commands/api.d.ts.map +1 -1
  19. package/dist/commands/api.js +173 -0
  20. package/dist/commands/api.js.map +1 -1
  21. package/dist/commands/completion.d.ts +6 -0
  22. package/dist/commands/completion.d.ts.map +1 -1
  23. package/dist/commands/completion.js +34 -0
  24. package/dist/commands/completion.js.map +1 -1
  25. package/dist/commands/connect.d.ts +32 -0
  26. package/dist/commands/connect.d.ts.map +1 -1
  27. package/dist/commands/connect.js +126 -1
  28. package/dist/commands/connect.js.map +1 -1
  29. package/dist/commands/control-plane-read.d.ts +60 -17
  30. package/dist/commands/control-plane-read.d.ts.map +1 -1
  31. package/dist/commands/control-plane-read.js +269 -231
  32. package/dist/commands/control-plane-read.js.map +1 -1
  33. package/dist/commands/deploy-promote.d.ts +14 -0
  34. package/dist/commands/deploy-promote.d.ts.map +1 -1
  35. package/dist/commands/deploy-promote.js +128 -0
  36. package/dist/commands/deploy-promote.js.map +1 -1
  37. package/dist/commands/deploy.d.ts +57 -0
  38. package/dist/commands/deploy.d.ts.map +1 -1
  39. package/dist/commands/deploy.js +154 -1
  40. package/dist/commands/deploy.js.map +1 -1
  41. package/dist/commands/dev.d.ts +25 -0
  42. package/dist/commands/dev.d.ts.map +1 -1
  43. package/dist/commands/dev.js +108 -0
  44. package/dist/commands/dev.js.map +1 -1
  45. package/dist/commands/doctor.d.ts +7 -7
  46. package/dist/commands/doctor.d.ts.map +1 -1
  47. package/dist/commands/doctor.js +144 -143
  48. package/dist/commands/doctor.js.map +1 -1
  49. package/dist/commands/flags.d.ts +35 -0
  50. package/dist/commands/flags.d.ts.map +1 -1
  51. package/dist/commands/flags.js +229 -0
  52. package/dist/commands/flags.js.map +1 -1
  53. package/dist/commands/history.d.ts +8 -5
  54. package/dist/commands/history.d.ts.map +1 -1
  55. package/dist/commands/history.js +46 -40
  56. package/dist/commands/history.js.map +1 -1
  57. package/dist/commands/init.d.ts +30 -0
  58. package/dist/commands/init.d.ts.map +1 -1
  59. package/dist/commands/init.js +89 -0
  60. package/dist/commands/init.js.map +1 -1
  61. package/dist/commands/link.d.ts +15 -0
  62. package/dist/commands/link.d.ts.map +1 -1
  63. package/dist/commands/link.js +284 -0
  64. package/dist/commands/link.js.map +1 -1
  65. package/dist/commands/login.d.ts +17 -1
  66. package/dist/commands/login.d.ts.map +1 -1
  67. package/dist/commands/login.js +79 -21
  68. package/dist/commands/login.js.map +1 -1
  69. package/dist/commands/migrate.d.ts +32 -0
  70. package/dist/commands/migrate.d.ts.map +1 -1
  71. package/dist/commands/migrate.js +255 -0
  72. package/dist/commands/migrate.js.map +1 -1
  73. package/dist/commands/rollback.d.ts +22 -0
  74. package/dist/commands/rollback.d.ts.map +1 -1
  75. package/dist/commands/rollback.js +271 -0
  76. package/dist/commands/rollback.js.map +1 -1
  77. package/dist/commands/secrets.d.ts +35 -5
  78. package/dist/commands/secrets.d.ts.map +1 -1
  79. package/dist/commands/secrets.js +94 -196
  80. package/dist/commands/secrets.js.map +1 -1
  81. package/dist/commands/status.d.ts +8 -5
  82. package/dist/commands/status.d.ts.map +1 -1
  83. package/dist/commands/status.js +162 -121
  84. package/dist/commands/status.js.map +1 -1
  85. package/dist/commands/unlink.d.ts +11 -0
  86. package/dist/commands/unlink.d.ts.map +1 -1
  87. package/dist/commands/unlink.js +75 -0
  88. package/dist/commands/unlink.js.map +1 -1
  89. package/dist/commands/update.d.ts +8 -4
  90. package/dist/commands/update.d.ts.map +1 -1
  91. package/dist/commands/update.js +83 -35
  92. package/dist/commands/update.js.map +1 -1
  93. package/dist/commands/validate.d.ts +12 -6
  94. package/dist/commands/validate.d.ts.map +1 -1
  95. package/dist/commands/validate.js +50 -23
  96. package/dist/commands/validate.js.map +1 -1
  97. package/dist/config.d.ts +8 -0
  98. package/dist/config.d.ts.map +1 -1
  99. package/dist/config.js +1 -1
  100. package/dist/config.js.map +1 -1
  101. package/dist/constants.d.ts.map +1 -1
  102. package/dist/constants.js +3 -0
  103. package/dist/constants.js.map +1 -1
  104. package/dist/init/templates.d.ts.map +1 -1
  105. package/dist/init/templates.js +9 -7
  106. package/dist/init/templates.js.map +1 -1
  107. package/dist/services/cloudflare-kv.d.ts +2 -2
  108. package/dist/services/cloudflare-kv.d.ts.map +1 -1
  109. package/dist/services/cloudflare-kv.js +10 -6
  110. package/dist/services/cloudflare-kv.js.map +1 -1
  111. package/dist/services/command-history.d.ts +2 -0
  112. package/dist/services/command-history.d.ts.map +1 -1
  113. package/dist/services/command-history.js +1 -1
  114. package/dist/services/command-history.js.map +1 -1
  115. package/dist/services/config.d.ts +24 -0
  116. package/dist/services/config.d.ts.map +1 -0
  117. package/dist/services/config.js +41 -0
  118. package/dist/services/config.js.map +1 -0
  119. package/dist/services/cwd.d.ts +12 -0
  120. package/dist/services/cwd.d.ts.map +1 -0
  121. package/dist/services/cwd.js +10 -0
  122. package/dist/services/cwd.js.map +1 -0
  123. package/dist/services/hubspot-dev-client.d.ts +38 -0
  124. package/dist/services/hubspot-dev-client.d.ts.map +1 -0
  125. package/dist/services/hubspot-dev-client.js +256 -0
  126. package/dist/services/hubspot-dev-client.js.map +1 -0
  127. package/dist/services/live.d.ts +7 -1
  128. package/dist/services/live.d.ts.map +1 -1
  129. package/dist/services/live.js +20 -8
  130. package/dist/services/live.js.map +1 -1
  131. package/dist/services/reporter.d.ts +14 -0
  132. package/dist/services/reporter.d.ts.map +1 -1
  133. package/dist/services/reporter.js +20 -0
  134. package/dist/services/reporter.js.map +1 -1
  135. package/dist/services/telemetry.d.ts +43 -0
  136. package/dist/services/telemetry.d.ts.map +1 -0
  137. package/dist/services/telemetry.js +93 -0
  138. package/dist/services/telemetry.js.map +1 -0
  139. package/dist/services/tenant-state.d.ts +85 -0
  140. package/dist/services/tenant-state.d.ts.map +1 -0
  141. package/dist/services/tenant-state.js +98 -0
  142. package/dist/services/tenant-state.js.map +1 -0
  143. package/package.json +3 -2
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  >
5
5
  > This file is the CLI *contract* — what `hs-x` will look like at completion. Many sections below describe commands, flags, or packages that are **not yet implemented**. For the actually-shipped CLI surface, run `hs-x --help` or read `packages/cli/src/index.ts` (the dispatch switch is the source of truth).
6
6
  >
7
- > Sections that drift from current implementation are marked inline with `[NOT YET IMPLEMENTED]` or `[PARTIAL]`. As of 2026-05-20, shipped top-level commands are: `init`/`create`, `check`, `validate`, `deploy`, `promote`, `connect`, `secrets`, `login`, `whoami`, `logout`, `completion`, `api`, `account`, `audit`, `drift`, `checkpoint`/`logs`, `routing`, `rollback`, `dev`, `migrate`, `rollout`/`flags`, `doctor`, `status`, `history`, `update`/`upgrade`. The planned monorepo package layout below does **not** match the actual `packages/` tree — see the workspace for the real list.
7
+ > Sections that drift from current implementation are marked inline with `[NOT YET IMPLEMENTED]` or `[PARTIAL]`. As of v1 (2026-06), shipped top-level commands are: `init` (alias `create`), `check`, `validate`, `deploy`, `connect`, `secrets`, `link`, `unlink`, `login`, `whoami`, `logout`, `completion`, `api`, `account`/`accounts`, `audit`, `drift`, `checkpoint`/`logs`, `routing`/`route`/`routes`, `promote`, `rollback`, `dev`, `migrate`, `flags`, `doctor`, `status`, `history`, `update`/`upgrade`. The planned monorepo package layout below does **not** match the actual `packages/` tree — see the workspace for the real list.
8
8
 
9
9
  *Working draft. This is the CLI contract for `hs-x` after the SDK/interface review pass. It assumes a monorepo implementation and keeps the CLI as orchestration over reusable packages. The CLI is the human surface, the CI surface, and the coding-agent surface; every command that matters must have stable JSON output and a matching MCP tool.*
10
10
 
@@ -15,7 +15,7 @@ This update folds in the root docs, `sdk/README.md`, and the current review find
15
15
  - first-run setup needs a single `hs-x connect` golden path;
16
16
  - portal-scoped dev routing requires an initial deployed runtime, so `dev` cannot pretend it is purely local;
17
17
  - the migration/card path should support Cloudflare-light or HubSpot-only first value where possible;
18
- - deploys use ADR-009 attestation-gated promotion, compatibility classification, rollback, and promotion;
18
+ - deploys use attestation-gated promotion, compatibility classification, rollback, and promotion;
19
19
  - metadata iteration needs an explicit command path (`dev upload` or `deploy --metadata-only`);
20
20
  - dev overrides should be exact capability matches in v1, not wildcard by default;
21
21
  - data-plane drift needs first-class commands (`doctor`, `drift`, `repair`);
@@ -35,7 +35,7 @@ This update folds in the root docs, `sdk/README.md`, and the current review find
35
35
 
36
36
  ## Monorepo package layout
37
37
 
38
- > **[PLANNED — does not match current `packages/` tree]** The actual workspace uses a smaller set of packages (`checkpoint`, `codegen`, `control-plane`, `design`, `e2e`, `email`, `fixtures`, `hubspot-cli`, `hubspot-client`, `hubspot-mock`, `mcp`, `runtime`, `sdk`, `stream-relay`, `studio`, `types`, `validator`). The breakdown below reflects the target decomposition, not what exists today.
38
+ > **[PLANNED — does not match current `packages/` tree]** The actual workspace uses a smaller set of packages (`checkpoint`, `codegen`, `control-plane`, `design`, `e2e`, `email`, `fixtures`, `hubspot-cli`, `hubspot-client`, `hubspot-mock`, `mcp`, `runtime`, `sdk`, `studio`, `types`, `validator`). The breakdown below reflects the target decomposition, not what exists today.
39
39
 
40
40
  The CLI package owns command registration, option parsing, prompts, and rendering. It does not own the core logic.
41
41
 
@@ -324,20 +324,34 @@ The CLI keeps HubSpot developer-account credentials distinct:
324
324
 
325
325
  For raw calls, `hs-x api hubspot <path>` accepts PAK-only, HAPIKEY-only, or both. When both are present, the request includes bearer auth and the `hapikey` query parameter.
326
326
 
327
- ## First-run golden paths
327
+ ## Install
328
328
 
329
- ### Full runtime path
329
+ ```bash
330
+ npm i -g @hs-x/cli
331
+ ```
332
+
333
+ This installs the `hs-x` command on your PATH. Both Node and Bun run it. You can also invoke it without a global install via `bunx @hs-x/cli <command>`.
330
334
 
331
- This path creates or links a project, connects HubSpot and Cloudflare, creates a development environment, deploys the first runtime shell needed for portal-scoped dev routing, and then starts local dev.
335
+ ## First-run golden path
336
+
337
+ This is the unlinked, direct-to-HubSpot path: scaffold a project, install its deps, point it at your HubSpot dev app and a Cloudflare API token, run the local loop, then deploy to your own Cloudflare and HubSpot.
332
338
 
333
339
  ```bash
334
- npx hs-x create deal-enricher
340
+ npm i -g @hs-x/cli
341
+ hs-x init deal-enricher
335
342
  cd deal-enricher
336
- hs-x connect
337
- hs-x dev --portal 12345
343
+ bun install
344
+ # set HubSpot dev-app credentials + a Cloudflare API token
345
+ # (HSX_HUBSPOT_CLIENT_ID / HSX_HUBSPOT_CLIENT_SECRET, CLOUDFLARE_API_TOKEN, etc.)
346
+ hs-x dev # local development loop
347
+ hs-x deploy # deploy to your own Cloudflare + HubSpot
338
348
  ```
339
349
 
340
- `hs-x connect` is intentionally broad. It handles or guides:
350
+ The CLI works direct-to-HubSpot without the HS-X platform. The control plane, dashboard, and billing are opt-in. Deployed apps run in *your* Cloudflare account.
351
+
352
+ ### Platform-linked setup with `hs-x connect`
353
+
354
+ If you opt into the HS-X platform, `hs-x connect` is the broader golden path: it links the project to an HS-X account and walks HubSpot and Cloudflare setup. It is intentionally broad. It handles or guides:
341
355
 
342
356
  - local HS-X auth;
343
357
  - HS-X account selection;
@@ -387,31 +401,43 @@ hs-x accounts current [--json]
387
401
  hs-x accounts switch <account>
388
402
  ```
389
403
 
390
- ### `hs-x create`
404
+ ### `hs-x init`
391
405
 
392
- Workspace command. Creates a new project and optionally adds it to `hsx.workspace.json`.
406
+ Scaffolds a new HS-X project in a new directory named after the project. `hs-x create` is an accepted alias.
393
407
 
394
408
  ```text
395
- hs-x create <name> [--type workflow-action|sync-source|empty] [--app-name <name>] [--dir <path>] [--account <account>] [--monorepo] [--runtime byo-cloudflare|managed-cloudflare|hubspot-only]
409
+ hs-x init [name] [--type workflow-action|sync-source|empty] [--app-name <name>] [--yes] [--no-install] [--force] [--cwd <dir>] [--quiet] [--json]
396
410
  ```
397
411
 
398
- ```ts
399
- export interface CreateOptions {
400
- name: string;
401
- type: "workflow-action" | "sync-source" | "empty";
402
- targetDir: string;
403
- account?: string;
404
- runtimePosture?: RuntimePosture;
405
- addToWorkspace: boolean;
406
- installDeps: boolean;
407
- }
412
+ Flags:
408
413
 
409
- export interface CreateResult {
410
- projectRoot: string;
411
- packageManager: "pnpm" | "npm" | "yarn" | "bun";
412
- filesCreated: string[];
413
- workspaceUpdated: boolean;
414
- nextSteps: string[];
414
+ - `--name <name>` — project directory and config name (a positional argument is also accepted).
415
+ - `--type <type>` — app type: `workflow-action` (default), `sync-source`, or `empty`. `--template <id>` is also accepted (`deals-tagger` is the workflow-action template).
416
+ - `--app-name <name>` HubSpot app display name; defaults from the project name. `--display-name` is an accepted alias.
417
+ - `--yes`, `-y` — accept defaults: install dependencies and skip prompts.
418
+ - `--no-install` — skip the dependency install step.
419
+ - `--force` — overwrite an existing `hsx.config.ts` at the target.
420
+ - `--cwd <dir>` — run as if invoked from `<dir>`.
421
+ - `--quiet`, `-q` — suppress progress output.
422
+ - `--json` — emit a JSON result.
423
+
424
+ A scaffold writes `package.json`, `tsconfig.json`, `.gitignore`, `hsx.config.ts`, and one or more `src/workers/*.ts` files. The generated `package.json` depends on `@hs-x/sdk` and `@hs-x/runtime` from npm (no `workspace:*`, no per-project `hs-x` devDependency — the CLI is installed globally). The `.gitignore` ignores `.hs-x/*` except `.hs-x/alchemy.run.ts`, which is tracked as the leaveability artifact.
425
+
426
+ When invoked without `--type` in an interactive terminal, `init` prompts for the project name, the template, the HubSpot app name, and whether to install dependencies. In `--json` or non-interactive mode it falls back to defaults (project name `hsx-app`, the workflow-action template) and skips prompts.
427
+
428
+ The JSON result has the shape:
429
+
430
+ ```json
431
+ {
432
+ "ok": true,
433
+ "command": "init",
434
+ "project": {
435
+ "name": "deal-enricher",
436
+ "appName": "Deal Enricher",
437
+ "root": "/abs/path/deal-enricher",
438
+ "template": "deals-tagger",
439
+ "installed": true
440
+ }
415
441
  }
416
442
  ```
417
443
 
@@ -545,7 +571,7 @@ hs-x dev upload [--metadata-only] # [NOT YET IMPLEMEN
545
571
 
546
572
  ### `hs-x deploy`
547
573
 
548
- Runs the Phase 1 two-cloud deploy state machine from ADR-009. A deploy records a candidate, uploads Cloudflare and HubSpot assets through local execution, waits for runtime attestation to report healthy drift, then promotes the deploy in control-plane state. Full router-based revisioned routing is deferred.
574
+ Runs the two-cloud deploy state machine. A deploy records a candidate, uploads Cloudflare and HubSpot assets through local execution, waits for runtime attestation to report healthy drift, then promotes the deploy in control-plane state. Full router-based revisioned routing is deferred.
549
575
 
550
576
  ```text
551
577
  hs-x deploy [--project <name>] [--env staging|production] [--plan] [--diff] [--resume <deployId>] [--breaking] [--semantic-change] [--expected-rps <n>] [--metadata-only] [--hubspot-only] [--json]
@@ -591,7 +617,7 @@ export interface DeployResult {
591
617
  }
592
618
  ```
593
619
 
594
- Phase 1 state machine:
620
+ Deploy state machine:
595
621
 
596
622
  ```text
597
623
  plan_requested
@@ -625,7 +651,7 @@ Rules:
625
651
  - `--hubspot-only` is allowed only for projects/capabilities with no Cloudflare runtime needs.
626
652
  - `--plan` includes cost shape, Workers Paid requirements, streaming polling cost, custom-domain/permitted URL warnings, and drift status.
627
653
  - If drift is detected, deploy offers `hs-x repair` first rather than silently deploying on top of drift.
628
- - `--portal-schema-fixture <path>` runs the ADR-008 schema planner against deterministic observed schema JSON.
654
+ - `--portal-schema-fixture <path>` runs the schema planner against deterministic observed schema JSON.
629
655
  - `--portal-schema-live` reads the target portal schema through the HubSpot developer client; `--apply-schema` applies only the managed `WILL CREATE` / `WILL ALTER` actions from that plan.
630
656
 
631
657
  ### `hs-x promote`
@@ -997,5 +1023,5 @@ Exit codes:
997
1023
  - `hs-x dev upload` vs `hs-x deploy --metadata-only`: should both exist or should one alias the other?
998
1024
  - Exact first-run dev runtime: does `hs-x connect` always deploy a shell Worker, or only when a capability requires runtime hosting?
999
1025
  - HubSpot-only migration: which legacy card shapes can truly deploy without Cloudflare?
1000
- - Fresh-clone generated refs: should `hs-x create` install a stub `@hs-x/refs` package or rely on generated `.hs-x/refs` after first `dev`/`deploy`?
1026
+ - Fresh-clone generated refs: should `hs-x init` install a stub `@hs-x/refs` package or rely on generated `.hs-x/refs` after first `dev`/`deploy`?
1001
1027
  - How much of `hs-x check` belongs in `validate` vs a marketplace-specific command?
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA2D9C,wBAAsB,MAAM,CAC1B,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,GAAG,SAAgB,GAClB,OAAO,CAAC,SAAS,CAAC,CAubpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAiDA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA6D9C,wBAAsB,MAAM,CAC1B,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,GAAG,SAAgB,GAClB,OAAO,CAAC,SAAS,CAAC,CAmFpB"}