codex-plugin-doctor 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -82,7 +82,9 @@ If you already have Codex installed locally and do not know plugin paths, discov
82
82
  ```bash
83
83
  codex-plugin-doctor list --installed
84
84
  codex-plugin-doctor check --installed
85
+ codex-plugin-doctor check --installed --all-summary
85
86
  codex-plugin-doctor check --installed github
87
+ codex-plugin-doctor explain plugin.manifest.missing
86
88
  ```
87
89
 
88
90
  Run from source:
@@ -154,23 +156,56 @@ Run these from a Codex plugin package root:
154
156
 
155
157
  ```bash
156
158
  codex-plugin-doctor --version
159
+ codex-plugin-doctor init my-plugin
157
160
  codex-plugin-doctor check .
158
161
  codex-plugin-doctor check . --json
159
162
  codex-plugin-doctor check . --json --output report.json
160
163
  codex-plugin-doctor check . --markdown --output report.md
164
+ codex-plugin-doctor check . --sarif --output results.sarif
161
165
  codex-plugin-doctor check . --ascii
162
166
  codex-plugin-doctor check . --no-animations
163
167
  codex-plugin-doctor check . --runtime
168
+ codex-plugin-doctor check . --config .codex-doctor.json
164
169
  codex-plugin-doctor check . --json --runtime --verbose-runtime
165
170
  ```
166
171
 
172
+ Optional local policy file:
173
+
174
+ ```json
175
+ {
176
+ "ignoreRules": ["plugin.heuristic.description.too_long"],
177
+ "failOnWarnings": true
178
+ }
179
+ ```
180
+
167
181
  Run these when you want Codex Plugin Doctor to find plugins from the local Codex installation:
168
182
 
169
183
  ```bash
170
184
  codex-plugin-doctor list --installed
171
185
  codex-plugin-doctor check --installed
186
+ codex-plugin-doctor check --installed --all-summary
172
187
  codex-plugin-doctor check --installed github
173
188
  codex-plugin-doctor check --installed github --runtime --no-animations
189
+ codex-plugin-doctor explain plugin.security.hard_coded_secret
190
+ ```
191
+
192
+ ## GitHub Action
193
+
194
+ ```yaml
195
+ name: Validate Codex plugin
196
+
197
+ on:
198
+ pull_request:
199
+
200
+ jobs:
201
+ doctor:
202
+ runs-on: ubuntu-latest
203
+ steps:
204
+ - uses: actions/checkout@v4
205
+ - uses: Esquetta/CodexPluginDoctor@v0.1.4
206
+ with:
207
+ path: .
208
+ runtime: "false"
174
209
  ```
175
210
 
176
211
  To self-test this repository after cloning it:
@@ -196,6 +231,7 @@ The validator is tuned against local fixtures and real marketplace-style plugin
196
231
  - [Real-World Validation Workflow](./docs/engineering/real-world-validation-workflow.md)
197
232
  - [Validation Sessions](./validation-sessions/README.md)
198
233
  - [Examples](./examples/README.md)
234
+ - [Rule Catalog](./docs/rules/catalog.md)
199
235
 
200
236
  Recent validation waves covered:
201
237
 
