@first-tree-ai/context-tree 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +91 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +95 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +3 -0
- package/dist/schemas-BJXFTfxw.d.mts +359 -0
- package/dist/schemas-D0Qt1bWc.mjs +207 -0
- package/dist/schemas.d.mts +2 -0
- package/dist/schemas.mjs +2 -0
- package/dist/src-Ce9BtETD.mjs +794 -0
- package/docs/specification.md +74 -0
- package/examples/basic/NODE.md +11 -0
- package/examples/basic/SCOPE.md +7 -0
- package/examples/basic/members/NODE.md +6 -0
- package/examples/basic/members/example-owner/NODE.md +10 -0
- package/examples/basic/systems/NODE.md +7 -0
- package/examples/basic/systems/runtime.md +16 -0
- package/package.json +75 -8
- package/policy/context-tree-policy.md +129 -0
- package/skills/context-tree-init/SKILL.md +43 -0
- package/skills/context-tree-init/agents/openai.yaml +4 -0
- package/skills/context-tree-read/SKILL.md +43 -0
- package/skills/context-tree-read/agents/openai.yaml +4 -0
- package/skills/context-tree-write/SKILL.md +59 -0
- package/skills/context-tree-write/agents/openai.yaml +4 -0
- package/templates/member-node.md +13 -0
- package/templates/members-index.md +9 -0
- package/templates/root-node.md +15 -0
- package/templates/scope.md +5 -0
- package/templates/validate-context-tree.yml +16 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Context Tree Format Specification
|
|
2
|
+
|
|
3
|
+
## Repository and root
|
|
4
|
+
|
|
5
|
+
A shared Context Tree lives in a `github.com` repository identified as
|
|
6
|
+
`OWNER/REPO`. GitHub commit SHAs identify exact shared snapshots. The package
|
|
7
|
+
still operates on local clones and worktrees because validation and editing are
|
|
8
|
+
filesystem operations.
|
|
9
|
+
|
|
10
|
+
The tree root is a real directory containing `NODE.md`. Optional `SCOPE.md`
|
|
11
|
+
must be a regular UTF-8 file with schema-version-1 frontmatter and non-empty
|
|
12
|
+
prose:
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
---
|
|
16
|
+
schemaVersion: 1
|
|
17
|
+
relatedRepositories:
|
|
18
|
+
- https://github.com/acme/service.git
|
|
19
|
+
---
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`relatedRepositories` remains provider-neutral and accepts at most 64
|
|
23
|
+
credential-free HTTP(S), `ssh://`, or scp-style SSH references. It describes
|
|
24
|
+
related source repositories; it does not identify the Context Tree repository.
|
|
25
|
+
|
|
26
|
+
## Nodes and content classes
|
|
27
|
+
|
|
28
|
+
The root requires `NODE.md`. A semantic directory represented as a node also
|
|
29
|
+
contains `NODE.md`; organizational directories containing Markdown leaves need
|
|
30
|
+
not. Normal nodes require a non-empty `title` and `owners` array. Optional
|
|
31
|
+
`description` is non-empty prose, and optional `soft_links` contains
|
|
32
|
+
tree-root-relative Markdown files or node directories.
|
|
33
|
+
|
|
34
|
+
- `normal`: root and durable domain decisions.
|
|
35
|
+
- `archive-supporting`: evidence beneath `raw-context/`.
|
|
36
|
+
- `member`: ownership and routing beneath `members/`.
|
|
37
|
+
- `repo-infra`: dot paths, generated output, instructions, build, and CI files.
|
|
38
|
+
|
|
39
|
+
Normal content must not depend on archive-supporting content. Symlinks fail
|
|
40
|
+
closed: they may not escape the tree, cross content-class boundaries, or stand
|
|
41
|
+
in for domain directories. Reads default to normal content. Glob patterns are
|
|
42
|
+
case-sensitive and segment-local.
|
|
43
|
+
|
|
44
|
+
`members/NODE.md` is the member index. Every direct member directory requires a
|
|
45
|
+
`NODE.md` with title, owners, type (`human` or `agent`), role, and domains.
|
|
46
|
+
|
|
47
|
+
## Public contracts
|
|
48
|
+
|
|
49
|
+
CLI JSON uses `schemaVersion: 1`. Exported strict Zod schemas are the source of
|
|
50
|
+
truth for library and CLI wire contracts. Unknown output properties are
|
|
51
|
+
rejected. Successful command results and runtime or argument failures emit one
|
|
52
|
+
JSON object on stdout; help and version output remain plain text. An invalid
|
|
53
|
+
`verify` report is still emitted and the command exits with status 1.
|
|
54
|
+
|
|
55
|
+
`policy` returns `content` and `schemaVersion`. `read` returns the root, target,
|
|
56
|
+
schema version, and selected entries. `verify` returns the root, schema version,
|
|
57
|
+
validity, findings, and content-class counts. None includes a tree digest or
|
|
58
|
+
per-entry digest. The Git commit SHA is recorded by the surrounding host Git
|
|
59
|
+
workflow rather than computed by the core.
|
|
60
|
+
|
|
61
|
+
## Lifecycle
|
|
62
|
+
|
|
63
|
+
Scaffolding always creates a validation workflow pinned to the package version
|
|
64
|
+
that generated it. New repositories always initialize and publish `main`,
|
|
65
|
+
regardless of the user's Git configuration; the generated workflow filters
|
|
66
|
+
pushes to `main`. Hosted reads require an explicit `OWNER/REPO` and branch, a
|
|
67
|
+
clean matching checkout, fast-forward refresh, validation, and a reported
|
|
68
|
+
commit SHA. Explicitly authorized stale reads are labeled and remain read-only.
|
|
69
|
+
|
|
70
|
+
Every write starts in an isolated worktree at a freshly fetched base commit.
|
|
71
|
+
The base and final tree must validate; all edits are direct, necessary Markdown
|
|
72
|
+
changes; the full diff is reviewed; publication uses a non-force task-branch
|
|
73
|
+
push and GitHub PR. An invalid base permits only an explicitly requested,
|
|
74
|
+
validator-scoped repair PR. No workflow merges automatically.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Runtime baseline"
|
|
3
|
+
owners: [example-owner]
|
|
4
|
+
soft_links:
|
|
5
|
+
- systems
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Runtime baseline
|
|
9
|
+
|
|
10
|
+
## Decision
|
|
11
|
+
|
|
12
|
+
Portable tooling runs on Node.js 22.13 or newer.
|
|
13
|
+
|
|
14
|
+
## Rationale
|
|
15
|
+
|
|
16
|
+
A modern baseline keeps filesystem and module behavior consistent.
|
package/package.json
CHANGED
|
@@ -1,13 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@first-tree-ai/context-tree",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Portable Context Tree schemas, tooling, and agent skills.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/first-tree-ai/context-tree.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/first-tree-ai/context-tree#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/first-tree-ai/context-tree/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agents",
|
|
17
|
+
"context-tree",
|
|
18
|
+
"knowledge",
|
|
19
|
+
"memory"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22.13.0"
|
|
23
|
+
},
|
|
24
|
+
"packageManager": "pnpm@10.12.1",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"bin": {
|
|
30
|
+
"context-tree": "./dist/cli/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.mts",
|
|
35
|
+
"import": "./dist/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./schemas": {
|
|
38
|
+
"types": "./dist/schemas.d.mts",
|
|
39
|
+
"import": "./dist/schemas.mjs"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"docs",
|
|
45
|
+
"examples",
|
|
46
|
+
"skills",
|
|
47
|
+
"policy",
|
|
48
|
+
"templates",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
6
52
|
"scripts": {
|
|
7
|
-
"
|
|
53
|
+
"build": "tsdown src/index.ts src/schemas.ts src/cli/index.ts --format esm --dts",
|
|
54
|
+
"check": "biome check .",
|
|
55
|
+
"format": "biome check --write .",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"test": "pnpm build && vitest run",
|
|
58
|
+
"validate:skills": "vitest run tests/skills.test.ts",
|
|
59
|
+
"check:package": "pnpm build && publint && attw --pack . --profile esm-only && pnpm package:e2e",
|
|
60
|
+
"package:e2e": "node scripts/package-e2e.mjs",
|
|
61
|
+
"check:names": "vitest run tests/names.test.ts",
|
|
62
|
+
"prepack": "pnpm build && pnpm validate:skills"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"commander": "^15.0.0",
|
|
66
|
+
"gray-matter": "^4.0.3",
|
|
67
|
+
"mdast-util-from-markdown": "^2.0.3",
|
|
68
|
+
"yaml": "^2.8.3",
|
|
69
|
+
"zod": "^4.0.0"
|
|
8
70
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@biomejs/biome": "^2.4.0",
|
|
73
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
74
|
+
"@types/node": "^22.16.0",
|
|
75
|
+
"publint": "^0.3.16",
|
|
76
|
+
"tsdown": "^0.21.4",
|
|
77
|
+
"typescript": "^5.8.0",
|
|
78
|
+
"vitest": "^3.2.0"
|
|
79
|
+
}
|
|
13
80
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
## Context Tree Policy
|
|
2
|
+
|
|
3
|
+
### What A Context Tree Is
|
|
4
|
+
|
|
5
|
+
The Context Tree is durable context, not a source-code mirror, wiki dump, or
|
|
6
|
+
task log. It records current decisions, constraints, ownership, and
|
|
7
|
+
cross-domain relationships with enough rationale that a future reader does
|
|
8
|
+
not have to reconstruct them from GitHub PRs, chat logs, or tribal knowledge.
|
|
9
|
+
|
|
10
|
+
### Source-System Boundary
|
|
11
|
+
|
|
12
|
+
The tree records **what was decided and why**; source repos record **how it is
|
|
13
|
+
implemented**. If information would rot when the next refactor lands, it does
|
|
14
|
+
not belong in the tree.
|
|
15
|
+
|
|
16
|
+
| Belongs in the tree | Stays in the source repo |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| A choice between alternatives and why the alternatives lost | Function signatures, types, class hierarchies |
|
|
19
|
+
| A constraint that shapes future implementation across repos | Step-by-step implementation walkthroughs |
|
|
20
|
+
| An ownership change or clarified review path | API request / response shapes |
|
|
21
|
+
| A current constraint that resulted from a deprecation | Test fixtures, snapshot data, build / CI config |
|
|
22
|
+
| A new relationship between two domains | Bug fixes that do not change a public contract |
|
|
23
|
+
| Rationale that would not be obvious from the diff alone | Refactors that preserve behaviour |
|
|
24
|
+
| A decision as it stands today: current state + present-tense rationale | Historical narrative of how we got here |
|
|
25
|
+
|
|
26
|
+
### Content Classes And Authority
|
|
27
|
+
|
|
28
|
+
- **Normal content** — root/domain `NODE.md` and regular domain leaves. It states current durable truth; when a decision changes, rewrite or remove old claims.
|
|
29
|
+
- **Archive/supporting content** — proposals, meetings, explorations, and raw material such as `raw-context/`. It is evidence, not canonical truth: read it only when asked, when the source is archive/proposal material, or when the task needs archive context. Normal content must not require this class.
|
|
30
|
+
- **Member content** — responsibility, ownership, and review scope such as `members/<id>/NODE.md`. Use it to route or validate *Who*, not as a substitute for normal decision/constraint nodes.
|
|
31
|
+
|
|
32
|
+
### Code vs Tree Drift Authority
|
|
33
|
+
|
|
34
|
+
Normal tree content is authoritative for durable context, but not a blind
|
|
35
|
+
override for observed source reality. By default, **code is the ground truth**
|
|
36
|
+
when the tree and code disagree: treat the tree as drifted and update the tree
|
|
37
|
+
from source-backed evidence. `decisionLocksCode: true` reverses that default
|
|
38
|
+
for one node: the tree wins, and code drift escalates to a human owner instead
|
|
39
|
+
of being silently fixed or ignored. Set or rely on that flag only on explicit
|
|
40
|
+
user or host-framework authorization.
|
|
41
|
+
|
|
42
|
+
### The Double Test
|
|
43
|
+
|
|
44
|
+
Before writing, apply both questions to every candidate fact:
|
|
45
|
+
|
|
46
|
+
1. **Decision test.** Does this source establish or change something a future
|
|
47
|
+
agent must respect when making cross-domain choices?
|
|
48
|
+
2. **Durability test.** If the triggering commit or GitHub PR were rewritten, would
|
|
49
|
+
the decision still stand?
|
|
50
|
+
|
|
51
|
+
The candidate belongs in the tree only when both answers are yes. Failing the
|
|
52
|
+
decision test means the source is implementation detail; failing the
|
|
53
|
+
durability test means the source captures how something was done this time,
|
|
54
|
+
not what was decided.
|
|
55
|
+
|
|
56
|
+
### Content Model: What / Why / Who
|
|
57
|
+
|
|
58
|
+
- **What** — the decision, design choice, or constraint as it stands today.
|
|
59
|
+
Write the durable claim, not implementation detail or a timeline of prior
|
|
60
|
+
states.
|
|
61
|
+
- **Why** — the surviving rationale: constraints that won, alternatives that
|
|
62
|
+
lost, and design course-corrections translated into present-tense reasoning.
|
|
63
|
+
Capture **why**, not only what. Design-phase chat, review, and meeting
|
|
64
|
+
threads are where this rationale is produced: somebody flags a constraint,
|
|
65
|
+
a first proposal is corrected, or an option conflicts with another domain.
|
|
66
|
+
The node records the surviving constraint and reasoning from those moments,
|
|
67
|
+
not the chronology. A node without rationale is a fact, not a decision record.
|
|
68
|
+
- **Who** — ownership, carried by `owners` frontmatter and
|
|
69
|
+
member content. Do not put ownership in the body, and do not unilaterally
|
|
70
|
+
edit `owners`.
|
|
71
|
+
|
|
72
|
+
### Add vs Edit
|
|
73
|
+
|
|
74
|
+
Default to editing an existing node. A node earns its existence by being
|
|
75
|
+
independently findable, ownable, or linkable; otherwise edit the existing
|
|
76
|
+
node. Add a leaf only when all three hold:
|
|
77
|
+
|
|
78
|
+
1. **Distinct identity** — a noun-phrase title that does not overlap any
|
|
79
|
+
sibling.
|
|
80
|
+
2. **Distinct anchor** — at least one of: different `owners`; another domain
|
|
81
|
+
would `soft_links` to this specific decision; or the source naturally has
|
|
82
|
+
its own Decision / Rationale / Constraints that cannot co-live with an
|
|
83
|
+
existing leaf.
|
|
84
|
+
3. **Passes the Double Test.**
|
|
85
|
+
|
|
86
|
+
Add a directory only when at least three cohesive leaves share an axis. New
|
|
87
|
+
top-level domains require explicit user or host-framework authorization. When
|
|
88
|
+
a decision touches two domains, keep canonical content in the more specific
|
|
89
|
+
domain and link from the broader one with normal-to-normal `soft_links` or
|
|
90
|
+
short prose.
|
|
91
|
+
|
|
92
|
+
### Node Shape
|
|
93
|
+
|
|
94
|
+
Required frontmatter:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
---
|
|
98
|
+
title: "Short noun phrase"
|
|
99
|
+
owners: [alice, bob]
|
|
100
|
+
---
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Useful optional frontmatter: `description`, `soft_links`,
|
|
104
|
+
`lastReviewed`, and `decisionLocksCode`. `lastReviewed` records an actual
|
|
105
|
+
owner review; update it only when that review is the concrete source for a
|
|
106
|
+
source-backed write. Use `owners: ["*"]` only when the user or host framework
|
|
107
|
+
explicitly opens ownership to everyone. Metadata supports scanning, routing,
|
|
108
|
+
and responsibility.
|
|
109
|
+
|
|
110
|
+
Prefer body sections in this order, omitting any that do not apply:
|
|
111
|
+
`Decision`, `Rationale`, `Constraints`, `Cross-Domain`. There is no
|
|
112
|
+
`Source`, `Provenance`, or `Shipped-in` section; PR, commit, and issue delivery
|
|
113
|
+
history lives in Git history and GitHub PR descriptions, not node prose.
|
|
114
|
+
|
|
115
|
+
### Write / Verify / GitHub PR Discipline
|
|
116
|
+
|
|
117
|
+
Default to not writing: a missing node is a question, a noisy node is a trap.
|
|
118
|
+
Source-backed writes require a concrete source artifact and surrounding context
|
|
119
|
+
(source, target, parent, relevant `soft_links`, ownership-adjacent member
|
|
120
|
+
content) unless already known. Actionable future work does not live in normal
|
|
121
|
+
tree content; put it in an issue, source artifact, or authorized decision
|
|
122
|
+
instead. `context-tree verify` must pass before any tree commit. Keep tree prose
|
|
123
|
+
current-state: no timeline, provenance, PR references, or implementation detail.
|
|
124
|
+
Every write starts from a freshly fetched base commit in an isolated clean
|
|
125
|
+
worktree, changes only necessary Markdown, passes verification, and is published
|
|
126
|
+
with a non-force task-branch push and GitHub PR. Never merge automatically. A
|
|
127
|
+
source-backed tree PR stays scoped to one source artifact so owner review and
|
|
128
|
+
rollback stay precise. An invalid base blocks semantic changes; only an explicit
|
|
129
|
+
repair request may produce a repair-only PR limited to validator findings.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context-tree-init
|
|
3
|
+
description: Create and publish a new private GitHub-backed Context Tree from an explicit repository identity.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: Requires Node.js 22.13+ and the context-tree CLI JSON schema version 1.
|
|
6
|
+
metadata:
|
|
7
|
+
author: first-tree-ai
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Context Tree Init
|
|
12
|
+
|
|
13
|
+
Create only. Require the user to explicitly provide a GitHub `OWNER/REPO`, empty
|
|
14
|
+
local destination, tree title, and initial owner. Every new repository uses
|
|
15
|
+
`main`; do not accept a configurable branch. Accept only
|
|
16
|
+
`github.com`; GitHub Enterprise Server and other forges are unsupported.
|
|
17
|
+
A Git remote proves identity, not user authority.
|
|
18
|
+
|
|
19
|
+
First run `context-tree --version`. If the command is missing, stop and tell the
|
|
20
|
+
user to run `npm install --global @first-tree-ai/context-tree`. Never install a
|
|
21
|
+
package automatically.
|
|
22
|
+
|
|
23
|
+
## Preflight
|
|
24
|
+
|
|
25
|
+
Before creating a directory, initializing Git, committing, or changing GitHub:
|
|
26
|
+
|
|
27
|
+
1. Run `context-tree policy` and require `schemaVersion: 1`.
|
|
28
|
+
2. Validate the explicit `OWNER/REPO`, destination, title, and owner. Do not accept a URL in place of `OWNER/REPO`; this avoids credential-bearing repository URLs entirely.
|
|
29
|
+
3. Use the host's existing `git` and `gh` credentials with non-interactive commands. Run `gh auth status` and stop if GitHub access is unavailable. Never request, store, or print credentials.
|
|
30
|
+
4. Confirm that the destination is absent or empty and that `gh repo view "OWNER/REPO"` establishes the target repository does not exist.
|
|
31
|
+
|
|
32
|
+
## Create and publish
|
|
33
|
+
|
|
34
|
+
1. Run `context-tree init --repository "OWNER/REPO" --tree-path "<destination>" --title "<title>" --owner "<owner>"`. The scaffold always contains the packaged GitHub Actions workflow pinned to the installed package version and filtered to `main`.
|
|
35
|
+
2. Run `context-tree verify --tree-path "<destination>"` and require a valid result.
|
|
36
|
+
3. Run `git init --initial-branch=main`, add only the scaffolded files, inspect the complete staged diff, and commit. Do not rely on `init.defaultBranch` or other user Git configuration.
|
|
37
|
+
4. Run `gh repo create "OWNER/REPO" --private --source "<destination>" --remote origin --push`. Create a public repository only when the user explicitly requests it; publish `main` only.
|
|
38
|
+
5. Verify that normalized `origin` matches `OWNER/REPO`, the checked-out branch is `main`, the local commit SHA equals `refs/remotes/origin/main`, and `refs/heads/main` exists remotely.
|
|
39
|
+
|
|
40
|
+
If creation or push has an uncertain result, inspect `gh repo view`, the local
|
|
41
|
+
remote, and `git ls-remote` before retrying only the missing operation. Never
|
|
42
|
+
delete a GitHub repository or overwrite remote history. Stop if the target
|
|
43
|
+
repository already exists or the destination is not absent or empty.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context-tree-read
|
|
3
|
+
description: Read task-scoped content from an explicitly authorized GitHub Context Tree checkout.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: Requires Node.js 22.13+ and the context-tree CLI JSON schema version 1.
|
|
6
|
+
metadata:
|
|
7
|
+
author: first-tree-ai
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Context Tree Read
|
|
12
|
+
|
|
13
|
+
Require an explicitly authorized GitHub `OWNER/REPO`, branch, and local
|
|
14
|
+
destination. Never infer authorization from the current directory, a remote, or
|
|
15
|
+
workspace files. A Git remote proves identity, not user authority.
|
|
16
|
+
|
|
17
|
+
First run `context-tree --version`. If the command is missing, stop and tell the
|
|
18
|
+
user to run `npm install --global @first-tree-ai/context-tree`. Never install a
|
|
19
|
+
package automatically.
|
|
20
|
+
|
|
21
|
+
## Checkout and freshness
|
|
22
|
+
|
|
23
|
+
1. Run `context-tree policy` and require `schemaVersion: 1`.
|
|
24
|
+
2. Reject repository URLs as identity input; require canonical `OWNER/REPO`, so credential-bearing URLs cannot enter commands or logs.
|
|
25
|
+
3. If the checkout is absent, clone the explicit branch from `https://github.com/OWNER/REPO.git` with host Git credentials and `GIT_TERMINAL_PROMPT=0`.
|
|
26
|
+
4. Before reusing a checkout, require a clean worktree with `git status --porcelain`, then compare its normalized `origin` and current branch with the explicit inputs. Reject mismatches, detached HEAD, symlinks at the checkout root, and implicit repository discovery.
|
|
27
|
+
5. Run `git pull --ff-only origin "<branch>"`, then record `git rev-parse HEAD`. Do not merge, reset, switch branches, or clean files.
|
|
28
|
+
|
|
29
|
+
If GitHub is unavailable, stop by default. Continue only when the user
|
|
30
|
+
explicitly authorizes a stale read of this already verified identity and branch.
|
|
31
|
+
Require the worktree to remain clean, label every result `STALE`, report the
|
|
32
|
+
refresh failure, and report the exact local commit SHA. A stale checkout is
|
|
33
|
+
read-only and must never be reused as the starting point for a write.
|
|
34
|
+
|
|
35
|
+
## Scoped read
|
|
36
|
+
|
|
37
|
+
1. Run `context-tree read --help`, then `context-tree verify --tree-path "<root>"`.
|
|
38
|
+
2. If verification fails, report the mechanical findings and stop without reading semantic content.
|
|
39
|
+
3. Select narrowly with `context-tree read --tree-path "<root>" [path] --pattern "<glob>" --depth <n> --content`.
|
|
40
|
+
4. Start with the root and relevant parents, then matched leaves and normal `soft_links` targets. Request member or archive-supporting classes only when required.
|
|
41
|
+
5. Apply the packaged policy when code and tree content conflict, and include the recorded Git commit SHA with the result.
|
|
42
|
+
|
|
43
|
+
The CLI performs no Git or GitHub operations. Keep the result task-scoped.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context-tree-write
|
|
3
|
+
description: Publish a source-backed Context Tree change through an isolated GitHub pull request.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: Requires Node.js 22.13+ and the context-tree CLI JSON schema version 1.
|
|
6
|
+
metadata:
|
|
7
|
+
author: first-tree-ai
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Context Tree Write
|
|
12
|
+
|
|
13
|
+
Require a concrete source artifact plus an explicitly authorized GitHub
|
|
14
|
+
`OWNER/REPO` and base branch. Accept a PR, issue, commit discussion, decision
|
|
15
|
+
document, meeting note, or pasted source. Without concrete evidence, stop.
|
|
16
|
+
A Git remote proves identity, not user authority.
|
|
17
|
+
|
|
18
|
+
First run `context-tree --version`. If the command is missing, stop and tell the
|
|
19
|
+
user to run `npm install --global @first-tree-ai/context-tree`. Never install a
|
|
20
|
+
package automatically.
|
|
21
|
+
|
|
22
|
+
Apply both durability tests: the source must establish something future agents
|
|
23
|
+
must respect, and it must remain true if the triggering implementation is
|
|
24
|
+
rewritten. Otherwise leave the tree unchanged.
|
|
25
|
+
|
|
26
|
+
## Fresh isolated base
|
|
27
|
+
|
|
28
|
+
1. Run `context-tree policy` and require `schemaVersion: 1`.
|
|
29
|
+
2. Require canonical `OWNER/REPO`, not a repository URL, and use existing host `git` and `gh` credentials with `GIT_TERMINAL_PROMPT=0`.
|
|
30
|
+
3. Verify any management checkout's normalized `origin`. Fetch the explicit base branch and resolve `refs/remotes/origin/<base>` to its exact Git commit SHA. A stale checkout may not become a write.
|
|
31
|
+
4. Create a unique task branch and agent-owned isolated worktree at that exact fetched commit. Never edit the shared checkout.
|
|
32
|
+
5. Require `git status --porcelain` to be empty and run `context-tree verify --tree-path "<root>"` before reading semantic content.
|
|
33
|
+
|
|
34
|
+
If the base is invalid, block all semantic edits. Continue only for an explicit
|
|
35
|
+
repair request, and make a repair-only PR whose changes are limited to exact
|
|
36
|
+
validator findings supported by existing authorized evidence. Never invent
|
|
37
|
+
owners, decisions, structure, or business content. The complete repaired tree
|
|
38
|
+
must pass verification before publication.
|
|
39
|
+
|
|
40
|
+
## Source-backed edit
|
|
41
|
+
|
|
42
|
+
1. Read the source and the minimum target, parent, relationship, and ownership context with `context-tree read --content`.
|
|
43
|
+
2. Prefer an existing node. Require explicit authority for ownership changes, locked decisions, or a new top-level domain.
|
|
44
|
+
3. Edit only the necessary regular, non-symlink Markdown files directly in the isolated worktree. Preserve path containment and never replace or traverse symlinks.
|
|
45
|
+
4. Run `context-tree verify --tree-path "<root>"` on the final tree.
|
|
46
|
+
5. Inspect the complete `git diff`, including every changed path and full patch. Stop if it contains anything outside the authorized Context Tree change.
|
|
47
|
+
|
|
48
|
+
## GitHub publication
|
|
49
|
+
|
|
50
|
+
1. Run repository-prescribed checks relevant to the changed tree.
|
|
51
|
+
2. Commit the verified diff on the task branch.
|
|
52
|
+
3. Push with `git push --set-upstream origin "<task-branch>"`. Use a non-force push; never force push or push directly to the base branch.
|
|
53
|
+
4. Open a GitHub PR targeting the explicit base with `gh pr create --base "<base>" --head "<task-branch>"`. Never merge automatically and never request reviewers automatically.
|
|
54
|
+
|
|
55
|
+
If push or PR creation has an unknown result, inspect the remote branch and
|
|
56
|
+
existing PRs before retrying only a missing operation. Leave conflicts and
|
|
57
|
+
outdated-branch handling to GitHub. Keep one coherent source per change and
|
|
58
|
+
remove an agent-owned worktree only when it is clean; never remove a pre-existing
|
|
59
|
+
or dirty worktree.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: {{ownerJson}}
|
|
3
|
+
description: "Initial Context Tree owner."
|
|
4
|
+
owners: [{{ownerJson}}]
|
|
5
|
+
type: human
|
|
6
|
+
role: "Context Tree owner"
|
|
7
|
+
domains:
|
|
8
|
+
- "context-tree"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# {{owner}}
|
|
12
|
+
|
|
13
|
+
Owns the initial Context Tree structure and reviews changes until responsibility is delegated explicitly.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: {{titleJson}}
|
|
3
|
+
description: "Durable decisions, constraints, ownership, and cross-domain relationships."
|
|
4
|
+
owners: [{{ownerJson}}]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# {{title}}
|
|
8
|
+
|
|
9
|
+
## Decision
|
|
10
|
+
|
|
11
|
+
This Context Tree is the canonical home for durable context within its declared scope.
|
|
12
|
+
|
|
13
|
+
## Rationale
|
|
14
|
+
|
|
15
|
+
Keeping current decisions and their surviving rationale together lets future readers act without reconstructing history.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Validate Context Tree
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: ["main"]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
validate:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
- name: Validate Context Tree
|
|
16
|
+
run: npx --yes @first-tree-ai/context-tree@{{packageVersion}} verify --tree-path .
|