docs-agent 1.1.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.1](https://github.com/rudderlabs/docs-agent/compare/v1.1.0...v1.1.1) (2026-02-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * change content order in docs review output ([#75](https://github.com/rudderlabs/docs-agent/issues/75)) ([600d280](https://github.com/rudderlabs/docs-agent/commit/600d28088fe7a30c68c31feae499916c70f30bb7))
9
+
3
10
  ## [1.1.0](https://github.com/rudderlabs/docs-agent/compare/v1.0.2...v1.1.0) (2025-11-20)
4
11
 
5
12
 
package/env.example CHANGED
@@ -12,6 +12,7 @@ MAX_TOKENS=8000
12
12
  OLLAMA_API_KEY=sk-ollama-1234567890
13
13
  OLLAMA_API_URL=http://localhost:11434/api/generateGEMINI_API_KEY=#deprecated
14
14
  GOOGLE_GENERATIVE_AI_API_KEY=
15
+ GEMINI_API_KEY=#alias for GOOGLE_GENERATIVE_AI_API_KEY
15
16
  OPENAI_API_KEY=sk-proj-1234567890
16
17
  ANTHROPIC_API_KEY=sk-ant-api03-1234567890
17
18
  OTEL_EXPORTER_OTLP_ENDPOINT=https://api.braintrust.dev/otel
package/package.json CHANGED
@@ -1,11 +1,23 @@
1
1
  {
2
2
  "name": "docs-agent",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Docs-Agent leverages AI to avoid outdated documentation, fix issues related to comprehensiblity or technical accuracy.",
5
- "main": "src/index.js",
5
+ "main": "src/lib.js",
6
+ "exports": {
7
+ ".": "./src/lib.js"
8
+ },
9
+ "bin": {
10
+ "docs-agent": "./src/cli.js"
11
+ },
6
12
  "type": "module",
7
13
  "license": "MIT",
8
- "files": ["src", "README.md", "LICENSE", "CHANGELOG.md", "env.example", "docs"],
14
+ "files": [
15
+ "src",
16
+ "README.md",
17
+ "LICENSE",
18
+ "CHANGELOG.md",
19
+ "env.example"
20
+ ],
9
21
  "scripts": {
10
22
  "test": "mocha test/**/*.test.js",
11
23
  "start": "node src/index.js",
@@ -0,0 +1,6 @@
1
+ export function configureLogsForMcp(consoleRef = console) {
2
+ consoleRef.log = consoleRef.error;
3
+ consoleRef.debug = consoleRef.error;
4
+ consoleRef.info = consoleRef.error;
5
+ consoleRef.warn = consoleRef.error;
6
+ }
package/src/cli.js CHANGED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+
3
+ import 'dotenv/config';
4
+ import path from 'path';
5
+ import api from './api.js';
6
+ import mcp from './mcp.js';
7
+ import { DocsAgent } from './lib.js';
8
+ import { configureLogsForMcp } from './LogUtility.js';
9
+
10
+ // CLI: no args / mcp → MCP server; api [--port=N] → API server; review <filepath> → DocsAgent.review
11
+
12
+ const args = process.argv.slice(2);
13
+ const subcommand = args[0];
14
+
15
+ function parseFlags(rest) {
16
+ const opts = {};
17
+ for (const arg of rest) {
18
+ if (arg.startsWith('--port=')) opts.port = arg.slice(7);
19
+ else if (arg.startsWith('--filename=')) opts.filename = arg.slice(11);
20
+ else if (arg.startsWith('--project-structure=')) opts.projectStructure = arg.slice(20);
21
+ else if (arg.startsWith('--instructions=')) opts.instructions = arg.slice(15);
22
+ }
23
+ return opts;
24
+ }
25
+
26
+ async function runMcp() {
27
+ configureLogsForMcp();
28
+ await mcp.start();
29
+ }
30
+
31
+ async function runApi(portArg) {
32
+ const port = portArg || process.env.PORT || 3001;
33
+ api.start(port);
34
+ }
35
+
36
+ async function runReview(filepath, opts) {
37
+ if (!filepath) {
38
+ console.error('Usage: docs-agent review <filepath> [--filename=...] [--project-structure=...] [--instructions=...]');
39
+ process.exit(1);
40
+ }
41
+ const absolutePath = path.isAbsolute(filepath) ? filepath : path.resolve(process.cwd(), filepath);
42
+ const agent = new DocsAgent('mcp');
43
+ const context = { filepath: absolutePath };
44
+ if (opts.filename) context.filename = opts.filename;
45
+ if (opts.projectStructure) context.projectStructure = opts.projectStructure;
46
+ const review = await agent.review(null, context, opts.instructions);
47
+ console.log(review);
48
+ }
49
+
50
+ async function main() {
51
+ if (!subcommand || subcommand === 'mcp') {
52
+ await runMcp();
53
+ return;
54
+ }
55
+ if (subcommand === 'api') {
56
+ const flags = parseFlags(args.slice(1));
57
+ await runApi(flags.port);
58
+ return;
59
+ }
60
+ if (subcommand === 'review') {
61
+ const filepath = args[1];
62
+ const flags = parseFlags(args.slice(2));
63
+ await runReview(filepath, flags);
64
+ return;
65
+ }
66
+ console.error(`Unknown subcommand: ${subcommand}`);
67
+ console.error('Usage: docs-agent [mcp|api|review ...]');
68
+ console.error(' (no args) or mcp → start MCP server');
69
+ console.error(' api [--port=N] → start HTTP API server');
70
+ console.error(' review <filepath> [--filename=...] [--project-structure=...] [--instructions=...]');
71
+ process.exit(1);
72
+ }
73
+
74
+ main().catch((err) => {
75
+ console.error(err);
76
+ process.exit(1);
77
+ });
@@ -12,10 +12,11 @@ ${PRINCIPLES}
12
12
  ${SCORING_PROMPT}
13
13
 
14
14
  ## Output format
15
- - Analysis summary of the documentation.
15
+ - Documentation file being reviewed: <filepath>
16
+ - Analysis summary.
16
17
  - An objective rating score of the documentation.
17
- - A list of actionable suggestions for the documentation.
18
- - A list of the documentation's strengths.
18
+ - A concise list of the documentation's strengths.
19
+ - A list of actionable suggestions for the documentation. (most important part of the output)
19
20
  - Do not add any other text or comments.
20
21
 
21
22
  `;
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import 'dotenv/config';
2
2
  import api from './api.js';
3
3
  import mcp from './mcp.js';
4
+ import { configureLogsForMcp } from './LogUtility.js';
4
5
  import fs from 'fs';
5
6
  import path from 'path';
6
7
 
@@ -15,14 +16,6 @@ if(process.env.MCP_DISABLED !== 'true'){
15
16
  mcp.start();
16
17
  }
17
18
 
18
- function configureLogsForMcp(){
19
- console.log = console.error;
20
- // console.error = () => {};
21
- console.debug = console.error;
22
- console.info = console.error;
23
- console.warn = console.error;
24
- }
25
-
26
19
  function setupPersistentLogs(filename){
27
20
  // Override console methods
28
21
  console.log = logToFile;
@@ -1,142 +0,0 @@
1
- ## Deployment Guide
2
-
3
- This guide covers deploying Docs-Agent as a container (recommended), with Docker Compose, or directly on a host (bare metal). It exposes an HTTP API on port 3001 when `API_DISABLED=false` and can be run as an MCP server with `MCP_DISABLED=false`.
4
-
5
- ### Prerequisites
6
- - Node.js v20+ (bare-metal or MCP usage)
7
- - Docker 24+ (for containerized deployment)
8
- - Optional: Docker Compose v2+
9
- - Required secrets (at least):
10
- - `GOOGLE_GENERATIVE_AI_API_KEY`
11
- - `ANTHROPIC_API_KEY`
12
- - `GITHUB_TOKEN` (for code search)
13
-
14
- Additional configuration (optional):
15
- - `API_KEY` for API security
16
- - `PREFERRED_AI_SERVICE`, `PREFERRED_AI_MODEL`, `REVIEW_AI_SERVICE`, `REVIEW_AI_MODEL`
17
- - `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_EXPORTER_OTLP_HEADERS` for observability
18
- - `MAX_TOKENS`, `MAX_CHANGES`, `ALLOW_DISRUPTIVE_CHANGES`
19
- - SSRF Protection:
20
- - `ALLOWED_WEBHOOK_URLS` for webhook endpoints (exact URLs only)
21
- - `RESULTS_WEBHOOK_KEY` for authenticating webhook requests (optional, sent as `x-api-key` header)
22
- - `REMOTE_FILE_ALLOWED_HOSTS` for remote file access (hostnames only)
23
- - `REMOTE_FILE_ALLOW_CUSTOM_HOSTS` to enable custom hosts (default: false)
24
-
25
- Environment defaults are shown in `env.example` and `docker-compose.yml`.
26
-
27
- ---
28
-
29
- ### Option A: Docker (single container)
30
- 1. Build the image:
31
- ```bash
32
- docker build -t docs-agent:latest .
33
- ```
34
- 2. Run the container (API mode):
35
- ```bash
36
- docker run --rm \
37
- -p 3001:3001 \
38
- -e NODE_ENV=production \
39
- -e PORT=3001 \
40
- -e API_DISABLED=false \
41
- -e MCP_DISABLED=true \
42
- -e API_KEY=secret_api_key \
43
- -e GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_key \
44
- -e ANTHROPIC_API_KEY=your_anthropic_key \
45
- -e GITHUB_TOKEN=your_github_pat \
46
- -e ALLOWED_WEBHOOK_URLS=https://github.app.url/api/comment \
47
- -e RESULTS_WEBHOOK_KEY=your_webhook_auth_key \
48
- -e REMOTE_FILE_ALLOWED_HOSTS=raw.githubusercontent.com \
49
- docs-agent:latest
50
- ```
51
-
52
- Health check: `GET http://localhost:3001/health` should return 200.
53
-
54
- Notes
55
- - The image runs as a non-root `nodejs` user.
56
- - Port 3001 is exposed; adjust with `-e PORT=... -p host:container`.
57
-
58
- ---
59
-
60
- ### Option B: Docker Compose (recommended for local/dev)
61
- Use the provided `docker-compose.yml`:
62
-
63
- ```bash
64
- docker compose up --build
65
- ```
66
-
67
- Then check: `curl http://localhost:3001/health`.
68
-
69
- Customize environment by editing `docker-compose.yml` or using an `.env` file. Ensure you set valid keys for:
70
- - `GOOGLE_GENERATIVE_AI_API_KEY`
71
- - `ANTHROPIC_API_KEY`
72
- - `GITHUB_TOKEN`
73
- - `API_KEY`
74
-
75
- For SSRF protection, configure:
76
- - `ALLOWED_WEBHOOK_URLS` - exact webhook URLs (comma-separated)
77
- - `RESULTS_WEBHOOK_KEY` - API key to authenticate webhook requests (optional, sent as `x-api-key` header)
78
- - `REMOTE_FILE_ALLOWED_HOSTS` - allowed hosts for remote file access
79
- - `REMOTE_FILE_ALLOW_CUSTOM_HOSTS` - set to "true" to enable custom hosts
80
-
81
- ---
82
-
83
- ### Option C: Bare metal (Node.js on host)
84
- 1. Install dependencies:
85
- ```bash
86
- npm ci --only=production
87
- ```
88
- 2. Configure environment (copy and edit):
89
- ```bash
90
- cp env.example .env
91
- # edit .env -> set API_DISABLED=false and add your keys
92
- ```
93
- 3. Start the server:
94
- ```bash
95
- npm start
96
- ```
97
- 4. Verify:
98
- ```bash
99
- curl http://localhost:3001/health
100
- ```
101
-
102
- For MCP usage (no HTTP API), set `MCP_DISABLED=false` and `API_DISABLED=true`, then point your MCP client (e.g., Cursor Custom Mode) to `node src/index.js`. See `README.md` for an example MCP client configuration.
103
-
104
- ---
105
-
106
- ### Configuration Reference
107
- - `API_DISABLED` (default true in example): set to `false` to enable HTTP API
108
- - `API_KEY`, always set this to a secret value to secure API endpoints
109
- - `MCP_DISABLED`: set to `false` to enable MCP server tools
110
- - `GOOGLE_GENERATIVE_AI_API_KEY`, `ANTHROPIC_API_KEY`: required for AI operations
111
- - `GITHUB_TOKEN`: required for auditing docs against code in private/public repos
112
- - `PREFERRED_AI_SERVICE`/`MODEL` and `REVIEW_AI_SERVICE`/`MODEL`: control model choices
113
- - `MAX_TOKENS`, `MAX_CHANGES`, `ALLOW_DISRUPTIVE_CHANGES`: safety/quality controls
114
- - Observability: set `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` to enable OTEL traces
115
- - SSRF Protection:
116
- - `ALLOWED_WEBHOOK_URLS`: exact webhook URLs only (comma-separated)
117
- - `RESULTS_WEBHOOK_KEY`: API key for webhook authentication (optional, sent as `x-api-key` header)
118
- - `REMOTE_FILE_ALLOWED_HOSTS`: allowed hosts for remote file reads (comma-separated)
119
- - `REMOTE_FILE_ALLOW_CUSTOM_HOSTS`: enable custom hosts (default: false)
120
-
121
- All variables and defaults are documented in `env.example`.
122
-
123
- ---
124
-
125
- ### Security and Operations
126
- - Provide secrets via environment variables or secret stores (never bake into images).
127
- - The container uses a non-root user and a health check.
128
- - Run behind an API gateway or reverse proxy in production; add rate limits and auth as needed.
129
- - **Path Traversal Protection**:
130
- - API mode: Restricts file access to `public/` subdirectory only
131
- - MCP mode: Allows unrestricted local file access (relies on MCP client permissions)
132
- - Both modes: Allow validated remote file access (GitHub/GitLab URLs)
133
- - SSRF Protection: Configure webhook and remote file allowlists to prevent unauthorized requests.
134
-
135
- ---
136
-
137
- ### Troubleshooting
138
- - Health endpoint not ready: allow the container start period defined in Dockerfile/Compose.
139
- - 401/403 errors from code search: verify `GITHUB_TOKEN` scopes (typically `repo`).
140
- - AI errors: verify keys and model names; ensure region/product access with providers.
141
-
142
-
@@ -1,26 +0,0 @@
1
- You are a helpful team member to coordinate documentation improvements tasks between the user and the MCP tools such as docs-agent.
2
- User will ask you for documentation improvements tasks or advice.
3
- You will then choose the appropriate MCP tools from docs-agent based on the task requirements.
4
-
5
- ## MCP Tool Usage Guidelines
6
- - Always use the docs-agent's tools for docs improvement to get the improved docs content.
7
- - Make sure to pass the necessary content to docs-agent such as the file content and context e.g. project structure, etc.
8
- - Always send the glossary page content as glossary parameter for the tool that requires it.
9
- - For tools that require specific files or information, find the related files or information from the source code or project context.
10
- - If the RudderStack documentation style guide rule (rudderstack-style.mdc) is available, provide its complete content in the custom instructions to ensure that the docs-agent output follows the RudderStack style.
11
- - The file paths must always be either absolute path or a remote url path
12
- - Always apply the docs-agent results as it is in the code immediately after they are received
13
- - Always show the audit or review results to ensure the reasoning behind the changes
14
-
15
- ## Finding related files
16
- - Based on the user goal, decide which files are the most relevant files for additional context
17
- - A file mentioned in the page could be a relevant file if the understanding of the page depends on that file content
18
- - Sibling files under the immediate parent folder are sometimes relevant as they relate to the same concept
19
- - Do not make up the filepath, always list files and then pick the filepath from there
20
-
21
- ## Boundaries
22
- - **Do not** make any additional changes to the docs-agent tool output, your job is to only apply those changes to current file content as it is.
23
- - Make sure the final file content matches the agent's version completely after applying the diff.
24
- - Remember to apply all the changes as it is, no additional changes or addition or deletion from your side.
25
- - Do not make changes to the file content that is not related to the returned docs content.
26
- - Do not ask the user to apply the changes returned by `improveDocs` or `editDocs` tools — just apply them directly.
package/docs/reference.md DELETED
@@ -1,258 +0,0 @@
1
- `docs-agent` is an AI-powered agent for continuous documentation improvement. It analyzes, reviews, and edits documentation files using advanced LLMs (Gemini, Claude, etc.), following the Diátaxis documentation framework. It exposes its functionality via an HTTP API, an MCP (Model Context Protocol) server, and a programmatic Node.js interface.
2
-
3
- ## 1. MCP Server Tools
4
-
5
- The MCP server exposes the following tools for integration with Model Context Protocol clients:
6
-
7
- ### `reviewDocs`
8
-
9
- - **Description:** Reviews documentation quality following the Diátaxis framework.
10
- - **Parameters:**
11
- - `filepath` (`string`): Absolute path to the docs file.
12
- - `filename` (`string`, optional): Relative path from project root.
13
- - `projectStructure` (`string`, optional): Project structure in markdown list format.
14
- - `customInstructions` (`string`, optional): Additional instructions.
15
- - `glossaryFile` (`string`, optional): Path to glossary file.
16
- - `relatedFiles` (`string[]`, optional): Absolute filepaths of related docs files.
17
- - `allowDisruptiveChanges` (`boolean`, optional, default: false): Allow major restructuring.
18
- - **Returns:** `{ content: [{ type: "text", text: string }] }`
19
-
20
- ### `improveDocs`
21
-
22
- - **Description:** Improves documentation quality following the Diátaxis framework.
23
- - **Parameters:**
24
- - `filepath` (`string`): Absolute path to the docs file.
25
- - `filename` (`string`, optional): Relative path from project root.
26
- - `projectStructure` (`string`, optional): Project structure in markdown list format.
27
- - `customInstructions` (`string`, optional): Additional instructions.
28
- - `glossaryFile` (`string`, optional): Path to glossary file.
29
- - `relatedFiles` (`string[]`, optional): Absolute filepaths of related docs files.
30
- - `allowDisruptiveChanges` (`boolean`, optional, default: false): Allow major restructuring.
31
- - **Returns:** `{ content: [{ type: "text", text: string }] }`
32
-
33
- ### `editDocs`
34
-
35
- - **Description:** Edits documentation according to the provided plan.
36
- - **Parameters:**
37
- - `filepath` (`string`): Absolute path to the docs file.
38
- - `editPlan` (`string`): Specific changes to be made to the documentation.
39
- - `filename` (`string`, optional): Relative path from project root.
40
- - `projectStructure` (`string`, optional): Project structure in markdown list format.
41
- - `customInstructions` (`string`, optional): Additional instructions.
42
- - `glossaryFile` (`string`, optional): Path to glossary file.
43
- - `relatedFiles` (`string[]`, optional): Absolute filepaths of related docs files.
44
- - **Returns:** `{ content: [{ type: "text", text: string }] }`
45
-
46
- ### `linkifyDocs`
47
-
48
- - **Description:** Improves internal linking to related files and glossary concepts.
49
- - **Parameters:**
50
- - `filepath` (`string`): Absolute path to the docs file.
51
- - `filename` (`string`, optional): Relative path from project root.
52
- - `projectStructure` (`string`, optional): Project structure in markdown list format.
53
- - `customInstructions` (`string`, optional): Additional instructions.
54
- - `glossaryFile` (`string`, optional): Path to glossary file.
55
- - `relatedFiles` (`string[]`, optional): Absolute filepaths of related docs files.
56
- - **Returns:** `{ content: [{ type: "text", text: string }] }`
57
-
58
- ### `auditDocsAgainstCode`
59
-
60
- - **Description:** Audits documentation against the corresponding codebase for accuracy and completeness.
61
- - **Parameters:**
62
- - `docsContentFilePath` (`string`): Absolute path to the docs file to audit.
63
- - `repoUrl` (`string`): GitHub repository URL for the reference source code.
64
- - `projectStructure` (`string`, optional): Project structure in markdown list format.
65
- - `customInstructions` (`string`, optional): Additional instructions.
66
- - **Returns:** `{ content: [{ type: "text", text: string }] }`
67
-
68
- ### `generateReferenceDocs` (Experimental)
69
-
70
- - **Description:** Generates reference documentation for the given codebase/content.
71
- - **Parameters:**
72
- - `referenceSourceCodeFiles` (`string[]`): Remote URLs of the necessary source code files.
73
- - `repoUrl` (`string`, optional): GitHub repository URL.
74
- - `interfaceType` (`"library" | "http" | "mcp" | "cli" | "rpc" | "other"`, optional): Type of interface.
75
- - `relatedFileUrls` (`string[]`, optional): Remote URLs of related code files.
76
- - `projectStructure` (`string`, optional): Project structure in markdown list format.
77
- - `customInstructions` (`string`, optional): Additional instructions.
78
- - `knowledgeBase` (`string`, optional): Higher-level architecture context (not included in output).
79
- - **Returns:** `{ content: [{ type: "text", text: string }] }`
80
- - **Note:** This tool is experimental and disabled by default.
81
-
82
- ----
83
-
84
- ## 2. Node.js Library API
85
-
86
- ### Example Usage
87
-
88
- ```js
89
- const docsAgent = new DocsAgent();
90
- const editedDocsPageContent = await docsAgent.reviewPrioritizeAndEdit(contentToEdit, {
91
- projectStructure: "- src/\n - DocsAgent.js\n - api.js\n - mcp.js\n - LLM.js\n - config/\n - principles.diataxis.js",
92
- customInstructions: "make sure the final output is a hugo markdown file"
93
- });
94
- console.log(editedDocsPageContent);
95
- ```
96
-
97
- ### DocsAgent Class
98
-
99
- The main class for documentation improvement operations.
100
-
101
- #### Constructor
102
-
103
- ```js
104
- new DocsAgent();
105
- ```
106
-
107
- - Initializes a new DocsAgent instance.
108
-
109
- #### Methods
110
-
111
- ##### `reviewPrioritizeAndEdit(content, context = {}, customInstructions, isFileWriteAllowed)`
112
-
113
- - **Description:** Plans and executes the documentation improvement process: review, prioritize, and edit.
114
- - **Parameters:**
115
- - `content` (`string`): The documentation content to improve. If not provided, `context.filepath` is required.
116
- - `context` (`object`):
117
- - `filepath` (`string`): Absolute or relative path to the docs file.
118
- - `filename` (`string`): Name of the docs file.
119
- - `projectStructure` (`string`): Project structure in markdown list format.
120
- - `glossaryFile` (`string`): Path to glossary file for consistent terminology.
121
- - `relatedFiles` (`string[]`): Absolute filepaths to related documentation files.
122
- - `allowDisruptiveChanges` (`boolean`): Allow major restructuring (default: false).
123
- - `customInstructions` (`string`): Additional instructions for the improvement process.
124
- - `isFileWriteAllowed` (`boolean`): If true, saves original and edited files to disk.
125
- - **Returns:** `Promise<string>` (the improved documentation content).
126
-
127
- ##### `review(content, context, customInstructions)`
128
-
129
- - **Description:** Reviews documentation and suggests improvements.
130
- - **Parameters:**
131
- - `content` (`string`): Documentation to review.
132
- - `context` (`object`): Context for the review (see above).
133
- - `customInstructions` (`string`): Additional instructions.
134
- - **Returns:** `Promise<string>` (review summary, rating, suggestions, strengths).
135
-
136
- ##### `prioritize(content, review, context, customInstructions)`
137
-
138
- - **Description:** Breaks down the review into prioritized editing tasks.
139
- - **Parameters:**
140
- - `content` (`string`): Documentation to review.
141
- - `review` (`string`): Review output.
142
- - `context` (`object`): Context for prioritization.
143
- - `customInstructions` (`string`): Additional instructions.
144
- - **Returns:** `Promise<string>` (prioritized editing plan).
145
-
146
- ##### `edit(content, editPlan, context, customInstructions)`
147
-
148
- - **Description:** Edits documentation according to the provided plan.
149
- - **Parameters:**
150
- - `content` (`string`): Documentation to edit.
151
- - `editPlan` (`string`): Editing plan.
152
- - `context` (`object`): Context for editing.
153
- - `customInstructions` (`string`): Additional instructions.
154
- - **Returns:** `Promise<string>` (edited documentation).
155
-
156
- ##### `linkify(content, context, customInstructions)`
157
-
158
- - **Description:** Improves internal linking to related files and glossary concepts.
159
- - **Parameters:**
160
- - `content` (`string`): Documentation to linkify.
161
- - `context` (`object`): Context for linking.
162
- - `customInstructions` (`string`): Additional instructions.
163
- - **Returns:** `Promise<string>` (content with improved links).
164
-
165
- ##### `generateReferenceDocs(referenceSourceCodeFiles, context, customInstructions)`
166
-
167
- - **Description:** Generates reference documentation for the given content.
168
- - **Parameters:**
169
- - `referenceSourceCodeFiles` (`string[]`): Remote URLs of the necessary source code files.
170
- - `context` (`object`): Context for generation.
171
- - `interfaceType` (`string`): Type of interface ("library", "http", "mcp", "cli", "rpc", or "other").
172
- - `repoUrl` (`string`): URL of the repository.
173
- - `projectStructure` (`string`): Project structure in markdown list format.
174
- - `relatedFileUrls` (`string[]`): Remote URLs of related code files.
175
- - `knowledgeBase` (`string`): Higher-level architecture context (not included in output).
176
- - `customInstructions` (`string`): Additional instructions.
177
- - **Returns:** `Promise<string>` (reference documentation).
178
-
179
- ##### `auditDocsAgainstCode(docsContentFilePath, context, customInstructions)`
180
-
181
- - **Description:** Audits documentation against the corresponding codebase for accuracy and completeness.
182
- - **Parameters:**
183
- - `docsContentFilePath` (`string`): Absolute path to the docs file to audit.
184
- - `context` (`object`): Context for the audit.
185
- - `repoUrl` (`string`): GitHub repository URL for the reference source code.
186
- - `projectStructure` (`string`): Project structure in markdown list format.
187
- - `customInstructions` (`string`): Additional instructions.
188
- - **Returns:** `Promise<string>` (audit report with discrepancies and suggestions).
189
-
190
- ---
191
-
192
- ## 3. HTTP API
193
-
194
- The HTTP API is served via Express (default port: 3001).
195
-
196
- ### Endpoints
197
-
198
- #### `POST /review`
199
-
200
- - **Request Body:** `{ content: string, filename?: string }`
201
- - **Response:** Review summary, rating, suggestions, strengths.
202
-
203
- #### `POST /prioritize`
204
-
205
- - **Request Body:** `{ content: string, review: string }`
206
- - **Response:** Prioritized actionable instructions.
207
-
208
- #### `POST /edit`
209
-
210
- - **Request Body:** `{ content: string, editPlan?: string, filename?: string }`
211
- - **Response:** Edited documentation content.
212
-
213
- #### `GET /health`
214
-
215
- - **Response:** Service status, version, uptime, memory, CPU usage.
216
-
217
- ---
218
-
219
- ## Prompts and Principles
220
-
221
- The agent uses a set of configurable prompts and principles (in `src/config/`) to guide its review, prioritization, editing, and linking operations. These include:
222
-
223
- - Diátaxis documentation principles
224
- - Technical accuracy principles
225
- - Writing and formatting style guides
226
- - Linking rules
227
-
228
- ---
229
-
230
- ## Environment Variables
231
-
232
- - `GITHUB_TOKEN` - GitHub personal access token
233
- - `REVIEW_AI_SERVICE` (Default: `gemini`) - AI service to be used for the documentation analysis part e.g. gemini, anthropic, etc.
234
- - `REVIEW_AI_MODEL` (Default: `gemini-2.5-pro-preview-05-06`) - AI model to be used for the documentation analysis part
235
- - `PREFERRED_AI_SERVICE` (Default: `anthropic`) - Preferred AI service
236
- - `PREFERRED_AI_MODEL` (Default: `claude-3-5-sonnet-20240620`) - Preferred AI model
237
- - `GOOGLE_GENERATIVE_AI_API_KEY` - Google AI API key
238
- - `ANTHROPIC_API_KEY` - Anthropic API key
239
- - `OPENAI_API_KEY` - OpenAI API key
240
- - `OLLAMA_API_KEY` - Ollama API key
241
- - `OLLAMA_API_URL` - Ollama API URL
242
- - `API_DISABLED` - Must not be "true" to serve the project as an HTTP API
243
- - `MCP_DISABLED` - Must not be "true" to serve the project as an MCP server
244
- - `MAX_CHANGES` - Maximum number of changes allowed
245
- - `ALLOW_DISRUPTIVE_CHANGES` - Whether to allow disruptive changes
246
- - `MAX_TOKENS` - Maximum tokens for LLM requests
247
-
248
- ---
249
-
250
- ## Folder and File Structure
251
-
252
- - `src/DocsAgent.js`: Main agent logic.
253
- - `src/LLM.js`: LLM interface.
254
- - `src/api.js`: HTTP API server.
255
- - `src/mcp.js`: MCP server and tool definitions.
256
- - `src/config/`: Prompts, principles, and configuration.
257
- - `test/`: Tests and fixtures.
258
- - `docs/`: Documentation.