@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.md CHANGED
@@ -1,166 +1,250 @@
1
1
  # gc-tree
2
2
 
3
- Branch-aware global context for AI coding tools.
3
+ <div align="center">
4
+
5
+ <img src="./logo.png" alt="gc-tree logo" width="260" />
6
+
7
+ ### Global context, beyond the project.
8
+
9
+ Attach durable, reusable context to your existing AI tools.
10
+ Manage multiple contexts like Git branches.
11
+
12
+ [![npm version](https://img.shields.io/npm/v/%40handsupmin%2Fgc-tree)](https://www.npmjs.com/package/@handsupmin/gc-tree)
13
+ [![npm downloads](https://img.shields.io/npm/dm/%40handsupmin%2Fgc-tree)](https://www.npmjs.com/package/@handsupmin/gc-tree)
14
+ [![GitHub stars](https://img.shields.io/github/stars/handsupmin/gc-tree)](https://github.com/handsupmin/gc-tree/stargazers)
15
+ [![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/handsupmin/gc-tree/blob/main/LICENSE)
16
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](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
- ## Introduction
20
+ </div>
8
21
 
9
- `gctree` is a lightweight **Global Context Tree** for AI coding tools.
10
- It gives long-lived context a reusable, file-backed home that stays explicit, branch-aware, and easy to plug into existing workflows.
22
+ ---
11
23
 
12
- When a single `AGENTS.md`, `CLAUDE.md`, or prompt snippet is no longer enough, `gctree` helps you:
24
+ ## The problem
13
25
 
14
- - separate context by product, client, or workstream
15
- - keep source-of-truth knowledge in markdown instead of hidden memory
16
- - resolve the active context quickly with a slim index and summary-first docs
17
- - onboard and update durable context through your preferred LLM CLI provider
18
- - limit a gc-branch to the repositories where it actually applies
26
+ You use Claude Code or Codex every day. But your real work spans multiple repos, products, and clients — and your AI tools only know about the current file.
19
27
 
20
- ## Key Features
28
+ So you end up doing this every session:
21
29
 
22
- - **Provider-driven onboarding**
23
- `gctree init` asks which provider mode you want (`claude-code`, `codex`, or `both`), then asks which language to use for responses, saves both choices, scaffolds the right command surface, and starts guided onboarding for the default `main` gc-branch.
24
- - **Repo-aware gc-branch scope**
25
- `gctree` can map a gc-branch to specific repositories through `~/.gctree/branch-repo-map.json`, so one branch can apply to B/C/D while being ignored in F.
26
- - **Interactive scope guard**
27
- If `gctree resolve` runs in a repo that is not yet mapped to the current gc-branch, it can ask whether to continue once, always use this gc-branch here, or ignore it here.
28
- - **Summary-first documentation**
29
- Let tools read the short version first and expand only when they need more detail.
30
- - **Guided durable updates**
31
- Reuse the same provider-driven flow to update context without hand-authoring JSON files.
30
+ - Re-explain which repos belong together
31
+ - Paste the same architecture doc into the prompt again
32
+ - Remind the agent about conventions it already "knew" last week
33
+ - Manually strip context that's irrelevant to the current repo
32
34
 
33
- ## Install & Quick Start
35
+ That's not an AI problem. It's a **context management problem**.
34
36
 
35
- ### Install from npm
37
+ ---
36
38
 
37
- ```bash
38
- npm install -g @handsupmin/gc-tree
39
- ```
39
+ ## What gc-tree does
40
40
 
41
- Or run it once without a global install:
41
+ `gc-tree` sits **above the repo level**. It stores durable context in structured markdown files and lets your AI tools pull only what's relevant — before each session, automatically.
42
42
 
43
43
  ```bash
44
- npx @handsupmin/gc-tree init
44
+ gctree resolve --query "auth token rotation policy"
45
45
  ```
46
46
 
47
- - **Package name:** `@handsupmin/gc-tree`
48
- - **CLI command:** `gctree`
49
- - **Requirements:** Node.js 20+
50
- For source-based development details, see [docs/local-development.md](https://github.com/handsupmin/gc-tree/blob/main/docs/local-development.md).
47
+ ```json
48
+ {
49
+ "gc_branch": "main",
50
+ "matches": [
51
+ {
52
+ "title": "Auth & Session Conventions",
53
+ "score": 4,
54
+ "summary": "JWT rotation on every request, refresh tokens stored in httpOnly cookies, 15-min access token TTL",
55
+ "excerpt": "## Auth Flow\nAccess token: 15-min TTL, rotated on every authenticated request..."
56
+ }
57
+ ]
58
+ }
59
+ ```
51
60
 
52
- ### Quick Start
61
+ Your AI tool gets the right context. Not the whole knowledge base — just the relevant slice.
53
62
 
54
- #### 1) Initialize gc-tree
63
+ **In practice: only ~4% of your total context is injected per query.** The other 96% stays on disk, out of the token window, until it's actually needed.
55
64
 
56
- ```bash
57
- gctree init
58
- ```
65
+ ---
66
+
67
+ ## Who this is for
59
68
 
60
- This command:
69
+ You'll get the most out of `gc-tree` if you:
61
70
 
62
- - creates `~/.gctree`
63
- - creates the default `main` gc-branch
64
- - asks which provider mode you want to use (`claude-code`, `codex`, or `both`)
65
- - if you choose `both`, asks which provider should start onboarding now
66
- - asks which language the workflow should use (`English`, `Korean`, or a custom language)
67
- - saves provider mode, onboarding provider, and language in `~/.gctree/settings.json`
68
- - scaffolds the current environment for the selected provider mode
69
- - launches guided onboarding for the active gc-branch when `main` is still empty
71
+ - Work across **multiple repos** (monorepo teams, platform + client repos, backend + frontend stacks)
72
+ - Switch between **multiple products or clients** in the same week
73
+ - Find yourself **re-explaining the same context** at the start of every AI session
74
+ - Want AI tools to understand your **conventions, architecture, and domain knowledge** — not just the current file
70
75
 
71
- #### 2) Resolve the active context
76
+ If you only ever work in one repo and one product, you probably don't need this. `CLAUDE.md` or `.cursorrules` is enough.
77
+
78
+ ---
79
+
80
+ ## Why not just use CLAUDE.md or cursor rules?
81
+
82
+ `CLAUDE.md` is great — for one repo.
83
+
84
+ The moment you have multiple repos, clients, or workstreams:
85
+
86
+ | | `CLAUDE.md` / cursor rules | `gc-tree` |
87
+ |---|---|---|
88
+ | Scope | One repo | Multiple repos, one context |
89
+ | Persistence | Per-repo file | Stored outside repos, reused across sessions |
90
+ | Switching contexts | Manual file edits | `gctree checkout client-b` |
91
+ | Relevance filtering | Everything or nothing | Only injects matching docs (~4% of total) |
92
+ | Onboarding | Hand-written | Guided by your AI tool |
93
+ | Works with Codex | ✅ | ✅ |
94
+ | Works with Claude Code | ✅ | ✅ |
95
+
96
+ ---
97
+
98
+ ## Validated performance
99
+
100
+ Tested against real internal documentation (4 Notion exports, Korean + English mixed queries):
101
+
102
+ | Metric | Result |
103
+ |---|---|
104
+ | Recall — relevant queries find the right doc | **100%** (16/16) |
105
+ | Precision — irrelevant queries return empty | **80%** (4/5) |
106
+ | F1 score | **88.9%** |
107
+ | Tokens injected per query vs. total context | **~4%** |
108
+ | Works with mixed Korean + English queries | ✅ |
109
+
110
+ ---
111
+
112
+ ## Works with Claude Code and Codex — both verified
72
113
 
73
114
  ```bash
74
- gctree resolve --query "auth token rotation"
115
+ gctree scaffold --host claude-code # installs CLAUDE.md snippet + /gc-onboard, /gc-update-global-context
116
+ gctree scaffold --host codex # installs AGENTS.md snippet + $gc-onboard, $gc-update-global-context
117
+ gctree scaffold --host both # both at once
75
118
  ```
76
119
 
77
- If the current repo is outside the mapped scope for the chosen gc-branch, `gctree` can ask whether to:
120
+ Both providers use the same underlying context store. Onboard once, use from either tool.
121
+
122
+ **Claude Code** — uses `/gc-resolve-context`, `/gc-onboard`, `/gc-update-global-context` slash commands.
78
123
 
79
- 1. continue once
80
- 2. always use this gc-branch for this repo
81
- 3. ignore this gc-branch for this repo
124
+ **Codex** — uses `$gc-resolve-context`, `$gc-onboard`, `$gc-update-global-context` skills. Verified with `codex exec`:
82
125
 
83
- Choosing 2 or 3 updates `~/.gctree/branch-repo-map.json`.
126
+ ```
127
+ gctree status → gc_branch: main, doc_count: 2
128
+ gctree resolve --query 'NestJS DTO plainToInstance'
129
+ → matched "Backend Coding Conventions" (score: 3)
130
+ → DTO: class-transformer plainToInstance, class-validator required
131
+ → Error handling: HttpException-based custom exceptions, no raw Error throws
132
+ ```
133
+
134
+ ---
84
135
 
85
- #### 3) Create another gc-branch when you need a separate context tree
136
+ ## Install & quick start
86
137
 
87
138
  ```bash
88
- gctree checkout -b client-b
139
+ npm install -g @handsupmin/gc-tree
140
+ gctree init
89
141
  ```
90
142
 
91
- `checkout -b` creates a **new empty gc-branch**. It does not copy existing branch docs.
143
+ `gctree init` walks you through:
144
+ 1. Choose provider: `claude-code`, `codex`, or `both`
145
+ 2. Scaffold the integration files into your current repo
146
+ 3. Run guided onboarding for the `main` gc-branch
92
147
 
93
- #### 4) Onboard that empty gc-branch through the configured provider
148
+ After that, your AI tool will know to call `gctree resolve` before planning or implementing.
149
+
150
+ - **CLI:** `gctree`
151
+ - **Requires:** Node.js 20+
152
+
153
+ ---
154
+
155
+ ## Common moves
156
+
157
+ ### Separate contexts for separate workstreams
94
158
 
95
159
  ```bash
160
+ gctree checkout -b client-b
96
161
  gctree onboard
97
162
  ```
98
163
 
99
- #### 5) Make a durable update later
164
+ Each gc-branch is a fully independent context lane. Switch between them like Git branches.
165
+
166
+ ### Pull relevant context on demand
100
167
 
101
168
  ```bash
102
- gctree update-global-context
169
+ gctree resolve --query "billing retry policy"
103
170
  ```
104
171
 
105
- Short aliases:
172
+ Returns only the matching docs — title, summary, and excerpt. Your tool reads the full doc only if the summary isn't enough.
173
+
174
+ ### Keep context current
106
175
 
107
176
  ```bash
108
- gctree update-gc
109
- gctree ugc
177
+ gctree update-global-context # or: gctree update-gc / gctree ugc
110
178
  ```
111
179
 
112
- If a repo turns out to belong to the current gc-branch after real work, the natural flow is:
113
-
114
- 1. allow that repo in the branch repo map
115
- 2. then run `gctree update-global-context` to add durable context about what that repo is and why it matters
180
+ Guided update flow your AI tool asks what changed and writes the new context back to the gc-branch.
116
181
 
117
- #### 6) Re-onboard only after resetting a gc-branch
182
+ ### Scope a context to specific repos
118
183
 
119
184
  ```bash
120
- gctree reset-gc-branch --branch client-b --yes
185
+ gctree set-repo-scope --branch client-b --include # include current repo
186
+ gctree set-repo-scope --branch client-b --exclude # exclude current repo
121
187
  ```
122
188
 
123
- ### Provider-facing commands inside the runtime
189
+ `gc-tree` won't inject a context into repos where it doesn't belong.
190
+
191
+ ---
124
192
 
125
- After scaffolding, the visible commands are:
193
+ ## How context is stored
194
+
195
+ ```
196
+ ~/.gctree/
197
+ branches/
198
+ main/
199
+ index.md ← compact index, ≤2000 chars, loaded first
200
+ docs/
201
+ auth.md ← full doc, read only when needed
202
+ architecture.md
203
+ client-b/
204
+ index.md
205
+ docs/
206
+ ...
207
+ branch-repo-map.json ← which repos belong to which gc-branch
208
+ settings.json ← preferred provider, language
209
+ ```
126
210
 
127
- - **Codex:** `$gc-onboard`, `$gc-update-global-context`
128
- - **Claude Code:** `/gc-onboard`, `/gc-update-global-context`
211
+ Context lives outside your repos — no `.gitignore` rules needed, no accidental commits, reusable across every project that uses the same gc-branch.
129
212
 
130
- Those commands should always mention the current active gc-branch before gathering or updating durable context, and they should keep using the saved workflow language unless the user explicitly asks to switch.
213
+ ---
131
214
 
132
- ### Core commands at a glance
215
+ ## Core commands
133
216
 
134
217
  | Goal | Command |
135
- | --- | --- |
218
+ |---|---|
136
219
  | Initialize gc-tree and choose a provider | `gctree init` |
137
220
  | Confirm the active gc-branch | `gctree status` |
138
221
  | Search the active context | `gctree resolve --query "..."` |
139
- | Show repo-scope rules | `gctree repo-map` |
140
- | Explicitly include/exclude a repo for a gc-branch | `gctree set-repo-scope --branch <name> --include` / `--exclude` |
141
222
  | Create or switch gc-branches | `gctree checkout <branch>` / `gctree checkout -b <branch>` |
223
+ | List all gc-branches | `gctree branches` |
142
224
  | Guided onboarding for an empty gc-branch | `gctree onboard` |
143
- | Guided durable update for the active gc-branch | `gctree update-global-context` / `gctree update-gc` / `gctree ugc` |
225
+ | Guided durable update for the active gc-branch | `gctree update-global-context` / `gctree ugc` |
226
+ | Show repo-scope rules | `gctree repo-map` |
227
+ | Include/exclude current repo for a gc-branch | `gctree set-repo-scope --branch <name> --include` / `--exclude` |
144
228
  | Reset a gc-branch before re-onboarding | `gctree reset-gc-branch --branch <name> --yes` |
145
- | Scaffold another environment manually | `gctree scaffold --host codex --target /path/to/repo` |
229
+ | Scaffold a new environment | `gctree scaffold --host codex --target /path/to/repo` |
146
230
 
147
- ## Documentation
231
+ ---
148
232
 
149
- Detailed docs live in the [`docs/`](https://github.com/handsupmin/gc-tree/tree/main/docs) directory.
233
+ ## Documentation
150
234
 
151
235
  - **Concept** — [`docs/concept.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/concept.md)
152
- Learn what `gctree` is, which problem it solves, and what belongs in the global-context layer.
153
236
  - **Principles** — [`docs/principles.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/principles.md)
154
- Read the rules behind gc-branches, repo scope, slim indexes, summary-first docs, and guided updates.
155
237
  - **Usage** — [`docs/usage.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/usage.md)
156
- See the standard CLI flow, provider-facing commands, repo-scope behavior, and integration patterns.
157
238
  - **Local development** — [`docs/local-development.md`](https://github.com/handsupmin/gc-tree/blob/main/docs/local-development.md)
158
- Learn how to run the CLI locally and verify changes before contributing.
239
+
240
+ ---
159
241
 
160
242
  ## Contribution
161
243
 
162
244
  Contributions are welcome. See [CONTRIBUTING.md](https://github.com/handsupmin/gc-tree/blob/main/CONTRIBUTING.md) for the development workflow and pull request checklist.
163
245
 
246
+ ---
247
+
164
248
  ## License
165
249
 
166
250
  MIT. See [`LICENSE`](https://github.com/handsupmin/gc-tree/blob/main/LICENSE).