@posthog/agent 1.12.0 → 1.14.0
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/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/node_modules/@ai-sdk/anthropic/dist/index.js +1154 -0
- package/dist/node_modules/@ai-sdk/anthropic/dist/index.js.map +1 -0
- package/dist/node_modules/@ai-sdk/provider/dist/index.js +296 -0
- package/dist/node_modules/@ai-sdk/provider/dist/index.js.map +1 -0
- package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js +576 -0
- package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js.map +1 -0
- package/dist/node_modules/@ai-sdk/ui-utils/dist/index.js +741 -0
- package/dist/node_modules/@ai-sdk/ui-utils/dist/index.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/context.js +112 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/context.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/diag.js +123 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/diag.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/metrics.js +62 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/metrics.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/propagation.js +91 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/propagation.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/trace.js +79 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/api/trace.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js +59 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js +99 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/baggage/utils.js +31 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/baggage/utils.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js +69 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/context/context.js +54 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/context/context.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/context-api.js +22 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/context-api.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js +104 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js +44 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag/types.js +43 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag/types.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag-api.js +27 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/diag-api.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js +62 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/internal/semver.js +121 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/internal/semver.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js +167 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js +33 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/metrics-api.js +22 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/metrics-api.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js +21 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js +35 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js +40 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/propagation-api.js +22 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/propagation-api.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js +70 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js +78 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js +34 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js +55 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js +56 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js +76 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js +27 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js +45 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/status.js +22 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/status.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js +25 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace-api.js +24 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/trace-api.js.map +1 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/version.js +20 -0
- package/dist/node_modules/@opentelemetry/api/build/esm/version.js.map +1 -0
- package/dist/node_modules/ai/dist/index.js +2870 -0
- package/dist/node_modules/ai/dist/index.js.map +1 -0
- package/dist/node_modules/nanoid/non-secure/index.js +13 -0
- package/dist/node_modules/nanoid/non-secure/index.js.map +1 -0
- package/dist/node_modules/secure-json-parse/index.js +133 -0
- package/dist/node_modules/secure-json-parse/index.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/index.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/index.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +110 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
- package/dist/src/agent.d.ts +3 -0
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +93 -291
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.d.ts +1 -1
- package/dist/src/agents/execution.d.ts.map +1 -1
- package/dist/src/agents/execution.js +28 -43
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.d.ts +1 -1
- package/dist/src/agents/planning.d.ts.map +1 -1
- package/dist/src/agents/planning.js +60 -67
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.d.ts +1 -1
- package/dist/src/agents/research.d.ts.map +1 -1
- package/dist/src/agents/research.js +68 -91
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +68 -36
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/structured-extraction.d.ts +2 -2
- package/dist/src/structured-extraction.d.ts.map +1 -1
- package/dist/src/structured-extraction.js +51 -110
- package/dist/src/structured-extraction.js.map +1 -1
- package/dist/src/workflow/config.d.ts +3 -0
- package/dist/src/workflow/config.d.ts.map +1 -0
- package/dist/src/workflow/config.js +43 -0
- package/dist/src/workflow/config.js.map +1 -0
- package/dist/src/workflow/steps/build.d.ts +3 -0
- package/dist/src/workflow/steps/build.d.ts.map +1 -0
- package/dist/src/workflow/steps/build.js +64 -0
- package/dist/src/workflow/steps/build.js.map +1 -0
- package/dist/src/workflow/steps/plan.d.ts +3 -0
- package/dist/src/workflow/steps/plan.d.ts.map +1 -0
- package/dist/src/workflow/steps/plan.js +86 -0
- package/dist/src/workflow/steps/plan.js.map +1 -0
- package/dist/src/workflow/steps/research.d.ts +3 -0
- package/dist/src/workflow/steps/research.d.ts.map +1 -0
- package/dist/src/workflow/steps/research.js +124 -0
- package/dist/src/workflow/steps/research.js.map +1 -0
- package/dist/src/workflow/types.d.ts +48 -0
- package/dist/src/workflow/types.d.ts.map +1 -0
- package/dist/src/workflow/utils.d.ts +12 -0
- package/dist/src/workflow/utils.d.ts.map +1 -0
- package/dist/src/workflow/utils.js +38 -0
- package/dist/src/workflow/utils.js.map +1 -0
- package/package.json +5 -2
- package/src/agent.ts +112 -321
- package/src/agents/execution.ts +28 -43
- package/src/agents/planning.ts +60 -67
- package/src/agents/research.ts +68 -91
- package/src/prompt-builder.ts +71 -37
- package/src/structured-extraction.ts +58 -115
- package/src/workflow/config.ts +42 -0
- package/src/workflow/steps/build.ts +87 -0
- package/src/workflow/steps/plan.ts +112 -0
- package/src/workflow/steps/research.ts +156 -0
- package/src/workflow/types.ts +53 -0
- package/src/workflow/utils.ts +50 -0
package/src/agents/planning.ts
CHANGED
|
@@ -1,67 +1,60 @@
|
|
|
1
|
-
export const PLANNING_SYSTEM_PROMPT =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
If supporting files are provided, incorporate them into your analysis:
|
|
63
|
-
- **Context files**: Additional requirements or constraints
|
|
64
|
-
- **Reference files**: Examples or documentation to follow
|
|
65
|
-
- **Previous plans**: Build upon or refine existing planning work
|
|
66
|
-
|
|
67
|
-
Your planning should be thorough enough that another agent in execution mode can implement the changes successfully.`;
|
|
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, edits, or command execution
|
|
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>`;
|
package/src/agents/research.ts
CHANGED
|
@@ -1,103 +1,80 @@
|
|
|
1
|
-
export const RESEARCH_SYSTEM_PROMPT =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- Look for similar implementations or patterns
|
|
33
|
-
|
|
34
|
-
2. **Decision Point Identification**
|
|
35
|
-
- Identify areas where implementation decisions need to be made
|
|
36
|
-
- Find multiple viable approaches in the codebase
|
|
37
|
-
- Note where user preferences would affect the implementation
|
|
38
|
-
- Consider architectural or design pattern choices
|
|
39
|
-
|
|
40
|
-
3. **Question Generation**
|
|
41
|
-
- Generate 3-5 clarifying questions
|
|
42
|
-
- Each question should offer 2-3 concrete options based on codebase analysis
|
|
43
|
-
- Options should reference actual patterns/approaches found in the code
|
|
44
|
-
- Always include option c) as "Something else (please specify)" for flexibility
|
|
45
|
-
- Focus on high-impact decisions that affect the implementation approach
|
|
46
|
-
|
|
47
|
-
## Output Format
|
|
48
|
-
|
|
49
|
-
After completing your research, you MUST use the \`create_plan\` tool to create a research.md artifact with your questions.
|
|
50
|
-
|
|
51
|
-
The artifact MUST follow this EXACT markdown format (this is critical for parsing):
|
|
1
|
+
export const RESEARCH_SYSTEM_PROMPT = `<role>
|
|
2
|
+
PostHog AI Research Agent — analyze codebases to understand implementation context and identify areas of focus for development tasks.
|
|
3
|
+
</role>
|
|
4
|
+
|
|
5
|
+
<constraints>
|
|
6
|
+
- Read-only: analyze files, search code, explore structure
|
|
7
|
+
- No modifications or code changes
|
|
8
|
+
</constraints>
|
|
9
|
+
|
|
10
|
+
<objective>
|
|
11
|
+
Your PRIMARY goal is to understand the codebase thoroughly and provide context for the planning phase.
|
|
12
|
+
|
|
13
|
+
ONLY generate clarifying questions if:
|
|
14
|
+
- The task description is genuinely vague or ambiguous
|
|
15
|
+
- There are multiple valid architectural approaches with significant tradeoffs
|
|
16
|
+
- Critical information is missing that cannot be inferred from the codebase
|
|
17
|
+
|
|
18
|
+
DO NOT ask questions like "how should I fix this" or "what approach do you prefer" — that defeats the purpose of autonomous task execution. The user has already specified what they want done.
|
|
19
|
+
</objective>
|
|
20
|
+
|
|
21
|
+
<process>
|
|
22
|
+
1. Explore repository structure and identify relevant files/components
|
|
23
|
+
2. Understand existing patterns, conventions, and dependencies
|
|
24
|
+
3. Locate similar implementations or related code
|
|
25
|
+
4. Identify the key areas of the codebase that will be affected
|
|
26
|
+
5. Document your findings to provide context for planning
|
|
27
|
+
6. ONLY if genuinely needed: generate 2-3 specific clarification questions
|
|
28
|
+
</process>
|
|
29
|
+
|
|
30
|
+
<output_format>
|
|
31
|
+
Output ONLY the markdown artifact with no preamble:
|
|
52
32
|
|
|
53
33
|
\`\`\`markdown
|
|
54
|
-
# Research
|
|
55
|
-
|
|
56
|
-
Based on my analysis of the codebase, here are the key questions to guide implementation:
|
|
34
|
+
# Research Findings
|
|
57
35
|
|
|
58
|
-
##
|
|
36
|
+
## Codebase Analysis
|
|
37
|
+
[Brief summary of relevant code structure, patterns, and files]
|
|
59
38
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- b) [Alternative approach based on another pattern - reference specific files/components]
|
|
63
|
-
- c) Something else (please specify)
|
|
39
|
+
## Key Areas of Focus
|
|
40
|
+
[List specific files/components that need modification]
|
|
64
41
|
|
|
65
|
-
##
|
|
66
|
-
|
|
67
|
-
**Options:**
|
|
68
|
-
- a) [Option with specific code references]
|
|
69
|
-
- b) [Alternative with specific code references]
|
|
70
|
-
- c) Something else (please specify)
|
|
42
|
+
## Implementation Context
|
|
43
|
+
[Important patterns, dependencies, or constraints found in the code]
|
|
71
44
|
|
|
72
|
-
##
|
|
45
|
+
## Clarifying Questions
|
|
46
|
+
[ONLY include this section if it will increase the quality of the plan]
|
|
73
47
|
|
|
48
|
+
## Question 1: [Specific architectural decision]
|
|
74
49
|
**Options:**
|
|
75
|
-
- a) [
|
|
76
|
-
- b) [Alternative]
|
|
50
|
+
- a) [Concrete option with file references]
|
|
51
|
+
- b) [Alternative with file references]
|
|
77
52
|
- c) Something else (please specify)
|
|
78
53
|
\`\`\`
|
|
79
54
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
55
|
+
Format requirements:
|
|
56
|
+
- Use "## Question N:" for question headers (h2)
|
|
57
|
+
- Follow with "**Options:**" on its own line
|
|
58
|
+
- Start options with "- a)", "- b)", "- c)"
|
|
59
|
+
- Always include "c) Something else (please specify)"
|
|
60
|
+
- Max 3 questions total
|
|
61
|
+
</output_format>
|
|
62
|
+
|
|
63
|
+
<examples>
|
|
64
|
+
<good_example>
|
|
65
|
+
Task: "Fix authentication bug in login flow"
|
|
66
|
+
Output: Research findings showing auth flow files, patterns used, NO questions needed
|
|
67
|
+
</good_example>
|
|
68
|
+
|
|
69
|
+
<bad_example>
|
|
70
|
+
Task: "Fix authentication bug"
|
|
71
|
+
Output: "How should I fix the authentication? a) Fix it one way b) Fix it another way"
|
|
72
|
+
Reason: Don't ask HOW to do the task — that's what the agent is for
|
|
73
|
+
</bad_example>
|
|
74
|
+
|
|
75
|
+
<good_example>
|
|
76
|
+
Task: "Add caching to API endpoints"
|
|
77
|
+
Output: Research showing existing cache implementations, question about cache backend choice IF multiple production systems are already in use
|
|
78
|
+
</good_example>
|
|
79
|
+
</examples>`;
|
|
103
80
|
|
package/src/prompt-builder.ts
CHANGED
|
@@ -213,49 +213,55 @@ export class PromptBuilder {
|
|
|
213
213
|
repositoryPath
|
|
214
214
|
);
|
|
215
215
|
|
|
216
|
-
// Process URL references in description
|
|
216
|
+
// Process URL references in description
|
|
217
217
|
const { description: processedDescription, referencedResources } = await this.processUrlReferences(
|
|
218
218
|
descriptionAfterFiles
|
|
219
219
|
);
|
|
220
220
|
|
|
221
|
-
let prompt = '';
|
|
222
|
-
prompt +=
|
|
221
|
+
let prompt = '<task>\n';
|
|
222
|
+
prompt += `<title>${task.title}</title>\n`;
|
|
223
|
+
prompt += `<description>${processedDescription}</description>\n`;
|
|
223
224
|
|
|
224
225
|
if ((task as any).primary_repository) {
|
|
225
|
-
prompt +=
|
|
226
|
+
prompt += `<repository>${(task as any).primary_repository}</repository>\n`;
|
|
226
227
|
}
|
|
228
|
+
prompt += '</task>\n';
|
|
227
229
|
|
|
228
230
|
// Add referenced files from @ mentions
|
|
229
231
|
if (referencedFiles.length > 0) {
|
|
230
|
-
prompt +=
|
|
232
|
+
prompt += '\n<referenced_files>\n';
|
|
231
233
|
for (const file of referencedFiles) {
|
|
232
|
-
prompt +=
|
|
234
|
+
prompt += `<file path="${file.path}">\n\`\`\`\n${file.content}\n\`\`\`\n</file>\n`;
|
|
233
235
|
}
|
|
236
|
+
prompt += '</referenced_files>\n';
|
|
234
237
|
}
|
|
235
238
|
|
|
236
239
|
// Add referenced resources from URL mentions
|
|
237
240
|
if (referencedResources.length > 0) {
|
|
238
|
-
prompt +=
|
|
241
|
+
prompt += '\n<referenced_resources>\n';
|
|
239
242
|
for (const resource of referencedResources) {
|
|
240
|
-
prompt +=
|
|
243
|
+
prompt += `<resource type="${resource.type}" url="${resource.url}">\n`;
|
|
244
|
+
prompt += `<title>${resource.title}</title>\n`;
|
|
245
|
+
prompt += `<content>${resource.content}</content>\n`;
|
|
246
|
+
prompt += '</resource>\n';
|
|
241
247
|
}
|
|
248
|
+
prompt += '</referenced_resources>\n';
|
|
242
249
|
}
|
|
243
250
|
|
|
244
251
|
try {
|
|
245
252
|
const taskFiles = await this.getTaskFiles(task.id);
|
|
246
253
|
const contextFiles = taskFiles.filter((f: any) => f.type === 'context' || f.type === 'reference');
|
|
247
254
|
if (contextFiles.length > 0) {
|
|
248
|
-
prompt +=
|
|
255
|
+
prompt += '\n<supporting_files>\n';
|
|
249
256
|
for (const file of contextFiles) {
|
|
250
|
-
prompt +=
|
|
257
|
+
prompt += `<file name="${file.name}" type="${file.type}">\n${file.content}\n</file>\n`;
|
|
251
258
|
}
|
|
259
|
+
prompt += '</supporting_files>\n';
|
|
252
260
|
}
|
|
253
261
|
} catch (error) {
|
|
254
262
|
this.logger.debug('No existing task files found for research', { taskId: task.id });
|
|
255
263
|
}
|
|
256
264
|
|
|
257
|
-
prompt += `\n\nPlease explore the codebase thoroughly and generate 3-5 clarifying questions that will help guide the implementation of this task. Use the \`create_plan\` tool to create a research.md artifact with your questions in the markdown format specified in your system prompt.`;
|
|
258
|
-
|
|
259
265
|
return prompt;
|
|
260
266
|
}
|
|
261
267
|
|
|
@@ -266,42 +272,50 @@ export class PromptBuilder {
|
|
|
266
272
|
repositoryPath
|
|
267
273
|
);
|
|
268
274
|
|
|
269
|
-
// Process URL references in description
|
|
275
|
+
// Process URL references in description
|
|
270
276
|
const { description: processedDescription, referencedResources } = await this.processUrlReferences(
|
|
271
277
|
descriptionAfterFiles
|
|
272
278
|
);
|
|
273
279
|
|
|
274
|
-
let prompt = '';
|
|
275
|
-
prompt +=
|
|
280
|
+
let prompt = '<task>\n';
|
|
281
|
+
prompt += `<title>${task.title}</title>\n`;
|
|
282
|
+
prompt += `<description>${processedDescription}</description>\n`;
|
|
276
283
|
|
|
277
284
|
if ((task as any).primary_repository) {
|
|
278
|
-
prompt +=
|
|
285
|
+
prompt += `<repository>${(task as any).primary_repository}</repository>\n`;
|
|
279
286
|
}
|
|
287
|
+
prompt += '</task>\n';
|
|
280
288
|
|
|
281
289
|
// Add referenced files from @ mentions
|
|
282
290
|
if (referencedFiles.length > 0) {
|
|
283
|
-
prompt +=
|
|
291
|
+
prompt += '\n<referenced_files>\n';
|
|
284
292
|
for (const file of referencedFiles) {
|
|
285
|
-
prompt +=
|
|
293
|
+
prompt += `<file path="${file.path}">\n\`\`\`\n${file.content}\n\`\`\`\n</file>\n`;
|
|
286
294
|
}
|
|
295
|
+
prompt += '</referenced_files>\n';
|
|
287
296
|
}
|
|
288
297
|
|
|
289
298
|
// Add referenced resources from URL mentions
|
|
290
299
|
if (referencedResources.length > 0) {
|
|
291
|
-
prompt +=
|
|
300
|
+
prompt += '\n<referenced_resources>\n';
|
|
292
301
|
for (const resource of referencedResources) {
|
|
293
|
-
prompt +=
|
|
302
|
+
prompt += `<resource type="${resource.type}" url="${resource.url}">\n`;
|
|
303
|
+
prompt += `<title>${resource.title}</title>\n`;
|
|
304
|
+
prompt += `<content>${resource.content}</content>\n`;
|
|
305
|
+
prompt += '</resource>\n';
|
|
294
306
|
}
|
|
307
|
+
prompt += '</referenced_resources>\n';
|
|
295
308
|
}
|
|
296
309
|
|
|
297
310
|
try {
|
|
298
311
|
const taskFiles = await this.getTaskFiles(task.id);
|
|
299
312
|
const contextFiles = taskFiles.filter((f: any) => f.type === 'context' || f.type === 'reference');
|
|
300
313
|
if (contextFiles.length > 0) {
|
|
301
|
-
prompt +=
|
|
314
|
+
prompt += '\n<supporting_files>\n';
|
|
302
315
|
for (const file of contextFiles) {
|
|
303
|
-
prompt +=
|
|
316
|
+
prompt += `<file name="${file.name}" type="${file.type}">\n${file.content}\n</file>\n`;
|
|
304
317
|
}
|
|
318
|
+
prompt += '</supporting_files>\n';
|
|
305
319
|
}
|
|
306
320
|
} catch (error) {
|
|
307
321
|
this.logger.debug('No existing task files found for planning', { taskId: task.id });
|
|
@@ -317,7 +331,12 @@ export class PromptBuilder {
|
|
|
317
331
|
|
|
318
332
|
const planTemplate = await this.generatePlanTemplate(templateVariables);
|
|
319
333
|
|
|
320
|
-
prompt +=
|
|
334
|
+
prompt += '\n<instructions>\n';
|
|
335
|
+
prompt += 'Analyze the codebase and create a detailed implementation plan. Use the template structure below, filling each section with specific, actionable information.\n';
|
|
336
|
+
prompt += '</instructions>\n\n';
|
|
337
|
+
prompt += '<plan_template>\n';
|
|
338
|
+
prompt += planTemplate;
|
|
339
|
+
prompt += '\n</plan_template>';
|
|
321
340
|
|
|
322
341
|
return prompt;
|
|
323
342
|
}
|
|
@@ -329,56 +348,71 @@ export class PromptBuilder {
|
|
|
329
348
|
repositoryPath
|
|
330
349
|
);
|
|
331
350
|
|
|
332
|
-
// Process URL references in description
|
|
351
|
+
// Process URL references in description
|
|
333
352
|
const { description: processedDescription, referencedResources } = await this.processUrlReferences(
|
|
334
353
|
descriptionAfterFiles
|
|
335
354
|
);
|
|
336
355
|
|
|
337
|
-
let prompt = '';
|
|
338
|
-
prompt +=
|
|
356
|
+
let prompt = '<task>\n';
|
|
357
|
+
prompt += `<title>${task.title}</title>\n`;
|
|
358
|
+
prompt += `<description>${processedDescription}</description>\n`;
|
|
339
359
|
|
|
340
360
|
if ((task as any).primary_repository) {
|
|
341
|
-
prompt +=
|
|
361
|
+
prompt += `<repository>${(task as any).primary_repository}</repository>\n`;
|
|
342
362
|
}
|
|
363
|
+
prompt += '</task>\n';
|
|
343
364
|
|
|
344
365
|
// Add referenced files from @ mentions
|
|
345
366
|
if (referencedFiles.length > 0) {
|
|
346
|
-
prompt +=
|
|
367
|
+
prompt += '\n<referenced_files>\n';
|
|
347
368
|
for (const file of referencedFiles) {
|
|
348
|
-
prompt +=
|
|
369
|
+
prompt += `<file path="${file.path}">\n\`\`\`\n${file.content}\n\`\`\`\n</file>\n`;
|
|
349
370
|
}
|
|
371
|
+
prompt += '</referenced_files>\n';
|
|
350
372
|
}
|
|
351
373
|
|
|
352
374
|
// Add referenced resources from URL mentions
|
|
353
375
|
if (referencedResources.length > 0) {
|
|
354
|
-
prompt +=
|
|
376
|
+
prompt += '\n<referenced_resources>\n';
|
|
355
377
|
for (const resource of referencedResources) {
|
|
356
|
-
prompt +=
|
|
378
|
+
prompt += `<resource type="${resource.type}" url="${resource.url}">\n`;
|
|
379
|
+
prompt += `<title>${resource.title}</title>\n`;
|
|
380
|
+
prompt += `<content>${resource.content}</content>\n`;
|
|
381
|
+
prompt += '</resource>\n';
|
|
357
382
|
}
|
|
383
|
+
prompt += '</referenced_resources>\n';
|
|
358
384
|
}
|
|
359
385
|
|
|
360
386
|
try {
|
|
361
387
|
const taskFiles = await this.getTaskFiles(task.id);
|
|
362
388
|
const hasPlan = taskFiles.some((f: any) => f.type === 'plan');
|
|
389
|
+
|
|
363
390
|
if (taskFiles.length > 0) {
|
|
364
|
-
prompt +=
|
|
391
|
+
prompt += '\n<context>\n';
|
|
365
392
|
for (const file of taskFiles) {
|
|
366
393
|
if (file.type === 'plan') {
|
|
367
|
-
prompt +=
|
|
394
|
+
prompt += `<plan>\n${file.content}\n</plan>\n`;
|
|
368
395
|
} else {
|
|
369
|
-
prompt +=
|
|
396
|
+
prompt += `<file name="${file.name}" type="${file.type}">\n${file.content}\n</file>\n`;
|
|
370
397
|
}
|
|
371
398
|
}
|
|
399
|
+
prompt += '</context>\n';
|
|
372
400
|
}
|
|
401
|
+
|
|
402
|
+
prompt += '\n<instructions>\n';
|
|
373
403
|
if (hasPlan) {
|
|
374
|
-
prompt +=
|
|
404
|
+
prompt += 'Implement the changes described in the execution plan. Follow the plan step-by-step and make the necessary file modifications.\n';
|
|
375
405
|
} else {
|
|
376
|
-
prompt +=
|
|
406
|
+
prompt += 'Implement the changes described in the task. Make the necessary file modifications to complete the task.\n';
|
|
377
407
|
}
|
|
408
|
+
prompt += '</instructions>';
|
|
378
409
|
} catch (error) {
|
|
379
410
|
this.logger.debug('No supporting files found for execution', { taskId: task.id });
|
|
380
|
-
prompt +=
|
|
411
|
+
prompt += '\n<instructions>\n';
|
|
412
|
+
prompt += 'Implement the changes described in the task.\n';
|
|
413
|
+
prompt += '</instructions>';
|
|
381
414
|
}
|
|
415
|
+
|
|
382
416
|
return prompt;
|
|
383
417
|
}
|
|
384
418
|
}
|