dsh-py-doctor: Turn Python/Django Production Errors into Structured Diagnostics

Preface

In DeepSeek Harness (DSH), investigating production incidents commonly involves copying tracebacks, pytest summaries, showmigrations output, or SQL debug logs from logs, pasting them into a conversation, and having a human or model read them line by line. This process is prone to errors: copying the wrong line numbers, missing the root cause hidden behind the __cause__ chain, or confusing “the model understood it” with “the text was actually fully parsed.”

dsh-py-doctor is a DSH plugin published by maintainer ax2 (SkillHub directory category: Workflow). It targets this specific type of input: it does not run Python, connect to databases, or execute migrate. Instead, it parses six categories of known syntax report text into structured JSON, accompanied by a coverage receipt indicating “how much was understood.” The following introduces its positioning, six tools, installation methods, and typical usage.

What is this

In short: dsh-py-doctor is an offline, deterministic diagnostic toolkit for Python/Django production errors. It provides 6 tools for DeepSeek Harness; it is purely local, zero-network, bounded, and reproducible.

The plugin does not execute Python, spawn subprocesses, read files, access the network, check the clock, or use random numbers—every tool is a pure function of its input. If the input exceeds the budget, it rejects it (no truncation); lines it cannot understand are listed honestly in unknown_lines (no silent discarding). The npm package version is 0.1.5, licensed under MIT, with 0 GitHub stars currently.

  • Directory Page: https://www.skillhub.cn/plugins/ax2/dsh-py-doctor
  • Source Code & Docs: https://github.com/ax2/dsh-py-doctor

The DSH ecosystem philosophy is “Everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek or Quantwa (Higgsfield).

Core Features: Six tools in the python group

All tool parameters are text (the raw error text, required, pasted inline). The return value is a unified receipt envelope: result contains the parsing results, while meta includes bytesIn, bytesOut, truncated, notes, etc.

Tool Reads Does Not Read
python_traceback CPython tracebacks: exception type/module/message, frame chains, __cause__/__context__ chains, SyntaxError carets, [Previous line repeated N more times], project vs. site-packages frames, root cause hints for common exceptions Non-traceback prose; truncated Traceback (most recent call last is judged as unrecognized
pytest_summary pytest counts, durations, FAILURES/ERRORS, E assertion summaries, short test summary info, --durations Sections not printed in the current run are named in warnings, no guessing
django_migrations showmigrations indented lists, --plan flat lists, DB banners, (no migrations), applied/unapplied and total counts per app, plan_needed --plan has no checkboxes; it will not claim any entry as “applied”
django_sql_n_plus_one Groups repeated queries by normalized statement, providing N+1 candidates, counts, verbs, table names, and raw samples Normalization is lossy, so raw samples are always preserved; it does not issue queries
django_checks manage.py check / check --deploy: levels, diagnostic IDs, messages, HINT, objects, counts per level, deployment checklist items, summaries If summary numbers don’t match the number of findings, both are reported without smoothing over the discrepancy
celery_report inspect active/reserved/ping/stats: workers, task entries and histograms, reserved sections, worker_count, etc. Pure inspect active cannot be distinguished from reserved; only explicit 'reserved': sections are counted as reserved_tasks

The README states that 75 tests pass; each parser has an independent parser_version (e.g., tb-1, pytest-1, migrations-1, sql-1, checks-1, celery-1).

Honest Receipt: Coverage and Budget

Every result includes coverage: total_lines, parsed_lines, unknown_count, unknown_lines (up to 8 samples), unknown_truncated, confidence (the proportion understood, not “how certain the model is”), and parser_version. Unrecognized lines lower the confidence and are not absorbed into structures like frames.

The plugin’s id under the profile, py-doctor, is configurable (all optional): for example, maxInputBytes defaults to 262144, exceeding which throws INPUT_TOO_LARGE; maxFrames defaults to 200, etc. Please refer to the README and repository for specific fields.

Installation and Activation

npm (Recommended):

dsh plugin --profile web add dsh-py-doctor

Pre-built tarball (same artifact as npm):

dsh plugin --profile web add https://github.com/ax2/dsh-py-doctor/releases/latest/download/dsh-py-doctor.tgz

To pin a version, replace latest/download/dsh-py-doctor.tgz in the URL with download/v<version>/dsh-py-doctor-<version>.tgz.

Restart the application after installation (the bundle list is read at startup). The package includes a cordis.patch.yml that inserts id: py-doctor into the profile’s bundle list, registering the 6 tools upon profile load. Runtime environment requires Node >=20.10; peer dependencies include @deepseek-ai/cordis and @deepseek-ai/dsh-tools.

If you wish to install dsh-deterministic-tools, dsh-jvm-doctor, and dsh-win-native together, you can use dsh-toolbox-bundle; do not mix with standalone installation.

Typical Usage

Traceback: Model calls python_traceback

Pass the raw traceback as text. Actual output example from the README (excerpt):

exception_type: KeyError            message: 'user_id'
deepest_frame:  svc.py:42 in handle
cause_hint:     The mapping has no key 'user_id'; production data is usually
                missing the key that test data always has.
coverage:       3/3 lines, 0 unknown, confidence 1 (parser tb-1)

The structured JSON will include exception_type, frames, deepest_project_frame, coverage, etc.; project frames and site-packages frames will have their origin distinguished.

Django N+1: Call django_sql_n_plus_one

Input is multi-line Django SQL logs, for example:

(0.004) SELECT "shop_product"."id" FROM "shop_product" WHERE "shop_product"."order_id" = 11 LIMIT 21; args=(11,)
(0.001) SELECT "shop_product"."id" FROM "shop_product" WHERE "shop_product"."order_id" = 12 LIMIT 21; args=(12,)
(0.001) SELECT "shop_product"."id" FROM "shop_product" WHERE "shop_product"."order_id" = 13 LIMIT 21; args=(13,)

In the output, candidates[0] will be marked n_plus_one: true, providing the normalized statement, count, table name, and one example raw sample line.

How it works in the Harness

After an agent pastes production logs into the conversation, DSH calls the corresponding tool; the model receives auditable JSON with coverage, rather than relying on ad-hoc scripts or secondary conclusions from network queries. The same input always yields the same output, facilitating inclusion in issues, CI, or post-mortem documents.

Applicable Scenarios and Notes

Who it is for: Developers and agent orchestrators who maintain Django/Celery production environments daily and need to quickly structure tracebacks, pytest failure summaries, unexecuted migrations, check --deploy items, SQL N+1 candidates, or Celery inspect outputs within DSH workflows.

Why insist on offline: Reproducible, auditable (no settings.py or DB connection string required), avoids introducing environment discrepancies by running Django locally again, and side-effect free (no migrate, no queries issued, no worker restarts).

Please be aware before installation: The plugin runs with the permissions of the current DSH process. Before installing, you should review the GitHub repository source code and MIT license yourself to ensure it meets your security and compliance requirements. The commands and fields in this introduction come from the public README and package.json; please do not speculate on configurations or versions not present in the materials.

Conclusion

dsh-py-doctor changes “paste logs, human finds lines” to “paste text, get structured diagnosis + coverage”: six tools cover tracebacks, pytest, migrations, N+1 SQL, Django checks, and Celery reports, all offline and bounded. To integrate it into DSH, simply install via dsh plugin --profile web add dsh-py-doctor and restart; for more details, see the SkillHub Directory and GitHub README.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye