Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .git-ai/lancedb.tar.gz
Git LFS file not shown
70 changes: 36 additions & 34 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,94 @@
# 开发指引
# Development Guide

## 先决条件
- Node.js 18+(建议 20+)
- Git(可选:git-lfs)
[简体中文](./DEVELOPMENT.zh-CN.md) | **English**

### Windows / Linux 安装注意
- `@lancedb/lancedb` 使用 N-API 预编译包,支持 win32/linux/darwin(x64/arm64)。如果安装失败,优先确认:Node 版本 >=18 且架构是 x64/arm64。
- `tree-sitter` / `tree-sitter-typescript` 依赖原生扩展,通常会拉取预编译包;若你的平台/Node 版本没有命中预编译包,则需要本机编译工具链:
- Windows:安装 “Visual Studio Build Tools(C++)” 与 Python(node-gyp 需要)
- Linux:安装 `build-essential`、`python3`(不同发行版包名略有差异)
## Prerequisites
- Node.js 18+ (20+ recommended)
- Git (optional: git-lfs)

## 安装依赖与构建
### Windows / Linux Installation Notes
- `@lancedb/lancedb` uses N-API prebuilt binaries, supporting win32/linux/darwin (x64/arm64). If installation fails, first check: Node version >=18 and architecture is x64/arm64.
- `tree-sitter` / `tree-sitter-typescript` rely on native extensions, usually fetching prebuilt binaries; if your platform/Node version doesn't hit a prebuilt binary, you need a local build toolchain:
- Windows: Install "Visual Studio Build Tools (C++)" and Python (required by node-gyp)
- Linux: Install `build-essential`, `python3` (package names may vary by distro)

## Install Dependencies & Build

```bash
npm i
npm run build
```

本项目使用 TypeScript 编译输出到 `dist/`
This project uses TypeScript to compile output to `dist/`.

## 本地运行(开发态)
## Local Run (Development)

```bash
npm run start -- --help
```

建议用 `node dist/bin/git-ai.js ...` 验证打包后的行为:
It is recommended to use `node dist/bin/git-ai.js ...` to verify behavior after packaging:

```bash
npm run build
node dist/bin/git-ai.js --help
node dist/bin/git-ai.js ai --help
```

## 全局安装(本机验证)
## Global Installation (Local Verification)

```bash
npm i -g .
git-ai --version
```

## 端到端测试
## End-to-End Tests

```bash
npm test
```

测试会在临时目录创建两类仓库(Spring Boot / Vue)并验证:
- `git-ai` 代理 git 的常用命令
Tests will create two types of repositories (Spring Boot / Vue) in a temporary directory and verify:
- `git-ai` proxies common git commands
- `git-ai ai index/pack/unpack/hooks`
- MCP server 的工具暴露
- MCP server tool exposure

## 常用开发工作流
## Common Development Workflow

### 1) 在任意仓库里跑索引
### 1) Run Indexing in Any Repo

```bash
cd /path/to/repo
git-ai ai index --overwrite
git-ai ai pack
```

### 2) 安装 hooks(让索引随提交自动更新)
### 2) Install Hooks (Auto-update index on commit)

```bash
git-ai ai hooks install
git-ai ai hooks status
```

### 3) 启动 MCP Server(供 Agent 查询)
### 3) Start MCP Server (For Agent Query)

```bash
git-ai ai serve
```

如果宿主无法保证工作目录指向仓库目录,可以先让 Agent 调用 `set_repo({path: ...})`,或在工具参数里传 `path`
If the host cannot guarantee the working directory points to the repository directory, you can let the Agent call `set_repo({path: ...})` first, or pass `path` in tool parameters.

## 发布注意事项(npm
- 确保 `npm run build` 已生成 `dist/**`
- `package.json` `files` 字段已包含 `dist/**` `assets/**`
- 发布前确认未提交任何敏感信息(token/密钥)
## Publishing Notes (npm)
- Ensure `npm run build` has generated `dist/**`
- `package.json` `files` field includes `dist/**` and `assets/**`
- Confirm no sensitive info (tokens/keys) is committed before publishing

