cue-ai 0.9.4 → 0.11.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 (1627) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +86 -256
  3. package/bin/cue-learnings +11 -3
  4. package/dist/cue.js +50597 -35330
  5. package/get.sh +43 -24
  6. package/install.sh +68 -45
  7. package/package.json +16 -5
  8. package/plugins/cue/.claude-plugin/plugin.json +19 -0
  9. package/plugins/cue/commands/cue-current.md +4 -0
  10. package/plugins/cue/commands/cue-mcps.md +4 -0
  11. package/plugins/cue/commands/cue-reload.md +6 -2
  12. package/plugins/cue/commands/cue-setup.md +40 -0
  13. package/plugins/cue/commands/cue-skills.md +4 -0
  14. package/plugins/cue/commands/cue-switch.md +4 -0
  15. package/plugins/cue/commands/cue.md +4 -0
  16. package/profiles/SCHEMA.md +242 -161
  17. package/profiles/_types.ts +300 -205
  18. package/profiles/aas-agents-orchestration/profile.yaml +44 -0
  19. package/profiles/aas-agents-quality-governance/profile.yaml +24 -0
  20. package/profiles/aas-agents-voice/profile.yaml +24 -0
  21. package/profiles/aas-ai-context-prompts/profile.yaml +36 -0
  22. package/profiles/aas-ai-evaluation-research/profile.yaml +26 -0
  23. package/profiles/aas-ai-infrastructure/profile.yaml +24 -0
  24. package/profiles/aas-ai-media-models/profile.yaml +27 -0
  25. package/profiles/aas-ai-personas/profile.yaml +28 -0
  26. package/profiles/aas-ai-products-agents/profile.yaml +34 -0
  27. package/profiles/aas-ai-retrieval-memory/profile.yaml +30 -0
  28. package/profiles/aas-architecture/profile.yaml +39 -0
  29. package/profiles/aas-automation/profile.yaml +25 -0
  30. package/profiles/aas-backend-api-design/profile.yaml +28 -0
  31. package/profiles/aas-backend-auth/profile.yaml +23 -0
  32. package/profiles/aas-backend-integrations/profile.yaml +24 -0
  33. package/profiles/aas-backend-services/profile.yaml +32 -0
  34. package/profiles/aas-blockchain/profile.yaml +24 -0
  35. package/profiles/aas-browser/profile.yaml +23 -0
  36. package/profiles/aas-business-finance-risk/profile.yaml +26 -0
  37. package/profiles/aas-business-odoo/profile.yaml +38 -0
  38. package/profiles/aas-business-operations/profile.yaml +32 -0
  39. package/profiles/aas-business-people-sales/profile.yaml +28 -0
  40. package/profiles/aas-business-strategy-product/profile.yaml +35 -0
  41. package/profiles/aas-cloud-architecture/profile.yaml +21 -0
  42. package/profiles/aas-cloud-aws/profile.yaml +26 -0
  43. package/profiles/aas-cloud-azure/profile.yaml +24 -0
  44. package/profiles/aas-cloud-delivery/profile.yaml +32 -0
  45. package/profiles/aas-cloud-reliability/profile.yaml +27 -0
  46. package/profiles/aas-commerce/profile.yaml +21 -0
  47. package/profiles/aas-content-analysis-learning/profile.yaml +25 -0
  48. package/profiles/aas-content-crossframe/profile.yaml +25 -0
  49. package/profiles/aas-content-presentations-office/profile.yaml +27 -0
  50. package/profiles/aas-content-seo-strategy/profile.yaml +36 -0
  51. package/profiles/aas-content-seo-writing/profile.yaml +26 -0
  52. package/profiles/aas-content-technical-docs/profile.yaml +31 -0
  53. package/profiles/aas-content-writing-editing/profile.yaml +31 -0
  54. package/profiles/aas-data/profile.yaml +34 -0
  55. package/profiles/aas-database/profile.yaml +31 -0
  56. package/profiles/aas-design-depth-spatial/profile.yaml +36 -0
  57. package/profiles/aas-design-expressive-retro/profile.yaml +35 -0
  58. package/profiles/aas-design-graphics-tools/profile.yaml +31 -0
  59. package/profiles/aas-design-minimal-editorial/profile.yaml +36 -0
  60. package/profiles/aas-design-systems-quality/profile.yaml +40 -0
  61. package/profiles/aas-development-agent-tooling/profile.yaml +31 -0
  62. package/profiles/aas-development-apple-hig/profile.yaml +35 -0
  63. package/profiles/aas-development-debugging-reliability/profile.yaml +37 -0
  64. package/profiles/aas-development-developer-tools/profile.yaml +29 -0
  65. package/profiles/aas-development-frameworks/profile.yaml +32 -0
  66. package/profiles/aas-development-functional-typescript/profile.yaml +28 -0
  67. package/profiles/aas-development-makepad/profile.yaml +26 -0
  68. package/profiles/aas-development-project-workflows/profile.yaml +38 -0
  69. package/profiles/aas-development-quality-refactoring/profile.yaml +36 -0
  70. package/profiles/aas-development-quality-refactoring-2/profile.yaml +35 -0
  71. package/profiles/aas-development-systems-languages/profile.yaml +44 -0
  72. package/profiles/aas-development-web-languages/profile.yaml +38 -0
  73. package/profiles/aas-education/profile.yaml +27 -0
  74. package/profiles/aas-finance/profile.yaml +22 -0
  75. package/profiles/aas-frontend-design-systems/profile.yaml +35 -0
  76. package/profiles/aas-frontend-frameworks-platforms/profile.yaml +30 -0
  77. package/profiles/aas-frontend-motion-3d/profile.yaml +26 -0
  78. package/profiles/aas-frontend-quality-performance/profile.yaml +26 -0
  79. package/profiles/aas-frontend-react-ecosystem/profile.yaml +34 -0
  80. package/profiles/aas-game/profile.yaml +39 -0
  81. package/profiles/aas-general-persuasion/profile.yaml +28 -0
  82. package/profiles/aas-health/profile.yaml +25 -0
  83. package/profiles/aas-legal/profile.yaml +29 -0
  84. package/profiles/aas-marketing-brand-growth/profile.yaml +28 -0
  85. package/profiles/aas-marketing-conversion-email/profile.yaml +32 -0
  86. package/profiles/aas-marketing-seo/profile.yaml +38 -0
  87. package/profiles/aas-marketing-social-content/profile.yaml +30 -0
  88. package/profiles/aas-media/profile.yaml +32 -0
  89. package/profiles/aas-mobile/profile.yaml +31 -0
  90. package/profiles/aas-product/profile.yaml +37 -0
  91. package/profiles/aas-productivity/profile.yaml +40 -0
  92. package/profiles/aas-research/profile.yaml +33 -0
  93. package/profiles/aas-security-application/profile.yaml +31 -0
  94. package/profiles/aas-security-cloud-compliance/profile.yaml +31 -0
  95. package/profiles/aas-security-supply-chain/profile.yaml +27 -0
  96. package/profiles/aas-security-threat-modeling/profile.yaml +25 -0
  97. package/profiles/aas-skills/profile.yaml +45 -0
  98. package/profiles/aas-testing-automation/profile.yaml +32 -0
  99. package/profiles/aas-testing-debugging/profile.yaml +27 -0
  100. package/profiles/aas-testing-quality-gates/profile.yaml +28 -0
  101. package/profiles/aas-travel/profile.yaml +21 -0
  102. package/profiles/aas-workflow-andruia/profile.yaml +23 -0
  103. package/profiles/aas-workflow-auctions/profile.yaml +26 -0
  104. package/profiles/aas-workflow-crossframe/profile.yaml +24 -0
  105. package/profiles/aas-workflow-delivery-git/profile.yaml +33 -0
  106. package/profiles/aas-workflow-development-bundles/profile.yaml +39 -0
  107. package/profiles/aas-workflow-infrastructure/profile.yaml +26 -0
  108. package/profiles/aas-workflow-methodologies/profile.yaml +28 -0
  109. package/profiles/aas-workflow-security-testing/profile.yaml +26 -0
  110. package/profiles/aas-workflow-skill-management/profile.yaml +39 -0
  111. package/profiles/ads-manager/profile.yaml +13 -0
  112. package/profiles/agency/profile.yaml +6 -0
  113. package/profiles/agv/profile.yaml +30 -0
  114. package/profiles/ai-engineer/profile.yaml +24 -0
  115. package/profiles/ai-job-search/profile.yaml +49 -0
  116. package/profiles/aws/profile.yaml +56 -2
  117. package/profiles/backend/profile.yaml +31 -6
  118. package/profiles/browser/profile.yaml +15 -16
  119. package/profiles/builder/profile.yaml +2 -6
  120. package/profiles/claude-ads/profile.yaml +151 -0
  121. package/profiles/commerce/profile.yaml +33 -25
  122. package/profiles/core/README.md +5 -0
  123. package/profiles/core/profile.yaml +108 -29
  124. package/profiles/cpp/profile.yaml +10 -0
  125. package/profiles/creative-media/profile.yaml +6 -1
  126. package/profiles/creativity/profile.yaml +1 -0
  127. package/profiles/cybersecurity/profile.yaml +4 -0
  128. package/profiles/designer/profile.yaml +8 -10
  129. package/profiles/docs-writer/profile.yaml +4 -1
  130. package/profiles/dropshipping/profile.yaml +0 -1
  131. package/profiles/ego-lite-stack/profile.yaml +400 -0
  132. package/profiles/flutter/profile.yaml +15 -0
  133. package/profiles/frontend/profile.yaml +12 -3
  134. package/profiles/frontend-design/profile.yaml +60 -0
  135. package/profiles/full/profile.yaml +7 -1
  136. package/profiles/fullstack-dev-skills/profile.yaml +112 -0
  137. package/profiles/go-api/profile.yaml +3 -0
  138. package/profiles/google-ads/profile.yaml +8 -7
  139. package/profiles/google-analytics/profile.yaml +2 -2
  140. package/profiles/growth/profile.yaml +1 -6
  141. package/profiles/gstack/profile.yaml +4 -1
  142. package/profiles/gui-gitnexus/README.md +48 -0
  143. package/profiles/gui-gitnexus/profile.yaml +79 -0
  144. package/profiles/headroom/README.md +38 -0
  145. package/profiles/headroom/profile.yaml +45 -0
  146. package/profiles/higgsfield/profile.yaml +6 -1
  147. package/profiles/hostinger/profile.yaml +1 -0
  148. package/profiles/improver/profile.yaml +11 -1
  149. package/profiles/jetson/profile.yaml +41 -0
  150. package/profiles/legal/profile.yaml +48 -0
  151. package/profiles/maker/profile.yaml +0 -3
  152. package/profiles/marketing/profile.yaml +1 -0
  153. package/profiles/medusa-dev/profile.yaml +14 -4
  154. package/profiles/medusa-stack/profile.yaml +6 -1
  155. package/profiles/medusa-vite/profile.yaml +9 -34
  156. package/profiles/nagyvikt-skills/profile.yaml +13 -0
  157. package/profiles/opensrc/profile.yaml +23 -0
  158. package/profiles/ops/profile.yaml +21 -6
  159. package/profiles/ponytail/README.md +47 -0
  160. package/profiles/ponytail/profile.yaml +60 -0
  161. package/profiles/postgres/profile.yaml +3 -0
  162. package/profiles/postizz/profile.yaml +4 -0
  163. package/profiles/python/profile.yaml +3 -2
  164. package/profiles/react-native/profile.yaml +4 -0
  165. package/profiles/readme-writer/profile.yaml +2 -1
  166. package/profiles/research/profile.yaml +1 -4
  167. package/profiles/reverse-skill/profile.yaml +96 -0
  168. package/profiles/ros2/profile.yaml +31 -0
  169. package/profiles/rust-core/profile.yaml +4 -0
  170. package/profiles/schema.json +134 -8
  171. package/profiles/secops/profile.yaml +760 -4
  172. package/profiles/seo/profile.yaml +14 -0
  173. package/profiles/skill-writer/profile.yaml +3 -0
  174. package/profiles/solidcraft/profile.yaml +33 -0
  175. package/profiles/stripe/profile.yaml +1 -4
  176. package/profiles/studio/profile.yaml +14 -17
  177. package/profiles/supercomputer/profile.yaml +7 -1
  178. package/profiles/swift-ios/profile.yaml +15 -0
  179. package/profiles/tanstack/logo.png +0 -0
  180. package/profiles/tanstack/profile.yaml +33 -0
  181. package/profiles/video/profile.yaml +1 -0
  182. package/profiles/vite/profile.yaml +8 -0
  183. package/profiles/webshop/profile.yaml +28 -22
  184. package/profiles/webshop-google/profile.yaml +2 -3
  185. package/profiles/wordpress/profile.yaml +1 -0
  186. package/profiles/x-growth-bot/profile.yaml +1 -1
  187. package/resources/mcps/configs/claude.sanitized.json +103 -17
  188. package/resources/mcps/configs/claude_runtime.sanitized.json +13 -53
  189. package/resources/mcps/configs/codex.sanitized.json +39 -21
  190. package/resources/skills/README.md +107 -28
  191. package/resources/skills/skills/browser/agent-browser/SKILL.md +11 -4
  192. package/resources/skills/skills/browser/ego-browser/SKILL.md +252 -0
  193. package/resources/skills/skills/browser/ego-browser/agents/openai.yaml +7 -0
  194. package/resources/skills/skills/browser/ego-browser/assets/composer-icon.png +0 -0
  195. package/resources/skills/skills/browser/ego-browser/assets/logo.png +0 -0
  196. package/resources/skills/skills/browser/ego-browser/learnings/facebook/browser-tools/composer-state.js +20 -0
  197. package/resources/skills/skills/browser/ego-browser/learnings/facebook/manifest.json +82 -0
  198. package/resources/skills/skills/browser/ego-browser/learnings/facebook/notes/groups.md +122 -0
  199. package/resources/skills/skills/browser/ego-browser/learnings/facebook/notes/overview.md +95 -0
  200. package/resources/skills/skills/browser/ego-browser/learnings/facebook/tools/group-feed.js +110 -0
  201. package/resources/skills/skills/browser/ego-browser/learnings/facebook/tools/group-post.js +165 -0
  202. package/resources/skills/skills/browser/ego-browser/learnings/facebook/tools/my-groups.js +56 -0
  203. package/resources/skills/skills/browser/ego-browser/learnings/google/browser-tools/autocomplete.js +11 -0
  204. package/resources/skills/skills/browser/ego-browser/learnings/google/manifest.json +40 -0
  205. package/resources/skills/skills/browser/ego-browser/learnings/google/notes/overview.md +23 -0
  206. package/resources/skills/skills/browser/ego-browser/learnings/google/tools/search-extract.js +39 -0
  207. package/resources/skills/skills/browser/ego-browser/learnings/package.json +5 -0
  208. package/resources/skills/skills/browser/ego-browser/learnings/x-com/browser-tools/extract-post.js +9 -0
  209. package/resources/skills/skills/browser/ego-browser/learnings/x-com/manifest.json +51 -0
  210. package/resources/skills/skills/browser/ego-browser/learnings/x-com/notes/overview.md +18 -0
  211. package/resources/skills/skills/browser/ego-browser/learnings/x-com/notes/timeline.md +19 -0
  212. package/resources/skills/skills/browser/ego-browser/learnings/x-com/tools/search-users.js +33 -0
  213. package/resources/skills/skills/browser/ego-browser/learnings/x-com/tools/timeline.js +32 -0
  214. package/resources/skills/skills/browser/ego-browser/references/install.md +197 -0
  215. package/resources/skills/skills/browser/ego-browser/references/task-spaces.md +184 -0
  216. package/resources/skills/skills/browser/ego-browser/references/video.md +17 -0
  217. package/resources/skills/skills/browser/ego-browser/scripts/install.sh +75 -0
  218. package/resources/skills/skills/browser/playwright/SKILL.md +6 -5
  219. package/resources/skills/skills/cad/solidcraft/SKILL.md +101 -0
  220. package/resources/skills/skills/career/ai-job-search/.gitattributes +1 -0
  221. package/resources/skills/skills/career/ai-job-search/SKILL.md +114 -0
  222. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/SKILL.md.template +200 -0
  223. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/README.md +93 -0
  224. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/package.json +20 -0
  225. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/src/cli.ts +254 -0
  226. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/src/commands/detail.ts +65 -0
  227. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/src/commands/search.ts +154 -0
  228. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/src/helpers.ts +230 -0
  229. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tests/cli-flag-validation.test.ts +122 -0
  230. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tests/commands.test.ts +234 -0
  231. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tests/helpers.ts +40 -0
  232. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tests/parsing.test.ts +102 -0
  233. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tests/request-timeout.test.ts +26 -0
  234. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tests/retry-backoff.test.ts +72 -0
  235. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/cli/tsconfig.json +14 -0
  236. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/freehire-search/url-reference.md +145 -0
  237. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/SKILL.md.template +180 -0
  238. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/README.md +400 -0
  239. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/package.json +25 -0
  240. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/src/cli.ts +45 -0
  241. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/src/commands/detail.ts +139 -0
  242. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/src/commands/search.ts +202 -0
  243. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/src/helpers.ts +199 -0
  244. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/cli-contract.test.ts +30 -0
  245. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/cli-flag-validation.test.ts +82 -0
  246. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/detail-jsonld.test.ts +40 -0
  247. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/helpers.ts +39 -0
  248. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/request-timeout.test.ts +23 -0
  249. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/retry-backoff.test.ts +64 -0
  250. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/rss-fetch.test.ts +20 -0
  251. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/rss-parsing.test.ts +96 -0
  252. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tests/search-normalization.test.ts +38 -0
  253. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/cli/tsconfig.json +20 -0
  254. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobbank-search/url-reference.md +327 -0
  255. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/SKILL.md.template +229 -0
  256. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/README.md +443 -0
  257. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/package.json +25 -0
  258. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/cli.ts +48 -0
  259. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/commands/autocomplete.ts +111 -0
  260. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/commands/categories.ts +67 -0
  261. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/commands/detail.ts +294 -0
  262. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/commands/locations.ts +101 -0
  263. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/commands/search.ts +209 -0
  264. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/src/helpers.ts +73 -0
  265. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/cli-contract.test.ts +27 -0
  266. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/cli-flag-validation.test.ts +97 -0
  267. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/detail-jsonld.test.ts +96 -0
  268. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/detail-parsing.test.ts +86 -0
  269. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/helpers.ts +39 -0
  270. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/request-timeout.test.ts +34 -0
  271. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/retry-backoff.test.ts +67 -0
  272. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/search-normalization.test.ts +105 -0
  273. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tests/user-agent.test.ts +48 -0
  274. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobdanmark-search/cli/tsconfig.json +20 -0
  275. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/SKILL.md.template +171 -0
  276. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/README.md +247 -0
  277. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/package.json +25 -0
  278. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/src/cli.ts +45 -0
  279. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/src/commands/detail.ts +321 -0
  280. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/src/commands/search.ts +103 -0
  281. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/src/helpers.ts +346 -0
  282. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/cli-contract.test.ts +38 -0
  283. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/cli-flag-validation.test.ts +80 -0
  284. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/detail-parsing.test.ts +152 -0
  285. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/helpers.ts +39 -0
  286. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/parsing.test.ts +98 -0
  287. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/request-timeout.test.ts +34 -0
  288. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/retry-backoff.test.ts +89 -0
  289. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tests/search-page.test.ts +69 -0
  290. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/cli/tsconfig.json +20 -0
  291. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobindex-search/url-reference.md +118 -0
  292. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/SKILL.md.template +206 -0
  293. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/README.md +385 -0
  294. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/package.json +24 -0
  295. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/src/cli.ts +47 -0
  296. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/src/commands/detail.ts +158 -0
  297. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/src/commands/occupations.ts +84 -0
  298. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/src/commands/search.ts +240 -0
  299. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/src/commands/suggestions.ts +66 -0
  300. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/src/helpers.ts +57 -0
  301. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/cli-contract.test.ts +49 -0
  302. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/cli-flag-validation.test.ts +97 -0
  303. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/detail-formatting.test.ts +121 -0
  304. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/helpers.ts +39 -0
  305. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/request-timeout.test.ts +23 -0
  306. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/retry-backoff.test.ts +59 -0
  307. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/search-normalization.test.ts +163 -0
  308. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tests/user-agent.test.ts +27 -0
  309. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/jobnet-search/cli/tsconfig.json +20 -0
  310. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/SKILL.md.template +103 -0
  311. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/README.md +61 -0
  312. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/package.json +20 -0
  313. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/src/cli.ts +206 -0
  314. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/src/commands/detail.ts +57 -0
  315. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/src/commands/search.ts +87 -0
  316. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/src/helpers.ts +288 -0
  317. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tests/cli-flag-validation.test.ts +146 -0
  318. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tests/helpers.ts +39 -0
  319. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tests/parsing.test.ts +277 -0
  320. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tests/request-timeout.test.ts +23 -0
  321. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tests/retry-backoff.test.ts +60 -0
  322. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tests/search.test.ts +61 -0
  323. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/cli/tsconfig.json +14 -0
  324. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.agents/skills/linkedin-search/url-reference.md +42 -0
  325. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/agents/gemini-research-expert.md +57 -0
  326. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/add-portal.md +160 -0
  327. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/add-template.md +201 -0
  328. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/apply.md +368 -0
  329. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/expand.md +216 -0
  330. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/gmail-sync.md +192 -0
  331. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/html-report.md +146 -0
  332. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/interview.md +111 -0
  333. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/notion-sync.md +149 -0
  334. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/outcome.md +195 -0
  335. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/rank.md +147 -0
  336. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/reset.md +275 -0
  337. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/commands/setup.md +432 -0
  338. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/settings.json +18 -0
  339. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/01-candidate-profile.md +73 -0
  340. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/02-behavioral-profile.md +54 -0
  341. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/03-writing-style.md +110 -0
  342. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/04-job-evaluation.md +269 -0
  343. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/05-cv-templates.md +371 -0
  344. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/06-cover-letter-templates.md +180 -0
  345. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/07-interview-prep.md +113 -0
  346. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/08-application-forms.md +87 -0
  347. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/09-web-research.md +114 -0
  348. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-application-assistant/SKILL.md.template +78 -0
  349. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-scraper/SKILL.md.template +282 -0
  350. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/job-scraper/search-queries.md +90 -0
  351. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.claude/skills/upskill/SKILL.md.template +256 -0
  352. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/FUNDING.yml +2 -0
  353. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/ISSUE_TEMPLATE/bug-report.md +22 -0
  354. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/ISSUE_TEMPLATE/config.yml +9 -0
  355. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/PULL_REQUEST_TEMPLATE.md +15 -0
  356. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/upstream-wontport.txt +12 -0
  357. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/workflows/ci.yml +249 -0
  358. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/.github/workflows/upstream-watch.yml +85 -0
  359. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/AGENTS.md +19 -0
  360. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/CHANGELOG.md +1074 -0
  361. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/CLAUDE.md +147 -0
  362. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/CONTRIBUTING.md +103 -0
  363. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/LICENSE +21 -0
  364. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/README.md +389 -0
  365. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/SECURITY.md +22 -0
  366. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/SETUP.md +353 -0
  367. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/assets/mascot/pip_flight_loop.gif +0 -0
  368. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/company_research/.gitkeep +0 -0
  369. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-Bla.ttf +0 -0
  370. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-BlaIta.ttf +0 -0
  371. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-Bol.ttf +0 -0
  372. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-BolIta.ttf +0 -0
  373. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-Hai.ttf +0 -0
  374. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-HaiIta.ttf +0 -0
  375. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-Lig.ttf +0 -0
  376. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-LigIta.ttf +0 -0
  377. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-Reg.ttf +0 -0
  378. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/lato/Lato-RegIta.ttf +0 -0
  379. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-Bold.otf +0 -0
  380. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-ExtraBold.otf +0 -0
  381. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-ExtraLight.otf +0 -0
  382. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-Heavy.otf +0 -0
  383. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-Light.otf +0 -0
  384. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-Medium.otf +0 -0
  385. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-Regular.otf +0 -0
  386. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-SemiBold.otf +0 -0
  387. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/OpenFonts/fonts/raleway/Raleway-Thin.otf +0 -0
  388. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/cover.cls +96 -0
  389. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cover_letters/cover_example.tex +61 -0
  390. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/cv/main_example.tex +183 -0
  391. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/README.md +200 -0
  392. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/applications/.gitkeep +0 -0
  393. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/cv/.gitkeep +0 -0
  394. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/diplomas/.gitkeep +0 -0
  395. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/linkedin/.gitkeep +0 -0
  396. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/postings/.gitkeep +0 -0
  397. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/documents/references/.gitkeep +0 -0
  398. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/job_scraper/.gitkeep +0 -0
  399. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/salary_lookup.py +434 -0
  400. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/templates/README.md +26 -0
  401. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/__init__.py +1 -0
  402. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_apply_records_application.py +479 -0
  403. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_check_framework_version.py +110 -0
  404. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_check_upstream_updates.py +164 -0
  405. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_company_research_cache.py +177 -0
  406. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_convert_salary_excel.py +342 -0
  407. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_gmail_sync_command.py +43 -0
  408. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_html_report_command.py +165 -0
  409. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_latex_guidance.py +140 -0
  410. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_lint_skills.py +173 -0
  411. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_notion_sync_command.py +69 -0
  412. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_onboarding_privacy.py +85 -0
  413. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_outcome_followup.py +90 -0
  414. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_placeholder_integrity.py +92 -0
  415. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_rank_command.py +423 -0
  416. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_readme_assets.py +34 -0
  417. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_reset_command.py +168 -0
  418. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_robots_check.py +264 -0
  419. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_salary_lookup.py +571 -0
  420. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_scrape_contract.py +140 -0
  421. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_scrape_provenance.py +110 -0
  422. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_security_guards.py +427 -0
  423. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_tracker_status_vocab.py +353 -0
  424. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_upskill_skill.py +145 -0
  425. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_upstream_triage.py +192 -0
  426. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tests/test_verify_pdf.py +115 -0
  427. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/README_SALARY_TOOL.md +124 -0
  428. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/check_framework_version.py +147 -0
  429. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/check_upstream_updates.py +196 -0
  430. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/convert_salary_excel.py +349 -0
  431. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/lint_skills.py +122 -0
  432. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/robots_check.py +142 -0
  433. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/security_guards.py +290 -0
  434. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/upstream_triage.py +227 -0
  435. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/tools/verify_pdf.py +175 -0
  436. package/resources/skills/skills/career/ai-job-search/assets/workspace-template/upskill/.gitkeep +0 -0
  437. package/resources/skills/skills/career/ai-job-search/references/upstream.md +13 -0
  438. package/resources/skills/skills/career/ai-job-search/scripts/init_workspace.py +79 -0
  439. package/resources/skills/skills/career/ai-job-search/scripts/init_workspace_test.py +64 -0
  440. package/resources/skills/skills/career/ai-job-search/test/codex-workspace.md +4 -0
  441. package/resources/skills/skills/career/ai-job-search/test/scraper-tools.md +4 -0
  442. package/resources/skills/skills/career/job-hunter/SKILL.md +1 -1
  443. package/resources/skills/skills/career/resume-version-manager/SKILL.md +5 -4
  444. package/resources/skills/skills/career/salary-negotiation-prep/SKILL.md +3 -2
  445. package/resources/skills/skills/caveman/caveman/SKILL.md +5 -5
  446. package/resources/skills/skills/caveman/caveman-commit/SKILL.md +7 -7
  447. package/resources/skills/skills/caveman/caveman-compress/SKILL.md +3 -3
  448. package/resources/skills/skills/caveman/caveman-help/SKILL.md +3 -3
  449. package/resources/skills/skills/caveman/caveman-review/SKILL.md +12 -12
  450. package/resources/skills/skills/caveman/entroly/SKILL.md +6 -6
  451. package/resources/skills/skills/colony/colony/SKILL.md +53 -53
  452. package/resources/skills/skills/colony/colony-prompts/SKILL.md +17 -16
  453. package/resources/skills/skills/content/anti-formula/SKILL.md +24 -41
  454. package/resources/skills/skills/content/article-to-everywhere/SKILL.md +22 -30
  455. package/resources/skills/skills/content/article-writer/SKILL.md +22 -29
  456. package/resources/skills/skills/content/doc/SKILL.md +2 -2
  457. package/resources/skills/skills/content/engagement-feedback/SKILL.md +17 -22
  458. package/resources/skills/skills/content/pdf/SKILL.md +1 -1
  459. package/resources/skills/skills/content/playwright/SKILL.md +4 -4
  460. package/resources/skills/skills/content/postiz-cards/SKILL.md +13 -14
  461. package/resources/skills/skills/content/stop-slop/SKILL.md +1 -1
  462. package/resources/skills/skills/content/trend-to-thread/SKILL.md +32 -31
  463. package/resources/skills/skills/deployment/coolify/SKILL.md +8 -0
  464. package/resources/skills/skills/deployment/pnpm/SKILL.md +3 -2
  465. package/resources/skills/skills/deployment/supabase/SKILL.md +11 -10
  466. package/resources/skills/skills/design/banana/SKILL.md +0 -30
  467. package/resources/skills/skills/design/brandkit/SKILL.md +13 -13
  468. package/resources/skills/skills/design/design-taste-frontend/SKILL.md +9 -9
  469. package/resources/skills/skills/design/gpt-taste/SKILL.md +4 -4
  470. package/resources/skills/skills/design/headless-gif-demo/SKILL.md +29 -12
  471. package/resources/skills/skills/design/high-end-visual-design/SKILL.md +13 -13
  472. package/resources/skills/skills/design/image-to-code/SKILL.md +15 -15
  473. package/resources/skills/skills/design/imagegen-frontend-mobile/SKILL.md +23 -23
  474. package/resources/skills/skills/design/imagegen-frontend-web/SKILL.md +28 -28
  475. package/resources/skills/skills/design/industrial-brutalist-ui/SKILL.md +3 -3
  476. package/resources/skills/skills/design/kitty-visualize/SKILL.md +14 -13
  477. package/resources/skills/skills/design/minimalist-ui/SKILL.md +7 -7
  478. package/resources/skills/skills/design/png-alpha-cleaner/SKILL.md +2 -2
  479. package/resources/skills/skills/design/readme-svg-design/SKILL.md +23 -16
  480. package/resources/skills/skills/design/redesign-existing-projects/SKILL.md +17 -17
  481. package/resources/skills/skills/design/remotion-best-practices/SKILL.md +4 -4
  482. package/resources/skills/skills/design/remotion-best-practices/rules/mapbox.md +1 -1
  483. package/resources/skills/skills/design/screenshot/SKILL.md +2 -2
  484. package/resources/skills/skills/design/stitch-design-taste/SKILL.md +33 -33
  485. package/resources/skills/skills/design/taste-skill/SKILL.md +3 -2
  486. package/resources/skills/skills/design/taste-skill-v1/SKILL.md +8 -7
  487. package/resources/skills/skills/design/ui-ux-pro-max/SKILL.md +5 -5
  488. package/resources/skills/skills/event-design/wedding-invitations/SKILL.md +13 -12
  489. package/resources/skills/skills/github/gh-auth-doctor/SKILL.md +12 -11
  490. package/resources/skills/skills/github/gh-fix-ci/SKILL.md +2 -1
  491. package/resources/skills/skills/github/gitguardex/SKILL.md +52 -7
  492. package/resources/skills/skills/github/github/SKILL.md +2 -1
  493. package/resources/skills/skills/github/guardex-merge-skills-to-dev/SKILL.md +2 -1
  494. package/resources/skills/skills/github/gx-agents/SKILL.md +49 -72
  495. package/resources/skills/skills/google-workspace/google-drive/SKILL.md +6 -6
  496. package/resources/skills/skills/gstack/autoplan/SKILL.md +72 -72
  497. package/resources/skills/skills/gstack/benchmark/SKILL.md +12 -11
  498. package/resources/skills/skills/gstack/benchmark-models/SKILL.md +19 -18
  499. package/resources/skills/skills/gstack/browse/SKILL.md +34 -28
  500. package/resources/skills/skills/gstack/browse/SKILL.md.tmpl +2 -4
  501. package/resources/skills/skills/gstack/canary/SKILL.md +24 -23
  502. package/resources/skills/skills/gstack/careful/SKILL.md +3 -2
  503. package/resources/skills/skills/gstack/codex/SKILL.md +47 -47
  504. package/resources/skills/skills/gstack/context-restore/SKILL.md +15 -10
  505. package/resources/skills/skills/gstack/context-save/SKILL.md +13 -8
  506. package/resources/skills/skills/gstack/cso/SKILL.md +59 -59
  507. package/resources/skills/skills/gstack/design-consultation/SKILL.md +58 -58
  508. package/resources/skills/skills/gstack/design-html/SKILL.md +53 -46
  509. package/resources/skills/skills/gstack/design-html/SKILL.md.tmpl +2 -9
  510. package/resources/skills/skills/gstack/design-review/SKILL.md +67 -66
  511. package/resources/skills/skills/gstack/design-shotgun/SKILL.md +61 -55
  512. package/resources/skills/skills/gstack/design-shotgun/SKILL.md.tmpl +2 -7
  513. package/resources/skills/skills/gstack/devex-review/SKILL.md +35 -34
  514. package/resources/skills/skills/gstack/document-generate/SKILL.md +23 -23
  515. package/resources/skills/skills/gstack/document-release/SKILL.md +59 -59
  516. package/resources/skills/skills/gstack/freeze/SKILL.md +6 -5
  517. package/resources/skills/skills/gstack/gstack-upgrade/SKILL.md +16 -9
  518. package/resources/skills/skills/gstack/gstack-upgrade/SKILL.md.tmpl +2 -5
  519. package/resources/skills/skills/gstack/guard/SKILL.md +6 -5
  520. package/resources/skills/skills/gstack/hackernews-frontpage/SKILL.md +1 -0
  521. package/resources/skills/skills/gstack/health/SKILL.md +3 -2
  522. package/resources/skills/skills/gstack/investigate/SKILL.md +15 -14
  523. package/resources/skills/skills/gstack/ios-clean/SKILL.md +40 -34
  524. package/resources/skills/skills/gstack/ios-clean/SKILL.md.tmpl +2 -7
  525. package/resources/skills/skills/gstack/ios-design-review/SKILL.md +40 -34
  526. package/resources/skills/skills/gstack/ios-design-review/SKILL.md.tmpl +2 -6
  527. package/resources/skills/skills/gstack/ios-fix/SKILL.md +39 -33
  528. package/resources/skills/skills/gstack/ios-fix/SKILL.md.tmpl +2 -8
  529. package/resources/skills/skills/gstack/ios-qa/SKILL.md +37 -36
  530. package/resources/skills/skills/gstack/ios-qa/SKILL.md.tmpl +3 -9
  531. package/resources/skills/skills/gstack/ios-sync/SKILL.md +37 -31
  532. package/resources/skills/skills/gstack/ios-sync/SKILL.md.tmpl +2 -8
  533. package/resources/skills/skills/gstack/land-and-deploy/SKILL.md +88 -88
  534. package/resources/skills/skills/gstack/landing-report/SKILL.md +11 -10
  535. package/resources/skills/skills/gstack/learn/SKILL.md +32 -25
  536. package/resources/skills/skills/gstack/learn/SKILL.md.tmpl +2 -8
  537. package/resources/skills/skills/gstack/make-pdf/SKILL.md +5 -4
  538. package/resources/skills/skills/gstack/office-hours/SKILL.md +140 -140
  539. package/resources/skills/skills/gstack/open-gstack-browser/SKILL.md +54 -48
  540. package/resources/skills/skills/gstack/open-gstack-browser/SKILL.md.tmpl +2 -4
  541. package/resources/skills/skills/gstack/pair-agent/SKILL.md +43 -37
  542. package/resources/skills/skills/gstack/pair-agent/SKILL.md.tmpl +2 -4
  543. package/resources/skills/skills/gstack/plan-ceo-review/SKILL.md +163 -163
  544. package/resources/skills/skills/gstack/plan-design-review/SKILL.md +107 -107
  545. package/resources/skills/skills/gstack/plan-devex-review/SKILL.md +62 -62
  546. package/resources/skills/skills/gstack/plan-eng-review/SKILL.md +114 -114
  547. package/resources/skills/skills/gstack/plan-tune/SKILL.md +28 -28
  548. package/resources/skills/skills/gstack/qa/SKILL.md +87 -81
  549. package/resources/skills/skills/gstack/qa/SKILL.md.tmpl +2 -9
  550. package/resources/skills/skills/gstack/qa-only/SKILL.md +64 -58
  551. package/resources/skills/skills/gstack/qa-only/SKILL.md.tmpl +2 -6
  552. package/resources/skills/skills/gstack/retro/SKILL.md +69 -69
  553. package/resources/skills/skills/gstack/review/SKILL.md +81 -80
  554. package/resources/skills/skills/gstack/scrape/SKILL.md +17 -17
  555. package/resources/skills/skills/gstack/setup-browser-cookies/SKILL.md +6 -5
  556. package/resources/skills/skills/gstack/setup-deploy/SKILL.md +9 -8
  557. package/resources/skills/skills/gstack/setup-gbrain/SKILL.md +107 -99
  558. package/resources/skills/skills/gstack/setup-gbrain/SKILL.md.tmpl +3 -9
  559. package/resources/skills/skills/gstack/ship/SKILL.md +186 -185
  560. package/resources/skills/skills/gstack/skillify/SKILL.md +25 -24
  561. package/resources/skills/skills/gstack/spec/SKILL.md +113 -107
  562. package/resources/skills/skills/gstack/spec/SKILL.md.tmpl +3 -7
  563. package/resources/skills/skills/gstack/sync-gbrain/SKILL.md +59 -51
  564. package/resources/skills/skills/gstack/sync-gbrain/SKILL.md.tmpl +2 -8
  565. package/resources/skills/skills/gstack/unfreeze/SKILL.md +4 -3
  566. package/resources/skills/skills/higgsfield/higgsfield-generate/SKILL.md +21 -20
  567. package/resources/skills/skills/higgsfield/higgsfield-marketplace-cards/SKILL.md +3 -2
  568. package/resources/skills/skills/higgsfield/higgsfield-product-photoshoot/SKILL.md +18 -17
  569. package/resources/skills/skills/higgsfield/higgsfield-soul-id/SKILL.md +12 -11
  570. package/resources/skills/skills/hostinger/dns/SKILL.md +17 -16
  571. package/resources/skills/skills/hostinger/domains/SKILL.md +14 -13
  572. package/resources/skills/skills/hostinger/hosting/SKILL.md +15 -14
  573. package/resources/skills/skills/hostinger/vps/SKILL.md +19 -18
  574. package/resources/skills/skills/legal/legal/SKILL.md +94 -0
  575. package/resources/skills/skills/legal/legal-agreement/SKILL.md +418 -0
  576. package/resources/skills/skills/legal/legal-compare/SKILL.md +177 -0
  577. package/resources/skills/skills/legal/legal-compliance/SKILL.md +370 -0
  578. package/resources/skills/skills/legal/legal-freelancer/SKILL.md +454 -0
  579. package/resources/skills/skills/legal/legal-missing/SKILL.md +232 -0
  580. package/resources/skills/skills/legal/legal-nda/SKILL.md +283 -0
  581. package/resources/skills/skills/legal/legal-negotiate/SKILL.md +248 -0
  582. package/resources/skills/skills/legal/legal-plain/SKILL.md +169 -0
  583. package/resources/skills/skills/legal/legal-privacy/SKILL.md +327 -0
  584. package/resources/skills/skills/legal/legal-report-pdf/SKILL.md +400 -0
  585. package/resources/skills/skills/legal/legal-report-pdf/scripts/generate_legal_pdf.py +446 -0
  586. package/resources/skills/skills/legal/legal-report-pdf/templates/contract-review-template.md +190 -0
  587. package/resources/skills/skills/legal/legal-review/SKILL.md +202 -0
  588. package/resources/skills/skills/legal/legal-risks/SKILL.md +171 -0
  589. package/resources/skills/skills/legal/legal-terms/SKILL.md +263 -0
  590. package/resources/skills/skills/marketing/ab-test-analyzer/SKILL.md +2 -1
  591. package/resources/skills/skills/marketing/ab-test-setup-and-analysis/SKILL.md +3 -3
  592. package/resources/skills/skills/marketing/account-structure-review/SKILL.md +5 -4
  593. package/resources/skills/skills/marketing/ad-copy-variant-generator/SKILL.md +4 -3
  594. package/resources/skills/skills/marketing/ad-extension-audit/SKILL.md +4 -3
  595. package/resources/skills/skills/marketing/ad-spend-allocator/SKILL.md +2 -1
  596. package/resources/skills/skills/marketing/anomaly-detection/SKILL.md +6 -5
  597. package/resources/skills/skills/marketing/attribution-model-comparison/SKILL.md +5 -4
  598. package/resources/skills/skills/marketing/audience-overlap-analysis/SKILL.md +5 -10
  599. package/resources/skills/skills/marketing/bid-strategy-recommendations/SKILL.md +6 -11
  600. package/resources/skills/skills/marketing/budget-scenario-planner/SKILL.md +4 -8
  601. package/resources/skills/skills/marketing/campaign-naming-convention-builder/SKILL.md +4 -9
  602. package/resources/skills/skills/marketing/channel-mix-optimizer/SKILL.md +4 -9
  603. package/resources/skills/skills/marketing/client-report-narratives/SKILL.md +5 -9
  604. package/resources/skills/skills/marketing/competitor-creative-analysis/SKILL.md +6 -5
  605. package/resources/skills/skills/marketing/competitor-teardown/SKILL.md +2 -1
  606. package/resources/skills/skills/marketing/content-repurposer/SKILL.md +4 -3
  607. package/resources/skills/skills/marketing/conversion-path-analysis/SKILL.md +4 -3
  608. package/resources/skills/skills/marketing/cpa-diagnostics/SKILL.md +3 -3
  609. package/resources/skills/skills/marketing/creative-fatigue-detection/SKILL.md +5 -4
  610. package/resources/skills/skills/marketing/cue-rec/SKILL.md +12 -12
  611. package/resources/skills/skills/marketing/day-hour-performance-breakdown/SKILL.md +4 -3
  612. package/resources/skills/skills/marketing/device-performance-split/SKILL.md +3 -2
  613. package/resources/skills/skills/marketing/e2e-seo-assistant/SKILL.md +3 -2
  614. package/resources/skills/skills/marketing/email-sequence-writer/SKILL.md +2 -1
  615. package/resources/skills/skills/marketing/frequency-cap-recommendations/SKILL.md +3 -3
  616. package/resources/skills/skills/marketing/geo-performance-analysis/SKILL.md +6 -5
  617. package/resources/skills/skills/marketing/google-ads-audit/SKILL.md +1 -1
  618. package/resources/skills/skills/marketing/icp-research-assistant/SKILL.md +3 -2
  619. package/resources/skills/skills/marketing/keyword-cannibalization-check/SKILL.md +4 -3
  620. package/resources/skills/skills/marketing/landing-page-audit/SKILL.md +2 -1
  621. package/resources/skills/skills/marketing/landing-page-audit-quick/SKILL.md +6 -5
  622. package/resources/skills/skills/marketing/linkedin-ads-audit/SKILL.md +2 -1
  623. package/resources/skills/skills/marketing/meta-ads-audit/SKILL.md +2 -1
  624. package/resources/skills/skills/marketing/pacing-monitor/SKILL.md +4 -3
  625. package/resources/skills/skills/marketing/performance-benchmarking/SKILL.md +6 -5
  626. package/resources/skills/skills/marketing/programmatic-seo-builder/SKILL.md +5 -4
  627. package/resources/skills/skills/marketing/quality-score-breakdown/SKILL.md +4 -3
  628. package/resources/skills/skills/marketing/reddit-ads-audit/SKILL.md +2 -1
  629. package/resources/skills/skills/marketing/retargeting-window-analysis/SKILL.md +6 -5
  630. package/resources/skills/skills/marketing/roas-forecasting/SKILL.md +3 -2
  631. package/resources/skills/skills/marketing/search-term-mining/SKILL.md +4 -3
  632. package/resources/skills/skills/marketing/utm-tracking-generator/SKILL.md +3 -2
  633. package/resources/skills/skills/marketing/wasted-spend-finder/SKILL.md +4 -3
  634. package/resources/skills/skills/marketing/weekly-account-summary/SKILL.md +5 -4
  635. package/resources/skills/skills/media/3d-logo-animation/SKILL.md +7 -6
  636. package/resources/skills/skills/media/action-figure-generator/SKILL.md +5 -4
  637. package/resources/skills/skills/media/ad-creative/SKILL.md +13 -12
  638. package/resources/skills/skills/media/ai-clipping/SKILL.md +27 -26
  639. package/resources/skills/skills/media/ai-fight-scene/SKILL.md +13 -12
  640. package/resources/skills/skills/media/amazon-product-listing/SKILL.md +12 -11
  641. package/resources/skills/skills/media/animal-video-generator/SKILL.md +6 -5
  642. package/resources/skills/skills/media/award-ceremony-video/SKILL.md +10 -9
  643. package/resources/skills/skills/media/blog-header/SKILL.md +5 -4
  644. package/resources/skills/skills/media/brand-kit/SKILL.md +12 -11
  645. package/resources/skills/skills/media/brochures/SKILL.md +11 -10
  646. package/resources/skills/skills/media/cartoon-dance-animation/SKILL.md +8 -7
  647. package/resources/skills/skills/media/character-story-video/SKILL.md +9 -8
  648. package/resources/skills/skills/media/chibi-collage-effect/SKILL.md +7 -6
  649. package/resources/skills/skills/media/cinema-director/SKILL.md +7 -6
  650. package/resources/skills/skills/media/color-analysis-board/SKILL.md +6 -6
  651. package/resources/skills/skills/media/core-edit/SKILL.md +2 -1
  652. package/resources/skills/skills/media/core-media/SKILL.md +3 -2
  653. package/resources/skills/skills/media/core-platform/SKILL.md +2 -1
  654. package/resources/skills/skills/media/couple-grid-creator/SKILL.md +5 -4
  655. package/resources/skills/skills/media/design-guide/SKILL.md +13 -13
  656. package/resources/skills/skills/media/drone-style-video/SKILL.md +8 -7
  657. package/resources/skills/skills/media/fashion-try-on/SKILL.md +8 -7
  658. package/resources/skills/skills/media/floor-plan-rendering/SKILL.md +8 -7
  659. package/resources/skills/skills/media/freeze-effect-video/SKILL.md +9 -8
  660. package/resources/skills/skills/media/giant-product-showcase/SKILL.md +11 -10
  661. package/resources/skills/skills/media/instagram-post/SKILL.md +6 -6
  662. package/resources/skills/skills/media/interior-design/SKILL.md +9 -8
  663. package/resources/skills/skills/media/interior-design-visualizer/SKILL.md +7 -6
  664. package/resources/skills/skills/media/jewelry-product-video/SKILL.md +5 -5
  665. package/resources/skills/skills/media/kdenlive/SKILL.md +11 -1
  666. package/resources/skills/skills/media/keyboard-art-maker/SKILL.md +5 -4
  667. package/resources/skills/skills/media/logo-branding/SKILL.md +11 -11
  668. package/resources/skills/skills/media/logo-creator/SKILL.md +3 -2
  669. package/resources/skills/skills/media/logo-generator/SKILL.md +7 -6
  670. package/resources/skills/skills/media/multi-angle-reshoot/SKILL.md +7 -6
  671. package/resources/skills/skills/media/multi-angle-shots/SKILL.md +10 -10
  672. package/resources/skills/skills/media/music-video/SKILL.md +7 -6
  673. package/resources/skills/skills/media/nano-banana/SKILL.md +3 -2
  674. package/resources/skills/skills/media/one-shot-video/SKILL.md +8 -7
  675. package/resources/skills/skills/media/photo-pack-generator/SKILL.md +23 -22
  676. package/resources/skills/skills/media/product-ad-cinematic/SKILL.md +12 -11
  677. package/resources/skills/skills/media/product-campaign/SKILL.md +13 -13
  678. package/resources/skills/skills/media/product-showcase-video/SKILL.md +10 -9
  679. package/resources/skills/skills/media/product-video-ad-maker/SKILL.md +7 -6
  680. package/resources/skills/skills/media/rednote-cover/SKILL.md +7 -7
  681. package/resources/skills/skills/media/seedance-2/SKILL.md +24 -23
  682. package/resources/skills/skills/media/selfie-with-celebrities/SKILL.md +8 -7
  683. package/resources/skills/skills/media/social-media-video/SKILL.md +28 -28
  684. package/resources/skills/skills/media/social-pack/SKILL.md +5 -4
  685. package/resources/skills/skills/media/storyboard/SKILL.md +4 -3
  686. package/resources/skills/skills/media/storyboard-to-cooking-video/SKILL.md +11 -10
  687. package/resources/skills/skills/media/talking-baby-video/SKILL.md +6 -5
  688. package/resources/skills/skills/media/ugc-ads-workflow/SKILL.md +8 -7
  689. package/resources/skills/skills/media/ugc-lifestyle-try-on/SKILL.md +11 -10
  690. package/resources/skills/skills/media/ugc-video-factory/SKILL.md +12 -11
  691. package/resources/skills/skills/media/ui-design/SKILL.md +2 -1
  692. package/resources/skills/skills/media/url-to-design/SKILL.md +8 -8
  693. package/resources/skills/skills/media/workflow/SKILL.md +13 -12
  694. package/resources/skills/skills/media/youtube-shorts/SKILL.md +18 -17
  695. package/resources/skills/skills/media/youtube-thumbnail/SKILL.md +10 -9
  696. package/resources/skills/skills/medusa/building-admin-dashboard-customizations/SKILL.md +2 -2
  697. package/resources/skills/skills/medusa/building-storefronts/SKILL.md +2 -2
  698. package/resources/skills/skills/medusa/building-with-medusa/SKILL.md +3 -3
  699. package/resources/skills/skills/medusa/creating-internal-agents/SKILL.md +16 -16
  700. package/resources/skills/skills/medusa/db-generate/SKILL.md +7 -2
  701. package/resources/skills/skills/medusa/db-migrate/SKILL.md +2 -2
  702. package/resources/skills/skills/medusa/gh-submodule-publish/SKILL.md +7 -7
  703. package/resources/skills/skills/medusa/higgsfield-to-medusa-products/SKILL.md +38 -29
  704. package/resources/skills/skills/medusa/marva-blog-author/SKILL.md +21 -20
  705. package/resources/skills/skills/medusa/medusa-local-dev/SKILL.md +12 -11
  706. package/resources/skills/skills/medusa/medusa-reference/SKILL.md +2 -2
  707. package/resources/skills/skills/medusa/medusa-shop-setup/SKILL.md +2 -2
  708. package/resources/skills/skills/medusa/new-admin-via-api/SKILL.md +19 -14
  709. package/resources/skills/skills/medusa/new-user/SKILL.md +7 -2
  710. package/resources/skills/skills/medusa/provision-medusa-s3-bucket/SKILL.md +15 -10
  711. package/resources/skills/skills/medusa/storefront-best-practices/SKILL.md +3 -3
  712. package/resources/skills/skills/medusa/woocommerce-to-medusa-import/SKILL.md +3 -2
  713. package/resources/skills/skills/meta/acpx/SKILL.md +14 -13
  714. package/resources/skills/skills/meta/analyze/SKILL.md +12 -11
  715. package/resources/skills/skills/meta/ask-claude/SKILL.md +2 -1
  716. package/resources/skills/skills/meta/ask-gemini/SKILL.md +2 -1
  717. package/resources/skills/skills/meta/autoresearch/SKILL.md +5 -0
  718. package/resources/skills/skills/meta/awesome-list-submit/SKILL.md +11 -3
  719. package/resources/skills/skills/meta/builtin-manager/SKILL.md +7 -5
  720. package/resources/skills/skills/meta/cli-writer/SKILL.md +14 -14
  721. package/resources/skills/skills/meta/cue-dashboard/SKILL.md +1 -1
  722. package/resources/skills/skills/meta/cue-usage/SKILL.md +4 -2
  723. package/resources/skills/skills/meta/description-optimizer/SKILL.md +14 -14
  724. package/resources/skills/skills/meta/doctor/SKILL.md +4 -3
  725. package/resources/skills/skills/meta/full-output-enforcement/SKILL.md +7 -6
  726. package/resources/skills/skills/meta/help/SKILL.md +3 -2
  727. package/resources/skills/skills/meta/integrity-tags/SKILL.md +26 -22
  728. package/resources/skills/skills/meta/just/SKILL.md +11 -10
  729. package/resources/skills/skills/meta/kiro-powers/SKILL.md +11 -4
  730. package/resources/skills/skills/meta/liedetector/SKILL.md +7 -6
  731. package/resources/skills/skills/meta/liedetector/scripts/run-evals.sh +25 -6
  732. package/resources/skills/skills/meta/mcpproxy/SKILL.md +7 -7
  733. package/resources/skills/skills/meta/memory-pressure/SKILL.md +10 -9
  734. package/resources/skills/skills/meta/note/SKILL.md +2 -1
  735. package/resources/skills/skills/meta/omx-setup/SKILL.md +2 -1
  736. package/resources/skills/skills/meta/plugin-creator/SKILL.md +2 -1
  737. package/resources/skills/skills/meta/profile-fit-monitor/SKILL.md +5 -4
  738. package/resources/skills/skills/meta/profile-optimizer/SKILL.md +14 -14
  739. package/resources/skills/skills/meta/profile-suggest/SKILL.md +6 -6
  740. package/resources/skills/skills/meta/profile-summon/SKILL.md +32 -25
  741. package/resources/skills/skills/meta/prompt-master/SKILL.md +99 -99
  742. package/resources/skills/skills/meta/ralph-loop/SKILL.md +10 -10
  743. package/resources/skills/skills/meta/retro/SKILL.md +9 -4
  744. package/resources/skills/skills/meta/save-profile/SKILL.md +14 -13
  745. package/resources/skills/skills/meta/skill-discovery/SKILL.md +5 -5
  746. package/resources/skills/skills/meta/skill-eval/SKILL.md +19 -19
  747. package/resources/skills/skills/meta/skill-reviewer/SKILL.md +36 -36
  748. package/resources/skills/skills/meta/skill-simplify/SKILL.md +6 -1
  749. package/resources/skills/skills/meta/skill-suggestion/SKILL.md +25 -24
  750. package/resources/skills/skills/meta/smart-loader/SKILL.md +11 -11
  751. package/resources/skills/skills/meta/smart-loader/scripts/smart-lookup.sh +43 -0
  752. package/resources/skills/skills/meta/smithery-usage/SKILL.md +5 -3
  753. package/resources/skills/skills/meta/soul/SKILL.md +13 -13
  754. package/resources/skills/skills/meta/upgrade-stack/SKILL.md +11 -10
  755. package/resources/skills/skills/meta/verify-council/SKILL.md +5 -3
  756. package/resources/skills/skills/meta/verify-council/references/lane-prompts.md +3 -3
  757. package/resources/skills/skills/meta/verify-council/references/workflow.js +4 -4
  758. package/resources/skills/skills/meta/workspace-recipes/SKILL.md +9 -8
  759. package/resources/skills/skills/nvidia/aiq-research/SKILL.md +4 -2
  760. package/resources/skills/skills/nvidia/cuopt-developer/SKILL.md +22 -21
  761. package/resources/skills/skills/nvidia/cuopt-install/SKILL.md +10 -9
  762. package/resources/skills/skills/nvidia/cuopt-numerical-optimization-api-c/SKILL.md +12 -11
  763. package/resources/skills/skills/nvidia/cuopt-numerical-optimization-api-cli/SKILL.md +15 -14
  764. package/resources/skills/skills/nvidia/cuopt-numerical-optimization-api-python/SKILL.md +8 -7
  765. package/resources/skills/skills/nvidia/cuopt-routing-api-python/SKILL.md +6 -5
  766. package/resources/skills/skills/nvidia/cuopt-server-api-python/SKILL.md +7 -6
  767. package/resources/skills/skills/nvidia/cuopt-server-common/SKILL.md +5 -4
  768. package/resources/skills/skills/nvidia/cuopt-user-rules/SKILL.md +12 -11
  769. package/resources/skills/skills/nvidia/numerical-optimization-formulation/SKILL.md +33 -32
  770. package/resources/skills/skills/nvidia/routing-formulation/SKILL.md +7 -6
  771. package/resources/skills/skills/nvidia/skill-evolution/SKILL.md +33 -32
  772. package/resources/skills/skills/obsidian/json-canvas/SKILL.md +2 -1
  773. package/resources/skills/skills/obsidian/obsidian-bases/SKILL.md +2 -1
  774. package/resources/skills/skills/obsidian/obsidian-cli/SKILL.md +5 -4
  775. package/resources/skills/skills/obsidian/obsidian-markdown/SKILL.md +2 -1
  776. package/resources/skills/skills/orchestration/authmux/SKILL.md +4 -3
  777. package/resources/skills/skills/orchestration/codex-fleet-login/SKILL.md +11 -11
  778. package/resources/skills/skills/orchestration/oh-my-agent/SKILL.md +5 -4
  779. package/resources/skills/skills/orchestration/pipeline/SKILL.md +2 -1
  780. package/resources/skills/skills/orchestration/visual-ralph/SKILL.md +2 -1
  781. package/resources/skills/skills/orchestration/worker/SKILL.md +2 -1
  782. package/resources/skills/skills/plan/autoplan/SKILL.md +16 -11
  783. package/resources/skills/skills/plan/investigate/SKILL.md +20 -15
  784. package/resources/skills/skills/plan/office-hours/SKILL.md +20 -15
  785. package/resources/skills/skills/plan/plan-ceo-review/SKILL.md +22 -17
  786. package/resources/skills/skills/plan/plan-eng-review/SKILL.md +12 -7
  787. package/resources/skills/skills/polymarket/polymarket-predictions-audit/SKILL.md +4 -3
  788. package/resources/skills/skills/polymarket/polymarket-research/SKILL.md +5 -4
  789. package/resources/skills/skills/predict-everything/mirofish/SKILL.md +15 -14
  790. package/resources/skills/skills/private/myvps/SKILL.md +3 -2
  791. package/resources/skills/skills/research/awesome-rust-search/SKILL.md +6 -10
  792. package/resources/skills/skills/research/cloakbrowser/SKILL.md +11 -11
  793. package/resources/skills/skills/research/defuddle/SKILL.md +2 -1
  794. package/resources/skills/skills/research/find-skills/SKILL.md +14 -11
  795. package/resources/skills/skills/research/flight-search/SKILL.md +14 -14
  796. package/resources/skills/skills/research/keyword-research/SKILL.md +23 -23
  797. package/resources/skills/skills/research/obscura/SKILL.md +14 -14
  798. package/resources/skills/skills/research/openai-docs/SKILL.md +1 -0
  799. package/resources/skills/skills/research/trendradar/SKILL.md +32 -30
  800. package/resources/skills/skills/review/api-tester/SKILL.md +14 -13
  801. package/resources/skills/skills/review/code-review/SKILL.md +1 -1
  802. package/resources/skills/skills/review/code-review-deep/SKILL.md +14 -9
  803. package/resources/skills/skills/review/open-code-review/SKILL.md +84 -0
  804. package/resources/skills/skills/review/security-best-practices/SKILL.md +3 -2
  805. package/resources/skills/skills/review/security-review/SKILL.md +3 -2
  806. package/resources/skills/skills/review/wtf/SKILL.md +7 -6
  807. package/resources/skills/skills/robotics/agvc/SKILL.md +73 -0
  808. package/resources/skills/skills/robotics/agvc/evals/evals.json +28 -0
  809. package/resources/skills/skills/robotics/agvc/test/hard-motion-exclusion.md +5 -0
  810. package/resources/skills/skills/robotics/agvc/test/multi-robot-selection.md +4 -0
  811. package/resources/skills/skills/robotics/agvc/test/read-only-tf.md +5 -0
  812. package/resources/skills/skills/robotics/agvc/test/stage-aware-graph.md +4 -0
  813. package/resources/skills/skills/robotics/agvc/test/two-step-confirmation.md +4 -0
  814. package/resources/skills/skills/robotics/ros-skill/LICENSE +201 -0
  815. package/resources/skills/skills/robotics/ros-skill/README.md +113 -0
  816. package/resources/skills/skills/robotics/ros-skill/SKILL.md +312 -0
  817. package/resources/skills/skills/robotics/ros-skill/examples/openclaw.md +135 -0
  818. package/resources/skills/skills/robotics/ros-skill/examples/sensor-monitor.md +60 -0
  819. package/resources/skills/skills/robotics/ros-skill/examples/turtlesim.md +82 -0
  820. package/resources/skills/skills/robotics/ros-skill/references/COMMANDS.md +550 -0
  821. package/resources/skills/skills/robotics/ros-skill/scripts/ros_cli.py +861 -0
  822. package/resources/skills/skills/rust/async-tokio/SKILL.md +10 -4
  823. package/resources/skills/skills/rust/axum-api/SKILL.md +10 -4
  824. package/resources/skills/skills/rust/bacon-watch/SKILL.md +7 -1
  825. package/resources/skills/skills/rust/bevy/SKILL.md +12 -6
  826. package/resources/skills/skills/rust/bindgen/SKILL.md +9 -3
  827. package/resources/skills/skills/rust/cargo-audit/SKILL.md +8 -2
  828. package/resources/skills/skills/rust/cargo-basics/SKILL.md +7 -1
  829. package/resources/skills/skills/rust/cargo-chef/SKILL.md +8 -3
  830. package/resources/skills/skills/rust/cargo-edit/SKILL.md +8 -2
  831. package/resources/skills/skills/rust/cargo-expand/SKILL.md +8 -2
  832. package/resources/skills/skills/rust/cargo-flamegraph/SKILL.md +7 -1
  833. package/resources/skills/skills/rust/cargo-fuzz/SKILL.md +10 -5
  834. package/resources/skills/skills/rust/cargo-hack/SKILL.md +7 -2
  835. package/resources/skills/skills/rust/cargo-msrv/SKILL.md +6 -2
  836. package/resources/skills/skills/rust/cargo-mutants/SKILL.md +9 -3
  837. package/resources/skills/skills/rust/cargo-nextest/SKILL.md +7 -1
  838. package/resources/skills/skills/rust/cargo-readme/SKILL.md +7 -2
  839. package/resources/skills/skills/rust/cbindgen/SKILL.md +9 -4
  840. package/resources/skills/skills/rust/chisel-tool/SKILL.md +11 -6
  841. package/resources/skills/skills/rust/clap-cli/SKILL.md +10 -4
  842. package/resources/skills/skills/rust/clippy-and-fmt/SKILL.md +8 -2
  843. package/resources/skills/skills/rust/cross-compile/SKILL.md +8 -2
  844. package/resources/skills/skills/rust/embedded/SKILL.md +14 -8
  845. package/resources/skills/skills/rust/error-handling/SKILL.md +8 -3
  846. package/resources/skills/skills/rust/just-runner/SKILL.md +8 -2
  847. package/resources/skills/skills/rust/mdbook/SKILL.md +7 -2
  848. package/resources/skills/skills/rust/napi-rs/SKILL.md +8 -3
  849. package/resources/skills/skills/rust/no-std/SKILL.md +10 -5
  850. package/resources/skills/skills/rust/property-testing/SKILL.md +10 -4
  851. package/resources/skills/skills/rust/pyo3/SKILL.md +8 -2
  852. package/resources/skills/skills/rust/ratatui-tui/SKILL.md +10 -5
  853. package/resources/skills/skills/rust/release-plz/SKILL.md +8 -3
  854. package/resources/skills/skills/rust/reqwest/SKILL.md +10 -4
  855. package/resources/skills/skills/rust/sccache/SKILL.md +6 -1
  856. package/resources/skills/skills/rust/serde/SKILL.md +9 -3
  857. package/resources/skills/skills/rust/snapshot-testing/SKILL.md +8 -3
  858. package/resources/skills/skills/rust/sqlx-cli/SKILL.md +8 -2
  859. package/resources/skills/skills/rust/tracing/SKILL.md +9 -3
  860. package/resources/skills/skills/rust/typos-spellcheck/SKILL.md +8 -3
  861. package/resources/skills/skills/rust/uniffi/SKILL.md +8 -3
  862. package/resources/skills/skills/rust/wasm-rust/SKILL.md +6 -1
  863. package/resources/skills/skills/security/agentshield/SKILL.md +7 -6
  864. package/resources/skills/skills/security/cso/SKILL.md +13 -8
  865. package/resources/skills/skills/security/trivy-scan/SKILL.md +1 -1
  866. package/resources/skills/skills/stripe/stripe-best-practices/SKILL.md +5 -4
  867. package/resources/skills/skills/stripe/stripe-webhooks/SKILL.md +13 -12
  868. package/resources/skills/skills/test/scenario-explorer/SKILL.md +5 -0
  869. package/resources/skills/skills/tools/ccusage/SKILL.md +1 -1
  870. package/resources/skills/skills/tools/headroom/SKILL.md +105 -0
  871. package/resources/skills/skills/tools/opensrc/SKILL.md +1 -1
  872. package/resources/skills/skills/tools/portless/SKILL.md +1 -1
  873. package/resources/skills/skills/tools/promptfoo/SKILL.md +140 -0
  874. package/resources/skills/skills/vercel/UPSTREAM.md +12 -0
  875. package/resources/skills/skills/vercel/composition-patterns/AGENTS.md +946 -0
  876. package/resources/skills/skills/vercel/composition-patterns/README.md +60 -0
  877. package/resources/skills/skills/vercel/composition-patterns/SKILL.md +89 -0
  878. package/resources/skills/skills/vercel/composition-patterns/metadata.json +11 -0
  879. package/resources/skills/skills/vercel/composition-patterns/rules/_sections.md +29 -0
  880. package/resources/skills/skills/vercel/composition-patterns/rules/_template.md +24 -0
  881. package/resources/skills/skills/vercel/composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
  882. package/resources/skills/skills/vercel/composition-patterns/rules/architecture-compound-components.md +112 -0
  883. package/resources/skills/skills/vercel/composition-patterns/rules/patterns-children-over-render-props.md +87 -0
  884. package/resources/skills/skills/vercel/composition-patterns/rules/patterns-explicit-variants.md +100 -0
  885. package/resources/skills/skills/vercel/composition-patterns/rules/react19-no-forwardref.md +42 -0
  886. package/resources/skills/skills/vercel/composition-patterns/rules/state-context-interface.md +191 -0
  887. package/resources/skills/skills/vercel/composition-patterns/rules/state-decouple-implementation.md +113 -0
  888. package/resources/skills/skills/vercel/composition-patterns/rules/state-lift-state.md +125 -0
  889. package/resources/skills/skills/vercel/deploy-to-vercel/SKILL.md +296 -0
  890. package/resources/skills/skills/vercel/deploy-to-vercel/resources/deploy-codex.sh +301 -0
  891. package/resources/skills/skills/vercel/deploy-to-vercel/resources/deploy.sh +301 -0
  892. package/resources/skills/skills/vercel/react-best-practices/AGENTS.md +3810 -0
  893. package/resources/skills/skills/vercel/react-best-practices/README.md +123 -0
  894. package/resources/skills/skills/vercel/react-best-practices/SKILL.md +149 -0
  895. package/resources/skills/skills/vercel/react-best-practices/metadata.json +15 -0
  896. package/resources/skills/skills/vercel/react-best-practices/rules/_sections.md +46 -0
  897. package/resources/skills/skills/vercel/react-best-practices/rules/_template.md +28 -0
  898. package/resources/skills/skills/vercel/react-best-practices/rules/advanced-effect-event-deps.md +56 -0
  899. package/resources/skills/skills/vercel/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  900. package/resources/skills/skills/vercel/react-best-practices/rules/advanced-init-once.md +42 -0
  901. package/resources/skills/skills/vercel/react-best-practices/rules/advanced-use-latest.md +39 -0
  902. package/resources/skills/skills/vercel/react-best-practices/rules/async-api-routes.md +38 -0
  903. package/resources/skills/skills/vercel/react-best-practices/rules/async-cheap-condition-before-await.md +37 -0
  904. package/resources/skills/skills/vercel/react-best-practices/rules/async-defer-await.md +82 -0
  905. package/resources/skills/skills/vercel/react-best-practices/rules/async-dependencies.md +51 -0
  906. package/resources/skills/skills/vercel/react-best-practices/rules/async-parallel.md +28 -0
  907. package/resources/skills/skills/vercel/react-best-practices/rules/async-suspense-boundaries.md +99 -0
  908. package/resources/skills/skills/vercel/react-best-practices/rules/bundle-analyzable-paths.md +63 -0
  909. package/resources/skills/skills/vercel/react-best-practices/rules/bundle-barrel-imports.md +60 -0
  910. package/resources/skills/skills/vercel/react-best-practices/rules/bundle-conditional.md +31 -0
  911. package/resources/skills/skills/vercel/react-best-practices/rules/bundle-defer-third-party.md +49 -0
  912. package/resources/skills/skills/vercel/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  913. package/resources/skills/skills/vercel/react-best-practices/rules/bundle-preload.md +50 -0
  914. package/resources/skills/skills/vercel/react-best-practices/rules/client-event-listeners.md +74 -0
  915. package/resources/skills/skills/vercel/react-best-practices/rules/client-localstorage-schema.md +71 -0
  916. package/resources/skills/skills/vercel/react-best-practices/rules/client-passive-event-listeners.md +48 -0
  917. package/resources/skills/skills/vercel/react-best-practices/rules/client-swr-dedup.md +56 -0
  918. package/resources/skills/skills/vercel/react-best-practices/rules/js-batch-dom-css.md +107 -0
  919. package/resources/skills/skills/vercel/react-best-practices/rules/js-cache-function-results.md +80 -0
  920. package/resources/skills/skills/vercel/react-best-practices/rules/js-cache-property-access.md +28 -0
  921. package/resources/skills/skills/vercel/react-best-practices/rules/js-cache-storage.md +70 -0
  922. package/resources/skills/skills/vercel/react-best-practices/rules/js-combine-iterations.md +32 -0
  923. package/resources/skills/skills/vercel/react-best-practices/rules/js-early-exit.md +50 -0
  924. package/resources/skills/skills/vercel/react-best-practices/rules/js-flatmap-filter.md +60 -0
  925. package/resources/skills/skills/vercel/react-best-practices/rules/js-hoist-regexp.md +45 -0
  926. package/resources/skills/skills/vercel/react-best-practices/rules/js-index-maps.md +37 -0
  927. package/resources/skills/skills/vercel/react-best-practices/rules/js-length-check-first.md +49 -0
  928. package/resources/skills/skills/vercel/react-best-practices/rules/js-min-max-loop.md +82 -0
  929. package/resources/skills/skills/vercel/react-best-practices/rules/js-request-idle-callback.md +105 -0
  930. package/resources/skills/skills/vercel/react-best-practices/rules/js-set-map-lookups.md +24 -0
  931. package/resources/skills/skills/vercel/react-best-practices/rules/js-tosorted-immutable.md +57 -0
  932. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-activity.md +26 -0
  933. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  934. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-conditional-render.md +40 -0
  935. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-content-visibility.md +38 -0
  936. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  937. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  938. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  939. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-resource-hints.md +85 -0
  940. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-script-defer-async.md +68 -0
  941. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-svg-precision.md +28 -0
  942. package/resources/skills/skills/vercel/react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  943. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-defer-reads.md +39 -0
  944. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-dependencies.md +45 -0
  945. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  946. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-derived-state.md +29 -0
  947. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-functional-setstate.md +74 -0
  948. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  949. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  950. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-memo.md +44 -0
  951. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  952. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-no-inline-components.md +82 -0
  953. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  954. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-split-combined-hooks.md +64 -0
  955. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-transitions.md +40 -0
  956. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-use-deferred-value.md +59 -0
  957. package/resources/skills/skills/vercel/react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  958. package/resources/skills/skills/vercel/react-best-practices/rules/server-after-nonblocking.md +73 -0
  959. package/resources/skills/skills/vercel/react-best-practices/rules/server-auth-actions.md +96 -0
  960. package/resources/skills/skills/vercel/react-best-practices/rules/server-cache-lru.md +41 -0
  961. package/resources/skills/skills/vercel/react-best-practices/rules/server-cache-react.md +76 -0
  962. package/resources/skills/skills/vercel/react-best-practices/rules/server-dedup-props.md +65 -0
  963. package/resources/skills/skills/vercel/react-best-practices/rules/server-hoist-static-io.md +149 -0
  964. package/resources/skills/skills/vercel/react-best-practices/rules/server-no-shared-module-state.md +50 -0
  965. package/resources/skills/skills/vercel/react-best-practices/rules/server-parallel-fetching.md +83 -0
  966. package/resources/skills/skills/vercel/react-best-practices/rules/server-parallel-nested-fetching.md +34 -0
  967. package/resources/skills/skills/vercel/react-best-practices/rules/server-serialization.md +38 -0
  968. package/resources/skills/skills/vercel/react-native-skills/AGENTS.md +2897 -0
  969. package/resources/skills/skills/vercel/react-native-skills/README.md +165 -0
  970. package/resources/skills/skills/vercel/react-native-skills/SKILL.md +121 -0
  971. package/resources/skills/skills/vercel/react-native-skills/metadata.json +16 -0
  972. package/resources/skills/skills/vercel/react-native-skills/rules/_sections.md +86 -0
  973. package/resources/skills/skills/vercel/react-native-skills/rules/_template.md +28 -0
  974. package/resources/skills/skills/vercel/react-native-skills/rules/animation-derived-value.md +53 -0
  975. package/resources/skills/skills/vercel/react-native-skills/rules/animation-gesture-detector-press.md +95 -0
  976. package/resources/skills/skills/vercel/react-native-skills/rules/animation-gpu-properties.md +65 -0
  977. package/resources/skills/skills/vercel/react-native-skills/rules/design-system-compound-components.md +66 -0
  978. package/resources/skills/skills/vercel/react-native-skills/rules/fonts-config-plugin.md +71 -0
  979. package/resources/skills/skills/vercel/react-native-skills/rules/imports-design-system-folder.md +68 -0
  980. package/resources/skills/skills/vercel/react-native-skills/rules/js-hoist-intl.md +61 -0
  981. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-callbacks.md +44 -0
  982. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-function-references.md +132 -0
  983. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-images.md +53 -0
  984. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-inline-objects.md +97 -0
  985. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-item-expensive.md +94 -0
  986. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-item-memo.md +82 -0
  987. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-item-types.md +104 -0
  988. package/resources/skills/skills/vercel/react-native-skills/rules/list-performance-virtualize.md +67 -0
  989. package/resources/skills/skills/vercel/react-native-skills/rules/monorepo-native-deps-in-app.md +46 -0
  990. package/resources/skills/skills/vercel/react-native-skills/rules/monorepo-single-dependency-versions.md +63 -0
  991. package/resources/skills/skills/vercel/react-native-skills/rules/navigation-native-navigators.md +188 -0
  992. package/resources/skills/skills/vercel/react-native-skills/rules/react-compiler-destructure-functions.md +50 -0
  993. package/resources/skills/skills/vercel/react-native-skills/rules/react-compiler-reanimated-shared-values.md +48 -0
  994. package/resources/skills/skills/vercel/react-native-skills/rules/react-state-dispatcher.md +91 -0
  995. package/resources/skills/skills/vercel/react-native-skills/rules/react-state-fallback.md +56 -0
  996. package/resources/skills/skills/vercel/react-native-skills/rules/react-state-minimize.md +65 -0
  997. package/resources/skills/skills/vercel/react-native-skills/rules/rendering-no-falsy-and.md +74 -0
  998. package/resources/skills/skills/vercel/react-native-skills/rules/rendering-text-in-text-component.md +36 -0
  999. package/resources/skills/skills/vercel/react-native-skills/rules/scroll-position-no-state.md +82 -0
  1000. package/resources/skills/skills/vercel/react-native-skills/rules/state-ground-truth.md +80 -0
  1001. package/resources/skills/skills/vercel/react-native-skills/rules/ui-expo-image.md +66 -0
  1002. package/resources/skills/skills/vercel/react-native-skills/rules/ui-image-gallery.md +104 -0
  1003. package/resources/skills/skills/vercel/react-native-skills/rules/ui-measure-views.md +78 -0
  1004. package/resources/skills/skills/vercel/react-native-skills/rules/ui-menus.md +174 -0
  1005. package/resources/skills/skills/vercel/react-native-skills/rules/ui-native-modals.md +77 -0
  1006. package/resources/skills/skills/vercel/react-native-skills/rules/ui-pressable.md +61 -0
  1007. package/resources/skills/skills/vercel/react-native-skills/rules/ui-safe-area-scroll.md +65 -0
  1008. package/resources/skills/skills/vercel/react-native-skills/rules/ui-scrollview-content-inset.md +45 -0
  1009. package/resources/skills/skills/vercel/react-native-skills/rules/ui-styling.md +87 -0
  1010. package/resources/skills/skills/vercel/react-view-transitions/AGENTS.md +955 -0
  1011. package/resources/skills/skills/vercel/react-view-transitions/README.md +42 -0
  1012. package/resources/skills/skills/vercel/react-view-transitions/SKILL.md +320 -0
  1013. package/resources/skills/skills/vercel/react-view-transitions/metadata.json +12 -0
  1014. package/resources/skills/skills/vercel/react-view-transitions/references/css-recipes.md +242 -0
  1015. package/resources/skills/skills/vercel/react-view-transitions/references/implementation.md +182 -0
  1016. package/resources/skills/skills/vercel/react-view-transitions/references/nextjs.md +176 -0
  1017. package/resources/skills/skills/vercel/react-view-transitions/references/patterns.md +262 -0
  1018. package/resources/skills/skills/vercel/vercel-cli-with-tokens/SKILL.md +353 -0
  1019. package/resources/skills/skills/vercel/vercel-optimize/AGENTS.md +48 -0
  1020. package/resources/skills/skills/vercel/vercel-optimize/CONTRIBUTING.md +41 -0
  1021. package/resources/skills/skills/vercel/vercel-optimize/README.md +91 -0
  1022. package/resources/skills/skills/vercel/vercel-optimize/SKILL.md +322 -0
  1023. package/resources/skills/skills/vercel/vercel-optimize/lib/auth-route.mjs +23 -0
  1024. package/resources/skills/skills/vercel/vercel-optimize/lib/budget-summary.mjs +182 -0
  1025. package/resources/skills/skills/vercel/vercel-optimize/lib/citations.mjs +139 -0
  1026. package/resources/skills/skills/vercel/vercel-optimize/lib/cost-coverage.mjs +143 -0
  1027. package/resources/skills/skills/vercel/vercel-optimize/lib/dedup-recs.mjs +325 -0
  1028. package/resources/skills/skills/vercel/vercel-optimize/lib/deep-dive.mjs +350 -0
  1029. package/resources/skills/skills/vercel/vercel-optimize/lib/display-labels.mjs +185 -0
  1030. package/resources/skills/skills/vercel/vercel-optimize/lib/extract-claims.mjs +550 -0
  1031. package/resources/skills/skills/vercel/vercel-optimize/lib/framework-support.mjs +67 -0
  1032. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/build-minutes-fanout.mjs +69 -0
  1033. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/cold-start.mjs +66 -0
  1034. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/contract.mjs +79 -0
  1035. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/cwv-poor.mjs +87 -0
  1036. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/external-api-slow.mjs +55 -0
  1037. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/hard-gates.mjs +73 -0
  1038. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/index.mjs +45 -0
  1039. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/isr-overrevalidation.mjs +62 -0
  1040. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/middleware-heavy.mjs +51 -0
  1041. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/observability-events-attribution.mjs +56 -0
  1042. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/platform-bot-protection.mjs +115 -0
  1043. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/platform-fluid-compute.mjs +83 -0
  1044. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/region-misconfig.mjs +64 -0
  1045. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/route-errors.mjs +80 -0
  1046. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/scanner-driven.mjs +122 -0
  1047. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/select-candidates.mjs +134 -0
  1048. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/slow-route.mjs +88 -0
  1049. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/types.d.ts +38 -0
  1050. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/uncached-route.mjs +93 -0
  1051. package/resources/skills/skills/vercel/vercel-optimize/lib/gates/usage-spike-triage.mjs +121 -0
  1052. package/resources/skills/skills/vercel/vercel-optimize/lib/grade-recommendation.mjs +155 -0
  1053. package/resources/skills/skills/vercel/vercel-optimize/lib/impact-label.mjs +126 -0
  1054. package/resources/skills/skills/vercel/vercel-optimize/lib/impact-magnitude.mjs +60 -0
  1055. package/resources/skills/skills/vercel/vercel-optimize/lib/investigation-brief.mjs +610 -0
  1056. package/resources/skills/skills/vercel/vercel-optimize/lib/observation-safety.mjs +174 -0
  1057. package/resources/skills/skills/vercel/vercel-optimize/lib/project-facts.mjs +99 -0
  1058. package/resources/skills/skills/vercel/vercel-optimize/lib/queries.mjs +315 -0
  1059. package/resources/skills/skills/vercel/vercel-optimize/lib/reconcile-candidates.mjs +372 -0
  1060. package/resources/skills/skills/vercel/vercel-optimize/lib/render-report.mjs +955 -0
  1061. package/resources/skills/skills/vercel/vercel-optimize/lib/repo-root.mjs +86 -0
  1062. package/resources/skills/skills/vercel/vercel-optimize/lib/route-normalize.mjs +220 -0
  1063. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/bot-protection-certainty.mjs +38 -0
  1064. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/cache-tag-invalidation-certainty.mjs +30 -0
  1065. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/count-correct.mjs +52 -0
  1066. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/function-duration-invocations.mjs +38 -0
  1067. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/index.mjs +79 -0
  1068. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/middleware-conflict.mjs +36 -0
  1069. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/missing-citation.mjs +16 -0
  1070. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/pre-release.mjs +74 -0
  1071. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/rate-limit.mjs +67 -0
  1072. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/rendering-mode-mislabel.mjs +38 -0
  1073. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/undeclared-dep.mjs +78 -0
  1074. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/vercel-directive-strip.mjs +37 -0
  1075. package/resources/skills/skills/vercel/vercel-optimize/lib/sanitizers/window-units.mjs +32 -0
  1076. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/cache-components-suspense-dedupe.mjs +109 -0
  1077. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/edge-heavy-import.mjs +94 -0
  1078. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/force-dynamic.mjs +42 -0
  1079. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/headers-in-page.mjs +44 -0
  1080. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/index.mjs +35 -0
  1081. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/large-static-asset.mjs +92 -0
  1082. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/max-age-without-s-maxage.mjs +42 -0
  1083. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/middleware-broad-matcher.mjs +55 -0
  1084. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/missing-cache-headers.mjs +90 -0
  1085. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/prisma-include-tree.mjs +42 -0
  1086. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/region-pin-in-config.mjs +88 -0
  1087. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/source-maps-production.mjs +36 -0
  1088. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/sveltekit-prerender-missing.mjs +43 -0
  1089. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/turbo-force-bypass.mjs +129 -0
  1090. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/unoptimized-image.mjs +113 -0
  1091. package/resources/skills/skills/vercel/vercel-optimize/lib/scanners/use-cache-date-stamp.mjs +106 -0
  1092. package/resources/skills/skills/vercel/vercel-optimize/lib/support-topics.mjs +355 -0
  1093. package/resources/skills/skills/vercel/vercel-optimize/lib/throttle.mjs +273 -0
  1094. package/resources/skills/skills/vercel/vercel-optimize/lib/util.mjs +17 -0
  1095. package/resources/skills/skills/vercel/vercel-optimize/lib/vercel.mjs +864 -0
  1096. package/resources/skills/skills/vercel/vercel-optimize/lib/verify-claim.mjs +1296 -0
  1097. package/resources/skills/skills/vercel/vercel-optimize/lib/workspace-resolver.mjs +521 -0
  1098. package/resources/skills/skills/vercel/vercel-optimize/metadata.json +14 -0
  1099. package/resources/skills/skills/vercel/vercel-optimize/references/candidates.md +176 -0
  1100. package/resources/skills/skills/vercel/vercel-optimize/references/data-collection.md +218 -0
  1101. package/resources/skills/skills/vercel/vercel-optimize/references/docs-library.json +683 -0
  1102. package/resources/skills/skills/vercel/vercel-optimize/references/doctrine.md +105 -0
  1103. package/resources/skills/skills/vercel/vercel-optimize/references/observability-plus.md +108 -0
  1104. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/README.md +53 -0
  1105. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/ai-application.md +32 -0
  1106. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/api-service.md +30 -0
  1107. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/content-site.md +30 -0
  1108. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/ecommerce.md +30 -0
  1109. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/marketing.md +30 -0
  1110. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/saas.md +31 -0
  1111. package/resources/skills/skills/vercel/vercel-optimize/references/playbooks/sveltekit.md +75 -0
  1112. package/resources/skills/skills/vercel/vercel-optimize/references/recommendations.md +203 -0
  1113. package/resources/skills/skills/vercel/vercel-optimize/references/scanner-patterns.md +251 -0
  1114. package/resources/skills/skills/vercel/vercel-optimize/references/scoring.md +205 -0
  1115. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/README.md +46 -0
  1116. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/astro-edge-middleware-scope.md +22 -0
  1117. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/astro-output-mode-and-isr.md +22 -0
  1118. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/auth-preserving-parallelization.md +22 -0
  1119. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/bot-protection-product-guardrails.md +22 -0
  1120. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/build-minutes-monorepo-fanout.md +23 -0
  1121. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/cache-components-static-shell-boundaries.md +22 -0
  1122. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/cache-components-suspense-dedupe-pitfall.md +23 -0
  1123. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/cdn-cache-auth-safety.md +22 -0
  1124. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/cold-start-initialization-bundle.md +22 -0
  1125. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/core-web-vitals-client-bottlenecks.md +22 -0
  1126. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/database-egress-pooling-region.md +22 -0
  1127. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/dynamic-rendering-traps.md +22 -0
  1128. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/external-api-critical-path-platform.md +22 -0
  1129. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/external-api-critical-path.md +22 -0
  1130. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/fast-data-transfer-payloads.md +22 -0
  1131. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/fluid-compute-caveats.md +22 -0
  1132. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/function-duration-io-and-after.md +22 -0
  1133. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/function-invocation-reduction.md +22 -0
  1134. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/function-region-misconfiguration-ttfb.md +23 -0
  1135. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/image-optimization-cost-control.md +22 -0
  1136. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/isr-revalidation-static-generation.md +22 -0
  1137. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/middleware-proxy-edge-cost.md +22 -0
  1138. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/next-fetch-revalidate-floor.md +22 -0
  1139. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/next-font-cls-self-hosting.md +23 -0
  1140. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/next-heavy-ui-lazy-load-boundaries.md +23 -0
  1141. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/next-image-lcp-preload-sizes.md +23 -0
  1142. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/next-route-handler-get-cache-defaults.md +22 -0
  1143. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/next-script-third-party-strategy.md +23 -0
  1144. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/nextjs-version-cache-semantics.md +22 -0
  1145. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/not-found-catchall-request-waste.md +23 -0
  1146. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/nuxt-route-rules-cache-isr.md +22 -0
  1147. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/observability-events-cost-attribution.md +22 -0
  1148. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/post-response-work-waituntil.md +22 -0
  1149. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/route-error-durable-offload.md +22 -0
  1150. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/route-error-runtime-limits.md +22 -0
  1151. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/runtime-cache-reusable-data.md +22 -0
  1152. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/sveltekit-isr-prerender-safety.md +22 -0
  1153. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/sveltekit-split-cold-start-tradeoff.md +22 -0
  1154. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/usage-spike-triage.md +22 -0
  1155. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/use-cache-date-stamp-isr-write-amplifier.md +23 -0
  1156. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/use-cache-remote-shared-origin-data.md +22 -0
  1157. package/resources/skills/skills/vercel/vercel-optimize/references/support-topics/workflow-resumable-stream-routes.md +23 -0
  1158. package/resources/skills/skills/vercel/vercel-optimize/references/verification.md +102 -0
  1159. package/resources/skills/skills/vercel/vercel-optimize/references/voice.md +76 -0
  1160. package/resources/skills/skills/vercel/vercel-optimize/scripts/budget-summary.mjs +56 -0
  1161. package/resources/skills/skills/vercel/vercel-optimize/scripts/build-docs.mjs +74 -0
  1162. package/resources/skills/skills/vercel/vercel-optimize/scripts/check-citations.mjs +81 -0
  1163. package/resources/skills/skills/vercel/vercel-optimize/scripts/check-docs-fresh.mjs +93 -0
  1164. package/resources/skills/skills/vercel/vercel-optimize/scripts/collect-signals.mjs +576 -0
  1165. package/resources/skills/skills/vercel/vercel-optimize/scripts/collect-sub-agent-outputs.mjs +296 -0
  1166. package/resources/skills/skills/vercel/vercel-optimize/scripts/deep-dive.mjs +319 -0
  1167. package/resources/skills/skills/vercel/vercel-optimize/scripts/gate-investigations.mjs +166 -0
  1168. package/resources/skills/skills/vercel/vercel-optimize/scripts/merge-signals.mjs +192 -0
  1169. package/resources/skills/skills/vercel/vercel-optimize/scripts/prepare-investigation-brief.mjs +231 -0
  1170. package/resources/skills/skills/vercel/vercel-optimize/scripts/reconcile-candidates.mjs +62 -0
  1171. package/resources/skills/skills/vercel/vercel-optimize/scripts/render-report.mjs +437 -0
  1172. package/resources/skills/skills/vercel/vercel-optimize/scripts/scan-codebase.mjs +313 -0
  1173. package/resources/skills/skills/vercel/vercel-optimize/scripts/verify-and-regen.mjs +346 -0
  1174. package/resources/skills/skills/vercel/vercel-optimize/scripts/verify-finding.mjs +19 -0
  1175. package/resources/skills/skills/vercel/web-design-guidelines/SKILL.md +39 -0
  1176. package/resources/skills/skills/vercel/writing-guidelines/SKILL.md +39 -0
  1177. package/resources/skills/skills/video/amazon-product-listing/SKILL.md +8 -12
  1178. package/resources/skills/skills/video/cinematic-flow/SKILL.md +7 -11
  1179. package/resources/skills/skills/video/motion-design-flow/SKILL.md +8 -12
  1180. package/resources/skills/skills/video/podcast-flow/SKILL.md +9 -13
  1181. package/resources/skills/skills/video/tv-ad/SKILL.md +8 -12
  1182. package/resources/skills/skills/video/ugc-flow/SKILL.md +12 -16
  1183. package/resources/skills/skills/video/video-adapt/SKILL.md +8 -12
  1184. package/resources/skills/skills/xbot/operate/SKILL.md +2 -9
  1185. package/src/commands/_index.test.ts +105 -0
  1186. package/src/commands/_index.ts +59 -25
  1187. package/src/commands/agent-prompt.test.ts +43 -0
  1188. package/src/commands/ai-score.e2e.test.ts +1 -1
  1189. package/src/commands/ai.test.ts +113 -0
  1190. package/src/commands/ai.ts +3 -5
  1191. package/src/commands/ask.test.ts +82 -0
  1192. package/src/commands/ask.ts +3 -4
  1193. package/src/commands/audit.test.ts +61 -0
  1194. package/src/commands/auth.e2e.test.ts +86 -0
  1195. package/src/commands/auth.test.ts +56 -0
  1196. package/src/commands/auth.ts +156 -0
  1197. package/src/commands/auto-detect.test.ts +22 -2
  1198. package/src/commands/auto-detect.ts +43 -19
  1199. package/src/commands/benchmark.test.ts +88 -0
  1200. package/src/commands/benchmark.ts +3 -5
  1201. package/src/commands/brief.ts +93 -0
  1202. package/src/commands/builtin.test.ts +199 -0
  1203. package/src/commands/builtin.ts +3 -4
  1204. package/src/commands/clean.test.ts +181 -0
  1205. package/src/commands/clean.ts +12 -12
  1206. package/src/commands/cli.test.ts +11 -3
  1207. package/src/commands/cli.ts +4 -5
  1208. package/src/commands/cloud-api.contract.test.ts +198 -0
  1209. package/src/commands/cloud.test.ts +76 -0
  1210. package/src/commands/cloud.ts +52 -244
  1211. package/src/commands/colony-dispatch.test.ts +143 -0
  1212. package/src/commands/completions.test.ts +195 -0
  1213. package/src/commands/cost-compare.test.ts +57 -0
  1214. package/src/commands/cost.ts +108 -39
  1215. package/src/commands/create-profile.test.ts +256 -0
  1216. package/src/commands/create-profile.ts +3 -4
  1217. package/src/commands/cue-learnings.test.ts +74 -0
  1218. package/src/commands/current.ts +2 -1
  1219. package/src/commands/dash.test.ts +9 -20
  1220. package/src/commands/dash.ts +2 -1
  1221. package/src/commands/debug.ts +5 -6
  1222. package/src/commands/diff.test.ts +64 -0
  1223. package/src/commands/diff.ts +3 -4
  1224. package/src/commands/discover-mcps.ts +189 -0
  1225. package/src/commands/discover-notify.ts +378 -0
  1226. package/src/commands/discover-site.ts +479 -0
  1227. package/src/commands/discover.search.test.ts +222 -0
  1228. package/src/commands/discover.ts +276 -1270
  1229. package/src/commands/docs-facts.test.ts +147 -0
  1230. package/src/commands/doctor.test.ts +147 -4
  1231. package/src/commands/doctor.ts +257 -67
  1232. package/src/commands/eval-behavior.ts +7 -8
  1233. package/src/commands/eval.ts +8 -8
  1234. package/src/commands/evolve.test.ts +56 -0
  1235. package/src/commands/evolve.ts +23 -26
  1236. package/src/commands/export-docker.test.ts +190 -0
  1237. package/src/commands/export-docker.ts +3 -4
  1238. package/src/commands/features-batch1.test.ts +1 -1
  1239. package/src/commands/feedback.test.ts +63 -0
  1240. package/src/commands/feedback.ts +5 -5
  1241. package/src/commands/firstmate.test.ts +200 -0
  1242. package/src/commands/firstmate.ts +161 -0
  1243. package/src/commands/fork-skills.test.ts +74 -0
  1244. package/src/commands/gates.ts +2 -1
  1245. package/src/commands/gc.test.ts +173 -0
  1246. package/src/commands/gc.ts +65 -0
  1247. package/src/commands/handoff-integration.test.ts +125 -0
  1248. package/src/commands/handoff.test.ts +249 -0
  1249. package/src/commands/handoff.ts +74 -41
  1250. package/src/commands/icon.ts +3 -4
  1251. package/src/commands/import-profile.test.ts +228 -0
  1252. package/src/commands/import-profile.ts +11 -7
  1253. package/src/commands/init-cost-proof.test.ts +30 -0
  1254. package/src/commands/init-noninteractive.test.ts +338 -0
  1255. package/src/commands/init-recommended-tools.test.ts +93 -0
  1256. package/src/commands/init.test.ts +77 -0
  1257. package/src/commands/init.ts +508 -87
  1258. package/src/commands/install-sh.e2e.test.ts +21 -8
  1259. package/src/commands/install.ts +618 -610
  1260. package/src/commands/launch-handoff.e2e.test.ts +85 -13
  1261. package/src/commands/launch.account-runtime.test.ts +117 -0
  1262. package/src/commands/launch.e2e.test.ts +160 -3
  1263. package/src/commands/launch.parse.test.ts +378 -0
  1264. package/src/commands/launch.test.ts +401 -108
  1265. package/src/commands/launch.ts +2179 -730
  1266. package/src/commands/lint-skill.test.ts +173 -0
  1267. package/src/commands/list.test.ts +72 -0
  1268. package/src/commands/list.ts +92 -17
  1269. package/src/commands/loadout.test.ts +225 -0
  1270. package/src/commands/loadout.ts +132 -0
  1271. package/src/commands/lock.test.ts +157 -0
  1272. package/src/commands/lock.ts +4 -5
  1273. package/src/commands/marketplace-manifest.test.ts +39 -0
  1274. package/src/commands/marketplace.test.ts +202 -0
  1275. package/src/commands/marketplace.ts +268 -36
  1276. package/src/commands/materialize.test.ts +59 -0
  1277. package/src/commands/materialize.ts +135 -134
  1278. package/src/commands/mcp.test.ts +109 -0
  1279. package/src/commands/mcps.test.ts +49 -0
  1280. package/src/commands/mcps.ts +73 -55
  1281. package/src/commands/mem.test.ts +94 -0
  1282. package/src/commands/merge.test.ts +57 -0
  1283. package/src/commands/migrate.test.ts +45 -0
  1284. package/src/commands/migrate.ts +3 -4
  1285. package/src/commands/new.test.ts +173 -0
  1286. package/src/commands/optimizer.test.ts +239 -0
  1287. package/src/commands/optimizer.ts +56 -255
  1288. package/src/commands/packs.test.ts +97 -0
  1289. package/src/commands/packs.ts +3 -4
  1290. package/src/commands/playground.test.ts +61 -0
  1291. package/src/commands/playground.ts +3 -4
  1292. package/src/commands/plugin-commands.test.ts +34 -0
  1293. package/src/commands/positioning.test.ts +46 -0
  1294. package/src/commands/profile-draft-skill.ts +3 -4
  1295. package/src/commands/profile-match.ts +179 -0
  1296. package/src/commands/profile-suggest.test.ts +67 -0
  1297. package/src/commands/profile-suggest.ts +130 -5
  1298. package/src/commands/profile.test.ts +59 -0
  1299. package/src/commands/profile.ts +6 -0
  1300. package/src/commands/replay-whatif.test.ts +154 -0
  1301. package/src/commands/replay.test.ts +68 -0
  1302. package/src/commands/resolve.deep.test.ts +155 -0
  1303. package/src/commands/resolve.test.ts +66 -0
  1304. package/src/commands/resolve.ts +436 -0
  1305. package/src/commands/ruler.test.ts +168 -0
  1306. package/src/commands/ruler.ts +270 -0
  1307. package/src/commands/scan.test.ts +83 -0
  1308. package/src/commands/score.test.ts +125 -0
  1309. package/src/commands/score.ts +1 -4
  1310. package/src/commands/security-audit.test.ts +133 -0
  1311. package/src/commands/security-audit.ts +4 -5
  1312. package/src/commands/security.test.ts +167 -2
  1313. package/src/commands/security.ts +219 -16
  1314. package/src/commands/setup.test.ts +32 -0
  1315. package/src/commands/share.test.ts +154 -0
  1316. package/src/commands/share.ts +28 -10
  1317. package/src/commands/shell.test.ts +406 -25
  1318. package/src/commands/shell.ts +438 -98
  1319. package/src/commands/skill-report.test.ts +110 -0
  1320. package/src/commands/skills-lint.test.ts +96 -0
  1321. package/src/commands/skills-lint.ts +31 -12
  1322. package/src/commands/skills-new.test.ts +96 -0
  1323. package/src/commands/skills-new.ts +3 -4
  1324. package/src/commands/skills-pin.test.ts +169 -0
  1325. package/src/commands/skills-pin.ts +4 -5
  1326. package/src/commands/skills-test.test.ts +234 -0
  1327. package/src/commands/skills-test.ts +6 -3
  1328. package/src/commands/skills.test.ts +109 -0
  1329. package/src/commands/skills.ts +451 -357
  1330. package/src/commands/snapshot.test.ts +189 -0
  1331. package/src/commands/snapshot.ts +121 -50
  1332. package/src/commands/sources.ts +5 -6
  1333. package/src/commands/stats.test.ts +262 -0
  1334. package/src/commands/stats.ts +115 -0
  1335. package/src/commands/status.test.ts +239 -0
  1336. package/src/commands/status.ts +92 -15
  1337. package/src/commands/submit-profile.ts +4 -4
  1338. package/src/commands/suggest-pairs.test.ts +249 -0
  1339. package/src/commands/suggest-pairs.ts +71 -30
  1340. package/src/commands/suggest.test.ts +215 -0
  1341. package/src/commands/suggest.ts +211 -29
  1342. package/src/commands/summon.test.ts +190 -13
  1343. package/src/commands/summon.ts +245 -29
  1344. package/src/commands/sync.test.ts +26 -0
  1345. package/src/commands/sync.ts +191 -0
  1346. package/src/commands/telemetry.test.ts +162 -0
  1347. package/src/commands/trace.test.ts +48 -0
  1348. package/src/commands/tree.test.ts +76 -0
  1349. package/src/commands/tui.test.ts +55 -0
  1350. package/src/commands/update.test.ts +98 -0
  1351. package/src/commands/update.ts +8 -9
  1352. package/src/commands/upgrade.test.ts +45 -0
  1353. package/src/commands/upgrade.ts +4 -5
  1354. package/src/commands/use.test.ts +63 -0
  1355. package/src/commands/use.ts +50 -7
  1356. package/src/commands/validate.test.ts +80 -0
  1357. package/src/commands/watch-live.test.ts +46 -0
  1358. package/src/commands/watch-live.ts +5 -6
  1359. package/src/commands/watch.test.ts +97 -0
  1360. package/src/commands/why.test.ts +46 -0
  1361. package/src/commands/why.ts +4 -5
  1362. package/src/commands/workspace.test.ts +92 -0
  1363. package/src/index.test.ts +150 -0
  1364. package/src/index.ts +50 -101
  1365. package/src/lib/aas-profile-organizer.test.ts +290 -0
  1366. package/src/lib/aas-profile-organizer.ts +849 -0
  1367. package/src/lib/agent-adapters.test.ts +138 -89
  1368. package/src/lib/agent-adapters.ts +358 -284
  1369. package/src/lib/agent-collaboration.test.ts +46 -0
  1370. package/src/lib/agent-docs-index.test.ts +74 -0
  1371. package/src/lib/agent-scoping.test.ts +181 -0
  1372. package/src/lib/ai-profile-advisor.test.ts +350 -0
  1373. package/src/lib/ai-profile-advisor.ts +549 -0
  1374. package/src/lib/analytics.test.ts +59 -1
  1375. package/src/lib/analytics.ts +37 -22
  1376. package/src/lib/auto-detect.test.ts +198 -2
  1377. package/src/lib/auto-detect.ts +251 -34
  1378. package/src/lib/brand-icons.test.ts +129 -0
  1379. package/src/lib/brand-icons.ts +6 -7
  1380. package/src/lib/cache.test.ts +261 -0
  1381. package/src/lib/cache.ts +194 -10
  1382. package/src/lib/catalog-index.test.ts +321 -0
  1383. package/src/lib/catalog-index.ts +560 -0
  1384. package/src/lib/ci-workflows.test.ts +40 -0
  1385. package/src/lib/claude-binary.test.ts +217 -0
  1386. package/src/lib/claude-binary.ts +131 -22
  1387. package/src/lib/claude-classifier.test.ts +250 -0
  1388. package/src/lib/claude-classifier.ts +283 -0
  1389. package/src/lib/claude-logo.test.ts +64 -0
  1390. package/src/lib/claude-logo.ts +41 -0
  1391. package/src/lib/cli-extractor.ts +4 -5
  1392. package/src/lib/codex-auth-sync.test.ts +80 -0
  1393. package/src/lib/codex-auth.ts +52 -0
  1394. package/src/lib/codex-config.test.ts +288 -0
  1395. package/src/lib/codex-config.ts +420 -0
  1396. package/src/lib/codex-hooks.test.ts +43 -0
  1397. package/src/lib/codex-hooks.ts +54 -0
  1398. package/src/lib/codex-ponytail.ts +31 -0
  1399. package/src/lib/colony-dispatch.test.ts +59 -0
  1400. package/src/lib/colony-dispatch.ts +3 -4
  1401. package/src/lib/combo-history.test.ts +163 -1
  1402. package/src/lib/combo-history.ts +87 -5
  1403. package/src/lib/command-runner.test.ts +52 -0
  1404. package/src/lib/command-runner.ts +19 -0
  1405. package/src/lib/companion-fetch.ts +36 -306
  1406. package/src/lib/conditional-skills.test.ts +22 -0
  1407. package/src/lib/conditional-skills.ts +19 -5
  1408. package/src/lib/conflict-detector.test.ts +73 -0
  1409. package/src/lib/conflict-detector.ts +5 -7
  1410. package/src/lib/context-mode.test.ts +90 -0
  1411. package/src/lib/context-mode.ts +81 -0
  1412. package/src/lib/core-gitguardex-skills.test.ts +38 -0
  1413. package/src/lib/credentials-sync.test.ts +438 -1
  1414. package/src/lib/credentials-sync.ts +382 -36
  1415. package/src/lib/cue-credentials.test.ts +109 -0
  1416. package/src/lib/cue-credentials.ts +89 -0
  1417. package/src/lib/cwd-resolver.test.ts +27 -0
  1418. package/src/lib/cwd-resolver.ts +12 -24
  1419. package/src/lib/dashboard-env-reader.test.ts +274 -0
  1420. package/src/lib/dashboard-env-reader.ts +107 -0
  1421. package/src/lib/dashboard-playbook-parser.ts +231 -0
  1422. package/src/lib/dashboard-server.test.ts +118 -5
  1423. package/src/lib/dashboard-server.ts +121 -465
  1424. package/src/lib/dashboard-static-assets.ts +119 -0
  1425. package/src/lib/dashboard-version.ts +33 -0
  1426. package/src/lib/default-profile.test.ts +13 -0
  1427. package/src/lib/default-profile.ts +26 -0
  1428. package/src/lib/discover-format.test.ts +10 -0
  1429. package/src/lib/discover-format.ts +76 -0
  1430. package/src/lib/discover-market-profile-yaml.test.ts +67 -0
  1431. package/src/lib/discover-market-profile-yaml.ts +47 -0
  1432. package/src/lib/firstmate-live.test.ts +146 -0
  1433. package/src/lib/firstmate-live.ts +127 -0
  1434. package/src/lib/fs-utils.ts +60 -0
  1435. package/src/lib/github-api.ts +230 -0
  1436. package/src/lib/handoff.test.ts +207 -0
  1437. package/src/lib/handoff.ts +243 -69
  1438. package/src/lib/help.test.ts +69 -0
  1439. package/src/lib/integrity-ladder.test.ts +120 -0
  1440. package/src/lib/kitty-image.ts +13 -0
  1441. package/src/lib/launch-format.ts +545 -0
  1442. package/src/lib/launch-guards.ts +38 -0
  1443. package/src/lib/launch-loader.test.ts +178 -0
  1444. package/src/lib/launch-loader.ts +240 -0
  1445. package/src/lib/lazy-skills.ts +47 -2
  1446. package/src/lib/liedetector-hooks.test.ts +303 -0
  1447. package/src/lib/local-inventory-types.ts +20 -0
  1448. package/src/lib/local-inventory.test.ts +103 -0
  1449. package/src/lib/local-inventory.ts +214 -0
  1450. package/src/lib/manifest-cache.test.ts +171 -0
  1451. package/src/lib/manifest-cache.ts +85 -33
  1452. package/src/lib/market-install.test.ts +128 -0
  1453. package/src/lib/market-install.ts +247 -0
  1454. package/src/lib/mcp-availability.test.ts +248 -0
  1455. package/src/lib/mcp-availability.ts +230 -0
  1456. package/src/lib/mcp-catalog.ts +4 -13
  1457. package/src/lib/mcp-materializer.ts +3 -8
  1458. package/src/lib/mcp-overrides.test.ts +214 -0
  1459. package/src/lib/mcp-overrides.ts +220 -0
  1460. package/src/lib/mcp-picker.test.ts +150 -0
  1461. package/src/lib/mcp-picker.ts +247 -0
  1462. package/src/lib/mcp-probe.test.ts +118 -0
  1463. package/src/lib/mcp-probe.ts +202 -0
  1464. package/src/lib/mcp-token-estimate.test.ts +105 -0
  1465. package/src/lib/mcp-token-estimate.ts +152 -0
  1466. package/src/lib/pack-resolver.test.ts +81 -0
  1467. package/src/lib/pack-resolver.ts +3 -4
  1468. package/src/lib/pair-suggestions.test.ts +80 -5
  1469. package/src/lib/pair-suggestions.ts +28 -12
  1470. package/src/lib/picker/card.test.ts +184 -0
  1471. package/src/lib/picker/card.ts +420 -0
  1472. package/src/lib/picker/categories.test.ts +91 -0
  1473. package/src/lib/picker/categories.ts +88 -0
  1474. package/src/lib/picker/classic.ts +1147 -0
  1475. package/src/lib/picker/flow.test.ts +49 -0
  1476. package/src/lib/picker/flow.ts +238 -0
  1477. package/src/lib/picker/keys.test.ts +373 -0
  1478. package/src/lib/picker/palette.test.ts +323 -0
  1479. package/src/lib/picker/palette.ts +667 -0
  1480. package/src/lib/picker/render-util.test.ts +213 -0
  1481. package/src/lib/picker/render-util.ts +111 -0
  1482. package/src/lib/picker/selector.test.ts +87 -0
  1483. package/src/lib/picker/selector.ts +51 -0
  1484. package/src/lib/picker/tally.test.ts +221 -0
  1485. package/src/lib/picker/tally.ts +154 -0
  1486. package/src/lib/picker/types.ts +150 -0
  1487. package/src/lib/picker/ui.test.ts +184 -0
  1488. package/src/lib/picker/ui.ts +219 -0
  1489. package/src/lib/picker.test.ts +55 -31
  1490. package/src/lib/picker.ts +89 -1475
  1491. package/src/lib/plugin-discovery.test.ts +175 -0
  1492. package/src/lib/ponytail-profile.test.ts +145 -0
  1493. package/src/lib/pr-poster.ts +6 -2
  1494. package/src/lib/profile-capabilities.test.ts +29 -0
  1495. package/src/lib/profile-capabilities.ts +22 -0
  1496. package/src/lib/profile-choice-feedback.test.ts +356 -0
  1497. package/src/lib/profile-choice-feedback.ts +669 -0
  1498. package/src/lib/profile-conflicts.test.ts +114 -0
  1499. package/src/lib/profile-conflicts.ts +52 -0
  1500. package/src/lib/profile-generator.ts +15 -56
  1501. package/src/lib/profile-linter.test.ts +217 -0
  1502. package/src/lib/profile-linter.ts +153 -35
  1503. package/src/lib/profile-loader.test.ts +402 -1
  1504. package/src/lib/profile-loader.ts +289 -88
  1505. package/src/lib/profile-match-llm.test.ts +194 -0
  1506. package/src/lib/profile-match-llm.ts +393 -0
  1507. package/src/lib/profile-match.test.ts +368 -0
  1508. package/src/lib/profile-match.ts +914 -0
  1509. package/src/lib/profile-merge.test.ts +30 -1
  1510. package/src/lib/profile-merge.ts +58 -18
  1511. package/src/lib/profile-metrics.test.ts +176 -0
  1512. package/src/lib/profile-metrics.ts +3 -4
  1513. package/src/lib/profile-names.test.ts +1 -1
  1514. package/src/lib/profile-suggestion-eval.test.ts +63 -0
  1515. package/src/lib/profile-suggestion-eval.ts +185 -0
  1516. package/src/lib/profile-yaml-editor.test.ts +66 -0
  1517. package/src/lib/profile-yaml-editor.ts +43 -0
  1518. package/src/lib/project-brief.test.ts +376 -0
  1519. package/src/lib/project-brief.ts +591 -0
  1520. package/src/lib/project-loadout.test.ts +273 -0
  1521. package/src/lib/project-loadout.ts +358 -0
  1522. package/src/lib/project-scanner.test.ts +228 -0
  1523. package/src/lib/project-skills-routing.test.ts +163 -0
  1524. package/src/lib/ratings.test.ts +130 -0
  1525. package/src/lib/repo-root.test.ts +80 -0
  1526. package/src/lib/repo-root.ts +38 -0
  1527. package/src/lib/repo-scope.ts +81 -0
  1528. package/src/lib/repository-stack-detect.test.ts +157 -0
  1529. package/src/lib/repository-stack-detect.ts +406 -0
  1530. package/src/lib/resolver-local.test.ts +40 -1
  1531. package/src/lib/resolver-local.ts +32 -5
  1532. package/src/lib/resolver-npx.test.ts +833 -4
  1533. package/src/lib/resolver-npx.ts +547 -62
  1534. package/src/lib/resolver-plugins.test.ts +2 -2
  1535. package/src/lib/resolver-plugins.ts +19 -42
  1536. package/src/lib/ruler.test.ts +332 -0
  1537. package/src/lib/ruler.ts +374 -0
  1538. package/src/lib/runtime-gc.test.ts +123 -0
  1539. package/src/lib/runtime-gc.ts +203 -0
  1540. package/src/lib/runtime-install.test.ts +213 -0
  1541. package/src/lib/runtime-install.ts +177 -35
  1542. package/src/lib/runtime-lock.test.ts +115 -0
  1543. package/src/lib/runtime-materializer.config-json.test.ts +123 -0
  1544. package/src/lib/runtime-materializer.mcp-prune.test.ts +105 -0
  1545. package/src/lib/runtime-materializer.plugin-cache.test.ts +785 -0
  1546. package/src/lib/runtime-materializer.process.test.ts +41 -0
  1547. package/src/lib/runtime-materializer.test.ts +1843 -167
  1548. package/src/lib/runtime-materializer.ts +1866 -520
  1549. package/src/lib/scan-plugins.ts +10 -5
  1550. package/src/lib/session-checkpoint.test.ts +295 -0
  1551. package/src/lib/session-checkpoint.ts +297 -0
  1552. package/src/lib/shared-profiles.test.ts +52 -1
  1553. package/src/lib/shared-profiles.ts +62 -14
  1554. package/src/lib/shim-dir.test.ts +155 -0
  1555. package/src/lib/shim-dir.ts +176 -0
  1556. package/src/lib/skill-dependencies.getNeeded.test.ts +81 -0
  1557. package/src/lib/skill-dependencies.test.ts +39 -0
  1558. package/src/lib/skill-dependencies.ts +77 -14
  1559. package/src/lib/skill-deps.test.ts +1 -17
  1560. package/src/lib/skill-deps.ts +3 -65
  1561. package/src/lib/skill-linter.test.ts +169 -0
  1562. package/src/lib/skill-linter.ts +204 -28
  1563. package/src/lib/skill-parser.ts +197 -0
  1564. package/src/lib/skill-quality.test.ts +1 -1
  1565. package/src/lib/skill-quality.ts +4 -5
  1566. package/src/lib/skill-report.test.ts +96 -6
  1567. package/src/lib/skill-report.ts +46 -18
  1568. package/src/lib/skill-resolve-journal.test.ts +104 -0
  1569. package/src/lib/skill-resolve-journal.ts +112 -0
  1570. package/src/lib/skill-router.test.ts +7 -0
  1571. package/src/lib/skill-router.ts +3 -1
  1572. package/src/lib/skill-sandbox.ts +3 -4
  1573. package/src/lib/skill-source.ts +104 -0
  1574. package/src/lib/skill-subset.cache.test.ts +172 -0
  1575. package/src/lib/skill-subset.isolation.test.ts +108 -0
  1576. package/src/lib/skill-subset.test.ts +25 -0
  1577. package/src/lib/skill-subset.ts +215 -46
  1578. package/src/lib/skills-lock.test.ts +5 -10
  1579. package/src/lib/skills-lock.ts +2 -2
  1580. package/src/lib/skillspector.test.ts +320 -0
  1581. package/src/lib/skillspector.ts +364 -0
  1582. package/src/lib/smart-loader-suggest.hook.test.ts +244 -0
  1583. package/src/lib/stack-profiles.ts +37 -0
  1584. package/src/lib/stack-suggest.test.ts +420 -0
  1585. package/src/lib/stack-suggest.ts +586 -0
  1586. package/src/lib/star-prompt.ts +15 -14
  1587. package/src/lib/telemetry-ingest.test.ts +52 -3
  1588. package/src/lib/telemetry-ingest.ts +43 -7
  1589. package/src/lib/telemetry-redact.ts +10 -4
  1590. package/src/lib/token-budget.test.ts +141 -0
  1591. package/src/lib/token-budget.ts +187 -0
  1592. package/src/lib/tui/app.ts +23 -8
  1593. package/src/lib/tui/data.test.ts +219 -0
  1594. package/src/lib/tui/data.ts +15 -18
  1595. package/src/lib/tui/input.test.ts +159 -0
  1596. package/src/lib/tui/screen.test.ts +85 -0
  1597. package/src/lib/uvx-installer.test.ts +54 -1
  1598. package/src/lib/uvx-installer.ts +51 -6
  1599. package/src/lib/workflow-store.test.ts +292 -0
  1600. package/src/lib/workspace-secrets.test.ts +99 -0
  1601. package/src/lib/workspaces.test.ts +417 -0
  1602. package/src/lib/workspaces.ts +6 -8
  1603. package/web/README.md +97 -0
  1604. package/web/src/skill-catalog.json +23 -0
  1605. package/web/src/skill-catalog.ts +15 -0
  1606. package/bin/README.md +0 -32
  1607. package/plugins/cue/plugin.json +0 -15
  1608. package/profiles/_cache/README.md +0 -21
  1609. package/profiles/dash-merge-test/profile.yaml +0 -114
  1610. package/resources/skills/skills/browser/lightpanda/SKILL.md +0 -99
  1611. package/resources/skills/skills/design/brandkit/brandkit/SKILL.md +0 -798
  1612. package/resources/skills/skills/design/brutalist-skill/SKILL.md +0 -92
  1613. package/resources/skills/skills/design/gpt-tasteskill/SKILL.md +0 -74
  1614. package/resources/skills/skills/design/image-to-code-skill/SKILL.md +0 -1228
  1615. package/resources/skills/skills/design/imagegen-frontend-mobile/imagegen-frontend-mobile/SKILL.md +0 -1465
  1616. package/resources/skills/skills/design/imagegen-frontend-web/imagegen-frontend-web/SKILL.md +0 -987
  1617. package/resources/skills/skills/design/minimalist-skill/SKILL.md +0 -85
  1618. package/resources/skills/skills/design/output-skill/SKILL.md +0 -49
  1619. package/resources/skills/skills/design/redesign-skill/SKILL.md +0 -178
  1620. package/resources/skills/skills/design/soft-skill/SKILL.md +0 -98
  1621. package/resources/skills/skills/design/stitch-skill/DESIGN.md +0 -121
  1622. package/resources/skills/skills/design/stitch-skill/SKILL.md +0 -184
  1623. package/src/lib/incremental-materialize.test.ts +0 -112
  1624. package/src/lib/incremental-materialize.ts +0 -81
  1625. package/src/lib/lazy-mcp-wrapper.sh +0 -21
  1626. package/src/lib/skill-compressor.ts +0 -70
  1627. package/src/lib/webhooks.ts +0 -58
