Repository navigation
Prevent .ai-context files from being committed - #8
tirthbodawala merged 4 commits into
Conversation
…cessing bug
## Problem
The Copier template was severely out of sync with source code:
- 15 test files missing (6 ai_tools, 5 quality, 4 project-level)
- 11 AI tools scripts missing (entire scripts/ai_tools/ directory)
- Quality scripts outdated (old class-based vs new function-based API)
- Template had only 10 tests vs 25 in source project
- Generated projects were missing critical functionality
## Solution
### 1. Created Automated Sync Script (sync_template.py)
New Python script that automates synchronization of source files to Copier template:
- Syncs 39 files total from source to template
- Automatic Jinja variable replacement:
- python_modern_template → {{ package_name }}
- python-modern-template → {{ project_name }}
- Handles special cases for files with literal {{...}} patterns
- Single command to keep template in sync: python sync_template.py
Files synced:
- 15 AI tools tests (test_finish_task, test_template_loader, test_update_plan_*, etc.)
- 5 quality tests (test_check, test_format, test_lint, test_security, test_test)
- 4 project-level tests (test_dependencies, test_docs, test_makefile, test_validate_ai_docs_sync)
- 11 AI tools scripts (all scripts/ai_tools/*.py including template_loader.py)
- 6 quality scripts (config, check, format, lint, security, test)
- 5 task template files (bugfix.md, docs.md, feature.md, refactor.md + __init__.py)
- 1 validation script (validate_ai_docs_sync.py)
- 1 scripts/__init__.py
### 2. Fixed Critical Bug: Corrupted Plan Files
**Problem**: Running `ai-start-task` in generated projects created plan files with
timestamp printed on every single character, making them completely unusable.
**Root Cause**: Copier was processing template_loader.py.jinja as a Jinja template
and removing all {{session_id}}, {{task_name}}, {{task_type}}, {{timestamp}}
placeholders, leaving empty .replace("", ...) calls.
Example of corrupted output:
```
2025-11-04 20:04:30f2025-11-04 20:04:30e2025-11-04 20:04:30a2025-11-04 20:04:30t...
```
**Solution**: Exclude files containing literal {{...}} patterns from Jinja processing.
Files template_loader.py and test_template_loader.py are now copied without .jinja
extension, preserving their literal {{variable}} strings intact.
### 3. Updated Documentation
Added comprehensive "Template Synchronization Script" section to
AI_DOCS/documentation-sync-rules.md documenting:
- What files get synced
- When to run sync
- How Jinja variable replacement works
- Expected test results in generated projects
## Verification
**Source Project:**
- ✅ All 200 tests pass
- ✅ Coverage: 86%
- ✅ Pylint: 10.00/10
- ✅ All quality gates pass
**Generated Projects:**
- ✅ 94 files generated (up from 72)
- ✅ All 25 test files present
- ✅ ai-start-task works correctly
- ✅ Plan files generated with proper variable substitution
- ✅ Formatting and linting pass
## Impact
- Generated projects now have full test coverage and working AI tools
- Single-command sync keeps template up to date
- No more manual file copying or missing features
- ai-start-task command now functional in all generated projects
- Template quality matches source project quality
## Changes
1. **Added clear naming convention documentation**
- Explains the difference between directory name, project name, package name, and project slug
- Shows default values when using --defaults flag:
- Project Name: 'My Python Project'
- Package Name: my_python_project (the actual Python package)
- Project Slug: 'my-python-project'
- Includes example for custom configuration
2. **Fixed broken documentation link**
- Removed reference to non-existent GETTING_STARTED.md
- Replaced with links to Quick Start and Example Configurations
## Why This Matters
Users were confused about what 'my_python_project' refers to when creating
projects with defaults. This clarifies that it's the Python package name
(what you import), which is different from the directory name you choose
and the human-readable project name.
Changes: - Updated .gitignore to exclude all .ai-context/* except *.example files - Created template files in template/.ai-context/ for new projects: - ACTIVE_TASKS.md - CONVENTIONS.md - LAST_SESSION_SUMMARY.md - RECENT_DECISIONS.md - Created .example files in .ai-context/ for repo developers - Removed tracked .ai-context files (developer-specific, not for version control) Rationale: - .ai-context/ contains session-specific and developer-specific data - Should not be committed to version control - Template files guide new projects - Example files guide repo developers
…ude-ai-context-files-011CUpGp2Wj3diwaB7qZyz1K
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Active Tasks | ||
|
|
||
| ## Current Tasks | ||
|
|
||
| None - Starting fresh | ||
|
|
||
| ## Completed | ||
|
|
||
| - ✅ Project initialized from python-modern-template | ||
|
|
||
| ## Pending User Actions | ||
|
|
||
| 1. Review and customize project configuration | ||
| 2. Set up development environment | ||
| 3. Begin implementation with TDD |
There was a problem hiding this comment.
Template .gitignore still allows committing AI context files
These new template files will be copied verbatim into generated projects, but the template’s .gitignore still only ignores .ai-context/sessions/. As a result, developers who follow the guidance to run ai-start-task/ai-finish-task will constantly dirty these tracked files and may accidentally commit their personal session context—the very scenario this commit is trying to prevent. Consider updating template/.gitignore to match the root policy (.ai-context/* except .example/.gitkeep) so generated repositories inherit the same protections.
Useful? React with 👍 / 👎.
Changes:
Rationale: