npm packages and DSH plugins both extend the deep toolchain, but they solve different problems. Understanding the distinction helps you choose the right tool for each use case.
Core Difference
npm packages are general-purpose tools; DSH plugins are deep-specific extensions. npm packages solve generic problems, DSH plugins solve specific needs in deep scenarios.
Architectural Differences
- npm packages: general dependencies, independent version management, decoupled from host environment
- DSH plugins: deep lifecycle integration, tightly bound to Cordis runtime
- npm packages: used via import/require, no runtime hooks
- DSH plugins: register lifecycle hooks, respond to deep events
When to Use DSH Plugins?
When you need to inject custom logic into the deep runtime, such as: intercepting API calls, modifying requests/responses, injecting custom tools.
When to Use npm Packages?
When you need general utility functions: data processing, formatting, validation, third-party API integration.
Selection Advice
Ask yourself first: is this need general or deep-specific? General needs → npm packages. Deep-specific needs → DSH plugins. The two can coexist — DSH plugins calling npm packages is a common pattern.
FAQ
<strong>Can DSH plugins use npm packages?</strong> Yes. DSH plugins can import any npm package internally.<br><strong>Can npm packages call DSH plugins?</strong> Not directly, but they can interact indirectly via API.<br><strong>How to choose?</strong> General tools → npm packages. Deep integration → DSH plugins. When in doubt, check the plugin marketplace first.