rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:kexiongwen/dsh-bsb-ipynb
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Read, edit, run and save Jupyter notebooks inside the DSH Better Sidebar.
中文 · English
dsh-bsb-ipynb is a DSH Better Sidebar plugin that turns the sidebar's file tree into a Jupyter notebook workspace. Click any .ipynb to read, edit, run and save it as you would in Jupyter. Kernels run in the host process through jupyter_client + ipykernel, so nothing Python-related runs in the browser and there is no build step.
text/html (sanitized against an allow-list), PNG/JPEG/SVG (image/jpg is accepted as an alias for image/jpeg), Markdown, JSON and ANSI-colored tracebacks. Images in Markdown and text/html outputs resolve the same way: attachment:, relative and Windows drive/UNC paths go through the plugin's workspace-confined image route, while http(s) and data:image sources load as-is (remote images are fetched from their origin).$...$ / \(...\) inline and $$...$$ / \[...\] display formulas in Markdown cells, Markdown outputs and text/latex outputs. KaTeX ships as a package-local chunk that loads only when a notebook contains math; the plugin reuses the DSH page's KaTeX stylesheet and webfonts and switches to self-contained MathML when that stylesheet is absent. Formulas in text/html outputs stay sanitized, not typeset.DSH_IPYNB_PYTHON, conda environments, python3/python on PATH, then DSH's bundled Python, and selects only environments that provide jupyter_client + ipykernel. DSH_IPYNB_PYTHON must be an absolute path; a relative or unusable value is still listed by /ipynb/interpreters with a reason but is never used. The launch config is built in-process, so a same-named system kernelspec cannot redirect the selected interpreter.DSH_IPYNB_KERNEL_IDLE_MS remains the deployment default for headless hosts.--dsw-alias-* and Shiki variables, and cell/editor/output type follows the DSH text and code font settings (dark mode is the host palette for the theme setting × OS scheme, with no plugin-side theme detection). UI strings are registered under the dsh-bsb-ipynb locale namespace and follow DSH's Chinese/English language preference.<script> never runs.| Requirement | Version / notes |
|---|---|
| DSH | Web GUI 0.2.2-rc.2 or newer (verified with 0.2.2-rc.3) |
| dsh-better-sidebar | 0.32.x (verified with 0.32.1; older lines are rejected by the runtime guard) |
| Python | jupyter_client + ipykernel; verify with python3 -c "import jupyter_client, ipykernel" (macOS/Linux) or python -c "import jupyter_client, ipykernel" (Windows) |
Version pairing: this build targets DSH 0.2.2-rc.2+ and
dsh-better-sidebar0.32.x. The sidebar version and required features are checked at startup, so a stale installation fails with a clear message instead of a missing-method error. The latest verified combination is DSH0.2.2-rc.3+dsh-better-sidebar@0.32.1; the unit suite and the pinned browser E2E pass.Upgrading from 0.30.x? The 0.30/older-sidebar line is intentionally no longer supported: update
dsh-better-sidebarto 0.32.x first, then reload the plugin.
# if the dependencies are missing
python3 -m pip install jupyter_client ipykernel # macOS / Linux
python -m pip install jupyter_client ipykernel # Windows (or: py -3 -m pip ...)
Cmd+R on macOS; Ctrl+R or F5 on Windows)..ipynb from the right-hand file tree; examples/demo.ipynb is a good first run.Windows: interpreter discovery looks for
python.exe/python3.exeonPATH(Microsoft Store app-execution aliases underWindowsAppsare skipped), conda environments (<env>\python.exe) and DSH's bundled Python. SetDSH_IPYNB_PYTHONto an absolutepython.exepath when the interpreter lives elsewhere; read-only or locked notebooks reject saves withwrite-blocked(409) until the file is writable again, and reading a file locked by another program returnsread-blocked(409).
| Action | Shortcut |
|---|---|
| Run the current cell | Cmd/Ctrl + Enter |
| Run and advance to the next cell | Shift + Enter |
| Insert a code cell below | Alt + Enter |
| Save | Cmd/Ctrl + S |
| Outdent the current line | Shift + Tab |
| Leave edit mode | Esc |
Run (Cmd/Ctrl + Enter) and save (Cmd/Ctrl + S) shortcuts also work in reading mode while the notebook view is visible: the target is the focused cell, otherwise the cell you last edited or ran, and Cmd/Ctrl + S is intercepted so the browser's save dialog does not open. While editing, Tab inserts four spaces and Shift+Tab removes one indent unit. Every action is also available from the toolbar (interpreter, Run all, interrupt, restart, save, reload, shut down kernel).
display(..., display_id=...) / handle.update(...)); updated results are included in the next save.dsh-bsb-ipynb/
├── index.js # host plugin entry: registers /ipynb routes and owns kernels
├── client.js # browser bundle (hand-written, no build step)
├── client.katex.js # vendored KaTeX chunk, lazily loaded for math (generated)
├── scripts/
│ └── build-katex-chunk.mjs # regenerates client.katex.js from the pinned devDependency
├── lib/
│ ├── routes.js # /ipynb/* HTTP API
│ ├── kernel.js # one bridge process per notebook, event queue, idle sweep
│ ├── notebook.js # nbformat 4 parse/normalize/serialize, sha256 versions, atomic writes
│ ├── gate.js # active workspace resolution and path escape protection
│ ├── active-worktree.js # host-evidenced linked worktree selection
│ ├── env.js # Python interpreter discovery and probing
│ ├── json-budget.js # exact JSON byte/node/depth budgets, mirrored in client.js
│ └── json.js # JSON envelope, request body reader, ApiError
├── python/bridge.py # JSONL kernel bridge over jupyter_client + ipykernel
├── locale/{en,zh}.json
└── test/ # node:test suite (including real kernels) + e2e/ browser smoke test
Request path: browser client.js → better-sidebar webServer → /ipynb/* routes → KernelManager → python/bridge.py (JSONL) ↔ ipykernel.
write-conflict (409) after the first succeeds. Hard-link aliases of the same inode are treated as different paths and are not serialized with each other. This does not acknowledge requests that have not yet reached the file queue after a network failure.write-blocked (409) with a fixable message instead of an internal error; autosave backs off up to 30 s and the response never embeds local paths or temp-file names..dsh-bsb-ipynb-*.tmp behind, the next save sweeps stale ones older than an hour.os._exit() always ends the NDJSON stream with a terminal failure event.DSH_IPYNB_KERNEL_IDLE_MS); ready timeout is 30 s. Shutdown waits 2 s, sends SIGTERM, then SIGKILL 2 s later and allows 500 ms for exit confirmation. If the process still has not exited, the request fails and the stopping entry remains managed; no replacement is started on that path until exit is confirmed. Disposal failures are logged instead of becoming unhandled errors.stopping state. A failed request is not evidence that the process is off; status or a successful retry must confirm exit. Late messages from the old execution cannot overwrite a newer shutdown or restart result.kernel_died and tears the bridge down instead of busy-looping; restarts run off the control loop, so status/interrupt/shutdown stay responsive during a slow restart.The notebook has no colour scheme of its own. client.js declares one token layer on .dsh-bsb-ipynb-root that maps plugin variables to the host theme, and every rule consumes that layer, so a DSH theme or dsh-web-ui skin that overrides the aliases re-skins the notebook automatically — including the kernel status dot, save/error text, banners, markdown links and Python syntax highlighting.
| Notebook role | Host token |
|---|---|
| Text, muted labels, borders, panel surface | --dsw-alias-label-primary / --dsw-alias-label-secondary, --dsw-alias-border-l1, --dsw-alias-bg-layer-1 |
| Cell/card surface, hover fill | --dsw-alias-bg-module-platform, --dsw-alias-interactive-bg-hover |
| Code block / inline code surface | --dsw-alias-markdown-code-block, --dsw-alias-markdown-inline-code |
| Kernel status (off / ready / busy) | --dsw-alias-label-tertiary (off), --dsw-alias-state-success-primary, --dsw-alias-state-warn-primary |
| Save failure, stderr, tracebacks | --dsw-alias-state-error-primary |
| Running-cell border, focus ring | --dsw-alias-state-business-primary (focus also honours --dsw-focus-ring-color) |
| Banners | color-mix() of --dsw-alias-state-business-primary / --dsw-alias-state-error-primary at 12% |
| Markdown links | --dsw-alias-link |
| Python syntax | --shiki-token-* (the Shiki palette shared with DSH markdown code blocks) |
| Text and code type | --dsh-content-font-size-secondary (+ delta), --dsh-code-font-size, --ds-font-family-code |
Font settings map as follows: text size scales the notebook body, markdown prose and the dense chrome labels; code size scales cell sources, the editor, execution prompts, outputs and fenced code blocks; the code font replaces the monospace stack; the text font is inherited from the host body. Defaults reproduce the previous pixel sizes (13 px root, 12 px code, 10–12 px chrome). When a host token is absent (unit tests, standalone rendering), each declaration falls back to its previous hardcoded value.
Intentionally not themed: ANSI 16-colour stdout painting (content, so the same notebook paints the same colours under every skin), inline styles inside HTML output (owned by pandas/plotly/…), and the white surface behind notebook images (keeps transparent PNG/SVG plots readable on dark themes).
All routes are mounted under /ipynb. JSON APIs return {ok:true,value} or {ok:false,error:{code,message,details?}}; /image streams image bytes and /execute responds with application/x-ndjson. POST bodies must be application/json.
| Method | Path | Description |
|---|---|---|
| GET | /ipynb/health |
Version, kernel count, interpreter stats (non-blocking; interpreters.checked=false until warm) |
| GET | /ipynb/interpreters |
Interpreter list and default |
| GET | /ipynb/config |
Current kernel idle timeout (idleMinutes; 0 disables the sweep) |
| GET | /ipynb/kernels?sessionId= |
Live kernels inside the session workspace |
| GET | /ipynb/image?sessionId=&path= |
Stream a workspace-confined image with MIME and SVG safety headers |
| POST | /ipynb/config |
{idleMinutes}; updates the kernel idle timeout |
| GET | /ipynb/status?sessionId=&path= |
Kernel status for a notebook |
| POST | /ipynb/read |
Read and parse a notebook |
| POST | /ipynb/create |
{sessionId, path}; creates Untitled.ipynb in a workspace directory |
| POST | /ipynb/save |
{notebook, baseVersion}; a stale version returns 409 |
| POST | /ipynb/execute |
{cellId, code, python?}; NDJSON execution events |
| POST | /ipynb/interrupt |
Interrupt the current execution |
| POST | /ipynb/restart |
Restart the kernel, optionally switching python |
| POST | /ipynb/shutdown |
Shut the kernel down |
Notebook routes require a non-empty sessionId and path (query parameters for /status and /image, JSON body for the rest). /kernels requires only sessionId; /health, /interpreters and /config do not require session parameters. /execute reports pre-header errors as the JSON envelope; after headers, failures arrive as {type:'fatal',code,message} NDJSON events.
Error codes: bad-request, forbidden, workspace-unknown, path-outside-root, not-found, read-blocked, not-notebook, too-large, write-conflict, write-blocked, write-failed, kernel-busy, kernel-unavailable, interpreter-unknown, method-not-allowed, internal.
text/html outputs are not typeset; that surface stays sanitized and static. Markdown cells, Markdown outputs and text/latex outputs are typeset.input(): kernels start with allow_stdin=False, so calls fail immediately rather than hanging. %% cell magics and !cmd, %pip, %cd, %pwd work.write-blocked (409) and locked files fail reads with read-blocked (409).| Item | Value |
|---|---|
| Notebook file size cap | 32 MiB (files above this are rejected with 413) |
| POST request body cap | 64 MiB (36 MiB on /ipynb/save) |
| Client output budget per cell | 32 MiB (UTF-8 bytes of the complete JSON) |
| Formula rendering | 20,000 characters per formula, 2,000 formulas per Markdown render, 2,000-entry render cache |
| KaTeX chunk | KaTeX 0.19.1, ≈267 KiB minified JS, requested only when a notebook contains math |
| Pending NDJSON queue / single kernel output line | 64 MiB / 64 MiB |
| Metadata | 100 levels / 10,000 nodes per value |
| JSON MIME values (outputs / attachments) | 100 levels / 250,000 nodes per value |
| HTML output sanitization | 100 levels / 250,000 nodes; larger fragments are shown as escaped text |
| Complete notebook structure | 128 levels / 1,000,000 nodes, including source lines on save |
| Autosave (default) / kernel status polling / NDJSON ping | 1.5 s / 10 s / 15 s |
| Ready timeout / shutdown grace / interrupt grace | 30 s / 2 s + 2 s + 500 ms exit confirmation / 3 s |
| Execute stream drain timeout | 10 s (a client that stops reading is disconnected) |
| Kernel idle sweep | 30 minutes by default; the viewer settings or DSH_IPYNB_KERNEL_IDLE_MS change it (0 disables the sweep) |
Save preflight and server serialization count the pretty-printed UTF-8 bytes, including the final newline, before allocating the complete JSON string or encoded buffer. Node budgets count containers and values across cells; shared values count at every occurrence. Live JSON outputs and their rendered text are also checked before formatting. The 250,000-node JSON MIME limit is a structural budget, not a promise to open arbitrary Plotly payloads: in the x/y two-array shape, 124,994 points are accepted and 124,995 are rejected. A notebook whose compact form fits 32 MiB but whose pretty-printed form exceeds it can be opened but not saved.
There is no build step for the viewer. The one generated artifact is the vendored KaTeX chunk client.katex.js, regenerated only when the pinned dev dependency is upgraded. DSH caches registered bundles, so after changing client.js, client.katex.js or host-side code, reload the dsh-bsb-ipynb plugin (or restart DSH) to apply it; after client changes also hard-refresh the page (Ctrl/Cmd+Shift+R).
for file in index.js lib/*.js client.js client.katex.js; do node --check "$file"; done
python -m py_compile python/bridge.py
npm test # run the complete unit and integration suite
npm install # Playwright and KaTeX (dev-only) for the E2E lane and chunk rebuilds
npm run test:e2e # isolated DSH 0.2.2-rc.3 + dsh-better-sidebar 0.32.1
npm run build:katex # regenerate client.katex.js after a deliberate KaTeX upgrade
The default E2E command above uses the normal workspace root. To exercise the host-selected alternate-root compatibility lane, run DSH_IPYNB_E2E_WORKTREE=1 npm run test:e2e on macOS/Linux; in Windows PowerShell, use $env:DSH_IPYNB_E2E_WORKTREE='1'; npm run test:e2e.
The browser E2E creates a temporary DSH_HOME, installs this checkout plus the pinned dsh-better-sidebar into a fresh Web profile, boots dsh on a free port, checks the viewer settings panel, opens a generated notebook through the real file tree, renders a local image through the confined route, loads the KaTeX chunk and checks the host stylesheet applies, and runs it through the editor-header Run all action, checks the Kernels page, creates another notebook from a directory row action and asserts the first notebook's autosaved output with the real Python kernel. It needs Google Chrome, network access for the first pnpm install, and a DSH CLI (DSH_E2E_DSH_BIN, or DSH_INSTALL_DIR + DSH_NODE_EXECUTABLE when run inside DSH Desktop). Update PINNED_DSH / PINNED_BSB in test/e2e/run.mjs when upgrading deliberately; the client runtime guard rejects older Better Sidebar builds. Set DSH_E2E_KEEP=1 to keep the temporary DSH home for inspection. Run it after any DSH / Better Sidebar bump and before a release; CI runs the three-OS unit matrix plus this pinned E2E lane.
The theme tests in test/client-theme.test.mjs resolve the injected stylesheet against the stock palette fixture in test/fixtures/dsh-theme-tokens.json; update that fixture deliberately when the DSH palette changes. Real-kernel tests skip automatically when no candidate interpreter provides jupyter_client/ipykernel; schema tests that need nbformat skip as well. Set DSH_IPYNB_TEST_PYTHON to choose the interpreter used by tests; in CI, set it explicitly and check for unexpected skips. CI runs the suite on ubuntu-latest, windows-latest and macos-latest. The ~28 case-sensitivity regression tests in test/control-symlink.test.mjs run only on case-insensitive file systems (macOS APFS, Windows NTFS) that also allow symlink creation; on Linux or a Windows account without Developer Mode they skip through the capability probe. The access-control cases in test/routes.test.mjs that need a non-root user skip automatically when the suite runs as root.
The math tests in test/client-math.test.mjs evaluate the shipped client.katex.js chunk in a VM, exercise inline/display delimiters, code-span and currency exclusions, the text/latex output path and the lazy-loader retry contract; the E2E additionally asserts that the real host stylesheet styles the rendered formula.
See CHANGELOG.md for release notes and CODE_REVIEW.md for current unresolved issues and verification evidence.
Issues and pull requests are welcome. See CONTRIBUTING.md for setup, tests and PR guidelines, and report security issues privately as described in SECURITY.md. Keep the client bundle hand-written and build-free (no bundler or new runtime dependencies).
MIT © 2026 dsh-bsb-ipynb authors — see LICENSE.
python/bridge.py and parts of the rendering algorithms are adapted from the MIT-licensed dong-victor/dsh-better-sidebar-jupyter; the design references kikulmj/dsh-jupyter (Apache-2.0). Full attribution and upstream license texts are in NOTICE.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。