opencode-ipynb 0.1.2 → 2.0.0

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 (126) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +191 -41
  3. package/dist/domain/cell.d.ts +2 -1
  4. package/dist/domain/errors.d.ts +3 -31
  5. package/dist/domain/execution.d.ts +4 -1
  6. package/dist/domain/notebook.d.ts +1 -1
  7. package/dist/domain/output.d.ts +0 -1
  8. package/dist/format/diagnostics.d.ts +0 -1
  9. package/dist/format/markdown.d.ts +1 -2
  10. package/dist/format/{diff.d.ts → notebook.d.ts} +2 -1
  11. package/dist/format/outputs.d.ts +3 -2
  12. package/dist/index.d.ts +3 -1
  13. package/dist/index.js +7303 -26413
  14. package/dist/load-document.d.ts +16 -0
  15. package/dist/lsp.d.ts +97 -0
  16. package/dist/lsp.js +129 -0
  17. package/dist/notebook-diagnostics.d.ts +55 -0
  18. package/dist/notebook-hooks.d.ts +23 -0
  19. package/dist/plugin-options.d.ts +4 -1
  20. package/dist/plugin-v2.d.ts +35 -0
  21. package/dist/plugin.d.ts +2 -3
  22. package/dist/registrations.d.ts +5 -0
  23. package/dist/rpc.d.ts +141 -0
  24. package/dist/rpc.js +84 -0
  25. package/dist/services/KernelManager.d.ts +36 -0
  26. package/dist/services/NotebookCleanService.d.ts +3 -7
  27. package/dist/services/NotebookEditService.d.ts +6 -12
  28. package/dist/services/NotebookExecutionService.d.ts +15 -11
  29. package/dist/services/NotebookExportService.d.ts +3 -7
  30. package/dist/services/NotebookFileService.d.ts +19 -13
  31. package/dist/services/NotebookInspectService.d.ts +15 -14
  32. package/dist/services/NotebookOutputService.d.ts +4 -10
  33. package/dist/services/NotebookReadService.d.ts +4 -10
  34. package/dist/services/PathService.d.ts +5 -7
  35. package/dist/services/PermissionService.d.ts +6 -8
  36. package/dist/services/PythonService.d.ts +23 -42
  37. package/dist/services/index.d.ts +22 -29
  38. package/dist/services/revision.d.ts +15 -0
  39. package/dist/tool.d.ts +66 -0
  40. package/dist/tools/_readPermission.d.ts +8 -0
  41. package/dist/tools/_resolveOptions.d.ts +13 -2
  42. package/dist/tools/cell_delete.d.ts +4 -13
  43. package/dist/tools/cell_insert.d.ts +10 -21
  44. package/dist/tools/cell_move.d.ts +5 -15
  45. package/dist/tools/clean.d.ts +8 -21
  46. package/dist/tools/doctor.d.ts +3 -11
  47. package/dist/tools/edit.d.ts +10 -21
  48. package/dist/tools/export.d.ts +12 -23
  49. package/dist/tools/inspect.d.ts +7 -19
  50. package/dist/tools/kernel.d.ts +13 -21
  51. package/dist/tools/lsp.d.ts +9 -0
  52. package/dist/tools/outputs.d.ts +15 -29
  53. package/dist/tools/read.d.ts +12 -29
  54. package/dist/tools/repro.d.ts +6 -14
  55. package/dist/tools/run.d.ts +17 -34
  56. package/dist/utils/ansi.d.ts +2 -1
  57. package/dist/utils/atomic-replace.d.ts +6 -0
  58. package/dist/utils/attachments.d.ts +2 -3
  59. package/dist/utils/execution-order.d.ts +8 -0
  60. package/dist/utils/fence.d.ts +2 -0
  61. package/dist/utils/i18n.d.ts +1 -2
  62. package/dist/utils/imports.d.ts +6 -1
  63. package/dist/utils/json.d.ts +0 -1
  64. package/dist/utils/limits.d.ts +12 -2
  65. package/dist/utils/markdown-safe.d.ts +7 -0
  66. package/dist/utils/metadata.d.ts +3 -0
  67. package/dist/utils/mime.d.ts +1 -1
  68. package/dist/utils/paths.d.ts +0 -2
  69. package/dist/utils/truncate.d.ts +0 -1
  70. package/dist/utils/windows.d.ts +4 -0
  71. package/dist/virtual-materialize.d.ts +36 -0
  72. package/package.json +30 -18
  73. package/python/ipynb_runner.py +247 -17
  74. package/python/requirements.txt +5 -4
  75. package/server.js +3 -0
  76. package/dist/domain/cell.d.ts.map +0 -1
  77. package/dist/domain/errors.d.ts.map +0 -1
  78. package/dist/domain/execution.d.ts.map +0 -1
  79. package/dist/domain/notebook.d.ts.map +0 -1
  80. package/dist/domain/output.d.ts.map +0 -1
  81. package/dist/format/diagnostics.d.ts.map +0 -1
  82. package/dist/format/diff.d.ts.map +0 -1
  83. package/dist/format/markdown.d.ts.map +0 -1
  84. package/dist/format/outputs.d.ts.map +0 -1
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/plugin-options.d.ts.map +0 -1
  87. package/dist/plugin.d.ts.map +0 -1
  88. package/dist/services/DiffService.d.ts +0 -17
  89. package/dist/services/DiffService.d.ts.map +0 -1
  90. package/dist/services/NotebookCleanService.d.ts.map +0 -1
  91. package/dist/services/NotebookEditService.d.ts.map +0 -1
  92. package/dist/services/NotebookExecutionService.d.ts.map +0 -1
  93. package/dist/services/NotebookExportService.d.ts.map +0 -1
  94. package/dist/services/NotebookFileService.d.ts.map +0 -1
  95. package/dist/services/NotebookInspectService.d.ts.map +0 -1
  96. package/dist/services/NotebookOutputService.d.ts.map +0 -1
  97. package/dist/services/NotebookReadService.d.ts.map +0 -1
  98. package/dist/services/PathService.d.ts.map +0 -1
  99. package/dist/services/PermissionService.d.ts.map +0 -1
  100. package/dist/services/PythonService.d.ts.map +0 -1
  101. package/dist/services/index.d.ts.map +0 -1
  102. package/dist/tools/_resolveOptions.d.ts.map +0 -1
  103. package/dist/tools/cell_delete.d.ts.map +0 -1
  104. package/dist/tools/cell_insert.d.ts.map +0 -1
  105. package/dist/tools/cell_move.d.ts.map +0 -1
  106. package/dist/tools/clean.d.ts.map +0 -1
  107. package/dist/tools/doctor.d.ts.map +0 -1
  108. package/dist/tools/edit.d.ts.map +0 -1
  109. package/dist/tools/export.d.ts.map +0 -1
  110. package/dist/tools/inspect.d.ts.map +0 -1
  111. package/dist/tools/kernel.d.ts.map +0 -1
  112. package/dist/tools/outputs.d.ts.map +0 -1
  113. package/dist/tools/read.d.ts.map +0 -1
  114. package/dist/tools/repro.d.ts.map +0 -1
  115. package/dist/tools/run.d.ts.map +0 -1
  116. package/dist/utils/ansi.d.ts.map +0 -1
  117. package/dist/utils/attachments.d.ts.map +0 -1
  118. package/dist/utils/fiber.d.ts +0 -2
  119. package/dist/utils/fiber.d.ts.map +0 -1
  120. package/dist/utils/i18n.d.ts.map +0 -1
  121. package/dist/utils/imports.d.ts.map +0 -1
  122. package/dist/utils/json.d.ts.map +0 -1
  123. package/dist/utils/limits.d.ts.map +0 -1
  124. package/dist/utils/mime.d.ts.map +0 -1
  125. package/dist/utils/paths.d.ts.map +0 -1
  126. package/dist/utils/truncate.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "opencode-ipynb",
