Skip to content

HOK-1571: Surface project-context compaction suggestion in mill dashboard#573

Merged
timogilvie merged 3 commits intoauto/integrationfrom
task/surface-suggestion-to-compact-recent-work
May 8, 2026
Merged

HOK-1571: Surface project-context compaction suggestion in mill dashboard#573
timogilvie merged 3 commits intoauto/integrationfrom
task/surface-suggestion-to-compact-recent-work

Conversation

@timogilvie
Copy link
Copy Markdown
Owner

Summary

  • Detects when .wavemill/project-context.md exceeds the configured threshold (default 100KB) at mill startup and surfaces a warning with a compact option in the task-selection pane
  • Adds a compact-project-context tool and project-context-compactor library module that archives old "Recent Work" entries to a monthly archive file and rewrites the context file below the threshold
  • Wires the 'c' key in the mill task-selection loop to trigger compaction in-place, only shown when the file is actually oversized
  • Persists the oversize warning to wavemill state so the dashboard can surface it across sessions

Changes

  • shared/lib/project-context-compactor.ts — new module: threshold check, entry parsing, archive-and-rewrite logic
  • shared/lib/project-context-compactor.test.ts — unit tests including regression test for heading-format body preservation
  • tools/compact-project-context.ts — thin CLI wrapper calling the compactor
  • shared/lib/wavemill-common.shcheck_project_context_size() and project_context_suggestion_clear() functions; portable mtime detection (GNU stat/date with BSD date -r fallback)
  • shared/lib/wavemill-mill.sh — startup call to check_project_context_size; conditional 'c' prompt and handler in task-selection loop; restored SKIP_BACKLOG_SELECTION variable reference (was accidentally hardcoded to empty string)
  • shared/lib/wavemill-context.shproject_context_suggestion_set/clear for status display
  • shared/lib/wavemill-status.sh — reads project_context_suggestion from state to surface in status output
  • shared/lib/config.ts / wavemill-config.schema.jsonprojectContext.compactionThresholdKb and keepRecent config fields

Test plan

  • npx tsx --test shared/lib/project-context-compactor.test.ts — 8 tests covering threshold skip, dry-run, archive naming, header preservation, entry body preservation, and heading/separator format parsing
  • bash tests/project-context-suggestion.test.sh — shell integration tests for check_project_context_size and project_context_suggestion_clear
  • Manual: run wavemill mill against a repo with a >100KB project-context.md and verify the warning and 'c' prompt appear; verify 'c' compacts and clears the warning

Self-review

  • Iteration 1 (exit code 1 — blockers found): Fixed SKIP_BACKLOG_SELECTION variable reference accidentally replaced with empty string; conditionalized 'c to compact context' prompt to only show when PROJECT_CONTEXT_OVERSIZED is set; fixed date -r portability for Linux; fixed dryRun guard in threshold-skip path
  • Iteration 2 (exit code 2 — tool error, but blocker visible in partial output): Fixed data loss bug in parseRecentEntries regex — |$ with /gm flag matched end-of-line causing the lazy quantifier to capture only heading lines and silently drop entry bodies; replaced with |(?![\s\S]) (end-of-string); added tests
  • Iteration 3 (exit code 0 — verdict: ready): One warning about threshold display in skipped path (cosmetic, non-blocking)

@timogilvie timogilvie force-pushed the task/surface-suggestion-to-compact-recent-work branch from 77fca6c to 699f5e0 Compare May 8, 2026 21:58
@timogilvie
Copy link
Copy Markdown
Owner Author

Wavemill Merge failed

GraphQL: 3 of 3 required status checks are expected. (mergePullRequest)

timogilvie added 3 commits May 8, 2026 18:58
- Restore SKIP_BACKLOG_SELECTION variable reference (was accidentally replaced with empty string literal)
- Show 'c to compact context' prompt only when PROJECT_CONTEXT_OVERSIZED is set
- Fix date -r portability: try GNU stat/date first, fall back to BSD date -r
- Fix dry-run skip logic in compactor: return skipped=true for under-threshold files regardless of dryRun flag
Replace |$ with |(?![\s\S]) in the entry lookahead to use end-of-string
semantics instead of end-of-line, preventing the lazy quantifier from
stopping after the heading line and silently dropping entry bodies.

Add tests for dry-run under-threshold skip and heading-format body preservation.
@timogilvie timogilvie force-pushed the task/surface-suggestion-to-compact-recent-work branch from 699f5e0 to 8dde554 Compare May 8, 2026 22:58
@timogilvie
Copy link
Copy Markdown
Owner Author

Wavemill Merge failed

GraphQL: 3 of 3 required status checks are expected. (mergePullRequest)

@timogilvie timogilvie merged commit be150e8 into auto/integration May 8, 2026
3 checks passed
@timogilvie timogilvie deleted the task/surface-suggestion-to-compact-recent-work branch May 8, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant