← 返回 Skills 市场
k-kolomeitsev

Data Structure Protocol (DSP)

作者 k-kolomeitsev · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
222
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install data-structure-protocol
功能描述
Build and navigate DSP (Data Structure Protocol) — graph-based long-term structural memory of codebases for LLM agents. Stores entities (modules, functions),...
使用说明 (SKILL.md)

Data Structure Protocol (DSP)

DSP builds a dependency graph of project entities in a .dsp/ directory. Each entity (module, function, external dependency) gets a UID, description, import list, and export index. The graph answers: what exists, why it exists, what depends on what, and who uses what.

DSP is NOT documentation for humans or AST dump. It captures meaning (purpose), boundaries (imports/exports), and reasons for connections (why).

Agent Prompt

Embed this context when working on a DSP-tracked project:

This project uses DSP (Data Structure Protocol). The .dsp/ directory is the entity graph of this project: modules, functions, dependencies, public API. It is your long-term memory of the code structure.

Core rules:

  1. Before changing code — find affected entities via dsp-cli search, find-by-source, or read-toc. Read their description and imports to understand context.
  2. When creating a file/module — call dsp-cli create-object. For each exported function — create-function (with --owner). Register exports via create-shared.
  3. When adding an import — call dsp-cli add-import with a brief why. For external dependencies — first create-object --kind external if the entity doesn't exist yet.
  4. When removing import / export / file — call remove-import, remove-shared, remove-entity respectively. Cascade cleanup is automatic.
  5. When renaming/moving a file — call move-entity. UID does not change.
  6. Don't touch DSP if only internal implementation changed without affecting purpose or dependencies.
  7. Bootstrap — if .dsp/ is empty, traverse the project from root entrypoint via DFS on imports, documenting every file.

Key commands:

dsp-cli init
dsp-cli create-object \x3Csource> \x3Cpurpose> [--kind external] [--toc ROOT_UID]
dsp-cli create-function \x3Csource> \x3Cpurpose> [--owner UID] [--toc ROOT_UID]
dsp-cli create-shared \x3Cexporter_uid> \x3Cshared_uid> [\x3Cshared_uid> ...]
dsp-cli add-import \x3Cimporter_uid> \x3Cimported_uid> \x3Cwhy> [--exporter UID]
dsp-cli remove-import \x3Cimporter_uid> \x3Cimported_uid> [--exporter UID]
dsp-cli remove-shared \x3Cexporter_uid> \x3Cshared_uid>
dsp-cli remove-entity \x3Cuid>
dsp-cli move-entity \x3Cuid> \x3Cnew_source>
dsp-cli update-description \x3Cuid> [--source S] [--purpose P] [--kind K]
dsp-cli get-entity \x3Cuid>
dsp-cli get-children \x3Cuid> [--depth N]
dsp-cli get-parents \x3Cuid> [--depth N]
dsp-cli search \x3Cquery>
dsp-cli find-by-source \x3Cpath>
dsp-cli read-toc [--toc ROOT_UID]
dsp-cli get-stats

Using the CLI

The script is at scripts/dsp-cli.py relative to this skill directory.

python \x3Cskill-path>/scripts/dsp-cli.py [--root \x3Cproject-root>] \x3Ccommand> [args]

--root defaults to current working directory. All paths in arguments are repo-relative.

Core Concepts

  • Code = graph. Nodes are Objects and Functions. Edges are imports and shared/exports.
  • Identity by UID, not file path. Path is an attribute; renames/moves don't change UID.
  • "Shared" creates an entity. If something becomes public (exported), it gets its own UID.
  • Import tracks both "from where" and "what". One code import may create two DSP links: to the module and to the specific shared entity.
  • Full import coverage. Every imported file/asset must be an Object in .dsp — code, images, styles, configs, everything.
  • why lives next to the imported entity in its exports/ directory (reverse index).
  • Start from roots. Each root entrypoint has its own TOC file.
  • External deps — record only. kind: external, no deep dive into node_modules/site-packages/etc. But exports index works — shows who imports it.

UID Format

  • Objects: obj-\x3C8 hex> (e.g., obj-a1b2c3d4)
  • Functions: func-\x3C8 hex> (e.g., func-7f3a9c12)

UID marker in source code — comment @dsp \x3Cuid> before declaration:

// @dsp func-7f3a9c12
export function calculateTotal(items) { ... }
# @dsp obj-e5f6g7h8
class UserService:

Workflows

Setting Up DSP

  1. Run dsp-cli init to create .dsp/ directory.
  2. Identify root entrypoint(s) — package.json main, framework entry, etc.
  3. Run bootstrap (DFS from root). See bootstrap.md.

Creating Entities (when writing new code)

  1. Create module: dsp-cli create-object \x3Cpath> \x3Cpurpose>
  2. Create functions: dsp-cli create-function \x3Cpath>#\x3Csymbol> \x3Cpurpose> --owner \x3Cmodule-uid>
  3. Register exports: dsp-cli create-shared \x3Cmodule-uid> \x3Cfunc-uid> [\x3Cfunc-uid> ...]
  4. Register imports: dsp-cli add-import \x3Cthis-uid> \x3Cimported-uid> \x3Cwhy> [--exporter \x3Cmodule-uid>]
  5. External deps: dsp-cli create-object \x3Cpackage-name> \x3Cpurpose> --kind external

