OpenViking
volcengine
Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:duyanta123/dsh-refactor-insight
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 简体中文
A DSH skill plugin: turns codebase smells into an executable refactoring plan with locations, priorities, and dependency ordering — a structural health check, not a diff review.
Turn codebase smells into an executable, priority-ordered refactoring plan.
Complementary by design: arch-doc looks at whole-repo structure (understanding the current state), existing code-review tools look at PRs/diffs (gating changes), and this plugin looks at whole-repo smells (outputting an action plan).
It answers:
Boundaries (red lines): outputs a plan only — never modifies code automatically; high-risk refactoring items are flagged by the LLM and require human confirmation. The script only yields hard facts (deterministic scanning, all six rule thresholds overridable); severity / cost / suggested actions are added by the LLM after pruning false positives, marked as inference.
Six deterministic smell rules (zero-dependency heuristics):
arch-profile --deps output; hub modules by in/out degree + Tarjan cycle detection)As a DSH plugin (recommended):
dsh plugin --profile web add "github:duyanta123/dsh-refactor-insight#v0.2.0"
Or from npm:
npm install dsh-refactor-insight
Compatibility tiers: the standalone diagnostic scripts (refactor-smell.mjs / arch-profile.mjs) run on Node.js >= 18; as a DSH 0.2.1-rc.2 plugin it is verified with Node.js >= 22.19. Run npm run test:compat to execute an isolated-profile add, dump-config, and startup smoke test.
Local development: add "dsh-refactor-insight": "file:<local-path>/dsh-refactor-insight" to the profile's package.json and "dsh-refactor-insight" to the bundles array.
After installing, restart the profile and tell the agent:
Use refactor-insight to health-check /path/to/repo
The skill runs a four-phase runbook (intake → scan → diagnose → prioritize & orchestrate) and generates REFACTOR-PLAN.md following the docs/refactor-plan-template.md skeleton.
# All six rules
node scripts/refactor-smell.mjs <repo_path>
# Reuse arch-profile's dependency output for coupling/cycle detection
node scripts/arch-profile.mjs <repo_path> --deps > deps.json
node scripts/refactor-smell.mjs <repo_path> --deps-json deps.json
| Option | Default | Description |
|---|---|---|
--max-lines <N> |
400 | Oversized file threshold (lines) |
--max-func-lines <N> |
80 | Long function threshold (body lines) |
--max-nesting <N> |
5 | Deep nesting threshold (indent/brace depth) |
--max-methods <N> |
10 | God object threshold (class method count) |
--max-class-lines <N> |
300 | God object threshold (class body lines) |
--max-coupling <N> |
4 | High-coupling threshold (in/out degree) |
--max-depth <N> |
4 | Directory scan depth (1–10) |
--include-dirs <a,b> |
- | Analyze only these directories |
--exclude-dirs <a,b> |
- | Extra excluded directories |
--deps-json <file> |
- | Reuse arch-profile --deps output for coupling/cycle detection |
Sample output (excerpt):
{
"language": "javascript/typescript",
"smells": [
{
"rule": "god-object",
"type": "god_object",
"path": "src/lib/GodService.js",
"name": "GodService",
"methods": 12,
"threshold": 10,
"severity": 2,
"cost": "M"
}
]
}
REFACTOR-PLAN.md: a structured refactoring plan with the fixed skeleton of summary → findings table (location/type/evidence/severity/cost/suggested action/risk) → priority ordering → dependency-ordered orchestration → appendix (rule thresholds, scan scope, generation time).
No coupling/cycle findings?
That rule needs a dependency graph as input: run node scripts/arch-profile.mjs <repo_path> --deps > deps.json first, then pass it via --deps-json deps.json (see Quick Start).
The findings include false positives?
By design: the script emits deterministic hard facts, and false-positive pruning is the LLM's job in the runbook phase (checked one by one with added context); when using the CLI alone, judge by the severity / cost fields plus the rule-specific fact fields (e.g. lines, max_depth, methods).
Many TODO/FIXME density findings? That rule is a noise metric (per-1k-line counts plus the first marker line) and does not require action; it carries the lowest weight in plan ordering.
Old sessions won't open after upgrading the DSH host to 0.1.5.x? The Session format V3 migration is irreversible and is host behavior; back up session logs before upgrading the host (see the 0.1.3 entry in CHANGELOG.md).
REFACTOR-PLAN.md output skeletonCLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: file。