Skip to content

fix: merge per-worktree hooks storage and include untracked files in diff stats - #79

Merged
fum4 merged 2 commits into
masterfrom
fix/delete-worktree
Mar 16, 2026
Merged

fum4 merged 2 commits into
masterfrom
fix/delete-worktree

Conversation

@fum4

@fum4 fum4 commented Mar 16, 2026 •

Copy link
Copy Markdown
Owner
  • consolidate latest-run.json + skill-results.json into single hooks.json (eliminates hooks/ subdirectory that survived worktree deletion)
  • skip persisting hook results for worktree-removed trigger (ensureDir was recreating the directory after deletion)
  • remove /api/worktrees/:id/hooks/skill-results endpoint (skills now returned inline via PipelineRun.skills from /hooks/status)
  • include untracked file line counts in git diff stats (UI was showing +0 for worktrees with only new files)

Summary by CodeRabbit

  • New Features

    • Git status now includes line counts from untracked files.
  • Refactor

    • Consolidated hook results and command runs into a single per-worktree hooks.json.
    • Run data now optionally includes skill results.
  • API Changes

    • Unified hooks API surface and removed the worktree-scoped skill-results endpoint and its client/hook bindings.
  • Tests

    • Added server tests covering git status and hook/verification behaviors.
  • Documentation

    • Updated architecture, configuration, and API docs to match consolidated storage and endpoints.

…diff stats

- consolidate latest-run.json + skill-results.json into single hooks.json
  (eliminates hooks/ subdirectory that survived worktree deletion)
- skip persisting hook results for worktree-removed trigger
  (ensureDir was recreating the directory after deletion)
- remove /api/worktrees/:id/hooks/skill-results endpoint
  (skills now returned inline via PipelineRun.skills from /hooks/status)
- include untracked file line counts in git diff stats
  (UI was showing +0 for worktrees with only new files)
@fum4 fum4 self-assigned this Mar 16, 2026
@vercel

vercel Bot commented Mar 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openkit Skipped Skipped Mar 16, 2026 9:13pm

@coderabbitai

coderabbitai Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Consolidates per-worktree hook data into a single .openkit/.../hooks.json (steps + skills), removes the worktree-scoped skill-results API and client hooks, adds skills?: SkillHookResult[] to PipelineRun, and includes untracked-file line counts in Git status; tests and docs updated.

Changes

Cohort / File(s) Summary
Hook Consolidation & Persistence
apps/server/src/verification-manager.ts, apps/server/src/verification-manager.test.ts
Merge run and skill-result storage into one hooks.json; persist/merge logic updated; PipelineRun now may include skills; lifecycle persistence skips on worktree removal.
Server Route Removal
apps/server/src/routes/verification.ts
Removed GET /api/worktrees/:id/hooks/skill-results endpoint.
Client API & Hooks Removal
apps/web-app/src/hooks/useApi.ts, apps/web-app/src/hooks/useHooks.ts, apps/web-app/src/hooks/api.ts
Removed fetchHookSkillResults API binding and useHookSkillResults hook; added skills?: SkillHookResult[] to client PipelineRun type.
Component State Change
apps/web-app/src/components/detail/HooksTab.tsx
Replaced external hook with local useState for skill results; fetchStatus reads result.status.skills and removed separate refetch calls.
Git Status Enhancement & Tests
libs/integrations/src/github/gh-client.ts, apps/server/src/git-status.test.ts
getGitStatus now counts untracked-file added lines (uses git ls-files + wc -l) with error-tolerant behavior; added comprehensive tests mocking execFile and command-path.
Public Types
libs/shared/src/worktree-types.ts
Added optional skills?: SkillHookResult[] to PipelineRun.
Documentation
docs/ARCHITECTURE.md, docs/CONFIGURATION.md, docs/HOOKS.md, docs/API.md
Docs updated to reflect single hooks.json storage and removal of the skill-results endpoint and related paths.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A rabbit nibbles lines and digs,
Merges files into cozy digs,
One hooks.json beneath the tree,
Steps and skills curl up with glee,
🐇📦🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the two main changes: consolidating per-worktree hooks storage into a single file and including untracked files in git diff statistics.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/delete-worktree
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

Clode Review

🟠 Medium

  1. wc -l with many untracked files can exceed OS arg limit — libs/integrations/src/github/gh-client.ts:358-362. If a worktree has thousands of untracked files, execFile("wc", ["-l", ...untrackedFiles]) will hit E2ARGUE / ARG_MAX. Consider counting lines in-process with Node (e.g., read each file and count newlines) or batching the wc calls.

  2. wc -l undercounts by one for files without trailing newline — libs/integrations/src/github/gh-client.ts:364-365. wc -l counts newline characters, so a 5-line file without a final newline reports 4. If precision matters, consider a Node-based line count.

  3. Silent empty catch block — libs/integrations/src/github/gh-client.ts:369-371. Per CLAUDE.md, silent catch {} blocks are never acceptable. The comment says "Ignore" but at minimum a log.warn() or log.debug() with context (error message, worktree path) is required so failures are diagnosable.

  4. wc -l is not available on all platforms — libs/integrations/src/github/gh-client.ts:358. On Windows, wc is not a standard command; this will always fail silently. A pure-Node line count would be portable.

🟡 Minor

  1. setupMockResponses matches on substring key.includes(pattern) — apps/server/src/git-status.test.ts:44. Could cause false matches if two patterns share a common substring. Not a problem with current test data but worth noting for future additions.

  2. Missing test for large untracked file count — Would be good to have a test documenting behavior when many untracked files are returned, since the implementation has an ARG_MAX limitation.

  3. promisify import at top level in test — apps/server/src/git-status.test.ts:2. The import { promisify } from "util" is used inside vi.mock factory. This works because Vitest hoists vi.mock calls, but it's a subtle ordering dependency. A comment noting why this import must be above the mock block would help future readers.

🟢 Resolved

  1. Test uses require("util") inside vi.mock factory — Now uses a top-level import { promisify } from "util" instead.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/server/src/verification-manager.ts (1)

207-225: ⚠️ Potential issue | 🟠 Major

Recompute PipelineRun.status from skills as well as steps.

After moving skill results into PipelineRun.skills, these write paths can persist an inconsistent run state: reportSkillResult() reuses the existing status, and mergeAndPersistRun() derives status from mergedSteps only. That can leave /hooks/status returning status: "completed" with a running or failed skill, and completedAt can be set too early. Please move this into a shared reducer/helper that derives the run status from both collections on every persist.

