feat: add work items CLI

This commit is contained in:
Affaan Mustafa
2026-05-11 12:13:30 -04:00
committed by Affaan Mustafa
parent 8926ea925e
commit b1e67788f7
8 changed files with 421 additions and 2 deletions

View File

@@ -450,6 +450,10 @@ function createQueryApi(db) {
ORDER BY updated_at DESC, id DESC
LIMIT ?
`);
const countWorkItemsStatement = db.prepare(`
SELECT COUNT(*) AS total_count
FROM work_items
`);
const listAllWorkItemsStatement = db.prepare(`
SELECT *
FROM work_items
@@ -690,6 +694,11 @@ function createQueryApi(db) {
return row ? mapSessionRow(row) : null;
}
function getWorkItemById(id) {
const row = getWorkItemStatement.get(id);
return row ? mapWorkItemRow(row) : null;
}
function listRecentSessions(options = {}) {
const limit = normalizeLimit(options.limit, 10);
return {
@@ -716,6 +725,14 @@ function createQueryApi(db) {
};
}
function listWorkItems(options = {}) {
const limit = normalizeLimit(options.limit, 20);
return {
totalCount: countWorkItemsStatement.get().total_count,
items: listWorkItemsStatement.all(limit).map(mapWorkItemRow),
};
}
function getStatus(options = {}) {
const activeLimit = normalizeLimit(options.activeLimit, 5);
const recentSkillRunLimit = normalizeLimit(options.recentSkillRunLimit, 20);
@@ -763,6 +780,7 @@ function createQueryApi(db) {
return {
getSessionById,
getSessionDetail,
getWorkItemById,
getStatus,
insertDecision(decision) {
const normalized = normalizeDecisionInput(decision);
@@ -812,6 +830,7 @@ function createQueryApi(db) {
return normalized;
},
listRecentSessions,
listWorkItems,
upsertInstallState(installState) {
const normalized = normalizeInstallStateInput(installState);
assertValidEntity('installState', normalized);