first-tree 0.0.5 → 0.0.7
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 +25 -7
- package/dist/cli.js +9 -6
- package/dist/{help-5-WG9QFm.js → help-BRO4mTG6.js} +1 -1
- package/dist/{init-CAq0Uhq6.js → init-BSs0ILp_.js} +49 -9
- package/dist/onboarding-BS8btkG4.js +2 -0
- package/dist/onboarding-D3hnxIie.js +10 -0
- package/dist/{repo-DkR12VUv.js → repo-0z7N9r17.js} +22 -16
- package/dist/source-integration-C2iiN4k_.js +80 -0
- package/dist/{upgrade-DYzuvv1k.js → upgrade-DvBdbph3.js} +26 -5
- package/dist/{verify-C0IUSkMZ.js → verify-DRt5mCqO.js} +7 -3
- package/package.json +2 -2
- package/skills/first-tree/SKILL.md +31 -5
- package/skills/first-tree/agents/openai.yaml +1 -1
- package/skills/first-tree/engine/init.ts +88 -5
- package/skills/first-tree/engine/repo.ts +38 -15
- package/skills/first-tree/engine/runtime/adapters.ts +0 -2
- package/skills/first-tree/engine/runtime/asset-loader.ts +6 -36
- package/skills/first-tree/engine/runtime/installer.ts +0 -2
- package/skills/first-tree/engine/runtime/source-integration.ts +80 -0
- package/skills/first-tree/engine/upgrade.ts +68 -12
- package/skills/first-tree/engine/validators/nodes.ts +2 -11
- 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 +33 -5
- 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 +64 -0
- package/skills/first-tree/references/upgrade-contract.md +23 -12
- package/skills/first-tree/scripts/check-skill-sync.sh +2 -1
- package/skills/first-tree/tests/asset-loader.test.ts +0 -24
- package/skills/first-tree/tests/helpers.ts +0 -14
- package/skills/first-tree/tests/init.test.ts +67 -0
- package/skills/first-tree/tests/repo.test.ts +20 -25
- package/skills/first-tree/tests/skill-artifacts.test.ts +43 -1
- package/skills/first-tree/tests/thin-cli.test.ts +5 -0
- package/skills/first-tree/tests/upgrade.test.ts +38 -23
- package/skills/first-tree/tests/verify.test.ts +18 -0
- package/dist/installer-UgNasLjl.js +0 -51
- package/dist/onboarding-3zYUeYQb.js +0 -2
- package/dist/onboarding-Dd63N-V1.js +0 -10
|
@@ -3,8 +3,6 @@ import { join, relative, posix } from "node:path";
|
|
|
3
3
|
import {
|
|
4
4
|
AGENT_INSTRUCTIONS_FILE,
|
|
5
5
|
LEGACY_AGENT_INSTRUCTIONS_FILE,
|
|
6
|
-
LEGACY_SKILL_NAME,
|
|
7
|
-
LEGACY_SKILL_ROOT,
|
|
8
6
|
SKILL_NAME,
|
|
9
7
|
SKILL_ROOT,
|
|
10
8
|
} from "#skill/engine/runtime/asset-loader.js";
|
|
@@ -88,12 +86,7 @@ function rel(path: string): string {
|
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
function isInstalledSkillPath(relPath: string): boolean {
|
|
91
|
-
return (
|
|
92
|
-
relPath === SKILL_ROOT ||
|
|
93
|
-
relPath.startsWith(`${SKILL_ROOT}/`) ||
|
|
94
|
-
relPath === LEGACY_SKILL_ROOT ||
|
|
95
|
-
relPath.startsWith(`${LEGACY_SKILL_ROOT}/`)
|
|
96
|
-
);
|
|
89
|
+
return relPath === SKILL_ROOT || relPath.startsWith(`${SKILL_ROOT}/`);
|
|
97
90
|
}
|
|
98
91
|
|
|
99
92
|
function isFrameworkContainerDir(relPath: string, fullPath: string): boolean {
|
|
@@ -106,9 +99,7 @@ function isFrameworkContainerDir(relPath: string, fullPath: string): boolean {
|
|
|
106
99
|
if (entries.length === 0) {
|
|
107
100
|
return false;
|
|
108
101
|
}
|
|
109
|
-
return entries.every(
|
|
110
|
-
(entry) => entry === SKILL_NAME || entry === LEGACY_SKILL_NAME,
|
|
111
|
-
);
|
|
102
|
+
return entries.every((entry) => entry === SKILL_NAME);
|
|
112
103
|
} catch {
|
|
113
104
|
return false;
|
|
114
105
|
}
|
|
@@ -50,6 +50,13 @@ export function runVerify(repo?: Repo, nodeValidator?: NodeValidator): number {
|
|
|
50
50
|
const r = repo ?? new Repo();
|
|
51
51
|
const validate = nodeValidator ?? defaultNodeValidator;
|
|
52
52
|
|
|
53
|
+
if (r.hasSourceWorkspaceIntegration() && !r.looksLikeTreeRepo()) {
|
|
54
|
+
console.error(
|
|
55
|
+
`Error: this repo only has the first-tree source/workspace integration installed. Verify the dedicated tree repo instead, for example \`context-tree verify --tree-path ../${r.repoName()}-context\`.`,
|
|
56
|
+
);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
if (r.isLikelySourceRepo() && !r.looksLikeTreeRepo()) {
|
|
54
61
|
console.error(
|
|
55
62
|
"Error: no installed framework skill found here. This looks like a source/workspace repo. Run `context-tree init` to create a dedicated tree repo, or pass `--tree-path` to verify an existing tree repo.",
|
|
@@ -13,6 +13,10 @@ This reference explains how to maintain the `first-tree` source repo itself.
|
|
|
13
13
|
This repo is not a user context tree. User decision content lives in the repos
|
|
14
14
|
that install the framework.
|
|
15
15
|
|
|
16
|
+
When a source/workspace repo installs first-tree, that repo should keep only
|
|
17
|
+
the local skill integration and marker lines. Tree content still belongs only
|
|
18
|
+
in a dedicated `*-context` repo.
|
|
19
|
+
|
|
16
20
|
## Canonical Layers
|
|
17
21
|
|
|
18
22
|
1. `SKILL.md` defines when to use the skill and the maintainer workflow.
|
|
@@ -33,6 +33,9 @@ These root files are shell code, not canonical knowledge stores:
|
|
|
33
33
|
- Keep root prose short. It should point to the skill, not duplicate the skill.
|
|
34
34
|
- Keep command semantics, install layout rules, and maintainer guidance in the
|
|
35
35
|
skill references.
|
|
36
|
+
- If init/upgrade semantics change for source/workspace repos versus dedicated
|
|
37
|
+
tree repos, update `references/source-workspace-installation.md` and
|
|
38
|
+
`references/upgrade-contract.md` instead of expanding root shell prose.
|
|
36
39
|
- If the shell gains behavior that is not obviously mechanical, move that
|
|
37
40
|
behavior or its contract into the skill.
|
|
38
41
|
- When in doubt, prefer adding a skill reference over expanding root docs.
|
|
@@ -65,8 +65,10 @@ Information an agent needs to **decide** on an approach — not to execute it.
|
|
|
65
65
|
### Step 1: Initialize
|
|
66
66
|
|
|
67
67
|
Recommended workflow: run `context-tree init` from your source or workspace repo.
|
|
68
|
-
The CLI will
|
|
69
|
-
|
|
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.
|
|
70
72
|
|
|
71
73
|
```bash
|
|
72
74
|
cd my-org
|
|
@@ -82,6 +84,10 @@ git init
|
|
|
82
84
|
context-tree init --here
|
|
83
85
|
```
|
|
84
86
|
|
|
87
|
+
Only use `--here` after you have already switched into the dedicated tree repo.
|
|
88
|
+
Do not use it inside the source/workspace repo unless you intentionally want
|
|
89
|
+
that repo itself to become the Context Tree.
|
|
90
|
+
|
|
85
91
|
Either way, the framework installs into `.agents/skills/first-tree/` and
|
|
86
92
|
`.claude/skills/first-tree/`, renders scaffolding (`NODE.md`, `AGENTS.md`,
|
|
87
93
|
`members/NODE.md`), and generates a task list in
|
|
@@ -90,6 +96,19 @@ Either way, the framework installs into `.agents/skills/first-tree/` and
|
|
|
90
96
|
Publishing tip: keep the tree repo in the same GitHub organization as the
|
|
91
97
|
source repo unless you have a reason not to.
|
|
92
98
|
|
|
99
|
+
Hard boundary: do **not** create `NODE.md`, `members/`, or tree-scoped
|
|
100
|
+
`AGENTS.md` in the source/workspace repo. Those files belong only in the
|
|
101
|
+
dedicated `*-context` repo.
|
|
102
|
+
|
|
103
|
+
Default agent workflow after initialization:
|
|
104
|
+
|
|
105
|
+
1. Create and push the dedicated `*-context` repo in the same GitHub
|
|
106
|
+
organization as the source repo.
|
|
107
|
+
2. Add the dedicated tree repo back to the source/workspace repo as a `git submodule`.
|
|
108
|
+
3. Open a PR against the source/workspace repo's default branch for the local
|
|
109
|
+
skill integration plus the new submodule pointer. Do not merge it
|
|
110
|
+
automatically.
|
|
111
|
+
|
|
93
112
|
### Step 2: Work Through the Task List
|
|
94
113
|
|
|
95
114
|
Read `.agents/skills/first-tree/progress.md`. It contains a checklist tailored
|
|
@@ -123,6 +142,10 @@ This fails if any items in `.agents/skills/first-tree/progress.md` remain
|
|
|
123
142
|
unchecked, and runs deterministic checks (valid frontmatter, node structure,
|
|
124
143
|
member nodes exist).
|
|
125
144
|
|
|
145
|
+
Do not run `context-tree verify` in the source/workspace repo itself. That repo
|
|
146
|
+
only carries the installed skill plus the
|
|
147
|
+
`FIRST-TREE-SOURCE-INTEGRATION:` line.
|
|
148
|
+
|
|
126
149
|
### Step 4: Design Your Domains
|
|
127
150
|
|
|
128
151
|
Create top-level directories for your organization's primary concerns. Each needs a `NODE.md`:
|
|
@@ -158,7 +181,7 @@ The tree doesn't duplicate source code — it captures what connects things and
|
|
|
158
181
|
|
|
159
182
|
| Command | Description |
|
|
160
183
|
|---------|-------------|
|
|
161
|
-
| `context-tree init` |
|
|
184
|
+
| `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` only when you are already inside the dedicated tree repo. |
|
|
162
185
|
| `context-tree verify` | Check the installed progress file for unchecked items + run deterministic validation. Use `--tree-path` when invoking from another working directory. |
|
|
163
186
|
| `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. |
|
|
164
187
|
| `context-tree help onboarding` | Print this onboarding guide. |
|
|
@@ -178,8 +201,12 @@ context-tree upgrade
|
|
|
178
201
|
`first-tree` npm package, preserves your tree content, and generates follow-up
|
|
179
202
|
tasks in `.agents/skills/first-tree/progress.md`.
|
|
180
203
|
|
|
181
|
-
If
|
|
182
|
-
`
|
|
204
|
+
If you run `context-tree upgrade` in the source/workspace repo, it refreshes
|
|
205
|
+
only the local installed skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines.
|
|
206
|
+
Run `context-tree upgrade --tree-path ../my-org-context` to upgrade the
|
|
207
|
+
dedicated tree repo itself.
|
|
208
|
+
|
|
209
|
+
If your repo still uses the older `skills/first-tree/` or `.context-tree/` layouts,
|
|
183
210
|
`context-tree upgrade` will migrate it to the current installed layout first.
|
|
184
211
|
|
|
185
212
|
To pick up a newer framework release, first run a newer package version, for
|
|
@@ -191,5 +218,6 @@ install before running `context-tree upgrade`.
|
|
|
191
218
|
## Further Reading
|
|
192
219
|
|
|
193
220
|
- `.agents/skills/first-tree/references/principles.md` — Core principles with detailed examples
|
|
221
|
+
- `.agents/skills/first-tree/references/source-workspace-installation.md` — Source/workspace install contract
|
|
194
222
|
- `.agents/skills/first-tree/references/ownership-and-naming.md` — How nodes are named and owned
|
|
195
223
|
- `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,64 @@
|
|
|
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
|
+
## Agent Decision Rule
|
|
25
|
+
|
|
26
|
+
- Treat "install and use first-tree" in a source/workspace repo as a two-repo
|
|
27
|
+
workflow: local integration in the current repo plus tree bootstrap in a
|
|
28
|
+
sibling `*-context` repo.
|
|
29
|
+
- Do not run `context-tree init --here` in the source/workspace repo unless the
|
|
30
|
+
user explicitly says that repo itself should become the Context Tree.
|
|
31
|
+
- If you cannot create the sibling repo locally, cannot push it to GitHub, or
|
|
32
|
+
cannot add the submodule yet, pause and report the blocker. Do not fall back
|
|
33
|
+
to creating `NODE.md`, `members/`, or tree-scoped `AGENTS.md` in the
|
|
34
|
+
source/workspace repo.
|
|
35
|
+
|
|
36
|
+
## Default Agent Workflow
|
|
37
|
+
|
|
38
|
+
When an agent is asked to install first-tree for a source/workspace repo, the
|
|
39
|
+
default workflow is:
|
|
40
|
+
|
|
41
|
+
1. Install the bundled first-tree skill into the current repo.
|
|
42
|
+
2. Upsert the `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
43
|
+
`CLAUDE.md`.
|
|
44
|
+
3. Create a sibling dedicated tree repo named `<repo>-context`.
|
|
45
|
+
4. Prefer creating and pushing that repo in the same GitHub organization as
|
|
46
|
+
the source repo, matching the source repo's default visibility unless the
|
|
47
|
+
user asks for something else.
|
|
48
|
+
5. Add the dedicated tree repo back to the source/workspace repo as a `git submodule`.
|
|
49
|
+
6. Run `context-tree init --here` inside the dedicated tree repo.
|
|
50
|
+
7. Draft the first tree version from the real codebase, docs, and ownership
|
|
51
|
+
signals.
|
|
52
|
+
8. Open a PR against the source/workspace repo's default branch for the local
|
|
53
|
+
skill integration plus the new submodule pointer. Do not merge it
|
|
54
|
+
automatically.
|
|
55
|
+
|
|
56
|
+
## Verification And Upgrade
|
|
57
|
+
|
|
58
|
+
- Do not run `context-tree verify` in the source/workspace repo. Verify the
|
|
59
|
+
dedicated tree repo instead, for example
|
|
60
|
+
`context-tree verify --tree-path ../my-repo-context`.
|
|
61
|
+
- Running `context-tree upgrade` in the source/workspace repo refreshes only
|
|
62
|
+
the local installed skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines.
|
|
63
|
+
- Run `context-tree upgrade --tree-path ../my-repo-context` to upgrade the
|
|
64
|
+
dedicated tree repo itself.
|
|
@@ -1,8 +1,7 @@
|
|
|
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
|
-
`skills/first-tree-cli-framework/`, and `.context-tree/` repos.
|
|
4
|
+
rules we keep for legacy `skills/first-tree/` and `.context-tree/` repos.
|
|
6
5
|
|
|
7
6
|
## Canonical Source
|
|
8
7
|
|
|
@@ -16,7 +15,8 @@ rules we keep for legacy `skills/first-tree/`,
|
|
|
16
15
|
|
|
17
16
|
## Installed Layout
|
|
18
17
|
|
|
19
|
-
The current installed layout in a
|
|
18
|
+
The current installed layout in a source/workspace repo or dedicated tree repo
|
|
19
|
+
is:
|
|
20
20
|
|
|
21
21
|
```text
|
|
22
22
|
.agents/
|
|
@@ -50,7 +50,11 @@ The current installed layout in a user repo is:
|
|
|
50
50
|
helpers/
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
For a source/workspace repo, the local integration stops there. It should also
|
|
54
|
+
carry a single `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
55
|
+
`CLAUDE.md`, but it must not contain tree content.
|
|
56
|
+
|
|
57
|
+
For a dedicated tree repo, the tree content still lives outside the skill:
|
|
54
58
|
|
|
55
59
|
- `NODE.md`
|
|
56
60
|
- `AGENTS.md`
|
|
@@ -66,22 +70,27 @@ skill discovery and hooks.
|
|
|
66
70
|
- `context-tree init`
|
|
67
71
|
- when run in a source/workspace repo, creates or reuses a sibling dedicated
|
|
68
72
|
tree repo by default
|
|
73
|
+
- installs the skill into the source/workspace repo without creating tree
|
|
74
|
+
files there
|
|
75
|
+
- upserts the `FIRST-TREE-SOURCE-INTEGRATION:` line in root `AGENTS.md` and
|
|
76
|
+
`CLAUDE.md`
|
|
69
77
|
- installs the skill into the target tree repo
|
|
70
|
-
- renders top-level tree scaffolding
|
|
71
|
-
- writes progress state to
|
|
78
|
+
- renders top-level tree scaffolding only in the target tree repo
|
|
79
|
+
- writes progress state only to the dedicated tree repo at
|
|
80
|
+
`.agents/skills/first-tree/progress.md`
|
|
72
81
|
- `context-tree verify`
|
|
73
82
|
- checks progress state from the installed skill
|
|
74
83
|
- validates root/frontmatter/agent markers
|
|
75
84
|
- runs node and member validators
|
|
85
|
+
- must reject source/workspace repos that carry only local integration
|
|
76
86
|
- `context-tree upgrade`
|
|
77
87
|
- compares the installed skill payload version to the skill bundled with the
|
|
78
88
|
currently running `first-tree` package
|
|
79
89
|
- refreshes the installed skill payload without overwriting tree content
|
|
90
|
+
- when run in a source/workspace repo, refreshes only the local installed
|
|
91
|
+
skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines
|
|
80
92
|
- migrates repos that still use the previous `skills/first-tree/` path onto
|
|
81
93
|
`.agents/skills/first-tree/` and `.claude/skills/first-tree/`
|
|
82
|
-
- migrates repos that still use the previous
|
|
83
|
-
`skills/first-tree-cli-framework/` path onto `.agents/skills/first-tree/`
|
|
84
|
-
and `.claude/skills/first-tree/`
|
|
85
94
|
- migrates legacy `.context-tree/` repos onto the installed skill layout
|
|
86
95
|
- preserves user-authored sections such as the editable part of `AGENTS.md`
|
|
87
96
|
|
|
@@ -93,12 +102,14 @@ skill discovery and hooks.
|
|
|
93
102
|
- Default dedicated-tree-repo creation is local-only. The CLI may create a new
|
|
94
103
|
sibling git repo on disk, but it must not clone the source repo or depend on
|
|
95
104
|
network access.
|
|
105
|
+
- Source/workspace repos must never receive `NODE.md`, `members/`, or
|
|
106
|
+
tree-scoped `AGENTS.md` from default init flows.
|
|
96
107
|
- Normal `context-tree init` and `context-tree upgrade` flows do not clone the
|
|
97
108
|
source repo or require network access.
|
|
98
109
|
- `context-tree verify` may still read a legacy
|
|
99
|
-
`.claude/skills/first-tree/...`, `skills/first-tree/...`,
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
`.claude/skills/first-tree/...`, `skills/first-tree/...`, or
|
|
111
|
+
`.context-tree/...` layout in an existing user repo so the repo can be
|
|
112
|
+
repaired or upgraded in place.
|
|
102
113
|
- `context-tree upgrade` must migrate either legacy layout onto
|
|
103
114
|
`.agents/skills/first-tree/` and `.claude/skills/first-tree/`, and remove
|
|
104
115
|
old skill directories afterward.
|
|
@@ -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"
|
|
@@ -89,7 +91,6 @@ for legacy_path in \
|
|
|
89
91
|
".claude" \
|
|
90
92
|
".context-tree" \
|
|
91
93
|
"docs" \
|
|
92
|
-
"skills/first-tree-cli-framework" \
|
|
93
94
|
"tests" \
|
|
94
95
|
"skills/first-tree/references/repo-snapshot"
|
|
95
96
|
do
|
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
INSTALLED_PROGRESS,
|
|
8
8
|
LEGACY_REPO_SKILL_PROGRESS,
|
|
9
9
|
LEGACY_REPO_SKILL_VERSION,
|
|
10
|
-
LEGACY_SKILL_PROGRESS,
|
|
11
|
-
LEGACY_SKILL_VERSION,
|
|
12
10
|
LEGACY_PROGRESS,
|
|
13
11
|
LEGACY_VERSION,
|
|
14
12
|
detectFrameworkLayout,
|
|
@@ -57,37 +55,15 @@ describe("asset-loader", () => {
|
|
|
57
55
|
).toBe(LEGACY_REPO_SKILL_VERSION);
|
|
58
56
|
});
|
|
59
57
|
|
|
60
|
-
it("detects the previous installed skill name before the .context-tree layout", () => {
|
|
61
|
-
const tmp = useTmpDir();
|
|
62
|
-
mkdirSync(
|
|
63
|
-
join(tmp.path, "skills", "first-tree-cli-framework", "assets", "framework"),
|
|
64
|
-
{
|
|
65
|
-
recursive: true,
|
|
66
|
-
},
|
|
67
|
-
);
|
|
68
|
-
mkdirSync(join(tmp.path, ".context-tree"), { recursive: true });
|
|
69
|
-
writeFileSync(join(tmp.path, LEGACY_SKILL_VERSION), "0.2.0\n");
|
|
70
|
-
writeFileSync(join(tmp.path, LEGACY_VERSION), "0.1.0\n");
|
|
71
|
-
|
|
72
|
-
expect(detectFrameworkLayout(tmp.path)).toBe("legacy-skill");
|
|
73
|
-
expect(
|
|
74
|
-
resolveFirstExistingPath(tmp.path, frameworkVersionCandidates()),
|
|
75
|
-
).toBe(LEGACY_SKILL_VERSION);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
58
|
it("prefers the installed progress file candidate", () => {
|
|
79
59
|
const tmp = useTmpDir();
|
|
80
60
|
mkdirSync(join(tmp.path, ".agents", "skills", "first-tree"), { recursive: true });
|
|
81
61
|
mkdirSync(join(tmp.path, ".claude", "skills", "first-tree"), { recursive: true });
|
|
82
62
|
mkdirSync(join(tmp.path, "skills", "first-tree"), { recursive: true });
|
|
83
|
-
mkdirSync(join(tmp.path, "skills", "first-tree-cli-framework"), {
|
|
84
|
-
recursive: true,
|
|
85
|
-
});
|
|
86
63
|
mkdirSync(join(tmp.path, ".context-tree"), { recursive: true });
|
|
87
64
|
writeFileSync(join(tmp.path, INSTALLED_PROGRESS), "new");
|
|
88
65
|
writeFileSync(join(tmp.path, CLAUDE_INSTALLED_PROGRESS), "claude");
|
|
89
66
|
writeFileSync(join(tmp.path, LEGACY_REPO_SKILL_PROGRESS), "old-repo-skill");
|
|
90
|
-
writeFileSync(join(tmp.path, LEGACY_SKILL_PROGRESS), "old-skill");
|
|
91
67
|
writeFileSync(join(tmp.path, LEGACY_PROGRESS), "old");
|
|
92
68
|
|
|
93
69
|
expect(resolveFirstExistingPath(tmp.path, progressFileCandidates())).toBe(
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
FRAMEWORK_VERSION,
|
|
10
10
|
LEGACY_AGENT_INSTRUCTIONS_FILE,
|
|
11
11
|
LEGACY_REPO_SKILL_VERSION,
|
|
12
|
-
LEGACY_SKILL_VERSION,
|
|
13
12
|
LEGACY_VERSION,
|
|
14
13
|
SKILL_ROOT,
|
|
15
14
|
} from "#skill/engine/runtime/asset-loader.js";
|
|
@@ -74,19 +73,6 @@ export function makeLegacyRepoFramework(root: string, version = "0.1.0"): void {
|
|
|
74
73
|
writeFileSync(join(root, LEGACY_REPO_SKILL_VERSION), `${version}\n`);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
export function makeLegacyNamedFramework(
|
|
78
|
-
root: string,
|
|
79
|
-
version = "0.1.0",
|
|
80
|
-
): void {
|
|
81
|
-
mkdirSync(
|
|
82
|
-
join(root, "skills", "first-tree-cli-framework", "assets", "framework"),
|
|
83
|
-
{
|
|
84
|
-
recursive: true,
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
writeFileSync(join(root, LEGACY_SKILL_VERSION), `${version}\n`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
76
|
export function makeSourceSkill(root: string, version = "0.2.0"): void {
|
|
91
77
|
const skillRoot = join(root, "skills", "first-tree");
|
|
92
78
|
mkdirSync(join(skillRoot, "agents"), { recursive: true });
|