peon-mem 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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +301 -0
  3. package/bin/peon-mem.mjs +273 -0
  4. package/dist/brain.d.ts +72 -0
  5. package/dist/brain.js +224 -0
  6. package/dist/compression.d.ts +9 -0
  7. package/dist/compression.js +37 -0
  8. package/dist/config.d.ts +22 -0
  9. package/dist/config.js +99 -0
  10. package/dist/daemon-cli.d.ts +2 -0
  11. package/dist/daemon-cli.js +54 -0
  12. package/dist/daemon.d.ts +23 -0
  13. package/dist/daemon.js +1078 -0
  14. package/dist/embedding-store.d.ts +43 -0
  15. package/dist/embedding-store.js +169 -0
  16. package/dist/embeddings.d.ts +93 -0
  17. package/dist/embeddings.js +345 -0
  18. package/dist/entities.d.ts +61 -0
  19. package/dist/entities.js +191 -0
  20. package/dist/entity-extraction.d.ts +33 -0
  21. package/dist/entity-extraction.js +75 -0
  22. package/dist/eval-metrics.d.ts +27 -0
  23. package/dist/eval-metrics.js +50 -0
  24. package/dist/evaluation.d.ts +58 -0
  25. package/dist/evaluation.js +244 -0
  26. package/dist/global-extraction.d.ts +15 -0
  27. package/dist/global-extraction.js +61 -0
  28. package/dist/global-memory.d.ts +43 -0
  29. package/dist/global-memory.js +306 -0
  30. package/dist/global-promotion.d.ts +25 -0
  31. package/dist/global-promotion.js +29 -0
  32. package/dist/hyde.d.ts +31 -0
  33. package/dist/hyde.js +46 -0
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +246 -0
  36. package/dist/injection.d.ts +38 -0
  37. package/dist/injection.js +133 -0
  38. package/dist/logger.d.ts +17 -0
  39. package/dist/logger.js +63 -0
  40. package/dist/memory-mutations.d.ts +24 -0
  41. package/dist/memory-mutations.js +57 -0
  42. package/dist/memory-store.d.ts +194 -0
  43. package/dist/memory-store.js +1205 -0
  44. package/dist/monitor.d.ts +13 -0
  45. package/dist/monitor.js +977 -0
  46. package/dist/overview.d.ts +73 -0
  47. package/dist/overview.js +104 -0
  48. package/dist/processor.d.ts +90 -0
  49. package/dist/processor.js +450 -0
  50. package/dist/quality.d.ts +86 -0
  51. package/dist/quality.js +338 -0
  52. package/dist/recuration.d.ts +13 -0
  53. package/dist/recuration.js +65 -0
  54. package/dist/reranker.d.ts +34 -0
  55. package/dist/reranker.js +89 -0
  56. package/dist/retrieval.d.ts +106 -0
  57. package/dist/retrieval.js +392 -0
  58. package/dist/session-index.d.ts +34 -0
  59. package/dist/session-index.js +87 -0
  60. package/dist/temporal.d.ts +20 -0
  61. package/dist/temporal.js +62 -0
  62. package/dist/token-ab-monitor.d.ts +1 -0
  63. package/dist/token-ab-monitor.js +7 -0
  64. package/dist/tools.d.ts +232 -0
  65. package/dist/tools.js +546 -0
  66. package/dist/types.d.ts +169 -0
  67. package/dist/types.js +1 -0
  68. package/docs/assets/neural-universe.png +0 -0
  69. package/package.json +57 -0
  70. package/scripts/claude-peon-hook.mjs +522 -0
  71. package/scripts/codex-peon-hook.mjs +4 -0
  72. package/scripts/eval-retrieval-labeled.mjs +135 -0
  73. package/scripts/eval-retrieval.mjs +96 -0
  74. package/scripts/evaluate-peon.mjs +47 -0
  75. package/scripts/install-peon-stl.mjs +82 -0
  76. package/scripts/install-peon.mjs +318 -0
  77. package/scripts/lib/eval-ledger.mjs +104 -0
  78. package/scripts/lib/stl-classify.mjs +44 -0
  79. package/scripts/longmemeval-eval.mjs +144 -0
  80. package/scripts/peon-report.mjs +155 -0
  81. package/scripts/peon-stl.mjs +506 -0
  82. package/scripts/token-ab-monitor.html +235 -0
@@ -0,0 +1,169 @@
1
+ export type PeonRole = "user" | "assistant" | "system";
2
+ export interface PeonSession {
3
+ id: string;
4
+ projectPath: string;
5
+ client: string;
6
+ cwd: string;
7
+ startedAt: string;
8
+ endedAt?: string;
9
+ }
10
+ export interface PeonEvent {
11
+ id: string;
12
+ sessionId: string;
13
+ type: string;
14
+ content: string;
15
+ createdAt: string;
16
+ role?: PeonRole;
17
+ }
18
+ export interface ProjectContext {
19
+ summary: string;
20
+ memories: string;
21
+ decisions: string;
22
+ preferences: string;
23
+ openQuestions: string;
24
+ artifacts: string;
25
+ timeline: string;
26
+ /** Episodic recall: top raw conversational turns relevant to the query (when requested). */
27
+ episodes?: string;
28
+ meta?: {
29
+ compacted: boolean;
30
+ maxChars: number;
31
+ };
32
+ /** Ids of the active beliefs that were actually recalled for this query — feeds reinforcement. */
33
+ recalledIds?: string[];
34
+ /**
35
+ * The single most query-relevant belief, hoisted so the injection can LEAD with it as a
36
+ * prominent banner — a structural nudge against the agent re-deriving what's already known.
37
+ * Only set when there's a query and a genuine (non-graph-neighbour) top hit.
38
+ */
39
+ headline?: string;
40
+ /**
41
+ * HIERARCHICAL RECALL: top query-relevant beliefs from Peon's GLOBAL brain (the parent of
42
+ * every project brain) — user-level facts/preferences every project should inherit.
43
+ */
44
+ global?: string;
45
+ }
46
+ export interface ProcessedMemory {
47
+ summary: string;
48
+ decisions: string[];
49
+ preferences: string[];
50
+ openQuestions: string[];
51
+ artifacts: string[];
52
+ timeline: string[];
53
+ memories?: MemoryRecordInput[];
54
+ /**
55
+ * Integrative consolidation operations. The model (or a manual aiResult)
56
+ * emits these AFTER seeing existing durable memory, to reconcile beliefs that
57
+ * changed — rather than only adding net-new facts. Absent/empty => add-only.
58
+ */
59
+ operations?: ConsolidationOperation[];
60
+ }
61
+ /**
62
+ * A reconciliation operation against an EXISTING memory record (by id).
63
+ * Only two verbs — net-new beliefs flow through the add channels, and an
64
+ * in-place edit is expressed as supersede(old) + replacement(new).
65
+ */
66
+ export type ConsolidationOperation = {
67
+ op: "supersede";
68
+ targetId: string;
69
+ reason?: string;
70
+ replacement: MemoryRecordInput;
71
+ } | {
72
+ op: "obsolete";
73
+ targetId: string;
74
+ reason?: string;
75
+ };
76
+ export interface ProcessingState {
77
+ lastStatus?: "processed" | "skipped" | "failed";
78
+ lastTrigger?: string;
79
+ lastReason?: string;
80
+ lastProcessedAt?: string;
81
+ lastProcessedRawChars?: number;
82
+ lastRawChars?: number;
83
+ /** Id of the last raw event consolidated — the delta cursor for the prompt. */
84
+ lastProcessedEventId?: string;
85
+ lastModel?: string;
86
+ lastEstimatedTokens?: number;
87
+ lastSkippedAt?: string;
88
+ lastSkipReason?: string;
89
+ /** Observability: what the most recent consolidation actually did. */
90
+ lastOperationsEmitted?: number;
91
+ lastSuperseded?: number;
92
+ lastObsoleted?: number;
93
+ lastMerged?: number;
94
+ }
95
+ export type MemoryType = "summary" | "decision" | "preference" | "open_question" | "artifact" | "timeline" | "fact";
96
+ export type MemoryScope = "project" | "global" | "session";
97
+ export type MemoryStatus = "active" | "stale" | "conflicted" | "superseded" | "archived";
98
+ export interface MemoryRecordInput {
99
+ type: MemoryType;
100
+ content: string;
101
+ scope?: MemoryScope;
102
+ importance?: number;
103
+ confidence?: number;
104
+ entities?: string[];
105
+ status?: MemoryStatus;
106
+ }
107
+ export interface MemoryRecord {
108
+ id: string;
109
+ type: MemoryType;
110
+ content: string;
111
+ normalized: string;
112
+ scope: MemoryScope;
113
+ status: MemoryStatus;
114
+ score: {
115
+ importance: number;
116
+ confidence: number;
117
+ };
118
+ source: {
119
+ kind: "ai_processing" | "manual" | "hook";
120
+ reason?: string;
121
+ };
122
+ entities: string[];
123
+ createdAt: string;
124
+ updatedAt: string;
125
+ /** When status === "superseded", the id of the record that replaced this one. */
126
+ supersededBy?: string;
127
+ /** User-pinned beliefs are protected from auto-staleness and rank first. */
128
+ pinned?: boolean;
129
+ /** Reinforcement: how "alive" this belief is. Recall raises it, disuse lets it settle.
130
+ * Drives what stays in working memory vs what gets compressed. Defaults to importance. */
131
+ strength?: number;
132
+ /** Times this belief has been recalled (injected or matched). */
133
+ recallCount?: number;
134
+ /** ISO timestamp of the last recall. */
135
+ lastRecalledAt?: string;
136
+ /** On a SUMMARY belief: the ids of the raw beliefs it rolls up (now archived). */
137
+ summaryOf?: string[];
138
+ /** On a raw belief: the id of the summary that now represents it (status archived). */
139
+ summarizedBy?: string;
140
+ /** Where this belief came from, so the agent can fetch ground truth for exact specifics. */
141
+ provenance?: {
142
+ kind: "url" | "file" | "episodic";
143
+ /** The pointer: a URL, a file path, or the ISO time anchor for the episodic layer. */
144
+ ref: string;
145
+ capturedAt: string;
146
+ };
147
+ }
148
+ export interface MemoryGraph {
149
+ nodes: Array<{
150
+ id: string;
151
+ type: string;
152
+ label: string;
153
+ /** For entity nodes: "code" (files/symbols) or "domain" (people/papers/concepts). */
154
+ namespace?: string;
155
+ }>;
156
+ edges: Array<{
157
+ from: string;
158
+ to: string;
159
+ type: string;
160
+ }>;
161
+ }
162
+ export interface BrainInspection {
163
+ projectPath: string;
164
+ query?: string;
165
+ records: MemoryRecord[];
166
+ graph: MemoryGraph;
167
+ injectionPreview: string;
168
+ context: ProjectContext;
169
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
Binary file
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "peon-mem",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "peon-mem": "bin/peon-mem.mjs",
8
+ "peon-mcp": "dist/index.js",
9
+ "peon-daemon": "dist/daemon-cli.js"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.json",
13
+ "daemon": "node dist/daemon-cli.js",
14
+ "install:peon": "node scripts/install-peon.mjs",
15
+ "evaluate": "node scripts/evaluate-peon.mjs",
16
+ "eval": "node scripts/eval-retrieval-labeled.mjs run",
17
+ "typecheck": "tsc -p tsconfig.json --noEmit",
18
+ "test": "PEON_QUERY_EMBED_CACHE=/tmp/peon-test-query-embed-cache.jsonl vitest run",
19
+ "prepublishOnly": "npm run build && npm test"
20
+ },
21
+ "dependencies": {
22
+ "@modelcontextprotocol/sdk": "^1.23.0"
23
+ },
24
+ "description": "Local-first hierarchical memory brain for AI coding agents — auto-capture, LLM consolidation into beliefs, hybrid retrieval, per-prompt injection, a living Neural Universe monitor, and a daily self-improvement loop. Works with Claude Code, Codex, and any MCP client.",
25
+ "license": "MIT",
26
+ "keywords": [
27
+ "memory",
28
+ "mcp",
29
+ "claude-code",
30
+ "codex",
31
+ "ai-agents",
32
+ "local-first",
33
+ "llm",
34
+ "rag",
35
+ "knowledge-base"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/VineetV2/peon-mem"
40
+ },
41
+ "engines": {
42
+ "node": ">=20"
43
+ },
44
+ "devDependencies": {
45
+ "typescript": "^5.7.0",
46
+ "vitest": "^4.0.0",
47
+ "@types/node": "^22.0.0"
48
+ },
49
+ "files": [
50
+ "bin",
51
+ "dist",
52
+ "scripts",
53
+ "docs/assets",
54
+ "README.md",
55
+ "LICENSE"
56
+ ]
57
+ }