create-universal-ai-context 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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +171 -0
  3. package/bin/create-ai-context.js +337 -0
  4. package/lib/adapters/antigravity.js +160 -0
  5. package/lib/adapters/claude.js +122 -0
  6. package/lib/adapters/cline.js +111 -0
  7. package/lib/adapters/copilot.js +117 -0
  8. package/lib/adapters/index.js +69 -0
  9. package/lib/ai-context-generator.js +234 -0
  10. package/lib/ai-orchestrator.js +431 -0
  11. package/lib/call-tracer.js +444 -0
  12. package/lib/detector.js +726 -0
  13. package/lib/environment-detector.js +239 -0
  14. package/lib/index.js +310 -0
  15. package/lib/installer.js +418 -0
  16. package/lib/migrate.js +319 -0
  17. package/lib/placeholder.js +541 -0
  18. package/lib/prompts.js +287 -0
  19. package/lib/spinner.js +60 -0
  20. package/lib/static-analyzer.js +729 -0
  21. package/lib/template-populator.js +843 -0
  22. package/lib/template-renderer.js +382 -0
  23. package/lib/validate.js +155 -0
  24. package/package.json +70 -0
  25. package/templates/AI_CONTEXT.md.template +245 -0
  26. package/templates/base/README.md +257 -0
  27. package/templates/base/RPI_WORKFLOW_PLAN.md +320 -0
  28. package/templates/base/agents/api-developer.md +76 -0
  29. package/templates/base/agents/context-engineer.md +525 -0
  30. package/templates/base/agents/core-architect.md +76 -0
  31. package/templates/base/agents/database-ops.md +76 -0
  32. package/templates/base/agents/deployment-ops.md +76 -0
  33. package/templates/base/agents/integration-hub.md +76 -0
  34. package/templates/base/analytics/README.md +114 -0
  35. package/templates/base/automation/config.json +58 -0
  36. package/templates/base/automation/generators/code-mapper.js +308 -0
  37. package/templates/base/automation/generators/index-builder.js +321 -0
  38. package/templates/base/automation/hooks/post-commit.sh +83 -0
  39. package/templates/base/automation/hooks/pre-commit.sh +103 -0
  40. package/templates/base/ci-templates/README.md +108 -0
  41. package/templates/base/ci-templates/github-actions/context-check.yml +144 -0
  42. package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -0
  43. package/templates/base/commands/analytics.md +238 -0
  44. package/templates/base/commands/auto-sync.md +172 -0
  45. package/templates/base/commands/collab.md +194 -0
  46. package/templates/base/commands/help.md +450 -0
  47. package/templates/base/commands/rpi-implement.md +115 -0
  48. package/templates/base/commands/rpi-plan.md +93 -0
  49. package/templates/base/commands/rpi-research.md +88 -0
  50. package/templates/base/commands/session-resume.md +144 -0
  51. package/templates/base/commands/session-save.md +112 -0
  52. package/templates/base/commands/validate-all.md +77 -0
  53. package/templates/base/commands/verify-docs-current.md +86 -0
  54. package/templates/base/config/base.json +57 -0
  55. package/templates/base/config/environments/development.json +13 -0
  56. package/templates/base/config/environments/production.json +17 -0
  57. package/templates/base/config/environments/staging.json +13 -0
  58. package/templates/base/config/local.json.example +21 -0
  59. package/templates/base/context/.meta/generated-at.json +18 -0
  60. package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -0
  61. package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -0
  62. package/templates/base/context/FILE_OWNERSHIP.md +57 -0
  63. package/templates/base/context/INTEGRATION_POINTS.md +92 -0
  64. package/templates/base/context/KNOWN_GOTCHAS.md +195 -0
  65. package/templates/base/context/TESTING_MAP.md +95 -0
  66. package/templates/base/context/WORKFLOW_INDEX.md +129 -0
  67. package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -0
  68. package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -0
  69. package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -0
  70. package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -0
  71. package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -0
  72. package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -0
  73. package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -0
  74. package/templates/base/knowledge/README.md +98 -0
  75. package/templates/base/knowledge/sessions/README.md +88 -0
  76. package/templates/base/knowledge/sessions/TEMPLATE.md +150 -0
  77. package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -0
  78. package/templates/base/knowledge/shared/decisions/README.md +49 -0
  79. package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -0
  80. package/templates/base/knowledge/shared/patterns/README.md +62 -0
  81. package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -0
  82. package/templates/base/plans/PLAN_TEMPLATE.md +250 -0
  83. package/templates/base/plans/active/.gitkeep +0 -0
  84. package/templates/base/plans/completed/.gitkeep +0 -0
  85. package/templates/base/research/RESEARCH_TEMPLATE.md +153 -0
  86. package/templates/base/research/active/.gitkeep +0 -0
  87. package/templates/base/research/completed/.gitkeep +0 -0
  88. package/templates/base/schemas/agent.schema.json +141 -0
  89. package/templates/base/schemas/anchors.schema.json +54 -0
  90. package/templates/base/schemas/automation.schema.json +93 -0
  91. package/templates/base/schemas/command.schema.json +134 -0
  92. package/templates/base/schemas/hashes.schema.json +40 -0
  93. package/templates/base/schemas/manifest.schema.json +117 -0
  94. package/templates/base/schemas/plan.schema.json +136 -0
  95. package/templates/base/schemas/research.schema.json +115 -0
  96. package/templates/base/schemas/roles.schema.json +34 -0
  97. package/templates/base/schemas/session.schema.json +77 -0
  98. package/templates/base/schemas/settings.schema.json +244 -0
  99. package/templates/base/schemas/staleness.schema.json +53 -0
  100. package/templates/base/schemas/team-config.schema.json +42 -0
  101. package/templates/base/schemas/workflow.schema.json +126 -0
  102. package/templates/base/session/checkpoints/.gitkeep +2 -0
  103. package/templates/base/session/current/state.json +20 -0
  104. package/templates/base/session/history/.gitkeep +2 -0
  105. package/templates/base/settings.json +3 -0
  106. package/templates/base/standards/COMPATIBILITY.md +219 -0
  107. package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -0
  108. package/templates/base/standards/QUALITY_CHECKLIST.md +211 -0
  109. package/templates/base/standards/README.md +66 -0
  110. package/templates/base/sync/anchors.json +6 -0
  111. package/templates/base/sync/hashes.json +6 -0
  112. package/templates/base/sync/staleness.json +10 -0
  113. package/templates/base/team/README.md +168 -0
  114. package/templates/base/team/config.json +79 -0
  115. package/templates/base/team/roles.json +145 -0
  116. package/templates/base/tools/bin/claude-context.js +151 -0
  117. package/templates/base/tools/lib/anchor-resolver.js +276 -0
  118. package/templates/base/tools/lib/config-loader.js +363 -0
  119. package/templates/base/tools/lib/detector.js +350 -0
  120. package/templates/base/tools/lib/diagnose.js +206 -0
  121. package/templates/base/tools/lib/drift-detector.js +373 -0
  122. package/templates/base/tools/lib/errors.js +199 -0
  123. package/templates/base/tools/lib/index.js +36 -0
  124. package/templates/base/tools/lib/init.js +192 -0
  125. package/templates/base/tools/lib/logger.js +230 -0
  126. package/templates/base/tools/lib/placeholder.js +201 -0
  127. package/templates/base/tools/lib/session-manager.js +354 -0
  128. package/templates/base/tools/lib/validate.js +521 -0
  129. package/templates/base/tools/package.json +49 -0
  130. package/templates/handlebars/antigravity.hbs +337 -0
  131. package/templates/handlebars/claude.hbs +184 -0
  132. package/templates/handlebars/cline.hbs +63 -0
  133. package/templates/handlebars/copilot.hbs +131 -0
  134. package/templates/handlebars/partials/gotcha-list.hbs +11 -0
  135. package/templates/handlebars/partials/header.hbs +3 -0
  136. package/templates/handlebars/partials/workflow-summary.hbs +16 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SireJeff
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,171 @@
1
+ # create-universal-ai-context
2
+
3
+ Universal AI context engineering for any codebase. Generates optimized context for **Claude Code**, **GitHub Copilot**, **Cline**, **Antigravity**, and more.
4
+
5
+ ![npm](https://img.shields.io/npm/v/create-universal-ai-context)
6
+ ![npm downloads](https://img.shields.io/npm/dm/create-universal-ai-context)
7
+
8
+ ## Quick Start
9
+
10
+ ```bash
11
+ npx create-universal-ai-context
12
+ ```
13
+
14
+ That's it. The CLI automatically:
15
+ 1. Detects your tech stack (Express, FastAPI, Next.js, Django, Rails, NestJS, etc.)
16
+ 2. Analyzes entry points and workflows
17
+ 3. Generates context files for all supported AI tools
18
+
19
+ ## AI Tools Supported
20
+
21
+ | Tool | Output | Description |
22
+ |------|--------|-------------|
23
+ | **Claude Code** | `AI_CONTEXT.md` + `.ai-context/` | Full context engineering system |
24
+ | **GitHub Copilot** | `.github/copilot-instructions.md` | Copilot workspace instructions |
25
+ | **Cline** | `.clinerules` | Cline rules file |
26
+ | **Antigravity** | `.agent/` | Identity, architecture, workflows, skills |
27
+
28
+ ## CLI Options
29
+
30
+ ```bash
31
+ # Basic usage
32
+ npx create-ai-context # Auto-detect and generate for all tools
33
+
34
+ # Select specific AI tools
35
+ npx create-ai-context --ai claude # Claude Code only
36
+ npx create-ai-context --ai copilot # GitHub Copilot only
37
+ npx create-ai-context --ai cline # Cline only
38
+ npx create-ai-context --ai antigravity # Antigravity only
39
+ npx create-ai-context --ai all # All tools (default)
40
+
41
+ # Analysis modes
42
+ npx create-ai-context --static # Force static analysis only
43
+ npx create-ai-context --force-ai # Require Claude Code session
44
+
45
+ # Other options
46
+ npx create-ai-context --yes # Accept all defaults
47
+ npx create-ai-context --dry-run # Preview without changes
48
+ npx create-ai-context my-project # Create in new directory
49
+ ```
50
+
51
+ ## Subcommands
52
+
53
+ ```bash
54
+ # Generate context for specific tools
55
+ npx create-ai-context generate --ai copilot
56
+
57
+ # Check installation status
58
+ npx create-ai-context status
59
+
60
+ # Migrate from v1.x
61
+ npx create-ai-context migrate
62
+ ```
63
+
64
+ ## What Gets Analyzed
65
+
66
+ | Analysis | Description |
67
+ |----------|-------------|
68
+ | **Entry Points** | API routes, CLI handlers, event listeners |
69
+ | **Workflows** | Business logic patterns (auth, payments, etc.) |
70
+ | **Architecture** | Directory structure, layers, dependencies |
71
+ | **Tech Stack** | Languages, frameworks, package managers |
72
+ | **LOC** | Lines of code with code/comments/blank breakdown |
73
+
74
+ ## Execution Modes
75
+
76
+ | Mode | Condition | Capabilities |
77
+ |------|-----------|--------------|
78
+ | **full-ai** | Claude Code + API key | AI-enhanced analysis |
79
+ | **hybrid** | Claude Code (no API) | Static + AI handoff |
80
+ | **standalone** | No Claude Code | Static analysis only |
81
+
82
+ ## Generated Structure
83
+
84
+ ```
85
+ your-project/
86
+ ├── AI_CONTEXT.md # Universal entry point
87
+ ├── .ai-context/ # Context engineering system
88
+ │ ├── agents/ # 6 specialized agents
89
+ │ ├── commands/ # 11 slash commands
90
+ │ ├── context/
91
+ │ │ ├── workflows/ # Auto-generated workflow docs
92
+ │ │ ├── ARCHITECTURE_SNAPSHOT.md
93
+ │ │ └── CODE_TO_WORKFLOW_MAP.md
94
+ │ └── indexes/ # Navigation hierarchy
95
+ ├── .github/
96
+ │ └── copilot-instructions.md # GitHub Copilot
97
+ ├── .clinerules # Cline
98
+ └── .agent/ # Antigravity
99
+ ├── rules/
100
+ ├── workflows/
101
+ └── skills/
102
+ ```
103
+
104
+ ## Tech Stack Presets
105
+
106
+ ```bash
107
+ npx create-ai-context -t python-fastapi
108
+ npx create-ai-context -t python-django
109
+ npx create-ai-context -t node-express
110
+ npx create-ai-context -t node-nestjs
111
+ npx create-ai-context -t typescript-nextjs
112
+ npx create-ai-context -t go-gin
113
+ npx create-ai-context -t rust-actix
114
+ npx create-ai-context -t ruby-rails
115
+ ```
116
+
117
+ ## Features
118
+
119
+ ### RPI Workflow
120
+ - `/rpi-research` - Systematic codebase exploration
121
+ - `/rpi-plan` - Implementation blueprints with file:line precision
122
+ - `/rpi-implement` - Atomic changes with continuous testing
123
+
124
+ ### Specialized Agents
125
+ - `@context-engineer` - Setup and maintenance
126
+ - `@core-architect` - System design
127
+ - `@database-ops` - Database operations
128
+ - `@api-developer` - API development
129
+ - `@integration-hub` - External services
130
+ - `@deployment-ops` - CI/CD and infrastructure
131
+
132
+ ## Migration from v1.x
133
+
134
+ If you have an existing `.claude/` directory:
135
+
136
+ ```bash
137
+ npx create-ai-context migrate
138
+ ```
139
+
140
+ This will:
141
+ - Rename `.claude/` to `.ai-context/`
142
+ - Rename `CLAUDE.md` to `AI_CONTEXT.md`
143
+ - Generate additional AI tool outputs
144
+
145
+ ## Requirements
146
+
147
+ - Node.js 18+
148
+
149
+ ## Related Packages
150
+
151
+ - [`claude-context`](https://www.npmjs.com/package/claude-context) - CLI tools for validation, sync, and diagnostics
152
+ - [`claude-context-plugin`](https://www.npmjs.com/package/claude-context-plugin) - Claude Code plugin with RPI workflow
153
+
154
+ ## Development
155
+
156
+ ```bash
157
+ git clone https://github.com/SireJeff/claude-context-engineering-template.git
158
+ cd claude-context-engineering-template/packages/create-ai-context
159
+ npm install
160
+ npm test
161
+ ```
162
+
163
+ ## License
164
+
165
+ MIT
166
+
167
+ ## Links
168
+
169
+ - [GitHub](https://github.com/SireJeff/claude-context-engineering-template)
170
+ - [Documentation](https://github.com/SireJeff/claude-context-engineering-template#readme)
171
+ - [Issues](https://github.com/SireJeff/claude-context-engineering-template/issues)
@@ -0,0 +1,337 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * create-ai-context CLI
5
+ *
6
+ * Universal AI Context Engineering - Set up context for Claude, Copilot, Cline, Antigravity, and more.
7
+ *
8
+ * Usage:
9
+ * npx create-ai-context # Initialize in current directory
10
+ * npx create-ai-context my-project # Initialize in new directory
11
+ * npx create-ai-context --yes # Skip prompts
12
+ * npx create-ai-context --ai copilot # Generate for specific tool
13
+ * npx create-ai-context generate # Regenerate context files
14
+ * npx create-ai-context generate --ai cline # Regenerate for specific tool
15
+ * npx create-ai-context migrate # Migrate from v1.x
16
+ */
17
+
18
+ const { program } = require('commander');
19
+ const chalk = require('chalk');
20
+ const path = require('path');
21
+ const fs = require('fs');
22
+ const { run } = require('../lib');
23
+ const { generateAll, getSupportedTools } = require('../lib/ai-context-generator');
24
+ const { migrateV1ToV2, getMigrationStatus } = require('../lib/migrate');
25
+ const { detectTechStack } = require('../lib/detector');
26
+ const { analyzeCodebase } = require('../lib/static-analyzer');
27
+ const { createSpinner } = require('../lib/spinner');
28
+ const packageJson = require('../package.json');
29
+
30
+ // ASCII Banner
31
+ const banner = `
32
+ ${chalk.cyan('╔═══════════════════════════════════════════════════════════╗')}
33
+ ${chalk.cyan('║')} ${chalk.bold.white('AI Context Engineering')} ${chalk.gray('v' + packageJson.version)} ${chalk.cyan('║')}
34
+ ${chalk.cyan('║')} ${chalk.gray('Universal context for Claude, Copilot, Cline & more')} ${chalk.cyan('║')}
35
+ ${chalk.cyan('╚═══════════════════════════════════════════════════════════╝')}
36
+ `;
37
+
38
+ // Supported AI tools
39
+ const AI_TOOLS = ['claude', 'copilot', 'cline', 'antigravity', 'all'];
40
+
41
+ // Parse AI tools helper
42
+ function parseAiTools(toolsString) {
43
+ const tools = toolsString.split(',').map(t => t.trim().toLowerCase());
44
+ const invalid = tools.filter(t => !AI_TOOLS.includes(t));
45
+ if (invalid.length > 0) {
46
+ console.error(chalk.red(`\n✖ Error: Invalid AI tools: ${invalid.join(', ')}`));
47
+ console.error(chalk.gray(` Valid options: ${AI_TOOLS.join(', ')}`));
48
+ process.exit(1);
49
+ }
50
+ return tools.includes('all') ? ['claude', 'copilot', 'cline', 'antigravity'] : tools;
51
+ }
52
+
53
+ program
54
+ .name('create-ai-context')
55
+ .description('Universal AI Context Engineering - Set up context for multiple AI coding assistants')
56
+ .version(packageJson.version);
57
+
58
+ // Main init command (default)
59
+ program
60
+ .argument('[project-name]', 'Name of the project (defaults to current directory name)')
61
+ .option('-y, --yes', 'Skip prompts and use defaults')
62
+ .option('--no-plugin', 'Skip plugin installation')
63
+ .option('-t, --template <preset>', 'Use a tech stack preset (python-fastapi, node-express, etc.)')
64
+ .option('--no-git', 'Skip git initialization')
65
+ .option('-n, --dry-run', 'Show what would be done without making changes')
66
+ .option('-v, --verbose', 'Show detailed output')
67
+ .option('--ai <tools>', 'Generate for specific AI tools (comma-separated: claude,copilot,cline,antigravity,all)', 'all')
68
+ .option('--force-ai', 'Force AI-enhanced mode (creates INIT_REQUEST.md)')
69
+ .option('--static', 'Force standalone mode (static analysis only, no AI setup)')
70
+ .option('--analyze-only', 'Run codebase analysis without installation')
71
+ .option('--monorepo', 'Initialize in monorepo mode with federation support')
72
+ .option('--federate', 'Run federation to generate context for subprojects')
73
+ .action(async (projectName, options) => {
74
+ console.log(banner);
75
+
76
+ const aiTools = parseAiTools(options.ai);
77
+
78
+ if (options.forceAi && options.static) {
79
+ console.error(chalk.red('\n✖ Error: --force-ai and --static are mutually exclusive'));
80
+ process.exit(1);
81
+ }
82
+
83
+ try {
84
+ await run({
85
+ projectName,
86
+ skipPrompts: options.yes,
87
+ installPlugin: options.plugin !== false,
88
+ template: options.template,
89
+ initGit: options.git !== false,
90
+ dryRun: options.dryRun,
91
+ verbose: options.verbose,
92
+ aiTools,
93
+ forceAi: options.forceAi,
94
+ forceStatic: options.static,
95
+ analyzeOnly: options.analyzeOnly,
96
+ monorepo: options.monorepo,
97
+ federate: options.federate
98
+ });
99
+ } catch (error) {
100
+ console.error(chalk.red('\n✖ Error:'), error.message);
101
+ if (options.verbose) {
102
+ console.error(chalk.gray(error.stack));
103
+ }
104
+ process.exit(1);
105
+ }
106
+ });
107
+
108
+ // Generate subcommand - regenerate context files
109
+ program
110
+ .command('generate')
111
+ .description('Regenerate AI context files for an existing project')
112
+ .option('--ai <tools>', 'Generate for specific AI tools (comma-separated)', 'all')
113
+ .option('-d, --dryRun', 'Show what would be done without making changes')
114
+ .option('-v, --verbose', 'Show detailed output')
115
+ .option('-p, --path <dir>', 'Project directory (defaults to current)', '.')
116
+ .action(async (options) => {
117
+ console.log(banner);
118
+
119
+ const projectRoot = path.resolve(options.path);
120
+ const aiTools = parseAiTools(options.ai);
121
+ const spinner = createSpinner();
122
+
123
+ // Check if project has .ai-context
124
+ const contextDir = path.join(projectRoot, '.ai-context');
125
+ if (!fs.existsSync(contextDir)) {
126
+ console.error(chalk.red('\n✖ Error: No .ai-context directory found.'));
127
+ console.error(chalk.gray(' Run `npx create-ai-context` first to initialize.'));
128
+ process.exit(1);
129
+ }
130
+
131
+ try {
132
+ // Detect tech stack
133
+ spinner.start('Detecting technology stack...');
134
+ const techStack = await detectTechStack(projectRoot);
135
+ spinner.succeed(`Detected: ${techStack.summary || 'Generic project'}`);
136
+
137
+ // Analyze codebase
138
+ spinner.start('Analyzing codebase...');
139
+ const analysis = await analyzeCodebase(projectRoot, { techStack });
140
+ analysis.techStack = techStack;
141
+ spinner.succeed(`Analyzed: ${analysis.summary?.totalFiles || 0} files`);
142
+
143
+ // Generate context files
144
+ spinner.start('Generating AI context files...');
145
+ const config = {
146
+ projectName: path.basename(projectRoot),
147
+ aiTools,
148
+ verbose: options.verbose
149
+ };
150
+
151
+ if (options.dryRun) {
152
+ spinner.info('Dry run - no files will be written');
153
+ console.log(chalk.gray('\nWould generate for:'));
154
+ aiTools.forEach(tool => {
155
+ console.log(chalk.gray(` • ${tool}`));
156
+ });
157
+ } else {
158
+ const results = await generateAll(analysis, config, projectRoot, {
159
+ aiTools,
160
+ verbose: options.verbose
161
+ });
162
+
163
+ if (results.success) {
164
+ spinner.succeed(`Generated ${results.summary.files} files for ${results.summary.successful} AI tools`);
165
+
166
+ console.log(chalk.bold('\nGenerated files:'));
167
+ results.generated.forEach(g => {
168
+ console.log(chalk.green(` ✓ ${g.displayName}`));
169
+ g.files.forEach(f => {
170
+ console.log(chalk.gray(` ${f.relativePath}`));
171
+ });
172
+ });
173
+ } else {
174
+ spinner.warn(`Generated ${results.summary.successful}/${results.summary.total} tools`);
175
+ results.errors.forEach(e => {
176
+ console.error(chalk.red(` ✖ ${e.adapter}: ${e.message || e.errors?.[0]?.message}`));
177
+ });
178
+ }
179
+ }
180
+ } catch (error) {
181
+ spinner.fail('Generation failed');
182
+ console.error(chalk.red('\n✖ Error:'), error.message);
183
+ if (options.verbose) {
184
+ console.error(chalk.gray(error.stack));
185
+ }
186
+ process.exit(1);
187
+ }
188
+ });
189
+
190
+ // Migrate subcommand - upgrade from v1.x
191
+ program
192
+ .command('migrate')
193
+ .description('Migrate from v1.x (.claude/) to v2.0 (.ai-context/)')
194
+ .option('-d, --dryRun', 'Show what would be done without making changes')
195
+ .option('--force', 'Overwrite existing v2.0 installation')
196
+ .option('--backup', 'Create backup of existing files')
197
+ .option('--no-update-refs', 'Skip updating internal references')
198
+ .option('-p, --path <dir>', 'Project directory (defaults to current)', '.')
199
+ .action(async (options) => {
200
+ console.log(banner);
201
+
202
+ const projectRoot = path.resolve(options.path);
203
+ const spinner = createSpinner();
204
+
205
+ // Check migration status
206
+ spinner.start('Checking installation...');
207
+ const status = getMigrationStatus(projectRoot);
208
+ spinner.succeed(`Status: ${status.message}`);
209
+
210
+ if (!status.needsMigration) {
211
+ console.log(chalk.green('\n✓ No migration needed.'));
212
+ process.exit(0);
213
+ }
214
+
215
+ // Show what will happen
216
+ console.log(chalk.bold('\nMigration plan:'));
217
+ if (status.details?.oldDir) {
218
+ console.log(chalk.cyan(` • Rename .claude/ → .ai-context/`));
219
+ }
220
+ if (status.details?.oldFile) {
221
+ console.log(chalk.cyan(` • Rename CLAUDE.md → AI_CONTEXT.md`));
222
+ }
223
+ if (options.updateRefs !== false) {
224
+ console.log(chalk.cyan(` • Update internal references in files`));
225
+ }
226
+
227
+ if (options.dryRun) {
228
+ console.log(chalk.yellow('\n[dry-run] No changes will be made'));
229
+ process.exit(0);
230
+ }
231
+
232
+ // Perform migration
233
+ spinner.start('Migrating...');
234
+ try {
235
+ const result = await migrateV1ToV2(projectRoot, {
236
+ dryRun: false,
237
+ force: options.force,
238
+ backup: options.backup,
239
+ updateReferences: options.updateRefs !== false
240
+ });
241
+
242
+ if (result.success) {
243
+ spinner.succeed('Migration completed successfully');
244
+
245
+ console.log(chalk.bold('\nChanges made:'));
246
+ result.changes.forEach(change => {
247
+ if (change.type === 'rename') {
248
+ console.log(chalk.green(` ✓ ${change.action} ${change.from} → ${change.to}`));
249
+ } else if (change.type === 'update') {
250
+ console.log(chalk.green(` ✓ ${change.action} ${change.file}`));
251
+ } else if (change.type === 'backup') {
252
+ console.log(chalk.blue(` ↺ ${change.action} ${change.from} → ${change.to}`));
253
+ }
254
+ });
255
+
256
+ if (result.warnings.length > 0) {
257
+ console.log(chalk.yellow('\nWarnings:'));
258
+ result.warnings.forEach(w => console.log(chalk.yellow(` ⚠ ${w}`)));
259
+ }
260
+
261
+ console.log(chalk.bold('\nNext steps:'));
262
+ console.log(chalk.gray(' 1. Review AI_CONTEXT.md for any needed updates'));
263
+ console.log(chalk.gray(' 2. Run `npx create-ai-context generate` to regenerate AI tool files'));
264
+ console.log(chalk.gray(' 3. Commit the changes'));
265
+ } else {
266
+ spinner.fail('Migration failed');
267
+ result.errors.forEach(e => {
268
+ console.error(chalk.red(` ✖ ${e}`));
269
+ });
270
+ process.exit(1);
271
+ }
272
+ } catch (error) {
273
+ spinner.fail('Migration failed');
274
+ console.error(chalk.red('\n✖ Error:'), error.message);
275
+ process.exit(1);
276
+ }
277
+ });
278
+
279
+ // Status subcommand - show current installation status
280
+ program
281
+ .command('status')
282
+ .description('Show current AI context installation status')
283
+ .option('-p, --path <dir>', 'Project directory (defaults to current)', '.')
284
+ .action(async (options) => {
285
+ console.log(banner);
286
+
287
+ const projectRoot = path.resolve(options.path);
288
+
289
+ // Check migration status
290
+ const migrationStatus = getMigrationStatus(projectRoot);
291
+
292
+ console.log(chalk.bold('Installation Status:\n'));
293
+
294
+ // Version status
295
+ if (migrationStatus.status === 'none') {
296
+ console.log(chalk.yellow(' ○ Not initialized'));
297
+ console.log(chalk.gray(' Run `npx create-ai-context` to initialize\n'));
298
+ } else if (migrationStatus.status === 'v1') {
299
+ console.log(chalk.yellow(' ○ v1.x installation found'));
300
+ console.log(chalk.gray(' Run `npx create-ai-context migrate` to upgrade to v2.0\n'));
301
+ } else if (migrationStatus.status === 'v2') {
302
+ console.log(chalk.green(' ✓ v2.0 installation'));
303
+ } else if (migrationStatus.status === 'mixed') {
304
+ console.log(chalk.yellow(' ⚠ Mixed v1.x and v2.0 installation'));
305
+ console.log(chalk.gray(' Run `npx create-ai-context migrate --force` to clean up\n'));
306
+ }
307
+
308
+ // Check AI tool outputs
309
+ if (migrationStatus.status === 'v2' || migrationStatus.status === 'mixed') {
310
+ console.log(chalk.bold('\nAI Tool Outputs:'));
311
+
312
+ const tools = getSupportedTools();
313
+ for (const tool of tools) {
314
+ let outputPath;
315
+ if (tool.name === 'claude') {
316
+ outputPath = path.join(projectRoot, 'AI_CONTEXT.md');
317
+ } else if (tool.name === 'copilot') {
318
+ outputPath = path.join(projectRoot, '.github', 'copilot-instructions.md');
319
+ } else if (tool.name === 'cline') {
320
+ outputPath = path.join(projectRoot, '.clinerules');
321
+ } else if (tool.name === 'antigravity') {
322
+ outputPath = path.join(projectRoot, '.agent');
323
+ }
324
+
325
+ const exists = fs.existsSync(outputPath);
326
+ if (exists) {
327
+ console.log(chalk.green(` ✓ ${tool.displayName} (${tool.outputPath})`));
328
+ } else {
329
+ console.log(chalk.gray(` ○ ${tool.displayName} (not generated)`));
330
+ }
331
+ }
332
+
333
+ console.log(chalk.gray('\n Run `npx create-ai-context generate` to regenerate'));
334
+ }
335
+ });
336
+
337
+ program.parse();
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Antigravity Adapter
3
+ *
4
+ * Generates .agent/ directory with multiple files for Google Antigravity.
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { renderMultiFileTemplate, buildContext } = require('../template-renderer');
10
+
11
+ /**
12
+ * Adapter metadata
13
+ */
14
+ const adapter = {
15
+ name: 'antigravity',
16
+ displayName: 'Antigravity',
17
+ description: 'Multi-file context for Google Antigravity',
18
+ outputType: 'multi-file',
19
+ outputPath: '.agent/'
20
+ };
21
+
22
+ /**
23
+ * Get output directory for Antigravity files
24
+ * @param {string} projectRoot - Project root directory
25
+ * @returns {string} Output directory path
26
+ */
27
+ function getOutputPath(projectRoot) {
28
+ return path.join(projectRoot, '.agent');
29
+ }
30
+
31
+ /**
32
+ * Check if Antigravity output already exists
33
+ * @param {string} projectRoot - Project root directory
34
+ * @returns {boolean}
35
+ */
36
+ function exists(projectRoot) {
37
+ return fs.existsSync(getOutputPath(projectRoot));
38
+ }
39
+
40
+ /**
41
+ * Generate Antigravity context files
42
+ * @param {object} analysis - Analysis results from static analyzer
43
+ * @param {object} config - Configuration from CLI
44
+ * @param {string} projectRoot - Project root directory
45
+ * @returns {object} Generation result
46
+ */
47
+ async function generate(analysis, config, projectRoot) {
48
+ const result = {
49
+ success: false,
50
+ adapter: adapter.name,
51
+ files: [],
52
+ errors: []
53
+ };
54
+
55
+ try {
56
+ // Build context from analysis
57
+ const context = buildContext(analysis, config);
58
+
59
+ // Get template path
60
+ const templatePath = path.join(__dirname, '..', '..', 'templates', 'handlebars', 'antigravity.hbs');
61
+
62
+ // Render multi-file template
63
+ const files = renderMultiFileTemplate(templatePath, context);
64
+
65
+ // Create output directory
66
+ const outputDir = getOutputPath(projectRoot);
67
+ if (!fs.existsSync(outputDir)) {
68
+ fs.mkdirSync(outputDir, { recursive: true });
69
+ }
70
+
71
+ // Write each file
72
+ for (const file of files) {
73
+ const filePath = path.join(outputDir, file.filename);
74
+ const fileDir = path.dirname(filePath);
75
+
76
+ // Ensure directory exists
77
+ if (!fs.existsSync(fileDir)) {
78
+ fs.mkdirSync(fileDir, { recursive: true });
79
+ }
80
+
81
+ // Write file
82
+ fs.writeFileSync(filePath, file.content, 'utf-8');
83
+
84
+ result.files.push({
85
+ path: filePath,
86
+ relativePath: `.agent/${file.filename}`,
87
+ size: file.content.length
88
+ });
89
+ }
90
+
91
+ result.success = true;
92
+ } catch (error) {
93
+ result.errors.push({
94
+ message: error.message,
95
+ stack: error.stack
96
+ });
97
+ }
98
+
99
+ return result;
100
+ }
101
+
102
+ /**
103
+ * Validate Antigravity output
104
+ * @param {string} projectRoot - Project root directory
105
+ * @returns {object} Validation result
106
+ */
107
+ function validate(projectRoot) {
108
+ const outputDir = getOutputPath(projectRoot);
109
+
110
+ if (!fs.existsSync(outputDir)) {
111
+ return {
112
+ valid: false,
113
+ error: '.agent/ directory not found'
114
+ };
115
+ }
116
+
117
+ // Check for required subdirectories
118
+ const requiredDirs = ['rules', 'workflows', 'skills'];
119
+ const missingDirs = [];
120
+
121
+ for (const dir of requiredDirs) {
122
+ if (!fs.existsSync(path.join(outputDir, dir))) {
123
+ missingDirs.push(dir);
124
+ }
125
+ }
126
+
127
+ if (missingDirs.length > 0) {
128
+ return {
129
+ valid: false,
130
+ error: `Missing directories: ${missingDirs.join(', ')}`
131
+ };
132
+ }
133
+
134
+ // Count files
135
+ let fileCount = 0;
136
+ const countFiles = (dir) => {
137
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
138
+ for (const entry of entries) {
139
+ if (entry.isDirectory()) {
140
+ countFiles(path.join(dir, entry.name));
141
+ } else {
142
+ fileCount++;
143
+ }
144
+ }
145
+ };
146
+ countFiles(outputDir);
147
+
148
+ return {
149
+ valid: true,
150
+ fileCount
151
+ };
152
+ }
153
+
154
+ module.exports = {
155
+ ...adapter,
156
+ getOutputPath,
157
+ exists,
158
+ generate,
159
+ validate
160
+ };