@superclaude-org/superflag 3.1.1 → 3.1.4

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/SUPERFLAG.md ADDED
@@ -0,0 +1,80 @@
1
+ # SuperFlag
2
+ MCP Protocol: get_directives([flags])
3
+
4
+ ## Core Workflow
5
+ <core_workflow>
6
+ When flags detected in user input:
7
+ 1. Execute MCP tool: get_directives([detected_flags])
8
+ 2. Apply directives completely and in order
9
+ 3. Verify compliance at checkpoints
10
+
11
+ **Call flags generously** - unexpected directives may contain guidance that helps you in ways you didn't anticipate.
12
+ </core_workflow>
13
+
14
+ ## Parametric Flags
15
+ Some flags accept an optional number suffix. Strip the suffix before calling get_directives:
16
+ - `--team-5` → call `get_directives(["--team"])`, use 5 as the team size
17
+ - `--sub-3` → call `get_directives(["--sub"])`, use 3 as the sub-agent count
18
+ - `--team` / `--sub` (no number) → auto-determine count from task complexity
19
+
20
+ ## Available Flags
21
+
22
+ ### Analysis & Optimization
23
+ - **--analyze**: Multi-perspective evidence-based analysis requiring 3+ independent perspectives for root cause identification
24
+ - **--performance**: Measure-first performance optimization with baseline metrics and ROI calculation before changes
25
+ - **--refactor**: Safe atomic refactoring with continuous test verification and zero regression guarantee
26
+ - **--strict**: Zero-error transparent execution with honest reporting, no fabricated rules, verify-before-claim
27
+ - **--lean**: Minimal resource-efficient implementation preserving all capabilities while eliminating waste
28
+
29
+ ### Discovery & Documentation
30
+ - **--discover**: Research-first solution selection with 3+ alternatives and quantitative comparison before deciding
31
+ - **--explain**: Progressive domain-expert disclosure from architectural intent to implementation details
32
+ - **--save**: Document SuperFlag development for seamless continuation
33
+ - **--load**: Load and verify handoff context by cross-checking document state against git reality
34
+
35
+ ### Workflow Management
36
+ - **--team**: Multi-agent coordination with optional count (--team-N) — automatically selects Agent tool or TeamCreate based on task structure, role-specialized agents
37
+ - **--skill**: Context-aware skill invocation — analyzes task and invokes the most appropriate superpowers skill before any action
38
+ - **--todo**: Scope-locked task tracking with real-time progress and zero silent drops
39
+ - **--seq**: Dependency-ordered sequential execution with mandatory checkpoint verification between steps
40
+ - **--collab**: Evidence-anchored peer collaboration with quantitative validation, anti-sycophancy, and position accountability
41
+
42
+ ### Output Control
43
+ - **--concise**: Precise timeless professional content prioritizing accuracy over brevity
44
+ - **--git**: Anonymous atomic commits with ASCII-only WHY-focused messages, no push without request
45
+ - **--readonly**: Analysis-only mode with absolute no-modification guarantee across files and git
46
+
47
+ ### Execution Discipline
48
+ - **--integrity**: Verification-before-claim with evidence for every assertion
49
+ - **--evolve**: Monotonic forward improvement with regression prevention
50
+
51
+ ### Meta Control
52
+ - **--reset**: Clear session and force fresh directives
53
+ - **--auto**: Grant autonomous flag selection authority
54
+
55
+ ## Flag Selection Strategy
56
+ <flag_selection_strategy>
57
+ When --auto is used:
58
+ 1. Analyze user intent and task requirements
59
+ 2. Select complementary flags that work together
60
+ 3. Avoid conflicting flags (e.g., --readonly with --git)
61
+ 4. Prioritize based on task type:
62
+ - Bugs: --analyze, --strict, --todo
63
+ - Performance: --performance, --lean
64
+ - Features: --discover, --skill, --todo
65
+ - Documentation: --explain, --save, --concise
66
+ - Multi-agent work: --team or --team-N (auto-selects Agent tool vs TeamCreate)
67
+ - Skill-driven work: --skill (auto-selects the right superpowers skill)
68
+ </flag_selection_strategy>
69
+
70
+ ## Examples
71
+ ```
72
+ "Fix this bug --analyze --strict"
73
+ "Optimize the code --performance --lean"
74
+ "Refactor safely --refactor --git"
75
+ "Research alternatives --discover --todo"
76
+ "Track complex task --todo --seq"
77
+ "Run with 3 agents --team-3"
78
+ "Auto-select best skill --skill"
79
+ "Autonomous mode --auto"
80
+ ```
package/dist/install.js CHANGED
@@ -238,6 +238,9 @@ async function installInteractive(platformNames) {
238
238
  detail: settingsResult ? "Hook registered" : "Already registered"
239
239
  });
240
240
  }
241
+ // Register MCP server for all platforms
242
+ const mcpResult = await registerMcpServer(platform);
243
+ tasks.push(mcpResult);
241
244
  }
242
245
  // Display results
243
246
  displayResults(tasks);
@@ -276,12 +279,11 @@ async function uninstallInteractive(platformNames) {
276
279
  detail: settingsResult ? "Hook unregistered" : "Not found"
277
280
  });
278
281
  }
282
+ // Unregister MCP server for all platforms
283
+ const mcpResult = await unregisterMcpServer(platform);
284
+ tasks.push(mcpResult);
279
285
  }
280
286
  displayResults(tasks);
281
- if (platformNames.includes("Claude Code")) {
282
- console.log(chalk.yellow("\n⚠ Note: Remove MCP server manually with:"));
283
- console.log(chalk.gray(" claude mcp remove superflag"));
284
- }
285
287
  }
286
288
  async function install(targetArg) {
287
289
  console.log(chalk.cyan.bold("\n============================================================"));
@@ -325,6 +327,9 @@ async function install(targetArg) {
325
327
  detail: settingsResult ? "Hook registered" : "Already registered"
326
328
  });
327
329
  }
330
+ // Register MCP server for all platforms
331
+ const mcpResult = await registerMcpServer(platform);
332
+ tasks.push(mcpResult);
328
333
  }
329
334
  // Display results
330
335
  displayResults(tasks);
@@ -367,10 +372,15 @@ async function uninstall(targetArg) {
367
372
  detail: settingsResult ? "Hook unregistered" : "Not found"
368
373
  });
369
374
  }
375
+ // Unregister MCP server for all platforms
376
+ const mcpResult = await unregisterMcpServer(platform);
377
+ tasks.push(mcpResult);
370
378
  }
371
379
  displayResults(tasks);
372
- if (targetArg === "all" || targetArg === "claude-code") {
373
- console.log(chalk.yellow("\n⚠ Note: Remove MCP server manually with:"));
380
+ // Check if Claude Code was in the uninstall and show manual MCP removal note
381
+ const claudeCodeIncluded = platforms.some(p => p.name === "Claude Code");
382
+ if (claudeCodeIncluded) {
383
+ console.log(chalk.yellow("\n⚠ Note: Remove Claude Code MCP server manually with:"));
374
384
  console.log(chalk.gray(" claude mcp remove superflag"));
375
385
  }
376
386
  }
@@ -378,20 +388,20 @@ function showNextSteps(platformNames) {
378
388
  console.log(chalk.yellow("\n📝 Next Steps:"));
379
389
  if (platformNames.includes("Claude Code")) {
380
390
  console.log(chalk.white("\nFor Claude Code:"));
381
- console.log(chalk.cyan(" 1. Register MCP server:"));
382
- console.log(chalk.gray(` claude mcp add superflag npx @superclaude-org/superflag@latest -s user`));
383
- console.log(chalk.cyan(" 2. Restart Claude Code"));
391
+ console.log(chalk.cyan(" 1. Restart Claude Code"));
392
+ console.log(chalk.cyan(" 2. Verify connection: claude mcp list"));
384
393
  }
385
394
  if (platformNames.includes("Gemini CLI")) {
386
395
  console.log(chalk.white("\nFor Gemini CLI:"));
387
- console.log(chalk.cyan(" 1. Register MCP server in Gemini settings"));
388
- console.log(chalk.cyan(" 2. Restart Gemini CLI"));
396
+ console.log(chalk.cyan(" 1. Restart Gemini CLI"));
397
+ console.log(chalk.cyan(" 2. MCP server already configured"));
389
398
  }
390
399
  if (platformNames.includes("Continue")) {
391
400
  console.log(chalk.white("\nFor Continue:"));
392
- console.log(chalk.cyan(" 1. Restart Continue extension"));
401
+ console.log(chalk.cyan(" 1. Restart VS Code with Continue extension"));
402
+ console.log(chalk.cyan(" 2. MCP server already configured"));
393
403
  }
394
- console.log(chalk.green("\n3. Test with: \"Analyze this code --analyze --strict\""));
404
+ console.log(chalk.green("\n✅ Test with: \"Analyze this code --analyze --strict\""));
395
405
  }
