agentfootprint 6.23.0 → 6.25.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 +31 -0
- package/bin/agentfootprint-lint-tools.mjs +14 -0
- package/dist/esm/lib/influence-core/cache.js +149 -0
- package/dist/esm/lib/influence-core/cache.js.map +1 -0
- package/dist/esm/lib/influence-core/index.js +32 -0
- package/dist/esm/lib/influence-core/index.js.map +1 -0
- package/dist/esm/lib/influence-core/margin.js +110 -0
- package/dist/esm/lib/influence-core/margin.js.map +1 -0
- package/dist/esm/lib/influence-core/signals.js +232 -0
- package/dist/esm/lib/influence-core/signals.js.map +1 -0
- package/dist/esm/lib/influence-core/similarity.js +79 -0
- package/dist/esm/lib/influence-core/similarity.js.map +1 -0
- package/dist/esm/lib/influence-core/types.js +35 -0
- package/dist/esm/lib/influence-core/types.js.map +1 -0
- package/dist/esm/lib/tool-lint/analyze.js +235 -0
- package/dist/esm/lib/tool-lint/analyze.js.map +1 -0
- package/dist/esm/lib/tool-lint/cli.js +198 -0
- package/dist/esm/lib/tool-lint/cli.js.map +1 -0
- package/dist/esm/lib/tool-lint/format.js +61 -0
- package/dist/esm/lib/tool-lint/format.js.map +1 -0
- package/dist/esm/lib/tool-lint/index.js +23 -0
- package/dist/esm/lib/tool-lint/index.js.map +1 -0
- package/dist/esm/lib/tool-lint/rules.js +249 -0
- package/dist/esm/lib/tool-lint/rules.js.map +1 -0
- package/dist/esm/lib/tool-lint/types.js +25 -0
- package/dist/esm/lib/tool-lint/types.js.map +1 -0
- package/dist/esm/lib/trace-toolpack/bounded.js +76 -0
- package/dist/esm/lib/trace-toolpack/bounded.js.map +1 -0
- package/dist/esm/lib/trace-toolpack/index.js +10 -0
- package/dist/esm/lib/trace-toolpack/index.js.map +1 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.js +699 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -0
- package/dist/esm/lib/trace-toolpack/types.js +24 -0
- package/dist/esm/lib/trace-toolpack/types.js.map +1 -0
- package/dist/esm/observe.js +25 -0
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/recorders/observability/ToolChoiceRecorder.js +261 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.js.map +1 -0
- package/dist/lib/influence-core/cache.js +155 -0
- package/dist/lib/influence-core/cache.js.map +1 -0
- package/dist/lib/influence-core/index.js +50 -0
- package/dist/lib/influence-core/index.js.map +1 -0
- package/dist/lib/influence-core/margin.js +114 -0
- package/dist/lib/influence-core/margin.js.map +1 -0
- package/dist/lib/influence-core/signals.js +242 -0
- package/dist/lib/influence-core/signals.js.map +1 -0
- package/dist/lib/influence-core/similarity.js +83 -0
- package/dist/lib/influence-core/similarity.js.map +1 -0
- package/dist/lib/influence-core/types.js +38 -0
- package/dist/lib/influence-core/types.js.map +1 -0
- package/dist/lib/tool-lint/analyze.js +242 -0
- package/dist/lib/tool-lint/analyze.js.map +1 -0
- package/dist/lib/tool-lint/cli.js +203 -0
- package/dist/lib/tool-lint/cli.js.map +1 -0
- package/dist/lib/tool-lint/format.js +65 -0
- package/dist/lib/tool-lint/format.js.map +1 -0
- package/dist/lib/tool-lint/index.js +43 -0
- package/dist/lib/tool-lint/index.js.map +1 -0
- package/dist/lib/tool-lint/rules.js +256 -0
- package/dist/lib/tool-lint/rules.js.map +1 -0
- package/dist/lib/tool-lint/types.js +26 -0
- package/dist/lib/tool-lint/types.js.map +1 -0
- package/dist/lib/trace-toolpack/bounded.js +86 -0
- package/dist/lib/trace-toolpack/bounded.js.map +1 -0
- package/dist/lib/trace-toolpack/index.js +16 -0
- package/dist/lib/trace-toolpack/index.js.map +1 -0
- package/dist/lib/trace-toolpack/traceToolpack.js +704 -0
- package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -0
- package/dist/lib/trace-toolpack/types.js +28 -0
- package/dist/lib/trace-toolpack/types.js.map +1 -0
- package/dist/observe.js +64 -1
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/ToolChoiceRecorder.js +266 -0
- package/dist/recorders/observability/ToolChoiceRecorder.js.map +1 -0
- package/dist/types/lib/influence-core/cache.d.ts +95 -0
- package/dist/types/lib/influence-core/cache.d.ts.map +1 -0
- package/dist/types/lib/influence-core/index.d.ts +33 -0
- package/dist/types/lib/influence-core/index.d.ts.map +1 -0
- package/dist/types/lib/influence-core/margin.d.ts +34 -0
- package/dist/types/lib/influence-core/margin.d.ts.map +1 -0
- package/dist/types/lib/influence-core/signals.d.ts +104 -0
- package/dist/types/lib/influence-core/signals.d.ts.map +1 -0
- package/dist/types/lib/influence-core/similarity.d.ts +26 -0
- package/dist/types/lib/influence-core/similarity.d.ts.map +1 -0
- package/dist/types/lib/influence-core/types.d.ts +158 -0
- package/dist/types/lib/influence-core/types.d.ts.map +1 -0
- package/dist/types/lib/tool-lint/analyze.d.ts +84 -0
- package/dist/types/lib/tool-lint/analyze.d.ts.map +1 -0
- package/dist/types/lib/tool-lint/cli.d.ts +44 -0
- package/dist/types/lib/tool-lint/cli.d.ts.map +1 -0
- package/dist/types/lib/tool-lint/format.d.ts +19 -0
- package/dist/types/lib/tool-lint/format.d.ts.map +1 -0
- package/dist/types/lib/tool-lint/index.d.ts +24 -0
- package/dist/types/lib/tool-lint/index.d.ts.map +1 -0
- package/dist/types/lib/tool-lint/rules.d.ts +86 -0
- package/dist/types/lib/tool-lint/rules.d.ts.map +1 -0
- package/dist/types/lib/tool-lint/types.d.ts +156 -0
- package/dist/types/lib/tool-lint/types.d.ts.map +1 -0
- package/dist/types/lib/trace-toolpack/bounded.d.ts +48 -0
- package/dist/types/lib/trace-toolpack/bounded.d.ts.map +1 -0
- package/dist/types/lib/trace-toolpack/index.d.ts +10 -0
- package/dist/types/lib/trace-toolpack/index.d.ts.map +1 -0
- package/dist/types/lib/trace-toolpack/traceToolpack.d.ts +70 -0
- package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -0
- package/dist/types/lib/trace-toolpack/types.d.ts +60 -0
- package/dist/types/lib/trace-toolpack/types.d.ts.map +1 -0
- package/dist/types/observe.d.ts +4 -0
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts +165 -0
- package/dist/types/recorders/observability/ToolChoiceRecorder.d.ts.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* analyzeToolCatalog — the tool-catalog confusability lint
|
|
4
|
+
* (RFC-002 block C1, the adoption front door).
|
|
5
|
+
*
|
|
6
|
+
* Pattern: policy layer over `pairwiseSimilarity` (influence-core) — the
|
|
7
|
+
* geometry is computed there; thresholds, verdicts, hints and
|
|
8
|
+
* the structural rule pack live here. Everything is consumer-
|
|
9
|
+
* injectable with our defaults (the plug-and-play meta-pattern).
|
|
10
|
+
* Role: `src/lib/tool-lint/`. ZERO stack buy-in — plain
|
|
11
|
+
* `{ name, description?, inputSchema? }[]` in, report out.
|
|
12
|
+
* `catalogFromTools` adapts the library's own `Tool[]`;
|
|
13
|
+
* `coerceCatalog` (cli.ts) normalizes OpenAI/Anthropic/MCP
|
|
14
|
+
* shapes.
|
|
15
|
+
*
|
|
16
|
+
* ## What is embedded (and why)
|
|
17
|
+
*
|
|
18
|
+
* `confusabilityText(tool)` = tokenized name + ': ' + description. The
|
|
19
|
+
* model differentiates tools by name AND description together, so two
|
|
20
|
+
* tools with near-identical names and overlapping descriptions ARE the
|
|
21
|
+
* confusability case (`get_fcns_database` vs `influx_get_fcns_database`)
|
|
22
|
+
* — embedding only the prose would miss the name signal.
|
|
23
|
+
*
|
|
24
|
+
* ## Calibration (RFC-002 §3 — read this before trusting verdicts)
|
|
25
|
+
*
|
|
26
|
+
* Absolute cosine ranges are PER-EMBEDDER. The default threshold (0.85)
|
|
27
|
+
* is a starting point for real sentence embedders. The test/demo
|
|
28
|
+
* `mockEmbedder` (character-frequency) compresses unrelated prose into
|
|
29
|
+
* ~0.85–0.97 — with it, use `MOCK_EMBEDDER_CALIBRATION` and trust only
|
|
30
|
+
* the RELATIVE ordering in `report.similarity.ranked` (the acceptance
|
|
31
|
+
* fixtures assert ordering, never absolute scores).
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.differentiationHint = exports.analyzeToolCatalog = exports.confusabilityText = exports.catalogFromTools = exports.MOCK_EMBEDDER_CALIBRATION = exports.DEFAULT_WATCH_BAND = exports.DEFAULT_CONFUSABILITY_THRESHOLD = void 0;
|
|
35
|
+
const index_js_1 = require("../influence-core/index.js");
|
|
36
|
+
const rules_js_1 = require("./rules.js");
|
|
37
|
+
/** Default `confusabilityThreshold` — a starting point for REAL sentence
|
|
38
|
+
* embedders (unrelated tool descriptions typically land 0.3–0.7).
|
|
39
|
+
* Calibrate per embedder; meaningless for the mock (see below). */
|
|
40
|
+
exports.DEFAULT_CONFUSABILITY_THRESHOLD = 0.85;
|
|
41
|
+
/** Default `watchBand` below the threshold. */
|
|
42
|
+
exports.DEFAULT_WATCH_BAND = 0.05;
|
|
43
|
+
/**
|
|
44
|
+
* Threshold/band calibrated for the char-frequency `mockEmbedder` on
|
|
45
|
+
* realistic tool prose (seed corpus: the Neo SAN catalog). The mock
|
|
46
|
+
* compresses unrelated descriptions into ~0.85–0.97 cosine, so expect
|
|
47
|
+
* false positives even at 0.94 — with the mock, the RELATIVE ordering
|
|
48
|
+
* of `report.similarity.ranked` is the trustworthy signal; absolute
|
|
49
|
+
* verdicts are only honest with a real embedder + per-embedder
|
|
50
|
+
* calibration.
|
|
51
|
+
*/
|
|
52
|
+
exports.MOCK_EMBEDDER_CALIBRATION = Object.freeze({
|
|
53
|
+
confusabilityThreshold: 0.94,
|
|
54
|
+
watchBand: 0.02,
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Adapt the library's `Tool[]` (from `defineTool` / `Agent.tool`) to the
|
|
58
|
+
* lint's plain catalog shape. Trivial on purpose: `Tool.schema` already
|
|
59
|
+
* IS `{ name, description, inputSchema }`.
|
|
60
|
+
*/
|
|
61
|
+
function catalogFromTools(tools) {
|
|
62
|
+
return tools.map((tool) => ({
|
|
63
|
+
name: tool.schema.name,
|
|
64
|
+
description: tool.schema.description,
|
|
65
|
+
inputSchema: tool.schema.inputSchema,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
exports.catalogFromTools = catalogFromTools;
|
|
69
|
+
/**
|
|
70
|
+
* The text the confusability analysis embeds for one tool: the name with
|
|
71
|
+
* `_`/`-`/camelCase boundaries opened into words, then the description.
|
|
72
|
+
* Exported so consumers can reproduce or replace the construction.
|
|
73
|
+
*/
|
|
74
|
+
function confusabilityText(tool) {
|
|
75
|
+
const name = tool.name
|
|
76
|
+
.replace(/[_-]+/g, ' ')
|
|
77
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
78
|
+
.trim();
|
|
79
|
+
const description = tool.description?.trim() ?? '';
|
|
80
|
+
return description.length > 0 ? `${name}: ${description}` : name;
|
|
81
|
+
}
|
|
82
|
+
exports.confusabilityText = confusabilityText;
|
|
83
|
+
/**
|
|
84
|
+
* Lint a tool catalog: pairwise confusability over what the model reads
|
|
85
|
+
* (when an embedder is supplied) + the structural rule pack. Returns a
|
|
86
|
+
* report whose `ok` is the CI gate.
|
|
87
|
+
*
|
|
88
|
+
* Duplicate tool names are themselves reported as structural errors
|
|
89
|
+
* (rule `duplicate-name`, built-in precondition — a catalog where two
|
|
90
|
+
* tools share a name is broken before any similarity question); the
|
|
91
|
+
* duplicates are dropped from the similarity analysis (first one wins).
|
|
92
|
+
*/
|
|
93
|
+
async function analyzeToolCatalog(tools, options = {}) {
|
|
94
|
+
const confusabilityThreshold = options.confusabilityThreshold ?? exports.DEFAULT_CONFUSABILITY_THRESHOLD;
|
|
95
|
+
const watchBand = options.watchBand ?? exports.DEFAULT_WATCH_BAND;
|
|
96
|
+
const rules = options.rules ?? rules_js_1.defaultStructuralRules;
|
|
97
|
+
const failOn = options.failOn ?? 'error';
|
|
98
|
+
// ── built-in precondition: duplicate names ──
|
|
99
|
+
const structural = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
const unique = [];
|
|
102
|
+
for (const tool of tools) {
|
|
103
|
+
if (seen.has(tool.name)) {
|
|
104
|
+
structural.push({
|
|
105
|
+
rule: 'duplicate-name',
|
|
106
|
+
tool: tool.name,
|
|
107
|
+
severity: 'error',
|
|
108
|
+
message: 'two tools share this name — the model cannot address them distinctly',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
seen.add(tool.name);
|
|
113
|
+
unique.push(tool);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// ── structural rule pack ──
|
|
117
|
+
for (const tool of unique) {
|
|
118
|
+
for (const rule of rules) {
|
|
119
|
+
structural.push(...rule.check(tool, unique));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ── pairwise confusability (embedder-gated) ──
|
|
123
|
+
let ranked = [];
|
|
124
|
+
const confusable = [];
|
|
125
|
+
const watch = [];
|
|
126
|
+
const analyzed = options.embedder !== undefined && unique.length >= 2;
|
|
127
|
+
if (options.embedder !== undefined && unique.length >= 2) {
|
|
128
|
+
const byName = new Map(unique.map((tool) => [tool.name, tool]));
|
|
129
|
+
const result = await (0, index_js_1.pairwiseSimilarity)({
|
|
130
|
+
items: unique.map((tool) => ({ id: tool.name, text: confusabilityText(tool) })),
|
|
131
|
+
embedder: options.embedder,
|
|
132
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
133
|
+
});
|
|
134
|
+
ranked = result.pairs;
|
|
135
|
+
for (const pair of result.pairs) {
|
|
136
|
+
if (pair.similarity >= confusabilityThreshold) {
|
|
137
|
+
confusable.push({
|
|
138
|
+
kind: 'confusable',
|
|
139
|
+
a: pair.a,
|
|
140
|
+
b: pair.b,
|
|
141
|
+
similarity: pair.similarity,
|
|
142
|
+
// byName lookups are safe: pair ids come from `unique` itself.
|
|
143
|
+
hint: differentiationHint(byName.get(pair.a), byName.get(pair.b)),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else if (pair.similarity >= confusabilityThreshold - watchBand) {
|
|
147
|
+
watch.push({
|
|
148
|
+
kind: 'watch',
|
|
149
|
+
a: pair.a,
|
|
150
|
+
b: pair.b,
|
|
151
|
+
similarity: pair.similarity,
|
|
152
|
+
hint: differentiationHint(byName.get(pair.a), byName.get(pair.b)),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const errors = structural.filter((f) => f.severity === 'error').length;
|
|
158
|
+
const warnings = structural.length - errors;
|
|
159
|
+
const gateFailures = failOn === 'warn' ? structural.length : errors;
|
|
160
|
+
return {
|
|
161
|
+
ok: confusable.length === 0 && gateFailures === 0,
|
|
162
|
+
toolCount: tools.length,
|
|
163
|
+
similarity: {
|
|
164
|
+
analyzed,
|
|
165
|
+
confusable,
|
|
166
|
+
watch,
|
|
167
|
+
ranked,
|
|
168
|
+
thresholds: { confusabilityThreshold, watchBand },
|
|
169
|
+
},
|
|
170
|
+
structural,
|
|
171
|
+
summary: { confusable: confusable.length, watch: watch.length, errors, warnings },
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
exports.analyzeToolCatalog = analyzeToolCatalog;
|
|
175
|
+
// ── differentiating-axis hint (heuristic, honest) ────────────────────
|
|
176
|
+
const STOPWORDS = new Set([
|
|
177
|
+
'a',
|
|
178
|
+
'an',
|
|
179
|
+
'and',
|
|
180
|
+
'are',
|
|
181
|
+
'by',
|
|
182
|
+
'for',
|
|
183
|
+
'from',
|
|
184
|
+
'get',
|
|
185
|
+
'in',
|
|
186
|
+
'into',
|
|
187
|
+
'is',
|
|
188
|
+
'its',
|
|
189
|
+
'of',
|
|
190
|
+
'on',
|
|
191
|
+
'or',
|
|
192
|
+
'the',
|
|
193
|
+
'to',
|
|
194
|
+
'which',
|
|
195
|
+
'with',
|
|
196
|
+
]);
|
|
197
|
+
function nameTokens(name) {
|
|
198
|
+
return name
|
|
199
|
+
.replace(/[_-]+/g, ' ')
|
|
200
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
201
|
+
.toLowerCase()
|
|
202
|
+
.split(/\s+/)
|
|
203
|
+
.filter((t) => t.length > 0);
|
|
204
|
+
}
|
|
205
|
+
function descriptionTokens(tool) {
|
|
206
|
+
return new Set((tool.description ?? '')
|
|
207
|
+
.toLowerCase()
|
|
208
|
+
.split(/[^a-z0-9_]+/)
|
|
209
|
+
.filter((t) => t.length >= 3 && !STOPWORDS.has(t)));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Suggest the DIFFERENTIATING AXIS for a flagged pair. Heuristic: when
|
|
213
|
+
* the names are near-twins (≤2 distinct tokens), the qualifier IS the
|
|
214
|
+
* axis — the descriptions must say when to choose each variant. When the
|
|
215
|
+
* names differ, surface the few description terms each tool does NOT
|
|
216
|
+
* share, as the place to anchor an explicit choice condition.
|
|
217
|
+
*/
|
|
218
|
+
function differentiationHint(a, b) {
|
|
219
|
+
const aTokens = nameTokens(a.name);
|
|
220
|
+
const bTokens = nameTokens(b.name);
|
|
221
|
+
const aOnly = aTokens.filter((t) => !bTokens.includes(t));
|
|
222
|
+
const bOnly = bTokens.filter((t) => !aTokens.includes(t));
|
|
223
|
+
const shared = aTokens.filter((t) => bTokens.includes(t));
|
|
224
|
+
if (shared.length >= 2 && aOnly.length + bOnly.length <= 2) {
|
|
225
|
+
const diff = [...aOnly, ...bOnly].map((t) => `'${t}'`).join(' vs ') || 'nothing — the names match';
|
|
226
|
+
return (`names differ only by ${diff} — make the descriptions say WHEN to choose each ` +
|
|
227
|
+
`(different backend/data source? live vs historical? freshness?), ` +
|
|
228
|
+
`e.g. "Use for …; prefer ${b.name} when …"`);
|
|
229
|
+
}
|
|
230
|
+
const aDesc = descriptionTokens(a);
|
|
231
|
+
const bDesc = descriptionTokens(b);
|
|
232
|
+
const aDistinct = [...aDesc].filter((t) => !bDesc.has(t)).slice(0, 3);
|
|
233
|
+
const bDistinct = [...bDesc].filter((t) => !aDesc.has(t)).slice(0, 3);
|
|
234
|
+
if (aDistinct.length === 0 && bDistinct.length === 0) {
|
|
235
|
+
return `the descriptions are near-duplicates — rewrite one to state when it, and not ${b.name}, is the right call`;
|
|
236
|
+
}
|
|
237
|
+
return (`descriptions overlap heavily; the distinct terms are ` +
|
|
238
|
+
`${a.name}: [${aDistinct.join(', ')}] vs ${b.name}: [${bDistinct.join(', ')}] — ` +
|
|
239
|
+
`lead with an explicit choice condition ("use when …") built on those`);
|
|
240
|
+
}
|
|
241
|
+
exports.differentiationHint = differentiationHint;
|
|
242
|
+
//# sourceMappingURL=analyze.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../../src/lib/tool-lint/analyze.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAGH,yDAAqF;AACrF,yCAAoD;AASpD;;oEAEoE;AACvD,QAAA,+BAA+B,GAAG,IAAI,CAAC;AAEpD,+CAA+C;AAClC,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAEvC;;;;;;;;GAQG;AACU,QAAA,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrD,sBAAsB,EAAE,IAAI;IAC5B,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,KAAsB;IACrD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;QACtB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;QACpC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;KACrC,CAAC,CAAC,CAAC;AACN,CAAC;AAND,4CAMC;AAED;;;;GAIG;AACH,SAAgB,iBAA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AAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,gFAAgF,CAAC,CAAC,IAAI,qBAAqB,CAAC;IACrH,CAAC;IACD,OAAO,CACL,uDAAuD;QACvD,GAAG,CAAC,CAAC,IAAI,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;QACjF,sEAAsE,CACvE,CAAC;AACJ,CAAC;AA7BD,kDA6BC"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool-lint CLI core (RFC-002 block C3 — the CI gate).
|
|
4
|
+
*
|
|
5
|
+
* Pattern: humble shell — `bin/agentfootprint-lint-tools.mjs` is a
|
|
6
|
+
* 3-line wrapper; ALL behavior (arg parsing, catalog coercion,
|
|
7
|
+
* report, exit code) lives here so it is unit-testable without
|
|
8
|
+
* spawning a process.
|
|
9
|
+
* Role: `src/lib/tool-lint/`. Reads ONE JSON file of tools, prints a
|
|
10
|
+
* report, returns the process exit code:
|
|
11
|
+
* 0 — report.ok
|
|
12
|
+
* 1 — findings failed the gate (!ok)
|
|
13
|
+
* 2 — usage / input error (bad flags, unreadable file,
|
|
14
|
+
* unrecognized JSON shape)
|
|
15
|
+
*
|
|
16
|
+
* ## Embedder & gating honesty
|
|
17
|
+
*
|
|
18
|
+
* The CLI has no way to receive a consumer embedder, so it uses the
|
|
19
|
+
* built-in deterministic mock (char-frequency, offline, dependency-free)
|
|
20
|
+
* for the similarity RANKING — and, by default, does NOT gate on it:
|
|
21
|
+
* without `--threshold`, similarity is report-only (relative ordering +
|
|
22
|
+
* watch hints) and the exit code reflects structural findings alone.
|
|
23
|
+
* Pass `--threshold` to make confusable pairs fail the gate — you own
|
|
24
|
+
* the calibration at that point (start from
|
|
25
|
+
* `MOCK_EMBEDDER_CALIBRATION.confusabilityThreshold` = 0.94). For real
|
|
26
|
+
* embedder gating, use `analyzeToolCatalog` from
|
|
27
|
+
* `agentfootprint/observe` in a small script instead.
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.runToolLintCli = exports.coerceCatalog = void 0;
|
|
31
|
+
const promises_1 = require("node:fs/promises");
|
|
32
|
+
const mockEmbedder_js_1 = require("../../memory/embedding/mockEmbedder.js");
|
|
33
|
+
const analyze_js_1 = require("./analyze.js");
|
|
34
|
+
const format_js_1 = require("./format.js");
|
|
35
|
+
const USAGE = `usage: agentfootprint-lint-tools <tools.json> [options]
|
|
36
|
+
|
|
37
|
+
<tools.json> JSON file with your tool catalog. Accepted shapes:
|
|
38
|
+
[{ name, description, inputSchema? }] (plain / MCP tool)
|
|
39
|
+
{ tools: [...] } (MCP tools/list result)
|
|
40
|
+
[{ type: 'function', function: {...} }] (OpenAI)
|
|
41
|
+
[{ name, description, input_schema }] (Anthropic)
|
|
42
|
+
|
|
43
|
+
--threshold <num> gate on confusable pairs at this cosine (mock-embedder
|
|
44
|
+
starting point: ${analyze_js_1.MOCK_EMBEDDER_CALIBRATION.confusabilityThreshold}). Without it, similarity is
|
|
45
|
+
REPORT-ONLY and only structural findings gate.
|
|
46
|
+
--watch-band <num> advisory band below the threshold (default ${analyze_js_1.MOCK_EMBEDDER_CALIBRATION.watchBand} with --threshold)
|
|
47
|
+
--strict structural warnings also fail the gate
|
|
48
|
+
--no-similarity skip the similarity analysis entirely
|
|
49
|
+
--top <n> ranked pairs to print (default 10)
|
|
50
|
+
--json print the full report as JSON instead of text
|
|
51
|
+
|
|
52
|
+
exit codes: 0 ok · 1 findings failed the gate · 2 usage/input error`;
|
|
53
|
+
/**
|
|
54
|
+
* Normalize any of the recognized tool-list JSON shapes to the lint's
|
|
55
|
+
* plain catalog. Throws (with a shape description) on unrecognized
|
|
56
|
+
* input — the CLI maps that to exit code 2.
|
|
57
|
+
*/
|
|
58
|
+
function coerceCatalog(json) {
|
|
59
|
+
// { tools: [...] } — MCP `tools/list` result envelope.
|
|
60
|
+
const list = Array.isArray(json)
|
|
61
|
+
? json
|
|
62
|
+
: json !== null &&
|
|
63
|
+
typeof json === 'object' &&
|
|
64
|
+
Array.isArray(json.tools)
|
|
65
|
+
? json.tools
|
|
66
|
+
: undefined;
|
|
67
|
+
if (list === undefined) {
|
|
68
|
+
throw new Error('expected a JSON array of tools or { tools: [...] }');
|
|
69
|
+
}
|
|
70
|
+
return list.map((raw, index) => {
|
|
71
|
+
if (raw === null || typeof raw !== 'object') {
|
|
72
|
+
throw new Error(`tools[${index}] is not an object`);
|
|
73
|
+
}
|
|
74
|
+
const entry = raw;
|
|
75
|
+
// OpenAI: { type: 'function', function: { name, description, parameters } }
|
|
76
|
+
const fn = entry.type === 'function' && entry.function !== null && typeof entry.function === 'object'
|
|
77
|
+
? entry.function
|
|
78
|
+
: entry;
|
|
79
|
+
const name = fn.name;
|
|
80
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
81
|
+
throw new Error(`tools[${index}] has no string 'name'`);
|
|
82
|
+
}
|
|
83
|
+
const description = typeof fn.description === 'string' ? fn.description : undefined;
|
|
84
|
+
// inputSchema (MCP/ours) | input_schema (Anthropic) | parameters (OpenAI)
|
|
85
|
+
const schema = fn.inputSchema ?? fn.input_schema ?? fn.parameters;
|
|
86
|
+
const inputSchema = schema !== null && typeof schema === 'object'
|
|
87
|
+
? schema
|
|
88
|
+
: undefined;
|
|
89
|
+
return {
|
|
90
|
+
name,
|
|
91
|
+
...(description !== undefined ? { description } : {}),
|
|
92
|
+
...(inputSchema !== undefined ? { inputSchema } : {}),
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.coerceCatalog = coerceCatalog;
|
|
97
|
+
function parseArgs(argv) {
|
|
98
|
+
let file;
|
|
99
|
+
let threshold;
|
|
100
|
+
let watchBand;
|
|
101
|
+
let strict = false;
|
|
102
|
+
let similarity = true;
|
|
103
|
+
let top = 10;
|
|
104
|
+
let json = false;
|
|
105
|
+
for (let i = 0; i < argv.length; i++) {
|
|
106
|
+
const arg = argv[i];
|
|
107
|
+
const numberFlag = (name) => {
|
|
108
|
+
const value = Number(argv[++i]);
|
|
109
|
+
if (!Number.isFinite(value))
|
|
110
|
+
throw new Error(`${name} expects a number`);
|
|
111
|
+
return value;
|
|
112
|
+
};
|
|
113
|
+
if (arg === '--threshold')
|
|
114
|
+
threshold = numberFlag('--threshold');
|
|
115
|
+
else if (arg === '--watch-band')
|
|
116
|
+
watchBand = numberFlag('--watch-band');
|
|
117
|
+
else if (arg === '--strict')
|
|
118
|
+
strict = true;
|
|
119
|
+
else if (arg === '--no-similarity')
|
|
120
|
+
similarity = false;
|
|
121
|
+
else if (arg === '--top')
|
|
122
|
+
top = numberFlag('--top');
|
|
123
|
+
else if (arg === '--json')
|
|
124
|
+
json = true;
|
|
125
|
+
else if (arg === '--help' || arg === '-h')
|
|
126
|
+
throw new Error(USAGE);
|
|
127
|
+
else if (arg.startsWith('-'))
|
|
128
|
+
throw new Error(`unknown flag '${arg}'\n\n${USAGE}`);
|
|
129
|
+
else if (file === undefined)
|
|
130
|
+
file = arg;
|
|
131
|
+
else
|
|
132
|
+
throw new Error(`unexpected extra argument '${arg}'\n\n${USAGE}`);
|
|
133
|
+
}
|
|
134
|
+
if (file === undefined)
|
|
135
|
+
throw new Error(USAGE);
|
|
136
|
+
return {
|
|
137
|
+
file,
|
|
138
|
+
...(threshold !== undefined ? { threshold } : {}),
|
|
139
|
+
...(watchBand !== undefined ? { watchBand } : {}),
|
|
140
|
+
strict,
|
|
141
|
+
similarity,
|
|
142
|
+
top,
|
|
143
|
+
json,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Run the lint CLI. Returns the exit code (never calls `process.exit` —
|
|
148
|
+
* the bin wrapper assigns it to `process.exitCode`).
|
|
149
|
+
*/
|
|
150
|
+
async function runToolLintCli(argv, io = {
|
|
151
|
+
// eslint-disable-next-line no-console
|
|
152
|
+
stdout: (line) => console.log(line),
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
154
|
+
stderr: (line) => console.error(line),
|
|
155
|
+
}) {
|
|
156
|
+
let args;
|
|
157
|
+
try {
|
|
158
|
+
args = parseArgs(argv);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
io.stderr(error.message);
|
|
162
|
+
return 2;
|
|
163
|
+
}
|
|
164
|
+
let catalog;
|
|
165
|
+
try {
|
|
166
|
+
catalog = coerceCatalog(JSON.parse(await (0, promises_1.readFile)(args.file, 'utf8')));
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
io.stderr(`agentfootprint-lint-tools: ${args.file}: ${error.message}`);
|
|
170
|
+
return 2;
|
|
171
|
+
}
|
|
172
|
+
// Without --threshold the mock-embedder similarity is REPORT-ONLY:
|
|
173
|
+
// rank pairs at an unreachable threshold (no 'confusable'/'watch'
|
|
174
|
+
// verdicts) so only the relative-ordering section prints.
|
|
175
|
+
const gateOnSimilarity = args.threshold !== undefined;
|
|
176
|
+
const threshold = args.threshold ?? Infinity;
|
|
177
|
+
const watchBand = args.watchBand ?? (gateOnSimilarity ? analyze_js_1.MOCK_EMBEDDER_CALIBRATION.watchBand : 0);
|
|
178
|
+
const report = await (0, analyze_js_1.analyzeToolCatalog)(catalog, {
|
|
179
|
+
...(args.similarity ? { embedder: (0, mockEmbedder_js_1.mockEmbedder)() } : {}),
|
|
180
|
+
confusabilityThreshold: threshold,
|
|
181
|
+
watchBand,
|
|
182
|
+
failOn: args.strict ? 'warn' : 'error',
|
|
183
|
+
});
|
|
184
|
+
if (args.json) {
|
|
185
|
+
io.stdout(JSON.stringify(report, null, 2));
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
if (args.similarity) {
|
|
189
|
+
io.stdout(gateOnSimilarity
|
|
190
|
+
? '⚠ similarity uses the built-in deterministic mock embedder — you own the ' +
|
|
191
|
+
'calibration of --threshold (cosine ranges are per-embedder; mock compresses ' +
|
|
192
|
+
'prose to ~0.85–0.97). Trust relative ordering first.'
|
|
193
|
+
: 'ℹ similarity is REPORT-ONLY (no --threshold): ranked pairs below are the ' +
|
|
194
|
+
'relative-ordering view from the built-in mock embedder. Pass --threshold ' +
|
|
195
|
+
`(mock starting point ${analyze_js_1.MOCK_EMBEDDER_CALIBRATION.confusabilityThreshold}) to gate on confusable pairs.`);
|
|
196
|
+
io.stdout('');
|
|
197
|
+
}
|
|
198
|
+
io.stdout((0, format_js_1.formatToolCatalogReport)(report, { topPairs: args.top }));
|
|
199
|
+
}
|
|
200
|
+
return report.ok ? 0 : 1;
|
|
201
|
+
}
|
|
202
|
+
exports.runToolLintCli = runToolLintCli;
|
|
203
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/lib/tool-lint/cli.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AAEH,+CAA4C;AAC5C,4EAAsE;AACtE,6CAA6E;AAC7E,2CAAsD;AAQtD,MAAM,KAAK,GAAG;;;;;;;;;0CAS4B,sCAAyB,CAAC,sBAAsB;;qEAErB,sCAAyB,CAAC,SAAS;;;;;;oEAMpC,CAAC;AAErE;;;;GAIG;AACH,SAAgB,aAAa,CAAC,IAAa;IACzC,uDAAuD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AC;QACxD,sBAAsB,EAAE,SAAS;QACjC,SAAS;QACT,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;KACvC,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,EAAE,CAAC,MAAM,CACP,gBAAgB;gBACd,CAAC,CAAC,2EAA2E;oBACzE,8EAA8E;oBAC9E,sDAAsD;gBAC1D,CAAC,CAAC,2EAA2E;oBACzE,2EAA2E;oBAC3E,wBAAwB,sCAAyB,CAAC,sBAAsB,gCAAgC,CAC/G,CAAC;YACF,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChB,CAAC;QACD,EAAE,CAAC,MAAM,CAAC,IAAA,mCAAuB,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AA1DD,wCA0DC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* formatToolCatalogReport — human-readable rendering of a lint report.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: pure presenter. One report → one string; used verbatim by the
|
|
6
|
+
* CLI (`agentfootprint-lint-tools`) and the examples so output
|
|
7
|
+
* stays byte-identical across surfaces.
|
|
8
|
+
* Role: `src/lib/tool-lint/` leaf. No I/O.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.formatToolCatalogReport = void 0;
|
|
12
|
+
function formatToolCatalogReport(report, options = {}) {
|
|
13
|
+
const topPairs = options.topPairs ?? 10;
|
|
14
|
+
const maxWatch = options.maxWatch ?? 10;
|
|
15
|
+
const lines = [];
|
|
16
|
+
const { similarity, structural, summary } = report;
|
|
17
|
+
lines.push(`tool-catalog lint — ${report.toolCount} tools · ` +
|
|
18
|
+
`${summary.confusable} confusable · ${summary.watch} watch · ` +
|
|
19
|
+
`${summary.errors} errors · ${summary.warnings} warnings`);
|
|
20
|
+
if (similarity.analyzed) {
|
|
21
|
+
lines.push('', `confusability (threshold ${similarity.thresholds.confusabilityThreshold}, ` +
|
|
22
|
+
`watch band ${similarity.thresholds.watchBand}):`);
|
|
23
|
+
if (similarity.confusable.length === 0 && similarity.watch.length === 0) {
|
|
24
|
+
lines.push(' no pairs at or near the threshold');
|
|
25
|
+
}
|
|
26
|
+
for (const pair of similarity.confusable) {
|
|
27
|
+
lines.push(` ✗ CONFUSABLE ${pair.similarity.toFixed(4)} ${pair.a} <> ${pair.b}`);
|
|
28
|
+
lines.push(` hint: ${pair.hint}`);
|
|
29
|
+
}
|
|
30
|
+
for (const pair of similarity.watch.slice(0, maxWatch)) {
|
|
31
|
+
lines.push(` ~ watch ${pair.similarity.toFixed(4)} ${pair.a} <> ${pair.b}`);
|
|
32
|
+
lines.push(` hint: ${pair.hint}`);
|
|
33
|
+
}
|
|
34
|
+
if (similarity.watch.length > maxWatch) {
|
|
35
|
+
lines.push(` … and ${similarity.watch.length - maxWatch} more watch pairs (see report.similarity.watch)`);
|
|
36
|
+
}
|
|
37
|
+
if (topPairs > 0 && similarity.ranked.length > 0) {
|
|
38
|
+
lines.push('', ` most-similar pairs (relative ordering — top ${topPairs}):`);
|
|
39
|
+
for (const pair of similarity.ranked.slice(0, topPairs)) {
|
|
40
|
+
lines.push(` ${pair.similarity.toFixed(4)} ${pair.a} <> ${pair.b}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
lines.push('', 'confusability: skipped (no embedder supplied — structural rules only)');
|
|
46
|
+
}
|
|
47
|
+
if (structural.length > 0) {
|
|
48
|
+
lines.push('', 'structural findings:');
|
|
49
|
+
for (const finding of structural) {
|
|
50
|
+
const where = finding.param ? `${finding.tool}.${finding.param}` : finding.tool;
|
|
51
|
+
const mark = finding.severity === 'error' ? '✗' : '~';
|
|
52
|
+
lines.push(` ${mark} ${finding.severity.padEnd(5)} [${finding.rule}] ${where}`);
|
|
53
|
+
lines.push(` ${finding.message}`);
|
|
54
|
+
if (finding.suggestion)
|
|
55
|
+
lines.push(` suggest: ${finding.suggestion}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
lines.push('', 'structural findings: none');
|
|
60
|
+
}
|
|
61
|
+
lines.push('', report.ok ? 'RESULT: ok' : 'RESULT: FAIL');
|
|
62
|
+
return lines.join('\n');
|
|
63
|
+
}
|
|
64
|
+
exports.formatToolCatalogReport = formatToolCatalogReport;
|
|
65
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/lib/tool-lint/format.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAaH,SAAgB,uBAAuB,CACrC,MAAyB,EACzB,UAA+B,EAAE;IAEjC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAEnD,KAAK,CAAC,IAAI,CACR,uBAAuB,MAAM,CAAC,SAAS,WAAW;QAChD,GAAG,OAAO,CAAC,UAAU,iBAAiB,OAAO,CAAC,KAAK,WAAW;QAC9D,GAAG,OAAO,CAAC,MAAM,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CAAC,IAAI,CAAC,kBAAkB,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAhED,0DAgEC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* tool-lint — the tool-catalog confusability lint (RFC-002 tier 1,
|
|
4
|
+
* blocks C1–C3).
|
|
5
|
+
*
|
|
6
|
+
* Build-time, CI-gateable, framework-agnostic: a plain
|
|
7
|
+
* `{ name, description?, inputSchema? }[]` in (any OpenAI / Anthropic /
|
|
8
|
+
* LangChain / MCP tool list coerces to it), a report with a CI-gateable
|
|
9
|
+
* `ok` out. The embedding geometry comes from influence-core
|
|
10
|
+
* (`pairwiseSimilarity`); this module is the policy layer — thresholds,
|
|
11
|
+
* verdicts, hints, and the pluggable structural rule pack.
|
|
12
|
+
*
|
|
13
|
+
* Surfaces:
|
|
14
|
+
* - `analyzeToolCatalog(tools, opts)` — the API (C1)
|
|
15
|
+
* - `defaultStructuralRules` + rule factories — the rule pack (C2)
|
|
16
|
+
* - `runToolLintCli` / bin `agentfootprint-lint-tools` — the gate (C3)
|
|
17
|
+
*
|
|
18
|
+
* Front-door guide: docs/guides/tool-catalog-lint.md
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.runToolLintCli = exports.coerceCatalog = exports.formatToolCatalogReport = exports.DEFAULT_WHEN_CUES = exports.DEFAULT_OMISSION_CUES = exports.saysWhatNotWhenRule = exports.optionalParamRule = exports.enumInProseRule = exports.descriptionRule = exports.defaultStructuralRules = exports.MOCK_EMBEDDER_CALIBRATION = exports.DEFAULT_WATCH_BAND = exports.DEFAULT_CONFUSABILITY_THRESHOLD = exports.differentiationHint = exports.confusabilityText = exports.catalogFromTools = exports.analyzeToolCatalog = void 0;
|
|
22
|
+
var analyze_js_1 = require("./analyze.js");
|
|
23
|
+
Object.defineProperty(exports, "analyzeToolCatalog", { enumerable: true, get: function () { return analyze_js_1.analyzeToolCatalog; } });
|
|
24
|
+
Object.defineProperty(exports, "catalogFromTools", { enumerable: true, get: function () { return analyze_js_1.catalogFromTools; } });
|
|
25
|
+
Object.defineProperty(exports, "confusabilityText", { enumerable: true, get: function () { return analyze_js_1.confusabilityText; } });
|
|
26
|
+
Object.defineProperty(exports, "differentiationHint", { enumerable: true, get: function () { return analyze_js_1.differentiationHint; } });
|
|
27
|
+
Object.defineProperty(exports, "DEFAULT_CONFUSABILITY_THRESHOLD", { enumerable: true, get: function () { return analyze_js_1.DEFAULT_CONFUSABILITY_THRESHOLD; } });
|
|
28
|
+
Object.defineProperty(exports, "DEFAULT_WATCH_BAND", { enumerable: true, get: function () { return analyze_js_1.DEFAULT_WATCH_BAND; } });
|
|
29
|
+
Object.defineProperty(exports, "MOCK_EMBEDDER_CALIBRATION", { enumerable: true, get: function () { return analyze_js_1.MOCK_EMBEDDER_CALIBRATION; } });
|
|
30
|
+
var rules_js_1 = require("./rules.js");
|
|
31
|
+
Object.defineProperty(exports, "defaultStructuralRules", { enumerable: true, get: function () { return rules_js_1.defaultStructuralRules; } });
|
|
32
|
+
Object.defineProperty(exports, "descriptionRule", { enumerable: true, get: function () { return rules_js_1.descriptionRule; } });
|
|
33
|
+
Object.defineProperty(exports, "enumInProseRule", { enumerable: true, get: function () { return rules_js_1.enumInProseRule; } });
|
|
34
|
+
Object.defineProperty(exports, "optionalParamRule", { enumerable: true, get: function () { return rules_js_1.optionalParamRule; } });
|
|
35
|
+
Object.defineProperty(exports, "saysWhatNotWhenRule", { enumerable: true, get: function () { return rules_js_1.saysWhatNotWhenRule; } });
|
|
36
|
+
Object.defineProperty(exports, "DEFAULT_OMISSION_CUES", { enumerable: true, get: function () { return rules_js_1.DEFAULT_OMISSION_CUES; } });
|
|
37
|
+
Object.defineProperty(exports, "DEFAULT_WHEN_CUES", { enumerable: true, get: function () { return rules_js_1.DEFAULT_WHEN_CUES; } });
|
|
38
|
+
var format_js_1 = require("./format.js");
|
|
39
|
+
Object.defineProperty(exports, "formatToolCatalogReport", { enumerable: true, get: function () { return format_js_1.formatToolCatalogReport; } });
|
|
40
|
+
var cli_js_1 = require("./cli.js");
|
|
41
|
+
Object.defineProperty(exports, "coerceCatalog", { enumerable: true, get: function () { return cli_js_1.coerceCatalog; } });
|
|
42
|
+
Object.defineProperty(exports, "runToolLintCli", { enumerable: true, get: function () { return cli_js_1.runToolLintCli; } });
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/tool-lint/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAcH,2CAQsB;AAPpB,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA;AAChB,+GAAA,iBAAiB,OAAA;AACjB,iHAAA,mBAAmB,OAAA;AACnB,6HAAA,+BAA+B,OAAA;AAC/B,gHAAA,kBAAkB,OAAA;AAClB,uHAAA,yBAAyB,OAAA;AAG3B,uCAWoB;AAVlB,kHAAA,sBAAsB,OAAA;AACtB,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA;AACrB,6GAAA,iBAAiB,OAAA;AAMnB,yCAAgF;AAAvE,oHAAA,uBAAuB,OAAA;AAEhC,mCAA6E;AAApE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA"}
|