@codacy/verity-cli 0.25.0-experimental.ed0c319 → 0.26.0-experimental.d7dfc00
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/bin/verity.js +220 -171
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -11216,8 +11216,63 @@ function registerAuthCommands(program2) {
|
|
|
11216
11216
|
}
|
|
11217
11217
|
|
|
11218
11218
|
// src/lib/hooks.ts
|
|
11219
|
+
var import_promises5 = require("node:fs/promises");
|
|
11220
|
+
var import_node_path5 = require("node:path");
|
|
11221
|
+
|
|
11222
|
+
// src/lib/json-file.ts
|
|
11219
11223
|
var import_promises4 = require("node:fs/promises");
|
|
11220
11224
|
var import_node_path4 = require("node:path");
|
|
11225
|
+
function jsonSemanticEqual(a, b) {
|
|
11226
|
+
if (a === b) return true;
|
|
11227
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
11228
|
+
return a === b;
|
|
11229
|
+
}
|
|
11230
|
+
const aIsArr = Array.isArray(a);
|
|
11231
|
+
const bIsArr = Array.isArray(b);
|
|
11232
|
+
if (aIsArr || bIsArr) {
|
|
11233
|
+
if (!aIsArr || !bIsArr || a.length !== b.length) return false;
|
|
11234
|
+
for (let i = 0; i < a.length; i++) {
|
|
11235
|
+
if (!jsonSemanticEqual(a[i], b[i])) return false;
|
|
11236
|
+
}
|
|
11237
|
+
return true;
|
|
11238
|
+
}
|
|
11239
|
+
const ao = a;
|
|
11240
|
+
const bo = b;
|
|
11241
|
+
const aKeys = Object.keys(ao).filter((k) => ao[k] !== void 0);
|
|
11242
|
+
const bKeys = Object.keys(bo).filter((k) => bo[k] !== void 0);
|
|
11243
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
11244
|
+
for (const k of aKeys) {
|
|
11245
|
+
if (bo[k] === void 0) return false;
|
|
11246
|
+
if (!jsonSemanticEqual(ao[k], bo[k])) return false;
|
|
11247
|
+
}
|
|
11248
|
+
return true;
|
|
11249
|
+
}
|
|
11250
|
+
function detectJsonIndent(raw) {
|
|
11251
|
+
const m = raw.match(/\n([ \t]+)\S/);
|
|
11252
|
+
return m ? m[1] : 2;
|
|
11253
|
+
}
|
|
11254
|
+
async function writeJsonFilePreservingStyle(file, value) {
|
|
11255
|
+
let currentRaw = null;
|
|
11256
|
+
try {
|
|
11257
|
+
currentRaw = await (0, import_promises4.readFile)(file, "utf-8");
|
|
11258
|
+
} catch {
|
|
11259
|
+
currentRaw = null;
|
|
11260
|
+
}
|
|
11261
|
+
if (currentRaw !== null) {
|
|
11262
|
+
try {
|
|
11263
|
+
if (jsonSemanticEqual(JSON.parse(currentRaw), value)) return false;
|
|
11264
|
+
} catch {
|
|
11265
|
+
}
|
|
11266
|
+
}
|
|
11267
|
+
const indent = currentRaw !== null ? detectJsonIndent(currentRaw) : 2;
|
|
11268
|
+
const next = JSON.stringify(value, null, indent) + "\n";
|
|
11269
|
+
if (next === currentRaw) return false;
|
|
11270
|
+
await (0, import_promises4.mkdir)((0, import_node_path4.dirname)(file), { recursive: true });
|
|
11271
|
+
await (0, import_promises4.writeFile)(file, next);
|
|
11272
|
+
return true;
|
|
11273
|
+
}
|
|
11274
|
+
|
|
11275
|
+
// src/lib/hooks.ts
|
|
11221
11276
|
var VERITY_STOP_HOOK = {
|
|
11222
11277
|
type: "command",
|
|
11223
11278
|
command: "verity analyze",
|
|
@@ -11295,7 +11350,7 @@ function globalSettingsFile() {
|
|
|
11295
11350
|
}
|
|
11296
11351
|
async function readSettings() {
|
|
11297
11352
|
try {
|
|
11298
|
-
const content = await (0,
|
|
11353
|
+
const content = await (0, import_promises5.readFile)(CLAUDE_SETTINGS_FILE, "utf-8");
|
|
11299
11354
|
return JSON.parse(content);
|
|
11300
11355
|
} catch {
|
|
11301
11356
|
return {};
|
|
@@ -11306,7 +11361,7 @@ async function readAllSettings() {
|
|
|
11306
11361
|
const out = [];
|
|
11307
11362
|
for (const f of files) {
|
|
11308
11363
|
try {
|
|
11309
|
-
out.push(JSON.parse(await (0,
|
|
11364
|
+
out.push(JSON.parse(await (0, import_promises5.readFile)(f, "utf-8")));
|
|
11310
11365
|
} catch {
|
|
11311
11366
|
}
|
|
11312
11367
|
}
|
|
@@ -11335,7 +11390,7 @@ async function checkExternalVerityHooks() {
|
|
|
11335
11390
|
for (const f of [SETTINGS_LOCAL_FILE, globalSettingsFile()]) {
|
|
11336
11391
|
let settings;
|
|
11337
11392
|
try {
|
|
11338
|
-
settings = JSON.parse(await (0,
|
|
11393
|
+
settings = JSON.parse(await (0, import_promises5.readFile)(f, "utf-8"));
|
|
11339
11394
|
} catch {
|
|
11340
11395
|
continue;
|
|
11341
11396
|
}
|
|
@@ -11369,20 +11424,17 @@ async function checkAllVerityHooksDetailed() {
|
|
|
11369
11424
|
return { stop, intent, baseline, current: hasCurrent, legacyOnly: hasLegacy && !hasCurrent };
|
|
11370
11425
|
}
|
|
11371
11426
|
async function writeSettings(settings) {
|
|
11372
|
-
await (
|
|
11373
|
-
await (0, import_promises4.writeFile)(CLAUDE_SETTINGS_FILE, JSON.stringify(settings, null, 2) + "\n");
|
|
11427
|
+
await writeJsonFilePreservingStyle(CLAUDE_SETTINGS_FILE, settings);
|
|
11374
11428
|
}
|
|
11375
11429
|
async function readSettingsAt(root) {
|
|
11376
11430
|
try {
|
|
11377
|
-
return JSON.parse(await (0,
|
|
11431
|
+
return JSON.parse(await (0, import_promises5.readFile)((0, import_node_path5.join)(root, CLAUDE_SETTINGS_FILE), "utf-8"));
|
|
11378
11432
|
} catch {
|
|
11379
11433
|
return {};
|
|
11380
11434
|
}
|
|
11381
11435
|
}
|
|
11382
11436
|
async function writeSettingsAt(root, settings) {
|
|
11383
|
-
|
|
11384
|
-
await (0, import_promises4.mkdir)((0, import_node_path4.dirname)(file), { recursive: true });
|
|
11385
|
-
await (0, import_promises4.writeFile)(file, JSON.stringify(settings, null, 2) + "\n");
|
|
11437
|
+
await writeJsonFilePreservingStyle((0, import_node_path5.join)(root, CLAUDE_SETTINGS_FILE), settings);
|
|
11386
11438
|
}
|
|
11387
11439
|
async function hasLegacyHooksAt(root) {
|
|
11388
11440
|
const settings = await readSettingsAt(root);
|
|
@@ -11621,7 +11673,7 @@ function registerHooksCommands(program2) {
|
|
|
11621
11673
|
var import_node_crypto3 = require("node:crypto");
|
|
11622
11674
|
|
|
11623
11675
|
// src/lib/conversation-buffer.ts
|
|
11624
|
-
var
|
|
11676
|
+
var import_promises6 = require("node:fs/promises");
|
|
11625
11677
|
var import_node_fs3 = require("node:fs");
|
|
11626
11678
|
var import_node_child_process5 = require("node:child_process");
|
|
11627
11679
|
var import_node_crypto = require("node:crypto");
|
|
@@ -11633,7 +11685,7 @@ function bufferTmpPath() {
|
|
|
11633
11685
|
}
|
|
11634
11686
|
async function appendToConversationBuffer(prompt, sessionId) {
|
|
11635
11687
|
try {
|
|
11636
|
-
await (0,
|
|
11688
|
+
await (0, import_promises6.mkdir)(VERITY_DIR, { recursive: true });
|
|
11637
11689
|
let sanitized = prompt.length > MAX_INTENT_CHARS ? prompt.slice(0, MAX_INTENT_CHARS) : prompt;
|
|
11638
11690
|
sanitized = stripImageReferences(sanitized);
|
|
11639
11691
|
const entry = {
|
|
@@ -11651,8 +11703,8 @@ async function appendToConversationBuffer(prompt, sessionId) {
|
|
|
11651
11703
|
const capped = recent.slice(-CONVERSATION_MAX_ENTRIES);
|
|
11652
11704
|
const content = capped.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
11653
11705
|
const tmpFile = bufferTmpPath();
|
|
11654
|
-
await (0,
|
|
11655
|
-
await (0,
|
|
11706
|
+
await (0, import_promises6.writeFile)(tmpFile, content);
|
|
11707
|
+
await (0, import_promises6.rename)(tmpFile, CONVERSATION_BUFFER_FILE);
|
|
11656
11708
|
} catch {
|
|
11657
11709
|
}
|
|
11658
11710
|
}
|
|
@@ -11669,10 +11721,10 @@ async function readAndClearConversationBuffer(currentSessionId) {
|
|
|
11669
11721
|
if (others.length > 0) {
|
|
11670
11722
|
const remaining = others.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
11671
11723
|
const tmpFile = bufferTmpPath();
|
|
11672
|
-
await (0,
|
|
11673
|
-
await (0,
|
|
11724
|
+
await (0, import_promises6.writeFile)(tmpFile, remaining);
|
|
11725
|
+
await (0, import_promises6.rename)(tmpFile, CONVERSATION_BUFFER_FILE);
|
|
11674
11726
|
} else {
|
|
11675
|
-
await (0,
|
|
11727
|
+
await (0, import_promises6.unlink)(CONVERSATION_BUFFER_FILE).catch(() => {
|
|
11676
11728
|
});
|
|
11677
11729
|
}
|
|
11678
11730
|
if (mine.length > 0) {
|
|
@@ -11684,8 +11736,8 @@ async function readAndClearConversationBuffer(currentSessionId) {
|
|
|
11684
11736
|
}
|
|
11685
11737
|
if ((0, import_node_fs3.existsSync)(INTENT_FILE)) {
|
|
11686
11738
|
try {
|
|
11687
|
-
const content = await (0,
|
|
11688
|
-
await (0,
|
|
11739
|
+
const content = await (0, import_promises6.readFile)(INTENT_FILE, "utf-8");
|
|
11740
|
+
await (0, import_promises6.unlink)(INTENT_FILE).catch(() => {
|
|
11689
11741
|
});
|
|
11690
11742
|
const data = JSON.parse(content);
|
|
11691
11743
|
if (data.prompt) {
|
|
@@ -11708,7 +11760,7 @@ async function readAndClearConversationBuffer(currentSessionId) {
|
|
|
11708
11760
|
}
|
|
11709
11761
|
async function readBufferEntries() {
|
|
11710
11762
|
try {
|
|
11711
|
-
const content = await (0,
|
|
11763
|
+
const content = await (0, import_promises6.readFile)(CONVERSATION_BUFFER_FILE, "utf-8");
|
|
11712
11764
|
const entries = [];
|
|
11713
11765
|
for (const line of content.split("\n")) {
|
|
11714
11766
|
const trimmed = line.trim();
|
|
@@ -11738,9 +11790,9 @@ function getRecentCommitMessages() {
|
|
|
11738
11790
|
}
|
|
11739
11791
|
|
|
11740
11792
|
// src/lib/task-context-buffer.ts
|
|
11741
|
-
var
|
|
11793
|
+
var import_promises7 = require("node:fs/promises");
|
|
11742
11794
|
var import_node_fs4 = require("node:fs");
|
|
11743
|
-
var
|
|
11795
|
+
var import_node_path6 = require("node:path");
|
|
11744
11796
|
var TASK_CONTEXT_DIR = `${VERITY_DIR}/.task-context`;
|
|
11745
11797
|
var MAX_BUFFER_BYTES = 500 * 1024;
|
|
11746
11798
|
var MAX_PROMPT_CHARS = 2e3;
|
|
@@ -11781,7 +11833,7 @@ async function readTaskContextBuffer(taskId) {
|
|
|
11781
11833
|
const filePath = bufferPath(taskId);
|
|
11782
11834
|
if (!(0, import_node_fs4.existsSync)(filePath)) return null;
|
|
11783
11835
|
try {
|
|
11784
|
-
const content = await (0,
|
|
11836
|
+
const content = await (0, import_promises7.readFile)(filePath, "utf-8");
|
|
11785
11837
|
if (!content.trim()) return null;
|
|
11786
11838
|
const lines = content.split("\n").filter((l) => l.trim());
|
|
11787
11839
|
const formatted = [];
|
|
@@ -11814,15 +11866,15 @@ async function readTaskContextBuffer(taskId) {
|
|
|
11814
11866
|
async function cleanupTaskContextBuffers() {
|
|
11815
11867
|
try {
|
|
11816
11868
|
if (!(0, import_node_fs4.existsSync)(TASK_CONTEXT_DIR)) return;
|
|
11817
|
-
const files = await (0,
|
|
11869
|
+
const files = await (0, import_promises7.readdir)(TASK_CONTEXT_DIR);
|
|
11818
11870
|
const cutoffMs = Date.now() - RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
11819
11871
|
for (const file of files) {
|
|
11820
11872
|
if (!file.endsWith(".jsonl")) continue;
|
|
11821
|
-
const filePath = (0,
|
|
11873
|
+
const filePath = (0, import_node_path6.join)(TASK_CONTEXT_DIR, file);
|
|
11822
11874
|
try {
|
|
11823
|
-
const stats = await (0,
|
|
11875
|
+
const stats = await (0, import_promises7.stat)(filePath);
|
|
11824
11876
|
if (stats.mtimeMs < cutoffMs) {
|
|
11825
|
-
await (0,
|
|
11877
|
+
await (0, import_promises7.unlink)(filePath);
|
|
11826
11878
|
}
|
|
11827
11879
|
} catch {
|
|
11828
11880
|
}
|
|
@@ -11832,33 +11884,33 @@ async function cleanupTaskContextBuffers() {
|
|
|
11832
11884
|
}
|
|
11833
11885
|
function bufferPath(taskId) {
|
|
11834
11886
|
const safe = taskId.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
11835
|
-
return (0,
|
|
11887
|
+
return (0, import_node_path6.join)(TASK_CONTEXT_DIR, `${safe}.jsonl`);
|
|
11836
11888
|
}
|
|
11837
11889
|
async function appendEntry(taskId, entry) {
|
|
11838
11890
|
try {
|
|
11839
|
-
await (0,
|
|
11891
|
+
await (0, import_promises7.mkdir)(TASK_CONTEXT_DIR, { recursive: true });
|
|
11840
11892
|
const filePath = bufferPath(taskId);
|
|
11841
11893
|
if ((0, import_node_fs4.existsSync)(filePath)) {
|
|
11842
|
-
const stats = await (0,
|
|
11894
|
+
const stats = await (0, import_promises7.stat)(filePath);
|
|
11843
11895
|
if (stats.size >= MAX_BUFFER_BYTES) {
|
|
11844
|
-
const content = await (0,
|
|
11896
|
+
const content = await (0, import_promises7.readFile)(filePath, "utf-8");
|
|
11845
11897
|
const lines = content.split("\n").filter((l) => l.trim());
|
|
11846
11898
|
const keepFrom = Math.floor(lines.length * 0.25);
|
|
11847
11899
|
const pruned = lines.slice(keepFrom).join("\n") + "\n";
|
|
11848
|
-
await (0,
|
|
11900
|
+
await (0, import_promises7.writeFile)(filePath, pruned);
|
|
11849
11901
|
}
|
|
11850
11902
|
}
|
|
11851
11903
|
const line = JSON.stringify(entry) + "\n";
|
|
11852
|
-
const existing = (0, import_node_fs4.existsSync)(filePath) ? await (0,
|
|
11853
|
-
await (0,
|
|
11904
|
+
const existing = (0, import_node_fs4.existsSync)(filePath) ? await (0, import_promises7.readFile)(filePath, "utf-8") : "";
|
|
11905
|
+
await (0, import_promises7.writeFile)(filePath, existing + line);
|
|
11854
11906
|
} catch {
|
|
11855
11907
|
}
|
|
11856
11908
|
}
|
|
11857
11909
|
|
|
11858
11910
|
// src/lib/memory-retrieval.ts
|
|
11859
|
-
var
|
|
11911
|
+
var import_promises8 = require("node:fs/promises");
|
|
11860
11912
|
var import_node_fs5 = require("node:fs");
|
|
11861
|
-
var
|
|
11913
|
+
var import_node_path7 = require("node:path");
|
|
11862
11914
|
var memoryDir = () => projectPath(`${VERITY_DIR}/memory`);
|
|
11863
11915
|
var DOMAINS = ["decisions", "quality", "security", "intent", "gotchas", "patterns", "domain", "integrations"];
|
|
11864
11916
|
var DEFAULT_BUDGET_TOKENS = 2e3;
|
|
@@ -11956,14 +12008,14 @@ async function retrieveForInjection(promptText, taskFiles = [], budgetTokens = D
|
|
|
11956
12008
|
const promptTokens = tokenize(promptText);
|
|
11957
12009
|
const nodes = [];
|
|
11958
12010
|
for (const domain of DOMAINS) {
|
|
11959
|
-
const domainDir = (0,
|
|
12011
|
+
const domainDir = (0, import_node_path7.join)(memoryDir(), domain);
|
|
11960
12012
|
if (!(0, import_node_fs5.existsSync)(domainDir)) continue;
|
|
11961
12013
|
try {
|
|
11962
|
-
const files = await (0,
|
|
12014
|
+
const files = await (0, import_promises8.readdir)(domainDir);
|
|
11963
12015
|
for (const file of files) {
|
|
11964
12016
|
if (!file.endsWith(".md")) continue;
|
|
11965
12017
|
try {
|
|
11966
|
-
const content = await (0,
|
|
12018
|
+
const content = await (0, import_promises8.readFile)((0, import_node_path7.join)(domainDir, file), "utf-8");
|
|
11967
12019
|
const { fm, body } = parseFrontmatter(content);
|
|
11968
12020
|
if (fm.status && fm.status !== "active") continue;
|
|
11969
12021
|
nodes.push({
|
|
@@ -12021,9 +12073,9 @@ async function retrieveForInjection(promptText, taskFiles = [], budgetTokens = D
|
|
|
12021
12073
|
}
|
|
12022
12074
|
|
|
12023
12075
|
// src/lib/memory-sync.ts
|
|
12024
|
-
var
|
|
12076
|
+
var import_promises9 = require("node:fs/promises");
|
|
12025
12077
|
var import_node_fs6 = require("node:fs");
|
|
12026
|
-
var
|
|
12078
|
+
var import_node_path8 = require("node:path");
|
|
12027
12079
|
var import_node_crypto2 = require("node:crypto");
|
|
12028
12080
|
|
|
12029
12081
|
// src/lib/glob-match.ts
|
|
@@ -12092,18 +12144,18 @@ var memoryDir2 = () => projectPath(`${VERITY_DIR}/memory`);
|
|
|
12092
12144
|
var DOMAINS2 = ["decisions", "quality", "security", "intent", "gotchas", "patterns", "domain", "integrations", "_archive"];
|
|
12093
12145
|
var syncStateFile = () => projectPath(`${VERITY_DIR}/.memory-sync-state.json`);
|
|
12094
12146
|
async function ensureMemoryDir() {
|
|
12095
|
-
await (0,
|
|
12147
|
+
await (0, import_promises9.mkdir)(memoryDir2(), { recursive: true });
|
|
12096
12148
|
for (const domain of DOMAINS2) {
|
|
12097
|
-
await (0,
|
|
12149
|
+
await (0, import_promises9.mkdir)((0, import_node_path8.join)(memoryDir2(), domain), { recursive: true });
|
|
12098
12150
|
}
|
|
12099
|
-
if (!(0, import_node_fs6.existsSync)((0,
|
|
12100
|
-
await (0,
|
|
12151
|
+
if (!(0, import_node_fs6.existsSync)((0, import_node_path8.join)(memoryDir2(), "SCHEMA.md"))) {
|
|
12152
|
+
await (0, import_promises9.writeFile)((0, import_node_path8.join)(memoryDir2(), "SCHEMA.md"), SCHEMA_TEMPLATE);
|
|
12101
12153
|
}
|
|
12102
|
-
if (!(0, import_node_fs6.existsSync)((0,
|
|
12103
|
-
await (0,
|
|
12154
|
+
if (!(0, import_node_fs6.existsSync)((0, import_node_path8.join)(memoryDir2(), "index.md"))) {
|
|
12155
|
+
await (0, import_promises9.writeFile)((0, import_node_path8.join)(memoryDir2(), "index.md"), "# Project Memory Index\n\nNo nodes yet. Run an analysis to start building the knowledge graph.\n");
|
|
12104
12156
|
}
|
|
12105
|
-
if (!(0, import_node_fs6.existsSync)((0,
|
|
12106
|
-
await (0,
|
|
12157
|
+
if (!(0, import_node_fs6.existsSync)((0, import_node_path8.join)(memoryDir2(), "log.md"))) {
|
|
12158
|
+
await (0, import_promises9.writeFile)((0, import_node_path8.join)(memoryDir2(), "log.md"), "# Memory Log\n\n");
|
|
12107
12159
|
}
|
|
12108
12160
|
}
|
|
12109
12161
|
async function buildManifest() {
|
|
@@ -12112,16 +12164,16 @@ async function buildManifest() {
|
|
|
12112
12164
|
}
|
|
12113
12165
|
const nodes = [];
|
|
12114
12166
|
for (const domain of DOMAINS2) {
|
|
12115
|
-
const domainDir = (0,
|
|
12167
|
+
const domainDir = (0, import_node_path8.join)(memoryDir2(), domain);
|
|
12116
12168
|
if (!(0, import_node_fs6.existsSync)(domainDir)) continue;
|
|
12117
12169
|
try {
|
|
12118
|
-
const files = await (0,
|
|
12170
|
+
const files = await (0, import_promises9.readdir)(domainDir);
|
|
12119
12171
|
for (const file of files) {
|
|
12120
12172
|
if (!file.endsWith(".md")) continue;
|
|
12121
12173
|
const filePath = `${domain}/${file}`;
|
|
12122
|
-
const fullPath = (0,
|
|
12174
|
+
const fullPath = (0, import_node_path8.join)(memoryDir2(), filePath);
|
|
12123
12175
|
try {
|
|
12124
|
-
const content = await (0,
|
|
12176
|
+
const content = await (0, import_promises9.readFile)(fullPath, "utf-8");
|
|
12125
12177
|
const hash = (0, import_node_crypto2.createHash)("sha256").update(content).digest("hex").slice(0, 16);
|
|
12126
12178
|
nodes.push({ path: filePath, content_hash: `sha256:${hash}` });
|
|
12127
12179
|
} catch {
|
|
@@ -12132,13 +12184,13 @@ async function buildManifest() {
|
|
|
12132
12184
|
}
|
|
12133
12185
|
let indexHash = null;
|
|
12134
12186
|
try {
|
|
12135
|
-
const indexContent = await (0,
|
|
12187
|
+
const indexContent = await (0, import_promises9.readFile)((0, import_node_path8.join)(memoryDir2(), "index.md"), "utf-8");
|
|
12136
12188
|
indexHash = `sha256:${(0, import_node_crypto2.createHash)("sha256").update(indexContent).digest("hex").slice(0, 16)}`;
|
|
12137
12189
|
} catch {
|
|
12138
12190
|
}
|
|
12139
12191
|
let logLength = 0;
|
|
12140
12192
|
try {
|
|
12141
|
-
const logContent = await (0,
|
|
12193
|
+
const logContent = await (0, import_promises9.readFile)((0, import_node_path8.join)(memoryDir2(), "log.md"), "utf-8");
|
|
12142
12194
|
logLength = logContent.split("\n").length;
|
|
12143
12195
|
} catch {
|
|
12144
12196
|
}
|
|
@@ -12151,13 +12203,13 @@ async function readOnDiskNodes() {
|
|
|
12151
12203
|
const out = /* @__PURE__ */ new Map();
|
|
12152
12204
|
if (!(0, import_node_fs6.existsSync)(memoryDir2())) return out;
|
|
12153
12205
|
for (const domain of DOMAINS2) {
|
|
12154
|
-
const domainDir = (0,
|
|
12206
|
+
const domainDir = (0, import_node_path8.join)(memoryDir2(), domain);
|
|
12155
12207
|
if (!(0, import_node_fs6.existsSync)(domainDir)) continue;
|
|
12156
12208
|
try {
|
|
12157
|
-
for (const file of await (0,
|
|
12209
|
+
for (const file of await (0, import_promises9.readdir)(domainDir)) {
|
|
12158
12210
|
if (!file.endsWith(".md")) continue;
|
|
12159
12211
|
try {
|
|
12160
|
-
out.set(`${domain}/${file}`, hashContent(await (0,
|
|
12212
|
+
out.set(`${domain}/${file}`, hashContent(await (0, import_promises9.readFile)((0, import_node_path8.join)(domainDir, file), "utf-8")));
|
|
12161
12213
|
} catch {
|
|
12162
12214
|
}
|
|
12163
12215
|
}
|
|
@@ -12169,7 +12221,7 @@ async function readOnDiskNodes() {
|
|
|
12169
12221
|
async function readSyncBaseline() {
|
|
12170
12222
|
const out = /* @__PURE__ */ new Map();
|
|
12171
12223
|
try {
|
|
12172
|
-
const parsed = JSON.parse(await (0,
|
|
12224
|
+
const parsed = JSON.parse(await (0, import_promises9.readFile)(syncStateFile(), "utf-8"));
|
|
12173
12225
|
if (Array.isArray(parsed?.nodes)) {
|
|
12174
12226
|
for (const n of parsed.nodes) if (n?.path) out.set(n.path, n.hash ?? null);
|
|
12175
12227
|
} else if (Array.isArray(parsed?.paths)) {
|
|
@@ -12185,12 +12237,12 @@ async function recordSyncedNodePaths() {
|
|
|
12185
12237
|
const next = JSON.stringify({ schema: 2, nodes }) + "\n";
|
|
12186
12238
|
let existing = "";
|
|
12187
12239
|
try {
|
|
12188
|
-
existing = await (0,
|
|
12240
|
+
existing = await (0, import_promises9.readFile)(syncStateFile(), "utf-8");
|
|
12189
12241
|
} catch {
|
|
12190
12242
|
}
|
|
12191
12243
|
if (existing === next) return;
|
|
12192
|
-
await (0,
|
|
12193
|
-
await (0,
|
|
12244
|
+
await (0, import_promises9.mkdir)(projectPath(VERITY_DIR), { recursive: true });
|
|
12245
|
+
await (0, import_promises9.writeFile)(syncStateFile(), next);
|
|
12194
12246
|
} catch {
|
|
12195
12247
|
}
|
|
12196
12248
|
}
|
|
@@ -12203,11 +12255,11 @@ async function computeEditedNodeUploads() {
|
|
|
12203
12255
|
const uploads = [];
|
|
12204
12256
|
for (const [path, prevHash] of prev) {
|
|
12205
12257
|
if (prevHash == null) continue;
|
|
12206
|
-
const full = (0,
|
|
12258
|
+
const full = (0, import_node_path8.join)(memoryDir2(), path);
|
|
12207
12259
|
if (!(0, import_node_fs6.existsSync)(full)) continue;
|
|
12208
12260
|
let content;
|
|
12209
12261
|
try {
|
|
12210
|
-
content = await (0,
|
|
12262
|
+
content = await (0, import_promises9.readFile)(full, "utf-8");
|
|
12211
12263
|
} catch {
|
|
12212
12264
|
continue;
|
|
12213
12265
|
}
|
|
@@ -12240,15 +12292,15 @@ async function applyMemoryWrites(writes, opts = {}) {
|
|
|
12240
12292
|
const logLines = [`- ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16)} \u2014 Applied ${count} write(s) from server`];
|
|
12241
12293
|
for (const n of notes) logLines.push(` - ${n}`);
|
|
12242
12294
|
try {
|
|
12243
|
-
const existing = (0, import_node_fs6.existsSync)((0,
|
|
12244
|
-
await (0,
|
|
12295
|
+
const existing = (0, import_node_fs6.existsSync)((0, import_node_path8.join)(memoryDir2(), "log.md")) ? await (0, import_promises9.readFile)((0, import_node_path8.join)(memoryDir2(), "log.md"), "utf-8") : "# Memory Log\n\n";
|
|
12296
|
+
await (0, import_promises9.writeFile)((0, import_node_path8.join)(memoryDir2(), "log.md"), existing + logLines.join("\n") + "\n");
|
|
12245
12297
|
} catch {
|
|
12246
12298
|
}
|
|
12247
12299
|
await recordSyncedNodePaths();
|
|
12248
12300
|
return count;
|
|
12249
12301
|
}
|
|
12250
12302
|
async function applyOneWrite(write, treePaths) {
|
|
12251
|
-
const fullPath = (0,
|
|
12303
|
+
const fullPath = (0, import_node_path8.join)(memoryDir2(), write.path);
|
|
12252
12304
|
const notes = [];
|
|
12253
12305
|
let content = write.content;
|
|
12254
12306
|
if (treePaths && treePaths.length > 0) {
|
|
@@ -12261,7 +12313,7 @@ async function applyOneWrite(write, treePaths) {
|
|
|
12261
12313
|
if ((0, import_node_fs6.existsSync)(fullPath)) {
|
|
12262
12314
|
let existing = "";
|
|
12263
12315
|
try {
|
|
12264
|
-
existing = await (0,
|
|
12316
|
+
existing = await (0, import_promises9.readFile)(fullPath, "utf-8");
|
|
12265
12317
|
} catch {
|
|
12266
12318
|
}
|
|
12267
12319
|
if (existing === content) return { written: false, notes };
|
|
@@ -12270,8 +12322,8 @@ async function applyOneWrite(write, treePaths) {
|
|
|
12270
12322
|
return { written: false, notes };
|
|
12271
12323
|
}
|
|
12272
12324
|
}
|
|
12273
|
-
await (0,
|
|
12274
|
-
await (0,
|
|
12325
|
+
await (0, import_promises9.mkdir)((0, import_node_path8.dirname)(fullPath), { recursive: true });
|
|
12326
|
+
await (0, import_promises9.writeFile)(fullPath, content);
|
|
12275
12327
|
return { written: true, notes };
|
|
12276
12328
|
}
|
|
12277
12329
|
function groundFileGlobs(content, treePaths) {
|
|
@@ -12311,10 +12363,10 @@ async function regenerateIndex() {
|
|
|
12311
12363
|
];
|
|
12312
12364
|
let totalNodes = 0;
|
|
12313
12365
|
for (const domain of DOMAINS2.filter((d) => d !== "_archive")) {
|
|
12314
|
-
const domainDir = (0,
|
|
12366
|
+
const domainDir = (0, import_node_path8.join)(memoryDir2(), domain);
|
|
12315
12367
|
if (!(0, import_node_fs6.existsSync)(domainDir)) continue;
|
|
12316
12368
|
try {
|
|
12317
|
-
const files = await (0,
|
|
12369
|
+
const files = await (0, import_promises9.readdir)(domainDir);
|
|
12318
12370
|
const mdFiles = files.filter((f) => f.endsWith(".md"));
|
|
12319
12371
|
if (mdFiles.length === 0) continue;
|
|
12320
12372
|
lines.push(`## ${domain}/ (${mdFiles.length})`);
|
|
@@ -12322,7 +12374,7 @@ async function regenerateIndex() {
|
|
|
12322
12374
|
for (const file of mdFiles.sort()) {
|
|
12323
12375
|
const slug = file.replace(/\.md$/, "");
|
|
12324
12376
|
try {
|
|
12325
|
-
const content = await (0,
|
|
12377
|
+
const content = await (0, import_promises9.readFile)((0, import_node_path8.join)(domainDir, file), "utf-8");
|
|
12326
12378
|
const title = pickFrontmatter(content, "title") ?? slug;
|
|
12327
12379
|
const kind = pickFrontmatter(content, "kind") ?? "-";
|
|
12328
12380
|
const confidence = pickFrontmatter(content, "confidence");
|
|
@@ -12346,14 +12398,14 @@ async function regenerateIndex() {
|
|
|
12346
12398
|
lines.push("No nodes yet. Run an analysis to start building the knowledge graph.");
|
|
12347
12399
|
}
|
|
12348
12400
|
const next = lines.join("\n") + "\n";
|
|
12349
|
-
const indexPath = (0,
|
|
12401
|
+
const indexPath = (0, import_node_path8.join)(memoryDir2(), "index.md");
|
|
12350
12402
|
let existing = null;
|
|
12351
12403
|
try {
|
|
12352
|
-
existing = await (0,
|
|
12404
|
+
existing = await (0, import_promises9.readFile)(indexPath, "utf-8");
|
|
12353
12405
|
} catch {
|
|
12354
12406
|
}
|
|
12355
12407
|
if (existing === next) return;
|
|
12356
|
-
await (0,
|
|
12408
|
+
await (0, import_promises9.writeFile)(indexPath, next);
|
|
12357
12409
|
}
|
|
12358
12410
|
function pickFrontmatter(content, key) {
|
|
12359
12411
|
const re = new RegExp(`^${key}:\\s*"?([^"\\n]+?)"?\\s*$`, "m");
|
|
@@ -12428,10 +12480,10 @@ function hasLegacyMemoryBlock(text) {
|
|
|
12428
12480
|
return findMarker(text, LEGACY_MD_START) !== -1;
|
|
12429
12481
|
}
|
|
12430
12482
|
async function ensureClaudeMdPointer(cwd = repoRoot()) {
|
|
12431
|
-
const claudeMdPath = (0,
|
|
12483
|
+
const claudeMdPath = (0, import_node_path8.join)(cwd, "CLAUDE.md");
|
|
12432
12484
|
let existing = "";
|
|
12433
12485
|
if ((0, import_node_fs6.existsSync)(claudeMdPath)) {
|
|
12434
|
-
existing = await (0,
|
|
12486
|
+
existing = await (0, import_promises9.readFile)(claudeMdPath, "utf-8");
|
|
12435
12487
|
}
|
|
12436
12488
|
let startTag = CLAUDE_MD_START;
|
|
12437
12489
|
let endTag = CLAUDE_MD_END;
|
|
@@ -12487,7 +12539,7 @@ async function ensureClaudeMdPointer(cwd = repoRoot()) {
|
|
|
12487
12539
|
next = existing.replace(/\n*$/, "") + "\n\n" + block + "\n";
|
|
12488
12540
|
}
|
|
12489
12541
|
if (next === existing) return;
|
|
12490
|
-
await (0,
|
|
12542
|
+
await (0, import_promises9.writeFile)(claudeMdPath, next);
|
|
12491
12543
|
}
|
|
12492
12544
|
function extractPreserveContent(interior) {
|
|
12493
12545
|
for (const [start, end] of [
|
|
@@ -12670,7 +12722,7 @@ async function fireClassify(prompt, sessionId) {
|
|
|
12670
12722
|
}
|
|
12671
12723
|
|
|
12672
12724
|
// src/commands/standard.ts
|
|
12673
|
-
var
|
|
12725
|
+
var import_promises10 = require("node:fs/promises");
|
|
12674
12726
|
var import_yaml = __toESM(require_dist());
|
|
12675
12727
|
function registerStandardCommands(program2) {
|
|
12676
12728
|
const standard = program2.command("standard").description("Manage the project Standard");
|
|
@@ -12688,7 +12740,7 @@ function registerStandardCommands(program2) {
|
|
|
12688
12740
|
}
|
|
12689
12741
|
let yamlContent;
|
|
12690
12742
|
try {
|
|
12691
|
-
yamlContent = await (0,
|
|
12743
|
+
yamlContent = await (0, import_promises10.readFile)(opts.file, "utf-8");
|
|
12692
12744
|
} catch {
|
|
12693
12745
|
printError(`Cannot read ${opts.file}`);
|
|
12694
12746
|
process.exit(1);
|
|
@@ -12779,7 +12831,7 @@ function registerStandardCommands(program2) {
|
|
|
12779
12831
|
}
|
|
12780
12832
|
|
|
12781
12833
|
// src/commands/config.ts
|
|
12782
|
-
var
|
|
12834
|
+
var import_promises11 = require("node:fs/promises");
|
|
12783
12835
|
function registerConfigCommands(program2) {
|
|
12784
12836
|
const config = program2.command("config").description("Manage analysis configuration");
|
|
12785
12837
|
config.command("push").description("Upload the analysis config to the service").option("--file <path>", "Path to config file", CODACY_CONFIG_FILE).action(async (opts) => {
|
|
@@ -12796,7 +12848,7 @@ function registerConfigCommands(program2) {
|
|
|
12796
12848
|
}
|
|
12797
12849
|
let content;
|
|
12798
12850
|
try {
|
|
12799
|
-
const raw = await (0,
|
|
12851
|
+
const raw = await (0, import_promises11.readFile)(opts.file, "utf-8");
|
|
12800
12852
|
content = JSON.parse(raw);
|
|
12801
12853
|
} catch {
|
|
12802
12854
|
printError(`Cannot read or parse ${opts.file}`);
|
|
@@ -13146,11 +13198,11 @@ async function sendGeneralFeedback(message, opts, globals) {
|
|
|
13146
13198
|
|
|
13147
13199
|
// src/commands/analyze.ts
|
|
13148
13200
|
var import_node_fs19 = require("node:fs");
|
|
13149
|
-
var
|
|
13201
|
+
var import_node_path15 = require("node:path");
|
|
13150
13202
|
|
|
13151
13203
|
// src/lib/files.ts
|
|
13152
13204
|
var import_node_fs8 = require("node:fs");
|
|
13153
|
-
var
|
|
13205
|
+
var import_node_path9 = require("node:path");
|
|
13154
13206
|
var LANG_MAP = {
|
|
13155
13207
|
// Analyzable (static analysis + Gemini)
|
|
13156
13208
|
ts: "typescript",
|
|
@@ -13218,7 +13270,7 @@ var LANG_MAP = {
|
|
|
13218
13270
|
mk: "make"
|
|
13219
13271
|
};
|
|
13220
13272
|
function detectLanguage(filepath) {
|
|
13221
|
-
const ext = (0,
|
|
13273
|
+
const ext = (0, import_node_path9.extname)(filepath).slice(1);
|
|
13222
13274
|
return LANG_MAP[ext] ?? ext;
|
|
13223
13275
|
}
|
|
13224
13276
|
function sortByMtime(files) {
|
|
@@ -13504,7 +13556,7 @@ function runCodacyAnalysis(files) {
|
|
|
13504
13556
|
|
|
13505
13557
|
// src/lib/specs.ts
|
|
13506
13558
|
var import_node_fs11 = require("node:fs");
|
|
13507
|
-
var
|
|
13559
|
+
var import_node_path10 = require("node:path");
|
|
13508
13560
|
var SPEC_CANDIDATES = [
|
|
13509
13561
|
"CLAUDE.md",
|
|
13510
13562
|
"AGENTS.md",
|
|
@@ -13566,7 +13618,7 @@ function findMdFiles(dir, maxDepth, depth = 0) {
|
|
|
13566
13618
|
try {
|
|
13567
13619
|
const entries = (0, import_node_fs11.readdirSync)(dir, { withFileTypes: true });
|
|
13568
13620
|
for (const entry of entries) {
|
|
13569
|
-
const fullPath = (0,
|
|
13621
|
+
const fullPath = (0, import_node_path10.join)(dir, entry.name);
|
|
13570
13622
|
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
13571
13623
|
result.push(fullPath);
|
|
13572
13624
|
} else if (entry.isDirectory() && depth < maxDepth - 1) {
|
|
@@ -13578,7 +13630,7 @@ function findMdFiles(dir, maxDepth, depth = 0) {
|
|
|
13578
13630
|
return result;
|
|
13579
13631
|
}
|
|
13580
13632
|
function discoverPlans() {
|
|
13581
|
-
const homePlansDir = (0,
|
|
13633
|
+
const homePlansDir = (0, import_node_path10.join)(process.env.HOME ?? "", ".claude", "plans");
|
|
13582
13634
|
const localPlansDir = ".claude/plans";
|
|
13583
13635
|
const candidates = [];
|
|
13584
13636
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -13588,7 +13640,7 @@ function discoverPlans() {
|
|
|
13588
13640
|
for (const f of (0, import_node_fs11.readdirSync)(plansDir)) {
|
|
13589
13641
|
if (!f.endsWith(".md") || seen.has(f)) continue;
|
|
13590
13642
|
seen.add(f);
|
|
13591
|
-
const fullPath = (0,
|
|
13643
|
+
const fullPath = (0, import_node_path10.join)(plansDir, f);
|
|
13592
13644
|
try {
|
|
13593
13645
|
const stat3 = (0, import_node_fs11.statSync)(fullPath);
|
|
13594
13646
|
candidates.push({ name: f, path: fullPath, mtime: stat3.mtimeMs, size: stat3.size });
|
|
@@ -13613,7 +13665,7 @@ function discoverPlans() {
|
|
|
13613
13665
|
|
|
13614
13666
|
// src/lib/snapshot.ts
|
|
13615
13667
|
var import_node_fs12 = require("node:fs");
|
|
13616
|
-
var
|
|
13668
|
+
var import_node_path11 = require("node:path");
|
|
13617
13669
|
var import_node_child_process7 = require("node:child_process");
|
|
13618
13670
|
function generateSnapshotDiffs(files) {
|
|
13619
13671
|
if (!(0, import_node_fs12.existsSync)(SNAPSHOT_DIR)) {
|
|
@@ -13621,7 +13673,7 @@ function generateSnapshotDiffs(files) {
|
|
|
13621
13673
|
}
|
|
13622
13674
|
const diffs = [];
|
|
13623
13675
|
for (const file of files) {
|
|
13624
|
-
const snapshotPath = (0,
|
|
13676
|
+
const snapshotPath = (0, import_node_path11.join)(SNAPSHOT_DIR, file.path);
|
|
13625
13677
|
const language = file.language ?? detectLanguage(file.path);
|
|
13626
13678
|
if ((0, import_node_fs12.existsSync)(snapshotPath)) {
|
|
13627
13679
|
const oldContent = (0, import_node_fs12.readFileSync)(snapshotPath, "utf-8");
|
|
@@ -13648,16 +13700,16 @@ ${addedLines}`,
|
|
|
13648
13700
|
function saveSnapshots(files) {
|
|
13649
13701
|
const snapshotPaths = /* @__PURE__ */ new Set();
|
|
13650
13702
|
for (const file of files) {
|
|
13651
|
-
const snapshotPath = (0,
|
|
13703
|
+
const snapshotPath = (0, import_node_path11.join)(SNAPSHOT_DIR, file.path);
|
|
13652
13704
|
snapshotPaths.add(snapshotPath);
|
|
13653
|
-
(0, import_node_fs12.mkdirSync)((0,
|
|
13705
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path11.dirname)(snapshotPath), { recursive: true });
|
|
13654
13706
|
(0, import_node_fs12.writeFileSync)(snapshotPath, file.content);
|
|
13655
13707
|
}
|
|
13656
13708
|
cleanStaleSnapshots(SNAPSHOT_DIR, snapshotPaths);
|
|
13657
13709
|
}
|
|
13658
13710
|
function computeDiff(oldContent, newContent, filePath) {
|
|
13659
|
-
const tmpOld = (0,
|
|
13660
|
-
const tmpNew = (0,
|
|
13711
|
+
const tmpOld = (0, import_node_path11.join)(SNAPSHOT_DIR, ".diff-old.tmp");
|
|
13712
|
+
const tmpNew = (0, import_node_path11.join)(SNAPSHOT_DIR, ".diff-new.tmp");
|
|
13661
13713
|
try {
|
|
13662
13714
|
(0, import_node_fs12.mkdirSync)(SNAPSHOT_DIR, { recursive: true });
|
|
13663
13715
|
(0, import_node_fs12.writeFileSync)(tmpOld, oldContent);
|
|
@@ -13690,7 +13742,7 @@ function cleanStaleSnapshots(dir, keepSet) {
|
|
|
13690
13742
|
const entries = (0, import_node_fs12.readdirSync)(dir, { withFileTypes: true });
|
|
13691
13743
|
for (const entry of entries) {
|
|
13692
13744
|
if (entry.name.startsWith(".")) continue;
|
|
13693
|
-
const fullPath = (0,
|
|
13745
|
+
const fullPath = (0, import_node_path11.join)(dir, entry.name);
|
|
13694
13746
|
if (entry.isDirectory()) {
|
|
13695
13747
|
cleanStaleSnapshots(fullPath, keepSet);
|
|
13696
13748
|
try {
|
|
@@ -13711,7 +13763,7 @@ function cleanStaleSnapshots(dir, keepSet) {
|
|
|
13711
13763
|
|
|
13712
13764
|
// src/lib/baseline.ts
|
|
13713
13765
|
var import_node_fs13 = require("node:fs");
|
|
13714
|
-
var
|
|
13766
|
+
var import_node_path12 = require("node:path");
|
|
13715
13767
|
var import_node_crypto5 = require("node:crypto");
|
|
13716
13768
|
var BASELINE_VERSION = 1;
|
|
13717
13769
|
var BASELINE_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
@@ -13722,13 +13774,13 @@ function sessionKey(sessionId) {
|
|
|
13722
13774
|
return (0, import_node_crypto5.createHash)("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
13723
13775
|
}
|
|
13724
13776
|
function sessionDir(key) {
|
|
13725
|
-
return (0,
|
|
13777
|
+
return (0, import_node_path12.join)(projectPath(BASELINE_DIR), key);
|
|
13726
13778
|
}
|
|
13727
13779
|
function manifestPath(dir) {
|
|
13728
|
-
return (0,
|
|
13780
|
+
return (0, import_node_path12.join)(dir, "manifest.json");
|
|
13729
13781
|
}
|
|
13730
13782
|
function mirrorPath(dir, repoRelPath) {
|
|
13731
|
-
return (0,
|
|
13783
|
+
return (0, import_node_path12.join)(dir, "files", repoRelPath);
|
|
13732
13784
|
}
|
|
13733
13785
|
function captureBaseline(opts = {}) {
|
|
13734
13786
|
const key = sessionKey(opts.sessionId);
|
|
@@ -13744,7 +13796,7 @@ function captureBaseline(opts = {}) {
|
|
|
13744
13796
|
(0, import_node_fs13.rmSync)(dir, { recursive: true, force: true });
|
|
13745
13797
|
} catch {
|
|
13746
13798
|
}
|
|
13747
|
-
const filesDir = (0,
|
|
13799
|
+
const filesDir = (0, import_node_path12.join)(dir, "files");
|
|
13748
13800
|
const mirrored = [];
|
|
13749
13801
|
try {
|
|
13750
13802
|
(0, import_node_fs13.mkdirSync)(filesDir, { recursive: true });
|
|
@@ -13754,7 +13806,7 @@ function captureBaseline(opts = {}) {
|
|
|
13754
13806
|
if (content === null) continue;
|
|
13755
13807
|
const dest = mirrorPath(dir, p);
|
|
13756
13808
|
try {
|
|
13757
|
-
(0, import_node_fs13.mkdirSync)((0,
|
|
13809
|
+
(0, import_node_fs13.mkdirSync)((0, import_node_path12.dirname)(dest), { recursive: true });
|
|
13758
13810
|
(0, import_node_fs13.writeFileSync)(dest, content);
|
|
13759
13811
|
mirrored.push(p);
|
|
13760
13812
|
} catch {
|
|
@@ -13882,7 +13934,7 @@ function pruneOldBaselines() {
|
|
|
13882
13934
|
}
|
|
13883
13935
|
const now = Date.now();
|
|
13884
13936
|
for (const name of entries) {
|
|
13885
|
-
const dir = (0,
|
|
13937
|
+
const dir = (0, import_node_path12.join)(root, name);
|
|
13886
13938
|
const manifest = readManifest(dir);
|
|
13887
13939
|
if (!manifest) {
|
|
13888
13940
|
try {
|
|
@@ -13981,7 +14033,7 @@ function gatherContextFiles(contextPaths, deltaFiles) {
|
|
|
13981
14033
|
|
|
13982
14034
|
// src/lib/cache-cleanup.ts
|
|
13983
14035
|
var import_node_fs16 = require("node:fs");
|
|
13984
|
-
var
|
|
14036
|
+
var import_node_path13 = require("node:path");
|
|
13985
14037
|
var CACHE_TTL_DAYS = 7;
|
|
13986
14038
|
function pruneStaleCache() {
|
|
13987
14039
|
try {
|
|
@@ -13989,7 +14041,7 @@ function pruneStaleCache() {
|
|
|
13989
14041
|
const cutoff = Date.now() - CACHE_TTL_DAYS * 24 * 3600 * 1e3;
|
|
13990
14042
|
for (const entry of (0, import_node_fs16.readdirSync)(dir)) {
|
|
13991
14043
|
if (!entry.startsWith("pending-")) continue;
|
|
13992
|
-
const path = (0,
|
|
14044
|
+
const path = (0, import_node_path13.join)(dir, entry);
|
|
13993
14045
|
try {
|
|
13994
14046
|
const stat3 = (0, import_node_fs16.statSync)(path);
|
|
13995
14047
|
if (stat3.mtimeMs < cutoff) {
|
|
@@ -14380,9 +14432,9 @@ function capArray(set, max) {
|
|
|
14380
14432
|
}
|
|
14381
14433
|
|
|
14382
14434
|
// src/lib/seed-runner.ts
|
|
14383
|
-
var
|
|
14435
|
+
var import_promises12 = require("node:fs/promises");
|
|
14384
14436
|
var import_node_fs18 = require("node:fs");
|
|
14385
|
-
var
|
|
14437
|
+
var import_node_path14 = require("node:path");
|
|
14386
14438
|
var import_yaml2 = __toESM(require_dist());
|
|
14387
14439
|
|
|
14388
14440
|
// src/lib/seed.ts
|
|
@@ -14626,7 +14678,7 @@ async function runSeed(opts) {
|
|
|
14626
14678
|
}
|
|
14627
14679
|
let standardDoc;
|
|
14628
14680
|
try {
|
|
14629
|
-
const raw = await (0,
|
|
14681
|
+
const raw = await (0, import_promises12.readFile)(STANDARD_FILE, "utf-8");
|
|
14630
14682
|
standardDoc = (0, import_yaml2.parse)(raw);
|
|
14631
14683
|
} catch {
|
|
14632
14684
|
return { created: 0, failed: 0, skipped: "no_standard", candidates: [] };
|
|
@@ -14635,7 +14687,7 @@ async function runSeed(opts) {
|
|
|
14635
14687
|
let readmeContent;
|
|
14636
14688
|
if ((0, import_node_fs18.existsSync)("README.md")) {
|
|
14637
14689
|
try {
|
|
14638
|
-
readmeContent = await (0,
|
|
14690
|
+
readmeContent = await (0, import_promises12.readFile)("README.md", "utf-8");
|
|
14639
14691
|
} catch {
|
|
14640
14692
|
}
|
|
14641
14693
|
}
|
|
@@ -14643,7 +14695,7 @@ async function runSeed(opts) {
|
|
|
14643
14695
|
for (const p of ["CLAUDE.md", ".claude/CLAUDE.md"]) {
|
|
14644
14696
|
if ((0, import_node_fs18.existsSync)(p)) {
|
|
14645
14697
|
try {
|
|
14646
|
-
claudeMdContent = await (0,
|
|
14698
|
+
claudeMdContent = await (0, import_promises12.readFile)(p, "utf-8");
|
|
14647
14699
|
break;
|
|
14648
14700
|
} catch {
|
|
14649
14701
|
}
|
|
@@ -14664,7 +14716,7 @@ async function runSeed(opts) {
|
|
|
14664
14716
|
if (candidates.length === 0) {
|
|
14665
14717
|
return { created: 0, failed: 0, skipped: "no_candidates", candidates: [] };
|
|
14666
14718
|
}
|
|
14667
|
-
const overviewPath = (0,
|
|
14719
|
+
const overviewPath = (0, import_node_path14.join)(MEMORY_DIR, "domain", "project-overview.md");
|
|
14668
14720
|
if ((0, import_node_fs18.existsSync)(overviewPath) && !opts.force) {
|
|
14669
14721
|
return { created: 0, failed: 0, skipped: "already_seeded", candidates };
|
|
14670
14722
|
}
|
|
@@ -14700,10 +14752,10 @@ async function runSeed(opts) {
|
|
|
14700
14752
|
}
|
|
14701
14753
|
const nodeId = res.data.node_id;
|
|
14702
14754
|
const filePathRel = res.data.file_path;
|
|
14703
|
-
const targetPath = (0,
|
|
14755
|
+
const targetPath = (0, import_node_path14.join)(MEMORY_DIR, filePathRel);
|
|
14704
14756
|
try {
|
|
14705
|
-
await (0,
|
|
14706
|
-
await (0,
|
|
14757
|
+
await (0, import_promises12.mkdir)((0, import_node_path14.dirname)(targetPath), { recursive: true });
|
|
14758
|
+
await (0, import_promises12.writeFile)(targetPath, renderNodeMarkdown(c, nodeId, createdAt));
|
|
14707
14759
|
created++;
|
|
14708
14760
|
opts.onCreated?.(nodeId, filePathRel, c);
|
|
14709
14761
|
} catch (err) {
|
|
@@ -14984,7 +15036,7 @@ async function runAnalyze(opts, globals) {
|
|
|
14984
15036
|
let autoSeedNotice = null;
|
|
14985
15037
|
try {
|
|
14986
15038
|
await ensureMemoryDir();
|
|
14987
|
-
const seedMarker = (0,
|
|
15039
|
+
const seedMarker = (0, import_node_path15.join)(VERITY_DIR, ".seeded");
|
|
14988
15040
|
const hasStandard = (0, import_node_fs19.existsSync)(STANDARD_FILE);
|
|
14989
15041
|
const alreadyTried = (0, import_node_fs19.existsSync)(seedMarker);
|
|
14990
15042
|
if (hasStandard && !alreadyTried) {
|
|
@@ -15478,9 +15530,9 @@ async function runReview(opts, globals) {
|
|
|
15478
15530
|
|
|
15479
15531
|
// src/commands/guard.ts
|
|
15480
15532
|
var import_node_fs22 = require("node:fs");
|
|
15481
|
-
var
|
|
15533
|
+
var import_node_path16 = require("node:path");
|
|
15482
15534
|
var GUARD_BLOCK_CAP = 2;
|
|
15483
|
-
var GUARD_ITER_FILE = (0,
|
|
15535
|
+
var GUARD_ITER_FILE = (0, import_node_path16.join)(VERITY_DIR, ".guard-iteration");
|
|
15484
15536
|
function readPreToolUseStdin() {
|
|
15485
15537
|
const empty = { command: "", cwd: null, sessionId: null };
|
|
15486
15538
|
return new Promise((resolve) => {
|
|
@@ -15795,14 +15847,14 @@ function writeBlockMessage(moment, response) {
|
|
|
15795
15847
|
|
|
15796
15848
|
// src/commands/init.ts
|
|
15797
15849
|
var import_node_fs24 = require("node:fs");
|
|
15798
|
-
var
|
|
15799
|
-
var
|
|
15850
|
+
var import_promises13 = require("node:fs/promises");
|
|
15851
|
+
var import_node_path18 = require("node:path");
|
|
15800
15852
|
var import_node_child_process9 = require("node:child_process");
|
|
15801
15853
|
var readline = __toESM(require("node:readline/promises"));
|
|
15802
15854
|
|
|
15803
15855
|
// src/commands/migrate.ts
|
|
15804
15856
|
var import_node_fs23 = require("node:fs");
|
|
15805
|
-
var
|
|
15857
|
+
var import_node_path17 = require("node:path");
|
|
15806
15858
|
var import_node_child_process8 = require("node:child_process");
|
|
15807
15859
|
var LEGACY_NPM_PACKAGE = "@codacy/gate-cli";
|
|
15808
15860
|
function defaultNpmRemover(pkg) {
|
|
@@ -15838,8 +15890,8 @@ async function runMigration(opts = {}) {
|
|
|
15838
15890
|
return { actions, migrated: actions.length > 0 };
|
|
15839
15891
|
}
|
|
15840
15892
|
function migrateProjectDir(root, actions) {
|
|
15841
|
-
const gateDir = (0,
|
|
15842
|
-
const verityDir = (0,
|
|
15893
|
+
const gateDir = (0, import_node_path17.join)(root, ".gate");
|
|
15894
|
+
const verityDir = (0, import_node_path17.join)(root, ".verity");
|
|
15843
15895
|
if ((0, import_node_fs23.existsSync)(gateDir) && !(0, import_node_fs23.existsSync)(verityDir)) {
|
|
15844
15896
|
return migrateProjectDirRename(root, gateDir, verityDir, actions);
|
|
15845
15897
|
}
|
|
@@ -15893,11 +15945,11 @@ function migrateProjectDirCarry(gateDir, verityDir, actions) {
|
|
|
15893
15945
|
}
|
|
15894
15946
|
function migrateGlobalCredentials(home, actions) {
|
|
15895
15947
|
if (!home) return;
|
|
15896
|
-
const gateCreds = (0,
|
|
15897
|
-
const verityCreds = (0,
|
|
15948
|
+
const gateCreds = (0, import_node_path17.join)(home, ".gate", "credentials");
|
|
15949
|
+
const verityCreds = (0, import_node_path17.join)(home, ".verity", "credentials");
|
|
15898
15950
|
if (!(0, import_node_fs23.existsSync)(gateCreds)) return;
|
|
15899
15951
|
if (!(0, import_node_fs23.existsSync)(verityCreds)) {
|
|
15900
|
-
(0, import_node_fs23.mkdirSync)((0,
|
|
15952
|
+
(0, import_node_fs23.mkdirSync)((0, import_node_path17.join)(home, ".verity"), { recursive: true });
|
|
15901
15953
|
moveFile(gateCreds, verityCreds);
|
|
15902
15954
|
actions.push("Moved ~/.gate/credentials \u2192 ~/.verity/credentials");
|
|
15903
15955
|
return;
|
|
@@ -15919,7 +15971,7 @@ async function migrateLegacyHooks(root, actions) {
|
|
|
15919
15971
|
}
|
|
15920
15972
|
}
|
|
15921
15973
|
async function migrateClaudeMd(root, actions) {
|
|
15922
|
-
const claudeMd = (0,
|
|
15974
|
+
const claudeMd = (0, import_node_path17.join)(root, "CLAUDE.md");
|
|
15923
15975
|
const hadLegacyBlock = (0, import_node_fs23.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd));
|
|
15924
15976
|
if (!hadLegacyBlock) return;
|
|
15925
15977
|
try {
|
|
@@ -15930,8 +15982,8 @@ async function migrateClaudeMd(root, actions) {
|
|
|
15930
15982
|
}
|
|
15931
15983
|
}
|
|
15932
15984
|
function migrateStandardFile(root, actions) {
|
|
15933
|
-
const gateMd = (0,
|
|
15934
|
-
const verityMd = (0,
|
|
15985
|
+
const gateMd = (0, import_node_path17.join)(root, "GATE.md");
|
|
15986
|
+
const verityMd = (0, import_node_path17.join)(root, "VERITY.md");
|
|
15935
15987
|
if (!(0, import_node_fs23.existsSync)(gateMd) || (0, import_node_fs23.existsSync)(verityMd)) return;
|
|
15936
15988
|
let moved = false;
|
|
15937
15989
|
if (isGitRepo(root) && isGitTracked(root, "GATE.md")) {
|
|
@@ -16019,15 +16071,15 @@ function moveFile(from, to) {
|
|
|
16019
16071
|
function carryLegacyContents(gateDir, verityDir) {
|
|
16020
16072
|
let copied = 0;
|
|
16021
16073
|
const walk = (relDir) => {
|
|
16022
|
-
const srcDir = (0,
|
|
16074
|
+
const srcDir = (0, import_node_path17.join)(gateDir, relDir);
|
|
16023
16075
|
for (const entry of (0, import_node_fs23.readdirSync)(srcDir)) {
|
|
16024
|
-
const rel = relDir ? (0,
|
|
16025
|
-
const src = (0,
|
|
16026
|
-
const dest = (0,
|
|
16076
|
+
const rel = relDir ? (0, import_node_path17.join)(relDir, entry) : entry;
|
|
16077
|
+
const src = (0, import_node_path17.join)(gateDir, rel);
|
|
16078
|
+
const dest = (0, import_node_path17.join)(verityDir, rel);
|
|
16027
16079
|
if ((0, import_node_fs23.statSync)(src).isDirectory()) {
|
|
16028
16080
|
walk(rel);
|
|
16029
16081
|
} else if (!(0, import_node_fs23.existsSync)(dest)) {
|
|
16030
|
-
(0, import_node_fs23.mkdirSync)((0,
|
|
16082
|
+
(0, import_node_fs23.mkdirSync)((0, import_node_path17.dirname)(dest), { recursive: true });
|
|
16031
16083
|
(0, import_node_fs23.cpSync)(src, dest);
|
|
16032
16084
|
copied++;
|
|
16033
16085
|
}
|
|
@@ -16037,22 +16089,22 @@ function carryLegacyContents(gateDir, verityDir) {
|
|
|
16037
16089
|
return copied;
|
|
16038
16090
|
}
|
|
16039
16091
|
async function needsMigration(root = repoRoot()) {
|
|
16040
|
-
const gateDir = (0,
|
|
16041
|
-
const verityDir = (0,
|
|
16092
|
+
const gateDir = (0, import_node_path17.join)(root, ".gate");
|
|
16093
|
+
const verityDir = (0, import_node_path17.join)(root, ".verity");
|
|
16042
16094
|
if ((0, import_node_fs23.existsSync)(gateDir) && !(0, import_node_fs23.existsSync)(verityDir)) return true;
|
|
16043
16095
|
if ((0, import_node_fs23.existsSync)(gateDir) && (0, import_node_fs23.existsSync)(verityDir)) {
|
|
16044
|
-
if ((0, import_node_fs23.existsSync)((0,
|
|
16096
|
+
if ((0, import_node_fs23.existsSync)((0, import_node_path17.join)(gateDir, "credentials")) && !(0, import_node_fs23.existsSync)((0, import_node_path17.join)(verityDir, "credentials"))) {
|
|
16045
16097
|
return true;
|
|
16046
16098
|
}
|
|
16047
|
-
if ((0, import_node_fs23.existsSync)((0,
|
|
16099
|
+
if ((0, import_node_fs23.existsSync)((0, import_node_path17.join)(gateDir, "memory")) && !(0, import_node_fs23.existsSync)((0, import_node_path17.join)(verityDir, "memory"))) {
|
|
16048
16100
|
return true;
|
|
16049
16101
|
}
|
|
16050
16102
|
}
|
|
16051
|
-
const claudeMd = (0,
|
|
16103
|
+
const claudeMd = (0, import_node_path17.join)(root, "CLAUDE.md");
|
|
16052
16104
|
if ((0, import_node_fs23.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd))) {
|
|
16053
16105
|
return true;
|
|
16054
16106
|
}
|
|
16055
|
-
if ((0, import_node_fs23.existsSync)((0,
|
|
16107
|
+
if ((0, import_node_fs23.existsSync)((0, import_node_path17.join)(root, "GATE.md")) && !(0, import_node_fs23.existsSync)((0, import_node_path17.join)(root, "VERITY.md"))) {
|
|
16056
16108
|
return true;
|
|
16057
16109
|
}
|
|
16058
16110
|
if (await hasLegacyHooksAt(root)) return true;
|
|
@@ -16127,7 +16179,7 @@ async function runOptionalAuth() {
|
|
|
16127
16179
|
localOnlyNote();
|
|
16128
16180
|
return;
|
|
16129
16181
|
}
|
|
16130
|
-
const projectName = parseRemote(remote)?.repo ?? (0,
|
|
16182
|
+
const projectName = parseRemote(remote)?.repo ?? (0, import_node_path18.basename)(process.cwd());
|
|
16131
16183
|
printInfo("Authenticating with GitHub\u2026");
|
|
16132
16184
|
const result = await registerProject({ projectName, remote, serviceUrl: DEFAULT_SERVICE_URL });
|
|
16133
16185
|
if (result.ok) {
|
|
@@ -16140,15 +16192,15 @@ async function runOptionalAuth() {
|
|
|
16140
16192
|
}
|
|
16141
16193
|
function resolveDataDir() {
|
|
16142
16194
|
const candidates = [
|
|
16143
|
-
(0,
|
|
16195
|
+
(0, import_node_path18.join)(__dirname, "..", "data"),
|
|
16144
16196
|
// installed: node_modules/@codacy/verity-cli/data
|
|
16145
|
-
(0,
|
|
16197
|
+
(0, import_node_path18.join)(__dirname, "..", "..", "data"),
|
|
16146
16198
|
// edge case: nested resolution
|
|
16147
|
-
(0,
|
|
16199
|
+
(0, import_node_path18.join)(process.cwd(), "cli", "data")
|
|
16148
16200
|
// local dev: running from repo root
|
|
16149
16201
|
];
|
|
16150
16202
|
for (const candidate of candidates) {
|
|
16151
|
-
if ((0, import_node_fs24.existsSync)((0,
|
|
16203
|
+
if ((0, import_node_fs24.existsSync)((0, import_node_path18.join)(candidate, "skills"))) {
|
|
16152
16204
|
return candidate;
|
|
16153
16205
|
}
|
|
16154
16206
|
}
|
|
@@ -16157,8 +16209,8 @@ function resolveDataDir() {
|
|
|
16157
16209
|
);
|
|
16158
16210
|
}
|
|
16159
16211
|
async function copyDir(src, dest) {
|
|
16160
|
-
await (0,
|
|
16161
|
-
await (0,
|
|
16212
|
+
await (0, import_promises13.mkdir)(dest, { recursive: true });
|
|
16213
|
+
await (0, import_promises13.cp)(src, dest, { recursive: true, force: true });
|
|
16162
16214
|
}
|
|
16163
16215
|
function registerInitCommand(program2) {
|
|
16164
16216
|
program2.command("init").description("Initialize Verity in the current project").option("--force", "Overwrite existing skills and hooks").action(async (opts) => {
|
|
@@ -16227,24 +16279,24 @@ function registerInitCommand(program2) {
|
|
|
16227
16279
|
console.log("");
|
|
16228
16280
|
printInfo("Installing skills...");
|
|
16229
16281
|
const dataDir = resolveDataDir();
|
|
16230
|
-
const skillsSource = (0,
|
|
16282
|
+
const skillsSource = (0, import_node_path18.join)(dataDir, "skills");
|
|
16231
16283
|
const skillsDest = ".claude/skills";
|
|
16232
16284
|
const skills = ["verity-setup", "verity-analyze", "verity-status", "verity-feedback", "verity-learn", "verity-memory", "verity-insights", "verity-reflect"];
|
|
16233
16285
|
let skillsInstalled = 0;
|
|
16234
16286
|
for (const skill of skills) {
|
|
16235
|
-
const src = (0,
|
|
16236
|
-
const dest = (0,
|
|
16287
|
+
const src = (0, import_node_path18.join)(skillsSource, skill);
|
|
16288
|
+
const dest = (0, import_node_path18.join)(skillsDest, skill);
|
|
16237
16289
|
if (!(0, import_node_fs24.existsSync)(src)) {
|
|
16238
16290
|
printWarn(` Skill data not found: ${skill}`);
|
|
16239
16291
|
continue;
|
|
16240
16292
|
}
|
|
16241
16293
|
if ((0, import_node_fs24.existsSync)(dest) && !force) {
|
|
16242
|
-
const srcSkill = (0,
|
|
16243
|
-
const destSkill = (0,
|
|
16294
|
+
const srcSkill = (0, import_node_path18.join)(src, "SKILL.md");
|
|
16295
|
+
const destSkill = (0, import_node_path18.join)(dest, "SKILL.md");
|
|
16244
16296
|
if ((0, import_node_fs24.existsSync)(destSkill)) {
|
|
16245
16297
|
try {
|
|
16246
|
-
const srcContent = await (0,
|
|
16247
|
-
const destContent = await (0,
|
|
16298
|
+
const srcContent = await (0, import_promises13.readFile)(srcSkill, "utf-8");
|
|
16299
|
+
const destContent = await (0, import_promises13.readFile)(destSkill, "utf-8");
|
|
16248
16300
|
if (srcContent === destContent) {
|
|
16249
16301
|
skillsInstalled++;
|
|
16250
16302
|
continue;
|
|
@@ -16270,7 +16322,7 @@ function registerInitCommand(program2) {
|
|
|
16270
16322
|
printWarn(` ${hookResult.error}`);
|
|
16271
16323
|
printInfo(' Run "verity hooks install --force" to overwrite.');
|
|
16272
16324
|
}
|
|
16273
|
-
await (0,
|
|
16325
|
+
await (0, import_promises13.mkdir)(VERITY_DIR, { recursive: true });
|
|
16274
16326
|
await ensureMemoryDir();
|
|
16275
16327
|
try {
|
|
16276
16328
|
await ensureClaudeMdPointer();
|
|
@@ -16278,8 +16330,8 @@ function registerInitCommand(program2) {
|
|
|
16278
16330
|
} catch (err) {
|
|
16279
16331
|
printWarn(` Could not update CLAUDE.md: ${err.message}`);
|
|
16280
16332
|
}
|
|
16281
|
-
const globalVerityDir = (0,
|
|
16282
|
-
await (0,
|
|
16333
|
+
const globalVerityDir = (0, import_node_path18.join)(process.env.HOME ?? "", ".verity");
|
|
16334
|
+
await (0, import_promises13.mkdir)(globalVerityDir, { recursive: true });
|
|
16283
16335
|
console.log("");
|
|
16284
16336
|
try {
|
|
16285
16337
|
await runOptionalAuth();
|
|
@@ -16309,7 +16361,7 @@ function registerInitCommand(program2) {
|
|
|
16309
16361
|
|
|
16310
16362
|
// src/commands/uninstall.ts
|
|
16311
16363
|
var import_node_fs25 = require("node:fs");
|
|
16312
|
-
var
|
|
16364
|
+
var import_node_path19 = require("node:path");
|
|
16313
16365
|
var SKILL_NAMES = [
|
|
16314
16366
|
"verity-setup",
|
|
16315
16367
|
"verity-analyze",
|
|
@@ -16328,7 +16380,7 @@ function registerUninstallCommand(program2) {
|
|
|
16328
16380
|
const actions = [];
|
|
16329
16381
|
const skillsRoot = projectPath(".claude/skills");
|
|
16330
16382
|
for (const name of SKILL_NAMES) {
|
|
16331
|
-
const dir = (0,
|
|
16383
|
+
const dir = (0, import_node_path19.join)(skillsRoot, name);
|
|
16332
16384
|
if ((0, import_node_fs25.existsSync)(dir)) {
|
|
16333
16385
|
actions.push({
|
|
16334
16386
|
label: `Remove .claude/skills/${name}/`,
|
|
@@ -16374,7 +16426,7 @@ function registerUninstallCommand(program2) {
|
|
|
16374
16426
|
}
|
|
16375
16427
|
});
|
|
16376
16428
|
const home = process.env.HOME ?? "";
|
|
16377
|
-
const globalVerityDir = (0,
|
|
16429
|
+
const globalVerityDir = (0, import_node_path19.join)(home, ".verity");
|
|
16378
16430
|
if (purgeGlobal && (0, import_node_fs25.existsSync)(globalVerityDir)) {
|
|
16379
16431
|
actions.push({
|
|
16380
16432
|
label: `Remove ~/.verity/ (global credentials \u2014 reconnect requires re-registration)`,
|
|
@@ -16573,7 +16625,7 @@ function registerTaskCommands(program2) {
|
|
|
16573
16625
|
|
|
16574
16626
|
// src/commands/reset.ts
|
|
16575
16627
|
var import_node_fs26 = require("node:fs");
|
|
16576
|
-
var
|
|
16628
|
+
var import_node_path20 = require("node:path");
|
|
16577
16629
|
function registerResetCommand(program2) {
|
|
16578
16630
|
program2.command("reset").description("Close the current task and clear transient state").option("--keep-task", "Only purge caches; leave the current task open").option("--all", "Also purge diagnostic logs (.verity/.logs/)").action(async (opts) => {
|
|
16579
16631
|
const globals = program2.opts();
|
|
@@ -16614,7 +16666,7 @@ function registerResetCommand(program2) {
|
|
|
16614
16666
|
for (const entry of (0, import_node_fs26.readdirSync)(cacheDir)) {
|
|
16615
16667
|
if (entry.startsWith("pending-")) {
|
|
16616
16668
|
try {
|
|
16617
|
-
(0, import_node_fs26.unlinkSync)((0,
|
|
16669
|
+
(0, import_node_fs26.unlinkSync)((0, import_node_path20.join)(cacheDir, entry));
|
|
16618
16670
|
purged++;
|
|
16619
16671
|
} catch {
|
|
16620
16672
|
}
|
|
@@ -16641,7 +16693,7 @@ function registerResetCommand(program2) {
|
|
|
16641
16693
|
if ((0, import_node_fs26.existsSync)(logsDir)) {
|
|
16642
16694
|
for (const entry of (0, import_node_fs26.readdirSync)(logsDir)) {
|
|
16643
16695
|
try {
|
|
16644
|
-
(0, import_node_fs26.unlinkSync)((0,
|
|
16696
|
+
(0, import_node_fs26.unlinkSync)((0, import_node_path20.join)(logsDir, entry));
|
|
16645
16697
|
} catch {
|
|
16646
16698
|
}
|
|
16647
16699
|
}
|
|
@@ -16899,8 +16951,7 @@ function registerRunCommand(program2) {
|
|
|
16899
16951
|
}
|
|
16900
16952
|
|
|
16901
16953
|
// src/lib/telemetry.ts
|
|
16902
|
-
var
|
|
16903
|
-
var import_node_path20 = require("node:path");
|
|
16954
|
+
var import_promises14 = require("node:fs/promises");
|
|
16904
16955
|
var SETTINGS_LOCAL_FILE2 = ".claude/settings.local.json";
|
|
16905
16956
|
var GITIGNORE_FILE = ".gitignore";
|
|
16906
16957
|
var GITIGNORE_ENTRY = ".claude/settings.local.json";
|
|
@@ -16931,21 +16982,19 @@ function buildTelemetryEnv(serviceUrl, token) {
|
|
|
16931
16982
|
var VERITY_TELEMETRY_KEYS = Object.keys(buildTelemetryEnv("", ""));
|
|
16932
16983
|
async function readSettingsLocal() {
|
|
16933
16984
|
try {
|
|
16934
|
-
return JSON.parse(await (0,
|
|
16985
|
+
return JSON.parse(await (0, import_promises14.readFile)(projectPath(SETTINGS_LOCAL_FILE2), "utf-8"));
|
|
16935
16986
|
} catch {
|
|
16936
16987
|
return {};
|
|
16937
16988
|
}
|
|
16938
16989
|
}
|
|
16939
16990
|
async function writeSettingsLocal(settings) {
|
|
16940
|
-
|
|
16941
|
-
await (0, import_promises13.mkdir)((0, import_node_path20.dirname)(file), { recursive: true });
|
|
16942
|
-
await (0, import_promises13.writeFile)(file, JSON.stringify(settings, null, 2) + "\n");
|
|
16991
|
+
await writeJsonFilePreservingStyle(projectPath(SETTINGS_LOCAL_FILE2), settings);
|
|
16943
16992
|
}
|
|
16944
16993
|
async function ensureGitignore() {
|
|
16945
16994
|
const file = projectPath(GITIGNORE_FILE);
|
|
16946
16995
|
let content = "";
|
|
16947
16996
|
try {
|
|
16948
|
-
content = await (0,
|
|
16997
|
+
content = await (0, import_promises14.readFile)(file, "utf-8");
|
|
16949
16998
|
} catch {
|
|
16950
16999
|
}
|
|
16951
17000
|
const lines = content.split("\n").map((l) => l.trim());
|
|
@@ -16954,7 +17003,7 @@ async function ensureGitignore() {
|
|
|
16954
17003
|
}
|
|
16955
17004
|
const block = "# Verity telemetry \u2014 holds your project token\n" + GITIGNORE_ENTRY + "\n";
|
|
16956
17005
|
const next = content ? content + (content.endsWith("\n") ? "" : "\n") + "\n" + block : block;
|
|
16957
|
-
await (0,
|
|
17006
|
+
await (0, import_promises14.writeFile)(file, next);
|
|
16958
17007
|
}
|
|
16959
17008
|
async function installTelemetry(serviceUrl, token) {
|
|
16960
17009
|
const env = buildTelemetryEnv(serviceUrl, token);
|
|
@@ -17034,7 +17083,7 @@ function registerTelemetryCommands(program2) {
|
|
|
17034
17083
|
}
|
|
17035
17084
|
|
|
17036
17085
|
// src/cli.ts
|
|
17037
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.
|
|
17086
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.26.0-experimental.d7dfc00").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
17038
17087
|
registerAuthCommands(program);
|
|
17039
17088
|
registerHooksCommands(program);
|
|
17040
17089
|
registerIntentCommands(program);
|