@@ -8,17 +8,65 @@
8
8
  */
9
9
 
10
10
  import { createHash } from "node:crypto";
11
- import { mkdir, rename, rm, symlink, writeFile, readFile, mkdtemp, readdir, lstat } from "node:fs/promises";
12
- import { dirname, join, resolve as resolvePath, basename, isAbsolute } from "node:path";
11
+ import http from "node:http";
12
+ import https from "node:https";
13
+ import {
14
+ mkdir,
15
+ rename,
16
+ rm,
17
+ symlink,
18
+ writeFile,
19
+ readFile,
20
+ mkdtemp,
21
+ readdir,
22
+ lstat,
23
+ stat,
24
+ copyFile,
25
+ cp,
26
+ readlink,
27
+ realpath,
28
+ rmdir,
29
+ unlink,
30
+ } from "node:fs/promises";
31
+ import {
32
+ dirname,
33
+ join,
34
+ resolve as resolvePath,
35
+ basename,
36
+ isAbsolute,
37
+ sep,
38
+ } from "node:path";
13
39
  import { fileURLToPath } from "node:url";
40
+ import { homedir } from "node:os";
14
41
 
15
- import type { AgentKind, ResolvedProfile } from "../../profiles/_types";
42
+ import type {
43
+ AgentKind,
44
+ CodexProfileConfig,
45
+ DeferredSkillEntry,
46
+ ResolvedProfile,
47
+ } from "../../profiles/_types";
48
+ import { buildCodexConfigToml, extractRuntimeCodexState } from "./codex-config";
49
+ import { reconcileCodexHooks } from "./codex-hooks";
50
+ import { withContextMode } from "./context-mode";
16
51
  import { normalizeUvxGitServers } from "./uvx-installer";
