aios-core 2.1.4 → 2.1.5

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 (23) hide show
  1. package/.aios-core/infrastructure/scripts/llm-routing/install-llm-routing.js +6 -6
  2. package/package.json +1 -1
  3. package/packages/installer/src/config/templates/env-template.js +2 -2
  4. package/packages/installer/src/wizard/wizard.js +34 -185
  5. package/src/wizard/index.js +2 -2
  6. package/.aios-core/development/tasks/analyze-brownfield.md +0 -456
  7. package/.aios-core/development/tasks/setup-project-docs.md +0 -444
  8. package/.aios-core/infrastructure/scripts/documentation-integrity/brownfield-analyzer.js +0 -501
  9. package/.aios-core/infrastructure/scripts/documentation-integrity/config-generator.js +0 -329
  10. package/.aios-core/infrastructure/scripts/documentation-integrity/deployment-config-loader.js +0 -282
  11. package/.aios-core/infrastructure/scripts/documentation-integrity/doc-generator.js +0 -331
  12. package/.aios-core/infrastructure/scripts/documentation-integrity/gitignore-generator.js +0 -312
  13. package/.aios-core/infrastructure/scripts/documentation-integrity/index.js +0 -74
  14. package/.aios-core/infrastructure/scripts/documentation-integrity/mode-detector.js +0 -358
  15. package/.aios-core/infrastructure/templates/core-config/core-config-brownfield.tmpl.yaml +0 -182
  16. package/.aios-core/infrastructure/templates/core-config/core-config-greenfield.tmpl.yaml +0 -127
  17. package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +0 -63
  18. package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +0 -18
  19. package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +0 -85
  20. package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +0 -145
  21. package/.aios-core/infrastructure/templates/project-docs/coding-standards-tmpl.md +0 -346
  22. package/.aios-core/infrastructure/templates/project-docs/source-tree-tmpl.md +0 -177
  23. package/.aios-core/infrastructure/templates/project-docs/tech-stack-tmpl.md +0 -267
