thanh-kit 2.5.11 → 2.5.12

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/dist/index.js CHANGED
@@ -142,12 +142,18 @@ function getCkInternalSource() {
142
142
  for (const basePath of CK_INTERNAL_PATHS) {
143
143
  const claudeDir = join(basePath, ".claude");
144
144
  if (existsSync(claudeDir) && existsSync(join(claudeDir, "skills"))) {
145
+ const agentsDir = join(basePath, ".agents");
145
146
  const agentsMd = join(basePath, "AGENTS.md");
147
+ const claudeMd = join(basePath, "CLAUDE.md");
148
+ const geminiMd = join(basePath, "GEMINI.md");
146
149
  return {
147
150
  path: basePath,
148
151
  type: "ck-internal",
149
152
  claudeDir,
150
- agentsMd: existsSync(agentsMd) ? agentsMd : null
153
+ agentsDir: existsSync(agentsDir) ? agentsDir : null,
154
+ agentsMd: existsSync(agentsMd) ? agentsMd : null,
155
+ claudeMd: existsSync(claudeMd) ? claudeMd : null,
156
+ geminiMd: existsSync(geminiMd) ? geminiMd : null
151
157
  };
152
158
  }
153
159
  }
@@ -155,12 +161,18 @@ function getCkInternalSource() {
155
161
  }
156
162
  function getEmbeddedTemplates() {
157
163
  if (existsSync(TEMPLATES_DIR)) {
164
+ const agentsDir = join(TEMPLATES_DIR, "..", ".agents");
158
165
  const agentsMd = join(TEMPLATES_DIR, "AGENTS.md");
166
+ const claudeMd = join(TEMPLATES_DIR, "CLAUDE.md");
167
+ const geminiMd = join(TEMPLATES_DIR, "GEMINI.md");
159
168
  return {
160
169
  path: TEMPLATES_DIR,
161
170
  type: "embedded",
162
171
  claudeDir: TEMPLATES_DIR,
163
- agentsMd: existsSync(agentsMd) ? agentsMd : null
172
+ agentsDir: existsSync(agentsDir) ? agentsDir : null,
173
+ agentsMd: existsSync(agentsMd) ? agentsMd : null,
174
+ claudeMd: existsSync(claudeMd) ? claudeMd : null,
175
+ geminiMd: existsSync(geminiMd) ? geminiMd : null
164
176
  };
165
177
  }
166
178
  return null;
@@ -193,12 +205,16 @@ function resolveSource(sourceFlag) {
193
205
  }
194
206
  const claudeDir = join(resolved, ".claude");
195
207
  const opencodeDir = join(resolved, ".opencode");
208
+ const agentsDir = join(resolved, ".agents");
196
209
  if (existsSync(claudeDir)) {
197
210
  return {
198
211
  path: resolved,
199
212
  type: "custom",
200
213
  claudeDir,
201
- agentsMd: existsSync(join(resolved, "AGENTS.md")) ? join(resolved, "AGENTS.md") : null
214
+ agentsDir: existsSync(agentsDir) ? agentsDir : null,
215
+ agentsMd: existsSync(join(resolved, "AGENTS.md")) ? join(resolved, "AGENTS.md") : null,
216
+ claudeMd: existsSync(join(resolved, "CLAUDE.md")) ? join(resolved, "CLAUDE.md") : null,
217
+ geminiMd: existsSync(join(resolved, "GEMINI.md")) ? join(resolved, "GEMINI.md") : null
202
218
  };
203
219
  }
204
220
  if (existsSync(opencodeDir)) {
@@ -206,7 +222,10 @@ function resolveSource(sourceFlag) {
206
222
  path: resolved,
207
223
  type: "custom",
208
224
  claudeDir: opencodeDir,
209
- agentsMd: existsSync(join(resolved, "AGENTS.md")) ? join(resolved, "AGENTS.md") : null
225
+ agentsDir: existsSync(agentsDir) ? agentsDir : null,
226
+ agentsMd: existsSync(join(resolved, "AGENTS.md")) ? join(resolved, "AGENTS.md") : null,
227
+ claudeMd: existsSync(join(resolved, "CLAUDE.md")) ? join(resolved, "CLAUDE.md") : null,
228
+ geminiMd: existsSync(join(resolved, "GEMINI.md")) ? join(resolved, "GEMINI.md") : null
210
229
  };
211
230
  }
212
231
  if (existsSync(join(resolved, "agents")) || existsSync(join(resolved, "commands"))) {
@@ -214,7 +233,10 @@ function resolveSource(sourceFlag) {
214
233
  path: resolved,
215
234
  type: "custom",
216
235
  claudeDir: resolved,
217
- agentsMd: existsSync(join(resolved, "AGENTS.md")) ? join(resolved, "AGENTS.md") : null
236
+ agentsDir: existsSync(agentsDir) ? agentsDir : null,
237
+ agentsMd: existsSync(join(resolved, "AGENTS.md")) ? join(resolved, "AGENTS.md") : null,
238
+ claudeMd: existsSync(join(resolved, "CLAUDE.md")) ? join(resolved, "CLAUDE.md") : null,
239
+ geminiMd: existsSync(join(resolved, "GEMINI.md")) ? join(resolved, "GEMINI.md") : null
218
240
  };
219
241
  }
220
242
  return { error: `No templates found in: ${sourceFlag}` };
@@ -1603,6 +1625,39 @@ async function copyAgentsMd(agentsMdPath, projectDir, mergeMode = false) {
1603
1625
  await fs8.copy(agentsMdPath, destPath, { overwrite: !mergeMode });
1604
1626
  return true;
1605
1627
  }
1628
+ async function copyClaudeMd(claudeMdPath, projectDir, mergeMode = false) {
1629
+ if (!claudeMdPath || !fs8.existsSync(claudeMdPath)) {
1630
+ return false;
1631
+ }
1632
+ const destPath = join9(projectDir, "CLAUDE.md");
1633
+ if (mergeMode && fs8.existsSync(destPath)) {
1634
+ return false;
1635
+ }
1636
+ await fs8.copy(claudeMdPath, destPath, { overwrite: !mergeMode });
1637
+ return true;
1638
+ }
1639
+ async function copyGeminiMd(geminiMdPath, projectDir, mergeMode = false) {
1640
+ if (!geminiMdPath || !fs8.existsSync(geminiMdPath)) {
1641
+ return false;
1642
+ }
1643
+ const destPath = join9(projectDir, "GEMINI.md");
1644
+ if (mergeMode && fs8.existsSync(destPath)) {
1645
+ return false;
1646
+ }
1647
+ await fs8.copy(geminiMdPath, destPath, { overwrite: !mergeMode });
1648
+ return true;
1649
+ }
1650
+ async function copyAgentsDir(agentsDirPath, projectDir, mergeMode = false) {
1651
+ if (!agentsDirPath || !fs8.existsSync(agentsDirPath)) {
1652
+ return false;
1653
+ }
1654
+ const destPath = join9(projectDir, ".agents");
1655
+ if (mergeMode && fs8.existsSync(destPath)) {
1656
+ return false;
1657
+ }
1658
+ await fs8.copy(agentsDirPath, destPath, { overwrite: !mergeMode });
1659
+ return true;
1660
+ }
1606
1661
  function listAvailable(type, sourceDir) {
1607
1662
  const typeDir = join9(sourceDir, type);
1608
1663
  if (!fs8.existsSync(typeDir)) {
@@ -1626,35 +1681,6 @@ var init_copy = __esm({
1626
1681
  // src/utils/prompts.ts
1627
1682
  import * as p from "@clack/prompts";
1628
1683
  import pc from "picocolors";
1629
- async function promptKit() {
1630
- const kits = getKitList();
1631
- const options = [
1632
- ...kits.map((kit2) => ({
1633
- value: kit2.name,
1634
- label: `${kit2.emoji} ${kit2.name}`,
1635
- hint: kit2.description
1636
- })),
1637
- { value: "custom", label: "\u{1F527} custom", hint: "Pick your own agents, skills, and commands" }
1638
- ];
1639
- const kit = await p.select({ message: "Select a kit:", options });
1640
- if (p.isCancel(kit)) process.exit(0);
1641
- return kit;
1642
- }
1643
- async function promptCliTargets() {
1644
- const selection = await p.multiselect({
1645
- message: "Select AI CLI target(s):",
1646
- options: [
1647
- { value: "claude", label: "Claude Code", hint: ".claude/" },
1648
- { value: "gemini", label: "Gemini CLI", hint: ".gemini/" },
1649
- { value: "codex", label: "Codex CLI", hint: ".agents/ + .codex/" },
1650
- { value: "discord", label: "Discord + Clawbot", hint: ".discord/" }
1651
- ],
1652
- initialValues: ["claude"],
1653
- required: true
1654
- });
1655
- if (p.isCancel(selection)) process.exit(0);
1656
- return selection;
1657
- }
1658
1684
  async function promptAgents(sourceDir) {
1659
1685
  const available = listAvailable("agents", sourceDir);
1660
1686
  if (available.length === 0) return [];
@@ -1715,18 +1741,6 @@ async function promptConfirm(message, defaultValue = true) {
1715
1741
  if (p.isCancel(result)) process.exit(0);
1716
1742
  return result;
1717
1743
  }
1718
- async function promptExistingTarget(targetPath) {
1719
- const action = await p.select({
1720
- message: `${targetPath} already exists. What do you want to do?`,
1721
- options: [
1722
- { value: "override", label: "Override", hint: "Replace all files" },
1723
- { value: "merge", label: "Merge", hint: "Only add missing files" },
1724
- { value: "skip", label: "Skip", hint: "Do nothing" }
1725
- ]
1726
- });
1727
- if (p.isCancel(action)) process.exit(0);
1728
- return action;
1729
- }
1730
1744
  async function promptUpdateConfirm(updates) {
1731
1745
  console.log(pc.cyan("\nChanges to apply:"));
1732
1746
  if (updates.toUpdate.length > 0) {
@@ -2066,14 +2080,12 @@ async function initCommand(projectName, options) {
2066
2080
  console.log(pc2.yellow(`Unknown target "${options.target}", using "claude"`));
2067
2081
  cliTargets = ["claude"];
2068
2082
  }
2069
- } else if (!process.stdin.isTTY || options.yes) {
2070
- cliTargets = ["claude"];
2071
2083
  } else {
2072
- cliTargets = await promptCliTargets();
2084
+ cliTargets = ["claude"];
2073
2085
  }
2074
2086
  let discordConfig = null;
2075
2087
  let openclawSetupSuccess = false;
2076
- if (cliTargets.includes("discord") && process.stdin.isTTY && !options.yes) {
2088
+ if (cliTargets.includes("discord") && options.target && process.stdin.isTTY) {
2077
2089
  discordConfig = await promptDiscordSetup();
2078
2090
  }
2079
2091
  let existingAction = null;
@@ -2095,20 +2107,7 @@ async function initCommand(projectName, options) {
2095
2107
  console.log(pc2.cyan(`Fresh install: removed existing files (${existingTargets.join(", ")})`));
2096
2108
  existingAction = null;
2097
2109
  } else if (existingTargets.length > 0 && !options.force) {
2098
- if (!process.stdin.isTTY || options.yes) {
2099
- if (options.yes) {
2100
- existingAction = "override";
2101
- } else {
2102
- console.log(pc2.yellow(`${existingTargets.join(", ")} already exists. Use --force to override.`));
2103
- return;
2104
- }
2105
- } else {
2106
- existingAction = await promptExistingTarget(existingTargets.join(", "));
2107
- if (existingAction === "skip") {
2108
- console.log(pc2.yellow("Skipped. No changes made."));
2109
- return;
2110
- }
2111
- }
2110
+ existingAction = "override";
2112
2111
  }
2113
2112
  if (!isCurrentDir && fs9.existsSync(projectDir) && !options.force) {
2114
2113
  const files = fs9.readdirSync(projectDir);
@@ -2124,12 +2123,7 @@ async function initCommand(projectName, options) {
2124
2123
  return;
2125
2124
  }
2126
2125
  console.log(pc2.gray(`Source: ${source.path}`));
2127
- let kitName = options.kit;
2128
- if (!kitName && !options.force && !options.yes) {
2129
- kitName = await promptKit();
2130
- } else if (!kitName) {
2131
- kitName = "engineer";
2132
- }
2126
+ let kitName = options.kit || "full";
2133
2127
  const mergeMode = existingAction === "merge";
2134
2128
  let toInstall = {
2135
2129
  agents: [],
@@ -2184,12 +2178,6 @@ async function initCommand(projectName, options) {
2184
2178
  console.log(pc2.gray(` Commands: ${toInstall.commands.length}`));
2185
2179
  }
2186
2180
  console.log("");
2187
- if (!options.force && !options.yes) {
2188
- if (!await promptConfirm("Proceed?")) {
2189
- console.log(pc2.yellow("Cancelled."));
2190
- return;
2191
- }
2192
- }
2193
2181
  const spinner = ora("Creating project...").start();
2194
2182
  try {
2195
2183
  await fs9.ensureDir(projectDir);
@@ -2251,8 +2239,19 @@ async function initCommand(projectName, options) {
2251
2239
  openclawSetupSuccess = true;
2252
2240
  }
2253
2241
  }
2254
- if (source.agentsMd && cliTargets.includes("claude")) {
2255
- await copyAgentsMd(source.agentsMd, projectDir, mergeMode);
2242
+ if (cliTargets.includes("claude")) {
2243
+ if (source.agentsMd) {
2244
+ await copyAgentsMd(source.agentsMd, projectDir, mergeMode);
2245
+ }
2246
+ if (source.claudeMd) {
2247
+ await copyClaudeMd(source.claudeMd, projectDir, mergeMode);
2248
+ }
2249
+ if (source.geminiMd) {
2250
+ await copyGeminiMd(source.geminiMd, projectDir, mergeMode);
2251
+ }
2252
+ if (source.agentsDir) {
2253
+ await copyAgentsDir(source.agentsDir, projectDir, mergeMode);
2254
+ }
2256
2255
  }
2257
2256
  spinner.text = "Saving state...";
2258
2257
  await createInitialState(projectDir, {