* feat(inline-comment): add confirmed param + probe-pattern safety net
Subagents that inherit this tool sometimes probe it with test comments
('Test comment to see if I can create inline comments') after hitting
unrelated errors elsewhere. Recurring issue across customer PRs.
Adds two defenses:
1. confirmed param: set true to post (final review comments should pass
this). When false, buffers to a JSONL file instead of posting.
2. Probe-pattern safety net: when confirmed is omitted (backward compat
for existing prompts), the body is checked against obvious probe
patterns ('test comment', 'can i', 'does this work', etc.). Matching
calls are buffered instead of posted.
A post-run step in action.yml reports the buffered call count and bodies
as a workflow warning for diagnostics.
Backward compatibility:
- Existing single-agent prompts (no confirmed param) post normally unless
the body happens to start with a probe phrase (unlikely for real
review comments)
- The code-review skill is being updated to pass confirmed: true in its
final posting step
- Subagent probes that would previously post now harmlessly buffer
* refactor: replace probe-regex with Haiku classification in post-step
The regex approach was narrow and could miss creative probe phrasings.
Replaced with a batch Haiku classification that runs after the session
completes.
Flow:
- MCP server: confirmed !== true -> buffer to JSONL (no classification
in-band, no latency in the tool path)
- Post-step (src/entrypoints/post-buffered-inline-comments.ts): reads
buffer, sends all bodies to a single Haiku call, posts only those
classified as real review comments
- confirmed=false entries are never posted regardless of classification
Fail-open: if ANTHROPIC_API_KEY is unavailable (Bedrock/Vertex users)
or the classification call fails, posts all unconfirmed comments. This
matches pre-PR behavior where all calls posted immediately.
The post-step emits :⚠️: for each filtered comment so users can
see what was dropped and why.
* feat: add classify_inline_comments opt-out input
New action input classify_inline_comments (default 'true'). Setting to
'false' restores pre-buffering behavior: all inline comment calls post
immediately regardless of the confirmed param.
Threads through: action input -> CLASSIFY_INLINE_COMMENTS env ->
context.inputs.classifyInlineComments -> MCP server env ->
CLASSIFY_ENABLED module const.
Post-step is also gated on the input so it skips entirely when
classification is disabled.
* docs: document classify_inline_comments input and confirmed param
- usage.md: add classify_inline_comments to inputs table
- solutions.md: mention confirmed=true in the prompt example and explain
buffering/classification in the tool permissions section
265 lines
7.9 KiB
TypeScript
265 lines
7.9 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { detectMode } from "../../src/modes/detector";
|
|
import type { GitHubContext } from "../../src/github/context";
|
|
|
|
describe("detectMode with enhanced routing", () => {
|
|
const baseContext = {
|
|
runId: "test-run",
|
|
eventAction: "opened",
|
|
repository: {
|
|
owner: "test-owner",
|
|
repo: "test-repo",
|
|
full_name: "test-owner/test-repo",
|
|
},
|
|
actor: "test-user",
|
|
inputs: {
|
|
prompt: "",
|
|
triggerPhrase: "@claude",
|
|
assigneeTrigger: "",
|
|
labelTrigger: "",
|
|
branchPrefix: "claude/",
|
|
useStickyComment: false,
|
|
classifyInlineComments: true,
|
|
useCommitSigning: false,
|
|
sshSigningKey: "",
|
|
botId: "123456",
|
|
botName: "claude-bot",
|
|
allowedBots: "",
|
|
allowedNonWriteUsers: "",
|
|
trackProgress: false,
|
|
includeFixLinks: true,
|
|
includeCommentsByActor: "",
|
|
excludeCommentsByActor: "",
|
|
},
|
|
};
|
|
|
|
describe("PR Events with track_progress", () => {
|
|
it("should use tag mode when track_progress is true for pull_request.opened", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "pull_request",
|
|
eventAction: "opened",
|
|
payload: { pull_request: { number: 1 } } as any,
|
|
entityNumber: 1,
|
|
isPR: true,
|
|
inputs: { ...baseContext.inputs, trackProgress: true },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
|
|
it("should use tag mode when track_progress is true for pull_request.synchronize", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "pull_request",
|
|
eventAction: "synchronize",
|
|
payload: { pull_request: { number: 1 } } as any,
|
|
entityNumber: 1,
|
|
isPR: true,
|
|
inputs: { ...baseContext.inputs, trackProgress: true },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
|
|
it("should use agent mode when track_progress is false for pull_request.opened", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "pull_request",
|
|
eventAction: "opened",
|
|
payload: { pull_request: { number: 1 } } as any,
|
|
entityNumber: 1,
|
|
isPR: true,
|
|
inputs: { ...baseContext.inputs, trackProgress: false },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("agent");
|
|
});
|
|
|
|
it("should throw error when track_progress is used with unsupported PR action", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "pull_request",
|
|
eventAction: "closed",
|
|
payload: { pull_request: { number: 1 } } as any,
|
|
entityNumber: 1,
|
|
isPR: true,
|
|
inputs: { ...baseContext.inputs, trackProgress: true },
|
|
};
|
|
|
|
expect(() => detectMode(context)).toThrow(
|
|
/track_progress for pull_request events is only supported for actions/,
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("Issue Events with track_progress", () => {
|
|
it("should use tag mode when track_progress is true for issues.opened", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issues",
|
|
eventAction: "opened",
|
|
payload: { issue: { number: 1, body: "Test" } } as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
inputs: { ...baseContext.inputs, trackProgress: true },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
|
|
it("should use agent mode when track_progress is false for issues", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issues",
|
|
eventAction: "opened",
|
|
payload: { issue: { number: 1, body: "Test" } } as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
inputs: { ...baseContext.inputs, trackProgress: false },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("agent");
|
|
});
|
|
|
|
it("should use agent mode for issues with explicit prompt", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issues",
|
|
eventAction: "opened",
|
|
payload: { issue: { number: 1, body: "Test issue" } } as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
inputs: { ...baseContext.inputs, prompt: "Analyze this issue" },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("agent");
|
|
});
|
|
|
|
it("should use tag mode for issues with @claude mention and no prompt", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issues",
|
|
eventAction: "opened",
|
|
payload: { issue: { number: 1, body: "@claude help" } } as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
});
|
|
|
|
describe("Comment Events (unchanged behavior)", () => {
|
|
it("should use tag mode for issue_comment with @claude mention", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issue_comment",
|
|
payload: {
|
|
issue: { number: 1, body: "Test" },
|
|
comment: { body: "@claude help" },
|
|
} as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
|
|
it("should use agent mode for issue_comment with prompt provided", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issue_comment",
|
|
payload: {
|
|
issue: { number: 1, body: "Test" },
|
|
comment: { body: "@claude help" },
|
|
} as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
inputs: { ...baseContext.inputs, prompt: "Review this PR" },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("agent");
|
|
});
|
|
|
|
it("should use tag mode for PR review comments with @claude mention", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "pull_request_review_comment",
|
|
payload: {
|
|
pull_request: { number: 1, body: "Test" },
|
|
comment: { body: "@claude check this" },
|
|
} as any,
|
|
entityNumber: 1,
|
|
isPR: true,
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
});
|
|
|
|
describe("Automation Events (should error with track_progress)", () => {
|
|
it("should throw error when track_progress is used with workflow_dispatch", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "workflow_dispatch",
|
|
payload: {} as any,
|
|
inputs: { ...baseContext.inputs, trackProgress: true },
|
|
};
|
|
|
|
expect(() => detectMode(context)).toThrow(
|
|
/track_progress is only supported /,
|
|
);
|
|
});
|
|
|
|
it("should use agent mode for workflow_dispatch without track_progress", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "workflow_dispatch",
|
|
payload: {} as any,
|
|
inputs: { ...baseContext.inputs, prompt: "Run workflow" },
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("agent");
|
|
});
|
|
});
|
|
|
|
describe("Custom prompt injection in tag mode", () => {
|
|
it("should use tag mode for PR events when both track_progress and prompt are provided", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "pull_request",
|
|
eventAction: "opened",
|
|
payload: { pull_request: { number: 1 } } as any,
|
|
entityNumber: 1,
|
|
isPR: true,
|
|
inputs: {
|
|
...baseContext.inputs,
|
|
trackProgress: true,
|
|
prompt: "Review for security issues",
|
|
},
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
|
|
it("should use tag mode for issue events when both track_progress and prompt are provided", () => {
|
|
const context: GitHubContext = {
|
|
...baseContext,
|
|
eventName: "issues",
|
|
eventAction: "opened",
|
|
payload: { issue: { number: 1, body: "Test" } } as any,
|
|
entityNumber: 1,
|
|
isPR: false,
|
|
inputs: {
|
|
...baseContext.inputs,
|
|
trackProgress: true,
|
|
prompt: "Analyze this issue",
|
|
},
|
|
};
|
|
|
|
expect(detectMode(context)).toBe("tag");
|
|
});
|
|
});
|
|
});
|