@pi-harness/pi-harness 0.1.2 → 0.1.4

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 (914) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +31 -7
  3. package/apps/web/dist/assets/index-CihATCjR.css +2 -0
  4. package/apps/web/dist/assets/index-NzapJoGa.js +20 -0
  5. package/apps/web/dist/assets/markdown-vendor-DUdMWn0M.js +66 -0
  6. package/apps/web/dist/assets/react-vendor-BD7-wQo9.js +9 -0
  7. package/apps/web/dist/icons/app/android-192.png +0 -0
  8. package/apps/web/dist/icons/app/android-512.png +0 -0
  9. package/apps/web/dist/icons/app/app-blue-512.png +0 -0
  10. package/apps/web/dist/icons/app/app-store-1024.png +0 -0
  11. package/apps/web/dist/icons/app/apple-touch-icon-180.png +0 -0
  12. package/apps/web/dist/icons/app/maskable-512.png +0 -0
  13. package/apps/web/dist/icons/favicon/favicon-16.png +0 -0
  14. package/apps/web/dist/icons/favicon/favicon-32.png +0 -0
  15. package/apps/web/dist/icons/favicon/favicon-48.png +0 -0
  16. package/apps/web/dist/icons/png-blue/pi-256.png +0 -0
  17. package/apps/web/dist/icons/png-blue/pi-512.png +0 -0
  18. package/apps/web/dist/icons/png-ink/pi-1024.png +0 -0
  19. package/apps/web/dist/icons/png-ink/pi-128.png +0 -0
  20. package/apps/web/dist/icons/png-ink/pi-16.png +0 -0
  21. package/apps/web/dist/icons/png-ink/pi-24.png +0 -0
  22. package/apps/web/dist/icons/png-ink/pi-256.png +0 -0
  23. package/apps/web/dist/icons/png-ink/pi-32.png +0 -0
  24. package/apps/web/dist/icons/png-ink/pi-48.png +0 -0
  25. package/apps/web/dist/icons/png-ink/pi-512.png +0 -0
  26. package/apps/web/dist/icons/png-ink/pi-64.png +0 -0
  27. package/apps/web/dist/icons/png-white/pi-1024.png +0 -0
  28. package/apps/web/dist/icons/png-white/pi-128.png +0 -0
  29. package/apps/web/dist/icons/png-white/pi-16.png +0 -0
  30. package/apps/web/dist/icons/png-white/pi-24.png +0 -0
  31. package/apps/web/dist/icons/png-white/pi-256.png +0 -0
  32. package/apps/web/dist/icons/png-white/pi-32.png +0 -0
  33. package/apps/web/dist/icons/png-white/pi-48.png +0 -0
  34. package/apps/web/dist/icons/png-white/pi-512.png +0 -0
  35. package/apps/web/dist/icons/png-white/pi-64.png +0 -0
  36. package/apps/web/dist/icons/social/og-1200x630.png +0 -0
  37. package/apps/web/dist/icons/svg/app-icon-blue.svg +13 -0
  38. package/apps/web/dist/icons/svg/app-icon-ink.svg +13 -0
  39. package/apps/web/dist/icons/svg/favicon.svg +10 -0
  40. package/apps/web/dist/icons/svg/lockup-horizontal.svg +13 -0
  41. package/apps/web/dist/icons/svg/mark-blue.svg +10 -0
  42. package/apps/web/dist/icons/svg/mark-compact.svg +10 -0
  43. package/apps/web/dist/icons/svg/mark-ink.svg +10 -0
  44. package/apps/web/dist/icons/svg/mark-white.svg +10 -0
  45. package/apps/web/dist/icons/svg/mark.svg +10 -0
  46. package/apps/web/dist/index.html +18 -6
  47. package/apps/web/dist/manifest.webmanifest +14 -0
  48. package/apps/web/index.html +14 -4
  49. package/apps/web/package.json +11 -9
  50. package/apps/web/profile/cordis.yml +222 -1
  51. package/apps/web/public/icons/app/android-192.png +0 -0
  52. package/apps/web/public/icons/app/android-512.png +0 -0
  53. package/apps/web/public/icons/app/app-blue-512.png +0 -0
  54. package/apps/web/public/icons/app/app-store-1024.png +0 -0
  55. package/apps/web/public/icons/app/apple-touch-icon-180.png +0 -0
  56. package/apps/web/public/icons/app/maskable-512.png +0 -0
  57. package/apps/web/public/icons/favicon/favicon-16.png +0 -0
  58. package/apps/web/public/icons/favicon/favicon-32.png +0 -0
  59. package/apps/web/public/icons/favicon/favicon-48.png +0 -0
  60. package/apps/web/public/icons/png-blue/pi-256.png +0 -0
  61. package/apps/web/public/icons/png-blue/pi-512.png +0 -0
  62. package/apps/web/public/icons/png-ink/pi-1024.png +0 -0
  63. package/apps/web/public/icons/png-ink/pi-128.png +0 -0
  64. package/apps/web/public/icons/png-ink/pi-16.png +0 -0
  65. package/apps/web/public/icons/png-ink/pi-24.png +0 -0
  66. package/apps/web/public/icons/png-ink/pi-256.png +0 -0
  67. package/apps/web/public/icons/png-ink/pi-32.png +0 -0
  68. package/apps/web/public/icons/png-ink/pi-48.png +0 -0
  69. package/apps/web/public/icons/png-ink/pi-512.png +0 -0
  70. package/apps/web/public/icons/png-ink/pi-64.png +0 -0
  71. package/apps/web/public/icons/png-white/pi-1024.png +0 -0
  72. package/apps/web/public/icons/png-white/pi-128.png +0 -0
  73. package/apps/web/public/icons/png-white/pi-16.png +0 -0
  74. package/apps/web/public/icons/png-white/pi-24.png +0 -0
  75. package/apps/web/public/icons/png-white/pi-256.png +0 -0
  76. package/apps/web/public/icons/png-white/pi-32.png +0 -0
  77. package/apps/web/public/icons/png-white/pi-48.png +0 -0
  78. package/apps/web/public/icons/png-white/pi-512.png +0 -0
  79. package/apps/web/public/icons/png-white/pi-64.png +0 -0
  80. package/apps/web/public/icons/social/og-1200x630.png +0 -0
  81. package/apps/web/public/icons/svg/app-icon-blue.svg +13 -0
  82. package/apps/web/public/icons/svg/app-icon-ink.svg +13 -0
  83. package/apps/web/public/icons/svg/favicon.svg +10 -0
  84. package/apps/web/public/icons/svg/lockup-horizontal.svg +13 -0
  85. package/apps/web/public/icons/svg/mark-blue.svg +10 -0
  86. package/apps/web/public/icons/svg/mark-compact.svg +10 -0
  87. package/apps/web/public/icons/svg/mark-ink.svg +10 -0
  88. package/apps/web/public/icons/svg/mark-white.svg +10 -0
  89. package/apps/web/public/icons/svg/mark.svg +10 -0
  90. package/apps/web/public/manifest.webmanifest +14 -0
  91. package/apps/web/server-dist/bin.js +19 -6
  92. package/apps/web/server-dist/bin.js.map +1 -1
  93. package/apps/web/src/command-palette.ts +28 -7
  94. package/apps/web/src/file-diff.ts +15 -10
  95. package/apps/web/src/main.ts +4 -1
  96. package/apps/web/src/runtime.css +17 -4
  97. package/apps/web/src/server/bin.ts +24 -7
  98. package/apps/web/src/style.css +2618 -8
  99. package/apps/web/src/tailwind.css +25 -0
  100. package/apps/web/tsconfig.build.json +5 -1
  101. package/apps/web/tsconfig.json +1 -1
  102. package/apps/web/vite.config.ts +20 -0
  103. package/package.json +29 -17
  104. package/packages/api-gateway/LICENSE +9 -0
  105. package/packages/api-gateway/dist/index.d.ts.map +1 -1
  106. package/packages/api-gateway/dist/index.js +1188 -42
  107. package/packages/api-gateway/dist/index.js.map +1 -1
  108. package/packages/api-gateway/dist/marketplace-entries/official/agent-teams.json +31 -0
  109. package/packages/api-gateway/dist/marketplace-entries/official/anchored-standard.json +29 -0
  110. package/packages/api-gateway/dist/marketplace-entries/official/annotation.json +28 -0
  111. package/packages/api-gateway/dist/marketplace-entries/official/archify.json +31 -0
  112. package/packages/api-gateway/dist/marketplace-entries/official/at-file.json +28 -0
  113. package/packages/api-gateway/dist/marketplace-entries/official/auto-mode.json +32 -0
  114. package/packages/api-gateway/dist/marketplace-entries/official/better-sidebar.json +32 -0
  115. package/packages/api-gateway/dist/marketplace-entries/official/browser-fetch.json +28 -0
  116. package/packages/api-gateway/dist/marketplace-entries/official/browser-session.json +29 -0
  117. package/packages/api-gateway/dist/marketplace-entries/official/canvas-draw.json +29 -0
  118. package/packages/api-gateway/dist/marketplace-entries/official/change-verifier.json +30 -0
  119. package/packages/api-gateway/dist/marketplace-entries/official/cleaner.json +29 -0
  120. package/packages/api-gateway/dist/marketplace-entries/official/cli-notifier.json +30 -0
  121. package/packages/api-gateway/dist/marketplace-entries/official/code2skill.json +29 -0
  122. package/packages/api-gateway/dist/marketplace-entries/official/colleague-skill.json +30 -0
  123. package/packages/api-gateway/dist/marketplace-entries/official/context-doctor.json +30 -0
  124. package/packages/api-gateway/dist/marketplace-entries/official/context.json +28 -0
  125. package/packages/api-gateway/dist/marketplace-entries/official/cordis-group.json +16 -0
  126. package/packages/api-gateway/dist/marketplace-entries/official/cordis-logger-console.json +16 -0
  127. package/packages/api-gateway/dist/marketplace-entries/official/cordis-timer.json +16 -0
  128. package/packages/api-gateway/dist/marketplace-entries/official/cost-meter.json +31 -0
  129. package/packages/api-gateway/dist/marketplace-entries/official/dependency-checker.json +31 -0
  130. package/packages/api-gateway/dist/marketplace-entries/official/docker-sandbox.json +29 -0
  131. package/packages/api-gateway/dist/marketplace-entries/official/fail-logger.json +29 -0
  132. package/packages/api-gateway/dist/marketplace-entries/official/genui.json +28 -0
  133. package/packages/api-gateway/dist/marketplace-entries/official/git-time-capsule.json +30 -0
  134. package/packages/api-gateway/dist/marketplace-entries/official/graph-memory.json +29 -0
  135. package/packages/api-gateway/dist/marketplace-entries/official/history-compressor.json +33 -0
  136. package/packages/api-gateway/dist/marketplace-entries/official/hol-guard.json +29 -0
  137. package/packages/api-gateway/dist/marketplace-entries/official/i18n-pair.json +29 -0
  138. package/packages/api-gateway/dist/marketplace-entries/official/image-compressor.json +29 -0
  139. package/packages/api-gateway/dist/marketplace-entries/official/llm-verifier.json +32 -0
  140. package/packages/api-gateway/dist/marketplace-entries/official/mcp-client.json +29 -0
  141. package/packages/api-gateway/dist/marketplace-entries/official/mcp-panel.json +29 -0
  142. package/packages/api-gateway/dist/marketplace-entries/official/memory.json +28 -0
  143. package/packages/api-gateway/dist/marketplace-entries/official/mirage-bridge.json +33 -0
  144. package/packages/api-gateway/dist/marketplace-entries/official/mock-server.json +29 -0
  145. package/packages/api-gateway/dist/marketplace-entries/official/modlens.json +28 -0
  146. package/packages/api-gateway/dist/marketplace-entries/official/module-search.json +30 -0
  147. package/packages/api-gateway/dist/marketplace-entries/official/obsidian-sync.json +29 -0
  148. package/packages/api-gateway/dist/marketplace-entries/official/openpets.json +29 -0
  149. package/packages/api-gateway/dist/marketplace-entries/official/plan-execute.json +29 -0
  150. package/packages/api-gateway/dist/marketplace-entries/official/plugin-check.json +29 -0
  151. package/packages/api-gateway/dist/marketplace-entries/official/plugin-dev.json +29 -0
  152. package/packages/api-gateway/dist/marketplace-entries/official/plugin-finder.json +32 -0
  153. package/packages/api-gateway/dist/marketplace-entries/official/plugin-radar.json +28 -0
  154. package/packages/api-gateway/dist/marketplace-entries/official/plugin-stars.json +29 -0
  155. package/packages/api-gateway/dist/marketplace-entries/official/prompt-guard.json +28 -0
  156. package/packages/api-gateway/dist/marketplace-entries/official/prompt-library.json +30 -0
  157. package/packages/api-gateway/dist/marketplace-entries/official/readme-gen.json +31 -0
  158. package/packages/api-gateway/dist/marketplace-entries/official/recall-unread.json +29 -0
  159. package/packages/api-gateway/dist/marketplace-entries/official/reverse-skill.json +30 -0
  160. package/packages/api-gateway/dist/marketplace-entries/official/reviewer-bot.json +29 -0
  161. package/packages/api-gateway/dist/marketplace-entries/official/runtime-doctor.json +32 -0
  162. package/packages/api-gateway/dist/marketplace-entries/official/secure-audit.json +30 -0
  163. package/packages/api-gateway/dist/marketplace-entries/official/session-bookmarks.json +30 -0
  164. package/packages/api-gateway/dist/marketplace-entries/official/session-bridge.json +30 -0
  165. package/packages/api-gateway/dist/marketplace-entries/official/session-compare.json +30 -0
  166. package/packages/api-gateway/dist/marketplace-entries/official/session-export.json +30 -0
  167. package/packages/api-gateway/dist/marketplace-entries/official/session-insights.json +29 -0
  168. package/packages/api-gateway/dist/marketplace-entries/official/session-search.json +30 -0
  169. package/packages/api-gateway/dist/marketplace-entries/official/skill-catalog.json +31 -0
  170. package/packages/api-gateway/dist/marketplace-entries/official/skill-guard.json +29 -0
  171. package/packages/api-gateway/dist/marketplace-entries/official/sql-lens.json +29 -0
  172. package/packages/api-gateway/dist/marketplace-entries/official/synapse.json +28 -0
  173. package/packages/api-gateway/dist/marketplace-entries/official/tab-manager.json +29 -0
  174. package/packages/api-gateway/dist/marketplace-entries/official/taskboard.json +29 -0
  175. package/packages/api-gateway/dist/marketplace-entries/official/telemetry-blocker.json +29 -0
  176. package/packages/api-gateway/dist/marketplace-entries/official/test-harness.json +29 -0
  177. package/packages/api-gateway/dist/marketplace-entries/official/theme-studio.json +32 -0
  178. package/packages/api-gateway/dist/marketplace-entries/official/token-guard.json +32 -0
  179. package/packages/api-gateway/dist/marketplace-entries/official/turn-rewind.json +29 -0
  180. package/packages/api-gateway/dist/marketplace-entries/official/undo-savepoint.json +28 -0
  181. package/packages/api-gateway/dist/marketplace-entries/official/vision-toolkit.json +29 -0
  182. package/packages/api-gateway/dist/marketplace-entries/official/web-research.json +29 -0
  183. package/packages/api-gateway/dist/marketplace-entries/official/workspace-navigator.json +32 -0
  184. package/packages/api-gateway/dist/marketplace-entries/official/workspace-search.json +29 -0
  185. package/packages/api-gateway/dist/marketplace-entries/official/yaml-validator.json +29 -0
  186. package/packages/api-gateway/dist/marketplace.d.ts +40 -2
  187. package/packages/api-gateway/dist/marketplace.d.ts.map +1 -1
  188. package/packages/api-gateway/dist/marketplace.js +225 -19
  189. package/packages/api-gateway/dist/marketplace.js.map +1 -1
  190. package/packages/api-gateway/dist/workspaces.d.ts +8 -0
  191. package/packages/api-gateway/dist/workspaces.d.ts.map +1 -0
  192. package/packages/api-gateway/dist/workspaces.js +14 -0
  193. package/packages/api-gateway/dist/workspaces.js.map +1 -0
  194. package/packages/api-gateway/package.json +20 -10
  195. package/packages/api-gateway/scripts/copy-marketplace-entries.mjs +13 -0
  196. package/packages/api-gateway/src/index.ts +1258 -61
  197. package/packages/api-gateway/src/marketplace-entries/official/agent-teams.json +31 -0
  198. package/packages/api-gateway/src/marketplace-entries/official/anchored-standard.json +29 -0
  199. package/packages/api-gateway/src/marketplace-entries/official/annotation.json +28 -0
  200. package/packages/api-gateway/src/marketplace-entries/official/archify.json +31 -0
  201. package/packages/api-gateway/src/marketplace-entries/official/at-file.json +28 -0
  202. package/packages/api-gateway/src/marketplace-entries/official/auto-mode.json +32 -0
  203. package/packages/api-gateway/src/marketplace-entries/official/better-sidebar.json +32 -0
  204. package/packages/api-gateway/src/marketplace-entries/official/browser-fetch.json +28 -0
  205. package/packages/api-gateway/src/marketplace-entries/official/browser-session.json +29 -0
  206. package/packages/api-gateway/src/marketplace-entries/official/canvas-draw.json +29 -0
  207. package/packages/api-gateway/src/marketplace-entries/official/change-verifier.json +30 -0
  208. package/packages/api-gateway/src/marketplace-entries/official/cleaner.json +29 -0
  209. package/packages/api-gateway/src/marketplace-entries/official/cli-notifier.json +30 -0
  210. package/packages/api-gateway/src/marketplace-entries/official/code2skill.json +29 -0
  211. package/packages/api-gateway/src/marketplace-entries/official/colleague-skill.json +30 -0
  212. package/packages/api-gateway/src/marketplace-entries/official/context-doctor.json +30 -0
  213. package/packages/api-gateway/src/marketplace-entries/official/context.json +28 -0
  214. package/packages/api-gateway/src/marketplace-entries/official/cordis-group.json +16 -0
  215. package/packages/api-gateway/src/marketplace-entries/official/cordis-logger-console.json +16 -0
  216. package/packages/api-gateway/src/marketplace-entries/official/cordis-timer.json +16 -0
  217. package/packages/api-gateway/src/marketplace-entries/official/cost-meter.json +31 -0
  218. package/packages/api-gateway/src/marketplace-entries/official/dependency-checker.json +31 -0
  219. package/packages/api-gateway/src/marketplace-entries/official/docker-sandbox.json +29 -0
  220. package/packages/api-gateway/src/marketplace-entries/official/fail-logger.json +29 -0
  221. package/packages/api-gateway/src/marketplace-entries/official/genui.json +28 -0
  222. package/packages/api-gateway/src/marketplace-entries/official/git-time-capsule.json +30 -0
  223. package/packages/api-gateway/src/marketplace-entries/official/graph-memory.json +29 -0
  224. package/packages/api-gateway/src/marketplace-entries/official/history-compressor.json +33 -0
  225. package/packages/api-gateway/src/marketplace-entries/official/hol-guard.json +29 -0
  226. package/packages/api-gateway/src/marketplace-entries/official/i18n-pair.json +29 -0
  227. package/packages/api-gateway/src/marketplace-entries/official/image-compressor.json +29 -0
  228. package/packages/api-gateway/src/marketplace-entries/official/llm-verifier.json +32 -0
  229. package/packages/api-gateway/src/marketplace-entries/official/mcp-client.json +29 -0
  230. package/packages/api-gateway/src/marketplace-entries/official/mcp-panel.json +29 -0
  231. package/packages/api-gateway/src/marketplace-entries/official/memory.json +28 -0
  232. package/packages/api-gateway/src/marketplace-entries/official/mirage-bridge.json +33 -0
  233. package/packages/api-gateway/src/marketplace-entries/official/mock-server.json +29 -0
  234. package/packages/api-gateway/src/marketplace-entries/official/modlens.json +28 -0
  235. package/packages/api-gateway/src/marketplace-entries/official/module-search.json +30 -0
  236. package/packages/api-gateway/src/marketplace-entries/official/obsidian-sync.json +29 -0
  237. package/packages/api-gateway/src/marketplace-entries/official/openpets.json +29 -0
  238. package/packages/api-gateway/src/marketplace-entries/official/plan-execute.json +29 -0
  239. package/packages/api-gateway/src/marketplace-entries/official/plugin-check.json +29 -0
  240. package/packages/api-gateway/src/marketplace-entries/official/plugin-dev.json +29 -0
  241. package/packages/api-gateway/src/marketplace-entries/official/plugin-finder.json +32 -0
  242. package/packages/api-gateway/src/marketplace-entries/official/plugin-radar.json +28 -0
  243. package/packages/api-gateway/src/marketplace-entries/official/plugin-stars.json +29 -0
  244. package/packages/api-gateway/src/marketplace-entries/official/prompt-guard.json +28 -0
  245. package/packages/api-gateway/src/marketplace-entries/official/prompt-library.json +30 -0
  246. package/packages/api-gateway/src/marketplace-entries/official/readme-gen.json +31 -0
  247. package/packages/api-gateway/src/marketplace-entries/official/recall-unread.json +29 -0
  248. package/packages/api-gateway/src/marketplace-entries/official/reverse-skill.json +30 -0
  249. package/packages/api-gateway/src/marketplace-entries/official/reviewer-bot.json +29 -0
  250. package/packages/api-gateway/src/marketplace-entries/official/runtime-doctor.json +32 -0
  251. package/packages/api-gateway/src/marketplace-entries/official/secure-audit.json +30 -0
  252. package/packages/api-gateway/src/marketplace-entries/official/session-bookmarks.json +30 -0
  253. package/packages/api-gateway/src/marketplace-entries/official/session-bridge.json +30 -0
  254. package/packages/api-gateway/src/marketplace-entries/official/session-compare.json +30 -0
  255. package/packages/api-gateway/src/marketplace-entries/official/session-export.json +30 -0
  256. package/packages/api-gateway/src/marketplace-entries/official/session-insights.json +29 -0
  257. package/packages/api-gateway/src/marketplace-entries/official/session-search.json +30 -0
  258. package/packages/api-gateway/src/marketplace-entries/official/skill-catalog.json +31 -0
  259. package/packages/api-gateway/src/marketplace-entries/official/skill-guard.json +29 -0
  260. package/packages/api-gateway/src/marketplace-entries/official/sql-lens.json +29 -0
  261. package/packages/api-gateway/src/marketplace-entries/official/synapse.json +28 -0
  262. package/packages/api-gateway/src/marketplace-entries/official/tab-manager.json +29 -0
  263. package/packages/api-gateway/src/marketplace-entries/official/taskboard.json +29 -0
  264. package/packages/api-gateway/src/marketplace-entries/official/telemetry-blocker.json +29 -0
  265. package/packages/api-gateway/src/marketplace-entries/official/test-harness.json +29 -0
  266. package/packages/api-gateway/src/marketplace-entries/official/theme-studio.json +32 -0
  267. package/packages/api-gateway/src/marketplace-entries/official/token-guard.json +32 -0
  268. package/packages/api-gateway/src/marketplace-entries/official/turn-rewind.json +29 -0
  269. package/packages/api-gateway/src/marketplace-entries/official/undo-savepoint.json +28 -0
  270. package/packages/api-gateway/src/marketplace-entries/official/vision-toolkit.json +29 -0
  271. package/packages/api-gateway/src/marketplace-entries/official/web-research.json +29 -0
  272. package/packages/api-gateway/src/marketplace-entries/official/workspace-navigator.json +32 -0
  273. package/packages/api-gateway/src/marketplace-entries/official/workspace-search.json +29 -0
  274. package/packages/api-gateway/src/marketplace-entries/official/yaml-validator.json +29 -0
  275. package/packages/api-gateway/src/marketplace.ts +267 -22
  276. package/packages/api-gateway/src/workspaces.ts +20 -0
  277. package/packages/api-gateway/test/index.test.ts +483 -33
  278. package/packages/api-gateway/test/marketplace.test.ts +282 -3
  279. package/packages/api-gateway/test/release-version.test.ts +71 -0
  280. package/packages/api-gateway/test/workspaces.test.ts +13 -0
  281. package/packages/api-gateway/tsconfig.build.json +1 -1
  282. package/packages/api-gateway/tsconfig.json +1 -1
  283. package/packages/bundle-web-app/LICENSE +9 -0
  284. package/packages/bundle-web-app/package.json +19 -9
  285. package/packages/bundle-web-app/tsconfig.build.json +1 -1
  286. package/packages/bundle-web-app/tsconfig.json +1 -1
  287. package/packages/cli/LICENSE +9 -0
  288. package/packages/cli/dist/args.d.ts.map +1 -1
  289. package/packages/cli/dist/args.js +16 -9
  290. package/packages/cli/dist/args.js.map +1 -1
  291. package/packages/cli/dist/bin.js +12 -3
  292. package/packages/cli/dist/bin.js.map +1 -1
  293. package/packages/cli/dist/main.d.ts +1 -0
  294. package/packages/cli/dist/main.d.ts.map +1 -1
  295. package/packages/cli/dist/main.js +49 -9
  296. package/packages/cli/dist/main.js.map +1 -1
  297. package/packages/cli/dist/node-stdio.d.ts +3 -1
  298. package/packages/cli/dist/node-stdio.d.ts.map +1 -1
  299. package/packages/cli/dist/node-stdio.js +91 -13
  300. package/packages/cli/dist/node-stdio.js.map +1 -1
  301. package/packages/cli/dist/relaunch.d.ts.map +1 -1
  302. package/packages/cli/dist/relaunch.js +23 -10
  303. package/packages/cli/dist/relaunch.js.map +1 -1
  304. package/packages/cli/package.json +18 -8
  305. package/packages/cli/src/args.ts +16 -10
  306. package/packages/cli/src/bin.ts +12 -3
  307. package/packages/cli/src/main.ts +54 -10
  308. package/packages/cli/src/node-stdio.ts +85 -13
  309. package/packages/cli/src/relaunch.ts +19 -6
  310. package/packages/cli/test/args.test.ts +22 -3
  311. package/packages/cli/test/binary.test.ts +58 -0
  312. package/packages/cli/test/broken-pipe.test.ts +32 -0
  313. package/packages/cli/test/cli.test.ts +57 -8
  314. package/packages/cli/test/node-stdio.test.ts +89 -0
  315. package/packages/cli/test/relaunch.test.ts +30 -2
  316. package/packages/cli/test/stdin-shutdown.test.ts +59 -0
  317. package/packages/cli/tsconfig.build.json +1 -3
  318. package/packages/cli/tsconfig.json +1 -4
  319. package/packages/client-web/LICENSE +9 -0
  320. package/packages/client-web/dist/annotation-ui.d.ts +11 -0
  321. package/packages/client-web/dist/annotation-ui.d.ts.map +1 -0
  322. package/packages/client-web/dist/annotation-ui.js +24 -0
  323. package/packages/client-web/dist/annotation-ui.js.map +1 -0
  324. package/packages/client-web/dist/browser-session-view.d.ts +7 -0
  325. package/packages/client-web/dist/browser-session-view.d.ts.map +1 -0
  326. package/packages/client-web/dist/browser-session-view.js +8 -0
  327. package/packages/client-web/dist/browser-session-view.js.map +1 -0
  328. package/packages/client-web/dist/control-room.d.ts +151 -6
  329. package/packages/client-web/dist/control-room.d.ts.map +1 -1
  330. package/packages/client-web/dist/control-room.js +156 -11
  331. package/packages/client-web/dist/control-room.js.map +1 -1
  332. package/packages/client-web/dist/design-contract.d.ts.map +1 -1
  333. package/packages/client-web/dist/design-contract.js +178 -19
  334. package/packages/client-web/dist/design-contract.js.map +1 -1
  335. package/packages/client-web/dist/index.d.ts +4 -1
  336. package/packages/client-web/dist/index.d.ts.map +1 -1
  337. package/packages/client-web/dist/index.js +11 -3
  338. package/packages/client-web/dist/index.js.map +1 -1
  339. package/packages/client-web/dist/markdown.d.ts +5 -0
  340. package/packages/client-web/dist/markdown.d.ts.map +1 -0
  341. package/packages/client-web/dist/markdown.js +20 -0
  342. package/packages/client-web/dist/markdown.js.map +1 -0
  343. package/packages/client-web/dist/marketplace-catalog.d.ts +3 -0
  344. package/packages/client-web/dist/marketplace-catalog.d.ts.map +1 -0
  345. package/packages/client-web/dist/marketplace-catalog.js +10 -0
  346. package/packages/client-web/dist/marketplace-catalog.js.map +1 -0
  347. package/packages/client-web/dist/marketplace-navigation.d.ts +19 -0
  348. package/packages/client-web/dist/marketplace-navigation.d.ts.map +1 -0
  349. package/packages/client-web/dist/marketplace-navigation.js +31 -0
  350. package/packages/client-web/dist/marketplace-navigation.js.map +1 -0
  351. package/packages/client-web/dist/message-content.d.ts +9 -0
  352. package/packages/client-web/dist/message-content.d.ts.map +1 -0
  353. package/packages/client-web/dist/message-content.js +54 -0
  354. package/packages/client-web/dist/message-content.js.map +1 -0
  355. package/packages/client-web/dist/plugin-navigation.d.ts +3 -0
  356. package/packages/client-web/dist/plugin-navigation.d.ts.map +1 -0
  357. package/packages/client-web/dist/plugin-navigation.js +10 -0
  358. package/packages/client-web/dist/plugin-navigation.js.map +1 -0
  359. package/packages/client-web/dist/plugin-search.d.ts +2 -0
  360. package/packages/client-web/dist/plugin-search.d.ts.map +1 -0
  361. package/packages/client-web/dist/plugin-search.js +7 -0
  362. package/packages/client-web/dist/plugin-search.js.map +1 -0
  363. package/packages/client-web/dist/plugin-stars-view.d.ts +12 -0
  364. package/packages/client-web/dist/plugin-stars-view.d.ts.map +1 -0
  365. package/packages/client-web/dist/plugin-stars-view.js +8 -0
  366. package/packages/client-web/dist/plugin-stars-view.js.map +1 -0
  367. package/packages/client-web/dist/prompt-completion.d.ts +13 -0
  368. package/packages/client-web/dist/prompt-completion.d.ts.map +1 -0
  369. package/packages/client-web/dist/prompt-completion.js +17 -0
  370. package/packages/client-web/dist/prompt-completion.js.map +1 -0
  371. package/packages/client-web/dist/react-room.d.ts +2 -1
  372. package/packages/client-web/dist/react-room.d.ts.map +1 -1
  373. package/packages/client-web/dist/react-room.js +2347 -93
  374. package/packages/client-web/dist/react-room.js.map +1 -1
  375. package/packages/client-web/dist/runtime-events.d.ts +4 -0
  376. package/packages/client-web/dist/runtime-events.d.ts.map +1 -0
  377. package/packages/client-web/dist/runtime-events.js +29 -0
  378. package/packages/client-web/dist/runtime-events.js.map +1 -0
  379. package/packages/client-web/package.json +19 -7
  380. package/packages/client-web/src/annotation-ui.ts +29 -0
  381. package/packages/client-web/src/browser-session-view.ts +13 -0
  382. package/packages/client-web/src/control-room.ts +359 -11
  383. package/packages/client-web/src/design-contract.ts +248 -26
  384. package/packages/client-web/src/index.ts +17 -4
  385. package/packages/client-web/src/markdown.tsx +22 -0
  386. package/packages/client-web/src/marketplace-catalog.ts +10 -0
  387. package/packages/client-web/src/marketplace-navigation.ts +46 -0
  388. package/packages/client-web/src/message-content.ts +51 -0
  389. package/packages/client-web/src/plugin-navigation.ts +9 -0
  390. package/packages/client-web/src/plugin-search.ts +5 -0
  391. package/packages/client-web/src/plugin-stars-view.ts +19 -0
  392. package/packages/client-web/src/prompt-completion.ts +24 -0
  393. package/packages/client-web/src/react-room.tsx +7360 -54
  394. package/packages/client-web/src/runtime-events.ts +29 -0
  395. package/packages/client-web/test/annotation-ui.test.ts +21 -0
  396. package/packages/client-web/test/browser-session-view.test.ts +17 -0
  397. package/packages/client-web/test/design-contract.test.ts +46 -1
  398. package/packages/client-web/test/marketplace-catalog.test.ts +52 -0
  399. package/packages/client-web/test/message-content.test.ts +43 -0
  400. package/packages/client-web/test/plugin-navigation.test.ts +16 -0
  401. package/packages/client-web/test/plugin-search.test.ts +22 -0
  402. package/packages/client-web/test/plugin-stars-view.test.ts +20 -0
  403. package/packages/client-web/test/prompt-completion.test.ts +21 -0
  404. package/packages/client-web/test/runtime-events.test.ts +28 -0
  405. package/packages/client-web/tsconfig.build.json +13 -1
  406. package/packages/client-web/tsconfig.json +11 -1
  407. package/packages/core/LICENSE +9 -0
  408. package/packages/core/dist/boot.d.ts.map +1 -1
  409. package/packages/core/dist/boot.js +42 -3
  410. package/packages/core/dist/boot.js.map +1 -1
  411. package/packages/core/dist/config.d.ts +2 -0
  412. package/packages/core/dist/config.d.ts.map +1 -0
  413. package/packages/core/dist/config.js +8 -0
  414. package/packages/core/dist/config.js.map +1 -0
  415. package/packages/core/dist/http.d.ts +8 -0
  416. package/packages/core/dist/http.d.ts.map +1 -0
  417. package/packages/core/dist/http.js +27 -0
  418. package/packages/core/dist/http.js.map +1 -0
  419. package/packages/core/dist/index.d.ts +2 -0
  420. package/packages/core/dist/index.d.ts.map +1 -1
  421. package/packages/core/dist/index.js +2 -0
  422. package/packages/core/dist/index.js.map +1 -1
  423. package/packages/core/dist/plugins/agent-teams.d.ts +17 -0
  424. package/packages/core/dist/plugins/agent-teams.d.ts.map +1 -0
  425. package/packages/core/dist/plugins/agent-teams.js +298 -0
  426. package/packages/core/dist/plugins/agent-teams.js.map +1 -0
  427. package/packages/core/dist/plugins/anchored-standard.d.ts +14 -0
  428. package/packages/core/dist/plugins/anchored-standard.d.ts.map +1 -0
  429. package/packages/core/dist/plugins/anchored-standard.js +84 -0
  430. package/packages/core/dist/plugins/anchored-standard.js.map +1 -0
  431. package/packages/core/dist/plugins/annotation.d.ts +18 -0
  432. package/packages/core/dist/plugins/annotation.d.ts.map +1 -0
  433. package/packages/core/dist/plugins/annotation.js +94 -0
  434. package/packages/core/dist/plugins/annotation.js.map +1 -0
  435. package/packages/core/dist/plugins/archify.d.ts +23 -0
  436. package/packages/core/dist/plugins/archify.d.ts.map +1 -0
  437. package/packages/core/dist/plugins/archify.js +98 -0
  438. package/packages/core/dist/plugins/archify.js.map +1 -0
  439. package/packages/core/dist/plugins/at-file.d.ts +8 -0
  440. package/packages/core/dist/plugins/at-file.d.ts.map +1 -0
  441. package/packages/core/dist/plugins/at-file.js +52 -0
  442. package/packages/core/dist/plugins/at-file.js.map +1 -0
  443. package/packages/core/dist/plugins/auto-mode.d.ts +15 -0
  444. package/packages/core/dist/plugins/auto-mode.d.ts.map +1 -0
  445. package/packages/core/dist/plugins/auto-mode.js +114 -0
  446. package/packages/core/dist/plugins/auto-mode.js.map +1 -0
  447. package/packages/core/dist/plugins/better-sidebar.d.ts +37 -0
  448. package/packages/core/dist/plugins/better-sidebar.d.ts.map +1 -0
  449. package/packages/core/dist/plugins/better-sidebar.js +89 -0
  450. package/packages/core/dist/plugins/better-sidebar.js.map +1 -0
  451. package/packages/core/dist/plugins/browser-fetch.d.ts +14 -0
  452. package/packages/core/dist/plugins/browser-fetch.d.ts.map +1 -0
  453. package/packages/core/dist/plugins/browser-fetch.js +167 -0
  454. package/packages/core/dist/plugins/browser-fetch.js.map +1 -0
  455. package/packages/core/dist/plugins/browser-session.d.ts +14 -0
  456. package/packages/core/dist/plugins/browser-session.d.ts.map +1 -0
  457. package/packages/core/dist/plugins/browser-session.js +265 -0
  458. package/packages/core/dist/plugins/browser-session.js.map +1 -0
  459. package/packages/core/dist/plugins/canvas-draw.d.ts +8 -0
  460. package/packages/core/dist/plugins/canvas-draw.d.ts.map +1 -0
  461. package/packages/core/dist/plugins/canvas-draw.js +88 -0
  462. package/packages/core/dist/plugins/canvas-draw.js.map +1 -0
  463. package/packages/core/dist/plugins/change-verifier.d.ts +8 -0
  464. package/packages/core/dist/plugins/change-verifier.d.ts.map +1 -0
  465. package/packages/core/dist/plugins/change-verifier.js +67 -0
  466. package/packages/core/dist/plugins/change-verifier.js.map +1 -0
  467. package/packages/core/dist/plugins/cleaner.d.ts +8 -0
  468. package/packages/core/dist/plugins/cleaner.d.ts.map +1 -0
  469. package/packages/core/dist/plugins/cleaner.js +56 -0
  470. package/packages/core/dist/plugins/cleaner.js.map +1 -0
  471. package/packages/core/dist/plugins/cli-notifier.d.ts +15 -0
  472. package/packages/core/dist/plugins/cli-notifier.d.ts.map +1 -0
  473. package/packages/core/dist/plugins/cli-notifier.js +110 -0
  474. package/packages/core/dist/plugins/cli-notifier.js.map +1 -0
  475. package/packages/core/dist/plugins/code2skill.d.ts +8 -0
  476. package/packages/core/dist/plugins/code2skill.d.ts.map +1 -0
  477. package/packages/core/dist/plugins/code2skill.js +95 -0
  478. package/packages/core/dist/plugins/code2skill.js.map +1 -0
  479. package/packages/core/dist/plugins/colleague-skill.d.ts +27 -0
  480. package/packages/core/dist/plugins/colleague-skill.d.ts.map +1 -0
  481. package/packages/core/dist/plugins/colleague-skill.js +99 -0
  482. package/packages/core/dist/plugins/colleague-skill.js.map +1 -0
  483. package/packages/core/dist/plugins/context-doctor.d.ts +30 -0
  484. package/packages/core/dist/plugins/context-doctor.d.ts.map +1 -0
  485. package/packages/core/dist/plugins/context-doctor.js +95 -0
  486. package/packages/core/dist/plugins/context-doctor.js.map +1 -0
  487. package/packages/core/dist/plugins/context.d.ts +8 -0
  488. package/packages/core/dist/plugins/context.d.ts.map +1 -0
  489. package/packages/core/dist/plugins/context.js +87 -0
  490. package/packages/core/dist/plugins/context.js.map +1 -0
  491. package/packages/core/dist/plugins/cost-meter.d.ts +32 -0
  492. package/packages/core/dist/plugins/cost-meter.d.ts.map +1 -0
  493. package/packages/core/dist/plugins/cost-meter.js +204 -0
  494. package/packages/core/dist/plugins/cost-meter.js.map +1 -0
  495. package/packages/core/dist/plugins/dependency-checker.d.ts +27 -0
  496. package/packages/core/dist/plugins/dependency-checker.d.ts.map +1 -0
  497. package/packages/core/dist/plugins/dependency-checker.js +221 -0
  498. package/packages/core/dist/plugins/dependency-checker.js.map +1 -0
  499. package/packages/core/dist/plugins/docker-sandbox.d.ts +8 -0
  500. package/packages/core/dist/plugins/docker-sandbox.d.ts.map +1 -0
  501. package/packages/core/dist/plugins/docker-sandbox.js +102 -0
  502. package/packages/core/dist/plugins/docker-sandbox.js.map +1 -0
  503. package/packages/core/dist/plugins/fail-logger.d.ts +8 -0
  504. package/packages/core/dist/plugins/fail-logger.d.ts.map +1 -0
  505. package/packages/core/dist/plugins/fail-logger.js +51 -0
  506. package/packages/core/dist/plugins/fail-logger.js.map +1 -0
  507. package/packages/core/dist/plugins/genui.d.ts +8 -0
  508. package/packages/core/dist/plugins/genui.d.ts.map +1 -0
  509. package/packages/core/dist/plugins/genui.js +79 -0
  510. package/packages/core/dist/plugins/genui.js.map +1 -0
  511. package/packages/core/dist/plugins/git-time-capsule.d.ts +9 -0
  512. package/packages/core/dist/plugins/git-time-capsule.d.ts.map +1 -0
  513. package/packages/core/dist/plugins/git-time-capsule.js +90 -0
  514. package/packages/core/dist/plugins/git-time-capsule.js.map +1 -0
  515. package/packages/core/dist/plugins/graph-memory.d.ts +16 -0
  516. package/packages/core/dist/plugins/graph-memory.d.ts.map +1 -0
  517. package/packages/core/dist/plugins/graph-memory.js +382 -0
  518. package/packages/core/dist/plugins/graph-memory.js.map +1 -0
  519. package/packages/core/dist/plugins/history-compressor.d.ts +15 -0
  520. package/packages/core/dist/plugins/history-compressor.d.ts.map +1 -0
  521. package/packages/core/dist/plugins/history-compressor.js +80 -0
  522. package/packages/core/dist/plugins/history-compressor.js.map +1 -0
  523. package/packages/core/dist/plugins/hol-guard.d.ts +29 -0
  524. package/packages/core/dist/plugins/hol-guard.d.ts.map +1 -0
  525. package/packages/core/dist/plugins/hol-guard.js +139 -0
  526. package/packages/core/dist/plugins/hol-guard.js.map +1 -0
  527. package/packages/core/dist/plugins/i18n-pair.d.ts +8 -0
  528. package/packages/core/dist/plugins/i18n-pair.d.ts.map +1 -0
  529. package/packages/core/dist/plugins/i18n-pair.js +76 -0
  530. package/packages/core/dist/plugins/i18n-pair.js.map +1 -0
  531. package/packages/core/dist/plugins/image-compressor.d.ts +8 -0
  532. package/packages/core/dist/plugins/image-compressor.d.ts.map +1 -0
  533. package/packages/core/dist/plugins/image-compressor.js +150 -0
  534. package/packages/core/dist/plugins/image-compressor.js.map +1 -0
  535. package/packages/core/dist/plugins/llm-verifier.d.ts +42 -0
  536. package/packages/core/dist/plugins/llm-verifier.d.ts.map +1 -0
  537. package/packages/core/dist/plugins/llm-verifier.js +128 -0
  538. package/packages/core/dist/plugins/llm-verifier.js.map +1 -0
  539. package/packages/core/dist/plugins/mcp-client.d.ts +19 -0
  540. package/packages/core/dist/plugins/mcp-client.d.ts.map +1 -0
  541. package/packages/core/dist/plugins/mcp-client.js +534 -0
  542. package/packages/core/dist/plugins/mcp-client.js.map +1 -0
  543. package/packages/core/dist/plugins/mcp-panel.d.ts +14 -0
  544. package/packages/core/dist/plugins/mcp-panel.d.ts.map +1 -0
  545. package/packages/core/dist/plugins/mcp-panel.js +180 -0
  546. package/packages/core/dist/plugins/mcp-panel.js.map +1 -0
  547. package/packages/core/dist/plugins/memory.d.ts +15 -0
  548. package/packages/core/dist/plugins/memory.d.ts.map +1 -0
  549. package/packages/core/dist/plugins/memory.js +161 -0
  550. package/packages/core/dist/plugins/memory.js.map +1 -0
  551. package/packages/core/dist/plugins/mirage-bridge.d.ts +23 -0
  552. package/packages/core/dist/plugins/mirage-bridge.d.ts.map +1 -0
  553. package/packages/core/dist/plugins/mirage-bridge.js +149 -0
  554. package/packages/core/dist/plugins/mirage-bridge.js.map +1 -0
  555. package/packages/core/dist/plugins/mock-server.d.ts +22 -0
  556. package/packages/core/dist/plugins/mock-server.d.ts.map +1 -0
  557. package/packages/core/dist/plugins/mock-server.js +149 -0
  558. package/packages/core/dist/plugins/mock-server.js.map +1 -0
  559. package/packages/core/dist/plugins/model.d.ts +1 -1
  560. package/packages/core/dist/plugins/model.d.ts.map +1 -1
  561. package/packages/core/dist/plugins/model.js +3 -1
  562. package/packages/core/dist/plugins/model.js.map +1 -1
  563. package/packages/core/dist/plugins/models.d.ts.map +1 -1
  564. package/packages/core/dist/plugins/models.js +5 -2
  565. package/packages/core/dist/plugins/models.js.map +1 -1
  566. package/packages/core/dist/plugins/modlens.d.ts +8 -0
  567. package/packages/core/dist/plugins/modlens.d.ts.map +1 -0
  568. package/packages/core/dist/plugins/modlens.js +63 -0
  569. package/packages/core/dist/plugins/modlens.js.map +1 -0
  570. package/packages/core/dist/plugins/module-search.d.ts +27 -0
  571. package/packages/core/dist/plugins/module-search.d.ts.map +1 -0
  572. package/packages/core/dist/plugins/module-search.js +174 -0
  573. package/packages/core/dist/plugins/module-search.js.map +1 -0
  574. package/packages/core/dist/plugins/obsidian-sync.d.ts +14 -0
  575. package/packages/core/dist/plugins/obsidian-sync.d.ts.map +1 -0
  576. package/packages/core/dist/plugins/obsidian-sync.js +79 -0
  577. package/packages/core/dist/plugins/obsidian-sync.js.map +1 -0
  578. package/packages/core/dist/plugins/openpets.d.ts +14 -0
  579. package/packages/core/dist/plugins/openpets.d.ts.map +1 -0
  580. package/packages/core/dist/plugins/openpets.js +99 -0
  581. package/packages/core/dist/plugins/openpets.js.map +1 -0
  582. package/packages/core/dist/plugins/plan-execute.d.ts +8 -0
  583. package/packages/core/dist/plugins/plan-execute.d.ts.map +1 -0
  584. package/packages/core/dist/plugins/plan-execute.js +70 -0
  585. package/packages/core/dist/plugins/plan-execute.js.map +1 -0
  586. package/packages/core/dist/plugins/plugin-check.d.ts +38 -0
  587. package/packages/core/dist/plugins/plugin-check.d.ts.map +1 -0
  588. package/packages/core/dist/plugins/plugin-check.js +227 -0
  589. package/packages/core/dist/plugins/plugin-check.js.map +1 -0
  590. package/packages/core/dist/plugins/plugin-dev.d.ts +8 -0
  591. package/packages/core/dist/plugins/plugin-dev.d.ts.map +1 -0
  592. package/packages/core/dist/plugins/plugin-dev.js +44 -0
  593. package/packages/core/dist/plugins/plugin-dev.js.map +1 -0
  594. package/packages/core/dist/plugins/plugin-finder.d.ts +16 -0
  595. package/packages/core/dist/plugins/plugin-finder.d.ts.map +1 -0
  596. package/packages/core/dist/plugins/plugin-finder.js +98 -0
  597. package/packages/core/dist/plugins/plugin-finder.js.map +1 -0
  598. package/packages/core/dist/plugins/plugin-radar.d.ts +29 -0
  599. package/packages/core/dist/plugins/plugin-radar.d.ts.map +1 -0
  600. package/packages/core/dist/plugins/plugin-radar.js +146 -0
  601. package/packages/core/dist/plugins/plugin-radar.js.map +1 -0
  602. package/packages/core/dist/plugins/plugin-stars.d.ts +45 -0
  603. package/packages/core/dist/plugins/plugin-stars.d.ts.map +1 -0
  604. package/packages/core/dist/plugins/plugin-stars.js +165 -0
  605. package/packages/core/dist/plugins/plugin-stars.js.map +1 -0
  606. package/packages/core/dist/plugins/prompt-guard.d.ts +8 -0
  607. package/packages/core/dist/plugins/prompt-guard.d.ts.map +1 -0
  608. package/packages/core/dist/plugins/prompt-guard.js +114 -0
  609. package/packages/core/dist/plugins/prompt-guard.js.map +1 -0
  610. package/packages/core/dist/plugins/prompt-library.d.ts +25 -0
  611. package/packages/core/dist/plugins/prompt-library.d.ts.map +1 -0
  612. package/packages/core/dist/plugins/prompt-library.js +142 -0
  613. package/packages/core/dist/plugins/prompt-library.js.map +1 -0
  614. package/packages/core/dist/plugins/readme-gen.d.ts +25 -0
  615. package/packages/core/dist/plugins/readme-gen.d.ts.map +1 -0
  616. package/packages/core/dist/plugins/readme-gen.js +139 -0
  617. package/packages/core/dist/plugins/readme-gen.js.map +1 -0
  618. package/packages/core/dist/plugins/recall-unread.d.ts +24 -0
  619. package/packages/core/dist/plugins/recall-unread.d.ts.map +1 -0
  620. package/packages/core/dist/plugins/recall-unread.js +124 -0
  621. package/packages/core/dist/plugins/recall-unread.js.map +1 -0
  622. package/packages/core/dist/plugins/resources.d.ts +1 -0
  623. package/packages/core/dist/plugins/resources.d.ts.map +1 -1
  624. package/packages/core/dist/plugins/resources.js +31 -22
  625. package/packages/core/dist/plugins/resources.js.map +1 -1
  626. package/packages/core/dist/plugins/reverse-skill.d.ts +23 -0
  627. package/packages/core/dist/plugins/reverse-skill.d.ts.map +1 -0
  628. package/packages/core/dist/plugins/reverse-skill.js +60 -0
  629. package/packages/core/dist/plugins/reverse-skill.js.map +1 -0
  630. package/packages/core/dist/plugins/reviewer-bot.d.ts +14 -0
  631. package/packages/core/dist/plugins/reviewer-bot.d.ts.map +1 -0
  632. package/packages/core/dist/plugins/reviewer-bot.js +133 -0
  633. package/packages/core/dist/plugins/reviewer-bot.js.map +1 -0
  634. package/packages/core/dist/plugins/runtime-doctor.d.ts +33 -0
  635. package/packages/core/dist/plugins/runtime-doctor.d.ts.map +1 -0
  636. package/packages/core/dist/plugins/runtime-doctor.js +114 -0
  637. package/packages/core/dist/plugins/runtime-doctor.js.map +1 -0
  638. package/packages/core/dist/plugins/runtime.d.ts.map +1 -1
  639. package/packages/core/dist/plugins/runtime.js +63 -14
  640. package/packages/core/dist/plugins/runtime.js.map +1 -1
  641. package/packages/core/dist/plugins/secure-audit.d.ts +31 -0
  642. package/packages/core/dist/plugins/secure-audit.d.ts.map +1 -0
  643. package/packages/core/dist/plugins/secure-audit.js +121 -0
  644. package/packages/core/dist/plugins/secure-audit.js.map +1 -0
  645. package/packages/core/dist/plugins/session-bookmarks.d.ts +15 -0
  646. package/packages/core/dist/plugins/session-bookmarks.d.ts.map +1 -0
  647. package/packages/core/dist/plugins/session-bookmarks.js +87 -0
  648. package/packages/core/dist/plugins/session-bookmarks.js.map +1 -0
  649. package/packages/core/dist/plugins/session-bridge.d.ts +44 -0
  650. package/packages/core/dist/plugins/session-bridge.d.ts.map +1 -0
  651. package/packages/core/dist/plugins/session-bridge.js +265 -0
  652. package/packages/core/dist/plugins/session-bridge.js.map +1 -0
  653. package/packages/core/dist/plugins/session-compare.d.ts +33 -0
  654. package/packages/core/dist/plugins/session-compare.d.ts.map +1 -0
  655. package/packages/core/dist/plugins/session-compare.js +150 -0
  656. package/packages/core/dist/plugins/session-compare.js.map +1 -0
  657. package/packages/core/dist/plugins/session-export.d.ts +9 -0
  658. package/packages/core/dist/plugins/session-export.d.ts.map +1 -0
  659. package/packages/core/dist/plugins/session-export.js +93 -0
  660. package/packages/core/dist/plugins/session-export.js.map +1 -0
  661. package/packages/core/dist/plugins/session-insights.d.ts +8 -0
  662. package/packages/core/dist/plugins/session-insights.d.ts.map +1 -0
  663. package/packages/core/dist/plugins/session-insights.js +47 -0
  664. package/packages/core/dist/plugins/session-insights.js.map +1 -0
  665. package/packages/core/dist/plugins/session-search.d.ts +20 -0
  666. package/packages/core/dist/plugins/session-search.d.ts.map +1 -0
  667. package/packages/core/dist/plugins/session-search.js +122 -0
  668. package/packages/core/dist/plugins/session-search.js.map +1 -0
  669. package/packages/core/dist/plugins/session.d.ts.map +1 -1
  670. package/packages/core/dist/plugins/session.js +4 -2
  671. package/packages/core/dist/plugins/session.js.map +1 -1
  672. package/packages/core/dist/plugins/skill-catalog.d.ts +26 -0
  673. package/packages/core/dist/plugins/skill-catalog.d.ts.map +1 -0
  674. package/packages/core/dist/plugins/skill-catalog.js +97 -0
  675. package/packages/core/dist/plugins/skill-catalog.js.map +1 -0
  676. package/packages/core/dist/plugins/skill-guard.d.ts +26 -0
  677. package/packages/core/dist/plugins/skill-guard.d.ts.map +1 -0
  678. package/packages/core/dist/plugins/skill-guard.js +139 -0
  679. package/packages/core/dist/plugins/skill-guard.js.map +1 -0
  680. package/packages/core/dist/plugins/sql-lens.d.ts +8 -0
  681. package/packages/core/dist/plugins/sql-lens.d.ts.map +1 -0
  682. package/packages/core/dist/plugins/sql-lens.js +85 -0
  683. package/packages/core/dist/plugins/sql-lens.js.map +1 -0
  684. package/packages/core/dist/plugins/stdio.d.ts +1 -1
  685. package/packages/core/dist/plugins/stdio.d.ts.map +1 -1
  686. package/packages/core/dist/plugins/stdio.js +3 -1
  687. package/packages/core/dist/plugins/stdio.js.map +1 -1
  688. package/packages/core/dist/plugins/synapse.d.ts +38 -0
  689. package/packages/core/dist/plugins/synapse.d.ts.map +1 -0
  690. package/packages/core/dist/plugins/synapse.js +93 -0
  691. package/packages/core/dist/plugins/synapse.js.map +1 -0
  692. package/packages/core/dist/plugins/tab-manager.d.ts +8 -0
  693. package/packages/core/dist/plugins/tab-manager.d.ts.map +1 -0
  694. package/packages/core/dist/plugins/tab-manager.js +135 -0
  695. package/packages/core/dist/plugins/tab-manager.js.map +1 -0
  696. package/packages/core/dist/plugins/taskboard.d.ts +15 -0
  697. package/packages/core/dist/plugins/taskboard.d.ts.map +1 -0
  698. package/packages/core/dist/plugins/taskboard.js +347 -0
  699. package/packages/core/dist/plugins/taskboard.js.map +1 -0
  700. package/packages/core/dist/plugins/telemetry-blocker.d.ts +8 -0
  701. package/packages/core/dist/plugins/telemetry-blocker.d.ts.map +1 -0
  702. package/packages/core/dist/plugins/telemetry-blocker.js +57 -0
  703. package/packages/core/dist/plugins/telemetry-blocker.js.map +1 -0
  704. package/packages/core/dist/plugins/test-harness.d.ts +8 -0
  705. package/packages/core/dist/plugins/test-harness.d.ts.map +1 -0
  706. package/packages/core/dist/plugins/test-harness.js +64 -0
  707. package/packages/core/dist/plugins/test-harness.js.map +1 -0
  708. package/packages/core/dist/plugins/theme-studio.d.ts +29 -0
  709. package/packages/core/dist/plugins/theme-studio.d.ts.map +1 -0
  710. package/packages/core/dist/plugins/theme-studio.js +141 -0
  711. package/packages/core/dist/plugins/theme-studio.js.map +1 -0
  712. package/packages/core/dist/plugins/token-guard.d.ts +15 -0
  713. package/packages/core/dist/plugins/token-guard.d.ts.map +1 -0
  714. package/packages/core/dist/plugins/token-guard.js +78 -0
  715. package/packages/core/dist/plugins/token-guard.js.map +1 -0
  716. package/packages/core/dist/plugins/tools.d.ts.map +1 -1
  717. package/packages/core/dist/plugins/tools.js +5 -2
  718. package/packages/core/dist/plugins/tools.js.map +1 -1
  719. package/packages/core/dist/plugins/turn-rewind.d.ts +19 -0
  720. package/packages/core/dist/plugins/turn-rewind.d.ts.map +1 -0
  721. package/packages/core/dist/plugins/turn-rewind.js +74 -0
  722. package/packages/core/dist/plugins/turn-rewind.js.map +1 -0
  723. package/packages/core/dist/plugins/undo-savepoint.d.ts +17 -0
  724. package/packages/core/dist/plugins/undo-savepoint.d.ts.map +1 -0
  725. package/packages/core/dist/plugins/undo-savepoint.js +247 -0
  726. package/packages/core/dist/plugins/undo-savepoint.js.map +1 -0
  727. package/packages/core/dist/plugins/vision-toolkit.d.ts +17 -0
  728. package/packages/core/dist/plugins/vision-toolkit.d.ts.map +1 -0
  729. package/packages/core/dist/plugins/vision-toolkit.js +145 -0
  730. package/packages/core/dist/plugins/vision-toolkit.js.map +1 -0
  731. package/packages/core/dist/plugins/web-research.d.ts +17 -0
  732. package/packages/core/dist/plugins/web-research.d.ts.map +1 -0
  733. package/packages/core/dist/plugins/web-research.js +275 -0
  734. package/packages/core/dist/plugins/web-research.js.map +1 -0
  735. package/packages/core/dist/plugins/workspace-navigator.d.ts +36 -0
  736. package/packages/core/dist/plugins/workspace-navigator.d.ts.map +1 -0
  737. package/packages/core/dist/plugins/workspace-navigator.js +150 -0
  738. package/packages/core/dist/plugins/workspace-navigator.js.map +1 -0
  739. package/packages/core/dist/plugins/workspace-search.d.ts +8 -0
  740. package/packages/core/dist/plugins/workspace-search.d.ts.map +1 -0
  741. package/packages/core/dist/plugins/workspace-search.js +134 -0
  742. package/packages/core/dist/plugins/workspace-search.js.map +1 -0
  743. package/packages/core/dist/plugins/yaml-validator.d.ts +8 -0
  744. package/packages/core/dist/plugins/yaml-validator.d.ts.map +1 -0
  745. package/packages/core/dist/plugins/yaml-validator.js +94 -0
  746. package/packages/core/dist/plugins/yaml-validator.js.map +1 -0
  747. package/packages/core/dist/profile.d.ts +1 -0
  748. package/packages/core/dist/profile.d.ts.map +1 -1
  749. package/packages/core/dist/profile.js +3 -0
  750. package/packages/core/dist/profile.js.map +1 -1
  751. package/packages/core/dist/runtime.d.ts.map +1 -1
  752. package/packages/core/dist/runtime.js +13 -4
  753. package/packages/core/dist/runtime.js.map +1 -1
  754. package/packages/core/dist/services.d.ts +55 -0
  755. package/packages/core/dist/services.d.ts.map +1 -1
  756. package/packages/core/dist/services.js +58 -2
  757. package/packages/core/dist/services.js.map +1 -1
  758. package/packages/core/dist/stdio.d.ts +13 -2
  759. package/packages/core/dist/stdio.d.ts.map +1 -1
  760. package/packages/core/dist/stdio.js +75 -9
  761. package/packages/core/dist/stdio.js.map +1 -1
  762. package/packages/core/dist/workspace-path.d.ts +12 -0
  763. package/packages/core/dist/workspace-path.d.ts.map +1 -0
  764. package/packages/core/dist/workspace-path.js +62 -0
  765. package/packages/core/dist/workspace-path.js.map +1 -0
  766. package/packages/core/package.json +18 -8
  767. package/packages/core/profiles/default/cordis.yml +85 -0
  768. package/packages/core/profiles/development/cordis.yml +1 -1
  769. package/packages/core/src/boot.ts +38 -2
  770. package/packages/core/src/config.ts +5 -0
  771. package/packages/core/src/http.ts +32 -0
  772. package/packages/core/src/index.ts +2 -0
  773. package/packages/core/src/plugins/agent-teams.ts +291 -0
  774. package/packages/core/src/plugins/anchored-standard.ts +88 -0
  775. package/packages/core/src/plugins/annotation.ts +106 -0
  776. package/packages/core/src/plugins/archify.ts +124 -0
  777. package/packages/core/src/plugins/at-file.ts +54 -0
  778. package/packages/core/src/plugins/auto-mode.ts +123 -0
  779. package/packages/core/src/plugins/better-sidebar.ts +117 -0
  780. package/packages/core/src/plugins/browser-fetch.ts +171 -0
  781. package/packages/core/src/plugins/browser-session.ts +287 -0
  782. package/packages/core/src/plugins/canvas-draw.ts +90 -0
  783. package/packages/core/src/plugins/change-verifier.ts +79 -0
  784. package/packages/core/src/plugins/cleaner.ts +61 -0
  785. package/packages/core/src/plugins/cli-notifier.ts +125 -0
  786. package/packages/core/src/plugins/code2skill.ts +96 -0
  787. package/packages/core/src/plugins/colleague-skill.ts +122 -0
  788. package/packages/core/src/plugins/context-doctor.ts +117 -0
  789. package/packages/core/src/plugins/context.ts +102 -0
  790. package/packages/core/src/plugins/cost-meter.ts +231 -0
  791. package/packages/core/src/plugins/dependency-checker.ts +241 -0
  792. package/packages/core/src/plugins/docker-sandbox.ts +100 -0
  793. package/packages/core/src/plugins/fail-logger.ts +51 -0
  794. package/packages/core/src/plugins/genui.ts +88 -0
  795. package/packages/core/src/plugins/git-time-capsule.ts +97 -0
  796. package/packages/core/src/plugins/graph-memory.ts +394 -0
  797. package/packages/core/src/plugins/history-compressor.ts +81 -0
  798. package/packages/core/src/plugins/hol-guard.ts +153 -0
  799. package/packages/core/src/plugins/i18n-pair.ts +82 -0
  800. package/packages/core/src/plugins/image-compressor.ts +144 -0
  801. package/packages/core/src/plugins/llm-verifier.ts +164 -0
  802. package/packages/core/src/plugins/mcp-client.ts +559 -0
  803. package/packages/core/src/plugins/mcp-panel.ts +190 -0
  804. package/packages/core/src/plugins/memory.ts +176 -0
  805. package/packages/core/src/plugins/mirage-bridge.ts +179 -0
  806. package/packages/core/src/plugins/mock-server.ts +158 -0
  807. package/packages/core/src/plugins/model.ts +3 -1
  808. package/packages/core/src/plugins/models.ts +5 -2
  809. package/packages/core/src/plugins/modlens.ts +63 -0
  810. package/packages/core/src/plugins/module-search.ts +201 -0
  811. package/packages/core/src/plugins/obsidian-sync.ts +83 -0
  812. package/packages/core/src/plugins/openpets.ts +109 -0
  813. package/packages/core/src/plugins/plan-execute.ts +76 -0
  814. package/packages/core/src/plugins/plugin-check.ts +232 -0
  815. package/packages/core/src/plugins/plugin-dev.ts +47 -0
  816. package/packages/core/src/plugins/plugin-finder.ts +108 -0
  817. package/packages/core/src/plugins/plugin-radar.ts +179 -0
  818. package/packages/core/src/plugins/plugin-stars.ts +205 -0
  819. package/packages/core/src/plugins/prompt-guard.ts +122 -0
  820. package/packages/core/src/plugins/prompt-library.ts +165 -0
  821. package/packages/core/src/plugins/readme-gen.ts +147 -0
  822. package/packages/core/src/plugins/recall-unread.ts +142 -0
  823. package/packages/core/src/plugins/resources.ts +28 -21
  824. package/packages/core/src/plugins/reverse-skill.ts +79 -0
  825. package/packages/core/src/plugins/reviewer-bot.ts +146 -0
  826. package/packages/core/src/plugins/runtime-doctor.ts +137 -0
  827. package/packages/core/src/plugins/runtime.ts +61 -14
  828. package/packages/core/src/plugins/secure-audit.ts +146 -0
  829. package/packages/core/src/plugins/session-bookmarks.ts +89 -0
  830. package/packages/core/src/plugins/session-bridge.ts +299 -0
  831. package/packages/core/src/plugins/session-compare.ts +180 -0
  832. package/packages/core/src/plugins/session-export.ts +99 -0
  833. package/packages/core/src/plugins/session-insights.ts +47 -0
  834. package/packages/core/src/plugins/session-search.ts +126 -0
  835. package/packages/core/src/plugins/session.ts +4 -2
  836. package/packages/core/src/plugins/skill-catalog.ts +117 -0
  837. package/packages/core/src/plugins/skill-guard.ts +152 -0
  838. package/packages/core/src/plugins/sql-lens.ts +92 -0
  839. package/packages/core/src/plugins/stdio.ts +3 -1
  840. package/packages/core/src/plugins/synapse.ts +130 -0
  841. package/packages/core/src/plugins/tab-manager.ts +135 -0
  842. package/packages/core/src/plugins/taskboard.ts +412 -0
  843. package/packages/core/src/plugins/telemetry-blocker.ts +62 -0
  844. package/packages/core/src/plugins/test-harness.ts +67 -0
  845. package/packages/core/src/plugins/theme-studio.ts +165 -0
  846. package/packages/core/src/plugins/token-guard.ts +84 -0
  847. package/packages/core/src/plugins/tools.ts +5 -2
  848. package/packages/core/src/plugins/turn-rewind.ts +86 -0
  849. package/packages/core/src/plugins/undo-savepoint.ts +284 -0
  850. package/packages/core/src/plugins/vision-toolkit.ts +153 -0
  851. package/packages/core/src/plugins/web-research.ts +289 -0
  852. package/packages/core/src/plugins/workspace-navigator.ts +164 -0
  853. package/packages/core/src/plugins/workspace-search.ts +139 -0
  854. package/packages/core/src/plugins/yaml-validator.ts +97 -0
  855. package/packages/core/src/profile.ts +3 -0
  856. package/packages/core/src/runtime.ts +11 -4
  857. package/packages/core/src/services.ts +110 -3
  858. package/packages/core/src/stdio.ts +79 -9
  859. package/packages/core/src/workspace-path.ts +69 -0
  860. package/packages/core/test/agent-teams.test.ts +24 -0
  861. package/packages/core/test/archify.test.ts +33 -0
  862. package/packages/core/test/better-sidebar.test.ts +125 -0
  863. package/packages/core/test/boot.test.ts +49 -6
  864. package/packages/core/test/colleague-skill.test.ts +74 -0
  865. package/packages/core/test/config.test.ts +121 -0
  866. package/packages/core/test/context-doctor.test.ts +32 -0
  867. package/packages/core/test/dependency-checker.test.ts +60 -0
  868. package/packages/core/test/git-time-capsule.test.ts +115 -0
  869. package/packages/core/test/http.test.ts +34 -0
  870. package/packages/core/test/llm-verifier.test.ts +72 -0
  871. package/packages/core/test/mirage-bridge.test.ts +54 -0
  872. package/packages/core/test/module-search.test.ts +78 -0
  873. package/packages/core/test/plugin-check.test.ts +16 -0
  874. package/packages/core/test/plugin-stars.test.ts +55 -0
  875. package/packages/core/test/profiles.integration.test.ts +49 -15
  876. package/packages/core/test/prompt-library.test.ts +56 -0
  877. package/packages/core/test/readme-gen.test.ts +45 -0
  878. package/packages/core/test/recall-unread.test.ts +35 -0
  879. package/packages/core/test/registry.test.ts +48 -0
  880. package/packages/core/test/reverse-skill.test.ts +40 -0
  881. package/packages/core/test/runtime-doctor.test.ts +55 -0
  882. package/packages/core/test/runtime-fixture.ts +4 -4
  883. package/packages/core/test/runtime.test.ts +90 -1
  884. package/packages/core/test/secure-audit.test.ts +16 -0
  885. package/packages/core/test/services.test.ts +2024 -5
  886. package/packages/core/test/session-bookmarks.test.ts +62 -0
  887. package/packages/core/test/session-bridge.test.ts +103 -0
  888. package/packages/core/test/session-compare.test.ts +94 -0
  889. package/packages/core/test/session-export.test.ts +54 -0
  890. package/packages/core/test/session-search.test.ts +30 -0
  891. package/packages/core/test/skill-catalog.test.ts +18 -0
  892. package/packages/core/test/skill-guard.test.ts +21 -0
  893. package/packages/core/test/stdio-args.test.ts +178 -0
  894. package/packages/core/test/theme-studio.test.ts +39 -0
  895. package/packages/core/test/token-guard.test.ts +34 -0
  896. package/packages/core/test/turn-rewind.test.ts +19 -0
  897. package/packages/core/test/vision-toolkit.test.ts +38 -0
  898. package/packages/core/test/workspace-git-status.test.ts +37 -0
  899. package/packages/core/test/workspace-navigator.test.ts +33 -0
  900. package/packages/core/test/workspace-path.test.ts +34 -0
  901. package/packages/core/tsconfig.build.json +1 -3
  902. package/packages/core/tsconfig.json +1 -4
  903. package/packages/host-webserver/LICENSE +9 -0
  904. package/packages/host-webserver/dist/index.js +1 -1
  905. package/packages/host-webserver/dist/index.js.map +1 -1
  906. package/packages/host-webserver/package.json +17 -7
  907. package/packages/host-webserver/src/index.ts +1 -1
  908. package/packages/host-webserver/test/index.test.ts +4 -1
  909. package/packages/host-webserver/tsconfig.build.json +1 -1
  910. package/packages/host-webserver/tsconfig.json +1 -1
  911. package/apps/web/dist/assets/index-Bwqek8LF.js +0 -20
  912. package/apps/web/dist/assets/index-DCHSASjq.css +0 -1
  913. package/packages/api-gateway/dist/marketplace-registry.json +0 -62
  914. package/packages/api-gateway/src/marketplace-registry.json +0 -62
