@sksoftofficial/mindroot 1.0.3 → 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/dashboard/index.html +40 -4
- 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/dashboard/index.html
CHANGED
|
@@ -44,7 +44,16 @@
|
|
|
44
44
|
#gate { margin:auto; text-align:center; display:flex; flex-direction:column; gap:14px; width:min(420px, calc(100% - 32px)); padding:28px; background:var(--bg2); border:1px solid var(--border); border-radius:10px; box-shadow:0 12px 40px rgba(0,0,0,.28) }
|
|
45
45
|
#gate input { width:100% }
|
|
46
46
|
main { display:flex; flex:1; overflow:hidden }
|
|
47
|
-
aside { position:relative; z-index:1; width:230px; background:var(--bg2); border-right:1px solid var(--border-soft); overflow-y:auto; padding:10px
|
|
47
|
+
aside { position:relative; z-index:1; width:230px; background:var(--bg2); border-right:1px solid var(--border-soft); overflow-y:auto; padding:10px 14px; box-shadow:8px 0 20px rgba(0,0,0,.12); display:flex; flex-direction:column; gap:8px; transition:width 160ms ease-out }
|
|
48
|
+
.sidebar-toggle { flex:none; height:34px; padding:0; display:flex; align-items:center; justify-content:center }
|
|
49
|
+
.sidebar-toggle svg { width:17px; height:17px; stroke:currentColor; transition:transform 160ms ease-out }
|
|
50
|
+
@media (min-width:701px) {
|
|
51
|
+
aside.collapsed { width:56px; padding:10px 12px }
|
|
52
|
+
aside.collapsed .sidebar-toggle svg { transform:rotate(180deg) }
|
|
53
|
+
aside.collapsed .proj { padding:7px 0; text-align:center; font-size:0 }
|
|
54
|
+
aside.collapsed .proj::before { content:attr(data-initial); font-size:12px; line-height:inherit }
|
|
55
|
+
}
|
|
56
|
+
#projList { display:flex; flex-direction:column; gap:2px }
|
|
48
57
|
.proj { padding:7px 10px; border-radius:5px; cursor:pointer; color:var(--dim) }
|
|
49
58
|
.proj:hover { background:var(--hover); color:var(--fg) }
|
|
50
59
|
.proj.active { background:var(--accent-soft); color:#f2b46f }
|
|
@@ -89,7 +98,7 @@
|
|
|
89
98
|
.editor-document { min-width:0 }
|
|
90
99
|
.editor-title { max-width:320px; color:var(--fg); font-size:13px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
|
|
91
100
|
.editor-actions { justify-self:end }
|
|
92
|
-
.viewmode { display:inline-flex; gap:
|
|
101
|
+
.viewmode { display:inline-flex; gap:2px; padding:2px; background:#191919; border:1px solid var(--border); border-radius:6px }
|
|
93
102
|
.viewmode button { padding:4px 10px; background:transparent; border-color:transparent }
|
|
94
103
|
.viewmode button:hover { background:var(--hover); border-color:transparent }
|
|
95
104
|
.viewmode button.on { background:var(--accent-soft); color:#f2b46f; border-color:transparent }
|
|
@@ -141,12 +150,13 @@
|
|
|
141
150
|
.header-lock-label { display:none }
|
|
142
151
|
main { flex-direction:column }
|
|
143
152
|
aside { width:100%; max-height:112px; border-right:0; border-bottom:1px solid var(--border-soft); padding:7px 8px; box-shadow:0 8px 20px rgba(0,0,0,.12) }
|
|
144
|
-
#projList {
|
|
153
|
+
#projList { flex-direction:row; gap:4px; overflow-x:auto }
|
|
145
154
|
.proj { flex:none; white-space:nowrap }
|
|
146
155
|
#content { padding:14px }
|
|
147
156
|
.workspace-head { align-items:flex-start; flex-wrap:wrap; gap:8px; margin-bottom:12px; padding-bottom:10px }
|
|
148
157
|
button, input { min-height:44px; touch-action:manipulation }
|
|
149
158
|
.header-lock, .back-button { width:44px; height:44px }
|
|
159
|
+
.sidebar-toggle { display:none }
|
|
150
160
|
.proj, .tab { min-height:44px; display:flex; align-items:center }
|
|
151
161
|
.tab { padding:5px 8px }
|
|
152
162
|
.delete-project { padding:5px 9px }
|
|
@@ -202,7 +212,14 @@
|
|
|
202
212
|
</div>
|
|
203
213
|
|
|
204
214
|
<main id="app" style="display:none">
|
|
205
|
-
<aside
|
|
215
|
+
<aside>
|
|
216
|
+
<button class="sidebar-toggle" type="button" title="Shrink menu" aria-label="Shrink menu" aria-expanded="true" onclick="toggleSidebar()">
|
|
217
|
+
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
218
|
+
<path d="m14 7-5 5 5 5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
219
|
+
</svg>
|
|
220
|
+
</button>
|
|
221
|
+
<div id="projList"></div>
|
|
222
|
+
</aside>
|
|
206
223
|
<section id="content"></section>
|
|
207
224
|
</main>
|
|
208
225
|
|
|
@@ -300,6 +317,7 @@ async function renderProjects() {
|
|
|
300
317
|
for (const r of rows) {
|
|
301
318
|
const div = document.createElement("div");
|
|
302
319
|
div.className = "proj" + (r.slug === currentProject ? " active" : "");
|
|
320
|
+
div.dataset.initial = r.slug.slice(0, 2).toUpperCase();
|
|
303
321
|
div.textContent = r.slug;
|
|
304
322
|
div.title = r.docs + " notes, " + r.memories + " memories";
|
|
305
323
|
div.onclick = () => selectProject(r.slug);
|
|
@@ -382,6 +400,24 @@ async function renderNotes(view) {
|
|
|
382
400
|
|
|
383
401
|
let mdMode = localStorage.getItem("mindroot_mdmode") || "preview";
|
|
384
402
|
|
|
403
|
+
let sidebarCollapsed = localStorage.getItem("mindroot_sidebar") === "collapsed";
|
|
404
|
+
function toggleSidebar() { setSidebar(!sidebarCollapsed); }
|
|
405
|
+
function setSidebar(collapsed) {
|
|
406
|
+
sidebarCollapsed = collapsed;
|
|
407
|
+
localStorage.setItem("mindroot_sidebar", collapsed ? "collapsed" : "expanded");
|
|
408
|
+
applySidebar();
|
|
409
|
+
}
|
|
410
|
+
function applySidebar() {
|
|
411
|
+
const aside = document.querySelector("main aside");
|
|
412
|
+
const btn = $(".sidebar-toggle");
|
|
413
|
+
aside.classList.toggle("collapsed", sidebarCollapsed);
|
|
414
|
+
btn.setAttribute("aria-expanded", String(!sidebarCollapsed));
|
|
415
|
+
const label = sidebarCollapsed ? "Expand menu" : "Shrink menu";
|
|
416
|
+
btn.title = label;
|
|
417
|
+
btn.setAttribute("aria-label", label);
|
|
418
|
+
}
|
|
419
|
+
applySidebar();
|
|
420
|
+
|
|
385
421
|
function renderMd(text) {
|
|
386
422
|
if (window.marked && window.DOMPurify) {
|
|
387
423
|
marked.setOptions({ gfm: true, breaks: true });
|
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
|
+
});
|