first-tree 0.0.7 → 0.0.8
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 +11 -4
- package/dist/bootstrap-YRjfHJp7.js +28 -0
- package/dist/cli.js +10 -4
- package/dist/{help-BRO4mTG6.js → help-CDfaFrzl.js} +1 -1
- package/dist/{init-BSs0ILp_.js → init-DjSVkUeR.js} +11 -6
- package/dist/onboarding-BiHx2jy5.js +10 -0
- package/dist/onboarding-Ce033qaW.js +2 -0
- package/dist/publish-D0crNDjz.js +504 -0
- package/dist/{repo-0z7N9r17.js → repo-BeVpMoHi.js} +2 -1
- package/dist/{source-integration-C2iiN4k_.js → source-integration-DMxnl8Dw.js} +1 -1
- package/dist/{upgrade-DvBdbph3.js → upgrade-B_NTlNrx.js} +2 -2
- package/dist/{verify-DRt5mCqO.js → verify-Chhm1vOF.js} +1 -1
- package/package.json +1 -1
- package/skills/first-tree/SKILL.md +14 -5
- package/skills/first-tree/assets/framework/VERSION +1 -1
- package/skills/first-tree/engine/commands/publish.ts +5 -0
- package/skills/first-tree/engine/init.ts +11 -5
- package/skills/first-tree/engine/publish.ts +807 -0
- package/skills/first-tree/engine/runtime/asset-loader.ts +1 -0
- package/skills/first-tree/engine/runtime/bootstrap.ts +40 -0
- package/skills/first-tree/references/maintainer-build-and-distribution.md +3 -0
- package/skills/first-tree/references/maintainer-thin-cli.md +1 -1
- package/skills/first-tree/references/onboarding.md +12 -9
- package/skills/first-tree/references/source-map.md +3 -1
- package/skills/first-tree/references/source-workspace-installation.md +13 -13
- package/skills/first-tree/references/upgrade-contract.md +11 -0
- package/skills/first-tree/tests/init.test.ts +19 -0
- package/skills/first-tree/tests/publish.test.ts +248 -0
- package/skills/first-tree/tests/skill-artifacts.test.ts +12 -0
- package/skills/first-tree/tests/thin-cli.test.ts +1 -0
- package/dist/onboarding-BS8btkG4.js +0 -2
- package/dist/onboarding-D3hnxIie.js +0 -10
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ sibling dedicated tree repo.
|
|
|
43
43
|
cd my-app
|
|
44
44
|
npx first-tree init
|
|
45
45
|
cd ../my-app-context
|
|
46
|
+
context-tree publish --open-pr
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
If you already created a dedicated tree repo yourself, initialize it in place:
|
|
@@ -66,10 +67,13 @@ that repo itself to become the Context Tree.
|
|
|
66
67
|
- Never create `NODE.md`, `members/`, or tree-scoped `AGENTS.md` in the
|
|
67
68
|
source/workspace repo. Those files live only in the dedicated `*-context`
|
|
68
69
|
repo.
|
|
69
|
-
- After
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
automatically.
|
|
70
|
+
- After drafting the initial tree version, run `context-tree publish --open-pr`
|
|
71
|
+
from the dedicated tree repo. That command creates or reuses the GitHub
|
|
72
|
+
`*-context` repo, adds it back to the source/workspace repo as a git
|
|
73
|
+
submodule, and opens a PR instead of merging automatically.
|
|
74
|
+
- After `context-tree publish` succeeds, treat the source repo's submodule
|
|
75
|
+
checkout as the canonical local working copy for the tree. The temporary
|
|
76
|
+
sibling bootstrap checkout can be deleted when you no longer need it.
|
|
73
77
|
- `context-tree verify` checks both the progress checklist and deterministic
|
|
74
78
|
tree validation. It is expected to fail until the required onboarding tasks
|
|
75
79
|
are complete.
|
|
@@ -89,6 +93,7 @@ runtime.
|
|
|
89
93
|
| Command | What it does |
|
|
90
94
|
| --- | --- |
|
|
91
95
|
| `context-tree init` | Install source/workspace integration locally and create or refresh a dedicated context tree repo; use `--here` only when you are already inside the dedicated tree repo |
|
|
96
|
+
| `context-tree publish` | Publish a dedicated tree repo to GitHub, add it back to the source/workspace repo as a submodule, and optionally open the source-repo PR |
|
|
92
97
|
| `context-tree verify` | Run verification checks against the current tree |
|
|
93
98
|
| `context-tree upgrade` | Refresh the installed skill from the current `first-tree` npm package; in a source/workspace repo it updates only local integration, while tree repos also get follow-up tasks |
|
|
94
99
|
| `context-tree help onboarding` | Print the onboarding guide |
|
|
@@ -112,6 +117,8 @@ runtime.
|
|
|
112
117
|
## Runtime And Maintainer Prerequisites
|
|
113
118
|
|
|
114
119
|
- User trees: the onboarding guide targets Node.js 18+.
|
|
120
|
+
- `context-tree publish` also expects GitHub CLI (`gh`) to be installed and
|
|
121
|
+
authenticated against GitHub.
|
|
115
122
|
- This source repo: use Node.js 22 and pnpm 10 to match CI and the checked-in
|
|
116
123
|
package manager version.
|
|
117
124
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { a as BOOTSTRAP_STATE } from "./repo-BeVpMoHi.js";
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
//#region skills/first-tree/engine/runtime/bootstrap.ts
|
|
5
|
+
function bootstrapStatePath(root) {
|
|
6
|
+
return join(root, BOOTSTRAP_STATE);
|
|
7
|
+
}
|
|
8
|
+
function readBootstrapState(root) {
|
|
9
|
+
const path = bootstrapStatePath(root);
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
12
|
+
if (typeof parsed.sourceRepoName !== "string" || typeof parsed.sourceRepoPath !== "string" || typeof parsed.treeRepoName !== "string") return null;
|
|
13
|
+
return {
|
|
14
|
+
sourceRepoName: parsed.sourceRepoName,
|
|
15
|
+
sourceRepoPath: parsed.sourceRepoPath,
|
|
16
|
+
treeRepoName: parsed.treeRepoName
|
|
17
|
+
};
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function writeBootstrapState(root, state) {
|
|
23
|
+
const path = bootstrapStatePath(root);
|
|
24
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
25
|
+
writeFileSync(path, `${JSON.stringify(state, null, 2)}\n`);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { writeBootstrapState as n, readBootstrapState as t };
|
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ const USAGE = `usage: context-tree <command>
|
|
|
8
8
|
|
|
9
9
|
Commands:
|
|
10
10
|
init Install source/workspace integration and create or refresh a dedicated context tree repo
|
|
11
|
+
publish Publish a dedicated tree repo to GitHub and reconnect it to the source repo
|
|
11
12
|
verify Run verification checks against a tree repo
|
|
12
13
|
upgrade Refresh the installed skill in a tree repo
|
|
13
14
|
help Show help for a topic (e.g. \`help onboarding\`)
|
|
@@ -18,6 +19,7 @@ Options:
|
|
|
18
19
|
|
|
19
20
|
Common examples:
|
|
20
21
|
context-tree init
|
|
22
|
+
context-tree publish --open-pr
|
|
21
23
|
mkdir my-org-context && cd my-org-context && git init && context-tree init --here
|
|
22
24
|
context-tree verify --tree-path ../my-org-context
|
|
23
25
|
context-tree upgrade --tree-path ../my-org-context
|
|
@@ -47,18 +49,22 @@ async function runCli(args, output = console.log) {
|
|
|
47
49
|
const command = args[0];
|
|
48
50
|
switch (command) {
|
|
49
51
|
case "init": {
|
|
50
|
-
const { runInit } = await import("./init-
|
|
52
|
+
const { runInit } = await import("./init-DjSVkUeR.js");
|
|
51
53
|
return runInit(args.slice(1));
|
|
52
54
|
}
|
|
53
55
|
case "verify": {
|
|
54
|
-
const { runVerify } = await import("./verify-
|
|
56
|
+
const { runVerify } = await import("./verify-Chhm1vOF.js");
|
|
55
57
|
return runVerify(args.slice(1));
|
|
56
58
|
}
|
|
59
|
+
case "publish": {
|
|
60
|
+
const { runPublish } = await import("./publish-D0crNDjz.js");
|
|
61
|
+
return runPublish(args.slice(1));
|
|
62
|
+
}
|
|
57
63
|
case "upgrade": {
|
|
58
|
-
const { runUpgrade } = await import("./upgrade-
|
|
64
|
+
const { runUpgrade } = await import("./upgrade-B_NTlNrx.js");
|
|
59
65
|
return runUpgrade(args.slice(1));
|
|
60
66
|
}
|
|
61
|
-
case "help": return (await import("./help-
|
|
67
|
+
case "help": return (await import("./help-CDfaFrzl.js")).runHelp(args.slice(1), write);
|
|
62
68
|
default:
|
|
63
69
|
write(`Unknown command: ${command}`);
|
|
64
70
|
write(USAGE);
|
|
@@ -12,7 +12,7 @@ async function runHelp(args, output = console.log) {
|
|
|
12
12
|
}
|
|
13
13
|
switch (topic) {
|
|
14
14
|
case "onboarding": {
|
|
15
|
-
const { runOnboarding } = await import("./onboarding-
|
|
15
|
+
const { runOnboarding } = await import("./onboarding-Ce033qaW.js");
|
|
16
16
|
return runOnboarding(output);
|
|
17
17
|
}
|
|
18
18
|
default:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as onboarding_default } from "./onboarding-
|
|
3
|
-
import { i as resolveBundledPackageRoot, n as copyCanonicalSkill, r as renderTemplateFile, t as upsertSourceIntegrationFiles } from "./source-integration-
|
|
1
|
+
import { E as installedSkillRootsDisplay, T as SOURCE_INTEGRATION_MARKER, _ as LEGACY_AGENT_INSTRUCTIONS_FILE, b as LEGACY_REPO_SKILL_EXAMPLES_DIR, c as CLAUDE_INSTRUCTIONS_FILE, d as FRAMEWORK_EXAMPLES_DIR, f as FRAMEWORK_TEMPLATES_DIR, h as INSTALLED_PROGRESS, i as AGENT_INSTRUCTIONS_TEMPLATE, m as FRAMEWORK_WORKFLOWS_DIR, n as Repo, p as FRAMEWORK_VERSION, r as AGENT_INSTRUCTIONS_FILE, s as CLAUDE_FRAMEWORK_EXAMPLES_DIR, t as FRAMEWORK_END_MARKER, u as FRAMEWORK_ASSET_ROOT, v as LEGACY_EXAMPLES_DIR } from "./repo-BeVpMoHi.js";
|
|
2
|
+
import { n as onboarding_default } from "./onboarding-BiHx2jy5.js";
|
|
3
|
+
import { i as resolveBundledPackageRoot, n as copyCanonicalSkill, r as renderTemplateFile, t as upsertSourceIntegrationFiles } from "./source-integration-DMxnl8Dw.js";
|
|
4
|
+
import { n as writeBootstrapState } from "./bootstrap-YRjfHJp7.js";
|
|
4
5
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { execFileSync } from "node:child_process";
|
|
6
7
|
import { dirname, join, relative, resolve } from "node:path";
|
|
@@ -253,9 +254,8 @@ function formatTaskList(groups, context) {
|
|
|
253
254
|
if (context.sourceRepoName) {
|
|
254
255
|
lines.push(`**Source/workspace contract:** Keep \`${context.sourceRepoName}\` limited to the installed skill plus the \`${SOURCE_INTEGRATION_MARKER}\` lines in \`${AGENT_INSTRUCTIONS_FILE}\` and \`${CLAUDE_INSTRUCTIONS_FILE}\`. Never add \`NODE.md\`, \`members/\`, or tree-scoped \`${AGENT_INSTRUCTIONS_FILE}\` there.`, "");
|
|
255
256
|
lines.push("## Source Workspace Workflow");
|
|
256
|
-
lines.push(`- [ ]
|
|
257
|
-
lines.push(`- [ ]
|
|
258
|
-
lines.push(`- [ ] Open a PR against the source/workspace repo's default branch with only the installed skill, the \`${SOURCE_INTEGRATION_MARKER}\` marker lines in \`${AGENT_INSTRUCTIONS_FILE}\` / \`${CLAUDE_INSTRUCTIONS_FILE}\`, and the new submodule pointer`);
|
|
257
|
+
lines.push(`- [ ] When this initial tree version is ready, run \`context-tree publish --open-pr\` from this dedicated tree repo. It will create or reuse the GitHub \`*-context\` repo, add it back to \`${context.sourceRepoName}\` as a git submodule, and open the source/workspace PR.`);
|
|
258
|
+
lines.push(`- [ ] After publish succeeds, treat the source/workspace repo's \`${context.sourceRepoName}\` submodule checkout as the canonical local working copy for this tree. The temporary sibling bootstrap repo can be deleted when you no longer need it.`);
|
|
259
259
|
lines.push("");
|
|
260
260
|
}
|
|
261
261
|
lines.push("When you publish this tree repo, keep it in the same GitHub organization as the source repo unless you have a reason not to.", "");
|
|
@@ -344,6 +344,11 @@ function runInit(repo, options) {
|
|
|
344
344
|
console.error(`Error: ${message}`);
|
|
345
345
|
return 1;
|
|
346
346
|
}
|
|
347
|
+
if (initTarget.dedicatedTreeRepo) writeBootstrapState(r.root, {
|
|
348
|
+
sourceRepoName: sourceRepo.repoName(),
|
|
349
|
+
sourceRepoPath: relativePathFrom(r.root, sourceRepo.root),
|
|
350
|
+
treeRepoName: r.repoName()
|
|
351
|
+
});
|
|
347
352
|
console.log(onboarding_default);
|
|
348
353
|
console.log("---\n");
|
|
349
354
|
const groups = evaluateAll(r);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region skills/first-tree/references/onboarding.md
|
|
2
|
+
var onboarding_default = "# Context Tree Onboarding\n\nYou 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.\n\n---\n\n## What Is a Context Tree\n\nA 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.\n\nKey properties:\n\n- **Nodes are markdown files.** Each directory has a `NODE.md` that describes the domain. Leaf `.md` files capture specific decisions or designs.\n- **Every node has an owner.** Declared in YAML frontmatter. Owners approve changes to their nodes.\n- **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.\n- **The tree is never a snapshot — it's the current state.** When decisions change, the tree updates. Stale nodes are bugs.\n\n### Frontmatter Format\n\nEvery node has frontmatter:\n\n```yaml\n---\ntitle: \"Auth Architecture\"\nowners: [alice, bob]\nsoft_links: [/infrastructure/deployments]\n---\n```\n\n- `owners` — who can approve changes. `owners: []` inherits from parent. `owners: [*]` means anyone.\n- `soft_links` — cross-references to related nodes in other domains.\n\n### What Belongs in the Tree\n\nInformation an agent needs to **decide** on an approach — not to execute it.\n\n**Yes:** \"Auth spans 4 repos: backend issues JWTs, frontend uses Better Auth, extension uses OAuth popup, desktop uses localhost callback.\"\n\n**No:** The function signature of `auth_service.verify()` — that's in the code.\n\n---\n\n## Four Principles\n\n1. **Source of truth for decisions, not execution.** The tree captures the *what* and *why*. Execution details stay in source systems.\n2. **Agents are first-class participants.** The tree is designed for agents to navigate and update.\n3. **Transparency by default.** Reading is open to all. Writing requires owner approval.\n4. **Git-native.** Nodes are files, domains are directories. History, ownership, and review follow Git conventions.\n\n---\n\n## How to Set Up a Context Tree\n\n### Prerequisites\n\n- A source/workspace Git repository, or an already-created dedicated tree repo\n- Node.js 18+\n- GitHub CLI (`gh`) if you want `context-tree publish` to create the remote\n `*-context` repo and open the source-repo PR for you\n- The npm package is `first-tree`, the installed CLI command is\n `context-tree`.\n- `context-tree init` installs the framework skill into\n `.agents/skills/first-tree/` and `.claude/skills/first-tree/`.\n- Use `npx first-tree init` for one-off runs, or `npm install -g first-tree`\n to add the `context-tree` command to your PATH\n\n### Step 1: Initialize\n\nRecommended workflow: run `context-tree init` from your source or workspace repo.\nThe CLI will install the bundled skill in the current repo, update root\n`AGENTS.md` and `CLAUDE.md` with a `FIRST-TREE-SOURCE-INTEGRATION:` line, and\ncreate a sibling dedicated tree repo named `<repo>-context` by default. Tree\nfiles are scaffolded only in the dedicated tree repo.\n\n```bash\ncd my-org\ncontext-tree init\ncd ../my-org-context\ncontext-tree publish --open-pr\n```\n\nIf you already created a dedicated tree repo manually, initialize it in place:\n\n```bash\nmkdir my-org-context && cd my-org-context\ngit init\ncontext-tree init --here\n```\n\nOnly use `--here` after you have already switched into the dedicated tree repo.\nDo not use it inside the source/workspace repo unless you intentionally want\nthat repo itself to become the Context Tree.\n\nEither way, the framework installs into `.agents/skills/first-tree/` and\n`.claude/skills/first-tree/`, renders scaffolding (`NODE.md`, `AGENTS.md`,\n`members/NODE.md`), and generates a task list in\n`.agents/skills/first-tree/progress.md`.\n\nHard boundary: do **not** create `NODE.md`, `members/`, or tree-scoped\n`AGENTS.md` in the source/workspace repo. Those files belong only in the\ndedicated `*-context` repo.\n\nDefault agent workflow after initialization:\n\n1. Draft the initial tree version in the dedicated `*-context` repo.\n2. Run `context-tree publish --open-pr` from that dedicated tree repo. It will\n create or reuse the GitHub `*-context` repo in the same owner/org as the\n source repo, add it back to the source/workspace repo as a `git submodule`,\n and open the source-repo PR.\n3. After publish succeeds, treat the source repo's submodule checkout as the\n canonical local working copy for the tree. The temporary sibling bootstrap\n checkout can be deleted when you no longer need it.\n\n### Step 2: Work Through the Task List\n\nRead `.agents/skills/first-tree/progress.md`. It contains a checklist tailored\nto the current state of the repo. Complete each task:\n\n- Fill in `NODE.md` with your organization name, owners, and domains\n- Add project-specific instructions to `AGENTS.md` below the framework markers\n- Create member nodes under `members/`\n- Optionally configure agent integration (for Claude Code, the installed hook\n assets live under `.claude/skills/first-tree/`)\n- Copy validation workflows from\n `.agents/skills/first-tree/assets/framework/workflows/` to\n `.github/workflows/`\n\nAs you complete each task, check it off in\n`.agents/skills/first-tree/progress.md` by changing `- [ ]` to `- [x]`.\n\n### Step 3: Verify\n\n```bash\ncontext-tree verify\n```\n\nOr, from your source/workspace repo:\n\n```bash\ncontext-tree verify --tree-path ../my-org-context\n```\n\nThis fails if any items in `.agents/skills/first-tree/progress.md` remain\nunchecked, and runs deterministic checks (valid frontmatter, node structure,\nmember nodes exist).\n\nDo not run `context-tree verify` in the source/workspace repo itself. That repo\nonly carries the installed skill plus the\n`FIRST-TREE-SOURCE-INTEGRATION:` line.\n\n### Step 4: Design Your Domains\n\nCreate top-level directories for your organization's primary concerns. Each needs a `NODE.md`:\n\n```\nmy-org-tree/\n NODE.md # root — lists all domains\n engineering/\n NODE.md # decisions about architecture, infra, tooling\n product/\n NODE.md # strategy, roadmap, user research\n marketing/\n NODE.md # positioning, campaigns\n members/\n NODE.md # team members and agents\n alice/\n NODE.md # individual member node\n```\n\n### Step 5: Populate from Existing Work\n\nFor each domain, extract knowledge from existing repos, docs, and systems:\n\n- Decisions and their rationale\n- Cross-domain relationships and dependencies\n- Constraints that aren't obvious from the code\n\nThe tree doesn't duplicate source code — it captures what connects things and why they were built that way.\n\n---\n\n## CLI Reference\n\n| Command | Description |\n|---------|-------------|\n| `context-tree init` | Install local source/workspace integration and create or refresh a dedicated tree repo. By default, running in a source/workspace repo creates a sibling `<repo>-context`; use `--here` only when you are already inside the dedicated tree repo. |\n| `context-tree publish` | Publish a dedicated tree repo to GitHub, add it back to the source/workspace repo as a submodule, and optionally open the source-repo PR. |\n| `context-tree verify` | Check the installed progress file for unchecked items + run deterministic validation. Use `--tree-path` when invoking from another working directory. |\n| `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. |\n| `context-tree help onboarding` | Print this onboarding guide. |\n\n---\n\n## Upgrading the Framework\n\nWhen the framework updates:\n\n```bash\ncontext-tree upgrade\n```\n\n`context-tree upgrade` refreshes `.agents/skills/first-tree/` and\n`.claude/skills/first-tree/` from the skill bundled with the currently running\n`first-tree` npm package, preserves your tree content, and generates follow-up\ntasks in `.agents/skills/first-tree/progress.md`.\n\nIf you run `context-tree upgrade` in the source/workspace repo, it refreshes\nonly the local installed skill plus the `FIRST-TREE-SOURCE-INTEGRATION:` lines.\nRun `context-tree upgrade --tree-path ../my-org-context` to upgrade the\ndedicated tree repo itself.\n\nIf your repo still uses the older `skills/first-tree/` or `.context-tree/` layouts,\n`context-tree upgrade` will migrate it to the current installed layout first.\n\nTo pick up a newer framework release, first run a newer package version, for\nexample `npx first-tree@latest upgrade`, or update your global `first-tree`\ninstall before running `context-tree upgrade`.\n\n---\n\n## Further Reading\n\n- `.agents/skills/first-tree/references/principles.md` — Core principles with detailed examples\n- `.agents/skills/first-tree/references/source-workspace-installation.md` — Source/workspace install contract\n- `.agents/skills/first-tree/references/ownership-and-naming.md` — How nodes are named and owned\n- `AGENTS.md` in your tree — The before/during/after workflow for every task\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region skills/first-tree/engine/onboarding.ts
|
|
5
|
+
function runOnboarding(output = console.log) {
|
|
6
|
+
output(onboarding_default);
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { onboarding_default as n, runOnboarding as t };
|