codebind 0.6.9__tar.gz → 0.6.10__tar.gz

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 (30) hide show
  1. {codebind-0.6.9 → codebind-0.6.10}/PKG-INFO +2 -2
  2. {codebind-0.6.9 → codebind-0.6.10}/README.md +1 -1
  3. {codebind-0.6.9 → codebind-0.6.10}/pyproject.toml +1 -1
  4. {codebind-0.6.9 → codebind-0.6.10}/pyproject.toml.orig +1 -1
  5. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/execution.py +2 -2
  6. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/terminal.py +49 -36
  7. {codebind-0.6.9 → codebind-0.6.10}/LICENSE +0 -0
  8. {codebind-0.6.9 → codebind-0.6.10}/data/share/jupyter/labextensions/codebind-jupyterlab/install.json +0 -0
  9. {codebind-0.6.9 → codebind-0.6.10}/data/share/jupyter/labextensions/codebind-jupyterlab/package.json +0 -0
  10. {codebind-0.6.9 → codebind-0.6.10}/data/share/jupyter/labextensions/codebind-jupyterlab/static/590.dae4561c5427a855.js +0 -0
  11. {codebind-0.6.9 → codebind-0.6.10}/data/share/jupyter/labextensions/codebind-jupyterlab/static/remoteEntry.c10098fb6e87897c.js +0 -0
  12. {codebind-0.6.9 → codebind-0.6.10}/data/share/jupyter/labextensions/codebind-jupyterlab/static/style.js +0 -0
  13. {codebind-0.6.9 → codebind-0.6.10}/data/share/jupyter/labextensions/codebind-jupyterlab/static/third-party-licenses.json +0 -0
  14. {codebind-0.6.9 → codebind-0.6.10}/jupyterlab/.yarnrc.yml +0 -0
  15. {codebind-0.6.9 → codebind-0.6.10}/jupyterlab/install.json +0 -0
  16. {codebind-0.6.9 → codebind-0.6.10}/jupyterlab/package.json +0 -0
  17. {codebind-0.6.9 → codebind-0.6.10}/jupyterlab/src/index.ts +0 -0
  18. {codebind-0.6.9 → codebind-0.6.10}/jupyterlab/tsconfig.json +0 -0
  19. {codebind-0.6.9 → codebind-0.6.10}/jupyterlab/yarn.lock +0 -0
  20. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/__init__.py +0 -0
  21. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/cli.py +0 -0
  22. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/configuration.py +0 -0
  23. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/conversation.py +0 -0
  24. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/display.py +0 -0
  25. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/extension.py +0 -0
  26. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/images.py +0 -0
  27. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/instructions.md +0 -0
  28. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/jupyter.py +0 -0
  29. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/py.typed +0 -0
  30. {codebind-0.6.9 → codebind-0.6.10}/src/codebind/session.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codebind
3
- Version: 0.6.9
3
+ Version: 0.6.10
4
4
  Summary: A frontend-neutral model loop for persistent IPython sessions.
5
5
  Keywords: ai,ipython,llm,repl,agents
6
6
  Author: Giovanni Gravili
@@ -75,7 +75,7 @@ Inspect this project and tell me what to implement first.
75
75
  ```
76
76
 
77
77
  Terminal conversations remain live for the current IPython process. Previous terminal inputs and outputs, including Python cells you ran yourself, enter the model's context when you ask a question. Durable automatic resumption belongs to notebooks, where the notebook file provides an unambiguous conversation identity.
78
- Model-executed cells appear with IPython's native input counter, syntax highlighting, output prompts, streams, and tracebacks. Assistant Markdown appears before the following tool cell, and tool output appears as it is written. To keep terminal scrollback usable, Codebind shows at most 10 gray lines of each model-executed cell's output, then displays a notice such as `… 990 more output lines. Run %output 8 to view all.` The complete output remains available to the model and in IPython history; `%output 8` opens its full text in IPython's pager. User-entered Python cells keep IPython's normal display behavior. Assistant Markdown is rendered through IPython's terminal MIME renderer. A terminal is a stream rather than a notebook document, so these displays are not editable notebook cells.
78
+ Model-executed cells appear with IPython's native input counter, syntax highlighting, output prompts, streams, and tracebacks. Assistant Markdown appears before the following tool cell, and tool output appears as it is written. To keep terminal scrollback usable, Codebind previews at most three gray output lines, shortening each line after 60 characters with `...`. Further lines appear as `… N more output lines.` The complete output remains available to the model and in IPython history; `%output 8` opens the full text of cell 8 in IPython's pager. User-entered Python cells keep IPython's normal display behavior. Assistant Markdown is rendered through IPython's terminal MIME renderer. A terminal is a stream rather than a notebook document, so these displays are not editable notebook cells.
79
79
 
80
80
  ## JupyterLab
81
81
 
@@ -47,7 +47,7 @@ Inspect this project and tell me what to implement first.
47
47
  ```
48
48
 
