first-tree 0.0.1 → 0.0.3

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.
Files changed (80) hide show
  1. package/README.md +73 -39
  2. package/dist/cli.js +27 -13
  3. package/dist/help-xEI-s9iN.js +25 -0
  4. package/dist/init-DtOjj0wc.js +253 -0
  5. package/dist/installer-rcZpGLnM.js +47 -0
  6. package/dist/onboarding-6Fr5Gkrk.js +2 -0
  7. package/dist/onboarding-B9zPGvvG.js +10 -0
  8. package/dist/repo-BTJG8BU1.js +187 -0
  9. package/dist/upgrade-COGgI7Rj.js +96 -0
  10. package/dist/{verify-DIz6qmBX.js → verify-CxN6JiV9.js} +135 -8
  11. package/package.json +33 -10
  12. package/skills/first-tree/SKILL.md +109 -0
  13. package/skills/first-tree/agents/openai.yaml +4 -0
  14. package/skills/first-tree/assets/framework/VERSION +1 -0
  15. package/skills/first-tree/assets/framework/examples/claude-code/README.md +14 -0
  16. package/skills/first-tree/assets/framework/examples/claude-code/settings.json +14 -0
  17. package/skills/first-tree/assets/framework/helpers/generate-codeowners.ts +224 -0
  18. package/skills/first-tree/assets/framework/helpers/inject-tree-context.sh +15 -0
  19. package/skills/first-tree/assets/framework/helpers/run-review.ts +179 -0
  20. package/skills/first-tree/assets/framework/manifest.json +11 -0
  21. package/skills/first-tree/assets/framework/prompts/pr-review.md +38 -0
  22. package/skills/first-tree/assets/framework/templates/agent.md.template +48 -0
  23. package/skills/first-tree/assets/framework/templates/member-node.md.template +18 -0
  24. package/skills/first-tree/assets/framework/templates/members-domain.md.template +45 -0
  25. package/skills/first-tree/assets/framework/templates/root-node.md.template +38 -0
  26. package/skills/first-tree/assets/framework/workflows/codeowners.yml +31 -0
  27. package/skills/first-tree/assets/framework/workflows/pr-review.yml +146 -0
  28. package/skills/first-tree/assets/framework/workflows/validate.yml +19 -0
  29. package/skills/first-tree/engine/commands/help.ts +32 -0
  30. package/skills/first-tree/engine/commands/init.ts +1 -0
  31. package/skills/first-tree/engine/commands/upgrade.ts +1 -0
  32. package/skills/first-tree/engine/commands/verify.ts +1 -0
  33. package/skills/first-tree/engine/init.ts +145 -0
  34. package/skills/first-tree/engine/onboarding.ts +10 -0
  35. package/skills/first-tree/engine/repo.ts +184 -0
  36. package/skills/first-tree/engine/rules/agent-instructions.ts +37 -0
  37. package/skills/first-tree/engine/rules/agent-integration.ts +19 -0
  38. package/skills/first-tree/engine/rules/ci-validation.ts +72 -0
  39. package/skills/first-tree/engine/rules/framework.ts +13 -0
  40. package/skills/first-tree/engine/rules/index.ts +41 -0
  41. package/skills/first-tree/engine/rules/members.ts +21 -0
  42. package/skills/first-tree/engine/rules/populate-tree.ts +36 -0
  43. package/skills/first-tree/engine/rules/root-node.ts +41 -0
  44. package/skills/first-tree/engine/runtime/adapters.ts +22 -0
  45. package/skills/first-tree/engine/runtime/asset-loader.ts +134 -0
  46. package/skills/first-tree/engine/runtime/installer.ts +82 -0
  47. package/skills/first-tree/engine/runtime/upgrader.ts +23 -0
  48. package/skills/first-tree/engine/upgrade.ts +176 -0
  49. package/skills/first-tree/engine/validators/members.ts +215 -0
  50. package/skills/first-tree/engine/validators/nodes.ts +514 -0
  51. package/skills/first-tree/engine/verify.ts +97 -0
  52. package/skills/first-tree/references/about.md +36 -0
  53. package/skills/first-tree/references/maintainer-architecture.md +59 -0
  54. package/skills/first-tree/references/maintainer-build-and-distribution.md +56 -0
  55. package/skills/first-tree/references/maintainer-testing.md +58 -0
  56. package/skills/first-tree/references/maintainer-thin-cli.md +38 -0
  57. package/skills/first-tree/references/onboarding.md +162 -0
  58. package/skills/first-tree/references/ownership-and-naming.md +94 -0
  59. package/skills/first-tree/references/principles.md +113 -0
  60. package/skills/first-tree/references/source-map.md +94 -0
  61. package/skills/first-tree/references/upgrade-contract.md +85 -0
  62. package/skills/first-tree/scripts/check-skill-sync.sh +133 -0
  63. package/skills/first-tree/scripts/quick_validate.py +95 -0
  64. package/skills/first-tree/scripts/run-local-cli.sh +35 -0
  65. package/skills/first-tree/tests/asset-loader.test.ts +75 -0
  66. package/skills/first-tree/tests/generate-codeowners.test.ts +94 -0
  67. package/skills/first-tree/tests/helpers.ts +149 -0
  68. package/skills/first-tree/tests/init.test.ts +153 -0
  69. package/skills/first-tree/tests/repo.test.ts +362 -0
  70. package/skills/first-tree/tests/rules.test.ts +394 -0
  71. package/skills/first-tree/tests/run-review.test.ts +155 -0
  72. package/skills/first-tree/tests/skill-artifacts.test.ts +307 -0
  73. package/skills/first-tree/tests/thin-cli.test.ts +59 -0
  74. package/skills/first-tree/tests/upgrade.test.ts +89 -0
  75. package/skills/first-tree/tests/validate-members.test.ts +224 -0
  76. package/skills/first-tree/tests/validate-nodes.test.ts +198 -0
  77. package/skills/first-tree/tests/verify.test.ts +142 -0
  78. package/dist/init-CE_944sb.js +0 -283
  79. package/dist/repo-BByc3VvM.js +0 -111
  80. package/dist/upgrade-Chr7z0CY.js +0 -82
