pi-doc-injector 0.6.0 → 0.8.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 +76 -201
- package/audit.ts +186 -0
- package/cache.ts +55 -7
- package/commands.ts +168 -105
- package/config.ts +134 -55
- package/docs/async-subagent-bug.md +4 -196
- package/docs/publish.md +9 -7
- package/docs/test-md.md +16 -1
- package/docs/typescript-hardening.md +38 -0
- package/docs/workflow-md.md +16 -1
- package/globber.ts +29 -12
- package/index.ts +262 -187
- package/injector.ts +93 -5
- package/keyword-gen.ts +161 -37
- package/keyword-llm.ts +24 -16
- package/matcher.ts +57 -19
- package/notifier.ts +36 -36
- package/package.json +16 -9
- package/registry.ts +92 -53
- package/types.ts +9 -1
- package/picomatch.d.ts +0 -11
package/commands.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Slash commands for the Doc Injector extension.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
ExtensionAPI,
|
|
6
|
+
ExtensionContext,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { readInjectionHistory } from "./audit";
|
|
9
|
+
import { formatInjectionHistory } from "./injector";
|
|
5
10
|
import type { DocRegistry } from "./registry";
|
|
6
11
|
import type { DocInjectorConfig } from "./types";
|
|
7
12
|
|
|
8
13
|
/** Dependencies injected into the command registrar. */
|
|
9
14
|
export interface CommandDeps {
|
|
10
15
|
getRegistry: () => DocRegistry | null;
|
|
16
|
+
resetInjectionState: () => void;
|
|
11
17
|
getEnabled: () => boolean;
|
|
12
18
|
setEnabled: (v: boolean) => void;
|
|
13
19
|
reloadRegistry: () => Promise<number>;
|
|
14
20
|
getConfig: () => DocInjectorConfig;
|
|
15
|
-
generateKeywordsLLM: (
|
|
21
|
+
generateKeywordsLLM: (
|
|
22
|
+
files: Array<{ path: string; snippet: string; existingKeywords: string[] }>,
|
|
23
|
+
) => Promise<void>;
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
/**
|
|
@@ -20,132 +28,187 @@ export interface CommandDeps {
|
|
|
20
28
|
*
|
|
21
29
|
* Commands:
|
|
22
30
|
* - `/doc-inject [on|off|toggle|list|reset|status]` — manage injection state
|
|
31
|
+
* - `/doc-inject history [count|all]` — inspect saved injection history
|
|
23
32
|
* - `/doc-reload` — re-scan docs folder
|
|
24
33
|
* - `/doc-keywords-gen [path]` — generate LLM keywords for keyword-less files
|
|
25
34
|
*/
|
|
26
35
|
export function registerCommands(pi: ExtensionAPI, deps: CommandDeps): void {
|
|
27
|
-
const cmd = (
|
|
36
|
+
const cmd = (
|
|
37
|
+
name: string,
|
|
38
|
+
desc: string,
|
|
39
|
+
handler: (args: string, ctx: ExtensionContext) => Promise<void>,
|
|
40
|
+
) => {
|
|
28
41
|
pi.registerCommand(name, { description: desc, handler });
|
|
29
42
|
};
|
|
30
43
|
|
|
31
|
-
cmd(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
ctx.ui.notify("📄 No docs loaded", "warning");
|
|
44
|
+
cmd(
|
|
45
|
+
"doc-inject",
|
|
46
|
+
"Doc injector: on|off|toggle|list|reset|status|history [count|all]",
|
|
47
|
+
async (args, ctx) => {
|
|
48
|
+
const a = args.trim().toLowerCase();
|
|
49
|
+
if (/^history(?:\s|$)/.test(a)) {
|
|
50
|
+
const requested = a.slice("history".length).trim();
|
|
51
|
+
let limit: number | "all" = 20;
|
|
52
|
+
if (requested === "all") {
|
|
53
|
+
limit = "all";
|
|
54
|
+
} else if (requested) {
|
|
55
|
+
const count = /^\d+$/.test(requested) ? Number(requested) : NaN;
|
|
56
|
+
if (!Number.isSafeInteger(count) || count <= 0) {
|
|
57
|
+
ctx.ui.notify(
|
|
58
|
+
"Usage: /doc-inject history [count|all] (count must be a positive safe integer)",
|
|
59
|
+
"warning",
|
|
60
|
+
);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
limit = count;
|
|
64
|
+
}
|
|
65
|
+
const history = readInjectionHistory(ctx.sessionManager.getBranch());
|
|
66
|
+
ctx.ui.notify(formatInjectionHistory(history, limit), "info");
|
|
55
67
|
return;
|
|
56
68
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ctx.ui.notify("📄
|
|
60
|
-
|
|
69
|
+
if (a === "on") {
|
|
70
|
+
deps.setEnabled(true);
|
|
71
|
+
ctx.ui.notify("📄 Doc injection enabled", "info");
|
|
72
|
+
} else if (a === "off") {
|
|
73
|
+
deps.setEnabled(false);
|
|
74
|
+
ctx.ui.notify("📄 Doc injection disabled", "warning");
|
|
75
|
+
} else if (a === "toggle") {
|
|
76
|
+
const next = !deps.getEnabled();
|
|
77
|
+
deps.setEnabled(next);
|
|
78
|
+
ctx.ui.notify(
|
|
79
|
+
`📄 Doc injection ${next ? "enabled" : "disabled"}`,
|
|
80
|
+
"info",
|
|
81
|
+
);
|
|
82
|
+
} else if (a === "reset") {
|
|
83
|
+
const reg = deps.getRegistry();
|
|
84
|
+
if (reg) {
|
|
85
|
+
deps.resetInjectionState();
|
|
86
|
+
ctx.ui.notify("📄 Injection state reset", "info");
|
|
87
|
+
} else {
|
|
88
|
+
ctx.ui.notify("📄 No registry loaded", "warning");
|
|
89
|
+
}
|
|
90
|
+
} else if (a === "list") {
|
|
91
|
+
const reg = deps.getRegistry();
|
|
92
|
+
if (!reg) {
|
|
93
|
+
ctx.ui.notify("📄 No docs loaded", "warning");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const entries = reg.getEntries();
|
|
97
|
+
if (entries.length === 0) {
|
|
98
|
+
ctx.ui.notify("📄 No documents found in docs folder", "info");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const lines = entries.map((e) => {
|
|
102
|
+
const status = e.injected ? "✅" : "⬜";
|
|
103
|
+
const sourceTag = `[${e.keywordSource}]`;
|
|
104
|
+
return `${status} ${sourceTag} ${e.relativePath}: "${e.title}" — keywords: [${e.keywords.join(", ")}]`;
|
|
105
|
+
});
|
|
106
|
+
ctx.ui.notify(`📄 Registered docs:\n${lines.join("\n")}`, "info");
|
|
107
|
+
} else {
|
|
108
|
+
// status (default)
|
|
109
|
+
const reg = deps.getRegistry();
|
|
110
|
+
if (!reg) {
|
|
111
|
+
ctx.ui.notify("📄 Status: No registry loaded", "warning");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const entries = reg.getEntries();
|
|
115
|
+
const injected = entries.filter((e) => e.injected).length;
|
|
116
|
+
const kwCount = entries.reduce((sum, e) => sum + e.keywords.length, 0);
|
|
117
|
+
ctx.ui.notify(
|
|
118
|
+
`📄 Doc Injector Status:\n` +
|
|
119
|
+
` Enabled: ${deps.getEnabled() ? "✅" : "❌"}\n` +
|
|
120
|
+
` Docs: ${entries.length}\n` +
|
|
121
|
+
` Keywords: ${kwCount}\n` +
|
|
122
|
+
` Injected: ${injected}`,
|
|
123
|
+
"info",
|
|
124
|
+
);
|
|
61
125
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
cmd(
|
|
130
|
+
"doc-reload",
|
|
131
|
+
"Re-scan docs folder and rebuild registry",
|
|
132
|
+
async (_args, ctx) => {
|
|
133
|
+
try {
|
|
134
|
+
const count = await deps.reloadRegistry();
|
|
135
|
+
ctx.ui.notify(`📄 Reloaded: ${count} documents found`, "info");
|
|
136
|
+
} catch (err) {
|
|
137
|
+
ctx.ui.notify(
|
|
138
|
+
`📄 Reload failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
139
|
+
"error",
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
cmd(
|
|
146
|
+
"doc-keywords-gen",
|
|
147
|
+
"Generate LLM keywords: /doc-keywords-gen [path] — no arg = all keyword-less files",
|
|
148
|
+
async (args, ctx) => {
|
|
70
149
|
const reg = deps.getRegistry();
|
|
71
150
|
if (!reg) {
|
|
72
|
-
ctx.ui.notify("📄
|
|
151
|
+
ctx.ui.notify("📄 No registry loaded", "warning");
|
|
73
152
|
return;
|
|
74
153
|
}
|
|
75
|
-
const entries = reg.getEntries();
|
|
76
|
-
const injected = entries.filter((e) => e.injected).length;
|
|
77
|
-
const kwCount = entries.reduce((sum, e) => sum + e.keywords.length, 0);
|
|
78
|
-
ctx.ui.notify(
|
|
79
|
-
`📄 Doc Injector Status:\n` +
|
|
80
|
-
` Enabled: ${deps.getEnabled() ? "✅" : "❌"}\n` +
|
|
81
|
-
` Docs: ${entries.length}\n` +
|
|
82
|
-
` Keywords: ${kwCount}\n` +
|
|
83
|
-
` Injected: ${injected}`,
|
|
84
|
-
"info",
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
154
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
cmd("doc-keywords-gen", "Generate LLM keywords: /doc-keywords-gen [path] — no arg = all keyword-less files", async (args, ctx) => {
|
|
99
|
-
const reg = deps.getRegistry();
|
|
100
|
-
if (!reg) {
|
|
101
|
-
ctx.ui.notify("📄 No registry loaded", "warning");
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
155
|
+
const config = deps.getConfig();
|
|
156
|
+
if (config.mode !== "keywords" || !config.llmKeywords) {
|
|
157
|
+
ctx.ui.notify(
|
|
158
|
+
"📄 LLM keyword generation requires mode: keywords and llmKeywords: true",
|
|
159
|
+
"warning",
|
|
160
|
+
);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
104
163
|
|
|
105
|
-
|
|
106
|
-
if (!config.llmKeywords) {
|
|
107
|
-
ctx.ui.notify("📄 LLM keyword generation is disabled (llmKeywords: false in config)", "warning");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
164
|
+
const targetPath = args.trim();
|
|
110
165
|
|
|
111
|
-
|
|
166
|
+
// Heuristic keywords remain eligible for upgrade after cache-backed reloads.
|
|
167
|
+
let candidates = reg.getEntries().filter((e) => {
|
|
168
|
+
if (e.keywordSource === "frontmatter") return false;
|
|
169
|
+
if (e.keywordSource === "llm") return false; // already LLM-generated
|
|
170
|
+
return true;
|
|
171
|
+
});
|
|
112
172
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
173
|
+
if (targetPath) {
|
|
174
|
+
candidates = candidates.filter((e) =>
|
|
175
|
+
e.relativePath.includes(targetPath),
|
|
176
|
+
);
|
|
177
|
+
if (candidates.length === 0) {
|
|
178
|
+
ctx.ui.notify(
|
|
179
|
+
`📄 No keyword-less files matching "${targetPath}"`,
|
|
180
|
+
"info",
|
|
181
|
+
);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
120
185
|
|
|
121
|
-
if (targetPath) {
|
|
122
|
-
candidates = candidates.filter((e) => e.relativePath.includes(targetPath));
|
|
123
186
|
if (candidates.length === 0) {
|
|
124
|
-
ctx.ui.notify(
|
|
187
|
+
ctx.ui.notify("📄 All files already have keywords", "info");
|
|
125
188
|
return;
|
|
126
189
|
}
|
|
127
|
-
}
|
|
128
190
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}));
|
|
142
|
-
batches.push(batch);
|
|
143
|
-
}
|
|
191
|
+
const batchSize = config.llmBatchSize;
|
|
192
|
+
const batches: Array<
|
|
193
|
+
Array<{ path: string; snippet: string; existingKeywords: string[] }>
|
|
194
|
+
> = [];
|
|
195
|
+
for (let i = 0; i < candidates.length; i += batchSize) {
|
|
196
|
+
const batch = candidates.slice(i, i + batchSize).map((e) => ({
|
|
197
|
+
path: e.relativePath,
|
|
198
|
+
snippet: e.content.slice(0, 500),
|
|
199
|
+
existingKeywords: e.keywords,
|
|
200
|
+
}));
|
|
201
|
+
batches.push(batch);
|
|
202
|
+
}
|
|
144
203
|
|
|
145
|
-
|
|
204
|
+
ctx.ui.notify(
|
|
205
|
+
`📄 Sending ${batches.length} keyword-generation batch(es) for ${candidates.length} file(s)...`,
|
|
206
|
+
"info",
|
|
207
|
+
);
|
|
146
208
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
209
|
+
for (const batch of batches) {
|
|
210
|
+
await deps.generateKeywordsLLM(batch);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
);
|
|
151
214
|
}
|
package/config.ts
CHANGED
|
@@ -13,23 +13,25 @@ import type { Notifier } from "./notifier";
|
|
|
13
13
|
* if not a number.
|
|
14
14
|
*/
|
|
15
15
|
function clampInt(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
value: unknown,
|
|
17
|
+
defaultVal: number,
|
|
18
|
+
min: number,
|
|
19
|
+
max: number,
|
|
20
|
+
fieldName: string,
|
|
21
|
+
notifier: Notifier,
|
|
22
22
|
): number {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
23
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
24
|
+
return defaultVal;
|
|
25
|
+
}
|
|
26
|
+
const intVal = Math.trunc(value);
|
|
27
|
+
if (intVal < min || intVal > max) {
|
|
28
|
+
const clamped = Math.max(min, Math.min(max, intVal));
|
|
29
|
+
notifier.warn(
|
|
30
|
+
`[doc-injector] ${fieldName} must be ${min}-${max}, got ${intVal}. Clamping to ${clamped}.`,
|
|
31
|
+
);
|
|
32
|
+
return clamped;
|
|
33
|
+
}
|
|
34
|
+
return intVal;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -38,22 +40,33 @@ function clampInt(
|
|
|
38
40
|
* Warns via the `notifier` for non-string entries.
|
|
39
41
|
*/
|
|
40
42
|
function validateGlobArray(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
value: unknown,
|
|
44
|
+
defaultVal: string[],
|
|
45
|
+
notifier: Notifier,
|
|
44
46
|
): string[] {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
if (!Array.isArray(value)) {
|
|
48
|
+
return [...defaultVal];
|
|
49
|
+
}
|
|
50
|
+
const result: string[] = [];
|
|
51
|
+
for (const item of value) {
|
|
52
|
+
if (typeof item === "string") {
|
|
53
|
+
result.push(item);
|
|
54
|
+
} else {
|
|
55
|
+
notifier.warn(
|
|
56
|
+
`[doc-injector] Non-string entry in glob array ignored: ${String(item)}`,
|
|
57
|
+
);
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Keep invalid config values from reaching filesystem and matching code. */
|
|
64
|
+
function validString(value: unknown, fallback: string): string {
|
|
65
|
+
return typeof value === "string" && value.trim() ? value : fallback;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function validBoolean(value: unknown, fallback: boolean): boolean {
|
|
69
|
+
return typeof value === "boolean" ? value : fallback;
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
/**
|
|
@@ -62,32 +75,98 @@ function validateGlobArray(
|
|
|
62
75
|
* fields. Falls back to DEFAULT_CONFIG if the file doesn't exist or is
|
|
63
76
|
* invalid. Warnings (clamping, invalid entries) go through the `notifier`.
|
|
64
77
|
*/
|
|
65
|
-
export async function loadConfig(
|
|
66
|
-
|
|
78
|
+
export async function loadConfig(
|
|
79
|
+
cwd: string,
|
|
80
|
+
notifier: Notifier,
|
|
81
|
+
): Promise<DocInjectorConfig> {
|
|
82
|
+
const configPath = join(cwd, ".pi", "doc-injector.json");
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
try {
|
|
85
|
+
const raw = await readFile(configPath, "utf-8");
|
|
86
|
+
const value: unknown = JSON.parse(raw);
|
|
87
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
88
|
+
throw new Error("Config must be an object");
|
|
89
|
+
}
|
|
90
|
+
const parsed = value as Partial<DocInjectorConfig>;
|
|
71
91
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
return {
|
|
93
|
+
mode:
|
|
94
|
+
parsed.mode === "simple" || parsed.mode === "keywords"
|
|
95
|
+
? parsed.mode
|
|
96
|
+
: DEFAULT_CONFIG.mode,
|
|
97
|
+
docsPath: validString(parsed.docsPath, DEFAULT_CONFIG.docsPath),
|
|
98
|
+
matchThreshold: clampInt(
|
|
99
|
+
parsed.matchThreshold,
|
|
100
|
+
DEFAULT_CONFIG.matchThreshold,
|
|
101
|
+
1,
|
|
102
|
+
Infinity,
|
|
103
|
+
"matchThreshold",
|
|
104
|
+
notifier,
|
|
105
|
+
),
|
|
106
|
+
streamWindowSize: clampInt(
|
|
107
|
+
parsed.streamWindowSize,
|
|
108
|
+
DEFAULT_CONFIG.streamWindowSize,
|
|
109
|
+
0,
|
|
110
|
+
Infinity,
|
|
111
|
+
"streamWindowSize",
|
|
112
|
+
notifier,
|
|
113
|
+
),
|
|
114
|
+
contextThreshold: clampInt(
|
|
115
|
+
parsed.contextThreshold,
|
|
116
|
+
DEFAULT_CONFIG.contextThreshold,
|
|
117
|
+
0,
|
|
118
|
+
100,
|
|
119
|
+
"contextThreshold",
|
|
120
|
+
notifier,
|
|
121
|
+
),
|
|
122
|
+
recursive: validBoolean(parsed.recursive, DEFAULT_CONFIG.recursive),
|
|
123
|
+
include: validateGlobArray(
|
|
124
|
+
parsed.include,
|
|
125
|
+
DEFAULT_CONFIG.include,
|
|
126
|
+
notifier,
|
|
127
|
+
),
|
|
128
|
+
exclude: validateGlobArray(
|
|
129
|
+
parsed.exclude,
|
|
130
|
+
DEFAULT_CONFIG.exclude,
|
|
131
|
+
notifier,
|
|
132
|
+
),
|
|
133
|
+
maxFileSize: clampInt(
|
|
134
|
+
parsed.maxFileSize,
|
|
135
|
+
DEFAULT_CONFIG.maxFileSize,
|
|
136
|
+
1024,
|
|
137
|
+
10 * 1024 * 1024,
|
|
138
|
+
"maxFileSize",
|
|
139
|
+
notifier,
|
|
140
|
+
),
|
|
141
|
+
autoKeywords: validBoolean(
|
|
142
|
+
parsed.autoKeywords,
|
|
143
|
+
DEFAULT_CONFIG.autoKeywords,
|
|
144
|
+
),
|
|
145
|
+
llmKeywords: validBoolean(parsed.llmKeywords, DEFAULT_CONFIG.llmKeywords),
|
|
146
|
+
maxConcurrent: clampInt(
|
|
147
|
+
parsed.maxConcurrent,
|
|
148
|
+
DEFAULT_CONFIG.maxConcurrent,
|
|
149
|
+
1,
|
|
150
|
+
100,
|
|
151
|
+
"maxConcurrent",
|
|
152
|
+
notifier,
|
|
153
|
+
),
|
|
154
|
+
llmBatchSize: clampInt(
|
|
155
|
+
parsed.llmBatchSize,
|
|
156
|
+
DEFAULT_CONFIG.llmBatchSize,
|
|
157
|
+
1,
|
|
158
|
+
100,
|
|
159
|
+
"llmBatchSize",
|
|
160
|
+
notifier,
|
|
161
|
+
),
|
|
162
|
+
};
|
|
163
|
+
} catch (err) {
|
|
164
|
+
if ((err as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
165
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
166
|
+
notifier.warn(
|
|
167
|
+
`[doc-injector] Failed to parse config at ${configPath}: ${detail}`,
|
|
168
|
+
);
|
|
92
169
|
}
|
|
170
|
+
return { ...DEFAULT_CONFIG };
|
|
171
|
+
}
|
|
93
172
|
}
|