up-cli 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

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.
@@ -1,6 +1,7 @@
1
1
  """Config file templates for Claude and Cursor."""
2
2
 
3
3
  from pathlib import Path
4
+ from datetime import date
4
5
 
5
6
 
6
7
  def create_config_files(target_dir: Path, ai_target: str, force: bool = False) -> None:
@@ -8,29 +9,56 @@ def create_config_files(target_dir: Path, ai_target: str, force: bool = False) -
8
9
  if ai_target in ("claude", "both"):
9
10
  _create_claude_md(target_dir, force)
10
11
  if ai_target in ("cursor", "both"):
12
+ _create_cursor_rules_dir(target_dir, force)
11
13
  _create_cursorrules(target_dir, force)
12
14
 
13
15
 
14
16
  def _write_file(path: Path, content: str, force: bool) -> None:
15
17
  if path.exists() and not force:
16
18
  return
19
+ path.parent.mkdir(parents=True, exist_ok=True)
17
20
  path.write_text(content)
18
21
 
19
22
 
20
23
  def _create_claude_md(target_dir: Path, force: bool) -> None:
21
24
  """Create CLAUDE.md for Claude Code."""
22
- content = """# Project Guide
25
+ today = date.today().isoformat()
26
+ project_name = target_dir.name
27
+
28
+ content = f"""# {project_name}
23
29
 
24
- ## On Session Start
30
+ > AI Instructions for Claude Code
31
+
32
+ **Version**: 1.0.0
33
+ **Updated**: {today}
34
+ **Min Claude Version**: 2024.01
35
+
36
+ ---
37
+
38
+ ## Quick Start
25
39
 
26
40
  1. Read `docs/CONTEXT.md` for current state
27
41
  2. Check `docs/handoff/LATEST.md` for recent work
28
42
  3. Use `docs/INDEX.md` to find relevant docs
29
- 4. Apply rules below
43
+
44
+ ## Project Structure
45
+
46
+ ```
47
+ {project_name}/
48
+ ├── CLAUDE.md # This file - AI reads first
49
+ ├── docs/ # Documentation
50
+ │ ├── CONTEXT.md # Current project state
51
+ │ ├── INDEX.md # Doc quick reference
52
+ │ └── handoff/ # Session continuity
53
+ ├── src/ # Source code
54
+ ├── tests/ # Tests
55
+ └── .claude/skills/ # Claude skills
56
+ ```
30
57
 
31
58
  ## AI Vibing Coding Rules
32
59
 
33
60
  ### Golden Rules
61
+
34
62
  1. **Vision before code** - Understand architecture first
35
63
  2. **One thing at a time** - Numbered, atomic requests
36
64
  3. **Verify immediately** - Test after each change
@@ -38,49 +66,503 @@ def _create_claude_md(target_dir: Path, force: bool) -> None:
38
66
  5. **Frustration = signal** - Change approach when stuck
39
67
 
40
68
  ### Request Format
69
+
41
70
  ```
42
71
  1. [ACTION] [TARGET] [CONTEXT]
43
72
  2. [ACTION] [TARGET] [CONTEXT]
44
73
  ```
45
74
 
46
75
  ### 2-Failure Rule
76
+
47
77
  If something fails twice:
48
78
  1. Provide more context
49
79
  2. Reference specific files
50
80
  3. Break into smaller steps
81
+ 4. Consider using a skill
51
82
 
52
83
  ## Skills
53
84
 
54
- | Skill | When to Use |
55
- |-------|-------------|
56
- | `/docs` | Create/manage documentation |
57
- | `/learn` | Research and create PRD |
58
- | `/product-loop` | Development with SESRC |
85
+ | Skill | Command | When to Use |
86
+ |-------|---------|-------------|
87
+ | Docs | `/docs` | Create/manage documentation |
88
+ | Learn | `/learn` | Research and create PRD |
89
+ | Product Loop | `/product-loop` | Development with SESRC |
90
+
91
+ ### Skill Usage Examples
92
+
93
+ ```
94
+ # Research before implementing
95
+ /learn auto
96
+
97
+ # Start development loop
98
+ /product-loop
99
+
100
+ # Create documentation
101
+ /docs new feature
102
+ ```
59
103
 
60
104
  ## Auto-Triggers
61
105
 
