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.
Files changed (137) hide show
  1. package/.claude/agents/brainstormer.md +96 -0
  2. package/.claude/agents/code-reviewer.md +141 -0
  3. package/.claude/agents/copywriter.md +108 -0
  4. package/.claude/agents/database-admin.md +86 -0
  5. package/.claude/agents/debugger.md +124 -0
  6. package/.claude/agents/docs-manager.md +115 -0
  7. package/.claude/agents/git-manager.md +60 -0
  8. package/.claude/agents/journal-writer.md +111 -0
  9. package/.claude/agents/planner.md +87 -0
  10. package/.claude/agents/project-manager.md +113 -0
  11. package/.claude/agents/researcher.md +173 -0
  12. package/.claude/agents/scout.md +123 -0
  13. package/.claude/agents/tester.md +95 -0
  14. package/.claude/agents/ui-ux-designer.md +206 -0
  15. package/.claude/commands/bootstrap.md +104 -0
  16. package/.claude/commands/brainstorm.md +67 -0
  17. package/.claude/commands/content/enhance.md +13 -0
  18. package/.claude/commands/content/fast.md +11 -0
  19. package/.claude/commands/content/good.md +13 -0
  20. package/.claude/commands/cook.md +19 -0
  21. package/.claude/commands/debug.md +10 -0
  22. package/.claude/commands/design/3d.md +65 -0
  23. package/.claude/commands/design/describe.md +13 -0
  24. package/.claude/commands/design/fast.md +19 -0
  25. package/.claude/commands/design/good.md +23 -0
  26. package/.claude/commands/design/screenshot.md +23 -0
  27. package/.claude/commands/design/video.md +23 -0
  28. package/.claude/commands/docs/init.md +13 -0
  29. package/.claude/commands/docs/summarize.md +10 -0
  30. package/.claude/commands/docs/update.md +21 -0
  31. package/.claude/commands/fix/ci.md +11 -0
  32. package/.claude/commands/fix/fast.md +12 -0
  33. package/.claude/commands/fix/hard.md +18 -0
  34. package/.claude/commands/fix/logs.md +16 -0
  35. package/.claude/commands/fix/test.md +18 -0
  36. package/.claude/commands/fix/types.md +10 -0
  37. package/.claude/commands/git/cm.md +5 -0
  38. package/.claude/commands/git/cp.md +4 -0
  39. package/.claude/commands/integrate/polar.md +42 -0
  40. package/.claude/commands/plan/ci.md +12 -0
  41. package/.claude/commands/plan/two.md +13 -0
  42. package/.claude/commands/plan.md +10 -0
  43. package/.claude/commands/scout.md +29 -0
  44. package/.claude/commands/test.md +7 -0
  45. package/.claude/commands/watzup.md +8 -0
  46. package/.claude/hooks/telegram_notify.sh +136 -0
  47. package/.claude/send-discord.sh +64 -0
  48. package/.claude/settings.json +7 -0
  49. package/.claude/statusline.sh +143 -0
  50. package/.claude/workflows/development-rules.md +80 -0
  51. package/.claude/workflows/documentation-management.md +28 -0
  52. package/.claude/workflows/orchestration-protocol.md +16 -0
  53. package/.claude/workflows/primary-workflow.md +41 -0
  54. package/.github/workflows/ci.yml +43 -0
  55. package/.github/workflows/release.yml +58 -0
  56. package/.opencode/agent/code-reviewer.md +141 -0
  57. package/.opencode/agent/debugger.md +74 -0
  58. package/.opencode/agent/docs-manager.md +119 -0
  59. package/.opencode/agent/git-manager.md +60 -0
  60. package/.opencode/agent/planner-researcher.md +100 -0
  61. package/.opencode/agent/planner.md +87 -0
  62. package/.opencode/agent/project-manager.md +113 -0
  63. package/.opencode/agent/researcher.md +173 -0
  64. package/.opencode/agent/solution-brainstormer.md +89 -0
  65. package/.opencode/agent/system-architecture.md +192 -0
  66. package/.opencode/agent/tester.md +96 -0
  67. package/.opencode/agent/ui-ux-designer.md +203 -0
  68. package/.opencode/agent/ui-ux-developer.md +97 -0
  69. package/.opencode/command/cook.md +7 -0
  70. package/.opencode/command/debug.md +10 -0
  71. package/.opencode/command/design/3d.md +65 -0
  72. package/.opencode/command/design/fast.md +18 -0
  73. package/.opencode/command/design/good.md +21 -0
  74. package/.opencode/command/design/screenshot.md +22 -0
  75. package/.opencode/command/design/video.md +22 -0
  76. package/.opencode/command/docs/init.md +11 -0
  77. package/.opencode/command/docs/summarize.md +10 -0
  78. package/.opencode/command/docs/update.md +18 -0
  79. package/.opencode/command/fix/ci.md +8 -0
  80. package/.opencode/command/fix/fast.md +11 -0
  81. package/.opencode/command/fix/hard.md +15 -0
  82. package/.opencode/command/fix/logs.md +16 -0
  83. package/.opencode/command/fix/test.md +18 -0
  84. package/.opencode/command/fix/types.md +10 -0
  85. package/.opencode/command/git/cm.md +5 -0
  86. package/.opencode/command/git/cp.md +4 -0
  87. package/.opencode/command/plan/ci.md +12 -0
  88. package/.opencode/command/plan/two.md +13 -0
  89. package/.opencode/command/plan.md +10 -0
  90. package/.opencode/command/test.md +7 -0
  91. package/.opencode/command/watzup.md +8 -0
  92. package/.releaserc.json +17 -0
  93. package/.repomixignore +15 -0
  94. package/AGENTS.md +217 -0
  95. package/CHANGELOG.md +16 -0
  96. package/CLAUDE.md +33 -0
  97. package/README.md +214 -0
  98. package/biome.json +25 -0
  99. package/bun.lock +1238 -0
  100. package/dist/index.js +19100 -0
  101. package/docs/code-standards.md +1128 -0
  102. package/docs/codebase-summary.md +821 -0
  103. package/docs/github-setup.md +176 -0
  104. package/docs/project-pdr.md +739 -0
  105. package/docs/system-architecture.md +950 -0
  106. package/docs/tech-stack.md +290 -0
  107. package/package.json +60 -0
  108. package/plans/251008-claudekit-cli-implementation-plan.md +1469 -0
  109. package/plans/reports/251008-from-code-reviewer-to-developer-review-report.md +864 -0
  110. package/plans/reports/251008-from-tester-to-developer-test-summary-report.md +409 -0
  111. package/plans/reports/251008-researcher-download-extraction-report.md +1377 -0
  112. package/plans/reports/251008-researcher-github-api-report.md +1339 -0
  113. package/plans/research/251008-cli-frameworks-bun-research.md +1051 -0
  114. package/plans/templates/bug-fix-template.md +69 -0
  115. package/plans/templates/feature-implementation-template.md +84 -0
  116. package/plans/templates/refactor-template.md +82 -0
  117. package/plans/templates/template-usage-guide.md +58 -0
  118. package/src/commands/new.ts +118 -0
  119. package/src/commands/update.ts +114 -0
  120. package/src/index.ts +44 -0
  121. package/src/lib/auth.ts +157 -0
  122. package/src/lib/download.ts +180 -0
  123. package/src/lib/github.ts +157 -0
  124. package/src/lib/merge.ts +116 -0
  125. package/src/lib/prompts.ts +113 -0
  126. package/src/types.ts +149 -0
  127. package/src/utils/config.ts +87 -0
  128. package/src/utils/logger.ts +37 -0
  129. package/tests/lib/auth.test.ts +116 -0
  130. package/tests/lib/download.test.ts +70 -0
  131. package/tests/lib/github.test.ts +52 -0
  132. package/tests/lib/merge.test.ts +138 -0
  133. package/tests/lib/prompts.test.ts +66 -0
  134. package/tests/types.test.ts +255 -0
  135. package/tests/utils/config.test.ts +263 -0
  136. package/tests/utils/logger.test.ts +124 -0
  137. package/tsconfig.json +30 -0
