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

open-code-cli

v1.19.1

Published

`open-code-cli` is a simple and efficient tool that enables you to quickly create command-line applications using TypeScript. With its well-structured codebase and robust features, it provides an easy-to-use interface for developing and testing your CLI a

Readme

Open Code CLI - GitHub Sync Workflow

A powerful CLI tool for syncing files and directories from GitHub repositories to your local machine using workflow configurations.

Prerequisites

  • Node.js 16+ installed
  • Git installed
  • GitHub personal access token with appropriate repository access

Installation

# Install globally
npm install -g open-code-cli

# Or use with npx
npx open-code-cli workflow workflow.json

GitHub Sync Workflow

The gh_sync task allows you to synchronize files and directories from GitHub repositories to your local machine.

Basic Usage

Create a JSON workflow file (e.g., sync-config.json) with the following structure:

{
  "workflow": [
    {
      "task": "gh_sync",
      "repos": [
        {
          "repo": "owner/repo-name",
          "sync": true,
          "force": false,
          "branch": "main",
          "files": [
            {
              "source": "path/in/repo",
              "local": "local/path"
            }
          ]
        }
      ]
    }
  ]
}

Run the workflow:

open-code-cli workflow sync-config.json

Configuration Options

Repository Configuration

| Property | Type | Required | Description | |-------------|-----------|----------|--------------------------------------------------| | repo | string | Yes | GitHub repository in format owner/repo | | sync | boolean | No | Whether to sync this repository (default: true) | | force | boolean | No | Force sync even if files haven't changed | | branch | string | No | Branch to sync from (default: main) | | forkRepo | string | No | (For contribute command) Fork repository to use for creating pull requests | | files | File[] | Yes | Array of file mappings |

File Mapping

| Property | Type | Required | Description | |----------|--------|----------|--------------------------------------------------| | source | string | Yes | Path in the repository to sync from | | local | string | Yes | Local path to sync to |

Example Configuration

{
  "workflow": [
    {
      "task": "gh_sync",
      "repos": [
        {
          "repo": "locospec/lens",
          "sync": true,
          "force": false,
          "branch": "main",
          "files": [
            {
              "source": "packages/lens-react/lib",
              "local": "resources/shared-js/locospec/lens-react/lib"
            }
          ]
        },
        {
          "repo": "locospec/engine-php",
          "sync": true,
          "force": false,
          "branch": "main",
          "forkRepo": "locospec/engine-php",
          "files": [
            {
              "source": "/",
              "local": "LCS/engine-php"
            }
          ]
        },
        {
          "repo": "locospec/locospec-laravel",
          "sync": true,
          "force": false,
          "branch": "main",
          "forkRepo": "locospec/locospec-laravel",
          "files": [
            {
              "source": "/",
              "local": "LCS/locospec-laravel"
            }
          ]
        }
      ]
    }
  ]
}

How It Works

  1. The tool checks if the local copy of each file exists and compares it with the remote version
  2. If the remote file is different, it will be downloaded and saved locally
  3. If force: true, files will be re-downloaded even if they haven't changed
  4. The tool maintains a cache of file hashes to track changes
  5. The repository is cloned once, and only changed files are copied locally

Best Practices

  1. Always specify the branch to avoid unexpected updates
  2. Use force: true sparingly to avoid unnecessary downloads
  3. Organize your file mappings logically for easier maintenance
  4. Add .open-code-cli to your .gitignore to avoid committing cache files

OpenRouter Integration

The AI-powered tasks require an OpenRouter API key. You can configure this using the init-open-router command:

open-code-cli init-open-router

This will prompt you for your API key and preferred model, storing the configuration in ~/.open-code-cli/openrouter.json.

Core Algorithms

File Action Decision Algorithm

The actionOnFile function determines what action to take on a file during synchronization by comparing file hashes and checking the tracker state:

Function: actionOnFile(
  sourcePath,
  localPath,
  repo,
  relativeLocalPath,
  trackerConfig,
  sourceCommitHash,
  force = false
)

1. If force is true:
   - Return COPY action (overrides all other logic)

2. If local file doesn't exist:
   - Return COPY action

3. Calculate hashes:
   - sourceFileHash = hash of source file
   - localFileHash = hash of local file
   - trackerFileHash = hash from tracker (if exists)
   - trackerAction = previous action from tracker (if exists)
   - lastCommitHash = last commit hash from tracker
   - currentCommitHash = sourceCommitHash or lastCommitHash

4. Special case for previously merged files (trackerAction === 'MERGE'):
   - If commit hash hasn't changed: Return NONE
   - If commit hash changed: Return MERGE

5. If no tracking data exists (first sync):
   - Return COPY action

6. Compare hashes to determine action:
   - If localFileHash === trackerFileHash && localFileHash !== sourceFileHash:
     - Return COPY (only source changed)
   - If localFileHash !== trackerFileHash && trackerFileHash === sourceFileHash:
     - Return NONE (only local changed)
   - If localFileHash !== trackerFileHash && localFileHash === sourceFileHash:
     - Return UPDATE_TRACKER (local changes pushed to source)
   - If localFileHash !== trackerFileHash && localFileHash !== sourceFileHash:
     - Return MERGE (both source and local changed)

7. Default: Return NONE (no changes detected)

2. Calculate hashes:
   - sourceFileHash = hash of source file
   - localFileHash = hash of local file
   - trackerFileHash = hash from tracker config (or null if not tracked)
   - lastCommitHash = commit hash from tracker (or null)
   - currentCommitHash = sourceCommitHash or lastCommitHash (or null)

3. Special handling for previously merged files:
   - If trackerAction is MERGE:
     - If lastCommitHash equals currentCommitHash:
       - Return NONE action (no changes needed)
     - Otherwise:
       - Return MERGE action (commit hash changed)

4. If no tracking data exists (trackerFileHash is null):
   - Return COPY action (first time syncing)

5. Compare file hashes:
   - If localFileHash equals trackerFileHash AND localFileHash doesn't equal sourceFileHash:
     - Return COPY action (only source file changed)
   - If localFileHash doesn't equal trackerFileHash AND trackerFileHash equals sourceFileHash:
     - Return NONE action (only local file changed)
   - If localFileHash doesn't equal trackerFileHash AND localFileHash equals sourceFileHash:
     - Return COPY action (local changes pushed to source)
   - If localFileHash doesn't equal trackerFileHash AND localFileHash doesn't equal sourceFileHash:
     - Return MERGE action (both files changed independently)

6. Default case:
   - Return NONE action (no changes detected)

This algorithm ensures files are properly synchronized while preserving local changes when appropriate and merging when necessary.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy Automating!