396
406
  function showUsage() {
397
407
  console.log("\nUsage:");
@@ -760,111 +770,298 @@ function getDefaultFlagsYaml() {
760
770
  }
761
771
  }
762
772
  function getSuperflagMdContent() {
763
- return `# SuperFlag
764
- MCP Protocol: get_directives([flags])
765
-
766
- ## Core Workflow
767
- <core_workflow>
768
- When flags detected in user input:
769
- 1. Execute MCP tool: get_directives([detected_flags])
770
- 2. Apply directives completely and in order
771
- 3. Verify compliance at checkpoints
772
- </core_workflow>
773
-
774
- ## Available Flags
775
-
776
- ### Analysis & Optimization
777
- - **--analyze**: Multi-perspective root cause analysis
778
- - **--performance**: Measure and optimize bottlenecks
779
- - **--refactor**: Safe code structure improvements
780
- - **--strict**: Zero-error execution with transparency
781
- - **--lean**: Eliminate waste with minimal implementation
782
-
783
- ### Discovery & Documentation
784
- - **--discover**: Research existing solutions first
785
- - **--explain**: Progressive disclosure from overview to details
786
- - **--save**: Create handoff documents for continuity
787
- - **--load**: Restore context from handoff documents
788
-
789
- ### Workflow Management
790
- - **--parallel**: Execute independent tasks simultaneously
791
- - **--todo**: Track progress with structured task management
792
- - **--seq**: Sequential step-by-step problem solving
793
- - **--collab**: Co-develop with quantitative validation
794
-
795
- ### Output Control
796
- - **--concise**: Professional, culturally neutral content
797
- - **--git**: Anonymous, ASCII-only commit messages
798
- - **--readonly**: Analysis without file modifications
799
-
800
- ### Meta Control
801
- - **--reset**: Clear session and force fresh directives
802
- - **--auto**: Grant autonomous flag selection authority
803
-
804
- ## Flag Selection Strategy
805
- <flag_selection_strategy>
806
- When --auto is used:
807
- 1. Analyze user intent and task requirements
808
- 2. Select complementary flags that work together
809
- 3. Avoid conflicting flags (e.g., --readonly with --git)
810
- 4. Prioritize based on task type:
811
- - Bugs: --analyze, --strict, --todo
812
- - Performance: --performance, --lean
813
- - Features: --discover, --parallel, --todo
814
- - Documentation: --explain, --save, --concise
815
- </flag_selection_strategy>
816
-
817
- ## Examples
818
- \`\`\`
819
- "Fix this bug --analyze --strict"
820
- "Optimize the code --performance --lean"
821
- "Refactor safely --refactor --git"
822
- "Research alternatives --discover --parallel"
823
- "Track complex task --todo --seq"
824
- \`\`\`
825
- `;
773
+ // Read SUPERFLAG.md from the package root
774
+ const superflagPath = path.join(__dirname, "..", "SUPERFLAG.md");
775
+ try {
776
+ return fsSync.readFileSync(superflagPath, "utf-8");
777
+ }
778
+ catch {
779
+ throw new Error(`SUPERFLAG.md not found at ${superflagPath}`);
780
+ }
826
781
  }
