opencastle 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/README.md +26 -9
  2. package/bin/cli.mjs +6 -0
  3. package/dist/cli/adapters/antigravity.d.ts +0 -1
  4. package/dist/cli/adapters/antigravity.d.ts.map +1 -1
  5. package/dist/cli/adapters/antigravity.js +2 -1
  6. package/dist/cli/adapters/antigravity.js.map +1 -1
  7. package/dist/cli/adapters/claude-code.d.ts +0 -1
  8. package/dist/cli/adapters/claude-code.d.ts.map +1 -1
  9. package/dist/cli/adapters/claude-code.js +0 -1
  10. package/dist/cli/adapters/claude-code.js.map +1 -1
  11. package/dist/cli/adapters/cursor.d.ts.map +1 -1
  12. package/dist/cli/adapters/cursor.js +8 -1
  13. package/dist/cli/adapters/cursor.js.map +1 -1
  14. package/dist/cli/adapters/opencode.d.ts +12 -5
  15. package/dist/cli/adapters/opencode.d.ts.map +1 -1
  16. package/dist/cli/adapters/opencode.js +17 -5
  17. package/dist/cli/adapters/opencode.js.map +1 -1
  18. package/dist/cli/adapters/rules-dir-base.d.ts +12 -1
  19. package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
  20. package/dist/cli/adapters/rules-dir-base.js +43 -57
  21. package/dist/cli/adapters/rules-dir-base.js.map +1 -1
  22. package/dist/cli/adapters/rules-dir-base.test.js +27 -18
  23. package/dist/cli/adapters/rules-dir-base.test.js.map +1 -1
  24. package/dist/cli/adapters/single-file-base.d.ts +11 -0
  25. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  26. package/dist/cli/adapters/single-file-base.js +44 -14
  27. package/dist/cli/adapters/single-file-base.js.map +1 -1
  28. package/dist/cli/adapters/vscode.d.ts +2 -1
  29. package/dist/cli/adapters/vscode.d.ts.map +1 -1
  30. package/dist/cli/adapters/vscode.js +2 -1
  31. package/dist/cli/adapters/vscode.js.map +1 -1
  32. package/dist/cli/adapters/windsurf.d.ts.map +1 -1
  33. package/dist/cli/adapters/windsurf.js +11 -1
  34. package/dist/cli/adapters/windsurf.js.map +1 -1
  35. package/dist/cli/agent-plugin.d.ts +119 -0
  36. package/dist/cli/agent-plugin.d.ts.map +1 -0
  37. package/dist/cli/agent-plugin.js +449 -0
  38. package/dist/cli/agent-plugin.js.map +1 -0
  39. package/dist/cli/agent-plugin.test.d.ts +2 -0
  40. package/dist/cli/agent-plugin.test.d.ts.map +1 -0
  41. package/dist/cli/agent-plugin.test.js +227 -0
  42. package/dist/cli/agent-plugin.test.js.map +1 -0
  43. package/dist/cli/baseline.d.ts.map +1 -1
  44. package/dist/cli/baseline.js +114 -34
  45. package/dist/cli/baseline.js.map +1 -1
  46. package/dist/cli/ci.d.ts.map +1 -1
  47. package/dist/cli/ci.js +18 -4
  48. package/dist/cli/ci.js.map +1 -1
  49. package/dist/cli/codex-target.test.js +14 -1
  50. package/dist/cli/codex-target.test.js.map +1 -1
  51. package/dist/cli/convoy/gates.d.ts +2 -20
  52. package/dist/cli/convoy/gates.d.ts.map +1 -1
  53. package/dist/cli/convoy/gates.js +3 -111
  54. package/dist/cli/convoy/gates.js.map +1 -1
  55. package/dist/cli/copy.d.ts +0 -8
  56. package/dist/cli/copy.d.ts.map +1 -1
  57. package/dist/cli/copy.js +0 -21
  58. package/dist/cli/copy.js.map +1 -1
  59. package/dist/cli/dispatcher.test.js +2 -2
  60. package/dist/cli/dispatcher.test.js.map +1 -1
  61. package/dist/cli/docs-accuracy.test.js +2 -0
  62. package/dist/cli/docs-accuracy.test.js.map +1 -1
  63. package/dist/cli/doctor.d.ts.map +1 -1
  64. package/dist/cli/doctor.js +2 -0
  65. package/dist/cli/doctor.js.map +1 -1
  66. package/dist/cli/doctor.test.js +2 -2
  67. package/dist/cli/doctor.test.js.map +1 -1
  68. package/dist/cli/explain.d.ts +5 -0
  69. package/dist/cli/explain.d.ts.map +1 -1
  70. package/dist/cli/explain.js +38 -2
  71. package/dist/cli/explain.js.map +1 -1
  72. package/dist/cli/init.test.js +78 -42
  73. package/dist/cli/init.test.js.map +1 -1
  74. package/dist/cli/layers.d.ts +8 -0
  75. package/dist/cli/layers.d.ts.map +1 -1
  76. package/dist/cli/layers.js +130 -13
  77. package/dist/cli/layers.js.map +1 -1
  78. package/dist/cli/layers.test.js +2 -2
  79. package/dist/cli/layers.test.js.map +1 -1
  80. package/dist/cli/legacy-install.test.js +8 -1
  81. package/dist/cli/legacy-install.test.js.map +1 -1
  82. package/dist/cli/lesson-command.test.d.ts +2 -0
  83. package/dist/cli/lesson-command.test.d.ts.map +1 -0
  84. package/dist/cli/lesson-command.test.js +100 -0
  85. package/dist/cli/lesson-command.test.js.map +1 -0
  86. package/dist/cli/lesson.d.ts +0 -9
  87. package/dist/cli/lesson.d.ts.map +1 -1
  88. package/dist/cli/lesson.js +212 -276
  89. package/dist/cli/lesson.js.map +1 -1
  90. package/dist/cli/lessons.d.ts +134 -0
  91. package/dist/cli/lessons.d.ts.map +1 -0
  92. package/dist/cli/lessons.js +493 -0
  93. package/dist/cli/lessons.js.map +1 -0
  94. package/dist/cli/lessons.test.d.ts +2 -0
  95. package/dist/cli/lessons.test.d.ts.map +1 -0
  96. package/dist/cli/lessons.test.js +214 -0
  97. package/dist/cli/lessons.test.js.map +1 -0
  98. package/dist/cli/managed-paths.d.ts.map +1 -1
  99. package/dist/cli/managed-paths.js +3 -1
  100. package/dist/cli/managed-paths.js.map +1 -1
  101. package/dist/cli/mcp-audit.d.ts.map +1 -1
  102. package/dist/cli/mcp-audit.js +2 -0
  103. package/dist/cli/mcp-audit.js.map +1 -1
  104. package/dist/cli/mcp-upgrade.test.js +24 -1
  105. package/dist/cli/mcp-upgrade.test.js.map +1 -1
  106. package/dist/cli/mcp.d.ts.map +1 -1
  107. package/dist/cli/mcp.js +22 -3
  108. package/dist/cli/mcp.js.map +1 -1
  109. package/dist/cli/pack-plugins.d.ts +8 -0
  110. package/dist/cli/pack-plugins.d.ts.map +1 -0
  111. package/dist/cli/pack-plugins.js +70 -0
  112. package/dist/cli/pack-plugins.js.map +1 -0
  113. package/dist/cli/plugin-command.test.d.ts +2 -0
  114. package/dist/cli/plugin-command.test.d.ts.map +1 -0
  115. package/dist/cli/plugin-command.test.js +114 -0
  116. package/dist/cli/plugin-command.test.js.map +1 -0
  117. package/dist/cli/plugin.d.ts +30 -0
  118. package/dist/cli/plugin.d.ts.map +1 -0
  119. package/dist/cli/plugin.js +291 -0
  120. package/dist/cli/plugin.js.map +1 -0
  121. package/dist/cli/promote-command.test.d.ts +2 -0
  122. package/dist/cli/promote-command.test.d.ts.map +1 -0
  123. package/dist/cli/promote-command.test.js +151 -0
  124. package/dist/cli/promote-command.test.js.map +1 -0
  125. package/dist/cli/promote.d.ts +12 -0
  126. package/dist/cli/promote.d.ts.map +1 -0
  127. package/dist/cli/promote.js +364 -0
  128. package/dist/cli/promote.js.map +1 -0
  129. package/dist/cli/secret-scan.d.ts +21 -0
  130. package/dist/cli/secret-scan.d.ts.map +1 -0
  131. package/dist/cli/secret-scan.js +114 -0
  132. package/dist/cli/secret-scan.js.map +1 -0
  133. package/dist/cli/sync-check.d.ts.map +1 -1
  134. package/dist/cli/sync-check.js +9 -0
  135. package/dist/cli/sync-check.js.map +1 -1
  136. package/dist/cli/sync-check.test.js +5 -4
  137. package/dist/cli/sync-check.test.js.map +1 -1
  138. package/dist/cli/team-commands.test.js +14 -2
  139. package/dist/cli/team-commands.test.js.map +1 -1
  140. package/dist/cli/team-sources.test.js +10 -0
  141. package/dist/cli/team-sources.test.js.map +1 -1
  142. package/dist/cli/types.d.ts +1 -1
  143. package/dist/cli/types.d.ts.map +1 -1
  144. package/dist/cli/update.d.ts.map +1 -1
  145. package/dist/cli/update.js +18 -0
  146. package/dist/cli/update.js.map +1 -1
  147. package/dist/cli/windsurf-target.test.d.ts +2 -0
  148. package/dist/cli/windsurf-target.test.d.ts.map +1 -0
  149. package/dist/cli/windsurf-target.test.js +62 -0
  150. package/dist/cli/windsurf-target.test.js.map +1 -0
  151. package/dist/orchestrator/plugins/agent-plugins.test.d.ts +2 -0
  152. package/dist/orchestrator/plugins/agent-plugins.test.d.ts.map +1 -0
  153. package/dist/orchestrator/plugins/agent-plugins.test.js +32 -0
  154. package/dist/orchestrator/plugins/agent-plugins.test.js.map +1 -0
  155. package/dist/orchestrator/plugins/registry.test.d.ts +2 -0
  156. package/dist/orchestrator/plugins/registry.test.d.ts.map +1 -0
  157. package/dist/orchestrator/plugins/registry.test.js +37 -0
  158. package/dist/orchestrator/plugins/registry.test.js.map +1 -0
  159. package/package.json +2 -1
  160. package/src/cli/adapters/antigravity.ts +2 -1
  161. package/src/cli/adapters/claude-code.ts +0 -1
  162. package/src/cli/adapters/cursor.ts +8 -1
  163. package/src/cli/adapters/opencode.ts +18 -6
  164. package/src/cli/adapters/rules-dir-base.test.ts +28 -18
  165. package/src/cli/adapters/rules-dir-base.ts +51 -90
  166. package/src/cli/adapters/single-file-base.ts +53 -14
  167. package/src/cli/adapters/vscode.ts +2 -1
  168. package/src/cli/adapters/windsurf.ts +11 -1
  169. package/src/cli/agent-plugin.test.ts +267 -0
  170. package/src/cli/agent-plugin.ts +469 -0
  171. package/src/cli/baseline.ts +115 -32
  172. package/src/cli/ci.ts +19 -4
  173. package/src/cli/codex-target.test.ts +15 -1
  174. package/src/cli/convoy/gates.ts +9 -142
  175. package/src/cli/copy.ts +0 -25
  176. package/src/cli/dispatcher.test.ts +2 -2
  177. package/src/cli/docs-accuracy.test.ts +2 -0
  178. package/src/cli/doctor.test.ts +2 -2
  179. package/src/cli/doctor.ts +2 -0
  180. package/src/cli/explain.ts +36 -2
  181. package/src/cli/fixtures/lessons-template-1.0.md +70 -0
  182. package/src/cli/init.test.ts +82 -42
  183. package/src/cli/layers.test.ts +2 -2
  184. package/src/cli/layers.ts +144 -14
  185. package/src/cli/legacy-install.test.ts +11 -1
  186. package/src/cli/lesson-command.test.ts +117 -0
  187. package/src/cli/lesson.ts +215 -266
  188. package/src/cli/lessons.test.ts +254 -0
  189. package/src/cli/lessons.ts +540 -0
  190. package/src/cli/managed-paths.ts +3 -1
  191. package/src/cli/mcp-audit.ts +2 -0
  192. package/src/cli/mcp-upgrade.test.ts +26 -1
  193. package/src/cli/mcp.ts +22 -3
  194. package/src/cli/pack-plugins.ts +70 -0
  195. package/src/cli/plugin-command.test.ts +125 -0
  196. package/src/cli/plugin.ts +309 -0
  197. package/src/cli/promote-command.test.ts +170 -0
  198. package/src/cli/promote.ts +371 -0
  199. package/src/cli/secret-scan.ts +154 -0
  200. package/src/cli/sync-check.test.ts +5 -4
  201. package/src/cli/sync-check.ts +9 -0
  202. package/src/cli/team-commands.test.ts +18 -2
  203. package/src/cli/team-sources.test.ts +11 -0
  204. package/src/cli/types.ts +1 -1
  205. package/src/cli/update.ts +20 -0
  206. package/src/cli/windsurf-target.test.ts +70 -0
  207. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  208. package/src/orchestrator/agents/researcher.agent.md +1 -1
  209. package/src/orchestrator/customizations/LESSONS-LEARNED.md +10 -66
  210. package/src/orchestrator/customizations/README.md +2 -1
  211. package/src/orchestrator/customizations/logs/README.md +1 -1
  212. package/src/orchestrator/plugins/agent-plugins.test.ts +34 -0
  213. package/src/orchestrator/plugins/astro/mcp.json +9 -0
  214. package/src/orchestrator/plugins/astro/plugin.json +21 -0
  215. package/src/orchestrator/plugins/chrome-devtools/mcp.json +13 -0
  216. package/src/orchestrator/plugins/chrome-devtools/plugin.json +21 -0
  217. package/src/orchestrator/plugins/cloudflare/mcp.json +9 -0
  218. package/src/orchestrator/plugins/cloudflare/plugin.json +21 -0
  219. package/src/orchestrator/plugins/contentful/mcp.json +13 -0
  220. package/src/orchestrator/plugins/contentful/plugin.json +21 -0
  221. package/src/orchestrator/plugins/convex/mcp.json +15 -0
  222. package/src/orchestrator/plugins/convex/plugin.json +21 -0
  223. package/src/orchestrator/plugins/coolify/mcp.json +13 -0
  224. package/src/orchestrator/plugins/coolify/plugin.json +25 -0
  225. package/src/orchestrator/plugins/cypress/plugin.json +21 -0
  226. package/src/orchestrator/plugins/drizzle/plugin.json +21 -0
  227. package/src/orchestrator/plugins/expo/mcp.json +9 -0
  228. package/src/orchestrator/plugins/expo/plugin.json +21 -0
  229. package/src/orchestrator/plugins/figma/mcp.json +9 -0
  230. package/src/orchestrator/plugins/figma/plugin.json +21 -0
  231. package/src/orchestrator/plugins/hetzner/plugin.json +24 -0
  232. package/src/orchestrator/plugins/jira/mcp.json +9 -0
  233. package/src/orchestrator/plugins/jira/plugin.json +21 -0
  234. package/src/orchestrator/plugins/linear/mcp.json +9 -0
  235. package/src/orchestrator/plugins/linear/plugin.json +21 -0
  236. package/src/orchestrator/plugins/netlify/mcp.json +13 -0
  237. package/src/orchestrator/plugins/netlify/plugin.json +21 -0
  238. package/src/orchestrator/plugins/nextjs/mcp.json +13 -0
  239. package/src/orchestrator/plugins/nextjs/plugin.json +21 -0
  240. package/src/orchestrator/plugins/notion/mcp.json +9 -0
  241. package/src/orchestrator/plugins/notion/plugin.json +21 -0
  242. package/src/orchestrator/plugins/nx/mcp.json +14 -0
  243. package/src/orchestrator/plugins/nx/plugin.json +21 -0
  244. package/src/orchestrator/plugins/playwright/mcp.json +13 -0
  245. package/src/orchestrator/plugins/playwright/plugin.json +21 -0
  246. package/src/orchestrator/plugins/prisma/mcp.json +14 -0
  247. package/src/orchestrator/plugins/prisma/plugin.json +21 -0
  248. package/src/orchestrator/plugins/registry.test.ts +42 -0
  249. package/src/orchestrator/plugins/resend/mcp.json +13 -0
  250. package/src/orchestrator/plugins/resend/plugin.json +24 -0
  251. package/src/orchestrator/plugins/sanity/mcp.json +9 -0
  252. package/src/orchestrator/plugins/sanity/plugin.json +21 -0
  253. package/src/orchestrator/plugins/sentry/mcp.json +12 -0
  254. package/src/orchestrator/plugins/sentry/plugin.json +24 -0
  255. package/src/orchestrator/plugins/slack/mcp.json +13 -0
  256. package/src/orchestrator/plugins/slack/plugin.json +24 -0
  257. package/src/orchestrator/plugins/strapi/mcp.json +13 -0
  258. package/src/orchestrator/plugins/strapi/plugin.json +21 -0
  259. package/src/orchestrator/plugins/stripe/mcp.json +9 -0
  260. package/src/orchestrator/plugins/stripe/plugin.json +21 -0
  261. package/src/orchestrator/plugins/supabase/mcp.json +9 -0
  262. package/src/orchestrator/plugins/supabase/plugin.json +21 -0
  263. package/src/orchestrator/plugins/teams/plugin.json +24 -0
  264. package/src/orchestrator/plugins/trello/mcp.json +13 -0
  265. package/src/orchestrator/plugins/trello/plugin.json +25 -0
  266. package/src/orchestrator/plugins/turborepo/plugin.json +21 -0
  267. package/src/orchestrator/plugins/vercel/mcp.json +9 -0
  268. package/src/orchestrator/plugins/vercel/plugin.json +21 -0
  269. package/src/orchestrator/plugins/vitest/plugin.json +21 -0
  270. package/src/orchestrator/skill-config-links.test.ts +2 -1
  271. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +1 -1
  272. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  273. package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
  274. package/src/orchestrator/skills/memory-merger/SKILL.md +17 -21
  275. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +44 -23
  276. package/src/orchestrator/skills/self-improvement/SKILL.md +30 -15
  277. /package/src/orchestrator/plugins/astro/{SKILL.md → skills/astro-framework/SKILL.md} +0 -0
  278. /package/src/orchestrator/plugins/chrome-devtools/{SKILL.md → skills/browser-testing/SKILL.md} +0 -0
  279. /package/src/orchestrator/plugins/cloudflare/{SKILL.md → skills/cloudflare-platform/SKILL.md} +0 -0
  280. /package/src/orchestrator/plugins/contentful/{SKILL.md → skills/contentful-cms/SKILL.md} +0 -0
  281. /package/src/orchestrator/plugins/convex/{SKILL.md → skills/convex-database/SKILL.md} +0 -0
  282. /package/src/orchestrator/plugins/coolify/{SKILL.md → skills/coolify-deployment/SKILL.md} +0 -0
  283. /package/src/orchestrator/plugins/cypress/{SKILL.md → skills/cypress-testing/SKILL.md} +0 -0
  284. /package/src/orchestrator/plugins/drizzle/{SKILL.md → skills/drizzle-orm/SKILL.md} +0 -0
  285. /package/src/orchestrator/plugins/expo/{SKILL.md → skills/expo-development/SKILL.md} +0 -0
  286. /package/src/orchestrator/plugins/figma/{SKILL.md → skills/figma-design/SKILL.md} +0 -0
  287. /package/src/orchestrator/plugins/hetzner/{SKILL.md → skills/hetzner-cloud/SKILL.md} +0 -0
  288. /package/src/orchestrator/plugins/jira/{SKILL.md → skills/jira-management/SKILL.md} +0 -0
  289. /package/src/orchestrator/plugins/linear/{SKILL.md → skills/linear-task-management/SKILL.md} +0 -0
  290. /package/src/orchestrator/plugins/netlify/{SKILL.md → skills/netlify-deployment/SKILL.md} +0 -0
  291. /package/src/orchestrator/plugins/nextjs/{SKILL.md → skills/nextjs-framework/SKILL.md} +0 -0
  292. /package/src/orchestrator/plugins/notion/{SKILL.md → skills/notion-knowledge-management/SKILL.md} +0 -0
  293. /package/src/orchestrator/plugins/nx/{SKILL.md → skills/nx-workspace/SKILL.md} +0 -0
  294. /package/src/orchestrator/plugins/playwright/{SKILL.md → skills/playwright-testing/SKILL.md} +0 -0
  295. /package/src/orchestrator/plugins/prisma/{SKILL.md → skills/prisma-database/SKILL.md} +0 -0
  296. /package/src/orchestrator/plugins/resend/{SKILL.md → skills/resend-email/SKILL.md} +0 -0
  297. /package/src/orchestrator/plugins/sanity/{SKILL.md → skills/sanity-cms/SKILL.md} +0 -0
  298. /package/src/orchestrator/plugins/sentry/{SKILL.md → skills/sentry-monitoring/SKILL.md} +0 -0
  299. /package/src/orchestrator/plugins/slack/{SKILL.md → skills/slack-notifications/SKILL.md} +0 -0
  300. /package/src/orchestrator/plugins/strapi/{SKILL.md → skills/strapi-cms/SKILL.md} +0 -0
  301. /package/src/orchestrator/plugins/stripe/{SKILL.md → skills/stripe-payments/SKILL.md} +0 -0
  302. /package/src/orchestrator/plugins/supabase/{SKILL.md → skills/supabase-database/SKILL.md} +0 -0
  303. /package/src/orchestrator/plugins/teams/{SKILL.md → skills/teams-notifications/SKILL.md} +0 -0
  304. /package/src/orchestrator/plugins/trello/{SKILL.md → skills/trello-task-management/SKILL.md} +0 -0
  305. /package/src/orchestrator/plugins/turborepo/{SKILL.md → skills/turborepo-monorepo/SKILL.md} +0 -0
  306. /package/src/orchestrator/plugins/vercel/{SKILL.md → skills/vercel-deployment/SKILL.md} +0 -0
  307. /package/src/orchestrator/plugins/vitest/{SKILL.md → skills/vitest-testing/SKILL.md} +0 -0
