@solidactions/cli 3.20.0 → 3.21.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 +11 -5
- package/dist/command-manifest.json +18 -7
- package/dist/commands/connection-list.js +2 -2
- package/dist/commands/database-push.js +1 -1
- package/dist/commands/deploy.js +20 -6
- package/dist/commands/dev.js +4 -4
- package/dist/commands/doc-pull.js +146 -32
- package/dist/commands/doc-push.js +242 -30
- package/dist/commands/env-list.js +8 -8
- package/dist/commands/init.js +4 -1
- package/dist/commands/login.js +7 -11
- package/dist/commands/run-list.js +3 -19
- package/dist/commands/run-start.js +10 -9
- package/dist/commands/run-view.js +8 -20
- package/dist/commands/workspaces.js +5 -1
- package/dist/index.js +13 -7
- package/dist/utils/api.js +34 -2
- package/dist/utils/config.js +96 -3
- package/dist/utils/mcp.js +38 -5
- package/dist/utils/mutating-commands.js +1 -1
- package/dist/utils/run-status.js +61 -0
- package/dist/utils/secure-write.js +40 -5
- package/dist/utils/workspace-lookup.js +30 -3
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* solidactions doc push <
|
|
3
|
+
* solidactions doc push <path>
|
|
4
4
|
*
|
|
5
|
-
* Recursively uploads a local
|
|
6
|
-
* server's `
|
|
5
|
+
* Recursively uploads a local docs tree (.md, .html, .canvas.json, .canvas) into
|
|
6
|
+
* SA-Docs via the docs MCP server's `docs_manage` tool's `bulk_create` action,
|
|
7
|
+
* mirroring folder structure — or pushes one such file alone.
|
|
7
8
|
*
|
|
8
9
|
* Prints a report distinguishing fully-published docs from "properties pending"
|
|
9
10
|
* ones (docs whose frontmatter properties couldn't be validated yet).
|
|
@@ -12,6 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
14
|
};
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.MAX_CHUNK_BYTES = exports.MAX_DOC_BODY_BYTES = void 0;
|
|
17
|
+
exports.docFileKind = docFileKind;
|
|
18
|
+
exports.quoteShellPath = quoteShellPath;
|
|
15
19
|
exports.docPushWithConfig = docPushWithConfig;
|
|
16
20
|
exports.docPush = docPush;
|
|
17
21
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -23,6 +27,31 @@ const api_1 = require("../utils/api");
|
|
|
23
27
|
const mcp_1 = require("../utils/mcp");
|
|
24
28
|
const docs_manifest_1 = require("../utils/docs-manifest");
|
|
25
29
|
const CHUNK_SIZE = 50;
|
|
30
|
+
/**
|
|
31
|
+
* The file kinds `doc push` creates docs from (cli#154). Order matters: `.canvas.json`
|
|
32
|
+
* must be tested before any shorter suffix. `type` is the built-in doc type the server
|
|
33
|
+
* creates the doc as; markdown sends none. `.canvas` is the JSON Canvas extension other
|
|
34
|
+
* tools write (PM ruling 8).
|
|
35
|
+
*/
|
|
36
|
+
const DOC_FILE_KINDS = [
|
|
37
|
+
{ suffix: '.canvas.json', type: 'canvas' },
|
|
38
|
+
{ suffix: '.canvas', type: 'canvas' },
|
|
39
|
+
{ suffix: '.html', type: 'visual' },
|
|
40
|
+
{ suffix: '.md' },
|
|
41
|
+
];
|
|
42
|
+
function docFileKind(fileName) {
|
|
43
|
+
return DOC_FILE_KINDS.find((kind) => fileName.endsWith(kind.suffix) && fileName.length > kind.suffix.length) ?? null;
|
|
44
|
+
}
|
|
45
|
+
/** Shell-quote a suggested path only when it needs it (cli#154 I4). */
|
|
46
|
+
function quoteShellPath(suggested) {
|
|
47
|
+
if (/^[A-Za-z0-9_./-]+$/.test(suggested))
|
|
48
|
+
return suggested;
|
|
49
|
+
return `'${suggested.replace(/'/g, `'\\''`)}'`;
|
|
50
|
+
}
|
|
51
|
+
/** The server's body cap (docs.blob_size_cap_bytes): refuse locally rather than send a doomed request (PM ruling 3). */
|
|
52
|
+
exports.MAX_DOC_BODY_BYTES = 1_048_576;
|
|
53
|
+
/** A bulk_create request carries at most CHUNK_SIZE items and about this many body bytes (PM ruling 3). */
|
|
54
|
+
exports.MAX_CHUNK_BYTES = 4_194_304;
|
|
26
55
|
const SKIP_DIRS = new Set(['node_modules']);
|
|
27
56
|
/**
|
|
28
57
|
* Directory/dot entries neither walker descends into or picks up: dotfiles and
|
|
@@ -34,10 +63,11 @@ function isSkippedEntry(name) {
|
|
|
34
63
|
return name.startsWith('.') || SKIP_DIRS.has(name);
|
|
35
64
|
}
|
|
36
65
|
/**
|
|
37
|
-
* Recursively walk `dir` and collect all
|
|
66
|
+
* Recursively walk `dir` and collect all pushable doc files (.md, .html,
|
|
67
|
+
* .canvas.json, .canvas).
|
|
38
68
|
* Returns a list of absolute paths.
|
|
39
69
|
*/
|
|
40
|
-
function
|
|
70
|
+
function walkDocFiles(dir) {
|
|
41
71
|
const results = [];
|
|
42
72
|
const walk = (current) => {
|
|
43
73
|
for (const entry of fs_1.default.readdirSync(current, { withFileTypes: true })) {
|
|
@@ -47,7 +77,7 @@ function walkMarkdownFiles(dir) {
|
|
|
47
77
|
if (entry.isDirectory()) {
|
|
48
78
|
walk(abs);
|
|
49
79
|
}
|
|
50
|
-
else if (entry.isFile() && entry.name
|
|
80
|
+
else if (entry.isFile() && docFileKind(entry.name) !== null) {
|
|
51
81
|
results.push(abs);
|
|
52
82
|
}
|
|
53
83
|
}
|
|
@@ -56,9 +86,9 @@ function walkMarkdownFiles(dir) {
|
|
|
56
86
|
return results;
|
|
57
87
|
}
|
|
58
88
|
/**
|
|
59
|
-
* Recursively walk `dir` and collect relative paths of
|
|
60
|
-
* are not present in the manifest — never uploaded by `doc push`;
|
|
61
|
-
* upload` is the way to create media docs from these. Dotfiles and
|
|
89
|
+
* Recursively walk `dir` and collect relative paths of files of no pushable
|
|
90
|
+
* kind that are not present in the manifest — never uploaded by `doc push`;
|
|
91
|
+
* `doc upload` is the way to create media docs from these. Dotfiles and
|
|
62
92
|
* dot-directories are excluded (`entry.name.startsWith('.')` also covers the
|
|
63
93
|
* `.solidactions-docs.json` sidecar itself).
|
|
64
94
|
*/
|
|
@@ -72,7 +102,7 @@ function walkUntrackedBinaries(dir, manifest) {
|
|
|
72
102
|
if (entry.isDirectory()) {
|
|
73
103
|
walk(abs);
|
|
74
104
|
}
|
|
75
|
-
else if (entry.isFile() &&
|
|
105
|
+
else if (entry.isFile() && docFileKind(entry.name) === null) {
|
|
76
106
|
const relPath = path_1.default.relative(dir, abs).split(path_1.default.sep).join('/');
|
|
77
107
|
if (!manifest?.docs[relPath]) {
|
|
78
108
|
results.push(relPath);
|
|
@@ -87,7 +117,8 @@ function walkUntrackedBinaries(dir, manifest) {
|
|
|
87
117
|
* Convert an absolute file path to a bulk_create item, relative to `rootDir`.
|
|
88
118
|
*/
|
|
89
119
|
function fileToItem(absPath, rootDir) {
|
|
90
|
-
const
|
|
120
|
+
const kind = docFileKind(path_1.default.basename(absPath));
|
|
121
|
+
const title = path_1.default.basename(absPath).slice(0, -kind.suffix.length);
|
|
91
122
|
const body = fs_1.default.readFileSync(absPath, 'utf8');
|
|
92
123
|
const relDir = path_1.default.relative(rootDir, path_1.default.dirname(absPath));
|
|
93
124
|
// Use POSIX separators; omit if file is in the root dir
|
|
@@ -96,8 +127,149 @@ function fileToItem(absPath, rootDir) {
|
|
|
96
127
|
if (relative_folder_path !== undefined) {
|
|
97
128
|
item.relative_folder_path = relative_folder_path;
|
|
98
129
|
}
|
|
130
|
+
if (kind.type !== undefined) {
|
|
131
|
+
item.type = kind.type;
|
|
132
|
+
}
|
|
99
133
|
return item;
|
|
100
134
|
}
|
|
135
|
+
/** Two files in one push that would create the same title in the same folder are refused locally (PM ruling 11). */
|
|
136
|
+
function assertUniqueTitles(files, rootDir) {
|
|
137
|
+
const seen = new Map();
|
|
138
|
+
for (const file of files) {
|
|
139
|
+
const name = path_1.default.basename(file);
|
|
140
|
+
const kind = docFileKind(name);
|
|
141
|
+
const relDir = path_1.default.relative(rootDir, path_1.default.dirname(file)).split(path_1.default.sep).join('/');
|
|
142
|
+
const title = name.slice(0, -kind.suffix.length);
|
|
143
|
+
const key = `${relDir}\u0000${title}`;
|
|
144
|
+
const relFile = path_1.default.relative(rootDir, file).split(path_1.default.sep).join('/');
|
|
145
|
+
const other = seen.get(key);
|
|
146
|
+
if (other !== undefined) {
|
|
147
|
+
process.stderr.write(chalk_1.default.red(`error: ${other} and ${relFile} would both create the doc "${title}"${relDir ? ` in ${relDir}` : ''} — rename one of them\n`));
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
seen.set(key, relFile);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function assertBodiesWithinCap(files, rootDir) {
|
|
154
|
+
for (const file of files) {
|
|
155
|
+
const size = fs_1.default.statSync(file).size;
|
|
156
|
+
if (size > exports.MAX_DOC_BODY_BYTES) {
|
|
157
|
+
const rel = path_1.default.relative(rootDir, file).split(path_1.default.sep).join('/');
|
|
158
|
+
process.stderr.write(chalk_1.default.red(`error: ${rel}: ${size} bytes is over the 1 MiB (${exports.MAX_DOC_BODY_BYTES} bytes) doc body limit\n`));
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** A canvas file must at least be a JSON object; shape is the server's (invalid_canvas_body). */
|
|
164
|
+
function assertCanvasFilesParse(files, rootDir) {
|
|
165
|
+
for (const file of files) {
|
|
166
|
+
if (docFileKind(path_1.default.basename(file))?.type !== 'canvas')
|
|
167
|
+
continue;
|
|
168
|
+
const rel = path_1.default.relative(rootDir, file).split(path_1.default.sep).join('/');
|
|
169
|
+
let parsed;
|
|
170
|
+
try {
|
|
171
|
+
parsed = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
process.stderr.write(chalk_1.default.red(`error: ${rel}: not a valid JSON Canvas file (${e.message})\n`));
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
178
|
+
process.stderr.write(chalk_1.default.red(`error: ${rel}: not a valid JSON Canvas file (expected a JSON object)\n`));
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function chunkItems(items) {
|
|
184
|
+
const chunks = [];
|
|
185
|
+
let current = [];
|
|
186
|
+
let bytes = 0;
|
|
187
|
+
for (const item of items) {
|
|
188
|
+
const size = Buffer.byteLength(item.body, 'utf8');
|
|
189
|
+
if (current.length > 0 && (current.length >= CHUNK_SIZE || bytes + size > exports.MAX_CHUNK_BYTES)) {
|
|
190
|
+
chunks.push(current);
|
|
191
|
+
current = [];
|
|
192
|
+
bytes = 0;
|
|
193
|
+
}
|
|
194
|
+
current.push(item);
|
|
195
|
+
bytes += size;
|
|
196
|
+
}
|
|
197
|
+
if (current.length > 0)
|
|
198
|
+
chunks.push(current);
|
|
199
|
+
return chunks;
|
|
200
|
+
}
|
|
201
|
+
/** Which doc types a file kind may replace. `.md` may replace anything that is not visual, canvas or media. */
|
|
202
|
+
function replaceKindMismatch(fileType, docSlug) {
|
|
203
|
+
if (fileType !== undefined)
|
|
204
|
+
return docSlug !== fileType;
|
|
205
|
+
return docSlug === 'visual' || docSlug === 'canvas' || docSlug === 'media';
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* `doc push <file> --replace <id>`: replace one existing doc's body by id (cli#154). No
|
|
209
|
+
* base_revision — the user named the doc — so the doc's type is checked first: the server
|
|
210
|
+
* accepts any body under the cap for a visual or markdown doc (PM ruling 2).
|
|
211
|
+
*/
|
|
212
|
+
async function replaceDocBody(absPath, singleFile, options, config) {
|
|
213
|
+
const fail = (message) => {
|
|
214
|
+
process.stderr.write(chalk_1.default.red(`error: ${message}\n`));
|
|
215
|
+
process.exit(1);
|
|
216
|
+
};
|
|
217
|
+
if (!/^\d+$/.test(options.replace ?? ''))
|
|
218
|
+
fail(`--replace takes a numeric doc id (got "${options.replace}").`);
|
|
219
|
+
if (!singleFile)
|
|
220
|
+
fail('--replace takes a single .md, .html, .canvas.json or .canvas file, not a directory.');
|
|
221
|
+
if (options.folder !== undefined || options.type !== undefined || options.onConflict !== undefined) {
|
|
222
|
+
fail('--replace cannot be combined with --folder, --type or --on-conflict.');
|
|
223
|
+
}
|
|
224
|
+
assertBodiesWithinCap([absPath], path_1.default.dirname(absPath));
|
|
225
|
+
assertCanvasFilesParse([absPath], path_1.default.dirname(absPath));
|
|
226
|
+
const id = Number(options.replace);
|
|
227
|
+
const file = path_1.default.basename(absPath);
|
|
228
|
+
const fileType = docFileKind(file).type;
|
|
229
|
+
let read;
|
|
230
|
+
try {
|
|
231
|
+
read = await (0, mcp_1.callDocsTool)(config, { action: 'read_doc', id });
|
|
232
|
+
}
|
|
233
|
+
catch (e) {
|
|
234
|
+
return fail(e.message);
|
|
235
|
+
}
|
|
236
|
+
if (!read.ok) {
|
|
237
|
+
fail(`${read.data?.code ?? 'unknown_error'}: ${read.data?.message ?? 'MCP returned an error with no message'}`);
|
|
238
|
+
}
|
|
239
|
+
const title = String(read.data?.title ?? '');
|
|
240
|
+
const docSlug = read.data?.doc_type?.slug ?? null;
|
|
241
|
+
if (replaceKindMismatch(fileType, docSlug)) {
|
|
242
|
+
fail(`doc ${id} ("${title}") is a ${docSlug ?? 'markdown'} doc, and ${file} is a ${fileType ?? 'markdown'} file — refusing to replace it.`);
|
|
243
|
+
}
|
|
244
|
+
if (options.dryRun) {
|
|
245
|
+
if (options.json) {
|
|
246
|
+
console.log(JSON.stringify({ replaced: { id, title, file, dry_run: true } }));
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
console.log(chalk_1.default.cyan(`[dry-run preview] would replace doc ${id} ("${title}") with ${file}`));
|
|
250
|
+
}
|
|
251
|
+
process.exit(0);
|
|
252
|
+
}
|
|
253
|
+
const body = fs_1.default.readFileSync(absPath, 'utf8');
|
|
254
|
+
let result;
|
|
255
|
+
try {
|
|
256
|
+
result = await (0, mcp_1.callDocsTool)(config, { action: 'write', id, body });
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
return fail(e.message);
|
|
260
|
+
}
|
|
261
|
+
if (!result.ok) {
|
|
262
|
+
fail(`${result.data?.code ?? 'unknown_error'}: ${result.data?.message ?? 'MCP returned an error with no message'}`);
|
|
263
|
+
}
|
|
264
|
+
const revision = result.data?.current_revision_id ?? null;
|
|
265
|
+
if (options.json) {
|
|
266
|
+
console.log(JSON.stringify({ replaced: { id, title, file, current_revision_id: revision } }));
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
console.log(chalk_1.default.green(`replaced doc ${id} ("${title}") with ${file}${revision !== null ? ` (revision ${revision})` : ''}`));
|
|
270
|
+
}
|
|
271
|
+
process.exit(0);
|
|
272
|
+
}
|
|
101
273
|
/**
|
|
102
274
|
* Merge two BulkCreateSummary objects by summing all numeric fields.
|
|
103
275
|
*/
|
|
@@ -151,26 +323,53 @@ function formatSummaryLine(summary, dryRun) {
|
|
|
151
323
|
* stub server without touching the filesystem config.
|
|
152
324
|
*/
|
|
153
325
|
async function docPushWithConfig(dir, options, config) {
|
|
154
|
-
const
|
|
155
|
-
if (!fs_1.default.existsSync(
|
|
156
|
-
process.stderr.write(chalk_1.default.red(`error: "${dir}"
|
|
326
|
+
const absPath = path_1.default.resolve(dir);
|
|
327
|
+
if (!fs_1.default.existsSync(absPath)) {
|
|
328
|
+
process.stderr.write(chalk_1.default.red(`error: "${dir}" does not exist.\n`));
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
const singleFile = fs_1.default.statSync(absPath).isFile();
|
|
332
|
+
if (singleFile && docFileKind(path_1.default.basename(absPath)) === null) {
|
|
333
|
+
process.stderr.write(chalk_1.default.red(`error: "${dir}" is not a .md, .html, .canvas.json or .canvas file (use \`solidactions doc upload\` for media).\n`));
|
|
157
334
|
process.exit(1);
|
|
158
335
|
}
|
|
159
|
-
|
|
336
|
+
if (options.replace !== undefined) {
|
|
337
|
+
await replaceDocBody(absPath, singleFile, options, config);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
// A single file is pushed as if its directory held only that file.
|
|
341
|
+
const absDir = singleFile ? path_1.default.dirname(absPath) : absPath;
|
|
160
342
|
// A missing/unparseable manifest means nothing is tracked — everything is untracked,
|
|
161
343
|
// matching the existing (pre-drift-guard) bulk_create behavior byte-for-byte.
|
|
162
344
|
const manifest = (0, docs_manifest_1.readManifest)(absDir, { warnOnParseError: true });
|
|
163
|
-
const
|
|
164
|
-
//
|
|
345
|
+
const allFiles = singleFile ? [absPath] : walkDocFiles(absDir);
|
|
346
|
+
// Files the manifest marks `media: true` are owned by the media pass below, not
|
|
347
|
+
// the doc-body pass: skip them in the filename-based preflight (the 1 MiB body
|
|
348
|
+
// cap, the canvas JSON check, the duplicate-title check — a tracked media file
|
|
349
|
+
// creates no new doc title). Media keeps its own size handling (the server's
|
|
350
|
+
// media cap); real doc-body files keep all three checks.
|
|
351
|
+
const mediaRelPaths = new Set(Object.entries(manifest?.docs ?? {})
|
|
352
|
+
.filter(([, entry]) => entry.media)
|
|
353
|
+
.map(([relPath]) => relPath));
|
|
354
|
+
const docBodyFiles = allFiles.filter((file) => !mediaRelPaths.has(path_1.default.relative(absDir, file).split(path_1.default.sep).join('/')));
|
|
355
|
+
assertBodiesWithinCap(docBodyFiles, absDir);
|
|
356
|
+
assertCanvasFilesParse(docBodyFiles, absDir);
|
|
357
|
+
if (!singleFile) {
|
|
358
|
+
assertUniqueTitles(docBodyFiles, absDir);
|
|
359
|
+
}
|
|
360
|
+
const trackedMediaEntries = singleFile
|
|
361
|
+
? Object.entries(manifest?.docs ?? {}).filter(([relPath, e]) => e.media && relPath === path_1.default.relative(absDir, absPath).split(path_1.default.sep).join('/'))
|
|
362
|
+
: Object.entries(manifest?.docs ?? {}).filter(([, e]) => e.media);
|
|
363
|
+
// A pulled folder of images alone (no doc files) must still be pushable — the early
|
|
165
364
|
// exit only fires when there's truly nothing to push.
|
|
166
365
|
if (allFiles.length === 0 && trackedMediaEntries.length === 0) {
|
|
167
|
-
process.stderr.write(chalk_1.default.red(`error: no .md files or tracked media found under "${dir}" — nothing to push.\n`));
|
|
366
|
+
process.stderr.write(chalk_1.default.red(`error: no .md, .html, .canvas.json or .canvas files or tracked media found under "${dir}" — nothing to push.\n`));
|
|
168
367
|
process.exit(1);
|
|
169
368
|
}
|
|
170
369
|
// Partition into tracked (relative path present in the pull manifest) vs. untracked.
|
|
171
370
|
// A media doc titled *.md (e.g. `notes.md`) is bytes, not markdown — it's owned by
|
|
172
371
|
// the media pass below, not this markdown pass, or its bytes would be sent through
|
|
173
|
-
//
|
|
372
|
+
// docs_manage write as a text body and corrupt the doc.
|
|
174
373
|
const trackedFiles = [];
|
|
175
374
|
const untrackedFiles = [];
|
|
176
375
|
for (const f of allFiles) {
|
|
@@ -202,7 +401,7 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
202
401
|
trackedUnchanged.push({ file: relPath, id: entry.id });
|
|
203
402
|
continue;
|
|
204
403
|
}
|
|
205
|
-
// --dry-run must never live-write: preview the tracked doc instead of calling
|
|
404
|
+
// --dry-run must never live-write: preview the tracked doc instead of calling docs_manage write.
|
|
206
405
|
if (options.dryRun) {
|
|
207
406
|
trackedPlanned.push({ file: relPath, id: entry.id });
|
|
208
407
|
continue;
|
|
@@ -213,7 +412,7 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
213
412
|
}
|
|
214
413
|
let mcpResult;
|
|
215
414
|
try {
|
|
216
|
-
mcpResult = await (0, mcp_1.callDocsTool)(config,
|
|
415
|
+
mcpResult = await (0, mcp_1.callDocsTool)(config, editArgs);
|
|
217
416
|
}
|
|
218
417
|
catch (e) {
|
|
219
418
|
process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
|
|
@@ -299,7 +498,7 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
299
498
|
process.stderr.write(chalk_1.default.red(`error: ${relPath}: ${data?.message ?? error.message}\n`));
|
|
300
499
|
process.exit(1);
|
|
301
500
|
}
|
|
302
|
-
// The REST presenter names the revision `current_version_id`; MCP
|
|
501
|
+
// The REST presenter names the revision `current_version_id`; MCP docs_manage write
|
|
303
502
|
// names it `current_revision_id`. Reading the wrong one nulls the entry and
|
|
304
503
|
// silently disarms the drift guard on every later push.
|
|
305
504
|
entry.current_revision_id = doc?.current_version_id ?? entry.current_revision_id;
|
|
@@ -307,18 +506,15 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
307
506
|
trackedWritten.push({ file: relPath, id: entry.id, current_revision_id: entry.current_revision_id });
|
|
308
507
|
(0, docs_manifest_1.writeManifest)(absDir, manifest);
|
|
309
508
|
}
|
|
310
|
-
const untrackedMedia = walkUntrackedBinaries(absDir, manifest);
|
|
509
|
+
const untrackedMedia = singleFile ? [] : walkUntrackedBinaries(absDir, manifest);
|
|
311
510
|
const items = untrackedFiles.map((f) => fileToItem(f, absDir));
|
|
312
511
|
// Untracked docs (new files, or files re-orphaned by a deleted-remotely re-pull)
|
|
313
512
|
// must land back under the folder this directory was pulled into, not the docs
|
|
314
513
|
// root — an explicit --folder always overrides the manifest's recorded folder.
|
|
315
514
|
const effectiveFolder = options.folder ?? manifest?.folder_path;
|
|
316
515
|
const folderInferredFromManifest = !options.folder && !!manifest?.folder_path;
|
|
317
|
-
// Chunk into groups of CHUNK_SIZE
|
|
318
|
-
const chunks =
|
|
319
|
-
for (let i = 0; i < items.length; i += CHUNK_SIZE) {
|
|
320
|
-
chunks.push(items.slice(i, i + CHUNK_SIZE));
|
|
321
|
-
}
|
|
516
|
+
// Chunk into groups of CHUNK_SIZE items and about MAX_CHUNK_BYTES of bodies.
|
|
517
|
+
const chunks = chunkItems(items);
|
|
322
518
|
if (folderInferredFromManifest && items.length > 0 && !options.json) {
|
|
323
519
|
console.log(chalk_1.default.gray(`creating untracked docs under "${effectiveFolder}" (from ${docs_manifest_1.DOCS_MANIFEST})`));
|
|
324
520
|
}
|
|
@@ -329,11 +525,14 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
329
525
|
const callArgs = {
|
|
330
526
|
action: 'bulk_create',
|
|
331
527
|
on_conflict: onConflict,
|
|
332
|
-
items: chunk.map(({ title, body, relative_folder_path }) => {
|
|
528
|
+
items: chunk.map(({ title, body, relative_folder_path, type }) => {
|
|
333
529
|
const item = { title, body };
|
|
334
530
|
if (relative_folder_path !== undefined) {
|
|
335
531
|
item.relative_folder_path = relative_folder_path;
|
|
336
532
|
}
|
|
533
|
+
if (type !== undefined) {
|
|
534
|
+
item.type = type;
|
|
535
|
+
}
|
|
337
536
|
return item;
|
|
338
537
|
}),
|
|
339
538
|
};
|
|
@@ -351,7 +550,7 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
351
550
|
}
|
|
352
551
|
let mcpResult;
|
|
353
552
|
try {
|
|
354
|
-
mcpResult = await (0, mcp_1.callDocsTool)(config,
|
|
553
|
+
mcpResult = await (0, mcp_1.callDocsTool)(config, callArgs);
|
|
355
554
|
}
|
|
356
555
|
catch (e) {
|
|
357
556
|
process.stderr.write(chalk_1.default.red(`error: ${e.message}\n`));
|
|
@@ -444,6 +643,19 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
444
643
|
process.stderr.write(chalk_1.default.red(`${row.file}: ${row.error ?? row.code ?? 'unknown error'}\n`));
|
|
445
644
|
}
|
|
446
645
|
}
|
|
646
|
+
// Docs created by an untracked push are not in the manifest, so re-pushing an edited page
|
|
647
|
+
// skips it under the default --on-conflict skip. Say how to update it (cli#154; the
|
|
648
|
+
// pull-side mapping that would track it is cli#157).
|
|
649
|
+
for (const row of allResultRows) {
|
|
650
|
+
if (row.status !== 'skipped' || docFileKind(path_1.default.basename(row.file))?.type === undefined)
|
|
651
|
+
continue;
|
|
652
|
+
// row.file is relative to the pushed directory; suggest the path the user
|
|
653
|
+
// typed (cli#154 I4): the directory argument joined for a directory push,
|
|
654
|
+
// the file argument itself for a single-file push.
|
|
655
|
+
const suggested = singleFile ? dir : path_1.default.join(dir, row.file);
|
|
656
|
+
process.stderr.write(chalk_1.default.yellow(`${row.file}: skipped — a doc with this title already exists. To update it, push again with --on-conflict overwrite, `
|
|
657
|
+
+ `or run \`solidactions doc push ${quoteShellPath(suggested)} --replace ${row.id ?? '<doc-id>'}\`\n`));
|
|
658
|
+
}
|
|
447
659
|
if (pendingItems.length > 0) {
|
|
448
660
|
console.log(chalk_1.default.yellow(`\nProperties pending (${pendingItems.length} doc${pendingItems.length === 1 ? '' : 's'}):`));
|
|
449
661
|
for (const item of pendingItems) {
|
|
@@ -36,12 +36,12 @@ async function envList(projectName, options = {}) {
|
|
|
36
36
|
const projectSlug = environment === 'production'
|
|
37
37
|
? projectName
|
|
38
38
|
: `${projectName}-${environment}`;
|
|
39
|
-
if (!options.json) {
|
|
40
|
-
console.log(chalk_1.default.blue(`Variables for project "${projectName}" (${environment}):`));
|
|
41
|
-
}
|
|
42
39
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
|
|
43
40
|
headers: (0, api_1.getApiHeaders)(config),
|
|
44
41
|
});
|
|
42
|
+
if (!options.json) {
|
|
43
|
+
console.log(chalk_1.default.blue(`Variables for project "${projectName}" (${environment}):`));
|
|
44
|
+
}
|
|
45
45
|
const mappings = response.data || [];
|
|
46
46
|
if (options.json) {
|
|
47
47
|
console.log(JSON.stringify(mappings, null, 2));
|
|
@@ -109,12 +109,12 @@ async function envList(projectName, options = {}) {
|
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
// List global variables with per-environment values
|
|
112
|
-
if (!options.json) {
|
|
113
|
-
console.log(chalk_1.default.blue('Global variables:'));
|
|
114
|
-
}
|
|
115
112
|
const response = await axios_1.default.get(`${config.host}/api/v1/variables`, {
|
|
116
113
|
headers: (0, api_1.getApiHeaders)(config),
|
|
117
114
|
});
|
|
115
|
+
if (!options.json) {
|
|
116
|
+
console.log(chalk_1.default.blue('Global variables:'));
|
|
117
|
+
}
|
|
118
118
|
const variables = response.data?.data || [];
|
|
119
119
|
if (options.json) {
|
|
120
120
|
console.log(JSON.stringify(variables, null, 2));
|
|
@@ -207,7 +207,7 @@ async function envList(projectName, options = {}) {
|
|
|
207
207
|
catch (error) {
|
|
208
208
|
if (error.response) {
|
|
209
209
|
if (error.response.status === 401) {
|
|
210
|
-
console.error(chalk_1.default.red(
|
|
210
|
+
console.error(chalk_1.default.red(`Authentication failed against ${config.host}. Run "solidactions login --global" to re-configure.`));
|
|
211
211
|
}
|
|
212
212
|
else if (error.response.status === 404) {
|
|
213
213
|
if (projectName) {
|
|
@@ -219,7 +219,7 @@ async function envList(projectName, options = {}) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
else {
|
|
222
|
-
console.error(chalk_1.default.red(
|
|
222
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
else {
|
package/dist/commands/init.js
CHANGED
|
@@ -11,6 +11,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
11
11
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
12
12
|
const github_1 = require("../utils/github");
|
|
13
13
|
const examples_ref_1 = require("../utils/examples-ref");
|
|
14
|
+
const slug_1 = require("../utils/slug");
|
|
14
15
|
const ai_init_1 = require("./ai-init");
|
|
15
16
|
const EXAMPLES_OWNER = 'SolidActions';
|
|
16
17
|
const EXAMPLES_REPO = 'solidactions-examples';
|
|
@@ -40,7 +41,9 @@ async function init(directory, options = {}) {
|
|
|
40
41
|
const cwd = process.cwd();
|
|
41
42
|
const installSkills = options.skills !== false; // default true
|
|
42
43
|
const targetDir = directory ? path_1.default.resolve(cwd, directory) : cwd;
|
|
43
|
-
|
|
44
|
+
// The canonical slug, not the folder's spelling: a mixed-case name is an invalid npm
|
|
45
|
+
// package name and redeploys under a different slug than the server stores (cli#102).
|
|
46
|
+
const projectName = (0, slug_1.slugifyName)(path_1.default.basename(targetDir)) || 'solidactions-project';
|
|
44
47
|
if (directory) {
|
|
45
48
|
fs_extra_1.default.ensureDirSync(targetDir);
|
|
46
49
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
|
|
7
7
|
exports.resolveLoginApiKey = resolveLoginApiKey;
|
|
8
|
-
exports.getConfig = getConfig;
|
|
9
|
-
exports.saveConfig = saveConfig;
|
|
10
8
|
exports.clearConfig = clearConfig;
|
|
11
9
|
exports.resolveLoginHost = resolveLoginHost;
|
|
12
10
|
exports.backupPathFor = backupPathFor;
|
|
@@ -72,15 +70,6 @@ async function resolveLoginApiKey(apiKey, options = {}, dependencies = {}) {
|
|
|
72
70
|
}
|
|
73
71
|
return trimmed;
|
|
74
72
|
}
|
|
75
|
-
function getConfig() {
|
|
76
|
-
const resolved = (0, config_1.resolveConfig)();
|
|
77
|
-
return resolved ? resolved.config : null;
|
|
78
|
-
}
|
|
79
|
-
function saveConfig(config) {
|
|
80
|
-
const resolved = (0, config_1.resolveConfig)();
|
|
81
|
-
const targetPath = resolved ? resolved.activePath : (0, config_1.getGlobalConfigPath)();
|
|
82
|
-
(0, config_1.writeConfigFile)(targetPath, config);
|
|
83
|
-
}
|
|
84
73
|
function clearConfig() {
|
|
85
74
|
(0, config_1.removeConfigFile)((0, config_1.getGlobalConfigPath)());
|
|
86
75
|
}
|
|
@@ -437,6 +426,11 @@ function logout(options = {}) {
|
|
|
437
426
|
}
|
|
438
427
|
function whoami() {
|
|
439
428
|
const resolved = (0, config_1.resolveConfig)();
|
|
429
|
+
if (resolved?.credentialConflict) {
|
|
430
|
+
// stderr, like requireResolvedConfig (PM ruling 7).
|
|
431
|
+
console.error(chalk_1.default.red((0, config_1.credentialConflictMessage)(resolved.credentialConflict)));
|
|
432
|
+
process.exit(1);
|
|
433
|
+
}
|
|
440
434
|
if (!resolved || !resolved.config.apiKey) {
|
|
441
435
|
console.log(chalk_1.default.yellow('Not initialized.'));
|
|
442
436
|
console.log(chalk_1.default.gray('Run "solidactions login --global" to configure.'));
|
|
@@ -451,6 +445,8 @@ function whoami() {
|
|
|
451
445
|
return chalk_1.default.gray('(from $SOLIDACTIONS_* env var)');
|
|
452
446
|
if (src === 'cli')
|
|
453
447
|
return chalk_1.default.gray('(from -w flag)');
|
|
448
|
+
if (src === 'default')
|
|
449
|
+
return chalk_1.default.gray('(default)');
|
|
454
450
|
if (src === null)
|
|
455
451
|
return chalk_1.default.gray('(unset)');
|
|
456
452
|
return chalk_1.default.gray(`(from ${src})`);
|
|
@@ -13,6 +13,7 @@ exports.displayDetailedList = displayDetailedList;
|
|
|
13
13
|
const axios_1 = __importDefault(require("axios"));
|
|
14
14
|
const chalk_1 = __importDefault(require("chalk"));
|
|
15
15
|
const api_1 = require("../utils/api");
|
|
16
|
+
const run_status_1 = require("../utils/run-status");
|
|
16
17
|
const table_1 = require("../utils/table");
|
|
17
18
|
const source_provenance_1 = require("../utils/source-provenance");
|
|
18
19
|
var source_provenance_2 = require("../utils/source-provenance");
|
|
@@ -152,7 +153,7 @@ function displaySummaryTable(runsList, projectName) {
|
|
|
152
153
|
const run = runsList[i];
|
|
153
154
|
const [id, workflow, status, revision, triggeredAt, triggeredBy] = rows[i];
|
|
154
155
|
const { attention } = summaryStatusLabel(run);
|
|
155
|
-
const statusColor = attention ? chalk_1.default.yellow : getStatusColor(status);
|
|
156
|
+
const statusColor = attention ? chalk_1.default.yellow : (0, run_status_1.getStatusColor)(status);
|
|
156
157
|
console.log(chalk_1.default.gray(id.padEnd(widths[0])) +
|
|
157
158
|
workflow.padEnd(widths[1]) +
|
|
158
159
|
statusColor(status.padEnd(widths[2])) +
|
|
@@ -169,7 +170,7 @@ function displayDetailedList(runsList, projectName) {
|
|
|
169
170
|
console.log(chalk_1.default.blue(header));
|
|
170
171
|
for (const run of runsList) {
|
|
171
172
|
const status = run.execution_status || run.status || '?';
|
|
172
|
-
const statusColor = getStatusColor(status);
|
|
173
|
+
const statusColor = (0, run_status_1.getStatusColor)(status);
|
|
173
174
|
const exitStr = run.exit_code !== null && run.exit_code !== undefined ? ` (exit ${run.exit_code})` : '';
|
|
174
175
|
console.log('');
|
|
175
176
|
const outcomeTag = detailedOutcomeTag(run);
|
|
@@ -350,20 +351,3 @@ function truncate(str, max) {
|
|
|
350
351
|
return str;
|
|
351
352
|
return str.substring(0, max - 3) + '...';
|
|
352
353
|
}
|
|
353
|
-
function getStatusColor(status) {
|
|
354
|
-
switch (status?.toLowerCase()) {
|
|
355
|
-
case 'completed':
|
|
356
|
-
case 'success':
|
|
357
|
-
return chalk_1.default.green;
|
|
358
|
-
case 'running':
|
|
359
|
-
return chalk_1.default.blue;
|
|
360
|
-
case 'pending':
|
|
361
|
-
case 'queued':
|
|
362
|
-
return chalk_1.default.yellow;
|
|
363
|
-
case 'failed':
|
|
364
|
-
case 'error':
|
|
365
|
-
return chalk_1.default.red;
|
|
366
|
-
default:
|
|
367
|
-
return chalk_1.default.gray;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
@@ -7,6 +7,7 @@ exports.run = run;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const api_1 = require("../utils/api");
|
|
10
|
+
const run_status_1 = require("../utils/run-status");
|
|
10
11
|
async function run(projectName, workflowName, options) {
|
|
11
12
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
12
13
|
const environment = options.env || 'dev';
|
|
@@ -40,16 +41,16 @@ async function run(projectName, workflowName, options) {
|
|
|
40
41
|
const statusResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runData.id}`, {
|
|
41
42
|
headers: (0, api_1.getApiHeaders)(config),
|
|
42
43
|
});
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
44
|
+
const outcome = (0, run_status_1.describeTerminalRun)(statusResponse.data ?? {});
|
|
45
|
+
if (outcome) {
|
|
45
46
|
clearInterval(poll);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
process.exit(
|
|
47
|
+
if (outcome.exitCode === 0) {
|
|
48
|
+
console.log(chalk_1.default.green(`\n${outcome.message}`));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.error(chalk_1.default.red(`\n${outcome.message}`));
|
|
52
|
+
}
|
|
53
|
+
process.exit(outcome.exitCode);
|
|
53
54
|
}
|
|
54
55
|
else if (attempts >= maxAttempts) {
|
|
55
56
|
clearInterval(poll);
|