first-tree 0.0.5 → 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 +21 -7
- package/dist/cli.js +5 -5
- package/dist/{help-5-WG9QFm.js → help-DV9-AaFp.js} +1 -1
- package/dist/{init-CAq0Uhq6.js → init-BgGH2_yC.js} +41 -7
- package/dist/onboarding-D7fGGOMN.js +10 -0
- package/dist/onboarding-lASHHmgO.js +2 -0
- package/dist/{repo-DkR12VUv.js → repo-Cc5U4DWT.js} +22 -2
- package/dist/{installer-UgNasLjl.js → source-integration-CuKjoheT.js} +36 -3
- package/dist/{upgrade-DYzuvv1k.js → upgrade-BvA9oKmi.js} +26 -3
- package/dist/{verify-C0IUSkMZ.js → verify-G8gNXzDX.js} +5 -1
- package/package.json +2 -2
- package/skills/first-tree/SKILL.md +21 -5
- package/skills/first-tree/agents/openai.yaml +1 -1
- package/skills/first-tree/assets/framework/VERSION +1 -1
- package/skills/first-tree/engine/init.ts +75 -4
- package/skills/first-tree/engine/repo.ts +38 -7
- package/skills/first-tree/engine/runtime/asset-loader.ts +6 -0
- package/skills/first-tree/engine/runtime/source-integration.ts +80 -0
- package/skills/first-tree/engine/upgrade.ts +68 -1
- 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 +28 -3
- 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 +19 -4
- package/skills/first-tree/scripts/check-skill-sync.sh +2 -0
- package/skills/first-tree/tests/init.test.ts +61 -0
- package/skills/first-tree/tests/repo.test.ts +20 -0
- package/skills/first-tree/tests/skill-artifacts.test.ts +39 -0
- package/skills/first-tree/tests/upgrade.test.ts +38 -2
- package/skills/first-tree/tests/verify.test.ts +18 -0
- package/dist/onboarding-3zYUeYQb.js +0 -2
- package/dist/onboarding-Dd63N-V1.js +0 -10
|
@@ -20,13 +20,17 @@ import {
|
|
|
20
20
|
frameworkVersionCandidates,
|
|
21
21
|
progressFileCandidates,
|
|
22
22
|
resolveFirstExistingPath,
|
|
23
|
+
SOURCE_INTEGRATION_FILES,
|
|
24
|
+
SOURCE_INTEGRATION_MARKER,
|
|
23
25
|
} from "#skill/engine/runtime/asset-loader.js";
|
|
24
26
|
|
|
25
27
|
const FRONTMATTER_RE = /^---\s*\n(.*?)\n---/s;
|
|
26
28
|
const OWNERS_RE = /^owners:\s*\[([^\]]*)\]/m;
|
|
27
29
|
const TITLE_RE = /^title:\s*['"]?(.+?)['"]?\s*$/m;
|
|
28
30
|
const EMPTY_REPO_ENTRY_ALLOWLIST = new Set([
|
|
31
|
+
".agents",
|
|
29
32
|
".DS_Store",
|
|
33
|
+
".claude",
|
|
30
34
|
".editorconfig",
|
|
31
35
|
".gitattributes",
|
|
32
36
|
".github",
|
|
@@ -273,6 +277,23 @@ export class Repo {
|
|
|
273
277
|
return text.includes(FRAMEWORK_BEGIN_MARKER) && text.includes(FRAMEWORK_END_MARKER);
|
|
274
278
|
}
|
|
275
279
|
|
|
280
|
+
hasSourceIntegrationFile(relPath: string): boolean {
|
|
281
|
+
return this.fileContains(relPath, SOURCE_INTEGRATION_MARKER);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
hasSourceWorkspaceIntegration(): boolean {
|
|
285
|
+
return SOURCE_INTEGRATION_FILES.some((file) => this.hasSourceIntegrationFile(file));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
hasTreeContent(): boolean {
|
|
289
|
+
return (
|
|
290
|
+
this.progressPath() !== null
|
|
291
|
+
|| this.hasAgentInstructionsMarkers()
|
|
292
|
+
|| this.pathExists("members/NODE.md")
|
|
293
|
+
|| this.frontmatter("NODE.md") !== null
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
276
297
|
hasMembers(): boolean {
|
|
277
298
|
const membersDir = join(this.root, "members");
|
|
278
299
|
try {
|
|
@@ -338,13 +359,19 @@ export class Repo {
|
|
|
338
359
|
return false;
|
|
339
360
|
}
|
|
340
361
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
362
|
+
if (this.hasTreeContent()) {
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (this.hasFramework() && this.hasSourceWorkspaceIntegration()) {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (this.hasFramework()) {
|
|
371
|
+
return !this.hasLikelySourceRepoSignals();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return false;
|
|
348
375
|
}
|
|
349
376
|
|
|
350
377
|
isLikelyEmptyRepo(): boolean {
|
|
@@ -359,6 +386,10 @@ export class Repo {
|
|
|
359
386
|
return false;
|
|
360
387
|
}
|
|
361
388
|
|
|
389
|
+
return this.hasLikelySourceRepoSignals();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
private hasLikelySourceRepoSignals(): boolean {
|
|
362
393
|
const entries = this.topLevelEntries().filter(
|
|
363
394
|
(entry) => !EMPTY_REPO_ENTRY_ALLOWLIST.has(entry),
|
|
364
395
|
);
|
|
@@ -21,6 +21,12 @@ export const INSTALLED_PROGRESS = join(SKILL_ROOT, "progress.md");
|
|
|
21
21
|
export const AGENT_INSTRUCTIONS_FILE = "AGENTS.md";
|
|
22
22
|
export const LEGACY_AGENT_INSTRUCTIONS_FILE = "AGENT.md";
|
|
23
23
|
export const AGENT_INSTRUCTIONS_TEMPLATE = "agents.md.template";
|
|
24
|
+
export const CLAUDE_INSTRUCTIONS_FILE = "CLAUDE.md";
|
|
25
|
+
export const SOURCE_INTEGRATION_MARKER = "FIRST-TREE-SOURCE-INTEGRATION:";
|
|
26
|
+
export const SOURCE_INTEGRATION_FILES = [
|
|
27
|
+
AGENT_INSTRUCTIONS_FILE,
|
|
28
|
+
CLAUDE_INSTRUCTIONS_FILE,
|
|
29
|
+
] as const;
|
|
24
30
|
|
|
25
31
|
export const CLAUDE_SKILL_AGENTS_DIR = join(CLAUDE_SKILL_ROOT, "agents");
|
|
26
32
|
export const CLAUDE_SKILL_REFERENCES_DIR = join(CLAUDE_SKILL_ROOT, "references");
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
SOURCE_INTEGRATION_FILES,
|
|
5
|
+
SOURCE_INTEGRATION_MARKER,
|
|
6
|
+
} from "#skill/engine/runtime/asset-loader.js";
|
|
7
|
+
|
|
8
|
+
export type SourceIntegrationFile = (typeof SOURCE_INTEGRATION_FILES)[number];
|
|
9
|
+
|
|
10
|
+
export interface SourceIntegrationUpdate {
|
|
11
|
+
action: "created" | "updated" | "unchanged";
|
|
12
|
+
file: SourceIntegrationFile;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function buildSourceIntegrationLine(treeRepoName: string): string {
|
|
16
|
+
return (
|
|
17
|
+
`${SOURCE_INTEGRATION_MARKER} Use the installed \`first-tree\` skill here;`
|
|
18
|
+
+ ` keep all Context Tree files only in the sibling dedicated`
|
|
19
|
+
+ ` \`${treeRepoName}\` repo/submodule and update that tree when decisions`
|
|
20
|
+
+ " or constraints change."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function hasSourceIntegrationMarker(text: string | null): boolean {
|
|
25
|
+
if (text === null) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return text
|
|
29
|
+
.replaceAll("\r\n", "\n")
|
|
30
|
+
.split("\n")
|
|
31
|
+
.some((line) => line.startsWith(SOURCE_INTEGRATION_MARKER));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function upsertSourceIntegrationFiles(
|
|
35
|
+
root: string,
|
|
36
|
+
treeRepoName: string,
|
|
37
|
+
): SourceIntegrationUpdate[] {
|
|
38
|
+
return SOURCE_INTEGRATION_FILES.map((file) =>
|
|
39
|
+
upsertSourceIntegrationFile(root, file, treeRepoName),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function upsertSourceIntegrationFile(
|
|
44
|
+
root: string,
|
|
45
|
+
file: SourceIntegrationFile,
|
|
46
|
+
treeRepoName: string,
|
|
47
|
+
): SourceIntegrationUpdate {
|
|
48
|
+
const fullPath = join(root, file);
|
|
49
|
+
const exists = existsSync(fullPath);
|
|
50
|
+
const nextLine = buildSourceIntegrationLine(treeRepoName);
|
|
51
|
+
const current = exists ? readFileSync(fullPath, "utf-8") : null;
|
|
52
|
+
const normalized = current?.replaceAll("\r\n", "\n") ?? "";
|
|
53
|
+
const lines = normalized === "" ? [] : normalized.split("\n");
|
|
54
|
+
const markerIndex = lines.findIndex((line) =>
|
|
55
|
+
line.startsWith(SOURCE_INTEGRATION_MARKER),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (markerIndex >= 0) {
|
|
59
|
+
if (lines[markerIndex] === nextLine) {
|
|
60
|
+
return { action: "unchanged", file };
|
|
61
|
+
}
|
|
62
|
+
lines[markerIndex] = nextLine;
|
|
63
|
+
} else {
|
|
64
|
+
if (lines.length > 0 && lines.at(-1) !== "") {
|
|
65
|
+
lines.push("");
|
|
66
|
+
}
|
|
67
|
+
lines.push(nextLine);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let nextText = lines.join("\n");
|
|
71
|
+
if (nextText !== "" && !nextText.endsWith("\n")) {
|
|
72
|
+
nextText += "\n";
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(fullPath, nextText);
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
action: exists ? "updated" : "created",
|
|
78
|
+
file,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Repo } from "#skill/engine/repo.js";
|
|
|
4
4
|
import {
|
|
5
5
|
AGENT_INSTRUCTIONS_FILE,
|
|
6
6
|
AGENT_INSTRUCTIONS_TEMPLATE,
|
|
7
|
+
CLAUDE_INSTRUCTIONS_FILE,
|
|
7
8
|
CLAUDE_SKILL_ROOT,
|
|
8
9
|
FRAMEWORK_WORKFLOWS_DIR,
|
|
9
10
|
FRAMEWORK_TEMPLATES_DIR,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
LEGACY_REPO_SKILL_ROOT,
|
|
15
16
|
LEGACY_SKILL_ROOT,
|
|
16
17
|
SKILL_ROOT,
|
|
18
|
+
SOURCE_INTEGRATION_MARKER,
|
|
17
19
|
installedSkillRootsDisplay,
|
|
18
20
|
type FrameworkLayout,
|
|
19
21
|
} from "#skill/engine/runtime/asset-loader.js";
|
|
@@ -21,6 +23,7 @@ import {
|
|
|
21
23
|
copyCanonicalSkill,
|
|
22
24
|
resolveBundledPackageRoot,
|
|
23
25
|
} from "#skill/engine/runtime/installer.js";
|
|
26
|
+
import { upsertSourceIntegrationFiles } from "#skill/engine/runtime/source-integration.js";
|
|
24
27
|
import {
|
|
25
28
|
compareFrameworkVersions,
|
|
26
29
|
readSourceVersion,
|
|
@@ -121,8 +124,10 @@ export interface UpgradeOptions {
|
|
|
121
124
|
|
|
122
125
|
export function runUpgrade(repo?: Repo, options?: UpgradeOptions): number {
|
|
123
126
|
const workingRepo = repo ?? new Repo();
|
|
127
|
+
const workspaceOnlyIntegration =
|
|
128
|
+
workingRepo.hasSourceWorkspaceIntegration() && !workingRepo.looksLikeTreeRepo();
|
|
124
129
|
|
|
125
|
-
if (workingRepo.isLikelySourceRepo() && !workingRepo.looksLikeTreeRepo()) {
|
|
130
|
+
if (workingRepo.isLikelySourceRepo() && !workingRepo.looksLikeTreeRepo() && !workspaceOnlyIntegration) {
|
|
126
131
|
console.error(
|
|
127
132
|
"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 upgrade an existing tree repo.",
|
|
128
133
|
);
|
|
@@ -178,6 +183,68 @@ export function runUpgrade(repo?: Repo, options?: UpgradeOptions): number {
|
|
|
178
183
|
}
|
|
179
184
|
|
|
180
185
|
const missingInstalledRoots = workingRepo.missingInstalledSkillRoots();
|
|
186
|
+
const sourceRepoTreePathHint = `../${workingRepo.repoName()}-context`;
|
|
187
|
+
|
|
188
|
+
if (workspaceOnlyIntegration) {
|
|
189
|
+
if (
|
|
190
|
+
layout === "skill" &&
|
|
191
|
+
missingInstalledRoots.length === 0 &&
|
|
192
|
+
packagedVersion === localVersion
|
|
193
|
+
) {
|
|
194
|
+
const updates = upsertSourceIntegrationFiles(
|
|
195
|
+
workingRepo.root,
|
|
196
|
+
`${workingRepo.repoName()}-context`,
|
|
197
|
+
);
|
|
198
|
+
const changedFiles = updates
|
|
199
|
+
.filter((update) => update.action !== "unchanged")
|
|
200
|
+
.map((update) => update.file);
|
|
201
|
+
if (changedFiles.length === 0) {
|
|
202
|
+
console.log(
|
|
203
|
+
`Already up to date with the bundled skill (${FRAMEWORK_VERSION} = ${localVersion}).`,
|
|
204
|
+
);
|
|
205
|
+
console.log(
|
|
206
|
+
`This repo only carries source/workspace integration. Upgrade the dedicated tree repo separately with \`context-tree upgrade --tree-path ${sourceRepoTreePathHint}\`.`,
|
|
207
|
+
);
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
console.log(
|
|
211
|
+
`Already up to date with the bundled skill (${FRAMEWORK_VERSION} = ${localVersion}).`,
|
|
212
|
+
);
|
|
213
|
+
console.log(
|
|
214
|
+
`Updated the ${SOURCE_INTEGRATION_MARKER} marker lines in ${changedFiles.map((file) => `\`${file}\``).join(" and ")}.`,
|
|
215
|
+
);
|
|
216
|
+
console.log(
|
|
217
|
+
`This repo only carries source/workspace integration. Upgrade the dedicated tree repo separately with \`context-tree upgrade --tree-path ${sourceRepoTreePathHint}\`.`,
|
|
218
|
+
);
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
copyCanonicalSkill(sourceRoot, workingRepo.root);
|
|
223
|
+
const updates = upsertSourceIntegrationFiles(
|
|
224
|
+
workingRepo.root,
|
|
225
|
+
`${workingRepo.repoName()}-context`,
|
|
226
|
+
);
|
|
227
|
+
const changedFiles = updates
|
|
228
|
+
.filter((update) => update.action !== "unchanged")
|
|
229
|
+
.map((update) => update.file);
|
|
230
|
+
console.log(
|
|
231
|
+
`Refreshed ${installedSkillRootsDisplay()} in this source/workspace repo.`,
|
|
232
|
+
);
|
|
233
|
+
if (changedFiles.length > 0) {
|
|
234
|
+
console.log(
|
|
235
|
+
`Updated the ${SOURCE_INTEGRATION_MARKER} marker lines in ${changedFiles.map((file) => `\`${file}\``).join(" and ")}.`,
|
|
236
|
+
);
|
|
237
|
+
} else {
|
|
238
|
+
console.log(
|
|
239
|
+
`The ${SOURCE_INTEGRATION_MARKER} marker lines in ${AGENT_INSTRUCTIONS_FILE} and ${CLAUDE_INSTRUCTIONS_FILE} were already current.`,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
console.log(
|
|
243
|
+
`This repo is not the Context Tree. Upgrade the dedicated tree repo separately with \`context-tree upgrade --tree-path ${sourceRepoTreePathHint}\`.`,
|
|
244
|
+
);
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
181
248
|
if (
|
|
182
249
|
layout === "skill" &&
|
|
183
250
|
missingInstalledRoots.length === 0 &&
|
|
@@ -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
|
|
@@ -90,6 +92,19 @@ Either way, the framework installs into `.agents/skills/first-tree/` and
|
|
|
90
92
|
Publishing tip: keep the tree repo in the same GitHub organization as the
|
|
91
93
|
source repo unless you have a reason not to.
|
|
92
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
|
+
|
|
93
108
|
### Step 2: Work Through the Task List
|
|
94
109
|
|
|
95
110
|
Read `.agents/skills/first-tree/progress.md`. It contains a checklist tailored
|
|
@@ -123,6 +138,10 @@ This fails if any items in `.agents/skills/first-tree/progress.md` remain
|
|
|
123
138
|
unchecked, and runs deterministic checks (valid frontmatter, node structure,
|
|
124
139
|
member nodes exist).
|
|
125
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.
|
|
144
|
+
|
|
126
145
|
### Step 4: Design Your Domains
|
|
127
146
|
|
|
128
147
|
Create top-level directories for your organization's primary concerns. Each needs a `NODE.md`:
|
|
@@ -158,7 +177,7 @@ The tree doesn't duplicate source code — it captures what connects things and
|
|
|
158
177
|
|
|
159
178
|
| Command | Description |
|
|
160
179
|
|---------|-------------|
|
|
161
|
-
| `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. |
|
|
162
181
|
| `context-tree verify` | Check the installed progress file for unchecked items + run deterministic validation. Use `--tree-path` when invoking from another working directory. |
|
|
163
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. |
|
|
164
183
|
| `context-tree help onboarding` | Print this onboarding guide. |
|
|
@@ -178,6 +197,11 @@ context-tree upgrade
|
|
|
178
197
|
`first-tree` npm package, preserves your tree content, and generates follow-up
|
|
179
198
|
tasks in `.agents/skills/first-tree/progress.md`.
|
|
180
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.
|
|
204
|
+
|
|
181
205
|
If your repo still uses the older `skills/first-tree/`,
|
|
182
206
|
`skills/first-tree-cli-framework/`, or `.context-tree/` layouts,
|
|
183
207
|
`context-tree upgrade` will migrate it to the current installed layout first.
|
|
@@ -191,5 +215,6 @@ install before running `context-tree upgrade`.
|
|
|
191
215
|
## Further Reading
|
|
192
216
|
|
|
193
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
|
|
194
219
|
- `.agents/skills/first-tree/references/ownership-and-naming.md` — How nodes are named and owned
|
|
195
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 |
|