scaffold-doc-cli 1.0.4 → 1.0.6

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 CHANGED
@@ -223,8 +223,14 @@ async function main() {
223
223
  const output = execSync('git diff --name-only HEAD~1 HEAD').toString();
224
224
  changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
225
225
  } catch (e) {
226
- console.error("Failed to detect changes:", e.message);
227
- return;
226
+ console.warn("HEAD~1 not found (likely first commit). Syncing all tracked files...");
227
+ try {
228
+ const output = execSync('git ls-tree -r HEAD --name-only').toString();
229
+ changedFiles = output.split('\\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
230
+ } catch (err) {
231
+ console.error("Failed to list files:", err.message);
232
+ return;
233
+ }
228
234
  }
229
235
 
230
236
  if (changedFiles.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scaffold-doc-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "CLI tool to scaffold standardized documentation structure for projects.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,82 +0,0 @@
1
- import { GoogleGenAI } from "@google/genai";
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { execSync } from 'child_process';
5
-
6
- const genAI = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
7
-
8
- async function main() {
9
- console.log("Starting AI Doc Sync...");
10
-
11
- // 1. Detect Changed Files
12
- let changedFiles = [];
13
- try {
14
- const output = execSync('git diff --name-only HEAD~1 HEAD').toString();
15
- changedFiles = output.split('\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
16
- } catch (e) {
17
- console.error("Failed to detect changes:", e.message);
18
- return;
19
- }
20
-
21
- if (changedFiles.length === 0) {
22
- console.log("No relevant code changes detected.");
23
- return;
24
- }
25
-
26
- console.log("Processing changed files:", changedFiles);
27
-
28
- // 2. Prepare Context for Gemini
29
- let context = "";
30
- for (const file of changedFiles) {
31
- if (fs.existsSync(file)) {
32
- context += `\n--- File: ${file} ---\n`;
33
- context += fs.readFileSync(file, 'utf-8').slice(0, 10000); // Limit size
34
- }
35
- }
36
-
37
- // 3. Prompt Gemini
38
- const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
39
-
40
- const prompt = `
41
- You are a technical documentation assistant.
42
- Analyze the following code changes and update the documentation in the .docs/ directory.
43
-
44
- Rules:
45
- 1. Output MUST be a valid JSON object where keys are file paths (relative to .docs/, e.g., "reference/controllers.md") and values are the NEW content of that file.
46
- 2. You can create new files if necessary.
47
- 3. You can update existing files (e.g., getting-started.md, architecture.md).
48
- 4. Focus on accuracy and clarity.
49
- 5. Do not include markdown code fence blocks in your response, just the raw JSON string.
50
-
51
- Code Context:
52
- ${context}
53
- `;
54
-
55
- try {
56
- const result = await model.generateContent(prompt);
57
- const text = result.response.text();
58
-
59
- // Simple cleanup if model adds code blocks
60
- const jsonStr = text.replace(/\`\`\`json/g, '').replace(/\`\`\`/g, '').trim();
61
- const updates = JSON.parse(jsonStr);
62
-
63
- // 4. Write Updates
64
- for (const [relativePath, content] of Object.entries(updates)) {
65
- const fullPath = path.join(process.cwd(), '.docs', relativePath);
66
- const dir = path.dirname(fullPath);
67
-
68
- if (!fs.existsSync(dir)) {
69
- fs.mkdirSync(dir, { recursive: true });
70
- }
71
-
72
- fs.writeFileSync(fullPath, content);
73
- console.log(`Updated: .docs/${relativePath}`);
74
- }
75
-
76
- } catch (error) {
77
- console.error("AI Generation failed:", error);
78
- process.exit(1);
79
- }
80
- }
81
-
82
- main();
@@ -1,47 +0,0 @@
1
- name: AI Doc Sync
2
-
3
- on:
4
- push:
5
- paths-ignore:
6
- - '.docs/**'
7
- workflow_dispatch:
8
-
9
- permissions:
10
- contents: write
11
- pull-requests: write
12
-
13
- jobs:
14
- doc-completion:
15
- runs-on: ubuntu-latest
16
- steps:
17
- - uses: actions/checkout@v3
18
- with:
19
- fetch-depth: 2
20
-
21
- - name: Setup Node.js
22
- uses: actions/setup-node@v3
23
- with:
24
- node-version: '22'
25
-
26
- - name: Install Dependencies
27
- run: npm install @google/genai --no-save
28
-
29
- - name: Run AI Doc Sync
30
- env:
31
- GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
32
- run: node .github/scripts/doc-sync.mjs
33
-
34
- - name: Create Pull Request
35
- uses: peter-evans/create-pull-request@v5
36
- with:
37
- token: ${{ secrets.GITHUB_TOKEN }}
38
- commit-message: "docs: auto-generated documentation updates"
39
- title: "docs: AI-generated documentation updates"
40
- body: |
41
- Automatic documentation updates generated by AI based on recent code changes.
42
-
43
- Please review and merge if accurate.
44
- branch: ai-docs/${{ github.ref_name }}
45
- base: ${{ github.head_ref || github.ref_name }}
46
- delete-branch: true
47
- add-paths: .docs
package/mkdocs.yml DELETED
@@ -1,12 +0,0 @@
1
- site_name: test Documentation
2
- docs_dir: .docs
3
- theme: readthedocs
4
-
5
- nav:
6
- - Home: index.md
7
- - Getting Started: getting-started.md
8
- - Architecture: architecture.md
9
- - Reference:
10
- - Components: reference/components.md
11
- - Composables: reference/composables.md
12
- - Server-routes: reference/server-routes.md