@@ -1,7 +1,8 @@
1
- import { resolve, join, basename } from 'node:path'
1
+ import { resolve, join, basename, dirname } from 'node:path'
2
2
  import { mkdir, writeFile, readdir, readFile, unlink, rename } from 'node:fs/promises'
3
- import { existsSync, readdirSync, realpathSync } from 'node:fs'
3
+ import { existsSync, readdirSync, realpathSync, rmdirSync } from 'node:fs'
4
4
  import { withSource, type CompileSource } from '../layers.js'
5
+ import { copyDir, mergeCopyResults } from '../copy.js'
5
6
  import { scaffoldMcpConfigInto } from '../mcp.js'
6
7
  import type { CopyResults, DoctorCheck, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
7
8
  import { splitFrontmatter, parseFrontmatterString } from './frontmatter.js'
@@ -14,7 +15,7 @@ import { writeManagedBlock, recordMerge } from '../managed-block.js'
14
15
  * copilot-instructions.md → <rootRulesFile>
15
16
  * instructions/*.md → <configDir>/rules/*<ruleExt> (always applies)
16
17
  * agents/*.agent.md → <configDir>/rules/agents/*<ruleExt>
17
- * skills/{star}/SKILL.md → <configDir>/rules/skills/*<ruleExt>
18
+ * skills/{star}/SKILL.md → <skillsDir>/<name>/SKILL.md, as Agent Skills
18
19
  * agent-workflows/*.md → <configDir>/rules/agent-workflows/*<ruleExt>
19
20
  * prompts/*.prompt.md → <configDir>/rules/prompts/*<ruleExt>
20
21
  *
@@ -50,6 +51,17 @@ export interface RulesDirConfig {
50
51
  ruleExt: string
51
52
  /** Renders the YAML frontmatter lines (without the `---` fences). */
52
53
  renderFrontmatter(scope: RuleScope): string[]
54
+ /**
55
+ * Where the IDE reads Agent Skills, relative to the project root.
56
+ *
57
+ * Cursor and Windsurf both read `SKILL.md` folders natively now. Flattened
58
+ * into rules, as every release before this one did, a skill lost its scripts
59
+ * and assets, could not be invoked by name, and was matched on its
60
+ * description as a rule instead of loaded as a skill.
61
+ */
62
+ skillsDir: string
63
+ /** The project MCP config, when it is not `<configDir>/mcp.json`. */
64
+ mcpConfigPath?: string
53
65
  }
