npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cyrus-edge-worker

v0.2.39

Published

Unified edge worker for processing Linear issues with Claude

Readme

@cyrus/edge-worker

Unified edge worker for processing Linear issues with Claude. Handles webhook events, manages Claude sessions, and posts comments back to Linear.

Installation

pnpm add @cyrus/edge-worker

Usage

The EdgeWorker supports multiple repository/Linear workspace pairs. Each repository configuration includes:

  • Git repository path and branch
  • Linear workspace ID and OAuth token
  • Workspace directory for issue processing

Single Repository Example (CLI)

import { EdgeWorker } from '@cyrus/edge-worker'

const edgeWorker = new EdgeWorker({
  // Connection
  proxyUrl: 'https://edge-proxy.example.com',
  
  // Claude
  claudePath: '/usr/local/bin/claude',
  defaultAllowedTools: ['bash', 'edit', 'read'],
  
  // Single repository configuration
  repositories: [{
    id: 'main-repo',
    name: 'Main Repository',
    repositoryPath: '/home/user/projects/main',
    baseBranch: 'main',
    linearWorkspaceId: 'workspace-123',
    linearToken: await oauthHelper.getAccessToken(),
    workspaceBaseDir: '/home/user/.cyrus/workspaces/main'
  }],
  
  // Optional handlers
  handlers: {
    // Custom workspace creation (e.g., git worktrees)
    createWorkspace: async (issue, repository) => {
      const path = await createGitWorktree(
        repository.repositoryPath,
        issue.identifier,
        repository.baseBranch
      )
      return { path, isGitWorktree: true }
    },
    
    // Log errors
    onError: (error) => {
      console.error('EdgeWorker error:', error)
    }
  },
  
  // Features
  features: {
    enableContinuation: true,
    enableTokenLimitHandling: true
  }
})

// Start processing
await edgeWorker.start()

Multi-Repository Example (Electron)

import { EdgeWorker } from '@cyrus/edge-worker'

// Load repository configurations from user settings
const repositories = userSettings.repositories.map(repo => ({
  id: repo.id,
  name: repo.name,
  repositoryPath: repo.path,
  baseBranch: repo.branch || 'main',
  linearWorkspaceId: repo.linearWorkspaceId,
  linearToken: repo.linearToken, // Each repo can have its own token
  workspaceBaseDir: path.join(app.getPath('userData'), 'workspaces', repo.id),
  isActive: repo.enabled
}))

const edgeWorker = new EdgeWorker({
  proxyUrl: config.proxyUrl,
  claudePath: getClaudePath(),
  
  // Multiple repositories
  repositories,
  
  // UI updates with repository context
  handlers: {
    onClaudeEvent: (issueId, event, repositoryId) => {
      // Update UI with Claude's progress
      mainWindow.webContents.send('claude-event', { 
        issueId, 
        event,
        repository: repositories.find(r => r.id === repositoryId)
      })
    },
    
    onSessionStart: (issueId, issue, repositoryId) => {
      const repo = repositories.find(r => r.id === repositoryId)
      // Show notification
      new Notification({
        title: `Processing Issue in ${repo.name}`,
        body: `Working on ${issue.identifier}: ${issue.title}`
      }).show()
    },
    
    createWorkspace: async (issue, repository) => {
      // Create git worktree for the specific repository
      const worktreePath = await createWorktree(
        repository.repositoryPath,
        issue.identifier,
        repository.baseBranch
      )
      return { path: worktreePath, isGitWorktree: true }
    }
  }
})

await edgeWorker.start()

Configuration

Required Config

  • proxyUrl: URL of the edge proxy server
  • claudePath: Path to Claude CLI executable
  • repositories: Array of repository configurations

Repository Configuration

Each repository in the repositories array requires:

  • id: Unique identifier for the repository
  • name: Display name for the repository
  • repositoryPath: Local git repository path
  • baseBranch: Branch to create worktrees from (e.g., 'main')
  • linearWorkspaceId: Linear workspace/team ID
  • linearToken: OAuth token for this Linear workspace
  • workspaceBaseDir: Where to create issue workspaces

Optional per-repository settings:

  • isActive: Whether to process webhooks (default: true)
  • promptTemplatePath: Custom prompt template for this repo

Optional Handlers

