@colbymchenry/codegraph 0.9.8 → 1.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/README.md +150 -70
- package/dist/bin/codegraph.d.ts +1 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/markers.d.ts +19 -0
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/queries.d.ts +43 -0
- package/dist/db/sqlite-adapter.d.ts +7 -0
- package/dist/directory.d.ts +34 -2
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/grammars.d.ts +7 -1
- package/dist/extraction/index.d.ts +34 -0
- package/dist/extraction/languages/c-cpp.d.ts +8 -0
- package/dist/extraction/languages/csharp.d.ts +22 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts +13 -0
- package/dist/extraction/liquid-extractor.d.ts +7 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/tree-sitter-types.d.ts +33 -0
- package/dist/extraction/tree-sitter.d.ts +237 -0
- package/dist/extraction/vue-extractor.d.ts +15 -0
- package/dist/index.d.ts +41 -3
- package/dist/installer/instructions-template.d.ts +34 -11
- package/dist/installer/targets/opencode.d.ts +9 -1
- package/dist/installer/targets/shared.d.ts +14 -0
- package/dist/mcp/daemon.d.ts +60 -1
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/ppid-watchdog.d.ts +44 -0
- package/dist/mcp/proxy.d.ts +6 -0
- package/dist/mcp/server-instructions.d.ts +12 -1
- package/dist/mcp/session.d.ts +2 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/tools.d.ts +110 -49
- package/dist/resolution/callback-synthesizer.d.ts +3 -3
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/index.d.ts +1 -0
- package/dist/resolution/import-resolver.d.ts +10 -0
- package/dist/resolution/index.d.ts +80 -0
- package/dist/resolution/name-matcher.d.ts +61 -0
- package/dist/resolution/types.d.ts +27 -3
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/search/query-utils.d.ts +35 -1
- package/dist/sync/watcher.d.ts +124 -32
- package/dist/telemetry/index.d.ts +146 -0
- package/dist/types.d.ts +25 -2
- package/dist/upgrade/index.d.ts +132 -0
- package/dist/utils.d.ts +30 -24
- package/package.json +7 -7
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codegraph upgrade`
|
|
3
|
+
*
|
|
4
|
+
* Self-update for the CLI, whatever way it was installed:
|
|
5
|
+
*
|
|
6
|
+
* - **bundle** — the self-contained runtime+app installed by `install.sh`
|
|
7
|
+
* (Linux/macOS) or `install.ps1` (Windows). Upgrading re-runs the SAME
|
|
8
|
+
* canonical installer script (single source of truth) so the download /
|
|
9
|
+
* version-resolution / PATH logic never drifts between first-install and
|
|
10
|
+
* upgrade.
|
|
11
|
+
* - **npm** — installed via `npm i -g @colbymchenry/codegraph`. Upgrading
|
|
12
|
+
* shells out to npm.
|
|
13
|
+
* - **npx** — ephemeral; nothing to upgrade (next `npx` fetches latest).
|
|
14
|
+
* - **source** — a git checkout running its own `dist/`; `git pull` + rebuild.
|
|
15
|
+
*
|
|
16
|
+
* Detection is structural (see `detectInstallMethod`): a bundle carries a
|
|
17
|
+
* vendored `node` binary and a `bin/codegraph` launcher next to its `lib/`, so
|
|
18
|
+
* we can recognize it from the running file's path without a marker file.
|
|
19
|
+
*
|
|
20
|
+
* Windows wrinkle: a running `node.exe` is locked and can't be deleted, so the
|
|
21
|
+
* bundle's `current\` dir can't be overwritten in place by the process doing
|
|
22
|
+
* the upgrade. We therefore spawn a DETACHED helper that waits for this
|
|
23
|
+
* process to exit (releasing the lock), then runs `install.ps1`. This is the
|
|
24
|
+
* conventional Windows self-update dance (rustup/nvm-windows do the same).
|
|
25
|
+
*/
|
|
26
|
+
export declare const REPO = "colbymchenry/codegraph";
|
|
27
|
+
export declare const NPM_PACKAGE = "@colbymchenry/codegraph";
|
|
28
|
+
export declare const INSTALL_SH_URL = "https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh";
|
|
29
|
+
export type InstallMethod = {
|
|
30
|
+
kind: 'bundle';
|
|
31
|
+
os: 'unix' | 'windows';
|
|
32
|
+
bundleRoot: string;
|
|
33
|
+
installDir: string | null;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'npm';
|
|
36
|
+
scope: 'global' | 'local';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'npx';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'source';
|
|
41
|
+
root: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'unknown';
|
|
44
|
+
reason: string;
|
|
45
|
+
};
|
|
46
|
+
export interface DetectInput {
|
|
47
|
+
/** `__filename` of the running CLI module — `<…>/dist/bin/codegraph.js`. */
|
|
48
|
+
filename: string;
|
|
49
|
+
platform: NodeJS.Platform;
|
|
50
|
+
cwd: string;
|
|
51
|
+
/** Injectable existence probe (defaults to fs.existsSync) — for tests. */
|
|
52
|
+
exists?: (p: string) => boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Where the bundle installer keeps its install root, derived from the bundle
|
|
56
|
+
* dir so an upgrade reuses a custom `CODEGRAPH_INSTALL_DIR`. Returns null when
|
|
57
|
+
* the layout isn't the one the installer creates (then the installer falls
|
|
58
|
+
* back to its own default).
|
|
59
|
+
*
|
|
60
|
+
* unix: <installDir>/versions/<vX.Y.Z> (bundleRoot) → <installDir>
|
|
61
|
+
* windows: <installDir>\current (bundleRoot) → <installDir>
|
|
62
|
+
*/
|
|
63
|
+
export declare function deriveInstallDir(bundleRoot: string, os: 'unix' | 'windows', exists: (p: string) => boolean): string | null;
|
|
64
|
+
export declare function detectInstallMethod(input: DetectInput): InstallMethod;
|
|
65
|
+
export interface Semver {
|
|
66
|
+
major: number;
|
|
67
|
+
minor: number;
|
|
68
|
+
patch: number;
|
|
69
|
+
pre: string | null;
|
|
70
|
+
}
|
|
71
|
+
export declare function parseSemver(version: string): Semver | null;
|
|
72
|
+
/** Returns >0 if a>b, <0 if a<b, 0 if equal. Throws on unparseable input. */
|
|
73
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
74
|
+
export declare function isUpdateAvailable(current: string, latest: string): boolean;
|
|
75
|
+
/** `0.9.9` / `v0.9.9` → `v0.9.9` (release tags are v-prefixed). */
|
|
76
|
+
export declare function normalizeVersion(v: string): string;
|
|
77
|
+
/** Strip a leading `v`: `v0.9.9` → `0.9.9`. */
|
|
78
|
+
export declare function stripV(v: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Parse the release tag out of the `Location` header GitHub returns for
|
|
81
|
+
* `/releases/latest` → `…/releases/tag/v0.9.9`. Pure so it's unit-tested.
|
|
82
|
+
*/
|
|
83
|
+
export declare function parseLatestTagFromLocation(location: string | undefined): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Resolve the latest release tag (e.g. `v0.9.9`).
|
|
86
|
+
*
|
|
87
|
+
* Primary: read the redirect `Location` from `github.com/<repo>/releases/latest`
|
|
88
|
+
* — same trick install.sh uses, because the unauthenticated GitHub API is
|
|
89
|
+
* rate-limited to 60 req/h/IP and 403s on shared/cloud hosts (issue #325). The
|
|
90
|
+
* redirect has no such limit. Fall back to the API only if the redirect can't
|
|
91
|
+
* be read.
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolveLatestVersion(repo?: string, timeoutMs?: number): Promise<string>;
|
|
94
|
+
export interface UpgradeOptions {
|
|
95
|
+
/** Pin a specific version (positional arg or CODEGRAPH_VERSION). */
|
|
96
|
+
version?: string;
|
|
97
|
+
/** Report current vs latest, don't change anything. */
|
|
98
|
+
check?: boolean;
|
|
99
|
+
/** Reinstall even if already on the resolved version. */
|
|
100
|
+
force?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** Injectable side-effects so the orchestrator stays unit-testable. */
|
|
103
|
+
export interface UpgradeDeps {
|
|
104
|
+
currentVersion: string;
|
|
105
|
+
method: InstallMethod;
|
|
106
|
+
resolveLatest: (pin?: string) => Promise<string>;
|
|
107
|
+
/** Run a command inheriting stdio; returns its exit code (-1 = spawn failed). */
|
|
108
|
+
run: (cmd: string, args: string[], env?: NodeJS.ProcessEnv) => number;
|
|
109
|
+
hasCommand: (cmd: string) => boolean;
|
|
110
|
+
log: (msg: string) => void;
|
|
111
|
+
warn: (msg: string) => void;
|
|
112
|
+
error: (msg: string) => void;
|
|
113
|
+
platform: NodeJS.Platform;
|
|
114
|
+
}
|
|
115
|
+
/** The honest, additive re-index reminder shown after a successful upgrade. */
|
|
116
|
+
export declare function reindexAdvisory(): string;
|
|
117
|
+
/**
|
|
118
|
+
* Returns the process exit code (0 = success / nothing to do, 1 = failure).
|
|
119
|
+
*/
|
|
120
|
+
export declare function runUpgrade(opts: UpgradeOptions, deps: UpgradeDeps): Promise<number>;
|
|
121
|
+
/** Build the in-place Windows upgrade script (exported for unit-testing). */
|
|
122
|
+
export declare function buildWindowsUpgradeScript(bundleRoot: string, version: string, arch: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* True if `cmd` resolves to an executable on PATH. A pure-Node PATH scan — NOT
|
|
125
|
+
* a spawned `command -v`/`which`: `command` is a shell builtin (no standalone
|
|
126
|
+
* binary on Debian, though macOS ships one), and `which` isn't guaranteed
|
|
127
|
+
* present on minimal images, so spawning either is unreliable. Scanning PATH
|
|
128
|
+
* ourselves behaves identically on every platform.
|
|
129
|
+
*/
|
|
130
|
+
export declare function hasCommand(cmd: string): boolean;
|
|
131
|
+
export declare function defaultRun(cmd: string, args: string[], env?: NodeJS.ProcessEnv): number;
|
|
132
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -29,12 +29,38 @@
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* Config "languages" whose nodes are pure key/value DATA lifted from a config
|
|
33
|
+
* file (e.g. Spring `application.{yml,properties}`), not source code.
|
|
34
|
+
*/
|
|
35
|
+
export declare const CONFIG_LEAF_LANGUAGES: ReadonlySet<string>;
|
|
36
|
+
/**
|
|
37
|
+
* A config-leaf node is a single key lifted out of a pure config/data file —
|
|
38
|
+
* `kind: 'constant'` in a {@link CONFIG_LEAF_LANGUAGES} language. Its on-disk
|
|
39
|
+
* line is `key = <value>`, and that value is routinely a secret (DB password,
|
|
40
|
+
* API key, JDBC URL with embedded creds). CodeGraph must surface the KEY only
|
|
41
|
+
* and never read/return the value, or it pushes secrets into agent context
|
|
42
|
+
* unbidden — the value isn't needed for resolution, and an agent that genuinely
|
|
43
|
+
* needs it can read the file directly. (#383)
|
|
44
|
+
*/
|
|
45
|
+
export declare function isConfigLeafNode(node: {
|
|
46
|
+
kind: string;
|
|
47
|
+
language?: string;
|
|
48
|
+
}): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Validate that a file path stays within the project root, resolving symlinks.
|
|
51
|
+
*
|
|
52
|
+
* Two layers: a cheap lexical check that catches `../` traversal, then a
|
|
53
|
+
* realpath check that catches symlink escapes — an in-repo symlink whose
|
|
54
|
+
* logical path is inside the root but whose real target points outside it
|
|
55
|
+
* (issue #527). A symlink that stays within the root is still allowed, so
|
|
56
|
+
* legitimate in-tree symlinks keep working. Both content-serving read sinks
|
|
57
|
+
* (codegraph_node `includeCode`, codegraph_explore source) go through here, so
|
|
58
|
+
* this is the chokepoint that keeps out-of-root file contents from leaking.
|
|
34
59
|
*
|
|
35
60
|
* @param projectRoot - The project root directory
|
|
36
|
-
* @param filePath - The relative file path to validate
|
|
37
|
-
* @returns The resolved absolute path, or null if it
|
|
61
|
+
* @param filePath - The (relative or absolute) file path to validate
|
|
62
|
+
* @returns The resolved absolute path (realpath when it exists), or null if it
|
|
63
|
+
* escapes the root
|
|
38
64
|
*/
|
|
39
65
|
export declare function validatePathWithinRoot(projectRoot: string, filePath: string): string | null;
|
|
40
66
|
/**
|
|
@@ -48,26 +74,6 @@ export declare function validatePathWithinRoot(projectRoot: string, filePath: st
|
|
|
48
74
|
* @returns An error message if invalid, or null if valid
|
|
49
75
|
*/
|
|
50
76
|
export declare function validateProjectPath(dirPath: string): string | null;
|
|
51
|
-
/**
|
|
52
|
-
* Check if a file path resolves to a location within the given root directory.
|
|
53
|
-
*
|
|
54
|
-
* Prevents path traversal attacks by ensuring the resolved absolute path
|
|
55
|
-
* starts with the resolved root path. Handles '..' sequences, symlink-like
|
|
56
|
-
* relative paths, and platform-specific separators.
|
|
57
|
-
*
|
|
58
|
-
* @param filePath - The path to check (can be relative or absolute)
|
|
59
|
-
* @param rootDir - The root directory that filePath must stay within
|
|
60
|
-
* @returns true if filePath resolves to a location within rootDir
|
|
61
|
-
*/
|
|
62
|
-
export declare function isPathWithinRoot(filePath: string, rootDir: string): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Like isPathWithinRoot but also resolves symlinks via fs.realpathSync.
|
|
65
|
-
*
|
|
66
|
-
* This catches symlink escapes where the logical path appears to be within
|
|
67
|
-
* root but the real path on disk points elsewhere. Falls back to logical
|
|
68
|
-
* path checking if realpath resolution fails (e.g. broken symlink).
|
|
69
|
-
*/
|
|
70
|
-
export declare function isPathWithinRootReal(filePath: string, rootDir: string): boolean;
|
|
71
77
|
/**
|
|
72
78
|
* Safely parse JSON with a fallback value.
|
|
73
79
|
* Prevents crashes from corrupted database metadata.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colbymchenry/codegraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Local-first code intelligence for AI agents (MCP). Self-contained — bundles its own runtime.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codegraph": "npm-shim.js"
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@colbymchenry/codegraph-darwin-arm64": "0.
|
|
19
|
-
"@colbymchenry/codegraph-darwin-x64": "0.
|
|
20
|
-
"@colbymchenry/codegraph-linux-arm64": "0.
|
|
21
|
-
"@colbymchenry/codegraph-linux-x64": "0.
|
|
22
|
-
"@colbymchenry/codegraph-win32-arm64": "0.
|
|
23
|
-
"@colbymchenry/codegraph-win32-x64": "0.
|
|
18
|
+
"@colbymchenry/codegraph-darwin-arm64": "1.0.0",
|
|
19
|
+
"@colbymchenry/codegraph-darwin-x64": "1.0.0",
|
|
20
|
+
"@colbymchenry/codegraph-linux-arm64": "1.0.0",
|
|
21
|
+
"@colbymchenry/codegraph-linux-x64": "1.0.0",
|
|
22
|
+
"@colbymchenry/codegraph-win32-arm64": "1.0.0",
|
|
23
|
+
"@colbymchenry/codegraph-win32-x64": "1.0.0"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"npm-shim.js",
|