62
- - New feature `/learn auto`
63
- - Start coding → `/product-loop`
64
- - Need docs `/docs new [type]`
65
- - Session end Update `docs/handoff/LATEST.md`
106
+ | Trigger | Action |
107
+ |---------|--------|
108
+ | New feature request | `/learn auto` |
109
+ | Start coding | `/product-loop` |
110
+ | Need documentation | `/docs new [type]` |
111
+ | Session end | Update `docs/handoff/LATEST.md` |
112
+
113
+ ## Context Budget
114
+
115
+ This project tracks context window usage:
116
+ - **Budget**: 100,000 tokens
117
+ - **Warning**: At 80% usage
118
+ - **Action**: Summarize and checkpoint at 90%
119
+
120
+ See `.claude/context_budget.json` for current usage.
121
+
122
+ ## Code Style
123
+
124
+ ### General
125
+
126
+ - Use descriptive names
127
+ - Keep functions small
128
+ - Document public APIs
129
+ - Write tests for new features
130
+
131
+ ### Python (if applicable)
132
+
133
+ - Use type hints
134
+ - Follow PEP 8
135
+ - Use dataclasses for data structures
136
+
137
+ ### TypeScript (if applicable)
138
+
139
+ - Strict mode enabled
140
+ - Prefer interfaces over types
141
+ - Use async/await
142
+
143
+ ## Testing
144
+
145
+ Before committing:
146
+ 1. Run tests: `pytest` or `npm test`
147
+ 2. Check types: `mypy` or `tsc --noEmit`
148
+ 3. Lint: `ruff` or `eslint`
149
+
150
+ ## Handoff Protocol
151
+
152
+ At session end, update `docs/handoff/LATEST.md`:
153
+ 1. What was accomplished
154
+ 2. Current blockers
155
+ 3. Suggested next steps
156
+ 4. Files modified
157
+
158
+ ---
159
+
160
+ *Generated by up-cli*
66
161
  """
67
162
  _write_file(target_dir / "CLAUDE.md", content, force)
68
163
 
69
164
 
165
+ def _create_cursor_rules_dir(target_dir: Path, force: bool) -> None:
166
+ """Create .cursor/rules/ directory with rule files."""
167
+ rules_dir = target_dir / ".cursor/rules"
168
+ rules_dir.mkdir(parents=True, exist_ok=True)
169
+
170
+ # Create main rules file
171
+ _create_main_cursor_rule(rules_dir, force)
172
+
173
+ # Create file-specific rules
174
+ _create_python_rule(rules_dir, force)
175
+ _create_typescript_rule(rules_dir, force)
176
+ _create_docs_rule(rules_dir, force)
177
+ _create_test_rule(rules_dir, force)
178
+
179
+
180
+ def _create_main_cursor_rule(rules_dir: Path, force: bool) -> None:
181
+ """Create main Cursor rule file."""
182
+ content = """---
183
+ description: Main project rules for AI assistance
184
+ globs: ["**/*"]
185
+ ---
186
+
187
+ # Project Rules
188
+
189
+ ## Skills Available
190
+
191
+ - `/docs` - Documentation management
192
+ - `/learn` - Research and PRD generation
193
+ - `/product-loop` - SESRC development workflow
194
+
195
+ ## Workflow
196
+
197
+ 1. **Research**: `/learn auto` - Analyze project and generate insights
198
+ 2. **Build**: `/product-loop` - Development with circuit breaker
199
+ 3. **Document**: `/docs new` - Create documentation
200
+
201
+ ## Code Quality
202
+
203
+ - Always run tests after changes
204
+ - Use type hints (Python) or TypeScript strict mode
205
+ - Keep functions under 50 lines
206
+ - Document public APIs
207
+
208
+ ## Context Management
209
+
210
+ - Read `docs/CONTEXT.md` for current state
211
+ - Update `docs/handoff/LATEST.md` at session end
212
+ - Reference specific files with @file syntax
213
+
214
+ ## Error Handling
215
+
216
+ If something fails twice:
217
+ 1. Add more context
218
+ 2. Break into smaller steps
219
+ 3. Consider a different approach
220
+ """
221
+ _write_file(rules_dir / "main.md", content, force)
222
+
223
+
224
+ def _create_python_rule(rules_dir: Path, force: bool) -> None:
225
+ """Create Python-specific Cursor rule."""
226
+ content = """---
227
+ description: Python code standards
228
+ globs: ["**/*.py"]
229
+ ---
230
+
231
+ # Python Rules
232
+
233
+ ## Style
234
+
235
+ - Use type hints for all function signatures
236
+ - Follow PEP 8 naming conventions
237
+ - Use dataclasses for data structures
238
+ - Prefer pathlib over os.path
239
+
240
+ ## Imports
241
+
242
+ ```python
243
+ # Standard library
244
+ import os
245
+ from pathlib import Path
246
+
247
+ # Third-party
248
+ import click
249
+ from rich.console import Console
250
+
251
+ # Local
252
+ from mypackage.module import function
253
+ ```
254
+
255
+ ## Documentation
256
+
257
+ ```python
258
+ def function_name(param: str, count: int = 0) -> bool:
259
+ \"\"\"Brief description.
260
+
261
+ Args:
262
+ param: Description of param
263
+ count: Description with default
264
+
265
+ Returns:
266
+ Description of return value
267
+
268
+ Raises:
269
+ ValueError: When param is invalid
270
+ \"\"\"
271
+ ```
272
+
273
+ ## Testing
274
+
275
+ - Use pytest
276
+ - Name test files `test_*.py`
277
+ - Use fixtures for setup
278
+ - Aim for >80% coverage
279
+
280
+ ## Common Patterns
281
+
282
+ ### Error Handling
283
+ ```python
284
+ try:
285
+ result = operation()
286
+ except SpecificError as e:
287
+ logger.error(f"Operation failed: {e}")
288
+ raise
289
+ ```
290
+
291
+ ### Configuration
292
+ ```python
293
+ @dataclass
294
+ class Config:
295
+ debug: bool = False
296
+ timeout: int = 30
297
+ ```
298
+ """
299
+ _write_file(rules_dir / "python.md", content, force)
300
+
301
+
302
+ def _create_typescript_rule(rules_dir: Path, force: bool) -> None:
303
+ """Create TypeScript-specific Cursor rule."""
304
+ content = """---
305
+ description: TypeScript code standards
306
+ globs: ["**/*.ts", "**/*.tsx"]
307
+ ---
308
+
309
+ # TypeScript Rules
310
+
311
+ ## Style
312
+
313
+ - Enable strict mode
314
+ - Use interfaces over types for objects
315
+ - Prefer async/await over promises
316
+ - Use const assertions where appropriate
317
+
318
+ ## Imports
319
+
320
+ ```typescript
321
+ // External packages
322
+ import React from 'react';
323
+ import { useState } from 'react';
324
+
325
+ // Internal modules
326
+ import { Component } from '@/components';
327
+ import { utils } from '@/lib';
328
+
329
+ // Types
330
+ import type { User } from '@/types';
331
+ ```
332
+
333
+ ## Types
334
+
335
+ ```typescript
336
+ // Prefer interfaces for objects
337
+ interface User {
338
+ id: string;
339
+ name: string;
340
+ email: string;
341
+ }
342
+
343
+ // Use type for unions/intersections
344
+ type Status = 'pending' | 'active' | 'completed';
345
+
346
+ // Generic constraints
347
+ function process<T extends { id: string }>(item: T): string {
348
+ return item.id;
349
+ }
350
+ ```
351
+
352
+ ## React Components (if applicable)
353
+
354
+ ```tsx
355
+ interface Props {
356
+ title: string;
357
+ onAction: () => void;
358
+ }
359
+
360
+ export function Component({ title, onAction }: Props) {
361
+ const [state, setState] = useState(false);
362
+
363
+ return (
364
+ <div>
365
+ <h1>{title}</h1>
366
+ <button onClick={onAction}>Action</button>
367
+ </div>
368
+ );
369
+ }
370
+ ```
371
+
372
+ ## Testing
373
+
374
+ - Use Jest or Vitest
375
+ - Name test files `*.test.ts` or `*.spec.ts`
376
+ - Mock external dependencies
377
+ """
378
+ _write_file(rules_dir / "typescript.md", content, force)
379
+
380
+
381
+ def _create_docs_rule(rules_dir: Path, force: bool) -> None:
382
+ """Create documentation-specific Cursor rule."""
383
+ content = """---
384
+ description: Documentation standards
385
+ globs: ["docs/**/*.md", "*.md"]
386
+ ---
387
+
388
+ # Documentation Rules
389
+
390
+ ## Structure
391
+
392
+ All docs should have:
393
+ 1. Title (H1)
394
+ 2. Metadata (Updated date, Status)
395
+ 3. Horizontal rule separator
396
+ 4. Content sections
397
+
398
+ ## Header Template
399
+
400
+ ```markdown
401
+ # Document Title
402
+
403
+ **Updated**: YYYY-MM-DD
404
+ **Status**: 🔄 Active | ✅ Completed | 📋 Draft
405
+
406
+ ---
407
+ ```
408
+
409
+ ## Status Icons
410
+
411
+ | Icon | Meaning |
412
+ |------|---------|
413
+ | 📋 | Draft/Planned |
414
+ | 🔄 | Active/In Progress |
415
+ | ✅ | Completed |
416
+ | ⏸️ | Paused |
417
+ | ❌ | Cancelled |
418
+
419
+ ## Tables
420
+
421
+ Use tables for structured information:
422
+
423
+ ```markdown
424
+ | Column 1 | Column 2 |
425
+ |----------|----------|
426
+ | Value 1 | Value 2 |
427
+ ```
428
+
429
+ ## Code Blocks
430
+
431
+ Always specify language:
432
+
433
+ ```python
434
+ def example():
435
+ pass
436
+ ```
437
+
438
+ ## Links
439
+
440
+ - Use relative paths for internal docs
441
+ - Use descriptive link text
442
+ - Example: [Architecture Overview](./architecture/README.md)
443
+
444
+ ## Key Files
445
+
446
+ | File | Purpose |
447
+ |------|---------|
448
+ | docs/CONTEXT.md | AI reads first |
449
+ | docs/INDEX.md | Quick reference |
450
+ | docs/handoff/LATEST.md | Session continuity |
451
+ """
452
+ _write_file(rules_dir / "docs.md", content, force)
453
+
454
+
455
+ def _create_test_rule(rules_dir: Path, force: bool) -> None:
456
+ """Create test-specific Cursor rule."""
457
+ content = """---
458
+ description: Testing standards
459
+ globs: ["tests/**/*", "**/*.test.*", "**/*.spec.*"]
460
+ ---
461
+
462
+ # Testing Rules
463
+
464
+ ## Structure
465
+
466
+ ```
467
+ tests/
468
+ ├── unit/ # Unit tests
469
+ ├── integration/ # Integration tests
470
+ ├── fixtures/ # Test fixtures
471
+ └── conftest.py # Shared fixtures (pytest)
472
+ ```
473
+
474
+ ## Naming
475
+
476
+ - Test files: `test_*.py` or `*.test.ts`
477
+ - Test functions: `test_[what]_[condition]_[expected]`
478
+ - Example: `test_login_with_invalid_password_returns_401`
479
+
480
+ ## AAA Pattern
481
+
482
+ ```python
483
+ def test_example():
484
+ # Arrange
485
+ user = create_user()
486
+
487
+ # Act
488
+ result = user.login("password")
489
+
490
+ # Assert
491
+ assert result.success is True
492
+ ```
493
+
494
+ ## Fixtures
495
+
496
+ ```python
497
+ @pytest.fixture
498
+ def user():
499
+ return User(name="test", email="test@example.com")
500
+
501
+ def test_with_fixture(user):
502
+ assert user.name == "test"
503
+ ```
504
+
505
+ ## Mocking
506
+
507
+ ```python
508
+ from unittest.mock import Mock, patch
509
+
510
+ @patch('module.external_service')
511
+ def test_with_mock(mock_service):
512
+ mock_service.return_value = {'status': 'ok'}
513
+ result = function_under_test()
514
+ assert result == 'ok'
515
+ ```
516
+
517
+ ## Coverage
518
+
519
+ - Aim for >80% coverage
520
+ - Focus on critical paths
521
+ - Don't test trivial code
522
+ """
523
+ _write_file(rules_dir / "tests.md", content, force)
524
+
525
+
70
526
  def _create_cursorrules(target_dir: Path, force: bool) -> None:
71
- """Create .cursorrules for Cursor AI."""
527
+ """Create root .cursorrules for Cursor AI."""
72
528
  content = """# Cursor Rules
73
529
 
74
- ## Skills Available
530
+ ## Project Overview
531
+
532
+ This project uses the up-cli scaffolding system with three integrated skills:
533
+ - `/docs` - Documentation management
534
+ - `/learn` - Research and PRD generation
535
+ - `/product-loop` - SESRC development workflow
536
+
537
+ ## Quick Reference
538
+
539
+ | Action | Command |
540
+ |--------|---------|
541
+ | Analyze project | `/learn auto` |
542
+ | Start dev loop | `/product-loop` |
543
+ | Create docs | `/docs new [type]` |
544
+ | Check status | `/product-loop status` |
545
+
546
+ ## Rules Location
547
+
548
+ See `.cursor/rules/` for detailed rules:
549
+ - `main.md` - General project rules
550
+ - `python.md` - Python standards
551
+ - `typescript.md` - TypeScript standards
552
+ - `docs.md` - Documentation standards
553
+ - `tests.md` - Testing standards
554
+
555
+ ## Context Files
75
556
 
76
- - /docs - Documentation management
77
- - /learn - Research and PRD
78
- - /product-loop - SESRC development
557
+ 1. `docs/CONTEXT.md` - Current project state
558
+ 2. `docs/INDEX.md` - Documentation index
559
+ 3. `docs/handoff/LATEST.md` - Last session handoff
79
560
 
80
561
  ## Workflow
81
562
 
82
- 1. Research: /learn auto
83
- 2. Build: /product-loop
84
- 3. Document: /docs new
563
+ 1. Read context files first
564
+ 2. Use appropriate skill commands
565
+ 3. Test changes before committing
566
+ 4. Update handoff at session end
85
567
  """
86
568
  _write_file(target_dir / ".cursorrules", content, force)