dsh-arch-doc 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - npm 包名改为 `dsh-arch-doc`:`arch-doc` 触发 npm 防抢注拦截(与既有包 `archdoc` 去连字符后撞名,403)。插件 id(cordis.patch.yml / providerName)与 GitHub 仓库名保持 `arch-doc` 不变,仅 npm 分发名变更。
6
+ - 新增 `prepublishOnly` 钩子:npm 发布前自动运行测试门禁,防止红测试状态发包。
7
+
8
+ ## 0.1.2 (2026-09-02)
9
+
10
+ - `.gitignore` 补充 `.tmp/` 本地临时产物与 `.env` 类密钥忽略。
11
+ - `package.json` 补充 `repository` / `bugs` / `homepage` 元数据。
12
+ - 新增 GitHub Actions CI(`.github/workflows/ci.yml`):ubuntu + windows × Node 18/22 矩阵运行语法检查与契约测试。
13
+ - 新增 `.editorconfig`(UTF-8 / LF / 2 空格基线)。
14
+ - README 新增「排障」章节:Mermaid 本地渲染、大仓库深度控制、无 Node 降级、入口识别。
15
+ - 新增 `examples/README.md` 与 fixtures 说明。
16
+
17
+ ## 0.1.1 (2026-08-16)
18
+
19
+ - 文档清理:移除内部实现方案稿(arch-doc-实现文档.md),公开文档不再包含本地个人路径。
20
+ - `PUBLISHING.md` 重写:状态更新为「已推送 GitHub、npm 包名可用」,补充 dsh-index 提交步骤与版本变更流程,检查清单勾选已达成项。
21
+ - `README.md` 补充输出产物说明、环境要求与 License。
22
+ - 修复 `test/arch-profile.test.mjs` 字符串字面量跨行导致的语法错误,`npm test` 11 项全部通过。
23
+
24
+ ## 0.1.0 (2026-08-16)
25
+
26
+ - 首个版本:实现 `arch-profile.mjs` 的 probe / scan / deps / entry / all 五类确定性扫描。
27
+ - 提供 `skills/arch-doc/SKILL.md` runbook 与 `docs/architecture-template.md` 输出模板。
28
+ - 内置 Python / Node / Go 三个最小 fixture 与 `node --test` 契约测试。
29
+ - 按 `dsh-data-insight` 同一标准打包(`package.json` + `cordis.patch.yml` + `plugin/index.js`)。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 duyanta123
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/PUBLISHING.md ADDED
@@ -0,0 +1,98 @@
1
+ # 发布与分发指南(PUBLISHING)
2
+
3
+ 本文档记录 `arch-doc` 从源码到分发的完整步骤,供维护者执行。
4
+
5
+ ## 当前状态
6
+
7
+ - 包结构已建成(package.json / cordis.patch.yml / plugin/index.js / skills / docs / scripts / examples / test)。
8
+ - `scripts/arch-profile.mjs` 通过 `node --check`,零依赖、无子进程。
9
+ - `npm test`(node --test)全绿,覆盖 probe / scan / deps / entry / run-methods / output-json / skip-excluded。
10
+ - 源码已推送 GitHub(`main` 分支),npm 包名为 `dsh-arch-doc`(原名 `arch-doc` 触发 npm 防抢注拦截——与既有包 `archdoc` 去连字符后撞名;插件 id 与 GitHub 仓库名保持 `arch-doc` 不变)。
11
+
12
+ ## 前置条件
13
+
14
+ - 能访问 github.com 与 registry.npmjs.org 的终端(或在代理环境下执行 git push)。
15
+ - 已登录 npm:`npm login`(需要 npm 账号 + 2FA)。
16
+ - GitHub 账号(用于建仓库与 push)。
17
+
18
+ ## 步骤 1:发布到 GitHub
19
+
20
+ ```powershell
21
+ # 1) 浏览器打开 https://github.com/new,仓库名 arch-doc,公开,
22
+ # 不要勾选 "Initialize with README / .gitignore / license"(本地已有)。
23
+ cd <你的本地路径>/arch-doc
24
+ git remote add origin https://github.com/duyanta123/arch-doc.git
25
+ git push -u origin main
26
+ git tag v<version>
27
+ git push origin v<version>
28
+ ```
29
+
30
+ ## 步骤 2:发布到 npm
31
+
32
+ ```powershell
33
+ cd <你的本地路径>/arch-doc
34
+ npm view dsh-arch-doc version # 确认包名可用(应 404)
35
+ npm login
36
+ npm publish
37
+ ```
38
+
39
+ ## 步骤 3:安装到 profile(三选一)
40
+
41
+ ```powershell
42
+ # npm 形态
43
+ dsh plugin --profile web add dsh-arch-doc
44
+
45
+ # GitHub 形态
46
+ dsh plugin --profile web add github:duyanta123/arch-doc#v<version>
47
+
48
+ # 本地 file: 链接(无需发布)
49
+ # profile 的 package.json 加 "arch-doc": "file:<本地路径>/arch-doc",
50
+ # 并在 dsh.profile.bundles 数组加 "arch-doc",然后 pnpm install。
51
+ ```
52
+
53
+ ## 步骤 4:验证
54
+
55
+ 1. 重启 profile,技能列表应出现 `arch-doc`。
56
+ 2. 说「用 arch-doc 分析 test/fixtures/python-app」,确认五阶段执行并产出 ARCHITECTURE.md / architecture.json / Mermaid 图。
57
+
58
+ ## 步骤 5:提交 dsh-index
59
+
60
+ 在 dsh-index 仓库的 `skills/` 下新增 `arch-doc/` 目录,包含技能索引所需的最小集合:
61
+
62
+ ```text
63
+ dsh-index/
64
+ └── skills/
65
+ └── arch-doc/
66
+ ├── SKILL.md # 技能定义(frontmatter 含 name / description)
67
+ ├── package.json # 包元数据(或 dsh-index 约定的 index 元数据)
68
+ ├── README.md # 能力说明
69
+ └── ...
70
+ ```
71
+
72
+ 提交方式二选一:
73
+
74
+ - `dsh submit`(如本机已安装 dsh CLI)。
75
+ - 在 dsh-index 仓库发起 PR,按其 CONTRIBUTING 约定填写技能元数据。
76
+
77
+ ## 提交 dsh-index 前检查清单
78
+
79
+ - [x] `package.json` 的 `files` 包含全部发布文件
80
+ - [x] `plugin/index.js` 使用 `FileSystemSkillProvider` 且 `includeDefaultRoots: false`
81
+ - [x] `SKILL.md` frontmatter 有 `name` 和 `description`
82
+ - [x] `scripts/arch-profile.mjs` 零依赖、无子进程
83
+ - [x] `npm test` 通过
84
+ - [x] `node --check` 通过
85
+ - [x] 输入/输出 JSON 结构稳定
86
+ - [x] 有 `examples/` 示例输出
87
+ - [x] 有 `README.md`、`LICENSE`、`PUBLISHING.md`
88
+ - [x] 包名 `dsh-arch-doc` 在 npm 上可用(`arch-doc` 因与既有包 `archdoc` 撞名被防抢注拦截,2026-09-02 改名)
89
+ - [ ] 本地 profile 安装后技能可被加载并正确输出文档
90
+ - [ ] dsh-index PR 已提交
91
+
92
+ ## 本地开发循环(改技能内容后)
93
+
94
+ 1. 改 `skills/`、`docs/`、`scripts/` 下的文件。
95
+ 2. 本地 `file:` 链接形态下,改 `skills/` 无需重装(FileSystemSkillProvider 会 watch 技能根)。
96
+ 3. 改 `plugin/index.js` / `cordis.patch.yml` / `package.json` 后需 `pnpm install` 并重启 profile。
97
+ 4. 提交前:`node --check scripts/arch-profile.mjs`、`npm test`、`git status` 确认。
98
+ 5. 版本变更时:更新 `package.json` 的 `version` 与 `CHANGELOG.md`,打 tag 并推送。
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # arch-doc
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
+ [![DeepSeek Harness](https://img.shields.io/badge/DeepSeek%20Harness-plugin-4c1d95)](https://github.com/topics/dsh-plugin)
5
+ [![dsh-index](https://img.shields.io/badge/dsh--index-arch--doc-blue)](https://dsh-index.xlings.org/packages/arch-doc/)
6
+ [![version](https://img.shields.io/badge/version-0.1.2-green)](CHANGELOG.md)
7
+
8
+ DSH 技能插件:输入代码库路径,自动生成架构文档(模块职责、依赖关系、入口点、运行方式)。
9
+
10
+ ## 能力
11
+ - 项目类型 / 语言 / 构建系统识别
12
+ - 模块划分与职责总结
13
+ - 内部 / 外部依赖提取与 Mermaid 依赖图
14
+ - 入口点(CLI / Web / Worker / Scheduler / Library)识别
15
+ - 运行方式(安装 / 开发 / 构建 / 测试 / 运行 / 部署)提取
16
+ - 输出 Markdown + JSON
17
+
18
+ ## 目录结构
19
+
20
+ ```text
21
+ arch-doc/
22
+ ├── package.json # npm 包 + dsh.bundle.patch
23
+ ├── cordis.patch.yml # DSH bundle patch
24
+ ├── plugin/index.js # ESM 入口,注册 skills/ 为技能根
25
+ ├── skills/arch-doc/SKILL.md # 技能 frontmatter + 阶段执行 runbook
26
+ ├── docs/ # 输出模板 + 扫描规则
27
+ ├── scripts/arch-profile.mjs # 零依赖 Node 脚本:probe/scan/deps/entry
28
+ ├── examples/ # 输入/输出示例
29
+ └── test/ # node --test 测试 + fixtures
30
+ ```
31
+
32
+ ## 使用
33
+
34
+ 1. 安装:`dsh plugin --profile web add github:duyanta123/arch-doc#v0.1.1`
35
+ 2. 使用:对 Agent 说「用 arch-doc 分析 /path/to/repo」
36
+ 3. 本地开发:profile 的 package.json 加 `"arch-doc": "file:<本地路径>/arch-doc"`,bundles 加 `"arch-doc"`
37
+
38
+ ## 输出
39
+
40
+ - `docs/ARCHITECTURE.md`:结构化架构文档(按 `docs/architecture-template.md` 骨架)
41
+ - `docs/architecture.json`:机器可读的结构化结果
42
+ - `docs/diagrams/module-dependencies.mmd`:Mermaid 模块依赖图
43
+
44
+ ## 环境要求
45
+
46
+ - Node.js >= 18(运行 `scripts/arch-profile.mjs`;无 Node 时 runbook 自动降级为 shell 手工探测)
47
+
48
+ ## 脚本
49
+
50
+ ```bash
51
+ node scripts/arch-profile.mjs <repo_path> --probe
52
+ node scripts/arch-profile.mjs <repo_path> --scan --max-depth 3
53
+ node scripts/arch-profile.mjs <repo_path> --deps
54
+ node scripts/arch-profile.mjs <repo_path> --entry
55
+ node scripts/arch-profile.mjs <repo_path> --all
56
+ ```
57
+
58
+ ## 测试
59
+
60
+ ```bash
61
+ npm test
62
+ node --check scripts/arch-profile.mjs
63
+ ```
64
+
65
+ ## 排障
66
+
67
+ - **生成的 `ARCHITECTURE.md` 里 Mermaid 图不渲染**:`file://` 协议下浏览器直接打开时,CDN 加载的 mermaid.js 受同源策略限制无法自动渲染;用 Typora 等本地渲染编辑器打开,或把 `diagrams/module-dependencies.mmd` 内容粘到 mermaid.live 查看。`.mmd` 源文件语法本身独立有效。
68
+ - **大仓库扫描太慢 / 输出太长**:`--max-depth 3` 起步,必要时降到 2;确认 `exclude_dirs` 覆盖了 `node_modules`、`.venv`、构建产物等大目录。
69
+ - **无 Node 环境时**:runbook 自动降级为 shell 手工探测(`find` / `ls` / 读 `package.json` / `go.mod` / `pyproject.toml`),结论质量略降但流程完整。
70
+ - **识别不到入口点**:先跑 `--probe` 确认项目类型识别正确;混合技术栈仓库以主语言构建文件为准(如 Go+Node 混合,以 `go.mod` 优先)。
71
+
72
+ ## License
73
+
74
+ [MIT](./LICENSE)
@@ -0,0 +1,11 @@
1
+ # arch-doc — DSH bundle patch.
2
+ #
3
+ # 当某个 profile 在 dsh.profile.bundles 中列出本包时(dsh plugin add 即完成此事),
4
+ # dsh 启动时把本补丁打入配置树:插入本包插件行,加载 package.json 的 main
5
+ # (plugin/index.js),将自带 skills/ 注册为技能根。
6
+ #
7
+ # 人设与工具不在此处重复声明——宿主 profile(web/standard)已提供文件、shell、
8
+ # 计划模式、web 搜索、子代理等 runbook 引用的全部工具。
9
+ - insert:
10
+ - id: arch-doc
11
+ name: arch-doc
@@ -0,0 +1,45 @@
1
+ # 架构文档模板
2
+
3
+ 固定章节顺序:
4
+
5
+ # 架构文档
6
+
7
+ ## 1. 项目概览
8
+ - 项目名称、一句话描述、架构风格(分层/模块化/微服务/插件化)、仓库类型(monolith/monorepo/library/microservices)。
9
+
10
+ ## 2. 技术栈
11
+ - 语言、框架、构建工具、数据库/中间件(仅列能在仓库中确认的)。
12
+
13
+ ## 3. 目录结构
14
+ - 代码块 tree,最多 3 层,排除 node_modules/.git/dist/build 等噪音。
15
+
16
+ ## 4. 模块职责
17
+ | 模块 | 路径 | 职责 | 关键文件 |
18
+ |---|---|---|---|
19
+
20
+ ## 5. 模块依赖关系
21
+ - 内部依赖表:source -> target(kind)
22
+ - Mermaid 图:
23
+
24
+ ```mermaid
25
+ graph TD
26
+ api --> auth
27
+ auth --> db
28
+ ```
29
+
30
+ ## 6. 入口点
31
+ | 类型 | 路径 | 启动命令 | 说明 |
32
+ |---|---|---|---|
33
+
34
+ ## 7. 运行方式
35
+ | 操作 | 命令 | 工作目录 |
36
+ |---|---|---|
37
+
38
+ ## 8. 关键流程
39
+ - 1–3 条核心链路,每条 3–7 步,必须基于已识别入口与依赖。
40
+
41
+ ## 9. 待确认/风险点
42
+ - 动态导入、反射调用、隐式依赖、无法确定的外部服务等。
43
+
44
+ ## 附录
45
+ - 扫描范围、排除目录、脚本命令、生成时间。
@@ -0,0 +1,95 @@
1
+ # arch-doc 扫描与识别规则
2
+
3
+ 本文档固化 `scripts/arch-profile.mjs` 的确定性规则,保证不同运行环境产出一致的事实数据。
4
+ 「硬事实」由脚本产出,「语义总结」由 LLM 补充,两者不得互相替代。
5
+
6
+ ## 1. 语言探测(--probe)
7
+
8
+ 按文件优先级识别,先到先得:
9
+
10
+ | 语言 | 标识文件 |
11
+ |---|---|
12
+ | TypeScript | tsconfig.json / pnpm-workspace.yaml(优先于 JavaScript 判定) |
13
+ | Python | pyproject.toml / setup.py / setup.cfg / requirements.txt / Pipfile |
14
+ | JavaScript | package.json |
15
+ | Go | go.mod |
16
+ | Java | pom.xml / build.gradle / build.gradle.kts / settings.gradle |
17
+ | Kotlin | build.gradle.kts |
18
+ | Rust | Cargo.toml |
19
+ | C / C++ | CMakeLists.txt / Makefile / meson.build |
20
+ | Ruby | Gemfile / Rakefile |
21
+ | PHP | composer.json |
22
+
23
+ 无标识文件时用目录结构启发式:存在 `cmd/`、`internal/`、`pkg/` 判为 Go;
24
+ 存在 `src/`、`app/`、`lib/` 时按 `*.py` 与 `*.js/*.ts` 数量比较判为 Python / TypeScript;
25
+ 否则回退 `generic`。
26
+
27
+ ## 2. 仓库类型判定(repo_type)
28
+
29
+ | 类型 | 规则 |
30
+ |---|---|
31
+ | monorepo | 顶层存在 packages/、apps/、services/、microservices/ |
32
+ | microservices | 多个顶层子目录各自含 Dockerfile / main.go / main.py / package.json / go.mod |
33
+ | library | 顶层含 src/、lib/ 或 include/ 且无运行入口 |
34
+ | monolith | 其余情况 |
35
+
36
+ 「运行入口」轻量判定:存在 main.* / server.* / app.* / worker.* / cli.* / index.*,或 bin/、cmd/ 目录,或 Dockerfile。
37
+
38
+ ## 3. 目录扫描
39
+
40
+ - 排除目录(默认):.git、node_modules、dist、build、__pycache__、.venv、venv、target、.idea、.vscode、.pytest_cache、.mypy_cache、coverage。
41
+ - 深度:`--max-depth` 默认 3(1–10)。
42
+ - 文件白名单:源码、配置、Manifest、README(按扩展名 + Makefile/Dockerfile/Rakefile/Gemfile 特殊名)。
43
+ - 大仓库保护:文件数 >2000 时只扫前两层模块,不逐文件通读内容。
44
+
45
+ ## 4. 模块划分(--scan)
46
+
47
+ 按语言惯例取模块容器目录,其直接子目录(含源码)成为模块;容器自身若无子目录而直接含源码,则容器本身为模块:
48
+
49
+ | 语言 | 模块容器 |
50
+ |---|---|
51
+ | Python | src/、app/、lib/,及顶层含 __init__.py 的包目录 |
52
+ | JavaScript / TypeScript | src/、lib/、packages/、apps/ |
53
+ | Go | cmd/、internal/、pkg/ |
54
+ | Java / Kotlin | src/main/java/(取包名首层目录) |
55
+ | 通用 | src/、lib/、app/、packages/ |
56
+
57
+ 每模块输出:name、path(posix 相对路径)、language、key_files(最多 5 个,优先 README/入口/大文件)、file_count。
58
+
59
+ ## 5. 依赖提取(--deps)
60
+
61
+ 静态文本解析,不做 AST。
62
+
63
+ | 语言 | 规则 |
64
+ |---|---|
65
+ | Python | `from X import ...`、`import X`(X 取首个标识段) |
66
+ | JavaScript / TypeScript | `import ... from 'X'`、`import 'X'`、`require('X')`、`import('X')` |
67
+ | Go | 单行 `import "X"` 与 `import (...)` 块 |
68
+ | Java / Kotlin | `import X;`(含 static) |
69
+
70
+ 内部依赖判定:导入路径首段命中模块名,或导入路径命中模块路径(点号归一后前缀匹配 / Go 模块路径包含匹配)。
71
+ 未命中内部模块的导入归入外部依赖,并从 Manifest(package.json / pyproject.toml / go.mod / pom.xml)补版本号。
72
+
73
+ 动态导入(`importlib`、`__import__`、`require(变量)`)不硬猜,只记录为风险。
74
+
75
+ ## 6. 入口点判定(--entry)
76
+
77
+ | 类型 | 判定依据 |
78
+ |---|---|
79
+ | web | 内容含 uvicorn/fastapi/flask/django/express/app.listen/listen(http) 等;或 server.js/app.js/index.js/main.go/Application.java |
80
+ | cli | bin/、cmd/ 目录;或 cli.py/cli.js;或内容含 argparse/commander/cobra/click/yargs/process.argv |
81
+ | worker | 文件名/内容含 worker、consumer、queue、celery、bullmq |
82
+ | scheduler | 文件名/内容含 cron、scheduler、schedule |
83
+ | library | 无运行入口,存在 lib.rs / index.ts 导出 / setup.py 包名 |
84
+ | unknown | 无法判断时不强行分类 |
85
+
86
+ ## 7. 运行方式提取(--entry)
87
+
88
+ | 来源 | 提取 |
89
+ |---|---|
90
+ | package.json scripts | install/dev/build/test/start/deploy 等(npm install / npm run <name> / npm start) |
91
+ | pyproject.toml | [project.scripts] 控制台命令、pip install -e .、uvicorn 开发命令 |
92
+ | Makefile | 目标名与 make <target> |
93
+ | Dockerfile | docker build / docker run |
94
+ | docker-compose.yml | docker compose up / down |
95
+ | README.md | npm run / pip install / go build / mvn 等命令仅作候选,需标注来源 |
@@ -0,0 +1,9 @@
1
+ # Examples
2
+
3
+ | 文件 | 用途 |
4
+ |------|------|
5
+ | `input.json` | 调用参数样例:`repo_path` / `output_path` / `max_depth` / `exclude_dirs` / `generate_mermaid` |
6
+ | `sample-output.md` | 生成的架构文档样例(Markdown 通道) |
7
+ | `sample-output.json` | 生成的结构化结果样例(JSON 通道:模块 / 依赖 / 入口 / 运行方式) |
8
+
9
+ `test/fixtures/` 下另有 Python / Node / Go 三个最小应用,供 `node --test` 契约测试使用:`go-app`(`cmd/server` 布局)、`node-app`(`src/server.js` + ESM)、`python-app`(`src/` 包结构 + `pyproject.toml`)。
@@ -0,0 +1,15 @@
1
+ {
2
+ "repo_path": "/path/to/my-app",
3
+ "output_format": "both",
4
+ "output_path": "/path/to/my-app/docs",
5
+ "max_depth": 3,
6
+ "exclude_dirs": [
7
+ ".git",
8
+ "node_modules",
9
+ "dist",
10
+ "build",
11
+ "__pycache__",
12
+ ".venv"
13
+ ],
14
+ "generate_mermaid": true
15
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "project": {
3
+ "name": "my-app",
4
+ "root": "/path/to/my-app",
5
+ "language": "python",
6
+ "repo_type": "monolith",
7
+ "description": "示例项目",
8
+ "tech_stack": [
9
+ "python",
10
+ "fastapi",
11
+ "docker"
12
+ ]
13
+ },
14
+ "modules": [
15
+ {
16
+ "name": "auth",
17
+ "path": "src/auth",
18
+ "responsibility": "用户认证与权限控制",
19
+ "language": "python",
20
+ "key_files": [
21
+ "src/auth/service.py"
22
+ ]
23
+ }
24
+ ],
25
+ "dependencies": {
26
+ "internal": [
27
+ {
28
+ "source": "api",
29
+ "target": "auth",
30
+ "kind": "import",
31
+ "path": "src/api/router.py"
32
+ }
33
+ ],
34
+ "external": [
35
+ {
36
+ "name": "fastapi",
37
+ "version": "0.115.0",
38
+ "category": "web"
39
+ }
40
+ ]
41
+ },
42
+ "entry_points": [
43
+ {
44
+ "type": "web",
45
+ "path": "src/main.py",
46
+ "command": "uvicorn src.main:app --reload",
47
+ "description": "API 服务入口"
48
+ }
49
+ ],
50
+ "run_methods": [
51
+ {
52
+ "action": "install",
53
+ "command": "pip install -e .",
54
+ "workspace": "."
55
+ },
56
+ {
57
+ "action": "dev",
58
+ "command": "uvicorn src.main:app --reload",
59
+ "workspace": "."
60
+ }
61
+ ],
62
+ "key_flows": [
63
+ {
64
+ "name": "用户登录",
65
+ "description": "登录请求处理链路",
66
+ "steps": [
67
+ "接收请求",
68
+ "校验参数",
69
+ "调用 auth 服务",
70
+ "返回 token"
71
+ ]
72
+ }
73
+ ],
74
+ "directory_tree": "src/\n├── api/\n├── auth/\n└── main.py",
75
+ "risks": [
76
+ "auth 模块通过 importlib 动态加载,需人工确认"
77
+ ]
78
+ }
@@ -0,0 +1,60 @@
1
+ # 架构文档
2
+
3
+ > 由 arch-doc 生成。事实数据来自脚本,语义总结由 LLM 补充并标注推断。
4
+
5
+ ## 1. 项目概览
6
+ - 项目名称:my-app
7
+ - 一句话描述:示例项目(Python FastAPI 服务)
8
+ - 架构风格:分层
9
+ - 仓库类型:monolith
10
+
11
+ ## 2. 技术栈
12
+ - 语言:python
13
+ - 框架:fastapi、uvicorn
14
+ - 构建/运行:docker
15
+
16
+ ## 3. 目录结构
17
+
18
+ ```text
19
+ src/
20
+ ├── api/
21
+ ├── auth/
22
+ └── main.py
23
+ ```
24
+
25
+ ## 4. 模块职责
26
+ | 模块 | 路径 | 职责 | 关键文件 |
27
+ |---|---|---|---|
28
+ | auth | src/auth | 用户认证与权限控制 | src/auth/service.py |
29
+
30
+ ## 5. 模块依赖关系
31
+ - 内部依赖表:api -> auth(import)
32
+ - Mermaid 图:
33
+
34
+ ```mermaid
35
+ graph TD
36
+ api --> auth
37
+ ```
38
+
39
+ ## 6. 入口点
40
+ | 类型 | 路径 | 启动命令 | 说明 |
41
+ |---|---|---|---|
42
+ | web | src/main.py | uvicorn src.main:app --reload | API 服务入口 |
43
+
44
+ ## 7. 运行方式
45
+ | 操作 | 命令 | 工作目录 |
46
+ |---|---|---|
47
+ | install | pip install -e . | . |
48
+ | dev | uvicorn src.main:app --reload | . |
49
+
50
+ ## 8. 关键流程
51
+ - **用户登录**:接收请求 -> 校验参数 -> 调用 auth 服务 -> 返回 token
52
+
53
+ ## 9. 待确认/风险点
54
+ - auth 模块通过 importlib 动态加载,需人工确认
55
+
56
+ ## 附录
57
+ - 扫描范围:src/(深度 3)
58
+ - 排除目录:.git、node_modules、dist、build、__pycache__、.venv
59
+ - 脚本命令:node scripts/arch-profile.mjs <repo> --all
60
+ - 生成时间:(生成时填写)
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "dsh-arch-doc",
3
+ "version": "0.1.2",
4
+ "description": "DSH arch-doc skill plugin: analyze a codebase and generate architecture documentation (module responsibilities, dependencies, entry points and run methods).",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/duyanta123/arch-doc.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/duyanta123/arch-doc/issues"
13
+ },
14
+ "homepage": "https://github.com/duyanta123/arch-doc#readme",
15
+ "scripts": {
16
+ "test": "node --test test/arch-profile.test.mjs",
17
+ "prepublishOnly": "npm test"
18
+ },
19
+ "main": "./plugin/index.js",
20
+ "exports": {
21
+ ".": "./plugin/index.js",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "dsh": {
25
+ "bundle": {
26
+ "patch": "./cordis.patch.yml"
27
+ }
28
+ },
29
+ "files": [
30
+ "plugin/index.js",
31
+ "cordis.patch.yml",
32
+ "skills/",
33
+ "docs/",
34
+ "scripts/",
35
+ "examples/",
36
+ "README.md",
37
+ "CHANGELOG.md",
38
+ "PUBLISHING.md",
39
+ "LICENSE"
40
+ ],
41
+ "peerDependencies": {
42
+ "@deepseek-ai/dsh-skill-filesystem": "*"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "@deepseek-ai/dsh-skill-filesystem": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "keywords": [
50
+ "dsh",
51
+ "dsh-plugin",
52
+ "deepseek-harness",
53
+ "architecture",
54
+ "documentation",
55
+ "code-analysis",
56
+ "dependency-graph",
57
+ "skills"
58
+ ]
59
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * arch-doc — DSH (DeepSeek Harness) 插件入口。
3
+ *
4
+ * 复用官方 @deepseek-ai/dsh-skill-filesystem 提供者,把本包自带的 skills/
5
+ * 目录注册为技能根(includeDefaultRoots: false,避免与宿主 profile 的
6
+ * 技能根重复)。零构建:本 ESM 模块由 harness 直接加载。
7
+ *
8
+ * 本包为纯指令型技能插件:它只注入 runbook 指令,计算由宿主已提供的
9
+ * 文件 / shell 工具驱动的 LLM 完成;arch-profile.mjs 脚本由 runbook 指引
10
+ * 通过 shell 直接调用(Node 内建能力,零依赖,不 spawn 子进程)。
11
+ */
12
+ import { fileURLToPath } from "node:url";
13
+ import { dirname, join } from "node:path";
14
+ import { FileSystemSkillProvider } from "@deepseek-ai/dsh-skill-filesystem";
15
+
16
+ export const name = "arch-doc";
17
+ export const inject = ["skills"];
18
+
19
+ const rootDir = join(dirname(fileURLToPath(import.meta.url)), "..");
20
+ const skillsDir = join(rootDir, "skills");
21
+
22
+ export function apply(ctx, config = {}) {
23
+ let provider;
24
+ ctx.skills.registerProvider((control) => {
25
+ provider = new FileSystemSkillProvider(ctx, control, {
26
+ providerName: "arch-doc",
27
+ includeDefaultRoots: false,
28
+ customSkillDirs: [skillsDir],
29
+ ...config,
30
+ });
31
+ return provider;
32
+ });
33
+ ctx.effect(
34
+ function* () {
35
+ yield async () => {
36
+ await provider?.dispose();
37
+ };
38
+ },
39
+ "arch-doc skill provider"
40
+ );
41
+ }