with one click
add-converter
// Add a new resource type converter to acplugin (e.g., adding support for converting a new Claude Code resource type)
// Add a new resource type converter to acplugin (e.g., adding support for converting a new Claude Code resource type)
Add support for a new target platform to acplugin (e.g., Windsurf, Zed, etc.)
Publish acplugin to npm with version bump, build, test, and 2FA handling
Publish acplugin to npm with version bump, build, test, and 2FA handling
Add a new resource type converter to acplugin (e.g., adding support for converting a new Claude Code resource type)
Add support for a new target platform to acplugin (e.g., Windsurf, Zed, etc.)
Publish acplugin to npm with version bump, build, test, and 2FA handling
| name | add-converter |
| description | Add a new resource type converter to acplugin (e.g., adding support for converting a new Claude Code resource type) |
当需要支持转换新的 Claude Code 资源类型时,按以下步骤操作。
src/types.ts)添加新资源的接口定义和 frontmatter 类型(如果有),以及在 ScanResult 中添加字段。在 ConvertedFile.type 联合类型中添加新值。
src/scanner/claude.ts)创建并导出可复用的扫描函数(如 scanXxxDir()),这样 plugin.ts 也能使用。
在 scanClaudeProject() 中调用新函数。
src/scanner/plugin.ts)在 scanPlugin() 中调用新扫描函数,注意 plugin 目录结构与 .claude/ 不同:
.claude/xxx/xxx/(直接在 plugin 根目录下)更新 countResources() 包含新资源。
src/converter/xxx.ts)实现 convertXxx(item, platform) 函数,处理三个平台:
export function convertXxx(item: Xxx, platform: Platform): ConvertedFile {
switch (platform) {
case 'codex': return convertToCodex(item);
case 'opencode': return convertToOpenCode(item);
case 'cursor': return convertToCursor(item);
}
}
关键原则:
ConvertedFilesrc/writer/*.ts)在三个 writer 文件中调用新 converter,处理合并逻辑。
src/index.ts)更新 printScanResult() 和 convertSingleScan() 中的资源计数。
src/__tests__/xxx.test.ts)为新 converter 创建测试,覆盖三个平台的转换逻辑。
在 test-fixture/ 中添加新资源类型的示例文件,确保 scanner.test.ts 覆盖。
社区插件的 YAML 可能格式不规范。扫描函数中必须 try-catch parseFrontmatter(),解析失败时用空 frontmatter + 原始内容兜底。