@@ -0,0 +1,88 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import { Type } from "@earendil-works/pi-ai";
3
+ import { defineTool, type AgentToolResult } from "@earendil-works/pi-coding-agent";
4
+
5
+ const maxBlocks = 12;
6
+ const maxTextLength = 4000;
7
+ type BlockType = "text" | "badge" | "progress";
8
+ type Tone = "neutral" | "info" | "success" | "warning" | "danger";
9
+ type GenUiBlock = { type: BlockType; label: string; value: string | number; tone: Tone };
10
+ type GenUiReport = { title: string; blocks: GenUiBlock[]; renderedAt: string };
11
+
12
+ function cleanText(value: string, field: string): string {
13
+ const text = value.trim();
14
+ if (text.length === 0) throw new Error(`${field} must not be empty`);
15
+ if (text.length > maxTextLength) throw new Error(`${field} must be at most ${maxTextLength} characters`);
16
+ return text;
17
+ }
18
+
19
+ function normalizeBlock(block: { type: BlockType; label: string; value: string; tone?: Tone }): GenUiBlock {
20
+ const label = cleanText(block.label, "Block label");
21
+ const rawValue = cleanText(block.value, "Block value");
22
+ if (block.type !== "progress") return { type: block.type, label, value: rawValue, tone: block.tone ?? "neutral" };
23
+ const value = Number(rawValue);
24
+ if (!Number.isFinite(value) || value < 0 || value > 100) throw new Error("Progress value must be a number from 0 to 100");
25
+ return { type: "progress", label, value, tone: block.tone ?? "info" };
26
+ }
27
+
28
+ export default {
29
+ name: "pi-genui",
30
+ inject: ["piPluginUi", "piTools"],
31
+ apply(context: Context) {
32
+ let rendered = 0;
33
+ let latest: GenUiReport | undefined;
34
+ const unregisterTool = context.piTools.register(
35
+ defineTool({
36
+ name: "genui_render",
37
+ label: "Render structured UI",
38
+ description: "Render safe structured text, badge, and progress blocks in the GenUI panel; HTML and scripts are treated as plain text.",
39
+ promptSnippet: "render a structured status card for the user",
40
+ parameters: Type.Object({
41
+ title: Type.String(),
42
+ blocks: Type.Array(
43
+ Type.Object({
44
+ type: Type.Union(["text", "badge", "progress"]),
45
+ label: Type.String(),
46
+ value: Type.String(),
47
+ tone: Type.Optional(Type.Union(["neutral", "info", "success", "warning", "danger"])),
48
+ }),
49
+ ),
50
+ }),
51
+ execute(_toolCallId, params): Promise<AgentToolResult<GenUiReport>> {
52
+ return Promise.resolve().then(() => {
53
+ if (params.blocks.length === 0 || params.blocks.length > maxBlocks) throw new Error(`GenUI requires 1 to ${maxBlocks} blocks`);
54
+ latest = {
55
+ title: cleanText(params.title, "Title"),
56
+ blocks: params.blocks.map((block) =>
57
+ normalizeBlock({
58
+ type: block.type as BlockType,
59
+ label: block.label,
60
+ value: block.value,
61
+ ...(block.tone === undefined ? {} : { tone: block.tone as Tone }),
62
+ }),
63
+ ),
64
+ renderedAt: new Date().toISOString(),
65
+ };
66
+ rendered += 1;
67
+ return {
68
+ content: [{ type: "text" as const, text: `Rendered ${latest.blocks.length} structured UI block(s): ${latest.title}` }],
69
+ details: latest,
70
+ };
71
+ });
72
+ },
73
+ }),
74
+ );
75
+ const disposePanel = context.piPluginUi.register({
76
+ id: "genui-panel",
77
+ pluginId: "@pi-harness/core/plugins/genui",
78
+ title: "GenUI",
79
+ description: "渲染安全的结构化状态卡片;文本中的 HTML 和脚本不会被执行。",
80
+ icon: "▤",
81
+ read: () => ({ rendered, latest: latest ?? null }),
82
+ });
83
+ context.effect(() => () => {
84
+ unregisterTool();
85
+ disposePanel();
86
+ });
87
+ },
88
+ };
@@ -0,0 +1,97 @@
1
+ import { execFile } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
3
+ import { mkdir, readdir, stat, writeFile } from "node:fs/promises";
4
+ import { promisify } from "node:util";
5
+ import { basename, join } from "node:path";
6
+ import type { Context } from "@deepseek-ai/cordis";
7
+ import { Type } from "@earendil-works/pi-ai";
8
+ import { defineTool, type AgentToolResult } from "@earendil-works/pi-coding-agent";
9
+
10
+ const execFileAsync = promisify(execFile);
11
+ const capsuleDirectory = "capsules";
12
+
13
+ async function git(cwd: string, args: readonly string[]): Promise<string> {
14
+ const result = await execFileAsync("git", [...args], { cwd, maxBuffer: 8 * 1024 * 1024 });
15
+ return result.stdout;
16
+ }
17
+
18
+ export async function applyCapsule(cwd: string, capsulePath: string): Promise<void> {
19
+ try {
20
+ await git(cwd, ["apply", "--reverse", "--check", "--binary", capsulePath]);
21
+ } catch (cause) {
22
+ throw new Error("Git capsule does not apply cleanly", { cause });
23
+ }
24
+ await git(cwd, ["apply", "--reverse", "--binary", capsulePath]);
25
+ }
26
+
27
+ async function listCapsules(directory: string): Promise<{ name: string; bytes: number }[]> {
28
+ const names = (await readdir(directory).catch(() => [] as string[]))
29
+ .filter((name) => name.endsWith(".patch"))
30
+ .sort()
31
+ .reverse()
32
+ .slice(0, 20);
33
+ return Promise.all(names.map(async (name) => ({ name, bytes: (await stat(join(directory, name))).size })));
34
+ }
35
+
36
+ export default {
37
+ name: "pi-git-time-capsule",
38
+ inject: ["piHarnessLaunch", "piPluginUi", "piTools"],
39
+ apply(context: Context) {
40
+ const directory = join(context.piHarnessLaunch.agentDir, capsuleDirectory);
41
+ let latest: { name: string; bytes: number; files: number; restored?: boolean } | undefined;
42
+ const unregisterTool = context.piTools.register(
43
+ defineTool({
44
+ name: "git_snapshot",
45
+ label: "Git snapshot",
46
+ description: "Save the current tracked Git diff as a timestamped patch outside the workspace for rollback or review.",
47
+ promptSnippet: "save a rollback patch before changing code",
48
+ parameters: Type.Object({}),
49
+ async execute(): Promise<AgentToolResult<{ path: string; bytes: number; files: number }>> {
50
+ const status = await git(context.piHarnessLaunch.cwd, ["status", "--short"]);
51
+ const patch = await git(context.piHarnessLaunch.cwd, ["diff", "HEAD", "--binary", "--no-ext-diff", "--", ".", ":(exclude).pi-harness/capsules"]);
52
+ await mkdir(directory, { recursive: true });
53
+ const timestamp = new Date().toISOString().replace(/[-:.]/g, "");
54
+ const name = `${timestamp}-${randomUUID().slice(0, 8)}.patch`;
55
+ const path = join(directory, name);
56
+ await writeFile(path, patch, { encoding: "utf8", mode: 0o600, flag: "wx" });
57
+ const files = status.split("\n").filter((line) => line.trim() !== "" && !line.startsWith("??")).length;
58
+ latest = { name, bytes: Buffer.byteLength(patch), files };
59
+ return { content: [{ type: "text", text: `Git snapshot saved: ${name}` }], details: { path, bytes: latest.bytes, files } };
60
+ },
61
+ }),
62
+ );
63
+ const unregisterRestore = context.piTools.register(
64
+ defineTool({
65
+ name: "git_restore",
66
+ label: "Restore Git snapshot",
67
+ description: "Apply a saved Git time capsule after an explicit confirmation; the patch is checked before it changes the workspace.",
68
+ promptSnippet: "restore a previously saved Git snapshot",
69
+ parameters: Type.Object({ name: Type.String({ description: "Capsule filename from the recent snapshots list" }), confirm: Type.Boolean() }),
70
+ async execute(_toolCallId, params): Promise<AgentToolResult<{ name: string; restored: true }>> {
71
+ if (!params.confirm) throw new Error("Git capsule restore writes the workspace and requires confirm=true");
72
+ const name = params.name.trim();
73
+ if (name.length === 0 || name.length > 255 || basename(name) !== name || !name.endsWith(".patch"))
74
+ throw new Error("Capsule name must be a .patch filename");
75
+ const path = join(directory, name);
76
+ await applyCapsule(context.piHarnessLaunch.cwd, path);
77
+ const bytes = (await stat(path)).size;
78
+ latest = { name, bytes, files: 0, restored: true };
79
+ return { content: [{ type: "text", text: `Git snapshot restored: ${name}` }], details: { name, restored: true } };
80
+ },
81
+ }),
82
+ );
83
+ const disposePanel = context.piPluginUi.register({
84
+ id: "git-time-capsule-panel",
85
+ pluginId: "@pi-harness/core/plugins/git-time-capsule",
86
+ title: "Git Time Capsule",
87
+ description: "查看最近的代码快照;快照保存在工作区之外,不会污染项目文件。",
88
+ icon: "◫",
89
+ read: async () => ({ latest: latest ?? null, capsules: await listCapsules(directory) }),
90
+ });
91
+ context.effect(() => () => {
92
+ unregisterTool();
93
+ unregisterRestore();
94
+ disposePanel();
95
+ });
96
+ },
97
+ };
@@ -0,0 +1,394 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, join, resolve } from "node:path";
4
+ import type { Context } from "@deepseek-ai/cordis";
5
+ import z from "@deepseek-ai/schemastery";
6
+ import { Type } from "@earendil-works/pi-ai";
7
+ import { defineTool, type AgentToolResult } from "@earendil-works/pi-coding-agent";
8
+
9
+ const defaultFileName = "graph-memory.json";
10
+ const absoluteNodeLimit = 2_000;
11
+ const absoluteRelationLimit = 5_000;
12
+ const maxLabelLength = 160;
13
+ const maxSummaryBytes = 16 * 1024;
14
+ const maxSourceLength = 512;
15
+ const maxQueryLength = 160;
16
+ const maxFileBytes = 4 * 1024 * 1024;
17
+ const lockRetryMs = 25;
18
+ const lockTimeoutMs = 10_000;
19
+
20
+ type NodeKind = "task" | "skill" | "event";
21
+ type RelationKind = "USED_SKILL" | "SOLVED_BY" | "REQUIRES" | "PATCHES" | "CONFLICTS_WITH" | "RELATED_TO";
22
+ type GraphNode = { id: string; kind: NodeKind; label: string; summary: string; source?: string; createdAt: string; updatedAt: string };
23
+ type GraphRelation = { id: string; from: string; to: string; relation: RelationKind; createdAt: string };
24
+ type GraphFile = { version: 1; nodes: GraphNode[]; relations: GraphRelation[] };
25
+ type GraphSearchReport = { query: string; total: number; nodes: GraphNode[]; relations: GraphRelation[] };
26
+ type GraphState = Pick<GraphFile, "nodes" | "relations">;
27
+
28
+ export interface GraphMemoryPluginConfig {
29
+ fileName?: string;
30
+ maxNodes?: number;
31
+ maxRelations?: number;
32
+ }
33
+
34
+ export const Config: z<GraphMemoryPluginConfig> = z.object({
35
+ fileName: z.string().default(defaultFileName),
36
+ maxNodes: z.number().default(absoluteNodeLimit),
37
+ maxRelations: z.number().default(absoluteRelationLimit),
38
+ });
39
+
40
+ function normalizeFilePath(agentDir: string, fileName: string | undefined): string {
41
+ const name = (fileName ?? defaultFileName).trim();
42
+ if (name === "" || basename(name) !== name || !name.toLowerCase().endsWith(".json")) throw new Error("Graph memory fileName must be a single .json filename");
43
+ return resolve(agentDir, name);
44
+ }
45
+
46
+ function normalizeText(value: string, field: string, maxLength: number): string {
47
+ const normalized = value.trim();
48
+ if (normalized.length === 0 || normalized.length > maxLength) throw new Error(`${field} must contain 1-${maxLength} characters`);
49
+ return normalized;
50
+ }
51
+
52
+ function normalizeSummary(value: string): string {
53
+ const normalized = value.trim();
54
+ if (normalized === "" || Buffer.byteLength(normalized, "utf8") > maxSummaryBytes)
55
+ throw new Error(`Graph memory summary must be non-empty and at most ${maxSummaryBytes} bytes`);
56
+ return normalized;
57
+ }
58
+
59
+ function isNodeKind(value: unknown): value is NodeKind {
60
+ return value === "task" || value === "skill" || value === "event";
61
+ }
62
+
63
+ function isRelationKind(value: unknown): value is RelationKind {
64
+ return value === "USED_SKILL" || value === "SOLVED_BY" || value === "REQUIRES" || value === "PATCHES" || value === "CONFLICTS_WITH" || value === "RELATED_TO";
65
+ }
66
+
67
+ function isGraphNode(value: unknown): value is GraphNode {
68
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
69
+ const node = value as Record<string, unknown>;
70
+ return (
71
+ typeof node.id === "string" &&
72
+ node.id.length > 0 &&
73
+ node.id.length <= maxLabelLength &&
74
+ isNodeKind(node.kind) &&
75
+ typeof node.label === "string" &&
76
+ node.label.trim().length > 0 &&
77
+ node.label.length <= maxLabelLength &&
78
+ typeof node.summary === "string" &&
79
+ node.summary.trim().length > 0 &&
80
+ Buffer.byteLength(node.summary, "utf8") <= maxSummaryBytes &&
81
+ (node.source === undefined || typeof node.source === "string") &&
82
+ (node.source === undefined || (node.source.length > 0 && node.source.length <= maxSourceLength)) &&
83
+ typeof node.createdAt === "string" &&
84
+ Number.isFinite(Date.parse(node.createdAt)) &&
85
+ typeof node.updatedAt === "string" &&
86
+ Number.isFinite(Date.parse(node.updatedAt))
87
+ );
88
+ }
89
+
90
+ function isGraphRelation(value: unknown): value is GraphRelation {
91
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
92
+ const relation = value as Record<string, unknown>;
93
+ return (
94
+ typeof relation.id === "string" &&
95
+ relation.id.length > 0 &&
96
+ relation.id.length <= maxLabelLength &&
97
+ typeof relation.from === "string" &&
98
+ typeof relation.to === "string" &&
99
+ isRelationKind(relation.relation) &&
100
+ typeof relation.createdAt === "string" &&
101
+ Number.isFinite(Date.parse(relation.createdAt))
102
+ );
103
+ }
104
+
105
+ async function readGraphFile(filePath: string, nodeLimit: number, relationLimit: number): Promise<GraphState> {
106
+ let raw: Buffer;
107
+ try {
108
+ raw = await readFile(filePath);
109
+ } catch (error) {
110
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return { nodes: [], relations: [] };
111
+ throw error;
112
+ }
113
+ if (raw.byteLength > maxFileBytes) throw new Error(`Graph memory file exceeds its ${maxFileBytes}-byte limit`);
114
+ const parsed = JSON.parse(raw.toString("utf8")) as Partial<GraphFile>;
115
+ if (parsed.version !== 1 || !Array.isArray(parsed.nodes) || !Array.isArray(parsed.relations)) throw new Error("Graph memory file has an unsupported format");
116
+ if (!parsed.nodes.every(isGraphNode)) throw new Error("Graph memory file contains invalid nodes");
117
+ if (!parsed.relations.every(isGraphRelation)) throw new Error("Graph memory file contains invalid relations");
118
+ if (parsed.nodes.length > nodeLimit) throw new Error(`Graph memory file exceeds its ${nodeLimit}-node limit`);
119
+ if (parsed.relations.length > relationLimit) throw new Error(`Graph memory file exceeds its ${relationLimit}-relation limit`);
120
+ const nodeIds = new Set(parsed.nodes.map((node) => node.id));
121
+ const relationIds = new Set<string>();
122
+ for (const relation of parsed.relations) {
123
+ if (!nodeIds.has(relation.from) || !nodeIds.has(relation.to)) throw new Error("Graph memory file contains relations with missing nodes");
124
+ if (relation.from === relation.to) throw new Error("Graph memory file contains self-relations");
125
+ if (!relationIds.add(relation.id)) throw new Error("Graph memory file contains duplicate relation ids");
126
+ }
127
+ if (nodeIds.size !== parsed.nodes.length) throw new Error("Graph memory file contains duplicate node ids");
128
+ return { nodes: parsed.nodes, relations: parsed.relations };
129
+ }
130
+
131
+ async function writeGraphFile(filePath: string, state: GraphState): Promise<void> {
132
+ const payload = JSON.stringify({ version: 1, ...state } satisfies GraphFile, null, 2);
133
+ await mkdir(dirname(filePath), { recursive: true });
134
+ const temporary = join(dirname(filePath), `.${basename(filePath)}.${randomUUID()}.tmp`);
135
+ await writeFile(temporary, payload, { encoding: "utf8", mode: 0o600 });
136
+ await rename(temporary, filePath);
137
+ }
138
+
139
+ async function acquireGraphLock(lockPath: string): Promise<() => Promise<void>> {
140
+ const deadline = Date.now() + lockTimeoutMs;
141
+ while (true) {
142
+ try {
143
+ await mkdir(lockPath);
144
+ return async () => {
145
+ await rm(lockPath, { recursive: true, force: true });
146
+ };
147
+ } catch (error) {
148
+ if ((error as NodeJS.ErrnoException).code !== "EEXIST" || Date.now() >= deadline)
149
+ throw new Error("Timed out waiting for graph memory file lock", { cause: error });
150
+ await new Promise<void>((resolve) => setTimeout(resolve, lockRetryMs));
151
+ }
152
+ }
153
+ }
154
+
155
+ export default {
156
+ name: "pi-graph-memory",
157
+ inject: ["piHarnessLaunch", "piPluginUi", "piTools"],
158
+ Config,
159
+ apply(context: Context, config: GraphMemoryPluginConfig) {
160
+ const filePath = normalizeFilePath(context.piHarnessLaunch.agentDir, config.fileName);
161
+ const nodeLimit = Math.max(1, Math.min(absoluteNodeLimit, Math.trunc(config.maxNodes ?? absoluteNodeLimit)));
162
+ const relationLimit = Math.max(1, Math.min(absoluteRelationLimit, Math.trunc(config.maxRelations ?? absoluteRelationLimit)));
163
+ let nodes: GraphNode[] = [];
164
+ let relations: GraphRelation[] = [];
165
+ let loaded = false;
166
+ let loading: Promise<void> | undefined;
167
+ let mutationQueue = Promise.resolve();
168
+ let lastSearch: GraphSearchReport | undefined;
169
+
170
+ const load = async (): Promise<void> => {
171
+ if (loaded) return;
172
+ if (loading !== undefined) return loading;
173
+ loading = (async () => {
174
+ const state = await readGraphFile(filePath, nodeLimit, relationLimit);
175
+ nodes = state.nodes;
176
+ relations = state.relations;
177
+ loaded = true;
178
+ })();
179
+ return loading;
180
+ };
181
+
182
+ const mutate = async <T>(operation: (state: GraphState) => T): Promise<T> => {
183
+ let result: T | undefined;
184
+ const run = async (): Promise<void> => {
185
+ const release = await acquireGraphLock(`${filePath}.lock`);
186
+ try {
187
+ const state = await readGraphFile(filePath, nodeLimit, relationLimit);
188
+ result = operation(state);
189
+ await writeGraphFile(filePath, state);
190
+ nodes = state.nodes;
191
+ relations = state.relations;
192
+ loaded = true;
193
+ } finally {
194
+ await release();
195
+ }
196
+ };
197
+ mutationQueue = mutationQueue.catch(() => undefined).then(run);
198
+ await mutationQueue;
199
+ return result as T;
200
+ };
201
+
202
+ const recordTool = defineTool({
203
+ name: "graph_memory_record",
204
+ label: "Record graph memory",
205
+ description: "Persist or update one typed task, skill, or event node with explicit provenance in the local graph memory.",
206
+ promptSnippet: "record durable typed knowledge in the local graph memory",
207
+ parameters: Type.Object({
208
+ kind: Type.Union([Type.Literal("task"), Type.Literal("skill"), Type.Literal("event")]),
209
+ label: Type.String(),
210
+ summary: Type.String(),
211
+ source: Type.Optional(Type.String()),
212
+ }),
213
+ async execute(_toolCallId, params): Promise<AgentToolResult<GraphNode>> {
214
+ const label = normalizeText(params.label, "Graph memory label", maxLabelLength);
215
+ const summary = normalizeSummary(params.summary);
216
+ const source = params.source === undefined ? undefined : normalizeText(params.source, "Graph memory source", maxSourceLength);
217
+ const node = await mutate((state) => {
218
+ const existing = state.nodes.find((candidate) => candidate.kind === params.kind && candidate.label.toLocaleLowerCase() === label.toLocaleLowerCase());
219
+ if (existing === undefined && state.nodes.length >= nodeLimit) throw new Error(`Graph memory reached its ${nodeLimit}-node limit`);
220
+ const now = new Date().toISOString();
221
+ const next: GraphNode =
222
+ existing === undefined
223
+ ? { id: randomUUID(), kind: params.kind, label, summary, ...(source === undefined ? {} : { source }), createdAt: now, updatedAt: now }
224
+ : { ...existing, label, summary, ...(source === undefined ? {} : { source }), updatedAt: now };
225
+ state.nodes = [next, ...state.nodes.filter((candidate) => candidate.id !== next.id)];
226
+ return next;
227
+ });
228
+ return { content: [{ type: "text", text: `Graph memory recorded: ${node.id} [${node.kind}] ${node.label}` }], details: node };
229
+ },
230
+ });
231
+
232
+ const linkTool = defineTool({
233
+ name: "graph_memory_link",
234
+ label: "Link graph memories",
235
+ description: "Create one typed directed relation between two existing graph-memory nodes.",
236
+ promptSnippet: "link two graph memories with a typed relation",
237
+ parameters: Type.Object({
238
+ from: Type.String(),
239
+ to: Type.String(),
240
+ relation: Type.Union([
241
+ Type.Literal("USED_SKILL"),
242
+ Type.Literal("SOLVED_BY"),
243
+ Type.Literal("REQUIRES"),
244
+ Type.Literal("PATCHES"),
245
+ Type.Literal("CONFLICTS_WITH"),
246
+ Type.Literal("RELATED_TO"),
247
+ ]),
248
+ }),
249
+ async execute(_toolCallId, params): Promise<AgentToolResult<GraphRelation>> {
250
+ const from = normalizeText(params.from, "Graph relation source id", maxLabelLength);
251
+ const to = normalizeText(params.to, "Graph relation target id", maxLabelLength);
252
+ if (from === to) throw new Error("Graph memory relations require two different nodes");
253
+ const relation = await mutate((state) => {
254
+ if (!state.nodes.some((node) => node.id === from)) throw new Error(`Graph memory source node not found: ${from}`);
255
+ if (!state.nodes.some((node) => node.id === to)) throw new Error(`Graph memory target node not found: ${to}`);
256
+ const existing = state.relations.find((candidate) => candidate.from === from && candidate.to === to && candidate.relation === params.relation);
257
+ if (existing !== undefined) return existing;
258
+ if (state.relations.length >= relationLimit) throw new Error(`Graph memory reached its ${relationLimit}-relation limit`);
259
+ const next: GraphRelation = { id: randomUUID(), from, to, relation: params.relation, createdAt: new Date().toISOString() };
260
+ state.relations = [next, ...state.relations];
261
+ return next;
262
+ });
263
+ return {
264
+ content: [{ type: "text", text: `Graph relation ${relation.id} ${relation.relation}: ${relation.from} → ${relation.to}` }],
265
+ details: relation,
266
+ };
267
+ },
268
+ });
269
+
270
+ const searchTool = defineTool({
271
+ name: "graph_memory_search",
272
+ label: "Search graph memory",
273
+ description: "Search typed graph-memory nodes by label, summary, provenance, kind, or connected relation.",
274
+ promptSnippet: "search the local cross-session knowledge graph",
275
+ parameters: Type.Object({
276
+ query: Type.String(),
277
+ kind: Type.Optional(Type.Union([Type.Literal("task"), Type.Literal("skill"), Type.Literal("event")])),
278
+ limit: Type.Optional(Type.Number()),
279
+ }),
280
+ async execute(_toolCallId, params): Promise<AgentToolResult<GraphSearchReport>> {
281
+ await load();
282
+ const query = normalizeText(params.query, "Graph memory query", maxQueryLength);
283
+ if (query.length < 2) throw new Error(`Graph memory query must contain 2-${maxQueryLength} characters`);
284
+ const needle = query.toLocaleLowerCase();
285
+ const limit = Math.max(1, Math.min(50, Math.trunc(params.limit ?? 12)));
286
+ const ranked = nodes
287
+ .filter((node) => params.kind === undefined || node.kind === params.kind)
288
+ .map((node) => {
289
+ const label = node.label.toLocaleLowerCase();
290
+ const summary = node.summary.toLocaleLowerCase();
291
+ const source = node.source?.toLocaleLowerCase() ?? "";
292
+ const relationHit = relations.some((relation) => {
293
+ if (relation.from !== node.id && relation.to !== node.id) return false;
294
+ if (relation.relation.toLocaleLowerCase().includes(needle)) return true;
295
+ const neighborId = relation.from === node.id ? relation.to : relation.from;
296
+ return (
297
+ nodes
298
+ .find((candidate) => candidate.id === neighborId)
299
+ ?.label.toLocaleLowerCase()
300
+ .includes(needle) ?? false
301
+ );
302
+ });
303
+ const score =
304
+ label === needle ? 100 : label.includes(needle) ? 60 : summary.includes(needle) ? 30 : source.includes(needle) || node.kind === needle ? 15 : 0;
305
+ return { node, score: score > 0 ? score : relationHit ? 20 : 0 };
306
+ })
307
+ .filter((match) => match.score > 0)
308
+ .sort((left, right) => right.score - left.score || right.node.updatedAt.localeCompare(left.node.updatedAt));
309
+ const matches = ranked.slice(0, limit).map((match) => match.node);
310
+ const matchedIds = new Set(matches.map((node) => node.id));
311
+ const matchedRelations = relations.filter((relation) => matchedIds.has(relation.from) || matchedIds.has(relation.to)).slice(0, limit * 4);
312
+ lastSearch = { query, total: ranked.length, nodes: matches, relations: matchedRelations };
313
+ return {
314
+ content: [
315
+ {
316
+ type: "text",
317
+ text:
318
+ matches.length === 0
319
+ ? `No graph memories found for ${query}.`
320
+ : matches.map((node) => `${node.id} [${node.kind}] ${node.label}: ${node.summary}`).join("\n"),
321
+ },
322
+ ],
323
+ details: lastSearch,
324
+ };
325
+ },
326
+ });
327
+
328
+ const forgetTool = defineTool({
329
+ name: "graph_memory_forget",
330
+ label: "Forget graph memory",
331
+ description: "Delete one graph-memory node and all incident relations after explicit confirmation.",
332
+ promptSnippet: "forget a graph memory after confirmation",
333
+ parameters: Type.Object({ id: Type.String(), confirm: Type.Boolean() }),
334
+ async execute(_toolCallId, params): Promise<AgentToolResult<{ id: string; removed: boolean; removedRelations: number }>> {
335
+ const id = normalizeText(params.id, "Graph memory node id", maxLabelLength);
336
+ if (params.confirm !== true) throw new Error("Deleting a graph memory requires confirm=true");
337
+ const result = await mutate((state) => {
338
+ const beforeNodes = state.nodes.length;
339
+ const beforeRelations = state.relations.length;
340
+ state.nodes = state.nodes.filter((node) => node.id !== id);
341
+ state.relations = state.relations.filter((relation) => relation.from !== id && relation.to !== id);
342
+ return { id, removed: state.nodes.length !== beforeNodes, removedRelations: beforeRelations - state.relations.length };
343
+ });
344
+ return {
345
+ content: [{ type: "text", text: result.removed ? `Graph memory deleted: ${id}` : `Graph memory not found: ${id}` }],
346
+ details: result,
347
+ };
348
+ },
349
+ });
350
+
351
+ const disposers: Array<() => void> = [];
352
+ try {
353
+ disposers.push(context.piTools.register(recordTool));
354
+ disposers.push(context.piTools.register(linkTool));
355
+ disposers.push(context.piTools.register(searchTool));
356
+ disposers.push(context.piTools.register(forgetTool));
357
+ disposers.push(
358
+ context.piPluginUi.register({
359
+ id: "graph-memory-panel",
360
+ pluginId: "@pi-harness/core/plugins/graph-memory",
361
+ title: "Graph Memory",
362
+ description: "显式记录任务、技能与事件关系,保留来源并跨会话查询。",
363
+ icon: "⌬",
364
+ read: async () => {
365
+ await load();
366
+ return {
367
+ filePath,
368
+ nodes: nodes.length,
369
+ relations: relations.length,
370
+ kinds: {
371
+ task: nodes.filter((node) => node.kind === "task").length,
372
+ skill: nodes.filter((node) => node.kind === "skill").length,
373
+ event: nodes.filter((node) => node.kind === "event").length,
374
+ },
375
+ recent: nodes.slice(0, 8),
376
+ recentRelations: relations.slice(0, 8).map((relation) => ({
377
+ ...relation,
378
+ fromLabel: nodes.find((node) => node.id === relation.from)?.label ?? relation.from,
379
+ toLabel: nodes.find((node) => node.id === relation.to)?.label ?? relation.to,
380
+ })),
381
+ lastSearch: lastSearch ?? null,
382
+ };
383
+ },
384
+ }),
385
+ );
386
+ } catch (error) {
387
+ for (const dispose of disposers.reverse()) dispose();
388
+ throw error;
389
+ }
390
+ context.effect(() => () => {
391
+ for (const dispose of disposers.reverse()) dispose();
392
+ });
393
+ },
394
+ };
@@ -0,0 +1,81 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import { Type } from "@earendil-works/pi-ai";
3
+ import { defineTool, type AgentToolResult } from "@earendil-works/pi-coding-agent";
4
+ import z from "@deepseek-ai/schemastery";
5
+
6
+ type CompressionState = { enabled: boolean; thresholdPercent: number; compactions: number; lastUsagePercent: number | null; lastError: string | null };
7
+ export interface HistoryCompressorPluginConfig {
8
+ enabled?: boolean;
9
+ thresholdPercent?: number;
10
+ }
11
+ export const Config: z<HistoryCompressorPluginConfig> = z.object({ enabled: z.boolean().default(true), thresholdPercent: z.number().default(85) });
12
+
13
+ export default {
14
+ name: "pi-history-compressor",
15
+ inject: ["piPluginUi", "piTools"],
16
+ Config,
17
+ apply(context: Context, config: HistoryCompressorPluginConfig) {
18
+ const enabled = config.enabled !== false;
19
+ const thresholdPercent = Math.max(1, Math.min(100, config.thresholdPercent ?? 85));
20
+ const state: CompressionState = { enabled, thresholdPercent, compactions: 0, lastUsagePercent: null, lastError: null };
21
+ let inFlight = false;
22
+ const runtime = () => context.get("piRuntime");
23
+ const compact = async (automatic: boolean): Promise<{ compacted: boolean; automatic: boolean }> => {
24
+ const service = runtime();
25
+ if (service === undefined) throw new Error("Pi runtime is not ready");
26
+ if (automatic && !enabled) return { compacted: false, automatic };
27
+ if (inFlight) return { compacted: false, automatic };
28
+ inFlight = true;
29
+ try {
30
+ await service.session.compact();
31
+ state.compactions += 1;
32
+ state.lastError = null;
33
+ return { compacted: true, automatic };
34
+ } catch (error) {
35
+ state.lastError = error instanceof Error ? error.message : String(error);
36
+ throw error;
37
+ } finally {
38
+ inFlight = false;
39
+ }
40
+ };
41
+ const inspectAndMaybeCompact = (): void => {
42
+ const service = runtime();
43
+ const usage = service?.session.getContextUsage();
44
+ state.lastUsagePercent = typeof usage?.percent === "number" ? usage.percent : null;
45
+ if (enabled && state.lastUsagePercent !== null && state.lastUsagePercent >= thresholdPercent) void compact(true).catch(() => undefined);
46
+ };
47
+ const unsubscribe = context.on("pi/session-event", (event) => {
48
+ if ((event as { type?: string }).type === "agent_end") inspectAndMaybeCompact();
49
+ });
50
+ const unregisterTool = context.piTools.register(
51
+ defineTool({
52
+ name: "compress_history",
53
+ label: "Compress history",
54
+ description: "Compact the current Pi session after explicit confirmation.",
55
+ promptSnippet: "compact the current conversation history",
56
+ parameters: Type.Object({ confirm: Type.Boolean({ description: "Must be true to compact history" }) }),
57
+ async execute(_toolCallId, params): Promise<AgentToolResult<{ compacted: boolean; automatic: boolean }>> {
58
+ if (params.confirm !== true) throw new Error("History compaction requires confirm=true");
59
+ const result = await compact(false);
60
+ return {
61
+ content: [{ type: "text", text: result.compacted ? "Session history compacted." : "Session compaction is already running." }],
62
+ details: result,
63
+ };
64
+ },
65
+ }),
66
+ );
67
+ const disposePanel = context.piPluginUi.register({
68
+ id: "history-compressor-panel",
69
+ pluginId: "@pi-harness/core/plugins/history-compressor",
70
+ title: "History Compressor",
71
+ description: "在上下文接近阈值时自动压缩历史消息。",
72
+ icon: "↯",
73
+ read: () => ({ ...state }),
74
+ });
75
+ context.effect(() => () => {
76
+ unsubscribe();
77
+ unregisterTool();
78
+ disposePanel();
79
+ });
80
+ },
81
+ };