@liuxincuit/pi-codegraph 0.1.2 → 0.1.3
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/CONTEXT.md +21 -21
- package/LICENSE +22 -22
- package/README.md +14 -6
- package/extensions/codegraph.ts +596 -488
- package/package.json +43 -43
- package/skills/codegraph/SKILL.md +31 -18
package/CONTEXT.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# pi-codegraph
|
|
2
|
-
|
|
3
|
-
A pi extension that gives the agent access to a CodeGraph index of the current project.
|
|
4
|
-
|
|
5
|
-
## Language
|
|
6
|
-
|
|
7
|
-
**Project**:
|
|
8
|
-
The directory the pi session runs in (`ctx.cwd`). The unit that CodeGraph indexes and the default scope of every query.
|
|
9
|
-
_Avoid_: workspace, repository, repo
|
|
10
|
-
|
|
11
|
-
**Index**:
|
|
12
|
-
The `.codegraph/` directory at the project root, holding the SQLite knowledge graph of the project's symbols, edges, and files. Built by `codegraph init`, updated by `codegraph sync`.
|
|
13
|
-
_Avoid_: database, cache, graph (ambiguous with the data structure)
|
|
14
|
-
|
|
15
|
-
**Explore**:
|
|
16
|
-
The single agent-facing query operation: a natural-language or symbol question answered with the relevant symbols' verbatim source plus the call paths between them.
|
|
17
|
-
_Avoid_: search, query, lookup
|
|
18
|
-
|
|
19
|
-
**Sync**:
|
|
20
|
-
An incremental update of the Index to match the files currently on disk. Cheap when nothing changed.
|
|
21
|
-
_Avoid_: refresh, rebuild (that's a full re-index)
|
|
1
|
+
# pi-codegraph
|
|
2
|
+
|
|
3
|
+
A pi extension that gives the agent access to a CodeGraph index of the current project.
|
|
4
|
+
|
|
5
|
+
## Language
|
|
6
|
+
|
|
7
|
+
**Project**:
|
|
8
|
+
The directory the pi session runs in (`ctx.cwd`). The unit that CodeGraph indexes and the default scope of every query.
|
|
9
|
+
_Avoid_: workspace, repository, repo
|
|
10
|
+
|
|
11
|
+
**Index**:
|
|
12
|
+
The `.codegraph/` directory at the project root, holding the SQLite knowledge graph of the project's symbols, edges, and files. Built by `codegraph init`, updated by `codegraph sync`.
|
|
13
|
+
_Avoid_: database, cache, graph (ambiguous with the data structure)
|
|
14
|
+
|
|
15
|
+
**Explore**:
|
|
16
|
+
The single agent-facing query operation: a natural-language or symbol question answered with the relevant symbols' verbatim source plus the call paths between them.
|
|
17
|
+
_Avoid_: search, query, lookup
|
|
18
|
+
|
|
19
|
+
**Sync**:
|
|
20
|
+
An incremental update of the Index to match the files currently on disk. Cheap when nothing changed.
|
|
21
|
+
_Avoid_: refresh, rebuild (that's a full re-index)
|
package/LICENSE
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 izhimu
|
|
4
|
-
Copyright (c) 2026 liuxincuit
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 izhimu
|
|
4
|
+
Copyright (c) 2026 liuxincuit
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -50,12 +50,8 @@ pi -e ./extensions/codegraph.ts
|
|
|
50
50
|
## 功能一览
|
|
51
51
|
|
|
52
52
|
- **`codegraph_*` 工具集** — 面向智能体的代码智能工具,均支持 `path` 参数查询其他已建索引的项目:
|
|
53
|
-
- `codegraph_explore
|
|
54
|
-
- `codegraph_query`
|
|
55
|
-
- `codegraph_node` — 单个符号的源码 + 调用轨迹,可链式追踪调用图
|
|
56
|
-
- `codegraph_callers` / `codegraph_callees` — 谁调用了它 / 它调用了谁(`limit`)
|
|
57
|
-
- `codegraph_impact` — 修改符号的影响半径(`depth`)
|
|
58
|
-
- `codegraph_files` — 从索引查看文件结构(tree/flat/grouped,`pattern`、`maxDepth`)
|
|
53
|
+
- `codegraph_explore`(**默认注册**)— 一揽子探索:相关符号逐字源码 + 调用路径 + 影响范围(`maxFiles` 限制返回行数)
|
|
54
|
+
- `codegraph_query` / `codegraph_node` / `codegraph_callers` / `codegraph_callees` / `codegraph_impact` / `codegraph_files`(**默认隐藏**,见下方配置)
|
|
59
55
|
- **`/codegraph-init [path]`** — 为项目建立索引(`codegraph init`)。
|
|
60
56
|
- **`/codegraph-sync [path]`** — 手动同步自上次索引以来的改动(`codegraph sync`)。
|
|
61
57
|
- **`/codegraph-status [path]`** — 查看索引状态与统计信息(`codegraph status`)。
|
|
@@ -77,6 +73,18 @@ pi -e ./extensions/codegraph.ts
|
|
|
77
73
|
|
|
78
74
|
索引构建始终由你显式触发——智能体自身不会运行 `codegraph init`(见 `docs/adr/0002`)。
|
|
79
75
|
|
|
76
|
+
## 细粒度工具(可选开启)
|
|
77
|
+
|
|
78
|
+
`codegraph_explore` 能覆盖绝大多数结构化查询,因此另外 6 个细粒度工具默认**不注册**,避免过多工具增加智能体的决策负担(见 `docs/adr/0003`)。需要时在全局 `~/.pi/agent/extensions/pi-codegraph/config.json` 或项目 `.pi/extensions/pi-codegraph/config.json` 中配置 `extraTools` 开启(项目配置覆盖全局):
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"extraTools": ["query", "node", "impact"]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
短名(`node`、`impact`)与完整工具名(`codegraph_node`)均可用,`"all"` 开启全部。配置在下一个会话生效(`/reload` 或重启 pi)。
|
|
87
|
+
|
|
80
88
|
## 工作原理
|
|
81
89
|
|
|
82
90
|
pi 原生不支持 MCP,因此本扩展通过执行 CLI 来桥接 CodeGraph——`codegraph explore` 产生与 `codegraph_explore` MCP 工具相同的输出(见 `docs/adr/0001`)。每次工具调用仅需一次 `pi.exec`:没有守护进程、没有 JSON-RPC,没有可泄漏或需要恢复的状态。
|