@tyyyho/treg 0.1.17 → 0.1.18

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/README.zh-hant.md CHANGED
@@ -119,8 +119,8 @@ formatter 預設:
119
119
  - `Claude -> CLAUDE.md`
120
120
  - `Codex -> AGENTS.md`
121
121
  - `Gemini -> GEMINI.md`
122
- - 僅更新 repo root 已存在的檔案。
123
- - 不存在的檔案會跳過,不會自動建立。
122
+ - 若檔案已存在會直接更新。
123
+ - 選擇的 AI 工具對應檔案不存在時,會先自動建立再注入說明。
124
124
  - 每個啟用功能的 skill 檔只會建立一次。
125
125
 
126
126
  ## 發布
@@ -71,9 +71,7 @@ const FEATURE_STEP_LABELS = {
71
71
  };
72
72
  function resolveSkillsDocs(projectDir, aiTools) {
73
73
  const docFiles = [...new Set(aiTools.map(tool => AI_TOOL_DOCS[tool]))];
74
- return docFiles
75
- .map(fileName => path.join(projectDir, fileName))
76
- .filter(existsSync);
74
+ return docFiles.map(fileName => path.join(projectDir, fileName));
77
75
  }
78
76
  function getEnabledFeatures(enabledFeatures) {
79
77
  return Object.entries(enabledFeatures)
@@ -174,26 +172,31 @@ function upsertSkillSection(content, nextSection) {
174
172
  }
175
173
  return `${content.trimEnd()}\n\n${nextSection.trim()}\n`;
176
174
  }
175
+ function buildInitialAiDocContent(fileName) {
176
+ const baseName = path.basename(fileName, path.extname(fileName));
177
+ return `# ${baseName}\n`;
178
+ }
177
179
  export async function runAiSkillsRule(context) {
178
180
  const { projectDir, dryRun, aiTools } = context;
179
181
  const targetFiles = resolveSkillsDocs(projectDir, aiTools);
180
- if (targetFiles.length === 0) {
181
- console.log("Skip ai-skills (selected AI docs not found)");
182
- return;
183
- }
184
182
  const enabled = getEnabledFeatures(context.enabledFeatures);
185
183
  await ensureSkillFiles(projectDir, enabled, context.testRunner, dryRun);
186
184
  const section = buildSkillSection(context);
187
185
  for (const targetFile of targetFiles) {
188
186
  if (dryRun) {
189
- console.log(`[dry-run] Would update ${path.basename(targetFile)} with AI skill guidance`);
187
+ const action = existsSync(targetFile) ? "update" : "create";
188
+ console.log(`[dry-run] Would ${action} ${path.basename(targetFile)} with AI skill guidance`);
190
189
  continue;
191
190
  }
192
- const current = await fs.readFile(targetFile, "utf8");
191
+ const exists = existsSync(targetFile);
192
+ const current = exists
193
+ ? await fs.readFile(targetFile, "utf8")
194
+ : buildInitialAiDocContent(targetFile);
193
195
  const updated = upsertSkillSection(current, section);
194
196
  if (updated !== current) {
197
+ await fs.mkdir(path.dirname(targetFile), { recursive: true });
195
198
  await fs.writeFile(targetFile, updated, "utf8");
196
- console.log(`Updated ${path.basename(targetFile)} with AI skill guidance`);
199
+ console.log(`${exists ? "Updated" : "Created"} ${path.basename(targetFile)} with AI skill guidance`);
197
200
  continue;
198
201
  }
199
202
  console.log(`${path.basename(targetFile)} already contains latest AI skill guidance`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tyyyho/treg",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "CLI tool for initializing development conventions in existing projects.",
5
5
  "license": "MIT",
6
6
  "repository": {