54
66
 
55
67
  export interface RulesDirAdapter {
@@ -96,12 +108,13 @@ async function reconcileCase(onDisk: string, visited: Set<string>): Promise<bool
96
108
  export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
97
109
  const { ideId, ideLabel, rootRulesFile, configDir, ruleExt, renderFrontmatter } = config
98
110
  const rulesPrefix = `${configDir}/rules`
99
- const mcpPath = `${configDir}/mcp.json`
111
+ const mcpPath = config.mcpConfigPath ?? `${configDir}/mcp.json`
100
112
 
101
113
  const rootIntro = [
102
114
  '# Project Instructions',
103
115
  '',
104
- `All conventions, architecture, and project context live in \`${rulesPrefix}/\`. Read those files before making changes.`,
116
+ `All conventions, architecture, and project context live in \`${rulesPrefix}/\`. Read those files before making changes. ` +
117
+ `Skills are in \`${config.skillsDir}/\` — load one when a task matches its description.`,
105
118
  '',
106
119
  ].join('\n')
107
120
 
@@ -115,21 +128,11 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
115
128
  interface ConvertFileOptions {
116
129
  alwaysApply?: boolean
117
130
  descriptionFallback?: string
118
- /**
119
- * Rewrites the body before the rule is assembled.
120
- *
121
- * A skill's siblings land at `skills/<skill>/<NAME><ruleExt>` while the skill
122
- * itself is `skills/<skill><ruleExt>`, so a pointer the source writes as
123
- * `REFERENCE.md` is wrong twice over here: wrong directory and wrong
124
- * extension. Fourteen skills point at a sibling this way, and on Cursor and
125
- * Windsurf every one of those pointers led nowhere.
126
- */
127
- rewriteBody?: (_body: string) => string
128
131
  }
129
132
 
130
133
  async function convertFile(
131
134
  srcPath: string,
132
- { alwaysApply = false, descriptionFallback = '', rewriteBody }: ConvertFileOptions = {},
135
+ { alwaysApply = false, descriptionFallback = '' }: ConvertFileOptions = {},
133
136
  ): Promise<string> {
134
137
  const content = await readFile(srcPath, 'utf8')
135
138
  const { frontmatter, body } = splitFrontmatter(content)
@@ -147,7 +150,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
147
150
  applyTo: meta['applyTo'],
148
151
  alwaysApply,
149
152
  tier: meta['tier'],
150
- }), '---', '', (rewriteBody ? rewriteBody(body) : body).trim(), '']
153
+ }), '---', '', body.trim(), '']
151
154
  return lines.join('\n')
