@lark-project/cli
Version:
飞书项目插件开发工具
52 lines (51 loc) • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkpointStatus = void 0;
const read_1 = require("./read");
/**
* Summarize current workflow progress by replaying events.jsonl.
*
* "Replay" here means: walk events in append order, remembering the latest
* phase/step/status so far. This gives us a snapshot without needing a
* state.json that suffers write contention.
*/
function checkpointStatus(options) {
var _a, _b, _c, _d, _e, _f;
const events = (0, read_1.readEvents)();
if (events.length === 0) {
if (options.format === 'json') {
process.stdout.write(JSON.stringify({ events: 0, last: null }) + '\n');
}
else {
process.stdout.write('No events recorded yet. Run `lpm ai checkpoint append ...` to start.\n');
}
return;
}
const last = events[events.length - 1];
const latestByPhase = new Map();
for (const ev of events) {
if (typeof ev.phase === 'number') {
latestByPhase.set(ev.phase, ev);
}
}
if (options.format === 'json') {
process.stdout.write(JSON.stringify({
events: events.length,
last,
phases: Array.from(latestByPhase.entries())
.sort(([a], [b]) => a - b)
.map(([phase, ev]) => ({ phase, step: ev.step, status: ev.status, ts: ev.ts })),
}) + '\n');
return;
}
// text format
process.stdout.write(`events: ${events.length}\n`);
process.stdout.write(`last: phase=${(_a = last.phase) !== null && _a !== void 0 ? _a : '-'} step=${(_b = last.step) !== null && _b !== void 0 ? _b : '-'} status=${(_c = last.status) !== null && _c !== void 0 ? _c : '-'} ts=${(_d = last.ts) !== null && _d !== void 0 ? _d : '-'}\n`);
if (latestByPhase.size > 0) {
process.stdout.write('phases:\n');
for (const [phase, ev] of Array.from(latestByPhase.entries()).sort(([a], [b]) => a - b)) {
process.stdout.write(` phase ${phase}: step=${(_e = ev.step) !== null && _e !== void 0 ? _e : '-'} status=${(_f = ev.status) !== null && _f !== void 0 ? _f : '-'}\n`);
}
}
}
exports.checkpointStatus = checkpointStatus;