49
49
  Terminal conversations remain live for the current IPython process. Previous terminal inputs and outputs, including Python cells you ran yourself, enter the model's context when you ask a question. Durable automatic resumption belongs to notebooks, where the notebook file provides an unambiguous conversation identity.
50
- Model-executed cells appear with IPython's native input counter, syntax highlighting, output prompts, streams, and tracebacks. Assistant Markdown appears before the following tool cell, and tool output appears as it is written. To keep terminal scrollback usable, Codebind shows at most 10 gray lines of each model-executed cell's output, then displays a notice such as `… 990 more output lines. Run %output 8 to view all.` The complete output remains available to the model and in IPython history; `%output 8` opens its full text in IPython's pager. User-entered Python cells keep IPython's normal display behavior. Assistant Markdown is rendered through IPython's terminal MIME renderer. A terminal is a stream rather than a notebook document, so these displays are not editable notebook cells.
50
+ Model-executed cells appear with IPython's native input counter, syntax highlighting, output prompts, streams, and tracebacks. Assistant Markdown appears before the following tool cell, and tool output appears as it is written. To keep terminal scrollback usable, Codebind previews at most three gray output lines, shortening each line after 60 characters with `...`. Further lines appear as `… N more output lines.` The complete output remains available to the model and in IPython history; `%output 8` opens the full text of cell 8 in IPython's pager. User-entered Python cells keep IPython's normal display behavior. Assistant Markdown is rendered through IPython's terminal MIME renderer. A terminal is a stream rather than a notebook document, so these displays are not editable notebook cells.
51
51
 
52
52
  ## JupyterLab
53
53
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codebind"
3
- version = "0.6.9"
3
+ version = "0.6.10"
4
4
  description = "A frontend-neutral model loop for persistent IPython sessions."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codebind"
3
- version = "0.6.9"
3
+ version = "0.6.10"
4
4
  description = "A frontend-neutral model loop for persistent IPython sessions."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -222,7 +222,7 @@ class IPythonExecutor:
222
222
  with preview_tool_output() as preview, record_tool_output(self.shell):
223
223
  result = self.shell.run_cell(cell, store_history=True)
224
224
  report = self._native_report(result)
225
- preview.show_notice(result.execution_count, report.error)
225
+ preview.show_notice(report.error)
226
226
  return report
227
227
 
228
228
  bridge = self.bridge
@@ -277,7 +277,7 @@ class IPythonExecutor:
277
277
  self.shell.events.trigger("post_execute")
278
278
  self.shell.events.trigger("post_run_cell", result)
279
279
  report = self._native_report(result)
280
- preview.show_notice(result.execution_count, report.error)
280
+ preview.show_notice(report.error)
281
281
  return report
282
282
 
283
283
  bridge = self.bridge
@@ -3,7 +3,6 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import ast
6
- import shutil
7
6
  import sys
8
7
  from collections.abc import Callable, Iterator
9
8
  from contextlib import contextmanager
@@ -23,7 +22,8 @@ from rich.markdown import Markdown
23
22
 
24
23
  _MISSING = object()
25
24
  _IMAGE_FORMATS = ("image/png", "image/jpeg", "image/svg+xml")
26
- _MAXIMUM_VISIBLE_OUTPUT_LINES = 10
25
+ _MAXIMUM_VISIBLE_OUTPUT_LINES = 3
26
+ _MAXIMUM_VISIBLE_OUTPUT_CHARACTERS_PER_LINE = 80
27
27
 
28
28
 
29
29
  def _plain_ansi(value: str) -> str:
@@ -192,66 +192,80 @@ class TerminalCellHistory:
192
192
  class _OutputPreview:
193
193
  """Limit only terminal painting; IPython still records every written byte."""
194
194
 
195
- def __init__(self, maximum_lines: int, maximum_characters: int) -> None:
195
+ def __init__(self, maximum_lines: int, maximum_characters_per_line: int) -> None:
196
196
  self.maximum_lines = maximum_lines
197
- self.maximum_characters = maximum_characters
197
+ self.maximum_characters_per_line = maximum_characters_per_line
198
198
  self.visible_lines = 0
199
+ self.characters_on_line = 0
200
+ self.line_truncated = False
199
201
  self.visible_characters = 0
200
202
  self.hidden_line_breaks = 0
201
203
  self.hidden_has_tail = False
202
204
  self.hidden_characters = 0
203
- self.truncated = False
204
205
  self.visible_ends_line = True
205
206
 
206
207
  def _hide(self, data: str) -> None:
207
- self.truncated = True
208
208
  self.hidden_characters += len(data)
209
209
  self.hidden_line_breaks += data.count("\n") + data.count("\r") - data.count("\r\n")
210
210
  self.hidden_has_tail = not data.endswith(("\n", "\r"))
211
211
 
