@suwujs/codex-vault 0.7.2 → 0.7.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/README.md CHANGED
@@ -69,14 +69,14 @@ Hooks power the loop:
69
69
  |------|------|------|-------------|-----------|
70
70
  | **session-start** | Agent starts | Injects North Star goals, recent git changes, active work, vault file listing | SessionStart | SessionStart |
71
71
  | **classify-message** | Every message | Detects decisions, wins, project updates — hints the agent where to file them | UserPromptSubmit | UserPromptSubmit |
72
- | **validate-write** | After writing `.md` | Checks frontmatter and wikilinks catches mistakes before they stick | PostToolUse (Write\|Edit) | N/A (Codex only supports Bash) |
72
+ | **validate-write** | After writing `.md` / running Bash | Checks frontmatter and wikilinks (Claude); detects command failures (Codex) | PostToolUse (Write\|Edit) | PostToolUse (Bash) |
73
73
 
74
74
  ## Supported Agents
75
75
 
76
76
  | Agent | Hooks | Skills | Status |
77
77
  |-------|-------|--------|--------|
78
78
  | Claude Code | 3 hooks via `.claude/settings.json` | `/dump` `/recall` `/ingest` `/wrap-up` | Full support |
79
- | Codex CLI | 2 hooks via `.codex/hooks.json` | `$dump` `$recall` `$ingest` `$wrap-up` | Full support (PostToolUse limited to Bash by Codex) |
79
+ | Codex CLI | 3 hooks via `.codex/hooks.json` | `$dump` `$recall` `$ingest` `$wrap-up` | Full support |
80
80
  | Other | Write an adapter ([docs/adding-an-agent.md](docs/adding-an-agent.md)) | Depends on agent | Community |
81
81
 
82
82
  ## Vault Structure
package/README.zh-CN.md CHANGED
@@ -101,14 +101,14 @@ Hook 驱动整个循环:
101
101
  |------|---------|--------|-------------|-----------|
102
102
  | **session-start** | Agent 启动 | 注入 North Star 目标、近期 git 变更、活跃项目、vault 文件清单 | SessionStart | SessionStart |
103
103
  | **classify-message** | 每条消息 | 检测决策、成果、项目更新 — 提示 agent 该归档到哪里 | UserPromptSubmit | UserPromptSubmit |