Also applies to: 497-514

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/server/src/verification-manager.ts` around lines 207 - 225,
reportSkillResult and mergeAndPersistRun can persist inconsistent
PipelineRun.status because status is currently derived only from steps or reused
from existing run; create a shared reducer/helper (e.g.,
deriveRunStatusFromStepsAndSkills or reducePipelineRunStatus) that accepts
mergedSteps and skills and returns the correct status and timestamps (including
completedAt) based on both collections, then call this helper wherever runs are
created/updated (reportSkillResult, mergeAndPersistRun, and the other write path
referenced around lines 497-514) so that getStatus/makeRun/persistRun use the
computed status/timestamps rather than reusing or deriving from steps alone.
🧹 Nitpick comments (1)
apps/web-app/src/components/detail/HooksTab.tsx (1)

30-30: Switch this import to a configured alias.

The updated ../../hooks/useHooks path adds another parent-relative import in app source. Please use the repo alias here instead of extending the ../ chain.

As per coding guidelines, "Do not use parent-relative imports (for example ../ or ../../) in app/lib source files. Only same-folder relative imports are allowed (for example ./file). For anything outside the current folder, use configured aliases."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web-app/src/components/detail/HooksTab.tsx` at line 30, Replace the
parent-relative import of useEffectiveHooksConfig in HooksTab.tsx (currently
importing from "../../hooks/useHooks") with the configured repo alias import
(e.g. use the project's alias for the hooks folder) so the symbol
useEffectiveHooksConfig is imported via the alias instead of a ../../ path;
update the import statement in HooksTab.tsx to reference the alias for the hooks
module and keep the imported identifier useEffectiveHooksConfig unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web-app/src/components/detail/HooksTab.tsx`:
- Around line 411-421: The fetchStatus callback currently only updates state
when result.status is truthy, so stale step/skill results persist and fetch
errors are silent; modify fetchStatus (the async function calling
api.fetchHooksStatus) to clear both local states by calling setStepResults({})
and setSkillResults([]) when result.status is null/undefined, and wrap the
api.fetchHooksStatus call in try/catch so on failure you call logger.error(...)
with the caught error and then surface a persistent toast using
showPersistentErrorToast or reportPersistentErrorToast with a user-friendly
message; ensure you still populate state when result.status exists (building the
map from result.status.steps into setStepResults and setting
setSkillResults(result.status.skills)).

In `@docs/CONFIGURATION.md`:
- Around line 560-562: The fenced code block containing
".openkit/worktrees/<worktreeId>/hooks.json" needs a language tag to satisfy
MD040; update the fence starting before ".openkit/..." (the triple backticks) to
include a language identifier such as "text" (i.e. change ``` to ```text) so the
block becomes ```text followed by .openkit/worktrees/<worktreeId>/hooks.json and
a closing ```; no other content changes required.

In `@docs/HOOKS.md`:
- Around line 188-195: The fenced code block showing the directory tree in
HOOKS.md (the block starting with ``` and the lines ".openkit/  .openkit/   
hooks.json ...") lacks a language tag; update that opening fence to include a
neutral language (for example change ``` to ```text) so the block becomes
```text to satisfy MD040 and keep markdown lint clean.
- Around line 199-214: Remove all references to the now-removed frontend hook
helper useHookSkillResults and any mention of the deprecated endpoint
/api/worktrees/:id/hooks/skill-results from the frontend section in HOOKS.md;
update text to describe the unified status flow (use the combined status
endpoint /api/worktrees/:id/hooks/status and the report endpoint
/api/worktrees/:id/hooks/report) and adjust examples/snippets to use the unified
status shape and hooks skill reporting fields instead of the old skill-results
usage.

In `@libs/integrations/src/github/gh-client.ts`:
- Around line 359-369: The call to execFile("wc", ["-l", ...untrackedFiles]) can
misinterpret filenames beginning with "-" and the catch currently swallows
errors; update the args to include the POSIX separator (execFile("wc", ["-l",
"--", ...untrackedFiles"])) and replace the empty catch with a logged error that
records context (e.g., worktreePath and untrackedFiles) and the thrown error so
failures around the execFile/wcOut/linesAdded logic are visible; keep the
original behavior of not failing the whole operation but ensure the error is
logged via your module's logger (e.g., logger.error or this.logger.error) with
clear context.

---

Outside diff comments:
In `@apps/server/src/verification-manager.ts`:
- Around line 207-225: reportSkillResult and mergeAndPersistRun can persist
inconsistent PipelineRun.status because status is currently derived only from
steps or reused from existing run; create a shared reducer/helper (e.g.,
deriveRunStatusFromStepsAndSkills or reducePipelineRunStatus) that accepts
mergedSteps and skills and returns the correct status and timestamps (including
completedAt) based on both collections, then call this helper wherever runs are
created/updated (reportSkillResult, mergeAndPersistRun, and the other write path
referenced around lines 497-514) so that getStatus/makeRun/persistRun use the
computed status/timestamps rather than reusing or deriving from steps alone.

---

Nitpick comments:
In `@apps/web-app/src/components/detail/HooksTab.tsx`:
- Line 30: Replace the parent-relative import of useEffectiveHooksConfig in
HooksTab.tsx (currently importing from "../../hooks/useHooks") with the
configured repo alias import (e.g. use the project's alias for the hooks folder)
so the symbol useEffectiveHooksConfig is imported via the alias instead of a
../../ path; update the import statement in HooksTab.tsx to reference the alias
for the hooks module and keep the imported identifier useEffectiveHooksConfig
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b779d99-f343-41c3-b212-97d3046b975e

📥 Commits

Reviewing files that changed from the base of the PR and between f424643 and afff647.

📒 Files selected for processing (14)
  • apps/server/src/git-status.test.ts
  • apps/server/src/routes/verification.ts
  • apps/server/src/verification-manager.test.ts
  • apps/server/src/verification-manager.ts
  • apps/web-app/src/components/detail/HooksTab.tsx
  • apps/web-app/src/hooks/api.ts
  • apps/web-app/src/hooks/useApi.ts
  • apps/web-app/src/hooks/useHooks.ts
  • docs/API.md
  • docs/ARCHITECTURE.md
  • docs/CONFIGURATION.md
  • docs/HOOKS.md
  • libs/integrations/src/github/gh-client.ts
  • libs/shared/src/worktree-types.ts
💤 Files with no reviewable changes (4)
  • apps/web-app/src/hooks/useApi.ts
  • docs/API.md
  • apps/server/src/routes/verification.ts
  • apps/web-app/src/hooks/useHooks.ts

Comment on lines 411 to 421
const fetchStatus = useCallback(async () => {
const result = await api.fetchHooksStatus(worktreeId);
if (result.status?.steps) {
if (result.status) {
const map: Record<string, StepResult> = {};
for (const step of result.status.steps) {
for (const step of result.status.steps ?? []) {
map[step.stepId] = step;
}
setStepResults(map);
setSkillResults(result.status.skills ?? []);
}
}, [api, worktreeId]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Reset local results on null status and handle fetch failures explicitly.

This only updates state when result.status is truthy, so a fresh or deleted worktree can keep rendering the previous worktree's step/skill results indefinitely. Also, this callback is now the single refresh path for both sections, but a rejected fetchHooksStatus() here is not logged or surfaced to the user. Clear both result states when no status is returned, and wrap the request with logger + persistent toast handling.

As per coding guidelines, "Always surface user-facing errors through toast notifications (showPersistentErrorToast / reportPersistentErrorToast). Errors that surface as toasts must also be logged through the logger."

Also applies to: 423-436

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web-app/src/components/detail/HooksTab.tsx` around lines 411 - 421, The
fetchStatus callback currently only updates state when result.status is truthy,
so stale step/skill results persist and fetch errors are silent; modify
fetchStatus (the async function calling api.fetchHooksStatus) to clear both
local states by calling setStepResults({}) and setSkillResults([]) when
result.status is null/undefined, and wrap the api.fetchHooksStatus call in
try/catch so on failure you call logger.error(...) with the caught error and
then surface a persistent toast using showPersistentErrorToast or
reportPersistentErrorToast with a user-friendly message; ensure you still
populate state when result.status exists (building the map from
result.status.steps into setStepResults and setting
setSkillResults(result.status.skills)).

Comment thread docs/CONFIGURATION.md
Comment on lines 560 to 562
```
.openkit/worktrees/<worktreeId>/hooks/latest-run.json
.openkit/worktrees/<worktreeId>/hooks/skill-results.json
.openkit/worktrees/<worktreeId>/hooks.json
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language to the fenced code block.

Line 560 uses a plain fence; please annotate it (for example text) to satisfy MD040.

Suggested patch
-```
+```text
 .openkit/worktrees/<worktreeId>/hooks.json
</details>

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.21.0)</summary>

[warning] 560-560: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @docs/CONFIGURATION.md around lines 560 - 562, The fenced code block
containing ".openkit/worktrees//hooks.json" needs a language tag to
satisfy MD040; update the fence starting before ".openkit/..." (the triple
backticks) to include a language identifier such as "text" (i.e. change totext) so the block becomes text followed by .openkit/worktrees/<worktreeId>/hooks.json and a closing ; no other content
changes required.


</details>

<!-- fingerprinting:phantom:poseidon:hawk -->

<!-- This is an auto-generated comment by CodeRabbit -->

Comment thread docs/HOOKS.md
Comment on lines 188 to 195
```
.openkit/
.openkit/
hooks.json # Global hooks configuration
hooks.json # Global hooks configuration
worktrees/
<worktreeId>/
hooks/
latest-run.json # Most recent command step run
skill-results.json # Agent-reported skill results
hooks.json # Combined step run + skill results
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language to this fenced block.

Line 188 should use a language tag (e.g. text) to satisfy MD040 and keep markdown lint clean.

🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 188-188: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/HOOKS.md` around lines 188 - 195, The fenced code block showing the
directory tree in HOOKS.md (the block starting with ``` and the lines ".openkit/
.openkit/    hooks.json ...") lacks a language tag; update that opening fence to
include a neutral language (for example change ``` to ```text) so the block
becomes ```text to satisfy MD040 and keep markdown lint clean.

Comment thread docs/HOOKS.md
Comment on lines +199 to +214
| Method | Path | Description |
| -------- | -------------------------------------- | ----------------------------------------------------------------------------- |
| `GET` | `/api/hooks/config` | Get hooks configuration |
| `PUT` | `/api/hooks/config` | Save full hooks configuration |
| `POST` | `/api/hooks/steps` | Add a step (`{ name, command, kind? }` or `{ name, kind: "prompt", prompt }`) |
| `PATCH` | `/api/hooks/steps/:stepId` | Update a step (`{ name?, command?, prompt?, kind?, enabled?, trigger? }`) |
| `DELETE` | `/api/hooks/steps/:stepId` | Remove a step |
| `POST` | `/api/hooks/skills/import` | Import a skill (`{ skillName, trigger?, condition? }`) |
| `GET` | `/api/hooks/skills/available` | List available skills from registry |
| `PATCH` | `/api/hooks/skills/:name` | Toggle a skill (`{ enabled, trigger? }`) |
| `DELETE` | `/api/hooks/skills/:name` | Remove a skill (`?trigger=` query param) |
| `POST` | `/api/worktrees/:id/hooks/run` | Run enabled command steps for a worktree (`{ trigger? }`) |
| `POST` | `/api/worktrees/:id/hooks/run/:stepId` | Run a single step |
| `GET` | `/api/worktrees/:id/hooks/status` | Get latest run status (includes both step and skill results) |
| `POST` | `/api/worktrees/:id/hooks/report` | Report a skill result (`{ skillName, trigger?, success, summary, ... }`) |
| `GET` | `/api/files/read?path=...` | Read a file by absolute path (used for MD report preview) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update the frontend section to remove useHookSkillResults references.

The REST API table reflects the unified status flow, but this file still documents useHookSkillResults later, which is stale after removing /api/worktrees/:id/hooks/skill-results.

Suggested doc adjustment
-### useHookSkillResults (`apps/web-app/src/hooks/useHooks.ts`)
-
-Hook for fetching agent-reported skill results for a worktree.
+### Skill results in hook status (`apps/web-app/src/hooks/useHooks.ts`)
+
+Skill results are returned inline via `status.skills` from `GET /api/worktrees/:id/hooks/status`; there is no separate skill-results endpoint.

As per coding guidelines {docs/**/*.md,README.md}: “Keep ALL docs in sync at ALL TIMES.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/HOOKS.md` around lines 199 - 214, Remove all references to the
now-removed frontend hook helper useHookSkillResults and any mention of the
deprecated endpoint /api/worktrees/:id/hooks/skill-results from the frontend
section in HOOKS.md; update text to describe the unified status flow (use the
combined status endpoint /api/worktrees/:id/hooks/status and the report endpoint
/api/worktrees/:id/hooks/report) and adjust examples/snippets to use the unified
status shape and hooks skill reporting fields instead of the old skill-results
usage.

Comment on lines +359 to +369
const { stdout: wcOut } = await execFile("wc", ["-l", ...untrackedFiles], {
cwd: worktreePath,
encoding: "utf-8",
});
// wc -l outputs " <count> <filename>" per file; for multiple files the last line is the total
const lastLine = wcOut.trim().split("\n").pop()!.trim();
linesAdded += parseInt(lastLine.split(/\s+/)[0], 10) || 0;
}
} catch {
// Ignore — e.g. no untracked files or wc unavailable
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify current wc invocation and whether '--' is used
rg -n 'execFile\("wc", \["-l"' libs/integrations/src/github/gh-client.ts

# Verify local logger availability and usage pattern in integrations package
fd logger.ts libs/integrations
rg -n 'domain:\s*"' libs/integrations/src -g '*.ts'

Repository: fum4/openkit

Length of output: 256


🏁 Script executed:

#!/bin/bash

# Check the exact catch block and surrounding context
sed -n '350,375p' libs/integrations/src/github/gh-client.ts

# Verify logger import in gh-client.ts
head -30 libs/integrations/src/github/gh-client.ts | grep -E 'import|logger'

# Check logger.ts to understand available API
cat libs/integrations/src/github/logger.ts

Repository: fum4/openkit

Length of output: 1274


🏁 Script executed:

#!/bin/bash

# Check what's in the local logger.ts
cat libs/integrations/src/github/logger.ts

# Verify the exact import and usage in gh-client.ts around line 359-369
sed -n '1,50p' libs/integrations/src/github/gh-client.ts

Repository: fum4/openkit

Length of output: 1627


🏁 Script executed:

#!/bin/bash

# Check how the logger is used elsewhere in gh-client.ts
rg -n 'log\.' libs/integrations/src/github/gh-client.ts | head -20

# Verify Logger API by checking `@openkit/logger` documentation or examples
find libs -name 'logger.ts' -type f | head -3 | xargs head -20

Repository: fum4/openkit

Length of output: 461


🏁 Script executed:

#!/bin/bash

# Check if 'log' is imported from './logger' in gh-client.ts
rg -n "from.*logger" libs/integrations/src/github/gh-client.ts

# Find other catch blocks in gh-client.ts to see if any log errors
rg -n -B2 -A2 'catch.*{' libs/integrations/src/github/gh-client.ts | head -40

# Check Logger API methods available
rg -n 'log\.(debug|info|warn|error|success)' libs/integrations/src/github -g '*.ts'

Repository: fum4/openkit

Length of output: 135


🏁 Script executed:

#!/bin/bash

# Check if 'log' is imported from './logger' in gh-client.ts
rg -n "from.*logger" libs/integrations/src/github/gh-client.ts

# Find other catch blocks in gh-client.ts to see if any log errors
rg -n -B2 -A2 'catch' libs/integrations/src/github/gh-client.ts

# Check Logger API methods in other integrations
rg -n 'log\.(debug|info|warn|error|success)' libs/integrations/src -g '*.ts' | head -20

Repository: fum4/openkit

Length of output: 4260


🏁 Script executed:

#!/bin/bash

# Get the full import section of gh-client.ts to see if log is imported
head -15 libs/integrations/src/github/gh-client.ts

# Check if log is used anywhere in the file at all
grep -n "^import.*log" libs/integrations/src/github/gh-client.ts
grep -n "log\." libs/integrations/src/github/gh-client.ts

# Look for Logger API signature to understand available methods
rg -A5 'class Logger' libs -g '*.ts' | head -30

Repository: fum4/openkit

Length of output: 1298


🏁 Script executed:

#!/bin/bash

# Get the Logger implementation to understand available methods
cat libs/logger/node/src/index.ts | head -100

# Check method signatures for debug/info/warn/error
rg -A3 'debug\(|info\(|warn\(|error\(' libs/logger/node/src/index.ts | head -40

Repository: fum4/openkit

Length of output: 4148


Add -- separator before filenames and log errors instead of silently ignoring them.

Line 359 passes filenames directly to wc without a -- separator, which means a filename starting with - could be interpreted as a flag. Additionally, the catch block at line 367 silently ignores all errors, violating the logging guideline that every error must be logged with context.

Suggested patch
+import { log } from "./logger";
+
 export async function checkGhInstalled(): Promise<boolean> {
@@
-      const { stdout: wcOut } = await execFile("wc", ["-l", ...untrackedFiles], {
+      const { stdout: wcOut } = await execFile("wc", ["-l", "--", ...untrackedFiles], {
         cwd: worktreePath,
         encoding: "utf-8",
       });
@@
-  } catch {
-    // Ignore — e.g. no untracked files or wc unavailable
+  } catch (err) {
+    log.debug("Failed to include untracked files in diff stats", {
+      domain: "github",
+      worktreePath,
+      error: err instanceof Error ? err.message : String(err),
+    });
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/integrations/src/github/gh-client.ts` around lines 359 - 369, The call
to execFile("wc", ["-l", ...untrackedFiles]) can misinterpret filenames
beginning with "-" and the catch currently swallows errors; update the args to
include the POSIX separator (execFile("wc", ["-l", "--", ...untrackedFiles"]))
and replace the empty catch with a logged error that records context (e.g.,
worktreePath and untrackedFiles) and the thrown error so failures around the
execFile/wcOut/linesAdded logic are visible; keep the original behavior of not
failing the whole operation but ensure the error is logged via your module's
logger (e.g., logger.error or this.logger.error) with clear context.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/server/src/git-status.test.ts`:
- Around line 12-17: The mock callback currently passes the result object as the
second arg which doesn't match execFile(error, stdout, stderr); update the mock
in the block that calls mockExec(args[0], args[1], args[2]) so that when result
is an Error you call cb(result) and when it's the success case you call cb(null,
result.stdout, result.stderr) to mirror the real execFile signature (referencing
mockExec and the cb callback).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c175f301-1196-44a9-9f39-dbcbc3862687

📥 Commits

Reviewing files that changed from the base of the PR and between afff647 and 140452d.

📒 Files selected for processing (1)
  • apps/server/src/git-status.test.ts

Comment on lines +12 to +17
const result = mockExec(args[0], args[1], args[2]);
if (result instanceof Error) {
cb(result);
} else {
cb(null, result);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

In Node.js child_process.execFile API, what is the callback signature and what values are passed for stdout/stderr?

💡 Result:

In child_process.execFile(file[, args][, options][, callback]), the optional callback is invoked on process termination with the signature:

(error, stdout, stderr) => { ... } [1]

  • error: null on success; otherwise an Error (with properties like error.code for exit code and error.signal if terminated by a signal). [1]
  • stdout / stderr: the child process’s buffered standard output / standard error. By default they are UTF-8 decoded strings; if options.encoding is 'buffer' (or an unrecognized encoding), they are passed as Buffer objects. [1][2]

🏁 Script executed:

cat -n apps/server/src/git-status.test.ts | head -40

Repository: fum4/openkit

Length of output: 1815


🏁 Script executed:

cat -n apps/server/src/git-status.test.ts | sed -n '39,80p'

Repository: fum4/openkit

Length of output: 1882


Fix callback mock signature to match execFile API.

The mock's callback on line 16 currently passes (null, result) where result is { stdout, stderr }, but the real execFile callback signature expects (error, stdout, stderr) as separate arguments. This mismatch could hide bugs if callback-style usage is introduced. Unpack the result object to match the actual API:

-      if (result instanceof Error) {
-        cb(result);
-      } else {
-        cb(null, result);
-      }
+      if (result instanceof Error) {
+        cb(result, "", "");
+      } else {
+        cb(null, result.stdout, result.stderr);
+      }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const result = mockExec(args[0], args[1], args[2]);
if (result instanceof Error) {
cb(result);
} else {
cb(null, result);
}
const result = mockExec(args[0], args[1], args[2]);
if (result instanceof Error) {
cb(result, "", "");
} else {
cb(null, result.stdout, result.stderr);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/server/src/git-status.test.ts` around lines 12 - 17, The mock callback
currently passes the result object as the second arg which doesn't match
execFile(error, stdout, stderr); update the mock in the block that calls
mockExec(args[0], args[1], args[2]) so that when result is an Error you call
cb(result) and when it's the success case you call cb(null, result.stdout,
result.stderr) to mirror the real execFile signature (referencing mockExec and
the cb callback).

@fum4
fum4 merged commit 72bf75e into master Mar 16, 2026
19 checks passed
@fum4
fum4 deleted the fix/delete-worktree branch March 16, 2026 21:47

This branch was previously deployed

1 inactive deployment
Preview — 140452de Deployed Mar 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant