Skip to content

Commit c2886c7

Browse files
author
hiwepy@gmail.com
committed
fix: 提醒 Hook 始终成功退出并升级至 0.1.6
1 parent cf4f82a commit c2886c7

16 files changed

Lines changed: 126 additions & 60 deletions

File tree

‎.agents/plugins/marketplace.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
"source": {
1010
"source": "url",
1111
"url": "https://github.com/full-stack-plugins/codegraph-plugin.git",
12-
"ref": "v0.1.5"
12+
"ref": "v0.1.6"
1313
},
1414
"policy": {
1515
"installation": "AVAILABLE",
1616
"authentication": "ON_USE"
1717
},
1818
"category": "Developer Tools",
19-
"version": "0.1.5",
19+
"version": "0.1.6",
2020
"description": "Inject the official CodeGraph prompt at session start (only when a `.codegraph/` directory exists) and expose all 20 codegraph CLI commands as slash commands for Codex/ZCode/Kimi/Claude Code. Pure Python stdlib.",
21-
"icon": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codegraph-plugin@v0.1.5/assets/official-logo.png",
21+
"icon": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codegraph-plugin@v0.1.6/assets/official-logo.png",
2222
"interface": {
2323
"displayName": "CodeGraph",
2424
"shortDescription": "Discoverable codegraph — official prompt + all CLI commands",
25-
"logo": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codegraph-plugin@v0.1.5/assets/official-logo.png"
25+
"logo": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codegraph-plugin@v0.1.6/assets/official-logo.png"
2626
}
2727
}
2828
]