All handlers are optional and now include repository context:

  • createWorkspace(issue, repository): Custom workspace creation
  • onClaudeEvent(issueId, event, repositoryId): Claude event updates
  • onSessionStart(issueId, issue, repositoryId): Session started
  • onSessionEnd(issueId, exitCode, repositoryId): Session ended
  • onError(error, context): Error handling

Features

  • enableContinuation: Use --continue flag for follow-up comments (default: true)
  • enableTokenLimitHandling: Auto-restart on token limits (default: true)
  • enableAttachmentDownload: Download issue attachments (default: false)

Events

The EdgeWorker extends EventEmitter and emits:

  • connected: Connected to proxy (token)
  • disconnected: Disconnected from proxy (token, reason)
  • session:started: Claude session started (issueId, issue, repositoryId)
  • session:ended: Claude session ended (issueId, exitCode, repositoryId)
  • claude:event: Any Claude event (issueId, event, repositoryId)
  • claude:response: Claude text response (issueId, text, repositoryId)
  • claude:tool-use: Claude used a tool (issueId, tool, input, repositoryId)
  • error: Error occurred (error, context)

Architecture

Your App (CLI/Electron)
    ↓ provides repository configs
EdgeWorker
    ↓ manages multiple repositories
    ├─→ Repository 1 (token A) ─→ Linear Workspace 1
    ├─→ Repository 2 (token A) ─→ Linear Workspace 1  
    └─→ Repository 3 (token B) ─→ Linear Workspace 2
    ↓ connects to proxy (grouped by token)
Edge Proxy
    ↓ webhooks from all workspaces
Linear

Key features:

  • Multiple repositories can share the same Linear workspace/token
  • Repositories with different tokens connect separately to minimize connections
  • Each repository has its own workspace directory and configuration
  • OAuth tokens serve dual purpose: proxy auth and Linear API calls

Prompt Templates

The EdgeWorker supports customizable prompt templates to tailor Claude's behavior for different repositories or workflows.

Default Template

If no custom template is specified, EdgeWorker uses a built-in template that helps Claude determine whether to:

  1. Execute - When requirements are clear, implement the solution
  2. Clarify - When requirements are vague, ask clarifying questions

Custom Templates

You can provide custom templates at two levels:

  • Global: Via config.features.promptTemplatePath
  • Per-repository: Via repository.promptTemplatePath (takes precedence)

Template Variables

Templates use Handlebars-style variables that are automatically replaced:

  • {{repository_name}} - Name of the repository
  • {{issue_id}} - Linear issue ID
  • {{issue_title}} - Issue title
  • {{issue_description}} - Full issue description
  • {{issue_state}} - Current issue state
  • {{issue_priority}} - Priority level (0-4)
  • {{issue_url}} - Direct link to Linear issue
  • {{comment_history}} - All previous comments formatted
  • {{latest_comment}} - Most recent comment text
  • {{working_directory}} - Current working directory
  • {{base_branch}} - Base git branch (e.g., 'main')
  • {{branch_name}} - Issue branch name

Example Custom Template

You are an expert {{repository_name}} developer.

## Current Task
**Issue**: {{issue_title}} (#{{issue_id}})
**Priority**: {{issue_priority}}
**Status**: {{issue_state}}

## Description
{{issue_description}}

## Previous Discussion
{{comment_history}}

## Technical Context
- Repository: {{repository_name}}
- Working Directory: {{working_directory}}
- Branch: {{branch_name}} (from {{base_branch}})

## Instructions
1. Review the issue requirements carefully
2. Check existing code patterns in the repository
3. Implement a solution following project conventions
4. Ensure all tests pass
5. Create a descriptive pull request

Remember to ask clarifying questions if requirements are unclear.

Using Custom Templates

// Global template for all repositories
const edgeWorker = new EdgeWorker({
  // ... other config
  features: {
    promptTemplatePath: './prompts/default.md'
  }
})

// Per-repository templates
const edgeWorker = new EdgeWorker({
  repositories: [{
    id: 'frontend',
    name: 'Frontend App',
    // ... other config
    promptTemplatePath: './prompts/frontend-specific.md'
  }, {
    id: 'backend', 
    name: 'Backend API',
    // ... other config
    promptTemplatePath: './prompts/backend-specific.md'
  }]
})