3
- "version": "0.1.2",
3
+ "version": "2.0.0",
4
4
  "description": "OpenCode community plugin that adds robust .ipynb (Jupyter Notebook) support: inspect, read, edit, run, outputs, clean, export, reproducibility reports, and warm kernels.",
5
5
  "type": "module",
6
- "packageManager": "bun@1.3.13",
6
+ "packageManager": "bun@1.4.4",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
@@ -11,7 +11,16 @@
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
13
13
  "import": "./dist/index.js"
14
- }
14
+ },
15
+ "./lsp": {
16
+ "types": "./dist/lsp.d.ts",
17
+ "import": "./dist/lsp.js"
18
+ },
19
+ "./rpc": {
20
+ "types": "./dist/rpc.d.ts",
21
+ "import": "./dist/rpc.js"
22
+ },
23
+ "./server.js": "./server.js"
15
24
  },
16
25
  "repository": {
17
26
  "type": "git",
@@ -23,23 +32,28 @@
23
32
  },
24
33
  "files": [
25
34
  "dist",
35
+ "server.js",
26
36
  "python/ipynb_runner.py",
27
37
  "python/requirements.txt",
28
38
  "README.md",
29
- "LICENSE"
39
+ "LICENSE",
40
+ "CHANGELOG.md"
30
41
  ],
31
42
  "publishConfig": {
32
43
  "access": "public"
33
44
  },
34
45
  "engines": {
35
- "bun": ">=1.3.0"
46
+ "bun": ">=1.4.4"
36
47
  },