212
+ def _paint(self, stream, text: str) -> None:
213
+ if not text:
214
+ return
215
+ if stream.isatty():
216
+ stream.write("\x1b[90m")
217
+ stream.write(text)
218
+ if stream.isatty():
219
+ stream.write("\x1b[0m")
220
+ self.visible_characters += len(text)
221
+
212
222
  def write(self, stream, data: str) -> int:
213
223
  for piece in data.splitlines(keepends=True):
214
- remaining = self.maximum_characters - self.visible_characters
215
- if self.truncated or self.visible_lines >= self.maximum_lines or remaining <= 0:
224
+ if self.visible_lines >= self.maximum_lines:
216
225
  self._hide(piece)
217
226
  continue
218
- visible = piece[:remaining]
219
- if len(visible) < len(piece) and "\x1b" in visible:
220
- # Never leave a partially printed ANSI escape sequence on screen.
221
- visible = ""
227
+
228
+ if piece.endswith("\r\n"):
229
+ body, ending = piece[:-2], "\r\n"
230
+ elif piece.endswith(("\n", "\r")):
231
+ body, ending = piece[:-1], piece[-1]
232
+ else:
233
+ body, ending = piece, ""
234
+
235
+ visible = ""
236
+ if not self.line_truncated:
237
+ remaining = self.maximum_characters_per_line - self.characters_on_line
238
+ visible = body[:remaining]
239
+ self.characters_on_line += len(visible)
240
+ if len(body) > remaining:
241
+ visible += "…"
242
+ self.line_truncated = True
243
+ if ending:
244
+ visible += ending
245
+ self.visible_lines += 1
246
+ self.characters_on_line = 0
247
+ self.line_truncated = False
222
248
  if visible:
223
- if stream.isatty():
224
- stream.write("\x1b[90m")
225
- stream.write(visible)
226
- if stream.isatty():
227
- stream.write("\x1b[0m")
228
- self.visible_characters += len(visible)
229
- self.visible_ends_line = visible.endswith(("\n", "\r"))
230
- if self.visible_ends_line:
231
- self.visible_lines += 1
232
- if len(visible) < len(piece):
233
- self._hide(piece[len(visible) :])
249
+ self._paint(stream, visible)
250
+ self.visible_ends_line = bool(ending)
234
251
  return len(data)
235
252
 
236
- def show_notice(self, number: int, error: dict[str, str] | None = None) -> None:
253
+ def show_notice(self, error: dict[str, str] | None = None) -> None:
237
254
  if self.visible_characters and not self.visible_ends_line:
238
255
  sys.stdout.write("\n")
239
256
  self.visible_ends_line = True
240
257
  if not self.hidden_characters:
241
258
  return
242
- if sys.stdout.isatty():
243
- sys.stdout.write("\x1b[0m")
259
+ terminal = sys.stdout.isatty()
260
+ if terminal:
261
+ sys.stdout.write("\x1b[90m")
244
262
  hidden_lines = self.hidden_line_breaks + int(self.hidden_has_tail)
245
263
  label = "line" if hidden_lines == 1 else "lines"
246
- sys.stdout.write(
247
- f"… {hidden_lines:,} more output {label}. Run %output {number} to view all.\n"
248
- )
264
+ sys.stdout.write(f"… {hidden_lines:,} more output {label}\n")
249
265
  if error is not None:
250
- if sys.stdout.isatty():
251
- sys.stdout.write("\x1b[90m")
252
266
  sys.stdout.write(f"{error['type']}: {error['message']}\n")
253
- if sys.stdout.isatty():
254
- sys.stdout.write("\x1b[0m")
267
+ if terminal:
268
+ sys.stdout.write("\x1b[0m")
255
269
 
256
270
 
257
271
  class _PreviewStream:
@@ -276,10 +290,10 @@ class _PreviewStream:
276
290
  @contextmanager
277
291
  def preview_tool_output(
278
292
  maximum_lines: int = _MAXIMUM_VISIBLE_OUTPUT_LINES,
293
+ maximum_characters_per_line: int = _MAXIMUM_VISIBLE_OUTPUT_CHARACTERS_PER_LINE,
279
294
  ) -> Iterator[_OutputPreview]:
280
295
  """Show a compact preview while keeping the tool cell's complete native output."""
281
- columns = shutil.get_terminal_size(fallback=(80, 24)).columns
282
- preview = _OutputPreview(maximum_lines, maximum_lines * max(20, columns))
296
+ preview = _OutputPreview(maximum_lines, maximum_characters_per_line)
283
297
  stdout, stderr = sys.stdout, sys.stderr
284
298
  preview_stdout = _PreviewStream(stdout, preview)
285
299
  preview_stderr = _PreviewStream(stderr, preview)
@@ -395,7 +409,6 @@ def show_input(shell: TerminalInteractiveShell, cell: str) -> None:
395
409
  style=style,
396
410
  color_depth=shell.color_depth,
397
411
  )
398
- sys.stdout.write("\n")
399
412
 
400
413
 
401
414
  def install_markdown_renderer(shell: TerminalInteractiveShell) -> Callable[[], None]:
File without changes
File without changes
File without changes