返回目录
模型与 MCP 插件

dsh-skill-tier

pandarayc/dsh-skill-tier

Progressive disclosure for DSH skill collections: one generated index skill stays in the catalog, every member stays user-invocable but leaves the model catalog. Zero dependencies.

Stars
0
Forks
0
Issues
0
更新
14 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:pandarayc/dsh-skill-tier

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

@pandarayc/dsh-skill-tier

English · 中文

Keep thousands of skills out of every turn's context. Zero dependencies, one file, no source edits.

A DSH skill catalog is a resident message carried on every turn of every session: each model-invocable skill contributes one - `name`: <description> line. A domain with a few dozen skills is expensive:

Collection Members Resident cost
lark-* (bundled with the Lark CLI) 28 +2,901 tokens (51% of the base prompt)
gsd-* (~/.claude/skills) 83 +2,047 tokens

This plugin folds a collection into three tiers:

Tier 0  catalog        one index entry (+78 … +121 tokens)        ← always resident
Tier 1  load index     routing table of every member (~4 KB)       ← paid when relevant
Tier 2  fetch bodies   only the 1–2 members actually needed        ← paid on a hit

Measured reduction: 96% (28 members: 2,901 → 119 tokens), with model discovery intact — members stay user-invocable, so /member-name still loads one directly.

Changes are listed in CHANGELOG.md.

Install

# From source
git clone https://github.com/pandarayc/dsh-skill-tier
dsh plugin --profile web add "$PWD/dsh-skill-tier"

# Or from npm (not published yet)
dsh plugin --profile web add @pandarayc/dsh-skill-tier

# Verify: the inserted row should show up
dsh --profile web --dump-config | grep -A3 skill-tier

An unconfigured install is inert: with no collection configured it produces no candidates and costs no catalog tokens. Collections can come from either of two layers (see below).

