mixgram 1.1.0 → 1.1.2
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/package.json +1 -1
- package/spec/scenarios/scenarios.js +4 -0
- package/src/config.js +2 -2
- package/src/fs/paths.js +32 -3
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* ctx: { h, parse, config, fs, reporter, ok } where ok(cond, msg) counts and optionally prints check.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
7
9
|
import {
|
|
8
10
|
decisionSqliteIndex,
|
|
9
11
|
decisionSqliteIndexRevision2,
|
|
@@ -44,6 +46,7 @@ export const scenarios = [
|
|
|
44
46
|
ok(s1.success && s1.id && s1.created === true, 'save success');
|
|
45
47
|
ok(fs.existsSync(s1.path), 'file created');
|
|
46
48
|
ok(s1.path.includes('mixgram') || s1.path.replace(/\\/g, '/').includes('mixgram'), 'project doc under mixgram');
|
|
49
|
+
ok(path.basename(s1.path) === 'architecture-sqlite-derived-index.md', 'project doc filename omits redundant prefixes');
|
|
47
50
|
|
|
48
51
|
const search1 = await h.mem_search({ query: 'derived SQLite index', project: PROJECT_NAME });
|
|
49
52
|
const search1Parsed = parseRes(search1);
|
|
@@ -74,6 +77,7 @@ export const scenarios = [
|
|
|
74
77
|
const s2 = parseRes(save2);
|
|
75
78
|
reporter.step('mem_save (home)', { scope: 'home', topic_key: patternIncrementalReindex.topic_key }, { path: s2.path, created: s2.created });
|
|
76
79
|
ok(s2.success && s2.path && s2.path.includes('home'), 'home save');
|
|
80
|
+
ok(path.basename(s2.path) === 'incremental-reindexing.md', 'home doc filename omits folder category');
|
|
77
81
|
|
|
78
82
|
const searchMerged = await h.mem_search({ query: 'reindex', scope_mode: 'merged', project: PROJECT_NAME });
|
|
79
83
|
const mergedParsed = parseRes(searchMerged);
|
package/src/config.js
CHANGED
|
@@ -10,8 +10,8 @@ function expandHome(p) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const DEFAULT_CONFIG = {
|
|
13
|
-
homeMemoryRoot: '~/.mixgram/
|
|
14
|
-
projectMemoryRoot: './
|
|
13
|
+
homeMemoryRoot: '~/.mixgram/docs',
|
|
14
|
+
projectMemoryRoot: './docs',
|
|
15
15
|
sqlitePath: '~/.mixgram/index.db',
|
|
16
16
|
watch: true,
|
|
17
17
|
indexing: {
|
package/src/fs/paths.js
CHANGED
|
@@ -32,10 +32,38 @@ function slugFromTopicKey(topicKey) {
|
|
|
32
32
|
.replace(/^-|-$/g, '') || 'note';
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function filenameSlugFromTopicKey(topicKey, { project = null, type = null } = {}) {
|
|
36
|
+
if (!topicKey || typeof topicKey !== 'string') return 'note';
|
|
37
|
+
|
|
38
|
+
const segments = topicKey
|
|
39
|
+
.split('/')
|
|
40
|
+
.map((segment) => segment.trim())
|
|
41
|
+
.filter(Boolean);
|
|
42
|
+
|
|
43
|
+
if (segments.length === 0) return 'note';
|
|
44
|
+
|
|
45
|
+
const normalizedProject = slugFromTopicKey(project);
|
|
46
|
+
if (normalizedProject !== 'note' && slugFromTopicKey(segments[0]) === normalizedProject) {
|
|
47
|
+
segments.shift();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const typeDir = TYPE_TO_DIR[type] || 'generated';
|
|
51
|
+
const redundantPrefixes = new Set([
|
|
52
|
+
slugFromTopicKey(type),
|
|
53
|
+
slugFromTopicKey(typeDir)
|
|
54
|
+
].filter((value) => value !== 'note'));
|
|
55
|
+
|
|
56
|
+
if (segments.length > 1 && redundantPrefixes.has(slugFromTopicKey(segments[0]))) {
|
|
57
|
+
segments.shift();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return slugFromTopicKey(segments.join('-'));
|
|
61
|
+
}
|
|
62
|
+
|
|
35
63
|
function documentPath(config, { scope, project, type, topic_key, id }) {
|
|
36
64
|
const typeDir = TYPE_TO_DIR[type] || 'generated';
|
|
37
|
-
const slug =
|
|
38
|
-
const baseName = `${
|
|
65
|
+
const slug = filenameSlugFromTopicKey(topic_key, { project, type });
|
|
66
|
+
const baseName = `${slug}.md`;
|
|
39
67
|
|
|
40
68
|
if (scope === 'home') {
|
|
41
69
|
const root = config.homeMemoryRoot;
|
|
@@ -75,5 +103,6 @@ export {
|
|
|
75
103
|
mixgramDir,
|
|
76
104
|
ensureMixgramDir,
|
|
77
105
|
TYPE_TO_DIR,
|
|
78
|
-
slugFromTopicKey
|
|
106
|
+
slugFromTopicKey,
|
|
107
|
+
filenameSlugFromTopicKey
|
|
79
108
|
};
|