@42ws/cli 0.0.3 → 0.0.5

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 CHANGED
@@ -73,7 +73,7 @@ CLI arguments take precedence over the configuration file.
73
73
 
74
74
  ## JSON output mode
75
75
 
76
- Use `--json` for machine-readable output (useful in CI):
76
+ Use `--json` for machine-readable output (useful in CI / AI agents):
77
77
 
78
78
  **Success:**
79
79
  ```json
@@ -84,3 +84,56 @@ Use `--json` for machine-readable output (useful in CI):
84
84
  ```json
85
85
  {"ok":false,"error":{"code":"NOT_LOGGED_IN","message":"You are not logged in.","suggestedFix":"Run `42ws login --token <your-token>` to authenticate."}}
86
86
  ```
87
+
88
+ Every error includes a `code`, `message`, and `suggestedFix`. AI agents should read `suggestedFix` and apply the suggested change before retrying.
89
+
90
+ ## For AI Agents
91
+
92
+ This CLI is designed to be driven by AI coding agents (Claude Code, Cursor, etc.).
93
+
94
+ ### Recommended invocation
95
+
96
+ ```
97
+ npx @42ws/cli@latest publish --yes --json
98
+ ```
99
+
100
+ - `--yes` skips all interactive prompts
101
+ - `--json` makes output machine-readable
102
+
103
+ ### Behavior contract
104
+
105
+ - All commands return `{"ok": true, ...}` on success or `{"ok": false, "error": {...}}` on failure.
106
+ - Errors always include `code`, `message`, and `suggestedFix`. Read `suggestedFix` and apply it before retrying.
107
+ - The CLI never opens a browser or asks for input when `--yes` is set.
108
+ - Site names are auto-derived from the directory name when `--yes` is set and no `--site` is given.
109
+ - Frameworks (Vite / Astro / Next static export / SvelteKit static / plain HTML) are auto-detected from `package.json` and the directory contents.
110
+
111
+ ### Rules for AI agents
112
+
113
+ - **Do not** ask the user for AWS credentials, S3 buckets, or CloudFront — 42ws abstracts these away.
114
+ - **Do not** publish backend code (API routes, server functions, databases). Only static files.
115
+ - **Do not** publish secret files. The CLI rejects `.env`, `.git/`, `node_modules/`, `*.pem`, `*.key`, `id_rsa`, `id_ed25519` automatically.
116
+ - **Do** read `error.suggestedFix` and apply it before retrying.
117
+ - **Do** return the published URL to the user.
118
+
119
+ ### Common error codes
120
+
121
+ | Code | Meaning | Fix |
122
+ |---|---|---|
123
+ | `NOT_LOGGED_IN` | No saved auth | Run `npx @42ws/cli@latest login` (browser auth) |
124
+ | `INVALID_SITE_NAME` | Site name missing or invalid | Add `--site <name>` or pass `--yes` to use directory name |
125
+ | `RESERVED_SITE_NAME` | Subdomain reserved | Pick a different name |
126
+ | `SITE_NAME_TAKEN` | Site already owned by someone | Pick a different name |
127
+ | `OUTPUT_DIR_NOT_FOUND` | `dist/` etc. missing | Run the build command first or pass `--dir <path>` |
128
+ | `NO_FILES_FOUND` | No files to publish | Check `--dir` is correct |
129
+ | `BLOCKED_FILE` | Secret file would be uploaded | Remove the file or add to `.gitignore` |
130
+ | `BUILD_FAILED` | Build command exited non-zero | Fix the build error first |
131
+ | `FORBIDDEN` | License not enabled or not site owner | Ask the account owner |
132
+
133
+ ### Suggested user-facing prompt
134
+
135
+ Users can paste this into their AI assistant:
136
+
137
+ > このプロジェクトを 42ws に公開してください。`npx @42ws/cli@latest publish` を使ってください。エラーが出たら `error.suggestedFix` の指示に従ってください。
138
+
139
+ (English: "Publish this project to 42ws using `npx @42ws/cli@latest publish`. If an error occurs, follow `error.suggestedFix`.")
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAGA,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAoB5C"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAIA,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CA0B5C"}
@@ -1,4 +1,5 @@
1
1
  import { loadConfig, saveConfig } from '../lib/config.js';
2
+ import { apiRequest } from '../lib/api.js';
2
3
  import { success, successMessage, isJsonMode } from '../lib/output.js';
3
4
  export async function logout() {
4
5
  const config = loadConfig();
@@ -11,7 +12,13 @@ export async function logout() {
11
12
  }
12
13
  return;
13
14
  }
14
- // Remove token, keep apiUrl
15
+ // Best-effort: invalidate the token on the server too
16
+ try {
17
+ await apiRequest(config, 'DELETE', '/v1/cli/session');
18
+ }
19
+ catch {
20
+ // ignore — local cleanup is what matters
21
+ }
15
22
  saveConfig({ removeToken: true, apiUrl: config.apiUrl });
16
23
  if (isJsonMode()) {
17
24
  success({ status: 'logged-out' });
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO;IACT,CAAC;IAED,4BAA4B;IAC5B,UAAU,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzD,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,cAAc,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO;IACT,CAAC;IAED,sDAAsD;IACtD,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IAED,UAAU,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzD,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,cAAc,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { open } from './commands/open.js';
7
7
  import { init } from './commands/init.js';
8
8
  import { pull } from './commands/pull.js';
9
9
  import { setJsonMode } from './lib/output.js';
10
- const VERSION = '0.0.3';
10
+ const VERSION = '0.0.5';
11
11
  const HELP = `
12
12
  42ws — Publish static sites in one command
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@42ws/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Publish static sites in one command",
5
5
  "publishConfig": {
6
6
  "access": "public"