opencode-ipynb 0.1.2 → 3.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 (130) hide show
  1. package/CHANGELOG.md +187 -0
  2. package/README.md +197 -41
  3. package/dist/domain/cell.d.ts +4 -3
  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 +6 -3
  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} +1 -1
  11. package/dist/format/outputs.d.ts +2 -2
  12. package/dist/index.d.ts +3 -1
  13. package/dist/index.js +11294 -28152
  14. package/dist/load-document.d.ts +10 -0
  15. package/dist/lsp.d.ts +58 -0
  16. package/dist/lsp.js +172 -0
  17. package/dist/notebook-diagnostics.d.ts +52 -0
  18. package/dist/notebook-hooks.d.ts +18 -0
  19. package/dist/plugin-options.d.ts +4 -1
  20. package/dist/plugin-v2.d.ts +31 -0
  21. package/dist/plugin.d.ts +2 -3
  22. package/dist/registrations.d.ts +5 -0
  23. package/dist/rpc.d.ts +134 -0
  24. package/dist/rpc.js +84 -0
  25. package/dist/services/KernelManager.d.ts +45 -0
  26. package/dist/services/NotebookCleanService.d.ts +7 -7
  27. package/dist/services/NotebookEditService.d.ts +15 -12
  28. package/dist/services/NotebookExecutionService.d.ts +41 -12
  29. package/dist/services/NotebookExportService.d.ts +3 -7
  30. package/dist/services/NotebookFileService.d.ts +31 -16
  31. package/dist/services/NotebookInspectService.d.ts +15 -19
  32. package/dist/services/NotebookOutputService.d.ts +7 -10
  33. package/dist/services/NotebookReadService.d.ts +4 -10
  34. package/dist/services/PathService.d.ts +10 -8
  35. package/dist/services/PermissionService.d.ts +13 -8
  36. package/dist/services/PythonService.d.ts +14 -43
  37. package/dist/services/index.d.ts +23 -28
  38. package/dist/services/revision.d.ts +9 -0
  39. package/dist/tool.d.ts +45 -0
  40. package/dist/tools/_readPermission.d.ts +2 -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 +1 -1
  57. package/dist/utils/atomic-replace.d.ts +2 -0
  58. package/dist/utils/attachments.d.ts +2 -3
  59. package/dist/utils/execution-order.d.ts +7 -0
  60. package/dist/utils/fence.d.ts +1 -0
  61. package/dist/utils/i18n.d.ts +1 -2
  62. package/dist/utils/imports.d.ts +0 -1
  63. package/dist/utils/json-patch.d.ts +58 -0
  64. package/dist/utils/json.d.ts +16 -2
  65. package/dist/utils/limits.d.ts +11 -2
  66. package/dist/utils/markdown-safe.d.ts +2 -0
  67. package/dist/utils/metadata.d.ts +2 -0
  68. package/dist/utils/mime.d.ts +1 -1
  69. package/dist/utils/paths.d.ts +2 -2
  70. package/dist/utils/realpath.d.ts +1 -0
  71. package/dist/utils/rename-hook.d.ts +6 -0
  72. package/dist/utils/truncate.d.ts +0 -1
  73. package/dist/utils/warnings.d.ts +15 -0
  74. package/dist/utils/windows.d.ts +3 -0
  75. package/dist/virtual-materialize.d.ts +25 -0
  76. package/package.json +30 -18
  77. package/python/ipynb_runner.py +418 -31
  78. package/python/requirements.txt +5 -4
  79. package/server.js +3 -0
  80. package/dist/domain/cell.d.ts.map +0 -1
  81. package/dist/domain/errors.d.ts.map +0 -1
  82. package/dist/domain/execution.d.ts.map +0 -1
  83. package/dist/domain/notebook.d.ts.map +0 -1
  84. package/dist/domain/output.d.ts.map +0 -1
  85. package/dist/format/diagnostics.d.ts.map +0 -1
  86. package/dist/format/diff.d.ts.map +0 -1
  87. package/dist/format/markdown.d.ts.map +0 -1
  88. package/dist/format/outputs.d.ts.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/plugin-options.d.ts.map +0 -1
  91. package/dist/plugin.d.ts.map +0 -1
  92. package/dist/services/DiffService.d.ts +0 -17
  93. package/dist/services/DiffService.d.ts.map +0 -1
  94. package/dist/services/NotebookCleanService.d.ts.map +0 -1
  95. package/dist/services/NotebookEditService.d.ts.map +0 -1
  96. package/dist/services/NotebookExecutionService.d.ts.map +0 -1
  97. package/dist/services/NotebookExportService.d.ts.map +0 -1
  98. package/dist/services/NotebookFileService.d.ts.map +0 -1
  99. package/dist/services/NotebookInspectService.d.ts.map +0 -1
  100. package/dist/services/NotebookOutputService.d.ts.map +0 -1
  101. package/dist/services/NotebookReadService.d.ts.map +0 -1
  102. package/dist/services/PathService.d.ts.map +0 -1
  103. package/dist/services/PermissionService.d.ts.map +0 -1
  104. package/dist/services/PythonService.d.ts.map +0 -1
  105. package/dist/services/index.d.ts.map +0 -1
  106. package/dist/tools/_resolveOptions.d.ts.map +0 -1
  107. package/dist/tools/cell_delete.d.ts.map +0 -1
  108. package/dist/tools/cell_insert.d.ts.map +0 -1
  109. package/dist/tools/cell_move.d.ts.map +0 -1
  110. package/dist/tools/clean.d.ts.map +0 -1
  111. package/dist/tools/doctor.d.ts.map +0 -1
  112. package/dist/tools/edit.d.ts.map +0 -1
  113. package/dist/tools/export.d.ts.map +0 -1
  114. package/dist/tools/inspect.d.ts.map +0 -1
  115. package/dist/tools/kernel.d.ts.map +0 -1
  116. package/dist/tools/outputs.d.ts.map +0 -1
  117. package/dist/tools/read.d.ts.map +0 -1
  118. package/dist/tools/repro.d.ts.map +0 -1
  119. package/dist/tools/run.d.ts.map +0 -1
  120. package/dist/utils/ansi.d.ts.map +0 -1
  121. package/dist/utils/attachments.d.ts.map +0 -1
  122. package/dist/utils/fiber.d.ts +0 -2
  123. package/dist/utils/fiber.d.ts.map +0 -1
  124. package/dist/utils/i18n.d.ts.map +0 -1
  125. package/dist/utils/imports.d.ts.map +0 -1
  126. package/dist/utils/json.d.ts.map +0 -1
  127. package/dist/utils/limits.d.ts.map +0 -1
  128. package/dist/utils/mime.d.ts.map +0 -1
  129. package/dist/utils/paths.d.ts.map +0 -1
  130. package/dist/utils/truncate.d.ts.map +0 -1
