scaffold-doc-cli 1.0.3 → 1.0.5
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.
|
@@ -14,8 +14,14 @@ async function main() {
|
|
|
14
14
|
const output = execSync('git diff --name-only HEAD~1 HEAD').toString();
|
|
15
15
|
changedFiles = output.split('\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
|
|
16
16
|
} catch (e) {
|
|
17
|
-
console.
|
|
18
|
-
|
|
17
|
+
console.warn("Could not compare with HEAD~1 (likely first commit or shallow fetch). Falling back to listing all files.");
|
|
18
|
+
try {
|
|
19
|
+
const output = execSync('git ls-tree -r --name-only HEAD').toString();
|
|
20
|
+
changedFiles = output.split('\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
|
|
21
|
+
} catch (fallbackError) {
|
|
22
|
+
console.error("Failed to list files:", fallbackError.message);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
if (changedFiles.length === 0) {
|
|
@@ -36,7 +42,7 @@ async function main() {
|
|
|
36
42
|
|
|
37
43
|
// 3. Prompt Gemini
|
|
38
44
|
const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
|
|
39
|
-
|
|
45
|
+
|
|
40
46
|
const prompt = `
|
|
41
47
|
You are a technical documentation assistant.
|
|
42
48
|
Analyze the following code changes and update the documentation in the .docs/ directory.
|
|
@@ -55,7 +61,7 @@ async function main() {
|
|
|
55
61
|
try {
|
|
56
62
|
const result = await model.generateContent(prompt);
|
|
57
63
|
const text = result.response.text();
|
|
58
|
-
|
|
64
|
+
|
|
59
65
|
// Simple cleanup if model adds code blocks
|
|
60
66
|
const jsonStr = text.replace(/\`\`\`json/g, '').replace(/\`\`\`/g, '').trim();
|
|
61
67
|
const updates = JSON.parse(jsonStr);
|
|
@@ -64,11 +70,11 @@ async function main() {
|
|
|
64
70
|
for (const [relativePath, content] of Object.entries(updates)) {
|
|
65
71
|
const fullPath = path.join(process.cwd(), '.docs', relativePath);
|
|
66
72
|
const dir = path.dirname(fullPath);
|
|
67
|
-
|
|
73
|
+
|
|
68
74
|
if (!fs.existsSync(dir)) {
|
|
69
75
|
fs.mkdirSync(dir, { recursive: true });
|
|
70
76
|
}
|
|
71
|
-
|
|
77
|
+
|
|
72
78
|
fs.writeFileSync(fullPath, content);
|
|
73
79
|
console.log(`Updated: .docs/${relativePath}`);
|
|
74
80
|
}
|
|
@@ -21,10 +21,10 @@ jobs:
|
|
|
21
21
|
- name: Setup Node.js
|
|
22
22
|
uses: actions/setup-node@v3
|
|
23
23
|
with:
|
|
24
|
-
node-version: '
|
|
24
|
+
node-version: '22'
|
|
25
25
|
|
|
26
26
|
- name: Install Dependencies
|
|
27
|
-
run: npm install @google/genai
|
|
27
|
+
run: npm install @google/genai --no-save
|
|
28
28
|
|
|
29
29
|
- name: Run AI Doc Sync
|
|
30
30
|
env:
|
|
@@ -44,3 +44,4 @@ jobs:
|
|
|
44
44
|
branch: ai-docs/${{ github.ref_name }}
|
|
45
45
|
base: ${{ github.head_ref || github.ref_name }}
|
|
46
46
|
delete-branch: true
|
|
47
|
+
add-paths: .docs
|
package/index.js
CHANGED
|
@@ -178,10 +178,10 @@ jobs:
|
|
|
178
178
|
- name: Setup Node.js
|
|
179
179
|
uses: actions/setup-node@v3
|
|
180
180
|
with:
|
|
181
|
-
node-version: '
|
|
181
|
+
node-version: '22'
|
|
182
182
|
|
|
183
183
|
- name: Install Dependencies
|
|
184
|
-
run: npm install @google/genai
|
|
184
|
+
run: npm install @google/genai --no-save
|
|
185
185
|
|
|
186
186
|
- name: Run AI Doc Sync
|
|
187
187
|
env:
|
|
@@ -201,6 +201,7 @@ jobs:
|
|
|
201
201
|
branch: ai-docs/\${{ github.ref_name }}
|
|
202
202
|
base: \${{ github.head_ref || github.ref_name }}
|
|
203
203
|
delete-branch: true
|
|
204
|
+
add-paths: .docs
|
|
204
205
|
`;
|
|
205
206
|
await fs.writeFile(path.join(workflowDir, 'ai-doc-sync.yml'), workflowContent);
|
|
206
207
|
console.log(chalk.green('✔ .github/workflows/ai-doc-sync.yml created'));
|