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

goluscriptmage-sync-cli

v1.0.0

Published

> **AI-Powered Git Workspace Documentation Synchronizer CLI Daemon**

Readme

📂 sync-cli (shadow-docs)

AI-Powered Git Workspace Documentation Synchronizer CLI Daemon

An intelligent developer workspace utility that monitors repository states, captures structural diffs, and integrates with the Google Gemini API to automatically generate and append codebase change summaries to STRUCTURE.md.


⚙️ Core Architecture & Flow

  [npx shadow-docs sync]  OR  [shadow-docs sync]
          │
          ▼
   (Git Verification) ➔ ensureCleanTree()
          │
     ┌────┴────────────────────────┐
     ▼                             ▼
[No Lock File]               [Has Lock File]
  └─► Baseline created.        ├─► git diff <lastHash> HEAD
  └─► Save current hash.       ├─► Read existing STRUCTURE.md (History)
  └─► Gather git ls-files (Structure)
                               │
                               ▼
                        (Ultimate Context)
                               │
                               ▼
                       [AIManager (Gemini)]
                               │
                               ▼
                  (Update Docs & Save lock state)

🛠️ Installation & Setup

1. Install Dependencies

Ensure you are in the project root directory and run:

npm install

This installs the required dependencies including @google/generative-ai for AI calls, commander for CLI structure, and chalk for console coloring.

2. Environment Configuration

Create a .env file in the root folder and add your Google Gemini API key:

GOOGLE_GEMINI_API_KEY=your_gemini_api_key_here

3. Compile the Codebase

Compile the TypeScript files using the local TS compiler config:

npm run build

This runs the TS compiler (tsc), transpiling TypeScript source files into executable ES modules inside the dist/ directory.


🚀 CLI Commands & Usage

The CLI currently exposes one primary command: sync.

Running the CLI Locally (via npx)

To test or execute the synchronization command directly from the build distribution:

npx shadow-docs sync

Running the CLI Globally (Recommended)

You can link the executable binary globally to your local system path:

npm link

After linking, you can run the CLI from any target repository workspace on your machine directly:

shadow-docs sync

What the sync Command Does:

  1. Validates Git Tree Cleanliness: Checks that your working tree has no uncommitted changes (ensureCleanTree). If there are dirty files, it aborts execution to maintain a stable commit-based baseline.
  2. Baseline Initialization (First Run): If .shadow-lock does not exist, it saves the current HEAD commit hash in .shadow-lock as a starting baseline. No documentation is written, and it prints Baseline created!.
  3. Diff Comparison (Subsequent Runs): On later runs, it compares the current HEAD commit hash against the lastHash stored in .shadow-lock.
  4. Generates Context Prompt: If changes exist, it extracts the code diff, maps the project file listing (git ls-files), and reads the existing documentation history (STRUCTURE.md).
  5. Generates and Appends Summary: Sends the full context to the Google Gemini model and appends the returned bulleted change summary to STRUCTURE.md without wiping existing records.

📂 Repository Directory Layout

shadow-docs/
├── src/
│   ├── commands/
│   │   └── sync.ts      # Main sync command orchestrator
│   ├── lib/
│   │   ├── ai.ts        # Gemini API prompt builder & content generator
│   │   └── git.ts       # Git status, diff, & file listings
│   ├── utils/
│   │   └── store.ts     # State management (.shadow-lock & STRUCTURE.md)
│   └── index.ts         # Commander CLI entrypoint registration
├── tsconfig.json        # TypeScript compiler parameters
└── package.json         # Package configuration and script definitions

🔒 State Persistence Specifications

  • .shadow-lock: A lightweight state configuration tracking the last synchronized commit hash and date:
    {
      "lastHash": "7083be62ee1e594ff1d81cbce7bed79ace4ee5a4",
      "updatedAt": "2026-07-12T14:44:56Z"
    }
  • STRUCTURE.md: The persistent documentation diary. The tool automatically appends updates to this file chronologically:
    ## 🗓️ Update: YYYY-MM-DD
    * Summary of code modifications generated by the model.

🚫 Constraints & Safety Rules

  • No Dirty Trees: The tool will abort execution if uncommitted active changes exist.
  • No Environment Bypass: Requires a valid GOOGLE_GEMINI_API_KEY to be loaded before generating summaries.
  • No Manual Lock Modifications: Modifying .shadow-lock manually might cause desynchronized states.