first-tree 0.0.4 → 0.0.6
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 +36 -13
- package/dist/cli.js +5 -5
- package/dist/{help-Dtdj91HJ.js → help-DV9-AaFp.js} +1 -1
- package/dist/{init--VepFe6N.js → init-BgGH2_yC.js} +57 -11
- package/dist/onboarding-D7fGGOMN.js +10 -0
- package/dist/onboarding-lASHHmgO.js +2 -0
- package/dist/{repo-DY57bMqr.js → repo-Cc5U4DWT.js} +76 -5
- package/dist/source-integration-CuKjoheT.js +84 -0
- package/dist/{upgrade-Cgx_K2HM.js → upgrade-BvA9oKmi.js} +37 -9
- package/dist/{verify-mC9ZTd1f.js → verify-G8gNXzDX.js} +5 -1
- package/package.json +11 -9
- package/skills/first-tree/SKILL.md +30 -10
- package/skills/first-tree/agents/openai.yaml +1 -1
- package/skills/first-tree/assets/framework/examples/claude-code/README.md +2 -2
- package/skills/first-tree/assets/framework/examples/claude-code/settings.json +1 -1
- package/skills/first-tree/assets/framework/helpers/generate-codeowners.ts +1 -1
- package/skills/first-tree/assets/framework/helpers/inject-tree-context.sh +0 -0
- package/skills/first-tree/assets/framework/helpers/run-review.ts +1 -1
- package/skills/first-tree/assets/framework/templates/agents.md.template +2 -2
- package/skills/first-tree/assets/framework/templates/members-domain.md.template +1 -1
- package/skills/first-tree/assets/framework/templates/root-node.md.template +3 -3
- package/skills/first-tree/assets/framework/workflows/codeowners.yml +1 -1
- package/skills/first-tree/assets/framework/workflows/pr-review.yml +1 -1
- package/skills/first-tree/engine/init.ts +78 -6
- package/skills/first-tree/engine/repo.ts +74 -10
- package/skills/first-tree/engine/rules/agent-integration.ts +3 -1
- package/skills/first-tree/engine/rules/framework.ts +2 -2
- package/skills/first-tree/engine/runtime/adapters.ts +6 -2
- package/skills/first-tree/engine/runtime/asset-loader.ts +142 -4
- package/skills/first-tree/engine/runtime/installer.ts +18 -12
- package/skills/first-tree/engine/runtime/source-integration.ts +80 -0
- package/skills/first-tree/engine/upgrade.ts +103 -9
- package/skills/first-tree/engine/verify.ts +7 -0
- package/skills/first-tree/references/maintainer-architecture.md +4 -0
- package/skills/first-tree/references/maintainer-thin-cli.md +3 -0
- package/skills/first-tree/references/onboarding.md +56 -21
- package/skills/first-tree/references/principles.md +97 -57
- package/skills/first-tree/references/source-map.md +1 -0
- package/skills/first-tree/references/source-workspace-installation.md +52 -0
- package/skills/first-tree/references/upgrade-contract.md +67 -26
- package/skills/first-tree/scripts/check-skill-sync.sh +2 -0
- package/skills/first-tree/scripts/quick_validate.py +0 -0
- package/skills/first-tree/scripts/run-local-cli.sh +0 -0
- package/skills/first-tree/tests/asset-loader.test.ts +23 -1
- package/skills/first-tree/tests/helpers.ts +27 -3
- package/skills/first-tree/tests/init.test.ts +72 -3
- package/skills/first-tree/tests/repo.test.ts +46 -0
- package/skills/first-tree/tests/rules.test.ts +9 -7
- package/skills/first-tree/tests/skill-artifacts.test.ts +45 -0
- package/skills/first-tree/tests/upgrade.test.ts +58 -3
- package/skills/first-tree/tests/verify.test.ts +21 -3
- package/dist/installer-cH7N4RNj.js +0 -47
- package/dist/onboarding-C9cYSE6F.js +0 -2
- package/dist/onboarding-CPP8fF4D.js +0 -10
|
@@ -56,16 +56,19 @@ Information an agent needs to **decide** on an approach — not to execute it.
|
|
|
56
56
|
- A source/workspace Git repository, or an already-created dedicated tree repo
|
|
57
57
|
- Node.js 18+
|
|
58
58
|
- The npm package is `first-tree`, the installed CLI command is
|
|
59
|
-
`context-tree
|
|
60
|
-
|
|
59
|
+
`context-tree`.
|
|
60
|
+
- `context-tree init` installs the framework skill into
|
|
61
|
+
`.agents/skills/first-tree/` and `.claude/skills/first-tree/`.
|
|
61
62
|
- Use `npx first-tree init` for one-off runs, or `npm install -g first-tree`
|
|
62
63
|
to add the `context-tree` command to your PATH
|
|
63
64
|
|
|
64
65
|
### Step 1: Initialize
|
|
65
66
|
|
|
66
67
|
Recommended workflow: run `context-tree init` from your source or workspace repo.
|
|
67
|
-
The CLI will
|
|
68
|
-
|
|
68
|
+
The CLI will install the bundled skill in the current repo, update root
|
|
69
|
+
`AGENTS.md` and `CLAUDE.md` with a `FIRST-TREE-SOURCE-INTEGRATION:` line, and
|
|
70
|
+
create a sibling dedicated tree repo named `<repo>-context` by default. Tree
|
|
71
|
+
files are scaffolded only in the dedicated tree repo.
|
|
69
72
|
|
|
70
73
|
```bash
|
|
71
74
|
cd my-org
|
|
@@ -81,24 +84,43 @@ git init
|
|
|
81
84
|
context-tree init --here
|
|
82
85
|
```
|
|
83
86
|
|
|
84
|
-
Either way, the framework installs into
|
|
85
|
-
scaffolding (`NODE.md`, `AGENTS.md`,
|
|
86
|
-
|
|
87
|
+
Either way, the framework installs into `.agents/skills/first-tree/` and
|
|
88
|
+
`.claude/skills/first-tree/`, renders scaffolding (`NODE.md`, `AGENTS.md`,
|
|
89
|
+
`members/NODE.md`), and generates a task list in
|
|
90
|
+
`.agents/skills/first-tree/progress.md`.
|
|
87
91
|
|
|
88
92
|
Publishing tip: keep the tree repo in the same GitHub organization as the
|
|
89
93
|
source repo unless you have a reason not to.
|
|
90
94
|
|
|
95
|
+
Hard boundary: do **not** create `NODE.md`, `members/`, or tree-scoped
|
|
96
|
+
`AGENTS.md` in the source/workspace repo. Those files belong only in the
|
|
97
|
+
dedicated `*-context` repo.
|
|
98
|
+
|
|
99
|
+
Default agent workflow after initialization:
|
|
100
|
+
|
|
101
|
+
1. Create and push the dedicated `*-context` repo in the same GitHub
|
|
102
|
+
organization as the source repo.
|
|
103
|
+
2. Add the dedicated tree repo back to the source/workspace repo as a `git submodule`.
|
|
104
|
+
3. Open a PR against the source/workspace repo's default branch for the local
|
|
105
|
+
skill integration plus the new submodule pointer. Do not merge it
|
|
106
|
+
automatically.
|
|
107
|
+
|
|
91
108
|
### Step 2: Work Through the Task List
|
|
92
109
|
|
|
93
|
-
Read
|
|
110
|
+
Read `.agents/skills/first-tree/progress.md`. It contains a checklist tailored
|
|
111
|
+
to the current state of the repo. Complete each task:
|
|
94
112
|
|
|
95
113
|
- Fill in `NODE.md` with your organization name, owners, and domains
|
|
96
114
|
- Add project-specific instructions to `AGENTS.md` below the framework markers
|
|
97
115
|
- Create member nodes under `members/`
|
|
98
|
-
- Optionally configure agent integration (
|
|
99
|
-
|
|
116
|
+
- Optionally configure agent integration (for Claude Code, the installed hook
|
|
117
|
+
assets live under `.claude/skills/first-tree/`)
|
|
118
|
+
- Copy validation workflows from
|
|
119
|
+
`.agents/skills/first-tree/assets/framework/workflows/` to
|
|
120
|
+
`.github/workflows/`
|
|
100
121
|
|
|
101
|
-
As you complete each task, check it off in
|
|
122
|
+
As you complete each task, check it off in
|
|
123
|
+
`.agents/skills/first-tree/progress.md` by changing `- [ ]` to `- [x]`.
|
|
102
124
|
|
|
103
125
|
### Step 3: Verify
|
|
104
126
|
|
|
@@ -112,7 +134,13 @@ Or, from your source/workspace repo:
|
|
|
112
134
|
context-tree verify --tree-path ../my-org-context
|
|
113
135
|
```
|
|
114
136
|
|
|
115
|
-
This fails if any items in
|
|
137
|
+
This fails if any items in `.agents/skills/first-tree/progress.md` remain
|
|
138
|
+
unchecked, and runs deterministic checks (valid frontmatter, node structure,
|
|
139
|
+
member nodes exist).
|
|
140
|
+
|
|
141
|
+
Do not run `context-tree verify` in the source/workspace repo itself. That repo
|
|
142
|
+
only carries the installed skill plus the
|
|
143
|
+
`FIRST-TREE-SOURCE-INTEGRATION:` line.
|
|
116
144
|
|
|
117
145
|
### Step 4: Design Your Domains
|
|
118
146
|
|
|
@@ -149,7 +177,7 @@ The tree doesn't duplicate source code — it captures what connects things and
|
|
|
149
177
|
|
|
150
178
|
| Command | Description |
|
|
151
179
|
|---------|-------------|
|
|
152
|
-
| `context-tree init` |
|
|
180
|
+
| `context-tree init` | Install local source/workspace integration and create or refresh a dedicated tree repo. By default, running in a source/workspace repo creates a sibling `<repo>-context`; use `--here` to initialize the current repo in place. |
|
|
153
181
|
| `context-tree verify` | Check the installed progress file for unchecked items + run deterministic validation. Use `--tree-path` when invoking from another working directory. |
|
|
154
182
|
| `context-tree upgrade` | Refresh the installed framework skill from the currently running `first-tree` npm package and generate follow-up tasks. Use `--tree-path` when invoking from another working directory. |
|
|
155
183
|
| `context-tree help onboarding` | Print this onboarding guide. |
|
|
@@ -164,13 +192,19 @@ When the framework updates:
|
|
|
164
192
|
context-tree upgrade
|
|
165
193
|
```
|
|
166
194
|
|
|
167
|
-
`context-tree upgrade` refreshes
|
|
168
|
-
skill bundled with the currently running
|
|
169
|
-
tree content, and generates follow-up
|
|
170
|
-
|
|
195
|
+
`context-tree upgrade` refreshes `.agents/skills/first-tree/` and
|
|
196
|
+
`.claude/skills/first-tree/` from the skill bundled with the currently running
|
|
197
|
+
`first-tree` npm package, preserves your tree content, and generates follow-up
|
|
198
|
+
tasks in `.agents/skills/first-tree/progress.md`.
|
|
199
|
+
|
|
200
|
+
If you run `context-tree upgrade` in the source/workspace repo, it refreshes
|
|
201
|
+
only the local installed skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines.
|
|
202
|
+
Run `context-tree upgrade --tree-path ../my-org-context` to upgrade the
|
|
203
|
+
dedicated tree repo itself.
|
|
171
204
|
|
|
172
|
-
If your repo still uses the older `skills/first-tree
|
|
173
|
-
`
|
|
205
|
+
If your repo still uses the older `skills/first-tree/`,
|
|
206
|
+
`skills/first-tree-cli-framework/`, or `.context-tree/` layouts,
|
|
207
|
+
`context-tree upgrade` will migrate it to the current installed layout first.
|
|
174
208
|
|
|
175
209
|
To pick up a newer framework release, first run a newer package version, for
|
|
176
210
|
example `npx first-tree@latest upgrade`, or update your global `first-tree`
|
|
@@ -180,6 +214,7 @@ install before running `context-tree upgrade`.
|
|
|
180
214
|
|
|
181
215
|
## Further Reading
|
|
182
216
|
|
|
183
|
-
-
|
|
184
|
-
-
|
|
217
|
+
- `.agents/skills/first-tree/references/principles.md` — Core principles with detailed examples
|
|
218
|
+
- `.agents/skills/first-tree/references/source-workspace-installation.md` — Source/workspace install contract
|
|
219
|
+
- `.agents/skills/first-tree/references/ownership-and-naming.md` — How nodes are named and owned
|
|
185
220
|
- `AGENTS.md` in your tree — The before/during/after workflow for every task
|
|
@@ -5,25 +5,26 @@ owners: []
|
|
|
5
5
|
|
|
6
6
|
# Tree Principles
|
|
7
7
|
|
|
8
|
-
This document explains the core principles of Context Tree
|
|
8
|
+
This document explains the four core principles of Context Tree and how to
|
|
9
|
+
apply them in practice. Read them in order: principle 1 defines what the tree
|
|
10
|
+
is for, principle 2 explains how to organize it, principle 3 clarifies access
|
|
11
|
+
and ownership, and principle 4 explains why the structure is tree-shaped and
|
|
12
|
+
Git-native.
|
|
9
13
|
|
|
10
14
|
---
|
|
11
15
|
|
|
12
16
|
## 1. Source of truth for decisions, not execution
|
|
13
17
|
|
|
14
|
-
The tree captures the *what* and *why*
|
|
18
|
+
The tree captures the *what* and *why* - strategic choices, cross-domain
|
|
19
|
+
relationships, and constraints. An agent should be able to read the tree and
|
|
20
|
+
decide on the right approach before consulting source systems for
|
|
21
|
+
implementation details.
|
|
15
22
|
|
|
16
|
-
###
|
|
23
|
+
### The decision test
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
4. Human reviews and approves.
|
|
22
|
-
5. Agent explores source systems to build a detailed execution plan.
|
|
23
|
-
6. If source systems reveal something the tree didn't capture — update the tree, revisit with the human, then proceed.
|
|
24
|
-
7. After execution is complete, update the tree to reflect any new decisions.
|
|
25
|
-
|
|
26
|
-
This applies to all tasks — features, campaigns, hiring decisions, refactors. Not every task requires a tree update, but the tree is always the starting point, and the question "does the tree need updating?" is always asked at the end.
|
|
25
|
+
If an agent needs this information to *decide* on an approach, it belongs in
|
|
26
|
+
the tree. If the agent only needs it to *execute*, it stays in the source
|
|
27
|
+
system.
|
|
27
28
|
|
|
28
29
|
### What belongs in the tree
|
|
29
30
|
|
|
@@ -32,82 +33,121 @@ This applies to all tasks — features, campaigns, hiring decisions, refactors.
|
|
|
32
33
|
- "We target academic researchers and AI-native teams because they have the highest tolerance for an agent-centric workflow."
|
|
33
34
|
- "Q3 campaign focuses on developer communities because enterprise sales cycle is too long for our current stage."
|
|
34
35
|
|
|
35
|
-
### What does
|
|
36
|
+
### What does not belong in the tree
|
|
36
37
|
|
|
37
|
-
- The function signature of `retrieval_service.search()`
|
|
38
|
-
- The database schema for the `chunk_embeddings` table
|
|
39
|
-
- The current ad copy for a campaign
|
|
40
|
-
- The current list of API endpoints
|
|
41
|
-
- The exact interview questions for a role
|
|
38
|
+
- The function signature of `retrieval_service.search()` - read the code.
|
|
39
|
+
- The database schema for the `chunk_embeddings` table - read the models.
|
|
40
|
+
- The current ad copy for a campaign - read the campaign tool.
|
|
41
|
+
- The current list of API endpoints - read the route files.
|
|
42
|
+
- The exact interview questions for a role - read the hiring doc.
|
|
42
43
|
|
|
43
|
-
###
|
|
44
|
+
### Good node examples
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
**Cross-domain relationships:** "Auth touches 4 repos: backend (JWT issuance), frontend (Better Auth client), browser extension (OAuth popup + device token), desktop (localhost callback server + JWT storage)." - An agent would need to search across all repos to piece this together.
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
**Strategic decisions with rationale:** "We use Reciprocal Rank Fusion to combine vector and BM25 results because pure vector search missed keyword-heavy queries and pure BM25 missed semantic matches." - This is nowhere in the source systems.
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
**Domain state summaries:** "The ingestion pipeline has 6 stages: download -> extract -> parse -> chunk -> embed -> store. PDF extraction uses MinerU (cloud). PPTX uses python-pptx locally." - An agent could trace this through 6+ files, or read one node.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
### Bad node examples
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
- Restating what one source file already says clearly.
|
|
55
|
+
- Documenting stable, well-known patterns (e.g., "we use FastAPI for the backend").
|
|
56
|
+
- Listing things that change frequently without decision implications.
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
### Use judgment, not a checklist
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
Not every task needs a tree update. A pure UI bug fix probably does not. But
|
|
61
|
+
do not assume - a "simple" feature like dark mode becomes a tree-worthy
|
|
62
|
+
decision once it involves auto mode, cross-device persistence, or desktop app
|
|
63
|
+
coordination. Evaluate each task in context.
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
### How this works during a task
|
|
66
|
+
|
|
67
|
+
1. Human says: "Let's add SSO to our product."
|
|
68
|
+
2. Agent reads relevant tree nodes (e.g., `platform/`, `environment/`).
|
|
69
|
+
3. Agent writes a top-level design based on tree context alone.
|
|
70
|
+
4. Human reviews and approves.
|
|
71
|
+
5. Agent explores source systems to build a detailed execution plan.
|
|
72
|
+
6. If source systems reveal something the tree did not capture, update the
|
|
73
|
+
tree, revisit with the human, then proceed.
|
|
74
|
+
7. After execution is complete, update the tree to reflect any new decisions.
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
This applies to all tasks - features, campaigns, hiring decisions, refactors.
|
|
77
|
+
Not every task requires a tree update, but the tree is always the starting
|
|
78
|
+
point, and the question "does the tree need updating?" is always asked at the
|
|
79
|
+
end.
|
|
62
80
|
|
|
63
|
-
|
|
81
|
+
### When the tree and source systems disagree
|
|
64
82
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
- "Hire a frontend engineer" → `people/hiring/` (role decision), soft link to the team they'd join
|
|
83
|
+
If an agent reads the tree, makes a decision, then discovers a source system
|
|
84
|
+
contradicts the tree, that is a tree bug. The tree must be corrected before
|
|
85
|
+
proceeding. This is how the tree stays accurate: every completed task is an
|
|
86
|
+
opportunity to validate and update it.
|
|
70
87
|
|
|
71
|
-
|
|
88
|
+
---
|
|
72
89
|
|
|
73
|
-
|
|
90
|
+
## 2. Agents are first-class participants
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
The tree is designed to be navigated and updated by agents, not just humans.
|
|
93
|
+
Domains are organized by concern - what an agent needs to know to act - not by
|
|
94
|
+
repo, team, or org chart.
|
|
76
95
|
|
|
77
|
-
|
|
96
|
+
### Organize by concern
|
|
78
97
|
|
|
79
|
-
|
|
98
|
+
An agent working on "add SSO support" does not think in terms of repos
|
|
99
|
+
(backend, frontend, extension, desktop) or org structure (engineering vs.
|
|
100
|
+
product). It needs all auth context - the why, the how, and the cross-domain
|
|
101
|
+
implications - in one place. Organizing by concern puts that context together.
|
|
80
102
|
|
|
81
|
-
|
|
103
|
+
### Place work in the domain of the primary concern
|
|
82
104
|
|
|
83
|
-
|
|
105
|
+
A feature or decision lives in the domain that owns the primary concern, with
|
|
106
|
+
soft links to other domains for discoverability:
|
|
84
107
|
|
|
85
|
-
|
|
108
|
+
- "Add SSO support" -> `platform/` (auth decision), soft links to
|
|
109
|
+
`environment/` (extension/desktop auth flows)
|
|
110
|
+
- "Support PPTX parsing" -> `knowledge/` (ingestion). Clear, single domain.
|
|
111
|
+
- "Q3 developer campaign" -> `marketing/` (go-to-market), soft link to the
|
|
112
|
+
product domain (feature positioning)
|
|
113
|
+
- "Agent remembers user preferences" -> `agent/` (memory)
|
|
114
|
+
- "Hire a frontend engineer" -> `people/hiring/` (role decision), soft link to
|
|
115
|
+
the team they would join
|
|
86
116
|
|
|
87
|
-
|
|
117
|
+
### Start flat, then split when needed
|
|
88
118
|
|
|
89
|
-
|
|
119
|
+
Start flat. Split when an agent cannot scan a `NODE.md` and quickly determine
|
|
120
|
+
where to go next. If a domain accumulates enough leaf nodes on a single topic,
|
|
121
|
+
that topic is ready to become a subdomain.
|
|
90
122
|
|
|
91
|
-
|
|
123
|
+
---
|
|
92
124
|
|
|
93
|
-
|
|
125
|
+
## 3. Transparency by default
|
|
94
126
|
|
|
95
|
-
|
|
127
|
+
All information in the tree is readable by everyone - humans and agents alike.
|
|
128
|
+
Reading is open; writing requires owner approval.
|
|
96
129
|
|
|
97
|
-
|
|
130
|
+
This means any agent can build full context by traversing the tree. No domain
|
|
131
|
+
is hidden. The ownership model controls who can *change* the tree, not who can
|
|
132
|
+
*read* it.
|
|
98
133
|
|
|
99
|
-
|
|
134
|
+
---
|
|
100
135
|
|
|
101
|
-
|
|
136
|
+
## 4. Git-native tree structure
|
|
102
137
|
|
|
103
|
-
|
|
138
|
+
Each node is a file, each domain is a directory, and the tree itself is a Git
|
|
139
|
+
repository. The tree shape gives predictable navigation; Git provides history,
|
|
140
|
+
review, and ownership workflows.
|
|
104
141
|
|
|
105
|
-
|
|
142
|
+
### Why a tree
|
|
106
143
|
|
|
107
|
-
|
|
144
|
+
A tree structure keeps information organized and navigable. Soft links allow
|
|
145
|
+
cross-references where needed without the complexity of a full graph. An agent
|
|
146
|
+
can start at any node and traverse up (broader context) or down (more detail)
|
|
147
|
+
predictably.
|
|
108
148
|
|
|
109
|
-
###
|
|
149
|
+
### Why Git
|
|
110
150
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
151
|
+
History, ownership, and review follow the same model software engineering has
|
|
152
|
+
refined for decades. Every change is a commit, every decision is reviewable in
|
|
153
|
+
a PR, and the full history of how the tree evolved is preserved.
|
|
@@ -11,6 +11,7 @@ information should be discoverable from this file.
|
|
|
11
11
|
| `SKILL.md` | Trigger conditions, workflow, and validation contract |
|
|
12
12
|
| `references/about.md` | Product framing for what Context Tree is and is not |
|
|
13
13
|
| `references/onboarding.md` | The onboarding narrative that `help onboarding` and `init` surface |
|
|
14
|
+
| `references/source-workspace-installation.md` | Contract for source/workspace installs vs dedicated tree repos |
|
|
14
15
|
| `references/principles.md` | Decision-model reference |
|
|
15
16
|
| `references/ownership-and-naming.md` | Ownership contract |
|
|
16
17
|
| `references/upgrade-contract.md` | Installed layout and upgrade semantics |
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Source/Workspace Installation Contract"
|
|
3
|
+
owners: []
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Source/Workspace Installation Contract
|
|
7
|
+
|
|
8
|
+
This reference defines what it means to "install and use first-tree" in an
|
|
9
|
+
existing source or workspace repository.
|
|
10
|
+
|
|
11
|
+
## Core Boundary
|
|
12
|
+
|
|
13
|
+
- The current source/workspace repo is **not** the Context Tree.
|
|
14
|
+
- The current source/workspace repo should carry only the installed
|
|
15
|
+
`.agents/skills/first-tree/` and `.claude/skills/first-tree/` skill roots
|
|
16
|
+
plus a single `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
17
|
+
`CLAUDE.md`.
|
|
18
|
+
- `NODE.md`, `members/`, and tree-scoped `AGENTS.md` content belong only in a
|
|
19
|
+
dedicated `*-context` repo.
|
|
20
|
+
- If a task changes decisions, rationale, ownership, or constraints, update
|
|
21
|
+
the dedicated tree repo rather than copying that material into the source
|
|
22
|
+
repo.
|
|
23
|
+
|
|
24
|
+
## Default Agent Workflow
|
|
25
|
+
|
|
26
|
+
When an agent is asked to install first-tree for a source/workspace repo, the
|
|
27
|
+
default workflow is:
|
|
28
|
+
|
|
29
|
+
1. Install the bundled first-tree skill into the current repo.
|
|
30
|
+
2. Upsert the `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
31
|
+
`CLAUDE.md`.
|
|
32
|
+
3. Create a sibling dedicated tree repo named `<repo>-context`.
|
|
33
|
+
4. Prefer creating and pushing that repo in the same GitHub organization as
|
|
34
|
+
the source repo, matching the source repo's default visibility unless the
|
|
35
|
+
user asks for something else.
|
|
36
|
+
5. Add the dedicated tree repo back to the source/workspace repo as a `git submodule`.
|
|
37
|
+
6. Run `context-tree init --here` inside the dedicated tree repo.
|
|
38
|
+
7. Draft the first tree version from the real codebase, docs, and ownership
|
|
39
|
+
signals.
|
|
40
|
+
8. Open a PR against the source/workspace repo's default branch for the local
|
|
41
|
+
skill integration plus the new submodule pointer. Do not merge it
|
|
42
|
+
automatically.
|
|
43
|
+
|
|
44
|
+
## Verification And Upgrade
|
|
45
|
+
|
|
46
|
+
- Do not run `context-tree verify` in the source/workspace repo. Verify the
|
|
47
|
+
dedicated tree repo instead, for example
|
|
48
|
+
`context-tree verify --tree-path ../my-repo-context`.
|
|
49
|
+
- Running `context-tree upgrade` in the source/workspace repo refreshes only
|
|
50
|
+
the local installed skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines.
|
|
51
|
+
- Run `context-tree upgrade --tree-path ../my-repo-context` to upgrade the
|
|
52
|
+
dedicated tree repo itself.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Upgrade Contract
|
|
2
2
|
|
|
3
3
|
This file describes the current installed-layout contract and the compatibility
|
|
4
|
-
rules we keep for legacy `skills/first-tree
|
|
5
|
-
`.context-tree/` repos.
|
|
4
|
+
rules we keep for legacy `skills/first-tree/`,
|
|
5
|
+
`skills/first-tree-cli-framework/`, and `.context-tree/` repos.
|
|
6
6
|
|
|
7
7
|
## Canonical Source
|
|
8
8
|
|
|
@@ -16,49 +16,85 @@ rules we keep for legacy `skills/first-tree-cli-framework/` and
|
|
|
16
16
|
|
|
17
17
|
## Installed Layout
|
|
18
18
|
|
|
19
|
-
The current installed layout in a
|
|
19
|
+
The current installed layout in a source/workspace repo or dedicated tree repo
|
|
20
|
+
is:
|
|
20
21
|
|
|
21
22
|
```text
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
.agents/
|
|
24
|
+
skills/
|
|
25
|
+
first-tree/
|
|
26
|
+
SKILL.md
|
|
27
|
+
progress.md
|
|
28
|
+
references/
|
|
29
|
+
assets/
|
|
30
|
+
framework/
|
|
31
|
+
manifest.json
|
|
32
|
+
VERSION
|
|
33
|
+
templates/
|
|
34
|
+
workflows/
|
|
35
|
+
prompts/
|
|
36
|
+
examples/
|
|
37
|
+
helpers/
|
|
38
|
+
.claude/
|
|
39
|
+
skills/
|
|
40
|
+
first-tree/
|
|
41
|
+
SKILL.md
|
|
42
|
+
references/
|
|
43
|
+
assets/
|
|
44
|
+
framework/
|
|
45
|
+
manifest.json
|
|
46
|
+
VERSION
|
|
47
|
+
templates/
|
|
48
|
+
workflows/
|
|
49
|
+
prompts/
|
|
50
|
+
examples/
|
|
51
|
+
helpers/
|
|
36
52
|
```
|
|
37
53
|
|
|
38
|
-
|
|
54
|
+
For a source/workspace repo, the local integration stops there. It should also
|
|
55
|
+
carry a single `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
56
|
+
`CLAUDE.md`, but it must not contain tree content.
|
|
57
|
+
|
|
58
|
+
For a dedicated tree repo, the tree content still lives outside the skill:
|
|
39
59
|
|
|
40
60
|
- `NODE.md`
|
|
41
61
|
- `AGENTS.md`
|
|
42
62
|
- `members/`
|
|
43
63
|
|
|
64
|
+
The repo-owned `.agents/skills/first-tree/` path is the primary installed root
|
|
65
|
+
for progress state, workflow references, and helper scripts. The matching
|
|
66
|
+
`.claude/skills/first-tree/` path mirrors the same payload for Claude-facing
|
|
67
|
+
skill discovery and hooks.
|
|
68
|
+
|
|
44
69
|
## Command Intent
|
|
45
70
|
|
|
46
71
|
- `context-tree init`
|
|
47
72
|
- when run in a source/workspace repo, creates or reuses a sibling dedicated
|
|
48
73
|
tree repo by default
|
|
74
|
+
- installs the skill into the source/workspace repo without creating tree
|
|
75
|
+
files there
|
|
76
|
+
- upserts the `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
77
|
+
`CLAUDE.md`
|
|
49
78
|
- installs the skill into the target tree repo
|
|
50
|
-
- renders top-level tree scaffolding
|
|
51
|
-
- writes progress state to
|
|
79
|
+
- renders top-level tree scaffolding only in the target tree repo
|
|
80
|
+
- writes progress state only to the dedicated tree repo at
|
|
81
|
+
`.agents/skills/first-tree/progress.md`
|
|
52
82
|
- `context-tree verify`
|
|
53
83
|
- checks progress state from the installed skill
|
|
54
84
|
- validates root/frontmatter/agent markers
|
|
55
85
|
- runs node and member validators
|
|
86
|
+
- must reject source/workspace repos that carry only local integration
|
|
56
87
|
- `context-tree upgrade`
|
|
57
88
|
- compares the installed skill payload version to the skill bundled with the
|
|
58
89
|
currently running `first-tree` package
|
|
59
90
|
- refreshes the installed skill payload without overwriting tree content
|
|
91
|
+
- when run in a source/workspace repo, refreshes only the local installed
|
|
92
|
+
skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines
|
|
93
|
+
- migrates repos that still use the previous `skills/first-tree/` path onto
|
|
94
|
+
`.agents/skills/first-tree/` and `.claude/skills/first-tree/`
|
|
60
95
|
- migrates repos that still use the previous
|
|
61
|
-
`skills/first-tree-cli-framework/` path onto
|
|
96
|
+
`skills/first-tree-cli-framework/` path onto `.agents/skills/first-tree/`
|
|
97
|
+
and `.claude/skills/first-tree/`
|
|
62
98
|
- migrates legacy `.context-tree/` repos onto the installed skill layout
|
|
63
99
|
- preserves user-authored sections such as the editable part of `AGENTS.md`
|
|
64
100
|
|
|
@@ -70,17 +106,22 @@ The tree content still lives outside the skill:
|
|
|
70
106
|
- Default dedicated-tree-repo creation is local-only. The CLI may create a new
|
|
71
107
|
sibling git repo on disk, but it must not clone the source repo or depend on
|
|
72
108
|
network access.
|
|
109
|
+
- Source/workspace repos must never receive `NODE.md`, `members/`, or
|
|
110
|
+
tree-scoped `AGENTS.md` from default init flows.
|
|
73
111
|
- Normal `context-tree init` and `context-tree upgrade` flows do not clone the
|
|
74
112
|
source repo or require network access.
|
|
75
113
|
- `context-tree verify` may still read a legacy
|
|
76
|
-
|
|
77
|
-
|
|
114
|
+
`.claude/skills/first-tree/...`, `skills/first-tree/...`,
|
|
115
|
+
`skills/first-tree-cli-framework/...`, or `.context-tree/...` layout in an
|
|
116
|
+
existing user repo so the repo can be repaired or upgraded in place.
|
|
78
117
|
- `context-tree upgrade` must migrate either legacy layout onto
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
`.agents/skills/first-tree/` and `.claude/skills/first-tree/`, and remove
|
|
119
|
+
old skill directories afterward.
|
|
120
|
+
- When both current and legacy layouts are present, prefer the
|
|
121
|
+
`.agents/skills/first-tree/` layout.
|
|
81
122
|
- Existing repos may still have a legacy `AGENT.md`; `init` and `upgrade`
|
|
82
123
|
must not silently overwrite it, and follow-up tasks should direct users to
|
|
83
|
-
rename it
|
|
124
|
+
rename or merge it into `AGENTS.md`.
|
|
84
125
|
|
|
85
126
|
## Invariants
|
|
86
127
|
|
|
@@ -39,6 +39,7 @@ require_file "$SOURCE_DIR/SKILL.md"
|
|
|
39
39
|
require_file "$SOURCE_DIR/agents/openai.yaml"
|
|
40
40
|
require_file "$SOURCE_DIR/references/about.md"
|
|
41
41
|
require_file "$SOURCE_DIR/references/onboarding.md"
|
|
42
|
+
require_file "$SOURCE_DIR/references/source-workspace-installation.md"
|
|
42
43
|
require_file "$SOURCE_DIR/references/principles.md"
|
|
43
44
|
require_file "$SOURCE_DIR/references/ownership-and-naming.md"
|
|
44
45
|
require_file "$SOURCE_DIR/references/source-map.md"
|
|
@@ -59,6 +60,7 @@ require_file "$SOURCE_DIR/engine/commands/verify.ts"
|
|
|
59
60
|
require_file "$SOURCE_DIR/engine/rules/index.ts"
|
|
60
61
|
require_file "$SOURCE_DIR/engine/runtime/asset-loader.ts"
|
|
61
62
|
require_file "$SOURCE_DIR/engine/runtime/installer.ts"
|
|
63
|
+
require_file "$SOURCE_DIR/engine/runtime/source-integration.ts"
|
|
62
64
|
require_file "$SOURCE_DIR/engine/runtime/upgrader.ts"
|
|
63
65
|
require_file "$SOURCE_DIR/engine/runtime/adapters.ts"
|
|
64
66
|
require_file "$SOURCE_DIR/engine/validators/members.ts"
|
|
File without changes
|
|
File without changes
|
|
@@ -2,8 +2,11 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import {
|
|
5
|
+
CLAUDE_INSTALLED_PROGRESS,
|
|
5
6
|
FRAMEWORK_VERSION,
|
|
6
7
|
INSTALLED_PROGRESS,
|
|
8
|
+
LEGACY_REPO_SKILL_PROGRESS,
|
|
9
|
+
LEGACY_REPO_SKILL_VERSION,
|
|
7
10
|
LEGACY_SKILL_PROGRESS,
|
|
8
11
|
LEGACY_SKILL_VERSION,
|
|
9
12
|
LEGACY_PROGRESS,
|
|
@@ -18,7 +21,7 @@ import { useTmpDir } from "./helpers.js";
|
|
|
18
21
|
describe("asset-loader", () => {
|
|
19
22
|
it("prefers the installed skill layout when both layouts exist", () => {
|
|
20
23
|
const tmp = useTmpDir();
|
|
21
|
-
mkdirSync(join(tmp.path, "skills", "first-tree", "assets", "framework"), {
|
|
24
|
+
mkdirSync(join(tmp.path, ".agents", "skills", "first-tree", "assets", "framework"), {
|
|
22
25
|
recursive: true,
|
|
23
26
|
});
|
|
24
27
|
mkdirSync(join(tmp.path, ".context-tree"), { recursive: true });
|
|
@@ -39,6 +42,21 @@ describe("asset-loader", () => {
|
|
|
39
42
|
expect(detectFrameworkLayout(tmp.path)).toBe("legacy");
|
|
40
43
|
});
|
|
41
44
|
|
|
45
|
+
it("detects the previous workspace skill path before older layouts", () => {
|
|
46
|
+
const tmp = useTmpDir();
|
|
47
|
+
mkdirSync(join(tmp.path, "skills", "first-tree", "assets", "framework"), {
|
|
48
|
+
recursive: true,
|
|
49
|
+
});
|
|
50
|
+
mkdirSync(join(tmp.path, ".context-tree"), { recursive: true });
|
|
51
|
+
writeFileSync(join(tmp.path, LEGACY_REPO_SKILL_VERSION), "0.2.0\n");
|
|
52
|
+
writeFileSync(join(tmp.path, LEGACY_VERSION), "0.1.0\n");
|
|
53
|
+
|
|
54
|
+
expect(detectFrameworkLayout(tmp.path)).toBe("legacy-repo-skill");
|
|
55
|
+
expect(
|
|
56
|
+
resolveFirstExistingPath(tmp.path, frameworkVersionCandidates()),
|
|
57
|
+
).toBe(LEGACY_REPO_SKILL_VERSION);
|
|
58
|
+
});
|
|
59
|
+
|
|
42
60
|
it("detects the previous installed skill name before the .context-tree layout", () => {
|
|
43
61
|
const tmp = useTmpDir();
|
|
44
62
|
mkdirSync(
|
|
@@ -59,12 +77,16 @@ describe("asset-loader", () => {
|
|
|
59
77
|
|
|
60
78
|
it("prefers the installed progress file candidate", () => {
|
|
61
79
|
const tmp = useTmpDir();
|
|
80
|
+
mkdirSync(join(tmp.path, ".agents", "skills", "first-tree"), { recursive: true });
|
|
81
|
+
mkdirSync(join(tmp.path, ".claude", "skills", "first-tree"), { recursive: true });
|
|
62
82
|
mkdirSync(join(tmp.path, "skills", "first-tree"), { recursive: true });
|
|
63
83
|
mkdirSync(join(tmp.path, "skills", "first-tree-cli-framework"), {
|
|
64
84
|
recursive: true,
|
|
65
85
|
});
|
|
66
86
|
mkdirSync(join(tmp.path, ".context-tree"), { recursive: true });
|
|
67
87
|
writeFileSync(join(tmp.path, INSTALLED_PROGRESS), "new");
|
|
88
|
+
writeFileSync(join(tmp.path, CLAUDE_INSTALLED_PROGRESS), "claude");
|
|
89
|
+
writeFileSync(join(tmp.path, LEGACY_REPO_SKILL_PROGRESS), "old-repo-skill");
|
|
68
90
|
writeFileSync(join(tmp.path, LEGACY_SKILL_PROGRESS), "old-skill");
|
|
69
91
|
writeFileSync(join(tmp.path, LEGACY_PROGRESS), "old");
|
|
70
92
|
|