kodingo-cli 1.3.4 → 1.4.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.
@@ -9,6 +9,7 @@ exports.writeConfig = writeConfig;
9
9
  exports.writeWorkspaceConfig = writeWorkspaceConfig;
10
10
  exports.readWorkspaceConfig = readWorkspaceConfig;
11
11
  exports.isCloudMode = isCloudMode;
12
+ exports.getCredentials = getCredentials;
12
13
  exports.getPersistence = getPersistence;
13
14
  /**
14
15
  * Persistence config switcher.
@@ -66,6 +67,32 @@ function readWorkspaceConfig(repoPath) {
66
67
  function isCloudMode() {
67
68
  return readConfig().mode === "cloud";
68
69
  }
70
+ const API_BASE_DEFAULT = "https://kodingo-api.onrender.com";
71
+ /**
72
+ * Real, workspace-scoped project credentials, walking up to parent
73
+ * directories when the exact repoRoot isn't a registered workspace key.
74
+ * Moved here from scan-git.ts (build brief "Item 8 — the temporal lobe",
75
+ * 2026-10-01) — it originally lived there as a private helper, but
76
+ * cloud-event-port.ts/db-event-port.ts now need this SAME real lookup too
77
+ * (see those files' own doc comments — inferDecisionSummary was calling
78
+ * POST /infer with no auth header at all). Importing it back from
79
+ * scan-git.ts would create a real circular dependency (scan-git.ts already
80
+ * imports both event-port classes); this lower-level module has no such
81
+ * cycle. Zero behavior change from the original — a pure relocation.
82
+ */
83
+ function getCredentials(repoRoot) {
84
+ const config = readConfig();
85
+ const normRoot = repoRoot.replace(/\/+$/, "");
86
+ let wsEntry = config.workspaces?.[normRoot] ?? config.workspaces?.[normRoot + "/"];
87
+ let current = normRoot;
88
+ while (!wsEntry && current !== node_path_1.default.dirname(current)) {
89
+ current = node_path_1.default.dirname(current);
90
+ wsEntry = config.workspaces?.[current] ?? config.workspaces?.[current + "/"];
91
+ }
92
+ const token = wsEntry?.token ?? "";
93
+ const apiUrl = wsEntry?.apiUrl ?? config.apiUrl ?? API_BASE_DEFAULT;
94
+ return { token, apiUrl };
95
+ }
69
96
  /**
70
97
  * Returns the correct persistence adapter based on config.
71
98
  * Import this in commands instead of importing the adapters directly.
@@ -1,145 +1,18 @@
1
1
  "use strict";
2
- /**
3
- * vendoredCodeDetector.ts
4
- *
5
- * Real, general, structural detection of vendored/third-party/bundled code
6
- * — NOT a hardcoded library-name list as the primary mechanism. Build
7
- * brief: "Stop capturing vendored/third-party code as if it were the
8
- * client's own" (2026-09-22). Mirrored, identically-designed module in
9
- * kodingo-api (utils/vendoredCodeDetector.ts) and kodingo-vscode
10
- * (src/utils/vendoredCodeDetector.ts) — each repo has its own real,
11
- * separate walk/extract pipeline with no shared low-level utility package
12
- * between them (kodingo-core is explicitly scoped to decision/memory
13
- * lifecycle domain logic, not general file classification), so this is
14
- * duplicated by design, matching this codebase's own established
15
- * precedent (e.g. IGNORED_DIRS is already independently duplicated across
16
- * scan-repo.ts and security-scan.ts within this same repo). See this
17
- * brief's own final report for the full reasoning.
18
- *
19
- * Real, confirmed evidence this fixes: an admin deep scan of a real
20
- * .NET/WebForms project (TestHaven/FOTX) captured real jQuery internals
21
- * (domManip, isWindow, movePrevious) and real ASP.NET WebForms framework
22
- * internals (WebPartManager_InitiateWebPartDragDrop,
23
- * WebForm_GetElementByTagName, Zone_UpdatePosition) as if they were the
24
- * client's own business logic — diluting a real answer to "what is this
25
- * project" into near-nothing.
26
- *
27
- * Three real, independent layers, checked cheapest/most-certain first:
28
- * 1. Path/directory conventions — reliable across languages/ecosystems,
29
- * needs only the file path.
30
- * 2. File-naming conventions (.min.js/.min.css) — same, path-only.
31
- * 3. Content heuristics (minified shape, an explicit auto-generated
32
- * header) — needs real file content.
33
- * A fourth, explicitly-acknowledged-INCOMPLETE layer: a real, growing list
34
- * of specific, well-known bundled framework files. This list will NEVER be
35
- * complete — it exists because layers 1-2, by design, cannot catch every
36
- * real case: these specific files are frequently checked in un-minified,
37
- * under an ordinarily-legitimate-looking folder name (e.g. "Scripts/",
38
- * which is NOT treated as a vendored-directory convention here precisely
39
- * because plenty of real WebForms projects also put their OWN
40
- * app-specific JS there — see isVendoredPath's own reasoning below).
41
- */
42
- Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.isVendoredPath = isVendoredPath;
44
- exports.isVendoredContent = isVendoredContent;
45
- exports.isVendoredCode = isVendoredCode;
46
- const NOT_VENDORED = { vendored: false, reason: null };
47
- // ── Layer 1: path/directory conventions ─────────────────────────────────────
48
- const VENDORED_DIR_SEGMENTS = [
49
- "node_modules", "vendor", "bower_components", "jspm_packages", "pods",
50
- ".venv", "venv", "site-packages",
51
- ];
52
- // "wwwroot/lib/" specifically is ASP.NET Core's real, well-known convention
53
- // for client-side libraries pulled in via LibMan/npm — directly relevant
54
- // to this exact client's real stack. "lib/" alone is NOT treated as
55
- // vendored — an extremely common real application folder name on its own.
56
- const VENDORED_PATH_PAIRS = [
57
- ["wwwroot", "lib"],
58
- ];
59
- // Classic NuGet packages/ convention: packages/<PackageName>.<Version>/...
60
- // Deliberately NOT a bare "packages/" match — that would false-positive on
61
- // the equally common JS/TS monorepo convention (Lerna/Yarn/npm workspaces)
62
- // where packages/<name>/ holds the CLIENT'S OWN first-party code.
63
- const NUGET_VERSIONED_DIR = /^[A-Za-z0-9_.-]+\.\d+\.\d+(\.\d+)?(-[A-Za-z0-9.]+)?$/;
64
- function pathSegments(filePath) {
65
- return filePath.replace(/\\/g, "/").split("/").filter(Boolean);
66
- }
67
- function isVendoredPath(filePath) {
68
- const segments = pathSegments(filePath);
69
- const lowerSegments = segments.map(s => s.toLowerCase());
70
- for (const dir of VENDORED_DIR_SEGMENTS) {
71
- if (lowerSegments.includes(dir)) {
72
- return { vendored: true, reason: `Path contains the "${dir}/" vendored-dependency directory convention.` };
73
- }
74
- }
75
- for (const [first, second] of VENDORED_PATH_PAIRS) {
76
- for (let i = 0; i < lowerSegments.length - 1; i++) {
77
- if (lowerSegments[i] === first && lowerSegments[i + 1] === second) {
78
- return { vendored: true, reason: `Path contains the "${first}/${second}/" vendored-dependency directory convention.` };
79
- }
80
- }
81
- }
82
- const packagesIdx = lowerSegments.indexOf("packages");
83
- if (packagesIdx !== -1 && packagesIdx + 1 < segments.length && NUGET_VERSIONED_DIR.test(segments[packagesIdx + 1])) {
84
- return { vendored: true, reason: `Path matches the classic NuGet "packages/<Name>.<Version>/" vendored-package convention.` };
85
- }
86
- const basename = segments[segments.length - 1] ?? "";
87
- if (/\.min\.(js|css)$/i.test(basename) || /-min\.(js|css)$/i.test(basename)) {
88
- return { vendored: true, reason: `Filename "${basename}" follows the minified-distribution naming convention (.min.js/.min.css).` };
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]; } };
89
7
  }
