@growthub/cli 0.3.38 → 0.3.39

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 (40) hide show
  1. package/README.md +4 -2
  2. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/.env.example +9 -0
  3. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/QUICKSTART.md +85 -0
  4. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/brands/NEW-CLIENT.md +46 -0
  5. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/brands/_template/brand-kit.md +89 -0
  6. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/brands/growthub/brand-kit.md +96 -0
  7. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/bundles/growthub-open-higgsfield-studio-v1.json +57 -0
  8. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/docs/open-higgsfield-fork-integration.md +63 -0
  9. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/docs/provider-adapter-layer.md +67 -0
  10. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/examples/platform-ready-handoff-sample.md +24 -0
  11. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/examples/prompt-matrix-sample.md +6 -0
  12. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/examples/shot-plan-sample.md +7 -0
  13. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/examples/visual-campaign-brief-sample.md +22 -0
  14. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/growthub-meta/README.md +67 -0
  15. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/growthub-meta/kit-standard.md +47 -0
  16. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/kit.json +106 -0
  17. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/output/README.md +34 -0
  18. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/output-standards.md +133 -0
  19. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/runtime-assumptions.md +108 -0
  20. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/check-deps.sh +37 -0
  21. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/clone-fork.sh +27 -0
  22. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/verify-env.mjs +72 -0
  23. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/skills.md +257 -0
  24. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/asset-tracking.md +5 -0
  25. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/frame-analysis.md +24 -0
  26. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/generation-batch-plan.md +7 -0
  27. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/model-selection-recommendation.md +23 -0
  28. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/platform-ready-execution-handoff.md +17 -0
  29. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-matrix.md +7 -0
  30. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/cinema-generation.md +16 -0
  31. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/image-generation.md +11 -0
  32. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/lip-sync-generation.md +14 -0
  33. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/video-generation.md +11 -0
  34. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/review-qa-checklist.md +26 -0
  35. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/shot-plan.md +11 -0
  36. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/studio-selection-brief.md +18 -0
  37. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/visual-campaign-brief.md +24 -0
  38. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/validation-checklist.md +49 -0
  39. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/workers/open-higgsfield-studio-operator/CLAUDE.md +264 -0
  40. package/package.json +1 -1
