mindforge-cc 2.0.0-alpha.9 → 2.0.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.
Files changed (61) hide show
  1. package/.agent/CLAUDE.md +26 -0
  2. package/.agent/mindforge/execute-phase.md +23 -0
  3. package/.agent/mindforge/install-skill.md +20 -11
  4. package/.agent/mindforge/learn.md +142 -0
  5. package/.agent/mindforge/marketplace.md +120 -0
  6. package/.agent/mindforge/new-runtime.md +19 -0
  7. package/.agent/mindforge/remember.md +16 -4
  8. package/.claude/CLAUDE.md +26 -0
  9. package/.claude/commands/mindforge/execute-phase.md +23 -0
  10. package/.claude/commands/mindforge/learn.md +142 -0
  11. package/.claude/commands/mindforge/marketplace.md +120 -0
  12. package/.claude/commands/mindforge/new-runtime.md +19 -0
  13. package/.mindforge/distribution/marketplace.md +53 -0
  14. package/.mindforge/org/skills/MANIFEST.md +1 -0
  15. package/.mindforge/production/production-checklist.md +34 -123
  16. package/.mindforge/skills-builder/auto-capture-protocol.md +88 -0
  17. package/.mindforge/skills-builder/learn-protocol.md +161 -0
  18. package/.mindforge/skills-builder/quality-scoring.md +120 -0
  19. package/.planning/AUDIT.jsonl +1 -0
  20. package/.planning/decisions/ADR-036-learn-command-docs-as-skill-source.md +26 -0
  21. package/.planning/decisions/ADR-037-auto-capture-frequency-threshold.md +26 -0
  22. package/.planning/decisions/ADR-038-skill-quality-minimum-60.md +27 -0
  23. package/CHANGELOG.md +52 -0
  24. package/MINDFORGE.md +9 -0
  25. package/README.md +42 -5
  26. package/bin/autonomous/auto-runner.js +12 -0
  27. package/bin/install.js +8 -2
  28. package/bin/installer-core.js +130 -26
  29. package/bin/migrations/1.0.0-to-2.0.0.js +115 -0
  30. package/bin/migrations/schema-versions.js +12 -0
  31. package/bin/mindforge-cli.js +35 -0
  32. package/bin/review/cross-review-engine.js +11 -0
  33. package/bin/skill-registry.js +167 -0
  34. package/bin/skill-validator.js +144 -0
  35. package/bin/skills-builder/learn-cli.js +57 -0
  36. package/bin/skills-builder/marketplace-cli.js +54 -0
  37. package/bin/skills-builder/marketplace-client.js +198 -0
  38. package/bin/skills-builder/pattern-detector.js +144 -0
  39. package/bin/skills-builder/skill-generator.js +258 -0
  40. package/bin/skills-builder/skill-registrar.js +107 -0
  41. package/bin/skills-builder/skill-scorer.js +263 -0
  42. package/bin/skills-builder/source-loader.js +268 -0
  43. package/docs/architecture/README.md +6 -1
  44. package/docs/architecture/adr-039-multi-runtime-support.md +20 -0
  45. package/docs/architecture/adr-040-additive-schema-migration.md +21 -0
  46. package/docs/architecture/adr-041-stable-runtime-interface-contract.md +20 -0
  47. package/docs/architecture/decision-records-index.md +3 -0
  48. package/docs/commands-reference.md +3 -0
  49. package/docs/mindforge-md-reference.md +4 -0
  50. package/docs/skills-authoring-guide.md +29 -0
  51. package/docs/skills-publishing-guide.md +3 -2
  52. package/docs/testing-current-version.md +3 -3
  53. package/docs/upgrade.md +16 -2
  54. package/docs/user-guide.md +57 -8
  55. package/docs/usp-features.md +21 -6
  56. package/package.json +1 -1
  57. package/.mindforge/memory/decision-library.jsonl +0 -0
  58. package/.mindforge/memory/knowledge-base.jsonl +0 -7
  59. package/.mindforge/memory/pattern-library.jsonl +0 -1
  60. package/.mindforge/memory/team-preferences.jsonl +0 -4
  61. package/.planning/browser-daemon.log +0 -32