152
155
  }
153
156
 
@@ -230,74 +233,15 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
230
233
  }
231
234
  }
232
235
 
233
- /**
234
- * Points a skill's sibling references at where this adapter actually puts them.
235
- *
236
- * `REFERENCE.md` and `./REFERENCE.md` both become `<skill>/REFERENCE<ruleExt>`,
237
- * which covers the markdown links most skills use and the bare prose mentions
238
- * a few of them use instead.
239
- */
240
- function retargetSiblings(body: string, skill: string, extras: string[]): string {
241
- let out = body
242
- for (const extra of extras) {
243
- const target = `${skill}/${ruleName(extra)}`
244
- // Escaped because sibling names carry dots, and one carries two
245
- // (`panel-report.template.md`), each of which would otherwise match any
246
- // character and retarget text that is not a path.
247
- const escaped = extra.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
248
- out = out.replace(new RegExp(`(?<![\\w/-])(?:\\./)?${escaped}(?![\\w-])`, 'g'), target)
249
- }
250
- return out
251
- }
252
-
253
- async function convertSkills(
254
- srcRoot: string,
255
- destDir: string,
256
- results: CopyResults,
257
- overwrite = false,
258
- excludedSkills?: Set<string>,
259
- ): Promise<void> {
236
+ /** Skills as Agent Skills: each `<name>/` folder, every file in it, frontmatter kept. */
237
+ async function copySkills(srcRoot: string, projectRoot: string, results: CopyResults, overwrite: boolean): Promise<void> {
260
238
  const skillsDir = resolve(srcRoot, 'skills')
261
239
  if (!existsSync(skillsDir)) return
262
-
263
- await mkdir(destDir, { recursive: true })
264
-
240
+ const dest = resolve(projectRoot, config.skillsDir)
241
+ await mkdir(dest, { recursive: true })
265
242
  for (const entry of await readdir(skillsDir, { withFileTypes: true })) {
266
- if (!entry.isDirectory()) continue
267
- if (excludedSkills?.has(entry.name)) continue
268
- const skillFile = resolve(skillsDir, entry.name, 'SKILL.md')
269
- if (!existsSync(skillFile)) continue
270
-
271
- // Extra files in the skill directory (e.g. templates). Resolved before the
272
- // skill is written, because the skill's own pointers at them have to be
273
- // rewritten to where they actually land.
274
- const files = await readdir(resolve(skillsDir, entry.name))
275
- const extras = files.filter((f) => f !== 'SKILL.md' && f.endsWith('.md'))
276
-
277
- await writeConverted(
278
- skillFile,
279
- resolve(destDir, `${entry.name}${ruleExt}`),
280
- {
281
- descriptionFallback: `Skill: ${entry.name}`,
282
- rewriteBody: (body) => retargetSiblings(body, entry.name, extras),
283
- },
284
- results,
285
- overwrite,
286
- )
287
-
288
- if (extras.length > 0) {
289
- const subDest = resolve(destDir, entry.name)
290
- await mkdir(subDest, { recursive: true })
291
- for (const file of extras) {
292
- await writeConverted(
293
- resolve(skillsDir, entry.name, file),
294
- resolve(subDest, ruleName(file)),
295
- { descriptionFallback: `${entry.name}: ${basename(file, '.md')}` },
296
- results,
297
- overwrite,
298
- )
299
- }
300
- }
243
+ if (!entry.isDirectory() || !existsSync(resolve(skillsDir, entry.name, 'SKILL.md'))) continue
244
+ mergeCopyResults(results, await copyDir(resolve(skillsDir, entry.name), resolve(dest, entry.name), { overwrite }))
301
245
  }
302
246
  }
303
247
 
@@ -336,7 +280,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
336
280
  descriptionPrefix: 'Agent: ',
337
281
  removeExt: '.agent.md',
338
282
  })
