Skip to content

Commit 8f8abba

Browse files
committed
feat: add sources --format, optimize gateway commands, improve test coverage
Features: - Add --format json option to sources command per RFC-0002:C-SOURCES Performance: - outline: use pre-built headings index when available (O(1) vs O(n) file scan) - sources: optimize mark_last_entries from O(n²) to O(n) Tests: - Add unit tests for index.rs (76% → 96%) and sync.rs (70% → 86%) - Add unit tests for logging.rs (78% → 93%) - Add integration tests for logging behavior - Add outline tests for both built (index) and unbuilt (fallback) paths - Add sources integration tests for all options Docs: - Update RFC-0002 with --format option for sources - Update README with sources --format json example - Update CHANGELOG with new features and performance improvements - Fix outdated lint rule numbers in validating.md workflow - Add tree output example to testing.md workflow Overall test coverage: 87.93% → 88.48%
1 parent 123513c commit 8f8abba

28 files changed

+874
-80
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "skillc"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = "2024"
55
license = "MIT OR Apache-2.0"
66
description = "A development kit for Agent Skills - the open format for extending AI agent capabilities"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ skc show my-skill --section "API" --max-lines 50 # Truncate output
105105
skc open my-skill SKILL.md --max-lines 100 # Read first 100 lines
106106
skc search my-skill "borrow checker"
107107
skc sources my-skill --pattern "*.md"
108+
skc sources my-skill --format json # JSON output
108109

109110
# Analytics
110111
skc stats my-skill --group-by sections

docs/rfc/RFC-0002.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!-- GENERATED: do not edit. Source: RFC-0002 -->
2-
<!-- SIGNATURE: sha256:672a3198ebf3468d08e85e0d60892add77b7e414be7b3e4ebe4b504f17450adc -->
2+
<!-- SIGNATURE: sha256:4d3ec959504d040daf017ecc16258ba108dacad6458122eb5a4060efdfda8dd8 -->
33

44
# RFC-0002: Gateway Protocol
55

6-
> **Version:** 0.1.0 | **Status:** normative | **Phase:** test
6+
> **Version:** 0.2.1 | **Status:** normative | **Phase:** test
77
88
---
99

@@ -210,6 +210,7 @@ The sources command MUST list all files in the skill's source directory in a tre
210210
| `--dir <path>` | Scope listing to a subdirectory |
211211
| `--limit <n>` | Maximum entries to display (default: 100) |
212212
| `--pattern <glob>` | Filter files by glob pattern (e.g., `*.md`) |
213+
| `--format <fmt>` | Output format: `text` (default) or `json` |
213214

214215
**Output format:**
215216

@@ -251,10 +252,14 @@ The command MUST reject any `--dir` path that would resolve outside the skill so
251252

252253
## Changelog
253254

254-
### v0.1.0 (2026-01-30)
255+
### v0.2.1 (2026-01-31)
255256

256-
Initial release
257+
Add missing --format support for
258+
259+
### v0.2.0 (2026-01-31)
257260

258-
#### Added
261+
C-SHOW updated with em-dash stripping and suggestions
259262

260-
- C-SHOW updated with em-dash stripping and suggestions
263+
### v0.1.0 (2026-01-30)
264+
265+
Initial release

docs/rfc/RFC-0004.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!-- GENERATED: do not edit. Source: RFC-0004 -->
2-
<!-- SIGNATURE: sha256:975e35b3688109154ff5d2ee3d885a3ee23bbc204a953a0c53c0938daed4892d -->
2+
<!-- SIGNATURE: sha256:72a6a5ccaa9dfbddd02590f892babad2362bdae67c5fd2210f7fafd6218d2d56 -->
33

44
# RFC-0004: Search Protocol
55

6-
> **Version:** 0.1.0 | **Status:** normative | **Phase:** test
6+
> **Version:** 0.2.0 | **Status:** normative | **Phase:** test
77
88
---
99

@@ -380,10 +380,10 @@ An index is corrupt if the database cannot be opened, `index_meta` table is miss
380380

381381
## Changelog
382382

383-
### v0.1.0 (2026-01-30)
383+
### v0.2.0 (2026-01-31)
384384

385-
Initial release
385+
C-INDEX updated with headings table, schema version bumped to 2
386386

387-
#### Added
387+
### v0.1.0 (2026-01-30)
388388