90
- const knownFileReason = matchKnownVendoredFile(basename);
91
- if (knownFileReason)
92
- return { vendored: true, reason: knownFileReason };
93
- return NOT_VENDORED;
94
- }
95
- // ── Layer 2: content heuristics ─────────────────────────────────────────────
96
- const MIN_CONTENT_LENGTH_FOR_MINIFICATION_CHECK = 5000;
97
- const MINIFIED_AVG_LINE_LENGTH_THRESHOLD = 500;
98
- const AUTO_GENERATED_HEADER_PATTERN = /<auto-generated|@generated\b|do not (edit|modify) this file|this file (is|was) auto-generated|machine[- ]generated/i;
99
- function isVendoredContent(content) {
100
- const header = content.slice(0, 500);
101
- if (AUTO_GENERATED_HEADER_PATTERN.test(header)) {
102
- return { vendored: true, reason: "File header contains an explicit auto-generated marker." };
103
- }
104
- if (content.length >= MIN_CONTENT_LENGTH_FOR_MINIFICATION_CHECK) {
105
- const lineCount = content.split("\n").length;
106
- const avgLineLength = content.length / Math.max(1, lineCount);
107
- if (avgLineLength > MINIFIED_AVG_LINE_LENGTH_THRESHOLD) {
108
- return {
109
- vendored: true,
110
- reason: `Unusually long average line length (${Math.round(avgLineLength)} chars/line across ${lineCount} lines) consistent with minified/bundled code, not hand-written source.`,
111
- };
112
- }
113
- }
114
- return NOT_VENDORED;
115
- }
116
- // ── Layer 3 (secondary, explicitly incomplete): known bundled framework files ──
117
- const KNOWN_VENDORED_FILENAME_PATTERNS = [
118
- /^jquery(-\d+(\.\d+){1,2})?(\.min)?\.js$/i,
119
- /^jquery-ui(-\d+(\.\d+){1,2})?(\.min)?\.js$/i,
120
- /^jquery\.validate(\.unobtrusive)?(\.min)?\.js$/i,
121
- /^jquery\.unobtrusive-ajax(\.min)?\.js$/i,
122
- /^WebUIValidation\.js$/i,
123
- /^WebForms\.js$/i,
124
- /^MicrosoftAjax(WebForms|Timer)?(\.debug)?\.js$/i,
125
- /^SmartNav\.js$/i,
126
- /^bootstrap(\.bundle)?(\.min)?\.(js|css)$/i,
127
- /^modernizr(-\d+(\.\d+){1,2})?(\.min)?\.js$/i,
128
- ];
129
- function matchKnownVendoredFile(basename) {
130
- for (const pattern of KNOWN_VENDORED_FILENAME_PATTERNS) {
131
- if (pattern.test(basename)) {
132
- return `Filename "${basename}" matches a real, known bundled/vendored framework file (secondary, explicitly-incomplete list — see this module's own file header).`;
133
- }
134
- }
135
- return null;
136
- }
137
- // ── Combined convenience ─────────────────────────────────────────────────────
138
- function isVendoredCode(filePath, content) {
139
- const pathResult = isVendoredPath(filePath);
140
- if (pathResult.vendored)
141
- return pathResult;
142
- if (content !== null)
143
- return isVendoredContent(content);
144
- return NOT_VENDORED;
145
- }
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /** Compatibility facade; canonical vendored-code policy lives in kodingo-core. */
18
+ __exportStar(require("kodingo-core/dist/src/entity-extractor/vendoredCodeDetector"), exports);
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareVersions = compareVersions;
4
+ exports.enforceVersionPolicy = enforceVersionPolicy;
5
+ const persistence_config_1 = require("./persistence-config");
6
+ const local_deep_scan_extractor_1 = require("./local-deep-scan-extractor");
7
+ const update_1 = require("../commands/update");
8
+ const { version: CLI_VERSION } = require("../../package.json");
9
+ function compareVersions(left, right) {
10
+ const a = left.split(".").map(Number), b = right.split(".").map(Number);
11
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
12
+ const delta = (a[i] ?? 0) - (b[i] ?? 0);
13
+ if (delta)
14
+ return delta > 0 ? 1 : -1;
15
+ }
16
+ return 0;
17
+ }
18
+ async function enforceVersionPolicy(args = process.argv.slice(2)) {
19
+ if (process.env.KODINGO_SKIP_UPDATE_CHECK === "true" || args[0] === "update")
20
+ return;
21
+ const apiUrl = ((0, persistence_config_1.readConfig)().apiUrl ?? "https://kodingo-api.onrender.com").replace(/\/$/, "");
22
+ let policy;
23
+ try {
24
+ const response = await fetch(`${apiUrl}/cli/version-policy`, { signal: AbortSignal.timeout(3000) });
25
+ if (!response.ok)
26
+ return;
27
+ policy = await response.json();
28
+ }
29
+ catch {
30
+ return;
31
+ }
32
+ if (local_deep_scan_extractor_1.EXTRACTOR_FORMAT_VERSION < policy.minimumExtractorFormat || local_deep_scan_extractor_1.EXTRACTOR_FORMAT_VERSION > policy.maximumExtractorFormat)
33
+ throw new Error(`${policy.message} Run: ${policy.updateCommand}`);
34
+ if (compareVersions(CLI_VERSION, policy.minimumCliVersion) < 0)
35
+ throw new Error(`Kodingo CLI ${CLI_VERSION} is below the required ${policy.minimumCliVersion}. Run: ${policy.updateCommand}`);
36
+ const nonInteractive = Boolean(process.env.CI) || args.includes("--no-update") || process.env.KODINGO_NO_AUTO_UPDATE === "true";
37
+ if (compareVersions(CLI_VERSION, policy.latestCliVersion) < 0) {
38
+ if (nonInteractive) {
39
+ console.warn(`Kodingo CLI ${policy.latestCliVersion} is available. Run: ${policy.updateCommand}`);
40
+ return;
41
+ }
42
+ await (0, update_1.updateCommand)(policy.latestCliVersion);
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "kodingo-cli",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "description": "Kodingo CLI",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "type": "commonjs",
8
8
  "main": "dist/cli.js",
9
9
  "bin": {
10
- "kodingo": "dist/cli.js"
10
+ "kodingo": "dist/bootstrap.js"
11
11
  },
12
12
  "files": [
13
13
  "dist"
@@ -26,7 +26,7 @@
26
26
  "@typescript-eslint/typescript-estree": "^8.61.1",
27
27
  "commander": "^12.1.0",
28
28
  "kodingo-agent": "^0.2.0",
29
- "kodingo-core": "^0.3.1",
29
+ "kodingo-core": "^0.3.6",
30
30
  "open": "^11.0.0",
31
31
  "simple-git": "^3.30.0",
32
32
  "tree-sitter-wasms": "^0.1.13",
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const graph_builder_1 = require("./utils/graph-builder");
4
- async function main() {
5
- const repoRoot = process.argv[2];
6
- const graph = await (0, graph_builder_1.buildGraph)(repoRoot);
7
- const node = Object.values(graph.nodes).find(n => n.name === "projectRoutes");
8
- console.log(node);
9
- }
10
- main();
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const ast_parser_1 = require("./utils/ast-parser");
8
- async function main() {
9
- const filePath = process.argv[2];
10
- const source = fs_1.default.readFileSync(filePath, "utf-8");
11
- const symbols = await (0, ast_parser_1.parseFile)(filePath, source);
12
- for (const s of symbols) {
13
- console.log(`${s.name}: calls = [${s.calls.join(", ")}]`);
14
- }
15
- }
16
- main();