wiki-viewer 1.4.3 → 1.5.1

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 (218) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +5 -0
  3. package/.next/standalone/.next/build-manifest.json +3 -3
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/routes-manifest.json +34 -0
  6. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  14. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js +8 -7
  24. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route/app-paths-manifest.json +3 -0
  26. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route/build-manifest.json +9 -0
  27. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route/server-reference-manifest.json +4 -0
  28. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js +17 -0
  29. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.map +5 -0
  30. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -0
  31. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route_client-reference-manifest.js +3 -0
  32. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route/app-paths-manifest.json +3 -0
  33. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route/build-manifest.json +9 -0
  34. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route/server-reference-manifest.json +4 -0
  35. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js +15 -0
  36. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.map +5 -0
  37. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -0
  38. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route_client-reference-manifest.js +3 -0
  39. package/.next/standalone/.next/server/app/api/agent/fs/move/route/app-paths-manifest.json +3 -0
  40. package/.next/standalone/.next/server/app/api/agent/fs/move/route/build-manifest.json +9 -0
  41. package/.next/standalone/.next/server/app/api/agent/fs/move/route/server-reference-manifest.json +4 -0
  42. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js +15 -0
  43. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.map +5 -0
  44. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -0
  45. package/.next/standalone/.next/server/app/api/agent/fs/move/route_client-reference-manifest.js +3 -0
  46. package/.next/standalone/.next/server/app/api/agent/fs/search/route/app-paths-manifest.json +3 -0
  47. package/.next/standalone/.next/server/app/api/agent/fs/search/route/build-manifest.json +9 -0
  48. package/.next/standalone/.next/server/app/api/agent/fs/search/route/server-reference-manifest.json +4 -0
  49. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js +15 -0
  50. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.map +5 -0
  51. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -0
  52. package/.next/standalone/.next/server/app/api/agent/fs/search/route_client-reference-manifest.js +3 -0
  53. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/agent/settings/route.js +1 -1
  55. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js +1 -1
  58. package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/api/system/clear-root/route.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/api/system/root-status/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  66. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  67. package/.next/standalone/.next/server/app/api/wiki/content/route.js +2 -2
  68. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  69. package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
  70. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  71. package/.next/standalone/.next/server/app/api/wiki/move/route.js +3 -3
  72. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  73. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  74. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  75. package/.next/standalone/.next/server/app/api/wiki/presence/route/app-paths-manifest.json +3 -0
  76. package/.next/standalone/.next/server/app/api/wiki/presence/route/build-manifest.json +9 -0
  77. package/.next/standalone/.next/server/app/api/wiki/presence/route/server-reference-manifest.json +4 -0
  78. package/.next/standalone/.next/server/app/api/wiki/presence/route.js +14 -0
  79. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.map +5 -0
  80. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -0
  81. package/.next/standalone/.next/server/app/api/wiki/presence/route_client-reference-manifest.js +3 -0
  82. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  83. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  84. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  85. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  86. package/.next/standalone/.next/server/app/index.html +1 -1
  87. package/.next/standalone/.next/server/app/index.rsc +2 -2
  88. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  89. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  90. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  91. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  92. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  93. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  94. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  95. package/.next/standalone/.next/server/app-paths-manifest.json +5 -0
  96. package/.next/standalone/.next/server/chunks/0p91_next_dist_esm_build_templates_app-route_0d2jbo5.js +3 -0
  97. package/.next/standalone/.next/server/chunks/0p91_next_dist_esm_build_templates_app-route_0ytral2.js +3 -0
  98. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-ao6a_._.js +1 -1
  99. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0269d2e._.js +1 -1
  100. package/.next/standalone/.next/server/chunks/[root-of-the-server]__05f6x0i._.js +3 -0
  101. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06-dtd0._.js +3 -0
  102. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06sek6_._.js +1 -1
  103. package/.next/standalone/.next/server/chunks/[root-of-the-server]__09s9qkd._.js +1 -1
  104. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0d75a5q._.js +1 -1
  105. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0d_da6q._.js +3 -0
  106. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0e7si9p._.js +1 -1
  107. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0hhhvm7._.js +1 -1
  108. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0kk26wc._.js +3 -0
  109. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0kur4ro._.js +15 -0
  110. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0p12-6~._.js +1 -1
  111. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0qc2~6l._.js +15 -0
  112. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0s~i040._.js +3 -0
  113. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0w47wil._.js +1 -1
  114. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0xq124z._.js +3 -0
  115. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0l..bxz._.js → [root-of-the-server]__0xz-_0v._.js} +2 -2
  116. package/.next/standalone/.next/server/chunks/[root-of-the-server]__10w2q~o._.js +1 -1
  117. package/.next/standalone/.next/server/chunks/_079xuln._.js +3 -0
  118. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_agent_fs_file_[___path]_route_actions_0gb11t~.js +3 -0
  119. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_agent_fs_ls_[[___path]]_route_actions_0wfg4nl.js +3 -0
  120. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_agent_fs_move_route_actions_0z34mqq.js +3 -0
  121. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_agent_fs_search_route_actions_0ut_ug..js +3 -0
  122. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_wiki_presence_route_actions_0x9d7f4.js +3 -0
  123. package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_055boxx._.js → 0~w0_katex_dist_katex_mjs_00650~e._.js} +1 -1
  124. package/.next/standalone/.next/server/chunks/ssr/12y~_mermaid_dist_chunks_mermaid_core_diagram-OG6HWLK6_mjs_0t5sus6._.js +1 -1
  125. package/.next/standalone/.next/server/chunks/ssr/12y~_mermaid_dist_chunks_mermaid_core_sankeyDiagram-5OEKKPKP_mjs_11ifrnu._.js +1 -1
  126. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__134_q7l._.js → [root-of-the-server]__12ahxbl._.js} +2 -2
  127. package/.next/standalone/.next/server/chunks/ssr/_0pqaawz._.js +3 -3
  128. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0rc1vh5._.js → node_modules__pnpm_02gx8km._.js} +1 -1
  129. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0t4unpg._.js → node_modules__pnpm_02mew~s._.js} +2 -2
  130. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_12-ni1n._.js → node_modules__pnpm_03ij5.g._.js} +2 -2
  131. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_12~a4c_._.js → node_modules__pnpm_03v21p-._.js} +2 -2
  132. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0f~_mm3._.js → node_modules__pnpm_05qsply._.js} +2 -2
  133. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0alwr5e._.js → node_modules__pnpm_06pgebo._.js} +2 -2
  134. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_02zxe7o._.js → node_modules__pnpm_08ibh0w._.js} +2 -2
  135. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0hr027i._.js → node_modules__pnpm_099cv.b._.js} +1 -1
  136. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0znncy9._.js → node_modules__pnpm_0cwpt9p._.js} +2 -2
  137. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-pisfi._.js → node_modules__pnpm_0f9fpy5._.js} +1 -1
  138. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0zhbnni._.js → node_modules__pnpm_0f_uzgy._.js} +1 -1
  139. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-w-d-.._.js → node_modules__pnpm_0fixtms._.js} +1 -1
  140. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_03z0vkh._.js → node_modules__pnpm_0gofu~q._.js} +1 -1
  141. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_10i6lh6._.js → node_modules__pnpm_0iojvye._.js} +2 -2
  142. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-hfev1._.js → node_modules__pnpm_0li2vzs._.js} +1 -1
  143. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_13kfy_z._.js → node_modules__pnpm_0m5-azh._.js} +1 -1
  144. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_071f6vl._.js → node_modules__pnpm_0n1kfcp._.js} +1 -1
  145. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_07uh2kc._.js → node_modules__pnpm_0rebktf._.js} +1 -1
  146. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0okw1r.._.js → node_modules__pnpm_0tkiej3._.js} +2 -2
  147. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0xuz.8f._.js → node_modules__pnpm_0v_nwsz._.js} +1 -1
  148. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0zb6573._.js → node_modules__pnpm_0wffzo0._.js} +1 -1
  149. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0d7jxsf._.js → node_modules__pnpm_0wouz19._.js} +1 -1
  150. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0egenev._.js → node_modules__pnpm_0xxwmv2._.js} +1 -1
  151. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0j9bq9s._.js → node_modules__pnpm_0zzzsrj._.js} +1 -1
  152. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0irsd.b._.js → node_modules__pnpm_0~.6dgb._.js} +1 -1
  153. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0erwv_m._.js → node_modules__pnpm_0~2~c30._.js} +1 -1
  154. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0y9k6h~._.js → node_modules__pnpm_10413dq._.js} +2 -2
  155. package/.next/standalone/.next/server/functions-config-manifest.json +5 -0
  156. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  157. package/.next/standalone/.next/server/middleware-manifest.json +5 -5
  158. package/.next/standalone/.next/server/pages/404.html +1 -1
  159. package/.next/standalone/.next/server/pages/500.html +1 -1
  160. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  161. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  162. package/.next/standalone/.next/static/chunks/{11s9zwr7edrs7.js → 17~r3.8awh3qg.js} +12 -12
  163. package/.next/standalone/README.md +79 -16
  164. package/.next/standalone/agents/bootstrap-prompt.md +12 -1
  165. package/.next/standalone/agents/wiki-viewer-skill/SKILL.md +199 -6
  166. package/.next/standalone/docs/file-vs-collab-authority.md +124 -0
  167. package/.next/standalone/package.json +1 -1
  168. package/.next/standalone/packages/wiki-viewer-mcp/README.md +194 -0
  169. package/.next/standalone/packages/wiki-viewer-mcp/dist/http-client.js +220 -0
  170. package/.next/standalone/packages/wiki-viewer-mcp/dist/index.js +472 -0
  171. package/.next/standalone/packages/wiki-viewer-mcp/dist/register.js +94 -0
  172. package/.next/standalone/packages/wiki-viewer-mcp/dist/state-cache.js +26 -0
  173. package/.next/standalone/packages/wiki-viewer-mcp/package-lock.json +1716 -0
  174. package/.next/standalone/packages/wiki-viewer-mcp/package.json +41 -0
  175. package/.next/standalone/packages/wiki-viewer-mcp/src/http-client.ts +344 -0
  176. package/.next/standalone/packages/wiki-viewer-mcp/src/index.ts +575 -0
  177. package/.next/standalone/packages/wiki-viewer-mcp/src/register.ts +144 -0
  178. package/.next/standalone/packages/wiki-viewer-mcp/src/state-cache.ts +45 -0
  179. package/.next/standalone/packages/wiki-viewer-mcp/tsconfig.json +19 -0
  180. package/.next/standalone/pnpm-lock.yaml +9 -9
  181. package/.next/standalone/src/app/api/agent/files/[...path]/route.ts +11 -1
  182. package/.next/standalone/src/app/api/agent/fs/file/[...path]/route.ts +344 -0
  183. package/.next/standalone/src/app/api/agent/fs/ls/[[...path]]/route.ts +147 -0
  184. package/.next/standalone/src/app/api/agent/fs/move/route.ts +125 -0
  185. package/.next/standalone/src/app/api/agent/fs/search/route.ts +236 -0
  186. package/.next/standalone/src/app/api/agent/register/route.ts +3 -3
  187. package/.next/standalone/src/app/api/agents/install/route.ts +44 -2
  188. package/.next/standalone/src/app/api/system/auth-settings/route.ts +1 -0
  189. package/.next/standalone/src/app/api/wiki/move/route.ts +10 -1
  190. package/.next/standalone/src/app/api/wiki/presence/route.ts +55 -0
  191. package/.next/standalone/src/components/ai-panel/ai-panel.tsx +98 -103
  192. package/.next/standalone/src/components/ai-panel/token-section.tsx +8 -7
  193. package/.next/standalone/src/components/auth-settings-sheet.tsx +81 -22
  194. package/.next/standalone/src/components/editor/editor.tsx +38 -0
  195. package/.next/standalone/src/lib/proof/audit.ts +79 -0
  196. package/.next/standalone/src/lib/proof/auth.ts +2 -2
  197. package/.next/standalone/src/lib/proof/collab-state.ts +79 -0
  198. package/.next/standalone/src/lib/proof/lease.ts +104 -0
  199. package/.next/standalone/src/lib/proof/ops-applier.ts +74 -25
  200. package/.next/standalone/src/lib/proof/raw-fs.ts +198 -0
  201. package/.next/standalone/src/lib/proof/registry.ts +1 -1
  202. package/.next/standalone/src/lib/proof/sidecar.ts +38 -1
  203. package/.next/standalone/src/lib/proof/types.ts +13 -1
  204. package/.next/standalone/src/tests/proof/agent-fs.test.ts +824 -0
  205. package/.next/standalone/src/tests/proof/agents-install.test.ts +53 -0
  206. package/.next/standalone/src/tests/proof/collab-state.test.ts +499 -0
  207. package/.next/standalone/src/tests/proof/reconcile-sidecar.test.ts +195 -0
  208. package/.next/standalone/src/tests/proof/sidecar-lifecycle.test.ts +177 -0
  209. package/.next/standalone/tsconfig.tsbuildinfo +1 -1
  210. package/README.md +79 -16
  211. package/package.json +1 -1
  212. package/.next/standalone/.next/server/chunks/[root-of-the-server]__09~~-nd._.js +0 -3
  213. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0w87kiz._.js +0 -3
  214. package/.next/standalone/.next/server/chunks/[root-of-the-server]__12ssbhv._.js +0 -3
  215. package/.next/standalone/.next/server/chunks/node_modules__pnpm_0g0fhfk._.js +0 -3
  216. /package/.next/standalone/.next/static/{kzOuSAQArtvD7uiAJ6ZLh → 3G_3qm2a9nOX7oi5k0mPV}/_buildManifest.js +0 -0
  217. /package/.next/standalone/.next/static/{kzOuSAQArtvD7uiAJ6ZLh → 3G_3qm2a9nOX7oi5k0mPV}/_clientMiddlewareManifest.js +0 -0
  218. /package/.next/standalone/.next/static/{kzOuSAQArtvD7uiAJ6ZLh → 3G_3qm2a9nOX7oi5k0mPV}/_ssgManifest.js +0 -0
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "wiki-viewer-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP filesystem adapter for wiki-viewer agent API",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "wiki-viewer-mcp": "dist/index.js"
9
+ },
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "postbuild": "node -e \"const fs=require('fs'),f='dist/index.js',c=fs.readFileSync(f,'utf8');if(!c.startsWith('#!'))fs.writeFileSync(f,'#!/usr/bin/env node\\n'+c);fs.chmodSync(f,'755');\"",
19
+ "dev": "tsc --watch",
20
+ "start": "node dist/index.js",
21
+ "test": "tsx --test src/__tests__/*.test.ts",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "engines": {
25
+ "node": ">=18.0.0"
26
+ },
27
+ "dependencies": {
28
+ "@modelcontextprotocol/sdk": "^1.13.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.0.0",
32
+ "tsx": "^4.22.3",
33
+ "typescript": "^5.8.0"
34
+ },
35
+ "keywords": [
36
+ "mcp",
37
+ "wiki-viewer",
38
+ "filesystem",
39
+ "agent"
40
+ ]
41
+ }
@@ -0,0 +1,344 @@
1
+ /**
2
+ * Typed HTTP client over the wiki-viewer agent filesystem API.
3
+ * Contract: docs/agent-fs-plan.md §2.
4
+ *
5
+ * All methods throw WikiViewerError on non-2xx unless noted.
6
+ * The caller (index.ts) catches 409/412 and surfaces them cleanly to the agent.
7
+ */
8
+
9
+ import * as cache from "./state-cache.js";
10
+ import type { CollabState, PathState } from "./state-cache.js";
11
+
12
+ // ─── Config ──────────────────────────────────────────────────────────────────
13
+
14
+ export interface ClientConfig {
15
+ baseUrl: string; // e.g. "https://notes.example.com"
16
+ token: string; // Bearer token from TOFU registration
17
+ agentId: string; // X-Agent-Id header
18
+ /** Override fetch implementation (for testing) */
19
+ fetch?: typeof fetch;
20
+ }
21
+
22
+ // ─── Errors ──────────────────────────────────────────────────────────────────
23
+
24
+ export class WikiViewerError extends Error {
25
+ constructor(
26
+ public readonly status: number,
27
+ public readonly code: string,
28
+ message: string,
29
+ public readonly body?: unknown,
30
+ ) {
31
+ super(message);
32
+ this.name = "WikiViewerError";
33
+ }
34
+ }
35
+
36
+ export class IfMatchError extends WikiViewerError {
37
+ constructor(path: string, body?: unknown) {
38
+ super(412, "IF_MATCH_MISMATCH", `If-Match mismatch for ${path} — re-read before writing`, body);
39
+ this.name = "IfMatchError";
40
+ }
41
+ }
42
+
43
+ export class CollabActiveError extends WikiViewerError {
44
+ constructor(
45
+ path: string,
46
+ public readonly snapshotUrl: string | null,
47
+ body?: unknown,
48
+ ) {
49
+ super(409, "COLLAB_ACTIVE", `${path} is being actively collaborated on — use Tier-2 block-ops`, body);
50
+ this.name = "CollabActiveError";
51
+ }
52
+ }
53
+
54
+ // ─── Response shapes ─────────────────────────────────────────────────────────
55
+
56
+ export interface ReadResult {
57
+ /** Raw response bytes */
58
+ body: Uint8Array;
59
+ /** UTF-8 text, if the content-type is text */
60
+ text: string | null;
61
+ sha256: string;
62
+ size: number;
63
+ mtime: string;
64
+ contentType: string;
65
+ collabState: CollabState;
66
+ collabRevision: number | null;
67
+ collabSnapshot: string | null;
68
+ }
69
+
70
+ export interface WriteResult {
71
+ path: string;
72
+ sha256: string;
73
+ size: number;
74
+ mtime: string;
75
+ created: boolean;
76
+ }
77
+
78
+ export interface DirEntry {
79
+ name: string;
80
+ path: string;
81
+ type: "file" | "directory";
82
+ size: number | null;
83
+ mtime: string | null;
84
+ }
85
+
86
+ export interface SearchMatch {
87
+ path: string;
88
+ line?: number;
89
+ text?: string;
90
+ }
91
+
92
+ export interface SearchResult {
93
+ kind: "grep" | "glob";
94
+ matches: SearchMatch[];
95
+ }
96
+
97
+ // ─── Client ──────────────────────────────────────────────────────────────────
98
+
99
+ export class WikiViewerClient {
100
+ private readonly baseUrl: string;
101
+ private readonly token: string;
102
+ private readonly agentId: string;
103
+ private readonly _fetch: typeof fetch;
104
+
105
+ constructor(config: ClientConfig) {
106
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
107
+ this.token = config.token;
108
+ this.agentId = config.agentId;
109
+ this._fetch = config.fetch ?? globalThis.fetch;
110
+ }
111
+
112
+ // ── Helpers ────────────────────────────────────────────────────────────────
113
+
114
+ private headers(extra: Record<string, string> = {}): Record<string, string> {
115
+ return {
116
+ Authorization: `Bearer ${this.token}`,
117
+ "X-Agent-Id": this.agentId,
118
+ ...extra,
119
+ };
120
+ }
121
+
122
+ private url(path: string, params?: Record<string, string>): string {
123
+ const u = new URL(`${this.baseUrl}${path}`);
124
+ if (params) {
125
+ for (const [k, v] of Object.entries(params)) {
126
+ u.searchParams.set(k, v);
127
+ }
128
+ }
129
+ return u.toString();
130
+ }
131
+
132
+ private async assertOk(res: Response, path: string): Promise<void> {
133
+ if (res.ok) return;
134
+ let body: unknown;
135
+ try { body = await res.json(); } catch { body = await res.text().catch(() => undefined); }
136
+ if (res.status === 412) throw new IfMatchError(path, body);
137
+ if (res.status === 409) {
138
+ const snapshotUrl = (body as Record<string, unknown>)?.snapshotUrl as string | null ?? null;
139
+ throw new CollabActiveError(path, snapshotUrl, body);
140
+ }
141
+ throw new WikiViewerError(
142
+ res.status,
143
+ `HTTP_${res.status}`,
144
+ `wiki-viewer ${res.status} for ${path}: ${res.statusText}`,
145
+ body,
146
+ );
147
+ }
148
+
149
+ private parseCollabHeaders(res: Response): Pick<ReadResult, "collabState" | "collabRevision" | "collabSnapshot"> {
150
+ const raw = (res.headers.get("X-Collab-State") ?? "not-markdown") as CollabState;
151
+ const validStates: CollabState[] = ["active", "tracked", "untracked", "not-markdown"];
152
+ const collabState: CollabState = validStates.includes(raw) ? raw : "not-markdown";
153
+ const revRaw = res.headers.get("X-Collab-Revision");
154
+ const collabRevision = revRaw !== null ? parseInt(revRaw, 10) : null;
155
+ const collabSnapshot = res.headers.get("X-Collab-Snapshot") ?? null;
156
+ return { collabState, collabRevision, collabSnapshot };
157
+ }
158
+
159
+ // ── read_file ──────────────────────────────────────────────────────────────
160
+
161
+ async readFile(path: string, range?: string): Promise<ReadResult> {
162
+ const extraHeaders: Record<string, string> = {};
163
+ if (range) extraHeaders["Range"] = range;
164
+
165
+ const res = await this._fetch(
166
+ this.url(`/api/agent/fs/file/${encodeFilePath(path)}`),
167
+ { headers: this.headers(extraHeaders) },
168
+ );
169
+ await this.assertOk(res, path);
170
+
171
+ const sha256 = stripQuotes(res.headers.get("ETag") ?? "");
172
+ const size = parseInt(res.headers.get("X-File-Size") ?? "0", 10);
173
+ const mtime = res.headers.get("X-File-Mtime") ?? "";
174
+ const contentType = res.headers.get("Content-Type") ?? "application/octet-stream";
175
+ const collab = this.parseCollabHeaders(res);
176
+
177
+ const bodyBuf = new Uint8Array(await res.arrayBuffer());
178
+ const isText = contentType.startsWith("text/") ||
179
+ contentType.includes("json") ||
180
+ contentType.includes("xml") ||
181
+ contentType.includes("javascript") ||
182
+ contentType.includes("typescript");
183
+
184
+ const text = isText ? new TextDecoder().decode(bodyBuf) : null;
185
+
186
+ const state: PathState = {
187
+ sha256,
188
+ collabState: collab.collabState,
189
+ collabRevision: collab.collabRevision,
190
+ collabSnapshot: collab.collabSnapshot,
191
+ fetchedAt: Date.now(),
192
+ };
193
+ cache.set(path, state);
194
+
195
+ return { body: bodyBuf, text, sha256, size, mtime, contentType, ...collab };
196
+ }
197
+
198
+ // ── write_file ─────────────────────────────────────────────────────────────
199
+
200
+ async writeFile(
201
+ path: string,
202
+ content: string | Uint8Array,
203
+ opts: {
204
+ ifMatch?: string;
205
+ mkdirs?: boolean;
206
+ force?: boolean;
207
+ /** If-Collab-Match: X-Collab-Revision value (when knowingly writing to a tracked .md) */
208
+ ifCollabMatch?: number;
209
+ } = {},
210
+ ): Promise<WriteResult> {
211
+ const extraHeaders: Record<string, string> = {};
212
+ // Auto-fill If-Match from the last-read sha (cache) on overwrite, unless the
213
+ // caller explicitly supplied one or is forcing. A create (no cached sha) omits it.
214
+ const ifMatch = opts.ifMatch ?? (opts.force ? undefined : cache.get(path)?.sha256);
215
+ if (ifMatch) extraHeaders["If-Match"] = ifMatch;
216
+ if (opts.ifCollabMatch !== undefined) {
217
+ extraHeaders["If-Collab-Match"] = String(opts.ifCollabMatch);
218
+ }
219
+
220
+ const params: Record<string, string> = {};
221
+ if (opts.mkdirs) params["mkdirs"] = "true";
222
+ if (opts.force) params["force"] = "true";
223
+
224
+ const body: BodyInit = typeof content === "string"
225
+ ? (new TextEncoder().encode(content) as unknown as Uint8Array<ArrayBuffer>)
226
+ : (content as unknown as Uint8Array<ArrayBuffer>);
227
+
228
+ const res = await this._fetch(
229
+ this.url(`/api/agent/fs/file/${encodeFilePath(path)}`, params),
230
+ {
231
+ method: "PUT",
232
+ headers: this.headers({ "Content-Type": "application/octet-stream", ...extraHeaders }),
233
+ body,
234
+ },
235
+ );
236
+ await this.assertOk(res, path);
237
+
238
+ const result: WriteResult = await res.json() as WriteResult;
239
+ // Update cache after successful write
240
+ cache.set(path, {
241
+ sha256: result.sha256,
242
+ collabState: "not-markdown",
243
+ collabRevision: null,
244
+ collabSnapshot: null,
245
+ fetchedAt: Date.now(),
246
+ });
247
+ return result;
248
+ }
249
+
250
+ // ── delete_file ────────────────────────────────────────────────────────────
251
+
252
+ async deleteFile(
253
+ path: string,
254
+ ifMatch: string,
255
+ opts: { recursive?: boolean; force?: boolean } = {},
256
+ ): Promise<void> {
257
+ const params: Record<string, string> = {};
258
+ if (opts.recursive) params["recursive"] = "true";
259
+ if (opts.force) params["force"] = "true";
260
+
261
+ const res = await this._fetch(
262
+ this.url(`/api/agent/fs/file/${encodeFilePath(path)}`, params),
263
+ {
264
+ method: "DELETE",
265
+ headers: this.headers({ "If-Match": ifMatch }),
266
+ },
267
+ );
268
+ await this.assertOk(res, path);
269
+ cache.del(path);
270
+ }
271
+
272
+ // ── list_directory ─────────────────────────────────────────────────────────
273
+
274
+ async listDirectory(
275
+ path: string,
276
+ opts: { recursive?: boolean; depth?: number; limit?: number } = {},
277
+ ): Promise<DirEntry[]> {
278
+ const params: Record<string, string> = {};
279
+ if (opts.recursive) params["recursive"] = "true";
280
+ if (opts.depth !== undefined) params["depth"] = String(opts.depth);
281
+ if (opts.limit !== undefined) params["limit"] = String(opts.limit);
282
+
283
+ const res = await this._fetch(
284
+ this.url(`/api/agent/fs/ls/${encodeFilePath(path)}`, params),
285
+ { headers: this.headers() },
286
+ );
287
+ await this.assertOk(res, path);
288
+ return res.json() as Promise<DirEntry[]>;
289
+ }
290
+
291
+ // ── search ────────────────────────────────────────────────────────────────
292
+
293
+ async search(body: {
294
+ kind: "grep" | "glob";
295
+ query: string;
296
+ path?: string;
297
+ glob?: string;
298
+ limit?: number;
299
+ }): Promise<SearchResult> {
300
+ const res = await this._fetch(
301
+ this.url("/api/agent/fs/search"),
302
+ {
303
+ method: "POST",
304
+ headers: this.headers({ "Content-Type": "application/json" }),
305
+ body: JSON.stringify(body),
306
+ },
307
+ );
308
+ await this.assertOk(res, "search");
309
+ return res.json() as Promise<SearchResult>;
310
+ }
311
+
312
+ // ── move_file ─────────────────────────────────────────────────────────────
313
+
314
+ async moveFile(from: string, to: string, ifMatch?: string): Promise<void> {
315
+ const body: Record<string, string> = { from, to };
316
+ if (ifMatch) body["ifMatch"] = ifMatch;
317
+
318
+ const res = await this._fetch(
319
+ this.url("/api/agent/fs/move"),
320
+ {
321
+ method: "POST",
322
+ headers: this.headers({ "Content-Type": "application/json" }),
323
+ body: JSON.stringify(body),
324
+ },
325
+ );
326
+ await this.assertOk(res, from);
327
+ cache.rename(from, to);
328
+ }
329
+ }
330
+
331
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
332
+
333
+ /** Encode path segments but preserve slashes */
334
+ function encodeFilePath(path: string): string {
335
+ return path
336
+ .replace(/^\/+/, "")
337
+ .split("/")
338
+ .map((seg) => encodeURIComponent(seg))
339
+ .join("/");
340
+ }
341
+
342
+ function stripQuotes(etag: string): string {
343
+ return etag.replace(/^"/, "").replace(/"$/, "");
344
+ }