Skip to content
This repository was archived by the owner on Nov 8, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/ci_cli.yaml
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
Comment on lines +51 to +52

Copy link
Copy Markdown
Contributor

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/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.

Suggested change
- 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

- 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
14 changes: 14 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ LINT_FRONTEND=false
LINT_BACKEND=false
LINT_UI=false
LINT_CODEMIRROR=false
LINT_CLI=false

for FILE in $CHANGED_FILES; do
if [[ "$FILE" =~ ^packages/frontend/ ]]; then
Expand All @@ -14,6 +15,8 @@ for FILE in $CHANGED_FILES; do
LINT_UI=true
elif [[ "$FILE" =~ ^packages/codemirror/ ]]; then
LINT_CODEMIRROR=true
elif [[ "$FILE" =~ ^packages/cli/ ]]; then
LINT_CLI=true
fi
done

Expand Down Expand Up @@ -60,3 +63,14 @@ if [ "$LINT_CODEMIRROR" = true ]; then
fi
cd ../..
fi

if [ "$LINT_CLI" = true ]; then
echo "Changes detected in cli. Linting & Formatting cli..."
cd packages/cli
npx lint-staged
if [ $? -ne 0 ]; then
echo "CLI Linting & Formatting failed. Commit aborted."
exit 1
fi
cd ../..
fi
2 changes: 1 addition & 1 deletion MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### 1. Update the version number.

- Update the `version` field in the root `package.json` file to reflect the overall version of the monorepo.
- Also, update `version` fields in the [`frontend` package.json](https://github.com/yorkie-team/codepair/blob/1f10dff1d9c253f921ba136c812383fbb292078f/frontend/package.json#L3) and [`backend` package.json](https://github.com/yorkie-team/codepair/blob/1f10dff1d9c253f921ba136c812383fbb292078f/backend/package.json#L3).
- Also update the `version` fields in the frontend, backend, and private CLI package manifests.

### 2. Write changelog of this version in [CHANGELOG.md](https://github.com/yorkie-team/codepair/blob/main/CHANGELOG.md).

Expand Down
51 changes: 45 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.json

Repository: 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.json

Repository: 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.


## 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

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ New design documents should be based on [TEMPLATE.md](TEMPLATE.md).

## Contents

(none)
- [CodePair CLI](cli.md)
89 changes: 89 additions & 0 deletions docs/design/cli.md
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.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"frontend": "pnpm --filter=@codepair/frontend",
"backend": "pnpm --filter=@codepair/backend",
"desktop": "pnpm --filter=@codepair/desktop",
"cli": "pnpm --filter=@codepair/cli dev",
"lint": "pnpm run --parallel lint",
"lint:check": "pnpm run --parallel lint:check",
"format": "pnpm run --parallel format",
Expand Down
Loading
Loading