@posthog/agent 2.3.616 → 2.3.619
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 +1 -1
- 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 +12 -3
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +12 -3
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/server/agent-server.test.ts +17 -0
- package/src/server/agent-server.ts +11 -2
package/package.json
CHANGED
|
@@ -826,6 +826,9 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
826
826
|
"If the user explicitly asks you to open or update a pull request",
|
|
827
827
|
"open a draft pull request",
|
|
828
828
|
"unless the user explicitly asks",
|
|
829
|
+
".github/pull_request_template.md",
|
|
830
|
+
"gh issue list --search",
|
|
831
|
+
"Closes #<n>",
|
|
829
832
|
"Generated-By: PostHog Code",
|
|
830
833
|
"Task-Id: test-task-id",
|
|
831
834
|
],
|
|
@@ -868,6 +871,13 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
868
871
|
expect(prompt).toContain("Generated-By: PostHog Code");
|
|
869
872
|
expect(prompt).toContain("Task-Id: test-task-id");
|
|
870
873
|
expect(prompt).toContain("Created with [PostHog Code]");
|
|
874
|
+
// PR template detection (repo first, org `.github` fallback)
|
|
875
|
+
expect(prompt).toContain(".github/pull_request_template.md");
|
|
876
|
+
expect(prompt).toContain("org's `.github` repo");
|
|
877
|
+
// Related-issue linking
|
|
878
|
+
expect(prompt).toContain("gh issue list --state open --search");
|
|
879
|
+
expect(prompt).toContain("Closes #<n>");
|
|
880
|
+
expect(prompt).toContain("Refs #<n>");
|
|
871
881
|
delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;
|
|
872
882
|
});
|
|
873
883
|
|
|
@@ -895,6 +905,13 @@ describe("AgentServer HTTP Mode", () => {
|
|
|
895
905
|
);
|
|
896
906
|
expect(prompt).toContain("Push to the existing PR branch");
|
|
897
907
|
expect(prompt).not.toContain("Create a draft pull request");
|
|
908
|
+
// Review-comment thread handling: reply + resolve
|
|
909
|
+
expect(prompt).toContain("review thread");
|
|
910
|
+
expect(prompt).toContain("/pulls/{n}/comments/{id}/replies");
|
|
911
|
+
expect(prompt).toContain("resolveReviewThread");
|
|
912
|
+
expect(prompt).toContain(
|
|
913
|
+
"Do NOT push fixes for review comments without replying to and resolving each related thread.",
|
|
914
|
+
);
|
|
898
915
|
delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;
|
|
899
916
|
});
|
|
900
917
|
|
|
@@ -1643,9 +1643,14 @@ After completing the requested changes:
|
|
|
1643
1643
|
1. Check out the existing PR branch with \`gh pr checkout ${prUrl}\`
|
|
1644
1644
|
2. Stage and commit all changes with a clear commit message
|
|
1645
1645
|
3. Push to the existing PR branch
|
|
1646
|
+
4. For every PR review comment or review thread you addressed, treat the thread as done only after BOTH of these:
|
|
1647
|
+
- Reply on the thread with a short note describing what changed (reference the commit SHA when useful) using \`gh api -X POST /repos/{owner}/{repo}/pulls/{n}/comments/{id}/replies -f body='...'\`.
|
|
1648
|
+
- Resolve the thread via the \`resolveReviewThread\` GraphQL mutation: \`gh api graphql -f query='mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}' -f id="<thread-node-id>"\`.
|
|
1649
|
+
List unresolved threads first with \`gh api graphql -f query='{repository(owner:"<owner>",name:"<repo>"){pullRequest(number:<n>){reviewThreads(first:100){nodes{id isResolved comments(first:1){nodes{body}}}}}}}'\` so you can resolve each one you fixed.
|
|
1646
1650
|
|
|
1647
1651
|
Important:
|
|
1648
1652
|
- Do NOT create a new branch or a new pull request.
|
|
1653
|
+
- Do NOT push fixes for review comments without replying to and resolving each related thread.
|
|
1649
1654
|
${attributionInstructions}
|
|
1650
1655
|
`;
|
|
1651
1656
|
}
|
|
@@ -1661,7 +1666,7 @@ When the user asks for code changes:
|
|
|
1661
1666
|
When the user explicitly asks to clone or work in a GitHub repository:
|
|
1662
1667
|
- Clone the repository into /tmp/workspace/repos/<owner>/<repo> using \`gh repo clone <owner>/<repo> /tmp/workspace/repos/<owner>/<repo>\`
|
|
1663
1668
|
- Work from inside that cloned repository for follow-up code changes
|
|
1664
|
-
- 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
|
|
1669
|
+
- 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. Before opening the PR, check the cloned repo for a PR template at \`.github/pull_request_template.md\` (or variants; fall back to the org's \`.github\` repo via \`gh api\`) and use it as the body structure, and search for matching open issues with \`gh issue list --search\` to include \`Closes #<n>\` / \`Refs #<n>\` links.
|
|
1665
1670
|
- Do NOT create branches, commits, push changes, or open pull requests unless the user explicitly asks for that`;
|
|
1666
1671
|
|
|
1667
1672
|
return `
|
|
@@ -1704,7 +1709,11 @@ After completing the requested changes:
|
|
|
1704
1709
|
1. Create a new branch prefixed with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`) based on the work done
|
|
1705
1710
|
2. Stage and commit all changes with a clear commit message
|
|
1706
1711
|
3. Push the branch to origin
|
|
1707
|
-
4.
|
|
1712
|
+
4. Before opening the PR, prepare the body:
|
|
1713
|
+
- Check the repo for a PR template at \`.github/pull_request_template.md\` (also try \`.github/PULL_REQUEST_TEMPLATE.md\`, \`docs/pull_request_template.md\`, and root variants). If one exists, use its exact section headings as the PR body — do NOT fall back to a generic Summary/Test plan format.
|
|
1714
|
+
- If no repo-level template exists, check the org's \`.github\` repo via \`gh api /repos/<owner>/.github/contents/.github/pull_request_template.md\` (and other common paths) and use that as a fallback.
|
|
1715
|
+
- Search for matching open issues with \`gh issue list --state open --search '<keywords>'\` (derive keywords from the branch name, commits, and changed files; \`gh issue view <n>\` to confirm relevance). For every issue this PR would resolve, include a \`Closes #<n>\` line in the body so GitHub auto-links and auto-closes it on merge. For issues that are related but not fully resolved, use \`Refs #<n>\` instead.
|
|
1716
|
+
5. Create a draft pull request using \`gh pr create --draft${this.config.baseBranch ? ` --base ${this.config.baseBranch}` : ""}\` with a descriptive title and the body prepared above. Add the following footer at the end of the PR description:
|
|
1708
1717
|
\`\`\`
|
|
1709
1718
|
---
|
|
1710
1719
|
*Created with [PostHog Code](https://posthog.com/code?ref=pr)*
|