contextos-agents 1.7.0 → 2.0.0-beta.3

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 (313) hide show
  1. package/.agents/AGENTS.md +16 -50
  2. package/.agents/adapters/aider/export.js +117 -99
  3. package/.agents/adapters/claude/export.js +68 -26
  4. package/.agents/adapters/copilot/export.js +90 -53
  5. package/.agents/adapters/cursor/export.js +100 -104
  6. package/.agents/adapters/drift-detector.js +196 -0
  7. package/.agents/adapters/gemini/export.js +76 -45
  8. package/.agents/adapters/pure-compiler.js +443 -0
  9. package/.agents/adapters/zed/export.js +104 -96
  10. package/.agents/compiled/registry.v2.json +504 -0
  11. package/.agents/compiled/registry.v2.sha256 +1 -0
  12. package/.agents/compiler/manifest-compiler.js +963 -0
  13. package/.agents/compiler/vendor/yaml.LICENSE.txt +13 -0
  14. package/.agents/compiler/vendor/yaml.SBOM.json +6 -0
  15. package/.agents/compiler/vendor/yaml.js +139 -0
  16. package/.agents/core/profiles/init.yaml +25 -0
  17. package/.agents/core/skills/context-manager/skill.yaml +3 -5
  18. package/.agents/core/skills/context-os/SKILL.md +3 -6
  19. package/.agents/core/skills/context-os/skill.yaml +3 -8
  20. package/.agents/core/skills/engineering-workflow/skill.yaml +1 -7
  21. package/.agents/core/skills/gemini-precision/skill.yaml +1 -6
  22. package/.agents/core/skills/gstack-roles/skill.yaml +3 -6
  23. package/.agents/core/skills/ponytail-mindset/skill.yaml +1 -7
  24. package/.agents/core/skills/security/skill.yaml +15 -3
  25. package/.agents/ctx.js +537 -112
  26. package/.agents/customization-dx.js +282 -0
  27. package/.agents/doctor.js +855 -66
  28. package/.agents/filesystem/index.js +71 -0
  29. package/.agents/filesystem/journaled-transaction.js +451 -0
  30. package/.agents/filesystem/lockfile-v2.js +275 -0
  31. package/.agents/filesystem/platform-hardening.js +222 -0
  32. package/.agents/filesystem/project-lock.js +218 -0
  33. package/.agents/filesystem/safe-path.js +256 -0
  34. package/.agents/generated/claude/skills/context-os/SKILL.md +1 -1
  35. package/.agents/generated/gemini/skills/context-os/SKILL.md +2 -2
  36. package/.agents/plugins/contextos/plugin.json +1 -1
  37. package/.agents/plugins.js +278 -64
  38. package/.agents/profiles.js +486 -51
  39. package/.agents/resolver/canonical-resolver.js +1348 -0
  40. package/.agents/resolver.js +50 -534
  41. package/.agents/rules/rule-catalog.js +525 -0
  42. package/.agents/schemas/attestation.review.v1.json +111 -0
  43. package/.agents/schemas/attestation.verification.v1.json +85 -0
  44. package/.agents/schemas/lockfile.v2.schema.json +134 -0
  45. package/.agents/schemas/profile.v2.schema.json +114 -0
  46. package/.agents/schemas/runtime.thread.v1.json +192 -0
  47. package/.agents/schemas/skill.manifest.v2.json +177 -0
  48. package/.agents/schemas/verification.spec.v1.json +39 -0
  49. package/.agents/schemas/workspace.graph.schema.json +106 -0
  50. package/.agents/skills-index.json +6 -166
  51. package/.agents/stats.js +9 -9
  52. package/.agents/transaction-core/event-store.js +288 -0
  53. package/.agents/transaction-core/idempotency.js +129 -0
  54. package/.agents/transaction-core/ipc-lock.js +311 -0
  55. package/.agents/transaction-core/plugin-supply-chain-bundle.js +436 -0
  56. package/.agents/validate.js +44 -1
  57. package/.agents/watch.js +354 -102
  58. package/.agents/workspace/workspace-graph.js +778 -0
  59. package/README.md +59 -387
  60. package/benchmarks/v2/analysis/statistics.js +140 -0
  61. package/benchmarks/v2/analysis/stats.js +69 -0
  62. package/benchmarks/v2/arms/arm-definitions.js +79 -0
  63. package/benchmarks/v2/dataset.schema.json +34 -0
  64. package/benchmarks/v2/evaluators/index.js +25 -0
  65. package/benchmarks/v2/evaluators/verified-success.js +116 -0
  66. package/benchmarks/v2/harness/runner.js +88 -0
  67. package/benchmarks/v2/pilot-tasks.json +392 -0
  68. package/bin/commands/recover.js +88 -0
  69. package/bin/commands/update.js +80 -17
  70. package/bin/commands.js +62 -25
  71. package/bin/index.js +138 -81
  72. package/bin/lib/lockfile.js +5 -3
  73. package/bin/lib/safe-writer.js +34 -3
  74. package/package.json +87 -72
  75. package/registry.json +2 -2
  76. package/registry.v2.schema.json +86 -0
  77. package/.agents/core/profiles/backend.yaml +0 -47
  78. package/.agents/core/profiles/enterprise.yaml +0 -46
  79. package/.agents/core/profiles/frontend.yaml +0 -46
  80. package/.agents/core/profiles/hackathon.yaml +0 -45
  81. package/.agents/core/profiles/mvp.yaml +0 -44
  82. package/.agents/core/profiles/startup.yaml +0 -48
  83. package/.agents/core/skills/adapters/EXAMPLES.md +0 -19
  84. package/.agents/core/skills/adapters/SKILL.md +0 -105
  85. package/.agents/core/skills/adapters/TROUBLESHOOTING.md +0 -7
  86. package/.agents/core/skills/adapters/VALIDATION.json +0 -12
  87. package/.agents/core/skills/adapters/skill.yaml +0 -16
  88. package/.agents/core/skills/architecture-diagrams/SKILL.md +0 -108
  89. package/.agents/core/skills/architecture-diagrams/VALIDATION.json +0 -12
  90. package/.agents/core/skills/architecture-diagrams/skill.yaml +0 -12
  91. package/.agents/core/skills/brutalist-design/SKILL.md +0 -150
  92. package/.agents/core/skills/brutalist-design/VALIDATION.json +0 -12
  93. package/.agents/core/skills/brutalist-design/skill.yaml +0 -12
  94. package/.agents/core/skills/database/EXAMPLES.md +0 -74
  95. package/.agents/core/skills/database/SKILL.md +0 -101
  96. package/.agents/core/skills/database/TROUBLESHOOTING.md +0 -18
  97. package/.agents/core/skills/database/VALIDATION.json +0 -11
  98. package/.agents/core/skills/database/skill.yaml +0 -31
  99. package/.agents/core/skills/ddd/EXAMPLES.md +0 -42
  100. package/.agents/core/skills/ddd/SKILL.md +0 -247
  101. package/.agents/core/skills/ddd/TROUBLESHOOTING.md +0 -19
  102. package/.agents/core/skills/ddd/VALIDATION.json +0 -12
  103. package/.agents/core/skills/ddd/ddd.md +0 -178
  104. package/.agents/core/skills/ddd/skill.yaml +0 -17
  105. package/.agents/core/skills/decisions/EXAMPLES.md +0 -35
  106. package/.agents/core/skills/decisions/SKILL.md +0 -90
  107. package/.agents/core/skills/decisions/TROUBLESHOOTING.md +0 -13
  108. package/.agents/core/skills/decisions/VALIDATION.json +0 -12
  109. package/.agents/core/skills/decisions/skill.yaml +0 -16
  110. package/.agents/core/skills/docker/EXAMPLES.md +0 -56
  111. package/.agents/core/skills/docker/SKILL.md +0 -63
  112. package/.agents/core/skills/docker/TROUBLESHOOTING.md +0 -18
  113. package/.agents/core/skills/docker/VALIDATION.json +0 -11
  114. package/.agents/core/skills/docker/skill.yaml +0 -29
  115. package/.agents/core/skills/fastapi/EXAMPLES.md +0 -36
  116. package/.agents/core/skills/fastapi/SKILL.md +0 -148
  117. package/.agents/core/skills/fastapi/TROUBLESHOOTING.md +0 -19
  118. package/.agents/core/skills/fastapi/VALIDATION.json +0 -12
  119. package/.agents/core/skills/fastapi/fastapi.md +0 -112
  120. package/.agents/core/skills/fastapi/skill.yaml +0 -17
  121. package/.agents/core/skills/generators/EXAMPLES.md +0 -19
  122. package/.agents/core/skills/generators/SKILL.md +0 -112
  123. package/.agents/core/skills/generators/TROUBLESHOOTING.md +0 -7
  124. package/.agents/core/skills/generators/VALIDATION.json +0 -12
  125. package/.agents/core/skills/generators/skill.yaml +0 -25
  126. package/.agents/core/skills/generators/templates/API.md +0 -77
  127. package/.agents/core/skills/generators/templates/ARCHITECTURE.md +0 -70
  128. package/.agents/core/skills/generators/templates/DATABASE.md +0 -42
  129. package/.agents/core/skills/generators/templates/DECISION.md +0 -46
  130. package/.agents/core/skills/generators/templates/PRD.md +0 -67
  131. package/.agents/core/skills/generators/templates/PROJECT_GRAPH.md +0 -56
  132. package/.agents/core/skills/generators/templates/ROADMAP.md +0 -51
  133. package/.agents/core/skills/generators/templates/TASKS.md +0 -43
  134. package/.agents/core/skills/generators/templates/UI.md +0 -73
  135. package/.agents/core/skills/graphify/EXAMPLES.md +0 -73
  136. package/.agents/core/skills/graphify/SKILL.md +0 -130
  137. package/.agents/core/skills/graphify/VALIDATION.json +0 -12
  138. package/.agents/core/skills/graphify/skill.yaml +0 -18
  139. package/.agents/core/skills/impeccable-design/EXAMPLES.md +0 -26
  140. package/.agents/core/skills/impeccable-design/SKILL.md +0 -201
  141. package/.agents/core/skills/impeccable-design/TROUBLESHOOTING.md +0 -19
  142. package/.agents/core/skills/impeccable-design/VALIDATION.json +0 -12
  143. package/.agents/core/skills/impeccable-design/skill.yaml +0 -20
  144. package/.agents/core/skills/interview-me/SKILL.md +0 -97
  145. package/.agents/core/skills/interview-me/VALIDATION.json +0 -12
  146. package/.agents/core/skills/interview-me/skill.yaml +0 -12
  147. package/.agents/core/skills/microservices/EXAMPLES.md +0 -38
  148. package/.agents/core/skills/microservices/SKILL.md +0 -164
  149. package/.agents/core/skills/microservices/TROUBLESHOOTING.md +0 -19
  150. package/.agents/core/skills/microservices/VALIDATION.json +0 -12
  151. package/.agents/core/skills/microservices/microservices.md +0 -119
  152. package/.agents/core/skills/microservices/skill.yaml +0 -17
  153. package/.agents/core/skills/minimalist-design/SKILL.md +0 -113
  154. package/.agents/core/skills/minimalist-design/VALIDATION.json +0 -12
  155. package/.agents/core/skills/minimalist-design/skill.yaml +0 -12
  156. package/.agents/core/skills/nestjs/EXAMPLES.md +0 -40
  157. package/.agents/core/skills/nestjs/SKILL.md +0 -139
  158. package/.agents/core/skills/nestjs/TROUBLESHOOTING.md +0 -19
  159. package/.agents/core/skills/nestjs/VALIDATION.json +0 -12
  160. package/.agents/core/skills/nestjs/nestjs.md +0 -103
  161. package/.agents/core/skills/nestjs/skill.yaml +0 -17
  162. package/.agents/core/skills/nextjs/EXAMPLES.md +0 -40
  163. package/.agents/core/skills/nextjs/SKILL.md +0 -163
  164. package/.agents/core/skills/nextjs/TROUBLESHOOTING.md +0 -19
  165. package/.agents/core/skills/nextjs/VALIDATION.json +0 -12
  166. package/.agents/core/skills/nextjs/nextjs.md +0 -67
  167. package/.agents/core/skills/nextjs/skill.yaml +0 -17
  168. package/.agents/core/skills/node/EXAMPLES.md +0 -80
  169. package/.agents/core/skills/node/SKILL.md +0 -128
  170. package/.agents/core/skills/node/TROUBLESHOOTING.md +0 -19
  171. package/.agents/core/skills/node/VALIDATION.json +0 -12
  172. package/.agents/core/skills/node/node.md +0 -87
  173. package/.agents/core/skills/node/skill.yaml +0 -17
  174. package/.agents/core/skills/performance/EXAMPLES.md +0 -30
  175. package/.agents/core/skills/performance/SKILL.md +0 -75
  176. package/.agents/core/skills/performance/TROUBLESHOOTING.md +0 -19
  177. package/.agents/core/skills/performance/VALIDATION.json +0 -12
  178. package/.agents/core/skills/performance/performance.md +0 -52
  179. package/.agents/core/skills/performance/skill.yaml +0 -17
  180. package/.agents/core/skills/react/EXAMPLES.md +0 -79
  181. package/.agents/core/skills/react/SKILL.md +0 -132
  182. package/.agents/core/skills/react/TROUBLESHOOTING.md +0 -19
  183. package/.agents/core/skills/react/VALIDATION.json +0 -12
  184. package/.agents/core/skills/react/react.md +0 -93
  185. package/.agents/core/skills/react/skill.yaml +0 -17
  186. package/.agents/core/skills/react-best-practices/SKILL.md +0 -155
  187. package/.agents/core/skills/react-best-practices/VALIDATION.json +0 -12
  188. package/.agents/core/skills/react-best-practices/skill.yaml +0 -14
  189. package/.agents/core/skills/redesign-audit/SKILL.md +0 -117
  190. package/.agents/core/skills/redesign-audit/VALIDATION.json +0 -12
  191. package/.agents/core/skills/redesign-audit/skill.yaml +0 -12
  192. package/.agents/core/skills/soft-design/SKILL.md +0 -108
  193. package/.agents/core/skills/soft-design/VALIDATION.json +0 -12
  194. package/.agents/core/skills/soft-design/skill.yaml +0 -12
  195. package/.agents/core/skills/state-management/EXAMPLES.md +0 -56
  196. package/.agents/core/skills/state-management/SKILL.md +0 -48
  197. package/.agents/core/skills/state-management/TROUBLESHOOTING.md +0 -18
  198. package/.agents/core/skills/state-management/VALIDATION.json +0 -11
  199. package/.agents/core/skills/state-management/skill.yaml +0 -28
  200. package/.agents/core/skills/subagent-orchestrator/SKILL.md +0 -117
  201. package/.agents/core/skills/subagent-orchestrator/VALIDATION.json +0 -12
  202. package/.agents/core/skills/subagent-orchestrator/skill.yaml +0 -12
  203. package/.agents/core/skills/system-design/EXAMPLES.md +0 -75
  204. package/.agents/core/skills/system-design/SKILL.md +0 -419
  205. package/.agents/core/skills/system-design/TROUBLESHOOTING.md +0 -19
  206. package/.agents/core/skills/system-design/VALIDATION.json +0 -12
  207. package/.agents/core/skills/system-design/skill.yaml +0 -20
  208. package/.agents/core/skills/system-design/system-design.md +0 -112
  209. package/.agents/core/skills/testing/EXAMPLES.md +0 -71
  210. package/.agents/core/skills/testing/SKILL.md +0 -70
  211. package/.agents/core/skills/testing/TROUBLESHOOTING.md +0 -18
  212. package/.agents/core/skills/testing/VALIDATION.json +0 -11
  213. package/.agents/core/skills/testing/skill.yaml +0 -32
  214. package/.agents/core/skills/typescript/EXAMPLES.md +0 -64
  215. package/.agents/core/skills/typescript/SKILL.md +0 -112
  216. package/.agents/core/skills/typescript/TROUBLESHOOTING.md +0 -19
  217. package/.agents/core/skills/typescript/VALIDATION.json +0 -12
  218. package/.agents/core/skills/typescript/skill.yaml +0 -17
  219. package/.agents/core/skills/typescript/typescript.md +0 -71
  220. package/.agents/core/skills/ui-design/EXAMPLES.md +0 -21
  221. package/.agents/core/skills/ui-design/SKILL.md +0 -124
  222. package/.agents/core/skills/ui-design/TROUBLESHOOTING.md +0 -19
  223. package/.agents/core/skills/ui-design/VALIDATION.json +0 -12
  224. package/.agents/core/skills/ui-design/skill.yaml +0 -17
  225. package/.agents/core/skills/ui-design/ui.md +0 -88
  226. package/.agents/core/skills/ui-ux-pro/EXAMPLES.md +0 -62
  227. package/.agents/core/skills/ui-ux-pro/SKILL.md +0 -375
  228. package/.agents/core/skills/ui-ux-pro/TROUBLESHOOTING.md +0 -19
  229. package/.agents/core/skills/ui-ux-pro/VALIDATION.json +0 -12
  230. package/.agents/core/skills/ui-ux-pro/skill.yaml +0 -19
  231. package/.agents/core/skills/ux-design/EXAMPLES.md +0 -36
  232. package/.agents/core/skills/ux-design/SKILL.md +0 -116
  233. package/.agents/core/skills/ux-design/TROUBLESHOOTING.md +0 -19
  234. package/.agents/core/skills/ux-design/VALIDATION.json +0 -12
  235. package/.agents/core/skills/ux-design/skill.yaml +0 -17
  236. package/.agents/core/skills/ux-design/ux.md +0 -80
  237. package/.agents/core/skills/vercel-optimize/SKILL.md +0 -83
  238. package/.agents/core/skills/vercel-optimize/VALIDATION.json +0 -12
  239. package/.agents/core/skills/vercel-optimize/scripts/collect-signals.mjs +0 -131
  240. package/.agents/core/skills/vercel-optimize/scripts/gate-investigations.mjs +0 -142
  241. package/.agents/core/skills/vercel-optimize/scripts/merge-signals.mjs +0 -143
  242. package/.agents/core/skills/vercel-optimize/scripts/scan-codebase.mjs +0 -174
  243. package/.agents/core/skills/vercel-optimize/skill.yaml +0 -18
  244. package/.agents/core/skills/web-accessibility/EXAMPLES.md +0 -39
  245. package/.agents/core/skills/web-accessibility/SKILL.md +0 -170
  246. package/.agents/core/skills/web-accessibility/TROUBLESHOOTING.md +0 -19
  247. package/.agents/core/skills/web-accessibility/VALIDATION.json +0 -12
  248. package/.agents/core/skills/web-accessibility/accessibility.md +0 -63
  249. package/.agents/core/skills/web-accessibility/skill.yaml +0 -17
  250. package/.agents/generated/claude/skills/adapters/SKILL.md +0 -126
  251. package/.agents/generated/claude/skills/architecture-diagrams/SKILL.md +0 -101
  252. package/.agents/generated/claude/skills/brutalist-design/SKILL.md +0 -145
  253. package/.agents/generated/claude/skills/database/SKILL.md +0 -191
  254. package/.agents/generated/claude/skills/ddd/SKILL.md +0 -305
  255. package/.agents/generated/claude/skills/decisions/SKILL.md +0 -134
  256. package/.agents/generated/claude/skills/docker/SKILL.md +0 -135
  257. package/.agents/generated/claude/skills/fastapi/SKILL.md +0 -200
  258. package/.agents/generated/claude/skills/generators/SKILL.md +0 -133
  259. package/.agents/generated/claude/skills/graphify/SKILL.md +0 -198
  260. package/.agents/generated/claude/skills/impeccable-design/SKILL.md +0 -241
  261. package/.agents/generated/claude/skills/interview-me/SKILL.md +0 -90
  262. package/.agents/generated/claude/skills/microservices/SKILL.md +0 -218
  263. package/.agents/generated/claude/skills/minimalist-design/SKILL.md +0 -108
  264. package/.agents/generated/claude/skills/nestjs/SKILL.md +0 -195
  265. package/.agents/generated/claude/skills/nextjs/SKILL.md +0 -219
  266. package/.agents/generated/claude/skills/node/SKILL.md +0 -224
  267. package/.agents/generated/claude/skills/performance/SKILL.md +0 -121
  268. package/.agents/generated/claude/skills/react/SKILL.md +0 -227
  269. package/.agents/generated/claude/skills/react-best-practices/SKILL.md +0 -146
  270. package/.agents/generated/claude/skills/redesign-audit/SKILL.md +0 -112
  271. package/.agents/generated/claude/skills/soft-design/SKILL.md +0 -103
  272. package/.agents/generated/claude/skills/state-management/SKILL.md +0 -120
  273. package/.agents/generated/claude/skills/subagent-orchestrator/SKILL.md +0 -110
  274. package/.agents/generated/claude/skills/system-design/SKILL.md +0 -507
  275. package/.agents/generated/claude/skills/testing/SKILL.md +0 -157
  276. package/.agents/generated/claude/skills/typescript/SKILL.md +0 -192
  277. package/.agents/generated/claude/skills/ui-design/SKILL.md +0 -161
  278. package/.agents/generated/claude/skills/ui-ux-pro/SKILL.md +0 -451
  279. package/.agents/generated/claude/skills/ux-design/SKILL.md +0 -168
  280. package/.agents/generated/claude/skills/vercel-optimize/SKILL.md +0 -76
  281. package/.agents/generated/claude/skills/web-accessibility/SKILL.md +0 -225
  282. package/.agents/generated/gemini/skills/adapters/SKILL.md +0 -135
  283. package/.agents/generated/gemini/skills/architecture-diagrams/SKILL.md +0 -107
  284. package/.agents/generated/gemini/skills/brutalist-design/SKILL.md +0 -151
  285. package/.agents/generated/gemini/skills/database/SKILL.md +0 -200
  286. package/.agents/generated/gemini/skills/ddd/SKILL.md +0 -314
  287. package/.agents/generated/gemini/skills/decisions/SKILL.md +0 -143
  288. package/.agents/generated/gemini/skills/docker/SKILL.md +0 -144
  289. package/.agents/generated/gemini/skills/fastapi/SKILL.md +0 -209
  290. package/.agents/generated/gemini/skills/generators/SKILL.md +0 -142
  291. package/.agents/generated/gemini/skills/graphify/SKILL.md +0 -205
  292. package/.agents/generated/gemini/skills/impeccable-design/SKILL.md +0 -250
  293. package/.agents/generated/gemini/skills/interview-me/SKILL.md +0 -96
  294. package/.agents/generated/gemini/skills/microservices/SKILL.md +0 -227
  295. package/.agents/generated/gemini/skills/minimalist-design/SKILL.md +0 -114
  296. package/.agents/generated/gemini/skills/nestjs/SKILL.md +0 -204
  297. package/.agents/generated/gemini/skills/nextjs/SKILL.md +0 -298
  298. package/.agents/generated/gemini/skills/node/SKILL.md +0 -323
  299. package/.agents/generated/gemini/skills/performance/SKILL.md +0 -185
  300. package/.agents/generated/gemini/skills/react/SKILL.md +0 -332
  301. package/.agents/generated/gemini/skills/react-best-practices/SKILL.md +0 -152
  302. package/.agents/generated/gemini/skills/redesign-audit/SKILL.md +0 -118
  303. package/.agents/generated/gemini/skills/soft-design/SKILL.md +0 -109
  304. package/.agents/generated/gemini/skills/state-management/SKILL.md +0 -129
  305. package/.agents/generated/gemini/skills/subagent-orchestrator/SKILL.md +0 -116
  306. package/.agents/generated/gemini/skills/system-design/SKILL.md +0 -631
  307. package/.agents/generated/gemini/skills/testing/SKILL.md +0 -166
  308. package/.agents/generated/gemini/skills/typescript/SKILL.md +0 -275
  309. package/.agents/generated/gemini/skills/ui-design/SKILL.md +0 -170
  310. package/.agents/generated/gemini/skills/ui-ux-pro/SKILL.md +0 -460
  311. package/.agents/generated/gemini/skills/ux-design/SKILL.md +0 -177
  312. package/.agents/generated/gemini/skills/vercel-optimize/SKILL.md +0 -82
  313. package/.agents/generated/gemini/skills/web-accessibility/SKILL.md +0 -300
