@platformos/platformos-mcp-supervisor 0.0.2 → 0.1.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 +90 -0
- package/dist/adapter-input.d.ts +113 -0
- package/dist/adapter-input.js +210 -0
- package/dist/adapter-input.spec.d.ts +1 -0
- package/dist/adapter-input.spec.js +275 -0
- package/dist/bin/args.spec.d.ts +1 -0
- package/dist/bin/args.spec.js +35 -0
- package/dist/check-docs.d.ts +21 -0
- package/dist/check-docs.js +38 -0
- package/dist/check-docs.spec.d.ts +1 -0
- package/dist/check-docs.spec.js +87 -0
- package/dist/context.d.ts +26 -0
- package/dist/context.js +11 -0
- package/dist/cost-model.d.ts +128 -0
- package/dist/cost-model.js +137 -0
- package/dist/cost-model.spec.d.ts +1 -0
- package/dist/cost-model.spec.js +91 -0
- package/dist/deadline.d.ts +27 -0
- package/dist/deadline.js +40 -0
- package/dist/deadline.spec.d.ts +1 -0
- package/dist/deadline.spec.js +83 -0
- package/dist/enrich/enrich.d.ts +87 -0
- package/dist/enrich/enrich.js +97 -0
- package/dist/enrich/enrich.spec.d.ts +1 -0
- package/dist/enrich/enrich.spec.js +184 -0
- package/dist/enrich/symbol.d.ts +16 -0
- package/dist/enrich/symbol.js +58 -0
- package/dist/enrich/symbol.spec.d.ts +1 -0
- package/dist/enrich/symbol.spec.js +89 -0
- package/dist/impact/impact.d.ts +9 -0
- package/dist/impact/impact.js +189 -0
- package/dist/impact/impact.spec.d.ts +1 -0
- package/dist/impact/impact.spec.js +357 -0
- package/dist/impact/project-scan.d.ts +37 -0
- package/dist/impact/project-scan.js +60 -0
- package/dist/impact/project-scan.spec.d.ts +1 -0
- package/dist/impact/project-scan.spec.js +121 -0
- package/dist/index.d.ts +1 -1
- package/dist/lint/fixes.d.ts +28 -0
- package/dist/lint/fixes.js +30 -0
- package/dist/lint/lint-batch.d.ts +100 -0
- package/dist/lint/lint-batch.js +98 -0
- package/dist/lint/lint-batch.spec.d.ts +1 -0
- package/dist/lint/lint-batch.spec.js +503 -0
- package/dist/lint/lint.d.ts +11 -1
- package/dist/lint/lint.js +9 -3
- package/dist/result/assemble.d.ts +12 -9
- package/dist/result/assemble.js +64 -16
- package/dist/result/assemble.spec.d.ts +1 -0
- package/dist/result/assemble.spec.js +319 -0
- package/dist/result/blocking.d.ts +86 -0
- package/dist/result/blocking.js +96 -0
- package/dist/result/blocking.spec.d.ts +1 -0
- package/dist/result/blocking.spec.js +201 -0
- package/dist/result/impact-states.d.ts +16 -0
- package/dist/result/impact-states.js +18 -0
- package/dist/result/response-budget.d.ts +9 -0
- package/dist/result/response-budget.js +131 -0
- package/dist/result/response-budget.spec.d.ts +1 -0
- package/dist/result/response-budget.spec.js +222 -0
- package/dist/result/types.d.ts +210 -104
- package/dist/result/types.js +4 -13
- package/dist/transport/instructions-coverage.spec.d.ts +1 -0
- package/dist/transport/instructions-coverage.spec.js +176 -0
- package/dist/transport/instructions.d.ts +1 -0
- package/dist/transport/instructions.js +132 -0
- package/dist/transport/process-guards.d.ts +43 -0
- package/dist/transport/process-guards.js +63 -0
- package/dist/transport/process-guards.spec.d.ts +1 -0
- package/dist/transport/process-guards.spec.js +200 -0
- package/dist/transport/server.d.ts +1 -1
- package/dist/transport/server.js +16 -9
- package/dist/transport/validate-code.d.ts +36 -18
- package/dist/transport/validate-code.js +200 -33
- package/dist/transport/validate-code.spec.d.ts +1 -0
- package/dist/transport/validate-code.spec.js +2303 -0
- package/dist/validate/batch-bounds.d.ts +34 -0
- package/dist/validate/batch-bounds.js +60 -0
- package/dist/validate/batch-coherence.d.ts +21 -0
- package/dist/validate/batch-coherence.js +54 -0
- package/dist/validate/batch-coherence.spec.d.ts +1 -0
- package/dist/validate/batch-coherence.spec.js +111 -0
- package/dist/validate/validate-buffers.d.ts +27 -0
- package/dist/validate/validate-buffers.js +265 -0
- package/package.json +8 -7
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE lint adapter, over check-node's `lintBuffers` seam. There is no single-buffer
|
|
3
|
+
* counterpart: the orchestrator always works on a list, so one file is a batch of one.
|
|
4
|
+
*
|
|
5
|
+
* Everything expensive in a lint is per-PROJECT, not per-buffer — resolving the config,
|
|
6
|
+
* walking and reconciling the app, reconciling the route table — so linting N files one
|
|
7
|
+
* call at a time re-discovers the same unchanged project N times.
|
|
8
|
+
*
|
|
9
|
+
* And it is more CORRECT, which matters more: with every buffer overlaid at once — in the
|
|
10
|
+
* `App` and in the filesystem view reference checks resolve through — a partial introduced
|
|
11
|
+
* in one buffer resolves for a `render` in another. File-by-file linting reports
|
|
12
|
+
* `MissingPartial` for a file present in the very same request.
|
|
13
|
+
*/
|
|
14
|
+
import { type LintBufferStatus, type LiquidHtmlNode } from '@platformos/platformos-check-node';
|
|
15
|
+
import type { ValidateCodeDiagnostic } from '../result/types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Every reason a lint can conclude it did NOT check a file — check-node's own vocabulary,
|
|
18
|
+
* minus the one status that means it did.
|
|
19
|
+
*
|
|
20
|
+
* `Exclude` rather than a respelling: a status added upstream lands in this type
|
|
21
|
+
* automatically and then fails to compile at the ONE place that decides what an agent hears
|
|
22
|
+
* about it (`DECLINE`, in `validate/validate-buffers.ts`).
|
|
23
|
+
*
|
|
24
|
+
* This adapter deliberately does NOT translate these into `NotApplicableReason` codes —
|
|
25
|
+
* two of them collapse onto one code but keep distinct prose, so the mapping produces the
|
|
26
|
+
* reason and the message together, in the module that owns refusal wording.
|
|
27
|
+
*/
|
|
28
|
+
export type LintNotCheckedStatus = Exclude<LintBufferStatus, 'checked'>;
|
|
29
|
+
/**
|
|
30
|
+
* What one linted file offers a later stage, beyond the diagnostics themselves.
|
|
31
|
+
*
|
|
32
|
+
* `startIndexes` is INDEX-ALIGNED with that file's `diagnostics` array: entry `i` is where
|
|
33
|
+
* diagnostic `i` starts. Both are produced by one `map` over the same offense list in
|
|
34
|
+
* `runBatchLint`, and `lint-batch.spec.ts` asserts the alignment rather than trusting it.
|
|
35
|
+
*
|
|
36
|
+
* A 0-based offset, not the diagnostic's 1-based line/column: it exists to locate a node in
|
|
37
|
+
* {@link ast}, and that is what `findCurrentNode` takes.
|
|
38
|
+
*/
|
|
39
|
+
export interface LintedSource {
|
|
40
|
+
/**
|
|
41
|
+
* The buffer's Liquid tree, exactly as check-node captured it inside the overlay — so it
|
|
42
|
+
* describes the text the offenses describe. Absent for GraphQL, YAML and assets, and for
|
|
43
|
+
* a buffer that did not parse.
|
|
44
|
+
*/
|
|
45
|
+
ast?: LiquidHtmlNode;
|
|
46
|
+
/** 0-based offense start offsets, index-aligned with this file's diagnostics. */
|
|
47
|
+
startIndexes: number[];
|
|
48
|
+
}
|
|
49
|
+
/** One buffer in a batch request, as the caller supplied it. */
|
|
50
|
+
export interface BatchBuffer {
|
|
51
|
+
/** File under edit — absolute, or relative to the project root. */
|
|
52
|
+
filePath: string;
|
|
53
|
+
/** In-memory buffer contents. */
|
|
54
|
+
content: string;
|
|
55
|
+
}
|
|
56
|
+
/** What one lint pass found, and which requested buffers it did not check — and why. */
|
|
57
|
+
export interface BatchLintResult {
|
|
58
|
+
/**
|
|
59
|
+
* Diagnostics per caller key. An empty array means checked and clean.
|
|
60
|
+
*
|
|
61
|
+
* A key appears in EXACTLY ONE of this and {@link notChecked} — or, if the engine
|
|
62
|
+
* returned nothing for it at all, in neither, which the orchestrator's fail safe turns
|
|
63
|
+
* into `internal_error` rather than a clean pass.
|
|
64
|
+
*/
|
|
65
|
+
diagnostics: Map<string, ValidateCodeDiagnostic[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Per file, the material ENRICHMENT needs and the agent surface deliberately does not
|
|
68
|
+
* carry: the buffer's parsed tree, and where in the buffer each diagnostic sits.
|
|
69
|
+
*
|
|
70
|
+
* OPTIONAL for the benefit of test stubs, which have no tree to offer; enrichment
|
|
71
|
+
* degrades to "no symbol hint" without it and still attaches each check's documentation
|
|
72
|
+
* URL. The REAL adapter always sets it, for every key it sets in `diagnostics` —
|
|
73
|
+
* `lint-batch.spec.ts` asserts that, so the leniency here cannot become leniency there.
|
|
74
|
+
*/
|
|
75
|
+
sources?: Map<string, LintedSource>;
|
|
76
|
+
/**
|
|
77
|
+
* Caller keys the lint did NOT check, each with check-node's own reason for it. The
|
|
78
|
+
* statuses carry genuinely different remedies, so they are kept distinct rather than
|
|
79
|
+
* flattened into one "ignored" bucket.
|
|
80
|
+
*
|
|
81
|
+
* Statuses, not prose and not agent-facing codes: translating one into what an agent
|
|
82
|
+
* reads belongs where every other refusal message lives.
|
|
83
|
+
*/
|
|
84
|
+
notChecked: Map<string, LintNotCheckedStatus>;
|
|
85
|
+
}
|
|
86
|
+
export interface BatchLintInput {
|
|
87
|
+
/** Absolute project root the buffers are validated against. */
|
|
88
|
+
projectDir: string;
|
|
89
|
+
buffers: BatchBuffer[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Lint every buffer in one pass, returning diagnostics — and the buffers nothing looked
|
|
93
|
+
* at — keyed by the caller's ORIGINAL `filePath` string.
|
|
94
|
+
*
|
|
95
|
+
* Keyed by the caller's own key on purpose: the caller may pass a relative path, an
|
|
96
|
+
* absolute one, or a mix, and it must be able to find its results without
|
|
97
|
+
* reconstructing our normalization. `lintBuffers` keys by normalized URI, so the
|
|
98
|
+
* mapping back happens here, where both forms are known.
|
|
99
|
+
*/
|
|
100
|
+
export declare function runBatchLint(input: BatchLintInput): Promise<BatchLintResult>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE lint adapter, over check-node's `lintBuffers` seam. There is no single-buffer
|
|
3
|
+
* counterpart: the orchestrator always works on a list, so one file is a batch of one.
|
|
4
|
+
*
|
|
5
|
+
* Everything expensive in a lint is per-PROJECT, not per-buffer — resolving the config,
|
|
6
|
+
* walking and reconciling the app, reconciling the route table — so linting N files one
|
|
7
|
+
* call at a time re-discovers the same unchanged project N times.
|
|
8
|
+
*
|
|
9
|
+
* And it is more CORRECT, which matters more: with every buffer overlaid at once — in the
|
|
10
|
+
* `App` and in the filesystem view reference checks resolve through — a partial introduced
|
|
11
|
+
* in one buffer resolves for a `render` in another. File-by-file linting reports
|
|
12
|
+
* `MissingPartial` for a file present in the very same request.
|
|
13
|
+
*/
|
|
14
|
+
import { lintBuffers, Severity, } from '@platformos/platformos-check-node';
|
|
15
|
+
// The SAME conversion `lintBuffers` keys its result map with, imported from the package
|
|
16
|
+
// that owns it rather than respelled through check-common's equivalent `path.toUri`: a
|
|
17
|
+
// spelling that disagreed would surface as a map miss on Windows only.
|
|
18
|
+
import { uriFromPath } from '@platformos/platformos-common';
|
|
19
|
+
import { toAbsoluteFilePath } from '../adapter-input.js';
|
|
20
|
+
import { toAgentFixes } from './fixes.js';
|
|
21
|
+
const SEVERITY = {
|
|
22
|
+
[Severity.ERROR]: 'error',
|
|
23
|
+
[Severity.WARNING]: 'warning',
|
|
24
|
+
[Severity.INFO]: 'info',
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Lint every buffer in one pass, returning diagnostics — and the buffers nothing looked
|
|
28
|
+
* at — keyed by the caller's ORIGINAL `filePath` string.
|
|
29
|
+
*
|
|
30
|
+
* Keyed by the caller's own key on purpose: the caller may pass a relative path, an
|
|
31
|
+
* absolute one, or a mix, and it must be able to find its results without
|
|
32
|
+
* reconstructing our normalization. `lintBuffers` keys by normalized URI, so the
|
|
33
|
+
* mapping back happens here, where both forms are known.
|
|
34
|
+
*/
|
|
35
|
+
export async function runBatchLint(input) {
|
|
36
|
+
const { projectDir, buffers } = input;
|
|
37
|
+
const diagnostics = new Map();
|
|
38
|
+
const sources = new Map();
|
|
39
|
+
const notChecked = new Map();
|
|
40
|
+
if (buffers.length === 0)
|
|
41
|
+
return { diagnostics, sources, notChecked };
|
|
42
|
+
const absoluteByKey = new Map();
|
|
43
|
+
for (const buffer of buffers) {
|
|
44
|
+
absoluteByKey.set(buffer.filePath, toAbsoluteFilePath(projectDir, buffer.filePath));
|
|
45
|
+
}
|
|
46
|
+
const results = await lintBuffers({
|
|
47
|
+
root: projectDir,
|
|
48
|
+
buffers: buffers.map((buffer) => ({
|
|
49
|
+
filePath: absoluteByKey.get(buffer.filePath),
|
|
50
|
+
content: buffer.content,
|
|
51
|
+
})),
|
|
52
|
+
});
|
|
53
|
+
// Re-key by the caller's string. `lintBuffers` keys by normalized URI, so match on the
|
|
54
|
+
// same conversion rather than string-comparing paths.
|
|
55
|
+
for (const [key, absolute] of absoluteByKey) {
|
|
56
|
+
const outcome = results.get(uriFromPath(absolute));
|
|
57
|
+
// A MISS SETS NOTHING, and must not: defaulting to `[]` reports the file CLEAN.
|
|
58
|
+
// Leaving the key absent reaches the orchestrator's fail safe, which answers
|
|
59
|
+
// `internal_error` — the only honest thing to say about a lookup that cannot fail.
|
|
60
|
+
if (outcome === undefined)
|
|
61
|
+
continue;
|
|
62
|
+
if (outcome.status !== 'checked') {
|
|
63
|
+
notChecked.set(key, outcome.status);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// ONE pass produces both, which is what keeps `startIndexes` aligned with
|
|
67
|
+
// `diagnostics`. Splitting this into two loops is how that invariant would break.
|
|
68
|
+
diagnostics.set(key, outcome.offenses.map((offense, index) => toDiagnostic(offense, outcome.fixes[index])));
|
|
69
|
+
sources.set(key, {
|
|
70
|
+
ast: outcome.ast,
|
|
71
|
+
startIndexes: outcome.offenses.map((offense) => offense.start.index),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return { diagnostics, sources, notChecked };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Map a check-common `Offense` to a `ValidateCodeDiagnostic`.
|
|
78
|
+
*
|
|
79
|
+
* check-common positions are 0-based for BOTH line and character; the agent surface uses
|
|
80
|
+
* 1-based line + column, so both get `+ 1`. The ONLY place the conversion happens.
|
|
81
|
+
*
|
|
82
|
+
* TWO COORDINATE SYSTEMS LIVE ON THE RESULT and only one is converted: the edits attached
|
|
83
|
+
* by {@link toAgentFixes} keep the engine's 0-based buffer OFFSETS, because that is what
|
|
84
|
+
* applying an edit requires. Converting those too would corrupt a file.
|
|
85
|
+
*/
|
|
86
|
+
function toDiagnostic(offense, fixes) {
|
|
87
|
+
return {
|
|
88
|
+
check: offense.check,
|
|
89
|
+
severity: SEVERITY[offense.severity],
|
|
90
|
+
message: offense.message,
|
|
91
|
+
line: offense.start.line + 1,
|
|
92
|
+
column: offense.start.character + 1,
|
|
93
|
+
end_line: offense.end.line + 1,
|
|
94
|
+
end_column: offense.end.character + 1,
|
|
95
|
+
...toAgentFixes(fixes),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=lint-batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|