@suwujs/codex-vault 0.5.2 → 0.5.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/package.json
CHANGED
package/plugin/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.3
|
|
@@ -343,6 +343,23 @@ def _build_banner(vault_dir):
|
|
|
343
343
|
# ── Main ───────────────────────────────────────────────────────────────
|
|
344
344
|
|
|
345
345
|
|
|
346
|
+
def _detect_platform():
|
|
347
|
+
"""Detect whether we're running under Claude Code or Codex CLI."""
|
|
348
|
+
if os.environ.get("CLAUDE_PROJECT_DIR"):
|
|
349
|
+
return "claude"
|
|
350
|
+
if os.environ.get("CODEX_PROJECT_DIR") or os.environ.get("CODEX_HOME"):
|
|
351
|
+
return "codex"
|
|
352
|
+
# Fallback: check parent process name
|
|
353
|
+
try:
|
|
354
|
+
ppid = os.getppid()
|
|
355
|
+
cmdline = Path(f"/proc/{ppid}/cmdline").read_text() if os.path.exists(f"/proc/{ppid}/cmdline") else ""
|
|
356
|
+
if "codex" in cmdline.lower():
|
|
357
|
+
return "codex"
|
|
358
|
+
except Exception:
|
|
359
|
+
pass
|
|
360
|
+
return "claude" # default
|
|
361
|
+
|
|
362
|
+
|
|
346
363
|
def main():
|
|
347
364
|
vault_dir = _find_vault_root()
|
|
348
365
|
if not vault_dir:
|
|
@@ -361,21 +378,25 @@ def main():
|
|
|
361
378
|
except Exception:
|
|
362
379
|
event = {}
|
|
363
380
|
|
|
381
|
+
platform = _detect_platform()
|
|
364
382
|
context = _build_context(vault_dir)
|
|
365
383
|
banner = _build_banner(vault_dir)
|
|
366
384
|
|
|
367
|
-
# =================== Codex hook trigger notification ===================
|
|
368
|
-
print("✅ 【Hook 通知】SessionStart 已触发 — 会话启动/恢复完成")
|
|
369
|
-
print(f" 会话 ID: {event.get('sessionId', '未知')} | Matcher: {event.get('matcher', 'N/A')}")
|
|
370
|
-
|
|
371
385
|
output = {
|
|
372
386
|
"hookSpecificOutput": {
|
|
373
387
|
"hookEventName": "SessionStart",
|
|
374
388
|
"additionalContext": context
|
|
375
389
|
},
|
|
376
|
-
"systemMessage": "【Codex Hook】SessionStart 执行完毕 ✅\n" + banner
|
|
377
390
|
}
|
|
378
391
|
|
|
392
|
+
if platform == "claude":
|
|
393
|
+
# Claude Code renders systemMessage in terminal
|
|
394
|
+
output["systemMessage"] = banner
|
|
395
|
+
else:
|
|
396
|
+
# Codex CLI: systemMessage not rendered by TUI,
|
|
397
|
+
# use stderr for terminal visibility (best effort)
|
|
398
|
+
sys.stderr.write(banner + "\n")
|
|
399
|
+
|
|
379
400
|
json.dump(output, sys.stdout)
|
|
380
401
|
sys.stdout.flush()
|
|
381
402
|
sys.exit(0)
|
|
@@ -343,6 +343,23 @@ def _build_banner(vault_dir):
|
|
|
343
343
|
# ── Main ───────────────────────────────────────────────────────────────
|
|
344
344
|
|
|
345
345
|
|
|
346
|
+
def _detect_platform():
|
|
347
|
+
"""Detect whether we're running under Claude Code or Codex CLI."""
|
|
348
|
+
if os.environ.get("CLAUDE_PROJECT_DIR"):
|
|
349
|
+
return "claude"
|
|
350
|
+
if os.environ.get("CODEX_PROJECT_DIR") or os.environ.get("CODEX_HOME"):
|
|
351
|
+
return "codex"
|
|
352
|
+
# Fallback: check parent process name
|
|
353
|
+
try:
|
|
354
|
+
ppid = os.getppid()
|
|
355
|
+
cmdline = Path(f"/proc/{ppid}/cmdline").read_text() if os.path.exists(f"/proc/{ppid}/cmdline") else ""
|
|
356
|
+
if "codex" in cmdline.lower():
|
|
357
|
+
return "codex"
|
|
358
|
+
except Exception:
|
|
359
|
+
pass
|
|
360
|
+
return "claude" # default
|
|
361
|
+
|
|
362
|
+
|
|
346
363
|
def main():
|
|
347
364
|
vault_dir = _find_vault_root()
|
|
348
365
|
if not vault_dir:
|
|
@@ -361,21 +378,25 @@ def main():
|
|
|
361
378
|
except Exception:
|
|
362
379
|
event = {}
|
|
363
380
|
|
|
381
|
+
platform = _detect_platform()
|
|
364
382
|
context = _build_context(vault_dir)
|
|
365
383
|
banner = _build_banner(vault_dir)
|
|
366
384
|
|
|
367
|
-
# =================== Codex hook trigger notification ===================
|
|
368
|
-
print("✅ 【Hook 通知】SessionStart 已触发 — 会话启动/恢复完成")
|
|
369
|
-
print(f" 会话 ID: {event.get('sessionId', '未知')} | Matcher: {event.get('matcher', 'N/A')}")
|
|
370
|
-
|
|
371
385
|
output = {
|
|
372
386
|
"hookSpecificOutput": {
|
|
373
387
|
"hookEventName": "SessionStart",
|
|
374
388
|
"additionalContext": context
|
|
375
389
|
},
|
|
376
|
-
"systemMessage": "【Codex Hook】SessionStart 执行完毕 ✅\n" + banner
|
|
377
390
|
}
|
|
378
391
|
|
|
392
|
+
if platform == "claude":
|
|
393
|
+
# Claude Code renders systemMessage in terminal
|
|
394
|
+
output["systemMessage"] = banner
|
|
395
|
+
else:
|
|
396
|
+
# Codex CLI: systemMessage not rendered by TUI,
|
|
397
|
+
# use stderr for terminal visibility (best effort)
|
|
398
|
+
sys.stderr.write(banner + "\n")
|
|
399
|
+
|
|
379
400
|
json.dump(output, sys.stdout)
|
|
380
401
|
sys.stdout.flush()
|
|
381
402
|
sys.exit(0)
|