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
@@ -7,7 +7,7 @@ export declare const CodeCellSchema: z.ZodObject<{
7
7
  cell_type: z.ZodLiteral<"code">;
8
8
  id: z.ZodOptional<z.ZodString>;
9
9
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
10
- execution_count: z.ZodUnion<readonly [z.ZodNullable<z.ZodNumber>, z.ZodNull]>;
10
+ execution_count: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
11
11
  source: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
12
12
  outputs: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
13
13
  }, z.core.$loose>;
@@ -25,13 +25,14 @@ export declare const RawCellSchema: z.ZodObject<{
25
25
  id: z.ZodOptional<z.ZodString>;
26
26
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
27
27
  source: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
28
+ attachments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
29
  }, z.core.$loose>;
29
30
  export type RawCellRaw = z.infer<typeof RawCellSchema>;
30
31
  export declare const CellSchema: z.ZodUnion<readonly [z.ZodObject<{
31
32
  cell_type: z.ZodLiteral<"code">;
32
33
  id: z.ZodOptional<z.ZodString>;
33
34
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
34
- execution_count: z.ZodUnion<readonly [z.ZodNullable<z.ZodNumber>, z.ZodNull]>;
35
+ execution_count: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
35
36
  source: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
36
37
  outputs: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
37
38
  }, z.core.$loose>, z.ZodObject<{
@@ -45,6 +46,6 @@ export declare const CellSchema: z.ZodUnion<readonly [z.ZodObject<{
45
46
  id: z.ZodOptional<z.ZodString>;
46
47
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
47
48
  source: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
49
+ attachments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
50
  }, z.core.$loose>]>;
49
51
  export type CellRaw = z.infer<typeof CellSchema>;
50
- //# sourceMappingURL=cell.d.ts.map
@@ -1,5 +1,4 @@
1
- import { Effect } from "effect";
2
- export type NotebookErrorKind = "NotebookNotFound" | "NotebookParse" | "NotebookValidation" | "CellIndexOutOfBounds" | "NotebookWrite" | "NotebookExecution" | "PythonRunner" | "PermissionDenied" | "OutputTooLarge" | "PathOutsideWorktree" | "NotebookNotImplemented" | "NotebookAttachment" | "LockError";
1
+ export type NotebookErrorKind = "NotebookNotFound" | "NotebookParse" | "NotebookValidation" | "CellIndexOutOfBounds" | "NotebookWrite" | "NotebookExecution" | "PythonRunner" | "PermissionDenied" | "PathOutsideWorktree" | "NotebookNotImplemented";
3
2
  declare const NotebookNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
4
3
  readonly _tag: "NotebookNotFound";
5
4
  } & Readonly<A>;
@@ -66,15 +65,7 @@ declare const PermissionDeniedError_base: new <A extends Record<string, any> = {
66
65
  export declare class PermissionDeniedError extends PermissionDeniedError_base<{
67
66
  readonly message: string;
68
67
  readonly action: string;
69
- }> {
70
- }
71
- declare const OutputTooLargeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
72
- readonly _tag: "OutputTooLarge";
73
- } & Readonly<A>;
74
- export declare class OutputTooLargeError extends OutputTooLargeError_base<{
75
- readonly message: string;
76
- readonly cellIndex: number;
77
- readonly bytes: number;
68
+ readonly cause?: unknown;
78
69
  }> {
79
70
  }
80
71
  declare const PathOutsideWorktreeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
@@ -94,26 +85,7 @@ export declare class NotebookNotImplementedError extends NotebookNotImplementedE
94
85
  readonly feature: string;
95
86
  }> {
96
87
  }
97
- declare const NotebookAttachmentError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
98
- readonly _tag: "NotebookAttachment";
99
- } & Readonly<A>;
100
- export declare class NotebookAttachmentError extends NotebookAttachmentError_base<{
101
- readonly message: string;
102
- readonly mime: string;
103
- }> {
104
- }
105
- declare const LockError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
106
- readonly _tag: "LockError";
107
- } & Readonly<A>;
108
- export declare class LockError extends LockError_base<{
109
- readonly message: string;
110
- readonly filePath: string;
111
- readonly cause: string;
112
- }> {
113
- }
114
- export type NotebookError = NotebookNotFoundError | NotebookParseError | NotebookValidationError | CellIndexOutOfBoundsError | NotebookWriteError | NotebookExecutionError | PythonRunnerError | PermissionDeniedError | OutputTooLargeError | PathOutsideWorktreeError | NotebookNotImplementedError | NotebookAttachmentError | LockError;
88
+ export type NotebookError = NotebookNotFoundError | NotebookParseError | NotebookValidationError | CellIndexOutOfBoundsError | NotebookWriteError | NotebookExecutionError | PythonRunnerError | PermissionDeniedError | PathOutsideWorktreeError | NotebookNotImplementedError;
115
89
  export declare const isNotebookError: (u: unknown) => u is NotebookError;
