@stigmer/plugin-package 0.1.0-dev.20261017020314.g644422724c27
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/LICENSE +194 -0
- package/README.md +72 -0
- package/client/archive.d.ts +27 -0
- package/client/archive.d.ts.map +1 -0
- package/client/archive.js +38 -0
- package/client/archive.js.map +1 -0
- package/client/builtin.d.ts +37 -0
- package/client/builtin.d.ts.map +1 -0
- package/client/builtin.js +49 -0
- package/client/builtin.js.map +1 -0
- package/client/ignore/defaults.d.ts +2 -0
- package/client/ignore/defaults.d.ts.map +1 -0
- package/client/ignore/defaults.js +140 -0
- package/client/ignore/defaults.js.map +1 -0
- package/client/ignore/match.d.ts +3 -0
- package/client/ignore/match.d.ts.map +1 -0
- package/client/ignore/match.js +166 -0
- package/client/ignore/match.js.map +1 -0
- package/client/ignore/matcher.d.ts +50 -0
- package/client/ignore/matcher.d.ts.map +1 -0
- package/client/ignore/matcher.js +116 -0
- package/client/ignore/matcher.js.map +1 -0
- package/client/ignore/pattern.d.ts +13 -0
- package/client/ignore/pattern.d.ts.map +1 -0
- package/client/ignore/pattern.js +119 -0
- package/client/ignore/pattern.js.map +1 -0
- package/client/prepare-eval.d.ts +62 -0
- package/client/prepare-eval.d.ts.map +1 -0
- package/client/prepare-eval.js +60 -0
- package/client/prepare-eval.js.map +1 -0
- package/client/prepare.d.ts +99 -0
- package/client/prepare.d.ts.map +1 -0
- package/client/prepare.js +89 -0
- package/client/prepare.js.map +1 -0
- package/client/presentation.d.ts +19 -0
- package/client/presentation.d.ts.map +1 -0
- package/client/presentation.js +44 -0
- package/client/presentation.js.map +1 -0
- package/client/refs.d.ts +76 -0
- package/client/refs.d.ts.map +1 -0
- package/client/refs.js +123 -0
- package/client/refs.js.map +1 -0
- package/client/release.d.ts +20 -0
- package/client/release.d.ts.map +1 -0
- package/client/release.js +28 -0
- package/client/release.js.map +1 -0
- package/client/reroot.d.ts +21 -0
- package/client/reroot.d.ts.map +1 -0
- package/client/reroot.js +37 -0
- package/client/reroot.js.map +1 -0
- package/client/select.d.ts +74 -0
- package/client/select.d.ts.map +1 -0
- package/client/select.js +121 -0
- package/client/select.js.map +1 -0
- package/client/vocabulary.d.ts +13 -0
- package/client/vocabulary.d.ts.map +1 -0
- package/client/vocabulary.js +17 -0
- package/client/vocabulary.js.map +1 -0
- package/client.d.ts +51 -0
- package/client.d.ts.map +1 -0
- package/client.js +51 -0
- package/client.js.map +1 -0
- package/detect.d.ts +83 -0
- package/detect.d.ts.map +1 -0
- package/detect.js +210 -0
- package/detect.js.map +1 -0
- package/dialects/claude.d.ts +34 -0
- package/dialects/claude.d.ts.map +1 -0
- package/dialects/claude.js +84 -0
- package/dialects/claude.js.map +1 -0
- package/dialects/codex.d.ts +20 -0
- package/dialects/codex.d.ts.map +1 -0
- package/dialects/codex.js +21 -0
- package/dialects/codex.js.map +1 -0
- package/dialects/cursor.d.ts +25 -0
- package/dialects/cursor.d.ts.map +1 -0
- package/dialects/cursor.js +66 -0
- package/dialects/cursor.js.map +1 -0
- package/dialects/manifest.d.ts +164 -0
- package/dialects/manifest.d.ts.map +1 -0
- package/dialects/manifest.js +256 -0
- package/dialects/manifest.js.map +1 -0
- package/dialects/open.d.ts +19 -0
- package/dialects/open.d.ts.map +1 -0
- package/dialects/open.js +49 -0
- package/dialects/open.js.map +1 -0
- package/documents.d.ts +58 -0
- package/documents.d.ts.map +1 -0
- package/documents.js +121 -0
- package/documents.js.map +1 -0
- package/evals/eval-dir.d.ts +59 -0
- package/evals/eval-dir.d.ts.map +1 -0
- package/evals/eval-dir.js +84 -0
- package/evals/eval-dir.js.map +1 -0
- package/evals/fields.d.ts +78 -0
- package/evals/fields.d.ts.map +1 -0
- package/evals/fields.js +156 -0
- package/evals/fields.js.map +1 -0
- package/evals/glob.d.ts +40 -0
- package/evals/glob.d.ts.map +1 -0
- package/evals/glob.js +146 -0
- package/evals/glob.js.map +1 -0
- package/evals/graders.d.ts +52 -0
- package/evals/graders.d.ts.map +1 -0
- package/evals/graders.js +279 -0
- package/evals/graders.js.map +1 -0
- package/evals/markdown.d.ts +24 -0
- package/evals/markdown.d.ts.map +1 -0
- package/evals/markdown.js +48 -0
- package/evals/markdown.js.map +1 -0
- package/evals/mocks.d.ts +50 -0
- package/evals/mocks.d.ts.map +1 -0
- package/evals/mocks.js +182 -0
- package/evals/mocks.js.map +1 -0
- package/evals/read-eval-suite.d.ts +110 -0
- package/evals/read-eval-suite.d.ts.map +1 -0
- package/evals/read-eval-suite.js +603 -0
- package/evals/read-eval-suite.js.map +1 -0
- package/evals/summary.d.ts +61 -0
- package/evals/summary.d.ts.map +1 -0
- package/evals/summary.js +69 -0
- package/evals/summary.js.map +1 -0
- package/evals/types.d.ts +203 -0
- package/evals/types.d.ts.map +1 -0
- package/evals/types.js +21 -0
- package/evals/types.js.map +1 -0
- package/files.d.ts +135 -0
- package/files.d.ts.map +1 -0
- package/files.js +209 -0
- package/files.js.map +1 -0
- package/frontmatter.d.ts +51 -0
- package/frontmatter.d.ts.map +1 -0
- package/frontmatter.js +61 -0
- package/frontmatter.js.map +1 -0
- package/index.d.ts +37 -0
- package/index.d.ts.map +1 -0
- package/index.js +33 -0
- package/index.js.map +1 -0
- package/marketplace/messages.d.ts +20 -0
- package/marketplace/messages.d.ts.map +1 -0
- package/marketplace/messages.js +49 -0
- package/marketplace/messages.js.map +1 -0
- package/marketplace/outcome.d.ts +70 -0
- package/marketplace/outcome.d.ts.map +1 -0
- package/marketplace/outcome.js +29 -0
- package/marketplace/outcome.js.map +1 -0
- package/marketplace/read-marketplace.d.ts +52 -0
- package/marketplace/read-marketplace.d.ts.map +1 -0
- package/marketplace/read-marketplace.js +351 -0
- package/marketplace/read-marketplace.js.map +1 -0
- package/messages.d.ts +55 -0
- package/messages.d.ts.map +1 -0
- package/messages.js +167 -0
- package/messages.js.map +1 -0
- package/normalise/hooks.d.ts +91 -0
- package/normalise/hooks.d.ts.map +1 -0
- package/normalise/hooks.js +437 -0
- package/normalise/hooks.js.map +1 -0
- package/normalise/ignored.d.ts +34 -0
- package/normalise/ignored.d.ts.map +1 -0
- package/normalise/ignored.js +78 -0
- package/normalise/ignored.js.map +1 -0
- package/normalise/mcp-servers.d.ts +50 -0
- package/normalise/mcp-servers.d.ts.map +1 -0
- package/normalise/mcp-servers.js +398 -0
- package/normalise/mcp-servers.js.map +1 -0
- package/normalise/settings.d.ts +32 -0
- package/normalise/settings.d.ts.map +1 -0
- package/normalise/settings.js +72 -0
- package/normalise/settings.js.map +1 -0
- package/normalise/skills.d.ts +39 -0
- package/normalise/skills.d.ts.map +1 -0
- package/normalise/skills.js +135 -0
- package/normalise/skills.js.map +1 -0
- package/normalise/stigmer-folder.d.ts +17 -0
- package/normalise/stigmer-folder.d.ts.map +1 -0
- package/normalise/stigmer-folder.js +19 -0
- package/normalise/stigmer-folder.js.map +1 -0
- package/normalise/sub-agents.d.ts +54 -0
- package/normalise/sub-agents.d.ts.map +1 -0
- package/normalise/sub-agents.js +219 -0
- package/normalise/sub-agents.js.map +1 -0
- package/normalise/variables.d.ts +31 -0
- package/normalise/variables.d.ts.map +1 -0
- package/normalise/variables.js +170 -0
- package/normalise/variables.js.map +1 -0
- package/outcome.d.ts +59 -0
- package/outcome.d.ts.map +1 -0
- package/outcome.js +32 -0
- package/outcome.js.map +1 -0
- package/package.json +47 -0
- package/placeholders.d.ts +65 -0
- package/placeholders.d.ts.map +1 -0
- package/placeholders.js +99 -0
- package/placeholders.js.map +1 -0
- package/presentation.d.ts +53 -0
- package/presentation.d.ts.map +1 -0
- package/presentation.js +156 -0
- package/presentation.js.map +1 -0
- package/read-plugin-package.d.ts +20 -0
- package/read-plugin-package.d.ts.map +1 -0
- package/read-plugin-package.js +73 -0
- package/read-plugin-package.js.map +1 -0
- package/src/client/archive.ts +44 -0
- package/src/client/builtin.ts +60 -0
- package/src/client/ignore/defaults.ts +155 -0
- package/src/client/ignore/match.ts +158 -0
- package/src/client/ignore/matcher.ts +156 -0
- package/src/client/ignore/pattern.ts +132 -0
- package/src/client/prepare-eval.ts +92 -0
- package/src/client/prepare.ts +160 -0
- package/src/client/presentation.ts +47 -0
- package/src/client/refs.ts +170 -0
- package/src/client/release.ts +29 -0
- package/src/client/reroot.ts +35 -0
- package/src/client/select.ts +161 -0
- package/src/client/vocabulary.ts +19 -0
- package/src/client.ts +102 -0
- package/src/detect.ts +245 -0
- package/src/dialects/claude.ts +102 -0
- package/src/dialects/codex.ts +26 -0
- package/src/dialects/cursor.ts +77 -0
- package/src/dialects/manifest.ts +316 -0
- package/src/dialects/open.ts +50 -0
- package/src/documents.ts +158 -0
- package/src/evals/eval-dir.ts +101 -0
- package/src/evals/fields.ts +184 -0
- package/src/evals/glob.ts +141 -0
- package/src/evals/graders.ts +293 -0
- package/src/evals/markdown.ts +56 -0
- package/src/evals/mocks.ts +202 -0
- package/src/evals/read-eval-suite.ts +713 -0
- package/src/evals/summary.ts +100 -0
- package/src/evals/types.ts +217 -0
- package/src/files.ts +235 -0
- package/src/frontmatter.ts +70 -0
- package/src/index.ts +129 -0
- package/src/marketplace/messages.ts +61 -0
- package/src/marketplace/outcome.ts +91 -0
- package/src/marketplace/read-marketplace.ts +388 -0
- package/src/messages.ts +248 -0
- package/src/normalise/hooks.ts +469 -0
- package/src/normalise/ignored.ts +79 -0
- package/src/normalise/mcp-servers.ts +423 -0
- package/src/normalise/settings.ts +81 -0
- package/src/normalise/skills.ts +145 -0
- package/src/normalise/stigmer-folder.ts +23 -0
- package/src/normalise/sub-agents.ts +231 -0
- package/src/normalise/variables.ts +181 -0
- package/src/outcome.ts +158 -0
- package/src/placeholders.ts +110 -0
- package/src/presentation.ts +170 -0
- package/src/read-plugin-package.ts +80 -0
- package/src/testing.ts +347 -0
- package/src/tool-names.ts +30 -0
- package/src/trim.ts +10 -0
- package/src/types.ts +214 -0
- package/testing.d.ts +127 -0
- package/testing.d.ts.map +1 -0
- package/testing.js +266 -0
- package/testing.js.map +1 -0
- package/tool-names.d.ts +21 -0
- package/tool-names.d.ts.map +1 -0
- package/tool-names.js +28 -0
- package/tool-names.js.map +1 -0
- package/trim.d.ts +7 -0
- package/trim.d.ts.map +1 -0
- package/trim.js +12 -0
- package/trim.js.map +1 -0
- package/types.d.ts +179 -0
- package/types.d.ts.map +1 -0
- package/types.js +19 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A case's MCP mocks, in the plugin-eval format's layout: the suite's
|
|
3
|
+
* `<suite>/mocks/<server>/` and the case's own `<case>/mocks/<server>/`,
|
|
4
|
+
* merged file by file with the case's file winning, so a case overrides
|
|
5
|
+
* one tool and keeps the suite's others.
|
|
6
|
+
*
|
|
7
|
+
* In a server's directory:
|
|
8
|
+
* - `<tool>.md`: one tool. Frontmatter `type` (`fixed`, the default, or
|
|
9
|
+
* `agent`), `expect`, `error` (`fixed` only) and `abort_when` (`agent`
|
|
10
|
+
* only); the body answers.
|
|
11
|
+
* - `_server.md`: one `agent` mock for the tools its `tools:` key lists; a
|
|
12
|
+
* `<tool>.md` for the same tool takes precedence. Its `expect:` is
|
|
13
|
+
* accepted only when `tools:` lists one tool.
|
|
14
|
+
* - `_tools.json`: the real server's saved `tools/list`, recorded by path
|
|
15
|
+
* for the runner to offer real descriptions and schemas.
|
|
16
|
+
* - `fixtures/`: files a body inserts; the runner resolves them, case
|
|
17
|
+
* directory first.
|
|
18
|
+
* `mocks/.replay/` holds adopted agent-mock recordings, which Stigmer does
|
|
19
|
+
* not read; the case only notes that it has them.
|
|
20
|
+
*
|
|
21
|
+
* A file that breaks these rules (an unknown key, a wrong type, an `expect`
|
|
22
|
+
* pattern outside the dialect) is an `eval-mock-invalid` finding of the
|
|
23
|
+
* case, which then does not load, as Claude Code stops such a case. Which
|
|
24
|
+
* servers a suite may mock is its reader's rule ({@link MockServerRule}): a
|
|
25
|
+
* plugin's suite mocks only the servers the plugin declares, a pushed
|
|
26
|
+
* folder any server whose name could be one. A directory the rule refuses
|
|
27
|
+
* is a finding of the suite and is ignored: no try could reach that server.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { compileExpect } from "@stigmer/eval-runtime";
|
|
31
|
+
import { isJsonObject, type JsonObject } from "../documents.js";
|
|
32
|
+
import { comparePaths, joinPath, type PluginFileIndex } from "../files.js";
|
|
33
|
+
import { type CaseFindings, type FieldScope, readNonEmptyString, readStringList, unknownKeys, wrong } from "./fields.js";
|
|
34
|
+
import { readMarkdown } from "./markdown.js";
|
|
35
|
+
import type { EvalMockServer, EvalMockTool, EvalSuiteFinding } from "./types.js";
|
|
36
|
+
|
|
37
|
+
/** The directory under the suite or a case that holds mocks. */
|
|
38
|
+
export const MOCKS_DIR = "mocks";
|
|
39
|
+
|
|
40
|
+
/** Adopted agent-mock recordings, under a mocks directory. */
|
|
41
|
+
const REPLAY_DIR = ".replay";
|
|
42
|
+
|
|
43
|
+
const SERVER_FILE = "_server.md";
|
|
44
|
+
const TOOLS_FILE = "_tools.json";
|
|
45
|
+
|
|
46
|
+
const TOOL_KEYS: ReadonlySet<string> = new Set(["type", "expect", "error", "abort_when"]);
|
|
47
|
+
const SERVER_KEYS: ReadonlySet<string> = new Set(["type", "tools", "expect", "abort_when"]);
|
|
48
|
+
|
|
49
|
+
/** What a case's mocks read to: the servers, and whether replays exist. */
|
|
50
|
+
export interface CaseMocks {
|
|
51
|
+
readonly servers: readonly EvalMockServer[];
|
|
52
|
+
readonly replays: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether a suite may mock the server a mock directory names: `undefined`
|
|
57
|
+
* keeps the directory, a sentence says why it is ignored.
|
|
58
|
+
*/
|
|
59
|
+
export type MockServerRule = (server: string) => string | undefined;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Read the mocks one case sees. A mock directory `rule` refuses adds a
|
|
63
|
+
* finding to `suiteFindings` (once per directory: `reported` remembers the
|
|
64
|
+
* suite's) and is skipped.
|
|
65
|
+
*/
|
|
66
|
+
export function readCaseMocks(
|
|
67
|
+
index: PluginFileIndex,
|
|
68
|
+
suiteDir: string,
|
|
69
|
+
caseDir: string,
|
|
70
|
+
rule: MockServerRule,
|
|
71
|
+
findings: CaseFindings,
|
|
72
|
+
suiteFindings: EvalSuiteFinding[],
|
|
73
|
+
reported: Set<string>,
|
|
74
|
+
): CaseMocks {
|
|
75
|
+
const suiteMocks = joinPath(suiteDir, MOCKS_DIR);
|
|
76
|
+
const caseMocks = `${caseDir}/${MOCKS_DIR}`;
|
|
77
|
+
const replays = index.isDirectory(`${suiteMocks}/${REPLAY_DIR}`) || index.isDirectory(`${caseMocks}/${REPLAY_DIR}`);
|
|
78
|
+
const names = new Set([...index.childDirectories(suiteMocks), ...index.childDirectories(caseMocks)]);
|
|
79
|
+
names.delete(REPLAY_DIR);
|
|
80
|
+
const servers: EvalMockServer[] = [];
|
|
81
|
+
for (const server of [...names].sort(comparePaths)) {
|
|
82
|
+
const problem = rule(server);
|
|
83
|
+
if (problem !== undefined) {
|
|
84
|
+
for (const dir of [`${suiteMocks}/${server}`, `${caseMocks}/${server}`]) {
|
|
85
|
+
if (!index.isDirectory(dir) || reported.has(dir)) continue;
|
|
86
|
+
reported.add(dir);
|
|
87
|
+
suiteFindings.push({ kind: "eval-mock-invalid", path: dir, message: `${dir}: ${problem}` });
|
|
88
|
+
}
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const read = readServer(index, `${suiteMocks}/${server}`, `${caseMocks}/${server}`, server, findings);
|
|
92
|
+
if (read !== undefined) servers.push(read);
|
|
93
|
+
}
|
|
94
|
+
return { servers, replays };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** One server's mocks, the case's files over the suite's. */
|
|
98
|
+
function readServer(
|
|
99
|
+
index: PluginFileIndex,
|
|
100
|
+
suiteDir: string,
|
|
101
|
+
caseDir: string,
|
|
102
|
+
server: string,
|
|
103
|
+
findings: CaseFindings,
|
|
104
|
+
): EvalMockServer | undefined {
|
|
105
|
+
const files = new Map<string, string>();
|
|
106
|
+
for (const dir of [suiteDir, caseDir]) {
|
|
107
|
+
for (const file of index.childFiles(dir)) files.set(file, `${dir}/${file}`);
|
|
108
|
+
}
|
|
109
|
+
const tools = new Map<string, EvalMockTool>();
|
|
110
|
+
for (const [file, path] of [...files].sort(([a], [b]) => comparePaths(a, b))) {
|
|
111
|
+
if (!file.endsWith(".md") || file.startsWith("_")) continue;
|
|
112
|
+
const tool = readToolMock(index, path, file.slice(0, -".md".length), findings);
|
|
113
|
+
if (tool !== undefined) tools.set(tool.tool, tool);
|
|
114
|
+
}
|
|
115
|
+
const serverPath = files.get(SERVER_FILE);
|
|
116
|
+
if (serverPath !== undefined) {
|
|
117
|
+
for (const tool of readServerMock(index, serverPath, findings)) {
|
|
118
|
+
if (!tools.has(tool.tool)) tools.set(tool.tool, tool);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const toolsFile = files.get(TOOLS_FILE);
|
|
122
|
+
return {
|
|
123
|
+
server,
|
|
124
|
+
tools: [...tools.values()].sort((a, b) => comparePaths(a.tool, b.tool)),
|
|
125
|
+
...(toolsFile !== undefined && { toolsFile }),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function scopeOf(path: string, findings: CaseFindings): FieldScope {
|
|
130
|
+
return { path, label: "", invalid: "eval-mock-invalid", findings };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function readToolMock(index: PluginFileIndex, path: string, tool: string, findings: CaseFindings): EvalMockTool | undefined {
|
|
134
|
+
const scope = scopeOf(path, findings);
|
|
135
|
+
const document = readMarkdown(index, scope);
|
|
136
|
+
if (document === undefined) return undefined;
|
|
137
|
+
const { fields } = document;
|
|
138
|
+
unknownKeys(fields, TOOL_KEYS, scope, "eval-mock-invalid", "frontmatter key");
|
|
139
|
+
const kind = readKind(fields["type"], scope);
|
|
140
|
+
const error = fields["error"];
|
|
141
|
+
if (error !== undefined && typeof error !== "boolean") wrong(scope, "error", "true or false");
|
|
142
|
+
if (error === true && kind === "agent") wrong(scope, "error", "unset on an agent mock (it applies to fixed mocks)");
|
|
143
|
+
const abortWhen = readNonEmptyString(fields, "abort_when", scope);
|
|
144
|
+
if (abortWhen !== undefined && kind === "fixed") wrong(scope, "abort_when", "unset on a fixed mock (it applies to agent mocks)");
|
|
145
|
+
const expect = readExpect(fields["expect"], scope);
|
|
146
|
+
if (kind === undefined) return undefined;
|
|
147
|
+
return {
|
|
148
|
+
tool,
|
|
149
|
+
file: path,
|
|
150
|
+
kind,
|
|
151
|
+
error: error === true,
|
|
152
|
+
...(expect !== undefined && { expect }),
|
|
153
|
+
...(abortWhen !== undefined && { abortWhen }),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** `_server.md`'s tools, each answered by it as an agent. */
|
|
158
|
+
function readServerMock(index: PluginFileIndex, path: string, findings: CaseFindings): readonly EvalMockTool[] {
|
|
159
|
+
const scope = scopeOf(path, findings);
|
|
160
|
+
const document = readMarkdown(index, scope);
|
|
161
|
+
if (document === undefined) return [];
|
|
162
|
+
const { fields } = document;
|
|
163
|
+
unknownKeys(fields, SERVER_KEYS, scope, "eval-mock-invalid", "frontmatter key");
|
|
164
|
+
const kind = readKind(fields["type"] ?? "agent", scope);
|
|
165
|
+
if (kind === "fixed") wrong(scope, "type", "agent (a _server.md answers as an agent)");
|
|
166
|
+
const tools = readStringList(fields, "tools", scope);
|
|
167
|
+
if (tools === undefined || tools.length === 0) {
|
|
168
|
+
if (fields["tools"] === undefined || tools !== undefined) wrong(scope, "tools", "a list of the tools it answers");
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
const expect = readExpect(fields["expect"], scope);
|
|
172
|
+
if (expect !== undefined && tools.length !== 1) {
|
|
173
|
+
wrong(scope, "expect", "on a tool's own <tool>.md when tools lists more than one tool");
|
|
174
|
+
}
|
|
175
|
+
const abortWhen = readNonEmptyString(fields, "abort_when", scope);
|
|
176
|
+
return tools.map((tool) => ({
|
|
177
|
+
tool,
|
|
178
|
+
file: path,
|
|
179
|
+
kind: "agent" as const,
|
|
180
|
+
error: false,
|
|
181
|
+
...(expect !== undefined && tools.length === 1 && { expect }),
|
|
182
|
+
...(abortWhen !== undefined && { abortWhen }),
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function readKind(value: unknown, scope: FieldScope): "fixed" | "agent" | undefined {
|
|
187
|
+
if (value === undefined || value === "fixed") return "fixed";
|
|
188
|
+
if (value === "agent") return "agent";
|
|
189
|
+
return wrong(scope, "type", "fixed or agent");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** An `expect:` block, compiled once so a pattern outside the dialect stops the case here. */
|
|
193
|
+
function readExpect(value: unknown, scope: FieldScope): JsonObject | undefined {
|
|
194
|
+
if (value === undefined) return undefined;
|
|
195
|
+
if (!isJsonObject(value)) return wrong(scope, "expect", "a map from input paths to rules");
|
|
196
|
+
const compiled = compileExpect(value);
|
|
197
|
+
if (!compiled.ok) {
|
|
198
|
+
scope.findings.add(scope.invalid, scope.path, compiled.error);
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
return value;
|
|
202
|
+
}
|