feat: add hybrid /add-extension skill for merging SE-2 extensions#1232
feat: add hybrid /add-extension skill for merging SE-2 extensions#1232technophile-04 wants to merge 6 commits intomainfrom
Conversation
Split extension merging into deterministic (Node.js script) and intelligent (Claude AI) operations. The script handles fetch, copy, and package.json merge, then outputs structured JSON tasks for Claude to process .args.mjs files and resolve file conflicts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rin-st
left a comment
There was a problem hiding this comment.
This is great Shiv! 1.7k+ lines of clean code, it's a joy to read it!
Review fixes applied
- Inlined
file_conflictextension content into JSON (was pointing to deleted temp files)- Added path traversal validation in
copyFile- Added bounds checking for
--localand--solidity-frameworkCLI flags- Removed dead
--yesflag- Fixed
showHelpto callgetExtensionsRegistry()directly instead ofvalidateExtensionName('_dummy_')- Added numeric type detection in
inferExportType- Expanded SKILL.md with detailed merge strategies and missing-file handling
Thanks for fixing bugs from my pr! I've met some of them but forgot to fix
Added my thoughts regarding PR. In short, I'm not sure it's a good approach long term, but it could work for some time until we change extensions structure.
note: Maybe we need to change most of extensions just to AI instructions? In that case adding extensions will be much simpler (I think you guys have similar thoughts)
YESS! I think we should focus on this maybe more? Maybe we add the SKILL.md (which maybe contain some metdata for AI like what this extesnion does, maybe a diff giving how this extesnion deviates from base create-eth) and then the files in extension will just contain the whole files code no .arg.mjs files? I also pushed some commits so now instead of hardcoding the patterns for the AI to guess, we ask it to fetch the https://github.com/scaffold-eth/create-eth/blob/main/contributors/TEMPLATE-FILES.md (subagent) does this so we dont' burn the context window. Also I think this file serves as source of truth with all the examples. |
Looking good to me! Not sure if we need to merge it though, or if we need to think about new structure of extensions and try to implement first. Or it could be next iteration |
Co-authored-by: Rinat <rin-st@users.noreply.github.com>
Co-authored-by: Rinat <rin-st@users.noreply.github.com>
|
Thanks @rin-st for testing! Just moved the skills to
cc @carletex for this. I think maybe we can ship this as initial version since again it doesn't have any damange on core logic. |
|
Pushed ef7d876 cleaning up few things:
|
Summary
/add-extension) that merges scaffold-eth extensions into existing SE-2 projects post-creationadd-extensionbranch approach which re-implemented create-eth's template processing pipeline (~700 lines of template code eliminated)How to test
/add-extension erc-20OR/add-extension add drizzle-neon and ponderin a clean SE-2 project — the script should copy files, merge package.json, then Claude processes the.args.mjstasksnode .claude/skills/add-extension/skill.mjs erc-20 --dry-run— should show change summary and AI merge tasks without applyingnode .claude/skills/add-extension/skill.mjs --list— should show all available extensionsyarn install && yarn next:buildshould succeedArchitecture
Things to look out for
merger.mjsvalidates destination paths stay within project root.args.mjscontent and modified file content are inlined into JSON output before temp directory cleanup, so Claude never needs to read temp filesDetailed changes
Key design decisions
.args.mjsfiles are read as raw text (noimport(), nonew Function()) — safer and simpler/export\s+const\s+(\w+)\s*=/g), types inferred by peeking at first characterfile_conflicttasks inline the extension file content (survives temp cleanup)preContent,extraMenuLinksObjects,configOverrides,fullContentOverride,extraContents,additionalVars,deploymentsLogic,$$expr$$convention, etc.What was eliminated vs previous
add-extensionbranchlib/templateMerger.mjs(257 lines) — fetched templates from GitHub, executed withnew Function()lib/templateUtils.mjs(137 lines) — path inference, diff generation, dynamic importlib/extensionTracker.mjs(44 lines) — parsedwithDefaultscalls from remote templateslib/create-eth-utils/utils.js(265 lines) — vendored create-eth utilities with@fastify/deepmerge@fastify/deepmergedependency (no longer needed)Review fixes applied
file_conflictextension content into JSON (was pointing to deleted temp files)copyFile--localand--solidity-frameworkCLI flags--yesflagshowHelpto callgetExtensionsRegistry()directly instead ofvalidateExtensionName('_dummy_')inferExportType🤖 Generated with Claude Code