Skip to content

Commit 0bc6d72

Browse files
authored
Merge pull request #13 from costiash/fix/critical-bugs-handle
feat!: v0.5.0 - Version-aware upgrade mechanism with breaking changes
2 parents e4f8f59 + db56701 commit 0bc6d72

File tree

633 files changed

+1050404
-9371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

633 files changed

+1050404
-9371
lines changed

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Mark documentation files as generated content
2+
# This prevents them from appearing in PR diffs by default
3+
# and excludes them from language statistics
4+
5+
docs/*.md linguist-generated=true
6+
docs/**/*.md linguist-generated=true
7+
8+
# Also mark search index as generated
9+
docs/.search_index.json linguist-generated=true

.github/workflows/claude-code-review.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name: Claude Code Review
33
on:
44
pull_request:
55
types: [opened, synchronize]
6-
# Optional: Only run on specific file changes
7-
# paths:
8-
# - "src/**/*.ts"
9-
# - "src/**/*.tsx"
10-
# - "src/**/*.js"
11-
# - "src/**/*.jsx"
6+
# Ignore documentation files (auto-generated, large volume)
7+
paths-ignore:
8+
- "docs/**"
9+
- "docs/*.md"
10+
- "*.md"
11+
- "enhancements/**"
1212

1313
jobs:
1414
claude-review:

.github/workflows/update-docs.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@ jobs:
2929
run: |
3030
python -m pip install --upgrade pip
3131
pip install -r scripts/requirements.txt
32-
32+
33+
# =================================================================
34+
# SAFEGUARD: Count files BEFORE fetch to detect mass deletions
35+
# =================================================================
36+
- name: Count files before fetch
37+
id: count-before
38+
run: |
39+
BEFORE=$(find docs/ -name "*.md" 2>/dev/null | wc -l)
40+
echo "count=$BEFORE" >> $GITHUB_OUTPUT
41+
echo "📊 Files before fetch: $BEFORE"
42+
3343
- name: Fetch latest documentation
3444
id: fetch-docs
3545
env:
@@ -38,7 +48,51 @@ jobs:
3848
run: |
3949
python scripts/fetch_claude_docs.py || echo "fetch_failed=true" >> $GITHUB_OUTPUT
4050
continue-on-error: true
41-
51+
52+
# =================================================================
53+
# SAFEGUARD: Validate file count AFTER fetch (FAIL + REVERT on trigger)
54+
# =================================================================
55+
- name: Validate after fetch (safeguard)
56+
id: validate-safeguard
57+
run: |
58+
AFTER=$(find docs/ -name "*.md" 2>/dev/null | wc -l)
59+
BEFORE=${{ steps.count-before.outputs.count }}
60+
61+
echo "📊 Files after fetch: $AFTER (was: $BEFORE)"
62+
63+
# SAFEGUARD 1: Check deletion percentage
64+
if [ "$BEFORE" -gt 0 ]; then
65+
DELETED=$((BEFORE - AFTER))
66+
if [ "$DELETED" -lt 0 ]; then
67+
DELETED=0
68+
fi
69+
PERCENT=$((DELETED * 100 / BEFORE))
70+
71+
if [ "$PERCENT" -gt 10 ]; then
72+
echo "::error::🚨 SAFEGUARD TRIGGERED: $PERCENT% of files would be deleted!"
73+
echo "::error:: Before: $BEFORE files, After: $AFTER files, Would delete: $DELETED"
74+
echo "::error:: This indicates sitemap discovery failure."
75+
echo ""
76+
echo "Reverting docs/ to previous state..."
77+
git checkout -- docs/
78+
echo "safeguard_triggered=true" >> $GITHUB_OUTPUT
79+
echo "::error::Workflow failed. Manual investigation required."
80+
exit 1
81+
fi
82+
fi
83+
84+
# SAFEGUARD 2: Check minimum file count
85+
if [ "$AFTER" -lt 250 ]; then
86+
echo "::error::🚨 SAFEGUARD TRIGGERED: Only $AFTER files remain (expected 250+)!"
87+
echo "Reverting docs/ to previous state..."
88+
git checkout -- docs/
89+
echo "safeguard_triggered=true" >> $GITHUB_OUTPUT
90+
echo "::error::Workflow failed. Manual investigation required."
91+
exit 1
92+
fi
93+
94+
echo "✅ Safeguard validation passed: $AFTER files present"
95+
4296
- name: Check for changes
4397
id: verify-changed-files
4498
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ claude-docs-helper.sh
9090
# Upstream reference repository (local development only)
9191
upstream/
9292

93+
# Archive folder (legacy/orphaned scripts)
94+
archive/
95+
9396
# ============================================================================
9497
# Documentation & Tracking Files (DO NOT COMMIT)
9598
# ============================================================================

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,50 @@ All notable changes to the enhanced edition of claude-code-docs will be document
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.0] - 2025-12-06
9+
10+
### Breaking Changes
11+
- **Filename Convention Changed**: All Claude Code CLI docs renamed to use domain-based prefix
12+
- Old: `docs__en__<topic>.md` (e.g., `docs__en__hooks.md`)
13+
- New: `claude-code__<topic>.md` (e.g., `claude-code__hooks.md`)
14+
- Platform docs use: `docs__en__<path>.md`
15+
- **Scripts Restructured**: Monolithic scripts replaced with modular packages
16+
- Added: `scripts/fetcher/` (8 modules for documentation fetching)
17+
- Added: `scripts/lookup/` (7 modules for search and validation)
18+
- Removed: `main.py`, `update_sitemap.py`, `extract_paths.py`, `clean_manifest.py`
19+
20+
### Added
21+
- **2x Documentation Coverage**: 571 files (up from ~270)
22+
- **573 Tracked Paths**: Comprehensive coverage across 6 categories
23+
- API Reference: 377 paths (65.8%)
24+
- Core Documentation: 82 paths (14.3%)
25+
- Prompt Library: 65 paths (11.3%)
26+
- Claude Code: 46 paths (8.0%)
27+
- Release Notes: 2 paths
28+
- Resources: 1 path
29+
- **Safety Thresholds**: Prevent catastrophic deletion during automated sync
30+
- `MIN_DISCOVERY_THRESHOLD`: 200 paths minimum from sitemaps
31+
- `MAX_DELETION_PERCENT`: 10% maximum deletion per sync
32+
- `MIN_EXPECTED_FILES`: 250 minimum files required
33+
- **Modular Architecture**: Better code organization and testability
34+
- `fetcher/` package: config, manifest, paths, sitemap, content, safeguards, cli
35+
- `lookup/` package: config, manifest, search, validation, formatting, cli
36+
- **Domain-Based Naming**: Clear source identification in filenames
37+
- `claude-code__*.md` from code.claude.com
38+
- `docs__en__*.md` from platform.claude.com
39+
- **Version-Aware Upgrades**: Installer detects existing version and shows upgrade info
40+
41+
### Changed
42+
- **Manifest Structure**: `paths_manifest.json` now tracks 573 paths in 6 categories
43+
- **Search Index**: Updated to cover all 571 documentation files
44+
- **Python Packages**: Thin wrappers (`fetch_claude_docs.py`, `lookup_paths.py`) for backward compatibility
45+
46+
### Upgrade Notes
47+
- **Seamless Upgrade**: Run `install.sh` again to upgrade from any v0.4.x version
48+
- **No Data Loss**: All user configs remain in `~/.claude/`
49+
- **Atomic Operation**: Installation uses temp directory, moves atomically
50+
- The installer will show before/after comparison during upgrade
51+
852
## [0.4.2] - 2025-11-25
953

1054
### Fixed

CLAUDE.md

Lines changed: 85 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
# Claude Code Documentation Mirror - Enhanced Edition
22

3-
This repository contains local copies of Claude Code documentation from https://docs.anthropic.com/en/docs/claude-code/
4-
5-
The docs are periodically updated via GitHub Actions.
3+
> **⛔ CRITICAL: UPSTREAM ISOLATION ⛔**
4+
>
5+
> **This repository is COMPLETELY INDEPENDENT. Do NOT:**
6+
> - Push to, pull from, or sync with the upstream repo (ericbuess/claude-code-docs)
7+
> - Create PRs to the upstream repo
8+
> - Add upstream as a remote
9+
> - Reference upstream in any git operations
10+
>
11+
> **All git operations must target `origin` (costiash/claude-code-docs) ONLY.**
12+
13+
This repository contains local copies of Claude documentation from multiple Anthropic sources:
14+
- **Platform docs**: https://platform.claude.com (API, guides, Agent SDK, etc.)
15+
- **Claude Code docs**: https://code.claude.com/docs (CLI-specific documentation)
16+
17+
The docs are periodically updated via GitHub Actions with safeguards to prevent mass deletion.
618

719
## Architecture: Single Installation with Optional Python Features
820

921
This repository uses a **graceful degradation** approach:
1022

1123
**Installation** (always the same):
12-
- 273 documentation paths tracked in manifest
13-
- ~266-270 files downloaded (varies based on fetch success)
24+
- 573 documentation paths tracked in manifest (6 categories)
25+
- 571 files downloaded
1426
- Python scripts for enhanced features
15-
- Full test suite and GitHub workflows
27+
- Full test suite (294 tests) and GitHub workflows
1628

