xtrm-tools 2.1.6 → 2.1.8
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/cli/dist/index.cjs +107 -22
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +4 -1
- package/config/hooks.json +5 -0
- package/hooks/README.md +19 -0
- package/hooks/beads-stop-gate.mjs +1 -0
- package/hooks/main-guard-post-push.mjs +71 -0
- package/package.json +11 -4
- package/project-skills/{py-quality-gate → quality-gates}/.claude/settings.json +10 -0
- package/project-skills/quality-gates/.claude/skills/using-quality-gates/SKILL.md +254 -0
- package/project-skills/quality-gates/README.md +109 -0
- package/project-skills/quality-gates/evals/evals.json +181 -0
- package/project-skills/quality-gates/workspace/iteration-1/FINAL-EVAL-SUMMARY.md +75 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-auto-fix-verification/with_skill/outputs/response.md +59 -0
- package/project-skills/quality-gates/workspace/iteration-1/edge-case-mixed-language-project/with_skill/outputs/response.md +60 -0
- package/project-skills/quality-gates/workspace/iteration-1/eval-summary.md +105 -0
- package/project-skills/quality-gates/workspace/iteration-1/partial-install-python-only/with_skill/outputs/response.md +93 -0
- package/project-skills/quality-gates/workspace/iteration-1/python-refactor-request/with_skill/outputs/response.md +104 -0
- package/project-skills/quality-gates/workspace/iteration-1/quality-gate-error-fix/with_skill/outputs/response.md +74 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-general-chat/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-math-question/with_skill/outputs/response.md +18 -0
- package/project-skills/quality-gates/workspace/iteration-1/should-not-trigger-unrelated-coding/with_skill/outputs/response.md +56 -0
- package/project-skills/quality-gates/workspace/iteration-1/tdd-guard-blocking-confusion/with_skill/outputs/response.md +67 -0
- package/project-skills/quality-gates/workspace/iteration-1/typescript-feature-with-tests/with_skill/outputs/response.md +97 -0
- package/project-skills/tdd-guard/.claude/hooks/tdd-guard-pretool-bridge.cjs +0 -1
- package/hooks/__pycache__/agent_context.cpython-314.pyc +0 -0
- package/project-skills/py-quality-gate/.claude/skills/using-py-quality-gate/SKILL.md +0 -112
- package/project-skills/py-quality-gate/README.md +0 -147
- package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/doc_reminder.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/skill_staleness.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/cataloger.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/skill_activator.cpython-314.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/test_skill_activator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/test_skill_activator.py +0 -58
- package/project-skills/service-skills-set/__pycache__/install-service-skills.cpython-314.pyc +0 -0
- package/project-skills/ts-quality-gate/.claude/settings.json +0 -16
- package/project-skills/ts-quality-gate/.claude/skills/using-ts-quality-gate/SKILL.md +0 -81
- package/project-skills/ts-quality-gate/README.md +0 -115
- package/skills/documenting/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/__pycache__/orchestrator.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/__pycache__/validate_metadata.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/add_entry.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/bump_release.cpython-314.pyc +0 -0
- package/skills/documenting/scripts/changelog/__pycache__/validate_changelog.cpython-314.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_changelog.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_drift_detector.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_orchestrator.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/__pycache__/test_validate_metadata.cpython-314-pytest-9.0.2.pyc +0 -0
- package/skills/documenting/tests/integration_test.sh +0 -70
- package/skills/documenting/tests/test_changelog.py +0 -201
- package/skills/documenting/tests/test_drift_detector.py +0 -80
- package/skills/documenting/tests/test_orchestrator.py +0 -52
- package/skills/documenting/tests/test_validate_metadata.py +0 -64
- /package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/hook-config.json +0 -0
- /package/project-skills/{ts-quality-gate → quality-gates}/.claude/hooks/quality-check.cjs +0 -0
- /package/project-skills/{py-quality-gate → quality-gates}/.claude/hooks/quality-check.py +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"hooks": {
|
|
3
|
-
"PostToolUse": [
|
|
4
|
-
{
|
|
5
|
-
"matcher": "Write|Edit|MultiEdit|mcp__serena__rename_symbol|mcp__serena__replace_symbol_body|mcp__serena__insert_after_symbol|mcp__serena__insert_before_symbol",
|
|
6
|
-
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
"type": "command",
|
|
9
|
-
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/quality-check.cjs\"",
|
|
10
|
-
"timeout": 30
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Using TS Quality Gate
|
|
2
|
-
|
|
3
|
-
**TS Quality Gate** enforces TypeScript, ESLint, and Prettier quality checks on every file edit. It provides immediate feedback and auto-fixes issues when possible.
|
|
4
|
-
|
|
5
|
-
## What It Does
|
|
6
|
-
|
|
7
|
-
- **TypeScript compilation check** - Catches type errors immediately
|
|
8
|
-
- **ESLint validation** - Enforces code style and best practices
|
|
9
|
-
- **Prettier formatting** - Ensures consistent code formatting
|
|
10
|
-
- **Auto-fix** - Automatically fixes issues when possible
|
|
11
|
-
- **Fast feedback** - Runs in <1s for most files
|
|
12
|
-
|
|
13
|
-
## How It Works
|
|
14
|
-
|
|
15
|
-
When you edit a TypeScript/JavaScript file:
|
|
16
|
-
|
|
17
|
-
1. PostToolUse hook fires after Write/Edit
|
|
18
|
-
2. Runs `quality-check.js` with the file path
|
|
19
|
-
3. Checks TypeScript compilation, ESLint, Prettier
|
|
20
|
-
4. Auto-fixes issues if configured
|
|
21
|
-
5. Returns exit code 2 if blocking errors found
|
|
22
|
-
|
|
23
|
-
## Configuration
|
|
24
|
-
|
|
25
|
-
The quality gate is configured via `.claude/hooks/hook-config.json`:
|
|
26
|
-
|
|
27
|
-
```json
|
|
28
|
-
{
|
|
29
|
-
"typescript": {
|
|
30
|
-
"enabled": true,
|
|
31
|
-
"showDependencyErrors": false
|
|
32
|
-
},
|
|
33
|
-
"eslint": {
|
|
34
|
-
"enabled": true,
|
|
35
|
-
"autofix": true
|
|
36
|
-
},
|
|
37
|
-
"prettier": {
|
|
38
|
-
"enabled": true,
|
|
39
|
-
"autofix": true
|
|
40
|
-
},
|
|
41
|
-
"general": {
|
|
42
|
-
"autofixSilent": true,
|
|
43
|
-
"debug": false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Requirements
|
|
49
|
-
|
|
50
|
-
- Node.js 18+
|
|
51
|
-
- TypeScript installed in project
|
|
52
|
-
- ESLint installed in project (optional)
|
|
53
|
-
- Prettier installed in project (optional)
|
|
54
|
-
|
|
55
|
-
## Installation
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
# Install project skill
|
|
59
|
-
xtrm install project ts-quality-gate
|
|
60
|
-
|
|
61
|
-
# Ensure dependencies are installed in your project
|
|
62
|
-
npm install --save-dev typescript eslint prettier
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Troubleshooting
|
|
66
|
-
|
|
67
|
-
**"ESLint not found"**
|
|
68
|
-
- Install ESLint: `npm install --save-dev eslint`
|
|
69
|
-
- Or disable in hook-config.json: `"eslint": { "enabled": false }`
|
|
70
|
-
|
|
71
|
-
**"Prettier not found"**
|
|
72
|
-
- Install Prettier: `npm install --save-dev prettier`
|
|
73
|
-
- Or disable in hook-config.json: `"prettier": { "enabled": false }`
|
|
74
|
-
|
|
75
|
-
**TypeScript errors from dependencies**
|
|
76
|
-
- Set `"showDependencyErrors": false` in hook-config.json
|
|
77
|
-
|
|
78
|
-
## See Also
|
|
79
|
-
|
|
80
|
-
- Full documentation: `.claude/docs/ts-quality-gate-readme.md`
|
|
81
|
-
- Reference: https://github.com/bartolli/claude-code-typescript-hooks
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# TS Quality Gate
|
|
2
|
-
|
|
3
|
-
**TypeScript/ESLint/Prettier quality gate** for Claude Code. Runs automatically on every file edit to ensure code quality.
|
|
4
|
-
|
|
5
|
-
## What It Does
|
|
6
|
-
|
|
7
|
-
TS Quality Gate enforces code quality standards in real-time:
|
|
8
|
-
|
|
9
|
-
| Check | Description | Auto-fix |
|
|
10
|
-
|-------|-------------|----------|
|
|
11
|
-
| **TypeScript** | Compilation errors, type safety | No |
|
|
12
|
-
| **ESLint** | Code style, best practices, rules | Yes (if enabled) |
|
|
13
|
-
| **Prettier** | Code formatting consistency | Yes (if enabled) |
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# Install project skill
|
|
19
|
-
xtrm install project ts-quality-gate
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**Post-install:** Ensure your project has the required dependencies:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install --save-dev typescript eslint prettier
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## How It Works
|
|
29
|
-
|
|
30
|
-
The quality gate runs as a `PostToolUse` hook:
|
|
31
|
-
|
|
32
|
-
1. You edit a TypeScript/JavaScript file
|
|
33
|
-
2. After the edit completes, the hook fires
|
|
34
|
-
3. `quality-check.cjs` validates the file
|
|
35
|
-
4. Issues are reported with auto-fix when possible
|
|
36
|
-
5. Exit code 2 blocks if critical errors found
|
|
37
|
-
|
|
38
|
-
## Configuration
|
|
39
|
-
|
|
40
|
-
Edit `.claude/hooks/hook-config.json` to customize:
|
|
41
|
-
|
|
42
|
-
```json
|
|
43
|
-
{
|
|
44
|
-
"typescript": {
|
|
45
|
-
"enabled": true,
|
|
46
|
-
"showDependencyErrors": false
|
|
47
|
-
},
|
|
48
|
-
"eslint": {
|
|
49
|
-
"enabled": true,
|
|
50
|
-
"autofix": true
|
|
51
|
-
},
|
|
52
|
-
"prettier": {
|
|
53
|
-
"enabled": true,
|
|
54
|
-
"autofix": true
|
|
55
|
-
},
|
|
56
|
-
"general": {
|
|
57
|
-
"autofixSilent": true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Environment Variable Overrides
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
export CLAUDE_HOOKS_TYPESCRIPT_ENABLED=false
|
|
66
|
-
export CLAUDE_HOOKS_ESLINT_AUTOFIX=true
|
|
67
|
-
export CLAUDE_HOOKS_PRETTIER_ENABLED=false
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Features
|
|
71
|
-
|
|
72
|
-
### TypeScript Checking
|
|
73
|
-
- Uses project's tsconfig.json
|
|
74
|
-
- Checks only edited file (fast)
|
|
75
|
-
- Optionally shows dependency errors
|
|
76
|
-
|
|
77
|
-
### ESLint Integration
|
|
78
|
-
- Auto-discovers .eslintrc or eslint.config.js
|
|
79
|
-
- Auto-fixes when `autofix: true`
|
|
80
|
-
- Reports errors and warnings
|
|
81
|
-
|
|
82
|
-
### Prettier Formatting
|
|
83
|
-
- Auto-discovers .prettierrc
|
|
84
|
-
- Auto-formats when `autofix: true`
|
|
85
|
-
- Supports all Prettier options
|
|
86
|
-
|
|
87
|
-
### Smart File Detection
|
|
88
|
-
- Skips non-source files
|
|
89
|
-
- Detects test files, CLI files, services
|
|
90
|
-
- Applies file-type-specific rules
|
|
91
|
-
|
|
92
|
-
## Exit Codes
|
|
93
|
-
|
|
94
|
-
| Code | Meaning |
|
|
95
|
-
|------|---------|
|
|
96
|
-
| 0 | All checks passed |
|
|
97
|
-
| 1 | Fatal error (hook crashed) |
|
|
98
|
-
| 2 | Blocking errors found (Claude must fix) |
|
|
99
|
-
|
|
100
|
-
## Troubleshooting
|
|
101
|
-
|
|
102
|
-
**Hook not running**
|
|
103
|
-
- Verify PostToolUse hook in `.claude/settings.json`
|
|
104
|
-
- Check hook path is correct
|
|
105
|
-
|
|
106
|
-
**TypeScript errors from node_modules**
|
|
107
|
-
- Set `showDependencyErrors: false`
|
|
108
|
-
|
|
109
|
-
**ESLint/Prettier not found**
|
|
110
|
-
- Install in project: `npm install --save-dev eslint prettier`
|
|
111
|
-
- Or disable in config
|
|
112
|
-
|
|
113
|
-
## Reference
|
|
114
|
-
|
|
115
|
-
Based on: https://github.com/bartolli/claude-code-typescript-hooks
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/skills/documenting/tests/__pycache__/test_drift_detector.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file
|
|
Binary file
|
package/skills/documenting/tests/__pycache__/test_validate_metadata.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Integration test for documenting skill workflows
|
|
3
|
-
|
|
4
|
-
set -e # Exit on error
|
|
5
|
-
|
|
6
|
-
TEST_DIR=$(mktemp -d)
|
|
7
|
-
echo "Test directory: $TEST_DIR"
|
|
8
|
-
|
|
9
|
-
# Ensure we are in the skill root (skills/documenting)
|
|
10
|
-
cd "$(dirname "$0")/.."
|
|
11
|
-
SKILL_ROOT=$(pwd)
|
|
12
|
-
echo "Skill root: $SKILL_ROOT"
|
|
13
|
-
|
|
14
|
-
# Test 1: Initialize CHANGELOG
|
|
15
|
-
echo "Test 1: Initialize CHANGELOG"
|
|
16
|
-
python3 -m scripts.changelog.init_changelog "$TEST_DIR/CHANGELOG.md"
|
|
17
|
-
python3 -m scripts.changelog.validate_changelog "$TEST_DIR/CHANGELOG.md"
|
|
18
|
-
echo "✅ CHANGELOG initialization passed"
|
|
19
|
-
|
|
20
|
-
# Test 2: Add entries
|
|
21
|
-
echo ""
|
|
22
|
-
echo "Test 2: Add entries to CHANGELOG"
|
|
23
|
-
python3 -m scripts.changelog.add_entry "$TEST_DIR/CHANGELOG.md" Added "Feature A"
|
|
24
|
-
python3 -m scripts.changelog.add_entry "$TEST_DIR/CHANGELOG.md" Fixed "Bug B"
|
|
25
|
-
python3 -m scripts.changelog.add_entry "$TEST_DIR/CHANGELOG.md" Changed "Refactor C"
|
|
26
|
-
python3 -m scripts.changelog.validate_changelog "$TEST_DIR/CHANGELOG.md"
|
|
27
|
-
echo "✅ Entry addition passed"
|
|
28
|
-
|
|
29
|
-
# Test 3: Bump release
|
|
30
|
-
echo ""
|
|
31
|
-
echo "Test 3: Bump release version"
|
|
32
|
-
python3 -m scripts.changelog.bump_release "$TEST_DIR/CHANGELOG.md" "1.0.0"
|
|
33
|
-
python3 -m scripts.changelog.validate_changelog "$TEST_DIR/CHANGELOG.md"
|
|
34
|
-
|
|
35
|
-
# Verify [Unreleased] is empty and [1.0.0] has entries
|
|
36
|
-
# Check 3 lines after Unreleased (header, empty line, next header)
|
|
37
|
-
if grep -A 2 "\[Unreleased\]" "$TEST_DIR/CHANGELOG.md" | grep -q "^- "; then
|
|
38
|
-
echo "❌ [Unreleased] should be empty after bump"
|
|
39
|
-
cat "$TEST_DIR/CHANGELOG.md"
|
|
40
|
-
exit 1
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
if ! grep -A 10 "\[1.0.0\]" "$TEST_DIR/CHANGELOG.md" | grep -q "Feature A"; then
|
|
44
|
-
echo "❌ [1.0.0] should contain Feature A"
|
|
45
|
-
exit 1
|
|
46
|
-
fi
|
|
47
|
-
echo "✅ Release bump passed"
|
|
48
|
-
|
|
49
|
-
# Test 4: Orchestrator
|
|
50
|
-
echo ""
|
|
51
|
-
echo "Test 4: Orchestrator workflow"
|
|
52
|
-
mkdir -p "$TEST_DIR/.serena/memories"
|
|
53
|
-
cp "$TEST_DIR/CHANGELOG.md" "$TEST_DIR/CHANGELOG.md.backup"
|
|
54
|
-
|
|
55
|
-
python3 -m scripts.orchestrator "$TEST_DIR" feature "Orchestrator test feature" --scope=test --category=testing
|
|
56
|
-
|
|
57
|
-
# Verify CHANGELOG updated
|
|
58
|
-
if ! grep -q "Orchestrator test feature" "$TEST_DIR/CHANGELOG.md"; then
|
|
59
|
-
echo "❌ Orchestrator should have updated CHANGELOG"
|
|
60
|
-
exit 1
|
|
61
|
-
fi
|
|
62
|
-
echo "✅ Orchestrator passed"
|
|
63
|
-
|
|
64
|
-
# Cleanup
|
|
65
|
-
rm -rf "$TEST_DIR"
|
|
66
|
-
|
|
67
|
-
echo ""
|
|
68
|
-
echo "========================================="
|
|
69
|
-
echo "✅ All integration tests passed!"
|
|
70
|
-
echo "========================================="
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Tests for CHANGELOG management scripts."""
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from scripts.changelog.validate_changelog import validate_changelog
|
|
7
|
-
from scripts.changelog.add_entry import add_entry, ChangeCategory
|
|
8
|
-
from scripts.changelog.bump_release import bump_release
|
|
9
|
-
from datetime import date
|
|
10
|
-
import tempfile
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_valid_changelog_passes():
|
|
14
|
-
"""Valid Keep a Changelog format should pass validation."""
|
|
15
|
-
valid_content = """# Changelog
|
|
16
|
-
|
|
17
|
-
All notable changes to this project will be documented in this file.
|
|
18
|
-
|
|
19
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
20
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
21
|
-
|
|
22
|
-
## [Unreleased]
|
|
23
|
-
|
|
24
|
-
### Added
|
|
25
|
-
- New feature description
|
|
26
|
-
|
|
27
|
-
## [1.0.0] - 2026-02-01
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
- Initial release
|
|
31
|
-
"""
|
|
32
|
-
result = validate_changelog(valid_content)
|
|
33
|
-
assert result["valid"] is True
|
|
34
|
-
assert len(result["errors"]) == 0
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_missing_unreleased_section_fails():
|
|
38
|
-
"""CHANGELOG without [Unreleased] section should fail."""
|
|
39
|
-
invalid_content = """# Changelog
|
|
40
|
-
|
|
41
|
-
## [1.0.0] - 2026-02-01
|
|
42
|
-
|
|
43
|
-
### Added
|
|
44
|
-
- Initial release
|
|
45
|
-
"""
|
|
46
|
-
result = validate_changelog(invalid_content)
|
|
47
|
-
assert result["valid"] is False
|
|
48
|
-
assert any("Unreleased" in err for err in result["errors"])
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_invalid_semver_fails():
|
|
52
|
-
"""CHANGELOG with invalid semver should fail."""
|
|
53
|
-
invalid_content = """# Changelog
|
|
54
|
-
|
|
55
|
-
## [Unreleased]
|
|
56
|
-
|
|
57
|
-
## [1.0] - 2026-02-01
|
|
58
|
-
|
|
59
|
-
### Added
|
|
60
|
-
- Initial release
|
|
61
|
-
"""
|
|
62
|
-
result = validate_changelog(invalid_content)
|
|
63
|
-
assert result["valid"] is False
|
|
64
|
-
assert any("semantic version" in err.lower() for err in result["errors"])
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def test_invalid_category_fails():
|
|
68
|
-
"""CHANGELOG with invalid category should fail."""
|
|
69
|
-
invalid_content = """# Changelog
|
|
70
|
-
|
|
71
|
-
## [Unreleased]
|
|
72
|
-
|
|
73
|
-
### InvalidCategory
|
|
74
|
-
- Some change
|
|
75
|
-
|
|
76
|
-
## [1.0.0] - 2026-02-01
|
|
77
|
-
|
|
78
|
-
### Added
|
|
79
|
-
- Initial release
|
|
80
|
-
"""
|
|
81
|
-
result = validate_changelog(invalid_content)
|
|
82
|
-
assert result["valid"] is False
|
|
83
|
-
assert any("category" in err.lower() for err in result["errors"])
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def test_add_entry_to_unreleased():
|
|
87
|
-
"""Adding entry should place it under [Unreleased] in correct category."""
|
|
88
|
-
changelog_content = """# Changelog
|
|
89
|
-
|
|
90
|
-
## [Unreleased]
|
|
91
|
-
|
|
92
|
-
## [1.0.0] - 2026-02-01
|
|
93
|
-
|
|
94
|
-
### Added
|
|
95
|
-
- Initial release
|
|
96
|
-
"""
|
|
97
|
-
|
|
98
|
-
result = add_entry(
|
|
99
|
-
changelog_content,
|
|
100
|
-
category=ChangeCategory.ADDED,
|
|
101
|
-
description="New feature X"
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
assert "### Added" in result
|
|
105
|
-
assert "- New feature X" in result
|
|
106
|
-
# Should be under [Unreleased], not under [1.0.0]
|
|
107
|
-
unreleased_section = result.split("## [1.0.0]")[0]
|
|
108
|
-
assert "- New feature X" in unreleased_section
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def test_add_entry_creates_category_if_missing():
|
|
112
|
-
"""Adding entry should create category section if it doesn't exist."""
|
|
113
|
-
changelog_content = """# Changelog
|
|
114
|
-
|
|
115
|
-
## [Unreleased]
|
|
116
|
-
|
|
117
|
-
## [1.0.0] - 2026-02-01
|
|
118
|
-
|
|
119
|
-
### Added
|
|
120
|
-
- Initial release
|
|
121
|
-
"""
|
|
122
|
-
|
|
123
|
-
result = add_entry(
|
|
124
|
-
changelog_content,
|
|
125
|
-
category=ChangeCategory.FIXED,
|
|
126
|
-
description="Bug fix Y"
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
assert "### Fixed" in result
|
|
130
|
-
assert "- Bug fix Y" in result
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def test_add_entry_maintains_category_order():
|
|
134
|
-
"""Categories should be ordered: Added, Changed, Deprecated, Removed, Fixed, Security."""
|
|
135
|
-
changelog_content = """# Changelog
|
|
136
|
-
|
|
137
|
-
## [Unreleased]
|
|
138
|
-
|
|
139
|
-
### Added
|
|
140
|
-
- Feature A
|
|
141
|
-
|
|
142
|
-
### Fixed
|
|
143
|
-
- Bug B
|
|
144
|
-
|
|
145
|
-
## [1.0.0] - 2026-02-01
|
|
146
|
-
"""
|
|
147
|
-
|
|
148
|
-
result = add_entry(
|
|
149
|
-
changelog_content,
|
|
150
|
-
category=ChangeCategory.CHANGED,
|
|
151
|
-
description="Change C"
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
# Changed should appear between Added and Fixed
|
|
155
|
-
lines = result.split('\n')
|
|
156
|
-
added_idx = next(i for i, line in enumerate(lines) if "### Added" in line)
|
|
157
|
-
changed_idx = next(i for i, line in enumerate(lines) if "### Changed" in line)
|
|
158
|
-
fixed_idx = next(i for i, line in enumerate(lines) if "### Fixed" in line)
|
|
159
|
-
|
|
160
|
-
assert added_idx < changed_idx < fixed_idx
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def test_bump_release_moves_unreleased():
|
|
164
|
-
"""Bumping release should move [Unreleased] to [X.Y.Z] - DATE."""
|
|
165
|
-
changelog_content = """# Changelog
|
|
166
|
-
|
|
167
|
-
## [Unreleased]
|
|
168
|
-
|
|
169
|
-
### Added
|
|
170
|
-
- New feature
|
|
171
|
-
|
|
172
|
-
## [1.0.0] - 2026-01-01
|
|
173
|
-
|
|
174
|
-
### Added
|
|
175
|
-
- Initial release
|
|
176
|
-
"""
|
|
177
|
-
|
|
178
|
-
result = bump_release(changelog_content, "1.1.0")
|
|
179
|
-
|
|
180
|
-
# Should have new version section
|
|
181
|
-
assert "## [1.1.0]" in result
|
|
182
|
-
assert f"## [1.1.0] - {date.today().strftime('%Y-%m-%d')}" in result
|
|
183
|
-
|
|
184
|
-
# New feature should be under 1.1.0 now
|
|
185
|
-
version_section = result.split("## [1.0.0]")[0]
|
|
186
|
-
assert "- New feature" in version_section
|
|
187
|
-
|
|
188
|
-
# [Unreleased] should be empty
|
|
189
|
-
unreleased_section = result.split("## [1.1.0]")[0]
|
|
190
|
-
assert "## [Unreleased]" in unreleased_section
|
|
191
|
-
# No ### categories under [Unreleased]
|
|
192
|
-
unreleased_lines = unreleased_section.split("## [Unreleased]")[1].split('\\n')
|
|
193
|
-
assert not any(line.startswith("###") for line in unreleased_lines)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
def test_bump_release_validates_semver():
|
|
197
|
-
"""Bumping with invalid semver should raise error."""
|
|
198
|
-
changelog_content = "## [Unreleased]"
|
|
199
|
-
|
|
200
|
-
with pytest.raises(ValueError, match="semantic version"):
|
|
201
|
-
bump_release(changelog_content, "1.0")
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import sys
|
|
4
|
-
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
|
|
5
|
-
from drift_detector import extract_tracks, match_files_to_tracks, format_scan_report
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
MEMORY_WITH_TRACKS = """---
|
|
9
|
-
title: Test SSOT
|
|
10
|
-
version: 1.0.0
|
|
11
|
-
updated: 2026-02-01
|
|
12
|
-
tracks:
|
|
13
|
-
- "cli/src/**/*.ts"
|
|
14
|
-
- "hooks/**/*.py"
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Purpose
|
|
18
|
-
Test memory.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
MEMORY_NO_TRACKS = """---
|
|
22
|
-
title: No Tracks
|
|
23
|
-
version: 1.0.0
|
|
24
|
-
updated: 2026-02-01
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Purpose
|
|
28
|
-
No tracking.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_extract_tracks_finds_globs():
|
|
33
|
-
tracks = extract_tracks(MEMORY_WITH_TRACKS)
|
|
34
|
-
assert tracks == ["cli/src/**/*.ts", "hooks/**/*.py"]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_extract_tracks_empty_when_missing():
|
|
38
|
-
tracks = extract_tracks(MEMORY_NO_TRACKS)
|
|
39
|
-
assert tracks == []
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def test_match_files_to_tracks_hit():
|
|
43
|
-
files = ["cli/src/core/diff.ts", "hooks/skill-suggestion.py"]
|
|
44
|
-
tracks = ["cli/src/**/*.ts", "hooks/**/*.py"]
|
|
45
|
-
matched = match_files_to_tracks(files, tracks)
|
|
46
|
-
assert "cli/src/core/diff.ts" in matched
|
|
47
|
-
assert "hooks/skill-suggestion.py" in matched
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def test_match_files_to_tracks_miss():
|
|
51
|
-
files = ["docs/README.md"]
|
|
52
|
-
tracks = ["cli/src/**/*.ts"]
|
|
53
|
-
assert match_files_to_tracks(files, tracks) == []
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def test_format_scan_report_stale():
|
|
57
|
-
stale = {"my_memory": {"files": ["cli/src/core/diff.ts"], "updated": "2026-02-01"}}
|
|
58
|
-
report = format_scan_report(stale)
|
|
59
|
-
assert "my_memory" in report
|
|
60
|
-
assert "cli/src/core/diff.ts" in report
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test_format_scan_report_clean():
|
|
64
|
-
report = format_scan_report({})
|
|
65
|
-
assert any(word in report.lower() for word in ["clean", "no stale", "up to date"])
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def test_match_files_to_tracks_no_false_positive():
|
|
69
|
-
"""A .py file in an unrelated dir must NOT match hooks/**/*.py"""
|
|
70
|
-
files = ["cli/src/transform.py", "docs/something.py"]
|
|
71
|
-
tracks = ["hooks/**/*.py"]
|
|
72
|
-
assert match_files_to_tracks(files, tracks) == []
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def test_match_files_to_tracks_direct_child():
|
|
76
|
-
"""hooks/**/*.py must match files directly under hooks/ (no subdir)"""
|
|
77
|
-
files = ["hooks/skill-suggestion.py"]
|
|
78
|
-
tracks = ["hooks/**/*.py"]
|
|
79
|
-
matched = match_files_to_tracks(files, tracks)
|
|
80
|
-
assert "hooks/skill-suggestion.py" in matched
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Tests for documentation orchestrator."""
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from scripts.orchestrator import DocumentingOrchestrator, ChangeType
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_orchestrator_routes_to_correct_docs(tmp_path):
|
|
10
|
-
"""Orchestrator should update relevant docs based on change type."""
|
|
11
|
-
# Setup test project
|
|
12
|
-
project_root = tmp_path / "test_project"
|
|
13
|
-
project_root.mkdir()
|
|
14
|
-
|
|
15
|
-
changelog = project_root / "CHANGELOG.md"
|
|
16
|
-
changelog.write_text("""# Changelog
|
|
17
|
-
|
|
18
|
-
## [Unreleased]
|
|
19
|
-
|
|
20
|
-
## [0.1.0] - 2026-02-01
|
|
21
|
-
|
|
22
|
-
### Added
|
|
23
|
-
- Initial release
|
|
24
|
-
""", encoding="utf-8")
|
|
25
|
-
|
|
26
|
-
serena_memories = project_root / ".serena" / "memories"
|
|
27
|
-
serena_memories.mkdir(parents=True)
|
|
28
|
-
|
|
29
|
-
orchestrator = DocumentingOrchestrator(project_root)
|
|
30
|
-
|
|
31
|
-
result = orchestrator.document_change(
|
|
32
|
-
change_type=ChangeType.FEATURE,
|
|
33
|
-
description="Add new API endpoint",
|
|
34
|
-
details={
|
|
35
|
-
"scope": "api-endpoints",
|
|
36
|
-
"category": "backend",
|
|
37
|
-
"files_changed": ["server.py", "routes/api.py"]
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
# Should update CHANGELOG
|
|
42
|
-
assert result["changelog_updated"] is True
|
|
43
|
-
# Should create/update SSOT
|
|
44
|
-
assert result["ssot_updated"] is False # Placeholder impl in plan returns False
|
|
45
|
-
# Should suggest README update
|
|
46
|
-
assert "readme_suggestions" in result
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def test_orchestrator_validates_all_docs():
|
|
50
|
-
"""Orchestrator should validate all documentation after updates."""
|
|
51
|
-
# Test validation integration
|
|
52
|
-
pass
|