@jacklika/dsh-tool-memory-filesystem 0.1.3-alpha.1 → 0.1.3-alpha.3
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/lib/index.js +35 -1
- package/lib/types/index.d.ts +6 -0
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -20,6 +20,31 @@ import yaml from 'js-yaml';
|
|
|
20
20
|
export function vaultRelativeId(root, absolutePath) {
|
|
21
21
|
return relative(root, absolutePath).replace(/\\/g, '/');
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Format a Date as an ISO-like string in Asia/Shanghai (+08:00).
|
|
25
|
+
* The project convention is to store all vault timestamps in Beijing time.
|
|
26
|
+
* Keep this in sync with the helper in `@jacklika/dsh-memory-curator`.
|
|
27
|
+
*/
|
|
28
|
+
export function formatBeijingTime(date) {
|
|
29
|
+
const parts = new Intl.DateTimeFormat('sv-SE', {
|
|
30
|
+
timeZone: 'Asia/Shanghai',
|
|
31
|
+
year: 'numeric',
|
|
32
|
+
month: '2-digit',
|
|
33
|
+
day: '2-digit',
|
|
34
|
+
hour: '2-digit',
|
|
35
|
+
minute: '2-digit',
|
|
36
|
+
second: '2-digit',
|
|
37
|
+
hour12: false,
|
|
38
|
+
}).formatToParts(date);
|
|
39
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? '00';
|
|
40
|
+
const yyyy = get('year');
|
|
41
|
+
const MM = get('month');
|
|
42
|
+
const dd = get('day');
|
|
43
|
+
const HH = get('hour');
|
|
44
|
+
const mm = get('minute');
|
|
45
|
+
const ss = get('second');
|
|
46
|
+
return `${yyyy}-${MM}-${dd}T${HH}:${mm}:${ss}+08:00`;
|
|
47
|
+
}
|
|
23
48
|
/** Cordis plugin name used by loader diagnostics. */
|
|
24
49
|
export const name = 'tool-memory-filesystem';
|
|
25
50
|
/** Services required by the wiki/memory tool suite. */
|
|
@@ -191,6 +216,15 @@ export async function resolveLinkTarget(root, extensions, target) {
|
|
|
191
216
|
export async function listNotePaths(root, extensions, indexHiddenDirs = false) {
|
|
192
217
|
const results = [];
|
|
193
218
|
const exclude = new Set(['.git', 'node_modules', '.obsidian']);
|
|
219
|
+
try {
|
|
220
|
+
if (!(await stat(root)).isDirectory())
|
|
221
|
+
return results;
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
if (err.code === 'ENOENT')
|
|
225
|
+
return results;
|
|
226
|
+
throw err;
|
|
227
|
+
}
|
|
194
228
|
async function walk(dir) {
|
|
195
229
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
196
230
|
for (const entry of entries) {
|
|
@@ -472,7 +506,7 @@ export function apply(ctx, config) {
|
|
|
472
506
|
const frontmatterText = Object.keys(frontmatter).length > 0
|
|
473
507
|
? `---\n${yaml.dump(frontmatter).trim()}\n---\n\n`
|
|
474
508
|
: '';
|
|
475
|
-
const timestamp = new Date()
|
|
509
|
+
const timestamp = formatBeijingTime(new Date());
|
|
476
510
|
finalBody = `${frontmatterText}${body}\n\n## ${timestamp}\n\n${args.content}\n`;
|
|
477
511
|
}
|
|
478
512
|
exec.signal.throwIfAborted();
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export type * from './types.ts';
|
|
|
17
17
|
* uses POSIX separators so note ids are stable across Windows, macOS, and Linux.
|
|
18
18
|
*/
|
|
19
19
|
export declare function vaultRelativeId(root: string, absolutePath: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format a Date as an ISO-like string in Asia/Shanghai (+08:00).
|
|
22
|
+
* The project convention is to store all vault timestamps in Beijing time.
|
|
23
|
+
* Keep this in sync with the helper in `@jacklika/dsh-memory-curator`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatBeijingTime(date: Date): string;
|
|
20
26
|
/** Cordis plugin name used by loader diagnostics. */
|
|
21
27
|
export declare const name = "tool-memory-filesystem";
|
|
22
28
|
/** Services required by the wiki/memory tool suite. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jacklika/dsh-tool-memory-filesystem",
|
|
3
3
|
"description": "Model-facing wiki/memory tools over a local Markdown vault: read, search, and write notes with Obsidian-style links and YAML frontmatter.",
|
|
4
|
-
"version": "0.1.3-alpha.
|
|
4
|
+
"version": "0.1.3-alpha.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@deepseek-ai/cordis": "4.0.4",
|
|
39
|
-
"@deepseek-ai/dsh-tools": ">=0.1.7-rc.1 <0.3.0",
|
|
40
|
-
"@deepseek-ai/dsh-util-values": ">=0.1.7-rc.1 <0.3.0"
|
|
39
|
+
"@deepseek-ai/dsh-tools": ">=0.1.7-rc.1 <0.3.0-0",
|
|
40
|
+
"@deepseek-ai/dsh-util-values": ">=0.1.7-rc.1 <0.3.0-0"
|
|
41
41
|
}
|
|
42
42
|
}
|