@@ -1,329 +0,0 @@
1
- /**
2
- * Config Generator Module
3
- *
4
- * Generates project-specific core-config.yaml from templates.
5
- * Supports greenfield and brownfield modes with deployment configuration.
6
- *
7
- * @module documentation-integrity/config-generator
8
- * @version 1.0.0
9
- * @story 6.9
10
- */
11
-
12
- const fs = require('fs');
13
- const path = require('path');
14
- const yaml = require('yaml');
15
-
16
- // Template directory
17
- const TEMPLATES_DIR = path.join(__dirname, '..', '..', 'templates', 'core-config');
18
-
19
- /**
20
- * Template file names
21
- * @enum {string}
22
- */
23
- const ConfigTemplates = {
24
- GREENFIELD: 'core-config-greenfield.tmpl.yaml',
25
- BROWNFIELD: 'core-config-brownfield.tmpl.yaml',
26
- };
27
-
28
- /**
29
- * Deployment workflow types
30
- * @enum {string}
31
- */
32
- const DeploymentWorkflow = {
33
- STAGING_FIRST: 'staging-first',
34
- DIRECT_TO_MAIN: 'direct-to-main',
35
- };
36
-
37
- /**
38
- * Deployment platform options
39
- * @enum {string}
40
- */
41
- const DeploymentPlatform = {
42
- RAILWAY: 'Railway',
43
- VERCEL: 'Vercel',
44
- AWS: 'AWS',
45
- DOCKER: 'Docker',
46
- NONE: 'None',
47
- };
48
-
49
- /**
50
- * Default deployment configuration
51
- * @type {Object}
52
- */
53
- const DEFAULT_DEPLOYMENT_CONFIG = {
54
- workflow: DeploymentWorkflow.STAGING_FIRST,
55
- stagingBranch: 'staging',
56
- productionBranch: 'main',
57
- defaultTarget: 'staging',
58
- stagingEnvName: 'Staging',
59
- productionEnvName: 'Production',
60
- platform: DeploymentPlatform.NONE,
61
- qualityGates: {
62
- lint: true,
63
- typecheck: true,
64
- tests: true,
65
- security: false,
66
- minCoverage: 50,
67
- },
68
- };
69
-
70
- /**
71
- * Builds config context from project info and deployment settings
72
- *
73
- * @param {string} projectName - Project name
74
- * @param {string} mode - Installation mode (greenfield/brownfield)
75
- * @param {Object} deploymentConfig - Deployment configuration
76
- * @param {Object} [analysisResults] - Brownfield analysis results (if applicable)
77
- * @returns {Object} Config context for template rendering
78
- */
79
- function buildConfigContext(projectName, mode, deploymentConfig = {}, analysisResults = {}) {
80
- const config = { ...DEFAULT_DEPLOYMENT_CONFIG, ...deploymentConfig };
81
- const isStaging = config.workflow === DeploymentWorkflow.STAGING_FIRST;
82
-
83
- const context = {
84
- // Basic info
85
- PROJECT_NAME: projectName,
86
- GENERATED_DATE: new Date().toISOString().split('T')[0],
87
- PROJECT_VERSION: analysisResults.version || '0.1.0',
88
-
89
- // Deployment workflow
90
- DEPLOYMENT_WORKFLOW: config.workflow,
91
-
92
- // Branch configuration
93
- STAGING_BRANCH: isStaging ? config.stagingBranch : 'null',
94
- PRODUCTION_BRANCH: config.productionBranch,
95
- DEFAULT_TARGET: isStaging ? config.stagingBranch : config.productionBranch,
96
-
97
- // Environment names
98
- STAGING_ENV_NAME: config.stagingEnvName,
99
- PRODUCTION_ENV_NAME: config.productionEnvName,
100
-
101
- // Platform
102
- DEPLOYMENT_PLATFORM: config.platform,
103
-
104
- // Quality gates
105
- QUALITY_LINT: config.qualityGates.lint,
106
- QUALITY_TYPECHECK: config.qualityGates.typecheck,
107
- QUALITY_TESTS: config.qualityGates.tests,
108
- QUALITY_SECURITY: config.qualityGates.security || false,
109
- MIN_COVERAGE: config.qualityGates.minCoverage || 50,
110
-
111
- // Brownfield specific (defaults for greenfield)
112
- HAS_EXISTING_STRUCTURE: analysisResults.hasExistingStructure || false,
113
- HAS_EXISTING_WORKFLOWS: analysisResults.hasExistingWorkflows || false,
114
- HAS_EXISTING_STANDARDS: analysisResults.hasExistingStandards || false,
115
- MERGE_STRATEGY: analysisResults.mergeStrategy || 'parallel',
116
-
117
- // Detected configs (brownfield)
118
- DETECTED_TECH_STACK: JSON.stringify(analysisResults.techStack || []),
119
- DETECTED_FRAMEWORKS: JSON.stringify(analysisResults.frameworks || []),
120
- DETECTED_LINTING: analysisResults.linting || 'none',
121
- DETECTED_FORMATTING: analysisResults.formatting || 'none',
122
- DETECTED_TESTING: analysisResults.testing || 'none',
123
-
124
- // Auto deploy settings
125
- STAGING_AUTO_DEPLOY: config.stagingAutoDeploy !== false,
126
- PRODUCTION_AUTO_DEPLOY: config.productionAutoDeploy !== false,
127
-
128
- // PR settings
129
- AUTO_ASSIGN_REVIEWERS: config.autoAssignReviewers || false,
130
- DRAFT_BY_DEFAULT: config.draftByDefault || false,
131
-
132
- // Existing config paths (brownfield)
133
- ESLINT_CONFIG_PATH: analysisResults.eslintPath || 'null',
134
- PRETTIER_CONFIG_PATH: analysisResults.prettierPath || 'null',
135
- TSCONFIG_PATH: analysisResults.tsconfigPath || 'null',
136
- FLAKE8_CONFIG_PATH: analysisResults.flake8Path || 'null',
137
- GITHUB_WORKFLOWS_PATH: analysisResults.githubWorkflowsPath || 'null',
138
- GITLAB_CI_PATH: analysisResults.gitlabCiPath || 'null',
139
- PACKAGE_JSON_PATH: analysisResults.packageJsonPath || 'null',
140
- REQUIREMENTS_PATH: analysisResults.requirementsPath || 'null',
141
- GO_MOD_PATH: analysisResults.goModPath || 'null',
142
-
143
- // Merge settings
144
- MERGE_WORKFLOWS: analysisResults.mergeWorkflows || false,
145
-
146
- // Migration notes (brownfield)
147
- MIGRATION_SUMMARY: analysisResults.summary || 'No analysis performed',
148
- MANUAL_REVIEW_ITEMS: analysisResults.manualReviewItems || [],
149
- CONFLICTS: analysisResults.conflicts || [],
150
- RECOMMENDATIONS: analysisResults.recommendations || [],
151
- };
152
-
153
- return context;
154
- }
155
-
156
- /**
157
- * Renders a YAML template with context
158
- *
159
- * @param {string} template - Template content
160
- * @param {Object} context - Context object
161
- * @returns {string} Rendered YAML content
162
- */
163
- function renderConfigTemplate(template, context) {
164
- let result = template;
165
-
166
- // Process {{#each}} blocks
167
- result = processEachBlocks(result, context);
168
-
169
- // Replace simple variables {{variable}}
170
- result = result.replace(/\{\{([^#/}][^}]*)\}\}/g, (match, key) => {
171
- const value = context[key.trim()];
172
- if (value === undefined) return match;
173
- if (typeof value === 'boolean') return value.toString();
174
- if (typeof value === 'number') return value.toString();
175
- return String(value);
176
- });
177
-
178
- return result;
179
- }
180
-
181
- /**
182
- * Process {{#each array}}...{{/each}} blocks
183
- *
184
- * @param {string} template - Template string
185
- * @param {Object} context - Context object
186
- * @returns {string} Processed template
187
- */
188
- function processEachBlocks(template, context) {
189
- const eachRegex = /\{\{#each\s+(\w+)\}\}([\s\S]*?)\{\{\/each\}\}/g;
190
-
191
- return template.replace(eachRegex, (match, arrayName, content) => {
192
- const array = context[arrayName];
193
- if (!Array.isArray(array) || array.length === 0) {
194
- return '';
195
- }
196
-
197
- return array
198
- .map((item) => {
199
- return content.replace(/\{\{this\}\}/g, String(item));
200
- })
201
- .join('');
202
- });
203
- }
204
-
205
- /**
206
- * Loads a config template
207
- *
208
- * @param {string} templateName - Template file name
209
- * @returns {string} Template content
210
- * @throws {Error} If template not found
211
- */
212
- function loadConfigTemplate(templateName) {
213
- const templatePath = path.join(TEMPLATES_DIR, templateName);
214
-
215
- if (!fs.existsSync(templatePath)) {
216
- throw new Error(`Config template not found: ${templatePath}`);
217
- }
218
-
219
- return fs.readFileSync(templatePath, 'utf8');
220
- }
221
-
222
- /**
223
- * Generates core-config.yaml for a project
224
- *
225
- * @param {string} targetDir - Target directory
226
- * @param {string} mode - Installation mode (greenfield/brownfield)
227
- * @param {Object} context - Config context
228
- * @param {Object} [options] - Generation options
229
- * @param {boolean} [options.dryRun] - Don't write file, just return content
230
- * @returns {Object} Generation result
231
- */
232
- function generateConfig(targetDir, mode, context, options = {}) {
233
- const templateName =
234
- mode === 'brownfield' ? ConfigTemplates.BROWNFIELD : ConfigTemplates.GREENFIELD;
235
-
236
- try {
237
- const template = loadConfigTemplate(templateName);
238
- const rendered = renderConfigTemplate(template, context);
239
-
240
- // Validate YAML syntax
241
- try {
242
- yaml.parse(rendered);
243
- } catch (yamlError) {
244
- return {
245
- success: false,
246
- error: `Generated YAML is invalid: ${yamlError.message}`,
247
- content: rendered,
248
- };
249
- }
250
-
251
- const configDir = path.join(targetDir, '.aios-core');
252
- const configPath = path.join(configDir, 'core-config.yaml');
253
-
254
- if (!options.dryRun) {
255
- fs.mkdirSync(configDir, { recursive: true });
256
- fs.writeFileSync(configPath, rendered, 'utf8');
257
- }
258
-
259
- return {
260
- success: true,
261
- path: configPath,
262
- content: rendered,
263
- };
264
- } catch (error) {
265
- return {
266
- success: false,
267
- error: error.message,
268
- content: null,
269
- };
270
- }
271
- }
272
-
273
- /**
274
- * Generates deployment config context from user inputs
275
- *
276
- * @param {Object} inputs - User inputs from wizard
277
- * @returns {Object} Deployment configuration
278
- */
279
- function buildDeploymentConfig(inputs = {}) {
280
- return {
281
- workflow: inputs.workflow || DeploymentWorkflow.STAGING_FIRST,
282
- stagingBranch: inputs.stagingBranch || 'staging',
283
- productionBranch: inputs.productionBranch || 'main',
284
- stagingEnvName: inputs.stagingEnvName || 'Staging',
285
- productionEnvName: inputs.productionEnvName || 'Production',
286
- platform: inputs.platform || DeploymentPlatform.NONE,
287
- qualityGates: {
288
- lint: inputs.lint !== false,
289
- typecheck: inputs.typecheck !== false,
290
- tests: inputs.tests !== false,
291
- security: inputs.security || false,
292
- minCoverage: inputs.minCoverage || 50,
293
- },
294
- autoAssignReviewers: inputs.autoAssignReviewers || false,
295
- draftByDefault: inputs.draftByDefault || false,
296
- };
297
- }
298
-
299
- /**
300
- * Gets default deployment config for a mode
301
- *
302
- * @param {string} mode - Installation mode
303
- * @returns {Object} Default deployment config
304
- */
305
- function getDefaultDeploymentConfig(mode) {
306
- if (mode === 'brownfield') {
307
- // Brownfield might use direct-to-main if solo project
308
- return {
309
- ...DEFAULT_DEPLOYMENT_CONFIG,
310
- // Keep staging-first as default, but brownfield analyzer may change this
311
- };
312
- }
313
-
314
- return { ...DEFAULT_DEPLOYMENT_CONFIG };
315
- }
316
-
317
- module.exports = {
318
- buildConfigContext,
319
- renderConfigTemplate,
320
- loadConfigTemplate,
321
- generateConfig,
322
- buildDeploymentConfig,
323
- getDefaultDeploymentConfig,
324
- ConfigTemplates,
325
- DeploymentWorkflow,
326
- DeploymentPlatform,
327
- DEFAULT_DEPLOYMENT_CONFIG,
328
- TEMPLATES_DIR,
329
- };
@@ -1,282 +0,0 @@
1
- /**
2
- * Deployment Config Loader
3
- *
4
- * Shared utility for loading deployment configuration from core-config.yaml.
5
- * Implements the Configuration-Driven Architecture pattern.
6
- *
7
- * Usage:
8
- * const { loadDeploymentConfig } = require('./deployment-config-loader');
9
- * const config = loadDeploymentConfig(projectRoot);
10
- *
11
- * @module documentation-integrity/deployment-config-loader
12
- * @version 1.0.0
13
- * @story 6.9
14
- */
15
-
16
- const fs = require('fs');
17
- const path = require('path');
18
- const yaml = require('yaml');
19
-
20
- /**
21
- * Default deployment configuration
22
- * Used when core-config.yaml doesn't exist or deployment section is missing
23
- *
24
- * @type {Object}
25
- */
26
- const DEFAULT_DEPLOYMENT_CONFIG = {
27
- workflow: 'staging-first',
28
-
29
- branches: {
30
- staging_targets: ['feature/*', 'fix/*', 'docs/*', 'chore/*', 'refactor/*', 'test/*'],
31
- production_targets: ['hotfix/*'],
32
- staging_branch: 'staging',
33
- production_branch: 'main',
34
- default_target: 'staging',
35
- },
36
-
37
- environments: {
38
- staging: {
39
- name: 'Staging',
40
- auto_deploy: true,
41
- platform: null,
42
- url: null,
43
- promotion_message: 'After validation, create PR to main for production',
44
- },
45
- production: {
46
- name: 'Production',
47
- auto_deploy: true,
48
- platform: null,
49
- url: null,
50
- promotion_message: 'This is the final production deployment',
51
- },
52
- },
53
-
54
- quality_gates: {
55
- lint: true,
56
- typecheck: true,
57
- tests: true,
58
- security_scan: false,
59
- min_coverage: 50,
60
- },
61
-
62
- pr_defaults: {
63
- auto_assign_reviewers: false,
64
- draft_by_default: false,
65
- include_deployment_info: true,
66
- },
67
- };
68
-
69
- /**
70
- * Loads deployment configuration from core-config.yaml
71
- *
72
- * @param {string} projectRoot - Project root directory
73
- * @returns {Object} Deployment configuration (merged with defaults)
74
- */
75
- function loadDeploymentConfig(projectRoot) {
76
- const configPath = path.join(projectRoot, '.aios-core', 'core-config.yaml');
77
-
78
- if (!fs.existsSync(configPath)) {
79
- console.warn(`[deployment-config-loader] core-config.yaml not found at ${configPath}`);
80
- console.warn('[deployment-config-loader] Using default deployment configuration');
81
- return { ...DEFAULT_DEPLOYMENT_CONFIG };
82
- }
83
-
84
- try {
85
- const configContent = fs.readFileSync(configPath, 'utf8');
86
- const config = yaml.parse(configContent);
87
-
88
- if (!config || !config.deployment) {
89
- console.warn('[deployment-config-loader] No deployment section in core-config.yaml');
90
- console.warn('[deployment-config-loader] Using default deployment configuration');
91
- return { ...DEFAULT_DEPLOYMENT_CONFIG };
92
- }
93
-
94
- // Deep merge with defaults to ensure all required fields exist
95
- return deepMerge(DEFAULT_DEPLOYMENT_CONFIG, config.deployment);
96
- } catch (error) {
97
- console.error(`[deployment-config-loader] Error loading config: ${error.message}`);
98
- console.warn('[deployment-config-loader] Using default deployment configuration');
99
- return { ...DEFAULT_DEPLOYMENT_CONFIG };
100
- }
101
- }
102
-
103
- /**
104
- * Loads project configuration from core-config.yaml
105
- *
106
- * @param {string} projectRoot - Project root directory
107
- * @returns {Object|null} Project configuration or null if not found
108
- */
109
- function loadProjectConfig(projectRoot) {
110
- const configPath = path.join(projectRoot, '.aios-core', 'core-config.yaml');
111
-
112
- if (!fs.existsSync(configPath)) {
113
- return null;
114
- }
115
-
116
- try {
117
- const configContent = fs.readFileSync(configPath, 'utf8');
118
- const config = yaml.parse(configContent);
119
- return config.project || null;
120
- } catch (error) {
121
- console.error(`[deployment-config-loader] Error loading project config: ${error.message}`);
122
- return null;
123
- }
124
- }
125
-
126
- /**
127
- * Gets the target branch for a given source branch
128
- *
129
- * @param {string} sourceBranch - Source branch name
130
- * @param {Object} deploymentConfig - Deployment configuration
131
- * @returns {string} Target branch name
132
- */
133
- function getTargetBranch(sourceBranch, deploymentConfig) {
134
- const { branches, workflow } = deploymentConfig;
135
-
136
- // Check if it's a staging branch (used for promotion)
137
- if (sourceBranch === branches.staging_branch) {
138
- return branches.production_branch;
139
- }
140
-
141
- // Check production targets (hotfix/* etc.)
142
- for (const pattern of branches.production_targets || []) {
143
- if (matchesBranchPattern(sourceBranch, pattern)) {
144
- return branches.production_branch;
145
- }
146
- }
147
-
148
- // Check staging targets
149
- for (const pattern of branches.staging_targets || []) {
150
- if (matchesBranchPattern(sourceBranch, pattern)) {
151
- // If direct-to-main workflow, target production
152
- if (workflow === 'direct-to-main') {
153
- return branches.production_branch;
154
- }
155
- return branches.staging_branch || branches.production_branch;
156
- }
157
- }
158
-
159
- // Default target
160
- return branches.default_target || branches.production_branch;
161
- }
162
-
163
- /**
164
- * Checks if a branch name matches a pattern
165
- *
166
- * @param {string} branchName - Branch name to check
167
- * @param {string} pattern - Pattern to match (e.g., "feature/*")
168
- * @returns {boolean} True if matches
169
- */
170
- function matchesBranchPattern(branchName, pattern) {
171
- // Convert glob pattern to regex
172
- const regexPattern = pattern
173
- .replace(/\*/g, '.*')
174
- .replace(/\?/g, '.');
175
-
176
- const regex = new RegExp(`^${regexPattern}$`);
177
- return regex.test(branchName);
178
- }
179
-
180
- /**
181
- * Gets environment configuration by name
182
- *
183
- * @param {string} envName - Environment name (staging/production)
184
- * @param {Object} deploymentConfig - Deployment configuration
185
- * @returns {Object|null} Environment configuration
186
- */
187
- function getEnvironmentConfig(envName, deploymentConfig) {
188
- const normalized = envName.toLowerCase();
189
- return deploymentConfig.environments?.[normalized] || null;
190
- }
191
-
192
- /**
193
- * Checks if quality gate is enabled
194
- *
195
- * @param {string} gateName - Gate name (lint, typecheck, tests, security_scan)
196
- * @param {Object} deploymentConfig - Deployment configuration
197
- * @returns {boolean} True if gate is enabled
198
- */
199
- function isQualityGateEnabled(gateName, deploymentConfig) {
200
- return deploymentConfig.quality_gates?.[gateName] === true;
201
- }
202
-
203
- /**
204
- * Gets all enabled quality gates
205
- *
206
- * @param {Object} deploymentConfig - Deployment configuration
207
- * @returns {string[]} List of enabled gate names
208
- */
209
- function getEnabledQualityGates(deploymentConfig) {
210
- const gates = deploymentConfig.quality_gates || {};
211
- return Object.entries(gates)
212
- .filter(([key, value]) => value === true && key !== 'min_coverage')
213
- .map(([key]) => key);
214
- }
215
-
216
- /**
217
- * Deep merge two objects
218
- *
219
- * @param {Object} target - Target object
220
- * @param {Object} source - Source object
221
- * @returns {Object} Merged object
222
- */
223
- function deepMerge(target, source) {
224
- const result = { ...target };
225
-
226
- for (const key of Object.keys(source)) {
227
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
228
- result[key] = deepMerge(target[key] || {}, source[key]);
229
- } else if (source[key] !== undefined) {
230
- result[key] = source[key];
231
- }
232
- }
233
-
234
- return result;
235
- }
236
-
237
- /**
238
- * Validates deployment configuration
239
- *
240
- * @param {Object} config - Deployment configuration to validate
241
- * @returns {Object} Validation result with isValid and errors
242
- */
243
- function validateDeploymentConfig(config) {
244
- const errors = [];
245
-
246
- // Check workflow
247
- if (!['staging-first', 'direct-to-main'].includes(config.workflow)) {
248
- errors.push(`Invalid workflow: ${config.workflow}`);
249
- }
250
-
251
- // Check branches
252
- if (!config.branches?.production_branch) {
253
- errors.push('Missing production_branch');
254
- }
255
-
256
- if (config.workflow === 'staging-first' && !config.branches?.staging_branch) {
257
- errors.push('staging-first workflow requires staging_branch');
258
- }
259
-
260
- // Check environments
261
- if (!config.environments?.production) {
262
- errors.push('Missing production environment configuration');
263
- }
264
-
265
- return {
266
- isValid: errors.length === 0,
267
- errors,
268
- };
269
- }
270
-
271
- module.exports = {
272
- loadDeploymentConfig,
273
- loadProjectConfig,
274
- getTargetBranch,
275
- matchesBranchPattern,
276
- getEnvironmentConfig,
277
- isQualityGateEnabled,
278
- getEnabledQualityGates,
279
- validateDeploymentConfig,
280
- deepMerge,
281
- DEFAULT_DEPLOYMENT_CONFIG,
282
- };