116
90
  export declare const errorToMessage: (e: unknown) => string;
117
- export declare const failWith: <E extends NotebookError>(e: E) => Effect.Effect<never, E, never>;
118
91
  export {};
119
- //# sourceMappingURL=errors.d.ts.map
@@ -18,6 +18,8 @@ export declare const RunRequestSchema: z.ZodObject<{
18
18
  kernel: z.ZodOptional<z.ZodString>;
19
19
  timeoutMs: z.ZodOptional<z.ZodNumber>;
20
20
  save: z.ZodOptional<z.ZodBoolean>;
21
+ includeRawOutputs: z.ZodOptional<z.ZodBoolean>;
22
+ kernelEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
23
  workingDirectory: z.ZodOptional<z.ZodString>;
22
24
  maxOutputChars: z.ZodOptional<z.ZodNumber>;
23
25
  }, z.core.$strip>;
@@ -35,6 +37,7 @@ export declare const CellExecutionSummarySchema: z.ZodObject<{
35
37
  sizeBytes: z.ZodNumber;
36
38
  }, z.core.$strip>>>;
37
39
  rawOutputs: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
40
+ rawOutputsOmitted: z.ZodOptional<z.ZodBoolean>;
38
41
  errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
39
42
  ename: z.ZodString;
40
43
  evalue: z.ZodString;
@@ -60,6 +63,7 @@ export declare const RunResponseSchema: z.ZodObject<{
60
63
  sizeBytes: z.ZodNumber;
61
64
  }, z.core.$strip>>>;
62
65
  rawOutputs: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
66
+ rawOutputsOmitted: z.ZodOptional<z.ZodBoolean>;
63
67
  errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
68
  ename: z.ZodString;
65
69
  evalue: z.ZodString;
@@ -84,4 +88,3 @@ export declare const RunResponseSchema: z.ZodObject<{
84
88
  }, z.core.$strip>>;
85
89
  }, z.core.$strip>;
86
90
  export type RunResponse = z.infer<typeof RunResponseSchema>;
