(store)
| 13 | // always sees current state without a follow-up call. |
| 14 | |
| 15 | function statusPayload(store) { |
| 16 | const c = store.active(); |
| 17 | if (!c) { |
| 18 | const all = store.list(); |
| 19 | if (all.length === 0) { |
| 20 | return { |
| 21 | active: null, |
| 22 | contracts: [], |
| 23 | message: 'No contracts on disk. Use contract_create to declare a Definition of Done.', |
| 24 | }; |
| 25 | } |
| 26 | return { |
| 27 | active: null, |
| 28 | contracts: all.map((row) => ({ id: row.id, title: row.title, status: row.status })), |
| 29 | message: 'No active contract. Use /contract activate <id> to set one.', |
| 30 | }; |
| 31 | } |
| 32 | const ds = c.doneStatus(); |
| 33 | return { |
| 34 | active: c.id, |
| 35 | title: c.title, |
| 36 | status: c.status, |
| 37 | summary: `${ds.passed}/${ds.total} passed (${ds.failed} failed, ${ds.pending} pending, ${ds.skipped} skipped)`, |
| 38 | done: ds.done, |
| 39 | assertions: c.assertions.map((a) => ({ id: a.id, text: a.text, state: a.state })), |
| 40 | blockers: ds.blockers, |
| 41 | }; |
| 42 | } |
| 43 | |
| 44 | function formatStatus(payload) { |
| 45 | if (!payload.active) { |
no test coverage detected