Skip to content

Refactor option parser utilities into domain-focused modules with compatibility wrappers#3160

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-split-option-parsers
May 14, 2026
Merged

Refactor option parser utilities into domain-focused modules with compatibility wrappers#3160
lpcox merged 3 commits into
mainfrom
copilot/refactor-split-option-parsers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

✨ Enhancement

src/option-parsers.ts had grown into a 600+ line mixed-responsibility utility file spanning rate limits, host ports, DNS, shell escaping, and volume parsing. This change separates those concerns into focused parser modules while keeping current imports stable through the existing option-parsers entrypoint.

  • What does this improve?

    • Splits unrelated parsing logic into dedicated modules under src/parsers/:
      • rate-limit-parsers.ts
      • host-port-parsers.ts
      • dns-parsers.ts
      • shell-utils.ts
      • volume-parsers.ts
    • Reduces cognitive load in src/option-parsers.ts by removing “grab-bag” utility density.
    • Keeps function boundaries aligned to domain ownership, making future edits less conflict-prone.
  • Why is this valuable?

    • Improves discoverability and reviewability of parser logic by concern.
    • Prevents further accumulation of unrelated utilities in a single file.
    • Preserves existing caller behavior (main-action, network-setup, preflight, cli-options) without requiring import churn.
  • Implementation approach:

    • Moved domain-specific implementations into src/parsers/*.
    • Converted src/option-parsers.ts into a compatibility surface that delegates to the new modules for split domains, while retaining non-split functions (parseMemoryLimit, parseAgentTimeout, checkDockerHost, resolveDockerHostPathPrefix, parseModelMultipliersCli, formatItem, collectRulesetFile, validateSkipPullWithBuildLocal).
// src/option-parsers.ts (compatibility wrapper pattern)
import { parseDnsServers as parseDnsServersImpl } from './parsers/dns-parsers';

export function parseDnsServers(input: string): string[] {
  return parseDnsServersImpl(input);
}

Copilot AI changed the title [WIP] Refactor split src/option-parsers.ts into domain-focused modules Refactor option parser utilities into domain-focused modules with compatibility wrappers May 14, 2026
Copilot AI requested a review from lpcox May 14, 2026 16:06
Copilot finished work on behalf of lpcox May 14, 2026 16:06
@lpcox lpcox marked this pull request as ready for review May 14, 2026 16:26
@lpcox lpcox requested a review from Mossaka as a code owner May 14, 2026 16:26
Copilot AI review requested due to automatic review settings May 14, 2026 16:26
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the previously monolithic src/option-parsers.ts into domain-focused parser modules under src/parsers/, while keeping src/option-parsers.ts as a compatibility entrypoint that delegates to the new implementations.

Changes:

  • Added new domain-scoped parser/util modules under src/parsers/ (rate-limit, host ports, DNS, shell escaping, volumes).
  • Updated src/option-parsers.ts to delegate parsing/validation logic to the new modules while retaining existing exports.
  • Kept non-split option parsing logic in src/option-parsers.ts (e.g., memory/timeout/docker host checks, formatting, etc.).
Show a summary per file
File Description
src/parsers/volume-parsers.ts New parsing helpers for volume mounts (and currently env var parsing).
src/parsers/shell-utils.ts New shell argument escaping/joining utilities.
src/parsers/rate-limit-parsers.ts New rate limit config builder and flag validators.
src/parsers/host-port-parsers.ts New host port flag validators and config application helper.
src/parsers/dns-parsers.ts New DNS parsing and localhost keyword processing.
src/option-parsers.ts Compatibility wrapper delegating to the new parser modules.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

src/option-parsers.ts:289

  • Similarly, processLocalhostKeyword now exposes ReturnType<typeof processLocalhostKeywordImpl> in its exported signature. With declaration emit enabled, this ties the public type surface of src/option-parsers.ts to internal parser modules and reduces the intended encapsulation of the compatibility entrypoint. Consider spelling out the return shape explicitly here to keep the compatibility boundary stable.
export function processLocalhostKeyword(
  allowedDomains: string[],
  enableHostAccess: boolean,
  allowHostPorts: string | undefined
): ReturnType<typeof processLocalhostKeywordImpl> {
  return processLocalhostKeywordImpl(allowedDomains, enableHostAccess, allowHostPorts);
}
  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment thread src/option-parsers.ts Outdated
rateLimitRpm?: string;
rateLimitRph?: string;
rateLimitBytesPm?: string;
}): ReturnType<typeof buildRateLimitConfigImpl> {
Comment thread src/parsers/volume-parsers.ts Outdated
Comment on lines +3 to +8
/**
* Parses environment variables from an array of KEY=VALUE strings
*/
export function parseEnvironmentVariables(
envVars: string[]
): { success: true; env: Record<string, string> } | { success: false; invalidVar: string } {
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 14, 2026

@copilot address review feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 14, 2026

@copilot address review feedback

Addressed in commit 1d8c36f.

  • Replaced ReturnType<typeof ...Impl> in src/option-parsers.ts with explicit public return types.
  • Moved parseEnvironmentVariables into new src/parsers/env-parsers.ts and kept volume-parsers.ts focused on volume parsing.
  • Updated wrapper imports accordingly.

Copilot finished work on behalf of lpcox May 14, 2026 17:47
@github-actions
Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ❌ (401 Bad credentials)
GitHub.com HTTP ⚠️ (pre-step data not resolved)
File write/read ✅ (smoke-test-copilot-25875769850.txt verified)

Overall: FAIL — GitHub MCP auth unavailable in this run.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

❌ GitHub API: HTTP 401 authentication error
✅ Playwright: github.com navigation successful
✅ File verify: smoke-test file validated

FAIL (2/3 tests passed)

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Offline) Mode — PASS ✅

Test Result
GitHub MCP connectivity ❌ (401 — MCP token unavailable in sandbox)
GitHub.com HTTP connectivity
File write/read (smoke-test-copilot-byok-25875769919.txt)
BYOK inference (agent → api-proxy → api.githubcopilot.com)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com

Overall: PASS (MCP read unavailable due to sandbox credentials, all functional tests passed)

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

✅ GitHub PR review: Refactor API proxy request path into focused guard and transport modules; fix: remove dead re-exports of WrapperConfig component types
❌ safeinputs-gh PR query: tool unavailable
✅ Playwright title check: GitHub
❌ Tavily search: no search tool exposed
✅ File write: smoke-test-codex-25875769880.txt
✅ Bash cat: verified
⚠️ Discussion comment: skipped, github-discussion-query unavailable
✅ Build: npm ci && npm run build
Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Smoke Test Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.14.1 v20.20.2
Go go1.22.12 go1.22.12

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #3160 · ● 5.4M ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Gemini Engine Validation

  1. GitHub MCP Testing: ❌ (Tools mcpscripts or github not found/available)
  2. GitHub.com Connectivity: ❌ (HTTP 400 from Squid proxy / SSL Error 35)
  3. File Writing Testing: ✅ (Verified at /tmp/gh-aw/agent/smoke-test-gemini-25875769766.txt)
  4. Bash Tool Testing: ✅ (Verified basic execution and file reading)

Overall Status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

  • ❌ Redis (host.docker.internal:6379): timeout — no response
  • ❌ PostgreSQL pg_isready (host.docker.internal:5432): no response
  • ❌ PostgreSQL SELECT 1: skipped (host unreachable)

Overall: FAIL — service containers are not reachable from this runner environment.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit d0f77d4 into main May 14, 2026
64 of 68 checks passed
@lpcox lpcox deleted the copilot/refactor-split-option-parsers branch May 14, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactoring] Split src/option-parsers.ts utility grab-bag into domain-focused modules

3 participants