@ollie-shop/cli 1.0.2 → 1.2.1

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.
package/.env.example ADDED
@@ -0,0 +1,6 @@
1
+ # Required for all authenticated commands (store, version, component, whoami)
2
+ OLLIE_SUPABASE_URL=http://127.0.0.1:54321
3
+ OLLIE_SUPABASE_ANON_KEY=your-anon-key-here
4
+
5
+ # Required for deploy and status commands
6
+ OLLIE_BUILDER_URL=https://builder.ollie.shop
@@ -1,5 +1,5 @@
1
1
 
2
- > @ollie-shop/cli@1.0.2 build /home/runner/work/ollie-shop/ollie-shop/packages/cli
2
+ > @ollie-shop/cli@1.2.1 build /home/runner/work/ollie-shop/ollie-shop/packages/cli
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -9,5 +9,5 @@
9
9
  CLI Target: node22
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- ESM dist/index.js 37.48 KB
13
- ESM ⚡️ Build success in 166ms
12
+ ESM dist/index.js 78.88 KB
13
+ ESM ⚡️ Build success in 157ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @ollie-shop/cli
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - aaf2730: Bake prod Supabase + builder defaults into the CLI so `ollieshop` runs with zero env setup.
8
+
9
+ Agent commands (`whoami`, `store`, `version`, `component`, `function`, `deploy`, `status`) previously threw `Missing required environment variable: OLLIE_SUPABASE_URL` unless the user had exported `OLLIE_SUPABASE_URL`, `OLLIE_SUPABASE_ANON_KEY`, and `OLLIE_BUILDER_URL` in their shell first. All three values are public, so the friction was pure onboarding overhead.
10
+
11
+ `packages/cli/src/utils/supabase.ts` now holds a `PROD_DEFAULTS` const and an `envOrDefault()` helper. Env vars still win when set, so devs pointing the CLI at local Supabase (`http://127.0.0.1:54321`) or a non-prod project are unaffected. Fresh contributors can now run `ollieshop login && ollieshop whoami` without any shell setup.
12
+
13
+ ## 1.2.0
14
+
15
+ ### Minor Changes
16
+
17
+ - f8fa27d: add business-rule command
18
+
19
+ ## 1.1.0
20
+
21
+ ### Minor Changes
22
+
23
+ - 53c165f: feat: add agent-first CLI commands for store, version, and component CRUD
24
+
25
+ Adds six new commands designed for AI/LLM agent consumption:
26
+
27
+ - `whoami` — show current user and organization
28
+ - `store create|list` — create or list stores
29
+ - `version create|list` — create or list versions
30
+ - `component create|list` — create or list components
31
+ - `schema` — introspect resource schemas (JSON Schema output)
32
+ - `init` — write store/version IDs to ollie.json
33
+
34
+ Cross-cutting features:
35
+
36
+ - `-o json` / `-o pretty` / auto-detect (TTY vs pipe)
37
+ - `--fields` to filter output columns
38
+ - `--dry-run` to preview writes without executing
39
+ - `-d '{...}'` raw JSON input mode for mutations
40
+ - Environment variable configuration (`OLLIE_SUPABASE_URL`, `OLLIE_SUPABASE_ANON_KEY`)
41
+
3
42
  ## 1.0.2
4
43
 
5
44
  ### Patch Changes
