@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/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@liuxincuit/pi-codegraph",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "CodeGraph support for pi — symbol source + call paths via the codegraph CLI",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"pi-package",
|
|
8
|
-
"codegraph",
|
|
9
|
-
"code-intelligence",
|
|
10
|
-
"knowledge-graph"
|
|
11
|
-
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/liuxincuit/pi-codegraph.git"
|
|
15
|
-
},
|
|
16
|
-
"author": "liuxincuit",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"peerDependencies": {
|
|
19
|
-
"@earendil-works/pi-coding-agent": "*"
|
|
20
|
-
},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
23
|
-
"@types/node": "^22.0.0",
|
|
24
|
-
"typebox": "^1.3.7",
|
|
25
|
-
"typescript": "^5.5.0"
|
|
26
|
-
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"typecheck": "tsc --noEmit",
|
|
29
|
-
"smoke": "tsc extensions/codegraph.ts --outDir .smoke-build --module esnext --target es2022 --moduleResolution bundler --skipLibCheck --noEmit false && node smoke.mjs"
|
|
30
|
-
},
|
|
31
|
-
"pi": {
|
|
32
|
-
"extensions": [
|
|
33
|
-
"./extensions"
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
"files": [
|
|
37
|
-
"extensions/",
|
|
38
|
-
"skills/",
|
|
39
|
-
"CONTEXT.md",
|
|
40
|
-
"README.md",
|
|
41
|
-
"LICENSE"
|
|
42
|
-
]
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@liuxincuit/pi-codegraph",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "CodeGraph support for pi — symbol source + call paths via the codegraph CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package",
|
|
8
|
+
"codegraph",
|
|
9
|
+
"code-intelligence",
|
|
10
|
+
"knowledge-graph"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/liuxincuit/pi-codegraph.git"
|
|
15
|
+
},
|
|
16
|
+
"author": "liuxincuit",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
23
|
+
"@types/node": "^22.0.0",
|
|
24
|
+
"typebox": "^1.3.7",
|
|
25
|
+
"typescript": "^5.5.0"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"smoke": "tsc extensions/codegraph.ts --outDir .smoke-build --module esnext --target es2022 --moduleResolution bundler --skipLibCheck --noEmit false && node smoke.mjs"
|
|
30
|
+
},
|
|
31
|
+
"pi": {
|
|
32
|
+
"extensions": [
|
|
33
|
+
"./extensions"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"extensions/",
|
|
38
|
+
"skills/",
|
|
39
|
+
"CONTEXT.md",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: codegraph
|
|
3
|
-
description:
|
|
3
|
+
description: 通过 codegraph_explore 工具查询项目的 CodeGraph 索引(符号源码、调用路径、影响范围)。当回答结构化代码问题——X 如何工作、X 在哪里、谁调用 Y、修改某处会影响什么——且项目存在 .codegraph/ 索引时使用。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# CodeGraph
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
`codegraph_explore` 工具从项目的 CodeGraph 索引(`.codegraph/`,由 `codegraph` CLI 建立与维护)回答结构化代码问题。**当项目存在 `.codegraph/` 索引时**,应优先使用它而不是 grep/read。
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 默认工具
|
|
11
11
|
|
|
12
|
-
- `
|
|
13
|
-
- `codegraph_node` — one known symbol's verbatim source + caller/callee trail. Chain it to follow a call graph across files.
|
|
14
|
-
- `codegraph_callers` / `codegraph_callees` — who calls a symbol / what a symbol calls.
|
|
15
|
-
- `codegraph_impact` — blast radius of changing a symbol; call before editing.
|
|
16
|
-
- `codegraph_files` — indexed file tree (tree/flat/grouped by language) with symbol counts.
|
|
17
|
-
- `codegraph_explore` — broad questions: relevant symbols' source + call paths in one shot. Name endpoint symbols (`mutateElement renderScene`) to surface paths across dynamic-dispatch hops.
|
|
12
|
+
- `codegraph_explore` — 一次调用完成广泛探索:相关符号的源码 + 调用路径。可以点名端点符号(`mutateElement renderScene`)以跨越动态分派跳转揭示调用路径。参数:`query`(符号名或自然语言问题)、可选 `maxFiles`(限制返回源码行数)。
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
绝大多数结构化问题只需 `codegraph_explore` 即可解决。该工具始终注册。
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
- `codegraph_query`: `search` (symbol name or partial), optional `kind` (function, method, class, ...) and `limit`.
|
|
23
|
-
- `codegraph_explore`: `query` (symbol names or natural language) and optional `maxFiles` to cap source lines returned.
|
|
16
|
+
## 细粒度工具(可选开启)
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
以下细粒度工具**默认隐藏**,以保持工具列表精简。它们只有在用户通过配置 `extraTools` 开启后才会注册;开启之前调用会报 "tool not found"。除非能在 `Available tools` 中看到它们,否则不要调用。
|
|
26
19
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
20
|
+
- `codegraph_query` — 定位符号:位置 + 签名,不含源码。
|
|
21
|
+
- `codegraph_node` — 单个已知符号的逐字源码 + 调用/被调轨迹,可链式追踪调用图。
|
|
22
|
+
- `codegraph_callers` / `codegraph_callees` — 谁调用了某符号 / 某符号调用了什么。
|
|
23
|
+
- `codegraph_impact` — 修改某符号的影响范围;编辑前调用。
|
|
24
|
+
- `codegraph_files` — 已建索引的文件树(tree/flat/grouped 按语言分组)与符号数量。
|
|
25
|
+
|
|
26
|
+
开启方式:在 `~/.pi/agent/extensions/pi-codegraph/config.json`(全局)或 `.pi/extensions/pi-codegraph/config.json`(项目,覆盖全局)中配置:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{ "extraTools": ["query", "node", "impact"] }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
短名(`node`、`impact`)与完整工具名(`codegraph_node`)均可,`"extraTools": "all"` 开启全部。配置在下一个会话生效(`/reload` 或重启 pi)。如果反复需要某个隐藏工具,可以向用户建议此配置。
|
|
33
|
+
|
|
34
|
+
## 如何查询
|
|
35
|
+
|
|
36
|
+
- `codegraph_explore` 接受 `path` 参数:要查询的项目目录,默认为当前工作目录。在 monorepo 中,传入包含 `.codegraph/` 的子项目目录。
|
|
37
|
+
|
|
38
|
+
## 反模式与指导
|
|
39
|
+
|
|
40
|
+
- **信任 AST 结果。** 不要用 grep 重复验证 codegraph 输出。
|
|
41
|
+
- **Already sent earlier in this conversation。** 当出现该提示时,内容已在会话上下文中——回看上下文,不要重新获取或 Read。
|
|
42
|
+
- **过期提示。** 如果输出警告 `⚠️ Some files referenced below were edited since the last index sync`,只直接读取其中被标记的文件;其余内容仍然新鲜。
|
|
43
|
+
- **无索引不可用。** 如果输出提示项目未建索引,本会话内停止对该项目调用 `codegraph_explore`,改用内置工具。是否建索引由用户决定——适当时建议用户运行 `/codegraph-init`。
|