first-tree 0.0.2 → 0.0.4

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 +116 -40
  2. package/dist/cli.js +46 -17
  3. package/dist/help-Dtdj91HJ.js +25 -0
  4. package/dist/init--VepFe6N.js +403 -0
  5. package/dist/installer-cH7N4RNj.js +47 -0
  6. package/dist/onboarding-C9cYSE6F.js +2 -0
  7. package/dist/onboarding-CPP8fF4D.js +10 -0
  8. package/dist/repo-DY57bMqr.js +318 -0
  9. package/dist/upgrade-Cgx_K2HM.js +135 -0
  10. package/dist/{verify-CSRIkuoM.js → verify-mC9ZTd1f.js} +118 -29
  11. package/package.json +33 -10
  12. package/skills/first-tree/SKILL.md +113 -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 +193 -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/agents.md.template +49 -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 +41 -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 +414 -0
  34. package/skills/first-tree/engine/onboarding.ts +10 -0
  35. package/skills/first-tree/engine/repo.ts +360 -0
  36. package/skills/first-tree/engine/rules/agent-instructions.ts +59 -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 +141 -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 +233 -0
  49. package/skills/first-tree/engine/validators/members.ts +215 -0
  50. package/skills/first-tree/engine/validators/nodes.ts +559 -0
  51. package/skills/first-tree/engine/verify.ts +155 -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 +59 -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 +185 -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 +94 -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 +169 -0
  68. package/skills/first-tree/tests/init.test.ts +250 -0
  69. package/skills/first-tree/tests/repo.test.ts +440 -0
  70. package/skills/first-tree/tests/rules.test.ts +413 -0
  71. package/skills/first-tree/tests/run-review.test.ts +155 -0
  72. package/skills/first-tree/tests/skill-artifacts.test.ts +311 -0
  73. package/skills/first-tree/tests/thin-cli.test.ts +104 -0
  74. package/skills/first-tree/tests/upgrade.test.ts +103 -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 +241 -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
package/README.md CHANGED
@@ -1,68 +1,144 @@
1
- # seed-tree
1
+ # first-tree
2
2
 
