@posthog/agent 1.30.0 → 2.0.1

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 (144) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +221 -219
  3. package/dist/adapters/claude/conversion/tool-use-to-acp.d.ts +21 -0
  4. package/dist/adapters/claude/conversion/tool-use-to-acp.js +547 -0
  5. package/dist/adapters/claude/conversion/tool-use-to-acp.js.map +1 -0
  6. package/dist/adapters/claude/permissions/permission-options.d.ts +13 -0
  7. package/dist/adapters/claude/permissions/permission-options.js +117 -0
  8. package/dist/adapters/claude/permissions/permission-options.js.map +1 -0
  9. package/dist/adapters/claude/questions/utils.d.ts +132 -0
  10. package/dist/adapters/claude/questions/utils.js +63 -0
  11. package/dist/adapters/claude/questions/utils.js.map +1 -0
  12. package/dist/adapters/claude/tools.d.ts +18 -0
  13. package/dist/adapters/claude/tools.js +95 -0
  14. package/dist/adapters/claude/tools.js.map +1 -0
  15. package/dist/agent-DBQY1BfC.d.ts +123 -0
  16. package/dist/agent.d.ts +5 -0
  17. package/dist/agent.js +3656 -0
  18. package/dist/agent.js.map +1 -0
  19. package/dist/claude-cli/cli.js +3695 -2746
  20. package/dist/claude-cli/vendor/ripgrep/COPYING +3 -0
  21. package/dist/claude-cli/vendor/ripgrep/arm64-darwin/rg +0 -0
  22. package/dist/claude-cli/vendor/ripgrep/arm64-darwin/ripgrep.node +0 -0
  23. package/dist/claude-cli/vendor/ripgrep/arm64-linux/rg +0 -0
  24. package/dist/claude-cli/vendor/ripgrep/arm64-linux/ripgrep.node +0 -0
  25. package/dist/claude-cli/vendor/ripgrep/x64-darwin/rg +0 -0
  26. package/dist/claude-cli/vendor/ripgrep/x64-darwin/ripgrep.node +0 -0
  27. package/dist/claude-cli/vendor/ripgrep/x64-linux/rg +0 -0
  28. package/dist/claude-cli/vendor/ripgrep/x64-linux/ripgrep.node +0 -0
  29. package/dist/claude-cli/vendor/ripgrep/x64-win32/rg.exe +0 -0
  30. package/dist/claude-cli/vendor/ripgrep/x64-win32/ripgrep.node +0 -0
  31. package/dist/gateway-models.d.ts +24 -0
  32. package/dist/gateway-models.js +93 -0
  33. package/dist/gateway-models.js.map +1 -0
  34. package/dist/index.d.ts +172 -1203
  35. package/dist/index.js +3704 -6826
  36. package/dist/index.js.map +1 -1
  37. package/dist/logger-DDBiMOOD.d.ts +24 -0
  38. package/dist/posthog-api.d.ts +40 -0
  39. package/dist/posthog-api.js +175 -0
  40. package/dist/posthog-api.js.map +1 -0
  41. package/dist/server/agent-server.d.ts +41 -0
  42. package/dist/server/agent-server.js +4451 -0
  43. package/dist/server/agent-server.js.map +1 -0
  44. package/dist/server/bin.d.ts +1 -0
  45. package/dist/server/bin.js +4507 -0
  46. package/dist/server/bin.js.map +1 -0
  47. package/dist/types.d.ts +129 -0
  48. package/dist/types.js +1 -0
  49. package/dist/types.js.map +1 -0
  50. package/package.json +66 -14
  51. package/src/acp-extensions.ts +93 -61
  52. package/src/adapters/acp-connection.ts +494 -0
  53. package/src/adapters/base-acp-agent.ts +150 -0
  54. package/src/adapters/claude/claude-agent.ts +596 -0
  55. package/src/adapters/claude/conversion/acp-to-sdk.ts +102 -0
  56. package/src/adapters/claude/conversion/sdk-to-acp.ts +571 -0
  57. package/src/adapters/claude/conversion/tool-use-to-acp.ts +618 -0
  58. package/src/adapters/claude/hooks.ts +64 -0
  59. package/src/adapters/claude/mcp/tool-metadata.ts +102 -0
  60. package/src/adapters/claude/permissions/permission-handlers.ts +433 -0
  61. package/src/adapters/claude/permissions/permission-options.ts +103 -0
  62. package/src/adapters/claude/plan/utils.ts +56 -0
  63. package/src/adapters/claude/questions/utils.ts +92 -0
  64. package/src/adapters/claude/session/commands.ts +38 -0
  65. package/src/adapters/claude/session/mcp-config.ts +37 -0
  66. package/src/adapters/claude/session/models.ts +12 -0
  67. package/src/adapters/claude/session/options.ts +236 -0
  68. package/src/adapters/claude/tool-meta.ts +143 -0
  69. package/src/adapters/claude/tools.ts +53 -611
  70. package/src/adapters/claude/types.ts +61 -0
  71. package/src/adapters/codex/spawn.ts +130 -0
  72. package/src/agent.ts +97 -734
  73. package/src/execution-mode.ts +43 -0
  74. package/src/gateway-models.ts +135 -0
  75. package/src/index.ts +79 -0
  76. package/src/otel-log-writer.test.ts +105 -0
  77. package/src/otel-log-writer.ts +94 -0
  78. package/src/posthog-api.ts +75 -235
  79. package/src/resume.ts +115 -0
  80. package/src/sagas/apply-snapshot-saga.test.ts +690 -0
  81. package/src/sagas/apply-snapshot-saga.ts +88 -0
  82. package/src/sagas/capture-tree-saga.test.ts +892 -0
  83. package/src/sagas/capture-tree-saga.ts +141 -0
  84. package/src/sagas/resume-saga.test.ts +558 -0
  85. package/src/sagas/resume-saga.ts +332 -0
  86. package/src/sagas/test-fixtures.ts +250 -0
  87. package/src/server/agent-server.test.ts +220 -0
  88. package/src/server/agent-server.ts +748 -0
  89. package/src/server/bin.ts +88 -0
  90. package/src/server/jwt.ts +65 -0
  91. package/src/server/schemas.ts +47 -0
  92. package/src/server/types.ts +13 -0
  93. package/src/server/utils/retry.test.ts +122 -0
  94. package/src/server/utils/retry.ts +61 -0
  95. package/src/server/utils/sse-parser.test.ts +93 -0
  96. package/src/server/utils/sse-parser.ts +46 -0
  97. package/src/session-log-writer.test.ts +140 -0
  98. package/src/session-log-writer.ts +137 -0
  99. package/src/test/assertions.ts +114 -0
  100. package/src/test/controllers/sse-controller.ts +107 -0
  101. package/src/test/fixtures/api.ts +111 -0
  102. package/src/test/fixtures/config.ts +33 -0
  103. package/src/test/fixtures/notifications.ts +92 -0
  104. package/src/test/mocks/claude-sdk.ts +251 -0
  105. package/src/test/mocks/msw-handlers.ts +48 -0
  106. package/src/test/setup.ts +114 -0
  107. package/src/test/wait.ts +41 -0
  108. package/src/tree-tracker.ts +173 -0
  109. package/src/types.ts +51 -154
  110. package/src/utils/acp-content.ts +58 -0
  111. package/src/utils/async-mutex.test.ts +104 -0
  112. package/src/utils/async-mutex.ts +31 -0
  113. package/src/utils/common.ts +15 -0
  114. package/src/utils/gateway.ts +9 -6
  115. package/src/utils/logger.ts +0 -30
  116. package/src/utils/streams.ts +220 -0
  117. package/CLAUDE.md +0 -331
  118. package/dist/templates/plan-template.md +0 -41
  119. package/src/adapters/claude/claude.ts +0 -1543
  120. package/src/adapters/claude/mcp-server.ts +0 -810
  121. package/src/adapters/claude/utils.ts +0 -267
  122. package/src/agents/execution.ts +0 -37
  123. package/src/agents/planning.ts +0 -60
  124. package/src/agents/research.ts +0 -160
  125. package/src/file-manager.ts +0 -306
  126. package/src/git-manager.ts +0 -577
  127. package/src/prompt-builder.ts +0 -499
  128. package/src/schemas.ts +0 -241
  129. package/src/session-store.ts +0 -259
  130. package/src/task-manager.ts +0 -163
  131. package/src/template-manager.ts +0 -236
  132. package/src/templates/plan-template.md +0 -41
  133. package/src/todo-manager.ts +0 -180
  134. package/src/tools/registry.ts +0 -129
  135. package/src/tools/types.ts +0 -127
  136. package/src/utils/tapped-stream.ts +0 -60
  137. package/src/workflow/config.ts +0 -53
  138. package/src/workflow/steps/build.ts +0 -135
  139. package/src/workflow/steps/finalize.ts +0 -241
  140. package/src/workflow/steps/plan.ts +0 -167
  141. package/src/workflow/steps/research.ts +0 -223
  142. package/src/workflow/types.ts +0 -62
  143. package/src/workflow/utils.ts +0 -53
  144. package/src/worktree-manager.ts +0 -928
