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

@shaohui_jin/git-cockpit-core

v0.1.15

Published

Git Cockpit 共享核心逻辑:GitService、权限、备份、日志

Readme

@shaohui_jin/git-cockpit-core

Git Cockpit 的共享核心逻辑,作为独立 npm 包发布,供 MCP Server 及未来基于它重构的下游项目(如 git-insight)直接复用。

涵盖 Git 仓库操作的封装、安全权限决策、备份、审计日志与本地存储,所有模块均依赖 Node 22+ 原生 node:sqlite,无外部数据库依赖。

环境要求

  • Node.js >= 22.5.0(使用 node:sqlite 原生模块)

安装

pnpm add @shaohui_jin/git-cockpit-core
# 或
npm install @shaohui_jin/git-cockpit-core

包为纯 ESM("type": "module"),提供 dist/index.d.ts 类型声明。

核心能力

| 模块 | 说明 | | --- | --- | | GitService | 基于 simple-git 的 Git 操作封装:串行执行队列、.git/index.lock 写前检查、数组参数防注入、高/中/低风险分级与 dry-run 写预览 | | PermissionManager | 工具级风险等级(readonly / write / dangerous)与审批规则决策 | | BackupManager | 高危操作前的备份与恢复 | | AuditLogger | 操作审计日志落库 | | RepoStore | 已打开仓库列表管理 | | openDatabase | 统一的 node:sqlite 数据库入口(数据目录由你传入) |

快速使用

import { GitService, PermissionManager, BackupManager, AuditLogger } from '@shaohui_jin/git-cockpit-core';

// 打开仓库(校验路径合法且是 Git 仓库),返回真实仓库根目录
const git = await GitService.open('/path/to/repo');

const status = await git.getStatus();             // RepoStatus 工作区状态
const preview = await git.commit('feat: x', { dryRun: true }); // 提交预览
console.log(preview.command, preview.affectedFiles);

// 权限决策
const pm = new PermissionManager({ permissions: { requireApprovalFor: ['git.reset.hard'] } });
const decision = pm.evaluate('git.reset.hard'); // { allowed: false, requiredApproval: true, ... }

// 高危操作前创建备份(保存分支引用与 stash 快照)
const backup = new BackupManager(git);
const result = await backup.createBackup();

发布说明(维护者)

版本号维护在 packages/core/package.json,发布由仓库根目录 .github/workflows/release-core.yml 负责:

  • 判据:远程不存在 core-v{version} tag 才发布
  • 流程:构建 → pnpm publish → 成功后才推送 tag core-v{version}
  • 触发:push 到 master/main,或 GitHub Actions 手动 workflow_dispatch
  • 需要仓库 Secret:NPM_TOKEN(npm Automation token)

详见仓库内 docs/release.md

License

MIT