@dosu/cli 0.14.1 → 0.14.2
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/bin/dosu.js +163 -88
- package/package.json +1 -1
package/bin/dosu.js
CHANGED
|
@@ -4341,7 +4341,7 @@ function getSupabaseAnonKey() {
|
|
|
4341
4341
|
function getVersionString() {
|
|
4342
4342
|
return `v${VERSION}`;
|
|
4343
4343
|
}
|
|
4344
|
-
var VERSION = "0.14.
|
|
4344
|
+
var VERSION = "0.14.2";
|
|
4345
4345
|
|
|
4346
4346
|
// src/debug/logger.ts
|
|
4347
4347
|
import {
|
|
@@ -5165,17 +5165,17 @@ import y2 from "node:process";
|
|
|
5165
5165
|
function ce() {
|
|
5166
5166
|
return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
5167
5167
|
}
|
|
5168
|
-
var
|
|
5168
|
+
var import_picocolors7, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2, W2, C2, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2 = (t) => {
|
|
5169
5169
|
switch (t) {
|
|
5170
5170
|
case "initial":
|
|
5171
5171
|
case "active":
|
|
5172
|
-
return
|
|
5172
|
+
return import_picocolors7.default.cyan(le);
|
|
5173
5173
|
case "cancel":
|
|
5174
|
-
return
|
|
5174
|
+
return import_picocolors7.default.red(L2);
|
|
5175
5175
|
case "error":
|
|
5176
|
-
return
|
|
5176
|
+
return import_picocolors7.default.yellow(W2);
|
|
5177
5177
|
case "submit":
|
|
5178
|
-
return
|
|
5178
|
+
return import_picocolors7.default.green(C2);
|
|
5179
5179
|
}
|
|
5180
5180
|
}, G2 = (t) => {
|
|
5181
5181
|
const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
|
|
@@ -5184,23 +5184,23 @@ var import_picocolors8, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2
|
|
|
5184
5184
|
const $2 = a < r.length && l2 > 0, g2 = a < r.length && l2 + a < r.length;
|
|
5185
5185
|
return r.slice(l2, l2 + a).map((p2, v, f) => {
|
|
5186
5186
|
const j2 = v === 0 && $2, E = v === f.length - 1 && g2;
|
|
5187
|
-
return j2 || E ?
|
|
5187
|
+
return j2 || E ? import_picocolors7.default.dim("...") : i(p2, v + l2 === n);
|
|
5188
5188
|
});
|
|
5189
5189
|
}, ye = (t) => {
|
|
5190
5190
|
const n = t.active ?? "Yes", r = t.inactive ?? "No";
|
|
5191
5191
|
return new dD({ active: n, inactive: r, initialValue: t.initialValue ?? true, render() {
|
|
5192
|
-
const i = `${
|
|
5192
|
+
const i = `${import_picocolors7.default.gray(o)}
|
|
5193
5193
|
${b2(this.state)} ${t.message}
|
|
5194
5194
|
`, s = this.value ? n : r;
|
|
5195
5195
|
switch (this.state) {
|
|
5196
5196
|
case "submit":
|
|
5197
|
-
return `${i}${
|
|
5197
|
+
return `${i}${import_picocolors7.default.gray(o)} ${import_picocolors7.default.dim(s)}`;
|
|
5198
5198
|
case "cancel":
|
|
5199
|
-
return `${i}${
|
|
5200
|
-
${
|
|
5199
|
+
return `${i}${import_picocolors7.default.gray(o)} ${import_picocolors7.default.strikethrough(import_picocolors7.default.dim(s))}
|
|
5200
|
+
${import_picocolors7.default.gray(o)}`;
|
|
5201
5201
|
default:
|
|
5202
|
-
return `${i}${
|
|
5203
|
-
${
|
|
5202
|
+
return `${i}${import_picocolors7.default.cyan(o)} ${this.value ? `${import_picocolors7.default.green(k2)} ${n}` : `${import_picocolors7.default.dim(P2)} ${import_picocolors7.default.dim(n)}`} ${import_picocolors7.default.dim("/")} ${this.value ? `${import_picocolors7.default.dim(P2)} ${import_picocolors7.default.dim(r)}` : `${import_picocolors7.default.green(k2)} ${r}`}
|
|
5203
|
+
${import_picocolors7.default.cyan(d2)}
|
|
5204
5204
|
`;
|
|
5205
5205
|
}
|
|
5206
5206
|
} }).prompt();
|
|
@@ -5209,43 +5209,43 @@ ${import_picocolors8.default.cyan(d2)}
|
|
|
5209
5209
|
const s = r.label ?? String(r.value);
|
|
5210
5210
|
switch (i) {
|
|
5211
5211
|
case "selected":
|
|
5212
|
-
return `${
|
|
5212
|
+
return `${import_picocolors7.default.dim(s)}`;
|
|
5213
5213
|
case "active":
|
|
5214
|
-
return `${
|
|
5214
|
+
return `${import_picocolors7.default.green(k2)} ${s} ${r.hint ? import_picocolors7.default.dim(`(${r.hint})`) : ""}`;
|
|
5215
5215
|
case "cancelled":
|
|
5216
|
-
return `${
|
|
5216
|
+
return `${import_picocolors7.default.strikethrough(import_picocolors7.default.dim(s))}`;
|
|
5217
5217
|
default:
|
|
5218
|
-
return `${
|
|
5218
|
+
return `${import_picocolors7.default.dim(P2)} ${import_picocolors7.default.dim(s)}`;
|
|
5219
5219
|
}
|
|
5220
5220
|
};
|
|
5221
5221
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
5222
|
-
const r = `${
|
|
5222
|
+
const r = `${import_picocolors7.default.gray(o)}
|
|
5223
5223
|
${b2(this.state)} ${t.message}
|
|
5224
5224
|
`;
|
|
5225
5225
|
switch (this.state) {
|
|
5226
5226
|
case "submit":
|
|
5227
|
-
return `${r}${
|
|
5227
|
+
return `${r}${import_picocolors7.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
5228
5228
|
case "cancel":
|
|
5229
|
-
return `${r}${
|
|
5230
|
-
${
|
|
5229
|
+
return `${r}${import_picocolors7.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
5230
|
+
${import_picocolors7.default.gray(o)}`;
|
|
5231
5231
|
default:
|
|
5232
|
-
return `${r}${
|
|
5233
|
-
${
|
|
5234
|
-
${
|
|
5232
|
+
return `${r}${import_picocolors7.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
5233
|
+
${import_picocolors7.default.cyan(o)} `)}
|
|
5234
|
+
${import_picocolors7.default.cyan(d2)}
|
|
5235
5235
|
`;
|
|
5236
5236
|
}
|
|
5237
5237
|
} }).prompt();
|
|
5238
5238
|
}, fe = (t) => {
|
|
5239
5239
|
const n = (r, i) => {
|
|
5240
5240
|
const s = r.label ?? String(r.value);
|
|
5241
|
-
return i === "active" ? `${
|
|
5241
|
+
return i === "active" ? `${import_picocolors7.default.cyan(A2)} ${s} ${r.hint ? import_picocolors7.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors7.default.green(T)} ${import_picocolors7.default.dim(s)} ${r.hint ? import_picocolors7.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors7.default.strikethrough(import_picocolors7.default.dim(s))}` : i === "active-selected" ? `${import_picocolors7.default.green(T)} ${s} ${r.hint ? import_picocolors7.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors7.default.dim(s)}` : `${import_picocolors7.default.dim(F)} ${import_picocolors7.default.dim(s)}`;
|
|
5242
5242
|
};
|
|
5243
5243
|
return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r) {
|
|
5244
5244
|
if (this.required && r.length === 0)
|
|
5245
5245
|
return `Please select at least one option.
|
|
5246
|
-
${
|
|
5246
|
+
${import_picocolors7.default.reset(import_picocolors7.default.dim(`Press ${import_picocolors7.default.gray(import_picocolors7.default.bgWhite(import_picocolors7.default.inverse(" space ")))} to select, ${import_picocolors7.default.gray(import_picocolors7.default.bgWhite(import_picocolors7.default.inverse(" enter ")))} to submit`))}`;
|
|
5247
5247
|
}, render() {
|
|
5248
|
-
const r = `${
|
|
5248
|
+
const r = `${import_picocolors7.default.gray(o)}
|
|
5249
5249
|
${b2(this.state)} ${t.message}
|
|
5250
5250
|
`, i = (s, c) => {
|
|
5251
5251
|
const a = this.value.includes(s.value);
|
|
@@ -5253,34 +5253,34 @@ ${b2(this.state)} ${t.message}
|
|
|
5253
5253
|
};
|
|
5254
5254
|
switch (this.state) {
|
|
5255
5255
|
case "submit":
|
|
5256
|
-
return `${r}${
|
|
5256
|
+
return `${r}${import_picocolors7.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors7.default.dim(", ")) || import_picocolors7.default.dim("none")}`;
|
|
5257
5257
|
case "cancel": {
|
|
5258
|
-
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(
|
|
5259
|
-
return `${r}${
|
|
5260
|
-
${
|
|
5258
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors7.default.dim(", "));
|
|
5259
|
+
return `${r}${import_picocolors7.default.gray(o)} ${s.trim() ? `${s}
|
|
5260
|
+
${import_picocolors7.default.gray(o)}` : ""}`;
|
|
5261
5261
|
}
|
|
5262
5262
|
case "error": {
|
|
5263
5263
|
const s = this.error.split(`
|
|
5264
|
-
`).map((c, a) => a === 0 ? `${
|
|
5264
|
+
`).map((c, a) => a === 0 ? `${import_picocolors7.default.yellow(d2)} ${import_picocolors7.default.yellow(c)}` : ` ${c}`).join(`
|
|
5265
5265
|
`);
|
|
5266
|
-
return `${r +
|
|
5267
|
-
${
|
|
5266
|
+
return `${r + import_picocolors7.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
5267
|
+
${import_picocolors7.default.yellow(o)} `)}
|
|
5268
5268
|
${s}
|
|
5269
5269
|
`;
|
|
5270
5270
|
}
|
|
5271
5271
|
default:
|
|
5272
|
-
return `${r}${
|
|
5273
|
-
${
|
|
5274
|
-
${
|
|
5272
|
+
return `${r}${import_picocolors7.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
5273
|
+
${import_picocolors7.default.cyan(o)} `)}
|
|
5274
|
+
${import_picocolors7.default.cyan(d2)}
|
|
5275
5275
|
`;
|
|
5276
5276
|
}
|
|
5277
5277
|
} }).prompt();
|
|
5278
5278
|
}, Ie = (t = "") => {
|
|
5279
|
-
process.stdout.write(`${
|
|
5279
|
+
process.stdout.write(`${import_picocolors7.default.gray(ue)} ${t}
|
|
5280
5280
|
`);
|
|
5281
5281
|
}, Se = (t = "") => {
|
|
5282
|
-
process.stdout.write(`${
|
|
5283
|
-
${
|
|
5282
|
+
process.stdout.write(`${import_picocolors7.default.gray(o)}
|
|
5283
|
+
${import_picocolors7.default.gray(d2)} ${t}
|
|
5284
5284
|
|
|
5285
5285
|
`);
|
|
5286
5286
|
}, M2, J2, Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
@@ -5305,14 +5305,14 @@ ${import_picocolors8.default.gray(d2)} ${t}
|
|
|
5305
5305
|
const h2 = (performance.now() - m2) / 1000, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
5306
5306
|
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
5307
5307
|
}, H2 = (m2 = "") => {
|
|
5308
|
-
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${
|
|
5308
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors7.default.gray(o)}
|
|
5309
5309
|
`);
|
|
5310
5310
|
let h2 = 0, w2 = 0;
|
|
5311
5311
|
j2(), c = setInterval(() => {
|
|
5312
5312
|
if (i && l2 === $2)
|
|
5313
5313
|
return;
|
|
5314
5314
|
B2(), $2 = l2;
|
|
5315
|
-
const I2 =
|
|
5315
|
+
const I2 = import_picocolors7.default.magenta(n[h2]);
|
|
5316
5316
|
if (i)
|
|
5317
5317
|
process.stdout.write(`${I2} ${l2}...`);
|
|
5318
5318
|
else if (t === "timer")
|
|
@@ -5325,7 +5325,7 @@ ${import_picocolors8.default.gray(d2)} ${t}
|
|
|
5325
5325
|
}, r);
|
|
5326
5326
|
}, N2 = (m2 = "", h2 = 0) => {
|
|
5327
5327
|
a = false, clearInterval(c), B2();
|
|
5328
|
-
const w2 = h2 === 0 ?
|
|
5328
|
+
const w2 = h2 === 0 ? import_picocolors7.default.green(C2) : h2 === 1 ? import_picocolors7.default.red(L2) : import_picocolors7.default.red(W2);
|
|
5329
5329
|
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
5330
5330
|
`) : process.stdout.write(`${w2} ${l2}
|
|
5331
5331
|
`), E(), s();
|
|
@@ -5337,7 +5337,7 @@ ${import_picocolors8.default.gray(d2)} ${t}
|
|
|
5337
5337
|
var init_dist6 = __esm(() => {
|
|
5338
5338
|
init_dist5();
|
|
5339
5339
|
init_dist5();
|
|
5340
|
-
|
|
5340
|
+
import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
5341
5341
|
import_sisteransi2 = __toESM(require_src(), 1);
|
|
5342
5342
|
V2 = ce();
|
|
5343
5343
|
le = u("◆", "*");
|
|
@@ -5361,30 +5361,30 @@ var init_dist6 = __esm(() => {
|
|
|
5361
5361
|
D = u("◆", "*");
|
|
5362
5362
|
U = u("▲", "!");
|
|
5363
5363
|
K2 = u("■", "x");
|
|
5364
|
-
M2 = { message: (t = "", { symbol: n =
|
|
5365
|
-
const r = [`${
|
|
5364
|
+
M2 = { message: (t = "", { symbol: n = import_picocolors7.default.gray(o) } = {}) => {
|
|
5365
|
+
const r = [`${import_picocolors7.default.gray(o)}`];
|
|
5366
5366
|
if (t) {
|
|
5367
5367
|
const [i, ...s] = t.split(`
|
|
5368
5368
|
`);
|
|
5369
|
-
r.push(`${n} ${i}`, ...s.map((c) => `${
|
|
5369
|
+
r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors7.default.gray(o)} ${c}`));
|
|
5370
5370
|
}
|
|
5371
5371
|
process.stdout.write(`${r.join(`
|
|
5372
5372
|
`)}
|
|
5373
5373
|
`);
|
|
5374
5374
|
}, info: (t) => {
|
|
5375
|
-
M2.message(t, { symbol:
|
|
5375
|
+
M2.message(t, { symbol: import_picocolors7.default.blue(q) });
|
|
5376
5376
|
}, success: (t) => {
|
|
5377
|
-
M2.message(t, { symbol:
|
|
5377
|
+
M2.message(t, { symbol: import_picocolors7.default.green(D) });
|
|
5378
5378
|
}, step: (t) => {
|
|
5379
|
-
M2.message(t, { symbol:
|
|
5379
|
+
M2.message(t, { symbol: import_picocolors7.default.green(C2) });
|
|
5380
5380
|
}, warn: (t) => {
|
|
5381
|
-
M2.message(t, { symbol:
|
|
5381
|
+
M2.message(t, { symbol: import_picocolors7.default.yellow(U) });
|
|
5382
5382
|
}, warning: (t) => {
|
|
5383
5383
|
M2.warn(t);
|
|
5384
5384
|
}, error: (t) => {
|
|
5385
|
-
M2.message(t, { symbol:
|
|
5385
|
+
M2.message(t, { symbol: import_picocolors7.default.red(K2) });
|
|
5386
5386
|
} };
|
|
5387
|
-
J2 = `${
|
|
5387
|
+
J2 = `${import_picocolors7.default.gray(o)} `;
|
|
5388
5388
|
});
|
|
5389
5389
|
|
|
5390
5390
|
// src/insights/insights.ts
|
|
@@ -11266,15 +11266,17 @@ ${import_picocolors6.default.dim(`Current: ${cfg.deployment_name ?? cfg.deployme
|
|
|
11266
11266
|
}
|
|
11267
11267
|
|
|
11268
11268
|
// src/commands/docs.ts
|
|
11269
|
+
init_dist6();
|
|
11270
|
+
init_dist();
|
|
11269
11271
|
init_esm();
|
|
11270
11272
|
init_trpc();
|
|
11271
11273
|
init_logger();
|
|
11272
|
-
var
|
|
11274
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
11273
11275
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
11274
11276
|
function requireConfig4() {
|
|
11275
11277
|
const cfg = requireLoginConfig();
|
|
11276
11278
|
if (!cfg.space_id) {
|
|
11277
|
-
console.error(
|
|
11279
|
+
console.error(import_picocolors8.default.red("Missing space config. Run 'dosu setup' to reconfigure."));
|
|
11278
11280
|
process.exit(1);
|
|
11279
11281
|
}
|
|
11280
11282
|
return cfg;
|
|
@@ -11284,7 +11286,7 @@ async function getKnowledgeStoreId(client, spaceId) {
|
|
|
11284
11286
|
space_id: spaceId
|
|
11285
11287
|
});
|
|
11286
11288
|
if (!store) {
|
|
11287
|
-
console.error(
|
|
11289
|
+
console.error(import_picocolors8.default.red("No knowledge store found for this deployment."));
|
|
11288
11290
|
process.exit(1);
|
|
11289
11291
|
}
|
|
11290
11292
|
return store.id;
|
|
@@ -11294,10 +11296,65 @@ function readBody(opts) {
|
|
|
11294
11296
|
return readFileSync3(opts.bodyFile, "utf-8");
|
|
11295
11297
|
return opts.body;
|
|
11296
11298
|
}
|
|
11299
|
+
var IMPORT_ALREADY_IN_PROGRESS_CODE = "IMPORT_ALREADY_IN_PROGRESS";
|
|
11300
|
+
var IMPORT_ALREADY_IN_PROGRESS_LEGACY_DETAIL_PHRASE = "import operation is already in progress";
|
|
11301
|
+
function parseSerializedImportError(message) {
|
|
11302
|
+
let text = message;
|
|
11303
|
+
let appCode;
|
|
11304
|
+
try {
|
|
11305
|
+
const parsed = JSON.parse(message);
|
|
11306
|
+
let codeCandidate;
|
|
11307
|
+
if (typeof parsed?.detail === "string") {
|
|
11308
|
+
text = parsed.detail;
|
|
11309
|
+
codeCandidate = parsed.code ?? parsed.dosuCode;
|
|
11310
|
+
} else if (parsed?.detail !== null && typeof parsed.detail === "object") {
|
|
11311
|
+
const inner = parsed.detail;
|
|
11312
|
+
if (typeof inner.detail === "string") {
|
|
11313
|
+
text = inner.detail;
|
|
11314
|
+
} else if (typeof inner.message === "string") {
|
|
11315
|
+
text = inner.message;
|
|
11316
|
+
}
|
|
11317
|
+
codeCandidate = inner.code ?? inner.dosuCode ?? parsed.code ?? parsed.dosuCode;
|
|
11318
|
+
} else {
|
|
11319
|
+
codeCandidate = parsed.code ?? parsed.dosuCode;
|
|
11320
|
+
}
|
|
11321
|
+
if (typeof codeCandidate === "string" && codeCandidate === IMPORT_ALREADY_IN_PROGRESS_CODE) {
|
|
11322
|
+
appCode = IMPORT_ALREADY_IN_PROGRESS_CODE;
|
|
11323
|
+
}
|
|
11324
|
+
} catch {}
|
|
11325
|
+
return {
|
|
11326
|
+
detail: text || "Import failed. Please try again.",
|
|
11327
|
+
appCode
|
|
11328
|
+
};
|
|
11329
|
+
}
|
|
11330
|
+
function trpcImportConflictAppCode(err) {
|
|
11331
|
+
if (!isTRPCClientError(err))
|
|
11332
|
+
return;
|
|
11333
|
+
const { data } = err;
|
|
11334
|
+
if (data === null || typeof data !== "object")
|
|
11335
|
+
return;
|
|
11336
|
+
const d3 = data;
|
|
11337
|
+
let candidate = d3.code;
|
|
11338
|
+
if (typeof candidate !== "string")
|
|
11339
|
+
candidate = d3.dosuCode;
|
|
11340
|
+
if (typeof candidate !== "string")
|
|
11341
|
+
return;
|
|
11342
|
+
return candidate === IMPORT_ALREADY_IN_PROGRESS_CODE ? IMPORT_ALREADY_IN_PROGRESS_CODE : undefined;
|
|
11343
|
+
}
|
|
11344
|
+
function isConcurrentImportError(err, msg) {
|
|
11345
|
+
if (trpcImportConflictAppCode(err) === IMPORT_ALREADY_IN_PROGRESS_CODE) {
|
|
11346
|
+
return true;
|
|
11347
|
+
}
|
|
11348
|
+
const { detail, appCode } = parseSerializedImportError(msg);
|
|
11349
|
+
if (appCode === IMPORT_ALREADY_IN_PROGRESS_CODE) {
|
|
11350
|
+
return true;
|
|
11351
|
+
}
|
|
11352
|
+
return detail.includes(IMPORT_ALREADY_IN_PROGRESS_LEGACY_DETAIL_PHRASE);
|
|
11353
|
+
}
|
|
11297
11354
|
async function backendPost(path, apiKey, body) {
|
|
11298
11355
|
const backendURL = getBackendURL();
|
|
11299
11356
|
if (!backendURL) {
|
|
11300
|
-
console.error(
|
|
11357
|
+
console.error(import_picocolors8.default.red("Backend URL not configured."));
|
|
11301
11358
|
process.exit(1);
|
|
11302
11359
|
}
|
|
11303
11360
|
const resp = await fetch(`${backendURL}${path}`, {
|
|
@@ -11333,14 +11390,14 @@ function docsCommand() {
|
|
|
11333
11390
|
return;
|
|
11334
11391
|
}
|
|
11335
11392
|
if (!pages || pages.length === 0) {
|
|
11336
|
-
console.log(
|
|
11393
|
+
console.log(import_picocolors8.default.dim("No documents found."));
|
|
11337
11394
|
return;
|
|
11338
11395
|
}
|
|
11339
|
-
printTable(["ID", "Title", "Status", "Created"], pages.map((
|
|
11340
|
-
|
|
11341
|
-
truncate(
|
|
11342
|
-
|
|
11343
|
-
formatDate(
|
|
11396
|
+
printTable(["ID", "Title", "Status", "Created"], pages.map((p2) => [
|
|
11397
|
+
p2.id.slice(0, 8),
|
|
11398
|
+
truncate(p2.title ?? "(untitled)", 50),
|
|
11399
|
+
p2.published ? "published" : "draft",
|
|
11400
|
+
formatDate(p2.created_at)
|
|
11344
11401
|
]), { rawData: pages });
|
|
11345
11402
|
});
|
|
11346
11403
|
cmd.command("get").description("Get a document").argument("<id>", "Page ID").option("--version <v>", "Specific version number").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
@@ -11355,10 +11412,10 @@ function docsCommand() {
|
|
|
11355
11412
|
return;
|
|
11356
11413
|
}
|
|
11357
11414
|
if (!page) {
|
|
11358
|
-
console.log(
|
|
11415
|
+
console.log(import_picocolors8.default.dim("Document not found."));
|
|
11359
11416
|
return;
|
|
11360
11417
|
}
|
|
11361
|
-
console.log(
|
|
11418
|
+
console.log(import_picocolors8.default.bold(page.title ?? "(untitled)"));
|
|
11362
11419
|
printInfo([
|
|
11363
11420
|
["ID", page.id],
|
|
11364
11421
|
["Status", page.published ? "published" : "draft"],
|
|
@@ -11383,7 +11440,7 @@ ${page.body}`);
|
|
|
11383
11440
|
printResult(result, opts);
|
|
11384
11441
|
return;
|
|
11385
11442
|
}
|
|
11386
|
-
console.log(
|
|
11443
|
+
console.log(import_picocolors8.default.green(`Document "${opts.title}" created.`));
|
|
11387
11444
|
});
|
|
11388
11445
|
cmd.command("update").description("Update a document").argument("<id>", "Page ID").option("--title <title>", "New title").option("--body <markdown>", "New body (markdown)").option("--body-file <path>", "Read body from file").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
11389
11446
|
const cfg = requireConfig4();
|
|
@@ -11400,7 +11457,7 @@ ${page.body}`);
|
|
|
11400
11457
|
printResult(result, opts);
|
|
11401
11458
|
return;
|
|
11402
11459
|
}
|
|
11403
|
-
console.log(
|
|
11460
|
+
console.log(import_picocolors8.default.green("Document updated."));
|
|
11404
11461
|
});
|
|
11405
11462
|
for (const archived of [true, false]) {
|
|
11406
11463
|
const name = archived ? "archive" : "unarchive";
|
|
@@ -11412,7 +11469,7 @@ ${page.body}`);
|
|
|
11412
11469
|
printResult({ success: true, id, archived }, opts);
|
|
11413
11470
|
return;
|
|
11414
11471
|
}
|
|
11415
|
-
console.log(
|
|
11472
|
+
console.log(import_picocolors8.default.green(`Document ${name}d.`));
|
|
11416
11473
|
});
|
|
11417
11474
|
}
|
|
11418
11475
|
cmd.command("delete").description("Delete a document").argument("<id>", "Page ID").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
@@ -11423,7 +11480,7 @@ ${page.body}`);
|
|
|
11423
11480
|
printResult({ success: true, id }, opts);
|
|
11424
11481
|
return;
|
|
11425
11482
|
}
|
|
11426
|
-
console.log(
|
|
11483
|
+
console.log(import_picocolors8.default.green("Document deleted."));
|
|
11427
11484
|
});
|
|
11428
11485
|
cmd.command("versions").description("List document versions").argument("<id>", "Page ID").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
11429
11486
|
const cfg = requireConfig4();
|
|
@@ -11434,7 +11491,7 @@ ${page.body}`);
|
|
|
11434
11491
|
return;
|
|
11435
11492
|
}
|
|
11436
11493
|
if (!versions || versions.length === 0) {
|
|
11437
|
-
console.log(
|
|
11494
|
+
console.log(import_picocolors8.default.dim("No versions found."));
|
|
11438
11495
|
return;
|
|
11439
11496
|
}
|
|
11440
11497
|
printTable(["Version", "Created"], versions.map((v) => [
|
|
@@ -11453,7 +11510,7 @@ ${page.body}`);
|
|
|
11453
11510
|
printResult({ success: true, id, version: opts.version }, opts);
|
|
11454
11511
|
return;
|
|
11455
11512
|
}
|
|
11456
|
-
console.log(
|
|
11513
|
+
console.log(import_picocolors8.default.green(`Document restored to version ${opts.version}.`));
|
|
11457
11514
|
});
|
|
11458
11515
|
cmd.command("generate").description("Generate a document using AI").requiredOption("--title <title>", "Document title").option("--instructions <text>", "Custom generation instructions").option("--json", "Output as JSON").action(async (opts) => {
|
|
11459
11516
|
const cfg = requireConfig4();
|
|
@@ -11468,7 +11525,7 @@ ${page.body}`);
|
|
|
11468
11525
|
printResult(result, opts);
|
|
11469
11526
|
return;
|
|
11470
11527
|
}
|
|
11471
|
-
console.log(
|
|
11528
|
+
console.log(import_picocolors8.default.green("Document generation started."));
|
|
11472
11529
|
});
|
|
11473
11530
|
cmd.command("auto-tag").description("Auto-tag a document using AI").argument("<id>", "Page ID").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
11474
11531
|
const cfg = requireConfig4();
|
|
@@ -11477,7 +11534,7 @@ ${page.body}`);
|
|
|
11477
11534
|
printResult(result, opts);
|
|
11478
11535
|
return;
|
|
11479
11536
|
}
|
|
11480
|
-
console.log(
|
|
11537
|
+
console.log(import_picocolors8.default.green("Auto-tagging started."));
|
|
11481
11538
|
});
|
|
11482
11539
|
cmd.command("import").description("Import documents from an external platform").argument("<platform>", "Platform: github, gitlab, confluence, notion, coda").requiredOption("--files <ids>", "Comma-separated file/page IDs to import").option("--json", "Output as JSON").action(async (platform, opts) => {
|
|
11483
11540
|
const cfg = requireConfig4();
|
|
@@ -11493,20 +11550,38 @@ ${page.body}`);
|
|
|
11493
11550
|
};
|
|
11494
11551
|
const fn = importFn[platform.toLowerCase()];
|
|
11495
11552
|
if (!fn) {
|
|
11496
|
-
console.error(
|
|
11553
|
+
console.error(import_picocolors8.default.red(`Unknown platform: ${platform}. Use: github, gitlab, confluence, notion, coda`));
|
|
11497
11554
|
process.exit(1);
|
|
11498
11555
|
}
|
|
11499
11556
|
const idField = ["confluence", "notion", "coda"].includes(platform.toLowerCase()) ? "page_ids" : "file_ids";
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11557
|
+
try {
|
|
11558
|
+
const result = await fn({
|
|
11559
|
+
knowledge_store_id: ksId,
|
|
11560
|
+
space_id: cfg.space_id,
|
|
11561
|
+
[idField]: fileIds
|
|
11562
|
+
});
|
|
11563
|
+
if (opts.json) {
|
|
11564
|
+
printResult(result, opts);
|
|
11565
|
+
return;
|
|
11566
|
+
}
|
|
11567
|
+
console.log(import_picocolors8.default.green(`Import started.${result.task_id ? ` Task ID: ${result.task_id}` : ""}`));
|
|
11568
|
+
} catch (err) {
|
|
11569
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
11570
|
+
logger.warn("docs-import", `Import failed: ${msg}`);
|
|
11571
|
+
const { detail } = parseSerializedImportError(msg);
|
|
11572
|
+
const isConcurrentImport = isConcurrentImportError(err, msg);
|
|
11573
|
+
if (opts.json) {
|
|
11574
|
+
const error = isConcurrentImport ? "An import is already in progress for this organization. Wait for it to complete or check status with: dosu docs import-status <task-id>" : detail;
|
|
11575
|
+
console.error(JSON.stringify({ error }));
|
|
11576
|
+
} else if (isConcurrentImport) {
|
|
11577
|
+
M2.error("An import is already in progress for this organization.");
|
|
11578
|
+
M2.info(`Check status with: ${import_picocolors8.default.cyan("dosu docs import-status <task-id>")}`);
|
|
11579
|
+
M2.info("Only one import can run per organization at a time.");
|
|
11580
|
+
} else {
|
|
11581
|
+
M2.error(detail);
|
|
11582
|
+
}
|
|
11583
|
+
process.exit(1);
|
|
11508
11584
|
}
|
|
11509
|
-
console.log(import_picocolors7.default.green(`Import started.${result.task_id ? ` Task ID: ${result.task_id}` : ""}`));
|
|
11510
11585
|
});
|
|
11511
11586
|
cmd.command("import-status").description("Check import task status").argument("<task-id>", "Import task ID").option("--json", "Output as JSON").action(async (taskId, opts) => {
|
|
11512
11587
|
const cfg = requireConfig4();
|
|
@@ -11517,7 +11592,7 @@ ${page.body}`);
|
|
|
11517
11592
|
return;
|
|
11518
11593
|
}
|
|
11519
11594
|
if (!status) {
|
|
11520
|
-
console.log(
|
|
11595
|
+
console.log(import_picocolors8.default.dim("Import task not found."));
|
|
11521
11596
|
return;
|
|
11522
11597
|
}
|
|
11523
11598
|
console.log(`Status: ${JSON.stringify(status)}`);
|
|
@@ -11566,7 +11641,7 @@ ${page.body}`);
|
|
|
11566
11641
|
};
|
|
11567
11642
|
const config = publishMap[platform];
|
|
11568
11643
|
if (!config) {
|
|
11569
|
-
console.error(
|
|
11644
|
+
console.error(import_picocolors8.default.red(`Unknown platform: ${platform}`));
|
|
11570
11645
|
process.exit(1);
|
|
11571
11646
|
}
|
|
11572
11647
|
logger.debug("docs", `Publishing to ${platform}`);
|
|
@@ -11575,7 +11650,7 @@ ${page.body}`);
|
|
|
11575
11650
|
printResult(result, opts);
|
|
11576
11651
|
return;
|
|
11577
11652
|
}
|
|
11578
|
-
console.log(
|
|
11653
|
+
console.log(import_picocolors8.default.green(`Document published to ${platform}.`));
|
|
11579
11654
|
});
|
|
11580
11655
|
cmd.command("sync-back").description("Sync document back to its source (Notion/Confluence)").argument("<id>", "Page ID").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
11581
11656
|
const cfg = requireConfig4();
|
|
@@ -11585,7 +11660,7 @@ ${page.body}`);
|
|
|
11585
11660
|
printResult(result, opts);
|
|
11586
11661
|
return;
|
|
11587
11662
|
}
|
|
11588
|
-
console.log(
|
|
11663
|
+
console.log(import_picocolors8.default.green("Sync-back initiated."));
|
|
11589
11664
|
});
|
|
11590
11665
|
return cmd;
|
|
11591
11666
|
}
|
|
@@ -12594,7 +12669,7 @@ function createProgram() {
|
|
|
12594
12669
|
console.log(`MCP ID: ${cfg.deployment_id}`);
|
|
12595
12670
|
} else {
|
|
12596
12671
|
console.log("MCP: None selected");
|
|
12597
|
-
console.log("Run 'dosu' to
|
|
12672
|
+
console.log("Run 'dosu deployments list' to see available MCPs, then 'dosu deployments switch <id>' to select one.");
|
|
12598
12673
|
}
|
|
12599
12674
|
});
|
|
12600
12675
|
const mcp = program2.command("mcp").description("Manage MCP server integrations");
|