wdyt 0.1.2 → 0.1.4
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/package.json +1 -1
- package/src/cli.ts +2 -1
- package/src/commands/chat.ts +8 -2
- package/src/commands/init.ts +53 -11
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { defineCommand, runMain } from "citty";
|
|
17
17
|
import type { CLIFlags } from "./types";
|
|
18
|
+
import pkg from "../package.json";
|
|
18
19
|
import { windowsCommand } from "./commands/windows";
|
|
19
20
|
import { builderCommand } from "./commands/builder";
|
|
20
21
|
import {
|
|
@@ -179,7 +180,7 @@ if (args[0] === "init") {
|
|
|
179
180
|
const main = defineCommand({
|
|
180
181
|
meta: {
|
|
181
182
|
name: "wdyt",
|
|
182
|
-
version:
|
|
183
|
+
version: pkg.version,
|
|
183
184
|
description: "Code review context builder for LLMs",
|
|
184
185
|
},
|
|
185
186
|
args: {
|
package/src/commands/chat.ts
CHANGED
|
@@ -319,9 +319,15 @@ export async function chatSendCommand(
|
|
|
319
319
|
await Bun.write(chatPath, xmlContent);
|
|
320
320
|
|
|
321
321
|
// Check if this is a review request - if so, run Claude CLI to do the review
|
|
322
|
-
|
|
322
|
+
// Triggers: mode="review", WDYT_REVIEW=1 env var, or --review in message
|
|
323
|
+
const isReviewMode = payload.mode === "review" ||
|
|
324
|
+
payload.mode === "impl-review" ||
|
|
325
|
+
process.env.WDYT_REVIEW === "1" ||
|
|
326
|
+
prompt.includes("[REVIEW]");
|
|
323
327
|
|
|
324
328
|
if (isReviewMode) {
|
|
329
|
+
console.error(`[wdyt] Review mode triggered (mode=${payload.mode}, env=${process.env.WDYT_REVIEW || "unset"})`);
|
|
330
|
+
|
|
325
331
|
// Check if claude CLI is available
|
|
326
332
|
if (!(await claudeCliAvailable())) {
|
|
327
333
|
return {
|
|
@@ -331,7 +337,7 @@ export async function chatSendCommand(
|
|
|
331
337
|
}
|
|
332
338
|
|
|
333
339
|
// Run the review using Claude CLI
|
|
334
|
-
console.error("Running review with Claude CLI...");
|
|
340
|
+
console.error("[wdyt] Running review with Claude CLI...");
|
|
335
341
|
const reviewOutput = await runClaudeReview(chatPath, prompt);
|
|
336
342
|
|
|
337
343
|
return {
|
package/src/commands/init.ts
CHANGED
|
@@ -13,6 +13,9 @@ import { join } from "path";
|
|
|
13
13
|
import { homedir } from "os";
|
|
14
14
|
import { $ } from "bun";
|
|
15
15
|
import * as readline from "readline";
|
|
16
|
+
import pkg from "../../package.json";
|
|
17
|
+
|
|
18
|
+
const CURRENT_VERSION = pkg.version;
|
|
16
19
|
|
|
17
20
|
interface InitOptions {
|
|
18
21
|
rpAlias?: boolean;
|
|
@@ -20,6 +23,30 @@ interface InitOptions {
|
|
|
20
23
|
global?: boolean;
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Get the installed version of wdyt binary
|
|
28
|
+
*/
|
|
29
|
+
async function getInstalledVersion(binPath: string): Promise<string | null> {
|
|
30
|
+
try {
|
|
31
|
+
const result = await $`${binPath} --version 2>/dev/null`.text();
|
|
32
|
+
return result.trim() || null;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Compare semver versions, returns true if v1 > v2
|
|
40
|
+
*/
|
|
41
|
+
function isNewerVersion(v1: string, v2: string): boolean {
|
|
42
|
+
const parse = (v: string) => v.split(".").map(Number);
|
|
43
|
+
const [a1, b1, c1] = parse(v1);
|
|
44
|
+
const [a2, b2, c2] = parse(v2);
|
|
45
|
+
if (a1 !== a2) return a1 > a2;
|
|
46
|
+
if (b1 !== b2) return b1 > b2;
|
|
47
|
+
return c1 > c2;
|
|
48
|
+
}
|
|
49
|
+
|
|
23
50
|
/**
|
|
24
51
|
* Prompt user for yes/no input
|
|
25
52
|
*/
|
|
@@ -102,25 +129,40 @@ export async function initCommand(options: InitOptions): Promise<{
|
|
|
102
129
|
};
|
|
103
130
|
}
|
|
104
131
|
|
|
105
|
-
// 2. Check if already installed globally
|
|
132
|
+
// 2. Check if already installed globally and compare versions
|
|
106
133
|
const alreadyInstalled = await commandExists("wdyt");
|
|
134
|
+
const wdytPath = join(binDir, "wdyt");
|
|
135
|
+
let needsUpdate = false;
|
|
107
136
|
|
|
108
|
-
if (alreadyInstalled
|
|
109
|
-
|
|
110
|
-
|
|
137
|
+
if (alreadyInstalled) {
|
|
138
|
+
const installedVersion = await getInstalledVersion(wdytPath);
|
|
139
|
+
if (installedVersion) {
|
|
140
|
+
if (isNewerVersion(CURRENT_VERSION, installedVersion)) {
|
|
141
|
+
lines.push("");
|
|
142
|
+
lines.push(`⚠️ Installed version: ${installedVersion}, available: ${CURRENT_VERSION}`);
|
|
143
|
+
lines.push(" Updating to latest version...");
|
|
144
|
+
needsUpdate = true;
|
|
145
|
+
} else if (!options.global) {
|
|
146
|
+
lines.push("");
|
|
147
|
+
lines.push(`✓ wdyt ${installedVersion} is already installed and up to date`);
|
|
148
|
+
}
|
|
149
|
+
} else if (!options.global) {
|
|
150
|
+
lines.push("");
|
|
151
|
+
lines.push("✓ wdyt is already available in PATH");
|
|
152
|
+
}
|
|
111
153
|
}
|
|
112
154
|
|
|
113
|
-
// 3. Global install if requested
|
|
114
|
-
if (options.global) {
|
|
115
|
-
|
|
116
|
-
|
|
155
|
+
// 3. Global install if requested OR if update needed
|
|
156
|
+
if (options.global || needsUpdate) {
|
|
157
|
+
if (!needsUpdate) {
|
|
158
|
+
lines.push("");
|
|
159
|
+
lines.push("Installing globally...");
|
|
160
|
+
}
|
|
117
161
|
|
|
118
162
|
try {
|
|
119
163
|
// Ensure bin directory exists
|
|
120
164
|
mkdirSync(binDir, { recursive: true });
|
|
121
165
|
|
|
122
|
-
// Get the path to the current executable or script
|
|
123
|
-
const currentExe = process.argv[1];
|
|
124
166
|
const targetPath = join(binDir, "wdyt");
|
|
125
167
|
|
|
126
168
|
// Build the binary
|
|
@@ -128,7 +170,7 @@ export async function initCommand(options: InitOptions): Promise<{
|
|
|
128
170
|
const srcDir = join(import.meta.dir, "..");
|
|
129
171
|
await $`bun build ${join(srcDir, "cli.ts")} --compile --outfile ${targetPath}`.quiet();
|
|
130
172
|
|
|
131
|
-
lines.push(` ✓ Installed to ${targetPath}`);
|
|
173
|
+
lines.push(` ✓ ${needsUpdate ? "Updated" : "Installed"} to ${targetPath} (v${CURRENT_VERSION})`);
|
|
132
174
|
|
|
133
175
|
// Check if ~/.local/bin is in PATH
|
|
134
176
|
const path = process.env.PATH || "";
|