@spike-forms/cli 0.2.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/README.md ADDED
@@ -0,0 +1,222 @@
1
+ # Spike Forms CLI
2
+
3
+ Command-line interface for managing Spike Forms - forms, submissions, projects, and teams.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @spike-forms/cli
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Authenticate via browser
15
+ spike login
16
+
17
+ # Create a form with live preview
18
+ spike forms create-page --name "Contact Form" --preview
19
+
20
+ # Edit and save changes
21
+ spike forms save
22
+
23
+ # List your forms
24
+ spike forms list
25
+ ```
26
+
27
+ ## Authentication
28
+
29
+ ### Browser Login (Recommended)
30
+
31
+ The `login` command opens your browser to authenticate and automatically saves your API key:
32
+
33
+ ```bash
34
+ spike login
35
+ ```
36
+
37
+ Options:
38
+ - `--timeout <seconds>` - Set login timeout (default: 120s)
39
+ - `--no-browser` - Display URL instead of opening browser automatically
40
+
41
+ ### Manual Configuration
42
+
43
+ ```bash
44
+ # Set API key directly
45
+ spike config set api-key <your-api-key>
46
+
47
+ # View current config
48
+ spike config get api-key
49
+ ```
50
+
51
+ ## Forms Management
52
+
53
+ ### Basic Operations
54
+
55
+ ```bash
56
+ # List all forms
57
+ spike forms list
58
+ spike forms list --limit 10 --format json
59
+
60
+ # Get form details
61
+ spike forms get <form-id>
62
+
63
+ # Create a form
64
+ spike forms create --name "Contact Form"
65
+
66
+ # Update a form
67
+ spike forms update <form-id> --name "New Name"
68
+ spike forms update <form-id> --is-active false
69
+
70
+ # Delete a form
71
+ spike forms delete <form-id>
72
+ ```
73
+
74
+ ### Live Preview Workflow
75
+
76
+ Edit forms locally with instant browser refresh. HTML is stored on the server (S3).
77
+
78
+ ```bash
79
+ # Edit existing form with live preview (fetches HTML from server)
80
+ spike forms edit <form-id>
81
+
82
+ # Run preview server in background
83
+ spike forms edit <form-id> --background
84
+
85
+ # Save local changes back to server
86
+ spike forms save
87
+ spike forms save <form-id> --file ./my-form.html
88
+
89
+ # Stop background preview server
90
+ spike forms stop-preview
91
+ ```
92
+
93
+ The preview server:
94
+ - Fetches HTML from server (S3) when you start editing
95
+ - Watches your local HTML file for changes
96
+ - Auto-refreshes the browser via Server-Sent Events
97
+ - Runs on `http://127.0.0.1` with a dynamic port
98
+
99
+ ### Create Form Page (Beta)
100
+
101
+ Create a new form and generate an HTML template in one command:
102
+
103
+ ```bash
104
+ # Create form and HTML file (saves to server automatically)
105
+ spike forms create-page --name "Contact Form"
106
+
107
+ # Create and start preview immediately
108
+ spike forms create-page --name "Contact Form" --preview
109
+
110
+ # Save to custom path
111
+ spike forms create-page --name "Contact Form" --file ./contact.html
112
+ ```
113
+
114
+ The generated HTML includes:
115
+ - Responsive form layout with basic styling
116
+ - Form action pointing to your form's submission endpoint (`/f/{slug}`)
117
+ - Name, email, and message fields (customize as needed)
118
+
119
+ ## Complete Edit Workflow
120
+
121
+ 1. **Start editing**: `spike forms edit <form-id>`
122
+ - Fetches HTML from server (S3)
123
+ - Saves to local file (`./form.html`)
124
+ - Starts live preview server
125
+ - Opens browser
126
+
127
+ 2. **Make changes**: Edit `./form.html` in your editor
128
+ - Browser auto-refreshes on save
129
+
130
+ 3. **Save to server**: `spike forms save`
131
+ - Uploads HTML back to server (S3)
132
+ - Dashboard iframe will show updated form
133
+
134
+ 4. **Stop preview**: Press `Ctrl+C` or run `spike forms stop-preview`
135
+
136
+ ## Submissions
137
+
138
+ ```bash
139
+ # List submissions for a form
140
+ spike submissions list --form-id <form-id>
141
+
142
+ # Get submission details
143
+ spike submissions get <submission-id>
144
+
145
+ # Delete a submission
146
+ spike submissions delete <submission-id>
147
+ ```
148
+
149
+ ## Projects & Teams
150
+
151
+ ```bash
152
+ # Projects
153
+ spike projects list
154
+ spike projects create --name "Website Forms"
155
+ spike projects get <project-id>
156
+
157
+ # Teams
158
+ spike teams list
159
+ spike teams create --name "Marketing"
160
+ spike teams get <team-id>
161
+ ```
162
+
163
+ ## AI Agent Integration
164
+
165
+ Launch OpenCode with Spike Forms knowledge:
166
+
167
+ ```bash
168
+ # Launch OpenCode (must be installed)
169
+ spike agent
170
+
171
+ # Install OpenCode if not present
172
+ spike agent --install
173
+
174
+ # Use specific model
175
+ spike agent --model gpt-4
176
+ ```
177
+
178
+ The agent command installs a skill file that teaches OpenCode about all CLI commands.
179
+
180
+ ## Configuration
181
+
182
+ Config file location: `~/.spike/config.json`
183
+
184
+ ```bash
185
+ # Set values
186
+ spike config set api-key <key>
187
+ spike config set base-url <url>
188
+
189
+ # Get values
190
+ spike config get api-key
191
+ spike config get base-url
192
+ ```
193
+
194
+ ## Environment Variables
195
+
196
+ - `SPIKE_API_KEY` or `SPIKE_TOKEN` - API key for authentication
197
+ - `SPIKE_API_URL` - Custom API base URL
198
+ - `SPIKE_DASHBOARD_URL` - Custom dashboard URL for login
199
+
200
+ ## How It Works
201
+
202
+ ### Form HTML Storage
203
+
204
+ Form HTML templates are stored in S3:
205
+ - `spike forms edit` fetches HTML from API → API fetches from S3 → returns to CLI
206
+ - `spike forms save` uploads HTML to API → API stores in S3
207
+ - Dashboard iframe loads HTML from S3 URL stored in form's `html_url` field
208
+
209
+ ### Form Submission Flow
210
+
211
+ 1. User visits form page (HTML served from S3 or embedded)
212
+ 2. Form action points to `/f/{slug}` on the Spike API
213
+ 3. Submissions are stored in database
214
+ 4. View submissions via CLI or dashboard
215
+
216
+ ### Login Flow
217
+
218
+ 1. CLI generates a secure state token
219
+ 2. Opens browser to dashboard consent page
220
+ 3. User approves CLI access
221
+ 4. Dashboard creates API key and redirects to CLI callback
222
+ 5. CLI saves the API key to config
@@ -0,0 +1,2 @@
1
+
2
+ export { }