wdyt 0.1.15 → 0.1.16

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 CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "wdyt",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "description": "Code review context builder for LLMs - what do you think?",
6
6
  "license": "MIT",
7
7
  "author": "bewinxed",
8
8
  "main": "src/cli.ts",
9
9
  "bin": {
10
- "wdyt": "./src/cli.ts"
10
+ "wdyt": "./src/cli.ts",
11
+ "rp-cli": "./src/cli.ts"
11
12
  },
12
13
  "files": [
13
14
  "src/**/*.ts",
package/src/cli.ts CHANGED
@@ -25,7 +25,6 @@ import {
25
25
  } from "./commands/prompt";
26
26
  import { selectGetCommand, selectAddCommand } from "./commands/select";
27
27
  import { chatSendCommand } from "./commands/chat";
28
- import { initCommand, parseInitArgs } from "./commands/init";
29
28
  import { parseExpression } from "./parseExpression";
30
29
 
31
30
  /**
@@ -169,22 +168,7 @@ function formatOutput(
169
168
  return `Error: ${result.error}`;
170
169
  }
171
170
 
172
- // Check if init command and handle it before citty
173
- const args = process.argv.slice(2);
174
- if (args[0] === "init") {
175
- const options = parseInitArgs(args.slice(1));
176
- initCommand(options).then((result) => {
177
- if (result.success) {
178
- console.log(result.output);
179
- process.exit(0);
180
- } else {
181
- console.error(result.error);
182
- process.exit(1);
183
- }
184
- });
185
- } else {
186
- // Only run citty for non-init commands
187
- const main = defineCommand({
171
+ const main = defineCommand({
188
172
  meta: {
189
173
  name: "wdyt",
190
174
  version: pkg.version,
@@ -231,11 +215,8 @@ if (args[0] === "init") {
231
215
  if (!flags.expression) {
232
216
  console.log("wdyt - Code review context builder for LLMs");
233
217
  console.log("");
234
- console.log("Setup:");
235
- console.log(" wdyt init # Interactive setup (prompts for options)");
236
- console.log(" wdyt init --global # Install binary globally");
237
- console.log(" wdyt init --rp-alias # Create rp-cli alias (for flowctl)");
238
- console.log(" wdyt init --no-alias # Skip rp-cli alias prompt");
218
+ console.log("Install:");
219
+ console.log(" bun add -g wdyt # Install globally (creates wdyt + rp-cli)");
239
220
  console.log("");
240
221
  console.log("Usage:");
241
222
  console.log(" wdyt --raw-json -e <expression>");
@@ -269,7 +250,6 @@ if (args[0] === "init") {
269
250
  process.exit(1);
270
251
  }
271
252
  },
272
- });
253
+ });
273
254
 
274
- runMain(main);
275
- }
255
+ runMain(main);
@@ -263,8 +263,8 @@ ${contextContent}
263
263
  await Bun.write(tempPromptPath, fullPrompt);
264
264
 
265
265
  try {
266
- // Run claude CLI in print mode, reading from temp file
267
- const result = await $`cat ${tempPromptPath} | claude -p`.text();
266
+ // Run claude CLI in print mode with no session persistence (one-off, not in /resume history)
267
+ const result = await $`cat ${tempPromptPath} | claude -p --no-session-persistence`.text();
268
268
 
269
269
  // Clean up temp file
270
270
  await $`rm ${tempPromptPath}`.quiet();
@@ -1,264 +0,0 @@
1
- /**
2
- * Init command - set up wdyt
3
- *
4
- * Usage:
5
- * bunx wdyt init # Interactive setup
6
- * bunx wdyt init --rp-alias # Also create rp-cli alias (skip prompt)
7
- * bunx wdyt init --no-alias # Skip rp-cli alias (no prompt)
8
- * bunx wdyt init --global # Install globally
9
- */
10
-
11
- import { mkdirSync, symlinkSync, unlinkSync } from "fs";
12
- import { join } from "path";
13
- import { homedir } from "os";
14
- import { $ } from "bun";
15
- import * as readline from "readline";
16
- import pkg from "../../package.json";
17
-
18
- const CURRENT_VERSION = pkg.version;
19
-
20
- interface InitOptions {
21
- rpAlias?: boolean;
22
- noAlias?: boolean;
23
- global?: boolean;
24
- }
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
-
50
- /**
51
- * Prompt user for yes/no input
52
- */
53
- async function promptYesNo(question: string, defaultYes = false): Promise<boolean> {
54
- const rl = readline.createInterface({
55
- input: process.stdin,
56
- output: process.stdout,
57
- });
58
-
59
- const hint = defaultYes ? "[Y/n]" : "[y/N]";
60
-
61
- return new Promise((resolve) => {
62
- rl.question(`${question} ${hint} `, (answer) => {
63
- rl.close();
64
- const trimmed = answer.trim().toLowerCase();
65
- if (trimmed === "") {
66
- resolve(defaultYes);
67
- } else {
68
- resolve(trimmed === "y" || trimmed === "yes");
69
- }
70
- });
71
- });
72
- }
73
-
74
- /**
75
- * Get the data directory path
76
- */
77
- function getDataDir(): string {
78
- const xdgDataHome = process.env.XDG_DATA_HOME;
79
- if (xdgDataHome) {
80
- return join(xdgDataHome, "wdyt");
81
- }
82
- return join(homedir(), ".wdyt");
83
- }
84
-
85
- /**
86
- * Get the bin directory for user installs
87
- */
88
- function getUserBinDir(): string {
89
- return join(homedir(), ".local", "bin");
90
- }
91
-
92
- /**
93
- * Check if a command exists in PATH
94
- */
95
- async function commandExists(cmd: string): Promise<boolean> {
96
- try {
97
- await $`which ${cmd}`.quiet();
98
- return true;
99
- } catch {
100
- return false;
101
- }
102
- }
103
-
104
- /**
105
- * Run the init command
106
- */
107
- export async function initCommand(options: InitOptions): Promise<{
108
- success: boolean;
109
- output?: string;
110
- error?: string;
111
- }> {
112
- const lines: string[] = [];
113
- const dataDir = getDataDir();
114
- const binDir = getUserBinDir();
115
-
116
- lines.push("🔍 wdyt - Code review context builder for LLMs");
117
- lines.push("");
118
-
119
- // 1. Create data directory
120
- lines.push("Setting up data directory...");
121
- try {
122
- mkdirSync(dataDir, { recursive: true });
123
- mkdirSync(join(dataDir, "chats"), { recursive: true });
124
- lines.push(` ✓ Created ${dataDir}`);
125
- } catch (error) {
126
- return {
127
- success: false,
128
- error: `Failed to create data directory: ${error}`,
129
- };
130
- }
131
-
132
- // 2. Check if already installed globally and compare versions
133
- const alreadyInstalled = await commandExists("wdyt");
134
- const wdytPath = join(binDir, "wdyt");
135
- let needsUpdate = false;
136
-
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
- }
153
- }
154
-
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
- }
161
-
162
- try {
163
- // Ensure bin directory exists
164
- mkdirSync(binDir, { recursive: true });
165
-
166
- const targetPath = join(binDir, "wdyt");
167
-
168
- // Build the binary
169
- lines.push(" Building binary...");
170
- const srcDir = join(import.meta.dir, "..");
171
- await $`bun build ${join(srcDir, "cli.ts")} --compile --outfile ${targetPath}`.quiet();
172
-
173
- lines.push(` ✓ ${needsUpdate ? "Updated" : "Installed"} to ${targetPath} (v${CURRENT_VERSION})`);
174
-
175
- // Check if ~/.local/bin is in PATH
176
- const path = process.env.PATH || "";
177
- if (!path.includes(binDir)) {
178
- lines.push("");
179
- lines.push(`⚠️ Add ${binDir} to your PATH:`);
180
- lines.push(` echo 'export PATH="${binDir}:$PATH"' >> ~/.bashrc`);
181
- }
182
- } catch (error) {
183
- lines.push(` ✗ Failed to install: ${error}`);
184
- }
185
- }
186
-
187
- // 4. Determine if we should create rp-cli alias
188
- let shouldCreateAlias = options.rpAlias;
189
-
190
- // If neither --rp-alias nor --no-alias was specified, prompt the user
191
- if (!options.rpAlias && !options.noAlias) {
192
- lines.push("");
193
- console.log(lines.join("\n"));
194
- lines.length = 0; // Clear lines since we just printed them
195
-
196
- console.log("");
197
- console.log("The rp-cli alias enables compatibility with flowctl/flow-next.");
198
- shouldCreateAlias = await promptYesNo("Create rp-cli alias?", true);
199
- }
200
-
201
- // Create rp-cli alias if requested or confirmed
202
- if (shouldCreateAlias) {
203
- lines.push("");
204
- lines.push("Creating rp-cli alias (for flowctl compatibility)...");
205
-
206
- const rpCliPath = join(binDir, "rp-cli");
207
- const secondOpinionPath = join(binDir, "wdyt");
208
-
209
- try {
210
- // Ensure bin directory exists
211
- mkdirSync(binDir, { recursive: true });
212
-
213
- // Remove existing symlink if present
214
- if (await Bun.file(rpCliPath).exists()) {
215
- unlinkSync(rpCliPath);
216
- }
217
-
218
- // Check if wdyt binary exists
219
- if (await Bun.file(secondOpinionPath).exists()) {
220
- symlinkSync(secondOpinionPath, rpCliPath);
221
- lines.push(` ✓ Created symlink: rp-cli -> wdyt`);
222
- } else {
223
- // If not installed globally, create the binary first
224
- lines.push(" Building rp-cli binary...");
225
- const srcDir = join(import.meta.dir, "..");
226
- await $`bun build ${join(srcDir, "cli.ts")} --compile --outfile ${rpCliPath}`.quiet();
227
- lines.push(` ✓ Installed rp-cli to ${rpCliPath}`);
228
- }
229
- } catch (error) {
230
- lines.push(` ✗ Failed to create alias: ${error}`);
231
- }
232
- }
233
-
234
- // 5. Summary
235
- lines.push("");
236
- lines.push("Setup complete! 🎉");
237
- lines.push("");
238
- lines.push("Usage:");
239
- lines.push(" wdyt -e 'windows' # List windows");
240
- lines.push(" wdyt -w 1 -e 'builder {}' # Create tab");
241
- lines.push(" wdyt -w 1 -t <id> -e 'select add file.ts'");
242
- lines.push("");
243
-
244
- if (!shouldCreateAlias && !options.noAlias) {
245
- lines.push("Tip: For flowctl/flow-next compatibility, run:");
246
- lines.push(" bunx wdyt init --rp-alias");
247
- }
248
-
249
- return {
250
- success: true,
251
- output: lines.join("\n"),
252
- };
253
- }
254
-
255
- /**
256
- * Parse init command arguments
257
- */
258
- export function parseInitArgs(args: string[]): InitOptions {
259
- return {
260
- rpAlias: args.includes("--rp-alias") || args.includes("--rp"),
261
- noAlias: args.includes("--no-alias") || args.includes("--no-rp"),
262
- global: args.includes("--global") || args.includes("-g"),
263
- };
264
- }