17
52
  import { evaluateCondition } from "./conditional-skills";
18
- import { hasWorkspaces, getActiveWorkspace, computeOverrides } from "./workspaces";
19
- import { parseSkillFromDir, renderRouter, type ParsedSkill } from "./skill-router";
20
-
21
- const REPO_ROOT = resolvePath(dirname(fileURLToPath(import.meta.url)), "..", "..");
53
+ import {
54
+ hasWorkspaces,
55
+ getActiveWorkspace,
56
+ computeOverrides,
57
+ } from "./workspaces";
58
+ import {
59
+ parseSkillFromDir,
60
+ renderRouter,
61
+ type ParsedSkill,
62
+ } from "./skill-router";
63
+ import { CODEX_BRIEF_POINTER } from "./project-brief";
64
+
65
+ const REPO_ROOT = resolvePath(
66
+ dirname(fileURLToPath(import.meta.url)),
67
+ "..",
68
+ "..",
69
+ );
22
70
  const RESOURCES_RULES = join(REPO_ROOT, "resources", "rules");
23
71
  const RESOURCES_COMMANDS = join(REPO_ROOT, "resources", "commands");
24
72
  const RESOURCES_SUBAGENTS = join(REPO_ROOT, "resources", "subagents");
@@ -29,6 +77,30 @@ const RESOURCES_PERSONAS = join(REPO_ROOT, "resources", "personas");
29
77
 