827
782
  function getPythonHookContent() {
828
- return `#!/usr/bin/env python3
829
- """SuperFlag Claude Code Hook - TypeScript Edition Bridge"""
830
-
831
- import sys
832
- import json
833
- import re
834
-
835
- def main():
836
- try:
837
- user_input = sys.stdin.read()
838
-
839
- # Detect flags in user input
840
- flags = re.findall(r'--\\w+', user_input)
841
-
842
- if flags:
843
- # Output hook message for Claude Code
844
- message = {
845
- "type": "system",
846
- "message": f"Flags detected: {', '.join(flags)}\\n" +
847
- "Execute: get_directives(" + str(flags) + ") for systematic implementation."
848
- }
849
- print(json.dumps(message))
850
- return 0
851
-
852
- except Exception:
853
- pass
854
-
855
- return 1
856
-
857
- if __name__ == "__main__":
858
- sys.exit(main())
783
+ return `#!/usr/bin/env python3
784
+ """SuperFlag Claude Code Hook - TypeScript Edition Bridge"""
785
+
786
+ import sys
787
+ import json
788
+ import re
789
+
790
+ def main():
791
+ try:
792
+ user_input = sys.stdin.read()
793
+
794
+ # Detect flags in user input
795
+ flags = re.findall(r'--\\w+', user_input)
796
+
797
+ if flags:
798
+ # Output hook message for Claude Code
799
+ message = {
800
+ "type": "system",
801
+ "message": f"Flags detected: {', '.join(flags)}\\n" +
802
+ "Execute: get_directives(" + str(flags) + ") for systematic implementation."
803
+ }
804
+ print(json.dumps(message))
805
+ return 0
806
+
807
+ except Exception:
808
+ pass
809
+
810
+ return 1
811
+
812
+ if __name__ == "__main__":
813
+ sys.exit(main())
859
814
  `;
860
815
  }
861
- // Main execution
816
+ // =====================================================
817
+ // MCP Auto-Registration Functions
818
+ // =====================================================
819
+ async function registerMcpServer(platform) {
820
+ try {
821
+ switch (platform.name) {
822
+ case "Claude Code":
823
+ return await registerClaudeCodeMcp();
824
+ case "Gemini CLI":
825
+ return await registerGeminiMcp();
826
+ case "Continue":
827
+ return await registerContinueMcp();
828
+ default:
829
+ return {
830
+ name: `${platform.name} MCP`,
831
+ status: "SKIP",
832
+ detail: "Not supported"
833
+ };
834
+ }
835
+ }
836
+ catch (error) {
837
+ return {
838
+ name: `${platform.name} MCP`,
839
+ status: "FAIL",
840
+ detail: error instanceof Error ? error.message : "Unknown error"
841
+ };
842
+ }
843
+ }
844
+ async function unregisterMcpServer(platform) {
845
+ try {
846
+ switch (platform.name) {
847
+ case "Claude Code":
848
+ return await unregisterClaudeCodeMcp();
849
+ case "Gemini CLI":
850
+ return await unregisterGeminiMcp();
851
+ case "Continue":
852
+ return await unregisterContinueMcp();
853
+ default:
854
+ return {
855
+ name: `${platform.name} MCP`,
856
+ status: "SKIP",
857
+ detail: "Not supported"
858
+ };
859
+ }
860
+ }
861
+ catch (error) {
862
+ return {
863
+ name: `${platform.name} MCP`,
864
+ status: "FAIL",
865
+ detail: error instanceof Error ? error.message : "Unknown error"
866
+ };
867
+ }
868
+ }
869
+ // Claude Code MCP Registration
870
+ async function registerClaudeCodeMcp() {
871
+ const configPath = path.join(os.homedir(), ".claude.json");
872
+ try {
873
+ let config = {};
874
+ // Read existing config
875
+ try {
876
+ const content = await fs.readFile(configPath, "utf-8");
877
+ config = JSON.parse(content);
878
+ }
879
+ catch {
880
+ // File doesn't exist, create new config
881
+ config = {};
882
+ }
883
+ // Ensure mcpServers section exists
884
+ if (!config.mcpServers) {
885
+ config.mcpServers = {};
886
+ }
887
+ // Add SuperFlag MCP server
888
+ config.mcpServers.superflag = {
889
+ type: "stdio",
890
+ command: "npx",
891
+ args: ["@superclaude-org/superflag@latest"],
892
+ env: {}
893
+ };
894
+ // Write back to file
895
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
896
+ return {
897
+ name: "Claude Code MCP",
898
+ status: "OK",
899
+ detail: "Registered"
900
+ };
901
+ }
902
+ catch (error) {
903
+ return {
904
+ name: "Claude Code MCP",
905
+ status: "FAIL",
906
+ detail: error instanceof Error ? error.message : "Unknown error"
907
+ };
908
+ }
909
+ }
910
+ async function unregisterClaudeCodeMcp() {
911
+ const configPath = path.join(os.homedir(), ".claude.json");
912
+ try {
913
+ const content = await fs.readFile(configPath, "utf-8");
914
+ const config = JSON.parse(content);
915
+ if (config.mcpServers && config.mcpServers.superflag) {
916
+ delete config.mcpServers.superflag;
917
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
918
+ return {
919
+ name: "Claude Code MCP",
920
+ status: "OK",
921
+ detail: "Unregistered"
922
+ };
923
+ }
924
+ return {
925
+ name: "Claude Code MCP",
926
+ status: "SKIP",
927
+ detail: "Not found"
928
+ };
929
+ }
930
+ catch {
931
+ return {
932
+ name: "Claude Code MCP",
933
+ status: "SKIP",
934
+ detail: "Config not found"
935
+ };
936
+ }
937
+ }
938
+ // Gemini CLI MCP Registration
939
+ async function registerGeminiMcp() {
940
+ const configPath = path.join(os.homedir(), ".gemini", "settings.json");
941
+ try {
942
+ // Ensure directory exists
943
+ await fs.mkdir(path.dirname(configPath), { recursive: true });
944
+ let config = {};
945
+ // Read existing config
946
+ try {
947
+ const content = await fs.readFile(configPath, "utf-8");
948
+ config = JSON.parse(content);
949
+ }
950
+ catch {
951
+ // File doesn't exist, create new config
952
+ config = {};
953
+ }
954
+ // Ensure mcpServers section exists
955
+ if (!config.mcpServers) {
956
+ config.mcpServers = {};
957
+ }
958
+ // Add SuperFlag MCP server
959
+ config.mcpServers.superflag = {
960
+ type: "stdio",
961
+ command: "npx",
962
+ args: ["@superclaude-org/superflag@latest"],
963
+ env: {}
964
+ };
965
+ // Write back to file
966
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
967
+ return {
968
+ name: "Gemini CLI MCP",
969
+ status: "OK",
970
+ detail: "Registered"
971
+ };
972
+ }
973
+ catch (error) {
974
+ return {
975
+ name: "Gemini CLI MCP",
976
+ status: "FAIL",
977
+ detail: error instanceof Error ? error.message : "Unknown error"
978
+ };
979
+ }
980
+ }
981
+ async function unregisterGeminiMcp() {
982
+ const configPath = path.join(os.homedir(), ".gemini", "settings.json");
983
+ try {
984
+ const content = await fs.readFile(configPath, "utf-8");
985
+ const config = JSON.parse(content);
986
+ if (config.mcpServers && config.mcpServers.superflag) {
987
+ delete config.mcpServers.superflag;
988
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
989
+ return {
990
+ name: "Gemini CLI MCP",
991
+ status: "OK",
992
+ detail: "Unregistered"
993
+ };
994
+ }
995
+ return {
996
+ name: "Gemini CLI MCP",
997
+ status: "SKIP",
998
+ detail: "Not found"
999
+ };
1000
+ }
1001
+ catch {
1002
+ return {
1003
+ name: "Gemini CLI MCP",
1004
+ status: "SKIP",
1005
+ detail: "Config not found"
1006
+ };
1007
+ }
1008
+ }
1009
+ // Continue MCP Registration
1010
+ async function registerContinueMcp() {
1011
+ const mcpDir = path.join(os.homedir(), ".continue", "mcpServers");
1012
+ const configPath = path.join(mcpDir, "superflag.yaml");
1013
+ try {
1014
+ // Ensure directory exists
1015
+ await fs.mkdir(mcpDir, { recursive: true });
1016
+ const mcpConfig = {
1017
+ name: "SuperFlag",
1018
+ command: "npx",
1019
+ args: ["@superclaude-org/superflag@latest"],
1020
+ env: {}
1021
+ };
1022
+ // Write MCP server config
1023
+ await fs.writeFile(configPath, yaml.dump(mcpConfig));
1024
+ return {
1025
+ name: "Continue MCP",
1026
+ status: "OK",
1027
+ detail: "Registered"
1028
+ };
1029
+ }
1030
+ catch (error) {
1031
+ return {
1032
+ name: "Continue MCP",
1033
+ status: "FAIL",
1034
+ detail: error instanceof Error ? error.message : "Unknown error"
1035
+ };
1036
+ }
1037
+ }
1038
+ async function unregisterContinueMcp() {
1039
+ const configPath = path.join(os.homedir(), ".continue", "mcpServers", "superflag.yaml");
1040
+ try {
1041
+ await fs.unlink(configPath);
1042
+ return {
1043
+ name: "Continue MCP",
1044
+ status: "OK",
1045
+ detail: "Unregistered"
1046
+ };
1047
+ }
1048
+ catch {
1049
+ return {
1050
+ name: "Continue MCP",
1051
+ status: "SKIP",
1052
+ detail: "Not found"
1053
+ };
1054
+ }
1055
+ }
1056
+ // Main execution (only for direct execution)
862
1057
  async function main() {
863
1058
  const args = process.argv.slice(2);
864
1059
  const command = args[0];
865
1060
  const commandArgs = args.slice(1);
866
1061
  await handleCommand(command || "", commandArgs);
867
1062
  }
868
- // Run if this is the main module
869
- main().catch(console.error);
1063
+ // Run only if this is the main module (not imported)
1064
+ if (import.meta.url === `file://${process.argv[1]}`) {
1065
+ main().catch(console.error);
1066
+ }
870
1067
  //# sourceMappingURL=install.js.map