mirror of
https://github.com/joelhooks/joelclaw.git
synced 2026-09-19 01:24:04 +08:00
26 lines
2.0 KiB
JSON
26 lines
2.0 KiB
JSON
{
|
|
"title": "Add formatLoopDuration utility function",
|
|
"stories": [
|
|
{
|
|
"id": "DUR-1",
|
|
"title": "Implement and export formatLoopDuration",
|
|
"description": "Add and export a pure function `formatLoopDuration(ms: number): string` to `src/inngest/functions/agent-loop/utils.ts`. The function converts a millisecond duration into a human-readable string with the following rules:\n\n1. Negative values and zero return `'0s'`\n2. Sub-second values show one decimal place: `500` → `'0.5s'`\n3. Exact seconds with no higher units: `5000` → `'5s'`\n4. Minutes and seconds: `65000` → `'1m 5s'`\n5. Hours, minutes, and seconds: `3661000` → `'1h 1m 1s'`\n6. Zero-value segments in the middle or end are omitted: `3600000` → `'1h'`, `3660000` → `'1h 1m'`\n7. Sub-second remainders are dropped once the duration is ≥ 1 second (no mixing `1m 5.3s`)\n\nThe function must be a named export so other modules can import it. Add unit tests in a colocated test file `src/inngest/functions/agent-loop/utils.test.ts` (create if it doesn't exist, append if it does) covering all cases listed above plus edge cases: very large values like `86400000` (24h), fractional ms like `1` → `'0s'` (rounds down sub-100ms), and `999` → `'1s'` (rounds to nearest tenth).",
|
|
"acceptance_criteria": [
|
|
"formatLoopDuration is exported from src/inngest/functions/agent-loop/utils.ts",
|
|
"formatLoopDuration(0) returns '0s'",
|
|
"formatLoopDuration(-100) returns '0s'",
|
|
"formatLoopDuration(500) returns '0.5s'",
|
|
"formatLoopDuration(5000) returns '5s'",
|
|
"formatLoopDuration(65000) returns '1m 5s'",
|
|
"formatLoopDuration(3661000) returns '1h 1m 1s'",
|
|
"formatLoopDuration(3600000) returns '1h'",
|
|
"Zero-value segments are omitted (no '0m' or '0s' padding)",
|
|
"All unit tests pass: bun test src/inngest/functions/agent-loop/utils.test.ts",
|
|
"TypeScript compiles cleanly: bunx tsc --noEmit"
|
|
],
|
|
"priority": 1,
|
|
"passes": false
|
|
}
|
|
]
|
|
}
|