@octocodeai/config 17.0.0
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 +21 -0
- package/README.md +466 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +263 -0
- package/dist/cli.js.map +7 -0
- package/dist/config/defaults.d.ts +16 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/loader.d.ts +8 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/resolver.d.ts +3 -0
- package/dist/config/resolver.d.ts.map +1 -0
- package/dist/config/resolverCache.d.ts +13 -0
- package/dist/config/resolverCache.d.ts.map +1 -0
- package/dist/config/resolverSections.d.ts +16 -0
- package/dist/config/resolverSections.d.ts.map +1 -0
- package/dist/config/runtimeSurface.d.ts +23 -0
- package/dist/config/runtimeSurface.d.ts.map +1 -0
- package/dist/config/types.d.ts +103 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validator.d.ts +3 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/home.d.ts +2 -0
- package/dist/home.d.ts.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +814 -0
- package/dist/index.js.map +7 -0
- package/dist/tokens/envTokens.d.ts +24 -0
- package/dist/tokens/envTokens.d.ts.map +1 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/types.d.ts +6 -0
- package/dist/tokens/types.d.ts.map +1 -0
- package/package.json +60 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
|
|
4
|
+
// src/cli.ts
|
|
5
|
+
import path4 from "node:path";
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import path3 from "node:path";
|
|
10
|
+
|
|
11
|
+
// src/home.ts
|
|
12
|
+
import os from "node:os";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
function getOctocodeHome(env = process.env) {
|
|
15
|
+
const override = env["OCTOCODE_HOME"];
|
|
16
|
+
if (override && override.trim()) return path.resolve(override.trim());
|
|
17
|
+
const home2 = os.homedir();
|
|
18
|
+
const platform = os.platform();
|
|
19
|
+
if (platform === "win32") {
|
|
20
|
+
const appData = env["APPDATA"] ?? path.join(home2, "AppData", "Roaming");
|
|
21
|
+
return path.join(appData, ".octocode");
|
|
22
|
+
}
|
|
23
|
+
if (platform === "darwin") return path.join(home2, ".octocode");
|
|
24
|
+
const xdg = env["XDG_CONFIG_HOME"] ?? path.join(home2, ".config");
|
|
25
|
+
return path.join(xdg, ".octocode");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/config/loader.ts
|
|
29
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
30
|
+
import path2 from "node:path";
|
|
31
|
+
function stripJson5Features(content) {
|
|
32
|
+
let result = "";
|
|
33
|
+
let i = 0;
|
|
34
|
+
let inString = false;
|
|
35
|
+
let stringChar = "";
|
|
36
|
+
while (i < content.length) {
|
|
37
|
+
const char = content[i];
|
|
38
|
+
const nextChar = content[i + 1];
|
|
39
|
+
if (!inString && (char === '"' || char === "'")) {
|
|
40
|
+
inString = true;
|
|
41
|
+
stringChar = char;
|
|
42
|
+
result += char;
|
|
43
|
+
i++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (inString) {
|
|
47
|
+
result += char;
|
|
48
|
+
if (char === "\\" && i + 1 < content.length) {
|
|
49
|
+
result += content[i + 1];
|
|
50
|
+
i += 2;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (char === stringChar) inString = false;
|
|
54
|
+
i++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (char === "/" && nextChar === "/") {
|
|
58
|
+
while (i < content.length && content[i] !== "\n") i++;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (char === "/" && nextChar === "*") {
|
|
62
|
+
i += 2;
|
|
63
|
+
while (i < content.length - 1) {
|
|
64
|
+
if (content[i] === "*" && content[i + 1] === "/") {
|
|
65
|
+
i += 2;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
i++;
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
result += char;
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
return result.replace(/,(\s*[}\]])/g, "$1");
|
|
76
|
+
}
|
|
77
|
+
function parseJson5(content) {
|
|
78
|
+
return JSON.parse(stripJson5Features(content));
|
|
79
|
+
}
|
|
80
|
+
function getConfigFilePath(home2 = getOctocodeHome()) {
|
|
81
|
+
return path2.join(home2, ".octocoderc");
|
|
82
|
+
}
|
|
83
|
+
function loadConfigSync(home2) {
|
|
84
|
+
const filePath = getConfigFilePath(home2);
|
|
85
|
+
if (!existsSync(filePath)) {
|
|
86
|
+
return { success: false, error: "Config file does not exist", path: filePath };
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const content = readFileSync(filePath, "utf-8");
|
|
90
|
+
if (!content.trim()) {
|
|
91
|
+
return { success: true, config: {}, path: filePath };
|
|
92
|
+
}
|
|
93
|
+
const parsed = parseJson5(content);
|
|
94
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
error: "Config file has invalid structure: must be a JSON object",
|
|
98
|
+
path: filePath
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return { success: true, config: parsed, path: filePath };
|
|
102
|
+
} catch (e) {
|
|
103
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
104
|
+
return { success: false, error: `Failed to parse config file: ${message}`, path: filePath };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/index.ts
|
|
109
|
+
var PROTECTED_KEYS = /* @__PURE__ */ new Set([
|
|
110
|
+
"PATH",
|
|
111
|
+
"HOME",
|
|
112
|
+
"SHELL",
|
|
113
|
+
"USER",
|
|
114
|
+
"LOGNAME",
|
|
115
|
+
"PWD",
|
|
116
|
+
"TMPDIR",
|
|
117
|
+
"NODE_OPTIONS",
|
|
118
|
+
"OCTOCODE_TOKEN",
|
|
119
|
+
"GH_TOKEN",
|
|
120
|
+
"GITHUB_TOKEN",
|
|
121
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
|
122
|
+
"PYTHON"
|
|
123
|
+
]);
|
|
124
|
+
function parseEnv(text) {
|
|
125
|
+
const out = {};
|
|
126
|
+
if (!text) return out;
|
|
127
|
+
for (const rawLine of text.split("\n")) {
|
|
128
|
+
const trimmed = rawLine.trim();
|
|
129
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
130
|
+
const normalized = trimmed.startsWith("export ") ? trimmed.slice("export ".length).trim() : trimmed;
|
|
131
|
+
const eq = normalized.indexOf("=");
|
|
132
|
+
if (eq === -1) continue;
|
|
133
|
+
const key = normalized.slice(0, eq).trim();
|
|
134
|
+
if (!key) continue;
|
|
135
|
+
out[key] = normalized.slice(eq + 1).trim().replace(/^["']|["']$/g, "");
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
function readTextIfExists(filePath) {
|
|
140
|
+
try {
|
|
141
|
+
return fs.readFileSync(filePath, "utf8");
|
|
142
|
+
} catch {
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function loadOctocodeEnv({
|
|
147
|
+
home: home2,
|
|
148
|
+
cwd,
|
|
149
|
+
trusted = false
|
|
150
|
+
} = {}) {
|
|
151
|
+
const map2 = {};
|
|
152
|
+
const sources2 = {};
|
|
153
|
+
if (home2) {
|
|
154
|
+
for (const [k, v] of Object.entries(parseEnv(readTextIfExists(path3.join(home2, ".env"))))) {
|
|
155
|
+
map2[k] = v;
|
|
156
|
+
sources2[k] = "global";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (cwd && trusted) {
|
|
160
|
+
for (const [k, v] of Object.entries(
|
|
161
|
+
parseEnv(readTextIfExists(path3.join(cwd, ".octocode", ".env")))
|
|
162
|
+
)) {
|
|
163
|
+
map2[k] = v;
|
|
164
|
+
sources2[k] = "project";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { map: map2, sources: sources2 };
|
|
168
|
+
}
|
|
169
|
+
function applyOctocodeEnv(map2, { env = process.env } = {}) {
|
|
170
|
+
const applied = [];
|
|
171
|
+
const skippedProtected = [];
|
|
172
|
+
const skippedExisting = [];
|
|
173
|
+
for (const [key, value] of Object.entries(map2 ?? {})) {
|
|
174
|
+
if (PROTECTED_KEYS.has(key)) {
|
|
175
|
+
skippedProtected.push(key);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const existing = env[key];
|
|
179
|
+
if (existing !== void 0 && existing !== "") {
|
|
180
|
+
skippedExisting.push(key);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
env[key] = value;
|
|
184
|
+
applied.push(key);
|
|
185
|
+
}
|
|
186
|
+
return { applied, skippedProtected, skippedExisting };
|
|
187
|
+
}
|
|
188
|
+
function propagateOctocodeEnv({
|
|
189
|
+
home: home2 = getOctocodeHome(),
|
|
190
|
+
cwd,
|
|
191
|
+
trusted = false,
|
|
192
|
+
env = process.env
|
|
193
|
+
} = {}) {
|
|
194
|
+
const { map: map2, sources: sources2 } = loadOctocodeEnv({ home: home2, cwd, trusted });
|
|
195
|
+
const result = applyOctocodeEnv(map2, { env });
|
|
196
|
+
return { ...result, sources: sources2, keys: Object.keys(map2) };
|
|
197
|
+
}
|
|
198
|
+
function loadOctocoderc(home2 = getOctocodeHome()) {
|
|
199
|
+
const result = loadConfigSync(home2);
|
|
200
|
+
if (result.success) return result.config ? result.config : {};
|
|
201
|
+
if (result.error && result.error !== "Config file does not exist") {
|
|
202
|
+
process.stderr.write(`[octocode-config] Failed to parse .octocoderc: ${result.error}
|
|
203
|
+
`);
|
|
204
|
+
}
|
|
205
|
+
return {};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// src/cli.ts
|
|
209
|
+
var args = process.argv.slice(2);
|
|
210
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
211
|
+
console.log(`@octocodeai/config \u2014 Octocode env inspector
|
|
212
|
+
|
|
213
|
+
Usage:
|
|
214
|
+
npx @octocodeai/config Print home dir, .env paths, key count
|
|
215
|
+
npx @octocodeai/config --keys List loaded key names (never values)
|
|
216
|
+
npx @octocodeai/config --check KEY Exit 0 if KEY is set, 1 if not
|
|
217
|
+
npx @octocodeai/config --help Show this help
|
|
218
|
+
|
|
219
|
+
Env files loaded (in precedence order):
|
|
220
|
+
<home>/.env Global keys (OCTOCODE_HOME or platform default)
|
|
221
|
+
<cwd>/.octocode/.env Project keys (trusted mode only)
|
|
222
|
+
`);
|
|
223
|
+
process.exit(0);
|
|
224
|
+
}
|
|
225
|
+
var home = getOctocodeHome();
|
|
226
|
+
if (args.includes("--check")) {
|
|
227
|
+
const checkIdx = args.indexOf("--check");
|
|
228
|
+
const key = args[checkIdx + 1];
|
|
229
|
+
if (!key) {
|
|
230
|
+
process.stderr.write("--check requires a KEY name\n");
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
propagateOctocodeEnv({ cwd: process.cwd(), trusted: true });
|
|
234
|
+
if (process.env[key]) {
|
|
235
|
+
console.log(`${key}: set`);
|
|
236
|
+
process.exit(0);
|
|
237
|
+
} else {
|
|
238
|
+
console.log(`${key}: not set`);
|
|
239
|
+
process.exit(1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (args.includes("--keys")) {
|
|
243
|
+
const { map: map2 } = loadOctocodeEnv({ home, cwd: process.cwd(), trusted: true });
|
|
244
|
+
const keys = Object.keys(map2);
|
|
245
|
+
if (keys.length === 0) {
|
|
246
|
+
console.log("No keys loaded.");
|
|
247
|
+
} else {
|
|
248
|
+
keys.forEach((k) => console.log(k));
|
|
249
|
+
}
|
|
250
|
+
process.exit(0);
|
|
251
|
+
}
|
|
252
|
+
var { map, sources } = loadOctocodeEnv({ home, cwd: process.cwd(), trusted: true });
|
|
253
|
+
var rc = loadOctocoderc(home);
|
|
254
|
+
var globalKeys = Object.values(sources).filter((s) => s === "global").length;
|
|
255
|
+
var projectKeys = Object.values(sources).filter((s) => s === "project").length;
|
|
256
|
+
console.log(`Octocode home: ${home}`);
|
|
257
|
+
console.log(`Global .env: ${path4.join(home, ".env")}`);
|
|
258
|
+
console.log(`Project .env: ${path4.join(process.cwd(), ".octocode", ".env")}`);
|
|
259
|
+
console.log(`Keys loaded: ${Object.keys(map).length} (${globalKeys} global, ${projectKeys} project)`);
|
|
260
|
+
if (Object.keys(rc).length > 0) {
|
|
261
|
+
console.log(`Config (.octocoderc): ${Object.keys(rc).join(", ")}`);
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.ts", "../src/index.ts", "../src/home.ts", "../src/config/loader.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n// @octocodeai/config CLI \u2014 inspect and verify Octocode env state.\n//\n// Usage:\n// npx @octocodeai/config # print home dir, file paths, key count\n// npx @octocodeai/config --keys # list loaded key names (no values ever printed)\n// npx @octocodeai/config --check KEY # exit 0 if KEY is set, exit 1 if not\n// npx @octocodeai/config --help\n\nimport path from 'node:path';\nimport {\n getOctocodeHome,\n loadOctocodeEnv,\n loadOctocoderc,\n propagateOctocodeEnv,\n} from './index.js';\n\nconst args = process.argv.slice(2);\n\nif (args.includes('--help') || args.includes('-h')) {\n console.log(`@octocodeai/config \u2014 Octocode env inspector\n\nUsage:\n npx @octocodeai/config Print home dir, .env paths, key count\n npx @octocodeai/config --keys List loaded key names (never values)\n npx @octocodeai/config --check KEY Exit 0 if KEY is set, 1 if not\n npx @octocodeai/config --help Show this help\n\nEnv files loaded (in precedence order):\n <home>/.env Global keys (OCTOCODE_HOME or platform default)\n <cwd>/.octocode/.env Project keys (trusted mode only)\n`);\n process.exit(0);\n}\n\nconst home = getOctocodeHome();\n\nif (args.includes('--check')) {\n const checkIdx = args.indexOf('--check');\n const key = args[checkIdx + 1];\n if (!key) {\n process.stderr.write('--check requires a KEY name\\n');\n process.exit(1);\n }\n propagateOctocodeEnv({ cwd: process.cwd(), trusted: true });\n if (process.env[key]) {\n console.log(`${key}: set`);\n process.exit(0);\n } else {\n console.log(`${key}: not set`);\n process.exit(1);\n }\n}\n\nif (args.includes('--keys')) {\n const { map } = loadOctocodeEnv({ home, cwd: process.cwd(), trusted: true });\n const keys = Object.keys(map);\n if (keys.length === 0) {\n console.log('No keys loaded.');\n } else {\n keys.forEach(k => console.log(k));\n }\n process.exit(0);\n}\n\n// Default: status\nconst { map, sources } = loadOctocodeEnv({ home, cwd: process.cwd(), trusted: true });\nconst rc = loadOctocoderc(home);\nconst globalKeys = Object.values(sources).filter(s => s === 'global').length;\nconst projectKeys = Object.values(sources).filter(s => s === 'project').length;\n\nconsole.log(`Octocode home: ${home}`);\nconsole.log(`Global .env: ${path.join(home, '.env')}`);\nconsole.log(`Project .env: ${path.join(process.cwd(), '.octocode', '.env')}`);\nconsole.log(`Keys loaded: ${Object.keys(map).length} (${globalKeys} global, ${projectKeys} project)`);\nif (Object.keys(rc).length > 0) {\n console.log(`Config (.octocoderc): ${Object.keys(rc).join(', ')}`);\n}\n", "// @octocodeai/config \u2014 single source of truth for ALL Octocode config + token env logic.\n//\n// Surfaces: MCP server \u00B7 CLI \u00B7 VS Code extension \u00B7 Pi extension \u00B7 agent \u00B7 standalone skills\n//\n// Zero dependencies (Node builtins only). Cross-platform.\n//\n// Precedence:\n// explicit process.env > <project>/.octocode/.env > <home>/.env > <home>/.octocoderc > defaults\n\nimport fs from 'node:fs';\nimport path from 'node:path';\n\n// \u2500\u2500\u2500 Re-export getOctocodeHome (defined in home.ts to break circular deps) \u2500\u2500\u2500\nexport { getOctocodeHome } from './home.js';\nimport { getOctocodeHome } from './home.js';\n\n// \u2500\u2500\u2500 Re-exports from config/ and tokens/ \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport * from './config/index.js';\nexport * from './tokens/index.js';\n\n// \u2500\u2500\u2500 Env loading (uses loadConfigSync from config/loader.ts below) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nimport { loadConfigSync } from './config/loader.js';\n\n/** Keys a project/global .env must never override \u2014 infrastructure + all auth tokens. */\nexport const PROTECTED_KEYS: ReadonlySet<string> = new Set([\n 'PATH', 'HOME', 'SHELL', 'USER', 'LOGNAME', 'PWD', 'TMPDIR', 'NODE_OPTIONS',\n 'OCTOCODE_TOKEN', 'GH_TOKEN', 'GITHUB_TOKEN', 'GITHUB_PERSONAL_ACCESS_TOKEN', 'PYTHON',\n]);\n\n/**\n * Parse dotenv text into a { KEY: VALUE } map. Strict KEY=VALUE, `#` comments,\n * optional `export ` prefix, surrounding quotes stripped. No shell expansion.\n */\nexport function parseEnv(text: string | null | undefined): Record<string, string> {\n const out: Record<string, string> = {};\n if (!text) return out;\n for (const rawLine of text.split('\\n')) {\n const trimmed = rawLine.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n const normalized = trimmed.startsWith('export ')\n ? trimmed.slice('export '.length).trim()\n : trimmed;\n const eq = normalized.indexOf('=');\n if (eq === -1) continue;\n const key = normalized.slice(0, eq).trim();\n if (!key) continue;\n out[key] = normalized.slice(eq + 1).trim().replace(/^[\"']|[\"']$/g, '');\n }\n return out;\n}\n\nfunction readTextIfExists(filePath: string): string {\n try { return fs.readFileSync(filePath, 'utf8'); } catch { return ''; }\n}\n\nexport interface LoadOctocodeEnvOptions {\n home?: string;\n cwd?: string;\n trusted?: boolean;\n}\n\nexport interface LoadOctocodeEnvResult {\n map: Record<string, string>;\n sources: Record<string, 'global' | 'project'>;\n}\n\n/**\n * Load merged Octocode env from global then project (project wins).\n * Returns { map, sources } where sources[key] = 'global' | 'project' (names only, no values).\n * The project file is included only when trusted.\n */\nexport function loadOctocodeEnv({\n home,\n cwd,\n trusted = false,\n}: LoadOctocodeEnvOptions = {}): LoadOctocodeEnvResult {\n const map: Record<string, string> = {};\n const sources: Record<string, 'global' | 'project'> = {};\n\n if (home) {\n for (const [k, v] of Object.entries(parseEnv(readTextIfExists(path.join(home, '.env'))))) {\n map[k] = v;\n sources[k] = 'global';\n }\n }\n if (cwd && trusted) {\n for (const [k, v] of Object.entries(\n parseEnv(readTextIfExists(path.join(cwd, '.octocode', '.env'))),\n )) {\n map[k] = v;\n sources[k] = 'project';\n }\n }\n return { map, sources };\n}\n\nexport interface ApplyOctocodeEnvOptions {\n env?: Record<string, string | undefined>;\n}\n\nexport interface ApplyOctocodeEnvResult {\n applied: string[];\n skippedProtected: string[];\n skippedExisting: string[];\n}\n\n/**\n * Apply a parsed env map into `env`. Skips keys already set (env wins over files) and\n * protected keys. Returns names only \u2014 never values \u2014 for logging/status.\n */\nexport function applyOctocodeEnv(\n map: Record<string, string> | null | undefined,\n { env = process.env }: ApplyOctocodeEnvOptions = {},\n): ApplyOctocodeEnvResult {\n const applied: string[] = [];\n const skippedProtected: string[] = [];\n const skippedExisting: string[] = [];\n\n for (const [key, value] of Object.entries(map ?? {})) {\n if (PROTECTED_KEYS.has(key)) { skippedProtected.push(key); continue; }\n const existing = env[key];\n if (existing !== undefined && existing !== '') { skippedExisting.push(key); continue; }\n env[key] = value;\n applied.push(key);\n }\n return { applied, skippedProtected, skippedExisting };\n}\n\nexport interface PropagateOctocodeEnvOptions {\n home?: string;\n cwd?: string;\n trusted?: boolean;\n env?: Record<string, string | undefined>;\n}\n\nexport interface PropagateOctocodeEnvResult extends ApplyOctocodeEnvResult {\n sources: Record<string, 'global' | 'project'>;\n keys: string[];\n}\n\n/** Convenience: load + apply in one call. Returns names-only metadata. */\nexport function propagateOctocodeEnv({\n home = getOctocodeHome(),\n cwd,\n trusted = false,\n env = process.env,\n}: PropagateOctocodeEnvOptions = {}): PropagateOctocodeEnvResult {\n const { map, sources } = loadOctocodeEnv({ home, cwd, trusted });\n const result = applyOctocodeEnv(map, { env });\n return { ...result, sources, keys: Object.keys(map) };\n}\n\n/**\n * True when stats.json writes are enabled via OCTOCODE_ENABLE_STATS=1|true.\n * Stats are always tracked in memory; this flag controls disk persistence only.\n * Keeping it off (the default) eliminates one write per 60-second flush cycle.\n */\nexport function isStatsEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n const v = env['OCTOCODE_ENABLE_STATS'];\n return v === '1' || v === 'true';\n}\n\n/**\n * Read and parse `<home>/.octocoderc`.\n * Delegates to the robust JSON5 loader (state-machine based, handles // inside strings).\n * Returns {} when absent or invalid. No secrets belong here.\n */\nexport function loadOctocoderc(home: string = getOctocodeHome()): Record<string, unknown> {\n const result = loadConfigSync(home);\n if (result.success) return result.config ? (result.config as Record<string, unknown>) : {};\n // File absent is silent; any other failure (parse error etc.) is reported.\n if (result.error && result.error !== 'Config file does not exist') {\n process.stderr.write(`[octocode-config] Failed to parse .octocoderc: ${result.error}\\n`);\n }\n return {};\n}\n", "/**\n * getOctocodeHome \u2014 single source of truth for the Octocode home directory.\n * Kept in its own file so config/loader.ts can import it without creating a\n * circular dependency with the main index.ts.\n *\n * Unified home per platform (matches octocode-tools-core/src/shared/paths.ts):\n * macOS: ~/.octocode\n * Linux: ${XDG_CONFIG_HOME:-~/.config}/.octocode\n * Windows: %APPDATA%\\.octocode\n * override: OCTOCODE_HOME\n */\nimport os from 'node:os';\nimport path from 'node:path';\n\nexport function getOctocodeHome(env: Record<string, string | undefined> = process.env): string {\n const override = env['OCTOCODE_HOME'];\n if (override && override.trim()) return path.resolve(override.trim());\n const home = os.homedir();\n const platform = os.platform();\n if (platform === 'win32') {\n const appData = env['APPDATA'] ?? path.join(home, 'AppData', 'Roaming');\n return path.join(appData, '.octocode');\n }\n if (platform === 'darwin') return path.join(home, '.octocode');\n const xdg = env['XDG_CONFIG_HOME'] ?? path.join(home, '.config');\n return path.join(xdg, '.octocode');\n}\n", "import { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { getOctocodeHome } from '../home.js';\nimport type { OctocodeConfig, LoadConfigResult } from './types.js';\n\n// \u2500\u2500\u2500 JSON5-compatible parser \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Handles: line comments (//) \u00B7 block comments (/* */) \u00B7 trailing commas.\n// State-machine based so // or /* inside string literals is never stripped.\n\nfunction stripJson5Features(content: string): string {\n let result = '';\n let i = 0;\n let inString = false;\n let stringChar = '';\n\n while (i < content.length) {\n const char = content[i]!;\n const nextChar = content[i + 1];\n\n if (!inString && (char === '\"' || char === \"'\")) {\n inString = true;\n stringChar = char;\n result += char;\n i++;\n continue;\n }\n\n if (inString) {\n result += char;\n if (char === '\\\\' && i + 1 < content.length) {\n result += content[i + 1]!;\n i += 2;\n continue;\n }\n if (char === stringChar) inString = false;\n i++;\n continue;\n }\n\n if (char === '/' && nextChar === '/') {\n while (i < content.length && content[i] !== '\\n') i++;\n continue;\n }\n\n if (char === '/' && nextChar === '*') {\n i += 2;\n while (i < content.length - 1) {\n if (content[i] === '*' && content[i + 1] === '/') { i += 2; break; }\n i++;\n }\n continue;\n }\n\n result += char;\n i++;\n }\n\n return result.replace(/,(\\s*[}\\]])/g, '$1');\n}\n\nfunction parseJson5(content: string): unknown {\n return JSON.parse(stripJson5Features(content));\n}\n\n// \u2500\u2500\u2500 Path helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Absolute path to the `.octocoderc` config file. */\nexport function getConfigFilePath(home: string = getOctocodeHome()): string {\n return path.join(home, '.octocoderc');\n}\n\n/** True when the `.octocoderc` file exists at the canonical location. */\nexport function configExists(home?: string): boolean {\n return existsSync(getConfigFilePath(home));\n}\n\n// \u2500\u2500\u2500 Loader \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport function loadConfigSync(home?: string): LoadConfigResult {\n const filePath = getConfigFilePath(home);\n\n if (!existsSync(filePath)) {\n return { success: false, error: 'Config file does not exist', path: filePath };\n }\n\n try {\n const content = readFileSync(filePath, 'utf-8');\n\n if (!content.trim()) {\n return { success: true, config: {}, path: filePath };\n }\n\n const parsed = parseJson5(content);\n\n // Simple structural guard (replaces zod OctocodeConfigSchema \u2014 which was\n // z.looseObject, so this is semantically equivalent with zero deps).\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return {\n success: false,\n error: 'Config file has invalid structure: must be a JSON object',\n path: filePath,\n };\n }\n\n return { success: true, config: parsed as OctocodeConfig, path: filePath };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return { success: false, error: `Failed to parse config file: ${message}`, path: filePath };\n }\n}\n\nexport async function loadConfig(home?: string): Promise<LoadConfigResult> {\n return loadConfigSync(home);\n}\n"],
|
|
5
|
+
"mappings": ";;;;AASA,OAAOA,WAAU;;;ACAjB,OAAO,QAAQ;AACf,OAAOC,WAAU;;;ACCjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,gBAAgB,MAA0C,QAAQ,KAAa;AAC7F,QAAM,WAAW,IAAI,eAAe;AACpC,MAAI,YAAY,SAAS,KAAK,EAAG,QAAO,KAAK,QAAQ,SAAS,KAAK,CAAC;AACpE,QAAMC,QAAO,GAAG,QAAQ;AACxB,QAAM,WAAW,GAAG,SAAS;AAC7B,MAAI,aAAa,SAAS;AACxB,UAAM,UAAU,IAAI,SAAS,KAAK,KAAK,KAAKA,OAAM,WAAW,SAAS;AACtE,WAAO,KAAK,KAAK,SAAS,WAAW;AAAA,EACvC;AACA,MAAI,aAAa,SAAU,QAAO,KAAK,KAAKA,OAAM,WAAW;AAC7D,QAAM,MAAM,IAAI,iBAAiB,KAAK,KAAK,KAAKA,OAAM,SAAS;AAC/D,SAAO,KAAK,KAAK,KAAK,WAAW;AACnC;;;AC1BA,SAAS,YAAY,oBAAoB;AACzC,OAAOC,WAAU;AAQjB,SAAS,mBAAmB,SAAyB;AACnD,MAAI,SAAS;AACb,MAAI,IAAI;AACR,MAAI,WAAW;AACf,MAAI,aAAa;AAEjB,SAAO,IAAI,QAAQ,QAAQ;AACzB,UAAM,OAAO,QAAQ,CAAC;AACtB,UAAM,WAAW,QAAQ,IAAI,CAAC;AAE9B,QAAI,CAA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
|
|
|
1
|
+
import type { RequiredGitHubConfig, RequiredLocalConfig, RequiredToolsConfig, RequiredNetworkConfig, RequiredLspConfig, RequiredOutputConfig, RequiredSessionConfig, ResolvedConfig } from './types.js';
|
|
2
|
+
export declare const DEFAULT_GITHUB_CONFIG: RequiredGitHubConfig;
|
|
3
|
+
export declare const DEFAULT_LOCAL_CONFIG: RequiredLocalConfig;
|
|
4
|
+
export declare const DEFAULT_TOOLS_CONFIG: RequiredToolsConfig;
|
|
5
|
+
export declare const DEFAULT_NETWORK_CONFIG: RequiredNetworkConfig;
|
|
6
|
+
export declare const DEFAULT_LSP_CONFIG: RequiredLspConfig;
|
|
7
|
+
export declare const DEFAULT_OUTPUT_CONFIG: RequiredOutputConfig;
|
|
8
|
+
export declare const DEFAULT_SESSION_CONFIG: RequiredSessionConfig;
|
|
9
|
+
export declare const DEFAULT_CONFIG: Omit<ResolvedConfig, 'source' | 'configPath'>;
|
|
10
|
+
export declare const MIN_TIMEOUT = 5000;
|
|
11
|
+
export declare const MAX_TIMEOUT = 300000;
|
|
12
|
+
export declare const MIN_RETRIES = 0;
|
|
13
|
+
export declare const MAX_RETRIES = 10;
|
|
14
|
+
export declare const MIN_OUTPUT_DEFAULT_CHAR_LENGTH = 1000;
|
|
15
|
+
export declare const MAX_OUTPUT_DEFAULT_CHAR_LENGTH = 50000;
|
|
16
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,qBAAqB,EAAE,oBAEnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,mBAKlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,mBAIlC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,qBAGpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,iBAEhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,oBAKnC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,qBAGpC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,YAAY,CASxE,CAAC;AAEF,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD,eAAO,MAAM,8BAA8B,QAAQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { OctocodeConfig, ResolvedConfig, ValidationResult, LoadConfigResult, GitHubConfigOptions, LocalConfigOptions, ToolsConfigOptions, NetworkConfigOptions, LspConfigOptions, OutputConfigOptions, OutputPaginationConfigOptions, RequiredGitHubConfig, RequiredLocalConfig, RequiredToolsConfig, RequiredNetworkConfig, RequiredLspConfig, RequiredOutputConfig, RequiredOutputPaginationConfig, RequiredSessionConfig, MinifyMode, } from './types.js';
|
|
2
|
+
export { CONFIG_SCHEMA_VERSION, CONFIG_FILE_NAME } from './types.js';
|
|
3
|
+
export { DEFAULT_CONFIG, DEFAULT_GITHUB_CONFIG, DEFAULT_LOCAL_CONFIG, DEFAULT_TOOLS_CONFIG, DEFAULT_NETWORK_CONFIG, DEFAULT_LSP_CONFIG, DEFAULT_OUTPUT_CONFIG, MIN_TIMEOUT, MAX_TIMEOUT, MIN_RETRIES, MAX_RETRIES, MIN_OUTPUT_DEFAULT_CHAR_LENGTH, MAX_OUTPUT_DEFAULT_CHAR_LENGTH, DEFAULT_SESSION_CONFIG, } from './defaults.js';
|
|
4
|
+
export { type RuntimeSurface, setRuntimeSurface, getRuntimeSurface, _resetRuntimeSurface, } from './runtimeSurface.js';
|
|
5
|
+
export { validateConfig } from './validator.js';
|
|
6
|
+
export { getConfigFilePath, configExists, loadConfigSync, loadConfig, } from './loader.js';
|
|
7
|
+
export { parseBooleanEnv, parseIntEnv, parseStringArrayEnv, resolveGitHub, resolveLocal, resolveTools, resolveNetwork, resolveLsp, resolveOutput, resolveSession, } from './resolverSections.js';
|
|
8
|
+
export { resolveConfigSync, resolveConfig, getConfig, getConfigSync, reloadConfig, invalidateConfigCache, _resetConfigCache, _getCacheState, getConfigValue, } from './resolver.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,8BAA8B,EAC9B,qBAAqB,EACrB,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,8BAA8B,EAC9B,8BAA8B,EAC9B,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,KAAK,cAAc,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LoadConfigResult } from './types.js';
|
|
2
|
+
/** Absolute path to the `.octocoderc` config file. */
|
|
3
|
+
export declare function getConfigFilePath(home?: string): string;
|
|
4
|
+
/** True when the `.octocoderc` file exists at the canonical location. */
|
|
5
|
+
export declare function configExists(home?: string): boolean;
|
|
6
|
+
export declare function loadConfigSync(home?: string): LoadConfigResult;
|
|
7
|
+
export declare function loadConfig(home?: string): Promise<LoadConfigResult>;
|
|
8
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA+DnE,sDAAsD;AACtD,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAA0B,GAAG,MAAM,CAE1E;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAEnD;AAID,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,CA+B9D;AAED,wBAAsB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEzE"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { resolveConfigSync, resolveConfig, getConfig, getConfigSync, reloadConfig, invalidateConfigCache, _resetConfigCache, _getCacheState, } from './resolverCache.js';
|
|
2
|
+
export declare function getConfigValue<T = unknown>(keyPath: string): T | undefined;
|
|
3
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/config/resolver.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAI5B,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAS1E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ResolvedConfig } from './types.js';
|
|
2
|
+
export declare function resolveConfigSync(): ResolvedConfig;
|
|
3
|
+
export declare function resolveConfig(): Promise<ResolvedConfig>;
|
|
4
|
+
export declare function getConfigSync(): ResolvedConfig;
|
|
5
|
+
export declare function getConfig(): Promise<ResolvedConfig>;
|
|
6
|
+
export declare function reloadConfig(): Promise<ResolvedConfig>;
|
|
7
|
+
export declare function invalidateConfigCache(): void;
|
|
8
|
+
export declare function _resetConfigCache(): void;
|
|
9
|
+
export declare function _getCacheState(): {
|
|
10
|
+
cached: boolean;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=resolverCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolverCache.d.ts","sourceRoot":"","sources":["../../src/config/resolverCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,YAAY,CAAC;AA0DjE,wBAAgB,iBAAiB,IAAI,cAAc,CAclD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,cAAc,CAAC,CAE7D;AAQD,wBAAgB,aAAa,IAAI,cAAc,CAW9C;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC,CAEzD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,cAAc,CAAC,CAG5D;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED,wBAAgB,cAAc,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAKvE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OctocodeConfig, RequiredGitHubConfig, RequiredLocalConfig, RequiredToolsConfig, RequiredNetworkConfig, RequiredLspConfig, RequiredOutputConfig, RequiredSessionConfig } from './types.js';
|
|
2
|
+
export declare function parseBooleanEnv(value: string | undefined): boolean | undefined;
|
|
3
|
+
export declare function parseIntEnv(value: string | undefined): number | undefined;
|
|
4
|
+
export declare function parseStringArrayEnv(value: string | undefined): string[] | undefined;
|
|
5
|
+
export declare function resolveGitHub(fileConfig?: OctocodeConfig['github']): RequiredGitHubConfig;
|
|
6
|
+
export declare function resolveLocal(fileConfig?: OctocodeConfig['local']): RequiredLocalConfig;
|
|
7
|
+
export declare function resolveTools(fileConfig?: OctocodeConfig['tools']): RequiredToolsConfig;
|
|
8
|
+
export declare function resolveNetwork(fileConfig?: OctocodeConfig['network']): RequiredNetworkConfig;
|
|
9
|
+
export declare function resolveLsp(fileConfig?: OctocodeConfig['lsp']): RequiredLspConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve session / stats-persistence config from env only.
|
|
12
|
+
* OCTOCODE_ENABLE_STATS=1|true turns on stats.json writes; default is off.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveSession(): RequiredSessionConfig;
|
|
15
|
+
export declare function resolveOutput(fileConfig?: OctocodeConfig['output']): RequiredOutputConfig;
|
|
16
|
+
//# sourceMappingURL=resolverSections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolverSections.d.ts","sourceRoot":"","sources":["../../src/config/resolverSections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAkBpB,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,GAAG,SAAS,CAOrB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOzE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,EAAE,GAAG,SAAS,CAQtB;AAED,wBAAgB,aAAa,CAC3B,UAAU,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,GACpC,oBAAoB,CAMtB;AAED,wBAAgB,YAAY,CAC1B,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GACnC,mBAAmB,CA4BrB;AAED,wBAAgB,YAAY,CAC1B,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GACnC,mBAAmB,CAerB;AAED,wBAAgB,cAAc,CAC5B,UAAU,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,GACrC,qBAAqB,CAevB;AAED,wBAAgB,UAAU,CACxB,UAAU,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GACjC,iBAAiB,CAOnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,qBAAqB,CAKtD;AAID,wBAAgB,aAAa,CAC3B,UAAU,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,GACpC,oBAAoB,CAwBtB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which interface is driving the shared tool core right now.
|
|
3
|
+
*
|
|
4
|
+
* Some config defaults differ by surface (see `resolveLocal`):
|
|
5
|
+
* - `cli`: local tools default to ENABLED; clone defaults to ENABLED.
|
|
6
|
+
* - `mcp`: local tools default to ENABLED; clone defaults to DISABLED.
|
|
7
|
+
*
|
|
8
|
+
* `ENABLE_LOCAL=false` or `local.enabled=false` explicitly disables local tools
|
|
9
|
+
* on every surface.
|
|
10
|
+
*
|
|
11
|
+
* Defaults to `mcp`, the primary consumer. The CLI binary calls
|
|
12
|
+
* `setRuntimeSurface('cli')` at startup before any tool runs.
|
|
13
|
+
*
|
|
14
|
+
* State lives on `globalThis` (not a module-level variable) so a single shared
|
|
15
|
+
* value is seen even when bundlers (esbuild) inline this module more than once
|
|
16
|
+
* across different package subpath entry points (`/config`, `/direct`, …).
|
|
17
|
+
*/
|
|
18
|
+
export type RuntimeSurface = 'cli' | 'mcp';
|
|
19
|
+
export declare function setRuntimeSurface(surface: RuntimeSurface): void;
|
|
20
|
+
export declare function getRuntimeSurface(): RuntimeSurface;
|
|
21
|
+
/** Test helper: restore the default surface. */
|
|
22
|
+
export declare function _resetRuntimeSurface(): void;
|
|
23
|
+
//# sourceMappingURL=runtimeSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeSurface.d.ts","sourceRoot":"","sources":["../../src/config/runtimeSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,CAAC;AAM3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAE/D;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAElD;AAED,gDAAgD;AAChD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export declare const CONFIG_SCHEMA_VERSION = 1;
|
|
2
|
+
export declare const CONFIG_FILE_NAME = ".octocoderc";
|
|
3
|
+
export interface GitHubConfigOptions {
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LocalConfigOptions {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
enableClone?: boolean;
|
|
9
|
+
allowedPaths?: string[];
|
|
10
|
+
workspaceRoot?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolsConfigOptions {
|
|
13
|
+
enabled?: string[] | null;
|
|
14
|
+
enableAdditional?: string[] | null;
|
|
15
|
+
disabled?: string[] | null;
|
|
16
|
+
}
|
|
17
|
+
export interface NetworkConfigOptions {
|
|
18
|
+
timeout?: number;
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface LspConfigOptions {
|
|
22
|
+
configPath?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface OutputPaginationConfigOptions {
|
|
25
|
+
defaultCharLength?: number;
|
|
26
|
+
}
|
|
27
|
+
export type MinifyMode = 'none' | 'standard' | 'symbols';
|
|
28
|
+
export interface OutputConfigOptions {
|
|
29
|
+
format?: 'yaml' | 'json';
|
|
30
|
+
pagination?: OutputPaginationConfigOptions;
|
|
31
|
+
}
|
|
32
|
+
export interface OctocodeConfig {
|
|
33
|
+
$schema?: string;
|
|
34
|
+
version?: number;
|
|
35
|
+
github?: GitHubConfigOptions;
|
|
36
|
+
local?: LocalConfigOptions;
|
|
37
|
+
tools?: ToolsConfigOptions;
|
|
38
|
+
network?: NetworkConfigOptions;
|
|
39
|
+
lsp?: LspConfigOptions;
|
|
40
|
+
output?: OutputConfigOptions;
|
|
41
|
+
}
|
|
42
|
+
export interface RequiredGitHubConfig {
|
|
43
|
+
apiUrl: string;
|
|
44
|
+
}
|
|
45
|
+
export interface RequiredLocalConfig {
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
enableClone: boolean;
|
|
48
|
+
allowedPaths: string[];
|
|
49
|
+
workspaceRoot: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
export interface RequiredToolsConfig {
|
|
52
|
+
enabled: string[] | null;
|
|
53
|
+
enableAdditional: string[] | null;
|
|
54
|
+
disabled: string[] | null;
|
|
55
|
+
}
|
|
56
|
+
export interface RequiredNetworkConfig {
|
|
57
|
+
timeout: number;
|
|
58
|
+
maxRetries: number;
|
|
59
|
+
}
|
|
60
|
+
export interface RequiredLspConfig {
|
|
61
|
+
configPath: string | undefined;
|
|
62
|
+
}
|
|
63
|
+
export interface RequiredOutputPaginationConfig {
|
|
64
|
+
defaultCharLength: number;
|
|
65
|
+
}
|
|
66
|
+
export interface RequiredOutputConfig {
|
|
67
|
+
format: 'yaml' | 'json';
|
|
68
|
+
pagination: RequiredOutputPaginationConfig;
|
|
69
|
+
}
|
|
70
|
+
export interface ResolvedConfig {
|
|
71
|
+
version: number;
|
|
72
|
+
github: RequiredGitHubConfig;
|
|
73
|
+
local: RequiredLocalConfig;
|
|
74
|
+
tools: RequiredToolsConfig;
|
|
75
|
+
network: RequiredNetworkConfig;
|
|
76
|
+
lsp: RequiredLspConfig;
|
|
77
|
+
output: RequiredOutputConfig;
|
|
78
|
+
session: RequiredSessionConfig;
|
|
79
|
+
source: 'file' | 'defaults' | 'mixed';
|
|
80
|
+
configPath?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Session / stats persistence options (env-var only — no .octocoderc equivalent).
|
|
84
|
+
* Resolved entirely from OCTOCODE_ENABLE_STATS; default is off to avoid
|
|
85
|
+
* unnecessary SSD writes on long-running agent sessions.
|
|
86
|
+
*/
|
|
87
|
+
export interface RequiredSessionConfig {
|
|
88
|
+
/** Write stats.json on every flush. Stats are always tracked in memory. */
|
|
89
|
+
enableStats: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface ValidationResult {
|
|
92
|
+
valid: boolean;
|
|
93
|
+
errors: string[];
|
|
94
|
+
warnings: string[];
|
|
95
|
+
config?: OctocodeConfig;
|
|
96
|
+
}
|
|
97
|
+
export interface LoadConfigResult {
|
|
98
|
+
success: boolean;
|
|
99
|
+
config?: OctocodeConfig;
|
|
100
|
+
error?: string;
|
|
101
|
+
path: string;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE1B,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAEnC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,6BAA6B;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB,UAAU,CAAC,EAAE,6BAA6B,CAAC;C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,EAAE,mBAAmB,CAAC;IAE3B,OAAO,EAAE,qBAAqB,CAAC;IAE/B,GAAG,EAAE,iBAAiB,CAAC;IAEvB,MAAM,EAAE,oBAAoB,CAAC;IAE7B,OAAO,EAAE,qBAAqB,CAAC;IAE/B,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IAEtC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IAEf,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IAEjB,MAAM,CAAC,EAAE,cAAc,CAAC;IAExB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoSnE,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAsDhE"}
|
package/dist/home.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"home.d.ts","sourceRoot":"","sources":["../src/home.ts"],"names":[],"mappings":"AAcA,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAY7F"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export { getOctocodeHome } from './home.js';
|
|
2
|
+
export * from './config/index.js';
|
|
3
|
+
export * from './tokens/index.js';
|
|
4
|
+
/** Keys a project/global .env must never override — infrastructure + all auth tokens. */
|
|
5
|
+
export declare const PROTECTED_KEYS: ReadonlySet<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Parse dotenv text into a { KEY: VALUE } map. Strict KEY=VALUE, `#` comments,
|
|
8
|
+
* optional `export ` prefix, surrounding quotes stripped. No shell expansion.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseEnv(text: string | null | undefined): Record<string, string>;
|
|
11
|
+
export interface LoadOctocodeEnvOptions {
|
|
12
|
+
home?: string;
|
|
13
|
+
cwd?: string;
|
|
14
|
+
trusted?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface LoadOctocodeEnvResult {
|
|
17
|
+
map: Record<string, string>;
|
|
18
|
+
sources: Record<string, 'global' | 'project'>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Load merged Octocode env from global then project (project wins).
|
|
22
|
+
* Returns { map, sources } where sources[key] = 'global' | 'project' (names only, no values).
|
|
23
|
+
* The project file is included only when trusted.
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadOctocodeEnv({ home, cwd, trusted, }?: LoadOctocodeEnvOptions): LoadOctocodeEnvResult;
|
|
26
|
+
export interface ApplyOctocodeEnvOptions {
|
|
27
|
+
env?: Record<string, string | undefined>;
|
|
28
|
+
}
|
|
29
|
+
export interface ApplyOctocodeEnvResult {
|
|
30
|
+
applied: string[];
|
|
31
|
+
skippedProtected: string[];
|
|
32
|
+
skippedExisting: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Apply a parsed env map into `env`. Skips keys already set (env wins over files) and
|
|
36
|
+
* protected keys. Returns names only — never values — for logging/status.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyOctocodeEnv(map: Record<string, string> | null | undefined, { env }?: ApplyOctocodeEnvOptions): ApplyOctocodeEnvResult;
|
|
39
|
+
export interface PropagateOctocodeEnvOptions {
|
|
40
|
+
home?: string;
|
|
41
|
+
cwd?: string;
|
|
42
|
+
trusted?: boolean;
|
|
43
|
+
env?: Record<string, string | undefined>;
|
|
44
|
+
}
|
|
45
|
+
export interface PropagateOctocodeEnvResult extends ApplyOctocodeEnvResult {
|
|
46
|
+
sources: Record<string, 'global' | 'project'>;
|
|
47
|
+
keys: string[];
|
|
48
|
+
}
|
|
49
|
+
/** Convenience: load + apply in one call. Returns names-only metadata. */
|
|
50
|
+
export declare function propagateOctocodeEnv({ home, cwd, trusted, env, }?: PropagateOctocodeEnvOptions): PropagateOctocodeEnvResult;
|
|
51
|
+
/**
|
|
52
|
+
* True when stats.json writes are enabled via OCTOCODE_ENABLE_STATS=1|true.
|
|
53
|
+
* Stats are always tracked in memory; this flag controls disk persistence only.
|
|
54
|
+
* Keeping it off (the default) eliminates one write per 60-second flush cycle.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isStatsEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Read and parse `<home>/.octocoderc`.
|
|
59
|
+
* Delegates to the robust JSON5 loader (state-machine based, handles // inside strings).
|
|
60
|
+
* Returns {} when absent or invalid. No secrets belong here.
|
|
61
|
+
*/
|
|
62
|
+
export declare function loadOctocoderc(home?: string): Record<string, unknown>;
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAI5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAMlC,yFAAyF;AACzF,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAG7C,CAAC;AAEH;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAA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