usecloudy 0.3.3 → 0.3.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/dist/index.js +433 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import fs, { chmodSync, createWriteStream, existsSync, lstatSync, readFileSync, readlinkSync, realpathSync, statSync, symlinkSync, watch, writeFileSync } from "node:fs";
|
|
4
|
-
import { chmod, copyFile, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { chmod, copyFile, cp, lstat, mkdir, readFile, readdir, readlink, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { EventEmitter } from "node:events";
|
|
@@ -255,10 +255,11 @@ async function loadRepo(from = process.cwd()) {
|
|
|
255
255
|
*
|
|
256
256
|
* export const PUBLIC_DOMAIN: string | null = "usecloudy.ai";
|
|
257
257
|
*
|
|
258
|
-
* PUBLIC_DOMAIN is the site and app domain: app.<domain> and the bare domain for the landing site. The API
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
258
|
+
* PUBLIC_DOMAIN is the site and app domain: app.<domain> and the bare domain for the landing site. The API lives on
|
|
259
|
+
* SERVICE_DOMAIN instead, which never moves (the domain move, docs/domain-move.md): the CLI keys saved sign-ins and
|
|
260
|
+
* each folder's space by its API address, so moving it would break every old CLI. The MCP server is given out as
|
|
261
|
+
* mcp.<PUBLIC_DOMAIN> and also answers, in place and forever, on mcp.<SERVICE_DOMAIN>: connectors are signed in to
|
|
262
|
+
* the address they were added with. What users publish (artifact pages and live apps) runs other people's HTML and JS, so it lives
|
|
262
263
|
* on a separate registrable domain, USER_CONTENT_DOMAIN, the way GitHub uses githubusercontent.com:
|
|
263
264
|
* pages at the bare user-content domain (/<id>/, /t/<token>/), apps at <slug>.<user-content domain>.
|
|
264
265
|
* Then a published page can never read or set cookies for the app or for Clerk. While PUBLIC_DOMAIN is
|
|
@@ -270,7 +271,7 @@ async function loadRepo(from = process.cwd()) {
|
|
|
270
271
|
const PUBLIC_DOMAIN = "usecloudy.ai";
|
|
271
272
|
/** Separate domain for published pages and live apps. Must not share a registrable domain with PUBLIC_DOMAIN. */
|
|
272
273
|
const USER_CONTENT_DOMAIN = "cloudy.page";
|
|
273
|
-
/** Where api.,
|
|
274
|
+
/** Where api., admin. and assets. live, forever, and mcp. too for old connectors: programs keep their addresses. */
|
|
274
275
|
const SERVICE_DOMAIN = "cloudtifact.com";
|
|
275
276
|
/**
|
|
276
277
|
* Every site and app domain we serve, new first. During and after the move (docs/domain-move.md) both answer: the old
|
|
@@ -6035,15 +6036,52 @@ const GUEST_KEY_HEADER = "x-cloudtifact-guest-key";
|
|
|
6035
6036
|
const commentImageIdSchema = string().regex(/^[0-9a-f]{32}$/);
|
|
6036
6037
|
//#endregion
|
|
6037
6038
|
//#region ../contract/src/public-link.ts
|
|
6038
|
-
/** Shared public-page URL rules: space ids, custom public links, leftover `@`
|
|
6039
|
+
/** Shared public-page URL rules: space ids, custom public links, leftover `@` pins, person `/@handle`, and `?v=` pins. */
|
|
6039
6040
|
const SPACE_ID_RE = /^[0-9a-z]{10}$/;
|
|
6040
|
-
|
|
6041
|
+
/** Lowercase letters and numbers, single dashes between them (no dash at either end). */
|
|
6042
|
+
const SPACE_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
6041
6043
|
const LEGACY_AT_RE = /^([0-9a-z]{10})@([1-9][0-9]{0,8})$/;
|
|
6042
6044
|
const PIN_RE = /^[1-9][0-9]{0,8}$/;
|
|
6045
|
+
/** Same as handleSchema: 1–39 lowercase letters, digits, dashes, no dash at either end. */
|
|
6046
|
+
const HANDLE_RE = /^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
|
|
6043
6047
|
const isSpaceId = (s) => SPACE_ID_RE.test(s);
|
|
6044
|
-
/**
|
|
6048
|
+
/** Dashed names kept for us, refused as custom public links and post links: pages we may want on cloudy.page later. */
|
|
6049
|
+
const DASHED_RESERVED = /* @__PURE__ */ new Set([
|
|
6050
|
+
"about-cloudy",
|
|
6051
|
+
"made-with-cloudy",
|
|
6052
|
+
"sign-in",
|
|
6053
|
+
"sign-up",
|
|
6054
|
+
"log-in",
|
|
6055
|
+
"log-out"
|
|
6056
|
+
]);
|
|
6057
|
+
/** A custom public-link segment: 2–60 lowercase letters, numbers and single dashes, and not a space id. */
|
|
6045
6058
|
function looksLikeSlug(s) {
|
|
6046
|
-
return s.length >= 2 && s.length <=
|
|
6059
|
+
return s.length >= 2 && s.length <= 60 && SPACE_SLUG_RE.test(s) && !isSpaceId(s);
|
|
6060
|
+
}
|
|
6061
|
+
function decodeSeg(seg) {
|
|
6062
|
+
try {
|
|
6063
|
+
return decodeURIComponent(seg);
|
|
6064
|
+
} catch {
|
|
6065
|
+
return null;
|
|
6066
|
+
}
|
|
6067
|
+
}
|
|
6068
|
+
/**
|
|
6069
|
+
* A person-URL path segment: `@` then a handle. `%40handle` is the same as `@handle`. Not a page slug.
|
|
6070
|
+
*/
|
|
6071
|
+
function parsePersonHandle(seg) {
|
|
6072
|
+
const s = decodeSeg(seg);
|
|
6073
|
+
if (s === null || !s.startsWith("@")) return null;
|
|
6074
|
+
const handle = s.slice(1);
|
|
6075
|
+
return HANDLE_RE.test(handle) ? handle : null;
|
|
6076
|
+
}
|
|
6077
|
+
/**
|
|
6078
|
+
* `/u/<segment>` as a person (the standard profile URL, `/@handle` is the short one): no dot, and a handle.
|
|
6079
|
+
* Password unlock tokens always contain a dot.
|
|
6080
|
+
*/
|
|
6081
|
+
function parsePersonHandleFromU(seg) {
|
|
6082
|
+
const s = decodeSeg(seg);
|
|
6083
|
+
if (s === null || s.includes(".")) return null;
|
|
6084
|
+
return HANDLE_RE.test(s) ? s : null;
|
|
6047
6085
|
}
|
|
6048
6086
|
function parseLegacyAt(seg) {
|
|
6049
6087
|
const m = LEGACY_AT_RE.exec(seg);
|
|
@@ -6068,7 +6106,7 @@ const WORKSPACE_ROLES = [
|
|
|
6068
6106
|
];
|
|
6069
6107
|
//#endregion
|
|
6070
6108
|
//#region ../contract/src/schemas.ts
|
|
6071
|
-
const handleSchema = string().regex(
|
|
6109
|
+
const handleSchema = string().regex(HANDLE_RE, "lowercase letters, digits and dashes, 1-39 chars");
|
|
6072
6110
|
const RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
6073
6111
|
"about",
|
|
6074
6112
|
"account",
|
|
@@ -6117,7 +6155,7 @@ const isReservedName = (name) => RESERVED_NAMES.has(name) || name.startsWith("de
|
|
|
6117
6155
|
const RESERVED_NAME_MESSAGE = "that name is reserved; pick another";
|
|
6118
6156
|
const spaceIdSchema = string().regex(/^[0-9a-z]{10}$/);
|
|
6119
6157
|
const sha256Schema = string().regex(/^[0-9a-f]{64}$/);
|
|
6120
|
-
const spaceSlugSchema = string().min(2).max(
|
|
6158
|
+
const spaceSlugSchema = string().min(2).max(60).regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and dashes").regex(SPACE_SLUG_RE, "use single dashes, and none at the start or end").refine((s) => !isReservedName(s) && !DASHED_RESERVED.has(s) && s !== "find" && s !== "ping", { message: RESERVED_NAME_MESSAGE }).refine((s) => !isSpaceId(s), { message: "that name looks like a space id; pick another" });
|
|
6121
6159
|
const spaceSlugPatchSchema = union([_null(), string().transform((s) => s.trim().toLowerCase()).pipe(spaceSlugSchema)]);
|
|
6122
6160
|
const fileKindSchema = _enum([
|
|
6123
6161
|
"markdown",
|
|
@@ -6195,6 +6233,15 @@ const devLoginOutput = object({
|
|
|
6195
6233
|
token: string(),
|
|
6196
6234
|
user: userSchema
|
|
6197
6235
|
});
|
|
6236
|
+
object({
|
|
6237
|
+
username: string().trim().min(1).max(100),
|
|
6238
|
+
code: string().trim().min(1).max(100),
|
|
6239
|
+
client: _enum(["app", "web"]).default("app")
|
|
6240
|
+
});
|
|
6241
|
+
const reviewSignInOutput = object({
|
|
6242
|
+
token: string(),
|
|
6243
|
+
user: userSchema
|
|
6244
|
+
});
|
|
6198
6245
|
/** A one-hour token for the comment panel on published pages: reads a space and reads or posts its comments. */
|
|
6199
6246
|
const embedTokenOutput = object({
|
|
6200
6247
|
token: string(),
|
|
@@ -6310,6 +6357,19 @@ const notMePreviewOutput = object({ signIn: signInSchema.omit({
|
|
|
6310
6357
|
}).nullable() });
|
|
6311
6358
|
const preferencesSchema = object({ developerMode: boolean() });
|
|
6312
6359
|
preferencesSchema.partial();
|
|
6360
|
+
const atLinkChoiceSchema = object({
|
|
6361
|
+
id: string(),
|
|
6362
|
+
name: string()
|
|
6363
|
+
});
|
|
6364
|
+
const atLinkSchema = object({
|
|
6365
|
+
spaceId: string().nullable(),
|
|
6366
|
+
choices: array(atLinkChoiceSchema),
|
|
6367
|
+
searchIndexed: boolean().optional()
|
|
6368
|
+
});
|
|
6369
|
+
object({
|
|
6370
|
+
spaceId: string().nullable().optional(),
|
|
6371
|
+
searchIndexed: boolean().optional()
|
|
6372
|
+
});
|
|
6313
6373
|
object({ handle: handleSchema });
|
|
6314
6374
|
const emailCategoryIdSchema = _enum([
|
|
6315
6375
|
"invites",
|
|
@@ -6340,6 +6400,14 @@ const meOutput = object({
|
|
|
6340
6400
|
});
|
|
6341
6401
|
object({ ticket: string().min(1).max(2e3) });
|
|
6342
6402
|
object({ userId: string().min(1).max(100) });
|
|
6403
|
+
object({
|
|
6404
|
+
reason: _enum([
|
|
6405
|
+
"spam",
|
|
6406
|
+
"abuse",
|
|
6407
|
+
"other"
|
|
6408
|
+
]),
|
|
6409
|
+
note: string().trim().max(1e3).optional()
|
|
6410
|
+
});
|
|
6343
6411
|
object({
|
|
6344
6412
|
token: string().regex(/^[0-9a-fA-F]{32,200}$/, "an APNs device token, in hex"),
|
|
6345
6413
|
environment: _enum(["sandbox", "production"])
|
|
@@ -6388,9 +6456,14 @@ object({
|
|
|
6388
6456
|
slug: workspaceSlugSchema,
|
|
6389
6457
|
name: string().min(1).max(100)
|
|
6390
6458
|
});
|
|
6459
|
+
const optionalLine = (max) => string().trim().max(max).transform((s) => s.replace(/\s+/g, " ") || null).nullable().optional();
|
|
6391
6460
|
object({
|
|
6392
6461
|
slug: workspaceSlugSchema.optional(),
|
|
6393
|
-
name: string().min(1).max(100).optional()
|
|
6462
|
+
name: string().min(1).max(100).optional(),
|
|
6463
|
+
publicPage: boolean().optional(),
|
|
6464
|
+
description: optionalLine(160),
|
|
6465
|
+
topic: optionalLine(40),
|
|
6466
|
+
searchIndexed: boolean().optional()
|
|
6394
6467
|
});
|
|
6395
6468
|
const workspaceMemberSchema = object({
|
|
6396
6469
|
user: userSchema,
|
|
@@ -6406,7 +6479,11 @@ const workspaceDetailSchema = workspaceSchema.extend({
|
|
|
6406
6479
|
seats: object({
|
|
6407
6480
|
used: number$1().int(),
|
|
6408
6481
|
limit: number$1().int()
|
|
6409
|
-
}).optional()
|
|
6482
|
+
}).optional(),
|
|
6483
|
+
publicPage: boolean().optional(),
|
|
6484
|
+
description: string().nullable().optional(),
|
|
6485
|
+
topic: string().nullable().optional(),
|
|
6486
|
+
searchIndexed: boolean().optional()
|
|
6410
6487
|
});
|
|
6411
6488
|
object({
|
|
6412
6489
|
handle: handleSchema,
|
|
@@ -6417,7 +6494,7 @@ object({
|
|
|
6417
6494
|
role: workspaceRoleSchema.default("member"),
|
|
6418
6495
|
email: email().max(200).optional(),
|
|
6419
6496
|
maxUses: number$1().int().min(1).max(1e3).nullable().optional(),
|
|
6420
|
-
expiresInDays: number$1().int().min(1).max(30).default(
|
|
6497
|
+
expiresInDays: number$1().int().min(1).max(30).default(30)
|
|
6421
6498
|
});
|
|
6422
6499
|
const workspaceInviteSchema = object({
|
|
6423
6500
|
id: string(),
|
|
@@ -6444,7 +6521,12 @@ const workspaceInvitePreviewOutput = object({
|
|
|
6444
6521
|
expiresAt: number$1(),
|
|
6445
6522
|
alreadyMember: boolean(),
|
|
6446
6523
|
email: string().nullable().default(null),
|
|
6447
|
-
wrongAccount: boolean().default(false)
|
|
6524
|
+
wrongAccount: boolean().default(false),
|
|
6525
|
+
full: object({
|
|
6526
|
+
plan: string(),
|
|
6527
|
+
seats: number$1().int(),
|
|
6528
|
+
owner: userSchema.nullable()
|
|
6529
|
+
}).nullable().default(null)
|
|
6448
6530
|
});
|
|
6449
6531
|
const acceptWorkspaceInviteOutput = object({ workspace: myWorkspaceSchema });
|
|
6450
6532
|
const auditActionSchema = _enum([
|
|
@@ -6485,6 +6567,11 @@ const auditActionSchema = _enum([
|
|
|
6485
6567
|
"discord.connected",
|
|
6486
6568
|
"discord.changed",
|
|
6487
6569
|
"discord.disconnected",
|
|
6570
|
+
"slack.connected",
|
|
6571
|
+
"slack.changed",
|
|
6572
|
+
"slack.disconnected",
|
|
6573
|
+
"slack.stopped",
|
|
6574
|
+
"slack.paused",
|
|
6488
6575
|
"domain.added",
|
|
6489
6576
|
"domain.removed",
|
|
6490
6577
|
"rule.created",
|
|
@@ -6504,7 +6591,8 @@ const auditEventSchema = object({
|
|
|
6504
6591
|
object({
|
|
6505
6592
|
before: number().int().positive().optional(),
|
|
6506
6593
|
beforeId: string().max(64).optional(),
|
|
6507
|
-
limit: number().int().min(1).max(200).default(50)
|
|
6594
|
+
limit: number().int().min(1).max(200).default(50),
|
|
6595
|
+
v: number().int().optional()
|
|
6508
6596
|
});
|
|
6509
6597
|
const listAuditOutput = object({
|
|
6510
6598
|
events: array(auditEventSchema),
|
|
@@ -6662,6 +6750,7 @@ const spaceSchema = object({
|
|
|
6662
6750
|
url: string(),
|
|
6663
6751
|
shareUrl: string().nullable(),
|
|
6664
6752
|
slug: string().nullable().optional(),
|
|
6753
|
+
searchIndexed: boolean().optional(),
|
|
6665
6754
|
kind: _enum([
|
|
6666
6755
|
"repo",
|
|
6667
6756
|
"live",
|
|
@@ -6742,7 +6831,8 @@ object({
|
|
|
6742
6831
|
guestWrites: boolean().optional(),
|
|
6743
6832
|
viewers: viewersSchema.partial().optional(),
|
|
6744
6833
|
password: string().min(4).max(200).nullable().optional(),
|
|
6745
|
-
slug: spaceSlugPatchSchema.optional()
|
|
6834
|
+
slug: spaceSlugPatchSchema.optional(),
|
|
6835
|
+
searchIndexed: boolean().optional()
|
|
6746
6836
|
});
|
|
6747
6837
|
object({ workspace: workspaceSlugSchema });
|
|
6748
6838
|
const moveSpaceOutput = object({
|
|
@@ -6750,6 +6840,11 @@ const moveSpaceOutput = object({
|
|
|
6750
6840
|
moved: array(spaceIdSchema)
|
|
6751
6841
|
});
|
|
6752
6842
|
object({ password: string().min(1).max(200) });
|
|
6843
|
+
const spacePasswordOutput = object({ password: string().nullable() });
|
|
6844
|
+
const customLinksOutput = object({
|
|
6845
|
+
used: number$1().int(),
|
|
6846
|
+
cap: number$1().int().nullable()
|
|
6847
|
+
});
|
|
6753
6848
|
const unlockSpaceOutput = object({
|
|
6754
6849
|
token: string(),
|
|
6755
6850
|
exp: number$1().int()
|
|
@@ -7236,6 +7331,7 @@ const AGENT_NAMES = {
|
|
|
7236
7331
|
opencode: "OpenCode",
|
|
7237
7332
|
cli: "CLI",
|
|
7238
7333
|
discord: "Discord",
|
|
7334
|
+
slack: "Slack",
|
|
7239
7335
|
mobile: "the mobile app",
|
|
7240
7336
|
claude: "Claude",
|
|
7241
7337
|
chatgpt: "ChatGPT",
|
|
@@ -7248,6 +7344,68 @@ const agentLabel = (via) => AGENT_NAMES[via] ?? via;
|
|
|
7248
7344
|
* hand ("cli"), or our own mobile app ("mobile"). Their reads count as reading, and notifications don't add "via ...".
|
|
7249
7345
|
*/
|
|
7250
7346
|
const isPersonVia = (via) => via === null || via === "cli" || via === "mobile";
|
|
7347
|
+
const slackSpaceSchema = object({
|
|
7348
|
+
id: string(),
|
|
7349
|
+
name: string(),
|
|
7350
|
+
visibility: visibilitySchema
|
|
7351
|
+
});
|
|
7352
|
+
const slackSpaceIds = array(string()).min(1).max(500);
|
|
7353
|
+
const slackConnectRequestOutput = object({
|
|
7354
|
+
userCode: string(),
|
|
7355
|
+
status: _enum([
|
|
7356
|
+
"pending",
|
|
7357
|
+
"approved",
|
|
7358
|
+
"denied",
|
|
7359
|
+
"expired"
|
|
7360
|
+
]),
|
|
7361
|
+
expiresAt: number$1(),
|
|
7362
|
+
teamName: string(),
|
|
7363
|
+
channelName: string(),
|
|
7364
|
+
isPrivate: boolean(),
|
|
7365
|
+
askedBy: string(),
|
|
7366
|
+
workspaces: array(object({
|
|
7367
|
+
slug: string(),
|
|
7368
|
+
name: string(),
|
|
7369
|
+
canShare: boolean(),
|
|
7370
|
+
following: array(string()),
|
|
7371
|
+
spaces: array(slackSpaceSchema)
|
|
7372
|
+
})),
|
|
7373
|
+
others: number$1().int(),
|
|
7374
|
+
problem: _enum([
|
|
7375
|
+
"shared",
|
|
7376
|
+
"removed",
|
|
7377
|
+
"archived"
|
|
7378
|
+
]).nullable()
|
|
7379
|
+
});
|
|
7380
|
+
object({
|
|
7381
|
+
approve: boolean(),
|
|
7382
|
+
workspaces: array(object({
|
|
7383
|
+
slug: string(),
|
|
7384
|
+
spaceIds: slackSpaceIds
|
|
7385
|
+
})).max(50).default([])
|
|
7386
|
+
});
|
|
7387
|
+
const slackChannelSchema = object({
|
|
7388
|
+
id: string(),
|
|
7389
|
+
teamName: string(),
|
|
7390
|
+
channelName: string().nullable(),
|
|
7391
|
+
isPrivate: boolean(),
|
|
7392
|
+
stopped: _enum([
|
|
7393
|
+
"shared",
|
|
7394
|
+
"removed",
|
|
7395
|
+
"archived"
|
|
7396
|
+
]).nullable(),
|
|
7397
|
+
needsApprover: boolean(),
|
|
7398
|
+
spaces: number$1().int(),
|
|
7399
|
+
spaceIds: array(string()).optional(),
|
|
7400
|
+
addedBy: userSchema.nullable(),
|
|
7401
|
+
createdAt: number$1()
|
|
7402
|
+
});
|
|
7403
|
+
const listSlackChannelsOutput = object({
|
|
7404
|
+
installUrl: string(),
|
|
7405
|
+
channels: array(slackChannelSchema),
|
|
7406
|
+
spaces: array(slackSpaceSchema).optional()
|
|
7407
|
+
});
|
|
7408
|
+
object({ spaceIds: slackSpaceIds });
|
|
7251
7409
|
const discordId = string().regex(/^\d{5,25}$/);
|
|
7252
7410
|
const discordName = string().trim().min(1).max(100);
|
|
7253
7411
|
const discordPersonSchema = object({
|
|
@@ -8089,6 +8247,8 @@ function createClient(opts) {
|
|
|
8089
8247
|
createSession: (input = {}) => call("POST", "/v1/sessions", createSessionOutput, input),
|
|
8090
8248
|
me: () => call("GET", "/v1/me", meOutput),
|
|
8091
8249
|
updatePreferences: (input) => call("PATCH", "/v1/me/preferences", preferencesSchema, input),
|
|
8250
|
+
atLink: () => call("GET", "/v1/me/at-link", atLinkSchema),
|
|
8251
|
+
updateAtLink: (input) => call("PUT", "/v1/me/at-link", atLinkSchema, input),
|
|
8092
8252
|
emailPreferences: () => call("GET", "/v1/me/email-preferences", emailPreferencesSchema),
|
|
8093
8253
|
updateEmailPreferences: (input) => call("PATCH", "/v1/me/email-preferences", emailPreferencesSchema, input),
|
|
8094
8254
|
notificationSettings: () => call("GET", "/v1/me/notifications", notificationSettingsSchema),
|
|
@@ -8111,6 +8271,12 @@ function createClient(opts) {
|
|
|
8111
8271
|
cancelDeletionFromLink: (ticket) => send("POST", "/v1/auth/cancel-deletion", { ticket }),
|
|
8112
8272
|
blockUser: (userId) => send("POST", "/v1/me/blocks", { userId }),
|
|
8113
8273
|
unblockUser: (userId) => send("DELETE", `/v1/me/blocks/${enc(userId)}`),
|
|
8274
|
+
/** Reports a comment to Cloudy's staff. */
|
|
8275
|
+
reportComment: (id, input) => send("POST", `/v1/comments/${enc(id)}/report`, input),
|
|
8276
|
+
/** Reports a whole space (what its pages show) to Cloudy's staff. */
|
|
8277
|
+
reportSpace: (id, input) => send("POST", `${space(id)}/report`, input),
|
|
8278
|
+
/** App Review's sign-in: works only for the review accounts the server names. */
|
|
8279
|
+
reviewSignIn: (input) => call("POST", "/v1/auth/review-sign-in", reviewSignInOutput, input),
|
|
8114
8280
|
registerPushDevice: (input) => send("POST", "/v1/me/push-devices", input),
|
|
8115
8281
|
unregisterPushDevice: (token) => send("DELETE", `/v1/me/push-devices/${enc(token)}`),
|
|
8116
8282
|
cliLoginStart: (input = {}) => call("POST", "/v1/auth/cli/start", cliLoginStartOutput, input),
|
|
@@ -8170,6 +8336,8 @@ function createClient(opts) {
|
|
|
8170
8336
|
if (query.v) q.set("v", query.v);
|
|
8171
8337
|
return call("GET", `${space(id)}/page${q.size ? `?${q}` : ""}`, spacePageOutput);
|
|
8172
8338
|
},
|
|
8339
|
+
spacePassword: (id) => call("GET", `${space(id)}/password`, spacePasswordOutput),
|
|
8340
|
+
customLinks: (id) => call("GET", `${space(id)}/custom-links`, customLinksOutput),
|
|
8173
8341
|
unlockSpace: (id, input) => call("POST", `${space(id)}/unlock`, unlockSpaceOutput, input),
|
|
8174
8342
|
recordView: (id, input) => call("POST", `${space(id)}/views`, null, input),
|
|
8175
8343
|
seen: (id, input) => call("POST", `${space(id)}/seen`, null, input),
|
|
@@ -8293,6 +8461,11 @@ function createClient(opts) {
|
|
|
8293
8461
|
listDiscordChannels: (slug) => call("GET", `/v1/workspaces/${enc(slug)}/discord`, listDiscordChannelsOutput),
|
|
8294
8462
|
setDiscordChannel: (slug, channelId, input) => send("PUT", `/v1/workspaces/${enc(slug)}/discord/${enc(channelId)}`, input),
|
|
8295
8463
|
disconnectDiscordChannel: (slug, channelId) => send("DELETE", `/v1/workspaces/${enc(slug)}/discord/${enc(channelId)}`),
|
|
8464
|
+
slackConnectRequest: (userCode) => call("GET", `/v1/slack/connects/${enc(userCode)}`, slackConnectRequestOutput),
|
|
8465
|
+
slackConnectDecide: (userCode, input) => send("POST", `/v1/slack/connects/${enc(userCode)}/decide`, input),
|
|
8466
|
+
listSlackChannels: (slug) => call("GET", `/v1/workspaces/${enc(slug)}/slack`, listSlackChannelsOutput),
|
|
8467
|
+
setSlackChannel: (slug, id, input) => send("PUT", `/v1/workspaces/${enc(slug)}/slack/${enc(id)}`, input),
|
|
8468
|
+
disconnectSlackChannel: (slug, id) => send("DELETE", `/v1/workspaces/${enc(slug)}/slack/${enc(id)}`),
|
|
8296
8469
|
listDiscordLinks: (spaceId) => call("GET", `/v1/spaces/${enc(spaceId)}/discord`, listDiscordLinksOutput),
|
|
8297
8470
|
discordChat: (spaceId, threadId, all = false) => call("GET", `/v1/spaces/${enc(spaceId)}/discord/${enc(threadId)}${all ? "?all=1" : ""}`, discordChatOutput),
|
|
8298
8471
|
unlinkDiscordThread: (spaceId, threadId) => send("DELETE", `/v1/spaces/${enc(spaceId)}/discord/${enc(threadId)}`),
|
|
@@ -8317,8 +8490,8 @@ function createClient(opts) {
|
|
|
8317
8490
|
if (query.before) q.set("before", String(query.before));
|
|
8318
8491
|
if (query.before && query.beforeId) q.set("beforeId", query.beforeId);
|
|
8319
8492
|
if (query.limit) q.set("limit", String(query.limit));
|
|
8320
|
-
|
|
8321
|
-
return call("GET", `/v1/workspaces/${enc(slug)}/audit
|
|
8493
|
+
q.set("v", String(2));
|
|
8494
|
+
return call("GET", `/v1/workspaces/${enc(slug)}/audit?${q}`, listAuditOutput);
|
|
8322
8495
|
}
|
|
8323
8496
|
};
|
|
8324
8497
|
}
|
|
@@ -13036,7 +13209,7 @@ function lookupArtifact(map, absPath, apiUrl) {
|
|
|
13036
13209
|
* /<slug>/, leftover /<id>@<n>/, old /p/<id>/) and signed page links (/t/<token>/, old /s/<token>/).
|
|
13037
13210
|
* A signed token names its space in its first part; the API still checks access, so reading it
|
|
13038
13211
|
* without the signing key is safe. Returns null when there is no space in it (a workspace link
|
|
13039
|
-
* /w/<slug>, a typo).
|
|
13212
|
+
* /w/<slug>, a person URL /@handle or /u/handle, a typo).
|
|
13040
13213
|
*/
|
|
13041
13214
|
function spaceIdFrom(input) {
|
|
13042
13215
|
const ref = input.trim();
|
|
@@ -13051,6 +13224,7 @@ function spaceIdFrom(input) {
|
|
|
13051
13224
|
return null;
|
|
13052
13225
|
}
|
|
13053
13226
|
const [first = "", second = ""] = segments;
|
|
13227
|
+
if (parsePersonHandle(first) || first === "u" && parsePersonHandleFromU(second)) return null;
|
|
13054
13228
|
if (first === "t") return tokenSpace(second);
|
|
13055
13229
|
if (first === "s" || first === "r" || first === "p") return idPart(second) ?? (first === "s" ? tokenSpace(second) : null);
|
|
13056
13230
|
return idPart(first) ?? (looksLikeSlug(first) ? first : null);
|
|
@@ -13100,7 +13274,7 @@ function tokenSpace(token) {
|
|
|
13100
13274
|
//#endregion
|
|
13101
13275
|
//#region src/version.ts
|
|
13102
13276
|
/** This CLI's version, from package.json at build time (tsdown.config.ts). Unbuilt (tests, tsx): "0.0.0-dev". */
|
|
13103
|
-
const VERSION = "0.3.
|
|
13277
|
+
const VERSION = "0.3.5";
|
|
13104
13278
|
/**
|
|
13105
13279
|
* Sent on every API request, so the API can tell which CLI version is calling (and one day tell an old one to
|
|
13106
13280
|
* upgrade). Without it Node sends just "node", which is what 0.2.2 and older send. The sign-in page shows it too.
|
|
@@ -13574,7 +13748,7 @@ function mergeCursorHooks(settings, command = HOOK_COMMAND) {
|
|
|
13574
13748
|
status
|
|
13575
13749
|
};
|
|
13576
13750
|
}
|
|
13577
|
-
async function readJson(file) {
|
|
13751
|
+
async function readJson$1(file) {
|
|
13578
13752
|
if (!existsSync(file)) return {};
|
|
13579
13753
|
const text = await readFile(file, "utf8");
|
|
13580
13754
|
if (!text.trim()) return {};
|
|
@@ -13597,7 +13771,7 @@ const hookFiles = (root) => ({
|
|
|
13597
13771
|
});
|
|
13598
13772
|
async function installHook(harness, root) {
|
|
13599
13773
|
const file = hookFiles(root)[harness];
|
|
13600
|
-
const current = await readJson(file);
|
|
13774
|
+
const current = await readJson$1(file);
|
|
13601
13775
|
if (harness === "cursor") {
|
|
13602
13776
|
const { settings, status } = mergeCursorHooks(current);
|
|
13603
13777
|
if (status !== "unchanged") await writeJson(file, settings);
|
|
@@ -13684,7 +13858,7 @@ function removeRulesHooks(settings) {
|
|
|
13684
13858
|
async function installRulesHooks(harness, root) {
|
|
13685
13859
|
if (harness === "cursor") return null;
|
|
13686
13860
|
const file = hookFiles(root)[harness];
|
|
13687
|
-
let current = await readJson(file);
|
|
13861
|
+
let current = await readJson$1(file);
|
|
13688
13862
|
let added = false;
|
|
13689
13863
|
for (const event of RULES_EVENTS) {
|
|
13690
13864
|
const r = mergeEventHook(current, event);
|
|
@@ -13706,7 +13880,7 @@ async function uninstallRulesHooks(harness, root) {
|
|
|
13706
13880
|
file,
|
|
13707
13881
|
removed: 0
|
|
13708
13882
|
};
|
|
13709
|
-
const { settings, removed } = removeRulesHooks(await readJson(file));
|
|
13883
|
+
const { settings, removed } = removeRulesHooks(await readJson$1(file));
|
|
13710
13884
|
if (removed) await writeJson(file, settings);
|
|
13711
13885
|
return {
|
|
13712
13886
|
harness,
|
|
@@ -13717,7 +13891,7 @@ async function uninstallRulesHooks(harness, root) {
|
|
|
13717
13891
|
/** Whether the repo's Claude Code or Codex settings run our command when a session starts. False on any doubt. */
|
|
13718
13892
|
async function hasRulesHooks(root) {
|
|
13719
13893
|
for (const harness of ["claude", "codex"]) {
|
|
13720
|
-
const groups = (await readJson(hookFiles(root)[harness]).catch(() => ({}))).hooks?.SessionStart;
|
|
13894
|
+
const groups = (await readJson$1(hookFiles(root)[harness]).catch(() => ({}))).hooks?.SessionStart;
|
|
13721
13895
|
if (Array.isArray(groups) && groups.some((g) => g?.hooks?.some((h) => isOurs(h?.command)))) return true;
|
|
13722
13896
|
}
|
|
13723
13897
|
return false;
|
|
@@ -13964,6 +14138,136 @@ async function revokeSavedToken(client) {
|
|
|
13964
14138
|
}
|
|
13965
14139
|
}
|
|
13966
14140
|
//#endregion
|
|
14141
|
+
//#region src/plugin-migrate.ts
|
|
14142
|
+
/**
|
|
14143
|
+
* The Claude Code plugin was called `cloudtifact` (cloudtifact@cloudtifact, /cloudtifact:publish) until CLI 0.3.4;
|
|
14144
|
+
* it is `cloudy` now (cloudy@cloudy, /cloudy:publish). Both come from the same marketplace repo, which now calls
|
|
14145
|
+
* itself `cloudy` and still lists the old plugin so old installs keep working. `cloudy skill install` moves an old
|
|
14146
|
+
* install over: it backs up Claude Code's plugin files, uninstalls the old plugin, removes the old marketplace
|
|
14147
|
+
* entry, adds the repo again (Claude Code then registers it as `cloudy`) and installs cloudy@cloudy.
|
|
14148
|
+
*
|
|
14149
|
+
* The order matters: Claude Code won't add a marketplace source it already has under another name, so the old
|
|
14150
|
+
* entry has to go before the new one can be added.
|
|
14151
|
+
*/
|
|
14152
|
+
const OLD_PLUGIN = "cloudtifact@cloudtifact";
|
|
14153
|
+
const NEW_PLUGIN = "cloudy@cloudy";
|
|
14154
|
+
const MARKETPLACE_REPO = "Cloudtifact/plugins";
|
|
14155
|
+
/** Runs `claude <args>`. Never throws. Two minutes each: adding a marketplace clones it from GitHub. */
|
|
14156
|
+
const runClaude = (args) => new Promise((resolve) => {
|
|
14157
|
+
execFile("claude", args, {
|
|
14158
|
+
timeout: 12e4,
|
|
14159
|
+
shell: process.platform === "win32",
|
|
14160
|
+
env: process.env
|
|
14161
|
+
}, (err, stdout, stderr) => resolve({
|
|
14162
|
+
ok: !err,
|
|
14163
|
+
out: `${stdout}${stderr}`.trim()
|
|
14164
|
+
}));
|
|
14165
|
+
});
|
|
14166
|
+
async function readJson(file) {
|
|
14167
|
+
try {
|
|
14168
|
+
return JSON.parse(await readFile(file, "utf8"));
|
|
14169
|
+
} catch {
|
|
14170
|
+
return null;
|
|
14171
|
+
}
|
|
14172
|
+
}
|
|
14173
|
+
function claudePaths(home) {
|
|
14174
|
+
const plugins = path.join(home, ".claude", "plugins");
|
|
14175
|
+
return {
|
|
14176
|
+
installed: path.join(plugins, "installed_plugins.json"),
|
|
14177
|
+
marketplaces: path.join(plugins, "known_marketplaces.json"),
|
|
14178
|
+
settings: path.join(home, ".claude", "settings.json")
|
|
14179
|
+
};
|
|
14180
|
+
}
|
|
14181
|
+
/** The old plugin's installs (one per scope), from installed_plugins.json. Empty when it isn't installed. */
|
|
14182
|
+
async function oldClaudePlugin(home) {
|
|
14183
|
+
const json = await readJson(claudePaths(home).installed);
|
|
14184
|
+
const entries = (json?.plugins ?? json)?.[OLD_PLUGIN];
|
|
14185
|
+
return Array.isArray(entries) ? entries : [];
|
|
14186
|
+
}
|
|
14187
|
+
const MANUAL = [
|
|
14188
|
+
` /plugin uninstall ${OLD_PLUGIN}`,
|
|
14189
|
+
" /plugin marketplace remove cloudtifact",
|
|
14190
|
+
` /plugin marketplace add ${MARKETPLACE_REPO}`,
|
|
14191
|
+
` /plugin install ${NEW_PLUGIN}`
|
|
14192
|
+
];
|
|
14193
|
+
/**
|
|
14194
|
+
* Moves a user-scope install of cloudtifact@cloudtifact to cloudy@cloudy (see the top of this file). Installs in a
|
|
14195
|
+
* project or local scope are left alone and listed with the commands to run there. `check` only reports.
|
|
14196
|
+
*/
|
|
14197
|
+
async function moveClaudePlugin(home, opts) {
|
|
14198
|
+
const installs = await oldClaudePlugin(home);
|
|
14199
|
+
if (!installs.length) return {
|
|
14200
|
+
state: "none",
|
|
14201
|
+
lines: []
|
|
14202
|
+
};
|
|
14203
|
+
const user = installs.some((i) => (i.scope ?? "user") === "user");
|
|
14204
|
+
const elsewhere = installs.filter((i) => (i.scope ?? "user") !== "user");
|
|
14205
|
+
const elsewhereLines = elsewhere.length ? [`Claude Code: ${OLD_PLUGIN} is also installed in ${elsewhere.map((i) => i.projectPath ?? i.scope).join(", ")}. In each, run:`, ...MANUAL] : [];
|
|
14206
|
+
if (opts.check || !user) return {
|
|
14207
|
+
state: "manual",
|
|
14208
|
+
lines: [...user ? [`Claude Code: ${OLD_PLUGIN} is installed. It is called ${NEW_PLUGIN} now; run \`cloudy skill install\` to switch.`] : [], ...elsewhereLines]
|
|
14209
|
+
};
|
|
14210
|
+
const run = opts.run ?? runClaude;
|
|
14211
|
+
if (!(await run(["--version"])).ok) return {
|
|
14212
|
+
state: "manual",
|
|
14213
|
+
lines: [`Claude Code: ${OLD_PLUGIN} is installed, but the claude command isn't on PATH. In Claude Code, run:`, ...MANUAL]
|
|
14214
|
+
};
|
|
14215
|
+
const paths = claudePaths(home);
|
|
14216
|
+
const backup = path.join(opts.backupDir, "claude");
|
|
14217
|
+
await mkdir(backup, { recursive: true });
|
|
14218
|
+
for (const f of [
|
|
14219
|
+
paths.installed,
|
|
14220
|
+
paths.marketplaces,
|
|
14221
|
+
paths.settings
|
|
14222
|
+
]) if (existsSync(f)) await copyFile(f, path.join(backup, path.basename(f)));
|
|
14223
|
+
const steps = [[
|
|
14224
|
+
"plugin",
|
|
14225
|
+
"uninstall",
|
|
14226
|
+
OLD_PLUGIN,
|
|
14227
|
+
"--scope",
|
|
14228
|
+
"user"
|
|
14229
|
+
]];
|
|
14230
|
+
const known = await readJson(paths.marketplaces) ?? {};
|
|
14231
|
+
const old = known.cloudtifact;
|
|
14232
|
+
const ours = (s) => /cloudtifact\/plugins/i.test(`${s?.repo ?? ""} ${s?.url ?? ""}`);
|
|
14233
|
+
const installed = (await readJson(paths.installed))?.plugins ?? {};
|
|
14234
|
+
const others = Object.keys(installed).filter((k) => k.endsWith("@cloudtifact") && k !== "cloudtifact@cloudtifact");
|
|
14235
|
+
if (old && ours(old.source) && !others.length && !elsewhere.length) steps.push([
|
|
14236
|
+
"plugin",
|
|
14237
|
+
"marketplace",
|
|
14238
|
+
"remove",
|
|
14239
|
+
"cloudtifact"
|
|
14240
|
+
]);
|
|
14241
|
+
if (!Object.entries(known).some(([name, m]) => name === "cloudy" && ours(m.source))) steps.push([
|
|
14242
|
+
"plugin",
|
|
14243
|
+
"marketplace",
|
|
14244
|
+
"add",
|
|
14245
|
+
MARKETPLACE_REPO
|
|
14246
|
+
]);
|
|
14247
|
+
if (!installed["cloudy@cloudy"]) steps.push([
|
|
14248
|
+
"plugin",
|
|
14249
|
+
"install",
|
|
14250
|
+
NEW_PLUGIN,
|
|
14251
|
+
"--scope",
|
|
14252
|
+
"user"
|
|
14253
|
+
]);
|
|
14254
|
+
for (const args of steps) {
|
|
14255
|
+
const r = await run(args);
|
|
14256
|
+
if (!r.ok) return {
|
|
14257
|
+
state: "failed",
|
|
14258
|
+
lines: [
|
|
14259
|
+
`Claude Code: \`claude ${args.join(" ")}\` failed: ${r.out.split("\n").pop() || "no output"}`,
|
|
14260
|
+
`Your plugin settings are backed up in ${backup}. To finish by hand, in Claude Code run:`,
|
|
14261
|
+
...MANUAL
|
|
14262
|
+
]
|
|
14263
|
+
};
|
|
14264
|
+
}
|
|
14265
|
+
return {
|
|
14266
|
+
state: "moved",
|
|
14267
|
+
lines: [`Claude Code: replaced ${OLD_PLUGIN} with ${NEW_PLUGIN} (commands are /cloudy:publish, /cloudy:comments, /cloudy:status). Restart Claude Code to load it. Backup: ${backup}`, ...elsewhereLines]
|
|
14268
|
+
};
|
|
14269
|
+
}
|
|
14270
|
+
//#endregion
|
|
13967
14271
|
//#region src/prompt.ts
|
|
13968
14272
|
const interactive = () => !!process.stdin.isTTY && !!process.stdout.isTTY;
|
|
13969
14273
|
async function ask(question, fallback = "") {
|
|
@@ -14362,6 +14666,12 @@ const SETTINGS = [
|
|
|
14362
14666
|
option: "--guest-comments <on|off>",
|
|
14363
14667
|
label: "People who are not signed in can comment",
|
|
14364
14668
|
get: (s) => s.guestComments
|
|
14669
|
+
},
|
|
14670
|
+
{
|
|
14671
|
+
flag: "search",
|
|
14672
|
+
option: "--search <on|off>",
|
|
14673
|
+
label: "Show its pages in search engines",
|
|
14674
|
+
get: (s) => s.searchIndexed ?? false
|
|
14365
14675
|
}
|
|
14366
14676
|
];
|
|
14367
14677
|
/**
|
|
@@ -14390,6 +14700,7 @@ function settingsPatch(opts) {
|
|
|
14390
14700
|
if (value === void 0) continue;
|
|
14391
14701
|
const on = onOff(value, s.option);
|
|
14392
14702
|
if (s.flag === "pagesShowData") patch.viewers = { dbRead: on };
|
|
14703
|
+
else if (s.flag === "search") patch.searchIndexed = on;
|
|
14393
14704
|
else patch[s.flag] = on;
|
|
14394
14705
|
}
|
|
14395
14706
|
if (opts.link !== void 0) {
|
|
@@ -14398,7 +14709,7 @@ function settingsPatch(opts) {
|
|
|
14398
14709
|
else if (!v) throw new CliError("--link takes a public link or off.");
|
|
14399
14710
|
else {
|
|
14400
14711
|
const parsed = spaceSlugSchema.safeParse(v);
|
|
14401
|
-
if (!parsed.success) throw new CliError(`--link: ${parsed.error.issues[0]?.message ?? "lowercase letters and
|
|
14712
|
+
if (!parsed.success) throw new CliError(`--link: ${parsed.error.issues[0]?.message ?? "lowercase letters, numbers and single dashes"}`);
|
|
14402
14713
|
patch.slug = parsed.data;
|
|
14403
14714
|
}
|
|
14404
14715
|
}
|
|
@@ -14426,7 +14737,7 @@ function settingsText(space) {
|
|
|
14426
14737
|
lines.push(` Always works ${always.href}`);
|
|
14427
14738
|
}
|
|
14428
14739
|
}
|
|
14429
|
-
if (space.visibility !== "public") lines.push("Guest writes
|
|
14740
|
+
if (space.visibility !== "public") lines.push("Guest writes, guest comments and search engines need a public space (--visibility public, space admins).");
|
|
14430
14741
|
return `${lines.join("\n")}\n`;
|
|
14431
14742
|
}
|
|
14432
14743
|
//#endregion
|
|
@@ -14437,7 +14748,7 @@ function settingsText(space) {
|
|
|
14437
14748
|
* refresh. Without it an agent keeps following the commands and limits of a CLI that has moved on.
|
|
14438
14749
|
*/
|
|
14439
14750
|
const skillMarkdown = (version = VERSION) => `---
|
|
14440
|
-
name:
|
|
14751
|
+
name: cloudy
|
|
14441
14752
|
description: Use when the user wants a page, report, dashboard, prototype or any other HTML to look at or share (publish it with Cloudy and give the link, instead of a built-in artifact tool), when they mention Cloudy or ask for feedback on something they published, or when editing docs in a repo that has a .cloudtifact.json file (read, address, reply to and resolve their comments).
|
|
14442
14753
|
---
|
|
14443
14754
|
|
|
@@ -14592,6 +14903,9 @@ const SKILL_TARGETS = [
|
|
|
14592
14903
|
]
|
|
14593
14904
|
}
|
|
14594
14905
|
];
|
|
14906
|
+
/** The skill's folder in each skills folder. It was `cloudtifact` until CLI 0.3.4. */
|
|
14907
|
+
const SKILL_DIR = "cloudy";
|
|
14908
|
+
const OLD_SKILL_DIR = "cloudtifact";
|
|
14595
14909
|
SKILL_TARGETS.map((t) => t.parts);
|
|
14596
14910
|
/** The version in a copy's marker, or null for a copy written before markers existed (0.2.4 and older). */
|
|
14597
14911
|
function skillVersionOf(text) {
|
|
@@ -14602,7 +14916,7 @@ async function skillCopies(home, version = VERSION) {
|
|
|
14602
14916
|
const copies = [];
|
|
14603
14917
|
for (const { agent, parts } of SKILL_TARGETS) {
|
|
14604
14918
|
if (!existsSync(path.join(home, parts[0]))) continue;
|
|
14605
|
-
const file = path.join(home, ...parts,
|
|
14919
|
+
const file = path.join(home, ...parts, SKILL_DIR, "SKILL.md");
|
|
14606
14920
|
if (!existsSync(file)) {
|
|
14607
14921
|
copies.push({
|
|
14608
14922
|
agent,
|
|
@@ -14623,13 +14937,62 @@ async function skillCopies(home, version = VERSION) {
|
|
|
14623
14937
|
return copies;
|
|
14624
14938
|
}
|
|
14625
14939
|
/**
|
|
14626
|
-
*
|
|
14940
|
+
* Copies of the skill under its old folder name (<skillsDir>/cloudtifact) that an older CLI or `npx skills add`
|
|
14941
|
+
* wrote. Only ours: the folder's SKILL.md must say `name: cloudtifact`. A symlinked folder counts too.
|
|
14942
|
+
*/
|
|
14943
|
+
async function oldSkillCopies(home) {
|
|
14944
|
+
const found = [];
|
|
14945
|
+
for (const { agent, parts } of SKILL_TARGETS) {
|
|
14946
|
+
const dir = path.join(home, ...parts, OLD_SKILL_DIR);
|
|
14947
|
+
try {
|
|
14948
|
+
const text = await readFile(path.join(dir, "SKILL.md"), "utf8");
|
|
14949
|
+
if (/^name:\s*cloudtifact\s*$/m.test(text.slice(0, 400))) found.push({
|
|
14950
|
+
agent,
|
|
14951
|
+
dir
|
|
14952
|
+
});
|
|
14953
|
+
} catch {
|
|
14954
|
+
try {
|
|
14955
|
+
if ((await lstat(dir)).isSymbolicLink() && path.basename(await readlink(dir)) === "cloudtifact") found.push({
|
|
14956
|
+
agent,
|
|
14957
|
+
dir,
|
|
14958
|
+
dangling: true
|
|
14959
|
+
});
|
|
14960
|
+
} catch {}
|
|
14961
|
+
}
|
|
14962
|
+
}
|
|
14963
|
+
return found;
|
|
14964
|
+
}
|
|
14965
|
+
/**
|
|
14966
|
+
* Removes the old-name copies once the new ones are written, so an agent doesn't see the same skill twice. All are
|
|
14967
|
+
* copied to `backupDir/<agent>/cloudtifact` before any is removed, because one agent's copy is often a symlink to
|
|
14968
|
+
* another's (a symlink's target is copied; then only the link is removed).
|
|
14969
|
+
*/
|
|
14970
|
+
async function removeOldSkillCopies(home, backupDir) {
|
|
14971
|
+
const old = await oldSkillCopies(home);
|
|
14972
|
+
for (const { agent, dir, dangling } of old) {
|
|
14973
|
+
if (dangling) continue;
|
|
14974
|
+
const to = path.join(backupDir, agent, OLD_SKILL_DIR);
|
|
14975
|
+
await mkdir(path.dirname(to), { recursive: true });
|
|
14976
|
+
await cp(dir, to, {
|
|
14977
|
+
recursive: true,
|
|
14978
|
+
dereference: true
|
|
14979
|
+
});
|
|
14980
|
+
}
|
|
14981
|
+
for (const { dir } of old) if ((await lstat(dir)).isSymbolicLink()) await rm(dir);
|
|
14982
|
+
else await rm(dir, {
|
|
14983
|
+
recursive: true,
|
|
14984
|
+
force: true
|
|
14985
|
+
});
|
|
14986
|
+
return old.map((o) => o.dir);
|
|
14987
|
+
}
|
|
14988
|
+
/**
|
|
14989
|
+
* Writes <skillsDir>/cloudy/SKILL.md for every agent installed under `home`. An agent counts as installed when
|
|
14627
14990
|
* its own folder exists (~/.claude, ~/.codex, ...); its skills/ folder is created if needed, since a fresh install
|
|
14628
14991
|
* doesn't have one yet. A copy from another CLI version is rewritten; one from this version is left alone, so a copy
|
|
14629
14992
|
* somebody edited by hand survives until the CLI changes. `check` reports and writes nothing.
|
|
14630
14993
|
*/
|
|
14631
14994
|
async function installSkill(home, opts = {}) {
|
|
14632
|
-
const version = opts.version ?? "0.3.
|
|
14995
|
+
const version = opts.version ?? "0.3.5";
|
|
14633
14996
|
const markdown = skillMarkdown(version);
|
|
14634
14997
|
const copies = await skillCopies(home, version);
|
|
14635
14998
|
const written = [];
|
|
@@ -14649,9 +15012,19 @@ async function installSkill(home, opts = {}) {
|
|
|
14649
15012
|
written,
|
|
14650
15013
|
current,
|
|
14651
15014
|
missing,
|
|
14652
|
-
copies
|
|
15015
|
+
copies,
|
|
15016
|
+
old: (await oldSkillCopies(home)).map((o) => o.dir),
|
|
15017
|
+
removed: opts.check ? [] : await removeOldSkillCopies(home, opts.backupDir ?? skillBackupDir(home))
|
|
14653
15018
|
};
|
|
14654
15019
|
}
|
|
15020
|
+
/** Where `skill install` backs up what it removes: ~/.config/cloudtifact/backups/<time>. */
|
|
15021
|
+
function skillBackupDir(home, now = /* @__PURE__ */ new Date()) {
|
|
15022
|
+
const stamp = now.toISOString().replace(/[:.]/g, "-");
|
|
15023
|
+
return path.join(globalConfigDir({
|
|
15024
|
+
...process.env,
|
|
15025
|
+
CLOUDTIFACT_HOME: home
|
|
15026
|
+
}), "backups", stamp);
|
|
15027
|
+
}
|
|
14655
15028
|
/**
|
|
14656
15029
|
* Rewrites every copy written by another CLI version, saying nothing: the CLI refreshes the skill the same way it
|
|
14657
15030
|
* shows an update notice, so nobody has to remember `skill install` after upgrading. Never throws.
|
|
@@ -14803,15 +15176,17 @@ function skillInstallWriteCount(out) {
|
|
|
14803
15176
|
* version's advice and its marker. Never throws (the CLI is already updated either way); returns the lines to print.
|
|
14804
15177
|
*/
|
|
14805
15178
|
async function refreshSkillAfterUpgrade(file, to) {
|
|
14806
|
-
const
|
|
15179
|
+
const out = await new Promise((resolve) => {
|
|
14807
15180
|
execFile(process.execPath, [
|
|
14808
15181
|
file,
|
|
14809
15182
|
"skill",
|
|
14810
15183
|
"install"
|
|
14811
|
-
], { timeout:
|
|
14812
|
-
})
|
|
14813
|
-
|
|
14814
|
-
|
|
15184
|
+
], { timeout: 3e5 }, (_err, stdout) => resolve(String(stdout ?? "")));
|
|
15185
|
+
});
|
|
15186
|
+
const copies = skillInstallWriteCount(out);
|
|
15187
|
+
const moves = out.split("\n").filter((l) => l.startsWith("Claude Code:") || l.startsWith("removed old "));
|
|
15188
|
+
if (!copies) return moves;
|
|
15189
|
+
return [`Agent skill: refreshed ${copies} cop${copies === 1 ? "y" : "ies"} for ${to}.`, ...moves];
|
|
14815
15190
|
}
|
|
14816
15191
|
/**
|
|
14817
15192
|
* Replaces the installed bundle at `file` with `bytes`: written to a temp file beside it, checked by
|
|
@@ -14946,7 +15321,7 @@ async function runUpdateCheck(source, deps = {}) {
|
|
|
14946
15321
|
source,
|
|
14947
15322
|
...latest ? { latest } : before?.latest ? { latest: before.latest } : {}
|
|
14948
15323
|
}, env);
|
|
14949
|
-
await refreshSkillCopies(homeDir(env), deps.version ?? "0.3.
|
|
15324
|
+
await refreshSkillCopies(homeDir(env), deps.version ?? "0.3.5");
|
|
14950
15325
|
}
|
|
14951
15326
|
/** Starts the check in a detached process that outlives this one and is never waited for. */
|
|
14952
15327
|
function spawnUpdateCheck(entry, source) {
|
|
@@ -15150,7 +15525,7 @@ const program = new Command().name("cloudy").description("Publish pages and docs
|
|
|
15150
15525
|
const tty = !!process.stdout.isTTY && !!process.stderr.isTTY;
|
|
15151
15526
|
if (updateNoticeOff({
|
|
15152
15527
|
env: process.env,
|
|
15153
|
-
current: "0.3.
|
|
15528
|
+
current: "0.3.5",
|
|
15154
15529
|
command: cmd.name()
|
|
15155
15530
|
})) return;
|
|
15156
15531
|
const entry = fileURLToPath(import.meta.url);
|
|
@@ -15926,7 +16301,7 @@ program.command("versions").description("List a space's versions, newest first")
|
|
|
15926
16301
|
if (!rows.length) return console.log("Nothing pushed yet.");
|
|
15927
16302
|
for (const v of rows) console.log(`v${v.version} ${v.at} UTC ${byPerson(`@${v.by}`, v.via)}${v.project ? ` · ${v.project}` : ""} +${v.added} ~${v.changed} -${v.removed}${v.message ? ` ${v.message}` : ""}`);
|
|
15928
16303
|
}));
|
|
15929
|
-
program.command("settings").description("Show who can open a space and its guest and visitor switches, or change them (space admins; the same switches as in the app)").option("--space <id>", "space id, public link, or copied URL (default: the first target in .cloudtifact.json)").option(VISIBILITY_OPTION, "who can open it: private (only members of its workspace; members also works) or public (anyone with the link). Going public turns guest comments on; going private turns guest comments
|
|
16304
|
+
program.command("settings").description("Show who can open a space and its guest and visitor switches, or change them (space admins; the same switches as in the app)").option("--space <id>", "space id, public link, or copied URL (default: the first target in .cloudtifact.json)").option(VISIBILITY_OPTION, "who can open it: private (only members of its workspace; members also works) or public (anyone with the link). Going public turns guest comments on; going private turns guest comments, guest writes and search engines off").option(SETTINGS[0].option, SETTINGS[0].label).option(SETTINGS[1].option, `${SETTINGS[1].label} (off keeps the database private from visitors)`).option(SETTINGS[2].option, SETTINGS[2].label).option(SETTINGS[3].option, `${SETTINGS[3].label} (public spaces with no password; off by default, and other public pages stay out of search)`).option("--link <name>", "set the public link (lowercase letters, numbers and single dashes; off clears it, and an old link goes to the new one)").option("--toon", "print TOON (compact, for agents)").option("--json", "print JSON").action(run(async (opts) => {
|
|
15930
16305
|
const { spaceId } = await pickSpace(opts.space);
|
|
15931
16306
|
const patch = settingsPatch(opts);
|
|
15932
16307
|
const { client } = await getClient();
|
|
@@ -16412,10 +16787,21 @@ rulesCmd.command("stats").description("How the rules are doing: sent, fit, follo
|
|
|
16412
16787
|
process.stdout.write(statsText(stats));
|
|
16413
16788
|
}));
|
|
16414
16789
|
const skill = program.command("skill").description("The agent skill that teaches agents to use Cloudy");
|
|
16415
|
-
skill.command("install").description("Write
|
|
16416
|
-
const
|
|
16790
|
+
skill.command("install").description("Write cloudy/SKILL.md into every agent skills folder, refreshing copies another CLI version wrote, and move old cloudtifact copies and Claude Code's old cloudtifact plugin over").option("--check", "only list the copies that are out of date; write nothing (exits 1 when any are)").action(run(async (opts) => {
|
|
16791
|
+
const backupDir = skillBackupDir(homeDir());
|
|
16792
|
+
const { written, current, missing, copies, old, removed } = await installSkill(homeDir(), {
|
|
16793
|
+
check: opts.check,
|
|
16794
|
+
backupDir
|
|
16795
|
+
});
|
|
16796
|
+
const plugin = await moveClaudePlugin(homeDir(), {
|
|
16797
|
+
backupDir,
|
|
16798
|
+
check: opts.check
|
|
16799
|
+
});
|
|
16417
16800
|
const behind = copies.filter((c) => c.state !== "current");
|
|
16418
16801
|
if (opts.check) {
|
|
16802
|
+
for (const d of old) console.log(`old name: ${d} (\`cloudy skill install\` moves it to ${SKILL_DIR}/)`);
|
|
16803
|
+
for (const l of plugin.lines) console.log(l);
|
|
16804
|
+
if (old.length || plugin.state !== "none") process.exitCode = 1;
|
|
16419
16805
|
for (const c of copies) console.log(`${c.agent}: ${c.state === "missing" ? "missing" : c.version ? `v${c.version}` : "no version marker"} ${c.state === "current" ? "(current)" : `(out of date, CLI is ${VERSION})`} ${c.file}`);
|
|
16420
16806
|
if (!copies.length) console.log(`No agents found, so nothing is installed (looked for ${missing.map((d) => path.dirname(d)).join(", ")}).`);
|
|
16421
16807
|
else if (behind.length) {
|
|
@@ -16426,6 +16812,9 @@ skill.command("install").description("Write cloudtifact/SKILL.md into every agen
|
|
|
16426
16812
|
}
|
|
16427
16813
|
for (const f of written) console.log(`${copies.some((c) => c.file === f && c.state === "stale") ? "refreshed" : "wrote"} ${f}`);
|
|
16428
16814
|
for (const f of current) console.log(`up to date ${f}`);
|
|
16815
|
+
for (const d of removed) console.log(`removed old ${d} (backup in ${backupDir})`);
|
|
16816
|
+
for (const l of plugin.lines) console.log(l);
|
|
16817
|
+
if (plugin.state === "failed") process.exitCode = 1;
|
|
16429
16818
|
if (!written.length && !current.length) console.log(`No agents found, so nothing was written (looked for ${missing.map((d) => path.dirname(d)).join(", ")}). Install Claude Code, Codex, Cursor or opencode, then run this again.`);
|
|
16430
16819
|
}));
|
|
16431
16820
|
skill.command("status").description("List the installed skill copies and the CLI version each was written with (exits 1 when any is out of date)").option("--toon", "print TOON (compact, for agents)").option("--json", "print JSON").action(run(async (opts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usecloudy",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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",
|