@@ -0,0 +1,120 @@
1
+ # MindForge v2 — Skill Quality Scoring
2
+
3
+ ## Purpose
4
+ Every SKILL.md gets a quality score from 0-100 before registration.
5
+ This score determines: whether it can be registered (≥ 60), whether it can
6
+ be published to the community marketplace (≥ 80), and how prominently it
7
+ is featured in search results.
8
+
9
+ ## Scoring dimensions (total: 100 points)
10
+
11
+ ### Dimension 1: Trigger Coverage (30 points)
12
+ Measures: How many unique, specific trigger keywords the skill has.
13
+ - 25-30 triggers: 30 points (full score)
14
+ - 20-24 triggers: 24 points
15
+ - 15-19 triggers: 18 points
16
+ - 10-14 triggers: 12 points
17
+ - 5-9 triggers: 6 points
18
+ - < 5 triggers: 0 points
19
+
20
+ Penalty: -2 points per generic trigger (words like "database", "api", "model"
21
+ that would fire for almost any project). Triggers must be technology-specific.
22
+
23
+ ### Dimension 2: Mandatory Actions Completeness (25 points)
24
+ Measures: Whether the skill has complete, actionable mandatory actions.
25
+ Check for these mandatory sections:
26
+ - [ ] At least 5 concrete "always do X" rules (5 pts)
27
+ - [ ] At least 3 concrete "never do Y" rules (5 pts)
28
+ - [ ] Security consideration section (5 pts)
29
+ - [ ] Performance consideration section (5 pts)
30
+ - [ ] Error handling guidance (5 pts)
31
+
32
+ ### Dimension 3: Code Examples (20 points)
33
+ Measures: Quality and completeness of code examples.
34
+ - 5+ complete, working code examples: 20 points
35
+ - 3-4 examples: 14 points
36
+ - 1-2 examples: 7 points
37
+ - No examples: 0 points
38
+
39
+ Bonus: +2 points if examples show both correct pattern AND anti-pattern side-by-side.
40
+
41
+ ### Dimension 4: Self-Check Checklist (15 points)
42
+ Measures: Does the skill include a checklist an agent can use to verify its work?
43
+ - 10+ checklist items: 15 points
44
+ - 7-9 items: 10 points
45
+ - 4-6 items: 7 points
46
+ - 1-3 items: 3 points
47
+ - No checklist: 0 points
48
+
49
+ ### Dimension 5: Injection Safety (10 points)
50
+ Measures: Does the skill pass all injection guard checks?
51
+ - No injection patterns detected: 10 points (full score)
52
+ - Any injection pattern detected: 0 points (FAIL — skill cannot be registered)
53
+
54
+ Injection patterns checked (same 8 as in skill-loader.md):
55
+ IGNORE ALL PREVIOUS INSTRUCTIONS, DISREGARD YOUR INSTRUCTIONS, etc.
56
+
57
+ ### Dimension 6: No Placeholders (10 points)
58
+ Measures: Absence of placeholder/template text that was never filled in.
59
+ - Zero placeholders: 10 points
60
+ - 1-2 placeholders: 5 points
61
+ - 3+ placeholders: 0 points
62
+
63
+ Placeholder patterns:
64
+ `[your description here]`, `TODO`, `FIXME`, `<description>`, `...fill in...`
65
+
66
+ ### Dimension 7: Version History (10 points)
67
+ Measures: Whether the skill has a changelog / version history.
68
+ - Has ## Version History section with at least v1.0.0 entry: 10 points
69
+ - Has frontmatter version but no history section: 5 points
70
+ - No version information: 0 points
71
+
72
+ Bonus: +2 points if skill has been updated more than once (shows maintenance).
73
+
74
+ ## Quality thresholds
75
+
76
+ | Score | Status | Allowed actions |
77
+ |---|---|---|
78
+ | 90-100 | Excellent | Register, publish, featured in marketplace |
79
+ | 80-89 | Good | Register, eligible to publish |
80
+ | 70-79 | Acceptable | Register, not eligible for marketplace |
81
+ | 60-69 | Minimum | Register with warning |
82
+ | < 60 | Insufficient | Cannot register — must improve first |
83
+
84
+ ## `session_quality_lift` metric
85
+ After a skill has been used in ≥ 5 sessions, compute:
86
+ ```
87
+ lift = avg(session_quality_score when skill active)
88
+ - avg(session_quality_score when skill not active)
89
+ ```
90
+ This is the most honest signal of skill value. A skill with quality_score=94
91
+ but session_quality_lift=-2 is a misleading skill (it sounds good but hurts results).
92
+
93
+ ## Scoring output format
94
+ ```json
95
+ {
96
+ "skill_name": "prisma-schema",
97
+ "version": "1.0.0",
98
+ "quality_score": 84,
99
+ "threshold_status": "good",
100
+ "can_register": true,
101
+ "can_publish": true,
102
+ "score_breakdown": {
103
+ "trigger_coverage": 27,
104
+ "mandatory_actions": 22,
105
+ "code_examples": 17,
106
+ "self_check": 12,
107
+ "injection_safe": 10,
108
+ "no_placeholders": 9,
109
+ "version_history": 8
110
+ },
111
+ "penalties_applied": [
112
+ { "dimension": "trigger_coverage", "reason": "1 generic trigger 'database'", "penalty": -2 }
113
+ ],
114
+ "improvement_suggestions": [
115
+ "Add 3 more trigger keywords to reach 25+ (currently 22)",
116
+ "Add performance considerations section (currently missing)",
117
+ "Add 3 more checklist items to reach 10+ (currently 7)"
118
+ ]
119
+ }
120
+ ```
@@ -0,0 +1 @@
1
+ {"timestamp":"2026-03-22T20:52:21.691Z","event":"skill_installed","skill_name":"security-owasp","skill_version":"1.2.0","tier":2,"source":"cli-system","validation_passed":true}
@@ -0,0 +1,26 @@
1
+ # ADR-036: Documentation is the authoritative source for skill content
2
+
3
+ **Status:** Accepted | **Date:** v2.0.0 | **Day:** 13
4
+
5
+ ## Context
6
+ Where should skill content come from — human-authored or AI-generated?
7
+
8
+ ## Decision
9
+ Skill content is AI-generated from authoritative documentation (official docs,
10
+ internal runbooks, npm READMEs, or session analysis). The AI reads the docs
11
+ and writes down what it learned, following the SKILL.md authoring template.
12
+
13
+ ## Rationale
14
+ Documentation is the authoritative, maintained, versioned source of truth for
15
+ any technology. Human-authored skills get stale and diverge from reality.
16
+ Documentation-sourced skills automatically reflect the current state of the
17
+ technology when regenerated.
18
+
19
+ The AI's role: transform documentation into the MindForge SKILL.md format
20
+ (structured rules, trigger keywords, code examples, checklist) — not to
21
+ invent patterns that don't exist in the documentation.
22
+
23
+ ## Consequences
24
+ Skills should be regenerated when documentation is updated (major versions).
25
+ The quality of skills depends on the quality of source documentation.
26
+ Internal documentation produces the most project-specific, valuable skills.
@@ -0,0 +1,26 @@
1
+ # ADR-037: Pattern frequency ≥ 2 tasks as the auto-capture threshold
2
+
3
+ **Status:** Accepted | **Date:** v2.0.0 | **Day:** 13
4
+
5
+ ## Context
6
+ What frequency of pattern appearance should trigger auto-capture?
7
+
8
+ ## Decision
9
+ Auto-capture triggers when a pattern appears in ≥ 2 tasks (default).
10
+ Exception: a pattern in 1 task can also qualify if difficulty = "high" AND
11
+ generality ≠ "low" (important patterns worth capturing even on first occurrence).
12
+
13
+ Configurable via AUTO_CAPTURE_MIN_PATTERN_COUNT in MINDFORGE.md.
14
+
15
+ ## Rationale
16
+ A single occurrence is high-noise — it could be a one-off approach or
17
+ something specific to that task's edge case. Two occurrences strongly
18
+ suggest a reusable pattern. The exception for "high difficulty + non-low
19
+ generality" catches important one-time discoveries (security patterns, tricky
20
+ library APIs) that are hard to rediscover and broadly applicable.
21
+
22
+ ## Consequences
23
+ Most phases will produce 0-3 capture candidates (not noisy).
24
+ High-activity phases with many similar tasks may produce more.
25
+ The user always approves before any skill is created — auto-capture is a
26
+ suggestion, never automatic skill creation.
@@ -0,0 +1,27 @@
1
+ # ADR-038: Minimum quality score of 60 for skill registration
2
+
3
+ **Status:** Accepted | **Date:** v2.0.0 | **Day:** 13
4
+
5
+ ## Context
6
+ What quality score should be required before a skill can be registered?
7
+
8
+ ## Decision
9
+ Minimum score of 60/100 for project/org registration.
10
+ Minimum score of 80/100 for community marketplace publication.
11
+ Injection check failure (dimension 5 = 0) = absolute block regardless of total score.
12
+
13
+ ## Rationale
14
+ 60 is the "minimum viable" threshold — a skill at 60 has enough triggers,
15
+ content, and examples to be useful, but is below the "good" tier (80).
16
+ The gap between 60 and 80 allows registration for internal use while protecting
17
+ the public marketplace from mediocre skills.
18
+
19
+ The injection check is absolute — a skill that contains "IGNORE ALL PREVIOUS
20
+ INSTRUCTIONS" must NEVER be registered regardless of its other quality dimensions.
21
+ Even a score of 95 with an injection pattern is blocked. This is the same
22
+ non-negotiable principle as Gate 3 (secret detection) in compliance-gates.md.
23
+
24
+ ## Consequences
25
+ The AI-generated learn pipeline is tuned to produce skills scoring ≥ 80.
26
+ Skills below 60 get improvement suggestions but cannot be registered.
27
+ Teams can lower this threshold via SKILL_QUALITY_MIN_SCORE in MINDFORGE.md.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.0] — The Autonomous Enterprise — 2026-03-24
4
+
5
+ 🚀 **MindForge v2.0.0 — The Autonomous Enterprise — Major Release**
6
+
7
+ This major release transforms MindForge from a Claude-centric framework into a universal AI agent operating system. With support for 6 major runtimes and a hardened autonomous execution engine, v2.0.0 is built for enterprise-scale AI orchestration.
8
+
9
+ ### Added
10
+ - **6-Runtime Multi-Platform Support**: Official support for Claude Code, Antigravity, Cursor, OpenCode, Gemini CLI, and GitHub Copilot.
11
+ - **Runtime Adapters**: Automatic content transformation for Gemini (model/filename mapping) and preambles for non-slash runtimes (Cursor/Copilot).
12
+ - **`/mindforge:new-runtime`**: Rapidly scaffold custom AI agent runtimes with correct directory structures and command visibility.
13
+ - **Unified Migration Engine (v2.0.0)**: Additive schema upgrades for `AUDIT.jsonl` (runtime/agent_id) and `token-usage.jsonl` (model_group).
14
+ - **Hardened Self-Building Skills**: Automated skill capture from documentation and phase outputs.
15
+ - **7-Dimension Quality Scorer**: Enhanced static analysis for skill authoring.
16
+ - **65-Point Production Checklist**: Exhaustive verification suite for enterprise readiness.
17
+
18
+ ### Changed
19
+ - **Directory Standard**: Antigravity local workflows moved to `.agents/workflows/` with mandatory YAML frontmatter.
20
+ - **Migration Strategy**: Transitioned to an idempotent, backup-first migration model with smart skipping.
21
+ - **Stable Interface Contract**: Hardened internal members (RUNTIMES, generateEntryContent) for extensibility.
22
+
23
+ ### Architecture Decisions
24
+ - **ADR-039**: Multi-Runtime Platform Support.
25
+ - **ADR-040**: Additive Schema Migration Strategy.
26
+ - **ADR-041**: Stable Runtime Interface Contract.
27
+
28
+ ---
29
+
30
+ ## [2.0.0-alpha.12] — Self-Building Skills Platform — 2026-03-24
31
+ ### Added
32
+ - **Self-Building Skills Platform**: Intelligent engine for automatically capturing skills from documentation, sessions, and npm packages.
33
+ - **`/mindforge:learn`**: High-level orchestration command for 7-step skill generation pipeline.
34
+ - **`/mindforge:marketplace`**: Seamless integration with npm registry for community skills discovery and installation.
35
+ - **7-Dimension Quality Scorer**: Static analysis tool ensuring high-quality, injection-safe skill authoring.
36
+ - **Auto-Capture Hook**: Automatic pattern detection from phase outputs (SUMMARY, ADR, HANDOFF).
37
+ - **CLI Commands**: `learn-skill` and `marketplace` added to `bin/mindforge-cli.js`.
38
+ - **ADR-036, ADR-037, ADR-038**: New architectural decisions for skill sourcing, capture thresholds, and quality gates.
39
+
40
+ ## [2.0.0-alpha.11] — Persistent Knowledge Graph — 2026-03-24
41
+ ### Added
42
+ - **Persistent Knowledge Graph**: Core engine for long-term memory across projects.
43
+ - **`remember` CLI**: New command for manual knowledge management and semantic search.
44
+ - **Automated Capture**: Hooks in `AutoRunner` and `CrossReviewEngine` to ingest insights automatically from phase completions and review reports.
45
+ - **Context Injection**: `installer-core.js` now auto-injects relevant historical context into `CLAUDE.md` during installation.
46
+ - **`test-memory` CLI**: New command for memory suite verification.
47
+
48
+ ## [2.0.0-alpha.10] — Skill Installation & Validation CLI — 2026-03-24
49
+ ### Added
50
+ - New CLI commands: `validate-skill`, `install-skill`, `register-skill`, `audit-skill`.
51
+ - Robust skill validation logic (Level 1 & 2) in `bin/skill-validator.js`.
52
+ - Automated manifest management and audit logging in `bin/skill-registry.js`.
53
+ - Integrated CLI commands into the `install-skill.md` agentic workflow for higher reliability.
54
+
3
55
  ## [2.0.0-alpha.9] — Verified Antigravity Compatibility — 2026-03-23
