spec(body-templates): per-doc body templates for Karpathy journals#390
Draft
tim-inkeep wants to merge 3 commits intomainfrom
Draft
spec(body-templates): per-doc body templates for Karpathy journals#390tim-inkeep wants to merge 3 commits intomainfrom
tim-inkeep wants to merge 3 commits intomainfrom
Conversation
Per-folder body templates as a sibling field to `frontmatter:` in
`folders[]` rules — `body:` (inline) and `bodyPath:` (file-ref) — with
{{var}} substitution at file creation time. Enables Karpathy-style
ingest folders + Obsidian-canonical daily-journal patterns through one
mechanism, no new abstraction beyond the existing folders array.
Includes:
- Grounding research at reports/per-doc-body-templates-karpathy-journals/
(REPORT.md + 3 evidence files; surveys Karpathy's documented workflow,
Obsidian Daily Notes/Templater/Periodic Notes, Hugo archetypes,
Logseq, GitHub issue templates, JetBrains, Notion DB templates)
- SPEC.md with 14 functional requirements, 23 decisions (most LOCKED),
9 non-goals, 5 personas, layered shared resolver in core for folder-
rule inheritance reused across body templates + future migrations
- Self-audit + design-challenge artifacts in meta/
Status: Draft — pending direction on Q1 (frontmatter dual-truth case
between virtual overlay and materialize-at-create).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Spec-only PR (markdown only — no source changes). Drafts a per-folder body template mechanism: a sibling field next to
frontmatter:on eachfolders[]rule, withbody:(inline) andbodyPath:(file-ref) variants and{{var}}substitution. Enables Karpathy-style ingest folders + Obsidian-canonical daily-journal patterns through one mechanism — no new abstraction beyond the existingfolders[]array.Status: Draft. Sharing for review before any implementation work starts.
What's in the diff
reports/per-doc-body-templates-karpathy-journals/— grounding research (REPORT.md + 3 evidence files). Surveys Karpathy's documented workflow, Obsidian Daily Notes / Templater / Periodic Notes, Hugo archetypes, Logseq, GitHub issue templates, JetBrains, Notion DB templates. Locks an MVP shape.specs/2026-04-30-per-doc-body-templates/SPEC.md— full spec with 14 functional requirements, 23 decisions (most LOCKED), 11 non-goals, 5 personas, layered shared resolver in core for folder-rule inheritance reused across body templates + future migrations.specs/2026-04-30-per-doc-body-templates/meta/— self-audit + design-challenge artifacts (1 HIGH severity finding caught + applied, 7 design challenges with resolutions).Highlights of locked decisions
body:(inline string) +bodyPath:(file-reference). When both set,bodyPath:wins; falls back tobody:if file unreadable. (D1, D8){{var}}and{{var:format}}— Obsidian-canonical. Variables in MVP:date,date:FORMAT(moment.js tokens),title,path,user. Single-pass substitution; undefined vars left literal + warned. (D6, D7, FR-4, FR-5)POST /api/create-page+ MCPwrite_document/create_pagewhen target doesn't exist AND agent body is empty (whitespace-only afterstripFrontmatter). Agent-supplied non-empty body always wins. (D3, D4, D5)folders[]rules;body+bodyPathare one logical "body template" field. Specific-wins (not general-wins). Tags concat across all layers. Override direction: file > more-specific folder > less-specific folder. (D10, FR-8)packages/core/src/config/folder-rule-resolver.tsexposing layered primitives (L1 folder-only / L2 file-frontmatter merge / L3 convenience). Body templates consume L1 only. Existing MCP virtual-overlay sites can migrate later. (D23){{user}}resolves only to principal-identity display name — agent display name intentionally NOT in fallback chain (avoidsauthor: Claude Codeleak in user files). (D11)One open question pending direction
Q1 — frontmatter dual-truth case. Currently
folders[].frontmatteris a virtual read-time overlay (verified inmcp/tools/{exec,read-document,search}.ts). Body templates are the FIRST materialize-at-create feature. For rules with BOTHfrontmatter:ANDbody:set, this creates an asymmetry (MCP responses show frontmatter; on-disk file doesn't).Three options:
frontmatter:-only stay virtual-overlay-only.frontmatter:always (separate spec).Resolver layering (D23) was designed so this is a call-site decision, not a resolver change — whichever option you pick, the resolver doesn't change.
Estimated implementation
~800-1200 LOC including tests. Roughly 2-4 days for a developer who knows the codebase. Detailed file-by-file breakdown in the closing comment of the conversation that produced this spec.
Test plan
/shipfor implementation🤖 Generated with Claude Code