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,821 @@
|
|
|
1
|
+
# Codebase Summary and Structure
|
|
2
|
+
# ClaudeKit CLI
|
|
3
|
+
|
|
4
|
+
**Version:** 0.1.0
|
|
5
|
+
**Date:** 2025-10-08
|
|
6
|
+
**Lines of Code:** ~1,438 (production) + ~850 (tests)
|
|
7
|
+
**Language:** TypeScript
|
|
8
|
+
**Runtime:** Bun v1.x+
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
1. [Project Overview](#project-overview)
|
|
15
|
+
2. [Directory Structure](#directory-structure)
|
|
16
|
+
3. [Module Breakdown](#module-breakdown)
|
|
17
|
+
4. [Entry Points](#entry-points)
|
|
18
|
+
5. [Key Dependencies](#key-dependencies)
|
|
19
|
+
6. [Testing Structure](#testing-structure)
|
|
20
|
+
7. [Build and Distribution](#build-and-distribution)
|
|
21
|
+
8. [Configuration Files](#configuration-files)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Project Overview
|
|
26
|
+
|
|
27
|
+
**ClaudeKit CLI** is a command-line tool for bootstrapping and updating projects from private GitHub repository releases. Built with Bun and TypeScript, it provides a fast, secure, and user-friendly experience for project setup and maintenance.
|
|
28
|
+
|
|
29
|
+
**Core Features:**
|
|
30
|
+
- Multi-tier GitHub authentication (gh CLI → env vars → keychain → prompt)
|
|
31
|
+
- Streaming downloads with progress tracking
|
|
32
|
+
- Smart file merging with conflict detection
|
|
33
|
+
- Secure credential storage using OS keychain
|
|
34
|
+
- Beautiful CLI interface with interactive prompts
|
|
35
|
+
|
|
36
|
+
**Tech Stack:**
|
|
37
|
+
- Runtime: Bun (fast JavaScript/TypeScript runtime)
|
|
38
|
+
- Language: TypeScript 5.x (strict mode)
|
|
39
|
+
- Validation: Zod (runtime type checking)
|
|
40
|
+
- CLI Framework: CAC (command parsing)
|
|
41
|
+
- UI: @clack/prompts, ora, cli-progress
|
|
42
|
+
- GitHub: @octokit/rest
|
|
43
|
+
- File Operations: fs-extra, tar, unzipper
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Directory Structure
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
claudekit-cli/
|
|
51
|
+
├── .github/ # GitHub workflows (future)
|
|
52
|
+
├── bin/ # Compiled binaries (output)
|
|
53
|
+
├── dist/ # Build output (transpiled JS)
|
|
54
|
+
├── docs/ # Documentation
|
|
55
|
+
│ ├── project-pdr.md # Product requirements
|
|
56
|
+
│ ├── code-standards.md # Coding standards
|
|
57
|
+
│ ├── system-architecture.md # Architecture diagrams
|
|
58
|
+
│ ├── codebase-summary.md # This file
|
|
59
|
+
│ └── tech-stack.md # Technology stack details
|
|
60
|
+
├── plans/ # Implementation plans & reports
|
|
61
|
+
│ ├── 251008-claudekit-cli-implementation-plan.md
|
|
62
|
+
│ ├── reports/ # Agent reports
|
|
63
|
+
│ │ ├── 251008-from-tester-to-developer-test-summary-report.md
|
|
64
|
+
│ │ ├── 251008-from-code-reviewer-to-developer-review-report.md
|
|
65
|
+
│ │ └── ...
|
|
66
|
+
│ ├── research/ # Research documents
|
|
67
|
+
│ │ └── 251008-cli-frameworks-bun-research.md
|
|
68
|
+
│ └── templates/ # Plan templates
|
|
69
|
+
├── src/ # Source code
|
|
70
|
+
│ ├── commands/ # Command implementations
|
|
71
|
+
│ │ ├── new.ts # 'ck new' command
|
|
72
|
+
│ │ └── update.ts # 'ck update' command
|
|
73
|
+
│ ├── lib/ # Core libraries
|
|
74
|
+
│ │ ├── auth.ts # Authentication manager
|
|
75
|
+
│ │ ├── github.ts # GitHub API client
|
|
76
|
+
│ │ ├── download.ts # Download manager
|
|
77
|
+
│ │ ├── merge.ts # File merger
|
|
78
|
+
│ │ └── prompts.ts # Interactive prompts
|
|
79
|
+
│ ├── utils/ # Utility modules
|
|
80
|
+
│ │ ├── config.ts # Configuration manager
|
|
81
|
+
│ │ └── logger.ts # Logger with sanitization
|
|
82
|
+
│ ├── index.ts # CLI entry point
|
|
83
|
+
│ └── types.ts # Type definitions & schemas
|
|
84
|
+
├── tests/ # Test files
|
|
85
|
+
│ ├── lib/
|
|
86
|
+
│ │ ├── auth.test.ts
|
|
87
|
+
│ │ ├── github.test.ts
|
|
88
|
+
│ │ ├── download.test.ts
|
|
89
|
+
│ │ ├── merge.test.ts
|
|
90
|
+
│ │ └── prompts.test.ts
|
|
91
|
+
│ ├── utils/
|
|
92
|
+
│ │ ├── config.test.ts
|
|
93
|
+
│ │ └── logger.test.ts
|
|
94
|
+
│ └── types.test.ts
|
|
95
|
+
├── .gitignore # Git ignore patterns
|
|
96
|
+
├── AGENTS.md # Agent definitions
|
|
97
|
+
├── CLAUDE.md # AI assistant instructions
|
|
98
|
+
├── README.md # User documentation
|
|
99
|
+
├── biome.json # Biome config (linter)
|
|
100
|
+
├── bun.lockb # Bun lock file
|
|
101
|
+
├── package.json # Package manifest
|
|
102
|
+
└── tsconfig.json # TypeScript configuration
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Module Breakdown
|
|
108
|
+
|
|
109
|
+
### Core Entry Point
|
|
110
|
+
|
|
111
|
+
#### `src/index.ts` (47 lines)
|
|
112
|
+
**Purpose:** CLI entry point and command routing
|
|
113
|
+
|
|
114
|
+
**Responsibilities:**
|
|
115
|
+
- Initialize CAC command parser
|
|
116
|
+
- Register commands (new, update)
|
|
117
|
+
- Handle version and help flags
|
|
118
|
+
- Global error handling
|
|
119
|
+
- Process exit codes
|
|
120
|
+
|
|
121
|
+
**Key Code:**
|
|
122
|
+
```typescript
|
|
123
|
+
#!/usr/bin/env bun
|
|
124
|
+
|
|
125
|
+
import { cac } from 'cac';
|
|
126
|
+
import { newCommand } from './commands/new';
|
|
127
|
+
import { updateCommand } from './commands/update';
|
|
128
|
+
|
|
129
|
+
const cli = cac('ck');
|
|
130
|
+
|
|
131
|
+
cli.command('new [dir]', 'Create a new project')
|
|
132
|
+
.option('--kit <kit>', 'Kit type: engineer, marketing')
|
|
133
|
+
.option('--version <version>', 'Specific version')
|
|
134
|
+
.action(newCommand);
|
|
135
|
+
|
|
136
|
+
cli.command('update [dir]', 'Update existing project')
|
|
137
|
+
.option('--kit <kit>', 'Kit type: engineer, marketing')
|
|
138
|
+
.option('--version <version>', 'Specific version')
|
|
139
|
+
.action(updateCommand);
|
|
140
|
+
|
|
141
|
+
cli.version(VERSION);
|
|
142
|
+
cli.help();
|
|
143
|
+
cli.parse();
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### Type Definitions
|
|
149
|
+
|
|
150
|
+
#### `src/types.ts` (146 lines)
|
|
151
|
+
**Purpose:** Central type definitions and validation schemas
|
|
152
|
+
|
|
153
|
+
**Contents:**
|
|
154
|
+
- Zod schemas for runtime validation
|
|
155
|
+
- TypeScript type exports
|
|
156
|
+
- Custom error classes
|
|
157
|
+
- Kit configuration
|
|
158
|
+
|
|
159
|
+
**Key Schemas:**
|
|
160
|
+
```typescript
|
|
161
|
+
// Command options
|
|
162
|
+
export const NewCommandOptionsSchema = z.object({
|
|
163
|
+
dir: z.string().default('.'),
|
|
164
|
+
kit: KitType.optional(),
|
|
165
|
+
version: z.string().optional(),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// GitHub release
|
|
169
|
+
export const GitHubReleaseSchema = z.object({
|
|
170
|
+
id: z.number(),
|
|
171
|
+
tag_name: z.string(),
|
|
172
|
+
name: z.string().nullable(),
|
|
173
|
+
assets: z.array(GitHubReleaseAssetSchema),
|
|
174
|
+
// ...
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Configuration
|
|
178
|
+
export const ConfigSchema = z.object({
|
|
179
|
+
github: z.object({
|
|
180
|
+
token: z.string().optional(),
|
|
181
|
+
}).optional(),
|
|
182
|
+
defaults: z.object({
|
|
183
|
+
kit: KitType.optional(),
|
|
184
|
+
dir: z.string().optional(),
|
|
185
|
+
}).optional(),
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Error Classes:**
|
|
190
|
+
```typescript
|
|
191
|
+
export class ClaudeKitError extends Error { ... }
|
|
192
|
+
export class AuthenticationError extends ClaudeKitError { ... }
|
|
193
|
+
export class GitHubError extends ClaudeKitError { ... }
|
|
194
|
+
export class DownloadError extends ClaudeKitError { ... }
|
|
195
|
+
export class ExtractionError extends ClaudeKitError { ... }
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### Commands
|
|
201
|
+
|
|
202
|
+
#### `src/commands/new.ts` (118 lines)
|
|
203
|
+
**Purpose:** Create new project from release
|
|
204
|
+
|
|
205
|
+
**Workflow:**
|
|
206
|
+
1. Parse and validate options
|
|
207
|
+
2. Get target directory (prompt if needed)
|
|
208
|
+
3. Validate directory is empty
|
|
209
|
+
4. Authenticate with GitHub
|
|
210
|
+
5. Select kit (prompt if needed)
|
|
211
|
+
6. Fetch latest release
|
|
212
|
+
7. Download release asset
|
|
213
|
+
8. Extract archive
|
|
214
|
+
9. Merge files to target directory
|
|
215
|
+
10. Show success message with next steps
|
|
216
|
+
|
|
217
|
+
**Key Features:**
|
|
218
|
+
- Interactive prompts for missing options
|
|
219
|
+
- Directory validation
|
|
220
|
+
- Progress tracking
|
|
221
|
+
- Error handling with cleanup
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
#### `src/commands/update.ts` (115 lines)
|
|
226
|
+
**Purpose:** Update existing project
|
|
227
|
+
|
|
228
|
+
**Workflow:**
|
|
229
|
+
1. Parse and validate options
|
|
230
|
+
2. Validate directory exists
|
|
231
|
+
3. Authenticate with GitHub
|
|
232
|
+
4. Detect kit from existing project
|
|
233
|
+
5. Fetch release (latest or specified version)
|
|
234
|
+
6. Detect file conflicts
|
|
235
|
+
7. Show confirmation prompt
|
|
236
|
+
8. Download and extract
|
|
237
|
+
9. Merge with conflict resolution
|
|
238
|
+
10. Show update summary
|
|
239
|
+
|
|
240
|
+
**Key Features:**
|
|
241
|
+
- Conflict detection before download
|
|
242
|
+
- Protected file patterns
|
|
243
|
+
- Confirmation prompt
|
|
244
|
+
- Update statistics
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
### Core Libraries
|
|
249
|
+
|
|
250
|
+
#### `src/lib/auth.ts` (152 lines)
|
|
251
|
+
**Purpose:** Multi-tier authentication management
|
|
252
|
+
|
|
253
|
+
**Authentication Fallback Chain:**
|
|
254
|
+
1. GitHub CLI (`gh auth token`)
|
|
255
|
+
2. Environment variables (GITHUB_TOKEN, GH_TOKEN)
|
|
256
|
+
3. Configuration file (~/.claudekit/config.json)
|
|
257
|
+
4. OS Keychain (via keytar)
|
|
258
|
+
5. User prompt (with optional storage)
|
|
259
|
+
|
|
260
|
+
**Key Methods:**
|
|
261
|
+
```typescript
|
|
262
|
+
class AuthManager {
|
|
263
|
+
static async getToken(): Promise<{ token: string; method: AuthMethod }> { ... }
|
|
264
|
+
static async getFromGhCli(): Promise<string | null> { ... }
|
|
265
|
+
static async promptForToken(): Promise<string> { ... }
|
|
266
|
+
static async saveToken(token: string): Promise<void> { ... }
|
|
267
|
+
static validateTokenFormat(token: string): boolean { ... }
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Features:**
|
|
272
|
+
- Token format validation
|
|
273
|
+
- Secure keychain storage
|
|
274
|
+
- User consent before storing
|
|
275
|
+
- Token caching
|
|
276
|
+
- Clear error messages
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
#### `src/lib/github.ts` (149 lines)
|
|
281
|
+
**Purpose:** GitHub API client for fetching releases
|
|
282
|
+
|
|
283
|
+
**Key Methods:**
|
|
284
|
+
```typescript
|
|
285
|
+
class GitHubClient {
|
|
286
|
+
constructor(token: string) { ... }
|
|
287
|
+
|
|
288
|
+
async getLatestRelease(kit: KitConfig): Promise<GitHubRelease> { ... }
|
|
289
|
+
async getRelease(kit: KitConfig, version: string): Promise<GitHubRelease> { ... }
|
|
290
|
+
async listReleases(kit: KitConfig): Promise<GitHubRelease[]> { ... }
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Features:**
|
|
295
|
+
- Octokit REST API integration
|
|
296
|
+
- Retry logic with exponential backoff
|
|
297
|
+
- Rate limit handling
|
|
298
|
+
- Error mapping (404, 401, 403)
|
|
299
|
+
- Private repository support
|
|
300
|
+
|
|
301
|
+
**Error Handling:**
|
|
302
|
+
- 404: Repository or release not found
|
|
303
|
+
- 401: Invalid or expired token
|
|
304
|
+
- 403: Rate limit exceeded
|
|
305
|
+
- Network errors with retry
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
#### `src/lib/download.ts` (178 lines)
|
|
310
|
+
**Purpose:** Streaming downloads with progress tracking
|
|
311
|
+
|
|
312
|
+
**Key Methods:**
|
|
313
|
+
```typescript
|
|
314
|
+
class DownloadManager {
|
|
315
|
+
async createTempDir(): Promise<string> { ... }
|
|
316
|
+
async downloadAsset(asset: GitHubReleaseAsset, destDir: string): Promise<string> { ... }
|
|
317
|
+
async extractArchive(archivePath: string, destDir: string): Promise<void> { ... }
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Features:**
|
|
322
|
+
- Streaming downloads (memory efficient)
|
|
323
|
+
- Progress bar with speed and ETA
|
|
324
|
+
- Temporary directory management
|
|
325
|
+
- Format detection (tar.gz, zip)
|
|
326
|
+
- Automatic cleanup
|
|
327
|
+
|
|
328
|
+
**Archive Extraction:**
|
|
329
|
+
- TAR.GZ: Uses `tar` library with streaming
|
|
330
|
+
- ZIP: Uses `unzipper` library
|
|
331
|
+
- Path traversal protection
|
|
332
|
+
- Strip top-level directory
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
#### `src/lib/merge.ts` (117 lines)
|
|
337
|
+
**Purpose:** Smart file merging with conflict detection
|
|
338
|
+
|
|
339
|
+
**Protected Patterns:**
|
|
340
|
+
```typescript
|
|
341
|
+
const DEFAULT_IGNORE_PATTERNS = [
|
|
342
|
+
'.env',
|
|
343
|
+
'.env.*',
|
|
344
|
+
'*.key',
|
|
345
|
+
'*.pem',
|
|
346
|
+
'*.p12',
|
|
347
|
+
'node_modules/**',
|
|
348
|
+
'.git/**',
|
|
349
|
+
'dist/**',
|
|
350
|
+
'build/**',
|
|
351
|
+
'bun.lockb',
|
|
352
|
+
];
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Key Methods:**
|
|
356
|
+
```typescript
|
|
357
|
+
class FileMerger {
|
|
358
|
+
constructor(ignorePatterns?: string[]) { ... }
|
|
359
|
+
|
|
360
|
+
async merge(
|
|
361
|
+
sourceDir: string,
|
|
362
|
+
destDir: string,
|
|
363
|
+
isNewProject: boolean
|
|
364
|
+
): Promise<MergeResult> { ... }
|
|
365
|
+
|
|
366
|
+
async detectConflicts(sourceDir: string, destDir: string): Promise<string[]> { ... }
|
|
367
|
+
private async copyFile(source: string, dest: string): Promise<void> { ... }
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Features:**
|
|
372
|
+
- Conflict detection before merge
|
|
373
|
+
- Protected file patterns with `ignore` library
|
|
374
|
+
- Recursive directory copying
|
|
375
|
+
- Merge statistics (created, skipped, overwritten)
|
|
376
|
+
- Error recovery
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
#### `src/lib/prompts.ts` (114 lines)
|
|
381
|
+
**Purpose:** Interactive user prompts with validation
|
|
382
|
+
|
|
383
|
+
**Key Methods:**
|
|
384
|
+
```typescript
|
|
385
|
+
class PromptsManager {
|
|
386
|
+
async selectKit(): Promise<KitType> { ... }
|
|
387
|
+
async selectVersion(versions: GitHubRelease[], defaultVersion?: string): Promise<string> { ... }
|
|
388
|
+
async getDirectory(defaultDir?: string): Promise<string> { ... }
|
|
389
|
+
async confirm(message: string, defaultValue?: boolean): Promise<boolean> { ... }
|
|
390
|
+
|
|
391
|
+
intro(message: string): void { ... }
|
|
392
|
+
outro(message: string): void { ... }
|
|
393
|
+
note(message: string, title?: string): void { ... }
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Features:**
|
|
398
|
+
- Beautiful UI with `@clack/prompts`
|
|
399
|
+
- Input validation
|
|
400
|
+
- Default values
|
|
401
|
+
- Colorized output
|
|
402
|
+
- Progress indicators
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
### Utilities
|
|
407
|
+
|
|
408
|
+
#### `src/utils/config.ts` (84 lines)
|
|
409
|
+
**Purpose:** Configuration file management
|
|
410
|
+
|
|
411
|
+
**Configuration Location:** `~/.claudekit/config.json`
|
|
412
|
+
|
|
413
|
+
**Key Methods:**
|
|
414
|
+
```typescript
|
|
415
|
+
class ConfigManager {
|
|
416
|
+
static async load(): Promise<Config> { ... }
|
|
417
|
+
static async save(config: Config): Promise<void> { ... }
|
|
418
|
+
static async get(key: string): Promise<any> { ... }
|
|
419
|
+
static async set(key: string, value: any): Promise<void> { ... }
|
|
420
|
+
static async getToken(): Promise<string | undefined> { ... }
|
|
421
|
+
static async setToken(token: string): Promise<void> { ... }
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Features:**
|
|
426
|
+
- JSON configuration storage
|
|
427
|
+
- Nested key access
|
|
428
|
+
- Automatic directory creation
|
|
429
|
+
- Validation with Zod
|
|
430
|
+
- In-memory caching
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
#### `src/utils/logger.ts` (38 lines)
|
|
435
|
+
**Purpose:** Logging with token sanitization
|
|
436
|
+
|
|
437
|
+
**Log Levels:**
|
|
438
|
+
```typescript
|
|
439
|
+
logger.info(message: string): void
|
|
440
|
+
logger.success(message: string): void
|
|
441
|
+
logger.warning(message: string): void
|
|
442
|
+
logger.error(message: string, error?: unknown): void
|
|
443
|
+
logger.debug(message: string): void (only if DEBUG env var set)
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**Security Features:**
|
|
447
|
+
```typescript
|
|
448
|
+
sanitize(text: string): string {
|
|
449
|
+
return text
|
|
450
|
+
.replace(/ghp_[a-zA-Z0-9]{36}/g, 'ghp_***')
|
|
451
|
+
.replace(/github_pat_[a-zA-Z0-9_]{82}/g, 'github_pat_***')
|
|
452
|
+
.replace(/gho_[a-zA-Z0-9]{36}/g, 'gho_***')
|
|
453
|
+
// ... more patterns
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
**Features:**
|
|
458
|
+
- Colorized output with `picocolors`
|
|
459
|
+
- Token sanitization (all GitHub token formats)
|
|
460
|
+
- Conditional debug logging
|
|
461
|
+
- Error stack traces
|
|
462
|
+
- Clean, readable output
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
## Entry Points
|
|
467
|
+
|
|
468
|
+
### CLI Entry Point
|
|
469
|
+
**File:** `src/index.ts`
|
|
470
|
+
**Shebang:** `#!/usr/bin/env bun`
|
|
471
|
+
**Binary:** `ck` (defined in package.json)
|
|
472
|
+
|
|
473
|
+
**Usage:**
|
|
474
|
+
```bash
|
|
475
|
+
ck new # Interactive mode
|
|
476
|
+
ck new --kit engineer # With options
|
|
477
|
+
ck update # Interactive mode
|
|
478
|
+
ck --version # Show version
|
|
479
|
+
ck --help # Show help
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Package Entry Point
|
|
483
|
+
**File:** `dist/index.js` (after build)
|
|
484
|
+
**Method:** `bun build src/index.ts --outdir dist --target node`
|
|
485
|
+
|
|
486
|
+
### Standalone Binary
|
|
487
|
+
**File:** `ck` (compiled binary)
|
|
488
|
+
**Method:** `bun build src/index.ts --compile --outfile ck`
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## Key Dependencies
|
|
493
|
+
|
|
494
|
+
### Production Dependencies
|
|
495
|
+
|
|
496
|
+
| Package | Version | Purpose |
|
|
497
|
+
|---------|---------|---------|
|
|
498
|
+
| `cac` | ^6.7.14 | Command-line argument parsing |
|
|
499
|
+
| `@clack/prompts` | ^0.7.0 | Beautiful interactive prompts |
|
|
500
|
+
| `@octokit/rest` | ^22.0.0 | GitHub REST API client |
|
|
501
|
+
| `zod` | ^3.23.8 | Runtime type validation |
|
|
502
|
+
| `keytar` | ^7.9.0 | Secure credential storage |
|
|
503
|
+
| `ora` | ^9.0.0 | Terminal spinners |
|
|
504
|
+
| `cli-progress` | ^3.12.0 | Progress bars |
|
|
505
|
+
| `picocolors` | ^1.1.1 | Terminal colors |
|
|
506
|
+
| `fs-extra` | ^11.2.0 | Enhanced file system operations |
|
|
507
|
+
| `tar` | ^7.4.3 | TAR archive extraction |
|
|
508
|
+
| `unzipper` | ^0.12.3 | ZIP archive extraction |
|
|
509
|
+
| `ignore` | ^5.3.2 | .gitignore-style pattern matching |
|
|
510
|
+
| `tmp` | ^0.2.3 | Temporary file management |
|
|
511
|
+
|
|
512
|
+
### Development Dependencies
|
|
513
|
+
|
|
514
|
+
| Package | Version | Purpose |
|
|
515
|
+
|---------|---------|---------|
|
|
516
|
+
| `typescript` | ^5.7.2 | TypeScript compiler |
|
|
517
|
+
| `@biomejs/biome` | ^1.9.4 | Linter and formatter |
|
|
518
|
+
| `@types/bun` | latest | Bun type definitions |
|
|
519
|
+
| `@types/node` | ^22.10.1 | Node.js type definitions |
|
|
520
|
+
| `@types/*` | various | Type definitions for dependencies |
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Testing Structure
|
|
525
|
+
|
|
526
|
+
### Test Organization
|
|
527
|
+
|
|
528
|
+
Tests mirror the source structure:
|
|
529
|
+
|
|
530
|
+
```
|
|
531
|
+
tests/
|
|
532
|
+
├── lib/ # Library tests
|
|
533
|
+
│ ├── auth.test.ts # 9 tests - Authentication
|
|
534
|
+
│ ├── github.test.ts # 5 tests - GitHub client
|
|
535
|
+
│ ├── download.test.ts # 5 tests - Downloads
|
|
536
|
+
│ ├── merge.test.ts # 11 tests - File merging
|
|
537
|
+
│ └── prompts.test.ts # 11 tests - User prompts
|
|
538
|
+
├── utils/ # Utility tests
|
|
539
|
+
│ ├── config.test.ts # 15 tests - Configuration
|
|
540
|
+
│ └── logger.test.ts # 13 tests - Logging
|
|
541
|
+
└── types.test.ts # 24 tests - Types & validation
|
|
542
|
+
|
|
543
|
+
Total: 93 tests (100% pass rate)
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### Test Coverage
|
|
547
|
+
|
|
548
|
+
**Overall:** 93 tests passing
|
|
549
|
+
**Coverage:** ~80% (estimated)
|
|
550
|
+
|
|
551
|
+
**Coverage by Module:**
|
|
552
|
+
- ✅ **Excellent:** types.ts, config.ts, logger.ts, merge.ts
|
|
553
|
+
- ✅ **Good:** auth.ts, prompts.ts
|
|
554
|
+
- ✅ **Basic:** github.ts, download.ts (integration tests would require mocking)
|
|
555
|
+
|
|
556
|
+
### Test Execution
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
bun test # Run all tests
|
|
560
|
+
bun test --watch # Watch mode
|
|
561
|
+
bun test path/to/file.test.ts # Run specific test
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
**Performance:** 734ms total execution time
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## Build and Distribution
|
|
569
|
+
|
|
570
|
+
### Development Build
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
bun install # Install dependencies
|
|
574
|
+
bun run dev # Run in development mode
|
|
575
|
+
bun run typecheck # Type check
|
|
576
|
+
bun run lint # Lint code
|
|
577
|
+
bun run format # Format code
|
|
578
|
+
bun test # Run tests
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### Production Build
|
|
582
|
+
|
|
583
|
+
```bash
|
|
584
|
+
# Transpiled build (for npm)
|
|
585
|
+
bun run build
|
|
586
|
+
# Output: dist/index.js
|
|
587
|
+
|
|
588
|
+
# Standalone binary (for direct distribution)
|
|
589
|
+
bun run compile
|
|
590
|
+
# Output: ./ck (executable)
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### Cross-Platform Builds
|
|
594
|
+
|
|
595
|
+
```bash
|
|
596
|
+
# macOS ARM64
|
|
597
|
+
bun build --compile src/index.ts --target=bun-darwin-arm64 --outfile ck-macos-arm64
|
|
598
|
+
|
|
599
|
+
# macOS x64
|
|
600
|
+
bun build --compile src/index.ts --target=bun-darwin-x64 --outfile ck-macos-x64
|
|
601
|
+
|
|
602
|
+
# Linux x64
|
|
603
|
+
bun build --compile src/index.ts --target=bun-linux-x64 --outfile ck-linux
|
|
604
|
+
|
|
605
|
+
# Windows x64
|
|
606
|
+
bun build --compile src/index.ts --target=bun-windows-x64 --outfile ck.exe
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### Distribution Methods
|
|
610
|
+
|
|
611
|
+
**1. npm Registry (Primary):**
|
|
612
|
+
```bash
|
|
613
|
+
bun add -g claudekit-cli
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
**2. GitHub Releases (Standalone Binary):**
|
|
617
|
+
```bash
|
|
618
|
+
curl -fsSL https://github.com/mrgoonie/claudekit-cli/releases/download/v0.1.0/ck-macos-arm64 -o ck
|
|
619
|
+
chmod +x ck
|
|
620
|
+
sudo mv ck /usr/local/bin/
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
**3. From Source:**
|
|
624
|
+
```bash
|
|
625
|
+
git clone https://github.com/mrgoonie/claudekit-cli
|
|
626
|
+
cd claudekit-cli
|
|
627
|
+
bun install
|
|
628
|
+
bun link
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
## Configuration Files
|
|
634
|
+
|
|
635
|
+
### `package.json`
|
|
636
|
+
**Purpose:** Package manifest and scripts
|
|
637
|
+
|
|
638
|
+
**Key Fields:**
|
|
639
|
+
```json
|
|
640
|
+
{
|
|
641
|
+
"name": "claudekit-cli",
|
|
642
|
+
"version": "0.1.0",
|
|
643
|
+
"type": "module",
|
|
644
|
+
"bin": {
|
|
645
|
+
"ck": "./dist/index.js"
|
|
646
|
+
},
|
|
647
|
+
"engines": {
|
|
648
|
+
"bun": ">=1.0.0"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### `tsconfig.json`
|
|
654
|
+
**Purpose:** TypeScript compiler configuration
|
|
655
|
+
|
|
656
|
+
**Key Settings:**
|
|
657
|
+
```json
|
|
658
|
+
{
|
|
659
|
+
"compilerOptions": {
|
|
660
|
+
"strict": true,
|
|
661
|
+
"target": "ES2022",
|
|
662
|
+
"module": "ESNext",
|
|
663
|
+
"moduleResolution": "bundler",
|
|
664
|
+
"types": ["bun-types"]
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
### `biome.json`
|
|
670
|
+
**Purpose:** Biome linter and formatter configuration
|
|
671
|
+
|
|
672
|
+
**Key Rules:**
|
|
673
|
+
- Recommended rules enabled
|
|
674
|
+
- Organize imports
|
|
675
|
+
- No `any` warnings
|
|
676
|
+
- No debugger/console.log in production
|
|
677
|
+
- 2-space indentation
|
|
678
|
+
- 100 character line width
|
|
679
|
+
|
|
680
|
+
### `.gitignore`
|
|
681
|
+
**Purpose:** Git ignore patterns
|
|
682
|
+
|
|
683
|
+
**Ignored:**
|
|
684
|
+
- `node_modules/`
|
|
685
|
+
- `dist/`
|
|
686
|
+
- `bin/`
|
|
687
|
+
- `*.log`
|
|
688
|
+
- `.env`
|
|
689
|
+
- `bun.lockb` (should be committed, but shown as example)
|
|
690
|
+
|
|
691
|
+
---
|
|
692
|
+
|
|
693
|
+
## Code Statistics
|
|
694
|
+
|
|
695
|
+
### Lines of Code by Module
|
|
696
|
+
|
|
697
|
+
| Module | Lines | Complexity | Status |
|
|
698
|
+
|--------|-------|------------|--------|
|
|
699
|
+
| **index.ts** | 47 | Low | ✅ Complete |
|
|
700
|
+
| **types.ts** | 146 | Low | ✅ Complete |
|
|
701
|
+
| **auth.ts** | 152 | Medium | ✅ Complete |
|
|
702
|
+
| **github.ts** | 149 | Medium | ✅ Complete |
|
|
703
|
+
| **download.ts** | 178 | High | ✅ Complete |
|
|
704
|
+
| **merge.ts** | 117 | Medium | ✅ Complete |
|
|
705
|
+
| **prompts.ts** | 114 | Low | ✅ Complete |
|
|
706
|
+
| **config.ts** | 84 | Low | ✅ Complete |
|
|
707
|
+
| **logger.ts** | 38 | Low | ✅ Complete |
|
|
708
|
+
| **new.ts** | 118 | Medium | ✅ Complete |
|
|
709
|
+
| **update.ts** | 115 | Medium | ✅ Complete |
|
|
710
|
+
|
|
711
|
+
**Total Production Code:** 1,438 lines
|
|
712
|
+
**Total Test Code:** ~850 lines
|
|
713
|
+
**Code-to-Test Ratio:** 1:0.59
|
|
714
|
+
|
|
715
|
+
### Code Quality Metrics
|
|
716
|
+
|
|
717
|
+
- **Type Coverage:** 100% (TypeScript strict mode)
|
|
718
|
+
- **Test Coverage:** ~80%
|
|
719
|
+
- **Linting Errors:** 0
|
|
720
|
+
- **Type Errors:** 0
|
|
721
|
+
- **Security Vulnerabilities:** 0
|
|
722
|
+
- **Average File Size:** 130 lines
|
|
723
|
+
- **Max File Size:** 178 lines (well under 500 line limit)
|
|
724
|
+
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
## Development Workflow
|
|
728
|
+
|
|
729
|
+
### Adding a New Feature
|
|
730
|
+
|
|
731
|
+
1. **Plan:** Create implementation plan in `plans/`
|
|
732
|
+
2. **Research:** Conduct research if needed, document in `plans/research/`
|
|
733
|
+
3. **Implement:** Write code following code standards
|
|
734
|
+
4. **Test:** Add comprehensive tests
|
|
735
|
+
5. **Review:** Run code review checklist
|
|
736
|
+
6. **Document:** Update relevant documentation
|
|
737
|
+
7. **Commit:** Use conventional commit format
|
|
738
|
+
|
|
739
|
+
### Modifying Existing Code
|
|
740
|
+
|
|
741
|
+
1. **Read:** Review module documentation
|
|
742
|
+
2. **Understand:** Check tests to understand behavior
|
|
743
|
+
3. **Modify:** Make changes following code standards
|
|
744
|
+
4. **Test:** Update and add tests
|
|
745
|
+
5. **Verify:** Run `bun test` and `bun run typecheck`
|
|
746
|
+
6. **Document:** Update JSDoc and README if needed
|
|
747
|
+
|
|
748
|
+
---
|
|
749
|
+
|
|
750
|
+
## Quick Reference
|
|
751
|
+
|
|
752
|
+
### Common Commands
|
|
753
|
+
|
|
754
|
+
```bash
|
|
755
|
+
# Development
|
|
756
|
+
bun install # Install dependencies
|
|
757
|
+
bun run dev new --kit engineer # Run in development
|
|
758
|
+
bun test # Run tests
|
|
759
|
+
bun run typecheck # Type check
|
|
760
|
+
bun run lint # Lint
|
|
761
|
+
bun run format # Format
|
|
762
|
+
|
|
763
|
+
# Build
|
|
764
|
+
bun run build # Build for npm
|
|
765
|
+
bun run compile # Build standalone binary
|
|
766
|
+
|
|
767
|
+
# Local Testing
|
|
768
|
+
bun link # Link globally
|
|
769
|
+
ck new --kit engineer # Test command
|
|
770
|
+
bun unlink # Unlink
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
### File Locations
|
|
774
|
+
|
|
775
|
+
- **Source Code:** `src/`
|
|
776
|
+
- **Tests:** `tests/`
|
|
777
|
+
- **Documentation:** `docs/`
|
|
778
|
+
- **Build Output:** `dist/` (gitignored)
|
|
779
|
+
- **Binaries:** `bin/` (gitignored)
|
|
780
|
+
- **Config:** `~/.claudekit/config.json` (user machine)
|
|
781
|
+
- **Keychain:** OS-specific (macOS Keychain, etc.)
|
|
782
|
+
|
|
783
|
+
### Environment Variables
|
|
784
|
+
|
|
785
|
+
```bash
|
|
786
|
+
GITHUB_TOKEN=ghp_xxx # GitHub PAT
|
|
787
|
+
GH_TOKEN=ghp_xxx # Alternative
|
|
788
|
+
DEBUG=1 # Enable debug logging
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
---
|
|
792
|
+
|
|
793
|
+
## Future Enhancements
|
|
794
|
+
|
|
795
|
+
### Planned Features
|
|
796
|
+
- Marketing kit support
|
|
797
|
+
- Linux and Windows compatibility
|
|
798
|
+
- Self-update mechanism
|
|
799
|
+
- Local template caching
|
|
800
|
+
- Shell completion scripts
|
|
801
|
+
|
|
802
|
+
### Technical Debt
|
|
803
|
+
- Add integration tests with Octokit mocking
|
|
804
|
+
- Add E2E tests for full command flows
|
|
805
|
+
- Complete JSDoc for all public APIs
|
|
806
|
+
- Add coverage reporting (c8/istanbul)
|
|
807
|
+
- Add CI/CD pipeline
|
|
808
|
+
|
|
809
|
+
### Performance Optimizations
|
|
810
|
+
- Parallel downloads (if multiple assets)
|
|
811
|
+
- Resume support for interrupted downloads
|
|
812
|
+
- Incremental updates (only download changed files)
|
|
813
|
+
- Better caching strategies
|
|
814
|
+
|
|
815
|
+
---
|
|
816
|
+
|
|
817
|
+
**Document Version:** 1.0
|
|
818
|
+
**Last Updated:** 2025-10-08
|
|
819
|
+
**Lines of Code:** 1,438 (production) + 850 (tests)
|
|
820
|
+
**Status:** Production Ready
|
|
821
|
+
**Next Review:** 2025-11-08
|