339
- await convertSkills(srcRoot, resolve(rulesRoot, 'skills'), results, false)
283
+ await copySkills(srcRoot, projectRoot, results, false)
340
284
  await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
341
285
  descriptionPrefix: 'Workflow: ',
342
286
  excludeFiles: new Set(['README.md']),
@@ -380,10 +324,12 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
380
324
  // Note what is here, so the sweep below can name what it removes. A file
381
325
  // disappearing with no line of output is not a warning the user saw.
382
326
  const beforeSweep = new Map<string, string>()
383
- if (existsSync(rulesRoot)) {
384
- for (const rel of filesUnderDir(rulesRoot)) {
385
- beforeSweep.set(resolve(rulesRoot, rel), `${configDir}/rules/${rel}`)
386
- }
327
+ for (const [root, label] of [
328
+ [rulesRoot, `${configDir}/rules`],
329
+ [resolve(projectRoot, config.skillsDir), config.skillsDir],
330
+ ]) {
331
+ if (!existsSync(root)) continue
332
+ for (const rel of filesUnderDir(root)) beforeSweep.set(resolve(root, rel), `${label}/${rel}`)
387
333
  }
388
334
 
389
335
  await convertDir(srcRoot, 'instructions', rulesRoot, results, {
@@ -395,7 +341,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
395
341
  removeExt: '.agent.md',
396
342
  overwrite: true,
397
343
  })
398
- await convertSkills(srcRoot, resolve(rulesRoot, 'skills'), results, true)
344
+ await copySkills(srcRoot, projectRoot, results, true)
399
345
  await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
400
346
  descriptionPrefix: 'Workflow: ',
401
347
  overwrite: true,
@@ -417,10 +363,25 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
417
363
  // reported as a stray first and removed here. That is what makes
418
364
  // `sync --check` clearable.
419
365
  const visited = new Set(results.visited ?? [])
366
+ const emptied = new Set<string>()
420
367
  for (const [abs, rel] of beforeSweep) {
421
368
  if (await reconcileCase(abs, visited)) continue
422
369
  await unlink(abs)
423
370
  ;(results.deleted ??= []).push(rel)
371
+ emptied.add(dirname(abs))
372
+ }
373
+ // Folders this sweep emptied — a skill moved out of `rules/skills/`, or one
374
+ // with no source left — go too; the roots themselves stay.
375
+ const roots = [rulesRoot, resolve(projectRoot, config.skillsDir)]
376
+ for (const start of [...emptied].sort((a, b) => b.length - a.length)) {
377
+ for (let dir = start; !roots.includes(dir) && roots.some((r) => dir.startsWith(r)); dir = dirname(dir)) {
378
+ try {
379
+ if (readdirSync(dir).length > 0) break
380
+ rmdirSync(dir)
381
+ } catch {
382
+ break
383
+ }
384
+ }
424
385
  }
425
386
 
426
387
  // Customizations are NEVER overwritten.
@@ -438,7 +399,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
438
399
  // `.cursor/rules/team-conventions.mdc` and reported "all clear" moments
439
400
  // before `sync` removed it. This is Cursor's documented place for project
440
401
  // rules, so that file is one people really do write.
441
- framework: [`${rulesPrefix}/`],
402
+ framework: [`${rulesPrefix}/`, `${config.skillsDir}/`],
442
403
  customizable: ['.opencastle/', mcpPath],
443
404
  }
444
405
  }
@@ -448,7 +409,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
448
409
  { label: `${ideLabel} rules file`, path: rootRulesFile, type: 'file' },
449
410
  { label: 'Instruction rules', path: `${rulesPrefix}/`, type: 'dir', countContents: true, countFilter: ruleExt },
450
411
  { label: 'Agent rules', path: `${rulesPrefix}/agents/`, type: 'dir', countContents: true, countFilter: ruleExt },
451
- { label: 'Skill rules', path: `${rulesPrefix}/skills/`, type: 'dir', countContents: true, countFilter: ruleExt },
412
+ { label: 'Skills directory', path: `${config.skillsDir}/`, type: 'dir', countContents: true },
452
413
  { label: 'Workflow rules', path: `${rulesPrefix}/agent-workflows/`, type: 'dir', countContents: true },
453
414
  { label: 'Prompt rules', path: `${rulesPrefix}/prompts/`, type: 'dir', countContents: true },
454
415
  ]
@@ -1,6 +1,6 @@
1
- import { resolve, basename, relative, sep } from 'node:path'
1
+ import { resolve, basename, dirname, relative, sep } from 'node:path'
2
2
  import { mkdir, writeFile, readdir, readFile, rm, rename } from 'node:fs/promises'
3
- import { existsSync, readdirSync, realpathSync } from 'node:fs'
3
+ import { existsSync, readdirSync, realpathSync, rmdirSync } from 'node:fs'
4
4
  import { writeManagedBlock, recordMerge } from '../managed-block.js'