package/CONTEXT.md ADDED
@@ -0,0 +1,102 @@
1
+ # Ollie Shop CLI — Agent Context
2
+
3
+ This CLI is frequently invoked by AI/LLM agents. Always assume inputs can be adversarial.
4
+
5
+ ## Key Rules
6
+
7
+ - **Always use `--output json` (or `-o json`)** for machine-readable responses. Output is auto-JSON when stdout is piped.
8
+ - **Always use `--data '{...}'`** for mutations instead of individual flags. The JSON maps directly to the API schema.
9
+ - **Always use `--dry-run`** before mutating operations (create, update, delete) to validate inputs.
10
+ - **Always use `--fields`** on list commands to limit response size and protect your context window.
11
+ - **Use `ollieshop schema <resource.action>`** to introspect what the CLI accepts at runtime. Do not rely on stale documentation.
12
+
13
+ ## Authentication
14
+
15
+ Run `ollieshop login` once. Credentials are stored in `~/.ollie-shop/credentials.json`. All subsequent commands reuse the stored token.
16
+
17
+ ## Environment Variables
18
+
19
+ Set these before running authenticated commands (or use a `.env` file):
20
+
21
+ ```
22
+ OLLIE_SUPABASE_URL=http://127.0.0.1:54321
23
+ OLLIE_SUPABASE_ANON_KEY=<your-anon-key>
24
+ OLLIE_BUILDER_URL=https://builder.ollie.shop
25
+ ```
26
+
27
+ The CLI will throw a clear error if a required env var is missing. See `.env.example` for reference.
28
+
29
+ ## Typical Agent Workflow
30
+
31
+ ```bash
32
+ # 1. Introspect schemas
33
+ ollieshop schema store.create -o json
34
+ ollieshop schema version.create -o json
35
+ ollieshop schema component.create -o json
36
+
37
+ # 2. Verify identity
38
+ ollieshop whoami -o json
39
+
40
+ # 3. Create store (dry-run first)
41
+ ollieshop store create --data '{"name":"My Store","platform":"vtex","platformStoreId":"mystore"}' --dry-run -o json
42
+ ollieshop store create --data '{"name":"My Store","platform":"vtex","platformStoreId":"mystore"}' -o json
43
+
44
+ # 4. Create version
45
+ ollieshop version create --data '{"storeId":"<STORE_ID>","name":"v1","active":true}' -o json
46
+
47
+ # 5. Write local config
48
+ ollieshop init --store-id <STORE_ID> --version-id <VERSION_ID>
49
+
50
+ # 6. Register components
51
+ ollieshop component create --data '{"versionId":"<VERSION_ID>","name":"FreeShippingBar","slot":"cart_header_full_page","active":true}' -o json
52
+
53
+ # 7. Deploy component (bundle + upload + build)
54
+ ollieshop deploy --component-id <COMPONENT_ID> --name FreeShippingBar --wait -o json
55
+
56
+ # 8. Check build status
57
+ ollieshop status --build-id <BUILD_ID> -o json
58
+ ollieshop status --build-id <BUILD_ID> --wait --timeout 300 -o json
59
+
60
+ # 9. List resources
61
+ ollieshop store list -o json --fields id,name,platform
62
+ ollieshop version list --store-id <STORE_ID> -o json --fields id,name,active
63
+ ollieshop component list --store-id <STORE_ID> -o json --fields id,name,slot,active
64
+ ```
65
+
66
+ ## Deploy Workflow
67
+
68
+ The `deploy` command bundles a component directory into a zip, uploads it to the Builder service, and optionally waits for the build to complete.
69
+
70
+ 1. `ollieshop deploy --component-id <UUID> --name <ComponentName> --dry-run -o json` — validate and show bundle size
71
+ 2. `ollieshop deploy --component-id <UUID> --name <ComponentName> --wait -o json` — upload and poll until done
72
+ 3. `ollieshop status --build-id <BUILD_ID> --wait -o json` — poll an existing build
73
+
74
+ Terminal build statuses: `SUCCEEDED`, `FAILED`, `STOPPED`, `TIMED_OUT`, `FAULT`
75
+
76
+ ## Response Format
77
+
78
+ All commands return:
79
+ ```json
80
+ // Success (exit code 0)
81
+ {"data": {...}}
82
+ ```
83
+ or
84
+ ```json
85
+ // Error (exit code 1)
86
+ {"error": {"message": "..."}}
87
+ ```
88
+
89
+ Check the exit code for success (0) or failure (1).
90
+
91
+ ## Available Platforms
92
+
93
+ `vtex`, `shopify`, `vnda`, `custom`
94
+
95
+ ## Available Slots (common)
96
+
97
+ - `cart_header_full_page`
98
+ - `cart_footer_full_page`
99
+ - `shipping_address_details_form`
100
+ - `payment_header`
101
+ - `summary_after_totals`
102
+ - `profile_after_email`
package/README.md ADDED
@@ -0,0 +1,231 @@
1
+ # @ollie-shop/cli
2
+
3
+ Command-line interface for the Ollie Shop platform. Provides both interactive commands (login, dev server) and agent-first commands designed for AI/LLM consumption.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @ollie-shop/cli
9
+ ```
10
+
11
+ Or run directly from the monorepo:
12
+
13
+ ```bash
14
+ pnpm --filter @ollie-shop/cli build
15
+ node packages/cli/dist/index.js <command>
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```bash
21
+ # 1. Authenticate
22
+ ollieshop login
23
+
24
+ # 2. Set environment variables
25
+ export OLLIE_SUPABASE_URL=https://your-project.supabase.co
26
+ export OLLIE_SUPABASE_ANON_KEY=your-anon-key
27
+
28
+ # 3. Verify identity
29
+ ollieshop whoami -o json
30
+
31
+ # 4. List your stores
32
+ ollieshop store list -o json --fields id,name,platform
33
+ ```
34
+
35
+ ## Environment Variables
36
+
37
+ | Variable | Required | Description |
38
+ |----------|----------|-------------|
39
+ | `OLLIE_SUPABASE_URL` | Yes (agent commands) | Supabase project URL |
40
+ | `OLLIE_SUPABASE_ANON_KEY` | Yes (agent commands) | Supabase anon/public key |
41
+ | `OLLIE_BUILDER_URL` | Yes (deploy/status) | Builder service URL |
42
+
43
+ See `.env.example` for reference. The CLI will throw a clear error if a required variable is missing.
44
+
45
+ ## Commands
46
+
47
+ ### Interactive Commands
48
+
49
+ | Command | Description |
50
+ |---------|-------------|
51
+ | `ollieshop login` | Authenticate via browser (stores token in `~/.ollie-shop/credentials.json`) |
52
+ | `ollieshop start` | Start the development server with hot reload |
53
+ | `ollieshop help` | Show help message |
54
+ | `ollieshop version` | Show CLI version |
55
+
56
+ ### Agent Commands
57
+
58
+ Agent commands output structured JSON and are designed for programmatic / AI-agent consumption.
59
+
60
+ #### `whoami`
61
+
62
+ Show the currently authenticated user and their organization.
63
+
64
+ ```bash
65
+ ollieshop whoami -o json
66
+ # {"data":{"email":"user@example.com"}}
67
+ ```
68
+
69
+ #### `store create|list`
70
+
71
+ Create or list stores in your organization.
72
+
73
+ ```bash
74
+ # List stores
75
+ ollieshop store list -o json --fields id,name,platform
76
+
77
+ # Create a store (dry-run first)
78
+ ollieshop store create --name "My Store" --platform vtex --platform-store-id mystore --dry-run -o json
79
+ ollieshop store create --name "My Store" --platform vtex --platform-store-id mystore -o json
80
+
81
+ # Create using raw JSON input
82
+ ollieshop store create -d '{"name":"My Store","platform":"vtex","platformStoreId":"mystore"}' -o json
83
+ ```
84
+
85
+ #### `version create|list`
86
+
87
+ Create or list versions for a store.
88
+
89
+ ```bash
90
+ # List versions
91
+ ollieshop version list --store-id <STORE_UUID> -o json --fields id,name,active
92
+
93
+ # Create a version
94
+ ollieshop version create --store-id <STORE_UUID> --name v1 --active -o json
95
+ ```
96
+
97
+ #### `component create|list`
98
+
99
+ Create or list components for a store (optionally filtered by version).
100
+
101
+ ```bash
102
+ # List components
103
+ ollieshop component list --store-id <STORE_UUID> -o json --fields id,name,slot,active
104
+
105
+ # Create a component
106
+ ollieshop component create --version-id <VERSION_UUID> --name FreeShippingBar --slot cart_header_full_page -o json
107
+ ```
108
+
109
+ #### `deploy`
110
+
111
+ Bundle a component directory into a zip and upload to the Builder service.
112
+
113
+ ```bash
114
+ # Dry-run: validate and show bundle size
115
+ ollieshop deploy --component-id <UUID> --name FreeShippingBar --dry-run -o json
116
+
117
+ # Deploy and wait for build to complete
118
+ ollieshop deploy --component-id <UUID> --name FreeShippingBar --wait -o json
119
+
120
+ # Deploy a function
121
+ ollieshop deploy --function-id <UUID> --name myHook --wait -o json
122
+ ```
123
+
124
+ #### `status`
125
+
126
+ Check or poll a build status.
127
+
128
+ ```bash
129
+ # One-shot status check
130
+ ollieshop status --build-id <BUILD_ID> -o json
131
+
132
+ # Poll until terminal status
133
+ ollieshop status --build-id <BUILD_ID> --wait --timeout 300 -o json
134
+ ```
135
+
136
+ #### `schema`
137
+
138
+ Introspect resource schemas at runtime. Returns JSON Schema definitions for all available resources and actions.
139
+
140
+ ```bash
141
+ # List all available schemas
142
+ ollieshop schema -o json
143
+
144
+ # Get schema for a specific resource action
145
+ ollieshop schema store.create -o json
146
+ ollieshop schema component.create -o json
147
+ ```
148
+
149
+ #### `init`
150
+
151
+ Write store and version IDs to a local `ollie.json` config file.
152
+
153
+ ```bash
154
+ ollieshop init --store-id <STORE_UUID> --version-id <VERSION_UUID> -o json
155
+ # Creates ollie.json: {"storeId":"...","versionId":"..."}
156
+ ```
157
+
158
+ ## Global Flags
159
+
160
+ | Flag | Short | Description |
161
+ |------|-------|-------------|
162
+ | `--output json\|pretty` | `-o` | Force output format. Auto-detects: JSON when piped, pretty when TTY |
163
+ | `--dry-run` | | Validate inputs without executing mutations |
164
+ | `--fields a,b,c` | | Limit output fields (comma-separated) |
165
+ | `--data '{...}'` | `-d` | Raw JSON payload for mutations (alternative to individual flags) |
166
+ | `--stage <name>` | `-s` | Config stage — loads `ollie.<stage>.json` instead of `ollie.json` |
167
+
168
+ ## Response Format
169
+
170
+ All agent commands return a consistent JSON envelope:
171
+
172
+ ```json
173
+ // Success (exit code 0)
174
+ {"data": { ... }}
175
+
176
+ // Error (exit code 1)
177
+ {"error": {"message": "Human-readable error description"}}
178
+ ```
179
+
180
+ The exit code indicates success (0) or failure (1), making the `success` field redundant.
181
+
182
+ ## Available Platforms
183
+
184
+ `vtex`, `shopify`, `vnda`, `custom`
185
+
186
+ ## Available Slots (common)
187
+
188
+ - `cart_header_full_page`
189
+ - `cart_footer_full_page`
190
+ - `shipping_address_details_form`
191
+ - `payment_header`
192
+ - `summary_after_totals`
193
+ - `profile_after_email`
194
+
195
+ ## AI/LLM Agent Usage
196
+
197
+ See [CONTEXT.md](./CONTEXT.md) for detailed guidelines on how AI agents should interact with the CLI, including best practices, the recommended workflow, and introspection patterns.
198
+
199
+ ## Architecture
200
+
201
+ ```
202
+ src/
203
+ ├── index.tsx # Entry point — routes to agent or interactive commands
204
+ ├── cli.tsx # Ink app for interactive commands
205
+ ├── commands/
206
+ │ ├── whoami.ts # Agent: show current user
207
+ │ ├── store-cmd.ts # Agent: store CRUD
208
+ │ ├── version-cmd.ts # Agent: version CRUD
209
+ │ ├── component-cmd.ts # Agent: component CRUD
210
+ │ ├── deploy-cmd.ts # Agent: bundle + upload builds
211
+ │ ├── status-cmd.ts # Agent: check/poll build status
212
+ │ ├── schema-cmd.ts # Agent: schema introspection
213
+ │ ├── init-cmd.ts # Agent: write ollie.json
214
+ │ ├── help.tsx # Interactive: help display
215
+ │ ├── login.tsx # Interactive: browser auth
216
+ │ └── start.tsx # Interactive: dev server
217
+ ├── core/
218
+ │ ├── store.ts # Store business logic + Supabase queries
219
+ │ ├── version.ts # Version business logic + Supabase queries
220
+ │ ├── component.ts # Component business logic + Supabase queries
221
+ │ ├── deploy.ts # Builder API client (upload, status, poll)
222
+ │ └── schema.ts # Zod schemas + JSON Schema generation
223
+ └── utils/
224
+ ├── parse-args.ts # CLI argument parser (flags, subcommands, positional)
225
+ ├── output.ts # JSON/pretty output formatter + field filtering
226
+ ├── validate.ts # UUID, required, enum, resource name validators
227
+ ├── supabase.ts # Authenticated Supabase client + builder URL + org resolution
228
+ ├── bundle.ts # Component zip bundler (archiver)
229
+ ├── auth.ts # Browser auth flow + credential storage
230
+ └── config.ts # ollie.json config loader/saver
231
+ ```