pystepmap 0.1.0__tar.gz

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.
Files changed (45) hide show
  1. pystepmap-0.1.0/.gitignore +11 -0
  2. pystepmap-0.1.0/LICENSE +21 -0
  3. pystepmap-0.1.0/PKG-INFO +54 -0
  4. pystepmap-0.1.0/README.md +32 -0
  5. pystepmap-0.1.0/hatch_build.py +34 -0
  6. pystepmap-0.1.0/pyproject.toml +49 -0
  7. pystepmap-0.1.0/src/pystepmap_server/__init__.py +3 -0
  8. pystepmap-0.1.0/src/pystepmap_server/api.py +890 -0
  9. pystepmap-0.1.0/src/pystepmap_server/app.py +151 -0
  10. pystepmap-0.1.0/src/pystepmap_server/cli.py +138 -0
  11. pystepmap-0.1.0/src/pystepmap_server/flows.py +542 -0
  12. pystepmap-0.1.0/src/pystepmap_server/live.py +151 -0
  13. pystepmap-0.1.0/src/pystepmap_server/locks.py +139 -0
  14. pystepmap-0.1.0/src/pystepmap_server/mcp_server.py +216 -0
  15. pystepmap-0.1.0/src/pystepmap_server/mcp_tools.py +1901 -0
  16. pystepmap-0.1.0/src/pystepmap_server/procinfo.py +61 -0
  17. pystepmap-0.1.0/src/pystepmap_server/requirements_view.py +63 -0
  18. pystepmap-0.1.0/src/pystepmap_server/runner.py +673 -0
  19. pystepmap-0.1.0/src/pystepmap_server/shared.py +198 -0
  20. pystepmap-0.1.0/src/pystepmap_server/sources.py +126 -0
  21. pystepmap-0.1.0/src/pystepmap_server/status.py +116 -0
  22. pystepmap-0.1.0/src/pystepmap_server/store.py +1091 -0
  23. pystepmap-0.1.0/src/pystepmap_server/testflows.py +648 -0
  24. pystepmap-0.1.0/src/pystepmap_server/web/assets/index-CkPpOJq9.js +1748 -0
  25. pystepmap-0.1.0/src/pystepmap_server/web/assets/index-NTWdqvqI.css +1 -0
  26. pystepmap-0.1.0/src/pystepmap_server/web/index.html +14 -0
  27. pystepmap-0.1.0/src/pystepmap_server/worker.py +303 -0
  28. pystepmap-0.1.0/tests/fixtures/no_python/README.txt +1 -0
  29. pystepmap-0.1.0/tests/fixtures/only_excluded/README.txt +1 -0
  30. pystepmap-0.1.0/tests/fixtures/only_excluded/build/generated.py +1 -0
  31. pystepmap-0.1.0/tests/fixtures/shop/app/__init__.py +0 -0
  32. pystepmap-0.1.0/tests/fixtures/shop/app/orders.py +27 -0
  33. pystepmap-0.1.0/tests/test_api.py +1441 -0
  34. pystepmap-0.1.0/tests/test_flows.py +1804 -0
  35. pystepmap-0.1.0/tests/test_live.py +168 -0
  36. pystepmap-0.1.0/tests/test_locks.py +231 -0
  37. pystepmap-0.1.0/tests/test_mcp_stdio.py +393 -0
  38. pystepmap-0.1.0/tests/test_mcp_tools.py +1499 -0
  39. pystepmap-0.1.0/tests/test_runner.py +813 -0
  40. pystepmap-0.1.0/tests/test_serve.py +218 -0
  41. pystepmap-0.1.0/tests/test_shared.py +187 -0
  42. pystepmap-0.1.0/tests/test_sources.py +170 -0
  43. pystepmap-0.1.0/tests/test_status.py +221 -0
  44. pystepmap-0.1.0/tests/test_store.py +1197 -0
  45. pystepmap-0.1.0/tests/test_worker.py +303 -0
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .superpowers/
6
+ .ruff_cache/
7
+ .claude/settings.local.json
8
+ # 从 .mcp.json.example 复制出来的本机配置:不要提交(见 README「在 Claude Code 里使用」)
9
+ .mcp.json
10
+ # 只留在本机、不进 git 的东西(试验代码等)
11
+ local/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 有礼貌的狼
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.
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.5
2
+ Name: pystepmap
3
+ Version: 0.1.0
4
+ Summary: 把 Python 后端静态分析成业务流程图:本机平台、命令行和给 Claude Code 用的 MCP 服务
5
+ Project-URL: Homepage, https://github.com/xiaoyin1993/pystepmap
6
+ Project-URL: Repository, https://github.com/xiaoyin1993/pystepmap
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: celery,claude-code,fastapi,flowchart,mcp,static-analysis,workflow
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Documentation
15
+ Requires-Python: >=3.12
16
+ Requires-Dist: fastapi
17
+ Requires-Dist: mcp>=2.3.0
18
+ Requires-Dist: pystepkit>=0.1.0
19
+ Requires-Dist: pystepmap-core==0.1.0
20
+ Requires-Dist: uvicorn
21
+ Description-Content-Type: text/markdown
22
+
23
+ # pystepmap
24
+
25
+ **把 Python 后端代码画成业务流程图。** 每个接口、后台任务、命令各画成一条"功能线":先做什么 → 判断什么 →
26
+ 在什么情况下以什么结局结束。让 AI 替你写后端时,不读代码也能看懂它写了什么流程、改了哪里、测试走到了哪些路。
27
+
28
+ ![pystepmap 平台:左边是功能线列表,中间是「账户转账」的流程图,右边是选中节点的源码](https://raw.githubusercontent.com/xiaoyin1993/pystepmap/main/docs/images/overview.png)
29
+
30
+ - 代码不需要任何标记:认得出 FastAPI / Flask 的接口,taskiq / Celery / DBOS 的任务和工作流,click / typer 的命令和脚本
31
+ - 分析只读,不导入、不执行被分析项目的代码;平台只监听 `127.0.0.1`,数据存在 `~/.pystepmap/`
32
+ - 代码改了标出流程哪里变了;跑测试看真实走过的路;先写需求再对照实现
33
+ - `pystepmap mcp` 把同一份数据交给 Claude Code
34
+
35
+ ## 安装
36
+
37
+ 需要 Python 3.12 及以上。
38
+
39
+ ```bash
40
+ uv tool install pystepmap # 或者:pip install pystepmap
41
+ ```
42
+
43
+ ## 开始
44
+
45
+ ```bash
46
+ pystepmap serve # 打开平台 http://127.0.0.1:5179,点"添加第一个项目"
47
+ pystepmap analyze /path/to/project -o graph.json # 只用命令行
48
+ claude mcp add --scope user pystepmap -- pystepmap mcp # 接入 Claude Code
49
+ ```
50
+
51
+ 想让 AI 写的流程代码带全中文标题、遵守编排约束时,在项目里装标记包 `pystepkit`,再用
52
+ `pystepmap kit install <项目目录>` 装上约束套件。
53
+
54
+ 完整文档见 [GitHub](https://github.com/xiaoyin1993/pystepmap)。
@@ -0,0 +1,32 @@
1
+ # pystepmap
2
+
3
+ **把 Python 后端代码画成业务流程图。** 每个接口、后台任务、命令各画成一条"功能线":先做什么 → 判断什么 →
4
+ 在什么情况下以什么结局结束。让 AI 替你写后端时,不读代码也能看懂它写了什么流程、改了哪里、测试走到了哪些路。
5
+
6
+ ![pystepmap 平台:左边是功能线列表,中间是「账户转账」的流程图,右边是选中节点的源码](https://raw.githubusercontent.com/xiaoyin1993/pystepmap/main/docs/images/overview.png)
7
+
8
+ - 代码不需要任何标记:认得出 FastAPI / Flask 的接口,taskiq / Celery / DBOS 的任务和工作流,click / typer 的命令和脚本
9
+ - 分析只读,不导入、不执行被分析项目的代码;平台只监听 `127.0.0.1`,数据存在 `~/.pystepmap/`
10
+ - 代码改了标出流程哪里变了;跑测试看真实走过的路;先写需求再对照实现
11
+ - `pystepmap mcp` 把同一份数据交给 Claude Code
12
+
13
+ ## 安装
14
+
15
+ 需要 Python 3.12 及以上。
16
+
17
+ ```bash
18
+ uv tool install pystepmap # 或者:pip install pystepmap
19
+ ```
20
+
21
+ ## 开始
22
+
23
+ ```bash
24
+ pystepmap serve # 打开平台 http://127.0.0.1:5179,点"添加第一个项目"
25
+ pystepmap analyze /path/to/project -o graph.json # 只用命令行
26
+ claude mcp add --scope user pystepmap -- pystepmap mcp # 接入 Claude Code
27
+ ```
28
+
29
+ 想让 AI 写的流程代码带全中文标题、遵守编排约束时,在项目里装标记包 `pystepkit`,再用
30
+ `pystepmap kit install <项目目录>` 装上约束套件。
31
+
32
+ 完整文档见 [GitHub](https://github.com/xiaoyin1993/pystepmap)。
@@ -0,0 +1,34 @@
1
+ """打包时把打包好的前端(仓库的 web/dist,npm run build 的产物)放进 pystepmap_server/web/:pip install pystepmap
2
+ 之后 pystepmap serve 直接有界面。web/dist 不进 git,在仓库里构建前先 npm run build。
3
+ - 在仓库里构建、web/dist 有:wheel 里放 pystepmap_server/web/,源码包(sdist)里放 src/pystepmap_server/web/
4
+ - 从源码包构建 wheel:前端已经在包目录 src/pystepmap_server/web/ 里,按普通文件打进去
5
+ - 都没有(比如 pip install git+… 直接从仓库装):照样构建,只是没有界面,pystepmap serve 的首页说明怎么打包前端;
6
+ 设了环境变量 PYSTEPMAP_REQUIRE_WEB=1 时报错(发布用,免得发出没有界面的包)
7
+ - 可编辑安装(uv sync)不放:运行时直接用仓库里的 web/dist(app.default_web_dist)
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ from pathlib import Path
14
+ from typing import Any
15
+
16
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
17
+
18
+ PACKED = "src/pystepmap_server/web"
19
+
20
+
21
+ class WebDistHook(BuildHookInterface):
22
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
23
+ if version == "editable":
24
+ return
25
+ root = Path(self.root)
26
+ dist = root.parent / "web" / "dist"
27
+ if (dist / "index.html").is_file():
28
+ dest = PACKED if self.target_name == "sdist" else "pystepmap_server/web"
29
+ build_data["force_include"][str(dist)] = dest
30
+ elif not (root / PACKED / "index.html").is_file():
31
+ message = "没有打包好的前端(web/dist/index.html):先在 web/ 下 npm install && npm run build"
32
+ if os.environ.get("PYSTEPMAP_REQUIRE_WEB") == "1":
33
+ raise FileNotFoundError(message)
34
+ self.app.display_warning(f"{message};这次构建的包没有界面")
@@ -0,0 +1,49 @@
1
+ [project]
2
+ # 发布名是 pystepmap:pip install pystepmap 装上全部(分析引擎、命令行、平台、MCP 服务、标记包)
3
+ name = "pystepmap"
4
+ version = "0.1.0"
5
+ description = "把 Python 后端静态分析成业务流程图:本机平台、命令行和给 Claude Code 用的 MCP 服务"
6
+ readme = "README.md"
7
+ requires-python = ">=3.12"
8
+ license = "MIT"
9
+ dependencies = [
10
+ "pystepmap-core==0.1.0", # 和引擎一起发版,版本号一致
11
+ "pystepkit>=0.1.0",
12
+ "fastapi",
13
+ "uvicorn",
14
+ "mcp>=2.3.0",
15
+ ]
16
+ keywords = ["flowchart", "static-analysis", "workflow", "fastapi", "celery", "mcp", "claude-code"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Topic :: Software Development :: Documentation",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/xiaoyin1993/pystepmap"
27
+ Repository = "https://github.com/xiaoyin1993/pystepmap"
28
+
29
+ # 命令在 pystepmap-core 里实现;这里再声明一次,uvx pystepmap / uv tool install pystepmap 才有这条命令
30
+ #(uv 只装主包自己声明的命令)
31
+ [project.scripts]
32
+ pystepmap = "pystepmap.cli:main"
33
+
34
+ [dependency-groups]
35
+ dev = ["httpx2"]
36
+
37
+ [tool.uv.sources]
38
+ pystepmap-core = { workspace = true }
39
+ pystepkit = { workspace = true }
40
+
41
+ [build-system]
42
+ requires = ["hatchling"]
43
+ build-backend = "hatchling.build"
44
+
45
+ [tool.hatch.build.targets.wheel]
46
+ packages = ["src/pystepmap_server"]
47
+
48
+ # 打包好的前端(web/dist)由 hatch_build.py 放进包里
49
+ [tool.hatch.build.hooks.custom]
@@ -0,0 +1,3 @@
1
+ """pystepmap 平台后端:存储(store)、流程(flows)、源码片段(sources)、HTTP 接口(api、app)、启动(cli)。"""
2
+
3
+ __version__ = "0.1.0"