Skip to content

Commit 9a9497f

Browse files
authored
Add structkit lint command and MCP tool (#146)
1 parent d3fc004 commit 9a9497f

7 files changed

Lines changed: 550 additions & 1 deletion

File tree

docs/cli-reference.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,38 @@ structkit validate [-h] [-l LOG] [-c CONFIG_FILE] [-i LOG_FILE] yaml_file
8080

8181
- `yaml_file`: Path to the YAML configuration file.
8282

83+
### `lint`
84+
85+
Run stricter quality checks against one or more StructKit YAML files or structure names. `validate` checks whether a structure is syntactically usable; `lint` adds quality and safety checks that can flag risky, ambiguous, or inconsistent definitions.
86+
87+
**Usage:**
88+
89+
```sh
90+
structkit lint [-h] [-l LOG] [-c CONFIG_FILE] [-i LOG_FILE] [-s STRUCTURES_PATH] [--all] [--json] [targets ...]
91+
```
92+
93+
**Arguments:**
94+
95+
- `targets`: One or more built-in structure names, custom structure names, or local `.yaml`/`.yml` files.
96+
- `-s STRUCTURES_PATH, --structures-path STRUCTURES_PATH`: Path to custom structure definitions. Can be set via the `STRUCTKIT_STRUCTURES_PATH` environment variable.
97+
- `--all`: Lint all bundled contrib structures.
98+
- `--json`: Print machine-readable JSON containing `summary` counts and individual `issues`.
99+
100+
**Rules and exit behavior:**
101+
102+
- Errors: invalid YAML, missing targets, missing files, non-mapping top-level YAML, invalid variable/hook shapes, duplicate variables, duplicate file/folder entries, template syntax errors, undefined template variables, and clearly destructive hooks such as filesystem-root removal.
103+
- Warnings: missing top-level descriptions, declared variables that are never referenced, suspicious hooks, unpinned GitHub remote URLs, and variable naming convention issues.
104+
- The command exits with status `1` when one or more lint errors are found. Warnings alone do not cause a non-zero exit.
105+
106+
Examples:
107+
108+
```sh
109+
structkit lint .struct.yaml
110+
structkit lint structkit/contribs/project/python.yaml
111+
structkit lint --all
112+
structkit lint .struct.yaml --json
113+
```
114+
83115
### `generate`
84116

85117
Generate the project structure.

docs/mcp-integration.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,27 @@ Validate a structure configuration YAML file.
103103
**Parameters:**
104104
- `yaml_file` (required): Path to the YAML configuration file to validate
105105

106+
### 6. lint_structure
107+
Lint one or more structure YAML files or structure names for quality and safety issues.
108+
109+
```json
110+
{
111+
"name": "lint_structure",
112+
"arguments": {
113+
"targets": ["project/python", "/path/to/.struct.yaml"],
114+
"structures_path": "/path/to/custom/structures",
115+
"lint_all": false,
116+
"output": "json"
117+
}
118+
}
119+
```
120+
121+
**Parameters:**
122+
- `targets` (optional): YAML file paths or structure names to lint. Required unless `lint_all` is true.
123+
- `structures_path` (optional): Custom path to structure definitions.
124+
- `lint_all` (optional): Lint all bundled contrib structures (default: false).
125+
- `output` (optional): Output format - "text" or "json" (default: "text").
126+
106127
## Usage
107128

108129
### Starting the MCP Server (FastMCP stdio / http / sse)
@@ -246,6 +267,7 @@ The MCP tools can be chained together for complex workflows:
246267
2. Get detailed info about a specific structure
247268
3. Generate the structure with custom mappings
248269
4. Validate any custom configurations
270+
5. Lint structures for stricter quality and safety checks
249271

250272
### Integration Examples
251273

@@ -374,6 +396,7 @@ Once connected, you can use these tools:
374396
- `generate_structure` - Generate project structures
375397
- `get_structure_vars` - Inspect declared structure variables
376398
- `validate_structure` - Validate YAML configuration files
399+
- `lint_structure` - Lint YAML files or structure names for quality and safety issues
377400

378401
## Troubleshooting
379402

0 commit comments

Comments
 (0)