‎.codex-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codegraph",
3-
"version": "0.1.5+codex.20260924",
3+
"version": "0.1.6+codex.20261003",
44
"description": "Inject the official CodeGraph prompt at session start (only when a `.codegraph/` directory exists) and expose all 20 codegraph CLI commands as slash commands for Codex/ZCode/Kimi/Claude Code. Pure Python stdlib.",
55
"author": {
66
"name": "Full Stack Plugins",

‎.zcode-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"en": "CodeGraph",
66
"zh-CN": "CodeGraph 代码智能"
77
},
8-
"version": "0.1.5",
8+
"version": "0.1.6",
99
"description": "Inject the official CodeGraph prompt at session start (only when a `.codegraph/` directory exists) and expose all 20 codegraph CLI commands as slash commands for Codex/ZCode/Kimi/Claude Code. Pure Python stdlib.",
1010
"description_i18n": {
1111
"en": "At SessionStart, when a `.codegraph/` directory exists, this plugin writes the official CodeGraph prompt block to `<cwd>/.claude/CLAUDE.md` or `<cwd>/AGENTS.md`, and injects the same block as SessionStart additionalContext. Exposes all 20 codegraph CLI commands as slash commands.",

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## 版本
1313

14-
- 当前: v0.1.5
14+
- 当前: v0.1.6
1515
- 同步自 codegraph v1.5.0 的 `instructions-template.ts`
1616
- Codex 后缀: `<version>+codex.YYYYMMDD`
1717

@@ -34,4 +34,4 @@
3434
- 不暴露 `codegraph prompt-hook` / `codegraph serve --mcp`(codegraph 自家隐藏命令)
3535
- 不挂 PreToolUse/PostToolUse/UserPromptSubmit/Stop 钩子(避免与 codeguard-plugin 抢触发器)
3636
- 不自动跑 `codegraph install`(那是用户的一次性 wiring 决策,插件不能越权)
37-
- 不读取或上传任何源代码到外部
37+
- 不读取或上传任何源代码到外部

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Check `<cwd>/.codegraph/` exists?
8787
with the full CodeGraph prompt block
8888
```
8989

90-
All exceptions fail-open (exit 0) — the host agent never sees a SessionStart error from this plugin.
90+
The reminder launcher tries `python`, then `python3`, with UTF-8 enabled. If neither interpreter starts, it exits 0. Library-loading and injection errors also fail open; failure to write the instruction file still permits session-context injection. Host-enforced timeouts or process termination remain outside this guarantee.
9191

9292
## Coexistence with `codegraph install`
9393

@@ -118,4 +118,4 @@ Apache-2.0. See [LICENSE](LICENSE). The official CodeGraph prompt block in `scri
118118

119119
## Privacy
120120

121-
See [PRIVACY.md](PRIVACY.md). The plugin is client-side only, makes no network calls, reads no user source code, and writes only to host instruction files using marker-fenced replacement.
121+
See [PRIVACY.md](PRIVACY.md). The plugin is client-side only, makes no network calls, reads no user source code, and writes only to host instruction files using marker-fenced replacement.

‎README.zh-CN.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
内容为完整 CodeGraph 提示词块
9292
```
9393

94-
所有异常都 fail-open(exit 0)——宿主代理不会看到本插件的任何 SessionStart 错误。
94+
提醒启动器依次尝试 `python`、`python3`,并开启 UTF-8;两个解释器都不能启动时仍 exit 0。库加载与注入异常同样 fail-open,指令文件写入失败仍继续注入会话提醒。宿主强制超时或终止进程不在此保证范围内。
9595

9696
## 与 `codegraph install` 的共存
9797

@@ -125,4 +125,4 @@ Apache-2.0。详见 [LICENSE](LICENSE)。`scripts/codegraph_lib/prompt.py` 中
125125

126126
## 隐私
127127

128-
详见 [PRIVACY.md](PRIVACY.md)。本插件纯客户端,不联网,不读取用户源代码,仅用标记区间替换写宿主指令文件。
128+
详见 [PRIVACY.md](PRIVACY.md)。本插件纯客户端,不联网,不读取用户源代码,仅用标记区间替换写宿主指令文件。

‎com.github.copilot/hooks/hooks.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"hooks": [
77
{
88
"type": "command",
9-
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject_codegraph_prompt.py\"",
9+
"command": "python -X utf8 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject_codegraph_prompt.py\" || python3 -X utf8 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject_codegraph_prompt.py\" || exit 0",
1010
"timeout": 10,
1111
"statusMessage": "codegraph-plugin: 检测 .codegraph/ 并注入官方提示词…"
1212
}
1313
]
1414
}
1515
]
1616
}
17-
}
17+
}

‎com.github.copilot/hooks/inject_codegraph_prompt.py‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@
1515
import sys
1616
from pathlib import Path
1717

18-
PLUGIN_ROOT = next((c for c in Path(__file__).resolve().parents if (c / "plugin.json").is_file()), Path(__file__).resolve().parents[1])
19-
sys.path.insert(0, str(PLUGIN_ROOT / "scripts"))
20-
21-
from codegraph_lib import ( # noqa: E402
22-
CODEGRAPH_INSTRUCTIONS_BLOCK,
23-
CODEGRAPH_SECTION_END,
24-
CODEGRAPH_SECTION_START,
25-
is_indexed,
26-
replace_or_append_marked_section,
27-
resolve_instructions_path,
28-
)
29-
30-
3118
def read_payload() -> dict:
3219
"""从 stdin 读 SessionStart JSON payload.
3320
@@ -46,6 +33,21 @@ def read_payload() -> dict:
4633

4734
def main() -> int:
4835
try:
36+
# 安装包定位与库加载也属于提醒的 fail-open 边界。
37+
plugin_root = next(
38+
(c for c in Path(__file__).resolve().parents if (c / "plugin.json").is_file()),
39+
Path(__file__).resolve().parents[1],
40+
)
41+
sys.path.insert(0, str(plugin_root / "scripts"))
42+
from codegraph_lib import (
43+
CODEGRAPH_INSTRUCTIONS_BLOCK,
44+
CODEGRAPH_SECTION_END,
45+
CODEGRAPH_SECTION_START,
46+
is_indexed,
47+
replace_or_append_marked_section,
48+
resolve_instructions_path,
49+
)
50+
4951
payload = read_payload()
5052
cwd_str = payload.get("cwd") if isinstance(payload, dict) else None
5153
cwd = Path(cwd_str) if cwd_str else Path(os.getcwd())

‎dev.openhands/hooks/hooks.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"hooks": [
77
{
88
"type": "command",
9-
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject_codegraph_prompt.py\"",
9+
"command": "python -X utf8 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject_codegraph_prompt.py\" || python3 -X utf8 \"${CLAUDE_PLUGIN_ROOT}/hooks/inject_codegraph_prompt.py\" || exit 0",
1010
"timeout": 10,
1111
"statusMessage": "codegraph-plugin: 检测 .codegraph/ 并注入官方提示词…"
1212
}
1313
]
1414
}
1515
]
1616
}
17-
}
17+
}

‎dev.openhands/hooks/inject_codegraph_prompt.py‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@
1515
import sys
1616
from pathlib import Path
1717

18-
PLUGIN_ROOT = next((c for c in Path(__file__).resolve().parents if (c / "plugin.json").is_file()), Path(__file__).resolve().parents[1])
19-
sys.path.insert(0, str(PLUGIN_ROOT / "scripts"))
20-
21-
from codegraph_lib import ( # noqa: E402
22-
CODEGRAPH_INSTRUCTIONS_BLOCK,
23-
CODEGRAPH_SECTION_END,
24-
CODEGRAPH_SECTION_START,
25-
is_indexed,
26-
replace_or_append_marked_section,
27-
resolve_instructions_path,
28-
)
29-
30-
3118
def read_payload() -> dict:
3219
"""从 stdin 读 SessionStart JSON payload.
3320
@@ -46,6 +33,21 @@ def read_payload() -> dict:
4633

4734
def main() -> int:
4835
try:
36+
# 安装包定位与库加载也属于提醒的 fail-open 边界。
37+
plugin_root = next(
38+
(c for c in Path(__file__).resolve().parents if (c / "plugin.json").is_file()),
39+
Path(__file__).resolve().parents[1],
40+
)
41+
sys.path.insert(0, str(plugin_root / "scripts"))
42+
from codegraph_lib import (
43+
CODEGRAPH_INSTRUCTIONS_BLOCK,
44+
CODEGRAPH_SECTION_END,
45+
CODEGRAPH_SECTION_START,
46+
is_indexed,
47+
replace_or_append_marked_section,
48+
resolve_instructions_path,
49+
)
50+
4951
payload = read_payload()
5052
cwd_str = payload.get("cwd") if isinstance(payload, dict) else None
5153
cwd = Path(cwd_str) if cwd_str else Path(os.getcwd())

0 commit comments

Comments
 (0)