claudekit-cli 1.0.0
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/.claude/agents/brainstormer.md +96 -0
- package/.claude/agents/code-reviewer.md +141 -0
- package/.claude/agents/copywriter.md +108 -0
- package/.claude/agents/database-admin.md +86 -0
- package/.claude/agents/debugger.md +124 -0
- package/.claude/agents/docs-manager.md +115 -0
- package/.claude/agents/git-manager.md +60 -0
- package/.claude/agents/journal-writer.md +111 -0
- package/.claude/agents/planner.md +87 -0
- package/.claude/agents/project-manager.md +113 -0
- package/.claude/agents/researcher.md +173 -0
- package/.claude/agents/scout.md +123 -0
- package/.claude/agents/tester.md +95 -0
- package/.claude/agents/ui-ux-designer.md +206 -0
- package/.claude/commands/bootstrap.md +104 -0
- package/.claude/commands/brainstorm.md +67 -0
- package/.claude/commands/content/enhance.md +13 -0
- package/.claude/commands/content/fast.md +11 -0
- package/.claude/commands/content/good.md +13 -0
- package/.claude/commands/cook.md +19 -0
- package/.claude/commands/debug.md +10 -0
- package/.claude/commands/design/3d.md +65 -0
- package/.claude/commands/design/describe.md +13 -0
- package/.claude/commands/design/fast.md +19 -0
- package/.claude/commands/design/good.md +23 -0
- package/.claude/commands/design/screenshot.md +23 -0
- package/.claude/commands/design/video.md +23 -0
- package/.claude/commands/docs/init.md +13 -0
- package/.claude/commands/docs/summarize.md +10 -0
- package/.claude/commands/docs/update.md +21 -0
- package/.claude/commands/fix/ci.md +11 -0
- package/.claude/commands/fix/fast.md +12 -0
- package/.claude/commands/fix/hard.md +18 -0
- package/.claude/commands/fix/logs.md +16 -0
- package/.claude/commands/fix/test.md +18 -0
- package/.claude/commands/fix/types.md +10 -0
- package/.claude/commands/git/cm.md +5 -0
- package/.claude/commands/git/cp.md +4 -0
- package/.claude/commands/integrate/polar.md +42 -0
- package/.claude/commands/plan/ci.md +12 -0
- package/.claude/commands/plan/two.md +13 -0
- package/.claude/commands/plan.md +10 -0
- package/.claude/commands/scout.md +29 -0
- package/.claude/commands/test.md +7 -0
- package/.claude/commands/watzup.md +8 -0
- package/.claude/hooks/telegram_notify.sh +136 -0
- package/.claude/send-discord.sh +64 -0
- package/.claude/settings.json +7 -0
- package/.claude/statusline.sh +143 -0
- package/.claude/workflows/development-rules.md +80 -0
- package/.claude/workflows/documentation-management.md +28 -0
- package/.claude/workflows/orchestration-protocol.md +16 -0
- package/.claude/workflows/primary-workflow.md +41 -0
- package/.github/workflows/ci.yml +43 -0
- package/.github/workflows/release.yml +58 -0
- package/.opencode/agent/code-reviewer.md +141 -0
- package/.opencode/agent/debugger.md +74 -0
- package/.opencode/agent/docs-manager.md +119 -0
- package/.opencode/agent/git-manager.md +60 -0
- package/.opencode/agent/planner-researcher.md +100 -0
- package/.opencode/agent/planner.md +87 -0
- package/.opencode/agent/project-manager.md +113 -0
- package/.opencode/agent/researcher.md +173 -0
- package/.opencode/agent/solution-brainstormer.md +89 -0
- package/.opencode/agent/system-architecture.md +192 -0
- package/.opencode/agent/tester.md +96 -0
- package/.opencode/agent/ui-ux-designer.md +203 -0
- package/.opencode/agent/ui-ux-developer.md +97 -0
- package/.opencode/command/cook.md +7 -0
- package/.opencode/command/debug.md +10 -0
- package/.opencode/command/design/3d.md +65 -0
- package/.opencode/command/design/fast.md +18 -0
- package/.opencode/command/design/good.md +21 -0
- package/.opencode/command/design/screenshot.md +22 -0
- package/.opencode/command/design/video.md +22 -0
- package/.opencode/command/docs/init.md +11 -0
- package/.opencode/command/docs/summarize.md +10 -0
- package/.opencode/command/docs/update.md +18 -0
- package/.opencode/command/fix/ci.md +8 -0
- package/.opencode/command/fix/fast.md +11 -0
- package/.opencode/command/fix/hard.md +15 -0
- package/.opencode/command/fix/logs.md +16 -0
- package/.opencode/command/fix/test.md +18 -0
- package/.opencode/command/fix/types.md +10 -0
- package/.opencode/command/git/cm.md +5 -0
- package/.opencode/command/git/cp.md +4 -0
- package/.opencode/command/plan/ci.md +12 -0
- package/.opencode/command/plan/two.md +13 -0
- package/.opencode/command/plan.md +10 -0
- package/.opencode/command/test.md +7 -0
- package/.opencode/command/watzup.md +8 -0
- package/.releaserc.json +17 -0
- package/.repomixignore +15 -0
- package/AGENTS.md +217 -0
- package/CHANGELOG.md +16 -0
- package/CLAUDE.md +33 -0
- package/README.md +214 -0
- package/biome.json +25 -0
- package/bun.lock +1238 -0
- package/dist/index.js +19100 -0
- package/docs/code-standards.md +1128 -0
- package/docs/codebase-summary.md +821 -0
- package/docs/github-setup.md +176 -0
- package/docs/project-pdr.md +739 -0
- package/docs/system-architecture.md +950 -0
- package/docs/tech-stack.md +290 -0
- package/package.json +60 -0
- package/plans/251008-claudekit-cli-implementation-plan.md +1469 -0
- package/plans/reports/251008-from-code-reviewer-to-developer-review-report.md +864 -0
- package/plans/reports/251008-from-tester-to-developer-test-summary-report.md +409 -0
- package/plans/reports/251008-researcher-download-extraction-report.md +1377 -0
- package/plans/reports/251008-researcher-github-api-report.md +1339 -0
- package/plans/research/251008-cli-frameworks-bun-research.md +1051 -0
- package/plans/templates/bug-fix-template.md +69 -0
- package/plans/templates/feature-implementation-template.md +84 -0
- package/plans/templates/refactor-template.md +82 -0
- package/plans/templates/template-usage-guide.md +58 -0
- package/src/commands/new.ts +118 -0
- package/src/commands/update.ts +114 -0
- package/src/index.ts +44 -0
- package/src/lib/auth.ts +157 -0
- package/src/lib/download.ts +180 -0
- package/src/lib/github.ts +157 -0
- package/src/lib/merge.ts +116 -0
- package/src/lib/prompts.ts +113 -0
- package/src/types.ts +149 -0
- package/src/utils/config.ts +87 -0
- package/src/utils/logger.ts +37 -0
- package/tests/lib/auth.test.ts +116 -0
- package/tests/lib/download.test.ts +70 -0
- package/tests/lib/github.test.ts +52 -0
- package/tests/lib/merge.test.ts +138 -0
- package/tests/lib/prompts.test.ts +66 -0
- package/tests/types.test.ts +255 -0
- package/tests/utils/config.test.ts +263 -0
- package/tests/utils/logger.test.ts +124 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# [Bug Fix] Implementation Plan
|
|
2
|
+
|
|
3
|
+
**Date**: YYYY-MM-DD
|
|
4
|
+
**Type**: Bug Fix
|
|
5
|
+
**Priority**: [Critical/High/Medium/Low]
|
|
6
|
+
**Context Tokens**: <150 words
|
|
7
|
+
|
|
8
|
+
## Executive Summary
|
|
9
|
+
Brief description of the bug and its impact.
|
|
10
|
+
|
|
11
|
+
## Issue Analysis
|
|
12
|
+
### Symptoms
|
|
13
|
+
- [ ] Symptom 1
|
|
14
|
+
- [ ] Symptom 2
|
|
15
|
+
|
|
16
|
+
### Root Cause
|
|
17
|
+
Brief explanation of the underlying cause.
|
|
18
|
+
|
|
19
|
+
### Evidence
|
|
20
|
+
- **Logs**: Reference to log files (don't include full logs)
|
|
21
|
+
- **Error Messages**: Key error patterns
|
|
22
|
+
- **Affected Components**: List of impacted files/modules
|
|
23
|
+
|
|
24
|
+
## Context Links
|
|
25
|
+
- **Related Issues**: [GitHub issue numbers]
|
|
26
|
+
- **Recent Changes**: [Relevant commits or PRs]
|
|
27
|
+
- **Dependencies**: [Related systems]
|
|
28
|
+
|
|
29
|
+
## Solution Design
|
|
30
|
+
### Approach
|
|
31
|
+
High-level fix strategy in 2-3 sentences.
|
|
32
|
+
|
|
33
|
+
### Changes Required
|
|
34
|
+
1. **File 1** (`path/to/file.ts`): Brief change description
|
|
35
|
+
2. **File 2** (`path/to/file.ts`): Brief change description
|
|
36
|
+
|
|
37
|
+
### Testing Changes
|
|
38
|
+
- [ ] Update existing tests
|
|
39
|
+
- [ ] Add new test cases
|
|
40
|
+
- [ ] Validate fix doesn't break existing functionality
|
|
41
|
+
|
|
42
|
+
## Implementation Steps
|
|
43
|
+
1. [ ] Step 1 - file: `path/to/file.ts`
|
|
44
|
+
2. [ ] Step 2 - file: `path/to/file.ts`
|
|
45
|
+
3. [ ] Run test suite
|
|
46
|
+
4. [ ] Validate fix in relevant environments
|
|
47
|
+
|
|
48
|
+
## Verification Plan
|
|
49
|
+
### Test Cases
|
|
50
|
+
- [ ] Test case 1: Expected behavior
|
|
51
|
+
- [ ] Test case 2: Edge case handling
|
|
52
|
+
- [ ] Regression test: Ensure no new issues
|
|
53
|
+
|
|
54
|
+
### Rollback Plan
|
|
55
|
+
If the fix causes issues:
|
|
56
|
+
1. Revert commit: `git revert <commit-hash>`
|
|
57
|
+
2. Restore previous behavior in files X, Y, Z
|
|
58
|
+
|
|
59
|
+
## Risk Assessment
|
|
60
|
+
| Risk | Impact | Mitigation |
|
|
61
|
+
|------|--------|------------|
|
|
62
|
+
| Risk 1 | Medium | Mitigation plan |
|
|
63
|
+
|
|
64
|
+
## TODO Checklist
|
|
65
|
+
- [ ] Implement fix
|
|
66
|
+
- [ ] Update tests
|
|
67
|
+
- [ ] Run full test suite
|
|
68
|
+
- [ ] Code review
|
|
69
|
+
- [ ] Deploy and verify
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# [Feature Name] Implementation Plan
|
|
2
|
+
|
|
3
|
+
**Date**: YYYY-MM-DD
|
|
4
|
+
**Type**: Feature Implementation
|
|
5
|
+
**Status**: Planning
|
|
6
|
+
**Context Tokens**: <200 words
|
|
7
|
+
|
|
8
|
+
## Executive Summary
|
|
9
|
+
Brief 2-3 sentence description of the feature and its business value.
|
|
10
|
+
|
|
11
|
+
## Context Links
|
|
12
|
+
- **Related Plans**: [List other plan files - no full content]
|
|
13
|
+
- **Dependencies**: [External systems, APIs, existing features]
|
|
14
|
+
- **Reference Docs**: [Link to docs in ./docs directory]
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
### Functional Requirements
|
|
18
|
+
- [ ] Requirement 1
|
|
19
|
+
- [ ] Requirement 2
|
|
20
|
+
|
|
21
|
+
### Non-Functional Requirements
|
|
22
|
+
- [ ] Performance target
|
|
23
|
+
- [ ] Security requirement
|
|
24
|
+
- [ ] Scalability requirement
|
|
25
|
+
|
|
26
|
+
## Architecture Overview
|
|
27
|
+
```mermaid
|
|
28
|
+
[Simple component diagram]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Key Components
|
|
32
|
+
- **Component 1**: Brief description
|
|
33
|
+
- **Component 2**: Brief description
|
|
34
|
+
|
|
35
|
+
### Data Models
|
|
36
|
+
- **Model 1**: Key fields
|
|
37
|
+
- **Model 2**: Key fields
|
|
38
|
+
|
|
39
|
+
## Implementation Phases
|
|
40
|
+
|
|
41
|
+
### Phase 1: [Name] (Est: X days)
|
|
42
|
+
**Scope**: Specific boundaries
|
|
43
|
+
**Tasks**:
|
|
44
|
+
1. [ ] Task 1 - file: `path/to/file.ts`
|
|
45
|
+
2. [ ] Task 2 - file: `path/to/file.ts`
|
|
46
|
+
|
|
47
|
+
**Acceptance Criteria**:
|
|
48
|
+
- [ ] Criteria 1
|
|
49
|
+
- [ ] Criteria 2
|
|
50
|
+
|
|
51
|
+
### Phase 2: [Name] (Est: X days)
|
|
52
|
+
[Repeat structure]
|
|
53
|
+
|
|
54
|
+
## Testing Strategy
|
|
55
|
+
- **Unit Tests**: Specific test coverage targets
|
|
56
|
+
- **Integration Tests**: Key interaction points
|
|
57
|
+
- **E2E Tests**: Critical user flows
|
|
58
|
+
|
|
59
|
+
## Security Considerations
|
|
60
|
+
- [ ] Security item 1
|
|
61
|
+
- [ ] Security item 2
|
|
62
|
+
|
|
63
|
+
## Risk Assessment
|
|
64
|
+
| Risk | Impact | Mitigation |
|
|
65
|
+
|------|--------|------------|
|
|
66
|
+
| Risk 1 | High | Mitigation strategy |
|
|
67
|
+
|
|
68
|
+
## Quick Reference
|
|
69
|
+
### Key Commands
|
|
70
|
+
```bash
|
|
71
|
+
npm run command
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Configuration Files
|
|
75
|
+
- `config/file.ts`: Purpose
|
|
76
|
+
- `.env.example`: Environment variables
|
|
77
|
+
|
|
78
|
+
## TODO Checklist
|
|
79
|
+
- [ ] Phase 1 Task 1
|
|
80
|
+
- [ ] Phase 1 Task 2
|
|
81
|
+
- [ ] Phase 2 Task 1
|
|
82
|
+
- [ ] Testing complete
|
|
83
|
+
- [ ] Documentation updated
|
|
84
|
+
- [ ] Code review passed
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# [Component/Module] Refactoring Plan
|
|
2
|
+
|
|
3
|
+
**Date**: YYYY-MM-DD
|
|
4
|
+
**Type**: Refactoring
|
|
5
|
+
**Scope**: [Module/Component/System level]
|
|
6
|
+
**Context Tokens**: <200 words
|
|
7
|
+
|
|
8
|
+
## Executive Summary
|
|
9
|
+
Brief description of what is being refactored and why.
|
|
10
|
+
|
|
11
|
+
## Current State Analysis
|
|
12
|
+
### Issues with Current Implementation
|
|
13
|
+
- [ ] Issue 1: Performance bottleneck
|
|
14
|
+
- [ ] Issue 2: Code maintainability
|
|
15
|
+
- [ ] Issue 3: Technical debt
|
|
16
|
+
|
|
17
|
+
### Metrics (Before)
|
|
18
|
+
- **Performance**: Current benchmarks
|
|
19
|
+
- **Code Quality**: Complexity metrics
|
|
20
|
+
- **Test Coverage**: Current percentage
|
|
21
|
+
|
|
22
|
+
## Context Links
|
|
23
|
+
- **Affected Modules**: [List without full content]
|
|
24
|
+
- **Dependencies**: [Other systems impacted]
|
|
25
|
+
- **Related Documentation**: [Links to docs]
|
|
26
|
+
|
|
27
|
+
## Refactoring Strategy
|
|
28
|
+
### Approach
|
|
29
|
+
High-level strategy for the refactoring in 2-3 sentences.
|
|
30
|
+
|
|
31
|
+
### Architecture Changes
|
|
32
|
+
```mermaid
|
|
33
|
+
[Before/After comparison diagram]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Key Improvements
|
|
37
|
+
- **Improvement 1**: Brief description
|
|
38
|
+
- **Improvement 2**: Brief description
|
|
39
|
+
|
|
40
|
+
## Implementation Plan
|
|
41
|
+
|
|
42
|
+
### Phase 1: Preparation (Est: X days)
|
|
43
|
+
**Scope**: Setup and preparation work
|
|
44
|
+
1. [ ] Create comprehensive tests for current functionality
|
|
45
|
+
2. [ ] Document current behavior
|
|
46
|
+
3. [ ] Identify all dependencies
|
|
47
|
+
|
|
48
|
+
### Phase 2: Core Refactoring (Est: X days)
|
|
49
|
+
**Scope**: Main refactoring work
|
|
50
|
+
1. [ ] Refactor component A - file: `path/to/file.ts`
|
|
51
|
+
2. [ ] Refactor component B - file: `path/to/file.ts`
|
|
52
|
+
3. [ ] Update integration points
|
|
53
|
+
|
|
54
|
+
### Phase 3: Integration & Testing (Est: X days)
|
|
55
|
+
**Scope**: Validation and cleanup
|
|
56
|
+
1. [ ] Integration testing
|
|
57
|
+
2. [ ] Performance validation
|
|
58
|
+
3. [ ] Documentation updates
|
|
59
|
+
|
|
60
|
+
## Backward Compatibility
|
|
61
|
+
- **Breaking Changes**: [List any breaking changes]
|
|
62
|
+
- **Migration Path**: [Steps for users/systems]
|
|
63
|
+
- **Deprecation Timeline**: [If applicable]
|
|
64
|
+
|
|
65
|
+
## Success Metrics (After)
|
|
66
|
+
- **Performance**: Target improvements
|
|
67
|
+
- **Code Quality**: Target metrics
|
|
68
|
+
- **Test Coverage**: Target percentage
|
|
69
|
+
|
|
70
|
+
## Risk Assessment
|
|
71
|
+
| Risk | Impact | Mitigation |
|
|
72
|
+
|------|--------|------------|
|
|
73
|
+
| Breaking changes | High | Comprehensive testing |
|
|
74
|
+
| Performance regression | Medium | Benchmarking |
|
|
75
|
+
|
|
76
|
+
## TODO Checklist
|
|
77
|
+
- [ ] Phase 1: Preparation complete
|
|
78
|
+
- [ ] Phase 2: Core refactoring complete
|
|
79
|
+
- [ ] Phase 3: Integration complete
|
|
80
|
+
- [ ] Performance benchmarks validated
|
|
81
|
+
- [ ] Documentation updated
|
|
82
|
+
- [ ] Code review passed
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Plan Template Usage Guide
|
|
2
|
+
|
|
3
|
+
## Template Selection
|
|
4
|
+
|
|
5
|
+
### Feature Implementation Template
|
|
6
|
+
**Use when**: Adding new functionality, endpoints, services, or modules
|
|
7
|
+
**File**: `feature-implementation-template.md`
|
|
8
|
+
**Size**: Medium to large scope changes
|
|
9
|
+
|
|
10
|
+
### Bug Fix Template
|
|
11
|
+
**Use when**: Fixing specific issues, errors, or broken functionality
|
|
12
|
+
**File**: `bug-fix-template.md`
|
|
13
|
+
**Size**: Small to medium scope changes
|
|
14
|
+
|
|
15
|
+
### Refactoring Template
|
|
16
|
+
**Use when**: Improving code structure, performance, or maintainability without changing functionality
|
|
17
|
+
**File**: `refactor-template.md`
|
|
18
|
+
**Size**: Medium to large scope changes
|
|
19
|
+
|
|
20
|
+
## Context Management Best Practices
|
|
21
|
+
|
|
22
|
+
### Keep Plans Focused
|
|
23
|
+
- **Executive Summary**: Max 3 sentences
|
|
24
|
+
- **Context Links**: Reference files, don't include full content
|
|
25
|
+
- **Tasks**: Max 10 per phase
|
|
26
|
+
- **Context Tokens**: Target <200 words for summaries
|
|
27
|
+
|
|
28
|
+
### Template Adaptation
|
|
29
|
+
1. Copy the appropriate template to `plans/YYMMDD-feature-name-plan.md`
|
|
30
|
+
2. Replace bracketed placeholders with actual content
|
|
31
|
+
3. Remove sections not relevant to your specific use case
|
|
32
|
+
4. Keep the core structure intact for consistency
|
|
33
|
+
|
|
34
|
+
### Cross-References Instead of Duplication
|
|
35
|
+
- Link to existing documentation in `./docs/`
|
|
36
|
+
- Reference other plans without copying content
|
|
37
|
+
- Use file paths instead of code blocks where possible
|
|
38
|
+
- Focus on "what" and "why", not detailed "how"
|
|
39
|
+
|
|
40
|
+
## Quality Checklist
|
|
41
|
+
|
|
42
|
+
Before finalizing any plan:
|
|
43
|
+
- [ ] Executive summary is clear and concise
|
|
44
|
+
- [ ] Tasks are specific and actionable
|
|
45
|
+
- [ ] File paths are included for implementation tasks
|
|
46
|
+
- [ ] Success criteria are measurable
|
|
47
|
+
- [ ] Context links are used instead of full content
|
|
48
|
+
- [ ] TODO checklist is complete and realistic
|
|
49
|
+
|
|
50
|
+
## Context Refresh Triggers
|
|
51
|
+
|
|
52
|
+
Use these templates when:
|
|
53
|
+
- Starting a new development phase
|
|
54
|
+
- Switching between different types of work (feature → bugfix)
|
|
55
|
+
- After major context accumulation (>8000 tokens)
|
|
56
|
+
- When agent handoffs occur
|
|
57
|
+
|
|
58
|
+
This ensures each plan starts with fresh, focused context optimized for the specific task type.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { pathExists, readdir } from "fs-extra";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { DownloadManager } from "../lib/download.js";
|
|
5
|
+
import { GitHubClient } from "../lib/github.js";
|
|
6
|
+
import { FileMerger } from "../lib/merge.js";
|
|
7
|
+
import { PromptsManager } from "../lib/prompts.js";
|
|
8
|
+
import { AVAILABLE_KITS, type NewCommandOptions, NewCommandOptionsSchema } from "../types.js";
|
|
9
|
+
import { ConfigManager } from "../utils/config.js";
|
|
10
|
+
import { logger } from "../utils/logger.js";
|
|
11
|
+
|
|
12
|
+
export async function newCommand(options: NewCommandOptions): Promise<void> {
|
|
13
|
+
const prompts = new PromptsManager();
|
|
14
|
+
|
|
15
|
+
prompts.intro("🚀 ClaudeKit - Create New Project");
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Validate and parse options
|
|
19
|
+
const validOptions = NewCommandOptionsSchema.parse(options);
|
|
20
|
+
|
|
21
|
+
// Load config for defaults
|
|
22
|
+
const config = await ConfigManager.get();
|
|
23
|
+
|
|
24
|
+
// Get kit selection
|
|
25
|
+
let kit = validOptions.kit || config.defaults?.kit;
|
|
26
|
+
if (!kit) {
|
|
27
|
+
kit = await prompts.selectKit();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const kitConfig = AVAILABLE_KITS[kit];
|
|
31
|
+
logger.info(`Selected kit: ${kitConfig.name}`);
|
|
32
|
+
|
|
33
|
+
// Get target directory
|
|
34
|
+
let targetDir = validOptions.dir || config.defaults?.dir || ".";
|
|
35
|
+
if (!validOptions.dir && !config.defaults?.dir) {
|
|
36
|
+
targetDir = await prompts.getDirectory(targetDir);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const resolvedDir = resolve(targetDir);
|
|
40
|
+
logger.info(`Target directory: ${resolvedDir}`);
|
|
41
|
+
|
|
42
|
+
// Check if directory exists and is not empty
|
|
43
|
+
if (await pathExists(resolvedDir)) {
|
|
44
|
+
const files = await readdir(resolvedDir);
|
|
45
|
+
const isEmpty = files.length === 0;
|
|
46
|
+
if (!isEmpty) {
|
|
47
|
+
const continueAnyway = await prompts.confirm(
|
|
48
|
+
"Directory is not empty. Files may be overwritten. Continue?",
|
|
49
|
+
);
|
|
50
|
+
if (!continueAnyway) {
|
|
51
|
+
logger.warning("Operation cancelled");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Initialize GitHub client
|
|
58
|
+
const github = new GitHubClient();
|
|
59
|
+
|
|
60
|
+
// Check repository access
|
|
61
|
+
const spinner = ora("Checking repository access...").start();
|
|
62
|
+
const hasAccess = await github.checkAccess(kitConfig);
|
|
63
|
+
if (!hasAccess) {
|
|
64
|
+
spinner.fail("Access denied to repository");
|
|
65
|
+
logger.error(
|
|
66
|
+
`Cannot access ${kitConfig.name}. Make sure your GitHub token has access to private repositories.`,
|
|
67
|
+
);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
spinner.succeed("Repository access verified");
|
|
71
|
+
|
|
72
|
+
// Get release
|
|
73
|
+
let release;
|
|
74
|
+
if (validOptions.version) {
|
|
75
|
+
logger.info(`Fetching release version: ${validOptions.version}`);
|
|
76
|
+
release = await github.getReleaseByTag(kitConfig, validOptions.version);
|
|
77
|
+
} else {
|
|
78
|
+
logger.info("Fetching latest release...");
|
|
79
|
+
release = await github.getLatestRelease(kitConfig);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
logger.success(`Found release: ${release.tag_name} - ${release.name}`);
|
|
83
|
+
|
|
84
|
+
// Find downloadable asset
|
|
85
|
+
const asset = release.assets.find(
|
|
86
|
+
(a) => a.name.endsWith(".tar.gz") || a.name.endsWith(".tgz") || a.name.endsWith(".zip"),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (!asset) {
|
|
90
|
+
logger.error("No downloadable archive found in release");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Download asset
|
|
95
|
+
const downloadManager = new DownloadManager();
|
|
96
|
+
const tempDir = await downloadManager.createTempDir();
|
|
97
|
+
const archivePath = await downloadManager.downloadAsset(asset, tempDir);
|
|
98
|
+
|
|
99
|
+
// Extract archive
|
|
100
|
+
const extractDir = `${tempDir}/extracted`;
|
|
101
|
+
await downloadManager.extractArchive(archivePath, extractDir);
|
|
102
|
+
|
|
103
|
+
// Copy files to target directory
|
|
104
|
+
const merger = new FileMerger();
|
|
105
|
+
await merger.merge(extractDir, resolvedDir, true); // Skip confirmation for new projects
|
|
106
|
+
|
|
107
|
+
prompts.outro(`✨ Project created successfully at ${resolvedDir}`);
|
|
108
|
+
|
|
109
|
+
// Show next steps
|
|
110
|
+
prompts.note(
|
|
111
|
+
`cd ${targetDir !== "." ? targetDir : "into the directory"}\nbun install\nbun run dev`,
|
|
112
|
+
"Next steps",
|
|
113
|
+
);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
logger.error(error instanceof Error ? error.message : "Unknown error occurred");
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { pathExists } from "fs-extra";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { DownloadManager } from "../lib/download.js";
|
|
5
|
+
import { GitHubClient } from "../lib/github.js";
|
|
6
|
+
import { FileMerger } from "../lib/merge.js";
|
|
7
|
+
import { PromptsManager } from "../lib/prompts.js";
|
|
8
|
+
import { AVAILABLE_KITS, type UpdateCommandOptions, UpdateCommandOptionsSchema } from "../types.js";
|
|
9
|
+
import { ConfigManager } from "../utils/config.js";
|
|
10
|
+
import { logger } from "../utils/logger.js";
|
|
11
|
+
|
|
12
|
+
export async function updateCommand(options: UpdateCommandOptions): Promise<void> {
|
|
13
|
+
const prompts = new PromptsManager();
|
|
14
|
+
|
|
15
|
+
prompts.intro("🔄 ClaudeKit - Update Project");
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Validate and parse options
|
|
19
|
+
const validOptions = UpdateCommandOptionsSchema.parse(options);
|
|
20
|
+
|
|
21
|
+
// Load config for defaults
|
|
22
|
+
const config = await ConfigManager.get();
|
|
23
|
+
|
|
24
|
+
// Get kit selection
|
|
25
|
+
let kit = validOptions.kit || config.defaults?.kit;
|
|
26
|
+
if (!kit) {
|
|
27
|
+
kit = await prompts.selectKit();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const kitConfig = AVAILABLE_KITS[kit];
|
|
31
|
+
logger.info(`Selected kit: ${kitConfig.name}`);
|
|
32
|
+
|
|
33
|
+
// Get target directory
|
|
34
|
+
let targetDir = validOptions.dir || config.defaults?.dir || ".";
|
|
35
|
+
if (!validOptions.dir && !config.defaults?.dir) {
|
|
36
|
+
targetDir = await prompts.getDirectory(targetDir);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const resolvedDir = resolve(targetDir);
|
|
40
|
+
logger.info(`Target directory: ${resolvedDir}`);
|
|
41
|
+
|
|
42
|
+
// Check if directory exists
|
|
43
|
+
if (!(await pathExists(resolvedDir))) {
|
|
44
|
+
logger.error(`Directory does not exist: ${resolvedDir}`);
|
|
45
|
+
logger.info('Use "ck new" to create a new project');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Initialize GitHub client
|
|
50
|
+
const github = new GitHubClient();
|
|
51
|
+
|
|
52
|
+
// Check repository access
|
|
53
|
+
const spinner = ora("Checking repository access...").start();
|
|
54
|
+
const hasAccess = await github.checkAccess(kitConfig);
|
|
55
|
+
if (!hasAccess) {
|
|
56
|
+
spinner.fail("Access denied to repository");
|
|
57
|
+
logger.error(
|
|
58
|
+
`Cannot access ${kitConfig.name}. Make sure your GitHub token has access to private repositories.`,
|
|
59
|
+
);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
spinner.succeed("Repository access verified");
|
|
63
|
+
|
|
64
|
+
// Get release
|
|
65
|
+
let release;
|
|
66
|
+
if (validOptions.version) {
|
|
67
|
+
logger.info(`Fetching release version: ${validOptions.version}`);
|
|
68
|
+
release = await github.getReleaseByTag(kitConfig, validOptions.version);
|
|
69
|
+
} else {
|
|
70
|
+
logger.info("Fetching latest release...");
|
|
71
|
+
release = await github.getLatestRelease(kitConfig);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
logger.success(`Found release: ${release.tag_name} - ${release.name}`);
|
|
75
|
+
|
|
76
|
+
// Find downloadable asset
|
|
77
|
+
const asset = release.assets.find(
|
|
78
|
+
(a) => a.name.endsWith(".tar.gz") || a.name.endsWith(".tgz") || a.name.endsWith(".zip"),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (!asset) {
|
|
82
|
+
logger.error("No downloadable archive found in release");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Download asset
|
|
87
|
+
const downloadManager = new DownloadManager();
|
|
88
|
+
const tempDir = await downloadManager.createTempDir();
|
|
89
|
+
const archivePath = await downloadManager.downloadAsset(asset, tempDir);
|
|
90
|
+
|
|
91
|
+
// Extract archive
|
|
92
|
+
const extractDir = `${tempDir}/extracted`;
|
|
93
|
+
await downloadManager.extractArchive(archivePath, extractDir);
|
|
94
|
+
|
|
95
|
+
// Merge files with confirmation
|
|
96
|
+
const merger = new FileMerger();
|
|
97
|
+
await merger.merge(extractDir, resolvedDir, false); // Show confirmation for updates
|
|
98
|
+
|
|
99
|
+
prompts.outro(`✨ Project updated successfully at ${resolvedDir}`);
|
|
100
|
+
|
|
101
|
+
// Show next steps
|
|
102
|
+
prompts.note(
|
|
103
|
+
"Your project has been updated with the latest version.\nProtected files (.env, etc.) were not modified.",
|
|
104
|
+
"Update complete",
|
|
105
|
+
);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof Error && error.message === "Merge cancelled by user") {
|
|
108
|
+
logger.warning("Update cancelled");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
logger.error(error instanceof Error ? error.message : "Unknown error occurred");
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { cac } from "cac";
|
|
7
|
+
import { newCommand } from "./commands/new.js";
|
|
8
|
+
import { updateCommand } from "./commands/update.js";
|
|
9
|
+
|
|
10
|
+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
11
|
+
|
|
12
|
+
// Read package.json for version
|
|
13
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
14
|
+
|
|
15
|
+
const cli = cac("ck");
|
|
16
|
+
|
|
17
|
+
// New command
|
|
18
|
+
cli
|
|
19
|
+
.command("new", "Bootstrap a new ClaudeKit project")
|
|
20
|
+
.option("--dir <dir>", "Target directory (default: .)")
|
|
21
|
+
.option("--kit <kit>", "Kit to use (engineer, marketing)")
|
|
22
|
+
.option("--version <version>", "Specific version to download (default: latest)")
|
|
23
|
+
.action(async (options) => {
|
|
24
|
+
await newCommand(options);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Update command
|
|
28
|
+
cli
|
|
29
|
+
.command("update", "Update existing ClaudeKit project")
|
|
30
|
+
.option("--dir <dir>", "Target directory (default: .)")
|
|
31
|
+
.option("--kit <kit>", "Kit to use (engineer, marketing)")
|
|
32
|
+
.option("--version <version>", "Specific version to download (default: latest)")
|
|
33
|
+
.action(async (options) => {
|
|
34
|
+
await updateCommand(options);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Version
|
|
38
|
+
cli.version(packageJson.version);
|
|
39
|
+
|
|
40
|
+
// Help
|
|
41
|
+
cli.help();
|
|
42
|
+
|
|
43
|
+
// Parse CLI arguments
|
|
44
|
+
cli.parse();
|