first-tree 0.0.2 → 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-CSRIkuoM.js → verify-CxN6JiV9.js} +53 -24
  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
@@ -1,111 +0,0 @@
1
- import { execFileSync } from "node:child_process";
2
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
- import { join, resolve } from "node:path";
4
- //#region src/repo.ts
5
- const FRONTMATTER_RE = /^---\s*\n(.*?)\n---/s;
6
- const OWNERS_RE = /^owners:\s*\[([^\]]*)\]/m;
7
- const TITLE_RE = /^title:\s*['"]?(.+?)['"]?\s*$/m;
8
- const FRAMEWORK_END_MARKER = "<!-- END CONTEXT-TREE FRAMEWORK -->";
9
- var Repo = class {
10
- root;
11
- constructor(root) {
12
- this.root = resolve(root ?? process.cwd());
13
- }
14
- pathExists(relPath) {
15
- return existsSync(join(this.root, relPath));
16
- }
17
- fileContains(relPath, text) {
18
- const fullPath = join(this.root, relPath);
19
- try {
20
- if (!statSync(fullPath).isFile()) return false;
21
- return readFileSync(fullPath, "utf-8").includes(text);
22
- } catch {
23
- return false;
24
- }
25
- }
26
- readFile(relPath) {
27
- try {
28
- return readFileSync(join(this.root, relPath), "utf-8");
29
- } catch {
30
- return null;
31
- }
32
- }
33
- frontmatter(relPath) {
34
- const text = this.readFile(relPath);
35
- if (text === null) return null;
36
- const m = text.match(FRONTMATTER_RE);
37
- if (!m) return null;
38
- const fm = m[1];
39
- const result = {};
40
- const titleM = fm.match(TITLE_RE);
41
- if (titleM) result.title = titleM[1].trim();
42
- const ownersM = fm.match(OWNERS_RE);
43
- if (ownersM) {
44
- const raw = ownersM[1].trim();
45
- result.owners = raw ? raw.split(",").map((o) => o.trim()).filter(Boolean) : [];
46
- }
47
- return result.title !== void 0 || result.owners !== void 0 ? result : null;
48
- }
49
- anyAgentConfig() {
50
- return [".claude/settings.json", ".codex/config.json"].some((c) => this.pathExists(c));
51
- }
52
- isGitRepo() {
53
- try {
54
- return statSync(join(this.root, ".git")).isDirectory();
55
- } catch {
56
- return false;
57
- }
58
- }
59
- hasFramework() {
60
- return this.pathExists(".context-tree/VERSION");
61
- }
62
- readVersion() {
63
- const text = this.readFile(".context-tree/VERSION");
64
- return text ? text.trim() : null;
65
- }
66
- hasAgentMdMarkers() {
67
- const text = this.readFile("AGENT.md");
68
- if (text === null) return false;
69
- return text.includes("<!-- BEGIN CONTEXT-TREE FRAMEWORK") && text.includes("<!-- END CONTEXT-TREE FRAMEWORK -->");
70
- }
71
- hasMembers() {
72
- const membersDir = join(this.root, "members");
73
- try {
74
- if (!statSync(membersDir).isDirectory()) return false;
75
- } catch {
76
- return false;
77
- }
78
- return existsSync(join(membersDir, "NODE.md"));
79
- }
80
- memberCount() {
81
- const membersDir = join(this.root, "members");
82
- try {
83
- if (!statSync(membersDir).isDirectory()) return 0;
84
- } catch {
85
- return 0;
86
- }
87
- let count = 0;
88
- for (const entry of readdirSync(membersDir)) {
89
- const childPath = join(membersDir, entry);
90
- try {
91
- if (statSync(childPath).isDirectory() && existsSync(join(childPath, "NODE.md"))) count++;
92
- } catch {}
93
- }
94
- return count;
95
- }
96
- hasPlaceholderNode() {
97
- return this.fileContains("NODE.md", "<!-- PLACEHOLDER");
98
- }
99
- hasUpstreamRemote() {
100
- try {
101
- return execFileSync("git", ["remote"], {
102
- cwd: this.root,
103
- encoding: "utf-8"
104
- }).split(/\s+/).includes("context-tree-upstream");
105
- } catch {
106
- return false;
107
- }
108
- }
109
- };
110
- //#endregion
111
- export { Repo as n, FRAMEWORK_END_MARKER as t };
@@ -1,82 +0,0 @@
1
- import { n as Repo } from "./repo-BByc3VvM.js";
2
- import { execFileSync } from "node:child_process";
3
- import { mkdirSync, writeFileSync } from "node:fs";
4
- import { dirname, join } from "node:path";
5
- //#region src/upgrade.ts
6
- const SEED_TREE_URL = "https://github.com/agent-team-foundation/seed-tree";
7
- function getUpstreamVersion(repo) {
8
- try {
9
- execFileSync("git", [
10
- "fetch",
11
- "context-tree-upstream",
12
- "--depth",
13
- "1"
14
- ], {
15
- cwd: repo.root,
16
- encoding: "utf-8",
17
- stdio: "pipe"
18
- });
19
- } catch {
20
- return null;
21
- }
22
- try {
23
- return execFileSync("git", ["show", "context-tree-upstream/main:.context-tree/VERSION"], {
24
- cwd: repo.root,
25
- encoding: "utf-8",
26
- stdio: "pipe"
27
- }).trim();
28
- } catch {
29
- return null;
30
- }
31
- }
32
- function writeProgress(repo, content) {
33
- const progressPath = join(repo.root, ".context-tree", "progress.md");
34
- mkdirSync(dirname(progressPath), { recursive: true });
35
- writeFileSync(progressPath, content);
36
- }
37
- function runUpgrade() {
38
- const repo = new Repo();
39
- if (!repo.hasFramework()) {
40
- console.error("Error: no .context-tree/ found. Run `context-tree init` first.");
41
- return 1;
42
- }
43
- const localVersion = repo.readVersion() ?? "unknown";
44
- console.log(`Local framework version: ${localVersion}\n`);
45
- if (!repo.hasUpstreamRemote()) {
46
- const output = [
47
- "# Context Tree Upgrade\n",
48
- "## Setup",
49
- `- [ ] Add upstream remote: \`git remote add context-tree-upstream ${SEED_TREE_URL}\``,
50
- "- [ ] Then run `context-tree upgrade` again to check for updates"
51
- ].join("\n");
52
- console.log(output);
53
- writeProgress(repo, output + "\n");
54
- console.log("\nProgress file written to .context-tree/progress.md");
55
- return 0;
56
- }
57
- const upstreamVersion = getUpstreamVersion(repo);
58
- if (upstreamVersion === null) {
59
- console.log("Could not fetch upstream version. Check your network and try again.");
60
- return 1;
61
- }
62
- if (upstreamVersion === localVersion) {
63
- console.log(`Already up to date (v${localVersion}).`);
64
- return 0;
65
- }
66
- const lines = [
67
- `# Context Tree Upgrade — v${localVersion} -> v${upstreamVersion}\n`,
68
- "## Framework",
69
- "- [ ] Pull latest from upstream: `git fetch context-tree-upstream && git merge context-tree-upstream/main`",
70
- "- [ ] Resolve any conflicts in `.context-tree/` (framework files should generally take upstream version)",
71
- ""
72
- ];
73
- if (repo.hasAgentMdMarkers()) lines.push("## Agent Instructions", "- [ ] Check if AGENT.md framework section needs updating — compare content between markers to the new template", "");
74
- lines.push("## Verification", `- [ ] \`.context-tree/VERSION\` reads \`${upstreamVersion}\``, "- [ ] `context-tree verify` passes", "- [ ] AGENT.md framework section matches upstream", "", "---", "", "**Important:** As you complete each task, check it off in `.context-tree/progress.md` by changing `- [ ]` to `- [x]`. Run `context-tree verify` when done — it will fail if any items remain unchecked.", "");
75
- const output = lines.join("\n");
76
- console.log(output);
77
- writeProgress(repo, output);
78
- console.log("Progress file written to .context-tree/progress.md");
79
- return 0;
80
- }
81
- //#endregion
82
- export { runUpgrade };