@shakudo/opencode-mattermost-control 0.3.45

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 (69) hide show
  1. package/.opencode/command/mattermost-connect.md +5 -0
  2. package/.opencode/command/mattermost-disconnect.md +5 -0
  3. package/.opencode/command/mattermost-monitor.md +12 -0
  4. package/.opencode/command/mattermost-status.md +5 -0
  5. package/.opencode/command/speckit.analyze.md +184 -0
  6. package/.opencode/command/speckit.checklist.md +294 -0
  7. package/.opencode/command/speckit.clarify.md +181 -0
  8. package/.opencode/command/speckit.constitution.md +82 -0
  9. package/.opencode/command/speckit.implement.md +135 -0
  10. package/.opencode/command/speckit.plan.md +89 -0
  11. package/.opencode/command/speckit.specify.md +258 -0
  12. package/.opencode/command/speckit.tasks.md +137 -0
  13. package/.opencode/command/speckit.taskstoissues.md +30 -0
  14. package/.opencode/plugin/mattermost-control/event-handlers/compaction.ts +61 -0
  15. package/.opencode/plugin/mattermost-control/event-handlers/file.ts +36 -0
  16. package/.opencode/plugin/mattermost-control/event-handlers/index.ts +14 -0
  17. package/.opencode/plugin/mattermost-control/event-handlers/message.ts +124 -0
  18. package/.opencode/plugin/mattermost-control/event-handlers/permission.ts +34 -0
  19. package/.opencode/plugin/mattermost-control/event-handlers/question.ts +92 -0
  20. package/.opencode/plugin/mattermost-control/event-handlers/session.ts +100 -0
  21. package/.opencode/plugin/mattermost-control/event-handlers/todo.ts +33 -0
  22. package/.opencode/plugin/mattermost-control/event-handlers/tool.ts +76 -0
  23. package/.opencode/plugin/mattermost-control/formatters.ts +202 -0
  24. package/.opencode/plugin/mattermost-control/index.ts +964 -0
  25. package/.opencode/plugin/mattermost-control/package.json +12 -0
  26. package/.opencode/plugin/mattermost-control/state.ts +180 -0
  27. package/.opencode/plugin/mattermost-control/timers.ts +96 -0
  28. package/.opencode/plugin/mattermost-control/tools/connect.ts +563 -0
  29. package/.opencode/plugin/mattermost-control/tools/file.ts +41 -0
  30. package/.opencode/plugin/mattermost-control/tools/index.ts +12 -0
  31. package/.opencode/plugin/mattermost-control/tools/monitor.ts +183 -0
  32. package/.opencode/plugin/mattermost-control/tools/schedule.ts +253 -0
  33. package/.opencode/plugin/mattermost-control/tools/session.ts +120 -0
  34. package/.opencode/plugin/mattermost-control/types.ts +107 -0
  35. package/LICENSE +21 -0
  36. package/README.md +1280 -0
  37. package/opencode-shared +359 -0
  38. package/opencode-shared-restart +495 -0
  39. package/opencode-shared-stop +90 -0
  40. package/package.json +65 -0
  41. package/src/clients/mattermost-client.ts +221 -0
  42. package/src/clients/websocket-client.ts +199 -0
  43. package/src/command-handler.ts +1035 -0
  44. package/src/config.ts +170 -0
  45. package/src/context-builder.ts +309 -0
  46. package/src/file-completion-handler.ts +521 -0
  47. package/src/file-handler.ts +242 -0
  48. package/src/guest-approval-handler.ts +223 -0
  49. package/src/logger.ts +73 -0
  50. package/src/merge-handler.ts +335 -0
  51. package/src/message-router.ts +151 -0
  52. package/src/models/index.ts +197 -0
  53. package/src/models/routing.ts +50 -0
  54. package/src/models/thread-mapping.ts +40 -0
  55. package/src/monitor-service.ts +222 -0
  56. package/src/notification-service.ts +118 -0
  57. package/src/opencode-session-registry.ts +370 -0
  58. package/src/persistence/team-store.ts +396 -0
  59. package/src/persistence/thread-mapping-store.ts +258 -0
  60. package/src/question-handler.ts +401 -0
  61. package/src/reaction-handler.ts +111 -0
  62. package/src/response-streamer.ts +364 -0
  63. package/src/scheduler/schedule-store.ts +261 -0
  64. package/src/scheduler/scheduler-service.ts +349 -0
  65. package/src/session-manager.ts +142 -0
  66. package/src/session-ownership-handler.ts +253 -0
  67. package/src/status-indicator.ts +279 -0
  68. package/src/thread-manager.ts +231 -0
  69. package/src/todo-manager.ts +162 -0
