gooseworks 0.4.2 → 0.5.0-dev.3.8661ef81

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 (130) hide show
  1. package/README.md +69 -21
  2. package/dist/agents/staging.d.ts +38 -0
  3. package/dist/agents/staging.d.ts.map +1 -0
  4. package/dist/agents/staging.js +309 -0
  5. package/dist/agents/staging.js.map +1 -0
  6. package/dist/auth/credentials.d.ts +1 -0
  7. package/dist/auth/credentials.d.ts.map +1 -1
  8. package/dist/auth/credentials.js +26 -8
  9. package/dist/auth/credentials.js.map +1 -1
  10. package/dist/auth/oauth-server.d.ts.map +1 -1
  11. package/dist/auth/oauth-server.js +18 -2
  12. package/dist/auth/oauth-server.js.map +1 -1
  13. package/dist/commands/doctor.d.ts +29 -5
  14. package/dist/commands/doctor.d.ts.map +1 -1
  15. package/dist/commands/doctor.js +117 -63
  16. package/dist/commands/doctor.js.map +1 -1
  17. package/dist/commands/fetch.d.ts +1 -0
  18. package/dist/commands/fetch.d.ts.map +1 -1
  19. package/dist/commands/fetch.js +64 -29
  20. package/dist/commands/fetch.js.map +1 -1
  21. package/dist/commands/formats.js +2 -2
  22. package/dist/commands/formats.js.map +1 -1
  23. package/dist/commands/graphics/publish-flow.js +1 -1
  24. package/dist/commands/graphics/publish-flow.js.map +1 -1
  25. package/dist/commands/install.d.ts.map +1 -1
  26. package/dist/commands/install.js +57 -4
  27. package/dist/commands/install.js.map +1 -1
  28. package/dist/commands/launch.d.ts +3 -0
  29. package/dist/commands/launch.d.ts.map +1 -0
  30. package/dist/commands/launch.js +35 -0
  31. package/dist/commands/launch.js.map +1 -0
  32. package/dist/commands/login.d.ts.map +1 -1
  33. package/dist/commands/login.js +15 -3
  34. package/dist/commands/login.js.map +1 -1
  35. package/dist/commands/logout.d.ts.map +1 -1
  36. package/dist/commands/logout.js +3 -1
  37. package/dist/commands/logout.js.map +1 -1
  38. package/dist/commands/skills.d.ts +50 -0
  39. package/dist/commands/skills.d.ts.map +1 -0
  40. package/dist/commands/skills.js +160 -0
  41. package/dist/commands/skills.js.map +1 -0
  42. package/dist/commands/styles.js +2 -2
  43. package/dist/commands/styles.js.map +1 -1
  44. package/dist/commands/update.d.ts.map +1 -1
  45. package/dist/commands/update.js +37 -6
  46. package/dist/commands/update.js.map +1 -1
  47. package/dist/commands/video-local.d.ts +9 -0
  48. package/dist/commands/video-local.d.ts.map +1 -0
  49. package/dist/commands/video-local.js +83 -0
  50. package/dist/commands/video-local.js.map +1 -0
  51. package/dist/commands/video-save.d.ts +3 -0
  52. package/dist/commands/video-save.d.ts.map +1 -0
  53. package/dist/commands/video-save.js +83 -0
  54. package/dist/commands/video-save.js.map +1 -0
  55. package/dist/config.d.ts.map +1 -1
  56. package/dist/config.js +11 -3
  57. package/dist/config.js.map +1 -1
  58. package/dist/environment.d.ts +9 -0
  59. package/dist/environment.d.ts.map +1 -0
  60. package/dist/environment.js +103 -0
  61. package/dist/environment.js.map +1 -0
  62. package/dist/index.js +12 -38
  63. package/dist/index.js.map +1 -1
  64. package/dist/lib/graphics-cache.d.ts.map +1 -1
  65. package/dist/lib/graphics-cache.js +2 -2
  66. package/dist/lib/graphics-cache.js.map +1 -1
  67. package/dist/lib/video-local-captions.d.ts +83 -0
  68. package/dist/lib/video-local-captions.d.ts.map +1 -0
  69. package/dist/lib/video-local-captions.js +261 -0
  70. package/dist/lib/video-local-captions.js.map +1 -0
  71. package/dist/lib/video-local-runtime.d.ts +8 -0
  72. package/dist/lib/video-local-runtime.d.ts.map +1 -0
  73. package/dist/lib/video-local-runtime.js +201 -0
  74. package/dist/lib/video-local-runtime.js.map +1 -0
  75. package/dist/lib/video-save-mcp.d.ts +9 -0
  76. package/dist/lib/video-save-mcp.d.ts.map +1 -0
  77. package/dist/lib/video-save-mcp.js +162 -0
  78. package/dist/lib/video-save-mcp.js.map +1 -0
  79. package/dist/lib/video-save.d.ts +77 -0
  80. package/dist/lib/video-save.d.ts.map +1 -0
  81. package/dist/lib/video-save.js +440 -0
  82. package/dist/lib/video-save.js.map +1 -0
  83. package/dist/program.d.ts +2 -0
  84. package/dist/program.d.ts.map +1 -0
  85. package/dist/program.js +54 -0
  86. package/dist/program.js.map +1 -0
  87. package/dist/skills/custom-video-skill.d.ts +3 -0
  88. package/dist/skills/custom-video-skill.d.ts.map +1 -0
  89. package/dist/skills/custom-video-skill.js +6 -0
  90. package/dist/skills/custom-video-skill.js.map +1 -0
  91. package/dist/skills/installer.d.ts +12 -6
  92. package/dist/skills/installer.d.ts.map +1 -1
  93. package/dist/skills/installer.js +82 -38
  94. package/dist/skills/installer.js.map +1 -1
  95. package/dist/skills/master-skill.d.ts +34 -28
  96. package/dist/skills/master-skill.d.ts.map +1 -1
  97. package/dist/skills/master-skill.js +2181 -858
  98. package/dist/skills/master-skill.js.map +1 -1
  99. package/dist/skills/package-freshness.d.ts +16 -0
  100. package/dist/skills/package-freshness.d.ts.map +1 -0
  101. package/dist/skills/package-freshness.js +36 -0
  102. package/dist/skills/package-freshness.js.map +1 -0
  103. package/dist/skills/releases.d.ts +12 -0
  104. package/dist/skills/releases.d.ts.map +1 -0
  105. package/dist/skills/releases.js +155 -0
  106. package/dist/skills/releases.js.map +1 -0
  107. package/dist/skills/routes.d.ts.map +1 -1
  108. package/dist/skills/routes.js +12 -6
  109. package/dist/skills/routes.js.map +1 -1
  110. package/dist/skills/staging-content.d.ts +3 -0
  111. package/dist/skills/staging-content.d.ts.map +1 -0
  112. package/dist/skills/staging-content.js +12 -0
  113. package/dist/skills/staging-content.js.map +1 -0
  114. package/dist/utils/browser-preflight.d.ts +29 -0
  115. package/dist/utils/browser-preflight.d.ts.map +1 -0
  116. package/dist/utils/browser-preflight.js +338 -0
  117. package/dist/utils/browser-preflight.js.map +1 -0
  118. package/package.json +11 -3
  119. package/skills/goose-ads/SKILL.md +486 -239
  120. package/skills/goose-product-photos/SKILL.md +138 -60
  121. package/skills/goose-video/SKILL.md +537 -259
  122. package/skills/goose-video-local/SKILL.md +1372 -236
  123. package/skills/gooseworks/SKILL.md +300 -32
  124. package/skills/make-custom-video/SKILL.md +697 -0
  125. package/skills/manifest.json +12 -0
  126. package/skills/routes.json +13 -6
  127. package/dist/skills/fetcher.d.ts +0 -18
  128. package/dist/skills/fetcher.d.ts.map +0 -1
  129. package/dist/skills/fetcher.js +0 -118
  130. package/dist/skills/fetcher.js.map +0 -1
