Commit Graph

203 Commits

Author SHA1 Message Date
km-anthropic
624adc1976 specify the type 2025-07-29 14:48:49 -07:00
km-anthropic
8207a5f128 bun format 2025-07-29 14:40:48 -07:00
km-anthropic
aaae231799 refactor: further simplify discriminated union implementation
- Add event name constants to reduce duplication
- Derive EntityEventName and AutomationEventName types from constants
- Use isAutomationContext consistently in agent mode and registry
- Simplify parseGitHubContext by removing redundant type assertions
- Extract payload casts to variables for cleaner code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 14:40:05 -07:00
km-anthropic
68e711968d some structural simplification 2025-07-29 14:32:28 -07:00
km-anthropic
5bdfd090e0 refactor: improve discriminated union implementation based on review feedback
- Use eventName checks instead of 'in' operator for more robust type guards
- Remove unnecessary type assertions - TypeScript's control flow analysis works correctly
- Remove redundant runtime checks for entityNumber and isPR
- Simplify code by using context directly after type guard

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 13:26:35 -07:00
km-anthropic
9c8ca262b6 More robust type checking 2025-07-29 13:21:58 -07:00
km-anthropic
21680fe730 update comment 2025-07-29 13:16:09 -07:00
km-anthropic
b1033b2ba1 refactor: implement discriminated unions for GitHub contexts
Split ParsedGitHubContext into entity-specific and automation contexts:
- ParsedGitHubContext: For entity events (issues/PRs) with required entityNumber and isPR
- AutomationContext: For workflow_dispatch/schedule events without entity fields
- GitHubContext: Union type for all contexts

