cong7781/novel: Character Relationship Extraction and Interactive Graph Visualization from Chinese Narrative Texts

Introduction

When analyzing Chinese long-form texts in DSH, a common practice is to paste entire sections into the conversation and let the model verbally summarize character relationships. As texts get longer, they exceed the context window; relationships often lack anchors in the original text, making them difficult to verify afterwards. The community plugin cong7781/novel (npm package name dsh-character-graph) addresses this: it extracts characters and relationships from narrative texts, renders them as clickable and draggable force-directed graphs within the conversation, and requires each edge to include evidence that can be verified verbatim against the original text. Edges that cannot be verified are discarded and counted in the statistics, rather than silently fabricated.

What Is This

cong7781/novel is published by maintainer cong7781 and categorized as Model Inference in the SkillHub plugin directory, with the tagline “Long-form relationship graph extraction.” The plugin uses the default model already configured in the host DSH (ctx.llm), without requiring separate API keys or local inference services; API costs are billed to the user’s own account. Current version 0.3.0 (2026-10-21), licensed under MIT, requires Node.js ≥ 20.

GitHub repository: https://github.com/cong7781/novel. DSH registers tools by the name field in package.json, so the tool name appearing in conversations is dsh-character-graph; the installation spec still uses github:cong7781/novel.

Core Features

In-Conversation Relationship Graphs (Included in Install Package)

Once installed into a profile, extraction can be triggered via the tool extract_characters({ path }) or by pasting text. Results are displayed as tool cards: nodes can be clicked to view a character’s relationships, and clicking a second person shows the original-text evidence between the two; the card provides ?pair= deep links, discard counts, and more. The hard text limit is 600,000 characters (MAX_CHARS); exceeding it raises an error explaining the reason, without silent truncation.

The plugin distribution is a pre-built client with zero npm dependencies (lib/client.js already bundles d3-force), requiring no build step or additional third-party packages at install time.

Three Text Scale Tiers

Text Scale Mechanism Notes (from README empirical summary)
≤ 8,000 chars Single ctx.llm call Full text passed in one prompt
8,000 – 50,000 chars Sliding window chunking ~3,500 chars/chunk, 12% overlap, per-chunk gating then global merge
50,000 – 600,000 chars Retrieval (RAG) Character scan → character-bigram BM25 retrieves candidate chunks → close reading of selected chunks → merge

The README documents a full-scale test on 600k chars (concurrency 6): 195 chunks / 207 API calls / 664k input tokens / ~$0.42 / 118s, with 100% verbatim evidence verification pass rate. Running a full-length novel for two minutes in a chat tool is inappropriate, so the repo additionally provides a web frontend and CLI (see “Use Cases” below), not included in the npm package.

Pipeline and Evidence Gate

The processing flow can be summarized as: text normalization → sliding-window chunking → (for long texts) character scan and BM25 retrieval → fine extraction on selected chunks → per-chunk evidence gate → alias resolution and global merge (up to 3 evidence entries per character pair).

Each edge must carry evidence, which must appear verbatim in the original chunk text the model saw at extraction time; otherwise it attempts re-anchoring with the longest common substring ≥12 characters, and if that still fails, the edge is discarded. Chunking does not relax this rule; discard reasons are categorized and displayed in both the UI and CLI (e.g., evidence-not-in-source, duplicate-evidence, pair-cap, etc.). The denominator of evidencePassRate only counts verification-failure discards, separately from strategic discards (duplicates, caps).

BM25 is chosen for long-text retrieval rather than embeddings because, per the README, the provider lacks an embedding API, and Chinese-name queries suit character-bigram exact matching better, with fast index rebuilds and zero additional dependencies.

Installation and Activation

From the DSH plugin page sidebar, or via plugin_manager in conversation, you can use any of the following sources (original installation instructions):

# 1) Install from GitHub (recommended)
github:cong7781/novel

# 2) Install from npm
dsh-character-graph

# 3) Local directory (for development, absolute path example)
D:\code\dsh-character-graph

After installation, it is enabled by default as a new bundle and written into the profile’s package.json / cordis.patch.yml. Install and start/stop operations are profile-level actions requiring danger-full-access or per-action approval. When using the github: shorthand, DSH first probes repository connectivity; if you encounter Permission denied (publickey), switch to https://github.com/cong7781/novel or configure an SSH key.

Prerequisite: The host DSH must have a default model configured. The plugin runs with the current DSH process permissions; before installing, review the repository source code and MIT license to ensure compliance with your security and compliance requirements.

Typical Usage

1. Extract in Conversation (Ready to Use After Install)

In a DSH conversation where the plugin is installed, ask the agent to call extract_characters, passing a local file path or pasted narrative text. The card directly displays the relationship graph and evidence; suitable for texts under 10k characters or paragraphs where you can accept longer wait times.

2. Repository CLI (Requires Cloning the Full Repository)

The install package does not include the CLI. If you have the full project directory locally (including scripts/), you can use the built-in sample to verify all three modes:

node scripts/extract-cli.mjs --path fixtures/sample.txt --out out/runs/m1-single-final --mode single
node scripts/extract-cli.mjs --path fixtures/sample.txt --out out/runs/m1-chunk-final  --mode chunk
node scripts/extract-cli.mjs --path fixtures/sample.txt --out out/runs/m1-rag-final    --mode rag

For long-text RAG, retrieval-plan-only mode, --max-blocks budgeted close reading, and --resume checkpointed runs, see the extract-cli.mjs examples in the README. Each run leaves JSON intermediate artifacts under out/runs/<name>/ (manifest.json, cast.json, blocks/, result.json, etc.); existing chunks are reused only when text hash, mode, and model match.

3. Local Web Viewer (Requires npm install After Cloning)

In the repository directory, run:

node scripts/serve.mjs

The server listens on 127.0.0.1:19401, requires esbuild-related dependencies and a DeepSeek key (or local ~/.dsh/.credentials.yaml). The page provides file selection/paste, progress bar, a statistics panel below the graph, and loading of historical artifacts from out/runs/; two consecutive clicks on the graph show a single character’s relationships and the evidence between two characters respectively.

Use Cases and Notes

Suitable for: Character relationship mapping in Chinese novels, scripts, and long narratives; scenarios requiring “relationships + original-text citations” rather than pure summaries; developers who have already configured models in DSH and want relationship graphs to appear directly in conversations.

Notes:

  • The community directory SkillHub has no official affiliation with DeepSeek / 幻方 (High-Flyer); the ecosystem philosophy is “everything is a plugin,” and this article introduces the community-maintained cong7781/novel.
  • For ultra-long texts, prefer the repository CLI or local viewer to avoid long-running conversation tool calls.
  • When HMR is enabled, the plugin takes effect immediately; if the host requires a restart to read the new lib/index.js, follow the README “Limitations” section.
  • Cost estimates in the README are calculated at DeepSeek official peak pricing; you can override with environment variables CHARACTER_GRAPH_PRICE_INPUT / CHARACTER_GRAPH_PRICE_OUTPUT / CHARACTER_GRAPH_PRICE_CACHE_HIT.

Conclusion

cong7781/novel (dsh-character-graph) turns “Chinese narrative → character relationship graph → verifiable original-text evidence” into an installable model-inference plugin within DSH, backed by chunking, BM25 retrieval, and a strict evidence gate to support up to roughly 600k characters. For further details on capabilities and empirical data, see the plugin directory page and GitHub repository:

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

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

Xiaoye