@mindfoldhq/trellis 0.5.0-beta.7 → 0.5.0-beta.9

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 (51) hide show
  1. package/dist/commands/init.d.ts +10 -0
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.js +380 -116
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/commands/update.d.ts.map +1 -1
  6. package/dist/commands/update.js +6 -21
  7. package/dist/commands/update.js.map +1 -1
  8. package/dist/configurators/index.d.ts.map +1 -1
  9. package/dist/configurators/index.js +10 -8
  10. package/dist/configurators/index.js.map +1 -1
  11. package/dist/configurators/opencode.d.ts +10 -3
  12. package/dist/configurators/opencode.d.ts.map +1 -1
  13. package/dist/configurators/opencode.js +58 -32
  14. package/dist/configurators/opencode.js.map +1 -1
  15. package/dist/configurators/qoder.d.ts +7 -6
  16. package/dist/configurators/qoder.d.ts.map +1 -1
  17. package/dist/configurators/qoder.js +17 -9
  18. package/dist/configurators/qoder.js.map +1 -1
  19. package/dist/configurators/shared.d.ts +2 -0
  20. package/dist/configurators/shared.d.ts.map +1 -1
  21. package/dist/configurators/shared.js +18 -0
  22. package/dist/configurators/shared.js.map +1 -1
  23. package/dist/migrations/manifests/0.5.0-beta.8.json +9 -0
  24. package/dist/migrations/manifests/0.5.0-beta.9.json +48 -0
  25. package/dist/templates/claude/settings.json +3 -0
  26. package/dist/templates/common/skills/brainstorm.md +47 -4
  27. package/dist/templates/opencode/plugins/inject-workflow-state.js +21 -7
  28. package/dist/templates/shared-hooks/inject-workflow-state.py +21 -8
  29. package/dist/templates/shared-hooks/session-start.py +14 -4
  30. package/dist/templates/trellis/config.yaml +6 -0
  31. package/dist/templates/trellis/index.d.ts +0 -1
  32. package/dist/templates/trellis/index.d.ts.map +1 -1
  33. package/dist/templates/trellis/index.js +0 -2
  34. package/dist/templates/trellis/index.js.map +1 -1
  35. package/dist/templates/trellis/scripts/common/types.py +0 -2
  36. package/dist/templates/trellis/workflow.md +8 -3
  37. package/dist/utils/project-detector.d.ts +2 -0
  38. package/dist/utils/project-detector.d.ts.map +1 -1
  39. package/dist/utils/project-detector.js +120 -11
  40. package/dist/utils/project-detector.js.map +1 -1
  41. package/dist/utils/task-json.d.ts +46 -0
  42. package/dist/utils/task-json.d.ts.map +1 -0
  43. package/dist/utils/task-json.js +49 -0
  44. package/dist/utils/task-json.js.map +1 -0
  45. package/package.json +1 -1
  46. package/dist/templates/markdown/spec/backend/directory-structure.md +0 -292
  47. package/dist/templates/markdown/spec/backend/index.md +0 -40
  48. package/dist/templates/markdown/spec/backend/script-conventions.md +0 -742
  49. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md +0 -118
  50. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md +0 -394
  51. package/dist/templates/trellis/scripts/create_bootstrap.py +0 -298