@@ -0,0 +1,7 @@
1
+ import type { CheckResult } from "../domain/types.js";
2
+ export interface DoctorConfig {
3
+ ignoreRules: string[];
4
+ failOnWarnings: boolean;
5
+ }
6
+ export declare function loadDoctorConfig(targetPath: string, explicitConfigPath?: string | null): Promise<DoctorConfig>;
7
+ export declare function applyDoctorConfig(result: CheckResult, config: DoctorConfig): CheckResult;
@@ -0,0 +1,45 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ const defaultConfig = {
4
+ ignoreRules: [],
5
+ failOnWarnings: false
6
+ };
7
+ function isStringArray(value) {
8
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
9
+ }
10
+ export async function loadDoctorConfig(targetPath, explicitConfigPath) {
11
+ const configPath = explicitConfigPath
12
+ ? path.resolve(explicitConfigPath)
13
+ : path.join(path.resolve(targetPath), ".codex-doctor.json");
14
+ try {
15
+ const parsed = JSON.parse(await readFile(configPath, "utf8"));
16
+ return {
17
+ ignoreRules: isStringArray(parsed.ignoreRules)
18
+ ? parsed.ignoreRules
19
+ : defaultConfig.ignoreRules,
20
+ failOnWarnings: typeof parsed.failOnWarnings === "boolean"
21
+ ? parsed.failOnWarnings
22
+ : defaultConfig.failOnWarnings
23
+ };
24
+ }
25
+ catch {
26
+ return defaultConfig;
27
+ }
28
+ }
29
+ export function applyDoctorConfig(result, config) {
30
+ const findings = result.findings.filter((finding) => !config.ignoreRules.includes(finding.id));
31
+ const hasFailures = findings.some((finding) => finding.severity === "fail");
32
+ const hasWarnings = findings.some((finding) => finding.severity === "warn");
33
+ const warningFailure = config.failOnWarnings && hasWarnings;
34
+ const status = hasFailures || warningFailure
35
+ ? "fail"
36
+ : hasWarnings
37
+ ? "warn"
38
+ : "pass";
39
+ return {
40
+ ...result,
41
+ status,
42
+ exitCode: status === "fail" ? 1 : 0,
43
+ findings
44
+ };
45
+ }
@@ -0,0 +1,6 @@
1
+ export interface InitPluginResult {
2
+ rootPath: string;
3
+ manifestPath: string;
4
+ skillPath: string;
5
+ }
6
+ export declare function initPluginPackage(targetPath: string): Promise<InitPluginResult>;
@@ -0,0 +1,39 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ function toPackageName(inputPath) {
4
+ return path.basename(path.resolve(inputPath))
5
+ .toLowerCase()
6
+ .replace(/[^a-z0-9-]+/g, "-")
7
+ .replace(/^-+|-+$/g, "") || "codex-plugin";
8
+ }
9
+ export async function initPluginPackage(targetPath) {
10
+ const rootPath = path.resolve(targetPath);
11
+ const manifestDirectory = path.join(rootPath, ".codex-plugin");
12
+ const skillsDirectory = path.join(rootPath, "skills", "hello");
13
+ const manifestPath = path.join(manifestDirectory, "plugin.json");
14
+ const skillPath = path.join(skillsDirectory, "SKILL.md");
15
+ await mkdir(manifestDirectory, { recursive: true });
16
+ await mkdir(skillsDirectory, { recursive: true });
17
+ await writeFile(manifestPath, `${JSON.stringify({
18
+ name: toPackageName(rootPath),
19
+ version: "0.1.0",
20
+ description: "A Codex plugin package scaffolded by Codex Plugin Doctor.",
21
+ skills: "skills"
22
+ }, null, 2)}\n`, "utf8");
23
+ await writeFile(skillPath, [
24
+ "---",
25
+ "name: hello",
26
+ "description: Use when verifying that this Codex plugin package loads correctly.",
27
+ "---",
28
+ "",
29
+ "# Hello",
30
+ "",
31
+ "This starter skill confirms the plugin package structure is valid.",
32
+ ""
33
+ ].join("\n"), "utf8");
34
+ return {
35
+ rootPath,
36
+ manifestPath,
37
+ skillPath
38
+ };
39
+ }
@@ -131,6 +131,12 @@ function countMatches(input, pattern) {
131
131
  const matches = input.match(pattern);
132
132
  return matches ? matches.length : 0;
133
133
  }
134
+ function extractSupportAssetReferences(content) {
135
+ const references = [...content.matchAll(/`((?:scripts|templates|assets|examples)\/[^`]+)`/g)]
136
+ .map((match) => match[1].trim())
137
+ .filter((reference) => reference.length > 0);
138
+ return [...new Set(references)];
139
+ }
134
140
  function isDescriptionLikelyVerbose(description, mode) {
135
141
  const trimmed = description.trim();
136
142
  const length = trimmed.length;
@@ -252,6 +258,14 @@ async function validateSkillDefinitions(discoveredPackage) {
252
258
  isDescriptionLikelyVerbose(frontmatter.description, "skill")) {
253
259
  findings.push(buildWarning("plugin.heuristic.skill_description.too_long", `The skill \`${skillDirectory.name}\` description is likely too verbose.`, "Overly long skill descriptions increase context cost and reduce the precision of skill matching.", `Shorten the \`description\` field in \`${skillFilePath}\` to a tightly scoped summary.`));
254
260
  }
261
+ for (const supportReference of extractSupportAssetReferences(skillContent)) {
262
+ const supportPath = path.resolve(skillRoot, supportReference);
263
+ const supportFileExists = await fileExists(supportPath);
264
+ const supportDirectoryExists = await directoryExists(supportPath);
265
+ if (!supportFileExists && !supportDirectoryExists) {
266
+ findings.push(buildWarning("plugin.skill.asset_reference.missing", `The skill \`${skillDirectory.name}\` references missing support asset \`${supportReference}\`.`, "Skills that point to missing scripts, templates, assets, or examples are harder to execute and can fail when an agent follows the instructions.", `Create \`${supportPath}\` or update the reference in \`${skillFilePath}\`.`));
267
+ }
268
+ }
255
269
  }
256
270
  return findings;
257
271
  }
@@ -0,0 +1,7 @@
1
+ import type { CheckResult } from "../domain/types.js";
2
+ import type { InstalledPlugin } from "../core/discover-installed-plugins.js";
3
+ export interface InstalledPluginCheckResult {
4
+ plugin: InstalledPlugin;
5
+ result: CheckResult;
6
+ }
7
+ export declare function renderInstalledSummary(checkedPlugins: InstalledPluginCheckResult[]): string;
@@ -0,0 +1,22 @@
1
+ export function renderInstalledSummary(checkedPlugins) {
2
+ const passCount = checkedPlugins.filter((item) => item.result.status === "pass").length;
3
+ const warnCount = checkedPlugins.filter((item) => item.result.status === "warn").length;
4
+ const failCount = checkedPlugins.filter((item) => item.result.status === "fail").length;
5
+ const lines = [
6
+ "Installed Plugin Summary",
7
+ "========================",
8
+ `Checked: ${checkedPlugins.length}`,
9
+ `Pass: ${passCount}`,
10
+ `Warn: ${warnCount}`,
11
+ `Fail: ${failCount}`,
12
+ "",
13
+ "Plugins",
14
+ "-------"
15
+ ];
16
+ for (const item of checkedPlugins) {
17
+ const findingIds = item.result.findings.map((finding) => finding.id);
18
+ const suffix = findingIds.length > 0 ? ` (${findingIds.join(", ")})` : "";
19
+ lines.push(`${item.result.status.toUpperCase()} ${item.plugin.name} - ${item.plugin.relativePath}${suffix}`);
20
+ }
21
+ return lines.join("\n");
22
+ }
@@ -0,0 +1,2 @@
1
+ import type { RuleDefinition } from "../rules/rule-catalog.js";
2
+ export declare function renderRuleExplanation(rule: RuleDefinition): string;
@@ -0,0 +1,26 @@
1
+ export function renderRuleExplanation(rule) {
2
+ return [
3
+ `Rule: ${rule.id}`,
4
+ "==============================",
5
+ `Category: ${rule.category}`,
6
+ `Default severity: ${rule.defaultSeverity}`,
7
+ "",
8
+ "Summary",
9
+ "-------",
10
+ rule.summary,
11
+ "",
12
+ "Why it matters",
13
+ "--------------",
14
+ rule.why,
15
+ "",
16
+ "Suggested fix",
17
+ "-------------",
18
+ rule.fix,
19
+ "",
20
+ "Example",
21
+ "-------",
22
+ rule.example,
23
+ "",
24
+ "Full catalog: docs/rules/catalog.md"
25
+ ].join("\n");
26
+ }
@@ -0,0 +1,2 @@
1
+ import type { CheckResult } from "../domain/types.js";
2
+ export declare function renderSarifReport(result: CheckResult): string;
@@ -0,0 +1,55 @@
1
+ import path from "node:path";
2
+ import { findRuleDefinition } from "../rules/rule-catalog.js";
3
+ function levelForFinding(finding) {
4
+ return finding.severity === "fail" ? "error" : "warning";
5
+ }
6
+ export function renderSarifReport(result) {
7
+ const rules = [...new Set(result.findings.map((finding) => finding.id))]
8
+ .map((ruleId) => {
9
+ const catalogEntry = findRuleDefinition(ruleId);
10
+ return {
11
+ id: ruleId,
12
+ name: ruleId,
13
+ shortDescription: {
14
+ text: catalogEntry?.summary ?? ruleId
15
+ },
16
+ help: {
17
+ text: catalogEntry
18
+ ? `${catalogEntry.why}\n\nSuggested fix: ${catalogEntry.fix}`
19
+ : "See the Codex Plugin Doctor report for remediation guidance."
20
+ }
21
+ };
22
+ });
23
+ const sarif = {
24
+ version: "2.1.0",
25
+ $schema: "https://json.schemastore.org/sarif-2.1.0.json",
26
+ runs: [
27
+ {
28
+ tool: {
29
+ driver: {
30
+ name: "Codex Plugin Doctor",
31
+ informationUri: "https://github.com/Esquetta/CodexPluginDoctor",
32
+ rules
33
+ }
34
+ },
35
+ results: result.findings.map((finding) => ({
36
+ ruleId: finding.id,
37
+ level: levelForFinding(finding),
38
+ message: {
39
+ text: `${finding.message} Suggested fix: ${finding.suggestedFix}`
40
+ },
41
+ locations: [
42
+ {
43
+ physicalLocation: {
44
+ artifactLocation: {
45
+ uri: path.basename(result.targetPath)
46
+ }
47
+ }
48
+ }
49
+ ]
50
+ }))
51
+ }
52
+ ]
53
+ };
54
+ return JSON.stringify(sarif, null, 2);
55
+ }
@@ -0,0 +1,13 @@
1
+ export type RuleCategory = "package" | "skill" | "mcp" | "runtime" | "security";
2
+ export type RuleSeverity = "fail" | "warn";
3
+ export interface RuleDefinition {
4
+ id: string;
5
+ category: RuleCategory;
6
+ defaultSeverity: RuleSeverity;
7
+ summary: string;
8
+ why: string;
9
+ fix: string;
10
+ example: string;
11
+ }
12
+ export declare const ruleCatalog: RuleDefinition[];
13
+ export declare function findRuleDefinition(id: string): RuleDefinition | null;
@@ -0,0 +1,194 @@
1
+ export const ruleCatalog = [
2
+ {
3
+ id: "plugin.manifest.missing",
4
+ category: "package",
5
+ defaultSeverity: "fail",
6
+ summary: "The target directory is missing `.codex-plugin/plugin.json`.",
7
+ why: "Codex needs the plugin manifest as the package entry point. Without it, the directory cannot be treated as a plugin package.",
8
+ fix: "Run the doctor against a plugin package root, or create `.codex-plugin/plugin.json` with at least `name`, `version`, and `description`.",
9
+ example: '{ "name": "my-plugin", "version": "0.1.0", "description": "Adds focused Codex workflow helpers." }'
10
+ },
11
+ {
12
+ id: "plugin.manifest.name.missing",
13
+ category: "package",
14
+ defaultSeverity: "fail",
15
+ summary: "The plugin manifest is missing a stable `name` field.",
16
+ why: "Codex and release tooling need a stable package name for display, matching, and diagnostics.",
17
+ fix: "Add a kebab-case `name` field to `.codex-plugin/plugin.json`.",
18
+ example: '{ "name": "github-workflow-doctor" }'
19
+ },
20
+ {
21
+ id: "plugin.manifest.version.missing",
22
+ category: "package",
23
+ defaultSeverity: "fail",
24
+ summary: "The plugin manifest is missing a `version` field.",
25
+ why: "Compatibility checks and release workflows cannot reason about package changes without a version.",
26
+ fix: "Add a semantic `version` field to `.codex-plugin/plugin.json`.",
27
+ example: '{ "version": "0.1.0" }'
28
+ },
29
+ {
30
+ id: "plugin.manifest.description.missing",
31
+ category: "package",
32
+ defaultSeverity: "fail",
33
+ summary: "The plugin manifest is missing a `description` field.",
34
+ why: "Plugin surfaces and reviewers need concise package metadata to understand what the plugin does.",
35
+ fix: "Add a short, specific `description` field to `.codex-plugin/plugin.json`.",
36
+ example: '{ "description": "Validates GitHub PR automation workflows before release." }'
37
+ },
38
+ {
39
+ id: "plugin.heuristic.description.too_long",
40
+ category: "package",
41
+ defaultSeverity: "warn",
42
+ summary: "The plugin manifest description is likely too verbose.",
43
+ why: "Verbose package metadata increases context cost and can dilute plugin discovery quality.",
44
+ fix: "Shorten the manifest description to a precise one- or two-sentence summary.",
45
+ example: "Good: `Audits Codex plugin packages before publishing.`"
46
+ },
47
+ {
48
+ id: "plugin.skills.path.missing",
49
+ category: "skill",
50
+ defaultSeverity: "fail",
51
+ summary: "The manifest points to a missing skills directory.",
52
+ why: "Codex cannot load packaged skills when the manifest references a directory that does not exist.",
53
+ fix: "Create the referenced skills directory or update the `skills` path in `.codex-plugin/plugin.json`.",
54
+ example: '{ "skills": "skills" }'
55
+ },
56
+ {
57
+ id: "plugin.skill.skill_md.missing",
58
+ category: "skill",
59
+ defaultSeverity: "fail",
60
+ summary: "A skill directory does not contain `SKILL.md`.",
61
+ why: "`SKILL.md` is the required entry point for Codex to load skill instructions and metadata.",
62
+ fix: "Add `SKILL.md` with frontmatter containing at least `name` and `description`.",
63
+ example: "---\nname: repo-auditor\ndescription: Use when auditing repository health.\n---"
64
+ },
65
+ {
66
+ id: "plugin.skill.name.missing",
67
+ category: "skill",
68
+ defaultSeverity: "fail",
69
+ summary: "A skill `SKILL.md` file is missing `name` frontmatter.",
70
+ why: "Codex needs a stable skill name for matching, display, and diagnostics.",
71
+ fix: "Add a `name` field to the skill frontmatter.",
72
+ example: "---\nname: release-checker\n---"
73
+ },
74
+ {
75
+ id: "plugin.skill.description.missing",
76
+ category: "skill",
77
+ defaultSeverity: "fail",
78
+ summary: "A skill `SKILL.md` file is missing `description` frontmatter.",
79
+ why: "Skill descriptions drive discovery and implicit matching, so missing descriptions make skills harder to use.",
80
+ fix: "Add a scoped `description` field that says when the skill should be used.",
81
+ example: "---\ndescription: Use when preparing an npm release with verification gates.\n---"
82
+ },
83
+ {
84
+ id: "plugin.heuristic.skill_description.too_long",
85
+ category: "skill",
86
+ defaultSeverity: "warn",
87
+ summary: "A skill description is likely too verbose.",
88
+ why: "Long, vague descriptions increase context cost and reduce skill matching precision.",
89
+ fix: "Shorten the description while keeping concrete triggers, inputs, and output expectations.",
90
+ example: "Good: `Use when creating GitHub Actions release workflows for Node CLIs.`"
91
+ },
92
+ {
93
+ id: "plugin.skill.asset_reference.missing",
94
+ category: "skill",
95
+ defaultSeverity: "warn",
96
+ summary: "A skill references a missing local support asset.",
97
+ why: "Skills that point to missing scripts, templates, assets, or examples can fail when an agent follows the instructions.",
98
+ fix: "Create the referenced support file or update the backticked reference in `SKILL.md`.",
99
+ example: "If `SKILL.md` says `scripts/setup.ps1`, make sure that file exists inside the skill directory."
100
+ },
101
+ {
102
+ id: "plugin.mcp.path.missing",
103
+ category: "mcp",
104
+ defaultSeverity: "fail",
105
+ summary: "The manifest points to a missing `.mcp.json` file.",
106
+ why: "Codex cannot load bundled MCP server definitions if the referenced config file does not exist.",
107
+ fix: "Create the referenced `.mcp.json` file or update the `mcpServers` path in the manifest.",
108
+ example: '{ "mcpServers": ".mcp.json" }'
109
+ },
110
+ {
111
+ id: "plugin.mcp.invalid_json",
112
+ category: "mcp",
113
+ defaultSeverity: "fail",
114
+ summary: "The referenced `.mcp.json` file is not valid JSON.",
115
+ why: "Codex must parse MCP configuration before it can start bundled servers.",
116
+ fix: "Fix the JSON syntax in the referenced `.mcp.json` file.",
117
+ example: '{ "mcpServers": { "doctor": { "command": "node", "args": ["server.js"] } } }'
118
+ },
119
+ {
120
+ id: "plugin.mcp.invalid_shape",
121
+ category: "mcp",
122
+ defaultSeverity: "fail",
123
+ summary: "The `.mcp.json` file does not expose a valid `mcpServers` object.",
124
+ why: "Codex expects MCP configuration to be object-shaped with named server entries.",
125
+ fix: "Define a non-empty top-level `mcpServers` object.",
126
+ example: '{ "mcpServers": { "doctor": { "command": "node", "args": ["server.js"] } } }'
127
+ },
128
+ {
129
+ id: "plugin.mcp.server.invalid",
130
+ category: "mcp",
131
+ defaultSeverity: "fail",
132
+ summary: "An MCP server entry is not an object.",
133
+ why: "Codex cannot interpret server settings unless each server is represented as an object.",
134
+ fix: "Change the server entry to an object with transport options.",
135
+ example: '{ "mcpServers": { "doctor": { "command": "node" } } }'
136
+ },
137
+ {
138
+ id: "plugin.mcp.server.transport.missing",
139
+ category: "mcp",
140
+ defaultSeverity: "fail",
141
+ summary: "An MCP server entry is missing both `command` and `url`.",
142
+ why: "Codex needs either a stdio command or a streamable HTTP URL to connect to a server.",
143
+ fix: "Add `command` for stdio servers or `url` for remote servers.",
144
+ example: '{ "command": "node", "args": ["server.js"] }'
145
+ },
146
+ {
147
+ id: "plugin.security.path_traversal",
148
+ category: "security",
149
+ defaultSeverity: "fail",
150
+ summary: "A manifest path escapes the plugin package root.",
151
+ why: "Paths outside the package root can expose unintended files and make package review unreliable.",
152
+ fix: "Keep manifest paths such as `skills` and `mcpServers` inside the plugin root.",
153
+ example: '{ "skills": "skills", "mcpServers": ".mcp.json" }'
154
+ },
155
+ {
156
+ id: "plugin.security.hard_coded_secret",
157
+ category: "security",
158
+ defaultSeverity: "fail",
159
+ summary: "An MCP server config contains a hard-coded secret-like env value.",
160
+ why: "Bundled credentials can leak through source control, npm packages, logs, or support bundles.",
161
+ fix: "Replace literal secrets with environment references or externally injected secrets.",
162
+ example: '{ "env": { "OPENAI_API_KEY": "${OPENAI_API_KEY}" } }'
163
+ },
164
+ {
165
+ id: "plugin.runtime.exited_early",
166
+ category: "runtime",
167
+ defaultSeverity: "fail",
168
+ summary: "An MCP server exited before the startup probe completed.",
169
+ why: "A server that exits immediately is unlikely to remain available during normal Codex use.",
170
+ fix: "Run the configured command manually, inspect stderr, and fix startup exceptions or missing dependencies.",
171
+ example: "node server.js"
172
+ },
173
+ {
174
+ id: "plugin.runtime.initialize.timeout",
175
+ category: "runtime",
176
+ defaultSeverity: "fail",
177
+ summary: "An MCP server did not answer `initialize` in time.",
178
+ why: "Codex cannot negotiate capabilities with a server that does not complete initialization.",
179
+ fix: "Ensure the server reads JSON-RPC from stdin, writes responses to stdout, and avoids slow startup work.",
180
+ example: "Respond to the `initialize` request before starting expensive background tasks."
181
+ },
182
+ {
183
+ id: "plugin.runtime.protocol.invalid_message",
184
+ category: "runtime",
185
+ defaultSeverity: "fail",
186
+ summary: "An MCP server wrote invalid JSON-RPC data to stdout.",
187
+ why: "MCP stdio transport requires newline-delimited JSON-RPC messages on stdout.",
188
+ fix: "Send logs to stderr and reserve stdout for JSON-RPC protocol messages only.",
189
+ example: "Use `console.error` for diagnostics in Node stdio servers."
190
+ }
191
+ ];
192
+ export function findRuleDefinition(id) {
193
+ return ruleCatalog.find((rule) => rule.id === id) ?? null;
194
+ }
package/dist/run-cli.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import { writeFile } from "node:fs/promises";
2
2
  import { discoverInstalledPlugins, filterInstalledPlugins } from "./core/discover-installed-plugins.js";
3
+ import { applyDoctorConfig, loadDoctorConfig } from "./core/doctor-config.js";
4
+ import { initPluginPackage } from "./core/init-plugin.js";
3
5
  import { runCheck } from "./index.js";
6
+ import { renderInstalledSummary } from "./reporting/render-installed-summary.js";
4
7
  import { renderJsonReport } from "./reporting/render-json-report.js";
5
8
  import { buildMarkdownReport } from "./reporting/render-markdown-report.js";
9
+ import { renderRuleExplanation } from "./reporting/render-rule-explanation.js";
10
+ import { renderSarifReport } from "./reporting/render-sarif-report.js";
6
11
  import { renderTextReport } from "./reporting/render-text-report.js";
12
+ import { findRuleDefinition } from "./rules/rule-catalog.js";
7
13
  import { createLiveStatusRenderer } from "./terminal/live-status-renderer.js";
8
14
  import { determineOutputPolicy } from "./terminal/output-policy.js";
9
15
  import { getSpinner } from "./terminal/spinner-registry.js";
@@ -17,7 +23,7 @@ const defaultIo = {
17
23
  }
18
24
  };
19
25
  function printUsage(io) {
20
- io.writeStderr("Usage: codex-plugin-doctor check <path|--installed> [filter] [--json|--markdown] [--output <path>] [--runtime] [--verbose-runtime] [--no-animations] [--ascii]\n codex-plugin-doctor list --installed\n codex-plugin-doctor --version");
26
+ io.writeStderr("Usage: codex-plugin-doctor check <path|--installed> [filter] [--json|--markdown] [--output <path>] [--runtime] [--verbose-runtime] [--no-animations] [--ascii]\n codex-plugin-doctor list --installed\n codex-plugin-doctor explain <finding-id>\n codex-plugin-doctor --version");
21
27
  }
