mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-29 16:16:08 +00:00
docs: migrate documentation to v2.0 plugin architecture
**Major Documentation Update:** - Remove old npm-based installer (bin/ directory) - Update README.md: 26 slash commands → 3 TypeScript plugins - Update CLAUDE.md: Reflect plugin architecture with hot reload - Update installation instructions: Plugin marketplace method **Changes:** - README.md: - Statistics: 26 commands → 3 plugins (PM Agent, Research, Index) - Installation: Plugin marketplace with auto-activation - Migration guide: v1.x slash commands → v2.0 plugins - Command examples: /sc:research → /research - Version: v4 → v2.0 (architectural change) - CLAUDE.md: - Project structure: Add .claude-plugin/ TypeScript architecture - Plugin architecture section: Hot reload, SessionStart hook - MCP integration: airis-mcp-gateway unified gateway - Remove references to old setup/ system - bin/ (DELETED): - check_env.js, check_update.js, cli.js, install.js, update.js - Old npm-based installer no longer needed **Architecture:** - TypeScript plugins: .claude-plugin/pm, research, index - Python package: src/superclaude/ (pytest plugin, CLI) - Hot reload: Edit → Save → Instant reflection - Auto-activation: SessionStart hook runs /pm automatically **Migration Path:** - Old: /sc:pm, /sc:research, /sc:index-repo (27 total) - New: /pm, /research, /index-repo (3 plugins) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
96
CLAUDE.md
96
CLAUDE.md
@@ -55,24 +55,37 @@ docker compose exec workspace uv run pytest
|
||||
|
||||
```
|
||||
SuperClaude_Framework/
|
||||
├── superclaude/ # Framework source
|
||||
│ ├── commands/ # Slash commands
|
||||
│ ├── agents/ # Agent personas
|
||||
│ ├── modes/ # Behavior modes
|
||||
│ ├── framework/ # Core principles/rules/flags
|
||||
│ ├── business/ # Business analysis patterns
|
||||
│ └── research/ # Research configurations
|
||||
├── setup/ # Installation system
|
||||
│ ├── components/ # Installable components
|
||||
│ │ ├── knowledge_base.py # Framework knowledge
|
||||
│ │ ├── behavior_modes.py # Mode definitions
|
||||
│ │ ├── agent_personas.py # Agent definitions
|
||||
│ │ ├── slash_commands.py # Command registration
|
||||
│ │ └── mcp_integration.py # External tool integration
|
||||
│ └── core/ # Installation logic
|
||||
└── tests/ # Test suite
|
||||
├── .claude-plugin/ # TypeScript plugins (v2.0 architecture)
|
||||
│ ├── pm/ # PM Agent plugin
|
||||
│ │ ├── index.ts # Main orchestrator (SessionStart auto-activation)
|
||||
│ │ ├── confidence.ts # Confidence assessment (≥90% threshold, Precision/Recall 1.0)
|
||||
│ │ └── package.json # Dependencies
|
||||
│ ├── research/ # Deep Research plugin
|
||||
│ │ ├── index.ts # Web research with adaptive planning
|
||||
│ │ └── package.json # Dependencies
|
||||
│ ├── index/ # Repository indexing plugin
|
||||
│ │ ├── index.ts # 94% token reduction (58K → 3K)
|
||||
│ │ └── package.json # Dependencies
|
||||
│ ├── hooks/
|
||||
│ │ └── hooks.json # SessionStart hook configuration
|
||||
│ ├── tests/ # Plugin tests (confidence_check, test cases)
|
||||
│ └── plugin.json # Plugin manifest (v2.0.0)
|
||||
├── src/superclaude/ # Python package (pytest plugin, CLI)
|
||||
│ ├── __init__.py # Exports: ConfidenceChecker, SelfCheckProtocol, ReflexionPattern
|
||||
│ ├── pytest_plugin.py # Auto-loaded pytest integration
|
||||
│ ├── pm_agent/ # PM Agent core (confidence, self-check, reflexion)
|
||||
│ ├── cli/ # CLI commands (main, doctor, install_skill)
|
||||
│ └── execution/ # Execution patterns (parallel, reflection, self_correction)
|
||||
├── docs/ # Documentation
|
||||
├── scripts/ # Analysis tools (A/B testing, workflow metrics)
|
||||
└── tests/ # Python test suite
|
||||
```
|
||||
|
||||
**Architecture Overview:**
|
||||
- **TypeScript Plugins** (.claude-plugin/): Hot reload, auto-activation, production workflows
|
||||
- **Python Package** (src/superclaude/): pytest plugin, CLI tools, PM Agent core logic
|
||||
- **Dual Language**: TypeScript for Claude Code integration, Python for testing/tooling
|
||||
|
||||
## 🔧 Development Workflow
|
||||
|
||||
### Makefile Commands (Recommended)
|
||||
@@ -200,13 +213,30 @@ tasks = [read_file1, read_file2, read_file3]
|
||||
tasks = [edit_file1, edit_file2, edit_file3]
|
||||
```
|
||||
|
||||
### Component Responsibility
|
||||
### Plugin Architecture (v2.0)
|
||||
|
||||
- **knowledge_base**: Framework knowledge initialization
|
||||
- **behavior_modes**: Execution mode definitions
|
||||
- **agent_personas**: AI agent personality definitions
|
||||
- **slash_commands**: CLI command registration
|
||||
- **mcp_integration**: External tool integration
|
||||
**TypeScript Plugins** (.claude-plugin/):
|
||||
- **pm/index.ts**: PM Agent orchestrator with SessionStart auto-activation
|
||||
- Confidence-driven workflow (≥90% threshold required)
|
||||
- Git status detection & display
|
||||
- Auto-starts on every session (no user command needed)
|
||||
- **research/index.ts**: Deep web research with adaptive planning
|
||||
- 3 strategies: Planning-Only, Intent-Planning, Unified
|
||||
- Multi-hop reasoning (up to 5 iterations)
|
||||
- Tavily MCP integration
|
||||
- **index/index.ts**: Repository indexing for token efficiency
|
||||
- 94% token reduction (58K → 3K tokens)
|
||||
- Parallel analysis (5 concurrent tasks)
|
||||
- PROJECT_INDEX.md generation
|
||||
|
||||
**Hot Reload**:
|
||||
- Edit TypeScript file → Save → Instant reflection (no restart)
|
||||
- Faster iteration than Markdown commands
|
||||
|
||||
**SessionStart Hook**:
|
||||
- Configured in hooks/hooks.json
|
||||
- Auto-executes /pm command on session start
|
||||
- User sees PM Agent activation message automatically
|
||||
|
||||
## 🧪 Testing with PM Agent Markers
|
||||
|
||||
@@ -323,19 +353,29 @@ From KNOWLEDGE.md and PLANNING.md:
|
||||
|
||||
## 🔧 MCP Server Integration
|
||||
|
||||
This framework integrates with multiple MCP servers:
|
||||
This framework integrates with multiple MCP servers via **airis-mcp-gateway**:
|
||||
|
||||
**Priority Servers:**
|
||||
- **Tavily**: Primary web search (Deep Research plugin)
|
||||
- **Serena**: Session persistence and memory
|
||||
- **Mindbase**: Cross-session learning (zero-footprint)
|
||||
- **Sequential**: Token-efficient reasoning (30-50% reduction)
|
||||
- **Context7**: Official documentation (prevent hallucination)
|
||||
- **Sequential**: Complex analysis and multi-step reasoning
|
||||
- **Tavily**: Web search for Deep Research
|
||||
|
||||
**Optional Servers:**
|
||||
- **Serena**: Session persistence and memory
|
||||
- **Playwright**: Browser automation testing
|
||||
- **Playwright**: JavaScript-heavy content extraction
|
||||
- **Magic**: UI component generation
|
||||
- **Chrome DevTools**: Performance analysis
|
||||
|
||||
**Always prefer MCP tools over speculation** when documentation or research is needed.
|
||||
**Integration Pattern:**
|
||||
- TypeScript plugins call MCP servers directly
|
||||
- Python pytest plugin uses MCP for test validation
|
||||
- Always prefer MCP tools over speculation when documentation or research is needed
|
||||
|
||||
**Unified Gateway:**
|
||||
- All MCP servers accessible via airis-mcp-gateway
|
||||
- Simplified configuration and tool selection
|
||||
- See: https://github.com/airis-mcp-gateway
|
||||
|
||||
## 🔗 Related
|
||||
|
||||
|
||||
118
README.md
118
README.md
@@ -62,12 +62,12 @@
|
||||
|
||||
## 📊 **Framework Statistics**
|
||||
|
||||
| **Commands** | **Agents** | **Modes** | **MCP Servers** |
|
||||
| **Plugins** | **Agents** | **Modes** | **MCP Servers** |
|
||||
|:------------:|:----------:|:---------:|:---------------:|
|
||||
| **26** | **16** | **7** | **8** |
|
||||
| Slash Commands | Specialized AI | Behavioral | Integrations |
|
||||
| **3** | **16** | **7** | **8** |
|
||||
| Plugin Commands | Specialized AI | Behavioral | Integrations |
|
||||
|
||||
Use the new `/sc:help` command to see a full list of all available commands.
|
||||
Three core plugins: **PM Agent** (orchestration), **Research** (web search), **Index** (context optimization).
|
||||
|
||||
</div>
|
||||
|
||||
@@ -100,29 +100,37 @@ Claude Code is a product built and maintained by [Anthropic](https://www.anthrop
|
||||
|
||||
## ⚡ **Quick Installation**
|
||||
|
||||
### **Minimal Setup - Works Immediately (No MCPs Required)**
|
||||
### **Plugin Installation - Auto-Activation with Hot Reload**
|
||||
|
||||
SuperClaude works **fully functional** without any MCP servers. Install and start using immediately:
|
||||
SuperClaude v2.0+ uses **TypeScript plugins** for instant updates and auto-activation:
|
||||
|
||||
| Method | Command | Best For |
|
||||
|:------:|---------|----------|
|
||||
| **🐍 pipx** | `pipx install SuperClaude && pipx upgrade SuperClaude && SuperClaude install` | **✅ Recommended** - Linux/macOS |
|
||||
| **📦 pip** | `pip install SuperClaude && pip upgrade SuperClaude && SuperClaude install` | Traditional Python environments |
|
||||
| **🌐 npm** | `npm install -g @bifrost_inc/superclaude && superclaude install` | Cross-platform, Node.js users |
|
||||
```bash
|
||||
# Method 1: Plugin Marketplace (Recommended)
|
||||
# Open Claude Code → /plugin marketplace → Search "pm-agent" → Install
|
||||
|
||||
### **Recommended Setup - Enhanced Performance (Optional MCPs)**
|
||||
# Method 2: Manual Installation
|
||||
cd /Users/kazuki/github/superclaude
|
||||
# Plugin auto-registers on session start via SessionStart hook
|
||||
```
|
||||
|
||||
**Key Features**:
|
||||
- ✅ **Hot Reload**: Edit TypeScript → Save → Instant reflection (no restart)
|
||||
- ✅ **Auto-Activation**: PM Agent starts automatically on session start
|
||||
- ✅ **Zero Configuration**: Works out of the box
|
||||
|
||||
### **Enhanced Performance (Optional MCPs)**
|
||||
|
||||
For **2-3x faster** execution and **30-50% fewer tokens**, optionally install MCP servers:
|
||||
|
||||
```bash
|
||||
# After basic installation, enhance with MCP servers:
|
||||
# Recommended MCP servers (via airis-mcp-gateway):
|
||||
# - Mindbase: Cross-session memory (automatic)
|
||||
# - Serena: Faster code understanding (2-3x faster)
|
||||
# - Serena: Session persistence (2-3x faster)
|
||||
# - Sequential: Token-efficient reasoning (30-50% fewer tokens)
|
||||
# - Context7: Curated official documentation
|
||||
# - Tavily: Optimized web search
|
||||
# - Tavily: Web search for Deep Research
|
||||
# - Context7: Official documentation lookup
|
||||
|
||||
# See docs/mcp/mcp-integration-policy.md for MCP installation guides
|
||||
# Install via: https://github.com/airis-mcp-gateway
|
||||
```
|
||||
|
||||
**Performance Comparison:**
|
||||
@@ -132,26 +140,29 @@ For **2-3x faster** execution and **30-50% fewer tokens**, optionally install MC
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary><b>⚠️ IMPORTANT: Upgrading from SuperClaude V3</b></summary>
|
||||
<summary><b>⚠️ IMPORTANT: Upgrading from SuperClaude V1.x (Slash Commands)</b></summary>
|
||||
|
||||
**If you have SuperClaude V3 installed, you SHOULD uninstall it before installing V4:**
|
||||
**V2.0 introduces breaking changes - migration from slash commands to TypeScript plugins:**
|
||||
|
||||
```bash
|
||||
# Uninstall V3 first
|
||||
Remove all related files and directories :
|
||||
*.md *.json and commands/
|
||||
# 1. Remove old slash commands (if installed)
|
||||
rm -rf ~/.claude/commands/sc/
|
||||
|
||||
# Then install V4
|
||||
pipx install SuperClaude && pipx upgrade SuperClaude && SuperClaude install
|
||||
# 2. Install new plugin
|
||||
# Via Claude Code: /plugin marketplace → "pm-agent"
|
||||
# Or clone repository to project directory
|
||||
```
|
||||
|
||||
**✅ What gets preserved during upgrade:**
|
||||
- ✓ Your custom slash commands (outside `commands/sc/`)
|
||||
- ✓ Your custom content in `CLAUDE.md`
|
||||
- ✓ Claude Code's `.claude.json`, `.credentials.json`, `settings.json` and `settings.local.json`
|
||||
- ✓ Any custom agents and files you've added
|
||||
**What's New in V2.0:**
|
||||
- ✅ TypeScript plugins (hot reload support)
|
||||
- ✅ Auto-activation via SessionStart hook
|
||||
- ✅ 3 core plugins: PM Agent, Research, Index
|
||||
- ✅ Confidence-driven workflow (≥90% threshold, Precision/Recall 1.0)
|
||||
|
||||
**⚠️ Note:** Other SuperClaude-related `.json` files from V3 may cause conflicts and should be removed.
|
||||
**Migration Notes:**
|
||||
- Old: `/sc:pm`, `/sc:research`, `/sc:index-repo` (27 commands)
|
||||
- New: `/pm`, `/research`, `/index-repo` (3 plugin commands)
|
||||
- Functionality improved with hot reload and auto-activation
|
||||
|
||||
</details>
|
||||
|
||||
@@ -232,9 +243,9 @@ pip install --break-system-packages SuperClaude
|
||||
|
||||
<div align="center">
|
||||
|
||||
## 🎉 **What's New in V4**
|
||||
## 🎉 **What's New in V2.0**
|
||||
|
||||
> *Version 4 brings significant improvements based on community feedback and real-world usage patterns.*
|
||||
> *Version 2.0 brings architectural transformation: migration from 27 slash commands to 3 TypeScript plugins with hot reload and auto-activation.*
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -252,12 +263,13 @@ pip install --break-system-packages SuperClaude
|
||||
</td>
|
||||
<td width="50%">
|
||||
|
||||
### 📝 **Improved Namespace**
|
||||
**`/sc:` prefix** for all commands:
|
||||
- No conflicts with custom commands
|
||||
- 25 commands covering full lifecycle
|
||||
- From brainstorming to deployment
|
||||
- Clean, organized command structure
|
||||
### 🔥 **TypeScript Plugins**
|
||||
**3 core plugins** with hot reload:
|
||||
- **PM Agent**: Confidence-driven orchestration (≥90% threshold)
|
||||
- **Research**: Deep web search with adaptive planning
|
||||
- **Index**: 94% token reduction (58K → 3K)
|
||||
- Auto-activation via SessionStart hook
|
||||
- Edit → Save → Instant reflection (no restart)
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -265,14 +277,14 @@ pip install --break-system-packages SuperClaude
|
||||
<td width="50%">
|
||||
|
||||
### 🔧 **MCP Server Integration**
|
||||
**8 powerful servers** working together:
|
||||
- **Context7** → Up-to-date documentation
|
||||
- **Sequential** → Complex analysis
|
||||
**8 powerful servers** (via airis-mcp-gateway):
|
||||
- **Tavily** → Primary web search (Deep Research)
|
||||
- **Serena** → Session persistence & memory
|
||||
- **Mindbase** → Cross-session learning (zero-footprint)
|
||||
- **Sequential** → Token-efficient reasoning
|
||||
- **Context7** → Official documentation lookup
|
||||
- **Playwright** → JavaScript-heavy content extraction
|
||||
- **Magic** → UI component generation
|
||||
- **Playwright** → Browser testing
|
||||
- **Morphllm** → Bulk transformations
|
||||
- **Serena** → Session persistence
|
||||
- **Tavily** → Web search for deep research
|
||||
- **Chrome DevTools** → Performance analysis
|
||||
|
||||
</td>
|
||||
@@ -376,16 +388,16 @@ SuperClaude v4.2 introduces comprehensive Deep Research capabilities, enabling a
|
||||
|
||||
```bash
|
||||
# Basic research with automatic depth
|
||||
/sc:research "latest AI developments 2024"
|
||||
/research "latest AI developments 2024"
|
||||
|
||||
# Controlled research depth
|
||||
/sc:research "quantum computing breakthroughs" --depth exhaustive
|
||||
# Controlled research depth (via options in TypeScript)
|
||||
/research "quantum computing breakthroughs" # depth: exhaustive
|
||||
|
||||
# Specific strategy selection
|
||||
/sc:research "market analysis" --strategy planning-only
|
||||
/research "market analysis" # strategy: planning-only
|
||||
|
||||
# Domain-filtered research
|
||||
/sc:research "React patterns" --domains "reactjs.org,github.com"
|
||||
# Domain-filtered research (Tavily MCP integration)
|
||||
/research "React patterns" # domains: reactjs.org,github.com
|
||||
```
|
||||
|
||||
### **Research Depth Levels**
|
||||
@@ -435,8 +447,8 @@ The Deep Research system intelligently coordinates multiple tools:
|
||||
</td>
|
||||
<td valign="top">
|
||||
|
||||
- 🎯 [**Commands Reference**](docs/user-guide/commands.md)
|
||||
*All 25 slash commands*
|
||||
- 🎯 [**Plugin Commands**](docs/user-guide/commands.md)
|
||||
*3 core plugin commands*
|
||||
|
||||
- 🤖 [**Agents Guide**](docs/user-guide/agents.md)
|
||||
*15 specialized agents*
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
const { spawnSync } = require("child_process");
|
||||
|
||||
function run(cmd, args = [], opts = {}) {
|
||||
return spawnSync(cmd, args, {
|
||||
stdio: opts.stdio || "pipe",
|
||||
shell: true
|
||||
});
|
||||
}
|
||||
|
||||
function checkCommand(cmd, args = ["--version"]) {
|
||||
const result = run(cmd, args);
|
||||
return result.status === 0;
|
||||
}
|
||||
|
||||
function detectPython() {
|
||||
const candidates = ["python3", "python", "py"];
|
||||
for (let c of candidates) {
|
||||
if (checkCommand(c)) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function detectPip() {
|
||||
const candidates = ["pip3", "pip", "py -m pip"];
|
||||
for (let c of candidates) {
|
||||
if (checkCommand(c.split(" ")[0])) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function detectPipx() {
|
||||
if (checkCommand("pipx")) return "pipx";
|
||||
return null;
|
||||
}
|
||||
|
||||
function isSuperClaudeInstalled(pipCmd) {
|
||||
const result = run(pipCmd, ["show", "SuperClaude"]);
|
||||
return result.status === 0;
|
||||
}
|
||||
|
||||
function isSuperClaudeInstalledPipx() {
|
||||
const result = run("pipx", ["list"]);
|
||||
if (result.status === 0 && result.stdout) {
|
||||
return result.stdout.toString().includes("SuperClaude");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkPythonEnvironment() {
|
||||
// Check if we're in an externally managed environment (PEP 668)
|
||||
const result = run("python3", ["-c", "import sysconfig; print(sysconfig.get_path('stdlib'))"]);
|
||||
if (result.status === 0 && result.stdout) {
|
||||
const stdlibPath = result.stdout.toString().trim();
|
||||
const checkPep668 = run("test", ["-f", `${stdlibPath}/EXTERNALLY-MANAGED`]);
|
||||
return checkPep668.status === 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = { run, detectPython, detectPip, detectPipx, isSuperClaudeInstalled, isSuperClaudeInstalledPipx, checkPythonEnvironment };
|
||||
@@ -1,276 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Auto-update checker for SuperClaude NPM package
|
||||
* Checks npm registry for newer versions and offers automatic updates
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
const https = require('https');
|
||||
|
||||
const CACHE_FILE = path.join(process.env.HOME || process.env.USERPROFILE, '.claude', '.npm_update_check');
|
||||
const CHECK_INTERVAL = 86400000; // 24 hours in milliseconds
|
||||
const TIMEOUT = 2000; // 2 seconds
|
||||
const PACKAGE_NAME = '@bifrost_inc/superclaude';
|
||||
|
||||
/**
|
||||
* Get the current package version from package.json
|
||||
*/
|
||||
function getCurrentVersion() {
|
||||
try {
|
||||
const packagePath = path.join(__dirname, '..', 'package.json');
|
||||
const packageData = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
||||
return packageData.version;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we should perform an update check based on last check time
|
||||
*/
|
||||
function shouldCheckUpdate(force = false) {
|
||||
if (force) return true;
|
||||
|
||||
try {
|
||||
if (!fs.existsSync(CACHE_FILE)) return true;
|
||||
|
||||
const data = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
|
||||
const lastCheck = data.lastCheck || 0;
|
||||
|
||||
// Check if 24 hours have passed
|
||||
return Date.now() - lastCheck > CHECK_INTERVAL;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the current timestamp as last check time
|
||||
*/
|
||||
function saveCheckTimestamp() {
|
||||
const cacheDir = path.dirname(CACHE_FILE);
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
if (!fs.existsSync(cacheDir)) {
|
||||
fs.mkdirSync(cacheDir, { recursive: true });
|
||||
}
|
||||
|
||||
let data = {};
|
||||
try {
|
||||
if (fs.existsSync(CACHE_FILE)) {
|
||||
data = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors
|
||||
}
|
||||
|
||||
data.lastCheck = Date.now();
|
||||
fs.writeFileSync(CACHE_FILE, JSON.stringify(data, null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Query npm registry for the latest version
|
||||
*/
|
||||
function getLatestVersion() {
|
||||
return new Promise((resolve) => {
|
||||
const options = {
|
||||
hostname: 'registry.npmjs.org',
|
||||
path: `/${PACKAGE_NAME}/latest`,
|
||||
method: 'GET',
|
||||
timeout: TIMEOUT,
|
||||
headers: {
|
||||
'User-Agent': 'SuperClaude-Updater'
|
||||
}
|
||||
};
|
||||
|
||||
const req = https.request(options, (res) => {
|
||||
let data = '';
|
||||
|
||||
res.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const packageData = JSON.parse(data);
|
||||
resolve(packageData.version);
|
||||
} catch {
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', () => resolve(null));
|
||||
req.on('timeout', () => {
|
||||
req.destroy();
|
||||
resolve(null);
|
||||
});
|
||||
|
||||
req.setTimeout(TIMEOUT);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare version strings
|
||||
*/
|
||||
function isNewerVersion(current, latest) {
|
||||
if (!current || !latest) return false;
|
||||
|
||||
const currentParts = current.split('.').map(Number);
|
||||
const latestParts = latest.split('.').map(Number);
|
||||
|
||||
for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
|
||||
const currentPart = currentParts[i] || 0;
|
||||
const latestPart = latestParts[i] || 0;
|
||||
|
||||
if (latestPart > currentPart) return true;
|
||||
if (latestPart < currentPart) return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if npm or yarn is being used globally
|
||||
*/
|
||||
function detectPackageManager() {
|
||||
// Check if installed globally with npm
|
||||
const npmResult = spawnSync('npm', ['list', '-g', PACKAGE_NAME], {
|
||||
encoding: 'utf8',
|
||||
shell: true
|
||||
});
|
||||
|
||||
if (npmResult.status === 0 && npmResult.stdout.includes(PACKAGE_NAME)) {
|
||||
return 'npm';
|
||||
}
|
||||
|
||||
// Check if installed globally with yarn
|
||||
const yarnResult = spawnSync('yarn', ['global', 'list'], {
|
||||
encoding: 'utf8',
|
||||
shell: true
|
||||
});
|
||||
|
||||
if (yarnResult.status === 0 && yarnResult.stdout.includes(PACKAGE_NAME)) {
|
||||
return 'yarn';
|
||||
}
|
||||
|
||||
return 'npm'; // Default to npm
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appropriate update command
|
||||
*/
|
||||
function getUpdateCommand() {
|
||||
const pm = detectPackageManager();
|
||||
|
||||
if (pm === 'yarn') {
|
||||
return `yarn global upgrade ${PACKAGE_NAME}`;
|
||||
}
|
||||
|
||||
return `npm update -g ${PACKAGE_NAME}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show update banner
|
||||
*/
|
||||
function showUpdateBanner(currentVersion, latestVersion, autoUpdate = false) {
|
||||
const updateCmd = getUpdateCommand();
|
||||
|
||||
console.log('\n\x1b[36m╔════════════════════════════════════════════════╗\x1b[0m');
|
||||
console.log(`\x1b[36m║\x1b[33m 🚀 Update Available: ${currentVersion} → ${latestVersion} \x1b[36m║\x1b[0m`);
|
||||
console.log(`\x1b[36m║\x1b[32m Run: ${updateCmd.padEnd(30)} \x1b[36m║\x1b[0m`);
|
||||
console.log('\x1b[36m╚════════════════════════════════════════════════╝\x1b[0m\n');
|
||||
|
||||
return autoUpdate || process.env.SUPERCLAUDE_AUTO_UPDATE === 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the update
|
||||
*/
|
||||
function performUpdate() {
|
||||
const updateCmd = getUpdateCommand();
|
||||
console.log('\x1b[36m🔄 Updating SuperClaude...\x1b[0m');
|
||||
|
||||
const cmdParts = updateCmd.split(' ');
|
||||
const result = spawnSync(cmdParts[0], cmdParts.slice(1), {
|
||||
stdio: 'inherit',
|
||||
shell: true
|
||||
});
|
||||
|
||||
if (result.status === 0) {
|
||||
console.log('\x1b[32m✅ Update completed successfully!\x1b[0m');
|
||||
console.log('\x1b[33mPlease restart SuperClaude to use the new version.\x1b[0m');
|
||||
return true;
|
||||
} else {
|
||||
console.log('\x1b[33m⚠️ Update failed. Please run manually:\x1b[0m');
|
||||
console.log(` ${updateCmd}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function to check and notify for updates
|
||||
*/
|
||||
async function checkAndNotify(options = {}) {
|
||||
const { force = false, autoUpdate = false, silent = false } = options;
|
||||
|
||||
// Check environment variables
|
||||
if (process.env.SUPERCLAUDE_NO_UPDATE_CHECK === 'true') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if enough time has passed
|
||||
if (!shouldCheckUpdate(force)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get current version
|
||||
const currentVersion = getCurrentVersion();
|
||||
if (!currentVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get latest version
|
||||
const latestVersion = await getLatestVersion();
|
||||
if (!latestVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save timestamp
|
||||
saveCheckTimestamp();
|
||||
|
||||
// Compare versions
|
||||
if (!isNewerVersion(currentVersion, latestVersion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show banner unless silent
|
||||
if (!silent) {
|
||||
const shouldUpdate = showUpdateBanner(currentVersion, latestVersion, autoUpdate);
|
||||
|
||||
if (shouldUpdate) {
|
||||
return performUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Export functions for use in other modules
|
||||
module.exports = {
|
||||
checkAndNotify,
|
||||
getCurrentVersion,
|
||||
getLatestVersion,
|
||||
isNewerVersion
|
||||
};
|
||||
|
||||
// If run directly, perform check
|
||||
if (require.main === module) {
|
||||
checkAndNotify({
|
||||
force: process.argv.includes('--force'),
|
||||
autoUpdate: process.argv.includes('--auto-update')
|
||||
});
|
||||
}
|
||||
44
bin/cli.js
44
bin/cli.js
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
const { spawnSync } = require("child_process");
|
||||
const { detectPython, detectPip } = require("./check_env");
|
||||
const { checkAndNotify } = require("./check_update");
|
||||
|
||||
let pythonCmd = detectPython();
|
||||
if (!pythonCmd) {
|
||||
console.error("❌ Python 3 is required but not found.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
// Parse command line arguments for update control
|
||||
const noUpdateCheck = args.includes('--no-update-check');
|
||||
const autoUpdate = args.includes('--auto-update');
|
||||
const isQuiet = args.includes('--quiet') || args.includes('-q');
|
||||
|
||||
// Special case: update command
|
||||
if (args[0] === "update") {
|
||||
require("./update");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Check for updates unless disabled
|
||||
if (!noUpdateCheck && !isQuiet) {
|
||||
// Run update check asynchronously to avoid blocking
|
||||
checkAndNotify({
|
||||
autoUpdate: autoUpdate,
|
||||
silent: false
|
||||
}).then(updated => {
|
||||
if (updated) {
|
||||
console.log("\n🔄 SuperClaude was updated. Please restart to use the new version.");
|
||||
process.exit(0);
|
||||
}
|
||||
}).catch(() => {
|
||||
// Silently ignore update check errors
|
||||
});
|
||||
}
|
||||
|
||||
// Forward everything to Python SuperClaude
|
||||
const result = spawnSync(pythonCmd, ["-m", "SuperClaude", ...args], { stdio: "inherit", shell: true });
|
||||
process.exit(result.status);
|
||||
|
||||
114
bin/install.js
114
bin/install.js
@@ -1,114 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
const { run, detectPython, detectPip, detectPipx, isSuperClaudeInstalled, isSuperClaudeInstalledPipx, checkPythonEnvironment } = require("./check_env");
|
||||
|
||||
console.log("🔍 Checking environment...");
|
||||
|
||||
let pythonCmd = detectPython();
|
||||
if (!pythonCmd) {
|
||||
console.error("❌ Python 3 is required but not found.");
|
||||
console.error(" Please install Python 3.8 or later from https://python.org");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`✅ Found Python: ${pythonCmd}`);
|
||||
|
||||
// Check if we're in an externally managed environment (PEP 668)
|
||||
const isExternallyManaged = checkPythonEnvironment();
|
||||
let installMethod = null;
|
||||
let isInstalled = false;
|
||||
|
||||
if (isExternallyManaged) {
|
||||
console.log("📦 Detected externally managed Python environment (PEP 668)");
|
||||
|
||||
// Try pipx first for externally managed environments
|
||||
let pipxCmd = detectPipx();
|
||||
if (pipxCmd) {
|
||||
console.log(`✅ Found pipx: ${pipxCmd}`);
|
||||
installMethod = "pipx";
|
||||
isInstalled = isSuperClaudeInstalledPipx();
|
||||
} else {
|
||||
console.log("⚠️ pipx is recommended for this system but not found.");
|
||||
console.log(" You can install pipx with: apt install pipx (Ubuntu/Debian) or brew install pipx (macOS)");
|
||||
console.log(" Alternatively, use one of these:");
|
||||
console.log(" pip install --user SuperClaude # Recommended");
|
||||
console.log(" pip install --break-system-packages SuperClaude # Force (use with caution)");
|
||||
|
||||
// Fall back to pip with --user flag
|
||||
let pipCmd = detectPip();
|
||||
if (pipCmd) {
|
||||
console.log(`✅ Found pip: ${pipCmd}`);
|
||||
console.log(" Will attempt installation with --user flag");
|
||||
installMethod = "pip-user";
|
||||
isInstalled = isSuperClaudeInstalled(pipCmd);
|
||||
} else {
|
||||
console.error("❌ Neither pipx nor pip found. Please install one of them.");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Standard environment - use pip normally
|
||||
let pipCmd = detectPip();
|
||||
if (!pipCmd) {
|
||||
console.error("❌ pip is required but not found.");
|
||||
console.error(" Please install pip or use your system's package manager");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`✅ Found pip: ${pipCmd}`);
|
||||
installMethod = "pip";
|
||||
isInstalled = isSuperClaudeInstalled(pipCmd);
|
||||
}
|
||||
|
||||
// Perform installation based on detected method
|
||||
if (!isInstalled) {
|
||||
console.log("📦 Installing SuperClaude from PyPI...");
|
||||
|
||||
let result;
|
||||
switch(installMethod) {
|
||||
case "pipx":
|
||||
result = run("pipx", ["install", "SuperClaude"], { stdio: "inherit" });
|
||||
break;
|
||||
case "pip-user":
|
||||
result = run(detectPip(), ["install", "--user", "SuperClaude"], { stdio: "inherit" });
|
||||
break;
|
||||
case "pip":
|
||||
result = run(detectPip(), ["install", "SuperClaude"], { stdio: "inherit" });
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error("❌ Installation failed.");
|
||||
if (installMethod === "pip" && isExternallyManaged) {
|
||||
console.error(" Your system requires pipx or --user flag for pip installations.");
|
||||
console.error(" Try: pipx install SuperClaude");
|
||||
console.error(" Or: pip install --user SuperClaude");
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("✅ SuperClaude installed successfully!");
|
||||
|
||||
// For pipx installations, ensure it's in PATH
|
||||
if (installMethod === "pipx") {
|
||||
console.log("\n📌 Note: If 'SuperClaude' command is not found, run:");
|
||||
console.log(" pipx ensurepath");
|
||||
console.log(" Then restart your terminal or run: source ~/.bashrc");
|
||||
}
|
||||
} else {
|
||||
console.log("✅ SuperClaude already installed.");
|
||||
}
|
||||
|
||||
// Try to run SuperClaude install
|
||||
console.log("\n🚀 Running SuperClaude installation...");
|
||||
const installResult = run("SuperClaude", ["install"], { stdio: "inherit" });
|
||||
|
||||
if (installResult.status !== 0) {
|
||||
console.log("\n⚠️ Could not run 'SuperClaude install' automatically.");
|
||||
console.log(" Please run it manually after ensuring SuperClaude is in your PATH:");
|
||||
console.log(" SuperClaude install");
|
||||
|
||||
if (installMethod === "pipx") {
|
||||
console.log("\n If command not found, try:");
|
||||
console.log(" pipx ensurepath && source ~/.bashrc");
|
||||
} else if (installMethod === "pip-user") {
|
||||
console.log("\n If command not found, add Python user bin to PATH:");
|
||||
console.log(" export PATH=\"$HOME/.local/bin:$PATH\"");
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
const { run, detectPip, detectPipx, isSuperClaudeInstalledPipx, checkPythonEnvironment } = require("./check_env");
|
||||
|
||||
console.log("🔄 Checking for SuperClaude updates...");
|
||||
|
||||
// Detect installation method
|
||||
const isExternallyManaged = checkPythonEnvironment();
|
||||
let updateMethod = null;
|
||||
|
||||
// Check if installed via pipx
|
||||
if (detectPipx() && isSuperClaudeInstalledPipx()) {
|
||||
updateMethod = "pipx";
|
||||
console.log("✅ Detected pipx installation");
|
||||
} else {
|
||||
// Check for pip installation
|
||||
let pipCmd = detectPip();
|
||||
if (!pipCmd) {
|
||||
console.error("❌ Neither pipx nor pip found, cannot update.");
|
||||
console.error(" Please install SuperClaude first using:");
|
||||
console.error(" pipx install SuperClaude");
|
||||
console.error(" or");
|
||||
console.error(" pip install SuperClaude");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (isExternallyManaged) {
|
||||
updateMethod = "pip-user";
|
||||
console.log("✅ Detected pip installation with --user flag");
|
||||
} else {
|
||||
updateMethod = "pip";
|
||||
console.log("✅ Detected standard pip installation");
|
||||
}
|
||||
}
|
||||
|
||||
// Perform update based on detected method
|
||||
console.log("🔄 Updating SuperClaude from PyPI...");
|
||||
|
||||
let result;
|
||||
switch(updateMethod) {
|
||||
case "pipx":
|
||||
result = run("pipx", ["upgrade", "SuperClaude"], { stdio: "inherit" });
|
||||
break;
|
||||
case "pip-user":
|
||||
result = run(detectPip(), ["install", "--upgrade", "--user", "SuperClaude"], { stdio: "inherit" });
|
||||
break;
|
||||
case "pip":
|
||||
result = run(detectPip(), ["install", "--upgrade", "SuperClaude"], { stdio: "inherit" });
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error("❌ Update failed.");
|
||||
if (updateMethod === "pip" && isExternallyManaged) {
|
||||
console.error(" Your system requires pipx or --user flag for pip operations.");
|
||||
console.error(" Try: pipx upgrade SuperClaude");
|
||||
console.error(" Or: pip install --upgrade --user SuperClaude");
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("✅ SuperClaude updated successfully!");
|
||||
|
||||
// Run SuperClaude update command
|
||||
console.log("\n🚀 Running SuperClaude update...");
|
||||
const updateResult = run("SuperClaude", ["update"], { stdio: "inherit" });
|
||||
|
||||
if (updateResult.status !== 0) {
|
||||
console.log("\n⚠️ Could not run 'SuperClaude update' automatically.");
|
||||
console.log(" Please run it manually:");
|
||||
console.log(" SuperClaude update");
|
||||
}
|
||||
Reference in New Issue
Block a user