wdyt 0.1.4 → 0.1.6

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/package.json +1 -1
  2. package/src/commands/chat.ts +103 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdyt",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Code review context builder for LLMs - what do you think?",
6
6
  "license": "MIT",
@@ -87,39 +87,112 @@ async function claudeCliAvailable(): Promise<boolean> {
87
87
  }
88
88
 
89
89
  /**
90
- * Run a review using Claude CLI
91
- * Returns the review output including verdict
90
+ * Quality auditor system prompt (matches flow-next's quality-auditor agent)
92
91
  */
93
- async function runClaudeReview(contextPath: string, prompt: string): Promise<string> {
92
+ const QUALITY_AUDITOR_PROMPT = `You are a pragmatic code auditor. Your job is to find real risks in recent changes - fast.
93
+
94
+ ## Audit Strategy
95
+
96
+ ### 1. Quick Scan (find obvious issues fast)
97
+ - **Secrets**: API keys, passwords, tokens in code
98
+ - **Debug code**: console.log, debugger, TODO/FIXME
99
+ - **Commented code**: Dead code that should be deleted
100
+ - **Large files**: Accidentally committed binaries, logs
101
+
102
+ ### 2. Correctness Review
103
+ - Does the code match the stated intent?
104
+ - Are there off-by-one errors, wrong operators, inverted conditions?
105
+ - Do error paths actually handle errors?
106
+ - Are promises/async properly awaited?
107
+
108
+ ### 3. Security Scan
109
+ - **Injection**: SQL, XSS, command injection vectors
110
+ - **Auth/AuthZ**: Are permissions checked? Can they be bypassed?
111
+ - **Data exposure**: Is sensitive data logged, leaked, or over-exposed?
112
+ - **Dependencies**: Any known vulnerable packages added?
113
+
114
+ ### 4. Simplicity Check
115
+ - Could this be simpler?
116
+ - Is there duplicated code that should be extracted?
117
+ - Are there unnecessary abstractions?
118
+ - Over-engineering for hypothetical future needs?
119
+
120
+ ### 5. Test Coverage
121
+ - Are new code paths tested?
122
+ - Do tests actually assert behavior (not just run)?
123
+ - Are edge cases from gap analysis covered?
124
+ - Are error paths tested?
125
+
126
+ ### 6. Performance Red Flags
127
+ - N+1 queries or O(n²) loops
128
+ - Unbounded data fetching
129
+ - Missing pagination/limits
130
+ - Blocking operations on hot paths
131
+
132
+ ## Output Format
133
+
134
+ \`\`\`markdown
135
+ ## Quality Audit: [Branch/Feature]
136
+
137
+ ### Summary
138
+ - Files changed: N
139
+ - Risk level: Low / Medium / High
140
+ - Ship recommendation: ✅ Ship / ⚠️ Fix first / ❌ Major rework
141
+
142
+ ### Critical (MUST fix before shipping)
143
+ - **[File:line]**: [Issue]
144
+ - Risk: [What could go wrong]
145
+ - Fix: [Specific suggestion]
146
+
147
+ ### Should Fix (High priority)
148
+ - **[File:line]**: [Issue]
149
+ - [Brief fix suggestion]
150
+
151
+ ### Consider (Nice to have)
152
+ - [Minor improvement suggestion]
153
+
154
+ ### Test Gaps
155
+ - [ ] [Untested scenario]
156
+
157
+ ### Security Notes
158
+ - [Any security observations]
159
+
160
+ ### What's Good
161
+ - [Positive observations - patterns followed, good decisions]
162
+ \`\`\`
163
+
164
+ ## Rules
165
+
166
+ - Find real risks, not style nitpicks
167
+ - Be specific: file:line + concrete fix
168
+ - Critical = could cause outage, data loss, security breach
169
+ - Don't block shipping for minor issues
170
+ - Acknowledge what's done well
171
+ - If no issues found, say so clearly`;
172
+
173
+ /**
174
+ * Run a chat using Claude CLI
175
+ * Sends the prompt + context to Claude and returns the response
176
+ */
177
+ async function runClaudeChat(contextPath: string, prompt: string): Promise<string> {
94
178
  // Read the context file content first
95
179
  const contextFile = Bun.file(contextPath);
96
180
  const contextContent = await contextFile.text();
97
181
 
98
- const reviewPrompt = `You are reviewing code changes. Analyze the following context and provide a thorough review.
182
+ // Build the full prompt with quality auditor system prompt + user prompt + context
183
+ const fullPrompt = `${QUALITY_AUDITOR_PROMPT}
184
+
185
+ ## User Request
99
186
 
100
- Review instructions:
101
187
  ${prompt}
102
188
 
103
189
  <context>
104
190
  ${contextContent}
105
- </context>
106
-
107
- Analyze the code for:
108
- - Correctness - Logic errors, bugs, spec compliance
109
- - Security - Injection risks, auth gaps, data exposure
110
- - Simplicity - Over-engineering, unnecessary complexity
111
- - Edge cases - Failure modes, boundary conditions
112
-
113
- Provide findings organized by severity (Critical > Major > Minor).
114
-
115
- REQUIRED: End your review with exactly one verdict tag:
116
- <verdict>SHIP</verdict> - Code is production-ready
117
- <verdict>NEEDS_WORK</verdict> - Issues must be fixed first
118
- <verdict>MAJOR_RETHINK</verdict> - Fundamental problems require redesign`;
191
+ </context>`;
119
192
 
120
193
  // Write prompt to temp file to avoid shell escaping issues
121
- const tempPromptPath = join(getChatsDir(), `review-prompt-${Date.now()}.txt`);
122
- await Bun.write(tempPromptPath, reviewPrompt);
194
+ const tempPromptPath = join(getChatsDir(), `prompt-${Date.now()}.txt`);
195
+ await Bun.write(tempPromptPath, fullPrompt);
123
196
 
124
197
  try {
125
198
  // Run claude CLI in print mode, reading from temp file
@@ -318,40 +391,24 @@ export async function chatSendCommand(
318
391
  const chatPath = join(chatsDir, `${chatId}.xml`);
319
392
  await Bun.write(chatPath, xmlContent);
320
393
 
321
- // Check if this is a review request - if so, run Claude CLI to do the review
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]");
327
-
328
- if (isReviewMode) {
329
- console.error(`[wdyt] Review mode triggered (mode=${payload.mode}, env=${process.env.WDYT_REVIEW || "unset"})`);
330
-
331
- // Check if claude CLI is available
332
- if (!(await claudeCliAvailable())) {
333
- return {
334
- success: false,
335
- error: "Review mode requires Claude CLI (claude) to be installed and in PATH",
336
- };
337
- }
338
-
339
- // Run the review using Claude CLI
340
- console.error("[wdyt] Running review with Claude CLI...");
341
- const reviewOutput = await runClaudeReview(chatPath, prompt);
394
+ // Always run Claude CLI to process the chat - that's what a drop-in rp-cli replacement does
395
+ if (await claudeCliAvailable()) {
396
+ console.error("[wdyt] Processing with Claude CLI...");
397
+ const response = await runClaudeChat(chatPath, prompt);
342
398
 
343
399
  return {
344
400
  success: true,
345
- data: { id: chatId, path: chatPath, review: reviewOutput },
346
- output: `Chat: \`${chatId}\`\n\n${reviewOutput}`,
401
+ data: { id: chatId, path: chatPath, review: response },
402
+ output: `Chat: \`${chatId}\`\n\n${response}`,
347
403
  };
348
404
  }
349
405
 
350
- // Return in the expected format: Chat: `<uuid>`
406
+ // Fallback: just return the chat ID if Claude CLI isn't available
407
+ console.error("[wdyt] Claude CLI not found, returning context only");
351
408
  return {
352
409
  success: true,
353
410
  data: { id: chatId, path: chatPath },
354
- output: `Chat: \`${chatId}\``,
411
+ output: `Chat: \`${chatId}\`\n\nContext exported to: ${chatPath}\n(Install Claude CLI for automatic LLM processing)`,
355
412
  };
356
413
  } catch (error) {
357
414
  const message = error instanceof Error ? error.message : String(error);