@posthog/agent 2.3.502 → 2.3.507
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/agent.js +2 -2
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +14 -4
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +14 -4
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/claude/session/options.ts +1 -1
- package/src/server/agent-server.test.ts +43 -0
- package/src/server/agent-server.ts +16 -2
package/package.json
CHANGED
|
@@ -154,7 +154,7 @@ function buildHooks(
|
|
|
154
154
|
const PH_EXPLORE_AGENT: NonNullable<Options["agents"]>[string] = {
|
|
155
155
|
description:
|
|
156
156
|
'Fast agent for exploring and understanding codebases. Use this when you need to find files by pattern (eg. "src/components/**/*.tsx"), search for code or keywords (eg. "where is the auth middleware?"), or answer questions about how the codebase works (eg. "how does the session service handle reconnects?"). When calling this agent, specify a thoroughness level: "quick" for targeted lookups, "medium" for broader exploration, or "very thorough" for comprehensive analysis across multiple locations.',
|
|
157
|
-
model: "
|
|
157
|
+
model: "sonnet",
|
|
158
158
|
prompt: `You are a fast, read-only codebase exploration agent.
|
|
159
159
|
|
|
160
160
|
Your job is to find files, search code, read the most relevant sources, and report findings clearly.
|
|
@@ -639,6 +639,49 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
639
639
|
expect(prompt).toContain("stop with local changes ready for review");
|
|
640
640
|
});
|
|
641
641
|
|
|
642
|
+
it.each([
|
|
643
|
+
{
|
|
644
|
+
label: "createPr unset",
|
|
645
|
+
config: { repositoryPath: undefined },
|
|
646
|
+
shouldContain: [
|
|
647
|
+
"Cloud Task Execution — No Repository Mode",
|
|
648
|
+
"Clone the repository into /tmp/workspace/repos/<owner>/<repo>",
|
|
649
|
+
"gh repo clone <owner>/<repo> /tmp/workspace/repos/<owner>/<repo>",
|
|
650
|
+
"If the user explicitly asks you to open or update a pull request",
|
|
651
|
+
"open a draft pull request",
|
|
652
|
+
"unless the user explicitly asks",
|
|
653
|
+
"Generated-By: PostHog Code",
|
|
654
|
+
"Task-Id: test-task-id",
|
|
655
|
+
],
|
|
656
|
+
shouldNotContain: [],
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
label: "createPr false",
|
|
660
|
+
config: { repositoryPath: undefined, createPr: false },
|
|
661
|
+
shouldContain: [
|
|
662
|
+
"Cloud Task Execution — No Repository Mode",
|
|
663
|
+
"You may clone a repository and make local edits in that clone",
|
|
664
|
+
"Do NOT create branches, commits, push changes, or open pull requests in this run",
|
|
665
|
+
],
|
|
666
|
+
shouldNotContain: ["open a draft pull request", "gh pr create --draft"],
|
|
667
|
+
},
|
|
668
|
+
])(
|
|
669
|
+
"returns no-repository prompt for $label",
|
|
670
|
+
({ config, shouldContain, shouldNotContain }) => {
|
|
671
|
+
const s = createServer(config);
|
|
672
|
+
const prompt = (
|
|
673
|
+
s as unknown as TestableServer
|
|
674
|
+
).buildCloudSystemPrompt();
|
|
675
|
+
|
|
676
|
+
for (const text of shouldContain) {
|
|
677
|
+
expect(prompt).toContain(text);
|
|
678
|
+
}
|
|
679
|
+
for (const text of shouldNotContain) {
|
|
680
|
+
expect(prompt).not.toContain(text);
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
);
|
|
684
|
+
|
|
642
685
|
it("returns auto-PR prompt for Slack-origin runs", () => {
|
|
643
686
|
process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "slack";
|
|
644
687
|
const s = createServer();
|
|
@@ -1605,6 +1605,19 @@ ${attributionInstructions}
|
|
|
1605
1605
|
}
|
|
1606
1606
|
|
|
1607
1607
|
if (!this.config.repositoryPath) {
|
|
1608
|
+
const publishInstructions =
|
|
1609
|
+
this.config.createPr === false
|
|
1610
|
+
? `
|
|
1611
|
+
When the user asks for code changes:
|
|
1612
|
+
- You may clone a repository and make local edits in that clone
|
|
1613
|
+
- Do NOT create branches, commits, push changes, or open pull requests in this run`
|
|
1614
|
+
: `
|
|
1615
|
+
When the user explicitly asks to clone or work in a GitHub repository:
|
|
1616
|
+
- Clone the repository into /tmp/workspace/repos/<owner>/<repo> using \`gh repo clone <owner>/<repo> /tmp/workspace/repos/<owner>/<repo>\`
|
|
1617
|
+
- Work from inside that cloned repository for follow-up code changes
|
|
1618
|
+
- If the user explicitly asks you to open or update a pull request, create a branch, commit the requested changes, push it, and open a draft pull request from inside the clone
|
|
1619
|
+
- Do NOT create branches, commits, push changes, or open pull requests unless the user explicitly asks for that`;
|
|
1620
|
+
|
|
1608
1621
|
return `
|
|
1609
1622
|
# Cloud Task Execution — No Repository Mode
|
|
1610
1623
|
|
|
@@ -1617,11 +1630,12 @@ When the user asks about analytics, data, metrics, events, funnels, dashboards,
|
|
|
1617
1630
|
|
|
1618
1631
|
When the user asks for code changes or software engineering tasks:
|
|
1619
1632
|
- Let them know you can help but don't have a repository connected for this session
|
|
1620
|
-
-
|
|
1633
|
+
- If they have not specified a repository to clone, offer to write code snippets, scripts, or provide guidance
|
|
1634
|
+
${publishInstructions}
|
|
1621
1635
|
|
|
1622
1636
|
Important:
|
|
1623
|
-
- Do NOT create branches, commits, or pull requests in this mode.
|
|
1624
1637
|
- Prefer using MCP tools to answer questions with real data over giving generic advice.
|
|
1638
|
+
${attributionInstructions}
|
|
1625
1639
|
`;
|
|
1626
1640
|
}
|
|
1627
1641
|
|