@handsupmin/gc-tree 0.1.4 → 0.2.1

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/docs/usage.md CHANGED
@@ -36,7 +36,33 @@ A standard `gctree` workflow looks like this: initialize gc-tree, choose a provi
36
36
  | `gctree reset-gc-branch --branch <name> --yes` | Clear a gc-branch so it can be onboarded again. |
37
37
  | `gctree update-global-context` | Launch a guided durable update for the active gc-branch. |
38
38
  | `gctree update-gc` / `gctree ugc` | Aliases for `gctree update-global-context`. |
39
- | `gctree scaffold --host <codex|claude-code>` | Install the provider-facing command surface in another environment. |
39
+ | `gctree scaffold --host <codex\|claude-code>` | Install the provider-facing command surface in another environment. |
40
+
41
+ ## What resolve returns
42
+
43
+ `gctree resolve` scores every document in the active gc-branch against your query and returns only the matching ones. Title matches count twice as much as body matches.
44
+
45
+ ```bash
46
+ gctree resolve --query "auth token rotation policy"
47
+ ```
48
+
49
+ ```json
50
+ {
51
+ "gc_branch": "main",
52
+ "query": "auth token rotation policy",
53
+ "matches": [
54
+ {
55
+ "title": "Auth & Session Conventions",
56
+ "path": "docs/auth.md",
57
+ "score": 4,
58
+ "summary": "JWT rotation on every request, refresh tokens in httpOnly cookies, 15-min access token TTL",
59
+ "excerpt": "## Auth Flow\nAccess token: 15-min TTL, rotated on every authenticated request..."
60
+ }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ The tool receives the summary and excerpt first. It reads the full document at `path` only when the summary is not enough. A query that matches nothing returns `"matches": []`.
40
66
 
41
67
  ## Example repo-scope flow
42
68
 
@@ -107,14 +133,36 @@ If a newly relevant repo should also become part of the durable context, the nat
107
133
 
108
134
  ### Codex CLI / Claude Code CLI
109
135
 
110
- `gctree scaffold` installs provider-facing commands such as guided onboarding and guided updates.
111
- Those commands should explicitly mention the current active gc-branch before they start gathering or applying durable context, and they should keep using the saved workflow language unless the user explicitly asks to switch.
136
+ `gctree scaffold` installs provider-facing command files into the target directory.
112
137
 
113
138
  ```bash
114
139
  gctree scaffold --host codex --target /path/to/repo
115
140
  gctree scaffold --host claude-code --target /path/to/repo
