@suwujs/codex-vault 0.1.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/LICENSE +21 -0
- package/README.md +174 -0
- package/README.zh-CN.md +155 -0
- package/bin/cli.js +90 -0
- package/package.json +29 -0
- package/plugin/VERSION +1 -0
- package/plugin/hooks/classify-message.py +240 -0
- package/plugin/hooks/session-start.sh +176 -0
- package/plugin/hooks/validate-write.py +113 -0
- package/plugin/install.sh +350 -0
- package/plugin/instructions.md +118 -0
- package/plugin/skills/dump.md +29 -0
- package/plugin/skills/ingest.md +63 -0
- package/plugin/skills/recall.md +54 -0
- package/plugin/skills/wrap-up.md +35 -0
- package/vault/.claude/settings.json +39 -0
- package/vault/.claude/skills/dump/SKILL.md +29 -0
- package/vault/.claude/skills/ingest/SKILL.md +63 -0
- package/vault/.claude/skills/recall/SKILL.md +54 -0
- package/vault/.claude/skills/wrap-up/SKILL.md +35 -0
- package/vault/.codex/config.toml +2 -0
- package/vault/.codex/hooks.json +39 -0
- package/vault/.codex/skills/dump/SKILL.md +29 -0
- package/vault/.codex/skills/ingest/SKILL.md +63 -0
- package/vault/.codex/skills/recall/SKILL.md +54 -0
- package/vault/.codex/skills/wrap-up/SKILL.md +35 -0
- package/vault/.codex-vault/hooks/classify-message.py +240 -0
- package/vault/.codex-vault/hooks/session-start.sh +176 -0
- package/vault/.codex-vault/hooks/validate-write.py +113 -0
- package/vault/AGENTS.md +118 -0
- package/vault/CLAUDE.md +118 -0
- package/vault/Home.md +21 -0
- package/vault/brain/Key Decisions.md +11 -0
- package/vault/brain/Memories.md +19 -0
- package/vault/brain/North Star.md +29 -0
- package/vault/brain/Patterns.md +11 -0
- package/vault/log.md +15 -0
- package/vault/reference/.gitkeep +0 -0
- package/vault/sources/.gitkeep +0 -0
- package/vault/sources/README.md +19 -0
- package/vault/templates/Decision Record.md +29 -0
- package/vault/templates/Reference Note.md +25 -0
- package/vault/templates/Source Summary.md +25 -0
- package/vault/templates/Thinking Note.md +26 -0
- package/vault/templates/Work Note.md +25 -0
- package/vault/work/Index.md +35 -0
- package/vault/work/active/.gitkeep +0 -0
- package/vault/work/archive/.gitkeep +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -eo pipefail
|
|
3
|
+
|
|
4
|
+
# Codex-Vault session-start hook
|
|
5
|
+
# Injects vault context into the agent's prompt at session start.
|
|
6
|
+
# Works with any agent that supports SessionStart hooks (Claude Code, Codex CLI).
|
|
7
|
+
#
|
|
8
|
+
# Dynamic context: adapts git log window, reads full North Star,
|
|
9
|
+
# shows all active work, and includes uncommitted changes.
|
|
10
|
+
|
|
11
|
+
VAULT_DIR="${CLAUDE_PROJECT_DIR:-${CODEX_PROJECT_DIR:-$(pwd)}}"
|
|
12
|
+
cd "$VAULT_DIR"
|
|
13
|
+
|
|
14
|
+
# Find vault root (look for Home.md or brain/ directory)
|
|
15
|
+
if [ ! -f "Home.md" ] && [ ! -d "brain/" ]; then
|
|
16
|
+
# Try vault/ subdirectory (integrated layout)
|
|
17
|
+
if [ -d "vault/" ]; then
|
|
18
|
+
VAULT_DIR="$VAULT_DIR/vault"
|
|
19
|
+
cd "$VAULT_DIR"
|
|
20
|
+
fi
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
echo "## Session Context"
|
|
24
|
+
echo ""
|
|
25
|
+
echo "### Date"
|
|
26
|
+
echo "$(date +%Y-%m-%d) ($(date +%A))"
|
|
27
|
+
echo ""
|
|
28
|
+
|
|
29
|
+
# North Star — full file (should be concise by design)
|
|
30
|
+
echo "### North Star"
|
|
31
|
+
if [ -f "brain/North Star.md" ]; then
|
|
32
|
+
cat "brain/North Star.md"
|
|
33
|
+
else
|
|
34
|
+
echo "(No North Star found — create brain/North Star.md to set goals)"
|
|
35
|
+
fi
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
# Recent changes — adaptive window
|
|
39
|
+
echo "### Recent Changes"
|
|
40
|
+
COMMITS_48H=$(git log --oneline --since="48 hours ago" --no-merges 2>/dev/null | wc -l | tr -d ' ')
|
|
41
|
+
if [ "$COMMITS_48H" -gt 0 ]; then
|
|
42
|
+
echo "(last 48 hours)"
|
|
43
|
+
git log --oneline --since="48 hours ago" --no-merges 2>/dev/null | head -15
|
|
44
|
+
else
|
|
45
|
+
COMMITS_7D=$(git log --oneline --since="7 days ago" --no-merges 2>/dev/null | wc -l | tr -d ' ')
|
|
46
|
+
if [ "$COMMITS_7D" -gt 0 ]; then
|
|
47
|
+
echo "(nothing in 48h — showing last 7 days)"
|
|
48
|
+
git log --oneline --since="7 days ago" --no-merges 2>/dev/null | head -15
|
|
49
|
+
else
|
|
50
|
+
echo "(nothing recent — showing last 5 commits)"
|
|
51
|
+
git log --oneline -5 --no-merges 2>/dev/null || echo "(no git history)"
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
54
|
+
echo ""
|
|
55
|
+
|
|
56
|
+
# Recent operations from log — adaptive
|
|
57
|
+
echo "### Recent Operations"
|
|
58
|
+
if [ -f "log.md" ]; then
|
|
59
|
+
ENTRY_COUNT=$(grep -c "^## \[" "log.md" 2>/dev/null || echo "0")
|
|
60
|
+
if [ "$ENTRY_COUNT" -gt 0 ]; then
|
|
61
|
+
# Show last 5 entries with full header line (includes date + type)
|
|
62
|
+
grep "^## \[" "log.md" | tail -5
|
|
63
|
+
else
|
|
64
|
+
echo "(no entries in log.md)"
|
|
65
|
+
fi
|
|
66
|
+
else
|
|
67
|
+
echo "(no log.md)"
|
|
68
|
+
fi
|
|
69
|
+
echo ""
|
|
70
|
+
|
|
71
|
+
# Active work — show all (this is the current focus, no truncation)
|
|
72
|
+
echo "### Active Work"
|
|
73
|
+
if [ -d "work/active" ]; then
|
|
74
|
+
WORK_FILES=$(ls work/active/*.md 2>/dev/null || true)
|
|
75
|
+
if [ -n "$WORK_FILES" ]; then
|
|
76
|
+
echo "$WORK_FILES" | sed 's|work/active/||;s|\.md$||'
|
|
77
|
+
else
|
|
78
|
+
echo "(none)"
|
|
79
|
+
fi
|
|
80
|
+
else
|
|
81
|
+
echo "(no work/active/ directory)"
|
|
82
|
+
fi
|
|
83
|
+
echo ""
|
|
84
|
+
|
|
85
|
+
# Uncommitted changes — shows agent what's in-flight
|
|
86
|
+
echo "### Uncommitted Changes"
|
|
87
|
+
CHANGES=$(git status --short -- . 2>/dev/null | head -20)
|
|
88
|
+
if [ -n "$CHANGES" ]; then
|
|
89
|
+
echo "$CHANGES"
|
|
90
|
+
else
|
|
91
|
+
echo "(working tree clean)"
|
|
92
|
+
fi
|
|
93
|
+
echo ""
|
|
94
|
+
|
|
95
|
+
# Recently modified brain files — highlights memory that may need review
|
|
96
|
+
echo "### Recently Modified Brain Files"
|
|
97
|
+
if [ -d "brain" ]; then
|
|
98
|
+
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null || echo "")
|
|
99
|
+
if [ -n "$GIT_DIR" ] && [ -f "$GIT_DIR/index" ]; then
|
|
100
|
+
RECENT_BRAIN=$(find brain/ -name "*.md" -newer "$GIT_DIR/index" 2>/dev/null || true)
|
|
101
|
+
else
|
|
102
|
+
RECENT_BRAIN=""
|
|
103
|
+
fi
|
|
104
|
+
if [ -n "$RECENT_BRAIN" ]; then
|
|
105
|
+
echo "$RECENT_BRAIN" | sed 's|brain/||;s|\.md$||'
|
|
106
|
+
else
|
|
107
|
+
# Fallback: show brain files modified in last 7 days
|
|
108
|
+
RECENT_BRAIN=$(find brain/ -name "*.md" -mtime -7 2>/dev/null || true)
|
|
109
|
+
if [ -n "$RECENT_BRAIN" ]; then
|
|
110
|
+
echo "(modified in last 7 days)"
|
|
111
|
+
echo "$RECENT_BRAIN" | sed 's|brain/||;s|\.md$||'
|
|
112
|
+
else
|
|
113
|
+
echo "(no recent changes)"
|
|
114
|
+
fi
|
|
115
|
+
fi
|
|
116
|
+
fi
|
|
117
|
+
echo ""
|
|
118
|
+
|
|
119
|
+
# Vault file listing — tiered to avoid flooding context in large vaults
|
|
120
|
+
echo "### Vault Files"
|
|
121
|
+
ALL_FILES=$(find . -name "*.md" -not -path "./.git/*" -not -path "./.obsidian/*" -not -path "./thinking/*" -not -path "./.claude/*" -not -path "./.codex/*" -not -path "./.codex-vault/*" -not -path "./node_modules/*" 2>/dev/null | sort)
|
|
122
|
+
FILE_COUNT=$(echo "$ALL_FILES" | grep -c . 2>/dev/null || echo "0")
|
|
123
|
+
|
|
124
|
+
_folder_summary() {
|
|
125
|
+
echo "$ALL_FILES" | sed 's|^\./||' | cut -d/ -f1 | sort | uniq -c | sort -rn | while read count dir; do
|
|
126
|
+
echo " $dir/ ($count files)"
|
|
127
|
+
done
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_key_files() {
|
|
131
|
+
echo "$ALL_FILES" | grep -E "(Home|Index|North Star|Memories|Key Decisions|Patterns|log)\\.md$" || true
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if [ "$FILE_COUNT" -le 20 ]; then
|
|
135
|
+
# Tier 1: small vault — list everything
|
|
136
|
+
echo "$ALL_FILES"
|
|
137
|
+
|
|
138
|
+
elif [ "$FILE_COUNT" -le 50 ]; then
|
|
139
|
+
# Tier 2: medium vault — list hot folders, summarize cold storage
|
|
140
|
+
HOT_FILES=$(echo "$ALL_FILES" | grep -v -E "^\./sources/|^\./work/archive/" || true)
|
|
141
|
+
COLD_COUNT=$(echo "$ALL_FILES" | grep -E "^\./sources/|^\./work/archive/" | grep -c . 2>/dev/null || echo "0")
|
|
142
|
+
|
|
143
|
+
if [ -n "$HOT_FILES" ]; then
|
|
144
|
+
echo "$HOT_FILES"
|
|
145
|
+
fi
|
|
146
|
+
if [ "$COLD_COUNT" -gt 0 ]; then
|
|
147
|
+
echo ""
|
|
148
|
+
echo "(+ $COLD_COUNT files in sources/ and work/archive/ — use /recall to search)"
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
elif [ "$FILE_COUNT" -le 150 ]; then
|
|
152
|
+
# Tier 3: large vault — folder summary + recent + key files
|
|
153
|
+
echo "($FILE_COUNT files — showing summary)"
|
|
154
|
+
echo ""
|
|
155
|
+
_folder_summary
|
|
156
|
+
echo ""
|
|
157
|
+
echo "Recently modified (7 days):"
|
|
158
|
+
find . -name "*.md" -mtime -7 -not -path "./.git/*" -not -path "./.obsidian/*" -not -path "./thinking/*" -not -path "./.claude/*" -not -path "./.codex/*" -not -path "./.codex-vault/*" -not -path "./node_modules/*" 2>/dev/null | sort || echo " (none)"
|
|
159
|
+
echo ""
|
|
160
|
+
echo "Key files:"
|
|
161
|
+
_key_files
|
|
162
|
+
|
|
163
|
+
else
|
|
164
|
+
# Tier 4: very large vault — minimal footprint
|
|
165
|
+
echo "($FILE_COUNT files — showing summary)"
|
|
166
|
+
echo ""
|
|
167
|
+
_folder_summary
|
|
168
|
+
echo ""
|
|
169
|
+
echo "Recently modified (3 days):"
|
|
170
|
+
find . -name "*.md" -mtime -3 -not -path "./.git/*" -not -path "./.obsidian/*" -not -path "./thinking/*" -not -path "./.claude/*" -not -path "./.codex/*" -not -path "./.codex-vault/*" -not -path "./node_modules/*" 2>/dev/null | sort || echo " (none)"
|
|
171
|
+
echo ""
|
|
172
|
+
echo "Key files:"
|
|
173
|
+
_key_files
|
|
174
|
+
echo ""
|
|
175
|
+
echo "Use /recall <topic> to search the vault."
|
|
176
|
+
fi
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Post-write validation for vault notes.
|
|
3
|
+
|
|
4
|
+
Checks frontmatter and wikilinks on any .md file written to the vault.
|
|
5
|
+
Agent-agnostic — outputs hookSpecificOutput compatible with both
|
|
6
|
+
Claude Code and Codex CLI.
|
|
7
|
+
"""
|
|
8
|
+
import json
|
|
9
|
+
import re
|
|
10
|
+
import sys
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _check_log_format(content):
|
|
16
|
+
"""Validate log.md entry format: ## [YYYY-MM-DD] <type> | <title>"""
|
|
17
|
+
warnings = []
|
|
18
|
+
for i, line in enumerate(content.splitlines(), 1):
|
|
19
|
+
if line.startswith("## ") and not line.startswith("## ["):
|
|
20
|
+
# Heading that looks like a log entry but missing date brackets
|
|
21
|
+
if any(t in line.lower() for t in ["ingest", "session", "query", "maintenance", "decision", "archive"]):
|
|
22
|
+
warnings.append(f"Line {i}: log entry missing date format — expected `## [YYYY-MM-DD] <type> | <title>`")
|
|
23
|
+
elif line.startswith("## ["):
|
|
24
|
+
if not re.match(r"^## \[\d{4}-\d{2}-\d{2}\] \w+", line):
|
|
25
|
+
warnings.append(f"Line {i}: malformed log entry — expected `## [YYYY-MM-DD] <type> | <title>`")
|
|
26
|
+
return warnings
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main():
|
|
30
|
+
try:
|
|
31
|
+
input_data = json.load(sys.stdin)
|
|
32
|
+
except (ValueError, EOFError, OSError):
|
|
33
|
+
sys.exit(0)
|
|
34
|
+
|
|
35
|
+
tool_input = input_data.get("tool_input")
|
|
36
|
+
if not isinstance(tool_input, dict):
|
|
37
|
+
sys.exit(0)
|
|
38
|
+
|
|
39
|
+
file_path = tool_input.get("file_path", "")
|
|
40
|
+
if not isinstance(file_path, str) or not file_path:
|
|
41
|
+
sys.exit(0)
|
|
42
|
+
|
|
43
|
+
if not file_path.endswith(".md"):
|
|
44
|
+
sys.exit(0)
|
|
45
|
+
|
|
46
|
+
normalized = file_path.replace("\\", "/")
|
|
47
|
+
basename = os.path.basename(normalized)
|
|
48
|
+
|
|
49
|
+
# Skip non-vault files
|
|
50
|
+
skip_names = {"README.md", "CHANGELOG.md", "CONTRIBUTING.md", "CLAUDE.md", "AGENTS.md", "LICENSE"}
|
|
51
|
+
if basename in skip_names:
|
|
52
|
+
sys.exit(0)
|
|
53
|
+
if basename.startswith("README.") and basename.endswith(".md"):
|
|
54
|
+
sys.exit(0)
|
|
55
|
+
|
|
56
|
+
skip_paths = [".claude/", ".codex/", ".codex-vault/", ".mind/", "templates/", "thinking/", "node_modules/", "plugin/", "docs/"]
|
|
57
|
+
if any(skip in normalized for skip in skip_paths):
|
|
58
|
+
sys.exit(0)
|
|
59
|
+
|
|
60
|
+
warnings = []
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
content = Path(file_path).read_text(encoding="utf-8")
|
|
64
|
+
|
|
65
|
+
if not content.startswith("---"):
|
|
66
|
+
warnings.append("Missing YAML frontmatter")
|
|
67
|
+
else:
|
|
68
|
+
parts = content.split("---", 2)
|
|
69
|
+
if len(parts) >= 3:
|
|
70
|
+
fm = parts[1]
|
|
71
|
+
if "date:" not in fm and basename != "log.md":
|
|
72
|
+
warnings.append("Missing `date` in frontmatter")
|
|
73
|
+
if "tags:" not in fm:
|
|
74
|
+
warnings.append("Missing `tags` in frontmatter")
|
|
75
|
+
if "description:" not in fm:
|
|
76
|
+
warnings.append("Missing `description` in frontmatter (~150 chars)")
|
|
77
|
+
|
|
78
|
+
if len(content) > 300 and "[[" not in content:
|
|
79
|
+
warnings.append("No [[wikilinks]] found — every note should link to at least one other note")
|
|
80
|
+
|
|
81
|
+
# Check for unfilled template placeholders
|
|
82
|
+
placeholders = re.findall(r"\{\{[^}]+\}\}", content)
|
|
83
|
+
if placeholders:
|
|
84
|
+
examples = ", ".join(placeholders[:3])
|
|
85
|
+
warnings.append(f"Unfilled template placeholders found: {examples}")
|
|
86
|
+
|
|
87
|
+
# Validate log.md format
|
|
88
|
+
if basename == "log.md":
|
|
89
|
+
log_warnings = _check_log_format(content)
|
|
90
|
+
warnings.extend(log_warnings)
|
|
91
|
+
|
|
92
|
+
except Exception:
|
|
93
|
+
sys.exit(0)
|
|
94
|
+
|
|
95
|
+
if warnings:
|
|
96
|
+
hint_list = "\n".join(f" - {w}" for w in warnings)
|
|
97
|
+
output = {
|
|
98
|
+
"hookSpecificOutput": {
|
|
99
|
+
"hookEventName": "PostToolUse",
|
|
100
|
+
"additionalContext": f"Vault warnings for `{basename}`:\n{hint_list}\nFix these before moving on."
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
json.dump(output, sys.stdout)
|
|
104
|
+
sys.stdout.flush()
|
|
105
|
+
|
|
106
|
+
sys.exit(0)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
try:
|
|
111
|
+
main()
|
|
112
|
+
except Exception:
|
|
113
|
+
sys.exit(0)
|
package/vault/AGENTS.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Codex-Vault — Core Instructions
|
|
2
|
+
|
|
3
|
+
A structured knowledge vault maintained by an LLM agent. You write notes, maintain links, and keep indexes current. The human curates sources, directs analysis, and asks questions.
|
|
4
|
+
|
|
5
|
+
## Vault Structure
|
|
6
|
+
|
|
7
|
+
| Folder | Purpose |
|
|
8
|
+
|--------|---------|
|
|
9
|
+
| `Home.md` | Vault entry point — quick links, current focus |
|
|
10
|
+
| `brain/` | Persistent memory — goals, decisions, patterns |
|
|
11
|
+
| `work/` | Work notes index (`Index.md`) |
|
|
12
|
+
| `work/active/` | Current projects (move to archive when done) |
|
|
13
|
+
| `work/archive/` | Completed work |
|
|
14
|
+
| `templates/` | Note templates with YAML frontmatter |
|
|
15
|
+
| `sources/` | Raw source documents — immutable, LLM reads only |
|
|
16
|
+
| `thinking/` | Scratchpad — promote findings, then delete |
|
|
17
|
+
| `reference/` | Saved answers and analyses from query writeback |
|
|
18
|
+
|
|
19
|
+
## Session Lifecycle
|
|
20
|
+
|
|
21
|
+
### Start
|
|
22
|
+
|
|
23
|
+
The SessionStart hook injects: North Star goals, recent git changes, active work, vault file listing. You start with context, not a blank slate.
|
|
24
|
+
|
|
25
|
+
### Work
|
|
26
|
+
|
|
27
|
+
1. The classify hook detects intent and suggests skills — **do not auto-execute**. Suggest the skill to the user and let them decide.
|
|
28
|
+
2. Available skills: `/dump`, `/recall`, `/ingest`, `/wrap-up`
|
|
29
|
+
3. Search before creating — check if a related note exists (use `/recall <topic>` for targeted vault search)
|
|
30
|
+
4. Update `work/Index.md` if a new note was created
|
|
31
|
+
|
|
32
|
+
### End
|
|
33
|
+
|
|
34
|
+
When the user says "wrap up" or similar:
|
|
35
|
+
1. Verify new notes have frontmatter and wikilinks
|
|
36
|
+
2. Update `work/Index.md` with any new or completed notes
|
|
37
|
+
3. Archive completed projects: move from `work/active/` to `work/archive/`
|
|
38
|
+
4. Check if `brain/` notes need updating with new decisions or patterns
|
|
39
|
+
|
|
40
|
+
## Creating Notes
|
|
41
|
+
|
|
42
|
+
1. **Always use YAML frontmatter**: `date`, `description` (~150 chars), `tags`
|
|
43
|
+
2. **Use templates** from `templates/`
|
|
44
|
+
3. **Place files correctly**: active work in `work/active/`, completed in `work/archive/`, source summaries in `work/active/` (tag: `source-summary`), drafts in `thinking/`
|
|
45
|
+
4. **Name files descriptively** — use the note title as filename
|
|
46
|
+
|
|
47
|
+
## Linking — Critical
|
|
48
|
+
|
|
49
|
+
**Graph-first.** Folders group by purpose, links group by meaning. A note lives in one folder but links to many notes.
|
|
50
|
+
|
|
51
|
+
**A note without links is a bug.** Every new note must link to at least one existing note via `[[wikilinks]]`.
|
|
52
|
+
|
|
53
|
+
Link syntax:
|
|
54
|
+
- `[[Note Title]]` — standard wikilink
|
|
55
|
+
- `[[Note Title|display text]]` — aliased
|
|
56
|
+
- `[[Note Title#Heading]]` — deep link
|
|
57
|
+
|
|
58
|
+
### When to Link
|
|
59
|
+
|
|
60
|
+
- Work note ↔ Decision Record (bidirectional)
|
|
61
|
+
- Index → all work notes
|
|
62
|
+
- North Star → active projects
|
|
63
|
+
- Memories → source notes
|
|
64
|
+
|
|
65
|
+
## Memory System
|
|
66
|
+
|
|
67
|
+
All persistent memory lives in `brain/`:
|
|
68
|
+
|
|
69
|
+
| File | Stores |
|
|
70
|
+
|------|--------|
|
|
71
|
+
| `North Star.md` | Goals and focus areas — read every session |
|
|
72
|
+
| `Memories.md` | Index of memory topics |
|
|
73
|
+
| `Key Decisions.md` | Decisions worth recalling across sessions |
|
|
74
|
+
| `Patterns.md` | Recurring patterns discovered across work |
|
|
75
|
+
|
|
76
|
+
When asked to "remember" something: write to the appropriate `brain/` file with a wikilink to context.
|
|
77
|
+
|
|
78
|
+
## Sources & Ingest
|
|
79
|
+
|
|
80
|
+
`sources/` holds raw source documents (articles, papers, web clips). This is the immutable layer — the agent reads from it but never modifies source files.
|
|
81
|
+
|
|
82
|
+
- Drop raw files into `sources/` (markdown preferred) or use `/ingest` with a URL
|
|
83
|
+
- `/ingest` reads the source, discusses key takeaways, then creates a **Source Summary** in `work/active/` with tag `source-summary`
|
|
84
|
+
- The summary uses the Source Summary template: Key Takeaways, Summary, Connections, Quotes/Data Points
|
|
85
|
+
- Every ingest updates `work/Index.md` (Sources section) and checks for cross-links to existing notes
|
|
86
|
+
- If the source contains decisions or patterns, update the relevant `brain/` notes too
|
|
87
|
+
- Source summaries link back to the raw source via the `source` frontmatter field
|
|
88
|
+
|
|
89
|
+
## Operation Log
|
|
90
|
+
|
|
91
|
+
Append to `log.md` after significant operations: ingests, decisions, project archives, maintenance passes.
|
|
92
|
+
|
|
93
|
+
- Format: `## [YYYY-MM-DD] <type> | <title>` followed by bullet points
|
|
94
|
+
- Types: `ingest`, `session`, `query`, `maintenance`, `decision`, `archive`
|
|
95
|
+
- Don't log every small edit — only operations that change the vault's knowledge state
|
|
96
|
+
- Entries are append-only; never edit or delete previous entries
|
|
97
|
+
|
|
98
|
+
## Query Writeback
|
|
99
|
+
|
|
100
|
+
When answering a substantial question that synthesizes multiple vault notes:
|
|
101
|
+
|
|
102
|
+
1. Offer: "This answer could be useful later — want me to save it as a reference note?"
|
|
103
|
+
2. If yes, create a Reference Note in `reference/` using the template
|
|
104
|
+
3. Link the reference note from related work notes in `## Related`
|
|
105
|
+
4. Add the reference note to `work/Index.md` under `## Reference`
|
|
106
|
+
5. Don't prompt for trivial questions — only for answers that synthesize, compare, or analyze
|
|
107
|
+
|
|
108
|
+
## Vault Location
|
|
109
|
+
|
|
110
|
+
The vault may live at the project root or in a `vault/` subdirectory. Use the SessionStart context to determine the actual path. All folder references above (e.g. `brain/`, `work/active/`) are relative to the vault root.
|
|
111
|
+
|
|
112
|
+
## Rules
|
|
113
|
+
|
|
114
|
+
- Preserve existing frontmatter when editing notes
|
|
115
|
+
- Always check for and suggest connections between notes
|
|
116
|
+
- Every note must have a `description` field (~150 chars)
|
|
117
|
+
- When reorganizing, never delete without user confirmation
|
|
118
|
+
- Use `[[wikilinks]]` not markdown links
|
package/vault/CLAUDE.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Codex-Vault — Core Instructions
|
|
2
|
+
|
|
3
|
+
A structured knowledge vault maintained by an LLM agent. You write notes, maintain links, and keep indexes current. The human curates sources, directs analysis, and asks questions.
|
|
4
|
+
|
|
5
|
+
## Vault Structure
|
|
6
|
+
|
|
7
|
+
| Folder | Purpose |
|
|
8
|
+
|--------|---------|
|
|
9
|
+
| `Home.md` | Vault entry point — quick links, current focus |
|
|
10
|
+
| `brain/` | Persistent memory — goals, decisions, patterns |
|
|
11
|
+
| `work/` | Work notes index (`Index.md`) |
|
|
12
|
+
| `work/active/` | Current projects (move to archive when done) |
|
|
13
|
+
| `work/archive/` | Completed work |
|
|
14
|
+
| `templates/` | Note templates with YAML frontmatter |
|
|
15
|
+
| `sources/` | Raw source documents — immutable, LLM reads only |
|
|
16
|
+
| `thinking/` | Scratchpad — promote findings, then delete |
|
|
17
|
+
| `reference/` | Saved answers and analyses from query writeback |
|
|
18
|
+
|
|
19
|
+
## Session Lifecycle
|
|
20
|
+
|
|
21
|
+
### Start
|
|
22
|
+
|
|
23
|
+
The SessionStart hook injects: North Star goals, recent git changes, active work, vault file listing. You start with context, not a blank slate.
|
|
24
|
+
|
|
25
|
+
### Work
|
|
26
|
+
|
|
27
|
+
1. The classify hook detects intent and suggests skills — **do not auto-execute**. Suggest the skill to the user and let them decide.
|
|
28
|
+
2. Available skills: `/dump`, `/recall`, `/ingest`, `/wrap-up`
|
|
29
|
+
3. Search before creating — check if a related note exists (use `/recall <topic>` for targeted vault search)
|
|
30
|
+
4. Update `work/Index.md` if a new note was created
|
|
31
|
+
|
|
32
|
+
### End
|
|
33
|
+
|
|
34
|
+
When the user says "wrap up" or similar:
|
|
35
|
+
1. Verify new notes have frontmatter and wikilinks
|
|
36
|
+
2. Update `work/Index.md` with any new or completed notes
|
|
37
|
+
3. Archive completed projects: move from `work/active/` to `work/archive/`
|
|
38
|
+
4. Check if `brain/` notes need updating with new decisions or patterns
|
|
39
|
+
|
|
40
|
+
## Creating Notes
|
|
41
|
+
|
|
42
|
+
1. **Always use YAML frontmatter**: `date`, `description` (~150 chars), `tags`
|
|
43
|
+
2. **Use templates** from `templates/`
|
|
44
|
+
3. **Place files correctly**: active work in `work/active/`, completed in `work/archive/`, source summaries in `work/active/` (tag: `source-summary`), drafts in `thinking/`
|
|
45
|
+
4. **Name files descriptively** — use the note title as filename
|
|
46
|
+
|
|
47
|
+
## Linking — Critical
|
|
48
|
+
|
|
49
|
+
**Graph-first.** Folders group by purpose, links group by meaning. A note lives in one folder but links to many notes.
|
|
50
|
+
|
|
51
|
+
**A note without links is a bug.** Every new note must link to at least one existing note via `[[wikilinks]]`.
|
|
52
|
+
|
|
53
|
+
Link syntax:
|
|
54
|
+
- `[[Note Title]]` — standard wikilink
|
|
55
|
+
- `[[Note Title|display text]]` — aliased
|
|
56
|
+
- `[[Note Title#Heading]]` — deep link
|
|
57
|
+
|
|
58
|
+
### When to Link
|
|
59
|
+
|
|
60
|
+
- Work note ↔ Decision Record (bidirectional)
|
|
61
|
+
- Index → all work notes
|
|
62
|
+
- North Star → active projects
|
|
63
|
+
- Memories → source notes
|
|
64
|
+
|
|
65
|
+
## Memory System
|
|
66
|
+
|
|
67
|
+
All persistent memory lives in `brain/`:
|
|
68
|
+
|
|
69
|
+
| File | Stores |
|
|
70
|
+
|------|--------|
|
|
71
|
+
| `North Star.md` | Goals and focus areas — read every session |
|
|
72
|
+
| `Memories.md` | Index of memory topics |
|
|
73
|
+
| `Key Decisions.md` | Decisions worth recalling across sessions |
|
|
74
|
+
| `Patterns.md` | Recurring patterns discovered across work |
|
|
75
|
+
|
|
76
|
+
When asked to "remember" something: write to the appropriate `brain/` file with a wikilink to context.
|
|
77
|
+
|
|
78
|
+
## Sources & Ingest
|
|
79
|
+
|
|
80
|
+
`sources/` holds raw source documents (articles, papers, web clips). This is the immutable layer — the agent reads from it but never modifies source files.
|
|
81
|
+
|
|
82
|
+
- Drop raw files into `sources/` (markdown preferred) or use `/ingest` with a URL
|
|
83
|
+
- `/ingest` reads the source, discusses key takeaways, then creates a **Source Summary** in `work/active/` with tag `source-summary`
|
|
84
|
+
- The summary uses the Source Summary template: Key Takeaways, Summary, Connections, Quotes/Data Points
|
|
85
|
+
- Every ingest updates `work/Index.md` (Sources section) and checks for cross-links to existing notes
|
|
86
|
+
- If the source contains decisions or patterns, update the relevant `brain/` notes too
|
|
87
|
+
- Source summaries link back to the raw source via the `source` frontmatter field
|
|
88
|
+
|
|
89
|
+
## Operation Log
|
|
90
|
+
|
|
91
|
+
Append to `log.md` after significant operations: ingests, decisions, project archives, maintenance passes.
|
|
92
|
+
|
|
93
|
+
- Format: `## [YYYY-MM-DD] <type> | <title>` followed by bullet points
|
|
94
|
+
- Types: `ingest`, `session`, `query`, `maintenance`, `decision`, `archive`
|
|
95
|
+
- Don't log every small edit — only operations that change the vault's knowledge state
|
|
96
|
+
- Entries are append-only; never edit or delete previous entries
|
|
97
|
+
|
|
98
|
+
## Query Writeback
|
|
99
|
+
|
|
100
|
+
When answering a substantial question that synthesizes multiple vault notes:
|
|
101
|
+
|
|
102
|
+
1. Offer: "This answer could be useful later — want me to save it as a reference note?"
|
|
103
|
+
2. If yes, create a Reference Note in `reference/` using the template
|
|
104
|
+
3. Link the reference note from related work notes in `## Related`
|
|
105
|
+
4. Add the reference note to `work/Index.md` under `## Reference`
|
|
106
|
+
5. Don't prompt for trivial questions — only for answers that synthesize, compare, or analyze
|
|
107
|
+
|
|
108
|
+
## Vault Location
|
|
109
|
+
|
|
110
|
+
The vault may live at the project root or in a `vault/` subdirectory. Use the SessionStart context to determine the actual path. All folder references above (e.g. `brain/`, `work/active/`) are relative to the vault root.
|
|
111
|
+
|
|
112
|
+
## Rules
|
|
113
|
+
|
|
114
|
+
- Preserve existing frontmatter when editing notes
|
|
115
|
+
- Always check for and suggest connections between notes
|
|
116
|
+
- Every note must have a `description` field (~150 chars)
|
|
117
|
+
- When reorganizing, never delete without user confirmation
|
|
118
|
+
- Use `[[wikilinks]]` not markdown links
|
package/vault/Home.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Vault entry point — current focus and quick navigation"
|
|
3
|
+
tags:
|
|
4
|
+
- index
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Home
|
|
8
|
+
|
|
9
|
+
## Current Focus
|
|
10
|
+
|
|
11
|
+
![[North Star#Current Focus]]
|
|
12
|
+
|
|
13
|
+
## Quick Links
|
|
14
|
+
|
|
15
|
+
- [[Index|Work Notes]] — all projects and decisions
|
|
16
|
+
- [[North Star]] — goals and direction
|
|
17
|
+
- [[Memories]] — persistent context
|
|
18
|
+
- [[Key Decisions]] — architectural and workflow decisions
|
|
19
|
+
- [[Patterns]] — recurring patterns
|
|
20
|
+
- [[Index#Reference|Reference Notes]] — saved answers and analyses
|
|
21
|
+
- [[Log]] — operation history
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Index of memory topics — decisions, patterns, context retained across sessions"
|
|
3
|
+
tags:
|
|
4
|
+
- brain
|
|
5
|
+
- index
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Memories
|
|
9
|
+
|
|
10
|
+
Persistent context retained across sessions. Each topic lives in its own note — follow the links.
|
|
11
|
+
|
|
12
|
+
- [[Key Decisions]] — decisions worth recalling
|
|
13
|
+
- [[Patterns]] — recurring patterns discovered across work
|
|
14
|
+
- [[North Star]] — living goals document
|
|
15
|
+
- [[Log]] — chronological record of vault operations
|
|
16
|
+
|
|
17
|
+
## Recent Context
|
|
18
|
+
|
|
19
|
+
-
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Living document of goals, focus areas, and aspirations — read at session start"
|
|
3
|
+
tags:
|
|
4
|
+
- brain
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# North Star
|
|
8
|
+
|
|
9
|
+
A living document of goals and focus areas. Both you and your LLM agent write to this. The agent reads it at the start of every session and references it when making suggestions.
|
|
10
|
+
|
|
11
|
+
## Current Focus
|
|
12
|
+
|
|
13
|
+
_What am I working toward right now?_
|
|
14
|
+
|
|
15
|
+
-
|
|
16
|
+
|
|
17
|
+
## Goals
|
|
18
|
+
|
|
19
|
+
### Short-term (This Quarter)
|
|
20
|
+
|
|
21
|
+
-
|
|
22
|
+
|
|
23
|
+
### Medium-term (This Half)
|
|
24
|
+
|
|
25
|
+
-
|
|
26
|
+
|
|
27
|
+
### Long-term
|
|
28
|
+
|
|
29
|
+
-
|
package/vault/log.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Chronological log of vault operations — ingests, queries, session starts, maintenance"
|
|
3
|
+
tags:
|
|
4
|
+
- index
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Log
|
|
8
|
+
|
|
9
|
+
Append-only record of vault operations. Each entry starts with `## [YYYY-MM-DD] <type> | <title>` for easy parsing with grep.
|
|
10
|
+
|
|
11
|
+
Entry types: `ingest`, `session`, `query`, `maintenance`, `decision`, `archive`.
|
|
12
|
+
|
|
13
|
+
## [2026-04-06] session | Initial vault setup
|
|
14
|
+
- Created vault structure
|
|
15
|
+
- Configured hooks for Claude Code and Codex CLI
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Sources
|
|
2
|
+
|
|
3
|
+
Drop raw source files here — articles, papers, web clips saved as markdown.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
- The LLM agent **reads** from this directory but **never modifies** source files.
|
|
8
|
+
- Sources are immutable reference material. The agent creates summaries in `work/active/` instead.
|
|
9
|
+
- Use `/ingest` (Claude Code) or say "ingest this source" (Codex CLI) to process a new source into a wiki page with cross-links.
|
|
10
|
+
|
|
11
|
+
## Supported Formats
|
|
12
|
+
|
|
13
|
+
- Markdown files (`.md`) — preferred
|
|
14
|
+
- Plain text (`.txt`)
|
|
15
|
+
- Web clips saved via `defuddle parse <url> --md > sources/filename.md`
|
|
16
|
+
|
|
17
|
+
## Naming
|
|
18
|
+
|
|
19
|
+
Use descriptive filenames: `karpathy-llm-wiki.md`, `react-server-components-rfc.md`, etc.
|