@growthub/cli 0.3.38 → 0.3.40

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 (41) 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 +95 -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 +108 -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 +145 -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 +40 -0
  22. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/patch-cors-proxy.sh +139 -0
  23. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/verify-env.mjs +72 -0
  24. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/skills.md +257 -0
  25. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/asset-tracking.md +5 -0
  26. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/frame-analysis.md +24 -0
  27. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/generation-batch-plan.md +7 -0
  28. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/model-selection-recommendation.md +23 -0
  29. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/platform-ready-execution-handoff.md +17 -0
  30. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-matrix.md +7 -0
  31. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/cinema-generation.md +16 -0
  32. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/image-generation.md +11 -0
  33. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/lip-sync-generation.md +14 -0
  34. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/prompt-templates/video-generation.md +11 -0
  35. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/review-qa-checklist.md +26 -0
  36. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/shot-plan.md +11 -0
  37. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/studio-selection-brief.md +18 -0
  38. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/templates/visual-campaign-brief.md +24 -0
  39. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/validation-checklist.md +49 -0
  40. package/assets/worker-kits/growthub-open-higgsfield-studio-v1/workers/open-higgsfield-studio-operator/CLAUDE.md +264 -0
  41. 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,108 @@
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/patch-cors-proxy.sh",
37
+ "setup/verify-env.mjs",
38
+ "setup/check-deps.sh",
39
+ "output/README.md",
40
+ "templates/visual-campaign-brief.md",
41
+ "templates/studio-selection-brief.md",
42
+ "templates/model-selection-recommendation.md",
43
+ "templates/shot-plan.md",
44
+ "templates/prompt-matrix.md",
45
+ "templates/generation-batch-plan.md",
46
+ "templates/asset-tracking.md",
47
+ "templates/review-qa-checklist.md",
48
+ "templates/platform-ready-execution-handoff.md",
49
+ "templates/frame-analysis.md",
50
+ "templates/prompt-templates/image-generation.md",
51
+ "templates/prompt-templates/video-generation.md",
52
+ "templates/prompt-templates/lip-sync-generation.md",
53
+ "templates/prompt-templates/cinema-generation.md",
54
+ "examples/visual-campaign-brief-sample.md",
55
+ "examples/shot-plan-sample.md",
56
+ "examples/prompt-matrix-sample.md",
57
+ "examples/platform-ready-handoff-sample.md",
58
+ "docs/open-higgsfield-fork-integration.md",
59
+ "docs/provider-adapter-layer.md",
60
+ "growthub-meta/README.md",
61
+ "growthub-meta/kit-standard.md"
62
+ ],
63
+ "setupPaths": {
64
+ "quickstart": "QUICKSTART.md",
65
+ "envExample": ".env.example",
66
+ "setupDir": "setup/",
67
+ "outputDir": "output/"
68
+ },
69
+ "outputStandard": {
70
+ "type": "working-directory",
71
+ "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>/.",
72
+ "requiredPaths": [
73
+ "QUICKSTART.md",
74
+ ".env.example",
75
+ "kit.json",
76
+ "bundles/growthub-open-higgsfield-studio-v1.json",
77
+ "skills.md",
78
+ "workers/open-higgsfield-studio-operator/CLAUDE.md",
79
+ "brands/_template/brand-kit.md",
80
+ "brands/growthub/brand-kit.md",
81
+ "brands/NEW-CLIENT.md",
82
+ "setup/clone-fork.sh",
83
+ "setup/patch-cors-proxy.sh",
84
+ "setup/verify-env.mjs",
85
+ "setup/check-deps.sh",
86
+ "output/README.md",
87
+ "templates",
88
+ "docs",
89
+ "growthub-meta"
90
+ ]
91
+ },
92
+ "bundles": [
93
+ {
94
+ "id": "growthub-open-higgsfield-studio-v1",
95
+ "version": "1.0.0",
96
+ "path": "bundles/growthub-open-higgsfield-studio-v1.json"
97
+ }
98
+ ],
99
+ "executionMode": "export",
100
+ "activationModes": ["export"],
101
+ "compatibility": {
102
+ "cliMinVersion": "0.3.37"
103
+ },
104
+ "provenance": {
105
+ "sourceRepo": "growthub-local",
106
+ "frozenAt": "2026-04-10T00:00:00.000Z"
107
+ }
108
+ }
@@ -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,145 @@
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
+ ## KNOWN FORK ISSUE — CORS POLICY (local-fork mode)
38
+
39
+ **Status:** Fixed. Patch is applied automatically by `setup/clone-fork.sh`.
40
+
41
+ **Root cause:** The upstream repo hardcodes `const BASE_URL = 'https://api.muapi.ai'` in
42
+ `packages/studio/src/muapi.js`. All browser fetch/XHR calls go directly to the external
43
+ API. `api.muapi.ai` does not return `Access-Control-Allow-Origin` headers, so every call
44
+ from `localhost:3001` is blocked by the browser's CORS policy.
45
+
46
+ **Errors you will see without the patch:**
47
+ ```
48
+ Access to fetch at 'https://api.muapi.ai/api/v1/account/balance'
49
+ from origin 'http://localhost:3001' has been blocked by CORS policy:
50
+ No 'Access-Control-Allow-Origin' header is present on the requested resource.
51
+ ```
52
+
53
+ **The fix:**
54
+ 1. `next.config.mjs` — rewrites `/muapi-proxy/:path*` → `https://api.muapi.ai/:path*` server-side
55
+ 2. `packages/studio/src/muapi.js` — `BASE_URL` changed to `'/muapi-proxy'`
56
+
57
+ All browser calls now hit `localhost:3001/muapi-proxy/...` (same origin, no CORS).
58
+ Next.js proxies them to `api.muapi.ai` from the server where CORS does not apply.
59
+
60
+ **To apply manually if not already patched:**
61
+ ```bash
62
+ bash setup/patch-cors-proxy.sh [path-to-fork]
63
+ # defaults to ~/open-higgsfield-ai
64
+ ```
65
+
66
+ **Affected functions in muapi.js:**
67
+ - `getUserBalance` — `/api/v1/account/balance`
68
+ - `submitAndPoll` — `/api/v1/${endpoint}`
69
+ - `pollForResult` — `/api/v1/predictions/${requestId}/result`
70
+ - `uploadFile` (XHR) — `/api/v1/upload_file`
71
+
72
+ ---
73
+
74
+ ## EXECUTION SURFACES
75
+
76
+ ### Local fork
77
+
78
+ Expected operator flow:
79
+ 1. inspect `README.md`
80
+ 2. inspect `packages/studio/src/models.js`
81
+ 3. inspect `packages/studio/src/muapi.js`
82
+ 4. inspect relevant studio component
83
+ 5. prepare prompts, assets, and batch order
84
+ 6. execute through the local app surface the fork provides
85
+
86
+ ### Browser-hosted
87
+
88
+ Expected operator flow:
89
+ 1. open hosted app
90
+ 2. load or enter API key
91
+ 3. select studio
92
+ 4. upload or reuse assets
93
+ 5. submit prompts in planned order
94
+ 6. poll and review results
95
+ 7. save result links and notes into output docs
96
+
97
+ ### Desktop app
98
+
99
+ Expected operator flow:
100
+ 1. launch Electron app
101
+ 2. confirm API key availability
102
+ 3. select studio
103
+ 4. reuse locally stored asset history when possible
104
+ 5. run generation batches
105
+ 6. collect outputs and review notes
106
+
107
+ ---
108
+
109
+ ## LOCAL STATE ASSUMPTIONS
110
+
111
+ The upstream repo describes persistent local state for:
112
+ - API key storage
113
+ - upload history
114
+ - generation history
115
+ - lip sync pending-job recovery
116
+
117
+ The agent should treat these as workflow assets:
118
+ - prefer reuse before re-upload
119
+ - document when history should be checked
120
+ - avoid assuming server-side persistence beyond the provider result URL
121
+
122
+ ---
123
+
124
+ ## FRAME ANALYSIS PRIMITIVE
125
+
126
+ When a local reference video exists, frame extraction can be used for shot planning:
127
+
128
+ ```bash
129
+ mkdir -p /tmp/open_higgsfield_frames
130
+ ffmpeg -i "/path/to/reference.mp4" -vf fps=1/2 /tmp/open_higgsfield_frames/frame_%04d.jpg
131
+ ```
132
+
133
+ Use this only when a local file is available. Do not promise it from a remote social URL alone.
134
+
135
+ ---
136
+
137
+ ## OUTPUT WRITING ASSUMPTION
138
+
139
+ All deliverables are written as Markdown in:
140
+
141
+ ```text
142
+ output/<client-slug>/<project-slug>/
143
+ ```
144
+
145
+ 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,40 @@
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 "Applying CORS proxy patch..."
25
+ # The upstream repo calls api.muapi.ai directly from the browser, which is blocked
26
+ # by CORS policy. This patch routes all API calls through the Next.js server.
27
+ # See setup/patch-cors-proxy.sh for full explanation.
28
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
29
+ if [ -f "$SCRIPT_DIR/patch-cors-proxy.sh" ]; then
30
+ bash "$SCRIPT_DIR/patch-cors-proxy.sh" "$FORK_DIR"
31
+ else
32
+ echo "WARNING: patch-cors-proxy.sh not found — skipping CORS patch."
33
+ echo "You may hit CORS errors when the studio calls api.muapi.ai from the browser."
34
+ fi
35
+
36
+ echo ""
37
+ echo "Starting dev server on http://localhost:$PORT"
38
+ echo "Press Ctrl+C to stop."
39
+ echo ""
40
+ npm run dev -- --port "$PORT"
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env bash
2
+ # patch-cors-proxy.sh — Apply Next.js CORS proxy patch to the Open Higgsfield AI local fork
3
+ #
4
+ # WHY THIS EXISTS
5
+ # ---------------
6
+ # The upstream repo calls api.muapi.ai directly from the browser (BASE_URL in muapi.js).
7
+ # api.muapi.ai does not return Access-Control-Allow-Origin headers, so every browser
8
+ # request from localhost:3001 is blocked by CORS policy.
9
+ #
10
+ # THE FIX
11
+ # -------
12
+ # 1. next.config.mjs — adds a rewrites() block:
13
+ # /muapi-proxy/:path* → https://api.muapi.ai/:path* (server-side, no CORS)
14
+ #
15
+ # 2. packages/studio/src/muapi.js — changes BASE_URL:
16
+ # 'https://api.muapi.ai' → '/muapi-proxy'
17
+ #
18
+ # All fetch/XHR calls now hit the local Next.js server which proxies them server-side.
19
+ # No browser cross-origin request is made. CORS policy never fires.
20
+ #
21
+ # USAGE
22
+ # -----
23
+ # bash setup/patch-cors-proxy.sh [path-to-fork]
24
+ #
25
+ # Defaults to ~/open-higgsfield-ai if no path given.
26
+ # Safe to run multiple times — idempotent.
27
+
28
+ set -e
29
+
30
+ FORK_DIR="${1:-$HOME/open-higgsfield-ai}"
31
+ NEXT_CONFIG="$FORK_DIR/next.config.mjs"
32
+ MUAPI_JS="$FORK_DIR/packages/studio/src/muapi.js"
33
+
34
+ echo ""
35
+ echo "=== CORS Proxy Patch ==="
36
+ echo "Fork: $FORK_DIR"
37
+ echo ""
38
+
39
+ # ── Guard: fork must exist ──────────────────────────────────────────────────
40
+ if [ ! -d "$FORK_DIR" ]; then
41
+ echo "ERROR: Fork not found at $FORK_DIR"
42
+ echo "Run setup/clone-fork.sh first."
43
+ exit 1
44
+ fi
45
+
46
+ if [ ! -f "$NEXT_CONFIG" ]; then
47
+ echo "ERROR: next.config.mjs not found at $NEXT_CONFIG"
48
+ exit 1
49
+ fi
50
+
51
+ if [ ! -f "$MUAPI_JS" ]; then
52
+ echo "ERROR: muapi.js not found at $MUAPI_JS"
53
+ exit 1
54
+ fi
55
+
56
+ # ── Idempotency check ───────────────────────────────────────────────────────
57
+ if grep -q "muapi-proxy" "$NEXT_CONFIG" 2>/dev/null; then
58
+ echo "✓ next.config.mjs already patched — skipping."
59
+ NEXT_DONE=1
60
+ else
61
+ NEXT_DONE=0
62
+ fi
63
+
64
+ if grep -q "muapi-proxy" "$MUAPI_JS" 2>/dev/null; then
65
+ echo "✓ muapi.js already patched — skipping."
66
+ MUAPI_DONE=1
67
+ else
68
+ MUAPI_DONE=0
69
+ fi
70
+
71
+ if [ "$NEXT_DONE" -eq 1 ] && [ "$MUAPI_DONE" -eq 1 ]; then
72
+ echo ""
73
+ echo "Both files already patched. Nothing to do."
74
+ exit 0
75
+ fi
76
+
77
+ # ── Backup originals ────────────────────────────────────────────────────────
78
+ if [ "$NEXT_DONE" -eq 0 ]; then
79
+ cp "$NEXT_CONFIG" "$NEXT_CONFIG.orig"
80
+ fi
81
+ if [ "$MUAPI_DONE" -eq 0 ]; then
82
+ cp "$MUAPI_JS" "$MUAPI_JS.orig"
83
+ fi
84
+
85
+ # ── Patch next.config.mjs ───────────────────────────────────────────────────
86
+ if [ "$NEXT_DONE" -eq 0 ]; then
87
+ cat > "$NEXT_CONFIG" << 'NEXTEOF'
88
+ /** @type {import('next').NextConfig} */
89
+ const nextConfig = {
90
+ transpilePackages: ['studio'],
91
+
92
+ // CORS proxy — forward all Muapi API calls through the Next.js server so
93
+ // the browser never makes cross-origin requests to api.muapi.ai directly.
94
+ // muapi.js uses BASE_URL = '/muapi-proxy', so every fetch/XHR hits
95
+ // /muapi-proxy/api/v1/... which Next.js rewrites to api.muapi.ai server-side.
96
+ async rewrites() {
97
+ return [
98
+ {
99
+ source: '/muapi-proxy/:path*',
100
+ destination: 'https://api.muapi.ai/:path*',
101
+ },
102
+ ];
103
+ },
104
+ };
105
+
106
+ export default nextConfig;
107
+ NEXTEOF
108
+ echo "✓ next.config.mjs patched — added /muapi-proxy rewrites()"
109
+ fi
110
+
111
+ # ── Patch muapi.js ──────────────────────────────────────────────────────────
112
+ if [ "$MUAPI_DONE" -eq 0 ]; then
113
+ # Replace the BASE_URL line only (targeted sed, not full file rewrite)
114
+ sed -i.bak \
115
+ "s|const BASE_URL = 'https://api.muapi.ai';|// Proxy through Next.js to avoid CORS. All calls route through /muapi-proxy/:path*\n// which next.config.mjs rewrites to api.muapi.ai server-side — no CORS headers needed.\nconst BASE_URL = '/muapi-proxy';|" \
116
+ "$MUAPI_JS"
117
+ # Remove sed backup (we already made our own)
118
+ rm -f "$MUAPI_JS.bak"
119
+ echo "✓ muapi.js patched — BASE_URL changed to '/muapi-proxy'"
120
+ fi
121
+
122
+ # ── Verify ───────────────────────────────────────────────────────────────────
123
+ echo ""
124
+ echo "Verifying patch..."
125
+
126
+ if grep -q "muapi-proxy" "$NEXT_CONFIG" && grep -q "muapi-proxy" "$MUAPI_JS"; then
127
+ echo "✓ Patch verified. Both files updated correctly."
128
+ else
129
+ echo "ERROR: Patch verification failed. Check the files manually."
130
+ echo " $NEXT_CONFIG"
131
+ echo " $MUAPI_JS"
132
+ exit 1
133
+ fi
134
+
135
+ echo ""
136
+ echo "CORS proxy patch complete."
137
+ echo "Restart the dev server to pick up next.config.mjs changes:"
138
+ echo " npm run dev -- --port 3001"
139
+ echo ""