wiki-viewer 1.14.1 → 1.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  4. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  11. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  19. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  20. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/index.html +1 -1
  61. package/.next/standalone/.next/server/app/index.rsc +1 -1
  62. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  63. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  64. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  65. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  66. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  67. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  68. package/.next/standalone/.next/server/middleware-manifest.json +1 -1
  69. package/.next/standalone/.next/server/pages/404.html +1 -1
  70. package/.next/standalone/.next/server/pages/500.html +1 -1
  71. package/.next/standalone/package.json +1 -1
  72. package/bin/postbuild.js +21 -0
  73. package/package.json +1 -1
  74. package/.next/standalone/.github/workflows/publish.yml +0 -37
  75. package/.next/standalone/.handoffs/archive/handoff-20260612-113332.md +0 -98
  76. package/.next/standalone/.handoffs/archive/handoff-20260612-141032.md +0 -73
  77. package/.next/standalone/.pi/ownership.json +0 -3
  78. package/.next/standalone/AGENTS.md +0 -114
  79. package/.next/standalone/DESIGN.md +0 -521
  80. package/.next/standalone/README.md +0 -821
  81. package/.next/standalone/TODO.md +0 -20
  82. package/.next/standalone/agents/bootstrap-prompt.md +0 -14
  83. package/.next/standalone/agents/wiki-viewer-skill/SKILL.md +0 -456
  84. package/.next/standalone/bin/postbuild.js +0 -78
  85. package/.next/standalone/bin/wiki-viewer.js +0 -922
  86. package/.next/standalone/certificates/localhost-key.pem +0 -28
  87. package/.next/standalone/certificates/localhost.pem +0 -24
  88. package/.next/standalone/docs/agent-collab-plan.md +0 -1615
  89. package/.next/standalone/docs/agent-collab-v2-plan.md +0 -771
  90. package/.next/standalone/docs/agent-fs-plan.md +0 -232
  91. package/.next/standalone/docs/editorial-skin-spec.md +0 -242
  92. package/.next/standalone/docs/file-vs-collab-authority.md +0 -124
  93. package/.next/standalone/docs/mobile-readiness-spec.md +0 -229
  94. package/.next/standalone/docs/workspacing-plan.md +0 -364
  95. package/.next/standalone/packages/wiki-viewer-mcp/README.md +0 -195
  96. package/.next/standalone/packages/wiki-viewer-mcp/bench-e2e.mjs +0 -166
  97. package/.next/standalone/packages/wiki-viewer-mcp/bench-latency.mjs +0 -87
  98. package/.next/standalone/packages/wiki-viewer-mcp/bench-payload.mjs +0 -45
  99. package/.next/standalone/packages/wiki-viewer-mcp/dist/http-client.js +0 -331
  100. package/.next/standalone/packages/wiki-viewer-mcp/dist/index.js +0 -531
  101. package/.next/standalone/packages/wiki-viewer-mcp/dist/register.js +0 -94
  102. package/.next/standalone/packages/wiki-viewer-mcp/dist/state-cache.js +0 -28
  103. package/.next/standalone/packages/wiki-viewer-mcp/package-lock.json +0 -1716
  104. package/.next/standalone/packages/wiki-viewer-mcp/package.json +0 -41
  105. package/.next/standalone/packages/wiki-viewer-mcp/src/http-client.ts +0 -459
  106. package/.next/standalone/packages/wiki-viewer-mcp/src/index.ts +0 -638
  107. package/.next/standalone/packages/wiki-viewer-mcp/src/register.ts +0 -144
  108. package/.next/standalone/packages/wiki-viewer-mcp/src/state-cache.ts +0 -55
  109. package/.next/standalone/packages/wiki-viewer-mcp/tsconfig.json +0 -19
  110. package/.next/standalone/pnpm-lock.yaml +0 -6697
  111. package/.next/standalone/pnpm-workspace.yaml +0 -8
  112. package/.next/standalone/postcss.config.mjs +0 -2
  113. package/.next/standalone/src/app/api/agent/activity/route.ts +0 -59
  114. package/.next/standalone/src/app/api/agent/admin/agents/[agentId]/revoke/route.ts +0 -40
  115. package/.next/standalone/src/app/api/agent/admin/agents/route.ts +0 -33
  116. package/.next/standalone/src/app/api/agent/admin/registrations/[regId]/approve/route.ts +0 -83
  117. package/.next/standalone/src/app/api/agent/admin/registrations/[regId]/deny/route.ts +0 -36
  118. package/.next/standalone/src/app/api/agent/admin/registrations/route.ts +0 -27
  119. package/.next/standalone/src/app/api/agent/events/[...path]/route.ts +0 -148
  120. package/.next/standalone/src/app/api/agent/files/[...path]/route.ts +0 -219
  121. package/.next/standalone/src/app/api/agent/fs/file/[...path]/route.ts +0 -446
  122. package/.next/standalone/src/app/api/agent/fs/ls/[[...path]]/route.ts +0 -152
  123. package/.next/standalone/src/app/api/agent/fs/move/route.ts +0 -130
  124. package/.next/standalone/src/app/api/agent/fs/search/route.ts +0 -272
  125. package/.next/standalone/src/app/api/agent/internal/span/route.ts +0 -121
  126. package/.next/standalone/src/app/api/agent/register/[regId]/route.ts +0 -50
  127. package/.next/standalone/src/app/api/agent/register/route.ts +0 -118
  128. package/.next/standalone/src/app/api/agent/settings/route.ts +0 -34
  129. package/.next/standalone/src/app/api/agent/settings/token/regenerate/route.ts +0 -20
  130. package/.next/standalone/src/app/api/agent/sidecar/[...path]/route.ts +0 -53
  131. package/.next/standalone/src/app/api/agents/install/route.ts +0 -143
  132. package/.next/standalone/src/app/api/agents/skill/route.ts +0 -20
  133. package/.next/standalone/src/app/api/agents/skill.tar.gz/route.ts +0 -87
  134. package/.next/standalone/src/app/api/app-proxy/[...path]/route.ts +0 -247
  135. package/.next/standalone/src/app/api/assets/[...path]/route.ts +0 -75
  136. package/.next/standalone/src/app/api/auth/[...all]/route.ts +0 -7
  137. package/.next/standalone/src/app/api/owner/init/route.ts +0 -14
  138. package/.next/standalone/src/app/api/share/[token]/route.ts +0 -269
  139. package/.next/standalone/src/app/api/share/route.ts +0 -127
  140. package/.next/standalone/src/app/api/system/admins/route.ts +0 -103
  141. package/.next/standalone/src/app/api/system/auth-config/route.ts +0 -22
  142. package/.next/standalone/src/app/api/system/auth-settings/route.ts +0 -86
  143. package/.next/standalone/src/app/api/system/browse/route.ts +0 -82
  144. package/.next/standalone/src/app/api/system/clear-root/route.ts +0 -16
  145. package/.next/standalone/src/app/api/system/config/route.ts +0 -14
  146. package/.next/standalone/src/app/api/system/pins/route.ts +0 -38
  147. package/.next/standalone/src/app/api/system/reveal/route.ts +0 -36
  148. package/.next/standalone/src/app/api/system/root-status/route.ts +0 -13
  149. package/.next/standalone/src/app/api/system/set-root/route.ts +0 -53
  150. package/.next/standalone/src/app/api/system/users/route.ts +0 -120
  151. package/.next/standalone/src/app/api/system/workspaces/[id]/open/route.ts +0 -34
  152. package/.next/standalone/src/app/api/system/workspaces/[id]/refresh/route.ts +0 -32
  153. package/.next/standalone/src/app/api/system/workspaces/[id]/route.ts +0 -78
  154. package/.next/standalone/src/app/api/system/workspaces/route.ts +0 -128
  155. package/.next/standalone/src/app/api/upload/[...path]/route.ts +0 -85
  156. package/.next/standalone/src/app/api/wiki/app/route.ts +0 -60
  157. package/.next/standalone/src/app/api/wiki/backlinks/route.ts +0 -29
  158. package/.next/standalone/src/app/api/wiki/content/route.ts +0 -159
  159. package/.next/standalone/src/app/api/wiki/download/route.ts +0 -100
  160. package/.next/standalone/src/app/api/wiki/file/route.ts +0 -57
  161. package/.next/standalone/src/app/api/wiki/folder/route.ts +0 -34
  162. package/.next/standalone/src/app/api/wiki/git-branches/route.ts +0 -32
  163. package/.next/standalone/src/app/api/wiki/git-checkout/route.ts +0 -45
  164. package/.next/standalone/src/app/api/wiki/git-diff/route.ts +0 -33
  165. package/.next/standalone/src/app/api/wiki/git-file-info/route.ts +0 -27
  166. package/.next/standalone/src/app/api/wiki/git-history/route.ts +0 -27
  167. package/.next/standalone/src/app/api/wiki/git-pull/route.ts +0 -48
  168. package/.next/standalone/src/app/api/wiki/move/route.ts +0 -61
  169. package/.next/standalone/src/app/api/wiki/new-file/route.ts +0 -56
  170. package/.next/standalone/src/app/api/wiki/outlinks/route.ts +0 -76
  171. package/.next/standalone/src/app/api/wiki/page/route.ts +0 -92
  172. package/.next/standalone/src/app/api/wiki/presence/route.ts +0 -56
  173. package/.next/standalone/src/app/api/wiki/route.ts +0 -116
  174. package/.next/standalone/src/app/api/wiki/search/route.ts +0 -44
  175. package/.next/standalone/src/app/api/wiki/slugs/route.ts +0 -54
  176. package/.next/standalone/src/app/api/wiki/upload/route.ts +0 -95
  177. package/.next/standalone/src/app/api/wiki/watch/route.ts +0 -67
  178. package/.next/standalone/src/app/globals.css +0 -1249
  179. package/.next/standalone/src/app/icon.svg +0 -11
  180. package/.next/standalone/src/app/layout.tsx +0 -78
  181. package/.next/standalone/src/app/manifest.ts +0 -30
  182. package/.next/standalone/src/app/page.tsx +0 -3260
  183. package/.next/standalone/src/app/s/[token]/page.tsx +0 -357
  184. package/.next/standalone/src/app/signin/page.tsx +0 -16
  185. package/.next/standalone/src/app/signin/signin-form.tsx +0 -238
  186. package/.next/standalone/src/components/ai-panel/activity-row.tsx +0 -284
  187. package/.next/standalone/src/components/ai-panel/ai-panel.tsx +0 -311
  188. package/.next/standalone/src/components/ai-panel/token-section.tsx +0 -313
  189. package/.next/standalone/src/components/auth-settings-sheet.tsx +0 -474
  190. package/.next/standalone/src/components/confirm-dialog.tsx +0 -56
  191. package/.next/standalone/src/components/dir-picker.tsx +0 -606
  192. package/.next/standalone/src/components/editor/backlinks-panel.tsx +0 -139
  193. package/.next/standalone/src/components/editor/bubble-menu.tsx +0 -346
  194. package/.next/standalone/src/components/editor/callout-extension.ts +0 -36
  195. package/.next/standalone/src/components/editor/comment-pip.tsx +0 -56
  196. package/.next/standalone/src/components/editor/comment-thread.tsx +0 -254
  197. package/.next/standalone/src/components/editor/csv-viewer.tsx +0 -379
  198. package/.next/standalone/src/components/editor/document-outline.tsx +0 -230
  199. package/.next/standalone/src/components/editor/editor-toolbar.tsx +0 -564
  200. package/.next/standalone/src/components/editor/editor.tsx +0 -1327
  201. package/.next/standalone/src/components/editor/extensions/drag-handle.ts +0 -325
  202. package/.next/standalone/src/components/editor/extensions/heading-anchors.ts +0 -55
  203. package/.next/standalone/src/components/editor/extensions/proof-span.ts +0 -60
  204. package/.next/standalone/src/components/editor/extensions/resizable-image.tsx +0 -159
  205. package/.next/standalone/src/components/editor/extensions.ts +0 -150
  206. package/.next/standalone/src/components/editor/file-fallback-viewer.tsx +0 -75
  207. package/.next/standalone/src/components/editor/folder-index.tsx +0 -236
  208. package/.next/standalone/src/components/editor/google-doc-viewer.tsx +0 -73
  209. package/.next/standalone/src/components/editor/image-viewer.tsx +0 -57
  210. package/.next/standalone/src/components/editor/large-file-gate.tsx +0 -108
  211. package/.next/standalone/src/components/editor/link-popover.tsx +0 -111
  212. package/.next/standalone/src/components/editor/media-popover.tsx +0 -212
  213. package/.next/standalone/src/components/editor/media-viewer.tsx +0 -70
  214. package/.next/standalone/src/components/editor/mermaid-viewer.tsx +0 -286
  215. package/.next/standalone/src/components/editor/node-app-viewer.tsx +0 -328
  216. package/.next/standalone/src/components/editor/notebook-viewer.tsx +0 -371
  217. package/.next/standalone/src/components/editor/office/docx-viewer.tsx +0 -93
  218. package/.next/standalone/src/components/editor/office/office-chrome.tsx +0 -83
  219. package/.next/standalone/src/components/editor/office/pptx-viewer.tsx +0 -104
  220. package/.next/standalone/src/components/editor/office/xlsx-viewer.tsx +0 -192
  221. package/.next/standalone/src/components/editor/pdf-viewer.tsx +0 -32
  222. package/.next/standalone/src/components/editor/proof-span-popover.tsx +0 -162
  223. package/.next/standalone/src/components/editor/slash-commands.tsx +0 -629
  224. package/.next/standalone/src/components/editor/source-viewer.tsx +0 -289
  225. package/.next/standalone/src/components/editor/suggest-edit-popover.tsx +0 -229
  226. package/.next/standalone/src/components/editor/suggestion-card.tsx +0 -206
  227. package/.next/standalone/src/components/editor/table-menu.tsx +0 -232
  228. package/.next/standalone/src/components/editor/view-mode-comment-button.tsx +0 -77
  229. package/.next/standalone/src/components/editor/website-viewer.tsx +0 -75
  230. package/.next/standalone/src/components/editor/wiki-link-create-dialog.tsx +0 -189
  231. package/.next/standalone/src/components/editor/wiki-link-decorator.ts +0 -79
  232. package/.next/standalone/src/components/editor/wiki-link-extension.ts +0 -120
  233. package/.next/standalone/src/components/editor/wiki-link-picker.tsx +0 -250
  234. package/.next/standalone/src/components/layout/viewer-toolbar.tsx +0 -54
  235. package/.next/standalone/src/components/search/search-command-dialog.tsx +0 -246
  236. package/.next/standalone/src/components/search/sidebar-search-box.tsx +0 -121
  237. package/.next/standalone/src/components/search/snippet-text.tsx +0 -48
  238. package/.next/standalone/src/components/share-dialog.tsx +0 -307
  239. package/.next/standalone/src/components/theme-provider.tsx +0 -16
  240. package/.next/standalone/src/components/theme-toggle.tsx +0 -24
  241. package/.next/standalone/src/components/ui/badge.tsx +0 -35
  242. package/.next/standalone/src/components/ui/button.tsx +0 -56
  243. package/.next/standalone/src/components/ui/card.tsx +0 -63
  244. package/.next/standalone/src/components/ui/collapsible.tsx +0 -9
  245. package/.next/standalone/src/components/ui/command.tsx +0 -151
  246. package/.next/standalone/src/components/ui/context-menu.tsx +0 -191
  247. package/.next/standalone/src/components/ui/dialog.tsx +0 -119
  248. package/.next/standalone/src/components/ui/dropdown-menu.tsx +0 -194
  249. package/.next/standalone/src/components/ui/input.tsx +0 -22
  250. package/.next/standalone/src/components/ui/label.tsx +0 -25
  251. package/.next/standalone/src/components/ui/popover.tsx +0 -33
  252. package/.next/standalone/src/components/ui/scroll-area.tsx +0 -47
  253. package/.next/standalone/src/components/ui/select.tsx +0 -156
  254. package/.next/standalone/src/components/ui/separator.tsx +0 -30
  255. package/.next/standalone/src/components/ui/sheet.tsx +0 -140
  256. package/.next/standalone/src/components/ui/skeleton.tsx +0 -15
  257. package/.next/standalone/src/components/ui/switch.tsx +0 -28
  258. package/.next/standalone/src/components/ui/tabs.tsx +0 -54
  259. package/.next/standalone/src/components/ui/textarea.tsx +0 -21
  260. package/.next/standalone/src/components/ui/tip.tsx +0 -23
  261. package/.next/standalone/src/components/ui/toggle-group.tsx +0 -41
  262. package/.next/standalone/src/components/ui/tooltip.tsx +0 -27
  263. package/.next/standalone/src/components/view-width-toggle.tsx +0 -70
  264. package/.next/standalone/src/components/wiki/frontmatter-header.tsx +0 -164
  265. package/.next/standalone/src/hooks/use-is-mobile.ts +0 -14
  266. package/.next/standalone/src/lib/app-runner.ts +0 -272
  267. package/.next/standalone/src/lib/auth/admin.ts +0 -120
  268. package/.next/standalone/src/lib/auth/allowlist.ts +0 -50
  269. package/.next/standalone/src/lib/auth/client.ts +0 -4
  270. package/.next/standalone/src/lib/auth/csrf.ts +0 -68
  271. package/.next/standalone/src/lib/auth/server.ts +0 -215
  272. package/.next/standalone/src/lib/cabinets/tree.ts +0 -75
  273. package/.next/standalone/src/lib/config.ts +0 -114
  274. package/.next/standalone/src/lib/embeds/detect.ts +0 -142
  275. package/.next/standalone/src/lib/git-secrets.ts +0 -65
  276. package/.next/standalone/src/lib/git.ts +0 -503
  277. package/.next/standalone/src/lib/google/detect.ts +0 -107
  278. package/.next/standalone/src/lib/markdown/parse-frontmatter.ts +0 -104
  279. package/.next/standalone/src/lib/markdown/remark-wikilinks.ts +0 -100
  280. package/.next/standalone/src/lib/markdown/sanitize-schema.ts +0 -106
  281. package/.next/standalone/src/lib/markdown/to-html.ts +0 -282
  282. package/.next/standalone/src/lib/markdown/to-markdown.ts +0 -252
  283. package/.next/standalone/src/lib/proof/activity-shared.ts +0 -31
  284. package/.next/standalone/src/lib/proof/activity.ts +0 -74
  285. package/.next/standalone/src/lib/proof/audit.ts +0 -88
  286. package/.next/standalone/src/lib/proof/auth.ts +0 -143
  287. package/.next/standalone/src/lib/proof/block-refs.ts +0 -133
  288. package/.next/standalone/src/lib/proof/blocks.ts +0 -73
  289. package/.next/standalone/src/lib/proof/client-auth.ts +0 -23
  290. package/.next/standalone/src/lib/proof/collab-state.ts +0 -81
  291. package/.next/standalone/src/lib/proof/event-bus.ts +0 -47
  292. package/.next/standalone/src/lib/proof/file-lock.ts +0 -43
  293. package/.next/standalone/src/lib/proof/glob.ts +0 -51
  294. package/.next/standalone/src/lib/proof/idempotency.ts +0 -37
  295. package/.next/standalone/src/lib/proof/lease.ts +0 -117
  296. package/.next/standalone/src/lib/proof/mutex.ts +0 -36
  297. package/.next/standalone/src/lib/proof/ops-applier.ts +0 -727
  298. package/.next/standalone/src/lib/proof/owner-auth.ts +0 -2
  299. package/.next/standalone/src/lib/proof/pending.ts +0 -97
  300. package/.next/standalone/src/lib/proof/proof-span.ts +0 -141
  301. package/.next/standalone/src/lib/proof/rate-limit.ts +0 -53
  302. package/.next/standalone/src/lib/proof/raw-fs.ts +0 -197
  303. package/.next/standalone/src/lib/proof/register-rate-limit.ts +0 -53
  304. package/.next/standalone/src/lib/proof/registry.ts +0 -195
  305. package/.next/standalone/src/lib/proof/sidecar.ts +0 -103
  306. package/.next/standalone/src/lib/proof/suggest-capture.ts +0 -69
  307. package/.next/standalone/src/lib/proof/types.ts +0 -182
  308. package/.next/standalone/src/lib/proof-config.ts +0 -14
  309. package/.next/standalone/src/lib/root-dir.ts +0 -35
  310. package/.next/standalone/src/lib/search/indexable-exts.ts +0 -25
  311. package/.next/standalone/src/lib/search/indexer.ts +0 -634
  312. package/.next/standalone/src/lib/search/sanitize.ts +0 -35
  313. package/.next/standalone/src/lib/search/search-db.ts +0 -57
  314. package/.next/standalone/src/lib/search/watcher-pool.ts +0 -79
  315. package/.next/standalone/src/lib/shared-docs/db.ts +0 -177
  316. package/.next/standalone/src/lib/toast.ts +0 -9
  317. package/.next/standalone/src/lib/utils.ts +0 -6
  318. package/.next/standalone/src/lib/wiki-helpers.ts +0 -36
  319. package/.next/standalone/src/lib/workspace-client.ts +0 -82
  320. package/.next/standalone/src/lib/workspace-context.ts +0 -173
  321. package/.next/standalone/src/lib/workspaces.ts +0 -400
  322. package/.next/standalone/src/middleware.ts +0 -44
  323. package/.next/standalone/src/stores/ai-panel-store.ts +0 -79
  324. package/.next/standalone/src/stores/editor-store.ts +0 -439
  325. package/.next/standalone/src/stores/pin-store.ts +0 -56
  326. package/.next/standalone/src/stores/proof-store.ts +0 -124
  327. package/.next/standalone/src/stores/recent-store.ts +0 -51
  328. package/.next/standalone/src/stores/search-store.ts +0 -104
  329. package/.next/standalone/src/stores/show-hidden-store.ts +0 -26
  330. package/.next/standalone/src/stores/sidebar-width-store.ts +0 -39
  331. package/.next/standalone/src/stores/skin-store.ts +0 -42
  332. package/.next/standalone/src/stores/tree-store.ts +0 -52
  333. package/.next/standalone/src/stores/view-width-store.ts +0 -101
  334. package/.next/standalone/src/stores/wiki-slugs-store.ts +0 -75
  335. package/.next/standalone/src/tests/proof/activity-aggregator.test.ts +0 -146
  336. package/.next/standalone/src/tests/proof/admin-create-user.test.ts +0 -43
  337. package/.next/standalone/src/tests/proof/agent-fs.test.ts +0 -973
  338. package/.next/standalone/src/tests/proof/agent-ownership.test.ts +0 -140
  339. package/.next/standalone/src/tests/proof/agent-workspace-scope.test.ts +0 -134
  340. package/.next/standalone/src/tests/proof/agents-install.test.ts +0 -110
  341. package/.next/standalone/src/tests/proof/bench-write.ts +0 -179
  342. package/.next/standalone/src/tests/proof/better-auth.test.ts +0 -68
  343. package/.next/standalone/src/tests/proof/block-refs.test.ts +0 -108
  344. package/.next/standalone/src/tests/proof/blocks.test.ts +0 -92
  345. package/.next/standalone/src/tests/proof/collab-state.test.ts +0 -501
  346. package/.next/standalone/src/tests/proof/comments-ops.test.ts +0 -177
  347. package/.next/standalone/src/tests/proof/editor-roundtrip.test.ts +0 -85
  348. package/.next/standalone/src/tests/proof/external-edit.test.ts +0 -58
  349. package/.next/standalone/src/tests/proof/file-lock.test.ts +0 -80
  350. package/.next/standalone/src/tests/proof/git-branches-checkout.test.ts +0 -136
  351. package/.next/standalone/src/tests/proof/git-read-features.test.ts +0 -473
  352. package/.next/standalone/src/tests/proof/git-secrets.test.ts +0 -138
  353. package/.next/standalone/src/tests/proof/git-sparse.test.ts +0 -257
  354. package/.next/standalone/src/tests/proof/git-workspace.test.ts +0 -135
  355. package/.next/standalone/src/tests/proof/git.test.ts +0 -243
  356. package/.next/standalone/src/tests/proof/glob.test.ts +0 -82
  357. package/.next/standalone/src/tests/proof/helpers/auth-session.ts +0 -27
  358. package/.next/standalone/src/tests/proof/markdown-to-html.test.ts +0 -46
  359. package/.next/standalone/src/tests/proof/ops-applier.test.ts +0 -368
  360. package/.next/standalone/src/tests/proof/owner-init.test.ts +0 -2
  361. package/.next/standalone/src/tests/proof/parse-frontmatter.test.ts +0 -60
  362. package/.next/standalone/src/tests/proof/preload.ts +0 -21
  363. package/.next/standalone/src/tests/proof/proof-span.test.ts +0 -98
  364. package/.next/standalone/src/tests/proof/rate-limit.test.ts +0 -54
  365. package/.next/standalone/src/tests/proof/readonly-enforcement.test.ts +0 -161
  366. package/.next/standalone/src/tests/proof/reconcile-sidecar.test.ts +0 -195
  367. package/.next/standalone/src/tests/proof/registration-flow.test.ts +0 -330
  368. package/.next/standalone/src/tests/proof/registry.test.ts +0 -169
  369. package/.next/standalone/src/tests/proof/routes.test.ts +0 -516
  370. package/.next/standalone/src/tests/proof/search-index.test.ts +0 -376
  371. package/.next/standalone/src/tests/proof/sidecar-lifecycle.test.ts +0 -177
  372. package/.next/standalone/src/tests/proof/sidecar-trim.test.ts +0 -58
  373. package/.next/standalone/src/tests/proof/suggestion-ops.test.ts +0 -280
  374. package/.next/standalone/src/tests/proof/wiki-content-put.test.ts +0 -140
  375. package/.next/standalone/src/tests/proof/wiki-routes-auth.test.ts +0 -208
  376. package/.next/standalone/src/tests/proof/workspace-isolation.test.ts +0 -87
  377. package/.next/standalone/src/tests/proof/workspaces-api.test.ts +0 -227
  378. package/.next/standalone/src/types/index.ts +0 -47
  379. package/.next/standalone/tailwind.config.ts +0 -191
  380. package/.next/standalone/tsconfig.json +0 -41
  381. package/.next/standalone/tsconfig.tsbuildinfo +0 -1
  382. /package/.next/standalone/.next/static/{WMOTgfV82apmdovxzgbMx → rRyvFORvJoc5OWbCR2A_P}/_buildManifest.js +0 -0
  383. /package/.next/standalone/.next/static/{WMOTgfV82apmdovxzgbMx → rRyvFORvJoc5OWbCR2A_P}/_clientMiddlewareManifest.js +0 -0
  384. /package/.next/standalone/.next/static/{WMOTgfV82apmdovxzgbMx → rRyvFORvJoc5OWbCR2A_P}/_ssgManifest.js +0 -0
