@crewpilot/agent 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,181 @@
1
+ # Knowledge Base
2
+
3
+ > **Pillar**: Insights | **ID**: `insights-knowledge-base`
4
+
5
+ ## Purpose
6
+
7
+ Persistent cross-session memory system. Stores decisions, patterns, lessons learned, and context so the team's knowledge compounds over time instead of resetting every conversation.
8
+
9
+ ## Activation Triggers
10
+
11
+ - "remember this", "recall", "what did we decide about"
12
+ - "history", "past decisions", "context from last time"
13
+ - "save this insight", "knowledge base"
14
+ - Implicitly used by other skills to check for prior context
15
+
16
+ ## Methodology
17
+
18
+ ### Process Flow
19
+
20
+ ```dot
21
+ digraph knowledge_base {
22
+ rankdir=TB;
23
+ node [shape=box];
24
+
25
+ subgraph cluster_store {
26
+ label="Store Operations";
27
+ decision [label="Store Decision"];
28
+ lesson [label="Store Lesson"];
29
+ pattern [label="Store Pattern"];
30
+ }
31
+
32
+ subgraph cluster_retrieve {
33
+ label="Retrieve Operations";
34
+ query [label="Direct Query"];
35
+ contextual [label="Contextual Retrieval\n(by other skills)"];
36
+ timeline [label="Timeline View"];
37
+ }
38
+
39
+ subgraph cluster_maintain {
40
+ label="Maintenance";
41
+ consolidate [label="Pattern Consolidation"];
42
+ export [label="Knowledge Export", shape=doublecircle];
43
+ }
44
+
45
+ decision -> query [style=dotted];
46
+ lesson -> query [style=dotted];
47
+ pattern -> query [style=dotted];
48
+ contextual -> consolidate [style=dotted, label="periodic"];
49
+ consolidate -> export;
50
+ }
51
+ ```
52
+
53
+ ### Store Operations
54
+
55
+ #### Store a Decision
56
+ When a significant decision is made during any skill:
57
+ 1. Extract: decision, rationale, alternatives rejected, date, related files
58
+ 2. Tag with categories: `architecture`, `technology`, `process`, `convention`
59
+ 3. Store via `catalyst_knowledge_store`
60
+
61
+ Entry format:
62
+ ```json
63
+ {
64
+ "type": "decision",
65
+ "title": "{short title}",
66
+ "content": "{decision and rationale}",
67
+ "tags": ["{category}", "{technology}"],
68
+ "related_files": ["{paths}"],
69
+ "timestamp": "{ISO date}"
70
+ }
71
+ ```
72
+
73
+ #### Store a Lesson Learned
74
+ When debugging reveals a non-obvious insight:
75
+ 1. Extract: what happened, why, prevention measure
76
+ 2. Tag with: `bug`, `performance`, `security`, `gotcha`
77
+ 3. Link to the fix commit if available
78
+
79
+ #### Store a Pattern
80
+ When `pattern-detection` identifies a codebase convention:
81
+ 1. Document the pattern with a code example
82
+ 2. Tag with: `pattern`, `convention`, `style`
83
+ 3. Reference canonical implementation files
84
+
85
+ ### Retrieve Operations
86
+
87
+ #### Direct Query
88
+ User asks "what did we decide about X":
89
+ 1. Search knowledge base via `catalyst_knowledge_search`
90
+ 2. Return matching entries with context
91
+ 3. If multiple matches, rank by relevance and recency
92
+
93
+ #### Contextual Retrieval (by other skills)
94
+ Skills query the knowledge base before starting:
95
+ 1. `solution-design` checks for prior decisions on the same topic
96
+ 2. `architecture-planner` retrieves existing ADRs
97
+ 3. `root-cause-analysis` checks if similar bugs were solved before
98
+ 4. `code-quality` retrieves documented conventions
99
+
100
+ #### Timeline View
101
+ User asks "what happened this week/sprint":
102
+ 1. Retrieve entries within the time range via `catalyst_knowledge_timeline`
103
+ 2. Group by type (decisions, lessons, patterns)
104
+ 3. Present as a chronological narrative
105
+
106
+ ### Maintenance Operations
107
+
108
+ #### Pattern Consolidation
109
+ Periodically:
110
+ 1. Identify related entries that can be merged
111
+ 2. Archive stale entries (decisions reversed, patterns abandoned)
112
+ 3. Flag contradictory entries for resolution
113
+
114
+ #### Knowledge Export
115
+ Generate a summary document:
116
+ 1. Active decisions and their current status
117
+ 2. Team conventions with code examples
118
+ 3. Common gotchas and their solutions
119
+
120
+ ## Tools Required
121
+
122
+ - `catalyst_knowledge_store` — Write entries to the knowledge base
123
+ - `catalyst_knowledge_search` — Full-text search across entries
124
+ - `catalyst_knowledge_timeline` — Time-range queries
125
+ - `catalyst_knowledge_patterns` — Pattern frequency analysis
126
+ - `catalyst_knowledge_export` — Generate summary documents
127
+
128
+ ## Output Format
129
+
130
+ ### For Storage
131
+ ```
132
+ ## [Catalyst → Knowledge Base: Stored]
133
+
134
+ ✓ Stored: {type} — "{title}"
135
+ Tags: {tags}
136
+ Related: {files}
137
+ ```
138
+
139
+ ### For Retrieval
140
+ ```
141
+ ## [Catalyst → Knowledge Base: Retrieved]
142
+
143
+ ### Results for "{query}"
144
+ Found {N} entries:
145
+
146
+ #### {title} ({type}, {date})
147
+ {content}
148
+ **Tags**: {tags}
149
+ **Related files**: {paths}
150
+
151
+ ---
152
+ (repeat per entry)
153
+ ```
154
+
155
+ ### For Timeline
156
+ ```
157
+ ## [Catalyst → Knowledge Base: Timeline]
158
+
159
+ ### {date range}
160
+
161
+ **Decisions**
162
+ - {title}: {summary}
163
+
164
+ **Lessons Learned**
165
+ - {title}: {summary}
166
+
167
+ **Patterns**
168
+ - {title}: {summary}
169
+ ```
170
+
171
+ ## Chains To
172
+
173
+ - Any skill can chain TO knowledge-base to store findings
174
+ - Knowledge-base is queried BY other skills, but doesn't chain outward
175
+
176
+ ## Anti-Patterns
177
+
178
+ - Do NOT store trivial information — only decisions, lessons, and patterns
179
+ - Do NOT store ephemeral state (what files are open, current branch)
180
+ - Do NOT return raw database entries — synthesize into readable summaries
181
+ - Do NOT store sensitive data (credentials, tokens, personal info)
@@ -0,0 +1,142 @@
1
+ # Pattern Detection
2
+
3
+ > **Pillar**: Insights | **ID**: `insights-pattern-detection`
4
+
5
+ ## Purpose
6
+
7
+ Codebase-wide pattern mining and anti-pattern identification. Analyzes structural health, detects recurring issues, tracks technical debt, and identifies emerging trends across the project.
8
+
9
+ ## Activation Triggers
10
+
11
+ - "codebase health", "find patterns", "anti-patterns", "tech debt"
12
+ - "what patterns are we using", "code trends", "structural analysis"
13
+ - Automatically triggered when `root-cause-analysis` finds a systemic issue
14
+
15
+ ## Methodology
16
+
17
+ ### Process Flow
18
+
19
+ ```dot
20
+ digraph pattern_detection {
21
+ rankdir=TB;
22
+ node [shape=box];
23
+
24
+ structure [label="Phase 1\nStructure Scan"];
25
+ mining [label="Phase 2\nPattern Mining"];
26
+ antipattern [label="Phase 3\nAnti-Pattern Detection"];
27
+ debt [label="Phase 4\nTechnical Debt Inventory"];
28
+ trends [label="Phase 5\nTrend Analysis", shape=diamond];
29
+ report [label="Report", shape=doublecircle];
30
+
31
+ structure -> mining;
32
+ mining -> antipattern;
33
+ antipattern -> debt;
34
+ debt -> trends;
35
+ trends -> report [label="historical\ndata available"];
36
+ debt -> report [label="no historical data"];
37
+ }
38
+ ```
39
+
40
+ ### Phase 1 — Structure Scan
41
+ 1. Map the project structure: directories, modules, layers
42
+ 2. Identify architectural patterns in use:
43
+ - MVC, MVVM, Clean Architecture, Hexagonal
44
+ - Microservices vs. monolith vs. modular monolith
45
+ - API patterns: REST, GraphQL, RPC
46
+ 3. Detect organizational patterns: feature-based vs. layer-based vs. hybrid
47
+
48
+ ### Phase 2 — Pattern Mining
49
+ Scan for recurring code patterns:
50
+
51
+ | Category | Patterns to Detect |
52
+ |---|---|
53
+ | **Error handling** | Try-catch styles, error propagation, error types |
54
+ | **Data access** | ORM patterns, raw queries, repository pattern |
55
+ | **State management** | Global state, dependency injection, singletons |
56
+ | **API design** | Route organization, middleware chains, validation |
57
+ | **Testing** | Test structure, mock strategies, fixture patterns |
58
+ | **Configuration** | Env vars, config objects, feature flags |
59
+
60
+ For each pattern found:
61
+ - **Frequency**: How often it appears
62
+ - **Consistency**: Are there deviations from the pattern?
63
+ - **Quality**: Is this a good pattern for this context?
64
+
65
+ ### Phase 3 — Anti-Pattern Detection
66
+ Flag known anti-patterns:
67
+
68
+ | Anti-Pattern | Symptoms |
69
+ |---|---|
70
+ | **God Object/File** | Single file > 500 lines with mixed responsibilities |
71
+ | **Circular Dependencies** | Module A imports B imports A |
72
+ | **Shotgun Surgery** | Small change requires touching 5+ files |
73
+ | **Feature Envy** | Function uses more of another module's data than its own |
74
+ | **Dead Code** | Unreachable functions, unused exports |
75
+ | **Copy-Paste** | Near-duplicate code blocks across files |
76
+ | **Primitive Obsession** | Strings/numbers used where domain types belong |
77
+ | **Configuration Drift** | Same setting configured differently in multiple places |
78
+
79
+ ### Phase 4 — Technical Debt Inventory
80
+ For each anti-pattern or inconsistency:
81
+ 1. Estimate effort to fix (T-shirt size)
82
+ 2. Assess impact on team velocity
83
+ 3. Rate urgency: address now vs. track vs. accept
84
+
85
+ ### Phase 5 — Trend Analysis
86
+ If `catalyst_knowledge_search` has historical data:
87
+ 1. Compare current patterns vs. previous scans
88
+ 2. Identify patterns that are spreading (good or bad)
89
+ 3. Flag entropy increase — growing inconsistency over time
90
+
91
+ ## Tools Required
92
+
93
+ - `codebase` — Full project scan
94
+ - `terminal` — Run static analysis tools
95
+ - `catalyst_metrics_complexity` — Complexity metrics per module
96
+ - `catalyst_knowledge_search` — Historical pattern data
97
+ - `catalyst_knowledge_store` — Record findings for future comparison
98
+
99
+ ## Output Format
100
+
101
+ ```
102
+ ## [Catalyst → Pattern Detection]
103
+
104
+ ### Architecture
105
+ {detected patterns and organization style}
106
+
107
+ ### Code Patterns
108
+ | Pattern | Category | Frequency | Consistency | Quality |
109
+ |---|---|---|---|---|
110
+ | {pattern} | {category} | {count} | {high/medium/low} | {good/acceptable/poor} |
111
+
112
+ ### Anti-Patterns
113
+ | Anti-Pattern | Locations | Severity | Fix Effort |
114
+ |---|---|---|---|
115
+ | {anti-pattern} | {files/modules} | {high/med/low} | {T-shirt} |
116
+
117
+ ### Technical Debt
118
+ | Item | Impact | Urgency | Effort |
119
+ |---|---|---|---|
120
+ | {debt item} | {velocity/quality/security} | {now/track/accept} | {T-shirt} |
121
+
122
+ ### Trends (if historical data available)
123
+ {getting better / getting worse / stable}
124
+
125
+ ### Summary
126
+ Codebase health: {score}/10
127
+ Top concern: {most impactful issue}
128
+ Quick wins: {list of low-effort improvements}
129
+ ```
130
+
131
+ ## Chains To
132
+
133
+ - `code-quality` — Deep review of flagged anti-pattern locations
134
+ - `architecture-planner` — Restructure if systemic issues found
135
+ - `knowledge-base` — Store scan results for trend tracking
136
+
137
+ ## Anti-Patterns (meta)
138
+
139
+ - Do NOT flag patterns as anti-patterns based on ideology — evaluate in context
140
+ - Do NOT report dead code without verifying it's truly unreachable
141
+ - Do NOT recommend rewrites for working code with manageable debt
142
+ - Do NOT present a massive list without prioritization
@@ -0,0 +1,141 @@
1
+ # Architecture Planner
2
+
3
+ > **Pillar**: Strategize | **ID**: `strategize-architecture-planner`
4
+
5
+ ## Purpose
6
+
7
+ Transform decisions into concrete architecture plans with component diagrams, API contracts, data flow, and implementation roadmaps. Produces living design documents that evolve with the codebase.
8
+
9
+ ## Activation Triggers
10
+
11
+ - "plan the architecture", "design the system", "create an RFC", "structure this"
12
+ - "how should I organize", "component diagram", "data flow", "API design"
13
+ - After `solution-design` selects an approach that needs detailing
14
+
15
+ ## Methodology
16
+
17
+ ### Process Flow
18
+
19
+ ```dot
20
+ digraph architecture_planner {
21
+ rankdir=TB;
22
+ node [shape=box];
23
+
24
+ scope [label="Phase 1\nScope Definition"];
25
+ components [label="Phase 2\nComponent Design"];
26
+ dataflow [label="Phase 3\nData Flow"];
27
+ roadmap [label="Phase 4\nImplementation Roadmap"];
28
+ adr [label="Phase 5\nADR", shape=diamond, style=filled, fillcolor="#ffcccc"];
29
+ feature [label="feature-builder\n(Milestone M1)", shape=doublecircle];
30
+
31
+ scope -> components;
32
+ components -> dataflow;
33
+ dataflow -> roadmap;
34
+ roadmap -> adr;
35
+ adr -> feature [label="approved"];
36
+ adr -> components [label="user requests\nrevisions"];
37
+ }
38
+ ```
39
+
40
+ ### Phase 1 — Scope Definition
41
+ 1. Identify system boundaries — what's in scope vs. out of scope
42
+ 2. List actors (users, services, external systems)
43
+ 3. Define key quality attributes: scalability, latency, availability, consistency
44
+ 4. Read existing codebase structure to understand current architecture
45
+
46
+ ### Phase 2 — Component Design
47
+ 1. Decompose into components/modules with clear responsibilities
48
+ 2. Define interfaces between components (API contracts, event schemas)
49
+ 3. Identify shared dependencies and data stores
50
+ 4. Map to existing code structure where applicable
51
+
52
+ Output as a component table:
53
+
54
+ | Component | Responsibility | Inputs | Outputs | Dependencies |
55
+ |---|---|---|---|---|
56
+ | | | | | |
57
+
58
+ ### Phase 3 — Data Flow
59
+ 1. Trace the primary user journey through the system
60
+ 2. Identify data transformations at each step
61
+ 3. Mark synchronous vs. asynchronous boundaries
62
+ 4. Identify potential bottlenecks and failure points
63
+
64
+ Produce a numbered flow:
65
+ ```
66
+ 1. User → API Gateway (HTTPS)
67
+ 2. API Gateway → Auth Service (validate token)
68
+ 3. Auth Service → User DB (query)
69
+ ...
70
+ ```
71
+
72
+ ### Phase 4 — Implementation Roadmap
73
+ 1. Break into milestones (each independently deployable/testable)
74
+ 2. Order by dependency graph — foundations first
75
+ 3. Estimate effort per milestone (T-shirt sizes)
76
+ 4. Identify the critical path
77
+ 5. Mark "go/no-go" decision points
78
+
79
+ ### Phase 5 — ADR (Architecture Decision Record)
80
+
81
+ <HARD-GATE>
82
+ Do NOT begin implementation until the architecture plan (components, data flow, roadmap) has been presented to and approved by the user.
83
+ If the user has not explicitly confirmed the architecture, do NOT proceed.
84
+ </HARD-GATE>
85
+
86
+ If `require_adr` is true in config, generate:
87
+
88
+ ```markdown
89
+ # ADR-{NNN}: {Title}
90
+
91
+ ## Status: Proposed
92
+ ## Context: {why this decision is needed}
93
+ ## Decision: {what was decided}
94
+ ## Consequences: {positive and negative}
95
+ ## Alternatives Considered: {options rejected and why}
96
+ ```
97
+
98
+ ## Tools Required
99
+
100
+ - `codebase` — Analyze existing project structure and dependencies
101
+ - `terminal` — Run dependency analysis commands (package.json, imports, etc.)
102
+ - `catalyst_knowledge_search` — Retrieve prior architecture decisions
103
+
104
+ ## Output Format
105
+
106
+ ```
107
+ ## [Catalyst → Architecture Planner]
108
+
109
+ ### Scope
110
+ {boundaries, actors, quality attributes}
111
+
112
+ ### Components
113
+ {component table}
114
+
115
+ ### Data Flow
116
+ {numbered flow}
117
+
118
+ ### Implementation Roadmap
119
+ | Milestone | Description | Effort | Dependencies |
120
+ |---|---|---|---|
121
+ | M1 | | | |
122
+
123
+ ### Critical Path
124
+ {sequence}
125
+
126
+ ### ADR (if enabled)
127
+ {ADR document}
128
+ ```
129
+
130
+ ## Chains To
131
+
132
+ - `feature-builder` — Start implementing milestone M1
133
+ - `test-first` — Write integration tests for component interfaces
134
+ - `doc-governance` — Ensure architecture docs stay synchronized
135
+
136
+ ## Anti-Patterns
137
+
138
+ - Do NOT design in a vacuum — always scan the existing codebase first
139
+ - Do NOT create components with unclear responsibilities (god-service smell)
140
+ - Do NOT skip the roadmap — architecture without sequencing is just a diagram
141
+ - Do NOT ignore existing patterns — evolve, don't replace, unless explicitly asked
@@ -0,0 +1,118 @@
1
+ # Solution Design
2
+
3
+ > **Pillar**: Strategize | **ID**: `strategize-solution-design`
4
+
5
+ ## Purpose
6
+
7
+ Structured ideation and trade-off analysis for technical decisions. Transforms vague questions into evaluated options with clear recommendations.
8
+
9
+ ## Activation Triggers
10
+
11
+ - "brainstorm", "explore options", "what are the approaches", "tradeoffs", "should I use X or Y"
12
+ - Any open-ended technical question with multiple viable paths
13
+
14
+ ## Methodology
15
+
16
+ ### Process Flow
17
+
18
+ ```dot
19
+ digraph solution_design {
20
+ rankdir=TB;
21
+ node [shape=box];
22
+
23
+ frame [label="Phase 1\nProblem Framing"];
24
+ options [label="Phase 2\nOption Generation\n(3-4 approaches)"];
25
+ matrix [label="Phase 3\nTrade-off Matrix"];
26
+ recommend [label="Phase 4\nRecommendation", shape=diamond, style=filled, fillcolor="#ffcccc"];
27
+ arch [label="architecture-planner", shape=doublecircle];
28
+ build [label="feature-builder", shape=doublecircle];
29
+
30
+ frame -> options;
31
+ options -> matrix;
32
+ matrix -> recommend;
33
+ recommend -> arch [label="needs detailed design"];
34
+ recommend -> build [label="ready to implement"];
35
+ recommend -> options [label="user rejects\nall options"];
36
+ }
37
+ ```
38
+
39
+ ### Phase 1 — Problem Framing
40
+ 1. Restate the problem in one sentence
41
+ 2. Identify constraints: time, team size, existing tech stack, scale requirements
42
+ 3. Ask 1-2 clarifying questions ONLY if the problem is genuinely ambiguous
43
+
44
+ ### Phase 2 — Option Generation
45
+ 1. Generate 3-4 distinct approaches (configurable via `max_options` in config)
46
+ 2. Each option must include:
47
+ - **Name**: Short memorable label
48
+ - **Approach**: 2-3 sentence description
49
+ - **Strengths**: What it does well
50
+ - **Risks**: What could go wrong
51
+ - **Effort**: T-shirt size (S/M/L/XL) with justification
52
+ 3. Options must be genuinely different — not variations of the same approach
53
+
54
+ ### Phase 3 — Trade-off Matrix
55
+ Build a comparison table:
56
+
57
+ | Criterion | Option A | Option B | Option C |
58
+ |---|---|---|---|
59
+ | Implementation effort | | | |
60
+ | Maintainability | | | |
61
+ | Performance | | | |
62
+ | Team familiarity | | | |
63
+
64
+ Rate each cell: `++` (strong), `+` (good), `~` (neutral), `-` (weak), `--` (poor)
65
+
66
+ ### Phase 4 — Recommendation
67
+
68
+ <HARD-GATE>
69
+ Do NOT proceed to implementation or architecture planning until the user has reviewed the trade-off matrix and confirmed the recommended option.
70
+ Present the recommendation and wait for explicit approval or selection.
71
+ </HARD-GATE>
72
+
73
+ 1. State the recommended option clearly
74
+ 2. Provide confidence level (1-10) with reasoning
75
+ 3. Identify the "decision reversal cost" — how hard is it to switch later
76
+ 4. List 1-2 things to validate before committing
77
+
78
+ ## Tools Required
79
+
80
+ - `codebase` — Scan existing stack for constraints
81
+ - `fetch` — Pull external docs/benchmarks when comparing technologies
82
+ - `catalyst_knowledge_search` — Check if similar decisions were made before
83
+
84
+ ## Output Format
85
+
86
+ ```
87
+ ## [Catalyst → Solution Design]
88
+
89
+ ### Problem
90
+ {one-sentence problem statement}
91
+
92
+ ### Options
93
+ 1. **{Name}** — {approach}
94
+ - Strengths: ...
95
+ - Risks: ...
96
+ - Effort: {T-shirt}
97
+
98
+ ### Trade-off Matrix
99
+ {table}
100
+
101
+ ### Recommendation
102
+ **{Option Name}** (Confidence: {N}/10)
103
+ {reasoning}
104
+
105
+ **Reversal cost**: {Low/Medium/High}
106
+ **Validate first**: {list}
107
+ ```
108
+
109
+ ## Chains To
110
+
111
+ - `architecture-planner` — When the recommended option needs detailed design
112
+ - `feature-builder` — When the user wants to start implementing immediately
113
+
114
+ ## Anti-Patterns
115
+
116
+ - Do NOT generate options just to fill a quota — 2 genuine options beat 4 padded ones
117
+ - Do NOT recommend without stating confidence and reversal cost
118
+ - Do NOT skip the trade-off matrix — it's the core value of this skill
@@ -0,0 +1,108 @@
1
+ /**
2
+ * postinstall.js — Runs after `npm install @crewpilot/agent`
3
+ *
4
+ * Creates .github/ files in the user's project so @Catalyst agent
5
+ * appears in Copilot Chat dropdown automatically.
6
+ *
7
+ * Uses INIT_CWD (set by npm to the directory where `npm install` was run).
8
+ * Silently exits on global installs or npx (no project root).
9
+ */
10
+
11
+ import fs from 'fs';
12
+ import path from 'path';
13
+ import { fileURLToPath } from 'url';
14
+
15
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
+
17
+ // INIT_CWD is the directory where the user ran `npm install`
18
+ const projectRoot = process.env.INIT_CWD;
19
+
20
+ // Skip if no project root (global install, npx, CI, etc.)
21
+ if (!projectRoot) {
22
+ process.exit(0);
23
+ }
24
+
25
+ // Skip if installing as a dependency of this package itself (dev scenario)
26
+ const ownPackageDir = path.join(__dirname, '..');
27
+ if (path.resolve(projectRoot) === path.resolve(ownPackageDir)) {
28
+ process.exit(0);
29
+ }
30
+
31
+ // Skip if no package.json in project root (not a real project)
32
+ if (!fs.existsSync(path.join(projectRoot, 'package.json'))) {
33
+ process.exit(0);
34
+ }
35
+
36
+ const githubDir = path.join(projectRoot, '.github');
37
+ const promptsDir = path.join(__dirname, '..', 'prompts');
38
+
39
+ // If prompts aren't bundled, silently exit
40
+ if (!fs.existsSync(promptsDir)) {
41
+ process.exit(0);
42
+ }
43
+
44
+ let created = 0;
45
+ let skipped = 0;
46
+
47
+ /**
48
+ * Copy a file from prompts/ to .github/ — never overwrites existing files
49
+ */
50
+ function syncFile(srcName, destRelative) {
51
+ const src = path.join(promptsDir, srcName);
52
+ const dest = path.join(githubDir, destRelative);
53
+
54
+ if (!fs.existsSync(src)) return;
55
+
56
+ if (fs.existsSync(dest)) {
57
+ skipped++;
58
+ return;
59
+ }
60
+
61
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
62
+ fs.copyFileSync(src, dest);
63
+ created++;
64
+ }
65
+
66
+ /**
67
+ * Copy all skills from prompts/skills/ to .github/skills/
68
+ */
69
+ function syncSkills() {
70
+ const skillsDir = path.join(promptsDir, 'skills');
71
+ if (!fs.existsSync(skillsDir)) return;
72
+
73
+ const skillDirs = fs.readdirSync(skillsDir).filter(d =>
74
+ fs.statSync(path.join(skillsDir, d)).isDirectory()
75
+ );
76
+
77
+ for (const name of skillDirs) {
78
+ const src = path.join(skillsDir, name, 'SKILL.md');
79
+ if (!fs.existsSync(src)) continue;
80
+
81
+ const dest = path.join(githubDir, 'skills', name, 'SKILL.md');
82
+ if (fs.existsSync(dest)) {
83
+ skipped++;
84
+ continue;
85
+ }
86
+
87
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
88
+ fs.copyFileSync(src, dest);
89
+ created++;
90
+ }
91
+ }
92
+
93
+ // --- Run ---
94
+ try {
95
+ fs.mkdirSync(githubDir, { recursive: true });
96
+
97
+ syncFile('agent.md', path.join('agents', 'catalyst.md'));
98
+ syncFile('copilot-instructions.md', 'copilot-instructions.md');
99
+ syncFile('catalyst.config.json', 'catalyst.config.json');
100
+ syncSkills();
101
+
102
+ if (created > 0) {
103
+ console.log(`\n ⚡ CrewPilot: Created ${created} file(s) in .github/ (${skipped} already existed)`);
104
+ console.log(' ⚡ Open Copilot Chat and select @Catalyst from the agent dropdown\n');
105
+ }
106
+ } catch {
107
+ // Silently fail — postinstall should never break npm install
108
+ }