trellis 3.1.26 → 3.1.31

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.
@@ -0,0 +1,166 @@
1
+ // @bun
2
+ import {
3
+ inferProjectContext,
4
+ init_infer,
5
+ init_profile,
6
+ init_write,
7
+ loadProfile
8
+ } from "./index-8f2z3b0h.js";
9
+
10
+ // src/scaffold/seed.ts
11
+ init_profile();
12
+ init_infer();
13
+ import { existsSync, writeFileSync } from "fs";
14
+ import { join } from "path";
15
+ async function seedContext(opts) {
16
+ const { rootPath, ide = "none", force = false } = opts;
17
+ const filesUpdated = [];
18
+ const timestamp = new Date().toISOString();
19
+ const profile = loadProfile();
20
+ const context = await inferProjectContext(rootPath);
21
+ const agentsDir = join(rootPath, ".trellis", "agents");
22
+ if (existsSync(agentsDir)) {
23
+ const agentsMdPath = join(agentsDir, "AGENTS.md");
24
+ if (existsSync(agentsMdPath) || force) {
25
+ const content = renderSeedAgentsMd(profile, context, timestamp);
26
+ writeFileSync(agentsMdPath, content, "utf-8");
27
+ filesUpdated.push(".trellis/agents/AGENTS.md");
28
+ }
29
+ const agentContextPath = join(agentsDir, "agent-context.json");
30
+ if (existsSync(agentContextPath) || force) {
31
+ const config = {
32
+ domain: context.domain,
33
+ ecosystem: context.ecosystem,
34
+ tools: [],
35
+ ontologies: [],
36
+ generatedAt: timestamp,
37
+ confidence: context.confidence,
38
+ lastSeed: timestamp
39
+ };
40
+ writeFileSync(agentContextPath, JSON.stringify(config, null, 2), "utf-8");
41
+ filesUpdated.push(".trellis/agents/agent-context.json");
42
+ }
43
+ }
44
+ switch (ide) {
45
+ case "cursor": {
46
+ const cursorRulesPath = join(rootPath, ".cursor", "rules.md");
47
+ if (existsSync(cursorRulesPath) || force) {
48
+ const content = renderSeedIdeRules(profile, context, "cursor", timestamp);
49
+ writeFileSync(cursorRulesPath, content, "utf-8");
50
+ filesUpdated.push(".cursor/rules.md");
51
+ }
52
+ break;
53
+ }
54
+ case "windsurf": {
55
+ const windsurfRulesPath = join(rootPath, ".windsurf", "rules.md");
56
+ if (existsSync(windsurfRulesPath) || force) {
57
+ const content = renderSeedIdeRules(profile, context, "windsurf", timestamp);
58
+ writeFileSync(windsurfRulesPath, content, "utf-8");
59
+ filesUpdated.push(".windsurf/rules.md");
60
+ }
61
+ break;
62
+ }
63
+ case "claude": {
64
+ const claudeSettingsPath = join(rootPath, ".claude", "settings.md");
65
+ if (existsSync(claudeSettingsPath) || force) {
66
+ const content = renderSeedIdeRules(profile, context, "claude", timestamp);
67
+ writeFileSync(claudeSettingsPath, content, "utf-8");
68
+ filesUpdated.push(".claude/settings.md");
69
+ }
70
+ break;
71
+ }
72
+ case "none":
73
+ break;
74
+ }
75
+ return {
76
+ success: true,
77
+ filesUpdated,
78
+ timestamp
79
+ };
80
+ }
81
+ function renderSeedAgentsMd(profile, context, timestamp) {
82
+ const userName = profile?.name ?? "the user";
83
+ const userBio = profile?.bio ?? "(not provided)";
84
+ const userSkills = profile?.skills?.length ? profile.skills.join(", ") : "(not specified)";
85
+ return `# Trellis Agent Context
86
+
87
+ > This file was seeded by \`trellis seed\` on ${timestamp}
88
+ > Inference confidence: **${context.confidence}**
89
+
90
+ ---
91
+
92
+ ## About the User
93
+
94
+ | Field | Value |
95
+ |-------|-------|
96
+ | **Name** | ${userName} |
97
+ | **Bio** | ${userBio} |
98
+ | **Skills** | ${userSkills} |
99
+
100
+ ---
101
+
102
+ ## About This Project
103
+
104
+ | Field | Value |
105
+ |-------|-------|
106
+ | **Name** | ${context.name ?? "(unnamed)"} |
107
+ | **Domain** | ${context.domain ?? "(not determined)"} |
108
+ | **Description** | ${context.description ?? "(no description found)"} |
109
+ | **Ecosystem** | ${context.ecosystem ?? "unknown"} |
110
+ | **File count** | ~${context.fileCount} |
111
+
112
+ ---
113
+
114
+ ## Agent Instructions
115
+
116
+ You are operating in a Trellis-tracked repository. Follow these guidelines:
117
+
118
+ 1. **Read \`agent-context.json\`** in this directory for registered tools, ontologies, and domain settings.
119
+ 2. **Check \`skills/\`** for domain-specific operating instructions relevant to this project.
120
+ 3. **Check \`workflows/\`** for repeatable task procedures.
121
+ 4. **Run \`trellis seed\`** to refresh this context file when the project evolves.
122
+
123
+ ---
124
+
125
+ ## Quick Reference
126
+
127
+ \`\`\`bash
128
+ trellis status # Current repo state
129
+ trellis log # Causal operation history
130
+ trellis seed # Refresh this context
131
+ trellis milestone # Create narrative checkpoints
132
+ \`\`\`
133
+ `;
134
+ }
135
+ function renderSeedIdeRules(profile, context, ide, timestamp) {
136
+ const ideName = ide.charAt(0).toUpperCase() + ide.slice(1);
137
+ const projectName = context.name ?? "this project";
138
+ return `# ${ideName} Rules for ${projectName}
139
+
140
+ > Generated by \`trellis seed\` on ${timestamp}
141
+
142
+ ## Project Context
143
+ - **Domain**: ${context.domain ?? "(not determined)"}
144
+ - **Ecosystem**: ${context.ecosystem ?? "unknown"}
145
+ - **File count**: ~${context.fileCount}
146
+ - **Confidence**: ${context.confidence}
147
+
148
+ ## Agent Instructions
149
+ You are working in a Trellis-tracked repository. See \`.trellis/agents/AGENTS.md\` for full context.
150
+
151
+ ## Commands
152
+ - \`trellis status\` \u2014 Check repo state
153
+ - \`trellis seed\` \u2014 Refresh this context file
154
+ - \`trellis log\` \u2014 View causal history
155
+
156
+ ---
157
+ *Auto-generated by Trellis. Run \`trellis seed\` to refresh context.*
158
+ `;
159
+ }
160
+
161
+ // src/scaffold/index.ts
162
+ init_infer();
163
+ init_profile();
164
+ init_write();
165
+
166
+ export { seedContext };