dsh-project-anchor: Auto-detect project ownership from the first message of a new session and inject context

Introduction

When working on multiple work items in parallel in DeepSeek Harness (DSH) for a long time, starting a new session often requires manually explaining “which project this is.” If the affiliation isn’t attached, the conclusions produced will land in the ledger without a project field, making post-hoc retrieval and resuming difficult. The common practice is to mention the project name in the first sentence of each session, or click “Attach” in the tab, but this is easily forgotten, and the model cannot get information like the period, finalized definition, and restricted areas from the project card in the first round.

“Project Anchor” (dsh-project-anchor) is a DSH memory plugin released by maintainer lvguqingyou: it anchors a session to a project. When the first sentence of a new session arrives, it automatically determines whether it belongs to an existing project based on ID, project name, alias, directory, or lexical evidence, and then injects a summary or a line of prompt as needed. Below is an introduction to its positioning, capabilities, installation, and typical usage.

What is this

  • Name: dsh-project-anchor (UI text: Project Anchor / Project anchor)
  • Category: Memory (Community directory SkillHub)
  • Repository: github.com/lvguqingyou/dsh-project-anchor
  • Current Version (docs): 0.2.1, License MIT
  • Engine Requirements: DSH >=0.2.0-rc.2 <0.3.0, Node >=20

The plugin maintains append-only facts for project registration tables, project cards, indexes, and affiliations under the workspace _ledger\. It provides tools to read/write affiliations and rebuild views. There is an additional “Project Anchor” tab in the conversation view for viewing affiliations, attaching, and the ledger panel.

Core Features

Session Anchoring and Project Registration

Tool Purpose
project_attach Attach this session to a specified project (project name, directory name, alias, or P2026-01, etc.); cancel means to detach
project_register Register a new project: write a line to the registration table and generate a project card; by default, it also attaches the current session; no need for a directory to exist first
project_status Read project card summary (period, finalized definition, restricted areas, resumption points) and the latest index node; reads the currently anchored session project by default

Affiliation is based on _ledger\affiliation.jsonl (latest in the same session). Automatic attachment is append-only; if written incorrectly, use project_attach to override or detach.

Automatic Determination for New Sessions (P5)

When the first user message of a new session arrives, if autoMatch is enabled, the plugin determines if it resembles a registered project and acts according to the tier (the first three tiers are handled by decideMatch, the fourth tier combines with unattached conclusions within the session):

Tier Behavior Summary
attach When evidence of being named and scores/lead are met, automatically write a high-confidence affiliation; the next round will bring that project’s context
hint When only lexical similarity is detected, do not write affiliation, but inject “likely related project + basis + key points on card” for the model to confirm in one sentence in the first round
new-project If no existing project matches, and the session has ≥2 real-user messages and ≥2 unattached conclusions, prompt to register or attach (once per session)
none If it resembles nothing yet and no output has been generated, do not inject

Determination only handles real-user speech (e.g., user/message), ignoring runtime context backfilling, agent instructions, etc., to avoid treating the plugin’s own prompts as user speech. Attachment is only automatically executed when “messages processed ≤ 1 and turns ≤ 1”. The cost of guessing wrong is higher than asking one more question, so affiliation is only written automatically with high confidence.

Lexical matching uses 2-grams weighted by project rarity (idf), and filters out generic words, stopwords, segmentation errors, etc., to reduce false positives. Pure English project name fragments do not participate in name matching; the full name or ID must be used for identification.

Context is injected via systemPrompt.context({ name: 'project:anchor', order: 100 }): if already anchored, give project summary; if not anchored but there is a hint, give renderAutoHint; otherwise do not inject.

Index, Suggestions, and Views

Tool Purpose
project_suggest Based on unattached ledger conclusions in the current session, cluster “independent project-like” candidates (suggestion only, not written to disk)
project_rebuild Rebuild 索引.md / 自由会话.md from append-only facts
project_ping Check if host is online and index file status