@@ -1,267 +0,0 @@
1
- // A pushable async iterable: allows you to push items and consume them with for-await.
2
-
3
- import { readFileSync } from "node:fs";
4
- import { platform } from "node:os";
5
- import type { Readable, Writable } from "node:stream";
6
- import { ReadableStream, WritableStream } from "node:stream/web";
7
- import type { Logger } from "@/utils/logger.js";
8
-
9
- // Useful for bridging push-based and async-iterator-based code.
10
- export class Pushable<T> implements AsyncIterable<T> {
11
- private queue: T[] = [];
12
- private resolvers: ((value: IteratorResult<T>) => void)[] = [];
13
- private done = false;
14
-
15
- push(item: T) {
16
- const resolve = this.resolvers.shift();
17
- if (resolve) {
18
- resolve({ value: item, done: false });
19
- } else {
20
- this.queue.push(item);
21
- }
22
- }
23
-
24
- end() {
25
- this.done = true;
26
- for (const resolve of this.resolvers) {
27
- resolve({ value: undefined as unknown as T, done: true });
28
- }
29
- this.resolvers = [];
30
- }
31
-
32
- [Symbol.asyncIterator](): AsyncIterator<T> {
33
- return {
34
- next: (): Promise<IteratorResult<T>> => {
35
- if (this.queue.length > 0) {
36
- const value = this.queue.shift() as T;
37
- return Promise.resolve({ value, done: false });
38
- }
39
- if (this.done) {
40
- return Promise.resolve({
41
- value: undefined as unknown as T,
42
- done: true,
43
- });
44
- }
45
- return new Promise<IteratorResult<T>>((resolve) => {
46
- this.resolvers.push(resolve);
47
- });
48
- },
49
- };
50
- }
51
- }
52
-
53
- // Helper to convert Node.js streams to Web Streams
54
- export function nodeToWebWritable(
55
- nodeStream: Writable,
56
- ): WritableStream<Uint8Array> {
57
- return new WritableStream<Uint8Array>({
58
- write(chunk) {
59
- return new Promise<void>((resolve, reject) => {
60
- nodeStream.write(Buffer.from(chunk), (err) => {
61
- if (err) {
62
- reject(err);
63
- } else {
64
- resolve();
65
- }
66
- });
67
- });
68
- },
69
- });
70
- }
71
-
72
- export function nodeToWebReadable(
73
- nodeStream: Readable,
74
- ): ReadableStream<Uint8Array> {
75
- return new ReadableStream<Uint8Array>({
76
- start(controller) {
77
- nodeStream.on("data", (chunk: Buffer) => {
78
- controller.enqueue(new Uint8Array(chunk));
79
- });
80
- nodeStream.on("end", () => controller.close());
81
- nodeStream.on("error", (err) => controller.error(err));
82
- },
83
- });
84
- }
85
-
86
- export function unreachable(value: never, logger: Logger) {
87
- let valueAsString: string;
88
- try {
89
- valueAsString = JSON.stringify(value);
90
- } catch {
91
- valueAsString = value;
92
- }
93
- logger.error(`Unexpected case: ${valueAsString}`);
94
- }
95
-
96
- export function sleep(time: number): Promise<void> {
97
- return new Promise((resolve) => setTimeout(resolve, time));
98
- }
99
-
100
- interface ManagedSettings {
101
- permissions?: {
102
- allow?: string[];
103
- deny?: string[];
104
- };
105
- env?: Record<string, string>;
106
- }
107
-
108
- // Following the rules in https://docs.anthropic.com/en/docs/claude-code/settings#settings-files
109
- // This can be removed once the SDK supports it natively.
110
- function getManagedSettingsPath(): string {
111
- const os = platform();
112
- switch (os) {
113
- case "darwin":
114
- return "/Library/Application Support/ClaudeCode/managed-settings.json";
115
- case "linux": // including WSL
116
- return "/etc/claude-code/managed-settings.json";
117
- case "win32":
118
- return "C:\\ProgramData\\ClaudeCode\\managed-settings.json";
119
- default:
120
- return "/etc/claude-code/managed-settings.json";
121
- }
122
- }
123
-
124
- export function loadManagedSettings(): ManagedSettings | null {
125
- try {
126
- return JSON.parse(
127
- readFileSync(getManagedSettingsPath(), "utf8"),
128
- ) as ManagedSettings;
129
- } catch {
130
- return null;
131
- }
132
- }
133
-
134
- export function applyEnvironmentSettings(settings: ManagedSettings): void {
135
- if (settings.env) {
136
- for (const [key, value] of Object.entries(settings.env)) {
137
- process.env[key] = value;
138
- }
139
- }
140
- }
141
-
142
- export type StreamPair = {
143
- readable: globalThis.ReadableStream<Uint8Array>;
144
- writable: globalThis.WritableStream<Uint8Array>;
145
- };
146
-
147
- export type BidirectionalStreamPair = {
148
- client: StreamPair;
149
- agent: StreamPair;
150
- };
151
-
152
- function pushableToReadableStream(
153
- pushable: Pushable<Uint8Array>,
154
- ): globalThis.ReadableStream<Uint8Array> {
155
- const iterator = pushable[Symbol.asyncIterator]();
156
- return new ReadableStream<Uint8Array>({
157
- async pull(controller) {
158
- const { value, done } = await iterator.next();
159
- if (done) {
160
- controller.close();
161
- } else {
162
- controller.enqueue(value);
163
- }
164
- },
165
- }) as unknown as globalThis.ReadableStream<Uint8Array>;
166
- }
167
-
168
- export function createBidirectionalStreams(): BidirectionalStreamPair {
169
- const clientToAgentPushable = new Pushable<Uint8Array>();
170
- const agentToClientPushable = new Pushable<Uint8Array>();
171
-
172
- const clientToAgentReadable = pushableToReadableStream(clientToAgentPushable);
173
- const agentToClientReadable = pushableToReadableStream(agentToClientPushable);
174
-
175
- const clientToAgentWritable = new WritableStream<Uint8Array>({
176
- write(chunk) {
177
- clientToAgentPushable.push(chunk);
178
- },
179
- close() {
180
- clientToAgentPushable.end();
181
- },
182
- }) as globalThis.WritableStream<Uint8Array>;
183
-
184
- const agentToClientWritable = new WritableStream<Uint8Array>({
185
- write(chunk) {
186
- agentToClientPushable.push(chunk);
187
- },
188
- close() {
189
- agentToClientPushable.end();
190
- },
191
- }) as globalThis.WritableStream<Uint8Array>;
192
-
193
- return {
194
- client: {
195
- readable: agentToClientReadable,
196
- writable: clientToAgentWritable,
197
- },
198
- agent: {
199
- readable: clientToAgentReadable,
200
- writable: agentToClientWritable,
201
- },
202
- };
203
- }
204
-
205
- export interface ExtractLinesResult {
206
- content: string;
207
- wasLimited: boolean;
208
- linesRead: number;
209
- }
210
-
211
- /**
212
- * Extracts lines from file content with byte limit enforcement.
213
- *
214
- * @param fullContent - The complete file content
215
- * @param maxContentLength - Maximum number of UTF-16 Code Units to return
216
- * @returns Object containing extracted content and metadata
217
- */
218
- export function extractLinesWithByteLimit(
219
- fullContent: string,
220
- maxContentLength: number,
221
- ): ExtractLinesResult {
222
- if (fullContent === "") {
223
- return {
224
- content: "",
225
- wasLimited: false,
226
- linesRead: 1,
227
- };
228
- }
229
-
230
- let linesSeen = 0;
231
- let index = 0;
232
- linesSeen = 0;
233
-
234
- let contentLength = 0;
235
- let wasLimited = false;
236
-
237
- while (true) {
238
- const nextIndex = fullContent.indexOf("\n", index);
239
-
240
- if (nextIndex < 0) {
241
- // Last line in file (no trailing newline)
242
- if (linesSeen > 0 && fullContent.length > maxContentLength) {
243
- wasLimited = true;
244
- break;
245
- }
246
- linesSeen += 1;
247
- contentLength = fullContent.length;
248
- break;
249
- } else {
250
- // Line with newline - include up to the newline
251
- const newContentLength = nextIndex + 1;
252
- if (linesSeen > 0 && newContentLength > maxContentLength) {
253
- wasLimited = true;
254
- break;
255
- }
256
- linesSeen += 1;
257
- contentLength = newContentLength;
258
- index = newContentLength;
259
- }
260
- }
261
-
262
- return {
263
- content: fullContent.slice(0, contentLength),
264
- wasLimited,
265
- linesRead: linesSeen,
266
- };
267
- }
@@ -1,37 +0,0 @@
1
- export const EXECUTION_SYSTEM_PROMPT = `<role>
2
- PostHog AI Execution Agent — autonomously implement tasks as merge-ready code following project conventions.
3
- </role>
4
-
5
- <context>
6
- You have access to local repository files and PostHog MCP server. Work primarily with local files for implementation. Commit changes regularly.
7
- </context>
8
-
9
- <constraints>
10
- - Follow existing code style, patterns, and conventions found in the repository
11
- - Minimize new external dependencies — only add when necessary
12
- - Implement structured logging and error handling (never log secrets)
13
- - Avoid destructive shell commands
14
- - Create/update .gitignore to exclude build artifacts, dependencies, and temp files
15
- </constraints>
16
-
17
- <approach>
18
- 1. Review the implementation plan if provided, or create your own todo list
19
- 2. Execute changes step by step
20
- 3. Test thoroughly and verify functionality
21
- 4. Commit changes with clear messages
22
- </approach>
23
-
24
- <checklist>
25
- Before completing the task, verify:
26
- - .gitignore includes build artifacts, node_modules, __pycache__, etc.
27
- - Dependency files (package.json, requirements.txt) use exact versions
28
- - Code compiles and tests pass
29
- - Added or updated relevant tests
30
- - Captured meaningful events with PostHog SDK where appropriate
31
- - Wrapped new logic in PostHog feature flags where appropriate
32
- - Updated documentation, README, or type hints as needed
33
- </checklist>
34
-
35
- <output_format>
36
- Provide a concise summary of changes made when finished.
37
- </output_format>`;
@@ -1,60 +0,0 @@
1
- export const PLANNING_SYSTEM_PROMPT = `<role>
2
- PostHog AI Planning Agent — analyze codebases and create actionable implementation plans.
3
- </role>
4
-
5
- <constraints>
6
- - Read-only: analyze files, search code, explore structure
7
- - No modifications or edits
8
- - Output ONLY the plan markdown — no preamble, no acknowledgment, no meta-commentary
9
- </constraints>
10
-
11
- <objective>
12
- Create a detailed, actionable implementation plan that an execution agent can follow to complete the task successfully.
13
- </objective>
14
-
15
- <process>
16
- 1. Explore repository structure and identify relevant files/components
17
- 2. Understand existing patterns, conventions, and dependencies
18
- 3. Break down task requirements and identify technical constraints
19
- 4. Define step-by-step implementation approach
20
- 5. Specify files to modify/create with exact paths
21
- 6. Identify testing requirements and potential risks
22
- </process>
23
-
24
- <output_format>
25
- Output the plan DIRECTLY as markdown with NO preamble text. Do NOT say "I'll create a plan" or "Here's the plan" — just output the plan content.
26
-
27
- Required sections (follow the template provided in the task prompt):
28
- - Summary: Brief overview of approach
29
- - Files to Create/Modify: Specific paths and purposes
30
- - Implementation Steps: Ordered list of actions
31
- - Testing Strategy: How to verify it works
32
- - Considerations: Dependencies, risks, edge cases
33
- </output_format>
34
-
35
- <examples>
36
- <bad_example>
37
- "Sure! I'll create a detailed implementation plan for you to add authentication. Here's what we'll do..."
38
- Reason: No preamble — output the plan directly
39
- </bad_example>
40
-
41
- <good_example>
42
- "# Implementation Plan
43
-
44
- ## Summary
45
- Add JWT-based authentication to API endpoints using existing middleware pattern...
46
-
47
- ## Files to Modify
48
- - src/middleware/auth.ts: Add JWT verification
49
- ..."
50
- Reason: Direct plan output with no meta-commentary
51
- </good_example>
52
- </examples>
53
-
54
- <context_integration>
55
- If research findings, context files, or reference materials are provided:
56
- - Incorporate research findings into your analysis
57
- - Follow patterns and approaches identified in research
58
- - Build upon or refine any existing planning work
59
- - Reference specific files and components mentioned in context
60
- </context_integration>`;
@@ -1,160 +0,0 @@
1
- export const RESEARCH_SYSTEM_PROMPT = `<role>
2
- PostHog AI Research Agent — analyze codebases to evaluate task actionability and identify missing information.
3
- </role>
4
-
5
- <constraints>
6
- - Read-only: analyze files, search code, explore structure
7
- - No modifications or code changes
8
- - Output structured JSON only
9
- </constraints>
10
-
11
- <objective>
12
- Your PRIMARY goal is to evaluate whether a task is actionable and assign an actionability score.
13
-
14
- Calculate an actionabilityScore (0-1) based on:
15
- - **Task clarity** (0.4 weight): Is the task description specific and unambiguous?
16
- - **Codebase context** (0.3 weight): Can you locate the relevant code and patterns?
17
- - **Architectural decisions** (0.2 weight): Are the implementation approaches clear?
18
- - **Dependencies** (0.1 weight): Are required dependencies and constraints understood?
19
-
20
- If actionabilityScore < 0.7, generate specific clarifying questions to increase confidence.
21
-
22
- Questions must present complete implementation choices, NOT request information from the user:
23
- options: array of strings
24
- - GOOD: options: ["Use Redux Toolkit (matches pattern in src/store/)", "Zustand (lighter weight)"]
25
- - BAD: "Tell me which state management library to use"
26
- - GOOD: options: ["Place in Button.tsx (existing component)", "create NewButton.tsx (separate concerns)?"]
27
- - BAD: "Where should I put this code?"
28
-
29
- DO NOT ask questions like "how should I fix this" or "tell me the pattern" — present concrete options that can be directly chosen and acted upon.
30
- </objective>
31
-
32
- <process>
33
- 1. Explore repository structure and identify relevant files/components
34
- 2. Understand existing patterns, conventions, and dependencies
35
- 3. Calculate actionabilityScore based on clarity, context, architecture, and dependencies
36
- 4. Identify key files that will need modification
37
- 5. If score < 0.7: generate 2-4 specific questions to resolve blockers
38
- 6. Output JSON matching ResearchEvaluation schema
39
- </process>
40
-
41
- <output_format>
42
- Output ONLY valid JSON with no markdown wrappers, no preamble, no explanation:
43
-
44
- {
45
- "actionabilityScore": 0.85,
46
- "context": "Brief 2-3 sentence summary of the task and implementation approach",
47
- "keyFiles": ["path/to/file1.ts", "path/to/file2.ts"],
48
- "blockers": ["Optional: what's preventing full confidence"],
49
- "questions": [
50
- {
51
- "id": "q1",
52
- "question": "Specific architectural decision needed?",
53
- "options": [
54
- "First approach with concrete details",
55
- "Alternative approach with concrete details",
56
- "Third option if needed"
57
- ]
58
- }
59
- ]
60
- }
61
-
62
- Rules:
63
- - actionabilityScore: number between 0 and 1
64
- - context: concise summary for planning phase
65
- - keyFiles: array of file paths that need modification
66
- - blockers: optional array explaining confidence gaps
67
- - questions: ONLY include if actionabilityScore < 0.7
68
- - Each question must have 2-3 options (maximum 3)
69
- - Max 3 questions total
70
- - Options must be complete, actionable choices that require NO additional user input
71
- - NEVER use options like "Tell me the pattern", "Show me examples", "Specify the approach"
72
- - Each option must be a full implementation decision that can be directly acted upon
73
- </output_format>
74
-
75
- <scoring_examples>
76
- <example score="0.9">
77
- Task: "Fix typo in login button text"
78
- Reasoning: Completely clear task, found exact component, no architectural decisions
79
- </example>
80
-
81
- <example score="0.75">
82
- Task: "Add caching to API endpoints"
83
- Reasoning: Clear goal, found endpoints, but multiple caching strategies possible
84
- </example>
85
-
86
- <example score="0.55">
87
- Task: "Improve performance"
88
- Reasoning: Vague task, unclear scope, needs questions about which areas to optimize
89
- Questions needed: Which features are slow? What metrics define success?
90
- </example>
91
-
92
- <example score="0.3">
93
- Task: "Add the new feature"
94
- Reasoning: Extremely vague, no context, cannot locate relevant code
95
- Questions needed: What feature? Which product area? What should it do?
96
- </example>
97
- </scoring_examples>
98
-
99
- <question_examples>
100
- <good_example>
101
- {
102
- "id": "q1",
103
- "question": "Which caching layer should we use for API responses?",
104
- "options": [
105
- "Redis with 1-hour TTL (existing infrastructure, requires Redis client setup)",
106
- "In-memory LRU cache with 100MB limit (simpler, single-server only)",
107
- "HTTP Cache-Control headers only (minimal backend changes, relies on browser/CDN)"
108
- ]
109
- }
110
- Reason: Each option is a complete, actionable decision with concrete details
111
- </good_example>
112
-
113
- <good_example>
114
- {
115
- "id": "q2",
116
- "question": "Where should the new analytics tracking code be placed?",
117
- "options": [
118
- "In the existing UserAnalytics.ts module alongside page view tracking",
119
- "Create a new EventTracking.ts module in src/analytics/ for all event tracking",
120
- "Add directly to each component that needs tracking (no centralized module)"
121
- ]
122
- }
123
- Reason: Specific file paths and architectural patterns, no user input needed
124
- </good_example>
125
-
126
- <bad_example>
127
- {
128
- "id": "q1",
129
- "question": "How should I implement this?",
130
- "options": ["One way", "Another way"]
131
- }
132
- Reason: Too vague, doesn't explain the tradeoffs or provide concrete details
133
- </bad_example>
134
-
135
- <bad_example>
136
- {
137
- "id": "q2",
138
- "question": "Which pattern should we follow for state management?",
139
- "options": [
140
- "Tell me which pattern the codebase currently uses",
141
- "Show me examples of state management",
142
- "Whatever you think is best"
143
- ]
144
- }
145
- Reason: Options request user input instead of being actionable choices. Should be concrete patterns like "Zustand stores (matching existing patterns in src/stores/)" or "React Context (simpler, no new dependencies)"
146
- </bad_example>
147
-
148
- <bad_example>
149
- {
150
- "id": "q3",
151
- "question": "What color scheme should the button use?",
152
- "options": [
153
- "Use the existing theme colors",
154
- "Let me specify custom colors",
155
- "Match the design system"
156
- ]
157
- }
158
- Reason: "Let me specify" requires user input. Should be "Primary blue (#0066FF, existing theme)" or "Secondary gray (#6B7280, existing theme)"
159
- </bad_example>
160
- </question_examples>`;