usecloudy 0.3.2 → 0.3.3
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 +4 -4
- package/dist/index.js +319 -255
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Cloudy CLI
|
|
2
2
|
|
|
3
|
-
The command line for [Cloudy](https://
|
|
3
|
+
The command line for [Cloudy](https://usecloudy.ai): publish pages and docs folders as links
|
|
4
4
|
people comment on, keep every version, and give the comments back to your coding agent.
|
|
5
5
|
|
|
6
6
|
```sh
|
|
@@ -17,7 +17,7 @@ Or run it once without installing: `npx usecloudy publish page.html`.
|
|
|
17
17
|
Without npm, use the install script:
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
curl -fsSL https://
|
|
20
|
+
curl -fsSL https://usecloudy.ai/install.sh | sh
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
The script puts the CLI in `~/.cloudtifact` (commands `cloudy` and `cloudtifact`) and adds `~/.cloudtifact/bin` to your PATH. Open a new terminal afterwards.
|
|
@@ -25,7 +25,7 @@ The script puts the CLI in `~/.cloudtifact` (commands `cloudy` and `cloudtifact`
|
|
|
25
25
|
```sh
|
|
26
26
|
cloudy login
|
|
27
27
|
cloudy publish page.html # one page or folder → a link
|
|
28
|
-
cloudy copy https://
|
|
28
|
+
cloudy copy https://cloudy.page/<id>/ # your own copy of a page someone sent
|
|
29
29
|
cloudy context pull --space <id> # Discord thread linked to the space
|
|
30
30
|
cloudy init && cloudy push # a repo's docs folder, versioned
|
|
31
31
|
cloudy comments --toon # what reviewers said, compact for agents
|
|
@@ -93,6 +93,6 @@ The tokens from `login` are stored in `~/.config/cloudtifact/config.json` (or `$
|
|
|
93
93
|
|
|
94
94
|
## Docs
|
|
95
95
|
|
|
96
|
-
Every command and option: the [CLI reference](https://
|
|
96
|
+
Every command and option: the [CLI reference](https://usecloudy.ai/docs/reference/cli).
|
|
97
97
|
|
|
98
98
|
MIT licensed.
|
package/dist/index.js
CHANGED
|
@@ -12,15 +12,253 @@ import { createHash } from "node:crypto";
|
|
|
12
12
|
import { createInterface } from "node:readline/promises";
|
|
13
13
|
import { Readable, Transform } from "node:stream";
|
|
14
14
|
import { pipeline } from "node:stream/promises";
|
|
15
|
+
//#region src/config.ts
|
|
16
|
+
/**
|
|
17
|
+
* Pinned, never derived from the site domain: saved sign-ins and each folder's space are keyed by this address, so a
|
|
18
|
+
* new default would sign everyone out and make publish create a new space each time (docs/domain-move.md).
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_API_URL = "https://api.cloudtifact.com";
|
|
21
|
+
const REPO_CONFIG_FILE = ".cloudtifact.json";
|
|
22
|
+
function homeDir(env = process.env) {
|
|
23
|
+
return env.CLOUDTIFACT_HOME || os.homedir();
|
|
24
|
+
}
|
|
25
|
+
function globalConfigDir(env = process.env) {
|
|
26
|
+
if (env.CLOUDTIFACT_CONFIG_DIR) return env.CLOUDTIFACT_CONFIG_DIR;
|
|
27
|
+
const xdg = env.XDG_CONFIG_HOME || path.join(homeDir(env), ".config");
|
|
28
|
+
return path.join(xdg, "cloudtifact");
|
|
29
|
+
}
|
|
30
|
+
function globalConfigPath(env = process.env) {
|
|
31
|
+
return path.join(globalConfigDir(env), "config.json");
|
|
32
|
+
}
|
|
33
|
+
async function readGlobalConfig(env = process.env) {
|
|
34
|
+
const file = globalConfigPath(env);
|
|
35
|
+
if (!existsSync(file)) return {};
|
|
36
|
+
try {
|
|
37
|
+
const data = JSON.parse(await readFile(file, "utf8"));
|
|
38
|
+
return data && typeof data === "object" ? data : {};
|
|
39
|
+
} catch {
|
|
40
|
+
throw new Error(`Could not parse ${file}. Fix or delete it, then run \`cloudy login\`.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function writeGlobalConfig(config, env = process.env) {
|
|
44
|
+
const dir = globalConfigDir(env);
|
|
45
|
+
await mkdir(dir, {
|
|
46
|
+
recursive: true,
|
|
47
|
+
mode: 448
|
|
48
|
+
});
|
|
49
|
+
const file = globalConfigPath(env);
|
|
50
|
+
await writeFile(file, `${JSON.stringify(config, null, 2)}\n`, { mode: 384 });
|
|
51
|
+
await chmod(file, 384);
|
|
52
|
+
}
|
|
53
|
+
async function clearGlobalConfig(env = process.env) {
|
|
54
|
+
await rm(globalConfigPath(env), { force: true });
|
|
55
|
+
}
|
|
56
|
+
/** env CLOUDTIFACT_API_URL > config file > default. */
|
|
57
|
+
function resolveApiUrl(config, env = process.env) {
|
|
58
|
+
return (env.CLOUDTIFACT_API_URL || config.apiUrl || "https://api.cloudtifact.com").replace(/\/+$/, "");
|
|
59
|
+
}
|
|
60
|
+
/** The API the saved token was issued by: the apiUrl saved with it (`login` always saves both), else the default. */
|
|
61
|
+
function tokenApiUrl(config) {
|
|
62
|
+
return (config.apiUrl || "https://api.cloudtifact.com").replace(/\/+$/, "");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The saved token, but only for the API it came from. CLOUDTIFACT_API_URL can point the CLI at another API; the
|
|
66
|
+
* token is never sent there (that API could keep it and use it against ours). For another API you're signed out.
|
|
67
|
+
*/
|
|
68
|
+
function savedTokenFor(config, apiUrl) {
|
|
69
|
+
return config.token && sameApi(tokenApiUrl(config), apiUrl) ? config.token : void 0;
|
|
70
|
+
}
|
|
71
|
+
function sameApi(a, b) {
|
|
72
|
+
const norm = (u) => {
|
|
73
|
+
try {
|
|
74
|
+
return new URL(u).href.replace(/\/+$/, "");
|
|
75
|
+
} catch {
|
|
76
|
+
return u.replace(/\/+$/, "");
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return norm(a) === norm(b);
|
|
80
|
+
}
|
|
81
|
+
const sameAccount = (a, b) => a.handle === b.handle && sameApi(a.apiUrl, b.apiUrl);
|
|
82
|
+
/** The active account (the top-level fields), if signed in. Very old configs saved a token without a handle: "". */
|
|
83
|
+
function activeAccount(config) {
|
|
84
|
+
if (!config.token) return void 0;
|
|
85
|
+
const { token, handle = "", workspace } = config;
|
|
86
|
+
return {
|
|
87
|
+
apiUrl: tokenApiUrl(config),
|
|
88
|
+
token,
|
|
89
|
+
handle,
|
|
90
|
+
...workspace ? { workspace } : {}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Every signed-in account, the active one first. Configs from before `accounts` hold just the active one. */
|
|
94
|
+
function accountsOf(config) {
|
|
95
|
+
const active = activeAccount(config);
|
|
96
|
+
const others = (config.accounts ?? []).filter((a) => !active || !sameAccount(a, active));
|
|
97
|
+
return active ? [active, ...others] : others;
|
|
98
|
+
}
|
|
99
|
+
/** Adds or updates an account and makes it the active one. */
|
|
100
|
+
function withActiveAccount(config, account) {
|
|
101
|
+
const { apiUrl, token, handle, workspace } = account;
|
|
102
|
+
const others = accountsOf(config).filter((a) => !sameAccount(a, account));
|
|
103
|
+
const { workspace: _w, ...rest } = config;
|
|
104
|
+
return {
|
|
105
|
+
...rest,
|
|
106
|
+
apiUrl,
|
|
107
|
+
token,
|
|
108
|
+
handle,
|
|
109
|
+
...workspace ? { workspace } : {},
|
|
110
|
+
accounts: [account, ...others]
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Updates an account in place (its default workspace, say), active or not. */
|
|
114
|
+
function withAccountUpdated(config, account) {
|
|
115
|
+
const active = activeAccount(config);
|
|
116
|
+
if (active && sameAccount(active, account)) return withActiveAccount(config, account);
|
|
117
|
+
return {
|
|
118
|
+
...config,
|
|
119
|
+
accounts: accountsOf(config).map((a) => sameAccount(a, account) ? account : a)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Forgets an account. If it was the active one, the next signed-in account becomes active. */
|
|
123
|
+
function withoutAccount(config, account) {
|
|
124
|
+
const left = accountsOf(config).filter((a) => !sameAccount(a, account));
|
|
125
|
+
const directories = Object.fromEntries(Object.entries(config.directories ?? {}).filter(([, h]) => h !== account.handle || left.some((a) => a.handle === h)));
|
|
126
|
+
const { apiUrl: _a, token: _t, handle: _h, workspace: _w, accounts: _l, directories: _d, ...rest } = config;
|
|
127
|
+
const base = {
|
|
128
|
+
...rest,
|
|
129
|
+
...Object.keys(directories).length ? { directories } : {}
|
|
130
|
+
};
|
|
131
|
+
const [next] = left;
|
|
132
|
+
return next ? withActiveAccount({
|
|
133
|
+
...base,
|
|
134
|
+
accounts: left
|
|
135
|
+
}, next) : base;
|
|
136
|
+
}
|
|
137
|
+
/** The account a folder is bound to (`cloudy switch <handle> --here`): the nearest bound folder above `from`. */
|
|
138
|
+
function boundHandle(config, from = process.cwd()) {
|
|
139
|
+
const dirs = config.directories ?? {};
|
|
140
|
+
let dir = path.resolve(from);
|
|
141
|
+
for (;;) {
|
|
142
|
+
const handle = dirs[dir];
|
|
143
|
+
if (handle) return {
|
|
144
|
+
handle,
|
|
145
|
+
dir
|
|
146
|
+
};
|
|
147
|
+
const parent = path.dirname(dir);
|
|
148
|
+
if (parent === dir) return null;
|
|
149
|
+
dir = parent;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** The folder `switch --here` binds: the repo root (or git root) above `from`, else `from`. */
|
|
153
|
+
function bindingRoot(from = process.cwd()) {
|
|
154
|
+
return findInitRoot(from);
|
|
155
|
+
}
|
|
156
|
+
/** Walks up from `from` to the nearest directory holding .cloudtifact.json. */
|
|
157
|
+
function findRepoRoot(from = process.cwd()) {
|
|
158
|
+
let dir = path.resolve(from);
|
|
159
|
+
for (;;) {
|
|
160
|
+
if (existsSync(path.join(dir, ".cloudtifact.json"))) return dir;
|
|
161
|
+
const parent = path.dirname(dir);
|
|
162
|
+
if (parent === dir) return null;
|
|
163
|
+
dir = parent;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** Where `init` should write: the git root above `from`, else `from`. */
|
|
167
|
+
function findInitRoot(from = process.cwd()) {
|
|
168
|
+
let dir = path.resolve(from);
|
|
169
|
+
for (;;) {
|
|
170
|
+
if (existsSync(path.join(dir, ".git")) || existsSync(path.join(dir, ".cloudtifact.json"))) return dir;
|
|
171
|
+
const parent = path.dirname(dir);
|
|
172
|
+
if (parent === dir) return path.resolve(from);
|
|
173
|
+
dir = parent;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The project work belongs to, recorded on each version: CLOUDTIFACT_PROJECT, else the name of the git repo above
|
|
178
|
+
* `from` (a worktree counts as its main repo), else null.
|
|
179
|
+
*/
|
|
180
|
+
function projectName(from = process.cwd(), env = process.env) {
|
|
181
|
+
const named = env.CLOUDTIFACT_PROJECT?.trim();
|
|
182
|
+
if (named) return named.slice(0, 100);
|
|
183
|
+
let dir = path.resolve(from);
|
|
184
|
+
for (;;) {
|
|
185
|
+
const git = path.join(dir, ".git");
|
|
186
|
+
if (existsSync(git)) {
|
|
187
|
+
try {
|
|
188
|
+
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync(git, "utf8"));
|
|
189
|
+
const main = m?.[1] ? /^(.*)[\\/]\.git[\\/]worktrees[\\/]/.exec(m[1].trim()) : null;
|
|
190
|
+
if (main?.[1]) return path.basename(main[1]);
|
|
191
|
+
} catch {}
|
|
192
|
+
return path.basename(dir);
|
|
193
|
+
}
|
|
194
|
+
const parent = path.dirname(dir);
|
|
195
|
+
if (parent === dir) return null;
|
|
196
|
+
dir = parent;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function parseRepoConfig(raw, file = REPO_CONFIG_FILE) {
|
|
200
|
+
const bad = (why) => /* @__PURE__ */ new Error(`${file}: ${why}`);
|
|
201
|
+
if (!raw || typeof raw !== "object") throw bad("expected a JSON object");
|
|
202
|
+
const { dir, targets } = raw;
|
|
203
|
+
if (typeof dir !== "string" || !dir) throw bad("\"dir\" must be a non-empty string");
|
|
204
|
+
if (!Array.isArray(targets)) throw bad("\"targets\" must be an array");
|
|
205
|
+
return {
|
|
206
|
+
dir,
|
|
207
|
+
targets: targets.map((t, i) => {
|
|
208
|
+
if (!t || typeof t !== "object" || typeof t.spaceId !== "string") throw bad(`targets[${i}].spaceId must be a string`);
|
|
209
|
+
const { spaceId, label } = t;
|
|
210
|
+
return label ? {
|
|
211
|
+
spaceId,
|
|
212
|
+
label
|
|
213
|
+
} : { spaceId };
|
|
214
|
+
})
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async function readRepoConfig(root) {
|
|
218
|
+
const file = path.join(root, REPO_CONFIG_FILE);
|
|
219
|
+
let raw;
|
|
220
|
+
try {
|
|
221
|
+
raw = JSON.parse(await readFile(file, "utf8"));
|
|
222
|
+
} catch (err) {
|
|
223
|
+
throw new Error(`Could not read ${file}: ${err.message}`);
|
|
224
|
+
}
|
|
225
|
+
return parseRepoConfig(raw, file);
|
|
226
|
+
}
|
|
227
|
+
async function writeRepoConfig(root, config) {
|
|
228
|
+
await writeFile(path.join(root, REPO_CONFIG_FILE), `${JSON.stringify(config, null, 2)}\n`);
|
|
229
|
+
}
|
|
230
|
+
const realOrSelf = (p) => {
|
|
231
|
+
try {
|
|
232
|
+
return realpathSync(p);
|
|
233
|
+
} catch {
|
|
234
|
+
return p;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
async function loadRepo(from = process.cwd()) {
|
|
238
|
+
const root = findRepoRoot(from);
|
|
239
|
+
if (!root) throw new Error(`No ${REPO_CONFIG_FILE} found here or above. Run \`cloudy init\` first.`);
|
|
240
|
+
const config = await readRepoConfig(root);
|
|
241
|
+
const docsDir = path.resolve(root, config.dir);
|
|
242
|
+
const rel = path.relative(realOrSelf(root), realOrSelf(docsDir));
|
|
243
|
+
if (rel.startsWith("..") || path.isAbsolute(rel)) throw new Error(`"dir" in ${REPO_CONFIG_FILE} must be inside the repo (got "${config.dir}")`);
|
|
244
|
+
return {
|
|
245
|
+
root,
|
|
246
|
+
config,
|
|
247
|
+
docsDir
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
15
251
|
//#region ../contract/src/domains.ts
|
|
16
252
|
/**
|
|
17
253
|
* Every public Cloudy address that code bakes in (CLI default, install command, landing and
|
|
18
|
-
* docs links, badges). One place
|
|
254
|
+
* docs links, badges). One place:
|
|
19
255
|
*
|
|
20
|
-
* export const PUBLIC_DOMAIN: string | null = "
|
|
256
|
+
* export const PUBLIC_DOMAIN: string | null = "usecloudy.ai";
|
|
21
257
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
258
|
+
* PUBLIC_DOMAIN is the site and app domain: app.<domain> and the bare domain for the landing site. The API and the MCP
|
|
259
|
+
* server live on SERVICE_DOMAIN instead, which never moves (the domain move, docs/domain-move.md): the CLI keys saved
|
|
260
|
+
* sign-ins and each folder's space by its API address, and connectors are signed in to the MCP address, so moving
|
|
261
|
+
* either would break every old CLI and connector. What users publish (artifact pages and live apps) runs other people's HTML and JS, so it lives
|
|
24
262
|
* on a separate registrable domain, USER_CONTENT_DOMAIN, the way GitHub uses githubusercontent.com:
|
|
25
263
|
* pages at the bare user-content domain (/<id>/, /t/<token>/), apps at <slug>.<user-content domain>.
|
|
26
264
|
* Then a published page can never read or set cookies for the app or for Clerk. While PUBLIC_DOMAIN is
|
|
@@ -29,9 +267,20 @@ import { pipeline } from "node:stream/promises";
|
|
|
29
267
|
* Deploy-time values (PUBLIC_API_URL, WEB_URL, ... in each wrangler.jsonc) are separate: wrangler
|
|
30
268
|
* reads JSON, not this file. Update those in the same change (see README "Choosing the domain").
|
|
31
269
|
*/
|
|
32
|
-
const PUBLIC_DOMAIN = "
|
|
270
|
+
const PUBLIC_DOMAIN = "usecloudy.ai";
|
|
33
271
|
/** Separate domain for published pages and live apps. Must not share a registrable domain with PUBLIC_DOMAIN. */
|
|
34
|
-
const USER_CONTENT_DOMAIN = "
|
|
272
|
+
const USER_CONTENT_DOMAIN = "cloudy.page";
|
|
273
|
+
/** Where api., mcp., admin. and assets. live, forever: programs talk to them, and they keep their addresses. */
|
|
274
|
+
const SERVICE_DOMAIN = "cloudtifact.com";
|
|
275
|
+
/**
|
|
276
|
+
* Every site and app domain we serve, new first. During and after the move (docs/domain-move.md) both answer: the old
|
|
277
|
+
* one sends page loads on to the new one and answers everything else in place.
|
|
278
|
+
*/
|
|
279
|
+
const OWN_SITE_DOMAINS = ["usecloudy.ai", "cloudtifact.com"];
|
|
280
|
+
/** Every user-content domain we serve (published pages, live apps), new first. Same rule as OWN_SITE_DOMAINS. */
|
|
281
|
+
const OWN_USER_CONTENT_DOMAINS = ["cloudy.page", "cloudtifact.app"];
|
|
282
|
+
OWN_SITE_DOMAINS.map((d) => `https://app.${d}`);
|
|
283
|
+
OWN_USER_CONTENT_DOMAINS.map((d) => `https://${d}`);
|
|
35
284
|
const WORKERS_DEV = {
|
|
36
285
|
api: "https://cloudtifact-api.cloudtifact.workers.dev",
|
|
37
286
|
web: "https://cloudtifact-docs.cloudtifact.workers.dev",
|
|
@@ -39,10 +288,10 @@ const WORKERS_DEV = {
|
|
|
39
288
|
landing: "https://cloudtifact-landing.cloudtifact.workers.dev",
|
|
40
289
|
appsHost: USER_CONTENT_DOMAIN
|
|
41
290
|
};
|
|
42
|
-
function urlsFor(domain, userContent = USER_CONTENT_DOMAIN) {
|
|
291
|
+
function urlsFor(domain, userContent = USER_CONTENT_DOMAIN, service = SERVICE_DOMAIN) {
|
|
43
292
|
if (!domain) return WORKERS_DEV;
|
|
44
293
|
return {
|
|
45
|
-
api: `https://api.${
|
|
294
|
+
api: `https://api.${service}`,
|
|
46
295
|
web: `https://app.${domain}`,
|
|
47
296
|
content: `https://${userContent}`,
|
|
48
297
|
landing: `https://${domain}`,
|
|
@@ -5832,7 +6081,11 @@ const RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
|
5832
6081
|
"billing",
|
|
5833
6082
|
"blog",
|
|
5834
6083
|
"cloudtifact",
|
|
6084
|
+
"cloudy",
|
|
5835
6085
|
"docs",
|
|
6086
|
+
"edit",
|
|
6087
|
+
"explore",
|
|
6088
|
+
"feed",
|
|
5836
6089
|
"guest",
|
|
5837
6090
|
"help",
|
|
5838
6091
|
"login",
|
|
@@ -5842,6 +6095,7 @@ const RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
|
5842
6095
|
"null",
|
|
5843
6096
|
"official",
|
|
5844
6097
|
"owner",
|
|
6098
|
+
"posts",
|
|
5845
6099
|
"root",
|
|
5846
6100
|
"security",
|
|
5847
6101
|
"settings",
|
|
@@ -5854,7 +6108,9 @@ const RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
|
5854
6108
|
"support",
|
|
5855
6109
|
"system",
|
|
5856
6110
|
"team",
|
|
6111
|
+
"topics",
|
|
5857
6112
|
"undefined",
|
|
6113
|
+
"usecloudy",
|
|
5858
6114
|
"www"
|
|
5859
6115
|
]);
|
|
5860
6116
|
const isReservedName = (name) => RESERVED_NAMES.has(name) || name.startsWith("deleted-");
|
|
@@ -5944,6 +6200,13 @@ const embedTokenOutput = object({
|
|
|
5944
6200
|
token: string(),
|
|
5945
6201
|
expiresAt: number$1()
|
|
5946
6202
|
});
|
|
6203
|
+
object({ state: string().min(1).max(4096) });
|
|
6204
|
+
const signInCarryOutput = object({
|
|
6205
|
+
ticket: string(),
|
|
6206
|
+
expiresAt: number$1()
|
|
6207
|
+
});
|
|
6208
|
+
object({ ticket: string().min(1).max(200) });
|
|
6209
|
+
const signInCarryRedeemOutput = object({ state: string() });
|
|
5947
6210
|
object({ token: string().max(200).optional() });
|
|
5948
6211
|
const createSessionOutput = object({
|
|
5949
6212
|
token: string(),
|
|
@@ -6575,7 +6838,8 @@ const listSpacesOutput = object({ spaces: array(spaceSchema) });
|
|
|
6575
6838
|
object({
|
|
6576
6839
|
q: string().trim().min(1).max(200),
|
|
6577
6840
|
workspace: workspaceSlugSchema.optional(),
|
|
6578
|
-
limit: number().int().min(1).max(50).default(10)
|
|
6841
|
+
limit: number().int().min(1).max(50).default(10),
|
|
6842
|
+
status: _enum(["active", "archived"]).default("active")
|
|
6579
6843
|
});
|
|
6580
6844
|
const findSpacesOutput = object({ spaces: array(spaceSchema.extend({
|
|
6581
6845
|
/** Pages (HTML and Markdown files) in its latest version. */
|
|
@@ -6584,7 +6848,7 @@ const findSpacesOutput = object({ spaces: array(spaceSchema.extend({
|
|
|
6584
6848
|
score: number$1(),
|
|
6585
6849
|
/** Close enough to publish into without being told (topicMatch in find.ts). */
|
|
6586
6850
|
strong: boolean(),
|
|
6587
|
-
/** The page whose title matched
|
|
6851
|
+
/** The page whose title matched at least as well as the space's name, if any. */
|
|
6588
6852
|
page: string().nullable(),
|
|
6589
6853
|
/** That page's path in the space ("plans/pricing.html"), for a link straight to it. */
|
|
6590
6854
|
pagePath: string().nullable().optional()
|
|
@@ -6652,7 +6916,8 @@ const listVersionsOutput = object({ versions: array(versionSchema) });
|
|
|
6652
6916
|
const getVersionOutput = object({
|
|
6653
6917
|
version: versionSchema,
|
|
6654
6918
|
files: array(fileEntrySchema),
|
|
6655
|
-
diff: diffSchema
|
|
6919
|
+
diff: diffSchema,
|
|
6920
|
+
pagePictures: record(string(), string()).optional()
|
|
6656
6921
|
});
|
|
6657
6922
|
const getFileOutput = object({
|
|
6658
6923
|
versionNumber: number$1().int(),
|
|
@@ -7206,7 +7471,8 @@ const spacePageOutput = object({
|
|
|
7206
7471
|
revisions: record(string(), array(commentRevisionSchema)),
|
|
7207
7472
|
discord: array(discordLinkSchema),
|
|
7208
7473
|
muted: boolean().nullable().optional(),
|
|
7209
|
-
mentionPeople: array(userSchema).nullable().optional()
|
|
7474
|
+
mentionPeople: array(userSchema).nullable().optional(),
|
|
7475
|
+
pagePictures: record(string(), string()).optional()
|
|
7210
7476
|
}).nullable()
|
|
7211
7477
|
});
|
|
7212
7478
|
//#endregion
|
|
@@ -7559,13 +7825,16 @@ const customDomainStatusSchema = _enum([
|
|
|
7559
7825
|
]);
|
|
7560
7826
|
const LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
7561
7827
|
/** Hosts nobody may connect: ours, and the shared hosting ones a customer can't own. */
|
|
7562
|
-
const NOT_CONNECTABLE = [
|
|
7828
|
+
const NOT_CONNECTABLE = [.../* @__PURE__ */ new Set([
|
|
7563
7829
|
USER_CONTENT_DOMAIN,
|
|
7564
|
-
"
|
|
7830
|
+
"usecloudy.ai",
|
|
7831
|
+
SERVICE_DOMAIN,
|
|
7832
|
+
...OWN_SITE_DOMAINS,
|
|
7833
|
+
...OWN_USER_CONTENT_DOMAINS,
|
|
7565
7834
|
"workers.dev",
|
|
7566
7835
|
"pages.dev",
|
|
7567
7836
|
"localhost"
|
|
7568
|
-
].filter(Boolean);
|
|
7837
|
+
])].filter(Boolean);
|
|
7569
7838
|
/** Lowercased, trimmed, without a scheme, path or trailing dot: what someone pasted, as a hostname. */
|
|
7570
7839
|
function normalizeHostname(input) {
|
|
7571
7840
|
let h = input.trim().toLowerCase();
|
|
@@ -7814,6 +8083,8 @@ function createClient(opts) {
|
|
|
7814
8083
|
devLogin: (input) => call("POST", "/v1/auth/dev-login", devLoginOutput, input),
|
|
7815
8084
|
createEmbedToken: () => call("POST", "/v1/auth/embed-token", embedTokenOutput),
|
|
7816
8085
|
createVisitorLink: () => call("POST", "/v1/auth/visitor-link", embedTokenOutput),
|
|
8086
|
+
createSignInCarry: (state) => call("POST", "/v1/auth/carry", signInCarryOutput, { state }),
|
|
8087
|
+
redeemSignInCarry: (ticket) => call("POST", "/v1/auth/carry/redeem", signInCarryRedeemOutput, { ticket }),
|
|
7817
8088
|
/** With the identity provider's session token as this client's token: swaps it for a browser sign-in. */
|
|
7818
8089
|
createSession: (input = {}) => call("POST", "/v1/sessions", createSessionOutput, input),
|
|
7819
8090
|
me: () => call("GET", "/v1/me", meOutput),
|
|
@@ -7874,6 +8145,7 @@ function createClient(opts) {
|
|
|
7874
8145
|
const params = new URLSearchParams({ q: query.q });
|
|
7875
8146
|
if (query.workspace) params.set("workspace", query.workspace);
|
|
7876
8147
|
if (query.limit) params.set("limit", String(query.limit));
|
|
8148
|
+
if (query.status) params.set("status", query.status);
|
|
7877
8149
|
return call("GET", `/v1/spaces/find?${params}`, findSpacesOutput);
|
|
7878
8150
|
},
|
|
7879
8151
|
createSpace: (input) => call("POST", "/v1/spaces", spaceSchema, input),
|
|
@@ -8722,238 +8994,6 @@ function resolveOptions(options) {
|
|
|
8722
8994
|
//#region ../contract/src/toon.ts
|
|
8723
8995
|
const toToon = (value) => encode(value);
|
|
8724
8996
|
//#endregion
|
|
8725
|
-
//#region src/config.ts
|
|
8726
|
-
const DEFAULT_API_URL = PUBLIC_URLS.api;
|
|
8727
|
-
const REPO_CONFIG_FILE = ".cloudtifact.json";
|
|
8728
|
-
function homeDir(env = process.env) {
|
|
8729
|
-
return env.CLOUDTIFACT_HOME || os.homedir();
|
|
8730
|
-
}
|
|
8731
|
-
function globalConfigDir(env = process.env) {
|
|
8732
|
-
if (env.CLOUDTIFACT_CONFIG_DIR) return env.CLOUDTIFACT_CONFIG_DIR;
|
|
8733
|
-
const xdg = env.XDG_CONFIG_HOME || path.join(homeDir(env), ".config");
|
|
8734
|
-
return path.join(xdg, "cloudtifact");
|
|
8735
|
-
}
|
|
8736
|
-
function globalConfigPath(env = process.env) {
|
|
8737
|
-
return path.join(globalConfigDir(env), "config.json");
|
|
8738
|
-
}
|
|
8739
|
-
async function readGlobalConfig(env = process.env) {
|
|
8740
|
-
const file = globalConfigPath(env);
|
|
8741
|
-
if (!existsSync(file)) return {};
|
|
8742
|
-
try {
|
|
8743
|
-
const data = JSON.parse(await readFile(file, "utf8"));
|
|
8744
|
-
return data && typeof data === "object" ? data : {};
|
|
8745
|
-
} catch {
|
|
8746
|
-
throw new Error(`Could not parse ${file}. Fix or delete it, then run \`cloudy login\`.`);
|
|
8747
|
-
}
|
|
8748
|
-
}
|
|
8749
|
-
async function writeGlobalConfig(config, env = process.env) {
|
|
8750
|
-
const dir = globalConfigDir(env);
|
|
8751
|
-
await mkdir(dir, {
|
|
8752
|
-
recursive: true,
|
|
8753
|
-
mode: 448
|
|
8754
|
-
});
|
|
8755
|
-
const file = globalConfigPath(env);
|
|
8756
|
-
await writeFile(file, `${JSON.stringify(config, null, 2)}\n`, { mode: 384 });
|
|
8757
|
-
await chmod(file, 384);
|
|
8758
|
-
}
|
|
8759
|
-
async function clearGlobalConfig(env = process.env) {
|
|
8760
|
-
await rm(globalConfigPath(env), { force: true });
|
|
8761
|
-
}
|
|
8762
|
-
/** env CLOUDTIFACT_API_URL > config file > default. */
|
|
8763
|
-
function resolveApiUrl(config, env = process.env) {
|
|
8764
|
-
return (env.CLOUDTIFACT_API_URL || config.apiUrl || DEFAULT_API_URL).replace(/\/+$/, "");
|
|
8765
|
-
}
|
|
8766
|
-
/** The API the saved token was issued by: the apiUrl saved with it (`login` always saves both), else the default. */
|
|
8767
|
-
function tokenApiUrl(config) {
|
|
8768
|
-
return (config.apiUrl || DEFAULT_API_URL).replace(/\/+$/, "");
|
|
8769
|
-
}
|
|
8770
|
-
/**
|
|
8771
|
-
* The saved token, but only for the API it came from. CLOUDTIFACT_API_URL can point the CLI at another API; the
|
|
8772
|
-
* token is never sent there (that API could keep it and use it against ours). For another API you're signed out.
|
|
8773
|
-
*/
|
|
8774
|
-
function savedTokenFor(config, apiUrl) {
|
|
8775
|
-
return config.token && sameApi(tokenApiUrl(config), apiUrl) ? config.token : void 0;
|
|
8776
|
-
}
|
|
8777
|
-
function sameApi(a, b) {
|
|
8778
|
-
const norm = (u) => {
|
|
8779
|
-
try {
|
|
8780
|
-
return new URL(u).href.replace(/\/+$/, "");
|
|
8781
|
-
} catch {
|
|
8782
|
-
return u.replace(/\/+$/, "");
|
|
8783
|
-
}
|
|
8784
|
-
};
|
|
8785
|
-
return norm(a) === norm(b);
|
|
8786
|
-
}
|
|
8787
|
-
const sameAccount = (a, b) => a.handle === b.handle && sameApi(a.apiUrl, b.apiUrl);
|
|
8788
|
-
/** The active account (the top-level fields), if signed in. Very old configs saved a token without a handle: "". */
|
|
8789
|
-
function activeAccount(config) {
|
|
8790
|
-
if (!config.token) return void 0;
|
|
8791
|
-
const { token, handle = "", workspace } = config;
|
|
8792
|
-
return {
|
|
8793
|
-
apiUrl: tokenApiUrl(config),
|
|
8794
|
-
token,
|
|
8795
|
-
handle,
|
|
8796
|
-
...workspace ? { workspace } : {}
|
|
8797
|
-
};
|
|
8798
|
-
}
|
|
8799
|
-
/** Every signed-in account, the active one first. Configs from before `accounts` hold just the active one. */
|
|
8800
|
-
function accountsOf(config) {
|
|
8801
|
-
const active = activeAccount(config);
|
|
8802
|
-
const others = (config.accounts ?? []).filter((a) => !active || !sameAccount(a, active));
|
|
8803
|
-
return active ? [active, ...others] : others;
|
|
8804
|
-
}
|
|
8805
|
-
/** Adds or updates an account and makes it the active one. */
|
|
8806
|
-
function withActiveAccount(config, account) {
|
|
8807
|
-
const { apiUrl, token, handle, workspace } = account;
|
|
8808
|
-
const others = accountsOf(config).filter((a) => !sameAccount(a, account));
|
|
8809
|
-
const { workspace: _w, ...rest } = config;
|
|
8810
|
-
return {
|
|
8811
|
-
...rest,
|
|
8812
|
-
apiUrl,
|
|
8813
|
-
token,
|
|
8814
|
-
handle,
|
|
8815
|
-
...workspace ? { workspace } : {},
|
|
8816
|
-
accounts: [account, ...others]
|
|
8817
|
-
};
|
|
8818
|
-
}
|
|
8819
|
-
/** Updates an account in place (its default workspace, say), active or not. */
|
|
8820
|
-
function withAccountUpdated(config, account) {
|
|
8821
|
-
const active = activeAccount(config);
|
|
8822
|
-
if (active && sameAccount(active, account)) return withActiveAccount(config, account);
|
|
8823
|
-
return {
|
|
8824
|
-
...config,
|
|
8825
|
-
accounts: accountsOf(config).map((a) => sameAccount(a, account) ? account : a)
|
|
8826
|
-
};
|
|
8827
|
-
}
|
|
8828
|
-
/** Forgets an account. If it was the active one, the next signed-in account becomes active. */
|
|
8829
|
-
function withoutAccount(config, account) {
|
|
8830
|
-
const left = accountsOf(config).filter((a) => !sameAccount(a, account));
|
|
8831
|
-
const directories = Object.fromEntries(Object.entries(config.directories ?? {}).filter(([, h]) => h !== account.handle || left.some((a) => a.handle === h)));
|
|
8832
|
-
const { apiUrl: _a, token: _t, handle: _h, workspace: _w, accounts: _l, directories: _d, ...rest } = config;
|
|
8833
|
-
const base = {
|
|
8834
|
-
...rest,
|
|
8835
|
-
...Object.keys(directories).length ? { directories } : {}
|
|
8836
|
-
};
|
|
8837
|
-
const [next] = left;
|
|
8838
|
-
return next ? withActiveAccount({
|
|
8839
|
-
...base,
|
|
8840
|
-
accounts: left
|
|
8841
|
-
}, next) : base;
|
|
8842
|
-
}
|
|
8843
|
-
/** The account a folder is bound to (`cloudy switch <handle> --here`): the nearest bound folder above `from`. */
|
|
8844
|
-
function boundHandle(config, from = process.cwd()) {
|
|
8845
|
-
const dirs = config.directories ?? {};
|
|
8846
|
-
let dir = path.resolve(from);
|
|
8847
|
-
for (;;) {
|
|
8848
|
-
const handle = dirs[dir];
|
|
8849
|
-
if (handle) return {
|
|
8850
|
-
handle,
|
|
8851
|
-
dir
|
|
8852
|
-
};
|
|
8853
|
-
const parent = path.dirname(dir);
|
|
8854
|
-
if (parent === dir) return null;
|
|
8855
|
-
dir = parent;
|
|
8856
|
-
}
|
|
8857
|
-
}
|
|
8858
|
-
/** The folder `switch --here` binds: the repo root (or git root) above `from`, else `from`. */
|
|
8859
|
-
function bindingRoot(from = process.cwd()) {
|
|
8860
|
-
return findInitRoot(from);
|
|
8861
|
-
}
|
|
8862
|
-
/** Walks up from `from` to the nearest directory holding .cloudtifact.json. */
|
|
8863
|
-
function findRepoRoot(from = process.cwd()) {
|
|
8864
|
-
let dir = path.resolve(from);
|
|
8865
|
-
for (;;) {
|
|
8866
|
-
if (existsSync(path.join(dir, ".cloudtifact.json"))) return dir;
|
|
8867
|
-
const parent = path.dirname(dir);
|
|
8868
|
-
if (parent === dir) return null;
|
|
8869
|
-
dir = parent;
|
|
8870
|
-
}
|
|
8871
|
-
}
|
|
8872
|
-
/** Where `init` should write: the git root above `from`, else `from`. */
|
|
8873
|
-
function findInitRoot(from = process.cwd()) {
|
|
8874
|
-
let dir = path.resolve(from);
|
|
8875
|
-
for (;;) {
|
|
8876
|
-
if (existsSync(path.join(dir, ".git")) || existsSync(path.join(dir, ".cloudtifact.json"))) return dir;
|
|
8877
|
-
const parent = path.dirname(dir);
|
|
8878
|
-
if (parent === dir) return path.resolve(from);
|
|
8879
|
-
dir = parent;
|
|
8880
|
-
}
|
|
8881
|
-
}
|
|
8882
|
-
/**
|
|
8883
|
-
* The project work belongs to, recorded on each version: CLOUDTIFACT_PROJECT, else the name of the git repo above
|
|
8884
|
-
* `from` (a worktree counts as its main repo), else null.
|
|
8885
|
-
*/
|
|
8886
|
-
function projectName(from = process.cwd(), env = process.env) {
|
|
8887
|
-
const named = env.CLOUDTIFACT_PROJECT?.trim();
|
|
8888
|
-
if (named) return named.slice(0, 100);
|
|
8889
|
-
let dir = path.resolve(from);
|
|
8890
|
-
for (;;) {
|
|
8891
|
-
const git = path.join(dir, ".git");
|
|
8892
|
-
if (existsSync(git)) {
|
|
8893
|
-
try {
|
|
8894
|
-
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync(git, "utf8"));
|
|
8895
|
-
const main = m?.[1] ? /^(.*)[\\/]\.git[\\/]worktrees[\\/]/.exec(m[1].trim()) : null;
|
|
8896
|
-
if (main?.[1]) return path.basename(main[1]);
|
|
8897
|
-
} catch {}
|
|
8898
|
-
return path.basename(dir);
|
|
8899
|
-
}
|
|
8900
|
-
const parent = path.dirname(dir);
|
|
8901
|
-
if (parent === dir) return null;
|
|
8902
|
-
dir = parent;
|
|
8903
|
-
}
|
|
8904
|
-
}
|
|
8905
|
-
function parseRepoConfig(raw, file = REPO_CONFIG_FILE) {
|
|
8906
|
-
const bad = (why) => /* @__PURE__ */ new Error(`${file}: ${why}`);
|
|
8907
|
-
if (!raw || typeof raw !== "object") throw bad("expected a JSON object");
|
|
8908
|
-
const { dir, targets } = raw;
|
|
8909
|
-
if (typeof dir !== "string" || !dir) throw bad("\"dir\" must be a non-empty string");
|
|
8910
|
-
if (!Array.isArray(targets)) throw bad("\"targets\" must be an array");
|
|
8911
|
-
return {
|
|
8912
|
-
dir,
|
|
8913
|
-
targets: targets.map((t, i) => {
|
|
8914
|
-
if (!t || typeof t !== "object" || typeof t.spaceId !== "string") throw bad(`targets[${i}].spaceId must be a string`);
|
|
8915
|
-
const { spaceId, label } = t;
|
|
8916
|
-
return label ? {
|
|
8917
|
-
spaceId,
|
|
8918
|
-
label
|
|
8919
|
-
} : { spaceId };
|
|
8920
|
-
})
|
|
8921
|
-
};
|
|
8922
|
-
}
|
|
8923
|
-
async function readRepoConfig(root) {
|
|
8924
|
-
const file = path.join(root, REPO_CONFIG_FILE);
|
|
8925
|
-
let raw;
|
|
8926
|
-
try {
|
|
8927
|
-
raw = JSON.parse(await readFile(file, "utf8"));
|
|
8928
|
-
} catch (err) {
|
|
8929
|
-
throw new Error(`Could not read ${file}: ${err.message}`);
|
|
8930
|
-
}
|
|
8931
|
-
return parseRepoConfig(raw, file);
|
|
8932
|
-
}
|
|
8933
|
-
async function writeRepoConfig(root, config) {
|
|
8934
|
-
await writeFile(path.join(root, REPO_CONFIG_FILE), `${JSON.stringify(config, null, 2)}\n`);
|
|
8935
|
-
}
|
|
8936
|
-
const realOrSelf = (p) => {
|
|
8937
|
-
try {
|
|
8938
|
-
return realpathSync(p);
|
|
8939
|
-
} catch {
|
|
8940
|
-
return p;
|
|
8941
|
-
}
|
|
8942
|
-
};
|
|
8943
|
-
async function loadRepo(from = process.cwd()) {
|
|
8944
|
-
const root = findRepoRoot(from);
|
|
8945
|
-
if (!root) throw new Error(`No ${REPO_CONFIG_FILE} found here or above. Run \`cloudy init\` first.`);
|
|
8946
|
-
const config = await readRepoConfig(root);
|
|
8947
|
-
const docsDir = path.resolve(root, config.dir);
|
|
8948
|
-
const rel = path.relative(realOrSelf(root), realOrSelf(docsDir));
|
|
8949
|
-
if (rel.startsWith("..") || path.isAbsolute(rel)) throw new Error(`"dir" in ${REPO_CONFIG_FILE} must be inside the repo (got "${config.dir}")`);
|
|
8950
|
-
return {
|
|
8951
|
-
root,
|
|
8952
|
-
config,
|
|
8953
|
-
docsDir
|
|
8954
|
-
};
|
|
8955
|
-
}
|
|
8956
|
-
//#endregion
|
|
8957
8997
|
//#region ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
8958
8998
|
/**
|
|
8959
8999
|
* CommanderError class
|
|
@@ -12631,7 +12671,14 @@ async function pushTarget(client, target, initial, opts = {}) {
|
|
|
12631
12671
|
let files = initial;
|
|
12632
12672
|
let uploaded = 0;
|
|
12633
12673
|
const planAndUpload = async () => {
|
|
12634
|
-
const
|
|
12674
|
+
const sent = manifestOf(files);
|
|
12675
|
+
const ours = new Set(sent.map((f) => f.path));
|
|
12676
|
+
const kept = opts.keep ? (await opts.keep()).filter((f) => !ours.has(f.path)) : [];
|
|
12677
|
+
const manifest = [...sent, ...kept.map(({ path, sha256, size }) => ({
|
|
12678
|
+
path,
|
|
12679
|
+
sha256,
|
|
12680
|
+
size
|
|
12681
|
+
}))];
|
|
12635
12682
|
const bySha = new Map(files.map((f) => [f.sha256, f]));
|
|
12636
12683
|
const plan = await client.pushPlan(target.spaceId, {
|
|
12637
12684
|
files: manifest,
|
|
@@ -12856,6 +12903,7 @@ async function bundleHtmlFile(file) {
|
|
|
12856
12903
|
warnings.push(`skipped ${ref}: ${why}`);
|
|
12857
12904
|
return null;
|
|
12858
12905
|
};
|
|
12906
|
+
if (ref.endsWith("/") || ref === ".") return null;
|
|
12859
12907
|
const rel = resolveInside(fromRel, ref);
|
|
12860
12908
|
if (!rel) return skip(`outside ${path.basename(base)}/`);
|
|
12861
12909
|
if (rel === entryRel || picked.has(rel)) return null;
|
|
@@ -12915,10 +12963,14 @@ async function publishToSpace(client, spaceId, bundle, opts) {
|
|
|
12915
12963
|
...f,
|
|
12916
12964
|
path: prefix + f.path
|
|
12917
12965
|
})) : bundle.files;
|
|
12966
|
+
const keep = opts.keepOthers ? async () => {
|
|
12967
|
+
return (await client.getSpace(spaceId)).latestVersion > 0 ? (await client.getVersion(spaceId, "latest")).files : [];
|
|
12968
|
+
} : void 0;
|
|
12918
12969
|
return pushTarget(client, { spaceId }, files, {
|
|
12919
12970
|
message: opts.message,
|
|
12920
12971
|
prefix,
|
|
12921
|
-
project: opts.project
|
|
12972
|
+
project: opts.project,
|
|
12973
|
+
keep
|
|
12922
12974
|
});
|
|
12923
12975
|
}
|
|
12924
12976
|
/**
|
|
@@ -13048,7 +13100,7 @@ function tokenSpace(token) {
|
|
|
13048
13100
|
//#endregion
|
|
13049
13101
|
//#region src/version.ts
|
|
13050
13102
|
/** This CLI's version, from package.json at build time (tsdown.config.ts). Unbuilt (tests, tsx): "0.0.0-dev". */
|
|
13051
|
-
const VERSION = "0.3.
|
|
13103
|
+
const VERSION = "0.3.3";
|
|
13052
13104
|
/**
|
|
13053
13105
|
* Sent on every API request, so the API can tell which CLI version is calling (and one day tell an old one to
|
|
13054
13106
|
* upgrade). Without it Node sends just "node", which is what 0.2.2 and older send. The sign-in page shows it too.
|
|
@@ -14447,9 +14499,18 @@ When you make an HTML page for the user, run \`cloudy publish <file.html>\` and
|
|
|
14447
14499
|
- To update it, edit the same file and publish it again: new version, same link.
|
|
14448
14500
|
- Keep supporting files next to the HTML (or in subfolders) and reference them with relative paths (\`style.css\`, \`img/logo.png\`). Absolute paths and files outside the page's folder aren't included.
|
|
14449
14501
|
- Spaces are private. Never add \`--public\` unless the user asks for a public link in this conversation, or it's a PR screenshot page. \`--public\` only works on the first publish. To switch a space later, a space admin runs \`cloudy settings --space <id> --visibility private\` (members of the workspace only) or \`--visibility public\` (anyone with the link, same rule as \`--public\`). Going public turns guest comments on; going private turns guest comments and guest writes off, and the public link stops working. \`cloudy artifacts\` lists what you've published.
|
|
14450
|
-
- New work joins the space already about the same topic, as a page, instead of making another space: \`publish\` finds it (same workspace, same who-can-see) and prints \`Looks like "<space>"\`. Tell the user where it went. To check first, run \`cloudy find "<title>" --toon\`; \`--add-to <id>\` adds the page to a space you pick, \`--new\` makes a separate space when the user wants one.
|
|
14502
|
+
- New work joins the space already about the same topic, as a page, instead of making another space: \`publish\` finds it (same workspace, same who-can-see) and prints \`Looks like "<space>"\`. Tell the user where it went. To check first, run \`cloudy find "<title>" --toon\`; \`--add-to <id>\` adds the page to a space you pick, \`--new\` makes a separate space when the user wants one. Then link it from the space's home page (below).
|
|
14451
14503
|
- A page that stores something needs the space to allow it: read "What a space can't do" first.
|
|
14452
14504
|
|
|
14505
|
+
### Adding a page to a space
|
|
14506
|
+
|
|
14507
|
+
A page added to a space (\`--add-to\`, or \`Looks like "<space>"\`) goes in its own folder, named after the file: \`mac-mini-server.html\` becomes \`mac-mini-server/\`, while \`index.html\` becomes \`index-2/\`. So name the file after its topic before you publish. Nobody finds the page unless the space's home page links to it, so every time:
|
|
14508
|
+
|
|
14509
|
+
1. \`cloudy copy <space id> --no-publish -o <dir>\` writes the space's files (the home page is \`index.html\`, each added page is \`<folder>/index.html\`). It makes no new space.
|
|
14510
|
+
2. Edit \`<dir>/index.html\`: add a link to the new page (\`href="mac-mini-server/"\`) in its navigation or list of contents, in the same style as the links already there. If the home page doesn't list its pages, add a short "Pages" list in its look; if the space has no home page at all, make a simple \`index.html\` that links to every folder.
|
|
14511
|
+
3. \`cloudy publish <dir>/index.html --space <id> --keep-pages\`. Without \`--keep-pages\`, publishing to \`--space\` replaces every file in the space and deletes the added pages.
|
|
14512
|
+
4. Give the user both links: the new page's and the home page's.
|
|
14513
|
+
|
|
14453
14514
|
## Copying a page someone sent you
|
|
14454
14515
|
|
|
14455
14516
|
When the user is sent a Cloudy link and wants their own copy, run \`cloudy copy <url>\`. It publishes the files into a new space in their workspace and prints the new link. It's private; add \`--public\` only if the user asks for a link anyone can open. \`-o <dir>\` also writes the files locally; \`--no-publish -o <dir>\` writes them without making a space.
|
|
@@ -14568,7 +14629,7 @@ async function skillCopies(home, version = VERSION) {
|
|
|
14568
14629
|
* somebody edited by hand survives until the CLI changes. `check` reports and writes nothing.
|
|
14569
14630
|
*/
|
|
14570
14631
|
async function installSkill(home, opts = {}) {
|
|
14571
|
-
const version = opts.version ?? "0.3.
|
|
14632
|
+
const version = opts.version ?? "0.3.3";
|
|
14572
14633
|
const markdown = skillMarkdown(version);
|
|
14573
14634
|
const copies = await skillCopies(home, version);
|
|
14574
14635
|
const written = [];
|
|
@@ -14885,7 +14946,7 @@ async function runUpdateCheck(source, deps = {}) {
|
|
|
14885
14946
|
source,
|
|
14886
14947
|
...latest ? { latest } : before?.latest ? { latest: before.latest } : {}
|
|
14887
14948
|
}, env);
|
|
14888
|
-
await refreshSkillCopies(homeDir(env), deps.version ?? "0.3.
|
|
14949
|
+
await refreshSkillCopies(homeDir(env), deps.version ?? "0.3.3");
|
|
14889
14950
|
}
|
|
14890
14951
|
/** Starts the check in a detached process that outlives this one and is never waited for. */
|
|
14891
14952
|
function spawnUpdateCheck(entry, source) {
|
|
@@ -15089,7 +15150,7 @@ const program = new Command().name("cloudy").description("Publish pages and docs
|
|
|
15089
15150
|
const tty = !!process.stdout.isTTY && !!process.stderr.isTTY;
|
|
15090
15151
|
if (updateNoticeOff({
|
|
15091
15152
|
env: process.env,
|
|
15092
|
-
current: "0.3.
|
|
15153
|
+
current: "0.3.3",
|
|
15093
15154
|
command: cmd.name()
|
|
15094
15155
|
})) return;
|
|
15095
15156
|
const entry = fileURLToPath(import.meta.url);
|
|
@@ -15609,8 +15670,9 @@ for (const [name, verb] of [["resolve", "Resolved"], ["unresolve", "Reopened"]])
|
|
|
15609
15670
|
const c = await (name === "resolve" ? client.resolveComment(commentId) : client.unresolveComment(commentId));
|
|
15610
15671
|
console.log(`${verb} ${c.id} on ${c.path}.`);
|
|
15611
15672
|
}));
|
|
15612
|
-
program.command("publish").description("Publish an HTML page (with the files it references) or a folder; prints its link").argument("<path>", "an .html file or a folder with index.html").option("--public", "anyone with the link can view (only when first published; default: private). Agents: only when the user asks").option("--name <name>", "space name (default: the page's <title>, else the file name)").option("--workspace <slug>", "workspace for a new space (default: the current one, see `workspace list`)").option("--space <id>", "publish as this existing space's main page (id or link), replacing its files").option("--add-to <id>", "add it as a page in this existing space (id or link), keeping the space's other pages").option("--new", "make a new space, even when an existing one looks like the same topic").option("--folder <path>", "file a new space in this folder, like \"Deals/Enterprise\" (see `cloudy folders`)").option("--project <name>", "the project this work belongs to (default: the git repo it's in)").option("--entry <file>", "folder only: the page to publish as index.html").option("-m, --message <message>", "version message").option("--no-db", "don't run the db/*.sql files next to the page").option("--strict", "make a page the space can't back an error, so nothing is published").action(run(async (target, opts) => {
|
|
15673
|
+
program.command("publish").description("Publish an HTML page (with the files it references) or a folder; prints its link").argument("<path>", "an .html file or a folder with index.html").option("--public", "anyone with the link can view (only when first published; default: private). Agents: only when the user asks").option("--name <name>", "space name (default: the page's <title>, else the file name)").option("--workspace <slug>", "workspace for a new space (default: the current one, see `workspace list`)").option("--space <id>", "publish as this existing space's main page (id or link), replacing its files").option("--keep-pages", "with --space: replace only the files you publish (its home page, say) and keep the space's other pages and files").option("--add-to <id>", "add it as a page in this existing space (id or link), keeping the space's other pages").option("--new", "make a new space, even when an existing one looks like the same topic").option("--folder <path>", "file a new space in this folder, like \"Deals/Enterprise\" (see `cloudy folders`)").option("--project <name>", "the project this work belongs to (default: the git repo it's in)").option("--entry <file>", "folder only: the page to publish as index.html").option("-m, --message <message>", "version message").option("--no-db", "don't run the db/*.sql files next to the page").option("--strict", "make a page the space can't back an error, so nothing is published").action(run(async (target, opts) => {
|
|
15613
15674
|
if (opts.space && opts.addTo) throw new CliError("Pass --space or --add-to, not both.");
|
|
15675
|
+
if (opts.keepPages && !opts.space) throw new CliError("--keep-pages goes with --space <id>: it updates that space's main page and keeps the rest.");
|
|
15614
15676
|
if ((opts.space || opts.addTo) && opts.new) throw new CliError("--new makes a new space; drop --space/--add-to.");
|
|
15615
15677
|
const abs = path.resolve(target);
|
|
15616
15678
|
if (!existsSync(abs)) throw new CliError(`${target} does not exist.`);
|
|
@@ -15717,6 +15779,7 @@ program.command("publish").description("Publish an HTML page (with the files it
|
|
|
15717
15779
|
project: opts.project ?? projectName(path.dirname(abs)),
|
|
15718
15780
|
message: opts.message,
|
|
15719
15781
|
db: opts.db,
|
|
15782
|
+
keepOthers: opts.keepPages,
|
|
15720
15783
|
log: (l) => console.log(l),
|
|
15721
15784
|
warn: (l) => console.error(l)
|
|
15722
15785
|
});
|
|
@@ -15724,6 +15787,7 @@ program.command("publish").description("Publish an HTML page (with the files it
|
|
|
15724
15787
|
if (r.status === "pushed") console.log(`Published "${space.name}" v${r.version} (${n} file${n === 1 ? "" : "s"}; ${summarize(r.diff)})`);
|
|
15725
15788
|
else console.log(`No changes since v${space.latestVersion}: "${space.name}"`);
|
|
15726
15789
|
for (const line of linkLines(space, prefix)) console.log(line);
|
|
15790
|
+
if (prefix) console.log(`Home page: add a link to ${prefix} in the space's home page (index.html), then publish it with --space ${space.id} --keep-pages.`);
|
|
15727
15791
|
}));
|
|
15728
15792
|
program.command("copy").description("Make your own copy of a Cloudy page someone sent you: a new space in your workspace").argument("<url>", "a Cloudy page link, space id, or public link").option("--at <n>", "the version to copy (default: the one in the URL, else latest)").option("--name <name>", "name for the new space (default: the original's name)").option("--workspace <slug>", "workspace for the new space (default: the current one, see `workspace list`)").option("--public", "anyone with the link can view (default: private). Agents: only when the user asks").option("-o, --output <dir>", "also write the files into this folder").option("--force", "overwrite files in -o").option("--no-publish", "write files with -o and don't make a new space").option("-m, --message <message>", "version message on the new space").option("--strict", "make a page the space can't back an error, so nothing is published").option("--toon", "print TOON (compact, for agents)").option("--json", "print JSON").action(run(async (url, opts) => {
|
|
15729
15793
|
const publish = opts.publish !== false;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usecloudy",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Publish pages and docs to Cloudy as links people comment on, with every version kept and the comments handed back to your agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "The Cloudy authors",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://usecloudy.ai/docs/reference/cli",
|
|
8
8
|
"bugs": {
|
|
9
|
-
"url": "https://
|
|
9
|
+
"url": "https://usecloudy.ai/support"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"usecloudy",
|