@soloworks/smking-wizard 0.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/CHANGELOG.md +31 -0
- package/README.md +90 -0
- package/dist/bin.mjs +1916 -0
- package/dist/bin.mjs.map +1 -0
- package/package.json +60 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @soloworks/smking-wizard
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
Initial release — single-command install wizard for smking SDKs.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **OAuth PKCE flow** — public client with localhost callback (ports 8235–8240), 6-min timeout, browser auto-open with URL fallback for SSH.
|
|
10
|
+
- **Framework detection** — Laravel (via `artisan` presence) and Next.js App Router (via `package.json` + `app/` or `src/app/`).
|
|
11
|
+
- **Package manager detection** — pnpm > bun > yarn > npm via lockfile.
|
|
12
|
+
- **Deterministic installers**:
|
|
13
|
+
- Laravel: `composer require smking/laravel` → `vendor:publish --tag=smking-config` → `.env` keys → `config:clear`.
|
|
14
|
+
- Next.js: `<pm> add @soloworks/smking-next` → `.env.local` keys → AST-style edit of `app/layout.tsx` to add `<SmkingAEO />`.
|
|
15
|
+
- **AI agent loop** — Claude Sonnet 4.6 via smking's gateway proxy (no customer Anthropic key needed). 6 typed tools (`detect_framework`, `detect_package_manager`, `install_package`, `set_env`, `run_doctor`, `report_failure`), zero bash, Zod-locked env keys.
|
|
16
|
+
- **Doctor verification** — runs `php artisan smking:doctor --json` (Laravel) or `smking-next doctor --json` (Next.js), parses structured output, agent retries up to 3× per failing check.
|
|
17
|
+
- **Failure telemetry** — unfixable failures POST to `/api/v1/doctor-reports` with structured ticket so smking founder can triage from dashboard.
|
|
18
|
+
- **Safety guards** — refuse on production-like environments (Node env / Vercel / Docker / Railway / fly.io / `/var/www` heuristics) and refuse on dirty git working tree, both with explicit override flags.
|
|
19
|
+
- **ink TUI** — welcome screen with trust signals, OAuth waiting screen with URL fallback, run screen with rolling progress log, done/error terminals.
|
|
20
|
+
|
|
21
|
+
### Architecture
|
|
22
|
+
|
|
23
|
+
- Backend: smking SaaS routes `/api/v1/wizard/{install-prompt, gateway/*, doctor-reports}` + dashboard inbox `/dashboard/[siteId]/doctor-reports`.
|
|
24
|
+
- DB: `doctor_reports`, `wizard_sessions` tables. `oauth_codes` gains PKCE columns.
|
|
25
|
+
- LLM proxy: per-session 200K token quota + per-user 5 sessions/day quota enforced server-side.
|
|
26
|
+
|
|
27
|
+
### Known limitations
|
|
28
|
+
|
|
29
|
+
- WordPress: out of scope. WP plugin install runs through `wp-admin` zip upload, not CLI.
|
|
30
|
+
- CI mode: `--ci` flag with personal API key not yet implemented.
|
|
31
|
+
- Token-level quota accounting: currently uses request-count proxy (80 req/session). Full token-stream parsing planned for 0.2.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @soloworks/smking-wizard
|
|
2
|
+
|
|
3
|
+
AI-powered install wizard for smking SDKs. One command installs the SDK, configures your `.env`, and verifies the install with a doctor check.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @soloworks/smking-wizard
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Supported frameworks: **Laravel** ([smking/laravel](https://packagist.org/packages/smking/laravel)) and **Next.js** ([@soloworks/smking-next](https://www.npmjs.com/package/@soloworks/smking-next)).
|
|
10
|
+
|
|
11
|
+
## What the wizard does
|
|
12
|
+
|
|
13
|
+
1. Opens your browser to log in to smking (OAuth)
|
|
14
|
+
2. Detects your framework (Laravel or Next.js App Router)
|
|
15
|
+
3. Runs the install command sequence (`composer require` / `pnpm add`)
|
|
16
|
+
4. Writes `SMKING_API_KEY` + `SMKING_BASE_URL` to your `.env`
|
|
17
|
+
5. For Next.js: injects `<SmkingAEO />` into `app/layout.tsx`
|
|
18
|
+
6. Runs `smking:doctor` to verify the install
|
|
19
|
+
7. If a check fails, an AI agent attempts to auto-fix (up to 3 retries per check)
|
|
20
|
+
8. If the agent gives up, posts a structured failure ticket back to smking so the founder can investigate
|
|
21
|
+
|
|
22
|
+
## What the wizard will NEVER do
|
|
23
|
+
|
|
24
|
+
- Commit, push, stash, or otherwise mutate git state — you review the diff yourself
|
|
25
|
+
- Read or upload your `.env` values to any server
|
|
26
|
+
- Run destructive commands (`rm`, `drop`, `migrate:fresh`, etc.)
|
|
27
|
+
- Modify environment variables other than `SMKING_*`
|
|
28
|
+
- Install packages other than the smking SDK for your framework
|
|
29
|
+
|
|
30
|
+
The agent's tool surface is 8 typed functions: `detect_framework`, `detect_package_manager`, `install_package`, `set_env`, `run_doctor`, `read_project_file` (cwd-scoped, extension-allowlisted), `run_artisan` (Laravel-only, 8 commands allowlisted), and `report_failure`. No bash, no generic file ops, no escape hatches.
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
- Node 20.10+
|
|
35
|
+
- A clean git working tree (the wizard wants its diff to be unambiguous — override with `--allow-dirty`)
|
|
36
|
+
- Not a production-like environment (override with `--allow-prod`)
|
|
37
|
+
|
|
38
|
+
## Flags
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
--debug Verbose debug output (also writes to /tmp/smking-wizard.log)
|
|
42
|
+
--dry-run Print intended changes without writing files
|
|
43
|
+
--allow-prod Override production-environment refusal
|
|
44
|
+
--allow-dirty Override the git-status-must-be-clean check
|
|
45
|
+
--version Print version
|
|
46
|
+
--help Print usage
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Environment variables
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
SMKING_SAAS_URL Override the SaaS origin the wizard talks to.
|
|
53
|
+
Default: https://smking-alone.vercel.app (current
|
|
54
|
+
production deploy). Set to http://localhost:3001
|
|
55
|
+
for local dev against a `pnpm dev` SaaS.
|
|
56
|
+
SMKING_WIZARD_CLIENT_ID Override the OAuth client_id (default: smking_wizard_v1).
|
|
57
|
+
Only useful when running against a custom SaaS
|
|
58
|
+
deploy that registered a different client.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## How LLM cost works
|
|
62
|
+
|
|
63
|
+
Wizard's LLM calls go through the smking gateway proxy. **The customer never sees or pays for an Anthropic API key** — smking covers it as a customer-onboarding cost.
|
|
64
|
+
|
|
65
|
+
The agent runs `claude-opus-4-7` with adaptive thinking + prompt caching on the system prompt, so a typical install does 4–6 round-trips at ≈ $0.05 total.
|
|
66
|
+
|
|
67
|
+
Quota caps (enforced server-side):
|
|
68
|
+
- 200,000 tokens per wizard session
|
|
69
|
+
- 5 sessions per user per day
|
|
70
|
+
|
|
71
|
+
If you hit the daily limit during testing, wait until UTC midnight or DM smking support.
|
|
72
|
+
|
|
73
|
+
## For SSH / remote dev environments
|
|
74
|
+
|
|
75
|
+
The wizard opens your browser via [`open`](https://npm.im/open). If you're SSH'd into a remote machine, that won't work — but the TUI also prints the OAuth URL as text. Copy that URL to a browser on your laptop, log in, and the wizard's localhost callback will catch the redirect (because the laptop's browser proxies the localhost callback to your SSH tunnel — assuming you've set up port forwarding for one of `8235-8240`).
|
|
76
|
+
|
|
77
|
+
For headless CI: not yet supported. CI mode (`--ci` with a personal API key) is on the roadmap.
|
|
78
|
+
|
|
79
|
+
## How to debug a failed install
|
|
80
|
+
|
|
81
|
+
If the doctor check fails and the agent can't fix it after 3 retries, the wizard automatically files a ticket to smking support with:
|
|
82
|
+
- Which checks failed (structured list)
|
|
83
|
+
- Your environment (Node / PHP / framework versions)
|
|
84
|
+
- Raw doctor output
|
|
85
|
+
|
|
86
|
+
You'll see a ticket ID printed (`dr_xxxxxxxxxxxx`). smking support can look it up directly — no need to send a separate email with logs.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT. See [LICENSE](../../LICENSE).
|