(report)
| 320 | } |
| 321 | |
| 322 | function render(report) { |
| 323 | const lines = [ |
| 324 | 'Citadel Next Action', |
| 325 | '='.repeat(40), |
| 326 | `Generated: ${report.generatedAt}`, |
| 327 | `Mode: ${report.mode}`, |
| 328 | `Outcome: ${report.outcome}`, |
| 329 | `Project: ${report.projectRoot}`, |
| 330 | '', |
| 331 | 'Initial', |
| 332 | ` Command: ${report.initial.nextAction?.command || '(none)'}`, |
| 333 | ` Why: ${report.initial.nextAction?.why || '(none)'}`, |
| 334 | '', |
| 335 | 'Steps', |
| 336 | ]; |
| 337 | |
| 338 | if (report.steps.length === 0) { |
| 339 | lines.push(' (none executed)'); |
| 340 | } else { |
| 341 | for (const [index, step] of report.steps.entries()) { |
| 342 | lines.push(` ${index + 1}. ${step.action.label}`); |
| 343 | lines.push(` command: ${step.repair.command}`); |
| 344 | lines.push(` exit: ${step.result.status}`); |
| 345 | if (step.result.stdout.trim()) lines.push(` stdout: ${step.result.stdout.trim().split(/\r?\n/)[0]}`); |
| 346 | if (step.result.stderr.trim()) lines.push(` stderr: ${step.result.stderr.trim().split(/\r?\n/)[0]}`); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | lines.push(''); |
| 351 | lines.push('Final'); |
| 352 | lines.push(` Command: ${report.final.nextAction?.command || '(none)'}`); |
| 353 | lines.push(` Why: ${report.final.nextAction?.why || '(none)'}`); |
| 354 | lines.push(` Pending: docSync=${report.final.pending?.docSync || 0}, mergeReviews=${report.final.pending?.mergeReviews || 0}, intakeItems=${report.final.pending?.intakeItems || 0}`); |
| 355 | lines.push(` Git dirty: ${report.final.gitStatus?.dirty ? 'yes' : 'no'}`); |
| 356 | |
| 357 | lines.push(''); |
| 358 | lines.push('Approval Capsule'); |
| 359 | if (!report.approvalCapsule) { |
| 360 | lines.push(' (none required)'); |
| 361 | } else { |
| 362 | lines.push(` Request: ${report.approvalCapsule.request}`); |
| 363 | lines.push(` Boundary: ${report.approvalCapsule.boundary}`); |
| 364 | lines.push(` Risk: ${report.approvalCapsule.risk}`); |
| 365 | lines.push(` Path: ${report.approvalCapsule.path || '(not written)'}`); |
| 366 | } |
| 367 | |
| 368 | lines.push(''); |
| 369 | lines.push('---HANDOFF---'); |
| 370 | lines.push(`- Outcome: ${report.outcome}`); |
| 371 | lines.push(`- Initial command: ${report.initial.nextAction?.command || '(none)'}`); |
| 372 | lines.push(`- Steps executed: ${report.steps.length}`); |
| 373 | lines.push(`- Final command: ${report.final.nextAction?.command || '(none)'}`); |
| 374 | if (report.approvalCapsule) lines.push(`- Approval capsule: ${report.approvalCapsule.path || 'pending write'}`); |
| 375 | lines.push('---'); |
| 376 | return `${lines.join('\n')}\n`; |
| 377 | } |
| 378 | |
| 379 | function normalizePath(value) { |
no outgoing calls
no test coverage detected