Skip to content

Commit 75998f1

Browse files
author
SukinShetty
committed
feat: add /nemp:cortex and /nemp:decay commands
Add Cortex intelligence layer with full report, status, --apply, --fuse, --chains, --history, insight, resolve, learn, simulate, trust, validate, and goal subcommands. Add decay engine command for vitality recalculation and auto-archiving. Update save, recall, context, foresight, health commands with cortex field support and backward compatibility.
1 parent 24ddfe1 commit 75998f1

File tree

8 files changed

+1600
-19
lines changed

8 files changed

+1600
-19
lines changed

CLAUDE.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Project Context (via Nemp Memory)
22

3-
> Auto-generated by Nemp Memory. Last updated: 2026-02-17 00:00
3+
> Auto-generated by Nemp Memory. Last updated: 2026-02-26 16:20
44
55
### Project Info
66

@@ -16,21 +16,32 @@
1616
|-----|-------|
1717
| **stack** | Claude Code Plugin — Markdown commands, JSON storage, agent tracking, access logs, token compression |
1818
| **storage-format** | JSON files — .nemp/memories.json (project), ~/.nemp/memories.json (global). Plus access.log audit trail and MEMORY.md index. |
19-
| **project-structure** | commands/ (16 .md files), skills/ (nemp-memory/SKILL.md), .claude-plugin/ (plugin.json, marketplace.json, hooks/), .nemp/ (config, memories, access.log), assets/ (logo/, images/, demos/) |
19+
| **project-structure** | commands/ (20 .md files incl. cortex.md+decay.md), skills/, .claude-plugin/, .nemp/ (memories, cortex, episodes, archive, evolution.log), assets/ |
2020

2121
### Features
2222

2323
| Key | Value |
2424
|-----|-------|
25-
| **commands-available** | activity, auto-capture, auto-sync, context, export, forget, init, list, list-global, log, recall, recall-global, save, save-global, suggest, sync |
25+
| **commands-available** | activity, auto-capture, auto-sync, context, cortex, decay, export, forget, foresight, health, init, list, list-global, log, recall, recall-global, save, save-global, suggest, sync |
2626

2727
### Other
2828

2929
| Key | Value |
3030
|-----|-------|
3131
| **author** | Sukin Shetty (contact@nemp.dev, github.com/SukinShetty) |
32-
| **version** | 0.2.0 |
32+
| **version** | 0.3.0 |
3333
| **license** | MIT |
3434
| **test-compression** | NextAuth.js auth with Google + GitHub OAuth providers |
3535

36+
### Cortex Status
37+
38+
| Key | Value |
39+
|-----|-------|
40+
| **cortex-version** | Tier 1-4 complete — tracking, classification, intelligence, cognitive |
41+
| **cortex-files** | cortex.json (chains/goals/conflicts), episodes.json, archive.json, evolution.log |
42+
| **cortex-commands** | /nemp:cortex, /nemp:cortex status, insight, resolve, learn, simulate, trust, validate, goal, --apply, --fuse, --chains, --history |
43+
| **cortex-hooks** | save (type inference + contradiction check), recall/context/foresight (vitality tracking + episodes) |
44+
| **trust-score** | Not yet calculated (run /nemp:cortex status) |
45+
| **last-reflection** | None yet — runs after 5 sessions |
46+
3647
---

commands/context.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,54 @@ For each (key, value) in memories:
118118
2. **Key contains** - Key contains search term or expanded keyword
119119
3. **Value contains** - Value contains search term or expanded keyword
120120

121+
### 4b. Update Vitality for All Returned Memories
122+
123+
For each memory that matches and will be displayed to the user, update its vitality counters:
124+
125+
1. If the memory lacks cortex fields, initialize with defaults first:
126+
- `type`: `"fact"`
127+
- `confidence`: `{"score": 0.65, "source": "agent-inferred", "reason": "Pre-cortex memory"}`
128+
- `vitality`: all counters set to 0, `score`: 50, `state`: "active", `trend`: "stable", `last_read`: null, `decay_rate`: 0.01
129+
- `links`: `{"goals": [], "conflicts": [], "supersedes": null, "superseded_by": null, "causal": []}`
130+
2. For each matched memory, update:
131+
```
132+
vitality.reads += 1
133+
vitality.reads_7d += 1
134+
vitality.reads_30d += 1
135+
vitality.last_read = <current ISO-8601 timestamp>
136+
```
137+
3. Recalculate `vitality.score` using the formula:
138+
```
139+
vitality = (
140+
(reads_7d × 15) +
141+
(reads_30d × 3) +
142+
(foresight_load_ratio × 20) +
143+
(agent_reference_ratio × 25) +
144+
(update_frequency × 10) +
145+
(goal_link_active × 15) -
146+
(correction_events × 10) -
147+
(days_since_last_read × decay_rate)
148+
)
149+
clamped to 0-100
150+
```
151+
Where:
152+
- `foresight_load_ratio` = foresight_loads / (foresight_loads + foresight_skips), default 0 if both are 0
153+
- `agent_reference_ratio` = agent_references / reads, default 0 if reads is 0
154+
- `update_frequency` = update_count / max(1, days_since_created)
155+
- `goal_link_active` = 1 if links.goals has any active goal, else 0
156+
4. Set `vitality.state` based on score:
157+
- 80-100: `"thriving"`
158+
- 50-79: `"active"`
159+
- 20-49: `"fading"`
160+
- 1-19: `"dormant"`
161+
- 0: `"extinct"`
162+
5. Write ALL updated memories back to memories.json in **one write operation** (do not write per-memory).
163+
164+
**Log the operation:**
165+
```bash
166+
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] CONTEXT_READ agent=${CLAUDE_AGENT_NAME:-main} query=<query> matched=<n>" >> .nemp/access.log
167+
```
168+
121169
### 5. Display Results
122170

123171
**When matches found:**

0 commit comments

Comments
 (0)