@yawlabs/ctxlint 0.5.0 → 0.7.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/.pre-commit-hooks.yaml +8 -0
- package/AGENT_SESSION_LINT_SPEC.md +366 -0
- package/CONTEXT_LINT_SPEC.md +613 -0
- package/MCP_CONFIG_LINT_SPEC.md +396 -0
- package/README.md +77 -17
- package/agent-session-lint-rules.json +157 -0
- package/context-lint-rules.json +415 -0
- package/dist/{chunk-FHTSMC5D.js → chunk-DYPYGTPV.js} +555 -23
- package/dist/chunk-ZXMDA7VB.js +16 -0
- package/dist/{cli-7IBRPDA6.js → cli-7DNRBGDO.js} +23 -8
- package/dist/index.js +3 -3
- package/dist/mcp/chunk-MCKGQKYU.js +15 -0
- package/dist/mcp/server.js +595 -25
- package/dist/mcp/tiktoken-MWTCLHI2.js +465 -0
- package/dist/{server-IFZ3VEK3.js → server-ADUSCPPU.js} +44 -3
- package/dist/tiktoken-CCNRJMFQ.js +466 -0
- package/mcp-config-lint-rules.json +413 -0
- package/package.json +33 -8
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ALL_CHECKS,
|
|
4
4
|
ALL_MCP_CHECKS,
|
|
5
|
+
ALL_SESSION_CHECKS,
|
|
5
6
|
VERSION,
|
|
6
7
|
applyFixes,
|
|
7
8
|
freeEncoder,
|
|
@@ -10,7 +11,8 @@ import {
|
|
|
10
11
|
resetTokenThresholds,
|
|
11
12
|
runAudit,
|
|
12
13
|
setTokenThresholds
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DYPYGTPV.js";
|
|
15
|
+
import "./chunk-ZXMDA7VB.js";
|
|
14
16
|
|
|
15
17
|
// src/cli.ts
|
|
16
18
|
import * as fs2 from "fs";
|
|
@@ -306,26 +308,35 @@ import * as path2 from "path";
|
|
|
306
308
|
async function runCli() {
|
|
307
309
|
const program = new Command();
|
|
308
310
|
program.name("ctxlint").description(
|
|
309
|
-
"Lint your AI agent context files
|
|
310
|
-
).version(VERSION).argument("[path]", "Project directory to scan", ".").option("--strict", "Exit code 1 on any warning or error (for CI)", false).option("--checks <checks>", "Comma-separated list of checks to run", "").option("--format <format>", "Output format: text, json, or sarif", "text").option("--tokens", "Show token breakdown per file", false).option("--verbose", "Show passing checks too", false).option("--fix", "Auto-fix broken paths using git history and fuzzy matching", false).option("--ignore <checks>", "Comma-separated list of checks to ignore", "").option("--quiet", "Suppress all output except errors (exit code only)", false).option("--config <path>", "Path to config file (default: .ctxlintrc in project root)").option("--depth <n>", "Max subdirectory depth to scan (default: 2)", "2").option("--mcp", "Enable MCP config linting alongside context file checks", false).option("--mcp-only", "Run only MCP config checks, skip context file checks", false).option("--mcp-global", "Also scan user/global MCP config files (implies --mcp)", false).action(async (projectPath, opts) => {
|
|
311
|
+
"Lint your AI agent context files and MCP server configs against your actual codebase"
|
|
312
|
+
).version(VERSION).argument("[path]", "Project directory to scan", ".").option("--strict", "Exit code 1 on any warning or error (for CI)", false).option("--checks <checks>", "Comma-separated list of checks to run", "").option("--format <format>", "Output format: text, json, or sarif", "text").option("--tokens", "Show token breakdown per file", false).option("--verbose", "Show passing checks too", false).option("--fix", "Auto-fix broken paths using git history and fuzzy matching", false).option("--ignore <checks>", "Comma-separated list of checks to ignore", "").option("--quiet", "Suppress all output except errors (exit code only)", false).option("--config <path>", "Path to config file (default: .ctxlintrc in project root)").option("--depth <n>", "Max subdirectory depth to scan (default: 2)", "2").option("--mcp", "Enable MCP config linting alongside context file checks", false).option("--mcp-only", "Run only MCP config checks, skip context file checks", false).option("--mcp-global", "Also scan user/global MCP config files (implies --mcp)", false).option("--mcp-server", "Start the MCP server (for IDE/agent integration)").option("--session", "Run session audit checks (cross-project consistency)", false).option("--session-only", "Run only session checks, skip context and MCP checks", false).action(async (projectPath, opts) => {
|
|
311
313
|
const resolvedPath = path2.resolve(projectPath);
|
|
312
314
|
const configPath = opts.config ? path2.resolve(opts.config) : void 0;
|
|
313
315
|
const config = configPath ? loadConfigFromPath(configPath) : loadConfig(resolvedPath);
|
|
314
316
|
const mcpGlobal = opts.mcpGlobal || false;
|
|
315
317
|
const mcpOnly = opts.mcpOnly || false;
|
|
316
318
|
const mcpFlag = opts.mcp || mcpGlobal || mcpOnly || config?.mcp || false;
|
|
319
|
+
const sessionFlag = opts.session || false;
|
|
320
|
+
const sessionOnly = opts.sessionOnly || false;
|
|
317
321
|
const explicitChecks = opts.checks ? opts.checks.split(",").map((c) => c.trim()) : null;
|
|
318
322
|
const hasMcpInChecks = explicitChecks?.some((c) => c.startsWith("mcp-")) || false;
|
|
323
|
+
const hasSessionInChecks = explicitChecks?.some((c) => c.startsWith("session-")) || false;
|
|
319
324
|
const effectiveMcp = mcpFlag || hasMcpInChecks;
|
|
325
|
+
const effectiveSession = sessionFlag || sessionOnly || hasSessionInChecks;
|
|
320
326
|
let checks;
|
|
321
327
|
if (explicitChecks) {
|
|
322
328
|
checks = explicitChecks;
|
|
329
|
+
} else if (sessionOnly) {
|
|
330
|
+
checks = ALL_SESSION_CHECKS;
|
|
323
331
|
} else if (mcpOnly) {
|
|
324
332
|
checks = ALL_MCP_CHECKS;
|
|
325
|
-
} else if (effectiveMcp) {
|
|
326
|
-
checks = [...config?.checks || ALL_CHECKS, ...ALL_MCP_CHECKS];
|
|
327
333
|
} else {
|
|
328
|
-
|
|
334
|
+
const base = config?.checks || ALL_CHECKS;
|
|
335
|
+
checks = [
|
|
336
|
+
...base,
|
|
337
|
+
...effectiveMcp ? ALL_MCP_CHECKS : [],
|
|
338
|
+
...effectiveSession ? ALL_SESSION_CHECKS : []
|
|
339
|
+
];
|
|
329
340
|
}
|
|
330
341
|
const options = {
|
|
331
342
|
projectPath: resolvedPath,
|
|
@@ -340,7 +351,9 @@ async function runCli() {
|
|
|
340
351
|
depth: parseInt(opts.depth, 10) || 2,
|
|
341
352
|
mcp: effectiveMcp,
|
|
342
353
|
mcpOnly,
|
|
343
|
-
mcpGlobal: mcpGlobal || config?.mcpGlobal || false
|
|
354
|
+
mcpGlobal: mcpGlobal || config?.mcpGlobal || false,
|
|
355
|
+
session: effectiveSession,
|
|
356
|
+
sessionOnly
|
|
344
357
|
};
|
|
345
358
|
if (config?.tokenThresholds) {
|
|
346
359
|
setTokenThresholds(config.tokenThresholds);
|
|
@@ -354,7 +367,9 @@ async function runCli() {
|
|
|
354
367
|
extraPatterns: config?.contextFiles,
|
|
355
368
|
mcp: options.mcp,
|
|
356
369
|
mcpGlobal: options.mcpGlobal,
|
|
357
|
-
mcpOnly: options.mcpOnly
|
|
370
|
+
mcpOnly: options.mcpOnly,
|
|
371
|
+
session: options.session,
|
|
372
|
+
sessionOnly: options.sessionOnly
|
|
358
373
|
});
|
|
359
374
|
spinner?.stop();
|
|
360
375
|
if (result.files.length === 0) {
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
if (process.argv.includes("--mcp")) {
|
|
5
|
-
await import("./server-
|
|
4
|
+
if (process.argv.includes("--mcp-server")) {
|
|
5
|
+
await import("./server-ADUSCPPU.js");
|
|
6
6
|
} else {
|
|
7
|
-
const { runCli } = await import("./cli-
|
|
7
|
+
const { runCli } = await import("./cli-7DNRBGDO.js");
|
|
8
8
|
await runCli();
|
|
9
9
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
__require,
|
|
14
|
+
__commonJS
|
|
15
|
+
};
|