Skip to content

Commit c4e886d

Browse files
Consolidate SecretRef documentation generators and preserve auth-profiles targets subsection structure
1 parent 4b839dc commit c4e886d

4 files changed

Lines changed: 123 additions & 113 deletions

File tree

‎docs/reference/secretref-credential-surface.md‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ Scope intent:
5656
- `channels.qqbot.clientSecret`
5757
- `channels.slack.accounts.*.appToken`
5858
- `channels.slack.accounts.*.botToken`
59+
- `channels.slack.accounts.*.relay.authToken`
5960
- `channels.slack.accounts.*.signingSecret`
6061
- `channels.slack.accounts.*.userToken`
6162
- `channels.slack.appToken`
6263
- `channels.slack.botToken`
64+
- `channels.slack.relay.authToken`
6365
- `channels.slack.signingSecret`
6466
- `channels.slack.userToken`
67+
- `channels.sms.accounts.*.authToken`
68+
- `channels.sms.authToken`
6569
- `channels.telegram.accounts.*.botToken`
6670
- `channels.telegram.accounts.*.webhookSecret`
6771
- `channels.telegram.botToken`
@@ -91,26 +95,34 @@ Scope intent:
9195
- `models.providers.*.request.tls.passphrase`
9296
- `plugins.entries.acpx.config.mcpServers.*.env.*`
9397
- `plugins.entries.brave.config.webSearch.apiKey`
98+
- `plugins.entries.codex.config.appServer.authToken`
99+
- `plugins.entries.codex.config.appServer.headers.*`
94100
- `plugins.entries.exa.config.webSearch.apiKey`
95101
- `plugins.entries.firecrawl.config.webSearch.apiKey`
102+
- `plugins.entries.google-meet.config.realtime.providers.*.apiKey`
96103
- `plugins.entries.google.config.webSearch.apiKey`
97104
- `plugins.entries.minimax.config.webSearch.apiKey`
98105
- `plugins.entries.moonshot.config.webSearch.apiKey`
106+
- `plugins.entries.parallel.config.webSearch.apiKey`
99107
- `plugins.entries.perplexity.config.webSearch.apiKey`
100108
- `plugins.entries.tavily.config.webSearch.apiKey`
101109
- `plugins.entries.voice-call.config.realtime.providers.*.apiKey`
102110
- `plugins.entries.voice-call.config.streaming.providers.*.apiKey`
103111
- `plugins.entries.voice-call.config.tts.providers.*.apiKey`
104112
- `plugins.entries.voice-call.config.twilio.authToken`
105113
- `plugins.entries.xai.config.webSearch.apiKey`
106-
- `profiles.*.keyRef` (`type: "api_key"`; unsupported when `auth.profiles.<id>.mode = "oauth"`)
107-
- `profiles.*.tokenRef` (`type: "token"`; unsupported when `auth.profiles.<id>.mode = "oauth"`)
108114
- `skills.entries.*.apiKey`
109115
- `talk.providers.*.apiKey`
116+
- `talk.realtime.providers.*.apiKey`
110117
- `tools.web.fetch.firecrawl.apiKey`
111118
- `tools.web.search.*.apiKey`
112119
- `tools.web.search.apiKey`
113120

