@pmate/cli 0.20.3 → 0.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.js +682 -133
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -168,6 +168,14 @@ type QuizCommandArgs = {
|
|
|
168
168
|
apiBaseUrl?: string;
|
|
169
169
|
linkBaseUrl?: string;
|
|
170
170
|
activate: boolean;
|
|
171
|
+
} | {
|
|
172
|
+
type: Command.Quiz;
|
|
173
|
+
action: "update-step";
|
|
174
|
+
paperId: string;
|
|
175
|
+
stepId: string;
|
|
176
|
+
filePath: string;
|
|
177
|
+
apiBaseUrl?: string;
|
|
178
|
+
linkBaseUrl?: string;
|
|
171
179
|
};
|
|
172
180
|
type LinearPrCommandArgs = {
|
|
173
181
|
type: Command.Linear;
|
|
@@ -592,6 +600,7 @@ type ServiceCommandArgs = {
|
|
|
592
600
|
page: number;
|
|
593
601
|
history: boolean;
|
|
594
602
|
search?: string;
|
|
603
|
+
follow: boolean;
|
|
595
604
|
};
|
|
596
605
|
type VercelProjectsCommandArgs = {
|
|
597
606
|
type: Command.Vercel;
|
package/dist/index.js
CHANGED
|
@@ -12712,7 +12712,7 @@ __export(index_exports, {
|
|
|
12712
12712
|
module.exports = __toCommonJS(index_exports);
|
|
12713
12713
|
var import_node_fs16 = require("fs");
|
|
12714
12714
|
var import_node_path21 = __toESM(require("path"));
|
|
12715
|
-
var
|
|
12715
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
12716
12716
|
|
|
12717
12717
|
// src/cli.ts
|
|
12718
12718
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -18370,6 +18370,38 @@ async function appendQuizPaperStep({
|
|
|
18370
18370
|
data
|
|
18371
18371
|
};
|
|
18372
18372
|
}
|
|
18373
|
+
async function updateQuizPaperStep({
|
|
18374
|
+
fetchImpl = fetch,
|
|
18375
|
+
apiBaseUrl,
|
|
18376
|
+
linkBaseUrl,
|
|
18377
|
+
paperId,
|
|
18378
|
+
stepId,
|
|
18379
|
+
step,
|
|
18380
|
+
token
|
|
18381
|
+
}) {
|
|
18382
|
+
const trimmedApiBaseUrl = apiBaseUrl.replace(/\/+$/, "");
|
|
18383
|
+
const trimmedLinkBaseUrl = linkBaseUrl.replace(/\/+$/, "");
|
|
18384
|
+
const previewLink = `${trimmedLinkBaseUrl}/?paper=${encodeURIComponent(paperId)}`;
|
|
18385
|
+
const data = await requestJson(
|
|
18386
|
+
fetchImpl,
|
|
18387
|
+
`${trimmedApiBaseUrl}/api/quiz/papers/${encodeURIComponent(paperId)}/steps/${encodeURIComponent(stepId)}`,
|
|
18388
|
+
{
|
|
18389
|
+
method: "PATCH",
|
|
18390
|
+
headers: {
|
|
18391
|
+
Authorization: `Bearer ${token}`,
|
|
18392
|
+
"Content-Type": "application/json"
|
|
18393
|
+
},
|
|
18394
|
+
body: JSON.stringify(step)
|
|
18395
|
+
},
|
|
18396
|
+
`\u66F4\u65B0\u9898\u76EE\uFF08${stepId}\uFF09`
|
|
18397
|
+
);
|
|
18398
|
+
return {
|
|
18399
|
+
apiBaseUrl: trimmedApiBaseUrl,
|
|
18400
|
+
paperId,
|
|
18401
|
+
previewLink,
|
|
18402
|
+
data
|
|
18403
|
+
};
|
|
18404
|
+
}
|
|
18373
18405
|
async function reorderQuizPaperSteps({
|
|
18374
18406
|
fetchImpl = fetch,
|
|
18375
18407
|
apiBaseUrl,
|
|
@@ -18512,6 +18544,22 @@ var QuizCommandHandler = class {
|
|
|
18512
18544
|
ui.info("stepId", String(step.stepId));
|
|
18513
18545
|
return;
|
|
18514
18546
|
}
|
|
18547
|
+
if (args.action === "update-step") {
|
|
18548
|
+
const resolvedFilePath = import_node_path14.default.resolve(process.cwd(), args.filePath);
|
|
18549
|
+
const step = JSON.parse((0, import_node_fs9.readFileSync)(resolvedFilePath, "utf8"));
|
|
18550
|
+
step.stepId = args.stepId;
|
|
18551
|
+
const result = await updateQuizPaperStep({
|
|
18552
|
+
apiBaseUrl,
|
|
18553
|
+
linkBaseUrl,
|
|
18554
|
+
paperId: args.paperId,
|
|
18555
|
+
stepId: args.stepId,
|
|
18556
|
+
step,
|
|
18557
|
+
token: session.token
|
|
18558
|
+
});
|
|
18559
|
+
ui.success("Quiz \u9898\u76EE\u5DF2\u66F4\u65B0", result.previewLink);
|
|
18560
|
+
ui.info("stepId", args.stepId);
|
|
18561
|
+
return;
|
|
18562
|
+
}
|
|
18515
18563
|
if (args.action === "reorder") {
|
|
18516
18564
|
const result = await reorderQuizPaperSteps({
|
|
18517
18565
|
apiBaseUrl,
|
|
@@ -20017,6 +20065,8 @@ var import_node_fs14 = require("fs");
|
|
|
20017
20065
|
var import_node_os6 = __toESM(require("os"));
|
|
20018
20066
|
var import_node_path19 = __toESM(require("path"));
|
|
20019
20067
|
var import_node_child_process9 = require("child_process");
|
|
20068
|
+
var import_node_readline = require("readline");
|
|
20069
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
20020
20070
|
var ServiceRuntimeRunner = class {
|
|
20021
20071
|
async deploy(service, options = {}) {
|
|
20022
20072
|
switch (service.runtimeType) {
|
|
@@ -20069,6 +20119,61 @@ var ServiceRuntimeRunner = class {
|
|
|
20069
20119
|
ui.title(`Logs for ${namespace}/${appName}`);
|
|
20070
20120
|
ui.info("Source", { mode: options.history ? "history" : "online" });
|
|
20071
20121
|
this.renderPage(page);
|
|
20122
|
+
if (options.follow) {
|
|
20123
|
+
await this.followLogs(namespace, appName, {
|
|
20124
|
+
page: options.page ?? 0,
|
|
20125
|
+
history: options.history ?? false,
|
|
20126
|
+
search: options.search,
|
|
20127
|
+
seedItems: page.data
|
|
20128
|
+
});
|
|
20129
|
+
}
|
|
20130
|
+
}
|
|
20131
|
+
async followLogs(namespace, appName, options) {
|
|
20132
|
+
const recent = [...options.seedItems];
|
|
20133
|
+
const interactive = this.createFollowConsole((state) => {
|
|
20134
|
+
this.renderFollowSnapshot(recent, state);
|
|
20135
|
+
});
|
|
20136
|
+
let running = true;
|
|
20137
|
+
interactive?.rl.on("close", () => {
|
|
20138
|
+
running = false;
|
|
20139
|
+
});
|
|
20140
|
+
const seen = new Set(options.seedItems.map((item) => item.hash));
|
|
20141
|
+
ui.info(
|
|
20142
|
+
"Follow",
|
|
20143
|
+
interactive ? "enabled (poll every 2s, Ctrl+C to stop, /help for filters)" : "enabled (poll every 2s, Ctrl+C to stop)"
|
|
20144
|
+
);
|
|
20145
|
+
interactive?.renderPrompt();
|
|
20146
|
+
while (running) {
|
|
20147
|
+
await this.sleep(2e3);
|
|
20148
|
+
let page;
|
|
20149
|
+
try {
|
|
20150
|
+
page = await this.fetchLogPage(namespace, appName, {
|
|
20151
|
+
page: options.page,
|
|
20152
|
+
history: options.history,
|
|
20153
|
+
search: options.search
|
|
20154
|
+
});
|
|
20155
|
+
} catch (error) {
|
|
20156
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
20157
|
+
ui.warn("Follow fetch failed", { message });
|
|
20158
|
+
continue;
|
|
20159
|
+
}
|
|
20160
|
+
const newItems = page.data.filter((item) => !seen.has(item.hash));
|
|
20161
|
+
if (newItems.length === 0) {
|
|
20162
|
+
continue;
|
|
20163
|
+
}
|
|
20164
|
+
const ordered = [...newItems].reverse();
|
|
20165
|
+
for (const item of ordered) {
|
|
20166
|
+
seen.add(item.hash);
|
|
20167
|
+
recent.unshift(item);
|
|
20168
|
+
if (recent.length > 200) {
|
|
20169
|
+
recent.pop();
|
|
20170
|
+
}
|
|
20171
|
+
if (this.matchFollowFilter(item, interactive?.state)) {
|
|
20172
|
+
ui.plain(this.renderLogLine(item));
|
|
20173
|
+
interactive?.renderPrompt();
|
|
20174
|
+
}
|
|
20175
|
+
}
|
|
20176
|
+
}
|
|
20072
20177
|
}
|
|
20073
20178
|
getDeploy(service) {
|
|
20074
20179
|
return service.deploy ?? {};
|
|
@@ -20333,6 +20438,14 @@ var ServiceRuntimeRunner = class {
|
|
|
20333
20438
|
headers: { Accept: "application/json" }
|
|
20334
20439
|
});
|
|
20335
20440
|
const payload = await response.json();
|
|
20441
|
+
if (response.status === 404 && /resource not found/i.test(payload.message || "")) {
|
|
20442
|
+
return {
|
|
20443
|
+
page: options.page,
|
|
20444
|
+
totalPage: 0,
|
|
20445
|
+
pageSize: 100,
|
|
20446
|
+
data: []
|
|
20447
|
+
};
|
|
20448
|
+
}
|
|
20336
20449
|
if (!response.ok || !payload.success || !payload.data) {
|
|
20337
20450
|
throw new Error(payload.message || `Log request failed: ${response.status}`);
|
|
20338
20451
|
}
|
|
@@ -20346,9 +20459,391 @@ var ServiceRuntimeRunner = class {
|
|
|
20346
20459
|
items: page.data.length
|
|
20347
20460
|
});
|
|
20348
20461
|
for (const item of page.data) {
|
|
20349
|
-
|
|
20350
|
-
|
|
20462
|
+
ui.plain(this.renderLogLine(item));
|
|
20463
|
+
}
|
|
20464
|
+
}
|
|
20465
|
+
renderLogLine(item) {
|
|
20466
|
+
const ts = import_chalk3.default.white(new Date(item.time).toISOString());
|
|
20467
|
+
const resolvedLevel = this.resolveItemLevel(item);
|
|
20468
|
+
const isErrorLike = resolvedLevel === "error" || /error|failed/i.test(item.type);
|
|
20469
|
+
const type = isErrorLike ? import_chalk3.default.bold.red(`[${item.type}]`) : import_chalk3.default.bold.blue(`[${item.type}]`);
|
|
20470
|
+
const level = resolvedLevel ? `${isErrorLike ? import_chalk3.default.bold.red(resolvedLevel.toUpperCase()) : import_chalk3.default.bold.yellow(resolvedLevel.toUpperCase())} ` : "";
|
|
20471
|
+
const data = this.formatLogData(item.data);
|
|
20472
|
+
const hash = import_chalk3.default.gray(`#${item.hash}`);
|
|
20473
|
+
return `${ts} ${level}${type} ${data} ${hash}`;
|
|
20474
|
+
}
|
|
20475
|
+
formatLogData(value) {
|
|
20476
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
20477
|
+
return import_chalk3.default.gray(this.formatAnyValue(value));
|
|
20478
|
+
}
|
|
20479
|
+
const objectValue = value;
|
|
20480
|
+
const entries = Object.entries(objectValue);
|
|
20481
|
+
if (entries.length === 0) {
|
|
20482
|
+
return "{}";
|
|
20483
|
+
}
|
|
20484
|
+
const body = entries.map(([key, item]) => `${import_chalk3.default.bold.white(key)}: ${import_chalk3.default.gray(this.formatAnyValue(item))}`).join(", ");
|
|
20485
|
+
return `{ ${body} }`;
|
|
20486
|
+
}
|
|
20487
|
+
formatAnyValue(value) {
|
|
20488
|
+
if (typeof value === "string") {
|
|
20489
|
+
return value;
|
|
20490
|
+
}
|
|
20491
|
+
if (typeof value === "number" || typeof value === "boolean" || value === null) {
|
|
20492
|
+
return String(value);
|
|
20493
|
+
}
|
|
20494
|
+
try {
|
|
20495
|
+
return JSON.stringify(value);
|
|
20496
|
+
} catch {
|
|
20497
|
+
return String(value);
|
|
20498
|
+
}
|
|
20499
|
+
}
|
|
20500
|
+
createFollowConsole(onFilterChanged) {
|
|
20501
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
20502
|
+
return void 0;
|
|
20503
|
+
}
|
|
20504
|
+
const state = {};
|
|
20505
|
+
const rl = (0, import_node_readline.createInterface)({
|
|
20506
|
+
input: process.stdin,
|
|
20507
|
+
output: process.stdout,
|
|
20508
|
+
terminal: true
|
|
20509
|
+
});
|
|
20510
|
+
const renderPrompt = () => {
|
|
20511
|
+
const hints = [];
|
|
20512
|
+
if (state.search) hints.push(`search=${state.search}`);
|
|
20513
|
+
if (state.type) hints.push(`type=${state.type}`);
|
|
20514
|
+
if (state.level) hints.push(`level=${state.level}`);
|
|
20515
|
+
if (state.whereExpr) hints.push(`where=${state.whereExpr}`);
|
|
20516
|
+
const suffix = hints.length ? ` (${hints.join(", ")})` : "";
|
|
20517
|
+
rl.setPrompt(import_chalk3.default.gray(`filter>${suffix} `));
|
|
20518
|
+
rl.prompt();
|
|
20519
|
+
};
|
|
20520
|
+
rl.on("line", (raw) => {
|
|
20521
|
+
const line = raw.trim();
|
|
20522
|
+
if (!line) {
|
|
20523
|
+
renderPrompt();
|
|
20524
|
+
return;
|
|
20525
|
+
}
|
|
20526
|
+
if (line === "/help") {
|
|
20527
|
+
ui.info("Follow commands", [
|
|
20528
|
+
"/search <text> set keyword filter on event + payload",
|
|
20529
|
+
"/type <event> set event type filter",
|
|
20530
|
+
"/level <lvl> set level filter (debug|info|warn|error)",
|
|
20531
|
+
"<text> wildcard match on event + payload (equivalent to *text*)",
|
|
20532
|
+
"<expr> set JSON field filter (supports &&, ||, ())",
|
|
20533
|
+
" e.g. datamode=prompt && (type=task_end || level=error)",
|
|
20534
|
+
"/clear clear all filters",
|
|
20535
|
+
"/quit exit follow mode"
|
|
20536
|
+
]);
|
|
20537
|
+
renderPrompt();
|
|
20538
|
+
return;
|
|
20539
|
+
}
|
|
20540
|
+
if (line === "/clear") {
|
|
20541
|
+
delete state.search;
|
|
20542
|
+
delete state.type;
|
|
20543
|
+
delete state.level;
|
|
20544
|
+
delete state.whereExpr;
|
|
20545
|
+
delete state.whereAst;
|
|
20546
|
+
ui.success("Filters cleared");
|
|
20547
|
+
onFilterChanged?.(state);
|
|
20548
|
+
renderPrompt();
|
|
20549
|
+
return;
|
|
20550
|
+
}
|
|
20551
|
+
if (line === "/quit" || line === "/exit") {
|
|
20552
|
+
rl.close();
|
|
20553
|
+
return;
|
|
20554
|
+
}
|
|
20555
|
+
if (line.startsWith("/search ")) {
|
|
20556
|
+
const value = line.slice("/search ".length).trim();
|
|
20557
|
+
state.search = value || void 0;
|
|
20558
|
+
ui.success("Updated search filter", { search: state.search });
|
|
20559
|
+
onFilterChanged?.(state);
|
|
20560
|
+
renderPrompt();
|
|
20561
|
+
return;
|
|
20562
|
+
}
|
|
20563
|
+
if (line.startsWith("/type ")) {
|
|
20564
|
+
const value = line.slice("/type ".length).trim();
|
|
20565
|
+
state.type = value || void 0;
|
|
20566
|
+
ui.success("Updated type filter", { type: state.type });
|
|
20567
|
+
onFilterChanged?.(state);
|
|
20568
|
+
renderPrompt();
|
|
20569
|
+
return;
|
|
20570
|
+
}
|
|
20571
|
+
if (line.startsWith("/level ")) {
|
|
20572
|
+
const value = line.slice("/level ".length).trim().toLowerCase();
|
|
20573
|
+
if (value !== "debug" && value !== "info" && value !== "warn" && value !== "error") {
|
|
20574
|
+
ui.warn("Invalid level", { value, allowed: ["debug", "info", "warn", "error"] });
|
|
20575
|
+
renderPrompt();
|
|
20576
|
+
return;
|
|
20577
|
+
}
|
|
20578
|
+
state.level = value;
|
|
20579
|
+
ui.success("Updated level filter", { level: state.level });
|
|
20580
|
+
onFilterChanged?.(state);
|
|
20581
|
+
renderPrompt();
|
|
20582
|
+
return;
|
|
20583
|
+
}
|
|
20584
|
+
if (!line.startsWith("/")) {
|
|
20585
|
+
if (this.isPlainWildcardInput(line)) {
|
|
20586
|
+
state.search = line;
|
|
20587
|
+
delete state.whereExpr;
|
|
20588
|
+
delete state.whereAst;
|
|
20589
|
+
ui.success("Updated wildcard filter", { search: state.search });
|
|
20590
|
+
onFilterChanged?.(state);
|
|
20591
|
+
renderPrompt();
|
|
20592
|
+
return;
|
|
20593
|
+
}
|
|
20594
|
+
try {
|
|
20595
|
+
const parsed = this.parseWhereExpression(line);
|
|
20596
|
+
state.whereExpr = line;
|
|
20597
|
+
state.whereAst = parsed;
|
|
20598
|
+
ui.success("Updated where filter", { where: state.whereExpr });
|
|
20599
|
+
onFilterChanged?.(state);
|
|
20600
|
+
} catch {
|
|
20601
|
+
ui.warn("Unknown follow command", { command: line, hint: "Type /help" });
|
|
20602
|
+
}
|
|
20603
|
+
renderPrompt();
|
|
20604
|
+
return;
|
|
20605
|
+
}
|
|
20606
|
+
ui.warn("Unknown follow command", { command: line, hint: "Type /help" });
|
|
20607
|
+
renderPrompt();
|
|
20608
|
+
});
|
|
20609
|
+
return { rl, state, renderPrompt };
|
|
20610
|
+
}
|
|
20611
|
+
matchFollowFilter(item, state) {
|
|
20612
|
+
if (!state) return true;
|
|
20613
|
+
if (state.type && !item.type.includes(state.type)) {
|
|
20614
|
+
return false;
|
|
20615
|
+
}
|
|
20616
|
+
if (state.level && this.resolveItemLevel(item) !== state.level) {
|
|
20617
|
+
return false;
|
|
20618
|
+
}
|
|
20619
|
+
if (state.search) {
|
|
20620
|
+
const haystack = `${item.type} ${JSON.stringify(item.data)}`;
|
|
20621
|
+
if (!haystack.toLowerCase().includes(state.search.toLowerCase())) {
|
|
20622
|
+
return false;
|
|
20623
|
+
}
|
|
20624
|
+
}
|
|
20625
|
+
if (state.whereAst && !this.evaluateWhereNode(item, state.whereAst)) {
|
|
20626
|
+
return false;
|
|
20627
|
+
}
|
|
20628
|
+
return true;
|
|
20629
|
+
}
|
|
20630
|
+
renderFollowSnapshot(recent, state) {
|
|
20631
|
+
const matched = recent.filter((item) => this.matchFollowFilter(item, state));
|
|
20632
|
+
ui.info("Filter snapshot", {
|
|
20633
|
+
matched: matched.length,
|
|
20634
|
+
recent: recent.length,
|
|
20635
|
+
shown: Math.min(matched.length, 20)
|
|
20636
|
+
});
|
|
20637
|
+
const toShow = matched.slice(0, 20);
|
|
20638
|
+
for (const item of toShow.reverse()) {
|
|
20639
|
+
ui.plain(this.renderLogLine(item));
|
|
20640
|
+
}
|
|
20641
|
+
}
|
|
20642
|
+
resolveItemLevel(item) {
|
|
20643
|
+
if (item.level) return item.level;
|
|
20644
|
+
if (!item.data || typeof item.data !== "object" || Array.isArray(item.data)) {
|
|
20645
|
+
return void 0;
|
|
20646
|
+
}
|
|
20647
|
+
const level = item.data.level;
|
|
20648
|
+
if (level === "debug" || level === "info" || level === "warn" || level === "error") {
|
|
20649
|
+
return level;
|
|
20650
|
+
}
|
|
20651
|
+
return void 0;
|
|
20652
|
+
}
|
|
20653
|
+
parseWhereExpression(expr) {
|
|
20654
|
+
const tokens = this.tokenizeWhere(expr);
|
|
20655
|
+
if (tokens.length === 0) {
|
|
20656
|
+
throw new Error("Expression is empty");
|
|
20657
|
+
}
|
|
20658
|
+
let idx = 0;
|
|
20659
|
+
const parsePrimary = () => {
|
|
20660
|
+
const token = tokens[idx];
|
|
20661
|
+
if (!token) {
|
|
20662
|
+
throw new Error("Unexpected end of expression");
|
|
20663
|
+
}
|
|
20664
|
+
if (token.kind === "lparen") {
|
|
20665
|
+
idx += 1;
|
|
20666
|
+
const node = parseOr();
|
|
20667
|
+
const closing = tokens[idx];
|
|
20668
|
+
if (!closing || closing.kind !== "rparen") {
|
|
20669
|
+
throw new Error("Missing closing ')' ");
|
|
20670
|
+
}
|
|
20671
|
+
idx += 1;
|
|
20672
|
+
return node;
|
|
20673
|
+
}
|
|
20674
|
+
if (token.kind !== "ident") {
|
|
20675
|
+
throw new Error(`Expected field name, got "${token.raw}"`);
|
|
20676
|
+
}
|
|
20677
|
+
const rawKey = token.value;
|
|
20678
|
+
idx += 1;
|
|
20679
|
+
const op = tokens[idx];
|
|
20680
|
+
if (!op || op.kind !== "eq") {
|
|
20681
|
+
throw new Error(`Expected "=" after "${rawKey}"`);
|
|
20682
|
+
}
|
|
20683
|
+
idx += 1;
|
|
20684
|
+
const valueToken = tokens[idx];
|
|
20685
|
+
if (!valueToken || valueToken.kind !== "ident" && valueToken.kind !== "quoted") {
|
|
20686
|
+
throw new Error(`Expected value after "${rawKey}="`);
|
|
20687
|
+
}
|
|
20688
|
+
idx += 1;
|
|
20689
|
+
return {
|
|
20690
|
+
kind: "clause",
|
|
20691
|
+
clause: {
|
|
20692
|
+
path: this.normalizeWhereKey(rawKey),
|
|
20693
|
+
expected: this.parseWhereValue(valueToken.value)
|
|
20694
|
+
}
|
|
20695
|
+
};
|
|
20696
|
+
};
|
|
20697
|
+
const parseAnd = () => {
|
|
20698
|
+
let node = parsePrimary();
|
|
20699
|
+
while (tokens[idx]?.kind === "and") {
|
|
20700
|
+
idx += 1;
|
|
20701
|
+
node = { kind: "and", left: node, right: parsePrimary() };
|
|
20702
|
+
}
|
|
20703
|
+
return node;
|
|
20704
|
+
};
|
|
20705
|
+
const parseOr = () => {
|
|
20706
|
+
let node = parseAnd();
|
|
20707
|
+
while (tokens[idx]?.kind === "or") {
|
|
20708
|
+
idx += 1;
|
|
20709
|
+
node = { kind: "or", left: node, right: parseAnd() };
|
|
20710
|
+
}
|
|
20711
|
+
return node;
|
|
20712
|
+
};
|
|
20713
|
+
const ast = parseOr();
|
|
20714
|
+
if (idx < tokens.length) {
|
|
20715
|
+
throw new Error(`Unexpected token "${tokens[idx].raw}"`);
|
|
20716
|
+
}
|
|
20717
|
+
return ast;
|
|
20718
|
+
}
|
|
20719
|
+
normalizeWhereKey(key) {
|
|
20720
|
+
const raw = key.trim();
|
|
20721
|
+
if (raw === "datamode") return "data.mode";
|
|
20722
|
+
if (raw === "type") return "type";
|
|
20723
|
+
if (raw === "level") return "level";
|
|
20724
|
+
if (raw === "taskid") return "data.taskId";
|
|
20725
|
+
return raw;
|
|
20726
|
+
}
|
|
20727
|
+
parseWhereValue(raw) {
|
|
20728
|
+
const trimmed = raw.trim();
|
|
20729
|
+
if (trimmed === "true") return true;
|
|
20730
|
+
if (trimmed === "false") return false;
|
|
20731
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
20732
|
+
return Number(trimmed);
|
|
20351
20733
|
}
|
|
20734
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
20735
|
+
return trimmed.slice(1, -1);
|
|
20736
|
+
}
|
|
20737
|
+
return trimmed;
|
|
20738
|
+
}
|
|
20739
|
+
tokenizeWhere(expr) {
|
|
20740
|
+
const tokens = [];
|
|
20741
|
+
let i = 0;
|
|
20742
|
+
const input = expr.trim();
|
|
20743
|
+
while (i < input.length) {
|
|
20744
|
+
const ch = input[i];
|
|
20745
|
+
if (/\s/.test(ch)) {
|
|
20746
|
+
i += 1;
|
|
20747
|
+
continue;
|
|
20748
|
+
}
|
|
20749
|
+
if (ch === "(") {
|
|
20750
|
+
tokens.push({ kind: "lparen", raw: ch });
|
|
20751
|
+
i += 1;
|
|
20752
|
+
continue;
|
|
20753
|
+
}
|
|
20754
|
+
if (ch === ")") {
|
|
20755
|
+
tokens.push({ kind: "rparen", raw: ch });
|
|
20756
|
+
i += 1;
|
|
20757
|
+
continue;
|
|
20758
|
+
}
|
|
20759
|
+
if (ch === "=") {
|
|
20760
|
+
tokens.push({ kind: "eq", raw: ch });
|
|
20761
|
+
i += 1;
|
|
20762
|
+
continue;
|
|
20763
|
+
}
|
|
20764
|
+
if (ch === "&" && input[i + 1] === "&") {
|
|
20765
|
+
tokens.push({ kind: "and", raw: "&&" });
|
|
20766
|
+
i += 2;
|
|
20767
|
+
continue;
|
|
20768
|
+
}
|
|
20769
|
+
if (ch === "|" && input[i + 1] === "|") {
|
|
20770
|
+
tokens.push({ kind: "or", raw: "||" });
|
|
20771
|
+
i += 2;
|
|
20772
|
+
continue;
|
|
20773
|
+
}
|
|
20774
|
+
if (ch === '"' || ch === "'") {
|
|
20775
|
+
const quote = ch;
|
|
20776
|
+
i += 1;
|
|
20777
|
+
let value = "";
|
|
20778
|
+
while (i < input.length && input[i] !== quote) {
|
|
20779
|
+
value += input[i];
|
|
20780
|
+
i += 1;
|
|
20781
|
+
}
|
|
20782
|
+
if (i >= input.length) {
|
|
20783
|
+
throw new Error("Unterminated quoted string");
|
|
20784
|
+
}
|
|
20785
|
+
i += 1;
|
|
20786
|
+
tokens.push({ kind: "quoted", raw: `${quote}${value}${quote}`, value });
|
|
20787
|
+
continue;
|
|
20788
|
+
}
|
|
20789
|
+
let raw = "";
|
|
20790
|
+
while (i < input.length) {
|
|
20791
|
+
const c = input[i];
|
|
20792
|
+
if (/\s/.test(c) || c === "(" || c === ")" || c === "=") break;
|
|
20793
|
+
if (c === "&" && input[i + 1] === "&" || c === "|" && input[i + 1] === "|") break;
|
|
20794
|
+
raw += c;
|
|
20795
|
+
i += 1;
|
|
20796
|
+
}
|
|
20797
|
+
if (!raw) {
|
|
20798
|
+
throw new Error(`Unexpected token near "${input.slice(i)}"`);
|
|
20799
|
+
}
|
|
20800
|
+
tokens.push({ kind: "ident", raw, value: raw });
|
|
20801
|
+
}
|
|
20802
|
+
return tokens;
|
|
20803
|
+
}
|
|
20804
|
+
readPathValue(source, pathExpr) {
|
|
20805
|
+
const path22 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
20806
|
+
let cursor = source;
|
|
20807
|
+
for (const segment of path22) {
|
|
20808
|
+
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
|
|
20809
|
+
return void 0;
|
|
20810
|
+
}
|
|
20811
|
+
cursor = cursor[segment];
|
|
20812
|
+
}
|
|
20813
|
+
return cursor;
|
|
20814
|
+
}
|
|
20815
|
+
equalsExpected(actual, expected) {
|
|
20816
|
+
if (actual === void 0) return false;
|
|
20817
|
+
if (typeof expected === "number") {
|
|
20818
|
+
if (typeof actual === "number") return actual === expected;
|
|
20819
|
+
if (typeof actual === "string" && /^-?\d+(\.\d+)?$/.test(actual.trim())) {
|
|
20820
|
+
return Number(actual) === expected;
|
|
20821
|
+
}
|
|
20822
|
+
return false;
|
|
20823
|
+
}
|
|
20824
|
+
if (typeof expected === "boolean") {
|
|
20825
|
+
if (typeof actual === "boolean") return actual === expected;
|
|
20826
|
+
if (typeof actual === "string") return actual.toLowerCase() === String(expected);
|
|
20827
|
+
return false;
|
|
20828
|
+
}
|
|
20829
|
+
if (typeof actual === "string") return actual === expected;
|
|
20830
|
+
if (typeof actual === "number" || typeof actual === "boolean") {
|
|
20831
|
+
return String(actual) === expected;
|
|
20832
|
+
}
|
|
20833
|
+
return false;
|
|
20834
|
+
}
|
|
20835
|
+
isPlainWildcardInput(input) {
|
|
20836
|
+
return !/[=()]/.test(input) && !input.includes("&&") && !input.includes("||");
|
|
20837
|
+
}
|
|
20838
|
+
evaluateWhereNode(item, node) {
|
|
20839
|
+
if (node.kind === "clause") {
|
|
20840
|
+
const actual = this.readPathValue(item, node.clause.path);
|
|
20841
|
+
return this.equalsExpected(actual, node.clause.expected);
|
|
20842
|
+
}
|
|
20843
|
+
if (node.kind === "and") {
|
|
20844
|
+
return this.evaluateWhereNode(item, node.left) && this.evaluateWhereNode(item, node.right);
|
|
20845
|
+
}
|
|
20846
|
+
return this.evaluateWhereNode(item, node.left) || this.evaluateWhereNode(item, node.right);
|
|
20352
20847
|
}
|
|
20353
20848
|
resolveTemplatePath(templateName) {
|
|
20354
20849
|
const candidates = [
|
|
@@ -20623,7 +21118,8 @@ var ServiceCommandHandler = class {
|
|
|
20623
21118
|
await runtime.log(record, {
|
|
20624
21119
|
page: args.page,
|
|
20625
21120
|
history: args.history,
|
|
20626
|
-
search: args.search
|
|
21121
|
+
search: args.search,
|
|
21122
|
+
follow: args.follow
|
|
20627
21123
|
});
|
|
20628
21124
|
return;
|
|
20629
21125
|
}
|
|
@@ -21819,6 +22315,7 @@ function parseServiceArgs(tokens) {
|
|
|
21819
22315
|
let page = 0;
|
|
21820
22316
|
let history = false;
|
|
21821
22317
|
let search;
|
|
22318
|
+
let follow = false;
|
|
21822
22319
|
while (rest.length > 0) {
|
|
21823
22320
|
const token = rest.shift();
|
|
21824
22321
|
switch (token) {
|
|
@@ -21837,6 +22334,10 @@ function parseServiceArgs(tokens) {
|
|
|
21837
22334
|
case "--search":
|
|
21838
22335
|
search = requireValue5(rest, token);
|
|
21839
22336
|
break;
|
|
22337
|
+
case "--follow":
|
|
22338
|
+
case "-f":
|
|
22339
|
+
follow = true;
|
|
22340
|
+
break;
|
|
21840
22341
|
case "--json":
|
|
21841
22342
|
json = true;
|
|
21842
22343
|
break;
|
|
@@ -21848,7 +22349,7 @@ function parseServiceArgs(tokens) {
|
|
|
21848
22349
|
const namespace = parsedRef.namespace;
|
|
21849
22350
|
const name = parsedRef.objectId;
|
|
21850
22351
|
if (action === "log") {
|
|
21851
|
-
return { type: "service" /* Service */, action, namespace, name, baseUrl, json, page, history, search };
|
|
22352
|
+
return { type: "service" /* Service */, action, namespace, name, baseUrl, json, page, history, search, follow };
|
|
21852
22353
|
}
|
|
21853
22354
|
if (action === "deploy" || action === "init") {
|
|
21854
22355
|
return { type: "service" /* Service */, action, namespace, name, cwd, baseUrl, json };
|
|
@@ -22201,136 +22702,137 @@ var pkg = JSON.parse(
|
|
|
22201
22702
|
(0, import_node_fs16.readFileSync)(import_node_path21.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
22202
22703
|
);
|
|
22203
22704
|
var HELP_TEXT = [
|
|
22204
|
-
|
|
22705
|
+
import_chalk4.default.bold(`pmate v${pkg.version}`),
|
|
22205
22706
|
"",
|
|
22206
|
-
|
|
22207
|
-
` ${
|
|
22707
|
+
import_chalk4.default.bold("Usage:"),
|
|
22708
|
+
` ${import_chalk4.default.cyan("pmate")} ${import_chalk4.default.gray("[options]")}`,
|
|
22208
22709
|
"",
|
|
22209
|
-
|
|
22210
|
-
` ${
|
|
22211
|
-
` ${
|
|
22212
|
-
` ${
|
|
22710
|
+
import_chalk4.default.bold("Options:"),
|
|
22711
|
+
` ${import_chalk4.default.green("-h, --help")} Show this help output`,
|
|
22712
|
+
` ${import_chalk4.default.green("-v, --version")} Print the current version`,
|
|
22713
|
+
` ${import_chalk4.default.green("-n, --name <n>")} Print a greeting for <n>`,
|
|
22213
22714
|
"",
|
|
22214
|
-
|
|
22215
|
-
` ${
|
|
22216
|
-
` ${
|
|
22217
|
-
` ${
|
|
22218
|
-
` ${
|
|
22219
|
-
` ${
|
|
22220
|
-
` ${
|
|
22221
|
-
` ${
|
|
22222
|
-
` ${
|
|
22223
|
-
` ${
|
|
22224
|
-
` ${
|
|
22225
|
-
` ${
|
|
22226
|
-
` ${
|
|
22227
|
-
` ${
|
|
22228
|
-
` ${
|
|
22229
|
-
` ${
|
|
22230
|
-
` ${
|
|
22231
|
-
` ${
|
|
22232
|
-
` ${
|
|
22233
|
-
` ${
|
|
22234
|
-
` ${
|
|
22235
|
-
` ${
|
|
22236
|
-
` ${
|
|
22237
|
-
` ${
|
|
22238
|
-
` ${
|
|
22239
|
-
` ${
|
|
22240
|
-
` ${
|
|
22241
|
-
` ${
|
|
22242
|
-
` ${
|
|
22243
|
-
` ${
|
|
22244
|
-
` ${
|
|
22245
|
-
` ${
|
|
22246
|
-
` ${
|
|
22247
|
-
` ${
|
|
22248
|
-
` ${
|
|
22249
|
-
` ${
|
|
22250
|
-
` ${
|
|
22251
|
-
` ${
|
|
22252
|
-
` ${
|
|
22253
|
-
` ${
|
|
22254
|
-
` ${
|
|
22255
|
-
` ${
|
|
22256
|
-
` ${
|
|
22257
|
-
` ${
|
|
22258
|
-
` ${
|
|
22259
|
-
` ${
|
|
22260
|
-
` ${
|
|
22261
|
-
` ${
|
|
22262
|
-
` ${
|
|
22263
|
-
` ${
|
|
22264
|
-
` ${
|
|
22265
|
-
` ${
|
|
22266
|
-
` ${
|
|
22267
|
-
` ${
|
|
22268
|
-
` ${
|
|
22269
|
-
` ${
|
|
22270
|
-
` ${
|
|
22271
|
-
` ${
|
|
22272
|
-
` ${
|
|
22273
|
-
` ${
|
|
22274
|
-
` ${
|
|
22275
|
-
` ${
|
|
22276
|
-
` ${
|
|
22277
|
-
` ${
|
|
22278
|
-
` ${
|
|
22279
|
-
` ${
|
|
22280
|
-
` ${
|
|
22281
|
-
` ${
|
|
22282
|
-
` ${
|
|
22283
|
-
` ${
|
|
22284
|
-
` ${
|
|
22285
|
-
` ${
|
|
22286
|
-
` ${
|
|
22287
|
-
` ${
|
|
22288
|
-
` ${
|
|
22289
|
-
` ${
|
|
22290
|
-
` ${
|
|
22291
|
-
` ${
|
|
22292
|
-
` ${
|
|
22293
|
-
` ${
|
|
22294
|
-
` ${
|
|
22295
|
-
` ${
|
|
22296
|
-
` ${
|
|
22297
|
-
` ${
|
|
22298
|
-
` ${
|
|
22299
|
-
` ${
|
|
22300
|
-
` ${
|
|
22301
|
-
` ${
|
|
22302
|
-
` ${
|
|
22303
|
-
` ${
|
|
22304
|
-
` ${
|
|
22305
|
-
` ${
|
|
22306
|
-
` ${
|
|
22307
|
-
` ${
|
|
22308
|
-
` ${
|
|
22309
|
-
` ${
|
|
22310
|
-
` ${
|
|
22311
|
-
` ${
|
|
22312
|
-
` ${
|
|
22313
|
-
` ${
|
|
22314
|
-
` ${
|
|
22315
|
-
` ${
|
|
22316
|
-
` ${
|
|
22317
|
-
` ${
|
|
22318
|
-
` ${
|
|
22319
|
-
` ${
|
|
22320
|
-
` ${
|
|
22321
|
-
` ${
|
|
22322
|
-
` ${
|
|
22323
|
-
` ${
|
|
22324
|
-
` ${
|
|
22325
|
-
` ${
|
|
22326
|
-
` ${
|
|
22327
|
-
` ${
|
|
22328
|
-
` ${
|
|
22329
|
-
` ${
|
|
22330
|
-
` ${
|
|
22331
|
-
` ${
|
|
22332
|
-
` ${
|
|
22333
|
-
` ${
|
|
22715
|
+
import_chalk4.default.bold("Commands:"),
|
|
22716
|
+
` ${import_chalk4.default.cyan("list [path]")} List apps from .pmate.yaml in the target folder`,
|
|
22717
|
+
` ${import_chalk4.default.cyan("login")} Log in and store a session in ~/.pmate/session.json`,
|
|
22718
|
+
` ${import_chalk4.default.gray(" [--app <app-id>]")}`,
|
|
22719
|
+
` ${import_chalk4.default.cyan("add-dns")} Add a DNS record via Aliyun DNS`,
|
|
22720
|
+
` ${import_chalk4.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
|
|
22721
|
+
` ${import_chalk4.default.cyan("sts")} Request an OSS STS token from the CI server`,
|
|
22722
|
+
` ${import_chalk4.default.cyan("bucket")} Manage OSS buckets`,
|
|
22723
|
+
` ${import_chalk4.default.gray(" --create --name <bucket> [--subdomain <name> --domain <name>]")}`,
|
|
22724
|
+
` ${import_chalk4.default.cyan("delete")} Tear down app resources created by init`,
|
|
22725
|
+
` ${import_chalk4.default.gray(" [app] <app-name> [--cwd <dir>]")}`,
|
|
22726
|
+
` ${import_chalk4.default.cyan("dev")} Run the dev script for app dir from .pmate.yaml`,
|
|
22727
|
+
` ${import_chalk4.default.gray(" <app-name> [--cwd <dir>]")}`,
|
|
22728
|
+
` ${import_chalk4.default.cyan("env")} Manage app env vars on the server`,
|
|
22729
|
+
` ${import_chalk4.default.gray(" <app-name> --list|--set <key> --value <value> [--delete <key>] [--cwd <dir>] [--verbose|-v]")}`,
|
|
22730
|
+
` ${import_chalk4.default.cyan("pr")} Create or update GitHub PRs with AI assistance`,
|
|
22731
|
+
` ${import_chalk4.default.gray(" merge [<pr>] (defaults: --squash --delete-branch)")}`,
|
|
22732
|
+
` ${import_chalk4.default.cyan("commit")} Create an AI-generated commit from local changes`,
|
|
22733
|
+
` ${import_chalk4.default.gray(" [--push] [--cwd <dir>]")}`,
|
|
22734
|
+
` ${import_chalk4.default.cyan("summary")} Summarize a GitHub PR with AI`,
|
|
22735
|
+
` ${import_chalk4.default.gray(" --pr <id> [--cwd <dir>]")}`,
|
|
22736
|
+
` ${import_chalk4.default.cyan("quiz")} Manage quiz papers on quiz-api`,
|
|
22737
|
+
` ${import_chalk4.default.gray(" create-draft --paper-id <id>")}`,
|
|
22738
|
+
` ${import_chalk4.default.gray(" update-meta --paper-id <id> --file <metadata.json>")}`,
|
|
22739
|
+
` ${import_chalk4.default.gray(" append-step --paper-id <id> --file <step.json>")}`,
|
|
22740
|
+
` ${import_chalk4.default.gray(" update-step --paper-id <id> --step-id <step-id> --file <step.json>")}`,
|
|
22741
|
+
` ${import_chalk4.default.gray(" reorder --paper-id <id> --step-ids <id1,id2,...>")}`,
|
|
22742
|
+
` ${import_chalk4.default.gray(" activate --paper-id <id>")}`,
|
|
22743
|
+
` ${import_chalk4.default.gray(" view --paper-id <id>")}`,
|
|
22744
|
+
` ${import_chalk4.default.gray(" edit-step --paper-id <id> --step-id <step-id> --file <step.json> [--new-paper-id <id>] [--activate]")}`,
|
|
22745
|
+
` ${import_chalk4.default.cyan("linear")} Create Linear issues`,
|
|
22746
|
+
` ${import_chalk4.default.gray(" (default) create via REPL")}`,
|
|
22747
|
+
` ${import_chalk4.default.gray(" create --repl [--cwd <dir>]")}`,
|
|
22748
|
+
` ${import_chalk4.default.gray(" create --title <title> [--desc <markdown>]")}`,
|
|
22749
|
+
` ${import_chalk4.default.gray(" [--team-id <id>|--team-key <key>] [--priority <0-4>]")}`,
|
|
22750
|
+
` ${import_chalk4.default.gray(" [--parent-id <id>] [--state-id <id>] [--cwd <dir>]")}`,
|
|
22751
|
+
` ${import_chalk4.default.gray(" cycle [--team-id <id>|--team-key <key>] [--account <title>] [--cwd <dir>]")}`,
|
|
22752
|
+
` ${import_chalk4.default.gray(" teams [--account <title>] [--cwd <dir>]")}`,
|
|
22753
|
+
` ${import_chalk4.default.gray(" whoami [--account <title>] [--cwd <dir>]")}`,
|
|
22754
|
+
` ${import_chalk4.default.gray(" update <issue> [--title <title>] [--desc <markdown>]")}`,
|
|
22755
|
+
` ${import_chalk4.default.gray(" [--team-id <id>|--team-key <key>] [--priority <0-4>]")}`,
|
|
22756
|
+
` ${import_chalk4.default.gray(" [--parent-id <id>] [--state-id <id>] [--cwd <dir>]")}`,
|
|
22757
|
+
` ${import_chalk4.default.gray(" view <issue> [--cwd <dir>]")}`,
|
|
22758
|
+
` ${import_chalk4.default.gray(" sub-issues <issue> [--cwd <dir>]")}`,
|
|
22759
|
+
` ${import_chalk4.default.gray(" comment <issue> --body <markdown> [--cwd <dir>]")}`,
|
|
22760
|
+
` ${import_chalk4.default.gray(" comments <issue> [--cwd <dir>]")}`,
|
|
22761
|
+
` ${import_chalk4.default.gray(" user-issues <user> [--cycle <number>] [--status <status>] [--cwd <dir>]")}`,
|
|
22762
|
+
` ${import_chalk4.default.gray(" issues [--query <text>] [--user <user>] [--status <status>] [--cycle <number>]")}`,
|
|
22763
|
+
` ${import_chalk4.default.gray(" [--team-id <id>|--team-key <key>] [--limit <1-250>] [--cwd <dir>]")}`,
|
|
22764
|
+
` ${import_chalk4.default.gray(" --pr [--cwd <dir>] (legacy)")}`,
|
|
22765
|
+
` ${import_chalk4.default.gray(" --repl [--cwd <dir>] (legacy)")}`,
|
|
22766
|
+
` ${import_chalk4.default.gray(" --screen-shot [--cwd <dir>] (legacy)")}`,
|
|
22767
|
+
` ${import_chalk4.default.cyan("notion")} View, create, or update Notion pages`,
|
|
22768
|
+
` ${import_chalk4.default.gray(" view <page-id|url>")}`,
|
|
22769
|
+
` ${import_chalk4.default.gray(" create --title <title> (--parent <page-id|url>|--private) [--content <text>|--file <path>]")}`,
|
|
22770
|
+
` ${import_chalk4.default.gray(" update <page-id|url> --content <text> [--append]")}`,
|
|
22771
|
+
` ${import_chalk4.default.gray(" update <page-id|url> --file <path> [--append]")}`,
|
|
22772
|
+
` ${import_chalk4.default.cyan("qrcode")} Capture a QR code screenshot and decode it`,
|
|
22773
|
+
` ${import_chalk4.default.cyan("oss")} Manage OSS buckets`,
|
|
22774
|
+
` ${import_chalk4.default.gray(" list")}`,
|
|
22775
|
+
` ${import_chalk4.default.gray(" upload --file <path> --key <key>")}`,
|
|
22776
|
+
` ${import_chalk4.default.cyan("random")} Generate random strings for tokens`,
|
|
22777
|
+
` ${import_chalk4.default.gray(" [--length <n>] [--charset base64url|hex|alnum|ascii]")}`,
|
|
22778
|
+
` ${import_chalk4.default.gray(" [--count <n>]")}`,
|
|
22779
|
+
` ${import_chalk4.default.gray(" --easy [--words <n>] [--digits <n>] [--separator <s>] [--count <n>]")}`,
|
|
22780
|
+
` ${import_chalk4.default.cyan("collect")} Collect threads/messages from Electron chat app via CDP`,
|
|
22781
|
+
` ${import_chalk4.default.gray(" --list [--endpoint <url>] [--json]")}`,
|
|
22782
|
+
` ${import_chalk4.default.gray(" --thread <name> [--endpoint <url>] [--json]")}`,
|
|
22783
|
+
` ${import_chalk4.default.cyan("agent")} Manage agent registry entries via agent-ui-api`,
|
|
22784
|
+
` ${import_chalk4.default.gray(" namespaces [--base-url <url>] [--json]")}`,
|
|
22785
|
+
` ${import_chalk4.default.gray(" list [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
22786
|
+
` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22787
|
+
` ${import_chalk4.default.gray(" view <ns:objectId> [--base-url <url>]")}`,
|
|
22788
|
+
` ${import_chalk4.default.gray(" create [<namespace>] --file <path> [--base-url <url>] [--json]")}`,
|
|
22789
|
+
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
22790
|
+
` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
|
|
22791
|
+
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22792
|
+
` ${import_chalk4.default.gray(" default namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
|
|
22793
|
+
` ${import_chalk4.default.cyan("ns")} Manage registered namespaces`,
|
|
22794
|
+
` ${import_chalk4.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
22795
|
+
` ${import_chalk4.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
22796
|
+
` ${import_chalk4.default.gray(" create <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
22797
|
+
` ${import_chalk4.default.cyan("role")} Manage role definitions via auth-api`,
|
|
22798
|
+
` ${import_chalk4.default.gray(" definition list [--base-url <url>] [--json]")}`,
|
|
22799
|
+
` ${import_chalk4.default.gray(" definition create <role> [--display-name <name>] [--description <text>] [--base-url <url>] [--json]")}`,
|
|
22800
|
+
` ${import_chalk4.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
22801
|
+
` ${import_chalk4.default.cyan("account")} View accounts and manage account role bindings`,
|
|
22802
|
+
` ${import_chalk4.default.gray(" view (--account <id> | --mobile <mobile> | --nickname <nickname>) [--base-url <url>] [--json]")}`,
|
|
22803
|
+
` ${import_chalk4.default.gray(" role list --account <id> [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
22804
|
+
` ${import_chalk4.default.gray(" role add --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]")}`,
|
|
22805
|
+
` ${import_chalk4.default.gray(" role remove --account <id> --namespace <ns> --role <role> [--base-url <url>] [--json]")}`,
|
|
22806
|
+
` ${import_chalk4.default.gray(" default base URL: https://auth-api-v2.pmate.chat")}`,
|
|
22807
|
+
` ${import_chalk4.default.cyan("store")} Manage @pmate/store namespaces, tables, and kv stores`,
|
|
22808
|
+
` ${import_chalk4.default.gray(" namespace list [--chain <chain>] [--indexer-base-url <url>] [--json]")}`,
|
|
22809
|
+
` ${import_chalk4.default.gray(" table list|get|exists|create|update|delete <name> [options]")}`,
|
|
22810
|
+
` ${import_chalk4.default.gray(" kv list|get|exists|set|delete <name> [options]")}`,
|
|
22811
|
+
` ${import_chalk4.default.gray(" defaults: chain=pmate namespace=pmate env base URLs from BLOCKCHAIN_BASE_URL / INDEXER_BASE_URL")}`,
|
|
22812
|
+
` ${import_chalk4.default.cyan("app")} Manage app registry entries via apps-api`,
|
|
22813
|
+
` ${import_chalk4.default.gray(" list [--ns <namespace>] [--base-url <url>] [--json]")}`,
|
|
22814
|
+
` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22815
|
+
` ${import_chalk4.default.gray(" view <ns:objectId> [--base-url <url>]")}`,
|
|
22816
|
+
` ${import_chalk4.default.gray(" create --file <path> [--base-url <url>] [--json]")}`,
|
|
22817
|
+
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
22818
|
+
` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
|
|
22819
|
+
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22820
|
+
` ${import_chalk4.default.gray(" default base URL: https://apps-api.pmate.chat")}`,
|
|
22821
|
+
` ${import_chalk4.default.cyan("service")} Manage service registry entries via apps-api`,
|
|
22822
|
+
` ${import_chalk4.default.gray(" list [--namespace <ns>] [--repo <owner/name|https://github.com/owner/name>] [--base-url <url>] [--json]")}`,
|
|
22823
|
+
` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22824
|
+
` ${import_chalk4.default.gray(" view <ns:objectId> [--base-url <url>]")}`,
|
|
22825
|
+
` ${import_chalk4.default.gray(" create --file <path> [--base-url <url>] [--json]")}`,
|
|
22826
|
+
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
22827
|
+
` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
|
|
22828
|
+
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22829
|
+
` ${import_chalk4.default.gray(" deploy <ns:objectId> [--cwd <dir>] [--base-url <url>]")}`,
|
|
22830
|
+
` ${import_chalk4.default.gray(" init <ns:objectId> [--cwd <dir>] [--base-url <url>]")}`,
|
|
22831
|
+
` ${import_chalk4.default.gray(" log <ns:objectId> [--page <n>] [--history] [--search <keyword>] [--follow|-f] [--base-url <url>]")}`,
|
|
22832
|
+
` ${import_chalk4.default.gray(" default base URL: https://apps-api.pmate.chat")}`,
|
|
22833
|
+
` ${import_chalk4.default.cyan("vercel")} Wrap common Vercel CLI inspection commands`,
|
|
22834
|
+
` ${import_chalk4.default.gray(" projects [--scope <scope>]")}`,
|
|
22835
|
+
` ${import_chalk4.default.gray(" deploys --project <name> [--last-week] [--scope <scope>]")}`
|
|
22334
22836
|
].join("\n");
|
|
22335
22837
|
function parseArgs(argv) {
|
|
22336
22838
|
const result = { help: false, version: false, rest: [] };
|
|
@@ -22836,7 +23338,7 @@ function parseQuizArgs(tokens) {
|
|
|
22836
23338
|
const rest = [...tokens];
|
|
22837
23339
|
const action = rest.shift();
|
|
22838
23340
|
if (!action) {
|
|
22839
|
-
throw new Error("Missing quiz action. Usage: quiz create-draft|update-meta|append-step|reorder|activate|view|edit-step");
|
|
23341
|
+
throw new Error("Missing quiz action. Usage: quiz create-draft|update-meta|append-step|update-step|reorder|activate|view|edit-step");
|
|
22840
23342
|
}
|
|
22841
23343
|
if (action === "create-draft") {
|
|
22842
23344
|
let paperId;
|
|
@@ -22947,6 +23449,53 @@ function parseQuizArgs(tokens) {
|
|
|
22947
23449
|
linkBaseUrl
|
|
22948
23450
|
};
|
|
22949
23451
|
}
|
|
23452
|
+
if (action === "update-step") {
|
|
23453
|
+
let paperId;
|
|
23454
|
+
let stepId;
|
|
23455
|
+
let filePath;
|
|
23456
|
+
let apiBaseUrl;
|
|
23457
|
+
let linkBaseUrl;
|
|
23458
|
+
while (rest.length > 0) {
|
|
23459
|
+
const token = rest.shift();
|
|
23460
|
+
switch (token) {
|
|
23461
|
+
case "--paper-id":
|
|
23462
|
+
paperId = requireValue8(rest, token);
|
|
23463
|
+
break;
|
|
23464
|
+
case "--step-id":
|
|
23465
|
+
stepId = requireValue8(rest, token);
|
|
23466
|
+
break;
|
|
23467
|
+
case "--file":
|
|
23468
|
+
filePath = requireValue8(rest, token);
|
|
23469
|
+
break;
|
|
23470
|
+
case "--base-url":
|
|
23471
|
+
apiBaseUrl = requireValue8(rest, token);
|
|
23472
|
+
break;
|
|
23473
|
+
case "--link-base":
|
|
23474
|
+
linkBaseUrl = requireValue8(rest, token);
|
|
23475
|
+
break;
|
|
23476
|
+
default:
|
|
23477
|
+
throw new Error(`Unknown quiz update-step option: ${token}`);
|
|
23478
|
+
}
|
|
23479
|
+
}
|
|
23480
|
+
if (!paperId) {
|
|
23481
|
+
throw new Error("Missing --paper-id. Usage: quiz update-step --paper-id <id> --step-id <id> --file <step.json>.");
|
|
23482
|
+
}
|
|
23483
|
+
if (!stepId) {
|
|
23484
|
+
throw new Error("Missing --step-id. Usage: quiz update-step --paper-id <id> --step-id <id> --file <step.json>.");
|
|
23485
|
+
}
|
|
23486
|
+
if (!filePath) {
|
|
23487
|
+
throw new Error("Missing --file. Usage: quiz update-step --paper-id <id> --step-id <id> --file <step.json>.");
|
|
23488
|
+
}
|
|
23489
|
+
return {
|
|
23490
|
+
type: "quiz" /* Quiz */,
|
|
23491
|
+
action: "update-step",
|
|
23492
|
+
paperId,
|
|
23493
|
+
stepId,
|
|
23494
|
+
filePath,
|
|
23495
|
+
apiBaseUrl,
|
|
23496
|
+
linkBaseUrl
|
|
23497
|
+
};
|
|
23498
|
+
}
|
|
22950
23499
|
if (action === "reorder") {
|
|
22951
23500
|
let paperId;
|
|
22952
23501
|
let stepIdsRaw;
|