3
- Template source and CLI for [Context Tree](https://context-tree.ai) the living source of truth for your organization.
3
+ `first-tree` publishes the `context-tree` CLI and bundles the canonical
4
+ `first-tree` skill used to bootstrap and maintain Context Tree repos.
4
5
 
5
- ## What is Context Tree?
6
+ ## Install And Run
6
7
 
7
- A tree-structured knowledge base that agents and humans build and maintain together. Every node represents a domain, decision, or design. Every node has an owner. When things change, the tree updates. See [docs/about.md](docs/about.md) for the full story.
8
+ - One-off use without installing globally:
9
+
10
+ ```bash
11
+ npx first-tree init
12
+ ```
13
+
14
+ - Global install:
15
+
16
+ ```bash
17
+ npm install -g first-tree
18
+ context-tree init
19
+ ```
20
+
21
+ - Show the installed CLI version:
22
+
23
+ ```bash
24
+ context-tree --version
25
+ ```
26
+
27
+ - Show the command list:
28
+
29
+ ```bash
30
+ context-tree --help
31
+ ```
32
+
33
+ Although the npm package is named `first-tree`, the installed CLI command is
34
+ `context-tree`.
8
35
 
9
36
  ## Quick Start
10
37
 
38
+ Recommended workflow: start from your source or workspace repo and let
39
+ `context-tree init` create a sibling dedicated tree repo.
40
+
11
41
  ```bash
12
- npx context-tree init
42
+ cd my-app
43
+ npx first-tree init
44
+ cd ../my-app-context
13
45
  ```
14
46
 
15
- Run this inside a git repo. It clones the framework, renders scaffolding, and generates a task list for your agent to work through.
47
+ If you already created a dedicated tree repo yourself, initialize it in place:
48
+
49
+ ```bash
50
+ mkdir my-org-context && cd my-org-context
51
+ git init
52
+ context-tree init --here
53
+ ```
54
+
55
+ - `context-tree init` installs `skills/first-tree/`, creates `NODE.md`,
56
+ `AGENTS.md`, `members/NODE.md`, and writes a checklist to
57
+ `skills/first-tree/progress.md`.
58
+ - `context-tree verify` checks both the progress checklist and deterministic
59
+ tree validation. It is expected to fail until the required onboarding tasks
60
+ are complete.
61
+ - `context-tree upgrade` refreshes the installed skill from the currently
62
+ running `first-tree` npm package. To force the newest published package for a
63
+ one-off upgrade, run `npx first-tree@latest upgrade`.
64
+
65
+ The package carries the bundled canonical skill, so `init` and `upgrade`
66
+ install from the package payload instead of cloning this source repo at
67
+ runtime.
16
68
 
17
69
  ## Commands
18
70
 
19
71
  | Command | What it does |
20
- |---------|-------------|
21
- | `context-tree init` | Bootstrap a new context tree in the current git repo |
22
- | `context-tree verify` | Run checks against the tree, report pass/fail |
23
- | `context-tree upgrade` | Compare local framework version to upstream, generate upgrade tasks |
72
+ | --- | --- |
73
+ | `context-tree init` | Create or refresh a dedicated context tree repo; use `--here` to initialize the current repo in place |
74
+ | `context-tree verify` | Run verification checks against the current tree |
75
+ | `context-tree upgrade` | Refresh the installed skill from the current `first-tree` npm package and write follow-up tasks |
76
+ | `context-tree help onboarding` | Print the onboarding guide |
77
+ | `context-tree --help` | Show the available commands |
78
+ | `context-tree --version` | Print the installed CLI version |
24
79
 
25
- ## What `init` creates
80
+ ## Package Name vs Command
26
81
 
27
- ```
28
- your-tree/
29
- .context-tree/ # framework (upgradable from seed-tree)
30
- VERSION
31
- principles.md
32
- ownership-and-naming.md
33
- templates/
34
- workflows/
35
- examples/
36
- NODE.md # root node — your domains (from template)
37
- AGENT.md # agent instructions with framework markers (from template)
38
- members/
39
- NODE.md # members domain (from template)
40
- ```
82
+ - npm package name: `first-tree`
83
+ - installed CLI command: `context-tree`
84
+ - installed skill directory inside a user tree: `skills/first-tree/`
85
+ - when maintainer docs mention "the `first-tree` skill", they mean that
86
+ bundled skill directory, not the npm package name
41
87
 
42
- ## Upgrades
88
+ ## Runtime And Maintainer Prerequisites
43
89
 
44
- After init, seed-tree is added as a git remote (`context-tree-upstream`). To upgrade the framework:
90
+ - User trees: the onboarding guide targets Node.js 18+.
91
+ - This source repo: use Node.js 22 and pnpm 10 to match CI and the checked-in
92
+ package manager version.
45
93
 
46
- ```bash
47
- context-tree upgrade # shows what changed and what to do
48
- ```
94
+ ## What This Repo Ships
49
95
 
50
- ## Documentation
96
+ - `src/` keeps the thin CLI shell that parses commands and dispatches to the
97
+ bundled skill.
98
+ - `skills/first-tree/` is the canonical source for framework behavior, shipped
99
+ templates, maintainer references, and validation logic.
100
+ - `evals/` is maintainer-only developer tooling for the source repo. It is
101
+ intentionally not part of the published package.
51
102
 
52
- - [docs/onboarding.md](docs/onboarding.md) Onboarding guide for setting up a context tree (for agents)
53
- - [docs/about.md](docs/about.md) — What is Context Tree and who it's for
54
- - [.context-tree/principles.md](.context-tree/principles.md) Core principles with examples
55
- - [.context-tree/ownership-and-naming.md](.context-tree/ownership-and-naming.md) — Node naming and ownership model
103
+ ## Developing This Repo
104
+
105
+ Run these commands from the repo root:
106
+
107
+ ```bash
108
+ pnpm install --frozen-lockfile
109
+ pnpm validate:skill
110
+ pnpm typecheck
111
+ pnpm test
112
+ pnpm build
113
+ ```
56
114
 
57
- ## Development
115
+ When package contents or install/upgrade behavior changes, also run:
58
116
 
59
117
  ```bash
60
- pnpm install
61
- pnpm test # run tests
62
- pnpm typecheck # type check
63
- pnpm build # build CLI
118
+ pnpm pack
64
119
  ```
65
120
 
121
+ ## Canonical Documentation
122
+
123
+ All framework documentation, maintainer guidance, and shipped runtime assets
124
+ live in `skills/first-tree/`.
125
+
126
+ - User-facing overview: `skills/first-tree/references/about.md`
127
+ - User onboarding: `skills/first-tree/references/onboarding.md`
128
+ - Maintainer entrypoint: `skills/first-tree/references/source-map.md`
129
+
130
+ If you are maintaining this repo, start with the source map instead of relying
131
+ on root-level prose.
132
+
133
+ ## Contributing And Security
134
+
135
+ - Use the GitHub issue forms for bug reports and feature requests so maintainers
136
+ get reproducible context up front.
137
+ - See `CONTRIBUTING.md` for local setup, validation expectations, and where
138
+ changes should live.
139
+ - See `CODE_OF_CONDUCT.md` for community expectations.
140
+ - See `SECURITY.md` for vulnerability reporting guidance.
141
+
66
142
  ## License
67
143
 
68
144
  Apache 2.0
package/dist/cli.js CHANGED
@@ -1,41 +1,70 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
2
4
  //#region src/cli.ts
3
5
  const USAGE = `usage: context-tree <command>
4
6
 
7
+ New to context-tree? Run \`context-tree help onboarding\` first.
8
+
5
9
  Commands:
6
- init Bootstrap a new context tree (clones seed-tree, copies framework files)
7
- verify Run verification checks against the current tree
8
- upgrade Generate an upgrade task list from upstream changes
10
+ init Create or refresh a dedicated context tree repo
11
+ verify Run verification checks against a tree repo
12
+ upgrade Refresh the installed skill in a tree repo
13
+ help Show help for a topic (e.g. \`help onboarding\`)
9
14
 
10
15
  Options:
11
- --help Show this help message
16
+ --help Show this help message
17
+ --version Show version number
18
+
19
+ Common examples:
20
+ context-tree init
21
+ context-tree init --here
22
+ context-tree verify --tree-path ../my-org-context
23
+ context-tree upgrade --tree-path ../my-org-context
12
24
  `;
13
- async function main() {
14
- const args = process.argv.slice(2);
25
+ function isDirectExecution(argv1, metaUrl = import.meta.url) {
26
+ if (argv1 === void 0) return false;
27
+ try {
28
+ return realpathSync(argv1) === realpathSync(fileURLToPath(metaUrl));
29
+ } catch {
30
+ return false;
31
+ }
32
+ }
33
+ async function runCli(args, output = console.log) {
34
+ const write = (text) => output(text);
15
35
  if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
16
- console.log(USAGE);
36
+ write(USAGE);
37
+ return 0;
38
+ }
39
+ if (args[0] === "--version" || args[0] === "-v") {
40
+ const { createRequire } = await import("node:module");
41
+ write(createRequire(import.meta.url)("../package.json").version);
17
42
  return 0;
18
43
  }
19
44
  const command = args[0];
20
45
  switch (command) {
21
46
  case "init": {
22
- const { runInit } = await import("./init-CE_944sb.js");
23
- return runInit();
47
+ const { runInit } = await import("./init--VepFe6N.js");
48
+ return runInit(args.slice(1));
24
49
  }
25
50
  case "verify": {
26
- const { runVerify } = await import("./verify-CSRIkuoM.js");
27
- return runVerify();
51
+ const { runVerify } = await import("./verify-mC9ZTd1f.js");
52
+ return runVerify(args.slice(1));
28
53
  }
29
54
  case "upgrade": {
30
- const { runUpgrade } = await import("./upgrade-Chr7z0CY.js");
31
- return runUpgrade();
55
+ const { runUpgrade } = await import("./upgrade-Cgx_K2HM.js");
56
+ return runUpgrade(args.slice(1));
32
57
  }
58
+ case "help": return (await import("./help-Dtdj91HJ.js")).runHelp(args.slice(1), write);
33
59
  default:
34
- console.log(`Unknown command: ${command}`);
35
- console.log(USAGE);
60
+ write(`Unknown command: ${command}`);
61
+ write(USAGE);
36
62
  return 1;
37
63
  }
38
64
  }
39
- main().then((code) => process.exit(code));
65
+ async function main() {
66
+ return runCli(process.argv.slice(2));
67
+ }
68
+ if (isDirectExecution(process.argv[1])) main().then((code) => process.exit(code));
40
69
  //#endregion
41
- export {};
70
+ export { USAGE, isDirectExecution, runCli };
@@ -0,0 +1,25 @@
1
+ //#region skills/first-tree/engine/commands/help.ts
2
+ const HELP_USAGE = `usage: context-tree help <topic>
3
+
4
+ Topics:
5
+ onboarding How to set up a context tree from scratch
6
+ `;
7
+ async function runHelp(args, output = console.log) {
8
+ const topic = args[0];
9
+ if (!topic || topic === "--help" || topic === "-h") {
10
+ output(HELP_USAGE);
11
+ return 0;
12
+ }
13
+ switch (topic) {
14
+ case "onboarding": {
15
+ const { runOnboarding } = await import("./onboarding-C9cYSE6F.js");
16
+ return runOnboarding(output);
17
+ }
18
+ default:
19
+ output(`Unknown help topic: ${topic}`);
20
+ output(HELP_USAGE);
21
+ return 1;
22
+ }
23
+ }
24
+ //#endregion
25
+ export { runHelp };