121+
### `auth-profiles.json` targets (`secrets configure` + `secrets apply` + `secrets audit`)
122+
123+
- `profiles.*.keyRef` (`type: "api_key"`; unsupported when `auth.profiles.<id>.mode = "oauth"`)
124+
- `profiles.*.tokenRef` (`type: "token"`; unsupported when `auth.profiles.<id>.mode = "oauth"`)
125+
114126
[//]: # "secretref-supported-list-end"
115127

116128
Notes:

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,8 +1520,8 @@
15201520
"check:architecture": "pnpm check:import-cycles && pnpm check:madge-import-cycles && pnpm check:deprecated-api-usage && pnpm check:deprecated-jsdoc && pnpm db:kysely:check && pnpm lint:kysely && pnpm check:database-first-legacy-stores",
15211521
"check:base-config-schema": "node --import tsx scripts/generate-base-config-schema.ts --check",
15221522
"check:bundled-channel-config-metadata": "node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check",
1523-
"secretref:docs:check": "node --import tsx scripts/generate-secretref-docs.ts --check",
1524-
"secretref:docs:gen": "node --import tsx scripts/generate-secretref-docs.ts --write",
1523+
"secretref:docs:check": "node --import tsx scripts/generate-secretref-credential-matrix.ts --check",
1524+
"secretref:docs:gen": "node --import tsx scripts/generate-secretref-credential-matrix.ts --write",
15251525
"check:changed": "node scripts/check-changed.mjs",
15261526
"check:changelog-attributions": "node scripts/check-changelog-attributions.mjs",
15271527
"check:database-first-legacy-stores": "node scripts/check-database-first-legacy-stores.mjs",

‎scripts/generate-secretref-credential-matrix.ts‎

Lines changed: 107 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,112 @@ import fs from "node:fs";
33
import path from "node:path";
44
import { buildSecretRefCredentialMatrix } from "../src/secrets/credential-matrix.js";
55

6-
const outputPath = path.join(
7-
process.cwd(),
8-
"docs",
9-
"reference",
10-
"secretref-user-supplied-credentials-matrix.json",
6+
const CHECK = process.argv.includes("--check");
7+
const WRITE = process.argv.includes("--write") || !CHECK; // Default to write mode if --check is not specified
8+
9+
const ROOT = path.resolve(import.meta.dirname, "..");
10+
11+
const matrixPath = path.join(ROOT, "docs", "reference", "secretref-user-supplied-credentials-matrix.json");
12+
const surfacePath = path.join(ROOT, "docs", "reference", "secretref-credential-surface.md");
13+
14+
const matrixData = buildSecretRefCredentialMatrix();
15+
const matrixJson = JSON.stringify(matrixData, null, 2) + "\n";
16+
17+
// Load original markdown file
18+
const originalSurface = fs.readFileSync(surfacePath, "utf8");
19+
20+
// Parse current lines to preserve comments/descriptions
21+
const lineMap = new Map<string, string>();
22+
for (const line of originalSurface.split(/\r?\n/)) {
23+
const match = line.match(/^- `([^`]+)`/);
24+
if (match) {
25+
lineMap.set(match[1], line);
26+
}
27+
}
28+
29+
// Separate keys by config file
30+
const openclawJsonKeys = matrixData.entries
31+
.filter((entry) => entry.configFile === "openclaw.json")
32+
.map((entry) => entry.path);
33+
34+
const authProfilesJsonKeys = matrixData.entries
35+
.filter((entry) => entry.configFile === "auth-profiles.json")
36+
.map((entry) => entry.refPath ?? entry.path);
37+
38+
// Format openclaw.json targets (sorted, descriptions preserved)
39+
const openclawLines = [...new Set(openclawJsonKeys)].toSorted().map((key) => {
40+
return lineMap.get(key) ?? `- \`${key}\``;
41+
});
42+
43+
// Format auth-profiles.json targets (sorted, descriptions preserved)
44+
const authProfilesLines = [...new Set(authProfilesJsonKeys)].toSorted().map((key) => {
45+
return lineMap.get(key) ?? `- \`${key}\``;
46+
});
47+
48+
// Combine with headers and distinct structures
49+
const newSupportedLines = [
50+
...openclawLines,
51+
"",
52+
"### `auth-profiles.json` targets (`secrets configure` + `secrets apply` + `secrets audit`)",
53+
"",
54+
...authProfilesLines,
55+
];
56+
57+
const unsupportedSet = new Set(matrixData.excludedMutableOrRuntimeManaged);
58+
const newUnsupportedLines = [...unsupportedSet].toSorted().map((key) => {
59+
return lineMap.get(key) ?? `- \`${key}\``;
60+
});
61+
62+
// Helper to replace block in markdown
63+
function replaceBlock(content: string, startMarker: string, endMarker: string, newLines: string[]): string {
64+
const startIdx = content.indexOf(startMarker);
65+
const endIdx = content.indexOf(endMarker);
66+
if (startIdx === -1 || endIdx === -1 || endIdx < startIdx) {
67+
throw new Error(`Markers not found: ${startMarker} or ${endMarker}`);
68+
}
69+
const before = content.slice(0, startIdx + startMarker.length);
70+
const after = content.slice(endIdx);
71+
return `${before}\n\n${newLines.join("\n")}\n\n${after}`;
72+
}
73+
74+
let newSurface = originalSurface;
75+
newSurface = replaceBlock(
76+
newSurface,
77+
'[//]: # "secretref-supported-list-start"',
78+
'[//]: # "secretref-supported-list-end"',
79+
newSupportedLines
80+
);
81+
newSurface = replaceBlock(
82+
newSurface,
83+
'[//]: # "secretref-unsupported-list-start"',
84+
'[//]: # "secretref-unsupported-list-end"',
85+
newUnsupportedLines
1186
);
1287

13-
const matrix = buildSecretRefCredentialMatrix();
14-
fs.writeFileSync(outputPath, `${JSON.stringify(matrix, null, 2)}\n`, "utf8");
15-
console.log(`Wrote ${outputPath}`);
88+
// Normalize line endings to LF
89+
newSurface = newSurface.replace(/\r\n/g, "\n");
90+
91+
if (CHECK) {
92+
const currentMatrix = fs.readFileSync(matrixPath, "utf8");
93+
const currentSurface = fs.readFileSync(surfacePath, "utf8").replace(/\r\n/g, "\n");
94+
95+
let drift = false;
96+
if (currentMatrix !== matrixJson) {
97+
console.error("Drift detected in secretref-user-supplied-credentials-matrix.json");
98+
drift = true;
99+
}
100+
if (currentSurface !== newSurface) {
101+
console.error("Drift detected in secretref-credential-surface.md");
102+
drift = true;
103+
}
104+
if (drift) {
105+
console.error("Please run: pnpm secretref:docs:gen");
106+
process.exit(1);
107+
} else {
108+
console.log("SecretRef reference docs are up to date.");
109+
}
110+
} else if (WRITE) {
111+
fs.writeFileSync(matrixPath, matrixJson, "utf8");
112+
fs.writeFileSync(surfacePath, newSurface, "utf8");
113+
console.log("SecretRef reference docs and matrix generated successfully.");
114+
}

‎scripts/generate-secretref-docs.ts‎

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)