contextos-agents 1.6.1 → 2.0.0-beta.2

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 (323) hide show
  1. package/.agents/AGENTS.md +6 -1
  2. package/.agents/adapters/aider/export.js +117 -97
  3. package/.agents/adapters/claude/export.js +68 -26
  4. package/.agents/adapters/copilot/export.js +90 -51
  5. package/.agents/adapters/cursor/export.js +83 -68
  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 +109 -62
  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/references/context-rules.md +59 -0
  18. package/.agents/core/skills/context-manager/skill.yaml +10 -5
  19. package/.agents/core/skills/context-os/SKILL.md +3 -6
  20. package/.agents/core/skills/context-os/skill.yaml +14 -8
  21. package/.agents/core/skills/engineering-workflow/SKILL.md +1 -1
  22. package/.agents/core/skills/engineering-workflow/skill.yaml +7 -7
  23. package/.agents/core/skills/gemini-precision/SKILL.md +4 -0
  24. package/.agents/core/skills/gemini-precision/skill.yaml +5 -6
  25. package/.agents/core/skills/gstack-roles/SKILL.md +3 -1
  26. package/.agents/core/skills/gstack-roles/skill.yaml +9 -6
  27. package/.agents/core/skills/ponytail-mindset/skill.yaml +7 -7
  28. package/.agents/core/skills/security/skill.yaml +21 -2
  29. package/.agents/ctx.js +587 -111
  30. package/.agents/customization-dx.js +282 -0
  31. package/.agents/doctor.js +877 -33
  32. package/.agents/filesystem/index.js +71 -0
  33. package/.agents/filesystem/journaled-transaction.js +451 -0
  34. package/.agents/filesystem/lockfile-v2.js +275 -0
  35. package/.agents/filesystem/platform-hardening.js +222 -0
  36. package/.agents/filesystem/project-lock.js +218 -0
  37. package/.agents/filesystem/safe-path.js +256 -0
  38. package/.agents/generated/claude/skills/context-os/SKILL.md +1 -1
  39. package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +1 -1
  40. package/.agents/generated/claude/skills/gemini-precision/SKILL.md +4 -0
  41. package/.agents/generated/claude/skills/gstack-roles/SKILL.md +3 -1
  42. package/.agents/generated/gemini/skills/context-os/SKILL.md +2 -2
  43. package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +1 -1
  44. package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +4 -0
  45. package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +3 -1
  46. package/.agents/plugins/contextos/hooks.json +25 -0
  47. package/.agents/plugins/contextos/plugin.json +19 -0
  48. package/.agents/plugins.js +432 -73
  49. package/.agents/profiles.js +507 -46
  50. package/.agents/resolver.js +50 -414
  51. package/.agents/schemas/attestation.review.v1.json +111 -0
  52. package/.agents/schemas/attestation.verification.v1.json +85 -0
  53. package/.agents/schemas/lockfile.v2.schema.json +134 -0
  54. package/.agents/schemas/profile.v2.schema.json +114 -0
  55. package/.agents/schemas/runtime.thread.v1.json +192 -0
  56. package/.agents/schemas/skill.manifest.v2.json +177 -0
  57. package/.agents/schemas/verification.spec.v1.json +39 -0
  58. package/.agents/schemas/workspace.graph.schema.json +106 -0
  59. package/.agents/stats.js +22 -9
  60. package/.agents/transaction-core/event-store.js +288 -0
  61. package/.agents/transaction-core/idempotency.js +129 -0
  62. package/.agents/transaction-core/ipc-lock.js +311 -0
  63. package/.agents/transaction-core/plugin-supply-chain-bundle.js +436 -0
  64. package/.agents/validate.js +143 -14
  65. package/.agents/watch.js +354 -102
  66. package/.agents/workspace/workspace-graph.js +778 -0
  67. package/README.md +59 -387
  68. package/benchmarks/v2/analysis/statistics.js +140 -0
  69. package/benchmarks/v2/analysis/stats.js +69 -0
  70. package/benchmarks/v2/arms/arm-definitions.js +79 -0
  71. package/benchmarks/v2/dataset.schema.json +34 -0
  72. package/benchmarks/v2/evaluators/index.js +25 -0
  73. package/benchmarks/v2/evaluators/verified-success.js +116 -0
  74. package/benchmarks/v2/harness/runner.js +88 -0
  75. package/benchmarks/v2/pilot-tasks.json +392 -0
  76. package/bin/commands/recover.js +88 -0
  77. package/bin/commands/uninstall.js +207 -0
  78. package/bin/commands/update.js +325 -0
  79. package/bin/commands.js +342 -0
  80. package/bin/index.js +326 -149
  81. package/bin/lib/detector.js +106 -0
  82. package/bin/lib/lockfile.js +253 -0
  83. package/bin/lib/safe-writer.js +290 -0
  84. package/package.json +85 -73
  85. package/registry.json +15 -7
  86. package/registry.schema.json +3 -1
  87. package/registry.v2.schema.json +86 -0
  88. package/.agents/core/profiles/backend.yaml +0 -47
  89. package/.agents/core/profiles/enterprise.yaml +0 -46
  90. package/.agents/core/profiles/frontend.yaml +0 -46
  91. package/.agents/core/profiles/hackathon.yaml +0 -45
  92. package/.agents/core/profiles/mvp.yaml +0 -44
  93. package/.agents/core/profiles/startup.yaml +0 -48
  94. package/.agents/core/skills/adapters/EXAMPLES.md +0 -19
  95. package/.agents/core/skills/adapters/SKILL.md +0 -105
  96. package/.agents/core/skills/adapters/TROUBLESHOOTING.md +0 -7
  97. package/.agents/core/skills/adapters/VALIDATION.json +0 -12
  98. package/.agents/core/skills/adapters/skill.yaml +0 -10
  99. package/.agents/core/skills/architecture-diagrams/SKILL.md +0 -108
  100. package/.agents/core/skills/architecture-diagrams/VALIDATION.json +0 -12
  101. package/.agents/core/skills/architecture-diagrams/skill.yaml +0 -8
  102. package/.agents/core/skills/brutalist-design/SKILL.md +0 -150
  103. package/.agents/core/skills/brutalist-design/VALIDATION.json +0 -12
  104. package/.agents/core/skills/brutalist-design/skill.yaml +0 -8
  105. package/.agents/core/skills/database/EXAMPLES.md +0 -74
  106. package/.agents/core/skills/database/SKILL.md +0 -101
  107. package/.agents/core/skills/database/TROUBLESHOOTING.md +0 -18
  108. package/.agents/core/skills/database/VALIDATION.json +0 -11
  109. package/.agents/core/skills/database/skill.yaml +0 -25
  110. package/.agents/core/skills/ddd/EXAMPLES.md +0 -42
  111. package/.agents/core/skills/ddd/SKILL.md +0 -247
  112. package/.agents/core/skills/ddd/TROUBLESHOOTING.md +0 -19
  113. package/.agents/core/skills/ddd/VALIDATION.json +0 -12
  114. package/.agents/core/skills/ddd/ddd.md +0 -178
  115. package/.agents/core/skills/ddd/skill.yaml +0 -10
  116. package/.agents/core/skills/decisions/EXAMPLES.md +0 -35
  117. package/.agents/core/skills/decisions/SKILL.md +0 -90
  118. package/.agents/core/skills/decisions/TROUBLESHOOTING.md +0 -13
  119. package/.agents/core/skills/decisions/VALIDATION.json +0 -12
  120. package/.agents/core/skills/decisions/skill.yaml +0 -10
  121. package/.agents/core/skills/docker/EXAMPLES.md +0 -56
  122. package/.agents/core/skills/docker/SKILL.md +0 -63
  123. package/.agents/core/skills/docker/TROUBLESHOOTING.md +0 -18
  124. package/.agents/core/skills/docker/VALIDATION.json +0 -11
  125. package/.agents/core/skills/docker/skill.yaml +0 -23
  126. package/.agents/core/skills/fastapi/EXAMPLES.md +0 -36
  127. package/.agents/core/skills/fastapi/SKILL.md +0 -148
  128. package/.agents/core/skills/fastapi/TROUBLESHOOTING.md +0 -19
  129. package/.agents/core/skills/fastapi/VALIDATION.json +0 -12
  130. package/.agents/core/skills/fastapi/fastapi.md +0 -112
  131. package/.agents/core/skills/fastapi/skill.yaml +0 -10
  132. package/.agents/core/skills/generators/EXAMPLES.md +0 -19
  133. package/.agents/core/skills/generators/SKILL.md +0 -112
  134. package/.agents/core/skills/generators/TROUBLESHOOTING.md +0 -7
  135. package/.agents/core/skills/generators/VALIDATION.json +0 -12
  136. package/.agents/core/skills/generators/skill.yaml +0 -10
  137. package/.agents/core/skills/generators/templates/API.md +0 -77
  138. package/.agents/core/skills/generators/templates/ARCHITECTURE.md +0 -70
  139. package/.agents/core/skills/generators/templates/DATABASE.md +0 -42
  140. package/.agents/core/skills/generators/templates/DECISION.md +0 -46
  141. package/.agents/core/skills/generators/templates/PRD.md +0 -67
  142. package/.agents/core/skills/generators/templates/PROJECT_GRAPH.md +0 -56
  143. package/.agents/core/skills/generators/templates/ROADMAP.md +0 -51
  144. package/.agents/core/skills/generators/templates/TASKS.md +0 -43
  145. package/.agents/core/skills/generators/templates/UI.md +0 -73
  146. package/.agents/core/skills/graphify/EXAMPLES.md +0 -73
  147. package/.agents/core/skills/graphify/SKILL.md +0 -130
  148. package/.agents/core/skills/graphify/VALIDATION.json +0 -12
  149. package/.agents/core/skills/graphify/skill.yaml +0 -13
  150. package/.agents/core/skills/impeccable-design/EXAMPLES.md +0 -26
  151. package/.agents/core/skills/impeccable-design/SKILL.md +0 -201
  152. package/.agents/core/skills/impeccable-design/TROUBLESHOOTING.md +0 -19
  153. package/.agents/core/skills/impeccable-design/VALIDATION.json +0 -12
  154. package/.agents/core/skills/impeccable-design/skill.yaml +0 -14
  155. package/.agents/core/skills/interview-me/SKILL.md +0 -97
  156. package/.agents/core/skills/interview-me/VALIDATION.json +0 -12
  157. package/.agents/core/skills/interview-me/skill.yaml +0 -8
  158. package/.agents/core/skills/microservices/EXAMPLES.md +0 -38
  159. package/.agents/core/skills/microservices/SKILL.md +0 -164
  160. package/.agents/core/skills/microservices/TROUBLESHOOTING.md +0 -19
  161. package/.agents/core/skills/microservices/VALIDATION.json +0 -12
  162. package/.agents/core/skills/microservices/microservices.md +0 -119
  163. package/.agents/core/skills/microservices/skill.yaml +0 -10
  164. package/.agents/core/skills/minimalist-design/SKILL.md +0 -113
  165. package/.agents/core/skills/minimalist-design/VALIDATION.json +0 -12
  166. package/.agents/core/skills/minimalist-design/skill.yaml +0 -8
  167. package/.agents/core/skills/nestjs/EXAMPLES.md +0 -40
  168. package/.agents/core/skills/nestjs/SKILL.md +0 -139
  169. package/.agents/core/skills/nestjs/TROUBLESHOOTING.md +0 -19
  170. package/.agents/core/skills/nestjs/VALIDATION.json +0 -12
  171. package/.agents/core/skills/nestjs/nestjs.md +0 -103
  172. package/.agents/core/skills/nestjs/skill.yaml +0 -10
  173. package/.agents/core/skills/nextjs/EXAMPLES.md +0 -40
  174. package/.agents/core/skills/nextjs/SKILL.md +0 -163
  175. package/.agents/core/skills/nextjs/TROUBLESHOOTING.md +0 -19
  176. package/.agents/core/skills/nextjs/VALIDATION.json +0 -12
  177. package/.agents/core/skills/nextjs/nextjs.md +0 -67
  178. package/.agents/core/skills/nextjs/skill.yaml +0 -10
  179. package/.agents/core/skills/node/EXAMPLES.md +0 -80
  180. package/.agents/core/skills/node/SKILL.md +0 -128
  181. package/.agents/core/skills/node/TROUBLESHOOTING.md +0 -19
  182. package/.agents/core/skills/node/VALIDATION.json +0 -12
  183. package/.agents/core/skills/node/node.md +0 -87
  184. package/.agents/core/skills/node/skill.yaml +0 -10
  185. package/.agents/core/skills/performance/EXAMPLES.md +0 -30
  186. package/.agents/core/skills/performance/SKILL.md +0 -75
  187. package/.agents/core/skills/performance/TROUBLESHOOTING.md +0 -19
  188. package/.agents/core/skills/performance/VALIDATION.json +0 -12
  189. package/.agents/core/skills/performance/performance.md +0 -52
  190. package/.agents/core/skills/performance/skill.yaml +0 -10
  191. package/.agents/core/skills/react/EXAMPLES.md +0 -79
  192. package/.agents/core/skills/react/SKILL.md +0 -132
  193. package/.agents/core/skills/react/TROUBLESHOOTING.md +0 -19
  194. package/.agents/core/skills/react/VALIDATION.json +0 -12
  195. package/.agents/core/skills/react/react.md +0 -93
  196. package/.agents/core/skills/react/skill.yaml +0 -10
  197. package/.agents/core/skills/react-best-practices/SKILL.md +0 -155
  198. package/.agents/core/skills/react-best-practices/VALIDATION.json +0 -12
  199. package/.agents/core/skills/react-best-practices/skill.yaml +0 -10
  200. package/.agents/core/skills/redesign-audit/SKILL.md +0 -117
  201. package/.agents/core/skills/redesign-audit/VALIDATION.json +0 -12
  202. package/.agents/core/skills/redesign-audit/skill.yaml +0 -8
  203. package/.agents/core/skills/soft-design/SKILL.md +0 -108
  204. package/.agents/core/skills/soft-design/VALIDATION.json +0 -12
  205. package/.agents/core/skills/soft-design/skill.yaml +0 -8
  206. package/.agents/core/skills/state-management/EXAMPLES.md +0 -56
  207. package/.agents/core/skills/state-management/SKILL.md +0 -48
  208. package/.agents/core/skills/state-management/TROUBLESHOOTING.md +0 -18
  209. package/.agents/core/skills/state-management/VALIDATION.json +0 -11
  210. package/.agents/core/skills/state-management/skill.yaml +0 -22
  211. package/.agents/core/skills/subagent-orchestrator/SKILL.md +0 -100
  212. package/.agents/core/skills/subagent-orchestrator/VALIDATION.json +0 -12
  213. package/.agents/core/skills/subagent-orchestrator/skill.yaml +0 -8
  214. package/.agents/core/skills/system-design/EXAMPLES.md +0 -75
  215. package/.agents/core/skills/system-design/SKILL.md +0 -419
  216. package/.agents/core/skills/system-design/TROUBLESHOOTING.md +0 -19
  217. package/.agents/core/skills/system-design/VALIDATION.json +0 -12
  218. package/.agents/core/skills/system-design/skill.yaml +0 -13
  219. package/.agents/core/skills/system-design/system-design.md +0 -112
  220. package/.agents/core/skills/testing/EXAMPLES.md +0 -71
  221. package/.agents/core/skills/testing/SKILL.md +0 -70
  222. package/.agents/core/skills/testing/TROUBLESHOOTING.md +0 -18
  223. package/.agents/core/skills/testing/VALIDATION.json +0 -11
  224. package/.agents/core/skills/testing/skill.yaml +0 -26
  225. package/.agents/core/skills/typescript/EXAMPLES.md +0 -64
  226. package/.agents/core/skills/typescript/SKILL.md +0 -112
  227. package/.agents/core/skills/typescript/TROUBLESHOOTING.md +0 -19
  228. package/.agents/core/skills/typescript/VALIDATION.json +0 -12
  229. package/.agents/core/skills/typescript/skill.yaml +0 -10
  230. package/.agents/core/skills/typescript/typescript.md +0 -71
  231. package/.agents/core/skills/ui-design/EXAMPLES.md +0 -21
  232. package/.agents/core/skills/ui-design/SKILL.md +0 -124
  233. package/.agents/core/skills/ui-design/TROUBLESHOOTING.md +0 -19
  234. package/.agents/core/skills/ui-design/VALIDATION.json +0 -12
  235. package/.agents/core/skills/ui-design/skill.yaml +0 -10
  236. package/.agents/core/skills/ui-design/ui.md +0 -88
  237. package/.agents/core/skills/ui-ux-pro/EXAMPLES.md +0 -62
  238. package/.agents/core/skills/ui-ux-pro/SKILL.md +0 -375
  239. package/.agents/core/skills/ui-ux-pro/TROUBLESHOOTING.md +0 -19
  240. package/.agents/core/skills/ui-ux-pro/VALIDATION.json +0 -12
  241. package/.agents/core/skills/ui-ux-pro/skill.yaml +0 -13
  242. package/.agents/core/skills/ux-design/EXAMPLES.md +0 -36
  243. package/.agents/core/skills/ux-design/SKILL.md +0 -116
  244. package/.agents/core/skills/ux-design/TROUBLESHOOTING.md +0 -19
  245. package/.agents/core/skills/ux-design/VALIDATION.json +0 -12
  246. package/.agents/core/skills/ux-design/skill.yaml +0 -10
  247. package/.agents/core/skills/ux-design/ux.md +0 -80
  248. package/.agents/core/skills/vercel-optimize/SKILL.md +0 -83
  249. package/.agents/core/skills/vercel-optimize/VALIDATION.json +0 -12
  250. package/.agents/core/skills/vercel-optimize/skill.yaml +0 -10
  251. package/.agents/core/skills/web-accessibility/EXAMPLES.md +0 -39
  252. package/.agents/core/skills/web-accessibility/SKILL.md +0 -170
  253. package/.agents/core/skills/web-accessibility/TROUBLESHOOTING.md +0 -19
  254. package/.agents/core/skills/web-accessibility/VALIDATION.json +0 -12
  255. package/.agents/core/skills/web-accessibility/accessibility.md +0 -63
  256. package/.agents/core/skills/web-accessibility/skill.yaml +0 -10
  257. package/.agents/generated/claude/skills/adapters/SKILL.md +0 -126
  258. package/.agents/generated/claude/skills/architecture-diagrams/SKILL.md +0 -101
  259. package/.agents/generated/claude/skills/brutalist-design/SKILL.md +0 -145
  260. package/.agents/generated/claude/skills/database/SKILL.md +0 -191
  261. package/.agents/generated/claude/skills/ddd/SKILL.md +0 -305
  262. package/.agents/generated/claude/skills/decisions/SKILL.md +0 -134
  263. package/.agents/generated/claude/skills/docker/SKILL.md +0 -135
  264. package/.agents/generated/claude/skills/fastapi/SKILL.md +0 -200
  265. package/.agents/generated/claude/skills/generators/SKILL.md +0 -133
  266. package/.agents/generated/claude/skills/graphify/SKILL.md +0 -198
  267. package/.agents/generated/claude/skills/impeccable-design/SKILL.md +0 -241
  268. package/.agents/generated/claude/skills/interview-me/SKILL.md +0 -90
  269. package/.agents/generated/claude/skills/microservices/SKILL.md +0 -218
  270. package/.agents/generated/claude/skills/minimalist-design/SKILL.md +0 -108
  271. package/.agents/generated/claude/skills/nestjs/SKILL.md +0 -195
  272. package/.agents/generated/claude/skills/nextjs/SKILL.md +0 -219
  273. package/.agents/generated/claude/skills/node/SKILL.md +0 -224
  274. package/.agents/generated/claude/skills/performance/SKILL.md +0 -121
  275. package/.agents/generated/claude/skills/react/SKILL.md +0 -227
  276. package/.agents/generated/claude/skills/react-best-practices/SKILL.md +0 -146
  277. package/.agents/generated/claude/skills/redesign-audit/SKILL.md +0 -112
  278. package/.agents/generated/claude/skills/soft-design/SKILL.md +0 -103
  279. package/.agents/generated/claude/skills/state-management/SKILL.md +0 -120
  280. package/.agents/generated/claude/skills/subagent-orchestrator/SKILL.md +0 -93
  281. package/.agents/generated/claude/skills/system-design/SKILL.md +0 -507
  282. package/.agents/generated/claude/skills/testing/SKILL.md +0 -157
  283. package/.agents/generated/claude/skills/typescript/SKILL.md +0 -192
  284. package/.agents/generated/claude/skills/ui-design/SKILL.md +0 -161
  285. package/.agents/generated/claude/skills/ui-ux-pro/SKILL.md +0 -451
  286. package/.agents/generated/claude/skills/ux-design/SKILL.md +0 -168
  287. package/.agents/generated/claude/skills/vercel-optimize/SKILL.md +0 -76
  288. package/.agents/generated/claude/skills/web-accessibility/SKILL.md +0 -225
  289. package/.agents/generated/gemini/skills/adapters/SKILL.md +0 -135
  290. package/.agents/generated/gemini/skills/architecture-diagrams/SKILL.md +0 -107
  291. package/.agents/generated/gemini/skills/brutalist-design/SKILL.md +0 -151
  292. package/.agents/generated/gemini/skills/database/SKILL.md +0 -200
  293. package/.agents/generated/gemini/skills/ddd/SKILL.md +0 -314
  294. package/.agents/generated/gemini/skills/decisions/SKILL.md +0 -143
  295. package/.agents/generated/gemini/skills/docker/SKILL.md +0 -144
  296. package/.agents/generated/gemini/skills/fastapi/SKILL.md +0 -209
  297. package/.agents/generated/gemini/skills/generators/SKILL.md +0 -142
  298. package/.agents/generated/gemini/skills/graphify/SKILL.md +0 -205
  299. package/.agents/generated/gemini/skills/impeccable-design/SKILL.md +0 -250
  300. package/.agents/generated/gemini/skills/interview-me/SKILL.md +0 -96
  301. package/.agents/generated/gemini/skills/microservices/SKILL.md +0 -227
  302. package/.agents/generated/gemini/skills/minimalist-design/SKILL.md +0 -114
  303. package/.agents/generated/gemini/skills/nestjs/SKILL.md +0 -204
  304. package/.agents/generated/gemini/skills/nextjs/SKILL.md +0 -298
  305. package/.agents/generated/gemini/skills/node/SKILL.md +0 -323
  306. package/.agents/generated/gemini/skills/performance/SKILL.md +0 -185
  307. package/.agents/generated/gemini/skills/react/SKILL.md +0 -332
  308. package/.agents/generated/gemini/skills/react-best-practices/SKILL.md +0 -152
  309. package/.agents/generated/gemini/skills/redesign-audit/SKILL.md +0 -118
  310. package/.agents/generated/gemini/skills/soft-design/SKILL.md +0 -109
  311. package/.agents/generated/gemini/skills/state-management/SKILL.md +0 -129
  312. package/.agents/generated/gemini/skills/subagent-orchestrator/SKILL.md +0 -99
  313. package/.agents/generated/gemini/skills/system-design/SKILL.md +0 -631
  314. package/.agents/generated/gemini/skills/testing/SKILL.md +0 -166
  315. package/.agents/generated/gemini/skills/typescript/SKILL.md +0 -275
  316. package/.agents/generated/gemini/skills/ui-design/SKILL.md +0 -170
  317. package/.agents/generated/gemini/skills/ui-ux-pro/SKILL.md +0 -460
  318. package/.agents/generated/gemini/skills/ux-design/SKILL.md +0 -177
  319. package/.agents/generated/gemini/skills/vercel-optimize/SKILL.md +0 -82
  320. package/.agents/generated/gemini/skills/web-accessibility/SKILL.md +0 -300
  321. package/.agents/mcp/runtime.py +0 -470
  322. package/.agents/mcp/server.mjs +0 -189271
  323. package/benchmarks/gemini-issues.js +0 -533