37
48
  "scripts": {
38
49
  "typecheck": "tsc --noEmit",
39
- "build": "bun build src/index.ts --target=bun --outdir=dist && tsc --emitDeclarationOnly --outDir dist",
50
+ "typecheck:tests": "tsc -p tsconfig.test.json",
51
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && bun build src/index.ts --target=bun --outdir=dist --external effect --external \"effect/*\" && bun build src/lsp.ts --target=bun --outdir=dist --external effect --external \"effect/*\" && bun build src/rpc.ts --target=bun --outdir=dist --external effect --external \"effect/*\" && tsc --emitDeclarationOnly --outDir dist",
40
52
  "test": "bun test",
41
53
  "lint:effect": "tsc --noEmit",
42
- "prepare:effect-lsp": "effect-language-service patch"
54
+ "prepare:effect-lsp": "effect-language-service patch",
55
+ "prepack": "node -e \"for (const f of ['dist/index.js','dist/index.d.ts','dist/lsp.js','dist/lsp.d.ts','dist/rpc.js','dist/rpc.d.ts']) if (!require('node:fs').existsSync(f)) { console.error(f + ' is missing; run: bun run build'); process.exit(1) }\"",
56
+ "test:coverage": "bun test --coverage"
43
57
  },
44
58
  "keywords": [
45
59
  "opencode",
@@ -52,18 +66,16 @@
52
66
  ],
53
67
  "license": "MIT",
54
68
  "peerDependencies": {
55
- "@opencode-ai/plugin": ">=0.0.0"
56
- },
57
- "dependencies": {
58
- "@opencode-ai/plugin": "latest",
59
- "diff": "^7.0.0",
60
- "effect": "^3.10.0",
61
- "zod": "4"
69
+ "@opencode/plugin": "^2.2.2",
70
+ "effect": "^4.0.0"
62
71
  },
72
+ "dependencies": {},
63
73
  "devDependencies": {
64
- "@effect/language-service": "^0.86.2",
65
- "@types/bun": "latest",
66
- "@types/diff": "7.0.0",
67
- "typescript": "^5.6.0"
74
+ "@effect/language-service": "^0.87.5",
75
+ "@opencode/plugin": "^2.2.2",
76
+ "@types/bun": "^1.4.4",
77
+ "effect": "4.0.6",
78
+ "typescript": "^5.6.0",
79
+ "zod": "4"
68
80
  }
69
81
  }
@@ -1,4 +1,4 @@
1
- """Real notebook runner for the opencode-ipynb plugin (v0.3 + v0.4 + v1.0).
1
+ """Real notebook runner for the opencode-ipynb plugin.
2
2
 
3
3
  Reads a JSON request from stdin and writes a JSON response to stdout. Modes:
4
4
 
@@ -7,7 +7,7 @@ Reads a JSON request from stdin and writes a JSON response to stdout. Modes:
7
7
  - ``env``: read the notebook's kernelspec / language_info, dump the
8
8
  current Python interpreter version + executable + platform, and run
9
9
  ``pip freeze --local``. Does NOT require nbformat / nbclient.
10
- - ``serve`` (v1.0, warm-kernel mode): enter a long-lived loop. The first
10
+ - ``serve`` (warm-kernel mode): enter a long-lived loop. The first
11
11
  request carries ``filePath`` (and optional ``kernel`` / ``timeoutMs``);
12
12
  subsequent requests are normal ``cell`` / ``all`` / ``range`` / ``from``
13
13
  / ``env`` requests. Each request has an integer ``id``; the response
@@ -23,10 +23,16 @@ venv still produces a structured error instead of a traceback.
23
23
 
24
24
  from __future__ import annotations
25
25
 
26
+ MAX_ERROR_TEXT = 8_000
27
+ MAX_RAW_OUTPUT_BYTES = 32 * 1024 * 1024
28
+ MAX_RAW_OUTPUT_TOTAL_BYTES = 48 * 1024 * 1024
29
+
26
30
  import json
27
31
  import os
32
+ import signal
28
33
  import subprocess
29
34
  import sys
35
+ import tempfile
30
36
  import time
31
37
  import traceback
32
38
  from typing import Any, Dict, Iterable, List, Optional
@@ -34,6 +40,14 @@ from typing import Any, Dict, Iterable, List, Optional
34
40
 
35
41
  PROBE_DEPS = ("nbformat", "nbclient", "jupyter_client", "ipykernel")
36
42
 
43
+ # Windows redirected stdio often uses the locale code page; requests and
44
+ # responses are UTF-8 JSON, so force it explicitly.
45
+ for _stream in (sys.stdin, sys.stdout, sys.stderr):
46
+ try:
47
+ _stream.reconfigure(encoding="utf-8", errors="strict")
48
+ except Exception:
49
+ pass
50
+
37
51
 
