@colbymchenry/codegraph-darwin-x64 1.0.1 → 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/lib/dist/bin/codegraph.js +111 -11
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/db/index.d.ts +22 -1
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +46 -1
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/queries.d.ts +14 -0
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +25 -0
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/directory.d.ts +43 -0
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +121 -0
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +11 -3
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +14 -5
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +6 -3
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +229 -62
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +47 -2
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/csharp.js +20 -0
- package/lib/dist/extraction/languages/csharp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +22 -0
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/java.d.ts.map +1 -1
- package/lib/dist/extraction/languages/java.js +213 -9
- package/lib/dist/extraction/languages/java.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +51 -0
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
- package/lib/dist/extraction/languages/scala.js +19 -9
- package/lib/dist/extraction/languages/scala.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +4 -1
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +13 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +119 -0
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +890 -11
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/index.d.ts +33 -0
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +68 -7
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +33 -67
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/instructions-template.d.ts +3 -3
- package/lib/dist/installer/instructions-template.d.ts.map +1 -1
- package/lib/dist/installer/instructions-template.js +4 -4
- package/lib/dist/installer/targets/claude.d.ts +18 -12
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +78 -6
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/shared.d.ts +12 -2
- package/lib/dist/installer/targets/shared.d.ts.map +1 -1
- package/lib/dist/installer/targets/shared.js +13 -12
- package/lib/dist/installer/targets/shared.js.map +1 -1
- package/lib/dist/installer/targets/types.d.ts +7 -0
- package/lib/dist/installer/targets/types.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +16 -0
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/engine.d.ts.map +1 -1
- package/lib/dist/mcp/engine.js +8 -0
- package/lib/dist/mcp/engine.js.map +1 -1
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +14 -1
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +18 -14
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +57 -52
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/session.d.ts.map +1 -1
- package/lib/dist/mcp/session.js +23 -18
- package/lib/dist/mcp/session.js.map +1 -1
- package/lib/dist/mcp/tools.d.ts +51 -1
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +585 -151
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/project-config.d.ts +36 -0
- package/lib/dist/project-config.d.ts.map +1 -0
- package/lib/dist/project-config.js +235 -0
- package/lib/dist/project-config.js.map +1 -0
- package/lib/dist/reasoning/config.d.ts +45 -0
- package/lib/dist/reasoning/config.d.ts.map +1 -0
- package/lib/dist/reasoning/config.js +171 -0
- package/lib/dist/reasoning/config.js.map +1 -0
- package/lib/dist/reasoning/credentials.d.ts +5 -0
- package/lib/dist/reasoning/credentials.d.ts.map +1 -0
- package/lib/dist/reasoning/credentials.js +83 -0
- package/lib/dist/reasoning/credentials.js.map +1 -0
- package/lib/dist/reasoning/login.d.ts +21 -0
- package/lib/dist/reasoning/login.d.ts.map +1 -0
- package/lib/dist/reasoning/login.js +85 -0
- package/lib/dist/reasoning/login.js.map +1 -0
- package/lib/dist/reasoning/reasoner.d.ts +43 -0
- package/lib/dist/reasoning/reasoner.d.ts.map +1 -0
- package/lib/dist/reasoning/reasoner.js +308 -0
- package/lib/dist/reasoning/reasoner.js.map +1 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +33 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.js +352 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts +6 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +1109 -1
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/goframe.js +112 -0
- package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
- package/lib/dist/resolution/frameworks/index.d.ts +1 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +5 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +17 -60
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
- package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/goframe-synthesizer.js +158 -0
- package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +48 -8
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/strip-comments.d.ts +1 -1
- package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
- package/lib/dist/resolution/strip-comments.js +2 -0
- package/lib/dist/resolution/strip-comments.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +68 -1
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +212 -14
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts +0 -3
- package/lib/dist/telemetry/index.d.ts.map +1 -1
- package/lib/dist/telemetry/index.js +4 -7
- package/lib/dist/telemetry/index.js.map +1 -1
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +40 -4
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/dist/utils.d.ts +14 -1
- package/lib/dist/utils.d.ts.map +1 -1
- package/lib/dist/utils.js +20 -2
- package/lib/dist/utils.js.map +1 -1
- package/lib/node_modules/.package-lock.json +1 -1
- package/lib/package.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Language } from './types';
|
|
2
|
+
/** Filename of the project-scoped config, resolved relative to the project root. */
|
|
3
|
+
export declare const PROJECT_CONFIG_FILENAME = "codegraph.json";
|
|
4
|
+
export interface ProjectConfig {
|
|
5
|
+
/** Map of custom file extension (`.foo`) to a supported language id. */
|
|
6
|
+
extensions?: Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Gitignore-style patterns naming gitignored directories whose embedded git
|
|
9
|
+
* repositories should be indexed anyway — the explicit opt-in to override
|
|
10
|
+
* `.gitignore` for nested-repo discovery (#622, #699). Absent/empty (the
|
|
11
|
+
* default) means `.gitignore` is fully respected: gitignored embedded repos
|
|
12
|
+
* are never discovered or indexed (#970, #976).
|
|
13
|
+
*/
|
|
14
|
+
includeIgnored?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load the validated extension overrides for a project, mtime-cached.
|
|
18
|
+
*
|
|
19
|
+
* Returns a map of `.ext` → supported language id. The result merges on top of
|
|
20
|
+
* the built-in extension map at the point of use (see `detectLanguage` /
|
|
21
|
+
* `isSourceFile`), with these user mappings taking precedence. Returns an empty
|
|
22
|
+
* map when there is no `codegraph.json` (the zero-config default).
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadExtensionOverrides(rootDir: string): Record<string, Language>;
|
|
25
|
+
/**
|
|
26
|
+
* Load the validated `includeIgnored` patterns for a project, mtime-cached.
|
|
27
|
+
*
|
|
28
|
+
* These name gitignored directories whose embedded git repositories should be
|
|
29
|
+
* indexed despite `.gitignore` (#622, #699). An empty result — the zero-config
|
|
30
|
+
* default — means `.gitignore` is fully respected: gitignored embedded repos
|
|
31
|
+
* are never discovered or indexed (#970, #976).
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadIncludeIgnoredPatterns(rootDir: string): string[];
|
|
34
|
+
/** Test/maintenance hook: forget cached config (e.g. after rewriting it in a test). */
|
|
35
|
+
export declare function clearProjectConfigCache(): void;
|
|
36
|
+
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,oFAAoF;AACpF,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA2JD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAEhF;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpE;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PROJECT_CONFIG_FILENAME = void 0;
|
|
37
|
+
exports.loadExtensionOverrides = loadExtensionOverrides;
|
|
38
|
+
exports.loadIncludeIgnoredPatterns = loadIncludeIgnoredPatterns;
|
|
39
|
+
exports.clearProjectConfigCache = clearProjectConfigCache;
|
|
40
|
+
/**
|
|
41
|
+
* Project-scoped configuration: a committed `codegraph.json` at the project
|
|
42
|
+
* root that a team shares through version control.
|
|
43
|
+
*
|
|
44
|
+
* Today it carries one thing — `extensions`, an opt-in map from a custom file
|
|
45
|
+
* extension to one of CodeGraph's supported languages. The built-in
|
|
46
|
+
* extension → language table (`EXTENSION_MAP` in `extraction/grammars.ts`) is
|
|
47
|
+
* otherwise hardcoded, so a codebase that uses a non-standard extension for a
|
|
48
|
+
* supported language (e.g. `.dota_lua` for Lua) sees those files silently
|
|
49
|
+
* skipped. This lets the project map them once, in a version-controlled file:
|
|
50
|
+
*
|
|
51
|
+
* {
|
|
52
|
+
* "extensions": {
|
|
53
|
+
* ".dota_lua": "lua",
|
|
54
|
+
* ".tpl": "php"
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* User mappings merge on TOP of the built-ins and win on conflict, so a project
|
|
59
|
+
* can also re-point a built-in extension (e.g. force `.h` → `cpp`). Absent or
|
|
60
|
+
* malformed config is the zero-config default — no overrides, no error. Invalid
|
|
61
|
+
* individual entries are warned-and-skipped (never fatal): an unparseable
|
|
62
|
+
* project file must not break indexing.
|
|
63
|
+
*/
|
|
64
|
+
const fs = __importStar(require("fs"));
|
|
65
|
+
const path = __importStar(require("path"));
|
|
66
|
+
const grammars_1 = require("./extraction/grammars");
|
|
67
|
+
const errors_1 = require("./errors");
|
|
68
|
+
/** Filename of the project-scoped config, resolved relative to the project root. */
|
|
69
|
+
exports.PROJECT_CONFIG_FILENAME = 'codegraph.json';
|
|
70
|
+
/**
|
|
71
|
+
* Cache keyed by project root. The loader is called once per indexing/scan/sync
|
|
72
|
+
* operation (and per watch event), so the mtime guard keeps repeat calls to one
|
|
73
|
+
* `stat` while a single `codegraph.json` is in force. Keying by root keeps two
|
|
74
|
+
* projects in the same process (the daemon / multi-project MCP server) isolated.
|
|
75
|
+
*/
|
|
76
|
+
const cache = new Map();
|
|
77
|
+
/** Shared frozen empties so the no-config path allocates nothing. */
|
|
78
|
+
const EMPTY_EXTENSIONS = Object.freeze({});
|
|
79
|
+
const EMPTY_CONFIG = Object.freeze({
|
|
80
|
+
extensions: EMPTY_EXTENSIONS,
|
|
81
|
+
includeIgnored: Object.freeze([]),
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Normalize a user-provided extension key to the `.ext` lowercase form used by
|
|
85
|
+
* the built-in map. Returns null for keys that can never match a real file
|
|
86
|
+
* extension (so the caller warns and skips):
|
|
87
|
+
* - empty / just "."
|
|
88
|
+
* - multi-part (".d.ts") — language detection keys off the FINAL extension
|
|
89
|
+
* only (`lastIndexOf('.')`), so a multi-dot key would never be consulted.
|
|
90
|
+
* - anything containing a path separator.
|
|
91
|
+
*/
|
|
92
|
+
function normalizeExtKey(raw) {
|
|
93
|
+
if (typeof raw !== 'string')
|
|
94
|
+
return null;
|
|
95
|
+
let ext = raw.trim().toLowerCase();
|
|
96
|
+
if (!ext)
|
|
97
|
+
return null;
|
|
98
|
+
if (!ext.startsWith('.'))
|
|
99
|
+
ext = '.' + ext;
|
|
100
|
+
const body = ext.slice(1);
|
|
101
|
+
if (!body)
|
|
102
|
+
return null;
|
|
103
|
+
if (body.includes('.') || body.includes('/') || body.includes('\\'))
|
|
104
|
+
return null;
|
|
105
|
+
return ext;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Read + JSON-parse a `codegraph.json` once and return its validated view.
|
|
109
|
+
* Every failure mode degrades to the zero-config default — a missing file, bad
|
|
110
|
+
* JSON, or a typo'd value never throws.
|
|
111
|
+
*/
|
|
112
|
+
function parseConfig(file) {
|
|
113
|
+
let raw;
|
|
114
|
+
try {
|
|
115
|
+
raw = fs.readFileSync(file, 'utf-8');
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return EMPTY_CONFIG;
|
|
119
|
+
}
|
|
120
|
+
let parsed;
|
|
121
|
+
try {
|
|
122
|
+
parsed = JSON.parse(raw);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
(0, errors_1.logWarn)(`Ignoring ${exports.PROJECT_CONFIG_FILENAME}: not valid JSON`, {
|
|
126
|
+
file,
|
|
127
|
+
error: err instanceof Error ? err.message : String(err),
|
|
128
|
+
});
|
|
129
|
+
return EMPTY_CONFIG;
|
|
130
|
+
}
|
|
131
|
+
if (!parsed || typeof parsed !== 'object')
|
|
132
|
+
return EMPTY_CONFIG;
|
|
133
|
+
const extensions = extractExtensions(parsed, file);
|
|
134
|
+
const includeIgnored = extractIncludeIgnored(parsed, file);
|
|
135
|
+
if (extensions === EMPTY_EXTENSIONS && includeIgnored.length === 0)
|
|
136
|
+
return EMPTY_CONFIG;
|
|
137
|
+
return { extensions, includeIgnored };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Validate the `extensions` map. Every failure mode degrades to "no overrides
|
|
141
|
+
* from this entry" — a bad value or a typo'd language never throws.
|
|
142
|
+
*/
|
|
143
|
+
function extractExtensions(parsed, file) {
|
|
144
|
+
const exts = parsed.extensions;
|
|
145
|
+
if (!exts || typeof exts !== 'object' || Array.isArray(exts))
|
|
146
|
+
return EMPTY_EXTENSIONS;
|
|
147
|
+
const out = {};
|
|
148
|
+
for (const [rawKey, rawVal] of Object.entries(exts)) {
|
|
149
|
+
const key = normalizeExtKey(rawKey);
|
|
150
|
+
if (!key) {
|
|
151
|
+
(0, errors_1.logWarn)(`Ignoring extension mapping in ${exports.PROJECT_CONFIG_FILENAME}: "${rawKey}" is not a valid file extension`, { file });
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (typeof rawVal !== 'string' || !(0, grammars_1.isLanguageSupported)(rawVal)) {
|
|
155
|
+
(0, errors_1.logWarn)(`Ignoring extension "${rawKey}" in ${exports.PROJECT_CONFIG_FILENAME}: "${String(rawVal)}" is not a supported language`, { file });
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
out[key] = rawVal;
|
|
159
|
+
}
|
|
160
|
+
return Object.keys(out).length > 0 ? out : EMPTY_EXTENSIONS;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Validate the `includeIgnored` patterns: an array of non-empty gitignore-style
|
|
164
|
+
* strings. A non-array value or a non-string/blank entry warns-and-skips; never
|
|
165
|
+
* throws. Patterns are kept verbatim (trimmed) so they match exactly as a
|
|
166
|
+
* `.gitignore` line would.
|
|
167
|
+
*/
|
|
168
|
+
function extractIncludeIgnored(parsed, file) {
|
|
169
|
+
const raw = parsed.includeIgnored;
|
|
170
|
+
if (raw === undefined)
|
|
171
|
+
return [];
|
|
172
|
+
if (!Array.isArray(raw)) {
|
|
173
|
+
(0, errors_1.logWarn)(`Ignoring "includeIgnored" in ${exports.PROJECT_CONFIG_FILENAME}: must be an array of gitignore-style patterns`, { file });
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
const out = [];
|
|
177
|
+
for (const entry of raw) {
|
|
178
|
+
if (typeof entry !== 'string' || !entry.trim()) {
|
|
179
|
+
(0, errors_1.logWarn)(`Ignoring an "includeIgnored" entry in ${exports.PROJECT_CONFIG_FILENAME}: every pattern must be a non-empty string`, { file });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
out.push(entry.trim());
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Load the parsed `codegraph.json` for a project, mtime-cached. A missing or
|
|
188
|
+
* malformed file yields the zero-config default. One `stat` (and at most one
|
|
189
|
+
* read/parse) while a single config file is in force, shared across every field.
|
|
190
|
+
*/
|
|
191
|
+
function loadParsedConfig(rootDir) {
|
|
192
|
+
const file = path.join(rootDir, exports.PROJECT_CONFIG_FILENAME);
|
|
193
|
+
let mtimeMs;
|
|
194
|
+
try {
|
|
195
|
+
mtimeMs = fs.statSync(file).mtimeMs;
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
// No config file — drop any stale cache entry and return the default.
|
|
199
|
+
cache.delete(rootDir);
|
|
200
|
+
return EMPTY_CONFIG;
|
|
201
|
+
}
|
|
202
|
+
const entry = cache.get(rootDir);
|
|
203
|
+
if (entry && entry.mtimeMs === mtimeMs)
|
|
204
|
+
return entry.config;
|
|
205
|
+
const config = parseConfig(file);
|
|
206
|
+
cache.set(rootDir, { mtimeMs, config });
|
|
207
|
+
return config;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Load the validated extension overrides for a project, mtime-cached.
|
|
211
|
+
*
|
|
212
|
+
* Returns a map of `.ext` → supported language id. The result merges on top of
|
|
213
|
+
* the built-in extension map at the point of use (see `detectLanguage` /
|
|
214
|
+
* `isSourceFile`), with these user mappings taking precedence. Returns an empty
|
|
215
|
+
* map when there is no `codegraph.json` (the zero-config default).
|
|
216
|
+
*/
|
|
217
|
+
function loadExtensionOverrides(rootDir) {
|
|
218
|
+
return loadParsedConfig(rootDir).extensions;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Load the validated `includeIgnored` patterns for a project, mtime-cached.
|
|
222
|
+
*
|
|
223
|
+
* These name gitignored directories whose embedded git repositories should be
|
|
224
|
+
* indexed despite `.gitignore` (#622, #699). An empty result — the zero-config
|
|
225
|
+
* default — means `.gitignore` is fully respected: gitignored embedded repos
|
|
226
|
+
* are never discovered or indexed (#970, #976).
|
|
227
|
+
*/
|
|
228
|
+
function loadIncludeIgnoredPatterns(rootDir) {
|
|
229
|
+
return loadParsedConfig(rootDir).includeIgnored;
|
|
230
|
+
}
|
|
231
|
+
/** Test/maintenance hook: forget cached config (e.g. after rewriting it in a test). */
|
|
232
|
+
function clearProjectConfigCache() {
|
|
233
|
+
cache.clear();
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=project-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+MA,wDAEC;AAUD,gEAEC;AAGD,0DAEC;AAlOD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,uCAAyB;AACzB,2CAA6B;AAE7B,oDAA4D;AAC5D,qCAAmC;AAEnC,oFAAoF;AACvE,QAAA,uBAAuB,GAAG,gBAAgB,CAAC;AA0BxD;;;;;GAKG;AACH,MAAM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OAAe;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,+BAAuB,CAAC,CAAC;IAEzD,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,sEAAsE;QACtE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC;IAE5D,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC;AAClD,CAAC;AAED,uFAAuF;AACvF,SAAgB,uBAAuB;IACrC,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Managed tier ("CodeGraph AI") — the metered gateway used when logged in. */
|
|
2
|
+
export declare const MANAGED_DEFAULT_URL = "https://ai.getcodegraph.com/v1";
|
|
3
|
+
/** The gateway's public model id (it translates this to the upstream provider id). */
|
|
4
|
+
export declare const MANAGED_DEFAULT_MODEL = "openai/gpt-oss-120b";
|
|
5
|
+
export interface OffloadConfig {
|
|
6
|
+
/** Managed tier: route through CodeGraph AI (metered) with the logged-in org token. */
|
|
7
|
+
managed?: boolean;
|
|
8
|
+
/** OpenAI-compatible base URL ending in `/v1` (e.g. https://api.cerebras.ai/v1). */
|
|
9
|
+
url?: string;
|
|
10
|
+
/** Model id to request (default `gpt-oss-120b` BYO, `openai/gpt-oss-120b` managed). */
|
|
11
|
+
model?: string;
|
|
12
|
+
/** Name of the env var holding the provider API key (never persisted). BYO only. */
|
|
13
|
+
keyEnv?: string;
|
|
14
|
+
/** reasoning_effort: low | medium | high (default `low`). */
|
|
15
|
+
effort?: string;
|
|
16
|
+
/** Output style: plain | report (default `plain`). */
|
|
17
|
+
style?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ResolvedOffload {
|
|
20
|
+
/** True when the offload is usable (endpoint present; for managed, a token too). */
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/** Managed tier (CodeGraph AI, metered) vs BYO endpoint. */
|
|
23
|
+
managed: boolean;
|
|
24
|
+
url?: string;
|
|
25
|
+
model: string;
|
|
26
|
+
/** Resolved API key / org token (from env, the configured `keyEnv`, or login), if any. */
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
/** Where the key/token came from (for `status` display) — never the secret itself. */
|
|
29
|
+
keySource?: string;
|
|
30
|
+
effort: string;
|
|
31
|
+
style: string;
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
maxTokens: number;
|
|
34
|
+
strip: boolean;
|
|
35
|
+
debug: boolean;
|
|
36
|
+
/** Where the endpoint came from — drives `codegraph offload status`. */
|
|
37
|
+
origin: 'env' | 'config' | 'none';
|
|
38
|
+
}
|
|
39
|
+
/** The persisted offload block (empty object if none). */
|
|
40
|
+
export declare function readOffloadConfig(): OffloadConfig;
|
|
41
|
+
/** Persist (or, with `null`, clear) the offload block, leaving other config keys intact. */
|
|
42
|
+
export declare function writeOffloadConfig(offload: OffloadConfig | null): void;
|
|
43
|
+
/** Merge the persisted config with `CODEGRAPH_OFFLOAD_*` env overrides (env wins). */
|
|
44
|
+
export declare function resolveOffload(env?: NodeJS.ProcessEnv): ResolvedOffload;
|
|
45
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/reasoning/config.ts"],"names":[],"mappings":"AAqBA,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AACpE,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,uFAAuF;IACvF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACnC;AAsBD,0DAA0D;AAC1D,wBAAgB,iBAAiB,IAAI,aAAa,CAIjD;AAED,4FAA4F;AAC5F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAKtE;AAOD,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,eAAe,CAwDpF"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MANAGED_DEFAULT_MODEL = exports.MANAGED_DEFAULT_URL = void 0;
|
|
37
|
+
exports.readOffloadConfig = readOffloadConfig;
|
|
38
|
+
exports.writeOffloadConfig = writeOffloadConfig;
|
|
39
|
+
exports.resolveOffload = resolveOffload;
|
|
40
|
+
/**
|
|
41
|
+
* Reasoning-offload configuration: the persistent, machine-level settings the
|
|
42
|
+
* `codegraph offload` CLI writes, merged with `CODEGRAPH_OFFLOAD_*` env overrides.
|
|
43
|
+
*
|
|
44
|
+
* Stored in `~/.codegraph/config.json` under the `offload` key — the same global
|
|
45
|
+
* home CodeGraph already uses for the daemon registry — because the reasoning
|
|
46
|
+
* endpoint is a per-machine choice (the model you bring), not per-project state.
|
|
47
|
+
* Every codegraph MCP server on the machine picks it up, so a user configures it
|
|
48
|
+
* once. Env vars override the file (CI / ephemeral / advanced use).
|
|
49
|
+
*
|
|
50
|
+
* For a BYO endpoint, the API key is NEVER written to disk: the CLI stores the
|
|
51
|
+
* NAME of an env var (`keyEnv`) and reads the key from it at call time. The
|
|
52
|
+
* MANAGED tier ("CodeGraph AI") instead authenticates with a revocable, org-scoped
|
|
53
|
+
* token from `codegraph offload login`, stored separately in `credentials.json`
|
|
54
|
+
* (see ./credentials) — so `config.json` itself never carries a secret either way.
|
|
55
|
+
*/
|
|
56
|
+
const fs = __importStar(require("fs"));
|
|
57
|
+
const path = __importStar(require("path"));
|
|
58
|
+
const os = __importStar(require("os"));
|
|
59
|
+
const credentials_1 = require("./credentials");
|
|
60
|
+
/** Managed tier ("CodeGraph AI") — the metered gateway used when logged in. */
|
|
61
|
+
exports.MANAGED_DEFAULT_URL = 'https://ai.getcodegraph.com/v1';
|
|
62
|
+
/** The gateway's public model id (it translates this to the upstream provider id). */
|
|
63
|
+
exports.MANAGED_DEFAULT_MODEL = 'openai/gpt-oss-120b';
|
|
64
|
+
function configDir() {
|
|
65
|
+
return path.join(os.homedir(), '.codegraph');
|
|
66
|
+
}
|
|
67
|
+
function configPath() {
|
|
68
|
+
return path.join(configDir(), 'config.json');
|
|
69
|
+
}
|
|
70
|
+
function readUserConfig() {
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(fs.readFileSync(configPath(), 'utf8'));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function writeUserConfig(cfg) {
|
|
79
|
+
fs.mkdirSync(configDir(), { recursive: true });
|
|
80
|
+
fs.writeFileSync(configPath(), JSON.stringify(cfg, null, 2) + '\n');
|
|
81
|
+
}
|
|
82
|
+
/** The persisted offload block (empty object if none). */
|
|
83
|
+
function readOffloadConfig() {
|
|
84
|
+
const cfg = readUserConfig();
|
|
85
|
+
const o = cfg.offload;
|
|
86
|
+
return o && typeof o === 'object' ? o : {};
|
|
87
|
+
}
|
|
88
|
+
/** Persist (or, with `null`, clear) the offload block, leaving other config keys intact. */
|
|
89
|
+
function writeOffloadConfig(offload) {
|
|
90
|
+
const cfg = readUserConfig();
|
|
91
|
+
if (offload === null)
|
|
92
|
+
delete cfg.offload;
|
|
93
|
+
else
|
|
94
|
+
cfg.offload = offload;
|
|
95
|
+
writeUserConfig(cfg);
|
|
96
|
+
}
|
|
97
|
+
const trimmed = (v) => {
|
|
98
|
+
const t = v?.trim();
|
|
99
|
+
return t ? t : undefined;
|
|
100
|
+
};
|
|
101
|
+
/** Merge the persisted config with `CODEGRAPH_OFFLOAD_*` env overrides (env wins). */
|
|
102
|
+
function resolveOffload(env = process.env) {
|
|
103
|
+
// Hard kill-switch: disable the offload for this process/session without touching
|
|
104
|
+
// the persisted config or the stored login — e.g. one A/B arm, or a user who wants
|
|
105
|
+
// codegraph_explore to return raw source for a session. Env-only by design.
|
|
106
|
+
if (env.CODEGRAPH_OFFLOAD_DISABLE === '1') {
|
|
107
|
+
return {
|
|
108
|
+
enabled: false, managed: false, url: undefined, model: exports.MANAGED_DEFAULT_MODEL,
|
|
109
|
+
apiKey: undefined, keySource: undefined, effort: 'low', style: 'plain',
|
|
110
|
+
timeoutMs: 20000, maxTokens: 12000, strip: false,
|
|
111
|
+
debug: env.CODEGRAPH_OFFLOAD_DEBUG === '1', origin: 'none',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const c = readOffloadConfig();
|
|
115
|
+
const managed = !!c.managed;
|
|
116
|
+
const envUrl = trimmed(env.CODEGRAPH_OFFLOAD_URL);
|
|
117
|
+
const envKey = trimmed(env.CODEGRAPH_OFFLOAD_KEY);
|
|
118
|
+
let url;
|
|
119
|
+
let apiKey;
|
|
120
|
+
let keySource;
|
|
121
|
+
let model;
|
|
122
|
+
if (managed) {
|
|
123
|
+
// Managed tier: default to the CodeGraph AI gateway + its public model id; the
|
|
124
|
+
// bearer is the org token from `codegraph offload login` (or an env override).
|
|
125
|
+
url = envUrl ?? trimmed(c.url) ?? exports.MANAGED_DEFAULT_URL;
|
|
126
|
+
model = trimmed(env.CODEGRAPH_OFFLOAD_MODEL) ?? trimmed(c.model) ?? exports.MANAGED_DEFAULT_MODEL;
|
|
127
|
+
if (envKey) {
|
|
128
|
+
apiKey = envKey;
|
|
129
|
+
keySource = 'CODEGRAPH_OFFLOAD_KEY';
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const t = (0, credentials_1.readOffloadToken)();
|
|
133
|
+
if (t) {
|
|
134
|
+
apiKey = t;
|
|
135
|
+
keySource = 'codegraph login';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// BYO: endpoint + (optional) provider key resolved from env or the named env var.
|
|
141
|
+
url = envUrl ?? trimmed(c.url);
|
|
142
|
+
model = trimmed(env.CODEGRAPH_OFFLOAD_MODEL) ?? trimmed(c.model) ?? 'gpt-oss-120b';
|
|
143
|
+
if (envKey) {
|
|
144
|
+
apiKey = envKey;
|
|
145
|
+
keySource = 'CODEGRAPH_OFFLOAD_KEY';
|
|
146
|
+
}
|
|
147
|
+
else if (c.keyEnv && trimmed(env[c.keyEnv])) {
|
|
148
|
+
apiKey = trimmed(env[c.keyEnv]);
|
|
149
|
+
keySource = c.keyEnv;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const origin = envUrl ? 'env' : (managed || trimmed(c.url)) ? 'config' : 'none';
|
|
153
|
+
return {
|
|
154
|
+
// Managed needs both an endpoint AND a token (no token → effectively logged out);
|
|
155
|
+
// BYO needs only an endpoint (some endpoints require no auth).
|
|
156
|
+
enabled: managed ? (!!url && !!apiKey) : !!url,
|
|
157
|
+
managed,
|
|
158
|
+
url,
|
|
159
|
+
model,
|
|
160
|
+
apiKey,
|
|
161
|
+
keySource,
|
|
162
|
+
effort: trimmed(env.CODEGRAPH_OFFLOAD_EFFORT) ?? trimmed(c.effort) ?? 'low',
|
|
163
|
+
style: trimmed(env.CODEGRAPH_OFFLOAD_STYLE) ?? trimmed(c.style) ?? 'plain',
|
|
164
|
+
timeoutMs: Number(env.CODEGRAPH_OFFLOAD_TIMEOUT_MS) || 20000,
|
|
165
|
+
maxTokens: Number(env.CODEGRAPH_OFFLOAD_MAXTOKENS) || 12000,
|
|
166
|
+
strip: env.CODEGRAPH_OFFLOAD_STRIP === '1',
|
|
167
|
+
debug: env.CODEGRAPH_OFFLOAD_DEBUG === '1',
|
|
168
|
+
origin,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/reasoning/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,8CAIC;AAGD,gDAKC;AAQD,wCAwDC;AA/JD;;;;;;;;;;;;;;;GAeG;AACH,u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,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAE3G,OAAO;QACL,kFAAkF;QAClF,+DAA+D;QAC/D,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QAC9C,OAAO;QACP,GAAG;QACH,KAAK;QACL,MAAM;QACN,SAAS;QACT,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK;QAC3E,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO;QAC1E,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,KAAK;QAC5D,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,KAAK;QAC3D,KAAK,EAAE,GAAG,CAAC,uBAAuB,KAAK,GAAG;QAC1C,KAAK,EAAE,GAAG,CAAC,uBAAuB,KAAK,GAAG;QAC1C,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The stored managed-offload org token, if the machine is logged in. */
|
|
2
|
+
export declare function readOffloadToken(): string | undefined;
|
|
3
|
+
/** Persist (or, with `null`, clear) the managed-offload org token at `0600`. */
|
|
4
|
+
export declare function writeOffloadToken(token: string | null): void;
|
|
5
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/reasoning/credentials.ts"],"names":[],"mappings":"AA0BA,yEAAyE;AACzE,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAGrD;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAS5D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readOffloadToken = readOffloadToken;
|
|
37
|
+
exports.writeOffloadToken = writeOffloadToken;
|
|
38
|
+
/**
|
|
39
|
+
* Managed-offload credentials: the CodeGraph org token that authenticates the
|
|
40
|
+
* managed reasoning tier against `codegraph-ai` (the metered gateway).
|
|
41
|
+
*
|
|
42
|
+
* Unlike a BYO provider key (which is never persisted — the config stores only the
|
|
43
|
+
* NAME of an env var), the org token IS a revocable, org-scoped auth token issued
|
|
44
|
+
* to this machine — like the token `gh auth` or `npm login` stores. So it lives in
|
|
45
|
+
* its own file, `~/.codegraph/credentials.json`, written `0600`, kept out of the
|
|
46
|
+
* shareable `config.json`.
|
|
47
|
+
*/
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const os = __importStar(require("os"));
|
|
51
|
+
function credentialsPath() {
|
|
52
|
+
return path.join(os.homedir(), '.codegraph', 'credentials.json');
|
|
53
|
+
}
|
|
54
|
+
function read() {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(fs.readFileSync(credentialsPath(), 'utf8'));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The stored managed-offload org token, if the machine is logged in. */
|
|
63
|
+
function readOffloadToken() {
|
|
64
|
+
const t = read().offloadToken;
|
|
65
|
+
return typeof t === 'string' && t.trim() ? t.trim() : undefined;
|
|
66
|
+
}
|
|
67
|
+
/** Persist (or, with `null`, clear) the managed-offload org token at `0600`. */
|
|
68
|
+
function writeOffloadToken(token) {
|
|
69
|
+
const p = credentialsPath();
|
|
70
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
71
|
+
const creds = read();
|
|
72
|
+
if (token === null)
|
|
73
|
+
delete creds.offloadToken;
|
|
74
|
+
else
|
|
75
|
+
creds.offloadToken = token;
|
|
76
|
+
// Write restrictively: create at 0600, and tighten an existing file too.
|
|
77
|
+
fs.writeFileSync(p, JSON.stringify(creds, null, 2) + '\n', { mode: 0o600 });
|
|
78
|
+
try {
|
|
79
|
+
fs.chmodSync(p, 0o600);
|
|
80
|
+
}
|
|
81
|
+
catch { /* best-effort on platforms without POSIX modes */ }
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/reasoning/credentials.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,4CAGC;AAGD,8CASC;AA1CD;;;;;;;;;GASG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB,SAAS,eAAe;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,IAAI;IACX,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,MAAM,CAAC,CAA4B,CAAC;IAC3F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,SAAgB,gBAAgB;IAC9B,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,YAAY,CAAC;IAC9B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,gFAAgF;AAChF,SAAgB,iBAAiB,CAAC,KAAoB;IACpD,MAAM,CAAC,GAAG,eAAe,EAAE,CAAC;IAC5B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;IACrB,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC,YAAY,CAAC;;QACzC,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC;IAChC,yEAAyE;IACzE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC;QAAC,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,kDAAkD,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Dashboard base for the device-login endpoints; override for testing via CODEGRAPH_LOGIN_URL. */
|
|
2
|
+
export declare function loginBaseUrl(): string;
|
|
3
|
+
/** The dashboard's response to a device-authorization start request. */
|
|
4
|
+
export interface DeviceStart {
|
|
5
|
+
device_code: string;
|
|
6
|
+
user_code: string;
|
|
7
|
+
verification_uri: string;
|
|
8
|
+
/** Same URL with the code prefilled, for one-click open. */
|
|
9
|
+
verification_uri_complete?: string;
|
|
10
|
+
/** Seconds the CLI should wait between polls. */
|
|
11
|
+
interval?: number;
|
|
12
|
+
/** Seconds until the request expires. */
|
|
13
|
+
expires_in?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Begin a device-authorization request. */
|
|
16
|
+
export declare function startDeviceLogin(): Promise<DeviceStart>;
|
|
17
|
+
/** Poll until the user approves in the browser; resolves with the org token. */
|
|
18
|
+
export declare function pollForToken(deviceCode: string, intervalSec: number, expiresInSec: number): Promise<string>;
|
|
19
|
+
/** Best-effort: open a URL in the default browser. Never throws — the URL is also printed. */
|
|
20
|
+
export declare function openBrowser(url: string): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/reasoning/login.ts"],"names":[],"mappings":"AAeA,mGAAmG;AACnG,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,4CAA4C;AAC5C,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,WAAW,CAAC,CAY7D;AAED,gFAAgF;AAChF,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBjH;AAED,8FAA8F;AAC9F,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5D"}
|