@@ -1,292 +0,0 @@
1
- # Directory Structure
2
-
3
- > How backend/CLI code is organized in this project.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- This project is a **TypeScript CLI tool** using ES modules. The source code follows a **dogfooding architecture** - Trellis uses its own configuration files (`.cursor/`, `.claude/`, `.trellis/`) as templates for new projects.
10
-
11
- ---
12
-
13
- ## Directory Layout
14
-
15
- ```
16
- src/
17
- ├── cli/ # CLI entry point and argument parsing
18
- │ └── index.ts # Main CLI entry (Commander.js setup)
19
- ├── commands/ # Command implementations
20
- │ └── init.ts # Each command in its own file
21
- ├── configurators/ # Configuration generators
22
- │ ├── index.ts # Platform registry (PLATFORM_FUNCTIONS, derived helpers)
23
- │ ├── shared.ts # Shared utilities (resolvePlaceholders)
24
- │ ├── claude.ts # Claude Code configurator
25
- │ ├── cursor.ts # Cursor configurator
26
- │ ├── iflow.ts # iFlow CLI configurator
27
- │ ├── opencode.ts # OpenCode configurator
28
- │ └── workflow.ts # Creates .trellis/ structure
29
- ├── constants/ # Shared constants and paths
30
- │ └── paths.ts # Path constants (centralized)
31
- ├── templates/ # Template utilities and generic templates
32
- │ ├── markdown/ # Generic markdown templates
33
- │ │ ├── spec/ # Spec templates (*.md.txt)
34
- │ │ ├── init-agent.md # Project root file template
35
- │ │ ├── agents.md # Project root file template
36
- │ │ ├── worktree.yaml.txt # Generic worktree config
37
- │ │ └── index.ts # Template exports
38
- │ └── extract.ts # Template extraction utilities
39
- ├── types/ # TypeScript type definitions
40
- │ └── ai-tools.ts # AI tool types and registry
41
- ├── utils/ # Shared utility functions
42
- │ ├── compare-versions.ts # Semver comparison with prerelease support
43
- │ ├── file-writer.ts # File writing with conflict handling
44
- │ ├── project-detector.ts # Project type detection
45
- │ ├── template-fetcher.ts # Remote template download from GitHub
46
- │ └── template-hash.ts # Template hash tracking for update detection
47
- └── index.ts # Package entry point (exports public API)
48
- ```
49
-
50
- ### Dogfooding Directories (Project Root)
51
-
52
- These directories are copied to `dist/` during build and used as templates:
53
-
54
- ```
55
- .cursor/ # Cursor configuration (dogfooded)
56
- ├── commands/ # Slash commands for Cursor
57
- │ ├── start.md
58
- │ ├── finish-work.md
59
- │ └── ...
60
-
61
- .claude/ # Claude Code configuration (dogfooded)
62
- ├── commands/ # Slash commands
63
- ├── agents/ # Multi-agent pipeline agents
64
- ├── hooks/ # Context injection hooks
65
- └── settings.json # Hook configuration
66
-
67
- .trellis/ # Trellis workflow (partially dogfooded)
68
- ├── scripts/ # Python scripts (dogfooded)
69
- │ ├── common/ # Shared utilities (paths.py, developer.py, etc.)
70
- │ ├── multi_agent/ # Pipeline scripts (start.py, status.py, etc.)
71
- │ ├── hooks/ # Lifecycle hook scripts (project-specific, NOT dogfooded)
72
- │ └── *.py # Main scripts (task.py, get_context.py, etc.)
73
- ├── workspace/ # Developer progress tracking
74
- │ └── index.md # Index template (dogfooded)
75
- ├── spec/ # Project guidelines (NOT dogfooded)
76
- │ ├── backend/ # Backend development docs
77
- │ ├── frontend/ # Frontend development docs
78
- │ └── guides/ # Thinking guides
79
- ├── workflow.md # Workflow documentation (dogfooded)
80
- ├── worktree.yaml # Worktree config (Trellis-specific)
81
- └── .gitignore # Git ignore rules (dogfooded)
82
- ```
83
-
84
- ---
85
-
86
- ## Dogfooding Architecture
87
-
88
- ### What is Dogfooded
89
-
90
- Files that are copied directly from Trellis project to user projects:
91
-
92
- | Source | Destination | Description |
93
- |--------|-------------|-------------|
94
- | `.cursor/` | `.cursor/` | Entire directory copied |
95
- | `.claude/` | `.claude/` | Entire directory copied |
96
- | `.trellis/scripts/` | `.trellis/scripts/` | All scripts copied |
97
- | `.trellis/workflow.md` | `.trellis/workflow.md` | Direct copy |
98
- | `.trellis/.gitignore` | `.trellis/.gitignore` | Direct copy |
99
- | `.trellis/workspace/index.md` | `.trellis/workspace/index.md` | Direct copy |
100
-
101
- ### What is NOT Dogfooded
102
-
103
- Files that use generic templates (in `src/templates/`):
104
-
105
- | Template Source | Destination | Reason |
106
- |----------------|-------------|--------|
107
- | `src/templates/markdown/spec/**/*.md.txt` | `.trellis/spec/**/*.md` | User fills with project-specific content |
108
- | `src/templates/markdown/worktree.yaml.txt` | `.trellis/worktree.yaml` | Language-agnostic template |
109
- | `src/templates/markdown/init-agent.md` | `init-agent.md` | Project root file |
110
- | `src/templates/markdown/agents.md` | `AGENTS.md` | Project root file |
111
-
112
- ### Build Process
113
-
114
- ```bash
115
- # scripts/copy-templates.js copies dogfooding sources to dist/
116
- pnpm build
117
-
118
- # Result:
119
- dist/
120
- ├── .cursor/ # From project root .cursor/
121
- ├── .claude/ # From project root .claude/
122
- ├── .trellis/ # From project root .trellis/ (filtered)
123
- │ ├── scripts/ # All scripts
124
- │ ├── workspace/
125
- │ │ └── index.md # Only index.md, no developer subdirs
126
- │ ├── workflow.md
127
- │ ├── worktree.yaml
128
- │ └── .gitignore
129
- └── templates/ # From src/templates/ (no .ts files)
130
- └── markdown/
131
- └── spec/ # Generic templates
132
- ```
133
-
134
- ---
135
-
136
- ## Module Organization
137
-
138
- ### Layer Responsibilities
139
-
140
- | Layer | Directory | Responsibility |
141
- |-------|-----------|----------------|
142
- | CLI | `cli/` | Parse arguments, display help, call commands |
143
- | Commands | `commands/` | Implement CLI commands, orchestrate actions |
144
- | Configurators | `configurators/` | Copy/generate configuration for tools |
145
- | Templates | `templates/` | Extract template content, provide utilities |
146
- | Types | `types/` | TypeScript type definitions |
147
- | Utils | `utils/` | Reusable utility functions |
148
- | Constants | `constants/` | Shared constants (paths, names) |
149
-
150
- ### Configurator Pattern
151
-
152
- Configurators use `cpSync` for direct directory copy (dogfooding):
153
-
154
- ```typescript
155
- // configurators/cursor.ts
156
- export async function configureCursor(cwd: string): Promise<void> {
157
- const sourcePath = getCursorSourcePath(); // dist/.cursor/ or .cursor/
158
- const destPath = path.join(cwd, ".cursor");
159
- cpSync(sourcePath, destPath, { recursive: true });
160
- }
161
- ```
162
-
163
- ### Template Extraction
164
-
165
- `extract.ts` provides utilities for reading dogfooded files:
166
-
167
- ```typescript
168
- // Get path to .trellis/ (works in dev and production)
169
- getTrellisSourcePath(): string
170
-
171
- // Read file from .trellis/
172
- readTrellisFile(relativePath: string): string
173
-
174
- // Copy directory from .trellis/ with executable scripts
175
- copyTrellisDir(srcRelativePath: string, destPath: string, options?: { executable?: boolean }): void
176
- ```
177
-
178
- ---
179
-
180
- ## Naming Conventions
181
-
182
- ### Files and Directories
183
-
184
- | Convention | Example | Usage |
185
- |------------|---------|-------|
186
- | `kebab-case` | `file-writer.ts` | All TypeScript files |
187
- | `kebab-case` | `multi-agent/` | All directories |
188
- | `*.ts` | `init.ts` | TypeScript source files |
189
- | `*.md.txt` | `index.md.txt` | Template files for markdown |
190
- | `*.yaml.txt` | `worktree.yaml.txt` | Template files for yaml |
191
-
192
- ### Why `.txt` Extension for Templates
193
-
194
- Templates use `.txt` extension to:
195
- - Prevent IDE markdown preview from rendering templates
196
- - Make clear these are template sources, not actual docs
197
- - Avoid confusion with actual markdown files
198
-
199
- ---
200
-
201
- ## DO / DON'T
202
-
203
- ### DO
204
-
205
- - Dogfood from project's own config files when possible
206
- - Use `cpSync` for copying entire directories
207
- - Keep generic templates in `src/templates/markdown/`
208
- - Use `.md.txt` or `.yaml.txt` for template files
209
- - Update dogfooding sources (`.cursor/`, `.claude/`, `.trellis/scripts/`) when making changes
210
- - Always use `python3` explicitly when documenting script invocation (Windows compatibility)
211
-
212
- ### DON'T
213
-
214
- - Don't hardcode file lists - copy entire directories instead
215
- - Don't duplicate content between templates and dogfooding sources
216
- - Don't put project-specific content in generic templates
217
- - Don't use dogfooding for spec/ (users fill these in)
218
-
219
- ---
220
-
221
- ## Design Decisions
222
-
223
- ### Remote Template Download (giget)
224
-
225
- **Context**: Need to download GitHub subdirectories for remote template support.
226
-
227
- **Options Considered**:
228
- 1. `degit` / `tiged` - Simple, but no programmatic API
229
- 2. `giget` - TypeScript native, has programmatic API, used by Nuxt/UnJS
230
- 3. Manual GitHub API - Too complex
231
-
232
- **Decision**: Use `giget` because:
233
- - TypeScript native with programmatic API
234
- - Supports GitHub subdirectory: `gh:user/repo/path/to/subdir`
235
- - Built-in caching for offline support
236
- - Actively maintained by UnJS ecosystem
237
-
238
- **Example**:
239
- ```typescript
240
- import { downloadTemplate } from "giget";
241
-
242
- await downloadTemplate("gh:mindfold-ai/marketplace/specs/electron-fullstack", {
243
- dir: destDir,
244
- preferOffline: true,
245
- });
246
- ```
247
-
248
- ### Directory Conflict Strategy (skip/overwrite/append)
249
-
250
- **Context**: When downloading remote templates, target directory may already exist.
251
-
252
- **Decision**: Three strategies with `skip` as default:
253
- - `skip` - Don't download if directory exists (safe default)
254
- - `overwrite` - Delete existing, download fresh
255
- - `append` - Only copy files that don't exist (merge)
256
-
257
- **Why**: giget doesn't support append natively, so we:
258
- 1. Download to temp directory
259
- 2. Walk and copy missing files only
260
- 3. Clean up temp directory
261
-
262
- **Example**:
263
- ```typescript
264
- // append strategy implementation
265
- const tempDir = path.join(os.tmpdir(), `trellis-template-${Date.now()}`);
266
- await downloadTemplate(source, { dir: tempDir });
267
- await copyMissing(tempDir, destDir); // Only copy non-existing files
268
- await fs.promises.rm(tempDir, { recursive: true });
269
- ```
270
-
271
- ### Extensible Template Type Mapping
272
-
273
- **Context**: Currently only `spec` templates, but future needs `skill`, `command`, `full` types.
274
-
275
- **Decision**: Use type field + mapping table for extensibility:
276
-
277
- ```typescript
278
- const INSTALL_PATHS: Record<string, string> = {
279
- spec: ".trellis/spec",
280
- skill: ".claude/skills",
281
- command: ".claude/commands",
282
- full: ".", // Entire project root
283
- };
284
-
285
- // Usage: auto-detect install path from template type
286
- const destDir = INSTALL_PATHS[template.type] || INSTALL_PATHS.spec;
287
- ```
288
-
289
- **Extensibility**: To add new template type:
290
- 1. Add entry to `INSTALL_PATHS`
291
- 2. Add templates to `index.json` with new type
292
- 3. No code changes needed for download logic
@@ -1,40 +0,0 @@
1
- # Backend Development Guidelines
2
-
3
- > Best practices for backend development in this project.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- This directory contains guidelines for backend development. Fill in each file with your project's specific conventions.
10
-
11
- ---
12
-
13
- ## Guidelines Index
14
-
15
- | Guide | Description | Status |
16
- |-------|-------------|--------|
17
- | [Directory Structure](./directory-structure.md) | Module organization and file layout | Done |
18
- | [Script Conventions](./script-conventions.md) | Python script standards for .trellis/scripts/ | Done |
19
- | [Error Handling](./error-handling.md) | Error types, handling strategies | Done |
20
- | [Quality Guidelines](./quality-guidelines.md) | Code standards, forbidden patterns | Done |
21
- | [Logging Guidelines](./logging-guidelines.md) | Structured logging, log levels | Done |
22
- | [Migrations](./migrations.md) | Version migration system for template files | Done |
23
- | [Database Guidelines](./database-guidelines.md) | ORM patterns, queries, migrations | N/A (CLI project) |
24
-
25
- ---
26
-
27
- ## How to Fill These Guidelines
28
-
29
- For each guideline file:
30
-
31
- 1. Document your project's **actual conventions** (not ideals)
32
- 2. Include **code examples** from your codebase
33
- 3. List **forbidden patterns** and why
34
- 4. Add **common mistakes** your team has made
35
-
36
- The goal is to help AI assistants and new team members understand how YOUR project works.
37
-
38
- ---
39
-
40
- **Language**: All documentation should be written in **English**.