@@ -0,0 +1,47 @@
1
+ # Kit Standard — Open Higgsfield Studio v1
2
+
3
+ This document defines the locked contract for this kit.
4
+
5
+ ---
6
+
7
+ ## Required files contract
8
+
9
+ Every path in `kit.json -> frozenAssetPaths` must exist in every valid release.
10
+
11
+ ---
12
+
13
+ ## Bundle contract
14
+
15
+ The bundle manifest must remain aligned with `kit.json`:
16
+ - `bundle.kitId` matches `kit.id`
17
+ - `bundle.workerId` matches `entrypoint.workerId`
18
+ - `requiredFrozenAssets` stays a subset of `frozenAssetPaths`
19
+
20
+ ---
21
+
22
+ ## Agent operating rules
23
+
24
+ The entrypoint file is the operating law. `skills.md` is the methodology.
25
+
26
+ Required invariants:
27
+ - strict workflow order
28
+ - repo inspection before planning when a fork exists
29
+ - one primary studio selection
30
+ - model recommendation with fallback
31
+ - explicit provider adapter assumptions
32
+ - operational output artifacts, not ideation-only text
33
+
34
+ ---
35
+
36
+ ## Runtime rules
37
+
38
+ - no secrets stored in kit files
39
+ - Muapi is the reference adapter, not a permanent monopoly
40
+ - browser, desktop, and local-fork modes are all first-class
41
+ - outputs are Markdown only
42
+
43
+ ---
44
+
45
+ ## Versioning rules
46
+
47
+ Additive template/docs changes are minor-version work. Entry-point path changes or export-name changes require a major version bump.
@@ -0,0 +1,106 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "kit": {
4
+ "id": "growthub-open-higgsfield-studio-v1",
5
+ "version": "1.0.0",
6
+ "name": "Growthub Agent Worker Kit — Open Higgsfield Studio",
7
+ "description": "Self-contained local execution environment for Open Higgsfield AI visual production. Produces implementation-ready visual briefs, prompt systems, shot plans, generation batches, model selections, and execution handoff artifacts for browser, desktop, and local fork workflows.",
8
+ "type": "worker",
9
+ "visibility": "public-open-source",
10
+ "sourceRepo": "growthub-local"
11
+ },
12
+ "entrypoint": {
13
+ "workerId": "open-higgsfield-studio-operator",
14
+ "path": "workers/open-higgsfield-studio-operator/CLAUDE.md"
15
+ },
16
+ "workerIds": [
17
+ "open-higgsfield-studio-operator"
18
+ ],
19
+ "agentContractPath": "workers/open-higgsfield-studio-operator/CLAUDE.md",
20
+ "brandTemplatePath": "brands/_template/brand-kit.md",
21
+ "publicExampleBrandPaths": [
22
+ "brands/growthub/brand-kit.md"
23
+ ],
24
+ "frozenAssetPaths": [
25
+ "QUICKSTART.md",
26
+ ".env.example",
27
+ "skills.md",
28
+ "output-standards.md",
29
+ "runtime-assumptions.md",
30
+ "validation-checklist.md",
31
+ "workers/open-higgsfield-studio-operator/CLAUDE.md",
32
+ "brands/_template/brand-kit.md",
33
+ "brands/growthub/brand-kit.md",
34
+ "brands/NEW-CLIENT.md",
35
+ "setup/clone-fork.sh",
36
+ "setup/verify-env.mjs",
37
+ "setup/check-deps.sh",
38
+ "output/README.md",
39
+ "templates/visual-campaign-brief.md",
40
+ "templates/studio-selection-brief.md",
41
+ "templates/model-selection-recommendation.md",
42
+ "templates/shot-plan.md",
43
+ "templates/prompt-matrix.md",
44
+ "templates/generation-batch-plan.md",
45
+ "templates/asset-tracking.md",
46
+ "templates/review-qa-checklist.md",
47
+ "templates/platform-ready-execution-handoff.md",
48
+ "templates/frame-analysis.md",
49
+ "templates/prompt-templates/image-generation.md",
50
+ "templates/prompt-templates/video-generation.md",
51
+ "templates/prompt-templates/lip-sync-generation.md",
52
+ "templates/prompt-templates/cinema-generation.md",
53
+ "examples/visual-campaign-brief-sample.md",
54
+ "examples/shot-plan-sample.md",
55
+ "examples/prompt-matrix-sample.md",
56
+ "examples/platform-ready-handoff-sample.md",
57
+ "docs/open-higgsfield-fork-integration.md",
58
+ "docs/provider-adapter-layer.md",
59
+ "growthub-meta/README.md",
60
+ "growthub-meta/kit-standard.md"
61
+ ],
62
+ "setupPaths": {
63
+ "quickstart": "QUICKSTART.md",
64
+ "envExample": ".env.example",
65
+ "setupDir": "setup/",
66
+ "outputDir": "output/"
67
+ },
68
+ "outputStandard": {
69
+ "type": "working-directory",
70
+ "description": "Exported folder is intended to be pointed at directly by the agent Working Directory. All outputs are Markdown files written to output/<client-slug>/<project-slug>/.",
71
+ "requiredPaths": [
72
+ "QUICKSTART.md",
73
+ ".env.example",
74
+ "kit.json",
75
+ "bundles/growthub-open-higgsfield-studio-v1.json",
76
+ "skills.md",
77
+ "workers/open-higgsfield-studio-operator/CLAUDE.md",
78
+ "brands/_template/brand-kit.md",
79
+ "brands/growthub/brand-kit.md",
80
+ "brands/NEW-CLIENT.md",
81
+ "setup/clone-fork.sh",
82
+ "setup/verify-env.mjs",
83
+ "setup/check-deps.sh",
84
+ "output/README.md",
85
+ "templates",
86
+ "docs",
87
+ "growthub-meta"
88
+ ]
89
+ },
90
+ "bundles": [
91
+ {
92
+ "id": "growthub-open-higgsfield-studio-v1",
93
+ "version": "1.0.0",
94
+ "path": "bundles/growthub-open-higgsfield-studio-v1.json"
95
+ }
96
+ ],
97
+ "executionMode": "export",
98
+ "activationModes": ["export"],
99
+ "compatibility": {
100
+ "cliMinVersion": "0.3.37"
101
+ },
102
+ "provenance": {
103
+ "sourceRepo": "growthub-local",
104
+ "frozenAt": "2026-04-10T00:00:00.000Z"
105
+ }
106
+ }
@@ -0,0 +1,34 @@
1
+ # Output Directory
2
+
3
+ All agent-generated deliverables are written here, organized by client and project.
4
+
5
+ ## Structure
6
+
7
+ ```
8
+ output/
9
+ <client-slug>/
10
+ <project-slug>/
11
+ visual-campaign-brief.md
12
+ studio-selection-brief.md
13
+ model-selection-recommendation.md
14
+ shot-plan.md
15
+ prompt-matrix.md
16
+ generation-batch-plan.md
17
+ asset-tracking.md
18
+ review-qa-checklist.md
19
+ platform-ready-execution-handoff.md
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ The agent creates this structure automatically when it writes its first deliverable. You do not need to create folders manually.
25
+
26
+ Use the `<client-slug>` to match your brand kit name (e.g. `growthub`, `acme-corp`) and the `<project-slug>` to identify the campaign or shoot (e.g. `q2-product-launch`, `founder-brand-video`).
27
+
28
+ ## Tracking deliverables
29
+
30
+ Each completed package is logged in the active brand kit under `Deliverable History`:
31
+
32
+ ```
33
+ - YYYY-MM-DD | Open Higgsfield Visual Package v<N> — <Project Name> | output/<client-slug>/<project-slug>/
34
+ ```
@@ -0,0 +1,133 @@
1
+ # Output Standards — Open Higgsfield Studio v1
2
+
3
+ This document defines the output contract for every artifact produced by this kit.
4
+
5
+ ---
6
+
7
+ ## OUTPUT FOLDER STRUCTURE
8
+
9
+ ```text
10
+ output/
11
+ └── <client-slug>/
12
+ └── <project-slug>/
13
+ ├── <ClientSlug>_VisualCampaignBrief_v<N>_<YYYYMMDD>.md
14
+ ├── <ClientSlug>_StudioSelectionBrief_v<N>_<YYYYMMDD>.md
15
+ ├── <ClientSlug>_ModelSelectionRecommendation_v<N>_<YYYYMMDD>.md
16
+ ├── <ClientSlug>_ShotPlan_v<N>_<YYYYMMDD>.md
17
+ ├── <ClientSlug>_PromptMatrix_v<N>_<YYYYMMDD>.md
18
+ ├── <ClientSlug>_GenerationBatchPlan_v<N>_<YYYYMMDD>.md
19
+ ├── <ClientSlug>_AssetTracking_v<N>_<YYYYMMDD>.md
20
+ ├── <ClientSlug>_ReviewQAChecklist_v<N>_<YYYYMMDD>.md
21
+ └── <ClientSlug>_PlatformReadyExecutionHandoff_v<N>_<YYYYMMDD>.md
22
+ ```
23
+
24
+ ---
25
+
26
+ ## REQUIRED OUTPUT TYPES
27
+
28
+ Every full package must include:
29
+ - visual campaign brief
30
+ - studio selection brief
31
+ - model selection recommendation
32
+ - shot plan
33
+ - prompt matrix
34
+ - generation batch plan
35
+ - asset tracking
36
+ - review QA checklist
37
+ - platform-ready execution handoff
38
+
39
+ ---
40
+
41
+ ## REQUIRED SECTIONS
42
+
43
+ ### Visual campaign brief
44
+ 1. Goal and deliverable
45
+ 2. Audience and platform context
46
+ 3. Brand and visual rules
47
+ 4. Content objective to visual strategy translation
48
+ 5. Asset inventory
49
+ 6. Studio hypothesis
50
+ 7. Output package summary
51
+
52
+ ### Studio selection brief
53
+ 1. Requested outcome
54
+ 2. Recommended studio
55
+ 3. Why this studio fits
56
+ 4. Input requirements
57
+ 5. Risks and fallback studio
58
+
59
+ ### Model selection recommendation
60
+ 1. Primary model table
61
+ 2. Fallback model table
62
+ 3. Endpoint and control assumptions
63
+ 4. Constraint notes
64
+
65
+ ### Shot plan
66
+ 1. Shot table
67
+ 2. Narrative arc notes
68
+ 3. Asset dependencies
69
+ 4. Review gates
70
+
71
+ ### Prompt matrix
72
+ 1. Prompt set metadata
73
+ 2. One row per output or shot
74
+ 3. Base prompt
75
+ 4. Variation prompt
76
+ 5. Negative / exclusion language
77
+ 6. Control settings
78
+
79
+ ### Generation batch plan
80
+ 1. Batch sequence table
81
+ 2. Submit order
82
+ 3. Polling / review cadence
83
+ 4. Retry rules
84
+
85
+ ### Asset tracking
86
+ 1. Asset inventory table
87
+ 2. Reuse status
88
+ 3. Upload status
89
+ 4. Ownership / notes
90
+
91
+ ### Review QA checklist
92
+ 1. Creative review
93
+ 2. Technical review
94
+ 3. Studio-specific review
95
+ 4. Handoff sign-off
96
+
97
+ ### Platform-ready execution handoff
98
+ 1. Runtime mode
99
+ 2. Repo inspection summary
100
+ 3. Provider adapter assumptions
101
+ 4. Exact execution steps
102
+ 5. Expected outputs
103
+ 6. Open questions
104
+
105
+ ---
106
+
107
+ ## FILE NAMING RULES
108
+
109
+ Pattern:
110
+
111
+ ```text
112
+ <ClientSlug>_<OutputType>_v<N>_<YYYYMMDD>.md
113
+ ```
114
+
115
+ Rules:
116
+ - `ClientSlug` is PascalCase
117
+ - never overwrite an existing version
118
+ - keep one artifact per file
119
+ - Markdown only
120
+
121
+ ---
122
+
123
+ ## QUALITY BAR
124
+
125
+ An output is complete when:
126
+ - no placeholder text remains
127
+ - the primary studio is explicit
128
+ - the model recommendation includes a fallback
129
+ - prompts are paste-ready
130
+ - every shot has a defined asset path or asset request
131
+ - batch sequencing reflects async submit/poll execution
132
+ - browser / desktop / local-fork mode is named
133
+ - review checklist is filled, not empty
@@ -0,0 +1,108 @@
1
+ # Runtime Assumptions — Open Higgsfield Studio v1
2
+
3
+ This document defines the runtime boundary for this kit.
4
+
5
+ ---
6
+
7
+ ## OVERVIEW
8
+
9
+ This kit targets a self-contained local working directory used by an agent operating against one of three execution surfaces:
10
+
11
+ | Mode | When to use | Assumption |
12
+ |---|---|---|
13
+ | `local-fork` | local checkout of Open Higgsfield AI is available | repo files can be inspected before planning |
14
+ | `browser-hosted` | operator uses the hosted browser app | studio behavior follows the public hosted workflow |
15
+ | `desktop-app` | operator uses the Electron app | same shared studio substrate, local desktop packaging |
16
+
17
+ Default planning mode is `local-fork` when a checkout exists. Otherwise use `browser-hosted`.
18
+
19
+ ---
20
+
21
+ ## OPEN HIGGSFIELD AI ASSUMPTIONS
22
+
23
+ Frozen upstream assumptions for this kit:
24
+ - repo exposes four studios: image, video, lip sync, cinema
25
+ - browser and desktop workflows both exist
26
+ - `packages/studio/src/models.js` is the model source of truth
27
+ - Muapi is the reference provider engine
28
+ - API auth uses `x-api-key`
29
+ - request flow is submit -> poll -> result
30
+ - uploads are first-class for image-conditioned and audio-conditioned workflows
31
+ - generation history and upload history matter to repeatability
32
+
33
+ If the local fork differs, the fork wins.
34
+
35
+ ---
36
+
37
+ ## EXECUTION SURFACES
38
+
39
+ ### Local fork
40
+
41
+ Expected operator flow:
42
+ 1. inspect `README.md`
43
+ 2. inspect `packages/studio/src/models.js`
44
+ 3. inspect `packages/studio/src/muapi.js`
45
+ 4. inspect relevant studio component
46
+ 5. prepare prompts, assets, and batch order
47
+ 6. execute through the local app surface the fork provides
48
+
49
+ ### Browser-hosted
50
+
51
+ Expected operator flow:
52
+ 1. open hosted app
53
+ 2. load or enter API key
54
+ 3. select studio
55
+ 4. upload or reuse assets
56
+ 5. submit prompts in planned order
57
+ 6. poll and review results
58
+ 7. save result links and notes into output docs
59
+
60
+ ### Desktop app
61
+
62
+ Expected operator flow:
63
+ 1. launch Electron app
64
+ 2. confirm API key availability
65
+ 3. select studio
66
+ 4. reuse locally stored asset history when possible
67
+ 5. run generation batches
68
+ 6. collect outputs and review notes
69
+
70
+ ---
71
+
72
+ ## LOCAL STATE ASSUMPTIONS
73
+
74
+ The upstream repo describes persistent local state for:
75
+ - API key storage
76
+ - upload history
77
+ - generation history
78
+ - lip sync pending-job recovery
79
+
80
+ The agent should treat these as workflow assets:
81
+ - prefer reuse before re-upload
82
+ - document when history should be checked
83
+ - avoid assuming server-side persistence beyond the provider result URL
84
+
85
+ ---
86
+
87
+ ## FRAME ANALYSIS PRIMITIVE
88
+
89
+ When a local reference video exists, frame extraction can be used for shot planning:
90
+
91
+ ```bash
92
+ mkdir -p /tmp/open_higgsfield_frames
93
+ ffmpeg -i "/path/to/reference.mp4" -vf fps=1/2 /tmp/open_higgsfield_frames/frame_%04d.jpg
94
+ ```
95
+
96
+ Use this only when a local file is available. Do not promise it from a remote social URL alone.
97
+
98
+ ---
99
+
100
+ ## OUTPUT WRITING ASSUMPTION
101
+
102
+ All deliverables are written as Markdown in:
103
+
104
+ ```text
105
+ output/<client-slug>/<project-slug>/
106
+ ```
107
+
108
+ The kit does not require its own npm install or custom CLI to be operational.
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+ # check-deps.sh — Verify local dependencies required for local-fork and frame-analysis workflows.
3
+ # Run before your first local-fork session.
4
+ set -e
5
+
6
+ PASS=0
7
+ FAIL=0
8
+
9
+ check() {
10
+ local name="$1"
11
+ local cmd="$2"
12
+ local install_hint="$3"
13
+ if command -v "$cmd" >/dev/null 2>&1; then
14
+ echo "OK $name ($(command -v "$cmd"))"
15
+ PASS=$((PASS + 1))
16
+ else
17
+ echo "MISSING $name — $install_hint"
18
+ FAIL=$((FAIL + 1))
19
+ fi
20
+ }
21
+
22
+ echo "=== Growthub Open Higgsfield — Dependency Check ==="
23
+ echo ""
24
+ check "git" "git" "https://git-scm.com/downloads"
25
+ check "node" "node" "https://nodejs.org"
26
+ check "npm" "npm" "Comes with Node.js"
27
+ check "ffmpeg" "ffmpeg" "brew install ffmpeg OR https://ffmpeg.org/download.html"
28
+ echo ""
29
+ echo "Passed: $PASS | Missing: $FAIL"
30
+
31
+ if [ "$FAIL" -gt 0 ]; then
32
+ echo ""
33
+ echo "Install missing tools before running local-fork or frame-analysis workflows."
34
+ exit 1
35
+ fi
36
+
37
+ echo "All dependencies present. You are ready for local-fork execution."
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+ # clone-fork.sh — Clone and boot the Open Higgsfield AI local fork
3
+ # Run from any location. Installs to ~/open-higgsfield-ai and starts dev server on port 3001.
4
+ set -e
5
+
6
+ FORK_DIR="$HOME/open-higgsfield-ai"
7
+ REPO_URL="https://github.com/Anil-matcha/Open-Higgsfield-AI"
8
+ PORT=3001
9
+
10
+ if [ -d "$FORK_DIR" ]; then
11
+ echo "Fork already exists at $FORK_DIR — skipping clone."
12
+ echo "To re-clone, remove the directory first: rm -rf $FORK_DIR"
13
+ else
14
+ echo "Cloning Open Higgsfield AI → $FORK_DIR"
15
+ git clone "$REPO_URL" "$FORK_DIR"
16
+ fi
17
+
18
+ cd "$FORK_DIR"
19
+
20
+ echo "Installing dependencies..."
21
+ npm install
22
+
23
+ echo ""
24
+ echo "Starting dev server on http://localhost:$PORT"
25
+ echo "Press Ctrl+C to stop."
26
+ echo ""
27
+ npm run dev -- --port "$PORT"
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ // verify-env.mjs — Validate MUAPI_API_KEY from .env before starting a generation session.
3
+ // Usage: node setup/verify-env.mjs
4
+ // Exit 0 = key is valid and reachable. Exit 1 = key missing, invalid, or API unreachable.
5
+
6
+ import { existsSync, readFileSync } from "node:fs";
7
+ import { resolve } from "node:path";
8
+
9
+ const envPath = resolve(process.cwd(), ".env");
10
+
11
+ function parseEnvFile(filePath) {
12
+ const vars = {};
13
+ const lines = readFileSync(filePath, "utf8").split("\n");
14
+ for (const line of lines) {
15
+ const trimmed = line.trim();
16
+ if (!trimmed || trimmed.startsWith("#")) continue;
17
+ const eqIndex = trimmed.indexOf("=");
18
+ if (eqIndex === -1) continue;
19
+ const key = trimmed.slice(0, eqIndex).trim();
20
+ const value = trimmed.slice(eqIndex + 1).trim();
21
+ vars[key] = value;
22
+ }
23
+ return vars;
24
+ }
25
+
26
+ async function main() {
27
+ if (!existsSync(envPath)) {
28
+ console.error("ERROR: .env file not found.");
29
+ console.error("Run: cp .env.example .env then add your MUAPI_API_KEY.");
30
+ process.exit(1);
31
+ }
32
+
33
+ const env = parseEnvFile(envPath);
34
+ const apiKey = env["MUAPI_API_KEY"];
35
+ const baseUrl = env["MUAPI_BASE_URL"] ?? "https://api.muapi.io";
36
+
37
+ if (!apiKey || apiKey === "your_muapi_key_here" || apiKey.trim() === "") {
38
+ console.error("ERROR: MUAPI_API_KEY is not set in .env.");
39
+ console.error("Get your key at https://muapi.ai/dashboard");
40
+ process.exit(1);
41
+ }
42
+
43
+ console.log(`Verifying key against ${baseUrl} ...`);
44
+
45
+ let res;
46
+ try {
47
+ res = await fetch(`${baseUrl}/v1/models`, {
48
+ method: "GET",
49
+ headers: { "x-api-key": apiKey },
50
+ });
51
+ } catch (err) {
52
+ console.error(`ERROR: Could not reach ${baseUrl}.`);
53
+ console.error(err.message);
54
+ process.exit(1);
55
+ }
56
+
57
+ if (res.status === 401 || res.status === 403) {
58
+ console.error(`ERROR: API key rejected (HTTP ${res.status}).`);
59
+ console.error("Check your MUAPI_API_KEY value at https://muapi.ai/dashboard");
60
+ process.exit(1);
61
+ }
62
+
63
+ if (!res.ok) {
64
+ console.error(`ERROR: Unexpected response from Muapi API (HTTP ${res.status}).`);
65
+ process.exit(1);
66
+ }
67
+
68
+ console.log("OK: MUAPI_API_KEY is valid and the API is reachable.");
69
+ process.exit(0);
70
+ }
71
+
72
+ main();