Navigating the Graph (when reading/understanding code)

  • Find entity by file: dsp-cli find-by-source \x3Cpath>
  • Search by keyword: dsp-cli search \x3Cquery>
  • Read TOC: dsp-cli read-toc → get all UIDs, then get-entity for details
  • Dependency tree down: dsp-cli get-children \x3Cuid> --depth N
  • Dependency tree up: dsp-cli get-parents \x3Cuid> --depth N
  • Impact analysis: dsp-cli get-recipients \x3Cuid> — who depends on this entity
  • Path between entities: dsp-cli get-path \x3Cfrom> \x3Cto>

Updating (when modifying code)

  • Purpose changed: dsp-cli update-description \x3Cuid> --purpose \x3Cnew>
  • File moved: dsp-cli move-entity \x3Cuid> \x3Cnew-path>
  • Import reason changed: dsp-cli update-import-why \x3Cimporter> \x3Cimported> \x3Cnew-why>

Deleting (when removing code)

  • Import removed: dsp-cli remove-import \x3Cimporter> \x3Cimported> [--exporter UID]
  • Export removed: dsp-cli remove-shared \x3Cexporter> \x3Cshared>
  • File/module deleted: dsp-cli remove-entity \x3Cuid> (cascading cleanup)

Diagnostics

  • dsp-cli detect-cycles — circular dependencies
  • dsp-cli get-orphans — unused entities
  • dsp-cli get-stats — project graph overview

When to Update DSP

Code Change DSP Action
New file/module create-object + create-function + create-shared + add-import
New import added add-import (+ create-object --kind external if new external dep)
Import removed remove-import
Export added create-shared (+ create-function if new function)
Export removed remove-shared
File renamed/moved move-entity
File deleted remove-entity
Purpose changed update-description
Internal-only change No DSP update needed

References

安全使用建议
This skill appears to do what it says: it creates and updates a .dsp/ graph inside the repo and does not contact external services or require secrets. Before installing or using it, (1) review and back up your repository (or run in a sandbox) since the agent will create/modify .dsp/ files in-place, (2) verify you are comfortable with an autonomous agent modifying project metadata, and (3) if you want stricter controls, run dsp-cli manually rather than allowing autonomous invocation so you can review changes before committing them.
功能分析
Type: OpenClaw Skill Name: data-structure-protocol Version: 1.0.0 The skill bundle implements the 'Data Structure Protocol' (DSP), a system for AI agents to maintain a graph-based map of a codebase's structure (modules, functions, and dependencies) within a local .dsp/ directory. The core logic in scripts/dsp-cli.py uses standard Python libraries (pathlib, shutil) to manage metadata files and directories; it contains no network calls, shell execution, or obfuscation. The instructions in SKILL.md and the reference documentation are consistent with the stated purpose of codebase mapping and do not attempt to subvert the agent or exfiltrate sensitive data.
能力评估
Purpose & Capability
The name/description (graph-based memory for codebases) matches the provided CLI and docs. The script implements UID generation, TOC management, imports/exports bookkeeping and bootstrap traversal — all expected for this functionality. No unrelated credentials or binaries are requested.
Instruction Scope
SKILL.md instructs the agent to run the local dsp-cli and to read/update the .dsp directory and project files; those actions are appropriate for maintaining a structural memory. The instructions do not direct the agent to read unrelated system files, environment secrets, or to transmit data externally. (Minor doc quirk: examples include an invalid hex character in a UID example, but this is non-security.)
Install Mechanism
There is no install spec; the skill is instruction-only plus a local Python CLI script. No remote downloads, package installs, or external taps are used.
Credentials
The skill declares no required environment variables, credentials, or config paths. The CLI operates on repository-relative paths and writes only into .dsp under the project root, which is proportionate to the stated goal.
Persistence & Privilege
always:false (normal). The CLI writes persistent state into the repository's .dsp directory and can be invoked by the agent autonomously. This is expected for a tool that maintains project memory, but users should be aware the agent can modify .dsp files when invoking the skill.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install data-structure-protocol
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /data-structure-protocol 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of the Data Structure Protocol (DSP) skill. - Introduces DSP as a codebase graph for long-term structural memory (entities, dependencies, APIs, reasons). - Details core DSP concepts, UID system, and strict CLI-driven workflows for creating, modifying, and navigating code structure. - Provides a comprehensive agent prompt with usage rules and safety checks for DSP-tracked projects. - Documents setup, updates, deletion scenarios, and diagnostics commands for maintaining DSP integrity. - Includes references for storage format, bootstrap procedure, and supported operations.
元数据
Slug data-structure-protocol
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Data Structure Protocol (DSP) 是什么?

Build and navigate DSP (Data Structure Protocol) — graph-based long-term structural memory of codebases for LLM agents. Stores entities (modules, functions),... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 222 次。

如何安装 Data Structure Protocol (DSP)?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install data-structure-protocol」即可一键安装,无需额外配置。

Data Structure Protocol (DSP) 是免费的吗?

是的,Data Structure Protocol (DSP) 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Data Structure Protocol (DSP) 支持哪些平台?

Data Structure Protocol (DSP) 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Data Structure Protocol (DSP)?

由 k-kolomeitsev(@k-kolomeitsev)开发并维护,当前版本 v1.0.0。

💬 留言讨论