package/bin/commands.js CHANGED
@@ -103,15 +103,14 @@ function formatStatusText(status) {
103
103
  const COMMAND_REGISTRY = {
104
104
  init: {
105
105
  name: 'init',
106
- description: 'Install and configure .agents/ in target project',
106
+ description: 'Compile and govern engineering context across AI coding agents.',
107
107
  usage: 'npx contextos-agents init [options]',
108
108
  requiresProject: false,
109
109
  options: [
110
110
  { flag: '--agent <target>', desc: 'Target agent (gemini, claude, cursor, auto)' },
111
111
  { flag: '--profile <name>', desc: 'Apply specific profile (mvp, startup, enterprise, etc.)' },
112
112
  { flag: '--auto', desc: 'Auto-detect tech stack and recommended profile' },
113
- { flag: '--minimal', desc: 'Install only 5 core essential skills' },
114
- { flag: '--with-mcp', desc: 'Install with MCP execution server enabled' },
113
+ { flag: '--minimal', desc: 'Install the 7-skill neutral bootstrap.' },
115
114
  { flag: '--force', desc: 'Overwrite existing installation' },
116
115
  { flag: '--dry-run', desc: 'Preview installation actions without writing' },
117
116
  { flag: '--skip-compile', desc: 'Skip auto-compiling skills after install' },
@@ -149,11 +148,35 @@ const COMMAND_REGISTRY = {
149
148
  },
150
149
  doctor: {
151
150
  name: 'doctor',
152
- description: 'Run project diagnostic health check',
153
- usage: 'contextos doctor [--json]',
151
+ description: 'Run project diagnostic health check (Doctor v2)',
152
+ usage: 'contextos doctor [--fix] [--strict] [--json]',
154
153
  requiresProject: false,
155
154
  options: [
156
- { flag: '--json', desc: 'Output health report in JSON format' },
155
+ { flag: '--fix', desc: 'Automatically remediate safe diagnostic issues and clean caches' },
156
+ { flag: '--strict', desc: 'Exit with non-zero code on any warning' },
157
+ { flag: '--json', desc: 'Output health report in versioned JSON format' },
158
+ ],
159
+ },
160
+ recover: {
161
+ name: 'recover',
162
+ description: 'List, rollback, or resume stuck filesystem transactions',
163
+ usage: 'contextos recover [--list] [--rollback <txId>] [--resume <txId>]',
164
+ requiresProject: true,
165
+ options: [
166
+ { flag: '--list', desc: 'List pending or broken transactions requiring recovery' },
167
+ { flag: '--rollback <txId>', desc: 'Rollback a broken transaction' },
168
+ { flag: '--resume <txId>', desc: 'Resume and complete a stuck transaction' },
169
+ ],
170
+ },
171
+ compile: {
172
+ name: 'compile',
173
+ description: 'Compile skill manifests into deterministic registry v2 (registry.v2.json)',
174
+ usage: 'contextos compile [--check] [--sarif] [--json]',
175
+ requiresProject: true,
176
+ options: [
177
+ { flag: '--check', desc: 'Validate manifests without writing to disk' },
178
+ { flag: '--sarif', desc: 'Output diagnostics in SARIF 2.1.0 format' },
179
+ { flag: '--json', desc: 'Output result in JSON format' },
157
180
  ],
158
181
  },
159
182
  validate: {
@@ -183,22 +206,39 @@ const COMMAND_REGISTRY = {
183
206
  },
184
207
  profile: {
185
208
  name: 'profile',
186
- description: 'Manage project profiles (list, show, apply, remove)',
187
- usage: 'contextos profile <list|show|apply|remove> [name]',
209
+ description: 'Manage project profiles (list, show, explain, apply, remove)',
210
+ usage: 'contextos profile <list|show|explain|apply|remove> [name] [--scope <pkg>] [--no-export] [--json]',
188
211
  requiresProject: true,
189
- options: [],
212
+ options: [
213
+ { flag: '--scope <path>', desc: 'Scope profile application or removal to specific package' },
214
+ { flag: '--no-export', desc: 'Skip re-exporting adapter skills after applying profile' },
215
+ { flag: '--json', desc: 'Output profile information in JSON format' },
216
+ ],
190
217
  },
191
218
  resolve: {
192
219
  name: 'resolve',
193
220
  description: 'Dynamically resolve minimal skills needed for a prompt or files',
194
- usage: 'contextos resolve <prompt> [--files <a,b>] [--phase <p>] [--json]',
221
+ usage: 'contextos resolve <prompt> [--files <a,b>] [--phase <p>] [--explain] [--budget <n>] [--json]',
195
222
  requiresProject: true,
196
223
  options: [
197
224
  { flag: '--files <list>', desc: 'Comma-separated list of touched files' },
198
225
  { flag: '--phase <name>', desc: 'Lifecycle phase (Define, Plan, Build, Verify, Review, Ship)' },
226
+ { flag: '--explain', desc: 'Display evidence scoring and decision breakdown' },
227
+ { flag: '--budget <tokens>', desc: 'Context token budget limit (default: 8000)' },
199
228
  { flag: '--json', desc: 'Output resolution in JSON format' },
200
229
  ],
201
230
  },
231
+ explain: {
232
+ name: 'explain',
233
+ description: 'Inspect rule catalog, enforcement levels, and automated checkers',
234
+ usage: 'contextos explain [ruleId|skillId] [--rules] [--checkers] [--json]',
235
+ requiresProject: true,
236
+ options: [
237
+ { flag: '--rules', desc: 'Display all declared rules with enforcement levels' },
238
+ { flag: '--checkers', desc: 'Display all registered automated enforcement checkers' },
239
+ { flag: '--json', desc: 'Output rule and enforcement data in JSON format' },
240
+ ],
241
+ },
202
242
  stats: {
203
243
  name: 'stats',
204
244
  description: 'Display token context savings report',
@@ -217,11 +257,13 @@ const COMMAND_REGISTRY = {
217
257
  },
218
258
  detect: {
219
259
  name: 'detect',
220
- description: 'Auto-detect project tech stack and recommend profile',
221
- usage: 'contextos detect [--json]',
260
+ description: 'Auto-detect project tech stack, workspace evidence graph, and scope',
261
+ usage: 'contextos detect [--scope <path>] [--explain] [--json]',
222
262
  requiresProject: false,
223
263
  options: [
224
- { flag: '--json', desc: 'Output detection result in JSON format' },
264
+ { flag: '--scope <path>', desc: 'Scope detection to nearest package of specific file or directory' },
265
+ { flag: '--explain', desc: 'Display evidence signals, internal dependencies, and stack breakdown' },
266
+ { flag: '--json', desc: 'Output workspace graph and detection in JSON format' },
225
267
  ],
226
268
  },
227
269
  'install-skill': {
@@ -240,22 +282,17 @@ const COMMAND_REGISTRY = {
240
282
  requiresProject: true,
241
283
  options: [],
242
284
  },
243
- 'setup-mcp': {
244
- name: 'setup-mcp',
245
- description: 'Add MCP execution server to an existing .agents/ project',
246
- usage: 'contextos setup-mcp [--force]',
285
+ recover: {
286
+ name: 'recover',
287
+ description: 'Recover from interrupted or failed multi-file transactions',
288
+ usage: 'contextos recover [--status] [--rollback [txId]] [--continue [txId]]',
247
289
  requiresProject: true,
248
290
  options: [
249
- { flag: '--force', desc: 'Overwrite existing .agents/mcp_config.json' },
291
+ { flag: '--status', desc: 'Inspect pending uncommitted transaction journals' },
292
+ { flag: '--rollback [txId]', desc: 'Roll back uncommitted or failed transaction' },
293
+ { flag: '--continue [txId]', desc: 'Attempt to resume and complete prepared transaction' },
250
294
  ],
251
295
  },
252
- 'clean-worktrees': {
253
- name: 'clean-worktrees',
254
- description: 'Clean up lingering .swarm-worktrees and swarm/* branches',
255
- usage: 'contextos clean-worktrees',
256
- requiresProject: false,
257
- options: [],
258
- },
259
296
  };
260
297
 
261
298
  /**
package/bin/index.js CHANGED
@@ -61,10 +61,10 @@ Options:
61
61
  --agent <name> Target AI agent or IDE (gemini, claude, cursor, auto)
62
62
  --dry-run Preview what will be copied without making changes
63
63
  --force Overwrite an existing .agents/ folder
64
- --minimal Install only 5 core skills (lightweight footprint)
64
+ --minimal Install only 7 core skills (lightweight footprint)
65
65
  --profile <name> Install a specific profile (mvp, startup, enterprise, frontend, backend)
66
66
  --auto Auto-detect tech stack and apply recommended profile
67
- --with-mcp, --mcp Install with MCP execution server enabled (.agents/mcp/ & mcp_config.json)
67
+ --with-mcp, --mcp [DEPRECATED] Use the separate @contextos/mcp package instead
68
68
  --skip-compile Skip running ctx.js export after installation
69
69
  --add-skill <ref> Install a community plugin skill after setup
70
70
 
@@ -76,6 +76,7 @@ Commands:
76
76
  doctor Run full project diagnostic health check
77
77
  audit Validate local skills (alias for validate)
78
78
  validate Validate local skills, frontmatter, and sync
79
+ compile Compile skill manifests into deterministic registry v2
79
80
  profile <subcmd> Manage profiles (list, apply, show, remove)
80
81
  export <target> Export skills (gemini, claude, cursor, copilot, aider, zed, all)
81
82
  resolve <prompt> Dynamically resolve minimal skills for a prompt or files
@@ -83,7 +84,7 @@ Commands:
83
84
  watch Start continuous file watcher and auto-sync daemon
84
85
  detect Analyze project and display detected tech stack & IDE
85
86
  install-skill Interactive skill installer (or pass <ref> / --from-repo)
86
- setup-mcp Add MCP execution server to an existing .agents/ project
87
+ setup-mcp [DEPRECATED] Add MCP execution server to an existing .agents/ project
87
88
 
88
89
  Profiles:
89
90
  mvp Fastest shipping, minimalist monolith, excludes microservices & DDD
@@ -103,7 +104,7 @@ Plugin ref formats:
103
104
  Examples:
104
105
  npx contextos-agents init Install .agents/ with auto-detected stack
105
106
  npx contextos-agents init --agent auto Install and configure for detected stack & IDE
106
- npx contextos-agents init --minimal Install only 5 core essential skills
107
+ npx contextos-agents init --minimal Install only 7 core essential skills
107
108
  npx contextos status Show project configuration and lockfile status
108
109
  npx contextos doctor Run project health check
109
110
  npx contextos export gemini Compile skills for Gemini
@@ -138,16 +139,95 @@ if (mainCommand === 'status') {
138
139
 
139
140
  // Detect command
140
141
  if (mainCommand === 'detect') {
141
- const detection = detectProjectAttributes(process.cwd());
142
- if (flags.json) {
143
- console.log(JSON.stringify(detection, null, 2));
142
+ const { WorkspaceGraphBuilder } = require('../.agents/workspace/workspace-graph.js');
143
+ const scopeIdx = args.indexOf('--scope');
144
+ const scopeArg = scopeIdx !== -1 && args[scopeIdx + 1] && !args[scopeIdx + 1].startsWith('--')
145
+ ? args[scopeIdx + 1]
146
+ : (args.find(a => a.startsWith('--scope=')) || '').split('=')[1];
147
+ const explain = args.includes('--explain');
148
+
149
+ const builder = new WorkspaceGraphBuilder();
150
+ const graph = builder.build(process.cwd());
151
+
152
+ if (scopeArg) {
153
+ const nearestPkg = builder.findNearestPackage(scopeArg, graph);
154
+ const evidence = builder.extractPackageEvidence(scopeArg, graph);
155
+
156
+ if (flags.json) {
157
+ console.log(JSON.stringify({
158
+ scope: scopeArg,
159
+ nearestPackage: nearestPkg,
160
+ evidence,
161
+ }, null, 2));
162
+ } else {
163
+ console.log('\n══════════════════════════════════════════');
164
+ console.log(' ContextOS — Workspace Scoped Detection');
165
+ console.log('══════════════════════════════════════════\n');
166
+ console.log(` Scope Path : ${scopeArg}`);
167
+ if (nearestPkg) {
168
+ console.log(` Nearest Package : ${nearestPkg.id} (${nearestPkg.ecosystem})`);
169
+ console.log(` Package Root : ${nearestPkg.root}`);
170
+ console.log(` Languages : ${nearestPkg.languages.join(', ') || 'unspecified'}`);
171
+ console.log(` Dependencies : ${nearestPkg.dependencies.length} (${nearestPkg.dependencies.slice(0, 8).join(', ')}${nearestPkg.dependencies.length > 8 ? '...' : ''})`);
172
+ console.log(` Configs : ${nearestPkg.configs.join(', ') || 'none'}`);
173
+ if (nearestPkg.internalDependencies.length > 0) {
174
+ console.log(` Internal Links : ${nearestPkg.internalDependencies.join(', ')}`);
175
+ }
176
+ if (evidence.length > 0) {
177
+ console.log('\n Scoped Evidence:');
178
+ for (const ev of evidence.slice(0, 10)) {
179
+ console.log(` • [${ev.source}] ${ev.target} (+${ev.weight}) — ${ev.description}`);
180
+ }
181
+ if (evidence.length > 10) {
182
+ console.log(` ... and ${evidence.length - 10} more signals`);
183
+ }
184
+ }
185
+ } else {
186
+ console.log(' Nearest Package : (none found)');
187
+ }
188
+ console.log('\n──────────────────────────────────────────\n');
189
+ }
190
+ } else if (flags.json) {
191
+ const detection = detectProjectAttributes(process.cwd());
192
+ console.log(JSON.stringify({
193
+ ...detection,
194
+ workspaceGraph: graph,
195
+ }, null, 2));
196
+ } else if (explain) {
197
+ console.log('\n══════════════════════════════════════════');
198
+ console.log(' ContextOS — Workspace Evidence Graph');
199
+ console.log('══════════════════════════════════════════\n');
200
+ console.log(` Repository Root : ${graph.repositoryRoot}`);
201
+ console.log(` Fingerprint : ${graph.fingerprint}`);
202
+ console.log(` Packages Found : ${graph.packages.length} ${graph.partial ? '(partial: true)' : ''}\n`);
203
+ for (const pkg of graph.packages) {
204
+ console.log(` • ${pkg.id} [${pkg.ecosystem}]`);
205
+ console.log(` Root : ${pkg.root}`);
206
+ console.log(` Manifests : ${pkg.manifests.join(', ')}`);
207
+ console.log(` Languages : ${pkg.languages.join(', ') || 'unspecified'}`);
208
+ console.log(` Dependencies : ${pkg.dependencies.length}`);
209
+ if (pkg.configs.length > 0) {
210
+ console.log(` Configs : ${pkg.configs.join(', ')}`);
211
+ }
212
+ if (pkg.internalDependencies.length > 0) {
213
+ console.log(` Internal Links : ${pkg.internalDependencies.join(', ')}`);
214
+ }
215
+ console.log('');
216
+ }
217
+ console.log('──────────────────────────────────────────\n');
144
218
  } else {
219
+ const detection = detectProjectAttributes(process.cwd());
145
220
  console.log('\nContextOS — Tech Stack & Environment Detection\n');
221
+ console.log(` Repository Root : ${graph.repositoryRoot}`);
222
+ console.log(` Packages Detected : ${graph.packages.map(p => `${p.id} (${p.root})`).join(', ')}`);
146
223
  console.log(` Detected Technologies : ${detection.summary.technologies.join(', ')}`);
147
224
  console.log(` Detected Environments : ${detection.summary.ides.join(', ')}`);
148
225
  console.log(` Recommended Profile : ${detection.summary.recommendedProfile}`);
149
226
  console.log(` Recommended Agents : ${detection.summary.recommendedAgents.join(', ')}`);
150
227
  console.log(` Recommended Skills : ${detection.summary.recommendedSkills.join(', ')}\n`);
228
+ console.log(' Commands:');
229
+ console.log(' contextos detect --scope <path> Scope detection to a specific file/subproject');
230
+ console.log(' contextos detect --explain Display full workspace evidence graph\n');
151
231
  }
152
232
  process.exit(0);
153
233
  }
@@ -155,14 +235,26 @@ if (mainCommand === 'detect') {
155
235
  // Doctor command
156
236
  if (mainCommand === 'doctor') {
157
237
  const doctorModule = require('../.agents/doctor.js');
158
- const result = doctorModule.runDoctor(process.cwd(), { json: flags.json });
238
+ const result = doctorModule.runDoctor(process.cwd(), {
239
+ json: flags.json,
240
+ fix: args.includes('--fix'),
241
+ strict: args.includes('--strict'),
242
+ });
159
243
  process.exit(result && result.ok === false ? 1 : 0);
160
244
  }
161
245
 
246
+ // Recover command
247
+ if (mainCommand === 'recover') {
248
+ const recoverModule = require('./commands/recover.js');
249
+ recoverModule(args, flags);
250
+ process.exit(0);
251
+ }
252
+
162
253
  // Proxy commands to .agents/ctx.js when executed in a ContextOS project
163
254
  const PROXY_COMMANDS = [
164
255
  'profile', 'export', 'validate', 'resolve', 'skill', 'index',
165
- 'clean-worktrees', 'stats', 'watch'
256
+ 'clean-worktrees', 'stats', 'watch', 'compile', 'explain',
257
+ 'thread'
166
258
  ];
167
259
 
168
260
  const ctxPath = path.join(process.cwd(), '.agents', 'ctx.js');
@@ -208,7 +300,7 @@ if (mainCommand === 'watch') {
208
300
  watchModule.runWatch(process.cwd());
209
301
  }
210
302
 
211
- const PROJECT_ONLY_COMMANDS = ['profile', 'export', 'validate', 'resolve', 'skill', 'index', 'clean-worktrees'];
303
+ const PROJECT_ONLY_COMMANDS = ['profile', 'export', 'validate', 'resolve', 'skill', 'index', 'clean-worktrees', 'compile', 'explain'];
212
304
  if (mainCommand && PROJECT_ONLY_COMMANDS.includes(mainCommand) && !hasLocalCtx) {
213
305
  console.error('[ERROR] .agents/ctx.js not found in current directory.');
214
306
  console.error(' Are you in a ContextOS project? Run `contextos` or `npx contextos-agents` first.');
@@ -338,46 +430,10 @@ if (mainCommand === 'install-skill') {
338
430
  })();
339
431
  }
340
432
  } else if (mainCommand === 'setup-mcp') {
341
- const targetPath = path.join(process.cwd(), '.agents');
342
- if (!fs.existsSync(targetPath)) {
343
- console.error('[ERROR] .agents/ folder not found in current directory.');
344
- console.error(' Run `npx contextos-agents` first or `npx contextos-agents --with-mcp`.');
345
- process.exit(1);
346
- }
347
-
348
- const sourceMcp = path.join(__dirname, '..', '.agents', 'mcp');
349
- const targetMcp = path.join(targetPath, 'mcp');
350
- if (!fs.existsSync(sourceMcp)) {
351
- console.error('[ERROR] Source MCP server bundle not found in package.');
352
- process.exit(1);
353
- }
354
-
355
- try {
356
- fs.cpSync(sourceMcp, targetMcp, { recursive: true, force: true });
357
- console.log('[OK] Installed ContextOS MCP execution server into .agents/mcp/');
358
-
359
- const mcpConfigPath = path.join(targetPath, 'mcp_config.json');
360
- if (!fs.existsSync(mcpConfigPath) || flags.force) {
361
- const defaultMcpConfig = {
362
- mcpServers: {
363
- "contextos": {
364
- command: "node",
365
- args: ["./.agents/mcp/server.mjs", "--dir", "."]
366
- }
367
- }
368
- };
369
- fs.writeFileSync(mcpConfigPath, JSON.stringify(defaultMcpConfig, null, 2));
370
- console.log('[OK] Created MCP configuration (.agents/mcp_config.json)');
371
- } else {
372
- console.log('[INFO] Existing .agents/mcp_config.json retained.');
373
- }
374
- console.log('\n[SUCCESS] ContextOS MCP execution layer is configured.');
375
- console.log('You can now use parallel subagents and git worktrees in your MCP-compatible IDE.\n');
376
- } catch (err) {
377
- console.error('[ERROR] Failed to configure MCP:', err.message);
378
- process.exit(1);
379
- }
380
- process.exit(0);
433
+ console.error('[DEPRECATED] The bundled MCP server has been moved to a separate package in v2.0.');
434
+ console.error(' To use the MCP Bridge or execution runtime, install @contextos/mcp:');
435
+ console.error(' npm install @contextos/mcp --save-dev');
436
+ process.exit(1);
381
437
  } else {
382
438
 
383
439
  // ── Paths ─────────────────────────────────────────────────────────────────────
@@ -389,7 +445,9 @@ const MINIMAL_SKILLS = new Set([
389
445
  'ponytail-mindset',
390
446
  'gstack-roles',
391
447
  'gemini-precision',
392
- 'react',
448
+ 'context-os',
449
+ 'context-manager',
450
+ 'security',
393
451
  ]);
394
452
 
395
453
  function uniqueSiblingPath(basePath, suffix) {
@@ -415,10 +473,8 @@ function installAtomically(source, target, options = {}) {
415
473
  force: true,
416
474
  filter: (src) => {
417
475
  const norm = src.replace(/\\/g, '/');
418
- if (!options.withMcp) {
419
- if (norm.endsWith('/mcp') || norm.includes('/mcp/') || norm.endsWith('/mcp_config.json')) {
420
- return false;
421
- }
476
+ if (norm.endsWith('/mcp') || norm.includes('/mcp/') || norm.endsWith('/mcp_config.json')) {
477
+ return false;
422
478
  }
423
479
  if (options.minimal) {
424
480
  const skillMatch = norm.match(/\/core\/skills\/([^/]+)/);
@@ -564,7 +620,12 @@ try {
564
620
  version,
565
621
  });
566
622
  } catch (err) {
567
- if (!flags.json) console.warn(`[WARN] Could not generate lockfile: ${err.message}`);
623
+ if (flags.json) {
624
+ console.error(JSON.stringify({ success: false, error: `Could not generate lockfile: ${err.message}` }));
625
+ } else {
626
+ console.error(`[ERROR] Could not generate lockfile: ${err.message}`);
627
+ }
628
+ process.exit(1);
568
629
  }
569
630
 
570
631
  if (!flags.json) {
@@ -582,21 +643,11 @@ try {
582
643
  }
583
644
  }
584
645
 
585
- // ── Create mcp_config.json only if --with-mcp ────────────────────────────────
646
+ // ── Deprecation warning for --with-mcp ────────────────────────────────────────────────
586
647
  if (flags.withMcp) {
587
- const mcpConfigPath = path.join(targetPath, 'mcp_config.json');
588
- if (!fs.existsSync(mcpConfigPath)) {
589
- const defaultMcpConfig = {
590
- mcpServers: {
591
- "contextos": {
592
- command: "node",
593
- args: ["./.agents/mcp/server.mjs", "--dir", "."]
594
- }
595
- }
596
- };
597
- fs.writeFileSync(mcpConfigPath, JSON.stringify(defaultMcpConfig, null, 2));
598
- if (!flags.json) console.log('[OK] Created default MCP configuration (.agents/mcp_config.json)');
599
- }
648
+ console.warn('\n[DEPRECATED] The --with-mcp flag is no longer supported in ContextOS v2.0.');
649
+ console.warn(' The MCP execution runtime has been moved to a separate package.');
650
+ console.warn(' To enable the MCP server, run: npm install @contextos/mcp --save-dev\n');
600
651
  }
601
652
 
602
653
  // ── Apply profile if requested or auto ──────────────────────────────────────
@@ -605,7 +656,12 @@ try {
605
656
  const applied = profiles.applyProfile(selectedProfile, process.cwd());
606
657
  if (!flags.json) console.log(`[OK] Applied profile '${applied.name}' (excluded: ${(applied.exclude_skills || []).join(', ') || 'none'})`);
607
658
  } catch (e) {
608
- if (!flags.json) console.warn(`[WARN] Could not apply profile '${selectedProfile}': ${e.message}`);
659
+ if (flags.json) {
660
+ console.error(JSON.stringify({ success: false, error: `Could not apply profile '${selectedProfile}': ${e.message}` }));
661
+ } else {
662
+ console.error(`[ERROR] Could not apply profile '${selectedProfile}': ${e.message}`);
663
+ }
664
+ process.exit(1);
609
665
  }
610
666
  }
611
667
 
@@ -626,10 +682,12 @@ try {
626
682
  stdio: flags.json ? 'ignore' : 'inherit',
627
683
  });
628
684
  } catch (e) {
629
- if (!flags.json) {
630
- console.warn(`[WARN] Skill compilation for '${ag}' failed — run manually:`);
631
- console.warn(` contextos export ${ag}`);
685
+ if (flags.json) {
686
+ console.error(JSON.stringify({ success: false, error: `Skill compilation for '${ag}' failed` }));
687
+ } else {
688
+ console.error(`[ERROR] Skill compilation for '${ag}' failed — run manually: contextos export ${ag}`);
632
689
  }
690
+ process.exit(1);
633
691
  }
634
692
  }
635
693
  }
@@ -649,10 +707,12 @@ try {
649
707
  stdio: flags.json ? 'ignore' : 'inherit',
650
708
  });
651
709
  } catch (e) {
652
- if (!flags.json) {
653
- console.warn(`[WARN] Skill install failed — run manually:`);
654
- console.warn(` node .agents/ctx.js skill add ${flags.addSkill}`);
710
+ if (flags.json) {
711
+ console.error(JSON.stringify({ success: false, error: `Skill install failed for ${flags.addSkill}` }));
712
+ } else {
713
+ console.error(`[ERROR] Skill install failed — run manually: node .agents/ctx.js skill add ${flags.addSkill}`);
655
714
  }
715
+ process.exit(1);
656
716
  }
657
717
  }
658
718
  }
@@ -686,10 +746,7 @@ try {
686
746
  console.log(' 6. Add community skills (plugins):');
687
747
  console.log(' contextos skill add username/my-skill');
688
748
  console.log(' contextos skill list');
689
- if (!flags.withMcp) {
690
- console.log(' 7. Enable MCP parallel subagents & worktrees (optional):');
691
- console.log(' contextos setup-mcp');
692
- }
749
+
693
750
  console.log('');
694
751
 
695
752
  } catch (error) {
@@ -59,7 +59,7 @@ function createLockfileData(options = {}) {
59
59
  return {
60
60
  schemaVersion: 1,
61
61
  installedPackage: options.installedPackage || 'contextos-agents',
62
- version: options.version || '1.7.0',
62
+ version: options.version || '1.7.1',
63
63
  selectedProfile: options.selectedProfile || 'default',
64
64
  installedAt: options.installedAt || new Date().toISOString(),
65
65
  managedFiles: options.managedFiles ? { ...options.managedFiles } : {},
@@ -124,8 +124,10 @@ function saveLockfile(projectDir, lockData) {
124
124
  try {
125
125
  if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath);
126
126
  } catch {}
127
- // Fallback direct write
128
- fs.writeFileSync(lockfilePath, content, 'utf8');
127
+ const atomicError = new Error(`Atomic lockfile update failed; original lockfile was preserved: ${err.message}`);
128
+ atomicError.code = 'CTX_LOCKFILE_ATOMIC_WRITE_FAILED';
129
+ atomicError.cause = err;
130
+ throw atomicError;
129
131
  }
130
132
  }
131
133
 
@@ -32,13 +32,43 @@ function atomicWriteFile(targetPath, content) {
32
32
  const tmpPath = `${targetPath}.tmp-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
33
33
  try {
34
34
  fs.writeFileSync(tmpPath, content, 'utf8');
35
- fs.renameSync(tmpPath, targetPath);
35
+
36
+ let renamed = false;
37
+ let lastError = null;
38
+ const maxRetries = 3;
39
+ const delays = [10, 50, 100];
40
+
41
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
42
+ try {
43
+ fs.renameSync(tmpPath, targetPath);
44
+ renamed = true;
45
+ break;
46
+ } catch (renameErr) {
47
+ lastError = renameErr;
48
+ // Check for transient locking errors common on Windows (EPERM, EBUSY, EACCES)
49
+ const isTransient = renameErr.code === 'EPERM' || renameErr.code === 'EBUSY' || renameErr.code === 'EACCES';
50
+ if (isTransient && attempt < maxRetries) {
51
+ const waitMs = delays[attempt];
52
+ try {
53
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, waitMs);
54
+ } catch {
55
+ const start = Date.now();
56
+ while (Date.now() - start < waitMs) {}
57
+ }
58
+ } else {
59
+ break;
60
+ }
61
+ }
62
+ }
63
+
64
+ if (!renamed) {
65
+ throw lastError || new Error(`Failed to atomically rename ${tmpPath} to ${targetPath}`);
66
+ }
36
67
  } catch (err) {
37
68
  try {
38
69
  if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath);
39
70
  } catch {}
40
- // Direct write fallback
41
- fs.writeFileSync(targetPath, content, 'utf8');
71
+ throw err;
42
72
  }
43
73
  }
44
74
 
@@ -256,4 +286,5 @@ module.exports = {
256
286
  executeFileWrite,
257
287
  planFileDelete,
258
288
  executeFileDelete,
289
+ cleanEmptyParentDirectories,
259
290
  };