This repository was archived by the owner on Nov 8, 2026. It is now read-only.
Repository navigation
Add CodePair developer setup CLI #607
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| name: CI CLI | ||
| on: | ||
| push: | ||
| branches: main | ||
| paths: | ||
| - ".github/workflows/ci_cli.yaml" | ||
| - "packages/backend/.env.example" | ||
| - "packages/backend/docker/docker-compose*.yml" | ||
| - "packages/cli/**" | ||
| - "packages/frontend/.env.example" | ||
| - "package.json" | ||
| - "pnpm-lock.yaml" | ||
| - "pnpm-workspace.yaml" | ||
| - "scripts/setup-yorkie-webhook.js" | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - ".github/workflows/ci_cli.yaml" | ||
| - "packages/backend/.env.example" | ||
| - "packages/backend/docker/docker-compose*.yml" | ||
| - "packages/cli/**" | ||
| - "packages/frontend/.env.example" | ||
| - "package.json" | ||
| - "pnpm-lock.yaml" | ||
| - "pnpm-workspace.yaml" | ||
| - "scripts/setup-yorkie-webhook.js" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 20 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| node-version: 22.x | ||
| integration: true | ||
| - os: macos-latest | ||
| node-version: 20.x | ||
| integration: false | ||
| - os: windows-latest | ||
| node-version: 24.x | ||
| integration: false | ||
| steps: | ||
| - name: Checkout 🛎️ | ||
| uses: actions/checkout@v4 | ||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: "pnpm" | ||
| - name: Install packages | ||
| run: pnpm install --frozen-lockfile --filter @codepair/cli --ignore-scripts | ||
| - name: Prettier | ||
| run: pnpm --filter=@codepair/cli format:check | ||
| - name: Integration file formatting | ||
| run: >- | ||
| pnpm --filter=@codepair/cli exec prettier --check | ||
| ../../README.md | ||
| ../../docs/design/cli.md | ||
| ../../scripts/setup-yorkie-webhook.js | ||
| ../../.github/workflows/ci_cli.yaml | ||
| - name: Lint | ||
| run: pnpm --filter=@codepair/cli lint | ||
| - name: Typecheck | ||
| run: pnpm --filter=@codepair/cli typecheck | ||
| - name: Unit tests | ||
| run: pnpm --filter=@codepair/cli test | ||
| - name: End-to-end tests | ||
| run: pnpm --filter=@codepair/cli test:e2e | ||
| - name: Check package contents | ||
| run: pnpm --filter=@codepair/cli pack:check | ||
| - name: Validate Docker Compose files | ||
| if: matrix.integration | ||
| run: | | ||
| docker compose -f packages/backend/docker/docker-compose.yml config --quiet | ||
| docker compose -f packages/backend/docker/docker-compose-full.yml config --quiet | ||
| - name: Install Yorkie CLI | ||
| if: matrix.integration | ||
| shell: bash | ||
| run: | | ||
| archive="$RUNNER_TEMP/yorkie-v0.7.12-linux-amd64.tar.gz" | ||
| install_dir="$RUNNER_TEMP/yorkie-cli" | ||
| curl --fail --location --retry 3 \ | ||
| --output "$archive" \ | ||
| https://github.com/yorkie-team/yorkie/releases/download/v0.7.12/yorkie-v0.7.12-linux-amd64.tar.gz | ||
| echo "a111367beeee9925248c506c11a8a8c9cb8dca0b48c79d542dbce6b66f88a4d9 $archive" \ | ||
| | sha256sum --check | ||
| mkdir -p "$install_dir" | ||
| tar --extract --gzip --file "$archive" --directory "$install_dir" \ | ||
| --strip-components=1 | ||
| echo "$install_dir" >> "$GITHUB_PATH" | ||
| - name: Start Yorkie server | ||
| if: matrix.integration | ||
| shell: bash | ||
| run: | | ||
| docker run --detach --name codepair-cli-yorkie \ | ||
| --publish 18080:8080 \ | ||
| yorkieteam/yorkie@sha256:f20f8d3604397156883bda4aa0e2951e5e537656af9a59fd1f34f591ac8206f3 \ | ||
| server --pprof-enabled | ||
| for attempt in {1..30}; do | ||
| if (echo > /dev/tcp/127.0.0.1/18080) >/dev/null 2>&1; then | ||
| exit 0 | ||
| fi | ||
| sleep 1 | ||
| done | ||
| docker logs codepair-cli-yorkie | ||
| exit 1 | ||
| - name: Real Yorkie integration test | ||
| if: matrix.integration | ||
| env: | ||
| CODEPAIR_YORKIE_RPC_ADDR: 127.0.0.1:18080 | ||
| run: pnpm --filter=@codepair/cli test:integration | ||
| - name: Yorkie logs | ||
| if: ${{ always() && matrix.integration }} | ||
| run: docker logs codepair-cli-yorkie || true | ||
| - name: Stop Yorkie server | ||
| if: ${{ always() && matrix.integration }} | ||
| run: docker rm --force codepair-cli-yorkie || true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,19 +29,53 @@ This repository contains multiple packages that make up our project, organized a | |
| - **`@codepair/backend`**: NestJS API server. See [packages/backend/README.md](packages/backend/README.md) for details. | ||
| - **`@codepair/codemirror`**: CodeMirror 6 editor with Yorkie sync, toolbar, preview. Self-contained vertical slice. | ||
| - **`@codepair/ui`**: Shared types (`EditorPort`, `EditorModeType`, `PresenceInfo`) and pure UI components. | ||
| - **`@codepair/cli`**: Node.js CLI for local CodePair setup and Yorkie webhook configuration. | ||
|
|
||
| ## Node.js Version Support | ||
|
|
||
| - **Supported:** **20.x (LTS)**, **22.x (Active LTS)**, **24.x (Current)** | ||
| - **Dropped:** **18.x** (End-of-life) | ||
|
Comment on lines
34
to
37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 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 🤖 Prompt for AI Agents |
||
|
|
||
| ## Command-Line Interface | ||
|
|
||
| After installing the workspace dependencies, run the CLI from the repository root: | ||
|
|
||
| ```bash | ||
| pnpm cli --help | ||
| pnpm cli setup yorkie | ||
| pnpm cli doctor | ||
| ``` | ||
|
|
||
| The setup command creates or reuses the local Yorkie project, configures its event webhook, and | ||
| synchronizes the Yorkie addresses and project keys in the development environment files. Its | ||
| default webhook URL is `http://host.docker.internal:3000/yorkie/document-events`, which lets the | ||
| Yorkie container reach the backend through its published port. Override it when your backend is | ||
| reachable elsewhere: | ||
|
|
||
| ```bash | ||
| pnpm cli setup yorkie --webhook-url http://your-backend:3000/yorkie/document-events | ||
| ``` | ||
|
|
||
| This workflow is intended for **Full Stack Development Mode**, where the backend runs on the host. | ||
| Frontend-only mode uses the services configured directly in `docker-compose-full.yml`. | ||
|
|
||
| For backward compatibility, the non-interactive webhook setup command remains available: | ||
|
|
||
| ```bash | ||
| pnpm setup:webhook | ||
| ``` | ||
|
|
||
| This delegates to the CLI non-interactively while retaining the legacy command's defaults. New | ||
| automation should call `pnpm cli setup yorkie --yes` directly. | ||
|
|
||
| ## Getting Started with Development | ||
|
|
||
| ### 1. Set Up GitHub OAuth Key | ||
|
|
||
| For the Social Login feature, you need to obtain a GitHub OAuth key before running the project. Please refer to [this document](./docs/1_Set_Up_GitHub_OAuth_Key.md) for guidance. | ||
|
|
||
| After completing this step, you should have the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` values. | ||
| After completing this step, you should have the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` | ||
| values. | ||
|
|
||
| ### 2. Choose Running Mode | ||
|
|
||
|
|
@@ -85,17 +119,21 @@ We offer two options. Choose the one that best suits your needs: | |
|
|
||
| ### 3-2. Full Stack Development Mode | ||
|
|
||
| 1. Update your `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` to `./packages/backend/.env.development`. | ||
| 1. Copy the environment examples if they are missing, then add your GitHub OAuth values to | ||
| `./packages/backend/.env.development`. | ||
|
|
||
| ```bash | ||
| vi ./packages/backend/.env.development | ||
| cp -n packages/backend/.env.example packages/backend/.env.development | ||
| cp -n packages/frontend/.env.example packages/frontend/.env.development | ||
|
|
||
| # In the file, update the following values: | ||
| # GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET | ||
| # Edit packages/backend/.env.development: | ||
| GITHUB_CLIENT_ID=your_github_client_id_here | ||
| GITHUB_CLIENT_SECRET=your_github_client_secret_here | ||
| ``` | ||
|
|
||
| The setup CLI only updates the Yorkie addresses and project keys. It preserves OAuth | ||
| credentials, JWT settings, and every other existing value. | ||
|
|
||
| 2. Run `./packages/backend/docker/docker-compose.yml`. | ||
|
|
||
| ```bash | ||
|
|
@@ -111,7 +149,7 @@ We offer two options. Choose the one that best suits your needs: | |
| 4. Set up the Yorkie webhook: | ||
|
|
||
| ```bash | ||
| pnpm setup:webhook | ||
| pnpm cli setup yorkie --yes | ||
| ``` | ||
|
|
||
| 5. Run the Backend application and the Frontend application: | ||
|
|
@@ -130,6 +168,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the co | |
| ## Documentation | ||
|
|
||
| - [docs/design/](docs/design/README.md) — Architectural design documents | ||
| - [docs/design/cli.md](docs/design/cli.md) — CLI design and integration | ||
| - [docs/tasks/](docs/tasks/README.md) — Task tracking (active and archived) | ||
| - [docs/editor-port-architecture.md](docs/editor-port-architecture.md) — Editor port architecture overview | ||
| - [packages/frontend/design/](packages/frontend/design/README.md) — Frontend-specific design docs | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ New design documents should be based on [TEMPLATE.md](TEMPLATE.md). | |
|
|
||
| ## Contents | ||
|
|
||
| (none) | ||
| - [CodePair CLI](cli.md) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| created: 2026-07-15 | ||
| updated: 2026-07-15 | ||
| tags: [cli, developer-tooling] | ||
| --- | ||
|
|
||
| # CodePair CLI | ||
|
|
||
| ## Problem | ||
|
|
||
| Local CodePair setup was implemented as a standalone JavaScript script. It was not typed, | ||
| packaged, or easy to validate across the operating systems and Node.js versions that CodePair | ||
| supports. Adding more setup operations to that script would make its command surface and failure | ||
| handling increasingly difficult to maintain. | ||
|
|
||
| ### Goals | ||
|
|
||
| - Provide a typed Node.js CLI in the pnpm workspace. | ||
| - Offer clear setup and diagnostic commands for contributors and automation. | ||
| - Preserve the existing `pnpm setup:webhook` workflow. | ||
| - Validate the built and installed package across the supported Node.js versions and operating systems. | ||
|
|
||
| ### Non-Goals | ||
|
|
||
| - Replace the Yorkie CLI or Yorkie server. | ||
| - Change the frontend or backend runtime architecture. | ||
| - Provide production deployment orchestration. | ||
|
|
||
| ## Design | ||
|
|
||
| The CLI lives in `packages/cli` as `@codepair/cli`. Contributors invoke it from the repository | ||
| root with `pnpm cli <arguments>`, which delegates to the package's development entry point. | ||
| `setup yorkie` owns local Yorkie project and webhook configuration, while `doctor` reports | ||
| toolchain, environment, service, and Yorkie readiness. | ||
|
|
||
| The existing `pnpm setup:webhook` command remains a non-interactive compatibility entry point. Its | ||
| root-level wrapper preserves the legacy webhook default and trusted-remote behavior, then delegates | ||
| to the CLI, which is the only implementation of the workflow. New automation should invoke | ||
| `pnpm cli setup yorkie --yes` and opt into any remote plaintext transport explicitly. | ||
|
|
||
| When development environment files do not exist, setup seeds them from the checked-in | ||
| `.env.example` files. It then writes only the selected Yorkie addresses and project keys, leaving | ||
| OAuth, JWT, AI provider, and storage settings untouched. The default webhook uses | ||
| `host.docker.internal` so Yorkie running in Docker can reach the backend's published host port; | ||
| `--webhook-url` supports other network layouts. | ||
|
|
||
| Commands return `0` on success, `1` for operational or diagnostic failure or an explicit user | ||
| decline, and `2` for invalid usage, safety validation, or a required confirmation in a non-TTY | ||
| environment. Both setup and doctor support structured JSON output so automation does not need to | ||
| parse human-readable messages. | ||
|
|
||
| CI pairs Linux, macOS, and Windows with Node.js 22, 20, and 24 respectively, covering every | ||
| supported operating system and Node.js major with three jobs rather than a nine-job Cartesian | ||
| matrix. Each job runs formatting, linting, type checking, unit tests, end-to-end tests, and an | ||
| installed-package smoke test. The Linux job also runs control-plane setup, idempotency, and doctor | ||
| checks against pinned Yorkie CLI and server releases. | ||
|
|
||
| ### Risks and Mitigation | ||
|
|
||
| | Risk | Mitigation | | ||
| | --------------------------------------------------------- | --------------------------------------------------------------------------------------------- | | ||
| | The compatibility command changes behavior | Preserve its legacy webhook and plaintext-remote defaults in the wrapper and test both paths. | | ||
| | The CLI works in the workspace but not after packaging | Install and execute the packed artifact in CI on all supported platforms. | | ||
| | Platform-specific process or path behavior regresses | Run the CLI validation suite on Ubuntu, macOS, and Windows. | | ||
| | A fake Yorkie misses a protocol or configuration mismatch | Run one pinned real-Yorkie integration path on Linux. | | ||
| | The container cannot reach a host backend | Add a host gateway mapping and use a container-reachable default webhook URL. | | ||
|
|
||
| ### Design Decisions | ||
|
|
||
| | Decision | Reason | | ||
| | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | Place the CLI under `packages/cli` | The existing `packages/*` workspace glob discovers it without special workspace configuration. | | ||
| | Keep the package private | The CLI configures a repository checkout; avoiding an npm release contract keeps ownership within the existing monorepo release process. | | ||
| | Route root commands through the package `dev` script | Contributors can run the TypeScript entry point without a separate root implementation. | | ||
| | Keep `setup:webhook` as a root alias | Existing documentation and automation continue to work. | | ||
| | Test the packed package in CI | Source-level tests alone cannot validate binary metadata or installation behavior. | | ||
| | Use a three-job compatibility matrix | It covers each supported OS and Node.js major without nine full workspace installs. | | ||
|
|
||
| ## Alternatives Considered | ||
|
|
||
| | Alternative | Why not | | ||
| | ---------------------------------------- | ----------------------------------------------------------------------------------------- | | ||
| | Extend `scripts/setup-yorkie-webhook.js` | It would keep the setup flow untyped, unpackaged, and difficult to test across platforms. | | ||
| | Put CLI commands in the backend package | CLI startup and packaging should not depend on the NestJS application lifecycle. | | ||
| | Remove `pnpm setup:webhook` immediately | It would break existing contributor workflows and automation without a migration period. | | ||
|
|
||
| ## Tasks | ||
|
|
||
| No separate execution task document is required for this focused integration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Disable credential persistence in the checkout action.
By default, the
actions/checkoutaction 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—settingpersist-credentials: falseimproves 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
🧰 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
Source: Linters/SAST tools