### GitHub Actions(归档 + GitHub Packages
仓库已提供发布工作流:当推送 tag `v*` 时,会:
### GitHub Actions (Archive + GitHub Packages)
Repository provides a release workflow: when pushing tag `v*`, it will:
- `npm ci` + `npm test`
- `npm pack` 生成 tgz 并作为 Release 资产上传
- 发布到 GitHub Packagesnpm.pkg.github.com
- `npm pack` generate tgz and upload as Release asset
- Publish to GitHub Packages (npm.pkg.github.com)

说明:
- GitHub Packages npm 包名需要 scope,工作流会在发布时临时把包名改为 `@<repo_owner>/git-ai`(不修改仓库内源码包名)。
- 如需同时发布 npmjs.org,请在仓库 Secrets 配置 `NPM_TOKEN`
Note:
- GitHub Packages npm package names require a scope. The workflow will temporarily change the package name to `@<repo_owner>/git-ai` during publishing (without modifying source package.json).
- To publish to npmjs.org simultaneously, please configure `NPM_TOKEN` in repository Secrets.
94 changes: 94 additions & 0 deletions DEVELOPMENT.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# 开发指引

**简体中文** | [English](./DEVELOPMENT.md)

## 先决条件
- Node.js 18+(建议 20+)
- Git(可选:git-lfs)

### Windows / Linux 安装注意
- `@lancedb/lancedb` 使用 N-API 预编译包,支持 win32/linux/darwin(x64/arm64)。如果安装失败,优先确认:Node 版本 >=18 且架构是 x64/arm64。
- `tree-sitter` / `tree-sitter-typescript` 依赖原生扩展,通常会拉取预编译包;若你的平台/Node 版本没有命中预编译包,则需要本机编译工具链:
- Windows:安装 “Visual Studio Build Tools(C++)” 与 Python(node-gyp 需要)
- Linux:安装 `build-essential`、`python3`(不同发行版包名略有差异)

## 安装依赖与构建

```bash
npm i
npm run build
```

本项目使用 TypeScript 编译输出到 `dist/`。

## 本地运行(开发态)

```bash
npm run start -- --help
```

建议用 `node dist/bin/git-ai.js ...` 验证打包后的行为:

```bash
npm run build
node dist/bin/git-ai.js --help
node dist/bin/git-ai.js ai --help
```

## 全局安装(本机验证)

```bash
npm i -g .
git-ai --version
```

## 端到端测试

```bash
npm test
```

测试会在临时目录创建两类仓库(Spring Boot / Vue)并验证:
- `git-ai` 代理 git 的常用命令
- `git-ai ai index/pack/unpack/hooks`
- MCP server 的工具暴露

## 常用开发工作流

### 1) 在任意仓库里跑索引

```bash
cd /path/to/repo
git-ai ai index --overwrite
git-ai ai pack
```

### 2) 安装 hooks(让索引随提交自动更新)

```bash
git-ai ai hooks install
git-ai ai hooks status
```

### 3) 启动 MCP Server(供 Agent 查询)

```bash
git-ai ai serve
```

如果宿主无法保证工作目录指向仓库目录,可以先让 Agent 调用 `set_repo({path: ...})`,或在工具参数里传 `path`。

## 发布注意事项(npm)
- 确保 `npm run build` 已生成 `dist/**`
- `package.json` 的 `files` 字段已包含 `dist/**` 与 `assets/**`
- 发布前确认未提交任何敏感信息(token/密钥)

### GitHub Actions(归档 + GitHub Packages)
仓库已提供发布工作流:当推送 tag `v*` 时,会:
- `npm ci` + `npm test`
- `npm pack` 生成 tgz 并作为 Release 资产上传
- 发布到 GitHub Packages(npm.pkg.github.com)

说明:
- GitHub Packages 的 npm 包名需要 scope,工作流会在发布时临时把包名改为 `@<repo_owner>/git-ai`(不修改仓库内源码包名)。
- 如需同时发布 npmjs.org,请在仓库 Secrets 配置 `NPM_TOKEN`。
Loading