From 37a9ff6b88453ff01dc84afe5f9c0b3407f7e23b Mon Sep 17 00:00:00 2001 From: dbpolito Date: Thu, 25 Jun 2026 16:07:19 -0300 Subject: [PATCH] refactor: remove PR branch alignment component - remove the bundled align-pr-branch component from config and schema - inline required PR checkout guidance for pr/fix - load pr/review changes directly from the PR head ref without checkout - update tests, generated OpenCode output, and component docs --- kompass.jsonc | 1 - kompass.schema.json | 7 ++----- packages/core/commands/pr/fix.md | 6 +++++- packages/core/commands/pr/review.md | 8 ++------ packages/core/components/align-pr-branch.md | 18 ------------------ packages/core/kompass.jsonc | 1 - packages/core/lib/config.ts | 3 --- packages/core/test/commands.test.ts | 18 +++++++++--------- packages/opencode/.opencode/commands/pr/fix.md | 11 ++++------- .../opencode/.opencode/commands/pr/review.md | 15 ++------------- packages/opencode/kompass.jsonc | 1 - .../reference/components/align-pr-branch.mdx | 12 ------------ .../docs/docs/reference/components/index.mdx | 5 ----- 13 files changed, 24 insertions(+), 82 deletions(-) delete mode 100644 packages/core/components/align-pr-branch.md delete mode 100644 packages/web/src/content/docs/docs/reference/components/align-pr-branch.mdx diff --git a/kompass.jsonc b/kompass.jsonc index 9cad009..664c0df 100644 --- a/kompass.jsonc +++ b/kompass.jsonc @@ -51,7 +51,6 @@ }, "components": { - "align-pr-branch": { "enabled": true }, "change-summary": { "enabled": true }, "changes-summary": { "enabled": true }, "commit": { "enabled": true }, diff --git a/kompass.schema.json b/kompass.schema.json index a1811dd..f44e721 100644 --- a/kompass.schema.json +++ b/kompass.schema.json @@ -215,9 +215,6 @@ "type": "object", "additionalProperties": false, "properties": { - "align-pr-branch": { - "$ref": "#/$defs/componentConfig" - }, "change-summary": { "$ref": "#/$defs/componentConfig" }, @@ -246,7 +243,7 @@ "type": "array", "items": { "type": "string", - "enum": ["align-pr-branch", "change-summary", "changes-summary", "commit", "dev-flow", "load-pr", "load-ticket", "skill-authoring", "summarize-changes"] + "enum": ["change-summary", "changes-summary", "commit", "dev-flow", "load-pr", "load-ticket", "skill-authoring", "summarize-changes"] }, "uniqueItems": true, "deprecated": true @@ -254,7 +251,7 @@ "paths": { "type": "object", "propertyNames": { - "enum": ["align-pr-branch", "change-summary", "changes-summary", "commit", "dev-flow", "load-pr", "load-ticket", "skill-authoring", "summarize-changes"] + "enum": ["change-summary", "changes-summary", "commit", "dev-flow", "load-pr", "load-ticket", "skill-authoring", "summarize-changes"] }, "additionalProperties": { "type": "string" diff --git a/packages/core/commands/pr/fix.md b/packages/core/commands/pr/fix.md index e8913d1..33f2efc 100644 --- a/packages/core/commands/pr/fix.md +++ b/packages/core/commands/pr/fix.md @@ -30,7 +30,11 @@ $ARGUMENTS ### Align Local Branch -<%~ include("@align-pr-branch", { action: "analyzing repository files or making code changes for this PR", scope: "inspect or modify local code for this PR", requiresBranch: true }) -%> +- If `` is unavailable, STOP and report that the PR head branch could not be determined +- Run `gh pr checkout ` before analyzing repository files or making code changes for this PR +- After checkout, store the active branch as `` +- If checkout fails or times out, STOP and report that the PR branch could not be checked out locally; do not retry checkout unless the user explicitly asks +- Do not inspect or modify local code for this PR until `` equals `` ### Load Changes diff --git a/packages/core/commands/pr/review.md b/packages/core/commands/pr/review.md index 6c7fb91..cda1a1d 100644 --- a/packages/core/commands/pr/review.md +++ b/packages/core/commands/pr/review.md @@ -24,10 +24,6 @@ $ARGUMENTS <%~ include("@load-pr", { config: it.config, ref: "", result: "" }) %> -### Align Local Branch - -<%~ include("@align-pr-branch", { action: "inspecting local repository files for this PR review", scope: "inspect local repository code for this PR", requiresBranch: false }) -%> - ### Load Ticket Context If `` links to exactly one clear ticket: @@ -37,13 +33,13 @@ If `` links to exactly one clear ticket: ### Load Changes -Call `<%= it.config.tools.changes_load.name %>` with `base: `, `head: `, and `depthHint: ` only when it is a positive integer. Store as ``. +Call `<%= it.config.tools.changes_load.name %>` with `base: `, `head: `, and `depthHint: ` only when it is a positive integer. Store as ``. ### Review Changes Following the reviewer agent guidance: 1. Check ``, ``, and `` -2. Use `` whenever local repository files need to be inspected alongside the diff +2. Use `` as the source of truth for changed files and diff hunks 3. Derive `` from `` and ``: - Include direct author replies that explicitly decline, defer, or intentionally narrow a suggestion and explain why they do not plan to implement it - Treat each matching author reply as higher priority than `` for that same concern, unless the current diff introduces a materially different defect with a concrete failure mode diff --git a/packages/core/components/align-pr-branch.md b/packages/core/components/align-pr-branch.md deleted file mode 100644 index b05385e..0000000 --- a/packages/core/components/align-pr-branch.md +++ /dev/null @@ -1,18 +0,0 @@ -- If `` is unavailable, STOP and report that the PR head branch could not be determined -<% if (it.requiresBranch) { -%> -- If `` equals `` and `` equals ``, store `` as `` and do not checkout again -- If `` differs from `` or `` differs from ``: - - Run `gh pr checkout ` before <%= it.action %> - - After checkout, store the active branch as `` - - Run `git rev-parse HEAD` again and store the trimmed result as `` - - If checkout fails or times out, STOP and report that the PR branch could not be checked out locally; do not retry checkout unless the user explicitly asks -- Do not <%= it.scope %> until `` equals `` and `` equals `` -<% } else { -%> -- If `` equals ``, store `` as `` when `` is available; otherwise store `` as ``. Do not checkout because the worktree is already at the PR head commit. -- If `` differs from ``: - - Run `gh pr checkout ` before <%= it.action %> - - After checkout, store the active branch as `` - - Run `git rev-parse HEAD` again and store the trimmed result as `` - - If checkout fails or times out, STOP and report that the PR branch could not be checked out locally; do not retry checkout unless the user explicitly asks -- Do not <%= it.scope %> until `` equals `` -<% } -%> diff --git a/packages/core/kompass.jsonc b/packages/core/kompass.jsonc index 9cad009..664c0df 100644 --- a/packages/core/kompass.jsonc +++ b/packages/core/kompass.jsonc @@ -51,7 +51,6 @@ }, "components": { - "align-pr-branch": { "enabled": true }, "change-summary": { "enabled": true }, "changes-summary": { "enabled": true }, "commit": { "enabled": true }, diff --git a/packages/core/lib/config.ts b/packages/core/lib/config.ts index 3f29cca..3990717 100644 --- a/packages/core/lib/config.ts +++ b/packages/core/lib/config.ts @@ -49,7 +49,6 @@ export const DEFAULT_COMMAND_NAMES = [ export const DEFAULT_AGENT_NAMES = ["worker", "navigator", "planner", "reviewer"] as const; export const DEFAULT_COMPONENT_NAMES = [ - "align-pr-branch", "change-summary", "changes-summary", "commit", @@ -132,7 +131,6 @@ export interface KompassConfig { ticket_load?: ToolConfig; }; components?: { - "align-pr-branch"?: ComponentConfig; "change-summary"?: ComponentConfig; "changes-summary"?: ComponentConfig; commit?: ComponentConfig; @@ -447,7 +445,6 @@ const defaultAgentPlanner: AgentDefinition = { }; const defaultComponentPaths: Record = { - "align-pr-branch": "components/align-pr-branch.md", "change-summary": "components/change-summary.md", "changes-summary": "components/changes-summary.md", "commit": "components/commit.md", diff --git a/packages/core/test/commands.test.ts b/packages/core/test/commands.test.ts index 0fa8290..c8a87d1 100644 --- a/packages/core/test/commands.test.ts +++ b/packages/core/test/commands.test.ts @@ -14,22 +14,22 @@ describe("resolveCommands", () => { assert.deepEqual(commands["pr/review"]?.config, { enabled: true }); }); - test("skips PR checkout when pr/review is already at PR head", async () => { + test("loads pr/review changes without checking out the PR branch", async () => { const commands = await resolveCommands(process.cwd()); const template = commands["pr/review"]?.template ?? ""; - assert.match(template, /git rev-parse HEAD/); - assert.match(template, /`` equals ``/); - assert.match(template, /Run `gh pr checkout `/); - assert.match(template, /do not retry checkout unless the user explicitly asks/); + assert.match(template, /head: /); + assert.match(template, /Use `` as the source of truth/); + assert.doesNotMatch(template, /Run `gh pr checkout `/); + assert.doesNotMatch(template, //); }); - test("requires PR branch for pr/fix checkout alignment", async () => { + test("requires PR branch checkout for pr/fix", async () => { const commands = await resolveCommands(process.cwd()); const template = commands["pr/fix"]?.template ?? ""; - assert.match(template, /`` equals `` and `` equals ``/); - assert.match(template, /`` differs from `` or `` differs from ``/); - assert.match(template, /Do not inspect or modify local code for this PR until `` equals `` and `` equals ``/); + assert.match(template, /Run `gh pr checkout ` before analyzing repository files or making code changes for this PR/); + assert.match(template, /Do not inspect or modify local code for this PR until `` equals ``/); + assert.doesNotMatch(template, /`` differs from `` or `` differs from ``/); }); }); diff --git a/packages/opencode/.opencode/commands/pr/fix.md b/packages/opencode/.opencode/commands/pr/fix.md index ab03e0c..42945b0 100644 --- a/packages/opencode/.opencode/commands/pr/fix.md +++ b/packages/opencode/.opencode/commands/pr/fix.md @@ -46,13 +46,10 @@ $ARGUMENTS ### Align Local Branch - If `` is unavailable, STOP and report that the PR head branch could not be determined -- If `` equals `` and `` equals ``, store `` as `` and do not checkout again -- If `` differs from `` or `` differs from ``: - - Run `gh pr checkout ` before analyzing repository files or making code changes for this PR - - After checkout, store the active branch as `` - - Run `git rev-parse HEAD` again and store the trimmed result as `` - - If checkout fails or times out, STOP and report that the PR branch could not be checked out locally; do not retry checkout unless the user explicitly asks -- Do not inspect or modify local code for this PR until `` equals `` and `` equals `` +- Run `gh pr checkout ` before analyzing repository files or making code changes for this PR +- After checkout, store the active branch as `` +- If checkout fails or times out, STOP and report that the PR branch could not be checked out locally; do not retry checkout unless the user explicitly asks +- Do not inspect or modify local code for this PR until `` equals `` ### Load Changes diff --git a/packages/opencode/.opencode/commands/pr/review.md b/packages/opencode/.opencode/commands/pr/review.md index 59351c0..be3ec43 100644 --- a/packages/opencode/.opencode/commands/pr/review.md +++ b/packages/opencode/.opencode/commands/pr/review.md @@ -39,17 +39,6 @@ $ARGUMENTS - Review attached images, screenshots, videos, PDFs, and other linked files whenever they can affect the requested fix, review outcome, reproduction steps, or acceptance criteria - If any relevant attachment cannot be accessed, note that gap and continue only when the remaining PR context is still sufficient to proceed reliably -### Align Local Branch - -- If `` is unavailable, STOP and report that the PR head branch could not be determined -- If `` equals ``, store `` as `` when `` is available; otherwise store `` as ``. Do not checkout because the worktree is already at the PR head commit. -- If `` differs from ``: - - Run `gh pr checkout ` before inspecting local repository files for this PR review - - After checkout, store the active branch as `` - - Run `git rev-parse HEAD` again and store the trimmed result as `` - - If checkout fails or times out, STOP and report that the PR branch could not be checked out locally; do not retry checkout unless the user explicitly asks -- Do not inspect local repository code for this PR until `` equals `` - ### Load Ticket Context If `` links to exactly one clear ticket: @@ -63,13 +52,13 @@ If `` links to exactly one clear ticket: ### Load Changes -Call `kompass_changes_load` with `base: `, `head: `, and `depthHint: ` only when it is a positive integer. Store as ``. +Call `kompass_changes_load` with `base: `, `head: `, and `depthHint: ` only when it is a positive integer. Store as ``. ### Review Changes Following the reviewer agent guidance: 1. Check ``, ``, and `` -2. Use `` whenever local repository files need to be inspected alongside the diff +2. Use `` as the source of truth for changed files and diff hunks 3. Derive `` from `` and ``: - Include direct author replies that explicitly decline, defer, or intentionally narrow a suggestion and explain why they do not plan to implement it - Treat each matching author reply as higher priority than `` for that same concern, unless the current diff introduces a materially different defect with a concrete failure mode diff --git a/packages/opencode/kompass.jsonc b/packages/opencode/kompass.jsonc index 9cad009..664c0df 100644 --- a/packages/opencode/kompass.jsonc +++ b/packages/opencode/kompass.jsonc @@ -51,7 +51,6 @@ }, "components": { - "align-pr-branch": { "enabled": true }, "change-summary": { "enabled": true }, "changes-summary": { "enabled": true }, "commit": { "enabled": true }, diff --git a/packages/web/src/content/docs/docs/reference/components/align-pr-branch.mdx b/packages/web/src/content/docs/docs/reference/components/align-pr-branch.mdx deleted file mode 100644 index ab4d956..0000000 --- a/packages/web/src/content/docs/docs/reference/components/align-pr-branch.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: align-pr-branch -description: Shared partial for aligning PR-scoped commands to the pull request branch. ---- - -## Behavior - -- requires the caller to provide `` -- runs `gh pr checkout ` before local PR analysis or edits -- stores the active branch as `` after checkout -- stops if checkout fails or if the active branch does not match `` -- accepts caller-provided wording through `it.action` and `it.scope` diff --git a/packages/web/src/content/docs/docs/reference/components/index.mdx b/packages/web/src/content/docs/docs/reference/components/index.mdx index faf18d1..b756ad4 100644 --- a/packages/web/src/content/docs/docs/reference/components/index.mdx +++ b/packages/web/src/content/docs/docs/reference/components/index.mdx @@ -7,7 +7,6 @@ Kompass command templates can include reusable Eta partials from `packages/core/ Bundled components: -- `align-pr-branch` - `change-summary` - `changes-summary` - `commit` @@ -19,10 +18,6 @@ Bundled components: ## Bundled components -### `align-pr-branch` - -Guides PR-scoped commands to switch onto the PR head branch with `gh pr checkout`, capture the active branch, and stop if local work is not aligned to the PR branch. - ### `change-summary` Loads changes with `changes_load`, analyzes file-level diffs, and groups the work into concise what/why themes.