5
5
  import { TIERS, TIER_IDS, isTier, tierForAgent, type Tier } from '../tiers.js'
6
6
  import { mergeCopyResults, copyDir } from '../copy.js'
@@ -38,6 +38,14 @@ export interface SingleFileAdapterConfig {
38
38
  * `.codex/skills/` this wrote was never loaded.
39
39
  */
40
40
  skillsDir?: string
41
+ /**
42
+ * Another root file this assistant also reads, and the targets that write
43
+ * it. With one of them selected the instructions are already in context
44
+ * through that file, so this one says where they are instead of repeating
45
+ * them: Antigravity reads `AGENTS.md` and `GEMINI.md` together, and with
46
+ * Codex or OpenCode also selected it loaded every instruction twice.
47
+ */
48
+ alsoReads?: { rootFile: string; writtenBy: IdeChoice[] }
41
49
  /**
42
50
  * Output an earlier release wrote outside today's framework directories,
43
51
  * present on disk now, relative to the project root. Removed on update.
@@ -48,16 +56,17 @@ export interface SingleFileAdapterConfig {
48
56
  /**
49
57
  * Creates install/update/getManagedPaths functions from a config object.
50
58
  *
51
- * Both Claude Code and OpenCode share the same structure:
52
- * 1. A single root .md file with embedded instructions, agent index, and skill index
53
- * 2. Agent definitions stripped of frontmatter
54
- * 3. Skills stripped of frontmatter
55
- * 4. Prompts stripped of frontmatter
56
- * 5. Workflows stripped of frontmatter
57
- * 6. Customizations scaffolded once
58
- * 7. MCP config scaffolded once
59
+ * Claude Code, OpenCode, Codex CLI and Antigravity share one structure:
60
+ * 1. A single root .md file — a managed block with the instructions, the agent
61
+ * index and the skill index
62
+ * 2. Agent definitions, frontmatter stripped
63
+ * 3. Skills as `<name>/SKILL.md` folders with their files, frontmatter kept —
64
+ * assistants find a skill by its `name` and `description`
65
+ * 4. Prompts and workflows, frontmatter stripped
66
+ * 5. The MCP config, merged into whatever the file already holds
59
67
  *
60
- * The only differences are directory names and file naming conventions.
68
+ * The differences are directory names, the skills directory, and file naming.
69
+ * `.opencastle/` is scaffolded by `init`, not by an adapter.
61
70
  */
62
71
  /**
63
72
  * Targets that compile to the same root file, in resolution order.
@@ -72,7 +81,7 @@ export interface SingleFileAdapterConfig {
72
81
  */
73
82
  const SHARED_ROOT_OWNERS: Record<string, Array<{ ide: string; dotDir: string; skillsDir: string }>> = {
74
83
  'AGENTS.md': [
75
- { ide: 'opencode', dotDir: '.opencode', skillsDir: '.opencode/skills' },
84
+ { ide: 'opencode', dotDir: '.opencode', skillsDir: '.agents/skills' },
76
85
  { ide: 'codex', dotDir: '.codex', skillsDir: '.agents/skills' },
77
86
  ],
78
87
  }
@@ -96,7 +105,9 @@ function referenceDir(config: SingleFileAdapterConfig, stack?: StackConfig): {
96
105
  const present = owners.filter((o) => selected.has(o.ide))
97
106
  if (present.length < 2) return { dir: config.dotDir, skills: skillsDirOf(config), sharedWith: [] }
98
107
  const [first, ...rest] = present
99
- const elsewhere = rest.flatMap((o) => (o.skillsDir.startsWith(`${o.dotDir}/`) ? [o.dotDir] : [o.dotDir, o.skillsDir]))
108
+ const elsewhere = rest.flatMap((o) =>
109
+ o.skillsDir.startsWith(`${o.dotDir}/`) || o.skillsDir === first.skillsDir ? [o.dotDir] : [o.dotDir, o.skillsDir],
110
+ )
100
111
  return { dir: first.dotDir, skills: first.skillsDir, sharedWith: elsewhere }
101
112
  }
102
113
 
@@ -322,7 +333,14 @@ export function createSingleFileAdapter(
322
333
  sections.push(skillLines.join('\n'))
323
334
  }
324
335
 
325
- const merge = await writeManagedBlock(rootPath, sections.join('\n'))
336
+ const deferTo = config.alsoReads && stack?.ides.some((i) => config.alsoReads!.writtenBy.includes(i)) ? config.alsoReads.rootFile : null
337
+ const body = deferTo
338
+ ? '# Project Instructions\n\n' +
339
+ `This project's instructions, agent index and skill index are in \`${deferTo}\`, which this assistant also reads — ` +
340
+ 'they are not repeated here, so they load once. ' +
341
+ `Skills are in \`${skillsDirOf(config)}/\`; agent definitions are in \`${config.dotDir}/agents/\`.`
342
+ : sections.join('\n')
343
+ const merge = await writeManagedBlock(rootPath, body)
326
344
  recordMerge(results, rootPath, merge)
327
345
  }
