@evandu/super-pi-server 0.0.0-stage → 0.1.260

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 (370) hide show
  1. package/README.md +250 -3
  2. package/agents/code-auditor.md +64 -0
  3. package/agents/code-designer.md +64 -0
  4. package/agents/coder.md +24 -0
  5. package/agents/critic.md +24 -0
  6. package/agents/document-organizer.md +48 -0
  7. package/agents/patcher.md +27 -0
  8. package/agents/planner.md +30 -0
  9. package/agents/project-leader.md +28 -0
  10. package/agents/reviewer.md +27 -0
  11. package/agents/scout.md +27 -0
  12. package/agents/solution-designer.md +62 -0
  13. package/agents/super-pi-documents/index.ts +92 -0
  14. package/agents/super-pi-feishu/index.ts +88 -0
  15. package/agents/super-pi-knowledge/index.ts +70 -0
  16. package/agents/super-pi-managed-model/index.ts +9 -0
  17. package/agents/super-pi-memory/index.ts +75 -0
  18. package/agents/super-pi-native-tools/index.ts +1 -0
  19. package/agents/super-pi-task/core.ts +2262 -0
  20. package/agents/super-pi-task/index.ts +814 -0
  21. package/agents/super-pi-task/workflow-schema.ts +34 -0
  22. package/agents/super-pi-web/index.ts +32 -0
  23. package/agents/verifier.md +25 -0
  24. package/assets/fonts/LICENSE +92 -0
  25. package/assets/fonts/NotoSansSC-Bold.otf +0 -0
  26. package/assets/fonts/NotoSansSC-Regular.otf +0 -0
  27. package/assets/knowledge-model/README.md +37 -0
  28. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/config.json +31 -0
  29. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/onnx/model_quantized.onnx +0 -0
  30. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/special_tokens_map.json +7 -0
  31. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer.json +21278 -0
  32. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer_config.json +15 -0
  33. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/vocab.txt +21128 -0
  34. package/bin/npm-prefix.d.ts +1 -0
  35. package/bin/npm-prefix.js +10 -0
  36. package/bin/super-pi.js +349 -0
  37. package/dist/client/.super-pi-client-sources.json +82 -0
  38. package/dist/client/assets/CodeMirrorEditor-mi9rGUce.js +2 -0
  39. package/dist/client/assets/GitDiffEditor-CpoDDQrA.css +1 -0
  40. package/dist/client/assets/GitDiffEditor-FQBfGxOY.js +29 -0
  41. package/dist/client/assets/diff-ChtP43wD.js +1 -0
  42. package/dist/client/assets/dist-AW5lyI3I.js +1 -0
  43. package/dist/client/assets/dist-B3-a6uF0.js +7 -0
  44. package/dist/client/assets/dist-BGxkyh6e.js +1 -0
  45. package/dist/client/assets/dist-BJxfd7yb.js +11 -0
  46. package/dist/client/assets/dist-BRVQKlcp.js +1 -0
  47. package/dist/client/assets/dist-BV64A9Ji.js +1 -0
  48. package/dist/client/assets/dist-BXAOrsjq.js +1 -0
  49. package/dist/client/assets/dist-CKF2Jksy.js +1 -0
  50. package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
  51. package/dist/client/assets/dist-Cus6_oaF.js +2 -0
  52. package/dist/client/assets/dist-Cx00EZKR.js +23 -0
  53. package/dist/client/assets/dist-D71y2EI1.js +1 -0
  54. package/dist/client/assets/dist-D978o95T.js +5 -0
  55. package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
  56. package/dist/client/assets/dist-Dds-qLxY.js +9 -0
  57. package/dist/client/assets/dist-DeD9copn.js +1 -0
  58. package/dist/client/assets/dist-DuvGReu-.js +6 -0
  59. package/dist/client/assets/dist-Dvb0SqcK.js +2 -0
  60. package/dist/client/assets/dist-J6XWqRpB.js +3 -0
  61. package/dist/client/assets/dist-QzbOCAU6.js +1 -0
  62. package/dist/client/assets/dist-moiMRpw_.js +1 -0
  63. package/dist/client/assets/dist-scBkrwv-.js +2 -0
  64. package/dist/client/assets/dockerfile-BDePf5PZ.js +1 -0
  65. package/dist/client/assets/index-Cn7hdrDw.js +350 -0
  66. package/dist/client/assets/index-UfzqdECL.css +1 -0
  67. package/dist/client/assets/powershell-D8WpQPaX.js +1 -0
  68. package/dist/client/assets/properties-C357ku5U.js +1 -0
  69. package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  70. package/dist/client/assets/ruby-ChfNwlCY.js +1 -0
  71. package/dist/client/assets/shell-DwuoZtxw.js +1 -0
  72. package/dist/client/assets/swift-DKB6_1j6.js +1 -0
  73. package/dist/client/assets/toml-BPTmHmyx.js +1 -0
  74. package/dist/client/favicon.ico +0 -0
  75. package/dist/client/favicon.png +0 -0
  76. package/dist/client/favicon.svg +10 -0
  77. package/dist/client/index.html +18 -0
  78. package/dist/extension.d.ts +15 -0
  79. package/dist/extension.js +126 -0
  80. package/dist/server/active-memory.d.ts +247 -0
  81. package/dist/server/active-memory.js +669 -0
  82. package/dist/server/agents.d.ts +245 -0
  83. package/dist/server/agents.js +701 -0
  84. package/dist/server/application/catalog-service.d.ts +98 -0
  85. package/dist/server/application/catalog-service.js +245 -0
  86. package/dist/server/application/conversation-service.d.ts +245 -0
  87. package/dist/server/application/conversation-service.js +654 -0
  88. package/dist/server/application/document-service.d.ts +68 -0
  89. package/dist/server/application/document-service.js +120 -0
  90. package/dist/server/application/extension-ui-service.d.ts +44 -0
  91. package/dist/server/application/extension-ui-service.js +135 -0
  92. package/dist/server/application/feishu-service.d.ts +179 -0
  93. package/dist/server/application/feishu-service.js +358 -0
  94. package/dist/server/application/group-chat-service.d.ts +75 -0
  95. package/dist/server/application/group-chat-service.js +953 -0
  96. package/dist/server/application/group-execution.d.ts +15 -0
  97. package/dist/server/application/group-execution.js +77 -0
  98. package/dist/server/application/project-service.d.ts +464 -0
  99. package/dist/server/application/project-service.js +2523 -0
  100. package/dist/server/application/provider-service.d.ts +174 -0
  101. package/dist/server/application/provider-service.js +510 -0
  102. package/dist/server/application/run-service.d.ts +547 -0
  103. package/dist/server/application/run-service.js +2683 -0
  104. package/dist/server/application/scheduled-task-service.d.ts +184 -0
  105. package/dist/server/application/scheduled-task-service.js +391 -0
  106. package/dist/server/application/session-orchestrator-service.d.ts +388 -0
  107. package/dist/server/application/session-orchestrator-service.js +1146 -0
  108. package/dist/server/application/session-reminder-service.d.ts +59 -0
  109. package/dist/server/application/session-reminder-service.js +141 -0
  110. package/dist/server/application/session-watchdog.d.ts +171 -0
  111. package/dist/server/application/session-watchdog.js +284 -0
  112. package/dist/server/application/workspace-service.d.ts +52 -0
  113. package/dist/server/application/workspace-service.js +186 -0
  114. package/dist/server/application/worktree-service.d.ts +13 -0
  115. package/dist/server/application/worktree-service.js +76 -0
  116. package/dist/server/browser-access.d.ts +34 -0
  117. package/dist/server/browser-access.js +89 -0
  118. package/dist/server/capability.d.ts +105 -0
  119. package/dist/server/capability.js +170 -0
  120. package/dist/server/command-handler.d.ts +93 -0
  121. package/dist/server/command-handler.js +540 -0
  122. package/dist/server/content-search.d.ts +16 -0
  123. package/dist/server/content-search.js +235 -0
  124. package/dist/server/conversation-usage.d.ts +22 -0
  125. package/dist/server/conversation-usage.js +43 -0
  126. package/dist/server/documents.d.ts +152 -0
  127. package/dist/server/documents.js +998 -0
  128. package/dist/server/engineering-learning.d.ts +30 -0
  129. package/dist/server/engineering-learning.js +106 -0
  130. package/dist/server/exec-service.d.ts +45 -0
  131. package/dist/server/exec-service.js +167 -0
  132. package/dist/server/explicit-file-open.d.ts +34 -0
  133. package/dist/server/explicit-file-open.js +105 -0
  134. package/dist/server/failure-text.d.ts +18 -0
  135. package/dist/server/failure-text.js +44 -0
  136. package/dist/server/feishu-cli.d.ts +223 -0
  137. package/dist/server/feishu-cli.js +464 -0
  138. package/dist/server/file-changes.d.ts +119 -0
  139. package/dist/server/file-changes.js +280 -0
  140. package/dist/server/file-diff.d.ts +41 -0
  141. package/dist/server/file-diff.js +97 -0
  142. package/dist/server/file-index.d.ts +100 -0
  143. package/dist/server/file-index.js +296 -0
  144. package/dist/server/file-name-index.d.ts +160 -0
  145. package/dist/server/file-name-index.js +411 -0
  146. package/dist/server/files.d.ts +269 -0
  147. package/dist/server/files.js +748 -0
  148. package/dist/server/git.d.ts +245 -0
  149. package/dist/server/git.js +903 -0
  150. package/dist/server/http-server.d.ts +45 -0
  151. package/dist/server/http-server.js +3830 -0
  152. package/dist/server/index.d.ts +1 -0
  153. package/dist/server/index.js +485 -0
  154. package/dist/server/inline-thinking.d.ts +90 -0
  155. package/dist/server/inline-thinking.js +181 -0
  156. package/dist/server/json-comments.d.ts +14 -0
  157. package/dist/server/json-comments.js +71 -0
  158. package/dist/server/knowledge-embedding-worker.d.ts +1 -0
  159. package/dist/server/knowledge-embedding-worker.js +27 -0
  160. package/dist/server/knowledge-vectors.d.ts +150 -0
  161. package/dist/server/knowledge-vectors.js +385 -0
  162. package/dist/server/knowledge.d.ts +273 -0
  163. package/dist/server/knowledge.js +848 -0
  164. package/dist/server/length-continuation.d.ts +83 -0
  165. package/dist/server/length-continuation.js +118 -0
  166. package/dist/server/logging.d.ts +32 -0
  167. package/dist/server/logging.js +185 -0
  168. package/dist/server/managed-http-tunnel.d.ts +6 -0
  169. package/dist/server/managed-http-tunnel.js +85 -0
  170. package/dist/server/managed-http.d.ts +4 -0
  171. package/dist/server/managed-http.js +85 -0
  172. package/dist/server/managed-model-adapter.d.ts +17 -0
  173. package/dist/server/managed-model-adapter.js +75 -0
  174. package/dist/server/managed-model-gateway.d.ts +49 -0
  175. package/dist/server/managed-model-gateway.js +73 -0
  176. package/dist/server/managed-servers.d.ts +55 -0
  177. package/dist/server/managed-servers.js +396 -0
  178. package/dist/server/managed-ssh.d.ts +26 -0
  179. package/dist/server/managed-ssh.js +73 -0
  180. package/dist/server/manager-vault.d.ts +11 -0
  181. package/dist/server/manager-vault.js +67 -0
  182. package/dist/server/memory-recall.d.ts +25 -0
  183. package/dist/server/memory-recall.js +45 -0
  184. package/dist/server/memory.d.ts +67 -0
  185. package/dist/server/memory.js +216 -0
  186. package/dist/server/message-media.d.ts +7 -0
  187. package/dist/server/message-media.js +54 -0
  188. package/dist/server/model-context-window.d.ts +186 -0
  189. package/dist/server/model-context-window.js +444 -0
  190. package/dist/server/model-filter.d.ts +23 -0
  191. package/dist/server/model-filter.js +48 -0
  192. package/dist/server/models-store.d.ts +36 -0
  193. package/dist/server/models-store.js +132 -0
  194. package/dist/server/native-tool-settings.d.ts +25 -0
  195. package/dist/server/native-tool-settings.js +41 -0
  196. package/dist/server/native-tools-extension.d.ts +2 -0
  197. package/dist/server/native-tools-extension.js +39 -0
  198. package/dist/server/native-tools-service.d.ts +39 -0
  199. package/dist/server/native-tools-service.js +240 -0
  200. package/dist/server/persistence/app-state-repository.d.ts +65 -0
  201. package/dist/server/persistence/app-state-repository.js +1 -0
  202. package/dist/server/persistence/json-state-repository.d.ts +14 -0
  203. package/dist/server/persistence/json-state-repository.js +43 -0
  204. package/dist/server/persistence/open-state-store.d.ts +3 -0
  205. package/dist/server/persistence/open-state-store.js +35 -0
  206. package/dist/server/persistence/rename.d.ts +22 -0
  207. package/dist/server/persistence/rename.js +44 -0
  208. package/dist/server/persistence/sqlite-state-repository.d.ts +12 -0
  209. package/dist/server/persistence/sqlite-state-repository.js +264 -0
  210. package/dist/server/pi-command.d.ts +94 -0
  211. package/dist/server/pi-command.js +265 -0
  212. package/dist/server/pi-native.d.ts +12 -0
  213. package/dist/server/pi-native.js +16 -0
  214. package/dist/server/pi-session-events.d.ts +158 -0
  215. package/dist/server/pi-session-events.js +373 -0
  216. package/dist/server/pi-session-pool.d.ts +233 -0
  217. package/dist/server/pi-session-pool.js +382 -0
  218. package/dist/server/pi-session.d.ts +642 -0
  219. package/dist/server/pi-session.js +655 -0
  220. package/dist/server/presentations/schema.d.ts +120 -0
  221. package/dist/server/presentations/schema.js +128 -0
  222. package/dist/server/provider-network.d.ts +16 -0
  223. package/dist/server/provider-network.js +106 -0
  224. package/dist/server/provider-proxy.d.ts +18 -0
  225. package/dist/server/provider-proxy.js +200 -0
  226. package/dist/server/providers.d.ts +333 -0
  227. package/dist/server/providers.js +989 -0
  228. package/dist/server/remote-bootstrap.d.ts +17 -0
  229. package/dist/server/remote-bootstrap.js +119 -0
  230. package/dist/server/rpc-channel.d.ts +131 -0
  231. package/dist/server/rpc-channel.js +135 -0
  232. package/dist/server/runtime.d.ts +1393 -0
  233. package/dist/server/runtime.js +3286 -0
  234. package/dist/server/scheduled-tasks.d.ts +101 -0
  235. package/dist/server/scheduled-tasks.js +138 -0
  236. package/dist/server/server-context.d.ts +119 -0
  237. package/dist/server/server-context.js +1 -0
  238. package/dist/server/session-cwd.d.ts +19 -0
  239. package/dist/server/session-cwd.js +58 -0
  240. package/dist/server/session-ledger.d.ts +67 -0
  241. package/dist/server/session-ledger.js +76 -0
  242. package/dist/server/session-memory-scope.d.ts +4 -0
  243. package/dist/server/session-memory-scope.js +30 -0
  244. package/dist/server/session-repository.d.ts +100 -0
  245. package/dist/server/session-repository.js +246 -0
  246. package/dist/server/session-tree-scope.d.ts +125 -0
  247. package/dist/server/session-tree-scope.js +337 -0
  248. package/dist/server/skills.d.ts +23 -0
  249. package/dist/server/skills.js +190 -0
  250. package/dist/server/store.d.ts +1062 -0
  251. package/dist/server/store.js +3305 -0
  252. package/dist/server/subagent-runs.d.ts +185 -0
  253. package/dist/server/subagent-runs.js +383 -0
  254. package/dist/server/subagents.d.ts +200 -0
  255. package/dist/server/subagents.js +619 -0
  256. package/dist/server/task-tool.d.ts +282 -0
  257. package/dist/server/task-tool.js +507 -0
  258. package/dist/server/tavily.d.ts +32 -0
  259. package/dist/server/tavily.js +136 -0
  260. package/dist/server/team-context.d.ts +12 -0
  261. package/dist/server/team-context.js +180 -0
  262. package/dist/server/terminal.d.ts +163 -0
  263. package/dist/server/terminal.js +557 -0
  264. package/dist/server/thinking-level-discovery.d.ts +38 -0
  265. package/dist/server/thinking-level-discovery.js +183 -0
  266. package/dist/server/time-zone.d.ts +20 -0
  267. package/dist/server/time-zone.js +32 -0
  268. package/dist/server/tool-calls.d.ts +130 -0
  269. package/dist/server/tool-calls.js +341 -0
  270. package/dist/server/tool-llm.d.ts +72 -0
  271. package/dist/server/tool-llm.js +146 -0
  272. package/dist/server/tool-registry.d.ts +129 -0
  273. package/dist/server/tool-registry.js +249 -0
  274. package/dist/server/tool-runner.d.ts +112 -0
  275. package/dist/server/tool-runner.js +306 -0
  276. package/dist/server/turn-failure.d.ts +48 -0
  277. package/dist/server/turn-failure.js +148 -0
  278. package/dist/server/types.d.ts +2315 -0
  279. package/dist/server/types.js +11 -0
  280. package/dist/server/update-status.d.ts +14 -0
  281. package/dist/server/update-status.js +69 -0
  282. package/dist/server/update.d.ts +46 -0
  283. package/dist/server/update.js +104 -0
  284. package/dist/server/upload.d.ts +35 -0
  285. package/dist/server/upload.js +177 -0
  286. package/dist/server/version.d.ts +33 -0
  287. package/dist/server/version.js +111 -0
  288. package/dist/server/web.d.ts +27 -0
  289. package/dist/server/web.js +183 -0
  290. package/dist/server/workflow-engine.d.ts +47 -0
  291. package/dist/server/workflow-engine.js +255 -0
  292. package/dist/server/workflow.d.ts +329 -0
  293. package/dist/server/workflow.js +469 -0
  294. package/dist/server/workspace-file-indexes.d.ts +2 -0
  295. package/dist/server/workspace-file-indexes.js +61 -0
  296. package/dist/server/workspace-file-operations.d.ts +36 -0
  297. package/dist/server/workspace-file-operations.js +281 -0
  298. package/dist/server/workspace-file-response.d.ts +7 -0
  299. package/dist/server/workspace-file-response.js +79 -0
  300. package/dist/server/ws-server.d.ts +149 -0
  301. package/dist/server/ws-server.js +640 -0
  302. package/dist/shared/agent-order.d.ts +44 -0
  303. package/dist/shared/agent-order.js +50 -0
  304. package/dist/shared/archive-decisions.d.ts +44 -0
  305. package/dist/shared/archive-decisions.js +98 -0
  306. package/dist/shared/background-task.d.ts +25 -0
  307. package/dist/shared/background-task.js +183 -0
  308. package/dist/shared/child-session-lock.d.ts +37 -0
  309. package/dist/shared/child-session-lock.js +59 -0
  310. package/dist/shared/content-search.d.ts +22 -0
  311. package/dist/shared/content-search.js +1 -0
  312. package/dist/shared/conversation-title.d.ts +4 -0
  313. package/dist/shared/conversation-title.js +4 -0
  314. package/dist/shared/file-mentions.d.ts +17 -0
  315. package/dist/shared/file-mentions.js +91 -0
  316. package/dist/shared/git-commit.d.ts +11 -0
  317. package/dist/shared/git-commit.js +1 -0
  318. package/dist/shared/git-graph.d.ts +42 -0
  319. package/dist/shared/git-graph.js +30 -0
  320. package/dist/shared/group-chat.d.ts +132 -0
  321. package/dist/shared/group-chat.js +6 -0
  322. package/dist/shared/managed-servers.d.ts +36 -0
  323. package/dist/shared/managed-servers.js +1 -0
  324. package/dist/shared/message-media.d.ts +12 -0
  325. package/dist/shared/message-media.js +27 -0
  326. package/dist/shared/model-window-label.d.ts +39 -0
  327. package/dist/shared/model-window-label.js +55 -0
  328. package/dist/shared/native-tools.d.ts +43 -0
  329. package/dist/shared/native-tools.js +1 -0
  330. package/dist/shared/pi-cache-warming.d.ts +9 -0
  331. package/dist/shared/pi-cache-warming.js +4 -0
  332. package/dist/shared/project-overview.d.ts +107 -0
  333. package/dist/shared/project-overview.js +92 -0
  334. package/dist/shared/project-presentation.d.ts +55 -0
  335. package/dist/shared/project-presentation.js +111 -0
  336. package/dist/shared/provider-network.d.ts +30 -0
  337. package/dist/shared/provider-network.js +1 -0
  338. package/dist/shared/session-reporting.d.ts +40 -0
  339. package/dist/shared/session-reporting.js +97 -0
  340. package/dist/shared/session-search.d.ts +14 -0
  341. package/dist/shared/session-search.js +1 -0
  342. package/dist/shared/team-context-view.d.ts +33 -0
  343. package/dist/shared/team-context-view.js +49 -0
  344. package/dist/shared/team-context.d.ts +59 -0
  345. package/dist/shared/team-context.js +3 -0
  346. package/dist/shared/terminal-protocol.d.ts +71 -0
  347. package/dist/shared/terminal-protocol.js +1 -0
  348. package/dist/shared/thinking-levels.d.ts +53 -0
  349. package/dist/shared/thinking-levels.js +85 -0
  350. package/dist/shared/tool-glyph.d.ts +7 -0
  351. package/dist/shared/tool-glyph.js +19 -0
  352. package/dist/shared/transcript-order.d.ts +7 -0
  353. package/dist/shared/transcript-order.js +12 -0
  354. package/dist/shared/update-status.d.ts +28 -0
  355. package/dist/shared/update-status.js +1 -0
  356. package/dist/shared/workspace-file-preview.d.ts +4 -0
  357. package/dist/shared/workspace-file-preview.js +28 -0
  358. package/package.json +450 -4
  359. package/scripts/diagnose.mjs +603 -0
  360. package/scripts/patch-brace-expansion.mjs +260 -0
  361. package/scripts/restart-server.mjs +104 -0
  362. package/skills/presentation/SKILL.md +30 -0
  363. package/skills/presentation/references/data.md +10 -0
  364. package/skills/presentation/references/quality.md +12 -0
  365. package/skills/presentation/references/story.md +12 -0
  366. package/skills/presentation/references/templates-and-editing.md +11 -0
  367. package/skills/presentation/references/visual-system.md +10 -0
  368. package/skills/super-pi-agent-development/SKILL.md +25 -0
  369. package/skills/super-pi-development/SKILL.md +31 -0
  370. package/skills/super-pi-tool-development/SKILL.md +39 -0