Data files include 项目登记表.md, 项目卡-<编号>.md, 索引.jsonl, 归属.jsonl, and the two Markdown views mentioned above.

“Project Anchor” Tab

Display session affiliation, attachable projects, card creation suggestions, and ledger panel in conversation.view (order 6); text follows Client locale (dsh-project-anchor namespace). When anchored, the page header has a granularity switch “Summary / Full Project Card” (effective only for this process, corresponding to the memory override of config item contextMode, not written to disk).

Installation and Enabling

Requires DSH version to satisfy engines.dsh in package.json. @deepseek-ai/schemastery is shared with the host; do not install it as a standalone dependency.

# Install from npm (recommended)
#   plugin_manager install_bundle { target: "dsh-project-anchor@0.2.1" }

# Install from GitHub (by release tag; when npm is unreachable)
#   plugin_manager install_bundle { target: "git+https://github.com/lvguqingyou/dsh-project-anchor.git#v0.2.1" }

# Local tarball (npm pack first)
dsh plugin install ./dsh-project-anchor-0.2.1.tgz

After installation, use project_ping to confirm live: true, indexRows is not 0, and ledger.route.status === 'registered'.

Common host-side configuration:

Key Default Description
autoMatch true Master switch for automatic determination on the first sentence of new sessions
autoMatchTurns 3 Still allow determination within the first few turns (including the fourth tier)
contextMode 'digest' Initial value of injection granularity
publishCatalog false Whether to project the project list to the catalog
catalogThrottleMinutes 10 Minimum interval for projection (minutes)

Typical Usage

  1. Manual Attachment: When the project is known for a new session, call project_attach and pass the project name, alias, or ID to project.
  2. Create New Workline: When there is no existing card, use project_register to register and attach the session, no need to create a directory first.
  3. Review Before Resuming: Use project_status to check period, restricted areas, resumption points, and recent index.
  4. Automatic Path: If the first sentence contains an ID or the full name/alias of a project, high confidence may lead to automatic attach; when only keywords hit, a hint will appear in the first round, requiring confirmation by the model or you before project_attach.
  5. Worked all day without affiliation: When conditions for the fourth tier are met, it will prompt to use project_register or project_attach; you can also use project_suggest to see candidates.
  6. View Out of Sync: After changing affiliation or a large amount of bookkeeping, execute project_rebuild to refresh the Markdown views.

Scenarios and Notes

Suitable for: DSH users working on multiple projects in parallel, relying on ledgers and project cards for resumption; scenarios where you want to reduce repeating explanations in the first sentence and have the model include project definitions in the first round.

Notes:

  • The plugin reads and writes the workspace under current DSH process permissions; please check the source code and MIT license before installation and assess whether your environment meets the requirements.
  • The browser settings page cannot directly write to the workspace (sandbox FS_SANDBOX_DENIED), and the tab granularity switch is not persistent; you must change the contextMode configuration to save the injection granularity long-term.
  • When using ctx.fs, the directory type is 'directory'; do not confuse it with 'dir', otherwise directory registration may be mistakenly rejected (explained in README).
  • The community directory SkillHub is an independent ecosystem site with no official affiliation with DeepSeek / Huafan; DSH itself also takes the direction of “everything is a plugin”, and this package is one of the community bundles.

Conclusion

dsh-project-anchor moves “which project the session belongs to” from post-hoc affiliation backfilling to automatic determination and context injection in the first sentence (and early turns) of new sessions, and works in conjunction with registration, indexing, and tab UI under _ledger. For details, test commands, and implementation boundaries, refer to the repository README.

  • Directory page: https://www.skillhub.cn/plugins/lvguqingyou/dsh-project-anchor
  • GitHub: https://github.com/lvguqingyou/dsh-project-anchor
羽毛球分组比赛记分
小程序二维码

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

Xiaoye