Skip to content

refactor: modular port-offset system, logger restructure, and codebase cleanup - #83

Merged
fum4 merged 5 commits into
masterfrom
refactor/modular-port-offset-and-cleanup
Mar 18, 2026
Merged

fum4 merged 5 commits into
masterfrom
refactor/modular-port-offset-and-cleanup

Conversation

@fum4

@fum4 fum4 commented Mar 18, 2026

Copy link
Copy Markdown
Owner
  • extract port-offset into standalone lib with adapter pattern for framework-specific behavior (RN, Expo, generic)
  • decompose PortManager god class into focused modules: offset-allocator, env-mapper, env-builder, hook-resolver, port-discovery, config-persistence
  • convert node port-hook from CJS to TypeScript, compiled via tsup
  • restructure logger lib: Go source in src/, build targets in src/targets/, language bindings in src/bindings/, build artifacts in dist/
  • split all bindings into bindings + logger files for consistency across Node, Browser, Python, and Zig
  • consolidate work skill: merge duplicate work-on-task into single base workflow, remove bundled skills concept
  • rename agent instruction dirs and skill folders for clarity
  • move test files to test/ directories at each nesting level
  • add workspace dependency convention and README requirement to CLAUDE.md
  • add configuration flags initialization convention
  • add READMEs to all apps and libs
  • enable native port hook by default
  • add smoke script for full workspace validation

…e cleanup

- extract port-offset into standalone lib with adapter pattern for
  framework-specific behavior (RN, Expo, generic)
- decompose PortManager god class into focused modules: offset-allocator,
  env-mapper, env-builder, hook-resolver, port-discovery, config-persistence
- convert node port-hook from CJS to TypeScript, compiled via tsup
- restructure logger lib: Go source in src/, build targets in src/targets/,
  language bindings in src/bindings/, build artifacts in dist/
- split all bindings into bindings + logger files for consistency across
  Node, Browser, Python, and Zig
- consolidate work skill: merge duplicate work-on-task into single base
  workflow, remove bundled skills concept
- rename agent instruction dirs and skill folders for clarity
- move test files to __test__/ directories at each nesting level
- add workspace dependency convention and README requirement to CLAUDE.md
- add configuration flags initialization convention
- add READMEs to all apps and libs
- enable native port hook by default
- add smoke script for full workspace validation
@fum4 fum4 self-assigned this Mar 18, 2026
@vercel

vercel Bot commented Mar 18, 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 18, 2026 2:24am

@coderabbitai

coderabbitai Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 202 files, which is 52 over the limit of 150.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5828b5a5-b6d2-46ab-a390-61bb8ec5b0a1

📥 Commits

