@ureck/alexandria 1.0.0 → 1.2.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.
- package/README.md +17 -2
- package/dist/chunk-53SIGH5A.js +69 -0
- package/dist/{chunk-DYCARGQR.js → chunk-CIOCSIB5.js} +50 -0
- package/dist/{chunk-DCKYTO4O.js → chunk-FBGIFNIO.js} +1 -1
- package/dist/chunk-QB37UGO6.js +490 -0
- package/dist/{chunk-RZI7TYAG.js → chunk-UWB6RKVN.js} +2 -1
- package/dist/{chunk-DHXL36RG.js → chunk-ZIQYAQCF.js} +19 -33
- package/dist/cli.js +574 -159
- package/dist/hooks/on-prompt.js +41 -27
- package/dist/hooks/on-session-start.js +9 -9
- package/dist/hooks/on-stop.js +27 -3
- package/dist/mcp/server.js +10 -10
- package/dist/{viewer-73ZWPIDC.js → viewer-JQCSWJ3C.js} +2 -3
- package/package.json +1 -1
- package/dist/chunk-D5ROL42O.js +0 -267
- package/dist/chunk-DEDAOKAV.js +0 -44
- package/dist/chunk-XWR74BQ2.js +0 -170
package/dist/chunk-XWR74BQ2.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/core/notes.ts
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import matter from "gray-matter";
|
|
7
|
-
var NOTE_TYPES = [
|
|
8
|
-
"note",
|
|
9
|
-
"prompt",
|
|
10
|
-
"session",
|
|
11
|
-
"map",
|
|
12
|
-
"plan",
|
|
13
|
-
"task",
|
|
14
|
-
"verification",
|
|
15
|
-
"lesson",
|
|
16
|
-
"solution"
|
|
17
|
-
];
|
|
18
|
-
var SKIP_DIRS = /* @__PURE__ */ new Set([".obsidian", ".vault", ".trash", ".git", "node_modules"]);
|
|
19
|
-
function extractWikilinks(content) {
|
|
20
|
-
const out = /* @__PURE__ */ new Set();
|
|
21
|
-
const re = /\[\[([^\]|#\n]+)(?:[|#][^\]]*)?\]\]/g;
|
|
22
|
-
let m;
|
|
23
|
-
while ((m = re.exec(content)) !== null) {
|
|
24
|
-
const target = m[1].trim();
|
|
25
|
-
if (target) out.add(target);
|
|
26
|
-
}
|
|
27
|
-
return [...out];
|
|
28
|
-
}
|
|
29
|
-
function slugify(text) {
|
|
30
|
-
return text.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "nota";
|
|
31
|
-
}
|
|
32
|
-
function listMarkdownFiles(root) {
|
|
33
|
-
const out = [];
|
|
34
|
-
const walk = (dir) => {
|
|
35
|
-
let entries;
|
|
36
|
-
try {
|
|
37
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
38
|
-
} catch {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
for (const e of entries) {
|
|
42
|
-
if (e.name.startsWith(".") || SKIP_DIRS.has(e.name)) continue;
|
|
43
|
-
const full = path.join(dir, e.name);
|
|
44
|
-
if (e.isDirectory()) walk(full);
|
|
45
|
-
else if (e.isFile() && e.name.endsWith(".md")) out.push(full);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
walk(root);
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
|
-
function parseNote(root, absPath) {
|
|
52
|
-
const raw = fs.readFileSync(absPath, "utf8");
|
|
53
|
-
const { data, content } = matter(raw);
|
|
54
|
-
const rel = path.relative(root, absPath).split(path.sep).join("/");
|
|
55
|
-
const title = typeof data.title === "string" && data.title || path.basename(absPath, ".md");
|
|
56
|
-
const type = NOTE_TYPES.includes(data.type) ? data.type : "note";
|
|
57
|
-
const status = ["active", "completed", "failed"].includes(data.status) ? data.status : void 0;
|
|
58
|
-
const tags = Array.isArray(data.tags) ? data.tags.map(String) : [];
|
|
59
|
-
return {
|
|
60
|
-
rel,
|
|
61
|
-
title,
|
|
62
|
-
type,
|
|
63
|
-
status,
|
|
64
|
-
tags,
|
|
65
|
-
created: data.created ? String(data.created) : void 0,
|
|
66
|
-
hits: typeof data.hits === "number" ? data.hits : 1,
|
|
67
|
-
content,
|
|
68
|
-
links: extractWikilinks(content)
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function frontmatter(n) {
|
|
72
|
-
const lines = [
|
|
73
|
-
"---",
|
|
74
|
-
`title: ${JSON.stringify(n.title)}`,
|
|
75
|
-
// aliases: Obsidian resuelve [[wikilinks]] contra alias, no contra el title
|
|
76
|
-
// del frontmatter — sin esto su graph view muestra los enlaces como rotos
|
|
77
|
-
`aliases: [${JSON.stringify(n.title)}]`,
|
|
78
|
-
`type: ${n.type}`,
|
|
79
|
-
...n.status ? [`status: ${n.status}`] : [],
|
|
80
|
-
`tags: [${n.tags.map((t) => JSON.stringify(t)).join(", ")}]`,
|
|
81
|
-
`created: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
82
|
-
`hits: ${n.hits ?? 1}`,
|
|
83
|
-
"---",
|
|
84
|
-
""
|
|
85
|
-
];
|
|
86
|
-
return lines.join("\n");
|
|
87
|
-
}
|
|
88
|
-
function ensureAlias(absPath) {
|
|
89
|
-
try {
|
|
90
|
-
const raw = fs.readFileSync(absPath, "utf8");
|
|
91
|
-
const { data, content } = matter(raw);
|
|
92
|
-
if (!data.title || data.aliases) return false;
|
|
93
|
-
data.aliases = [String(data.title)];
|
|
94
|
-
fs.writeFileSync(absPath, matter.stringify(content, data));
|
|
95
|
-
return true;
|
|
96
|
-
} catch {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function createNote(managed, n) {
|
|
101
|
-
const dir = path.join(managed, n.dir ?? "notes");
|
|
102
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
103
|
-
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
104
|
-
const base = `${date}-${slugify(n.title)}`;
|
|
105
|
-
let file = path.join(dir, `${base}.md`);
|
|
106
|
-
let i = 2;
|
|
107
|
-
while (fs.existsSync(file)) file = path.join(dir, `${base}-${i++}.md`);
|
|
108
|
-
fs.writeFileSync(
|
|
109
|
-
file,
|
|
110
|
-
frontmatter({ title: n.title, type: n.type ?? "note", tags: n.tags ?? [], status: n.status }) + n.content.trim() + "\n"
|
|
111
|
-
);
|
|
112
|
-
return file;
|
|
113
|
-
}
|
|
114
|
-
function setNoteStatus(absPath, status) {
|
|
115
|
-
const raw = fs.readFileSync(absPath, "utf8");
|
|
116
|
-
const { data, content } = matter(raw);
|
|
117
|
-
data.status = status;
|
|
118
|
-
data.updated = (/* @__PURE__ */ new Date()).toISOString();
|
|
119
|
-
fs.writeFileSync(absPath, matter.stringify(content, data));
|
|
120
|
-
}
|
|
121
|
-
function touchNote(absPath) {
|
|
122
|
-
const raw = fs.readFileSync(absPath, "utf8");
|
|
123
|
-
const { data, content } = matter(raw);
|
|
124
|
-
data.hits = (typeof data.hits === "number" ? data.hits : 1) + 1;
|
|
125
|
-
data.updated = (/* @__PURE__ */ new Date()).toISOString();
|
|
126
|
-
fs.writeFileSync(absPath, matter.stringify(content, data));
|
|
127
|
-
}
|
|
128
|
-
function upsertNote(managed, n) {
|
|
129
|
-
const dir = path.join(managed, n.dir ?? "notes");
|
|
130
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
131
|
-
const file = path.join(dir, `${n.fixedName}.md`);
|
|
132
|
-
if (fs.existsSync(file)) {
|
|
133
|
-
const raw = fs.readFileSync(file, "utf8");
|
|
134
|
-
const { data } = matter(raw);
|
|
135
|
-
data.updated = (/* @__PURE__ */ new Date()).toISOString();
|
|
136
|
-
fs.writeFileSync(file, matter.stringify(n.content.trim() + "\n", data));
|
|
137
|
-
} else {
|
|
138
|
-
fs.writeFileSync(
|
|
139
|
-
file,
|
|
140
|
-
frontmatter({ title: n.title, type: n.type ?? "note", tags: n.tags ?? [], status: n.status }) + n.content.trim() + "\n"
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
return file;
|
|
144
|
-
}
|
|
145
|
-
function appendToNote(managed, n) {
|
|
146
|
-
const dir = path.join(managed, n.dir ?? "sessions");
|
|
147
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
148
|
-
const file = path.join(dir, `${n.fixedName}.md`);
|
|
149
|
-
if (fs.existsSync(file)) {
|
|
150
|
-
fs.appendFileSync(file, "\n" + n.content.trim() + "\n");
|
|
151
|
-
} else {
|
|
152
|
-
fs.writeFileSync(
|
|
153
|
-
file,
|
|
154
|
-
frontmatter({ title: n.title, type: n.type ?? "session", tags: n.tags ?? [], status: n.status }) + n.content.trim() + "\n"
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
return file;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export {
|
|
161
|
-
slugify,
|
|
162
|
-
listMarkdownFiles,
|
|
163
|
-
parseNote,
|
|
164
|
-
ensureAlias,
|
|
165
|
-
createNote,
|
|
166
|
-
setNoteStatus,
|
|
167
|
-
touchNote,
|
|
168
|
-
upsertNote,
|
|
169
|
-
appendToNote
|
|
170
|
-
};
|