4
56
  ### Fixed
5
57
  - Fixed critical installer regression where `files` variable was undefined during command installation.
package/MINDFORGE.md CHANGED
@@ -97,3 +97,12 @@ PROJECT_FORBIDDEN_PATTERNS="""
97
97
  - No console.log in API services
98
98
  - No TODO comments in committed code
99
99
  """
100
+
101
+ ## Self-Building Skills
102
+ AUTO_CAPTURE_SKILLS=false
103
+ AUTO_CAPTURE_MIN_PATTERN_COUNT=2
104
+ AUTO_CAPTURE_MIN_CONFIDENCE=0.75
105
+ LEARN_MODEL=inherit
106
+ MARKETPLACE_REGISTRY=https://registry.mindforge.dev/v1
107
+ MARKETPLACE_DAILY_FETCH_LIMIT=50
108
+ SKILL_QUALITY_MIN_SCORE=60
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # MindForge — Enterprise Agentic Framework (v2.0.0-alpha.9)
1
+ # MindForge — Enterprise Agentic Framework (v2.0.0)
2
2
 
3
3
  MindForge turns Claude Code and Antigravity into production-grade engineering
4
4
  partners with governance, observability, and a disciplined workflow engine.
5
- Release published: v1.0.0 (GitHub Releases).
5
+ Release published: v2.0.0.
6
6
 