Reviewing files that changed from the base of the PR and between ae1c42c and adc51e5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (202)
  • .claude/skills/address-pr-review/SKILL.md
  • .github/workflows/review-pull-request.yml
  • .vscode/launch.json
  • AGENTS.md
  • CLAUDE.md
  • apps/cli/README.md
  • apps/cli/package.json
  • apps/cli/src/init.ts
  • apps/desktop-app/README.md
  • apps/mobile-app/README.md
  • apps/server/README.md
  • apps/server/package.json
  • apps/server/project.json
  • apps/server/src/__test__/activity-log.test.ts
  • apps/server/src/__test__/branch-name.test.ts
  • apps/server/src/__test__/fixtures.ts
  • apps/server/src/__test__/git-policy.test.ts
  • apps/server/src/__test__/git-status.test.ts
  • apps/server/src/__test__/local-config.test.ts
  • apps/server/src/__test__/notes-manager.test.ts
  • apps/server/src/__test__/ops-log.test.ts
  • apps/server/src/__test__/perf-monitor.test.ts
  • apps/server/src/__test__/task-context.test.ts
  • apps/server/src/__test__/terminal-manager.test.ts
  • apps/server/src/__test__/verification-manager.test.ts
  • apps/server/src/framework-detect.ts
  • apps/server/src/index.ts
  • apps/server/src/lib/project-skill-bootstrap.ts
  • apps/server/src/manager.ts
  • apps/server/src/port-manager.test.ts
  • apps/server/src/port-manager.ts
  • apps/server/src/routes/skills.ts
  • apps/server/src/verification-skills.ts
  • apps/server/tsup.config.ts
  • apps/server/vitest.config.ts
  • apps/web-app/README.md
  • apps/web-app/src/__test__/mocks/child-process.ts
  • apps/web-app/src/__test__/mocks/handlers.ts
  • apps/web-app/src/__test__/mocks/integrations.ts
  • apps/web-app/src/__test__/render.tsx
  • apps/web-app/src/__test__/server-bridge.ts
  • apps/web-app/src/__test__/setup.ts
  • apps/web-app/src/components/__test__/ActivityFeed.test.tsx
  • apps/web-app/src/components/__test__/AppSettingsModal.test.tsx
  • apps/web-app/src/components/__test__/Button.test.tsx
  • apps/web-app/src/components/__test__/ConfirmDialog.test.tsx
  • apps/web-app/src/components/__test__/CreateCustomTaskModal.test.tsx
  • apps/web-app/src/components/__test__/CreateForm.test.tsx
  • apps/web-app/src/components/__test__/CreateWorktreeModal.test.tsx
  • apps/web-app/src/components/__test__/CustomTaskItem.test.tsx
  • apps/web-app/src/components/__test__/JiraIssueItem.test.tsx
  • apps/web-app/src/components/__test__/JiraIssueList.test.tsx
  • apps/web-app/src/components/__test__/LinearIssueItem.test.tsx
  • apps/web-app/src/components/__test__/LinearIssueList.test.tsx
  • apps/web-app/src/components/__test__/LinkIssueModal.test.tsx
  • apps/web-app/src/components/__test__/Modal.test.tsx
  • apps/web-app/src/components/__test__/PerformancePage.test.tsx
  • apps/web-app/src/components/__test__/ToggleSwitch.test.tsx
  • apps/web-app/src/components/__test__/WorktreeExistsModal.test.tsx
  • apps/web-app/src/components/__test__/WorktreeItem.test.tsx
  • apps/web-app/src/components/__test__/WorktreeList.test.tsx
  • apps/web-app/src/components/detail/DetailPanel.test.tsx
  • apps/web-app/src/components/detail/NotesSection.test.tsx
  • apps/web-app/src/components/detail/SkillDetailPanel.tsx
  • apps/web-app/src/components/detail/TerminalView.test.tsx
  • apps/web-app/src/components/detail/TodoList.test.tsx
  • apps/web-app/src/css.d.ts
  • apps/web-app/src/hooks/__test__/useActivityFeed.test.ts
  • apps/web-app/src/hooks/__test__/useCustomTasks.test.ts
  • apps/web-app/src/hooks/__test__/useJiraIssues.test.ts
  • apps/web-app/src/hooks/__test__/useLinearIssues.test.ts
  • apps/web-app/src/hooks/__test__/usePerformanceMetrics.test.ts
  • apps/web-app/src/hooks/__test__/useWorktrees.test.ts
  • apps/web-app/src/types.ts
  • apps/web-app/vite.config.ts
  • apps/website/README.md
  • apps/website/astro.config.ts
  • apps/website/package.json
  • apps/website/src/constants.ts
  • apps/website/src/layouts/Layout.astro
  • docs/ARCHITECTURE.md
  • docs/DEVELOPMENT.md
  • docs/PORT-MAPPING.md
  • docs/PROJECT_STRUCTURE.md
  • libs/agents/src/index.ts
  • libs/agents/src/instructions.ts
  • libs/agents/src/mcp/claude-skill.md
  • libs/agents/src/mcp/cursor-rule.md
  • libs/agents/src/mcp/instructions.md
  • libs/agents/src/sample-skills/address-review-findings/SKILL.md
  • libs/agents/src/sample-skills/explain-like-im-5/SKILL.md
  • libs/agents/src/sample-skills/how-to-test/SKILL.md
  • libs/agents/src/sample-skills/review-changes/SKILL.md
  • libs/agents/src/sample-skills/summarize-changes/SKILL.md
  • libs/agents/src/sample-skills/write-e2e-tests/SKILL.md
  • libs/agents/src/sample-skills/write-integration-tests/SKILL.md
  • libs/agents/src/sample-skills/write-tests/SKILL.md
  • libs/agents/src/sample-skills/write-unit-tests/SKILL.md
  • libs/agents/src/skills/work-on-task/SKILL.md
  • libs/agents/src/work-skill/base.md
  • libs/agents/src/work-skill/claude-skill.md
  • libs/agents/src/work-skill/cursor-rule.md
  • libs/agents/src/work-skill/vscode-prompt.md
  • libs/integrations/README.md
  • libs/logger/.gitignore
  • libs/logger/README.md
  • libs/logger/browser/package.json
  • libs/logger/browser/src/.gitignore
  • libs/logger/browser/src/index.ts
  • libs/logger/browser/src/wasm_exec.d.ts
  • libs/logger/browser/tsconfig.json
  • libs/logger/cgo/go.mod
  • libs/logger/go.mod
  • libs/logger/node/package.json
  • libs/logger/node/tsconfig.json
  • libs/logger/package.json
  • libs/logger/project.json
  • libs/logger/python/__init__.pyi
  • libs/logger/python/bindings.pyi
  • libs/logger/python/logger.pyi
  • libs/logger/src/bindings/browser/bindings.ts
  • libs/logger/src/bindings/browser/logger.ts
  • libs/logger/src/bindings/node/bindings.ts
  • libs/logger/src/bindings/node/logger.ts
  • libs/logger/src/bindings/python/.gitignore
  • libs/logger/src/bindings/python/__init__.py
  • libs/logger/src/bindings/python/bindings.py
  • libs/logger/src/bindings/python/logger.py
  • libs/logger/src/bindings/python/py.typed
  • libs/logger/src/bindings/python/pyproject.toml
  • libs/logger/src/bindings/ts_utils.test.ts
  • libs/logger/src/bindings/ts_utils.ts
  • libs/logger/src/bindings/zig/bindings.zig
  • libs/logger/src/bindings/zig/logger.zig
  • libs/logger/src/colors.go
  • libs/logger/src/console.go
  • libs/logger/src/console_wasm.go
  • libs/logger/src/formatter.go
  • libs/logger/src/go.mod
  • libs/logger/src/logger.go
  • libs/logger/src/sink.go
  • libs/logger/src/targets/cgo/build.sh
  • libs/logger/src/targets/cgo/exports.go
  • libs/logger/src/targets/cgo/go.mod
  • libs/logger/src/targets/wasm/build.sh
  • libs/logger/src/targets/wasm/go.mod
  • libs/logger/src/targets/wasm/main.go
  • libs/logger/src/transport.go
  • libs/logger/src/transport_wasm.go
  • libs/logger/tsconfig.json
  • libs/logger/vitest.config.ts
  • libs/logger/wasm/build.sh
  • libs/logger/wasm/go.mod
  • libs/logger/zig/logger.zig
  • libs/native-port-resolution/README.md
  • libs/port-offset/README.md
  • libs/port-offset/package.json
  • libs/port-offset/project.json
  • libs/port-offset/src/__test__/config-persistence.test.ts
  • libs/port-offset/src/__test__/env-builder.test.ts
  • libs/port-offset/src/__test__/env-mapper.test.ts
  • libs/port-offset/src/__test__/hook-resolver.test.ts
  • libs/port-offset/src/__test__/offset-allocator.test.ts
  • libs/port-offset/src/__test__/port-manager.test.ts
  • libs/port-offset/src/adapters/__test__/expo.test.ts
  • libs/port-offset/src/adapters/__test__/react-native.test.ts
  • libs/port-offset/src/adapters/__test__/registry.test.ts
  • libs/port-offset/src/adapters/base.ts
  • libs/port-offset/src/adapters/expo.ts
  • libs/port-offset/src/adapters/generic.ts
  • libs/port-offset/src/adapters/react-native.ts
  • libs/port-offset/src/adapters/registry.ts
  • libs/port-offset/src/config-persistence.ts
  • libs/port-offset/src/env-builder.ts
  • libs/port-offset/src/env-mapper.ts
  • libs/port-offset/src/hook-resolver.ts
  • libs/port-offset/src/hooks/README.md
  • libs/port-offset/src/hooks/libc/.gitignore
  • libs/port-offset/src/hooks/libc/build.zig
  • libs/port-offset/src/hooks/libc/interpose.c
  • libs/port-offset/src/hooks/libc/port-hook.zig
  • libs/port-offset/src/hooks/libc/smoke.sh
  • libs/port-offset/src/hooks/node/port-hook.ts
  • libs/port-offset/src/hooks/node/tsup.config.ts
  • libs/port-offset/src/index.ts
  • libs/port-offset/src/logger.ts
  • libs/port-offset/src/offset-allocator.ts
  • libs/port-offset/src/port-discovery.ts
  • libs/port-offset/src/port-manager.ts
  • libs/port-offset/src/types.ts
  • libs/port-offset/tsconfig.json
  • libs/port-offset/vitest.config.ts
  • libs/shared/README.md
  • libs/shared/package.json
  • libs/shared/src/__test__/activity-event.test.ts
  • libs/shared/src/__test__/commit-message.test.ts
  • libs/shared/src/__test__/detect-config.test.ts
  • libs/shared/src/__test__/git.test.ts
  • libs/shared/src/constants.ts
  • libs/shared/src/detect-config.ts
  • libs/shared/src/logger.ts
  • package.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/modular-port-offset-and-cleanup
