Feature template tiles#207
Merged
Merged
Conversation
Complete implementation of tile-based template storage with 6 subtasks:
1. Extend itemType to accept string values
- Add type guards: isBuiltInItemType(), isReservedItemType(), isCustomItemType()
- Add RESERVED_ITEM_TYPES constant
- 33 unit tests
2. Add templateName column
- Migration 0015_add_template_name_column.sql
- Update types across layers (domain → infrastructure → API)
- 19 integration tests
3. Implement Template Resolver Service
- TemplateResolverService for tile-based template lookup
- TemplateData and TemplateWithChildren types
- TemplateNotFoundError for clear error handling
- 25 unit tests
4. Migrate Built-in Templates to Tile Storage
- Seed script: drizzle/seeds/templates.seed.ts (idempotent)
- Well-known coordinates under D1i4gEqbi01JWS2F6I7GUN8ekRiU2mjK,0:1,2,*
- 33 unit tests
5. Update buildPrompt to Use Tile-Based Templates
- Tile-based template lookup with TypeScript fallback
- {{@ChildTemplateName}} pre-processor syntax for sub-templates
- 43 unit tests
6. Add User Template Allowlist Enforcement
- TemplateAllowlistService for security validation
- Built-in templates always allowed
- Case-insensitive matching
- Visibility validation (public tiles require public templates)
- 56 unit tests
Architecture improvements (Rule-of-6 compliance):
- services/_templates/ subfolder for template services
- services/_context/ subfolder for context builders
- templates/_internals/ for shared utilities
Total: 209+ new tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…e column The templateName column was created with VARCHAR(255) and no unique constraint, but the spec in TEMPLATES_AS_TILES.md requires: - VARCHAR(100) length limit - UNIQUE constraint for global template name uniqueness Changes: - Add migration 0016 to add UNIQUE constraint and change column to VARCHAR(100) - Update schema definition to match (length: 100, uniqueIndex) This fixes 4 failing integration tests that validate these constraints. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add user_template_allowlist table for per-user allowed templates - Create DrizzleTemplateAllowlistRepository for database operations - Add tRPC endpoints: getEffectiveAllowlist, addToAllowlist, removeFromAllowlist - Update _TypeSelectorField to fetch allowed types from API dynamically - Change itemType from MapItemType enum to ItemTypeValue (MapItemType | string) - Update entire type chain: domain → infrastructure → services → API → cache - Add type assertions for enum comparisons to fix ESLint errors - Isolate flaky template-name-column tests in test runner - Fix migration to reference "users" table (not "user") 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement two-phase template rendering with child path syntax:
- child[-3].title, child[-2,-1].content for direct field access
- child[-6..-1], child[1..6] for range iteration
- {{@RenderChildren range=[-6..-1] fallback='generic'}} for pool dispatch
New modules:
- _pre-processor/_path-parser.ts: Parse child path expressions
- _pool/: Template pool types and builder for itemType matching
- _compiler/: Two-phase compile (structural template) + render (Mustache)
Key features:
- Templates match tiles by templateName (title) to itemType
- Recursive depth control via nested template pools
- Variable prefixing: {{title}} → {{child[-3].title}}
- Inspectable compiled templates showing exact prompt structure
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…te context
- Add {{@RenderAncestors fallback='...'}} tag for ancestor pool dispatch
- Allow direction 0 in range for hexplan tiles (range=[0..0])
- Add template context support via template[-1], template[-2], etc.
- Add ancestor path syntax: ancestor[-1] (parent), ancestor[-2] (grandparent)
- Update System Task Template to use:
- {{{template[-1].content}}} for hexrun-intro
- {{@RenderAncestors fallback='ancestor'}} for ancestors
- {{@RenderChildren range=[0..0] fallback='hexplan'}} for hexplan
- Add sub-templates: system (subtasks), ancestor, hexplan
- Add hexrun-intro as composed child of template tile
- Add plan for User Interlocutor Template migration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the restriction that prevented user tiles (tiles with empty path) from being compose expanded. This enables users to add composed children to their root tile, which is now relevant for the template system. Changes: - Remove isUserTile check from canShowComposition in MapUI.tsx - Remove isUserTile check from DynamicFrameCore.tsx - Remove isUserTile check from BaseFrame.tsx - Update test to expect user tiles can now show composition 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add USER_SUB_TEMPLATES with organizational, context, generic, section,
and recent-history templates for type-specific rendering
- Add USER_TEMPLATE_CONTEXT for user intro content at template[-1]
- Update USER_TEMPLATE to use {{@RenderChildren}} for pool-based dispatch
- Add _buildUserTemplateTile() and _buildTaskTileForUserTemplate() helpers
- Fix _renderChild to prefer tag fallback over pool default fallback
- Simplify UserTemplateData interface for pool-based rendering
Template dispatch priority: exact itemType match → tag fallback → pool fallback
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Architecture fixes: - Export isBuiltInItemType from mapping/utils for cross-domain access - Update _prompt-builder.ts to import from mapping/utils instead of infrastructure - Add TemplateAllowlistService and DrizzleTemplateAllowlistRepository to agentic index - Update agentic router to use domain index imports - Create dependencies.json for template-allowlist infrastructure - Add template-allowlist to infrastructure subsystems Test fix: - Update BaseFrame-composition test to expect user tiles CAN show composition (aligns with cc4d2c1 which removed user tile restriction) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix @typescript-eslint/no-unsafe-enum-comparison errors caused by comparing ItemTypeValue (MapItemType | string) with MapItemType enum. Root cause: ESLint cache was stale locally, hiding errors that CI (fresh checkout) detected. Fixed by adding explicit type assertions. Files fixed: - validation-strategy.ts (3 comparisons) - map-item-validation.ts (2 comparisons) - _map-management.service.ts (2 comparisons) - _map-item-movement-helpers.ts (1 comparison) - move-orchestrator.ts (1 comparison) - contracts.ts (1 comparison) - map-item-copy-helpers.test.ts (1 comparison) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Migrations 0013-0017 were not registered in meta/_journal.json, causing CI to skip them. This resulted in "column template_name does not exist" errors because the schema wasn't applied. Added journal entries for: - 0013_alter_tile_favorites_mapitemid_to_integer - 0014_migrate_item_types - 0015_add_template_name_column - 0016_fix_template_name_constraints - 0017_add_user_template_allowlist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Migration fix: - Make 0013 migration idempotent - checks if column is already integer before attempting text→integer conversion (0012 already creates as int) Circular import fix: - Move item-type-utils from infrastructure to utils to break cycle: map-item.ts → utils → infrastructure → map-item.ts - Use lazy initialization for MapItemType set to avoid undefined during module loading - Update infrastructure/index.ts to note new location - Update test imports to use new utils location 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Delete old infrastructure/map-item/item-type-utils.ts (had eager initialization causing circular import) - Update _item-crud.service.ts to import isBuiltInItemType from utils instead of infrastructure The lazy-initialized version in utils/item-type-utils.ts is the correct source for these utilities. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
No description provided.