playwrightauthor 1.0.2__tar.gz

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.
Files changed (37) hide show
  1. playwrightauthor-1.0.2/.cursorrules +292 -0
  2. playwrightauthor-1.0.2/.github/workflows/ci.yml +30 -0
  3. playwrightauthor-1.0.2/.gitignore +91 -0
  4. playwrightauthor-1.0.2/AGENTS.md +292 -0
  5. playwrightauthor-1.0.2/CHANGELOG.md +17 -0
  6. playwrightauthor-1.0.2/CLAUDE.md +292 -0
  7. playwrightauthor-1.0.2/GEMINI.md +292 -0
  8. playwrightauthor-1.0.2/LICENSE +21 -0
  9. playwrightauthor-1.0.2/PKG-INFO +498 -0
  10. playwrightauthor-1.0.2/PLAN.md +58 -0
  11. playwrightauthor-1.0.2/README.md +477 -0
  12. playwrightauthor-1.0.2/TODO.md +19 -0
  13. playwrightauthor-1.0.2/llms.txt +2442 -0
  14. playwrightauthor-1.0.2/old/google_docs_scraper_simple.py +138 -0
  15. playwrightauthor-1.0.2/old/playwrightauthor.md +34 -0
  16. playwrightauthor-1.0.2/publish.sh +6 -0
  17. playwrightauthor-1.0.2/pyproject.toml +76 -0
  18. playwrightauthor-1.0.2/src/playwrightauthor/__init__.py +11 -0
  19. playwrightauthor-1.0.2/src/playwrightauthor/__main__.py +12 -0
  20. playwrightauthor-1.0.2/src/playwrightauthor/author.py +85 -0
  21. playwrightauthor-1.0.2/src/playwrightauthor/browser/__init__.py +1 -0
  22. playwrightauthor-1.0.2/src/playwrightauthor/browser/finder.py +45 -0
  23. playwrightauthor-1.0.2/src/playwrightauthor/browser/installer.py +64 -0
  24. playwrightauthor-1.0.2/src/playwrightauthor/browser/launcher.py +23 -0
  25. playwrightauthor-1.0.2/src/playwrightauthor/browser/process.py +19 -0
  26. playwrightauthor-1.0.2/src/playwrightauthor/browser_manager.py +88 -0
  27. playwrightauthor-1.0.2/src/playwrightauthor/cli.py +52 -0
  28. playwrightauthor-1.0.2/src/playwrightauthor/exceptions.py +11 -0
  29. playwrightauthor-1.0.2/src/playwrightauthor/onboarding.py +25 -0
  30. playwrightauthor-1.0.2/src/playwrightauthor/templates/onboarding.html +34 -0
  31. playwrightauthor-1.0.2/src/playwrightauthor/typing.py +3 -0
  32. playwrightauthor-1.0.2/src/playwrightauthor/utils/logger.py +16 -0
  33. playwrightauthor-1.0.2/src/playwrightauthor/utils/paths.py +14 -0
  34. playwrightauthor-1.0.2/tests/test_author.py +37 -0
  35. playwrightauthor-1.0.2/tests/test_benchmark.py +8 -0
  36. playwrightauthor-1.0.2/tests/test_integration.py +16 -0
  37. playwrightauthor-1.0.2/tests/test_utils.py +17 -0