@@ -0,0 +1,263 @@
1
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2
+ import { existsSync } from "node:fs";
3
+ import { mkdir, rm, writeFile } from "node:fs/promises";
4
+ import { homedir } from "node:os";
5
+ import { join } from "node:path";
6
+ import type { Config } from "../../src/types.js";
7
+ import { ConfigManager } from "../../src/utils/config.js";
8
+
9
+ const TEST_CONFIG_DIR = join(homedir(), ".claudekit-test");
10
+ const TEST_CONFIG_FILE = join(TEST_CONFIG_DIR, "config.json");
11
+
12
+ describe("ConfigManager", () => {
13
+ beforeEach(async () => {
14
+ // Create test config directory
15
+ if (!existsSync(TEST_CONFIG_DIR)) {
16
+ await mkdir(TEST_CONFIG_DIR, { recursive: true });
17
+ }
18
+
19
+ // Override config paths for testing
20
+ // Note: This is a simplified test - in production we'd need to mock the paths
21
+ });
22
+
23
+ afterEach(async () => {
24
+ // Clean up test config directory
25
+ if (existsSync(TEST_CONFIG_DIR)) {
26
+ await rm(TEST_CONFIG_DIR, { recursive: true, force: true });
27
+ }
28
+
29
+ // Reset ConfigManager state
30
+ (ConfigManager as any).config = null;
31
+ });
32
+
33
+ describe("load", () => {
34
+ test("should return default config when no config file exists", async () => {
35
+ const config = await ConfigManager.load();
36
+ expect(config).toEqual({ github: {}, defaults: {} });
37
+ });
38
+
39
+ test("should load config from file when it exists", async () => {
40
+ const testConfig: Config = {
41
+ github: { token: "test-token" },
42
+ defaults: { kit: "engineer", dir: "./test" },
43
+ };
44
+
45
+ // Write test config file (to actual location for this test)
46
+ const actualConfigDir = join(homedir(), ".claudekit");
47
+ const actualConfigFile = join(actualConfigDir, "config.json");
48
+
49
+ if (!existsSync(actualConfigDir)) {
50
+ await mkdir(actualConfigDir, { recursive: true });
51
+ }
52
+ await writeFile(actualConfigFile, JSON.stringify(testConfig));
53
+
54
+ try {
55
+ const config = await ConfigManager.load();
56
+ expect(config.github?.token).toBe("test-token");
57
+ expect(config.defaults?.kit).toBe("engineer");
58
+ } finally {
59
+ // Cleanup
60
+ if (existsSync(actualConfigFile)) {
61
+ await rm(actualConfigFile);
62
+ }
63
+ }
64
+ });
65
+
66
+ test("should return default config on invalid JSON", async () => {
67
+ const actualConfigDir = join(homedir(), ".claudekit");
68
+ const actualConfigFile = join(actualConfigDir, "config.json");
69
+
70
+ if (!existsSync(actualConfigDir)) {
71
+ await mkdir(actualConfigDir, { recursive: true });
72
+ }
73
+ await writeFile(actualConfigFile, "invalid json");
74
+
75
+ try {
76
+ const config = await ConfigManager.load();
77
+ expect(config).toEqual({ github: {}, defaults: {} });
78
+ } finally {
79
+ // Cleanup
80
+ if (existsSync(actualConfigFile)) {
81
+ await rm(actualConfigFile);
82
+ }
83
+ }
84
+ });
85
+
86
+ test("should cache config after first load", async () => {
87
+ const config1 = await ConfigManager.load();
88
+ const config2 = await ConfigManager.load();
89
+ expect(config1).toBe(config2); // Same reference
90
+ });
91
+ });
92
+
93
+ describe("save", () => {
94
+ test("should save valid config to file", async () => {
95
+ const testConfig: Config = {
96
+ github: { token: "test-token" },
97
+ defaults: { kit: "marketing", dir: "./projects" },
98
+ };
99
+
100
+ await ConfigManager.save(testConfig);
101
+
102
+ // Verify file was created
103
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
104
+ expect(existsSync(actualConfigFile)).toBe(true);
105
+
106
+ // Cleanup
107
+ if (existsSync(actualConfigFile)) {
108
+ await rm(actualConfigFile);
109
+ }
110
+ const actualConfigDir = join(homedir(), ".claudekit");
111
+ if (existsSync(actualConfigDir)) {
112
+ await rm(actualConfigDir, { recursive: true });
113
+ }
114
+ });
115
+
116
+ test("should create config directory if it does not exist", async () => {
117
+ const actualConfigDir = join(homedir(), ".claudekit");
118
+ if (existsSync(actualConfigDir)) {
119
+ await rm(actualConfigDir, { recursive: true });
120
+ }
121
+
122
+ const testConfig: Config = { github: {}, defaults: {} };
123
+ await ConfigManager.save(testConfig);
124
+
125
+ expect(existsSync(actualConfigDir)).toBe(true);
126
+
127
+ // Cleanup
128
+ if (existsSync(actualConfigDir)) {
129
+ await rm(actualConfigDir, { recursive: true });
130
+ }
131
+ });
132
+
133
+ test("should throw error on invalid config", async () => {
134
+ const invalidConfig = {
135
+ github: { token: 123 }, // Invalid: should be string
136
+ };
137
+
138
+ await expect(ConfigManager.save(invalidConfig as any)).rejects.toThrow();
139
+ });
140
+
141
+ test("should update cached config", async () => {
142
+ const testConfig: Config = {
143
+ github: { token: "new-token" },
144
+ defaults: {},
145
+ };
146
+
147
+ await ConfigManager.save(testConfig);
148
+ const loaded = await ConfigManager.get();
149
+ expect(loaded.github?.token).toBe("new-token");
150
+
151
+ // Cleanup
152
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
153
+ const actualConfigDir = join(homedir(), ".claudekit");
154
+ if (existsSync(actualConfigFile)) {
155
+ await rm(actualConfigFile);
156
+ }
157
+ if (existsSync(actualConfigDir)) {
158
+ await rm(actualConfigDir, { recursive: true });
159
+ }
160
+ });
161
+ });
162
+
163
+ describe("get", () => {
164
+ test("should return current config", async () => {
165
+ const config = await ConfigManager.get();
166
+ expect(config).toBeDefined();
167
+ expect(config).toHaveProperty("github");
168
+ expect(config).toHaveProperty("defaults");
169
+ });
170
+ });
171
+
172
+ describe("set", () => {
173
+ test("should set nested config value", async () => {
174
+ await ConfigManager.set("github.token", "test-token-123");
175
+ const config = await ConfigManager.get();
176
+ expect(config.github?.token).toBe("test-token-123");
177
+
178
+ // Cleanup
179
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
180
+ const actualConfigDir = join(homedir(), ".claudekit");
181
+ if (existsSync(actualConfigFile)) {
182
+ await rm(actualConfigFile);
183
+ }
184
+ if (existsSync(actualConfigDir)) {
185
+ await rm(actualConfigDir, { recursive: true });
186
+ }
187
+ });
188
+
189
+ test("should create nested objects if they do not exist", async () => {
190
+ await ConfigManager.set("defaults.kit", "engineer");
191
+ const config = await ConfigManager.get();
192
+ expect(config.defaults?.kit).toBe("engineer");
193
+
194
+ // Cleanup
195
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
196
+ const actualConfigDir = join(homedir(), ".claudekit");
197
+ if (existsSync(actualConfigFile)) {
198
+ await rm(actualConfigFile);
199
+ }
200
+ if (existsSync(actualConfigDir)) {
201
+ await rm(actualConfigDir, { recursive: true });
202
+ }
203
+ });
204
+
205
+ test("should handle multiple nested levels", async () => {
206
+ await ConfigManager.set("defaults.dir", "/test/path");
207
+ const config = await ConfigManager.get();
208
+ expect(config.defaults?.dir).toBe("/test/path");
209
+
210
+ // Cleanup
211
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
212
+ const actualConfigDir = join(homedir(), ".claudekit");
213
+ if (existsSync(actualConfigFile)) {
214
+ await rm(actualConfigFile);
215
+ }
216
+ if (existsSync(actualConfigDir)) {
217
+ await rm(actualConfigDir, { recursive: true });
218
+ }
219
+ });
220
+ });
221
+
222
+ describe("getToken", () => {
223
+ test("should return token from config", async () => {
224
+ await ConfigManager.setToken("test-token-456");
225
+ const token = await ConfigManager.getToken();
226
+ expect(token).toBe("test-token-456");
227
+
228
+ // Cleanup
229
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
230
+ const actualConfigDir = join(homedir(), ".claudekit");
231
+ if (existsSync(actualConfigFile)) {
232
+ await rm(actualConfigFile);
233
+ }
234
+ if (existsSync(actualConfigDir)) {
235
+ await rm(actualConfigDir, { recursive: true });
236
+ }
237
+ });
238
+
239
+ test("should return undefined if no token is set", async () => {
240
+ (ConfigManager as any).config = null;
241
+ const token = await ConfigManager.getToken();
242
+ expect(token).toBeUndefined();
243
+ });
244
+ });
245
+
246
+ describe("setToken", () => {
247
+ test("should set token in config", async () => {
248
+ await ConfigManager.setToken("new-test-token");
249
+ const config = await ConfigManager.get();
250
+ expect(config.github?.token).toBe("new-test-token");
251
+
252
+ // Cleanup
253
+ const actualConfigFile = join(homedir(), ".claudekit", "config.json");
254
+ const actualConfigDir = join(homedir(), ".claudekit");
255
+ if (existsSync(actualConfigFile)) {
256
+ await rm(actualConfigFile);
257
+ }
258
+ if (existsSync(actualConfigDir)) {
259
+ await rm(actualConfigDir, { recursive: true });
260
+ }
261
+ });
262
+ });
263
+ });
@@ -0,0 +1,124 @@
1
+ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
2
+ import { logger } from "../../src/utils/logger.js";
3
+
4
+ describe("Logger Utilities", () => {
5
+ let consoleLogSpy: any;
6
+ let consoleErrorSpy: any;
7
+ const originalDebug = process.env.DEBUG;
8
+
9
+ beforeEach(() => {
10
+ consoleLogSpy = mock(() => {});
11
+ consoleErrorSpy = mock(() => {});
12
+ console.log = consoleLogSpy;
13
+ console.error = consoleErrorSpy;
14
+ });
15
+
16
+ afterEach(() => {
17
+ process.env.DEBUG = originalDebug;
18
+ consoleLogSpy.mockRestore?.();
19
+ consoleErrorSpy.mockRestore?.();
20
+ });
21
+
22
+ describe("info", () => {
23
+ test("should log info messages", () => {
24
+ logger.info("Test info message");
25
+ expect(consoleLogSpy).toHaveBeenCalled();
26
+ });
27
+ });
28
+
29
+ describe("success", () => {
30
+ test("should log success messages", () => {
31
+ logger.success("Test success message");
32
+ expect(consoleLogSpy).toHaveBeenCalled();
33
+ });
34
+ });
35
+
36
+ describe("warning", () => {
37
+ test("should log warning messages", () => {
38
+ logger.warning("Test warning message");
39
+ expect(consoleLogSpy).toHaveBeenCalled();
40
+ });
41
+ });
42
+
43
+ describe("error", () => {
44
+ test("should log error messages", () => {
45
+ logger.error("Test error message");
46
+ expect(consoleErrorSpy).toHaveBeenCalled();
47
+ });
48
+ });
49
+
50
+ describe("debug", () => {
51
+ test("should log debug messages when DEBUG is set", () => {
52
+ process.env.DEBUG = "true";
53
+ logger.debug("Test debug message");
54
+ expect(consoleLogSpy).toHaveBeenCalled();
55
+ });
56
+
57
+ test("should not log debug messages when DEBUG is not set", () => {
58
+ process.env.DEBUG = undefined;
59
+ logger.debug("Test debug message");
60
+ expect(consoleLogSpy).not.toHaveBeenCalled();
61
+ });
62
+ });
63
+
64
+ describe("sanitize", () => {
65
+ test("should sanitize ghp_ tokens (36 chars)", () => {
66
+ const text = "Token: ghp_123456789012345678901234567890123456";
67
+ const sanitized = logger.sanitize(text);
68
+ expect(sanitized).toBe("Token: ghp_***");
69
+ });
70
+
71
+ test("should sanitize github_pat_ tokens (82 chars)", () => {
72
+ // github_pat_ prefix + 82 alphanumeric/underscore characters (exact length)
73
+ const token =
74
+ "1234567890123456789012345678901234567890123456789012345678901234567890123456789012";
75
+ const text = `Token: github_pat_${token}`;
76
+ const sanitized = logger.sanitize(text);
77
+ expect(sanitized).toBe("Token: github_pat_***");
78
+ });
79
+
80
+ test("should sanitize gho_ tokens (36 chars)", () => {
81
+ const text = "Token: gho_123456789012345678901234567890123456";
82
+ const sanitized = logger.sanitize(text);
83
+ expect(sanitized).toBe("Token: gho_***");
84
+ });
85
+
86
+ test("should sanitize ghu_ tokens (36 chars)", () => {
87
+ const text = "Token: ghu_123456789012345678901234567890123456";
88
+ const sanitized = logger.sanitize(text);
89
+ expect(sanitized).toBe("Token: ghu_***");
90
+ });
91
+
92
+ test("should sanitize ghs_ tokens (36 chars)", () => {
93
+ const text = "Token: ghs_123456789012345678901234567890123456";
94
+ const sanitized = logger.sanitize(text);
95
+ expect(sanitized).toBe("Token: ghs_***");
96
+ });
97
+
98
+ test("should sanitize ghr_ tokens (36 chars)", () => {
99
+ const text = "Token: ghr_123456789012345678901234567890123456";
100
+ const sanitized = logger.sanitize(text);
101
+ expect(sanitized).toBe("Token: ghr_***");
102
+ });
103
+
104
+ test("should sanitize multiple tokens", () => {
105
+ const ghpToken = "123456789012345678901234567890123456";
106
+ const patToken =
107
+ "1234567890123456789012345678901234567890123456789012345678901234567890123456789012";
108
+ const text = `Tokens: ghp_${ghpToken} and github_pat_${patToken}`;
109
+ const sanitized = logger.sanitize(text);
110
+ expect(sanitized).toBe("Tokens: ghp_*** and github_pat_***");
111
+ });
112
+
113
+ test("should not modify text without tokens", () => {
114
+ const text = "No tokens here, just regular text";
115
+ const sanitized = logger.sanitize(text);
116
+ expect(sanitized).toBe(text);
117
+ });
118
+
119
+ test("should handle empty string", () => {
120
+ const sanitized = logger.sanitize("");
121
+ expect(sanitized).toBe("");
122
+ });
123
+ });
124
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "lib": ["ES2022"],
6
+ "moduleResolution": "bundler",
7
+ "types": ["bun-types"],
8
+
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "allowSyntheticDefaultImports": true,
15
+
16
+ "declaration": true,
17
+ "declarationMap": true,
18
+ "sourceMap": true,
19
+
20
+ "outDir": "./dist",
21
+ "rootDir": "./src",
22
+
23
+ "noUnusedLocals": true,
24
+ "noUnusedParameters": true,
25
+ "noImplicitReturns": true,
26
+ "noFallthroughCasesInSwitch": true
27
+ },
28
+ "include": ["src/**/*"],
29
+ "exclude": ["node_modules", "dist", "bin"]
30
+ }