@gitpagedocs/tools 1.1.62 → 1.1.63
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/README.md +33 -33
- package/package.json +1 -1
- package/src/ai/bootstrap.ts +50 -50
- package/src/ai/catalog.ts +188 -188
- package/src/ai/factory.ts +14 -14
- package/src/ai/http/streaming.ts +60 -60
- package/src/ai/index.ts +27 -27
- package/src/ai/legacy-adapter.ts +33 -33
- package/src/ai/model-registry.ts +13 -13
- package/src/ai/providers/anthropic-provider.ts +83 -83
- package/src/ai/providers/cohere-provider.ts +66 -66
- package/src/ai/providers/gemini-provider.ts +84 -84
- package/src/ai/providers/ollama-provider.ts +69 -69
- package/src/ai/providers/openai-compatible-provider.ts +75 -75
- package/src/ai/providers/shared.ts +72 -72
- package/src/ai/registry.ts +29 -29
- package/src/cache/file-cache.ts +86 -86
- package/src/cache/index.ts +9 -9
- package/src/cache/memory-cache.ts +47 -47
- package/src/cache/web-storage-cache.ts +91 -91
- package/src/config/config-loader.ts +59 -59
- package/src/config/index.ts +1 -1
- package/src/constants/config.ts +8 -8
- package/src/constants/index.ts +1 -1
- package/src/crypto/doc-access.ts +62 -62
- package/src/crypto/index.ts +4 -4
- package/src/crypto/node-crypto-service.ts +87 -87
- package/src/crypto/web-crypto-service.ts +102 -102
- package/src/crypto/web.ts +4 -4
- package/src/documentation/doc-generator.ts +74 -74
- package/src/documentation/doc-updater.ts +47 -47
- package/src/documentation/index.ts +18 -18
- package/src/documentation/marker-patcher.ts +33 -33
- package/src/documentation/sections.ts +84 -84
- package/src/errors/app-error.ts +84 -84
- package/src/errors/index.ts +1 -1
- package/src/filesystem/file-service.ts +121 -121
- package/src/filesystem/index.ts +2 -2
- package/src/index.ts +25 -25
- package/src/logger/index.ts +2 -2
- package/src/logger/logger.ts +73 -73
- package/src/logger/redaction.ts +43 -43
- package/src/platform/index.ts +1 -1
- package/src/platform/user-config-dir.ts +48 -48
- package/src/ports/ai.ts +109 -109
- package/src/ports/cache.ts +16 -16
- package/src/ports/config.ts +21 -21
- package/src/ports/crypto.ts +33 -33
- package/src/ports/index.ts +15 -15
- package/src/ports/logger.ts +23 -23
- package/src/ports/security.ts +42 -42
- package/src/security/credential-vault.ts +117 -117
- package/src/security/file-vault-storage.ts +25 -25
- package/src/security/index.ts +8 -8
- package/src/security/migrate-plaintext-key.ts +38 -38
- package/src/security/password-gate.ts +62 -62
- package/src/security/web-storage-vault-storage.ts +23 -23
- package/src/security/web.ts +9 -9
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import type { AIProvider, GenerateRequest, ProviderConfig } from "../ports/ai";
|
|
2
|
-
|
|
3
|
-
/** Documentation artifact kinds the generator can produce. */
|
|
4
|
-
export type DocKind =
|
|
5
|
-
| "readme"
|
|
6
|
-
| "changelog"
|
|
7
|
-
| "release-notes"
|
|
8
|
-
| "api"
|
|
9
|
-
| "architecture"
|
|
10
|
-
| "database"
|
|
11
|
-
| "documentation"
|
|
12
|
-
| "update"
|
|
13
|
-
| "analyze-repository"
|
|
14
|
-
| "analyze-project"
|
|
15
|
-
| "analyze-source"
|
|
16
|
-
| "validate";
|
|
17
|
-
|
|
18
|
-
const BASE_SYSTEM =
|
|
19
|
-
"You are a senior staff engineer and technical writer. Produce precise, " +
|
|
20
|
-
"well-structured GitHub-flavored Markdown. Be accurate to the provided source; " +
|
|
21
|
-
"never invent APIs, files, or behavior that is not present in the input.";
|
|
22
|
-
|
|
23
|
-
const KIND_SYSTEM: Record<DocKind, string> = {
|
|
24
|
-
readme: "Generate a complete README.md: title, summary, features, install, usage, configuration, and license.",
|
|
25
|
-
changelog: "Produce a Keep a Changelog style CHANGELOG entry grouping changes under Added/Changed/Fixed/Removed.",
|
|
26
|
-
"release-notes": "Write concise, user-facing release notes highlighting notable changes and breaking changes.",
|
|
27
|
-
api: "Generate API reference documentation for the exported functions, classes, and types in the input.",
|
|
28
|
-
architecture: "Describe the architecture: layers, modules, data flow, and key design decisions. Use diagrams in text form where helpful.",
|
|
29
|
-
database: "Document the data model: entities, fields, relationships, and constraints inferred from the input.",
|
|
30
|
-
documentation: "Generate clear developer documentation for the provided code.",
|
|
31
|
-
update: "Update the existing documentation to reflect the provided source changes, preserving correct content.",
|
|
32
|
-
"analyze-repository": "Analyze the repository structure and summarize purpose, stack, modules, and notable patterns.",
|
|
33
|
-
"analyze-project": "Analyze the project and summarize architecture, dependencies, and areas of risk or improvement.",
|
|
34
|
-
"analyze-source": "Analyze the provided source code: responsibilities, complexity, issues, and suggestions.",
|
|
35
|
-
validate: "Review the documentation for accuracy, completeness, broken references, and gaps. Return a findings list.",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export interface GenerateDocInput {
|
|
39
|
-
readonly kind: DocKind;
|
|
40
|
-
/** Source/context material (file listing, code, existing docs, …). */
|
|
41
|
-
readonly context: string;
|
|
42
|
-
/** Optional extra user instructions. */
|
|
43
|
-
readonly instructions?: string;
|
|
44
|
-
readonly signal?: AbortSignal;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Generates documentation by composing a kind-specific prompt and delegating to
|
|
49
|
-
* any AIProvider. The single place documentation prompts live, shared by the
|
|
50
|
-
* CLI, MCP and frontend.
|
|
51
|
-
*/
|
|
52
|
-
export class DocumentationService {
|
|
53
|
-
constructor(
|
|
54
|
-
private readonly provider: AIProvider,
|
|
55
|
-
private readonly config: ProviderConfig,
|
|
56
|
-
) {}
|
|
57
|
-
|
|
58
|
-
buildRequest(input: GenerateDocInput): GenerateRequest {
|
|
59
|
-
const system = `${BASE_SYSTEM}\n${KIND_SYSTEM[input.kind]}`;
|
|
60
|
-
const userParts = [input.instructions, "--- INPUT ---", input.context].filter(Boolean);
|
|
61
|
-
return {
|
|
62
|
-
system,
|
|
63
|
-
messages: [{ role: "user", content: userParts.join("\n\n") }],
|
|
64
|
-
temperature: 0.2,
|
|
65
|
-
maxTokens: 4000,
|
|
66
|
-
signal: input.signal,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async generate(input: GenerateDocInput): Promise<string> {
|
|
71
|
-
const response = await this.provider.generate(this.buildRequest(input), this.config);
|
|
72
|
-
return response.text;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
import type { AIProvider, GenerateRequest, ProviderConfig } from "../ports/ai";
|
|
2
|
+
|
|
3
|
+
/** Documentation artifact kinds the generator can produce. */
|
|
4
|
+
export type DocKind =
|
|
5
|
+
| "readme"
|
|
6
|
+
| "changelog"
|
|
7
|
+
| "release-notes"
|
|
8
|
+
| "api"
|
|
9
|
+
| "architecture"
|
|
10
|
+
| "database"
|
|
11
|
+
| "documentation"
|
|
12
|
+
| "update"
|
|
13
|
+
| "analyze-repository"
|
|
14
|
+
| "analyze-project"
|
|
15
|
+
| "analyze-source"
|
|
16
|
+
| "validate";
|
|
17
|
+
|
|
18
|
+
const BASE_SYSTEM =
|
|
19
|
+
"You are a senior staff engineer and technical writer. Produce precise, " +
|
|
20
|
+
"well-structured GitHub-flavored Markdown. Be accurate to the provided source; " +
|
|
21
|
+
"never invent APIs, files, or behavior that is not present in the input.";
|
|
22
|
+
|
|
23
|
+
const KIND_SYSTEM: Record<DocKind, string> = {
|
|
24
|
+
readme: "Generate a complete README.md: title, summary, features, install, usage, configuration, and license.",
|
|
25
|
+
changelog: "Produce a Keep a Changelog style CHANGELOG entry grouping changes under Added/Changed/Fixed/Removed.",
|
|
26
|
+
"release-notes": "Write concise, user-facing release notes highlighting notable changes and breaking changes.",
|
|
27
|
+
api: "Generate API reference documentation for the exported functions, classes, and types in the input.",
|
|
28
|
+
architecture: "Describe the architecture: layers, modules, data flow, and key design decisions. Use diagrams in text form where helpful.",
|
|
29
|
+
database: "Document the data model: entities, fields, relationships, and constraints inferred from the input.",
|
|
30
|
+
documentation: "Generate clear developer documentation for the provided code.",
|
|
31
|
+
update: "Update the existing documentation to reflect the provided source changes, preserving correct content.",
|
|
32
|
+
"analyze-repository": "Analyze the repository structure and summarize purpose, stack, modules, and notable patterns.",
|
|
33
|
+
"analyze-project": "Analyze the project and summarize architecture, dependencies, and areas of risk or improvement.",
|
|
34
|
+
"analyze-source": "Analyze the provided source code: responsibilities, complexity, issues, and suggestions.",
|
|
35
|
+
validate: "Review the documentation for accuracy, completeness, broken references, and gaps. Return a findings list.",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface GenerateDocInput {
|
|
39
|
+
readonly kind: DocKind;
|
|
40
|
+
/** Source/context material (file listing, code, existing docs, …). */
|
|
41
|
+
readonly context: string;
|
|
42
|
+
/** Optional extra user instructions. */
|
|
43
|
+
readonly instructions?: string;
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generates documentation by composing a kind-specific prompt and delegating to
|
|
49
|
+
* any AIProvider. The single place documentation prompts live, shared by the
|
|
50
|
+
* CLI, MCP and frontend.
|
|
51
|
+
*/
|
|
52
|
+
export class DocumentationService {
|
|
53
|
+
constructor(
|
|
54
|
+
private readonly provider: AIProvider,
|
|
55
|
+
private readonly config: ProviderConfig,
|
|
56
|
+
) {}
|
|
57
|
+
|
|
58
|
+
buildRequest(input: GenerateDocInput): GenerateRequest {
|
|
59
|
+
const system = `${BASE_SYSTEM}\n${KIND_SYSTEM[input.kind]}`;
|
|
60
|
+
const userParts = [input.instructions, "--- INPUT ---", input.context].filter(Boolean);
|
|
61
|
+
return {
|
|
62
|
+
system,
|
|
63
|
+
messages: [{ role: "user", content: userParts.join("\n\n") }],
|
|
64
|
+
temperature: 0.2,
|
|
65
|
+
maxTokens: 4000,
|
|
66
|
+
signal: input.signal,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async generate(input: GenerateDocInput): Promise<string> {
|
|
71
|
+
const response = await this.provider.generate(this.buildRequest(input), this.config);
|
|
72
|
+
return response.text;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import type { FileService } from "../filesystem/file-service";
|
|
2
|
-
import { patchManagedRegion } from "./marker-patcher";
|
|
3
|
-
|
|
4
|
-
export interface ManagedUpdate {
|
|
5
|
-
/** Target file relative to the project root. */
|
|
6
|
-
readonly path: string;
|
|
7
|
-
/** Generated content for the managed region (markers added automatically). */
|
|
8
|
-
readonly generated: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface UpdateResult {
|
|
12
|
-
readonly path: string;
|
|
13
|
-
/** True if an existing managed region was replaced (vs appended). */
|
|
14
|
-
readonly replaced: boolean;
|
|
15
|
-
/** True if the file content actually changed (idempotent re-runs are false). */
|
|
16
|
-
readonly changed: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Updates only the managed region of documentation files, preserving manual
|
|
21
|
-
* content. Idempotent: re-running with identical generated content leaves files
|
|
22
|
-
* untouched (`changed: false`). Built on patchManagedRegion + FileService.
|
|
23
|
-
*/
|
|
24
|
-
export class DocUpdater {
|
|
25
|
-
constructor(private readonly files: FileService) {}
|
|
26
|
-
|
|
27
|
-
async updateManagedFile(path: string, generated: string): Promise<UpdateResult> {
|
|
28
|
-
let existing = "";
|
|
29
|
-
try {
|
|
30
|
-
existing = await this.files.read(path, 2_000_000);
|
|
31
|
-
} catch {
|
|
32
|
-
existing = "";
|
|
33
|
-
}
|
|
34
|
-
const { content, replaced } = patchManagedRegion(existing, generated);
|
|
35
|
-
const changed = content !== existing;
|
|
36
|
-
if (changed) await this.files.write(path, content);
|
|
37
|
-
return { path, replaced, changed };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async updateManagedFiles(updates: ManagedUpdate[]): Promise<UpdateResult[]> {
|
|
41
|
-
const results: UpdateResult[] = [];
|
|
42
|
-
for (const update of updates) {
|
|
43
|
-
results.push(await this.updateManagedFile(update.path, update.generated));
|
|
44
|
-
}
|
|
45
|
-
return results;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
import type { FileService } from "../filesystem/file-service";
|
|
2
|
+
import { patchManagedRegion } from "./marker-patcher";
|
|
3
|
+
|
|
4
|
+
export interface ManagedUpdate {
|
|
5
|
+
/** Target file relative to the project root. */
|
|
6
|
+
readonly path: string;
|
|
7
|
+
/** Generated content for the managed region (markers added automatically). */
|
|
8
|
+
readonly generated: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface UpdateResult {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
/** True if an existing managed region was replaced (vs appended). */
|
|
14
|
+
readonly replaced: boolean;
|
|
15
|
+
/** True if the file content actually changed (idempotent re-runs are false). */
|
|
16
|
+
readonly changed: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Updates only the managed region of documentation files, preserving manual
|
|
21
|
+
* content. Idempotent: re-running with identical generated content leaves files
|
|
22
|
+
* untouched (`changed: false`). Built on patchManagedRegion + FileService.
|
|
23
|
+
*/
|
|
24
|
+
export class DocUpdater {
|
|
25
|
+
constructor(private readonly files: FileService) {}
|
|
26
|
+
|
|
27
|
+
async updateManagedFile(path: string, generated: string): Promise<UpdateResult> {
|
|
28
|
+
let existing = "";
|
|
29
|
+
try {
|
|
30
|
+
existing = await this.files.read(path, 2_000_000);
|
|
31
|
+
} catch {
|
|
32
|
+
existing = "";
|
|
33
|
+
}
|
|
34
|
+
const { content, replaced } = patchManagedRegion(existing, generated);
|
|
35
|
+
const changed = content !== existing;
|
|
36
|
+
if (changed) await this.files.write(path, content);
|
|
37
|
+
return { path, replaced, changed };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async updateManagedFiles(updates: ManagedUpdate[]): Promise<UpdateResult[]> {
|
|
41
|
+
const results: UpdateResult[] = [];
|
|
42
|
+
for (const update of updates) {
|
|
43
|
+
results.push(await this.updateManagedFile(update.path, update.generated));
|
|
44
|
+
}
|
|
45
|
+
return results;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { DocumentationService } from "./doc-generator";
|
|
2
|
-
export type { DocKind, GenerateDocInput } from "./doc-generator";
|
|
3
|
-
export {
|
|
4
|
-
patchManagedRegion,
|
|
5
|
-
START_MARKER,
|
|
6
|
-
END_MARKER,
|
|
7
|
-
} from "./marker-patcher";
|
|
8
|
-
export type { PatchResult } from "./marker-patcher";
|
|
9
|
-
export { DocUpdater } from "./doc-updater";
|
|
10
|
-
export type { ManagedUpdate, UpdateResult } from "./doc-updater";
|
|
11
|
-
export {
|
|
12
|
-
providersSection,
|
|
13
|
-
cliCommandsSection,
|
|
14
|
-
devWorkflowSection,
|
|
15
|
-
securityNoteSection,
|
|
16
|
-
CLI_COMMANDS,
|
|
17
|
-
} from "./sections";
|
|
18
|
-
export type { CommandDoc } from "./sections";
|
|
1
|
+
export { DocumentationService } from "./doc-generator";
|
|
2
|
+
export type { DocKind, GenerateDocInput } from "./doc-generator";
|
|
3
|
+
export {
|
|
4
|
+
patchManagedRegion,
|
|
5
|
+
START_MARKER,
|
|
6
|
+
END_MARKER,
|
|
7
|
+
} from "./marker-patcher";
|
|
8
|
+
export type { PatchResult } from "./marker-patcher";
|
|
9
|
+
export { DocUpdater } from "./doc-updater";
|
|
10
|
+
export type { ManagedUpdate, UpdateResult } from "./doc-updater";
|
|
11
|
+
export {
|
|
12
|
+
providersSection,
|
|
13
|
+
cliCommandsSection,
|
|
14
|
+
devWorkflowSection,
|
|
15
|
+
securityNoteSection,
|
|
16
|
+
CLI_COMMANDS,
|
|
17
|
+
} from "./sections";
|
|
18
|
+
export type { CommandDoc } from "./sections";
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotent marker-based content patcher. Only the region between the markers
|
|
3
|
-
* is rewritten; manual content outside is preserved. Used by update flows and
|
|
4
|
-
* the Phase 9 documentation automation.
|
|
5
|
-
*/
|
|
6
|
-
export const START_MARKER = "<!-- gitpagedocs:start -->";
|
|
7
|
-
export const END_MARKER = "<!-- gitpagedocs:end -->";
|
|
8
|
-
|
|
9
|
-
export interface PatchResult {
|
|
10
|
-
readonly content: string;
|
|
11
|
-
/** True when an existing managed region was replaced (vs appended). */
|
|
12
|
-
readonly replaced: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Replace the managed region in `existing` with `generated`. If no markers are
|
|
17
|
-
* present, the managed block is appended. Re-running with the same generated
|
|
18
|
-
* content yields identical output (idempotent).
|
|
19
|
-
*/
|
|
20
|
-
export function patchManagedRegion(existing: string, generated: string): PatchResult {
|
|
21
|
-
const block = `${START_MARKER}\n${generated.trim()}\n${END_MARKER}`;
|
|
22
|
-
const startIdx = existing.indexOf(START_MARKER);
|
|
23
|
-
const endIdx = existing.indexOf(END_MARKER);
|
|
24
|
-
|
|
25
|
-
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
26
|
-
const before = existing.slice(0, startIdx);
|
|
27
|
-
const after = existing.slice(endIdx + END_MARKER.length);
|
|
28
|
-
return { content: `${before}${block}${after}`, replaced: true };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const separator = existing.trim() ? `${existing.replace(/\s+$/, "")}\n\n` : "";
|
|
32
|
-
return { content: `${separator}${block}\n`, replaced: false };
|
|
33
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Idempotent marker-based content patcher. Only the region between the markers
|
|
3
|
+
* is rewritten; manual content outside is preserved. Used by update flows and
|
|
4
|
+
* the Phase 9 documentation automation.
|
|
5
|
+
*/
|
|
6
|
+
export const START_MARKER = "<!-- gitpagedocs:start -->";
|
|
7
|
+
export const END_MARKER = "<!-- gitpagedocs:end -->";
|
|
8
|
+
|
|
9
|
+
export interface PatchResult {
|
|
10
|
+
readonly content: string;
|
|
11
|
+
/** True when an existing managed region was replaced (vs appended). */
|
|
12
|
+
readonly replaced: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Replace the managed region in `existing` with `generated`. If no markers are
|
|
17
|
+
* present, the managed block is appended. Re-running with the same generated
|
|
18
|
+
* content yields identical output (idempotent).
|
|
19
|
+
*/
|
|
20
|
+
export function patchManagedRegion(existing: string, generated: string): PatchResult {
|
|
21
|
+
const block = `${START_MARKER}\n${generated.trim()}\n${END_MARKER}`;
|
|
22
|
+
const startIdx = existing.indexOf(START_MARKER);
|
|
23
|
+
const endIdx = existing.indexOf(END_MARKER);
|
|
24
|
+
|
|
25
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
26
|
+
const before = existing.slice(0, startIdx);
|
|
27
|
+
const after = existing.slice(endIdx + END_MARKER.length);
|
|
28
|
+
return { content: `${before}${block}${after}`, replaced: true };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const separator = existing.trim() ? `${existing.replace(/\s+$/, "")}\n\n` : "";
|
|
32
|
+
return { content: `${separator}${block}\n`, replaced: false };
|
|
33
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { PROVIDER_CATALOG, ALL_PROVIDER_IDS } from "../ai/catalog";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Deterministic documentation section generators. Pure functions over the
|
|
5
|
-
* static catalog/command data, so the managed regions they produce are stable
|
|
6
|
-
* across runs (idempotent) and require no AI call.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/** Markdown table of supported AI providers and their default models. */
|
|
10
|
-
export function providersSection(): string {
|
|
11
|
-
const header = "| Provider | ID | Default model | Capabilities |\n| --- | --- | --- | --- |";
|
|
12
|
-
const rows = ALL_PROVIDER_IDS.map((id) => {
|
|
13
|
-
const spec = PROVIDER_CATALOG[id];
|
|
14
|
-
const caps = [
|
|
15
|
-
spec.capabilities.streaming ? "stream" : null,
|
|
16
|
-
spec.capabilities.vision ? "vision" : null,
|
|
17
|
-
spec.capabilities.audio ? "audio" : null,
|
|
18
|
-
]
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
.join(", ");
|
|
21
|
-
return `| ${spec.label} | \`${id}\` | \`${spec.defaultModel}\` | ${caps || "text"} |`;
|
|
22
|
-
});
|
|
23
|
-
return [`### Supported AI providers (${ALL_PROVIDER_IDS.length})`, "", header, ...rows].join("\n");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface CommandDoc {
|
|
27
|
-
readonly name: string;
|
|
28
|
-
readonly summary: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Markdown list of CLI commands. */
|
|
32
|
-
export function cliCommandsSection(commands: readonly CommandDoc[]): string {
|
|
33
|
-
const items = commands.map((c) => `- \`gitpagedocs ${c.name}\` — ${c.summary}`);
|
|
34
|
-
return ["### CLI commands", "", ...items].join("\n");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Markdown block documenting the monorepo dev workflow (deterministic). */
|
|
38
|
-
export function devWorkflowSection(): string {
|
|
39
|
-
const cmds = [
|
|
40
|
-
["pnpm install", "install workspace dependencies"],
|
|
41
|
-
["pnpm run typecheck", "type-check frontend + tools + mcp"],
|
|
42
|
-
["pnpm run lint", "lint the project"],
|
|
43
|
-
["pnpm run test:unit", "run the Vitest unit/integration suite"],
|
|
44
|
-
["pnpm run test:cov", "unit tests with coverage"],
|
|
45
|
-
["pnpm run test:e2e", "Playwright frontend E2E"],
|
|
46
|
-
["pnpm run smoke:all", "CLI/contract/tools/mcp regression wall"],
|
|
47
|
-
["pnpm run build", "build the static site"],
|
|
48
|
-
];
|
|
49
|
-
return [
|
|
50
|
-
"### Development",
|
|
51
|
-
"",
|
|
52
|
-
"This is a pnpm + turbo monorepo: `frontend/` (Next.js viewer), `cli/` (the published `gitpagedocs` npm package), `tools/` (`@gitpagedocs/tools` shared core), and `mcp/` (`@gitpagedocs/mcp` server).",
|
|
53
|
-
"",
|
|
54
|
-
...cmds.map(([c, d]) => `- \`${c}\` — ${d}`),
|
|
55
|
-
].join("\n");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Markdown block summarizing how API keys are handled (deterministic). */
|
|
59
|
-
export function securityNoteSection(): string {
|
|
60
|
-
return [
|
|
61
|
-
"### API key handling",
|
|
62
|
-
"",
|
|
63
|
-
"- API keys are stored **encrypted at rest** (AES-256-GCM) behind a local password — never in plaintext.",
|
|
64
|
-
"- The password gates sensitive operations and is held only in memory for the session.",
|
|
65
|
-
"- Keys are **never logged** (the logger redacts secrets) and are sent only to the AI provider you select.",
|
|
66
|
-
"- To report a vulnerability, open a security advisory or issue on the repository.",
|
|
67
|
-
].join("\n");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** The canonical command list for the documentation (legacy + new verbs). */
|
|
71
|
-
export const CLI_COMMANDS: readonly CommandDoc[] = [
|
|
72
|
-
{ name: "init", summary: "scaffold gitpagedocs config files" },
|
|
73
|
-
{ name: "config", summary: "show the resolved gitpagedocs config" },
|
|
74
|
-
{ name: "provider [id]", summary: "list AI providers or show one" },
|
|
75
|
-
{ name: "models [provider]", summary: "list catalog models" },
|
|
76
|
-
{ name: "ai", summary: "interactive AI docs generator (writes pages in the gitpagedocs pattern)" },
|
|
77
|
-
{ name: "document[:repo|:file|:folder]", summary: "generate documentation with AI in the gitpagedocs pattern" },
|
|
78
|
-
{ name: "password", summary: "set a documentation access password (writes the public key to config.json)" },
|
|
79
|
-
{ name: "deploy | pages", summary: "configure GitHub Pages via Actions and push" },
|
|
80
|
-
{ name: "doctor", summary: "diagnose the environment" },
|
|
81
|
-
{ name: "mcp start", summary: "start the MCP server over stdio" },
|
|
82
|
-
{ name: "version", summary: "print the CLI version" },
|
|
83
|
-
{ name: "update", summary: "check the registry for a newer CLI and print the install command" },
|
|
84
|
-
];
|
|
1
|
+
import { PROVIDER_CATALOG, ALL_PROVIDER_IDS } from "../ai/catalog";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deterministic documentation section generators. Pure functions over the
|
|
5
|
+
* static catalog/command data, so the managed regions they produce are stable
|
|
6
|
+
* across runs (idempotent) and require no AI call.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Markdown table of supported AI providers and their default models. */
|
|
10
|
+
export function providersSection(): string {
|
|
11
|
+
const header = "| Provider | ID | Default model | Capabilities |\n| --- | --- | --- | --- |";
|
|
12
|
+
const rows = ALL_PROVIDER_IDS.map((id) => {
|
|
13
|
+
const spec = PROVIDER_CATALOG[id];
|
|
14
|
+
const caps = [
|
|
15
|
+
spec.capabilities.streaming ? "stream" : null,
|
|
16
|
+
spec.capabilities.vision ? "vision" : null,
|
|
17
|
+
spec.capabilities.audio ? "audio" : null,
|
|
18
|
+
]
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.join(", ");
|
|
21
|
+
return `| ${spec.label} | \`${id}\` | \`${spec.defaultModel}\` | ${caps || "text"} |`;
|
|
22
|
+
});
|
|
23
|
+
return [`### Supported AI providers (${ALL_PROVIDER_IDS.length})`, "", header, ...rows].join("\n");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CommandDoc {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly summary: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Markdown list of CLI commands. */
|
|
32
|
+
export function cliCommandsSection(commands: readonly CommandDoc[]): string {
|
|
33
|
+
const items = commands.map((c) => `- \`gitpagedocs ${c.name}\` — ${c.summary}`);
|
|
34
|
+
return ["### CLI commands", "", ...items].join("\n");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Markdown block documenting the monorepo dev workflow (deterministic). */
|
|
38
|
+
export function devWorkflowSection(): string {
|
|
39
|
+
const cmds = [
|
|
40
|
+
["pnpm install", "install workspace dependencies"],
|
|
41
|
+
["pnpm run typecheck", "type-check frontend + tools + mcp"],
|
|
42
|
+
["pnpm run lint", "lint the project"],
|
|
43
|
+
["pnpm run test:unit", "run the Vitest unit/integration suite"],
|
|
44
|
+
["pnpm run test:cov", "unit tests with coverage"],
|
|
45
|
+
["pnpm run test:e2e", "Playwright frontend E2E"],
|
|
46
|
+
["pnpm run smoke:all", "CLI/contract/tools/mcp regression wall"],
|
|
47
|
+
["pnpm run build", "build the static site"],
|
|
48
|
+
];
|
|
49
|
+
return [
|
|
50
|
+
"### Development",
|
|
51
|
+
"",
|
|
52
|
+
"This is a pnpm + turbo monorepo: `frontend/` (Next.js viewer), `cli/` (the published `gitpagedocs` npm package), `tools/` (`@gitpagedocs/tools` shared core), and `mcp/` (`@gitpagedocs/mcp` server).",
|
|
53
|
+
"",
|
|
54
|
+
...cmds.map(([c, d]) => `- \`${c}\` — ${d}`),
|
|
55
|
+
].join("\n");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Markdown block summarizing how API keys are handled (deterministic). */
|
|
59
|
+
export function securityNoteSection(): string {
|
|
60
|
+
return [
|
|
61
|
+
"### API key handling",
|
|
62
|
+
"",
|
|
63
|
+
"- API keys are stored **encrypted at rest** (AES-256-GCM) behind a local password — never in plaintext.",
|
|
64
|
+
"- The password gates sensitive operations and is held only in memory for the session.",
|
|
65
|
+
"- Keys are **never logged** (the logger redacts secrets) and are sent only to the AI provider you select.",
|
|
66
|
+
"- To report a vulnerability, open a security advisory or issue on the repository.",
|
|
67
|
+
].join("\n");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The canonical command list for the documentation (legacy + new verbs). */
|
|
71
|
+
export const CLI_COMMANDS: readonly CommandDoc[] = [
|
|
72
|
+
{ name: "init", summary: "scaffold gitpagedocs config files" },
|
|
73
|
+
{ name: "config", summary: "show the resolved gitpagedocs config" },
|
|
74
|
+
{ name: "provider [id]", summary: "list AI providers or show one" },
|
|
75
|
+
{ name: "models [provider]", summary: "list catalog models" },
|
|
76
|
+
{ name: "ai", summary: "interactive AI docs generator (writes pages in the gitpagedocs pattern)" },
|
|
77
|
+
{ name: "document[:repo|:file|:folder]", summary: "generate documentation with AI in the gitpagedocs pattern" },
|
|
78
|
+
{ name: "password", summary: "set a documentation access password (writes the public key to config.json)" },
|
|
79
|
+
{ name: "deploy | pages", summary: "configure GitHub Pages via Actions and push" },
|
|
80
|
+
{ name: "doctor", summary: "diagnose the environment" },
|
|
81
|
+
{ name: "mcp start", summary: "start the MCP server over stdio" },
|
|
82
|
+
{ name: "version", summary: "print the CLI version" },
|
|
83
|
+
{ name: "update", summary: "check the registry for a newer CLI and print the install command" },
|
|
84
|
+
];
|