makotrace 0.3.3__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.
Potentially problematic release.
This version of makotrace might be problematic. Click here for more details.
- makotrace-0.3.3/LICENSE +21 -0
- makotrace-0.3.3/MANIFEST.in +17 -0
- makotrace-0.3.3/PKG-INFO +89 -0
- makotrace-0.3.3/README_PYPI.md +63 -0
- makotrace-0.3.3/docs/DEEPSEEK_USAGE.md +71 -0
- makotrace-0.3.3/docs/RELEASE.md +64 -0
- makotrace-0.3.3/docs/RELEASE_0.3.1.md +33 -0
- makotrace-0.3.3/docs/RELEASE_0.3.2.md +20 -0
- makotrace-0.3.3/docs/RELEASE_0.3.3.md +22 -0
- makotrace-0.3.3/examples/axis_demo.py +34 -0
- makotrace-0.3.3/examples/calls_demo/app.py +34 -0
- makotrace-0.3.3/examples/calls_demo/report.py +36 -0
- makotrace-0.3.3/examples/calls_demo/users.py +33 -0
- makotrace-0.3.3/examples/demo/v1/app.py +55 -0
- makotrace-0.3.3/examples/demo/v2/app.py +64 -0
- makotrace-0.3.3/examples/js_dataflow_demo/Counter.vue +21 -0
- makotrace-0.3.3/examples/js_dataflow_demo/app.js +9 -0
- makotrace-0.3.3/examples/js_dataflow_demo/util.js +9 -0
- makotrace-0.3.3/examples/ui_guards.vue +10 -0
- makotrace-0.3.3/pyproject.toml +39 -0
- makotrace-0.3.3/setup.cfg +4 -0
- makotrace-0.3.3/src/makotrace/__init__.py +13 -0
- makotrace-0.3.3/src/makotrace/assets/cytoscape-LICENSE.txt +19 -0
- makotrace-0.3.3/src/makotrace/assets/cytoscape.min.js +32 -0
- makotrace-0.3.3/src/makotrace/assets/dagre-LEGAL.txt +23 -0
- makotrace-0.3.3/src/makotrace/assets/dagre-LICENSE.txt +19 -0
- makotrace-0.3.3/src/makotrace/assets/dagre.min.js +3 -0
- makotrace-0.3.3/src/makotrace/assets/explorer.css +125 -0
- makotrace-0.3.3/src/makotrace/assets/explorer.html.tmpl +75 -0
- makotrace-0.3.3/src/makotrace/assets/explorer.js +622 -0
- makotrace-0.3.3/src/makotrace/assets/flow_axis.js +240 -0
- makotrace-0.3.3/src/makotrace/assets/parallel_forest.js +92 -0
- makotrace-0.3.3/src/makotrace/assets/project_atlas.js +47 -0
- makotrace-0.3.3/src/makotrace/assets/textbook.js +81 -0
- makotrace-0.3.3/src/makotrace/calls.py +584 -0
- makotrace-0.3.3/src/makotrace/cli.py +286 -0
- makotrace-0.3.3/src/makotrace/dataflow.py +244 -0
- makotrace-0.3.3/src/makotrace/edge_io.py +53 -0
- makotrace-0.3.3/src/makotrace/fdiff.py +61 -0
- makotrace-0.3.3/src/makotrace/gitdiff.py +94 -0
- makotrace-0.3.3/src/makotrace/graph.py +302 -0
- makotrace-0.3.3/src/makotrace/js_adapter.py +1033 -0
- makotrace-0.3.3/src/makotrace/js_dataflow.py +398 -0
- makotrace-0.3.3/src/makotrace/js_parser.py +890 -0
- makotrace-0.3.3/src/makotrace/mcp_server.py +100 -0
- makotrace-0.3.3/src/makotrace/model.py +213 -0
- makotrace-0.3.3/src/makotrace/query.py +309 -0
- makotrace-0.3.3/src/makotrace/render.py +59 -0
- makotrace-0.3.3/src/makotrace/scanner.py +257 -0
- makotrace-0.3.3/src/makotrace.egg-info/PKG-INFO +89 -0
- makotrace-0.3.3/src/makotrace.egg-info/SOURCES.txt +90 -0
- makotrace-0.3.3/src/makotrace.egg-info/dependency_links.txt +1 -0
- makotrace-0.3.3/src/makotrace.egg-info/entry_points.txt +2 -0
- makotrace-0.3.3/src/makotrace.egg-info/requires.txt +8 -0
- makotrace-0.3.3/src/makotrace.egg-info/top_level.txt +1 -0
- makotrace-0.3.3/tests/__init__.py +0 -0
- makotrace-0.3.3/tests/test_calls.py +180 -0
- makotrace-0.3.3/tests/test_dataflow.py +222 -0
- makotrace-0.3.3/tests/test_edge_io.py +97 -0
- makotrace-0.3.3/tests/test_external.py +159 -0
- makotrace-0.3.3/tests/test_fdiff.py +148 -0
- makotrace-0.3.3/tests/test_flow_axis.cjs +66 -0
- makotrace-0.3.3/tests/test_gitdiff.py +142 -0
- makotrace-0.3.3/tests/test_js_adapter.py +329 -0
- makotrace-0.3.3/tests/test_js_class_modern.py +177 -0
- makotrace-0.3.3/tests/test_js_dataflow.py +375 -0
- makotrace-0.3.3/tests/test_js_dataflow_review.py +47 -0
- makotrace-0.3.3/tests/test_js_modern_syntax.py +245 -0
- makotrace-0.3.3/tests/test_js_regressions.py +181 -0
- makotrace-0.3.3/tests/test_js_round2.py +159 -0
- makotrace-0.3.3/tests/test_js_round3.py +143 -0
- makotrace-0.3.3/tests/test_parallel_forest.cjs +42 -0
- makotrace-0.3.3/tests/test_project_atlas.cjs +28 -0
- makotrace-0.3.3/tests/test_query.py +172 -0
- makotrace-0.3.3/tests/test_query_usability.py +108 -0
- makotrace-0.3.3/tests/test_render.py +207 -0
- makotrace-0.3.3/tests/test_scanner.py +163 -0
- makotrace-0.3.3/tests/test_self_host_fixes.py +346 -0
- makotrace-0.3.3/tests/test_self_host_review.py +74 -0
- makotrace-0.3.3/tests/test_textbook.cjs +15 -0
- makotrace-0.3.3/tests/test_ui_payload.py +100 -0
- makotrace-0.3.3/tests/ui_acceptance.cjs +155 -0
- makotrace-0.3.3/tests/ui_atlas_acceptance.cjs +38 -0
- makotrace-0.3.3/tests/ui_axis_acceptance.cjs +52 -0
- makotrace-0.3.3/tests/ui_book_acceptance.cjs +27 -0
- makotrace-0.3.3/tests/ui_edge_io_acceptance.cjs +23 -0
- makotrace-0.3.3/tests/ui_forest_acceptance.cjs +45 -0
- makotrace-0.3.3/tests/ui_legacy_acceptance.cjs +362 -0
- makotrace-0.3.3/tests/ui_vue_dataflow_acceptance.cjs +18 -0
makotrace-0.3.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 makoTrace contributors
|
|
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,17 @@
|
|
|
1
|
+
include LICENSE README_PYPI.md pyproject.toml
|
|
2
|
+
recursive-include src/makotrace/assets *.js *.css *.tmpl *.txt
|
|
3
|
+
recursive-include examples *.py *.js *.mjs *.ts *.tsx *.vue *.html *.json *.md
|
|
4
|
+
recursive-include tests *.py *.cjs
|
|
5
|
+
include docs/RELEASE.md
|
|
6
|
+
include docs/RELEASE_0.3.1.md
|
|
7
|
+
include docs/RELEASE_0.3.2.md
|
|
8
|
+
include docs/RELEASE_0.3.3.md
|
|
9
|
+
include docs/DEEPSEEK_USAGE.md
|
|
10
|
+
prune output
|
|
11
|
+
prune dist
|
|
12
|
+
prune build
|
|
13
|
+
prune .git
|
|
14
|
+
prune .venv
|
|
15
|
+
prune docs/acceptance
|
|
16
|
+
exclude README.md
|
|
17
|
+
global-exclude __pycache__ *.py[cod] .DS_Store
|
makotrace-0.3.3/PKG-INFO
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: makotrace
|
|
3
|
+
Version: 0.3.3
|
|
4
|
+
Summary: Offline call graphs, function diffs and bounded AI queries for Python, JavaScript and TypeScript
|
|
5
|
+
Author: xiyuehe
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: static-analysis,ast,call-graph,code-visualization,makotrace
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: src/makotrace/assets/cytoscape-LICENSE.txt
|
|
17
|
+
License-File: src/makotrace/assets/dagre-LICENSE.txt
|
|
18
|
+
License-File: src/makotrace/assets/dagre-LEGAL.txt
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
21
|
+
Provides-Extra: js
|
|
22
|
+
Requires-Dist: tree-sitter<0.24,>=0.23.2; extra == "js"
|
|
23
|
+
Requires-Dist: tree-sitter-javascript<0.24,>=0.23.1; extra == "js"
|
|
24
|
+
Requires-Dist: tree-sitter-typescript<0.24,>=0.23.2; extra == "js"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# makoTrace
|
|
28
|
+
|
|
29
|
+
Static call graphs, basic data flow, function-level diffs and bounded AI queries. Generate a **single offline HTML** to explore a project with search, multi-file selection, a merged graph and embedded source.
|
|
30
|
+
|
|
31
|
+
**0.3.3 is an early preview.** Python 3.9+. Python analysis uses the standard library. JavaScript, Vue, HTML scripts, TypeScript and TSX use optional Tree-sitter grammars.
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
For a published version:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
python -m pip install "makotrace[js]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For a downloaded preview wheel:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
python -m pip install "./makotrace-0.3.3-py3-none-any.whl[js]"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Python-only projects can omit `[js]`. The wheel itself is platform independent; optional parser wheels depend on platform availability. No CDN, running web server, API key or frontend build is required to open the generated HTML.
|
|
48
|
+
|
|
49
|
+
## Try your project
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
makotrace graph /path/to/project --out project.html
|
|
53
|
+
makotrace graph /path/to/new --diff /path/to/old --out changes.html
|
|
54
|
+
makotrace graph /path/to/project --diff-git HEAD~1 --out changes.html
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Open the HTML in a browser. Check one or several analyzed files to merge them in the same graph; select the whole project to restore all files. Search functions, inspect one/two-hop neighborhoods, hover call conditions and double-click for source. Use the overview and readable-scale buttons to navigate large graphs.
|
|
58
|
+
|
|
59
|
+
The default graph uses text labels, small nodes, directed branches and separated call regions. Other layouts and a function-local tree are available. This does not guarantee a crossing-free graph or readable labels for hundreds of nodes fitted onto one screen.
|
|
60
|
+
|
|
61
|
+
## AI and machine-readable output
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
makotrace graph /path/to/project --json > graph.json
|
|
65
|
+
makotrace query graph.json --snapshot --action search --text save
|
|
66
|
+
makotrace query graph.json --snapshot --action neighbors --symbol 'app.py::main'
|
|
67
|
+
makotrace query graph.json --snapshot --action source --symbol 'app.py::main'
|
|
68
|
+
makotrace mcp graph.json --snapshot
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The read-only MCP stdio server exposes summary, search, symbol details, bounded neighborhoods, directed shortest call paths, source paging and explicit refresh. It supports the legacy initialization protocols through **2025-11-25**; it does not implement the 2026-07-28 stateless protocol. A client must be configured to launch the command. Starting the server alone does not connect it to an AI conversation.
|
|
72
|
+
|
|
73
|
+
Search defaults to function/method/class definitions; use `--kind all` or an explicit data/ghost kind for other symbols. Source defaults to the definition's line range; use `--scope file` for neighboring context. CLI `neighbors --limit N` bounds both nodes and edges; `path --limit N` bounds visited nodes, not path length. MCP uses the explicit `max_nodes`, `max_edges` and `max_visited` arguments.
|
|
74
|
+
|
|
75
|
+
Python relative imports are matched within the scanned files, including parent packages and basic submodule imports. Missing targets stay unresolved. JSON commands and stderr use UTF-8 on Windows; UTF-8 BOM input is accepted. Dynamic reexports, complete import binding and runtime execution are outside this preview's scope.
|
|
76
|
+
|
|
77
|
+
The graph JSON includes data edges and call-edge input/output summaries. MCP path/neighborhood tools currently traverse call edges, not data paths.
|
|
78
|
+
|
|
79
|
+
The same query layer can scan a project directly or read a makoTrace JSON/offline HTML snapshot. No arbitrary file-read or source-execution tool is exposed.
|
|
80
|
+
|
|
81
|
+
## Limits to understand
|
|
82
|
+
|
|
83
|
+
- Results are static relationships, not execution traces, timing or proof that a conditional path can run. `resolved`, `possible`, `unresolved`, `external` and guards remain explicit.
|
|
84
|
+
- Dynamic targets can remain unresolved. Unresolved does not mean no call. Python and JavaScript/TypeScript support basic function-local data flow: parameters, simple assignments, returns, direct-call receivers and known cross-file parameter passing. Vue supports explicit `.value` reads/writes. Full reactive dependencies, templates, props/emits/v-model, script-setup top-level statements and complete async data semantics are not implemented. Particle animation uses existing static data edges.
|
|
85
|
+
- **HTML and JSON exports contain source snapshots.** Share them only when you intend to share those sources. Public distribution archives contain the tool and synthetic examples, not generated project exports.
|
|
86
|
+
- Diff keeps new/old snapshots separate. Old coordinates of still-existing functions may be unavailable and are reported as unknown by the AI source reader.
|
|
87
|
+
- Windows and desktop Edge are the primary tested environment. Other operating systems/browsers are not comprehensively verified. This is not a security scanner.
|
|
88
|
+
|
|
89
|
+
MIT licensed. Bundled Cytoscape.js and Dagre retain their own MIT notices inside package assets and generated HTML.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# makoTrace
|
|
2
|
+
|
|
3
|
+
Static call graphs, basic data flow, function-level diffs and bounded AI queries. Generate a **single offline HTML** to explore a project with search, multi-file selection, a merged graph and embedded source.
|
|
4
|
+
|
|
5
|
+
**0.3.3 is an early preview.** Python 3.9+. Python analysis uses the standard library. JavaScript, Vue, HTML scripts, TypeScript and TSX use optional Tree-sitter grammars.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
For a published version:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
python -m pip install "makotrace[js]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
For a downloaded preview wheel:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
python -m pip install "./makotrace-0.3.3-py3-none-any.whl[js]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Python-only projects can omit `[js]`. The wheel itself is platform independent; optional parser wheels depend on platform availability. No CDN, running web server, API key or frontend build is required to open the generated HTML.
|
|
22
|
+
|
|
23
|
+
## Try your project
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
makotrace graph /path/to/project --out project.html
|
|
27
|
+
makotrace graph /path/to/new --diff /path/to/old --out changes.html
|
|
28
|
+
makotrace graph /path/to/project --diff-git HEAD~1 --out changes.html
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Open the HTML in a browser. Check one or several analyzed files to merge them in the same graph; select the whole project to restore all files. Search functions, inspect one/two-hop neighborhoods, hover call conditions and double-click for source. Use the overview and readable-scale buttons to navigate large graphs.
|
|
32
|
+
|
|
33
|
+
The default graph uses text labels, small nodes, directed branches and separated call regions. Other layouts and a function-local tree are available. This does not guarantee a crossing-free graph or readable labels for hundreds of nodes fitted onto one screen.
|
|
34
|
+
|
|
35
|
+
## AI and machine-readable output
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
makotrace graph /path/to/project --json > graph.json
|
|
39
|
+
makotrace query graph.json --snapshot --action search --text save
|
|
40
|
+
makotrace query graph.json --snapshot --action neighbors --symbol 'app.py::main'
|
|
41
|
+
makotrace query graph.json --snapshot --action source --symbol 'app.py::main'
|
|
42
|
+
makotrace mcp graph.json --snapshot
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The read-only MCP stdio server exposes summary, search, symbol details, bounded neighborhoods, directed shortest call paths, source paging and explicit refresh. It supports the legacy initialization protocols through **2025-11-25**; it does not implement the 2026-07-28 stateless protocol. A client must be configured to launch the command. Starting the server alone does not connect it to an AI conversation.
|
|
46
|
+
|
|
47
|
+
Search defaults to function/method/class definitions; use `--kind all` or an explicit data/ghost kind for other symbols. Source defaults to the definition's line range; use `--scope file` for neighboring context. CLI `neighbors --limit N` bounds both nodes and edges; `path --limit N` bounds visited nodes, not path length. MCP uses the explicit `max_nodes`, `max_edges` and `max_visited` arguments.
|
|
48
|
+
|
|
49
|
+
Python relative imports are matched within the scanned files, including parent packages and basic submodule imports. Missing targets stay unresolved. JSON commands and stderr use UTF-8 on Windows; UTF-8 BOM input is accepted. Dynamic reexports, complete import binding and runtime execution are outside this preview's scope.
|
|
50
|
+
|
|
51
|
+
The graph JSON includes data edges and call-edge input/output summaries. MCP path/neighborhood tools currently traverse call edges, not data paths.
|
|
52
|
+
|
|
53
|
+
The same query layer can scan a project directly or read a makoTrace JSON/offline HTML snapshot. No arbitrary file-read or source-execution tool is exposed.
|
|
54
|
+
|
|
55
|
+
## Limits to understand
|
|
56
|
+
|
|
57
|
+
- Results are static relationships, not execution traces, timing or proof that a conditional path can run. `resolved`, `possible`, `unresolved`, `external` and guards remain explicit.
|
|
58
|
+
- Dynamic targets can remain unresolved. Unresolved does not mean no call. Python and JavaScript/TypeScript support basic function-local data flow: parameters, simple assignments, returns, direct-call receivers and known cross-file parameter passing. Vue supports explicit `.value` reads/writes. Full reactive dependencies, templates, props/emits/v-model, script-setup top-level statements and complete async data semantics are not implemented. Particle animation uses existing static data edges.
|
|
59
|
+
- **HTML and JSON exports contain source snapshots.** Share them only when you intend to share those sources. Public distribution archives contain the tool and synthetic examples, not generated project exports.
|
|
60
|
+
- Diff keeps new/old snapshots separate. Old coordinates of still-existing functions may be unavailable and are reported as unknown by the AI source reader.
|
|
61
|
+
- Windows and desktop Edge are the primary tested environment. Other operating systems/browsers are not comprehensively verified. This is not a security scanner.
|
|
62
|
+
|
|
63
|
+
MIT licensed. Bundled Cytoscape.js and Dagre retain their own MIT notices inside package assets and generated HTML.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 给 DS(DeepSeek)用:先找关系,再读相关代码
|
|
2
|
+
|
|
3
|
+
适用于 0.3.3。包本身不绑定哪家模型,不需要模型 API key。让 DS 所在的编程工具调用本地命令即可;前提是该工具已配置好 DS,并允许它操作你的项目。**验证的是这些本地接口,没有登录、配置或实连 DS 账户。**
|
|
4
|
+
|
|
5
|
+
## 在 ZCode 等编程工具中
|
|
6
|
+
|
|
7
|
+
先安装朋友试用包。**先在准备使用它的同一个终端检查入口**,不能只看某份仓库里的版本号:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
makotrace --version
|
|
11
|
+
python -m pip show makotrace
|
|
12
|
+
python -c "import makotrace; print(makotrace.__file__)"
|
|
13
|
+
makotrace query --help
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
第一项应显示 `makotrace 0.3.3`,最后一项应显示查询帮助。如果 pip 显示旧版或 editable 指向旧 ZCode 副本,先从解压后的试用目录离线安装:
|
|
17
|
+
|
|
18
|
+
```powershell
|
|
19
|
+
python -m pip install --no-index --find-links ./wheelhouse "./makotrace-0.3.3-py3-none-any.whl[js]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
再检查一次。若 `python -m makotrace.cli --version` 与 `makotrace --version` 不一致,说明终端找到了另一份命令;可先用前者替换下文的 `makotrace`,并核对 `Get-Command makotrace -All`。保留旧副本开发是可以的,重新 editable 安装旧目录会再次切回旧实现。
|
|
23
|
+
|
|
24
|
+
此前默认 Python 3.9 的旧 editable 登记已改为本地 wheel 安装,0.3.1/0.3.2 实测记录分别在仓库 docs/acceptance/local-install-20261121/ 与 docs/acceptance/query-0.3.2/。2026-11-22 用户授权先存本地 Git 再备份同步,0.3.3 加入 DS 的相对导入、机器输出 UTF-8 和 BOM 修复,另有独立复核反例。最终安装/同步状态以 docs/acceptance/release-0.3.3/ 的实际报告为准,不代表其他电脑自动升级。
|
|
25
|
+
|
|
26
|
+
确认入口后,打开你想分析的项目,再把下面这段话发给 DS:
|
|
27
|
+
|
|
28
|
+
> 本机已安装 makotrace。请先为当前项目生成一份放在项目目录外的 HTML 图快照;后续用 makotrace query 的 --snapshot 查询它。先看 summary,按我问题中的函数/文件名做 search,再用完整符号 ID 查 symbol、neighbors 和 source。先只查相关函数,不把整仓源码一次全读。symbol 的调用边有 io 摘要,可看传入实参、返回式候选和接收变量;保留未知目标、条件、外部标记及简写/截断说明。返回式是静态证据,不是运行时值。需要最新代码时重新生成快照。
|
|
29
|
+
|
|
30
|
+
例如项目在 `D:/work/project`,快照放 `D:/maps/project.html`:
|
|
31
|
+
|
|
32
|
+
```powershell
|
|
33
|
+
makotrace graph "D:/work/project" --out "D:/maps/project.html"
|
|
34
|
+
makotrace query "D:/maps/project.html" --snapshot --action summary
|
|
35
|
+
makotrace query "D:/maps/project.html" --snapshot --action search --text save
|
|
36
|
+
makotrace query "D:/maps/project.html" --snapshot --action symbol --symbol "app.py::main"
|
|
37
|
+
makotrace query "D:/maps/project.html" --snapshot --action neighbors --symbol "app.py::main" --hops 2
|
|
38
|
+
makotrace query "D:/maps/project.html" --snapshot --action source --symbol "app.py::main"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
示例符号 ID 要替换为搜索返回的真实 ID。快照放在分析目录外,避免后续把生成图又当作项目 HTML 分析。HTML 文件通过 --out 写入 UTF-8,无需重定向 JSON。query 每次重新读取快照;持续多次查询可由兼容客户端使用 MCP 常驻加载。
|
|
42
|
+
|
|
43
|
+
0.3.2 默认 search 只找真实函数/方法/类定义,找全部符号加 --kind all,找未知目标加 --kind ghost,找变量加 --kind var。source 默认只返回所选定义的行范围;要读相邻文件上下文加 --scope file,长函数用 --max-lines/--max-chars 和返回的续读坐标分页。若没有定义坐标则明确回退,不能假定返回的是独立函数。
|
|
44
|
+
|
|
45
|
+
neighbors 可用 --max-nodes/--max-edges 分别限制;CLI 简写 --limit N 同时限制两者。path 使用 --max-visited 控制搜索预算,CLI --limit N 是其别名,**不是路径长度**。不要把别名与对应精确参数混传。MCP 工具仍用原精确参数。
|
|
46
|
+
|
|
47
|
+
### 两种 JSON 输出的区别
|
|
48
|
+
|
|
49
|
+
`calls --json` 是原始分析结果,带 `data_summary`、`data_nodes/data_edges`;它不带展示层派生的调用 `io` 摘要。`graph --json` 才是与 HTML 完全同源的 payload,调用边有 `io`。`query symbol` 的出入调用边也带同一摘要。旧 HTML 不会因安装升级而补出原本没采到的数据流,需要重新生成快照。
|
|
50
|
+
|
|
51
|
+
## MCP 是可选入口
|
|
52
|
+
|
|
53
|
+
若承载 DS 的客户端支持本包列出的旧握手版 MCP stdio,可让它启动:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
makotrace mcp "D:/maps/project.html" --snapshot
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
当前支持的握手版本到 2025-11-25,不支持 2026-07-28 无状态协议;不同客户端兼容性需实测。没有修改 ZCode 或其他客户端配置。不能仅因服务启动就说 DS 已连上。
|
|
60
|
+
|
|
61
|
+
## 如果只用普通网页聊天
|
|
62
|
+
|
|
63
|
+
网页对话不能因为装了这个包就自动读取你的本地项目。可以把工具查询出的相关函数/局部关系结果复制给 DS;是否能上传某种文件取决于网页本身。本工具没有代你上传或发送项目源码。
|
|
64
|
+
|
|
65
|
+
## 它能帮 DS 做什么
|
|
66
|
+
|
|
67
|
+
- 找到跨文件函数、谁调用谁、对应源码,以及调用边的静态输入/返回/接收摘要。
|
|
68
|
+
- 减少无关文件的读取,按跳数/条数/行数限制结果;本轮没有做 DS 的 token 节省比例或回答准确率对照实验。
|
|
69
|
+
- **尚未提供专门的数据路径查询工具**。AI 的 neighbors/path 遍历调用边;完整数据证据在统一 graph JSON 的 data_nodes/data_edges 中。JS/Vue/TS 支持的是函数内基础静态数据流,不是完整响应式传播和运行回放。
|
|
70
|
+
|
|
71
|
+
导出图和 JSON 包含源码快照;查询结果也可能包含源码。交给在线模型前按自己的项目分享范围处理。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# 0.3.0 朋友试用与发布
|
|
2
|
+
|
|
3
|
+
2026-11-21。本版是早期试用,已准备本地安装包;**尚未上传 PyPI / TestPyPI**。本机为 Windows x64 / CPython 3.9,其他平台没有本轮实机验收。
|
|
4
|
+
|
|
5
|
+
## 朋友直接试用
|
|
6
|
+
|
|
7
|
+
解压 `makotrace-0.3.0-windows-trial.zip`,进入该目录。电脑需已有 Python 和 pip。Python 项目无需第三方运行依赖:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
python -m pip install --no-index --no-deps ./makotrace-0.3.0-py3-none-any.whl
|
|
11
|
+
makotrace graph ./examples/calls_demo --out demo.html
|
|
12
|
+
makotrace graph "D:/朋友的项目" --out project.html
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
JS / Vue / HTML 内联脚本 / TypeScript / TSX 项目,使用附带的离线 Windows x64 依赖(CPython 3.9–3.13,pip 自动匹配):
|
|
16
|
+
|
|
17
|
+
```powershell
|
|
18
|
+
python -m pip install --no-index --find-links ./wheelhouse "./makotrace-0.3.0-py3-none-any.whl[js]"
|
|
19
|
+
makotrace graph "D:/朋友的项目" --out project.html
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
双击 HTML 后,在左边勾选一个或多个已分析文件,调用关系合并在同一张图里;“整个项目”恢复全部文件。“综合总览”看分布,“可读字号”回到可读大小。函数双击查看生成时的源码。仍可搜索、聚焦一/二跳、切换平行树/局部树/其他布局。
|
|
23
|
+
|
|
24
|
+
跨平台核心 wheel 为 `py3-none-any`;离线解析器 wheelhouse **只适用于 Windows x64 的 CPython 3.9–3.13**,仅 3.9 实机运行验收。其他系统/解释器需要其匹配的 Tree-sitter wheel;本版没有承诺 CPython 3.14 的 JS extra 可安装。联网环境可让 pip 获取适配依赖:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
python -m pip install "./makotrace-0.3.0-py3-none-any.whl[js]"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
试用包只有工具、上游解析器 wheel、人工演示项目和说明,未包含 Crystal / 重锋等真实项目导出。生成的 HTML / JSON **内嵌项目源码**,转发前按自己的源码分享范围决定。分析结果是静态关系;未定目标不代表没有调用;JS/TS 暂无数据流分析。
|
|
31
|
+
|
|
32
|
+
AI 接入口已经包含:`makotrace query`、`makotrace mcp`。后者需在兼容客户端配置启动命令,仅支持文档列出的旧版初始化协议,不会因安装就自动连接当前聊天。
|
|
33
|
+
|
|
34
|
+
## 本地重建与检查
|
|
35
|
+
|
|
36
|
+
标准 PyPA 流程(开发机有构建工具时):
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
python -m pip install build twine
|
|
40
|
+
python -m build
|
|
41
|
+
python -m twine check dist/makotrace-0.3.0*
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
本轮 PyPI 的 pip TLS 下载失败,改用本机 setuptools 82.0.1 的 PEP 517 后端离线构建:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
python -c "import setuptools.build_meta as b; b.build_sdist('dist'); b.build_wheel('dist')"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
源码发行包包含人工 examples 和回归测试,不包含输出、验收截图、工作区配置或真实项目源码。版本号同时登记在 `pyproject.toml` 和 `src/makotrace/__init__.py`。完整验证证据见 `docs/HTML_ACCEPTANCE.md` 以及 `docs/acceptance/release-0.3.0/report.json`。是否实际运行过 twine 以报告为准。
|
|
51
|
+
|
|
52
|
+
## 公开上传留到发布步骤
|
|
53
|
+
|
|
54
|
+
官方参考:[Packaging Python Projects](https://packaging.python.org/en/latest/tutorials/packaging-projects/)。公开发行前需用发布者自己的账户确认包名、项目权限和说明。此次 PyPI 官方 JSON 查询 `makotrace` 返回 404,不代表名称已预留,也不保证未来上传一定可用。
|
|
55
|
+
|
|
56
|
+
有发布授权和账户后可先上传 TestPyPI,再核对安装,最后上传 PyPI;凭据由发布者在自己的凭据管理环境处理,不放入仓库或聊天。不要把真实项目 HTML 加入发行包。
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
python -m twine upload --repository testpypi dist/makotrace-0.3.0*
|
|
60
|
+
# 测试及发布确认完成后:
|
|
61
|
+
python -m twine upload dist/makotrace-0.3.0*
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
这里只提供操作说明,本轮没有执行上传。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 0.3.1 试用更新:边上输入/输出与 Vue 基础数据流
|
|
2
|
+
|
|
3
|
+
2026-11-21。GLM 首版分析器、Codex 复核修正与图形接入。当前版本仍为早期试用,本地发行包已准备;未上传 PyPI / TestPyPI。
|
|
4
|
+
|
|
5
|
+
## 给朋友安装
|
|
6
|
+
|
|
7
|
+
解压 `makotrace-0.3.1-windows-trial.zip`,在目录里打开终端。已有 Python + pip 的 Windows x64 CPython 3.9–3.13 可用附带离线依赖:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
python -m pip install --no-index --find-links ./wheelhouse "./makotrace-0.3.1-py3-none-any.whl[js]"
|
|
11
|
+
makotrace graph "D:/朋友的项目" --out project.html
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
只分析 Python 项目可不加 `[js]`。核心 wheel 跨平台,离线 wheelhouse 只含 Windows x64 文件;本轮实际安装验收环境为 CPython 3.9.0 + Edge,其他解释器/平台未实机验收。
|
|
15
|
+
|
|
16
|
+
先双击 `vue-demo.html` 看跨文件调用、`.value` 和数据关系,或打开 `demo.html` 看 Python 示例。左栏勾选多个文件合并显示。顶部“边上数据”可切自动/全部/隐藏;小图自动标注,大图选中函数后读相关边。边旁的“传入 / 返回式 / 接到”是代码表达式或变量,不是实际运行数值。
|
|
17
|
+
|
|
18
|
+
打开“显示数据流”可看基础数据关系,“数据传输动画”仅按已有静态数据边示意方向,最多 60 条,不代表实际执行速度和先后。双击函数可读生成时的源码快照。
|
|
19
|
+
|
|
20
|
+
## 本版实际范围
|
|
21
|
+
|
|
22
|
+
- Python 既有基础数据流保留;JS/Vue/TS/TSX 新增函数内参数、简单声明/赋值、读引用、return(含箭头隐式返回)、直接调用结果接收、已知调用的基础跨文件传参、显式 `X.value` 读写。
|
|
23
|
+
- Spread 展开后的参数位置未知,不强配。回调与父函数隔离,不自动推导闭包来源;形参重赋值保持符号身份,不做 SSA 或分支值合并。
|
|
24
|
+
- 返回表达式可能简写,缺失证据标“未分析”,分支候选不保证本次执行。数据关系不是运行时跟踪。
|
|
25
|
+
- **未实现**:Vue 模板/跨组件 props/emits/v-model、完整 computed/watch 响应依赖、script setup 顶层散语句、通用对象别名/属性追踪、await/Promise 的完整异步数据语义、网络真实响应值。
|
|
26
|
+
- AI 的搜索/符号/源码工具可读同源 io 摘要;路径/邻域工具仍仅遍历调用边,没有专门的数据路径查询。
|
|
27
|
+
- 导出 HTML/JSON 内嵌项目源码。朋友 zip 只含工具、官方解析器 wheel 和人工示例,不含真实 Crystal/重锋项目导出。
|
|
28
|
+
|
|
29
|
+
## 验证和公开发行
|
|
30
|
+
|
|
31
|
+
测试与构建记录见 `HTML_ACCEPTANCE.md` 的最新集成节、`acceptance/vue-dataflow-20261121/` 和 `acceptance/release-0.3.1/report.json`。PyPA 构建工具网络下载仍受本机 pip TLS EOF 影响,使用已安装 setuptools 后端离线构建;严格元数据和隔离安装已核验,未把未运行的 twine check 宣称为通过。
|
|
32
|
+
|
|
33
|
+
本轮没有公开上传。公开步骤、PyPI 账户和名称确认参见 [0.3.0 发布说明](RELEASE.md) 与 [PyPA 官方指南](https://packaging.python.org/en/latest/tutorials/packaging-projects/);不要在聊天或仓库中放 token。上传时请明确选择本版的 wheel/sdist,避免误上传朋友 zip 或旧版本文件。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# 0.3.2:DS 查询体验修正
|
|
2
|
+
|
|
3
|
+
2026-11-21。沿用 0.3.1 的离线图、基础数据流和静态分析边界,不增加解析依赖,未上传 PyPI。
|
|
4
|
+
|
|
5
|
+
解压本版 Windows 试用包,在解压目录中离线安装并检查:
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
python -m pip install --no-index --find-links ./wheelhouse "./makotrace-0.3.2-py3-none-any.whl[js]"
|
|
9
|
+
makotrace --version
|
|
10
|
+
makotrace query --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Python 及离线依赖范围与 [0.3.1](RELEASE_0.3.1.md) 相同。实际验收 Python 3.9 x64;离线解析器附 CPython 3.9–3.13 Windows x64 wheel。
|
|
14
|
+
|
|
15
|
+
- search 默认仅真实 function/method/class 定义;查未知目标用 --kind ghost,数据用 --kind var/param/attr/ret,全部用 --kind all。未知目标仍存在图中,未删除。
|
|
16
|
+
- CLI neighbors --limit N 等价同时指定 --max-nodes N --max-edges N,N 为 1–200;path --limit N 等价 --max-visited N,N 为 1–10000,表示搜索预算,绝非路径跳数。不能同时传别名和对应精确上限;MCP 仍使用精确参数。
|
|
17
|
+
- source 默认按当前定义行号裁剪。--max-lines/--max-chars 可继续分页;读到定义末尾不再以相邻函数作为下一页。需要上下文请加 --scope file。旧版坐标/定义范围缺失时明确回退到文件上下文。同一行多定义可能共享文字,当前模型没有定义列范围。
|
|
18
|
+
- E 盘完整源码、测试、文档及本地发行物已准备,默认安装已升级;旧 ZCode 仓库的整仓同步被自动审批拒绝,尚未写入,需要用户明确授权。拟同步内容和备份/重建要求见源码仓库 docs/ZCODE_SYNC_REVIEW.md,不能只改旧仓库版本号。
|
|
19
|
+
|
|
20
|
+
此前 0.3.1 的原始测试报告保持不变,新验证另存。Vue mixin/全局注入、模板和完整响应式传播未因此实现,unresolved 表示观察到调用但不能确定目标。模型实际接入和源码分享仍由承载它的客户端决定。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 0.3.3:DS 自举修复与本地 Git 交付
|
|
2
|
+
|
|
3
|
+
2026-11-22。沿用 0.3.2 查询体验与离线图;DS 实现 Python 相对导入、UTF-8 输出和 BOM,Codex 复核并修正同名包绑定与 argparse 提前报错。
|
|
4
|
+
|
|
5
|
+
在 Windows 试用包解压目录离线安装:
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
python -m pip install --no-index --find-links ./wheelhouse "./makotrace-0.3.3-py3-none-any.whl[js]"
|
|
9
|
+
makotrace --version
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
核心 Python 3.9+;附带解析器 wheel 适用于 CPython 3.9–3.13 Windows x64,实际验收 Python 3.9。无需 PyPI 网络即可安装。未上传 PyPI,用户明确只存本地 Git,不创建或推送远端。
|
|
13
|
+
|
|
14
|
+
- 直接相对导入、别名、父包、基本子模块属性和包 __init__ 定义可在已扫描范围内解析;缺失/越界/星号来源未知保留 unresolved,不用同名文件兜底。
|
|
15
|
+
- 包内已有函数、类、直接赋值或导入绑定时,不把其属性错误连接到同名子模块;未支持的属性保持未知。完整运行时名字绑定、动态重导出、循环导入不在范围内。
|
|
16
|
+
- scan/diff/calls/graph --json 与 query/MCP 机器输出统一 UTF-8;stderr 含 argparse 的提前错误同样 UTF-8。人类 stdout 保持控制台编码策略。
|
|
17
|
+
- Python utf-8-sig 文件正常解析,scan_source 只去开头 BOM,语法错误仍记录。目录分析继续跳过 .min.js/.d.ts,保留 assets 中普通业务 JS。
|
|
18
|
+
- 0.3.2 的 search、source 定义范围、neighbors/path --limit 保留。Vue mixin/全局注入/完整响应式尚未实现。
|
|
19
|
+
|
|
20
|
+
测试及发行报告见源码仓库 docs/acceptance/release-0.3.3/;DS 过程记录为 DS_SELF_HOST_RESULT.md,最终集成记录优先于历史“未修/未安装”阶段说明。
|
|
21
|
+
|
|
22
|
+
用户已授权验收后先存本地 Git、再备份同步 ZCode。同步以同一个已提交版本为准,保留旧分支和输出;同步成功与提交号以实际 sync-report.json 为准,不将安装成功当作源码已同步。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Longest-call-axis fixture: a shortcut, a cycle, and an unknown branch."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def start(value):
|
|
5
|
+
result = read(value)
|
|
6
|
+
store(result) # Shortcut must not shorten the longest call chain.
|
|
7
|
+
unknown_sink(result)
|
|
8
|
+
return result
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def read(value):
|
|
12
|
+
return normalize(value)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def normalize(value):
|
|
16
|
+
return store(value)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def store(value):
|
|
20
|
+
return notify(value)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def notify(value):
|
|
24
|
+
return value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def cycle_a(value):
|
|
28
|
+
return cycle_b(value)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def cycle_b(value):
|
|
32
|
+
if value:
|
|
33
|
+
cycle_a(value - 1)
|
|
34
|
+
return notify(value)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""入口模块(calls_demo):把各模块串起来。
|
|
2
|
+
|
|
3
|
+
预期调用图行为:
|
|
4
|
+
- main → parse_args / make_adult_report 同文件 + from-import → resolved
|
|
5
|
+
- main → users.load_users import 模块属性跨文件 → resolved
|
|
6
|
+
- main → report.render 局部变量方法 → unresolved
|
|
7
|
+
- 模块级 if __name__ 块中的 main(sys.argv) 不记录(模块级调用属已知边界)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import users
|
|
11
|
+
from report import make_adult_report
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_args(argv):
|
|
15
|
+
"""极简参数解析:取第一个参数为数据文件路径。"""
|
|
16
|
+
path = "users.txt"
|
|
17
|
+
if argv:
|
|
18
|
+
path = argv[0]
|
|
19
|
+
return path
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def main(argv=None):
|
|
23
|
+
"""组装整条流程:解析参数 → 载入 → 报表。"""
|
|
24
|
+
argv = argv or []
|
|
25
|
+
path = parse_args(argv)
|
|
26
|
+
all_users = users.load_users(path)
|
|
27
|
+
report = make_adult_report(all_users)
|
|
28
|
+
return report.render()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
import sys
|
|
33
|
+
|
|
34
|
+
main(sys.argv)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""报表生成(calls_demo):演示类内调用与跨文件导入解析。
|
|
2
|
+
|
|
3
|
+
预期调用图行为:
|
|
4
|
+
- make_adult_report → find_adults from-import 跨文件 → resolved
|
|
5
|
+
- make_adult_report → Report 本地类构造 → resolved(指向类符号)
|
|
6
|
+
- report.add_row / report.render 局部变量方法调用 → unresolved(对象来源属数据流)
|
|
7
|
+
- Report.add_row 中的 self.rows.append → unresolved
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from users import find_adults
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Report:
|
|
14
|
+
"""极简报表:标题 + 行。"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, title):
|
|
17
|
+
self.title = title
|
|
18
|
+
self.rows = []
|
|
19
|
+
|
|
20
|
+
def add_row(self, text):
|
|
21
|
+
self.rows.append(text)
|
|
22
|
+
return self
|
|
23
|
+
|
|
24
|
+
def render(self):
|
|
25
|
+
lines = [self.title]
|
|
26
|
+
for row in self.rows:
|
|
27
|
+
lines.append("- " + row)
|
|
28
|
+
return "\n".join(lines)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def make_adult_report(users):
|
|
32
|
+
"""生成成年人名单报表。"""
|
|
33
|
+
report = Report("成年人名单")
|
|
34
|
+
for name in find_adults(users):
|
|
35
|
+
report.add_row(name)
|
|
36
|
+
return report.render()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""用户数据加载与筛选(calls_demo)。
|
|
2
|
+
|
|
3
|
+
预期调用图行为:
|
|
4
|
+
- load_users / find_adults / filter_users 为顶层函数,可被同文件与跨文件 resolved 引用
|
|
5
|
+
- filter_users 中的 predicate(u) 是参数函数调用 → unresolved(不假装确定)
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
def load_users(path):
|
|
9
|
+
"""读取用户列表,每行「名字,年龄」。"""
|
|
10
|
+
users = []
|
|
11
|
+
with open(path, "r", encoding="utf-8") as fh:
|
|
12
|
+
for line in fh:
|
|
13
|
+
name, _, age = line.partition(",")
|
|
14
|
+
users.append((name.strip(), int(age)))
|
|
15
|
+
return users
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def find_adults(users, min_age=18):
|
|
19
|
+
"""筛出年龄不小于 min_age 的用户名。"""
|
|
20
|
+
matched = []
|
|
21
|
+
for name, age in users:
|
|
22
|
+
if age >= min_age:
|
|
23
|
+
matched.append(name)
|
|
24
|
+
return matched
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def filter_users(users, predicate):
|
|
28
|
+
"""按外部传入的条件函数筛选(参数函数:调用图标 unresolved)。"""
|
|
29
|
+
result = []
|
|
30
|
+
for u in users:
|
|
31
|
+
if predicate(u):
|
|
32
|
+
result.append(u)
|
|
33
|
+
return result
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""示例项目 V1:用于演示 makoTrace 的函数级 Diff。"""
|
|
2
|
+
|
|
3
|
+
APP_NAME = "demo"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def load_config(path, defaults=None):
|
|
7
|
+
"""读取配置文件并合并默认值。"""
|
|
8
|
+
config = dict(defaults or {})
|
|
9
|
+
if not path:
|
|
10
|
+
return config
|
|
11
|
+
with open(path, "r", encoding="utf-8") as fh:
|
|
12
|
+
for line in fh:
|
|
13
|
+
key, _, value = line.partition("=")
|
|
14
|
+
config[key.strip()] = value.strip()
|
|
15
|
+
return config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def validate_user(name, age, allow_guest=False):
|
|
19
|
+
# 检查用户名与年龄
|
|
20
|
+
if not name:
|
|
21
|
+
return False
|
|
22
|
+
if age < 0:
|
|
23
|
+
raise ValueError("age < 0")
|
|
24
|
+
if allow_guest and name == "guest":
|
|
25
|
+
return True
|
|
26
|
+
return len(name) >= 2
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _parse_int(text):
|
|
30
|
+
"""把文本解析成 int,失败返回 0。"""
|
|
31
|
+
try:
|
|
32
|
+
return int(text)
|
|
33
|
+
except ValueError:
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class UserService:
|
|
38
|
+
"""演示用类。"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, config):
|
|
41
|
+
self.config = config
|
|
42
|
+
self.users = {}
|
|
43
|
+
|
|
44
|
+
def add_user(self, name, age):
|
|
45
|
+
if name in self.users:
|
|
46
|
+
return False
|
|
47
|
+
self.users[name] = age
|
|
48
|
+
return True
|
|
49
|
+
|
|
50
|
+
def find_adults(self, min_age=18):
|
|
51
|
+
result = []
|
|
52
|
+
for name, age in self.users.items():
|
|
53
|
+
if age >= min_age:
|
|
54
|
+
result.append(name)
|
|
55
|
+
return result
|