@@ -0,0 +1,392 @@
1
+ [
2
+ {
3
+ "id": "task-01-mock-task",
4
+ "description": "This is mock task 1 for the benchmark pilot.",
5
+ "expectedState": {
6
+ "filesToExist": [
7
+ "output-01.js"
8
+ ],
9
+ "filesToContain": {
10
+ "output-01.js": "console.log('mock 1');"
11
+ }
12
+ },
13
+ "hash": "sha256:7afaa346b4bf92bf9dc21e9ae809887412a86beb766842e99df7fee6573a4781"
14
+ },
15
+ {
16
+ "id": "task-02-mock-task",
17
+ "description": "This is mock task 2 for the benchmark pilot.",
18
+ "expectedState": {
19
+ "filesToExist": [
20
+ "output-02.js"
21
+ ],
22
+ "filesToContain": {
23
+ "output-02.js": "console.log('mock 2');"
24
+ }
25
+ },
26
+ "hash": "sha256:78686d2704d4d6900bb73f4941aa661a26a09f4346ab5e83281c0a18830ad1dd"
27
+ },
28
+ {
29
+ "id": "task-03-mock-task",
30
+ "description": "This is mock task 3 for the benchmark pilot.",
31
+ "expectedState": {
32
+ "filesToExist": [
33
+ "output-03.js"
34
+ ],
35
+ "filesToContain": {
36
+ "output-03.js": "console.log('mock 3');"
37
+ }
38
+ },
39
+ "hash": "sha256:1724980aa084bbaa16a8a69b664b783799bc75f8abe13ffc65b76843564fbbff"
40
+ },
41
+ {
42
+ "id": "task-04-mock-task",
43
+ "description": "This is mock task 4 for the benchmark pilot.",
44
+ "expectedState": {
45
+ "filesToExist": [
46
+ "output-04.js"
47
+ ],
48
+ "filesToContain": {
49
+ "output-04.js": "console.log('mock 4');"
50
+ }
51
+ },
52
+ "hash": "sha256:8f9ba36d8e59dd863b941cf6aba8709674901dba17f3e9c904e4da733538e38a"
53
+ },
54
+ {
55
+ "id": "task-05-mock-task",
56
+ "description": "This is mock task 5 for the benchmark pilot.",
57
+ "expectedState": {
58
+ "filesToExist": [
59
+ "output-05.js"
60
+ ],
61
+ "filesToContain": {
62
+ "output-05.js": "console.log('mock 5');"
63
+ }
64
+ },
65
+ "hash": "sha256:e7c08de777760acda054e9e20c19133287d1c245ef5efb6abaea6ec1ee3020e9"
66
+ },
67
+ {
68
+ "id": "task-06-mock-task",
69
+ "description": "This is mock task 6 for the benchmark pilot.",
70
+ "expectedState": {
71
+ "filesToExist": [
72
+ "output-06.js"
73
+ ],
74
+ "filesToContain": {
75
+ "output-06.js": "console.log('mock 6');"
76
+ }
77
+ },
78
+ "hash": "sha256:98c4ca9fa7207111d5816fe81f22b0e0cd27dc2b9d78ee9deb626d0a901f6921"
79
+ },
80
+ {
81
+ "id": "task-07-mock-task",
82
+ "description": "This is mock task 7 for the benchmark pilot.",
83
+ "expectedState": {
84
+ "filesToExist": [
85
+ "output-07.js"
86
+ ],
87
+ "filesToContain": {
88
+ "output-07.js": "console.log('mock 7');"
89
+ }
90
+ },
91
+ "hash": "sha256:014e4ceaa5a9e5112150d2536f78ecab3801305b5e95ceabf1de359314f9274f"
92
+ },
93
+ {
94
+ "id": "task-08-mock-task",
95
+ "description": "This is mock task 8 for the benchmark pilot.",
96
+ "expectedState": {
97
+ "filesToExist": [
98
+ "output-08.js"
99
+ ],
100
+ "filesToContain": {
101
+ "output-08.js": "console.log('mock 8');"
102
+ }
103
+ },
104
+ "hash": "sha256:f0470f4ad3dcb981ec0447de20036801ec638a0b7b32ae4dd8e6d1c94c08257e"
105
+ },
106
+ {
107
+ "id": "task-09-mock-task",
108
+ "description": "This is mock task 9 for the benchmark pilot.",
109
+ "expectedState": {
110
+ "filesToExist": [
111
+ "output-09.js"
112
+ ],
113
+ "filesToContain": {
114
+ "output-09.js": "console.log('mock 9');"
115
+ }
116
+ },
117
+ "hash": "sha256:e34d3152baeb112c9bd77f2381ea0cf9b902613c95d5ae2660b51a4e7ede2785"
118
+ },
119
+ {
120
+ "id": "task-10-mock-task",
121
+ "description": "This is mock task 10 for the benchmark pilot.",
122
+ "expectedState": {
123
+ "filesToExist": [
124
+ "output-10.js"
125
+ ],
126
+ "filesToContain": {
127
+ "output-10.js": "console.log('mock 10');"
128
+ }
129
+ },
130
+ "hash": "sha256:8bfdd14ef40300544ba24d517506314c6b8fd3075ecad82341f15eb2715692e0"
131
+ },
132
+ {
133
+ "id": "task-11-mock-task",
134
+ "description": "This is mock task 11 for the benchmark pilot.",
135
+ "expectedState": {
136
+ "filesToExist": [
137
+ "output-11.js"
138
+ ],
139
+ "filesToContain": {
140
+ "output-11.js": "console.log('mock 11');"
141
+ }
142
+ },
143
+ "hash": "sha256:555ada841ff8a3cc6b4ce15165f2d214f818bde82cdb71d942137ab132d499e6"
144
+ },
145
+ {
146
+ "id": "task-12-mock-task",
147
+ "description": "This is mock task 12 for the benchmark pilot.",
148
+ "expectedState": {
149
+ "filesToExist": [
150
+ "output-12.js"
151
+ ],
152
+ "filesToContain": {
153
+ "output-12.js": "console.log('mock 12');"
154
+ }
155
+ },
156
+ "hash": "sha256:712690d9849664fd0adbfeb295d9e47618024ad8c4be52adfa314e3d31481e50"
157
+ },
158
+ {
159
+ "id": "task-13-mock-task",
160
+ "description": "This is mock task 13 for the benchmark pilot.",
161
+ "expectedState": {
162
+ "filesToExist": [
163
+ "output-13.js"
164
+ ],
165
+ "filesToContain": {
166
+ "output-13.js": "console.log('mock 13');"
167
+ }
168
+ },
169
+ "hash": "sha256:aa050d240a6c17ad68f304685f77782bbb8ab5cc6dae23d3cbd845de6cf87304"
170
+ },
171
+ {
172
+ "id": "task-14-mock-task",
173
+ "description": "This is mock task 14 for the benchmark pilot.",
174
+ "expectedState": {
175
+ "filesToExist": [
176
+ "output-14.js"
177
+ ],
178
+ "filesToContain": {
179
+ "output-14.js": "console.log('mock 14');"
180
+ }
181
+ },
182
+ "hash": "sha256:ec88ecb7025218c79945d70e568f358e61452ab70d9c434b337411f6a8f468fc"
183
+ },
184
+ {
185
+ "id": "task-15-mock-task",
186
+ "description": "This is mock task 15 for the benchmark pilot.",
187
+ "expectedState": {
188
+ "filesToExist": [
189
+ "output-15.js"
190
+ ],
191
+ "filesToContain": {
192
+ "output-15.js": "console.log('mock 15');"
193
+ }
194
+ },
195
+ "hash": "sha256:5f1f6caf37ba31b3b91b876e5e592717abc9c97e0349c15e7ff3c2da2d133947"
196
+ },
197
+ {
198
+ "id": "task-16-mock-task",
199
+ "description": "This is mock task 16 for the benchmark pilot.",
200
+ "expectedState": {
201
+ "filesToExist": [
202
+ "output-16.js"
203
+ ],
204
+ "filesToContain": {
205
+ "output-16.js": "console.log('mock 16');"
206
+ }
207
+ },
208
+ "hash": "sha256:e8e6bfe60cd69b3373e667336d41d3c95fdbc5008f9c0eb99b1b94460e7ad0fd"
209
+ },
210
+ {
211
+ "id": "task-17-mock-task",
212
+ "description": "This is mock task 17 for the benchmark pilot.",
213
+ "expectedState": {
214
+ "filesToExist": [
215
+ "output-17.js"
216
+ ],
217
+ "filesToContain": {
218
+ "output-17.js": "console.log('mock 17');"
219
+ }
220
+ },
221
+ "hash": "sha256:3a41c6b074a0770e0fb6822ed252c69a77c05fa7bd97fcd9bf9b16f6cf193dd8"
222
+ },
223
+ {
224
+ "id": "task-18-mock-task",
225
+ "description": "This is mock task 18 for the benchmark pilot.",
226
+ "expectedState": {
227
+ "filesToExist": [
228
+ "output-18.js"
229
+ ],
230
+ "filesToContain": {
231
+ "output-18.js": "console.log('mock 18');"
232
+ }
233
+ },
234
+ "hash": "sha256:dbd6cc88cb73c805eef95f0cea09e09927f6b13e33fad1e69c049d174eab537f"
235
+ },
236
+ {
237
+ "id": "task-19-mock-task",
238
+ "description": "This is mock task 19 for the benchmark pilot.",
239
+ "expectedState": {
240
+ "filesToExist": [
241
+ "output-19.js"
242
+ ],
243
+ "filesToContain": {
244
+ "output-19.js": "console.log('mock 19');"
245
+ }
246
+ },
247
+ "hash": "sha256:b844124ce8543a3863a82699dd4cefb5e9b9391547934546974419be2b069895"
248
+ },
249
+ {
250
+ "id": "task-20-mock-task",
251
+ "description": "This is mock task 20 for the benchmark pilot.",
252
+ "expectedState": {
253
+ "filesToExist": [
254
+ "output-20.js"
255
+ ],
256
+ "filesToContain": {
257
+ "output-20.js": "console.log('mock 20');"
258
+ }
259
+ },
260
+ "hash": "sha256:ad1eb8063f7138e9fb193982a6bc4db5eed1e8fb4af21ddbda75270cb2c06d51"
261
+ },
262
+ {
263
+ "id": "task-21-mock-task",
264
+ "description": "This is mock task 21 for the benchmark pilot.",
265
+ "expectedState": {
266
+ "filesToExist": [
267
+ "output-21.js"
268
+ ],
269
+ "filesToContain": {
270
+ "output-21.js": "console.log('mock 21');"
271
+ }
272
+ },
273
+ "hash": "sha256:2dd74021abc2bb10e9bed627b7fb072311ed8e86b95526b8a57149cd4f89a7df"
274
+ },
275
+ {
276
+ "id": "task-22-mock-task",
277
+ "description": "This is mock task 22 for the benchmark pilot.",
278
+ "expectedState": {
279
+ "filesToExist": [
280
+ "output-22.js"
281
+ ],
282
+ "filesToContain": {
283
+ "output-22.js": "console.log('mock 22');"
284
+ }
285
+ },
286
+ "hash": "sha256:4865211d3986fbea264350c8965dba461d6eb5dec27beceaebd247c49b7f6fff"
287
+ },
288
+ {
289
+ "id": "task-23-mock-task",
290
+ "description": "This is mock task 23 for the benchmark pilot.",
291
+ "expectedState": {
292
+ "filesToExist": [
293
+ "output-23.js"
294
+ ],
295
+ "filesToContain": {
296
+ "output-23.js": "console.log('mock 23');"
297
+ }
298
+ },
299
+ "hash": "sha256:168e4241ee5aee2f186f0aab6856178a11fef6399d27f17f62cc25cb695aac0e"
300
+ },
301
+ {
302
+ "id": "task-24-mock-task",
303
+ "description": "This is mock task 24 for the benchmark pilot.",
304
+ "expectedState": {
305
+ "filesToExist": [
306
+ "output-24.js"
307
+ ],
308
+ "filesToContain": {
309
+ "output-24.js": "console.log('mock 24');"
310
+ }
311
+ },
312
+ "hash": "sha256:1b7f1e388d8f3e020f6f33a61f29bf40f9e56f203f1b634c47b36e70a5493f01"
313
+ },
314
+ {
315
+ "id": "task-25-mock-task",
316
+ "description": "This is mock task 25 for the benchmark pilot.",
317
+ "expectedState": {
318
+ "filesToExist": [
319
+ "output-25.js"
320
+ ],
321
+ "filesToContain": {
322
+ "output-25.js": "console.log('mock 25');"
323
+ }
324
+ },
325
+ "hash": "sha256:2ad0d0c64bbc6d5fc6bb10e398ce1e62ae9a6c73b4a13390646d94f90830ee04"
326
+ },
327
+ {
328
+ "id": "task-26-mock-task",
329
+ "description": "This is mock task 26 for the benchmark pilot.",
330
+ "expectedState": {
331
+ "filesToExist": [
332
+ "output-26.js"
333
+ ],
334
+ "filesToContain": {
335
+ "output-26.js": "console.log('mock 26');"
336
+ }
337
+ },
338
+ "hash": "sha256:b4eaa7cfe62d917b87a0311079eadd9a7c2488676f84b3bad540425c5d52ed5c"
339
+ },
340
+ {
341
+ "id": "task-27-mock-task",
342
+ "description": "This is mock task 27 for the benchmark pilot.",
343
+ "expectedState": {
344
+ "filesToExist": [
345
+ "output-27.js"
346
+ ],
347
+ "filesToContain": {
348
+ "output-27.js": "console.log('mock 27');"
349
+ }
350
+ },
351
+ "hash": "sha256:1d571536957594de46fbd9fe0710eefcc66d849ea53dde9ad61ee483941349e1"
352
+ },
353
+ {
354
+ "id": "task-28-mock-task",
355
+ "description": "This is mock task 28 for the benchmark pilot.",
356
+ "expectedState": {
357
+ "filesToExist": [
358
+ "output-28.js"
359
+ ],
360
+ "filesToContain": {
361
+ "output-28.js": "console.log('mock 28');"
362
+ }
363
+ },
364
+ "hash": "sha256:765672c715bfb9813a05949c7e9eff2a8cd91eed05b0ee026d177561b77411eb"
365
+ },
366
+ {
367
+ "id": "task-29-mock-task",
368
+ "description": "This is mock task 29 for the benchmark pilot.",
369
+ "expectedState": {
370
+ "filesToExist": [
371
+ "output-29.js"
372
+ ],
373
+ "filesToContain": {
374
+ "output-29.js": "console.log('mock 29');"
375
+ }
376
+ },
377
+ "hash": "sha256:7209b936824e13b1ec6eeec1503b0ef2ffd0698378ab5739857130773ebf743c"
378
+ },
379
+ {
380
+ "id": "task-30-mock-task",
381
+ "description": "This is mock task 30 for the benchmark pilot.",
382
+ "expectedState": {
383
+ "filesToExist": [
384
+ "output-30.js"
385
+ ],
386
+ "filesToContain": {
387
+ "output-30.js": "console.log('mock 30');"
388
+ }
389
+ },
390
+ "hash": "sha256:872fd6ef064d17a4315293952bf4d8704c47d3d94affa903695dfd7e2f9461e8"
391
+ }
392
+ ]
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { JournaledTransaction, TX_STATES } = require('../../.agents/filesystem/journaled-transaction.js');
5
+ const { ProjectMutationLock } = require('../../.agents/filesystem/project-lock.js');
6
+
7
+ // Minimal ANSI colors
8
+ const isTTY = process.stdout.isTTY;
9
+ const c = {
10
+ red: (s) => isTTY ? `\x1b[31m${s}\x1b[0m` : s,
11
+ green: (s) => isTTY ? `\x1b[32m${s}\x1b[0m` : s,
12
+ yellow: (s) => isTTY ? `\x1b[33m${s}\x1b[0m` : s,
13
+ cyan: (s) => isTTY ? `\x1b[36m${s}\x1b[0m` : s,
14
+ };
15
+
16
+ function recoverCommand(args, flags) {
17
+ const ROOT = process.cwd();
18
+
19
+ const isList = flags.list || args.includes('--list');
20
+
21
+ const rollbackIdx = args.indexOf('--rollback');
22
+ const txIdRollback = rollbackIdx !== -1 && args[rollbackIdx + 1] ? args[rollbackIdx + 1] : null;
23
+
24
+ const resumeIdx = args.indexOf('--resume');
25
+ const txIdResume = resumeIdx !== -1 && args[resumeIdx + 1] ? args[resumeIdx + 1] : null;
26
+
27
+ if (isList) {
28
+ const pending = JournaledTransaction.listPending(ROOT);
29
+ if (pending.length === 0) {
30
+ console.log(c.green('✓ No pending or stuck transactions found.'));
31
+ process.exit(0);
32
+ }
33
+ console.log(c.yellow(`Found ${pending.length} pending/stuck transaction(s):\n`));
34
+ pending.forEach(tx => {
35
+ console.log(` ID: ${c.cyan(tx.txId)}`);
36
+ console.log(` State: ${tx.state === TX_STATES.RECOVERY_REQUIRED ? c.red(tx.state) : c.yellow(tx.state)}`);
37
+ console.log(` Date: ${tx.createdAt}`);
38
+ if (tx.error) console.log(` Error: ${c.red(tx.error)}`);
39
+ console.log('');
40
+ });
41
+ console.log('To recover, run:');
42
+ console.log(` contextos recover --resume <ID>`);
43
+ console.log(` contextos recover --rollback <ID>`);
44
+ process.exit(0);
45
+ }
46
+
47
+ if (txIdRollback) {
48
+ console.log(c.cyan(`Attempting to rollback transaction: ${txIdRollback}`));
49
+ const projectLock = new ProjectMutationLock(ROOT);
50
+ let lockToken = null;
51
+ try {
52
+ lockToken = projectLock.acquire({ command: 'recover:rollback' });
53
+ const tx = JournaledTransaction.load(ROOT, txIdRollback);
54
+ tx.rollback();
55
+ console.log(c.green(`✓ Transaction ${txIdRollback} successfully rolled back.`));
56
+ } catch (err) {
57
+ console.error(c.red(`\n[ERROR] Rollback failed: ${err.message}`));
58
+ process.exit(1);
59
+ } finally {
60
+ if (lockToken) projectLock.release(lockToken);
61
+ }
62
+ process.exit(0);
63
+ }
64
+
65
+ if (txIdResume) {
66
+ console.log(c.cyan(`Attempting to resume transaction: ${txIdResume}`));
67
+ const projectLock = new ProjectMutationLock(ROOT);
68
+ let lockToken = null;
69
+ try {
70
+ lockToken = projectLock.acquire({ command: 'recover:resume' });
71
+ const tx = JournaledTransaction.load(ROOT, txIdResume);
72
+ // Simply calling commit() will resume if it's not COMMITTED/ROLLED_BACK
73
+ tx.commit();
74
+ console.log(c.green(`✓ Transaction ${txIdResume} successfully resumed and committed.`));
75
+ } catch (err) {
76
+ console.error(c.red(`\n[ERROR] Resume failed: ${err.message}`));
77
+ process.exit(1);
78
+ } finally {
79
+ if (lockToken) projectLock.release(lockToken);
80
+ }
81
+ process.exit(0);
82
+ }
83
+
84
+ console.log(c.red('Usage: contextos recover [--list] [--rollback <txId>] [--resume <txId>]'));
85
+ process.exit(1);
86
+ }
87
+
88
+ module.exports = recoverCommand;
@@ -0,0 +1,207 @@
1
+ /**
2
+ * bin/commands/uninstall.js
3
+ * ContextOS CLI — Safe Uninstall Command
4
+ *
5
+ * Removes ContextOS artifacts safely:
6
+ * - Only deletes clean managed files (content matches installation hash)
7
+ * - Never deletes user-modified managed files (USER_MODIFIED_PRESERVED)
8
+ * - Never deletes user-created custom skills or unmanaged files
9
+ * - Preserves .agents/ directory if user files remain
10
+ * - Removes .agents/ cleanly if no user files remain
11
+ * - Supports --dry-run
12
+ */
13
+
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+ const {
17
+ loadLockfile,
18
+ migrateExistingInstallation,
19
+ } = require('../lib/lockfile.js');
20
+ const {
21
+ planFileDelete,
22
+ executeFileDelete,
23
+ } = require('../lib/safe-writer.js');
24
+
25
+ /**
26
+ * Recursively count all files remaining in a directory (excluding specified skip names).
27
+ */
28
+ function countFiles(dir, skipNames = new Set()) {
29
+ let count = 0;
30
+ if (!fs.existsSync(dir)) return 0;
31
+
32
+ try {
33
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
34
+ if (skipNames.has(entry.name)) continue;
35
+ const full = path.join(dir, entry.name);
36
+ if (entry.isDirectory()) {
37
+ count += countFiles(full, skipNames);
38
+ } else if (entry.isFile()) {
39
+ count++;
40
+ }
41
+ }
42
+ } catch {
43
+ return 0;
44
+ }
45
+ return count;
46
+ }
47
+
48
+ /**
49
+ * Plan uninstallation for a target project.
50
+ */
51
+ function planUninstall(projectDir, options = {}) {
52
+ const targetAgentsDir = path.join(projectDir, '.agents');
53
+ if (!fs.existsSync(targetAgentsDir)) {
54
+ return {
55
+ ok: false,
56
+ error: 'NO_AGENTS_DIR',
57
+ message: 'No .agents/ directory found in the target project. Nothing to uninstall.',
58
+ plans: [],
59
+ summary: { delete: 0, skipModified: 0, skipUnmanaged: 0, missing: 0 },
60
+ };
61
+ }
62
+
63
+ const sourceAgentsDir = options.sourceAgentsDir || path.join(__dirname, '..', '..', '.agents');
64
+
65
+ // Load existing lockfile or build migration plan
66
+ let lockData = loadLockfile(projectDir);
67
+ if (!lockData) {
68
+ lockData = migrateExistingInstallation(projectDir, sourceAgentsDir, {
69
+ dryRun: true,
70
+ inMemory: true,
71
+ });
72
+ }
73
+
74
+ const plans = [];
75
+ if (lockData && lockData.managedFiles) {
76
+ for (const relPath of Object.keys(lockData.managedFiles)) {
77
+ const plan = planFileDelete({
78
+ projectDir,
79
+ relPath,
80
+ lockData,
81
+ });
82
+ plans.push(plan);
83
+ }
84
+ }
85
+
86
+ // Count unmanaged files in .agents that are not in lockData
87
+ const managedSet = new Set(Object.keys(lockData?.managedFiles || {}));
88
+ let unmanagedFilesCount = 0;
89
+
90
+ function findUnmanaged(currentDir) {
91
+ let entries;
92
+ try {
93
+ entries = fs.readdirSync(currentDir, { withFileTypes: true });
94
+ } catch {
95
+ return;
96
+ }
97
+
98
+ for (const entry of entries) {
99
+ const full = path.join(currentDir, entry.name);
100
+ if (entry.isDirectory()) {
101
+ findUnmanaged(full);
102
+ } else if (entry.isFile()) {
103
+ if (entry.name === 'contextos.lock.json') continue;
104
+ const rel = path.relative(projectDir, full).replace(/\\/g, '/');
105
+ if (!managedSet.has(rel)) {
106
+ unmanagedFilesCount++;
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ findUnmanaged(targetAgentsDir);
113
+
114
+ const summary = {
115
+ delete: plans.filter(p => p.action === 'DELETE').length,
116
+ skipModified: plans.filter(p => p.action === 'SKIP' && p.reason === 'USER_MODIFIED_PRESERVED').length,
117
+ missing: plans.filter(p => p.action === 'SKIP' && p.reason === 'ALREADY_MISSING').length,
118
+ skipUnmanaged: unmanagedFilesCount,
119
+ };
120
+
121
+ return {
122
+ ok: true,
123
+ plans,
124
+ summary,
125
+ lockData,
126
+ };
127
+ }
128
+
129
+ /**
130
+ * Run safe uninstall against a target project.
131
+ */
132
+ function runUninstall(projectDir = process.cwd(), options = {}) {
133
+ const dryRun = Boolean(options.dryRun);
134
+
135
+ console.log(`\nContextOS Safe Uninstall ${dryRun ? '[DRY-RUN]' : ''}`);
136
+ console.log(`Target: ${projectDir}`);
137
+
138
+ const planned = planUninstall(projectDir, options);
139
+ if (!planned.ok) {
140
+ console.error(`\n[ERROR] ${planned.message}`);
141
+ return planned;
142
+ }
143
+
144
+ const { lockData, plans, summary } = planned;
145
+
146
+ console.log('\nPlanned Actions:');
147
+ for (const item of plans) {
148
+ if (item.action === 'DELETE') {
149
+ console.log(` - DELETE ${item.relPath}`);
150
+ } else if (item.reason === 'USER_MODIFIED_PRESERVED') {
151
+ console.log(` = PRESERVE ${item.relPath} (modified by user — will NOT delete)`);
152
+ }
153
+ }
154
+
155
+ if (summary.skipUnmanaged > 0) {
156
+ console.log(` = PRESERVE ${summary.skipUnmanaged} unmanaged user file(s)/skill(s) in .agents/`);
157
+ }
158
+
159
+ console.log('\nSummary:');
160
+ console.log(` To delete: ${summary.delete}`);
161
+ console.log(` Preserved: ${summary.skipModified} (user-modified) + ${summary.skipUnmanaged} (user-created)`);
162
+
163
+ if (dryRun) {
164
+ console.log('\n[DRY-RUN] No files were deleted.');
165
+ return { ...planned, executed: false };
166
+ }
167
+
168
+ // Execute deletions
169
+ let deletedCount = 0;
170
+ for (const item of plans) {
171
+ if (item.action === 'DELETE') {
172
+ const res = executeFileDelete(item, lockData, { dryRun: false });
173
+ if (res.executed) deletedCount++;
174
+ }
175
+ }
176
+
177
+ const targetAgentsDir = path.join(projectDir, '.agents');
178
+ const lockfilePath = path.join(targetAgentsDir, 'contextos.lock.json');
179
+
180
+ // Count remaining files in .agents (excluding lockfile)
181
+ const remainingFiles = countFiles(targetAgentsDir, new Set(['contextos.lock.json']));
182
+
183
+ if (remainingFiles === 0) {
184
+ // Completely clean, remove lockfile and .agents directory
185
+ try {
186
+ if (fs.existsSync(lockfilePath)) fs.unlinkSync(lockfilePath);
187
+ fs.rmSync(targetAgentsDir, { recursive: true, force: true });
188
+ console.log('\n[OK] ContextOS completely uninstalled. .agents/ removed.');
189
+ } catch (err) {
190
+ console.warn(`[WARN] Could not remove .agents directory: ${err.message}`);
191
+ }
192
+ } else {
193
+ // User files or modified files remain — remove lockfile or keep remaining?
194
+ try {
195
+ if (fs.existsSync(lockfilePath)) fs.unlinkSync(lockfilePath);
196
+ } catch {}
197
+ console.log(`\n[OK] Clean ContextOS artifacts uninstalled (${deletedCount} removed).`);
198
+ console.log(`[INFO] .agents/ preserved because ${remainingFiles} user-modified or custom file(s) remain.`);
199
+ }
200
+
201
+ return { ...planned, executed: true, deletedCount, remainingFiles };
202
+ }
203
+
204
+ module.exports = {
205
+ planUninstall,
206
+ runUninstall,
207
+ };