pi-nocturne-memory 1.0.1

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.
@@ -0,0 +1,27 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ publish:
14
+ name: Publish to npm
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: "22"
22
+
23
+ - name: Upgrade npm
24
+ run: npm install -g npm@latest && npm config set registry https://registry.npmjs.org/
25
+
26
+ - name: Publish
27
+ run: npm publish --access public
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # pi-nocturne-memory
2
+
3
+ **Nocturne Memory extension for Pi — automated memory management with SessionStart boot protocol.**
4
+
5
+ ## Features
6
+
7
+ - **SessionStart Boot Protocol** — Automatically calls `read_memory("system://boot")` at session start
8
+ - **Memory Rules** — Global rules injected every session for intelligent memory usage
9
+ - **5 Memory Tools** — read, create, update, delete, alias, search, manage_triggers
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pi install npm:pi-nocturne-memory
15
+ ```
16
+
17
+ ## Configure
18
+
19
+ Add to `~/.claude/rules.md` or project rules:
20
+
21
+ ```markdown
22
+ - nocturne-memory rules (from pi-nocturne-memory extension)
23
+ ```
24
+
25
+ ## How It Works
26
+
27
+ 1. **SessionStart Hook** — Triggers boot protocol at session start
28
+ 2. **Agent calls `nocturne_boot`** — Loads system://boot, recent/5, glossary
29
+ 3. **Global Rules** — Memory operation rules injected every session
30
+ 4. **Agent uses memory tools** — read/create/update/delete based on rules
31
+
32
+ ## License
33
+
34
+ MIT
@@ -0,0 +1,77 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { Text } from "@earendil-works/pi-tui";
3
+ import { Type } from "typebox";
4
+
5
+ const BOOT_URIS = [
6
+ "system://boot",
7
+ "system://recent/5",
8
+ "system://glossary",
9
+ ];
10
+
11
+ export default function (pi: ExtensionAPI) {
12
+ pi.registerTool({
13
+ name: "nocturne_boot",
14
+ label: "Boot Memory",
15
+ description:
16
+ "Call this at the start of every new session. Loads core memories, recent context, and glossary. This is your self-discipline startup protocol — call it before doing anything else.",
17
+ promptGuidelines: [
18
+ "MUST call this at the start of every new session before any other work.",
19
+ "This loads your core identity, recent context, and trigger glossary.",
20
+ "After booting, check if any disclosure conditions are triggered by the current conversation.",
21
+ ],
22
+ parameters: Type.Object({}),
23
+
24
+ async execute(_toolCallId, _params, _signal, onUpdate) {
25
+ onUpdate?.({
26
+ content: [{ type: "text", text: "🌙 Booting Nocturne Memory..." }],
27
+ details: { phase: "booting" },
28
+ });
29
+
30
+ const results: string[] = [];
31
+ const errors: string[] = [];
32
+
33
+ for (const uri of BOOT_URIS) {
34
+ try {
35
+ const resp = await fetch(`http://localhost:3000/mcp`, {
36
+ method: "POST",
37
+ headers: { "Content-Type": "application/json" },
38
+ body: JSON.stringify({
39
+ jsonrpc: "2.0",
40
+ id: uri,
41
+ method: "tools/call",
42
+ params: { name: "read_memory", arguments: { uri } },
43
+ }),
44
+ });
45
+ const data = await resp.json();
46
+ if (data.result?.content?.[0]?.text) {
47
+ results.push(`=== ${uri} ===\n${data.result.content[0].text}`);
48
+ }
49
+ } catch (err) {
50
+ errors.push(`${uri}: ${err instanceof Error ? err.message : String(err)}`);
51
+ }
52
+ }
53
+
54
+ if (results.length === 0 && errors.length > 0) {
55
+ return {
56
+ content: [{ type: "text", text: `❌ Failed to boot memory:\n${errors.join("\n")}` }],
57
+ details: { error: errors.join("\n") },
58
+ };
59
+ }
60
+
61
+ return {
62
+ content: [{ type: "text", text: results.join("\n\n---\n\n") }],
63
+ details: { booted: results.length, failed: errors.length },
64
+ };
65
+ },
66
+
67
+ renderCall(_args, theme) {
68
+ return new Text(theme.fg("toolTitle", theme.bold("🌙 Boot Memory")), 0, 0);
69
+ },
70
+
71
+ renderResult(result, _options, theme) {
72
+ const d = result.details as { error?: string; booted?: number } | undefined;
73
+ if (d?.error) return new Text(theme.fg("error", "❌ Boot failed"), 0, 0);
74
+ return new Text(theme.fg("success", `✓ ${d?.booted ?? 0} memory nodes loaded`), 0, 0);
75
+ },
76
+ });
77
+ }
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ # SessionStart hook for pi-nocturne-memory
3
+ # This runs when a new Pi session starts
4
+
5
+ # Check if nocturne-memory MCP is available
6
+ if command -v pi &> /dev/null; then
7
+ # Trigger the boot protocol by calling the MCP tool
8
+ # This will be picked up by the agent
9
+ echo "NOCTURNE_BOOT_REQUIRED"
10
+ fi
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "pi-nocturne-memory",
3
+ "version": "1.0.1",
4
+ "description": "Nocturne Memory extension for Pi — automated memory management with SessionStart boot protocol",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": "github:RealAlexandreAI/pi-nocturne-memory",
8
+ "keywords": [
9
+ "pi-package",
10
+ "pi",
11
+ "memory",
12
+ "extension"
13
+ ],
14
+ "pi": {
15
+ "extensions": [
16
+ "./extensions"
17
+ ],
18
+ "hooks": [
19
+ "./hooks/session-start.sh"
20
+ ]
21
+ },
22
+ "dependencies": {
23
+ "@earendil-works/pi-coding-agent": "^0.80.0"
24
+ }
25
+ }
package/rules.md ADDED
@@ -0,0 +1,31 @@
1
+ # Nocturne Memory Rules
2
+
3
+ ## Self-Discipline Startup Protocol
4
+ At the start of every new session, the agent MUST call `nocturne_boot` before doing anything else. This loads core memories, recent context, and glossary.
5
+
6
+ ## Memory OPERATIONS
7
+
8
+ ### Reading
9
+ - IF user mentions a topic you should have memory about → read_memory first
10
+ - IF unsure about a memory URI → use search_memory
11
+ - IF conversation exceeds 15 turns → read_memory to recalibrate
12
+ - IF disclosure condition is triggered → must read immediately
13
+
14
+ ### Writing
15
+ - New insights/understandings → create_memory immediately
16
+ - User reveals new info about themselves → create_memory
17
+ - Relationship events → create_memory
18
+ - Technical conclusions → create_memory
19
+ - Successful judgments → create_memory with [Baseline], [Deviation], [Result], [Reusable judgment] format
20
+
21
+ ### Updating
22
+ - Found inaccurate info → update_memory immediately
23
+ - User corrects you → update_memory
24
+ - Outdated info → update_memory
25
+
26
+ ### Deleting
27
+ - New insight covers old record → delete redundant nodes
28
+ - Bug/error/low quality → delete
29
+
30
+ ## Memory Value Principle
31
+ Memory value = ability to change behavior. If remembering something doesn't change your action, it's dead data worth deleting.