389-
- C-INDEX updated with headings table, schema version bumped to 2
389+
Initial release

docs/workflows/testing.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ Opens a specific file from the skill. Use this for non-markdown files or when yo
6161
skc sources my-skill
6262
```
6363

64-
Lists all files in the skill:
64+
Lists all files in the skill as a tree:
6565

6666
```
67-
SKILL.md
68-
examples/usage.md
69-
reference/api.md
67+
my-skill/
68+
├── SKILL.md
69+
├── examples/
70+
│ └── usage.md
71+
└── reference/
72+
└── api.md
73+
```
74+
75+
Use `--format json` for machine-readable output:
76+
77+
```bash
78+
skc sources my-skill --format json
7079
```
7180

7281
### Search content

docs/workflows/validating.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,42 @@ This checks your skill against quality rules and reports any issues.
1212

1313
## What lint checks
1414

15-
### Structure rules (SKL0xx)
15+
See [RFC-0008:C-REGISTRY](../rfc/RFC-0008.md#rfc-0008c-registry) for the full rule specification.
16+
17+
### Meta rules (SKL0xx)
1618

1719
- **SKL001**: Skip compiled skills (internal)
18-
- **SKL002**: `SKILL.md` must exist at skill root
19-
- **SKL003**: No empty directories
20-
21-
### File rules (SKL1xx)
22-
23-
- **SKL101**: Frontmatter must be valid YAML
24-
- **SKL102**: `name` field required in frontmatter
25-
- **SKL103**: `description` field required in frontmatter
26-
- **SKL104**: `name` must match directory name
27-
- **SKL105**: `description` should be 10-200 characters
28-
- **SKL106**: Title heading should match skill name
29-
- **SKL107**: Skill should have activation triggers
30-
- **SKL108**: `description` shouldn't start with "A skill..."
20+
21+
### Frontmatter rules (SKL1xx)
22+
23+
- **SKL100**: Frontmatter must be valid YAML
24+
- **SKL101**: `name` field required
25+
- **SKL102**: `name` format (lowercase, hyphens, digits only)
26+
- **SKL103**: `name` length (1-64 chars)
27+
- **SKL104**: `name` should match directory name
28+
- **SKL105**: `description` field required
29+
- **SKL106**: `description` must be non-empty
30+
- **SKL107**: `description` length (10-200 chars recommended)
31+
- **SKL108**: Include activation triggers
3132
- **SKL109**: Only known frontmatter fields allowed
3233

33-
### Markdown rules (SKL2xx)
34+
### Structure rules (SKL2xx)
3435

35-
- **SKL201**: Headings should use ATX style (`#`)
36-
- **SKL202**: Single H1 per file
37-
- **SKL203**: No skipped heading levels
38-
- **SKL204**: No trailing punctuation in headings
36+
- **SKL201**: SKILL.md size warning (>500 lines)
37+
- **SKL202**: Missing H1 heading
38+
- **SKL203**: H1 should match skill name
39+
- **SKL204**: First heading should be H1
40+
- **SKL205**: No skipped heading levels
3941

4042
### Link rules (SKL3xx)
4143

4244
- **SKL301**: Internal links must resolve
4345
- **SKL302**: Anchor links must resolve
46+
- **SKL303**: Links must not escape skill root
47+
48+
### File rules (SKL4xx)
49+
50+
- **SKL401**: No orphan files (files not linked from SKILL.md)
4451

4552
## Output formats
4653

gov/rfc/RFC-0001/rfc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
"notes": "Initial release"
5050
}
5151
],
52-
"signature": "b1fea06be63537da56748e580c5cd3c6fe983b2ff0f8428578921fe8f390f6f8"
52+
"signature": "94b3db4a23d6c62af6a620d43a06f82f367205019ace5b25764890d397886fb7"
5353
}