@@ -0,0 +1,292 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## 1. Project Overview
6
+
7
+ PlaywrightAuthor is a convenience package for Microsoft Playwright that handles browser automation setup. It automatically manages Chrome for Testing installation, authentication with user profiles, and provides ready-to-use Browser objects through simple context managers.
8
+
9
+ ## 2. Key Architecture
10
+
11
+ **Core Design Pattern**: The library follows a context manager pattern with `Browser()` and `AsyncBrowser()` classes that return authenticated Playwright browser objects.
12
+
13
+ **Main Components** (planned structure):
14
+ - `playwrightauthor/author.py` - Core Browser/AsyncBrowser classes (main API)
15
+ - `playwrightauthor/browser_manager.py` - Chrome installation/process management
16
+ - `playwrightauthor/onboarding.py` - User guidance for authentication
17
+ - `playwrightauthor/cli.py` - Fire-powered CLI interface
18
+ - `playwrightauthor/utils/` - Logger and cross-platform path utilities
19
+
20
+ **Current State**: The project is in early development. The main implementation exists as a legacy scraper in `old/google_docs_scraper_simple.py` that demonstrates the core concept of connecting to an existing Chrome debug session.
21
+
22
+ ## 3. Development Commands
23
+
24
+ ### 3.1. Environment Setup
25
+ ```bash
26
+ # Initial setup with uv
27
+ curl -LsSf https://astral.sh/uv/install.sh | sh
28
+ uv venv --python 3.12
29
+ uv init
30
+ uv add playwright rich fire loguru platformdirs requests psutil
31
+ ```
32
+
33
+ ### 3.2. Code Quality Pipeline
34
+ After any Python changes, run:
35
+ ```bash
36
+ fd -e py -x uvx autoflake -i {}; \
37
+ fd -e py -x uvx pyupgrade --py312-plus {}; \
38
+ fd -e py -x uvx ruff check --output-format=github --fix --unsafe-fixes {}; \
39
+ fd -e py -x uvx ruff format --respect-gitignore --target-version py312 {}; \
40
+ python -m pytest
41
+ ```
42
+
43
+ ### 3.3. Testing
44
+ - Run tests: `python -m pytest`
45
+ - Tests are located in `tests/` directory
46
+ - Current tests may be integration tests requiring live Chrome instance
47
+
48
+ ### 3.4. CLI Usage
49
+ Once implemented:
50
+ ```bash
51
+ python -m playwrightauthor status # Check browser status
52
+ ```
53
+
54
+ ## 4. Code Standards
55
+
56
+ - **File headers**: Every Python file should include a `this_file:` comment with the relative path
57
+ - **Dependencies**: Use uv script headers with `# /// script` blocks
58
+ - **Type hints**: Use modern Python type hints (list, dict, | for unions)
59
+ - **Logging**: Use loguru with verbose flag support
60
+ - **CLI**: Use Fire for command-line interfaces with Rich for output
61
+
62
+ ## 5. Browser Management Strategy
63
+
64
+ The core technical challenge is reliably managing Chrome for Testing:
65
+
66
+ 1. **Detection**: Check if Chrome is running with `--remote-debugging-port=9222`
67
+ 2. **Installation**: Prefer `npx puppeteer browsers install`, fallback to LKGV JSON downloads
68
+ 3. **Process Management**: Kill non-debug instances, launch with persistent user-data-dir
69
+ 4. **Connection**: Use Playwright's `connect_over_cdp()` to attach to debug session
70
+
71
+ ## 6. Project Workflow
72
+
73
+ The project follows a documentation-driven development approach:
74
+ 1. Read `WORK.md` and `PLAN.md` before making changes
75
+ 2. Update documentation files after implementation
76
+ 3. Use "Wait, but" reflection methodology for code review
77
+ 4. Maintain minimal, self-contained commits
78
+
79
+ ## 7. Dependencies
80
+
81
+ Core runtime dependencies:
82
+ - `playwright` - Browser automation
83
+ - `rich` - Terminal output formatting
84
+ - `fire` - CLI generation
85
+ - `loguru` - Logging
86
+ - `platformdirs` - Cross-platform paths
87
+ - `requests` - HTTP client for downloads
88
+ - `psutil` - Process management
89
+
90
+ # Software Development Rules
91
+
92
+ ## 8. Pre-Work Preparation
93
+
94
+ ### 8.1. Before Starting Any Work
95
+ - **ALWAYS** read `WORK.md` in the main project folder for work progress
96
+ - Read `README.md` to understand the project
97
+ - STEP BACK and THINK HEAVILY STEP BY STEP about the task
98
+ - Consider alternatives and carefully choose the best option
99
+ - Check for existing solutions in the codebase before starting
100
+
101
+ ### 8.2. Project Documentation to Maintain
102
+ - `README.md` - purpose and functionality
103
+ - `CHANGELOG.md` - past change release notes (accumulative)
104
+ - `PLAN.md` - detailed future goals, clear plan that discusses specifics
105
+ - `TODO.md` - flat simplified itemized `- [ ]`-prefixed representation of `PLAN.md`
106
+ - `WORK.md` - work progress updates
107
+
108
+ ## 9. General Coding Principles
109
+
110
+ ### 9.1. Core Development Approach
111
+ - Iterate gradually, avoiding major changes
112
+ - Focus on minimal viable increments and ship early
113
+ - Minimize confirmations and checks
114
+ - Preserve existing code/structure unless necessary
115
+ - Check often the coherence of the code you're writing with the rest of the code
116
+ - Analyze code line-by-line
117
+
118
+ ### 9.2. Code Quality Standards
119
+ - Use constants over magic numbers
120
+ - Write explanatory docstrings/comments that explain what and WHY
121
+ - Explain where and how the code is used/referred to elsewhere
122
+ - Handle failures gracefully with retries, fallbacks, user guidance
123
+ - Address edge cases, validate assumptions, catch errors early
124
+ - Let the computer do the work, minimize user decisions
125
+ - Reduce cognitive load, beautify code
126
+ - Modularize repeated logic into concise, single-purpose functions
127
+ - Favor flat over nested structures
128
+
129
+ ## 10. Tool Usage (When Available)
130
+
131
+ ### 10.1. Additional Tools
132
+ - If we need a new Python project, run `curl -LsSf https://astral.sh/uv/install.sh | sh; uv venv --python 3.12; uv init; uv add fire rich; uv sync`
133
+ - Use `tree` CLI app if available to verify file locations
134
+ - Check existing code with `.venv` folder to scan and consult dependency source code
135
+ - Run `DIR="."; uvx codetoprompt --compress --output "$DIR/llms.txt" --respect-gitignore --cxml --exclude "*.svg,.specstory,*.md,*.txt,ref,testdata,*.lock,*.svg" "$DIR"` to get a condensed snapshot of the codebase into `llms.txt`
136
+
137
+ ## 11. File Management
138
+
139
+ ### 11.1. File Path Tracking
140
+ - **MANDATORY**: In every source file, maintain a `this_file` record showing the path relative to project root
141
+ - Place `this_file` record near the top:
142
+ - As a comment after shebangs in code files
143
+ - In YAML frontmatter for Markdown files
144
+ - Update paths when moving files
145
+ - Omit leading `./`
146
+ - Check `this_file` to confirm you're editing the right file
147
+
148
+ ## 12. Python-Specific Guidelines
149
+
150
+ ### 12.1. PEP Standards
151
+ - PEP 8: Use consistent formatting and naming, clear descriptive names
152
+ - PEP 20: Keep code simple and explicit, prioritize readability over cleverness
153
+ - PEP 257: Write clear, imperative docstrings
154
+ - Use type hints in their simplest form (list, dict, | for unions)
155
+
156
+ ### 12.2. Modern Python Practices
157
+ - Use f-strings and structural pattern matching where appropriate
158
+ - Write modern code with `pathlib`
159
+ - ALWAYS add "verbose" mode loguru-based logging & debug-log
160
+ - Use `uv add`
161
+ - Use `uv pip install` instead of `pip install`
162
+ - Prefix Python CLI tools with `python -m` (e.g., `python -m pytest`)
163
+
164
+ ### 12.3. CLI Scripts Setup
165
+ For CLI Python scripts, use `fire` & `rich`, and start with:
166
+ ```python
167
+ #!/usr/bin/env -S uv run -s
168
+ # /// script
169
+ # dependencies = ["PKG1", "PKG2"]
170
+ # ///
171
+ # this_file: PATH_TO_CURRENT_FILE
172
+ ```
173
+
174
+ ### 12.4. Post-Edit Python Commands
175
+ ```bash
176
+ fd -e py -x uvx autoflake -i {}; fd -e py -x uvx pyupgrade --py312-plus {}; fd -e py -x uvx ruff check --output-format=github --fix --unsafe-fixes {}; fd -e py -x uvx ruff format --respect-gitignore --target-version py312 {}; python -m pytest;
177
+ ```
178
+
179
+ ## 13. Post-Work Activities
180
+
181
+ ### 13.1. Critical Reflection
182
+ - After completing a step, say "Wait, but" and do additional careful critical reasoning
183
+ - Go back, think & reflect, revise & improve what you've done
184
+ - Don't invent functionality freely
185
+ - Stick to the goal of "minimal viable next version"
186
+
187
+ ### 13.2. Documentation Updates
188
+ - Update `WORK.md` with what you've done and what needs to be done next
189
+ - Document all changes in `CHANGELOG.md`
190
+ - Update `TODO.md` and `PLAN.md` accordingly
191
+
192
+ ## 14. Work Methodology
193
+
194
+ ### 14.1. Virtual Team Approach
195
+ Be creative, diligent, critical, relentless & funny! Lead two experts:
196
+ - **"Ideot"** - for creative, unorthodox ideas
197
+ - **"Critin"** - to critique flawed thinking and moderate for balanced discussions
198
+
199
+ Collaborate step-by-step, sharing thoughts and adapting. If errors are found, step back and focus on accuracy and progress.
200
+
201
+ ### 14.2. Continuous Work Mode
202
+ - Treat all items in `PLAN.md` and `TODO.md` as one huge TASK
203
+ - Work on implementing the next item
204
+ - Review, reflect, refine, revise your implementation
205
+ - Periodically check off completed issues
206
+ - Continue to the next item without interruption
207
+
208
+ ## 15. Special Commands
209
+
210
+ ### 15.1. `/plan` Command - Transform Requirements into Detailed Plans
211
+
212
+ When I say "/plan [requirement]", you must:
213
+
214
+ 1. **DECONSTRUCT** the requirement:
215
+ - Extract core intent, key features, and objectives
216
+ - Identify technical requirements and constraints
217
+ - Map what's explicitly stated vs. what's implied
218
+ - Determine success criteria
219
+
220
+ 2. **DIAGNOSE** the project needs:
221
+ - Audit for missing specifications
222
+ - Check technical feasibility
223
+ - Assess complexity and dependencies
224
+ - Identify potential challenges
225
+
226
+ 3. **RESEARCH** additional material:
227
+ - Repeatedly call the `perplexity_ask` and request up-to-date information or additional remote context
228
+ - Repeatedly call the `context7` tool and request up-to-date software package documentation
229
+ - Repeatedly call the `codex` tool and request additional reasoning, summarization of files and second opinion
230
+
231
+ 4. **DEVELOP** the plan structure:
232
+ - Break down into logical phases/milestones
233
+ - Create hierarchical task decomposition
234
+ - Assign priorities and dependencies
235
+ - Add implementation details and technical specs
236
+ - Include edge cases and error handling
237
+ - Define testing and validation steps
238
+
239
+ 5. **DELIVER** to `PLAN.md`:
240
+ - Write a comprehensive, detailed plan with:
241
+ - Project overview and objectives
242
+ - Technical architecture decisions
243
+ - Phase-by-phase breakdown
244
+ - Specific implementation steps
245
+ - Testing and validation criteria
246
+ - Future considerations
247
+ - Simultaneously create/update `TODO.md` with the flat itemized `- [ ]` representation
248
+
249
+ **Plan Optimization Techniques:**
250
+ - **Task Decomposition:** Break complex requirements into atomic, actionable tasks
251
+ - **Dependency Mapping:** Identify and document task dependencies
252
+ - **Risk Assessment:** Include potential blockers and mitigation strategies
253
+ - **Progressive Enhancement:** Start with MVP, then layer improvements
254
+ - **Technical Specifications:** Include specific technologies, patterns, and approaches
255
+
256
+ ### 15.2. `/report` Command
257
+
258
+ 1. Read all `./TODO.md` and `./PLAN.md` files
259
+ 2. Analyze recent changes
260
+ 3. Document all changes in `./CHANGELOG.md`
261
+ 4. Remove completed items from `./TODO.md` and `./PLAN.md`
262
+ 5. Ensure `./PLAN.md` contains detailed, clear plans with specifics
263
+ 6. Ensure `./TODO.md` is a flat simplified itemized representation
264
+
265
+ ### 15.3. `/work` Command
266
+
267
+ 1. Read all `./TODO.md` and `./PLAN.md` files and reflect
268
+ 2. Write down the immediate items in this iteration into `./WORK.md`
269
+ 3. Work on these items
270
+ 4. Think, contemplate, research, reflect, refine, revise
271
+ 5. Be careful, curious, vigilant, energetic
272
+ 6. Verify your changes and think aloud
273
+ 7. Consult, research, reflect
274
+ 8. Periodically remove completed items from `./WORK.md`
275
+ 9. Tick off completed items from `./TODO.md` and `./PLAN.md`
276
+ 10. Update `./WORK.md` with improvement tasks
277
+ 11. Execute `/report`
278
+ 12. Continue to the next item
279
+
280
+ ## 16. Additional Guidelines
281
+
282
+ - Ask before extending/refactoring existing code that may add complexity or break things
283
+ - Work tirelessly without constant updates when in continuous work mode
284
+ - Only notify when you've completed all `PLAN.md` and `TODO.md` items
285
+
286
+ ## 17. Command Summary
287
+
288
+ - `/plan [requirement]` - Transform vague requirements into detailed `PLAN.md` and `TODO.md`
289
+ - `/report` - Update documentation and clean up completed tasks
290
+ - `/work` - Enter continuous work mode to implement plans
291
+ - You may use these commands autonomously when appropriate
292
+
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest, windows-latest]
15
+ python-version: ["3.12"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v3
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - name: Install dependencies
24
+ run: |
25
+ curl -LsSf https://astral.sh/uv/install.sh | sh
26
+ uv venv
27
+ uv sync
28
+ - name: Run tests
29
+ run: |
30
+ uv run python -m pytest
@@ -0,0 +1,91 @@
1
+
2
+ __marimo__/
3
+ __pycache__/
4
+ __pypackages__/
5
+ .abstra/
6
+ .cache
7
+ .coverage
8
+ .coverage.*
9
+ .cursorignore
10
+ .cursorindexingignore
11
+ .dmypy.json
12
+ .DS_Store
13
+ .eggs/
14
+ .env
15
+ .envrc
16
+ .hypothesis/
17
+ .installed.cfg
18
+ .ipynb_checkpoints
19
+ .mypy_cache/
20
+ .nox/
21
+ .pdm-build/
22
+ .pdm-python
23
+ .pixi
24
+ .pybuilder/
25
+ .pypirc
26
+ .pyre/
27
+ .pytest_cache/
28
+ .Python
29
+ .pytype/
30
+ .ropeproject
31
+ .ruff_cache/
32
+ .scrapy
33
+ .spyderproject
34
+ .spyproject
35
+ .tox/
36
+ .venv
37
+ .webassets-cache
38
+ *.cover
39
+ *.egg
40
+ *.egg-info/
41
+ *.log
42
+ *.manifest
43
+ *.mo
44
+ *.pot
45
+ *.py.cover
46
+ *.py[codz]
47
+ *.sage.py
48
+ *.so
49
+ *.spec
50
+ *$py.class
51
+ /site
52
+ uv.lock
53
+ build/
54
+ celerybeat-schedule
55
+ celerybeat.pid
56
+ cover/
57
+ coverage.xml
58
+ cython_debug/
59
+ db.sqlite3
60
+ db.sqlite3-journal
61
+ develop-eggs/
62
+ dist/
63
+ dmypy.json
64
+ docs/_build/
65
+ downloads/
66
+ eggs/
67
+ env.bak/
68
+ env/
69
+ ENV/
70
+ htmlcov/
71
+ instance/
72
+ ipython_config.py
73
+ lib/
74
+ lib64/
75
+ local_settings.py
76
+ MANIFEST
77
+ marimo/_lsp/
78
+ marimo/_static/
79
+ nosetests.xml
80
+ parts/
81
+ pip-delete-this-directory.txt
82
+ pip-log.txt
83
+ profile_default/
84
+ sdist/
85
+ share/python-wheels/
86
+ src/playwrightauthor/_version.py
87
+ target/
88
+ var/
89
+ venv.bak/
90
+ venv/
91
+ wheels/
@@ -0,0 +1,292 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## 1. Project Overview
6
+
7
+ PlaywrightAuthor is a convenience package for Microsoft Playwright that handles browser automation setup. It automatically manages Chrome for Testing installation, authentication with user profiles, and provides ready-to-use Browser objects through simple context managers.
8
+
9
+ ## 2. Key Architecture
10
+
11
+ **Core Design Pattern**: The library follows a context manager pattern with `Browser()` and `AsyncBrowser()` classes that return authenticated Playwright browser objects.
12
+
13
+ **Main Components** (planned structure):
14
+ - `playwrightauthor/author.py` - Core Browser/AsyncBrowser classes (main API)
15
+ - `playwrightauthor/browser_manager.py` - Chrome installation/process management
16
+ - `playwrightauthor/onboarding.py` - User guidance for authentication
17
+ - `playwrightauthor/cli.py` - Fire-powered CLI interface
18
+ - `playwrightauthor/utils/` - Logger and cross-platform path utilities
19
+
20
+ **Current State**: The project is in early development. The main implementation exists as a legacy scraper in `old/google_docs_scraper_simple.py` that demonstrates the core concept of connecting to an existing Chrome debug session.
21
+
22
+ ## 3. Development Commands
23
+
24
+ ### 3.1. Environment Setup
25
+ ```bash
26
+ # Initial setup with uv
27
+ curl -LsSf https://astral.sh/uv/install.sh | sh
28
+ uv venv --python 3.12
29
+ uv init
30
+ uv add playwright rich fire loguru platformdirs requests psutil
31
+ ```
32
+
33
+ ### 3.2. Code Quality Pipeline
34
+ After any Python changes, run:
35
+ ```bash
36
+ fd -e py -x uvx autoflake -i {}; \
37
+ fd -e py -x uvx pyupgrade --py312-plus {}; \
38
+ fd -e py -x uvx ruff check --output-format=github --fix --unsafe-fixes {}; \
39
+ fd -e py -x uvx ruff format --respect-gitignore --target-version py312 {}; \
40
+ python -m pytest
41
+ ```
42
+
43
+ ### 3.3. Testing
44
+ - Run tests: `python -m pytest`
45
+ - Tests are located in `tests/` directory
46
+ - Current tests may be integration tests requiring live Chrome instance
47
+
48
+ ### 3.4. CLI Usage
49
+ Once implemented:
50
+ ```bash
51
+ python -m playwrightauthor status # Check browser status
52
+ ```
53
+
54
+ ## 4. Code Standards
55
+
56
+ - **File headers**: Every Python file should include a `this_file:` comment with the relative path
57
+ - **Dependencies**: Use uv script headers with `# /// script` blocks
58
+ - **Type hints**: Use modern Python type hints (list, dict, | for unions)
59
+ - **Logging**: Use loguru with verbose flag support
60
+ - **CLI**: Use Fire for command-line interfaces with Rich for output
61
+
62
+ ## 5. Browser Management Strategy
63
+
64
+ The core technical challenge is reliably managing Chrome for Testing:
65
+
66
+ 1. **Detection**: Check if Chrome is running with `--remote-debugging-port=9222`
67
+ 2. **Installation**: Prefer `npx puppeteer browsers install`, fallback to LKGV JSON downloads
68
+ 3. **Process Management**: Kill non-debug instances, launch with persistent user-data-dir
69
+ 4. **Connection**: Use Playwright's `connect_over_cdp()` to attach to debug session
70
+
71
+ ## 6. Project Workflow
72
+
73
+ The project follows a documentation-driven development approach:
74
+ 1. Read `WORK.md` and `PLAN.md` before making changes
75
+ 2. Update documentation files after implementation
76
+ 3. Use "Wait, but" reflection methodology for code review
77
+ 4. Maintain minimal, self-contained commits
78
+
79
+ ## 7. Dependencies
80
+
81
+ Core runtime dependencies:
82
+ - `playwright` - Browser automation
83
+ - `rich` - Terminal output formatting
84
+ - `fire` - CLI generation
85
+ - `loguru` - Logging
86
+ - `platformdirs` - Cross-platform paths
87
+ - `requests` - HTTP client for downloads
88
+ - `psutil` - Process management
89
+
90
+ # Software Development Rules
91
+
92
+ ## 8. Pre-Work Preparation
93
+
94
+ ### 8.1. Before Starting Any Work
95
+ - **ALWAYS** read `WORK.md` in the main project folder for work progress
96
+ - Read `README.md` to understand the project
97
+ - STEP BACK and THINK HEAVILY STEP BY STEP about the task
98
+ - Consider alternatives and carefully choose the best option
99
+ - Check for existing solutions in the codebase before starting
100
+
101
+ ### 8.2. Project Documentation to Maintain
102
+ - `README.md` - purpose and functionality
103
+ - `CHANGELOG.md` - past change release notes (accumulative)
104
+ - `PLAN.md` - detailed future goals, clear plan that discusses specifics
105
+ - `TODO.md` - flat simplified itemized `- [ ]`-prefixed representation of `PLAN.md`
106
+ - `WORK.md` - work progress updates
107
+
108
+ ## 9. General Coding Principles
109
+
110
+ ### 9.1. Core Development Approach
111
+ - Iterate gradually, avoiding major changes
112
+ - Focus on minimal viable increments and ship early
113
+ - Minimize confirmations and checks
114
+ - Preserve existing code/structure unless necessary
115
+ - Check often the coherence of the code you're writing with the rest of the code
116
+ - Analyze code line-by-line
117
+
118
+ ### 9.2. Code Quality Standards
119
+ - Use constants over magic numbers
120
+ - Write explanatory docstrings/comments that explain what and WHY
121
+ - Explain where and how the code is used/referred to elsewhere
122
+ - Handle failures gracefully with retries, fallbacks, user guidance
123
+ - Address edge cases, validate assumptions, catch errors early
124
+ - Let the computer do the work, minimize user decisions
125
+ - Reduce cognitive load, beautify code
126
+ - Modularize repeated logic into concise, single-purpose functions
127
+ - Favor flat over nested structures
128
+
129
+ ## 10. Tool Usage (When Available)
130
+
131
+ ### 10.1. Additional Tools
132
+ - If we need a new Python project, run `curl -LsSf https://astral.sh/uv/install.sh | sh; uv venv --python 3.12; uv init; uv add fire rich; uv sync`
133
+ - Use `tree` CLI app if available to verify file locations
134
+ - Check existing code with `.venv` folder to scan and consult dependency source code
135
+ - Run `DIR="."; uvx codetoprompt --compress --output "$DIR/llms.txt" --respect-gitignore --cxml --exclude "*.svg,.specstory,*.md,*.txt,ref,testdata,*.lock,*.svg" "$DIR"` to get a condensed snapshot of the codebase into `llms.txt`
136
+
137
+ ## 11. File Management
138
+
139
+ ### 11.1. File Path Tracking
140
+ - **MANDATORY**: In every source file, maintain a `this_file` record showing the path relative to project root
141
+ - Place `this_file` record near the top:
142
+ - As a comment after shebangs in code files
143
+ - In YAML frontmatter for Markdown files
144
+ - Update paths when moving files
145
+ - Omit leading `./`
146
+ - Check `this_file` to confirm you're editing the right file
147
+
148
+ ## 12. Python-Specific Guidelines
149
+
150
+ ### 12.1. PEP Standards
151
+ - PEP 8: Use consistent formatting and naming, clear descriptive names
152
+ - PEP 20: Keep code simple and explicit, prioritize readability over cleverness
153
+ - PEP 257: Write clear, imperative docstrings
154
+ - Use type hints in their simplest form (list, dict, | for unions)
155
+
156
+ ### 12.2. Modern Python Practices
157
+ - Use f-strings and structural pattern matching where appropriate
158
+ - Write modern code with `pathlib`
159
+ - ALWAYS add "verbose" mode loguru-based logging & debug-log
160
+ - Use `uv add`
161
+ - Use `uv pip install` instead of `pip install`
162
+ - Prefix Python CLI tools with `python -m` (e.g., `python -m pytest`)
163
+
164
+ ### 12.3. CLI Scripts Setup
165
+ For CLI Python scripts, use `fire` & `rich`, and start with:
166
+ ```python
167
+ #!/usr/bin/env -S uv run -s
168
+ # /// script
169
+ # dependencies = ["PKG1", "PKG2"]
170
+ # ///
171
+ # this_file: PATH_TO_CURRENT_FILE
172
+ ```
173
+
174
+ ### 12.4. Post-Edit Python Commands
175
+ ```bash
176
+ fd -e py -x uvx autoflake -i {}; fd -e py -x uvx pyupgrade --py312-plus {}; fd -e py -x uvx ruff check --output-format=github --fix --unsafe-fixes {}; fd -e py -x uvx ruff format --respect-gitignore --target-version py312 {}; python -m pytest;
177
+ ```
178
+
179
+ ## 13. Post-Work Activities
180
+
181
+ ### 13.1. Critical Reflection
182
+ - After completing a step, say "Wait, but" and do additional careful critical reasoning
183
+ - Go back, think & reflect, revise & improve what you've done
184
+ - Don't invent functionality freely
185
+ - Stick to the goal of "minimal viable next version"
186
+
187
+ ### 13.2. Documentation Updates
188
+ - Update `WORK.md` with what you've done and what needs to be done next
189
+ - Document all changes in `CHANGELOG.md`
190
+ - Update `TODO.md` and `PLAN.md` accordingly
191
+
192
+ ## 14. Work Methodology
193
+
194
+ ### 14.1. Virtual Team Approach
195
+ Be creative, diligent, critical, relentless & funny! Lead two experts:
196
+ - **"Ideot"** - for creative, unorthodox ideas
197
+ - **"Critin"** - to critique flawed thinking and moderate for balanced discussions
198
+
199
+ Collaborate step-by-step, sharing thoughts and adapting. If errors are found, step back and focus on accuracy and progress.
200
+
201
+ ### 14.2. Continuous Work Mode
202
+ - Treat all items in `PLAN.md` and `TODO.md` as one huge TASK
203
+ - Work on implementing the next item
204
+ - Review, reflect, refine, revise your implementation
205
+ - Periodically check off completed issues
206
+ - Continue to the next item without interruption
207
+
208
+ ## 15. Special Commands
209
+
210
+ ### 15.1. `/plan` Command - Transform Requirements into Detailed Plans
211
+
212
+ When I say "/plan [requirement]", you must:
213
+
214
+ 1. **DECONSTRUCT** the requirement:
215
+ - Extract core intent, key features, and objectives
216
+ - Identify technical requirements and constraints
217
+ - Map what's explicitly stated vs. what's implied
218
+ - Determine success criteria
219
+
220
+ 2. **DIAGNOSE** the project needs:
221
+ - Audit for missing specifications
222
+ - Check technical feasibility
223
+ - Assess complexity and dependencies
224
+ - Identify potential challenges
225
+
226
+ 3. **RESEARCH** additional material:
227
+ - Repeatedly call the `perplexity_ask` and request up-to-date information or additional remote context
228
+ - Repeatedly call the `context7` tool and request up-to-date software package documentation
229
+ - Repeatedly call the `codex` tool and request additional reasoning, summarization of files and second opinion
230
+
231
+ 4. **DEVELOP** the plan structure:
232
+ - Break down into logical phases/milestones
233
+ - Create hierarchical task decomposition
234
+ - Assign priorities and dependencies
235
+ - Add implementation details and technical specs
236
+ - Include edge cases and error handling
237
+ - Define testing and validation steps
238
+
239
+ 5. **DELIVER** to `PLAN.md`:
240
+ - Write a comprehensive, detailed plan with:
241
+ - Project overview and objectives
242
+ - Technical architecture decisions
243
+ - Phase-by-phase breakdown
244
+ - Specific implementation steps
245
+ - Testing and validation criteria
246
+ - Future considerations
247
+ - Simultaneously create/update `TODO.md` with the flat itemized `- [ ]` representation
248
+
249
+ **Plan Optimization Techniques:**
250
+ - **Task Decomposition:** Break complex requirements into atomic, actionable tasks
251
+ - **Dependency Mapping:** Identify and document task dependencies
252
+ - **Risk Assessment:** Include potential blockers and mitigation strategies
253
+ - **Progressive Enhancement:** Start with MVP, then layer improvements
254
+ - **Technical Specifications:** Include specific technologies, patterns, and approaches
255
+
256
+ ### 15.2. `/report` Command
257
+
258
+ 1. Read all `./TODO.md` and `./PLAN.md` files
259
+ 2. Analyze recent changes
260
+ 3. Document all changes in `./CHANGELOG.md`
261
+ 4. Remove completed items from `./TODO.md` and `./PLAN.md`
262
+ 5. Ensure `./PLAN.md` contains detailed, clear plans with specifics
263
+ 6. Ensure `./TODO.md` is a flat simplified itemized representation
264
+
265
+ ### 15.3. `/work` Command
266
+
267
+ 1. Read all `./TODO.md` and `./PLAN.md` files and reflect
268
+ 2. Write down the immediate items in this iteration into `./WORK.md`
269
+ 3. Work on these items
270
+ 4. Think, contemplate, research, reflect, refine, revise
271
+ 5. Be careful, curious, vigilant, energetic
272
+ 6. Verify your changes and think aloud
273
+ 7. Consult, research, reflect
274
+ 8. Periodically remove completed items from `./WORK.md`
275
+ 9. Tick off completed items from `./TODO.md` and `./PLAN.md`
276
+ 10. Update `./WORK.md` with improvement tasks
277
+ 11. Execute `/report`
278
+ 12. Continue to the next item
279
+
280
+ ## 16. Additional Guidelines
281
+
282
+ - Ask before extending/refactoring existing code that may add complexity or break things
283
+ - Work tirelessly without constant updates when in continuous work mode
284
+ - Only notify when you've completed all `PLAN.md` and `TODO.md` items
285
+
286
+ ## 17. Command Summary
287
+
288
+ - `/plan [requirement]` - Transform vague requirements into detailed `PLAN.md` and `TODO.md`
289
+ - `/report` - Update documentation and clean up completed tasks
290
+ - `/work` - Enter continuous work mode to implement plans
291
+ - You may use these commands autonomously when appropriate
292
+