7
7
  ```bash
8
8
  npx mindforge-cc@latest
@@ -23,6 +23,7 @@ Decisions get forgotten. MindForge fixes that with:
23
23
  - **Browser Runtime** — headful/headless visual QA and sessions (v2)
24
24
  - **Multi-Model Intelligence** — dynamic routing, adversarial reviews, and deep research (v2)
25
25
  - **Persistent Knowledge Graph** — long-term memory across all engineering sessions (v2)
26
+ - **Self-Building Skills** — automatically capture knowledge from any source into reusable skills (v2)
26
27
  - **Quality gates** — compliance and security are non-bypassable
27
28
  - **Audit trail** — append-only history of every action
28
29
 
@@ -67,9 +68,34 @@ Optional: minimal project scaffolding
67
68
  npx mindforge-cc@latest --claude --local --minimal
68
69
  ```
69
70
 
70
- ### Both runtimes
71
+ ### Cursor
71
72
  ```bash
72
- npx mindforge-cc@latest --all --global
73
+ npx mindforge-cc@latest --cursor --local
74
+ ```
75
+
76
+ ### Gemini CLI
77
+ ```bash
78
+ npx mindforge-cc@latest --gemini --global
79
+ ```
80
+
81
+ ### GitHub Copilot
82
+ ```bash
83
+ npx mindforge-cc@latest --copilot --local
84
+ ```
85
+
86
+ ### OpenCode
87
+ ```bash
88
+ npx mindforge-cc@latest --opencode --global
89
+ ```
90
+
91
+ ### Specific Runtime (Universal)
92
+ ```bash
93
+ npx mindforge-cc@latest --runtime <name>
94
+ ```
95
+
96
+ ### Multiple runtimes
97
+ ```bash
98
+ npx mindforge-cc@latest --runtime claude,cursor --local
73
99
  ```