1729
**Runtime Features** (Python-dependent):
1830
- **Without Python 3.9+**: Basic documentation reading via shell scripts
@@ -383,36 +395,53 @@ When Python 3.9+ is installed, these additional capabilities are available:
383395
- **Full-text search**: `--search "keyword"` searches across all documentation content
384396
- **Category filtering**: `--category api` lists paths in specific categories
385397
- **Path validation**: `--validate` checks documentation integrity
386-
- **Active documentation**: Access to 273 active paths across 7 categories:
387-
- Core Documentation (80 paths, 29.3%)
388-
- API Reference (79 paths, 28.9%)
389-
- Prompt Library (65 paths, 23.8%)
390-
- Claude Code (45 paths, 16.5%)
398+
- **Active documentation**: Access to 573 paths across 6 categories:
399+
- API Reference (377 paths, 65.8%) - Includes multi-language SDK docs (Python, TypeScript, Go, Java, Kotlin, Ruby)
400+
- Core Documentation (82 paths, 14.3%)
401+
- Prompt Library (65 paths, 11.3%)
402+
- Claude Code (46 paths, 8.0%)
391403
- Release Notes (2 paths)
392404
- Resources (1 path)
393-
- Uncategorized (1 path)
394405

395406
See `enhancements/` directory for comprehensive feature documentation and examples.
396407

397408
## Repository Structure
398409

399410
```
400411
/
401-
├── docs/ # ~266-270 documentation files (.md format)
412+
├── docs/ # 571 documentation files (.md format)
402413
│ ├── docs_manifest.json # File tracking manifest
403414
│ └── .search_index.json # Full-text search index (Python-generated)
404415
├── scripts/
405416
│ ├── claude-docs-helper.sh # Main helper (feature detection)
406-
│ ├── fetch_claude_docs.py # Documentation fetcher with auto-regeneration
407-
│ ├── lookup_paths.py # Search & validation (Python)
408-
│ └── build_search_index.py # Index builder (Python)
409-
├── paths_manifest.json # Active paths manifest (273 paths tracked)
417+
│ ├── fetch_claude_docs.py # Thin wrapper for fetcher package
418+
│ ├── lookup_paths.py # Thin wrapper for lookup package
419+
│ ├── build_search_index.py # Index builder (Python)
420+
│ ├── fetcher/ # Documentation fetching package
421+
│ │ ├── __init__.py # Package exports
422+
│ │ ├── config.py # Constants and safety thresholds
423+
│ │ ├── manifest.py # Manifest file operations
424+
│ │ ├── paths.py # Path conversion and categorization
425+
│ │ ├── sitemap.py # Sitemap discovery and parsing
426+
│ │ ├── content.py # Content fetching and validation
427+
│ │ ├── safeguards.py # Safety checks (deletion prevention)
428+
│ │ └── cli.py # Main entry point
429+
│ └── lookup/ # Search and validation package
430+
│ ├── __init__.py # Package exports
431+
│ ├── config.py # Configuration constants
432+
│ ├── manifest.py # Manifest loading utilities
433+
│ ├── search.py # Search functionality
434+
│ ├── validation.py # Path validation
435+
│ ├── formatting.py # Output formatting
436+
│ └── cli.py # Main entry point
437+
├── paths_manifest.json # Active paths manifest (573 paths, 6 categories)
438+
├── archive/ # Archived/deprecated scripts (git-ignored)
410439
├── enhancements/ # Feature documentation
411440
│ ├── README.md # Overview
412441
│ ├── FEATURES.md # Technical specs
413442
│ ├── CAPABILITIES.md # Detailed capabilities
414443
│ └── EXAMPLES.md # Usage examples
415-
├── tests/ # Test suite (620 tests, 618 passing)
444+
├── tests/ # Test suite (294 tests, 294 passing)
416445
├── install.sh # Installation script
417446
└── CLAUDE.md # This file (AI context)
418447
@@ -430,15 +459,48 @@ When working on this repository:
430459
@uninstall.sh - Clean removal
431460

432461
### Python Features
433-
@scripts/fetch_claude_docs.py - Documentation fetcher with auto-regeneration
434-
@scripts/lookup_paths.py - Search & validation
462+
@scripts/fetch_claude_docs.py - Thin wrapper for fetcher package (backwards compatible)
463+
@scripts/lookup_paths.py - Thin wrapper for lookup package (backwards compatible)
464+
@scripts/fetcher/ - Documentation fetching package (8 modules)
465+
@scripts/lookup/ - Search & validation package (7 modules)
435466
@scripts/build_search_index.py - Full-text search indexing
436-
@paths_manifest.json - Active paths manifest (273 paths tracked)
437-
@tests/ - Test suite (620 tests)
467+
@paths_manifest.json - Active paths manifest (573 paths, 6 categories)
468+
@tests/ - Test suite (294 tests)
438469

439470
### Automation
440471
@.github/workflows/ - Auto-update workflows (runs every 3 hours)
441472

473+
## Documentation Deletion Safeguards
474+
475+
The automated sync system includes multiple safeguards to prevent catastrophic documentation loss. These were implemented after a critical bug where 80%+ of documentation was deleted due to broken sitemap URLs.
476+
477+
### Safety Thresholds (in `scripts/fetcher/config.py`)
478+
479+
| Constant | Value | Purpose |
480+
|----------|-------|---------|
481+
| `MIN_DISCOVERY_THRESHOLD` | 200 | Minimum paths that must be discovered from sitemaps |
482+
| `MAX_DELETION_PERCENT` | 10 | Maximum percentage of files that can be deleted in one sync |
483+
| `MIN_EXPECTED_FILES` | 250 | Minimum files that must remain after sync |
484+
485+
### How Safeguards Work
486+
487+
1. **Discovery Validation**: Before fetching, validates that sitemap discovery found enough paths
488+
2. **Deletion Limiting**: `cleanup_old_files()` refuses to delete more than 10% of existing files
489+
3. **File Count Validation**: Refuses to proceed if result would have fewer than 250 files
490+
4. **Workflow Validation**: GitHub Actions validates sync success before committing
491+
492+
### Sitemap Sources
493+
494+
Documentation is discovered from two sitemaps:
495+
- `https://platform.claude.com/sitemap.xml` - Platform documentation (API, guides, etc.)
496+
- `https://code.claude.com/docs/sitemap.xml` - Claude Code CLI documentation
497+
498+
### Filename Conventions
499+
500+
Files are named based on their source:
501+
- Platform docs: `en__docs__section__page.md` (double underscore for path separators)
502+
- Claude Code docs: `docs__en__page.md` (prefixed with `docs__`)
503+
442504
## Working on This Repository
443505

