feat(workflow): enrich workflow/agent metadata from workflowProgress;

lightweight workflowTree, build debounce, minor fixes

  - Index phase, label, model, state, duration, tokens per workflow agent
  - Index duration, total_tokens, status, name per workflow run
  - workflowTree returns parsed result + agent summaries instead of
    dumping all messages
  - 30s debounce on buildIndex to avoid repeated directory scans
  - Fix broken BASH_EXIT_PAT (SQLite LIKE has no character classes)
  - Fix SKILL.md step numbering, document FTS5 hyphen limitation
This commit is contained in:
tommy0103
2026-06-04 15:49:57 +08:00
parent ab828364ad
commit 67513b793f
6 changed files with 55 additions and 21 deletions
+8 -5
View File
@@ -22,7 +22,7 @@ function buildWhere(opts, aliases) {
return { where: clauses.length ? clauses.join(' AND ') : '1=1', params };
}
const BASH_EXIT_PAT = 'Exit code [1-9]%';
const BASH_EXIT_PAT = 'Exit code %';
function createQueryApi(db) {
const q = (sql, ...p) => db.prepare(sql).all(...p);
@@ -107,10 +107,13 @@ function createQueryApi(db) {
const workflowTree = (runId) => {
const wf = db.prepare('SELECT * FROM workflows WHERE run_id=?').get(runId);
if (!wf) return null;
const agents = db.prepare('SELECT * FROM workflow_agents WHERE run_id=?').all(runId).map(a => ({
...a, messages: db.prepare('SELECT * FROM messages WHERE agent_id=? ORDER BY timestamp').all(a.agent_id),
}));
return { ...wf, agents };
let result = null;
try { result = JSON.parse(wf.result_json); } catch {}
const agents = db.prepare('SELECT * FROM workflow_agents WHERE run_id=?').all(runId).map(a => {
const mc = db.prepare('SELECT COUNT(*) as c FROM messages WHERE agent_id=?').get(a.agent_id);
return { ...a, messageCount: mc?.c || 0 };
});
return { ...wf, result, agents };
};
const fileHistory = (fp, opts = {}) => {