hypomnema 1.0.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.
Files changed (79) hide show
  1. package/.claude-plugin/plugin.json +11 -0
  2. package/LICENSE +21 -0
  3. package/README.ko.md +160 -0
  4. package/README.md +160 -0
  5. package/commands/.gitkeep +0 -0
  6. package/commands/crystallize.md +116 -0
  7. package/commands/doctor.md +66 -0
  8. package/commands/feedback.md +67 -0
  9. package/commands/graph.md +54 -0
  10. package/commands/ingest.md +85 -0
  11. package/commands/init.md +101 -0
  12. package/commands/lint.md +55 -0
  13. package/commands/query.md +55 -0
  14. package/commands/resume.md +48 -0
  15. package/commands/stats.md +39 -0
  16. package/commands/uninstall.md +52 -0
  17. package/commands/upgrade.md +63 -0
  18. package/commands/verify.md +60 -0
  19. package/docs/.gitkeep +0 -0
  20. package/docs/ARCHITECTURE.md +183 -0
  21. package/docs/CONTRIBUTING.md +115 -0
  22. package/docs/TEST-CASES.md +580 -0
  23. package/hooks/.gitkeep +0 -0
  24. package/hooks/hooks.json +109 -0
  25. package/hooks/hypo-auto-commit.mjs +36 -0
  26. package/hooks/hypo-auto-stage.mjs +30 -0
  27. package/hooks/hypo-compact-guard.mjs +71 -0
  28. package/hooks/hypo-cwd-change.mjs +91 -0
  29. package/hooks/hypo-file-watch.mjs +47 -0
  30. package/hooks/hypo-first-prompt.mjs +59 -0
  31. package/hooks/hypo-hot-rebuild.mjs +95 -0
  32. package/hooks/hypo-lookup.mjs +178 -0
  33. package/hooks/hypo-personal-check.mjs +195 -0
  34. package/hooks/hypo-session-start.mjs +141 -0
  35. package/hooks/hypo-shared.mjs +213 -0
  36. package/package.json +37 -0
  37. package/scripts/.gitkeep +0 -0
  38. package/scripts/bump-version.mjs +53 -0
  39. package/scripts/crystallize.mjs +153 -0
  40. package/scripts/doctor.mjs +361 -0
  41. package/scripts/feedback.mjs +130 -0
  42. package/scripts/graph.mjs +183 -0
  43. package/scripts/ingest.mjs +130 -0
  44. package/scripts/init.mjs +515 -0
  45. package/scripts/lib/frontmatter.mjs +11 -0
  46. package/scripts/lib/hypo-ignore.mjs +54 -0
  47. package/scripts/lib/hypo-root.mjs +53 -0
  48. package/scripts/lint.mjs +210 -0
  49. package/scripts/query.mjs +124 -0
  50. package/scripts/resume.mjs +115 -0
  51. package/scripts/stats.mjs +132 -0
  52. package/scripts/uninstall.mjs +188 -0
  53. package/scripts/upgrade.mjs +538 -0
  54. package/scripts/verify.mjs +172 -0
  55. package/skills/.gitkeep +0 -0
  56. package/skills/crystallize/SKILL.md +85 -0
  57. package/skills/graph/SKILL.md +54 -0
  58. package/skills/ingest/SKILL.md +83 -0
  59. package/skills/lint/SKILL.md +55 -0
  60. package/skills/query/SKILL.md +58 -0
  61. package/skills/verify/SKILL.md +92 -0
  62. package/templates/.gitkeep +0 -0
  63. package/templates/.hypoignore +18 -0
  64. package/templates/Home.md +34 -0
  65. package/templates/Overview.md +50 -0
  66. package/templates/SCHEMA.md +106 -0
  67. package/templates/hot.md +22 -0
  68. package/templates/hypo-automation.md +69 -0
  69. package/templates/hypo-config.md +41 -0
  70. package/templates/hypo-guide.md +146 -0
  71. package/templates/hypo-help.md +53 -0
  72. package/templates/index.md +44 -0
  73. package/templates/log.md +25 -0
  74. package/templates/pages/_index.md +61 -0
  75. package/templates/projects/_template/hot.md +28 -0
  76. package/templates/projects/_template/index.md +39 -0
  77. package/templates/projects/_template/prd.md +29 -0
  78. package/templates/projects/_template/session-state.md +9 -0
  79. package/templates/session-state.md +12 -0
@@ -0,0 +1,183 @@
1
+ # Hypomnema — Architecture
2
+
3
+ ## Overview
4
+
5
+ Hypomnema is an LLM-native personal wiki that runs as a Claude Code extension. It has three runtime layers:
6
+
7
+ 1. **Slash commands** — LLM-driven operations triggered by `/hypo:*` in Claude Code
8
+ 2. **Lifecycle hooks** — background automation triggered by Claude Code events
9
+ 3. **Wiki vault** — a local markdown directory that serves as the persistent knowledge store
10
+
11
+ ---
12
+
13
+ ## Package layout
14
+
15
+ ```
16
+ hypomnema/
17
+ ├── commands/ ← slash command definitions (.md prompts)
18
+ ├── hooks/ ← lifecycle hooks deployed to ~/.claude/hooks/
19
+ │ ├── hypo-shared.mjs ← shared utilities (inlined at deploy; no external imports)
20
+ │ └── hooks.json ← hook-to-event registry
21
+ ├── scripts/ ← command implementations called by slash commands
22
+ │ └── lib/ ← shared helpers (frontmatter, hypo-root, hypo-ignore)
23
+ ├── skills/ ← Agent Skills (skills/<name>/SKILL.md) for /hypo:* commands
24
+ ├── templates/ ← baseline wiki files copied on init
25
+ ├── tests/
26
+ │ └── runner.mjs ← no-dependency test runner
27
+ └── docs/ ← ARCHITECTURE.md, CONTRIBUTING.md
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Slash commands
33
+
34
+ Each command is a pair:
35
+
36
+ | File | Role |
37
+ |------|------|
38
+ | `commands/<name>.md` | Prompt definition — instructions Claude follows when the command is invoked |
39
+ | `scripts/<name>.mjs` | Script implementation — Node.js logic called by the command |
40
+
41
+ Commands: `init`, `ingest`, `query`, `crystallize`, `resume`, `feedback`, `verify`, `stats`, `graph`, `lint`, `doctor`, `upgrade`, `uninstall`.
42
+
43
+ ---
44
+
45
+ ## Lifecycle hooks
46
+
47
+ Hooks run automatically at Claude Code lifecycle events. They are deployed to `~/.claude/hooks/` by `init`/`upgrade`.
48
+
49
+ ### Event map (`hooks/hooks.json`)
50
+
51
+ | Event | Hooks |
52
+ |-------|-------|
53
+ | `SessionStart` | `hypo-session-start.mjs` |
54
+ | `UserPromptSubmit` | `hypo-first-prompt.mjs`, `hypo-lookup.mjs`, `hypo-compact-guard.mjs` |
55
+ | `PreCompact` | `hypo-personal-check.mjs` |
56
+ | `PostToolUse` | `hypo-auto-stage.mjs` |
57
+ | `Stop` | `hypo-hot-rebuild.mjs`, `hypo-auto-commit.mjs` |
58
+ | `CwdChanged` | `hypo-cwd-change.mjs` |
59
+ | `FileChanged` | `hypo-file-watch.mjs` |
60
+
61
+ ### Hook responsibilities
62
+
63
+ - **hypo-session-start** — injects wiki index and active project context at session open
64
+ - **hypo-first-prompt** — injects session-state for the active project on the first user prompt
65
+ - **hypo-lookup** — resolves `[[wikilink]]` references in prompts to actual page content
66
+ - **hypo-compact-guard** — blocks `/compact` if the session-close checklist is incomplete
67
+ - **hypo-personal-check** — pre-compact validation: uncommitted changes, log integrity
68
+ - **hypo-auto-stage** — stages modified wiki files after tool use
69
+ - **hypo-hot-rebuild** — rewrites `hot.md` at session end based on recent activity
70
+ - **hypo-auto-commit** — commits and pushes staged wiki changes at session stop
71
+ - **hypo-cwd-change** — re-resolves active project when the working directory changes
72
+ - **hypo-file-watch** — watches for external wiki edits and re-indexes changed pages
73
+
74
+ ### Deployment constraint
75
+
76
+ Hooks run in an isolated environment at `~/.claude/hooks/`. They **cannot import from relative paths** outside their own directory. As a result, `hypo-shared.mjs` is copied alongside each hook at deploy time. All shared utilities must remain self-contained in that file.
77
+
78
+ ---
79
+
80
+ ## Shared utilities (`hooks/hypo-shared.mjs`)
81
+
82
+ Core helpers used across hooks and scripts:
83
+
84
+ | Export | Purpose |
85
+ |--------|---------|
86
+ | `HYPO_DIR` | Resolved wiki root path |
87
+ | `PKG_ROOT` | Package install path, read from `~/.claude/hypo-pkg.json` |
88
+ | `resolveHypoRoot()` | `HYPO_DIR` env → `hypo-config.md` scan → `~/hypomnema` fallback |
89
+ | `loadHypoIgnore()` | Parses `.hypoignore` into pattern list |
90
+ | `isIgnored()` | Tests a file path against `.hypoignore` patterns |
91
+ | `hypoIsClean()` | Checks git status + unpushed commits |
92
+ | `hotMdIsClean()` | Validates `hot.md` structure |
93
+ | `isCompactCommand()` | Detects `/compact` invocations |
94
+ | `buildOutput()` | Formats hook output for Claude Code's `additionalContext` channel |
95
+
96
+ ---
97
+
98
+ ## Scripts lib (`scripts/lib/`)
99
+
100
+ Helpers used by command scripts (not deployed to hooks):
101
+
102
+ | File | Purpose |
103
+ |------|---------|
104
+ | `frontmatter.mjs` | Parse and serialize YAML frontmatter |
105
+ | `hypo-root.mjs` | Wiki root resolution (mirrors hook logic, allows imports) |
106
+ | `hypo-ignore.mjs` | `.hypoignore` parsing (mirrors hook logic, allows imports) |
107
+
108
+ ---
109
+
110
+ ## Wiki vault layout
111
+
112
+ ```
113
+ <hypo-root>/
114
+ ├── hypo-config.md ← root marker + settings
115
+ ├── index.md ← searchable page catalog
116
+ ├── hot.md ← active project pointers
117
+ ├── log.md ← append-only activity log
118
+ ├── SCHEMA.md ← type system reference
119
+ ├── hypo-guide.md ← operations guide
120
+ ├── .hypoignore ← privacy/exclusion patterns
121
+ ├── pages/ ← permanent knowledge pages
122
+ ├── projects/ ← per-project session artifacts
123
+ │ └── <name>/
124
+ │ ├── hot.md ← project-level status
125
+ │ └── session-state.md← next tasks + last session summary
126
+ └── sources/ ← raw ingested sources (append-only)
127
+ ```
128
+
129
+ `hypo-config.md` presence is the wiki root marker. `resolveHypoRoot()` scans candidate directories for it.
130
+
131
+ ---
132
+
133
+ ## Init and upgrade flow
134
+
135
+ 1. **Init** (`/hypo:init`):
136
+ - Wizard collects wiki path and hook preferences
137
+ - Creates vault directory structure
138
+ - Copies `templates/` files
139
+ - Deploys hooks to `~/.claude/hooks/` (and optionally `~/.codex/hooks/`)
140
+ - Merges hook entries into `~/.claude/settings.json` (idempotent)
141
+ - Writes `~/.claude/hypo-pkg.json` with `pkgRoot` for future upgrades
142
+
143
+ 2. **Upgrade** (`/hypo:upgrade`):
144
+ - Reads `pkgRoot` from `~/.claude/hypo-pkg.json`
145
+ - Re-deploys hooks from the new package version
146
+ - Re-merges `settings.json` entries
147
+
148
+ ---
149
+
150
+ ## Data flow: ingest
151
+
152
+ ```
153
+ source (URL / file / paste)
154
+ → LLM reads + synthesizes
155
+ → check index.md for existing related pages
156
+ → update existing page OR create new page in pages/
157
+ → append raw source to sources/<slug>.md
158
+ → update index.md + log.md
159
+ ```
160
+
161
+ ## Data flow: query
162
+
163
+ ```
164
+ user question
165
+ → search index.md + page frontmatter
166
+ → load candidate pages
167
+ → LLM synthesizes grounded answer with [[wikilink]] citations
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Exclusion patterns
173
+
174
+ `.hypoignore` controls which files hooks include in context. The default patterns exclude common large binaries (`*.pdf`, `*.zip`) and credential extensions (`*.pem`, `*.env`). Edit this file directly in your wiki root to add additional exclusions.
175
+
176
+ ---
177
+
178
+ ## Testing
179
+
180
+ ```bash
181
+ npm test # tests/runner.mjs — unit + smoke tests, no external deps
182
+ npm run lint # scripts/lint.mjs — frontmatter + wikilink validation
183
+ ```
@@ -0,0 +1,115 @@
1
+ # Contributing to Hypomnema
2
+
3
+ ## Requirements
4
+
5
+ - Node.js ≥ 18
6
+ - Claude Code CLI (for end-to-end testing)
7
+
8
+ No build step. The package is plain ESM.
9
+
10
+ ---
11
+
12
+ ## Setup
13
+
14
+ ```bash
15
+ git clone https://github.com/sk-lim19f/Hypomnema.git
16
+ cd Hypomnema
17
+ npm install # no runtime deps; installs dev tooling only
18
+ npm test # verify baseline
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Project layout
24
+
25
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for a full breakdown. The short version:
26
+
27
+ | Directory | What to touch |
28
+ |-----------|---------------|
29
+ | `commands/` | Prompt definitions for `/hypo:*` slash commands |
30
+ | `scripts/` | Node.js implementations called by commands |
31
+ | `scripts/lib/` | Shared helpers for scripts (frontmatter, hypo-root, hypo-ignore) |
32
+ | `hooks/` | Claude Code lifecycle hooks + `hooks.json` registry |
33
+ | `hooks/hypo-shared.mjs` | Shared hook utilities — see deployment constraint below |
34
+ | `templates/` | Baseline files copied into new wiki vaults on init |
35
+ | `tests/runner.mjs` | Test suite |
36
+ | `docs/` | Documentation |
37
+
38
+ ---
39
+
40
+ ## Hook deployment constraint
41
+
42
+ Hooks are deployed to `~/.claude/hooks/` and **run in isolation** — they cannot import from relative paths. All shared logic lives in `hooks/hypo-shared.mjs`, which is copied alongside each hook at deploy time. If you add a utility that hooks need, add it to `hypo-shared.mjs`. Do not create additional shared files that hooks import.
43
+
44
+ Scripts in `scripts/` are not subject to this constraint and can import from `scripts/lib/`.
45
+
46
+ ---
47
+
48
+ ## Making changes
49
+
50
+ ### Adding or modifying a slash command
51
+
52
+ 1. Edit `commands/<name>.md` — the LLM-facing prompt.
53
+ 2. Edit `scripts/<name>.mjs` — the Node.js logic.
54
+ 3. If the command is new, add a skill wrapper in `skills/` and register it in `package.json` if needed.
55
+ 4. Update `README.md` command table if the command is user-facing.
56
+
57
+ ### Adding or modifying a hook
58
+
59
+ 1. Edit the hook file in `hooks/`.
60
+ 2. If it's a new hook, add it to `hooks/hooks.json` under the correct event key.
61
+ 3. If the hook needs shared utilities, add them to `hooks/hypo-shared.mjs`.
62
+ 4. Test by running `npm test` and manually running `/hypo:upgrade` in a Claude Code session.
63
+
64
+ ### Modifying `hypo-shared.mjs`
65
+
66
+ This file is deployed verbatim to `~/.claude/hooks/`. Keep it self-contained:
67
+ - Only Node.js built-ins (`fs`, `path`, `os`, `child_process`)
68
+ - No relative imports
69
+ - No npm dependencies
70
+
71
+ ### Adding a template file
72
+
73
+ Drop the file in `templates/` and update `commands/init.md` to include it in the copy step.
74
+
75
+ ---
76
+
77
+ ## Testing
78
+
79
+ ```bash
80
+ npm test # unit + smoke tests (tests/runner.mjs, no external deps)
81
+ npm run lint # frontmatter + wikilink validation
82
+ ```
83
+
84
+ The test runner uses only Node.js built-ins. Tests create temporary directories and clean up after themselves.
85
+
86
+ When adding a feature, add a corresponding test in `tests/runner.mjs`. For hook changes that are hard to unit-test, document a manual verification step in the PR description.
87
+
88
+ ---
89
+
90
+ ## Branch and commit conventions
91
+
92
+ - One logical change per branch.
93
+ - Branch names: `fix/<topic>`, `feat/<topic>`, `docs/<topic>`, `refactor/<topic>`.
94
+ - Commit messages: imperative, lowercase subject line, ≤ 72 characters.
95
+ - Good: `fix: resolve wiki root when HYPO_DIR contains ~`
96
+ - Bad: `Fixed the bug with the wiki root path resolution issue`
97
+ - For non-trivial changes, get a second review before merging.
98
+
99
+ ---
100
+
101
+ ## Submitting a PR
102
+
103
+ 1. Run `npm test` and `npm run lint` — both must pass.
104
+ 2. If you changed a hook, manually test the affected lifecycle event in Claude Code.
105
+ 3. If you changed `hypo-shared.mjs`, verify the deployed copy works after `/hypo:upgrade`.
106
+ 4. Open the PR against `main`. Include what was changed and why, plus any manual verification steps.
107
+
108
+ ---
109
+
110
+ ## What not to do
111
+
112
+ - Don't add npm runtime dependencies. The package intentionally has none.
113
+ - Don't add external imports to hook files.
114
+ - Don't edit files under `templates/` to fix bugs — fix the source in `scripts/` or `hooks/` and let init/upgrade propagate the change.
115
+ - Don't commit `~/.claude/hypo-pkg.json` or any user-specific config.