74
100
 
75
101
  ---
@@ -159,6 +185,17 @@ If issues are found, run:
159
185
  / mindforge:dashboard
160
186
  → Real-time web observability and governance at localhost:7339 (v2)
161
187
  → Live audit logs, metrics, activity, and team feed
188
+
189
+ / mindforge:learn
190
+ → Automatically capture skills from Docs, Sessions, or npm (v2)
191
+ → 7-dimension quality scoring and injection protection
192
+
193
+ / mindforge:marketplace
194
+ → Search, install, and publish community skills (v2)
195
+ → Verified installation via npm-based registry
196
+
197
+ / mindforge:new-runtime
198
+ → Scaffold custom runtime configurations for any AI agent (v2)
162
199
  ```
163
200
 
164
201
  ---
@@ -215,7 +252,7 @@ See `.mindforge/production/token-optimiser.md`.
215
252
 
216
253
  ---
217
254
 
218
- ## What ships in v2.0.0-alpha.9
255
+ ## What ships in v2.0.0-alpha.10
219
256
  - **Real-time Dashboard**: `/mindforge:dashboard` and web-based observability.
220
257
  - **Persistent Knowledge Graph**: `/mindforge:remember` and long-term memory engine.
221
258
  - **Multi-Model Intelligence Layer**: `/mindforge:cross-review`, `/mindforge:research`, and `/mindforge:costs`.
@@ -11,6 +11,7 @@ const stuckMonitor = require('./stuck-monitor');
11
11
  const steeringManager = require('./steer');
12
12
  const progressStream = require('./progress-stream');
13
13
  const headlessAdapter = require('./headless');
14
+ const KnowledgeCapture = require('../memory/knowledge-capture');
14
15
 
15
16
  class AutoRunner {
16
17
  constructor(options = {}) {
@@ -66,6 +67,17 @@ class AutoRunner {
66
67
  console.log('✅ Phase complete!');
67
68
  const report = progressStream.generateReport(this.auditPath, this.phase);
68
69
  fs.writeFileSync(path.join(process.cwd(), `.planning/phases/${this.phase}/AUTONOMOUS-REPORT.md`), report);
70
+
71
+ // Auto-capture knowledge from completed phase (ADRs, findings)
72
+ try {
73
+ const captured = KnowledgeCapture.captureFromPhaseCompletion(this.phase);
74
+ if (captured.length > 0) {
75
+ console.log(`🧠 Knowledge Graph: Captured ${captured.length} new insights from phase completion.`);
76
+ }
77
+ } catch (err) {
78
+ console.error('⚠️ Knowledge Capture failed:', err.message);
79
+ }
80
+
69
81
  this.writeAudit({ event: 'auto_mode_completed', timestamp: new Date().toISOString() });
70
82
  }
71
83
 
package/bin/install.js CHANGED
@@ -50,7 +50,8 @@ if (ARGS.includes('--help') || ARGS.includes('-h')) {
50
50
 
51
51
  // ── Determine execution mode ──────────────────────────────────────────────────
52
52
  const NON_INTERACTIVE_FLAGS = [
53
- '--claude', '--antigravity', '--all',
53
+ '--claude', '--antigravity', '--cursor', '--opencode', '--gemini', '--copilot',
54
+ '--all', '--runtime',
54
55
  '--global', '-g', '--local', '-l',
55
56
  '--uninstall', '--update', '--check',
56
57
  '--skip-wizard', '--dry-run', '--with-utils', '--minimal',
@@ -86,7 +87,12 @@ function printHelp() {
86
87
  RUNTIMES (pick one or use --all)
87
88
  --claude Claude Code (~/.claude or .claude/)
88
89
  --antigravity Antigravity (~/.gemini/antigravity or .agents/; .agent/ legacy)
89
- --all Both runtimes
90
+ --cursor Cursor (~/.cursor or .cursor/)
91
+ --opencode OpenCode (~/.opencode or .opencode/)
92
+ --gemini Gemini CLI (~/.gemini or .gemini/)
93
+ --copilot GitHub Copilot (~/.github/copilot or .github/)
94
+ --all All 6 runtimes
95
+ --runtime <name> Explicitly specify runtime by name
90
96
 
91
97
  SCOPE
92
98
  --global, -g Install to home directory (all projects)
@@ -7,25 +7,86 @@
7
7
  const fs = require('fs');
8
8
  const path = require('path');
9
9
  const os = require('os');
10
+ const SessionMemoryLoader = require('./memory/session-memory-loader');
10
11
 
11
12
  const VERSION = require('../package.json').version;
12
13
 
13
14
  // ── Runtime configurations ────────────────────────────────────────────────────
14
15
  const RUNTIMES = {
15
16
  claude: {
17
+ displayName: 'Claude Code',
16
18
  globalDir: path.join(os.homedir(), '.claude'),
17
19
  localDir: '.claude',
18
20
  commandsSubdir: 'commands/mindforge',
19
21
  entryFile: 'CLAUDE.md',
22
+ supportsSlash: true,
20
23
  },
21
24
  antigravity: {
25
+ displayName: 'Antigravity',
22
26
  globalDir: path.join(os.homedir(), '.gemini', 'antigravity'),
23
27
  localDir: '.agents',
24
28
  commandsSubdir: 'workflows',
25
29
  entryFile: 'CLAUDE.md',
30
+ supportsSlash: true,
31
+ },
32
+ cursor: {
33
+ displayName: 'Cursor',
34
+ globalDir: path.join(os.homedir(), '.cursor'),
35
+ localDir: '.cursor',
36
+ commandsSubdir: 'rules',
37
+ entryFile: '.cursorrules',
38
+ supportsSlash: false,
39
+ },
40
+ opencode: {
41
+ displayName: 'OpenCode',
42
+ globalDir: path.join(os.homedir(), '.opencode'),
43
+ localDir: '.opencode',
44
+ commandsSubdir: 'commands/mindforge',
45
+ entryFile: 'CLAUDE.md',
46
+ supportsSlash: true,
47
+ },
48
+ gemini: {
49
+ displayName: 'Gemini CLI',
50
+ globalDir: path.join(os.homedir(), '.gemini'),
51
+ localDir: '.gemini',
52
+ commandsSubdir: 'commands/mindforge',
53
+ entryFile: 'GEMINI.md',
54
+ supportsSlash: true,
55
+ },
56
+ copilot: {
57
+ displayName: 'GitHub Copilot',
58
+ globalDir: path.join(os.homedir(), '.github', 'copilot'),
59
+ localDir: '.github',
60
+ commandsSubdir: 'copilot-instructions/mindforge',
61
+ entryFile: 'copilot-instructions.md',
62
+ supportsSlash: false,
26
63
  },
27
64
  };
28
65
 
66
+ /**
67
+ * Generates runtime-specific entry file content.
68
+ * e.g. replacing "Claude" with "Gemini" in GEMINI.md
69
+ */
70
+ function generateEntryContent(runtime, sourceContent) {
71
+ if (runtime === 'gemini') {
72
+ return sourceContent
73
+ .replace(/claude-3-5-sonnet/gi, 'gemini-2.0-flash-exp')
74
+ .replace(/Claude Code/g, 'Gemini CLI')
75
+ .replace(/CLAUDE.md/g, 'GEMINI.md');
76
+ }
77
+
78
+ if (runtime === 'cursor' || runtime === 'copilot') {
79
+ // Add preamble for non-slash runtimes as per review feedback
80
+ const preamble = `<!--
81
+ MindForge Rule Set for ${RUNTIMES[runtime].displayName}
82
+ MindForge command reference: @[command name without .md]
83
+ -->\n\n`;
84
+ return preamble + sourceContent;
85
+ }
86
+
87
+ return sourceContent;
88
+ }
89
+
29
90
  // ── File system utilities ─────────────────────────────────────────────────────
30
91
  const fsu = {
31
92
  exists: p => fs.existsSync(p),
@@ -159,9 +220,10 @@ function safeCopyClaude(src, dst, options = {}) {
159
220
 
160
221
  // ── Install verification ──────────────────────────────────────────────────────
161
222
  function verifyInstall(baseDir, cmdsDir, runtime, scope) {
223
+ const cfg = RUNTIMES[runtime];
162
224
  const pfx = runtime === 'antigravity' ? 'mindforge:' : '';
163
225
  const required = [
164
- scope === 'local' ? path.join(process.cwd(), 'CLAUDE.md') : path.join(baseDir, 'CLAUDE.md'),
226
+ scope === 'local' ? path.join(process.cwd(), cfg.entryFile) : path.join(baseDir, cfg.entryFile),
165
227
  path.join(cmdsDir, `${pfx}help.md`),
166
228
  path.join(cmdsDir, `${pfx}init-project.md`),
167
229
  path.join(cmdsDir, `${pfx}health.md`),
@@ -200,32 +262,56 @@ async function install(runtime, scope, options = {}) {
200
262
 
201
263
  if (dryRun) {
202
264
  console.log('\n Would install:');
203
- console.log(` CLAUDE.md → ${path.join(baseDir, 'CLAUDE.md')}`);
265
+ console.log(` ${cfg.entryFile} → ${path.join(baseDir, cfg.entryFile)}`);
204
266
  console.log(` ${fsu.listFiles(src('.claude', 'commands', 'mindforge')).length} commands → ${cmdsDir}`);
205
267
  return;
206
268
  }
207
269
 
208
- // ── 1. Install CLAUDE.md (Root standardization for IDEs) ────────────────────
209
- const claudeSrc = runtime === 'claude'
210
- ? src('.claude', 'CLAUDE.md')
211
- : src('.agent', 'CLAUDE.md');
212
-
270
+ const claudeSrc = src('.claude', 'CLAUDE.md');
213
271
  if (fsu.exists(claudeSrc)) {
272
+ // ✨ PERSISTENT MEMORY: Load relevant context for this session
273
+ let content = fsu.read(claudeSrc);
274
+ if (scope === 'local') {
275
+ try {
276
+ const stack = SessionMemoryLoader.readTechStack();
277
+ const memory = SessionMemoryLoader.loadForSession({ techStack: stack });
278
+ if (memory.count > 0) {
279
+ const header = SessionMemoryLoader.generateSessionHeader(memory);
280
+ const injection = `\n\n## 🧠 Knowledge Context (Auto-loaded)\n${header}\n${memory.formatted}\n`;
281
+ content += injection;
282
+ }
283
+ } catch (err) {
284
+ console.error(' ⚠️ Memory injection failed:', err.message);
285
+ }
286
+ }
287
+
288
+ // ✨ RUNTIME ADAPTATION: Generate specific content for this runtime
289
+ const adaptedContent = generateEntryContent(runtime, content);
290
+
214
291
  // Keep legacy location based on runtime config
