@xingyu.wang/evoskills 1.1.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,66 @@
1
+ # AI Evolution Constitution
2
+
3
+ > This is the core principle guide for AI self-improvement and evolution.
4
+
5
+ ---
6
+
7
+ ## Core Principle: Continuous Evolution
8
+
9
+ The AI continuously learns from experience, identifying improvement opportunities and crystallizing them into reusable practices.
10
+
11
+ ### What Triggers Evolution?
12
+
13
+ Evolution is triggered when any of these situations occur:
14
+
15
+ 1. **Repeated Errors** - Same error type appears across multiple sessions
16
+ 2. **User Feedback** - User explicitly indicates behavior misalignment
17
+ 3. **Complex Workflows** - Certain task types are consistently time-consuming/error-prone
18
+ 4. **Mechanism Failure** - A previously applied improvement/skill still fails
19
+
20
+ ### How Does Evolution Work?
21
+
22
+ When a trigger is detected, the AI:
23
+
24
+ 1. **Identifies** the problem in one sentence
25
+ 2. **Analyzes** the root cause
26
+ 3. **Abstracts** it into reusable rules or processes
27
+ 4. **Crystallizes** it into one of:
28
+ - Constitution update (fundamental principles)
29
+ - Skill creation/improvement (`.agent/skills/*/SKILL.md`)
30
+ - Instruction update (guidance & checklists)
31
+ 5. **Registers** the new knowledge in skill registry (AGENTS.md)
32
+ 6. **Verifies** the improvement works in subsequent sessions
33
+
34
+ ### Why This Matters
35
+
36
+ Without evolution, the AI repeats the same mistakes. With evolution, every error becomes a learning opportunity, every user feedback improves the system, every complex workflow becomes a reusable skill.
37
+
38
+ ---
39
+
40
+ ## Skill Modularity Principle
41
+
42
+ **Key design decisions:**
43
+
44
+ - **Skills are self-contained**: Each skill defines its own triggers, dependencies, and constraints internally
45
+ - **Constitution doesn't maintain dependency tables**: This allows new skills to be added without modifying the constitution
46
+ - **Dynamic extensibility**: New skills integrate automatically through internal declarations
47
+ - **Skill autonomy**: Skills are independent and can be maintained separately
48
+
49
+ When creating skill `_my-skill`, you only need to declare its tier and dependencies in the skill's metadata - no constitution modification needed.
50
+
51
+ ---
52
+
53
+ ## Glossary
54
+
55
+ | Term | Definition |
56
+ |------|-----------|
57
+ | **Constitution** | Core evolution principles (this file) |
58
+ | **Skill** | Reusable workflow with internal trigger conditions and dependencies |
59
+ | **Tier** | How a skill activates: auto-enforced, conditional, or explicit-request |
60
+ | **Trigger** | Condition that activates a skill |
61
+
62
+ ---
63
+
64
+ > **Version**: 2.1
65
+ > **Focus**: Evolution mechanism only (lean and focused)
66
+ > **Related Files**: See `.github/EXECUTION_RULES.md` for mandatory rules, `AGENTS.md` for skill registry
@@ -0,0 +1,105 @@
1
+ # Execution Rules
2
+
3
+ > Optional rules that enforce safe and predictable AI behavior. Install with evoskills; can be deleted if not needed for your use case.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ These 4 rules form the guardrails for reliable AI execution. They are **auto-enforced by the core system** when enabled, but can be selectively disabled or removed if your workflow doesn't require them.
10
+
11
+ **Install Status**: These rules are auto-installed by `evoskills init`. To disable, remove this file's entry from `.github/copilot-instructions.md`.
12
+
13
+ ---
14
+
15
+ ## Rule 1: Instruction Guard (_instruction-guard)
16
+
17
+ **Purpose**: Ensure project context is always loaded before responding.
18
+
19
+ **When Active**: Before each response, if project instruction file (`.github/copilot-instructions.md`) is not in current context, read it immediately.
20
+
21
+ **Why**: Prevents deviations due to missing project-specific requirements.
22
+
23
+ ---
24
+
25
+ ## Rule 2: Context Acknowledgment (_context-ack)
26
+
27
+ **Purpose**: Enable users to quickly verify the AI is following correct rules.
28
+
29
+ **When Active**: Each response must follow specified output format:
30
+ - Fixed prefix at start
31
+ - Polite address line
32
+ - Main content
33
+ - Reference list at end (showing which files/rules were consulted)
34
+
35
+ **Why**: Makes compliance transparent and auditable.
36
+
37
+ ---
38
+
39
+ ## Rule 3: File Output Guard (_file-output-guard)
40
+
41
+ **Purpose**: Prevent accidental file overwrites and unsafe operations.
42
+
43
+ **When Active**:
44
+ - **Forbidden**: Using HERE documents for file creation (`cat > file << 'EOF'`)
45
+ - **Required**: Use `create_file` or `replace_string_in_file` tools only
46
+ - **Large Files**: Files >5KB must be segmented to same file to avoid session limits
47
+
48
+ **Why**: Ensures file operations are safe, traceable, and controllable.
49
+
50
+ ---
51
+
52
+ ## Rule 4: Session Safety (_session-safety)
53
+
54
+ **Purpose**: Prevent session failure due to excessive output.
55
+
56
+ **When Active**: When estimated output length exceeds 5KB:
57
+ - Segment processing or write to file instead
58
+ - Don't output overly long content in single response
59
+
60
+ **Why**: Protects conversation session from breaking.
61
+
62
+ ---
63
+
64
+ ## How These Rules Work Together
65
+
66
+ ```
67
+ Rule 1 (_instruction-guard)
68
+ ↓ [load context]
69
+ Rule 2 (_context-ack)
70
+ ↓ [format response]
71
+ Rule 3 (_file-output-guard)
72
+ ↓ [file operations safe]
73
+ Rule 4 (_session-safety)
74
+ ↓ [output within limits]
75
+ ✅ Safe, predictable, auditable execution
76
+ ```
77
+
78
+ ---
79
+
80
+ ## When to Disable
81
+
82
+ You can safely remove this file's reference from `.github/copilot-instructions.md` if:
83
+
84
+ 1. You're using the AI in personal projects with low risk tolerance
85
+ 2. Your workflow doesn't need output format enforcement
86
+ 3. You want maximum flexibility without guardrails
87
+
88
+ However, we recommend keeping at least **Rule 1** (_instruction-guard) enabled for project-based work.
89
+
90
+ ---
91
+
92
+ ## Relationship to Evolution
93
+
94
+ These rules are **separate from evolution**. Evolution (in AI_CONSTITUTION.md) happens automatically when triggers fire. These rules ensure safe execution during evolution and regular tasks.
95
+
96
+ Think of it this way:
97
+ - **Constitution** = "How the AI learns"
98
+ - **Execution Rules** = "How the AI operates safely"
99
+ - **Skills** = "What the AI does"
100
+
101
+ ---
102
+
103
+ > **Version**: 1.0
104
+ > **Install Source**: evoskills (auto-installed with `evoskills init`)
105
+ > **Customization**: Can be extended in project-specific instruction files
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Xingyuwang & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # evoskills
2
+
3
+ > Evolution Skills CLI - A modular, evolvable AI skills framework for GitHub Copilot
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@xingyu.wang/evoskills.svg)](https://www.npmjs.com/package/@xingyu.wang/evoskills)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ **evoskills** is a CLI tool and skill framework that enhances AI assistants (like GitHub Copilot) with modular, reusable capabilities. It provides a self-improving system through constitutional AI guidelines and pluggable skills.
9
+
10
+ ## ✨ Features
11
+
12
+ - 🧩 **Modular Skills**: Install only the skills you need
13
+ - 🔄 **Self-Improving**: Built-in evolution mechanism learns from mistakes
14
+ - 🛡️ **Safe by Default**: Content protection prevents overwriting user customizations
15
+ - 📦 **openskills Compatible**: Works with standard openskills format
16
+ - 🌐 **Extensible**: Create your own skill repositories
17
+ - 🚀 **Zero Config**: Sensible defaults, auto-saves configuration
18
+
19
+ ## 📦 Installation
20
+
21
+ ### Option 1: Global Install (Recommended for regular use)
22
+
23
+ ```bash
24
+ npm install -g @xingyu.wang/evoskills
25
+ ```
26
+
27
+ Then use anywhere:
28
+
29
+ ```bash
30
+ evoskills --help
31
+ ```
32
+
33
+ ### Option 2: Use with npx (No installation required)
34
+
35
+ ```bash
36
+ npx @xingyu.wang/evoskills init
37
+ ```
38
+
39
+ ## 🚀 Quick Start
40
+
41
+ Initialize evoskills in your project:
42
+
43
+ ```bash
44
+ cd /path/to/your/project
45
+ evoskills init
46
+ ```
47
+
48
+ This will:
49
+ - ✅ Create `.agent/skills/` directory (skills installed from GitHub)
50
+ - ✅ Generate `AGENTS.md` at project root (openskills-compatible skill registry)
51
+ - ✅ Download `.github/AI_CONSTITUTION.md` (core evolution mechanism)
52
+ - ✅ Download `.github/EXECUTION_RULES.md` (optional safety guardrails)
53
+ - ✅ Create `.github/copilot-instructions.md` (entry point for the system)
54
+ - ✅ Save configuration to `.evoskills-config.json`
55
+
56
+ **Three-layer architecture:**
57
+ 1. **AI Constitution** - Evolution principles (always active, cannot be disabled)
58
+ 2. **Execution Rules** - 4 optional safety guardrails (can be removed if not needed)
59
+ 3. **Skills** - Reusable capabilities (5 core required, 9 optional)
60
+
61
+ ## 📚 Usage
62
+
63
+ ### List Available Skills
64
+
65
+ ```bash
66
+ evoskills list # Show all available skills
67
+ evoskills list --installed # Show installed skills only
68
+ ```
69
+
70
+ ### Install/Remove Skills
71
+
72
+ ```bash
73
+ evoskills install _git-commit # Install a skill
74
+ evoskills remove _git-commit # Remove a skill
75
+ ```
76
+
77
+ ### Update Skills and CLI
78
+
79
+ ```bash
80
+ evoskills update # Update CLI (via npm) and refresh all installed skills
81
+ evoskills update _git-commit # Update specific skill only
82
+ ```
83
+
84
+ ### Use Custom Skill Repository
85
+
86
+ ```bash
87
+ evoskills init --repo https://github.com/your-username/your-skills-repo
88
+ evoskills update --repo <url> # Switch repository and update all skills
89
+ ```
90
+
91
+ The repository URL is auto-saved to `.evoskills-config.json`.
92
+
93
+ ## 🎯 Available Skills
94
+
95
+ The default repository provides 14 skills across 5 categories:
96
+
97
+ ### Core Skills (Required - Auto-installed)
98
+ - `_instruction-guard` - Ensures project instructions are always read before responses
99
+ - `_context-ack` - Formats responses with headers and reference lists
100
+ - `_file-output-guard` - Prevents accidental file overwrites
101
+ - `_execution-precheck` - Validates dependencies before executing commands
102
+ - `_evolution-core` - Identifies improvement opportunities and proposes enhancements
103
+
104
+ ### Git & Version Control
105
+ - `_git-commit` - Conventional commits workflow
106
+ - `_pr-creator` - Automate PR generation
107
+
108
+ ### Release Management
109
+ - `_release-process` - Complete release workflow
110
+
111
+ ### Code Quality
112
+ - `_code-health-check` - Quality checks before commit
113
+ - `_typescript-type-safety` - TypeScript type safety guidelines
114
+
115
+ ### Workflow & Automation
116
+ - `_change-summary` - Summarize work sessions
117
+ - `_traceability-check` - Ensure decisions are documented
118
+ - `_session-safety` - Prevent state violations
119
+ - `_skills-manager` - Manage skills lifecycle
120
+
121
+ ## 🛡️ User Content Protection
122
+
123
+ evoskills intelligently preserves your customizations during updates:
124
+
125
+ ### AGENTS.md Protection
126
+ - Managed region marked with `<!-- EVOSKILLS_START -->` and `<!-- EVOSKILLS_END -->`
127
+ - Content outside markers is preserved (your custom skills, notes, etc.)
128
+ - Updates only replace content between markers
129
+ - If no markers exist, content is appended (never overwritten)
130
+
131
+ ### copilot-instructions.md Protection
132
+ - New file: Creates standard template with required references
133
+ - Existing file: Checks for `AI_CONSTITUTION.md` and `AGENTS.md` references
134
+ - Only appends missing references, never overwrites existing content
135
+
136
+ **Example**: You can safely add your own skill groups to `AGENTS.md` - evoskills updates won't touch them.
137
+
138
+ ## 📂 Project Structure
139
+
140
+ This repository uses the same `.agent/skills/` structure it creates for users (dogfooding):
141
+
142
+ ```
143
+ .agent/skills/ # Skill source definitions (14 skills)
144
+ evoskills # CLI entry point (npm bin)
145
+ .github/
146
+ AI_CONSTITUTION.md # Constitutional template
147
+ AGENTS.md # Skill registry (openskills format)
148
+ package.json # npm package metadata
149
+ ```
150
+
151
+ When users install skills from GitHub, evoskills downloads from the `.agent/skills/` path.
152
+
153
+ ## 🤝 Contributing
154
+
155
+ Contributions are welcome! See our [contribution guidelines](SKILL_DEFINITION_SPECIFICATION.md) for details.
156
+
157
+ Quick contribution workflow:
158
+
159
+ ```bash
160
+ git checkout -b feat/your-feature
161
+ # Make your changes in .agent/skills/
162
+ git commit -m "feat: add new skill"
163
+ git push -u origin feat/your-feature
164
+ # Create PR (with GitHub CLI)
165
+ gh pr create --fill
166
+ ```
167
+
168
+ ## 📄 License
169
+
170
+ MIT © [xingyu.wang](https://github.com/xingyu.wang)
171
+
172
+ ## 🔗 Links
173
+
174
+ - [npm Package](https://www.npmjs.com/package/@xingyu.wang/evoskills)
175
+ - [GitHub Repository](https://github.com/xingyu.wang/copilot-evolution-skills)
176
+ - [Skill Definition Specification](SKILL_DEFINITION_SPECIFICATION.md)
package/evoskills ADDED
@@ -0,0 +1,591 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6
+ CLI_VERSION="1.1.0"
7
+
8
+ # Project config file (in current directory)
9
+ PROJECT_CONFIG_FILE=".evoskills-config.json"
10
+
11
+ AGENTS_DIR=".agent"
12
+ SKILLS_DIR="$AGENTS_DIR/skills"
13
+
14
+ # Default skill repository
15
+ DEFAULT_SKILLS_REPO="https://github.com/xingyu.wang/copilot-evolution-skills"
16
+
17
+ GREEN='\033[0;32m'
18
+ YELLOW='\033[1;33m'
19
+ BLUE='\033[0;34m'
20
+ RED='\033[0;31m'
21
+ NC='\033[0m'
22
+
23
+ CORE_SKILLS=(
24
+ "_instruction-guard"
25
+ "_context-ack"
26
+ "_file-output-guard"
27
+ "_execution-precheck"
28
+ "_evolution-core"
29
+ )
30
+
31
+ OPTIONAL_SKILLS=(
32
+ "_git-commit"
33
+ "_pr-creator"
34
+ "_release-process"
35
+ "_code-health-check"
36
+ "_typescript-type-safety"
37
+ "_change-summary"
38
+ "_traceability-check"
39
+ "_session-safety"
40
+ "_skills-manager"
41
+ )
42
+
43
+ print_success() { echo -e "${GREEN}✅ $*${NC}"; }
44
+ print_info() { echo -e "${BLUE}ℹ️ $*${NC}"; }
45
+ print_warn() { echo -e "${YELLOW}⚠️ $*${NC}"; }
46
+ print_error() { echo -e "${RED}❌ $*${NC}"; }
47
+
48
+ show_help() {
49
+ cat << 'EOF'
50
+ evoskills - Evolution Skills CLI
51
+
52
+ Usage:
53
+ evoskills <command> [options]
54
+
55
+ Commands:
56
+ init [OPTIONS] Initialize project skills
57
+ --core-only Install core required skills only
58
+ --skills <list> Install selected skills (comma-separated)
59
+ --all Install all skills (default)
60
+ --repo <url> Use custom skill repository (saved to .evoskills-config.json)
61
+
62
+ list [--installed] List available or installed skills
63
+ install <skill> Install a skill from configured repository
64
+ add <skill> Alias of install
65
+ remove <skill> Remove a skill
66
+ update [OPTIONS] Update CLI and refresh skills/constitution
67
+ --repo <url> Switch to a different skill repository
68
+ [skill] Update specific skill only (omit to update all)
69
+ contribute <skill> Start contribution flow for a skill
70
+ --version, -v Print CLI version
71
+ --help, -h Print this help
72
+
73
+ Default repository: https://github.com/xingyu.wang/copilot-evolution-skills
74
+
75
+ Notes:
76
+ - Skills are installed to .agent/skills/
77
+ - Repository URL is auto-saved in .evoskills-config.json when using --repo
78
+ - 'update' without args refreshes CLI (via npm) and all skills from saved repo
79
+ - AGENTS.md is auto-generated for openskills compatibility
80
+ EOF
81
+ }
82
+
83
+ ensure_layout() {
84
+ mkdir -p "$SKILLS_DIR"
85
+ mkdir -p ".github"
86
+ }
87
+
88
+ get_config_value() {
89
+ local key="$1"
90
+
91
+ # Return default if no config file exists
92
+ if [ ! -f "$PROJECT_CONFIG_FILE" ]; then
93
+ case "$key" in
94
+ skillsRepo) echo "$DEFAULT_SKILLS_REPO" ;;
95
+ *) echo "" ;;
96
+ esac
97
+ return
98
+ fi
99
+
100
+ # Try to read from config file
101
+ if command -v jq &> /dev/null; then
102
+ jq -r ".\"$key\" // empty" "$PROJECT_CONFIG_FILE" 2>/dev/null || echo ""
103
+ else
104
+ grep "\"$key\"" "$PROJECT_CONFIG_FILE" | sed 's/.*": "\(.*\)".*/\1/' || echo ""
105
+ fi
106
+ }
107
+
108
+ set_config_value() {
109
+ local key="$1"
110
+ local value="$2"
111
+
112
+ # Create empty config if it doesn't exist
113
+ if [ ! -f "$PROJECT_CONFIG_FILE" ]; then
114
+ echo "{}" > "$PROJECT_CONFIG_FILE"
115
+ fi
116
+
117
+ # Update config file
118
+ if command -v jq &> /dev/null; then
119
+ jq ".\"$key\" = \"$value\"" "$PROJECT_CONFIG_FILE" > "${PROJECT_CONFIG_FILE}.tmp" && mv "${PROJECT_CONFIG_FILE}.tmp" "$PROJECT_CONFIG_FILE"
120
+ else
121
+ # Fallback: simple sed replacement or append
122
+ if grep -q "\"$key\"" "$PROJECT_CONFIG_FILE"; then
123
+ sed -i '' "s/\"$key\": \"[^\"]*\"/\"$key\": \"$value\"/" "$PROJECT_CONFIG_FILE"
124
+ else
125
+ sed -i '' '$ s/}/,"'$key'": "'$value'"}/' "$PROJECT_CONFIG_FILE"
126
+ fi
127
+ fi
128
+
129
+ print_success "Config saved: $key = $value"
130
+ }
131
+
132
+ create_constitution_if_missing() {
133
+ if [ ! -f ".github/AI_CONSTITUTION.md" ]; then
134
+ local skills_repo
135
+ skills_repo=$(get_config_value "skillsRepo")
136
+
137
+ if curl -sf "$skills_repo/raw/main/.github/AI_CONSTITUTION.md" > ".github/AI_CONSTITUTION.md" 2>/dev/null; then
138
+ print_success "Downloaded .github/AI_CONSTITUTION.md"
139
+ else
140
+ cat > ".github/AI_CONSTITUTION.md" << 'EOF'
141
+ # AI Constitution
142
+
143
+ Please add your project constitution here or configure the skills repository URL.
144
+ EOF
145
+ print_warn "Could not download constitution; created minimal .github/AI_CONSTITUTION.md"
146
+ fi
147
+ fi
148
+ }
149
+
150
+ create_execution_rules_if_missing() {
151
+ if [ ! -f ".github/EXECUTION_RULES.md" ]; then
152
+ local skills_repo
153
+ skills_repo=$(get_config_value "skillsRepo")
154
+
155
+ if curl -sf "$skills_repo/raw/main/.github/EXECUTION_RULES.md" > ".github/EXECUTION_RULES.md" 2>/dev/null; then
156
+ print_success "Downloaded .github/EXECUTION_RULES.md"
157
+ else
158
+ print_warn "Could not download execution rules (optional)"
159
+ fi
160
+ fi
161
+ }
162
+
163
+ create_copilot_instructions_if_missing() {
164
+ if [ ! -f ".github/copilot-instructions.md" ]; then
165
+ cat > ".github/copilot-instructions.md" << 'EOF'
166
+ ---
167
+ applyTo: "**"
168
+ ---
169
+
170
+ ## Core Documents (Required)
171
+
172
+ Please read and follow the AI evolution principle:
173
+ - `.github/AI_CONSTITUTION.md` - Core evolution mechanism (always active, cannot be disabled)
174
+
175
+ ## Optional Execution Rules
176
+
177
+ For additional safety guardrails, see:
178
+ - `.github/EXECUTION_RULES.md` - 4 optional rules (can be disabled if not needed for your use case)
179
+
180
+ ## Skills Registry
181
+
182
+ For available skills and how they work:
183
+ - `AGENTS.md` - Skill registry with `_evolution-core` as the core skill
184
+
185
+ ---
186
+
187
+ **Note**: The AI will continuously evolve by learning from errors, user feedback, and complex workflows. This is built into the core system and cannot be disabled.
188
+ EOF
189
+ print_success "Created .github/copilot-instructions.md"
190
+ else
191
+ # Check if file already contains required references
192
+ local has_constitution=false
193
+ local has_execution=false
194
+ local has_agents=false
195
+
196
+ if grep -q "AI_CONSTITUTION.md" ".github/copilot-instructions.md"; then
197
+ has_constitution=true
198
+ fi
199
+
200
+ if grep -q "EXECUTION_RULES.md" ".github/copilot-instructions.md"; then
201
+ has_execution=true
202
+ fi
203
+
204
+ if grep -q "AGENTS.md" ".github/copilot-instructions.md"; then
205
+ has_agents=true
206
+ fi
207
+
208
+ # Append missing references
209
+ if [ "$has_constitution" = false ] || [ "$has_execution" = false ] || [ "$has_agents" = false ]; then
210
+ echo "" >> ".github/copilot-instructions.md"
211
+ echo "<!-- evoskills: auto-generated references -->" >> ".github/copilot-instructions.md"
212
+
213
+ if [ "$has_constitution" = false ]; then
214
+ echo "- Please read and follow AI_CONSTITUTION.md (core evolution mechanism)" >> ".github/copilot-instructions.md"
215
+ fi
216
+
217
+ if [ "$has_execution" = false ]; then
218
+ echo "- See EXECUTION_RULES.md for optional safety guardrails" >> ".github/copilot-instructions.md"
219
+ fi
220
+
221
+ if [ "$has_agents" = false ]; then
222
+ echo "- Refer to AGENTS.md for skills registry" >> ".github/copilot-instructions.md"
223
+ fi
224
+
225
+ print_success "Updated .github/copilot-instructions.md with evoskills references"
226
+ fi
227
+ fi
228
+ }
229
+
230
+ write_agents_registry() {
231
+ local installed_list
232
+ installed_list=$(find "$SKILLS_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; 2>/dev/null | sort)
233
+
234
+ # Generate our skills section in a temp file
235
+ local temp_content=".evoskills-section.tmp"
236
+ cat > "$temp_content" << 'MARKER_EOF'
237
+ <!-- EVOSKILLS_START -->
238
+ <skills_system priority="1">
239
+
240
+ ## Available Skills (evoskills)
241
+
242
+ <!--
243
+ SKILLS_TABLE_START -->
244
+ <usage>
245
+ When users ask you to perform tasks, check if any of the
246
+ available skills below can help complete the task more effectively. Skills provide
247
+ specialized capabilities and domain knowledge.
248
+
249
+ How to use skills:
250
+ - Invoke: Bash("npx openskills read <skill-name>")
251
+ - The skill content will load with detailed instructions on how to complete the task
252
+ - Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
253
+
254
+ Usage notes:
255
+ - Only use skills listed in <available_skills> below
256
+ - Do not invoke a skill that is already loaded in your context
257
+ - Each skill invocation is stateless
258
+ </usage>
259
+
260
+ <available_skills>
261
+
262
+ MARKER_EOF
263
+
264
+ # Add installed skills
265
+ if [ -n "$installed_list" ]; then
266
+ while IFS= read -r skill; do
267
+ cat >> "$temp_content" << EOF
268
+ <skill>
269
+ <name>$skill</name>
270
+ <description>Skill: $skill</description>
271
+ <location>project</location>
272
+ </skill>
273
+
274
+ EOF
275
+ done <<< "$installed_list"
276
+ fi
277
+
278
+ cat >> "$temp_content" << 'MARKER_EOF'
279
+
280
+ </available_skills>
281
+ <!--
282
+ SKILLS_TABLE_END -->
283
+
284
+ </skills_system>
285
+ <!-- EVOSKILLS_END -->
286
+ MARKER_EOF
287
+
288
+ # Update or create AGENTS.md
289
+ if [ ! -f "AGENTS.md" ]; then
290
+ # Create new file
291
+ cat > "AGENTS.md" << 'EOF'
292
+ # AGENTS
293
+
294
+ EOF
295
+ cat "$temp_content" >> "AGENTS.md"
296
+ print_success "Created AGENTS.md"
297
+ else
298
+ # Check if our markers exist
299
+ if grep -q "<!-- EVOSKILLS_START -->" "AGENTS.md" && grep -q "<!-- EVOSKILLS_END -->" "AGENTS.md"; then
300
+ # Replace content between markers using sed
301
+ local agents_tmp="AGENTS.md.tmp"
302
+
303
+ # Extract content before EVOSKILLS_START
304
+ sed -n '1,/<!-- EVOSKILLS_START -->/p' "AGENTS.md" | sed '$d' > "$agents_tmp"
305
+
306
+ # Add our new content
307
+ cat "$temp_content" >> "$agents_tmp"
308
+
309
+ # Extract content after EVOSKILLS_END
310
+ sed -n '/<!-- EVOSKILLS_END -->/,$p' "AGENTS.md" | tail -n +2 >> "$agents_tmp"
311
+
312
+ mv "$agents_tmp" "AGENTS.md"
313
+ print_success "Updated evoskills section in AGENTS.md"
314
+ else
315
+ # Append our section to existing file
316
+ echo "" >> "AGENTS.md"
317
+ cat "$temp_content" >> "AGENTS.md"
318
+ print_success "Appended evoskills section to AGENTS.md"
319
+ fi
320
+ fi
321
+
322
+ # Cleanup
323
+ rm -f "$temp_content"
324
+ }
325
+
326
+ install_skill_github() {
327
+ local skill="$1"
328
+ local skills_repo
329
+ skills_repo=$(get_config_value "skillsRepo")
330
+
331
+ if [ -d "$SKILLS_DIR/$skill" ]; then
332
+ print_warn "Skill already installed: $skill"
333
+ return 0
334
+ fi
335
+
336
+ mkdir -p "$SKILLS_DIR/$skill"
337
+
338
+ # Try to download SKILL.md and references from GitHub
339
+ if curl -sf "$skills_repo/raw/main/.agent/skills/$skill/SKILL.md" > "$SKILLS_DIR/$skill/SKILL.md" 2>/dev/null; then
340
+ print_success "Installed skill: $skill"
341
+
342
+ # Try to download references/ if present
343
+ if curl -sf "$skills_repo/raw/main/.agent/skills/$skill/references/" &>/dev/null; then
344
+ print_info "Downloading skill references..."
345
+ mkdir -p "$SKILLS_DIR/$skill/references"
346
+ # Download common reference files
347
+ for ref_file in "*.md"; do
348
+ curl -sf "$skills_repo/raw/main/.agent/skills/$skill/references/$ref_file" > "$SKILLS_DIR/$skill/references/$ref_file" 2>/dev/null || true
349
+ done
350
+ fi
351
+
352
+ # Try to download scripts/ if present
353
+ if curl -sf "$skills_repo/raw/main/.agent/skills/$skill/scripts/" &>/dev/null; then
354
+ print_info "Downloading skill scripts..."
355
+ mkdir -p "$SKILLS_DIR/$skill/scripts"
356
+ for script_file in "*.sh"; do
357
+ curl -sf "$skills_repo/raw/main/.agent/skills/$skill/scripts/$script_file" > "$SKILLS_DIR/$skill/scripts/$script_file" 2>/dev/null || true
358
+ done
359
+ fi
360
+ else
361
+ print_error "Failed to download skill: $skill from $skills_repo"
362
+ rm -rf "$SKILLS_DIR/$skill"
363
+ return 1
364
+ fi
365
+ }
366
+
367
+ cmd_init() {
368
+ local core_only=false
369
+ local skills=""
370
+ local install_all=true
371
+ local custom_repo=""
372
+
373
+ while [[ $# -gt 0 ]]; do
374
+ case "$1" in
375
+ --core-only)
376
+ core_only=true
377
+ install_all=false
378
+ shift
379
+ ;;
380
+ --skills)
381
+ skills="$2"
382
+ install_all=false
383
+ shift 2
384
+ ;;
385
+ --all)
386
+ install_all=true
387
+ shift
388
+ ;;
389
+ --repo)
390
+ custom_repo="$2"
391
+ set_config_value "skillsRepo" "$custom_repo"
392
+ shift 2
393
+ ;;
394
+ *)
395
+ print_error "Unknown option: $1"
396
+ exit 1
397
+ ;;
398
+ esac
399
+ done
400
+
401
+ ensure_layout
402
+
403
+ cat > "$PROJECT_CONFIG_FILE" << EOF
404
+ {
405
+ "version": "1.1.0",
406
+ "installedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
407
+ "skillsDir": ".agent/skills",
408
+ "openskillsCompatible": true,
409
+ "skillsRepo": "$(get_config_value 'skillsRepo')"
410
+ }
411
+ EOF
412
+
413
+ create_constitution_if_missing
414
+ create_execution_rules_if_missing
415
+ create_copilot_instructions_if_missing
416
+
417
+ print_info "Installing core skills..."
418
+ for skill in "${CORE_SKILLS[@]}"; do
419
+ install_skill_github "$skill"
420
+ done
421
+
422
+ if [ "$core_only" = false ]; then
423
+ if [ -n "$skills" ]; then
424
+ print_info "Installing selected skills..."
425
+ for skill in ${skills//,/ }; do
426
+ install_skill_github "$skill"
427
+ done
428
+ elif [ "$install_all" = true ]; then
429
+ print_info "Installing all optional skills..."
430
+ for skill in "${OPTIONAL_SKILLS[@]}"; do
431
+ install_skill_github "$skill"
432
+ done
433
+ fi
434
+ fi
435
+
436
+ write_agents_registry
437
+ print_success "Initialization complete (.agent/skills + AGENTS.md + AI_CONSTITUTION.md)"
438
+ }
439
+
440
+ cmd_list() {
441
+ local show_installed=false
442
+
443
+ while [[ $# -gt 0 ]]; do
444
+ case "$1" in
445
+ --installed) show_installed=true ;;
446
+ esac
447
+ shift
448
+ done
449
+
450
+ if [ "$show_installed" = true ]; then
451
+ if [ -d "$SKILLS_DIR" ]; then
452
+ find "$SKILLS_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort
453
+ else
454
+ print_warn ".agent/skills not found. Run: evoskills init"
455
+ fi
456
+ return
457
+ fi
458
+
459
+ echo "Core skills:"
460
+ for skill in "${CORE_SKILLS[@]}"; do
461
+ echo " - $skill"
462
+ done
463
+
464
+ echo "Optional skills:"
465
+ for skill in "${OPTIONAL_SKILLS[@]}"; do
466
+ echo " - $skill"
467
+ done
468
+ }
469
+
470
+ cmd_install() {
471
+ local skill="$1"
472
+ [ -z "$skill" ] && { print_error "Usage: evoskills install <skill>"; exit 1; }
473
+
474
+ ensure_layout
475
+ install_skill_github "$skill"
476
+ write_agents_registry
477
+ }
478
+
479
+ cmd_remove() {
480
+ local skill="$1"
481
+ [ -z "$skill" ] && { print_error "Usage: evoskills remove <skill>"; exit 1; }
482
+
483
+ case "$skill" in
484
+ _instruction-guard|_context-ack|_file-output-guard|_execution-precheck|_evolution-core)
485
+ print_error "Cannot remove core skill: $skill"
486
+ exit 1
487
+ ;;
488
+ esac
489
+
490
+ if [ -d "$SKILLS_DIR/$skill" ]; then
491
+ rm -rf "$SKILLS_DIR/$skill"
492
+ print_success "Removed skill: $skill"
493
+ write_agents_registry
494
+ else
495
+ print_warn "Skill is not installed: $skill"
496
+ fi
497
+ }
498
+
499
+ cmd_update() {
500
+ local skill=""
501
+ local custom_repo=""
502
+
503
+ while [[ $# -gt 0 ]]; do
504
+ case "$1" in
505
+ --repo)
506
+ custom_repo="$2"
507
+ set_config_value "skillsRepo" "$custom_repo"
508
+ shift 2
509
+ ;;
510
+ *)
511
+ if [[ ! "$1" =~ ^-- ]]; then
512
+ skill="$1"
513
+ fi
514
+ shift
515
+ ;;
516
+ esac
517
+ done
518
+
519
+ # Update CLI itself if no specific skill requested
520
+ if [ -z "$skill" ]; then
521
+ if command -v npm &> /dev/null; then
522
+ print_info "Updating evoskills CLI..."
523
+ npm install -g @xingyu.wang/evoskills@latest 2>/dev/null || print_warn "CLI update failed (may need sudo or already latest)"
524
+ else
525
+ print_warn "npm not found; skipping CLI update"
526
+ fi
527
+ fi
528
+
529
+ ensure_layout
530
+ create_constitution_if_missing
531
+ create_execution_rules_if_missing
532
+ create_copilot_instructions_if_missing
533
+
534
+ if [ -n "$skill" ]; then
535
+ print_info "Refreshing skill: $skill"
536
+ rm -rf "$SKILLS_DIR/$skill"
537
+ install_skill_github "$skill"
538
+ else
539
+ print_info "Refreshing all skills from $(get_config_value 'skillsRepo')..."
540
+ # Refresh all installed skills
541
+ if [ -d "$SKILLS_DIR" ]; then
542
+ for installed_skill in "$SKILLS_DIR"/*; do
543
+ if [ -d "$installed_skill" ]; then
544
+ skill_name=$(basename "$installed_skill")
545
+ print_info "Updating $skill_name..."
546
+ rm -rf "$installed_skill"
547
+ install_skill_github "$skill_name"
548
+ fi
549
+ done
550
+ fi
551
+ fi
552
+
553
+ write_agents_registry
554
+ print_success "Update complete"
555
+ }
556
+
557
+ cmd_contribute() {
558
+ local skill="$1"
559
+ [ -z "$skill" ] && { print_error "Usage: evoskills contribute <skill>"; exit 1; }
560
+
561
+ if [ ! -d "$SKILLS_DIR/$skill" ]; then
562
+ print_error "Skill not found: $skill (expected in .agent/skills/)"
563
+ exit 1
564
+ fi
565
+
566
+ print_info "Contribution flow:"
567
+ print_info "1. Fork the repository"
568
+ print_info "2. Create a feature branch: git checkout -b feature/update-$skill"
569
+ print_info "3. Update skill in .agent/skills/$skill/"
570
+ print_info "4. Commit: git commit -m 'feat: update $skill'"
571
+ print_info "5. Push and open a pull request"
572
+ }
573
+
574
+ main() {
575
+ local command="$1"
576
+ shift || true
577
+
578
+ case "$command" in
579
+ init) cmd_init "$@" ;;
580
+ list) cmd_list "$@" ;;
581
+ install|add) cmd_install "$@" ;;
582
+ remove) cmd_remove "$@" ;;
583
+ update) cmd_update "$@" ;;
584
+ contribute) cmd_contribute "$@" ;;
585
+ --version|-v) echo "evoskills version $CLI_VERSION" ;;
586
+ --help|-h|help|"") show_help ;;
587
+ *) print_error "Unknown command: $command"; show_help; exit 1 ;;
588
+ esac
589
+ }
590
+
591
+ main "$@"
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@xingyu.wang/evoskills",
3
+ "version": "1.1.0",
4
+ "description": "Evolution Skills CLI for installing and managing openskills-compatible AI skills.",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "evoskills": "./evoskills"
8
+ },
9
+ "files": [
10
+ "evoskills",
11
+ "README.md",
12
+ "LICENSE",
13
+ ".github/AI_CONSTITUTION.md",
14
+ ".github/EXECUTION_RULES.md"
15
+ ],
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/xingyu.wang/copilot-evolution-skills.git"
25
+ }
26
+ }