38
52
  def _read_request() -> Dict[str, Any]:
39
53
  raw = sys.stdin.read()
@@ -83,10 +97,30 @@ def _read_notebook_raw(file_path: str) -> Dict[str, Any]:
83
97
  return data
84
98
 
85
99
 
100
+ PIP_FREEZE_CODE = (
101
+ "import sys; "
102
+ "sys.path[:] = [p for p in sys.path if p not in ('', '.')]; "
103
+ "from pip._internal.cli.main import main; "
104
+ "raise SystemExit(main(['freeze', '--local']))"
105
+ )
106
+
107
+
86
108
  def _run_pip_freeze(python_executable: str, timeout_s: int = 30) -> List[str]:
87
- """Run ``pip freeze --local`` and return a list of ``package==version`` strings."""
109
+ """Run ``pip freeze --local`` without importing project files.
110
+
111
+ ``python -m pip`` puts the current directory first on sys.path, so a
112
+ repository-supplied ``pip.py`` would execute during a read-only report.
113
+ Use ``-c`` plus explicit sys.path sanitation instead of ``-m``: this
114
+ keeps user-site pip available (unlike ``-I``) while removing the cwd
115
+ entries before pip is imported. ``-E`` drops PYTHONPATH/PYTHONHOME.
116
+ """
117
+ env = os.environ.copy()
118
+ env.pop("PYTHONPATH", None)
119
+ env.pop("PYTHONHOME", None)
88
120
  raw = subprocess.check_output(
89
- [python_executable, "-m", "pip", "freeze", "--local"],
121
+ [python_executable, "-E", "-c", PIP_FREEZE_CODE],
122
+ cwd=tempfile.gettempdir(),
123
+ env=env,
90
124
  stderr=subprocess.PIPE,
91
125
  timeout=timeout_s,
92
126
  )
@@ -94,6 +128,71 @@ def _run_pip_freeze(python_executable: str, timeout_s: int = 30) -> List[str]:
94
128
  return [line.strip() for line in text.splitlines() if line.strip()]
95
129
 
96
130
 
131
+ def _kernel_pid(client: Any) -> Optional[int]:
132
+ km = getattr(client, "km", None)
133
+ provisioner = getattr(km, "provisioner", None)
134
+ pid = getattr(provisioner, "pid", None)
135
+ if not isinstance(pid, int):
136
+ pid = getattr(km, "kernel_pid", None)
137
+ return pid if isinstance(pid, int) and pid > 0 else None
138
+
139
+
140
+ def _kill_kernel_process_group(client: Any) -> None:
141
+ """Kill the kernel and every process it started.
142
+
143
+ Jupyter starts the kernel in its own session, so killing the helper's
144
+ process group is not enough. The kernel is the leader of its own group.
145
+ """
146
+ pid = _kernel_pid(client)
147
+ if pid is None:
148
+ return
149
+ kill_signal = getattr(signal, "SIGKILL", signal.SIGTERM)
150
+ try:
151
+ if hasattr(os, "killpg") and hasattr(os, "getpgid"):
152
+ os.killpg(os.getpgid(pid), kill_signal)
153
+ else:
154
+ os.kill(pid, kill_signal)
155
+ except ProcessLookupError:
156
+ pass
157
+ except Exception:
158
+ try:
159
+ os.kill(pid, kill_signal)
160
+ except Exception:
161
+ pass
162
+
163
+
164
+ _ACTIVE_CLIENT: Any = None
165
+
166
+
167
+ def _handle_sigterm(signum: int, frame: Any) -> None:
168
+ """Best-effort cleanup when the wrapper aborts a one-shot/serve run."""
169
+ try:
170
+ if _ACTIVE_CLIENT is not None:
171
+ _kill_kernel_process_group(_ACTIVE_CLIENT)
172
+ finally:
173
+ os._exit(143)
174
+
175
+
176
+ signal.signal(signal.SIGTERM, _handle_sigterm)
177
+
178
+
179
+ def _kernel_env(req: Dict[str, Any]) -> Dict[str, str]:
180
+ """Environment for the notebook kernel only.
181
+
182
+ The helper process itself runs with PYTHONPATH/PYTHONHOME removed so a
183
+ project cannot shadow stdlib imports. The original values are carried in
184
+ the request and restored for the kernel, where user code is expected to
185
+ run with the environment the user configured.
186
+ """
187
+ env = {key: value for key, value in os.environ.items()}
188
+ extra = req.get("kernelEnv")
189
+ if isinstance(extra, dict):
190
+ for key, value in extra.items():
191
+ if isinstance(key, str) and isinstance(value, str):
192
+ env[key] = value
193
+ return env
194
+
195
+
97
196
  def _build_env_report(
98
197
  file_path: str,
99
198
  started: float,
@@ -204,7 +303,9 @@ def _select_cell_indexes(req: Dict[str, Any], total: int) -> List[int]:
204
303
  """Return the cell indexes (across the WHOLE notebook) the caller wants to run."""
205
304
  mode = req["mode"]
206
305
  if total <= 0:
207
- return []
306
+ if mode == "all":
307
+ return []
308
+ raise ValueError("notebook has no cells")
208
309
  if mode == "all":
209
310
  return list(range(total))
210
311
  if mode == "cell":
@@ -223,6 +324,10 @@ def _select_cell_indexes(req: Dict[str, Any], total: int) -> List[int]:
223
324
  raise ValueError("mode='range' requires integer start and end")
224
325
  if start < 0 or end < 0 or start > end:
225
326
  raise ValueError(f"invalid range start={start} end={end}")
327
+ if start >= total:
328
+ raise ValueError(
329
+ f"range start {start} out of range (notebook has {total} cells)"
330
+ )
226
331
  return list(range(start, min(end, total - 1) + 1))
227
332
  if mode == "from":
228
333
  idx = req.get("cellIndex")
@@ -297,6 +402,7 @@ def _build_cell_summary(
297
402
  status: str,
298
403
  max_output_chars: int,
299
404
  duration_ms: int,
405
+ include_raw: bool = False,
300
406
  ) -> Dict[str, Any]:
301
407
  summary: Dict[str, Any] = {
302
408
  "cellIndex": cell_index,
@@ -308,8 +414,15 @@ def _build_cell_summary(
308
414
  if ec is not None:
309
415
  summary["executionCount"] = int(ec)
310
416
  raw_outputs = list(cell.get("outputs", []) or [])
311
- if raw_outputs:
312
- summary["rawOutputs"] = raw_outputs
417
+ if raw_outputs and include_raw:
418
+ try:
419
+ encoded = json.dumps(raw_outputs)
420
+ except Exception:
421
+ encoded = ""
422
+ if len(encoded) <= MAX_RAW_OUTPUT_BYTES:
423
+ summary["rawOutputs"] = raw_outputs
424
+ else:
425
+ summary["rawOutputsOmitted"] = True
313
426
  for out in raw_outputs:
314
427
  addition = _summarize_output(out)
315
428
  _merge_summaries(summary, addition)
@@ -320,6 +433,19 @@ def _build_cell_summary(
320
433
  summary[key] = summary[key][:max_output_chars] + (
321
434
  f"\n... (truncated, use maxOutputChars to increase)"
322
435
  )
436
+ for err in summary.get("errors") or []:
437
+ for key in ("ename", "evalue"):
438
+ value = str(err.get(key) or "")
439
+ if len(value) > MAX_ERROR_TEXT:
440
+ err[key] = value[:MAX_ERROR_TEXT] + "\n... (truncated)"
441
+ else:
442
+ err[key] = value
443
+ tb = [str(line) for line in (err.get("traceback") or [])]
444
+ joined = "\n".join(tb)
445
+ if len(joined) > MAX_ERROR_TEXT:
446
+ err["traceback"] = [joined[:MAX_ERROR_TEXT] + "\n... (truncated)"]
447
+ else:
448
+ err["traceback"] = tb
323
449
  return summary
324
450
 
325
451
 
@@ -342,9 +468,12 @@ def _error_response(
342
468
  "error": {
343
469
  "kind": kind,
344
470
  "cellIndex": cell_index,
345
- "ename": ename,
346
- "evalue": evalue,
347
- "traceback": list(traceback_lines or []),
471
+ "ename": str(ename)[:MAX_ERROR_TEXT],
472
+ "evalue": str(evalue)[:MAX_ERROR_TEXT],
473
+ "traceback": [
474
+ line[:MAX_ERROR_TEXT]
475
+ for line in list(traceback_lines or [])[:200]
476
+ ],
348
477
  },
349
478
  }
350
479
  if request_id is not None:
@@ -365,6 +494,23 @@ def _resolve_kernel_name(req: Dict[str, Any], nb: Any) -> Optional[str]:
365
494
  return None
366
495
 
367
496
 
497
+ def _cap_raw_outputs(outputs: List[Dict[str, Any]]) -> None:
498
+ remaining = MAX_RAW_OUTPUT_TOTAL_BYTES
499
+ for summary in outputs:
500
+ raw = summary.get("rawOutputs")
501
+ if raw is None:
502
+ continue
503
+ try:
504
+ size = len(json.dumps(raw))
505
+ except Exception:
506
+ size = MAX_RAW_OUTPUT_TOTAL_BYTES + 1
507
+ if size > remaining:
508
+ summary.pop("rawOutputs", None)
509
+ summary["rawOutputsOmitted"] = True
510
+ else:
511
+ remaining -= size
512
+
513
+
368
514
  def _run_nbclient(
369
515
  req: Dict[str, Any],
370
516
  nb: Any,
@@ -422,10 +568,14 @@ def _run_nbclient(
422
568
  # into the kernel subprocess Popen call. Execute the selected cells
423
569
  # explicitly so mode=cell/range/from never runs cells outside the
424
570
  # requested slice.
425
- with client.setup_kernel():
571
+ global _ACTIVE_CLIENT
572
+ _ACTIVE_CLIENT = client
573
+ with client.setup_kernel(env=_kernel_env(req)):
426
574
  for idx in target_code_cells:
427
575
  client.execute_cell(nb.cells[idx], idx)
428
576
  except Exception as exc:
577
+ if type(exc).__name__ == "CellTimeoutError":
578
+ _kill_kernel_process_group(client)
429
579
  failing_cell_index = getattr(exc, "cell_index", None)
430
580
  if not isinstance(failing_cell_index, int) or failing_cell_index < 0:
431
581
  msg = str(exc)
@@ -461,18 +611,24 @@ def _run_nbclient(
461
611
  status="ok",
462
612
  max_output_chars=int(req.get("maxOutputChars", 12_000)),
463
613
  duration_ms=0,
614
+ include_raw=bool(req.get("save", False) or req.get("includeRawOutputs", False)),
464
615
  )
465
616
  )
466
617
 
618
+ _cap_raw_outputs(outputs)
467
619
  return {
468
620
  "success": True,
469
- "executedCells": cell_indexes,
621
+ "executedCells": target_code_cells,
470
622
  "durationMs": int((time.time() - started) * 1000),
471
623
  "saved": False,
472
624
  "outputs": outputs,
473
625
  }
474
626
 
475
627
 
628
+ class KernelBroken(Exception):
629
+ """Raised when a timed-out cell requires a fresh kernel."""
630
+
631
+
476
632
  def _run_serve_request(
477
633
  req: Dict[str, Any],
478
634
  client: Any,
@@ -511,6 +667,27 @@ def _run_serve_request(
511
667
  request_id=req_id,
512
668
  )
513
669
 
670
+ # A warm kernel keeps Python state, but the notebook source must follow
671
+ # edits on disk. Reload the cells before every request; the kernel client
672
+ # keeps its process and namespace, while the NotebookNode is refreshed.
673
+ try:
674
+ import nbformat # type: ignore
675
+
676
+ fresh = nbformat.read(file_path, as_version=4)
677
+ nb.cells = fresh.cells
678
+ nb.metadata = fresh.metadata
679
+ except Exception as exc:
680
+ return _error_response(
681
+ req,
682
+ started,
683
+ "PythonRunnerError",
684
+ type(exc).__name__,
685
+ f"Failed to reload notebook {file_path}: {exc}",
686
+ -1,
687
+ traceback.format_exception(exc),
688
+ request_id=req_id,
689
+ )
690
+
514
691
  if req["mode"] == "serve":
515
692
  return _error_response(
516
693
  req,
@@ -554,7 +731,7 @@ def _run_serve_request(
554
731
  if not target_code_cells:
555
732
  response = {
556
733
  "success": True,
557
- "executedCells": cell_indexes,
734
+ "executedCells": [],
558
735
  "durationMs": int((time.time() - started) * 1000),
559
736
  "outputs": [],
560
737
  }
@@ -563,6 +740,12 @@ def _run_serve_request(
563
740
  return response
564
741
 
565
742
  timeout_s = max(1, int(req.get("timeoutMs", 120_000) / 1000))
743
+ # The initial client timeout belongs to the first serve request. Update it
744
+ # per request so a short first call does not freeze every later timeout.
745
+ try:
746
+ client.timeout = timeout_s
747
+ except Exception:
748
+ pass
566
749
  # Per-cell durations: capture start/end around each `execute_cell` call so
567
750
  # the `cell_duration_ms` field reflects what actually happened, not the
568
751
  # batch total attributed to the first cell.
@@ -589,7 +772,7 @@ def _run_serve_request(
589
772
  break
590
773
  else:
591
774
  failing_cell_index = target_code_cells[0] if target_code_cells else -1
592
- return _error_response(
775
+ response = _error_response(
593
776
  req,
594
777
  started,
595
778
  "CellExecutionError",
@@ -599,6 +782,21 @@ def _run_serve_request(
599
782
  traceback.format_exception(exc),
600
783
  request_id=req_id,
601
784
  )
785
+ if type(exc).__name__ == "CellTimeoutError":
786
+ # nbclient leaves the cell running. Kill the kernel and its
787
+ # descendants so the next request starts clean instead of
788
+ # queueing behind a runaway cell.
789
+ _kill_kernel_process_group(client)
790
+ try:
791
+ client.shutdown_kernel()
792
+ except Exception:
793
+ pass
794
+ try:
795
+ client.cleanup_kernel()
796
+ except Exception:
797
+ pass
798
+ raise KernelBroken("kernel stopped after a cell timeout") from exc
799
+ return response
602
800
 
603
801
  outputs: List[Dict[str, Any]] = []
604
802
  for i in cell_indexes:
@@ -612,12 +810,14 @@ def _run_serve_request(
612
810
  status="ok",
613
811
  max_output_chars=int(req.get("maxOutputChars", 12_000)),
614
812
  duration_ms=cell_durations_ms.get(i, 0),
813
+ include_raw=bool(req.get("save", False) or req.get("includeRawOutputs", False)),
615
814
  )
616
815
  )
617
816
 
817
+ _cap_raw_outputs(outputs)
618
818
  response = {
619
819
  "success": True,
620
- "executedCells": cell_indexes,
820
+ "executedCells": target_code_cells,
621
821
  "durationMs": int((time.time() - started) * 1000),
622
822
  "outputs": outputs,
623
823
  }
@@ -627,7 +827,7 @@ def _run_serve_request(
627
827
 
628
828
 
629
829
  def _serve_mode(init_req: Dict[str, Any]) -> int:
630
- """v1.0 warm-kernel loop. Initializes one kernel and serves NDJSON
830
+ """Warm-kernel loop. Initializes one kernel and serves NDJSON
631
831
  requests until ``{"mode": "shutdown"}`` or EOF on stdin.
632
832
  """
633
833
  file_path = init_req.get("filePath")
@@ -698,10 +898,24 @@ def _serve_mode(init_req: Dict[str, Any]) -> int:
698
898
  # NOT use ``setup_kernel`` (a context manager) because we want the
699
899
  # kernel to outlive the first request — subsequent requests reuse
700
900
  # the same kernel client via ``client.execute_cell``.
901
+ global _ACTIVE_CLIENT
902
+ _ACTIVE_CLIENT = client
701
903
  client.km = client.create_kernel_manager()
702
- client.start_new_kernel()
904
+ client.start_new_kernel(env=_kernel_env(init_req))
703
905
  client.start_new_kernel_client()
704
906
  except Exception as exc:
907
+ # A kernel may already be running even though the client failed.
908
+ # Jupyter starts it in its own session, so the parent cannot reap it
909
+ # from the helper's process group.
910
+ try:
911
+ client.shutdown_kernel(now=True)
912
+ except Exception:
913
+ pass
914
+ try:
915
+ _kill_kernel_process_group(client)
916
+ except Exception:
917
+ pass
918
+ _ACTIVE_CLIENT = None
705
919
  _write_response(
706
920
  _error_response(
707
921
  init_req,
@@ -718,6 +932,7 @@ def _serve_mode(init_req: Dict[str, Any]) -> int:
718
932
  ready_response: Dict[str, Any] = {
719
933
  "ready": True,
720
934
  "pid": os.getpid(),
935
+ "kernelPid": _kernel_pid(client),
721
936
  "kernelName": kernel_name,
722
937
  "durationMs": int((time.time() - started) * 1000),
723
938
  }
@@ -764,6 +979,20 @@ def _serve_mode(init_req: Dict[str, Any]) -> int:
764
979
 
765
980
  try:
766
981
  response = _run_serve_request(req, client, nb, file_path)
982
+ except KernelBroken as exc:
983
+ req_id = req.get("id") if isinstance(req.get("id"), int) else None
984
+ _write_response(
985
+ _error_response(
986
+ req,
987
+ time.time(),
988
+ "PythonRunnerError",
989
+ "KernelRestartRequired",
990
+ str(exc),
991
+ -1,
992
+ request_id=req_id,
993
+ )
994
+ )
995
+ break
767
996
  except Exception as exc:
768
997
  req_id = req.get("id") if isinstance(req.get("id"), int) else None
769
998
  response = _error_response(
@@ -782,6 +1011,7 @@ def _serve_mode(init_req: Dict[str, Any]) -> int:
782
1011
  except KeyboardInterrupt:
783
1012
  return 0
784
1013
  finally:
1014
+ _kill_kernel_process_group(client)
785
1015
  try:
786
1016
  client.shutdown_kernel()
787
1017
  except Exception:
@@ -7,23 +7,24 @@
7
7
  # fast, reproducible, and respects the user's existing Python install.
8
8
  #
9
9
  # Preferred (uv):
10
- # uv pip install nbformat nbclient jupyter_client ipykernel
10
+ # uv pip install pip nbformat nbclient jupyter_client ipykernel
11
11
  # python -m ipykernel install --user
12
12
  #
13
13
  # Alternative (pip into a venv):
14
14
  # python -m venv .venv
15
15
  # source .venv/bin/activate # Windows: .venv\Scripts\activate
16
- # pip install nbformat nbclient jupyter_client ipykernel
16
+ # pip install pip nbformat nbclient jupyter_client ipykernel
17
17
  # python -m ipykernel install --user
18
18
  #
19
19
  # Alternative (conda):
20
- # conda install -c conda-forge nbformat nbclient jupyter_client ipykernel
20
+ # conda install -c conda-forge pip nbformat nbclient jupyter_client ipykernel
21
21
  #
22
22
  # If you have multiple Python interpreters, point the plugin at the right
23
23
  # one via either:
24
- # - opencode.json: { "ipynb": { "pythonPath": "C:/path/to/python.exe" } }
24
+ # - opencode.json: { "plugins": [{ "package": "opencode-ipynb", "options": { "pythonPath": "/path/to/python" } }] }
25
25
  # - env var: OPENCODE_IPYNB_PYTHON=C:/path/to/python.exe
26
26
 
27
+ pip>=23
27
28
  nbformat>=5.9
28
29
  nbclient>=0.9
29
30
  jupyter_client>=8.0
package/server.js ADDED
@@ -0,0 +1,3 @@
1
+ // OpenCode V2 resolves a local plugin directory by trying `<dir>/server` first.
2
+ // Keep this stable entrypoint at the package root and re-export the built plugin.
3
+ export { default } from "./dist/index.js"
@@ -1 +0,0 @@
1
- {"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../src/domain/cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,YAAY,6DAA6C,CAAA;AACtE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAA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"execution.d.ts","sourceRoot":"","sources":["../../src/domain/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,eAAe;;;;;;;;iBAQ1B,CAAA;AACF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,eAAO,MAAM,gBAAgB;;;;;;;;;;;iBAiB3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;iBA0BrC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgB5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/domain/notebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,eAAO,MAAM,gBAAgB;;;;iBAMb,CAAA;AAChB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD,eAAO,MAAM,kBAAkB;;iBAIf,CAAA;AAChB,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBAOnB,CAAA;AAChB,M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G,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAA;AAE/F,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,cAM/D,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/format/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAGhD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,CAAA;IACrC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACtB;AAKD,eAAO,MAAM,WAAW,GAAI,MAAM,OAAO,EAAE,OAAO,MAAM,KAAG,cAiG1D,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/format/diff.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,CAAA;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACnD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GAAG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ED,eAAO,MAAM,yBAAyB,GAAI,UAAU,WAAW,EAAE,UAAU,MAAM,KAAG,MA8BnF,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,KAAK,MAAM,KAAG,MAAsC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-options.d.ts","sourceRoot":"","sources":["../src/plugin-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,mBAAmB;;;;;;;;iBA8C9B,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,kBAAkB,GAC7B,KAAK,OAAO,EACZ,WAAU,OAAO,CAAC,aAAa,CAAM,KACpC,aAOF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAiBjD,QAAA,MAAM,MAAM,EAAE,MA8Bb,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -1,17 +0,0 @@
1
- import { Context, Effect } from "effect";
2
- import { diffLines } from "diff";
3
- export interface DiffServiceShape {
4
- readonly cellDiff: (oldSource: string, newSource: string) => string;
5
- readonly notebookJsonDiff: (oldJson: string, newJson: string, filePath: string) => string;
6
- }
7
- declare const DiffService_base: Context.TagClass<DiffService, "@ipynb/DiffService", DiffServiceShape>;
8
- export declare class DiffService extends DiffService_base {
9
- }
10
- export declare const makeDiffService: () => DiffServiceShape;
11
- export declare const _internal: {
12
- buildDiff: () => DiffServiceShape;
13
- diffLines: typeof diffLines;
14
- };
15
- export declare const _Effect: typeof Effect;
16
- export {};
17
- //# sourceMappingURL=DiffService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DiffService.d.ts","sourceRoot":"","sources":["../../src/services/DiffService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAuB,SAAS,EAAe,MAAM,MAAM,CAAA;AAElE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACnE,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CAC1F;;AAED,qBAAa,WAAY,SAAQ,gBAAkE;CAAG;AAiCtG,eAAO,MAAM,eAAe,QA/BN,gBA+BkB,CAAA;AAExC,eAAO,MAAM,SAAS;qBAjCA,gBAAgB;;CAiCW,CAAA;AACjD,eAAO,MAAM,OAAO,eAAS,CAAA"}