@@ -0,0 +1,56 @@
1
+ # Build And Distribution
2
+
3
+ Use this reference when touching package wiring, release behavior, or the
4
+ distributable contract of `first-tree`.
5
+
6
+ ## Fast Validation
7
+
8
+ Run these commands from the repo root:
9
+
10
+ ```bash
11
+ pnpm validate:skill
12
+ pnpm typecheck
13
+ pnpm test
14
+ pnpm build
15
+ ```
16
+
17
+ ## Packaging Checks
18
+
19
+ When changing package contents, build wiring, or install/upgrade behavior, also
20
+ run:
21
+
22
+ ```bash
23
+ pnpm pack
24
+ ```
25
+
26
+ Inspect the tarball contents before merging packaging changes. The distribution
27
+ must be able to carry the canonical skill and the thin CLI shell without
28
+ requiring repo-local prose.
29
+
30
+ ## Build Responsibilities
31
+
32
+ - `package.json` defines package metadata, scripts, and import aliases.
33
+ - `tsconfig.json` defines TypeScript compile boundaries.
34
+ - `tsdown.config.ts` defines the build entry and asset loaders.
35
+ - `vitest.config.ts` defines unit-test entrypoints, and
36
+ `vitest.eval.config.ts` defines the repo-only maintainer eval entrypoint.
37
+ - `.github/workflows/ci.yml` is the thin CI shell for repo validation.
38
+
39
+ These files are shell surfaces. Their meaning must be documented here or in
40
+ another skill reference, not only in the files themselves.
41
+
42
+ ## Distribution Rules
43
+
44
+ - Do not introduce a second copy of the framework outside the skill.
45
+ - `package.json` must ship `skills/first-tree/` in the published
46
+ package alongside the thin CLI build output.
47
+ - Keep repo-only developer tooling such as root `evals/` out of the published
48
+ package unless it becomes part of the user-facing framework contract.
49
+ - If the CLI needs bundled knowledge or payload files, ship the canonical skill
50
+ with the package rather than copying that information into root docs.
51
+ - Normal `context-tree init` / `context-tree upgrade` flows must install from
52
+ the skill bundled in the running package, not by cloning the source repo.
53
+ - If you change anything that gets copied into user repos, bump
54
+ `assets/framework/VERSION` and keep the upgrade task text in sync.
55
+ - If packaging changes alter what gets installed into user repos, update
56
+ `references/upgrade-contract.md`, tests, and validation commands together.
@@ -0,0 +1,58 @@
1
+ # Testing
2
+
3
+ Use this reference when validating framework behavior or changing the testing
4
+ surface.
5
+
6
+ ## Core Checks
7
+
8
+ ```bash
9
+ pnpm validate:skill
10
+ pnpm typecheck
11
+ pnpm test
12
+ pnpm build
13
+ ```
14
+
15
+ ### What Each Check Covers
16
+
17
+ - `pnpm validate:skill` verifies the canonical skill structure and sync rules.
18
+ - `pnpm typecheck` catches TypeScript boundary and import issues.
19
+ - `pnpm test` runs unit tests plus repo-local helper tests that support
20
+ maintainer tooling.
21
+ - `pnpm build` checks the thin CLI bundle.
22
+
23
+ ## Targeted Unit Tests
24
+
25
+ Examples:
26
+
27
+ ```bash
28
+ pnpm test -- skills/first-tree/tests/rules.test.ts
29
+ pnpm test -- skills/first-tree/tests/verify.test.ts
30
+ pnpm test -- skills/first-tree/tests/skill-artifacts.test.ts
31
+ pnpm test -- skills/first-tree/tests/thin-cli.test.ts
32
+ ```
33
+
34
+ If a future refactor changes these paths again, keep the command semantics and
35
+ coverage expectations documented here.
36
+
37
+ ## Packaging Check
38
+
39
+ ```bash
40
+ pnpm pack
41
+ ```
42
+
43
+ Inspect the tarball when package contents or install/upgrade behavior changes.
44
+ The published package should include the thin CLI shell and canonical skill, but
45
+ not repo-only developer tooling such as root `evals/`.
46
+
47
+ ## Repo-Only Evals
48
+
49
+ The end-to-end eval harness is intentionally not part of the distributed skill.
50
+ It lives under root `evals/` for `first-tree` maintainers working in this
51
+ source repo. Use `evals/README.md` when you need to run or update it.
52
+
53
+ ## Change Discipline
54
+
55
+ - Update this reference whenever core test entrypoints or packaging boundaries
56
+ change.
57
+ - If a maintainer would need oral history to know which checks matter, that
58
+ knowledge belongs here.
@@ -0,0 +1,38 @@
1
+ # Thin CLI Shell
2
+
3
+ Use this reference when changing the root CLI/package shell.
4
+
5
+ ## Shell Responsibilities
6
+
7
+ The root shell should do only a few things:
8
+
9
+ - parse commands and flags
10
+ - expose version/help
11
+ - load canonical framework behavior
12
+ - build, validate, and package the distributable
13
+
14
+ If a change requires non-trivial framework knowledge, put that knowledge in the
15
+ skill and have the shell call it.
16
+
17
+ ## Shell Surface
18
+
19
+ These root files are shell code, not canonical knowledge stores:
20
+
21
+ - `src/cli.ts`
22
+ - `src/md.d.ts`
23
+ - `package.json`
24
+ - `tsconfig.json`
25
+ - `tsdown.config.ts`
26
+ - `vitest.config.ts`
27
+ - `vitest.eval.config.ts` (repo-only maintainer eval entrypoint)
28
+ - `.github/workflows/ci.yml`
29
+ - root `README.md` and `AGENT.md`
30
+
31
+ ## Rules For Shell Changes
32
+
33
+ - Keep root prose short. It should point to the skill, not duplicate the skill.
34
+ - Keep command semantics, install layout rules, and maintainer guidance in the
35
+ skill references.
36
+ - If the shell gains behavior that is not obviously mechanical, move that
37
+ behavior or its contract into the skill.
38
+ - When in doubt, prefer adding a skill reference over expanding root docs.
@@ -0,0 +1,162 @@
1
+ # Context Tree Onboarding
2
+
3
+ You are setting up a **Context Tree** — the living source of truth for an organization. This document tells you what it is and how to bootstrap one.
4
+
5
+ ---
6
+
7
+ ## What Is a Context Tree
8
+
9
+ A Context Tree is a Git repository where every directory is a **domain** and every file is a **node**. Each node captures decisions, designs, and cross-domain relationships — the knowledge that would otherwise scatter across PRs, documents, and people's heads.
10
+
11
+ Key properties:
12
+
13
+ - **Nodes are markdown files.** Each directory has a `NODE.md` that describes the domain. Leaf `.md` files capture specific decisions or designs.
14
+ - **Every node has an owner.** Declared in YAML frontmatter. Owners approve changes to their nodes.
15
+ - **Organized by concern, not by repo or team.** An agent working on "add SSO" finds all auth context in one place — not split across 4 repos.
16
+ - **The tree is never a snapshot — it's the current state.** When decisions change, the tree updates. Stale nodes are bugs.
17
+
18
+ ### Frontmatter Format
19
+
20
+ Every node has frontmatter:
21
+
22
+ ```yaml
23
+ ---
24
+ title: "Auth Architecture"
25
+ owners: [alice, bob]
26
+ soft_links: [/infrastructure/deployments]
27
+ ---
28
+ ```
29
+
30
+ - `owners` — who can approve changes. `owners: []` inherits from parent. `owners: [*]` means anyone.
31
+ - `soft_links` — cross-references to related nodes in other domains.
32
+
33
+ ### What Belongs in the Tree
34
+
35
+ Information an agent needs to **decide** on an approach — not to execute it.
36
+
37
+ **Yes:** "Auth spans 4 repos: backend issues JWTs, frontend uses Better Auth, extension uses OAuth popup, desktop uses localhost callback."
38
+
39
+ **No:** The function signature of `auth_service.verify()` — that's in the code.
40
+
41
+ ---
42
+
43
+ ## Four Principles
44
+
45
+ 1. **Source of truth for decisions, not execution.** The tree captures the *what* and *why*. Execution details stay in source systems.
46
+ 2. **Agents are first-class participants.** The tree is designed for agents to navigate and update.
47
+ 3. **Transparency by default.** Reading is open to all. Writing requires owner approval.
48
+ 4. **Git-native.** Nodes are files, domains are directories. History, ownership, and review follow Git conventions.
49
+
50
+ ---
51
+
52
+ ## How to Set Up a Context Tree
53
+
54
+ ### Prerequisites
55
+
56
+ - A Git repository for your tree (separate from your code repos)
57
+ - Node.js 18+
58
+ - The npm package is `first-tree`, the installed CLI command is
59
+ `context-tree`, and the installed skill directory in the tree is
60
+ `skills/first-tree/`
61
+ - Use `npx first-tree init` for one-off runs, or `npm install -g first-tree`
62
+ to add the `context-tree` command to your PATH
63
+
64
+ ### Step 1: Initialize
65
+
66
+ ```bash
67
+ mkdir my-org-tree && cd my-org-tree
68
+ git init
69
+ context-tree init
70
+ ```
71
+
72
+ This installs the framework skill into `skills/first-tree/`, renders scaffolding (`NODE.md`, `AGENT.md`, `members/NODE.md`), and generates a task list in `skills/first-tree/progress.md`.
73
+
74
+ ### Step 2: Work Through the Task List
75
+
76
+ Read `skills/first-tree/progress.md`. It contains a checklist tailored to the current state of the repo. Complete each task:
77
+
78
+ - Fill in `NODE.md` with your organization name, owners, and domains
79
+ - Add project-specific instructions to `AGENT.md` below the framework markers
80
+ - Create member nodes under `members/`
81
+ - Optionally configure agent integration (e.g., Claude Code session hooks)
82
+ - Copy validation workflows from `skills/first-tree/assets/framework/workflows/` to `.github/workflows/`
83
+
84
+ As you complete each task, check it off in `skills/first-tree/progress.md` by changing `- [ ]` to `- [x]`.
85
+
86
+ ### Step 3: Verify
87
+
88
+ ```bash
89
+ context-tree verify
90
+ ```
91
+
92
+ This fails if any items in `skills/first-tree/progress.md` remain unchecked, and runs deterministic checks (valid frontmatter, node structure, member nodes exist).
93
+
94
+ ### Step 4: Design Your Domains
95
+
96
+ Create top-level directories for your organization's primary concerns. Each needs a `NODE.md`:
97
+
98
+ ```
99
+ my-org-tree/
100
+ NODE.md # root — lists all domains
101
+ engineering/
102
+ NODE.md # decisions about architecture, infra, tooling
103
+ product/
104
+ NODE.md # strategy, roadmap, user research
105
+ marketing/
106
+ NODE.md # positioning, campaigns
107
+ members/
108
+ NODE.md # team members and agents
109
+ alice/
110
+ NODE.md # individual member node
111
+ ```
112
+
113
+ ### Step 5: Populate from Existing Work
114
+
115
+ For each domain, extract knowledge from existing repos, docs, and systems:
116
+
117
+ - Decisions and their rationale
118
+ - Cross-domain relationships and dependencies
119
+ - Constraints that aren't obvious from the code
120
+
121
+ The tree doesn't duplicate source code — it captures what connects things and why they were built that way.
122
+
123
+ ---
124
+
125
+ ## CLI Reference
126
+
127
+ | Command | Description |
128
+ |---------|-------------|
129
+ | `context-tree init` | Bootstrap a new tree. Installs the framework skill, renders templates, generates a task list. |
130
+ | `context-tree verify` | Check the installed progress file for unchecked items + run deterministic validation. |
131
+ | `context-tree upgrade` | Refresh the installed framework skill from the currently running `first-tree` npm package and generate follow-up tasks. |
132
+ | `context-tree help onboarding` | Print this onboarding guide. |
133
+
134
+ ---
135
+
136
+ ## Upgrading the Framework
137
+
138
+ When the framework updates:
139
+
140
+ ```bash
141
+ context-tree upgrade
142
+ ```
143
+
144
+ `context-tree upgrade` refreshes `skills/first-tree/` from the
145
+ skill bundled with the currently running `first-tree` npm package, preserves your
146
+ tree content, and generates follow-up tasks in
147
+ `skills/first-tree/progress.md`.
148
+
149
+ If your repo still uses the older `skills/first-tree-cli-framework/` path,
150
+ `context-tree upgrade` will migrate it to `skills/first-tree/` first.
151
+
152
+ To pick up a newer framework release, first run a newer package version, for
153
+ example `npx first-tree@latest upgrade`, or update your global `first-tree`
154
+ install before running `context-tree upgrade`.
155
+
156
+ ---
157
+
158
+ ## Further Reading
159
+
160
+ - `skills/first-tree/references/principles.md` — Core principles with detailed examples
161
+ - `skills/first-tree/references/ownership-and-naming.md` — How nodes are named and owned
162
+ - `AGENT.md` in your tree — The before/during/after workflow for every task
@@ -0,0 +1,94 @@
1
+ ---
2
+ title: "Node Naming and Ownership Model"
3
+ owners: []
4
+ ---
5
+
6
+ # Node Naming and Ownership Model
7
+
8
+ ## Summary
9
+
10
+ This proposal defines how nodes are structured, named, and owned in a Context Tree repository.
11
+
12
+ ## NODE.md as the Parent Node
13
+
14
+ Every folder in the tree **must** contain a `NODE.md` file. This file serves two purposes:
15
+
16
+ 1. **Description** — it is the human- and agent-readable explanation of the domain that folder represents.
17
+ 2. **Ownership** — its frontmatter declares who owns all content within the folder.
18
+
19
+ Example:
20
+
21
+ ```yaml
22
+ # backend/NODE.md
23
+ ---
24
+ title: Backend Architecture
25
+ owners: [alice, bob]
26
+ soft_links: [/infrastructure/deployments]
27
+ ---
28
+
29
+ This subtree covers the backend service architecture, including API design,
30
+ data access patterns, and service-to-service communication.
31
+ ```
32
+
33
+ ## Ownership Rules
34
+
35
+ 1. **NODE.md is the folder-level authority.** Its owners can approve changes to any file within the folder.
36
+
37
+ 2. **Leaf files can declare their own owners.** These owners can approve changes to that specific file. This is additive — `NODE.md` owners retain full authority over all files in the folder.
38
+
39
+ 3. **Multiple owners are allowed.** On both `NODE.md` and leaf files.
40
+
41
+ 4. **Inheritance with override.** Every node must declare an `owners` field. To inherit from the nearest parent `NODE.md` that declares owners, use `owners: []`. Omitting `owners` entirely is not permitted. When a `NODE.md` explicitly declares owners, it fully overrides the parent — the parent folder's owners have no implicit authority over child folders.
42
+
43
+ 5. **Every folder requires a NODE.md.** Creating a subfolder means someone must think about ownership — either declare owners explicitly or inherit from the parent.
44
+
45
+ 6. **Wildcard owner.** `owners: [*]` means anyone can approve changes to that file or folder. When a NODE.md declares `owners: [*]`, anyone can add or edit leaf nodes in that folder without approval. The parent NODE.md owners still retain authority (per rule 1). Use this for open-contribution areas like tips, FAQs, proposals, or community-editable content.
46
+
47
+ ## Example
48
+
49
+ ```
50
+ /backend/
51
+ NODE.md <- owners: [alice]
52
+ auth.md <- owners: [carol]
53
+ storage.md <- owners: [] (inherits from NODE.md)
54
+ tips.md <- owners: [*]
55
+
56
+ /proposals/
57
+ NODE.md <- owners: [*]
58
+ new-feature.md <- owners: [] (inherits from NODE.md)
59
+ ```
60
+
61
+ - **backend/auth.md** — both Alice and Carol can approve changes
62
+ - **backend/storage.md** — only Alice can approve changes (owners: [] inherits from NODE.md)
63
+ - **backend/tips.md** — anyone can approve changes; Alice also retains authority (governed by NODE.md)
64
+ - **backend/NODE.md** — only Alice can approve changes
65
+ - **proposals/new-feature.md** — anyone can approve changes (owners: [] inherits wildcard from NODE.md)
66
+ - **proposals/NODE.md** — anyone can approve changes; parent NODE.md owners still retain authority
67
+
68
+ ## Leaf Files
69
+
70
+ Any `.md` file in a folder other than `NODE.md` is a leaf node. Leaf nodes:
71
+
72
+ - Contain content with optional frontmatter (title, owners, soft_links, etc.)
73
+ - Are always governed by the folder's `NODE.md` ownership in addition to any owners they declare
74
+
75
+ ## CODEOWNERS Generation
76
+
77
+ The CLI can generate a GitHub `CODEOWNERS` file from all `NODE.md` and leaf file frontmatter in the tree. This gives teams PR-level enforcement of the ownership model without custom tooling.
78
+
79
+ Example generated output:
80
+
81
+ ```
82
+ # Auto-generated from Context Tree. Do not edit manually.
83
+ /backend/ @alice
84
+ /backend/auth.md @alice @carol
85
+ /frontend/ @dana @eli
86
+ ```
87
+
88
+ ## Why This Design
89
+
90
+ - **Simple to resolve ownership** — `NODE.md` owners always apply; leaf file owners are additive.
91
+ - **Tree structure enforces clarity** — ownership disagreements at the folder level are resolved by splitting into subtrees.
92
+ - **Folder creation is deliberate** — requiring `NODE.md` with owners prevents folder sprawl.
93
+ - **Flexible without complexity** — leaf files can have specialized owners without introducing override semantics.
94
+ - **Git-native** — everything is a file, versioned, reviewable in PRs.
@@ -0,0 +1,113 @@
1
+ ---
2
+ title: "Tree Principles: Explanation and Examples"
3
+ owners: []
4
+ ---
5
+
6
+ # Tree Principles
7
+
8
+ This document explains the core principles of Context Tree with concrete examples.
9
+
10
+ ---
11
+
12
+ ## 1. Source of truth for decisions, not execution
13
+
14
+ The tree captures the *what* and *why* — strategic choices, cross-domain relationships, constraints. An agent should be able to read the tree and produce a correct approach without consulting source systems.
15
+
16
+ ### Workflow
17
+
18
+ 1. Human says: "Let's add SSO to our product."
19
+ 2. Agent reads relevant tree nodes (e.g., `platform/`, `environment/`).
20
+ 3. Agent writes a top-level design based on tree context alone.
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.
27
+
28
+ ### What belongs in the tree
29
+
30
+ - "Auth flows span four repos: backend issues JWTs, frontend uses Better Auth, browser extension authenticates via OAuth popup through the frontend, desktop app uses a localhost callback server."
31
+ - "We chose MinerU for PDF parsing because it handles academic papers with complex layouts better than alternatives we tested."
32
+ - "We target academic researchers and AI-native teams because they have the highest tolerance for an agent-centric workflow."
33
+ - "Q3 campaign focuses on developer communities because enterprise sales cycle is too long for our current stage."
34
+
35
+ ### What does NOT belong in the tree
36
+
37
+ - The function signature of `retrieval_service.search()` — read the code.
38
+ - The database schema for the `chunk_embeddings` table — read the models.
39
+ - The current ad copy for a campaign — read the campaign tool.
40
+ - The current list of API endpoints — read the route files.
41
+ - The exact interview questions for a role — read the hiring doc.
42
+
43
+ ### The test
44
+
45
+ If an agent needs this information to *decide* on an approach, it belongs in the tree. If the agent only needs it to *execute*, it stays in the source system.
46
+
47
+ ### When inconsistency is found
48
+
49
+ If an agent reads the tree, makes a decision, then discovers a source system contradicts the tree — that's a tree bug. The tree must be corrected before proceeding. This is how the tree stays accurate: every completed task is an opportunity to validate and update it.
50
+
51
+ ---
52
+
53
+ ## 2. Agents are first-class participants
54
+
55
+ The tree is designed to be navigated and updated by agents, not just humans. Domains are organized by concern — what an agent needs to know to act — not by repo, team, or org chart.
56
+
57
+ ### Why organize by concern?
58
+
59
+ An agent working on "add SSO support" doesn't think in terms of repos (backend, frontend, extension, desktop) or org structure (engineering vs. product). It needs all auth context — the why, the how, the cross-domain implications — in one place. Organizing by concern puts that context together.
60
+
61
+ ### Domain placement
62
+
63
+ A feature or decision lives in the domain that owns the primary concern, with soft links to other domains for discoverability:
64
+
65
+ - "Add SSO support" → `platform/` (auth decision), soft links to `environment/` (extension/desktop auth flows)
66
+ - "Support PPTX parsing" → `knowledge/` (ingestion). Clear, single domain.
67
+ - "Q3 developer campaign" → `marketing/` (go-to-market), soft link to product domain (feature positioning)
68
+ - "Agent remembers user preferences" → `agent/` (memory)
69
+ - "Hire a frontend engineer" → `people/hiring/` (role decision), soft link to the team they'd join
70
+
71
+ ### When to create subdomains
72
+
73
+ Start flat. Split when an agent can't scan a NODE.md and quickly determine where to go next. If a domain accumulates enough leaf nodes on a single topic, that topic is ready to become a subdomain.
74
+
75
+ ### Whether something belongs in the tree is a judgment call
76
+
77
+ Not every task needs a tree update. A pure UI bug fix probably doesn't. But don't assume — a "simple" feature like dark mode becomes a tree-worthy decision once it involves auto mode, cross-device persistence, or desktop app coordination. Evaluate per task.
78
+
79
+ ---
80
+
81
+ ## 3. Transparency by default
82
+
83
+ All information in the tree is readable by everyone — humans and agents alike. Writing requires owner approval; reading is open.
84
+
85
+ This means any agent can build full context by traversing the tree. No domain is hidden. The ownership model controls who can *change* the tree, not who can *read* it.
86
+
87
+ ---
88
+
89
+ ## 4. Git-native tree structure
90
+
91
+ Each node is a file; each domain is a directory. The tree is a Git repository.
92
+
93
+ ### Why a tree?
94
+
95
+ A tree structure keeps information organized and navigable. Soft links allow cross-references where needed without the complexity of a full graph. An agent can start at any node and traverse up (broader context) or down (more detail) predictably.
96
+
97
+ ### Why Git?
98
+
99
+ History, ownership, and review follow the same model software engineering has refined for decades. Every change is a commit, every decision is reviewable in a PR, and the full history of how the tree evolved is preserved.
100
+
101
+ ### Examples of good nodes
102
+
103
+ **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.
104
+
105
+ **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.
106
+
107
+ **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.
108
+
109
+ ### Examples of bad nodes
110
+
111
+ - Restating what one source file already says clearly.
112
+ - Documenting stable, well-known patterns (e.g., "we use FastAPI for the backend").
113
+ - Listing things that change frequently without decision implications.
@@ -0,0 +1,94 @@
1
+ # Context Tree Source Map
2
+
3
+ This is the canonical reading index for the single-skill architecture. If a
4
+ maintainer needs information to safely change the framework or thin CLI, that
5
+ information should be discoverable from this file.
6
+
7
+ ## Read First
8
+
9
+ | Path | Why it matters |
10
+ | --- | --- |
11
+ | `SKILL.md` | Trigger conditions, workflow, and validation contract |
12
+ | `references/about.md` | Product framing for what Context Tree is and is not |
13
+ | `references/onboarding.md` | The onboarding narrative that `help onboarding` and `init` surface |
14
+ | `references/principles.md` | Decision-model reference |
15
+ | `references/ownership-and-naming.md` | Ownership contract |
16
+ | `references/upgrade-contract.md` | Installed layout and upgrade semantics |
17
+ | `references/maintainer-architecture.md` | Source-repo architecture and invariants |
18
+ | `references/maintainer-thin-cli.md` | Root shell contract and anti-duplication rules |
19
+ | `references/maintainer-build-and-distribution.md` | Build, pack, and distribution contract |
20
+ | `references/maintainer-testing.md` | Test workflow and maintainer validation expectations |
21
+
22
+ ## Runtime Payload
23
+
24
+ The installed skill payload lives under `assets/framework/`.
25
+
26
+ | Path | Purpose |
27
+ | --- | --- |
28
+ | `assets/framework/manifest.json` | Runtime asset contract |
29
+ | `assets/framework/VERSION` | Version marker for installed payloads |
30
+ | `assets/framework/templates/` | Generated scaffolds |
31
+ | `assets/framework/workflows/` | CI templates |
32
+ | `assets/framework/prompts/` | Review prompt payload |
33
+ | `assets/framework/examples/` | Agent integration examples |
34
+ | `assets/framework/helpers/` | Shipped helper scripts and TypeScript utilities |
35
+ | `progress.md` | Generated in user repos to track unfinished setup or upgrade tasks |
36
+
37
+ ## Framework Engine Surface
38
+
39
+ These skill-owned files implement the framework behavior.
40
+
41
+ | Path | Purpose |
42
+ | --- | --- |
43
+ | `engine/commands/` | Stable command entrypoints that the thin CLI imports |
44
+ | `engine/init.ts` / `engine/verify.ts` / `engine/upgrade.ts` | Command implementations for install, verify, and upgrade |
45
+ | `engine/onboarding.ts` | Canonical onboarding text loader |
46
+ | `engine/repo.ts` | Repo inspection and layout helpers |
47
+ | `engine/rules/` | Situation-aware task generation after `init` |
48
+ | `engine/validators/` | Deterministic tree and member validation |
49
+ | `engine/runtime/asset-loader.ts` | Path constants plus legacy-layout detection |
50
+ | `engine/runtime/installer.ts` | Bundled-package discovery, skill copy, and template-render helpers |
51
+ | `engine/runtime/upgrader.ts` | Packaged-skill version comparison helpers |
52
+ | `engine/runtime/adapters.ts` | Agent-integration path helpers |
53
+
54
+ ## Thin CLI Shell Surface
55
+
56
+ These root files are distribution shell code. They should stay thin and should
57
+ not become the only place important maintainer knowledge lives.
58
+
59
+ | Path | Purpose |
60
+ | --- | --- |
61
+ | `src/cli.ts` | Thin command parser and dispatcher |
62
+ | `src/md.d.ts` | Build-time markdown module typing |
63
+ | `package.json` | Package metadata, import aliases, and scripts |
64
+ | `tsconfig.json` | TypeScript compile boundaries |
65
+ | `tsdown.config.ts` | Build entry and asset handling |
66
+ | `vitest.config.ts` | Unit-test entrypoints |
67
+ | `.github/workflows/ci.yml` | Thin CI shell |
68
+ | `README.md` | Thin distribution overview |
69
+ | `AGENT.md` | Thin maintainer pointer for agent sessions |
70
+
71
+ ## Validation
72
+
73
+ | Path | Coverage |
74
+ | --- | --- |
75
+ | `tests/init.test.ts` | Init scaffolding behavior |
76
+ | `tests/verify.test.ts` | Verification and progress gating |
77
+ | `tests/rules.test.ts` | Task generation text |
78
+ | `tests/asset-loader.test.ts` | Layout detection and path precedence |
79
+ | `tests/generate-codeowners.test.ts` | Ownership helper behavior |
80
+ | `tests/run-review.test.ts` | Review helper behavior |
81
+ | `tests/skill-artifacts.test.ts` | Skill export and documentation integrity |
82
+ | `tests/thin-cli.test.ts` | Thin CLI entrypoint smoke coverage |
83
+ | `tests/upgrade.test.ts` | Installed-skill upgrade behavior |
84
+
85
+ ## Compatibility Notes
86
+
87
+ - The source repo intentionally contains no root `.context-tree/`, `docs/`,
88
+ mirror skills, or bundled repo snapshot.
89
+ - Legacy `.context-tree/...` paths still matter only for migrating existing
90
+ user repos; the compatibility logic lives in
91
+ `engine/runtime/asset-loader.ts` and `engine/upgrade.ts`.
92
+ - Root `README.md` and `AGENT.md` are intentionally brief. Important
93
+ information must live in the skill references instead.
94
+ - If you change `references/` or `assets/framework/`, run `pnpm validate:skill`.