444506
**Critical Rule**: Changes must maintain graceful degradation - work with AND without Python.
@@ -463,7 +525,7 @@ python3 scripts/lookup_paths.py --search "mcp"
463525
pytest tests/ -v
464526

465527
# Run full test suite
466-
pytest tests/ -q # Should see: 598 passed, 2 skipped
528+
pytest tests/ -q # Should see: 294 passed, 2 skipped
467529
```
468530

469531
## Upstream Compatibility

CONTRIBUTING.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ Thank you for contributing to the Enhanced Claude Code Documentation Mirror!
77
This project extends [ericbuess/claude-code-docs](https://github.com/ericbuess/claude-code-docs) with optional Python features:
88

99
**Core Principle: Graceful Degradation**
10-
- Single installation (273 paths tracked + Python scripts)
10+
- Single installation (573 paths tracked across 6 categories + Python scripts)
1111
- Python features activate only when Python 3.9+ is available
1212
- Everything works without Python (basic `/docs` command)
1313
- No separate "modes" - just feature detection at runtime
1414

1515
**Design Goals:**
16-
1. **Honesty**: Accurate claims about what we deliver (273 paths tracked, ~266-270 files downloaded)
16+
1. **Honesty**: Accurate claims about what we deliver (573 paths tracked, 571 files downloaded)
1717
2. **Simplicity**: One installation, automatic feature detection
1818
3. **Compatibility**: Works with upstream, same `/docs` interface
19-
4. **Testing**: High test coverage (78%), all changes tested
19+
4. **Testing**: All changes tested (294 tests)
2020

2121
## Repository URL Strategy
2222

@@ -125,8 +125,7 @@ pip install -e ".[dev]"
125125
~/.claude-code-docs/claude-docs-helper.sh --validate
126126
127127
# Run tests (REQUIRED before submitting PR)
128-
pytest tests/ -v # Should see: 627 passed, 2 skipped
129-
pytest --cov=scripts --cov-report=term # Should see: ~78.7%
128+
pytest tests/ -v # Should see: 294 passed, 2 skipped
130129
131130
# Test specific changes
132131
python scripts/lookup_paths.py "your test query"
@@ -331,10 +330,9 @@ def test_search_paths_with_limit():
331330
```
332331

333332
**Current test status:**
334-
- Total: 629 tests
335-
- Passing: 627 (99.7%)
333+
- Total: 296 tests
334+
- Passing: 294 (99.3%)
336335
- Skipped: 2 (intentional)
337-
- Coverage: 78.70%
338336

339337
## Pull Request Guidelines
340338

@@ -417,17 +415,14 @@ git push origin v0.x.x
417415

418416
**When to release:**
419417
- New Python features complete
420-
- All tests passing (629/629 or 627/629)
418+
- All tests passing (294/296 or 296/296)
421419
- Documentation updated
422420

423421
**Process:**
424422
```bash
425423
# Ensure tests pass
426424
pytest
427425

428-
# Check coverage
429-
pytest --cov=scripts --cov-report=term # Should be ~78.7%
430-
431426
# Update versions
432427
# Edit install.sh, README.md
433428

0 commit comments

Comments
 (0)