specweave 0.6.7 → 0.6.8

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 (44) hide show
  1. package/CLAUDE.md +30 -21
  2. package/dist/adapters/adapter-interface.d.ts +11 -11
  3. package/dist/adapters/adapter-interface.d.ts.map +1 -1
  4. package/dist/adapters/adapter-interface.js +1 -1
  5. package/dist/adapters/adapter-loader.d.ts +1 -2
  6. package/dist/adapters/adapter-loader.d.ts.map +1 -1
  7. package/dist/adapters/adapter-loader.js +3 -6
  8. package/dist/adapters/adapter-loader.js.map +1 -1
  9. package/dist/adapters/agents-md-generator.d.ts +3 -3
  10. package/dist/adapters/agents-md-generator.js +3 -3
  11. package/dist/adapters/generic/adapter.d.ts +2 -2
  12. package/dist/adapters/generic/adapter.d.ts.map +1 -1
  13. package/dist/adapters/generic/adapter.js +28 -9
  14. package/dist/adapters/generic/adapter.js.map +1 -1
  15. package/dist/cli/commands/init.d.ts.map +1 -1
  16. package/dist/cli/commands/init.js +51 -22
  17. package/dist/cli/commands/init.js.map +1 -1
  18. package/dist/core/types/config.d.ts +2 -2
  19. package/dist/core/types/config.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/plugins/specweave/commands/do.md +2 -0
  22. package/plugins/specweave/commands/done.md +2 -0
  23. package/plugins/specweave/commands/inc.md +1 -1
  24. package/plugins/specweave/commands/validate.md +2 -0
  25. package/plugins/specweave/hooks/docs-changed.sh +23 -3
  26. package/plugins/specweave/hooks/human-input-required.sh +23 -3
  27. package/plugins/specweave/hooks/post-task-completion.sh +20 -1
  28. package/plugins/specweave/hooks/pre-implementation.sh +23 -3
  29. package/src/adapters/README.md +27 -63
  30. package/src/adapters/adapter-interface.ts +11 -11
  31. package/src/adapters/adapter-loader.ts +3 -6
  32. package/src/adapters/agents-md-generator.ts +3 -3
  33. package/src/adapters/generic/adapter.ts +28 -9
  34. package/src/templates/AGENTS.md.template +351 -0
  35. package/dist/adapters/copilot/adapter.d.ts +0 -86
  36. package/dist/adapters/copilot/adapter.d.ts.map +0 -1
  37. package/dist/adapters/copilot/adapter.js +0 -396
  38. package/dist/adapters/copilot/adapter.js.map +0 -1
  39. package/plugins/.specweave/logs/hooks-debug.log +0 -24
  40. package/plugins/.specweave/logs/last-hook-fire +0 -1
  41. package/plugins/.specweave/logs/last-todowrite-time +0 -1
  42. package/plugins/.specweave/logs/tasks.log +0 -6
  43. package/src/adapters/copilot/README.md +0 -240
  44. package/src/adapters/copilot/adapter.ts +0 -444