@@ -1,5 +1,19 @@
1
1
  import { Effect } from "effect";
2
2
  import { NotebookParseError } from "../domain/errors.js";
3
+ import { type JsonTextStyle, type PatchFailureReason } from "./json-patch.js";
4
+ export { MAX_JSON_DEPTH } from "./json-patch.js";
5
+ export type { PatchFailureReason };
3
6
  export declare const safeParseJson: (text: string, filePath: string) => Effect.Effect<unknown, NotebookParseError>;
4
- export declare const stringifyNotebook: (notebook: unknown) => string;
5
- //# sourceMappingURL=json.d.ts.map
7
+ export interface NotebookFormat extends JsonTextStyle {
8
+ readonly trailingNewline: boolean;
9
+ }
10
+ export declare const DEFAULT_NOTEBOOK_FORMAT: NotebookFormat;
11
+ export declare const detectNotebookFormat: (text: string) => NotebookFormat;
12
+ export declare const stringifyNotebook: (notebook: unknown, format?: NotebookFormat) => string;
13
+ export type WriteMode = "patched" | "fallback";
14
+ export interface RewriteResult {
15
+ readonly text: string;
16
+ readonly mode: WriteMode;
17
+ readonly reason?: PatchFailureReason;
18
+ }
19
+ export declare const rewriteNotebookTextDetailed: (previousText: string, notebook: unknown, format: NotebookFormat) => RewriteResult;
@@ -1,9 +1,18 @@
1
1
  export declare const DEFAULT_MAX_SOURCE_CHARS = 12000;
2
2
  export declare const DEFAULT_MAX_OUTPUT_CHARS = 6000;
3
3
  export declare const DEFAULT_MAX_INSPECT_CELLS = 200;
4
- export declare const DEFAULT_MAX_TRACEBACK_CHARS = 8000;
5
4
  export declare const DEFAULT_MAX_IMAGE_NOTICE_COUNT = 20;
6
5
  export declare const DEFAULT_MAX_EXPORT_CHARS = 60000;
7
6
  export declare const DEFAULT_RUN_TIMEOUT_MS = 120000;
8
7
  export declare const DEFAULT_INSPECT_PREVIEW_CHARS = 240;
9
- //# sourceMappingURL=limits.d.ts.map
8
+ export declare const MAX_NOTEBOOK_BYTES: number;
9
+ export declare const MAX_READ_CELLS = 500;
10
+ export declare const MAX_INSPECT_CELLS = 1000;
11
+ export declare const MAX_METADATA_CHARS = 20000;
12
+ export declare const MAX_RUN_RESPONSE_CHARS = 120000;
13
+ export declare const MAX_READ_RESPONSE_CHARS = 120000;
14
+ export declare const MAX_HELPER_STDOUT_BYTES: number;
15
+ export declare const MAX_ATTACHMENT_BYTES: number;
16
+ export declare const MAX_DIAGNOSTICS_METADATA = 500;
17
+ export declare const MAX_ANALYSIS_WARNINGS = 500;
18
+ export declare const MAX_DIAGNOSTICS_METADATA_BYTES = 200000;
@@ -0,0 +1,2 @@
1
+ export declare const sanitizeInline: (text: string) => string;
2
+ export declare const truncateMarkdown: (text: string, maxChars: number, hint: string) => string;
@@ -0,0 +1,2 @@
1
+ import type { NotebookDiagnostic } from "../notebook-diagnostics.js";
2
+ export declare const capDiagnosticMetadata: (diagnostics: ReadonlyArray<NotebookDiagnostic>) => ReadonlyArray<NotebookDiagnostic>;
@@ -1,4 +1,4 @@
1
1
  export declare const isImageMime: (mime: string) => boolean;
2
2
  export declare const estimateBase64Bytes: (data: string) => number;
3
3
  export declare const humanBytes: (n: number) => string;
4
- //# sourceMappingURL=mime.d.ts.map
4
+ export declare const isAttachableImageMime: (mime: string) => boolean;
@@ -3,9 +3,9 @@ export interface NormalizeOptions {
3
3
  readonly resolveAbsolute?: (p: string) => string;
4
4
  }
5
5
  export declare const normalizeSlashes: (p: string, platform?: NodeJS.Platform) => string;
6
+ export declare const absoluteDriveRoot: (value: string, platform?: NodeJS.Platform) => string;
6
7
  export declare const isAbsolutePath: (p: string) => boolean;
7
8
  export declare const hasIpynbExtension: (p: string) => boolean;
8
- export declare const ensureIpynbExtension: (p: string) => string;
9
9
  export interface ResolveInput {
10
10
  readonly inputPath: string;
11
11
  readonly base: string;
@@ -19,4 +19,4 @@ export interface RelativeOptions {
19
19
  }
20
20
  export declare const makeRelative: (from: string, to: string, opts?: RelativeOptions) => string;
21
21
  export declare const toForwardSlashes: (p: string) => string;
22
- //# sourceMappingURL=paths.d.ts.map
22
+ export declare const pathInside: (root: string, target: string, platform?: NodeJS.Platform) => boolean;
@@ -0,0 +1 @@
1
+ export declare const realpathWithRetry: (target: string) => Promise<string>;
@@ -0,0 +1,6 @@
1
+ type RenameHook = (target: string) => Promise<void> | void;
2
+ export declare const setBeforeRenameHook: (next: RenameHook | undefined) => void;
3
+ export declare const setAfterRenameHook: (next: RenameHook | undefined) => void;
4
+ export declare const beforeRenameHook: (target: string) => Promise<void>;
5
+ export declare const afterRenameHook: (target: string) => Promise<void>;
6
+ export {};
@@ -14,4 +14,3 @@ export type TruncateHint = string | TruncateHintSpec;
14
14
  export declare const truncate: (text: string, maxChars: number, hint?: TruncateHint) => TruncateResult;
15
15
  export declare const truncatePreview: (text: string, maxChars: number) => string;
16
16
  export declare const firstLine: (text: string) => string;
17
- //# sourceMappingURL=truncate.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Effect } from "effect";
2
+ export type WarningSource = "atomic-replace" | "cleanup" | "json-patch" | "lock" | "permission-alias" | "path-resolution" | "python-probe" | "revision-check" | "shell-command" | "sidecar-cleanup" | "temp-unlink";
3
+ export interface Warning {
4
+ readonly source: WarningSource;
5
+ readonly message: string;
6
+ readonly detail?: string;
7
+ }
8
+ export interface WarningSink {
9
+ readonly add: (warning: Warning) => void;
10
+ readonly drain: () => ReadonlyArray<Warning>;
11
+ }
12
+ export declare const makeWarningSink: () => WarningSink;
13
+ export declare const warningFrom: (source: WarningSource, error: unknown, context?: string) => Warning;
14
+ export declare const ignoreExpectedFailure: <A>(sink: WarningSink | undefined, source: WarningSource, context: string, effect: Effect.Effect<A, unknown>) => Effect.Effect<A | undefined>;
15
+ export declare const bestEffort: (sink: WarningSink | undefined, source: WarningSource, context: string, action: () => Promise<unknown>) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { type WarningSink } from "./warnings.js";
2
+ export declare const taskkillPath: () => string;
3
+ export declare const killWindowsTree: (pid: number, sink?: WarningSink) => void;
@@ -0,0 +1,25 @@
1
+ import type { NotebookVirtualDocument } from "./lsp.js";
2
+ import { type Warning, type WarningSink } from "./utils/warnings.js";
3
+ export interface MaterializedCell {
4
+ readonly cellIndex: number;
5
+ readonly cellType: string;
6
+ readonly startLine: number;
7
+ readonly endLine: number;
8
+ }
9
+ export interface MaterializedDocument {
10
+ readonly path: string;
11
+ readonly text: string;
12
+ readonly cells: ReadonlyArray<MaterializedCell>;
13
+ readonly warnings?: ReadonlyArray<Warning>;
14
+ }
15
+ export interface MaterializeOptions {
16
+ readonly warningSink?: WarningSink | undefined;
17
+ }
18
+ export interface CleanupOptions {
19
+ readonly warningSink?: WarningSink;
20
+ }
21
+ export declare const materializedPath: (filePath: string, root?: string) => string;
22
+ export declare const materializeVirtualDocument: (document: NotebookVirtualDocument, worktree: string, options?: MaterializeOptions) => Promise<MaterializedDocument>;
23
+ export declare const refreshMaterializedDocument: (document: NotebookVirtualDocument, worktree: string, options?: MaterializeOptions) => Promise<boolean>;
24
+ export declare const hasMaterializedDocument: (worktree: string, filePath: string, options?: MaterializeOptions) => Promise<boolean>;
25
+ export declare const cleanupVirtualDocuments: (worktree: string, options?: CleanupOptions) => Promise<void>;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "opencode-ipynb",
3
- "version": "0.1.2",
3
+ "version": "3.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": "bun run scripts/prepack-check.ts",
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
  }