141
+ gctree scaffold --host both --target /path/to/repo
142
+ ```
143
+
144
+ **Files written for `--host codex`:**
145
+
146
+ ```
147
+ AGENTS.md ← gctree snippet appended to agent instructions
148
+ .codex/prompts/gctree-bootstrap.md ← bootstrap context for Codex sessions
149
+ .codex/skills/gc-resolve-context/SKILL.md ← resolve skill
150
+ .codex/skills/gc-onboard/SKILL.md ← onboarding skill
151
+ .codex/skills/gc-update-global-context/SKILL.md ← update skill
116
152
  ```
117
153
 
154
+ **Files written for `--host claude-code`:**
155
+
156
+ ```
157
+ CLAUDE.md ← gctree snippet appended
158
+ .claude/hooks/gctree-session-start.md ← session-start hook
159
+ .claude/commands/gc-resolve-context.md ← resolve slash command
160
+ .claude/commands/gc-onboard.md ← onboard slash command
161
+ .claude/commands/gc-update-global-context.md ← update slash command
162
+ ```
163
+
164
+ Existing files are left untouched unless you pass `--force`.
165
+
118
166
  ### Runtime behavior
119
167
 
120
168
  The active gc-branch is the one pointed to by `HEAD` inside `~/.gctree`, but repo mapping can override that fallback when a repository is explicitly bound to another gc-branch.
package/docs/usage.zh.md CHANGED
@@ -1,48 +1,74 @@
1
- # 使用方法
1
+ # 使用指南
2
2
 
3
3
  [English](usage.md) | [한국어](usage.ko.md) | [简体中文](usage.zh.md) | [日本語](usage.ja.md) | [Español](usage.es.md)
4
4
 
5
- ## 摘要
5
+ ## 概述
6
6
 
7
- 标准的 `gctree` 工作流大致是这样的:先初始化 gc-tree,选择 provider,为默认的 `main` gc-branch 完成 onboarding,用 resolve 拉取当前需要的上下文,在需要的时候创建新的 gc-branch,把仓库映射到正确的 gc-branch,后续再通过带引导的更新来维护长期上下文。
7
+ 标准的 `gctree` 工作流如下:初始化 gc-tree、选择提供商、对默认的 `main` gc-branch 执行 onboard、解析所需上下文、在工作需要独立空间时创建新的 gc-branch、将代码仓库映射到正确的 gc-branch,以及在后续使用有引导的更新流程进行持久化变更。
8
8
 
9
9
  ## 标准工作流
10
10
 
11
11
  1. 运行 `gctree init`
12
- 2. 选择你偏好的 provider 模式(`claude-code`、`codex` 或 `both`)
12
+ 2. 选择首选的提供商模式(`claude-code`、`codex` 或 `both`)
13
13
  3. 选择工作流语言(`English`、`Korean` 或自定义语言)
14
- 4. 如果你选择了 `both`,再决定这次 onboarding 由哪个 provider 先启动
15
- 5. 完成默认 `main` gc-branch 的引导式 onboarding
16
- 6. `gctree resolve --query "..."` 拉取相关上下文
17
- 7. `gctree checkout` 创建或切换 gc-branch
18
- 8. `gctree onboard` 只用于空的 gc-branch
19
- 9. 通过 repo scope 映射,让 gc-branch 只在它该生效的仓库里生效
20
- 10. 之后的长期变化用 `gctree update-global-context` 来补充
14
+ 4. 如果选择了 `both`,选择哪个提供商现在开始 onboarding
15
+ 5. 对默认的 `main` gc-branch 完成有引导的 onboarding
16
+ 6. 使用 `gctree resolve --query "..."` 解析相关上下文
17
+ 7. 使用 `gctree checkout` 创建或切换 gc-branch
18
+ 8. 仅对空的 gc-branch 运行 `gctree onboard`
19
+ 9. 使用仓库作用范围映射,使 gc-branch 只在其适用的地方生效
20
+ 10. 使用 `gctree update-global-context` 进行后续的持久化变更
21
21
 
22
22
  ## 核心命令
23
23
 
24
24
  | 命令 | 用途 |
25
25
  | --- | --- |
26
- | `gctree init` | 创建 `~/.gctree`,创建默认 `main` gc-branch,保存 provider 模式 / onboarding provider / 偏好语言,为当前环境安装 scaffold,并在 `main` 为空时启动引导式 onboarding。 |
27
- | `gctree checkout <branch>` | 切换当前激活的 gc-branch。 |
28
- | `gctree checkout -b <branch>` | 创建一个新的空 gc-branch 并立即切换过去。 |
29
- | `gctree branches` | 列出可用的 gc-branch,并标出当前激活的是哪一个。 |
30
- | `gctree status` | 显示当前 gc-branch、当前仓库、当前 repo-scope 状态、告警以及偏好的 provider。 |
31
- | `gctree resolve --query TEXT` | 从相关 gc-branch 中搜索上下文。如果当前仓库还没有映射,`gctree` 可能会询问应该如何处理这个仓库。 |
32
- | `gctree repo-map` | 显示当前 `branch-repo-map.json` 的内容。 |
33
- | `gctree set-repo-scope --branch <name> --include` | 把当前仓库标记为该 gc-branch 的包含仓库。 |
34
- | `gctree set-repo-scope --branch <name> --exclude` | 把当前仓库标记为该 gc-branch 下应忽略的仓库。 |
35
- | `gctree onboard` | 为当前激活的 gc-branch 启动引导式 onboarding。只有在该 gc-branch 为空时才可用。 |
36
- | `gctree reset-gc-branch --branch <name> --yes` | 清空某条 gc-branch,让它可以重新 onboarding。 |
37
- | `gctree update-global-context` | 为当前激活的 gc-branch 启动一次带引导的长期更新。 |
38
- | `gctree update-gc` / `gctree ugc` | `gctree update-global-context` 的简短别名。 |
39
- | `gctree scaffold --host <codex|claude-code>` | 在其他环境里安装 provider 对应的命令表面。 |
40
-
41
- ## repo scope 示例流程
42
-
43
- 假设 gc-branch `A` 与仓库 `B`、`C`、`D` 相关,但与 `F` 无关。
44
-
45
- 你可以这样管理:
26
+ | `gctree init` | 创建 `~/.gctree`,创建默认的 `main` gc-branch,保存提供商模式、onboarding 提供商及首选语言,scaffold 当前环境,并在 `main` 为空时启动有引导的 onboarding。 |
27
+ | `gctree checkout <branch>` | 切换活跃的 gc-branch。 |
28
+ | `gctree checkout -b <branch>` | 创建并切换到一个新的空 gc-branch |
29
+ | `gctree branches` | 列出可用的 gc-branch 并显示当前活跃的那个。 |
30
+ | `gctree status` | 显示活跃的 gc-branch、当前仓库、当前仓库的作用范围状态、警告信息及首选提供商。 |
31
+ | `gctree resolve --query TEXT` | 在相关的 gc-branch 中搜索上下文。如果当前仓库尚未映射,`gctree` 会询问该如何处理这个仓库。 |
32
+ | `gctree repo-map` | 显示 `branch-repo-map.json` 的当前内容。 |
33
+ | `gctree set-repo-scope --branch <name> --include` | 将当前仓库标记为该 gc-branch 的包含仓库。 |
34
+ | `gctree set-repo-scope --branch <name> --exclude` | 将当前仓库标记为该 gc-branch 的忽略仓库。 |
35
+ | `gctree onboard` | 为活跃的 gc-branch 启动有引导的 onboarding。仅当该 gc-branch 为空时有效。 |
36
+ | `gctree reset-gc-branch --branch <name> --yes` | 清空一个 gc-branch,使其可以重新 onboard。 |
37
+ | `gctree update-global-context` | 为活跃的 gc-branch 启动有引导的持久化更新。 |
38
+ | `gctree update-gc` / `gctree ugc` | `gctree update-global-context` 的别名。 |
39
+ | `gctree scaffold --host <codex\|claude-code>` | 在另一个环境中安装面向提供商的命令接口。 |
40
+
41
+ ## resolve 返回的内容
42
+
43
+ `gctree resolve` 对活跃 gc-branch 中的每个文档与查询内容进行评分,只返回匹配的文档。标题匹配的权重是正文匹配的两倍。
44
+
45
+ ```bash
46
+ gctree resolve --query "auth token rotation policy"
47
+ ```
48
+
49
+ ```json
50
+ {
51
+ "gc_branch": "main",
52
+ "query": "auth token rotation policy",
53
+ "matches": [
54
+ {
55
+ "title": "Auth & Session Conventions",
56
+ "path": "docs/auth.md",
57
+ "score": 4,
58
+ "summary": "JWT rotation on every request, refresh tokens in httpOnly cookies, 15-min access token TTL",
59
+ "excerpt": "## Auth Flow\nAccess token: 15-min TTL, rotated on every authenticated request..."
60
+ }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ 工具首先接收摘要和摘录。只有在摘要不足以满足需求时,才会读取 `path` 指向的完整文档。如果查询没有任何匹配,则返回 `"matches": []`。
66
+
67
+ ## 仓库作用范围示例流程
68
+
69
+ 假设 gc-branch `A` 与代码仓库 `B`、`C` 和 `D` 相关,但与 `F` 无关。
70
+
71
+ 可以通过以下方式管理:
46
72
 
47
73
  ```json
48
74
  {
@@ -53,19 +79,19 @@
53
79
  }
54
80
  ```
55
81
 
56
- 这份配置保存在:
82
+ 存储在:
57
83
 
58
84
  ```text
59
85
  ~/.gctree/branch-repo-map.json
60
86
  ```
61
87
 
62
- 当你在仓库 `E` 中执行 `resolve`,而 branch `A` 还没有映射到这里时,`gctree` 可以询问你是否要:
88
+ `resolve` 在代码仓库 `E` 中运行,而分支 `A` 尚未在 `E` 中映射时,`gctree` 会询问:
63
89
 
64
- 1. 只这一次继续
65
- 2. 以后在 `E` 中始终使用 `A`
90
+ 1. 继续一次
91
+ 2. 始终在 `E` 中使用 `A`
66
92
  3. 在 `E` 中忽略 `A`
67
93
 
68
- ## 首次运行示例
94
+ ## 首次运行示例流程
69
95
 
70
96
  ```bash
71
97
  gctree init
@@ -74,10 +100,10 @@ gctree init
74
100
  然后:
75
101
 
76
102
  1. 选择 `codex` 或 `claude-code`
77
- 2. 让 `gctree` 为当前环境安装 scaffold
78
- 3. 完成 `main` gc-branch 的引导式 onboarding
103
+ 2. 让 `gctree` scaffold 当前环境
104
+ 3. `main` gc-branch 完成有引导的 onboarding
79
105
 
80
- ## 多分支示例
106
+ ## 多分支示例流程
81
107
 
82
108
  ```bash
83
109
  gctree checkout -b client-b
@@ -85,7 +111,7 @@ gctree onboard
85
111
  gctree resolve --query "billing retry policy"
86
112
  ```
87
113
 
88
- ## 更新示例
114
+ ## 更新示例流程
89
115
 
90
116
  ```bash
91
117
  gctree update-global-context
@@ -98,24 +124,46 @@ gctree update-gc
98
124
  gctree ugc
99
125
  ```
100
126
 
101
- 如果某个新变得重要的仓库也应该进入长期上下文,更自然的流程是:
127
+ 如果一个新相关的代码仓库也需要成为持久化上下文的一部分,自然的流程是:
102
128
 
103
- 1. 先把这个仓库映射到对应的 gc-branch
104
- 2. 再执行 `update-global-context`,补充这个仓库做什么、为什么重要等长期知识
129
+ 1. 将该仓库映射到 gc-branch
130
+ 2. 然后运行 `update-global-context`,添加关于该仓库用途及重要性的持久化知识
105
131
 
106
132
  ## 集成模式
107
133
 
108
134
  ### Codex CLI / Claude Code CLI
109
135
 
110
- `gctree scaffold` 会安装面向 provider 的命令表面,比如引导式 onboarding 和引导式更新。
111
- 这些命令在开始收集或应用长期上下文之前,都应该明确说明当前激活的是哪条 gc-branch,并且除非用户明确要求切换,否则应继续使用已经保存的工作流语言。
136
+ `gctree scaffold` 将面向提供商的命令文件安装到目标目录中。
112
137
 
113
138
  ```bash
114
139
  gctree scaffold --host codex --target /path/to/repo
115
140
  gctree scaffold --host claude-code --target /path/to/repo
141
+ gctree scaffold --host both --target /path/to/repo
142
+ ```
143
+
144
+ **`--host codex` 写入的文件:**
145
+
146
+ ```
147
+ AGENTS.md ← gctree 代码片段追加到 agent 指令中
148
+ .codex/prompts/gctree-bootstrap.md ← Codex 会话的引导上下文
149
+ .codex/skills/gc-resolve-context/SKILL.md ← resolve 技能
150
+ .codex/skills/gc-onboard/SKILL.md ← onboarding 技能
151
+ .codex/skills/gc-update-global-context/SKILL.md ← 更新技能
116
152
  ```
117
153
 
154
+ **`--host claude-code` 写入的文件:**
155
+
156
+ ```
157
+ CLAUDE.md ← gctree 代码片段追加
158
+ .claude/hooks/gctree-session-start.md ← 会话启动钩子
159
+ .claude/commands/gc-resolve-context.md ← resolve 斜杠命令
160
+ .claude/commands/gc-onboard.md ← onboard 斜杠命令
161
+ .claude/commands/gc-update-global-context.md ← 更新斜杠命令
162
+ ```
163
+
164
+ 除非传入 `--force`,否则已有文件不会被修改。
165
+
118
166
  ### 运行时行为
119
167
 
120
- 默认情况下,激活的 gc-branch `~/.gctree` `HEAD` 指向的那一条。但如果某个仓库被显式绑定到了另一条 gc-branch,repo mapping 就可以覆盖这个默认值。
121
- 这使得 gc-tree 对那些同时在许多互不相关仓库里开很多会话的重度用户来说也依然实用。
168
+ 活跃的 gc-branch `~/.gctree` 内的 `HEAD` 指向,但当一个代码仓库被显式绑定到另一个 gc-branch 时,仓库映射可以覆盖这一后备设置。
169
+ 这使得 gc-tree 对于同时保持大量无关会话的重度用户而言非常实用。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handsupmin/gc-tree",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Global Context Tree, a lightweight branch-aware global context orchestrator for AI coding tools",
5
5
  "type": "module",
6
6
  "private": false,
@@ -18,7 +18,16 @@
18
18
  "scripts": {
19
19
  "build": "tsc -p tsconfig.json",
20
20
  "test": "node --import tsx --test tests/*.test.ts",
21
- "prepack": "npm run build"
21
+ "prepack": "npm run build",
22
+ "eval": "node --import tsx tests/eval/index.ts",
23
+ "eval:verbose": "node --import tsx tests/eval/index.ts --verbose",
24
+ "eval:multi-repo": "node --import tsx tests/eval/multi-repo.ts",
25
+ "eval:multi-repo:verbose": "node --import tsx tests/eval/multi-repo.ts --verbose",
26
+ "eval:autoresearch": "node --import tsx tests/eval/autoresearch.ts",
27
+ "eval:multilingual": "node --import tsx tests/eval/multilingual.ts",
28
+ "eval:multilingual:verbose": "node --import tsx tests/eval/multilingual.ts --verbose",
29
+ "eval:real-docs": "node --import tsx tests/eval/real-docs.ts",
30
+ "eval:real-docs:verbose": "node --import tsx tests/eval/real-docs.ts --verbose"
22
31
  },
23
32
  "engines": {
24
33
  "node": ">=20"