Skip to content

Commit 2c734e0

Browse files
authored
Merge pull request #3 from hacklmdev/dev
Dev
2 parents 2983cf2 + fc0a998 commit 2c734e0

24 files changed

Lines changed: 574 additions & 80 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
dist/
33
*.vsix
44
site/
5+
.memory/cleanup.log

.memory/cleanup.log

Lines changed: 0 additions & 10 deletions
This file was deleted.

.memory/decisions.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ Memories stored by HackLM Memory.
3434

3535
- [docs-site-zensical] Docs site uses Zensical (pip install zensical). Config in zensical.toml at repo root. Serve: .venv/Scripts/zensical.exe serve. Build: zensical build → site/. Deploys to GitHub Pages via .github/workflows/docs.yml on push to main.
3636

37-
3837
- [globalstate-keys-file] All globalState keys live in extension/src/globalStateKeys.ts as named exports. Never use bare string literals for globalState keys elsewhere.
3938

4039
- [category-limits-source] CATEGORY_LIMITS constant removed from markdownStore.ts. Category limits come from VS Code config only (package.json defaults via config.get). Default fallback is hardcoded as 20 in utils.ts.
4140

42-
- [stale-slug-pruner-removed] pruneStaleEntries removed from cleanupMemory.ts. Stale slugs last-cleanup and last-session-debrief no longer exist. ADRs 0001 and 0013 deleted from docs/decisions/ as they documented completed migration periods.
43-
44-
4541
- [adr-location] ADRs live in docs/decisions.md but are NOT in the Zensical nav. The nav has an ADR page (docs/adr.md) instead. That page links back to docs/decisions.md on GitHub.
42+
43+
- [category-limits-defaults] Category defaults doubled: Instruction/Security = 30, Quirk/Preference/Decision = 40. Schema maximum raised to 100. Fallback in utils.ts and UI validation cap updated to match.

.memory/quirks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ Memories stored by HackLM Memory.
99
- [empty-justification] Passing an empty options object to sendRequest suppresses the justification string in the VS Code permission prompt. The user sees a blank reason. Always pass a justification.
1010

1111
- [adr-location] ADRs live in docs/decisions.md (a single flat file, not a directory). No separate per-ADR files. Add new ADRs as new H2 sections at the bottom of that file.
12+
13+
- [wx-flag-advisory-lock] The outer cross-process lock uses fs.open with the wx flag to create the lockfile exclusively. If the file already exists the open fails, signaling another process holds the lock. Never use a different open mode for this file.

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.1.0] - 2026-02-28
11+
12+
### Added
13+
14+
- Two-tier write locking: cross-process advisory lockfile (`crossProcessLock.ts`) stacked over per-file in-process promise queue — prevents concurrent writes from multiple VS Code windows
15+
- Plan agent patching: `patchPlanAgent()` injects `queryMemory` + `storeMemory` into the Copilot Chat Plan agent on every activation (idempotent)
16+
17+
### Changed
18+
19+
- Default category limits doubled: Instruction/Security 15→30, Quirk/Preference/Decision 20→40
20+
- Configurable maximum raised from 50 to 100
21+
1022
## [1.0.0] - 2026-02-27
1123

1224
### Added
@@ -30,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3042
- Per-category entry limit settings
3143
- Getting Started walkthrough (5 steps)
3244
- esbuild single-file bundle (`dist/extension.js`) — no webpack
33-
- Publishes to VS Marketplace and Open VSX (compatible with VS Code and Google Antigravity)
45+
- Publishes to VS Marketplace and Open VSX
3446

3547
[Unreleased]: https://github.com/hacklmdev/memory/compare/v1.0.0...HEAD
3648
[1.0.0]: https://github.com/hacklmdev/memory/releases/tag/v1.0.0

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Thank you for your interest in contributing.
55
## Prerequisites
66

77
- [Node.js](https://nodejs.org/) 20+
8-
- [VS Code](https://code.visualstudio.com/) 1.99+ (or any Open VSX-compatible editor, e.g. Google Antigravity)
8+
- [VS Code](https://code.visualstudio.com/) 1.99+
99
- Git
1010

1111
## Build

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,27 @@ A long-term memory layer for VS Code Copilot — learn from interactions, retain
1717

1818
## Compatibility
1919

20-
Works in any Open VSX-compatible editor:
20+
Requires [VS Code](https://code.visualstudio.com/) 1.99+.
2121

22-
- [VS Code](https://code.visualstudio.com/) 1.99+
23-
- [Google Antigravity](https://antigravity.google/) (Open VSX)
24-
- [Gitpod](https://gitpod.io/) (Open VSX)
22+
Also published to [Open VSX](https://open-vsx.org/extension/hacklm/hacklm-memory) for editors that use the Open VSX registry.
2523

26-
> **Note:** The memory LM tools (`storeMemory`, `queryMemory`) require the editor to implement the VS Code LM Tool API. Editors that do not implement this API will install the extension but the tools will not be available in chat.
24+
### Open VSX editors
25+
26+
In Open VSX-compatible editors the extension installs and activates. What works depends on whether the editor implements the VS Code LM Tool API:
27+
28+
| Feature | Available |
29+
|---------|----------|
30+
| `.memory/*.md` files created on first open | Always |
31+
| `copilot-instructions.md` reference block injected | Always |
32+
| `storeMemory` / `queryMemory` LM tools | VS Code LM Tool API required |
33+
| Tree view, status bar, control panel | VS Code only |
34+
| LM deduplication and gap analysis | VS Code LM Tool API required |
35+
36+
The `.memory/` files and `copilot-instructions.md` pointer are set up regardless of editor. Once those exist, any AI agent that reads instruction files can access the memory store directly — even without the LM tools.
37+
38+
The full experience (LM tools, UI) requires VS Code 1.99+.
39+
40+
Support for additional editors via MCP is planned — see the [Roadmap](docs/roadmap.md).
2741

2842
## Architecture
2943

@@ -78,7 +92,7 @@ npm run build
7892
| `hacklm-memory.lmFamily` | `gpt-5-mini` | Copilot model family for LM operations |
7993
| `hacklm-memory.autoApproveStore` | `false` | Skip confirmation prompt when saving memories |
8094
| `hacklm-memory.manageInstructionFile` | `true` | Allow the extension to manage `.github/copilot-instructions.md` |
81-
| `hacklm-memory.categoryLimit.*` | varies | Per-category max entry counts |
95+
| `hacklm-memory.categoryLimit.*` | varies (30–40) | Per-category max entry counts |
8296

8397
## Privacy
8498

@@ -94,7 +108,7 @@ Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) before
94108
- [Architecture](docs/architecture.md) — module map, data flow, key design decisions
95109
- [API Reference](docs/api-reference.md) — LM tool schemas, memory file format
96110
- [Developer Guide](docs/contributing.md) — how to add categories, tools, and tests
97-
- [Architecture Decision Records](docs/decisions.md)16 ADRs covering every major decision
111+
- [Architecture Decision Records](docs/decisions.md)17 ADRs covering every major decision
98112
- [Roadmap](docs/roadmap.md) — planned work and open contribution areas
99113

100114
## License

docs/adr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ This makes the codebase predictable. When LM behaviour changes, you edit one fil
3232

3333
## 4. Editor-agnostic storage
3434

35-
The `.memory/*.md` file format is the stable contract — not VS Code, not TypeScript, not this extension. A future JetBrains plugin or Neovim integration must read and write the same format for memory to be shareable across editors.
35+
The `.memory/*.md` file format is the stable contract — not VS Code, not TypeScript, not this extension. Any future port (JetBrains plugin, Neovim integration, MCP server for Google Antigravity) must read and write the same format for memory to be shareable across editors.
3636

37-
The storage layer (`dedup.ts`, `scoring.ts`, `search.ts`, `markdownStore.ts`) has no VS Code dependency and must stay that way.
37+
The storage layer (`dedup.ts`, `scoring.ts`, `search.ts`, `markdownStore.ts`) has no VS Code dependency and must stay that way. When additional editor support is built, this layer is extracted to `packages/storage` and shared — not copied.
3838

3939
---
4040

docs/api-reference.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ Returns `"No memories found."` if no entries match.
116116

117117
| Category | File | Default Limit | What It Stores |
118118
|----------|------|---------------|----------------|
119-
| `Instruction` | `.memory/instructions.md` | 15 | How Copilot should behave |
120-
| `Quirk` | `.memory/quirks.md` | 20 | Project-specific weirdness — non-obvious gotchas |
121-
| `Preference` | `.memory/preferences.md` | 20 | Style, tone, and design choices |
122-
| `Decision` | `.memory/decisions.md` | 20 | Architectural commitments |
123-
| `Security` | `.memory/security.md` | 15 | Rules that must never be broken |
119+
| `Instruction` | `.memory/instructions.md` | 30 | How Copilot should behave |
120+
| `Quirk` | `.memory/quirks.md` | 40 | Project-specific weirdness — non-obvious gotchas |
121+
| `Preference` | `.memory/preferences.md` | 40 | Style, tone, and design choices |
122+
| `Decision` | `.memory/decisions.md` | 40 | Architectural commitments |
123+
| `Security` | `.memory/security.md` | 30 | Rules that must never be broken |
124124

125125
Limits are configurable per-category via `hacklm-memory.categoryLimit.<Category>` settings.
126126

docs/architecture.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ flowchart TD
6969

7070
## Key Design Decisions
7171

72-
### Per-file Mutex Locks
72+
### Two-tier Write Locks
7373

74-
`markdownStore.ts` maintains a `Map<filePath, Promise<void>>` as a chained promise queue. Every read-then-write operation on a `.memory/*.md` file acquires the lock for that specific file. This prevents concurrent `storeMemory` calls and background cleanup from corrupting the same file simultaneously.
74+
Every write to `.memory/*.md` goes through two stacked locks:
75+
76+
1. **Outer — cross-process advisory lockfile** (`crossProcessLock.ts`): `withCrossProcessLock(memoryDir, fn)` creates `.memory/.lock` with an exclusive `fs.open('wx')` — an atomic OS primitive that works on POSIX and NTFS. Only one process can hold this file at a time. All other processes spin (with linear back-off, max 20 retries) until the holder removes it. Stale locks (dead PID or age > 10 s) are automatically removed, including on extension startup via `clearStaleLockOnStartup()`.
77+
78+
2. **Inner — per-file in-process promise queue** (`markdownStore.ts`): `withFileLock(filePath, fn)` chains a `Promise<void>` per file path. This serialises concurrent async calls within the same extension host process (e.g. `storeMemory` + background cleanup hitting the same category file).
79+
80+
Callers outside `markdownStore.ts` never interact with either lock directly. The combined wrapper `withMemoryWriteLock(filePath, fn)` is the only entry point used by `appendMemory`, `upsertMemory`, `deleteMemory`, and `migrateFiles`.
81+
82+
See [ADR 0018](decisions.md#0018--two-tier-write-locking-for-memory-files) for the full decision record.
7583

7684
### Centralised LM Access
7785

@@ -99,7 +107,7 @@ This extension uses:
99107
- `vscode.lm.selectChatModels` — to select a Copilot model for redundancy checks and gap analysis
100108
- `vscode.lm.onDidChangeChatModels` — to refresh the status bar when available models change
101109

102-
These APIs require **VS Code 1.99+** (or any Open VSX-compatible editor that implements the VS Code LM Tool API at the same version level). Editors that do not implement `vscode.lm.registerTool` will install the extension but the memory tools will not be available in chat.
110+
These APIs require **VS Code 1.99+**. The extension publishes to Open VSX; the memory tools function in any editor that implements the VS Code LM Tool API. A separate MCP-based implementation for additional editors is planned (see [ADR 0017](decisions.md#0017--additional-editor-support-via-mcp)).
103111

104112
## Future: JetBrains Support
105113

0 commit comments

Comments
 (0)