📝 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 18, 2026 •

Copy link
Copy Markdown
Contributor

Clode Review

🔴 Major

(No major issues found.)

🟠 Medium

  1. enableDefaultProjectSkills is still a no-op stub called from apps/cli/src/init.ts — apps/server/src/lib/project-skill-bootstrap.ts remains a no-op with a comment saying "it can be removed once all call sites are cleaned up." This PR is the cleanup PR — the import and call in apps/cli/src/init.ts should be removed now rather than shipping dead code.

  2. libs/shared now depends on @openkit/logger — libs/shared/package.json adds a workspace dependency on @openkit/logger. Since shared is the lowest-level library imported by everything, this creates a potential circular dependency risk if logger ever imports from shared. The dependency graph should be verified to remain acyclic. Additionally, libs/shared/src/detect-config.ts now imports ./logger which loads the Go FFI logger — this changes behavior in environments where the Go shared library isn't built (e.g. CI without Go, test environments). The previous console.warn fallback was simpler and had no dependency.

  3. SkillDetailPanel still passes actions: null explicitly — apps/web-app/src/components/detail/SkillDetailPanel.tsx:384 passes actions: null where it previously conditionally rendered a diff button. This is dead prop noise — should be omitted entirely or the pathAnnotation type cleaned up.

  4. Port hook TypeScript source (port-hook.ts) uses import net from "net" — libs/port-offset/src/hooks/node/port-hook.ts:6 uses ESM import syntax, compiled to CJS via tsup for use with --require. While tsup handles the conversion, the runtime behavior depends on tsup correctly transpiling the ESM import to require("net"). The original .cjs file used require("net") directly, which was guaranteed to work. Worth verifying the tsup CJS output works correctly when injected via --require.

  5. useNativePortHook default flipped from opt-in to opt-out — apps/server/src/manager.ts:279 and :2154 change === true to !== false, and PortManager.useNativeHook defaults to true. This silently enables the native port hook for all existing users who haven't explicitly set the config flag. Should be called out in release notes.

