llm-wiki-kit 0.1.1 → 0.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/src/fs-utils.js +20 -1
package/package.json
CHANGED
package/src/fs-utils.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
unlink,
|
|
13
13
|
writeFile,
|
|
14
14
|
} from 'fs/promises';
|
|
15
|
-
import { dirname, join, parse, resolve } from 'path';
|
|
15
|
+
import { basename, dirname, join, parse, resolve } from 'path';
|
|
16
16
|
import { PROJECT_MARKERS } from './constants.js';
|
|
17
17
|
import { normalizeForStorage } from './redaction.js';
|
|
18
18
|
|
|
@@ -112,8 +112,27 @@ export async function safeSymlink(target, linkPath) {
|
|
|
112
112
|
await symlink(target, linkPath);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
async function containingWikiParent(path) {
|
|
116
|
+
let current = path;
|
|
117
|
+
while (true) {
|
|
118
|
+
if (
|
|
119
|
+
basename(current) === 'llm-wiki' &&
|
|
120
|
+
await exists(join(current, 'wiki', 'index.md')) &&
|
|
121
|
+
await exists(join(current, 'raw')) &&
|
|
122
|
+
await exists(join(current, 'outputs'))
|
|
123
|
+
) {
|
|
124
|
+
return dirname(current);
|
|
125
|
+
}
|
|
126
|
+
const parent = dirname(current);
|
|
127
|
+
if (parent === current) return null;
|
|
128
|
+
current = parent;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
115
132
|
export async function findProjectRoot(startDir = process.cwd()) {
|
|
116
133
|
let current = resolve(startDir);
|
|
134
|
+
const wikiParent = await containingWikiParent(current);
|
|
135
|
+
if (wikiParent) return wikiParent;
|
|
117
136
|
while (true) {
|
|
118
137
|
for (const marker of PROJECT_MARKERS) {
|
|
119
138
|
if (await exists(join(current, marker))) return current;
|