@scribe-platform/cli 0.2.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -4
- package/dist/commands/schema.d.ts.map +1 -1
- package/dist/commands/schema.js +51 -0
- package/dist/commands/schema.js.map +1 -1
- package/dist/commands/submission.d.ts.map +1 -1
- package/dist/commands/submission.js +74 -22
- package/dist/commands/submission.js.map +1 -1
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +93 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +62 -11
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +66 -9
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/skill.d.ts +45 -0
- package/dist/lib/skill.d.ts.map +1 -0
- package/dist/lib/skill.js +70 -0
- package/dist/lib/skill.js.map +1 -0
- package/package.json +3 -1
- package/skills/scribe-site-builder/SKILL.md +373 -0
- package/skills/scribe-site-builder/recipes/README.md +31 -0
- package/skills/scribe-site-builder/recipes/collections.md +87 -0
- package/skills/scribe-site-builder/recipes/deploy.md +122 -0
- package/skills/scribe-site-builder/recipes/forms.md +231 -0
- package/skills/scribe-site-builder/recipes/schema.md +99 -0
package/dist/lib/client.js
CHANGED
|
@@ -27,7 +27,7 @@ export class ScribeClient {
|
|
|
27
27
|
constructor(options) {
|
|
28
28
|
this.options = options;
|
|
29
29
|
}
|
|
30
|
-
async
|
|
30
|
+
async send(method, path, body) {
|
|
31
31
|
const res = await fetch(`${this.options.apiUrl}${path}`, {
|
|
32
32
|
method,
|
|
33
33
|
headers: {
|
|
@@ -36,7 +36,10 @@ export class ScribeClient {
|
|
|
36
36
|
},
|
|
37
37
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
return { res, text: await res.text() };
|
|
40
|
+
}
|
|
41
|
+
async request(method, path, body) {
|
|
42
|
+
const { res, text } = await this.send(method, path, body);
|
|
40
43
|
const data = text.length > 0 ? JSON.parse(text) : undefined;
|
|
41
44
|
if (!res.ok) {
|
|
42
45
|
const message = data && typeof data === 'object' && 'error' in data ? String(data.error) : res.statusText;
|
|
@@ -44,6 +47,28 @@ export class ScribeClient {
|
|
|
44
47
|
}
|
|
45
48
|
return data;
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* For responses that aren't JSON — today, a CSV export. A failure still
|
|
52
|
+
* arrives as a JSON `{ error }` body, so the error path parses while the
|
|
53
|
+
* success path deliberately doesn't.
|
|
54
|
+
*/
|
|
55
|
+
async requestText(method, path, body) {
|
|
56
|
+
const { res, text } = await this.send(method, path, body);
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
let data;
|
|
59
|
+
try {
|
|
60
|
+
data = text.length > 0 ? JSON.parse(text) : undefined;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// A non-JSON error body (a proxy's HTML 502 page, say) is not worth a
|
|
64
|
+
// parse failure masking the status code the caller actually needs.
|
|
65
|
+
data = undefined;
|
|
66
|
+
}
|
|
67
|
+
const message = data && typeof data === 'object' && 'error' in data ? String(data.error) : res.statusText;
|
|
68
|
+
throw new ScribeApiError(message, res.status, data);
|
|
69
|
+
}
|
|
70
|
+
return text;
|
|
71
|
+
}
|
|
47
72
|
async whoami() {
|
|
48
73
|
return this.request('GET', '/api/v1/whoami');
|
|
49
74
|
}
|
|
@@ -84,13 +109,42 @@ export class ScribeClient {
|
|
|
84
109
|
async revertContent(site, path, sha) {
|
|
85
110
|
return this.request('POST', `/api/v1/sites/${encodeURIComponent(site)}/content/${encodePath(path)}?action=revert&sha=${encodeURIComponent(sha)}`);
|
|
86
111
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
/** `page` is 1-based; omitting it lets the server pick the first page and its own page size. */
|
|
113
|
+
async listSubmissions(site, collection, status, page) {
|
|
114
|
+
const query = new URLSearchParams({
|
|
115
|
+
collection,
|
|
116
|
+
...(status ? { status } : {}),
|
|
117
|
+
...(page !== undefined ? { page: String(page) } : {}),
|
|
118
|
+
});
|
|
119
|
+
return this.request('GET', `/api/v1/sites/${encodeURIComponent(site)}/submissions?${query.toString()}`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* `id` is the submission's ObjectId, so the route takes a single path segment
|
|
123
|
+
* rather than a repo path. No `sha` and no conflict case: status is
|
|
124
|
+
* last-write-wins, and `note` appends to the event log — which is the record
|
|
125
|
+
* of what actually happened.
|
|
126
|
+
*/
|
|
127
|
+
async updateSubmission(site, collection, id, input) {
|
|
128
|
+
// `collection` rides as a query param rather than a path segment: the id
|
|
129
|
+
// alone identifies the submission, but the route needs the collection's
|
|
130
|
+
// workflow to validate the requested status against.
|
|
131
|
+
const query = new URLSearchParams({ collection });
|
|
132
|
+
return this.request('PATCH', `/api/v1/sites/${encodeURIComponent(site)}/submissions/${encodeURIComponent(id)}?${query.toString()}`, input);
|
|
133
|
+
}
|
|
134
|
+
/** Hard delete, cascading the submission's events. Staff roles only — a site user's key gets a 403. */
|
|
135
|
+
async deleteSubmission(site, collection, id) {
|
|
136
|
+
const query = new URLSearchParams({ collection });
|
|
137
|
+
return this.request('DELETE', `/api/v1/sites/${encodeURIComponent(site)}/submissions/${encodeURIComponent(id)}?${query.toString()}`);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns the export as **text**, not a parsed object, so a CSV reaches
|
|
141
|
+
* stdout byte-for-byte as the server wrote it and a JSON export isn't
|
|
142
|
+
* round-tripped through `JSON.parse` only to be stringified again with
|
|
143
|
+
* different spacing.
|
|
144
|
+
*/
|
|
145
|
+
async exportSubmissions(site, collection, format, status) {
|
|
146
|
+
const query = new URLSearchParams({ collection, format, ...(status ? { status } : {}) });
|
|
147
|
+
return this.requestText('GET', `/api/v1/sites/${encodeURIComponent(site)}/submissions/export?${query.toString()}`);
|
|
94
148
|
}
|
|
95
149
|
async getSchema(site) {
|
|
96
150
|
return this.request('GET', `/api/v1/sites/${encodeURIComponent(site)}/schema`);
|
|
@@ -101,6 +155,9 @@ export class ScribeClient {
|
|
|
101
155
|
path,
|
|
102
156
|
});
|
|
103
157
|
}
|
|
158
|
+
async schemaApply(site, spec) {
|
|
159
|
+
return this.request('PUT', `/api/v1/sites/${encodeURIComponent(site)}/schema/collections`, { spec });
|
|
160
|
+
}
|
|
104
161
|
async schemaRemove(site, name) {
|
|
105
162
|
return this.request('DELETE', `/api/v1/sites/${encodeURIComponent(site)}/schema/collections/${encodeURIComponent(name)}`);
|
|
106
163
|
}
|
package/dist/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrB;IACA;IAHlB,YACE,OAAe,EACC,MAAc,EACd,IAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrB;IACA;IAHlB,YACE,OAAe,EACC,MAAc,EACd,IAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAqGD,iHAAiH;AACjH,SAAS,UAAU,CAAC,IAA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|
+
export declare const SKILL_NAME = "scribe-site-builder";
|
|
3
|
+
/** Where Claude Code discovers globally-installed skills. */
|
|
4
|
+
export declare function skillDestination(): string;
|
|
5
|
+
/**
|
|
6
|
+
* The skill bundled with this install, or null if it can't be found. Two
|
|
7
|
+
* candidates, tried in order:
|
|
8
|
+
*
|
|
9
|
+
* 1. `<package>/skills/<name>` — a published tarball, where `prepack`
|
|
10
|
+
* (scripts/bundle-skill.mjs) copied the repo's skill in.
|
|
11
|
+
* 2. `<repo>/skills/<name>` — a dev checkout, where the skill only exists at
|
|
12
|
+
* the monorepo root.
|
|
13
|
+
*
|
|
14
|
+
* Both are the same number of levels up from this file whether it runs as
|
|
15
|
+
* `src/lib/skill.ts` (tests) or `dist/lib/skill.js` (published).
|
|
16
|
+
*
|
|
17
|
+
* Resolved at call time, on purpose: `scribe update` calls this *after* `npm
|
|
18
|
+
* install -g` has replaced this package's files, so it reads the skill that
|
|
19
|
+
* ships with the version just installed rather than the one the running process
|
|
20
|
+
* started with.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bundledSkillPath(): string | null;
|
|
23
|
+
export type SkillInstallResult = {
|
|
24
|
+
status: 'installed';
|
|
25
|
+
dest: string;
|
|
26
|
+
} | {
|
|
27
|
+
status: 'symlink';
|
|
28
|
+
dest: string;
|
|
29
|
+
} | {
|
|
30
|
+
status: 'missing-source';
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Copies the bundled skill into ~/.claude/skills, replacing whatever is there.
|
|
34
|
+
*
|
|
35
|
+
* A **symlink** at the destination is left untouched: that's a dev checkout
|
|
36
|
+
* pointing at the repo's own skills/ directory, and overwriting it with a copy
|
|
37
|
+
* would silently detach the author's live editing target.
|
|
38
|
+
*/
|
|
39
|
+
export declare function installSkill(options?: {
|
|
40
|
+
source?: string | null;
|
|
41
|
+
dest?: string;
|
|
42
|
+
}): SkillInstallResult;
|
|
43
|
+
/** Shortens a path for display, so output reads `~/.claude/skills/...`. */
|
|
44
|
+
export declare function tildify(path: string): string;
|
|
45
|
+
//# sourceMappingURL=skill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/lib/skill.ts"],"names":[],"mappings":"AAKA,sFAAsF;AACtF,eAAO,MAAM,UAAU,wBAAwB,CAAC;AAEhD,6DAA6D;AAC7D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAOhD;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAWjC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,kBAAkB,CAaxG;AAED,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { cpSync, existsSync, lstatSync, mkdirSync, rmSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
/** The Claude Code skill this package ships, as both its directory and skill name. */
|
|
6
|
+
export const SKILL_NAME = 'scribe-site-builder';
|
|
7
|
+
/** Where Claude Code discovers globally-installed skills. */
|
|
8
|
+
export function skillDestination() {
|
|
9
|
+
return join(homedir(), '.claude', 'skills', SKILL_NAME);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The skill bundled with this install, or null if it can't be found. Two
|
|
13
|
+
* candidates, tried in order:
|
|
14
|
+
*
|
|
15
|
+
* 1. `<package>/skills/<name>` — a published tarball, where `prepack`
|
|
16
|
+
* (scripts/bundle-skill.mjs) copied the repo's skill in.
|
|
17
|
+
* 2. `<repo>/skills/<name>` — a dev checkout, where the skill only exists at
|
|
18
|
+
* the monorepo root.
|
|
19
|
+
*
|
|
20
|
+
* Both are the same number of levels up from this file whether it runs as
|
|
21
|
+
* `src/lib/skill.ts` (tests) or `dist/lib/skill.js` (published).
|
|
22
|
+
*
|
|
23
|
+
* Resolved at call time, on purpose: `scribe update` calls this *after* `npm
|
|
24
|
+
* install -g` has replaced this package's files, so it reads the skill that
|
|
25
|
+
* ships with the version just installed rather than the one the running process
|
|
26
|
+
* started with.
|
|
27
|
+
*/
|
|
28
|
+
export function bundledSkillPath() {
|
|
29
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
const candidates = [
|
|
31
|
+
join(here, '..', '..', 'skills', SKILL_NAME),
|
|
32
|
+
join(here, '..', '..', '..', '..', 'skills', SKILL_NAME),
|
|
33
|
+
];
|
|
34
|
+
return candidates.find((candidate) => existsSync(join(candidate, 'SKILL.md'))) ?? null;
|
|
35
|
+
}
|
|
36
|
+
/** lstat without throwing, so a missing path and a broken symlink are both answerable. */
|
|
37
|
+
function lstatOrNull(path) {
|
|
38
|
+
try {
|
|
39
|
+
return lstatSync(path);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Copies the bundled skill into ~/.claude/skills, replacing whatever is there.
|
|
47
|
+
*
|
|
48
|
+
* A **symlink** at the destination is left untouched: that's a dev checkout
|
|
49
|
+
* pointing at the repo's own skills/ directory, and overwriting it with a copy
|
|
50
|
+
* would silently detach the author's live editing target.
|
|
51
|
+
*/
|
|
52
|
+
export function installSkill(options = {}) {
|
|
53
|
+
const source = options.source === undefined ? bundledSkillPath() : options.source;
|
|
54
|
+
const dest = options.dest ?? skillDestination();
|
|
55
|
+
if (!source)
|
|
56
|
+
return { status: 'missing-source' };
|
|
57
|
+
const existing = lstatOrNull(dest);
|
|
58
|
+
if (existing?.isSymbolicLink())
|
|
59
|
+
return { status: 'symlink', dest };
|
|
60
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
61
|
+
rmSync(dest, { recursive: true, force: true });
|
|
62
|
+
cpSync(source, dest, { recursive: true });
|
|
63
|
+
return { status: 'installed', dest };
|
|
64
|
+
}
|
|
65
|
+
/** Shortens a path for display, so output reads `~/.claude/skills/...`. */
|
|
66
|
+
export function tildify(path) {
|
|
67
|
+
const home = homedir();
|
|
68
|
+
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=skill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../src/lib/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAc,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,sFAAsF;AACtF,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEhD,6DAA6D;AAC7D,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CA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E,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scribe-platform/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Command-line interface for Scribe CMS — scaffold sites, edit content, and triage form submissions from the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Dave Weaver",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"bin",
|
|
34
34
|
"dist",
|
|
35
|
+
"skills",
|
|
35
36
|
"README.md",
|
|
36
37
|
"LICENSE"
|
|
37
38
|
],
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "tsc -p tsconfig.json",
|
|
47
|
+
"prepack": "node scripts/bundle-skill.mjs",
|
|
46
48
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
47
49
|
"lint": "tsc -p tsconfig.json --noEmit",
|
|
48
50
|
"prepublishOnly": "npm run build"
|