22
28
  function renderInstalledPlugins(plugins) {
23
29
  const lines = [
@@ -54,6 +60,32 @@ export async function runCli(args, io = defaultIo, options = {}) {
54
60
  io.writeStdout(renderInstalledPlugins(installedPlugins));
55
61
  return 0;
56
62
  }
63
+ if (command === "explain") {
64
+ if (!maybePath || maybePath.startsWith("--")) {
65
+ io.writeStderr("Missing finding id. Usage: codex-plugin-doctor explain <finding-id>");
66
+ return 2;
67
+ }
68
+ const rule = findRuleDefinition(maybePath);
69
+ if (!rule) {
70
+ io.writeStderr(`Unknown finding id: ${maybePath}`);
71
+ return 1;
72
+ }
73
+ io.writeStdout(renderRuleExplanation(rule));
74
+ return 0;
75
+ }
76
+ if (command === "init") {
77
+ const targetPath = maybePath && !maybePath.startsWith("--") ? maybePath : ".";
78
+ const result = await initPluginPackage(targetPath);
79
+ io.writeStdout([
80
+ "Initialized Codex plugin package",
81
+ `Root: ${result.rootPath}`,
82
+ `Manifest: ${result.manifestPath}`,
83
+ `Skill: ${result.skillPath}`,
84
+ "",
85
+ `Next: codex-plugin-doctor check ${result.rootPath}`
86
+ ].join("\n"));
87
+ return 0;
88
+ }
57
89
  if (command !== "check") {
58
90
  printUsage(io);
59
91
  return 2;
@@ -73,16 +105,24 @@ export async function runCli(args, io = defaultIo, options = {}) {
73
105
  : remainingArgs;
74
106
  const jsonOutput = normalizedFlags.includes("--json");
75
107
  const markdownOutput = normalizedFlags.includes("--markdown");
108
+ const sarifOutput = normalizedFlags.includes("--sarif");
76
109
  const runtimeProbeEnabled = normalizedFlags.includes("--runtime");
77
110
  const verboseRuntime = normalizedFlags.includes("--verbose-runtime");
78
111
  const noAnimations = normalizedFlags.includes("--no-animations");
79
112
  const asciiMode = normalizedFlags.includes("--ascii");
113
+ const installedSummary = normalizedFlags.includes("--all-summary");
80
114
  const outputIndex = normalizedFlags.indexOf("--output");
81
115
  const outputPath = outputIndex === -1 ? null : normalizedFlags[outputIndex + 1];
116
+ const configIndex = normalizedFlags.indexOf("--config");
117
+ const configPath = configIndex === -1 ? null : normalizedFlags[configIndex + 1];
82
118
  if (outputIndex !== -1 && (!outputPath || outputPath.startsWith("--"))) {
83
119
  io.writeStderr("Missing path after --output.");
84
120
  return 2;
85
121
  }
122
+ if (configIndex !== -1 && (!configPath || configPath.startsWith("--"))) {
123
+ io.writeStderr("Missing path after --config.");
124
+ return 2;
125
+ }
86
126
  const outputPolicy = determineOutputPolicy({
87
127
  jsonOutput,
88
128
  markdownOutput,
@@ -102,39 +142,47 @@ export async function runCli(args, io = defaultIo, options = {}) {
102
142
  : "No installed Codex plugins found.");
103
143
  return 1;
104
144
  }
105
- const results = [];
145
+ const checkedPlugins = [];
106
146
  for (const plugin of installedPlugins) {
107
- results.push(await runCheckImpl(plugin.rootPath, {
108
- runtime: runtimeProbeEnabled,
109
- runtimeTranscript: runtimeProbeEnabled && verboseRuntime
110
- ? (line) => io.writeStderr(line)
111
- : undefined
112
- }));
147
+ const config = await loadDoctorConfig(plugin.rootPath, configPath);
148
+ checkedPlugins.push({
149
+ plugin,
150
+ result: applyDoctorConfig(await runCheckImpl(plugin.rootPath, {
151
+ runtime: runtimeProbeEnabled,
152
+ runtimeTranscript: runtimeProbeEnabled && verboseRuntime
153
+ ? (line) => io.writeStderr(line)
154
+ : undefined
155
+ }), config)
156
+ });
113
157
  }
114
- const report = results
115
- .map((result) => markdownOutput
116
- ? buildMarkdownReport(result, { runtimeProbeEnabled })
117
- : jsonOutput
118
- ? renderJsonReport(result, { runtimeProbeEnabled })
119
- : renderTextReport(result, { ascii: outputPolicy.style === "ascii" }))
120
- .join("\n\n");
158
+ const report = installedSummary
159
+ ? renderInstalledSummary(checkedPlugins)
160
+ : checkedPlugins
161
+ .map((item) => sarifOutput
162
+ ? renderSarifReport(item.result)
163
+ : markdownOutput
164
+ ? buildMarkdownReport(item.result, { runtimeProbeEnabled })
165
+ : jsonOutput
166
+ ? renderJsonReport(item.result, { runtimeProbeEnabled })
167
+ : renderTextReport(item.result, { ascii: outputPolicy.style === "ascii" }))
168
+ .join("\n\n");
121
169
  if (outputPath) {
122
170
  await writeFile(outputPath, report, "utf8");
123
171
  }
124
172
  io.writeStdout(report);
125
- return results.some((result) => result.exitCode === 1) ? 1 : 0;
173
+ return checkedPlugins.some((item) => item.result.exitCode === 1) ? 1 : 0;
126
174
  }
127
175
  const renderer = outputPolicy.interactive
128
176
  && !verboseRuntime
129
177
  ? createLiveStatusRenderer(io, getSpinner(outputPolicy.style === "ascii" ? "ascii" : "doctor"))
130
178
  : null;
131
179
  renderer?.start("Validating package");
132
- const result = await runCheckImpl(targetPath, {
180
+ const result = applyDoctorConfig(await runCheckImpl(targetPath, {
133
181
  runtime: runtimeProbeEnabled,
134
182
  runtimeTranscript: runtimeProbeEnabled && verboseRuntime
135
183
  ? (line) => io.writeStderr(line)
136
184
  : undefined
137
- });
185
+ }), await loadDoctorConfig(targetPath, configPath));
138
186
  if (renderer) {
139
187
  if (result.status === "fail") {
140
188
  renderer.stopFailure("Validation failed");
@@ -145,9 +193,11 @@ export async function runCli(args, io = defaultIo, options = {}) {
145
193
  }
146
194
  const report = markdownOutput
147
195
  ? buildMarkdownReport(result, { runtimeProbeEnabled })
148
- : jsonOutput
149
- ? renderJsonReport(result, { runtimeProbeEnabled })
150
- : renderTextReport(result, { ascii: outputPolicy.style === "ascii" });
196
+ : sarifOutput
197
+ ? renderSarifReport(result)
198
+ : jsonOutput
199
+ ? renderJsonReport(result, { runtimeProbeEnabled })
200
+ : renderTextReport(result, { ascii: outputPolicy.style === "ascii" });
151
201
  if (outputPath) {
152
202
  await writeFile(outputPath, report, "utf8");
153
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-plugin-doctor",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "CLI-first validator for Codex plugins, skills, and MCP package surfaces with runtime MCP protocol validation.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",