77 lines
4.5 KiB
Markdown

# SLICE 1 — Groundwork: process rules + body-fetch optimization
> **State-saving rule:** update this file immediately after EVERY completed task (tick the checkbox, update Status and Resume notes) and whenever pausing for input — automatically, without being asked. State on disk must always match reality.
## Status
**COMPLETE** (2026-07-15). All six tasks done; 97/97 tests pass. Ready to
proceed to SLICE2.
Decision recorded 2026-07-15: body-fetch optimization (Task 4) is scoped
**plumbing-only, behaviour-preserving** — add the fields-hint adapter param and
drop `body` only where `extractGtdBlock` is provably never called (both-`none`
paths). No change to card styling/title for `todos: all`. This lands the adapter
plumbing SLICE3's `scope: all` needs without altering render output.
Pending user input (non-blocking, defaults recorded in SLICE4):
1. gtd-gantt fence disambiguation: `project:` key present = item block,
absent = chart block (chart filters via `filter-project:`).
2. Dateless gantt items: excluded with a warning (no Unscheduled strip).
## Goal
Set up the working rules for the whole effort and land the performance
optimization that `scope: all` (SLICE3) depends on.
## Tasks
- [x] Verify `.git/info/exclude` covers local guidance, planning files, and`n other workspace-only metadata. Confirmed 2026-07-15; no change needed.
- [x] Establish the .jpl archive rule: `scripts/archive-jpl.sh` moves existing
`publish/*.jpl` to `build-archive/<name>-<version>-<yyyymmdd-HHMMSS>.jpl`.
Wired as the `predist` npm script so it runs automatically before every
`npm run dist`. Validated 2026-07-15 (archives + no-op-on-empty both work).
CORRECTION (2026-07-15, during first real `npm run dist`): the archive was
originally written to `publish/archive/`, but webpack's `buildMain` step
runs `fs.removeSync(publishDir)` (wipes it) and `package.json`
`"files": ["publish"]` would ship it to npm. Moved to repo-root
`build-archive/` (git-ignored, outside publish/). local guidance + .gitignore
updated. Re-validated with a full `npm run dist`: archive survives, fresh
jpl written to publish/.
- [x] Fix `jest.config.js` ESM/CJS mismatch (`export default``module.exports`).
Done 2026-07-15: `npx jest` runs, all 88 tests pass (8 suites).
- [x] Body-fetch optimization (plumbing-only, behaviour-preserving). Done 2026-07-15:
- `DataAdapter.getNotesInFolder` gains an `includeBody: boolean` fetch hint;
`RawNote.body` is now optional. Real adapter (`index.ts`) requests
`NOTE_FIELDS_WITH_BODY` vs `NOTE_FIELDS` accordingly.
- Each collector computes `needsBody` before the fetch:
events = `notes !== "none" || todos !== "none"`;
kanban/matrix = `todos !== "none"`.
These are exactly the paths where `extractGtdBlock` is reached, so render
output is identical — body is only dropped for degenerate empty views.
- `extractGtdBlock` param widened to `string | undefined` (already guarded
by `body || ""`).
Investigation confirmed the slice's stated "todos: all" win is NOT
behaviour-preserving (block is read for card styling even in `all` mode),
so it was deliberately excluded per the recorded decision. The value here is
the adapter plumbing that SLICE3's `scope: all` needs.
- [x] Unit tests for the fields-hint logic. Done 2026-07-15:
`src/tests/Gtd/fieldsHint.test.ts` — a recording adapter asserts each
collector passes the correct `includeBody` flag per mode (9 cases).
- [x] Run full test suite; record results here. 2026-07-15: **97 passed, 97 total**
(9 suites) — 88 pre-existing + 9 new fields-hint cases.
## Decisions / notes
- Node on this machine: 18.19.1 (WSL Ubuntu). Jest 30.
- Run all commands via `wsl -d Ubuntu -- bash -c "cd ~/projects/joplin-plugin-gtd-calendar && ..."`.
## Resume notes
SLICE1 is complete. Files touched:
- `jest.config.js` (`export default``module.exports`)
- `scripts/archive-jpl.sh` (new) + `predist` npm script in `package.json`
- `src/Gtd/types.ts` (`RawNote.body` optional; `getNotesInFolder` gains `includeBody`)
- `src/index.ts` (`NOTE_FIELDS` / `NOTE_FIELDS_WITH_BODY`, conditional fetch)
- `src/Gtd/collectEvents.ts`, `collectKanban.ts`, `collectMatrix.ts` (`needsBody`)
- `src/Gtd/gtdBlock.ts` (param `string | undefined`)
- `src/tests/Gtd/fieldsHint.test.ts` (new)
Nothing left open. `npx tsc --noEmit` shows only pre-existing `api/` typing
errors (generated Joplin typings referencing absent modules); no new errors in
`src/`. Next: SLICE2.