Preamble

In the DSH plugin architecture, building a plugin with specific business capabilities usually requires manually orchestrating multiple foundational tools (such as data fetching, causal inference, and document generation). dsh-dcs-engine (Dynamic Capability Synthesis Engine) aims to solve this problem. It can synthesize fragmented foundational tools at runtime into named, registered, reusable, and persistable DSH Capabilities, thereby reducing repetitive boilerplate code and accelerating the development of capability composition.

Positioning

It is the Host Composition Layer of the DSH protocol stack and also the consumer and demonstration carrier of the five core components (CDP, intent network, CSP, ASP, universal-adapter):

  • CDP (ctx.cdpRegistry): consumes semantics (cognitive_style / semantic_tags / boundaries) for candidate scoring.
  • Intent Network (ctx.intentNetwork): reuses its plan() method, or uses the built-in rule topology planning.
  • CSP (ctx.cspStore): only writes decision_trace.
  • ASP (ctx.aspGuard): enforces side_effects review before registering synthesized artifacts.
  • universal-adapter: only consumes its mcp::* tools bridged into ctx.tools.

DCS does not replace any one of these components. Instead, it makes the existing five core components “truly usable” and validates the performance of this protocol stack under composite applications.

Core Capabilities

  1. Synthesis Strategies: supports rule (default, zero LLM overhead), llm, and hybrid strategies.
  2. Materializer (M2 Stage): can already generate a complete deployable dsh-cap-<id> plugin skeleton, including files such as package.json, tsconfig.json, and src/index.ts.
  3. Registration and Reuse: synthesized artifacts can be registered in capabilityRegistry and exposed through defineTool.
  4. Safety Review: synthesized artifacts must pass a ctx.aspGuard review before registration.

Installation and Enablement

Install it through the DSH plugin manager:

dsh plugin --profile web add github:helibeiqi/dsh-dcs-engine

Typical Usage

1. Basic Synthesis and Registration

Taking “analyze the reasons for AAPL decline and generate a Chinese report” as an example, DCS automatically selects foundational components (such as dsh-quant-data-mcp::quote, mcp::causal_inference, and docx_gen::create), plans the topology using built-in rules, generates a stock_causal_report CapabilitySpec, and registers it after passing ASP review.

const registry = ctx.get('capabilityRegistry');
const spec = await registry.synthesizeAndRegister('分析 AAPL 下跌原因并生成中文报告');
const report = await registry.invoke(spec.id, { symbol: 'AAPL' });

2. Export a Complete Plugin Skeleton

Use the Materializer to generate a complete deployable plugin directory:

npx tsx scripts/dcs-synthesize.ts --intent "分析 AAPL 下跌原因并生成中文报告" --persist
# Output to capabilities/stock_causal_report.capability.json

Configuration Options

The plugin supports the following configuration fields:

Field Description Default Value
sources Foundation component sources (such as artifacts in capabilitiesDir) { capabilitiesDir: "./capabilities" }
synthesizer Synthesis strategy (strategy), fallback to LLM, maximum number of candidates { strategy: "rule", fallbackToLLM: true, maxCandidates: 20 }
registry Deduplication (semantic hash), automatic tool registration { deduplicate: true, autoRegisterTools: true }
materializer M2 stage switch, output format { enabled: false, format: "plugin-skeleton" }
safety ASP review requirements, block registration on failure { requireAsp: true, blockOnFail: true }

Note: Only the five fields above are recognized; other fields are invalid.

Safety Notes

  1. Mandatory ASP Review: synthesized artifacts must pass ctx.aspGuard before registration. When safety.blockOnFail is true and the review fails, a SynthesisRejectedError is thrown.
  2. Unknown ASP State Handling: without ASP, safety.asp_verdict = "unknown". If safety.requireAsp=true, the plugin refuses to register.
  3. File Path Whitelist: all file I/O operations are limited to capabilitiesDir and outDir.

Cautions

  • Developer Preview: the M2-stage Materializer can already generate a complete skeleton, but the API may change within the 0.1.x releases. In production environments, wait for the stable 1.0 release.
  • Dependencies: runtime dependencies include @deepseek-ai/cordis >= 0.1.0 and @deepseek-ai/dsh-tools >= 0.1.0.
  • Manual Refinement: the src/index.ts generated by the Materializer uses generic input mapping and may require manual refinement of the exact parameter schema for the tools in each step.

Summary

dsh-dcs-engine provides a mechanism that allows developers to quickly generate DSH plugin skeletons with complex capabilities through intent descriptions. It leverages the DSH five core components through orthogonal collaboration, and its strict safety review mechanism ensures the safety of synthesized artifacts.