104
- | **validate-write** | 写 `.md` 后 | 检查 frontmatter 和 wikilinks — 在落盘前纠错 | PostToolUse (Write\|Edit) | 不支持(Codex 仅支持 Bash |
104
+ | **validate-write** | 写 `.md` 后 / 执行 Bash 后 | 检查 frontmatter 和 wikilinks(Claude);检测命令失败(Codex) | PostToolUse (Write\|Edit) | PostToolUse (Bash) |
105
105
 
106
106
  ## 支持的 Agent
107
107
 
108
108
  | Agent | Hooks | Skills | 状态 |
109
109
  |-------|-------|--------|------|
110
110
  | Claude Code | `.claude/settings.json` 3 hooks | `/dump` `/recall` `/ingest` `/wrap-up` | 完整支持 |
111
- | Codex CLI | `.codex/hooks.json` 2 hooks | `$dump` `$recall` `$ingest` `$wrap-up` | 完整支持(PostToolUse 受 Codex 限制仅支持 Bash) |
111
+ | Codex CLI | `.codex/hooks.json` 3 hooks | `$dump` `$recall` `$ingest` `$wrap-up` | 完整支持 |
112
112
  | 其他 | 写适配器([指南](docs/adding-an-agent.md)) | 取决于 agent | 社区贡献 |
113
113
 
114
114
  ## Vault 结构
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suwujs/codex-vault",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Persistent knowledge vault for LLM agents (Claude Code, Codex CLI)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -85,9 +85,10 @@ def _match(patterns, text):
85
85
  return False
86
86
 
87
87
 
88
- def _find_vault_root():
88
+ def _find_vault_root(cwd=None):
89
89
  """Find vault root from CWD — check for Home.md/brain/, then vault/ subdir."""
90
- cwd = os.environ.get("CODEX_PROJECT_DIR", os.getcwd())
90
+ if cwd is None:
91
+ cwd = os.getcwd()
91
92
  if os.path.isfile(os.path.join(cwd, "Home.md")) or os.path.isdir(os.path.join(cwd, "brain")):
92
93
  return cwd
93
94
  vault_sub = os.path.join(cwd, "vault")
@@ -99,9 +100,9 @@ def _find_vault_root():
99
100
  return None
100
101
 
101
102
 
102
- def _read_mode():
103
+ def _read_mode(cwd=None):
103
104
  """Read classify mode from vault config. Default: suggest."""
104
- vault_root = _find_vault_root()
105
+ vault_root = _find_vault_root(cwd)
105
106
  if not vault_root:
106
107
  return "suggest"
107
108
  config_path = os.path.join(vault_root, ".codex-vault", "config.json")
@@ -219,11 +220,12 @@ def main():
219
220
  if not isinstance(prompt, str) or not prompt:
220
221
  sys.exit(0)
221
222
 
223
+ cwd = input_data.get("cwd", os.getcwd())
222
224
  signal_messages = []
223
225
  session_end_messages = []
224
226
 
225
227
  try:
226
- mode = _read_mode()
228
+ mode = _read_mode(cwd)
227
229
 
228
230
  # Regular signal classification
229
231
  signals = classify(prompt, mode)
@@ -231,7 +233,7 @@ def main():
231
233
 
232
234
  # Session-end check (always suggest mode — never auto-execute wrap-up)
233
235
  if is_session_end(prompt):
234
- vault_root = _find_vault_root()
236
+ vault_root = _find_vault_root(cwd)
235
237
  if vault_root:
236
238
  integrity_warnings = _check_vault_integrity(vault_root)
237
239
  if integrity_warnings:
@@ -17,9 +17,10 @@ from datetime import datetime
17
17
  from pathlib import Path
18
18
 
19
19
 
20
- def _find_vault_root():
20
+ def _find_vault_root(cwd=None):
21
21
  """Find vault root from CWD — check for Home.md/brain/, then vault/ subdir."""
22
- cwd = os.environ.get("CODEX_PROJECT_DIR", os.getcwd())
22
+ if cwd is None:
23
+ cwd = os.getcwd()
23
24
  if os.path.isfile(os.path.join(cwd, "Home.md")) or os.path.isdir(os.path.join(cwd, "brain")):
24
25
  return cwd
25
26
  vault_sub = os.path.join(cwd, "vault")
@@ -343,7 +344,14 @@ def _build_banner(vault_dir):
343
344
 
344
345
 
345
346
  def main():
346
- vault_dir = _find_vault_root()
347
+ # Read hook input first — Codex provides cwd via stdin JSON
348
+ try:
349
+ event = json.load(sys.stdin)
350
+ except Exception:
351
+ event = {}
352
+
353
+ cwd = event.get("cwd", os.getcwd())
354
+ vault_dir = _find_vault_root(cwd)
347
355
  if not vault_dir:
348
356
  output = {
349
357
  "hookSpecificOutput": {
@@ -354,12 +362,6 @@ def main():
354
362
  sys.stdout.write(json.dumps(output) + "\n")
355
363
  sys.exit(0)
356
364
 
357
- # Read hook input for session metadata
358
- try:
359
- event = json.load(sys.stdin)
360
- except Exception:
361
- event = {}
362
-
363
365
  context = _build_context(vault_dir)
364
366
 
365
367
  # Build a short summary for user-facing display
package/plugin/install.sh CHANGED
@@ -157,7 +157,7 @@ PYEOF
157
157
  # --- Helper: merge hooks into existing hooks.json (Codex CLI) ---
158
158
  # Codex CLI differences:
159
159
  # - SessionStart matcher: "startup|resume" (no compact)
160
- # - No PostToolUse hook (Codex only supports Bash matcher, not Write|Edit)
160
+ # - PostToolUse matcher: "Bash" (Codex only supports Bash, not Write|Edit)
161
161
 
162
162
  merge_codex_hooks_json() {
163
163
  local target_file="$1"
@@ -178,6 +178,10 @@ new_hooks = {
178
178
  "UserPromptSubmit": [{
179
179
  "hooks": [{"type": "command", "command": f"python3 {hooks_rel}/classify-message.py", "timeout": 15}]
180
180
  }],
181
+ "PostToolUse": [{
182
+ "matcher": "Bash",
183
+ "hooks": [{"type": "command", "command": f"python3 {hooks_rel}/validate-write.py", "timeout": 15}]
184
+ }],
181
185
  }
182
186
 
183
187
  if os.path.isfile(target_file):
@@ -346,7 +350,7 @@ setup_codex() {
346
350
  mkdir -p "$VAULT_DIR/.codex"
347
351
 
348
352
  merge_codex_hooks_json "$VAULT_DIR/.codex/hooks.json" "$HOOKS_REL/codex"
349
- echo " [+] .codex/hooks.json (2 hooks)"
353
+ echo " [+] .codex/hooks.json (3 hooks)"
350
354
 
351
355
  # Enable hooks feature flag
352
356
  enable_codex_hooks "$VAULT_DIR"