87
- //# sourceMappingURL=execution.d.ts.map
@@ -26,7 +26,7 @@ export declare const NotebookMetadataSchema: z.ZodObject<{
26
26
  export type NotebookMetadataRaw = z.infer<typeof NotebookMetadataSchema>;
27
27
  export declare const NotebookSchema: z.ZodObject<{
28
28
  nbformat: z.ZodNumber;
29
- nbformat_minor: z.ZodOptional<z.ZodNumber>;
29
+ nbformat_minor: z.ZodNumber;
30
30
  metadata: z.ZodDefault<z.ZodObject<{
31
31
  kernelspec: z.ZodOptional<z.ZodObject<{
32
32
  name: z.ZodOptional<z.ZodString>;
@@ -43,7 +43,7 @@ export declare const NotebookSchema: z.ZodObject<{
43
43
  cell_type: z.ZodLiteral<"code">;
44
44
  id: z.ZodOptional<z.ZodString>;
45
45
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
46
- execution_count: z.ZodUnion<readonly [z.ZodNullable<z.ZodNumber>, z.ZodNull]>;
46
+ execution_count: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
47
47
  source: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
48
48
  outputs: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
49
49
  }, z.core.$loose>, z.ZodObject<{
@@ -57,9 +57,12 @@ export declare const NotebookSchema: z.ZodObject<{
57
57
  id: z.ZodOptional<z.ZodString>;
58
58
  metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
59
59
  source: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
60
+ attachments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
61
  }, z.core.$loose>]>>;
61
62
  }, z.core.$loose>;
62
63
  export type NotebookRaw = z.infer<typeof NotebookSchema>;
63
64
  export declare const normalizeSource: (source: z.infer<typeof SourceSchema>) => string;
64
65
  export declare const cellSource: (cell: CellRaw) => string;
65
- //# sourceMappingURL=notebook.d.ts.map
66
+ export declare const splitSourceLines: (source: string) => string[];
67
+ export declare const formatSourceLike: (previous: z.infer<typeof SourceSchema>, next: string) => z.infer<typeof SourceSchema>;
68
+ export declare const applyNotebookDefaults: (raw: unknown) => NotebookRaw;
@@ -47,4 +47,3 @@ export declare const CellOutputSchema: z.ZodUnion<readonly [z.ZodObject<{
47
47
  export type CellOutputRaw = z.infer<typeof CellOutputSchema>;
48
48
  export type CellOutputKind = "stream" | "display_data" | "execute_result" | "error" | "unknown";
49
49
  export declare const detectOutputKind: (raw: Record<string, unknown>) => CellOutputKind;
50
- //# sourceMappingURL=output.d.ts.map
@@ -12,4 +12,3 @@ export interface CellInspection {
12
12
  outputSummary: string;
13
13
  }
14
14
  export declare const inspectCell: (cell: CellRaw, index: number) => CellInspection;
15
- //# sourceMappingURL=diagnostics.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import type { CellRaw } from "../domain/cell.js";
2
2
  import { type OutputFormatOptions } from "./outputs.js";
3
- import type { ToolAttachment } from "@opencode-ai/plugin";
3
+ import type { ToolAttachment } from "../tool.js";
4
4
  export interface MarkdownReadOptions {
5
5
  readonly includeOutputs: boolean;
6
6
  readonly includeErrors: boolean;
@@ -16,4 +16,3 @@ export interface FormattedCell {
16
16
  }
17
17
  export declare const formatCellMarkdown: (cell: CellRaw, index: number, optsInput?: Partial<MarkdownReadOptions>) => string;
18
18
  export declare const formatCellMarkdownDetailed: (cell: CellRaw, index: number, optsInput?: Partial<MarkdownReadOptions>) => Promise<FormattedCell>;
19
- //# sourceMappingURL=markdown.d.ts.map
@@ -1,6 +1,7 @@
1
1
  export interface MarkdownCellInput {
2
2
  readonly cell_type: "code" | "markdown" | "raw";
3
3
  readonly source: string;
4
+ readonly attachments?: ReadonlyArray<string> | undefined;
4
5
  }
5
6
  export interface FormatMarkdownOptions {
6
7
  readonly includeOutputs?: boolean | undefined;
@@ -17,4 +18,3 @@ export declare const formatNotebookAsPython: (params: {
17
18
  cells: ReadonlyArray<MarkdownCellInput>;
18
19
  header?: string;
19
20
  }) => string;
20
- //# sourceMappingURL=diff.d.ts.map
@@ -1,8 +1,9 @@
1
1
  import type { CellRaw } from "../domain/cell.js";
2
2
  import type { NotebookRaw } from "../domain/notebook.js";
3
- import type { ToolAttachment } from "@opencode-ai/plugin";
3
+ import type { ToolAttachment } from "../tool.js";
4
4
  export interface OutputFormatOptions {
5
5
  readonly includeImages: boolean;
6
+ readonly hardCap?: boolean | undefined;
6
7
  readonly saveImages?: boolean | undefined;
7
8
  readonly maxOutputChars: number;
8
9
  readonly maxTracebackChars: number;
@@ -16,4 +17,3 @@ export declare const formatOutputs: (cell: CellRaw, optsInput?: Partial<OutputFo
16
17
  export declare const formatOutputsDetailed: (cell: CellRaw, optsInput?: Partial<OutputFormatOptions>) => Promise<FormattedOutput>;
17
18
  export declare const formatNotebookDiagnostics: (notebook: NotebookRaw, filePath: string) => string;
18
19
  export declare const formatSourcePreview: (source: string, max: number) => string;
19
- //# sourceMappingURL=outputs.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default } from "./plugin.js";
2
- //# sourceMappingURL=index.d.ts.map
2
+ export { buildNotebookVirtualDocument, makePositionMapper, toCellPosition, toVirtualPosition, type CellPosition, type NotebookCellDocument, type NotebookLike, type NotebookVirtualDocument, type PositionMapper, type VirtualDocumentOptions, type VirtualPosition } from "./lsp.js";
3
+ export { NotebookRpc } from "./rpc.js";
4
+ export { sanitizeNotebookText } from "./notebook-diagnostics.js";