wiki-viewer 1.7.0 → 1.7.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 (68) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/standalone/.next/build-manifest.json +3 -3
  4. package/.next/standalone/.next/prerender-manifest.json +29 -0
  5. package/.next/standalone/.next/routes-manifest.json +6 -0
  6. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.rsc +2 -2
  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 +2 -2
  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 +3 -3
  15. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  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/app-proxy/[...path]/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/index.html +1 -1
  26. package/.next/standalone/.next/server/app/index.rsc +3 -3
  27. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  28. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  29. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  30. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  31. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  32. package/.next/standalone/.next/server/app/manifest.webmanifest/route/app-paths-manifest.json +3 -0
  33. package/.next/standalone/.next/server/app/manifest.webmanifest/route/build-manifest.json +9 -0
  34. package/.next/standalone/.next/server/app/manifest.webmanifest/route/server-reference-manifest.json +4 -0
  35. package/.next/standalone/.next/server/app/manifest.webmanifest/route.js +9 -0
  36. package/.next/standalone/.next/server/app/manifest.webmanifest/route.js.map +5 -0
  37. package/.next/standalone/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -0
  38. package/.next/standalone/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +3 -0
  39. package/.next/standalone/.next/server/app/manifest.webmanifest.body +1 -0
  40. package/.next/standalone/.next/server/app/manifest.webmanifest.meta +1 -0
  41. package/.next/standalone/.next/server/app-paths-manifest.json +1 -0
  42. package/.next/standalone/.next/server/chunks/0p91_next_dist_1195ub1._.js +18 -0
  43. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06yp.08._.js +3 -0
  44. package/.next/standalone/.next/server/chunks/_next-internal_server_app_manifest_webmanifest_route_actions_04wfv0d.js +3 -0
  45. package/.next/standalone/.next/server/chunks/ssr/0p91_next_dist_esm_build_templates_app-page_042apsk.js +1 -1
  46. package/.next/standalone/.next/server/chunks/ssr/0p91_next_dist_esm_build_templates_app-page_08q3u1e.js +1 -1
  47. package/.next/standalone/.next/server/chunks/ssr/0p91_next_dist_esm_build_templates_app-page_0nflz3~.js +1 -1
  48. package/.next/standalone/.next/server/chunks/ssr/0p91_next_dist_esm_build_templates_app-page_0p5k29e.js +1 -1
  49. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0hvvps3._.js +1 -1
  50. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  51. package/.next/standalone/.next/server/middleware-manifest.json +1 -1
  52. package/.next/standalone/.next/server/pages/404.html +1 -1
  53. package/.next/standalone/.next/server/pages/500.html +1 -1
  54. package/.next/standalone/docs/agent-fs-plan.md +3 -1
  55. package/.next/standalone/package.json +1 -1
  56. package/.next/standalone/packages/wiki-viewer-mcp/dist/http-client.js +78 -0
  57. package/.next/standalone/packages/wiki-viewer-mcp/dist/index.js +25 -18
  58. package/.next/standalone/packages/wiki-viewer-mcp/package.json +1 -1
  59. package/.next/standalone/public/icon-192.png +0 -0
  60. package/.next/standalone/public/icon-512.png +0 -0
  61. package/.next/standalone/public/icon-maskable-512.png +0 -0
  62. package/.next/standalone/src/app/layout.tsx +15 -1
  63. package/.next/standalone/src/app/manifest.ts +30 -0
  64. package/.next/standalone/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +1 -1
  66. /package/.next/standalone/.next/static/{uQH5T9TFHOhO0NJbO4QGI → 0XvNCOSEq7cbARTLtAolL}/_buildManifest.js +0 -0
  67. /package/.next/standalone/.next/static/{uQH5T9TFHOhO0NJbO4QGI → 0XvNCOSEq7cbARTLtAolL}/_clientMiddlewareManifest.js +0 -0
  68. /package/.next/standalone/.next/static/{uQH5T9TFHOhO0NJbO4QGI → 0XvNCOSEq7cbARTLtAolL}/_ssgManifest.js +0 -0
@@ -22,7 +22,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
22
22
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
23
23
  import * as z from "zod";
24
24
  import { parseArgs } from "node:util";
25
- import { WikiViewerClient, IfMatchError, CollabActiveError, WikiViewerError } from "./http-client.js";
25
+ import { WikiViewerClient, IfMatchError, CollabActiveError, WikiViewerError, PatchUnsupportedError, MatchCountError } from "./http-client.js";
26
26
  import * as stateCache from "./state-cache.js";
27
27
  /**
28
28
  * Enable pooled HTTP keep-alive for the global fetch the client uses.
@@ -246,30 +246,37 @@ export function createServer(client) {
246
246
  const block = checkCollabBlock(path);
247
247
  if (block)
248
248
  return err(block);
249
- // Fast path: if a prior read cached this file's text + sha, transform
250
- // from cache and do a conditional PUT (If-Match=cached sha). This
251
- // skips the GET round-trip. If the file changed server-side the PUT
252
- // 412s (IfMatchError) and we fall back to a fresh read+retry so the
253
- // result is always against current content, never a stale write.
254
- const cached = stateCache.get(path);
255
- if (cached?.body !== undefined &&
256
- cached.sha256 &&
257
- cached.collabState !== "active" &&
258
- cached.body.includes(find)) {
259
- const newContent = cached.body.replace(find, replace);
249
+ // Best path: server-side PATCH str-replace sends only {find,replace}
250
+ // (~hundreds of bytes) instead of the whole file. One small request.
251
+ // Requires a known sha (If-Match); use cached sha if present, else the
252
+ // server's 412-recover path handles it. Falls back to read+PUT if the
253
+ // server has no PATCH route (older version).
254
+ const cachedForPatch = stateCache.get(path);
255
+ if (cachedForPatch?.collabState !== "active") {
260
256
  try {
261
- const writeResult = await client.writeFile(path, newContent, {
262
- ifMatch: cached.sha256,
257
+ const r = await client.patchFile(path, find, replace, {
258
+ ifMatch: cachedForPatch?.sha256,
263
259
  });
264
- return ok(`Edited: ${path}\nReplaced ${JSON.stringify(find)} → ${JSON.stringify(replace)}\nNew sha256: ${writeResult.sha256}`);
260
+ return ok(`Edited: ${path}\nReplaced ${JSON.stringify(find)} → ${JSON.stringify(replace)}\nNew sha256: ${r.sha256}`);
265
261
  }
266
262
  catch (e) {
267
- if (!(e instanceof IfMatchError))
263
+ if (e instanceof MatchCountError) {
264
+ return err(`edit_file: expected to replace exactly 1 occurrence of ${JSON.stringify(find)} in "${path}", ` +
265
+ `but found ${e.found}. Re-read the file or make the search string unique.`);
266
+ }
267
+ if (e instanceof CollabActiveError) {
268
+ return err(collabActiveMessage(path, e.snapshotUrl));
269
+ }
270
+ if (e instanceof IfMatchError) {
271
+ // sha was stale — fall through to read+retry below.
272
+ }
273
+ else if (!(e instanceof PatchUnsupportedError)) {
268
274
  throw e;
269
- // File changed since our cached read — fall through to re-read.
275
+ }
276
+ // PatchUnsupportedError or stale If-Match → fall back to read+PUT.
270
277
  }
271
278
  }
272
- // Slow path: read → transform → PUT with If-Match.
279
+ // Fallback path: read → transform → PUT with If-Match.
273
280
  const readResult = await client.readFile(path);
274
281
  if (readResult.text === null) {
275
282
  return err(`edit_file: "${path}" appears to be binary — cannot do text replacement.`);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-viewer-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "MCP filesystem adapter for wiki-viewer agent API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import type { Metadata } from "next";
1
+ import type { Metadata, Viewport } from "next";
2
2
  import { Inter } from "next/font/google";
3
3
  import "./globals.css";
4
4
  import { Toaster } from "sonner";
@@ -9,6 +9,20 @@ const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
9
9
  export const metadata: Metadata = {
10
10
  title: "Wiki Viewer",
11
11
  description: "Local file browser, viewer, and editor",
12
+ manifest: "/manifest.webmanifest",
13
+ appleWebApp: {
14
+ capable: true,
15
+ title: "Wiki",
16
+ statusBarStyle: "black-translucent",
17
+ },
18
+ icons: {
19
+ icon: "/icon-192.png",
20
+ apple: "/icon-192.png",
21
+ },
22
+ };
23
+
24
+ export const viewport: Viewport = {
25
+ themeColor: "#0c0a09",
12
26
  };
13
27
 
14
28
  export default function RootLayout({
@@ -0,0 +1,30 @@
1
+ import type { MetadataRoute } from "next";
2
+
3
+ /**
4
+ * Web app manifest. Makes iOS/Android "Add to Home Screen" install a real
5
+ * standalone PWA (display: standalone) with persistent storage, instead of a
6
+ * plain bookmark. Without this, iOS treats the shortcut as ephemeral and evicts
7
+ * its cookie jar, forcing re-login on every reopen.
8
+ */
9
+ export default function manifest(): MetadataRoute.Manifest {
10
+ return {
11
+ name: "Wiki Viewer",
12
+ short_name: "Wiki",
13
+ description: "Local file browser, viewer, and editor",
14
+ start_url: "/",
15
+ scope: "/",
16
+ display: "standalone",
17
+ background_color: "#0c0a09",
18
+ theme_color: "#0c0a09",
19
+ icons: [
20
+ { src: "/icon-192.png", sizes: "192x192", type: "image/png", purpose: "any" },
21
+ { src: "/icon-512.png", sizes: "512x512", type: "image/png", purpose: "any" },
22
+ {
23
+ src: "/icon-maskable-512.png",
24
+ sizes: "512x512",
25
+ type: "image/png",
26
+ purpose: "maskable",
27
+ },
28
+ ],
29
+ };
30
+ }