### IPC Client Usage Example Source: https://github.com/zgsm-ai/costrict/blob/main/packages/ipc/README.md Demonstrates how to instantiate an IpcClient and send commands to the CoStrict extension. Includes examples for resuming a task and starting a new task with configuration. ```typescript import { IpcClient } from "@roo-code/ipc" const client = new IpcClient("/path/to/socket") // Resume a task client.sendCommand({ commandName: "ResumeTask", data: "task-123", }) // Start a new task client.sendCommand({ commandName: "StartNewTask", data: { configuration: { /* RooCode settings */ }, text: "Hello, world!", images: [], newTab: false, }, }) ``` -------------------------------- ### Development Installation Steps Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Installs the CLI for development purposes. Requires installing dependencies, building the main extension, and then building the CLI. ```bash # From the monorepo root. pnpm install # Build the main extension first. pnpm --filter zgsm bundle # Build the CLI. pnpm --filter @roo-code/cli build ``` -------------------------------- ### Build and Install CLI Locally Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Build the CLI tarball and install it locally on your system. This allows you to test the installed version. ```bash ./apps/cli/scripts/build.sh --install ``` -------------------------------- ### Setup Evals Locally on macOS Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/README.md Execute this script to install development tools, programming languages, configure VS Code, set up Docker services, and prepare the evals repository for local development. It also handles database setup and prompts for an OpenRouter API key. ```shell cd packages/evals && ./scripts/setup.sh ``` -------------------------------- ### Copy Example .env.local File Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/README.md Copy the example environment file to your local directory to begin customizing port settings. ```sh cp packages/evals/.env.local.example packages/evals/.env.local ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/zgsm-ai/costrict/blob/main/CONTRIBUTING.md Install all necessary project dependencies using pnpm. This command should be run after cloning the repository. ```shell pnpm install ``` -------------------------------- ### Start Evals Service Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/README.md Initiate the evals service using pnpm. This command starts the web service that runs the programming exercises. ```sh pnpm evals ``` -------------------------------- ### Load and Use CoStrict API Source: https://github.com/zgsm-ai/costrict/blob/main/packages/types/npm/README.md Demonstrates how to install the types, import the API, load the extension, and use its methods to interact with CoStrict. ```typescript import { RooCodeAPI } from "@roo-code/types" const extension = vscode.extensions.getExtension("zgsm-ai.zgsm") if (!extension?.isActive) { throw new Error("Extension is not activated") } const api = extension.exports if (!api) { throw new Error("API is not available") } // Start a new task with an initial message. await api.startNewTask("Hello, CoStrict API! Let's make a new project...") // Start a new task with an initial message and images. await api.startNewTask("Use this design language", ["data:image/webp;base64,..."]) // Send a message to the current task. await api.sendMessage("Can you fix the @problems?") // Simulate pressing the primary button in the chat interface (e.g. 'Save' or 'Proceed While Running'). await api.pressPrimaryButton() // Simulate pressing the secondary button in the chat interface (e.g. 'Reject'). await api.pressSecondaryButton() ``` -------------------------------- ### Custom Installation Directory Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Installs the Roo Code CLI to a custom directory. Set ROO_INSTALL_DIR and ROO_BIN_DIR environment variables before running the install script. ```bash ROO_INSTALL_DIR=/opt/roo-code ROO_BIN_DIR=/usr/local/bin curl -fsSL ... | sh ``` -------------------------------- ### Interactive Rebase Commands Explanation Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/fork.md This example shows the interactive rebase interface and explains the available commands like pick, reword, edit, squash, fixup, and exec for managing commit history. ```bash pick 07c5abd Introduce OpenPGP and teach basic usage pick de9b1eb Fix PostChecker::Post#urls pick 3e7ee36 Hey kids, stop all the highlighting pick fa20af3 git interactive rebase, squash, amend # Rebase 8db7e8b..fa20af3 onto 8db7e8b # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out ``` -------------------------------- ### Git Reset and Commit Example Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/fork.md A simplified method to undo the last 5 commits, add all changes, and create a new commit. ```bash $ git reset HEAD~5 $ git add . $ git commit -am "Here's the bug fix that closes #28" $ git push --force ``` -------------------------------- ### Git Commit Messages Example Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/fork.md Illustrates how to structure multi-line commit messages in Git. ```bash # This is a combination of 3 commits. # The first commit's message is: Introduce OpenPGP and teach basic usage # This is the 2nd commit message: Fix PostChecker::Post#urls # This is the 3rd commit message: # Hey kids, stop all the highlighting ``` -------------------------------- ### Quick Install Roo Code CLI Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Installs the Roo Code CLI using a recommended script. Ensure Node.js 20+ and a compatible OS (macOS Apple Silicon or Linux x64) are present. ```bash curl -fsSL https://raw.githubusercontent.com/RooCodeInc/Roo-Code/main/apps/cli/install.sh | sh ``` -------------------------------- ### Breaking Change Footer Example Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/commit-message.md Example of a footer section detailing a breaking change, including a summary and migration instructions. ```git commit BREAKING CHANGE: Legacy token validation removed The deprecated `auth.legacyCheck` method is no longer supported. Migration: Use `auth.secureValidate` with JWT v2.0+ tokens and set `{ validationMode: 'strict' }` in config. ``` -------------------------------- ### Install Specific Version Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Installs a specific version of the Roo Code CLI. Set the ROO_VERSION environment variable before executing the install script. ```bash ROO_VERSION=0.1.0 curl -fsSL https://raw.githubusercontent.com/RooCodeInc/Roo-Code/main/apps/cli/install.sh | sh ``` -------------------------------- ### Commit Body Example Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/commit-message.md An example of the body section of a commit message, explaining the motivation and differences from previous versions. ```git commit Safari 15.4+ enforces stricter CORS policies for localStorage access, causing intermittent auth failures. Added retry logic for token refresh. ``` -------------------------------- ### Update Dockerfile for Language Runtime Installation Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Modify `packages/evals/Dockerfile.runner` to install the necessary runtime for your new language. This can be done using package managers or custom installation scripts. ```dockerfile # Install your new language runtime RUN apt update && apt install -y your-language-runtime # Or for languages that need special installation: ARG YOUR_LANGUAGE_VERSION=1.0.0 RUN curl -sSL https://install-your-language.sh | sh -s -- --version ${YOUR_LANGUAGE_VERSION} ``` -------------------------------- ### Execute Deployment Script Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Run the automated deployment script to perform environment checks, pull/build Docker images, initialize the database, start service containers, and verify their status. ```bash bash deploy.sh ``` -------------------------------- ### Markdown for Exercise Instructions Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Structure the main exercise description and problem details using Markdown. Includes sections for instructions, problem description, examples, and constraints. ```markdown # Instructions Create an implementation of [problem description]. ## Problem Description [Detailed explanation of what needs to be implemented] ## Examples - Input: [example input] - Output: [expected output] ## Constraints - [Any constraints or requirements] ``` ```markdown # Instructions Create a function that reverses a string. ## Problem Description Write a function called `reverse` that takes a string as input and returns the string with its characters in reverse order. ## Examples - Input: `reverse("hello")` → Output: `"olleh"` - Input: `reverse("world")` → Output: `"dlrow"` - Input: `reverse("")` → Output: `""` - Input: `reverse("a")` → Output: `"a"` ## Constraints - Input will always be a valid string - Empty strings should return empty strings ``` -------------------------------- ### Example Angular Commit Message Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/commit-message.md A complete example of an Angular-style commit message demonstrating feature addition with scope, body, and footer. ```git commit feat(config): add validation mode for JWT tokens Add `validationMode` option to enforce strict JWT validation as per RFC 7519. Default value 'loose' maintains backward compatibility. Closes #392 BREAKING CHANGE: `legacyCheck` method removed Use `secureValidate` with `{ validationMode: 'strict' }` instead. Update config before v3.0 release. ``` -------------------------------- ### Closing Issues Footer Example Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/commit-message.md Example of a footer section used to close issues, listing multiple issue numbers. ```git commit Safari 15.4+ enforces stricter CORS policies for localStorage access, causing intermittent auth failures. Added retry logic for token refresh. Closes #392 ``` -------------------------------- ### Revert Commit Example Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/commit-message.md An example of a commit message for reverting a previous commit, including the reverted commit's header and hash. ```git commit revert: feat: add 'Host' option This reverts commit bb42d749a7d129db0546bf89a48f84ec127843ce. ``` -------------------------------- ### Nginx Configuration for Domain Binding and Load Balancing Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Example Nginx configuration to set up a reverse proxy and load balancer for accessing CoStrict services in a production environment. This ensures secure and reliable access through a custom domain. ```nginx upstream costrict_backend { server {COSTRICT_BACKEND}:{PORT_APISIX_ENTRY}; } server { listen 443 ssl; server_name your-domain.com; location / { proxy_pass http://costrict_backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } ``` -------------------------------- ### Initialize and Use ExtensionClient Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/docs/AGENT_LOOP.md Demonstrates how to initialize the ExtensionClient, query agent state and mode, and subscribe to state and mode change events. The `debug` option writes logs to a file. ```typescript const client = new ExtensionClient({ ssendMessage: (msg) => extensionHost.sendToExtension(msg), debug: true, // Writes to ~/.roo/cli-debug.log }) // Query state at any time const state = client.getAgentState() if (state.isWaitingForInput) { console.log(`Agent needs: ${state.currentAsk}`) } // Query current mode const mode = client.getCurrentMode() console.log(`Current mode: ${mode}`) // e.g., "code", "architect", "ask" // Subscribe to events client.on("waitingForInput", (event) => { console.log(`Waiting for: ${event.ask}`) }) // Subscribe to mode changes client.on("modeChanged", (event) => { console.log(`Mode changed: ${event.previousMode} -> ${event.currentMode}`) }) ``` -------------------------------- ### Go Test File Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Write comprehensive unit tests for the Go implementation using the `testing` package. ```go package reversestring import "testing" func TestReverse(t *testing.T) { tests := []struct { input string expected string }{ {"hello", "olleh"}, {"world", "dlrow"}, {"", ""}, {"a", "a"}, } for _, test := range tests { result := Reverse(test.input) if result != test.expected { t.Errorf("Reverse(%q) = %q, expected %q", test.input, result, test.expected) } } } ``` -------------------------------- ### Go Module Configuration Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Add a `go.mod` file for Go exercises to manage dependencies and module information. ```go module reverse-string go 1.18 ``` -------------------------------- ### Local Testing - Go Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Run local tests for Go exercises using the `go test` command. Ensure tests fail with stub and pass with implementation. ```bash cd go/reverse-string go test ``` -------------------------------- ### Go Implementation Stub Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Create a Go function stub with a placeholder return for the exercise. ```go package reversestring // Reverse returns the input string with its characters in reverse order func Reverse(s string) string { // TODO: implement return "" } ``` -------------------------------- ### Run CLI from Source Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Execute the CLI directly from source code without requiring a build. This is useful for rapid development and testing. ```bash pnpm dev --provider roo --api-key $ROO_API_KEY --print "Hello" ``` -------------------------------- ### Uninstall Roo Code CLI Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Removes the Roo Code CLI installation files from the system. ```bash rm -rf ~/.roo/cli ~/.local/bin/cos ``` -------------------------------- ### List Docker Networks Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md List all Docker networks available on the host system. ```bash # Check Docker network docker network ls ``` -------------------------------- ### Clone Deployment Repository Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Clone the zgsm-ai/zgsm-backend-deploy repository to your local machine to begin the deployment process. ```bash git clone https://github.com/zgsm-ai/zgsm-backend-deploy.git cd zgsm-backend-deploy ``` -------------------------------- ### Python Project Configuration Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Ensure the parent directory of Python exercises has a `pyproject.toml` file for project metadata and dependencies. ```toml [project] name = "python-exercises" version = "0.1.0" description = "Python exercises for Roo Code evals" requires-python = ">=3.9" dependencies = [ "pytest>=8.3.5", ] ``` -------------------------------- ### Exercise Directory Structure Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Understand the standardized directory structure for each exercise within a specific language. ```bash git clone https://github.com/RooCodeInc/Roo-Code-Evals.git evals cd evals ``` ```bash mkdir {language}/{exercise-name} cd {language}/{exercise-name} ``` -------------------------------- ### Create and Checkout New Branch Source: https://github.com/zgsm-ai/costrict/blob/main/sync-upstream.md Creates a new local branch named 'roo-to-main' and immediately switches to it. This is useful for starting new feature development or preparing for a merge. ```git git checkout -b roo-to-main ``` -------------------------------- ### Resulting Commit Message After Squashing Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/fork.md When commits are squashed, the resulting commit message is a combination of the messages from the original squashed commits. This example shows how messages from multiple commits are merged. ```bash # This is a combination of 3 commits. # The first commit's message is: Introduce OpenPGP and teach basic usage # This is the 2nd commit message: Fix PostChecker::Post#urls # This is the 3rd commit message: Hey kids, stop all the highlighting ``` -------------------------------- ### Run Roo Code CLI Interactively (No Prompt) Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Starts the Roo Code CLI in interactive TUI mode without an initial prompt. Useful for directly entering the interactive session. ```bash cos -w ~/Documents/my-project ``` -------------------------------- ### Fast Local Build Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Perform a quick local build of the CLI tarball, skipping the verification step. Use this for faster iteration during development. ```bash ./apps/cli/scripts/build.sh --skip-verify ``` -------------------------------- ### Stream NDJSON Commands with Task ID Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Sends NDJSON commands via stdin to the Roo Code CLI, including a specific taskId for the start command. This allows for structured programmatic interaction. ```bash printf '{"command":"start","requestId":"1","taskId":"018f7fc8-7c96-7f7c-98aa-2ec4ff7f6d87","prompt":"1+1=?"}\n' | roo --print --stdin-prompt-stream --output-format stream-json ``` -------------------------------- ### Linting Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Run the linter to check for code style and potential issues. ```bash pnpm lint ``` -------------------------------- ### Agent Response Messages Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/docs/AGENT_LOOP.md Send these messages to control the agent's state and provide information. Use 'yesButtonClicked' or 'noButtonClicked' for action approvals, 'messageResponse' for answers, 'newTask' to start a task, and 'cancelTask' to stop the current one. ```typescript // Approve an action (tool, command, browser, MCP) client.sendMessage({ type: "askResponse", askResponse: "yesButtonClicked", }) ``` ```typescript // Reject an action client.sendMessage({ type: "askResponse", askResponse: "noButtonClicked", }) ``` ```typescript // Answer a question client.sendMessage({ type: "askResponse", askResponse: "messageResponse", text: "My answer here", }) ``` ```typescript // Start a new task client.sendMessage({ type: "newTask", text: "Build a web app", }) ``` ```typescript // Cancel current task client.sendMessage({ type: "cancelTask", }) ``` -------------------------------- ### Perform Database Backup Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Execute a database backup script. Ensure the backup script is located at ./scripts/backup.sh. ```bash # Database backup bash ./scripts/backup.sh ``` -------------------------------- ### Build Project Source: https://github.com/zgsm-ai/costrict/blob/main/sync-upstream.md Compiles and bundles the project using the pnpm package manager. This command is used to detect compilation errors. ```shell pnpm build ``` -------------------------------- ### Add and Commit Changes Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/fork.md Stage your modified or new files and then commit them. Use `git status` to review changes before committing. Refer to commit specifications for formatting. ```bash $ git add # 注意:如果有新文件生成,也要 add 进去 $ git status $ git commit ``` -------------------------------- ### Scale Service Instances with Docker Compose Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Scale the number of instances for a specific service using docker-compose up --scale. Replace 'chatgpt' with the desired service name and '3' with the desired number of instances. ```bash # Scale service instances docker-compose up -d --scale chatgpt=3 ``` -------------------------------- ### Perform Database Recovery Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Restore the database from a backup file. Provide the backup file name as an argument to the restore script. ```bash # Database recovery bash ./scripts/restore.sh [backup_file] ``` -------------------------------- ### View Detailed Container Error Logs Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Retrieve detailed logs for a specific service container to diagnose startup failures or other issues. ```bash # View detailed error logs docker-compose logs [service_name] ``` -------------------------------- ### Build CLI Tarball Locally Source: https://github.com/zgsm-ai/costrict/blob/main/apps/cli/README.md Create a platform-specific tarball of the CLI for local development and testing. This script bundles ripgrep with the CLI. ```bash ./apps/cli/scripts/build.sh ``` -------------------------------- ### Python Test File Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Write comprehensive unit tests for the Python implementation using the `unittest` module. ```python import unittest from reverse_string import reverse class ReverseStringTest(unittest.TestCase): def test_reverse_hello(self): self.assertEqual(reverse("hello"), "olleh") def test_reverse_world(self): self.assertEqual(reverse("world"), "dlrow") def test_reverse_empty_string(self): self.assertEqual(reverse(""), "") def test_reverse_single_character(self): self.assertEqual(reverse("a"), "a") ``` -------------------------------- ### Inspect Docker Network Details Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Display detailed information about a specific Docker network, including its configuration and connected containers. ```bash # Inspect Docker network docker network inspect {network_name} ``` -------------------------------- ### Local Testing - Python Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Run local tests for Python exercises using `uv` and `pytest`. Ensure tests fail with stub and pass with implementation. ```bash cd python/reverse-string uv run python3 -m pytest -o markers=task reverse_string_test.py ``` -------------------------------- ### Create Language-Specific Prompt Source: https://github.com/zgsm-ai/costrict/blob/main/packages/evals/ADDING-EVALS.md Create a markdown file named `prompts/{language}.md` in the evals repository. This file defines the instructions for completing coding exercises in the new language. ```markdown Your job is to complete a coding exercise described in the markdown files inside the `docs` directory. A file with the implementation stubbed out has been created for you, along with a test file (the tests should be failing initially). To successfully complete the exercise, you must pass all the tests in the test file. To confirm that your solution is correct, run the tests with `{test-command}`. Do not alter the test file; it should be run as-is. Do not use the "ask_followup_question" tool. Your job isn't done until the tests pass. Don't attempt completion until you run the tests and they pass. You should start by reading the files in the `docs` directory so that you understand the exercise, and then examine the stubbed out implementation and the test file. ``` -------------------------------- ### Update Service Configuration with Docker Compose Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Force a recreation of a service to apply configuration changes using docker-compose up --force-recreate. Specify the service name to update. ```bash # Update service configuration docker-compose up -d --force-recreate [service_name] ``` -------------------------------- ### View Service Logs with Docker Compose Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Follow service logs in real-time using docker-compose logs. Specify the service name to view logs for a particular service. ```bash # View service logs docker-compose logs -f [service_name] ``` -------------------------------- ### View PostgreSQL Container Logs Source: https://github.com/zgsm-ai/costrict/blob/main/assets/docs/devel/en-US/deployment.md Access the logs of the PostgreSQL container to troubleshoot database-related issues. ```bash # View database logs docker-compose logs postgres ```