30
78
  /** Char count past which Claude Code warns about (and is slowed by) a memory file. */
31
79
  const MEMORY_FILE_WARN_CHARS = 40_000;
80
+ const RUNTIME_KEY_MAX_BYTES = 120;
81
+
82
+ /**
83
+ * Keep a logical profile/composite key usable as one filesystem component.
84
+ * Short keys stay unchanged; oversized keys retain a readable prefix plus a
85
+ * stable hash so distinct composites cannot collapse onto the same runtime.
86
+ */
87
+ export function runtimePathKey(runtimeKey: string): string {
88
+ if (Buffer.byteLength(runtimeKey, "utf8") <= RUNTIME_KEY_MAX_BYTES) {
89
+ return runtimeKey;
90
+ }
91
+
92
+ const suffix = `~${createHash("sha256").update(runtimeKey).digest("hex").slice(0, 16)}`;
93
+ const prefixBudget = RUNTIME_KEY_MAX_BYTES - Buffer.byteLength(suffix, "utf8");
94
+ let prefix = "";
95
+ let prefixBytes = 0;
96
+ for (const char of runtimeKey) {
97
+ const charBytes = Buffer.byteLength(char, "utf8");
98
+ if (prefixBytes + charBytes > prefixBudget) break;
99
+ prefix += char;
100
+ prefixBytes += charBytes;
101
+ }
102
+ return `${prefix}${suffix}`;
103
+ }
32
104
 
