ccjk 13.6.2 → 13.6.4

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.
@@ -0,0 +1,444 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { rm, mkdir, copyFile } from 'node:fs/promises';
3
+ import { fileURLToPath } from 'node:url';
4
+ import a from '../chunks/index5.mjs';
5
+ import { i as inquirer } from '../chunks/index6.mjs';
6
+ import { ensureI18nInitialized, i18n } from '../chunks/index2.mjs';
7
+ import { CLAUDE_DIR } from '../chunks/constants.mjs';
8
+ import { j as join, d as dirname } from './ccjk.bQ7Dh1g4.mjs';
9
+
10
+ const WORKFLOW_CONFIG_BASE = [
11
+ {
12
+ id: "interviewWorkflow",
13
+ defaultSelected: true,
14
+ order: 1,
15
+ commands: ["interview.md"],
16
+ agents: [],
17
+ autoInstallAgents: false,
18
+ category: "interview",
19
+ displayCategory: "planning",
20
+ outputDir: "interview",
21
+ metadata: {
22
+ version: "1.0.0",
23
+ addedDate: "2025-01",
24
+ tags: ["recommended", "popular"],
25
+ difficulty: "beginner"
26
+ }
27
+ },
28
+ {
29
+ id: "essentialTools",
30
+ defaultSelected: true,
31
+ order: 2,
32
+ commands: ["init-project.md", "feat.md"],
33
+ agents: [
34
+ { id: "init-architect", filename: "init-architect.md", required: true },
35
+ { id: "get-current-datetime", filename: "get-current-datetime.md", required: true },
36
+ { id: "planner", filename: "planner.md", required: true },
37
+ { id: "ui-ux-designer", filename: "ui-ux-designer.md", required: true }
38
+ ],
39
+ autoInstallAgents: true,
40
+ category: "essential",
41
+ displayCategory: "planning",
42
+ outputDir: "essential",
43
+ metadata: {
44
+ version: "1.0.0",
45
+ addedDate: "2025-01",
46
+ tags: ["essential"],
47
+ difficulty: "beginner"
48
+ }
49
+ },
50
+ {
51
+ id: "gitWorkflow",
52
+ defaultSelected: true,
53
+ order: 3,
54
+ commands: ["git-commit.md", "git-rollback.md", "git-cleanBranches.md", "git-worktree.md"],
55
+ agents: [],
56
+ autoInstallAgents: false,
57
+ category: "git",
58
+ displayCategory: "versionControl",
59
+ outputDir: "git",
60
+ metadata: {
61
+ version: "1.0.0",
62
+ addedDate: "2025-01",
63
+ tags: ["popular"],
64
+ difficulty: "beginner"
65
+ }
66
+ },
67
+ {
68
+ id: "sixStepsWorkflow",
69
+ defaultSelected: false,
70
+ order: 4,
71
+ commands: ["workflow.md"],
72
+ agents: [],
73
+ autoInstallAgents: false,
74
+ category: "sixStep",
75
+ displayCategory: "development",
76
+ outputDir: "workflow",
77
+ metadata: {
78
+ version: "1.0.0",
79
+ addedDate: "2025-01",
80
+ tags: ["professional"],
81
+ difficulty: "intermediate"
82
+ }
83
+ },
84
+ {
85
+ id: "specFirstTDD",
86
+ defaultSelected: false,
87
+ order: 5,
88
+ commands: ["spec-first-tdd.md"],
89
+ agents: [],
90
+ autoInstallAgents: false,
91
+ category: "specFirstTDD",
92
+ displayCategory: "quality",
93
+ outputDir: "spec-first-tdd",
94
+ metadata: {
95
+ version: "1.0.0",
96
+ addedDate: "2025-02",
97
+ tags: ["professional", "new"],
98
+ difficulty: "advanced"
99
+ }
100
+ },
101
+ {
102
+ id: "continuousDelivery",
103
+ defaultSelected: false,
104
+ order: 6,
105
+ commands: ["continuous-delivery.md"],
106
+ agents: [],
107
+ autoInstallAgents: false,
108
+ category: "continuousDelivery",
109
+ displayCategory: "quality",
110
+ outputDir: "continuous-delivery",
111
+ metadata: {
112
+ version: "1.0.0",
113
+ addedDate: "2025-02",
114
+ tags: ["professional", "new"],
115
+ difficulty: "advanced"
116
+ }
117
+ },
118
+ {
119
+ id: "refactoringMaster",
120
+ defaultSelected: false,
121
+ order: 7,
122
+ commands: ["refactoring-master.md"],
123
+ agents: [],
124
+ autoInstallAgents: false,
125
+ category: "refactoringMaster",
126
+ displayCategory: "quality",
127
+ outputDir: "refactoring-master",
128
+ metadata: {
129
+ version: "1.0.0",
130
+ addedDate: "2025-02",
131
+ tags: ["professional", "new"],
132
+ difficulty: "advanced"
133
+ }
134
+ },
135
+ {
136
+ id: "linearMethod",
137
+ defaultSelected: false,
138
+ order: 8,
139
+ commands: ["linear-method.md"],
140
+ agents: [],
141
+ autoInstallAgents: false,
142
+ category: "linearMethod",
143
+ displayCategory: "planning",
144
+ outputDir: "linear-method",
145
+ metadata: {
146
+ version: "1.0.0",
147
+ addedDate: "2025-02",
148
+ tags: ["new"],
149
+ difficulty: "intermediate"
150
+ }
151
+ }
152
+ ];
153
+ function getWorkflowConfigs() {
154
+ ensureI18nInitialized();
155
+ const workflowTranslations = [
156
+ {
157
+ id: "interviewWorkflow",
158
+ name: i18n.t("workflow:workflowOption.interviewWorkflow"),
159
+ description: i18n.t("workflow:workflowDescription.interviewWorkflow"),
160
+ stats: i18n.t("workflow:workflowStats.interviewWorkflow")
161
+ },
162
+ {
163
+ id: "essentialTools",
164
+ name: i18n.t("workflow:workflowOption.essentialTools"),
165
+ description: i18n.t("workflow:workflowDescription.essentialTools"),
166
+ stats: i18n.t("workflow:workflowStats.essentialTools")
167
+ },
168
+ {
169
+ id: "gitWorkflow",
170
+ name: i18n.t("workflow:workflowOption.gitWorkflow"),
171
+ description: i18n.t("workflow:workflowDescription.gitWorkflow"),
172
+ stats: i18n.t("workflow:workflowStats.gitWorkflow")
173
+ },
174
+ {
175
+ id: "sixStepsWorkflow",
176
+ name: i18n.t("workflow:workflowOption.sixStepsWorkflow"),
177
+ description: i18n.t("workflow:workflowDescription.sixStepsWorkflow"),
178
+ stats: i18n.t("workflow:workflowStats.sixStepsWorkflow")
179
+ },
180
+ {
181
+ id: "specFirstTDD",
182
+ name: i18n.t("workflow:workflowOption.specFirstTDD"),
183
+ description: i18n.t("workflow:workflowDescription.specFirstTDD"),
184
+ stats: i18n.t("workflow:workflowStats.specFirstTDD")
185
+ },
186
+ {
187
+ id: "continuousDelivery",
188
+ name: i18n.t("workflow:workflowOption.continuousDelivery"),
189
+ description: i18n.t("workflow:workflowDescription.continuousDelivery"),
190
+ stats: i18n.t("workflow:workflowStats.continuousDelivery")
191
+ },
192
+ {
193
+ id: "refactoringMaster",
194
+ name: i18n.t("workflow:workflowOption.refactoringMaster"),
195
+ description: i18n.t("workflow:workflowDescription.refactoringMaster"),
196
+ stats: i18n.t("workflow:workflowStats.refactoringMaster")
197
+ },
198
+ {
199
+ id: "linearMethod",
200
+ name: i18n.t("workflow:workflowOption.linearMethod"),
201
+ description: i18n.t("workflow:workflowDescription.linearMethod"),
202
+ stats: i18n.t("workflow:workflowStats.linearMethod")
203
+ }
204
+ ];
205
+ return WORKFLOW_CONFIG_BASE.map((baseConfig) => {
206
+ const translation = workflowTranslations.find((t) => t.id === baseConfig.id);
207
+ return {
208
+ ...baseConfig,
209
+ name: translation?.name || baseConfig.id,
210
+ description: translation?.description,
211
+ stats: translation?.stats
212
+ };
213
+ });
214
+ }
215
+ function getWorkflowConfig(workflowId) {
216
+ return getWorkflowConfigs().find((config) => config.id === workflowId);
217
+ }
218
+ function getOrderedWorkflows() {
219
+ return getWorkflowConfigs().sort((a, b) => a.order - b.order);
220
+ }
221
+ function getTagLabel(tag) {
222
+ ensureI18nInitialized();
223
+ const tagKeys = {
224
+ recommended: "workflow:tags.recommended",
225
+ popular: "workflow:tags.popular",
226
+ new: "workflow:tags.new",
227
+ essential: "workflow:tags.essential",
228
+ professional: "workflow:tags.professional"
229
+ };
230
+ return i18n.t(tagKeys[tag]);
231
+ }
232
+
233
+ function getRootDir() {
234
+ const currentFilePath = fileURLToPath(import.meta.url);
235
+ const distDir = dirname(dirname(currentFilePath));
236
+ return dirname(distDir);
237
+ }
238
+ const DEFAULT_CODE_TOOL_TEMPLATE = "claude-code";
239
+ const COMMON_TEMPLATE_CATEGORIES = ["git", "sixStep", "essential", "interview", "specFirstTDD", "continuousDelivery", "refactoringMaster", "linearMethod"];
240
+ function formatTags(tags) {
241
+ const tagColors = {
242
+ recommended: (text) => a.bgGreen.black(` ${text} `),
243
+ popular: (text) => a.bgYellow.black(` ${text} `),
244
+ new: (text) => a.bgCyan.black(` ${text} `),
245
+ essential: (text) => a.bgBlue.white(` ${text} `),
246
+ professional: (text) => a.bgMagenta.white(` ${text} `)
247
+ };
248
+ return tags.map((tag) => tagColors[tag](getTagLabel(tag))).join(" ");
249
+ }
250
+ function buildWorkflowChoice(workflow) {
251
+ const tags = formatTags(workflow.metadata.tags);
252
+ const stats = workflow.stats ? a.dim(workflow.stats) : "";
253
+ const description = workflow.description ? a.gray(workflow.description) : "";
254
+ const nameLine = `${workflow.name} ${tags}`;
255
+ const detailLine = stats ? ` ${stats}` : "";
256
+ const descLine = description ? ` ${description}` : "";
257
+ const displayName = [nameLine, detailLine, descLine].filter(Boolean).join("\n");
258
+ return {
259
+ name: displayName,
260
+ value: workflow.id,
261
+ checked: workflow.defaultSelected
262
+ };
263
+ }
264
+ async function selectAndInstallWorkflows(configLang, preselectedWorkflows) {
265
+ ensureI18nInitialized();
266
+ const workflows = getOrderedWorkflows();
267
+ const choices = workflows.map((workflow) => buildWorkflowChoice(workflow));
268
+ let selectedWorkflows;
269
+ if (preselectedWorkflows) {
270
+ selectedWorkflows = preselectedWorkflows;
271
+ } else {
272
+ console.log("");
273
+ console.log(a.bold.cyan("\u2501".repeat(60)));
274
+ console.log(a.bold.white(` \u{1F680} ${i18n.t("workflow:selectWorkflowType")}`));
275
+ console.log(a.bold.cyan("\u2501".repeat(60)));
276
+ console.log("");
277
+ const response = await inquirer.prompt({
278
+ type: "checkbox",
279
+ name: "selectedWorkflows",
280
+ message: i18n.t("common:multiSelectHint"),
281
+ choices,
282
+ pageSize: 15
283
+ });
284
+ selectedWorkflows = response.selectedWorkflows;
285
+ }
286
+ if (!selectedWorkflows || selectedWorkflows.length === 0) {
287
+ console.log(a.yellow(i18n.t("common:cancelled")));
288
+ return;
289
+ }
290
+ await cleanupOldVersionFiles();
291
+ for (const workflowId of selectedWorkflows) {
292
+ const config = getWorkflowConfig(workflowId);
293
+ if (config) {
294
+ await installWorkflowWithDependencies(config, configLang);
295
+ }
296
+ }
297
+ }
298
+ async function installWorkflowWithDependencies(config, configLang) {
299
+ const rootDir = getRootDir();
300
+ ensureI18nInitialized();
301
+ const result = {
302
+ workflow: config.id,
303
+ success: true,
304
+ installedCommands: [],
305
+ installedAgents: [],
306
+ errors: []
307
+ };
308
+ const WORKFLOW_OPTION_KEYS = {
309
+ essentialTools: i18n.t("workflow:workflowOption.essentialTools"),
310
+ sixStepsWorkflow: i18n.t("workflow:workflowOption.sixStepsWorkflow"),
311
+ gitWorkflow: i18n.t("workflow:workflowOption.gitWorkflow"),
312
+ interviewWorkflow: i18n.t("workflow:workflowOption.interviewWorkflow"),
313
+ specFirstTDD: i18n.t("workflow:workflowOption.specFirstTDD"),
314
+ continuousDelivery: i18n.t("workflow:workflowOption.continuousDelivery"),
315
+ refactoringMaster: i18n.t("workflow:workflowOption.refactoringMaster"),
316
+ linearMethod: i18n.t("workflow:workflowOption.linearMethod")
317
+ };
318
+ const workflowName = WORKFLOW_OPTION_KEYS[config.id] || config.id;
319
+ console.log(a.green(`
320
+ \u{1F4E6} ${i18n.t("workflow:installingWorkflow")}: ${workflowName}...`));
321
+ const commandsDir = join(CLAUDE_DIR, "commands", "ccjk");
322
+ if (!existsSync(commandsDir)) {
323
+ await mkdir(commandsDir, { recursive: true });
324
+ }
325
+ for (const commandFile of config.commands) {
326
+ const isCommonTemplate = COMMON_TEMPLATE_CATEGORIES.includes(config.category);
327
+ const commandSource = isCommonTemplate ? join(
328
+ rootDir,
329
+ "templates",
330
+ "common",
331
+ "workflow",
332
+ config.category,
333
+ configLang,
334
+ commandFile
335
+ ) : join(
336
+ rootDir,
337
+ "templates",
338
+ DEFAULT_CODE_TOOL_TEMPLATE,
339
+ configLang,
340
+ "workflow",
341
+ config.category,
342
+ "commands",
343
+ commandFile
344
+ );
345
+ const destFileName = commandFile;
346
+ const commandDest = join(commandsDir, destFileName);
347
+ if (existsSync(commandSource)) {
348
+ try {
349
+ await copyFile(commandSource, commandDest);
350
+ result.installedCommands.push(destFileName);
351
+ console.log(a.gray(` \u2714 ${i18n.t("workflow:installedCommand")}: ccjk/${destFileName}`));
352
+ } catch (error) {
353
+ const errorMsg = `${i18n.t("workflow:failedToInstallCommand")} ${commandFile}: ${error}`;
354
+ result.errors?.push(errorMsg);
355
+ console.error(a.red(` \u2717 ${errorMsg}`));
356
+ result.success = false;
357
+ }
358
+ }
359
+ }
360
+ if (config.autoInstallAgents && config.agents.length > 0) {
361
+ const agentsCategoryDir = join(CLAUDE_DIR, "agents", "ccjk", config.category);
362
+ if (!existsSync(agentsCategoryDir)) {
363
+ await mkdir(agentsCategoryDir, { recursive: true });
364
+ }
365
+ for (const agent of config.agents) {
366
+ const isCommonTemplate = COMMON_TEMPLATE_CATEGORIES.includes(config.category);
367
+ const agentSource = isCommonTemplate ? join(
368
+ rootDir,
369
+ "templates",
370
+ "common",
371
+ "workflow",
372
+ config.category,
373
+ configLang,
374
+ "agents",
375
+ agent.filename
376
+ ) : join(
377
+ rootDir,
378
+ "templates",
379
+ DEFAULT_CODE_TOOL_TEMPLATE,
380
+ configLang,
381
+ "workflow",
382
+ config.category,
383
+ "agents",
384
+ agent.filename
385
+ );
386
+ const agentDest = join(agentsCategoryDir, agent.filename);
387
+ if (existsSync(agentSource)) {
388
+ try {
389
+ await copyFile(agentSource, agentDest);
390
+ result.installedAgents.push(agent.filename);
391
+ console.log(a.gray(` \u2714 ${i18n.t("workflow:installedAgent")}: ccjk/${config.category}/${agent.filename}`));
392
+ } catch (error) {
393
+ const errorMsg = `${i18n.t("workflow:failedToInstallAgent")} ${agent.filename}: ${error}`;
394
+ result.errors?.push(errorMsg);
395
+ console.error(a.red(` \u2717 ${errorMsg}`));
396
+ if (agent.required) {
397
+ result.success = false;
398
+ }
399
+ }
400
+ }
401
+ }
402
+ }
403
+ if (result.success) {
404
+ console.log(a.green(`\u2714 ${workflowName} ${i18n.t("workflow:workflowInstallSuccess")}`));
405
+ } else {
406
+ console.log(a.red(`\u2717 ${workflowName} ${i18n.t("workflow:workflowInstallError")}`));
407
+ }
408
+ return result;
409
+ }
410
+ async function cleanupOldVersionFiles() {
411
+ ensureI18nInitialized();
412
+ console.log(a.green(`
413
+ \u{1F9F9} ${i18n.t("workflow:cleaningOldFiles")}...`));
414
+ const oldCommandFiles = [
415
+ join(CLAUDE_DIR, "commands", "workflow.md"),
416
+ join(CLAUDE_DIR, "commands", "feat.md")
417
+ ];
418
+ const oldAgentFiles = [
419
+ join(CLAUDE_DIR, "agents", "planner.md"),
420
+ join(CLAUDE_DIR, "agents", "ui-ux-designer.md")
421
+ ];
422
+ for (const file of oldCommandFiles) {
423
+ if (existsSync(file)) {
424
+ try {
425
+ await rm(file, { force: true });
426
+ console.log(a.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
427
+ } catch {
428
+ console.error(a.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
429
+ }
430
+ }
431
+ }
432
+ for (const file of oldAgentFiles) {
433
+ if (existsSync(file)) {
434
+ try {
435
+ await rm(file, { force: true });
436
+ console.log(a.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
437
+ } catch {
438
+ console.error(a.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
439
+ }
440
+ }
441
+ }
442
+ }
443
+
444
+ export { WORKFLOW_CONFIG_BASE as W, selectAndInstallWorkflows as s };