moflo 4.8.23 → 4.8.25

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.
Files changed (87) hide show
  1. package/.claude/agents/flow-nexus/app-store.md +88 -0
  2. package/.claude/agents/flow-nexus/authentication.md +69 -0
  3. package/.claude/agents/flow-nexus/challenges.md +81 -0
  4. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  5. package/.claude/agents/flow-nexus/payments.md +83 -0
  6. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  7. package/.claude/agents/flow-nexus/swarm.md +76 -0
  8. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  9. package/.claude/agents/flow-nexus/workflow.md +84 -0
  10. package/.claude/agents/payments/agentic-payments.md +126 -0
  11. package/.claude/agents/sona/sona-learning-optimizer.md +74 -0
  12. package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
  13. package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
  14. package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
  15. package/.claude/agents/sublinear/performance-optimizer.md +368 -0
  16. package/.claude/agents/sublinear/trading-predictor.md +246 -0
  17. package/.claude/agents/v3/adr-architect.md +184 -0
  18. package/.claude/agents/v3/aidefence-guardian.md +282 -0
  19. package/.claude/agents/v3/claims-authorizer.md +208 -0
  20. package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -0
  21. package/.claude/agents/v3/ddd-domain-expert.md +220 -0
  22. package/.claude/agents/v3/injection-analyst.md +236 -0
  23. package/.claude/agents/v3/memory-specialist.md +995 -0
  24. package/.claude/agents/v3/performance-engineer.md +1233 -0
  25. package/.claude/agents/v3/pii-detector.md +151 -0
  26. package/.claude/agents/v3/reasoningbank-learner.md +213 -0
  27. package/.claude/agents/v3/security-architect-aidefence.md +410 -0
  28. package/.claude/agents/v3/security-architect.md +867 -0
  29. package/.claude/agents/v3/security-auditor.md +771 -0
  30. package/.claude/agents/v3/sparc-orchestrator.md +182 -0
  31. package/.claude/agents/v3/swarm-memory-manager.md +157 -0
  32. package/.claude/agents/v3/v3-integration-architect.md +205 -0
  33. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  34. package/.claude/commands/analysis/README.md +9 -0
  35. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  36. package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
  37. package/.claude/commands/analysis/performance-report.md +25 -0
  38. package/.claude/commands/analysis/token-efficiency.md +45 -0
  39. package/.claude/commands/analysis/token-usage.md +25 -0
  40. package/.claude/commands/automation/README.md +9 -0
  41. package/.claude/commands/automation/auto-agent.md +122 -0
  42. package/.claude/commands/automation/self-healing.md +106 -0
  43. package/.claude/commands/automation/session-memory.md +90 -0
  44. package/.claude/commands/automation/smart-agents.md +73 -0
  45. package/.claude/commands/automation/smart-spawn.md +25 -0
  46. package/.claude/commands/automation/workflow-select.md +25 -0
  47. package/.claude/commands/monitoring/README.md +9 -0
  48. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  49. package/.claude/commands/monitoring/agents.md +44 -0
  50. package/.claude/commands/monitoring/real-time-view.md +25 -0
  51. package/.claude/commands/monitoring/status.md +46 -0
  52. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  53. package/.claude/commands/optimization/README.md +9 -0
  54. package/.claude/commands/optimization/auto-topology.md +62 -0
  55. package/.claude/commands/optimization/cache-manage.md +25 -0
  56. package/.claude/commands/optimization/parallel-execute.md +25 -0
  57. package/.claude/commands/optimization/parallel-execution.md +50 -0
  58. package/.claude/commands/optimization/topology-optimize.md +25 -0
  59. package/.claude/guidance/shipped/agent-bootstrap.md +5 -0
  60. package/.claude/guidance/shipped/task-icons.md +42 -0
  61. package/.claude/helpers/gate-hook.mjs +50 -0
  62. package/.claude/helpers/gate.cjs +138 -0
  63. package/.claude/helpers/hook-handler.cjs +76 -0
  64. package/.claude/helpers/prompt-hook.mjs +72 -0
  65. package/.claude/scripts/build-embeddings.mjs +549 -0
  66. package/.claude/scripts/generate-code-map.mjs +776 -0
  67. package/.claude/scripts/hooks.mjs +656 -0
  68. package/.claude/scripts/index-guidance.mjs +893 -0
  69. package/.claude/scripts/index-tests.mjs +710 -0
  70. package/.claude/scripts/semantic-search.mjs +473 -0
  71. package/.claude/scripts/session-start-launcher.mjs +238 -0
  72. package/.claude/skills/pair-programming/SKILL.md +1202 -0
  73. package/.claude/skills/stream-chain/SKILL.md +563 -0
  74. package/.claude/skills/v3-cli-modernization/SKILL.md +872 -0
  75. package/.claude/skills/v3-core-implementation/SKILL.md +797 -0
  76. package/.claude/skills/v3-ddd-architecture/SKILL.md +442 -0
  77. package/.claude/skills/v3-integration-deep/SKILL.md +241 -0
  78. package/.claude/skills/v3-mcp-optimization/SKILL.md +777 -0
  79. package/.claude/skills/v3-memory-unification/SKILL.md +174 -0
  80. package/.claude/skills/v3-performance-optimization/SKILL.md +390 -0
  81. package/.claude/skills/v3-security-overhaul/SKILL.md +82 -0
  82. package/.claude/skills/v3-swarm-coordination/SKILL.md +340 -0
  83. package/bin/setup-project.mjs +3 -1
  84. package/package.json +1 -1
  85. package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +2 -0
  86. package/src/@claude-flow/cli/dist/src/init/moflo-init.js +60 -4
  87. package/src/@claude-flow/cli/package.json +1 -1
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+
6
+ var PROJECT_DIR = (process.env.CLAUDE_PROJECT_DIR || process.cwd()).replace(/^\/([a-z])\//i, '$1:/');
7
+ var STATE_FILE = path.join(PROJECT_DIR, '.claude', 'workflow-state.json');
8
+
9
+ function readState() {
10
+ try {
11
+ if (fs.existsSync(STATE_FILE)) return JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8'));
12
+ } catch (e) { /* reset on corruption */ }
13
+ return { tasksCreated: false, taskCount: 0, memorySearched: false, memoryRequired: true, interactionCount: 0, sessionStart: null, lastBlockedAt: null };
14
+ }
15
+
16
+ function writeState(s) {
17
+ try {
18
+ var dir = path.dirname(STATE_FILE);
19
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
20
+ fs.writeFileSync(STATE_FILE, JSON.stringify(s, null, 2));
21
+ } catch (e) { /* non-fatal */ }
22
+ }
23
+
24
+ // Load moflo.yaml gate config (defaults: all enabled)
25
+ function loadGateConfig() {
26
+ var defaults = { memory_first: true, task_create_first: true, context_tracking: true };
27
+ try {
28
+ var yamlPath = path.join(PROJECT_DIR, 'moflo.yaml');
29
+ if (fs.existsSync(yamlPath)) {
30
+ var content = fs.readFileSync(yamlPath, 'utf-8');
31
+ if (/memory_first:\s*false/i.test(content)) defaults.memory_first = false;
32
+ if (/task_create_first:\s*false/i.test(content)) defaults.task_create_first = false;
33
+ if (/context_tracking:\s*false/i.test(content)) defaults.context_tracking = false;
34
+ }
35
+ } catch (e) { /* use defaults */ }
36
+ return defaults;
37
+ }
38
+
39
+ var config = loadGateConfig();
40
+ var command = process.argv[2];
41
+
42
+ var EXEMPT = ['.claude/', '.claude\\', 'CLAUDE.md', 'MEMORY.md', 'workflow-state', 'node_modules'];
43
+ var DANGEROUS = ['rm -rf /', 'format c:', 'del /s /q c:\\', ':(){:|:&};:', 'mkfs.', '> /dev/sda'];
44
+ var DIRECTIVE_RE = /^(yes|no|yeah|yep|nope|sure|ok|okay|correct|right|exactly|perfect)\b/i;
45
+ var TASK_RE = /\b(fix|bug|error|implement|add|create|build|write|refactor|debug|test|feature|issue|security|optimi)\b/i;
46
+
47
+ switch (command) {
48
+ case 'check-before-agent': {
49
+ var s = readState();
50
+ // Hard gate: memory must be searched
51
+ if (config.memory_first && s.memoryRequired && !s.memorySearched) {
52
+ process.stderr.write('BLOCKED: Search memory (mcp__moflo__memory_search) before spawning agents.\n');
53
+ process.exit(2);
54
+ }
55
+ // Soft gate: TaskCreate recommended but not blocking
56
+ // (TaskCreate PostToolUse doesn't fire in Claude Code, so we can't track it reliably)
57
+ if (config.task_create_first && !s.tasksCreated) {
58
+ process.stdout.write('REMINDER: Use TaskCreate before spawning agents. Task tool is blocked until then.\n');
59
+ }
60
+ break;
61
+ }
62
+ case 'check-before-scan': {
63
+ if (!config.memory_first) break;
64
+ var s = readState();
65
+ if (s.memorySearched || !s.memoryRequired) break;
66
+ var target = (process.env.TOOL_INPUT_pattern || '') + ' ' + (process.env.TOOL_INPUT_path || '');
67
+ if (EXEMPT.some(function(p) { return target.indexOf(p) >= 0; })) break;
68
+ process.stderr.write('BLOCKED: Search memory before exploring files. Use mcp__moflo__memory_search.\n');
69
+ process.exit(2);
70
+ }
71
+ case 'check-before-read': {
72
+ if (!config.memory_first) break;
73
+ var s = readState();
74
+ if (s.memorySearched || !s.memoryRequired) break;
75
+ var fp = process.env.TOOL_INPUT_file_path || '';
76
+ if (fp.indexOf('.claude/guidance/') < 0 && fp.indexOf('.claude\\guidance\\') < 0) break;
77
+ process.stderr.write('BLOCKED: Search memory before reading guidance files. Use mcp__moflo__memory_search.\n');
78
+ process.exit(2);
79
+ }
80
+ case 'record-task-created': {
81
+ var s = readState();
82
+ s.tasksCreated = true;
83
+ s.taskCount = (s.taskCount || 0) + 1;
84
+ writeState(s);
85
+ break;
86
+ }
87
+ case 'record-memory-searched': {
88
+ var s = readState();
89
+ s.memorySearched = true;
90
+ writeState(s);
91
+ break;
92
+ }
93
+ case 'check-bash-memory': {
94
+ var cmd = process.env.TOOL_INPUT_command || '';
95
+ if (/semantic-search|memory search|memory retrieve|memory-search/.test(cmd)) {
96
+ var s = readState();
97
+ s.memorySearched = true;
98
+ writeState(s);
99
+ }
100
+ break;
101
+ }
102
+ case 'check-dangerous-command': {
103
+ var cmd = (process.env.TOOL_INPUT_command || '').toLowerCase();
104
+ for (var i = 0; i < DANGEROUS.length; i++) {
105
+ if (cmd.indexOf(DANGEROUS[i]) >= 0) {
106
+ console.log('[BLOCKED] Dangerous command: ' + DANGEROUS[i]);
107
+ process.exit(2);
108
+ }
109
+ }
110
+ break;
111
+ }
112
+ case 'prompt-reminder': {
113
+ var s = readState();
114
+ s.memorySearched = false;
115
+ var prompt = process.env.CLAUDE_USER_PROMPT || '';
116
+ s.memoryRequired = prompt.length >= 4 && !DIRECTIVE_RE.test(prompt) && (TASK_RE.test(prompt) || prompt.length > 80);
117
+ s.interactionCount = (s.interactionCount || 0) + 1;
118
+ writeState(s);
119
+ if (!s.tasksCreated) console.log('REMINDER: Use TaskCreate before spawning agents. Task tool is blocked until then.');
120
+ if (config.context_tracking) {
121
+ var ic = s.interactionCount;
122
+ if (ic > 30) console.log('Context: CRITICAL. Commit, store learnings, suggest new session.');
123
+ else if (ic > 20) console.log('Context: DEPLETED. Checkpoint progress. Recommend /compact or fresh session.');
124
+ else if (ic > 10) console.log('Context: MODERATE. Re-state goal before architectural decisions. Use agents for >300 LOC.');
125
+ }
126
+ break;
127
+ }
128
+ case 'compact-guidance': {
129
+ console.log('Pre-Compact: Check CLAUDE.md for rules. Use memory search to recover context after compact.');
130
+ break;
131
+ }
132
+ case 'session-reset': {
133
+ writeState({ tasksCreated: false, taskCount: 0, memorySearched: false, memoryRequired: true, interactionCount: 0, sessionStart: new Date().toISOString(), lastBlockedAt: null });
134
+ break;
135
+ }
136
+ default:
137
+ break;
138
+ }
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+
6
+ var PROJECT_DIR = process.env.CLAUDE_PROJECT_DIR || process.cwd();
7
+ var METRICS_FILE = path.join(PROJECT_DIR, '.claude-flow', 'metrics', 'learning.json');
8
+ var command = process.argv[2];
9
+
10
+ // Read stdin (Claude Code sends hook data as JSON)
11
+ function readStdin() {
12
+ if (process.stdin.isTTY) return Promise.resolve('');
13
+ return new Promise(function(resolve) {
14
+ var data = '';
15
+ var timer = setTimeout(function() {
16
+ process.stdin.removeAllListeners();
17
+ process.stdin.pause();
18
+ resolve(data);
19
+ }, 500);
20
+ process.stdin.setEncoding('utf8');
21
+ process.stdin.on('data', function(chunk) { data += chunk; });
22
+ process.stdin.on('end', function() { clearTimeout(timer); resolve(data); });
23
+ process.stdin.on('error', function() { clearTimeout(timer); resolve(data); });
24
+ process.stdin.resume();
25
+ });
26
+ }
27
+
28
+ function bumpMetric(key) {
29
+ try {
30
+ var metrics = {};
31
+ if (fs.existsSync(METRICS_FILE)) metrics = JSON.parse(fs.readFileSync(METRICS_FILE, 'utf-8'));
32
+ metrics[key] = (metrics[key] || 0) + 1;
33
+ metrics.lastUpdated = new Date().toISOString();
34
+ var dir = path.dirname(METRICS_FILE);
35
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
36
+ fs.writeFileSync(METRICS_FILE, JSON.stringify(metrics, null, 2));
37
+ } catch (e) { /* non-fatal */ }
38
+ }
39
+
40
+ readStdin().then(function(stdinData) {
41
+ var hookInput = {};
42
+ if (stdinData && stdinData.trim()) {
43
+ try { hookInput = JSON.parse(stdinData); } catch (e) { /* ignore */ }
44
+ }
45
+
46
+ switch (command) {
47
+ case 'route': {
48
+ var prompt = hookInput.prompt || hookInput.command || process.env.PROMPT || '';
49
+ if (prompt) console.log('[INFO] Routing: ' + prompt.substring(0, 80));
50
+ else console.log('[INFO] Ready');
51
+ break;
52
+ }
53
+ case 'pre-edit':
54
+ case 'post-edit':
55
+ bumpMetric('edits');
56
+ console.log('[OK] Edit recorded');
57
+ break;
58
+ case 'pre-task':
59
+ bumpMetric('tasks');
60
+ console.log('[OK] Task started');
61
+ break;
62
+ case 'post-task':
63
+ bumpMetric('tasksCompleted');
64
+ console.log('[OK] Task completed');
65
+ break;
66
+ case 'session-end':
67
+ console.log('[OK] Session ended');
68
+ break;
69
+ case 'notification':
70
+ // Silent — just acknowledge
71
+ break;
72
+ default:
73
+ if (command) console.log('[OK] Hook: ' + command);
74
+ break;
75
+ }
76
+ });
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from 'child_process';
3
+ import { resolve } from 'path';
4
+
5
+ // Read stdin JSON from Claude Code
6
+ var stdinData = '';
7
+ try {
8
+ stdinData = await new Promise(function(res) {
9
+ var data = '';
10
+ var timeout = setTimeout(function() { res(data); }, 500);
11
+ process.stdin.setEncoding('utf-8');
12
+ process.stdin.on('data', function(chunk) { data += chunk; });
13
+ process.stdin.on('end', function() { clearTimeout(timeout); res(data); });
14
+ process.stdin.on('error', function() { clearTimeout(timeout); res(''); });
15
+ if (process.stdin.isTTY) { clearTimeout(timeout); res(''); }
16
+ });
17
+ } catch (e) { /* no stdin */ }
18
+
19
+ var hookContext = {};
20
+ try { if (stdinData.trim()) hookContext = JSON.parse(stdinData); } catch (e) {}
21
+
22
+ var userPrompt = hookContext.user_prompt || hookContext.prompt || '';
23
+ var env = Object.assign({}, process.env, { CLAUDE_USER_PROMPT: userPrompt });
24
+
25
+ // Run prompt-reminder via gate.cjs
26
+ var projectDir = (env.CLAUDE_PROJECT_DIR || process.cwd()).replace(/^\/([a-z])\//i, '$1:/');
27
+ var gateScript = resolve(projectDir, '.claude/helpers/gate.cjs');
28
+ var output = '';
29
+ try {
30
+ output = execSync('node "' + gateScript + '" prompt-reminder', {
31
+ env: env, encoding: 'utf-8', timeout: 3000, stdio: ['pipe', 'pipe', 'pipe']
32
+ });
33
+ } catch (err) { output = (err && err.stdout) || ''; }
34
+
35
+ // Classify prompt for namespace hint
36
+ var lower = userPrompt.toLowerCase();
37
+
38
+ var KNOWLEDGE_ONLY = /\b(knowledge|remember|recall)\b|we (decid|agree|chose|said)/;
39
+ var EXPLICIT_NS = [
40
+ { pattern: /\b(pattern|convention|best practice|style|coding rule)\b/, ns: 'patterns', label: 'code patterns and conventions' },
41
+ { pattern: /\b(code.?map|file structure|project structure|directory)\b/, ns: 'code-map', label: 'codebase navigation' },
42
+ ];
43
+ var PATTERN_HINTS = [/\b(template|example|similar to|how do we|how should)\b/];
44
+ var DOMAIN_HINTS = [
45
+ /\b(guidance|guide|docs|documentation|rules|how-to)\b/,
46
+ /\b(architecture|design|domain|tenant|migrat|schema|deploy)/,
47
+ /\b(rule|requirement|constraint|compliance)\b/,
48
+ ];
49
+ var NAV_PATTERNS = [
50
+ /\b(find|where|which file|look up|locate|endpoint|route|url|path)\b/,
51
+ /\b(class|function|method|component|service|entity|module)\b/,
52
+ ];
53
+
54
+ var nsHint = '';
55
+ if (KNOWLEDGE_ONLY.test(lower)) {
56
+ nsHint = 'Memory namespace hint: use "knowledge" for user-directed project decisions.';
57
+ } else {
58
+ var found = EXPLICIT_NS.find(function(e) { return e.pattern.test(lower); });
59
+ if (found) {
60
+ nsHint = 'Memory namespace hint: use "' + found.ns + '" for ' + found.label + '.';
61
+ } else if (DOMAIN_HINTS.some(function(p) { return p.test(lower); })) {
62
+ nsHint = 'Memory namespace hint: search "guidance" and "knowledge" for domain rules and project decisions.';
63
+ } else if (PATTERN_HINTS.some(function(p) { return p.test(lower); })) {
64
+ nsHint = 'Memory namespace hint: use "patterns" for code patterns and conventions.';
65
+ } else if (NAV_PATTERNS.some(function(p) { return p.test(lower); })) {
66
+ nsHint = 'Memory namespace hint: use "code-map" for codebase navigation.';
67
+ }
68
+ }
69
+
70
+ var parts = [output.trim(), nsHint].filter(Boolean);
71
+ if (parts.length) process.stdout.write(parts.join('\n') + '\n');
72
+ process.exit(0);