@usevalt/cli 0.7.1 → 0.7.2

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -106
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,10 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
2
 
9
3
  // src/index.ts
10
4
  import { Command as Command16 } from "commander";
@@ -254,7 +248,7 @@ function getEndpoint2() {
254
248
  return process.env.VALT_ENDPOINT ?? "https://usevalt.com";
255
249
  }
256
250
  function sleep(ms) {
257
- return new Promise((resolve4) => setTimeout(resolve4, ms));
251
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
258
252
  }
259
253
  async function openBrowser(url) {
260
254
  try {
@@ -509,13 +503,13 @@ var doctorCommand = new Command5("doctor").description("Check Valt configuration
509
503
  "UserPromptSubmit",
510
504
  "SessionEnd"
511
505
  ];
512
- const hooksPath = `${process.env["HOME"] ?? "~"}/.claude/hooks.json`;
506
+ const settingsPath = `${process.env["HOME"] ?? "~"}/.claude/settings.json`;
513
507
  try {
514
508
  const { existsSync: exists, readFileSync: read } = await import("fs");
515
- if (exists(hooksPath)) {
516
- const hooksContent = read(hooksPath, "utf-8");
517
- const hooksConfig = JSON.parse(hooksContent);
518
- const registeredHooks = hooksConfig.hooks ?? {};
509
+ if (exists(settingsPath)) {
510
+ const settingsContent = read(settingsPath, "utf-8");
511
+ const settingsConfig = JSON.parse(settingsContent);
512
+ const registeredHooks = settingsConfig.hooks ?? {};
519
513
  const presentHooks = EXPECTED_HOOKS.filter((name) => {
520
514
  const hookEntries = registeredHooks[name];
521
515
  return Array.isArray(hookEntries) && JSON.stringify(hookEntries).includes("valt");
@@ -1082,11 +1076,11 @@ async function readStdin() {
1082
1076
  if (process.stdin.isTTY) return {};
1083
1077
  try {
1084
1078
  const chunks = [];
1085
- const data = await new Promise((resolve4) => {
1079
+ const data = await new Promise((resolve3) => {
1086
1080
  process.stdin.setEncoding("utf-8");
1087
1081
  process.stdin.on("data", (chunk) => chunks.push(String(chunk)));
1088
- process.stdin.on("end", () => resolve4(chunks.join("")));
1089
- setTimeout(() => resolve4(chunks.join("")), 500);
1082
+ process.stdin.on("end", () => resolve3(chunks.join("")));
1083
+ setTimeout(() => resolve3(chunks.join("")), 500);
1090
1084
  });
1091
1085
  return data.trim() ? JSON.parse(data) : {};
1092
1086
  } catch {
@@ -1214,28 +1208,33 @@ function classifyToolCall(toolName, toolInput) {
1214
1208
  return { eventType: "tool.call" };
1215
1209
  }
1216
1210
  }
1217
- function isTestCommand(command) {
1218
- const testPatterns = [
1219
- /\b(jest|vitest|mocha|ava)\b/,
1220
- /\bpnpm\s+(test|t)\b/,
1221
- /\bnpm\s+(test|t)\b/,
1222
- /\bnpx\s+(jest|vitest)\b/,
1223
- /\bpytest\b/,
1224
- /\bpython\s+-m\s+pytest\b/,
1225
- /\bcargo\s+test\b/,
1226
- /\bgo\s+test\b/,
1227
- /\bmake\s+test\b/
1228
- ];
1229
- return testPatterns.some((p) => p.test(command));
1230
- }
1231
1211
  function parseTestResults(stdout) {
1232
- const vitestMatch = stdout.match(/Tests\s+(\d+)\s+passed.*?(\d+)\s+failed/i) ?? stdout.match(/Tests\s+(\d+)\s+passed\s+\((\d+)\)/i);
1233
- if (vitestMatch) {
1234
- const passed = parseInt(vitestMatch[1], 10);
1235
- const failedOrTotal = parseInt(vitestMatch[2], 10);
1236
- const failed = stdout.includes("failed") ? failedOrTotal : 0;
1237
- const total = stdout.includes("failed") ? passed + failed : failedOrTotal;
1238
- return { testsRun: total, testsPassed: passed, testsFailed: failed, framework: "vitest" };
1212
+ const vitestFailFirst = stdout.match(/Tests\s+(\d+)\s+failed\s*\|\s*(\d+)\s+passed\s+\((\d+)\)/i);
1213
+ if (vitestFailFirst) {
1214
+ return {
1215
+ testsRun: parseInt(vitestFailFirst[3], 10),
1216
+ testsPassed: parseInt(vitestFailFirst[2], 10),
1217
+ testsFailed: parseInt(vitestFailFirst[1], 10),
1218
+ framework: "vitest"
1219
+ };
1220
+ }
1221
+ const vitestAllPassed = stdout.match(/Tests\s+(\d+)\s+passed\s+\((\d+)\)/i);
1222
+ if (vitestAllPassed) {
1223
+ return {
1224
+ testsRun: parseInt(vitestAllPassed[2], 10),
1225
+ testsPassed: parseInt(vitestAllPassed[1], 10),
1226
+ testsFailed: 0,
1227
+ framework: "vitest"
1228
+ };
1229
+ }
1230
+ const vitestAllFailed = stdout.match(/Tests\s+(\d+)\s+failed\s+\((\d+)\)/i);
1231
+ if (vitestAllFailed) {
1232
+ return {
1233
+ testsRun: parseInt(vitestAllFailed[2], 10),
1234
+ testsPassed: 0,
1235
+ testsFailed: parseInt(vitestAllFailed[1], 10),
1236
+ framework: "vitest"
1237
+ };
1239
1238
  }
1240
1239
  const jestMatch = stdout.match(/Tests:\s+(?:(\d+)\s+failed,\s+)?(\d+)\s+passed,\s+(\d+)\s+total/i);
1241
1240
  if (jestMatch) {
@@ -1452,16 +1451,6 @@ var toolCallCommand = new Command13("tool-call").description("Hook: called on ea
1452
1451
  ...command ? { command } : {}
1453
1452
  }
1454
1453
  });
1455
- if (eventType === "command.execute" && command && isTestCommand(command)) {
1456
- events.push({
1457
- event_id: crypto.randomUUID(),
1458
- session_id: session.sessionId,
1459
- event_type: "test.run",
1460
- timestamp,
1461
- tool: "claude-code",
1462
- metadata: { command, source: "pre-tool-detect" }
1463
- });
1464
- }
1465
1454
  }
1466
1455
  await sendEvents(session.endpoint, session.apiKey, events);
1467
1456
  } catch {
@@ -1924,66 +1913,12 @@ function removeHooks() {
1924
1913
 
1925
1914
  // src/commands/start.ts
1926
1915
  import { Command as Command15 } from "commander";
1927
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, existsSync as existsSync5 } from "fs";
1928
- import { resolve as resolve3 } from "path";
1929
- var HOOKS_PATH = ".claude/hooks.json";
1930
- var VALT_HOOKS = {
1931
- SessionStart: [{
1932
- hooks: [{ type: "command", command: "npx @usevalt/cli hook session-start" }]
1933
- }],
1934
- PreToolCall: [{
1935
- matcher: ".*",
1936
- hooks: [{ type: "command", command: "echo '{}' | npx @usevalt/cli hook tool-call" }]
1937
- }],
1938
- Stop: [{
1939
- hooks: [{ type: "command", command: "npx @usevalt/cli hook session-end" }]
1940
- }]
1941
- };
1942
- var startCommand = new Command15("start").description("Configure Valt for Claude Code in the current project").action(() => {
1943
- try {
1944
- const apiKey = getApiKey();
1945
- if (!apiKey) {
1946
- error("No API key found. Set VALT_API_KEY or run `valt login` first.");
1947
- process.exit(1);
1948
- }
1949
- const claudeDir = resolve3(process.cwd(), ".claude");
1950
- if (!existsSync5(claudeDir)) {
1951
- warn("No .claude/ directory found. This command is designed for Claude Code projects.");
1952
- info("Creating .claude/ directory...");
1953
- const { mkdirSync: mkdirSync3 } = __require("fs");
1954
- mkdirSync3(claudeDir, { recursive: true });
1955
- }
1956
- const hooksFile = resolve3(process.cwd(), HOOKS_PATH);
1957
- let existingHooks = {};
1958
- if (existsSync5(hooksFile)) {
1959
- try {
1960
- existingHooks = JSON.parse(readFileSync5(hooksFile, "utf-8"));
1961
- info("Found existing hooks.json -- merging Valt hooks.");
1962
- } catch {
1963
- warn("Existing hooks.json is not valid JSON. Creating a new one.");
1964
- existingHooks = {};
1965
- }
1966
- }
1967
- const hooks = existingHooks.hooks ?? {};
1968
- for (const [event, valtEntries] of Object.entries(VALT_HOOKS)) {
1969
- const existing = hooks[event];
1970
- const hasValt = existing?.some(
1971
- (entry) => entry.hooks?.some((h) => h.command?.includes("@usevalt/cli"))
1972
- );
1973
- if (hasValt) {
1974
- continue;
1975
- }
1976
- hooks[event] = [...existing ?? [], ...valtEntries];
1977
- }
1978
- const merged = { ...existingHooks, hooks };
1979
- writeFileSync5(hooksFile, JSON.stringify(merged, null, 2) + "\n", "utf-8");
1980
- success("Valt is configured.");
1981
- info(`Hooks written to ${bold(HOOKS_PATH)}`);
1982
- info("Start a Claude Code session and your work will be tracked automatically.");
1983
- } catch (err) {
1984
- error(`Failed to configure: ${err instanceof Error ? err.message : String(err)}`);
1985
- process.exit(1);
1986
- }
1916
+ var startCommand = new Command15("start").description("Configure Valt for Claude Code (deprecated \u2014 use `valt setup`)").action(() => {
1917
+ warn("`valt start` is deprecated. Use `valt setup` instead.");
1918
+ info("Run: valt setup");
1919
+ info("");
1920
+ info("This configures hooks in ~/.claude/settings.json where Claude Code reads them.");
1921
+ process.exit(0);
1987
1922
  });
1988
1923
 
1989
1924
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usevalt/cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Valt CLI — trust layer for AI-assisted development",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "tsup": "^8.4.0",
40
40
  "typescript": "^5.7.0",
41
41
  "vitest": "^3.2.0",
42
- "@usevalt/typescript-config": "0.0.0",
43
- "@usevalt/eslint-config": "0.0.0"
42
+ "@usevalt/eslint-config": "0.0.0",
43
+ "@usevalt/typescript-config": "0.0.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsup",