@sksoftofficial/mindroot 1.0.4 → 1.0.5
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/README.md +1 -1
- package/package.json +1 -1
- package/src/core.js +4 -3
- package/src/markdown.js +6 -0
- package/src/mcp.js +1 -1
- package/test/markdown.test.js +6 -1
- package/test/mcp.test.js +20 -0
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ All tools are prefixed `mindroot_`.
|
|
|
143
143
|
| `list_notes` | `project*` | List notes with section paths |
|
|
144
144
|
| `read_note` | `project*`, `path`, `section?` | Full note content, or one section's body via `section` (hash-verified, auto-reindexed) |
|
|
145
145
|
| `save_note` | `project*`, `path`, `content` | Create/overwrite a note |
|
|
146
|
-
| `update_section` | `project*`, `path`, `heading_path`, `content` | Replace one section body,
|
|
146
|
+
| `update_section` | `project*`, `path`, `heading_path`, `content` | Replace one section body, or append the section when missing |
|
|
147
147
|
| `delete_note` | `project*`, `path` | Delete a note (clears its linked memories) |
|
|
148
148
|
|
|
149
149
|
## REST API
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sksoftofficial/mindroot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Long-term memory for AI agents: hybrid-searched memories over human-editable markdown notes. 100% local — offline ONNX embeddings, SQLite FTS5, MCP server, REST API, CLI, dashboard. No cloud, no API keys.",
|
|
5
5
|
"homepage": "https://skbilisim.com/en/projects/mindroot",
|
|
6
6
|
"type": "module",
|
package/src/core.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
reindexDoc,
|
|
11
11
|
httpError,
|
|
12
12
|
} from "./indexer.js";
|
|
13
|
-
import { parseMarkdown, replaceSectionBody } from "./markdown.js";
|
|
13
|
+
import { appendSection, parseMarkdown, replaceSectionBody } from "./markdown.js";
|
|
14
14
|
import { embedDoc } from "./embedder.js";
|
|
15
15
|
import { ONNX_MODEL_ID } from "./paths.js";
|
|
16
16
|
import { searchMemories as hybridSearchMemories, searchNotes as hybridSearchNotes, searchProjects } from "./search.js";
|
|
@@ -137,8 +137,9 @@ export async function updateSection(db, slug, relPath, headingPath, newContent)
|
|
|
137
137
|
const { content } = await verifyAndLoadDoc(db, slug, relPath);
|
|
138
138
|
const parsed = parseMarkdown(content);
|
|
139
139
|
const sec = parsed.sections.find((s) => s.path === headingPath);
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
const updated = sec
|
|
141
|
+
? replaceSectionBody(content, sec, newContent)
|
|
142
|
+
: appendSection(content, headingPath, newContent);
|
|
142
143
|
return saveNote(db, slug, relPath, updated);
|
|
143
144
|
}
|
|
144
145
|
|
package/src/markdown.js
CHANGED
|
@@ -70,3 +70,9 @@ export function replaceSectionBody(raw, sec, newBody) {
|
|
|
70
70
|
const replacement = newBody.replace(/\n+$/, "").split("\n");
|
|
71
71
|
return [...lines.slice(0, sec.bodyStart), ...replacement, ...lines.slice(sec.bodyEnd)].join("\n");
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
export function appendSection(raw, headingPath, body) {
|
|
75
|
+
const note = raw.replace(/\n+$/, "");
|
|
76
|
+
const content = body.replace(/\n+$/, "");
|
|
77
|
+
return `${note ? `${note}\n\n` : ""}## ${headingPath}${content ? `\n\n${content}` : ""}\n`;
|
|
78
|
+
}
|
package/src/mcp.js
CHANGED
|
@@ -123,7 +123,7 @@ export function tools() {
|
|
|
123
123
|
{
|
|
124
124
|
name: "mindroot_update_section",
|
|
125
125
|
description:
|
|
126
|
-
"Replace the body of
|
|
126
|
+
"Replace the body of an existing heading-section, or append it to the note when missing.",
|
|
127
127
|
inputSchema: {
|
|
128
128
|
type: "object",
|
|
129
129
|
properties: {
|
package/test/markdown.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
|
-
import { parseMarkdown, docTitle, replaceSectionBody } from "../src/markdown.js";
|
|
3
|
+
import { appendSection, parseMarkdown, docTitle, replaceSectionBody } from "../src/markdown.js";
|
|
4
4
|
|
|
5
5
|
test("parseMarkdown builds nested heading paths and excludes H1", () => {
|
|
6
6
|
const md = "# Title\n\nintro\n\n## Arch\n\ntop\n\n### Arch::Storage\n\nnested\n";
|
|
@@ -30,3 +30,8 @@ test("replaceSectionBody splices only the target section", () => {
|
|
|
30
30
|
assert.match(out, /keep me/);
|
|
31
31
|
assert.match(out, /^# T/);
|
|
32
32
|
});
|
|
33
|
+
|
|
34
|
+
test("appendSection adds a missing section at the end", () => {
|
|
35
|
+
const md = "# T\n\n## Existing\n\nkeep me\n";
|
|
36
|
+
assert.equal(appendSection(md, "Added", "new body"), `${md}\n## Added\n\nnew body\n`);
|
|
37
|
+
});
|
package/test/mcp.test.js
CHANGED
|
@@ -109,3 +109,23 @@ test("rename_project moves slug, dir, and embeddings", async () => {
|
|
|
109
109
|
assert.equal(bad.body.result.isError, true);
|
|
110
110
|
assert.match(bad.body.result.content[0].text, /invalid project slug/);
|
|
111
111
|
});
|
|
112
|
+
|
|
113
|
+
test("update_section appends a missing section", async () => {
|
|
114
|
+
await call("mindroot_save_note", {
|
|
115
|
+
project: "section-upsert",
|
|
116
|
+
path: "note.md",
|
|
117
|
+
content: "# Note\n\n## Existing\n\nkeep me\n",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const res = await call("mindroot_update_section", {
|
|
121
|
+
project: "section-upsert",
|
|
122
|
+
path: "note.md",
|
|
123
|
+
heading_path: "Added",
|
|
124
|
+
content: "new body",
|
|
125
|
+
});
|
|
126
|
+
assert.equal(res.body.result.isError, undefined);
|
|
127
|
+
|
|
128
|
+
const note = JSON.parse(res.body.result.content[0].text);
|
|
129
|
+
assert.equal(note.content, "# Note\n\n## Existing\n\nkeep me\n\n## Added\n\nnew body\n");
|
|
130
|
+
assert.ok(note.sections.some((section) => section.path === "Added"));
|
|
131
|
+
});
|