auto-docify 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jayant
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # auto-docify
2
+
3
+ ![Node.js](https://img.shields.io/badge/Node.js-≥18-339933?logo=node.js&logoColor=white)
4
+ ![NPM Version](https://img.shields.io/npm/v/auto-docify.svg?logo=npm)
5
+ ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
6
+
7
+ ## 📖 Description
8
+
9
+ **auto-docify** is a lightweight CLI tool that automatically creates (or updates) a high‑quality `README.md` for any project. It scans your source files, extracts useful information, and leverages the **Groq** LLM API to craft polished documentation.
10
+
11
+ Key capabilities:
12
+
13
+ - **File scanning** – walks through your project and collects file names, structure, and metadata
14
+ - **AI‑powered writing** – uses Groq's LLM to generate human‑friendly documentation
15
+ - **Existing README awareness** – reads and enhances an existing `README.md` instead of overwriting it
16
+ - **Your API key** – users provide their own Groq API key (no shared keys)
17
+
18
+ ---
19
+
20
+ ## 🚀 Quick Start
21
+
22
+ ### 1. Install globally
23
+
24
+ ```bash
25
+ npm install -g auto-docify
26
+ ```
27
+
28
+ ### 2. Get your Groq API key
29
+
30
+ Get a free API key from [https://groq.com](https://groq.com)
31
+
32
+ ### 3. Run the generator
33
+
34
+ ```bash
35
+ auto-docify "/path/to/your/project" -k "your_groq_api_key"
36
+ ```
37
+
38
+ After the command finishes, a fresh `README.md` will appear in the target directory.
39
+
40
+ ---
41
+
42
+ ## 🛠️ Installation
43
+
44
+ ### As a global CLI
45
+
46
+ ```bash
47
+ npm install -g auto-docify
48
+ ```
49
+
50
+ ### As a development dependency
51
+
52
+ ```bash
53
+ npm install -D auto-docify
54
+ ```
55
+
56
+ ### Prerequisites
57
+
58
+ | Requirement | Version |
59
+ | ---------------- | ------------------------------------------------ |
60
+ | **Node.js** | >= 18 |
61
+ | **npm** | >= 8 |
62
+ | **Groq API key** | Obtain from [https://groq.com](https://groq.com) |
63
+
64
+ ---
65
+
66
+ ## 📦 Usage
67
+
68
+ ### CLI Syntax
69
+
70
+ ```bash
71
+ auto-docify [options] <projectPath>
72
+ ```
73
+
74
+ | Option | Alias | Description |
75
+ | ------ | ----------- | ---------------------------- |
76
+ | `-k` | `--api-key` | Your Groq API key (required) |
77
+ | `-h` | `--help` | Show help information |
78
+
79
+ ### Examples
80
+
81
+ ```bash
82
+ # Generate README for a project (required -k flag)
83
+ auto-docify "/path/to/project" -k "gsk_xxxxxxxx"
84
+
85
+ # Generate README for current directory
86
+ auto-docify . -k "gsk_xxxxxxxx"
87
+
88
+ # Show help
89
+ auto-docify --help
90
+ ```
91
+
92
+ ### Using with node directly
93
+
94
+ ```bash
95
+ # Set API key as environment variable
96
+ set GROQ_API_KEY=your_key
97
+ node index.js "/path/to/project"
98
+ ```
99
+
100
+ ### Programmatic API
101
+
102
+ If you prefer to call the generator from another Node script:
103
+
104
+ ```javascript
105
+ const generateReadme = require("auto-docify");
106
+
107
+ (async () => {
108
+ const markdown = await generateReadme("/my/project", {
109
+ apiKey: "gsk_xxxxxxxx",
110
+ });
111
+
112
+ console.log("README generated!");
113
+ })();
114
+ ```
115
+
116
+ Or using environment variable:
117
+
118
+ ```javascript
119
+ process.env.GROQ_API_KEY = "gsk_xxxxxxxx";
120
+
121
+ const generateReadme = require("auto-docify");
122
+
123
+ await generateReadme("/my/project");
124
+ ```
125
+
126
+ ---
127
+
128
+ ## ✨ Features
129
+
130
+ | Feature | Description |
131
+ | ------- | ---------------------------------------------------------------------- |
132
+ | ✅ | **File scanner** – walks through project and collects metadata |
133
+ | ✅ | **Existing README reader** – parses current README to preserve content |
134
+ | ✅ | **AI integration** – uses Groq API for generating documentation |
135
+ | ✅ | **Custom prompts** – builds context‑aware prompts for the LLM |
136
+ | ✅ | **Project analyzer** – detects language, tech stack, and structure |
137
+ | ✅ | **CLI interface** – quick, one‑liner generation |
138
+ | ✅ | **Programmatic API** – use as a library in your own code |
139
+
140
+ ---
141
+
142
+ ## 🏗️ Tech Stack
143
+
144
+ | Layer | Technology |
145
+ | -------------- | ------------------------------------------------------------- |
146
+ | Runtime | **Node.js** (v18+) |
147
+ | CLI Framework | Native `process.argv` handling |
148
+ | AI Provider | **groq-sdk** |
149
+ | Env Management | **dotenv** |
150
+ | Code Analysis | Custom scanners (`helpers/scanner.js`, `helpers/analyzer.js`) |
151
+
152
+ ---
153
+
154
+ ## 🤝 Contributing
155
+
156
+ Contributions are welcome! Follow these steps:
157
+
158
+ 1. **Fork** the repository
159
+ 2. **Clone** your fork:
160
+ ```bash
161
+ git clone https://github.com/yourusername/auto-docify.git
162
+ ```
163
+ 3. **Create a feature branch**:
164
+ ```bash
165
+ git checkout -b feature/awesome-new-feature
166
+ ```
167
+ 4. **Install dependencies**:
168
+ ```bash
169
+ npm install
170
+ ```
171
+ 5. **Make your changes** and test locally:
172
+ ```bash
173
+ node index.js /test/project -k "your_key"
174
+ ```
175
+ 6. **Commit** and **push** to your fork
176
+ 7. Open a **Pull Request**
177
+
178
+ ---
179
+
180
+ ## 📝 License
181
+
182
+ Distributed under the **MIT License**. See the `LICENSE` file for details.
183
+
184
+ ---
185
+
186
+ ## 📚 Related Projects & Resources
187
+
188
+ - [Groq SDK Documentation](https://github.com/groq/groq-node)
189
+ - [Node.js File System API](https://nodejs.org/api/fs.html)
190
+ - [dotenv – Environment variables](https://github.com/motdotla/dotenv)
191
+
192
+ ---
193
+
194
+ Happy documenting! 🎉
package/cli.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ const generateReadme = require("./index");
4
+
5
+ const args = process.argv.slice(2);
6
+ let projectPath = args[0] || process.cwd();
7
+ let apiKey = process.env.GROQ_API_KEY;
8
+
9
+ for (let i = 0; i < args.length; i++) {
10
+ if (args[i] === "-k" || args[i] === "--api-key") {
11
+ apiKey = args[i + 1];
12
+ i++;
13
+ } else {
14
+ projectPath = args[i];
15
+ }
16
+ }
17
+
18
+ if (!apiKey) {
19
+ console.error("❌ Error: GROQ_API_KEY required.");
20
+ console.log("Usage: auto-readme <path> -k <api-key>");
21
+ console.log("Or: set GROQ_API_KEY=*** auto-readme <path>");
22
+ process.exit(1);
23
+ }
24
+
25
+ process.env.GROQ_API_KEY = apiKey;
26
+
27
+ console.log(`Generate README for: ${projectPath}`);
28
+
29
+ generateReadme(projectPath)
30
+ .then(() => console.log("README Generated Successfully"))
31
+ .catch((err) => {
32
+ console.log("Error", err.message);
33
+ process.exit(1);
34
+ });
@@ -0,0 +1,17 @@
1
+ require("dotenv").config();
2
+ const Groq = require("groq-sdk");
3
+
4
+ const AICall = async (prompt) => {
5
+ const client = new Groq({
6
+ apiKey: process.env.GROQ_API_KEY,
7
+ });
8
+
9
+ const chatCompletion = await client.chat.completions.create({
10
+ messages: [{ role: "user", content: prompt }],
11
+ model: "openai/gpt-oss-120b",
12
+ });
13
+
14
+ return chatCompletion;
15
+ };
16
+
17
+ module.exports = AICall;
@@ -0,0 +1,26 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const analyzer = (projectPath, info) => {
5
+ const pkgPath = path.join(projectPath, "package.json");
6
+ if (fs.existsSync(pkgPath)) {
7
+ try {
8
+ info.packageJson = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
9
+ info.name = info.packageJson.name || info.name;
10
+ } catch (error) {
11
+ console.log(error.message);
12
+ }
13
+ }
14
+
15
+ const reqPath = path.join(projectPath, "requirements.txt");
16
+ if (fs.existsSync(reqPath)) {
17
+ try {
18
+ info.requirements = fs.readFileSync(reqPath, "utf-8").trim();
19
+ } catch (error) {
20
+ console.log(error.message);
21
+ }
22
+ }
23
+ return info;
24
+ };
25
+
26
+ module.exports = analyzer;
@@ -0,0 +1,19 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const readmeReader = (projectPath, info) => {
5
+ ["README.md", "README.txt", "readme.md", "readme.txt"].forEach((f) => {
6
+ const readmePath = path.join(projectPath, f);
7
+ try {
8
+ if (fs.existsSync(readmePath)) {
9
+ info.readme = fs.readFileSync(readmePath, "utf-8").slice(0, 2000);
10
+ }
11
+ } catch (error) {
12
+ console.log(error.message);
13
+ }
14
+ });
15
+
16
+ return info;
17
+ };
18
+
19
+ module.exports = readmeReader;
@@ -0,0 +1,62 @@
1
+ const prompt = (info) => {
2
+ const filesSummary = info.files
3
+ .slice(0, 15)
4
+ .map((f) => `${f.path} (${f.ext})`)
5
+ .join(", ");
6
+ const dirsSummary = info.directories.slice(0, 8).join(", ");
7
+
8
+ let p = `Generate a professional, complete README.md for this project.
9
+
10
+ PROJECT:
11
+ - Name: ${info.name}
12
+ - Main Files: ${info.mainFiles.join(", ") || "None"}
13
+ - Directories: ${dirsSummary || "None"}
14
+ - Files: ${filesSummary}`;
15
+
16
+ if (info.packageJson) {
17
+ p += `
18
+ - Description: ${info.packageJson.description || "N/A"}
19
+ - Scripts: ${Object.keys(info.packageJson.scripts || {}).join(", ")}
20
+ - Dependencies: ${Object.keys(info.packageJson.dependencies || {})
21
+ .slice(0, 10)
22
+ .join(", ")}
23
+ - Dev Dependencies: ${Object.keys(info.packageJson.devDependencies || {})
24
+ .slice(0, 5)
25
+ .join(", ")}`;
26
+ }
27
+
28
+ if (info.requirements) {
29
+ p += `\n- Requirements: ${info.requirements.slice(0, 300)}`;
30
+ }
31
+
32
+ if (info.readme) {
33
+ p += `\nEXISTING README:\n${info.readme.slice(0, 800)}`;
34
+ }
35
+
36
+ p += `
37
+
38
+ Create a README with these sections:
39
+ 1. **Badges** - Add relevant badges (Node.js, npm, License)
40
+ 2. **Description** - What this project does (1-2 sentences)
41
+ 3. **Quick Start** - Install & run in 3-4 steps
42
+ 4. **Installation** - As CLI or dependency
43
+ 5. **Usage** - CLI syntax + code example
44
+ 6. **Features** - 5-7 key features as a table or bullet list
45
+ 7. **Tech Stack** - Technologies used (table format)
46
+ 8. **Contributing** - How to contribute (basic template)
47
+ 9. **License** - MIT
48
+
49
+ RULES:
50
+ - Use "${info.name}" as project name (NOT placeholder)
51
+ - Output ONLY markdown, no explanations
52
+ - Keep it under 600 words
53
+ - Use clear, friendly tone
54
+ - Include actual commands based on the project's scripts/structure
55
+ - Infer purpose from file names and code structure
56
+
57
+ Generate the complete README.md now:`;
58
+
59
+ return p;
60
+ };
61
+
62
+ module.exports = prompt;
@@ -0,0 +1,113 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const scanProject = (projectPath) => {
5
+ const info = {
6
+ name: path.basename(projectPath),
7
+ files: [],
8
+ directories: [],
9
+ packageJson: null,
10
+ requirements: null,
11
+ readme: null,
12
+ mainFiles: [],
13
+ configFiles: [],
14
+ };
15
+
16
+ const scanDir = (dirPath, depth = 0) => {
17
+ if (depth > 3) return;
18
+
19
+ try {
20
+ const items = fs.readdirSync(dirPath);
21
+
22
+ for (const item of items) {
23
+ if (
24
+ [
25
+ "node_modules",
26
+ ".git",
27
+ ".gitignore",
28
+ ".env",
29
+ "dist",
30
+ "build",
31
+ "__pycache__",
32
+ "venv",
33
+ "vendor",
34
+ ".devcontainer",
35
+ ".next",
36
+ ].includes(item)
37
+ ) {
38
+ continue;
39
+ }
40
+
41
+ const fullPath = path.join(dirPath, item);
42
+ const stat = fs.statSync(fullPath);
43
+
44
+ if (stat.isDirectory()) {
45
+ info.directories.push(path.relative(projectPath, fullPath));
46
+ scanDir(fullPath, depth + 1);
47
+ } else {
48
+ const ext = path.extname(item).toLowerCase();
49
+ const relPath = path.relative(projectPath, fullPath);
50
+
51
+ info.files.push({
52
+ name: item,
53
+ path: relPath,
54
+ ext: ext,
55
+ });
56
+
57
+ if (
58
+ [
59
+ "index.js",
60
+ "main.js",
61
+ "app.js",
62
+ "server.js",
63
+ "index.ts",
64
+ "main.ts",
65
+ "app.ts",
66
+ "main.py",
67
+ "app.py",
68
+ "index.py",
69
+ "__main__.py",
70
+ "main.go",
71
+ "main.rs",
72
+ "src/main.rs",
73
+ "src/main.go",
74
+ "Program.cs",
75
+ "main.c",
76
+ "main.cpp",
77
+ ].includes(item)
78
+ ) {
79
+ info.mainFiles.push(relPath);
80
+ }
81
+
82
+ if (
83
+ [
84
+ "package.json",
85
+ "requirements.txt",
86
+ "Pipfile",
87
+ "Cargo.toml",
88
+ "go.mod",
89
+ "pom.xml",
90
+ "build.gradle",
91
+ "tsconfig.json",
92
+ ".env.example",
93
+ "docker-compose.yml",
94
+ "Dockerfile",
95
+ "Makefile",
96
+ "pyproject.toml",
97
+ "setup.py",
98
+ ].includes(item)
99
+ ) {
100
+ info.configFiles.push(relPath);
101
+ }
102
+ }
103
+ }
104
+ } catch (error) {
105
+ console.log(error.message);
106
+ }
107
+ };
108
+
109
+ scanDir(projectPath);
110
+ return info;
111
+ };
112
+
113
+ module.exports = scanProject;
package/index.js ADDED
@@ -0,0 +1,39 @@
1
+ const scanProject = require("./helpers/scanner");
2
+ const analyzer = require("./helpers/analyzer");
3
+ const readmeReader = require("./helpers/existingReadmeReader");
4
+ const prompt = require("./helpers/prompt");
5
+ const AICall = require("./helpers/AICall");
6
+ const fs = require("fs").promises;
7
+ const path = require("path");
8
+
9
+ const generateReadme = async (dirPath, options = {}) => {
10
+ const apiKey = options.apiKey || process.env.GROQ_API_KEY;
11
+
12
+ if (!apiKey) {
13
+ throw new Error(
14
+ "GROQ_API_KEY is required. Pass it as generateReadme(path, { apiKey: '...' }) " +
15
+ "or set process.env.GROQ_API_KEY before calling.",
16
+ );
17
+ }
18
+
19
+ process.env.GROQ_API_KEY = apiKey;
20
+
21
+ const dirInfo = scanProject(dirPath);
22
+ const analysisResult = analyzer(dirPath, dirInfo);
23
+ const readme = readmeReader(dirPath, analysisResult);
24
+ const promptData = prompt(readme);
25
+ const AIData = await AICall(promptData);
26
+ const READMEData = AIData.choices[0]?.message.content;
27
+
28
+ await fs.writeFile(path.join(dirPath, "README.md"), READMEData, "utf-8");
29
+ console.log("Completed");
30
+ };
31
+
32
+ module.exports = generateReadme;
33
+
34
+ //CLI mode
35
+
36
+ if (require.main == module) {
37
+ const dirPath = process.argv[2] || process.cwd();
38
+ generateReadme(dirPath).catch(console.error);
39
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "auto-docify",
3
+ "version": "1.0.1",
4
+ "description": "Creates README file for projects automatically",
5
+ "license": "MIT",
6
+ "author": "Jayant",
7
+ "main": "index.js",
8
+ "bin": {
9
+ "auto-docify": "cli.js"
10
+ },
11
+ "keywords": [
12
+ "readme",
13
+ "ai",
14
+ "generator",
15
+ "documentation",
16
+ "groq",
17
+ "automation"
18
+ ],
19
+ "scripts": {
20
+ "test": "echo \"Error: no test specified\" && exit 1"
21
+ },
22
+ "dependencies": {
23
+ "dotenv": "^17.4.2",
24
+ "groq-sdk": "^1.2.0"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "http://github.com/saxena-jayant/auto-docify.git"
29
+ },
30
+ "homepage": "http://github.com/saxena-jayant/auto-docify"
31
+ }