215
- safeCopyClaude(claudeSrc, path.join(baseDir, 'CLAUDE.md'), { force, verbose });
292
+ const tempEntry = path.join(os.tmpdir(), `${cfg.entryFile}-${Date.now()}.md`);
293
+ fsu.write(tempEntry, adaptedContent);
294
+
295
+ const targetPath = path.join(baseDir, cfg.entryFile);
296
+ safeCopyClaude(tempEntry, targetPath, { force, verbose });
216
297
 
217
298
  // ✨ STANDARD: Inject into project root and IDE-specific rules files
218
299
  if (scope === 'local' && !selfInstall) {
219
300
  const rootClaude = path.join(process.cwd(), 'CLAUDE.md');
220
- const rootCursor = path.join(process.cwd(), '.cursorrules');
221
- const rootWindsurf = path.join(process.cwd(), '.windsurfrules');
301
+ const rootEntry = path.join(process.cwd(), cfg.entryFile);
302
+
303
+ // Always provide CLAUDE.md as the base standard
304
+ safeCopyClaude(tempEntry, rootClaude, { force, verbose });
222
305
 
223
- safeCopyClaude(claudeSrc, rootClaude, { force, verbose });
224
- safeCopyClaude(claudeSrc, rootCursor, { force, verbose });
225
- safeCopyClaude(claudeSrc, rootWindsurf, { force, verbose });
226
- console.log('CLAUDE.md (Mirrored to project root & .cursorrules)');
306
+ // If the runtime entry file is different (e.g. .cursorrules, copilot-instructions.md), copy that too
307
+ if (cfg.entryFile !== 'CLAUDE.md') {
308
+ safeCopyClaude(tempEntry, rootEntry, { force, verbose });
309
+ console.log(`${cfg.entryFile} (Mirrored to project root)`);
310
+ } else {
311
+ console.log(' ✅ CLAUDE.md (Mirrored to project root)');
312
+ }
227
313
  } else {
228
- console.log('CLAUDE.md');
314
+ console.log(`${cfg.entryFile}`);
229
315
  }