@@ -0,0 +1,337 @@
1
+ /** The depth cap on an ancestor walk. A tree deeper than this is a bug, not a reason to hang. */
2
+ const MAX_ANCESTOR_DEPTH = 64;
3
+ /**
4
+ * The chain of ancestors of a conversation, starting with the conversation itself.
5
+ *
6
+ * A dangling parent (one whose conversation is gone) simply ends the chain, and a cycle is cut by
7
+ * the depth cap: the walk is for the message, so it must terminate whatever the data says.
8
+ */
9
+ const ancestorChain = (store, conversationId) => {
10
+ const chain = [];
11
+ const seen = new Set();
12
+ let current = conversationId;
13
+ while (current && !seen.has(current) && chain.length < MAX_ANCESTOR_DEPTH) {
14
+ seen.add(current);
15
+ chain.push(current);
16
+ current = store.conversation(current)?.parentConversationId;
17
+ }
18
+ return chain;
19
+ };
20
+ /**
21
+ * The relation between two sessions, in the tree.
22
+ *
23
+ * READ ONLY. This classifies a pair for the sake of the refusal message; it never grants access.
24
+ */
25
+ export const classifySessionRelation = (store, callerConversationId, targetConversationId) => {
26
+ if (callerConversationId === targetConversationId)
27
+ return "self";
28
+ const callerChain = ancestorChain(store, callerConversationId);
29
+ const targetChain = ancestorChain(store, targetConversationId);
30
+ if (targetChain[1] === callerConversationId)
31
+ return "direct-child";
32
+ // The caller sits somewhere above the target: the target is a descendant, a level down or more.
33
+ if (targetChain.indexOf(callerConversationId) > 0)
34
+ return "descendant";
35
+ // The target sits above the caller.
36
+ if (callerChain.indexOf(targetConversationId) > 0)
37
+ return "ancestor";
38
+ // The target has no parent at all: it is the root of another tree.
39
+ if (targetChain.length === 1)
40
+ return "other-root";
41
+ // A shared ancestor means the same chart; without one, another department.
42
+ const shared = targetChain.slice(1).find((id) => callerChain.slice(1).includes(id));
43
+ return shared ? "peer" : "unrelated";
44
+ };
45
+ /** The session between the caller and the target, when the target is a descendant of it. */
46
+ const intermediateSession = (store, callerConversationId, targetConversationId) => {
47
+ const chain = ancestorChain(store, targetConversationId);
48
+ const index = chain.indexOf(callerConversationId);
49
+ return index > 1 ? chain[index - 1] : undefined;
50
+ };
51
+ /** The nearest session both the caller and the target descend from, when there is one. */
52
+ const commonAncestorSession = (store, callerConversationId, targetConversationId) => {
53
+ const callerChain = ancestorChain(store, callerConversationId);
54
+ const targetChain = ancestorChain(store, targetConversationId);
55
+ return targetChain.slice(1).find((id) => callerChain.slice(1).includes(id));
56
+ };
57
+ /**
58
+ * The reason a pair was refused, in the words of the relation that was found.
59
+ *
60
+ * The reader is a model about to retry, or a person reading a log: the message says which relation
61
+ * was found (peer, grandchild, ancestor, another tree, another department) and what the rule is, so
62
+ * a retry with a different target is an informed one.
63
+ *
64
+ * The three subjects read differently on purpose. Refusing to DISPATCH a peer and refusing to
65
+ * LIST a peer's subordinates are the same boundary, but they are not the same mistake, and a
66
+ * reader who is told which one they made can fix the right thing.
67
+ */
68
+ const relationReason = (relation, subject, callerConversationId, targetConversationId, verb, intermediateId, ancestorId) => {
69
+ if (subject === "list-children") {
70
+ switch (relation) {
71
+ case "direct-child":
72
+ return `列出 ${targetConversationId} 的下属属于跨级查询,跨级不被允许。`;
73
+ case "descendant":
74
+ return intermediateId
75
+ ? `${targetConversationId} 是 ${callerConversationId} 的隔级下属(中间隔着 ${intermediateId}),跨级列出下属不被允许。`
76
+ : `${targetConversationId} 是 ${callerConversationId} 的隔级下属,跨级列出下属不被允许。`;
77
+ case "ancestor":
78
+ return `${callerConversationId} 不能列出自己上级的下属。`;
79
+ case "peer":
80
+ return ancestorId
81
+ ? `${targetConversationId} 是 ${callerConversationId} 的平级会话(两者的共同上级是 ${ancestorId}),列出别人的下属属于越权。`
82
+ : `${targetConversationId} 是 ${callerConversationId} 的平级会话,列出别人的下属属于越权。`;
83
+ case "other-root":
84
+ return `${targetConversationId} 是一个独立的顶层会话,它的下属不属于 ${callerConversationId}。`;
85
+ case "unrelated":
86
+ return `${targetConversationId} 与 ${callerConversationId} 不在同一条会话树上(${targetConversationId} 不是 ${callerConversationId} 的直接下属),跨部门不被允许。`;
87
+ case "self":
88
+ return `会话不是自己的下属。`;
89
+ }
90
+ }
91
+ if (subject === "declare-parent") {
92
+ switch (relation) {
93
+ case "descendant":
94
+ return `${targetConversationId} 是 ${callerConversationId} 的隔级下属,不能被重新声明为 ${callerConversationId} 的直接下属。`;
95
+ case "ancestor":
96
+ return `${callerConversationId} 不能把会话 ${targetConversationId} 声明为自己的下属。`;
97
+ case "peer":
98
+ return `${targetConversationId} 是 ${callerConversationId} 的平级会话,不能被 ${callerConversationId} 收编为自己的下属。`;
99
+ case "other-root":
100
+ return `${targetConversationId} 是一个独立的顶层会话,不能被 ${callerConversationId} 声明为下属。`;
101
+ case "unrelated":
102
+ return `${targetConversationId} 与 ${callerConversationId} 不在同一条会话树上,不能被 ${callerConversationId} 声明为下属。`;
103
+ case "direct-child":
104
+ case "self":
105
+ return `会话不是自己的下属。`;
106
+ }
107
+ }
108
+ switch (relation) {
109
+ case "self":
110
+ return `会话不是自己的下属。`;
111
+ case "direct-child":
112
+ return `${targetConversationId} 是 ${callerConversationId} 的直接子会话。`;
113
+ case "descendant":
114
+ return intermediateId
115
+ ? `${targetConversationId} 是 ${callerConversationId} 的隔级下属(中间隔着 ${intermediateId}),跨级${verb}不被允许。`
116
+ : `${targetConversationId} 是 ${callerConversationId} 的隔级下属,跨级${verb}不被允许。`;
117
+ case "ancestor":
118
+ return `${callerConversationId} 不能${verb}自己的上级。`;
119
+ case "peer":
120
+ return ancestorId
121
+ ? `${targetConversationId} 是 ${callerConversationId} 的平级会话(两者的共同上级是 ${ancestorId}),不在 ${callerConversationId} 的直接下属中。`
122
+ : `${targetConversationId} 是 ${callerConversationId} 的平级会话,不在 ${callerConversationId} 的直接下属中。`;
123
+ case "other-root":
124
+ return `${targetConversationId} 是一个独立的顶层会话,不属于 ${callerConversationId}。`;
125
+ case "unrelated":
126
+ return `${targetConversationId} 与 ${callerConversationId} 不在同一条会话树上(${targetConversationId} 不是 ${callerConversationId} 的直接下属),跨部门${verb}不被允许。`;
127
+ }
128
+ };
129
+ /**
130
+ * Writes the refusal for a pair that is not allowed to be reached.
131
+ *
132
+ * The three shapes, because the three failures are different failures:
133
+ * - managing a session -> 「不能调度/读取/停止/恢复会话 X」
134
+ * - listing a session's kids -> 「不能列出会话 X 的下属」
135
+ * - claiming a parent -> 「不能把会话 X 声明为自己的下属」
136
+ */
137
+ export const describeScopeRefusal = (options) => {
138
+ const { store, callerConversationId, targetConversationId, verb, subject } = options;
139
+ const relation = classifySessionRelation(store, callerConversationId, targetConversationId);
140
+ const intermediateId = intermediateSession(store, callerConversationId, targetConversationId);
141
+ const ancestorId = commonAncestorSession(store, callerConversationId, targetConversationId);
142
+ const reason = relationReason(relation, subject, callerConversationId, targetConversationId, verb, intermediateId, ancestorId);
143
+ if (subject === "list-children") {
144
+ return `调用方会话 ${callerConversationId} 不能列出会话 ${targetConversationId} 的下属:${reason}只能列出自己直接创建的子会话。`;
145
+ }
146
+ if (subject === "declare-parent") {
147
+ return `调用方会话 ${callerConversationId} 不能把会话 ${targetConversationId} 声明为自己的下属:${reason}创建会话的父会话必须是调用方自己。`;
148
+ }
149
+ return `调用方会话 ${callerConversationId} 不能${verb}会话 ${targetConversationId}:${reason}只能${verb}自己直接创建的子会话。`;
150
+ };
151
+ /** The refusal for a caller that cannot be identified at all. */
152
+ const missingCallerRefusal = (callerConversationId) => ({
153
+ ok: false,
154
+ status: 403,
155
+ error: callerConversationId
156
+ ? `调用方会话 ${callerConversationId} 不存在或未关联有效工作区,拒绝编排操作。`
157
+ : "调用方会话为空,拒绝编排操作。",
158
+ });
159
+ /**
160
+ * Checks that the caller may manage the target: the target must be the caller's DIRECT child.
161
+ *
162
+ * The workspace check is NOT part of this rule and is NOT removed by it - a conversation has to be
163
+ * in the caller's workspace AND in the caller's own subtree. The workspace refusal comes first
164
+ * because it is the older, coarser boundary, and its message names the two workspaces.
165
+ */
166
+ export const verifyDirectChildScope = (options) => {
167
+ const { store, callerConversationId, targetConversationId } = options;
168
+ const verb = options.verb ?? "调度";
169
+ const caller = callerConversationId?.trim();
170
+ if (!caller)
171
+ return missingCallerRefusal(callerConversationId);
172
+ const callerConversation = store.conversation(caller);
173
+ if (!callerConversation?.workspaceId)
174
+ return missingCallerRefusal(caller);
175
+ const target = store.conversation(targetConversationId);
176
+ if (!target) {
177
+ return { ok: false, status: 400, error: `找不到会话:${targetConversationId}` };
178
+ }
179
+ if (target.workspaceId !== callerConversation.workspaceId) {
180
+ return {
181
+ ok: false,
182
+ status: 403,
183
+ error: `调用方会话 ${caller} 所在工作区为 ${callerConversation.workspaceId},目标会话 ${targetConversationId} 所在工作区为 ${target.workspaceId},拒绝跨工作区操作。目标会话必须属于调用方工作区。`,
184
+ };
185
+ }
186
+ // THE RULE, IN ONE LINE. The target's tree edge must point at the caller, exactly.
187
+ if (target.parentConversationId !== caller) {
188
+ return {
189
+ ok: false,
190
+ status: 403,
191
+ error: describeScopeRefusal({
192
+ store,
193
+ callerConversationId: caller,
194
+ targetConversationId,
195
+ verb,
196
+ subject: "manage",
197
+ }),
198
+ };
199
+ }
200
+ return { ok: true };
201
+ };
202
+ /**
203
+ * Checks that the caller may list a parent's children.
204
+ *
205
+ * The rule is EQUALITY, not parenthood: the parent whose children are listed must be the caller
206
+ * itself, so the only sessions on the list are the caller's own direct children. Listing the
207
+ * children of the caller's own child would be listing grandchildren, which is the cross-level reach
208
+ * this whole rule exists to refuse.
209
+ */
210
+ export const verifyListParentScope = (options) => {
211
+ const { store, callerConversationId, requestedParentId } = options;
212
+ const caller = callerConversationId?.trim();
213
+ if (!caller)
214
+ return missingCallerRefusal(callerConversationId);
215
+ const callerConversation = store.conversation(caller);
216
+ if (!callerConversation?.workspaceId)
217
+ return missingCallerRefusal(caller);
218
+ const requested = requestedParentId?.trim();
219
+ // No parent named: the caller's own children are what gets listed.
220
+ if (!requested)
221
+ return { ok: true };
222
+ const parentConversation = store.conversation(requested);
223
+ if (parentConversation && parentConversation.workspaceId !== callerConversation.workspaceId) {
224
+ return {
225
+ ok: false,
226
+ status: 403,
227
+ error: `调用方会话 ${caller} 所在工作区为 ${callerConversation.workspaceId},请求的父会话 ${requested} 所在工作区为 ${parentConversation.workspaceId},拒绝跨工作区查询。父会话必须属于调用方工作区。`,
228
+ };
229
+ }
230
+ if (requested === caller)
231
+ return { ok: true };
232
+ return {
233
+ ok: false,
234
+ status: 403,
235
+ error: describeScopeRefusal({
236
+ store,
237
+ callerConversationId: caller,
238
+ targetConversationId: requested,
239
+ verb: "列出",
240
+ subject: "list-children",
241
+ }),
242
+ };
243
+ };
244
+ /**
245
+ * Checks that the caller may REPORT to the target: the target must be the caller's DIRECT PARENT.
246
+ *
247
+ * THE REPORTING LINE IS THE TREE EDGE, READ BACKWARDS. Every other rule in this file asks "may this
248
+ * session manage that one?" - and the answer is always about a session's subordinates. A report is the
249
+ * one message that travels UP, so the rule is inverted: a child reports to the session that owns it,
250
+ * the one whose id is the child's `parentConversationId`, and to nobody else.
251
+ *
252
+ * WHY THE INVERSION IS NOT A LOOPHOLE. A peer is somebody else's child, an ancestor is above the
253
+ * caller's own parent, a grandchild is below the caller, and a session in another workspace is another
254
+ * department. Every one of them would put one branch's news into another branch's inbox, and the inbox
255
+ * is where a parent's NEXT ACTION is decided - so a report that crossed a branch would be a stranger's
256
+ * news steering the wrong supervisor.
257
+ *
258
+ * THE RECIPIENT IS DERIVED, NOT CHOSEN. This check exists for the case where a caller NAMES a
259
+ * recipient at all: the server derives the parent from the tree and this refuses anything else, so a
260
+ * model cannot redirect its own report up or sideways.
261
+ */
262
+ export const verifyReportTargetScope = (options) => {
263
+ const { store, callerConversationId, targetConversationId } = options;
264
+ const caller = callerConversationId?.trim();
265
+ if (!caller)
266
+ return missingCallerRefusal(callerConversationId);
267
+ const callerConversation = store.conversation(caller);
268
+ if (!callerConversation?.workspaceId)
269
+ return missingCallerRefusal(caller);
270
+ const target = store.conversation(targetConversationId);
271
+ if (!target) {
272
+ return { ok: false, status: 400, error: `找不到会话:${targetConversationId}` };
273
+ }
274
+ if (target.workspaceId !== callerConversation.workspaceId) {
275
+ return {
276
+ ok: false,
277
+ status: 403,
278
+ error: `调用方会话 ${caller} 所在工作区为 ${callerConversation.workspaceId},目标会话 ${targetConversationId} 所在工作区为 ${target.workspaceId},拒绝跨工作区汇报。汇报对象必须与调用方在同一工作区。`,
279
+ };
280
+ }
281
+ // THE RULE, INVERTED. The caller's own parent edge must point at the target.
282
+ if (callerConversation.parentConversationId === targetConversationId) {
283
+ return { ok: true };
284
+ }
285
+ const relation = classifySessionRelation(store, caller, targetConversationId);
286
+ const reason = relation === "self"
287
+ ? `会话 ${caller} 不能向自己汇报`
288
+ : relation === "ancestor"
289
+ ? `${targetConversationId} 是 ${caller} 的上级会话,但不是它的直属父会话`
290
+ : relation === "descendant"
291
+ ? `${targetConversationId} 是 ${caller} 的下属会话`
292
+ : relation === "peer"
293
+ ? `${targetConversationId} 与 ${caller} 是平级会话`
294
+ : relation === "other-root"
295
+ ? `${targetConversationId} 是另一个树的顶层会话`
296
+ : `${targetConversationId} 与 ${caller} 不在同一条会话树上`;
297
+ return {
298
+ ok: false,
299
+ status: 403,
300
+ error: `子会话 ${caller} 只能向自己的直属父会话汇报:${reason}。汇报对象由服务端按会话树决定,调用方不能指定。`,
301
+ };
302
+ };
303
+ /**
304
+ * Checks the parent a new session is created under.
305
+ *
306
+ * The parent edge is written onto the new conversation at birth, and the result callback follows
307
+ * that edge home. A caller that names somebody ELSE as the parent would therefore rewrite that
308
+ * session's reporting line - putting the victim's result into the caller's inbox - so the parent
309
+ * must be the caller. An empty parent means a top-level session, which is what the user's own "+"
310
+ * creates and what a session with no owner legitimately is.
311
+ */
312
+ export const verifySpawnParentScope = (options) => {
313
+ const { store, callerConversationId, requestedParentId } = options;
314
+ const caller = callerConversationId?.trim();
315
+ if (!caller)
316
+ return missingCallerRefusal(callerConversationId);
317
+ const callerConversation = store.conversation(caller);
318
+ if (!callerConversation?.workspaceId)
319
+ return missingCallerRefusal(caller);
320
+ const requested = requestedParentId?.trim();
321
+ // No parent named: a top-level session, owned by nobody and reportable to nobody.
322
+ if (!requested)
323
+ return { ok: true };
324
+ if (requested === caller)
325
+ return { ok: true };
326
+ return {
327
+ ok: false,
328
+ status: 403,
329
+ error: describeScopeRefusal({
330
+ store,
331
+ callerConversationId: caller,
332
+ targetConversationId: requested,
333
+ verb: "调度",
334
+ subject: "declare-parent",
335
+ }),
336
+ };
337
+ };
@@ -0,0 +1,23 @@
1
+ import type { SkillSummary } from "./types.js";
2
+ import type { ActiveMemory } from "./active-memory.js";
3
+ /**
4
+ * Loads and returns all available skills for a given workspace and global environment.
5
+ * Priority is given to Pi SDK's DefaultResourceLoader which scans project and user skills.
6
+ * Falls back to direct filesystem scanning if Pi SDK is unavailable.
7
+ */
8
+ export declare function getAvailableSkills(workspacePath?: string, options?: {
9
+ memory?: ActiveMemory;
10
+ workspaceId?: string;
11
+ }): Promise<SkillSummary[]>;
12
+ /**
13
+ * Reads the markdown content of a specific skill by name or ID.
14
+ */
15
+ export declare function readSkill(nameOrId: string, workspacePath?: string, options?: {
16
+ memory?: ActiveMemory;
17
+ workspaceId?: string;
18
+ }): Promise<{
19
+ id: string;
20
+ name: string;
21
+ description: string;
22
+ content: string;
23
+ } | null>;
@@ -0,0 +1,190 @@
1
+ import { existsSync } from "node:fs";
2
+ import { readdir, readFile } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ /**
7
+ * Loads and returns all available skills for a given workspace and global environment.
8
+ * Priority is given to Pi SDK's DefaultResourceLoader which scans project and user skills.
9
+ * Falls back to direct filesystem scanning if Pi SDK is unavailable.
10
+ */
11
+ export async function getAvailableSkills(workspacePath, options) {
12
+ const cwd = workspacePath && existsSync(workspacePath) ? workspacePath : process.cwd();
13
+ const skillsMap = new Map();
14
+ // 1. Try loading via Pi SDK DefaultResourceLoader
15
+ try {
16
+ const sdk = await import("@earendil-works/pi-coding-agent").catch(() => null);
17
+ if (sdk?.DefaultResourceLoader) {
18
+ const agentDir = join(homedir(), ".pi", "agent");
19
+ const loader = new sdk.DefaultResourceLoader({ cwd, agentDir });
20
+ await loader.reload();
21
+ const res = loader.getSkills();
22
+ if (Array.isArray(res?.skills)) {
23
+ for (const s of res.skills) {
24
+ if (!s.name)
25
+ continue;
26
+ const scope = s.sourceInfo?.scope === "project" ? "workspace" : "global";
27
+ skillsMap.set(s.name, {
28
+ id: `skill:${s.name}`,
29
+ name: s.name,
30
+ description: s.description || "",
31
+ scope,
32
+ filePath: s.filePath,
33
+ });
34
+ }
35
+ }
36
+ }
37
+ }
38
+ catch {
39
+ // Ignore and proceed to filesystem fallback
40
+ }
41
+ // 2. Fallback: Direct directory scan if SDK loaded nothing or was unavailable
42
+ if (skillsMap.size === 0) {
43
+ const scanDirs = [
44
+ { dir: join(cwd, ".pi", "skills"), scope: "workspace" },
45
+ { dir: join(cwd, ".agents", "skills"), scope: "workspace" },
46
+ { dir: join(homedir(), ".pi", "agent", "skills"), scope: "global" },
47
+ { dir: join(homedir(), ".agents", "skills"), scope: "global" },
48
+ ];
49
+ for (const { dir, scope } of scanDirs) {
50
+ if (!existsSync(dir))
51
+ continue;
52
+ try {
53
+ const entries = await readdir(dir, { withFileTypes: true });
54
+ for (const entry of entries) {
55
+ let skillFile = "";
56
+ let skillName = entry.name;
57
+ if (entry.isDirectory()) {
58
+ const candidate = join(dir, entry.name, "SKILL.md");
59
+ if (existsSync(candidate)) {
60
+ skillFile = candidate;
61
+ skillName = entry.name;
62
+ }
63
+ }
64
+ else if (entry.isFile() && entry.name.endsWith(".md")) {
65
+ skillFile = join(dir, entry.name);
66
+ skillName = entry.name.replace(/\.md$/, "");
67
+ }
68
+ if (skillFile) {
69
+ try {
70
+ const text = await readFile(skillFile, "utf-8");
71
+ const frontmatterMatch = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
72
+ let description = "";
73
+ let parsedName = skillName;
74
+ if (frontmatterMatch) {
75
+ const nameMatch = /^name:\s*(.+)$/m.exec(frontmatterMatch[1]);
76
+ if (nameMatch)
77
+ parsedName = nameMatch[1].trim();
78
+ const descMatch = /^description:\s*(.+)$/m.exec(frontmatterMatch[1]);
79
+ if (descMatch)
80
+ description = descMatch[1].trim();
81
+ }
82
+ if (!skillsMap.has(parsedName)) {
83
+ skillsMap.set(parsedName, {
84
+ id: `skill:${parsedName}`,
85
+ name: parsedName,
86
+ description,
87
+ scope,
88
+ filePath: skillFile,
89
+ });
90
+ }
91
+ }
92
+ catch {
93
+ // Ignore unreadable file
94
+ }
95
+ }
96
+ }
97
+ }
98
+ catch {
99
+ // Ignore unreadable directory
100
+ }
101
+ }
102
+ }
103
+ // Built-in skills must be visible even when the SDK found user/project skills.
104
+ const bundledRoot = fileURLToPath(new URL("../../skills/", import.meta.url));
105
+ try {
106
+ for (const entry of await readdir(bundledRoot, { withFileTypes: true })) {
107
+ if (!entry.isDirectory())
108
+ continue;
109
+ const skillFile = join(bundledRoot, entry.name, "SKILL.md");
110
+ if (!existsSync(skillFile))
111
+ continue;
112
+ const text = await readFile(skillFile, "utf-8");
113
+ const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? "";
114
+ const name = /^name:\s*(.+)$/m.exec(frontmatter)?.[1]?.trim() ?? entry.name;
115
+ const description = /^description:\s*(.+)$/m.exec(frontmatter)?.[1]?.trim() ?? "";
116
+ if (!skillsMap.has(name))
117
+ skillsMap.set(name, { id: `skill:${name}`, name, description, scope: "global", filePath: skillFile });
118
+ }
119
+ }
120
+ catch { /* The package may be running from a partial development checkout. */ }
121
+ // 3. Optional: merge active memory notes skills if available and not colliding
122
+ if (options?.memory && options?.workspaceId) {
123
+ try {
124
+ const memoryEntries = await options.memory.notes.apply(options.workspaceId, "", { target: "skills", action: "list" });
125
+ if (Array.isArray(memoryEntries)) {
126
+ for (const entry of memoryEntries) {
127
+ const firstLine = entry.content.split(/\r?\n/, 1)[0].replace(/^#+\s*/, "").trim();
128
+ const name = firstLine || "unnamed-skill";
129
+ if (!skillsMap.has(name) && !skillsMap.has(entry.id)) {
130
+ skillsMap.set(`mem:${entry.id}`, {
131
+ id: `skill:${entry.id}`,
132
+ name,
133
+ description: "Active memory skill",
134
+ scope: "memory",
135
+ });
136
+ }
137
+ }
138
+ }
139
+ }
140
+ catch {
141
+ // Memory may not be ready or active
142
+ }
143
+ }
144
+ return Array.from(skillsMap.values()).sort((a, b) => a.name.localeCompare(b.name));
145
+ }
146
+ /**
147
+ * Reads the markdown content of a specific skill by name or ID.
148
+ */
149
+ export async function readSkill(nameOrId, workspacePath, options) {
150
+ const cleanId = nameOrId.startsWith("skill:") ? nameOrId.slice("skill:".length) : nameOrId;
151
+ const skills = await getAvailableSkills(workspacePath, options);
152
+ const found = skills.find((s) => s.name === cleanId || s.name === nameOrId || s.id === nameOrId || s.id === `skill:${cleanId}`);
153
+ if (!found)
154
+ return null;
155
+ // If it's a file on disk
156
+ if (found.filePath && existsSync(found.filePath)) {
157
+ try {
158
+ const content = await readFile(found.filePath, "utf-8");
159
+ return {
160
+ id: found.id,
161
+ name: found.name,
162
+ description: found.description,
163
+ content,
164
+ };
165
+ }
166
+ catch {
167
+ return null;
168
+ }
169
+ }
170
+ // If it's stored in active memory
171
+ if (found.scope === "memory" && options?.memory && options?.workspaceId) {
172
+ try {
173
+ const entryId = found.id.startsWith("skill:") ? found.id.slice("skill:".length) : found.id;
174
+ const memoryEntries = await options.memory.notes.apply(options.workspaceId, "", { target: "skills", action: "list" });
175
+ const entry = memoryEntries.find((e) => e.id === entryId || e.id === found.name);
176
+ if (entry) {
177
+ return {
178
+ id: found.id,
179
+ name: found.name,
180
+ description: found.description,
181
+ content: entry.content,
182
+ };
183
+ }
184
+ }
185
+ catch {
186
+ return null;
187
+ }
188
+ }
189
+ return null;
190
+ }