d365fo-mcp 1.26.0 → 1.26.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/dist/bridge/bridgeClient.d.ts +50 -0
- package/dist/bridge/bridgeClient.js +131 -0
- package/dist/bridge/udeLaunchPaths.d.ts +20 -0
- package/dist/bridge/udeLaunchPaths.js +34 -0
- package/dist/config/settings.js +22 -0
- package/dist/index.js +23 -10
- package/dist/metadata/symbolIndex.d.ts +7 -0
- package/dist/metadata/symbolIndex.js +36 -1
- package/dist/middleware/httpPipeline.d.ts +14 -0
- package/dist/middleware/httpPipeline.js +23 -0
- package/dist/scripts/build-database.js +52 -3
- package/dist/scripts/build-fts.js +52 -3
- package/dist/scripts/extract-binary-models.js +20 -0
- package/dist/scripts/extract-metadata.js +20 -0
- package/dist/scripts/startupIndexWorker.js +52 -3
- package/dist/server/transport.js +5 -0
- package/dist/tools/readers/classInfo.js +29 -5
- package/dist/tools/readers/diskFallback.d.ts +30 -0
- package/dist/tools/readers/diskFallback.js +61 -0
- package/dist/tools/readers/edtInfo.js +7 -0
- package/dist/tools/readers/formInfo.js +14 -0
- package/dist/tools/readers/getWorkspaceInfo.js +15 -1
- package/dist/tools/sdlc/modelReindex.d.ts +30 -1
- package/dist/tools/sdlc/modelReindex.js +98 -6
- package/dist/tools/sdlc/runBpCheck.d.ts +28 -0
- package/dist/tools/sdlc/runBpCheck.js +82 -16
- package/dist/tools/sdlc/updateSymbolIndex.d.ts +17 -0
- package/dist/tools/sdlc/updateSymbolIndex.js +21 -0
- package/dist/tools/smart/generateSmartForm.js +9 -5
- package/dist/tools/smart/generateSmartReport.js +9 -5
- package/dist/tools/smart/generateSmartTable.js +9 -5
- package/dist/tools/toolHandler.js +6 -2
- package/dist/tools/write/createD365File.js +19 -12
- package/dist/tools/write/deleteD365File.js +7 -2
- package/dist/utils/modelClassifier.d.ts +2 -0
- package/dist/utils/modelClassifier.js +4 -0
- package/dist/utils/nameArguments.d.ts +22 -0
- package/dist/utils/nameArguments.js +59 -0
- package/dist/utils/objectFileLookup.js +5 -2
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import fs from 'fs';
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import { bridgeRefreshProvider } from '../../bridge/index.js';
|
|
19
|
-
import { isCustomModel } from '../../utils/modelClassifier.js';
|
|
19
|
+
import { getAutoDetectedCustomModels, getCustomModels, isCustomModel } from '../../utils/modelClassifier.js';
|
|
20
20
|
import { getConfigManager } from '../../utils/configManager.js';
|
|
21
21
|
import { resetMetadataMtimeCache } from '../../utils/indexStaleness.js';
|
|
22
22
|
import { indexOneFile, isAotFolder } from './updateSymbolIndex.js';
|
|
@@ -60,7 +60,9 @@ export async function resolveModelFolder(model, context) {
|
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
for (const pkg of packages) {
|
|
63
|
-
|
|
63
|
+
// A package linked into the packages root (a junction or symlink to a repository)
|
|
64
|
+
// is not a "directory" to a Dirent; existsSync below follows the link.
|
|
65
|
+
if (!pkg.isDirectory() && !pkg.isSymbolicLink())
|
|
64
66
|
continue;
|
|
65
67
|
const candidate = path.join(root, pkg.name, model);
|
|
66
68
|
if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory())
|
|
@@ -96,7 +98,7 @@ export function listModelFiles(folder) {
|
|
|
96
98
|
walk(folder, false);
|
|
97
99
|
return files;
|
|
98
100
|
}
|
|
99
|
-
export async function reindexModel(model, context) {
|
|
101
|
+
export async function reindexModel(model, context, options = {}) {
|
|
100
102
|
const fail = (text) => ({ content: [{ type: 'text', text }], isError: true });
|
|
101
103
|
// A Microsoft model is tens of thousands of files and changes only with a platform
|
|
102
104
|
// update, which is what build-database is for.
|
|
@@ -115,12 +117,13 @@ export async function reindexModel(model, context) {
|
|
|
115
117
|
const { symbolIndex } = context;
|
|
116
118
|
const onDisk = listModelFiles(folder);
|
|
117
119
|
const recorded = symbolIndex.getIndexedFileMtimes?.(model) ?? new Map();
|
|
118
|
-
const
|
|
120
|
+
const since = options.unrecordedSince;
|
|
121
|
+
const firstPass = recorded.size === 0 && since === undefined;
|
|
119
122
|
const changed = onDisk.filter(fp => {
|
|
120
123
|
const was = recorded.get(fp.toLowerCase());
|
|
121
|
-
if (was === undefined)
|
|
122
|
-
return true;
|
|
123
124
|
try {
|
|
125
|
+
if (was === undefined)
|
|
126
|
+
return since === undefined || fs.statSync(fp).mtimeMs > since;
|
|
124
127
|
return fs.statSync(fp).mtimeMs !== was;
|
|
125
128
|
}
|
|
126
129
|
catch {
|
|
@@ -164,6 +167,9 @@ export async function reindexModel(model, context) {
|
|
|
164
167
|
const failures = [];
|
|
165
168
|
const names = [];
|
|
166
169
|
for (const fp of [...changed, ...deleted]) {
|
|
170
|
+
// Types indexed without a parser finish in microtasks; yield so requests are served
|
|
171
|
+
// between files, however many changed.
|
|
172
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
167
173
|
const result = await indexOneFile(fp, context);
|
|
168
174
|
if (result.isError)
|
|
169
175
|
failures.push(result.text);
|
|
@@ -191,4 +197,90 @@ export async function reindexModel(model, context) {
|
|
|
191
197
|
...(failures.length > 0 && failures.length === changed.length + deleted.length ? { isError: true } : {}),
|
|
192
198
|
};
|
|
193
199
|
}
|
|
200
|
+
/** A file changed this shortly before the model's stamp is read again (clock skew, writes in flight). */
|
|
201
|
+
const STARTUP_TOLERANCE_MS = 60_000;
|
|
202
|
+
/**
|
|
203
|
+
* Bring the index in line with files changed while the server was not running (a git pull,
|
|
204
|
+
* a branch switch, a Visual Studio session), once, in the background after start-up.
|
|
205
|
+
*
|
|
206
|
+
* Runs reindexModel for each model, one at a time with a yield between models, so a
|
|
207
|
+
* request is never queued behind more than one model's walk. A model whose files are all
|
|
208
|
+
* indexed costs one directory walk and one stat per file. Returns one log line per model
|
|
209
|
+
* that changed, and never throws.
|
|
210
|
+
*/
|
|
211
|
+
export async function reindexChangedModels(models, context) {
|
|
212
|
+
const index = context.symbolIndex;
|
|
213
|
+
// Only for a model with no stamp of its own (an index built before stamps existed):
|
|
214
|
+
// every write moves last_indexed_at, so it can hide an older change.
|
|
215
|
+
const fallback = Date.parse(index.getLastIndexedAt?.() ?? '');
|
|
216
|
+
const lines = [];
|
|
217
|
+
for (const model of models) {
|
|
218
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
219
|
+
try {
|
|
220
|
+
const synced = Date.parse(index.getModelSyncedAt?.(model) ?? '');
|
|
221
|
+
const since = Number.isFinite(synced) ? synced : fallback;
|
|
222
|
+
if (!Number.isFinite(since))
|
|
223
|
+
continue;
|
|
224
|
+
const startedAt = new Date().toISOString();
|
|
225
|
+
const result = await reindexModel(model, context, { unrecordedSince: since - STARTUP_TOLERANCE_MS });
|
|
226
|
+
const text = result.content[0]?.text ?? '';
|
|
227
|
+
// A failed file stays unrecorded, so the stamp must not move past it.
|
|
228
|
+
if (!result.isError && !text.includes('file(s) failed'))
|
|
229
|
+
index.setModelSyncedAt?.(model, startedAt);
|
|
230
|
+
if (result.isError || !/re-indexed from/.test(text))
|
|
231
|
+
continue;
|
|
232
|
+
const indexed = /Indexed : (\d+)/.exec(text)?.[1] ?? '?';
|
|
233
|
+
const removed = /Removed : (\d+)/.exec(text)?.[1] ?? '?';
|
|
234
|
+
lines.push(`${model}: ${indexed} changed or new, ${removed} deleted`);
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
lines.push(`${model}: skipped (${err instanceof Error ? err.message : err})`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return lines;
|
|
241
|
+
}
|
|
242
|
+
/** Delay after start-up before the background pass, so it does not compete with the first requests. */
|
|
243
|
+
const STARTUP_REINDEX_DELAY_MS = 15_000;
|
|
244
|
+
/** At most this many models are checked at start-up. */
|
|
245
|
+
const STARTUP_REINDEX_MAX_MODELS = 20;
|
|
246
|
+
/**
|
|
247
|
+
* The custom models this workspace develops: the configured model, the models registered
|
|
248
|
+
* as custom at run time, and the CUSTOM_MODELS entries that are names (not masks).
|
|
249
|
+
*/
|
|
250
|
+
export function workspaceCustomModels(configuredModel) {
|
|
251
|
+
const names = [
|
|
252
|
+
...(configuredModel ? [configuredModel] : []),
|
|
253
|
+
...getAutoDetectedCustomModels(),
|
|
254
|
+
...getCustomModels().filter(m => !m.includes('*') && !m.startsWith('!')),
|
|
255
|
+
];
|
|
256
|
+
const seen = new Set();
|
|
257
|
+
return names.filter(n => {
|
|
258
|
+
const key = n.toLowerCase();
|
|
259
|
+
if (seen.has(key) || !isCustomModel(n))
|
|
260
|
+
return false;
|
|
261
|
+
seen.add(key);
|
|
262
|
+
return true;
|
|
263
|
+
}).slice(0, STARTUP_REINDEX_MAX_MODELS);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Schedule reindexChangedModels once, STARTUP_REINDEX_DELAY_MS after start-up, unless
|
|
267
|
+
* REINDEX_CHANGED_ON_STARTUP=false. The timer is unref'd, so it never keeps the process alive.
|
|
268
|
+
*/
|
|
269
|
+
export function scheduleStartupReindex(context, log, delayMs = STARTUP_REINDEX_DELAY_MS) {
|
|
270
|
+
if (process.env.REINDEX_CHANGED_ON_STARTUP?.trim().toLowerCase() === 'false')
|
|
271
|
+
return;
|
|
272
|
+
const timer = setTimeout(async () => {
|
|
273
|
+
try {
|
|
274
|
+
const configMgr = getConfigManager();
|
|
275
|
+
const configured = configMgr.getModelName() ?? (await configMgr.getAutoDetectedModelName());
|
|
276
|
+
const lines = await reindexChangedModels(workspaceCustomModels(configured), context);
|
|
277
|
+
for (const line of lines)
|
|
278
|
+
log(`Re-indexed files changed since the last index: ${line}`);
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
log(`Start-up re-index skipped: ${err instanceof Error ? err.message : err}`);
|
|
282
|
+
}
|
|
283
|
+
}, delayMs);
|
|
284
|
+
timer.unref?.();
|
|
285
|
+
}
|
|
194
286
|
//# sourceMappingURL=modelReindex.js.map
|
|
@@ -24,6 +24,34 @@ export declare function normalizeElementType(raw: string): string;
|
|
|
24
24
|
* caller will act on.
|
|
25
25
|
*/
|
|
26
26
|
export declare function describeNonRun(output: string, targetName?: string): string;
|
|
27
|
+
/** How an xppbp process ended, when it did not end with exit code 0 (execFile's error fields). */
|
|
28
|
+
export interface XppbpFailure {
|
|
29
|
+
code?: number | string | null;
|
|
30
|
+
signal?: string | null;
|
|
31
|
+
killed?: boolean;
|
|
32
|
+
message?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* An xppbp run that broke off, as a sentence — or '' when it finished.
|
|
36
|
+
*
|
|
37
|
+
* "No findings" is a pass only when the checker reached the end. A crashed run
|
|
38
|
+
* prints no findings either, and with the exit code unread it came back as
|
|
39
|
+
* `✅ BP Check passed`.
|
|
40
|
+
*
|
|
41
|
+
* xppbp 7.0.7996.33 exited 0 on every completed run probed (with warnings, and
|
|
42
|
+
* with an "element not found" error), 1 on a rejected argument and 6 on a fatal
|
|
43
|
+
* error. A non-zero exit is still accepted when the run printed its tally AND
|
|
44
|
+
* reported something: those findings are real, and they cannot read as a pass.
|
|
45
|
+
*/
|
|
46
|
+
export declare function describeFailedRun(output: string, failure?: XppbpFailure): string;
|
|
47
|
+
/**
|
|
48
|
+
* Does a run_bp_check reply say that something went unchecked? A refusal or a
|
|
49
|
+
* broken-off run starts with "❌", a batch marks the object, a build result puts
|
|
50
|
+
* the reply under its best-practices heading, and a diff with nothing in it never
|
|
51
|
+
* starts xppbp. Such a reply with no finding in it is no evidence of a clean
|
|
52
|
+
* object — the eval oracle must not score it as one.
|
|
53
|
+
*/
|
|
54
|
+
export declare function replyLeavesBpUnchecked(reply: string): boolean;
|
|
27
55
|
/** Elements xppbp reported as not compiled (its CompilerMetadataMissing warning). */
|
|
28
56
|
export declare function uncompiledElements(output: string): string[];
|
|
29
57
|
/**
|
|
@@ -157,6 +157,64 @@ export function describeNonRun(output, targetName) {
|
|
|
157
157
|
}
|
|
158
158
|
return '';
|
|
159
159
|
}
|
|
160
|
+
/** Does the output report anything — a finding line, or a non-zero tally? */
|
|
161
|
+
function hasIssues(output) {
|
|
162
|
+
// xppbp emits either "BPError..."/XML <Diagnostic severity="error"> or
|
|
163
|
+
// "BestPractices Warning/Error: ..." — both count as a violation.
|
|
164
|
+
return /BPError|<Diagnostic|severity="error"|BestPractices (Warning|Error):/i.test(output)
|
|
165
|
+
|| /severity\s*[:=]\s*error/i.test(output)
|
|
166
|
+
|| /^Warnings:\s*[1-9]/m.test(output)
|
|
167
|
+
|| /^Errors:\s*[1-9]/m.test(output);
|
|
168
|
+
}
|
|
169
|
+
/** The closing tally of a run that got to the end. */
|
|
170
|
+
const TALLY_PATTERN = /^\s*Errors:\s*\d+\s*$/m;
|
|
171
|
+
/** e.g. "MetadataProvider Fatal Error: No module with the name … could be found". */
|
|
172
|
+
const FATAL_LINE_PATTERN = /^\s*(?:\w+ )?Fatal Error:/m;
|
|
173
|
+
/**
|
|
174
|
+
* An xppbp run that broke off, as a sentence — or '' when it finished.
|
|
175
|
+
*
|
|
176
|
+
* "No findings" is a pass only when the checker reached the end. A crashed run
|
|
177
|
+
* prints no findings either, and with the exit code unread it came back as
|
|
178
|
+
* `✅ BP Check passed`.
|
|
179
|
+
*
|
|
180
|
+
* xppbp 7.0.7996.33 exited 0 on every completed run probed (with warnings, and
|
|
181
|
+
* with an "element not found" error), 1 on a rejected argument and 6 on a fatal
|
|
182
|
+
* error. A non-zero exit is still accepted when the run printed its tally AND
|
|
183
|
+
* reported something: those findings are real, and they cannot read as a pass.
|
|
184
|
+
*/
|
|
185
|
+
export function describeFailedRun(output, failure) {
|
|
186
|
+
const how = !failure ? ''
|
|
187
|
+
: failure.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER' ? 'xppbp printed more output than the server can hold, and was stopped'
|
|
188
|
+
: failure.killed ? 'xppbp was stopped before it finished (the time limit is 5 minutes per run)'
|
|
189
|
+
: typeof failure.code === 'number' ? `xppbp exited with code ${failure.code}`
|
|
190
|
+
: failure.signal ? `xppbp was terminated by ${failure.signal}`
|
|
191
|
+
: `xppbp could not be run (${failure.message ?? failure.code})`;
|
|
192
|
+
if (FATAL_LINE_PATTERN.test(output)) {
|
|
193
|
+
return `${how || 'xppbp finished'} after reporting a fatal error, so the check is incomplete.`;
|
|
194
|
+
}
|
|
195
|
+
if (failure && !(TALLY_PATTERN.test(output) && hasIssues(output))) {
|
|
196
|
+
return `${how} without a completed result, so the absence of findings below proves nothing.`;
|
|
197
|
+
}
|
|
198
|
+
if (!output.trim()) {
|
|
199
|
+
return 'xppbp printed nothing, so there is no evidence that any rule ran.';
|
|
200
|
+
}
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Does a run_bp_check reply say that something went unchecked? A refusal or a
|
|
205
|
+
* broken-off run starts with "❌", a batch marks the object, a build result puts
|
|
206
|
+
* the reply under its best-practices heading, and a diff with nothing in it never
|
|
207
|
+
* starts xppbp. Such a reply with no finding in it is no evidence of a clean
|
|
208
|
+
* object — the eval oracle must not score it as one.
|
|
209
|
+
*/
|
|
210
|
+
export function replyLeavesBpUnchecked(reply) {
|
|
211
|
+
const text = reply.replace(/^/, '').trim();
|
|
212
|
+
return text === ''
|
|
213
|
+
|| text.startsWith('❌')
|
|
214
|
+
|| text.startsWith('✅ Nothing to check')
|
|
215
|
+
|| /^❌ BP Check\b|── ❌ NOT CHECKED|^⚠️ bpCheck requested but could not run/m.test(text)
|
|
216
|
+
|| /^--- Best practices \(bpCheck=true\)[^\n]*\n❌/m.test(text);
|
|
217
|
+
}
|
|
160
218
|
/** Elements xppbp reported as not compiled (its CompilerMetadataMissing warning). */
|
|
161
219
|
export function uncompiledElements(output) {
|
|
162
220
|
const names = new Set();
|
|
@@ -689,25 +747,28 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
689
747
|
];
|
|
690
748
|
// One entry per object; `null` is the unfiltered whole-model run.
|
|
691
749
|
const runTargets = targets.length > 0 ? targets : [null];
|
|
692
|
-
const
|
|
750
|
+
const runs = await withOperationLock(`bp:${modelName}`, async () => {
|
|
693
751
|
// The flag style is a property of the installed xppbp, not of the object:
|
|
694
752
|
// once one works, later objects in the batch start from it instead of
|
|
695
753
|
// paying the fallback chain again.
|
|
696
754
|
let preferredStyle = 0;
|
|
697
|
-
const
|
|
755
|
+
const results = [];
|
|
698
756
|
for (const target of runTargets) {
|
|
699
757
|
let combined = '';
|
|
758
|
+
let failure;
|
|
700
759
|
for (let i = preferredStyle; i < styles.length; i++) {
|
|
701
760
|
const args = styles[i].build(target);
|
|
702
761
|
console.error(`[run_bp_check] Attempt ${i + 1} (${styles[i].label}) for ${selector(target)}: "${xppbpPath}" ${args.join(' ')}`);
|
|
703
762
|
let stdout = '';
|
|
704
763
|
let stderr = '';
|
|
764
|
+
failure = undefined;
|
|
705
765
|
try {
|
|
706
766
|
({ stdout, stderr } = await tryXppbp(xppbpPath, args));
|
|
707
767
|
}
|
|
708
768
|
catch (e) {
|
|
709
769
|
stdout = e.stdout ?? '';
|
|
710
770
|
stderr = e.stderr ?? '';
|
|
771
|
+
failure = e;
|
|
711
772
|
}
|
|
712
773
|
combined = [stdout, stderr].filter(Boolean).join('\n').trim();
|
|
713
774
|
if (!HELP_TEXT_PATTERN.test(combined) && combined !== '') {
|
|
@@ -715,10 +776,11 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
715
776
|
break;
|
|
716
777
|
}
|
|
717
778
|
}
|
|
718
|
-
|
|
779
|
+
results.push({ output: combined, failure });
|
|
719
780
|
}
|
|
720
|
-
return
|
|
781
|
+
return results;
|
|
721
782
|
});
|
|
783
|
+
const combinedByTarget = runs.map(r => r.output);
|
|
722
784
|
// If the first target still shows help text, no flag style works on this
|
|
723
785
|
// xppbp at all — report that once rather than per object.
|
|
724
786
|
if (HELP_TEXT_PATTERN.test(combinedByTarget[0])) {
|
|
@@ -730,6 +792,15 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
730
792
|
isError: true
|
|
731
793
|
};
|
|
732
794
|
}
|
|
795
|
+
// Judged once, on xppbp's own output: a rejection it explains (describeNonRun),
|
|
796
|
+
// else a run that broke off (describeFailedRun).
|
|
797
|
+
const verdicts = runs.map((r, i) => {
|
|
798
|
+
const rejected = describeNonRun(r.output, runTargets[i]?.name);
|
|
799
|
+
return rejected
|
|
800
|
+
? { reason: rejected, brokeOff: false }
|
|
801
|
+
: { reason: describeFailedRun(r.output, r.failure), brokeOff: true };
|
|
802
|
+
});
|
|
803
|
+
const nonRunByTarget = verdicts.map(v => v.reason);
|
|
733
804
|
// Pipeline parity (bpPipelineParity.ts): the OperationalDomain/SubscriberAccessLevel
|
|
734
805
|
// rules the pipeline's newer BP packages have and this xppbp lacks go INTO the output,
|
|
735
806
|
// as detail lines, so every reader below (verdict, findings section, build summary)
|
|
@@ -740,19 +811,13 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
740
811
|
modelName,
|
|
741
812
|
targets: runTargets,
|
|
742
813
|
outputs: combinedByTarget,
|
|
743
|
-
skip:
|
|
814
|
+
skip: nonRunByTarget.map(Boolean),
|
|
744
815
|
indexFormAllLocal: db ? form => formDataSourcesAllLocal(form, db) : undefined,
|
|
745
816
|
labelsCompiled: labelResult.success,
|
|
746
817
|
parse: parseBpFindings,
|
|
747
818
|
});
|
|
748
819
|
for (let i = 0; i < combinedByTarget.length; i++)
|
|
749
820
|
combinedByTarget[i] += parity.appended[i];
|
|
750
|
-
// xppbp emits either "BPError..."/XML <Diagnostic severity="error"> or
|
|
751
|
-
// "BestPractices Warning/Error: ..." — both count as a violation.
|
|
752
|
-
const hasIssues = (output) => /BPError|<Diagnostic|severity="error"|BestPractices (Warning|Error):/i.test(output)
|
|
753
|
-
|| /severity\s*[:=]\s*error/i.test(output)
|
|
754
|
-
|| /^Warnings:\s*[1-9]/m.test(output)
|
|
755
|
-
|| /^Errors:\s*[1-9]/m.test(output);
|
|
756
821
|
const header = `Model: ${modelName}` + (resolvedProjectPath ? `\nProject: ${resolvedProjectPath}` : '');
|
|
757
822
|
// A clean xppbp run is routinely read as "the task is done". It is not a compile:
|
|
758
823
|
// run f2e7b71a shipped a CoC method that violates SYS10028 with this line reading
|
|
@@ -772,7 +837,7 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
772
837
|
const dataDir = context?.symbolIndex?.dataDir;
|
|
773
838
|
const perTarget = combinedByTarget.map(o => parseBpFindings(o));
|
|
774
839
|
const baselineSound = !!dataDir
|
|
775
|
-
&& combinedByTarget.every((o, i) => !
|
|
840
|
+
&& combinedByTarget.every((o, i) => !nonRunByTarget[i]
|
|
776
841
|
&& (perTarget[i].length > 0 || !hasIssues(o)));
|
|
777
842
|
let view;
|
|
778
843
|
if (baselineSound) {
|
|
@@ -788,12 +853,15 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
788
853
|
if (runTargets.length === 1) {
|
|
789
854
|
const combined = combinedByTarget[0];
|
|
790
855
|
const target = runTargets[0];
|
|
791
|
-
const notRun =
|
|
856
|
+
const notRun = nonRunByTarget[0];
|
|
792
857
|
if (notRun) {
|
|
858
|
+
const headline = verdicts[0].brokeOff
|
|
859
|
+
? '❌ BP Check did NOT complete — this is not a pass.'
|
|
860
|
+
: '❌ BP Check did NOT run — nothing was verified.';
|
|
793
861
|
return {
|
|
794
862
|
content: [{
|
|
795
863
|
type: 'text',
|
|
796
|
-
text:
|
|
864
|
+
text: `${headline}\n\n${header}` +
|
|
797
865
|
(target ? `\nFilter: ${selector(target)}` : '') +
|
|
798
866
|
`\n\n${notRun}\n\n${combined || '(no output)'}`,
|
|
799
867
|
}],
|
|
@@ -823,8 +891,6 @@ export const runBpCheckTool = async (params, context) => {
|
|
|
823
891
|
}
|
|
824
892
|
// Batch: one preamble, findings grouped per object (#828).
|
|
825
893
|
const { preamble, bodies } = splitSharedPreamble(combinedByTarget);
|
|
826
|
-
// Not `.map(describeNonRun)` — that would pass the array index as the target name.
|
|
827
|
-
const nonRunByTarget = combinedByTarget.map((output, i) => describeNonRun(output, runTargets[i]?.name));
|
|
828
894
|
const notRunCount = nonRunByTarget.filter(Boolean).length;
|
|
829
895
|
const issueCount = combinedByTarget.filter((o, i) => !nonRunByTarget[i]
|
|
830
896
|
&& (view ? freshOf(i).length > 0 : hasIssues(o))).length;
|
|
@@ -13,6 +13,23 @@ export declare function isAotFolder(segment: string): boolean;
|
|
|
13
13
|
* when the path carries no AOT folder at all.
|
|
14
14
|
*/
|
|
15
15
|
export declare function classifyAotFolder(aotFolder: string): XppSymbol['type'];
|
|
16
|
+
/**
|
|
17
|
+
* update_symbol_index as a client calls it: every filePath must be under a configured
|
|
18
|
+
* package root, because the file is read into the index and later reads answer from it.
|
|
19
|
+
* The server's own callers use updateSymbolIndexTool with paths they have checked.
|
|
20
|
+
*/
|
|
21
|
+
export declare const updateSymbolIndexRequest: (params: any, context: XppServerContext) => Promise<{
|
|
22
|
+
content: {
|
|
23
|
+
type: string;
|
|
24
|
+
text: string;
|
|
25
|
+
}[];
|
|
26
|
+
isError: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
content: {
|
|
29
|
+
type: string;
|
|
30
|
+
text: string;
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
16
33
|
export declare const updateSymbolIndexTool: (params: any, context: XppServerContext) => Promise<{
|
|
17
34
|
content: {
|
|
18
35
|
type: string;
|
|
@@ -5,6 +5,7 @@ import { parseLabelFile } from '../../metadata/labelParser.js';
|
|
|
5
5
|
import { renderMethodSignature } from '../../metadata/xppDeclaration.js';
|
|
6
6
|
import { bridgeRefreshProvider } from '../../bridge/index.js';
|
|
7
7
|
import { getLastRefreshStartedAt } from '../../bridge/debouncedRefresh.js';
|
|
8
|
+
import { assertReadRootAllowed } from '../../utils/pathContainment.js';
|
|
8
9
|
// Tool registration (name, description, inputSchema) lives in
|
|
9
10
|
// src/server/toolSchemas/updateSymbolIndex.ts — the single source of truth for tool
|
|
10
11
|
// instructions. It is NOT in mcpServer.ts; that file only spreads the
|
|
@@ -200,6 +201,26 @@ async function refreshBridgeForBatch(context, filePaths) {
|
|
|
200
201
|
return { note: `Bridge refresh skipped: ${e?.message ?? e}`, redundant: false };
|
|
201
202
|
}
|
|
202
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* update_symbol_index as a client calls it: every filePath must be under a configured
|
|
206
|
+
* package root, because the file is read into the index and later reads answer from it.
|
|
207
|
+
* The server's own callers use updateSymbolIndexTool with paths they have checked.
|
|
208
|
+
*/
|
|
209
|
+
export const updateSymbolIndexRequest = async (params, context) => {
|
|
210
|
+
for (const filePath of normalizeFilePaths(params?.filePath)) {
|
|
211
|
+
const allowed = await assertReadRootAllowed(filePath);
|
|
212
|
+
if (!allowed.ok) {
|
|
213
|
+
return {
|
|
214
|
+
content: [{
|
|
215
|
+
type: 'text',
|
|
216
|
+
text: `❌ update_symbol_index: filePath rejected, nothing was indexed.\n${allowed.reason}`,
|
|
217
|
+
}],
|
|
218
|
+
isError: true,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return updateSymbolIndexTool(params, context);
|
|
223
|
+
};
|
|
203
224
|
export const updateSymbolIndexTool = async (params, context) => {
|
|
204
225
|
const filePaths = normalizeFilePaths(params?.filePath);
|
|
205
226
|
const model = typeof params?.model === 'string' ? params.model.trim() : '';
|
|
@@ -1035,25 +1035,29 @@ export async function handleGenerateSmartForm(args, symbolIndex) {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
const targetPath = path.join(packagePath, resolvedModel, resolvedModel, 'AxForm', `${finalName}.xml`);
|
|
1037
1037
|
const normalizedPath = targetPath.replace(/\//g, '\\');
|
|
1038
|
+
// normalizedPath is for the reply and the .rnrproj; the disk is reached through
|
|
1039
|
+
// the native path. Same string on Windows; elsewhere a backslash is a file-name
|
|
1040
|
+
// character, and writing to normalizedPath made one file in the working directory.
|
|
1041
|
+
const diskPath = targetPath;
|
|
1038
1042
|
// Verify drive/root exists
|
|
1039
|
-
const driveOrRoot = path.parse(
|
|
1043
|
+
const driveOrRoot = path.parse(diskPath).root;
|
|
1040
1044
|
if (driveOrRoot && !fs.existsSync(driveOrRoot)) {
|
|
1041
1045
|
throw new Error(`❌ Drive or root path does not exist: ${driveOrRoot}\n\n` +
|
|
1042
1046
|
`Attempting to create: ${normalizedPath}\n\n` +
|
|
1043
1047
|
`Update "packagePath" in .mcp.json to match your actual D365FO installation.`);
|
|
1044
1048
|
}
|
|
1045
|
-
const dir = path.dirname(
|
|
1049
|
+
const dir = path.dirname(diskPath);
|
|
1046
1050
|
if (!fs.existsSync(dir)) {
|
|
1047
1051
|
fs.mkdirSync(dir, { recursive: true });
|
|
1048
1052
|
}
|
|
1049
1053
|
// Only a file this call brings into being may later be deleted by undo.
|
|
1050
|
-
const existedBefore = fs.existsSync(
|
|
1051
|
-
fs.writeFileSync(
|
|
1054
|
+
const existedBefore = fs.existsSync(diskPath);
|
|
1055
|
+
fs.writeFileSync(diskPath, normalizeD365Xml(xml), 'utf-8');
|
|
1052
1056
|
console.log(`[generateSmartForm] Created file: ${normalizedPath}`);
|
|
1053
1057
|
// Tell the index about it, the way every create/modify path does.
|
|
1054
1058
|
// Without this the object is invisible to `search` — which is now answered
|
|
1055
1059
|
// from the index for untyped queries — in the very session that created it.
|
|
1056
|
-
await upsertWrittenFileIntoIndex(
|
|
1060
|
+
await upsertWrittenFileIntoIndex(diskPath, { symbolIndex });
|
|
1057
1061
|
// Add to Visual Studio project if a projectPath is known
|
|
1058
1062
|
let projectMessage = '';
|
|
1059
1063
|
let addedToProject;
|
|
@@ -1035,22 +1035,26 @@ export async function handleGenerateSmartReport(args, symbolIndex, bridge) {
|
|
|
1035
1035
|
for (const obj of generatedObjects) {
|
|
1036
1036
|
const targetPath = path.join(pkgPath, resolvedModel, resolvedModel, obj.aotFolder, `${obj.objectName}.xml`);
|
|
1037
1037
|
const normalizedPath = targetPath.replace(/\//g, '\\');
|
|
1038
|
-
|
|
1038
|
+
// normalizedPath is for the reply and the .rnrproj; the disk is reached through
|
|
1039
|
+
// the native path. Same string on Windows; elsewhere a backslash is a file-name
|
|
1040
|
+
// character, and writing to normalizedPath made one file in the working directory.
|
|
1041
|
+
const diskPath = targetPath;
|
|
1042
|
+
const dir = path.dirname(diskPath);
|
|
1039
1043
|
if (!fs.existsSync(dir)) {
|
|
1040
1044
|
fs.mkdirSync(dir, { recursive: true });
|
|
1041
1045
|
}
|
|
1042
1046
|
// Guard: refuse to overwrite existing table files (would destroy existing methods, fields, etc.)
|
|
1043
|
-
if (obj.objectType === 'table' && fs.existsSync(
|
|
1047
|
+
if (obj.objectType === 'table' && fs.existsSync(diskPath)) {
|
|
1044
1048
|
results.push(`⚠️ ${obj.objectType}: ${normalizedPath} — SKIPPED (file already exists, would destroy existing content). Use \`d365fo_file(action="modify")\` to modify existing tables.`);
|
|
1045
1049
|
log(`Skipped existing table: ${normalizedPath}`);
|
|
1046
1050
|
continue;
|
|
1047
1051
|
}
|
|
1048
1052
|
// Only a file this call brings into being may later be deleted by undo.
|
|
1049
|
-
const existedBefore = fs.existsSync(
|
|
1050
|
-
fs.writeFileSync(
|
|
1053
|
+
const existedBefore = fs.existsSync(diskPath);
|
|
1054
|
+
fs.writeFileSync(diskPath, normalizeD365Xml(obj.content), 'utf-8');
|
|
1051
1055
|
// Same reason as the other generators: an object the index never hears
|
|
1052
1056
|
// about is missing from the untyped `search` that now answers from it.
|
|
1053
|
-
await upsertWrittenFileIntoIndex(
|
|
1057
|
+
await upsertWrittenFileIntoIndex(diskPath, { symbolIndex });
|
|
1054
1058
|
let projectMsg = '';
|
|
1055
1059
|
let addedToProject;
|
|
1056
1060
|
if (effectiveProjectPath) {
|
|
@@ -920,6 +920,10 @@ export async function handleGenerateSmartTable(args, symbolIndex, bridge) {
|
|
|
920
920
|
const targetPath = path.join(packagePath, resolvedModel, resolvedModel, 'AxTable', `${finalName}.xml`);
|
|
921
921
|
// Normalize path to Windows format (backslashes) for consistency
|
|
922
922
|
const normalizedPath = targetPath.replace(/\//g, '\\');
|
|
923
|
+
// normalizedPath is for the reply and the .rnrproj; the disk is reached through
|
|
924
|
+
// the native path. Same string on Windows; elsewhere a backslash is a file-name
|
|
925
|
+
// character, and writing to normalizedPath made one file in the working directory.
|
|
926
|
+
const diskPath = targetPath;
|
|
923
927
|
// Reject Windows paths when running on non-Windows (e.g. Linux Azure proxy)
|
|
924
928
|
if (process.platform !== 'win32' && /^[A-Z]:\\/.test(normalizedPath)) {
|
|
925
929
|
throw new Error(`❌ Cannot create D365FO file on non-Windows system!\n\n` +
|
|
@@ -929,30 +933,30 @@ export async function handleGenerateSmartTable(args, symbolIndex, bridge) {
|
|
|
929
933
|
`Run the MCP server locally on the D365FO Windows VM.`);
|
|
930
934
|
}
|
|
931
935
|
// Verify drive/root exists before attempting recursive mkdir
|
|
932
|
-
const driveOrRoot = path.parse(
|
|
936
|
+
const driveOrRoot = path.parse(diskPath).root;
|
|
933
937
|
if (driveOrRoot && !fs.existsSync(driveOrRoot)) {
|
|
934
938
|
throw new Error(`❌ Drive or root path does not exist: ${driveOrRoot}\n\n` +
|
|
935
939
|
`Attempting to create: ${normalizedPath}\n\n` +
|
|
936
940
|
`Update "packagePath" in .mcp.json to match your actual D365FO installation.`);
|
|
937
941
|
}
|
|
938
942
|
// Create directory if needed
|
|
939
|
-
const dir = path.dirname(
|
|
943
|
+
const dir = path.dirname(diskPath);
|
|
940
944
|
if (!fs.existsSync(dir)) {
|
|
941
945
|
fs.mkdirSync(dir, { recursive: true });
|
|
942
946
|
}
|
|
943
947
|
// Guard: refuse to overwrite an existing table file (would destroy existing methods, fields, etc.)
|
|
944
|
-
if (fs.existsSync(
|
|
948
|
+
if (fs.existsSync(diskPath)) {
|
|
945
949
|
throw new Error(`⚠️ Table "${finalName}" already exists at:\n${normalizedPath}\n\n` +
|
|
946
950
|
`\`generate_object(mode="scaffold", objectType="table")\` is for **NEW** tables only.\n` +
|
|
947
951
|
`Use \`d365fo_file(action="modify")\` to add fields, methods, or indexes to an existing table.\n` +
|
|
948
952
|
`Use \`get_object_info(objectType="table", name="${finalName}")\` to inspect the current structure.`);
|
|
949
953
|
}
|
|
950
954
|
// Write file
|
|
951
|
-
fs.writeFileSync(
|
|
955
|
+
fs.writeFileSync(diskPath, normalizeD365Xml(xml), 'utf-8');
|
|
952
956
|
// Tell the index about it, the way every create/modify path does.
|
|
953
957
|
// Without this the object is invisible to `search` — which is now answered
|
|
954
958
|
// from the index for untyped queries — in the very session that created it.
|
|
955
|
-
await upsertWrittenFileIntoIndex(
|
|
959
|
+
await upsertWrittenFileIntoIndex(diskPath, { symbolIndex });
|
|
956
960
|
console.log(`[generateSmartTable] Created file: ${normalizedPath}`);
|
|
957
961
|
// Add to Visual Studio project if a projectPath is known
|
|
958
962
|
let projectMessage = '';
|
|
@@ -21,7 +21,7 @@ import { extensionInfoTool } from './readers/extensionInfo.js';
|
|
|
21
21
|
import { getKnowledgeTool } from './knowledge/getKnowledge.js';
|
|
22
22
|
import { validateObjectNamingTool } from './analysis/validateObjectNaming.js';
|
|
23
23
|
import { verifyD365ProjectTool } from './sdlc/verifyD365Project.js';
|
|
24
|
-
import {
|
|
24
|
+
import { updateSymbolIndexRequest } from './sdlc/updateSymbolIndex.js';
|
|
25
25
|
import { buildProjectTool } from './sdlc/buildProject.js';
|
|
26
26
|
import { dbSyncTool } from './sdlc/dbSync.js';
|
|
27
27
|
import { runBpCheckTool } from './sdlc/runBpCheck.js';
|
|
@@ -37,6 +37,7 @@ import { getWorkspaceInfoTool } from './readers/getWorkspaceInfo.js';
|
|
|
37
37
|
import { recordToolStart, startMetricsLogging, recordCallSequence, occurrencesInEpoch, reportSlowCall } from '../utils/toolMetrics.js';
|
|
38
38
|
import { DEDUP_EXCLUDED_TOOLS, DEDUP_TTL_MS, dedupKey, getDedupedResult, storeDedupResult, appendNote, getInFlight, registerInFlight, clearInFlight, MUTATING_TOOLS, currentWriteEpoch, bumpWriteEpoch, } from '../utils/callDedup.js';
|
|
39
39
|
import { capToolResponse } from './responseCaps.js';
|
|
40
|
+
import { refusePathAsName } from '../utils/nameArguments.js';
|
|
40
41
|
/**
|
|
41
42
|
* Tools whose call can WRITE to the model. Used only to pick the right wording
|
|
42
43
|
* when the bridge failed but the tool still returned OK — see the note in the
|
|
@@ -217,6 +218,9 @@ export function registerToolHandler(server, context) {
|
|
|
217
218
|
isError: true,
|
|
218
219
|
};
|
|
219
220
|
}
|
|
221
|
+
const pathAsName = refusePathAsName(toolName, request.params.arguments); // every tool, one place
|
|
222
|
+
if (pathAsName)
|
|
223
|
+
return pathAsName;
|
|
220
224
|
// Loop detection + duplicate-call dedup
|
|
221
225
|
const callKey = dedupKey(toolName, request.params.arguments);
|
|
222
226
|
// Captured HERE, not after the tool runs: it tags this occurrence in the
|
|
@@ -319,7 +323,7 @@ export function registerToolHandler(server, context) {
|
|
|
319
323
|
case 'verify_d365fo_project':
|
|
320
324
|
return verifyD365ProjectTool(request, context);
|
|
321
325
|
case 'update_symbol_index':
|
|
322
|
-
return await
|
|
326
|
+
return await updateSymbolIndexRequest(request.params.arguments, context);
|
|
323
327
|
case 'build_d365fo_project':
|
|
324
328
|
// Streams progress while xppc runs, so a build longer than any timeout
|
|
325
329
|
// still completes inside this one call instead of handing back a stub.
|