Repository navigation
fix: Added in debug mode, support for storing raw data in json #2156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Claude Code Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, ready_for_review, reopened] | ||
| # Optional: Only run on specific file changes | ||
| # paths: | ||
| # - "src/**/*.ts" | ||
| # - "src/**/*.tsx" | ||
| # - "src/**/*.js" | ||
| # - "src/**/*.jsx" | ||
|
|
||
| jobs: | ||
| claude-review: | ||
| # Optional: Filter by PR author | ||
| # if: | | ||
| # github.event.pull_request.user.login == 'external-contributor' || | ||
| # github.event.pull_request.user.login == 'new-developer' || | ||
| # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code Review | ||
| id: claude-review | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' | ||
| plugins: 'code-review@claude-code-plugins' | ||
| prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' | ||
| # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | ||
| # or https://code.claude.com/docs/en/cli-reference for available options | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Claude Code | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| claude: | ||
| if: | | ||
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
| (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
| id-token: write | ||
| actions: read # Required for Claude to read CI results on PRs | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code | ||
| id: claude | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
|
|
||
| # This is an optional setting that allows Claude to read CI results on PRs | ||
| additional_permissions: | | ||
| actions: read | ||
| # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. | ||
| # prompt: 'Update the pull request description to include a summary of changes.' | ||
|
|
||
| # Optional: Add claude_args to customize behavior and configuration | ||
| # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | ||
| # or https://code.claude.com/docs/en/cli-reference for available options | ||
| # claude_args: '--allowed-tools Bash(gh pr *)' | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,7 @@ let tunnelProcess: ReturnType<typeof spawn> | null = null; | |
| let tunnelPid: number | null = null; | ||
| let installPromise: Promise<string> | null = null; | ||
| let startPromise: Promise<CloudflaredTunnelStatus> | null = null; | ||
| let stateFileQueue: Promise<void> = Promise.resolve(); | ||
| const NON_ACTIONABLE_CLOUDFLARED_WARNING_PATTERNS = [ | ||
| /failed to sufficiently increase receive buffer size/i, | ||
| ] as const; | ||
|
|
@@ -205,14 +206,35 @@ async function readStateFile(): Promise<PersistedTunnelState> { | |
| } | ||
| } | ||
|
|
||
| async function writeStateFile(state: PersistedTunnelState) { | ||
| async function writeStateFileNow(state: PersistedTunnelState) { | ||
| await ensureTunnelDir(); | ||
| await fs.writeFile(getStateFilePath(), JSON.stringify(state, null, 2) + "\n", "utf8"); | ||
| } | ||
|
|
||
| async function withStateFileLock<T>(operation: () => Promise<T>): Promise<T> { | ||
| const previous = stateFileQueue; | ||
| let release!: () => void; | ||
| stateFileQueue = new Promise<void>((resolve) => { | ||
| release = resolve; | ||
| }); | ||
|
|
||
| await previous; | ||
| try { | ||
| return await operation(); | ||
| } finally { | ||
| release(); | ||
| } | ||
| } | ||
|
Comment on lines
+214
to
+227
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| async function writeStateFile(state: PersistedTunnelState) { | ||
| await withStateFileLock(() => writeStateFileNow(state)); | ||
| } | ||
|
|
||
| async function updateStateFile(patch: PersistedTunnelState) { | ||
| const current = await readStateFile(); | ||
| await writeStateFile({ ...current, ...patch }); | ||
| await withStateFileLock(async () => { | ||
| const current = await readStateFile(); | ||
| await writeStateFileNow({ ...current, ...patch }); | ||
| }); | ||
| } | ||
|
|
||
| async function clearPidFile() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,12 @@ function parsePositiveInt(value: string | undefined, fallback: number): number { | |
| return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback; | ||
| } | ||
|
|
||
| function parseNonNegativeInt(value: string | undefined, fallback: number): number { | ||
| if (value === undefined || value === "") return fallback; | ||
| const parsed = Number.parseInt(value, 10); | ||
| return Number.isInteger(parsed) && parsed >= 0 ? parsed : fallback; | ||
| } | ||
|
|
||
| function parseBoolean(value: string | undefined, fallback: boolean): boolean { | ||
| if (!value) return fallback; | ||
| const normalized = value.trim().toLowerCase(); | ||
|
|
@@ -101,3 +107,26 @@ export function getAppLogLevel(defaultLevel: string): string { | |
| export function getAppLogFormat(defaultFormat: string): string { | ||
| return process.env.APP_LOG_FORMAT || defaultFormat; | ||
| } | ||
|
|
||
| // ─── Chat log truncation limits ───────────────────────────────────────────── | ||
|
|
||
| export function getChatLogTextLimit(): number { | ||
| return parsePositiveInt(process.env.CHAT_LOG_TEXT_LIMIT, 64 * 1024); | ||
| } | ||
|
|
||
| export function getChatLogArrayTailItems(): number { | ||
| return parsePositiveInt(process.env.CHAT_LOG_ARRAY_TAIL_ITEMS, 24); | ||
| } | ||
|
|
||
| export function getChatLogMaxDepth(): number { | ||
| return parsePositiveInt(process.env.CHAT_LOG_MAX_DEPTH, 6); | ||
| } | ||
|
|
||
| export function getChatLogMaxObjectKeys(): number { | ||
| return parseNonNegativeInt(process.env.CHAT_LOG_MAX_OBJECT_KEYS, 80); | ||
| } | ||
|
|
||
| export function isChatDebugFileEnabled(): boolean { | ||
| if (parseBoolean(process.env.CHAT_DEBUG_FILE, false)) return true; | ||
| return process.env.APP_LOG_LEVEL?.trim().toLowerCase() === "debug"; | ||
| } | ||
|
Comment on lines
+113
to
+132
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These getters for chat log limits are called frequently within recursive functions (e.g., let _chatLogTextLimit: number | undefined;
export function getChatLogTextLimit(): number {
if (_chatLogTextLimit === undefined) {
_chatLogTextLimit = parsePositiveInt(process.env.CHAT_LOG_TEXT_LIMIT, 64 * 1024);
}
return _chatLogTextLimit;
}
let _chatLogArrayTailItems: number | undefined;
export function getChatLogArrayTailItems(): number {
if (_chatLogArrayTailItems === undefined) {
_chatLogArrayTailItems = parsePositiveInt(process.env.CHAT_LOG_ARRAY_TAIL_ITEMS, 24);
}
return _chatLogArrayTailItems;
}
let _chatLogMaxDepth: number | undefined;
export function getChatLogMaxDepth(): number {
if (_chatLogMaxDepth === undefined) {
_chatLogMaxDepth = parsePositiveInt(process.env.CHAT_LOG_MAX_DEPTH, 6);
}
return _chatLogMaxDepth;
}
let _chatLogMaxObjectKeys: number | undefined;
export function getChatLogMaxObjectKeys(): number {
if (_chatLogMaxObjectKeys === undefined) {
_chatLogMaxObjectKeys = parseNonNegativeInt(process.env.CHAT_LOG_MAX_OBJECT_KEYS, 80);
}
return _chatLogMaxObjectKeys;
}
let _isChatDebugFileEnabled: boolean | undefined;
export function isChatDebugFileEnabled(): boolean {
if (_isChatDebugFileEnabled === undefined) {
if (parseBoolean(process.env.CHAT_DEBUG_FILE, false)) {
_isChatDebugFileEnabled = true;
} else {
_isChatDebugFileEnabled = process.env.APP_LOG_LEVEL?.trim().toLowerCase() === "debug";
}
}
return _isChatDebugFileEnabled;
} |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to
getChatLogArrayTailItems()is performed even if thevalueis not an array. Since this function is called recursively for every node in the payload, moving this lookup inside theArray.isArray(value)block will avoid unnecessary environment variable lookups and parsing for non-array objects.