Skip to content

Fix scaffold pain points + fix three regressions (plan prompt, mutation filter, migrations)#29

Merged
teallarson merged 2 commits intomainfrom
teallarson/fix-scaffold-issues
Mar 18, 2026
Merged

Fix scaffold pain points + fix three regressions (plan prompt, mutation filter, migrations)#29
teallarson merged 2 commits intomainfrom
teallarson/fix-scaffold-issues

Conversation

@teallarson
Copy link
Copy Markdown
Collaborator

@teallarson teallarson commented Mar 18, 2026

Summary

The first commit (ac3ae8e) introduced scaffold improvements but also caused three regressions. The second commit fixes all three:

Original improvements (ac3ae8e)

  • Plan route imports system prompt from shared lib/agent.ts / triage-agent.ts
  • NEXT_PUBLIC_APP_URL and BETTER_AUTH_URL derived from PORT in next.config.ts
  • Migration validation: verifies .sql files were generated before proceeding
  • New source mappings for Reddit, X, and Notion with icons
  • Bump version 0.4.1 → 0.5.0

Regression fixes (4ae140d)

  • P0 — Restore structured planning prompt: The shared system-prompt.md uses plain-text format, but the extractJsonBlocks() parser expects ```json:task / ```json:summary fenced blocks. Created a dedicated plan-prompt.md with the structured format and wired it into both ai-sdk and mastra plan routes.
  • P1 — Restore comprehensive mutation filter: The regex was narrowed to only delete|archive|remove|merge|close, allowing write tools (create, send, reply, post, etc.) through to the planner. Restored the full filter.
  • P2 — Template-aware migration recovery messages: Hardcoded "bun run db:setup" is wrong for langchain (Python/Alembic). Added formatMigrateCommands() helper that builds the correct command from meta.migrate.

Files changed

File Change
templates/_shared/plan-prompt.md New — structured planning prompt with json:task/json:summary format
templates/_shared/partials/plan-route-body.hbs Use planPrompt instead of systemPrompt; restore comprehensive mutation filter
templates/ai-sdk/template.json Add plan-prompt.md to sharedFiles
templates/mastra/template.json Add plan-prompt.md to sharedFiles
templates/ai-sdk/lib/agent.ts Export planPrompt
templates/mastra/src/mastra/agents/triage-agent.ts Export planPrompt
templates/ai-sdk/app/api/plan/route.ts.hbs Import planPrompt instead of systemPrompt
templates/mastra/app/api/plan/route.ts.hbs Import planPrompt instead of systemPrompt
src/post-scaffold.ts Add formatMigrateCommands() helper; use for recovery messages

Test plan

  • Scaffold ai-sdk template — verify lib/plan-prompt.md exists and plan route imports planPrompt
  • Scaffold mastra template — verify src/mastra/agents/plan-prompt.md exists and plan route imports planPrompt
  • Scaffold langchain template — verify unchanged (uses its own _build_plan_prompt())
  • Grep scaffolded output for mutation filter — confirm comprehensive regex (create, update, send, reply, etc.)
  • Simulate migration failure on langchain template — confirm recovery message shows .venv/bin/alembic upgrade head

🤖 Generated with Claude Code

teallarson and others added 2 commits March 18, 2026 11:32
…, migrations, source mapping

- B1: plan/route.ts now imports systemPrompt from lib/agent.ts (removes duplicate PLAN_SYSTEM_PROMPT)
- B2: mutation filter narrowed to destructive-only ops (delete/archive/remove/merge/close)
- B3: NEXT_PUBLIC_APP_URL and BETTER_AUTH_URL derived from PORT in next.config.ts
- B4: runMigrations verifies non-empty SQL output; adds db:setup script to templates
- B5: lib/sources.ts adds Reddit, X, and Notion source mappings
- Bump version to 0.5.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ration messages

The previous commit replaced the structured planning prompt (which emits
```json:task / ```json:summary blocks) with the general system prompt,
breaking the parser — zero tasks shown. This restores a dedicated
plan-prompt.md for the planning route.

Also restores the comprehensive mutation filter regex (create, update,
send, reply, etc.) and replaces hardcoded "bun run db:setup" recovery
messages with template-aware commands from meta.migrate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@teallarson teallarson changed the title Fix scaffold pain points (P1-P6) Fix scaffold pain points + fix three regressions (plan prompt, mutation filter, migrations) Mar 18, 2026
@teallarson teallarson requested a review from sdserranog March 18, 2026 19:15
@teallarson teallarson marked this pull request as ready for review March 18, 2026 19:15
Copy link
Copy Markdown
Contributor

@sdserranog sdserranog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@teallarson teallarson merged commit 6059c6a into main Mar 18, 2026
@teallarson teallarson deleted the teallarson/fix-scaffold-issues branch March 18, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants