cofactor-memory 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 +112 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1309 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +1183 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jayhack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Cofactor
|
|
2
|
+
|
|
3
|
+
Cofactor is a local-first memory index for Markdown corpora and AI agents. It scans notes, extracts structural signals, precomputes catalyst-style questions, and searches documents through those questions without sending private text to a model at query time.
|
|
4
|
+
|
|
5
|
+
Landing page: [Cofactor](https://jayhack.github.io/cofactor/)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g cofactor-memory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For one-off use:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx cofactor-memory init ./notes
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## CLI
|
|
20
|
+
|
|
21
|
+
Index a Markdown corpus:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
cofactor init ./notes
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Inspect the local petri dish of entities and catalysts:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
cofactor petri ./notes --json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Ask a search question:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
cofactor catalyze "why did auth change direction around rollback?" --vault ./notes --json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Apply one corpus's catalysts to another local corpus:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
cofactor apply ../project-docs --vault ./notes
|
|
43
|
+
cofactor catalyze "session recovery tradeoffs" --vault ./notes --target project-docs --json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Install agent instructions:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
cofactor agents codex .
|
|
50
|
+
cofactor agents claude .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Run an MCP stdio server:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
cofactor mcp ./notes
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## What It Indexes
|
|
60
|
+
|
|
61
|
+
Cofactor extracts local structure from Markdown, MDX, and text files:
|
|
62
|
+
|
|
63
|
+
- frontmatter tags, inline hashtags, folders, and wiki links
|
|
64
|
+
- creation/update timestamps from frontmatter or file metadata
|
|
65
|
+
- document chunks and sparse TF-IDF vectors
|
|
66
|
+
- deterministic catalyst-style questions for each salient entity
|
|
67
|
+
- precomputed question-to-document links
|
|
68
|
+
|
|
69
|
+
The index is stored under `.cofactor/` in the corpus root. Add that directory to `.gitignore` unless you intentionally want to version the generated memory.
|
|
70
|
+
|
|
71
|
+
## SDK
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { catalyze, indexVault, petri } from "cofactor-memory";
|
|
75
|
+
|
|
76
|
+
await indexVault("./notes");
|
|
77
|
+
|
|
78
|
+
const graph = await petri("./notes");
|
|
79
|
+
const results = await catalyze("where did we decide to rewrite auth?", {
|
|
80
|
+
vaultPath: "./notes",
|
|
81
|
+
limit: 5,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
console.log(graph.entities);
|
|
85
|
+
console.log(results.results);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Commands
|
|
89
|
+
|
|
90
|
+
| Command | Purpose |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `init [vault]` | scan a corpus and write `.cofactor/index.json` |
|
|
93
|
+
| `refresh [vault]` | alias for `init` |
|
|
94
|
+
| `petri [vault]` | print entity and catalyst working memory |
|
|
95
|
+
| `catalyze <query>` | search through catalysts and return relevant notes |
|
|
96
|
+
| `apply <target>` | project current vault catalysts onto another corpus |
|
|
97
|
+
| `agents <codex\|claude>` | install agent instructions |
|
|
98
|
+
| `mcp [vault]` | expose `petri` and `catalyze` as MCP stdio tools |
|
|
99
|
+
| `status [vault]` | report index metadata |
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
npm install
|
|
105
|
+
npm test
|
|
106
|
+
npm run typecheck
|
|
107
|
+
npm run lint
|
|
108
|
+
npm run build
|
|
109
|
+
npm publish --dry-run
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Publishing will require an npm account with permission to publish `cofactor-memory`.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|