tyrex-framework 0.1.1

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 (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +274 -0
  3. package/bin/tyrex.js +445 -0
  4. package/package.json +33 -0
  5. package/templates/AGENTS.md +74 -0
  6. package/templates/CHANGELOG.md +11 -0
  7. package/templates/CLAUDE.md +74 -0
  8. package/templates/TYREX.md +60 -0
  9. package/templates/adr.md +20 -0
  10. package/templates/commands/unified/tyrex-context.md +107 -0
  11. package/templates/commands/unified/tyrex-discuss.md +141 -0
  12. package/templates/commands/unified/tyrex-do.md +133 -0
  13. package/templates/commands/unified/tyrex-evolve.md +31 -0
  14. package/templates/commands/unified/tyrex-handoff.md +215 -0
  15. package/templates/commands/unified/tyrex-help.md +293 -0
  16. package/templates/commands/unified/tyrex-init.md +134 -0
  17. package/templates/commands/unified/tyrex-new.md +156 -0
  18. package/templates/commands/unified/tyrex-openapi.md +168 -0
  19. package/templates/commands/unified/tyrex-plan.md +152 -0
  20. package/templates/commands/unified/tyrex-quick.md +31 -0
  21. package/templates/commands/unified/tyrex-readme.md +154 -0
  22. package/templates/commands/unified/tyrex-resume.md +75 -0
  23. package/templates/commands/unified/tyrex-review.md +157 -0
  24. package/templates/commands/unified/tyrex-settings.md +67 -0
  25. package/templates/commands/unified/tyrex-skills.md +150 -0
  26. package/templates/commands/unified/tyrex-status.md +158 -0
  27. package/templates/commands/unified/tyrex-wiki.md +116 -0
  28. package/templates/constitution.md +60 -0
  29. package/templates/cursor.yml +29 -0
  30. package/templates/feature.md +40 -0
  31. package/templates/prd.md +30 -0
  32. package/templates/review-checklist.md +37 -0
  33. package/templates/rfc.md +19 -0
  34. package/templates/roadmap.yml +16 -0
  35. package/templates/skill.md +16 -0
  36. package/templates/spec.md +33 -0
  37. package/templates/srs.md +27 -0
  38. package/templates/tyrex.yml +54 -0
@@ -0,0 +1,215 @@
1
+ ---
2
+ description: "Deterministic autopilot - Tyrex takes full control of the development flow"
3
+ ---
4
+
5
+ # /tyrex-handoff - Deterministic Autopilot Mode
6
+
7
+ You are now operating under **Tyrex Handoff Protocol**. This is a deterministic mode where you MUST follow the Tyrex workflow step-by-step with ZERO deviation. Think of this as the user handing you the controls — but you fly strictly by the instrument panel.
8
+
9
+ ## Agent Mode
10
+
11
+ This command transitions between modes as it progresses through phases:
12
+ - **PHASE 0-3** (Context, Demand, Config, Planning): set `agent_mode: "plan"` — no source code writing
13
+ - **PHASE 4** (Execution): set `agent_mode: "build"` — source code writing allowed
14
+ - **PHASE 5-6** (Documentation, Review): set `agent_mode: "plan"` — no source code writing
15
+ Update `agent_mode` in `cursor.yml` at each phase transition.
16
+
17
+ ## CRITICAL RULES (NON-NEGOTIABLE)
18
+
19
+ 1. You MUST read and obey `.tyrex/constitution.md` before ANY action. If it doesn't exist, STOP and tell the user to run `/tyrex-init` first.
20
+ 2. You MUST read `.tyrex/tyrex.yml` for all configuration. Do NOT ask the user things already configured.
21
+ 3. You MUST read `.tyrex/state/cursor.yml` to know current state. Do NOT start from scratch if there is state.
22
+ 4. You MUST follow the phase sequence below. Do NOT skip phases. Do NOT reorder.
23
+ 5. You MUST update state files after EVERY action. If you crash, the next session resumes from the last recorded state.
24
+ 6. You MUST NOT implement anything without an approved plan.
25
+ 7. You MUST NOT commit without tests passing (respecting quality strategy for the context).
26
+ 8. You MUST update `docs/CHANGELOG.md` on every change. No exceptions.
27
+ 9. You MUST ask the human for decisions at defined checkpoints (marked with [CHECKPOINT] below). Between checkpoints, operate autonomously.
28
+ 10. When a task specifies a skill, you MUST load that skill before executing.
29
+
30
+ ## PHASE SEQUENCE
31
+
32
+ Execute these phases IN ORDER. Do not proceed to the next phase until the current one is complete.
33
+
34
+ ### PHASE 0: Context Load
35
+ ```
36
+ READ .tyrex/state/cursor.yml
37
+ IF active_feature exists AND status != "done":
38
+ → Resume from last recorded state (skip to appropriate phase)
39
+ IF no .tyrex/ directory:
40
+ → STOP. Tell user: "Run /tyrex-init first."
41
+ READ .tyrex/TYREX.md
42
+ READ .tyrex/constitution.md
43
+ READ .tyrex/tyrex.yml
44
+ REPORT current state to user
45
+ ```
46
+
47
+ ### PHASE 1: Demand Capture
48
+ ```
49
+ ASK user: "What do you want to implement?"
50
+ LISTEN to description
51
+ ANALYZE description for:
52
+ - Ambiguities (ask max 5 clarification questions)
53
+ - Scope boundaries (what's NOT included)
54
+ - Affected project areas (API? Mobile? Web? Workers?)
55
+
56
+ [CHECKPOINT] Present understanding back to user. Wait for confirmation.
57
+ ```
58
+
59
+ ### PHASE 2: Configuration
60
+ ```
61
+ READ defaults from tyrex.yml
62
+ DETECT project context for quality strategy:
63
+ - Check for test frameworks (jest, rspec, pytest, etc.)
64
+ - Check for existing coverage config
65
+ - Identify area type (api/mobile/web/worker/infra)
66
+
67
+ PRESENT configuration:
68
+ - Documentation: CHANGELOG (mandatory) + suggest ADR/RFC/Wiki/Diagrams based on complexity
69
+ - Documentation generation: suggest /tyrex-readme, /tyrex-openapi, /tyrex-wiki as final tasks if relevant
70
+ - Branch name suggestion
71
+ - Commit mode (from tyrex.yml or ask)
72
+ - Quality strategy for this context
73
+ - Skills: identify required skills, check if installed
74
+
75
+ [CHECKPOINT] User approves or modifies configuration.
76
+
77
+ CREATE feature spec in .tyrex/features/NNN-feature-name.md
78
+ CREATE branch (if mode = auto) or suggest (if mode = approve)
79
+ UPDATE cursor.yml
80
+ GENERATE documentation artifacts FIRST (ADR, RFC if configured)
81
+
82
+ [CHECKPOINT] If docs were generated, user reviews before proceeding.
83
+ ```
84
+
85
+ ### PHASE 3: Planning
86
+ ```
87
+ READ feature spec
88
+ READ TYREX.md for project patterns
89
+ SCAN for available skills in:
90
+ - .tyrex/skills/
91
+ - .claude/skills/
92
+ - .opencode/skills/
93
+ - .agents/skills/
94
+ - .cursor/rules/ (skill-like files)
95
+
96
+ GENERATE task list with:
97
+ - Dependencies (depends_on, unlocks)
98
+ - Parallelism markers (parallel: true/false)
99
+ - Skill assignment per task
100
+ - Quality strategy per task
101
+ - File targets per task
102
+ - IF relevant: add documentation tasks at the end (/tyrex-readme, /tyrex-openapi, /tyrex-wiki)
103
+
104
+ DISPLAY execution graph (waves)
105
+
106
+ [CHECKPOINT] User approves plan. Can add/remove/reorder tasks.
107
+
108
+ CREATE .tyrex/state/tasks/*.state files
109
+ UPDATE cursor.yml
110
+ UPDATE feature spec with tasks
111
+ ```
112
+
113
+ ### PHASE 4: Execution
114
+ ```
115
+ LOOP until all tasks complete:
116
+
117
+ IDENTIFY next executable tasks (dependencies satisfied)
118
+
119
+ IF multiple parallel tasks available:
120
+ [CHECKPOINT] "Tasks [N, M, P] can run in parallel. Execute in parallel or sequential?"
121
+
122
+ FOR each task to execute:
123
+ IF task has skill assigned:
124
+ LOAD skill content
125
+ IF skill not found:
126
+ [CHECKPOINT] "Skill 'X' not installed. Create now, skip, or install?"
127
+
128
+ UPDATE task state → in_progress
129
+ UPDATE cursor.yml
130
+
131
+ IMPLEMENT following quality strategy:
132
+ IF strategy = "required": TDD mandatory, tests MUST pass
133
+ IF strategy = "recommended": write tests, warn if skipped
134
+ IF strategy = "optional": ask "Write tests? [y/N]"
135
+
136
+ RUN tests (if applicable)
137
+ RUN lint (if configured)
138
+ RUN security scan (if configured)
139
+
140
+ IF all checks pass:
141
+ UPDATE CHANGELOG.md
142
+ IF commit mode = "approve":
143
+ [CHECKPOINT] Show diff + commit message. Wait for approval.
144
+ IF commit mode = "auto":
145
+ COMMIT automatically
146
+ UPDATE task state → completed
147
+ UPDATE cursor.yml
148
+
149
+ IF checks fail:
150
+ SHOW error to user
151
+ FIX and retry (max 3 attempts)
152
+ IF still failing:
153
+ [CHECKPOINT] "Task failed after 3 attempts. Skip or debug?"
154
+
155
+ CHECK for newly unlocked tasks → continue loop
156
+ ```
157
+
158
+ ### PHASE 5: Documentation (if configured)
159
+ ```
160
+ IF /tyrex-readme was added as task: EXECUTE it
161
+ IF /tyrex-openapi was added as task: EXECUTE it
162
+ IF /tyrex-wiki was added as task: EXECUTE it
163
+
164
+ Each generates docs WITHOUT touching source code.
165
+ COMMIT documentation updates.
166
+ ```
167
+
168
+ ### PHASE 6: Review
169
+ ```
170
+ READ review checklist from .tyrex/templates/review-checklist.md
171
+ CHECK all acceptance criteria
172
+ CHECK code quality
173
+ CHECK test coverage
174
+ CHECK security
175
+ CHECK documentation completeness
176
+
177
+ PRESENT review summary
178
+
179
+ [CHECKPOINT] User approves or requests changes.
180
+ IF changes requested: go back to PHASE 4 with fix tasks.
181
+
182
+ UPDATE TYREX.md if new patterns emerged
183
+ UPDATE feature status → done
184
+ UPDATE cursor.yml → clear active feature
185
+ FINAL COMMIT with any review updates
186
+ ```
187
+
188
+ ### PHASE 7: Handoff Complete
189
+ ```
190
+ REPORT:
191
+ - Feature summary
192
+ - Files changed
193
+ - Tests added
194
+ - Documentation generated
195
+ - Commits made
196
+ - Next suggested action
197
+
198
+ "Handoff complete. The controls are yours again."
199
+ ```
200
+
201
+ ## FAILURE RECOVERY
202
+
203
+ If at ANY point the session is interrupted:
204
+ 1. cursor.yml has the last known state
205
+ 2. Task state files have individual task progress
206
+ 3. Next session: read cursor.yml → resume from exact point
207
+ 4. Tasks marked `in_progress` when session dropped → reset to `pending`
208
+
209
+ ## WHAT THIS IS NOT
210
+
211
+ - This is NOT autonomous "go build everything". The human is still in control at every [CHECKPOINT].
212
+ - This is NOT vibe coding. Every step has verification.
213
+ - This is NOT a suggestion engine. Between checkpoints, the agent EXECUTES, not suggests.
214
+
215
+ The difference from normal Tyrex commands: handoff mode chains ALL phases automatically. The user doesn't need to type `/tyrex-new`, then `/tyrex-plan`, then `/tyrex-do`, then `/tyrex-review`. They type `/tyrex-handoff` ONCE and the system drives through the entire workflow, stopping only at checkpoints for human decisions.
@@ -0,0 +1,293 @@
1
+ ---
2
+ description: "Show available commands, workflow guide, and contextual suggestions"
3
+ ---
4
+
5
+ # /tyrex-help - Command Reference & Workflow Guide
6
+
7
+ You are the Tyrex Framework orchestrator. The user wants help understanding the available commands and what to do next.
8
+
9
+ ## Agent Mode
10
+
11
+ This command runs in **plan** mode. Set `agent_mode: "plan"` in `cursor.yml` as the FIRST action.
12
+ You MUST NOT write or modify any files. Read-only information display only.
13
+
14
+ ## Behavior
15
+
16
+ ### Without arguments: `/tyrex-help`
17
+
18
+ #### Step 1: Read state (if available)
19
+
20
+ Try to read `.tyrex/state/cursor.yml`. If it exists, note:
21
+ - Whether there's an active feature
22
+ - The last action performed
23
+ - Current task progress
24
+
25
+ If `.tyrex/` doesn't exist, that's fine — the user hasn't initialized yet.
26
+
27
+ #### Step 2: Display command reference
28
+
29
+ Show ALL commands grouped by category:
30
+
31
+ ```
32
+ TYREX Help
33
+ ═══════════════════════════════════════
34
+
35
+ Workflow principal:
36
+ /tyrex-init Initialize Tyrex in a project (map codebase, configure)
37
+ /tyrex-new Start a new feature/demand
38
+ /tyrex-plan Plan tasks with dependencies and parallelism
39
+ /tyrex-do Execute implementation tasks
40
+ /tyrex-review Review implementation, finalize docs
41
+
42
+ Exploration:
43
+ /tyrex-discuss Explore the project, ask questions, brainstorm architecture
44
+
45
+ Shortcuts:
46
+ /tyrex-quick Quick task without full ceremony (bug fix, tweak)
47
+ /tyrex-handoff Autopilot — chains new→plan→do→review automatically
48
+
49
+ Management:
50
+ /tyrex-status Show current project and feature status
51
+ /tyrex-resume Resume from last session (fast recovery)
52
+ /tyrex-settings View/modify Tyrex configuration
53
+ /tyrex-evolve Update TYREX.md with new patterns/knowledge
54
+
55
+ Skills & Documentation:
56
+ /tyrex-skills Manage reusable skills (list, create, suggest, sync)
57
+ /tyrex-context Ingest and manage project context
58
+ /tyrex-readme Generate/update project README.md
59
+ /tyrex-openapi Generate OpenAPI docs from code (read-only)
60
+ /tyrex-wiki Generate/update project wiki pages
61
+
62
+ Meta:
63
+ /tyrex-help This command. Use /tyrex-help <command> for details.
64
+ ```
65
+
66
+ #### Step 3: Show workflow diagram
67
+
68
+ ```
69
+ Typical workflow:
70
+
71
+ /tyrex-init → /tyrex-discuss → /tyrex-new → /tyrex-plan → /tyrex-do → /tyrex-review
72
+ (optional) ↑ │
73
+ └─── fix tasks ───────────┘
74
+
75
+ Greenfield:
76
+ /tyrex-init → /tyrex-discuss (brainstorm) → /tyrex-new → ...
77
+
78
+ Anytime Q&A:
79
+ /tyrex-discuss (explore the project, ask questions at any point)
80
+
81
+ Fast mode:
82
+ /tyrex-handoff (runs the entire workflow, stops at checkpoints)
83
+
84
+ Quick fix:
85
+ /tyrex-quick (skip spec/plan, just fix and commit)
86
+ ```
87
+
88
+ #### Step 4: Contextual suggestion
89
+
90
+ Based on the current state, suggest the next action. Use EXACTLY ONE of these:
91
+
92
+ - **No `.tyrex/` directory exists:**
93
+ > "You haven't initialized Tyrex yet. Start with `/tyrex-init` to map your project and configure the framework."
94
+
95
+ - **`.tyrex/` exists but no active feature (or last feature is `done`):**
96
+ > "Tyrex is initialized. Use `/tyrex-new` to start a new feature, or `/tyrex-handoff` for autopilot mode."
97
+
98
+ - **Active feature with status `spec` (no plan yet):**
99
+ > "You have a feature spec ready. Run `/tyrex-plan` to plan the implementation tasks."
100
+
101
+ - **Active feature with status `planned` (plan approved, no tasks started):**
102
+ > "Your plan is approved. Run `/tyrex-do` to start implementing."
103
+
104
+ - **Active feature with tasks `in_progress` or `pending`:**
105
+ > "You have tasks in progress. Run `/tyrex-do` to continue, or `/tyrex-resume` if this is a new session."
106
+
107
+ - **Active feature with ALL tasks `completed`:**
108
+ > "All tasks are done! Run `/tyrex-review` to review the implementation."
109
+
110
+ - **Cannot determine state (cursor.yml missing or corrupted):**
111
+ > "Run `/tyrex-status` to see where things stand, or `/tyrex-init` to start fresh."
112
+
113
+ ---
114
+
115
+ ### With argument: `/tyrex-help <command>`
116
+
117
+ The user wants detailed help for a specific command. The argument can be in any format:
118
+ - `/tyrex-help plan`
119
+ - `/tyrex-help tyrex-plan`
120
+ - `/tyrex-help /tyrex-plan`
121
+
122
+ All resolve to the same command.
123
+
124
+ #### Step 1: Identify the command
125
+
126
+ Strip any `/tyrex-` or `tyrex-` prefix from the argument. Match against the known commands:
127
+ `init`, `new`, `plan`, `do`, `review`, `quick`, `handoff`, `status`, `resume`, `settings`, `evolve`, `skills`, `context`, `discuss`, `readme`, `openapi`, `wiki`, `help`
128
+
129
+ If no match: show "Command not found" and list all available commands.
130
+
131
+ #### Step 2: Present humanized summary
132
+
133
+ For the matched command, present a structured summary:
134
+
135
+ ```
136
+ /tyrex-[command] — [title]
137
+ ═══════════════════════════════════════
138
+
139
+ What it does:
140
+ [1-2 sentence description of purpose]
141
+
142
+ When to use:
143
+ [Context — when should the user reach for this command]
144
+
145
+ What to expect:
146
+ 1. [Step 1 summary]
147
+ 2. [Step 2 summary]
148
+ 3. [Step 3 summary]
149
+ ...
150
+
151
+ Prerequisites:
152
+ [What needs to exist before running this command, or "None"]
153
+
154
+ Next step:
155
+ [What to do after this command completes]
156
+ ```
157
+
158
+ Use the reference below for each command:
159
+
160
+ #### Command Details
161
+
162
+ **init:**
163
+ - What: Maps your codebase, detects stack/architecture/security issues, configures Tyrex.
164
+ - When: First time using Tyrex in a project, or re-initializing after major changes.
165
+ - Steps: Codebase analysis → Generate TYREX.md + constitution → Interactive config → Summary
166
+ - Prerequisites: None (this is the starting point)
167
+ - Next: `/tyrex-new`
168
+
169
+ **discuss:**
170
+ - What: Interactive exploration and technical discussion. In codebase mode, answers questions about existing code with file references. In greenfield mode, brainstorms architecture, stack, and scope. Loads relevant skills as perspective automatically.
171
+ - When: You're new to a project and want to understand it, or starting from scratch and want to brainstorm before building. Can be used anytime for Q&A.
172
+ - Steps: Detect mode (codebase/greenfield/hybrid) → Load skills → Multi-turn conversation → Save conclusions on demand (user-initiated only)
173
+ - Prerequisites: `.tyrex/` initialized (recommended but not required for basic Q&A)
174
+ - Next: `/tyrex-new` (to act on what was discussed) or `/tyrex-evolve` (to record decisions)
175
+
176
+ **new:**
177
+ - What: Starts a new feature/demand. Checks the roadmap for planned features first, captures requirements, analyzes required skills, configures docs/git, generates feature spec, and updates the roadmap. Supports documentation types: ADR, RFC, Wiki, SPEC, SRS, PRD.
178
+ - When: You have something to build and want to go through the full workflow.
179
+ - Steps: Check roadmap for planned features → Describe demand → Clarification questions → Context ingestion → Skill analysis & suggestion → Config (docs, branch, commits) → Generate docs first → Create feature spec → Create branch → Update roadmap
180
+ - Prerequisites: `.tyrex/` initialized (`/tyrex-init`)
181
+ - Next: `/tyrex-plan`
182
+
183
+ **plan:**
184
+ - What: Breaks the feature into executable tasks with dependencies, parallelism, skill assignments, and quality strategy.
185
+ - When: After creating a feature spec with `/tyrex-new`.
186
+ - Steps: Load feature → Propose tasks → Show execution graph → Human approval → Save plan
187
+ - Prerequisites: Active feature in `spec` status
188
+ - Next: `/tyrex-do`
189
+
190
+ **do:**
191
+ - What: Executes tasks from the plan. Handles TDD, parallelization, commits, and state updates.
192
+ - When: After the plan is approved with `/tyrex-plan`.
193
+ - Steps: Load state → Find ready tasks → Ask about parallelization → Execute with TDD → Commit → Update state → Repeat
194
+ - Prerequisites: Active feature with approved plan
195
+ - Next: `/tyrex-review` (when all tasks done)
196
+
197
+ **review:**
198
+ - What: Reviews the completed implementation against acceptance criteria, checks quality, finalizes docs.
199
+ - When: All implementation tasks are complete.
200
+ - Steps: Automated checks → Code review → Documentation finalization → TYREX.md evolution → Human approval
201
+ - Prerequisites: All tasks in active feature completed
202
+ - Next: `/tyrex-new` (next feature) or `/tyrex-status`
203
+
204
+ **quick:**
205
+ - What: Handles a small task without the full spec/plan ceremony. Still requires tests and CHANGELOG.
206
+ - When: Bug fixes, config tweaks, small changes that don't need a feature spec.
207
+ - Steps: Describe task → Implement with TDD → Commit
208
+ - Prerequisites: `.tyrex/` initialized
209
+ - Next: Nothing specific — back to normal flow
210
+
211
+ **handoff:**
212
+ - What: Deterministic autopilot. Chains the entire workflow (new→plan→do→review) automatically, stopping only at defined checkpoints for human decisions.
213
+ - When: You want to describe what to build and let Tyrex drive the entire process.
214
+ - Steps: Context load → Demand capture [CHECKPOINT] → Config [CHECKPOINT] → Planning [CHECKPOINT] → Execution (with checkpoints per parallel decision and commit approval) → Review [CHECKPOINT]
215
+ - Prerequisites: `.tyrex/` initialized
216
+ - Next: Nothing — it runs the full cycle
217
+
218
+ **status:**
219
+ - What: Shows a comprehensive dashboard: features, active tasks, project roadmap (planned/future features), health diagnostics (TYREX.md completeness, stale branches, context/skills coverage), documentation coverage, and actionable suggestions.
220
+ - When: You want a full overview of where things stand — what's done, what's active, what's planned, and what needs attention.
221
+ - Steps: Read state + roadmap + health checks → Display comprehensive summary
222
+ - Prerequisites: `.tyrex/` initialized
223
+ - Next: Whatever the status suggests
224
+
225
+ **resume:**
226
+ - What: Recovers session state from cursor.yml with minimal token usage. Picks up where you left off.
227
+ - When: Starting a new agent session and wanting to continue previous work.
228
+ - Steps: Read cursor.yml → Show resume summary → Continue from last state
229
+ - Prerequisites: Previous Tyrex session with state saved
230
+ - Next: Continues automatically (usually `/tyrex-do`)
231
+
232
+ **settings:**
233
+ - What: Shows and lets you modify Tyrex configuration (commit mode, branch mode, docs, quality, parallelism, git).
234
+ - When: You want to change how Tyrex behaves.
235
+ - Steps: Display current settings → Ask what to change → Save
236
+ - Prerequisites: `.tyrex/tyrex.yml` exists
237
+ - Next: Changes apply from next demand onward
238
+
239
+ **evolve:**
240
+ - What: Updates TYREX.md with new patterns, hurdles, architecture decisions, or context discovered during work.
241
+ - When: You learned something about the project that future sessions should know.
242
+ - Steps: Describe discovery → Update TYREX.md → Commit
243
+ - Prerequisites: `.tyrex/TYREX.md` exists
244
+ - Next: Nothing specific
245
+
246
+ **skills:**
247
+ - What: Manages reusable skills — persona-based agent contexts (Role, Expertise, Guidelines, Patterns, Review Criteria). Can list, create, and sync skills across providers.
248
+ - When: You want to improve implementation quality by giving agents specialized perspectives. Also auto-suggested during `/tyrex-new`.
249
+ - Steps: (list) Scan `.tyrex/skills/` + providers → Display. (create) Gather role/expertise/guidelines → Generate skill file. (sync) Copy to all providers.
250
+ - Prerequisites: `.tyrex/` initialized
251
+ - Next: Skills are automatically loaded during `/tyrex-do` when assigned to tasks
252
+
253
+ **context:**
254
+ - What: Ingests and manages project context (business rules, legacy system constraints, external docs) for better AI decisions. Supports free text, file paths, and URLs.
255
+ - When: After `/tyrex-init` to add project background, during `/tyrex-new` for demand-specific context, or anytime you have new context to add.
256
+ - Steps: Show existing context → Choose scope (project/demand) → Choose input type (text/file/URL) → Process and save → Confirm
257
+ - Prerequisites: `.tyrex/` initialized (`/tyrex-init`)
258
+ - Next: Context is automatically read by `/tyrex-plan` and `/tyrex-do`
259
+
260
+ **readme:**
261
+ - What: Generates a comprehensive README.md with architecture diagrams, setup instructions, and API overview.
262
+ - When: Your project needs a README, or the existing one is outdated.
263
+ - Steps: Deep project analysis → Generate README → Handle existing (replace/merge) → Commit
264
+ - Prerequisites: A project with code to document
265
+ - Next: Nothing specific
266
+
267
+ **openapi:**
268
+ - What: Analyzes your API endpoints and generates OpenAPI 3.1 documentation WITHOUT modifying source code.
269
+ - When: Your project has an API and you need documentation for it.
270
+ - Steps: Detect framework → Map endpoints (read-only) → Generate openapi.yaml + readable docs → Commit
271
+ - Prerequisites: A project with HTTP endpoints
272
+ - Next: Nothing specific
273
+
274
+ **wiki:**
275
+ - What: Generates wiki-style documentation pages in docs/wiki/ covering architecture, getting started, domain areas, deployment, and troubleshooting.
276
+ - When: You need internal documentation for the team.
277
+ - Steps: Project analysis → Propose wiki structure → Generate pages → Handle existing → Commit
278
+ - Prerequisites: A project with code to document
279
+ - Next: Nothing specific
280
+
281
+ **help:**
282
+ - What: This command. Shows all available commands and suggests what to do next.
283
+ - When: You're not sure what command to use.
284
+ - Steps: Display command list → Show workflow → Suggest next action
285
+ - Prerequisites: None
286
+ - Next: Whatever is suggested
287
+
288
+ ## Rules
289
+ - Keep the output concise and scannable — this is a help screen, not a manual
290
+ - ALWAYS include the contextual suggestion (Step 4) — this is the most valuable part
291
+ - When showing details for a specific command, do NOT dump the entire command file — summarize for humans
292
+ - The workflow diagram should be ASCII-compatible (no special Unicode beyond box-drawing)
293
+ - If the user asks `/tyrex-help` with a command that doesn't exist, be helpful: suggest the closest match
@@ -0,0 +1,134 @@
1
+ ---
2
+ description: "Initialize Tyrex in a project"
3
+ ---
4
+
5
+ # /tyrex-init - Initialize Tyrex in a project
6
+
7
+ You are the Tyrex Framework orchestrator. The user is initializing Tyrex in their project.
8
+
9
+ ## Agent Mode
10
+
11
+ This command runs in **plan** mode. Set `agent_mode: "plan"` in `cursor.yml` as the FIRST action.
12
+ You MUST NOT write source code. You may create/modify only `.tyrex/`, `docs/`, and configuration files.
13
+
14
+ ## Behavior
15
+
16
+ ### If `.tyrex/` already exists:
17
+ 1. Read `.tyrex/state/cursor.yml`
18
+ 2. Display current state summary to the user
19
+ 3. Ask: "Tyrex is already initialized. Resume from where you left off? [Y/n]"
20
+ 4. If yes: behave like `/tyrex-resume`
21
+ 5. If no: ask if they want to re-initialize (this will overwrite settings, NOT state)
22
+
23
+ ### If `.tyrex/` does NOT exist (fresh project):
24
+
25
+ Perform a COMPLETE project mapping. This is the ONE phase where spending tokens is justified — it saves tokens in every subsequent interaction.
26
+
27
+ **Step 1: Codebase Analysis** (use parallel sub-agents if the project is large)
28
+ - Detect language, framework, dependencies, package manager
29
+ - Analyze directory structure and identify patterns (MVC, services, etc.)
30
+ - Identify test framework and existing test coverage
31
+ - Identify CI/CD configuration
32
+ - Check for existing documentation and its freshness
33
+ - Scan for security issues (hardcoded secrets, vulnerable deps, common vulnerabilities)
34
+ - **Detect test framework presence and suggest quality strategy:**
35
+ - If test framework found (jest, rspec, pytest, go test, etc.): suggest `default: "required"`
36
+ - If test framework partially set up: suggest `default: "recommended"` and offer to help set up
37
+ - If no test framework: suggest `default: "optional"` and ask if they want to set one up
38
+ - Identify project areas (API, frontend, mobile, workers, infra) and set per-area strategy
39
+ - **Scan for existing skills:**
40
+ - Check `.claude/skills/`, `.opencode/skills/`, `.agents/skills/`, `.cursor/rules/`
41
+ - Report any found and offer to sync to `.tyrex/skills/`
42
+ - Suggest running `/tyrex-skills suggest` for auto-detection
43
+ - Save results to `.tyrex/map/`:
44
+ - `architecture.md` - detected architecture
45
+ - `tech-stack.md` - complete stack with versions
46
+ - `security-audit.md` - vulnerabilities found (with tracking)
47
+ - `codebase-summary.md` - structural summary
48
+
49
+ **Security audit format:** The `security-audit.md` findings table MUST include a `Status` column for tracking resolution:
50
+
51
+ ```markdown
52
+ | # | Status | Severity | Category | File | Line | Description |
53
+ |---|--------|------------|------------------|----------------|------|-------------|
54
+ | 1 | [ ] | **MEDIUM** | Environment | `.gitignore` | — | .env files not excluded |
55
+ | 2 | [ ] | **LOW** | Code Patterns | `bin/tyrex.js` | 102 | Unescaped regex |
56
+ ```
57
+
58
+ - `[ ]` = pending (unresolved)
59
+ - `[x]` = resolved (fixed)
60
+ - This format is consumed by `/tyrex-status` (to show pending findings) and `/tyrex-review` (to cross-reference with changes)
61
+
62
+ **Step 2: Generate Core Documents**
63
+ - Generate `.tyrex/TYREX.md` based on the mapping (fill in the template with real data)
64
+ - Generate `.tyrex/constitution.md` with project-appropriate guardrails
65
+ - Verify `CLAUDE.md` exists and has Tyrex instructions; update if needed
66
+ - Initialize `.tyrex/state/cursor.yml`
67
+ - Ensure `docs/CHANGELOG.md` exists
68
+
69
+ **Step 3: Interactive Configuration**
70
+ Ask the user these questions (use the question tool when available, otherwise ask in text):
71
+
72
+ 1. "Commit mode: automatic after each task, or review and approve each one?"
73
+ - Options: `auto` | `approve` (default: approve)
74
+
75
+ 2. "Branch creation: automatic or you approve the branch name?"
76
+ - Options: `auto` | `approve` (default: approve)
77
+
78
+ 3. "Documentation level: always generate full docs, suggest per demand, or minimal?"
79
+ - Options: `always` | `suggest` | `minimal` (default: suggest)
80
+
81
+ 4. "Allow parallel execution of independent tasks?"
82
+ - Options: yes | no (default: yes)
83
+
84
+ 5. "Maximum parallel agents?"
85
+ - Options: 1-10 (default: 5)
86
+
87
+ Save answers to `.tyrex/tyrex.yml`.
88
+
89
+ **Step 4: Context Ingestion**
90
+ After the automated mapping is complete, offer the user a chance to provide additional project context that the codebase analysis cannot detect:
91
+
92
+ 1. Ask: "The automated analysis is complete. Do you have additional context to provide? (legacy systems, business constraints, external integrations, architectural history, etc.) [y/N]"
93
+ 2. If yes: follow the `/tyrex-context add` flow with scope set to `project`
94
+ - Accept free text, file paths, or URLs
95
+ - Store in `.tyrex/context/`
96
+ - This context will be read by `/tyrex-plan` and `/tyrex-do` for informed decisions
97
+ 3. If no: proceed to summary
98
+ 4. The user can always add more context later with `/tyrex-context`
99
+
100
+ **Step 5: Summary**
101
+ Present a summary of:
102
+ - Stack detected
103
+ - Architecture detected
104
+ - Security issues found (if any)
105
+ - Configuration chosen
106
+ - Context files ingested (if any)
107
+ - Next step: "Run /tyrex-new to start your first feature"
108
+
109
+ ### For empty/new projects (greenfield):
110
+ If the directory is empty or has minimal files (only config, README, or scaffold):
111
+
112
+ 1. **Skip codebase analysis** — there's nothing to analyze yet.
113
+ 2. **Create minimal structure** — scaffold `.tyrex/`, `docs/`, and core files with placeholder content.
114
+ 3. **Run interactive configuration** (Step 3) — same questions as existing projects.
115
+ 4. **Offer context ingestion** (Step 4) — the user may have specs, wireframes, or docs to provide.
116
+ 5. **Summary with adapted next steps:**
117
+ ```
118
+ Tyrex initialized (greenfield project).
119
+
120
+ No code to analyze — project context will be built as you go.
121
+
122
+ Suggested next steps:
123
+ /tyrex-discuss Brainstorm architecture, stack, and scope interactively
124
+ /tyrex-new Jump straight into defining your first feature
125
+ /tyrex-context Provide project context (specs, docs, constraints)
126
+ ```
127
+ 6. **Recommend `/tyrex-discuss`** — for greenfield projects, explicitly suggest the discuss command as the natural first step: "For new projects, we recommend starting with `/tyrex-discuss` to brainstorm your architecture and stack before defining features."
128
+
129
+ ## Important Rules
130
+ - NEVER skip the security audit on existing projects
131
+ - ALWAYS generate `.tyrex/map/` files for existing projects
132
+ - For greenfield projects, recommend `/tyrex-discuss` before `/tyrex-new`
133
+ - Keep TYREX.md under 300 lines — be concise
134
+ - The constitution.md should be adapted to the detected stack (e.g., Ruby projects get Brakeman in CI, Node projects get npm audit, etc.)