@handsupmin/gc-tree 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +172 -88
- package/README.ja.md +175 -91
- package/README.ko.md +177 -93
- package/README.md +169 -85
- package/README.zh.md +173 -89
- package/dist/src/resolve.js +40 -6
- package/docs/concept.es.md +37 -37
- package/docs/concept.ja.md +43 -43
- package/docs/concept.ko.md +41 -41
- package/docs/concept.md +15 -15
- package/docs/concept.zh.md +37 -37
- package/docs/local-development.es.md +25 -25
- package/docs/local-development.ja.md +22 -22
- package/docs/local-development.ko.md +25 -25
- package/docs/local-development.md +3 -3
- package/docs/local-development.zh.md +23 -23
- package/docs/principles.es.md +27 -26
- package/docs/principles.ja.md +28 -27
- package/docs/principles.ko.md +29 -28
- package/docs/principles.md +4 -4
- package/docs/principles.zh.md +28 -27
- package/docs/usage.es.md +32 -30
- package/docs/usage.ja.md +45 -43
- package/docs/usage.ko.md +41 -39
- package/docs/usage.md +2 -2
- package/docs/usage.zh.md +46 -44
- package/package.json +9 -2
package/README.zh.md
CHANGED
|
@@ -1,165 +1,249 @@
|
|
|
1
1
|
# gc-tree
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<img src="./logo.png" alt="gc-tree logo" width="260" />
|
|
6
|
+
|
|
7
|
+
### 不止于项目内部的全局上下文。
|
|
8
|
+
|
|
9
|
+
在你现有的 AI 工具之上,再加一层可复用、能长期积累的上下文。
|
|
10
|
+
像管理 Git 分支一样管理多条上下文线索。
|
|
11
|
+
|
|
12
|
+
[](https://www.npmjs.com/package/@handsupmin/gc-tree)
|
|
13
|
+
[](https://www.npmjs.com/package/@handsupmin/gc-tree)
|
|
14
|
+
[](https://github.com/handsupmin/gc-tree/stargazers)
|
|
15
|
+
[](https://github.com/handsupmin/gc-tree/blob/main/LICENSE)
|
|
16
|
+
[](https://nodejs.org)
|
|
4
17
|
|
|
5
18
|
[English](https://github.com/handsupmin/gc-tree/blob/main/README.md) | [한국어](https://github.com/handsupmin/gc-tree/blob/main/README.ko.md) | [简体中文](https://github.com/handsupmin/gc-tree/blob/main/README.zh.md) | [日本語](https://github.com/handsupmin/gc-tree/blob/main/README.ja.md) | [Español](https://github.com/handsupmin/gc-tree/blob/main/README.es.md)
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
</div>
|
|
8
21
|
|
|
9
|
-
|
|
10
|
-
它为长期上下文提供了一个可复用、基于文件、支持分支的明确归宿,而且可以自然接入现有工作流。
|
|
22
|
+
---
|
|
11
23
|
|
|
12
|
-
|
|
24
|
+
## 问题所在
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
- 用 markdown 文档保存 source of truth,而不是依赖隐藏记忆
|
|
16
|
-
- 通过精简索引和 summary-first 文档更快定位当前上下文
|
|
17
|
-
- 通过偏好的 LLM CLI 完成 onboarding 与长期更新
|
|
18
|
-
- 让某个 gc-branch 只作用于真正相关的仓库
|
|
26
|
+
你每天都在用 Claude Code 或 Codex。但你的实际工作横跨多个仓库、产品和客户——而 AI 工具只认识当前文件。
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
于是你不得不一遍遍地做这些事:
|
|
21
29
|
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
- **交互式范围保护**
|
|
27
|
-
如果 `gctree resolve` 发现当前仓库还没有映射到这个 gc-branch,它可以询问是仅本次继续、以后总是使用,还是在这个仓库里忽略它。
|
|
28
|
-
- **Summary-first 文档结构**
|
|
29
|
-
工具可以先读取简短摘要,只有在需要时才展开完整文档。
|
|
30
|
-
- **引导式长期更新**
|
|
31
|
-
不需要手写 JSON 文件,也可以通过同样的 provider 流程更新全局上下文。
|
|
30
|
+
- 重新解释哪些仓库属于同一套系统
|
|
31
|
+
- 把同一份架构文档反复粘贴进提示词
|
|
32
|
+
- 提醒 AI 它上周"已经知道"的编码规范
|
|
33
|
+
- 手动剔除与当前仓库无关的上下文
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
这不是 AI 的问题,而是**上下文管理的问题**。
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
---
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
npm install -g @handsupmin/gc-tree
|
|
39
|
-
```
|
|
39
|
+
## gc-tree 做什么
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
`gc-tree` 工作在**仓库之上**。它把上下文存储为结构化的 Markdown 文件,让 AI 工具在每次会话前自动拉取相关内容。
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
|
|
44
|
+
gctree resolve --query "auth token rotation policy"
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"gc_branch": "main",
|
|
50
|
+
"matches": [
|
|
51
|
+
{
|
|
52
|
+
"title": "认证与 Session 规范",
|
|
53
|
+
"score": 4,
|
|
54
|
+
"summary": "每次请求都做 JWT rotation,refresh token 存在 httpOnly cookie 里,access token TTL 15 分钟",
|
|
55
|
+
"excerpt": "## 认证流程\nAccess token:15 分钟 TTL,每次认证请求都做 rotation..."
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
AI 工具拿到的是正确的上下文——不是整个知识库,而是恰好相关的那一片。
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
**实测:每次查询只注入约 4% 的总上下文。** 其余 96% 留在磁盘上,真正需要时才进入 token 窗口。
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
gctree init
|
|
58
|
-
```
|
|
65
|
+
---
|
|
59
66
|
|
|
60
|
-
|
|
67
|
+
## 适合哪些人
|
|
61
68
|
|
|
62
|
-
-
|
|
63
|
-
- 创建默认 `main` gc-branch
|
|
64
|
-
- 让你选择 provider 模式(`claude-code`、`codex` 或 `both`)
|
|
65
|
-
- 如果你选择 `both`,再选择这次 onboarding 要由哪个 provider 启动
|
|
66
|
-
- 让你选择语言(`English`、`Korean`,或手动输入语言)
|
|
67
|
-
- 把 provider 模式、实际 onboarding provider 和语言保存到 `~/.gctree/settings.json`
|
|
68
|
-
- 为当前环境安装对应的命令表面
|
|
69
|
-
- 当 `main` 仍为空时,为当前 gc-branch 启动引导式 onboarding
|
|
69
|
+
如果以下几条符合你的情况,gc-tree 会很适合你:
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
- 工作横跨**多个仓库**(单体仓库团队、平台 + 客户仓库、后端 + 前端技术栈)
|
|
72
|
+
- 同一周内要在**多个产品或客户**之间来回切换
|
|
73
|
+
- 每次开 AI 会话都要**重复解释相同的上下文**
|
|
74
|
+
- 希望 AI 工具不只了解当前文件,还能理解**编码规范、架构和领域知识**
|
|
75
|
+
|
|
76
|
+
如果你只在一个仓库、一个产品里工作,不需要这个工具。`CLAUDE.md` 或 `.cursorrules` 就够了。
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 和 CLAUDE.md 或 cursor rules 有什么区别?
|
|
81
|
+
|
|
82
|
+
`CLAUDE.md` 很好用——在单个仓库里。
|
|
83
|
+
|
|
84
|
+
一旦你有了多个仓库、客户或工作线:
|
|
85
|
+
|
|
86
|
+
| | `CLAUDE.md` / cursor rules | `gc-tree` |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| 作用范围 | 单个仓库 | 多个仓库,一套上下文 |
|
|
89
|
+
| 持久化方式 | 仓库内的文件 | 存储在仓库外,跨会话复用 |
|
|
90
|
+
| 切换上下文 | 手动编辑文件 | `gctree checkout client-b` |
|
|
91
|
+
| 相关性过滤 | 全部或全无 | 只注入匹配的文档(约 4%) |
|
|
92
|
+
| 初始化方式 | 手写 | 由 AI 工具引导完成 |
|
|
93
|
+
| 支持 Codex | ✅ | ✅ |
|
|
94
|
+
| 支持 Claude Code | ✅ | ✅ |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 经过验证的性能
|
|
99
|
+
|
|
100
|
+
基于真实内部文档测试(4 份 Notion 导出,中英文混合查询):
|
|
101
|
+
|
|
102
|
+
| 指标 | 结果 |
|
|
103
|
+
|---|---|
|
|
104
|
+
| Recall——相关查询找到正确文档的比例 | **100%**(16/16) |
|
|
105
|
+
| Precision——无关查询返回空结果的比例 | **80%**(4/5) |
|
|
106
|
+
| F1 分数 | **88.9%** |
|
|
107
|
+
| 每次查询注入的 token 占总上下文的比例 | **约 4%** |
|
|
108
|
+
| 支持中英文混合查询 | ✅ |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Claude Code 和 Codex 均已验证可用
|
|
72
113
|
|
|
73
114
|
```bash
|
|
74
|
-
gctree
|
|
115
|
+
gctree scaffold --host claude-code # 安装 CLAUDE.md 片段 + /gc-onboard、/gc-update-global-context
|
|
116
|
+
gctree scaffold --host codex # 安装 AGENTS.md 片段 + $gc-onboard、$gc-update-global-context
|
|
117
|
+
gctree scaffold --host both # 两者同时安装
|
|
75
118
|
```
|
|
76
119
|
|
|
77
|
-
|
|
120
|
+
两个 provider 使用同一个底层上下文存储。onboard 一次,两个工具都能用。
|
|
121
|
+
|
|
122
|
+
**Claude Code** — 使用 `/gc-resolve-context`、`/gc-onboard`、`/gc-update-global-context` 斜杠命令。
|
|
78
123
|
|
|
79
|
-
|
|
80
|
-
2. 以后这个仓库总是使用这个 gc-branch
|
|
81
|
-
3. 在这个仓库里忽略这个 gc-branch
|
|
124
|
+
**Codex** — 使用 `$gc-resolve-context`、`$gc-onboard`、`$gc-update-global-context` skill。已通过 `codex exec` 实际验证:
|
|
82
125
|
|
|
83
|
-
|
|
126
|
+
```
|
|
127
|
+
gctree status → gc_branch: main,doc_count: 2
|
|
128
|
+
gctree resolve --query 'NestJS DTO plainToInstance'
|
|
129
|
+
→ 匹配到"后端编码规范"(score: 3)
|
|
130
|
+
→ DTO:class-transformer plainToInstance,class-validator 必填
|
|
131
|
+
→ 错误处理:基于 HttpException 的自定义异常,禁止直接抛出 raw Error
|
|
132
|
+
```
|
|
84
133
|
|
|
85
|
-
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 安装与快速开始
|
|
86
137
|
|
|
87
138
|
```bash
|
|
88
|
-
|
|
139
|
+
npm install -g @handsupmin/gc-tree
|
|
140
|
+
gctree init
|
|
89
141
|
```
|
|
90
142
|
|
|
91
|
-
`
|
|
143
|
+
`gctree init` 会引导你:
|
|
144
|
+
1. 选择 provider:`claude-code`、`codex` 或 `both`
|
|
145
|
+
2. 在当前仓库安装集成文件
|
|
146
|
+
3. 为 `main` gc-branch 完成引导式 onboarding
|
|
92
147
|
|
|
93
|
-
|
|
148
|
+
之后,AI 工具会自动学会在规划或实现前调用 `gctree resolve`。
|
|
149
|
+
|
|
150
|
+
- **CLI:** `gctree`
|
|
151
|
+
- **要求:** Node.js 20+
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 常用操作
|
|
156
|
+
|
|
157
|
+
### 为不同工作线创建独立上下文
|
|
94
158
|
|
|
95
159
|
```bash
|
|
160
|
+
gctree checkout -b client-b
|
|
96
161
|
gctree onboard
|
|
97
162
|
```
|
|
98
163
|
|
|
99
|
-
|
|
164
|
+
每个 gc-branch 都是完全独立的上下文通道,像 Git 分支一样自由切换。
|
|
165
|
+
|
|
166
|
+
### 按需拉取相关上下文
|
|
100
167
|
|
|
101
168
|
```bash
|
|
102
|
-
gctree
|
|
169
|
+
gctree resolve --query "billing retry policy"
|
|
103
170
|
```
|
|
104
171
|
|
|
105
|
-
|
|
172
|
+
只返回匹配的文档——标题、摘要和摘录。摘要不够用时,工具才会读完整文档。
|
|
173
|
+
|
|
174
|
+
### 保持上下文与时俱进
|
|
106
175
|
|
|
107
176
|
```bash
|
|
108
|
-
gctree update-gc
|
|
109
|
-
gctree ugc
|
|
177
|
+
gctree update-global-context # 或:gctree update-gc / gctree ugc
|
|
110
178
|
```
|
|
111
179
|
|
|
112
|
-
|
|
180
|
+
引导式更新流程——AI 工具询问发生了哪些变化,并将新上下文写回 gc-branch。
|
|
113
181
|
|
|
114
|
-
|
|
115
|
-
2. 再用 `gctree update-global-context` 补充这个仓库是什么、为什么重要等长期上下文
|
|
116
|
-
|
|
117
|
-
#### 6) 重新 onboarding 前先重置 gc-branch
|
|
182
|
+
### 限定上下文作用的仓库范围
|
|
118
183
|
|
|
119
184
|
```bash
|
|
120
|
-
gctree
|
|
185
|
+
gctree set-repo-scope --branch client-b --include # 包含当前仓库
|
|
186
|
+
gctree set-repo-scope --branch client-b --exclude # 排除当前仓库
|
|
121
187
|
```
|
|
122
188
|
|
|
123
|
-
|
|
189
|
+
`gc-tree` 不会向不相关的仓库注入上下文。
|
|
190
|
+
|
|
191
|
+
---
|
|
124
192
|
|
|
125
|
-
|
|
193
|
+
## 上下文的存储结构
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
~/.gctree/
|
|
197
|
+
branches/
|
|
198
|
+
main/
|
|
199
|
+
index.md ← 压缩索引,≤2000 字符,优先加载
|
|
200
|
+
docs/
|
|
201
|
+
auth.md ← 完整文档,按需读取
|
|
202
|
+
architecture.md
|
|
203
|
+
client-b/
|
|
204
|
+
index.md
|
|
205
|
+
docs/
|
|
206
|
+
...
|
|
207
|
+
branch-repo-map.json ← 哪些仓库属于哪个 gc-branch
|
|
208
|
+
settings.json ← 首选 provider、语言
|
|
209
|
+
```
|
|
126
210
|
|
|
127
|
-
|
|
128
|
-
- **Claude Code:** `/gc-onboard`, `/gc-update-global-context`
|
|
211
|
+
上下文存储在仓库之外——无需 `.gitignore` 规则,不会误提交,使用同一 gc-branch 的所有项目都可复用。
|
|
129
212
|
|
|
130
|
-
|
|
213
|
+
---
|
|
131
214
|
|
|
132
|
-
|
|
215
|
+
## 核心命令
|
|
133
216
|
|
|
134
217
|
| 目标 | 命令 |
|
|
135
|
-
|
|
218
|
+
|---|---|
|
|
136
219
|
| 初始化 gc-tree 并选择 provider | `gctree init` |
|
|
137
|
-
|
|
|
220
|
+
| 确认当前激活的 gc-branch | `gctree status` |
|
|
138
221
|
| 搜索当前上下文 | `gctree resolve --query "..."` |
|
|
139
|
-
| 查看仓库范围规则 | `gctree repo-map` |
|
|
140
|
-
| 为 gc-branch 显式设置仓库包含/排除 | `gctree set-repo-scope --branch <name> --include` / `--exclude` |
|
|
141
222
|
| 创建或切换 gc-branch | `gctree checkout <branch>` / `gctree checkout -b <branch>` |
|
|
142
|
-
|
|
|
143
|
-
|
|
|
223
|
+
| 列出所有 gc-branch | `gctree branches` |
|
|
224
|
+
| 对空 gc-branch 进行引导式 onboarding | `gctree onboard` |
|
|
225
|
+
| 对当前 gc-branch 进行引导式更新 | `gctree update-global-context` / `gctree ugc` |
|
|
226
|
+
| 查看仓库范围规则 | `gctree repo-map` |
|
|
227
|
+
| 为 gc-branch 包含或排除当前仓库 | `gctree set-repo-scope --branch <name> --include` / `--exclude` |
|
|
144
228
|
| 重新 onboarding 前重置 gc-branch | `gctree reset-gc-branch --branch <name> --yes` |
|
|
145
|
-
|
|
|
229
|
+
| 在新环境中安装 scaffold | `gctree scaffold --host codex --target /path/to/repo` |
|
|
146
230
|
|
|
147
|
-
|
|
231
|
+
---
|
|
148
232
|
|
|
149
|
-
|
|
233
|
+
## 文档
|
|
150
234
|
|
|
151
235
|
- **概念** — [`docs/concept.zh.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/concept.zh.md)
|
|
152
|
-
说明 `gctree` 是什么、解决什么问题,以及全局上下文层的边界。
|
|
153
236
|
- **原理** — [`docs/principles.zh.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/principles.zh.md)
|
|
154
|
-
介绍 gc-branch、仓库范围、summary-first 文档和引导式更新等原则。
|
|
155
237
|
- **使用方法** — [`docs/usage.zh.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/usage.zh.md)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
238
|
+
- **本地开发** — [`docs/local-development.zh.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/local-development.zh.md)
|
|
239
|
+
|
|
240
|
+
---
|
|
159
241
|
|
|
160
242
|
## 贡献
|
|
161
243
|
|
|
162
|
-
欢迎贡献。开发流程与 PR
|
|
244
|
+
欢迎贡献。开发流程与 PR 检查清单见 [CONTRIBUTING.md](https://github.com/handsupmin/gc-tree/blob/main/CONTRIBUTING.md)。
|
|
245
|
+
|
|
246
|
+
---
|
|
163
247
|
|
|
164
248
|
## 许可证
|
|
165
249
|
|
package/dist/src/resolve.js
CHANGED
|
@@ -2,13 +2,44 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { extractExcerpt, extractSummary, parseIndexEntries } from './markdown.js';
|
|
4
4
|
import { branchDir, branchIndexPath } from './paths.js';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// Common English stop words that are too short or generic to be meaningful query signals.
|
|
6
|
+
const STOP_WORDS = new Set([
|
|
7
|
+
'a', 'an', 'the', 'and', 'or', 'but', 'if', 'in', 'on', 'at', 'to', 'for',
|
|
8
|
+
'of', 'with', 'by', 'as', 'is', 'it', 'its', 'be', 'was', 'are', 'were',
|
|
9
|
+
'do', 'did', 'has', 'had', 'not', 'no', 'so', 'up', 'out', 'off', 'via',
|
|
10
|
+
'vs', 'per', 'set', 'get', 'run', 'add', 'use', 'new', 'old', 'all', 'any',
|
|
11
|
+
]);
|
|
12
|
+
function tokenize(text) {
|
|
13
|
+
// Split on whitespace, punctuation, and symbols — preserving Unicode letters
|
|
14
|
+
// and digits (including Korean, Japanese, CJK, etc.).
|
|
15
|
+
return String(text || '')
|
|
7
16
|
.toLowerCase()
|
|
8
|
-
.split(/[
|
|
9
|
-
.filter((
|
|
17
|
+
.split(/[^\p{L}\p{N}]+/u)
|
|
18
|
+
.filter((t) => t.length >= 2 && !STOP_WORDS.has(t));
|
|
19
|
+
}
|
|
20
|
+
function makeTokenRegex(token) {
|
|
21
|
+
// ASCII-only token: use \b word boundary (prevents "store" → "storefront").
|
|
22
|
+
// Non-ASCII token (Korean, CJK, etc.): use Unicode letter lookbehind/lookahead
|
|
23
|
+
// because \b doesn't work for non-ASCII characters.
|
|
24
|
+
const isAscii = /^[a-z0-9]+$/.test(token);
|
|
25
|
+
return isAscii
|
|
26
|
+
? new RegExp(`\\b${token}\\b`)
|
|
27
|
+
: new RegExp(`(?<!\\p{L})${token}(?!\\p{L})`, 'u');
|
|
28
|
+
}
|
|
29
|
+
function scoreText(text, query) {
|
|
30
|
+
const tokens = tokenize(query);
|
|
31
|
+
if (tokens.length === 0)
|
|
32
|
+
return 0;
|
|
10
33
|
const haystack = String(text || '').toLowerCase();
|
|
11
|
-
return tokens.reduce((sum, token) =>
|
|
34
|
+
return tokens.reduce((sum, token) => {
|
|
35
|
+
try {
|
|
36
|
+
return sum + (makeTokenRegex(token).test(haystack) ? 1 : 0);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Regex construction failed (e.g. special chars in token) — fall back to substring
|
|
40
|
+
return sum + (haystack.includes(token) ? 1 : 0);
|
|
41
|
+
}
|
|
42
|
+
}, 0);
|
|
12
43
|
}
|
|
13
44
|
export async function resolveContext({ home, branch, query, }) {
|
|
14
45
|
const indexRaw = await readFile(branchIndexPath(home, branch), 'utf8');
|
|
@@ -19,7 +50,10 @@ export async function resolveContext({ home, branch, query, }) {
|
|
|
19
50
|
const raw = await readFile(fullPath, 'utf8');
|
|
20
51
|
const summary = extractSummary(raw);
|
|
21
52
|
const combined = `${entry.title}\n${summary}\n${raw}`;
|
|
22
|
-
|
|
53
|
+
// Title matches count double (higher signal density)
|
|
54
|
+
const titleScore = scoreText(entry.title, query);
|
|
55
|
+
const bodyScore = scoreText(`${summary}\n${raw}`, query);
|
|
56
|
+
const score = titleScore * 2 + bodyScore;
|
|
23
57
|
if (score <= 0)
|
|
24
58
|
continue;
|
|
25
59
|
matches.push({
|
package/docs/concept.es.md
CHANGED
|
@@ -2,51 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
[English](concept.md) | [한국어](concept.ko.md) | [简体中文](concept.zh.md) | [日本語](concept.ja.md) | [Español](concept.es.md)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Resumen
|
|
6
6
|
|
|
7
|
-
`gctree` es una capa de contexto global
|
|
7
|
+
`gctree` es una capa ligera de contexto global para herramientas de programación con IA. Mantiene el contexto duradero en documentos markdown explícitos fuera de cualquier repositorio individual, permite cambiar entre gc-branches y puede limitar cada gc-branch a los repositorios donde realmente tiene sentido.
|
|
8
8
|
|
|
9
9
|
## Qué es `gctree`
|
|
10
10
|
|
|
11
|
-
`gctree` es una CLI
|
|
12
|
-
Está pensada para
|
|
11
|
+
`gctree` es una CLI para gestionar contexto global reutilizable.
|
|
12
|
+
Está pensada para equipos y personas que quieren que el contexto de largo recorrido sobreviva entre repositorios, sesiones y herramientas, sin convertirlo en una memoria oculta imposible de inspeccionar.
|
|
13
13
|
|
|
14
|
-
En lugar de
|
|
14
|
+
En lugar de repartir el conocimiento importante entre archivos de prompt, notas locales al repo e instrucciones improvisadas, `gctree` le da a ese conocimiento un hogar estable, visible y respaldado por archivos.
|
|
15
15
|
|
|
16
16
|
## Qué problema resuelve
|
|
17
17
|
|
|
18
|
-
Muchos entornos de programación con IA empiezan
|
|
18
|
+
Muchos entornos de programación con IA empiezan de forma bastante simple:
|
|
19
19
|
|
|
20
|
-
- un
|
|
21
|
-
- un
|
|
22
|
-
- un archivo de
|
|
23
|
-
-
|
|
20
|
+
- un `AGENTS.md`
|
|
21
|
+
- un `CLAUDE.md`
|
|
22
|
+
- un archivo de prompt dentro del repo
|
|
23
|
+
- unas pocas notas que se copian al prompt cuando hacen falta
|
|
24
24
|
|
|
25
|
-
Eso funciona
|
|
25
|
+
Eso funciona durante un tiempo. Pero cuando empiezan a aparecer necesidades reales, la misma configuración empieza a romperse:
|
|
26
26
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
27
|
+
- cada producto necesita un contexto distinto
|
|
28
|
+
- el trabajo para clientes debe mantenerse aislado
|
|
29
|
+
- la guía reutilizable debería vivir fuera de un único repositorio
|
|
30
|
+
- varias herramientas deberían poder leer la misma source of truth
|
|
31
|
+
- el contexto duradero debería evolucionar con un flujo seguro y revisable
|
|
32
|
+
- una misma persona puede tener muchas sesiones abiertas en muchos repos a la vez
|
|
33
33
|
|
|
34
|
-
`gctree`
|
|
34
|
+
`gctree` existe para resolver precisamente esa capa del problema, y hacerlo de forma limpia.
|
|
35
35
|
|
|
36
36
|
## Límite de alcance
|
|
37
37
|
|
|
38
|
-
`gctree`
|
|
38
|
+
`gctree` no pretende ser:
|
|
39
39
|
|
|
40
|
-
- un orquestador
|
|
40
|
+
- un orquestador integral que lleve una petición hasta el commit
|
|
41
41
|
- un sistema de memoria oculta
|
|
42
42
|
- un runtime de colaboración en navegador
|
|
43
|
-
- un producto
|
|
43
|
+
- un producto de base de conocimiento de propósito general
|
|
44
44
|
|
|
45
|
-
Se
|
|
45
|
+
Se concentra en una sola tarea: gestionar ramas de contexto global reutilizable y sus actualizaciones explícitas.
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## Modelo de archivos
|
|
48
48
|
|
|
49
|
-
Un directorio
|
|
49
|
+
Un directorio personal típico queda así:
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
52
|
~/.gctree/
|
|
@@ -60,22 +60,22 @@ Un directorio home típico se ve así:
|
|
|
60
60
|
docs/
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
- `HEAD`
|
|
64
|
-
- `settings.json` guarda el modo de provider, el provider
|
|
65
|
-
- `branch-repo-map.json` guarda
|
|
63
|
+
- `HEAD` sigue el gc-branch activo por defecto.
|
|
64
|
+
- `settings.json` guarda el modo de provider, el provider elegido para lanzar el onboarding en runtime y el idioma preferido del flujo.
|
|
65
|
+
- `branch-repo-map.json` guarda qué repositorios están incluidos o excluidos para cada gc-branch.
|
|
66
66
|
- `branch.json` guarda metadatos ligeros del gc-branch.
|
|
67
|
-
- `index.md` es el punto de entrada compacto para
|
|
68
|
-
- `docs/`
|
|
67
|
+
- `index.md` es el punto de entrada compacto para herramientas y personas.
|
|
68
|
+
- `docs/` contiene los documentos markdown que actúan como source of truth.
|
|
69
69
|
|
|
70
|
-
## Comportamiento con
|
|
70
|
+
## Comportamiento con conciencia de repositorio
|
|
71
71
|
|
|
72
|
-
Un gc-branch no tiene por qué aplicarse
|
|
73
|
-
Si la rama `A` solo es relevante para `B`, `C` y `D`,
|
|
72
|
+
Un gc-branch no tiene por qué aplicarse en todas partes.
|
|
73
|
+
Si la rama `A` solo es relevante para los repositorios `B`, `C` y `D`, `gctree` puede dejarlo registrado en `branch-repo-map.json`.
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Cuando `gctree resolve` se ejecuta desde otro repositorio, por ejemplo `F`, puede:
|
|
76
76
|
|
|
77
|
-
- continuar solo
|
|
78
|
-
- usar siempre
|
|
79
|
-
-
|
|
77
|
+
- continuar solo una vez
|
|
78
|
+
- usar siempre ese gc-branch en `F`
|
|
79
|
+
- ignorar ese gc-branch en `F`
|
|
80
80
|
|
|
81
|
-
Eso
|
|
81
|
+
Eso hace que gc-tree sea mucho más seguro para quienes mantienen muchas sesiones paralelas abiertas en repositorios que no tienen relación entre sí.
|
package/docs/concept.ja.md
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 概念
|
|
2
2
|
|
|
3
3
|
[English](concept.md) | [한국어](concept.ko.md) | [简体中文](concept.zh.md) | [日本語](concept.ja.md) | [Español](concept.es.md)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 要約
|
|
6
6
|
|
|
7
|
-
`gctree` は AI
|
|
7
|
+
`gctree` は AI コーディングツール向けの軽量なグローバルコンテキストレイヤーです。単一リポジトリの外側に長期コンテキストを明示的な markdown 文書として置き、gc-branch を切り替えながら文脈を使い分けられるようにし、各 gc-branch が本当に関係あるリポジトリにだけ影響するよう制御できます。
|
|
8
8
|
|
|
9
|
-
## `gctree`
|
|
9
|
+
## `gctree` とは何か
|
|
10
10
|
|
|
11
|
-
`gctree`
|
|
12
|
-
|
|
11
|
+
`gctree` は再利用できるグローバルコンテキストを管理するための CLI です。
|
|
12
|
+
複数のリポジトリ、複数のセッション、複数のツールをまたいでも長期コンテキストが生き残るようにしつつ、それをブラックボックスな隠れメモリにはしない、という前提で作られています。
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
大事な知識がプロンプトファイル、リポジトリ内メモ、場当たり的な指示に散らばる代わりに、`gctree` はその知識に安定したファイルベースの置き場所を与えます。
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## 何の問題を解決するのか
|
|
17
17
|
|
|
18
|
-
多くの AI
|
|
18
|
+
多くの AI コーディング環境は、最初はこんな形で始まります。
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
20
|
+
- `AGENTS.md` が 1 つ
|
|
21
|
+
- `CLAUDE.md` が 1 つ
|
|
22
|
+
- リポジトリ内の短いプロンプトファイルが 1 つ
|
|
23
|
+
- 必要なときだけプロンプトに貼り付けるメモが少し
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
しばらくはそれで回ります。けれど実務が乗ってくると、同じやり方はすぐ苦しくなります。
|
|
26
26
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
27
|
+
- プロダクトごとに必要なコンテキストが違う
|
|
28
|
+
- クライアント案件は互いに分離しておく必要がある
|
|
29
|
+
- 再利用したいガイダンスは単一リポジトリの外に置きたい
|
|
30
|
+
- 複数ツールが同じ source of truth を読めるべき
|
|
31
|
+
- 長期コンテキストは安全でレビュー可能な流れで育てたい
|
|
32
|
+
- 1 人のユーザーが同時に複数リポジトリで複数セッションを動かすことがある
|
|
33
33
|
|
|
34
|
-
`gctree`
|
|
34
|
+
`gctree` は、まさにそのレイヤーをきれいに扱うためのものです。
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## スコープの境界
|
|
37
37
|
|
|
38
|
-
`gctree`
|
|
38
|
+
`gctree` は意図的に、次のものではありません。
|
|
39
39
|
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
40
|
+
- リクエストからコミットまでを一気通貫で回す実行オーケストレータ
|
|
41
|
+
- 隠れメモリの仕組み
|
|
42
|
+
- ブラウザ型のコラボレーションランタイム
|
|
43
43
|
- 汎用ナレッジベース製品
|
|
44
44
|
|
|
45
|
-
`gctree`
|
|
45
|
+
`gctree` が集中する仕事は 1 つです。再利用できるグローバルコンテキストブランチと、その明示的な更新を管理することです。
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## ファイルモデル
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
典型的なホームディレクトリ配下の構成はこうなります。
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
52
|
~/.gctree/
|
|
@@ -60,22 +60,22 @@
|
|
|
60
60
|
docs/
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
- `HEAD`
|
|
64
|
-
- `settings.json`
|
|
65
|
-
- `branch-repo-map.json`
|
|
66
|
-
- `branch.json`
|
|
67
|
-
- `index.md`
|
|
68
|
-
- `docs/` には source-of-truth の markdown
|
|
63
|
+
- `HEAD` はデフォルトでアクティブになる gc-branch を追跡します。
|
|
64
|
+
- `settings.json` には provider モード、ランタイム起動に使うオンボーディング provider、優先するワークフロー言語が入ります。
|
|
65
|
+
- `branch-repo-map.json` には各 gc-branch ごとのリポジトリの include / exclude 情報が入ります。
|
|
66
|
+
- `branch.json` には軽量な gc-branch メタデータが入ります。
|
|
67
|
+
- `index.md` はツールが最初に読むコンパクトな入口です。
|
|
68
|
+
- `docs/` には source-of-truth の markdown 文書が入ります。
|
|
69
69
|
|
|
70
|
-
##
|
|
70
|
+
## リポジトリを意識した振る舞い
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
たとえば branch `A` が `B`、`C`、`D`
|
|
72
|
+
gc-branch はどこでも有効である必要はありません。
|
|
73
|
+
たとえば branch `A` が repo `B`、`C`、`D` にしか関係しないなら、その事実を `branch-repo-map.json` に記録できます。
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
その状態で別の repo `F` から `gctree resolve` を実行した場合、`gctree` は次のように扱えます。
|
|
76
76
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
77
|
+
- 今回だけ続ける
|
|
78
|
+
- 今後も `F` ではその gc-branch を使う
|
|
79
|
+
- `F` ではその gc-branch を無視する
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
これによって、無関係なリポジトリをまたいで多くの並行セッションを開いているヘビーユーザーでも、gc-tree をかなり安全に使えます。
|