@posthog/agent 2.3.616 → 2.3.643

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.
@@ -8809,7 +8809,7 @@ var import_zod3 = require("zod");
8809
8809
  // package.json
8810
8810
  var package_default = {
8811
8811
  name: "@posthog/agent",
8812
- version: "2.3.616",
8812
+ version: "2.3.643",
8813
8813
  repository: "https://github.com/PostHog/code",
8814
8814
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
8815
8815
  exports: {
@@ -13562,6 +13562,28 @@ var BaseAcpAgent = class {
13562
13562
  // src/adapters/claude/conversion/acp-to-sdk.ts
13563
13563
  var path5 = __toESM(require("path"), 1);
13564
13564
  var import_node_url = require("url");
13565
+ var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
13566
+ var COMMON_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
13567
+ "png",
13568
+ "jpg",
13569
+ "jpeg",
13570
+ "gif",
13571
+ "webp",
13572
+ "bmp",
13573
+ "svg",
13574
+ "heic",
13575
+ "tif",
13576
+ "tiff"
13577
+ ]);
13578
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
13579
+ "mp4",
13580
+ "mov",
13581
+ "webm",
13582
+ "mkv",
13583
+ "avi",
13584
+ "mpeg",
13585
+ "mpg"
13586
+ ]);
13565
13587
  function sdkText(value) {
13566
13588
  return { type: "text", text: value };
13567
13589
  }
@@ -13576,20 +13598,37 @@ function formatUriAsLink(uri) {
13576
13598
  return uri;
13577
13599
  }
13578
13600
  }
13579
- function formatFileAttachment(uri) {
13601
+ function readToolGuidanceForPath(filePath) {
13602
+ const ext = path5.extname(filePath).slice(1).toLowerCase();
13603
+ if (PDF_EXTENSIONS.has(ext)) {
13604
+ return 'Optional `pages` string (e.g. "1-5") per Read call instead of loading the entire PDF.';
13605
+ }
13606
+ if (COMMON_IMAGE_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext)) {
13607
+ return "Binary file \u2014 use Read with `file_path`; prefer bounded reads where supported.";
13608
+ }
13609
+ return "Large text \u2014 use multiple Read calls with optional `offset` and `limit`.";
13610
+ }
13611
+ function workspacePromptFromFileUri(uri) {
13580
13612
  try {
13581
13613
  const filePath = (0, import_node_url.fileURLToPath)(uri);
13582
13614
  const name2 = path5.basename(filePath) || filePath;
13583
13615
  return [
13584
- "Attached file available in the workspace:",
13585
- `- name: ${name2}`,
13586
- `- path: ${filePath}`,
13587
- "Use the available tools to inspect this file if needed."
13616
+ "Attached workspace file \u2014 use Read with required `file_path`:",
13617
+ `- file_path: ${filePath}`,
13618
+ `- name (context): ${name2}`,
13619
+ readToolGuidanceForPath(filePath)
13588
13620
  ].join("\n");
13589
13621
  } catch {
13590
- return `Attached file available at ${uri}`;
13622
+ return [
13623
+ "Attached file \u2014 decode path from URI, call Read with that path as `file_path`:",
13624
+ uri,
13625
+ 'Chunk PDFs with `pages` (e.g. "1-5"); long text with `offset`/`limit`.'
13626
+ ].join("\n");
13591
13627
  }
13592
13628
  }