@@ -0,0 +1,258 @@
1
+ ---
2
+ description: Create or update the feature specification from a natural language feature description.
3
+ handoffs:
4
+ - label: Build Technical Plan
5
+ agent: speckit.plan
6
+ prompt: Create a plan for the spec. I am building with...
7
+ - label: Clarify Spec Requirements
8
+ agent: speckit.clarify
9
+ prompt: Clarify specification requirements
10
+ send: true
11
+ ---
12
+
13
+ ## User Input
14
+
15
+ ```text
16
+ $ARGUMENTS
17
+ ```
18
+
19
+ You **MUST** consider the user input before proceeding (if not empty).
20
+
21
+ ## Outline
22
+
23
+ The text the user typed after `/speckit.specify` in the triggering message **is** the feature description. Assume you always have it available in this conversation even if `$ARGUMENTS` appears literally below. Do not ask the user to repeat it unless they provided an empty command.
24
+
25
+ Given that feature description, do this:
26
+
27
+ 1. **Generate a concise short name** (2-4 words) for the branch:
28
+ - Analyze the feature description and extract the most meaningful keywords
29
+ - Create a 2-4 word short name that captures the essence of the feature
30
+ - Use action-noun format when possible (e.g., "add-user-auth", "fix-payment-bug")
31
+ - Preserve technical terms and acronyms (OAuth2, API, JWT, etc.)
32
+ - Keep it concise but descriptive enough to understand the feature at a glance
33
+ - Examples:
34
+ - "I want to add user authentication" → "user-auth"
35
+ - "Implement OAuth2 integration for the API" → "oauth2-api-integration"
36
+ - "Create a dashboard for analytics" → "analytics-dashboard"
37
+ - "Fix payment processing timeout bug" → "fix-payment-timeout"
38
+
39
+ 2. **Check for existing branches before creating new one**:
40
+
41
+ a. First, fetch all remote branches to ensure we have the latest information:
42
+
43
+ ```bash
44
+ git fetch --all --prune
45
+ ```
46
+
47
+ b. Find the highest feature number across all sources for the short-name:
48
+ - Remote branches: `git ls-remote --heads origin | grep -E 'refs/heads/[0-9]+-<short-name>$'`
49
+ - Local branches: `git branch | grep -E '^[* ]*[0-9]+-<short-name>$'`
50
+ - Specs directories: Check for directories matching `specs/[0-9]+-<short-name>`
51
+
52
+ c. Determine the next available number:
53
+ - Extract all numbers from all three sources
54
+ - Find the highest number N
55
+ - Use N+1 for the new branch number
56
+
57
+ d. Run the script `.specify/scripts/bash/create-new-feature.sh --json "$ARGUMENTS"` with the calculated number and short-name:
58
+ - Pass `--number N+1` and `--short-name "your-short-name"` along with the feature description
59
+ - Bash example: `.specify/scripts/bash/create-new-feature.sh --json "$ARGUMENTS" --json --number 5 --short-name "user-auth" "Add user authentication"`
60
+ - PowerShell example: `.specify/scripts/bash/create-new-feature.sh --json "$ARGUMENTS" -Json -Number 5 -ShortName "user-auth" "Add user authentication"`
61
+
62
+ **IMPORTANT**:
63
+ - Check all three sources (remote branches, local branches, specs directories) to find the highest number
64
+ - Only match branches/directories with the exact short-name pattern
65
+ - If no existing branches/directories found with this short-name, start with number 1
66
+ - You must only ever run this script once per feature
67
+ - The JSON is provided in the terminal as output - always refer to it to get the actual content you're looking for
68
+ - The JSON output will contain BRANCH_NAME and SPEC_FILE paths
69
+ - For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot")
70
+
71
+ 3. Load `.specify/templates/spec-template.md` to understand required sections.
72
+
73
+ 4. Follow this execution flow:
74
+
75
+ 1. Parse user description from Input
76
+ If empty: ERROR "No feature description provided"
77
+ 2. Extract key concepts from description
78
+ Identify: actors, actions, data, constraints
79
+ 3. For unclear aspects:
80
+ - Make informed guesses based on context and industry standards
81
+ - Only mark with [NEEDS CLARIFICATION: specific question] if:
82
+ - The choice significantly impacts feature scope or user experience
83
+ - Multiple reasonable interpretations exist with different implications
84
+ - No reasonable default exists
85
+ - **LIMIT: Maximum 3 [NEEDS CLARIFICATION] markers total**
86
+ - Prioritize clarifications by impact: scope > security/privacy > user experience > technical details
87
+ 4. Fill User Scenarios & Testing section
88
+ If no clear user flow: ERROR "Cannot determine user scenarios"
89
+ 5. Generate Functional Requirements
90
+ Each requirement must be testable
91
+ Use reasonable defaults for unspecified details (document assumptions in Assumptions section)
92
+ 6. Define Success Criteria
93
+ Create measurable, technology-agnostic outcomes
94
+ Include both quantitative metrics (time, performance, volume) and qualitative measures (user satisfaction, task completion)
95
+ Each criterion must be verifiable without implementation details
96
+ 7. Identify Key Entities (if data involved)
97
+ 8. Return: SUCCESS (spec ready for planning)
98
+
99
+ 5. Write the specification to SPEC_FILE using the template structure, replacing placeholders with concrete details derived from the feature description (arguments) while preserving section order and headings.
100
+
101
+ 6. **Specification Quality Validation**: After writing the initial spec, validate it against quality criteria:
102
+
103
+ a. **Create Spec Quality Checklist**: Generate a checklist file at `FEATURE_DIR/checklists/requirements.md` using the checklist template structure with these validation items:
104
+
105
+ ```markdown
106
+ # Specification Quality Checklist: [FEATURE NAME]
107
+
108
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
109
+ **Created**: [DATE]
110
+ **Feature**: [Link to spec.md]
111
+
112
+ ## Content Quality
113
+
114
+ - [ ] No implementation details (languages, frameworks, APIs)
115
+ - [ ] Focused on user value and business needs
116
+ - [ ] Written for non-technical stakeholders
117
+ - [ ] All mandatory sections completed
118
+
119
+ ## Requirement Completeness
120
+
121
+ - [ ] No [NEEDS CLARIFICATION] markers remain
122
+ - [ ] Requirements are testable and unambiguous
123
+ - [ ] Success criteria are measurable
124
+ - [ ] Success criteria are technology-agnostic (no implementation details)
125
+ - [ ] All acceptance scenarios are defined
126
+ - [ ] Edge cases are identified
127
+ - [ ] Scope is clearly bounded
128
+ - [ ] Dependencies and assumptions identified
129
+
130
+ ## Feature Readiness
131
+
132
+ - [ ] All functional requirements have clear acceptance criteria
133
+ - [ ] User scenarios cover primary flows
134
+ - [ ] Feature meets measurable outcomes defined in Success Criteria
135
+ - [ ] No implementation details leak into specification
136
+
137
+ ## Notes
138
+
139
+ - Items marked incomplete require spec updates before `/speckit.clarify` or `/speckit.plan`
140
+ ```
141
+
142
+ b. **Run Validation Check**: Review the spec against each checklist item:
143
+ - For each item, determine if it passes or fails
144
+ - Document specific issues found (quote relevant spec sections)
145
+
146
+ c. **Handle Validation Results**:
147
+
148
+ - **If all items pass**: Mark checklist complete and proceed to step 6
149
+
150
+ - **If items fail (excluding [NEEDS CLARIFICATION])**:
151
+ 1. List the failing items and specific issues
152
+ 2. Update the spec to address each issue
153
+ 3. Re-run validation until all items pass (max 3 iterations)
154
+ 4. If still failing after 3 iterations, document remaining issues in checklist notes and warn user
155
+
156
+ - **If [NEEDS CLARIFICATION] markers remain**:
157
+ 1. Extract all [NEEDS CLARIFICATION: ...] markers from the spec
158
+ 2. **LIMIT CHECK**: If more than 3 markers exist, keep only the 3 most critical (by scope/security/UX impact) and make informed guesses for the rest
159
+ 3. For each clarification needed (max 3), present options to user in this format:
160
+
161
+ ```markdown
162
+ ## Question [N]: [Topic]
163
+
164
+ **Context**: [Quote relevant spec section]
165
+
166
+ **What we need to know**: [Specific question from NEEDS CLARIFICATION marker]
167
+
168
+ **Suggested Answers**:
169
+
170
+ | Option | Answer | Implications |
171
+ |--------|--------|--------------|
172
+ | A | [First suggested answer] | [What this means for the feature] |
173
+ | B | [Second suggested answer] | [What this means for the feature] |
174
+ | C | [Third suggested answer] | [What this means for the feature] |
175
+ | Custom | Provide your own answer | [Explain how to provide custom input] |
176
+
177
+ **Your choice**: _[Wait for user response]_
178
+ ```
179
+
180
+ 4. **CRITICAL - Table Formatting**: Ensure markdown tables are properly formatted:
181
+ - Use consistent spacing with pipes aligned
182
+ - Each cell should have spaces around content: `| Content |` not `|Content|`
183
+ - Header separator must have at least 3 dashes: `|--------|`
184
+ - Test that the table renders correctly in markdown preview
185
+ 5. Number questions sequentially (Q1, Q2, Q3 - max 3 total)
186
+ 6. Present all questions together before waiting for responses
187
+ 7. Wait for user to respond with their choices for all questions (e.g., "Q1: A, Q2: Custom - [details], Q3: B")
188
+ 8. Update the spec by replacing each [NEEDS CLARIFICATION] marker with the user's selected or provided answer
189
+ 9. Re-run validation after all clarifications are resolved
190
+
191
+ d. **Update Checklist**: After each validation iteration, update the checklist file with current pass/fail status
192
+
193
+ 7. Report completion with branch name, spec file path, checklist results, and readiness for the next phase (`/speckit.clarify` or `/speckit.plan`).
194
+
195
+ **NOTE:** The script creates and checks out the new branch and initializes the spec file before writing.
196
+
197
+ ## General Guidelines
198
+
199
+ ## Quick Guidelines
200
+
201
+ - Focus on **WHAT** users need and **WHY**.
202
+ - Avoid HOW to implement (no tech stack, APIs, code structure).
203
+ - Written for business stakeholders, not developers.
204
+ - DO NOT create any checklists that are embedded in the spec. That will be a separate command.
205
+
206
+ ### Section Requirements
207
+
208
+ - **Mandatory sections**: Must be completed for every feature
209
+ - **Optional sections**: Include only when relevant to the feature
210
+ - When a section doesn't apply, remove it entirely (don't leave as "N/A")
211
+
212
+ ### For AI Generation
213
+
214
+ When creating this spec from a user prompt:
215
+
216
+ 1. **Make informed guesses**: Use context, industry standards, and common patterns to fill gaps
217
+ 2. **Document assumptions**: Record reasonable defaults in the Assumptions section
218
+ 3. **Limit clarifications**: Maximum 3 [NEEDS CLARIFICATION] markers - use only for critical decisions that:
219
+ - Significantly impact feature scope or user experience
220
+ - Have multiple reasonable interpretations with different implications
221
+ - Lack any reasonable default
222
+ 4. **Prioritize clarifications**: scope > security/privacy > user experience > technical details
223
+ 5. **Think like a tester**: Every vague requirement should fail the "testable and unambiguous" checklist item
224
+ 6. **Common areas needing clarification** (only if no reasonable default exists):
225
+ - Feature scope and boundaries (include/exclude specific use cases)
226
+ - User types and permissions (if multiple conflicting interpretations possible)
227
+ - Security/compliance requirements (when legally/financially significant)
228
+
229
+ **Examples of reasonable defaults** (don't ask about these):
230
+
231
+ - Data retention: Industry-standard practices for the domain
232
+ - Performance targets: Standard web/mobile app expectations unless specified
233
+ - Error handling: User-friendly messages with appropriate fallbacks
234
+ - Authentication method: Standard session-based or OAuth2 for web apps
235
+ - Integration patterns: RESTful APIs unless specified otherwise
236
+
237
+ ### Success Criteria Guidelines
238
+
239
+ Success criteria must be:
240
+
241
+ 1. **Measurable**: Include specific metrics (time, percentage, count, rate)
242
+ 2. **Technology-agnostic**: No mention of frameworks, languages, databases, or tools
243
+ 3. **User-focused**: Describe outcomes from user/business perspective, not system internals
244
+ 4. **Verifiable**: Can be tested/validated without knowing implementation details
245
+
246
+ **Good examples**:
247
+
248
+ - "Users can complete checkout in under 3 minutes"
249
+ - "System supports 10,000 concurrent users"
250
+ - "95% of searches return results in under 1 second"
251
+ - "Task completion rate improves by 40%"
252
+
253
+ **Bad examples** (implementation-focused):
254
+
255
+ - "API response time is under 200ms" (too technical, use "Users see results instantly")
256
+ - "Database can handle 1000 TPS" (implementation detail, use user-facing metric)
257
+ - "React components render efficiently" (framework-specific)
258
+ - "Redis cache hit rate above 80%" (technology-specific)
@@ -0,0 +1,137 @@
1
+ ---
2
+ description: Generate an actionable, dependency-ordered tasks.md for the feature based on available design artifacts.
3
+ handoffs:
4
+ - label: Analyze For Consistency
5
+ agent: speckit.analyze
6
+ prompt: Run a project analysis for consistency
7
+ send: true
8
+ - label: Implement Project
9
+ agent: speckit.implement
10
+ prompt: Start the implementation in phases
11
+ send: true
12
+ ---
13
+
14
+ ## User Input
15
+
16
+ ```text
17
+ $ARGUMENTS
18
+ ```
19
+
20
+ You **MUST** consider the user input before proceeding (if not empty).
21
+
22
+ ## Outline
23
+
24
+ 1. **Setup**: Run `.specify/scripts/bash/check-prerequisites.sh --json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
25
+
26
+ 2. **Load design documents**: Read from FEATURE_DIR:
27
+ - **Required**: plan.md (tech stack, libraries, structure), spec.md (user stories with priorities)
28
+ - **Optional**: data-model.md (entities), contracts/ (API endpoints), research.md (decisions), quickstart.md (test scenarios)
29
+ - Note: Not all projects have all documents. Generate tasks based on what's available.
30
+
31
+ 3. **Execute task generation workflow**:
32
+ - Load plan.md and extract tech stack, libraries, project structure
33
+ - Load spec.md and extract user stories with their priorities (P1, P2, P3, etc.)
34
+ - If data-model.md exists: Extract entities and map to user stories
35
+ - If contracts/ exists: Map endpoints to user stories
36
+ - If research.md exists: Extract decisions for setup tasks
37
+ - Generate tasks organized by user story (see Task Generation Rules below)
38
+ - Generate dependency graph showing user story completion order
39
+ - Create parallel execution examples per user story
40
+ - Validate task completeness (each user story has all needed tasks, independently testable)
41
+
42
+ 4. **Generate tasks.md**: Use `.specify/templates/tasks-template.md` as structure, fill with:
43
+ - Correct feature name from plan.md
44
+ - Phase 1: Setup tasks (project initialization)
45
+ - Phase 2: Foundational tasks (blocking prerequisites for all user stories)
46
+ - Phase 3+: One phase per user story (in priority order from spec.md)
47
+ - Each phase includes: story goal, independent test criteria, tests (if requested), implementation tasks
48
+ - Final Phase: Polish & cross-cutting concerns
49
+ - All tasks must follow the strict checklist format (see Task Generation Rules below)
50
+ - Clear file paths for each task
51
+ - Dependencies section showing story completion order
52
+ - Parallel execution examples per story
53
+ - Implementation strategy section (MVP first, incremental delivery)
54
+
55
+ 5. **Report**: Output path to generated tasks.md and summary:
56
+ - Total task count
57
+ - Task count per user story
58
+ - Parallel opportunities identified
59
+ - Independent test criteria for each story
60
+ - Suggested MVP scope (typically just User Story 1)
61
+ - Format validation: Confirm ALL tasks follow the checklist format (checkbox, ID, labels, file paths)
62
+
63
+ Context for task generation: $ARGUMENTS
64
+
65
+ The tasks.md should be immediately executable - each task must be specific enough that an LLM can complete it without additional context.
66
+
67
+ ## Task Generation Rules
68
+
69
+ **CRITICAL**: Tasks MUST be organized by user story to enable independent implementation and testing.
70
+
71
+ **Tests are OPTIONAL**: Only generate test tasks if explicitly requested in the feature specification or if user requests TDD approach.
72
+
73
+ ### Checklist Format (REQUIRED)
74
+
75
+ Every task MUST strictly follow this format:
76
+
77
+ ```text
78
+ - [ ] [TaskID] [P?] [Story?] Description with file path
79
+ ```
80
+
81
+ **Format Components**:
82
+
83
+ 1. **Checkbox**: ALWAYS start with `- [ ]` (markdown checkbox)
84
+ 2. **Task ID**: Sequential number (T001, T002, T003...) in execution order
85
+ 3. **[P] marker**: Include ONLY if task is parallelizable (different files, no dependencies on incomplete tasks)
86
+ 4. **[Story] label**: REQUIRED for user story phase tasks only
87
+ - Format: [US1], [US2], [US3], etc. (maps to user stories from spec.md)
88
+ - Setup phase: NO story label
89
+ - Foundational phase: NO story label
90
+ - User Story phases: MUST have story label
91
+ - Polish phase: NO story label
92
+ 5. **Description**: Clear action with exact file path
93
+
94
+ **Examples**:
95
+
96
+ - ✅ CORRECT: `- [ ] T001 Create project structure per implementation plan`
97
+ - ✅ CORRECT: `- [ ] T005 [P] Implement authentication middleware in src/middleware/auth.py`
98
+ - ✅ CORRECT: `- [ ] T012 [P] [US1] Create User model in src/models/user.py`
99
+ - ✅ CORRECT: `- [ ] T014 [US1] Implement UserService in src/services/user_service.py`
100
+ - ❌ WRONG: `- [ ] Create User model` (missing ID and Story label)
101
+ - ❌ WRONG: `T001 [US1] Create model` (missing checkbox)
102
+ - ❌ WRONG: `- [ ] [US1] Create User model` (missing Task ID)
103
+ - ❌ WRONG: `- [ ] T001 [US1] Create model` (missing file path)
104
+
105
+ ### Task Organization
106
+
107
+ 1. **From User Stories (spec.md)** - PRIMARY ORGANIZATION:
108
+ - Each user story (P1, P2, P3...) gets its own phase
109
+ - Map all related components to their story:
110
+ - Models needed for that story
111
+ - Services needed for that story
112
+ - Endpoints/UI needed for that story
113
+ - If tests requested: Tests specific to that story
114
+ - Mark story dependencies (most stories should be independent)
115
+
116
+ 2. **From Contracts**:
117
+ - Map each contract/endpoint → to the user story it serves
118
+ - If tests requested: Each contract → contract test task [P] before implementation in that story's phase
119
+
120
+ 3. **From Data Model**:
121
+ - Map each entity to the user story(ies) that need it
122
+ - If entity serves multiple stories: Put in earliest story or Setup phase
123
+ - Relationships → service layer tasks in appropriate story phase
124
+
125
+ 4. **From Setup/Infrastructure**:
126
+ - Shared infrastructure → Setup phase (Phase 1)
127
+ - Foundational/blocking tasks → Foundational phase (Phase 2)
128
+ - Story-specific setup → within that story's phase
129
+
130
+ ### Phase Structure
131
+
132
+ - **Phase 1**: Setup (project initialization)
133
+ - **Phase 2**: Foundational (blocking prerequisites - MUST complete before user stories)
134
+ - **Phase 3+**: User Stories in priority order (P1, P2, P3...)
135
+ - Within each story: Tests (if requested) → Models → Services → Endpoints → Integration
136
+ - Each phase should be a complete, independently testable increment
137
+ - **Final Phase**: Polish & Cross-Cutting Concerns
@@ -0,0 +1,30 @@
1
+ ---
2
+ description: Convert existing tasks into actionable, dependency-ordered GitHub issues for the feature based on available design artifacts.
3
+ tools: ['github/github-mcp-server/issue_write']
4
+ ---
5
+
6
+ ## User Input
7
+
8
+ ```text
9
+ $ARGUMENTS
10
+ ```
11
+
12
+ You **MUST** consider the user input before proceeding (if not empty).
13
+
14
+ ## Outline
15
+
16
+ 1. Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
17
+ 1. From the executed script, extract the path to **tasks**.
18
+ 1. Get the Git remote by running:
19
+
20
+ ```bash
21
+ git config --get remote.origin.url
22
+ ```
23
+
24
+ > [!CAUTION]
25
+ > ONLY PROCEED TO NEXT STEPS IF THE REMOTE IS A GITHUB URL
26
+
27
+ 1. For each task in the list, use the GitHub MCP server to create a new issue in the repository that is representative of the Git remote.
28
+
29
+ > [!CAUTION]
30
+ > UNDER NO CIRCUMSTANCES EVER CREATE ISSUES IN REPOSITORIES THAT DO NOT MATCH THE REMOTE URL
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Compaction event handler - handles session.compacted events
3
+ */
4
+
5
+ import { PluginState } from "../state.js";
6
+ import { formatFullResponse } from "../formatters.js";
7
+ import { log } from "../../../../src/logger.js";
8
+
9
+ function isScheduledTaskSession(sessionId: string): boolean {
10
+ const scheduler = PluginState.schedulerService;
11
+ return scheduler?.isRunningScheduledTask(sessionId) ?? false;
12
+ }
13
+
14
+ export async function handleSessionCompacted(event: any): Promise<void> {
15
+ const eventSessionId = event.properties?.sessionID;
16
+ const { mmClient, streamer } = PluginState;
17
+
18
+ if (!eventSessionId || !mmClient || !streamer) return;
19
+
20
+ if (isScheduledTaskSession(eventSessionId)) {
21
+ log.debug(`[ScheduledTask] Suppressing session.compacted for scheduled task session ${eventSessionId.substring(0, 8)}`);
22
+ return;
23
+ }
24
+
25
+ log.info(`[Compaction] Session ${eventSessionId.substring(0, 8)} compacted`);
26
+ const props = event.properties || {};
27
+ log.debug(`[Compaction] Event properties: ${JSON.stringify(props)}`);
28
+
29
+ const ctx = PluginState.activeResponseContexts.get(eventSessionId);
30
+ if (!ctx) return;
31
+
32
+ ctx.compactionCount += 1;
33
+ ctx.awaitingContinuation = true;
34
+ ctx.inCompactionSummary = false;
35
+ log.info(`[Compaction] Set awaitingContinuation=true, inCompactionSummary=false for session ${eventSessionId.substring(0, 8)}`);
36
+
37
+ try {
38
+ const oldContent = formatFullResponse(ctx);
39
+ const newStreamCtx = await streamer.recreateStreamAtBottom(ctx.streamCtx, oldContent);
40
+ ctx.streamCtx = newStreamCtx;
41
+ log.debug(`[Compaction] Recreated stream at bottom, new postId=${newStreamCtx.postId}`);
42
+
43
+ const compactionMsg = `📦 **Context Compacted** (×${ctx.compactionCount})\n\n` +
44
+ `_Context was automatically compressed to continue the conversation._`;
45
+
46
+ const targetChannelId = ctx.streamCtx?.channelId || ctx.mmSession.dmChannelId;
47
+ const post = await mmClient.createPost(
48
+ targetChannelId,
49
+ compactionMsg,
50
+ ctx.threadRootPostId
51
+ );
52
+ ctx.compactionPostId = post.id;
53
+ log.debug(`[Compaction] Created compaction post ${post.id}`);
54
+
55
+ const newStreamCtx2 = await streamer.recreateStreamAtBottom(ctx.streamCtx);
56
+ ctx.streamCtx = newStreamCtx2;
57
+ log.debug(`[Compaction] Recreated stream after notification, new postId=${newStreamCtx2.postId}`);
58
+ } catch (e) {
59
+ log.error(`[Compaction] Failed to handle compaction:`, e);
60
+ }
61
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * File event handler - handles file.edited events
3
+ */
4
+
5
+ import { PluginState } from "../state.js";
6
+ import { log } from "../../../../src/logger.js";
7
+
8
+ function isScheduledTaskSession(sessionId: string): boolean {
9
+ const scheduler = PluginState.schedulerService;
10
+ return scheduler?.isRunningScheduledTask(sessionId) ?? false;
11
+ }
12
+
13
+ export async function handleFileEdited(event: any): Promise<void> {
14
+ const { fileHandler } = PluginState;
15
+ if (!fileHandler) return;
16
+
17
+ const sessionId = event.properties?.sessionID;
18
+ if (!sessionId) return;
19
+
20
+ if (isScheduledTaskSession(sessionId)) {
21
+ log.debug(`[ScheduledTask] Suppressing file.edited for scheduled task session ${sessionId.substring(0, 8)}`);
22
+ return;
23
+ }
24
+
25
+ const ctx = PluginState.activeResponseContexts.get(sessionId);
26
+ if (!ctx) return;
27
+
28
+ try {
29
+ const filePath = event.properties?.path;
30
+ if (filePath) {
31
+ await fileHandler.sendOutboundFile(ctx.mmSession, filePath, `File updated: \`${filePath}\``);
32
+ }
33
+ } catch (e) {
34
+ log.error("Failed to send file update:", e);
35
+ }
36
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Event handlers module - exports all OpenCode event handlers
3
+ *
4
+ * This module aggregates event handlers for the Mattermost Control Plugin.
5
+ */
6
+
7
+ export { handlePermissionAsked } from "./permission.js";
8
+ export { handleQuestionAsked } from "./question.js";
9
+ export { handleSessionIdle, handleSessionStatus } from "./session.js";
10
+ export { handleSessionCompacted } from "./compaction.js";
11
+ export { handleMessageUpdated, handleMessagePartUpdated } from "./message.js";
12
+ export { handleFileEdited } from "./file.js";
13
+ export { handleTodoUpdated } from "./todo.js";
14
+ export { handleToolExecuteBefore, handleToolExecuteAfter } from "./tool.js";
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Message event handlers - handles message.updated and message.part.updated events
3
+ */
4
+
5
+ import { PluginState } from "../state.js";
6
+ import { formatFullResponse } from "../formatters.js";
7
+ import { updateResponseStream } from "../timers.js";
8
+ import { log } from "../../../../src/logger.js";
9
+
10
+ /**
11
+ * Check if a session is running a scheduled task.
12
+ * If so, streaming updates should be suppressed to prevent routing to wrong threads.
13
+ */
14
+ function isScheduledTaskSession(sessionId: string): boolean {
15
+ const scheduler = PluginState.schedulerService;
16
+ return scheduler?.isRunningScheduledTask(sessionId) ?? false;
17
+ }
18
+
19
+ export async function handleMessageUpdated(event: any): Promise<void> {
20
+ const msgInfo = event.properties?.info;
21
+ if (msgInfo?.role !== "assistant" || !msgInfo?.sessionID) return;
22
+
23
+ // Skip streaming updates for scheduled task sessions to prevent routing to wrong threads
24
+ if (isScheduledTaskSession(msgInfo.sessionID)) {
25
+ log.debug(`[ScheduledTask] Suppressing message.updated for scheduled task session ${msgInfo.sessionID.substring(0, 8)}`);
26
+ return;
27
+ }
28
+
29
+ const ctx = PluginState.activeResponseContexts.get(msgInfo.sessionID);
30
+ if (!ctx) return;
31
+
32
+ // Detect compaction summary messages
33
+ if (msgInfo.agent === "compaction" || msgInfo.summary === true) {
34
+ log.info(`[Compaction] Detected compaction summary message for session ${msgInfo.sessionID.substring(0, 8)}, suppressing text accumulation`);
35
+ ctx.inCompactionSummary = true;
36
+ }
37
+
38
+ // Update cost tracking
39
+ ctx.cost.currentMessage = msgInfo.cost || 0;
40
+ if (msgInfo.tokens) {
41
+ ctx.cost.tokens = {
42
+ input: msgInfo.tokens.input || 0,
43
+ output: msgInfo.tokens.output || 0,
44
+ reasoning: msgInfo.tokens.reasoning || 0,
45
+ cache: {
46
+ read: msgInfo.tokens.cache?.read || 0,
47
+ write: msgInfo.tokens.cache?.write || 0,
48
+ },
49
+ };
50
+ }
51
+
52
+ await updateResponseStream(msgInfo.sessionID);
53
+ }
54
+
55
+ export async function handleMessagePartUpdated(event: any): Promise<void> {
56
+ const { streamer, isConnected } = PluginState;
57
+ if (!isConnected || !streamer) return;
58
+
59
+ const part = event.properties?.part;
60
+ const delta = event.properties?.delta;
61
+ const sessionId = part?.sessionID || event.properties?.sessionID;
62
+
63
+ if (!sessionId) return;
64
+
65
+ // Skip streaming updates for scheduled task sessions
66
+ if (isScheduledTaskSession(sessionId)) {
67
+ log.debug(`[ScheduledTask] Suppressing message.part.updated for scheduled task session ${sessionId.substring(0, 8)}`);
68
+ return;
69
+ }
70
+
71
+ const ctx = PluginState.activeResponseContexts.get(sessionId);
72
+ if (!ctx) return;
73
+
74
+ let shouldUpdate = false;
75
+
76
+ if (part?.type === "text" && delta) {
77
+ // Skip compaction summary text
78
+ if (ctx.inCompactionSummary) {
79
+ log.debug(`[Compaction] Suppressing compaction summary text for session ${sessionId.substring(0, 8)}`);
80
+ return;
81
+ }
82
+ // Reset awaiting continuation flag when real content arrives
83
+ if (ctx.awaitingContinuation) {
84
+ log.info(`[Compaction] Continuation content received, resetting awaitingContinuation for session ${sessionId.substring(0, 8)}`);
85
+ ctx.awaitingContinuation = false;
86
+ }
87
+ ctx.responseBuffer += delta;
88
+ ctx.textPartCount = (ctx.textPartCount || 0) + 1;
89
+ shouldUpdate = true;
90
+ } else if (part?.type === "reasoning" && delta) {
91
+ // Skip compaction summary reasoning
92
+ if (ctx.inCompactionSummary) {
93
+ log.debug(`[Compaction] Suppressing compaction summary reasoning for session ${sessionId.substring(0, 8)}`);
94
+ return;
95
+ }
96
+ if (ctx.awaitingContinuation) {
97
+ log.info(`[Compaction] Continuation reasoning received, resetting awaitingContinuation for session ${sessionId.substring(0, 8)}`);
98
+ ctx.awaitingContinuation = false;
99
+ }
100
+ ctx.thinkingBuffer += delta;
101
+ ctx.reasoningPartCount = (ctx.reasoningPartCount || 0) + 1;
102
+ shouldUpdate = true;
103
+ } else if (part?.type === "tool" && part?.tool === "bash" && part?.state?.status === "running") {
104
+ // Live shell output streaming
105
+ const shellOutput = part.state.metadata?.output;
106
+ if (shellOutput && shellOutput !== ctx.shellOutput) {
107
+ ctx.shellOutput = shellOutput;
108
+ ctx.shellOutputLastUpdate = Date.now();
109
+ shouldUpdate = true;
110
+ }
111
+ }
112
+
113
+ if (shouldUpdate) {
114
+ ctx.lastUpdateTime = Date.now();
115
+
116
+ const formattedOutput = formatFullResponse(ctx);
117
+
118
+ try {
119
+ await streamer.updateStream(ctx.streamCtx, formattedOutput);
120
+ } catch (e) {
121
+ log.error("Failed to update stream:", e);
122
+ }
123
+ }
124
+ }