gov/rfc/RFC-0002/clauses/C-SOURCES.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"title": "Sources Command",
44
"kind": "normative",
55
"status": "active",
6-
"text": "**Syntax:** `skc sources <skill> [options]`\n\nThe sources command MUST list all files in the skill's source directory in a tree-style format.\n\n**Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--depth <n>` | Maximum tree depth to display (default: unlimited) |\n| `--dir <path>` | Scope listing to a subdirectory |\n| `--limit <n>` | Maximum entries to display (default: 100) |\n| `--pattern <glob>` | Filter files by glob pattern (e.g., `*.md`) |\n\n**Output format:**\n\nThe command MUST output a tree-style directory listing:\n- Files are listed with their relative paths\n- Directories that are not expanded MUST show a file count suffix: `dirname/ (N files)`\n- When `--limit` is exceeded, output MUST end with a truncation indicator: `... (N more)`\n\n**Ordering:**\nEntries MUST be sorted lexicographically by relative path (bytewise ASCII order), with directories listed before files at each level.\n\n**Example output:**\n\n```\n$ skc sources cuda --depth 2\ncuda/\n├── SKILL.md\n├── references/\n│ ├── compilation.md\n│ ├── cuda-driver-docs/ (156 files)\n│ ├── cuda-runtime-docs/ (89 files)\n│ ├── debugging-tools.md\n│ └── ... (8 more)\n```\n\n**Scoped listing:**\n\nWhen `--dir` is provided, the command MUST:\n- Validate that the path exists within the skill root\n- Display the subtree rooted at that directory\n- Apply `--depth` relative to the specified directory\n\n**Path safety:**\nThe command MUST reject any `--dir` path that would resolve outside the skill source directory after canonicalization. See [[RFC-0005:C-CODES]] for error E012.",
6+
"text": "**Syntax:** `skc sources <skill> [options]`\n\nThe sources command MUST list all files in the skill's source directory in a tree-style format.\n\n**Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--depth <n>` | Maximum tree depth to display (default: unlimited) |\n| `--dir <path>` | Scope listing to a subdirectory |\n| `--limit <n>` | Maximum entries to display (default: 100) |\n| `--pattern <glob>` | Filter files by glob pattern (e.g., `*.md`) |\n| `--format <fmt>` | Output format: `text` (default) or `json` |\n\n**Output format:**\n\nThe command MUST output a tree-style directory listing:\n- Files are listed with their relative paths\n- Directories that are not expanded MUST show a file count suffix: `dirname/ (N files)`\n- When `--limit` is exceeded, output MUST end with a truncation indicator: `... (N more)`\n\n**Ordering:**\nEntries MUST be sorted lexicographically by relative path (bytewise ASCII order), with directories listed before files at each level.\n\n**Example output:**\n\n```\n$ skc sources cuda --depth 2\ncuda/\n├── SKILL.md\n├── references/\n│ ├── compilation.md\n│ ├── cuda-driver-docs/ (156 files)\n│ ├── cuda-runtime-docs/ (89 files)\n│ ├── debugging-tools.md\n│ └── ... (8 more)\n```\n\n**Scoped listing:**\n\nWhen `--dir` is provided, the command MUST:\n- Validate that the path exists within the skill root\n- Display the subtree rooted at that directory\n- Apply `--depth` relative to the specified directory\n\n**Path safety:**\nThe command MUST reject any `--dir` path that would resolve outside the skill source directory after canonicalization. See [[RFC-0005:C-CODES]] for error E012.",
77
"since": "0.1.0"
88
}

gov/rfc/RFC-0002/rfc.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"rfc_id": "RFC-0002",
33
"title": "Gateway Protocol",
4-
"version": "0.1.0",
4+
"version": "0.2.1",
55
"status": "normative",
66
"phase": "test",
77
"owners": ["@govctl-org"],
88
"created": "2026-01-26",
9-
"updated": "2026-01-30",
9+
"updated": "2026-01-31",
1010
"sections": [
1111
{
1212
"title": "Summary",
@@ -24,11 +24,21 @@
2424
}
2525
],
2626
"changelog": [
27+
{
28+
"version": "0.2.1",
29+
"date": "2026-01-31",
30+
"notes": "Add missing --format support for "
31+
},
32+
{
33+
"version": "0.2.0",
34+
"date": "2026-01-31",
35+
"notes": "C-SHOW updated with em-dash stripping and suggestions"
36+
},
2737
{
2838
"version": "0.1.0",
2939
"date": "2026-01-30",
30-
"notes": "Initial release",
31-
"added": ["C-SHOW updated with em-dash stripping and suggestions"]
40+
"notes": "Initial release"
3241
}
33-
]
42+
],
43+
"signature": "4d3ec959504d040daf017ecc16258ba108dacad6458122eb5a4060efdfda8dd8"
3444
}

0 commit comments

Comments
 (0)