@@ -1,280 +0,0 @@
1
- import { test, before, after } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { mkdtemp, writeFile, rm } from "node:fs/promises";
4
- import { tmpdir } from "node:os";
5
- import path from "node:path";
6
- import { applyOps, readSnapshot } from "../../lib/proof/ops-applier.js";
7
- import { setRootDir } from "../../lib/root-dir.js";
8
-
9
- let tmpRoot: string;
10
-
11
- before(async () => {
12
- tmpRoot = await mkdtemp(path.join(tmpdir(), "wiki-suggestion-ops-test-"));
13
- setRootDir(tmpRoot);
14
- });
15
-
16
- after(async () => {
17
- await rm(tmpRoot, { recursive: true, force: true });
18
- });
19
-
20
- async function writeDoc(name: string, content: string): Promise<void> {
21
- await writeFile(path.join(tmpRoot, name), content, "utf-8");
22
- }
23
-
24
- // ── suggestion.add (pending) ─────────────────────────────────────────────────
25
-
26
- test("suggestion.add with status=pending → sidecar has pending suggestion + event suggestion.added", async () => {
27
- await writeDoc("sug-add-pending.md", "# Title\n\nOriginal paragraph.\n");
28
- const snap = await readSnapshot(tmpRoot, "sug-add-pending.md");
29
- assert.ok(snap !== null);
30
- const paraRef = snap!.blocks[1].ref;
31
-
32
- const result = await applyOps({
33
- rootDir: tmpRoot,
34
- mdPath: "sug-add-pending.md",
35
- baseRevision: 0,
36
- by: "ai:claude",
37
- ops: [{
38
- type: "suggestion.add",
39
- ref: paraRef,
40
- kind: "replace",
41
- markdown: "Proposed replacement.",
42
- basis: "described",
43
- basisDetail: "user mentioned slippage",
44
- }],
45
- });
46
-
47
- assert.ok(result.ok, `expected ok: ${JSON.stringify(result)}`);
48
- const sug = result.ok ? result.snapshot.suggestions[0] : null;
49
- assert.ok(sug, "pending suggestion should be present in snapshot");
50
- assert.equal(sug!.status, "pending");
51
- assert.equal(sug!.kind, "replace");
52
- assert.equal(sug!.markdown, "Proposed replacement.");
53
- assert.equal(sug!.by, "ai:claude");
54
- assert.equal(sug!.basisDetail, "user mentioned slippage");
55
-
56
- // Event: suggestion.added emitted
57
- assert.ok(result.ok);
58
- const addedEvt = result.ok
59
- ? result.emittedEvents.find((e) => e.type === "suggestion.added")
60
- : null;
61
- assert.ok(addedEvt, "suggestion.added event should be emitted");
62
- assert.equal((addedEvt as unknown as { type: string; suggestionId: string }).suggestionId, sug!.id);
63
-
64
- // File content should NOT change (still pending)
65
- const snap2 = await readSnapshot(tmpRoot, "sug-add-pending.md");
66
- assert.ok(snap2!.blocks.some((b) => b.markdown.includes("Original paragraph.")), "original should remain");
67
- });
68
-
69
- // ── suggestion.add (pre-accepted) ────────────────────────────────────────────
70
-
71
- test("suggestion.add with status=accepted → block replaced + 2 events", async () => {
72
- await writeDoc("sug-add-accepted.md", "# Title\n\nOriginal paragraph.\n");
73
- const snap = await readSnapshot(tmpRoot, "sug-add-accepted.md");
74
- const paraRef = snap!.blocks[1].ref;
75
-
76
- const result = await applyOps({
77
- rootDir: tmpRoot,
78
- mdPath: "sug-add-accepted.md",
79
- baseRevision: 0,
80
- by: "ai:claude",
81
- ops: [{
82
- type: "suggestion.add",
83
- ref: paraRef,
84
- kind: "replace",
85
- markdown: "Auto-accepted replacement.",
86
- status: "accepted",
87
- }],
88
- });
89
-
90
- assert.ok(result.ok, `expected ok: ${JSON.stringify(result)}`);
91
-
92
- // Suggestion should NOT be in pending list (it's archived)
93
- const pending = result.ok ? result.snapshot.suggestions : [];
94
- assert.equal(pending.length, 0, "no pending suggestions after auto-accept");
95
-
96
- // Two events: suggestion.added + suggestion.accepted
97
- assert.ok(result.ok);
98
- const events = result.ok ? result.emittedEvents : [];
99
- const addedEvt = events.find((e) => e.type === "suggestion.added");
100
- const acceptedEvt = events.find((e) => e.type === "suggestion.accepted");
101
- assert.ok(addedEvt, "suggestion.added event should be emitted");
102
- assert.ok(acceptedEvt, "suggestion.accepted event should be emitted");
103
- });
104
-
105
- // ── suggestion.accept ────────────────────────────────────────────────────────
106
-
107
- test("suggestion.accept → pending becomes accepted, block edit applied, event emitted", async () => {
108
- await writeDoc("sug-accept.md", "# Title\n\nOriginal paragraph.\n");
109
- const snap = await readSnapshot(tmpRoot, "sug-accept.md");
110
- const paraRef = snap!.blocks[1].ref;
111
-
112
- // Add suggestion
113
- const addResult = await applyOps({
114
- rootDir: tmpRoot,
115
- mdPath: "sug-accept.md",
116
- baseRevision: 0,
117
- by: "ai:claude",
118
- ops: [{
119
- type: "suggestion.add",
120
- ref: paraRef,
121
- kind: "replace",
122
- markdown: "Accepted replacement.",
123
- }],
124
- });
125
- assert.ok(addResult.ok, `add: ${JSON.stringify(addResult)}`);
126
- const sugId = addResult.ok ? addResult.snapshot.suggestions[0]?.id : null;
127
- assert.ok(sugId, "suggestion id must exist");
128
-
129
- // Accept suggestion
130
- const acceptResult = await applyOps({
131
- rootDir: tmpRoot,
132
- mdPath: "sug-accept.md",
133
- baseRevision: 1,
134
- by: "human",
135
- ops: [{ type: "suggestion.accept", suggestionId: sugId! }],
136
- });
137
- assert.ok(acceptResult.ok, `accept: ${JSON.stringify(acceptResult)}`);
138
-
139
- // No more pending suggestions
140
- const pending = acceptResult.ok ? acceptResult.snapshot.suggestions : [];
141
- assert.equal(pending.length, 0, "no pending after accept");
142
-
143
- // suggestion.accepted event emitted
144
- assert.ok(acceptResult.ok);
145
- const evt = acceptResult.ok
146
- ? acceptResult.emittedEvents.find((e) => e.type === "suggestion.accepted")
147
- : null;
148
- assert.ok(evt, "suggestion.accepted event emitted");
149
-
150
- // File content updated
151
- const snap2 = await readSnapshot(tmpRoot, "sug-accept.md");
152
- assert.ok(snap2!.blocks.some((b) => b.markdown.includes("Accepted replacement.")), "block replaced");
153
- assert.ok(!snap2!.blocks.some((b) => b.markdown.includes("Original paragraph.")), "old block gone");
154
- });
155
-
156
- // ── suggestion.reject ────────────────────────────────────────────────────────
157
-
158
- test("suggestion.reject → moved to archivedSuggestions + event, file unchanged", async () => {
159
- await writeDoc("sug-reject.md", "# Title\n\nOriginal paragraph.\n");
160
- const snap = await readSnapshot(tmpRoot, "sug-reject.md");
161
- const paraRef = snap!.blocks[1].ref;
162
-
163
- const addResult = await applyOps({
164
- rootDir: tmpRoot,
165
- mdPath: "sug-reject.md",
166
- baseRevision: 0,
167
- by: "ai:claude",
168
- ops: [{
169
- type: "suggestion.add",
170
- ref: paraRef,
171
- kind: "replace",
172
- markdown: "Rejected replacement.",
173
- }],
174
- });
175
- assert.ok(addResult.ok);
176
- const sugId = addResult.ok ? addResult.snapshot.suggestions[0]?.id : null;
177
- assert.ok(sugId);
178
-
179
- const rejectResult = await applyOps({
180
- rootDir: tmpRoot,
181
- mdPath: "sug-reject.md",
182
- baseRevision: 1,
183
- by: "human",
184
- ops: [{ type: "suggestion.reject", suggestionId: sugId! }],
185
- });
186
- assert.ok(rejectResult.ok, `reject: ${JSON.stringify(rejectResult)}`);
187
-
188
- // No pending suggestions
189
- const pending = rejectResult.ok ? rejectResult.snapshot.suggestions : [];
190
- assert.equal(pending.length, 0, "no pending after reject");
191
-
192
- // suggestion.rejected event
193
- assert.ok(rejectResult.ok);
194
- const evt = rejectResult.ok
195
- ? rejectResult.emittedEvents.find((e) => e.type === "suggestion.rejected")
196
- : null;
197
- assert.ok(evt, "suggestion.rejected event emitted");
198
-
199
- // File NOT changed
200
- const snap2 = await readSnapshot(tmpRoot, "sug-reject.md");
201
- assert.ok(snap2!.blocks.some((b) => b.markdown.includes("Original paragraph.")), "original preserved");
202
- assert.ok(!snap2!.blocks.some((b) => b.markdown.includes("Rejected replacement.")), "rejected text absent");
203
- });
204
-
205
- // ── two pending on same ref, accept one → other auto-rejected (§6.8) ─────────
206
-
207
- test("two pending suggestions on same ref: accept one → other auto-rejected (resolvedBy: system)", async () => {
208
- await writeDoc("sug-conflict.md", "# Title\n\nOriginal paragraph.\n");
209
- const snap = await readSnapshot(tmpRoot, "sug-conflict.md");
210
- const paraRef = snap!.blocks[1].ref;
211
-
212
- // Add first suggestion
213
- const add1 = await applyOps({
214
- rootDir: tmpRoot,
215
- mdPath: "sug-conflict.md",
216
- baseRevision: 0,
217
- by: "ai:claude",
218
- ops: [{ type: "suggestion.add", ref: paraRef, kind: "replace", markdown: "Suggestion A." }],
219
- });
220
- assert.ok(add1.ok);
221
- const sugId1 = add1.ok ? add1.snapshot.suggestions[0]?.id : null;
222
- assert.ok(sugId1);
223
-
224
- // Add second suggestion (same ref)
225
- const add2 = await applyOps({
226
- rootDir: tmpRoot,
227
- mdPath: "sug-conflict.md",
228
- baseRevision: 1,
229
- by: "ai:cursor",
230
- ops: [{ type: "suggestion.add", ref: paraRef, kind: "replace", markdown: "Suggestion B." }],
231
- });
232
- assert.ok(add2.ok);
233
- const sugId2 = add2.ok ? add2.snapshot.suggestions[1]?.id : null;
234
- assert.ok(sugId2, "second suggestion should exist");
235
-
236
- // Both pending
237
- assert.equal(add2.ok ? add2.snapshot.suggestions.length : -1, 2, "two pending");
238
-
239
- // Accept first
240
- const acceptResult = await applyOps({
241
- rootDir: tmpRoot,
242
- mdPath: "sug-conflict.md",
243
- baseRevision: 2,
244
- by: "human",
245
- ops: [{ type: "suggestion.accept", suggestionId: sugId1! }],
246
- });
247
- assert.ok(acceptResult.ok, `accept: ${JSON.stringify(acceptResult)}`);
248
-
249
- // No pending left
250
- const pending = acceptResult.ok ? acceptResult.snapshot.suggestions : [];
251
- assert.equal(pending.length, 0, "no pending after accepting one");
252
-
253
- // suggestion.rejected event with reason=superseded for the second
254
- assert.ok(acceptResult.ok);
255
- const events = acceptResult.ok ? acceptResult.emittedEvents : [];
256
- const rejectedEvt = events.find(
257
- (e) => e.type === "suggestion.rejected" && (e as unknown as { suggestionId: string }).suggestionId === sugId2,
258
- ) as { type: string; by: string; reason: string } | undefined;
259
- assert.ok(rejectedEvt, "rejected event for second suggestion");
260
- assert.equal(rejectedEvt!.by, "system", "resolvedBy should be system");
261
- assert.equal(rejectedEvt!.reason, "superseded");
262
- });
263
-
264
- // ── suggestion.accept on nonexistent ID → 409 SUGGESTION_NOT_FOUND ──────────
265
-
266
- test("suggestion.accept on nonexistent ID → 409 SUGGESTION_NOT_FOUND", async () => {
267
- await writeDoc("sug-notfound.md", "# Title\n\nParagraph.\n");
268
-
269
- const result = await applyOps({
270
- rootDir: tmpRoot,
271
- mdPath: "sug-notfound.md",
272
- baseRevision: 0,
273
- by: "human",
274
- ops: [{ type: "suggestion.accept", suggestionId: "sdeadbeef" }],
275
- });
276
-
277
- assert.ok(!result.ok);
278
- assert.equal(result.ok ? "" : result.code, "SUGGESTION_NOT_FOUND");
279
- assert.equal(result.ok ? 0 : result.status, 409);
280
- });
@@ -1,140 +0,0 @@
1
- /**
2
- * Tests for PUT /api/wiki/content:
3
- * - auth required
4
- * - non-markdown plain write
5
- * - markdown with revision tracking
6
- * - stale revision → 409
7
- * - agent sees bumped revision after PUT
8
- */
9
- import { test, before, after } from "node:test";
10
- import assert from "node:assert/strict";
11
- import { mkdtemp, rm, writeFile, mkdir } from "node:fs/promises";
12
- import { tmpdir } from "node:os";
13
- import path from "node:path";
14
-
15
- let tmpHome: string;
16
- let tmpRoot: string;
17
-
18
- before(async () => {
19
- tmpHome = await mkdtemp(path.join(tmpdir(), "wiki-put-test-"));
20
- tmpRoot = await mkdtemp(path.join(tmpdir(), "wiki-put-root-"));
21
- process.env.HOME = tmpHome;
22
- process.env.ROOT_DIR = tmpRoot;
23
- // Force root-dir module to pick up new ROOT_DIR
24
- const { setRootDir } = await import("../../lib/root-dir.js");
25
- setRootDir(tmpRoot);
26
- });
27
-
28
- after(async () => {
29
- await rm(tmpHome, { recursive: true, force: true });
30
- await rm(tmpRoot, { recursive: true, force: true });
31
- });
32
-
33
- import { PUT, GET } from "../../app/api/wiki/content/route.js";
34
-
35
- async function makeUserCookie(): Promise<string> {
36
- const { auth, authReady } = await import("../../lib/auth/server.js");
37
- await authReady();
38
- const res = await auth.api.signUpEmail({
39
- body: {
40
- email: `put${Date.now()}${Math.random().toString(36).slice(2, 5)}@test.local`,
41
- password: "test1234!",
42
- name: "Put Test User",
43
- },
44
- asResponse: true,
45
- });
46
- if (!res.ok) throw new Error("signUpEmail failed: " + res.status);
47
- const setCookie = res.headers.get("set-cookie") ?? "";
48
- return setCookie
49
- .split(/,(?=[^ ])/)
50
- .map((c) => c.split(";")[0].trim())
51
- .join("; ");
52
- }
53
-
54
- function makePutReq(
55
- body: Record<string, unknown>,
56
- cookie: string,
57
- ): Request {
58
- return new Request("http://localhost:3000/api/wiki/content", {
59
- method: "PUT",
60
- headers: { "Content-Type": "application/json", Cookie: cookie },
61
- body: JSON.stringify(body),
62
- });
63
- }
64
-
65
- test("PUT without session → 401", async () => {
66
- const req = new Request("http://localhost:3000/api/wiki/content", {
67
- method: "PUT",
68
- headers: { "Content-Type": "application/json" },
69
- body: JSON.stringify({ path: "test.md", content: "hi" }),
70
- });
71
- const res = await PUT(req);
72
- assert.equal(res.status, 401);
73
- });
74
-
75
- test("PUT markdown with session + baseRevision:0 on new file → 200, revision 1", async () => {
76
- const cookie = await makeUserCookie();
77
- const filePath = path.join(tmpRoot, "new.md");
78
- await writeFile(filePath, "# Hello\n", "utf-8");
79
-
80
- const req = makePutReq({ path: "new.md", content: "# Updated\n", baseRevision: 0 }, cookie);
81
- const res = await PUT(req);
82
- assert.equal(res.status, 200);
83
- const data = (await res.json()) as { ok: boolean; revision: number };
84
- assert.equal(data.ok, true);
85
- assert.equal(typeof data.revision, "number");
86
- assert.ok(data.revision >= 1);
87
- });
88
-
89
- test("PUT markdown with matching baseRevision → 200", async () => {
90
- const cookie = await makeUserCookie();
91
- const filePath = path.join(tmpRoot, "rev.md");
92
- await writeFile(filePath, "# Rev\n", "utf-8");
93
-
94
- // First save — baseRevision:0 for fresh file
95
- const r1 = await PUT(makePutReq({ path: "rev.md", content: "# Rev v1\n", baseRevision: 0 }, cookie));
96
- assert.equal(r1.status, 200);
97
- const d1 = (await r1.json()) as { revision: number };
98
-
99
- // Second save — matching baseRevision
100
- const r2 = await PUT(makePutReq({ path: "rev.md", content: "# Rev v2\n", baseRevision: d1.revision }, cookie));
101
- assert.equal(r2.status, 200);
102
- const d2 = (await r2.json()) as { revision: number };
103
- assert.equal(d2.revision, d1.revision + 1);
104
- });
105
-
106
- test("PUT markdown with stale baseRevision → 409", async () => {
107
- const cookie = await makeUserCookie();
108
- const filePath = path.join(tmpRoot, "stale.md");
109
- await writeFile(filePath, "# Stale\n", "utf-8");
110
-
111
- // First save to bump revision
112
- const r1 = await PUT(makePutReq({ path: "stale.md", content: "# v1\n", baseRevision: 0 }, cookie));
113
- assert.equal(r1.status, 200);
114
-
115
- // Second save with stale revision 0
116
- const r2 = await PUT(makePutReq({ path: "stale.md", content: "# v2\n", baseRevision: 0 }, cookie));
117
- assert.equal(r2.status, 409);
118
- const body = (await r2.json()) as { error: string; currentRevision: number };
119
- assert.equal(body.error, "STALE_REVISION");
120
- assert.ok(body.currentRevision >= 1);
121
- });
122
-
123
- test("PUT non-markdown file → 200, no revision field", async () => {
124
- const cookie = await makeUserCookie();
125
- const filePath = path.join(tmpRoot, "data.json");
126
- await writeFile(filePath, "{}", "utf-8");
127
-
128
- const req = makePutReq({ path: "data.json", content: '{"a":1}' }, cookie);
129
- const res = await PUT(req);
130
- assert.equal(res.status, 200);
131
- const data = (await res.json()) as { ok: boolean; revision?: number };
132
- assert.equal(data.ok, true);
133
- assert.equal(data.revision, undefined);
134
- });
135
-
136
- test("GET without auth → 401", async () => {
137
- const req = new Request("http://localhost:3000/api/wiki/content?path=read.md");
138
- const res = await GET(req);
139
- assert.equal(res.status, 401);
140
- });
@@ -1,208 +0,0 @@
1
- /**
2
- * Auth and CSRF enforcement tests for /api/wiki/* routes.
3
- *
4
- * Verifies:
5
- * - Unauthenticated requests to protected endpoints → 401
6
- * - Cross-origin state-changing requests → 403
7
- * - Same-origin state-changing requests pass the CSRF check
8
- * - baseRevision required for markdown PUT → 400 BASE_REVISION_REQUIRED
9
- * - Stale baseRevision → 409 STALE_REVISION
10
- * - Happy-path markdown PUT → 200 with revision header
11
- * - GET with auth returns X-Wiki-Revision + X-Wiki-Fingerprint for markdown
12
- */
13
- import { test, before, after } from "node:test";
14
- import assert from "node:assert/strict";
15
- import { mkdtemp, rm, writeFile, mkdir } from "node:fs/promises";
16
- import { tmpdir } from "node:os";
17
- import path from "node:path";
18
-
19
- let tmpHome: string;
20
- let tmpRoot: string;
21
-
22
- before(async () => {
23
- tmpHome = await mkdtemp(path.join(tmpdir(), "wiki-auth-routes-test-"));
24
- process.env.HOME = tmpHome;
25
- process.env.AUTH_ALLOWED_DOMAIN = "test.local";
26
-
27
- tmpRoot = await mkdtemp(path.join(tmpdir(), "wiki-auth-routes-root-"));
28
- process.env.ROOT_DIR = tmpRoot;
29
-
30
- const { setRootDir } = await import("../../lib/root-dir.js");
31
- setRootDir(tmpRoot);
32
-
33
- // Pre-create test files so routes can operate
34
- await mkdir(path.join(tmpRoot, "sub"), { recursive: true });
35
- await writeFile(path.join(tmpRoot, "auth-test.md"), "# Auth Test\n", "utf-8");
36
- await writeFile(path.join(tmpRoot, "stale.md"), "# Stale\n", "utf-8");
37
- await writeFile(path.join(tmpRoot, "happy.md"), "# Happy\n", "utf-8");
38
- await writeFile(path.join(tmpRoot, "rev-check.md"), "# Rev\n", "utf-8");
39
- });
40
-
41
- after(async () => {
42
- delete process.env.AUTH_ALLOWED_DOMAIN;
43
- await rm(tmpHome, { recursive: true, force: true });
44
- await rm(tmpRoot, { recursive: true, force: true });
45
- });
46
-
47
- import { GET as wikiContentGET, PUT as wikiContentPUT } from "../../app/api/wiki/content/route.js";
48
- import { POST as wikiMovePOST } from "../../app/api/wiki/move/route.js";
49
- import { POST as wikiUploadPOST } from "../../app/api/wiki/upload/route.js";
50
- import { DELETE as wikiRootDELETE } from "../../app/api/wiki/route.js";
51
- import { makeUserSession } from "./helpers/auth-session.js";
52
-
53
- // ─── Unauthenticated → 401 ───────────────────────────────────────────────────
54
-
55
- test("GET /api/wiki/content without cookie → 401", async () => {
56
- const req = new Request("http://localhost:3000/api/wiki/content?path=auth-test.md");
57
- const res = await wikiContentGET(req);
58
- assert.equal(res.status, 401);
59
- });
60
-
61
- test("POST /api/wiki/upload without cookie → 401", async () => {
62
- const formData = new FormData();
63
- formData.append("file", new Blob(["hello"], { type: "text/plain" }), "test.txt");
64
- formData.append("path", "test.txt");
65
- const req = new Request("http://localhost:3000/api/wiki/upload", {
66
- method: "POST",
67
- body: formData,
68
- });
69
- const res = await wikiUploadPOST(req);
70
- assert.equal(res.status, 401);
71
- });
72
-
73
- test("POST /api/wiki/move without cookie → 401", async () => {
74
- const req = new Request("http://localhost:3000/api/wiki/move", {
75
- method: "POST",
76
- headers: { "Content-Type": "application/json" },
77
- body: JSON.stringify({ from: "auth-test.md", to: "renamed.md" }),
78
- });
79
- const res = await wikiMovePOST(req);
80
- assert.equal(res.status, 401);
81
- });
82
-
83
- test("DELETE /api/wiki without cookie → 401", async () => {
84
- const req = new Request("http://localhost:3000/api/wiki?path=auth-test.md", {
85
- method: "DELETE",
86
- });
87
- const res = await wikiRootDELETE(req);
88
- assert.equal(res.status, 401);
89
- });
90
-
91
- // ─── CSRF origin checks ───────────────────────────────────────────────────────
92
-
93
- test("POST /api/wiki/move with valid session + bad origin → 403", async () => {
94
- const cookie = await makeUserSession();
95
- const req = new Request("http://localhost:3000/api/wiki/move", {
96
- method: "POST",
97
- headers: {
98
- "Content-Type": "application/json",
99
- Cookie: cookie,
100
- Origin: "https://evil.com",
101
- },
102
- body: JSON.stringify({ from: "auth-test.md", to: "hacked.md" }),
103
- });
104
- const res = await wikiMovePOST(req);
105
- assert.equal(res.status, 403);
106
- });
107
-
108
- test("POST /api/wiki/move with valid session + matching origin → not 403/401", async () => {
109
- const cookie = await makeUserSession();
110
- const req = new Request("http://localhost:3000/api/wiki/move", {
111
- method: "POST",
112
- headers: {
113
- "Content-Type": "application/json",
114
- Cookie: cookie,
115
- Origin: "http://localhost:3000",
116
- },
117
- body: JSON.stringify({ from: "nonexistent-file.md", to: "also-nonexistent.md" }),
118
- });
119
- const res = await wikiMovePOST(req);
120
- // CSRF and auth passed — will fail at file-system level (404 or 400), not 403/401
121
- assert.notEqual(res.status, 403);
122
- assert.notEqual(res.status, 401);
123
- });
124
-
125
- // ─── baseRevision enforcement ─────────────────────────────────────────────────
126
-
127
- test("PUT /api/wiki/content markdown + no baseRevision → 400 BASE_REVISION_REQUIRED", async () => {
128
- const cookie = await makeUserSession();
129
- const req = new Request("http://localhost:3000/api/wiki/content", {
130
- method: "PUT",
131
- headers: { "Content-Type": "application/json", Cookie: cookie },
132
- body: JSON.stringify({ path: "auth-test.md", content: "# Updated\n" }),
133
- });
134
- const res = await wikiContentPUT(req);
135
- assert.equal(res.status, 400);
136
- const body = (await res.json()) as { error: string };
137
- assert.equal(body.error, "BASE_REVISION_REQUIRED");
138
- });
139
-
140
- test("PUT /api/wiki/content markdown + stale baseRevision → 409 STALE_REVISION", async () => {
141
- const cookie = await makeUserSession();
142
-
143
- // First: do a valid save to bump the revision to 1
144
- const r1 = await wikiContentPUT(
145
- new Request("http://localhost:3000/api/wiki/content", {
146
- method: "PUT",
147
- headers: { "Content-Type": "application/json", Cookie: cookie },
148
- body: JSON.stringify({ path: "stale.md", content: "# v1\n", baseRevision: 0 }),
149
- }),
150
- );
151
- assert.equal(r1.status, 200);
152
-
153
- // Now try with stale baseRevision 0 again
154
- const r2 = await wikiContentPUT(
155
- new Request("http://localhost:3000/api/wiki/content", {
156
- method: "PUT",
157
- headers: { "Content-Type": "application/json", Cookie: cookie },
158
- body: JSON.stringify({ path: "stale.md", content: "# v2\n", baseRevision: 0 }),
159
- }),
160
- );
161
- assert.equal(r2.status, 409);
162
- const body = (await r2.json()) as { error: string; currentRevision: number };
163
- assert.equal(body.error, "STALE_REVISION");
164
- assert.equal(body.currentRevision, 1);
165
- });
166
-
167
- test("PUT /api/wiki/content markdown happy path → 200", async () => {
168
- const cookie = await makeUserSession();
169
- const req = new Request("http://localhost:3000/api/wiki/content", {
170
- method: "PUT",
171
- headers: { "Content-Type": "application/json", Cookie: cookie },
172
- body: JSON.stringify({ path: "happy.md", content: "# Updated\n", baseRevision: 0 }),
173
- });
174
- const res = await wikiContentPUT(req);
175
- assert.equal(res.status, 200);
176
- const data = (await res.json()) as { ok: boolean; revision: number };
177
- assert.equal(data.ok, true);
178
- assert.equal(data.revision, 1);
179
- });
180
-
181
- // ─── Response headers ─────────────────────────────────────────────────────────
182
-
183
- test("GET /api/wiki/content markdown with auth → X-Wiki-Revision + X-Wiki-Fingerprint", async () => {
184
- const cookie = await makeUserSession();
185
-
186
- // First write to ensure sidecar exists with revision 1
187
- await wikiContentPUT(
188
- new Request("http://localhost:3000/api/wiki/content", {
189
- method: "PUT",
190
- headers: { "Content-Type": "application/json", Cookie: cookie },
191
- body: JSON.stringify({ path: "rev-check.md", content: "# Rev v1\n", baseRevision: 0 }),
192
- }),
193
- );
194
-
195
- const getReq = new Request(
196
- "http://localhost:3000/api/wiki/content?path=rev-check.md",
197
- { headers: { Cookie: cookie } },
198
- );
199
- const res = await wikiContentGET(getReq);
200
- assert.equal(res.status, 200);
201
-
202
- const revision = res.headers.get("X-Wiki-Revision");
203
- const fingerprint = res.headers.get("X-Wiki-Fingerprint");
204
- assert.ok(revision !== null, "X-Wiki-Revision header missing");
205
- assert.ok(fingerprint !== null, "X-Wiki-Fingerprint header missing");
206
- assert.equal(revision, "1");
207
- assert.ok(fingerprint.startsWith("sha256:"), "fingerprint should be sha256:...");
208
- });