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).
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
> dsp-cli create-function
> dsp-cli create-shared
> dsp-cli add-import
> dsp-cli remove-import
> dsp-cli remove-shared
> dsp-cli remove-entity
> dsp-cli move-entity
> dsp-cli update-description
> dsp-cli get-entity
> dsp-cli get-children
> dsp-cli get-parents
> dsp-cli search
> dsp-cli find-by-source
> dsp-cli read-toc [--toc ROOT_UID]
> dsp-cli get-stats
> ```
The script is at scripts/dsp-cli.py relative to this skill directory.
python <skill-path>/scripts/dsp-cli.py [--root <project-root>] <command> [args]
--root defaults to current working directory. All paths in arguments are repo-relative.
imports and shared/exports..dsp — code, images, styles, configs, everything.why lives next to the imported entity in its exports/ directory (reverse index).kind: external, no deep dive into node_modules/site-packages/etc. But exports index works — shows who imports it.obj-<8 hex> (e.g., obj-a1b2c3d4)func-<8 hex> (e.g., func-7f3a9c12)UID marker in source code — comment @dsp before declaration:
// @dsp func-7f3a9c12
export function calculateTotal(items) { ... }
# @dsp obj-e5f6g7h8
class UserService:
dsp-cli init to create .dsp/ directory.package.json main, framework entry, etc.dsp-cli create-object dsp-cli create-function # --owner dsp-cli create-shared [ ...] dsp-cli add-import [--exporter ] dsp-cli create-object --kind external dsp-cli find-by-source dsp-cli search dsp-cli read-toc → get all UIDs, then get-entity for detailsdsp-cli get-children --depth N dsp-cli get-parents --depth N dsp-cli get-recipients — who depends on this entitydsp-cli get-path dsp-cli update-description --purpose dsp-cli move-entity dsp-cli update-import-why dsp-cli remove-import [--exporter UID] dsp-cli remove-shared dsp-cli remove-entity (cascading cleanup)dsp-cli detect-cycles — circular dependenciesdsp-cli get-orphans — unused entitiesdsp-cli get-stats — project graph overview| 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 |
.dsp/ directory structure, file formats, TOC共 1 个版本