@gramatr/mcp 0.8.8 → 0.8.10

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 (60) hide show
  1. package/dist/bin/build-mcpb.d.ts +8 -2
  2. package/dist/bin/build-mcpb.d.ts.map +1 -1
  3. package/dist/bin/build-mcpb.js +7 -7
  4. package/dist/bin/build-mcpb.js.map +1 -1
  5. package/dist/bin/gramatr-mcp.d.ts.map +1 -1
  6. package/dist/bin/gramatr-mcp.js +10 -2
  7. package/dist/bin/gramatr-mcp.js.map +1 -1
  8. package/dist/bin/setup.d.ts +1 -1
  9. package/dist/bin/setup.d.ts.map +1 -1
  10. package/dist/bin/setup.js +8 -22
  11. package/dist/bin/setup.js.map +1 -1
  12. package/dist/hooks/generated/hook-timeouts.d.ts +13 -1
  13. package/dist/hooks/generated/hook-timeouts.d.ts.map +1 -1
  14. package/dist/hooks/generated/hook-timeouts.js +13 -1
  15. package/dist/hooks/generated/hook-timeouts.js.map +1 -1
  16. package/dist/hooks/generated/schema-constants.d.ts +23 -9
  17. package/dist/hooks/generated/schema-constants.d.ts.map +1 -1
  18. package/dist/hooks/generated/schema-constants.js +26 -9
  19. package/dist/hooks/generated/schema-constants.js.map +1 -1
  20. package/dist/hooks/input-validator.d.ts +5 -0
  21. package/dist/hooks/input-validator.d.ts.map +1 -1
  22. package/dist/hooks/input-validator.js +113 -1
  23. package/dist/hooks/input-validator.js.map +1 -1
  24. package/dist/hooks/lib/gramatr-hook-utils.d.ts.map +1 -1
  25. package/dist/hooks/lib/gramatr-hook-utils.js +2 -2
  26. package/dist/hooks/lib/gramatr-hook-utils.js.map +1 -1
  27. package/dist/hooks/lib/hook-state.d.ts.map +1 -1
  28. package/dist/hooks/lib/hook-state.js +29 -28
  29. package/dist/hooks/lib/hook-state.js.map +1 -1
  30. package/dist/hooks/lib/routing.js +1 -1
  31. package/dist/hooks/lib/routing.js.map +1 -1
  32. package/dist/hooks/lib/types.d.ts +0 -1
  33. package/dist/hooks/lib/types.d.ts.map +1 -1
  34. package/dist/hooks/user-prompt-submit.js +1 -1
  35. package/dist/hooks/user-prompt-submit.js.map +1 -1
  36. package/dist/proxy/remote-client.d.ts.map +1 -1
  37. package/dist/proxy/remote-client.js +2 -1
  38. package/dist/proxy/remote-client.js.map +1 -1
  39. package/dist/setup/examples/gramatr-opencode-plugin.js +5 -5
  40. package/dist/setup/examples/gramatr-opencode-plugin.js.map +1 -1
  41. package/dist/setup/generated/instruction-blocks.d.ts +27 -0
  42. package/dist/setup/generated/instruction-blocks.d.ts.map +1 -0
  43. package/dist/setup/generated/instruction-blocks.js +27 -0
  44. package/dist/setup/generated/instruction-blocks.js.map +1 -0
  45. package/dist/setup/generated/platform-hooks.d.ts +2 -1
  46. package/dist/setup/generated/platform-hooks.d.ts.map +1 -1
  47. package/dist/setup/generated/platform-hooks.js +101 -22
  48. package/dist/setup/generated/platform-hooks.js.map +1 -1
  49. package/dist/setup/instructions.d.ts.map +1 -1
  50. package/dist/setup/instructions.js +9 -46
  51. package/dist/setup/instructions.js.map +1 -1
  52. package/dist/setup/integrations.d.ts.map +1 -1
  53. package/dist/setup/integrations.js +4 -3
  54. package/dist/setup/integrations.js.map +1 -1
  55. package/dist/setup/targets.d.ts +3 -3
  56. package/dist/setup/targets.d.ts.map +1 -1
  57. package/dist/setup/targets.js +8 -9
  58. package/dist/setup/targets.js.map +1 -1
  59. package/package.json +3 -2
  60. package/scripts/postinstall.mjs +49 -97
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gramatr/mcp",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "description": "grāmatr — Intelligence middleware for AI agents. Pre-classifies every request, injects relevant memory and behavioral context, enforces data quality, and maintains session continuity across Claude, ChatGPT, Codex, Cursor, Gemini, and any MCP-compatible client.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -52,7 +52,8 @@
52
52
  "LICENSE"
