greprag 5.48.0 → 5.49.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 (37) hide show
  1. package/dist/commands/checkpoint-helpers.js +6 -1
  2. package/dist/commands/checkpoint-helpers.js.map +1 -1
  3. package/dist/commands/crush.d.ts +9 -0
  4. package/dist/commands/crush.js +39 -0
  5. package/dist/commands/crush.js.map +1 -1
  6. package/dist/commands/fix.js +7 -3
  7. package/dist/commands/fix.js.map +1 -1
  8. package/dist/commands/init.js +47 -49
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/commands/opencode-relay.d.ts +14 -8
  11. package/dist/commands/opencode-relay.js +15 -19
  12. package/dist/commands/opencode-relay.js.map +1 -1
  13. package/dist/commands/watcher-registry.js +4 -2
  14. package/dist/commands/watcher-registry.js.map +1 -1
  15. package/dist/crush/code-compressor.d.ts +61 -0
  16. package/dist/crush/code-compressor.js +359 -0
  17. package/dist/crush/code-compressor.js.map +1 -0
  18. package/dist/crush/crush-types.d.ts +1 -1
  19. package/dist/crush/index.d.ts +1 -0
  20. package/dist/crush/index.js +6 -1
  21. package/dist/crush/index.js.map +1 -1
  22. package/dist/index.js +8 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/opencode-plugin-crush.d.ts +137 -0
  25. package/dist/opencode-plugin-crush.js +278 -0
  26. package/dist/opencode-plugin-crush.js.map +1 -0
  27. package/dist/opencode-plugin.bundle.js +2447 -0
  28. package/dist/opencode-plugin.d.ts +6 -0
  29. package/dist/opencode-plugin.js +124 -72
  30. package/dist/opencode-plugin.js.map +1 -1
  31. package/dist/session-id.d.ts +9 -0
  32. package/dist/session-id.js +15 -0
  33. package/dist/session-id.js.map +1 -1
  34. package/dist/worktree-state.js +5 -5
  35. package/dist/worktree-state.js.map +1 -1
  36. package/package.json +3 -2
  37. package/scripts/bundle-opencode-plugin.mjs +54 -0
@@ -0,0 +1,54 @@
1
+ /**
2
+ * bundle-opencode-plugin.mjs — produce the SINGLE self-contained opencode
3
+ * plugin artifact.
4
+ *
5
+ * WHY THIS EXISTS — opencode auto-loads every `.js` in
6
+ * `~/.config/opencode/plugins/` as a plugin, so greprag deploys exactly ONE
7
+ * file there: `greprag-memory.js`. A single deployed file cannot resolve a
8
+ * relative `require('./X')` under opencode's Bun loader, so for a long time the
9
+ * plugin loaded its internal deps (helpers → proc → crush engine) by ABSOLUTE
10
+ * path from `~/.greprag/`. Every new dep was a fresh chance to forget to deploy
11
+ * it — the `./proc` and `./crush` traps both shipped that way. This bundle kills
12
+ * the class: esbuild inlines `opencode-plugin.ts` + all its pure-JS internal
13
+ * deps into one file with zero sidecar requires (only Node builtins stay
14
+ * external, which Bun provides). The CLI itself is NOT bundled — the turn-capture
15
+ * daemon is the installed `greprag` binary spawned BY NAME, never required in.
16
+ *
17
+ * EXPORT CONTRACT — the source ends with `export = { id, server }`; esbuild
18
+ * compiles that to a clean `module.exports = { id, server }` with NO
19
+ * `__esModule` marker, which is exactly the shape opencode's `await import()`
20
+ * loader expects (`mod.default === { id, server }`). See
21
+ * adr/opencode-monitor-relay.md 2026-06-06 (f) for why the marker is fatal, and
22
+ * tests/test-opencode-bundle.cjs for the regression guard on that contract.
23
+ *
24
+ * adr: adr/opencode-monitor-relay.md (2026-06-20 bundle entry)
25
+ * adr: adr/opencode-context-compressor.md (2026-06-20 bundle entry)
26
+ */
27
+ import { build } from 'esbuild';
28
+ import { fileURLToPath } from 'url';
29
+ import path from 'path';
30
+
31
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
32
+ const cliRoot = path.resolve(__dirname, '..');
33
+
34
+ await build({
35
+ entryPoints: [path.join(cliRoot, 'src', 'opencode-plugin.ts')],
36
+ outfile: path.join(cliRoot, 'dist', 'opencode-plugin.bundle.js'),
37
+ bundle: true,
38
+ platform: 'node',
39
+ // CommonJS so `export = { id, server }` → `module.exports = { id, server }`
40
+ // with no `__esModule` marker. opencode loads via `await import()`; a CJS
41
+ // module with no marker exposes `mod.default === module.exports` — the V1
42
+ // plugin object the loader's `readV1Plugin` reads.
43
+ format: 'cjs',
44
+ target: 'node18',
45
+ // No npm deps are reachable from the plugin's import graph (helpers/proc/crush
46
+ // are all pure local code; the crush engine is dep-free by design). Node
47
+ // builtins (fs, os, path, crypto, child_process, stream) stay external — Bun
48
+ // provides them. So nothing else needs externalizing; an unexpected external
49
+ // dep here would surface as an esbuild resolution error, which is the signal.
50
+ legalComments: 'none',
51
+ logLevel: 'warning',
52
+ });
53
+
54
+ console.log(' Bundled opencode plugin → packages/cli/dist/opencode-plugin.bundle.js (self-contained, zero sidecar requires)');