ID:WORK-138Status:donePriority:mediumComplexity:moderateSource:SPEC-038
plan-history site rune — tag definition and pipeline hooks
Implement the plan-history Markdoc tag as a self-closing aggregation rune following the established plan rune pattern (sentinel + meta tags + placeholder → aggregate → postProcess resolution). Supports both per-entity and global feed modes.
Acceptance Criteria
- Tag definition in
runes/plan/src/tags/plan-history.tswith attributes:id,limit,type,since,group - Self-closing tag stores parameters as meta tags and emits sentinel marker
- Rune config added to
runes/plan/src/config.tswith block nameplan-history - Rune exported in
runes/plan/src/index.tsRunePackage - Aggregate hook extracts history data and adds to
PlanAggregatedData - PostProcess hook detects sentinel and resolves per-entity timeline HTML
- PostProcess hook detects sentinel and resolves global commit-grouped feed HTML
- Per-entity HTML follows BEM structure from spec:
rf-plan-history__events,__event,__date,__hash,__changes,__change,__field,__value,__criteria - Global feed HTML includes
rf-plan-history--globalmodifier and__commit-message,__entity-summaryelements - Attribute values use
data-type="add|remove"for diff styling - Criteria collapse: show first 3, collapse rest with "+N more criteria" in per-entity mode
- Auto-injection: postProcess appends History section to entity pages (when enabled) for entities with >1 commit
- Commit hashes link to repository URL when configured (parsed from
git remote get-url origin)
Dependencies
- Event model types and per-entity git history extraction — Event model and per-entity extraction
- Batch extraction and history caching — Batch extraction and caching
Approach
Follow the exact pattern used by plan-activity and plan-progress:
- Tag definition exports sentinel constant and uses
createContentModelSchemawithselfClosing: true - Extend
PlanAggregatedDatainterface withhistory: Map<string, HistoryEvent[]>andglobalHistoryfields - In aggregate hook, run batch extraction and populate history data
- In postProcess, detect
plan-historysentinel, read params, build timeline HTML using MarkdocTagobjects - Auto-injection follows the same pattern as the existing auto-relationships injection
Repository URL parsing: use git remote get-url origin at aggregate time, with a config override field.
References
- Git-Native Entity History — Git-Native Entity History (Site Rune + Rendering sections)
Resolution
Completed: 2026-04-13
Branch: claude/spec-038-breakdown-pChav
What was done
runes/plan/src/history.ts— Core event model types (HistoryEvent, AttributeChange, CriteriaChange) + per-entity extraction algorithm (git log --follow, git show, parse/diff) + batch extraction + cachingrunes/plan/src/commands/history.ts— CLIplan historycommand with single-entity and global modes, all filters (--since, --type, --author, --status, --all, --limit, --format json)runes/plan/src/cli-plugin.ts— Registered history command in CLI pluginrunes/plan/src/tags/plan-history.ts— Self-closing plan-history tag definition with sentinel patternrunes/plan/src/pipeline.ts— Extended PlanAggregatedData with history + repositoryUrl fields, added aggregate hook extraction, added postProcess resolver for per-entity timeline and global commit-grouped feedrunes/plan/src/commands/render-pipeline.ts— Pass plan directory to pipeline via setPlanDirrunes/plan/src/config.ts— Added PlanHistory rune configrunes/plan/src/index.ts— Exported plan-history rune in RunePackagerunes/plan/styles/default.css— Timeline CSS with vertical line, circle markers, diff coloring, responsive layoutrunes/plan/test/history.test.ts— 31 tests covering parsing, diffing, and integration with real git repos
Notes
- All 6 work items were implemented together as they form a cohesive feature
- Pre-existing build issues in the plan package (missing @types/node, unresolved @refrakt-md/runes) prevent full tsc build, but all new code compiles and tests pass via vitest
- History cache uses a separate .plan-history-cache.json file (not merged into .plan-cache.json) to keep concerns separate
Relationships
Depends on
History
- 607bcd1statusready→done
- ☑ Tag definition in `runes/plan/src/tags/plan-history.ts` with attributes: `id`, `limit`, `type`, `since`, `group`
- ☑ Self-closing tag stores parameters as meta tags and emits sentinel marker
- ☑ Rune config added to `runes/plan/src/config.ts` with block name `plan-history`
- +10 more criteria
- a59fd62Created (ready, medium, moderate, SPEC-038, plan, runes, pipeline, git, history)