This eliminates ~20 null checks throughout the codebase and provides better type safety.
Entity-specific code paths are now guaranteed to have the required fields.

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 13:09:01 -07:00
km-anthropic
f1ce8b3d62 Merge branch 'main' of https://github.com/anthropics/claude-code-action into km/add-workflow-dispatch-schedule-support 2025-07-29 11:55:20 -07:00
km-anthropic
ec0e9b4f87 add schedule & workflow dispatch paths. Also make prepare logic conditional (#353)
* feat: add agent mode for automation scenarios

- Add agent mode that always triggers without checking for mentions
- Implement Mode interface with support for mode-specific tool configuration
- Add getAllowedTools() and getDisallowedTools() methods to Mode interface
- Simplify tests by combining related test cases
- Update documentation and examples to include agent mode
- Fix TypeScript imports to prevent circular dependencies

Agent mode is designed for automation and workflow_dispatch scenarios
where Claude should always run without requiring trigger phrases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Minor update to readme (from @main to @beta)

* Since workflow_dispatch isn't in the base action, update the examples accordingly

* minor formatting issue

* Update to say beta instead of main

* Fix missed tracking comment to be false

* add schedule & workflow dispatch paths. Also make prepare logic conditional

* tests

* Add test workflow for workflow_dispatch functionality

* Update workflow to use correct branch reference

* remove test workflow dispatch file

* minor lint update

* update workflow dispatch agent example

* minor lint update

* refactor: simplify prepare logic with mode-specific implementations

* ensure tag mode can't work with workflow dispatch and schedule tasks

* simplify: remove workflow_dispatch/schedule from create-prompt

- Remove workflow_dispatch and schedule event handling from create-prompt
  since agent mode doesn't use the standard prompt generation flow
- Enforce mode compatibility at selection time in the registry instead
  of runtime validation in tag mode
- Add explanatory comment in agent mode about why prompt file is needed
- Update tests to reflect simplified event handling

This reduces code duplication and makes the separation between tag mode
(entity-based events) and agent mode (automation events) clearer.

* simplify PR by making agent mode only work with workflow dispatch and schedule events

* remove unnecessary changes

* remove unnecessary changes from PR

- Revert update-comment-link.ts changes (agent mode doesn't use this)
- Revert create-initial.ts changes (agent mode doesn't create comments)
- Remove unused default-branch.ts file
- Revert install-mcp-server.ts changes (agent mode uses minimal MCP)

These files are only used by tag mode for entity-based events, not needed
for workflow_dispatch/schedule support via agent mode.

* fix: handle optional entityNumber for TypeScript

- Add runtime checks in files that require entityNumber
- These files are only used by tag mode which always has entityNumber
- Agent mode (workflow_dispatch/schedule) doesn't use these files

* linting update

---------

Co-authored-by: km-anthropic <km-anthropic@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-07-29 11:52:45 -07:00
Ashwin Bhat
af32fd318a Revert "feat: add GITHUB_HOST to github-mcp-server for GitHub Enterprise Serv…" (#359)
This reverts commit e07ea013bd.
v0.0.48
2025-07-29 11:51:20 -07:00
km-anthropic
5146c656e8 linting update 2025-07-29 11:16:51 -07:00
km-anthropic
5da8dc78e6 fix: handle optional entityNumber for TypeScript
- Add runtime checks in files that require entityNumber
- These files are only used by tag mode which always has entityNumber
- Agent mode (workflow_dispatch/schedule) doesn't use these files
2025-07-29 11:16:09 -07:00
km-anthropic
1c2e7e788d Merge branch 'main' of https://github.com/anthropics/claude-code-action into km/add-workflow-dispatch-schedule-support 2025-07-29 11:08:07 -07:00
km-anthropic
b85d457dc6 remove unnecessary changes from PR
- Revert update-comment-link.ts changes (agent mode doesn't use this)
- Revert create-initial.ts changes (agent mode doesn't create comments)
- Remove unused default-branch.ts file
- Revert install-mcp-server.ts changes (agent mode uses minimal MCP)

These files are only used by tag mode for entity-based events, not needed
for workflow_dispatch/schedule support via agent mode.
2025-07-29 11:06:24 -07:00
km-anthropic
3ebb5202a2 remove unnecessary changes 2025-07-29 11:01:38 -07:00
km-anthropic
3402c5355d simplify PR by making agent mode only work with workflow dispatch and schedule events 2025-07-29 10:46:44 -07:00
km-anthropic
26d6ecc65d simplify: remove workflow_dispatch/schedule from create-prompt
- Remove workflow_dispatch and schedule event handling from create-prompt
  since agent mode doesn't use the standard prompt generation flow
- Enforce mode compatibility at selection time in the registry instead
  of runtime validation in tag mode
- Add explanatory comment in agent mode about why prompt file is needed
- Update tests to reflect simplified event handling

This reduces code duplication and makes the separation between tag mode
(entity-based events) and agent mode (automation events) clearer.
2025-07-29 10:15:22 -07:00
km-anthropic
859e93f18e ensure tag mode can't work with workflow dispatch and schedule tasks 2025-07-29 09:38:00 -07:00
km-anthropic
96970dfa2d refactor: simplify prepare logic with mode-specific implementations 2025-07-29 08:56:26 -07:00
YutaSaito
e07ea013bd feat: add GITHUB_HOST to github-mcp-server for GitHub Enterprise Server (#343) v0.0.47 2025-07-28 17:39:52 -07:00
aki77
6037d754ac chore: update MCP server image to version 0.9.0 (#344) v0.0.46 2025-07-28 16:20:59 -07:00
GitHub Actions
04b2df22d4 chore: bump Claude Code version to 1.0.62 2025-07-28 22:36:23 +00:00
km-anthropic
11d4e4c175 minor lint update 2025-07-28 12:28:57 -07:00
km-anthropic
bde5e40caf update workflow dispatch agent example 2025-07-28 12:27:05 -07:00
km-anthropic
6dbeb928d1 minor lint update 2025-07-28 12:21:12 -07:00
km-anthropic
cc8c99b7b4 Merge branch 'main' of https://github.com/anthropics/claude-code-action into km/add-workflow-dispatch-schedule-support 2025-07-28 12:19:37 -07:00
km-anthropic
aa2ef8067e remove test workflow dispatch file 2025-07-28 12:03:45 -07:00
km-anthropic
a433016152 Update workflow to use correct branch reference 2025-07-28 11:53:48 -07:00
km-anthropic
7a53e0529b Add test workflow for workflow_dispatch functionality 2025-07-28 11:52:52 -07:00
km-anthropic
dfe00d37c1 tests 2025-07-28 11:49:30 -07:00
km-anthropic
999dd8a3b6 add schedule & workflow dispatch paths. Also make prepare logic conditional 2025-07-28 11:28:06 -07:00
Ashwin Bhat
8fc9a366cb chore: update Claude Code installation to use bun and version 1.0.61 (#352)
- Switch from npm to bun for Claude Code installation in base-action
- Update Claude Code version from 1.0.59 to 1.0.61 in main action
- Ensures consistent package manager usage across both action files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-28 09:44:51 -07:00
GitHub Actions
7c5a98d59d chore: bump Claude Code version to 1.0.61 v0.0.45 2025-07-25 21:06:57 +00:00
km-anthropic
c3e0ab4d6d feat: add agent mode for automation scenarios (#337)
* feat: add agent mode for automation scenarios

- Add agent mode that always triggers without checking for mentions
- Implement Mode interface with support for mode-specific tool configuration
- Add getAllowedTools() and getDisallowedTools() methods to Mode interface
- Simplify tests by combining related test cases
- Update documentation and examples to include agent mode
- Fix TypeScript imports to prevent circular dependencies

Agent mode is designed for automation and workflow_dispatch scenarios
where Claude should always run without requiring trigger phrases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Minor update to readme (from @main to @beta)

* Since workflow_dispatch isn't in the base action, update the examples accordingly

* minor formatting issue

* Update to say beta instead of main

* Fix missed tracking comment to be false

---------

Co-authored-by: km-anthropic <km-anthropic@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-07-24 14:53:15 -07:00
GitHub Actions
94437192fa chore: bump Claude Code version to 1.0.60 2025-07-24 21:02:45 +00:00
km-anthropic
a53ce607e4 Fix missed tracking comment to be false 2025-07-24 13:25:26 -07:00
km-anthropic
02c804a6be Update to say beta instead of main 2025-07-24 13:23:55 -07:00
km-anthropic
cda7d07f95 minor formatting issue 2025-07-24 12:31:20 -07:00
km-anthropic
65bfefd6c4 Since workflow_dispatch isn't in the base action, update the examples accordingly 2025-07-24 10:11:40 -07:00
km-anthropic
4a6d3cf183 Minor update to readme (from @main to @beta) 2025-07-24 08:35:25 -07:00
km-anthropic
3fef2d3f20 feat: add agent mode for automation scenarios
- Add agent mode that always triggers without checking for mentions
- Implement Mode interface with support for mode-specific tool configuration
- Add getAllowedTools() and getDisallowedTools() methods to Mode interface
- Simplify tests by combining related test cases
- Update documentation and examples to include agent mode
- Fix TypeScript imports to prevent circular dependencies

Agent mode is designed for automation and workflow_dispatch scenarios
where Claude should always run without requiring trigger phrases.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-24 00:01:40 -07:00
Yuku Kotani
9cf75f75b9 feat: format PR and issue body text in prompt variables (#330)
* feat: format PR and issue body text in prompt variables

Apply formatBody function to PR_BODY and ISSUE_BODY variables to properly handle images and markdown formatting in prompt context.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* style: format PR_BODY and ISSUE_BODY ternary expressions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add claude_code_oauth_token to all GitHub workflow tests

Add claude_code_oauth_token parameter to all test workflow files to support new authentication method. This ensures proper authentication for Claude Code API access in GitHub Actions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revert "feat: add claude_code_oauth_token to all GitHub workflow tests"

This reverts commit fccc1a0ebd.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-23 22:16:10 -07:00
km-anthropic
a58dc37018 Add mode support (#333)
* Add mode support

* update "as any" with proper "as unknwon as ModeName" casting

* Add documentation to README and registry.ts

* Add  tests for differen event types, integration flows, and error conditions

* Clean up some tests

* Minor test fix

* Minor formatting test + switch from interface to type

* correct the order of mkdir call

* always configureGitAuth as there's already a fallback to handle null users by using the bot ID

* simplify registry setup

---------

Co-authored-by: km-anthropic <km-anthropic@users.noreply.github.com>
2025-07-23 20:35:11 -07:00
Ashwin Bhat
963754fa12 perf: optimize Squid proxy startup time (#334)
* perf: optimize Squid proxy startup time

- Replace fixed 7-second sleep with dynamic readiness check
- Only shutdown existing Squid if actually running
- Add detailed timing logs to track each step's duration
- Expected reduction: ~7-8 seconds to ~1-2 seconds startup overhead

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: extract squid setup into standalone script

Move squid proxy setup logic from action.yml inline bash script
to scripts/setup-network-restrictions.sh for better maintainability
and cleaner action configuration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revert "refactor: extract squid setup into standalone script"

This reverts commit b18aa2821d.

* tmp

* Reapply "refactor: extract squid setup into standalone script"

This reverts commit 07f6911549.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-23 20:33:29 -07:00
Ashwin Bhat
3f4d843152 Revert "feat: integrate Claude Code SDK to replace process spawning (#327)" (#335)
* Revert "feat: integrate Claude Code SDK to replace process spawning (#327)"

This reverts commit 204266ca45.

* 1.0.59
2025-07-23 18:42:43 -07:00
GitHub Actions
e26577a930 chore: bump Claude Code version to 1.0.59 v0.0.44 2025-07-23 21:38:01 +00:00
GitHub Actions
eba34996fb chore: bump Claude Code version to 1.0.58 2025-07-23 21:24:21 +00:00
Ashwin Bhat
0763498a5a feat: add DETAILED_PERMISSION_MESSAGES env var to Claude Code invocation (#328)
Enables detailed permission messages in Claude Code by setting the
DETAILED_PERMISSION_MESSAGES environment variable to '1' in the
Run Claude Code step.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
v0.0.43
2025-07-22 20:02:46 -07:00
Ashwin Bhat
204266ca45 feat: integrate Claude Code SDK to replace process spawning (#327)
* feat: integrate Claude Code SDK to replace process spawning

- Add @anthropic-ai/claude-code dependency to base-action
- Replace mkfifo/cat process spawning with direct SDK usage
- Remove global Claude Code installation from action.yml files
- Maintain full compatibility with existing options
- Add comprehensive tests for SDK integration

This change makes the implementation cleaner and more reliable by
eliminating the complexity of managing child processes and named pipes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: add debugging and bun executable for Claude Code SDK

- Add stderr handler to capture CLI errors
- Explicitly set bun as the executable for the SDK
- This should help diagnose why the CLI is exiting with code 1

* fix: extract mcpServers from parsed MCP config

The SDK expects just the servers object, not the wrapper object with mcpServers property.

* tsc

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-22 16:56:54 -07:00