@superclaude-org/superflag 3.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.
- package/LICENSE +21 -0
- package/README.md +292 -0
- package/dist/directives.d.ts +44 -0
- package/dist/directives.d.ts.map +1 -0
- package/dist/directives.js +99 -0
- package/dist/directives.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +870 -0
- package/dist/install.js.map +1 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +203 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +43 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +117 -0
- package/dist/session.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/flags.yaml +569 -0
- package/hooks/superflag.py +192 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Context Engine MCP 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,292 @@
|
|
|
1
|
+
# SuperFlag
|
|
2
|
+
|
|
3
|
+
> **⚠️ MIGRATION NOTICE**: TypeScript/MCP version now available:
|
|
4
|
+
> ```bash
|
|
5
|
+
> npm install -g @superclaude-org/superflag
|
|
6
|
+
> # or use with npx
|
|
7
|
+
> npx @superclaude-org/superflag install
|
|
8
|
+
> ```
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
> **Note**: This project was inspired by the pioneering work in [SuperClaude Framework](https://github.com/SuperClaude-Org/SuperClaude_Framework) and [SuperGemini Framework](https://github.com/SuperClaude-Org/SuperGemini_Framework). Special thanks to [SuperClaude-Org](https://github.com/SuperClaude-Org) team members [@NomenAK](https://github.com/NomenAK) and [@mithun50](https://github.com/mithun50) whose work made this possible.
|
|
15
|
+
|
|
16
|
+
SuperFlag provides 18 contextual flags that guide assistant behavior (e.g., `--strict`, `--auto`). It exposes an MCP stdio server and small setup helpers for common clients.
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install globally
|
|
22
|
+
npm install -g @superclaude-org/superflag
|
|
23
|
+
|
|
24
|
+
# Interactive installation (choose platforms)
|
|
25
|
+
superflag install
|
|
26
|
+
|
|
27
|
+
# Direct installation
|
|
28
|
+
superflag install cc # Claude Code
|
|
29
|
+
superflag install gemini # Gemini CLI
|
|
30
|
+
superflag install cn # Continue
|
|
31
|
+
|
|
32
|
+
# Register MCP server in Claude Code
|
|
33
|
+
claude mcp add superflag "npx" "-y" "@superclaude-org/superflag" -s user
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then in your client/assistant, use prompts with flags:
|
|
37
|
+
- "Fix this bug --auto" (auto-select flags)
|
|
38
|
+
- "--save" (handoff documentation)
|
|
39
|
+
- "Analyze --strict" (precise, zero-tolerance mode)
|
|
40
|
+
|
|
41
|
+
## 18 Flags
|
|
42
|
+
|
|
43
|
+
| Flag | Purpose |
|
|
44
|
+
|------|---------|
|
|
45
|
+
| `--analyze` | Multi-angle systematic analysis |
|
|
46
|
+
| `--auto` | AI selects optimal flag combination |
|
|
47
|
+
| `--collab` | Co-develop solutions through trust-based iteration |
|
|
48
|
+
| `--concise` | Minimal communication |
|
|
49
|
+
| `--discover` | Discover existing solutions before building new |
|
|
50
|
+
| `--explain` | Progressive disclosure |
|
|
51
|
+
| `--git` | Version control best practices |
|
|
52
|
+
| `--lean` | Essential focus only |
|
|
53
|
+
| `--load` | Load handoff documentation |
|
|
54
|
+
| `--parallel` | Multi-agent processing |
|
|
55
|
+
| `--performance` | Speed and efficiency optimization |
|
|
56
|
+
| `--readonly` | Analysis only mode |
|
|
57
|
+
| `--refactor` | Code quality improvement |
|
|
58
|
+
| `--reset` | Reset all flag states to new (clears session cache) |
|
|
59
|
+
| `--save` | Handoff documentation |
|
|
60
|
+
| `--seq` | Sequential thinking |
|
|
61
|
+
| `--strict` | Zero-error enforcement |
|
|
62
|
+
| `--todo` | Task management |
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
### Claude Code
|
|
67
|
+
```bash
|
|
68
|
+
# Install package
|
|
69
|
+
pip install superflag
|
|
70
|
+
|
|
71
|
+
# Install configuration files (automatic MCP registration)
|
|
72
|
+
superflag install
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Continue Extension
|
|
76
|
+
```bash
|
|
77
|
+
# Install package
|
|
78
|
+
pip install superflag
|
|
79
|
+
|
|
80
|
+
# Install configuration files
|
|
81
|
+
superflag install --target cn
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Edit `~/.continue/mcpServers/superflag.yaml`:
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
# Standard Python (most common)
|
|
88
|
+
name: SuperFlag
|
|
89
|
+
command: python
|
|
90
|
+
args: ["-m", "superflag"]
|
|
91
|
+
|
|
92
|
+
# Or use absolute path to specific environment
|
|
93
|
+
# name: SuperFlag
|
|
94
|
+
# command: /path/to/venv/bin/python
|
|
95
|
+
# args: ["-m", "superflag"]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Restart VS Code, then type `@` in Continue chat to access MCP tools.
|
|
99
|
+
|
|
100
|
+
### Gemini CLI
|
|
101
|
+
```bash
|
|
102
|
+
# Install package
|
|
103
|
+
pip install superflag
|
|
104
|
+
|
|
105
|
+
# Install configuration files for Gemini CLI
|
|
106
|
+
superflag install --target gemini-cli
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This command:
|
|
110
|
+
- Appends `@SUPERFLAG.md` to `~/.gemini/GEMINI.md` (adds once; no duplicate)
|
|
111
|
+
- Writes latest instructions to `~/.gemini/SUPERFLAG.md`
|
|
112
|
+
|
|
113
|
+
Register the MCP stdio command in Gemini CLI settings:
|
|
114
|
+
- Command: `python -m superflag`
|
|
115
|
+
- Args: `[]`
|
|
116
|
+
- Transport: stdio
|
|
117
|
+
|
|
118
|
+
MCP registration (example)
|
|
119
|
+
- File: `~/.gemini/settings.json`
|
|
120
|
+
- Add or merge this into the `mcpServers` section:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"superflag": {
|
|
126
|
+
"type": "stdio",
|
|
127
|
+
"command": "python",
|
|
128
|
+
"args": ["-m", "superflag"],
|
|
129
|
+
"env": {}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Gemini CLI settings
|
|
136
|
+
- Location: `~/.gemini/settings.json`
|
|
137
|
+
- Structure:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"<server-name>": {
|
|
143
|
+
"type": "stdio",
|
|
144
|
+
"command": "<executable or interpreter>",
|
|
145
|
+
"args": ["<arg1>", "<arg2>", "..."],
|
|
146
|
+
"env": { "ENV_KEY": "value" }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Common setups
|
|
153
|
+
- pip (python -m):
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"superflag": {
|
|
158
|
+
"type": "stdio",
|
|
159
|
+
"command": "python",
|
|
160
|
+
"args": ["-m", "superflag"],
|
|
161
|
+
"env": {}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
- venv absolute path (Windows):
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"mcpServers": {
|
|
171
|
+
"superflag": {
|
|
172
|
+
"type": "stdio",
|
|
173
|
+
"command": "C:\\path\\to\\venv\\Scripts\\superflag.exe",
|
|
174
|
+
"args": [],
|
|
175
|
+
"env": {}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- venv with interpreter (module run):
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"mcpServers": {
|
|
185
|
+
"superflag": {
|
|
186
|
+
"type": "stdio",
|
|
187
|
+
"command": "/path/to/venv/bin/python",
|
|
188
|
+
"args": ["-m", "superflag"],
|
|
189
|
+
"env": {}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Notes
|
|
196
|
+
- `type` is `stdio`.
|
|
197
|
+
- If the command is not on PATH, use an absolute path (escape backslashes on Windows).
|
|
198
|
+
- After editing, restart Gemini CLI and verify tools (e.g., list_available_flags).
|
|
199
|
+
|
|
200
|
+
## Usage
|
|
201
|
+
|
|
202
|
+
### In Chat
|
|
203
|
+
```python
|
|
204
|
+
# Auto mode - AI selects flags
|
|
205
|
+
"Refactor this code --auto"
|
|
206
|
+
|
|
207
|
+
# Direct flags
|
|
208
|
+
"--save" # Creates handoff doc
|
|
209
|
+
"--analyze --strict" # Multi-angle analysis with zero errors
|
|
210
|
+
"--reset --analyze" # Reset session and reapply
|
|
211
|
+
|
|
212
|
+
# Combined flags
|
|
213
|
+
"Review this --analyze --strict --seq"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### MCP Tools
|
|
217
|
+
- `get_directives(['--flag1', '--flag2'])` - Activates flags
|
|
218
|
+
|
|
219
|
+
Development: use `pip install -e .` for editable installs.
|
|
220
|
+
|
|
221
|
+
Configuration updates: edit `~/.superflag/flags.yaml` and restart the MCP server.
|
|
222
|
+
|
|
223
|
+
### Optional MCP Servers
|
|
224
|
+
Additional MCP servers can complement certain flags:
|
|
225
|
+
|
|
226
|
+
#### For `--seq` flag:
|
|
227
|
+
```bash
|
|
228
|
+
# Sequential thinking server
|
|
229
|
+
claude mcp add -s user -- sequential-thinking npx -y @modelcontextprotocol/server-sequential-thinking
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
These are optional; SuperFlag works without them.
|
|
233
|
+
|
|
234
|
+
### Session
|
|
235
|
+
- Duplicate flags produce a brief reminder instead of repeating full directives.
|
|
236
|
+
- Use `--reset` when the task/context changes (resets all flag states to new).
|
|
237
|
+
- The server tracks active flags per session.
|
|
238
|
+
- Note: In Claude, flag states persist through `/clear` or `/compact` commands. Use `--reset` to reinitialize.
|
|
239
|
+
|
|
240
|
+
## `--auto`
|
|
241
|
+
`--auto` instructs the assistant to analyze the task and pick appropriate flags (do not include `--auto` in get_directives calls).
|
|
242
|
+
|
|
243
|
+
Behavior
|
|
244
|
+
- `--auto` only: the assistant selects a full set of flags automatically.
|
|
245
|
+
- `--auto --flag1 --flag2`: the assistant applies `--flag1`, `--flag2` and may add additional flags if helpful. User‑specified flags take priority when there is overlap or conflict.
|
|
246
|
+
- `--flag1 --flag2` (without `--auto`): only the specified flags are applied.
|
|
247
|
+
|
|
248
|
+
## Files Created
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
~/.claude/
|
|
252
|
+
├── CLAUDE.md # References @SUPERFLAG.md
|
|
253
|
+
├── SUPERFLAG.md # Flag instructions (auto-updated)
|
|
254
|
+
├── hooks/
|
|
255
|
+
│ └── superflag.py # Hook for flag detection (Claude Code only)
|
|
256
|
+
└── settings.json # Updated with hook registration (Claude Code only)
|
|
257
|
+
|
|
258
|
+
~/.continue/
|
|
259
|
+
├── config.yaml # Contains SuperFlag rules
|
|
260
|
+
└── mcpServers/
|
|
261
|
+
├── superflag.yaml
|
|
262
|
+
├── sequential-thinking.yaml
|
|
263
|
+
└── context7.yaml
|
|
264
|
+
|
|
265
|
+
~/.superflag/
|
|
266
|
+
└── flags.yaml # Flag definitions
|
|
267
|
+
|
|
268
|
+
~/.gemini/
|
|
269
|
+
├── GEMINI.md # References @SUPERFLAG.md
|
|
270
|
+
└── SUPERFLAG.md # Flag instructions (auto-updated)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Uninstallation
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Complete uninstall from all environments (Claude Code + Continue)
|
|
277
|
+
superflag uninstall
|
|
278
|
+
|
|
279
|
+
# Remove Python package
|
|
280
|
+
pip uninstall superflag
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Note: During uninstallation, `~/.superflag/flags.yaml` is backed up to `~/flags.yaml.backup_YYYYMMDD_HHMMSS` before removal. During installation, existing flags.yaml is backed up and updated to the latest version.
|
|
284
|
+
|
|
285
|
+
Claude Code note: Uninstall removes the `@SUPERFLAG.md` reference from `~/.claude/CLAUDE.md`, deletes `~/.claude/SUPERFLAG.md` if present, removes the hook file from `~/.claude/hooks/superflag.py`, and removes the hook registration from `~/.claude/settings.json`.
|
|
286
|
+
|
|
287
|
+
Gemini CLI note: Uninstall removes the `@SUPERFLAG.md` reference from `~/.gemini/GEMINI.md` and deletes `~/.gemini/SUPERFLAG.md` if present.
|
|
288
|
+
|
|
289
|
+
Continue note: Uninstall removes the SuperFlag rules from `~/.continue/config.yaml` (when present) and deletes `~/.continue/mcpServers/superflag.yaml` if present.
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
MIT
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
interface FlagConfig {
|
|
2
|
+
brief: string;
|
|
3
|
+
directive: string;
|
|
4
|
+
verification?: string;
|
|
5
|
+
}
|
|
6
|
+
interface FlagsYaml {
|
|
7
|
+
directives: Record<string, FlagConfig>;
|
|
8
|
+
hook_messages?: Record<string, any>;
|
|
9
|
+
meta_instructions?: {
|
|
10
|
+
list_available_flags?: string;
|
|
11
|
+
get_directives?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface Directive {
|
|
15
|
+
brief: string;
|
|
16
|
+
raw: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class DirectiveLoader {
|
|
19
|
+
private cachedConfig;
|
|
20
|
+
private lastLoadTime;
|
|
21
|
+
private cacheTimeout;
|
|
22
|
+
/**
|
|
23
|
+
* Load directives for specified flags from YAML file
|
|
24
|
+
*/
|
|
25
|
+
loadDirectives(flags: string[], yamlPath: string): Promise<Record<string, Directive>>;
|
|
26
|
+
/**
|
|
27
|
+
* Load and cache YAML configuration
|
|
28
|
+
*/
|
|
29
|
+
loadYamlConfig(yamlPath: string): Promise<FlagsYaml>;
|
|
30
|
+
/**
|
|
31
|
+
* Format a flag config into a directive
|
|
32
|
+
*/
|
|
33
|
+
private formatDirective;
|
|
34
|
+
/**
|
|
35
|
+
* Copy bundled flags.yaml to user directory
|
|
36
|
+
*/
|
|
37
|
+
private copyBundledConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Clear the cache (useful for testing or forced reload)
|
|
40
|
+
*/
|
|
41
|
+
clearCache(): void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=directives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAUA,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,SAAS;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,iBAAiB,CAAC,EAAE;QAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,YAAY,CAAiB;IAErC;;OAEG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAwBrC;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAmC1D;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;YACW,iBAAiB;IAa/B;;OAEG;IACH,UAAU,IAAI,IAAI;CAInB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as yaml from "js-yaml";
|
|
2
|
+
import * as fs from "fs/promises";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { dirname } from "path";
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
export class DirectiveLoader {
|
|
9
|
+
cachedConfig = null;
|
|
10
|
+
lastLoadTime = 0;
|
|
11
|
+
cacheTimeout = 60000; // 1 minute cache
|
|
12
|
+
/**
|
|
13
|
+
* Load directives for specified flags from YAML file
|
|
14
|
+
*/
|
|
15
|
+
async loadDirectives(flags, yamlPath) {
|
|
16
|
+
// Load configuration
|
|
17
|
+
const config = await this.loadYamlConfig(yamlPath);
|
|
18
|
+
// Map flags to directives
|
|
19
|
+
const directives = {};
|
|
20
|
+
for (const flag of flags) {
|
|
21
|
+
const flagConfig = config.directives?.[flag];
|
|
22
|
+
if (flagConfig) {
|
|
23
|
+
directives[flag] = this.formatDirective(flagConfig);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Handle unknown flag
|
|
27
|
+
directives[flag] = {
|
|
28
|
+
brief: "Unknown flag",
|
|
29
|
+
raw: `<task>\nUnknown flag: ${flag}\n</task>\n\n<verify>\n☐ Flag not found in configuration\n</verify>`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return directives;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Load and cache YAML configuration
|
|
37
|
+
*/
|
|
38
|
+
async loadYamlConfig(yamlPath) {
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
// Check cache
|
|
41
|
+
if (this.cachedConfig &&
|
|
42
|
+
now - this.lastLoadTime < this.cacheTimeout) {
|
|
43
|
+
return this.cachedConfig;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
// Check if file exists
|
|
47
|
+
await fs.access(yamlPath);
|
|
48
|
+
// Read and parse YAML
|
|
49
|
+
const content = await fs.readFile(yamlPath, "utf-8");
|
|
50
|
+
const config = yaml.load(content);
|
|
51
|
+
// Update cache
|
|
52
|
+
this.cachedConfig = config;
|
|
53
|
+
this.lastLoadTime = now;
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// If user's file doesn't exist, copy from package
|
|
58
|
+
try {
|
|
59
|
+
return await this.copyBundledConfig(yamlPath);
|
|
60
|
+
}
|
|
61
|
+
catch (copyError) {
|
|
62
|
+
// Fatal error: No flags.yaml found
|
|
63
|
+
throw new Error(`Cannot find flags.yaml. The package is corrupted or incomplete. Please reinstall.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Format a flag config into a directive
|
|
69
|
+
*/
|
|
70
|
+
formatDirective(flagConfig) {
|
|
71
|
+
// Just use the directive as-is from YAML
|
|
72
|
+
// The YAML already has proper formatting
|
|
73
|
+
return {
|
|
74
|
+
brief: flagConfig.brief,
|
|
75
|
+
raw: flagConfig.directive,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Copy bundled flags.yaml to user directory
|
|
80
|
+
*/
|
|
81
|
+
async copyBundledConfig(yamlPath) {
|
|
82
|
+
const packageFlagsPath = path.join(__dirname, '..', 'flags.yaml');
|
|
83
|
+
const content = await fs.readFile(packageFlagsPath, 'utf-8');
|
|
84
|
+
const config = yaml.load(content);
|
|
85
|
+
// Copy to user's home directory
|
|
86
|
+
const dir = path.dirname(yamlPath);
|
|
87
|
+
await fs.mkdir(dir, { recursive: true });
|
|
88
|
+
await fs.writeFile(yamlPath, content, 'utf-8');
|
|
89
|
+
return config;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Clear the cache (useful for testing or forced reload)
|
|
93
|
+
*/
|
|
94
|
+
clearCache() {
|
|
95
|
+
this.cachedConfig = null;
|
|
96
|
+
this.lastLoadTime = 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=directives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAsBtC,MAAM,OAAO,eAAe;IAClB,YAAY,GAAqB,IAAI,CAAC;IACtC,YAAY,GAAW,CAAC,CAAC;IACzB,YAAY,GAAW,KAAK,CAAC,CAAC,iBAAiB;IAEvD;;OAEG;IACH,KAAK,CAAC,cAAc,CAClB,KAAe,EACf,QAAgB;QAEhB,qBAAqB;QACrB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAEnD,0BAA0B;QAC1B,MAAM,UAAU,GAA8B,EAAE,CAAC;QAEjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC;YAE7C,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,sBAAsB;gBACtB,UAAU,CAAC,IAAI,CAA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J,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,iBAAiB,CAAC,QAAgB;QAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAClE,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc,CAAC;QAE/C,gCAAgC;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAE/C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IACxB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { SuperFlagServer } from "./server.js";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { VERSION } from "./version.js";
|
|
8
|
+
// Check for CLI commands
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
// Handle version flags (NPM best practice)
|
|
11
|
+
if (args[0] === "--version" || args[0] === "-v" || args[0] === "version") {
|
|
12
|
+
console.log(VERSION);
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
// Handle help flags
|
|
16
|
+
if (args[0] === "--help" || args[0] === "-h" || args[0] === "help") {
|
|
17
|
+
console.log(`SuperFlag v${VERSION}`);
|
|
18
|
+
console.log("\nUsage:");
|
|
19
|
+
console.log(" superflag --version, -v Show version");
|
|
20
|
+
console.log(" superflag --help, -h Show help");
|
|
21
|
+
console.log(" superflag install [--target TARGET] Install SuperFlag");
|
|
22
|
+
console.log(" superflag uninstall [--target TARGET] Uninstall SuperFlag");
|
|
23
|
+
console.log(" superflag Run as MCP server");
|
|
24
|
+
console.log("\nTargets:");
|
|
25
|
+
console.log(" claude-code Claude Code platform");
|
|
26
|
+
console.log(" gemini-cli Gemini CLI platform");
|
|
27
|
+
console.log(" cn Continue platform");
|
|
28
|
+
console.log(" all All platforms");
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
if (args[0] === "install" || args[0] === "uninstall") {
|
|
32
|
+
// Delegate to install script
|
|
33
|
+
import("./install.js").then(module => {
|
|
34
|
+
module.handleCommand(args[0], args.slice(1));
|
|
35
|
+
}).catch(err => {
|
|
36
|
+
console.error(chalk.red(`Failed to load install module: ${err.message}`));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Run MCP server
|
|
42
|
+
runServer().catch((error) => {
|
|
43
|
+
console.error(chalk.red("Fatal error running server:"), error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function runServer() {
|
|
48
|
+
console.error(chalk.cyan("Starting SuperFlag MCP Server..."));
|
|
49
|
+
const server = new Server({
|
|
50
|
+
name: "superflag",
|
|
51
|
+
version: VERSION,
|
|
52
|
+
}, {
|
|
53
|
+
capabilities: {
|
|
54
|
+
tools: {},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const superflagServer = new SuperFlagServer();
|
|
58
|
+
// Register tools
|
|
59
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
60
|
+
tools: superflagServer.getTools(),
|
|
61
|
+
}));
|
|
62
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
63
|
+
const result = await superflagServer.handleToolCall(request.params.name, request.params.arguments);
|
|
64
|
+
return result;
|
|
65
|
+
});
|
|
66
|
+
// Connect via stdio
|
|
67
|
+
const transport = new StdioServerTransport();
|
|
68
|
+
await server.connect(transport);
|
|
69
|
+
console.error(chalk.green("✓ SuperFlag MCP Server running on stdio"));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,yBAAyB;AACzB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,2CAA2C;AAC3C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;IACzE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CA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