@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
|
@@ -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
|
-
|
|
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
|
|
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(
|
|
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`);
|