230
316
  }
231
317
 
@@ -354,13 +440,13 @@ async function uninstall(runtime, scope, options = {}) {
354
440
  const cfg = RUNTIMES[runtime];
355
441
  const baseDir = resolveBaseDir(runtime, scope);
356
442
  const cmdsDir = norm(path.join(baseDir, cfg.commandsSubdir));
357
- const claudeMd = norm(path.join(baseDir, 'CLAUDE.md'));
443
+ const entryFile = norm(path.join(baseDir, cfg.entryFile));
358
444
 
359
445
  console.log(`\n Uninstalling MindForge (${runtime} / ${scope})...`);
360
446
  if (dryRun) {
361
447
  console.log(` Would remove: ${cmdsDir}`);
362
- if (fsu.exists(claudeMd) && fsu.read(claudeMd).includes('MindForge'))
363
- console.log(` Would remove: ${claudeMd}`);
448
+ if (fsu.exists(entryFile) && fsu.read(entryFile).includes('MindForge'))
449
+ console.log(` Would remove: ${entryFile}`);
364
450
  return;
365
451
  }
366
452
 
@@ -370,10 +456,10 @@ async function uninstall(runtime, scope, options = {}) {
370
456
  console.log(` ✅ Removed: ${cmdsDir}`);
371
457
  }
372
458
 
373
- // Remove CLAUDE.md only if it's a MindForge-generated file
374
- if (fsu.exists(claudeMd) && fsu.read(claudeMd).includes('MindForge')) {
375
- fs.unlinkSync(claudeMd);
376
- console.log(` ✅ Removed: ${claudeMd}`);
459
+ // Remove entry file only if it's a MindForge-generated file
460
+ if (fsu.exists(entryFile) && fsu.read(entryFile).includes('MindForge')) {
461
+ fs.unlinkSync(entryFile);
462
+ console.log(` ✅ Removed: ${entryFile}`);
377
463
  }
378
464
 
379
465
  // Preserve .planning/ and .mindforge/ — user data, not our files to delete
@@ -383,9 +469,27 @@ async function uninstall(runtime, scope, options = {}) {
383
469
 
384
470
  // ── Main run ──────────────────────────────────────────────────────────────────
385
471
  async function run(args) {
386
- const runtime = args.includes('--antigravity') ? 'antigravity'
387
- : args.includes('--all') ? 'all'
388
- : 'claude';
472
+ // Parse runtime from flags
473
+ let runtime = args.includes('--all') ? 'all' : null;
474
+
475
+ if (!runtime) {
476
+ // Check for explicit --runtime flag
477
+ const rtIdx = args.indexOf('--runtime');
478
+ if (rtIdx !== -1 && args[rtIdx + 1]) {
479
+ runtime = args[rtIdx + 1].toLowerCase();
480
+ } else {
481
+ // Check for boolean flags (e.g. --cursor, --gemini)
482
+ for (const key of Object.keys(RUNTIMES)) {
483
+ if (args.includes(`--${key}`)) {
484
+ runtime = key;
485
+ break;
486
+ }
487
+ }
488
+ }
489
+ }
490
+
491
+ // Default to claude if no runtime specified
492
+ if (!runtime) runtime = 'claude';
389
493
  const scope = args.includes('--global') || args.includes('-g') ? 'global' : 'local';
390
494
  const dryRun = args.includes('--dry-run');
391
495
  const force = args.includes('--force');
@@ -426,4 +530,4 @@ async function run(args) {
426
530
  }
427
531
  }
428
532
 
429
- module.exports = { run, install, uninstall };
533
+ module.exports = { run, install, uninstall, RUNTIMES, generateEntryContent };