🟡 Minor

  1. Inconsistent test directory naming — Some detail/ subdirectory tests (DetailPanel.test.tsx, NotesSection.test.tsx, TerminalView.test.tsx, TodoList.test.tsx) remain co-located in apps/web-app/src/components/detail/ rather than being moved to detail/__test__/, breaking the stated __test__/ convention that this PR codifies in CLAUDE.md.

  2. smoke script in root package.json runs all tasks with --parallel — pnpm nx run-many -t fix:format,fix:lint,check:types,build,test --parallel — build and test may have ordering dependencies (test relies on build output). Nx task-level dependsOn should handle this, but it's worth verifying that the --parallel at the run-many level still respects those.

  3. Python type stubs removed without replacement — libs/logger/python/__init__.pyi, bindings.pyi, and logger.pyi were deleted. The Python bindings moved to src/bindings/python/ but no new .pyi stubs were created. Python users lose IDE autocomplete.

  4. PerformancePage.test.tsx mock paths use relative ../../ — apps/web-app/src/components/__test__/PerformancePage.test.tsx:8-12 mocks ../../hooks/usePerformanceMetrics and ../../hooks/api. These are fragile relative paths. Consider module aliases.

  5. Missing newline at end of .gitignore — libs/logger/src/bindings/python/.gitignore is missing a trailing newline (line 1: __pycache__/ without \n).

🟢 Resolved

  1. verification-manager.test.ts mock path mismatch — Previously mocked ./logger but the test moved to __test__/. Now correctly mocks ../logger at apps/server/src/__test__/verification-manager.test.ts:8.

  2. css.d.ts moved to root of src/ — Confirmed moved from apps/web-app/src/types/css.d.ts to apps/web-app/src/css.d.ts.

  3. libs/logger Python type stubs removed — Tracked as a minor issue above; acknowledged as known.

@github-actions

github-actions Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Claude Review

