### Install Dependencies in Post-Creation Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md A simple command to install Node.js dependencies immediately after a worktree is created. ```bash npm install ``` -------------------------------- ### Global CCManager Configuration Example Source: https://context7.com/kbwo/ccmanager/llms.txt An example of a global CCManager configuration file in JSON format. This file defines settings for keyboard shortcuts, command presets, worktree management, merge strategies, status hooks, and auto-approval. ```json { "shortcuts": { "returnToMenu": { "ctrl": true, "key": "e" }, "cancel": { "key": "escape" } }, "commandPresets": { "presets": [ { "id": "claude-default", "name": "Claude Default", "command": "claude", "args": ["--resume"], "fallbackArgs": [], "detectionStrategy": "claude" }, { "id": "gemini-dev", "name": "Gemini Development", "command": "gemini", "args": ["--model", "gemini-pro"], "detectionStrategy": "gemini" } ], "defaultPresetId": "claude-default", "selectPresetOnStart": false }, "worktree": { "autoDirectory": true, "autoDirectoryPattern": "../{branch}", "copySessionData": true, "sortByLastSession": true, "autoUseDefaultBranch": false }, "mergeConfig": { "mergeArgs": ["--no-ff"], "rebaseArgs": [] }, "statusHooks": { "idle": { "command": "noti -t 'Claude Code' -m 'Session is now idle'", "enabled": true }, "busy": { "command": "noti -t 'Claude Code' -m 'Session is processing'", "enabled": true }, "waiting_input": { "command": "noti -t 'Claude Code' -m 'Claude needs your input'", "enabled": true } }, "worktreeHooks": { "pre_creation": { "command": "echo 'Validating worktree creation'", "enabled": false }, "post_creation": { "command": "npm install", "enabled": true } }, "autoApproval": { "enabled": false, "customCommand": "", "timeout": 60 } } ``` -------------------------------- ### Install and Run CCManager Source: https://github.com/kbwo/ccmanager/blob/main/README.md Commands to install the CCManager package globally via npm, build from source, or execute directly using npx. ```bash npm install -g ccmanager npm install npm run build npm start ccmanager npx ccmanager ``` -------------------------------- ### Configure Worktree Hooks for Creation Events Source: https://context7.com/kbwo/ccmanager/llms.txt Define pre-creation and post-creation hooks for worktrees. Pre-creation hooks can abort worktree creation based on conditions like branch naming conventions or disk space. Post-creation hooks run asynchronously after the worktree is created, useful for setup tasks like installing dependencies. ```json { "worktreeHooks": { "pre_creation": { "command": "#!/bin/bash\nif [[ ! \"$CCMANAGER_WORKTREE_BRANCH\" =~ ^(feature|bugfix|hotfix)/ ]]; then\n echo 'Error: Branch name must start with feature/, bugfix/, or hotfix/' >&2\n exit 1\nfi", "enabled": true }, "post_creation": { "command": "npm install && cp .env.example .env", "enabled": true } } } ``` ```bash #!/bin/bash # Ensure at least 1GB free disk space FREE_KB=$(df "$CCMANAGER_GIT_ROOT" | tail -1 | awk '{print $4}') MIN_KB=1048576 # 1GB in KB if [ "$FREE_KB" -lt "$MIN_KB" ]; then echo "Error: Insufficient disk space. Need at least 1GB free." >&2 exit 1 fi ``` -------------------------------- ### Per-Project CCManager Configuration Example Source: https://context7.com/kbwo/ccmanager/llms.txt An example of a per-project CCManager configuration file in JSON format. This file overrides global settings for a specific project, including the default command, shortcuts, worktree behavior, and command presets. ```json { "command": { "name": "gemini", "args": [] }, "shortcuts": { "returnToMenu": { "ctrl": true, "key": "r" } }, "worktree": { "autoDirectory": true, "autoDirectoryPattern": ".git/tasks/{branch}", "copySessionData": false }, "commandPresets": { "presets": [ { "id": "project-claude", "name": "Project Claude", "command": "claude", "args": ["--model", "opus"], "detectionStrategy": "claude" } ], "defaultPresetId": "project-claude" } } ``` -------------------------------- ### CCManager JSON Configuration Example Source: https://github.com/kbwo/ccmanager/blob/main/docs/command-config.md Example of the CCManager configuration file (config.json) showing how to define the command, arguments, and fallback arguments for code sessions. This structure allows for flexible command execution with fallback mechanisms. ```json { "command": { "command": "claude", "args": ["--resume", "--model", "opus"], "fallbackArgs": ["--model", "opus"] } } ``` -------------------------------- ### Install CCManager Globally Source: https://context7.com/kbwo/ccmanager/llms.txt Installs the CCManager CLI application globally on your system using npm, making it accessible from any directory. ```bash npm install -g ccmanager ``` -------------------------------- ### Logging Example Source: https://github.com/kbwo/ccmanager/blob/main/AGENTS.md Demonstrates the usage of the logger class for outputting information. It is recommended to use this logger instead of the console for better log management. ```typescript logger.info("This is info level log"); ``` -------------------------------- ### Configure Keyboard Shortcuts Source: https://github.com/kbwo/ccmanager/blob/main/README.md Example JSON configuration for customizing keyboard shortcuts in CCManager. This file can be placed in the global config directory or the project root. ```json { "shortcuts": { "returnToMenu": { "ctrl": true, "key": "r" }, "cancel": { "key": "escape" } } } ``` -------------------------------- ### Launch CCManager Source: https://context7.com/kbwo/ccmanager/llms.txt Launches the CCManager TUI application in the current Git repository. This command assumes CCManager is installed globally. ```bash ccmanager ``` -------------------------------- ### Run CCManager without Installation Source: https://context7.com/kbwo/ccmanager/llms.txt Executes the CCManager CLI application directly using npx without requiring a global installation. This is useful for trying out the tool or running it in environments where global package installation is restricted. ```bash npx ccmanager ``` -------------------------------- ### Project Development Lifecycle Commands Source: https://github.com/kbwo/ccmanager/blob/main/README.md A collection of standard NPM scripts used for project maintenance. These include dependency installation, development server execution, building, testing, linting, and type checking. ```bash npm install npm run dev npm run build npm test npm run lint npm run typecheck ``` -------------------------------- ### Parallel and Sequential Composition with Effect-ts Source: https://github.com/kbwo/ccmanager/blob/main/docs/effect-error-handling-migration.md Illustrates Effect-ts's capabilities for composing asynchronous operations. The 'Parallel Queries' example shows how to run multiple effects concurrently using `Effect.all`, while 'Sequential Composition' demonstrates chaining operations using `Effect.flatMap` for dependent tasks. ```typescript // Load branches and default branch in parallel const loadBranchData = Effect.all([ worktreeService.getAllBranchesEffect(), worktreeService.getDefaultBranchEffect() ], { concurrency: 2 }); const result = await Effect.runPromise( Effect.match(loadBranchData, { onFailure: (error) => ({ type: 'error', error }), onSuccess: ([branches, defaultBranch]) => ({ type: 'success', data: { branches, defaultBranch } }) }) ); ``` ```typescript // Chain validation and creation createWorktreeEffect(branchName: string, path: string) { return Effect.flatMap( this.validatePath(path), (validPath) => this.performCreate(validPath, branchName) ); } ``` -------------------------------- ### Devcontainer Integration Setup Source: https://context7.com/kbwo/ccmanager/llms.txt Configure CCManager to execute commands within a devcontainer environment. This allows the host machine to manage the AI session while the execution happens inside the container. ```bash ccmanager --devc-up-command "devcontainer up --workspace-folder ." \ --devc-exec-command "devcontainer exec --workspace-folder ." ``` -------------------------------- ### Access Git Root in Post-Creation Hook Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md Example of using the CCMANAGER_GIT_ROOT environment variable to navigate to the git root directory when executing commands in a post-creation hook. ```bash cd "$CCMANAGER_GIT_ROOT" && your-command-here ``` -------------------------------- ### Execute Custom Approval with Codex Source: https://github.com/kbwo/ccmanager/blob/main/docs/auto-approval.md Example of using a custom command with Codex to perform approval checks. This command utilizes environment variables provided by CCManager and outputs the required JSON schema. ```bash codex exec --json "$DEFAULT_PROMPT" \ --output-schema /auto-approval.schema.json \ --output-last-message /tmp/codex-output.json > /dev/null \ && cat /tmp/codex-output.json ``` -------------------------------- ### Build Project for Production Source: https://github.com/kbwo/ccmanager/blob/main/AGENTS.md Compiles the project into a production-ready state, outputting artifacts to the 'dist/' directory. This command is used before deployment or publishing. ```bash npm run build ``` -------------------------------- ### Prepare for Publishing Source: https://github.com/kbwo/ccmanager/blob/main/AGENTS.md Runs the full test pipeline, including linting, type checking, and unit tests, before publishing the package. This ensures the code meets quality standards. ```bash npm run prepublishOnly ``` -------------------------------- ### Development and Build Commands Source: https://context7.com/kbwo/ccmanager/llms.txt Standard npm scripts for developing, testing, and building CCManager. Includes commands for local development, production builds, and binary distribution. ```bash npm install npm run dev npm run build npm start npm test npm run lint npm run typecheck ``` -------------------------------- ### Configure Command Presets for Session Creation Source: https://context7.com/kbwo/ccmanager/llms.txt Define command presets with primary and fallback arguments for reliable session creation. Each preset has a unique ID, name, command, arguments, and a detection strategy. ```json { "commandPresets": { "presets": [ { "id": "claude-resume", "name": "Claude with Resume", "command": "claude", "args": ["--resume", "--model", "opus"], "fallbackArgs": ["--model", "opus"], "detectionStrategy": "claude" }, { "id": "gemini-standard", "name": "Gemini Standard", "command": "gemini", "args": [], "detectionStrategy": "gemini" }, { "id": "codex-dev", "name": "Codex Development", "command": "codex", "args": ["--approval-mode", "suggest"], "detectionStrategy": "codex" } ], "defaultPresetId": "claude-resume", "selectPresetOnStart": true } } ``` -------------------------------- ### CCManager CLI Options Source: https://context7.com/kbwo/ccmanager/llms.txt Demonstrates common command-line flags for CCManager, including showing help, version, enabling multi-project mode, and configuring devcontainer integration. ```bash # Show help ccmanager --help ``` ```bash # Show version ccmanager --version ``` ```bash # Enable multi-project mode (requires CCMANAGER_MULTI_PROJECT_ROOT environment variable) export CCMANAGER_MULTI_PROJECT_ROOT="/path/to/your/projects" ccmanager --multi-project ``` ```bash # Run with devcontainer support (both flags required together) ccmanager --devc-up-command "devcontainer up --workspace-folder ." \ --devc-exec-command "devcontainer exec --workspace-folder ." ``` -------------------------------- ### Validate Branch Naming Convention Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md A pre-creation hook that enforces a naming convention for Git branches. It ensures the branch name starts with 'feature/', 'bugfix/', or 'hotfix/'. ```bash if [[ ! "$CCMANAGER_WORKTREE_BRANCH" =~ ^(feature|bugfix|hotfix)/ ]]; then echo "Error: Branch name must start with feature/, bugfix/, or hotfix/" >&2 exit 1 fi ``` -------------------------------- ### Run Unit Tests Source: https://github.com/kbwo/ccmanager/blob/main/AGENTS.md Executes the Vitest unit test suite. This command is used to verify the correctness of the codebase and should be run before publishing. ```bash npm run test ``` -------------------------------- ### Run Development Server Source: https://github.com/kbwo/ccmanager/blob/main/AGENTS.md Launches the TypeScript compiler in watch mode for rapid development feedback. This command is essential for the local development workflow. ```bash npm run dev ``` -------------------------------- ### Automated Preset Execution in Containers Source: https://github.com/kbwo/ccmanager/blob/main/docs/devcontainer.md Demonstrates how CCManager automatically appends preset arguments to the devcontainer execution command. This allows for seamless integration of pre-configured AI assistant settings within isolated environments. ```bash devcontainer exec --workspace-folder . -- claude --dangerously-skip-permissions -m claude-3-opus ``` -------------------------------- ### Manage Multi-Project Environments Source: https://context7.com/kbwo/ccmanager/llms.txt Configure CCManager to track multiple git repositories from a single root directory. This enables seamless switching between different project contexts. ```bash export CCMANAGER_MULTI_PROJECT_ROOT="/path/to/your/projects" ccmanager --multi-project ``` -------------------------------- ### Check Disk Space Before Worktree Creation Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md A pre-creation hook that verifies available disk space on the Git root partition. It aborts the process if less than 1GB of space is available. ```bash FREE_KB=$(df "$CCMANAGER_GIT_ROOT" | tail -1 | awk '{print $4}') MIN_KB=1048576 if [ "$FREE_KB" -lt "$MIN_KB" ]; then echo "Error: Insufficient disk space. Need at least 1GB free." >&2 exit 1 fi ``` -------------------------------- ### Configure Waiting for Input Notification with noti Source: https://github.com/kbwo/ccmanager/blob/main/docs/status-hooks.md Sets up a notification using the 'noti' command when the CCManager session is waiting for user input. It displays the current worktree branch in the notification title and message. ```bash noti -t "Claude Code" -m "Claude is waiting for your input in $CCMANAGER_WORKTREE_BRANCH branch" ``` -------------------------------- ### Run CCManager in Multi-Project Mode Source: https://github.com/kbwo/ccmanager/blob/main/docs/multi-project.md This command initiates CCManager in multi-project mode. Ensure the CCMANAGER_MULTI_PROJECT_ROOT environment variable is set beforehand, or CCManager will display an error. ```bash npx ccmanager --multi-project ``` -------------------------------- ### Configure Auto-Generation via JSON Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-auto-directory.md This configuration enables the automatic directory generation feature and defines the naming pattern for worktrees. It should be placed in the ~/.config/ccmanager/config.json file. ```json { "worktree": { "autoDirectory": true, "autoDirectoryPattern": "../{branch}" } } ``` -------------------------------- ### Configure AI Assistant Detection Strategies Source: https://context7.com/kbwo/ccmanager/llms.txt Define command presets and detection strategies for various AI CLI tools. This mapping allows CCManager to correctly identify and interact with different AI assistants. ```json { "commandPresets": { "presets": [ { "id": "claude-preset", "name": "Claude Code", "command": "claude", "detectionStrategy": "claude" }, { "id": "gemini-preset", "name": "Gemini CLI", "command": "gemini", "detectionStrategy": "gemini" } ] } } ``` -------------------------------- ### Configure Status Hooks for Session State Changes Source: https://context7.com/kbwo/ccmanager/llms.txt Execute custom commands when session status changes. Environment variables provide context about the state change, such as old and new states, worktree path, and session ID. Supports notifications via tools like 'noti' or integrations like Slack. ```json { "statusHooks": { "idle": { "command": "noti -t 'Claude Code' -m 'Session is now idle in $CCMANAGER_WORKTREE_BRANCH'", "enabled": true }, "busy": { "command": "noti -t 'Claude Code' -m 'Session is now busy on branch $CCMANAGER_WORKTREE_BRANCH'", "enabled": true }, "waiting_input": { "command": "noti -t 'Claude Code' -m 'Claude is waiting for your input in $CCMANAGER_WORKTREE_BRANCH'", "enabled": true } } } ``` ```json { "statusHooks": { "waiting_input": { "command": "curl -X POST -H 'Content-type: application/json' --data '{\"text\":\'Claude is now \'$CCMANAGER_NEW_STATE\' in \'$CCMANAGER_WORKTREE_PATH\'}' YOUR_SLACK_WEBHOOK_URL", "enabled": true } } } ``` -------------------------------- ### Define Project Configuration in .ccmanager.json Source: https://github.com/kbwo/ccmanager/blob/main/docs/project-config.md This JSON structure defines the project-specific configuration for CCManager. It includes command settings and custom keyboard shortcuts that override global defaults. ```json { "command": { "name": "gemini", "args": [] }, "shortcuts": { "returnToMenu": { "ctrl": true, "key": "e" } } } ``` -------------------------------- ### Configure Automatic Worktree Directory Generation Source: https://context7.com/kbwo/ccmanager/llms.txt Enable and configure automatic generation of worktree directory paths based on branch names using a specified pattern. This feature can also copy session data to the new worktree. ```json { "worktree": { "autoDirectory": true, "autoDirectoryPattern": "../{branch}", "copySessionData": true } } ``` -------------------------------- ### Enable Git Worktree Configuration Source: https://github.com/kbwo/ccmanager/blob/main/docs/git-worktree-config.md Commands to enable the worktree configuration extension either for the current repository or globally. This is a prerequisite for CCManager's advanced status tracking features. ```bash git config extensions.worktreeConfig true git config --global extensions.worktreeConfig true ``` -------------------------------- ### JSON Structure for Recent Projects Source: https://github.com/kbwo/ccmanager/blob/main/docs/multi-project.md This JSON structure illustrates the format of the `recent-projects.json` file. It's an array of objects, where each object represents a recently accessed project with its path, name, and the timestamp of last access. ```json [ { "path": "/home/user/projects/my-app", "name": "my-app", "lastAccessed": 1703001234567 }, { "path": "/home/user/projects/another-project", "name": "another-project", "lastAccessed": 1703001234566 } ] ``` -------------------------------- ### Configure CCManager Worktree Hooks Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md JSON configuration schema for enabling pre-creation and post-creation hooks within the CCManager configuration file. ```json { "worktreeHooks": { "pre_creation": { "command": "your-validation-command", "enabled": true }, "post_creation": { "command": "your-command-here", "enabled": true } } } ``` -------------------------------- ### Manual Worktree Configuration Management Source: https://github.com/kbwo/ccmanager/blob/main/docs/git-worktree-config.md Commands to manually set or verify the parent branch for a specific worktree. This allows users to define or correct the relationship between a worktree and its source branch. ```bash git config --worktree ccmanager.parentBranch main git config --worktree ccmanager.parentBranch ``` -------------------------------- ### Configure CCManager for Devcontainers Source: https://github.com/kbwo/ccmanager/blob/main/docs/devcontainer.md Use the CLI arguments to define how CCManager initializes and executes commands within a devcontainer environment. These commands provide full flexibility for custom workflows and wrapper tools. ```bash ccmanager --devc-up-command "" --devc-exec-command "" ``` -------------------------------- ### Configure Idle Status Notification with noti Source: https://github.com/kbwo/ccmanager/blob/main/docs/status-hooks.md Sets up a notification using the 'noti' command when the CCManager session becomes idle. It displays the current worktree branch in the notification title and message. ```bash noti -t "Claude Code" -m "Session is now idle in $CCMANAGER_WORKTREE_BRANCH" ``` -------------------------------- ### Execute Compiled CLI Source: https://github.com/kbwo/ccmanager/blob/main/AGENTS.md Runs the compiled command-line interface script located in 'dist/cli.js'. This is useful for manual smoke testing of the built application. ```bash npm run start ``` -------------------------------- ### Custom Command Verification Schema for Auto Approval Source: https://context7.com/kbwo/ccmanager/llms.txt Configure a custom verification command for auto-approval. This command must output JSON matching the auto-approval schema and receives environment variables like DEFAULT_PROMPT and TERMINAL_OUTPUT. ```bash # Environment variables provided to custom command: # DEFAULT_PROMPT: The exact prompt text CCManager would have sent to Claude # TERMINAL_OUTPUT: The captured terminal output ``` -------------------------------- ### Configure Busy Status Notification with noti Source: https://github.com/kbwo/ccmanager/blob/main/docs/status-hooks.md Sets up a notification using the 'noti' command when the CCManager session becomes busy. It displays the current worktree branch in the notification title and message. ```bash noti -t "Claude Code" -m "Session is now busy on branch $CCMANAGER_WORKTREE_BRANCH" ``` -------------------------------- ### Configure Auto Approval with AI Verification Source: https://context7.com/kbwo/ccmanager/llms.txt Enable automatic approval of safe prompts using AI verification. This feature can use Claude Haiku by default or a custom verification command. A timeout can be specified for the verification process. ```json { "autoApproval": { "enabled": true, "timeout": 60 } } ``` ```json { "autoApproval": { "enabled": true, "customCommand": "my-custom-verifier", "timeout": 30 } } ``` -------------------------------- ### Customize Keyboard Shortcuts Source: https://context7.com/kbwo/ccmanager/llms.txt Define custom keyboard shortcuts for CCManager navigation and control. Users can map specific keys and modifiers to actions like returning to the menu or canceling operations. ```json { "shortcuts": { "returnToMenu": { "ctrl": true, "key": "e" }, "cancel": { "key": "escape" } } } ``` -------------------------------- ### Verify CI Status of Base Branch Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md A pre-creation hook that uses the GitHub CLI to check if the latest CI run for the base branch was successful. It issues a warning if the status is not 'success'. ```bash if [ -n "$CCMANAGER_BASE_BRANCH" ]; then STATUS=$(gh run list --branch "$CCMANAGER_BASE_BRANCH" --limit 1 --json conclusion -q '.[0].conclusion') if [ "$STATUS" != "success" ]; then echo "Warning: Base branch CI status is '$STATUS'" >&2 fi fi ``` -------------------------------- ### Execute Codex with Custom Schema Source: https://context7.com/kbwo/ccmanager/llms.txt Run the Codex CLI tool using a specific output schema for automated approval workflows. This command pipes the output to a temporary file for further processing. ```bash codex exec --json "$DEFAULT_PROMPT" \ --output-schema /path/to/auto-approval.schema.json \ --output-last-message /tmp/codex-output.json > /dev/null \ && cat /tmp/codex-output.json ``` -------------------------------- ### Configure Auto Approval via JSON Source: https://github.com/kbwo/ccmanager/blob/main/docs/auto-approval.md Enable or disable the auto-approval feature by modifying the CCManager configuration file. You can also specify a custom command for approval logic. ```json { "autoApproval": { "enabled": true, "customCommand": "my-checker" } } ``` -------------------------------- ### Test WorktreeService with Effect-ts Source: https://github.com/kbwo/ccmanager/blob/main/docs/effect-error-handling-migration.md These are unit tests for the WorktreeService, demonstrating how to test asynchronous operations that return Effect-ts types. It includes tests for successfully retrieving worktrees and for handling potential GitErrors using Effect.either for error inspection. These tests ensure the service behaves as expected under various conditions. ```typescript describe('WorktreeService', () => { it('should get worktrees using Effect', async () => { const worktrees = await Effect.runPromise( worktreeService.getWorktreesEffect() ); expect(worktrees).toHaveLength(3); }); it('should handle git errors', async () => { const result = await Effect.runPromise( Effect.either(worktreeService.getWorktreesEffect()) ); if (Either.isLeft(result)) { expect(result.left._tag).toBe('GitError'); } }); }); ``` -------------------------------- ### Configure AI Auto-Approval Schema Source: https://context7.com/kbwo/ccmanager/llms.txt Define the JSON schema for automated approval logic in AI assistant interactions. This ensures that prompts requiring manual intervention are flagged correctly. ```json { "needsPermission": true, "reason": "Optional reason for requiring manual approval" } ``` -------------------------------- ### Load Data with useEffect and Effect-ts Source: https://github.com/kbwo/ccmanager/blob/main/docs/effect-error-handling-migration.md This snippet demonstrates loading data asynchronously within a React component using the useEffect hook and Effect-ts. It handles success and failure states, updates component state, and includes cleanup logic to prevent race conditions. Dependencies include Effect-ts and React hooks. ```typescript useEffect(() => { let cancelled = false; const loadData = async () => { const result = await Effect.runPromise( Effect.match(service.getDataEffect(), { onFailure: (err: AppError) => ({ type: 'error' as const, error: err }), onSuccess: (data) => ({ type: 'success' as const, data }) }) ); if (!cancelled) { if (result.type === 'error') { setError(formatError(result.error)); } else { setData(result.data); } setIsLoading(false); } }; loadData().catch(err => { if (!cancelled) { setError(`Unexpected error: ${String(err)}`); setIsLoading(false); } }); return () => { cancelled = true; }; }, []); ``` -------------------------------- ### Error Recovery Strategies with Effect-ts Source: https://github.com/kbwo/ccmanager/blob/main/docs/effect-error-handling-migration.md Showcases Effect-ts's flexible error recovery patterns. 'Specific Error Handling' uses `Effect.catchTag` to handle particular error types, allowing for conditional logic. 'Fallback Values' demonstrates `Effect.catchAll` to provide a default success value when an operation fails. ```typescript // Recover from specific error types const withRecovery = Effect.catchTag( createWorktreeEffect(path, branch), 'GitError', (error) => { if (error.exitCode === 128) { // Branch exists, try alternative return createWorktreeEffect(path + '-2', branch + '-2'); } return Effect.fail(error); } ); ``` ```typescript // Provide default if operation fails const worktreesWithFallback = Effect.catchAll( worktreeService.getWorktreesEffect(), (error) => { console.error('Failed to get worktrees:', error); return Effect.succeed([defaultWorktree]); } ); ``` -------------------------------- ### TypeScript Interfaces for Git Projects and Recent Projects Source: https://github.com/kbwo/ccmanager/blob/main/docs/multi-project.md These TypeScript interfaces define the data structures used by CCManager to represent git projects and recently accessed projects. GitProject includes details like the repository path and name, while RecentProject tracks the path, name, and last accessed timestamp. ```typescript interface GitProject { path: string; // Absolute path to git repository name: string; // Project name (directory name) relativePath: string; // Path relative to root directory isValid: boolean; // Whether it's a valid git repo } interface RecentProject { path: string; // Absolute path name: string; // Project name lastAccessed: number; // Unix timestamp } ``` -------------------------------- ### Send Status Change to Slack via Webhook Source: https://github.com/kbwo/ccmanager/blob/main/docs/status-hooks.md Sends a JSON payload containing the new CCManager state and worktree path to a Slack channel using a webhook. Requires a valid Slack webhook URL. ```bash curl -X POST -H 'Content-type: application/json' --data '{"text":"Claude is now '"$CCMANAGER_NEW_STATE"' in '"$CCMANAGER_WORKTREE_PATH"'"}' YOUR_SLACK_WEBHOOK_URL ``` -------------------------------- ### Prevent Duplicate Worktrees Source: https://github.com/kbwo/ccmanager/blob/main/docs/worktree-hooks.md A pre-creation hook that checks if a worktree for the specified branch already exists in the current repository to prevent conflicts. ```bash EXISTING=$(git worktree list | grep "\[$CCMANAGER_WORKTREE_BRANCH\]") if [ -n "$EXISTING" ]; then echo "Error: Worktree for branch '$CCMANAGER_WORKTREE_BRANCH' already exists" >&2 exit 1 fi ``` -------------------------------- ### Effect-ts Error Handling for Worktree Operations Source: https://github.com/kbwo/ccmanager/blob/main/docs/effect-error-handling-migration.md Demonstrates how to wrap asynchronous operations like git commands within Effect-ts's `Effect.tryPromise` for type-safe error handling. It specifies how to map caught errors to a custom `GitError` type, ensuring explicit error types in function signatures. ```typescript getWorktreesEffect(): Effect.Effect { return Effect.tryPromise({ try: async () => { /* ... */ }, catch: (error: any) => new GitError({ /* ... */ }) }); } ```