@salsita-ai/sdk 0.50.0-develop.c28cfb7ded → 0.50.0-develop.ca72986c39

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 (53) hide show
  1. package/README.md +13 -12
  2. package/dist/application-spec/generate-application/code/generate-application-code.d.ts +3 -2
  3. package/dist/application-spec/generate-application/code/generate-application-code.js +1 -1
  4. package/dist/application-spec/generate-application/code/project-scaffolding.d.ts +9 -4
  5. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  6. package/dist/application-spec/generate-application/code/templates/frontend-config.js +3 -5
  7. package/dist/application-spec/generate-application/code/templates/gitignore.js +1 -2
  8. package/dist/application-spec/generate-application/code/templates/globals.js +3 -4
  9. package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -0
  10. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  11. package/dist/application-spec/generate-application/code/templates/root-tsconfig.d.ts +6 -0
  12. package/dist/application-spec/generate-application/code/templates/root-tsconfig.js +2 -0
  13. package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -1
  14. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +1 -1
  15. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +5 -4
  16. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
  17. package/dist/application-spec/generate-application/code/templates/tsconfig.d.ts +5 -0
  18. package/dist/application-spec/generate-application/code/templates/tsconfig.js +1 -1
  19. package/dist/application-spec/generate-application/code/templates/webhooks-config.js +2 -3
  20. package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +10 -0
  21. package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
  22. package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.d.ts +9 -0
  23. package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.js +1 -0
  24. package/dist/client/phoenix-api.d.ts +367 -0
  25. package/dist/docs/index.json +1 -1
  26. package/dist/docs/phoenix/deployments.mdx +2 -6
  27. package/dist/docs/phoenix/getting-started.mdx +1 -0
  28. package/dist/docs/phoenix/localization.mdx +4 -4
  29. package/dist/docs/phoenix/migration-guide.mdx +19 -8
  30. package/dist/docs/phoenix/phoenix-cli.mdx +36 -6
  31. package/dist/docs/phoenix/project-structure.mdx +17 -5
  32. package/dist/docs/phoenix/sdk-builder-workflow.mdx +1 -1
  33. package/dist/docs/phoenix/webhooks.mdx +4 -4
  34. package/dist/globals/index.d.ts +2 -0
  35. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  36. package/dist/phoenix/application-spec/project-files.js +1 -1
  37. package/dist/phoenix/cli.js +1 -1
  38. package/dist/phoenix/commands/check.js +1 -1
  39. package/dist/phoenix/commands/deps/deps.d.ts +52 -0
  40. package/dist/phoenix/commands/deps/deps.js +3 -0
  41. package/dist/phoenix/commands/deps/index.d.ts +1 -0
  42. package/dist/phoenix/commands/deps/index.js +1 -0
  43. package/dist/phoenix/commands/deps/sdk-manifest.d.ts +12 -0
  44. package/dist/phoenix/commands/deps/sdk-manifest.js +1 -0
  45. package/dist/phoenix/commands/dev.js +5 -5
  46. package/dist/phoenix/commands/index.d.ts +1 -0
  47. package/dist/phoenix/commands/index.js +1 -1
  48. package/dist/phoenix/services/application-spec-project-watcher.d.ts +2 -0
  49. package/dist/phoenix/services/application-spec-project-watcher.js +2 -2
  50. package/dist/phoenix/services/swc.js +1 -1
  51. package/dist/phoenix/utils/index.d.ts +1 -0
  52. package/dist/phoenix/utils/index.js +1 -1
  53. package/package.json +3 -6
@@ -183,7 +183,7 @@ type CustomMaterial = Phx['AdminModel']['CustomMaterial']
183
183
  | File | Auto-Generated? | Notes |
184
184
  | ------------------------------------------------------ | --------------- | -------------------------------------- |
185
185
  | `package.json` | Partially | Dependencies merged, scripts untouched |
186
- | `tsconfig.json` | Yes | Managed by Phoenix |
186
+ | `tsconfig.json` | Once | Yours; see below |
187
187
  | `eslint.config.js` | Yes | Managed by Phoenix |
188
188
  | `prettier.config.js` | Yes | Managed by Phoenix |
189
189
  | `.prettierignore` | No | Optional and your own; see below |
@@ -192,19 +192,29 @@ type CustomMaterial = Phx['AdminModel']['CustomMaterial']
192
192
  | `.gitignore` | Partially | Only in a git repository; see Markers |
193
193
  | `.env` | No | Git-ignored, local config |
194
194
  | `.env.example` | No | Template for env vars |
195
- | `.env.generated` | Yes | Auto-generated IDs, git-ignored |
195
+ | `.env.generated` | Yes | Optional, git-ignored; see below |
196
196
  | `README.md` | No | Project documentation |
197
197
  | `AGENTS.md` | No | Your own coding-agent instructions |
198
198
  | `.claude/skills/phoenix*/`, `.agents/skills/phoenix*/` | Yes | Phoenix agent skills |
199
199
 
200
200
  Sync does not write `README.md`, `AGENTS.md`, `.env.example`, `.env.ci` or the `README.md` files in `assets/public/` and `assets/private/`. Earlier SDK versions wrote them once; a project that has them keeps them, and they are yours to edit.
201
201
 
202
+ Phoenix keeps the generated env file, with the IDs and values of the prepared deployment, in `.phoenix/` unless the project has a `.env.generated` in its root, which then is the one that counts. `phoenix dev` creates no `.env.generated` in the project root; the deployment and environment commands write it there. See [The generated env file](?path=/docs/phoenix-phoenix-cli--docs#the-generated-env-file).
203
+
202
204
  With the application-spec pipeline (see [Current and legacy project tooling](?path=/docs/phoenix-phoenix-cli--docs#current-and-legacy-project-tooling)), Phoenix does not write a `.prettierignore`, and a fresh clone or CI checkout of a project has none. `phoenix check` and `phoenix fix` do not read one: they skip `.phoenix/`, `dist/`, the compiled catalogs in `src/locales/`, `pnpm-lock.yaml` and `.linguirc` on their own. A project that runs Prettier directly, as `prettier --check .` or from an editor, can add its own `.prettierignore`. To commit it, add a `!.prettierignore` line after the Phoenix block of `.gitignore`, because that block lists the file. The legacy pipeline writes `.prettierignore` on every sync.
203
205
 
206
+ With the application-spec pipeline, the project's TypeScript settings are in `.phoenix/tsconfig.json`, which sync rewrites with the rest of `.phoenix/`. The root `tsconfig.json` is the one editors and tools find: sync writes it only when the project has none, as a single line that extends the generated settings, and it is yours to commit and to add to:
207
+
208
+ ```json
209
+ { "extends": "./.phoenix/tsconfig.json" }
210
+ ```
211
+
212
+ The only root `tsconfig.json` sync replaces is the full file earlier SDK versions generated there, recognised by its settings; any other stays as it is. `phoenix dev`, `phoenix build` and the webhook bundle do not resolve `paths` aliases, so an alias added to the root file passes `phoenix check` and fails the build. `phoenix check` type-checks with the root `tsconfig.json`, or with `.phoenix/tsconfig.json` when the project has none. The legacy pipeline writes the full `tsconfig.json` on every sync.
213
+
204
214
  ### DO NOT EDIT (Fully Auto-Generated)
205
215
 
206
- - **Everything in `.phoenix/`** - Completely regenerated on each build. The one exception is `.phoenix/variants/`, where a coding agent writes the option files for `phoenix variants`; a rebuild keeps it
207
- - `tsconfig.json`, `eslint.config.js`, `prettier.config.js`
216
+ - **Everything in `.phoenix/`** - Completely regenerated on each build. The exceptions are `.phoenix/variants/`, where a coding agent writes the option files for `phoenix variants`, and `.phoenix/.env.generated`, the generated env file of `phoenix dev`; a rebuild keeps both
217
+ - `eslint.config.js`, `prettier.config.js`
208
218
  - `.linguirc`, `.nvmrc`
209
219
  - `src/locales/**/*.ts` - Compiled from `.po` catalogs
210
220
  - `.env.generated`
@@ -242,6 +252,7 @@ With the application-spec pipeline (see [Current and legacy project tooling](?pa
242
252
  - `templates/`
243
253
  - `package.json` (scripts section, custom dependencies)
244
254
  - `.env`, `.env.example`, `.env.ci`
255
+ - `tsconfig.json` (application-spec pipeline; keep it extending `.phoenix/tsconfig.json`)
245
256
  - `README.md`, `AGENTS.md`
246
257
 
247
258
  ## File Naming Conventions
@@ -349,6 +360,7 @@ project-root/
349
360
  │ ├── admin-interface.ts # Admin interface types
350
361
  │ ├── i18n.ts # i18n initialization
351
362
  │ ├── globals.d.ts # Global type definitions
363
+ │ ├── tsconfig.json # TypeScript settings, extended by the root tsconfig.json
352
364
  │ ├── index.html # Configurator HTML entry
353
365
  │ └── admin.html # Admin HTML entry
354
366
  │
@@ -512,7 +524,7 @@ Assets are split between two locations with different deployment strategies:
512
524
 
513
525
  Localization files enable multi-language support in your configurator.
514
526
 
515
- Translatable messages are authored in TypeScript and TSX source files using `@lingui/macro`.
527
+ Translatable messages are authored in TypeScript and TSX source files using Lingui's macros: `msg` from `@lingui/core/macro` and `<Trans>` from `@lingui/react/macro`.
516
528
 
517
529
  Locale catalogs live in `src/locales/<lang>/`. Phoenix creates and updates the `messages.po` source catalogs; edit their `msgstr` values to provide translations. The `messages.ts` files are compiled from those catalogs and must not be edited directly.
518
530
 
@@ -76,7 +76,7 @@ pnpm phoenix deploy
76
76
  `phoenix deploy` goes through these steps:
77
77
 
78
78
  1. It validates the application spec.
79
- 2. It packs the project files: the `.yaml` files in `spec`, everything in `src`, `mocks`, `assets`, `public` and `templates`, and `package.json`, `pnpm-lock.yaml`, `pnpm-workspace.yaml`, `.gitignore`, `CLAUDE.md` and `.cursor/rules/phoenix.mdc`. Every `node_modules`, `.phoenix` and `__generated` folder, every `.DS_Store` and `._*` file and every `.env` and `.env.*` file are left out, at any depth.
79
+ 2. It packs the project files: the `.yaml` files in `spec`, everything in `src`, `mocks`, `assets`, `public` and `templates`, and `package.json`, `tsconfig.json`, `pnpm-lock.yaml`, `pnpm-workspace.yaml`, `.gitignore`, `CLAUDE.md` and `.cursor/rules/phoenix.mdc`. Every `node_modules`, `.phoenix` and `__generated` folder, every `.DS_Store` and `._*` file and every `.env` and `.env.*` file are left out, at any depth.
80
80
  3. It asks the server for a build. The server compares your domain model with the deployed one and refuses, before anything is uploaded, a model that changed under an already deployed model version; see [Migrations](?path=/docs/phoenix-migrations--docs).
81
81
  4. It uploads the archive, which may be up to 200 MB.
82
82
  5. It starts the build, prints a link to the build's page in Studio and follows the build until your configurator is live, then prints its URL.
@@ -408,7 +408,7 @@ ctx.emailTaskBuilder.withSubject(msg`Your configuration`)
408
408
  In React templates, use `<Trans>` for inline strings and `<HtmlHelpers.Localized>` to render message descriptors:
409
409
 
410
410
  ```tsx
411
- import { Trans } from '@lingui/macro'
411
+ import { Trans } from '@lingui/react/macro'
412
412
 
413
413
  import { HtmlHelpers } from '@salsita-ai/sdk/webhook'
414
414
 
@@ -473,7 +473,7 @@ The template file:
473
473
 
474
474
  ```tsx
475
475
  // src/webhooks/handlers/configurator-finalize-handler/tasks/pdf-template.tsx
476
- import { Trans } from '@lingui/macro'
476
+ import { Trans } from '@lingui/react/macro'
477
477
 
478
478
  import { HtmlHelpers, PdfHelpers, ResourceHelpers } from '@salsita-ai/sdk/webhook'
479
479
 
@@ -595,7 +595,7 @@ except for resource reference interpolation.
595
595
 
596
596
  ```tsx
597
597
  // src/webhooks/handlers/configurator-finalize-handler/tasks/email-task.tsx
598
- import { msg } from '@lingui/macro'
598
+ import { msg } from '@lingui/core/macro'
599
599
 
600
600
  import { EmailTemplate } from './email-template.js'
601
601
 
@@ -620,7 +620,7 @@ export const simpleEmailTask = phx.webhooks.taskFactory.createSendEmailTask((res
620
620
 
621
621
  ```tsx
622
622
  // src/webhooks/handlers/configurator-finalize-handler/tasks/email-template.tsx
623
- import { Trans } from '@lingui/macro'
623
+ import { Trans } from '@lingui/react/macro'
624
624
 
625
625
  import { EmailHelpers, ResourceHelpers } from '@salsita-ai/sdk/webhook'
626
626
 
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/triple-slash-reference */
2
+ // Resolved from the SDK's own `vite`, so a project's `import.meta.env` and asset imports type-check without a `vite` of its own
3
+ /// <reference types="vite/client" />
2
4
  /// <reference path="./asset-modules.d.ts" />
3
5
 
4
6
  export {}
@@ -1 +1 @@
1
- import{existsSync as e,lstatSync as i,readFileSync as t,readdirSync as r,rmSync as o,unlinkSync as s}from"fs";import{join as n}from"path";import{format as a}from"prettier";import{prettierrc as l}from"@salsita-ai/common/prettier";import{GeneratedApplication as c,GeneratedApplicationFile as p,RuntimeReferenceStore as g,buildPhoenixDefinitions as f,createContentDiffTracker as h,generateApplicationCode as d,parseApplicationFiles as m}from"#package/application-spec";import{getAllPhxDefinitions as u}from"#package/domain";import{compileWithSwc as w}from"../services/swc.js";import{isInsideGitRepository as b,syncChangedFiles as S}from"../utils/index.js";import{readApplicationFiles as j}from"./application-spec-file-reader.js";import{cleanStaleAgentSkills as v,removeProjectFiles as D}from"./clean-project-files.js";import{swcEvalExpressionParser as F,swcModuleAnalyzer as x}from"./swc-module-analyzer.js";let y=".phoenix",P=`${y}/`,k=async e=>{if(e.binary||!1===e.format)return e;try{let i=await a(e.content,{...l,filepath:e.path});return p(e.path,i,{binary:e.binary,format:e.format})}catch{return e}},C=async e=>{let[i,t,r]=await Promise.all([Promise.all(e.generatedProjectFiles.map(k)),Promise.all(e.initialProjectFiles.map(k)),Promise.all(e.prettierFiles.map(k))]);return c({files:e.files,generatedProjectFiles:i,initialProjectFiles:t,prettierFiles:r,removedProjectFiles:e.removedProjectFiles})};export class ApplicationSpecBuilder{contentDiff;referenceStore;config;logger;phxDefinitions;constructor(e){this.config=e,this.logger=e.logger,this.referenceStore=new g,this.contentDiff=h({readDiskContent:this.readDiskContent}),this.phxDefinitions=f(u())}async build(e){let i=e?.parsingContext,t=e?.compile??!0;e?.force&&this.referenceStore.clear();let r=i?.startSpan("readFiles","build","application-spec-builder.ts"),o=e?.rawProjectFiles??await j({envs:{}});r?.();let s=m({rawProjectFiles:o,phxDefinitions:this.phxDefinitions},{analyzer:x,evalExpressionParser:F,referenceStore:this.referenceStore,logger:this.logger,parsingContext:i});if(!s.ok)return{ok:!1,rawProjectFiles:o,errors:s.errors,diagnostics:s.diagnostics,metrics:s.metrics,counts:s.counts};let{applicationSpec:n,categorizedFiles:a,rawMockTemplates:l}=s.value,c=i?.startSpan("generateCode","build","application-spec-builder.ts"),p=b(process.cwd());p||this.logger.debug(" Not inside a git repository, .gitignore is not written");let g=d({applicationSpec:n,categorizedFiles:a,phxDefinitions:this.phxDefinitions,sdkVersion:this.config.sdkVersion,projectInGitRepository:p,cliUseWorkspace:this.config.cliUseWorkspace,name:this.config.name,description:this.config.description,projectSlug:this.config.projectSlug,environmentSlug:this.config.environmentSlug,enableEditor:this.config.enableEditor,inlineTemplates:this.config.inlineTemplates,rawMockTemplates:l});c?.();let f=i?.startSpan("cleanStaleFiles","build","application-spec-builder.ts"),h=new Set(g.files.map(e=>e.path));this.cleanStaleGeneratedFiles(h),D(g.removedProjectFiles,{logger:this.logger}),v(new Set(g.generatedProjectFiles.map(e=>e.path)),{logger:this.logger}),f?.();let u=i?.startSpan("contentDiff","build","application-spec-builder.ts"),w=await C(g),y=this.contentDiff.getChangedApplicationFiles(w,{generatedFilesPathPrefix:P,force:e?.force}),k=y.changedGeneratedFiles;u?.(),k.length>0?this.logger.info(` ${k.length}/${g.files.length} generated files changed`):this.logger.info(" No generated files changed");let $=y.filesToWrite.length-k.length;$>0&&this.logger.info(` ${$} project files changed`);let T=i?.startSpan("writeFiles","build","application-spec-builder.ts");return await S(y.filesToWrite,{logger:this.logger,skipChecksum:!0}),T?.(),t&&await this.compile(i),{ok:!0,application:s.value,changedFiles:k,diagnostics:s.diagnostics,metrics:s.metrics,counts:s.counts}}async compile(e){let i=e?.startSpan("swcCompile(src)","build","application-spec-builder.ts");await w({sourceDir:"src",outDir:`./${y}/.swc/src`},{logger:this.logger}),i?.();let t=e?.startSpan("swcCompile(.phoenix)","build","application-spec-builder.ts");await w({sourceDir:y,outDir:`./${y}/.swc/${y}`},{logger:this.logger}),t?.()}readDiskContent=i=>{try{if(e(i))return t(i,"utf-8")}catch{}};cleanStaleGeneratedFiles(t){let a=new Set(["public",".swc","dist","phoenix-dev.log","phoenix-dev.log.1","phoenix-dev.log.2","variants","variant-recovery.json"]);try{if(!e(y))return;for(let e of r(y)){if(a.has(e)||t.has(e))continue;let r=n(y,e);try{let e=i(r);if(e.isSymbolicLink())continue;e.isDirectory()?o(r,{recursive:!0}):s(r),this.logger.debug(` Removed stale: ${r}`)}catch{}}}catch{}}}
1
+ import{existsSync as e,lstatSync as i,readFileSync as t,readdirSync as r,rmSync as o,unlinkSync as s}from"fs";import{join as n}from"path";import{format as a}from"prettier";import{prettierrc as l}from"@salsita-ai/common/prettier";import{GeneratedApplication as c,GeneratedApplicationFile as p,RuntimeReferenceStore as g,buildPhoenixDefinitions as f,createContentDiffTracker as h,generateApplicationCode as d,parseApplicationFiles as m}from"#package/application-spec";import{getAllPhxDefinitions as u}from"#package/domain";import{compileWithSwc as w}from"../services/swc.js";import{isInsideGitRepository as b,syncChangedFiles as S}from"../utils/index.js";import{readApplicationFiles as j}from"./application-spec-file-reader.js";import{cleanStaleAgentSkills as v,removeProjectFiles as D}from"./clean-project-files.js";import{swcEvalExpressionParser as F,swcModuleAnalyzer as x}from"./swc-module-analyzer.js";let y=".phoenix",P=`${y}/`,k=async e=>{if(e.binary||!1===e.format)return e;try{let i=await a(e.content,{...l,filepath:e.path});return p(e.path,i,{binary:e.binary,format:e.format})}catch{return e}},C=async e=>{let[i,t,r]=await Promise.all([Promise.all(e.generatedProjectFiles.map(k)),Promise.all(e.initialProjectFiles.map(k)),Promise.all(e.prettierFiles.map(k))]);return c({files:e.files,generatedProjectFiles:i,initialProjectFiles:t,prettierFiles:r,removedProjectFiles:e.removedProjectFiles})};export class ApplicationSpecBuilder{contentDiff;referenceStore;config;logger;phxDefinitions;constructor(e){this.config=e,this.logger=e.logger,this.referenceStore=new g,this.contentDiff=h({readDiskContent:this.readDiskContent}),this.phxDefinitions=f(u())}async build(e){let i=e?.parsingContext,t=e?.compile??!0;e?.force&&this.referenceStore.clear();let r=i?.startSpan("readFiles","build","application-spec-builder.ts"),o=e?.rawProjectFiles??await j({envs:{}});r?.();let s=m({rawProjectFiles:o,phxDefinitions:this.phxDefinitions},{analyzer:x,evalExpressionParser:F,referenceStore:this.referenceStore,logger:this.logger,parsingContext:i});if(!s.ok)return{ok:!1,rawProjectFiles:o,errors:s.errors,diagnostics:s.diagnostics,metrics:s.metrics,counts:s.counts};let{applicationSpec:n,categorizedFiles:a,rawMockTemplates:l}=s.value,c=i?.startSpan("generateCode","build","application-spec-builder.ts"),p=b(process.cwd());p||this.logger.debug(" Not inside a git repository, .gitignore is not written");let g=d({applicationSpec:n,categorizedFiles:a,phxDefinitions:this.phxDefinitions,sdkVersion:this.config.sdkVersion,projectInGitRepository:p,cliUseWorkspace:this.config.cliUseWorkspace,name:this.config.name,description:this.config.description,projectSlug:this.config.projectSlug,environmentSlug:this.config.environmentSlug,enableEditor:this.config.enableEditor,inlineTemplates:this.config.inlineTemplates,rawMockTemplates:l});c?.();let f=i?.startSpan("cleanStaleFiles","build","application-spec-builder.ts"),h=new Set(g.files.map(e=>e.path));this.cleanStaleGeneratedFiles(h),D(g.removedProjectFiles,{logger:this.logger}),v(new Set(g.generatedProjectFiles.map(e=>e.path)),{logger:this.logger}),f?.();let u=i?.startSpan("contentDiff","build","application-spec-builder.ts"),w=await C(g),y=this.contentDiff.getChangedApplicationFiles(w,{generatedFilesPathPrefix:P,force:e?.force}),k=y.changedGeneratedFiles;u?.(),k.length>0?this.logger.info(` ${k.length}/${g.files.length} generated files changed`):this.logger.info(" No generated files changed");let $=y.filesToWrite.length-k.length;$>0&&this.logger.info(` ${$} project files changed`);let T=i?.startSpan("writeFiles","build","application-spec-builder.ts");return await S(y.filesToWrite,{logger:this.logger,skipChecksum:!0}),T?.(),t&&await this.compile(i),{ok:!0,application:s.value,changedFiles:k,diagnostics:s.diagnostics,metrics:s.metrics,counts:s.counts}}async compile(e){let i=e?.startSpan("swcCompile(src)","build","application-spec-builder.ts");await w({sourceDir:"src",outDir:`./${y}/.swc/src`},{logger:this.logger}),i?.();let t=e?.startSpan("swcCompile(.phoenix)","build","application-spec-builder.ts");await w({sourceDir:y,outDir:`./${y}/.swc/${y}`},{logger:this.logger}),t?.()}readDiskContent=i=>{try{if(e(i))return t(i,"utf-8")}catch{}};cleanStaleGeneratedFiles(t){let a=new Set(["public",".swc","dist","phoenix-dev.log","phoenix-dev.log.1","phoenix-dev.log.2","variants","variant-recovery.json",".env.generated"]);try{if(!e(y))return;for(let e of r(y)){if(a.has(e)||t.has(e))continue;let r=n(y,e);try{let e=i(r);if(e.isSymbolicLink())continue;e.isDirectory()?o(r,{recursive:!0}):s(r),this.logger.debug(` Removed stale: ${r}`)}catch{}}}catch{}}}
@@ -1 +1 @@
1
- import{globby as s}from"globby";import e from"picomatch";export const SPEC_FILE_PATTERN="spec/**/*.yaml";export const PARSED_TEXT_FILE_PATTERNS=["spec/**/*.yaml","src/**/*.{ts,tsx}","mocks/**/*.{yaml,yml}",".gitignore",".cursor/rules/phoenix.mdc","CLAUDE.md","package.json","assets/chat/embeddings.csv","assets/chat/chat.yaml"];export const PARSED_ASSET_FILE_PATTERNS=["assets/private/**","assets/public/**"];let o=[...PARSED_TEXT_FILE_PATTERNS,...PARSED_ASSET_FILE_PATTERNS,"src/**","mocks/**","assets/**","public/**","templates/**","pnpm-lock.yaml","pnpm-workspace.yaml"],t=["**/node_modules/**","**/.phoenix/**","**/__generated/**","**/.DS_Store","**/._*","**/.env","**/.env.*"],c=e(o,{dot:!0,ignore:t});export const isProjectFile=s=>c(s);export const listProjectEntries=async e=>(await s(o,{cwd:e,dot:!0,ignore:t,onlyFiles:!1,followSymbolicLinks:!1})).sort();
1
+ import{globby as s}from"globby";import o from"picomatch";export const SPEC_FILE_PATTERN="spec/**/*.yaml";export const PARSED_TEXT_FILE_PATTERNS=["spec/**/*.yaml","src/**/*.{ts,tsx}","mocks/**/*.{yaml,yml}",".gitignore",".cursor/rules/phoenix.mdc","CLAUDE.md","package.json","tsconfig.json","assets/chat/embeddings.csv","assets/chat/chat.yaml"];export const PARSED_ASSET_FILE_PATTERNS=["assets/private/**","assets/public/**"];let e=[...PARSED_TEXT_FILE_PATTERNS,...PARSED_ASSET_FILE_PATTERNS,"src/**","mocks/**","assets/**","public/**","templates/**","pnpm-lock.yaml","pnpm-workspace.yaml"],t=["**/node_modules/**","**/.phoenix/**","**/__generated/**","**/.DS_Store","**/._*","**/.env","**/.env.*"],c=o(e,{dot:!0,ignore:t});export const isProjectFile=s=>c(s);export const listProjectEntries=async o=>(await s(e,{cwd:o,dot:!0,ignore:t,onlyFiles:!1,followSymbolicLinks:!1})).sort();
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{bool as e,str as o}from"envalid";import{readFileSync as t}from"fs";import{readFile as i}from"fs/promises";import{arch as r,platform as n}from"os";import{dirname as a,join as s,resolve as l}from"path";import{P as p,match as d}from"ts-pattern";import{fileURLToPath as c}from"url";import u from"yargs";import{hideBin as E}from"yargs/helpers";import{z as v}from"zod";import{createEnvReader as f}from"@salsita-ai/common/env";import{DEFAULT_PROJECT_ALIAS as g,FeedbackType as m}from"@salsita-ai/contracts/domain";import{phoenixCli as y}from"#package/legacy";import{readSpecProject as h}from"./application-spec/read-spec-project.js";import{prepareDevelopmentEnvironment as R,prepareLocalEnvironment as S,runActivateDeploymentCommand as _,runBuildCommand as O,runChangelogCommand as U,runCheckCommand as P,runCleanCommand as b,runCleanupEnvironmentCommand as L,runCreateEnvironmentCommand as I,runDataCommand as N,runDeployCommand as T,runDeploymentBuildEnvsCommand as w,runDevCommand as k,runDocsCommand as D,runExtractSourcesCommand as j,runFeedbackCommand as G,runFinishDeploymentCommand as C,runFixCommand as A,runInitCommand as K,runInspectAssetsCommand as V,runLinkCommand as M,runListEnvironmentsCommand as J,runLoginCommand as B,runLogoutCommand as F,runPrepareCiCommand as x,runPrepareDeploymentCommand as Y,runRegisterDeploymentCommand as q,runSceneCommand as H,runScreenshotCommand as W,runStateCommand as $,runStoryCommand as X,runSyncCommand as z,runUnlinkCommand as Q,runVariantsCommand as Z}from"./commands/index.js";import{DEFAULT_PHOENIX_REGION as ee,PHOENIX_REGIONS as eo,PUBLIC_PHOENIX_REGIONS as et,VariantFileSession as ei,getRegionServerUrl as er,getRegionStudioUrl as en,resolveSignedInDevelopmentEnvironment as ea}from"./services/index.js";import{getIsEditorEnabled as es}from"./utils/get-is-editor-enabled.js";import{createLogger as el}from"./utils/index.js";let ep=(e,o,t)=>{e?.info(`Using ${o?"application-spec":"domain-spec"} flow (${t})`)},ed=(e,o,t)=>{let i=t?.logger??el();if(void 0!==e)return i.detail(`Application spec: ${e} (from CLI flag)`),ep(t?.logger,e,"from CLI flag"),e;let r=process.env.USE_APPLICATION_SPEC;if(void 0!==r){let e="true"===r||"1"===r;return i.detail(`Application spec: ${e} (from environment variable)`),ep(t?.logger,e,"from environment variable"),e}return void 0!==o?(i.detail(`Application spec: ${o} (from package.json phoenix.applicationFlow)`),ep(t?.logger,o,"from package.json phoenix.applicationFlow"),o):(i.detail("Application spec: false (default)"),ep(t?.logger,!1,"default"),!1)},ec=t(s(a(c(import.meta.url)),"../../package.json"),"utf-8");if(!ec)throw Error("Project package.json is required, please provide it in the package.json file");let eu=v.object({version:v.string({required_error:"Project version is required, please provide it in the package.json file"}),name:v.string({required_error:"Project name is required, please provide it in the package.json file"})}).parse(JSON.parse(ec)),eE=async()=>{try{let e=await i("./package.json","utf-8"),o=JSON.parse(e);return{name:o.name,applicationFlow:o.phoenix?.applicationFlow}}catch{return{name:void 0,applicationFlow:void 0}}},ev=e=>{if(!(e instanceof Error))return String(e);let o=(e=>{if(!(e instanceof Error))return;if(e.message.length>0)return e.message;let o=(e instanceof AggregateError?e.errors:[]).find(e=>e instanceof Error&&e.message.length>0);return o instanceof Error?o.message:"code"in e&&"string"==typeof e.code?e.code:void 0})(e.cause);return void 0===o?e.message:`${e.message}: ${o}`};await u(E(process.argv)).scriptName("phoenix").usage("$0 <command> [options]").command(["build","b"],"Build the project",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("onlyFrontend",{alias:"F",type:"boolean",description:"Build only frontend bundle"}).option("onlyWebhook",{alias:"W",type:"boolean",description:"Build only webhooks"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("banner",{type:"string",requiresArg:!0,description:"Text for the comment at the top of every frontend .js file, public in the bundle (default: application version from the spec and the git commit when available)",coerce:e=>"string"==typeof e?e:e.join("\n")}),async t=>{let i,r=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),BUILD_TARGET:o({choices:["frontend","webhook","both"],default:"both"}),FORCE_REBUILD:e({default:!1})})(),n=el({debug:t.debug??r.DEBUG}),a=es(t.editor,r.ENABLE_EDITOR),s=t.force??r.FORCE_REBUILD,l=await eE(),p=ed(t.applicationSpec,l.applicationFlow,{logger:n}),d=t.projectSlug??r.PROJECT_SLUG??l.name,c=t.environmentSlug??r.ENVIRONMENT_SLUG??l.name;if(!d)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!c)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let u=t.onlyFrontend,E=t.onlyWebhook;if(u&&E)throw Error("Cannot use --onlyFrontend and --onlyWebhook flags together, they are mutually exclusive");i=u?"frontend":E?"webhook":r.BUILD_TARGET;let v={sdkVersion:eu.version,projectSlug:d,environmentSlug:c,cliUseWorkspace:t.workspace,enableEditor:a,buildTarget:i,force:s};await (p?O({...v,banner:t.banner},{logger:n}):y.runBuildCommand(v,{logger:n}))}).command(["clean","cl"],"Clean build artifacts, reinstall dependencies, and rebuild specs",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1})})(),r=el({debug:t.debug??i.DEBUG}),n=es(t.editor,i.ENABLE_EDITOR),a=await eE(),s=ed(t.applicationSpec,a.applicationFlow,{logger:r}),l=t.projectSlug??i.PROJECT_SLUG??a.name,p=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!l)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!p)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (s?b:y.runCleanCommand)({sdkVersion:eu.version,projectSlug:l,environmentSlug:p,cliUseWorkspace:t.workspace,enableEditor:n},{logger:r})}).command(["dev","d"],"Start development mode (Vite, spec watching, and the webhook tunnel)",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("editorWsPort",{alias:"ep",type:"string",description:"Port for the editor WebSocket server (defaults to EDITOR_WS_PORT env or 3020)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("withLingui",{alias:"wl",type:"boolean",description:"Enable or disable i18n messages extraction and compilation (defaults to WITH_LINGUI env or false)"}).option("persistence",{alias:"P",type:"string",description:"Persistence mode for the configurator (defaults to PERSISTENCE_MODE env or server)",choices:["memory","local-storage","server"]}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("tui",{alias:"T",type:"boolean",description:"Render logs in a terminal UI with per-stream pages and split view; requires an interactive terminal (env: PHOENIX_TUI, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}).option("region",{choices:et,description:`Phoenix region of the workspace you are signed in to, used when .env has no SERVER_URL (default: ${ee})`}).option("serverUrl",{type:"string",description:"URL of the Phoenix server, instead of SERVER_URL or the region default"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket when the development deployment is prepared (env: SKIP_UPLOAD, default: false)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),EDITOR_WS_PORT:o({default:"3020"}),DEBUG:e({default:!1}),WITH_LINGUI:e({default:!1}),PERSISTENCE_MODE:o({default:void 0}),FORCE_REBUILD:e({default:!1}),PHOENIX_TUI:e({default:!1}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),PHOENIX_REGION:o({choices:eo,default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=el({debug:r}),a=es(t.editor,i.ENABLE_EDITOR),s=t.editorWsPort??i.EDITOR_WS_PORT,l=t.force??i.FORCE_REBUILD,c=t.withLingui??i.WITH_LINGUI,u=t.persistence??i.PERSISTENCE_MODE,E=!u||"server"===u,v=t.tui??i.PHOENIX_TUI,m=await eE(),R=ed(t.applicationSpec,m.applicationFlow,{logger:n}),S=t.local??i.PHOENIX_LOCAL,_=t.projectSlug??i.PROJECT_SLUG;R&&await ei.recover(process.cwd(),n);let O=E&&R&&!S&&!_?.length?await h(process.cwd()):void 0,{serverUrl:U,developmentKey:P,apiToken:b,projectSlug:L,environmentSlug:I}=await d({useServer:E,local:S,serverUrl:t.serverUrl??i.SERVER_URL,developmentKey:i.DEVELOPMENT_KEY,projectSlug:_?.length?_:O,environmentSlug:t.environmentSlug??i.ENVIRONMENT_SLUG}).with({useServer:!1},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t??m.name,environmentSlug:i??m.name})).with({local:!0},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e?.length?e:"http://localhost:3000",developmentKey:o?.length?o:"dev_local-dev-key-12345",apiToken:void 0,projectSlug:t?.length?t:"local",environmentSlug:i?.length?i:"dev-local"})).with({developmentKey:p.string.minLength(1)},()=>O===g,()=>{throw Error(`phoenix dev has a DEVELOPMENT_KEY, but the spec says \`project: ${g}\`, which only a signed-in workspace can resolve. Set PROJECT_SLUG in .env by pasting the .env block of your Studio development environment, or name the project's slug in the spec.`)}).with({serverUrl:p.string.minLength(1),developmentKey:p.string.minLength(1),projectSlug:p.string.minLength(1),environmentSlug:p.string.minLength(1)},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t,environmentSlug:i})).with({developmentKey:p.union(void 0,""),projectSlug:p.string.minLength(1)},()=>R,async({serverUrl:e,projectSlug:o})=>{let r=e?.length?e:er(t.region??i.PHOENIX_REGION??ee),a=await ea({serverUrl:r,project:o});return n.info(`Developing in ${a.projectSlug}/${a.environmentSlug} of workspace "${a.workspaceName}" on ${r}`),{serverUrl:r,developmentKey:void 0,apiToken:a.apiToken,projectSlug:a.projectSlug,environmentSlug:a.environmentSlug}}).with({developmentKey:p.union(void 0,""),projectSlug:p.union(void 0,"")},()=>R,()=>{throw Error(`phoenix dev does not know which project to develop in. Add \`project: ${g}\` to spec/application.yaml to use the default project of the workspace you are signed in to, or paste the .env block of a Studio development environment into .env. Pass --local to use the local-mode server.`)}).otherwise(()=>{throw Error("phoenix dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.")});if(!L)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!I)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let N={sdkVersion:eu.version,projectSlug:L,environmentSlug:I,cliUseWorkspace:t.workspace,enableEditor:a,editorWsPort:s,debug:r,withLingui:c,persistenceMode:u,force:l,tui:v,serverUrl:U,skipUpload:t.skipUpload??i.SKIP_UPLOAD};if(R){let e=P?{developmentKey:P}:b?{apiToken:b}:void 0;await k({...N,credential:e},{logger:n})}else await y.runDevCommand({...N,developmentKey:P},{logger:n})}).command(["link","l"],"Link local SDK for development",e=>e.option("sdk-path",{type:"string",description:"Path to the SDK repository",default:"../configurator-phoenix"}),async e=>{let o=el();await M({sdkPath:e.sdkPath},{logger:o})}).command(["unlink","ul"],"Remove local SDK linking",()=>{},async()=>{let e=el();await Q({logger:e})}).command(["sync","s"],"Sync project files and compile specs without building vite/webhooks",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("analyze",{alias:"a",type:"boolean",description:"Print pipeline metrics flamegraph after build (requires --applicationSpec)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),FORCE_REBUILD:e({default:!1})})(),r=el({debug:t.debug??i.DEBUG}),n=es(t.editor,i.ENABLE_EDITOR),a=t.force??i.FORCE_REBUILD,s=await eE(),l=ed(t.applicationSpec,s.applicationFlow,{logger:r}),p=t.projectSlug??i.PROJECT_SLUG??s.name,d=t.environmentSlug??i.ENVIRONMENT_SLUG??s.name;if(!p)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!d)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (l?z:y.runSyncCommand)({sdkVersion:eu.version,projectSlug:p,environmentSlug:d,cliUseWorkspace:t.workspace,enableEditor:n,force:a,analyze:t.analyze},{logger:r})}).command("init [folder]","Start a Phoenix project: write package.json when the folder has none, a starter spec and pnpm-workspace.yaml with the pnpm settings the install needs. Continue with phoenix sync, phoenix login and phoenix dev",e=>e.positional("folder",{type:"string",description:"Folder to create the project in (default: the working directory)"}).option("scaffold",{type:"boolean",hidden:!0,description:"Accepted for compatibility and ignored: init always only writes the starter project"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}),async e=>{let o=el({debug:e.debug??!1});try{await K({sdkVersion:eu.version,projectRoot:void 0===e.folder?void 0:l(e.folder)},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["story","st"],"Storybook example utilities",e=>X(e),()=>{}).command(["check","c"],"Run checks (TypeScript, ESLint, Prettier). Runs all by default, or only selected when any of --types/--lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("types",{type:"boolean",description:"Run TypeScript check"}).option("lint",{type:"boolean",description:"Run ESLint check"}).option("format",{type:"boolean",description:"Run Prettier check"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=el({debug:o.debug??t.DEBUG});await P({types:o.types,lint:o.lint,format:o.format},{logger:i})}).command(["fix","f"],"Fix linting and formatting issues. Runs all by default, or only selected when any of --lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("lint",{type:"boolean",description:"Run ESLint fix"}).option("format",{type:"boolean",description:"Run Prettier fix"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=el({debug:o.debug??t.DEBUG});await A({lint:o.lint,format:o.format},{logger:i})}).command(["changelog","clog"],"Display SDK changelog",e=>e.option("ver",{type:"string",description:"Show specific version (e.g., 0.36.0)"}).option("all",{alias:"a",type:"boolean",description:"Show all versions (warning: large output)"}).option("page",{alias:"p",type:"number",description:"Page number (3 versions per page)"}).option("list",{alias:"l",type:"boolean",description:"List version numbers only"}),async e=>{let o=el();await U({version:e.ver,all:e.all,page:e.page,list:e.list},{logger:o})}).command(["inspect:assets","ia"],"Inspect 3D assets (glTF/GLB) — nodes, transforms, bounds, origin, materials, morph targets, animations",e=>e.option("file",{alias:"f",type:"string",description:"Path to specific glTF/GLB file"}).option("objects",{alias:"O",type:"boolean",description:"Show only object/node names"}).option("materials",{alias:"m",type:"boolean",description:"Show only material names"}).option("morphs",{alias:"M",type:"boolean",description:"Show only morph target names"}).option("animations",{alias:"a",type:"boolean",description:"Show only animation names"}).option("json",{alias:"j",type:"boolean",description:"Output as JSON"}),async e=>{let o=el();await V({file:e.file,objects:e.objects,materials:e.materials,morphs:e.morphs,animations:e.animations,json:e.json},{logger:o})}).command(["screenshot","ss"],"Capture a screenshot of the configurator canvas",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (defaults to SCREENSHOT_OUTPUT env or ./screenshot.png)"}).option("width",{alias:"w",type:"number",description:"Width in pixels (default: 1920)"}).option("height",{alias:"H",type:"number",description:"Height in pixels (default: 1080)"}).option("format",{alias:"f",type:"string",description:"Image format: PNG or JPEG (default: PNG)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"}),SCREENSHOT_OUTPUT:o({default:"./screenshot.png"})})(),i=el();await W({port:e.port??t.EDITOR_WS_PORT,output:e.output??t.SCREENSHOT_OUTPUT,width:e.width,height:e.height,format:e.format},{logger:i})}).command("variants [directory]","Show the options of a .phoenix/variants/<name>/ folder over the configurator and wait for the answer",e=>e.positional("directory",{type:"string",description:"Folder below .phoenix/variants/ holding one .variant.js script per option"}).option("title",{alias:"t",type:"string",description:"Question shown above the options"}).option("description",{alias:"d",type:"string",description:"A line under the question saying what differs between the options"}).option("timeout",{type:"number",description:'Seconds to wait for the answer before exiting with status "waiting" (default: 540)'}).option("keep",{type:"boolean",description:"Keep the folder after the answer instead of removing it"}).option("close",{type:"boolean",description:"Close the open preview without waiting for an answer; the folder is kept"}).option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=el();await Z({directory:e.directory,title:e.title,description:e.description,timeout:e.timeout,keep:e.keep,close:e.close,port:e.port??t.EDITOR_WS_PORT},{logger:i})}).command(["inspect:state","is"],"Get the current editor state as JSON (entities, navigation, validation)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("sections",{alias:"s",type:"string",description:"Comma-separated sections: entities,navigation,validation (default: all)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=el();await $({port:e.port??t.EDITOR_WS_PORT,output:e.output,sections:e.sections,pretty:e.pretty},{logger:i})}).command(["inspect:data","id"],"Get the current editor context data as JSON (published, frontend, backend, session, access, web component)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=el();await N({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["inspect:scene","isc"],"Get the current Three.js scene graph as JSON",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=el();await H({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["docs","doc"],"Browse SDK documentation",e=>e.option("read",{alias:"r",type:"string",description:"Read a specific doc file (e.g., docs/phoenix/admin.mdx)"}).option("category",{alias:"c",type:"string",description:"Show all docs in a category"}).option("list",{alias:"l",type:"boolean",description:"List all docs with paths and titles"}).option("search",{alias:"s",type:"string",description:"Search doc content for a term (case-insensitive)"}).option("dir",{type:"boolean",description:"Print the absolute path of the docs directory"}),async e=>{let o=el();await D({read:e.read,category:e.category,list:e.list,search:e.search,dir:e.dir},{logger:o})}).command(["prepare:ci","pci","ci"],"Prepare CI environment by copying .env.ci to .env",()=>{},async()=>{let e=el();await x({logger:e})}).command({command:"environment:create",aliases:["env:create"],describe:"Create a new deployment environment",deprecated:"Switch to a new workflow and use deployment:prepare instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("name",{alias:"n",type:"string",description:"Name of the environment to be created"}).option("slug",{type:"string",description:"Slug of the customer to be created"}).option("uuid",{alias:"u",type:"string",description:"UUID of the environment to be created"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment UUID to",default:".env.generated"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=el({debug:i});await I({server:o.server,apiKey:o.apiKey,name:o.name,slug:o.slug,uuid:o.uuid,outFile:o.outFile,debug:i},{logger:r})}}).command({command:"environment:list",aliases:["env:list"],describe:"List all deployment environments",deprecated:"Switch to a new workflow and use the prepare environment flow instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=el({debug:i});await J({server:o.server,apiKey:o.apiKey,debug:i},{logger:r})}}).command(["environment:cleanup","env:cleanup","ec"],"Cleanup a transient deployment environment",e=>e.option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Project slug (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Environment slug (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write cleanup result env variables to (env: OUT_FILE, default: .env.generated)",default:".env.generated"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),OUT_FILE:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY,a=t.projectKey??i.PROJECT_KEY,s=t.projectSlug??i.PROJECT_SLUG,l=await eE(),p=t.environmentSlug??i.ENVIRONMENT_SLUG??l.name,d=t.serverUrl??i.SERVER_URL,c=t.outFile??i.OUT_FILE??".env.generated";if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");if(!p)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");if(!d)throw Error("Server URL is required, provide via --serverUrl or -su, or set SERVER_URL environment variable");let u=el({debug:r});await L({server:d,apiKey:n,projectKey:a,projectSlug:s,environmentSlug:p,debug:r,outFile:c},{logger:u})}).command(["login <customer>"],"Sign the CLI in to an SDK-builder workspace; you approve it in Studio",e=>e.positional("customer",{type:"string",demandOption:!0,description:"Slug of the SDK-builder workspace (customer)"}).option("region",{choices:et,description:`Phoenix region the workspace lives in (default: ${ee})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("studioUrl",{type:"string",description:"URL of Studio for the workspace, instead of the region default"}).option("open",{type:"boolean",default:!0,description:"Open the approval page in the default browser (--no-open to only print the link)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:eo,default:void 0})})(),i=e.region??t.PHOENIX_REGION??ee,r=el();try{await B({customer:e.customer,serverUrl:e.serverUrl??er(i),studioUrl:e.studioUrl??en(i,e.customer),open:e.open},{logger:r})}catch(e){r.error(ev(e)),process.exit(1)}}).command(["deploy"],"Upload this SDK-builder project and follow its build until it is live",e=>e.option("region",{choices:et,description:`Phoenix region the workspace lives in (default: ${ee})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("wait",{type:"boolean",default:!0,description:"Follow the build until it finishes (--no-wait to return once it starts)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:eo,default:void 0})})(),i=e.region??t.PHOENIX_REGION??ee,r=el();try{await T({serverUrl:e.serverUrl??er(i),sdkVersion:eu.version,wait:e.wait,projectDir:process.cwd(),pollIntervalMs:3e3},{logger:r})}catch(e){r.error(ev(e)),process.exit(1)}}).command(["logout"],"Revoke the API token of an SDK-builder workspace and forget it on this computer",e=>e.option("region",{choices:et,description:`Phoenix region to sign out of (default: ${ee})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:eo,default:void 0})})(),i=e.region??t.PHOENIX_REGION??ee,r=el();try{await F({serverUrl:e.serverUrl??er(i)},{logger:r})}catch(e){r.error(ev(e)),process.exit(1)}}).command(["feedback [message]"],"Send feedback about the SDK, CLI, docs or Studio to the Phoenix team",e=>e.positional("message",{type:"string",description:"What you want to tell the Phoenix team; leave it out when you pass --file"}).option("file",{type:"string",description:"Path of a text file that holds the message, for a long report instead of the argument"}).option("type",{choices:[m.Bug,m.Idea,m.Other],default:m.Other,description:"What the feedback is about"}).option("contact",{type:"string",description:"How to reach you, when you want a reply"}).option("agent",{type:"string",description:"Name of the coding agent that writes the feedback"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the workspace project the feedback is about (env: PROJECT_SLUG, defaults to `project` of the application spec)"}).option("region",{choices:et,description:`Phoenix region the workspace lives in (default: ${ee})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:eo,default:void 0}),PROJECT_SLUG:o({default:void 0})})(),i=el(),a=e.region??t.PHOENIX_REGION??ee,s=e.projectSlug??t.PROJECT_SLUG,l=s?.length?s:await h(process.cwd()).catch(()=>{i.warn("The feedback is sent without a project, because `project` could not be read from the application spec. Pass --projectSlug to name the project.")});try{await G({serverUrl:e.serverUrl??er(a),message:e.message,file:e.file,type:e.type,contact:e.contact,agent:e.agent,project:l,sdkVersion:eu.version,clientInfo:`${n()} ${r()}, Node.js ${process.versions.node}`},{logger:i})}catch(e){i.error(ev(e)),process.exit(1)}}).command({command:"deployment:register",aliases:["dep:register","dr"],describe:"Register deployment configuration",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the deployment ID to",default:".env.generated"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip uploading assets",default:!1}).option("activate",{alias:"a",type:"boolean",description:"Activate deployment after registration",default:!0}).option("overrideSchema",{alias:"os",type:"boolean",description:"Override existing schema",default:!1}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=el({debug:i});await q({server:o.server,apiKey:o.apiKey,outFile:o.outFile,skipUpload:o.skipUpload,activate:o.activate,overrideSchema:o.overrideSchema,debug:i},{logger:r})}}).command({command:"deployment:activate",aliases:["dep:activate","da"],describe:"Activate a deployment",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("uuid",{alias:"u",type:"string",description:"UUID of the deployment to activate"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=el({debug:i});await _({server:o.server,apiKey:o.apiKey,uuid:o.uuid,debug:i},{logger:r})}}).command(["deployment:prepare","dep:prepare","dp"],"Prepare environment and register deployment (env: ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, PROJECT_REF, PROJECT_SHA, ENVIRONMENT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (will be created if it does not exist) (env: ENVIRONMENT_SLUG, required)"}).option("projectRef",{type:"string",description:"Source branch, tag, or ref recorded as deployment provenance (env: PROJECT_REF)"}).option("projectSha",{type:"string",description:"Full commit SHA of the checked-out project revision (env: PROJECT_SHA)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File to write upload links to (used by finish command) (default: .upload-links.json)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),PROJECT_REF:o({default:void 0}),PROJECT_SHA:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!1}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY;if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let a=t.projectKey??i.PROJECT_KEY;if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let s=t.projectSlug??i.PROJECT_SLUG;if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let l=t.environmentSlug??i.ENVIRONMENT_SLUG;if(!l)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=await eE(),c=el({debug:r}),u=ed(t.applicationSpec,d.applicationFlow,{logger:c});await (u?Y:y.runPrepareDeploymentCommand)({apiKey:n,projectKey:a,projectSlug:s,projectRef:t.projectRef??i.PROJECT_REF,projectSha:t.projectSha??i.PROJECT_SHA,environmentSlug:l,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,uploadLinksFile:t.uploadLinksFile??".upload-links.json",serverUrl:p,debug:r,projectVersion:eu.version},{logger:c})}).command(["deployment:prepare-dev","dep:prepare-dev","dpd"],"Prepare a development deployment (env: SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, DEVELOPMENT_KEY, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required unless --local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the development environment (env: ENVIRONMENT_SLUG, required unless --local)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows overriding deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0})})(),r=t.debug??i.DEBUG,n=el({debug:r}),a=t.local??i.PHOENIX_LOCAL,s=i.SERVER_URL,l=t.projectSlug??i.PROJECT_SLUG,p=t.environmentSlug??i.ENVIRONMENT_SLUG,d=i.DEVELOPMENT_KEY;if(a&&(s=s?.length?s:"http://localhost:3000",l=l?.length?l:"local",p=p?.length?p:"dev-local",d=d?.length?d:"dev_local-dev-key-12345"),!s||!l||!p||!d)throw Error("phoenix deployment:prepare-dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.");let c=await eE(),u=ed(t.applicationSpec,c.applicationFlow,{logger:n}),E={serverUrl:s,projectSlug:l,environmentSlug:p,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,debug:r,projectVersion:eu.version};try{u?await R({...E,credential:{developmentKey:d}},{logger:n}):await y.prepareDevelopmentEnvironment({...E,developmentKey:d},{logger:n})}catch(e){n.error(`Development environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:prepare-local","dep:prepare-local","dpl"],"Prepare local environment for development (env: PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL, LAMBDA_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, default: local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, default: project name in package.json)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, default: http://localhost:3000)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Webhook URL (env: LAMBDA_URL, default: http://localhost:8080)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_SLUG:o({default:void 0}),PROJECT_KEY:o({default:"project_local-dev-key-12345"}),PROJECT_SLUG:o({default:"local"}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0}),SERVER_URL:o({default:"http://localhost:3000"}),LAMBDA_URL:o({default:"http://localhost:8080"}),ENVIRONMENT_API_KEY:o({default:"local-dev-key-12345"})})(),r=t.debug??i.DEBUG,n=t.projectKey??i.PROJECT_KEY;if(!n)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let a=await eE(),s=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!s)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let l=t.apiKey??i.ENVIRONMENT_API_KEY;if(!l)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let p=el({debug:r}),d=ed(t.applicationSpec,a.applicationFlow,{logger:p});try{await (d?S:y.prepareLocalEnvironment)({apiKey:l,projectKey:n,projectSlug:t.projectSlug??i.PROJECT_SLUG,environmentSlug:s,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,serverUrl:t.serverUrl??i.SERVER_URL,lambdaUrl:t.lambdaUrl??i.LAMBDA_URL,debug:r,projectVersion:eu.version},{logger:p})}catch(e){p.error(`Local environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:extract-sources <archive> <folder>"],"Validate the source archive of a phoenix deploy and extract its project files into a new folder. Links, special files, unsafe paths and oversized content are refused; entries that are not project files are left out",e=>e.positional("archive",{type:"string",demandOption:!0,description:"The source archive (.tgz)"}).positional("folder",{type:"string",demandOption:!0,description:"New or empty folder to extract the project files into"}),async e=>{let o=el();try{await j({archivePath:e.archive,targetDir:e.folder},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["deployment:build-envs","dep:build-envs","dbe"],"Write the environment variables for the build step of a prepared deployment that builds apart from its deploy (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SERVER_URL)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the prepared deployment (env: DEPLOYMENT_ID, required)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=el({debug:r});await w({uuid:n,apiKey:a,projectKey:s,projectSlug:l,outFile:t.outFile??i.OUT_FILE,serverUrl:p,debug:r},{logger:d})}).command(["deployment:finish","dep:finish","df"],"Upload files to S3 and activate deployment (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, LAMBDA_URL, SERVER_URL, SKIP_UPLOAD)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the deployment to be activated (env: DEPLOYMENT_ID, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File containing upload links (generated by prepare command) (default: .upload-links.json)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Lambda webhook URL for the deployment (env: LAMBDA_URL, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),LAMBDA_URL:o({default:void 0}),SERVER_URL:o({default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.lambdaUrl??i.LAMBDA_URL;if(!p)throw Error("Lambda URL is required, provide via --lambdaUrl or -l, or set LAMBDA_URL environment variable");let d=t.serverUrl??i.SERVER_URL;if(!d)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let c=el({debug:r});await C({uuid:n,uploadLinksFile:t.uploadLinksFile??".upload-links.json",apiKey:a,projectKey:s,projectSlug:l,lambdaUrl:p,serverUrl:d,skipUpload:t.skipUpload??i.SKIP_UPLOAD,debug:r},{logger:c})}).demandCommand(1,"Please specify a command").help().alias("help","h").version(eu.version).alias("version","v").strict().parse();
2
+ import{bool as e,str as o}from"envalid";import{readFileSync as t}from"fs";import{readFile as i}from"fs/promises";import{arch as r,platform as n}from"os";import{dirname as a,join as s,resolve as l}from"path";import{P as p,match as d}from"ts-pattern";import{fileURLToPath as c}from"url";import u from"yargs";import{hideBin as E}from"yargs/helpers";import{z as v}from"zod";import{createEnvReader as f}from"@salsita-ai/common/env";import{DEFAULT_PROJECT_ALIAS as g,FeedbackType as m}from"@salsita-ai/contracts/domain";import{phoenixCli as h}from"#package/legacy";import{readSpecProject as y}from"./application-spec/read-spec-project.js";import{prepareDevelopmentEnvironment as R,prepareLocalEnvironment as S,runActivateDeploymentCommand as _,runBuildCommand as O,runChangelogCommand as U,runCheckCommand as P,runCleanCommand as b,runCleanupEnvironmentCommand as L,runCreateEnvironmentCommand as I,runDataCommand as N,runDeployCommand as T,runDeploymentBuildEnvsCommand as w,runDepsCommand as k,runDevCommand as D,runDocsCommand as j,runExtractSourcesCommand as C,runFeedbackCommand as G,runFinishDeploymentCommand as A,runFixCommand as K,runInitCommand as V,runInspectAssetsCommand as M,runLinkCommand as J,runListEnvironmentsCommand as B,runLoginCommand as F,runLogoutCommand as x,runPrepareCiCommand as Y,runPrepareDeploymentCommand as q,runRegisterDeploymentCommand as H,runSceneCommand as W,runScreenshotCommand as $,runStateCommand as X,runStoryCommand as z,runSyncCommand as Q,runUnlinkCommand as Z,runVariantsCommand as ee}from"./commands/index.js";import{DEFAULT_PHOENIX_REGION as eo,PHOENIX_REGIONS as et,PUBLIC_PHOENIX_REGIONS as ei,VariantFileSession as er,getRegionServerUrl as en,getRegionStudioUrl as ea,resolveSignedInDevelopmentEnvironment as es}from"./services/index.js";import{getIsEditorEnabled as el}from"./utils/get-is-editor-enabled.js";import{createLogger as ep}from"./utils/index.js";let ed=(e,o,t)=>{e?.info(`Using ${o?"application-spec":"domain-spec"} flow (${t})`)},ec=(e,o,t)=>{let i=t?.logger??ep();if(void 0!==e)return i.detail(`Application spec: ${e} (from CLI flag)`),ed(t?.logger,e,"from CLI flag"),e;let r=process.env.USE_APPLICATION_SPEC;if(void 0!==r){let e="true"===r||"1"===r;return i.detail(`Application spec: ${e} (from environment variable)`),ed(t?.logger,e,"from environment variable"),e}return void 0!==o?(i.detail(`Application spec: ${o} (from package.json phoenix.applicationFlow)`),ed(t?.logger,o,"from package.json phoenix.applicationFlow"),o):(i.detail("Application spec: false (default)"),ed(t?.logger,!1,"default"),!1)},eu=t(s(a(c(import.meta.url)),"../../package.json"),"utf-8");if(!eu)throw Error("Project package.json is required, please provide it in the package.json file");let eE=v.object({version:v.string({required_error:"Project version is required, please provide it in the package.json file"}),name:v.string({required_error:"Project name is required, please provide it in the package.json file"})}).parse(JSON.parse(eu)),ev=async()=>{try{let e=await i("./package.json","utf-8"),o=JSON.parse(e);return{name:o.name,applicationFlow:o.phoenix?.applicationFlow}}catch{return{name:void 0,applicationFlow:void 0}}},ef=e=>{if(!(e instanceof Error))return String(e);let o=(e=>{if(!(e instanceof Error))return;if(e.message.length>0)return e.message;let o=(e instanceof AggregateError?e.errors:[]).find(e=>e instanceof Error&&e.message.length>0);return o instanceof Error?o.message:"code"in e&&"string"==typeof e.code?e.code:void 0})(e.cause);return void 0===o?e.message:`${e.message}: ${o}`};await u(E(process.argv)).scriptName("phoenix").usage("$0 <command> [options]").command(["build","b"],"Build the project",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("onlyFrontend",{alias:"F",type:"boolean",description:"Build only frontend bundle"}).option("onlyWebhook",{alias:"W",type:"boolean",description:"Build only webhooks"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("banner",{type:"string",requiresArg:!0,description:"Text for the comment at the top of every frontend .js file, public in the bundle (default: application version from the spec and the git commit when available)",coerce:e=>"string"==typeof e?e:e.join("\n")}),async t=>{let i,r=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),BUILD_TARGET:o({choices:["frontend","webhook","both"],default:"both"}),FORCE_REBUILD:e({default:!1})})(),n=ep({debug:t.debug??r.DEBUG}),a=el(t.editor,r.ENABLE_EDITOR),s=t.force??r.FORCE_REBUILD,l=await ev(),p=ec(t.applicationSpec,l.applicationFlow,{logger:n}),d=t.projectSlug??r.PROJECT_SLUG??l.name,c=t.environmentSlug??r.ENVIRONMENT_SLUG??l.name;if(!d)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!c)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let u=t.onlyFrontend,E=t.onlyWebhook;if(u&&E)throw Error("Cannot use --onlyFrontend and --onlyWebhook flags together, they are mutually exclusive");i=u?"frontend":E?"webhook":r.BUILD_TARGET;let v={sdkVersion:eE.version,projectSlug:d,environmentSlug:c,cliUseWorkspace:t.workspace,enableEditor:a,buildTarget:i,force:s};await (p?O({...v,banner:t.banner},{logger:n}):h.runBuildCommand(v,{logger:n}))}).command(["clean","cl"],"Clean build artifacts, reinstall dependencies, and rebuild specs",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1})})(),r=ep({debug:t.debug??i.DEBUG}),n=el(t.editor,i.ENABLE_EDITOR),a=await ev(),s=ec(t.applicationSpec,a.applicationFlow,{logger:r}),l=t.projectSlug??i.PROJECT_SLUG??a.name,p=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!l)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!p)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (s?b:h.runCleanCommand)({sdkVersion:eE.version,projectSlug:l,environmentSlug:p,cliUseWorkspace:t.workspace,enableEditor:n},{logger:r})}).command(["dev","d"],"Start development mode (Vite, spec watching, and the webhook tunnel)",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("editorWsPort",{alias:"ep",type:"string",description:"Port for the editor WebSocket server (defaults to EDITOR_WS_PORT env or 3020)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG; required in server mode unless --local; offline modes default to the package name)"}).option("withLingui",{alias:"wl",type:"boolean",description:"Enable or disable i18n messages extraction and compilation (defaults to WITH_LINGUI env or false)"}).option("persistence",{alias:"P",type:"string",description:"Persistence mode for the configurator (defaults to PERSISTENCE_MODE env or server)",choices:["memory","local-storage","server"]}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("tui",{alias:"T",type:"boolean",description:"Render logs in a terminal UI with per-stream pages and split view; requires an interactive terminal (env: PHOENIX_TUI, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}).option("region",{choices:ei,description:`Phoenix region of the workspace you are signed in to, used when .env has no SERVER_URL (default: ${eo})`}).option("serverUrl",{type:"string",description:"URL of the Phoenix server, instead of SERVER_URL or the region default"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket when the development deployment is prepared (env: SKIP_UPLOAD, default: false)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),EDITOR_WS_PORT:o({default:"3020"}),DEBUG:e({default:!1}),WITH_LINGUI:e({default:!1}),PERSISTENCE_MODE:o({default:void 0}),FORCE_REBUILD:e({default:!1}),PHOENIX_TUI:e({default:!1}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),PHOENIX_REGION:o({choices:et,default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=ep({debug:r}),a=el(t.editor,i.ENABLE_EDITOR),s=t.editorWsPort??i.EDITOR_WS_PORT,l=t.force??i.FORCE_REBUILD,c=t.withLingui??i.WITH_LINGUI,u=t.persistence??i.PERSISTENCE_MODE,E=!u||"server"===u,v=t.tui??i.PHOENIX_TUI,m=await ev(),R=ec(t.applicationSpec,m.applicationFlow,{logger:n}),S=t.local??i.PHOENIX_LOCAL,_=t.projectSlug??i.PROJECT_SLUG;R&&await er.recover(process.cwd(),n);let O=E&&R&&!S&&!_?.length?await y(process.cwd()):void 0,{serverUrl:U,developmentKey:P,apiToken:b,projectSlug:L,environmentSlug:I}=await d({useServer:E,local:S,serverUrl:t.serverUrl??i.SERVER_URL,developmentKey:i.DEVELOPMENT_KEY,projectSlug:_?.length?_:O,environmentSlug:t.environmentSlug??i.ENVIRONMENT_SLUG}).with({useServer:!1},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t??m.name,environmentSlug:i??m.name})).with({local:!0},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e?.length?e:"http://localhost:3000",developmentKey:o?.length?o:"dev_local-dev-key-12345",apiToken:void 0,projectSlug:t?.length?t:"local",environmentSlug:i?.length?i:"dev-local"})).with({developmentKey:p.string.minLength(1)},()=>O===g,()=>{throw Error(`phoenix dev has a DEVELOPMENT_KEY, but the spec says \`project: ${g}\`, which only a signed-in workspace can resolve. Set PROJECT_SLUG in .env by pasting the .env block of your Studio development environment, or name the project's slug in the spec.`)}).with({serverUrl:p.string.minLength(1),developmentKey:p.string.minLength(1),projectSlug:p.string.minLength(1),environmentSlug:p.string.minLength(1)},async({serverUrl:e,developmentKey:o,projectSlug:t,environmentSlug:i})=>({serverUrl:e,developmentKey:o,apiToken:void 0,projectSlug:t,environmentSlug:i})).with({developmentKey:p.union(void 0,""),projectSlug:p.string.minLength(1)},()=>R,async({serverUrl:e,projectSlug:o})=>{let r=e?.length?e:en(t.region??i.PHOENIX_REGION??eo),a=await es({serverUrl:r,project:o});return n.info(`Developing in ${a.projectSlug}/${a.environmentSlug} of workspace "${a.workspaceName}" on ${r}`),{serverUrl:r,developmentKey:void 0,apiToken:a.apiToken,projectSlug:a.projectSlug,environmentSlug:a.environmentSlug}}).with({developmentKey:p.union(void 0,""),projectSlug:p.union(void 0,"")},()=>R,()=>{throw Error(`phoenix dev does not know which project to develop in. Add \`project: ${g}\` to spec/application.yaml to use the default project of the workspace you are signed in to, or paste the .env block of a Studio development environment into .env. Pass --local to use the local-mode server.`)}).otherwise(()=>{throw Error("phoenix dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.")});if(!L)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!I)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");let N={sdkVersion:eE.version,projectSlug:L,environmentSlug:I,cliUseWorkspace:t.workspace,enableEditor:a,editorWsPort:s,debug:r,withLingui:c,persistenceMode:u,force:l,tui:v,serverUrl:U,skipUpload:t.skipUpload??i.SKIP_UPLOAD};if(R){let e=P?{developmentKey:P}:b?{apiToken:b}:void 0;await D({...N,credential:e},{logger:n})}else await h.runDevCommand({...N,developmentKey:P},{logger:n})}).command(["link","l"],"Link local SDK for development",e=>e.option("sdk-path",{type:"string",description:"Path to the SDK repository",default:"../configurator-phoenix"}),async e=>{let o=ep();await J({sdkPath:e.sdkPath},{logger:o})}).command(["unlink","ul"],"Remove local SDK linking",()=>{},async()=>{let e=ep();await Z({logger:e})}).command(["sync","s"],"Sync project files and compile specs without building vite/webhooks",e=>e.option("workspace",{alias:"w",type:"boolean",description:"Override workspace mode (uses .phoenix.json config by default)"}).option("editor",{type:"boolean",description:"Enable or disable editor files generation (defaults to ENABLE_EDITOR env or true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, defaults to project name in package.json)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("force",{alias:"f",type:"boolean",description:"Force full rebuild, skip cache (env: FORCE_REBUILD, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("analyze",{alias:"a",type:"boolean",description:"Print pipeline metrics flamegraph after build (requires --applicationSpec)"}),async t=>{let i=f({ENABLE_EDITOR:e({default:!0}),DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),FORCE_REBUILD:e({default:!1})})(),r=ep({debug:t.debug??i.DEBUG}),n=el(t.editor,i.ENABLE_EDITOR),a=t.force??i.FORCE_REBUILD,s=await ev(),l=ec(t.applicationSpec,s.applicationFlow,{logger:r}),p=t.projectSlug??i.PROJECT_SLUG??s.name,d=t.environmentSlug??i.ENVIRONMENT_SLUG??s.name;if(!p)throw Error("Project slug is required, provide via --projectSlug, set PROJECT_SLUG env, or ensure package.json has a name field");if(!d)throw Error("Environment slug is required, provide via --environmentSlug, set ENVIRONMENT_SLUG env, or ensure package.json has a name field");await (l?Q:h.runSyncCommand)({sdkVersion:eE.version,projectSlug:p,environmentSlug:d,cliUseWorkspace:t.workspace,enableEditor:n,force:a,analyze:t.analyze},{logger:r})}).command(["deps"],"Bring package.json in line with the SDK's peer dependencies: add the missing ones and move out-of-range versions into the SDK's range. Installs nothing; run pnpm install next",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async e=>{let o=ep({debug:e.debug??!1}),t=await ev();if(!ec(e.applicationSpec,t.applicationFlow,{logger:o}))return void o.info("phoenix deps changes nothing in a legacy project: phoenix sync manages its dependencies. Switch the project to the application-spec pipeline (phoenix.applicationFlow in package.json) to manage them with phoenix deps.");try{await k({projectRoot:process.cwd()},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command("init [folder]","Start a Phoenix project: write package.json when the folder has none, a starter spec and pnpm-workspace.yaml with the pnpm settings the install needs. Continue with phoenix sync, phoenix login and phoenix dev",e=>e.positional("folder",{type:"string",description:"Folder to create the project in (default: the working directory)"}).option("scaffold",{type:"boolean",hidden:!0,description:"Accepted for compatibility and ignored: init always only writes the starter project"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging"}),async e=>{let o=ep({debug:e.debug??!1});try{await V({sdkVersion:eE.version,projectRoot:void 0===e.folder?void 0:l(e.folder)},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["story","st"],"Storybook example utilities",e=>z(e),()=>{}).command(["check","c"],"Run checks (TypeScript, ESLint, Prettier). Runs all by default, or only selected when any of --types/--lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("types",{type:"boolean",description:"Run TypeScript check"}).option("lint",{type:"boolean",description:"Run ESLint check"}).option("format",{type:"boolean",description:"Run Prettier check"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=ep({debug:o.debug??t.DEBUG});await P({types:o.types,lint:o.lint,format:o.format},{logger:i})}).command(["fix","f"],"Fix linting and formatting issues. Runs all by default, or only selected when any of --lint/--format is passed.",e=>e.option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("lint",{type:"boolean",description:"Run ESLint fix"}).option("format",{type:"boolean",description:"Run Prettier fix"}),async o=>{let t=f({DEBUG:e({default:!1})})(),i=ep({debug:o.debug??t.DEBUG});await K({lint:o.lint,format:o.format},{logger:i})}).command(["changelog","clog"],"Display SDK changelog",e=>e.option("ver",{type:"string",description:"Show specific version (e.g., 0.36.0)"}).option("all",{alias:"a",type:"boolean",description:"Show all versions (warning: large output)"}).option("page",{alias:"p",type:"number",description:"Page number (3 versions per page)"}).option("list",{alias:"l",type:"boolean",description:"List version numbers only"}),async e=>{let o=ep();await U({version:e.ver,all:e.all,page:e.page,list:e.list},{logger:o})}).command(["inspect:assets","ia"],"Inspect 3D assets (glTF/GLB) — nodes, transforms, bounds, origin, materials, morph targets, animations",e=>e.option("file",{alias:"f",type:"string",description:"Path to specific glTF/GLB file"}).option("objects",{alias:"O",type:"boolean",description:"Show only object/node names"}).option("materials",{alias:"m",type:"boolean",description:"Show only material names"}).option("morphs",{alias:"M",type:"boolean",description:"Show only morph target names"}).option("animations",{alias:"a",type:"boolean",description:"Show only animation names"}).option("json",{alias:"j",type:"boolean",description:"Output as JSON"}),async e=>{let o=ep();await M({file:e.file,objects:e.objects,materials:e.materials,morphs:e.morphs,animations:e.animations,json:e.json},{logger:o})}).command(["screenshot","ss"],"Capture a screenshot of the configurator canvas",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (defaults to SCREENSHOT_OUTPUT env or ./screenshot.png)"}).option("width",{alias:"w",type:"number",description:"Width in pixels (default: 1920)"}).option("height",{alias:"H",type:"number",description:"Height in pixels (default: 1080)"}).option("format",{alias:"f",type:"string",description:"Image format: PNG or JPEG (default: PNG)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"}),SCREENSHOT_OUTPUT:o({default:"./screenshot.png"})})(),i=ep();await $({port:e.port??t.EDITOR_WS_PORT,output:e.output??t.SCREENSHOT_OUTPUT,width:e.width,height:e.height,format:e.format},{logger:i})}).command("variants [directory]","Show the options of a .phoenix/variants/<name>/ folder over the configurator and wait for the answer",e=>e.positional("directory",{type:"string",description:"Folder below .phoenix/variants/ holding one .variant.js script per option"}).option("title",{alias:"t",type:"string",description:"Question shown above the options"}).option("description",{alias:"d",type:"string",description:"A line under the question saying what differs between the options"}).option("timeout",{type:"number",description:'Seconds to wait for the answer before exiting with status "waiting" (default: 540)'}).option("keep",{type:"boolean",description:"Keep the folder after the answer instead of removing it"}).option("close",{type:"boolean",description:"Close the open preview without waiting for an answer; the folder is kept"}).option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await ee({directory:e.directory,title:e.title,description:e.description,timeout:e.timeout,keep:e.keep,close:e.close,port:e.port??t.EDITOR_WS_PORT},{logger:i})}).command(["inspect:state","is"],"Get the current editor state as JSON (entities, navigation, validation)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("sections",{alias:"s",type:"string",description:"Comma-separated sections: entities,navigation,validation (default: all)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await X({port:e.port??t.EDITOR_WS_PORT,output:e.output,sections:e.sections,pretty:e.pretty},{logger:i})}).command(["inspect:data","id"],"Get the current editor context data as JSON (published, frontend, backend, session, access, web component)",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await N({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["inspect:scene","isc"],"Get the current Three.js scene graph as JSON",e=>e.option("port",{alias:"p",type:"string",description:"WebSocket server port (defaults to EDITOR_WS_PORT env or 3020)"}).option("output",{alias:"o",type:"string",description:"Output file path (prints to stdout if omitted)"}).option("pretty",{alias:"P",type:"boolean",description:"Pretty-print JSON output (default: true)",default:!0}),async e=>{let t=f({EDITOR_WS_PORT:o({default:"3020"})})(),i=ep();await W({port:e.port??t.EDITOR_WS_PORT,output:e.output,pretty:e.pretty},{logger:i})}).command(["docs","doc"],"Browse SDK documentation",e=>e.option("read",{alias:"r",type:"string",description:"Read a specific doc file (e.g., docs/phoenix/admin.mdx)"}).option("category",{alias:"c",type:"string",description:"Show all docs in a category"}).option("list",{alias:"l",type:"boolean",description:"List all docs with paths and titles"}).option("search",{alias:"s",type:"string",description:"Search doc content for a term (case-insensitive)"}).option("dir",{type:"boolean",description:"Print the absolute path of the docs directory"}),async e=>{let o=ep();await j({read:e.read,category:e.category,list:e.list,search:e.search,dir:e.dir},{logger:o})}).command(["prepare:ci","pci","ci"],"Prepare CI environment by copying .env.ci to .env",()=>{},async()=>{let e=ep();await Y({logger:e})}).command({command:"environment:create",aliases:["env:create"],describe:"Create a new deployment environment",deprecated:"Switch to a new workflow and use deployment:prepare instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("name",{alias:"n",type:"string",description:"Name of the environment to be created"}).option("slug",{type:"string",description:"Slug of the customer to be created"}).option("uuid",{alias:"u",type:"string",description:"UUID of the environment to be created"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment UUID to",default:".env.generated"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await I({server:o.server,apiKey:o.apiKey,name:o.name,slug:o.slug,uuid:o.uuid,outFile:o.outFile,debug:i},{logger:r})}}).command({command:"environment:list",aliases:["env:list"],describe:"List all deployment environments",deprecated:"Switch to a new workflow and use the prepare environment flow instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await B({server:o.server,apiKey:o.apiKey,debug:i},{logger:r})}}).command(["environment:cleanup","env:cleanup","ec"],"Cleanup a transient deployment environment",e=>e.option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Project slug (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Environment slug (env: ENVIRONMENT_SLUG, defaults to project name in package.json)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write cleanup result env variables to (env: OUT_FILE, default: .env.generated)",default:".env.generated"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),OUT_FILE:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY,a=t.projectKey??i.PROJECT_KEY,s=t.projectSlug??i.PROJECT_SLUG,l=await ev(),p=t.environmentSlug??i.ENVIRONMENT_SLUG??l.name,d=t.serverUrl??i.SERVER_URL,c=t.outFile??i.OUT_FILE??".env.generated";if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");if(!p)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");if(!d)throw Error("Server URL is required, provide via --serverUrl or -su, or set SERVER_URL environment variable");let u=ep({debug:r});await L({server:d,apiKey:n,projectKey:a,projectSlug:s,environmentSlug:p,debug:r,outFile:c},{logger:u})}).command(["login <customer>"],"Sign the CLI in to an SDK-builder workspace; you approve it in Studio",e=>e.positional("customer",{type:"string",demandOption:!0,description:"Slug of the SDK-builder workspace (customer)"}).option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("studioUrl",{type:"string",description:"URL of Studio for the workspace, instead of the region default"}).option("open",{type:"boolean",default:!0,description:"Open the approval page in the default browser (--no-open to only print the link)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await F({customer:e.customer,serverUrl:e.serverUrl??en(i),studioUrl:e.studioUrl??ea(i,e.customer),open:e.open},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["deploy"],"Upload this SDK-builder project and follow its build until it is live",e=>e.option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}).option("wait",{type:"boolean",default:!0,description:"Follow the build until it finishes (--no-wait to return once it starts)"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await T({serverUrl:e.serverUrl??en(i),sdkVersion:eE.version,wait:e.wait,projectDir:process.cwd(),pollIntervalMs:3e3},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["logout"],"Revoke the API token of an SDK-builder workspace and forget it on this computer",e=>e.option("region",{choices:ei,description:`Phoenix region to sign out of (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0})})(),i=e.region??t.PHOENIX_REGION??eo,r=ep();try{await x({serverUrl:e.serverUrl??en(i)},{logger:r})}catch(e){r.error(ef(e)),process.exit(1)}}).command(["feedback [message]"],"Send feedback about the SDK, CLI, docs or Studio to the Phoenix team",e=>e.positional("message",{type:"string",description:"What you want to tell the Phoenix team; leave it out when you pass --file"}).option("file",{type:"string",description:"Path of a text file that holds the message, for a long report instead of the argument"}).option("type",{choices:[m.Bug,m.Idea,m.Other],default:m.Other,description:"What the feedback is about"}).option("contact",{type:"string",description:"How to reach you, when you want a reply"}).option("agent",{type:"string",description:"Name of the coding agent that writes the feedback"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the workspace project the feedback is about (env: PROJECT_SLUG, defaults to `project` of the application spec)"}).option("region",{choices:ei,description:`Phoenix region the workspace lives in (default: ${eo})`}).option("serverUrl",{alias:"su",type:"string",description:"URL of the Phoenix server, instead of the region default"}),async e=>{let t=f({PHOENIX_REGION:o({choices:et,default:void 0}),PROJECT_SLUG:o({default:void 0})})(),i=ep(),a=e.region??t.PHOENIX_REGION??eo,s=e.projectSlug??t.PROJECT_SLUG,l=s?.length?s:await y(process.cwd()).catch(()=>{i.warn("The feedback is sent without a project, because `project` could not be read from the application spec. Pass --projectSlug to name the project.")});try{await G({serverUrl:e.serverUrl??en(a),message:e.message,file:e.file,type:e.type,contact:e.contact,agent:e.agent,project:l,sdkVersion:eE.version,clientInfo:`${n()} ${r()}, Node.js ${process.versions.node}`},{logger:i})}catch(e){i.error(ef(e)),process.exit(1)}}).command({command:"deployment:register",aliases:["dep:register","dr"],describe:"Register deployment configuration",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the deployment ID to",default:".env.generated"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip uploading assets",default:!1}).option("activate",{alias:"a",type:"boolean",description:"Activate deployment after registration",default:!0}).option("overrideSchema",{alias:"os",type:"boolean",description:"Override existing schema",default:!1}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await H({server:o.server,apiKey:o.apiKey,outFile:o.outFile,skipUpload:o.skipUpload,activate:o.activate,overrideSchema:o.overrideSchema,debug:i},{logger:r})}}).command({command:"deployment:activate",aliases:["dep:activate","da"],describe:"Activate a deployment",deprecated:"Switch to a new workflow and use deployment:prepare and deployment:finish instead",builder:e=>e.option("server",{alias:"s",type:"string",description:"URL of the Phoenix server (defaults to SERVER_URL env)"}).option("apiKey",{alias:"k",type:"string",description:"API key for server access (defaults to ENVIRONMENT_API_KEY env)"}).option("uuid",{alias:"u",type:"string",description:"UUID of the deployment to activate"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (defaults to DEBUG env or false)"}),handler:async o=>{let t=f({DEBUG:e({default:!1})})(),i=o.debug??t.DEBUG,r=ep({debug:i});await _({server:o.server,apiKey:o.apiKey,uuid:o.uuid,debug:i},{logger:r})}}).command(["deployment:prepare","dep:prepare","dp"],"Prepare environment and register deployment (env: ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, PROJECT_REF, PROJECT_SHA, ENVIRONMENT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (will be created if it does not exist) (env: ENVIRONMENT_SLUG, required)"}).option("projectRef",{type:"string",description:"Source branch, tag, or ref recorded as deployment provenance (env: PROJECT_REF)"}).option("projectSha",{type:"string",description:"Full commit SHA of the checked-out project revision (env: PROJECT_SHA)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File to write upload links to (used by finish command) (default: .upload-links.json)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),PROJECT_REF:o({default:void 0}),PROJECT_SHA:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!1}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.apiKey??i.ENVIRONMENT_API_KEY;if(!n)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let a=t.projectKey??i.PROJECT_KEY;if(!a)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let s=t.projectSlug??i.PROJECT_SLUG;if(!s)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let l=t.environmentSlug??i.ENVIRONMENT_SLUG;if(!l)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=await ev(),c=ep({debug:r}),u=ec(t.applicationSpec,d.applicationFlow,{logger:c});await (u?q:h.runPrepareDeploymentCommand)({apiKey:n,projectKey:a,projectSlug:s,projectRef:t.projectRef??i.PROJECT_REF,projectSha:t.projectSha??i.PROJECT_SHA,environmentSlug:l,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,uploadLinksFile:t.uploadLinksFile??".upload-links.json",serverUrl:p,debug:r,projectVersion:eE.version},{logger:c})}).command(["deployment:prepare-dev","dep:prepare-dev","dpd"],"Prepare a development deployment (env: SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, DEVELOPMENT_KEY, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required unless --local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the development environment (env: ENVIRONMENT_SLUG, required unless --local)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows overriding deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}).option("local",{type:"boolean",description:"Use local-mode development environment defaults (env: PHOENIX_LOCAL, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),PROJECT_SLUG:o({default:void 0}),ENVIRONMENT_SLUG:o({default:void 0}),SERVER_URL:o({default:void 0}),DEVELOPMENT_KEY:o({default:void 0}),PHOENIX_LOCAL:e({default:!1}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0})})(),r=t.debug??i.DEBUG,n=ep({debug:r}),a=t.local??i.PHOENIX_LOCAL,s=i.SERVER_URL,l=t.projectSlug??i.PROJECT_SLUG,p=t.environmentSlug??i.ENVIRONMENT_SLUG,d=i.DEVELOPMENT_KEY;if(a&&(s=s?.length?s:"http://localhost:3000",l=l?.length?l:"local",p=p?.length?p:"dev-local",d=d?.length?d:"dev_local-dev-key-12345"),!s||!l||!p||!d)throw Error("phoenix deployment:prepare-dev needs SERVER_URL, PROJECT_SLUG, ENVIRONMENT_SLUG, and DEVELOPMENT_KEY in .env. Create a development environment for your project in Studio and paste its .env block, or pass --local to use the local-mode server.");let c=await ev(),u=ec(t.applicationSpec,c.applicationFlow,{logger:n}),E={serverUrl:s,projectSlug:l,environmentSlug:p,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,debug:r,projectVersion:eE.version};try{u?await R({...E,credential:{developmentKey:d}},{logger:n}):await h.prepareDevelopmentEnvironment({...E,developmentKey:d},{logger:n})}catch(e){n.error(`Development environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:prepare-local","dep:prepare-local","dpl"],"Prepare local environment for development (env: PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SKIP_UPLOAD, OVERRIDE_SCHEMA, SERVER_URL, LAMBDA_URL)",e=>e.option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, default: local)"}).option("environmentSlug",{alias:"e",type:"string",description:"Slug of the environment (env: ENVIRONMENT_SLUG, default: project name in package.json)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("overrideSchema",{alias:"os",type:"boolean",description:"Allows to override deployment schemas (env: OVERRIDE_SCHEMA, default: true)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, default: http://localhost:3000)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Webhook URL (env: LAMBDA_URL, default: http://localhost:8080)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("applicationSpec",{alias:"as",type:"boolean",description:"Use application-spec pipeline (env: USE_APPLICATION_SPEC, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),ENVIRONMENT_SLUG:o({default:void 0}),PROJECT_KEY:o({default:"project_local-dev-key-12345"}),PROJECT_SLUG:o({default:"local"}),OUT_FILE:o({default:".env.generated"}),SKIP_UPLOAD:e({default:!1}),OVERRIDE_SCHEMA:e({default:!0}),SERVER_URL:o({default:"http://localhost:3000"}),LAMBDA_URL:o({default:"http://localhost:8080"}),ENVIRONMENT_API_KEY:o({default:"local-dev-key-12345"})})(),r=t.debug??i.DEBUG,n=t.projectKey??i.PROJECT_KEY;if(!n)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let a=await ev(),s=t.environmentSlug??i.ENVIRONMENT_SLUG??a.name;if(!s)throw Error("Environment slug is required, provide via --environmentSlug or -e, or set ENVIRONMENT_SLUG environment variable");let l=t.apiKey??i.ENVIRONMENT_API_KEY;if(!l)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let p=ep({debug:r}),d=ec(t.applicationSpec,a.applicationFlow,{logger:p});try{await (d?S:h.prepareLocalEnvironment)({apiKey:l,projectKey:n,projectSlug:t.projectSlug??i.PROJECT_SLUG,environmentSlug:s,outFile:t.outFile??i.OUT_FILE,skipUpload:t.skipUpload??i.SKIP_UPLOAD,overrideSchema:t.overrideSchema??i.OVERRIDE_SCHEMA,serverUrl:t.serverUrl??i.SERVER_URL,lambdaUrl:t.lambdaUrl??i.LAMBDA_URL,debug:r,projectVersion:eE.version},{logger:p})}catch(e){p.error(`Local environment preparation failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}}).command(["deployment:extract-sources <archive> <folder>"],"Validate the source archive of a phoenix deploy and extract its project files into a new folder. Links, special files, unsafe paths and oversized content are refused; entries that are not project files are left out",e=>e.positional("archive",{type:"string",demandOption:!0,description:"The source archive (.tgz)"}).positional("folder",{type:"string",demandOption:!0,description:"New or empty folder to extract the project files into"}),async e=>{let o=ep();try{await C({archivePath:e.archive,targetDir:e.folder},{logger:o})}catch(e){o.error(e instanceof Error?e.message:String(e)),process.exit(1)}}).command(["deployment:build-envs","dep:build-envs","dbe"],"Write the environment variables for the build step of a prepared deployment that builds apart from its deploy (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, OUT_FILE, SERVER_URL)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the prepared deployment (env: DEPLOYMENT_ID, required)"}).option("outFile",{alias:"o",type:"string",description:"Output file to write the environment variables to (env: OUT_FILE, default: .env.generated)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),OUT_FILE:o({default:".env.generated"}),SERVER_URL:o({default:void 0})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.serverUrl??i.SERVER_URL;if(!p)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let d=ep({debug:r});await w({uuid:n,apiKey:a,projectKey:s,projectSlug:l,outFile:t.outFile??i.OUT_FILE,serverUrl:p,debug:r},{logger:d})}).command(["deployment:finish","dep:finish","df"],"Upload files to S3 and activate deployment (env: DEPLOYMENT_ID, ENVIRONMENT_API_KEY, PROJECT_KEY, PROJECT_SLUG, LAMBDA_URL, SERVER_URL, SKIP_UPLOAD)",e=>e.option("uuid",{alias:"u",type:"string",description:"Id of the deployment to be activated (env: DEPLOYMENT_ID, required)"}).option("uploadLinksFile",{alias:"ulf",type:"string",description:"File containing upload links (generated by prepare command) (default: .upload-links.json)"}).option("apiKey",{alias:"a",type:"string",description:"API key for server access (env: ENVIRONMENT_API_KEY, required)"}).option("projectKey",{alias:"k",type:"string",description:"Project key to access the Project resources (env: PROJECT_KEY, required)"}).option("projectSlug",{alias:"p",type:"string",description:"Slug of the project (env: PROJECT_SLUG, required)"}).option("lambdaUrl",{alias:"l",type:"string",description:"Lambda webhook URL for the deployment (env: LAMBDA_URL, required)"}).option("serverUrl",{alias:"s",type:"string",description:"PHX server URL (env: SERVER_URL, required)"}).option("skipUpload",{alias:"su",type:"boolean",description:"Skip upload of resources to S3 bucket (env: SKIP_UPLOAD, default: false)"}).option("debug",{alias:"D",type:"boolean",description:"Enable debug mode for detailed logging (env: DEBUG, default: false)"}),async t=>{let i=f({DEBUG:e({default:!1}),DEPLOYMENT_ID:o({default:void 0}),ENVIRONMENT_API_KEY:o({default:void 0}),PROJECT_KEY:o({default:void 0}),PROJECT_SLUG:o({default:void 0}),LAMBDA_URL:o({default:void 0}),SERVER_URL:o({default:void 0}),SKIP_UPLOAD:e({default:!1})})(),r=t.debug??i.DEBUG,n=t.uuid??i.DEPLOYMENT_ID;if(!n)throw Error("Deployment ID is required, provide via --uuid or -u, or set DEPLOYMENT_ID environment variable");let a=t.apiKey??i.ENVIRONMENT_API_KEY;if(!a)throw Error("API key is required, provide via --apiKey or -a, or set ENVIRONMENT_API_KEY environment variable");let s=t.projectKey??i.PROJECT_KEY;if(!s)throw Error("Project key is required, provide via --projectKey or -k, or set PROJECT_KEY environment variable");let l=t.projectSlug??i.PROJECT_SLUG;if(!l)throw Error("Project slug is required, provide via --projectSlug or -p, or set PROJECT_SLUG environment variable");let p=t.lambdaUrl??i.LAMBDA_URL;if(!p)throw Error("Lambda URL is required, provide via --lambdaUrl or -l, or set LAMBDA_URL environment variable");let d=t.serverUrl??i.SERVER_URL;if(!d)throw Error("Server URL is required, provide via --serverUrl or -s, or set SERVER_URL environment variable");let c=ep({debug:r});await A({uuid:n,uploadLinksFile:t.uploadLinksFile??".upload-links.json",apiKey:a,projectKey:s,projectSlug:l,lambdaUrl:p,serverUrl:d,skipUpload:t.skipUpload??i.SKIP_UPLOAD,debug:r},{logger:c})}).demandCommand(1,"Please specify a command").help().alias("help","h").version(eE.version).alias("version","v").strict().parse();
@@ -1 +1 @@
1
- import{runCommand as e}from"../utils/index.js";import{checkFiles as t}from"./prettier.js";export const runCheckCommand=async(r,c)=>{let{logger:s}=c,i=!0===r.types||!0===r.lint||!0===r.format,o=!i||!0===r.types,n=!i||!0===r.lint,a=!i||!0===r.format;try{if(s.step("Running checks"),o&&await e({command:"tsc",args:["--project","tsconfig.json","--noEmit","--checkers","1"],description:"TypeScript check",quiet:!0},{logger:s}),n&&await e({command:"eslint",args:["src","--no-error-on-unmatched-pattern"],description:"ESLint check",quiet:!0},{logger:s}),a){if(s.step("Prettier check"),!await t(".",{logger:s}))throw Error("Prettier check failed");s.success("Prettier check passed")}s.success("All checks passed!")}catch(e){s.error(`Check failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}};
1
+ import{existsSync as e}from"fs";import{runCommand as t}from"../utils/index.js";import{checkFiles as r}from"./prettier.js";export const runCheckCommand=async(s,c)=>{let{logger:i}=c,o=!0===s.types||!0===s.lint||!0===s.format,n=!o||!0===s.types,a=!o||!0===s.lint,p=!o||!0===s.format;try{if(i.step("Running checks"),n&&await t({command:"tsc",args:["--project",e("tsconfig.json")?"tsconfig.json":".phoenix/tsconfig.json","--noEmit","--checkers","1"],description:"TypeScript check",quiet:!0},{logger:i}),a&&await t({command:"eslint",args:["src","--no-error-on-unmatched-pattern"],description:"ESLint check",quiet:!0},{logger:i}),p){if(i.step("Prettier check"),!await r(".",{logger:i}))throw Error("Prettier check failed");i.success("Prettier check passed")}i.success("All checks passed!")}catch(e){i.error(`Check failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}};
@@ -0,0 +1,52 @@
1
+ import type { CommandContext } from '../types.js';
2
+ export interface DepsCommandProps {
3
+ /** The project folder whose `package.json` is brought in line with the SDK's peers. */
4
+ readonly projectRoot: string;
5
+ }
6
+ /** The `package.json` fields whose entries count as the project declaring a package. */
7
+ declare const DECLARED_DEPENDENCY_FIELDS: readonly ['dependencies', 'devDependencies', 'optionalDependencies'];
8
+ type DeclaredDependencyField = (typeof DECLARED_DEPENDENCY_FIELDS)[number];
9
+ /**
10
+ * A package the project must declare next to the SDK, because the SDK lists it as a peer: the SDK's code imports it,
11
+ * but the project's install provides it, so the project and the SDK share one copy.
12
+ */
13
+ interface RequiredPeer {
14
+ readonly name: string;
15
+ /** The range from the SDK's `peerDependencies`. A declared version must fall inside it. */
16
+ readonly range: string;
17
+ /** The exact version `phoenix deps` writes for a missing or out-of-range peer: the lowest version of `range`. */
18
+ readonly version: string;
19
+ /** Type packages are needed only to typecheck, so they go to `devDependencies`; everything else to `dependencies`. */
20
+ readonly field: 'dependencies' | 'devDependencies';
21
+ }
22
+ /**
23
+ * A required peer the project does not satisfy: it declares the peer nowhere (`found` is undefined), or it declares
24
+ * it with a specifier whose lowest version falls outside the SDK's range. A peer declared out of range in two fields
25
+ * is two mismatches, one per entry.
26
+ */
27
+ interface PeerMismatch {
28
+ readonly peer: RequiredPeer;
29
+ readonly found: {
30
+ readonly field: DeclaredDependencyField;
31
+ readonly specifier: string;
32
+ } | undefined;
33
+ }
34
+ type JsonObject = Readonly<Record<string, unknown>>;
35
+ /**
36
+ * Lists every peer of the SDK the project's `package.json` does not satisfy, in the order of the SDK's
37
+ * `peerDependencies`. A peer is required unless the SDK marks it optional; `@clerk/clerk-react` is required when the
38
+ * project's spec sets `useClerk`. A required peer is a mismatch when no dependency field declares it, and once for each
39
+ * field that declares it with a specifier whose lowest version falls outside the SDK's range.
40
+ */
41
+ export declare const findSdkPeerMismatches: ({ packageJson, useClerk, }: {
42
+ readonly packageJson: JsonObject;
43
+ readonly useClerk: boolean;
44
+ }) => readonly PeerMismatch[];
45
+ /**
46
+ * Brings the project's `package.json` in line with the SDK: adds every required peer it does not declare and moves
47
+ * every declared peer whose version falls outside the SDK's range to the lowest version of that range, in the field
48
+ * that declares it. Specifiers that are not semver ranges stay as they are. The only entries it removes are the
49
+ * packages `@salsita-ai/sdk` replaces. It installs nothing; the next step is `pnpm install`.
50
+ */
51
+ export declare const runDepsCommand: (props: DepsCommandProps, { logger }: CommandContext) => Promise<void>;
52
+ export {};
@@ -0,0 +1,3 @@
1
+ import{existsSync as e}from"fs";import{readFile as r,writeFile as t}from"fs/promises";import{join as a}from"path";import{lt as n,minVersion as i,satisfies as o,validRange as s}from"semver";import{RuntimeReferenceStore as p,buildPhoenixDefinitions as l,parseApplicationFiles as d}from"#package/application-spec";import{getAllPhxDefinitions as c}from"#package/domain";import{readApplicationFiles as m}from"../../application-spec/application-spec-file-reader.js";import{swcEvalExpressionParser as f,swcModuleAnalyzer as u}from"../../application-spec/swc-module-analyzer.js";import{naturalCompare as h}from"../../utils/index.js";import{readSdkManifest as g}from"./sdk-manifest.js";let j=["@salsita-ai/platform-project-sdk","@salsita-ai/platform-common","@salsita-ai/platform-contracts","@salsita-ai/common","@salsita-ai/contracts"],k=["dependencies","devDependencies","optionalDependencies"],v=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),$=async t=>{let a;if(!e(t))throw Error(`phoenix deps found no package.json at ${t}. It brings the dependencies of an existing project in line with the SDK, so run it in the project folder.`);let n=await r(t,"utf-8");try{a=JSON.parse(n)}catch(e){throw Error(`phoenix deps could not read package.json because it is not valid JSON: ${e instanceof Error?e.message:String(e)} Fix the file and run phoenix deps again.`)}if(!v(a))throw Error("phoenix deps could not read package.json because it is not a JSON object. Fix the file and run phoenix deps again.");return{content:n,packageJson:a}},w=async(e,r)=>{let t=d({rawProjectFiles:await m({projectRoot:e,envs:{}}),phxDefinitions:l(c())},{analyzer:u,evalExpressionParser:f,referenceStore:new p,logger:r});if(!t.ok)throw Error(`phoenix deps could not parse the application spec, which says through useClerk whether the project needs @clerk/clerk-react:
2
+ ${t.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}
3
+ Fix these errors and run phoenix deps again.`);return t.value.applicationSpec.appMetadata.useClerk},x=e=>Object.fromEntries(k.map(r=>{let t=e[r];return[r,v(t)?Object.fromEntries(Object.entries(t).filter(e=>"string"==typeof e[1])):{}]})),b=({peer:e,found:r})=>void 0===r?{kind:"add",field:e.field,name:e.name,to:e.version}:{kind:"update",field:r.field,name:e.name,from:r.specifier,to:e.version,range:e.range},y=(e,r)=>{let t=new Set(r.flatMap(e=>"remove"===e.kind?[e.name]:[])),a=new Map(r.flatMap(e=>"update"===e.kind?[[e.name,e.to]]:[])),n=r.flatMap(e=>"add"===e.kind?[e]:[]),i=Object.entries(v(e)?e:{}).filter(([e])=>!t.has(e)).map(([e,r])=>[e,a.get(e)??r]);return Object.fromEntries([...n].sort((e,r)=>h(e.name,r.name)).reduce((e,r)=>{var t,a;let n;return t=r.name,a=r.to,-1===(n=e.findIndex(([e])=>h(e,t)>0))?[...e,[t,a]]:[...e.slice(0,n),[t,a],...e.slice(n)]},i))},S=e=>{switch(e.kind){case"add":return` ${e.field}: added ${e.name} ${e.to}`;case"update":var r,t;let a;return(r=e.from,t=e.to,null!==(a=i(r))&&n(t,a))?` ${e.field}: downgraded ${e.name} ${e.from} → ${e.to}, because the SDK supports ${e.range}`:` ${e.field}: updated ${e.name} ${e.from} → ${e.to}`;case"remove":return` ${e.field}: removed ${e.name}, which @salsita-ai/sdk replaces`}};export const findSdkPeerMismatches=({packageJson:e,useClerk:r})=>{let t=x(e);return(e=>{let{peerDependencies:r,optionalPeers:t}=g();return Object.entries(r).filter(([r])=>"@clerk/clerk-react"===r&&e||!t.includes(r)).map(([e,r])=>((e,r)=>{let t=i(r);if(null===t)throw Error(`The SDK's peer range "${r}" for ${e} matches no version, so no version of it can be required. The SDK installation is damaged; reinstall @salsita-ai/sdk.`);return{name:e,range:r,version:t.version,field:e.startsWith("@types/")?"devDependencies":"dependencies"}})(e,r))})(r).flatMap(e=>{let r=k.flatMap(r=>{let a=t[r]?.[e.name];return void 0===a?[]:[{field:r,specifier:a}]});return 0===r.length?[{peer:e,found:void 0}]:r.filter(r=>!((e,r)=>{if(null===s(e))return!0;let t=i(e);return null!==t&&o(t,r,{includePrerelease:!0})})(r.specifier,e.range)).map(r=>({peer:e,found:r}))})};export const runDepsCommand=async(e,{logger:r})=>{var n,i;let o,s,p,l,d,c,m,f=a(e.projectRoot,"package.json"),{content:u,packageJson:h}=await $(f),g=await w(e.projectRoot,r),v=(n=findSdkPeerMismatches({packageJson:h,useClerk:g}),o=x(h),s=k.flatMap(e=>j.filter(r=>o[e]?.[r]!==void 0).map(r=>({kind:"remove",field:e,name:r}))),[...n.map(b),...s]);0===v.length?r.success("package.json already declares every package the SDK needs. Nothing to change."):(await t(f,(p=e=>v.filter(r=>r.field===e),l=k.filter(e=>p(e).length>0),i=Object.fromEntries([...Object.entries(h).map(([e,r])=>{let t=l.find(r=>r===e);return void 0===t?[e,r]:[e,y(r,p(t))]}),...l.filter(e=>!(e in h)).map(e=>[e,y(void 0,p(e))])]),d=/^[ \t]+(?=")/m.exec(u)?.[0]??" ",c=u.includes("\r\n")?"\r\n":"\n",m=/\r?\n$/.test(u)?c:"",JSON.stringify(i,null,d).replace(/\n/g,c)+m)),r.success("Updated package.json:"),r.info(["",...v.map(S),"","Next step: pnpm install"].join("\n")))};
@@ -0,0 +1 @@
1
+ export { findSdkPeerMismatches, runDepsCommand } from './deps.js';
@@ -0,0 +1 @@
1
+ export{findSdkPeerMismatches,runDepsCommand}from"./deps.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The part of the SDK's own `package.json` that says which packages a project must install next to it. The SDK's
3
+ * `peerDependencies` are the single source of those versions: `phoenix deps` writes them into a project.
4
+ */
5
+ export interface SdkManifest {
6
+ /** Peer name to the semver range the SDK supports. */
7
+ readonly peerDependencies: Readonly<Record<string, string>>;
8
+ /** Peers the SDK marks optional, which a project installs only when it uses the feature behind them. */
9
+ readonly optionalPeers: readonly string[];
10
+ }
11
+ /** Reads the manifest of the SDK this CLI runs from. */
12
+ export declare const readSdkManifest: () => SdkManifest;
@@ -0,0 +1 @@
1
+ import{readFileSync as e}from"fs";import{fileURLToPath as r}from"url";import{z as t}from"zod";let a=t.object({peerDependencies:t.record(t.string(),t.string()).default({}),peerDependenciesMeta:t.record(t.string(),t.object({optional:t.boolean().optional()})).default({})}),o=r(new URL("../../../../package.json",import.meta.url));export const readSdkManifest=()=>{let r=a.safeParse(JSON.parse(e(o,"utf-8")));if(!r.success)throw Error(`The SDK's package.json at ${o} has no readable peerDependencies: ${r.error.message}. The SDK installation is damaged; reinstall @salsita-ai/sdk.`);let{peerDependencies:t,peerDependenciesMeta:s}=r.data;return{peerDependencies:t,optionalPeers:Object.entries(s).filter(([,e])=>!0===e.optional).map(([e])=>e)}};