examples/*.yml reference the package name, so --patch can overlay configuration on an installed package:

# Package installed: overlay examples onto the installed row
dsh --profile headless --patch examples/lark.yml "just reply OK"

# Not installed yet: point the patch at your clone
sed "s|'@pandarayc/dsh-skill-tier'|'$PWD/lib/index.js'|" examples/lark.yml > /tmp/lark.local.yml
dsh --profile headless --patch /tmp/lark.local.yml "just reply OK"

Run these with headless (or any app that takes a task); --json is a headless flag and the web app does not accept it. Use --dump-config to verify the row in the web profile.

Workspace usage (after the package is installed):

mkdir -p ~/work/feishu/.dsh
cat > ~/work/feishu/.dsh/skill-tier.json <<'JSON'
{ "groups": [{ "name": "lark", "title": "Feishu/Lark entry point",
  "description": "Feishu/Lark entry point ({count} sub-skills)…",
  "dir": "~/.dsh/lark-skills", "members": "lark-*",
  "detailHint": "lark-cli skills read <member>" }] }
JSON
cd ~/work/feishu && dsh --profile web    # this directory carries the index; others do not

Configuration

- insert:
    - id: skill-tier
      name: '@pandarayc/dsh-skill-tier'   # use /path/to/dsh-skill-tier/lib/index.js when not installed
      config:
        revalidateMs: 0                 # optional, see below
        providerName: skill-tier       # optional, unique per layer; see “one row per profile”
        watch: false                   # optional, opt in to mid-session member add/remove refresh
        groups:
          - name: lark                  # index skill name, kebab-case
            title: Feishu/Lark entry point   # heading of the index body
            description: "…the catalog line that says when to load this…"
            dir: "~/.dsh/lark-skills"   # member directory (does **not** have to be a DSH scan root)
            members: "lark-*"           # glob, see below
            detailHint: "lark-cli skills read <member>"   # optional: how to fetch a full body
            rules:                      # optional: extra rules appended to the body
              - "Read lark-shared before any Feishu operation"
            rank: 350                   # optional, lower wins (default 350); see “precedence”
            source: custom              # optional, defaults to custom
Field Required Meaning
providerName Provider name registered with DSH, default skill-tier. Must be unique within a layer, otherwise registration throws (see below)
groups[].name ✅ Name of the index skill; the identity besides its directory, must be kebab-case
groups[].dir ✅ Directory holding the members; ~ supported. Do not also make it a DSH scan root: dsh-skill-filesystem would list the members again and the cost comes back
groups[].description ✅ The catalog line. DSH truncates past 500 characters; the plugin warns at config time. {count} is replaced with the live member count — see “prompt stability” before combining it with watch
groups[].title Index body heading, defaults to name. Also supports {count}
groups[].members Defaults to *. Supports *, prefixes foo-*, exact names, comma-separated lists, and ! exclusions (lark-*,!lark-mindnotes)
groups[].detailHint How the model should fetch a member body. Defaults to a file-path instruction
groups[].rules Rules appended to the index body. Defaults to two rules (read 1–2 members, the body is authoritative)
revalidateMs Default 0: every list() re-checks the member files by content hash. See below
watch Default false. When true, watches collection roots and invalidates the catalog mid-session so a new member is callable without a restart. Off by default because a refresh is the only path that can make DSH republish the resident catalog; see “prompt stability and the KV cache”

Member format matches dsh-skill-filesystem: <dir>/<name>/SKILL.md, or a flat <dir>/<name>.md.

One row per profile

Put every collection under the same config.groups instead of mounting the plugin twice:

# ❌ The second instance fails to register: duplicate provider name in one layer
- insert:
    - id: skill-tier-lark
      name: …/lib/index.js
    - id: skill-tier-gsd      # → “already registered”; the whole instance stays inactive
      name: …/lib/index.js

The DSH skill registry throws on a duplicate provider name within one layer, and the second instance simply does not activate — all you see is warning: 1 entry did not activate. The plugin translates that raw error into an actionable message. If you really need multiple rows, give each a different providerName.

Overlaying with --patch is safe: patch layers are merged by entry id, later layers win. So --patch examples/lark.yml on a profile that already has the package does not register twice — it replaces the installed row's config.

Precedence (rank)

Lower rank wins. DSH's ranks by source:

rank Source
100 <projectRoot>/.dsh/skills
200 <projectRoot>/.agents/skills
250 runtime registrations (ctx.skills.register)
300 profile customSkillDirs
350 this plugin's default
400 ~/.dsh/skills
500 ~/.agents/skills
600 DSH bundled

350 deliberately does not shadow project skills or customSkillDirs. It avoids 300 because at the same rank the winner is decided by provider registration order, which is unpredictable for users.

⚠️ This only settles duplicate names within one layer. The registry is layered by scope: across layers the nearest layer wins outright and rank is not consulted (per the dsh-skill registry docs). So “installed in the profile” and “mounted by an agent preset” behave differently.

To make this plugin never shadow any existing source, set rank: 700 (> 600).

Two configuration layers

Configuration has two sources; the workspace layer overrides the entry layer by name:

Layer Location Scope Typical use
entry config.groups on the skill-tier row in the profile's cordis.patch.yml every session of that profile collections everyone should have
workspace <cwd>/.dsh/skill-tier.json only sessions opened in that directory “carry the Lark index only when I open the Feishu workspace”

The workspace file has the same shape as the entry layer:

{
  "groups": [
    {
      "name": "lark",
      "title": "Feishu/Lark entry point",
      "description": "Feishu/Lark entry point ({count} sub-skills)…",
      "dir": "~/.dsh/lark-skills",
      "members": "lark-*",
      "detailHint": "lark-cli skills read <member>"
    }
  ]
}

It may also override revalidateMs.

Install once, activate per workspace:

~/code/my-project/          no .dsh/skill-tier.json → zero cost
~/work/feishu/              .dsh/skill-tier.json declares lark → one index entry (+78 … +121)

The workspace layer is deliberately uncached: list() runs once or twice per session, so re-reading a small JSON is negligible, while caching would bring back the “I edited the config and nothing happened” trap — the same class of problem the member scan is designed to avoid.

Only <cwd>/.dsh/skill-tier.json is read; no upward search. To have it apply in subdirectories, put the file in the directory you actually open.

What it changes

Nothing on disk. It composes visibility at the provider layer:

Model catalog skill tool User /member-name
Index skill ✅ one line ✅ ✅
Member skills ❌ ❌ ✅

Compare with injecting disable-model-invocation: true into member files:

Editing files This plugin
Source files polluted; rollback needs another sync untouched
Member directory must be a DSH scan root need not be; no contention with dsh-skill-filesystem
Index sync rerun a script computed on every list()

Design notes

  • Content hash, not mtime, decides staleness. Learned the hard way: when a sync script rewrites a file in place with the same length, the filesystem timestamp may not move at all (observed equal mtimeNs within one tick), leaving the index permanently stale. Content hashing has no such window.
  • Every call reads the member files. Before worrying about cost: the registry caches catalogs, so list() runs once in a 4-step session. Measured: 28 members → list() 8.6 ms, get(router) 6.2 ms. Cheap I/O for exact staleness. revalidateMs is an escape hatch for hundreds of members.
  • Refresh is opt-in (watch: false by default). The registry caches list(), so a new member is invisible to /name until a restart unless the provider invalidates the catalog. That refresh is the only path that can make DSH republish the resident skill catalog, so it stays off unless a workspace actually adds skills mid-session. See “prompt stability and the KV cache”.
  • When enabled, watch only the collection roots. One non-recursive fs.watch per directory, used solely to notice members being added or removed. It does not watch file contents (a depth-1 watcher would not see SKILL.md edits anyway) and is persistent: false so it cannot hold the host open. Events are debounced (250 ms) and turned into one registration-scoped invalidate(), outside the collect stack.
  • kebab-case names are mandatory. One bad name (e.g. gsd-extract_learnings with an underscore) makes the whole registry throw. The plugin skips such entries and warns.
  • Provider names are unique per layer. A duplicate throws and deactivates the whole instance while dsh prints only did not activate; the plugin translates that into “one row per profile / use providerName”.
  • Default rank 350, not 300. Same rank as customSkillDirs would make registration order decide.
  • Deliberately no agent/pre-step catalog rewriting. See below.
  • Zero runtime dependencies. Only node:fs/promises, node:fs, node:crypto, node:path, node:os.

Prompt stability and the KV cache

DSH keeps the skill catalog as a durable user message and only republishes when the digest of the model-facing entries (name + capped description, model-invocable only) changes. A republish appends a complete replacement catalog to the history; it is retained, and the replacement plus later turns form a new suffix while the earlier prefix stays reusable. It is not a full-prefix invalidation, but it is still prompt growth that would otherwise not exist — and it is worth not triggering for free.

This plugin separates the two surfaces:

Change Resident catalog line On-demand index body Prompt effect
Member added/removed, static description unchanged changes none — no republish
Member content/body edited unchanged changes on next get() none until the member is loaded
description / group set changed changes changes one replacement catalog

Measured against the real ctx.skills registry: with watch: true and a static description, adding a member mid-session makes it callable and leaves the model-invocable entry set byte-identical, so dsh-tool-skill appends nothing. With {count} in the description, the same add changes the catalog entry and triggers a replacement.

Therefore: keep description static, put {count} in title (the body is loaded on demand), and only turn watch on when you actually need mid-session additions. If both are set, the plugin warns at the first discovery and explains the cost.

Why not filter the catalog instead

“Delete members from <available_skills>” sounds more direct, but it requires rewriting source.kind === 'skill-catalog' messages in agent/pre-step. Measured on 2026-09-27 (DSH 0.1.7-rc.2), that path has a silent failure mode:

dsh-tool-skill's own catalog hook appends the catalog after const decision = await next(). Cordis waterfalls run first-registered outermost, and registration order equals activation order (plugins with inject activate once dependencies are ready), not config order. So:

observed agent/pre-step chain (outer → inner)
  i1 probe (no inject)   i3,i4 dsh-tool-skill   i6 capability-menu-policy

capability-menu sits at i6 (inner) and filters before the catalog is appended → the filter is a no-op. Control experiment: the same filter placed at the outer layer immediately cuts the catalog from 6 to 4 entries. Right classification, wrong position.

So this plugin takes another route: members get invocation.modelInvocable = false and the upstream catalog builder excludes them itself (filter(isModelInvocable) in dsh-tool-skill). That is the upstream contract — no hook-order dependency, no hijacking someone else's message.

Measured numbers

Metric = inputTokens + cacheReadTokens (not inputTokens alone, which is only the uncached part), same trivial prompt:

Scenario prompt tokens Δ
headless baseline (collection absent) 5,695 —
plugin + --patch examples/lark.yml, 28 members folded into one index 5,814 +119
no plugin, 28 members as a project scan root 8,596 +2,901

The index line's cost depends on its description: measured +78 … +121 (+78 for the 83-member gsd group).

Reproduction (the member directory must not be a DSH scan root):

# Control: 28 members as a project scan root (the old way)
mkdir -p /tmp/larktest/.dsh && ln -s ~/.dsh/lark-skills /tmp/larktest/.dsh/skills
cd /tmp/larktest && dsh --profile headless --json "just reply OK"        # expect ≈ 8596

# This plugin: same collection as one index entry
cd /tmp && dsh --profile <with-plugin> --patch examples/lark.yml --json "just reply OK"   # expect ≈ 5814
cd /tmp && dsh --profile headless --json "just reply OK"                                  # baseline ≈ 5695

⚠️ Most common verification mistake: making the same directory both a project scan root and a plugin dir. dsh-skill-filesystem then lists every member anyway (rank 100 beats the plugin's 350) and the plugin looks like it “does nothing”. A member directory belongs to one side or the other.

DSH compatibility

DSH Status
0.2.1-rc.2 / 0.2.1-rc.4 Tested (full functionality: observation objects, path, member-set refresh)
0.2.x Same provider contract; snapshot() gates the observation object
0.1.7 – 0.1.x Legacy path: list() returns a plain array, directory failures count as empty; no path preview

package.json declares "engines": { "dsh": ">=0.1.7-0 <0.3.0" } (the -0 keeps prereleases in range) plus "dsh": { "manifestVersion": 1 }. dsh plugin add / the plugin manager enforce the range; the check was verified with evaluatePluginCompatibility from dsh-app-boot against runtime 0.2.1-rc.2 (compatible) and 0.3.0 (rejected).

Host surface

Item Content
Services registered none (no ctx.provide)
Events emitted none (no ctx.emit)
Dependencies skills (Cordis inject); built-in node:fs, node:fs/promises, node:crypto, node:path, node:os
Host capabilities used ctx.skills.registerProvider; the registration's control.signal (teardown) and control.invalidate (member-set refresh); ctx.logger for warnings
Public surface one skill provider (skill-tier), one bundle patch (cordis.patch.yml); no HTTP route, no client bundle, no tool
Config surface profile row config (groups, providerName, revalidateMs, watch) plus <cwd>/.dsh/skill-tier.json

Exposing no service or event is deliberate: the capability is a skill source, and no other plugin should call into it.

Tests

node test/skill-tier.test.mjs     # 38 cases, no framework dependency

Covers: frontmatter parsing (quotes/colons/block scalars/BOM/multi-line scalars), frontmatter stripped from member bodies, path on summaries and definitions, visibility composition, index rendering, content-hash invalidation, member add/remove, invalid group/member names, unreadable directory → incomplete observation (complete:false) and recovery, ENOENT is not a discovery failure, legacy hosts still receive arrays, shared directory with different members does not cross-contaminate, {count} interpolation, prompt-stable default (member changes do not invalidate), watch + {count} warns about the catalog cost, watcher-driven refresh mid-session, ~ expansion, long-description warnings, ! exclusions, teardown, unconfigured behavior, provider name (default/explicit/invalid fallback/reserved fallback), registration conflicts translated into actionable errors, default rank 350, and workspace layer add/override/per-cwd isolation/bad JSON warned once/revalidateMs override.

Limits

Limit Note
Index table grows linearly Above 100 members the body adds a “split the collection” hint. Index-of-indexes is not implemented
Glob supports only * and ! No ?, {}, or **
One in-memory cache per host process Several processes each scan once (8 ms); not worth a shared cache
Member metadata is not parsed Frontmatter yields only name / description / whenToUse; nested fields such as metadata.requires stay in the file (zero deps, no full YAML)
Watcher (when enabled) sees add/remove, not content Content edits are picked up by the content hash on the next scan; the index body is recomputed on every get()
One row per profile Provider names are unique per layer; use one config.groups or distinct providerNames

Relation to capability-menu

PKUfudawei/dsh-capability-menu is a broader capability-tiering plugin (tools + skills + Web UI). They are upstream/downstream, not competitors:

skill-tier (provider layer)       turns a directory outside any scan root into ctx.skills entries
        ↓
capability-menu (policy layer)    decides how much of those skills appears in the catalog

⚠️ Measured on 2026-09-27 (DSH 0.1.7-rc.2 + capability-menu 0.1.4): capability-menu's skill side did not work — it enumerated with ctx.skills.list({}) (no cwd, so project skills were invisible) and its agent/pre-step catalog filter had no effect even on visible skills. The tool side worked. Version mismatch, not a design fault.

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。