Repository navigation
Conversation
Replace the webhook setup script with a typed workspace CLI. Preserve the legacy entry point for existing automation. Add deterministic black-box and package-installation coverage. Test the control-plane flow against a pinned Yorkie release. Generated with OpenAI Codex.
|
|
📝 WalkthroughWalkthroughAdds the ChangesCodePair CLI
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant User
participant CodePairCLI
participant YorkieCLI
participant EnvFiles
User->>CodePairCLI: setup yorkie
CodePairCLI->>YorkieCLI: login and inspect project
YorkieCLI-->>CodePairCLI: project and webhook state
CodePairCLI->>YorkieCLI: create or update project webhook
CodePairCLI->>EnvFiles: atomically write Yorkie values
EnvFiles-->>CodePairCLI: persisted configuration
CodePairCLI-->>User: structured setup result
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (1)
packages/cli/LICENSE (1)
189-189: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUpdate the copyright placeholders.
The boilerplate text in the appendix still contains the
[yyyy]and[name of copyright owner]placeholders. Consider replacing these with the actual copyright details or removing the appendix if it's unnecessary.📝 Proposed fix to update the copyright
- Copyright [yyyy] [name of copyright owner] + Copyright 2026 CodePair Authors🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/LICENSE` at line 189, Update the copyright notice in the LICENSE appendix by replacing the [yyyy] and [name of copyright owner] placeholders with the project’s actual copyright year and owner, or remove the unnecessary appendix section entirely.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci_cli.yaml:
- Around line 51-52: Update the `actions/checkout@v4` step in the workflow to
set `persist-credentials` to false, while leaving the existing checkout behavior
unchanged.
In `@packages/cli/src/adapters/yorkie-cli.ts`:
- Around line 38-43: Update unwrapProjectRecords to reject the entire array when
any entry is not a non-null, non-array object, rather than filtering invalid
entries out; preserve the valid-array conversion and fail-closed behavior for
malformed responses. Add a regression test covering a mixed valid/invalid array
and verifying it is rejected without allowing project creation to proceed.
In `@packages/cli/src/checks/yorkie.ts`:
- Around line 127-139: Update the error handling around cli.listProjects() so
INVALID_YORKIE_PROJECT_JSON and INVALID_YORKIE_PROJECT_OUTPUT are reported as
incompatible Yorkie CLI/server output rather than connection failures. Preserve
the existing connection/login failure response for other errors, and provide
remediation directing users to check Yorkie CLI/server compatibility.
In `@packages/cli/src/core/env-file.ts`:
- Around line 14-27: Update decodeEnvValue to recognize and decode quoted values
before trailing inline comments, so inputs such as FOO="bar" # comment return
bar without surrounding quotes. Preserve the existing handling for single-quoted
and unquoted values, and ensure comments are ignored only after the quoted value
is extracted.
In `@packages/cli/src/core/output.ts`:
- Around line 19-25: Update writeResult so redactValue(result, secrets) is
computed and used before both the JSON and human-readable output branches.
Ensure doctor messages, setup actions, remediation text, and errors are rendered
from the redacted result while preserving the existing formatting behavior.
In `@packages/cli/src/core/redact.ts`:
- Around line 61-76: Update redactValueInternal’s traversal tracking so seen
only contains the current ancestor chain: after recursively processing an array
or object branch, remove the current value from seen before returning. Preserve
"[Circular]" for objects encountered while already in the active ancestor path,
while allowing repeated shared references in separate branches to be processed
normally.
In `@packages/cli/src/main.ts`:
- Around line 26-31: Keep the fallback error command label initialized to the
default command and do not derive it from raw argv or unparsed options when
extractGlobalOptions fails. Only update the command after successful global
parsing using recognized command tokens, preserving the default label for inputs
such as --json --root.
- Around line 33-50: Update the early version and help response branches in the
CLI entry flow to honor parsed.options.json. When --json is present, emit
exactly one valid structured JSON document for packageVersion(), helpFor(), or
MAIN_HELP; otherwise preserve the existing plain-text output. Ensure all
relevant branches—version, positional help, option help, and empty
arguments—follow this behavior.
In `@packages/cli/test/e2e/fixtures/fake-tool-bootstrap.cjs`:
- Around line 144-146: Update the event handling near
project.event_webhook_events so --event-webhook-events-add preserves existing
subscriptions and appends the requested event rather than replacing the list.
Ensure the event is added only once, while retaining the current empty-list
behavior when no event is provided.
In `@README.md`:
- Around line 34-37: Update the “Node.js Version Support” section to list only
the supported major versions, removing the “LTS,” “Active LTS,” and “Current”
lifecycle parentheticals while preserving the supported and dropped version
entries.
In `@scripts/setup-yorkie-webhook.js`:
- Around line 14-25: The legacy webhook wrapper must not unconditionally enable
insecure remote authentication. In scripts/setup-yorkie-webhook.js lines 14-25,
remove --allow-insecure-remote from the default delegation and require an
explicit user-controlled opt-in instead; in
packages/cli/test/e2e/package.test.mjs lines 25-64, update the successful legacy
delegation to use loopback and add coverage verifying non-loopback plaintext
login is refused.
---
Nitpick comments:
In `@packages/cli/LICENSE`:
- Line 189: Update the copyright notice in the LICENSE appendix by replacing the
[yyyy] and [name of copyright owner] placeholders with the project’s actual
copyright year and owner, or remove the unnecessary appendix section entirely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7a278cd3-e0af-4c73-9e2e-2fbdf5eaa2d3
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (52)
.github/workflows/ci_cli.yaml.husky/pre-commitMAINTAINING.mdREADME.mddocs/design/README.mddocs/design/cli.mdpackage.jsonpackages/backend/.env.examplepackages/backend/docker/docker-compose.ymlpackages/cli/.prettierignorepackages/cli/.prettierrcpackages/cli/LICENSEpackages/cli/README.mdpackages/cli/eslint.config.mjspackages/cli/package.jsonpackages/cli/src/adapters/network.tspackages/cli/src/adapters/yorkie-cli.tspackages/cli/src/checks/context.tspackages/cli/src/checks/env.tspackages/cli/src/checks/services.tspackages/cli/src/checks/toolchain.tspackages/cli/src/checks/yorkie.tspackages/cli/src/cli.tspackages/cli/src/commands/doctor.tspackages/cli/src/commands/setup-yorkie.tspackages/cli/src/core/args.tspackages/cli/src/core/env-file.tspackages/cli/src/core/errors.tspackages/cli/src/core/output.tspackages/cli/src/core/process.tspackages/cli/src/core/project-root.tspackages/cli/src/core/prompt.tspackages/cli/src/core/redact.tspackages/cli/src/core/url.tspackages/cli/src/help.tspackages/cli/src/main.tspackages/cli/src/types.tspackages/cli/test/e2e/cli.test.mjspackages/cli/test/e2e/fixtures/fake-tool-bootstrap.cjspackages/cli/test/e2e/helpers/cli-harness.mjspackages/cli/test/e2e/package.test.mjspackages/cli/test/e2e/setup.test.mjspackages/cli/test/helpers/environment.mjspackages/cli/test/integration/yorkie.test.mjspackages/cli/test/unit/env-file.test.mjspackages/cli/test/unit/options.test.mjspackages/cli/test/unit/process-services.test.mjspackages/cli/test/unit/url-redact.test.mjspackages/cli/test/unit/yorkie-cli.test.mjspackages/cli/tsconfig.jsonpackages/frontend/.env.examplescripts/setup-yorkie-webhook.js
| - name: Checkout 🛎️ | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Disable credential persistence in the checkout action.
By default, the actions/checkout action persists the GitHub token in the local git configuration. Because this workflow only runs tests and builds—and does not push commits back to the repository—setting persist-credentials: false improves the pipeline's security posture by preventing potential credential leakage in the event of compromised dependencies or downstream command injection.
🔒️ Proposed fix to disable credential persistence
- name: Checkout 🛎️
uses: actions/checkout@v4
+ with:
+ persist-credentials: false📝 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.
| - name: Checkout 🛎️ | |
| uses: actions/checkout@v4 | |
| - name: Checkout 🛎️ | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false |
🧰 Tools
🪛 zizmor (1.26.1)
[warning] 51-52: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/ci_cli.yaml around lines 51 - 52, Update the
`actions/checkout@v4` step in the workflow to set `persist-credentials` to
false, while leaving the existing checkout behavior unchanged.
Source: Linters/SAST tools
| function unwrapProjectRecords(value: unknown): Record<string, unknown>[] { | ||
| if (Array.isArray(value)) { | ||
| return value.filter( | ||
| (entry): entry is Record<string, unknown> => | ||
| typeof entry === "object" && entry !== null && !Array.isArray(entry) | ||
| ); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Reject malformed project entries instead of silently dropping them.
A partially malformed Yorkie response becomes an incomplete valid list. Setup may then treat an existing project as absent and issue a mutating project create command. Validate every array entry and fail closed; add a mixed valid/invalid-array regression test.
Proposed fix
if (Array.isArray(value)) {
- return value.filter(
- (entry): entry is Record<string, unknown> =>
- typeof entry === "object" && entry !== null && !Array.isArray(entry)
- );
+ const records: Record<string, unknown>[] = [];
+ for (const entry of value) {
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
+ throw new OperationalError(
+ "Yorkie project list contains an invalid project entry.",
+ "INVALID_YORKIE_PROJECT_OUTPUT"
+ );
+ }
+ records.push(entry as Record<string, unknown>);
+ }
+ return records;
}📝 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.
| function unwrapProjectRecords(value: unknown): Record<string, unknown>[] { | |
| if (Array.isArray(value)) { | |
| return value.filter( | |
| (entry): entry is Record<string, unknown> => | |
| typeof entry === "object" && entry !== null && !Array.isArray(entry) | |
| ); | |
| function unwrapProjectRecords(value: unknown): Record<string, unknown>[] { | |
| if (Array.isArray(value)) { | |
| const records: Record<string, unknown>[] = []; | |
| for (const entry of value) { | |
| if (typeof entry !== "object" || entry === null || Array.isArray(entry)) { | |
| throw new OperationalError( | |
| "Yorkie project list contains an invalid project entry.", | |
| "INVALID_YORKIE_PROJECT_OUTPUT" | |
| ); | |
| } | |
| records.push(entry as Record<string, unknown>); | |
| } | |
| return records; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/adapters/yorkie-cli.ts` around lines 38 - 43, Update
unwrapProjectRecords to reject the entire array when any entry is not a
non-null, non-array object, rather than filtering invalid entries out; preserve
the valid-array conversion and fail-closed behavior for malformed responses. Add
a regression test covering a mixed valid/invalid array and verifying it is
rejected without allowing project creation to proceed.
| let projects; | ||
| try { | ||
| projects = await cli.listProjects(); | ||
| } catch { | ||
| return [ | ||
| { | ||
| id: "yorkie.connection", | ||
| scope: "yorkie", | ||
| status: "fail", | ||
| message: `Could not list Yorkie projects at ${endpoint.rpcAddress}.`, | ||
| remediation: "Run codepair setup yorkie or log in with Yorkie CLI.", | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve incompatible-output failures instead of reporting them as connection errors.
listProjects() can throw INVALID_YORKIE_PROJECT_JSON or INVALID_YORKIE_PROJECT_OUTPUT, but this catch reports both as connectivity/login failures. Distinguish parser errors and recommend checking Yorkie CLI/server compatibility.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/checks/yorkie.ts` around lines 127 - 139, Update the error
handling around cli.listProjects() so INVALID_YORKIE_PROJECT_JSON and
INVALID_YORKIE_PROJECT_OUTPUT are reported as incompatible Yorkie CLI/server
output rather than connection failures. Preserve the existing connection/login
failure response for other errors, and provide remediation directing users to
check Yorkie CLI/server compatibility.
| function decodeEnvValue(raw: string): string { | ||
| const trimmed = raw.trim(); | ||
| if (trimmed.startsWith('"') && trimmed.endsWith('"')) { | ||
| try { | ||
| return JSON.parse(trimmed) as string; | ||
| } catch { | ||
| return trimmed.slice(1, -1); | ||
| } | ||
| } | ||
| if (trimmed.startsWith("'") && trimmed.endsWith("'")) { | ||
| return trimmed.slice(1, -1); | ||
| } | ||
| return trimmed.replace(/\s+#.*$/, "").trim(); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Handle trailing comments on quoted values.
The decodeEnvValue function incorrectly retains the surrounding quotes if a quoted value includes a trailing inline comment (e.g., FOO="bar" # comment). Because the trimmed string ends with # comment rather than ", the endsWith('"') check fails, causing it to fall through to the bare-value handler which returns the literal string "bar".
Consider using a regular expression to cleanly extract the quoted section independently of any trailing comments.
🐛 Proposed fix to handle quotes and comments correctly
function decodeEnvValue(raw: string): string {
const trimmed = raw.trim();
- if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
+
+ const doubleQuoteMatch = trimmed.match(/^"((?:[^"\\]|\\.)*)"(?:\s+#.*)?$/);
+ if (doubleQuoteMatch) {
try {
- return JSON.parse(trimmed) as string;
+ return JSON.parse(`"${doubleQuoteMatch[1]}"`) as string;
} catch {
- return trimmed.slice(1, -1);
+ return doubleQuoteMatch[1];
}
}
- if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
- return trimmed.slice(1, -1);
+
+ const singleQuoteMatch = trimmed.match(/^'([^']*)'(?:\s+#.*)?$/);
+ if (singleQuoteMatch) {
+ return singleQuoteMatch[1];
}
+
return trimmed.replace(/\s+#.*$/, "").trim();
}📝 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.
| function decodeEnvValue(raw: string): string { | |
| const trimmed = raw.trim(); | |
| if (trimmed.startsWith('"') && trimmed.endsWith('"')) { | |
| try { | |
| return JSON.parse(trimmed) as string; | |
| } catch { | |
| return trimmed.slice(1, -1); | |
| } | |
| } | |
| if (trimmed.startsWith("'") && trimmed.endsWith("'")) { | |
| return trimmed.slice(1, -1); | |
| } | |
| return trimmed.replace(/\s+#.*$/, "").trim(); | |
| } | |
| function decodeEnvValue(raw: string): string { | |
| const trimmed = raw.trim(); | |
| const doubleQuoteMatch = trimmed.match(/^"((?:[^"\\]|\\.)*)"(?:\s+#.*)?$/); | |
| if (doubleQuoteMatch) { | |
| try { | |
| return JSON.parse(`"${doubleQuoteMatch[1]}"`) as string; | |
| } catch { | |
| return doubleQuoteMatch[1]; | |
| } | |
| } | |
| const singleQuoteMatch = trimmed.match(/^'([^']*)'(?:\s+#.*)?$/); | |
| if (singleQuoteMatch) { | |
| return singleQuoteMatch[1]; | |
| } | |
| return trimmed.replace(/\s+#.*$/, "").trim(); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/core/env-file.ts` around lines 14 - 27, Update
decodeEnvValue to recognize and decode quoted values before trailing inline
comments, so inputs such as FOO="bar" # comment return bar without surrounding
quotes. Preserve the existing handling for single-quoted and unquoted values,
and ensure comments are ignored only after the quoted value is extracted.
| export function writeResult( | ||
| result: ResultEnvelope, | ||
| json: boolean, | ||
| secrets: Iterable<string> = [] | ||
| ): void { | ||
| if (json) { | ||
| process.stdout.write(`${JSON.stringify(redactValue(result, secrets), null, 2)}\n`); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Apply redaction to human-readable output too.
secrets is only used by the JSON branch. Doctor messages, setup actions, remediation text, and errors can therefore print a supplied secret verbatim in normal mode. Redact the result before either output path.
Also applies to: 29-56
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/core/output.ts` around lines 19 - 25, Update writeResult so
redactValue(result, secrets) is computed and used before both the JSON and
human-readable output branches. Ensure doctor messages, setup actions,
remediation text, and errors are rendered from the redacted result while
preserving the existing formatting behavior.
| let json = argv.includes("--json"); | ||
| let remaining: string[] = [...argv]; | ||
| try { | ||
| const parsed = extractGlobalOptions(argv); | ||
| json = parsed.options.json; | ||
| remaining = parsed.remaining; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not derive the error command from unparsed options.
When global parsing fails, remaining still contains raw arguments. For example, --json --root produces an error envelope whose command is "--json" rather than "codepair". Keep the fallback label until parsing succeeds or derive it from recognized command tokens.
Also applies to: 74-83
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/main.ts` around lines 26 - 31, Keep the fallback error
command label initialized to the default command and do not derive it from raw
argv or unparsed options when extractGlobalOptions fails. Only update the
command after successful global parsing using recognized command tokens,
preserving the default label for inputs such as --json --root.
| if (parsed.options.version || remaining[0] === "version") { | ||
| process.stdout.write(`${await packageVersion()}\n`); | ||
| return 0; | ||
| } | ||
|
|
||
| if (remaining[0] === "help") { | ||
| process.stdout.write(helpFor(remaining.slice(1))); | ||
| return 0; | ||
| } | ||
|
|
||
| if (parsed.options.help) { | ||
| process.stdout.write(helpFor(remaining)); | ||
| return 0; | ||
| } | ||
|
|
||
| if (remaining.length === 0) { | ||
| process.stdout.write(MAIN_HELP); | ||
| return 0; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Honor --json for help and version responses.
These early branches emit plain text even when --json is present, violating the documented “one structured JSON document” contract and breaking automation expecting valid JSON.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/main.ts` around lines 33 - 50, Update the early version and
help response branches in the CLI entry flow to honor parsed.options.json. When
--json is present, emit exactly one valid structured JSON document for
packageVersion(), helpFor(), or MAIN_HELP; otherwise preserve the existing
plain-text output. Ensure all relevant branches—version, positional help, option
help, and empty arguments—follow this behavior.
| project.event_webhook_url = flagValue(args, "--event-webhook-url") || ""; | ||
| const event = flagValue(args, "--event-webhook-events-add"); | ||
| project.event_webhook_events = event ? [event] : []; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
rg -n -C4 -- \
'--event-webhook-events-add|event_webhook_events' \
packages/cli/src packages/cli/testRepository: yorkie-team/codepair
Length of output: 5711
🏁 Script executed:
#!/bin/bash
set -eu
# Inspect the relevant fixture and the tests that depend on its webhook behavior.
sed -n '1,260p' packages/cli/test/e2e/fixtures/fake-tool-bootstrap.cjs
printf '\n--- setup.test.mjs ---\n'
sed -n '1,180p' packages/cli/test/e2e/setup.test.mjs
printf '\n--- cli-harness.mjs ---\n'
sed -n '150,230p' packages/cli/test/e2e/helpers/cli-harness.mjs
printf '\n--- yorkie-cli.ts excerpt ---\n'
sed -n '110,170p' packages/cli/src/adapters/yorkie-cli.tsRepository: yorkie-team/codepair
Length of output: 15872
🏁 Script executed:
#!/bin/bash
set -eu
# Find the setup flow that decides when webhook configuration runs.
rg -n -C4 -- 'configureEventWebhook|event_webhook_events|event-webhook-events-add|yorkie\.webhook|webhook' packages/cli/src packages/cli/testRepository: yorkie-team/codepair
Length of output: 41660
🌐 Web query:
Yorkie CLI project update --event-webhook-events-add additive preserve existing webhook events
💡 Result:
Yes, the --event-webhook-events-add flag in the Yorkie CLI is designed to be additive, meaning it preserves existing webhook events while adding new ones to the configuration [1][2]. When you run the yorkie project update command with the --event-webhook-events-add flag, the specified events are appended to the project's current list of active webhook events [3][1]. Similarly, the CLI provides a corresponding --event-webhook-events-rm flag if you need to explicitly remove specific events from the configuration [1][2]. For example, to add an event to an existing configuration without affecting the ones already set, you can use: yorkie project update [project-name] --event-webhook-events-add "DocumentRootChanged" This behavior is consistent across similar CLI operations in Yorkie, such as managing authentication webhook methods with the --auth-webhook-method-add and --auth-webhook-method-rm flags [1].
Citations:
- 1: https://github.com/yorkie-team/yorkie-team.github.io/blob/main/docs/tools/cli.mdx
- 2: https://yorkie.dev/docs/tools/cli
- 3: https://github.com/yorkie-team/yorkie-team.github.io/blob/main/docs/advanced/event-webhook.mdx
Model --event-webhook-events-add as additive. packages/cli/test/e2e/fixtures/fake-tool-bootstrap.cjs:144-146 currently overwrites event_webhook_events with a single item, which drops any preexisting subscriptions. Preserve the existing list and append the requested event once so the fixture matches Yorkie’s behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/test/e2e/fixtures/fake-tool-bootstrap.cjs` around lines 144 -
146, Update the event handling near project.event_webhook_events so
--event-webhook-events-add preserves existing subscriptions and appends the
requested event rather than replacing the list. Ensure the event is added only
once, while retaining the current empty-list behavior when no event is provided.
| ## Node.js Version Support | ||
|
|
||
| - **Supported:** **20.x (LTS)**, **22.x (Active LTS)**, **24.x (Current)** | ||
| - **Dropped:** **18.x** (End-of-life) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
jq '.engines.node // empty' package.json packages/cli/package.jsonRepository: yorkie-team/codepair
Length of output: 178
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\nREADME excerpt:\n'
sed -n '30,42p' README.md
printf '\nPackage engine constraints:\n'
jq -r '.engines.node // empty' package.json packages/cli/package.jsonRepository: yorkie-team/codepair
Length of output: 795
Remove the Node.js lifecycle labels
The supported majors already match the package engine range, but the (LTS)/(Active LTS)/(Current) parentheticals are time-sensitive and will drift; list the supported versions without lifecycle labels instead.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` around lines 34 - 37, Update the “Node.js Version Support” section
to list only the supported major versions, removing the “LTS,” “Active LTS,” and
“Current” lifecycle parentheticals while preserving the supported and dropped
version entries.
| const cliArguments = [ | ||
| "cli", | ||
| "setup", | ||
| "yorkie", | ||
| "--yes", | ||
| "--allow-insecure-remote", | ||
| ]; | ||
| const command = | ||
| process.platform === "win32" ? process.env.ComSpec || "cmd.exe" : "pnpm"; | ||
| const commandArguments = | ||
| process.platform === "win32" | ||
| ? ["/d", "/s", "/c", "pnpm cli setup yorkie --yes --allow-insecure-remote"] |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
The legacy compatibility path bypasses remote transport safety. The wrapper silently opts into insecure remote authentication, and its E2E test makes that behavior mandatory.
scripts/setup-yorkie-webhook.js#L14-L25: remove unconditional--allow-insecure-remote; require an explicit user-controlled opt-in.packages/cli/test/e2e/package.test.mjs#L25-L64: use loopback for successful legacy delegation and test that non-loopback plaintext login is refused.
📍 Affects 2 files
scripts/setup-yorkie-webhook.js#L14-L25(this comment)packages/cli/test/e2e/package.test.mjs#L25-L64
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/setup-yorkie-webhook.js` around lines 14 - 25, The legacy webhook
wrapper must not unconditionally enable insecure remote authentication. In
scripts/setup-yorkie-webhook.js lines 14-25, remove --allow-insecure-remote from
the default delegation and require an explicit user-controlled opt-in instead;
in packages/cli/test/e2e/package.test.mjs lines 25-64, update the successful
legacy delegation to use loopback and add coverage verifying non-loopback
plaintext login is refused.
|
Closing this in favor of a product-facing CLI that operates through CodePair's application API. The current contributor setup CLI does not match the intended user workflow. |
What this PR does / why we need it:
This PR adds a typed, repository-local CLI for setting up and diagnosing a CodePair development environment.
The primary contributor workflows are:
setup yorkiecreates or reuses the selected Yorkie project, configures theDocumentRootChangedwebhook, writes the Yorkie addresses and project keys to the development environment files, and verifies the resulting state. Missing environment files are seeded from checked-in examples. Re-running the command is idempotent.doctorprovides read-only checks for the supported toolchain, environment configuration, local services, and Yorkie project state. Both commands support structured JSON output and stable exit codes for automation.The previous webhook script was difficult to extend safely because setup, process execution, environment-file mutation, and output handling were coupled in one untyped file. The new package separates argument parsing, process execution, Yorkie access, environment-file handling, diagnostics, networking, prompting, and output formatting into focused modules.
The CLI is intentionally:
Compatibility and application boundaries:
pnpm setup:webhookremains available and delegates to the new implementation.YORKIE_API_ADDR,YORKIE_PROJECT_SECRET_KEY,VITE_YORKIE_API_ADDR, andVITE_YORKIE_API_KEY. Existing comments, OAuth credentials, JWT settings, AI provider settings, storage configuration, and other values are preserved.host.docker.internalhost-gateway mapping for local development, allowing the Yorkie container to reach the host backend.docker-compose-full.ymlare unchanged.Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
Security and failure handling:
--secure.--yes, and--dry-runvalidates prerequisites and reports the plan without changing state.Yorkie currently accepts its password through
yorkie login -p.--password-stdinkeeps the password out of the CodePair command line, but the child Yorkie process may expose it briefly to same-host process inspection. This is documented, and setup should only be run on a trusted development machine.Validation completed:
pnpm --filter=@codepair/cli verifycodepairbinary, validates package contents, and confirms internal deep imports are blocked.doctorverification from the written environment files.docker compose config.The real-Yorkie test validates the control-plane workflow. It does not start the complete CodePair application or assert delivery of an actual document-change webhook through the backend.
The dedicated CLI workflow covers Ubuntu/Node.js 22, macOS/Node.js 20, and Windows/Node.js 24. This covers every supported operating system and Node.js major without a nine-job Cartesian matrix. The Linux job additionally verifies both Compose files and runs against a checksum-verified Yorkie CLI archive and digest-pinned Yorkie server image.
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
🤖 Generated with OpenAI Codex.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes