@ollie-shop/cli 1.0.2 → 1.1.0
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 +3 -0
- package/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +23 -0
- package/CONTEXT.md +84 -0
- package/README.md +199 -0
- package/dist/index.js +886 -48
- package/package.json +4 -2
- package/src/commands/component-cmd.ts +107 -0
- package/src/commands/help.tsx +90 -17
- package/src/commands/init-cmd.ts +53 -0
- package/src/commands/schema-cmd.ts +34 -0
- package/src/commands/store-cmd.ts +105 -0
- package/src/commands/version-cmd.ts +100 -0
- package/src/commands/whoami.ts +28 -0
- package/src/core/component.ts +76 -0
- package/src/core/schema.ts +136 -0
- package/src/core/store.ts +76 -0
- package/src/core/version.ts +67 -0
- package/src/index.tsx +34 -4
- package/src/utils/output.ts +125 -0
- package/src/utils/parse-args.ts +90 -0
- package/src/utils/supabase.ts +59 -0
- package/src/utils/validate.ts +58 -0
package/.env.example
ADDED
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @ollie-shop/cli@1.0
|
|
2
|
+
> @ollie-shop/cli@1.1.0 build /home/runner/work/ollie-shop/ollie-shop/packages/cli
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
[34mCLI[39m Target: node22
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m64.35 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 202ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @ollie-shop/cli
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 53c165f: feat: add agent-first CLI commands for store, version, and component CRUD
|
|
8
|
+
|
|
9
|
+
Adds six new commands designed for AI/LLM agent consumption:
|
|
10
|
+
|
|
11
|
+
- `whoami` — show current user and organization
|
|
12
|
+
- `store create|list` — create or list stores
|
|
13
|
+
- `version create|list` — create or list versions
|
|
14
|
+
- `component create|list` — create or list components
|
|
15
|
+
- `schema` — introspect resource schemas (JSON Schema output)
|
|
16
|
+
- `init` — write store/version IDs to ollie.json
|
|
17
|
+
|
|
18
|
+
Cross-cutting features:
|
|
19
|
+
|
|
20
|
+
- `-o json` / `-o pretty` / auto-detect (TTY vs pipe)
|
|
21
|
+
- `--fields` to filter output columns
|
|
22
|
+
- `--dry-run` to preview writes without executing
|
|
23
|
+
- `-d '{...}'` raw JSON input mode for mutations
|
|
24
|
+
- Environment variable configuration (`OLLIE_SUPABASE_URL`, `OLLIE_SUPABASE_ANON_KEY`)
|
|
25
|
+
|
|
3
26
|
## 1.0.2
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/CONTEXT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
```
|
|
25
|
+
|
|
26
|
+
The CLI will throw a clear error if a required env var is missing. See `.env.example` for reference.
|
|
27
|
+
|
|
28
|
+
## Typical Agent Workflow
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1. Introspect schemas
|
|
32
|
+
ollieshop schema store.create -o json
|
|
33
|
+
ollieshop schema version.create -o json
|
|
34
|
+
ollieshop schema component.create -o json
|
|
35
|
+
|
|
36
|
+
# 2. Verify identity
|
|
37
|
+
ollieshop whoami -o json
|
|
38
|
+
|
|
39
|
+
# 3. Create store (dry-run first)
|
|
40
|
+
ollieshop store create --data '{"name":"My Store","platform":"vtex","platformStoreId":"mystore"}' --dry-run -o json
|
|
41
|
+
ollieshop store create --data '{"name":"My Store","platform":"vtex","platformStoreId":"mystore"}' -o json
|
|
42
|
+
|
|
43
|
+
# 4. Create version
|
|
44
|
+
ollieshop version create --data '{"storeId":"<STORE_ID>","name":"v1","active":true}' -o json
|
|
45
|
+
|
|
46
|
+
# 5. Write local config
|
|
47
|
+
ollieshop init --store-id <STORE_ID> --version-id <VERSION_ID>
|
|
48
|
+
|
|
49
|
+
# 6. Register components
|
|
50
|
+
ollieshop component create --data '{"versionId":"<VERSION_ID>","name":"FreeShippingBar","slot":"cart_header_full_page","active":true}' -o json
|
|
51
|
+
|
|
52
|
+
# 7. List resources
|
|
53
|
+
ollieshop store list -o json --fields id,name,platform
|
|
54
|
+
ollieshop version list --store-id <STORE_ID> -o json --fields id,name,active
|
|
55
|
+
ollieshop component list --store-id <STORE_ID> -o json --fields id,name,slot,active
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Response Format
|
|
59
|
+
|
|
60
|
+
All commands return:
|
|
61
|
+
```json
|
|
62
|
+
// Success (exit code 0)
|
|
63
|
+
{"data": {...}}
|
|
64
|
+
```
|
|
65
|
+
or
|
|
66
|
+
```json
|
|
67
|
+
// Error (exit code 1)
|
|
68
|
+
{"error": {"message": "..."}}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Check the exit code for success (0) or failure (1).
|
|
72
|
+
|
|
73
|
+
## Available Platforms
|
|
74
|
+
|
|
75
|
+
`vtex`, `shopify`, `vnda`, `custom`
|
|
76
|
+
|
|
77
|
+
## Available Slots (common)
|
|
78
|
+
|
|
79
|
+
- `cart_header_full_page`
|
|
80
|
+
- `cart_footer_full_page`
|
|
81
|
+
- `shipping_address_details_form`
|
|
82
|
+
- `payment_header`
|
|
83
|
+
- `summary_after_totals`
|
|
84
|
+
- `profile_after_email`
|
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
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
|
+
|
|
42
|
+
See `.env.example` for reference. The CLI will throw a clear error if a required variable is missing.
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
### Interactive Commands
|
|
47
|
+
|
|
48
|
+
| Command | Description |
|
|
49
|
+
|---------|-------------|
|
|
50
|
+
| `ollieshop login` | Authenticate via browser (stores token in `~/.ollie-shop/credentials.json`) |
|
|
51
|
+
| `ollieshop start` | Start the development server with hot reload |
|
|
52
|
+
| `ollieshop help` | Show help message |
|
|
53
|
+
| `ollieshop version` | Show CLI version |
|
|
54
|
+
|
|
55
|
+
### Agent Commands
|
|
56
|
+
|
|
57
|
+
Agent commands output structured JSON and are designed for programmatic / AI-agent consumption.
|
|
58
|
+
|
|
59
|
+
#### `whoami`
|
|
60
|
+
|
|
61
|
+
Show the currently authenticated user and their organization.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
ollieshop whoami -o json
|
|
65
|
+
# {"data":{"email":"user@example.com"}}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### `store create|list`
|
|
69
|
+
|
|
70
|
+
Create or list stores in your organization.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# List stores
|
|
74
|
+
ollieshop store list -o json --fields id,name,platform
|
|
75
|
+
|
|
76
|
+
# Create a store (dry-run first)
|
|
77
|
+
ollieshop store create --name "My Store" --platform vtex --platform-store-id mystore --dry-run -o json
|
|
78
|
+
ollieshop store create --name "My Store" --platform vtex --platform-store-id mystore -o json
|
|
79
|
+
|
|
80
|
+
# Create using raw JSON input
|
|
81
|
+
ollieshop store create -d '{"name":"My Store","platform":"vtex","platformStoreId":"mystore"}' -o json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### `version create|list`
|
|
85
|
+
|
|
86
|
+
Create or list versions for a store.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# List versions
|
|
90
|
+
ollieshop version list --store-id <STORE_UUID> -o json --fields id,name,active
|
|
91
|
+
|
|
92
|
+
# Create a version
|
|
93
|
+
ollieshop version create --store-id <STORE_UUID> --name v1 --active -o json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `component create|list`
|
|
97
|
+
|
|
98
|
+
Create or list components for a store (optionally filtered by version).
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# List components
|
|
102
|
+
ollieshop component list --store-id <STORE_UUID> -o json --fields id,name,slot,active
|
|
103
|
+
|
|
104
|
+
# Create a component
|
|
105
|
+
ollieshop component create --version-id <VERSION_UUID> --name FreeShippingBar --slot cart_header_full_page -o json
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### `schema`
|
|
109
|
+
|
|
110
|
+
Introspect resource schemas at runtime. Returns JSON Schema definitions for all available resources and actions.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# List all available schemas
|
|
114
|
+
ollieshop schema -o json
|
|
115
|
+
|
|
116
|
+
# Get schema for a specific resource action
|
|
117
|
+
ollieshop schema store.create -o json
|
|
118
|
+
ollieshop schema component.create -o json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### `init`
|
|
122
|
+
|
|
123
|
+
Write store and version IDs to a local `ollie.json` config file.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
ollieshop init --store-id <STORE_UUID> --version-id <VERSION_UUID> -o json
|
|
127
|
+
# Creates ollie.json: {"storeId":"...","versionId":"..."}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Global Flags
|
|
131
|
+
|
|
132
|
+
| Flag | Short | Description |
|
|
133
|
+
|------|-------|-------------|
|
|
134
|
+
| `--output json\|pretty` | `-o` | Force output format. Auto-detects: JSON when piped, pretty when TTY |
|
|
135
|
+
| `--dry-run` | | Validate inputs without executing mutations |
|
|
136
|
+
| `--fields a,b,c` | | Limit output fields (comma-separated) |
|
|
137
|
+
| `--data '{...}'` | `-d` | Raw JSON payload for mutations (alternative to individual flags) |
|
|
138
|
+
| `--stage <name>` | `-s` | Config stage — loads `ollie.<stage>.json` instead of `ollie.json` |
|
|
139
|
+
|
|
140
|
+
## Response Format
|
|
141
|
+
|
|
142
|
+
All agent commands return a consistent JSON envelope:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
// Success (exit code 0)
|
|
146
|
+
{"data": { ... }}
|
|
147
|
+
|
|
148
|
+
// Error (exit code 1)
|
|
149
|
+
{"error": {"message": "Human-readable error description"}}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The exit code indicates success (0) or failure (1), making the `success` field redundant.
|
|
153
|
+
|
|
154
|
+
## Available Platforms
|
|
155
|
+
|
|
156
|
+
`vtex`, `shopify`, `vnda`, `custom`
|
|
157
|
+
|
|
158
|
+
## Available Slots (common)
|
|
159
|
+
|
|
160
|
+
- `cart_header_full_page`
|
|
161
|
+
- `cart_footer_full_page`
|
|
162
|
+
- `shipping_address_details_form`
|
|
163
|
+
- `payment_header`
|
|
164
|
+
- `summary_after_totals`
|
|
165
|
+
- `profile_after_email`
|
|
166
|
+
|
|
167
|
+
## AI/LLM Agent Usage
|
|
168
|
+
|
|
169
|
+
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.
|
|
170
|
+
|
|
171
|
+
## Architecture
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
src/
|
|
175
|
+
├── index.tsx # Entry point — routes to agent or interactive commands
|
|
176
|
+
├── cli.tsx # Ink app for interactive commands
|
|
177
|
+
├── commands/
|
|
178
|
+
│ ├── whoami.ts # Agent: show current user
|
|
179
|
+
│ ├── store-cmd.ts # Agent: store CRUD
|
|
180
|
+
│ ├── version-cmd.ts # Agent: version CRUD
|
|
181
|
+
│ ├── component-cmd.ts# Agent: component CRUD
|
|
182
|
+
│ ├── schema-cmd.ts # Agent: schema introspection
|
|
183
|
+
│ ├── init-cmd.ts # Agent: write ollie.json
|
|
184
|
+
│ ├── help.tsx # Interactive: help display
|
|
185
|
+
│ ├── login.tsx # Interactive: browser auth
|
|
186
|
+
│ └── start.tsx # Interactive: dev server
|
|
187
|
+
├── core/
|
|
188
|
+
│ ├── store.ts # Store business logic + Supabase queries
|
|
189
|
+
│ ├── version.ts # Version business logic + Supabase queries
|
|
190
|
+
│ ├── component.ts # Component business logic + Supabase queries
|
|
191
|
+
│ └── schema.ts # Zod schemas + JSON Schema generation
|
|
192
|
+
└── utils/
|
|
193
|
+
├── parse-args.ts # CLI argument parser (flags, subcommands, positional)
|
|
194
|
+
├── output.ts # JSON/pretty output formatter + field filtering
|
|
195
|
+
├── validate.ts # UUID, required, enum, resource name validators
|
|
196
|
+
├── supabase.ts # Authenticated Supabase client + org resolution
|
|
197
|
+
├── auth.ts # Browser auth flow + credential storage
|
|
198
|
+
└── config.ts # ollie.json config loader/saver
|
|
199
|
+
```
|