@runcontext/cli 0.2.1 → 0.3.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/dist/index.js +395 -43
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command12 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/commands/lint.ts
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import chalk2 from "chalk";
|
|
9
9
|
import path from "path";
|
|
10
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
10
11
|
import {
|
|
11
12
|
compile,
|
|
12
|
-
|
|
13
|
+
loadConfigAsync,
|
|
13
14
|
LintEngine,
|
|
14
|
-
ALL_RULES
|
|
15
|
+
ALL_RULES,
|
|
16
|
+
filterByDirectives,
|
|
17
|
+
applyFixes,
|
|
18
|
+
loadPlugins,
|
|
19
|
+
computeCacheHash,
|
|
20
|
+
readCache,
|
|
21
|
+
writeCache
|
|
15
22
|
} from "@runcontext/core";
|
|
16
23
|
|
|
17
24
|
// src/formatters/pretty.ts
|
|
@@ -89,22 +96,230 @@ function formatJson(data) {
|
|
|
89
96
|
return JSON.stringify(data, null, 2);
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
// src/formatters/sarif.ts
|
|
100
|
+
function mapSeverity(severity) {
|
|
101
|
+
switch (severity) {
|
|
102
|
+
case "error":
|
|
103
|
+
return "error";
|
|
104
|
+
case "warning":
|
|
105
|
+
return "warning";
|
|
106
|
+
default:
|
|
107
|
+
return "note";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function formatSarif(diagnostics) {
|
|
111
|
+
const ruleMap = /* @__PURE__ */ new Map();
|
|
112
|
+
for (const d of diagnostics) {
|
|
113
|
+
if (!ruleMap.has(d.ruleId)) {
|
|
114
|
+
ruleMap.set(d.ruleId, {
|
|
115
|
+
id: d.ruleId,
|
|
116
|
+
shortDescription: { text: d.message }
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const results = diagnostics.map((d) => ({
|
|
121
|
+
ruleId: d.ruleId,
|
|
122
|
+
level: mapSeverity(d.severity),
|
|
123
|
+
message: { text: d.message },
|
|
124
|
+
locations: [
|
|
125
|
+
{
|
|
126
|
+
physicalLocation: {
|
|
127
|
+
artifactLocation: { uri: d.location.file },
|
|
128
|
+
region: {
|
|
129
|
+
startLine: d.location.line,
|
|
130
|
+
startColumn: d.location.column
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}));
|
|
136
|
+
const sarif = {
|
|
137
|
+
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
|
|
138
|
+
version: "2.1.0",
|
|
139
|
+
runs: [
|
|
140
|
+
{
|
|
141
|
+
tool: {
|
|
142
|
+
driver: {
|
|
143
|
+
name: "ContextKit",
|
|
144
|
+
version: "0.2.1",
|
|
145
|
+
informationUri: "https://github.com/erickittelson/ContextKit",
|
|
146
|
+
rules: Array.from(ruleMap.values())
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
results
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
};
|
|
153
|
+
return JSON.stringify(sarif, null, 2);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/formatters/github.ts
|
|
157
|
+
function formatGitHub(diagnostics) {
|
|
158
|
+
if (diagnostics.length === 0) {
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
161
|
+
const lines = [];
|
|
162
|
+
for (const d of diagnostics) {
|
|
163
|
+
const level = d.severity === "error" ? "error" : "warning";
|
|
164
|
+
lines.push(
|
|
165
|
+
`::${level} file=${d.location.file},line=${d.location.line},col=${d.location.column},title=${d.ruleId}::${d.message}`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return lines.join("\n");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/formatters/junit.ts
|
|
172
|
+
function escapeXml(str) {
|
|
173
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
174
|
+
}
|
|
175
|
+
function formatJUnit(diagnostics) {
|
|
176
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
177
|
+
for (const d of diagnostics) {
|
|
178
|
+
const file = d.location.file;
|
|
179
|
+
if (!byFile.has(file)) {
|
|
180
|
+
byFile.set(file, []);
|
|
181
|
+
}
|
|
182
|
+
byFile.get(file).push(d);
|
|
183
|
+
}
|
|
184
|
+
const lines = [];
|
|
185
|
+
lines.push('<?xml version="1.0" encoding="UTF-8"?>');
|
|
186
|
+
lines.push(
|
|
187
|
+
`<testsuites name="ContextKit" tests="${diagnostics.length}" failures="${diagnostics.length}">`
|
|
188
|
+
);
|
|
189
|
+
for (const [file, diags] of byFile) {
|
|
190
|
+
lines.push(
|
|
191
|
+
` <testsuite name="${escapeXml(file)}" tests="${diags.length}" failures="${diags.length}">`
|
|
192
|
+
);
|
|
193
|
+
for (const d of diags) {
|
|
194
|
+
const name = `${d.ruleId} (${d.location.line}:${d.location.column})`;
|
|
195
|
+
lines.push(` <testcase name="${escapeXml(name)}" classname="${escapeXml(file)}">`);
|
|
196
|
+
lines.push(
|
|
197
|
+
` <failure message="${escapeXml(d.message)}" type="${d.severity}">${escapeXml(d.ruleId)}: ${escapeXml(d.message)} at ${escapeXml(file)}:${d.location.line}:${d.location.column}</failure>`
|
|
198
|
+
);
|
|
199
|
+
lines.push(" </testcase>");
|
|
200
|
+
}
|
|
201
|
+
lines.push(" </testsuite>");
|
|
202
|
+
}
|
|
203
|
+
lines.push("</testsuites>");
|
|
204
|
+
return lines.join("\n");
|
|
205
|
+
}
|
|
206
|
+
|
|
92
207
|
// src/commands/lint.ts
|
|
93
|
-
var
|
|
208
|
+
var VALID_FORMATS = ["pretty", "json", "sarif", "github", "junit"];
|
|
209
|
+
function detectFormat() {
|
|
210
|
+
if (process.env.GITHUB_ACTIONS) return "github";
|
|
211
|
+
if (process.env.CI) return "json";
|
|
212
|
+
return "pretty";
|
|
213
|
+
}
|
|
214
|
+
function collectRule(value, previous) {
|
|
215
|
+
const lastColon = value.lastIndexOf(":");
|
|
216
|
+
if (lastColon === -1) {
|
|
217
|
+
throw new Error(`Invalid --rule format: "${value}". Expected "ruleId:severity" (e.g., "governance/grain-required:error")`);
|
|
218
|
+
}
|
|
219
|
+
const ruleId = value.slice(0, lastColon);
|
|
220
|
+
const severity = value.slice(lastColon + 1);
|
|
221
|
+
if (!["error", "warning", "off"].includes(severity)) {
|
|
222
|
+
throw new Error(`Invalid severity "${severity}" in --rule "${value}". Must be error, warning, or off.`);
|
|
223
|
+
}
|
|
224
|
+
previous[ruleId] = severity;
|
|
225
|
+
return previous;
|
|
226
|
+
}
|
|
227
|
+
function formatOutput(diagnostics, format) {
|
|
228
|
+
switch (format) {
|
|
229
|
+
case "json":
|
|
230
|
+
return formatJson(diagnostics);
|
|
231
|
+
case "sarif":
|
|
232
|
+
return formatSarif(diagnostics);
|
|
233
|
+
case "github":
|
|
234
|
+
return formatGitHub(diagnostics);
|
|
235
|
+
case "junit":
|
|
236
|
+
return formatJUnit(diagnostics);
|
|
237
|
+
case "pretty":
|
|
238
|
+
default:
|
|
239
|
+
return formatDiagnostics(diagnostics);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
var lintCommand = new Command("lint").description("Run all lint rules against context files").option("--context-dir <path>", "Path to context directory").option("--format <type>", `Output format: ${VALID_FORMATS.join(", ")}`).option("--max-warnings <count>", "Exit with error if warning count exceeds this threshold", parseInt).option("--output-file <path>", "Write formatted output to a file").option("--rule <ruleId:severity>", "Override rule severity (repeatable)", collectRule, {}).option("--fix", "Automatically fix problems").option("--fix-dry-run", "Show what --fix would change without writing").option("--cache", "Only lint changed files (uses .contextkit-cache)").option("--no-cache", "Bypass the lint cache").action(async (opts) => {
|
|
94
243
|
try {
|
|
95
|
-
const config =
|
|
244
|
+
const config = await loadConfigAsync(process.cwd());
|
|
96
245
|
const contextDir = opts.contextDir ? path.resolve(opts.contextDir) : path.resolve(config.context_dir);
|
|
97
|
-
const
|
|
246
|
+
const rootDir = process.cwd();
|
|
247
|
+
const format = opts.format ? VALID_FORMATS.includes(opts.format) ? opts.format : "pretty" : detectFormat();
|
|
248
|
+
const useCache = opts.cache === true;
|
|
249
|
+
if (useCache) {
|
|
250
|
+
const configContent = JSON.stringify(config) + JSON.stringify(opts.rule ?? {});
|
|
251
|
+
const hash = computeCacheHash(contextDir, configContent);
|
|
252
|
+
const cached = readCache(rootDir, hash);
|
|
253
|
+
if (cached) {
|
|
254
|
+
const output2 = formatOutput(cached, format);
|
|
255
|
+
if (opts.outputFile) {
|
|
256
|
+
writeFileSync(path.resolve(opts.outputFile), output2, "utf-8");
|
|
257
|
+
const ec = cached.filter((d) => d.severity === "error").length;
|
|
258
|
+
const wc = cached.filter((d) => d.severity === "warning").length;
|
|
259
|
+
console.log(`Results written to ${opts.outputFile} (${ec} error(s), ${wc} warning(s)) (cached)`);
|
|
260
|
+
} else {
|
|
261
|
+
console.log(output2);
|
|
262
|
+
}
|
|
263
|
+
const hasErrors2 = cached.some((d) => d.severity === "error");
|
|
264
|
+
if (hasErrors2) process.exit(1);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const { graph, diagnostics: compileDiags, directives } = await compile({
|
|
98
269
|
contextDir,
|
|
99
|
-
config
|
|
270
|
+
config,
|
|
271
|
+
rootDir
|
|
100
272
|
});
|
|
101
|
-
const
|
|
102
|
-
const
|
|
273
|
+
const configOverrides = config.lint?.severity_overrides ?? {};
|
|
274
|
+
const cliOverrides = opts.rule;
|
|
275
|
+
const overrides = {
|
|
276
|
+
...configOverrides,
|
|
277
|
+
...cliOverrides
|
|
278
|
+
};
|
|
279
|
+
const engine = new LintEngine(Object.keys(overrides).length > 0 ? overrides : void 0);
|
|
103
280
|
for (const rule of ALL_RULES) {
|
|
104
281
|
engine.register(rule);
|
|
105
282
|
}
|
|
283
|
+
if (config.plugins && config.plugins.length > 0) {
|
|
284
|
+
const pluginRules = await loadPlugins(config.plugins);
|
|
285
|
+
for (const rule of pluginRules) {
|
|
286
|
+
engine.register(rule);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
106
289
|
const lintDiags = engine.run(graph);
|
|
107
|
-
|
|
290
|
+
let allDiags = filterByDirectives(
|
|
291
|
+
[...compileDiags, ...lintDiags],
|
|
292
|
+
directives
|
|
293
|
+
);
|
|
294
|
+
if (opts.fix || opts.fixDryRun) {
|
|
295
|
+
const fixable = allDiags.filter((d) => d.fixable && d.fix);
|
|
296
|
+
if (fixable.length > 0) {
|
|
297
|
+
const fixes = applyFixes(fixable, (filePath) => readFileSync(filePath, "utf-8"));
|
|
298
|
+
if (opts.fixDryRun) {
|
|
299
|
+
console.log(chalk2.blue(`Would fix ${fixable.length} issue(s) in ${fixes.size} file(s):`));
|
|
300
|
+
for (const [file] of fixes) {
|
|
301
|
+
console.log(chalk2.gray(` ${file}`));
|
|
302
|
+
}
|
|
303
|
+
console.log("");
|
|
304
|
+
} else {
|
|
305
|
+
for (const [file, content] of fixes) {
|
|
306
|
+
writeFileSync(file, content, "utf-8");
|
|
307
|
+
}
|
|
308
|
+
console.log(chalk2.green(`Fixed ${fixable.length} issue(s) in ${fixes.size} file(s).`));
|
|
309
|
+
const { graph: reGraph, diagnostics: reCompileDiags, directives: reDirs } = await compile({
|
|
310
|
+
contextDir,
|
|
311
|
+
config,
|
|
312
|
+
rootDir: process.cwd()
|
|
313
|
+
});
|
|
314
|
+
const reEngine = new LintEngine(Object.keys(overrides).length > 0 ? overrides : void 0);
|
|
315
|
+
for (const rule of ALL_RULES) {
|
|
316
|
+
reEngine.register(rule);
|
|
317
|
+
}
|
|
318
|
+
const reLintDiags = reEngine.run(reGraph);
|
|
319
|
+
allDiags = filterByDirectives([...reCompileDiags, ...reLintDiags], reDirs);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
108
323
|
if (config.minimum_tier) {
|
|
109
324
|
const tierOrder = ["none", "bronze", "silver", "gold"];
|
|
110
325
|
const minIdx = tierOrder.indexOf(config.minimum_tier);
|
|
@@ -121,10 +336,26 @@ var lintCommand = new Command("lint").description("Run all lint rules against co
|
|
|
121
336
|
}
|
|
122
337
|
}
|
|
123
338
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
339
|
+
if (useCache) {
|
|
340
|
+
const configContent = JSON.stringify(config) + JSON.stringify(opts.rule ?? {});
|
|
341
|
+
const hash = computeCacheHash(contextDir, configContent);
|
|
342
|
+
writeCache(rootDir, hash, allDiags);
|
|
343
|
+
}
|
|
344
|
+
const output = formatOutput(allDiags, format);
|
|
345
|
+
if (opts.outputFile) {
|
|
346
|
+
writeFileSync(path.resolve(opts.outputFile), output, "utf-8");
|
|
347
|
+
const errorCount = allDiags.filter((d) => d.severity === "error").length;
|
|
348
|
+
const warnCount2 = allDiags.filter((d) => d.severity === "warning").length;
|
|
349
|
+
console.log(`Results written to ${opts.outputFile} (${errorCount} error(s), ${warnCount2} warning(s))`);
|
|
126
350
|
} else {
|
|
127
|
-
console.log(
|
|
351
|
+
console.log(output);
|
|
352
|
+
}
|
|
353
|
+
const warnCount = allDiags.filter((d) => d.severity === "warning").length;
|
|
354
|
+
if (opts.maxWarnings !== void 0 && !isNaN(opts.maxWarnings) && warnCount > opts.maxWarnings) {
|
|
355
|
+
console.error(
|
|
356
|
+
chalk2.red(`Too many warnings: ${warnCount} (max allowed: ${opts.maxWarnings})`)
|
|
357
|
+
);
|
|
358
|
+
process.exit(1);
|
|
128
359
|
}
|
|
129
360
|
const hasErrors = allDiags.some((d) => d.severity === "error");
|
|
130
361
|
if (hasErrors) {
|
|
@@ -141,13 +372,13 @@ import { Command as Command2 } from "commander";
|
|
|
141
372
|
import chalk3 from "chalk";
|
|
142
373
|
import path2 from "path";
|
|
143
374
|
import fs from "fs";
|
|
144
|
-
import { compile as compile2, loadConfig
|
|
375
|
+
import { compile as compile2, loadConfig, emitManifest } from "@runcontext/core";
|
|
145
376
|
var buildCommand = new Command2("build").description("Compile context files and emit manifest JSON").option("--context-dir <path>", "Path to context directory").option("--output-dir <path>", "Path to output directory").option("--format <type>", "Output format: pretty or json", "pretty").action(async (opts) => {
|
|
146
377
|
try {
|
|
147
|
-
const config =
|
|
378
|
+
const config = loadConfig(process.cwd());
|
|
148
379
|
const contextDir = opts.contextDir ? path2.resolve(opts.contextDir) : path2.resolve(config.context_dir);
|
|
149
380
|
const outputDir = opts.outputDir ? path2.resolve(opts.outputDir) : path2.resolve(config.output_dir);
|
|
150
|
-
const { graph, diagnostics } = await compile2({ contextDir, config });
|
|
381
|
+
const { graph, diagnostics } = await compile2({ contextDir, config, rootDir: process.cwd() });
|
|
151
382
|
const errors = diagnostics.filter((d) => d.severity === "error");
|
|
152
383
|
if (errors.length > 0) {
|
|
153
384
|
if (opts.format === "json") {
|
|
@@ -181,12 +412,12 @@ var buildCommand = new Command2("build").description("Compile context files and
|
|
|
181
412
|
import { Command as Command3 } from "commander";
|
|
182
413
|
import chalk4 from "chalk";
|
|
183
414
|
import path3 from "path";
|
|
184
|
-
import { compile as compile3, loadConfig as
|
|
415
|
+
import { compile as compile3, loadConfig as loadConfig2, computeTier } from "@runcontext/core";
|
|
185
416
|
var tierCommand = new Command3("tier").description("Show tier scorecard for one or all models").argument("[model-name]", "Specific model name to check").option("--context-dir <path>", "Path to context directory").option("--format <type>", "Output format: pretty or json", "pretty").action(async (modelName, opts) => {
|
|
186
417
|
try {
|
|
187
|
-
const config =
|
|
418
|
+
const config = loadConfig2(process.cwd());
|
|
188
419
|
const contextDir = opts.contextDir ? path3.resolve(opts.contextDir) : path3.resolve(config.context_dir);
|
|
189
|
-
const { graph } = await compile3({ contextDir, config });
|
|
420
|
+
const { graph } = await compile3({ contextDir, config, rootDir: process.cwd() });
|
|
190
421
|
let scores;
|
|
191
422
|
if (modelName) {
|
|
192
423
|
if (!graph.models.has(modelName)) {
|
|
@@ -227,12 +458,12 @@ var tierCommand = new Command3("tier").description("Show tier scorecard for one
|
|
|
227
458
|
import { Command as Command4 } from "commander";
|
|
228
459
|
import chalk5 from "chalk";
|
|
229
460
|
import path4 from "path";
|
|
230
|
-
import { compile as compile4, loadConfig as
|
|
461
|
+
import { compile as compile4, loadConfig as loadConfig3 } from "@runcontext/core";
|
|
231
462
|
var explainCommand = new Command4("explain").description("Look up models, terms, or owners by name and show details").argument("<name>", "Name of a model, term, or owner to look up").option("--context-dir <path>", "Path to context directory").option("--format <type>", "Output format: pretty or json", "pretty").action(async (name, opts) => {
|
|
232
463
|
try {
|
|
233
|
-
const config =
|
|
464
|
+
const config = loadConfig3(process.cwd());
|
|
234
465
|
const contextDir = opts.contextDir ? path4.resolve(opts.contextDir) : path4.resolve(config.context_dir);
|
|
235
|
-
const { graph } = await compile4({ contextDir, config });
|
|
466
|
+
const { graph } = await compile4({ contextDir, config, rootDir: process.cwd() });
|
|
236
467
|
const results = [];
|
|
237
468
|
if (graph.models.has(name)) {
|
|
238
469
|
results.push({ type: "model", name, data: graph.models.get(name) });
|
|
@@ -283,16 +514,16 @@ import path5 from "path";
|
|
|
283
514
|
import fs2 from "fs";
|
|
284
515
|
import {
|
|
285
516
|
compile as compile5,
|
|
286
|
-
loadConfig as
|
|
517
|
+
loadConfig as loadConfig4,
|
|
287
518
|
LintEngine as LintEngine2,
|
|
288
519
|
ALL_RULES as ALL_RULES2,
|
|
289
|
-
applyFixes
|
|
520
|
+
applyFixes as applyFixes2
|
|
290
521
|
} from "@runcontext/core";
|
|
291
522
|
var fixCommand = new Command5("fix").description("Auto-fix lint issues").option("--context-dir <path>", "Path to context directory").option("--format <type>", "Output format: pretty or json", "pretty").option("--dry-run", "Show what would be fixed without writing files").action(async (opts) => {
|
|
292
523
|
try {
|
|
293
|
-
const config =
|
|
524
|
+
const config = loadConfig4(process.cwd());
|
|
294
525
|
const contextDir = opts.contextDir ? path5.resolve(opts.contextDir) : path5.resolve(config.context_dir);
|
|
295
|
-
const { graph } = await compile5({ contextDir, config });
|
|
526
|
+
const { graph } = await compile5({ contextDir, config, rootDir: process.cwd() });
|
|
296
527
|
const overrides = config.lint?.severity_overrides;
|
|
297
528
|
const engine = new LintEngine2(overrides);
|
|
298
529
|
for (const rule of ALL_RULES2) {
|
|
@@ -309,7 +540,7 @@ var fixCommand = new Command5("fix").description("Auto-fix lint issues").option(
|
|
|
309
540
|
return;
|
|
310
541
|
}
|
|
311
542
|
const readFile = (filePath) => fs2.readFileSync(filePath, "utf-8");
|
|
312
|
-
const fixedFiles =
|
|
543
|
+
const fixedFiles = applyFixes2(fixable, readFile);
|
|
313
544
|
if (opts.dryRun) {
|
|
314
545
|
if (opts.format === "json") {
|
|
315
546
|
const entries = [...fixedFiles.entries()].map(([file, content]) => ({
|
|
@@ -356,17 +587,25 @@ var fixCommand = new Command5("fix").description("Auto-fix lint issues").option(
|
|
|
356
587
|
import { Command as Command6 } from "commander";
|
|
357
588
|
import chalk7 from "chalk";
|
|
358
589
|
import path6 from "path";
|
|
590
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
359
591
|
import {
|
|
360
592
|
compile as compile6,
|
|
361
|
-
loadConfig as
|
|
593
|
+
loadConfig as loadConfig5,
|
|
362
594
|
LintEngine as LintEngine3,
|
|
363
|
-
ALL_RULES as ALL_RULES3
|
|
595
|
+
ALL_RULES as ALL_RULES3,
|
|
596
|
+
filterByDirectives as filterByDirectives2,
|
|
597
|
+
applyFixes as applyFixes3
|
|
364
598
|
} from "@runcontext/core";
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
599
|
+
function diagKey(d) {
|
|
600
|
+
return `${d.ruleId}|${d.location.file}:${d.location.line}:${d.location.column}|${d.message}`;
|
|
601
|
+
}
|
|
602
|
+
var previousDiags = /* @__PURE__ */ new Map();
|
|
603
|
+
async function runLint(contextDir, fix) {
|
|
604
|
+
const config = loadConfig5(process.cwd());
|
|
605
|
+
const { graph, diagnostics: compileDiags, directives } = await compile6({
|
|
368
606
|
contextDir,
|
|
369
|
-
config
|
|
607
|
+
config,
|
|
608
|
+
rootDir: process.cwd()
|
|
370
609
|
});
|
|
371
610
|
const overrides = config.lint?.severity_overrides;
|
|
372
611
|
const engine = new LintEngine3(overrides);
|
|
@@ -374,19 +613,68 @@ async function runLint(contextDir) {
|
|
|
374
613
|
engine.register(rule);
|
|
375
614
|
}
|
|
376
615
|
const lintDiags = engine.run(graph);
|
|
377
|
-
|
|
616
|
+
let allDiags = filterByDirectives2([...compileDiags, ...lintDiags], directives);
|
|
617
|
+
if (fix) {
|
|
618
|
+
const fixable = allDiags.filter((d) => d.fixable && d.fix);
|
|
619
|
+
if (fixable.length > 0) {
|
|
620
|
+
const fixes = applyFixes3(fixable, (filePath) => readFileSync2(filePath, "utf-8"));
|
|
621
|
+
for (const [file, content] of fixes) {
|
|
622
|
+
writeFileSync2(file, content, "utf-8");
|
|
623
|
+
}
|
|
624
|
+
const { graph: reGraph, diagnostics: reCompileDiags, directives: reDirs } = await compile6({
|
|
625
|
+
contextDir,
|
|
626
|
+
config,
|
|
627
|
+
rootDir: process.cwd()
|
|
628
|
+
});
|
|
629
|
+
const reEngine = new LintEngine3(overrides);
|
|
630
|
+
for (const rule of ALL_RULES3) {
|
|
631
|
+
reEngine.register(rule);
|
|
632
|
+
}
|
|
633
|
+
allDiags = filterByDirectives2([...reCompileDiags, ...reEngine.run(reGraph)], reDirs);
|
|
634
|
+
if (fixable.length > 0) {
|
|
635
|
+
console.log(chalk7.green(` Auto-fixed ${fixable.length} issue(s).`));
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
const currentDiags = /* @__PURE__ */ new Map();
|
|
640
|
+
for (const d of allDiags) {
|
|
641
|
+
currentDiags.set(diagKey(d), d);
|
|
642
|
+
}
|
|
643
|
+
const newIssues = [];
|
|
644
|
+
const resolved = [];
|
|
645
|
+
for (const [key, d] of currentDiags) {
|
|
646
|
+
if (!previousDiags.has(key)) newIssues.push(d);
|
|
647
|
+
}
|
|
648
|
+
for (const [key, d] of previousDiags) {
|
|
649
|
+
if (!currentDiags.has(key)) resolved.push(d);
|
|
650
|
+
}
|
|
378
651
|
console.clear();
|
|
379
652
|
console.log(chalk7.gray(`[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}] Linting...`));
|
|
653
|
+
if (previousDiags.size > 0) {
|
|
654
|
+
if (resolved.length > 0) {
|
|
655
|
+
console.log(chalk7.green(` ${resolved.length} issue(s) resolved`));
|
|
656
|
+
}
|
|
657
|
+
if (newIssues.length > 0) {
|
|
658
|
+
console.log(chalk7.red(` ${newIssues.length} new issue(s)`));
|
|
659
|
+
}
|
|
660
|
+
if (resolved.length === 0 && newIssues.length === 0) {
|
|
661
|
+
console.log(chalk7.gray(" No changes"));
|
|
662
|
+
}
|
|
663
|
+
console.log("");
|
|
664
|
+
}
|
|
380
665
|
console.log(formatDiagnostics(allDiags));
|
|
381
666
|
console.log("");
|
|
667
|
+
previousDiags = currentDiags;
|
|
382
668
|
}
|
|
383
|
-
var devCommand = new Command6("dev").description("Watch mode \u2014 re-run lint on file changes").option("--context-dir <path>", "Path to context directory").action(async (opts) => {
|
|
669
|
+
var devCommand = new Command6("dev").description("Watch mode \u2014 re-run lint on file changes").option("--context-dir <path>", "Path to context directory").option("--fix", "Auto-fix problems on each re-lint").action(async (opts) => {
|
|
384
670
|
try {
|
|
385
|
-
const config =
|
|
671
|
+
const config = loadConfig5(process.cwd());
|
|
386
672
|
const contextDir = opts.contextDir ? path6.resolve(opts.contextDir) : path6.resolve(config.context_dir);
|
|
673
|
+
const fix = opts.fix === true;
|
|
387
674
|
console.log(chalk7.blue(`Watching ${contextDir} for changes...`));
|
|
675
|
+
if (fix) console.log(chalk7.blue("Auto-fix enabled."));
|
|
388
676
|
console.log(chalk7.gray("Press Ctrl+C to stop.\n"));
|
|
389
|
-
await runLint(contextDir);
|
|
677
|
+
await runLint(contextDir, fix);
|
|
390
678
|
const { watch } = await import("chokidar");
|
|
391
679
|
let debounceTimer = null;
|
|
392
680
|
const watcher = watch(contextDir, {
|
|
@@ -399,7 +687,7 @@ var devCommand = new Command6("dev").description("Watch mode \u2014 re-run lint
|
|
|
399
687
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
400
688
|
debounceTimer = setTimeout(async () => {
|
|
401
689
|
try {
|
|
402
|
-
await runLint(contextDir);
|
|
690
|
+
await runLint(contextDir, fix);
|
|
403
691
|
} catch (err) {
|
|
404
692
|
console.error(
|
|
405
693
|
chalk7.red(`Lint error: ${err.message}`)
|
|
@@ -553,12 +841,12 @@ var initCommand = new Command7("init").description("Scaffold a v0.2 ContextKit p
|
|
|
553
841
|
import { Command as Command8 } from "commander";
|
|
554
842
|
import chalk9 from "chalk";
|
|
555
843
|
import path8 from "path";
|
|
556
|
-
import { compile as compile7, loadConfig as
|
|
844
|
+
import { compile as compile7, loadConfig as loadConfig6, emitManifest as emitManifest2 } from "@runcontext/core";
|
|
557
845
|
var siteCommand = new Command8("site").description("Build a static documentation site from compiled context").option("--context-dir <path>", "Path to context directory").option("--output-dir <path>", "Path to site output directory").action(async (opts) => {
|
|
558
846
|
try {
|
|
559
|
-
const config =
|
|
847
|
+
const config = loadConfig6(process.cwd());
|
|
560
848
|
const contextDir = opts.contextDir ? path8.resolve(opts.contextDir) : path8.resolve(config.context_dir);
|
|
561
|
-
const { graph } = await compile7({ contextDir, config });
|
|
849
|
+
const { graph } = await compile7({ contextDir, config, rootDir: process.cwd() });
|
|
562
850
|
const manifest = emitManifest2(graph, config);
|
|
563
851
|
let buildSite;
|
|
564
852
|
try {
|
|
@@ -662,9 +950,72 @@ var validateOsiCommand = new Command10("validate-osi").description("Validate a s
|
|
|
662
950
|
}
|
|
663
951
|
});
|
|
664
952
|
|
|
953
|
+
// src/commands/rules.ts
|
|
954
|
+
import { Command as Command11 } from "commander";
|
|
955
|
+
import chalk12 from "chalk";
|
|
956
|
+
import { ALL_RULES as ALL_RULES4 } from "@runcontext/core";
|
|
957
|
+
function formatRuleTable(rules) {
|
|
958
|
+
if (rules.length === 0) {
|
|
959
|
+
return chalk12.gray("No rules match the filters.");
|
|
960
|
+
}
|
|
961
|
+
const lines = [];
|
|
962
|
+
const header = `${"ID".padEnd(40)} ${"Tier".padEnd(8)} ${"Severity".padEnd(10)} ${"Fix".padEnd(5)} Description`;
|
|
963
|
+
lines.push(chalk12.bold(header));
|
|
964
|
+
lines.push(chalk12.gray("\u2500".repeat(100)));
|
|
965
|
+
for (const rule of rules) {
|
|
966
|
+
const tier = rule.tier ?? "\u2014";
|
|
967
|
+
const tierCol = colorTier(tier);
|
|
968
|
+
const fixCol = rule.fixable ? chalk12.green("yes") : chalk12.gray("no");
|
|
969
|
+
const sevCol = rule.defaultSeverity === "error" ? chalk12.red(rule.defaultSeverity) : chalk12.yellow(rule.defaultSeverity);
|
|
970
|
+
const deprecated = rule.deprecated ? chalk12.gray(" (deprecated)") : "";
|
|
971
|
+
lines.push(
|
|
972
|
+
`${rule.id.padEnd(40)} ${tierCol.padEnd(8 + (tierCol.length - tier.length))} ${sevCol.padEnd(10 + (sevCol.length - rule.defaultSeverity.length))} ${fixCol.padEnd(5 + (fixCol.length - (rule.fixable ? 3 : 2)))} ${rule.description}${deprecated}`
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
lines.push("");
|
|
976
|
+
lines.push(chalk12.gray(`${rules.length} rule(s) total`));
|
|
977
|
+
return lines.join("\n");
|
|
978
|
+
}
|
|
979
|
+
function colorTier(tier) {
|
|
980
|
+
switch (tier) {
|
|
981
|
+
case "gold":
|
|
982
|
+
return chalk12.yellow(tier);
|
|
983
|
+
case "silver":
|
|
984
|
+
return chalk12.white(tier);
|
|
985
|
+
case "bronze":
|
|
986
|
+
return chalk12.hex("#CD7F32")(tier);
|
|
987
|
+
default:
|
|
988
|
+
return chalk12.gray(tier);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
var rulesCommand = new Command11("rules").description("List all lint rules with metadata").option("--tier <tier>", "Filter by tier: bronze, silver, gold").option("--fixable", "Show only fixable rules").option("--format <type>", "Output format: pretty or json", "pretty").action((opts) => {
|
|
992
|
+
let rules = [...ALL_RULES4];
|
|
993
|
+
if (opts.tier) {
|
|
994
|
+
const tier = opts.tier;
|
|
995
|
+
rules = rules.filter((r) => r.tier === tier);
|
|
996
|
+
}
|
|
997
|
+
if (opts.fixable) {
|
|
998
|
+
rules = rules.filter((r) => r.fixable);
|
|
999
|
+
}
|
|
1000
|
+
if (opts.format === "json") {
|
|
1001
|
+
const data = rules.map((r) => ({
|
|
1002
|
+
id: r.id,
|
|
1003
|
+
tier: r.tier ?? null,
|
|
1004
|
+
defaultSeverity: r.defaultSeverity,
|
|
1005
|
+
fixable: r.fixable,
|
|
1006
|
+
description: r.description,
|
|
1007
|
+
deprecated: r.deprecated ?? false,
|
|
1008
|
+
replacedBy: r.replacedBy ?? null
|
|
1009
|
+
}));
|
|
1010
|
+
console.log(formatJson(data));
|
|
1011
|
+
} else {
|
|
1012
|
+
console.log(formatRuleTable(rules));
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
|
|
665
1016
|
// src/index.ts
|
|
666
|
-
var program = new
|
|
667
|
-
program.name("context").description("ContextKit \u2014 AI-ready metadata governance over OSI").version("0.2.
|
|
1017
|
+
var program = new Command12();
|
|
1018
|
+
program.name("context").description("ContextKit \u2014 AI-ready metadata governance over OSI").version("0.2.1");
|
|
668
1019
|
program.addCommand(lintCommand);
|
|
669
1020
|
program.addCommand(buildCommand);
|
|
670
1021
|
program.addCommand(tierCommand);
|
|
@@ -675,5 +1026,6 @@ program.addCommand(initCommand);
|
|
|
675
1026
|
program.addCommand(siteCommand);
|
|
676
1027
|
program.addCommand(serveCommand);
|
|
677
1028
|
program.addCommand(validateOsiCommand);
|
|
1029
|
+
program.addCommand(rulesCommand);
|
|
678
1030
|
program.parse();
|
|
679
1031
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/lint.ts","../src/formatters/pretty.ts","../src/formatters/json.ts","../src/commands/build.ts","../src/commands/tier.ts","../src/commands/explain.ts","../src/commands/fix.ts","../src/commands/dev.ts","../src/commands/init.ts","../src/commands/site.ts","../src/commands/serve.ts","../src/commands/validate-osi.ts"],"sourcesContent":["// ContextKit CLI v0.2\n\nimport { Command } from 'commander';\nimport { lintCommand } from './commands/lint.js';\nimport { buildCommand } from './commands/build.js';\nimport { tierCommand } from './commands/tier.js';\nimport { explainCommand } from './commands/explain.js';\nimport { fixCommand } from './commands/fix.js';\nimport { devCommand } from './commands/dev.js';\nimport { initCommand } from './commands/init.js';\nimport { siteCommand } from './commands/site.js';\nimport { serveCommand } from './commands/serve.js';\nimport { validateOsiCommand } from './commands/validate-osi.js';\n\nconst program = new Command();\n\nprogram\n .name('context')\n .description('ContextKit — AI-ready metadata governance over OSI')\n .version('0.2.0');\n\n// Register all commands\nprogram.addCommand(lintCommand);\nprogram.addCommand(buildCommand);\nprogram.addCommand(tierCommand);\nprogram.addCommand(explainCommand);\nprogram.addCommand(fixCommand);\nprogram.addCommand(devCommand);\nprogram.addCommand(initCommand);\nprogram.addCommand(siteCommand);\nprogram.addCommand(serveCommand);\nprogram.addCommand(validateOsiCommand);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport {\n compile,\n loadConfig,\n LintEngine,\n ALL_RULES,\n type Diagnostic,\n type Severity,\n type MetadataTier,\n} from '@runcontext/core';\nimport { formatDiagnostics } from '../formatters/pretty.js';\nimport { formatJson } from '../formatters/json.js';\n\nexport const lintCommand = new Command('lint')\n .description('Run all lint rules against context files')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n // Compile the context graph\n const { graph, diagnostics: compileDiags } = await compile({\n contextDir,\n config,\n });\n\n // Run lint engine\n const overrides = config.lint?.severity_overrides as\n | Record<string, Severity | 'off'>\n | undefined;\n const engine = new LintEngine(overrides);\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n const lintDiags = engine.run(graph);\n\n // Merge compile diagnostics with lint diagnostics\n const allDiags: Diagnostic[] = [...compileDiags, ...lintDiags];\n\n // Enforce minimum_tier policy\n if (config.minimum_tier) {\n const tierOrder: MetadataTier[] = ['none', 'bronze', 'silver', 'gold'];\n const minIdx = tierOrder.indexOf(config.minimum_tier);\n for (const [modelName, score] of graph.tiers) {\n const actualIdx = tierOrder.indexOf(score.tier);\n if (actualIdx < minIdx) {\n allDiags.push({\n ruleId: 'tier/minimum-tier',\n severity: 'error',\n message: `Model \"${modelName}\" is tier \"${score.tier}\" but minimum_tier is \"${config.minimum_tier}\"`,\n location: { file: `model:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n // Output results\n if (opts.format === 'json') {\n console.log(formatJson(allDiags));\n } else {\n console.log(formatDiagnostics(allDiags));\n }\n\n // Exit with code 1 if there are errors\n const hasErrors = allDiags.some((d) => d.severity === 'error');\n if (hasErrors) {\n process.exit(1);\n }\n } catch (err) {\n console.error(chalk.red(`Lint failed: ${(err as Error).message}`));\n process.exit(1);\n }\n });\n","import chalk from 'chalk';\nimport type { Diagnostic, TierScore, TierCheckResult } from '@runcontext/core';\n\n/**\n * Format an array of diagnostics as colorized, human-readable text.\n */\nexport function formatDiagnostics(diagnostics: Diagnostic[]): string {\n if (diagnostics.length === 0) {\n return chalk.green('No issues found.');\n }\n\n const lines: string[] = [];\n\n for (const d of diagnostics) {\n const icon =\n d.severity === 'error' ? chalk.red('error') : chalk.yellow('warning');\n const loc = chalk.gray(\n `${d.location.file}:${d.location.line}:${d.location.column}`,\n );\n const rule = chalk.gray(`[${d.ruleId}]`);\n const fixTag = d.fixable ? chalk.blue(' (fixable)') : '';\n\n lines.push(` ${icon} ${d.message} ${rule}${fixTag}`);\n lines.push(` ${loc}`);\n }\n\n const errorCount = diagnostics.filter((d) => d.severity === 'error').length;\n const warnCount = diagnostics.filter((d) => d.severity === 'warning').length;\n\n lines.push('');\n const parts: string[] = [];\n if (errorCount > 0) parts.push(chalk.red(`${errorCount} error(s)`));\n if (warnCount > 0) parts.push(chalk.yellow(`${warnCount} warning(s)`));\n lines.push(parts.join(', '));\n\n return lines.join('\\n');\n}\n\n/**\n * Format a tier score as colorized, human-readable text.\n */\nexport function formatTierScore(score: TierScore): string {\n const lines: string[] = [];\n\n const tierColor = getTierColor(score.tier);\n lines.push(\n `${chalk.bold(score.model)}: ${tierColor(score.tier.toUpperCase())}`,\n );\n lines.push('');\n\n lines.push(formatTierSection('Bronze', score.bronze.passed, score.bronze.checks));\n lines.push(formatTierSection('Silver', score.silver.passed, score.silver.checks));\n lines.push(formatTierSection('Gold', score.gold.passed, score.gold.checks));\n\n return lines.join('\\n');\n}\n\nfunction formatTierSection(\n label: string,\n passed: boolean,\n checks: TierCheckResult[],\n): string {\n const lines: string[] = [];\n const status = passed ? chalk.green('PASS') : chalk.red('FAIL');\n lines.push(` ${label}: ${status}`);\n\n for (const check of checks) {\n const icon = check.passed ? chalk.green(' +') : chalk.red(' -');\n lines.push(` ${icon} ${check.label}`);\n if (check.detail && !check.passed) {\n lines.push(chalk.gray(` ${check.detail}`));\n }\n }\n\n return lines.join('\\n');\n}\n\nfunction getTierColor(tier: string): (text: string) => string {\n switch (tier) {\n case 'gold':\n return chalk.yellow;\n case 'silver':\n return chalk.white;\n case 'bronze':\n return chalk.hex('#CD7F32');\n default:\n return chalk.gray;\n }\n}\n\n/**\n * Format a generic info message.\n */\nexport function formatInfo(message: string): string {\n return chalk.blue(message);\n}\n\n/**\n * Format an error message.\n */\nexport function formatError(message: string): string {\n return chalk.red(`Error: ${message}`);\n}\n\n/**\n * Format a success message.\n */\nexport function formatSuccess(message: string): string {\n return chalk.green(message);\n}\n","/**\n * Format any value as pretty-printed JSON.\n */\nexport function formatJson(data: unknown): string {\n return JSON.stringify(data, null, 2);\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { compile, loadConfig, emitManifest } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\nimport { formatSuccess, formatError } from '../formatters/pretty.js';\n\nexport const buildCommand = new Command('build')\n .description('Compile context files and emit manifest JSON')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--output-dir <path>', 'Path to output directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n const outputDir = opts.outputDir\n ? path.resolve(opts.outputDir)\n : path.resolve(config.output_dir);\n\n // Compile the context graph\n const { graph, diagnostics } = await compile({ contextDir, config });\n\n // Check for compile errors\n const errors = diagnostics.filter((d) => d.severity === 'error');\n if (errors.length > 0) {\n if (opts.format === 'json') {\n console.log(formatJson({ success: false, errors }));\n } else {\n console.error(\n chalk.red(`Build failed with ${errors.length} error(s):`),\n );\n for (const e of errors) {\n console.error(chalk.red(` - ${e.message} [${e.ruleId}]`));\n }\n }\n process.exit(1);\n }\n\n // Emit manifest\n const manifest = emitManifest(graph, config);\n\n // Write to output directory\n fs.mkdirSync(outputDir, { recursive: true });\n const outputPath = path.join(outputDir, 'contextkit-manifest.json');\n fs.writeFileSync(outputPath, JSON.stringify(manifest, null, 2), 'utf-8');\n\n if (opts.format === 'json') {\n console.log(formatJson({ success: true, outputPath, manifest }));\n } else {\n console.log(formatSuccess(`Manifest written to ${outputPath}`));\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { compile, loadConfig, computeTier, type TierScore } from '@runcontext/core';\nimport { formatTierScore, formatError } from '../formatters/pretty.js';\nimport { formatJson } from '../formatters/json.js';\n\nexport const tierCommand = new Command('tier')\n .description('Show tier scorecard for one or all models')\n .argument('[model-name]', 'Specific model name to check')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (modelName: string | undefined, opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n const { graph } = await compile({ contextDir, config });\n\n let scores: TierScore[];\n\n if (modelName) {\n // Single model\n if (!graph.models.has(modelName)) {\n console.error(formatError(`Model '${modelName}' not found.`));\n const available = [...graph.models.keys()].join(', ');\n if (available) {\n console.error(chalk.gray(`Available models: ${available}`));\n }\n process.exit(1);\n }\n scores = [computeTier(modelName, graph)];\n } else {\n // All models\n scores = [...graph.models.keys()].map((name) =>\n computeTier(name, graph),\n );\n }\n\n if (scores.length === 0) {\n console.log(\n opts.format === 'json'\n ? formatJson([])\n : chalk.yellow('No models found.'),\n );\n return;\n }\n\n if (opts.format === 'json') {\n console.log(formatJson(scores));\n } else {\n for (const score of scores) {\n console.log(formatTierScore(score));\n console.log('');\n }\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { compile, loadConfig } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\nimport { formatError } from '../formatters/pretty.js';\n\nexport const explainCommand = new Command('explain')\n .description('Look up models, terms, or owners by name and show details')\n .argument('<name>', 'Name of a model, term, or owner to look up')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (name: string, opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n const { graph } = await compile({ contextDir, config });\n\n const results: Array<{ type: string; name: string; data: unknown }> = [];\n\n // Search models\n if (graph.models.has(name)) {\n results.push({ type: 'model', name, data: graph.models.get(name) });\n }\n\n // Search terms\n if (graph.terms.has(name)) {\n results.push({ type: 'term', name, data: graph.terms.get(name) });\n }\n\n // Search owners\n if (graph.owners.has(name)) {\n results.push({ type: 'owner', name, data: graph.owners.get(name) });\n }\n\n // Search governance\n if (graph.governance.has(name)) {\n results.push({\n type: 'governance',\n name,\n data: graph.governance.get(name),\n });\n }\n\n // Search rules\n if (graph.rules.has(name)) {\n results.push({ type: 'rules', name, data: graph.rules.get(name) });\n }\n\n // Search lineage\n if (graph.lineage.has(name)) {\n results.push({ type: 'lineage', name, data: graph.lineage.get(name) });\n }\n\n if (results.length === 0) {\n console.error(formatError(`No matching entity found for '${name}'.`));\n process.exit(1);\n }\n\n if (opts.format === 'json') {\n console.log(formatJson(results));\n } else {\n for (const result of results) {\n console.log(chalk.bold(`${result.type}: ${result.name}`));\n console.log(chalk.gray('---'));\n console.log(JSON.stringify(result.data, null, 2));\n console.log('');\n }\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport {\n compile,\n loadConfig,\n LintEngine,\n ALL_RULES,\n applyFixes,\n type Severity,\n} from '@runcontext/core';\nimport { formatSuccess, formatError } from '../formatters/pretty.js';\nimport { formatJson } from '../formatters/json.js';\n\nexport const fixCommand = new Command('fix')\n .description('Auto-fix lint issues')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .option('--dry-run', 'Show what would be fixed without writing files')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n // Compile and lint\n const { graph } = await compile({ contextDir, config });\n\n const overrides = config.lint?.severity_overrides as\n | Record<string, Severity | 'off'>\n | undefined;\n const engine = new LintEngine(overrides);\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n const diagnostics = engine.run(graph);\n\n const fixable = diagnostics.filter((d) => d.fixable);\n\n if (fixable.length === 0) {\n if (opts.format === 'json') {\n console.log(formatJson({ fixedFiles: [], fixCount: 0 }));\n } else {\n console.log(chalk.green('No fixable issues found.'));\n }\n return;\n }\n\n // Apply fixes\n const readFile = (filePath: string) =>\n fs.readFileSync(filePath, 'utf-8');\n const fixedFiles = applyFixes(fixable, readFile);\n\n if (opts.dryRun) {\n if (opts.format === 'json') {\n const entries = [...fixedFiles.entries()].map(([file, content]) => ({\n file,\n content,\n }));\n console.log(\n formatJson({ dryRun: true, fixCount: fixable.length, entries }),\n );\n } else {\n console.log(\n chalk.yellow(`Dry run: ${fixable.length} issue(s) would be fixed in ${fixedFiles.size} file(s):`),\n );\n for (const file of fixedFiles.keys()) {\n console.log(chalk.gray(` ${file}`));\n }\n }\n return;\n }\n\n // Write fixed files\n for (const [file, content] of fixedFiles) {\n fs.writeFileSync(file, content, 'utf-8');\n }\n\n if (opts.format === 'json') {\n console.log(\n formatJson({\n fixedFiles: [...fixedFiles.keys()],\n fixCount: fixable.length,\n }),\n );\n } else {\n console.log(\n formatSuccess(\n `Fixed ${fixable.length} issue(s) in ${fixedFiles.size} file(s).`,\n ),\n );\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport {\n compile,\n loadConfig,\n LintEngine,\n ALL_RULES,\n type Severity,\n} from '@runcontext/core';\nimport { formatDiagnostics } from '../formatters/pretty.js';\n\nasync function runLint(contextDir: string): Promise<void> {\n const config = loadConfig(process.cwd());\n\n const { graph, diagnostics: compileDiags } = await compile({\n contextDir,\n config,\n });\n\n const overrides = config.lint?.severity_overrides as\n | Record<string, Severity | 'off'>\n | undefined;\n const engine = new LintEngine(overrides);\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n const lintDiags = engine.run(graph);\n const allDiags = [...compileDiags, ...lintDiags];\n\n console.clear();\n console.log(chalk.gray(`[${new Date().toLocaleTimeString()}] Linting...`));\n console.log(formatDiagnostics(allDiags));\n console.log('');\n}\n\nexport const devCommand = new Command('dev')\n .description('Watch mode — re-run lint on file changes')\n .option('--context-dir <path>', 'Path to context directory')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n console.log(chalk.blue(`Watching ${contextDir} for changes...`));\n console.log(chalk.gray('Press Ctrl+C to stop.\\n'));\n\n // Initial lint run\n await runLint(contextDir);\n\n // Dynamic import of chokidar for watch mode\n const { watch } = await import('chokidar');\n\n let debounceTimer: ReturnType<typeof setTimeout> | null = null;\n\n const watcher = watch(contextDir, {\n ignored: /(^|[/\\\\])\\../, // ignore dotfiles\n persistent: true,\n ignoreInitial: true,\n });\n\n watcher.on('all', (_event, _filePath) => {\n if (debounceTimer) clearTimeout(debounceTimer);\n debounceTimer = setTimeout(async () => {\n try {\n await runLint(contextDir);\n } catch (err) {\n console.error(\n chalk.red(`Lint error: ${(err as Error).message}`),\n );\n }\n }, 300);\n });\n } catch (err) {\n console.error(chalk.red(`Dev mode failed: ${(err as Error).message}`));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { formatSuccess, formatError } from '../formatters/pretty.js';\n\nconst EXAMPLE_OSI = `version: \"1.0\"\n\nsemantic_model:\n - name: example-model\n description: An example semantic model\n ai_context:\n instructions: \"Use this model for general analytics queries\"\n synonyms: [\"example\", \"sample model\"]\n\n datasets:\n - name: example_table\n source: warehouse.public.example_table\n primary_key: [id]\n description: \"Example table\"\n fields:\n - name: id\n expression:\n dialects:\n - dialect: ANSI_SQL\n expression: id\n description: \"Primary key\"\n type: number\n - name: name\n expression:\n dialects:\n - dialect: ANSI_SQL\n expression: name\n description: \"Name field\"\n type: string\n`;\n\nconst EXAMPLE_GOVERNANCE = `model: example-model\nowner: data-team\nclassification: internal\nsecurity:\n pii: false\n access_level: internal\ndatasets:\n example_table:\n grain: one row per example entity\n fields:\n id:\n description: \"Primary key\"\n name:\n description: \"Name field\"\n`;\n\nconst EXAMPLE_TERM = `glossary:\n - term: Example Term\n definition: A sample glossary term to demonstrate the format\n aliases: [\"sample term\"]\n owner: data-team\n`;\n\nconst EXAMPLE_OWNER = `team: data-team\nname: Data Team\nemail: data-team@example.com\nslack: \"#data-team\"\nmembers:\n - name: Jane Doe\n role: lead\n`;\n\nconst EXAMPLE_CONFIG = `context_dir: context\noutput_dir: dist\nminimum_tier: bronze\n`;\n\nexport const initCommand = new Command('init')\n .description('Scaffold a v0.2 ContextKit project structure')\n .option('--dir <path>', 'Root directory for the project', '.')\n .action(async (opts) => {\n try {\n const rootDir = path.resolve(opts.dir);\n const contextDir = path.join(rootDir, 'context');\n\n // Create directory structure\n const dirs = [\n path.join(contextDir, 'models'),\n path.join(contextDir, 'governance'),\n path.join(contextDir, 'glossary'),\n path.join(contextDir, 'owners'),\n ];\n\n for (const dir of dirs) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n // Write example files (only if they don't already exist)\n const files: Array<{ path: string; content: string }> = [\n {\n path: path.join(contextDir, 'models', 'example-model.osi.yaml'),\n content: EXAMPLE_OSI,\n },\n {\n path: path.join(\n contextDir,\n 'governance',\n 'example-model.governance.yaml',\n ),\n content: EXAMPLE_GOVERNANCE,\n },\n {\n path: path.join(contextDir, 'glossary', 'glossary.term.yaml'),\n content: EXAMPLE_TERM,\n },\n {\n path: path.join(contextDir, 'owners', 'data-team.owner.yaml'),\n content: EXAMPLE_OWNER,\n },\n {\n path: path.join(rootDir, 'contextkit.config.yaml'),\n content: EXAMPLE_CONFIG,\n },\n ];\n\n let created = 0;\n let skipped = 0;\n\n for (const file of files) {\n if (fs.existsSync(file.path)) {\n console.log(chalk.gray(` skip ${path.relative(rootDir, file.path)} (exists)`));\n skipped++;\n } else {\n fs.writeFileSync(file.path, file.content, 'utf-8');\n console.log(chalk.green(` create ${path.relative(rootDir, file.path)}`));\n created++;\n }\n }\n\n console.log('');\n console.log(\n formatSuccess(\n `Initialized ContextKit project: ${created} file(s) created, ${skipped} skipped.`,\n ),\n );\n console.log('');\n console.log(chalk.gray('Next steps:'));\n console.log(chalk.gray(' 1. Edit the example files in context/'));\n console.log(chalk.gray(' 2. Run: context lint'));\n console.log(chalk.gray(' 3. Run: context build'));\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { compile, loadConfig, emitManifest } from '@runcontext/core';\nimport { formatError } from '../formatters/pretty.js';\n\nexport const siteCommand = new Command('site')\n .description('Build a static documentation site from compiled context')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--output-dir <path>', 'Path to site output directory')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n // Compile the context graph\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n\n // Try to import the site generator\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic import\n let buildSite: ((...args: any[]) => Promise<void>) | undefined;\n try {\n const siteModule = await import('@runcontext/site');\n buildSite = siteModule.buildSite;\n } catch {\n // @runcontext/site not yet implemented\n }\n\n if (!buildSite) {\n console.log(\n chalk.yellow(\n 'Site generator is not yet available. Install @runcontext/site to enable this command.',\n ),\n );\n process.exit(0);\n }\n\n const outputDir = opts.outputDir\n ? path.resolve(opts.outputDir)\n : path.resolve(config.site?.base_path ?? 'site');\n\n await buildSite(manifest, config, outputDir);\n console.log(chalk.green(`Site built to ${outputDir}`));\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { formatError } from '../formatters/pretty.js';\n\nexport const serveCommand = new Command('serve')\n .description('Start the MCP server (stdio transport)')\n .option('--context-dir <path>', 'Path to context directory')\n .action(async (opts) => {\n try {\n // Dynamic import — @runcontext/mcp is an optional peer\n let startServer: ((options?: { contextDir?: string; rootDir?: string }) => Promise<unknown>) | undefined;\n try {\n const mcpModule = await import('@runcontext/mcp');\n startServer = mcpModule.startServer;\n } catch {\n // @runcontext/mcp not installed\n }\n\n if (!startServer) {\n console.log(\n chalk.yellow(\n 'MCP server is not available. Install @runcontext/mcp to enable this command.',\n ),\n );\n process.exit(1);\n }\n\n console.log(chalk.blue('Starting MCP server (stdio transport)...'));\n await startServer({\n contextDir: opts.contextDir,\n rootDir: process.cwd(),\n });\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { parseFile, osiDocumentSchema } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\nimport { formatError, formatSuccess } from '../formatters/pretty.js';\n\nexport const validateOsiCommand = new Command('validate-osi')\n .description('Validate a single OSI file against the schema')\n .argument('<file>', 'Path to the OSI YAML file')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (file: string, opts) => {\n try {\n const filePath = path.resolve(file);\n\n // Parse the file\n const parsed = await parseFile(filePath, 'model');\n\n // Validate against the schema\n const result = osiDocumentSchema.safeParse(parsed.data);\n\n if (result.success) {\n if (opts.format === 'json') {\n console.log(\n formatJson({\n valid: true,\n file: filePath,\n data: result.data,\n }),\n );\n } else {\n console.log(formatSuccess(`${filePath} is valid.`));\n }\n } else {\n const issues = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }));\n\n if (opts.format === 'json') {\n console.log(\n formatJson({\n valid: false,\n file: filePath,\n issues,\n }),\n );\n } else {\n console.error(chalk.red(`Validation failed for ${filePath}:`));\n for (const issue of issues) {\n console.error(chalk.red(` ${issue.path}: ${issue.message}`));\n }\n }\n process.exit(1);\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n"],"mappings":";;;AAEA,SAAS,WAAAA,iBAAe;;;ACFxB,SAAS,eAAe;AACxB,OAAOC,YAAW;AAClB,OAAO,UAAU;AACjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;;;ACXP,OAAO,WAAW;AAMX,SAAS,kBAAkB,aAAmC;AACnE,MAAI,YAAY,WAAW,GAAG;AAC5B,WAAO,MAAM,MAAM,kBAAkB;AAAA,EACvC;AAEA,QAAM,QAAkB,CAAC;AAEzB,aAAW,KAAK,aAAa;AAC3B,UAAM,OACJ,EAAE,aAAa,UAAU,MAAM,IAAI,OAAO,IAAI,MAAM,OAAO,SAAS;AACtE,UAAM,MAAM,MAAM;AAAA,MAChB,GAAG,EAAE,SAAS,IAAI,IAAI,EAAE,SAAS,IAAI,IAAI,EAAE,SAAS,MAAM;AAAA,IAC5D;AACA,UAAM,OAAO,MAAM,KAAK,IAAI,EAAE,MAAM,GAAG;AACvC,UAAM,SAAS,EAAE,UAAU,MAAM,KAAK,YAAY,IAAI;AAEtD,UAAM,KAAK,KAAK,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,GAAG,MAAM,EAAE;AACpD,UAAM,KAAK,OAAO,GAAG,EAAE;AAAA,EACzB;AAEA,QAAM,aAAa,YAAY,OAAO,CAAC,MAAM,EAAE,aAAa,OAAO,EAAE;AACrE,QAAM,YAAY,YAAY,OAAO,CAAC,MAAM,EAAE,aAAa,SAAS,EAAE;AAEtE,QAAM,KAAK,EAAE;AACb,QAAM,QAAkB,CAAC;AACzB,MAAI,aAAa,EAAG,OAAM,KAAK,MAAM,IAAI,GAAG,UAAU,WAAW,CAAC;AAClE,MAAI,YAAY,EAAG,OAAM,KAAK,MAAM,OA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IAAc,OAAO,CAAC;AACjD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;;;AZ7CH,IAAM,UAAU,IAAIC,UAAQ;AAE5B,QACG,KAAK,SAAS,EACd,YAAY,yDAAoD,EAChE,QAAQ,OAAO;AAGlB,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,cAAc;AACjC,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,kBAAkB;AAErC,QAAQ,MAAM;","names":["Command","chalk","chalk","Command","chalk","path","compile","loadConfig","Command","loadConfig","path","compile","chalk","Command","chalk","path","compile","loadConfig","Command","loadConfig","path","compile","chalk","Command","chalk","path","compile","loadConfig","Command","loadConfig","path","compile","chalk","Command","chalk","path","fs","compile","loadConfig","LintEngine","ALL_RULES","Command","loadConfig","path","compile","LintEngine","ALL_RULES","chalk","fs","Command","chalk","path","compile","loadConfig","LintEngine","ALL_RULES","loadConfig","compile","LintEngine","ALL_RULES","chalk","Command","path","Command","chalk","path","fs","Command","path","fs","chalk","Command","chalk","path","compile","loadConfig","emitManifest","Command","loadConfig","path","compile","emitManifest","chalk","Command","chalk","Command","chalk","Command","chalk","path","Command","path","chalk","Command"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/lint.ts","../src/formatters/pretty.ts","../src/formatters/json.ts","../src/formatters/sarif.ts","../src/formatters/github.ts","../src/formatters/junit.ts","../src/commands/build.ts","../src/commands/tier.ts","../src/commands/explain.ts","../src/commands/fix.ts","../src/commands/dev.ts","../src/commands/init.ts","../src/commands/site.ts","../src/commands/serve.ts","../src/commands/validate-osi.ts","../src/commands/rules.ts"],"sourcesContent":["// ContextKit CLI v0.2\n\nimport { Command } from 'commander';\nimport { lintCommand } from './commands/lint.js';\nimport { buildCommand } from './commands/build.js';\nimport { tierCommand } from './commands/tier.js';\nimport { explainCommand } from './commands/explain.js';\nimport { fixCommand } from './commands/fix.js';\nimport { devCommand } from './commands/dev.js';\nimport { initCommand } from './commands/init.js';\nimport { siteCommand } from './commands/site.js';\nimport { serveCommand } from './commands/serve.js';\nimport { validateOsiCommand } from './commands/validate-osi.js';\nimport { rulesCommand } from './commands/rules.js';\n\nconst program = new Command();\n\nprogram\n .name('context')\n .description('ContextKit — AI-ready metadata governance over OSI')\n .version('0.2.1');\n\n// Register all commands\nprogram.addCommand(lintCommand);\nprogram.addCommand(buildCommand);\nprogram.addCommand(tierCommand);\nprogram.addCommand(explainCommand);\nprogram.addCommand(fixCommand);\nprogram.addCommand(devCommand);\nprogram.addCommand(initCommand);\nprogram.addCommand(siteCommand);\nprogram.addCommand(serveCommand);\nprogram.addCommand(validateOsiCommand);\nprogram.addCommand(rulesCommand);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport {\n compile,\n loadConfigAsync,\n LintEngine,\n ALL_RULES,\n filterByDirectives,\n applyFixes,\n loadPlugins,\n computeCacheHash,\n readCache,\n writeCache,\n type Diagnostic,\n type Severity,\n type MetadataTier,\n} from '@runcontext/core';\nimport { formatDiagnostics } from '../formatters/pretty.js';\nimport { formatJson } from '../formatters/json.js';\nimport { formatSarif } from '../formatters/sarif.js';\nimport { formatGitHub } from '../formatters/github.js';\nimport { formatJUnit } from '../formatters/junit.js';\n\ntype FormatType = 'pretty' | 'json' | 'sarif' | 'github' | 'junit';\n\nconst VALID_FORMATS: FormatType[] = ['pretty', 'json', 'sarif', 'github', 'junit'];\n\n/**\n * Detect the best default format based on CI environment.\n */\nfunction detectFormat(): FormatType {\n if (process.env.GITHUB_ACTIONS) return 'github';\n if (process.env.CI) return 'json';\n return 'pretty';\n}\n\n/**\n * Parse --rule overrides: \"ruleId:severity\" pairs.\n * Accumulates across multiple --rule flags.\n */\nfunction collectRule(value: string, previous: Record<string, string>): Record<string, string> {\n const lastColon = value.lastIndexOf(':');\n if (lastColon === -1) {\n throw new Error(`Invalid --rule format: \"${value}\". Expected \"ruleId:severity\" (e.g., \"governance/grain-required:error\")`);\n }\n const ruleId = value.slice(0, lastColon);\n const severity = value.slice(lastColon + 1);\n if (!['error', 'warning', 'off'].includes(severity)) {\n throw new Error(`Invalid severity \"${severity}\" in --rule \"${value}\". Must be error, warning, or off.`);\n }\n previous[ruleId] = severity;\n return previous;\n}\n\n/**\n * Format diagnostics using the specified format.\n */\nfunction formatOutput(diagnostics: Diagnostic[], format: FormatType): string {\n switch (format) {\n case 'json':\n return formatJson(diagnostics);\n case 'sarif':\n return formatSarif(diagnostics);\n case 'github':\n return formatGitHub(diagnostics);\n case 'junit':\n return formatJUnit(diagnostics);\n case 'pretty':\n default:\n return formatDiagnostics(diagnostics);\n }\n}\n\nexport const lintCommand = new Command('lint')\n .description('Run all lint rules against context files')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', `Output format: ${VALID_FORMATS.join(', ')}`)\n .option('--max-warnings <count>', 'Exit with error if warning count exceeds this threshold', parseInt)\n .option('--output-file <path>', 'Write formatted output to a file')\n .option('--rule <ruleId:severity>', 'Override rule severity (repeatable)', collectRule, {})\n .option('--fix', 'Automatically fix problems')\n .option('--fix-dry-run', 'Show what --fix would change without writing')\n .option('--cache', 'Only lint changed files (uses .contextkit-cache)')\n .option('--no-cache', 'Bypass the lint cache')\n .action(async (opts) => {\n try {\n const config = await loadConfigAsync(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n const rootDir = process.cwd();\n\n // Determine output format (explicit flag > CI auto-detect)\n const format: FormatType = opts.format\n ? (VALID_FORMATS.includes(opts.format) ? opts.format : 'pretty')\n : detectFormat();\n\n // Check cache if --cache is enabled\n const useCache = opts.cache === true;\n if (useCache) {\n const configContent = JSON.stringify(config) + JSON.stringify(opts.rule ?? {});\n const hash = computeCacheHash(contextDir, configContent);\n const cached = readCache(rootDir, hash);\n if (cached) {\n const output = formatOutput(cached, format);\n if (opts.outputFile) {\n writeFileSync(path.resolve(opts.outputFile), output, 'utf-8');\n const ec = cached.filter((d) => d.severity === 'error').length;\n const wc = cached.filter((d) => d.severity === 'warning').length;\n console.log(`Results written to ${opts.outputFile} (${ec} error(s), ${wc} warning(s)) (cached)`);\n } else {\n console.log(output);\n }\n const hasErrors = cached.some((d) => d.severity === 'error');\n if (hasErrors) process.exit(1);\n return;\n }\n }\n\n // Compile the context graph\n const { graph, diagnostics: compileDiags, directives } = await compile({\n contextDir,\n config,\n rootDir,\n });\n\n // Merge severity overrides: config file + CLI --rule overrides (CLI wins)\n const configOverrides = (config.lint?.severity_overrides ?? {}) as Record<string, Severity | 'off'>;\n const cliOverrides = opts.rule as Record<string, string>;\n const overrides: Record<string, Severity | 'off'> = {\n ...configOverrides,\n ...cliOverrides as Record<string, Severity | 'off'>,\n };\n\n // Run lint engine with built-in + plugin rules\n const engine = new LintEngine(Object.keys(overrides).length > 0 ? overrides : undefined);\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n if (config.plugins && config.plugins.length > 0) {\n const pluginRules = await loadPlugins(config.plugins);\n for (const rule of pluginRules) {\n engine.register(rule);\n }\n }\n const lintDiags = engine.run(graph);\n\n // Merge compile diagnostics with lint diagnostics, then filter by inline directives\n let allDiags: Diagnostic[] = filterByDirectives(\n [...compileDiags, ...lintDiags],\n directives,\n );\n\n // Apply auto-fixes if --fix or --fix-dry-run\n if (opts.fix || opts.fixDryRun) {\n const fixable = allDiags.filter((d) => d.fixable && d.fix);\n if (fixable.length > 0) {\n const fixes = applyFixes(fixable, (filePath) => readFileSync(filePath, 'utf-8'));\n\n if (opts.fixDryRun) {\n console.log(chalk.blue(`Would fix ${fixable.length} issue(s) in ${fixes.size} file(s):`));\n for (const [file] of fixes) {\n console.log(chalk.gray(` ${file}`));\n }\n console.log('');\n } else {\n // Write fixes to disk\n for (const [file, content] of fixes) {\n writeFileSync(file, content, 'utf-8');\n }\n console.log(chalk.green(`Fixed ${fixable.length} issue(s) in ${fixes.size} file(s).`));\n\n // Re-lint to show remaining issues\n const { graph: reGraph, diagnostics: reCompileDiags, directives: reDirs } = await compile({\n contextDir,\n config,\n rootDir: process.cwd(),\n });\n const reEngine = new LintEngine(Object.keys(overrides).length > 0 ? overrides : undefined);\n for (const rule of ALL_RULES) {\n reEngine.register(rule);\n }\n const reLintDiags = reEngine.run(reGraph);\n allDiags = filterByDirectives([...reCompileDiags, ...reLintDiags], reDirs);\n }\n }\n }\n\n // Enforce minimum_tier policy\n if (config.minimum_tier) {\n const tierOrder: MetadataTier[] = ['none', 'bronze', 'silver', 'gold'];\n const minIdx = tierOrder.indexOf(config.minimum_tier);\n for (const [modelName, score] of graph.tiers) {\n const actualIdx = tierOrder.indexOf(score.tier);\n if (actualIdx < minIdx) {\n allDiags.push({\n ruleId: 'tier/minimum-tier',\n severity: 'error',\n message: `Model \"${modelName}\" is tier \"${score.tier}\" but minimum_tier is \"${config.minimum_tier}\"`,\n location: { file: `model:${modelName}`, line: 1, column: 1 },\n fixable: false,\n });\n }\n }\n }\n\n // Write cache if enabled\n if (useCache) {\n const configContent = JSON.stringify(config) + JSON.stringify(opts.rule ?? {});\n const hash = computeCacheHash(contextDir, configContent);\n writeCache(rootDir, hash, allDiags);\n }\n\n // Format output\n const output = formatOutput(allDiags, format);\n\n // Write to file if --output-file specified\n if (opts.outputFile) {\n writeFileSync(path.resolve(opts.outputFile), output, 'utf-8');\n // Print summary to stdout\n const errorCount = allDiags.filter((d) => d.severity === 'error').length;\n const warnCount = allDiags.filter((d) => d.severity === 'warning').length;\n console.log(`Results written to ${opts.outputFile} (${errorCount} error(s), ${warnCount} warning(s))`);\n } else {\n console.log(output);\n }\n\n // Check --max-warnings threshold\n const warnCount = allDiags.filter((d) => d.severity === 'warning').length;\n if (opts.maxWarnings !== undefined && !isNaN(opts.maxWarnings) && warnCount > opts.maxWarnings) {\n console.error(\n chalk.red(`Too many warnings: ${warnCount} (max allowed: ${opts.maxWarnings})`),\n );\n process.exit(1);\n }\n\n // Exit with code 1 if there are errors\n const hasErrors = allDiags.some((d) => d.severity === 'error');\n if (hasErrors) {\n process.exit(1);\n }\n } catch (err) {\n console.error(chalk.red(`Lint failed: ${(err as Error).message}`));\n process.exit(1);\n }\n });\n","import chalk from 'chalk';\nimport type { Diagnostic, TierScore, TierCheckResult } from '@runcontext/core';\n\n/**\n * Format an array of diagnostics as colorized, human-readable text.\n */\nexport function formatDiagnostics(diagnostics: Diagnostic[]): string {\n if (diagnostics.length === 0) {\n return chalk.green('No issues found.');\n }\n\n const lines: string[] = [];\n\n for (const d of diagnostics) {\n const icon =\n d.severity === 'error' ? chalk.red('error') : chalk.yellow('warning');\n const loc = chalk.gray(\n `${d.location.file}:${d.location.line}:${d.location.column}`,\n );\n const rule = chalk.gray(`[${d.ruleId}]`);\n const fixTag = d.fixable ? chalk.blue(' (fixable)') : '';\n\n lines.push(` ${icon} ${d.message} ${rule}${fixTag}`);\n lines.push(` ${loc}`);\n }\n\n const errorCount = diagnostics.filter((d) => d.severity === 'error').length;\n const warnCount = diagnostics.filter((d) => d.severity === 'warning').length;\n\n lines.push('');\n const parts: string[] = [];\n if (errorCount > 0) parts.push(chalk.red(`${errorCount} error(s)`));\n if (warnCount > 0) parts.push(chalk.yellow(`${warnCount} warning(s)`));\n lines.push(parts.join(', '));\n\n return lines.join('\\n');\n}\n\n/**\n * Format a tier score as colorized, human-readable text.\n */\nexport function formatTierScore(score: TierScore): string {\n const lines: string[] = [];\n\n const tierColor = getTierColor(score.tier);\n lines.push(\n `${chalk.bold(score.model)}: ${tierColor(score.tier.toUpperCase())}`,\n );\n lines.push('');\n\n lines.push(formatTierSection('Bronze', score.bronze.passed, score.bronze.checks));\n lines.push(formatTierSection('Silver', score.silver.passed, score.silver.checks));\n lines.push(formatTierSection('Gold', score.gold.passed, score.gold.checks));\n\n return lines.join('\\n');\n}\n\nfunction formatTierSection(\n label: string,\n passed: boolean,\n checks: TierCheckResult[],\n): string {\n const lines: string[] = [];\n const status = passed ? chalk.green('PASS') : chalk.red('FAIL');\n lines.push(` ${label}: ${status}`);\n\n for (const check of checks) {\n const icon = check.passed ? chalk.green(' +') : chalk.red(' -');\n lines.push(` ${icon} ${check.label}`);\n if (check.detail && !check.passed) {\n lines.push(chalk.gray(` ${check.detail}`));\n }\n }\n\n return lines.join('\\n');\n}\n\nfunction getTierColor(tier: string): (text: string) => string {\n switch (tier) {\n case 'gold':\n return chalk.yellow;\n case 'silver':\n return chalk.white;\n case 'bronze':\n return chalk.hex('#CD7F32');\n default:\n return chalk.gray;\n }\n}\n\n/**\n * Format a generic info message.\n */\nexport function formatInfo(message: string): string {\n return chalk.blue(message);\n}\n\n/**\n * Format an error message.\n */\nexport function formatError(message: string): string {\n return chalk.red(`Error: ${message}`);\n}\n\n/**\n * Format a success message.\n */\nexport function formatSuccess(message: string): string {\n return chalk.green(message);\n}\n","/**\n * Format any value as pretty-printed JSON.\n */\nexport function formatJson(data: unknown): string {\n return JSON.stringify(data, null, 2);\n}\n","import type { Diagnostic } from '@runcontext/core';\n\ninterface SarifRuleDescriptor {\n id: string;\n shortDescription: { text: string };\n}\n\ninterface SarifResult {\n ruleId: string;\n level: 'error' | 'warning' | 'note';\n message: { text: string };\n locations: Array<{\n physicalLocation: {\n artifactLocation: { uri: string };\n region: { startLine: number; startColumn: number };\n };\n }>;\n}\n\ninterface SarifRun {\n tool: {\n driver: {\n name: string;\n version: string;\n informationUri: string;\n rules: SarifRuleDescriptor[];\n };\n };\n results: SarifResult[];\n}\n\ninterface SarifLog {\n $schema: string;\n version: string;\n runs: SarifRun[];\n}\n\nfunction mapSeverity(severity: string): 'error' | 'warning' | 'note' {\n switch (severity) {\n case 'error':\n return 'error';\n case 'warning':\n return 'warning';\n default:\n return 'note';\n }\n}\n\n/**\n * Format diagnostics as SARIF v2.1.0 JSON.\n * GitHub natively consumes this for code scanning alerts.\n */\nexport function formatSarif(diagnostics: Diagnostic[]): string {\n // Collect unique rules\n const ruleMap = new Map<string, SarifRuleDescriptor>();\n for (const d of diagnostics) {\n if (!ruleMap.has(d.ruleId)) {\n ruleMap.set(d.ruleId, {\n id: d.ruleId,\n shortDescription: { text: d.message },\n });\n }\n }\n\n const results: SarifResult[] = diagnostics.map((d) => ({\n ruleId: d.ruleId,\n level: mapSeverity(d.severity),\n message: { text: d.message },\n locations: [\n {\n physicalLocation: {\n artifactLocation: { uri: d.location.file },\n region: {\n startLine: d.location.line,\n startColumn: d.location.column,\n },\n },\n },\n ],\n }));\n\n const sarif: SarifLog = {\n $schema:\n 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json',\n version: '2.1.0',\n runs: [\n {\n tool: {\n driver: {\n name: 'ContextKit',\n version: '0.2.1',\n informationUri: 'https://github.com/erickittelson/ContextKit',\n rules: Array.from(ruleMap.values()),\n },\n },\n results,\n },\n ],\n };\n\n return JSON.stringify(sarif, null, 2);\n}\n","import type { Diagnostic } from '@runcontext/core';\n\n/**\n * Format diagnostics as GitHub Actions workflow commands.\n * Output: ::warning file={f},line={l},col={c},title={ruleId}::{message}\n * Works in any GitHub Actions workflow — annotations appear inline on PRs.\n */\nexport function formatGitHub(diagnostics: Diagnostic[]): string {\n if (diagnostics.length === 0) {\n return '';\n }\n\n const lines: string[] = [];\n\n for (const d of diagnostics) {\n const level = d.severity === 'error' ? 'error' : 'warning';\n lines.push(\n `::${level} file=${d.location.file},line=${d.location.line},col=${d.location.column},title=${d.ruleId}::${d.message}`,\n );\n }\n\n return lines.join('\\n');\n}\n","import type { Diagnostic } from '@runcontext/core';\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\n/**\n * Format diagnostics as JUnit XML.\n * Consumed by Jenkins, GitLab CI, CircleCI, Azure DevOps.\n * Groups diagnostics by file as <testsuite>, each diagnostic as <testcase> with <failure>.\n */\nexport function formatJUnit(diagnostics: Diagnostic[]): string {\n // Group diagnostics by file\n const byFile = new Map<string, Diagnostic[]>();\n for (const d of diagnostics) {\n const file = d.location.file;\n if (!byFile.has(file)) {\n byFile.set(file, []);\n }\n byFile.get(file)!.push(d);\n }\n\n const lines: string[] = [];\n lines.push('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');\n lines.push(\n `<testsuites name=\"ContextKit\" tests=\"${diagnostics.length}\" failures=\"${diagnostics.length}\">`,\n );\n\n for (const [file, diags] of byFile) {\n lines.push(\n ` <testsuite name=\"${escapeXml(file)}\" tests=\"${diags.length}\" failures=\"${diags.length}\">`,\n );\n\n for (const d of diags) {\n const name = `${d.ruleId} (${d.location.line}:${d.location.column})`;\n lines.push(` <testcase name=\"${escapeXml(name)}\" classname=\"${escapeXml(file)}\">`);\n lines.push(\n ` <failure message=\"${escapeXml(d.message)}\" type=\"${d.severity}\">${escapeXml(d.ruleId)}: ${escapeXml(d.message)} at ${escapeXml(file)}:${d.location.line}:${d.location.column}</failure>`,\n );\n lines.push(' </testcase>');\n }\n\n lines.push(' </testsuite>');\n }\n\n lines.push('</testsuites>');\n return lines.join('\\n');\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { compile, loadConfig, emitManifest } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\nimport { formatSuccess, formatError } from '../formatters/pretty.js';\n\nexport const buildCommand = new Command('build')\n .description('Compile context files and emit manifest JSON')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--output-dir <path>', 'Path to output directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n const outputDir = opts.outputDir\n ? path.resolve(opts.outputDir)\n : path.resolve(config.output_dir);\n\n // Compile the context graph\n const { graph, diagnostics } = await compile({ contextDir, config, rootDir: process.cwd() });\n\n // Check for compile errors\n const errors = diagnostics.filter((d) => d.severity === 'error');\n if (errors.length > 0) {\n if (opts.format === 'json') {\n console.log(formatJson({ success: false, errors }));\n } else {\n console.error(\n chalk.red(`Build failed with ${errors.length} error(s):`),\n );\n for (const e of errors) {\n console.error(chalk.red(` - ${e.message} [${e.ruleId}]`));\n }\n }\n process.exit(1);\n }\n\n // Emit manifest\n const manifest = emitManifest(graph, config);\n\n // Write to output directory\n fs.mkdirSync(outputDir, { recursive: true });\n const outputPath = path.join(outputDir, 'contextkit-manifest.json');\n fs.writeFileSync(outputPath, JSON.stringify(manifest, null, 2), 'utf-8');\n\n if (opts.format === 'json') {\n console.log(formatJson({ success: true, outputPath, manifest }));\n } else {\n console.log(formatSuccess(`Manifest written to ${outputPath}`));\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { compile, loadConfig, computeTier, type TierScore } from '@runcontext/core';\nimport { formatTierScore, formatError } from '../formatters/pretty.js';\nimport { formatJson } from '../formatters/json.js';\n\nexport const tierCommand = new Command('tier')\n .description('Show tier scorecard for one or all models')\n .argument('[model-name]', 'Specific model name to check')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (modelName: string | undefined, opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n const { graph } = await compile({ contextDir, config, rootDir: process.cwd() });\n\n let scores: TierScore[];\n\n if (modelName) {\n // Single model\n if (!graph.models.has(modelName)) {\n console.error(formatError(`Model '${modelName}' not found.`));\n const available = [...graph.models.keys()].join(', ');\n if (available) {\n console.error(chalk.gray(`Available models: ${available}`));\n }\n process.exit(1);\n }\n scores = [computeTier(modelName, graph)];\n } else {\n // All models\n scores = [...graph.models.keys()].map((name) =>\n computeTier(name, graph),\n );\n }\n\n if (scores.length === 0) {\n console.log(\n opts.format === 'json'\n ? formatJson([])\n : chalk.yellow('No models found.'),\n );\n return;\n }\n\n if (opts.format === 'json') {\n console.log(formatJson(scores));\n } else {\n for (const score of scores) {\n console.log(formatTierScore(score));\n console.log('');\n }\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { compile, loadConfig } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\nimport { formatError } from '../formatters/pretty.js';\n\nexport const explainCommand = new Command('explain')\n .description('Look up models, terms, or owners by name and show details')\n .argument('<name>', 'Name of a model, term, or owner to look up')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (name: string, opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n const { graph } = await compile({ contextDir, config, rootDir: process.cwd() });\n\n const results: Array<{ type: string; name: string; data: unknown }> = [];\n\n // Search models\n if (graph.models.has(name)) {\n results.push({ type: 'model', name, data: graph.models.get(name) });\n }\n\n // Search terms\n if (graph.terms.has(name)) {\n results.push({ type: 'term', name, data: graph.terms.get(name) });\n }\n\n // Search owners\n if (graph.owners.has(name)) {\n results.push({ type: 'owner', name, data: graph.owners.get(name) });\n }\n\n // Search governance\n if (graph.governance.has(name)) {\n results.push({\n type: 'governance',\n name,\n data: graph.governance.get(name),\n });\n }\n\n // Search rules\n if (graph.rules.has(name)) {\n results.push({ type: 'rules', name, data: graph.rules.get(name) });\n }\n\n // Search lineage\n if (graph.lineage.has(name)) {\n results.push({ type: 'lineage', name, data: graph.lineage.get(name) });\n }\n\n if (results.length === 0) {\n console.error(formatError(`No matching entity found for '${name}'.`));\n process.exit(1);\n }\n\n if (opts.format === 'json') {\n console.log(formatJson(results));\n } else {\n for (const result of results) {\n console.log(chalk.bold(`${result.type}: ${result.name}`));\n console.log(chalk.gray('---'));\n console.log(JSON.stringify(result.data, null, 2));\n console.log('');\n }\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport {\n compile,\n loadConfig,\n LintEngine,\n ALL_RULES,\n applyFixes,\n type Severity,\n} from '@runcontext/core';\nimport { formatSuccess, formatError } from '../formatters/pretty.js';\nimport { formatJson } from '../formatters/json.js';\n\nexport const fixCommand = new Command('fix')\n .description('Auto-fix lint issues')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .option('--dry-run', 'Show what would be fixed without writing files')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n // Compile and lint\n const { graph } = await compile({ contextDir, config, rootDir: process.cwd() });\n\n const overrides = config.lint?.severity_overrides as\n | Record<string, Severity | 'off'>\n | undefined;\n const engine = new LintEngine(overrides);\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n const diagnostics = engine.run(graph);\n\n const fixable = diagnostics.filter((d) => d.fixable);\n\n if (fixable.length === 0) {\n if (opts.format === 'json') {\n console.log(formatJson({ fixedFiles: [], fixCount: 0 }));\n } else {\n console.log(chalk.green('No fixable issues found.'));\n }\n return;\n }\n\n // Apply fixes\n const readFile = (filePath: string) =>\n fs.readFileSync(filePath, 'utf-8');\n const fixedFiles = applyFixes(fixable, readFile);\n\n if (opts.dryRun) {\n if (opts.format === 'json') {\n const entries = [...fixedFiles.entries()].map(([file, content]) => ({\n file,\n content,\n }));\n console.log(\n formatJson({ dryRun: true, fixCount: fixable.length, entries }),\n );\n } else {\n console.log(\n chalk.yellow(`Dry run: ${fixable.length} issue(s) would be fixed in ${fixedFiles.size} file(s):`),\n );\n for (const file of fixedFiles.keys()) {\n console.log(chalk.gray(` ${file}`));\n }\n }\n return;\n }\n\n // Write fixed files\n for (const [file, content] of fixedFiles) {\n fs.writeFileSync(file, content, 'utf-8');\n }\n\n if (opts.format === 'json') {\n console.log(\n formatJson({\n fixedFiles: [...fixedFiles.keys()],\n fixCount: fixable.length,\n }),\n );\n } else {\n console.log(\n formatSuccess(\n `Fixed ${fixable.length} issue(s) in ${fixedFiles.size} file(s).`,\n ),\n );\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport {\n compile,\n loadConfig,\n LintEngine,\n ALL_RULES,\n filterByDirectives,\n applyFixes,\n type Diagnostic,\n type Severity,\n} from '@runcontext/core';\nimport { formatDiagnostics } from '../formatters/pretty.js';\n\n/** Serialize a diagnostic to a comparable key. */\nfunction diagKey(d: Diagnostic): string {\n return `${d.ruleId}|${d.location.file}:${d.location.line}:${d.location.column}|${d.message}`;\n}\n\nlet previousDiags: Map<string, Diagnostic> = new Map();\n\nasync function runLint(\n contextDir: string,\n fix: boolean,\n): Promise<void> {\n const config = loadConfig(process.cwd());\n\n const { graph, diagnostics: compileDiags, directives } = await compile({\n contextDir,\n config,\n rootDir: process.cwd(),\n });\n\n const overrides = config.lint?.severity_overrides as\n | Record<string, Severity | 'off'>\n | undefined;\n const engine = new LintEngine(overrides);\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n const lintDiags = engine.run(graph);\n let allDiags = filterByDirectives([...compileDiags, ...lintDiags], directives);\n\n // Apply fixes in watch mode if --fix\n if (fix) {\n const fixable = allDiags.filter((d) => d.fixable && d.fix);\n if (fixable.length > 0) {\n const fixes = applyFixes(fixable, (filePath) => readFileSync(filePath, 'utf-8'));\n for (const [file, content] of fixes) {\n writeFileSync(file, content, 'utf-8');\n }\n // Re-lint after fixes\n const { graph: reGraph, diagnostics: reCompileDiags, directives: reDirs } = await compile({\n contextDir,\n config,\n rootDir: process.cwd(),\n });\n const reEngine = new LintEngine(overrides);\n for (const rule of ALL_RULES) {\n reEngine.register(rule);\n }\n allDiags = filterByDirectives([...reCompileDiags, ...reEngine.run(reGraph)], reDirs);\n\n if (fixable.length > 0) {\n console.log(chalk.green(` Auto-fixed ${fixable.length} issue(s).`));\n }\n }\n }\n\n // Build current diagnostics map\n const currentDiags = new Map<string, Diagnostic>();\n for (const d of allDiags) {\n currentDiags.set(diagKey(d), d);\n }\n\n // Compute diff\n const newIssues: Diagnostic[] = [];\n const resolved: Diagnostic[] = [];\n\n for (const [key, d] of currentDiags) {\n if (!previousDiags.has(key)) newIssues.push(d);\n }\n for (const [key, d] of previousDiags) {\n if (!currentDiags.has(key)) resolved.push(d);\n }\n\n // Display\n console.clear();\n console.log(chalk.gray(`[${new Date().toLocaleTimeString()}] Linting...`));\n\n if (previousDiags.size > 0) {\n // Show diff summary\n if (resolved.length > 0) {\n console.log(chalk.green(` ${resolved.length} issue(s) resolved`));\n }\n if (newIssues.length > 0) {\n console.log(chalk.red(` ${newIssues.length} new issue(s)`));\n }\n if (resolved.length === 0 && newIssues.length === 0) {\n console.log(chalk.gray(' No changes'));\n }\n console.log('');\n }\n\n console.log(formatDiagnostics(allDiags));\n console.log('');\n\n previousDiags = currentDiags;\n}\n\nexport const devCommand = new Command('dev')\n .description('Watch mode — re-run lint on file changes')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--fix', 'Auto-fix problems on each re-lint')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n const fix = opts.fix === true;\n\n console.log(chalk.blue(`Watching ${contextDir} for changes...`));\n if (fix) console.log(chalk.blue('Auto-fix enabled.'));\n console.log(chalk.gray('Press Ctrl+C to stop.\\n'));\n\n // Initial lint run\n await runLint(contextDir, fix);\n\n // Dynamic import of chokidar for watch mode\n const { watch } = await import('chokidar');\n\n let debounceTimer: ReturnType<typeof setTimeout> | null = null;\n\n const watcher = watch(contextDir, {\n ignored: /(^|[/\\\\])\\../, // ignore dotfiles\n persistent: true,\n ignoreInitial: true,\n });\n\n watcher.on('all', (_event, _filePath) => {\n if (debounceTimer) clearTimeout(debounceTimer);\n debounceTimer = setTimeout(async () => {\n try {\n await runLint(contextDir, fix);\n } catch (err) {\n console.error(\n chalk.red(`Lint error: ${(err as Error).message}`),\n );\n }\n }, 300);\n });\n } catch (err) {\n console.error(chalk.red(`Dev mode failed: ${(err as Error).message}`));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { formatSuccess, formatError } from '../formatters/pretty.js';\n\nconst EXAMPLE_OSI = `version: \"1.0\"\n\nsemantic_model:\n - name: example-model\n description: An example semantic model\n ai_context:\n instructions: \"Use this model for general analytics queries\"\n synonyms: [\"example\", \"sample model\"]\n\n datasets:\n - name: example_table\n source: warehouse.public.example_table\n primary_key: [id]\n description: \"Example table\"\n fields:\n - name: id\n expression:\n dialects:\n - dialect: ANSI_SQL\n expression: id\n description: \"Primary key\"\n type: number\n - name: name\n expression:\n dialects:\n - dialect: ANSI_SQL\n expression: name\n description: \"Name field\"\n type: string\n`;\n\nconst EXAMPLE_GOVERNANCE = `model: example-model\nowner: data-team\nclassification: internal\nsecurity:\n pii: false\n access_level: internal\ndatasets:\n example_table:\n grain: one row per example entity\n fields:\n id:\n description: \"Primary key\"\n name:\n description: \"Name field\"\n`;\n\nconst EXAMPLE_TERM = `glossary:\n - term: Example Term\n definition: A sample glossary term to demonstrate the format\n aliases: [\"sample term\"]\n owner: data-team\n`;\n\nconst EXAMPLE_OWNER = `team: data-team\nname: Data Team\nemail: data-team@example.com\nslack: \"#data-team\"\nmembers:\n - name: Jane Doe\n role: lead\n`;\n\nconst EXAMPLE_CONFIG = `context_dir: context\noutput_dir: dist\nminimum_tier: bronze\n`;\n\nexport const initCommand = new Command('init')\n .description('Scaffold a v0.2 ContextKit project structure')\n .option('--dir <path>', 'Root directory for the project', '.')\n .action(async (opts) => {\n try {\n const rootDir = path.resolve(opts.dir);\n const contextDir = path.join(rootDir, 'context');\n\n // Create directory structure\n const dirs = [\n path.join(contextDir, 'models'),\n path.join(contextDir, 'governance'),\n path.join(contextDir, 'glossary'),\n path.join(contextDir, 'owners'),\n ];\n\n for (const dir of dirs) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n // Write example files (only if they don't already exist)\n const files: Array<{ path: string; content: string }> = [\n {\n path: path.join(contextDir, 'models', 'example-model.osi.yaml'),\n content: EXAMPLE_OSI,\n },\n {\n path: path.join(\n contextDir,\n 'governance',\n 'example-model.governance.yaml',\n ),\n content: EXAMPLE_GOVERNANCE,\n },\n {\n path: path.join(contextDir, 'glossary', 'glossary.term.yaml'),\n content: EXAMPLE_TERM,\n },\n {\n path: path.join(contextDir, 'owners', 'data-team.owner.yaml'),\n content: EXAMPLE_OWNER,\n },\n {\n path: path.join(rootDir, 'contextkit.config.yaml'),\n content: EXAMPLE_CONFIG,\n },\n ];\n\n let created = 0;\n let skipped = 0;\n\n for (const file of files) {\n if (fs.existsSync(file.path)) {\n console.log(chalk.gray(` skip ${path.relative(rootDir, file.path)} (exists)`));\n skipped++;\n } else {\n fs.writeFileSync(file.path, file.content, 'utf-8');\n console.log(chalk.green(` create ${path.relative(rootDir, file.path)}`));\n created++;\n }\n }\n\n console.log('');\n console.log(\n formatSuccess(\n `Initialized ContextKit project: ${created} file(s) created, ${skipped} skipped.`,\n ),\n );\n console.log('');\n console.log(chalk.gray('Next steps:'));\n console.log(chalk.gray(' 1. Edit the example files in context/'));\n console.log(chalk.gray(' 2. Run: context lint'));\n console.log(chalk.gray(' 3. Run: context build'));\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { compile, loadConfig, emitManifest } from '@runcontext/core';\nimport { formatError } from '../formatters/pretty.js';\n\nexport const siteCommand = new Command('site')\n .description('Build a static documentation site from compiled context')\n .option('--context-dir <path>', 'Path to context directory')\n .option('--output-dir <path>', 'Path to site output directory')\n .action(async (opts) => {\n try {\n const config = loadConfig(process.cwd());\n const contextDir = opts.contextDir\n ? path.resolve(opts.contextDir)\n : path.resolve(config.context_dir);\n\n // Compile the context graph\n const { graph } = await compile({ contextDir, config, rootDir: process.cwd() });\n const manifest = emitManifest(graph, config);\n\n // Try to import the site generator\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic import\n let buildSite: ((...args: any[]) => Promise<void>) | undefined;\n try {\n const siteModule = await import('@runcontext/site');\n buildSite = siteModule.buildSite;\n } catch {\n // @runcontext/site not yet implemented\n }\n\n if (!buildSite) {\n console.log(\n chalk.yellow(\n 'Site generator is not yet available. Install @runcontext/site to enable this command.',\n ),\n );\n process.exit(0);\n }\n\n const outputDir = opts.outputDir\n ? path.resolve(opts.outputDir)\n : path.resolve(config.site?.base_path ?? 'site');\n\n await buildSite(manifest, config, outputDir);\n console.log(chalk.green(`Site built to ${outputDir}`));\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { formatError } from '../formatters/pretty.js';\n\nexport const serveCommand = new Command('serve')\n .description('Start the MCP server (stdio transport)')\n .option('--context-dir <path>', 'Path to context directory')\n .action(async (opts) => {\n try {\n // Dynamic import — @runcontext/mcp is an optional peer\n let startServer: ((options?: { contextDir?: string; rootDir?: string }) => Promise<unknown>) | undefined;\n try {\n const mcpModule = await import('@runcontext/mcp');\n startServer = mcpModule.startServer;\n } catch {\n // @runcontext/mcp not installed\n }\n\n if (!startServer) {\n console.log(\n chalk.yellow(\n 'MCP server is not available. Install @runcontext/mcp to enable this command.',\n ),\n );\n process.exit(1);\n }\n\n console.log(chalk.blue('Starting MCP server (stdio transport)...'));\n await startServer({\n contextDir: opts.contextDir,\n rootDir: process.cwd(),\n });\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport path from 'node:path';\nimport { parseFile, osiDocumentSchema } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\nimport { formatError, formatSuccess } from '../formatters/pretty.js';\n\nexport const validateOsiCommand = new Command('validate-osi')\n .description('Validate a single OSI file against the schema')\n .argument('<file>', 'Path to the OSI YAML file')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action(async (file: string, opts) => {\n try {\n const filePath = path.resolve(file);\n\n // Parse the file\n const parsed = await parseFile(filePath, 'model');\n\n // Validate against the schema\n const result = osiDocumentSchema.safeParse(parsed.data);\n\n if (result.success) {\n if (opts.format === 'json') {\n console.log(\n formatJson({\n valid: true,\n file: filePath,\n data: result.data,\n }),\n );\n } else {\n console.log(formatSuccess(`${filePath} is valid.`));\n }\n } else {\n const issues = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }));\n\n if (opts.format === 'json') {\n console.log(\n formatJson({\n valid: false,\n file: filePath,\n issues,\n }),\n );\n } else {\n console.error(chalk.red(`Validation failed for ${filePath}:`));\n for (const issue of issues) {\n console.error(chalk.red(` ${issue.path}: ${issue.message}`));\n }\n }\n process.exit(1);\n }\n } catch (err) {\n console.error(formatError((err as Error).message));\n process.exit(1);\n }\n });\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { ALL_RULES, type LintRule, type RuleTier } from '@runcontext/core';\nimport { formatJson } from '../formatters/json.js';\n\nfunction formatRuleTable(rules: LintRule[]): string {\n if (rules.length === 0) {\n return chalk.gray('No rules match the filters.');\n }\n\n const lines: string[] = [];\n\n // Header\n const header = `${'ID'.padEnd(40)} ${'Tier'.padEnd(8)} ${'Severity'.padEnd(10)} ${'Fix'.padEnd(5)} Description`;\n lines.push(chalk.bold(header));\n lines.push(chalk.gray('─'.repeat(100)));\n\n for (const rule of rules) {\n const tier = rule.tier ?? '—';\n const tierCol = colorTier(tier);\n const fixCol = rule.fixable ? chalk.green('yes') : chalk.gray('no');\n const sevCol =\n rule.defaultSeverity === 'error'\n ? chalk.red(rule.defaultSeverity)\n : chalk.yellow(rule.defaultSeverity);\n const deprecated = rule.deprecated ? chalk.gray(' (deprecated)') : '';\n\n lines.push(\n `${rule.id.padEnd(40)} ${tierCol.padEnd(8 + (tierCol.length - tier.length))} ${sevCol.padEnd(10 + (sevCol.length - rule.defaultSeverity.length))} ${fixCol.padEnd(5 + (fixCol.length - (rule.fixable ? 3 : 2)))} ${rule.description}${deprecated}`,\n );\n }\n\n lines.push('');\n lines.push(chalk.gray(`${rules.length} rule(s) total`));\n\n return lines.join('\\n');\n}\n\nfunction colorTier(tier: string): string {\n switch (tier) {\n case 'gold':\n return chalk.yellow(tier);\n case 'silver':\n return chalk.white(tier);\n case 'bronze':\n return chalk.hex('#CD7F32')(tier);\n default:\n return chalk.gray(tier);\n }\n}\n\nexport const rulesCommand = new Command('rules')\n .description('List all lint rules with metadata')\n .option('--tier <tier>', 'Filter by tier: bronze, silver, gold')\n .option('--fixable', 'Show only fixable rules')\n .option('--format <type>', 'Output format: pretty or json', 'pretty')\n .action((opts) => {\n let rules = [...ALL_RULES];\n\n // Filter by tier\n if (opts.tier) {\n const tier = opts.tier as RuleTier;\n rules = rules.filter((r) => r.tier === tier);\n }\n\n // Filter by fixable\n if (opts.fixable) {\n rules = rules.filter((r) => r.fixable);\n }\n\n if (opts.format === 'json') {\n const data = rules.map((r) => ({\n id: r.id,\n tier: r.tier ?? null,\n defaultSeverity: r.defaultSeverity,\n fixable: r.fixable,\n description: r.description,\n deprecated: r.deprecated ?? false,\n replacedBy: r.replacedBy ?? null,\n }));\n console.log(formatJson(data));\n } else {\n console.log(formatRuleTable(rules));\n }\n });\n"],"mappings":";;;AAEA,SAAS,WAAAA,iBAAe;;;ACFxB,SAAS,eAAe;AACx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AE,cAAc;AAAA,IAC9B,EAAE;AACF,YAAQ,IAAI,WAAW,IAAI,CAAC;AAAA,EAC9B,OAAO;AACL,YAAQ,IAAI,gBAAgB,KAAK,CAAC;AAAA,EACpC;AACF,CAAC;;;AhBrEH,IAAM,UAAU,IAAIC,UAAQ;AAE5B,QACG,KAAK,SAAS,EACd,YAAY,yDAAoD,EAChE,QAAQ,OAAO;AAGlB,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,cAAc;AACjC,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,UAAU;AAC7B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,WAAW;AAC9B,QAAQ,WAAW,YAAY;AAC/B,QAAQ,WAAW,kBAAkB;AACrC,QAAQ,WAAW,YAAY;AAE/B,QAAQ,MAAM;","names":["Command","chalk","output","hasErrors","chalk","warnCount","Command","chalk","path","compile","Command","path","compile","chalk","Command","chalk","path","compile","loadConfig","Command","loadConfig","path","compile","chalk","Command","chalk","path","compile","loadConfig","Command","loadConfig","path","compile","chalk","Command","chalk","path","fs","compile","loadConfig","LintEngine","ALL_RULES","applyFixes","Command","loadConfig","path","compile","LintEngine","ALL_RULES","chalk","fs","applyFixes","Command","chalk","path","readFileSync","writeFileSync","compile","loadConfig","LintEngine","ALL_RULES","filterByDirectives","applyFixes","loadConfig","compile","LintEngine","ALL_RULES","filterByDirectives","applyFixes","readFileSync","writeFileSync","chalk","Command","path","Command","chalk","path","fs","Command","path","fs","chalk","Command","chalk","path","compile","loadConfig","emitManifest","Command","loadConfig","path","compile","emitManifest","chalk","Command","chalk","Command","chalk","Command","chalk","path","Command","path","chalk","Command","chalk","ALL_RULES","chalk","Command","ALL_RULES","Command"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runcontext/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI for ContextKit — lint, build, fix, and serve institutional context",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Kittelson",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"chalk": "^5.4.0",
|
|
30
30
|
"chokidar": "^4.0.0",
|
|
31
31
|
"commander": "^14.0.0",
|
|
32
|
-
"@runcontext/
|
|
33
|
-
"@runcontext/
|
|
34
|
-
"@runcontext/
|
|
32
|
+
"@runcontext/site": "^0.3.0",
|
|
33
|
+
"@runcontext/core": "^0.3.0",
|
|
34
|
+
"@runcontext/mcp": "^0.3.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^25.3.3",
|