truecourse 0.5.9 → 0.5.10
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/cli.mjs +24985 -6285
- package/package.json +1 -1
- package/server.mjs +117 -43
package/package.json
CHANGED
package/server.mjs
CHANGED
|
@@ -142246,7 +142246,7 @@ function getIO() {
|
|
|
142246
142246
|
var import_express10 = __toESM(require_express2(), 1);
|
|
142247
142247
|
var import_cors = __toESM(require_lib(), 1);
|
|
142248
142248
|
import fs13 from "node:fs";
|
|
142249
|
-
import { fileURLToPath as
|
|
142249
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
142250
142250
|
import path17 from "node:path";
|
|
142251
142251
|
|
|
142252
142252
|
// apps/dashboard/server/src/middleware/error.ts
|
|
@@ -150373,28 +150373,13 @@ function makeDenormalizer(graph) {
|
|
|
150373
150373
|
// packages/core/dist/commands/analyze-in-process.js
|
|
150374
150374
|
init_config2();
|
|
150375
150375
|
init_logger();
|
|
150376
|
-
async function analyzeInProcess(project, options = {}) {
|
|
150377
|
-
const startedAt = Date.now();
|
|
150378
|
-
log.info(`[LLM] Provider: claude-code, model: ${config.claudeCodeModel || "default"}, maxConcurrency: ${config.claudeCodeMaxConcurrency}`);
|
|
150379
|
-
const core = await analyzeCore(project, { ...options, mode: "full" });
|
|
150380
|
-
return persistFullAnalysis(project, core, startedAt);
|
|
150381
|
-
}
|
|
150382
150376
|
|
|
150383
|
-
// packages/core/dist/
|
|
150384
|
-
async function diffInProcess(project, options = {}) {
|
|
150385
|
-
const core = await analyzeCore(project, { ...options, mode: "diff" });
|
|
150386
|
-
return persistDiffAnalysis(project, core);
|
|
150387
|
-
}
|
|
150388
|
-
|
|
150389
|
-
// apps/dashboard/server/src/routes/analyses.ts
|
|
150390
|
-
init_analysis_registry();
|
|
150391
|
-
init_provider();
|
|
150392
|
-
|
|
150393
|
-
// apps/dashboard/server/src/services/telemetry.service.ts
|
|
150377
|
+
// packages/core/dist/services/telemetry.service.js
|
|
150394
150378
|
import fs10 from "node:fs";
|
|
150395
150379
|
import path14 from "node:path";
|
|
150396
150380
|
import os3 from "node:os";
|
|
150397
150381
|
import crypto from "node:crypto";
|
|
150382
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
150398
150383
|
|
|
150399
150384
|
// node_modules/.pnpm/posthog-node@4.18.0/node_modules/posthog-node/lib/node/index.mjs
|
|
150400
150385
|
import { posix, dirname as dirname6, sep as sep2 } from "path";
|
|
@@ -154173,13 +154158,13 @@ var PostHog = class extends PostHogBackendClient {
|
|
|
154173
154158
|
}
|
|
154174
154159
|
};
|
|
154175
154160
|
|
|
154176
|
-
//
|
|
154161
|
+
// packages/core/dist/services/telemetry.service.js
|
|
154177
154162
|
var DEFAULT_CONFIG = {
|
|
154178
154163
|
enabled: true,
|
|
154179
|
-
anonymousId: ""
|
|
154164
|
+
anonymousId: "",
|
|
154165
|
+
noticeShown: false
|
|
154180
154166
|
};
|
|
154181
154167
|
var POSTHOG_API_KEY = "phc_ys9Ykf49KmNqAC3fhq3jugTejc4BDqyKqRS8qRoYZYew";
|
|
154182
|
-
var TOOL_VERSION = "0.2.2";
|
|
154183
154168
|
function getTelemetryConfigPath() {
|
|
154184
154169
|
return path14.join(os3.homedir(), ".truecourse", "telemetry.json");
|
|
154185
154170
|
}
|
|
@@ -154197,7 +154182,8 @@ function readTelemetryConfig() {
|
|
|
154197
154182
|
} catch {
|
|
154198
154183
|
const config2 = {
|
|
154199
154184
|
enabled: true,
|
|
154200
|
-
anonymousId: crypto.randomUUID()
|
|
154185
|
+
anonymousId: crypto.randomUUID(),
|
|
154186
|
+
noticeShown: false
|
|
154201
154187
|
};
|
|
154202
154188
|
writeTelemetryConfig(config2);
|
|
154203
154189
|
return config2;
|
|
@@ -154219,9 +154205,12 @@ function writeTelemetryConfig(partial) {
|
|
|
154219
154205
|
}
|
|
154220
154206
|
var posthogClient = null;
|
|
154221
154207
|
function isTelemetryEnabled() {
|
|
154222
|
-
if (!POSTHOG_API_KEY)
|
|
154223
|
-
|
|
154224
|
-
if (process.env.
|
|
154208
|
+
if (!POSTHOG_API_KEY)
|
|
154209
|
+
return false;
|
|
154210
|
+
if (process.env.CI === "true")
|
|
154211
|
+
return false;
|
|
154212
|
+
if (process.env.TRUECOURSE_TELEMETRY === "0")
|
|
154213
|
+
return false;
|
|
154225
154214
|
const config2 = readTelemetryConfig();
|
|
154226
154215
|
return config2.enabled;
|
|
154227
154216
|
}
|
|
@@ -154235,28 +154224,74 @@ function getPostHogClient() {
|
|
|
154235
154224
|
return posthogClient;
|
|
154236
154225
|
}
|
|
154237
154226
|
function bucketFileCount(count) {
|
|
154238
|
-
if (count <= 50)
|
|
154239
|
-
|
|
154240
|
-
if (count <=
|
|
154227
|
+
if (count <= 50)
|
|
154228
|
+
return "1-50";
|
|
154229
|
+
if (count <= 200)
|
|
154230
|
+
return "50-200";
|
|
154231
|
+
if (count <= 500)
|
|
154232
|
+
return "200-500";
|
|
154241
154233
|
return "500+";
|
|
154242
154234
|
}
|
|
154243
154235
|
function bucketDuration(ms) {
|
|
154244
154236
|
const seconds = ms / 1e3;
|
|
154245
|
-
if (seconds < 5)
|
|
154246
|
-
|
|
154247
|
-
if (seconds <
|
|
154248
|
-
|
|
154237
|
+
if (seconds < 5)
|
|
154238
|
+
return "<5s";
|
|
154239
|
+
if (seconds < 15)
|
|
154240
|
+
return "5-15s";
|
|
154241
|
+
if (seconds < 60)
|
|
154242
|
+
return "15-60s";
|
|
154243
|
+
if (seconds < 300)
|
|
154244
|
+
return "1-5m";
|
|
154249
154245
|
return "5m+";
|
|
154250
154246
|
}
|
|
154247
|
+
var EXTENSION_TO_LANGUAGE = {
|
|
154248
|
+
".ts": "typescript",
|
|
154249
|
+
".tsx": "typescript",
|
|
154250
|
+
".js": "javascript",
|
|
154251
|
+
".jsx": "javascript",
|
|
154252
|
+
".py": "python",
|
|
154253
|
+
".cs": "csharp",
|
|
154254
|
+
".go": "go",
|
|
154255
|
+
".java": "java",
|
|
154256
|
+
".rb": "ruby",
|
|
154257
|
+
".rs": "rust"
|
|
154258
|
+
};
|
|
154259
|
+
function detectLanguages(result) {
|
|
154260
|
+
const languages = /* @__PURE__ */ new Set();
|
|
154261
|
+
for (const service of result.services) {
|
|
154262
|
+
for (const filePath of service.files) {
|
|
154263
|
+
const ext2 = path14.extname(filePath).toLowerCase();
|
|
154264
|
+
const lang = EXTENSION_TO_LANGUAGE[ext2];
|
|
154265
|
+
if (lang)
|
|
154266
|
+
languages.add(lang);
|
|
154267
|
+
}
|
|
154268
|
+
}
|
|
154269
|
+
return Array.from(languages).sort();
|
|
154270
|
+
}
|
|
154271
|
+
var cachedVersion = null;
|
|
154272
|
+
function readToolVersion() {
|
|
154273
|
+
if (cachedVersion)
|
|
154274
|
+
return cachedVersion;
|
|
154275
|
+
try {
|
|
154276
|
+
const here = fileURLToPath4(import.meta.url);
|
|
154277
|
+
const pkgPath = path14.resolve(path14.dirname(here), "..", "..", "package.json");
|
|
154278
|
+
const pkg = JSON.parse(fs10.readFileSync(pkgPath, "utf-8"));
|
|
154279
|
+
cachedVersion = String(pkg.version ?? "0.0.0");
|
|
154280
|
+
} catch {
|
|
154281
|
+
cachedVersion = "0.0.0";
|
|
154282
|
+
}
|
|
154283
|
+
return cachedVersion;
|
|
154284
|
+
}
|
|
154251
154285
|
function getSystemInfo() {
|
|
154252
154286
|
return {
|
|
154253
154287
|
os: `${process.platform}-${process.arch}`,
|
|
154254
|
-
version:
|
|
154288
|
+
version: readToolVersion()
|
|
154255
154289
|
};
|
|
154256
154290
|
}
|
|
154257
|
-
function trackEvent(event, properties) {
|
|
154291
|
+
async function trackEvent(event, properties) {
|
|
154258
154292
|
try {
|
|
154259
|
-
if (!isTelemetryEnabled())
|
|
154293
|
+
if (!isTelemetryEnabled())
|
|
154294
|
+
return;
|
|
154260
154295
|
const config2 = readTelemetryConfig();
|
|
154261
154296
|
const client = getPostHogClient();
|
|
154262
154297
|
const systemInfo = getSystemInfo();
|
|
@@ -154269,10 +154304,54 @@ function trackEvent(event, properties) {
|
|
|
154269
154304
|
os: systemInfo.os
|
|
154270
154305
|
}
|
|
154271
154306
|
});
|
|
154307
|
+
await client.flush();
|
|
154272
154308
|
} catch {
|
|
154273
154309
|
}
|
|
154274
154310
|
}
|
|
154275
154311
|
|
|
154312
|
+
// packages/core/dist/commands/analyze-in-process.js
|
|
154313
|
+
async function analyzeInProcess(project, options = {}) {
|
|
154314
|
+
const startedAt = Date.now();
|
|
154315
|
+
log.info(`[LLM] Provider: claude-code, model: ${config.claudeCodeModel || "default"}, maxConcurrency: ${config.claudeCodeMaxConcurrency}`);
|
|
154316
|
+
const core = await analyzeCore(project, { ...options, mode: "full" });
|
|
154317
|
+
const result = persistFullAnalysis(project, core, startedAt);
|
|
154318
|
+
if (options.source) {
|
|
154319
|
+
await trackEvent("analyze", {
|
|
154320
|
+
source: options.source,
|
|
154321
|
+
mode: "full",
|
|
154322
|
+
serviceCount: result.serviceCount,
|
|
154323
|
+
fileCountRange: bucketFileCount(result.fileCount),
|
|
154324
|
+
languages: detectLanguages(core.analysisResult),
|
|
154325
|
+
architecture: result.architecture,
|
|
154326
|
+
durationRange: bucketDuration(result.durationMs)
|
|
154327
|
+
});
|
|
154328
|
+
}
|
|
154329
|
+
return result;
|
|
154330
|
+
}
|
|
154331
|
+
|
|
154332
|
+
// packages/core/dist/commands/diff-in-process.js
|
|
154333
|
+
async function diffInProcess(project, options = {}) {
|
|
154334
|
+
const startedAt = Date.now();
|
|
154335
|
+
const core = await analyzeCore(project, { ...options, mode: "diff" });
|
|
154336
|
+
const result = persistDiffAnalysis(project, core);
|
|
154337
|
+
if (options.source) {
|
|
154338
|
+
await trackEvent("analyze", {
|
|
154339
|
+
source: options.source,
|
|
154340
|
+
mode: "diff",
|
|
154341
|
+
languages: detectLanguages(core.analysisResult),
|
|
154342
|
+
changedFileCount: result.diff.changedFiles.length,
|
|
154343
|
+
newViolations: result.diff.summary.newCount,
|
|
154344
|
+
resolvedViolations: result.diff.summary.resolvedCount,
|
|
154345
|
+
durationRange: bucketDuration(Date.now() - startedAt)
|
|
154346
|
+
});
|
|
154347
|
+
}
|
|
154348
|
+
return result;
|
|
154349
|
+
}
|
|
154350
|
+
|
|
154351
|
+
// apps/dashboard/server/src/routes/analyses.ts
|
|
154352
|
+
init_analysis_registry();
|
|
154353
|
+
init_provider();
|
|
154354
|
+
|
|
154276
154355
|
// packages/core/dist/services/violation-query.service.js
|
|
154277
154356
|
function getDisabledRuleKeys(repoPath) {
|
|
154278
154357
|
return new Set(readProjectConfig(repoPath).disabledRules ?? []);
|
|
@@ -154628,22 +154707,17 @@ async function runFullAnalyze(id, repo, opts) {
|
|
|
154628
154707
|
tracker: opts.tracker,
|
|
154629
154708
|
signal: opts.signal,
|
|
154630
154709
|
provider,
|
|
154710
|
+
source: "dashboard",
|
|
154631
154711
|
onLlmEstimate: createSocketLlmEstimateHandler(id)
|
|
154632
154712
|
});
|
|
154633
154713
|
emitViolationsReady(id, outcome.analysisId);
|
|
154634
154714
|
emitAnalysisComplete(id, outcome.analysisId);
|
|
154635
|
-
trackEvent("analyze", {
|
|
154636
|
-
serviceCount: outcome.serviceCount,
|
|
154637
|
-
fileCountRange: bucketFileCount(outcome.fileCount),
|
|
154638
|
-
languages: [],
|
|
154639
|
-
architecture: outcome.architecture,
|
|
154640
|
-
durationRange: bucketDuration(outcome.durationMs)
|
|
154641
|
-
});
|
|
154642
154715
|
}
|
|
154643
154716
|
async function runDiffAnalyze(id, repo, opts) {
|
|
154644
154717
|
const { diff } = await diffInProcess(repo, {
|
|
154645
154718
|
tracker: opts.tracker,
|
|
154646
154719
|
signal: opts.signal,
|
|
154720
|
+
source: "dashboard",
|
|
154647
154721
|
onLlmEstimate: createSocketLlmEstimateHandler(id)
|
|
154648
154722
|
});
|
|
154649
154723
|
emitViolationsReady(id, diff.id);
|
|
@@ -156159,7 +156233,7 @@ router9.get(
|
|
|
156159
156233
|
var analytics_default = router9;
|
|
156160
156234
|
|
|
156161
156235
|
// apps/dashboard/server/src/app.ts
|
|
156162
|
-
var __dirname3 = path17.dirname(
|
|
156236
|
+
var __dirname3 = path17.dirname(fileURLToPath5(import.meta.url));
|
|
156163
156237
|
function createApp(opts = {}) {
|
|
156164
156238
|
const app = (0, import_express10.default)();
|
|
156165
156239
|
app.use((0, import_cors.default)());
|