@@ -1,240 +0,0 @@
1
- # GitHub Copilot Adapter
2
-
3
- **Automation Level**: Basic (Code suggestions with workspace context)
4
-
5
- ## Overview
6
-
7
- The GitHub Copilot adapter provides **basic automation** for SpecWeave by configuring workspace instructions that Copilot reads to provide better code suggestions.
8
-
9
- ## Key Limitation: No Custom Commands
10
-
11
- Unlike Claude Code (native skills/agents/commands) and Cursor (simulated via .cursorrules), GitHub Copilot does NOT support:
12
- - Custom slash commands
13
- - Workflow automation
14
- - Role-based assistance
15
- - Auto-activation
16
-
17
- **What it DOES support**:
18
- - Workspace instructions (.github/copilot/instructions.md)
19
- - Better code suggestions based on project context
20
- - Copilot Chat for Q&A
21
- - **Progressive disclosure via SKILLS-INDEX.md** (NEW in v0.3.8) - Access all 35+ skills!
22
-
23
- ## What This Adapter Provides
24
-
25
- ### šŸ” Progressive Disclosure (NEW)
26
-
27
- SpecWeave now includes **SKILLS-INDEX.md** - enabling GitHub Copilot to discover and use all 35+ skills!
28
-
29
- **How it works**:
30
- 1. Read `.claude/skills/SKILLS-INDEX.md` (referenced in AGENTS.md)
31
- 2. Match task to activation keywords
32
- 3. Load specific SKILL.md when relevant
33
- 4. Follow proven workflows
34
-
35
- **Benefits**:
36
- - āœ… **90% token savings** (5k vs 50k tokens)
37
- - āœ… **Full skill access** - All 35+ skills now available to Copilot!
38
- - āœ… **Consistent output** - Follow SpecWeave best practices
39
-
40
- **Example**:
41
- ```markdown
42
- # From AGENTS.md, you learn about:
43
- .claude/skills/SKILLS-INDEX.md # Single-file skill reference
44
-
45
- # When user asks: "Plan a new feature"
46
- # 1. Read SKILLS-INDEX.md → Find "increment-planner" skill
47
- # 2. Load .claude/skills/increment-planner/SKILL.md
48
- # 3. Follow the increment planning workflow
49
- ```
50
-
51
- ### .github/copilot/instructions.md
52
- - **What**: Workspace guidance that Copilot reads automatically
53
- - **Contains**: Project structure, workflows, best practices
54
- - **Benefit**: Copilot suggests code following SpecWeave patterns
55
-
56
- **Example**:
57
- ```markdown
58
- # In instructions.md:
59
- ## Workflow: Creating Features
60
-
61
- 1. Create increment folder: .specweave/increments/####-feature-name/
62
- 2. Create spec.md (WHAT & WHY - technology-agnostic)
63
- 3. Create plan.md (HOW - technology-specific)
64
- 4. Create tasks.md (implementation checklist)
65
- 5. Create context-manifest.yaml (context loading - 70%+ token savings)
66
- ```
67
-
68
- When you start typing in spec.md, Copilot suggests content following this structure!
69
-
70
- ## Installation
71
-
72
- ```bash
73
- # Install SpecWeave with Copilot adapter
74
- npx specweave init my-project --adapter copilot
75
-
76
- # Files created:
77
- # .github/copilot/instructions.md (workspace instructions)
78
- ```
79
-
80
- ## Directory Structure
81
-
82
- ```
83
- .github/copilot/
84
- ā”œā”€ā”€ instructions.md # Workspace instructions (Copilot reads this)
85
- └── README.md # This file
86
- ```
87
-
88
- ## Usage Examples
89
-
90
- ### Example 1: Creating spec.md
91
-
92
- **You**:
93
- 1. Create file: `.specweave/increments/0001-auth/spec.md`
94
- 2. Start typing YAML frontmatter: `---`
95
-
96
- **Copilot** (based on instructions.md):
97
- ```markdown
98
- ---
99
- increment: 0001-auth
100
- title: "User Authentication"
101
- priority: P1
102
- status: planned
103
- ---
104
-
105
- # Increment 0001: User Authentication
106
-
107
- ## Overview
108
- ...
109
- ```
110
-
111
- Copilot suggests the complete structure!
112
-
113
- ### Example 2: Copilot Chat Q&A
114
-
115
- **You**: "How do I create a plan.md following SpecWeave?"
116
-
117
- **Copilot** (reads instructions.md):
118
- ```
119
- Based on SpecWeave guidelines, plan.md should contain:
120
-
121
- 1. Architecture section (components, data model, APIs)
122
- 2. Technology-specific details (unlike spec.md which is tech-agnostic)
123
- 3. References to ADRs (Architecture Decision Records)
124
- 4. Implementation strategy
125
-
126
- Example structure:
127
- ...
128
- ```
129
-
130
- ### Example 3: Context Manifest
131
-
132
- **You**: Start typing in `context-manifest.yaml`
133
-
134
- **Copilot** (based on patterns in instructions.md):
135
- ```yaml
136
- ---
137
- spec_sections:
138
- - .specweave/docs/internal/strategy/auth/spec.md
139
- documentation:
140
- - .specweave/docs/internal/architecture/auth/design.md
141
- max_context_tokens: 10000
142
- ---
143
- ```
144
-
145
- ## Comparison with Other Adapters
146
-
147
- | Feature | Claude Code | Cursor | Copilot | Generic |
148
- |---------|-------------|--------|---------|---------|
149
- | **Automation** | Full | Semi | Basic | Manual |
150
- | **Skills** | Native | Simulated | N/A | N/A |
151
- | **Agents** | Native | Manual roles | N/A | N/A |
152
- | **Commands** | Slash commands | Workflow instructions | N/A | Step-by-step guide |
153
- | **Context Shortcuts** | Native | @ shortcuts | N/A | Manual copy-paste |
154
- | **Code Suggestions** | āœ… | āœ… | āœ… | āŒ |
155
- | **Workflow Automation** | āœ… | āš™ļø | āŒ | āŒ |
156
-
157
- **Copilot = Basic but useful** (better than nothing!)
158
-
159
- ## Limitations
160
-
161
- āŒ **No workflow automation** - Must create folders/files manually
162
- āŒ **No skills/agents** - Can't simulate roles like Cursor
163
- āŒ **No commands** - No slash commands or @ shortcuts
164
- āŒ **No hooks** - Can't auto-update docs (see workaround below)
165
- āš ļø **Completely manual workflow** - Just better code suggestions
166
-
167
- āœ… **But still helpful for**:
168
- - Code completion following SpecWeave patterns
169
- - Suggesting file structures
170
- - Copilot Chat Q&A about project
171
-
172
- ### Documentation Update Workaround
173
-
174
- Since GitHub Copilot doesn't have hooks, you MUST manually update documentation after every task.
175
-
176
- **See the comprehensive guide in AGENTS.md** (section: "Documentation Updates - CRITICAL FOR NON-CLAUDE TOOLS")
177
-
178
- **Quick checklist after completing any task**:
179
- 1. Update `.specweave/increments/{id}/tasks.md` (mark tasks complete)
180
- 2. Update `.specweave/docs/internal/architecture/` (HLD/LLD/ADRs)
181
- 3. Update `.specweave/docs/internal/strategy/` (PRDs if requirements changed)
182
- 4. Update `README.md` (user-facing changes)
183
- 5. Update `CHANGELOG.md` (version history)
184
-
185
- ## When to Use This Adapter
186
-
187
- āœ… **Use Copilot adapter if**:
188
- - You already use VS Code + GitHub Copilot
189
- - You want better code suggestions
190
- - You don't mind manual workflows
191
- - Simple projects
192
-
193
- āš ļø **Consider alternatives if**:
194
- - You want automation → Use Claude Code (full) or Cursor (semi)
195
- - You need skills/agents → Use Claude Code
196
- - You want role-based assistance → Use Claude Code or Cursor
197
-
198
- ## How Copilot Uses Workspace Instructions
199
-
200
- **Automatic (no action needed)**:
201
- 1. You open project in VS Code with Copilot
202
- 2. Copilot reads `.github/copilot/instructions.md` automatically
203
- 3. Copilot understands:
204
- - SpecWeave structure (.specweave/ folders)
205
- - File naming (spec.md, plan.md, tasks.md)
206
- - Patterns (context manifests, test IDs)
207
- - Best practices (tech-agnostic specs, etc.)
208
-
209
- **Result**: Better code suggestions that fit SpecWeave!
210
-
211
- **Example**:
212
- - Type `# Increment` → Copilot suggests increment structure
213
- - Type `TC-0001` → Copilot suggests test case format
214
- - Type `context-manifest.yaml` → Copilot suggests manifest structure
215
-
216
- ## Tips & Tricks
217
-
218
- ### 1. Reference instructions.md
219
- If Copilot suggests wrong patterns: "Follow .github/copilot/instructions.md"
220
-
221
- ### 2. Use Copilot Chat
222
- Ask: "How does SpecWeave work?" → Copilot explains from instructions
223
-
224
- ### 3. Start Typing, Let Copilot Complete
225
- Begin with YAML frontmatter or headers → Copilot fills in rest
226
-
227
- ### 4. Check Context Manifests
228
- Open context-manifest.yaml → Copilot sees relevant files
229
-
230
- ## Related Documentation
231
-
232
- - [SPECWEAVE.md](../../SPECWEAVE.md) - Complete development guide
233
- - [.github/copilot/instructions.md](.github/copilot/instructions.md) - Workspace instructions
234
- - [Adapter Architecture](../README.md) - Multi-tool design philosophy
235
-
236
- ---
237
-
238
- **Status**: Active (v0.2.0-beta.1+)
239
- **Market Share**: ~40% (GitHub Copilot users)
240
- **Priority**: P1 (large market, even with basic automation)
@@ -1,444 +0,0 @@
1
- /**
2
- * GitHub Copilot Adapter
3
- *
4
- * Basic automation adapter for GitHub Copilot.
5
- * Compiles SpecWeave plugins to AGENTS.md (universal standard) for context and suggestions.
6
- *
7
- * This adapter compiles skills, agents, and commands into AGENTS.md format.
8
- */
9
-
10
- import * as path from 'path';
11
- import fs from 'fs-extra';
12
- import { AdapterBase } from '../adapter-base.js';
13
- import { AdapterOptions, AdapterFile } from '../adapter-interface.js';
14
- import type { Plugin } from '../../core/types/plugin.js';
15
- import { compileToAgentsMd, getSpecweaveInstallPath } from '../../utils/agents-md-compiler.js';
16
- import { LanguageManager, getSystemPromptForLanguage } from '../../core/i18n/language-manager.js';
17
- import type { SupportedLanguage } from '../../core/i18n/types.js';
18
-
19
- export class CopilotAdapter extends AdapterBase {
20
- name = 'copilot';
21
- description = 'GitHub Copilot adapter - Basic automation with AGENTS.md';
22
- automationLevel = 'basic' as const;
23
-
24
- /**
25
- * Detect if GitHub Copilot is available
26
- *
27
- * Note: Detection is best-effort since Copilot might be installed
28
- * but we can't detect it reliably. This adapter is safe to use
29
- * as a fallback since Copilot reads AGENTS.md (universal standard).
30
- */
31
- async detect(): Promise<boolean> {
32
- // Always return false to make this a manual selection
33
- // Users can explicitly choose Copilot adapter if they want
34
- return false;
35
- }
36
-
37
- /**
38
- * Get files to install for Copilot adapter
39
- *
40
- * Note: Copilot automatically reads AGENTS.md (universal standard).
41
- * No additional files needed.
42
- */
43
- getFiles(): AdapterFile[] {
44
- return [];
45
- }
46
-
47
- /**
48
- * Install Copilot adapter
49
- */
50
- async install(options: AdapterOptions): Promise<void> {
51
- console.log('\nšŸ“¦ Configuring GitHub Copilot (Basic Automation)\n');
52
-
53
- // 1. Create .specweave/ structure
54
- const specweaveDir = path.join(options.projectPath, '.specweave');
55
- await fs.ensureDir(specweaveDir);
56
- await fs.ensureDir(path.join(specweaveDir, 'increments'));
57
- await fs.ensureDir(path.join(specweaveDir, 'increments', '_backlog'));
58
- await fs.ensureDir(path.join(specweaveDir, 'docs', 'internal', 'strategy'));
59
- await fs.ensureDir(path.join(specweaveDir, 'docs', 'internal', 'architecture', 'adr'));
60
- await fs.ensureDir(path.join(specweaveDir, 'docs', 'internal', 'architecture', 'rfc'));
61
- await fs.ensureDir(path.join(specweaveDir, 'docs', 'internal', 'architecture', 'diagrams'));
62
- await fs.ensureDir(path.join(specweaveDir, 'docs', 'internal', 'delivery'));
63
- await fs.ensureDir(path.join(specweaveDir, 'docs', 'public', 'guides'));
64
- await fs.ensureDir(path.join(specweaveDir, 'logs'));
65
-
66
- console.log('āœ… Created .specweave/ structure');
67
-
68
- // 2. Find SpecWeave installation
69
- let specweavePath: string;
70
- try {
71
- specweavePath = getSpecweaveInstallPath();
72
- console.log(`āœ… Found SpecWeave installation at: ${specweavePath}`);
73
- } catch (error) {
74
- console.error('āŒ Could not find SpecWeave installation');
75
- console.error(' Make sure SpecWeave is installed: npm install -g specweave');
76
- return;
77
- }
78
-
79
- // 3. Compile plugins to AGENTS.md
80
- console.log('šŸ“ Compiling plugins to AGENTS.md...');
81
- const result = await compileToAgentsMd(specweavePath);
82
-
83
- // 4. Write AGENTS.md
84
- const agentsMdPath = path.join(options.projectPath, 'AGENTS.md');
85
- await fs.writeFile(agentsMdPath, result.agentsMd, 'utf-8');
86
-
87
- console.log('āœ… Created AGENTS.md with:');
88
- console.log(` - ${result.skills.length} skills`);
89
- console.log(` - ${result.agents.length} agents`);
90
- console.log(` - ${result.commands.length} commands`);
91
-
92
- // 5. Create .github/copilot/instructions.md (optional)
93
- const copilotDir = path.join(options.projectPath, '.github', 'copilot');
94
- await fs.ensureDir(copilotDir);
95
-
96
- const instructionsContent = `# GitHub Copilot Instructions
97
-
98
- This project uses SpecWeave for spec-driven development.
99
-
100
- ## Important Context
101
-
102
- - **AGENTS.md**: Complete workflow guide (read this first!)
103
- - **Structure**: All work happens in \`.specweave/increments/\`
104
- - **Workflow**: spec.md → plan.md → tasks.md → tests.md
105
-
106
- ## When Suggesting Code
107
-
108
- - Follow patterns in AGENTS.md
109
- - Create files in increment folders, not project root
110
- - Reference existing specs and plans
111
- - Follow naming conventions (kebab-case for increments)
112
-
113
- See AGENTS.md for complete details.
114
- `;
115
-
116
- await fs.writeFile(path.join(copilotDir, 'instructions.md'), instructionsContent, 'utf-8');
117
- console.log('āœ… Created .github/copilot/instructions.md');
118
-
119
- console.log('\nāœ… Copilot will automatically read AGENTS.md');
120
- }
121
-
122
- /**
123
- * Post-installation instructions
124
- */
125
- async postInstall(options: AdapterOptions): Promise<void> {
126
- console.log(this.getInstructions());
127
- }
128
-
129
- /**
130
- * Get usage instructions for Copilot adapter
131
- */
132
- getInstructions(): string {
133
- return `
134
- ================================================================
135
- GitHub Copilot Adapter - Basic Automation
136
- ================================================================
137
-
138
- Your project is now configured for GitHub Copilot!
139
-
140
- WHAT THIS PROVIDES:
141
-
142
- - AGENTS.md (Universal Standard)
143
- - Copilot automatically reads this file
144
- - Contains all workflow instructions
145
- - Project structure and templates
146
- - Following agents.md standard (https://agents.md/)
147
-
148
- - Better Code Suggestions
149
- - Copilot reads AGENTS.md for context
150
- - Suggests code following SpecWeave patterns
151
- - Understands project structure
152
-
153
- UNDERSTANDING THE DIFFERENCE:
154
-
155
- Claude Code (Full Automation):
156
- - Native skills (auto-activate)
157
- - Native agents (separate context windows)
158
- - Native hooks (auto-update docs)
159
- - Slash commands (/inc, /do, /done)
160
-
161
- Cursor (Semi-Automation):
162
- - Reads AGENTS.md for workflow
163
- - @ context shortcuts
164
- - Composer multi-file editing
165
-
166
- Copilot (Basic Automation - This Adapter):
167
- - Reads AGENTS.md automatically
168
- - Better code suggestions
169
- - No skills, agents, hooks, or commands
170
- - Manual workflow with AI assistance
171
-
172
- HOW COPILOT USES AGENTS.MD:
173
-
174
- GitHub Copilot automatically reads AGENTS.md to understand:
175
- - SpecWeave structure (.specweave/ folders)
176
- - File naming conventions (spec.md, plan.md, tasks.md)
177
- - Context manifests (what files to reference)
178
- - Best practices (technology-agnostic specs, etc.)
179
-
180
- Result: Copilot suggests code that fits SpecWeave patterns!
181
-
182
- HOW TO USE SPECWEAVE WITH COPILOT:
183
-
184
- 1. Copilot reads AGENTS.md automatically
185
- - No action needed - just open project in VS Code
186
- - Copilot will suggest code following SpecWeave patterns
187
-
188
- 2. Create increments manually:
189
- mkdir -p .specweave/increments/0001-user-auth
190
-
191
- 3. Reference context manifests:
192
- Open context-manifest.yaml
193
- → Copilot sees which files are relevant
194
- → Provides better suggestions
195
-
196
- 4. Ask Copilot Chat for guidance:
197
- "How do I create a spec.md following SpecWeave?"
198
- "Generate plan.md for user authentication"
199
- "What should go in context-manifest.yaml?"
200
-
201
- 5. Use Copilot inline suggestions:
202
- Start typing in spec.md → Copilot suggests content
203
- Following SpecWeave patterns from AGENTS.md
204
-
205
- WORKFLOW EXAMPLE:
206
-
207
- Creating a Feature:
208
-
209
- 1. Create increment folder:
210
- mkdir -p .specweave/increments/0002-payments
211
- cd .specweave/increments/0002-payments
212
-
213
- 2. Create spec.md:
214
- - Open file, start typing frontmatter
215
- - Copilot suggests SpecWeave structure (from AGENTS.md)
216
- - Fill in user stories, acceptance criteria
217
-
218
- 3. Create plan.md:
219
- - Reference spec.md (Copilot reads it)
220
- - Start typing "# Technical Plan"
221
- - Copilot suggests architecture sections
222
-
223
- 4. Create context-manifest.yaml:
224
- - Copilot suggests relevant files to include
225
- - Lists spec sections and architecture docs
226
-
227
- LIMITATIONS (vs Claude Code & Cursor):
228
-
229
- - No auto-activation or workflows
230
- - No skills, agents, hooks
231
- - No slash commands or @ shortcuts
232
- - No role-based assistance (PM, Architect, etc.)
233
- - Completely manual workflow
234
-
235
- But Copilot still provides helpful suggestions!
236
- - Understands SpecWeave structure from AGENTS.md
237
- - Suggests code following project patterns
238
-
239
- DOCUMENTATION:
240
-
241
- - AGENTS.md: Universal workflow instructions (Copilot reads this!)
242
- - .specweave/docs/: Project documentation
243
-
244
- You're ready to build with SpecWeave on GitHub Copilot!
245
-
246
- Note: For better automation, consider Claude Code (full) or Cursor (semi).
247
- Copilot is best for simple projects or when already using VS Code + Copilot.
248
- `;
249
- }
250
-
251
- /**
252
- * Check if Copilot adapter supports plugins
253
- *
254
- * Copilot has plugin support via AGENTS.md compilation (same as Cursor)
255
- *
256
- * @returns boolean True for Copilot
257
- */
258
- supportsPlugins(): boolean {
259
- return true;
260
- }
261
-
262
- /**
263
- * Read language configuration from project config
264
- *
265
- * @returns Language setting from config, defaults to 'en'
266
- */
267
- private async getLanguageConfig(): Promise<SupportedLanguage> {
268
- const projectPath = process.cwd();
269
- const configPath = path.join(projectPath, '.specweave', 'config.json');
270
-
271
- if (!(await fs.pathExists(configPath))) {
272
- return 'en'; // Default to English if no config
273
- }
274
-
275
- try {
276
- const config = await fs.readJson(configPath);
277
- return (config.language as SupportedLanguage) || 'en';
278
- } catch (error) {
279
- console.warn('āš ļø Could not read language from config, defaulting to English');
280
- return 'en';
281
- }
282
- }
283
-
284
- /**
285
- * Inject system prompt for non-English languages
286
- *
287
- * Prepends language instruction to markdown content if language !== 'en'
288
- *
289
- * @param content Original markdown content
290
- * @param language Target language
291
- * @returns Modified content with system prompt (or unchanged if English)
292
- */
293
- private injectSystemPrompt(content: string, language: SupportedLanguage): string {
294
- if (language === 'en') {
295
- return content; // No changes for English - preserve default behavior
296
- }
297
-
298
- // Get system prompt for target language
299
- const systemPrompt = getSystemPromptForLanguage(language);
300
-
301
- // For AGENTS.md compilation, inject at the beginning of the content
302
- return `${systemPrompt}\n\n${content}`;
303
- }
304
-
305
- /**
306
- * Compile and install a plugin for Copilot
307
- *
308
- * Copilot uses AGENTS.md compilation (same as Cursor)
309
- *
310
- * NEW: Injects system prompts for non-English languages
311
- *
312
- * @param plugin Plugin to install
313
- */
314
- async compilePlugin(plugin: Plugin): Promise<void> {
315
- const projectPath = process.cwd();
316
- const agentsMdPath = path.join(projectPath, 'AGENTS.md');
317
-
318
- console.log(`\nšŸ“¦ Compiling plugin for Copilot: ${plugin.manifest.name}`);
319
-
320
- // Get language configuration for system prompt injection
321
- const language = await this.getLanguageConfig();
322
- if (language !== 'en') {
323
- console.log(` 🌐 Language: ${language} (system prompts will be injected)`);
324
- }
325
-
326
- if (!(await fs.pathExists(agentsMdPath))) {
327
- throw new Error('AGENTS.md not found. Run specweave init first.');
328
- }
329
-
330
- let agentsMd = await fs.readFile(agentsMdPath, 'utf-8');
331
-
332
- const pluginMarker = `<!-- Plugin: ${plugin.manifest.name} -->`;
333
- if (agentsMd.includes(pluginMarker)) {
334
- console.log(` ā„¹ļø Plugin ${plugin.manifest.name} already compiled to AGENTS.md`);
335
- return;
336
- }
337
-
338
- let pluginSection = `\n\n${pluginMarker}\n\n`;
339
- pluginSection += `# Plugin: ${plugin.manifest.name}\n\n`;
340
- pluginSection += `${plugin.manifest.description}\n\n`;
341
-
342
- if (plugin.skills.length > 0) {
343
- pluginSection += `## Skills\n\n`;
344
- for (const skill of plugin.skills) {
345
- const skillContent = await fs.readFile(path.join(skill.path, 'SKILL.md'), 'utf-8');
346
- const contentWithoutFrontmatter = skillContent.replace(/^---\n[\s\S]+?\n---\n/, '');
347
- // Inject system prompt if needed
348
- const modifiedContent = this.injectSystemPrompt(contentWithoutFrontmatter, language);
349
- pluginSection += `### ${skill.name}\n\n${modifiedContent}\n\n`;
350
- }
351
- }
352
-
353
- if (plugin.agents.length > 0) {
354
- pluginSection += `## Agents\n\n`;
355
- for (const agent of plugin.agents) {
356
- const agentContent = await fs.readFile(path.join(agent.path, 'AGENT.md'), 'utf-8');
357
- // Inject system prompt if needed
358
- const modifiedContent = this.injectSystemPrompt(agentContent, language);
359
- pluginSection += `### ${agent.name}\n\n${modifiedContent}\n\n`;
360
- }
361
- }
362
-
363
- if (plugin.commands.length > 0) {
364
- pluginSection += `## Commands\n\n`;
365
- for (const command of plugin.commands) {
366
- const commandContent = await fs.readFile(command.path, 'utf-8');
367
- const contentWithoutFrontmatter = commandContent.replace(/^---\n[\s\S]+?\n---\n/, '');
368
- // Inject system prompt if needed
369
- const modifiedContent = this.injectSystemPrompt(contentWithoutFrontmatter, language);
370
- pluginSection += `### /${command.name}\n\n${modifiedContent}\n\n`;
371
- }
372
- }
373
-
374
- pluginSection += `<!-- End Plugin: ${plugin.manifest.name} -->\n`;
375
-
376
- agentsMd += pluginSection;
377
- await fs.writeFile(agentsMdPath, agentsMd, 'utf-8');
378
-
379
- console.log(` āœ“ Compiled to AGENTS.md`);
380
- console.log(` āœ“ ${plugin.skills.length} skills, ${plugin.agents.length} agents, ${plugin.commands.length} commands`);
381
- console.log(`\nāœ… Plugin ${plugin.manifest.name} compiled for Copilot!`);
382
- }
383
-
384
- /**
385
- * Unload a plugin from Copilot
386
- */
387
- async unloadPlugin(pluginName: string): Promise<void> {
388
- const projectPath = process.cwd();
389
- const agentsMdPath = path.join(projectPath, 'AGENTS.md');
390
-
391
- console.log(`\nšŸ—‘ļø Unloading plugin from Copilot: ${pluginName}`);
392
-
393
- if (!(await fs.pathExists(agentsMdPath))) {
394
- console.warn(`āš ļø AGENTS.md not found`);
395
- return;
396
- }
397
-
398
- let agentsMd = await fs.readFile(agentsMdPath, 'utf-8');
399
-
400
- const startMarker = `<!-- Plugin: ${pluginName} -->`;
401
- const endMarker = `<!-- End Plugin: ${pluginName} -->`;
402
-
403
- const startIndex = agentsMd.indexOf(startMarker);
404
- if (startIndex === -1) {
405
- console.warn(`āš ļø Plugin ${pluginName} not found in AGENTS.md`);
406
- return;
407
- }
408
-
409
- const endIndex = agentsMd.indexOf(endMarker, startIndex);
410
- if (endIndex === -1) {
411
- console.warn(`āš ļø Plugin ${pluginName} section malformed`);
412
- return;
413
- }
414
-
415
- agentsMd = agentsMd.slice(0, startIndex) + agentsMd.slice(endIndex + endMarker.length);
416
- await fs.writeFile(agentsMdPath, agentsMd, 'utf-8');
417
-
418
- console.log(` āœ“ Removed from AGENTS.md`);
419
- console.log(`\nāœ… Plugin ${pluginName} unloaded!`);
420
- }
421
-
422
- /**
423
- * Get list of installed plugins for Copilot
424
- */
425
- async getInstalledPlugins(): Promise<string[]> {
426
- const projectPath = process.cwd();
427
- const agentsMdPath = path.join(projectPath, 'AGENTS.md');
428
-
429
- if (!(await fs.pathExists(agentsMdPath))) {
430
- return [];
431
- }
432
-
433
- const agentsMd = await fs.readFile(agentsMdPath, 'utf-8');
434
- const pluginMarkerRegex = /<!-- Plugin: (specweave-[a-z0-9-]+) -->/g;
435
- const matches = agentsMd.matchAll(pluginMarkerRegex);
436
-
437
- const plugins: string[] = [];
438
- for (const match of matches) {
439
- plugins.push(match[1]);
440
- }
441
-
442
- return plugins;
443
- }
444
- }