13629
+ function isFileSchemeUri(uri) {
13630
+ return Boolean(uri?.startsWith("file://"));
13631
+ }
13593
13632
  function transformMcpCommand(text2) {
13594
13633
  const mcpMatch = text2.match(/^\/mcp:([^:\s]+):(\S+)(\s+.*)?$/);
13595
13634
  if (mcpMatch) {
@@ -13606,17 +13645,22 @@ function processPromptChunk(chunk, content, context) {
13606
13645
  case "resource_link":
13607
13646
  content.push(
13608
13647
  sdkText(
13609
- chunk.uri.startsWith("file://") ? formatFileAttachment(chunk.uri) : formatUriAsLink(chunk.uri)
13648
+ chunk.uri.startsWith("file://") ? workspacePromptFromFileUri(chunk.uri) : formatUriAsLink(chunk.uri)
13610
13649
  )
13611
13650
  );
13612
13651
  break;
13613
13652
  case "resource":
13614
13653
  if ("text" in chunk.resource) {
13615
- content.push(sdkText(formatUriAsLink(chunk.resource.uri)));
13654
+ const uri = chunk.resource.uri;
13655
+ if (uri != null && isFileSchemeUri(uri)) {
13656
+ content.push(sdkText(workspacePromptFromFileUri(uri)));
13657
+ break;
13658
+ }
13659
+ content.push(sdkText(formatUriAsLink(uri ?? "")));
13616
13660
  context.push(
13617
13661
  sdkText(
13618
13662
  `
13619
- <context ref="${chunk.resource.uri}">
13663
+ <context ref="${uri ?? ""}">
13620
13664
  ${chunk.resource.text}
13621
13665
  </context>`
13622
13666
  )
@@ -13638,6 +13682,8 @@ ${chunk.resource.text}
13638
13682
  type: "image",
13639
13683
  source: { type: "url", url: chunk.uri }
13640
13684
  });
13685
+ } else if (chunk.uri != null && isFileSchemeUri(chunk.uri)) {
13686
+ content.push(sdkText(workspacePromptFromFileUri(chunk.uri)));
13641
13687
  }
13642
13688
  break;
13643
13689
  default:
@@ -22486,9 +22532,14 @@ After completing the requested changes:
22486
22532
  1. Check out the existing PR branch with \`gh pr checkout ${prUrl}\`
22487
22533
  2. Stage and commit all changes with a clear commit message
22488
22534
  3. Push to the existing PR branch
22535
+ 4. For every PR review comment or review thread you addressed, treat the thread as done only after BOTH of these:
22536
+ - 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='...'\`.
22537
+ - 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>"\`.
22538
+ 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.
22489
22539
 
22490
22540
  Important:
22491
22541
  - Do NOT create a new branch or a new pull request.
22542
+ - Do NOT push fixes for review comments without replying to and resolving each related thread.
22492
22543
  ${attributionInstructions}
22493
22544
  `;
22494
22545
  }
@@ -22500,7 +22551,7 @@ When the user asks for code changes:
22500
22551
  When the user explicitly asks to clone or work in a GitHub repository:
22501
22552
  - Clone the repository into /tmp/workspace/repos/<owner>/<repo> using \`gh repo clone <owner>/<repo> /tmp/workspace/repos/<owner>/<repo>\`
22502
22553
  - Work from inside that cloned repository for follow-up code changes
22503
- - 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
22554
+ - 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.
22504
22555
  - Do NOT create branches, commits, push changes, or open pull requests unless the user explicitly asks for that`;
22505
22556
  return `
22506
22557
  # Cloud Task Execution \u2014 No Repository Mode
@@ -22540,7 +22591,11 @@ After completing the requested changes:
22540
22591
  1. Create a new branch prefixed with \`posthog-code/\` (e.g. \`posthog-code/fix-login-redirect\`) based on the work done
22541
22592
  2. Stage and commit all changes with a clear commit message
22542
22593
  3. Push the branch to origin
22543
- 4. Create a draft pull request using \`gh pr create --draft${this.config.baseBranch ? ` --base ${this.config.baseBranch}` : ""}\` with a descriptive title and body. Add the following footer at the end of the PR description:
22594
+ 4. Before opening the PR, prepare the body:
22595
+ - 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 \u2014 do NOT fall back to a generic Summary/Test plan format.
22596
+ - 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.
22597
+ - 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.
22598
+ 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:
22544
22599
  \`\`\`
22545
22600
  ---
22546
22601
  *Created with [PostHog Code](https://posthog.com/code?ref=pr)*