🟡 Minor

  1. Dead code: enableDefaultProjectSkills no-op stub — apps/server/src/lib/project-skill-bootstrap.ts is still a no-op function with a comment saying "can be removed once all call sites are cleaned up." It's still called from apps/cli/src/init.ts. Consider removing it and its call site in this PR rather than leaving dead code.

  2. SkillDetailPanel hardcoded null actions — apps/web-app/src/components/detail/SkillDetailPanel.tsx now hardcodes actions: null in the pathAnnotation prop. The actions prop and its rendering logic in the receiving component could be simplified/removed if it's always null now.

  3. detail/ test files not moved to __test__/ — Tests in apps/web-app/src/components/detail/ (e.g., DetailPanel.test.tsx, NotesSection.test.tsx, TerminalView.test.tsx, TodoList.test.tsx) still live alongside source files rather than in a __test__/ directory. They were updated to use ../../__test__/render imports, so they're partially migrated, but the files themselves weren't moved — inconsistent with every other test directory in this PR.

  4. css.d.ts moved from types/ to root — apps/web-app/src/types/css.d.ts → apps/web-app/src/css.d.ts. Verify the types/ directory is cleaned up or still has other files.

  5. useNativePortHook default flipped — apps/server/src/manager.ts:279 changes from === true to !== false, making the native port hook enabled by default. This is a behavioral change for existing projects without useNativePortHook in their config. Confirm this is intentional.

  6. Logger python/.gitignore missing trailing newline — libs/logger/src/bindings/python/.gitignore has no trailing newline (__pycache__/ with no final newline). Minor but technically non-POSIX.

  7. Logger .gitignore deleted — verify coverage — The old libs/logger/.gitignore excluded liblogger.dylib, liblogger.so, etc. Build artifacts now go to dist/. Verify there's a .gitignore (or parent gitignore) covering libs/logger/dist/.

  8. Smoke command runs fix:* (mutating) alongside read-only checks — The pnpm smoke script runs fix:format,fix:lint,check:types,build,test. Running fix:* (which modifies files) in a "smoke" context is unexpected — smoke tests should be read-only. Consider using check:format,check:lint instead.

  9. Port-offset logger mock path mismatch — Several test files in libs/port-offset/src/__test__/ mock "./logger" (e.g., config-persistence.test.ts, env-builder.test.ts, hook-resolver.test.ts, port-manager.test.ts), but the actual logger import in the source files is "../logger" (one directory up from the __test__/ subdirectory). Vitest may resolve these correctly due to module resolution rules, but it's worth verifying these mocks actually intercept the right module. The adapter tests mock "../logger" which is correct relative to their __test__/ location.

  10. SITE_URL constant removed from shared, duplicated in website — libs/shared/src/constants.ts removed SITE_URL, and apps/website/src/constants.ts now defines it locally. Fine for now but worth noting if other packages need it later.

🟢 Resolved

  1. (From prior review) "Clode" typo in review workflow and skill — Fixed: Clode Review → Claude Review in .github/workflows/review-pull-request.yml and .claude/skills/address-pr-review/SKILL.md.

  2. (From prior review) All test files consistently moved to __test__/ directories — Server tests, web-app component tests, hook tests, and shared lib tests are all moved. (Exception: detail/ tests noted above in Minor build(deps): bump astro from 5.17.2 to 5.17.3 in /website #3.)

  3. (From prior review) Port manager and framework detection extracted to @openkit/port-offset with comprehensive test coverage — Tests are well-decomposed across offset-allocator.test.ts, env-builder.test.ts, env-mapper.test.ts, hook-resolver.test.ts, config-persistence.test.ts, port-manager.test.ts, and adapter-specific tests.

  4. (From prior review) Bundled skills removed cleanly — ensureBundledSkills, BUNDLED_SKILLS, builtIn field, and DiffEditor comparison all removed consistently across server, agents, web-app types, and vite config.

  5. (From prior review) Logger restructured with src/ layout — Go source, bindings, and build targets all moved under libs/logger/src/ with updated package.json exports and build scripts.

  6. (From prior review) Documentation updated — ARCHITECTURE.md, DEVELOPMENT.md, PORT-MAPPING.md, PROJECT_STRUCTURE.md all updated to reflect new paths. README files added for all apps and libs.

  7. (From prior review) CLAUDE.md and AGENTS.md kept in sync — Both files have identical changes (README requirement, __test__/ convention, workspace dependencies, configuration flags sections).

  8. (From prior review) Website dependency on @openkit/shared removed — Website now uses a local constants.ts instead of importing SITE_URL from shared.

@fum4

fum4 commented Mar 18, 2026

Copy link
Copy Markdown
Owner Author

/package

@github-actions

github-actions Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

📦 Packaging completed

Triggered by @fum4 with /package

View workflow logs

Target Status Artifact
macOS (Apple Silicon) 📦 Success Download
macOS (Intel) 📦 Success Download
Linux 📦 Success Download

@fum4
fum4 requested a review from LunatiqueCoder March 18, 2026 16:54
@fum4
fum4 merged commit 9cea8f8 into master Mar 18, 2026
19 checks passed
@fum4
fum4 deleted the refactor/modular-port-offset-and-cleanup branch March 18, 2026 16:55

This branch was previously deployed

1 inactive deployment
Preview — adc51e5c Deployed Mar 18, 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