@fabricorg/cli 0.1.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/dist/fabric.js +2240 -0
- package/dist/fabric.js.map +1 -0
- package/package.json +45 -0
package/dist/fabric.js
ADDED
|
@@ -0,0 +1,2240 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/bin/fabric.ts
|
|
55
|
+
import { Command as Command19 } from "commander";
|
|
56
|
+
|
|
57
|
+
// src/commands/agents/index.ts
|
|
58
|
+
import { Command } from "commander";
|
|
59
|
+
|
|
60
|
+
// src/lib/client.ts
|
|
61
|
+
import { FabricAuthError, FabricClient } from "@fabricorg/sdk";
|
|
62
|
+
|
|
63
|
+
// src/lib/config.ts
|
|
64
|
+
import Conf from "conf";
|
|
65
|
+
var DEFAULTS = {
|
|
66
|
+
activeProfile: "default",
|
|
67
|
+
profiles: {},
|
|
68
|
+
defaultFormat: "table"
|
|
69
|
+
};
|
|
70
|
+
var _store;
|
|
71
|
+
function getStore() {
|
|
72
|
+
if (!_store) {
|
|
73
|
+
_store = new Conf({
|
|
74
|
+
projectName: "fabricai",
|
|
75
|
+
defaults: DEFAULTS
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return _store;
|
|
79
|
+
}
|
|
80
|
+
function getConfig() {
|
|
81
|
+
return getStore().store;
|
|
82
|
+
}
|
|
83
|
+
function getActiveProfile() {
|
|
84
|
+
var _a2;
|
|
85
|
+
const cfg = getConfig();
|
|
86
|
+
return (_a2 = cfg.profiles[cfg.activeProfile]) != null ? _a2 : {};
|
|
87
|
+
}
|
|
88
|
+
function getApiKey() {
|
|
89
|
+
if (process.env.FABRIC_API_KEY) {
|
|
90
|
+
return process.env.FABRIC_API_KEY;
|
|
91
|
+
}
|
|
92
|
+
return getActiveProfile().apiKey;
|
|
93
|
+
}
|
|
94
|
+
function getBaseUrl() {
|
|
95
|
+
if (process.env.FABRIC_BASE_URL) {
|
|
96
|
+
return process.env.FABRIC_BASE_URL;
|
|
97
|
+
}
|
|
98
|
+
return getActiveProfile().baseUrl;
|
|
99
|
+
}
|
|
100
|
+
function getDefaultContext() {
|
|
101
|
+
if (process.env.FABRIC_ORG) {
|
|
102
|
+
return { type: "org", slug: process.env.FABRIC_ORG };
|
|
103
|
+
}
|
|
104
|
+
if (process.env.FABRIC_PERSONAL === "1") {
|
|
105
|
+
return { type: "personal" };
|
|
106
|
+
}
|
|
107
|
+
return getActiveProfile().defaultContext;
|
|
108
|
+
}
|
|
109
|
+
function getOutputFormat() {
|
|
110
|
+
if (process.env.FABRIC_FORMAT === "json" || process.env.FABRIC_FORMAT === "yaml" || process.env.FABRIC_FORMAT === "csv") {
|
|
111
|
+
return process.env.FABRIC_FORMAT;
|
|
112
|
+
}
|
|
113
|
+
return getConfig().defaultFormat;
|
|
114
|
+
}
|
|
115
|
+
function saveApiKey(apiKey, profile = "default") {
|
|
116
|
+
var _a2;
|
|
117
|
+
const store = getStore();
|
|
118
|
+
const profiles = store.get("profiles");
|
|
119
|
+
store.set("profiles", __spreadProps(__spreadValues({}, profiles), {
|
|
120
|
+
[profile]: __spreadProps(__spreadValues({}, (_a2 = profiles[profile]) != null ? _a2 : {}), { apiKey })
|
|
121
|
+
}));
|
|
122
|
+
store.set("activeProfile", profile);
|
|
123
|
+
}
|
|
124
|
+
function clearApiKey(profile = "default") {
|
|
125
|
+
var _a2;
|
|
126
|
+
const store = getStore();
|
|
127
|
+
const profiles = store.get("profiles");
|
|
128
|
+
const _b = (_a2 = profiles[profile]) != null ? _a2 : {}, { apiKey: _ } = _b, rest = __objRest(_b, ["apiKey"]);
|
|
129
|
+
store.set("profiles", __spreadProps(__spreadValues({}, profiles), { [profile]: rest }));
|
|
130
|
+
}
|
|
131
|
+
function saveDefaultContext(ctx, profile) {
|
|
132
|
+
var _a2;
|
|
133
|
+
const store = getStore();
|
|
134
|
+
const active = profile != null ? profile : store.get("activeProfile");
|
|
135
|
+
const profiles = store.get("profiles");
|
|
136
|
+
store.set("profiles", __spreadProps(__spreadValues({}, profiles), {
|
|
137
|
+
[active]: __spreadProps(__spreadValues({}, (_a2 = profiles[active]) != null ? _a2 : {}), { defaultContext: ctx })
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
function getConfigPath() {
|
|
141
|
+
return getStore().path;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/lib/output.ts
|
|
145
|
+
import Table from "cli-table3";
|
|
146
|
+
function printOutput(data, opts = {}) {
|
|
147
|
+
var _a2, _b, _c, _d;
|
|
148
|
+
const format = (_a2 = opts.format) != null ? _a2 : getOutputFormat();
|
|
149
|
+
if (format === "json") {
|
|
150
|
+
process.stdout.write(`${JSON.stringify(data, null, 2)}
|
|
151
|
+
`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (format === "yaml") {
|
|
155
|
+
process.stdout.write(`${toYaml(data)}
|
|
156
|
+
`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (format === "quiet") {
|
|
160
|
+
const rows2 = Array.isArray(data) ? data : [data];
|
|
161
|
+
const key = (_b = opts.idKey) != null ? _b : "id";
|
|
162
|
+
for (const row of rows2) {
|
|
163
|
+
const val = row[key];
|
|
164
|
+
if (val !== void 0) {
|
|
165
|
+
process.stdout.write(`${String(val)}
|
|
166
|
+
`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (format === "csv") {
|
|
172
|
+
const rows2 = Array.isArray(data) ? data : [data];
|
|
173
|
+
if (rows2.length === 0) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const cols2 = (_c = opts.columns) != null ? _c : Object.keys(rows2[0]);
|
|
177
|
+
process.stdout.write(`${cols2.map(csvEscape).join(",")}
|
|
178
|
+
`);
|
|
179
|
+
for (const row of rows2) {
|
|
180
|
+
process.stdout.write(
|
|
181
|
+
`${cols2.map(
|
|
182
|
+
(c) => {
|
|
183
|
+
var _a3;
|
|
184
|
+
return csvEscape(
|
|
185
|
+
String((_a3 = row[c]) != null ? _a3 : "")
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
).join(",")}
|
|
189
|
+
`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const rows = Array.isArray(data) ? data : [data];
|
|
195
|
+
if (rows.length === 0) {
|
|
196
|
+
process.stdout.write("(no results)\n");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const cols = (_d = opts.columns) != null ? _d : Object.keys(rows[0]);
|
|
200
|
+
const table = new Table({ head: cols, style: { head: ["cyan"] } });
|
|
201
|
+
for (const row of rows) {
|
|
202
|
+
table.push(
|
|
203
|
+
cols.map((c) => formatCell(row[c]))
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
process.stdout.write(`${table.toString()}
|
|
207
|
+
`);
|
|
208
|
+
}
|
|
209
|
+
function printRecord(data, opts = {}) {
|
|
210
|
+
var _a2;
|
|
211
|
+
const format = (_a2 = opts.format) != null ? _a2 : getOutputFormat();
|
|
212
|
+
if (format === "json") {
|
|
213
|
+
printOutput(data, opts);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (format === "yaml") {
|
|
217
|
+
printOutput(data, opts);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const table = new Table({ style: { head: ["cyan"] } });
|
|
221
|
+
for (const [key, val] of Object.entries(data)) {
|
|
222
|
+
table.push({ [key]: formatCell(val) });
|
|
223
|
+
}
|
|
224
|
+
process.stdout.write(`${table.toString()}
|
|
225
|
+
`);
|
|
226
|
+
}
|
|
227
|
+
function printSuccess(message) {
|
|
228
|
+
process.stdout.write(`\u2713 ${message}
|
|
229
|
+
`);
|
|
230
|
+
}
|
|
231
|
+
function printError(message, exitCode = 1) {
|
|
232
|
+
process.stderr.write(`\u2717 ${message}
|
|
233
|
+
`);
|
|
234
|
+
process.exit(exitCode);
|
|
235
|
+
}
|
|
236
|
+
function printWarning(message) {
|
|
237
|
+
process.stderr.write(`\u26A0 ${message}
|
|
238
|
+
`);
|
|
239
|
+
}
|
|
240
|
+
function formatCell(val) {
|
|
241
|
+
if (val === null || val === void 0) {
|
|
242
|
+
return "";
|
|
243
|
+
}
|
|
244
|
+
if (typeof val === "boolean") {
|
|
245
|
+
return val ? "yes" : "no";
|
|
246
|
+
}
|
|
247
|
+
if (typeof val === "object") {
|
|
248
|
+
return JSON.stringify(val);
|
|
249
|
+
}
|
|
250
|
+
const s = String(val);
|
|
251
|
+
if (/^\d{4}-\d{2}-\d{2}T/.test(s)) {
|
|
252
|
+
return s.slice(0, 10);
|
|
253
|
+
}
|
|
254
|
+
return s;
|
|
255
|
+
}
|
|
256
|
+
function csvEscape(s) {
|
|
257
|
+
if (s.includes(",") || s.includes('"') || s.includes("\n")) {
|
|
258
|
+
return `"${s.replace(/"/g, '""')}"`;
|
|
259
|
+
}
|
|
260
|
+
return s;
|
|
261
|
+
}
|
|
262
|
+
function toYaml(val, indent = 0) {
|
|
263
|
+
const pad = " ".repeat(indent);
|
|
264
|
+
if (val === null || val === void 0) {
|
|
265
|
+
return "~";
|
|
266
|
+
}
|
|
267
|
+
if (typeof val === "boolean" || typeof val === "number") {
|
|
268
|
+
return String(val);
|
|
269
|
+
}
|
|
270
|
+
if (typeof val === "string") {
|
|
271
|
+
if (val.includes("\n") || val.includes(":") || val.includes('"')) {
|
|
272
|
+
return `"${val.replace(/"/g, '\\"')}"`;
|
|
273
|
+
}
|
|
274
|
+
return val;
|
|
275
|
+
}
|
|
276
|
+
if (Array.isArray(val)) {
|
|
277
|
+
if (val.length === 0) {
|
|
278
|
+
return "[]";
|
|
279
|
+
}
|
|
280
|
+
return val.map((item) => `${pad}- ${toYaml(item, indent + 1)}`).join("\n");
|
|
281
|
+
}
|
|
282
|
+
if (typeof val === "object") {
|
|
283
|
+
const entries = Object.entries(val);
|
|
284
|
+
if (entries.length === 0) {
|
|
285
|
+
return "{}";
|
|
286
|
+
}
|
|
287
|
+
return entries.map(([k, v]) => {
|
|
288
|
+
const valStr = toYaml(v, indent + 1);
|
|
289
|
+
const isMultiline = valStr.includes("\n");
|
|
290
|
+
return isMultiline ? `${pad}${k}:
|
|
291
|
+
${valStr}` : `${pad}${k}: ${valStr}`;
|
|
292
|
+
}).join("\n");
|
|
293
|
+
}
|
|
294
|
+
return String(val);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/lib/client.ts
|
|
298
|
+
function getClient() {
|
|
299
|
+
const apiKey = getApiKey();
|
|
300
|
+
if (!apiKey) {
|
|
301
|
+
printError(
|
|
302
|
+
"Not authenticated. Run:\n fabric auth login --key <api-key>",
|
|
303
|
+
3
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
return new FabricClient({ apiKey, baseUrl: getBaseUrl() });
|
|
308
|
+
} catch (err) {
|
|
309
|
+
if (err instanceof FabricAuthError) {
|
|
310
|
+
printError(err.message, 3);
|
|
311
|
+
}
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/lib/context.ts
|
|
317
|
+
function resolveContext(personal, org, required = true) {
|
|
318
|
+
if (personal && org) {
|
|
319
|
+
printError("Cannot use --personal and --org together", 2);
|
|
320
|
+
}
|
|
321
|
+
if (personal) {
|
|
322
|
+
return { type: "personal" };
|
|
323
|
+
}
|
|
324
|
+
if (org) {
|
|
325
|
+
return { type: "org", slug: org };
|
|
326
|
+
}
|
|
327
|
+
const stored = getDefaultContext();
|
|
328
|
+
if (stored) {
|
|
329
|
+
if (stored.type === "personal") {
|
|
330
|
+
return { type: "personal" };
|
|
331
|
+
}
|
|
332
|
+
if (stored.type === "org") {
|
|
333
|
+
return { type: "org", slug: stored.slug };
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (required) {
|
|
337
|
+
printError(
|
|
338
|
+
"Context is required. Use --personal, --org <slug>, or set a default with:\n fabric ctx use personal\n fabric ctx use org <slug>",
|
|
339
|
+
2
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
return void 0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// src/commands/agents/index.ts
|
|
346
|
+
function buildAgentsCommand() {
|
|
347
|
+
const agents = new Command("agents").description("Manage agents");
|
|
348
|
+
agents.command("list").description("List agents").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--status <status>", "Filter: ACTIVE|INACTIVE|DEPRECATED").option("--limit <n>", "Max results", "50").option(
|
|
349
|
+
"--format <format>",
|
|
350
|
+
"Output format: table|json|yaml|csv",
|
|
351
|
+
"table"
|
|
352
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
353
|
+
(opts) => __async(null, null, function* () {
|
|
354
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
355
|
+
const client = getClient();
|
|
356
|
+
let list;
|
|
357
|
+
try {
|
|
358
|
+
list = yield client.agents.list({
|
|
359
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
360
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
361
|
+
status: opts.status,
|
|
362
|
+
limit: Number(opts.limit)
|
|
363
|
+
});
|
|
364
|
+
} catch (err) {
|
|
365
|
+
printError(err.message, 1);
|
|
366
|
+
}
|
|
367
|
+
if (opts.quiet) {
|
|
368
|
+
for (const a of list) {
|
|
369
|
+
process.stdout.write(`${a.id}
|
|
370
|
+
`);
|
|
371
|
+
}
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
printOutput(list, {
|
|
375
|
+
format: opts.format,
|
|
376
|
+
columns: [
|
|
377
|
+
"id",
|
|
378
|
+
"name",
|
|
379
|
+
"displayName",
|
|
380
|
+
"framework",
|
|
381
|
+
"status",
|
|
382
|
+
"createdAt"
|
|
383
|
+
]
|
|
384
|
+
});
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
agents.command("show <id>").description("Show agent details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
388
|
+
(id, opts) => __async(null, null, function* () {
|
|
389
|
+
var _a2;
|
|
390
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
391
|
+
const client = getClient();
|
|
392
|
+
let agent;
|
|
393
|
+
try {
|
|
394
|
+
agent = yield client.agents.get(id, {
|
|
395
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
396
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
397
|
+
});
|
|
398
|
+
} catch (err) {
|
|
399
|
+
printError(err.message, 1);
|
|
400
|
+
}
|
|
401
|
+
const fmt = opts.format;
|
|
402
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
403
|
+
printOutput(agent, { format: fmt });
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
printRecord({
|
|
407
|
+
ID: agent.id,
|
|
408
|
+
"Agent ID": agent.agentId,
|
|
409
|
+
Name: agent.name,
|
|
410
|
+
"Display name": agent.displayName,
|
|
411
|
+
Framework: agent.framework,
|
|
412
|
+
Status: agent.status,
|
|
413
|
+
"Deployment URL": (_a2 = agent.deploymentUrl) != null ? _a2 : "(none)",
|
|
414
|
+
Created: agent.createdAt.slice(0, 10)
|
|
415
|
+
});
|
|
416
|
+
})
|
|
417
|
+
);
|
|
418
|
+
agents.command("execute <id>").description("Execute an agent").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--input <json>", `Input JSON (e.g. '{"key":"value"}')`).option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
419
|
+
(id, opts) => __async(null, null, function* () {
|
|
420
|
+
var _a2;
|
|
421
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
422
|
+
const client = getClient();
|
|
423
|
+
let inputObj = {};
|
|
424
|
+
if (opts.input) {
|
|
425
|
+
try {
|
|
426
|
+
inputObj = JSON.parse(opts.input);
|
|
427
|
+
} catch (e) {
|
|
428
|
+
printError("--input must be valid JSON", 2);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
let result;
|
|
432
|
+
try {
|
|
433
|
+
result = yield client.agents.execute(id, {
|
|
434
|
+
input: inputObj,
|
|
435
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
436
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
437
|
+
});
|
|
438
|
+
} catch (err) {
|
|
439
|
+
printError(err.message, 1);
|
|
440
|
+
}
|
|
441
|
+
const fmt = opts.format;
|
|
442
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
443
|
+
printOutput(result, { format: fmt });
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
printRecord(__spreadValues({
|
|
447
|
+
"Task ID": result.taskId,
|
|
448
|
+
"Workflow ID": result.workflowId,
|
|
449
|
+
"Run ID": (_a2 = result.runId) != null ? _a2 : "(pending)",
|
|
450
|
+
Status: result.status
|
|
451
|
+
}, result.warning ? { Warning: result.warning } : {}));
|
|
452
|
+
})
|
|
453
|
+
);
|
|
454
|
+
return agents;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// src/commands/auth/keys.ts
|
|
458
|
+
import { Command as Command2 } from "commander";
|
|
459
|
+
function buildKeysCommand() {
|
|
460
|
+
const keys = new Command2("keys").description("Manage API keys");
|
|
461
|
+
keys.command("list").description("List your API keys").option(
|
|
462
|
+
"--format <format>",
|
|
463
|
+
"Output format: table|json|yaml|csv",
|
|
464
|
+
"table"
|
|
465
|
+
).action((opts) => __async(null, null, function* () {
|
|
466
|
+
const client = getClient();
|
|
467
|
+
let list;
|
|
468
|
+
try {
|
|
469
|
+
list = yield client.auth.listKeys();
|
|
470
|
+
} catch (err) {
|
|
471
|
+
printError(err.message, 1);
|
|
472
|
+
}
|
|
473
|
+
printOutput(list, {
|
|
474
|
+
format: opts.format,
|
|
475
|
+
columns: [
|
|
476
|
+
"id",
|
|
477
|
+
"name",
|
|
478
|
+
"keyPrefix",
|
|
479
|
+
"scopes",
|
|
480
|
+
"lastUsedAt",
|
|
481
|
+
"expiresAt",
|
|
482
|
+
"createdAt"
|
|
483
|
+
]
|
|
484
|
+
});
|
|
485
|
+
}));
|
|
486
|
+
keys.command("create").description("Create a new API key (raw key shown only once)").requiredOption("-n, --name <name>", "Key name").option(
|
|
487
|
+
"-s, --scopes <scopes>",
|
|
488
|
+
"Comma-separated scopes (e.g. projects:read,workflows:run)",
|
|
489
|
+
"orgs:read"
|
|
490
|
+
).option(
|
|
491
|
+
"-e, --expires <days>",
|
|
492
|
+
"Days until expiry (1\u2013365, omit for no expiry)"
|
|
493
|
+
).option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
494
|
+
(opts) => __async(null, null, function* () {
|
|
495
|
+
const client = getClient();
|
|
496
|
+
const scopes = opts.scopes.split(",").map((s) => s.trim());
|
|
497
|
+
const expiresInDays = opts.expires ? Number.parseInt(opts.expires, 10) : void 0;
|
|
498
|
+
if (expiresInDays !== void 0 && Number.isNaN(expiresInDays)) {
|
|
499
|
+
printError("--expires must be a number", 2);
|
|
500
|
+
}
|
|
501
|
+
let created;
|
|
502
|
+
try {
|
|
503
|
+
created = yield client.auth.createKey({
|
|
504
|
+
name: opts.name,
|
|
505
|
+
scopes,
|
|
506
|
+
expiresInDays
|
|
507
|
+
});
|
|
508
|
+
} catch (err) {
|
|
509
|
+
printError(err.message, 1);
|
|
510
|
+
}
|
|
511
|
+
const fmt = opts.format;
|
|
512
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
513
|
+
printOutput(created, { format: fmt });
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
process.stdout.write("\n");
|
|
517
|
+
printSuccess(`API key created: ${created.name}`);
|
|
518
|
+
process.stdout.write(`
|
|
519
|
+
Key: ${created.rawKey}
|
|
520
|
+
`);
|
|
521
|
+
process.stdout.write(` Prefix: ${created.keyPrefix}
|
|
522
|
+
`);
|
|
523
|
+
process.stdout.write(
|
|
524
|
+
` Scopes: ${created.scopes.join(", ")}
|
|
525
|
+
`
|
|
526
|
+
);
|
|
527
|
+
if (created.expiresAt) {
|
|
528
|
+
process.stdout.write(
|
|
529
|
+
` Expires: ${String(created.expiresAt).slice(0, 10)}
|
|
530
|
+
`
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
process.stdout.write(
|
|
534
|
+
"\n \u26A0 Store this key now \u2014 it will never be shown again.\n\n"
|
|
535
|
+
);
|
|
536
|
+
})
|
|
537
|
+
);
|
|
538
|
+
keys.command("revoke <id>").description("Permanently revoke an API key").action((id) => __async(null, null, function* () {
|
|
539
|
+
const client = getClient();
|
|
540
|
+
try {
|
|
541
|
+
yield client.auth.revokeKey(id);
|
|
542
|
+
} catch (err) {
|
|
543
|
+
printError(err.message, 1);
|
|
544
|
+
}
|
|
545
|
+
printSuccess(`API key ${id} revoked.`);
|
|
546
|
+
}));
|
|
547
|
+
return keys;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// src/commands/auth/login.ts
|
|
551
|
+
import * as readline from "readline";
|
|
552
|
+
import { FabricClient as FabricClient2 } from "@fabricorg/sdk";
|
|
553
|
+
import { Command as Command3 } from "commander";
|
|
554
|
+
function promptApiKey() {
|
|
555
|
+
return __async(this, null, function* () {
|
|
556
|
+
const rl = readline.createInterface({
|
|
557
|
+
input: process.stdin,
|
|
558
|
+
output: process.stdout
|
|
559
|
+
});
|
|
560
|
+
return new Promise((resolve) => {
|
|
561
|
+
process.stdout.write("Fabric API Key: ");
|
|
562
|
+
process.stdin.resume();
|
|
563
|
+
process.stdin.setEncoding("utf8");
|
|
564
|
+
let key = "";
|
|
565
|
+
process.stdin.once("data", (chunk) => {
|
|
566
|
+
key = String(chunk).trim();
|
|
567
|
+
process.stdout.write("\n");
|
|
568
|
+
rl.close();
|
|
569
|
+
resolve(key);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function buildLoginCommand() {
|
|
575
|
+
return new Command3("login").description("Authenticate with a Fabric API key").option("-k, --key <api-key>", "API key (fab_... or org_...)").option("--base-url <url>", "Override the Fabric base URL").action((opts) => __async(null, null, function* () {
|
|
576
|
+
var _a2, _b, _c;
|
|
577
|
+
let apiKey = (_a2 = opts.key) == null ? void 0 : _a2.trim();
|
|
578
|
+
if (!apiKey) {
|
|
579
|
+
apiKey = yield promptApiKey();
|
|
580
|
+
}
|
|
581
|
+
if (!apiKey) {
|
|
582
|
+
printError("API key is required", 2);
|
|
583
|
+
}
|
|
584
|
+
if (!apiKey.startsWith("fab_") && !apiKey.startsWith("org_")) {
|
|
585
|
+
printError(
|
|
586
|
+
"Invalid API key format. Keys must start with fab_ or org_",
|
|
587
|
+
2
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
const baseUrl = (_b = opts.baseUrl) != null ? _b : getBaseUrl();
|
|
591
|
+
const client = new FabricClient2({ apiKey, baseUrl });
|
|
592
|
+
let name;
|
|
593
|
+
let email;
|
|
594
|
+
try {
|
|
595
|
+
const me = yield client.auth.whoami();
|
|
596
|
+
name = (_c = me.user.name) != null ? _c : me.user.email;
|
|
597
|
+
email = me.user.email;
|
|
598
|
+
} catch (e) {
|
|
599
|
+
printError(
|
|
600
|
+
"Authentication failed. Check that the key is valid and not expired.",
|
|
601
|
+
3
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
saveApiKey(apiKey);
|
|
605
|
+
printSuccess(`Authenticated as ${name} (${email})`);
|
|
606
|
+
}));
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/commands/auth/logout.ts
|
|
610
|
+
import { Command as Command4 } from "commander";
|
|
611
|
+
function buildLogoutCommand() {
|
|
612
|
+
return new Command4("logout").description("Remove stored API key").action(() => {
|
|
613
|
+
if (!getApiKey()) {
|
|
614
|
+
printWarning("No API key stored \u2014 already logged out.");
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
clearApiKey();
|
|
618
|
+
printSuccess("Logged out. API key removed.");
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// src/commands/auth/whoami.ts
|
|
623
|
+
import { Command as Command5 } from "commander";
|
|
624
|
+
function buildWhoamiCommand() {
|
|
625
|
+
return new Command5("whoami").description("Show current authentication and identity").option("--format <format>", "Output format: table|json|yaml", "table").action((opts) => __async(null, null, function* () {
|
|
626
|
+
var _a2, _b;
|
|
627
|
+
const client = getClient();
|
|
628
|
+
let me;
|
|
629
|
+
try {
|
|
630
|
+
me = yield client.auth.whoami();
|
|
631
|
+
} catch (err) {
|
|
632
|
+
printError((_a2 = err.message) != null ? _a2 : "Request failed", 3);
|
|
633
|
+
}
|
|
634
|
+
const fmt = opts.format;
|
|
635
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
636
|
+
printOutput(me, { format: fmt });
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
printRecord({
|
|
640
|
+
User: (_b = me.user.name) != null ? _b : "(no name)",
|
|
641
|
+
Email: me.user.email,
|
|
642
|
+
Role: me.user.role,
|
|
643
|
+
"Key type": me.keyType,
|
|
644
|
+
"Key prefix": me.keyPrefix,
|
|
645
|
+
Scopes: me.scopes.join(", "),
|
|
646
|
+
"Orgs count": String(me.orgs.length),
|
|
647
|
+
"Member since": me.user.createdAt.slice(0, 10)
|
|
648
|
+
});
|
|
649
|
+
if (me.orgs.length > 0) {
|
|
650
|
+
process.stdout.write("\nOrganizations:\n");
|
|
651
|
+
printOutput(me.orgs, {
|
|
652
|
+
format: "table",
|
|
653
|
+
columns: ["name", "slug", "role", "joinedAt"]
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}));
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/commands/chats/index.ts
|
|
660
|
+
import { Command as Command6 } from "commander";
|
|
661
|
+
function buildChatsCommand() {
|
|
662
|
+
const chats = new Command6("chats").description("Manage AI chat sessions");
|
|
663
|
+
chats.command("list").description("List AI chat sessions").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--limit <n>", "Max results (default 20)", "20").option(
|
|
664
|
+
"--format <format>",
|
|
665
|
+
"Output format: table|json|yaml|csv",
|
|
666
|
+
"table"
|
|
667
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
668
|
+
(opts) => __async(null, null, function* () {
|
|
669
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
670
|
+
const client = getClient();
|
|
671
|
+
let list;
|
|
672
|
+
try {
|
|
673
|
+
list = yield client.chats.list({
|
|
674
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
675
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
676
|
+
limit: Number(opts.limit)
|
|
677
|
+
});
|
|
678
|
+
} catch (err) {
|
|
679
|
+
printError(err.message, 1);
|
|
680
|
+
}
|
|
681
|
+
if (opts.quiet) {
|
|
682
|
+
for (const c of list) {
|
|
683
|
+
process.stdout.write(`${c.id}
|
|
684
|
+
`);
|
|
685
|
+
}
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
printOutput(list, {
|
|
689
|
+
format: opts.format,
|
|
690
|
+
columns: ["id", "title", "updatedAt"]
|
|
691
|
+
});
|
|
692
|
+
})
|
|
693
|
+
);
|
|
694
|
+
chats.command("show <id>").description("Show chat details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
695
|
+
(id, opts) => __async(null, null, function* () {
|
|
696
|
+
var _a2;
|
|
697
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
698
|
+
const client = getClient();
|
|
699
|
+
let chat;
|
|
700
|
+
try {
|
|
701
|
+
chat = yield client.chats.get(id, {
|
|
702
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
703
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
704
|
+
});
|
|
705
|
+
} catch (err) {
|
|
706
|
+
printError(err.message, 1);
|
|
707
|
+
}
|
|
708
|
+
const fmt = opts.format;
|
|
709
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
710
|
+
printOutput(chat, { format: fmt });
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
printRecord({
|
|
714
|
+
ID: chat.id,
|
|
715
|
+
Title: (_a2 = chat.title) != null ? _a2 : "(untitled)",
|
|
716
|
+
Updated: chat.updatedAt.slice(0, 16).replace("T", " "),
|
|
717
|
+
Created: chat.createdAt.slice(0, 10)
|
|
718
|
+
});
|
|
719
|
+
})
|
|
720
|
+
);
|
|
721
|
+
return chats;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// src/commands/completion/index.ts
|
|
725
|
+
import { Command as Command7 } from "commander";
|
|
726
|
+
var BASH_COMPLETION = `
|
|
727
|
+
# fabric bash completion
|
|
728
|
+
_fabric_completion() {
|
|
729
|
+
local cur prev words cword
|
|
730
|
+
_init_completion || return
|
|
731
|
+
|
|
732
|
+
local commands="auth ctx orgs projects features workflows prompts agents skills mcp frames workspaces chats reports config completion"
|
|
733
|
+
|
|
734
|
+
case "$prev" in
|
|
735
|
+
fabric)
|
|
736
|
+
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
|
|
737
|
+
return ;;
|
|
738
|
+
auth)
|
|
739
|
+
COMPREPLY=($(compgen -W "login logout whoami keys" -- "$cur"))
|
|
740
|
+
return ;;
|
|
741
|
+
keys)
|
|
742
|
+
COMPREPLY=($(compgen -W "list create revoke" -- "$cur"))
|
|
743
|
+
return ;;
|
|
744
|
+
ctx)
|
|
745
|
+
COMPREPLY=($(compgen -W "current use" -- "$cur"))
|
|
746
|
+
return ;;
|
|
747
|
+
orgs)
|
|
748
|
+
COMPREPLY=($(compgen -W "list show" -- "$cur"))
|
|
749
|
+
return ;;
|
|
750
|
+
projects)
|
|
751
|
+
COMPREPLY=($(compgen -W "list show create update" -- "$cur"))
|
|
752
|
+
return ;;
|
|
753
|
+
features)
|
|
754
|
+
COMPREPLY=($(compgen -W "list show create update tasks" -- "$cur"))
|
|
755
|
+
return ;;
|
|
756
|
+
workflows)
|
|
757
|
+
COMPREPLY=($(compgen -W "list show trigger status" -- "$cur"))
|
|
758
|
+
return ;;
|
|
759
|
+
prompts)
|
|
760
|
+
COMPREPLY=($(compgen -W "list get create update" -- "$cur"))
|
|
761
|
+
return ;;
|
|
762
|
+
agents)
|
|
763
|
+
COMPREPLY=($(compgen -W "list show execute" -- "$cur"))
|
|
764
|
+
return ;;
|
|
765
|
+
skills)
|
|
766
|
+
COMPREPLY=($(compgen -W "list show" -- "$cur"))
|
|
767
|
+
return ;;
|
|
768
|
+
mcp)
|
|
769
|
+
COMPREPLY=($(compgen -W "servers configs" -- "$cur"))
|
|
770
|
+
return ;;
|
|
771
|
+
configs)
|
|
772
|
+
COMPREPLY=($(compgen -W "list show delete" -- "$cur"))
|
|
773
|
+
return ;;
|
|
774
|
+
frames)
|
|
775
|
+
COMPREPLY=($(compgen -W "list show" -- "$cur"))
|
|
776
|
+
return ;;
|
|
777
|
+
workspaces)
|
|
778
|
+
COMPREPLY=($(compgen -W "list show" -- "$cur"))
|
|
779
|
+
return ;;
|
|
780
|
+
chats)
|
|
781
|
+
COMPREPLY=($(compgen -W "list show" -- "$cur"))
|
|
782
|
+
return ;;
|
|
783
|
+
reports)
|
|
784
|
+
COMPREPLY=($(compgen -W "templates executions" -- "$cur"))
|
|
785
|
+
return ;;
|
|
786
|
+
templates)
|
|
787
|
+
COMPREPLY=($(compgen -W "list show" -- "$cur"))
|
|
788
|
+
return ;;
|
|
789
|
+
executions)
|
|
790
|
+
COMPREPLY=($(compgen -W "list" -- "$cur"))
|
|
791
|
+
return ;;
|
|
792
|
+
completion)
|
|
793
|
+
COMPREPLY=($(compgen -W "bash zsh fish" -- "$cur"))
|
|
794
|
+
return ;;
|
|
795
|
+
esac
|
|
796
|
+
|
|
797
|
+
COMPREPLY=($(compgen -W "--format --org --personal --quiet --help" -- "$cur"))
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
complete -F _fabric_completion fabric
|
|
801
|
+
`.trim();
|
|
802
|
+
var ZSH_COMPLETION = `
|
|
803
|
+
#compdef fabric
|
|
804
|
+
|
|
805
|
+
_fabric() {
|
|
806
|
+
local state
|
|
807
|
+
|
|
808
|
+
_arguments \\
|
|
809
|
+
'--format[Output format]:format:(table json yaml csv)' \\
|
|
810
|
+
'--version[Show version]' \\
|
|
811
|
+
'--help[Show help]' \\
|
|
812
|
+
'1: :->command' \\
|
|
813
|
+
'*: :->args'
|
|
814
|
+
|
|
815
|
+
case $state in
|
|
816
|
+
command)
|
|
817
|
+
local commands=(
|
|
818
|
+
'auth:Authenticate and manage API keys'
|
|
819
|
+
'ctx:Manage active context'
|
|
820
|
+
'orgs:List organizations'
|
|
821
|
+
'projects:Manage projects'
|
|
822
|
+
'features:Manage project features'
|
|
823
|
+
'workflows:Manage workflows'
|
|
824
|
+
'prompts:Manage prompts'
|
|
825
|
+
'agents:Manage agents'
|
|
826
|
+
'skills:Browse skills'
|
|
827
|
+
'mcp:Manage MCP servers and configs'
|
|
828
|
+
'frames:Manage AI-generated frames'
|
|
829
|
+
'workspaces:Manage workspaces'
|
|
830
|
+
'chats:View AI chat history'
|
|
831
|
+
'reports:Manage reports'
|
|
832
|
+
'config:Show CLI configuration'
|
|
833
|
+
'completion:Output shell completion script'
|
|
834
|
+
)
|
|
835
|
+
_describe 'command' commands
|
|
836
|
+
;;
|
|
837
|
+
args)
|
|
838
|
+
case $words[2] in
|
|
839
|
+
auth)
|
|
840
|
+
local subcmds=('login:Log in' 'logout:Log out' 'whoami:Show current user' 'keys:Manage API keys')
|
|
841
|
+
_describe 'subcommand' subcmds ;;
|
|
842
|
+
projects)
|
|
843
|
+
local subcmds=('list:List projects' 'show:Show project' 'create:Create project' 'update:Update project')
|
|
844
|
+
_describe 'subcommand' subcmds ;;
|
|
845
|
+
features)
|
|
846
|
+
local subcmds=('list:List features' 'show:Show feature' 'create:Create feature' 'update:Update feature' 'tasks:List tasks')
|
|
847
|
+
_describe 'subcommand' subcmds ;;
|
|
848
|
+
workflows)
|
|
849
|
+
local subcmds=('list:List workflows' 'show:Show workflow' 'trigger:Trigger workflow' 'status:Check status')
|
|
850
|
+
_describe 'subcommand' subcmds ;;
|
|
851
|
+
prompts)
|
|
852
|
+
local subcmds=('list:List prompts' 'get:Get prompt' 'create:Create prompt' 'update:Update prompt')
|
|
853
|
+
_describe 'subcommand' subcmds ;;
|
|
854
|
+
agents)
|
|
855
|
+
local subcmds=('list:List agents' 'show:Show agent' 'execute:Execute agent')
|
|
856
|
+
_describe 'subcommand' subcmds ;;
|
|
857
|
+
mcp)
|
|
858
|
+
local subcmds=('servers:List MCP servers' 'configs:Manage MCP configs')
|
|
859
|
+
_describe 'subcommand' subcmds ;;
|
|
860
|
+
frames)
|
|
861
|
+
local subcmds=('list:List frames' 'show:Show frame')
|
|
862
|
+
_describe 'subcommand' subcmds ;;
|
|
863
|
+
workspaces)
|
|
864
|
+
local subcmds=('list:List workspaces' 'show:Show workspace')
|
|
865
|
+
_describe 'subcommand' subcmds ;;
|
|
866
|
+
skills)
|
|
867
|
+
local subcmds=('list:List skills' 'show:Show skill')
|
|
868
|
+
_describe 'subcommand' subcmds ;;
|
|
869
|
+
chats)
|
|
870
|
+
local subcmds=('list:List chats' 'show:Show chat')
|
|
871
|
+
_describe 'subcommand' subcmds ;;
|
|
872
|
+
reports)
|
|
873
|
+
local subcmds=('templates:Manage report templates' 'executions:List report executions')
|
|
874
|
+
_describe 'subcommand' subcmds ;;
|
|
875
|
+
completion)
|
|
876
|
+
local subcmds=('bash:Bash completion' 'zsh:Zsh completion' 'fish:Fish completion')
|
|
877
|
+
_describe 'subcommand' subcmds ;;
|
|
878
|
+
esac ;;
|
|
879
|
+
esac
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
_fabric "$@"
|
|
883
|
+
`.trim();
|
|
884
|
+
var FISH_COMPLETION = `
|
|
885
|
+
# fabric fish completion
|
|
886
|
+
set -l fabric_commands auth ctx orgs projects features workflows prompts agents skills mcp frames workspaces chats reports config completion
|
|
887
|
+
|
|
888
|
+
complete -c fabric -f
|
|
889
|
+
|
|
890
|
+
# Top-level commands
|
|
891
|
+
complete -c fabric -n '__fish_use_subcommand' -a auth -d 'Authenticate and manage API keys'
|
|
892
|
+
complete -c fabric -n '__fish_use_subcommand' -a ctx -d 'Manage active context'
|
|
893
|
+
complete -c fabric -n '__fish_use_subcommand' -a orgs -d 'List organizations'
|
|
894
|
+
complete -c fabric -n '__fish_use_subcommand' -a projects -d 'Manage projects'
|
|
895
|
+
complete -c fabric -n '__fish_use_subcommand' -a features -d 'Manage project features'
|
|
896
|
+
complete -c fabric -n '__fish_use_subcommand' -a workflows -d 'Manage workflows'
|
|
897
|
+
complete -c fabric -n '__fish_use_subcommand' -a prompts -d 'Manage prompts'
|
|
898
|
+
complete -c fabric -n '__fish_use_subcommand' -a agents -d 'Manage agents'
|
|
899
|
+
complete -c fabric -n '__fish_use_subcommand' -a skills -d 'Browse skills'
|
|
900
|
+
complete -c fabric -n '__fish_use_subcommand' -a mcp -d 'Manage MCP servers and configs'
|
|
901
|
+
complete -c fabric -n '__fish_use_subcommand' -a frames -d 'Manage AI-generated frames'
|
|
902
|
+
complete -c fabric -n '__fish_use_subcommand' -a workspaces -d 'Manage workspaces'
|
|
903
|
+
complete -c fabric -n '__fish_use_subcommand' -a chats -d 'View AI chat history'
|
|
904
|
+
complete -c fabric -n '__fish_use_subcommand' -a reports -d 'Manage reports'
|
|
905
|
+
complete -c fabric -n '__fish_use_subcommand' -a config -d 'Show CLI configuration'
|
|
906
|
+
complete -c fabric -n '__fish_use_subcommand' -a completion -d 'Output shell completion script'
|
|
907
|
+
|
|
908
|
+
# Subcommands
|
|
909
|
+
complete -c fabric -n '__fish_seen_subcommand_from auth' -a 'login logout whoami keys'
|
|
910
|
+
complete -c fabric -n '__fish_seen_subcommand_from ctx' -a 'current use'
|
|
911
|
+
complete -c fabric -n '__fish_seen_subcommand_from orgs' -a 'list show'
|
|
912
|
+
complete -c fabric -n '__fish_seen_subcommand_from projects' -a 'list show create update'
|
|
913
|
+
complete -c fabric -n '__fish_seen_subcommand_from features' -a 'list show create update tasks'
|
|
914
|
+
complete -c fabric -n '__fish_seen_subcommand_from workflows' -a 'list show trigger status'
|
|
915
|
+
complete -c fabric -n '__fish_seen_subcommand_from prompts' -a 'list get create update'
|
|
916
|
+
complete -c fabric -n '__fish_seen_subcommand_from agents' -a 'list show execute'
|
|
917
|
+
complete -c fabric -n '__fish_seen_subcommand_from skills' -a 'list show'
|
|
918
|
+
complete -c fabric -n '__fish_seen_subcommand_from mcp' -a 'servers configs'
|
|
919
|
+
complete -c fabric -n '__fish_seen_subcommand_from configs' -a 'list show delete'
|
|
920
|
+
complete -c fabric -n '__fish_seen_subcommand_from frames' -a 'list show'
|
|
921
|
+
complete -c fabric -n '__fish_seen_subcommand_from workspaces' -a 'list show'
|
|
922
|
+
complete -c fabric -n '__fish_seen_subcommand_from chats' -a 'list show'
|
|
923
|
+
complete -c fabric -n '__fish_seen_subcommand_from reports' -a 'templates executions'
|
|
924
|
+
complete -c fabric -n '__fish_seen_subcommand_from templates' -a 'list show'
|
|
925
|
+
complete -c fabric -n '__fish_seen_subcommand_from executions' -a 'list'
|
|
926
|
+
complete -c fabric -n '__fish_seen_subcommand_from completion' -a 'bash zsh fish'
|
|
927
|
+
|
|
928
|
+
# Common flags
|
|
929
|
+
complete -c fabric -l format -d 'Output format' -a 'table json yaml csv'
|
|
930
|
+
complete -c fabric -l org -d 'Organization context' -r
|
|
931
|
+
complete -c fabric -l personal -d 'Personal context'
|
|
932
|
+
complete -c fabric -s q -l quiet -d 'Quiet output'
|
|
933
|
+
complete -c fabric -l help -d 'Show help'
|
|
934
|
+
`.trim();
|
|
935
|
+
function buildCompletionCommand() {
|
|
936
|
+
const completion = new Command7("completion").description(
|
|
937
|
+
"Output shell completion script"
|
|
938
|
+
);
|
|
939
|
+
completion.command("bash").description("Output bash completion script").action(() => {
|
|
940
|
+
process.stdout.write(`${BASH_COMPLETION}
|
|
941
|
+
`);
|
|
942
|
+
process.stderr.write(
|
|
943
|
+
'# Add to ~/.bashrc:\n# eval "$(fabric completion bash)"\n'
|
|
944
|
+
);
|
|
945
|
+
});
|
|
946
|
+
completion.command("zsh").description("Output zsh completion script").action(() => {
|
|
947
|
+
process.stdout.write(`${ZSH_COMPLETION}
|
|
948
|
+
`);
|
|
949
|
+
process.stderr.write(
|
|
950
|
+
'# Add to ~/.zshrc:\n# eval "$(fabric completion zsh)"\n'
|
|
951
|
+
);
|
|
952
|
+
});
|
|
953
|
+
completion.command("fish").description("Output fish completion script").action(() => {
|
|
954
|
+
process.stdout.write(`${FISH_COMPLETION}
|
|
955
|
+
`);
|
|
956
|
+
process.stderr.write(
|
|
957
|
+
"# Save to ~/.config/fish/completions/fabric.fish\n"
|
|
958
|
+
);
|
|
959
|
+
});
|
|
960
|
+
return completion;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// src/commands/ctx/index.ts
|
|
964
|
+
import { Command as Command8 } from "commander";
|
|
965
|
+
function buildCtxCommand() {
|
|
966
|
+
const ctx = new Command8("ctx").description(
|
|
967
|
+
"Manage tenant context (personal vs org)"
|
|
968
|
+
);
|
|
969
|
+
ctx.command("current").description("Show the active default context").action(() => {
|
|
970
|
+
const stored = getDefaultContext();
|
|
971
|
+
if (!stored) {
|
|
972
|
+
printWarning(
|
|
973
|
+
"No default context set. Use --personal or --org <slug> on each command, or run:\n fabric ctx use personal\n fabric ctx use org <slug>"
|
|
974
|
+
);
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (stored.type === "personal") {
|
|
978
|
+
process.stdout.write("Context: personal\n");
|
|
979
|
+
} else {
|
|
980
|
+
process.stdout.write(`Context: org:${stored.slug}
|
|
981
|
+
`);
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
const use = new Command8("use").description(
|
|
985
|
+
"Set the default context for commands"
|
|
986
|
+
);
|
|
987
|
+
use.command("personal").description("Use personal context by default").action(() => {
|
|
988
|
+
saveDefaultContext({ type: "personal" });
|
|
989
|
+
printSuccess("Default context set to: personal");
|
|
990
|
+
});
|
|
991
|
+
use.command("org <slug>").description("Use an org context by default").action((slug) => {
|
|
992
|
+
saveDefaultContext({ type: "org", slug });
|
|
993
|
+
printSuccess(`Default context set to: org:${slug}`);
|
|
994
|
+
});
|
|
995
|
+
ctx.addCommand(use);
|
|
996
|
+
return ctx;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// src/commands/features/index.ts
|
|
1000
|
+
import { Command as Command9 } from "commander";
|
|
1001
|
+
function buildFeaturesCommand() {
|
|
1002
|
+
const features = new Command9("features").description(
|
|
1003
|
+
"Manage project features"
|
|
1004
|
+
);
|
|
1005
|
+
features.command("list").description("List features in a project").requiredOption("-p, --project <id>", "Project ID").option("--org <slug>", "Organization context").option("--personal", "Personal context").option(
|
|
1006
|
+
"--priority <priority>",
|
|
1007
|
+
"Filter: P0_CRITICAL|P1_HIGH|P2_MEDIUM|P3_LOW"
|
|
1008
|
+
).option("--search <query>", "Search by title").option("--limit <n>", "Max results (default 50)", "50").option(
|
|
1009
|
+
"--format <format>",
|
|
1010
|
+
"Output format: table|json|yaml|csv",
|
|
1011
|
+
"table"
|
|
1012
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1013
|
+
(opts) => __async(null, null, function* () {
|
|
1014
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1015
|
+
const client = getClient();
|
|
1016
|
+
let list;
|
|
1017
|
+
try {
|
|
1018
|
+
list = yield client.projects.listFeatures(opts.project, {
|
|
1019
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1020
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1021
|
+
priority: opts.priority,
|
|
1022
|
+
search: opts.search,
|
|
1023
|
+
limit: Number(opts.limit)
|
|
1024
|
+
});
|
|
1025
|
+
} catch (err) {
|
|
1026
|
+
printError(err.message, 1);
|
|
1027
|
+
}
|
|
1028
|
+
if (opts.quiet) {
|
|
1029
|
+
for (const f of list) {
|
|
1030
|
+
process.stdout.write(`${f.id}
|
|
1031
|
+
`);
|
|
1032
|
+
}
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
printOutput(list, {
|
|
1036
|
+
format: opts.format,
|
|
1037
|
+
columns: ["identifier", "title", "priority", "createdAt"]
|
|
1038
|
+
});
|
|
1039
|
+
})
|
|
1040
|
+
);
|
|
1041
|
+
features.command("show <id>").description("Show feature details").requiredOption("-p, --project <projectId>", "Project ID").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1042
|
+
(id, opts) => __async(null, null, function* () {
|
|
1043
|
+
var _a2, _b, _c;
|
|
1044
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1045
|
+
const client = getClient();
|
|
1046
|
+
let feature;
|
|
1047
|
+
try {
|
|
1048
|
+
feature = yield client.projects.getFeature(
|
|
1049
|
+
opts.project,
|
|
1050
|
+
id,
|
|
1051
|
+
{
|
|
1052
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1053
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1054
|
+
}
|
|
1055
|
+
);
|
|
1056
|
+
} catch (err) {
|
|
1057
|
+
printError(err.message, 1);
|
|
1058
|
+
}
|
|
1059
|
+
const fmt = opts.format;
|
|
1060
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1061
|
+
printOutput(feature, { format: fmt });
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
printRecord({
|
|
1065
|
+
ID: feature.id,
|
|
1066
|
+
Identifier: feature.identifier,
|
|
1067
|
+
Title: feature.title,
|
|
1068
|
+
Priority: feature.priority,
|
|
1069
|
+
Description: (_a2 = feature.description) != null ? _a2 : "(none)",
|
|
1070
|
+
"Acceptance Criteria": (_b = feature.acceptanceCriteria) != null ? _b : "(none)",
|
|
1071
|
+
Project: feature.projectId,
|
|
1072
|
+
Assignee: (_c = feature.assigneeId) != null ? _c : "(none)",
|
|
1073
|
+
Created: feature.createdAt.slice(0, 10)
|
|
1074
|
+
});
|
|
1075
|
+
})
|
|
1076
|
+
);
|
|
1077
|
+
features.command("create <title>").description("Create a feature in a project").requiredOption("-p, --project <projectId>", "Project ID").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("-d, --description <text>", "Feature description").option(
|
|
1078
|
+
"--priority <priority>",
|
|
1079
|
+
"Priority: P0_CRITICAL|P1_HIGH|P2_MEDIUM|P3_LOW (default: P2_MEDIUM)"
|
|
1080
|
+
).option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1081
|
+
(title, opts) => __async(null, null, function* () {
|
|
1082
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1083
|
+
const client = getClient();
|
|
1084
|
+
let feature;
|
|
1085
|
+
try {
|
|
1086
|
+
feature = yield client.projects.createFeature(
|
|
1087
|
+
opts.project,
|
|
1088
|
+
{
|
|
1089
|
+
title,
|
|
1090
|
+
description: opts.description,
|
|
1091
|
+
priority: opts.priority,
|
|
1092
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1093
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
} catch (err) {
|
|
1097
|
+
printError(err.message, 1);
|
|
1098
|
+
}
|
|
1099
|
+
const fmt = opts.format;
|
|
1100
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1101
|
+
printOutput(feature, { format: fmt });
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
printSuccess(`Feature ${feature.identifier} created`);
|
|
1105
|
+
printRecord({
|
|
1106
|
+
ID: feature.id,
|
|
1107
|
+
Identifier: feature.identifier,
|
|
1108
|
+
Title: feature.title,
|
|
1109
|
+
Priority: feature.priority,
|
|
1110
|
+
Project: feature.projectId,
|
|
1111
|
+
Created: feature.createdAt.slice(0, 10)
|
|
1112
|
+
});
|
|
1113
|
+
})
|
|
1114
|
+
);
|
|
1115
|
+
features.command("tasks").description("List tasks (sub-items) for a feature").requiredOption("-p, --project <projectId>", "Project ID").requiredOption("-f, --feature <featureId>", "Feature ID").option("--org <slug>", "Organization context").option("--personal", "Personal context").option(
|
|
1116
|
+
"--format <format>",
|
|
1117
|
+
"Output format: table|json|yaml|csv",
|
|
1118
|
+
"table"
|
|
1119
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1120
|
+
(opts) => __async(null, null, function* () {
|
|
1121
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1122
|
+
const client = getClient();
|
|
1123
|
+
let tasks;
|
|
1124
|
+
try {
|
|
1125
|
+
tasks = yield client.projects.listTasks(
|
|
1126
|
+
opts.project,
|
|
1127
|
+
opts.feature,
|
|
1128
|
+
{
|
|
1129
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1130
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
1133
|
+
} catch (err) {
|
|
1134
|
+
printError(err.message, 1);
|
|
1135
|
+
}
|
|
1136
|
+
if (opts.quiet) {
|
|
1137
|
+
for (const t of tasks) {
|
|
1138
|
+
process.stdout.write(`${t.id}
|
|
1139
|
+
`);
|
|
1140
|
+
}
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
printOutput(tasks, {
|
|
1144
|
+
format: opts.format,
|
|
1145
|
+
columns: [
|
|
1146
|
+
"identifier",
|
|
1147
|
+
"title",
|
|
1148
|
+
"status",
|
|
1149
|
+
"estimatedHours"
|
|
1150
|
+
]
|
|
1151
|
+
});
|
|
1152
|
+
})
|
|
1153
|
+
);
|
|
1154
|
+
features.command("update <id>").description("Update a feature").requiredOption("-p, --project <projectId>", "Project ID").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--title <title>", "New title").option("-d, --description <text>", "New description").option(
|
|
1155
|
+
"--priority <priority>",
|
|
1156
|
+
"Priority: P0_CRITICAL|P1_HIGH|P2_MEDIUM|P3_LOW"
|
|
1157
|
+
).option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1158
|
+
(id, opts) => __async(null, null, function* () {
|
|
1159
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1160
|
+
const client = getClient();
|
|
1161
|
+
let feature;
|
|
1162
|
+
try {
|
|
1163
|
+
feature = yield client.projects.updateFeature(
|
|
1164
|
+
opts.project,
|
|
1165
|
+
id,
|
|
1166
|
+
{
|
|
1167
|
+
title: opts.title,
|
|
1168
|
+
description: opts.description,
|
|
1169
|
+
priority: opts.priority,
|
|
1170
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1171
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
} catch (err) {
|
|
1175
|
+
printError(err.message, 1);
|
|
1176
|
+
}
|
|
1177
|
+
const fmt = opts.format;
|
|
1178
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1179
|
+
printOutput(feature, { format: fmt });
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
printRecord({
|
|
1183
|
+
ID: feature.id,
|
|
1184
|
+
Identifier: feature.identifier,
|
|
1185
|
+
Title: feature.title,
|
|
1186
|
+
Priority: feature.priority,
|
|
1187
|
+
Updated: feature.updatedAt.slice(0, 10)
|
|
1188
|
+
});
|
|
1189
|
+
})
|
|
1190
|
+
);
|
|
1191
|
+
return features;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// src/commands/frames/index.ts
|
|
1195
|
+
import { Command as Command10 } from "commander";
|
|
1196
|
+
function buildFramesCommand() {
|
|
1197
|
+
const frames = new Command10("frames").description(
|
|
1198
|
+
"Manage AI-generated frames and slideshows"
|
|
1199
|
+
);
|
|
1200
|
+
frames.command("list").description("List frames and slideshows").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--limit <n>", "Max results (default 50)", "50").option(
|
|
1201
|
+
"--format <format>",
|
|
1202
|
+
"Output format: table|json|yaml|csv",
|
|
1203
|
+
"table"
|
|
1204
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1205
|
+
(opts) => __async(null, null, function* () {
|
|
1206
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1207
|
+
const client = getClient();
|
|
1208
|
+
let list;
|
|
1209
|
+
try {
|
|
1210
|
+
list = yield client.frames.list({
|
|
1211
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1212
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1213
|
+
limit: Number(opts.limit)
|
|
1214
|
+
});
|
|
1215
|
+
} catch (err) {
|
|
1216
|
+
printError(err.message, 1);
|
|
1217
|
+
}
|
|
1218
|
+
if (opts.quiet) {
|
|
1219
|
+
for (const f of list) {
|
|
1220
|
+
process.stdout.write(`${f.id}
|
|
1221
|
+
`);
|
|
1222
|
+
}
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
printOutput(list, {
|
|
1226
|
+
format: opts.format,
|
|
1227
|
+
columns: [
|
|
1228
|
+
"id",
|
|
1229
|
+
"title",
|
|
1230
|
+
"fileType",
|
|
1231
|
+
"status",
|
|
1232
|
+
"isPublic",
|
|
1233
|
+
"updatedAt"
|
|
1234
|
+
]
|
|
1235
|
+
});
|
|
1236
|
+
})
|
|
1237
|
+
);
|
|
1238
|
+
frames.command("show <id>").description("Show frame details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1239
|
+
(id, opts) => __async(null, null, function* () {
|
|
1240
|
+
var _a2, _b, _c;
|
|
1241
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1242
|
+
const client = getClient();
|
|
1243
|
+
let frame;
|
|
1244
|
+
try {
|
|
1245
|
+
frame = yield client.frames.get(id, {
|
|
1246
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1247
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1248
|
+
});
|
|
1249
|
+
} catch (err) {
|
|
1250
|
+
printError(err.message, 1);
|
|
1251
|
+
}
|
|
1252
|
+
const fmt = opts.format;
|
|
1253
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1254
|
+
printOutput(frame, { format: fmt });
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
printRecord({
|
|
1258
|
+
ID: frame.id,
|
|
1259
|
+
Title: frame.title,
|
|
1260
|
+
Kind: (_a2 = frame.kind) != null ? _a2 : "(none)",
|
|
1261
|
+
"File Type": frame.fileType,
|
|
1262
|
+
Status: frame.status,
|
|
1263
|
+
Public: frame.isPublic ? "yes" : "no",
|
|
1264
|
+
"Share Token": (_b = frame.shareToken) != null ? _b : "(none)",
|
|
1265
|
+
Description: (_c = frame.description) != null ? _c : "(none)",
|
|
1266
|
+
Updated: frame.updatedAt.slice(0, 10)
|
|
1267
|
+
});
|
|
1268
|
+
})
|
|
1269
|
+
);
|
|
1270
|
+
return frames;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// src/commands/mcp/index.ts
|
|
1274
|
+
import { Command as Command11 } from "commander";
|
|
1275
|
+
function buildMcpCommand() {
|
|
1276
|
+
const mcp = new Command11("mcp").description(
|
|
1277
|
+
"Manage MCP servers and configurations"
|
|
1278
|
+
);
|
|
1279
|
+
mcp.command("servers").description("List accessible MCP servers (system + custom)").option("--org <slug>", "Organization context").option("--personal", "Personal context").option(
|
|
1280
|
+
"--format <format>",
|
|
1281
|
+
"Output format: table|json|yaml|csv",
|
|
1282
|
+
"table"
|
|
1283
|
+
).option("-q, --quiet", "Print server keys only").action(
|
|
1284
|
+
(opts) => __async(null, null, function* () {
|
|
1285
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1286
|
+
const client = getClient();
|
|
1287
|
+
let list;
|
|
1288
|
+
try {
|
|
1289
|
+
list = yield client.mcp.listServers({
|
|
1290
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1291
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1292
|
+
});
|
|
1293
|
+
} catch (err) {
|
|
1294
|
+
printError(err.message, 1);
|
|
1295
|
+
}
|
|
1296
|
+
if (opts.quiet) {
|
|
1297
|
+
for (const s of list) {
|
|
1298
|
+
process.stdout.write(`${s.key}
|
|
1299
|
+
`);
|
|
1300
|
+
}
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
printOutput(list, {
|
|
1304
|
+
format: opts.format,
|
|
1305
|
+
columns: [
|
|
1306
|
+
"key",
|
|
1307
|
+
"name",
|
|
1308
|
+
"transport",
|
|
1309
|
+
"category",
|
|
1310
|
+
"isSystemProvided"
|
|
1311
|
+
]
|
|
1312
|
+
});
|
|
1313
|
+
})
|
|
1314
|
+
);
|
|
1315
|
+
const configs = new Command11("configs").description(
|
|
1316
|
+
"Manage MCP configurations"
|
|
1317
|
+
);
|
|
1318
|
+
configs.command("list", { isDefault: true }).description("List your MCP configurations").option("--org <slug>", "Organization context").option("--personal", "Personal context").option(
|
|
1319
|
+
"--format <format>",
|
|
1320
|
+
"Output format: table|json|yaml|csv",
|
|
1321
|
+
"table"
|
|
1322
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1323
|
+
(opts) => __async(null, null, function* () {
|
|
1324
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1325
|
+
const client = getClient();
|
|
1326
|
+
let list;
|
|
1327
|
+
try {
|
|
1328
|
+
list = yield client.mcp.listConfigs({
|
|
1329
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1330
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1331
|
+
});
|
|
1332
|
+
} catch (err) {
|
|
1333
|
+
printError(err.message, 1);
|
|
1334
|
+
}
|
|
1335
|
+
if (opts.quiet) {
|
|
1336
|
+
for (const c of list) {
|
|
1337
|
+
process.stdout.write(`${c.id}
|
|
1338
|
+
`);
|
|
1339
|
+
}
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
printOutput(list, {
|
|
1343
|
+
format: opts.format,
|
|
1344
|
+
columns: [
|
|
1345
|
+
"id",
|
|
1346
|
+
"serverName",
|
|
1347
|
+
"displayName",
|
|
1348
|
+
"authType",
|
|
1349
|
+
"enabled",
|
|
1350
|
+
"status"
|
|
1351
|
+
]
|
|
1352
|
+
});
|
|
1353
|
+
})
|
|
1354
|
+
);
|
|
1355
|
+
configs.command("show <id>").description("Show a specific MCP configuration").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1356
|
+
(id, opts) => __async(null, null, function* () {
|
|
1357
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1358
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1359
|
+
const client = getClient();
|
|
1360
|
+
let config2;
|
|
1361
|
+
try {
|
|
1362
|
+
config2 = yield client.mcp.getConfig(id, {
|
|
1363
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1364
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1365
|
+
});
|
|
1366
|
+
} catch (err) {
|
|
1367
|
+
printError(err.message, 1);
|
|
1368
|
+
}
|
|
1369
|
+
const fmt = opts.format;
|
|
1370
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1371
|
+
printOutput(config2, { format: fmt });
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
printRecord({
|
|
1375
|
+
ID: config2.id,
|
|
1376
|
+
Server: (_a2 = config2.serverName) != null ? _a2 : config2.mcpServerId,
|
|
1377
|
+
"Server Key": (_b = config2.serverKey) != null ? _b : "(none)",
|
|
1378
|
+
"Display Name": (_c = config2.displayName) != null ? _c : "(none)",
|
|
1379
|
+
"Base URL": (_d = config2.baseUrl) != null ? _d : "(none)",
|
|
1380
|
+
Transport: (_e = config2.transport) != null ? _e : "(default)",
|
|
1381
|
+
"Auth Type": config2.authType,
|
|
1382
|
+
Enabled: config2.enabled ? "yes" : "no",
|
|
1383
|
+
Status: config2.status,
|
|
1384
|
+
"Last Health Check": (_g = (_f = config2.lastHealthCheckAt) == null ? void 0 : _f.slice(0, 19)) != null ? _g : "(never)",
|
|
1385
|
+
Created: config2.createdAt.slice(0, 10)
|
|
1386
|
+
});
|
|
1387
|
+
})
|
|
1388
|
+
);
|
|
1389
|
+
configs.command("delete <id>").description("Delete an MCP configuration").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("-y, --yes", "Skip confirmation prompt").action(
|
|
1390
|
+
(id, opts) => __async(null, null, function* () {
|
|
1391
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1392
|
+
const client = getClient();
|
|
1393
|
+
if (!opts.yes) {
|
|
1394
|
+
process.stderr.write(
|
|
1395
|
+
`Delete MCP config ${id}? This cannot be undone. Pass --yes to confirm.
|
|
1396
|
+
`
|
|
1397
|
+
);
|
|
1398
|
+
process.exit(2);
|
|
1399
|
+
}
|
|
1400
|
+
try {
|
|
1401
|
+
yield client.mcp.deleteConfig(id, {
|
|
1402
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1403
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1404
|
+
});
|
|
1405
|
+
} catch (err) {
|
|
1406
|
+
printError(err.message, 1);
|
|
1407
|
+
}
|
|
1408
|
+
process.stdout.write(`MCP config ${id} deleted.
|
|
1409
|
+
`);
|
|
1410
|
+
})
|
|
1411
|
+
);
|
|
1412
|
+
mcp.addCommand(configs);
|
|
1413
|
+
mcp.command("serve").description(
|
|
1414
|
+
"Run a stdio MCP server exposing this workspace's whole integration catalog. Point Claude Desktop, Cursor, or any MCP client at it."
|
|
1415
|
+
).action(() => __async(null, null, function* () {
|
|
1416
|
+
const { runStdio } = yield import("@fabricorg/sdk-mcp/stdio");
|
|
1417
|
+
yield runStdio();
|
|
1418
|
+
}));
|
|
1419
|
+
return mcp;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// src/commands/orgs/index.ts
|
|
1423
|
+
import { Command as Command12 } from "commander";
|
|
1424
|
+
function buildOrgsCommand() {
|
|
1425
|
+
const orgs = new Command12("orgs").description("Manage organizations");
|
|
1426
|
+
orgs.command("list").description("List organizations you belong to").option(
|
|
1427
|
+
"--format <format>",
|
|
1428
|
+
"Output format: table|json|yaml|csv",
|
|
1429
|
+
"table"
|
|
1430
|
+
).option("-q, --quiet", "Print slugs only").action((opts) => __async(null, null, function* () {
|
|
1431
|
+
const client = getClient();
|
|
1432
|
+
let list;
|
|
1433
|
+
try {
|
|
1434
|
+
list = yield client.orgs.list();
|
|
1435
|
+
} catch (err) {
|
|
1436
|
+
printError(err.message, 1);
|
|
1437
|
+
}
|
|
1438
|
+
if (opts.quiet) {
|
|
1439
|
+
for (const org of list) {
|
|
1440
|
+
process.stdout.write(`${org.slug}
|
|
1441
|
+
`);
|
|
1442
|
+
}
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
printOutput(list, {
|
|
1446
|
+
format: opts.format,
|
|
1447
|
+
columns: ["name", "slug", "role", "joinedAt"]
|
|
1448
|
+
});
|
|
1449
|
+
}));
|
|
1450
|
+
orgs.command("show <slug>").description("Show details for an organization").option("--format <format>", "Output format: table|json|yaml", "table").action((slug, opts) => __async(null, null, function* () {
|
|
1451
|
+
var _a2;
|
|
1452
|
+
const client = getClient();
|
|
1453
|
+
let list;
|
|
1454
|
+
try {
|
|
1455
|
+
list = yield client.orgs.list();
|
|
1456
|
+
} catch (err) {
|
|
1457
|
+
printError(err.message, 1);
|
|
1458
|
+
}
|
|
1459
|
+
const org = list.find(
|
|
1460
|
+
(o) => o.slug === slug || o.id === slug
|
|
1461
|
+
);
|
|
1462
|
+
if (!org) {
|
|
1463
|
+
printError(`Organization not found: ${slug}`, 4);
|
|
1464
|
+
}
|
|
1465
|
+
const fmt = opts.format;
|
|
1466
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1467
|
+
printOutput(org, { format: fmt });
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
printRecord({
|
|
1471
|
+
Name: org.name,
|
|
1472
|
+
Slug: org.slug,
|
|
1473
|
+
Role: org.role,
|
|
1474
|
+
"Joined at": String(org.joinedAt).slice(0, 10),
|
|
1475
|
+
Logo: (_a2 = org.logo) != null ? _a2 : "(none)"
|
|
1476
|
+
});
|
|
1477
|
+
}));
|
|
1478
|
+
return orgs;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// src/commands/projects/index.ts
|
|
1482
|
+
import { Command as Command13 } from "commander";
|
|
1483
|
+
function buildProjectsCommand() {
|
|
1484
|
+
const projects = new Command13("projects").description("Manage projects");
|
|
1485
|
+
projects.command("list").description("List projects").option("--org <slug>", "Organization context").option("--personal", "Personal context").option(
|
|
1486
|
+
"--status <status>",
|
|
1487
|
+
"Filter by status: ACTIVE|DRAFT|COMPLETED|ARCHIVED"
|
|
1488
|
+
).option("--search <query>", "Search by name").option("--limit <n>", "Max results (default 20)", "20").option(
|
|
1489
|
+
"--format <format>",
|
|
1490
|
+
"Output format: table|json|yaml|csv",
|
|
1491
|
+
"table"
|
|
1492
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1493
|
+
(opts) => __async(null, null, function* () {
|
|
1494
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1495
|
+
const client = getClient();
|
|
1496
|
+
let list;
|
|
1497
|
+
try {
|
|
1498
|
+
list = yield client.projects.list({
|
|
1499
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1500
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1501
|
+
status: opts.status,
|
|
1502
|
+
search: opts.search,
|
|
1503
|
+
limit: Number(opts.limit)
|
|
1504
|
+
});
|
|
1505
|
+
} catch (err) {
|
|
1506
|
+
printError(err.message, 1);
|
|
1507
|
+
}
|
|
1508
|
+
if (opts.quiet) {
|
|
1509
|
+
for (const p of list) {
|
|
1510
|
+
process.stdout.write(`${p.id}
|
|
1511
|
+
`);
|
|
1512
|
+
}
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
printOutput(list, {
|
|
1516
|
+
format: opts.format,
|
|
1517
|
+
columns: ["id", "name", "status", "createdAt"]
|
|
1518
|
+
});
|
|
1519
|
+
})
|
|
1520
|
+
);
|
|
1521
|
+
projects.command("show <id>").description("Show project details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1522
|
+
(id, opts) => __async(null, null, function* () {
|
|
1523
|
+
var _a2, _b;
|
|
1524
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1525
|
+
const client = getClient();
|
|
1526
|
+
let project;
|
|
1527
|
+
try {
|
|
1528
|
+
project = yield client.projects.get(id, {
|
|
1529
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1530
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1531
|
+
});
|
|
1532
|
+
} catch (err) {
|
|
1533
|
+
printError(err.message, 1);
|
|
1534
|
+
}
|
|
1535
|
+
const fmt = opts.format;
|
|
1536
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1537
|
+
printOutput(project, { format: fmt });
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
printRecord({
|
|
1541
|
+
ID: project.id,
|
|
1542
|
+
Name: project.name,
|
|
1543
|
+
Status: project.status,
|
|
1544
|
+
Description: (_a2 = project.description) != null ? _a2 : "(none)",
|
|
1545
|
+
Repository: (_b = project.repositoryUrl) != null ? _b : "(none)",
|
|
1546
|
+
Created: project.createdAt.slice(0, 10)
|
|
1547
|
+
});
|
|
1548
|
+
})
|
|
1549
|
+
);
|
|
1550
|
+
projects.command("create <name>").description("Create a new project").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("-d, --description <text>", "Project description").option("--repo <url>", "Repository URL").option(
|
|
1551
|
+
"--status <status>",
|
|
1552
|
+
"Initial status: DRAFT|ACTIVE (default: DRAFT)",
|
|
1553
|
+
"DRAFT"
|
|
1554
|
+
).option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1555
|
+
(name, opts) => __async(null, null, function* () {
|
|
1556
|
+
var _a2;
|
|
1557
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1558
|
+
const client = getClient();
|
|
1559
|
+
let project;
|
|
1560
|
+
try {
|
|
1561
|
+
project = yield client.projects.create({
|
|
1562
|
+
name,
|
|
1563
|
+
description: opts.description,
|
|
1564
|
+
repositoryUrl: opts.repo,
|
|
1565
|
+
status: opts.status,
|
|
1566
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1567
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1568
|
+
});
|
|
1569
|
+
} catch (err) {
|
|
1570
|
+
printError(err.message, 1);
|
|
1571
|
+
}
|
|
1572
|
+
const fmt = opts.format;
|
|
1573
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1574
|
+
printOutput(project, { format: fmt });
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
printSuccess(`Project "${project.name}" created`);
|
|
1578
|
+
printRecord({
|
|
1579
|
+
ID: project.id,
|
|
1580
|
+
Name: project.name,
|
|
1581
|
+
Status: project.status,
|
|
1582
|
+
Description: (_a2 = project.description) != null ? _a2 : "(none)",
|
|
1583
|
+
Created: project.createdAt.slice(0, 10)
|
|
1584
|
+
});
|
|
1585
|
+
})
|
|
1586
|
+
);
|
|
1587
|
+
projects.command("update <id>").description("Update a project").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--name <name>", "New name").option("-d, --description <text>", "New description").option("--repo <url>", "Repository URL").option("--status <status>", "Status: DRAFT|ACTIVE|COMPLETED|ARCHIVED").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1588
|
+
(id, opts) => __async(null, null, function* () {
|
|
1589
|
+
var _a2;
|
|
1590
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1591
|
+
const client = getClient();
|
|
1592
|
+
let project;
|
|
1593
|
+
try {
|
|
1594
|
+
project = yield client.projects.update(id, {
|
|
1595
|
+
name: opts.name,
|
|
1596
|
+
description: opts.description,
|
|
1597
|
+
repositoryUrl: opts.repo,
|
|
1598
|
+
status: opts.status,
|
|
1599
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1600
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1601
|
+
});
|
|
1602
|
+
} catch (err) {
|
|
1603
|
+
printError(err.message, 1);
|
|
1604
|
+
}
|
|
1605
|
+
const fmt = opts.format;
|
|
1606
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1607
|
+
printOutput(project, { format: fmt });
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
printRecord({
|
|
1611
|
+
ID: project.id,
|
|
1612
|
+
Name: project.name,
|
|
1613
|
+
Status: project.status,
|
|
1614
|
+
Description: (_a2 = project.description) != null ? _a2 : "(none)",
|
|
1615
|
+
Updated: project.updatedAt.slice(0, 10)
|
|
1616
|
+
});
|
|
1617
|
+
})
|
|
1618
|
+
);
|
|
1619
|
+
return projects;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
// src/commands/prompts/index.ts
|
|
1623
|
+
import { Command as Command14 } from "commander";
|
|
1624
|
+
function buildPromptsCommand() {
|
|
1625
|
+
const prompts = new Command14("prompts").description(
|
|
1626
|
+
"Manage prompt templates"
|
|
1627
|
+
);
|
|
1628
|
+
prompts.command("list").description("List prompt templates").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--search <query>", "Search by name").option("--category <cat>", "Filter by category").option("--limit <n>", "Max results", "50").option(
|
|
1629
|
+
"--format <format>",
|
|
1630
|
+
"Output format: table|json|yaml|csv",
|
|
1631
|
+
"table"
|
|
1632
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1633
|
+
(opts) => __async(null, null, function* () {
|
|
1634
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1635
|
+
const client = getClient();
|
|
1636
|
+
let list;
|
|
1637
|
+
try {
|
|
1638
|
+
list = yield client.prompts.list({
|
|
1639
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1640
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1641
|
+
search: opts.search,
|
|
1642
|
+
category: opts.category,
|
|
1643
|
+
limit: Number(opts.limit)
|
|
1644
|
+
});
|
|
1645
|
+
} catch (err) {
|
|
1646
|
+
printError(err.message, 1);
|
|
1647
|
+
}
|
|
1648
|
+
if (opts.quiet) {
|
|
1649
|
+
for (const p of list) {
|
|
1650
|
+
process.stdout.write(`${p.id}
|
|
1651
|
+
`);
|
|
1652
|
+
}
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
printOutput(list, {
|
|
1656
|
+
format: opts.format,
|
|
1657
|
+
columns: [
|
|
1658
|
+
"id",
|
|
1659
|
+
"key",
|
|
1660
|
+
"name",
|
|
1661
|
+
"scope",
|
|
1662
|
+
"category",
|
|
1663
|
+
"updatedAt"
|
|
1664
|
+
]
|
|
1665
|
+
});
|
|
1666
|
+
})
|
|
1667
|
+
);
|
|
1668
|
+
prompts.command("get <id>").description("Get a prompt (prints latest version content by default)").option("--org <slug>", "Organization context").option("--personal", "Personal context").option(
|
|
1669
|
+
"--format <format>",
|
|
1670
|
+
"Output format: raw|table|json|yaml (default: raw)",
|
|
1671
|
+
"raw"
|
|
1672
|
+
).action(
|
|
1673
|
+
(id, opts) => __async(null, null, function* () {
|
|
1674
|
+
var _a2, _b, _c, _d, _e;
|
|
1675
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1676
|
+
const client = getClient();
|
|
1677
|
+
let prompt;
|
|
1678
|
+
try {
|
|
1679
|
+
prompt = yield client.prompts.get(id, {
|
|
1680
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1681
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1682
|
+
});
|
|
1683
|
+
} catch (err) {
|
|
1684
|
+
printError(err.message, 1);
|
|
1685
|
+
}
|
|
1686
|
+
const fmt = opts.format;
|
|
1687
|
+
if (fmt === "json") {
|
|
1688
|
+
printOutput(prompt, { format: "json" });
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
if (fmt === "yaml") {
|
|
1692
|
+
printOutput(prompt, { format: "yaml" });
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
const content = (_c = (_b = (_a2 = prompt.versions) == null ? void 0 : _a2[0]) == null ? void 0 : _b.content) != null ? _c : "(no content)";
|
|
1696
|
+
if (fmt === "raw") {
|
|
1697
|
+
process.stdout.write(`${content}
|
|
1698
|
+
`);
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
printRecord({
|
|
1702
|
+
ID: prompt.id,
|
|
1703
|
+
Key: prompt.key,
|
|
1704
|
+
Name: prompt.name,
|
|
1705
|
+
Scope: prompt.scope,
|
|
1706
|
+
Category: (_d = prompt.category) != null ? _d : "(none)",
|
|
1707
|
+
Tags: ((_e = prompt.tags) != null ? _e : []).join(", ") || "(none)"
|
|
1708
|
+
});
|
|
1709
|
+
process.stdout.write(`
|
|
1710
|
+
--- Content ---
|
|
1711
|
+
${content}
|
|
1712
|
+
`);
|
|
1713
|
+
})
|
|
1714
|
+
);
|
|
1715
|
+
prompts.command("create").description("Create a new prompt").option("--org <slug>", "Organization context").option("--personal", "Personal context").requiredOption("--key <key>", "Prompt key (unique identifier)").requiredOption("--name <name>", "Prompt name").option("-d, --description <text>", "Prompt description").option("--content <text>", "Initial prompt content").option("--category <cat>", "Category").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1716
|
+
(opts) => __async(null, null, function* () {
|
|
1717
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1718
|
+
const client = getClient();
|
|
1719
|
+
let prompt;
|
|
1720
|
+
try {
|
|
1721
|
+
prompt = yield client.prompts.create({
|
|
1722
|
+
key: opts.key,
|
|
1723
|
+
name: opts.name,
|
|
1724
|
+
description: opts.description,
|
|
1725
|
+
content: opts.content,
|
|
1726
|
+
category: opts.category,
|
|
1727
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1728
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1729
|
+
});
|
|
1730
|
+
} catch (err) {
|
|
1731
|
+
printError(err.message, 1);
|
|
1732
|
+
}
|
|
1733
|
+
const fmt = opts.format;
|
|
1734
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1735
|
+
printOutput(prompt, { format: fmt });
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
printSuccess(`Prompt "${prompt.name}" created`);
|
|
1739
|
+
printRecord({
|
|
1740
|
+
ID: prompt.id,
|
|
1741
|
+
Key: prompt.key,
|
|
1742
|
+
Name: prompt.name,
|
|
1743
|
+
Scope: prompt.scope,
|
|
1744
|
+
Created: prompt.createdAt.slice(0, 10)
|
|
1745
|
+
});
|
|
1746
|
+
})
|
|
1747
|
+
);
|
|
1748
|
+
prompts.command("update <id>").description("Update a prompt").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--name <name>", "New name").option("-d, --description <text>", "New description").option("--category <cat>", "Category").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1749
|
+
(id, opts) => __async(null, null, function* () {
|
|
1750
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1751
|
+
const client = getClient();
|
|
1752
|
+
let prompt;
|
|
1753
|
+
try {
|
|
1754
|
+
prompt = yield client.prompts.update(id, {
|
|
1755
|
+
name: opts.name,
|
|
1756
|
+
description: opts.description,
|
|
1757
|
+
category: opts.category,
|
|
1758
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1759
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1760
|
+
});
|
|
1761
|
+
} catch (err) {
|
|
1762
|
+
printError(err.message, 1);
|
|
1763
|
+
}
|
|
1764
|
+
const fmt = opts.format;
|
|
1765
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1766
|
+
printOutput(prompt, { format: fmt });
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
printRecord({
|
|
1770
|
+
ID: prompt.id,
|
|
1771
|
+
Key: prompt.key,
|
|
1772
|
+
Name: prompt.name,
|
|
1773
|
+
Scope: prompt.scope,
|
|
1774
|
+
Updated: prompt.updatedAt.slice(0, 10)
|
|
1775
|
+
});
|
|
1776
|
+
})
|
|
1777
|
+
);
|
|
1778
|
+
return prompts;
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
// src/commands/reports/index.ts
|
|
1782
|
+
import { Command as Command15 } from "commander";
|
|
1783
|
+
function buildReportsCommand() {
|
|
1784
|
+
const reports = new Command15("reports").description(
|
|
1785
|
+
"Manage report templates and executions"
|
|
1786
|
+
);
|
|
1787
|
+
const templates = new Command15("templates").description(
|
|
1788
|
+
"Manage report templates"
|
|
1789
|
+
);
|
|
1790
|
+
templates.command("list", { isDefault: true }).description("List report templates").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--search <query>", "Search by name").option("--category <cat>", "Filter by category").option("--limit <n>", "Max results (default 20)", "20").option(
|
|
1791
|
+
"--format <format>",
|
|
1792
|
+
"Output format: table|json|yaml|csv",
|
|
1793
|
+
"table"
|
|
1794
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1795
|
+
(opts) => __async(null, null, function* () {
|
|
1796
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1797
|
+
const client = getClient();
|
|
1798
|
+
let list;
|
|
1799
|
+
try {
|
|
1800
|
+
list = yield client.reports.listTemplates({
|
|
1801
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1802
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1803
|
+
search: opts.search,
|
|
1804
|
+
category: opts.category,
|
|
1805
|
+
limit: Number(opts.limit)
|
|
1806
|
+
});
|
|
1807
|
+
} catch (err) {
|
|
1808
|
+
printError(err.message, 1);
|
|
1809
|
+
}
|
|
1810
|
+
if (opts.quiet) {
|
|
1811
|
+
for (const t of list) {
|
|
1812
|
+
process.stdout.write(`${t.id}
|
|
1813
|
+
`);
|
|
1814
|
+
}
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
printOutput(list, {
|
|
1818
|
+
format: opts.format,
|
|
1819
|
+
columns: [
|
|
1820
|
+
"id",
|
|
1821
|
+
"name",
|
|
1822
|
+
"templateType",
|
|
1823
|
+
"scope",
|
|
1824
|
+
"usageCount"
|
|
1825
|
+
]
|
|
1826
|
+
});
|
|
1827
|
+
})
|
|
1828
|
+
);
|
|
1829
|
+
templates.command("show <id>").description("Show report template details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
1830
|
+
(id, opts) => __async(null, null, function* () {
|
|
1831
|
+
var _a2, _b;
|
|
1832
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1833
|
+
const client = getClient();
|
|
1834
|
+
let tmpl;
|
|
1835
|
+
try {
|
|
1836
|
+
tmpl = yield client.reports.getTemplate(id, {
|
|
1837
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1838
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
1839
|
+
});
|
|
1840
|
+
} catch (err) {
|
|
1841
|
+
printError(err.message, 1);
|
|
1842
|
+
}
|
|
1843
|
+
const fmt = opts.format;
|
|
1844
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1845
|
+
printOutput(tmpl, { format: fmt });
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
printRecord({
|
|
1849
|
+
ID: tmpl.id,
|
|
1850
|
+
Name: tmpl.name,
|
|
1851
|
+
Type: tmpl.templateType,
|
|
1852
|
+
Scope: tmpl.scope,
|
|
1853
|
+
Category: (_a2 = tmpl.category) != null ? _a2 : "(none)",
|
|
1854
|
+
Tags: tmpl.tags.join(", ") || "(none)",
|
|
1855
|
+
Public: tmpl.isPublic ? "yes" : "no",
|
|
1856
|
+
"Use Count": String(tmpl.usageCount),
|
|
1857
|
+
Description: (_b = tmpl.description) != null ? _b : "(none)",
|
|
1858
|
+
Updated: tmpl.updatedAt.slice(0, 10)
|
|
1859
|
+
});
|
|
1860
|
+
})
|
|
1861
|
+
);
|
|
1862
|
+
reports.addCommand(templates);
|
|
1863
|
+
const executions = new Command15("executions").description(
|
|
1864
|
+
"View report executions"
|
|
1865
|
+
);
|
|
1866
|
+
executions.command("list", { isDefault: true }).description("List report executions").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--limit <n>", "Max results (default 20)", "20").option(
|
|
1867
|
+
"--format <format>",
|
|
1868
|
+
"Output format: table|json|yaml|csv",
|
|
1869
|
+
"table"
|
|
1870
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1871
|
+
(opts) => __async(null, null, function* () {
|
|
1872
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1873
|
+
const client = getClient();
|
|
1874
|
+
let list;
|
|
1875
|
+
try {
|
|
1876
|
+
list = yield client.reports.listExecutions({
|
|
1877
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1878
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1879
|
+
limit: Number(opts.limit)
|
|
1880
|
+
});
|
|
1881
|
+
} catch (err) {
|
|
1882
|
+
printError(err.message, 1);
|
|
1883
|
+
}
|
|
1884
|
+
if (opts.quiet) {
|
|
1885
|
+
for (const e of list) {
|
|
1886
|
+
process.stdout.write(`${e.id}
|
|
1887
|
+
`);
|
|
1888
|
+
}
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
printOutput(list, {
|
|
1892
|
+
format: opts.format,
|
|
1893
|
+
columns: [
|
|
1894
|
+
"id",
|
|
1895
|
+
"templateId",
|
|
1896
|
+
"status",
|
|
1897
|
+
"startedAt",
|
|
1898
|
+
"completedAt"
|
|
1899
|
+
]
|
|
1900
|
+
});
|
|
1901
|
+
})
|
|
1902
|
+
);
|
|
1903
|
+
reports.addCommand(executions);
|
|
1904
|
+
return reports;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
// src/commands/skills/index.ts
|
|
1908
|
+
import { Command as Command16 } from "commander";
|
|
1909
|
+
function buildSkillsCommand() {
|
|
1910
|
+
const skills = new Command16("skills").description(
|
|
1911
|
+
"Browse skill definitions"
|
|
1912
|
+
);
|
|
1913
|
+
skills.command("list").description("List skills").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--search <query>", "Search by name").option("--category <cat>", "Filter by category").option("--limit <n>", "Max results", "50").option(
|
|
1914
|
+
"--format <format>",
|
|
1915
|
+
"Output format: table|json|yaml|csv",
|
|
1916
|
+
"table"
|
|
1917
|
+
).option("-q, --quiet", "Print slugs only").action(
|
|
1918
|
+
(opts) => __async(null, null, function* () {
|
|
1919
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1920
|
+
const client = getClient();
|
|
1921
|
+
let list;
|
|
1922
|
+
try {
|
|
1923
|
+
list = yield client.skills.list({
|
|
1924
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1925
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1926
|
+
search: opts.search,
|
|
1927
|
+
category: opts.category,
|
|
1928
|
+
limit: Number(opts.limit)
|
|
1929
|
+
});
|
|
1930
|
+
} catch (err) {
|
|
1931
|
+
printError(err.message, 1);
|
|
1932
|
+
}
|
|
1933
|
+
if (opts.quiet) {
|
|
1934
|
+
for (const s of list) {
|
|
1935
|
+
process.stdout.write(`${s.slug}
|
|
1936
|
+
`);
|
|
1937
|
+
}
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
printOutput(list, {
|
|
1941
|
+
format: opts.format,
|
|
1942
|
+
columns: ["slug", "name", "category", "scope", "useCount"]
|
|
1943
|
+
});
|
|
1944
|
+
})
|
|
1945
|
+
);
|
|
1946
|
+
skills.command("show <id>").description("Show skill details (accepts ID or slug)").option("--format <format>", "Output format: table|json|yaml", "table").action((id, opts) => __async(null, null, function* () {
|
|
1947
|
+
var _a2;
|
|
1948
|
+
const client = getClient();
|
|
1949
|
+
let skill;
|
|
1950
|
+
try {
|
|
1951
|
+
skill = yield client.skills.get(id);
|
|
1952
|
+
} catch (err) {
|
|
1953
|
+
printError(err.message, 1);
|
|
1954
|
+
}
|
|
1955
|
+
const fmt = opts.format;
|
|
1956
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
1957
|
+
printOutput(skill, { format: fmt });
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
printRecord({
|
|
1961
|
+
ID: skill.id,
|
|
1962
|
+
Slug: skill.slug,
|
|
1963
|
+
Name: skill.name,
|
|
1964
|
+
Category: (_a2 = skill.category) != null ? _a2 : "(none)",
|
|
1965
|
+
Scope: skill.scope,
|
|
1966
|
+
Tags: skill.tags.join(", ") || "(none)",
|
|
1967
|
+
Published: skill.isPublished ? "yes" : "no",
|
|
1968
|
+
"Use Count": String(skill.useCount),
|
|
1969
|
+
Version: String(skill.version),
|
|
1970
|
+
Description: skill.description,
|
|
1971
|
+
Updated: skill.updatedAt.slice(0, 10)
|
|
1972
|
+
});
|
|
1973
|
+
}));
|
|
1974
|
+
return skills;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
// src/commands/workflows/index.ts
|
|
1978
|
+
import { Command as Command17 } from "commander";
|
|
1979
|
+
function buildWorkflowsCommand() {
|
|
1980
|
+
const workflows = new Command17("workflows").description("Manage workflows");
|
|
1981
|
+
workflows.command("list").description("List workflows").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--status <status>", "Filter: DRAFT|ACTIVE|PAUSED|ARCHIVED").option("--search <query>", "Search by name").option("--limit <n>", "Max results", "20").option(
|
|
1982
|
+
"--format <format>",
|
|
1983
|
+
"Output format: table|json|yaml|csv",
|
|
1984
|
+
"table"
|
|
1985
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
1986
|
+
(opts) => __async(null, null, function* () {
|
|
1987
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
1988
|
+
const client = getClient();
|
|
1989
|
+
let list;
|
|
1990
|
+
try {
|
|
1991
|
+
list = yield client.workflows.list({
|
|
1992
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
1993
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
1994
|
+
status: opts.status,
|
|
1995
|
+
search: opts.search,
|
|
1996
|
+
limit: Number(opts.limit)
|
|
1997
|
+
});
|
|
1998
|
+
} catch (err) {
|
|
1999
|
+
printError(err.message, 1);
|
|
2000
|
+
}
|
|
2001
|
+
if (opts.quiet) {
|
|
2002
|
+
for (const w of list) {
|
|
2003
|
+
process.stdout.write(`${w.id}
|
|
2004
|
+
`);
|
|
2005
|
+
}
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
2008
|
+
printOutput(list, {
|
|
2009
|
+
format: opts.format,
|
|
2010
|
+
columns: [
|
|
2011
|
+
"id",
|
|
2012
|
+
"name",
|
|
2013
|
+
"status",
|
|
2014
|
+
"triggerType",
|
|
2015
|
+
"createdAt"
|
|
2016
|
+
]
|
|
2017
|
+
});
|
|
2018
|
+
})
|
|
2019
|
+
);
|
|
2020
|
+
workflows.command("show <id>").description("Show workflow details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
2021
|
+
(id, opts) => __async(null, null, function* () {
|
|
2022
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
2023
|
+
const client = getClient();
|
|
2024
|
+
let wf;
|
|
2025
|
+
try {
|
|
2026
|
+
wf = yield client.workflows.get(id, {
|
|
2027
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
2028
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
2029
|
+
});
|
|
2030
|
+
} catch (err) {
|
|
2031
|
+
printError(err.message, 1);
|
|
2032
|
+
}
|
|
2033
|
+
const fmt = opts.format;
|
|
2034
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
2035
|
+
printOutput(wf, { format: fmt });
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
printRecord({
|
|
2039
|
+
ID: wf.id,
|
|
2040
|
+
Name: wf.name,
|
|
2041
|
+
Status: wf.status,
|
|
2042
|
+
Trigger: wf.triggerType,
|
|
2043
|
+
Version: String(wf.version),
|
|
2044
|
+
Created: wf.createdAt.slice(0, 10)
|
|
2045
|
+
});
|
|
2046
|
+
})
|
|
2047
|
+
);
|
|
2048
|
+
workflows.command("trigger <id>").description("Trigger a workflow execution").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--input <json>", "JSON input for triggerData", "{}").option("--vars <json>", "JSON variables", "{}").action(
|
|
2049
|
+
(id, opts) => __async(null, null, function* () {
|
|
2050
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
2051
|
+
const client = getClient();
|
|
2052
|
+
let triggerData = {};
|
|
2053
|
+
let variables = {};
|
|
2054
|
+
try {
|
|
2055
|
+
triggerData = JSON.parse(opts.input);
|
|
2056
|
+
variables = JSON.parse(opts.vars);
|
|
2057
|
+
} catch (e) {
|
|
2058
|
+
printError("--input and --vars must be valid JSON", 2);
|
|
2059
|
+
}
|
|
2060
|
+
let result;
|
|
2061
|
+
try {
|
|
2062
|
+
result = yield client.workflows.trigger(id, {
|
|
2063
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
2064
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
2065
|
+
triggerData,
|
|
2066
|
+
variables
|
|
2067
|
+
});
|
|
2068
|
+
} catch (err) {
|
|
2069
|
+
printError(err.message, 1);
|
|
2070
|
+
}
|
|
2071
|
+
printSuccess("Workflow triggered");
|
|
2072
|
+
process.stdout.write(` Execution ID: ${result.executionId}
|
|
2073
|
+
`);
|
|
2074
|
+
process.stdout.write(` Status: ${result.status}
|
|
2075
|
+
`);
|
|
2076
|
+
})
|
|
2077
|
+
);
|
|
2078
|
+
workflows.command("status <id> <execId>").description("Get workflow execution status").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
2079
|
+
(id, execId, opts) => __async(null, null, function* () {
|
|
2080
|
+
var _a2, _b, _c, _d, _e;
|
|
2081
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
2082
|
+
const client = getClient();
|
|
2083
|
+
let exec;
|
|
2084
|
+
try {
|
|
2085
|
+
exec = yield client.workflows.getExecution(id, execId, {
|
|
2086
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
2087
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
2088
|
+
});
|
|
2089
|
+
} catch (err) {
|
|
2090
|
+
printError(err.message, 1);
|
|
2091
|
+
}
|
|
2092
|
+
const fmt = opts.format;
|
|
2093
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
2094
|
+
printOutput(exec, { format: fmt });
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
printRecord({
|
|
2098
|
+
ID: exec.id,
|
|
2099
|
+
"Workflow ID": exec.workflowId,
|
|
2100
|
+
Status: exec.status,
|
|
2101
|
+
"Trigger type": exec.triggerType,
|
|
2102
|
+
Started: (_b = (_a2 = exec.startedAt) == null ? void 0 : _a2.slice(0, 19)) != null ? _b : "(not started)",
|
|
2103
|
+
Completed: (_d = (_c = exec.completedAt) == null ? void 0 : _c.slice(0, 19)) != null ? _d : "(running)",
|
|
2104
|
+
Error: (_e = exec.error) != null ? _e : "(none)"
|
|
2105
|
+
});
|
|
2106
|
+
})
|
|
2107
|
+
);
|
|
2108
|
+
return workflows;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
// src/commands/workspaces/index.ts
|
|
2112
|
+
import { Command as Command18 } from "commander";
|
|
2113
|
+
function buildWorkspacesCommand() {
|
|
2114
|
+
const workspaces = new Command18("workspaces").description(
|
|
2115
|
+
"Manage workspaces"
|
|
2116
|
+
);
|
|
2117
|
+
workspaces.command("list").description("List workspaces").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--search <query>", "Search by name").option("--status <status>", "Filter: ACTIVE|ARCHIVED").option("--limit <n>", "Max results (default 20)", "20").option(
|
|
2118
|
+
"--format <format>",
|
|
2119
|
+
"Output format: table|json|yaml|csv",
|
|
2120
|
+
"table"
|
|
2121
|
+
).option("-q, --quiet", "Print IDs only").action(
|
|
2122
|
+
(opts) => __async(null, null, function* () {
|
|
2123
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
2124
|
+
const client = getClient();
|
|
2125
|
+
let list;
|
|
2126
|
+
try {
|
|
2127
|
+
list = yield client.workspaces.list({
|
|
2128
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
2129
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0,
|
|
2130
|
+
search: opts.search,
|
|
2131
|
+
status: opts.status,
|
|
2132
|
+
limit: Number(opts.limit)
|
|
2133
|
+
});
|
|
2134
|
+
} catch (err) {
|
|
2135
|
+
printError(err.message, 1);
|
|
2136
|
+
}
|
|
2137
|
+
if (opts.quiet) {
|
|
2138
|
+
for (const w of list) {
|
|
2139
|
+
process.stdout.write(`${w.id}
|
|
2140
|
+
`);
|
|
2141
|
+
}
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
printOutput(list, {
|
|
2145
|
+
format: opts.format,
|
|
2146
|
+
columns: [
|
|
2147
|
+
"id",
|
|
2148
|
+
"name",
|
|
2149
|
+
"type",
|
|
2150
|
+
"status",
|
|
2151
|
+
"documentCount",
|
|
2152
|
+
"updatedAt"
|
|
2153
|
+
]
|
|
2154
|
+
});
|
|
2155
|
+
})
|
|
2156
|
+
);
|
|
2157
|
+
workspaces.command("show <id>").description("Show workspace details").option("--org <slug>", "Organization context").option("--personal", "Personal context").option("--format <format>", "Output format: table|json|yaml", "table").action(
|
|
2158
|
+
(id, opts) => __async(null, null, function* () {
|
|
2159
|
+
var _a2;
|
|
2160
|
+
const ctx = resolveContext(opts.personal, opts.org, false);
|
|
2161
|
+
const client = getClient();
|
|
2162
|
+
let ws;
|
|
2163
|
+
try {
|
|
2164
|
+
ws = yield client.workspaces.get(id, {
|
|
2165
|
+
org: (ctx == null ? void 0 : ctx.type) === "org" ? ctx.slug : void 0,
|
|
2166
|
+
personal: (ctx == null ? void 0 : ctx.type) === "personal" ? true : void 0
|
|
2167
|
+
});
|
|
2168
|
+
} catch (err) {
|
|
2169
|
+
printError(err.message, 1);
|
|
2170
|
+
}
|
|
2171
|
+
const fmt = opts.format;
|
|
2172
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
2173
|
+
printOutput(ws, { format: fmt });
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
printRecord({
|
|
2177
|
+
ID: ws.id,
|
|
2178
|
+
Name: ws.name,
|
|
2179
|
+
Type: ws.type,
|
|
2180
|
+
Status: ws.status,
|
|
2181
|
+
Description: (_a2 = ws.description) != null ? _a2 : "(none)",
|
|
2182
|
+
Documents: String(ws.documentCount),
|
|
2183
|
+
Conversations: String(ws.conversationCount),
|
|
2184
|
+
Updated: ws.updatedAt.slice(0, 10)
|
|
2185
|
+
});
|
|
2186
|
+
})
|
|
2187
|
+
);
|
|
2188
|
+
return workspaces;
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
// src/bin/fabric.ts
|
|
2192
|
+
var program = new Command19();
|
|
2193
|
+
var _a;
|
|
2194
|
+
program.name("fabric").description("Fabric AI platform CLI").version("0.1.0").option(
|
|
2195
|
+
"--format <format>",
|
|
2196
|
+
"Output format: table|json|yaml|csv",
|
|
2197
|
+
(_a = process.env.FABRIC_FORMAT) != null ? _a : "table"
|
|
2198
|
+
);
|
|
2199
|
+
var auth = new Command19("auth").description(
|
|
2200
|
+
"Authenticate and manage API keys"
|
|
2201
|
+
);
|
|
2202
|
+
auth.addCommand(buildLoginCommand());
|
|
2203
|
+
auth.addCommand(buildLogoutCommand());
|
|
2204
|
+
auth.addCommand(buildWhoamiCommand());
|
|
2205
|
+
auth.addCommand(buildKeysCommand());
|
|
2206
|
+
program.addCommand(auth);
|
|
2207
|
+
program.addCommand(buildCtxCommand());
|
|
2208
|
+
program.addCommand(buildOrgsCommand());
|
|
2209
|
+
program.addCommand(buildProjectsCommand());
|
|
2210
|
+
program.addCommand(buildFeaturesCommand());
|
|
2211
|
+
program.addCommand(buildWorkflowsCommand());
|
|
2212
|
+
program.addCommand(buildPromptsCommand());
|
|
2213
|
+
program.addCommand(buildAgentsCommand());
|
|
2214
|
+
program.addCommand(buildSkillsCommand());
|
|
2215
|
+
program.addCommand(buildMcpCommand());
|
|
2216
|
+
program.addCommand(buildFramesCommand());
|
|
2217
|
+
program.addCommand(buildWorkspacesCommand());
|
|
2218
|
+
program.addCommand(buildChatsCommand());
|
|
2219
|
+
program.addCommand(buildReportsCommand());
|
|
2220
|
+
program.addCommand(buildCompletionCommand());
|
|
2221
|
+
var config = new Command19("config").description("Show CLI configuration");
|
|
2222
|
+
config.command("path").description("Print the path to the config file").action(() => {
|
|
2223
|
+
process.stdout.write(`${getConfigPath()}
|
|
2224
|
+
`);
|
|
2225
|
+
});
|
|
2226
|
+
program.addCommand(config);
|
|
2227
|
+
process.on("unhandledRejection", (reason) => {
|
|
2228
|
+
const message = reason instanceof Error ? reason.message : String(reason);
|
|
2229
|
+
if (process.env.FABRIC_FORMAT === "json") {
|
|
2230
|
+
process.stderr.write(
|
|
2231
|
+
JSON.stringify({ error: { message, code: "UNHANDLED_ERROR" } }) + "\n"
|
|
2232
|
+
);
|
|
2233
|
+
} else {
|
|
2234
|
+
process.stderr.write(`\u2717 ${message}
|
|
2235
|
+
`);
|
|
2236
|
+
}
|
|
2237
|
+
process.exit(1);
|
|
2238
|
+
});
|
|
2239
|
+
program.parse(process.argv);
|
|
2240
|
+
//# sourceMappingURL=fabric.js.map
|