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