feat(cli): add gram plan and bring the rests and the plan to the editor, the diff and the playground #81

Merged
abiwab merged 6 commits from feat/schedule-consumers into main 2026-10-04 12:51:29 +02:00
Owner

PR 5 of the 1.4.0 scheduler plan (`.notes/plan-scheduler-1-4.md`, section 11): the consumers. One commit per area.

  • CLI
    • `gram plan --serve "2026-10-11 13:00" [--tz] [--available ...] [--format text|md|html|json] [--ics file]`. `--available` is repeatable (`08:00-22:00`, `fri=18:00-22:00`, `2026-10-09=none`, several ranges with commas); citty keeps only the last value of a repeated flag, so they are read from the raw arguments. No `--available` means all day. `--tz` defaults to the machine's zone (the one place where the machine is read, at the CLI boundary), `--now` makes the "start in the past" check testable.
    • `--ics`: RFC 5545 file, events in UTC, `VALARM` on the tasks that need the hands, deterministic (the stamp is `--now`), text escaped, lines folded at 75 octets without cutting a character. The status goes to stderr so `--format json --ics` stays pipeable.
    • `--rests` on `view`, `export`, `print` and `cook`; `cook` also gets `--mise-en-place`.
    • Thin command, logic in `services/planner.ts`, `plan-flags.ts`, `ics.ts`.
  • Renderer / scheduler: `describeRunSheet()` exposes the sheet in words (the ICS is built from it), and `parseInstant`, `parseLocalIso`, `toLocalIso`, `toUtcIso` are exported.
  • Language server / VS Code: `gram.rests` (preview, Gantt, title hint; re-renders open recipes when it changes, same plumbing and tests as `gram.miseEnPlace`). `SESSION_OVERFLOW` shows as a warning on its section (test added).
  • Analyzer: `gram diff` reads the active time from the schedule (an active range counts on its longest figure, so editing `~{20-25min}` shows), falling back on the old metric for JSON without `tasks`.
  • Playground: a rests selector next to the mise en place one (both shared by the preview, the Gantt chart and the Markdown view), a "Plan" popover (serving time, zone, availability range) that puts the Gantt chart on the calendar, and a "Production sheet" tab. All remembered in `localStorage` inside `try/catch`; a plan that cannot be made is reported next to the controls. Playground chunk 505 KB for 800 KB.

Checks: 1647 tests, lint, typecheck, build, conformance, `deprecations:check`, any-ratchet, `dedupe:check`, docs build. `gram plan` is tested as a real process (flags, formats, ICS, errors, `--rests` on the other commands).

I could not look at the playground in a browser here (the Chrome extension was not connected): types, build and bundle size are checked, but the popover layout and the new tab deserve a look.

Not in this PR: docs (the next one), `gram cook` guided in real hours with notifications (out of the 1.4.0 scope).

PR 5 of the 1.4.0 scheduler plan (\`.notes/plan-scheduler-1-4.md\`, section 11): the consumers. One commit per area. - **CLI** - \`gram plan <recipe> --serve "2026-10-11 13:00" [--tz] [--available ...] [--format text|md|html|json] [--ics file]\`. \`--available\` is repeatable (\`08:00-22:00\`, \`fri=18:00-22:00\`, \`2026-10-09=none\`, several ranges with commas); citty keeps only the last value of a repeated flag, so they are read from the raw arguments. No \`--available\` means all day. \`--tz\` defaults to the machine's zone (the one place where the machine is read, at the CLI boundary), \`--now\` makes the "start in the past" check testable. - \`--ics\`: RFC 5545 file, events in UTC, \`VALARM\` on the tasks that need the hands, deterministic (the stamp is \`--now\`), text escaped, lines folded at 75 octets without cutting a character. The status goes to stderr so \`--format json --ics\` stays pipeable. - \`--rests\` on \`view\`, \`export\`, \`print\` and \`cook\`; \`cook\` also gets \`--mise-en-place\`. - Thin command, logic in \`services/planner.ts\`, \`plan-flags.ts\`, \`ics.ts\`. - **Renderer / scheduler**: \`describeRunSheet()\` exposes the sheet in words (the ICS is built from it), and \`parseInstant\`, \`parseLocalIso\`, \`toLocalIso\`, \`toUtcIso\` are exported. - **Language server / VS Code**: \`gram.rests\` (preview, Gantt, title hint; re-renders open recipes when it changes, same plumbing and tests as \`gram.miseEnPlace\`). \`SESSION_OVERFLOW\` shows as a warning on its section (test added). - **Analyzer**: \`gram diff\` reads the active time from the schedule (an active range counts on its longest figure, so editing \`~{20-25min}\` shows), falling back on the old metric for JSON without \`tasks\`. - **Playground**: a rests selector next to the mise en place one (both shared by the preview, the Gantt chart and the Markdown view), a "Plan" popover (serving time, zone, availability range) that puts the Gantt chart on the calendar, and a "Production sheet" tab. All remembered in \`localStorage\` inside \`try/catch\`; a plan that cannot be made is reported next to the controls. Playground chunk 505 KB for 800 KB. Checks: 1647 tests, lint, typecheck, build, conformance, \`deprecations:check\`, any-ratchet, \`dedupe:check\`, docs build. \`gram plan\` is tested as a real process (flags, formats, ICS, errors, \`--rests\` on the other commands). I could not look at the playground in a browser here (the Chrome extension was not connected): types, build and bundle size are checked, but the popover layout and the new tab deserve a look. Not in this PR: docs (the next one), \`gram cook\` guided in real hours with notifications (out of the 1.4.0 scope).
abiwab scheduled this pull request to auto merge when all checks succeed 2026-10-04 12:50:13 +02:00
abiwab merged commit 99f429f3ec into main 2026-10-04 12:51:29 +02:00
abiwab deleted branch feat/schedule-consumers 2026-10-04 12:51:29 +02:00
Sign in to join this conversation.
No description provided.