dsh-hindsight-bank-router: Anchoring Hindsight's Bank Identity to Remote Repository Name

Introduction

In the memory ecosystem of DeepSeek Harness (DSH), @vectorize-io/hindsight-coding-agents provides long-term memory for each repository, but its bank name defaults to the local directory name. This causes the same repository to fork into disconnected memory banks due to different clone directory names (e.g., payments-app vs. mobile-client).

This plugin, dsh-hindsight-bank-router, maintained by j62268781-alt, is an MIT-licensed open-source plugin. Its core function is to anchor the Hindsight coding plugin’s bank identity to the remote repository name rather than the local directory name, thereby allowing every clone of the same repository to share the same memory bank.

Core Functions

By dynamically generating the mapPathToBank configuration, the plugin achieves the following capabilities:

  • Anchoring Remote Repository Name: Regardless of the local directory name, it is uniformly resolved to git::<remote-repo-name>.
  • Declarative Priority Chain: Supports priority overrides via user-level workspace files, in-repository .hindsight.json, the git remote name, and the local directory name.
  • Dual-Switch Enablement Mechanism: It only takes effect when both the user-level enableBankRouter and the deployment-level enabled are set to true.
  • Never Overwrites User Configuration: The sidecar state file records the managed scope, and the plugin only deletes entries it generated itself.
  • Zero Subprocess Overhead: Directly reads .git/config without spawning git processes, avoiding timeouts and load issues.
  • Chinese Repository Name Support: Correctly handles URL decoding to support mapping of Chinese repository names.
  • Fail Open: Any exceptions are only logged and do not block DSH startup.

Routing Rules and Priority Chain

When processing bank mappings, the plugin follows a strict priority order. Once a match is found, subsequent lookups stop:

  1. User-Level Workspace File: The bankId in ~/.hindsight/workspaces/<dirname>.json (highest priority).
  2. In-Repository Configuration: The bankId in <workspace>/.hindsight.json.
  3. Git Remote Repository Name: When a .git directory is detected and an origin remote address exists, it generates git::<remote-repo-name>.
  4. Local Directory Name: For non-Git directories or repositories without an origin, it falls back to the default behavior.
  5. Non-Git Directory Default: When allowed by configuration, it generates workspace::<dirname> for direct subdirectories of the root directory.

Note: Explicit configurations (items 1 and 2) have the highest priority and will override subsequent rules regardless of whether it is a Git repository. This serves as the “escape hatch” for manual user intervention.

Enablement Switches

By default, the routing function is disabled and must be explicitly turned on. This requires both switches to be true simultaneously:
* User-Level Master Switch: Set "enableBankRouter": true in ~/.hindsight/coding-agent.json.
* Deployment-Level Switch: Set enabled: true in the config of cordis.patch.yml (usually controlled by the DSH profile).

Installation

This plugin is a supplement to Hindsight; the Hindsight coding plugin must be installed first.

dsh plugin --profile desktop add @j62268781-alt/dsh-hindsight-b

Configuration Example

The plugin automatically scans and merges configurations upon DSH startup. You can override the default behavior through explicit configuration:

{
  "bankId": "custom::my-bank"
}

This configuration will be written to the mapPathToBank field in ~/.hindsight/coding-agent.json.

Security and Limitations

  • No Recursive Scanning: Only direct subdirectories of the root directory are processed; recursion stops immediately upon encountering a .git directory.
  • Non-Git Directory Limitation: The bank name for non-Git directories remains the directory name. Different people with the same directory name might map to the same bank (the plugin does not handle this scenario).
  • Corrupted Configuration Protection: If a config file exists but JSON parsing fails, the plugin will skip it with a warning and will not overwrite existing content.
  • Handling No origin: Repositories without a remote address do not generate a mapping, leaving it to Hindsight’s default logic.

Summary

For developers using DSH, dsh-hindsight-bank-router solves the memory forking problem in Hindsight during multi-terminal collaboration. By anchoring the bank to the objective remote repository name, it ensures that the memories of team members for the same repository are shared and consistent.

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

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

Xiaoye