scaffold-doc-cli 1.0.6 → 1.0.7
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/index.js +13 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -220,7 +220,7 @@ async function main() {
|
|
|
220
220
|
// 1. Detect Changed Files
|
|
221
221
|
let changedFiles = [];
|
|
222
222
|
try {
|
|
223
|
-
const output = execSync('git diff --name-only HEAD~1 HEAD').toString();
|
|
223
|
+
const output = execSync('git diff --name-only HEAD~1 HEAD 2>/dev/null').toString();
|
|
224
224
|
changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
|
|
225
225
|
} catch (e) {
|
|
226
226
|
console.warn("HEAD~1 not found (likely first commit). Syncing all tracked files...");
|
|
@@ -250,8 +250,10 @@ async function main() {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
// 3. Prompt Gemini
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
// 3. Prompt Gemini (using @google/genai SDK)
|
|
254
|
+
// No need to get model instance first in this SDK version based on user snippet
|
|
255
|
+
|
|
256
|
+
|
|
255
257
|
const prompt = \`
|
|
256
258
|
You are a technical documentation assistant.
|
|
257
259
|
Analyze the following code changes and update the documentation in the .docs/ directory.
|
|
@@ -268,9 +270,12 @@ async function main() {
|
|
|
268
270
|
\`;
|
|
269
271
|
|
|
270
272
|
try {
|
|
271
|
-
const result = await
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
const result = await genAI.models.generateContent({
|
|
274
|
+
model: "gemini-2.5-flash",
|
|
275
|
+
contents: prompt
|
|
276
|
+
});
|
|
277
|
+
const text = result.text;
|
|
278
|
+
|
|
274
279
|
// Simple cleanup if model adds code blocks
|
|
275
280
|
const jsonStr = text.replace(/\\\`\\\`\\\`json/g, '').replace(/\\\`\\\`\\\`/g, '').trim();
|
|
276
281
|
const updates = JSON.parse(jsonStr);
|
|
@@ -279,11 +284,11 @@ async function main() {
|
|
|
279
284
|
for (const [relativePath, content] of Object.entries(updates)) {
|
|
280
285
|
const fullPath = path.join(process.cwd(), '.docs', relativePath);
|
|
281
286
|
const dir = path.dirname(fullPath);
|
|
282
|
-
|
|
287
|
+
|
|
283
288
|
if (!fs.existsSync(dir)) {
|
|
284
289
|
fs.mkdirSync(dir, { recursive: true });
|
|
285
290
|
}
|
|
286
|
-
|
|
291
|
+
|
|
287
292
|
fs.writeFileSync(fullPath, content);
|
|
288
293
|
console.log(\`Updated: .docs/\${relativePath}\`);
|
|
289
294
|
}
|