53
53
  ],
54
54
  "dependencies": {
55
- "@modelcontextprotocol/sdk": "^1.12.0"
55
+ "@modelcontextprotocol/sdk": "^1.12.0",
56
+ "better-sqlite3": "^12.9.0"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@types/better-sqlite3": "^7.6.13",
@@ -1,115 +1,67 @@
1
1
  /**
2
- * postinstall.mjs — Auto-download the pre-compiled gramatr binary for the user's platform.
2
+ * postinstall.mjs — Auto-detect and configure local AI clients.
3
3
  *
4
- * Runs on `npm install @gramatr/client`. Detects platform + arch, downloads
5
- * the matching binary from the GitHub Release, and installs it to
6
- * ~/.gramatr/bin/gramatr.
4
+ * Runs on `npm install -g @gramatr/mcp`. Detects installed AI clients
5
+ * (Claude Code, Codex, Gemini CLI, etc.), configures them automatically,
6
+ * and prints a link for web/app setup.
7
7
  *
8
8
  * Design constraints:
9
- * - Pure Node.js (no external dependencies, no bun)
10
- * - Node 18+ (native fetch)
11
- * - Graceful failure: logs a warning but always exits 0
12
- * - ISC-A: npm install must not fail if GitHub is unreachable
9
+ * - Pure Node.js (no external dependencies)
10
+ * - Graceful failure: always exits 0
11
+ * - Non-interactive in CI (no prompts)
13
12
  */
14
13
 
15
- import { createWriteStream } from "node:fs";
16
- import { chmod, mkdir, rename, unlink } from "node:fs/promises";
14
+ import { execSync } from "node:child_process";
15
+ import { mkdir } from "node:fs/promises";
17
16
  import { homedir } from "node:os";
18
- import { dirname, join } from "node:path";
19
- import { pipeline } from "node:stream/promises";
20
- import { Readable } from "node:stream";
21
- import { createRequire } from "node:module";
17
+ import { join } from "node:path";
22
18
  import { fileURLToPath } from "node:url";
19
+ import { dirname } from "node:path";
23
20
 
24
- // Download from the PUBLIC repo (gramatr/mcp), not the private monorepo (gramatr/gramatr).
25
- const GITHUB_RELEASE_BASE =
26
- "https://github.com/gramatr/mcp/releases/download";
27
-
28
- /** Map (platform, arch) to the binary asset name. */
29
- function getBinaryName(platform, arch) {
30
- const map = {
31
- "linux-x64": "gramatr-linux-x64",
32
- "linux-arm64": "gramatr-linux-arm64",
33
- "darwin-x64": "gramatr-darwin-x64",
34
- "darwin-arm64": "gramatr-darwin-arm64",
35
- "win32-x64": "gramatr-windows-x64.exe",
36
- };
37
-
38
- const key = `${platform}-${arch}`;
39
- return map[key] ?? null;
40
- }
21
+ async function main() {
22
+ const home = homedir();
23
+ const gramatrDir = join(home, ".gramatr");
24
+ await mkdir(gramatrDir, { recursive: true });
41
25
 
42
- /** Read version from the package's own package.json. */
43
- function getVersion() {
26
+ // Resolve the gramatr-mcp entry point relative to this script
44
27
  const __dirname = dirname(fileURLToPath(import.meta.url));
45
- const require = createRequire(import.meta.url);
46
- const pkg = require(join(__dirname, "..", "package.json"));
47
- return pkg.version;
48
- }
28
+ const entrypoint = join(__dirname, "..", "dist", "bin", "gramatr-mcp.js");
49
29
 
50
- /** Download a file from `url` to `dest`, following redirects (fetch handles them). */
51
- async function downloadBinary(url, dest) {
52
- const response = await fetch(url, { redirect: "follow" });
53
-
54
- if (!response.ok) {
55
- throw new Error(
56
- `Download failed: HTTP ${response.status} ${response.statusText}`,
57
- );
58
- }
59
-
60
- const tempDest = `${dest}.tmp`;
61
- const body = Readable.fromWeb(response.body);
62
- const fileStream = createWriteStream(tempDest);
30
+ console.log("");
31
+ console.log(" ┌─────────────────────────────────────────────┐");
32
+ console.log(" │ grāmatr AI Intelligence Layer installed │");
33
+ console.log(" └─────────────────────────────────────────────┘");
34
+ console.log("");
63
35
 
36
+ // Auto-detect and configure local clients
64
37
  try {
65
- await pipeline(body, fileStream);
66
- await rename(tempDest, dest);
67
- } catch (err) {
68
- // Clean up partial download
69
- await unlink(tempDest).catch(() => {});
70
- throw err;
71
- }
72
- }
73
-
74
- async function main() {
75
- const platform = process.platform;
76
- const arch = process.arch;
77
-
78
- const binaryName = getBinaryName(platform, arch);
79
- if (!binaryName) {
80
- console.warn(
81
- `[gramatr] Unsupported platform: ${platform}-${arch}. ` +
82
- "Skipping binary download. You can install manually from " +
83
- "https://github.com/gramatr/gramatr/releases",
84
- );
85
- return;
86
- }
87
-
88
- const version = getVersion();
89
- const url = `${GITHUB_RELEASE_BASE}/v${version}/${binaryName}`;
90
-
91
- const installDir = join(homedir(), ".gramatr", "bin");
92
- const isWindows = platform === "win32";
93
- const installPath = join(installDir, isWindows ? "gramatr.exe" : "gramatr");
94
-
95
- console.log(`[gramatr] Downloading ${binaryName} v${version}...`);
96
-
97
- await mkdir(installDir, { recursive: true });
98
- await downloadBinary(url, installPath);
99
-
100
- if (!isWindows) {
101
- await chmod(installPath, 0o755);
38
+ execSync(`node "${entrypoint}" setup auto --yes`, {
39
+ stdio: "inherit",
40
+ timeout: 30000,
41
+ });
42
+ } catch {
43
+ // Setup failed or timed out — print manual instructions
44
+ console.log(" [gramatr] Auto-setup skipped. Configure manually:");
45
+ console.log(" npx @gramatr/mcp setup claude # Claude Code");
46
+ console.log(" npx @gramatr/mcp setup codex # OpenAI Codex");
47
+ console.log(" npx @gramatr/mcp setup auto # Detect all clients");
102
48
  }
103
49
 
104
- console.log(`[gramatr] Installed to ${installPath}`);
50
+ console.log("");
51
+ console.log(" ── Next steps ──────────────────────────────────");
52
+ console.log("");
53
+ console.log(" Local clients (configured above):");
54
+ console.log(" Restart your AI client to activate gramatr.");
55
+ console.log("");
56
+ console.log(" Web & app clients:");
57
+ console.log(" https://gramatr.com/setup");
58
+ console.log("");
59
+ console.log(" Claude Web / ChatGPT / Gemini — paste your");
60
+ console.log(" prompt or connect the MCP add-on.");
61
+ console.log("");
62
+ console.log(" Verify installation:");
63
+ console.log(" npx @gramatr/mcp setup verify");
64
+ console.log("");
105
65
  }
106
66
 
107
- main().catch((err) => {
108
- console.warn(
109
- `[gramatr] Binary download failed: ${err.message}. ` +
110
- "This is non-fatal — you can install manually from " +
111
- "https://github.com/gramatr/gramatr/releases",
112
- );
113
- // Always exit 0 — never break npm install
114
- process.exit(0);
115
- });
67
+ main().catch(() => process.exit(0));