328
346
 
@@ -472,12 +490,19 @@ export function createSingleFileAdapter(
472
490
  // deletion was silent and the categories looked right.
473
491
  const written = new Set<string>(installResult.visited ?? [])
474
492
  for (const dirPath of sweptDirs) {
493
+ const emptied = new Set<string>()
475
494
  for (const rel of filesUnderDir(dirPath)) {
476
495
  const abs = resolve(dirPath, rel)
477
496
  if (await reconcileCase(abs, written)) continue
478
497
  ;(results.deleted ??= []).push(before.get(abs) ?? rel)
479
498
  await rm(abs, { force: true })
499
+ emptied.add(dirname(abs))
480
500
  }
501
+ // A skill whose last file went leaves its folder, and an assistant that
502
+ // scans the directory sees a skill with no SKILL.md. Only folders this
503
+ // sweep emptied: an empty directory standing where a generated file
504
+ // belongs is a fault for a person, and every check names it as one.
505
+ pruneEmptied(dirPath, emptied)
481
506
  }
482
507
  // What an earlier release put where this one no longer writes — the
483
508
  // un-namespaced commands at the top of `.claude/commands/`. Asked after the
@@ -555,6 +580,20 @@ export function createSingleFileAdapter(
555
580
  return { install, update, getManagedPaths, getDoctorChecks, getLegacyOutputs }
556
581
  }
557
582
 
583
+ /** Remove each of `dirs` that is now empty, and its parents up to `root`, which stays. */
584
+ function pruneEmptied(root: string, dirs: Set<string>): void {
585
+ for (const start of [...dirs].sort((a, b) => b.length - a.length)) {
586
+ for (let dir = start; dir !== root && dir.startsWith(root); dir = dirname(dir)) {
587
+ try {
588
+ if (readdirSync(dir).length > 0) break
589
+ rmdirSync(dir)
590
+ } catch {
591
+ break
592
+ }
593
+ }
594
+ }
595
+ }
596
+
558
597
  /** Every file under a directory, relative to it. */
559
598
  function filesUnderDir(root: string): string[] {
560
599
  const out: string[] = []
@@ -20,7 +20,8 @@ import { isOurVscodePrompt, legacyVscodePrompts, vscodePromptFile, withCommandNa
20
20
  * skills/ → .github/skills/
21
21
  * agent-workflows/ → .github/agent-workflows/
22
22
  * prompts/<name>.prompt.md → .github/prompts/oc.<name>.prompt.md (/oc:<name>)
23
- * customizations/ → .opencastle/ (scaffolded once)
23
+ *
24
+ * `.opencastle/` is scaffolded by `init`, not here.
24
25
  */
25
26
 
26
27
  export const IDE_ID = 'vscode'
@@ -1,10 +1,18 @@
1
1
  import { createRulesDirAdapter } from './rules-dir-base.js'
2
2
 
3
3
  /**
4
- * Windsurf adapter — a rules-directory IDE writing `.md` files.
4
+ * Windsurf adapter — Windsurf is now Devin Desktop. A rules-directory IDE
5
+ * writing `.md` files, with skills as Agent Skills.
5
6
  *
6
7
  * Windsurf replaces Cursor's boolean with a single `trigger` enum, so the glob
7
8
  * case and the always-on case are mutually exclusive rather than combinable.
9
+ *
10
+ * Both of Devin Desktop's agents read skills from `.agents/skills/`, so skills
11
+ * go there, shared with every other target that reads it. MCP servers go to
12
+ * `.devin/mcp_config.json`, the project file the default Devin Local agent
13
+ * reads; the legacy Cascade agent reads only its global config. Releases
14
+ * before this one wrote `.windsurf/mcp.json`, which nothing reads — `sync`
15
+ * takes our servers back out of it.
8
16
  */
9
17
  const adapter = createRulesDirAdapter({
10
18
  ideId: 'windsurf',
@@ -12,6 +20,8 @@ const adapter = createRulesDirAdapter({
12
20
  rootRulesFile: '.windsurfrules',
13
21
  configDir: '.windsurf',
14
22
  ruleExt: '.md',
23
+ skillsDir: '.agents/skills',
24
+ mcpConfigPath: '.devin/mcp_config.json',
15
25
  renderFrontmatter({ description, applyTo, alwaysApply, tier }) {
16
26
  let trigger: 'always_on' | 'model_decision' | 'glob'
17
27
  let globs: string[] | undefined