package/README.md CHANGED
@@ -4,27 +4,44 @@ Put your AI agent on the growth team. GooseWorks gives Claude Code, Cursor, and
4
4
 
5
5
  ## Install
6
6
 
7
- Pick your agent:
7
+ **Paste this into your agent** (Claude Code, Cursor, Codex, or a chat app like Claude or ChatGPT):
8
+
9
+ ```text
10
+ Install gooseworks: https://gooseworks.ai/install.md
11
+ ```
12
+
13
+ Your agent reads that page and follows it. The page is short and you can read it too. It makes the agent:
14
+
15
+ 1. **Ask you first.** It says exactly what it will install and waits for your OK. The install touches your agent's skills folder, its MCP config and `~/.gooseworks/credentials.json`, nothing else, and only ever runs `npx gooseworks@latest …`.
16
+ 2. **Install** the GooseWorks skills and register the `gooseworks` MCP server with the right flag for your agent (`--claude`, `--cursor`, `--codex`), always with `--mcp`.
17
+ 3. **Sign you in** with Google in your browser (the URL is always printed too).
18
+ 4. **Check the install** with `npx gooseworks@latest doctor` and tell you to restart the agent so the MCP tools load.
19
+ 5. **Set up your company** after the restart: it asks for your website and saves what it learns as a reusable **Company Brain** that improves every later research, creative, and growth task.
20
+
21
+ Want a specific skill too? Say so: `Install gooseworks: https://gooseworks.ai/install.md, including the goose-graphics skill.`
22
+
23
+ If your agent cannot run terminal commands (claude.ai, ChatGPT), the page tells it to give you the MCP connector address (`https://mcp.gooseworks.ai/mcp`) instead.
24
+
25
+ ### Run it yourself
26
+
27
+ Prefer the terminal? Pick your agent (keep `--mcp`; `--all` includes it):
8
28
 
9
29
  ```bash
10
30
  # Claude Code
11
- npx gooseworks install --claude --mcp
12
- npx gooseworks install --claude --mcp --with goose-graphics
31
+ npx gooseworks@latest install --claude --mcp
32
+ npx gooseworks@latest install --claude --mcp --with goose-graphics
13
33
 
14
34
  # Cursor
15
- npx gooseworks install --cursor --mcp
35
+ npx gooseworks@latest install --cursor --mcp
16
36
 
17
37
  # Codex
18
- npx gooseworks install --codex --mcp
38
+ npx gooseworks@latest install --codex --mcp
19
39
 
20
40
  # All detected agents
21
- npx gooseworks install --all
41
+ npx gooseworks@latest install --all
22
42
  ```
23
43
 
24
- This does three things:
25
- 1. Opens browser for Google sign-in
26
- 2. Installs the GooseWorks skill into your coding agent
27
- 3. You're ready — ask your agent to "scrape reddit", "find leads", "research competitors", or "create product photos"
44
+ Restart your coding agent afterwards (MCP servers are only read at startup), then ask it to "scrape reddit", "find leads", "research competitors", or "create product photos".
28
45
 
29
46
  You do not need a special onboarding command. Ask GooseWorks to do a normal task, or say:
30
47
 
@@ -152,12 +169,20 @@ Credits: 847 available (500 subscription + 347 purchased)
152
169
 
153
170
  ### `update`
154
171
 
155
- Re-fetch the latest skill without re-authenticating.
172
+ Refresh the entry instructions bundled in your installed CLI without re-authenticating.
173
+ The command checks the published release first and refuses to reinstall a known older CLI
174
+ bundle. Edited or untracked entry files and standalone recipe packages are preserved.
156
175
 
157
176
  ```bash
177
+ npx gooseworks skills status
158
178
  npx gooseworks update
159
179
  ```
160
180
 
181
+ Use `gooseworks skills status --json` for release, bundle and actual-file hashes. Upgrade an
182
+ outdated CLI with `npm install -g gooseworks@latest` before updating its entries. Review and
183
+ back up local edits before explicitly using `gooseworks update --overwrite-modified`.
184
+ An unavailable release check means freshness is unknown, not current.
185
+
161
186
  ## How It Works
162
187
 
163
188
  1. **Install** — authenticates you and installs a master skill file into your coding agent
@@ -184,7 +209,7 @@ For focused creative work you can also use:
184
209
 
185
210
  - `/goose-ads` for static ads, ad research, and ad performance.
186
211
  - `/goose-product-photos` for studio, lifestyle, marketplace, social, and on-model product photography.
187
- - `/goose-video` to order a video ad in chat (renders on the GooseWorks server).
212
+ - `/goose-video` to pick a video format and make the ad on this machine (Claude Code, Codex or Cursor).
188
213
  - `/goose-video-local` to render a video project you started in the app, on this machine.
189
214
  - `goose-graphics` for social graphics, carousels, slides, and branded visual content.
190
215
  - `animate-image` to turn an approved still into a short motion creative.
@@ -214,7 +239,7 @@ npx gooseworks call scrapecreators /v1/facebook/adLibrary/search/ads \
214
239
 
215
240
  We'd rather you know exactly what this CLI does before you run it:
216
241
 
217
- - **Skill scripts are open source and fetched at runtime.** `gooseworks fetch <slug>` (and the skills that call it) download skill content and Python scripts from the GooseWorks catalog on demand, save them under `/tmp/gooseworks-scripts/`, and run them on your machine. Every skill and its scripts live in the public, open-source [goose-skills repo](https://github.com/gooseworks-ai/goose-skills/tree/main/skills) — the catalog is synced from there — so the code is the same maintained, auditable source you can read on GitHub. They're served from the catalog (kept current) rather than pinned to the installed CLI version, so you always get the latest version of a skill.
242
+ - **Skill scripts are open source and fetched at runtime.** `gooseworks fetch <slug>` (and the skills that call it) download skill content and Python scripts from the GooseWorks catalog on demand, save them under `/tmp/gooseworks-scripts/`, and run them on your machine. Every skill and its scripts live in the public, open-source [goose-skills repo](https://github.com/gooseworks-ai/goose-skills/tree/main/skills) — the catalog is synced from there — so the code is the same maintained, auditable source you can read on GitHub. They are served from the connected catalog rather than the installed CLI version. Saved copies retain the version/hash returned when fetched; compare them again for new work.
218
243
  - **The MCP server is opt-in.** It's only registered when you pass `--mcp` (or `--all`). When you do, the CLI adds a `gooseworks` entry to `~/.claude.json` (Claude Code) or `~/.codex/config.toml` (Codex) that includes your bearer token in an `Authorization` header — this is how every HTTP MCP server authenticates. Skip `--mcp` if you don't want the server registered as a live tool provider; shared onboarding and ads creation require it.
219
244
  - **Credentials are stored locally.** Your API key lives in `~/.gooseworks/credentials.json`, written with `0600` permissions in a `0700` directory. `gooseworks logout` deletes it.
220
245
  - **`gooseworks env` exposes your key.** `eval $(gooseworks env)` exports `GOOSEWORKS_API_KEY` into your shell environment, where any process you run can read it. Most commands (e.g. `gooseworks call`) load credentials on their own — only use `env` when a script genuinely needs the environment variable.
@@ -246,8 +271,8 @@ creative fatigue, CAC & lead quality, competitor ad intelligence, ad angles & ho
246
271
  `gooseworks` parent router also hands ad requests to it. Claude auto-loads whichever skill
247
272
  matches the task; the two are domain-scoped and never merged.
248
273
 
249
- > Renamed from `ads-remix`. Older installs get the stale `ads-remix` skill cleaned up
250
- > automatically on the next `install`.
274
+ > Renamed from `ads-remix`. Install and update preserve legacy directories. If an
275
+ > older `ads-remix` entry remains, review and back it up before removing it yourself.
251
276
 
252
277
  ```bash
253
278
  gooseworks install --claude --mcp
@@ -267,14 +292,37 @@ Generation is billed to your GooseWorks credits **server-side**: `submit_remix_b
267
292
  the estimated cost up front and bills only the images that complete. There's no separate
268
293
  ad-credit balance. Use `estimate_remix_batch` (cost preview) and `gooseworks credits` (balance).
269
294
 
295
+ ### Original videos and the shared harness
296
+
297
+ The installed `make-custom-video` entry connects GooseWorks projects, authenticated
298
+ script and ingredient approvals, budgets, media storage and delivery to the shared
299
+ `video-production-harness` catalog skill. It contains no production playbook or
300
+ assembly code. CLI, direct MCP and Growth fetch the same production package through
301
+ the GooseWorks catalog; direct MCP clients do not need a local CLI.
302
+
303
+ Production instructions are maintained in Goose Studio's existing control-plane
304
+ harness. Tested Studio changes publish a generated package to `goose-skills`.
305
+ Each run saves its fetched package in its durable workspace. Project metadata keeps
306
+ only the version, hash and package location; resuming uses the saved package instead
307
+ of changing instructions during production. An unavailable package blocks
308
+ generation. New runs use the currently published catalog version.
309
+
270
310
  ### Keeping skills up to date
271
311
 
272
- - **Entry skills** (`gooseworks`, `goose-ads`) are vendored in the CLI. They're (re)installed
273
- on `install`/`update`, and **refreshed on `login`** — but only when their content actually
274
- changed (a content-hash stamp skips unchanged ones, so re-running is cheap). Bump the CLI
275
- (`npx gooseworks@latest …`) to get new entry-skill content.
276
- - **Recipe skills** (e.g. ad-analytics like `meta-ads-analyzer`) are **fetched live** from
277
- goose-skills each time they're used, so they're always current — nothing to update.
312
+ - **Entry skills** are bundled in the CLI. `skills status` compares their actual installed bytes,
313
+ bundled bytes and the integrity-verified published npm package. Install/update/login warn
314
+ about an outdated CLI, different instructions, modified files or an unavailable release check.
315
+ They preserve edited or untracked files by default. A development build ahead of the release
316
+ is reported as unreleased; it is not silently downgraded.
317
+ - **Saved recipe packages** use the connected catalog's `version` / `contentHash` and dependency
318
+ hashes. `gooseworks fetch <slug> --saved-package <json-file>` compares a saved fetch response
319
+ and returns the current package without replacing the file. Canonical MCP `catalog_fetch`
320
+ supports optional saved hashes when advertised; other hosts compare the returned hashes
321
+ themselves. The server cannot inspect a client's files, and reported hashes do not certify
322
+ later manual edits. Missing hashes mean unknown.
323
+ - **Hosted snapshots** use the existing Skills Update action. Approved runs keep their recorded
324
+ package. Fetch into a new directory for new work; do not replace a running project's harness.
325
+ Updating skill content does not refresh a host's cached MCP tool schemas.
278
326
 
279
327
  ## File Layout
280
328
 
@@ -0,0 +1,38 @@
1
+ export { stagingContent } from '../skills/staging-content';
2
+ export type StagingAgent = 'claude' | 'codex';
3
+ interface Manifest {
4
+ environment: 'staging';
5
+ project: string;
6
+ version: string;
7
+ sourceBranch: 'dev';
8
+ sourceRevision: string | null;
9
+ mcpEndpoint: string;
10
+ agents: StagingAgent[];
11
+ skills: Record<string, string>;
12
+ }
13
+ export declare function projectProfile(project: string): {
14
+ project: string;
15
+ root: string;
16
+ home: string;
17
+ manifest: string;
18
+ };
19
+ /** Project/parent customizations could reintroduce a production plugin or MCP. */
20
+ export declare function assertCleanProject(project: string): void;
21
+ export declare function installStagingProject(project: string, agents: string[]): Manifest;
22
+ export declare function stagingLaunch(project: string, agent: string): {
23
+ command: string;
24
+ args: string[];
25
+ cwd: string;
26
+ env: NodeJS.ProcessEnv;
27
+ home: string;
28
+ manifest: Manifest;
29
+ };
30
+ /** Read Claude's startup event and stop before a model request (no provider credential needed). */
31
+ export declare function inspectClaudeSkills(launch: ReturnType<typeof stagingLaunch>): Promise<string[]>;
32
+ /** Real, free Codex discovery. Refuse incompatible versions before starting a session. */
33
+ export declare function inspectCodexSkills(launch: ReturnType<typeof stagingLaunch>): Promise<Array<{
34
+ name: string;
35
+ path: string;
36
+ enabled: boolean;
37
+ }>>;
38
+ //# sourceMappingURL=staging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../../src/agents/staging.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC9C,UAAU,QAAQ;IAAG,WAAW,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,KAAK,CAAC;IAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAAE;AAGjN,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAMjH;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAWxD;AAQD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CA+BjF;AAYD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CA0BxK;AAiBD,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B/F;AAED,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CA8C7I"}
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.stagingContent = void 0;
37
+ exports.projectProfile = projectProfile;
38
+ exports.assertCleanProject = assertCleanProject;
39
+ exports.installStagingProject = installStagingProject;
40
+ exports.stagingLaunch = stagingLaunch;
41
+ exports.inspectClaudeSkills = inspectClaudeSkills;
42
+ exports.inspectCodexSkills = inspectCodexSkills;
43
+ const fs = __importStar(require("node:fs"));
44
+ const path = __importStar(require("node:path"));
45
+ const os = __importStar(require("node:os"));
46
+ const node_crypto_1 = require("node:crypto");
47
+ const node_child_process_1 = require("node:child_process");
48
+ const credentials_1 = require("../auth/credentials");
49
+ const environment_1 = require("../environment");
50
+ const installer_1 = require("../skills/installer");
51
+ const version_1 = require("../version");
52
+ var staging_content_1 = require("../skills/staging-content");
53
+ Object.defineProperty(exports, "stagingContent", { enumerable: true, get: function () { return staging_content_1.stagingContent; } });
54
+ const hash = (value) => (0, node_crypto_1.createHash)('sha256').update(value).digest('hex');
55
+ function projectProfile(project) {
56
+ if (!project)
57
+ throw new Error('Staging requires --project <folder>');
58
+ const resolved = fs.realpathSync(path.resolve(project));
59
+ if (!fs.statSync(resolved).isDirectory())
60
+ throw new Error('--project must be a directory');
61
+ const root = path.join((0, environment_1.profileRoot)(), 'projects', hash(resolved).slice(0, 20));
62
+ return { project: resolved, root, home: path.join(root, 'home'), manifest: path.join(root, 'manifest.json') };
63
+ }
64
+ /** Project/parent customizations could reintroduce a production plugin or MCP. */
65
+ function assertCleanProject(project) {
66
+ const userHome = fs.realpathSync(process.env.GOOSEWORKS_USER_HOME || os.homedir());
67
+ for (let dir = project;; dir = path.dirname(dir)) {
68
+ // User-global roots are excluded by the child home; they must stay installed.
69
+ if (dir !== userHome) {
70
+ for (const name of ['.claude', '.codex', '.agents', '.cursor', '.mcp.json']) {
71
+ if (fs.existsSync(path.join(dir, name)))
72
+ throw new Error(`Staging cannot safely load project customization ${path.join(dir, name)}. Use a clean test folder outside that project tree.`);
73
+ }
74
+ }
75
+ if (path.dirname(dir) === dir)
76
+ break;
77
+ }
78
+ }
79
+ function privateWrite(file, body, mode = 0o600) {
80
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
81
+ if (fs.lstatSync(file, { throwIfNoEntry: false })?.isSymbolicLink())
82
+ throw new Error(`Refusing linked staging config: ${file}`);
83
+ fs.writeFileSync(file, body, { mode });
84
+ fs.chmodSync(file, mode);
85
+ }
86
+ function installStagingProject(project, agents) {
87
+ if ((0, environment_1.getEnvironment)() !== 'staging')
88
+ throw new Error('Project isolation is available with --env staging');
89
+ if (!agents.length || agents.some(agent => !['claude', 'codex'].includes(agent)))
90
+ throw new Error('Staging supports --claude and --codex. Cursor staging is refused until its skill isolation can be verified.');
91
+ const profile = projectProfile(project);
92
+ assertCleanProject(profile.project);
93
+ if (fs.existsSync(profile.manifest)) {
94
+ const previous = JSON.parse(fs.readFileSync(profile.manifest, 'utf8'));
95
+ for (const agent of previous.agents)
96
+ stagingLaunch(project, agent);
97
+ }
98
+ const credentials = (0, credentials_1.getCredentials)();
99
+ if (!credentials?.mcp_server_url)
100
+ throw new Error('Staging requires a staging GooseWorks login with an MCP connection. Run gooseworks --env staging login.');
101
+ const skills = {};
102
+ const source = (0, installer_1.getSkillsBasePath)();
103
+ for (const name of fs.readdirSync(source)) {
104
+ if (name.startsWith('.'))
105
+ continue;
106
+ const directory = path.join(source, name);
107
+ if (!fs.statSync(directory).isDirectory() || !fs.existsSync(path.join(directory, 'SKILL.md')))
108
+ continue;
109
+ if (fs.lstatSync(directory).isSymbolicLink())
110
+ throw new Error(`Linked staging package refused: ${name}`);
111
+ for (const agent of agents) {
112
+ const target = path.join(profile.home, `.${agent}`, 'skills', name);
113
+ // Refuse edits instead of silently destroying previously tested instructions.
114
+ if (fs.existsSync(target))
115
+ fs.rmSync(target, { recursive: true });
116
+ fs.cpSync(directory, target, { recursive: true, dereference: false });
117
+ }
118
+ skills[name] = treeHash(directory);
119
+ }
120
+ if (!skills.gooseworks)
121
+ throw new Error('Install the bundled staging entry skills first');
122
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', 'package.json'), 'utf8'));
123
+ const manifest = { environment: 'staging', project: profile.project, version: (0, version_1.getVersion)(), sourceBranch: 'dev', sourceRevision: pkg.gooseworksRelease?.commit || null, mcpEndpoint: credentials.mcp_server_url, agents: agents, skills };
124
+ privateWrite(profile.manifest, JSON.stringify(manifest, null, 2) + '\n');
125
+ writeConnections(profile.home, credentials);
126
+ return manifest;
127
+ }
128
+ function writeConnections(home, credentials) {
129
+ const endpoint = credentials.mcp_server_url.replace(/\/$/, '');
130
+ const url = endpoint.endsWith('/mcp') ? endpoint : `${endpoint}/mcp`;
131
+ privateWrite(path.join(home, 'mcp.json'), JSON.stringify({ mcpServers: { 'gooseworks-staging': { type: 'http', url, headers: { Authorization: `Bearer ${credentials.api_key}` } } } }));
132
+ // Codex shells can otherwise filter custom environment variables or reset PATH.
133
+ const pinned = { HOME: home, GOOSEWORKS_USER_HOME: process.env.GOOSEWORKS_USER_HOME || os.homedir(), GOOSEWORKS_SESSION_ENV: 'staging', GOOSEWORKS_API_BASE: credentials.api_base, PATH: `${path.join(home, 'bin')}${path.delimiter}${process.env.PATH || ''}` };
134
+ const shell = Object.entries(pinned).map(([key, value]) => `${key} = ${JSON.stringify(value)}`).join('\n');
135
+ privateWrite(path.join(home, '.codex', 'config.toml'), `allow_login_shell = false\n[shell_environment_policy]\ninherit = "all"\n[shell_environment_policy.set]\n${shell}\n[mcp_servers.gooseworks-staging]\nurl = ${JSON.stringify(url)}\n[mcp_servers.gooseworks-staging.http_headers]\nAuthorization = ${JSON.stringify(`Bearer ${credentials.api_key}`)}\n`);
136
+ }
137
+ function stagingLaunch(project, agent) {
138
+ if (!['claude', 'codex'].includes(agent))
139
+ throw new Error('Use --agent claude or --agent codex for an isolated staging session');
140
+ const profile = projectProfile(project);
141
+ assertCleanProject(profile.project);
142
+ const manifest = JSON.parse(fs.readFileSync(profile.manifest, 'utf8'));
143
+ if (manifest.environment !== 'staging' || manifest.project !== profile.project || !manifest.agents.includes(agent))
144
+ throw new Error('Project/environment mismatch. Install staging for this project and agent first.');
145
+ const root = path.join(profile.home, `.${agent}`, 'skills');
146
+ const actual = fs.readdirSync(root).filter(name => !name.startsWith('.'));
147
+ if (actual.length !== Object.keys(manifest.skills).length)
148
+ throw new Error('Unexpected skill in staging profile; reinstall into a fresh test folder');
149
+ for (const [name, expected] of Object.entries(manifest.skills)) {
150
+ const file = path.join(root, name, 'SKILL.md');
151
+ if (treeHash(path.dirname(file)) !== expected)
152
+ throw new Error(`Staging skill changed or linked: ${name}. Review it and install into a fresh test folder.`);
153
+ }
154
+ const credentials = (0, credentials_1.getCredentials)();
155
+ if (!credentials?.mcp_server_url)
156
+ throw new Error('Sign in to staging again before launching');
157
+ writeConnections(profile.home, credentials);
158
+ const env = { ...process.env };
159
+ // Do not carry production Goose tokens, custom provider homes, or daemon handles.
160
+ for (const key of Object.keys(env))
161
+ if (/^(GOOSEWORKS_|CODEX_|CLAUDE_|CLAUDECODE$|CURSOR_|XDG_)/.test(key))
162
+ delete env[key];
163
+ Object.assign(env, { HOME: profile.home, USERPROFILE: profile.home, XDG_CONFIG_HOME: path.join(profile.home, '.config'), XDG_DATA_HOME: path.join(profile.home, '.local', 'share'), CODEX_HOME: path.join(profile.home, '.codex'), CLAUDE_CONFIG_DIR: path.join(profile.home, '.claude'), GOOSEWORKS_USER_HOME: process.env.GOOSEWORKS_USER_HOME || os.homedir(), GOOSEWORKS_SESSION_ENV: 'staging', GOOSEWORKS_API_BASE: credentials.api_base });
164
+ // Use this exact CLI build inside the agent, even if its PATH has an older global CLI.
165
+ const bin = path.join(profile.home, 'bin');
166
+ if (process.platform === 'win32')
167
+ throw new Error('Isolated staging launch currently requires macOS or Linux');
168
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
169
+ privateWrite(path.join(bin, 'gooseworks'), `#!/bin/sh\nGOOSEWORKS_SESSION_ENV=staging\nexport GOOSEWORKS_SESSION_ENV\nexec ${quote(process.execPath)} ${quote(path.resolve(__dirname, '..', 'index.js'))} "$@"\n`, 0o700);
170
+ env.PATH = `${bin}${path.delimiter}${process.env.PATH || ''}`;
171
+ return { command: agent, cwd: profile.project, env, home: profile.home, manifest, args: agent === 'claude' ? ['--setting-sources', 'user', '--strict-mcp-config', '--mcp-config', path.join(profile.home, 'mcp.json')] : ['--cd', profile.project] };
172
+ }
173
+ function treeHash(directory) {
174
+ const digest = (0, node_crypto_1.createHash)('sha256');
175
+ function visit(dir) {
176
+ for (const name of fs.readdirSync(dir).sort()) {
177
+ const file = path.join(dir, name);
178
+ const stat = fs.lstatSync(file);
179
+ if (stat.isSymbolicLink())
180
+ throw new Error(`Linked staging package file refused: ${file}`);
181
+ digest.update(path.relative(directory, file) + '\0');
182
+ if (stat.isDirectory())
183
+ visit(file);
184
+ else if (stat.isFile())
185
+ digest.update(fs.readFileSync(file));
186
+ else
187
+ throw new Error(`Unsupported staging package file: ${file}`);
188
+ }
189
+ }
190
+ visit(directory);
191
+ return digest.digest('hex');
192
+ }
193
+ /** Read Claude's startup event and stop before a model request (no provider credential needed). */
194
+ function inspectClaudeSkills(launch) {
195
+ return new Promise((resolve, reject) => {
196
+ const env = { ...launch.env, ANTHROPIC_API_KEY: 'sk-ant-gooseworks-inventory-invalid-key' };
197
+ // Inventory must never use a real billable provider connection.
198
+ for (const key of Object.keys(env))
199
+ if (/^(ANTHROPIC_AUTH_TOKEN|ANTHROPIC_BASE_URL|CLAUDE_CODE_USE_|AWS_|GOOGLE_|AZURE_)/.test(key))
200
+ delete env[key];
201
+ const child = (0, node_child_process_1.spawn)('claude', [...launch.args, '-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose'], { cwd: launch.cwd, env, stdio: ['pipe', 'pipe', 'pipe'] });
202
+ let finished = false;
203
+ let buffer = '';
204
+ const finish = (error, skills) => { if (finished)
205
+ return; finished = true; clearTimeout(timer); child.kill(); error ? reject(error) : resolve(skills); };
206
+ const timer = setTimeout(() => finish(new Error('Claude startup inventory timed out; update Claude and retry')), 30000);
207
+ child.on('error', error => finish(error));
208
+ child.on('exit', () => { if (!finished)
209
+ finish(new Error('Claude did not provide its skill inventory; update Claude')); });
210
+ child.stderr.on('data', () => undefined);
211
+ child.stdout.on('data', data => {
212
+ buffer += data;
213
+ if (buffer.length > 2 * 1024 * 1024)
214
+ return finish(new Error('Invalid Claude startup event'));
215
+ let end;
216
+ while ((end = buffer.indexOf('\n')) >= 0) {
217
+ let message;
218
+ try {
219
+ message = JSON.parse(buffer.slice(0, end));
220
+ }
221
+ catch {
222
+ buffer = buffer.slice(end + 1);
223
+ continue;
224
+ }
225
+ buffer = buffer.slice(end + 1);
226
+ if (message.type !== 'system' || message.subtype !== 'init')
227
+ continue;
228
+ if (!Array.isArray(message.skills) || !Array.isArray(message.plugins) || !Array.isArray(message.mcp_servers))
229
+ return finish(new Error('Incompatible Claude startup inventory'));
230
+ const expected = Object.keys(launch.manifest.skills);
231
+ if (expected.some(name => !message.skills.includes(name)) || message.skills.some((name) => /^(goose|make-custom-video)/.test(name) && !expected.includes(name)) || message.plugins.length || message.mcp_servers.some((server) => server.name !== 'gooseworks-staging'))
232
+ return finish(new Error('Claude loaded an unexpected skill, plugin, or MCP. Staging launch refused.'));
233
+ finish(undefined, message.skills);
234
+ }
235
+ });
236
+ child.stdin.write(JSON.stringify({ type: 'user', message: { role: 'user', content: '/skills' } }) + '\n');
237
+ });
238
+ }
239
+ /** Real, free Codex discovery. Refuse incompatible versions before starting a session. */
240
+ function inspectCodexSkills(launch) {
241
+ return new Promise((resolve, reject) => {
242
+ const child = (0, node_child_process_1.spawn)('codex', ['app-server'], { cwd: launch.cwd, env: launch.env, stdio: ['pipe', 'pipe', 'pipe'] });
243
+ let buffer = '';
244
+ let finished = false;
245
+ let inventory;
246
+ let configVerified = false;
247
+ const finish = (error, skills) => { if (finished)
248
+ return; finished = true; clearTimeout(timer); child.kill(); error ? reject(error) : resolve(skills); };
249
+ const timer = setTimeout(() => finish(new Error('Codex skill isolation check timed out; update Codex and retry')), 15000);
250
+ child.on('error', error => finish(error));
251
+ child.on('exit', () => { if (!finished)
252
+ finish(new Error('Codex does not support the staging inventory check; update Codex')); });
253
+ child.stderr.on('data', () => undefined);
254
+ child.stdout.on('data', data => {
255
+ buffer += data;
256
+ if (buffer.length > 2 * 1024 * 1024)
257
+ return finish(new Error('Invalid Codex inventory response'));
258
+ let end;
259
+ while ((end = buffer.indexOf('\n')) >= 0) {
260
+ const line = buffer.slice(0, end);
261
+ buffer = buffer.slice(end + 1);
262
+ let message;
263
+ try {
264
+ message = JSON.parse(line);
265
+ }
266
+ catch {
267
+ continue;
268
+ }
269
+ if (message.error)
270
+ return finish(new Error('Codex rejected the staging inventory check; update Codex'));
271
+ if (message.id === 1) {
272
+ child.stdin.write(JSON.stringify({ method: 'initialized' }) + '\n');
273
+ child.stdin.write(JSON.stringify({ id: 2, method: 'skills/list', params: { cwds: [launch.cwd], forceReload: true } }) + '\n');
274
+ child.stdin.write(JSON.stringify({ id: 3, method: 'config/read', params: { cwd: launch.cwd, includeLayers: false } }) + '\n');
275
+ }
276
+ if (message.id === 2) {
277
+ const rows = message.result?.data;
278
+ if (!Array.isArray(rows) || rows.some(row => row.errors?.length))
279
+ return finish(new Error('Could not read the complete Codex skill inventory'));
280
+ const skills = rows.flatMap(row => row.skills || []).filter(skill => skill.enabled);
281
+ const allowed = fs.realpathSync(launch.home) + path.sep;
282
+ if (skills.some(skill => !fs.realpathSync(skill.path).startsWith(allowed)))
283
+ return finish(new Error('Codex discovered skills outside the staging profile. Launch refused.'));
284
+ const names = new Set(skills.map(skill => skill.name));
285
+ if (Object.keys(launch.manifest.skills).some(name => !names.has(name)))
286
+ return finish(new Error('Codex did not load all staging skills. Launch refused.'));
287
+ inventory = skills.map(skill => ({ name: skill.name, path: skill.path, enabled: skill.enabled }));
288
+ if (configVerified)
289
+ finish(undefined, inventory);
290
+ }
291
+ if (message.id === 3) {
292
+ const servers = message.result?.config?.mcp_servers;
293
+ const endpoint = launch.manifest.mcpEndpoint.replace(/\/$/, '');
294
+ const expectedUrl = endpoint.endsWith('/mcp') ? endpoint : `${endpoint}/mcp`;
295
+ if (!servers || Object.keys(servers).length !== 1 || !servers['gooseworks-staging'] || servers['gooseworks-staging'].url !== expectedUrl)
296
+ return finish(new Error('Codex effective MCP configuration is not isolated to staging. Launch refused.'));
297
+ const plugins = message.result?.config?.plugins;
298
+ if (plugins && Object.values(plugins).some((plugin) => plugin?.enabled !== false))
299
+ return finish(new Error('Codex loaded unexpected plugin configuration. Launch refused.'));
300
+ configVerified = true;
301
+ if (inventory)
302
+ finish(undefined, inventory);
303
+ }
304
+ }
305
+ });
306
+ child.stdin.write(JSON.stringify({ id: 1, method: 'initialize', params: { clientInfo: { name: 'gooseworks-staging-check', version: (0, version_1.getVersion)() } } }) + '\n');
307
+ });
308
+ }
309
+ //# sourceMappingURL=staging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.js","sourceRoot":"","sources":["../../src/agents/staging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,wCAMC;AAGD,gDAWC;AAQD,sDA+BC;AAYD,sCA0BC;AAkBD,kDA2BC;AAGD,gDA8CC;AA9MD,4CAA8B;AAC9B,gDAAkC;AAClC,4CAA8B;AAC9B,6CAAyC;AACzC,2DAA2C;AAC3C,qDAAqD;AACrD,gDAA6D;AAC7D,mDAAwD;AACxD,wCAAwC;AACxC,6DAA2D;AAAlD,iHAAA,cAAc,OAAA;AAIvB,MAAM,IAAI,GAAG,CAAC,KAAsB,EAAE,EAAE,CAAC,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAE1F,SAAgB,cAAc,CAAC,OAAe;IAC5C,IAAI,C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AAE,OAAO,EAAE,IAAA,oBAAU,GAAE,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACjK,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -11,6 +11,7 @@ export interface Credentials {
11
11
  /** Base URL for the GooseWorks MCP server (e.g. http://localhost:6200 in dev). */
12
12
  mcp_server_url?: string;
13
13
  }
14
+ export declare function validateCredentials(creds: Credentials): void;
14
15
  export declare function getCredentials(): Credentials | null;
15
16
  export declare function saveCredentials(creds: Credentials): void;
16
17
  export declare function clearCredentials(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/auth/credentials.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD,wBAAgB,cAAc,IAAI,WAAW,GAAG,IAAI,CAcnD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CASxD;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAQvC;AAED,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAGzC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAGnC"}
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/auth/credentials.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAG5D;AAED,wBAAgB,cAAc,IAAI,WAAW,GAAG,IAAI,CAgBnD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAcxD;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAUvC;AAED,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAGzC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAGnC"}
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.validateCredentials = validateCredentials;
36
37
  exports.getCredentials = getCredentials;
37
38
  exports.saveCredentials = saveCredentials;
38
39
  exports.clearCredentials = clearCredentials;
@@ -42,35 +43,52 @@ const fs = __importStar(require("fs"));
42
43
  const path = __importStar(require("path"));
43
44
  const os = __importStar(require("os"));
44
45
  const config_1 = require("../config");
45
- const CREDENTIALS_DIR = path.join(os.homedir(), '.gooseworks');
46
- const CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, 'credentials.json');
46
+ const environment_1 = require("../environment");
47
+ function credentialsFile() { return path.join((0, environment_1.profileRoot)(), 'credentials.json'); }
48
+ const LEGACY_FILE = path.join(os.homedir(), '.gooseworks', 'credentials.json');
49
+ function validateCredentials(creds) {
50
+ (0, environment_1.assertConnection)(creds.api_base, 'api');
51
+ if (creds.mcp_server_url)
52
+ (0, environment_1.assertConnection)(creds.mcp_server_url, 'mcp');
53
+ }
47
54
  function getCredentials() {
55
+ let parsed;
48
56
  try {
49
- if (!fs.existsSync(CREDENTIALS_FILE)) {
57
+ const file = fs.existsSync(credentialsFile()) ? credentialsFile()
58
+ : (0, environment_1.getEnvironment)() === 'production' && fs.existsSync(LEGACY_FILE) ? LEGACY_FILE : null;
59
+ if (!file)
50
60
  return null;
51
- }
52
- const raw = fs.readFileSync(CREDENTIALS_FILE, 'utf-8');
53
- const parsed = JSON.parse(raw);
54
- if (!parsed.api_key || !parsed.email || !parsed.agent_id) {
61
+ parsed = JSON.parse(fs.readFileSync(file, 'utf-8'));
62
+ if (!parsed.api_key || !parsed.email || !parsed.agent_id || !parsed.api_base) {
55
63
  return null;
56
64
  }
57
- return parsed;
58
65
  }
59
66
  catch {
60
67
  return null;
61
68
  }
69
+ // A mismatched saved login is an error, never an excuse to use another profile.
70
+ validateCredentials(parsed);
71
+ return parsed;
62
72
  }
63
73
  function saveCredentials(creds) {
74
+ validateCredentials(creds);
75
+ const CREDENTIALS_DIR = (0, environment_1.profileRoot)();
76
+ const CREDENTIALS_FILE = credentialsFile();
64
77
  if (!fs.existsSync(CREDENTIALS_DIR)) {
65
78
  fs.mkdirSync(CREDENTIALS_DIR, { mode: 0o700, recursive: true });
66
79
  }
67
80
  fs.writeFileSync(CREDENTIALS_FILE, JSON.stringify(creds, null, 2) + '\n', { mode: 0o600 });
81
+ fs.chmodSync(CREDENTIALS_DIR, 0o700);
82
+ fs.chmodSync(CREDENTIALS_FILE, 0o600);
68
83
  }
69
84
  function clearCredentials() {
85
+ const CREDENTIALS_FILE = credentialsFile();
70
86
  try {
71
87
  if (fs.existsSync(CREDENTIALS_FILE)) {
72
88
  fs.unlinkSync(CREDENTIALS_FILE);
73
89
  }
90
+ if ((0, environment_1.getEnvironment)() === 'production' && fs.existsSync(LEGACY_FILE))
91
+ fs.unlinkSync(LEGACY_FILE);
74
92
  }
75
93
  catch {
76
94
  // Ignore errors during cleanup