@suwujs/codex-vault 0.3.3 → 0.4.0

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
@@ -113,7 +113,7 @@ User-invoked skills — the agent suggests them, but only executes when you expl
113
113
  | `/ingest` | Process a source document into wiki pages with cross-links |
114
114
  | `/recall` | On-demand memory retrieval — search the vault for a topic and synthesize |
115
115
 
116
- The classify hook detects intent (decision, win, project update, query, ingest) and suggests the right skill. You decide whether to run it the agent never auto-writes vault notes.
116
+ The classify hook detects intent (decision, win, project update, query, ingest) and suggests the right skill. By default, you decide whether to run it (**suggest mode**). Set `{"classify_mode": "auto"}` in `vault/.codex-vault/config.json` to have the agent execute skills automatically (**auto mode**).
117
117
 
118
118
  Claude Code uses `/skill-name`, Codex CLI uses `$skill-name`. Both read from their respective `.claude/skills/` and `.codex/skills/` directories.
119
119
 
@@ -163,12 +163,22 @@ See [docs/usage.md](docs/usage.md) — 7 real scenarios from first session to pr
163
163
  | Your goals | Edit `brain/North Star.md` |
164
164
  | New note types | Add templates to `templates/`, update `plugin/instructions.md` |
165
165
  | More signals | Add patterns to `plugin/hooks/classify-message.py` |
166
+ | Auto-execute skills | Set `{"classify_mode": "auto"}` in `vault/.codex-vault/config.json` |
166
167
  | New agent | Add hooks and skills in `plugin/` ([guide](docs/adding-an-agent.md)) |
167
168
 
169
+ ## CLI
170
+
171
+ ```bash
172
+ npx @suwujs/codex-vault init # Install vault + hooks into current project
173
+ npx @suwujs/codex-vault upgrade # Upgrade hooks and skills (preserves vault data)
174
+ npx @suwujs/codex-vault uninstall # Remove hooks and skills (preserves vault data)
175
+ ```
176
+
168
177
  ## Requirements
169
178
 
170
179
  - Git
171
180
  - Python 3
181
+ - Node.js >= 18 (for CLI)
172
182
  - One of: [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex)
173
183
  - Optional: [Obsidian](https://obsidian.md) (for graph view, backlinks, visual browsing)
174
184
 
package/README.zh-CN.md CHANGED
@@ -146,10 +146,25 @@ vault/
146
146
  4. **图优先** — 目录按用途分组,`[[wikilinks]]` 按语义分组。链接是主要的组织工具。
147
147
  5. **面向未来** — 即使模型有了内建记忆,vault 仍然有价值:可审计、可迁移、git 追踪的本地存储。
148
148
 
149
+ ## CLI
150
+
151
+ ```bash
152
+ npx @suwujs/codex-vault init # 安装 vault + hooks 到当前项目
153
+ npx @suwujs/codex-vault upgrade # 升级 hooks 和 skills(保留 vault 数据)
154
+ npx @suwujs/codex-vault uninstall # 移除 hooks 和 skills(保留 vault 数据)
155
+ ```
156
+
157
+ ## 配置
158
+
159
+ | 配置项 | 文件 | 说明 |
160
+ |--------|------|------|
161
+ | 自动执行 skills | `vault/.codex-vault/config.json` | `{"classify_mode": "auto"}` — 检测到意图后自动执行对应 skill,而非建议 |
162
+
149
163
  ## 依赖
150
164
 
151
165
  - Git
152
166
  - Python 3
167
+ - Node.js >= 18(CLI 安装用)
153
168
  - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) 或 [Codex CLI](https://github.com/openai/codex)(二选一)
154
169
  - 可选:[Obsidian](https://obsidian.md)(图谱视图、反向链接、可视化浏览)
155
170
 
package/bin/cli.js CHANGED
@@ -64,12 +64,19 @@ function assertBash() {
64
64
  function runInit() {
65
65
  assertBash();
66
66
 
67
- // Check if already installed
67
+ // Check if already installed (including legacy codex-mem)
68
68
  const versionFile = path.join(process.cwd(), 'vault', '.codex-vault', 'version');
69
+ const legacyVersionFile = path.join(process.cwd(), 'vault', '.codex-mem', 'version');
69
70
  if (fs.existsSync(versionFile)) {
70
71
  const installed = fs.readFileSync(versionFile, 'utf8').trim();
71
72
  console.log(`codex-vault v${installed} is already installed in this directory.`);
72
- console.log('To reinstall, remove vault/.codex-vault/version first.');
73
+ console.log('Run "codex-vault upgrade" to update, or remove vault/.codex-vault/version to reinstall.');
74
+ return;
75
+ }
76
+ if (fs.existsSync(legacyVersionFile)) {
77
+ const installed = fs.readFileSync(legacyVersionFile, 'utf8').trim();
78
+ console.log(`Legacy codex-mem v${installed} detected.`);
79
+ console.log('Run "codex-vault uninstall" first, then "codex-vault init".');
73
80
  return;
74
81
  }
75
82
 
@@ -98,13 +105,19 @@ function runInit() {
98
105
  function cmdUpgrade() {
99
106
  assertBash();
100
107
 
101
- // Check if installed
108
+ // Check if installed (including legacy codex-mem)
102
109
  const versionFile = path.join(process.cwd(), 'vault', '.codex-vault', 'version');
103
- if (!fs.existsSync(versionFile)) {
110
+ const legacyVersionFile = path.join(process.cwd(), 'vault', '.codex-mem', 'version');
111
+ if (!fs.existsSync(versionFile) && !fs.existsSync(legacyVersionFile)) {
104
112
  console.error('codex-vault is not installed in this directory.');
105
113
  console.error('Run "codex-vault init" first.');
106
114
  process.exit(1);
107
115
  }
116
+ if (!fs.existsSync(versionFile) && fs.existsSync(legacyVersionFile)) {
117
+ console.error('Legacy codex-mem installation detected.');
118
+ console.error('Run "codex-vault uninstall" first, then "codex-vault init".');
119
+ process.exit(1);
120
+ }
108
121
 
109
122
  const installedVersion = fs.readFileSync(versionFile, 'utf8').trim();
110
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suwujs/codex-vault",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Persistent knowledge vault for LLM agents (Claude Code, Codex CLI)",
5
5
  "license": "MIT",
6
6
  "repository": {
package/plugin/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
@@ -20,6 +20,38 @@ if [ ! -f "Home.md" ] && [ ! -d "brain/" ]; then
20
20
  fi
21
21
  fi
22
22
 
23
+ # --- Visible banner (stderr → user terminal) ---
24
+ {
25
+ echo ""
26
+ echo " ╭─────────────────────────────────────╮"
27
+ echo " │ 📚 Codex-Vault · Session Context │"
28
+ echo " ├─────────────────────────────────────┤"
29
+
30
+ # North Star preview — extract first non-empty bullet under "## Current Focus"
31
+ if [ -f "brain/North Star.md" ]; then
32
+ GOAL=$(sed -n '/^## Current Focus/,/^## /{/^- ./{s/^- //;p;q;};}' "brain/North Star.md" | cut -c1-40)
33
+ [ -n "$GOAL" ] && echo " │ 🎯 $GOAL" || echo " │ 🎯 (set goals in North Star.md)"
34
+ else
35
+ echo " │ 🎯 (create brain/North Star.md)"
36
+ fi
37
+
38
+ # Active work count
39
+ WORK_COUNT=$(find work/active -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
40
+ echo " │ 📋 $WORK_COUNT active project(s)"
41
+
42
+ # Uncommitted changes count
43
+ CHANGE_COUNT=$(git status --short -- . 2>/dev/null | wc -l | tr -d ' ')
44
+ if [ "$CHANGE_COUNT" -gt 0 ]; then
45
+ echo " │ ✏️ $CHANGE_COUNT uncommitted change(s)"
46
+ else
47
+ echo " │ ✅ working tree clean"
48
+ fi
49
+
50
+ echo " ╰─────────────────────────────────────╯"
51
+ echo ""
52
+ } >&2
53
+
54
+ # --- Full context (stdout → agent) ---
23
55
  echo "## Session Context"
24
56
  echo ""
25
57
  echo "### Date"
@@ -20,6 +20,38 @@ if [ ! -f "Home.md" ] && [ ! -d "brain/" ]; then
20
20
  fi
21
21
  fi
22
22
 
23
+ # --- Visible banner (stderr → user terminal) ---
24
+ {
25
+ echo ""
26
+ echo " ╭─────────────────────────────────────╮"
27
+ echo " │ 📚 Codex-Vault · Session Context │"
28
+ echo " ├─────────────────────────────────────┤"
29
+
30
+ # North Star preview — extract first non-empty bullet under "## Current Focus"
31
+ if [ -f "brain/North Star.md" ]; then
32
+ GOAL=$(sed -n '/^## Current Focus/,/^## /{/^- ./{s/^- //;p;q;};}' "brain/North Star.md" | cut -c1-40)
33
+ [ -n "$GOAL" ] && echo " │ 🎯 $GOAL" || echo " │ 🎯 (set goals in North Star.md)"
34
+ else
35
+ echo " │ 🎯 (create brain/North Star.md)"
36
+ fi
37
+
38
+ # Active work count
39
+ WORK_COUNT=$(find work/active -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
40
+ echo " │ 📋 $WORK_COUNT active project(s)"
41
+
42
+ # Uncommitted changes count
43
+ CHANGE_COUNT=$(git status --short -- . 2>/dev/null | wc -l | tr -d ' ')
44
+ if [ "$CHANGE_COUNT" -gt 0 ]; then
45
+ echo " │ ✏️ $CHANGE_COUNT uncommitted change(s)"
46
+ else
47
+ echo " │ ✅ working tree clean"
48
+ fi
49
+
50
+ echo " ╰─────────────────────────────────────╯"
51
+ echo ""
52
+ } >&2
53
+
54
+ # --- Full context (stdout → agent) ---
23
55
  echo "## Session Context"
24
56
  echo ""
25
57
  echo "### Date"
@@ -40,12 +72,12 @@ echo "### Recent Changes"
40
72
  COMMITS_48H=$(git log --oneline --since="48 hours ago" --no-merges 2>/dev/null | wc -l | tr -d ' ')
41
73
  if [ "$COMMITS_48H" -gt 0 ]; then
42
74
  echo "(last 48 hours)"
43
- git log --oneline --since="48 hours ago" --no-merges 2>/dev/null | head -15
75
+ git log --oneline --since="48 hours ago" --no-merges 2>/dev/null | head -15 || true
44
76
  else
45
77
  COMMITS_7D=$(git log --oneline --since="7 days ago" --no-merges 2>/dev/null | wc -l | tr -d ' ')
46
78
  if [ "$COMMITS_7D" -gt 0 ]; then
47
79
  echo "(nothing in 48h — showing last 7 days)"
48
- git log --oneline --since="7 days ago" --no-merges 2>/dev/null | head -15
80
+ git log --oneline --since="7 days ago" --no-merges 2>/dev/null | head -15 || true
49
81
  else
50
82
  echo "(nothing recent — showing last 5 commits)"
51
83
  git log --oneline -5 --no-merges 2>/dev/null || echo "(no git history)"
@@ -84,7 +116,7 @@ echo ""
84
116
 
85
117
  # Uncommitted changes — shows agent what's in-flight
86
118
  echo "### Uncommitted Changes"
87
- CHANGES=$(git status --short -- . 2>/dev/null | head -20)
119
+ CHANGES=$(git status --short -- . 2>/dev/null | head -20 || true)
88
120
  if [ -n "$CHANGES" ]; then
89
121
  echo "$CHANGES"
90
122
  else