33
105
  function resolveResourcePath(ref: string, base: string): string {
34
106
  return isAbsolute(ref) ? ref : join(base, ref);
@@ -46,6 +118,12 @@ export interface MaterializeInput {
46
118
  profile: ResolvedProfile;
47
119
  agent: AgentKind;
48
120
  runtimeRoot: string;
121
+ /** Runtime dir key — defaults to `profile.name`. Set to `<profile>@<accountTag>`
122
+ * so two authmux parallel accounts sharing a cue profile get isolated runtimes
123
+ * (separate `.credentials.json`/`.claude.json`) instead of collapsing into one
124
+ * Anthropic login. Only the physical runtime path changes; profile identity is
125
+ * still `profile.name`. */
126
+ runtimeKey?: string;
49
127
  /** Map skill id → source dir on disk (caller resolves local/npx/plugin paths). */
50
128
  skillSourceLookup: (id: string) => Promise<string>;
51
129
  /** Pre-resolved sanitized MCP registry for this agent. */
@@ -54,6 +132,25 @@ export interface MaterializeInput {
54
132
  userClaudeMd: string;
55
133
  /** Directory to copy .credentials.json from (e.g. a pre-set CLAUDE_CONFIG_DIR). */
56
134
  credentialsSource?: string;
135
+ /** Codex only: path to the base `config.toml` (normally ~/.codex/config.toml)
136
+ * whose top-level keys, `[features]`, and `[[skills.config]]` the runtime
137
+ * config inherits. cue redirects CODEX_HOME at the runtime, so without this
138
+ * the session loses user configuration. Omit to inherit nothing (what tests do). */
139
+ codexBaseConfig?: string;
140
+ /** Codex only: user/repo skill files that bypass `$CODEX_HOME/skills` and
141
+ * must be disabled so the cue profile remains the source of truth. */
142
+ codexExternalSkillPaths?: string[];
143
+ /** Lazy-MCP: ids the launcher disabled — removed from the runtime .claude.json
144
+ * even though the rebuild preserves the old file. Profile.mcps is already
145
+ * pruned to the kept set; this just evicts the stale keys. */
146
+ disabledMcpIds?: string[];
147
+ /** Test seam for loopback proxy health; production defaults to the HTTP probe. */
148
+ proxyHealthCheck?: (url: string) => Promise<boolean>;
149
+ /** Override the path to context-mode.json. When set, `withContextMode` reads
150
+ * this path instead of `configDir()/context-mode.json`. Pass a non-existent
151
+ * path in tests to prevent the user's real installation from leaking into the
152
+ * test runtime. */
153
+ contextModePath?: string;
57
154
  }
58
155
 
59
156
  export interface MaterializeOutput {
@@ -94,8 +191,13 @@ export async function isRuntimeStale(
94
191
  profileName: string,
95
192
  agent: AgentKind,
96
193
  runtimeRoot: string,
194
+ runtimeKey: string = profileName,
97
195
  ): Promise<boolean> {
98
- const runtimeDir = join(runtimeRoot, profileName, agentSubdir(agent));
196
+ const runtimeDir = join(
197
+ runtimeRoot,
198
+ runtimePathKey(runtimeKey),
199
+ agentSubdir(agent),
200
+ );
99
201
  const hashFile = join(runtimeDir, ".cue-hash");
100
202
  let hashMtime: number;
101
203
  try {
@@ -107,10 +209,15 @@ export async function isRuntimeStale(
107
209
  // (a) Source profile.yaml newer than the hash. Its own try/catch so a missing
108
210
  // yaml doesn't short-circuit the skill check below.
109
211
  try {
110
- if ((await lstat(join(profilesDir(), profileName, "profile.yaml"))).mtimeMs > hashMtime) {
212
+ if (
213
+ (await lstat(join(profilesDir(), profileName, "profile.yaml"))).mtimeMs >
214
+ hashMtime
215
+ ) {
111
216
  return true;
112
217
  }
113
- } catch { /* no source yaml — fall through to the skill check */ }
218
+ } catch {
219
+ /* no source yaml — fall through to the skill check */
220
+ }
114
221
 
115
222
  // (b) Any resolved SKILL.md newer than the hash.
116
223
  const skillsDir = join(runtimeDir, "skills");
@@ -122,13 +229,19 @@ export async function isRuntimeStale(
122
229
  }
123
230
  for (const slug of slugs) {
124
231
  try {
125
- if ((await lstat(join(skillsDir, slug, "SKILL.md"))).mtimeMs > hashMtime) return true;
126
- } catch { /* broken symlink / no SKILL.md under this slug — skip */ }
232
+ if ((await lstat(join(skillsDir, slug, "SKILL.md"))).mtimeMs > hashMtime)
233
+ return true;
234
+ } catch {
235
+ /* broken symlink / no SKILL.md under this slug — skip */
236
+ }
127
237
  }
128
238
  return false;
129
239
  }
130
240
 
131
- function appliesToAgent(scoped: { agents?: AgentKind[] }, agent: AgentKind): boolean {
241
+ function appliesToAgent(
242
+ scoped: { agents?: AgentKind[] },
243
+ agent: AgentKind,
244
+ ): boolean {
132
245
  if (!scoped.agents || scoped.agents.length === 0) return true;
133
246
  return scoped.agents.includes(agent);
134
247
  }
@@ -138,7 +251,11 @@ function sortedJson(value: unknown): string {
138
251
  if (Array.isArray(value)) return "[" + value.map(sortedJson).join(",") + "]";
139
252
  const obj = value as Record<string, unknown>;
140
253
  const keys = Object.keys(obj).sort();
141
- return "{" + keys.map((k) => JSON.stringify(k) + ":" + sortedJson(obj[k])).join(",") + "}";
254
+ return (
255
+ "{" +
256
+ keys.map((k) => JSON.stringify(k) + ":" + sortedJson(obj[k])).join(",") +
257
+ "}"
258
+ );
142
259
  }
143
260
 
144
261
  // Bump when the on-disk runtime layout changes in a way the profile content
@@ -146,332 +263,288 @@ function sortedJson(value: unknown): string {
146
263
  // into the hash forces every profile to rebuild once on its next launch, so
147
264
  // layout fixes roll out without a manual `--rematerialize` per profile.
148
265
  // v2: flat skill layout + .cue-skills manifest (was nested <category>/<slug>)
149
- const MATERIALIZER_VERSION = 2;
150
-
151
- function computeHash(profile: ResolvedProfile, agent: AgentKind): string {
152
- const canonical = sortedJson({ v: MATERIALIZER_VERSION, agent, profile });
266
+ // v3: slimmer CLAUDE.md — drop the duplicate ~/.claude/CLAUDE.md append and
267
+ // default-off the per-session telemetry sections (#65). The generated
268
+ // content shrank but no profile field changed, so without this bump every
269
+ // already-materialized runtime would keep serving its cached 37KB file.
270
+ // v4: Codex config.toml inherits the base config's top-level keys +
271
+ // [features] (reasoning effort, context window, auto-compact). Same
272
+ // situation — generated content changed, no profile field did.
273
+ // v5: Codex profile hooks share hooks.json with installed runtime hooks.
274
+ // v6: Retain runtime approvals, track hook ownership, deduplicate instructions.
275
+ const MATERIALIZER_VERSION = 6;
276
+
277
+ function computeHash(
278
+ profile: ResolvedProfile,
279
+ agent: AgentKind,
280
+ extra = "",
281
+ ): string {
282
+ const canonical = sortedJson({
283
+ v: MATERIALIZER_VERSION,
284
+ agent,
285
+ profile,
286
+ extra,
287
+ });
153
288
  return createHash("sha256").update(canonical).digest("hex");
154
289
  }
155
290
 
156
- export async function materializeRuntime(input: MaterializeInput): Promise<MaterializeOutput> {
157
- const { profile, agent, runtimeRoot } = input;
158
- const runtimeDir = join(runtimeRoot, profile.name, agentSubdir(agent));
291
+ async function readPersonaIncludes(profile: ResolvedProfile): Promise<string> {
292
+ const refs = profile.personaIncludes ?? [];
293
+ let text = "";
294
+ const included = new Set<string>();
295
+ for (const ref of refs) {
296
+ const path = isAbsolute(ref)
297
+ ? ref
298
+ : join(RESOURCES_PERSONAS, ref.endsWith(".md") ? ref : `${ref}.md`);
299
+ try {
300
+ const content = (await readFile(path, "utf8")).trim();
301
+ if (content && !included.has(content)) {
302
+ included.add(content);
303
+ text += content + "\n\n";
304
+ }
305
+ } catch {
306
+ // Missing snippet — skip silently. cue validate checks persona_includes
307
+ // refs via checkResourceRefs and will surface missing files there.
308
+ }
309
+ }
310
+ return text;
311
+ }
159
312
 
160
- // Normalize any `uvx --from git+<repo> <bin>` MCP entries: install the
161
- // package locally with `uv tool install` and rewrite the entry to call the
162
- // installed binary. Sidesteps both the MCP-startup cold-download race and
163
- // the auto-mode classifier's "fetch arbitrary code from URL" block.
164
- // Idempotent — re-runs detect an existing binary and just rewrite.
165
- const { normalized: normalizedRegistry, report: uvxReport } =
166
- normalizeUvxGitServers(input.mcpRegistry);
167
- const effectiveInput: MaterializeInput = { ...input, mcpRegistry: normalizedRegistry };
168
- if (uvxReport.installed.length > 0) {
169
- process.stderr.write(
170
- `[cue] installed uvx MCPs: ${uvxReport.installed.join(", ")}\n`,
171
- );
313
+ function effectiveCodexOverrides(
314
+ profile: ResolvedProfile,
315
+ ): CodexProfileConfig | undefined {
316
+ const legacy = profile.codexConfig ?? {};
317
+ const current = (profile as { codex?: CodexProfileConfig }).codex ?? {};
318
+ if (Object.keys(legacy).length === 0 && Object.keys(current).length === 0) {
319
+ return undefined;
172
320
  }
321
+ const merged: Record<string, unknown> = { ...legacy, ...current };
322
+ const legacyFeatures = isRecord(legacy.features) ? legacy.features : {};
323
+ const currentFeatures = isRecord(current.features) ? current.features : {};
324
+ if (
325
+ Object.keys(legacyFeatures).length > 0 ||
326
+ Object.keys(currentFeatures).length > 0
327
+ ) {
328
+ merged.features = { ...legacyFeatures, ...currentFeatures };
329
+ }
330
+ return merged as CodexProfileConfig;
331
+ }
173
332
 
174
- const hash = computeHash(profile, agent);
333
+ function isRecord(value: unknown): value is Record<string, unknown> {
334
+ return typeof value === "object" && value !== null && !Array.isArray(value);
335
+ }
175
336
 
176
- // Collect profile MCP entries once — used by both cache-hit and rebuild paths
177
- // for the .claude.json sync.
178
- const mcpServers = collectProfileMcps(profile, agent, effectiveInput.mcpRegistry);
337
+ /**
338
+ * Whether to emit the per-session telemetry sections — `## Skill Usage`,
339
+ * `## Last Session`, `## Common Workflows` — into the materialized memory file.
340
+ *
341
+ * Default OFF. These are usage-analytics / warm-start blocks: they change every
342
+ * time analytics or the last session change, cost ~0.6KB on a heavy profile, and
343
+ * carry no triggering signal (a skill's `description` is what makes it fire, not
344
+ * a hit count). The capability table and `## Available Skills` already name every
345
+ * skill, so dropping these loses no trigger surface — only volatile noise.
346
+ *
347
+ * Opt back in with `CUE_SESSION_TELEMETRY=1|true` (mirrors the file's other
348
+ * default-off knobs like `CUE_TRIGGER_PHRASES`).
349
+ */
350
+ export function shouldIncludeSessionTelemetry(
351
+ env: Record<string, string | undefined>,
352
+ ): boolean {
353
+ return (
354
+ env.CUE_SESSION_TELEMETRY === "1" || env.CUE_SESSION_TELEMETRY === "true"
355
+ );
356
+ }
179
357
 
180
- // Short-circuit if hash matches.
181
- try {
182
- const existing = (await readFile(join(runtimeDir, ".cue-hash"), "utf8")).trim();
183
- if (existing === hash) {
184
- // Refresh state from credentialsSource even on cache hit so account
185
- // switches and newly-added source entries are reflected.
186
- if (effectiveInput.credentialsSource) {
187
- // Re-merge settings.json from current credentialsSource.
188
- if (agent === "claude-code") {
189
- const merged = await buildClaudeSettings(profile, agent, effectiveInput);
190
- await writeFile(join(runtimeDir, "settings.json"), merged + "\n");
191
- }
192
- // Re-overlay any source entries that aren't already present (e.g.
193
- // user added a new sessions/ entry, plugins/, etc.).
194
- await overlaySourceState(runtimeDir, effectiveInput.credentialsSource);
195
- // Pre-seed the plugin cache so enabled-plugin hooks find their version
196
- // dir immediately (avoids the "Plugin directory does not exist" race).
197
- await linkPluginCache(runtimeDir, effectiveInput.credentialsSource);
198
- }
199
- if (agent === "claude-code") {
200
- await syncMcpsIntoClaudeJson(runtimeDir, mcpServers);
201
- }
202
- return { runtimeDir, rebuilt: false, hash };
203
- }
204
- } catch { /* not present — fall through to build */ }
358
+ const MATERIALIZE_LOCK_STALE_MS = 600_000;
359
+ const MATERIALIZE_LOCK_WAIT_MS = 30_000;
205
360
 
206
- // Build in a sibling tmp dir, atomic-swap at the end.
361
+ async function withMaterializeLock<T>(
362
+ runtimeDir: string,
363
+ action: () => Promise<T>,
364
+ ): Promise<T> {
365
+ const lockDir = `${runtimeDir}.lock`;
366
+ const ownerFile = join(lockDir, "owner.json");
367
+ const token = `${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
368
+ const deadline = Date.now() + MATERIALIZE_LOCK_WAIT_MS;
207
369
  await mkdir(dirname(runtimeDir), { recursive: true });
208
- const tmpDir = await mkdtemp(`${runtimeDir}.tmp.`);
209
370
 
210
- // 1. Skills — missing refs are warned + skipped, not fatal. A profile that
211
- // lists 20 skills and has 1 broken ref shouldn't crash the entire launch.
212
- // `cue debug` and `cue validate` surface the broken ref clearly so the user
213
- // can fix it. Behavior matches `cue debug`'s tolerance.
214
- const skillsDir = join(tmpDir, "skills");
215
- await mkdir(skillsDir, { recursive: true });
216
- const skippedSkills: string[] = [];
217
- let attemptedSkills = 0;
218
- // Skills are linked FLAT — skills/<slug>, not skills/<category>/<slug>.
219
- // Claude Code (and Codex) only register a personal skill one level deep, by
220
- // its directory name (skills/<name>/SKILL.md → /<name>); a nested category
221
- // dir is invisible to that scan. Flattening matches `activate-profile.sh`'s
222
- // manual installer and lets every profile skill be invoked via the Skill
223
- // tool — including the slug==category cases (caveman/caveman, github/github,
224
- // colony/colony) that a nested layout can't expose. smart-loader's dedup no
225
- // longer reads the dir tree; it reads the `.cue-skills` manifest written
226
- // below, which preserves the <category>/<slug> identity.
227
- const loadedSkillIds: string[] = [];
228
- // Resolve first, link second, so slug collisions resolve by LAST-WINS: when
229
- // two skills share a slug (e.g. plan/investigate lean vs gstack/investigate
230
- // full), the later entry wins the flat /<slug> name. Skill lists merge
231
- // parent→child (core first, profile last), so last-wins = the more-specific
232
- // profile's choice overrides the inherited one — the standard override rule.
233
- // The loser is still in the manifest, so smart-loader can surface it.
234
- const slugToSrc = new Map<string, string>();
235
- const slugToId = new Map<string, string>();
236
- const overridden: string[] = [];
237
- for (const skill of profile.skills.local) {
238
- if (!appliesToAgent(skill, agent)) continue;
239
- if (skill.when && !evaluateCondition(skill.when, process.cwd())) continue;
240
- attemptedSkills++;
371
+ while (true) {
372
+ let created = false;
241
373
  try {
242
- const src = await input.skillSourceLookup(skill.id);
243
- loadedSkillIds.push(skill.id);
244
- const slug = basename(skill.id);
245
- const prevId = slugToId.get(slug);
246
- if (prevId !== undefined && prevId !== skill.id) {
247
- overridden.push(`${slug}: ${prevId} → ${skill.id}`);
374
+ await mkdir(lockDir);
375
+ created = true;
376
+ await writeFile(ownerFile, JSON.stringify({ pid: process.pid, token }));
377
+ break;
378
+ } catch (error) {
379
+ if (created) {
380
+ await rm(lockDir, { recursive: true, force: true });
381
+ throw error;
248
382
  }
249
- slugToSrc.set(slug, src);
250
- slugToId.set(slug, skill.id);
251
- } catch (err) {
252
- skippedSkills.push(skill.id);
383
+ if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
384
+ try {
385
+ const age = Date.now() - (await lstat(lockDir)).mtimeMs;
386
+ const owner = JSON.parse(await readFile(ownerFile, "utf8")) as {
387
+ pid?: number;
388
+ };
389
+ let ownerAlive = typeof owner.pid === "number";
390
+ if (ownerAlive) {
391
+ try {
392
+ process.kill(owner.pid!, 0);
393
+ } catch (probeError) {
394
+ ownerAlive = (probeError as NodeJS.ErrnoException).code === "EPERM";
395
+ }
396
+ }
397
+ if (!ownerAlive && age > 1_000) {
398
+ await rm(lockDir, { recursive: true, force: true });
399
+ continue;
400
+ }
401
+ } catch {
402
+ try {
403
+ const age = Date.now() - (await lstat(lockDir)).mtimeMs;
404
+ if (age > MATERIALIZE_LOCK_STALE_MS) {
405
+ await rm(lockDir, { recursive: true, force: true });
406
+ continue;
407
+ }
408
+ } catch {
409
+ /* lock disappeared between checks */
410
+ }
411
+ }
412
+ if (Date.now() >= deadline) {
413
+ throw new Error(
414
+ `Timed out waiting for runtime materialization lock: ${lockDir}`,
415
+ );
416
+ }
417
+ await new Promise((resolve) => setTimeout(resolve, 25));
253
418
  }
254
419
  }
255
- for (const [slug, src] of slugToSrc) {
256
- await symlink(src, join(skillsDir, slug));
257
- }
258
- if (overridden.length > 0) {
259
- process.stderr.write(
260
- `[cue] ${overridden.length} skill slug collision(s) resolved last-wins ` +
261
- `(loser still smart-loadable): ${overridden.join("; ")}\n`,
262
- );
263
- }
264
- // Manifest for smart-loader's --exclude-loaded: the resolved <category>/<slug>
265
- // ids, decoupled from the (now flat) on-disk layout.
266
- await writeFile(
267
- join(tmpDir, ".cue-skills"),
268
- loadedSkillIds.length > 0 ? `${loadedSkillIds.join("\n")}\n` : "",
269
- );
270
- if (skippedSkills.length > 0) {
271
- process.stderr.write(
272
- `[cue] skipped ${skippedSkills.length} missing skill(s): ${skippedSkills.slice(0, 5).join(", ")}` +
273
- (skippedSkills.length > 5 ? `, +${skippedSkills.length - 5} more` : "") +
274
- ` — run \`cue debug ${profile.name}\` for details\n`,
275
- );
276
- }
277
- // Fail-loud guard: a single broken ref in a 20-skill profile is tolerable
278
- // (warned above), but if MORE THAN HALF the skills failed to resolve, the
279
- // materialized runtime is broken — almost always a misconfigured skill
280
- // source root (e.g. resolveLocalSkill falling back to a stale default when
281
- // CUE_REPO_ROOT is unset). Silently writing a near-empty CLAUDE.md is worse
282
- // than crashing. Bypass with CUE_ALLOW_PARTIAL_SKILLS=1 for the rare profile
283
- // that genuinely expects most skills to be unavailable.
284
- const allowPartial =
285
- process.env.CUE_ALLOW_PARTIAL_SKILLS === "1" ||
286
- process.env.CUE_ALLOW_PARTIAL_SKILLS === "true";
287
- if (
288
- !allowPartial &&
289
- attemptedSkills > 0 &&
290
- skippedSkills.length / attemptedSkills > 0.5
291
- ) {
292
- await rm(tmpDir, { recursive: true, force: true });
293
- throw new Error(
294
- `[cue] skill resolution failed: ${skippedSkills.length}/${attemptedSkills} ` +
295
- `skill(s) for profile "${profile.name}" could not be resolved. The runtime ` +
296
- `would be broken, so the rebuild was aborted (old runtime left intact). ` +
297
- `This usually means the skill source root is wrong — check CUE_REPO_ROOT / ` +
298
- `the skillSourceLookup wiring, then run \`cue debug ${profile.name}\`. ` +
299
- `Set CUE_ALLOW_PARTIAL_SKILLS=1 to bypass.`,
300
- );
420
+
421
+ try {
422
+ return await action();
423
+ } finally {
424
+ try {
425
+ const owner = JSON.parse(await readFile(ownerFile, "utf8")) as {
426
+ token?: string;
427
+ };
428
+ if (owner.token === token)
429
+ await rm(lockDir, { recursive: true, force: true });
430
+ } catch {
431
+ /* a stale-lock recovery already replaced or removed this lock */
432
+ }
301
433
  }
434
+ }
302
435
 
303
- // Defensive defaults — older fixtures may not declare these arrays.
304
- const profileRules = profile.rules ?? [];
305
- const profileCommands = profile.commands ?? [];
306
- const profileSubagents = profile.subagents ?? [];
307
- // Effective hook list: profile-declared hooks PLUS the cue-quality-gates
308
- // Stop hook when the profile declares any qualityGates. Keeps profile
309
- // authors from having to remember to wire both `qualityGates` and the
310
- // matching hook entry — declaring gates is enough. Same dedupe + merge
311
- // logic runs again in buildClaudeSettings so the settings.json wiring
312
- // stays consistent with the symlinked files here.
313
- const profileHooks = [...(profile.hooks ?? [])];
314
- const profileGatesForAutoHook = (profile as any).qualityGates ?? [];
436
+ /**
437
+ * Return `profile.hooks` with the cue-quality-gates Stop hook auto-injected
438
+ * when the profile declares qualityGates but hasn't explicitly listed the
439
+ * hook. Centralises the invariant so both the symlink phase and
440
+ * buildClaudeSettings stay consistent without duplicating the guard.
441
+ */
442
+ function effectiveHookList(profile: ResolvedProfile, agent: AgentKind): string[] {
443
+ const hooks = [...(profile.hooks ?? [])];
315
444
  if (
316
445
  agent === "claude-code" &&
317
- profileGatesForAutoHook.length > 0 &&
318
- !profileHooks.includes("cue-quality-gates.json")
446
+ (profile.qualityGates ?? []).length > 0 &&
447
+ !hooks.includes("cue-quality-gates.json")
319
448
  ) {
320
- profileHooks.push("cue-quality-gates.json");
321
- }
322
-
323
- // 1b. Commands — symlink each <ref>.md into commands/ (Claude reads .claude/commands/*.md)
324
- if (agent === "claude-code" && profileCommands.length > 0) {
325
- const commandsDir = join(tmpDir, "commands");
326
- await mkdir(commandsDir, { recursive: true });
327
- for (const ref of profileCommands) {
328
- const src = resolveResourcePath(ref.endsWith(".md") ? ref : `${ref}.md`, RESOURCES_COMMANDS);
329
- try {
330
- await lstat(src);
331
- await symlink(src, join(commandsDir, basename(src)));
332
- } catch { /* missing source — skip */ }
333
- }
449
+ hooks.push("cue-quality-gates.json");
334
450
  }
451
+ return hooks;
452
+ }
335
453
 
336
- // 1b2. Subagents — symlink each <ref>.md FLAT into agents/ (Claude reads
337
- // .claude/agents/*.md and delegates to them via the Task tool). Refs may be
338
- // division-scoped (e.g. "design/design-ui-designer"); we flatten to the
339
- // basename since agent file-stems are already globally unique. When a profile
340
- // declares subagents, the real agents/ dir we create here causes the later
341
- // overlay step to skip the user's ~/.claude/agents passthrough (existing real
342
- // dir is left untouched) — the profile's curated set wins, by design.
343
- if (agent === "claude-code" && profileSubagents.length > 0) {
344
- const agentsDir = join(tmpDir, "agents");
345
- await mkdir(agentsDir, { recursive: true });
346
- for (const ref of profileSubagents) {
347
- const src = resolveResourcePath(ref.endsWith(".md") ? ref : `${ref}.md`, RESOURCES_SUBAGENTS);
348
- try {
349
- await lstat(src);
350
- await symlink(src, join(agentsDir, basename(src)));
351
- } catch { /* missing source — skip */ }
352
- }
454
+ // Subdirectory-scoped refs flatten to their basename, so two rules can collide
455
+ // (common/security.md and typescript/security.md). The first one wins; any other
456
+ // symlink failure is real and propagates.
457
+ export async function linkUnlessPresent(src: string, dest: string): Promise<void> {
458
+ try {
459
+ await symlink(src, dest);
460
+ } catch (e: unknown) {
461
+ if ((e as NodeJS.ErrnoException).code !== "EEXIST") throw e;
462
+ console.warn(`cue: skipped ${src}: ${basename(dest)} is already linked by an earlier ref`);
353
463
  }
464
+ }
354
465
 
355
- // 1c. Rules — symlink into rules/. Contents get appended to CLAUDE.md below.
356
- if (profileRules.length > 0) {
357
- const rulesDir = join(tmpDir, "rules");
358
- await mkdir(rulesDir, { recursive: true });
359
- for (const ref of profileRules) {
360
- const src = resolveResourcePath(ref.endsWith(".md") ? ref : `${ref}.md`, RESOURCES_RULES);
361
- try {
362
- await lstat(src);
363
- await symlink(src, join(rulesDir, basename(src)));
364
- } catch { /* missing source — skip */ }
466
+ /**
467
+ * Symlink a list of resource refs into `targetDir`, appending `ext` when the
468
+ * ref lacks it. If `companionExts` is given, each ref's companion files
469
+ * (e.g. `.sh` / `.py` next to a hook's `.json`) are symlinked too.
470
+ * An empty `refs` array is a no-op.
471
+ */
472
+ async function symlinkResources(
473
+ refs: string[],
474
+ targetDir: string,
475
+ resourceDir: string,
476
+ ext: string,
477
+ companionExts?: readonly string[],
478
+ ): Promise<void> {
479
+ if (refs.length === 0) return;
480
+ await mkdir(targetDir, { recursive: true });
481
+ for (const ref of refs) {
482
+ const fname = ext ? (ref.endsWith(ext) ? ref : `${ref}${ext}`) : ref;
483
+ const src = resolveResourcePath(fname, resourceDir);
484
+ try {
485
+ await lstat(src);
486
+ } catch (e: unknown) {
487
+ // Only skip when the source is genuinely absent; propagate everything
488
+ // else (EPERM, ENOSPC, …) so the caller gets a real error.
489
+ if ((e as NodeJS.ErrnoException).code === "ENOENT") continue;
490
+ throw e;
365
491
  }
366
- }
367
-
368
- // 1d. Hooks — symlink scripts into hooks/. settings.json wiring happens in buildClaudeSettings.
369
- // A hook ref points at a `.json` config; its referenced script (e.g. `<stem>.sh`)
370
- // lives next to it in resources/hooks/ and must be symlinked too, otherwise the
371
- // Stop/PreToolUse/etc. hook fires `bash $CLAUDE_CONFIG_DIR/hooks/<stem>.sh` and
372
- // dies with "No such file or directory".
373
- if (agent === "claude-code" && profileHooks.length > 0) {
374
- const hooksDir = join(tmpDir, "hooks");
375
- await mkdir(hooksDir, { recursive: true });
376
- for (const ref of profileHooks) {
377
- const src = resolveResourcePath(ref, RESOURCES_HOOKS);
378
- try {
379
- await lstat(src);
380
- await symlink(src, join(hooksDir, basename(src)));
381
- } catch { /* missing source — skip */ }
492
+ await linkUnlessPresent(src, join(targetDir, basename(src)));
493
+ if (companionExts) {
382
494
  const stem = basename(ref).replace(/\.[^.]+$/, "");
383
- for (const ext of [".sh", ".py", ".js", ".mjs", ".ts"]) {
384
- const companion = join(RESOURCES_HOOKS, `${stem}${ext}`);
495
+ for (const compExt of companionExts) {
496
+ const companion = resolveResourcePath(`${stem}${compExt}`, resourceDir);
385
497
  try {
386
498
  await lstat(companion);
387
- await symlink(companion, join(hooksDir, `${stem}${ext}`));
388
- } catch { /* no companion at this ext — skip */ }
499
+ } catch (e: unknown) {
500
+ if ((e as NodeJS.ErrnoException).code === "ENOENT") continue;
501
+ throw e;
502
+ }
503
+ await linkUnlessPresent(companion, join(targetDir, `${stem}${compExt}`));
389
504
  }
390
505
  }
391
506
  }
507
+ }
392
508
 
393
- // 1e. Playbooks (Phase 2) — symlink markdown protocols into playbooks/.
394
- // Indexed in CLAUDE.md so Claude knows to consult them; bodies lazy-loaded.
395
- const profilePlaybooks = (profile as any).playbooks ?? [];
396
- if (profilePlaybooks.length > 0) {
397
- const pbDir = join(tmpDir, "playbooks");
398
- await mkdir(pbDir, { recursive: true });
399
- for (const ref of profilePlaybooks) {
400
- const src = resolveResourcePath(ref.endsWith(".md") ? ref : `${ref}.md`, RESOURCES_PLAYBOOKS);
401
- try {
402
- await lstat(src);
403
- await symlink(src, join(pbDir, basename(src)));
404
- } catch { /* missing source — skip */ }
405
- }
406
- }
407
-
408
- // 1f. Quality gates (Phase 3) — symlink validator scripts into quality-gates/.
409
- // The Stop hook (cue-quality-gates.sh, see resources/hooks/) iterates this
410
- // directory and fails the session if any gate exits non-zero.
411
- // Refs in profile.yaml typically omit the `.sh` extension, so we append it
412
- // when missing — otherwise resolveResourcePath produces e.g.
413
- // `.../resources/quality-gates/lint-skill-pass` (no such file) and the
414
- // lstat fails silently, leaving the gate undeployed at Stop time.
415
- const profileGates = (profile as any).qualityGates ?? [];
416
- if (agent === "claude-code" && profileGates.length > 0) {
417
- const gDir = join(tmpDir, "quality-gates");
418
- await mkdir(gDir, { recursive: true });
419
- for (const ref of profileGates) {
420
- const fname = ref.endsWith(".sh") ? ref : `${ref}.sh`;
421
- const src = resolveResourcePath(fname, RESOURCES_QUALITY_GATES);
422
- try {
423
- await lstat(src);
424
- await symlink(src, join(gDir, basename(src)));
425
- } catch { /* missing source — skip; surfaced by `cue doctor` (D8) */ }
426
- }
427
- }
428
-
429
- // 2. settings.json (Claude) or config.toml (Codex) — Claude-only first cut.
430
- // mcpServers was already collected above (used by both code paths).
431
- if (agent === "claude-code") {
432
- const merged = await buildClaudeSettings(profile, agent, effectiveInput);
433
- await writeFile(join(tmpDir, "settings.json"), merged + "\n");
434
- } else {
435
- // Codex equivalent — write config.toml from registry. Caller pre-renders to TOML.
436
- await writeFile(join(tmpDir, "config.toml"), tomlRender({ mcp_servers: mcpServers }));
437
- }
509
+ /**
510
+ * Build and write the CLAUDE.md (or AGENTS.md) memory-file stamp for a
511
+ * materialised runtime. Extracted from the 921-line materializeRuntimeUnlocked
512
+ * to keep the orchestrator as a thin sequencer.
513
+ */
514
+ async function buildMemoryFileStamp(
515
+ tmpDir: string,
516
+ profile: ResolvedProfile,
517
+ agent: AgentKind,
518
+ input: Pick<MaterializeInput, "skillSourceLookup" | "userClaudeMd">,
519
+ personaIncludesText: string,
520
+ ): Promise<void> {
521
+ const profileRules = profile.rules ?? [];
522
+ const profileCommands = profile.commands ?? [];
523
+ const profileSubagents = profile.subagents ?? [];
438
524
 
439
- // 3. CLAUDE.md with stamp + role identity
440
525
  const iconStr = profile.icon ?? "";
441
526
  const skillsList = (profile.skills?.local ?? [])
442
- .map((s) => typeof s === "string" ? s : s.id)
527
+ .map((s) => (typeof s === "string" ? s : s.id))
443
528
  .filter((s) => !s.includes("*"));
444
- const mcpsList = (profile.mcps ?? [])
445
- .map((m) => typeof m === "string" ? m : m.id);
529
+ const mcpsList = (profile.mcps ?? []).map((m) =>
530
+ typeof m === "string" ? m : m.id,
531
+ );
446
532
 
447
- let stamp = `<!-- cue: profile=${profile.name} icon=${iconStr} -->\n` +
448
- `# Active Profile: ${iconStr ? iconStr + " " : ""}${profile.name}\n\n` +
449
- `> ${profile.description}\n\n`;
533
+ let stamp =
534
+ `<!-- cue: profile=${profile.name} icon=${iconStr} -->\n` +
535
+ `# Active Profile: ${iconStr ? iconStr + " " : ""}${profile.name}\n\n` +
536
+ `> ${profile.description}\n\n`;
450
537
 
451
538
  // Phase 1: Persona — multi-line role-priming defining who the agent IS.
452
539
  // Goes above the mechanical "Your Role" block so it primes interpretation
453
540
  // of everything that follows. Profiles without a persona keep the old
454
541
  // generic block (backwards-compatible).
455
- const profilePersona = (profile as any).persona ?? "";
542
+ const profilePersona = profile.persona ?? "";
456
543
 
457
544
  // persona_includes: shared snippets prepended to the persona. Lets
458
545
  // cross-profile policies (Integrity Protocol, voice rules) live in one
459
546
  // file in resources/personas/ and fan out via the profile chain.
460
- const personaIncludes: string[] = (profile as any).personaIncludes ?? [];
461
- let includesText = "";
462
- for (const ref of personaIncludes) {
463
- const path = isAbsolute(ref)
464
- ? ref
465
- : join(RESOURCES_PERSONAS, ref.endsWith(".md") ? ref : `${ref}.md`);
466
- try {
467
- const content = (await readFile(path, "utf8")).trim();
468
- if (content) includesText += content + "\n\n";
469
- } catch {
470
- // missing snippet — skip silently; cue validate will surface it
471
- }
472
- }
473
-
474
- const fullPersona = (includesText + profilePersona).trim();
547
+ const fullPersona = (personaIncludesText + profilePersona).trim();
475
548
  if (fullPersona) {
476
549
  stamp += `## Your Expertise\n\n${fullPersona}\n\n`;
477
550
  }
@@ -503,13 +576,30 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
503
576
  // silently vanishing.
504
577
  const fallbackName = id.split("/").pop() ?? id;
505
578
  routerParsed.push({
506
- id, name: fallbackName, triggers: [], capability: "",
507
- capabilityExplicit: false, whenToInvoke: [], notFor: "",
508
- rawDescription: "", quality: "none", missing: true,
579
+ id,
580
+ name: fallbackName,
581
+ triggers: [],
582
+ capability: "",
583
+ capabilityExplicit: false,
584
+ whenToInvoke: [],
585
+ notFor: "",
586
+ rawDescription: "",
587
+ quality: "none",
588
+ missing: true,
509
589
  });
510
590
  }
511
591
  }
512
- const routerOverrides = (profile as { personaRouting?: { phrase?: string; capability?: string; skill: string; note?: string }[] }).personaRouting ?? [];
592
+ const routerOverrides =
593
+ (
594
+ profile as {
595
+ personaRouting?: {
596
+ phrase?: string;
597
+ capability?: string;
598
+ skill: string;
599
+ note?: string;
600
+ }[];
601
+ }
602
+ ).personaRouting ?? [];
513
603
 
514
604
  // Telemetry-driven router compaction. Read the same skill-usage data that
515
605
  // `cue skill-report` shows; collapse zombies (0 hits in last 30d) into a
@@ -521,7 +611,9 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
521
611
  const { computeSkillUsage } = await import("./skill-report");
522
612
  const usage = computeSkillUsage(profile, { windowDays: 30 });
523
613
  zombieIds = usage.filter((u) => u.zombie).map((u) => u.id);
524
- } catch { /* render full router on any failure */ }
614
+ } catch {
615
+ /* render full router on any failure */
616
+ }
525
617
  const lean = process.env.CUE_LEAN === "1" || process.env.CUE_LEAN === "true";
526
618
  // Default-on: the trigger-phrases table duplicates each SKILL.md's own
527
619
  // frontmatter, and on heavy profiles it pushes the materialized CLAUDE.md
@@ -536,7 +628,8 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
536
628
  // under "Available Skills" and loadable on demand. Override with
537
629
  // CUE_MAX_CAPABILITY_ROWS (0 disables the cap).
538
630
  const maxCapEnv = Number(process.env.CUE_MAX_CAPABILITY_ROWS);
539
- const maxCapabilityRows = Number.isFinite(maxCapEnv) && maxCapEnv >= 0 ? maxCapEnv : 50;
631
+ const maxCapabilityRows =
632
+ Number.isFinite(maxCapEnv) && maxCapEnv >= 0 ? maxCapEnv : 50;
540
633
  const routerBlock = renderRouter(routerParsed, {
541
634
  overrides: routerOverrides,
542
635
  zombies: zombieIds,
@@ -547,15 +640,17 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
547
640
  if (routerBlock) stamp += routerBlock;
548
641
 
549
642
  // Role identity — tell Claude what it is
550
- stamp += `## Your Role\n\n` +
551
- `You are operating as **${profile.name}** — ${profile.description.toLowerCase()}.\n` +
552
- `Focus on tasks within this domain. Use the skills loaded in this profile.\n\n`;
643
+ stamp +=
644
+ `## Your Role\n\n` +
645
+ `You are operating as **${profile.name}** — ${profile.description.toLowerCase()}.\n` +
646
+ `Focus on tasks within this domain. Use the skills loaded in this profile.\n\n`;
553
647
 
554
648
  // Skills summary
555
649
  if (skillsList.length > 0) {
556
650
  stamp += `## Available Skills (${skillsList.length})\n\n`;
557
651
  if (skillsList.length <= 20) {
558
- stamp += skillsList.map((s) => `- \`${s.split("/").pop()}\``).join("\n") + "\n";
652
+ stamp +=
653
+ skillsList.map((s) => `- \`${s.split("/").pop()}\``).join("\n") + "\n";
559
654
  } else {
560
655
  // Group by category
561
656
  const groups = new Map<string, string[]>();
@@ -578,48 +673,65 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
578
673
  stamp += `## MCP Servers: ${mcpsList.join(", ")}\n\n`;
579
674
  }
580
675
 
581
- // Skill usage analytics — help the model prioritize frequently-used skills
582
- try {
583
- const { skillStats } = await import("./analytics");
584
- const stats = skillStats(profile.name);
585
- if (stats.length > 0) {
586
- stamp += `## Skill Usage (last 30 days)\n\n`;
587
- stamp += `Prioritize these skills — they're the ones actually used:\n`;
588
- for (const s of stats.slice(0, 8)) {
589
- stamp += `- \`${s.skill}\` (${s.hits}× used)\n`;
676
+ // Per-session telemetry sections (Skill Usage / Last Session / Common
677
+ // Workflows). Default-off: volatile usage/warm-start noise with no triggering
678
+ // value — every skill is already named in the capability table and
679
+ // "## Available Skills". Opt back in with CUE_SESSION_TELEMETRY=1. Skipping
680
+ // the block also skips the analytics/session disk reads below.
681
+ if (shouldIncludeSessionTelemetry(process.env)) {
682
+ // Skill usage analytics — help the model prioritize frequently-used skills
683
+ try {
684
+ const { skillStats } = await import("./analytics");
685
+ const stats = skillStats(profile.name);
686
+ if (stats.length > 0) {
687
+ stamp += `## Skill Usage (last 30 days)\n\n`;
688
+ stamp += `Prioritize these skills — they're the ones actually used:\n`;
689
+ for (const s of stats.slice(0, 8)) {
690
+ stamp += `- \`${s.skill}\` (${s.hits}× used)\n`;
691
+ }
692
+ stamp += "\n";
590
693
  }
591
- stamp += "\n";
694
+ } catch {
695
+ /* analytics unavailable — skip */
592
696
  }
593
- } catch { /* analytics unavailable — skip */ }
594
697
 
595
- // Profile fit monitoring — formerly a ~150-token hardcoded block; now a
596
- // skill (meta/profile-fit-monitor) loaded on demand. Net per-message cost
597
- // drops to just the skill's description line in "## Available Skills".
698
+ // Profile fit monitoring — formerly a ~150-token hardcoded block; now a
699
+ // skill (meta/profile-fit-monitor) loaded on demand. Net per-message cost
700
+ // drops to just the skill's description line in "## Available Skills".
598
701
 
599
- // #8: Warm-start context — last session summary
600
- const lastSession = await getLastSessionSummary(profile.name);
601
- if (lastSession) {
602
- stamp += `## Last Session\n\n${lastSession}\n\n`;
603
- }
702
+ // #8: Warm-start context — last session summary
703
+ const lastSession = await getLastSessionSummary(profile.name);
704
+ if (lastSession) {
705
+ stamp += `## Last Session\n\n${lastSession}\n\n`;
706
+ }
604
707
 
605
- // #9: Skill chaining hints — common workflows from usage patterns
606
- const chains = await getSkillChains(skillsList);
607
- if (chains) {
608
- stamp += `## Common Workflows\n\n${chains}\n\n`;
708
+ // #9: Skill chaining hints — common workflows from usage patterns
709
+ const chains = await getSkillChains(skillsList);
710
+ if (chains) {
711
+ stamp += `## Common Workflows\n\n${chains}\n\n`;
712
+ }
609
713
  }
610
714
 
611
715
  // Rules — index only. Symlinks live in rules/; Claude reads on demand instead
612
716
  // of paying the full token cost every turn.
613
717
  if (profileRules.length > 0) {
614
- stamp += `## Rules (${profileRules.length})\n\n` +
718
+ stamp +=
719
+ `## Rules (${profileRules.length})\n\n` +
615
720
  `Read on demand from \`rules/\`:\n` +
616
- profileRules.map((r) => `- \`rules/${basename(r.endsWith(".md") ? r : `${r}.md`)}\``).join("\n") + "\n\n";
721
+ profileRules
722
+ .map(
723
+ (r) => `- \`rules/${basename(r.endsWith(".md") ? r : `${r}.md`)}\``,
724
+ )
725
+ .join("\n") +
726
+ "\n\n";
617
727
  }
618
728
 
619
729
  // Commands — list as a quick reference
620
730
  if (profileCommands.length > 0) {
621
- stamp += `## Available Commands\n\n` +
622
- profileCommands.map((c) => `- /${basename(c, ".md")}`).join("\n") + "\n\n";
731
+ stamp +=
732
+ `## Available Commands\n\n` +
733
+ profileCommands.map((c) => `- /${basename(c, ".md")}`).join("\n") +
734
+ "\n\n";
623
735
  }
624
736
 
625
737
  // Subagents — a grouped roster of the delegatable specialists in agents/.
@@ -637,7 +749,8 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
637
749
  if (!groups.has(div)) groups.set(div, []);
638
750
  groups.get(div)!.push(stem);
639
751
  }
640
- stamp += `## Subagents (${profileSubagents.length})\n\n` +
752
+ stamp +=
753
+ `## Subagents (${profileSubagents.length})\n\n` +
641
754
  `Delegatable specialists in \`agents/\`. **Prefer handing a matching task ` +
642
755
  `to one of these via the Task tool over improvising it yourself.** Claude ` +
643
756
  `Code routes by each agent's description; this is your quick map of who's ` +
@@ -650,24 +763,41 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
650
763
 
651
764
  // Playbooks (Phase 2) — proven step-by-step protocols for common tasks.
652
765
  // Indexed only; bodies are read on demand when the matching task triggers.
653
- if (profilePlaybooks.length > 0) {
654
- stamp += `## Playbooks (${profilePlaybooks.length})\n\n` +
766
+ if ((profile.playbooks ?? []).length > 0) {
767
+ stamp +=
768
+ `## Playbooks (${profile.playbooks.length})\n\n` +
655
769
  `Read on demand from \`playbooks/\` when the user's request matches:\n` +
656
- profilePlaybooks.map((p: string) => {
657
- const stem = basename(p, ".md");
658
- return `- \`playbooks/${stem}.md\` — use when ${stem.replace(/-/g, " ")}`;
659
- }).join("\n") + "\n\n" +
770
+ profile.playbooks
771
+ .map((p: string) => {
772
+ const stem = basename(p, ".md");
773
+ return `- \`playbooks/${stem}.md\` — use when ${stem.replace(/-/g, " ")}`;
774
+ })
775
+ .join("\n") +
776
+ "\n\n" +
660
777
  `**Following a playbook beats freestyling.** If a relevant playbook exists, read it first and step through it.\n\n`;
661
778
  }
662
779
 
663
780
  // Quality gates (Phase 3) — mention so Claude knows what'll be checked at Stop.
664
- const profileGatesForStamp = (profile as any).qualityGates ?? [];
781
+ const profileGatesForStamp = profile.qualityGates ?? [];
665
782
  if (profileGatesForStamp.length > 0) {
666
- stamp += `## Quality Gates\n\nBefore claiming this session complete, these checks run at Stop:\n` +
667
- profileGatesForStamp.map((g: string) => `- \`${basename(g)}\``).join("\n") + "\n\n" +
783
+ stamp +=
784
+ `## Quality Gates\n\nBefore claiming this session complete, these checks run at Stop:\n` +
785
+ profileGatesForStamp
786
+ .map((g: string) => `- \`${basename(g)}\``)
787
+ .join("\n") +
788
+ "\n\n" +
668
789
  `Don't claim "done" if you haven't met them — they'll fail you publicly.\n\n`;
669
790
  }
670
791
 
792
+ // Codex has no `--append-system-prompt`, so the per-directory project brief
793
+ // reaches it through a file named by CUE_PROJECT_BRIEF. This pointer must stay
794
+ // STATIC: the runtime memory file is shared by every directory using this
795
+ // profile, so anything directory-specific here would leak across projects and
796
+ // churn the materialization hash. claude-code gets the brief inline instead.
797
+ if (agent === "codex") {
798
+ stamp += `## Project brief\n\n${CODEX_BRIEF_POINTER}\n\n`;
799
+ }
800
+
671
801
  stamp += `---\n*generated ${new Date().toISOString()} — do not hand-edit*\n\n`;
672
802
 
673
803
  const memoryFileContent = stamp + input.userClaudeMd;
@@ -676,16 +806,581 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
676
806
  // memory file crosses ~40k chars. Warn at materialize time — the moment the
677
807
  // file is generated — so a bloated profile is caught before the user sees
678
808
  // the runtime warning, with a pointer to the usual culprit.
679
- if (memoryFileContent.length > MEMORY_FILE_WARN_CHARS) {
809
+ if (
810
+ agent === "claude-code" &&
811
+ memoryFileContent.length > MEMORY_FILE_WARN_CHARS
812
+ ) {
680
813
  const kb = (memoryFileContent.length / 1000).toFixed(1);
681
814
  process.stderr.write(
682
815
  `[cue] ${memoryFileName} for profile "${profile.name}" is ${kb}k chars ` +
683
- `(> ${(MEMORY_FILE_WARN_CHARS / 1000).toFixed(0)}k) — large memory files slow the agent ` +
684
- `and trigger its perf warning. Trim the profile (fewer skills/rules) or the ` +
685
- `appended user instructions.\n`,
816
+ `(> ${(MEMORY_FILE_WARN_CHARS / 1000).toFixed(0)}k) — large memory files slow the agent ` +
817
+ `and trigger its perf warning. Trim the profile (fewer skills/rules) or the ` +
818
+ `appended user instructions.\n`,
819
+ );
820
+ }
821
+ await writeFile(join(tmpDir, memoryFileName), memoryFileContent);
822
+ }
823
+
824
+ /**
825
+ * Carry Codex durable thread state forward, then atomically swap the staging
826
+ * directory into the live runtime path and sync MCPs. Extracted from the
827
+ * 921-line materializeRuntimeUnlocked to keep that function as an orchestrator.
828
+ */
829
+ async function atomicSwapRuntime(
830
+ runtimeDir: string,
831
+ tmpDir: string,
832
+ agent: AgentKind,
833
+ mcpServers: Record<string, McpServerConfig>,
834
+ effectiveInput: MaterializeInput,
835
+ ): Promise<void> {
836
+ // Codex writes durable thread state directly into CODEX_HOME (sessions/,
837
+ // history.jsonl, thread-store SQLite files, writer locks, etc.). Unlike
838
+ // Claude, it has no credentialsSource overlay, so an atomic rematerialization
839
+ // must carry every non-cue-managed entry forward. Otherwise changing a
840
+ // profile while Codex is running deletes the active rollout and transcript
841
+ // persistence starts failing with "no rollout found for thread id".
842
+ if (agent === "codex") {
843
+ // Read as late as possible, before moving any durable state. An unreadable
844
+ // file must not be mistaken for a first launch.
845
+ const oldConfig = await readFile(join(runtimeDir, "config.toml"), "utf8").catch(
846
+ (error: NodeJS.ErrnoException) => {
847
+ if (error.code === "ENOENT") return "";
848
+ throw error;
849
+ },
850
+ );
851
+ let localState: string | null = null;
852
+ try {
853
+ localState = extractRuntimeCodexState(oldConfig);
854
+ } catch {
855
+ /* corrupt runtime config.toml — skip state preservation, let fresh config land */
856
+ }
857
+ if (localState) {
858
+ const configPath = join(tmpDir, "config.toml");
859
+ await writeFile(configPath, (await readFile(configPath, "utf8")) + "\n" + localState, { mode: 0o600 });
860
+ }
861
+ const managed = new Set([
862
+ ".cue-hash",
863
+ ".cue-skills",
864
+ "AGENTS.md",
865
+ "config.toml",
866
+ "playbooks",
867
+ "rules",
868
+ "skills",
869
+ ]);
870
+ let oldEntries: string[] = [];
871
+ try {
872
+ oldEntries = await readdir(runtimeDir);
873
+ } catch {
874
+ /* first build */
875
+ }
876
+ for (const name of oldEntries) {
877
+ if (managed.has(name)) continue;
878
+ const oldPath = join(runtimeDir, name);
879
+ const newPath = join(tmpDir, name);
880
+ try {
881
+ await lstat(newPath);
882
+ continue; // a freshly generated entry wins
883
+ } catch {
884
+ /* absent in the new runtime — preserve the old one */
885
+ }
886
+ try {
887
+ await rename(oldPath, newPath);
888
+ } catch {
889
+ /* best-effort per entry */
890
+ }
891
+ }
892
+ }
893
+
894
+ // 6. Atomic swap: rm -rf old, rename tmp.
895
+ //
896
+ // Preserve session/credential state from the OLD runtime so resume + auth
897
+ // survive across rematerializations:
898
+ // - .claude.json → session state, projects list, oauthAccount
899
+ // - .credentials.json → OAuth tokens (refresh + access)
900
+ // - backups/ → Claude Code's own .claude.json backup chain
901
+ // - session-env/ → environment snapshots for sessions still running
902
+ // - tasks/ → in-flight task state for sessions still running
903
+ //
904
+ // We MOVE these from the old runtime over whatever the overlay step (5)
905
+ // dropped into tmpDir — so a logged-in runtime stays logged in even when
906
+ // ~/.claude.json (the credentialsSource) is in a stale/half-logged-out
907
+ // state. Without this, an authmux account swap or a partial claude write
908
+ // to the source would propagate into every cue-materialized profile.
909
+ //
910
+ // Trade-off: to fresh-bootstrap a profile after deliberately switching
911
+ // accounts at the source, run:
912
+ // rm ~/.config/cue/runtime/<profile>/claude/.credentials.json
913
+ // rm ~/.config/cue/runtime/<profile>/claude/.claude.json
914
+ // Next launch will copy current source state.
915
+ // Account-identity guard: runtime dirs are keyed by PROFILE, so two authmux
916
+ // accounts (claude-account1 / claude-account2 with different
917
+ // CLAUDE_CONFIG_DIRs) share the same runtime. When the OLD runtime belongs
918
+ // to a different account than the current credentialsSource, resurrecting
919
+ // its .claude.json/.credentials.json would pair the old account's identity
920
+ // with the new account's tokens (or vice versa) — and the expiresAt
921
+ // comparison below is meaningless across accounts. Skip preservation
922
+ // entirely and let the overlay's source state win.
923
+ let sameAccount = true;
924
+ if (effectiveInput.credentialsSource) {
925
+ const srcUuid =
926
+ (await accountUuidAt(join(effectiveInput.credentialsSource, ".config.json"))) ??
927
+ (await accountUuidAt(join(effectiveInput.credentialsSource, ".claude.json")));
928
+ // 2.1.x keeps the identity in .config.json; older clients in .claude.json.
929
+ const oldUuid =
930
+ (await accountUuidAt(join(runtimeDir, ".config.json"))) ??
931
+ (await accountUuidAt(join(runtimeDir, ".claude.json")));
932
+ if (srcUuid && oldUuid && srcUuid !== oldUuid) sameAccount = false;
933
+ }
934
+ // `.config.json` is Claude Code 2.1.x's user config (session state, oauth
935
+ // account, mcpServers). Dropping it on a rebuild would hand a migrated client
936
+ // a runtime without its state — and the file cue syncs profile MCPs into.
937
+ //
938
+ // `projects` holds the user's session transcripts. Normally it is a symlink
939
+ // into the source config — the overlay recreates that link in tmpDir, and the
940
+ // lstat guard below skips symlinks, so the fresh link still wins. But when the
941
+ // source config has no projects/ of its own, Claude Code creates a REAL
942
+ // directory here, and the swap's `rm -rf` of the old runtime then destroys
943
+ // every transcript in it (observed 2026-09-10: a core@claude5 rebuild took 12
944
+ // sessions / ~130 MB of history with it). Transcripts are neither
945
+ // identity-bound nor regenerable, so a real directory is carried across even
946
+ // when the account changed — there is no identity to mispair.
947
+ const preserveFiles = sameAccount
948
+ ? [
949
+ ".claude.json",
950
+ ".config.json",
951
+ ".credentials.json",
952
+ "backups",
953
+ "session-env",
954
+ "tasks",
955
+ "projects",
956
+ ]
957
+ : ["projects"];
958
+ for (const name of preserveFiles) {
959
+ const oldPath = join(runtimeDir, name);
960
+ const newPath = join(tmpDir, name);
961
+ try {
962
+ const st = await lstat(oldPath);
963
+ if (!(st.isFile() || st.isDirectory())) continue;
964
+ if (name === ".credentials.json") {
965
+ // Freshness guard — fixes "logged-out after relaunch". Anthropic rotates
966
+ // the refresh token on every refresh, so only the copy with the highest
967
+ // expiresAt still holds a live refresh token. Step 5's overlay already
968
+ // placed the freshly-synced SOURCE creds in tmpDir (and
969
+ // resolveClaudeCredentialsSource healed source from the freshest sibling
970
+ // runtime first). Resurrect the OLD runtime's creds ONLY when they are
971
+ // strictly newer than source — otherwise keep source, so a rebuild can't
972
+ // drag a dead, rotated token back into the runtime. When source is
973
+ // half-logged-out its expiresAt is 0/old, so a logged-in runtime still
974
+ // wins and stays logged in (the original intent of this preserve step).
975
+ const oldExp = await credentialsExpiresAt(oldPath);
976
+ const newExp = await credentialsExpiresAt(newPath);
977
+ if (oldExp <= newExp) continue; // source as-fresh-or-fresher → keep it
978
+ }
979
+ // Remove whatever overlay put here (likely a symlink for .claude.json
980
+ // or a copy for .credentials.json) so rename can replace it cleanly.
981
+ await rm(newPath, { force: true, recursive: true });
982
+ await rename(oldPath, newPath);
983
+ } catch {
984
+ /* doesn't exist — skip */
985
+ }
986
+ }
987
+ // `rm -rf runtimeDir` followed by rename leaves the live path NONEXISTENT for
988
+ // the whole recursive delete — seconds, on a runtime carrying a plugin cache
989
+ // and a backup chain. A Claude Code session already running against this
990
+ // profile resolves ${CLAUDE_CONFIG_DIR}/hooks/*.sh through that exact path, so
991
+ // every hook firing inside the gap dies with "No such file or directory"
992
+ // (observed 2026-08-03: nine Stop hooks at once, mid-session rematerialize).
993
+ //
994
+ // Move the old tree aside instead. The live path is then unresolvable only
995
+ // between two renames, and the delete runs after the new runtime is already
996
+ // in place. `.old-*` is a SIBLING of the swap target, so it stays on the same
997
+ // filesystem (rename cannot cross devices) and one level below the runtime
998
+ // root that runtime-gc scans — it is never mistaken for a runtime entry.
999
+ const trashDir = `${runtimeDir}.old-${process.pid}-${Date.now().toString(36)}`;
1000
+ let trashed = false;
1001
+ try {
1002
+ await rename(runtimeDir, trashDir);
1003
+ trashed = true;
1004
+ } catch {
1005
+ /* no previous runtime (first materialization) — nothing to move aside */
1006
+ }
1007
+ await rename(tmpDir, runtimeDir);
1008
+ if (trashed) {
1009
+ await rm(trashDir, { recursive: true, force: true }).catch(() => {
1010
+ /* the new runtime is already live; a stale .old-* is swept below */
1011
+ });
1012
+ }
1013
+ await sweepStaleSwapDirs(runtimeDir);
1014
+
1015
+ if (agent === "claude-code") {
1016
+ await syncMcpsIntoClaudeJson(
1017
+ runtimeDir,
1018
+ mcpServers,
1019
+ effectiveInput.disabledMcpIds,
1020
+ );
1021
+ }
1022
+ }
1023
+
1024
+ /**
1025
+ * Resolve skill source dirs, create flat symlinks in `<tmpDir>/skills/`, write
1026
+ * the `.cue-skills` manifest, and enforce the >50%-failure safety guard.
1027
+ * Returns the slug→src map (for Codex config) and the deferred-skills list.
1028
+ */
1029
+ async function resolveAndLinkSkills(
1030
+ tmpDir: string,
1031
+ profile: ResolvedProfile,
1032
+ agent: AgentKind,
1033
+ input: Pick<MaterializeInput, "skillSourceLookup">,
1034
+ ): Promise<{ slugToSrc: Map<string, string>; deferredSkills: DeferredSkillEntry[] }> {
1035
+ // 1. Skills — missing refs are warned + skipped, not fatal. A profile that
1036
+ // lists 20 skills and has 1 broken ref shouldn't crash the entire launch.
1037
+ // `cue debug` and `cue validate` surface the broken ref clearly so the user
1038
+ // can fix it. Behavior matches `cue debug`'s tolerance.
1039
+ const skillsDir = join(tmpDir, "skills");
1040
+ await mkdir(skillsDir, { recursive: true });
1041
+ const skippedSkills: string[] = [];
1042
+ let attemptedSkills = 0;
1043
+ // Skills are linked FLAT — skills/<slug>, not skills/<category>/<slug>.
1044
+ // Claude Code (and Codex) only register a personal skill one level deep, by
1045
+ // its directory name (skills/<name>/SKILL.md → /<name>); a nested category
1046
+ // dir is invisible to that scan. Flattening matches `activate-profile.sh`'s
1047
+ // manual installer and lets every profile skill be invoked via the Skill
1048
+ // tool — including the slug==category cases (caveman/caveman, github/github,
1049
+ // colony/colony) that a nested layout can't expose. smart-loader's dedup no
1050
+ // longer reads the dir tree; it reads the `.cue-skills` manifest written
1051
+ // below, which preserves the <category>/<slug> identity.
1052
+ const loadedSkillIds: string[] = [];
1053
+ // Resolve first, link second, so slug collisions resolve by LAST-WINS: when
1054
+ // two skills share a slug (e.g. plan/investigate lean vs gstack/investigate
1055
+ // full), the later entry wins the flat /<slug> name. Skill lists merge
1056
+ // parent→child (core first, profile last), so last-wins = the more-specific
1057
+ // profile's choice overrides the inherited one — the standard override rule.
1058
+ // The loser is still in the manifest, so smart-loader can surface it.
1059
+ const slugToSrc = new Map<string, string>();
1060
+ const slugToId = new Map<string, string>();
1061
+ const overridden: string[] = [];
1062
+ for (const skill of profile.skills.local) {
1063
+ if (!appliesToAgent(skill, agent)) continue;
1064
+ if (skill.when && !evaluateCondition(skill.when, process.cwd())) continue;
1065
+ attemptedSkills++;
1066
+ try {
1067
+ const src = await input.skillSourceLookup(skill.id);
1068
+ loadedSkillIds.push(skill.id);
1069
+ const slug = basename(skill.id);
1070
+ const prevId = slugToId.get(slug);
1071
+ if (prevId !== undefined && prevId !== skill.id) {
1072
+ overridden.push(`${slug}: ${prevId} → ${skill.id}`);
1073
+ }
1074
+ slugToSrc.set(slug, src);
1075
+ slugToId.set(slug, skill.id);
1076
+ } catch {
1077
+ skippedSkills.push(skill.id);
1078
+ }
1079
+ }
1080
+ for (const [slug, src] of slugToSrc) {
1081
+ await symlink(src, join(skillsDir, slug));
1082
+ }
1083
+ // Project-loadout deferred index: one generated (written, not symlinked)
1084
+ // skill standing in for every skill the loadout deferred. Costs a single
1085
+ // frontmatter line always-on; the agent invokes it to discover and Read a
1086
+ // deferred skill's real SKILL.md. Present in the content hash via
1087
+ // profile.deferredSkills, so loadout changes rebuild this file.
1088
+ const deferredSkills = profile.deferredSkills ?? [];
1089
+ if (deferredSkills.length > 0) {
1090
+ const { DEFERRED_INDEX_SLUG, generateDeferredIndexSkill } =
1091
+ await import("./lazy-skills");
1092
+ const indexDir = join(skillsDir, DEFERRED_INDEX_SLUG);
1093
+ await mkdir(indexDir, { recursive: true });
1094
+ await writeFile(
1095
+ join(indexDir, "SKILL.md"),
1096
+ generateDeferredIndexSkill(deferredSkills),
1097
+ );
1098
+ }
1099
+ if (overridden.length > 0) {
1100
+ process.stderr.write(
1101
+ `[cue] ${overridden.length} skill slug collision(s) resolved last-wins ` +
1102
+ `(loser still smart-loadable): ${overridden.join("; ")}\n`,
1103
+ );
1104
+ }
1105
+ // Manifest for smart-loader's --exclude-loaded: the resolved <category>/<slug>
1106
+ // ids, decoupled from the (now flat) on-disk layout.
1107
+ await writeFile(
1108
+ join(tmpDir, ".cue-skills"),
1109
+ loadedSkillIds.length > 0 ? `${loadedSkillIds.join("\n")}\n` : "",
1110
+ );
1111
+ if (skippedSkills.length > 0) {
1112
+ process.stderr.write(
1113
+ `[cue] skipped ${skippedSkills.length} missing skill(s): ${skippedSkills.slice(0, 5).join(", ")}` +
1114
+ (skippedSkills.length > 5
1115
+ ? `, +${skippedSkills.length - 5} more`
1116
+ : "") +
1117
+ ` — run \`cue debug ${profile.name}\` for details\n`,
1118
+ );
1119
+ }
1120
+ // Fail-loud guard: a single broken ref in a 20-skill profile is tolerable
1121
+ // (warned above), but if MORE THAN HALF the skills failed to resolve, the
1122
+ // materialized runtime is broken — almost always a misconfigured skill
1123
+ // source root (e.g. resolveLocalSkill falling back to a stale default when
1124
+ // CUE_REPO_ROOT is unset). Silently writing a near-empty CLAUDE.md is worse
1125
+ // than crashing. Bypass with CUE_ALLOW_PARTIAL_SKILLS=1 for the rare profile
1126
+ // that genuinely expects most skills to be unavailable.
1127
+ const allowPartial =
1128
+ process.env.CUE_ALLOW_PARTIAL_SKILLS === "1" ||
1129
+ process.env.CUE_ALLOW_PARTIAL_SKILLS === "true";
1130
+ if (
1131
+ !allowPartial &&
1132
+ attemptedSkills > 0 &&
1133
+ skippedSkills.length / attemptedSkills > 0.5
1134
+ ) {
1135
+ await rm(tmpDir, { recursive: true, force: true });
1136
+ throw new Error(
1137
+ `[cue] skill resolution failed: ${skippedSkills.length}/${attemptedSkills} ` +
1138
+ `skill(s) for profile "${profile.name}" could not be resolved. The runtime ` +
1139
+ `would be broken, so the rebuild was aborted (old runtime left intact). ` +
1140
+ `This usually means the skill source root is wrong — check CUE_REPO_ROOT / ` +
1141
+ `the skillSourceLookup wiring, then run \`cue debug ${profile.name}\`. ` +
1142
+ `Set CUE_ALLOW_PARTIAL_SKILLS=1 to bypass.`,
1143
+ );
1144
+ }
1145
+ return { slugToSrc, deferredSkills };
1146
+ }
1147
+
1148
+ export async function materializeRuntime(
1149
+ input: MaterializeInput,
1150
+ ): Promise<MaterializeOutput> {
1151
+ input = await withContextMode(input, input.contextModePath);
1152
+ const runtimeDir = join(
1153
+ input.runtimeRoot,
1154
+ runtimePathKey(input.runtimeKey ?? input.profile.name),
1155
+ agentSubdir(input.agent),
1156
+ );
1157
+ return withMaterializeLock(runtimeDir, () =>
1158
+ materializeRuntimeUnlocked(input),
1159
+ );
1160
+ }
1161
+
1162
+ async function materializeRuntimeUnlocked(
1163
+ input: MaterializeInput,
1164
+ ): Promise<MaterializeOutput> {
1165
+ const { profile, agent, runtimeRoot } = input;
1166
+ const runtimeDir = join(
1167
+ runtimeRoot,
1168
+ runtimePathKey(input.runtimeKey ?? profile.name),
1169
+ agentSubdir(agent),
1170
+ );
1171
+ const plugins = agent === "claude-code" &&
1172
+ (!input.credentialsSource || !sameResolvedPath(runtimeDir, input.credentialsSource))
1173
+ ? await inspectRuntimePlugins(runtimeDir, input.credentialsSource)
1174
+ : undefined;
1175
+
1176
+ // Normalize any `uvx --from git+<repo> <bin>` MCP entries: install the
1177
+ // package locally with `uv tool install` and rewrite the entry to call the
1178
+ // installed binary. Sidesteps both the MCP-startup cold-download race and
1179
+ // the auto-mode classifier's "fetch arbitrary code from URL" block.
1180
+ // Idempotent — re-runs detect an existing binary and just rewrite.
1181
+ const { normalized: normalizedRegistry, report: uvxReport } =
1182
+ normalizeUvxGitServers(input.mcpRegistry);
1183
+ const effectiveInput: MaterializeInput = {
1184
+ ...input,
1185
+ mcpRegistry: normalizedRegistry,
1186
+ };
1187
+ if (uvxReport.installed.length > 0) {
1188
+ process.stderr.write(
1189
+ `[cue] installed uvx MCPs: ${uvxReport.installed.join(", ")}\n`,
1190
+ );
1191
+ }
1192
+
1193
+ // The base Codex config is part of this runtime's content, so it belongs in
1194
+ // the hash: edit ~/.codex/config.toml and the next launch must rebuild rather
1195
+ // than keep serving a config.toml with the previous knobs.
1196
+ const codexBaseText =
1197
+ agent === "codex" && effectiveInput.codexBaseConfig
1198
+ ? await readFile(effectiveInput.codexBaseConfig, "utf8").catch(() => "")
1199
+ : "";
1200
+ const codexSkillScopeText =
1201
+ agent === "codex" && effectiveInput.codexExternalSkillPaths
1202
+ ? JSON.stringify([...effectiveInput.codexExternalSkillPaths].sort())
1203
+ : "";
1204
+ // Collect profile MCP entries once. Codex embeds these in config.toml, so the
1205
+ // effective registry must participate in its runtime hash: installing or
1206
+ // removing a command must rebuild the file instead of retaining stale MCPs.
1207
+ const mcpServers = collectProfileMcps(
1208
+ profile,
1209
+ agent,
1210
+ effectiveInput.mcpRegistry,
1211
+ );
1212
+ const codexMcpText = agent === "codex" ? sortedJson(mcpServers) : "";
1213
+ // Included persona bodies are generated into CLAUDE.md / AGENTS.md, so their
1214
+ // source text must participate in the content hash. Otherwise editing a
1215
+ // shared policy leaves already-materialized runtimes stale indefinitely.
1216
+ const personaIncludesText = await readPersonaIncludes(profile);
1217
+ const hash = computeHash(
1218
+ profile,
1219
+ agent,
1220
+ `${codexBaseText}\n${codexSkillScopeText}\n${codexMcpText}\n${personaIncludesText}`,
1221
+ );
1222
+
1223
+ // Short-circuit if hash matches.
1224
+ try {
1225
+ const existing = (
1226
+ await readFile(join(runtimeDir, ".cue-hash"), "utf8")
1227
+ ).trim();
1228
+ if (existing === hash) {
1229
+ // Refresh state from credentialsSource even on cache hit so account
1230
+ // switches and newly-added source entries are reflected.
1231
+ if (effectiveInput.credentialsSource) {
1232
+ // Re-merge settings.json from current credentialsSource.
1233
+ if (agent === "claude-code") {
1234
+ const merged = await buildClaudeSettings(
1235
+ profile,
1236
+ agent,
1237
+ effectiveInput,
1238
+ runtimeDir,
1239
+ mcpServers,
1240
+ );
1241
+ await writeFile(join(runtimeDir, "settings.json"), merged + "\n");
1242
+ }
1243
+ // Re-overlay any source entries that aren't already present (e.g.
1244
+ // user added a new sessions/ entry, plugins/, etc.).
1245
+ await overlaySourceState(runtimeDir, effectiveInput.credentialsSource);
1246
+ // Pre-seed the plugin cache so enabled-plugin hooks find their version
1247
+ // dir immediately (avoids the "Plugin directory does not exist" race).
1248
+ if (!sameResolvedPath(runtimeDir, effectiveInput.credentialsSource)) {
1249
+ if (plugins) await refreshPlugins(plugins);
1250
+ else await seedPluginLinks(runtimeDir, effectiveInput.credentialsSource);
1251
+ }
1252
+ }
1253
+ if (agent === "claude-code") {
1254
+ await syncMcpsIntoClaudeJson(
1255
+ runtimeDir,
1256
+ mcpServers,
1257
+ effectiveInput.disabledMcpIds,
1258
+ );
1259
+ }
1260
+ return { runtimeDir, rebuilt: false, hash };
1261
+ }
1262
+ } catch {
1263
+ /* not present — fall through to build */
1264
+ }
1265
+
1266
+ // Build in a sibling tmp dir, atomic-swap at the end.
1267
+ await mkdir(dirname(runtimeDir), { recursive: true });
1268
+ const tmpDir = await mkdtemp(`${runtimeDir}.tmp.`);
1269
+
1270
+ // 1. Skills — resolve, link flat, write .cue-skills manifest, enforce guard.
1271
+ const { slugToSrc, deferredSkills } = await resolveAndLinkSkills(tmpDir, profile, agent, input);
1272
+
1273
+ // Defensive defaults — older fixtures may not declare these arrays.
1274
+ const profileRules = profile.rules ?? [];
1275
+ const profileCommands = profile.commands ?? [];
1276
+ const profileSubagents = profile.subagents ?? [];
1277
+ // Effective hook list: profile-declared hooks PLUS the cue-quality-gates
1278
+ // Stop hook when the profile declares any qualityGates. Shared helper
1279
+ // effectiveHookList() enforces the same invariant in buildClaudeSettings
1280
+ // so the symlinked files and settings.json wiring stay consistent.
1281
+ const profileHooks = effectiveHookList(profile, agent);
1282
+
1283
+ // 1b. Commands — symlink each <ref>.md into commands/ (Claude reads .claude/commands/*.md)
1284
+ // 1b. Commands — symlink each <ref>.md into commands/ (Claude reads .claude/commands/*.md)
1285
+ if (agent === "claude-code") {
1286
+ await symlinkResources(profileCommands, join(tmpDir, "commands"), RESOURCES_COMMANDS, ".md");
1287
+ }
1288
+
1289
+ // 1b2. Subagents — symlink each <ref>.md FLAT into agents/ (Claude reads
1290
+ // .claude/agents/*.md and delegates to them via the Task tool). Refs may be
1291
+ // division-scoped (e.g. "design/design-ui-designer"); we flatten to the
1292
+ // basename since agent file-stems are already globally unique. When a profile
1293
+ // declares subagents, the real agents/ dir we create here causes the later
1294
+ // overlay step to skip the user's ~/.claude/agents passthrough (existing real
1295
+ // dir is left untouched) — the profile's curated set wins, by design.
1296
+ if (agent === "claude-code") {
1297
+ await symlinkResources(profileSubagents, join(tmpDir, "agents"), RESOURCES_SUBAGENTS, ".md");
1298
+ }
1299
+
1300
+ // 1c. Rules — symlink into rules/. Contents get appended to CLAUDE.md below.
1301
+ await symlinkResources(profileRules, join(tmpDir, "rules"), RESOURCES_RULES, ".md");
1302
+
1303
+ // 1d. Hooks — symlink scripts into hooks/. settings.json wiring happens in buildClaudeSettings.
1304
+ // A hook ref points at a `.json` config; its referenced script (e.g. `<stem>.sh`)
1305
+ // lives next to it in resources/hooks/ and must be symlinked too, otherwise the
1306
+ // Stop/PreToolUse/etc. hook fires `bash $CLAUDE_CONFIG_DIR/hooks/<stem>.sh` and
1307
+ // dies with "No such file or directory".
1308
+ if (agent === "claude-code") {
1309
+ await symlinkResources(
1310
+ profileHooks,
1311
+ join(tmpDir, "hooks"),
1312
+ RESOURCES_HOOKS,
1313
+ "",
1314
+ [".sh", ".py", ".js", ".mjs", ".ts"],
686
1315
  );
687
1316
  }
688
- await writeFile(join(tmpDir, memoryFileName), memoryFileContent);
1317
+
1318
+ // 1e. Playbooks (Phase 2) — symlink markdown protocols into playbooks/.
1319
+ // Indexed in CLAUDE.md so Claude knows to consult them; bodies lazy-loaded.
1320
+ await symlinkResources(profile.playbooks ?? [], join(tmpDir, "playbooks"), RESOURCES_PLAYBOOKS, ".md");
1321
+
1322
+ // 1f. Quality gates (Phase 3) — symlink validator scripts into quality-gates/.
1323
+ // The Stop hook (cue-quality-gates.sh, see resources/hooks/) iterates this
1324
+ // directory and fails the session if any gate exits non-zero.
1325
+ // Refs in profile.yaml typically omit the `.sh` extension, so we append it
1326
+ // when missing — otherwise resolveResourcePath produces e.g.
1327
+ // `.../resources/quality-gates/lint-skill-pass` (no such file) and the
1328
+ // lstat fails silently, leaving the gate undeployed at Stop time.
1329
+ if (agent === "claude-code") {
1330
+ await symlinkResources(profile.qualityGates ?? [], join(tmpDir, "quality-gates"), RESOURCES_QUALITY_GATES, ".sh");
1331
+ }
1332
+
1333
+ // 2. settings.json (Claude) or config.toml (Codex) — Claude-only first cut.
1334
+ // mcpServers was already collected above (used by both code paths).
1335
+ if (agent === "claude-code") {
1336
+ const merged = await buildClaudeSettings(
1337
+ profile,
1338
+ agent,
1339
+ effectiveInput,
1340
+ runtimeDir,
1341
+ mcpServers,
1342
+ );
1343
+ await writeFile(join(tmpDir, "settings.json"), merged + "\n");
1344
+ } else {
1345
+ // Codex equivalent — config.toml. cue points CODEX_HOME at this runtime, so
1346
+ // this file is the ONLY config the session reads: it has to carry the base
1347
+ // config's autonomy knobs (reasoning effort, context window, auto-compact,
1348
+ // [features]) and its skill overrides or the session silently diverges from
1349
+ // the user's canonical Codex setup.
1350
+ const overrides = effectiveCodexOverrides(profile) ?? {};
1351
+ let config = buildCodexConfigToml({
1352
+ baseText: codexBaseText,
1353
+ overrides,
1354
+ mcpServers,
1355
+ disabledSkillPaths: effectiveInput.codexExternalSkillPaths,
1356
+ enabledSkillPaths: [
1357
+ ...slugToSrc.keys(),
1358
+ ...(deferredSkills.length > 0 ? ["cue-deferred-skills"] : []),
1359
+ ].map((slug) => join(runtimeDir, "skills", slug, "SKILL.md")),
1360
+ });
1361
+ const readOptional = (name: string) => readFile(join(runtimeDir, name), "utf8").catch(
1362
+ (error: NodeJS.ErrnoException) => {
1363
+ if (error.code === "ENOENT") return undefined;
1364
+ throw error;
1365
+ },
1366
+ );
1367
+ const ownedRaw = await readOptional(".cue-hooks.json");
1368
+ if (overrides.hooks || ownedRaw !== undefined) {
1369
+ const { document, owned } = reconcileCodexHooks(await readOptional("hooks.json"), ownedRaw, overrides.hooks);
1370
+ await writeFile(
1371
+ join(tmpDir, "hooks.json"),
1372
+ JSON.stringify(document, null, 2) + "\n",
1373
+ { mode: 0o600 },
1374
+ );
1375
+ await writeFile(join(tmpDir, ".cue-hooks.json"), JSON.stringify(owned, null, 2) + "\n", { mode: 0o600 });
1376
+ // The builder emits profile overrides as single-line top-level values.
1377
+ config = config.replace(/^hooks = .*\n/m, "");
1378
+ }
1379
+ await writeFile(join(tmpDir, "config.toml"), config);
1380
+ }
1381
+
1382
+ // 3. CLAUDE.md with stamp + role identity
1383
+ await buildMemoryFileStamp(tmpDir, profile, agent, input, personaIncludesText);
689
1384
 
690
1385
  // 4. hash (no trailing newline so /^[a-f0-9]{64}$/ matches directly)
691
1386
  await writeFile(join(tmpDir, ".cue-hash"), hash);
@@ -697,84 +1392,51 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
697
1392
  // perspective, while still letting cue override skills/, settings.json,
698
1393
  // and CLAUDE.md.
699
1394
  if (input.credentialsSource) {
700
- await overlaySourceState(tmpDir, input.credentialsSource);
701
- // Pre-seed the plugin cache + marketplace metadata from the real config so
702
- // enabled-plugin hooks find their version dir on the first prompt instead
703
- // of racing Claude's lazy per-config-dir download.
704
- await linkPluginCache(tmpDir, input.credentialsSource);
705
- }
706
-
707
- // 6. Atomic swap: rm -rf old, rename tmp.
708
- //
709
- // Preserve session/credential state from the OLD runtime so resume + auth
710
- // survive across rematerializations:
711
- // - .claude.json → session state, projects list, oauthAccount
712
- // - .credentials.json → OAuth tokens (refresh + access)
713
- // - backups/ → Claude Code's own .claude.json backup chain
714
- //
715
- // We MOVE these from the old runtime over whatever the overlay step (5)
716
- // dropped into tmpDir — so a logged-in runtime stays logged in even when
717
- // ~/.claude.json (the credentialsSource) is in a stale/half-logged-out
718
- // state. Without this, an authmux account swap or a partial claude write
719
- // to the source would propagate into every cue-materialized profile.
720
- //
721
- // Trade-off: to fresh-bootstrap a profile after deliberately switching
722
- // accounts at the source, run:
723
- // rm ~/.config/cue/runtime/<profile>/claude/.credentials.json
724
- // rm ~/.config/cue/runtime/<profile>/claude/.claude.json
725
- // Next launch will copy current source state.
726
- // Account-identity guard: runtime dirs are keyed by PROFILE, so two authmux
727
- // accounts (claude-account1 / claude-account2 with different
728
- // CLAUDE_CONFIG_DIRs) share the same runtime. When the OLD runtime belongs
729
- // to a different account than the current credentialsSource, resurrecting
730
- // its .claude.json/.credentials.json would pair the old account's identity
731
- // with the new account's tokens (or vice versa) — and the expiresAt
732
- // comparison below is meaningless across accounts. Skip preservation
733
- // entirely and let the overlay's source state win.
734
- let sameAccount = true;
735
- if (input.credentialsSource) {
736
- const srcUuid = await accountUuidAt(join(input.credentialsSource, ".claude.json"));
737
- const oldUuid = await accountUuidAt(join(runtimeDir, ".claude.json"));
738
- if (srcUuid && oldUuid && srcUuid !== oldUuid) sameAccount = false;
1395
+ await overlaySourceState(tmpDir, input.credentialsSource, runtimeDir);
1396
+ // Pre-seed plugins before activation so enabled hooks can resolve immediately.
1397
+ if (!plugins && !sameResolvedPath(runtimeDir, input.credentialsSource)) {
1398
+ await seedPluginLinks(tmpDir, input.credentialsSource);
1399
+ }
739
1400
  }
740
- const preserveFiles = sameAccount ? [".claude.json", ".credentials.json", "backups"] : [];
741
- for (const name of preserveFiles) {
742
- const oldPath = join(runtimeDir, name);
743
- const newPath = join(tmpDir, name);
1401
+ if (plugins) {
744
1402
  try {
745
- const st = await lstat(oldPath);
746
- if (!(st.isFile() || st.isDirectory())) continue;
747
- if (name === ".credentials.json") {
748
- // Freshness guard — fixes "logged-out after relaunch". Anthropic rotates
749
- // the refresh token on every refresh, so only the copy with the highest
750
- // expiresAt still holds a live refresh token. Step 5's overlay already
751
- // placed the freshly-synced SOURCE creds in tmpDir (and
752
- // resolveClaudeCredentialsSource healed source from the freshest sibling
753
- // runtime first). Resurrect the OLD runtime's creds ONLY when they are
754
- // strictly newer than source — otherwise keep source, so a rebuild can't
755
- // drag a dead, rotated token back into the runtime. When source is
756
- // half-logged-out its expiresAt is 0/old, so a logged-in runtime still
757
- // wins and stays logged in (the original intent of this preserve step).
758
- const oldExp = await credentialsExpiresAt(oldPath);
759
- const newExp = await credentialsExpiresAt(newPath);
760
- if (oldExp <= newExp) continue; // source as-fresh-or-fresher → keep it
761
- }
762
- // Remove whatever overlay put here (likely a symlink for .claude.json
763
- // or a copy for .credentials.json) so rename can replace it cleanly.
764
- await rm(newPath, { force: true, recursive: true });
765
- await rename(oldPath, newPath);
766
- } catch { /* doesn't exist — skip */ }
1403
+ await stageRuntimePlugins(plugins, tmpDir);
1404
+ } catch (error) {
1405
+ await rm(tmpDir, { recursive: true, force: true }).catch(() => {});
1406
+ throw error;
1407
+ }
767
1408
  }
768
- await rm(runtimeDir, { recursive: true, force: true });
769
- await rename(tmpDir, runtimeDir);
770
1409
 
771
- if (agent === "claude-code") {
772
- await syncMcpsIntoClaudeJson(runtimeDir, mcpServers);
773
- }
1410
+ // Codex durable state preservation + 6. Atomic swap + post-swap MCP sync
1411
+ await atomicSwapRuntime(runtimeDir, tmpDir, agent, mcpServers, effectiveInput);
774
1412
 
775
1413
  return { runtimeDir, rebuilt: true, hash };
776
1414
  }
777
1415
 
1416
+ /**
1417
+ * Delete `<runtimeDir>.old-*` leftovers from an earlier swap that was killed
1418
+ * between the two renames. Best-effort and never fatal: the runtime it belongs
1419
+ * to is already live, so a leftover only wastes disk.
1420
+ */
1421
+ async function sweepStaleSwapDirs(runtimeDir: string): Promise<void> {
1422
+ const parent = dirname(runtimeDir);
1423
+ const prefix = `${basename(runtimeDir)}.old-`;
1424
+ try {
1425
+ const names = await readdir(parent);
1426
+ await Promise.all(
1427
+ names
1428
+ .filter((name) => name.startsWith(prefix))
1429
+ .map((name) =>
1430
+ rm(join(parent, name), { recursive: true, force: true }).catch(
1431
+ () => {},
1432
+ ),
1433
+ ),
1434
+ );
1435
+ } catch {
1436
+ /* parent unreadable — nothing to sweep */
1437
+ }
1438
+ }
1439
+
778
1440
  /**
779
1441
  * Read `claudeAiOauth.expiresAt` (ms epoch) from a `.credentials.json`. Returns
780
1442
  * 0 when the file is missing, unparseable, or carries no expiry — so anything
@@ -783,7 +1445,9 @@ export async function materializeRuntime(input: MaterializeInput): Promise<Mater
783
1445
  async function credentialsExpiresAt(path: string): Promise<number> {
784
1446
  try {
785
1447
  const raw = await readFile(path, "utf8");
786
- const parsed = JSON.parse(raw) as { claudeAiOauth?: { expiresAt?: number } };
1448
+ const parsed = JSON.parse(raw) as {
1449
+ claudeAiOauth?: { expiresAt?: number };
1450
+ };
787
1451
  const exp = parsed?.claudeAiOauth?.expiresAt;
788
1452
  return typeof exp === "number" ? exp : 0;
789
1453
  } catch {
@@ -802,7 +1466,9 @@ async function credentialsExpiresAt(path: string): Promise<number> {
802
1466
  async function accountUuidAt(path: string): Promise<string | undefined> {
803
1467
  try {
804
1468
  const raw = await readFile(path, "utf8");
805
- const parsed = JSON.parse(raw) as { oauthAccount?: { accountUuid?: string } };
1469
+ const parsed = JSON.parse(raw) as {
1470
+ oauthAccount?: { accountUuid?: string };
1471
+ };
806
1472
  return parsed?.oauthAccount?.accountUuid;
807
1473
  } catch {
808
1474
  return undefined;
@@ -817,39 +1483,128 @@ function collectProfileMcps(
817
1483
  const out: Record<string, McpServerConfig> = {};
818
1484
  for (const m of profile.mcps) {
819
1485
  if (!appliesToAgent(m, agent)) continue;
1486
+ // cwd/env gate — a `when:`-conditioned server only activates when its
1487
+ // condition holds, so gated MCPs cost zero schema tokens elsewhere.
1488
+ // Mirrors the conditional-skill guard above.
1489
+ if (m.when && !evaluateCondition(m.when, process.cwd())) continue;
820
1490
  const reg = registry[m.id];
821
1491
  if (reg !== undefined) out[m.id] = reg;
822
1492
  }
823
1493
  return out;
824
1494
  }
825
1495
 
826
- // Claude Code reads MCP server definitions from .claude.json's top-level
1496
+ // Merge the profile's MCPs over whatever a Claude user-config file already
1497
+ // declares. Lazy-MCP removal: the rebuild preserves the OLD runtime's config
1498
+ // (session/auth state) and we merge additively onto it — so an MCP the user
1499
+ // disabled would otherwise linger across launches. Delete exactly the ids the
1500
+ // launcher disabled (case-insensitive), and only those, so user-added MCPs are
1501
+ // never touched.
1502
+ function mergeMcpServers(
1503
+ existing: Record<string, unknown>,
1504
+ mcpServers: Record<string, McpServerConfig>,
1505
+ disabledIds: string[],
1506
+ ): Record<string, unknown> {
1507
+ const merged: Record<string, unknown> = { ...existing, ...mcpServers };
1508
+ if (disabledIds.length > 0) {
1509
+ const drop = new Set(disabledIds.map((id) => id.toLowerCase()));
1510
+ // Never evict a key that's part of the current (kept) set — a kept MCP can't
1511
+ // also be disabled. Keeps removal strictly to dropped ids.
1512
+ const kept = new Set(Object.keys(mcpServers).map((k) => k.toLowerCase()));
1513
+ for (const key of Object.keys(merged)) {
1514
+ const lower = key.toLowerCase();
1515
+ if (drop.has(lower) && !kept.has(lower)) delete merged[key];
1516
+ }
1517
+ }
1518
+ return merged;
1519
+ }
1520
+
1521
+ // Claude Code reads MCP server definitions from its user config's top-level
827
1522
  // `mcpServers` field, not from settings.json. Without this sync, profile MCPs
828
1523
  // declared in profile.yaml never get started.
829
1524
  //
1525
+ // Two files, because Claude Code moved: up to 2.0 the user config was
1526
+ // `.claude.json`; since 2.1.x it is `.config.json` in the same directory, and
1527
+ // when THAT file exists Claude ignores `.claude.json` entirely — `mcpServers`
1528
+ // included. Syncing only the legacy file therefore silently starts zero
1529
+ // profile MCPs on a migrated runtime (codegraph / context7 / ego-browser were
1530
+ // all missing from every session, 2026-09-11). `.claude.json` is still written
1531
+ // for pre-2.1 clients and for cue's own readers (`readRuntimeMcpServerIds`).
1532
+ //
830
1533
  // We dereference any symlink first and write a real file in its place so
831
1534
  // per-profile MCP additions don't leak back into a shared account-level
832
1535
  // .claude.json (e.g. multiple cue profiles backed by the same account file).
833
1536
  async function syncMcpsIntoClaudeJson(
834
1537
  runtimeDir: string,
835
1538
  mcpServers: Record<string, McpServerConfig>,
1539
+ disabledIds: string[] = [],
836
1540
  ): Promise<void> {
837
1541
  const target = join(runtimeDir, ".claude.json");
838
1542
  let parsed: Record<string, unknown> = {};
839
1543
  try {
840
1544
  const raw = await readFile(target, "utf8"); // follows symlink
841
1545
  parsed = JSON.parse(raw);
842
- } catch {
843
- // missing or unreadable — start with an empty doc; claude will fill the
844
- // rest on next startup. If the file isn't valid JSON we'd lose state, but
845
- // claude itself would also fail to read it, so a clean rewrite is fine.
1546
+ } catch (err) {
1547
+ // A missing file (ENOENT) or invalid JSON is fine to start fresh from —
1548
+ // claude would also fail to read a corrupt file, so a clean rewrite loses
1549
+ // nothing. But a TRANSIENT read error (EMFILE/EACCES on an existing, valid
1550
+ // file) must NOT trigger a stub rewrite that wipes session/auth state — bail
1551
+ // and leave .claude.json untouched this launch.
1552
+ const code = (err as NodeJS.ErrnoException)?.code;
1553
+ if (code !== undefined && code !== "ENOENT") return;
846
1554
  }
847
- const existing = (parsed.mcpServers as Record<string, unknown> | undefined) ?? {};
848
- parsed.mcpServers = { ...existing, ...mcpServers };
1555
+ const existing =
1556
+ (parsed.mcpServers as Record<string, unknown> | undefined) ?? {};
1557
+ parsed.mcpServers = mergeMcpServers(existing, mcpServers, disabledIds);
849
1558
 
850
1559
  // Replace whatever's there (symlink or stale file) with a real file copy.
851
1560
  await rm(target, { force: true });
852
1561
  await writeFile(target, JSON.stringify(parsed, null, 2));
1562
+
1563
+ await syncMcpsIntoConfigJson(runtimeDir, mcpServers, disabledIds);
1564
+ }
1565
+
1566
+ // The 2.1.x user config. Only ever UPDATED, never created: a runtime without
1567
+ // one is a pre-2.1 (or not-yet-migrated) client that reads `.claude.json`, and
1568
+ // an empty `.config.json` would make a newer client ignore that file. Written
1569
+ // via tmp + rename with the original mode preserved — Claude keeps the file
1570
+ // read-only (0444) and may re-read it while a session runs, so an in-place
1571
+ // truncating write is not safe.
1572
+ async function syncMcpsIntoConfigJson(
1573
+ runtimeDir: string,
1574
+ mcpServers: Record<string, McpServerConfig>,
1575
+ disabledIds: string[],
1576
+ ): Promise<void> {
1577
+ const target = join(runtimeDir, ".config.json");
1578
+ let parsed: Record<string, unknown>;
1579
+ let mode: number;
1580
+ try {
1581
+ const [raw, info] = await Promise.all([readFile(target, "utf8"), stat(target)]);
1582
+ parsed = JSON.parse(raw);
1583
+ mode = info.mode & 0o777;
1584
+ } catch {
1585
+ // Missing, unreadable or corrupt: leave it alone. A corrupt file is
1586
+ // Claude's own to repair; rewriting it from a stub would drop auth state.
1587
+ return;
1588
+ }
1589
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return;
1590
+ const rawExisting = parsed.mcpServers;
1591
+ const existing =
1592
+ rawExisting && typeof rawExisting === "object" && !Array.isArray(rawExisting)
1593
+ ? (rawExisting as Record<string, unknown>)
1594
+ : {};
1595
+ // Only `mcpServers` is touched; every other field is Claude's own state and
1596
+ // is carried over as read. (Between the read above and the rename below a
1597
+ // concurrently running Claude session could rewrite the file — accepted: the
1598
+ // sync runs once per launch and Claude keeps the file read-only.)
1599
+ parsed.mcpServers = mergeMcpServers(existing, mcpServers, disabledIds);
1600
+
1601
+ const tmp = `${target}.cue-${process.pid}.tmp`;
1602
+ try {
1603
+ await writeFile(tmp, JSON.stringify(parsed, null, 2), { mode });
1604
+ await rename(tmp, target);
1605
+ } finally {
1606
+ await rm(tmp, { force: true });
1607
+ }
853
1608
  }
854
1609
 
855
1610
  // Build the merged Claude Code settings.json content (string).
@@ -881,6 +1636,10 @@ const CUE_MANAGED_ENTRIES = new Set([
881
1636
  "plugins",
882
1637
  ]);
883
1638
 
1639
+ function sameResolvedPath(a: string, b: string): boolean {
1640
+ return resolvePath(a) === resolvePath(b);
1641
+ }
1642
+
884
1643
  /**
885
1644
  * Overlay state from `sourceDir` into `targetDir` by symlinking every
886
1645
  * top-level entry that cue doesn't actively manage. This makes the runtime
@@ -894,7 +1653,25 @@ const CUE_MANAGED_ENTRIES = new Set([
894
1653
  * on cache hit, where the previous symlinks point to a different source.
895
1654
  * Errors per-entry are non-fatal.
896
1655
  */
897
- async function overlaySourceState(targetDir: string, sourceDir: string): Promise<void> {
1656
+ /**
1657
+ * @param staggerKey Stable identity for the runtime being built. The fresh path
1658
+ * writes into a tmp dir that is renamed into place afterwards, so `targetDir`
1659
+ * is not the same string across a fresh materialize and a later cache-hit
1660
+ * refresh. Credential staggering must key off the runtime's final location or
1661
+ * the same runtime would land in a different slot on every rebuild.
1662
+ */
1663
+ async function overlaySourceState(
1664
+ targetDir: string,
1665
+ sourceDir: string,
1666
+ staggerKey: string = targetDir,
1667
+ ): Promise<void> {
1668
+ const sourceResolved = resolvePath(sourceDir);
1669
+ const targetResolved = resolvePath(targetDir);
1670
+ const finalResolved = resolvePath(staggerKey);
1671
+ if (sourceResolved === targetResolved || sourceResolved === finalResolved) {
1672
+ return;
1673
+ }
1674
+
898
1675
  let entries: string[];
899
1676
  try {
900
1677
  entries = await readdir(sourceDir);
@@ -908,22 +1685,43 @@ async function overlaySourceState(targetDir: string, sourceDir: string): Promise
908
1685
  // surface it so the runtime looks fully onboarded — otherwise claude
909
1686
  // boots into the OAuth flow even with a valid .credentials.json present.
910
1687
  // Only kicks in when sourceDir is the user's ~/.claude.
911
- if (!entries.includes(".claude.json") && sourceDir === join(homedir(), ".claude")) {
1688
+ if (
1689
+ !entries.includes(".claude.json") &&
1690
+ sourceDir === join(homedir(), ".claude")
1691
+ ) {
912
1692
  const legacy = join(homedir(), ".claude.json");
913
1693
  try {
914
1694
  const { existsSync } = await import("node:fs");
915
1695
  if (existsSync(legacy)) entries.push(".claude.json");
916
- } catch { /* skip */ }
1696
+ } catch {
1697
+ /* skip */
1698
+ }
917
1699
  }
918
1700
 
1701
+ // Account identity of both sides, resolved ONCE before the loop below can
1702
+ // swap `.claude.json` out from under the comparison. Same home-root fallback
1703
+ // as the entry list above: with no CLAUDE_CONFIG_DIR, Claude Code keeps
1704
+ // `oauthAccount` in `~/.claude.json`, not in `~/.claude/.claude.json`.
1705
+ const identityOf = async (dir: string): Promise<string | undefined> =>
1706
+ (await accountUuidAt(join(dir, ".config.json"))) ??
1707
+ (await accountUuidAt(join(dir, ".claude.json"))) ??
1708
+ (basename(dir) === ".claude"
1709
+ ? await accountUuidAt(join(dirname(dir), ".claude.json"))
1710
+ : undefined);
1711
+ const srcAccount = await identityOf(sourceDir);
1712
+ const dstAccount = await identityOf(targetDir);
1713
+ // Unknown on either side → treat as the same account: the expiry comparison
1714
+ // below is a no-op when the files agree, and refusing to compare would put us
1715
+ // back on the unconditional stamp this guard exists to prevent.
1716
+ const sameAccount = !srcAccount || !dstAccount || srcAccount === dstAccount;
1717
+
919
1718
  for (const name of entries) {
920
1719
  if (CUE_MANAGED_ENTRIES.has(name)) continue;
921
1720
  const targetPath = join(targetDir, name);
922
1721
  // Special-case the legacy ~/.claude.json fallback above: source is at the
923
1722
  // home-root path, not inside sourceDir.
924
1723
  const isLegacyClaudeJson =
925
- name === ".claude.json" &&
926
- sourceDir === join(homedir(), ".claude");
1724
+ name === ".claude.json" && sourceDir === join(homedir(), ".claude");
927
1725
  const sourcePath = isLegacyClaudeJson
928
1726
  ? join(homedir(), ".claude.json")
929
1727
  : join(sourceDir, name);
@@ -932,7 +1730,9 @@ async function overlaySourceState(targetDir: string, sourceDir: string): Promise
932
1730
  try {
933
1731
  const st = await lstat(targetPath);
934
1732
  existingType = st.isSymbolicLink() ? "symlink" : "other";
935
- } catch { /* missing */ }
1733
+ } catch {
1734
+ /* missing */
1735
+ }
936
1736
 
937
1737
  // .claude.json gets the same copy-not-symlink treatment as .credentials.json:
938
1738
  // claude rewrites it atomically and we want per-profile session state, not
@@ -960,32 +1760,65 @@ async function overlaySourceState(targetDir: string, sourceDir: string): Promise
960
1760
  // Copy to a sibling tmp + atomic rename — never leaves a window
961
1761
  // where .claude.json is missing/partial while a concurrent claude
962
1762
  // process might read or atomically rewrite it.
963
- const { copyFile } = await import("node:fs/promises");
964
1763
  const tmp = `${targetPath}.cue-swap.${process.pid}`;
965
1764
  await copyFile(sourcePath, tmp);
966
1765
  await rename(tmp, targetPath);
967
- } catch { /* non-fatal — keep existing file */ }
1766
+ } catch {
1767
+ /* non-fatal — keep existing file */
1768
+ }
968
1769
  }
969
1770
  }
970
1771
  continue; // cue override — don't touch
971
1772
  }
1773
+ // Freshness guard on the rotated OAuth token. Anthropic rotates the refresh
1774
+ // token on every refresh, so only the copy with the highest expiresAt still
1775
+ // holds a LIVE one. This overlay runs on every cache-hit launch — and via
1776
+ // `cue sync` / `cue install`, which resolve their source with
1777
+ // `healFromRuntime: false` — so stamping source over the runtime
1778
+ // unconditionally can hand a session a dead token and force a mid-session
1779
+ // re-login, across every runtime at once on a bulk sync. Keep whichever side
1780
+ // is newer; mirror of the rebuild path's `preserveFiles` guard.
1781
+ //
1782
+ // Scoped to one account: when the identities differ this is a deliberate
1783
+ // account switch, and source must win regardless of expiry.
1784
+ if (name === ".credentials.json" && sameAccount) {
1785
+ const srcExpiresAt = await credentialsExpiresAt(sourcePath);
1786
+ const dstExpiresAt = await credentialsExpiresAt(targetPath);
1787
+ if (dstExpiresAt > srcExpiresAt) continue; // runtime holds the live token
1788
+ }
972
1789
 
973
- if (existingType === "symlink" || (existingType === "other" && isCopyFile)) {
1790
+ if (
1791
+ existingType === "symlink" ||
1792
+ (existingType === "other" && isCopyFile)
1793
+ ) {
974
1794
  // Replace if it points elsewhere (e.g. previous account on cache hit).
975
1795
  try {
976
1796
  await rm(targetPath, { force: true });
977
- } catch { continue; }
1797
+ } catch {
1798
+ continue;
1799
+ }
978
1800
  }
979
1801
 
980
1802
  if (isCopyFile) {
981
- const { copyFile } = await import("node:fs/promises");
982
1803
  try {
983
- await copyFile(sourcePath, targetPath);
984
- } catch { /* skip */ }
1804
+ if (name === ".credentials.json") {
1805
+ // Staggered, so this runtime reaches its apparent expiry at a
1806
+ // different minute than its siblings and they stop racing for one
1807
+ // rotation. See writeStaggeredCopy in credentials-sync.
1808
+ const { writeStaggeredCopy } = await import("./credentials-sync");
1809
+ await writeStaggeredCopy(sourcePath, targetPath, staggerKey);
1810
+ } else {
1811
+ await copyFile(sourcePath, targetPath);
1812
+ }
1813
+ } catch {
1814
+ /* skip */
1815
+ }
985
1816
  } else {
986
1817
  try {
987
1818
  await symlink(sourcePath, targetPath);
988
- } catch { /* race or permission — skip silently */ }
1819
+ } catch {
1820
+ /* race or permission — skip silently */
1821
+ }
989
1822
  }
990
1823
  }
991
1824
  }
@@ -1012,7 +1845,13 @@ async function overlaySourceState(targetDir: string, sourceDir: string): Promise
1012
1845
  * it risks clobbering the real registry with an empty `{plugins:{}}`.
1013
1846
  * - `data`: per-plugin writable state; the self-referential ELOOP source.
1014
1847
  */
1015
- export async function linkPluginCache(targetDir: string, sourceDir: string): Promise<void> {
1848
+ async function seedPluginLinks(
1849
+ targetDir: string,
1850
+ sourceDir: string,
1851
+ resolved?: ReadonlyMap<string, string>,
1852
+ ): Promise<void> {
1853
+ if (sameResolvedPath(targetDir, sourceDir)) return;
1854
+
1016
1855
  const srcPlugins = join(sourceDir, "plugins");
1017
1856
  try {
1018
1857
  await lstat(srcPlugins);
@@ -1029,58 +1868,513 @@ export async function linkPluginCache(targetDir: string, sourceDir: string): Pro
1029
1868
  } catch {
1030
1869
  continue; // not present in source
1031
1870
  }
1871
+ const linkTarget = resolved ? resolved.get(name) : sourcePath;
1872
+ if (!linkTarget) continue;
1032
1873
  const targetPath = join(pluginsDir, name);
1033
1874
  // Replace whatever's there (Claude's lazy/empty copy or a stale symlink)
1034
- // with a symlink to the real, already-downloaded tree.
1035
- try {
1036
- await rm(targetPath, { recursive: true, force: true });
1037
- } catch { /* nothing to remove */ }
1875
+ // with a symlink to the real, already-downloaded tree — atomically.
1876
+ //
1877
+ // A plain rm-then-symlink leaves the path absent for a moment, and
1878
+ // re-materializing happens while sessions are live. A hook firing in that
1879
+ // window sees exactly the error this function exists to prevent:
1880
+ // "Plugin directory does not exist … run /plugin to reinstall". Observed
1881
+ // 2026-08-07, a Stop hook against claude-mem@thedotmack. So stage the new
1882
+ // link beside the target and rename() it over: same directory, so the swap
1883
+ // is atomic and a concurrent reader sees the old entry or the new one,
1884
+ // never neither.
1885
+ const stagePath = `${targetPath}.cue-tmp-${process.pid}`;
1038
1886
  try {
1039
- await symlink(sourcePath, targetPath);
1040
- } catch { /* race or permission — skip silently */ }
1887
+ await rm(stagePath, { recursive: true, force: true });
1888
+ await symlink(linkTarget, stagePath);
1889
+ try {
1890
+ await rename(stagePath, targetPath);
1891
+ } catch {
1892
+ // rename refuses to clobber a real directory, and POSIX has no atomic
1893
+ // way to replace a directory with a symlink — so this branch keeps the
1894
+ // old window. It is the first materialization, when the target is
1895
+ // still Claude's lazy empty copy; every later pass finds a symlink and
1896
+ // takes the atomic path above, which is the one that was failing hooks.
1897
+ await rm(targetPath, { recursive: true, force: true });
1898
+ await rename(stagePath, targetPath);
1899
+ }
1900
+ } catch {
1901
+ // Race or permission — leave the existing entry in place rather than
1902
+ // removing it, and don't leak the staged link.
1903
+ await rm(stagePath, { recursive: true, force: true }).catch(() => {});
1904
+ }
1905
+ }
1906
+ }
1907
+
1908
+ const PLUGIN_TREES = [["cache", 3], ["marketplaces", 1]] as const;
1909
+ const MARKETPLACE_REGISTRY = "known_marketplaces.json";
1910
+ const INSTALLED_PLUGINS = "installed_plugins.json";
1911
+ const LEGACY_IMPORTS = ".cue-marketplace-imports.json";
1912
+
1913
+ function missingPluginPath(error: NodeJS.ErrnoException): undefined {
1914
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return undefined;
1915
+ throw error;
1916
+ }
1917
+
1918
+ function pluginRealpath(path: string) {
1919
+ return realpath(path).catch((error: NodeJS.ErrnoException) => {
1920
+ if (error.code === "ELOOP") return undefined;
1921
+ return missingPluginPath(error);
1922
+ });
1923
+ }
1924
+
1925
+ function insidePluginPath(parent: string, path: string) {
1926
+ return path === parent || path.startsWith(parent.endsWith(sep) ? parent : parent + sep);
1927
+ }
1928
+
1929
+ function safePluginLink(slot: string, source: string) {
1930
+ return !insidePluginPath(source, slot) && !insidePluginPath(slot, source);
1931
+ }
1932
+
1933
+ async function pluginFile(path: string) {
1934
+ const info = await lstat(path).catch(missingPluginPath);
1935
+ if (!(info?.isFile() || info?.isSymbolicLink())) return undefined;
1936
+ const linked = info.isSymbolicLink();
1937
+ const text = await readFile(path, "utf8").catch((error: NodeJS.ErrnoException) => {
1938
+ if (linked && error.code === "ELOOP") return undefined;
1939
+ return missingPluginPath(error);
1940
+ });
1941
+ return { linked, text, inode: info.ino, device: info.dev, changed: info.ctimeMs };
1942
+ }
1943
+
1944
+ function pluginRecord(text: string | undefined): Record<string, unknown> | undefined {
1945
+ if (text === undefined) return {};
1946
+ try {
1947
+ const parsed: unknown = JSON.parse(text);
1948
+ if (isRecord(parsed)) return parsed;
1949
+ } catch {
1950
+ /* Leave a malformed registry for Claude to repair. */
1951
+ }
1952
+ }
1953
+
1954
+ async function pluginChildren(path: string) {
1955
+ return (await readdir(path).catch(missingPluginPath)) ?? [];
1956
+ }
1957
+
1958
+ function directoryAt(path: string) {
1959
+ return stat(path).then((entry) => entry.isDirectory(), (error: NodeJS.ErrnoException) => {
1960
+ if (error.code === "ELOOP") return false;
1961
+ return missingPluginPath(error) ?? false;
1962
+ });
1963
+ }
1964
+
1965
+ async function hasLocalPluginEntries(path: string, depth: number): Promise<boolean> {
1966
+ for (const entry of (await readdir(path, { withFileTypes: true }).catch(missingPluginPath)) ?? []) {
1967
+ if (!entry.isSymbolicLink() &&
1968
+ (depth === 1 || !entry.isDirectory() ||
1969
+ await hasLocalPluginEntries(join(path, entry.name), depth - 1))) return true;
1970
+ }
1971
+ return false;
1972
+ }
1973
+
1974
+ async function sourceMarketplaces(source: string | undefined, live: string) {
1975
+ const text = source
1976
+ ? await readFile(join(source, MARKETPLACE_REGISTRY), "utf8").catch(missingPluginPath)
1977
+ : undefined;
1978
+ const entries = pluginRecord(text);
1979
+ if (!entries) return undefined;
1980
+ const result: Record<string, unknown> = Object.create(null);
1981
+ for (const [name, entry] of Object.entries(entries)) {
1982
+ if (!isRecord(entry) || !name || name === "." || name === ".." || basename(name) !== name) continue;
1983
+ const original = entry.installLocation;
1984
+ const clone = typeof original === "string" && isAbsolute(original) && await directoryAt(original)
1985
+ ? original : join(source!, "marketplaces", name);
1986
+ const physical = await pluginRealpath(clone);
1987
+ const slot = join(live, "marketplaces", name);
1988
+ if (physical && (physical === slot || safePluginLink(slot, physical)) && await directoryAt(physical)) {
1989
+ result[name] = clone === original ? entry : { ...entry, installLocation: clone };
1990
+ }
1991
+ }
1992
+ return { entries, result };
1993
+ }
1994
+
1995
+ async function inspectRuntimePlugins(runtimeDir: string, sourceDir?: string) {
1996
+ const live = join(runtimeDir, "plugins");
1997
+ const physicalRuntime = await pluginRealpath(runtimeDir) ??
1998
+ join(await pluginRealpath(dirname(runtimeDir)) ?? resolvePath(dirname(runtimeDir)), basename(runtimeDir));
1999
+ const physicalLive = join(physicalRuntime, "plugins");
2000
+ const physicalRoot = await pluginRealpath(live);
2001
+ // Previous cue versions linked the active plugins dir into a sibling.
2002
+ // Accept that live link for migration, without looking for sibling archives.
2003
+ const legacyDir = physicalRuntime + ".plugin-state";
2004
+ const physicalParent = physicalRoot && dirname(physicalRoot);
2005
+ const legacyRoot = physicalParent && basename(physicalRoot) === "plugins" &&
2006
+ dirname(physicalParent) === dirname(legacyDir) &&
2007
+ (physicalParent === legacyDir || physicalParent.startsWith(legacyDir + "-"));
2008
+ const foreign = physicalRoot !== undefined && physicalRoot !== physicalLive && !legacyRoot;
2009
+ const source = sourceDir ? join(sourceDir, "plugins") : undefined;
2010
+ const sourceRoot = source && await pluginRealpath(source);
2011
+ const sameSource = sourceRoot === physicalLive;
2012
+ const canSeed = (kind: string, incoming: string) =>
2013
+ safePluginLink(join(physicalLive, kind), incoming) &&
2014
+ (!physicalRoot || safePluginLink(join(physicalRoot, kind), incoming));
2015
+ const localFiles = new Set(physicalRoot && !foreign ? await pluginChildren(live) : []);
2016
+ const sourceFiles = new Set(sourceRoot ? await pluginChildren(sourceRoot) : []);
2017
+ const installed = localFiles.has(INSTALLED_PLUGINS) ? await pluginFile(join(live, INSTALLED_PLUGINS)) : undefined;
2018
+ const registry = localFiles.has(MARKETPLACE_REGISTRY) ? await pluginFile(join(live, MARKETPLACE_REGISTRY)) : undefined;
2019
+ const installedRecord = installed?.linked ? undefined : pluginRecord(installed?.text)?.plugins;
2020
+ const installs = isRecord(installedRecord)
2021
+ ? Object.values(installedRecord).flatMap((entries: unknown) => Array.isArray(entries) ? entries : [])
2022
+ : [];
2023
+ const trees = new Map<string, string>();
2024
+ const seeds = new Map<string, string>();
2025
+ let cleanup = !physicalRoot && !!(await lstat(live).catch(missingPluginPath))?.isSymbolicLink();
2026
+ let retargetMarketplaces = false;
2027
+ for (const [kind, depth] of PLUGIN_TREES) {
2028
+ const path = join(live, kind);
2029
+ const info = localFiles.has(kind) ? await lstat(path).catch(missingPluginPath) : undefined;
2030
+ const current = info?.isSymbolicLink() ? await pluginRealpath(path) : undefined;
2031
+ const incoming = sourceRoot && sourceFiles.has(kind) ? await pluginRealpath(join(sourceRoot, kind)) : undefined;
2032
+ if (incoming && canSeed(kind, incoming)) seeds.set(kind, incoming);
2033
+ const backing = current === join(physicalRoot ?? physicalLive, "." + kind + ".cue-local");
2034
+ if (info?.isDirectory() || backing) {
2035
+ const real = backing ? current! : path;
2036
+ if (await hasLocalPluginEntries(real, depth)) trees.set(kind, real);
2037
+ // With no source to replace a merged tree, reconcile its leftover links in place.
2038
+ if (!incoming && (await pluginChildren(real)).length) cleanup = true;
2039
+ }
2040
+ if (info?.isSymbolicLink() && !current) cleanup = true;
2041
+ if (kind === "marketplaces" && current && incoming && current !== incoming) retargetMarketplaces = true;
2042
+ if (incoming && !seeds.has(kind)) cleanup = true;
2043
+ }
2044
+ const sourceRegistry = sourceRoot && sourceFiles.has(MARKETPLACE_REGISTRY)
2045
+ ? await pluginRealpath(join(sourceRoot, MARKETPLACE_REGISTRY)) : undefined;
2046
+ if (sourceRegistry && canSeed(MARKETPLACE_REGISTRY, sourceRegistry)) {
2047
+ seeds.set(MARKETPLACE_REGISTRY, sourceRegistry);
2048
+ }
2049
+ if (registry?.linked && registry.text === undefined) cleanup = true;
2050
+ const upstream = sourceRegistry ? await sourceMarketplaces(sourceRoot, physicalLive) : undefined;
2051
+ const local = registry && !registry.linked && pluginRecord(registry.text);
2052
+ const extraRegistration = local === undefined && !!registry && !registry.linked ||
2053
+ local && Object.entries(local).some(([name, entry]) =>
2054
+ sortedJson(entry) !== sortedJson(upstream?.entries[name]));
2055
+ const sourceNeedsCorrection = upstream &&
2056
+ sortedJson(upstream.entries) !== sortedJson(upstream.result);
2057
+ // Pair an existing marketplace tree with its registry when replacing it
2058
+ // with a populated source. The baseline seeding path has no such check.
2059
+ const protectedRetarget = retargetMarketplaces &&
2060
+ (Object.keys(pluginRecord(registry?.text) ?? {}).length > 0 ||
2061
+ Object.keys(upstream?.entries ?? {}).length > 0);
2062
+ const preserve = trees.size > 0 || installs.length > 0 || !!extraRegistration ||
2063
+ (!!installed && !installed.linked && !pluginRecord(installed.text));
2064
+ const reconcile = preserve || cleanup || sourceNeedsCorrection || protectedRetarget ||
2065
+ !!(sourceRegistry && !seeds.has(MARKETPLACE_REGISTRY)) ||
2066
+ localFiles.has(LEGACY_IMPORTS);
2067
+ return { live, physicalLive, physicalRoot, foreign, source, sourceDir, installed, registry, installs,
2068
+ trees, seeds, preserve, reconcile, sameSource };
2069
+ }
2070
+
2071
+ type RuntimePlugins = Awaited<ReturnType<typeof inspectRuntimePlugins>>;
2072
+
2073
+ async function publishPluginEntry(
2074
+ target: string,
2075
+ prepare: (staged: string) => Promise<void>,
2076
+ unchanged: () => Promise<boolean>,
2077
+ emptyDir = false,
2078
+ ): Promise<boolean> {
2079
+ const stage = await mkdtemp(target + ".cue-tmp-");
2080
+ try {
2081
+ const staged = join(stage, "entry");
2082
+ await prepare(staged);
2083
+ // A Claude write can still land between this reread and rename. The next
2084
+ // launch re-derives the registry from the source and surviving local entries
2085
+ // with real clones. Cue can't recover metadata overwritten in that window.
2086
+ if (!(await unchanged())) return false;
2087
+ if (emptyDir) await rmdir(target);
2088
+ await rename(staged, target);
2089
+ return true;
2090
+ } finally {
2091
+ await rm(stage, { recursive: true, force: true });
2092
+ }
2093
+ }
2094
+
2095
+ async function syncPluginTree(
2096
+ target: string, source: string | undefined, depth: number, retained: ReadonlyMap<string, string>,
2097
+ blockedRoot?: string,
2098
+ ): Promise<boolean> {
2099
+ const info = await lstat(target).catch(missingPluginPath);
2100
+ const incoming = source && await pluginRealpath(source);
2101
+ const parent = await realpath(dirname(target));
2102
+ const slot = join(parent, basename(target));
2103
+ const allowed = incoming && (!blockedRoot || !insidePluginPath(blockedRoot, incoming));
2104
+ if (info?.isDirectory() && depth > 0) {
2105
+ const children = await pluginChildren(target);
2106
+ if (children.length) {
2107
+ const upstream = allowed && (incoming === slot || safePluginLink(slot, incoming))
2108
+ && await directoryAt(incoming) ? source : undefined;
2109
+ for (const name of new Set([...children, ...(upstream ? await pluginChildren(upstream) : [])])) {
2110
+ if (!(await syncPluginTree(join(target, name), upstream && join(upstream, name),
2111
+ depth - 1, retained, blockedRoot))) return false;
2112
+ }
2113
+ return true;
2114
+ }
2115
+ }
2116
+ if (info && !info.isSymbolicLink() && !(depth > 0 && info.isDirectory())) return true;
2117
+ const current = info?.isSymbolicLink() ? await pluginRealpath(target) : undefined;
2118
+ if (current && safePluginLink(slot, current) && depth > 0 &&
2119
+ [...retained.keys()].some((path) => path !== target && insidePluginPath(target, path))) {
2120
+ // An installed version still uses this branch of a previous cache.
2121
+ return true;
2122
+ }
2123
+ const saved = retained.get(target);
2124
+ const next = saved ?? (allowed ? incoming : undefined);
2125
+ if (!next || !safePluginLink(slot, next)) {
2126
+ if (info?.isSymbolicLink()) await unlink(target);
2127
+ return true;
2128
+ }
2129
+ if (current === next) return true;
2130
+ return publishPluginEntry(target, (staged) => symlink(next, staged),
2131
+ async () => (await pluginRealpath(saved ?? source!)) === next, info?.isDirectory());
2132
+ }
2133
+
2134
+ async function referencedCacheVersions(state: RuntimePlugins) {
2135
+ const retained = new Map<string, string>();
2136
+ if (!state.installs.length) return retained;
2137
+ const cache = join(state.live, "cache");
2138
+ const canonicalCache = await pluginRealpath(cache);
2139
+ if (!canonicalCache) return retained;
2140
+ for (const install of state.installs) {
2141
+ if (!isRecord(install) || typeof install.installPath !== "string" || !isAbsolute(install.installPath)) continue;
2142
+ const path = resolvePath(install.installPath);
2143
+ // A prior account's absolute install path can still identify a version
2144
+ // under the runtime's shared cache. Check that both paths reach it.
2145
+ const marker = join("plugins", "cache") + sep;
2146
+ const offset = path.lastIndexOf(sep + marker);
2147
+ const relative = insidePluginPath(cache, path) ? path.slice(cache.length + 1) :
2148
+ insidePluginPath(canonicalCache, path) ? path.slice(canonicalCache.length + 1) :
2149
+ offset < 0 ? "" : path.slice(offset + marker.length + 1);
2150
+ if (!relative) continue;
2151
+ const actual = await pluginRealpath(join(cache, relative));
2152
+ if (actual && actual === await pluginRealpath(path) && await directoryAt(actual)) {
2153
+ retained.set(relative, actual);
2154
+ }
2155
+ }
2156
+ return retained;
2157
+ }
2158
+
2159
+ async function mergePluginTrees(state: RuntimePlugins, dest: string, staged: boolean) {
2160
+ const retained = await referencedCacheVersions(state);
2161
+ for (const [kind, depth] of PLUGIN_TREES) {
2162
+ const path = join(dest, kind);
2163
+ const source = state.source && join(state.source, kind);
2164
+ const backing = "." + kind + ".cue-local";
2165
+ const backingPath = join(dest, backing);
2166
+ const current = await lstat(path).catch(missingPluginPath);
2167
+ const localLink = current?.isSymbolicLink() && await readlink(path) === backing &&
2168
+ (await lstat(backingPath).catch(missingPluginPath))?.isDirectory();
2169
+ const incoming = source && await pluginRealpath(source);
2170
+ const existingCache = kind === "cache" && retained.size && !state.trees.has(kind) &&
2171
+ incoming !== await pluginRealpath(join(state.live, kind));
2172
+ const useBacking = !staged && existingCache && current?.isSymbolicLink() && !localLink;
2173
+ if (useBacking) {
2174
+ const existing = await lstat(backingPath).catch(missingPluginPath);
2175
+ if (existing && !existing.isDirectory()) return false;
2176
+ }
2177
+ const tree = localLink || useBacking ? backingPath : path;
2178
+ const retainedLinks = new Map<string, string>();
2179
+ if (kind === "cache") {
2180
+ for (const [relative, real] of retained) {
2181
+ if (staged && insidePluginPath(state.physicalRoot ?? state.physicalLive, real)) continue;
2182
+ const target = join(tree, relative);
2183
+ retainedLinks.set(target, real);
2184
+ if (existingCache) {
2185
+ await mkdir(dirname(target), { recursive: true });
2186
+ await syncPluginTree(target, undefined, 0, retainedLinks);
2187
+ }
2188
+ }
2189
+ }
2190
+ if (!(await syncPluginTree(tree, source, depth, retainedLinks,
2191
+ staged ? state.physicalRoot ?? state.physicalLive : undefined))) return false;
2192
+ if (useBacking && !(await publishPluginEntry(path, (entry) => symlink(backing, entry), async () => true))) {
2193
+ return false;
2194
+ }
2195
+ }
2196
+ return true;
2197
+ }
2198
+
2199
+ async function mergeMarketplaceRegistry(state: RuntimePlugins, dest: string) {
2200
+ const upstream = await sourceMarketplaces(state.source, state.physicalLive);
2201
+ const local = pluginRecord(state.registry?.linked ? undefined : state.registry?.text);
2202
+ if (!upstream || !local) return;
2203
+ const merged = upstream.result;
2204
+ const tree = state.trees.get("marketplaces");
2205
+ if (tree) {
2206
+ for (const [name, entry] of Object.entries(local)) {
2207
+ if (!isRecord(entry) || basename(name) !== name || name === "." || name === ".." || !name) continue;
2208
+ const location = join(state.live, "marketplaces", name);
2209
+ const clone = join(tree, name);
2210
+ if (!(await lstat(clone).catch(missingPluginPath))?.isDirectory()) continue;
2211
+ // A copied upstream entry can share a name with a different runtime clone.
2212
+ // Its original location must identify this clone before we prefer it.
2213
+ if (entry.installLocation === location ||
2214
+ (typeof entry.installLocation === "string" &&
2215
+ await pluginRealpath(entry.installLocation) === await realpath(clone))) {
2216
+ merged[name] = { ...entry, installLocation: location };
2217
+ }
2218
+ }
2219
+ }
2220
+ const path = join(dest, MARKETPLACE_REGISTRY);
2221
+ const snapshot = dest === state.live ? state.registry : undefined;
2222
+ if (!snapshot && !Object.keys(merged).length && !state.source) return;
2223
+ if (!snapshot?.linked && snapshot?.text && sortedJson(local) === sortedJson(merged)) return;
2224
+ await publishPluginEntry(path, (entry) => writeFile(entry, JSON.stringify(merged, null, 2) + "\n"),
2225
+ async () => JSON.stringify(await pluginFile(path)) === JSON.stringify(snapshot));
2226
+ }
2227
+
2228
+ export async function linkPluginCache(targetDir: string, sourceDir: string): Promise<void> {
2229
+ if (sameResolvedPath(targetDir, sourceDir)) return;
2230
+ await refreshPlugins(await inspectRuntimePlugins(targetDir, sourceDir));
2231
+ }
2232
+
2233
+ async function refreshPlugins(state: RuntimePlugins) {
2234
+ if (!state.sourceDir || state.foreign || state.sameSource) return;
2235
+ if (!state.reconcile) return seedPluginLinks(dirname(state.live), state.sourceDir, state.seeds);
2236
+ if (!state.physicalRoot && (await lstat(state.live).catch(missingPluginPath))?.isSymbolicLink()) {
2237
+ await unlink(state.live);
2238
+ }
2239
+ await mkdir(state.live, { recursive: true });
2240
+ if (await mergePluginTrees(state, state.live, false)) await mergeMarketplaceRegistry(state, state.live);
2241
+ await rm(join(state.live, LEGACY_IMPORTS), { force: true });
2242
+ }
2243
+
2244
+
2245
+ async function pluginStateFingerprint(state: RuntimePlugins) {
2246
+ // Only rebuilds with local state walk the payload. Metadata catches
2247
+ // in-place writes and replacements without reading every file's contents.
2248
+ const metadata = [];
2249
+ for (const [kind, tree] of state.trees) {
2250
+ for (const path of ["", ...(await readdir(tree, { recursive: true })).sort()]) {
2251
+ const info = await lstat(join(tree, path));
2252
+ metadata.push([kind, path, info.dev, info.ino, info.size, info.mtimeMs, info.ctimeMs]);
2253
+ }
2254
+ }
2255
+ return JSON.stringify([state.physicalRoot, state.registry, state.installed, metadata,
2256
+ [...await referencedCacheVersions(state)]]);
2257
+ }
2258
+
2259
+ async function stageRuntimePlugins(state: RuntimePlugins, stage: string) {
2260
+ if (!state.preserve && (!state.sourceDir || state.sameSource)) return;
2261
+ if (!state.reconcile) {
2262
+ if (state.sourceDir) await seedPluginLinks(stage, state.sourceDir, state.seeds);
2263
+ return;
2264
+ }
2265
+ const original = state.preserve ? await pluginStateFingerprint(state) : undefined;
2266
+ const dest = join(stage, "plugins");
2267
+ await mkdir(dest, { recursive: true });
2268
+ for (const [kind, tree] of state.trees) {
2269
+ await cp(tree, join(dest, kind), { recursive: true, verbatimSymlinks: true });
2270
+ }
2271
+ if (state.installed && !state.installed.linked) {
2272
+ await copyFile(join(state.live, INSTALLED_PLUGINS), join(dest, INSTALLED_PLUGINS));
2273
+ }
2274
+ if (state.registry && !state.registry.linked && !pluginRecord(state.registry.text)) {
2275
+ await copyFile(join(state.live, MARKETPLACE_REGISTRY), join(dest, MARKETPLACE_REGISTRY));
2276
+ }
2277
+ if (!(await mergePluginTrees(state, dest, true))) throw new Error("[cue] Plugin source changed while staging");
2278
+ await mergeMarketplaceRegistry(state, dest);
2279
+ if (original !== undefined) {
2280
+ const current = await inspectRuntimePlugins(dirname(state.live), state.sourceDir);
2281
+ if (original !== await pluginStateFingerprint(current)) {
2282
+ throw new Error("[cue] Plugin state changed while staging. Retry the rebuild.");
2283
+ }
2284
+ }
2285
+ }
2286
+
2287
+ /**
2288
+ * Parse a loopback proxy URL. Returns a URL only for loopback hosts
2289
+ * (127.0.0.1 / ::1 / localhost) — those are the ones we health-gate; any other
2290
+ * host is treated as a managed remote and left alone.
2291
+ */
2292
+ function parseLoopbackProxyUrl(rawUrl: string): URL | null {
2293
+ try {
2294
+ const u = new URL(rawUrl);
2295
+ const host = u.hostname;
2296
+ if (host !== "127.0.0.1" && host !== "::1" && host !== "localhost")
2297
+ return null;
2298
+ if (u.protocol !== "http:" && u.protocol !== "https:") return null;
2299
+ return u;
2300
+ } catch {
2301
+ return null;
1041
2302
  }
1042
2303
  }
1043
2304
 
2305
+ /**
2306
+ * Whether a proxy base URL should be applied to settings.json. Non-loopback
2307
+ * URLs are always "reachable" (not gated — assumed deliberately managed). A
2308
+ * loopback URL is reachable only if its HTTP `/health` endpoint returns 2xx
2309
+ * within `timeoutMs`. A raw TCP connect is not enough: a saturated proxy may
2310
+ * accept sockets while timing out or returning 503 to Claude traffic.
2311
+ */
2312
+ async function isProxyReachable(
2313
+ rawUrl: string,
2314
+ timeoutMs = 400,
2315
+ ): Promise<boolean> {
2316
+ const baseUrl = parseLoopbackProxyUrl(rawUrl);
2317
+ if (!baseUrl) return true;
2318
+ const healthUrl = new URL("/health", baseUrl);
2319
+ return await new Promise<boolean>((resolveProbe) => {
2320
+ const client = healthUrl.protocol === "https:" ? https : http;
2321
+ let settled = false;
2322
+ const finish = (ok: boolean): void => {
2323
+ if (settled) return;
2324
+ settled = true;
2325
+ resolveProbe(ok);
2326
+ };
2327
+ const req = client.get(healthUrl, (res) => {
2328
+ res.resume();
2329
+ finish((res.statusCode ?? 0) >= 200 && (res.statusCode ?? 0) < 300);
2330
+ });
2331
+ req.setTimeout(timeoutMs, () => {
2332
+ req.destroy();
2333
+ finish(false);
2334
+ });
2335
+ req.once("error", () => finish(false));
2336
+ });
2337
+ }
2338
+
1044
2339
  async function buildClaudeSettings(
1045
2340
  profile: ResolvedProfile,
1046
2341
  agent: AgentKind,
1047
2342
  input: MaterializeInput,
2343
+ runtimeDir: string,
2344
+ mcpServers: Record<string, McpServerConfig>,
1048
2345
  ): Promise<string> {
1049
2346
  const enabledPlugins: Record<string, true> = {};
1050
2347
  for (const plugin of profile.plugins) {
1051
2348
  if (!appliesToAgent(plugin, agent)) continue;
1052
2349
  enabledPlugins[plugin.id] = true;
1053
2350
  }
1054
- const mcpServers = collectProfileMcps(profile, agent, input.mcpRegistry);
1055
2351
  let baseSettings: Record<string, unknown> = {};
1056
2352
  if (input.credentialsSource) {
1057
2353
  try {
1058
- const raw = await readFile(join(input.credentialsSource, "settings.json"), "utf8");
2354
+ const raw = await readFile(
2355
+ join(input.credentialsSource, "settings.json"),
2356
+ "utf8",
2357
+ );
1059
2358
  baseSettings = JSON.parse(raw);
1060
- } catch { /* no existing settings — start fresh */ }
2359
+ } catch {
2360
+ /* no existing settings — start fresh */
2361
+ }
1061
2362
  }
2363
+ const profileLocalSettings = await readClaudeProfileLocalSettings(runtimeDir);
1062
2364
 
1063
2365
  // Merge profile hooks. A hook ref points to a JSON file with shape
1064
2366
  // { hooks: { PreToolUse: [...], ... } } — same shape Claude Code expects.
1065
2367
  // Multiple hook files concat their event arrays under each lifecycle key.
1066
2368
  let mergedHooks: Record<string, unknown[]> = {};
1067
- const baseHooks = (baseSettings.hooks as Record<string, unknown[]> | undefined) ?? {};
2369
+ const baseHooks =
2370
+ (baseSettings.hooks as Record<string, unknown[]> | undefined) ?? {};
1068
2371
  for (const [k, v] of Object.entries(baseHooks)) {
1069
2372
  mergedHooks[k] = Array.isArray(v) ? [...v] : [];
1070
2373
  }
1071
2374
  // Auto-inject the cue-quality-gates Stop hook when the profile declares
1072
- // any qualityGates. This avoids the footgun where a profile lists gates
1073
- // but forgets to wire the hook, so gates would never actually fire.
1074
- // Explicit `hooks: [cue-quality-gates.json]` still works and is deduped.
1075
- const declaredHooks = [...(profile.hooks ?? [])];
1076
- const profileGatesForHook = (profile as any).qualityGates ?? [];
1077
- if (
1078
- agent === "claude-code" &&
1079
- profileGatesForHook.length > 0 &&
1080
- !declaredHooks.includes("cue-quality-gates.json")
1081
- ) {
1082
- declaredHooks.push("cue-quality-gates.json");
1083
- }
2375
+ // any qualityGates. effectiveHookList() centralises this logic so both the
2376
+ // symlink phase and settings.json wiring stay consistent.
2377
+ const declaredHooks = effectiveHookList(profile, agent);
1084
2378
  for (const ref of declaredHooks) {
1085
2379
  const src = resolveResourcePath(ref, RESOURCES_HOOKS);
1086
2380
  try {
@@ -1090,7 +2384,9 @@ async function buildClaudeSettings(
1090
2384
  if (!Array.isArray(entries)) continue;
1091
2385
  mergedHooks[event] = [...(mergedHooks[event] ?? []), ...entries];
1092
2386
  }
1093
- } catch { /* missing or malformed — skip */ }
2387
+ } catch {
2388
+ /* missing or malformed — skip */
2389
+ }
1094
2390
  }
1095
2391
 
1096
2392
  // Dedupe entries per event by JSON signature — keeps the first occurrence.
@@ -1111,6 +2407,10 @@ async function buildClaudeSettings(
1111
2407
 
1112
2408
  const settings: Record<string, unknown> = {
1113
2409
  ...baseSettings,
2410
+ // Claude's /auto-mode-setup writes environment-specific trust context to
2411
+ // the profile runtime, not the global credentials source. Carry that one
2412
+ // Claude-managed field across both cache-hit refreshes and full rebuilds.
2413
+ ...profileLocalSettings,
1114
2414
  // MCPs are profile-scoped — do NOT merge baseSettings.mcpServers in.
1115
2415
  // Otherwise every MCP registered in the user's source ~/.claude/settings.json
1116
2416
  // (or ~/.claude-accounts/<acct>/settings.json) leaks into every profile's
@@ -1140,6 +2440,7 @@ async function buildClaudeSettings(
1140
2440
  // into settings.json. To surface a new one, append its key here.
1141
2441
  const CLAUDE_RUNTIME_ENV_KEYS = [
1142
2442
  "CLAUDE_CODE_SUBAGENT_MODEL", // run Task/Agent subagents on a cheaper model
2443
+ "ANTHROPIC_BASE_URL", // route Claude traffic through a local proxy (e.g. the headroom compression wrap). Health-gated below: a loopback URL is dropped when the proxy isn't answering, so a dead proxy falls back to direct Anthropic instead of bricking Claude.
1143
2444
  ];
1144
2445
  // Preserve any account-level env from credentialsSource (spread in via
1145
2446
  // baseSettings above); profile-declared keys overlay it (profile is more
@@ -1151,9 +2452,25 @@ async function buildClaudeSettings(
1151
2452
  };
1152
2453
  for (const key of CLAUDE_RUNTIME_ENV_KEYS) {
1153
2454
  const val = profile.env?.[key];
1154
- if (typeof val === "string" && val.length > 0 && !val.includes("${")) {
1155
- runtimeEnv[key] = val;
2455
+ if (typeof val !== "string" || val.length === 0 || val.includes("${")) {
2456
+ continue;
1156
2457
  }
2458
+ // Health-gate the proxy wrap. ANTHROPIC_BASE_URL pointed at an unreachable
2459
+ // local proxy would make Claude unable to reach Anthropic at all. Only
2460
+ // surface it when a loopback proxy actually answers; otherwise drop it
2461
+ // (fail-open to direct Anthropic) and warn. Non-loopback URLs are not
2462
+ // gated — they're assumed to be a deliberately-managed remote endpoint.
2463
+ const proxyHealthCheck = input.proxyHealthCheck ?? isProxyReachable;
2464
+ if (key === "ANTHROPIC_BASE_URL" && !(await proxyHealthCheck(val))) {
2465
+ console.warn(
2466
+ `[cue] ANTHROPIC_BASE_URL=${val} is unreachable — dropping the proxy ` +
2467
+ `wrap for profile "${profile.name}"; Claude will talk to Anthropic ` +
2468
+ `directly. Start the proxy (e.g. \`systemctl --user start headroom-proxy\`) ` +
2469
+ `to enable compression.`,
2470
+ );
2471
+ continue;
2472
+ }
2473
+ runtimeEnv[key] = val;
1157
2474
  }
1158
2475
  if (Object.keys(runtimeEnv).length > 0) {
1159
2476
  settings.env = runtimeEnv;
@@ -1163,61 +2480,73 @@ async function buildClaudeSettings(
1163
2480
  return JSON.stringify(settings, null, 2);
1164
2481
  }
1165
2482
 
1166
- // Minimal TOML emitter for the MCP config block. Replace with `@iarna/toml` if
1167
- // we need broader coverage. Codex only reads a flat-ish [mcp_servers.<id>] table.
1168
- function tomlRender(obj: { mcp_servers: Record<string, unknown> }): string {
1169
- const out: string[] = [];
1170
- for (const [id, val] of Object.entries(obj.mcp_servers)) {
1171
- out.push(`[mcp_servers.${id}]`);
1172
- for (const [k, v] of Object.entries(val as Record<string, unknown>)) {
1173
- out.push(`${k} = ${JSON.stringify(v)}`);
2483
+ async function readClaudeProfileLocalSettings(
2484
+ runtimeDir: string,
2485
+ ): Promise<Record<string, unknown>> {
2486
+ try {
2487
+ const parsed = JSON.parse(
2488
+ await readFile(join(runtimeDir, "settings.json"), "utf8"),
2489
+ ) as unknown;
2490
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
2491
+ return {};
2492
+ }
2493
+ const settings = parsed as Record<string, unknown>;
2494
+ if (Object.prototype.hasOwnProperty.call(settings, "autoMode")) {
2495
+ return { autoMode: settings.autoMode };
1174
2496
  }
1175
- out.push("");
2497
+ } catch {
2498
+ /* first build or malformed old settings — use credentials source only */
1176
2499
  }
1177
- return out.join("\n");
2500
+ return {};
1178
2501
  }
1179
2502
 
1180
2503
  // ---------------------------------------------------------------------------
1181
2504
  // #8: Warm-start — summarize last session for this profile
1182
2505
  // ---------------------------------------------------------------------------
1183
2506
 
1184
- import { homedir } from "node:os";
1185
- import { readdirSync, existsSync, statSync } from "node:fs";
1186
- import { spawnSync } from "node:child_process";
1187
-
1188
- async function getLastSessionSummary(profileName: string): Promise<string | null> {
2507
+ export async function getLastSessionSummary(
2508
+ profileName: string,
2509
+ projectsDir = join(homedir(), ".claude", "projects"),
2510
+ ): Promise<string | null> {
1189
2511
  try {
1190
- const projectsDir = join(homedir(), ".claude", "projects");
1191
- if (!existsSync(projectsDir)) return null;
2512
+ // Check projectsDir exists
2513
+ const projectEntries = await readdir(projectsDir).catch(() => null);
2514
+ if (!projectEntries) return null;
1192
2515
 
1193
2516
  // Find the most recent session jsonl in the cwd-based project dir
1194
2517
  const cwdKey = process.cwd().replace(/\//g, "-");
1195
- const projectDir = readdirSync(projectsDir)
2518
+ const candidates = projectEntries
1196
2519
  .filter((d) => d.includes(cwdKey.slice(1, 30)))
1197
- .map((d) => join(projectsDir, d))
1198
- .find((d) => existsSync(d));
2520
+ .map((d) => join(projectsDir, d));
2521
+ let projectDir: string | undefined;
2522
+ for (const c of candidates) {
2523
+ const entries = await readdir(c).catch(() => null);
2524
+ if (entries !== null) { projectDir = c; break; }
2525
+ }
1199
2526
 
1200
2527
  if (!projectDir) return null;
1201
2528
 
1202
2529
  // Find most recent .jsonl (limit scan to avoid slow stat on large dirs)
1203
- const allFiles = readdirSync(projectDir).filter((f) => f.endsWith(".jsonl"));
2530
+ const allFiles = (await readdir(projectDir)).filter((f) => f.endsWith(".jsonl"));
1204
2531
  if (allFiles.length === 0) return null;
1205
2532
 
1206
2533
  // Sort by name (includes timestamp) — take last 3 only
1207
2534
  const recent = allFiles.sort().slice(-3);
1208
- const sessions = recent
1209
- .map((f) => ({ name: f, mtime: statSync(join(projectDir, f)).mtimeMs }))
1210
- .sort((a, b) => b.mtime - a.mtime);
2535
+ const sessions = await Promise.all(
2536
+ recent.map(async (f) => ({ name: f, mtime: (await stat(join(projectDir!, f))).mtimeMs })),
2537
+ );
2538
+ sessions.sort((a, b) => b.mtime - a.mtime);
1211
2539
 
1212
2540
  const lastFile = join(projectDir, sessions[0]!.name);
1213
2541
  const lastMtime = new Date(sessions[0]!.mtime);
1214
2542
  const ago = formatTimeAgo(lastMtime);
1215
2543
 
1216
- // Extract a quick summary: last few assistant messages
1217
- const res = spawnSync("tail", ["-50", lastFile], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 2000 });
1218
- if (!res.stdout) return null;
1219
-
1220
- const lines = res.stdout.split("\n").filter(Boolean);
2544
+ // Extract a quick summary: last few assistant messages.
2545
+ // Read the last ~8 KB and slice to the last 50 newline-terminated records
2546
+ // — avoids the blocking spawnSync("tail", ...) subprocess.
2547
+ const raw = await readFile(lastFile, "utf8").catch(() => null);
2548
+ if (!raw) return null;
2549
+ const lines = raw.split("\n").filter(Boolean).slice(-50);
1221
2550
  const summaryParts: string[] = [];
1222
2551
 
1223
2552
  for (const line of lines.reverse()) {
@@ -1225,8 +2554,11 @@ async function getLastSessionSummary(profileName: string): Promise<string | null
1225
2554
  const msg = JSON.parse(line);
1226
2555
  if (msg.type === "assistant" && msg.message?.content) {
1227
2556
  const text = Array.isArray(msg.message.content)
1228
- ? msg.message.content.find((c: any) => c.type === "text")?.text ?? ""
1229
- : typeof msg.message.content === "string" ? msg.message.content : "";
2557
+ ? (msg.message.content.find((c: any) => c.type === "text")?.text ??
2558
+ "")
2559
+ : typeof msg.message.content === "string"
2560
+ ? msg.message.content
2561
+ : "";
1230
2562
  if (text.length > 20) {
1231
2563
  // Take first sentence
1232
2564
  const sentence = text.split(/[.!?\n]/)[0]?.trim();
@@ -1259,36 +2591,48 @@ function formatTimeAgo(date: Date): string {
1259
2591
  // #9: Skill chaining — detect common skill sequences from usage
1260
2592
  // ---------------------------------------------------------------------------
1261
2593
 
1262
- async function getSkillChains(skillsList: string[]): Promise<string | null> {
2594
+ export async function getSkillChains(
2595
+ skillsList: string[],
2596
+ projectsDir = join(homedir(), ".claude", "projects"),
2597
+ ): Promise<string | null> {
1263
2598
  try {
1264
- const projectsDir = join(homedir(), ".claude", "projects");
1265
- if (!existsSync(projectsDir)) return null;
2599
+ const projectEntries = await readdir(projectsDir).catch(() => null);
2600
+ if (!projectEntries) return null;
1266
2601
 
1267
- // Scan recent sessions for skill co-occurrence
1268
- const coOccurrence = new Map<string, Map<string, number>>();
2602
+ // Scan recent sessions for skill co-occurrence using async file reads
2603
+ // instead of a blocking grep subprocess. Mirrors the original grep -roh
2604
+ // behaviour: check both files directly in projectsDir and one level deep
2605
+ // inside subdirectories.
1269
2606
  const slugs = new Set(skillsList.map((s) => s.split("/").pop() ?? s));
2607
+ const SKILL_RE = /skills\/([a-z][a-z0-9-]*)\/SKILL\.md/g;
2608
+ const skillCounts = new Map<string, number>();
1270
2609
 
1271
- const res = spawnSync("grep", ["-roh", "skills/[a-z][a-z0-9-]*/SKILL.md", projectsDir], {
1272
- stdio: ["ignore", "pipe", "pipe"],
1273
- encoding: "utf8",
1274
- timeout: 2000,
1275
- });
1276
-
1277
- if (!res.stdout) return null;
2610
+ async function scanFileForSkills(filePath: string): Promise<void> {
2611
+ const content = await readFile(filePath, "utf8").catch(() => "");
2612
+ for (const m of content.matchAll(SKILL_RE)) {
2613
+ const slug = m[1]!;
2614
+ if (slugs.has(slug)) {
2615
+ skillCounts.set(slug, (skillCounts.get(slug) ?? 0) + 1);
2616
+ }
2617
+ }
2618
+ }
1278
2619
 
1279
- // Group skill reads by session file (co-occurrence within same session)
1280
- const sessionSkills = new Map<string, string[]>();
1281
- // We can't easily get per-file grouping from grep -r, so use a simpler heuristic:
1282
- // just find which skills from THIS profile are most commonly used together
1283
- const skillCounts = new Map<string, number>();
1284
- for (const line of res.stdout.split("\n")) {
1285
- const match = line.match(/skills\/([a-z][a-z0-9-]*)\/SKILL\.md/);
1286
- if (match && slugs.has(match[1]!)) {
1287
- skillCounts.set(match[1]!, (skillCounts.get(match[1]!) ?? 0) + 1);
2620
+ for (const entry of projectEntries) {
2621
+ const entryPath = join(projectsDir, entry);
2622
+ const subEntries = await readdir(entryPath).catch(() => null);
2623
+ if (subEntries === null) {
2624
+ // It's a file — scan it directly (mirrors grep -roh recursion depth 1)
2625
+ await scanFileForSkills(entryPath);
2626
+ } else {
2627
+ // It's a directory — scan all files inside
2628
+ for (const f of subEntries) {
2629
+ await scanFileForSkills(join(entryPath, f));
2630
+ }
1288
2631
  }
1289
2632
  }
1290
2633
 
1291
- // Find top 3 most-used skills and present as a workflow hint
2634
+ // We can't easily get per-file grouping, so use a simpler heuristic:
2635
+ // just find which skills from THIS profile are most commonly used together.
1292
2636
  const topSkills = [...skillCounts.entries()]
1293
2637
  .sort((a, b) => b[1] - a[1])
1294
2638
  .slice(0, 5)
@@ -1297,9 +2641,11 @@ async function getSkillChains(skillsList: string[]): Promise<string | null> {
1297
2641
  if (topSkills.length < 2) return null;
1298
2642
 
1299
2643
  // Build a simple chain from the top skills
1300
- return `Based on your usage patterns, common skill sequences:\n` +
2644
+ return (
2645
+ `Based on your usage patterns, common skill sequences:\n` +
1301
2646
  `- ${topSkills.slice(0, 3).join(" → ")}\n` +
1302
- (topSkills.length > 3 ? `- ${topSkills.slice(2, 5).join(" → ")}\n` : "");
2647
+ (topSkills.length > 3 ? `- ${topSkills.slice(2, 5).join(" → ")}\n` : "")
2648
+ );
1303
2649
  } catch {
1304
2650
  return null;
1305
2651
  }