aios-core 2.1.5 → 2.1.6

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 (29) hide show
  1. package/.aios-core/development/tasks/analyze-brownfield.md +456 -0
  2. package/.aios-core/development/tasks/setup-project-docs.md +440 -0
  3. package/.aios-core/infrastructure/scripts/documentation-integrity/brownfield-analyzer.js +501 -0
  4. package/.aios-core/infrastructure/scripts/documentation-integrity/config-generator.js +368 -0
  5. package/.aios-core/infrastructure/scripts/documentation-integrity/deployment-config-loader.js +308 -0
  6. package/.aios-core/infrastructure/scripts/documentation-integrity/doc-generator.js +331 -0
  7. package/.aios-core/infrastructure/scripts/documentation-integrity/gitignore-generator.js +312 -0
  8. package/.aios-core/infrastructure/scripts/documentation-integrity/index.js +74 -0
  9. package/.aios-core/infrastructure/scripts/documentation-integrity/mode-detector.js +389 -0
  10. package/.aios-core/infrastructure/templates/core-config/core-config-brownfield.tmpl.yaml +176 -0
  11. package/.aios-core/infrastructure/templates/core-config/core-config-greenfield.tmpl.yaml +127 -0
  12. package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -0
  13. package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -0
  14. package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -0
  15. package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -0
  16. package/.aios-core/infrastructure/templates/project-docs/coding-standards-tmpl.md +346 -0
  17. package/.aios-core/infrastructure/templates/project-docs/source-tree-tmpl.md +177 -0
  18. package/.aios-core/infrastructure/templates/project-docs/tech-stack-tmpl.md +267 -0
  19. package/package.json +1 -1
  20. package/packages/installer/src/config/templates/env-template.js +2 -2
  21. package/packages/installer/src/wizard/wizard.js +185 -34
  22. package/packages/installer/tests/integration/environment-configuration.test.js +2 -1
  23. package/packages/installer/tests/unit/env-template.test.js +3 -2
  24. package/.aios-core/development/tasks/validate-structure.md +0 -243
  25. package/.aios-core/infrastructure/scripts/source-tree-guardian/index.js +0 -375
  26. package/.aios-core/infrastructure/scripts/source-tree-guardian/manifest-generator.js +0 -410
  27. package/.aios-core/infrastructure/scripts/source-tree-guardian/rules/naming-rules.yaml +0 -285
  28. package/.aios-core/infrastructure/scripts/source-tree-guardian/rules/placement-rules.yaml +0 -262
  29. package/.aios-core/infrastructure/scripts/source-tree-guardian/validator.js +0 -468
@@ -1,46 +1,70 @@
1
1
  const { detectProjectType } = require('../detection/detect-project-type');
2
+ const {
3
+ detectInstallationMode,
4
+ getModeOptions,
5
+ validateModeSelection,
6
+ InstallationMode,
7
+ } = require('../../../../.aios-core/infrastructure/scripts/documentation-integrity/mode-detector');
2
8
 
3
9
  /**
4
10
  * Interactive Wizard for AIOS Installation
5
- *
6
- * This is a stub implementation that demonstrates the integration
7
- * with the project type detection module (Story 1.3).
8
- * Full wizard implementation is part of Story 1.2.
9
- *
11
+ *
12
+ * Supports three installation modes:
13
+ * - GREENFIELD: New project - generates all docs and config
14
+ * - BROWNFIELD: Existing project - analyzes and adapts
15
+ * - FRAMEWORK_DEV: Contributing to aios-core itself
16
+ *
10
17
  * @module wizard
18
+ * @version 2.0.0
19
+ * @story 6.9
11
20
  */
12
21
 
13
22
  /**
14
23
  * Run the interactive installer wizard
15
- *
24
+ *
16
25
  * @param {Object} options - Wizard options
17
26
  * @param {string} options.targetDir - Target directory for installation
27
+ * @param {string} options.mode - Pre-selected mode (skip detection)
18
28
  * @returns {Promise<Object>} Installation configuration
19
29
  */
20
30
  async function runWizard(options = {}) {
21
31
  const targetDir = options.targetDir || process.cwd();
22
-
32
+
23
33
  try {
24
- // Step 1: Welcome screen (Story 1.2)
34
+ // Step 1: Welcome screen
25
35
  console.log('🚀 Welcome to AIOS Installer\n');
26
-
27
- // Step 2: Detect project type (THIS STORY - Story 1.3)
28
- console.log('📊 Detecting project type...');
29
- const detectedType = detectProjectType(targetDir);
30
- console.log(`✅ Detected: ${detectedType}\n`);
31
-
32
- // Step 3: Confirm with user (Story 1.2)
33
- const confirmedType = await confirmProjectType(detectedType);
34
-
35
- // Step 4: Continue with installation (Stories 1.4-1.8)
36
+
37
+ // Step 2: Detect installation mode (Story 6.9)
38
+ console.log('📊 Analyzing project directory...');
39
+ const detected = detectInstallationMode(targetDir);
40
+ console.log(`✅ Detected: ${detected.mode} (${detected.reason})\n`);
41
+
42
+ // Step 3: Select installation mode (with user override)
43
+ const selectedMode = options.mode || (await selectInstallationMode(detected));
44
+
45
+ // Step 4: Validate selection
46
+ const validation = validateModeSelection(selectedMode, detected);
47
+ if (validation.warnings.length > 0) {
48
+ console.log('\n⚠️ Warnings:');
49
+ validation.warnings.forEach((w) => console.log(` - ${w}`));
50
+ console.log('');
51
+ }
52
+
53
+ // Step 5: Mode-specific configuration
54
+ const modeConfig = await configureModeSpecific(selectedMode, targetDir, detected);
55
+
56
+ // Step 6: Continue with installation (Stories 1.4-1.8)
36
57
  // - IDE Selection (Story 1.4)
37
58
  // - MCP Installation (Story 1.5)
38
59
  // - Environment Config (Story 1.6)
39
60
  // - Validation (Story 1.8)
40
-
61
+
41
62
  return {
42
- projectType: confirmedType,
63
+ projectType: detected.legacyType, // Backward compatibility
64
+ installationMode: selectedMode,
43
65
  targetDir,
66
+ detected,
67
+ modeConfig,
44
68
  // Other configuration will be added by downstream stories
45
69
  };
46
70
  } catch (error) {
@@ -49,29 +73,152 @@ async function runWizard(options = {}) {
49
73
  }
50
74
  }
51
75
 
76
+ /**
77
+ * Select installation mode with user input
78
+ *
79
+ * @param {Object} detected - Detection result from mode detector
80
+ * @returns {Promise<string>} Selected installation mode
81
+ */
82
+ async function selectInstallationMode(detected) {
83
+ const options = getModeOptions(detected);
84
+
85
+ console.log('Select installation type:\n');
86
+ options.forEach((opt, index) => {
87
+ const marker = opt.value === detected.mode ? '→' : ' ';
88
+ console.log(`${marker} ${index + 1}. ${opt.label}`);
89
+ console.log(` ${opt.hint}\n`);
90
+ });
91
+
92
+ // Stub: In real implementation, use @clack/prompts select()
93
+ // For now, return detected mode or first option
94
+ console.log(`(Using detected mode: ${detected.mode})`);
95
+ console.log('(Interactive selection via @clack/prompts in Story 1.2)\n');
96
+
97
+ return detected.mode !== InstallationMode.UNKNOWN ? detected.mode : InstallationMode.GREENFIELD;
98
+ }
99
+
100
+ /**
101
+ * Configure mode-specific settings
102
+ *
103
+ * @param {string} mode - Selected installation mode
104
+ * @param {string} targetDir - Target directory
105
+ * @param {Object} detected - Detection result
106
+ * @returns {Promise<Object>} Mode-specific configuration
107
+ */
108
+ async function configureModeSpecific(mode, _targetDir, _detected) {
109
+ const config = {
110
+ mode,
111
+ generateDocs: true,
112
+ generateConfig: true,
113
+ generateGitignore: true,
114
+ runSetupGithub: false,
115
+ deployment: null,
116
+ };
117
+
118
+ switch (mode) {
119
+ case InstallationMode.FRAMEWORK_DEV:
120
+ // Framework development - skip project setup
121
+ console.log('🔧 Framework Development Mode');
122
+ console.log(' → Using existing framework standards');
123
+ console.log(' → Skipping project documentation generation');
124
+ console.log(' → Skipping infrastructure setup\n');
125
+ config.generateDocs = false;
126
+ config.generateConfig = false;
127
+ config.generateGitignore = false;
128
+ break;
129
+
130
+ case InstallationMode.GREENFIELD:
131
+ // New project - full scaffolding
132
+ console.log('🆕 Greenfield Mode');
133
+ console.log(' → Will generate project documentation');
134
+ console.log(' → Will create project-specific core-config');
135
+ console.log(' → Will generate .gitignore based on tech stack');
136
+ console.log(' → Will offer *setup-github for infrastructure\n');
137
+ config.runSetupGithub = true;
138
+ // Deployment config will be elicited in Phase 3
139
+ config.deployment = await elicitDeploymentConfig();
140
+ break;
141
+
142
+ case InstallationMode.BROWNFIELD:
143
+ // Existing project - analyze and adapt
144
+ console.log('📂 Brownfield Mode');
145
+ console.log(' → Will analyze existing source tree');
146
+ console.log(' → Will detect existing coding standards');
147
+ console.log(' → Will merge with existing .gitignore');
148
+ console.log(' → Will analyze existing GitHub workflows\n');
149
+ // Deployment config will be elicited based on analysis in Phase 3
150
+ config.deployment = await elicitDeploymentConfig();
151
+ break;
152
+
153
+ default:
154
+ console.log('❓ Unknown mode - using greenfield defaults\n');
155
+ }
156
+
157
+ return config;
158
+ }
159
+
160
+ /**
161
+ * Elicit deployment configuration from user
162
+ * Implements Task 3.3 from Story 6.9
163
+ *
164
+ * @returns {Promise<Object>} Deployment configuration
165
+ */
166
+ async function elicitDeploymentConfig() {
167
+ // Stub implementation - will be fully implemented in Phase 3
168
+ console.log('📦 Deployment Configuration');
169
+ console.log(' (Full elicitation will be implemented in Phase 3)\n');
170
+
171
+ // Return default staging-first workflow
172
+ return {
173
+ workflow: 'staging-first',
174
+ branches: {
175
+ staging_targets: ['feature/*', 'fix/*', 'docs/*', 'chore/*', 'refactor/*', 'test/*'],
176
+ production_targets: ['hotfix/*'],
177
+ staging_branch: 'staging',
178
+ production_branch: 'main',
179
+ default_target: 'staging',
180
+ },
181
+ environments: {
182
+ staging: {
183
+ name: 'Staging',
184
+ auto_deploy: true,
185
+ platform: null, // To be detected/elicited
186
+ },
187
+ production: {
188
+ name: 'Production',
189
+ auto_deploy: true,
190
+ platform: null,
191
+ },
192
+ },
193
+ quality_gates: {
194
+ lint: true,
195
+ typecheck: true,
196
+ tests: true,
197
+ security_scan: false,
198
+ },
199
+ };
200
+ }
201
+
52
202
  /**
53
203
  * Confirm project type with user or allow override
54
- *
204
+ * @deprecated Use selectInstallationMode instead
205
+ *
55
206
  * @param {string} detectedType - Detected project type
56
207
  * @returns {Promise<string>} Confirmed project type
57
208
  */
58
209
  async function confirmProjectType(detectedType) {
59
- // Stub implementation - full implementation in Story 1.2
60
- // In real implementation, this would use @clack/prompts to ask user
61
-
210
+ // Kept for backward compatibility
62
211
  const typeDescriptions = {
63
- 'GREENFIELD': 'New project - AIOS will create complete structure',
64
- 'BROWNFIELD': 'Existing project - AIOS will integrate with current setup',
65
- 'EXISTING_AIOS': 'AIOS already installed - Would you like to update or reinstall?',
66
- 'UNKNOWN': 'Unknown project type - Manual selection required',
212
+ GREENFIELD: 'New project - AIOS will create complete structure',
213
+ BROWNFIELD: 'Existing project - AIOS will integrate with current setup',
214
+ EXISTING_AIOS: 'AIOS already installed - Would you like to update or reinstall?',
215
+ UNKNOWN: 'Unknown project type - Manual selection required',
67
216
  };
68
-
217
+
69
218
  console.log(`Project Type: ${detectedType}`);
70
219
  console.log(`Description: ${typeDescriptions[detectedType]}`);
71
- console.log('(Interactive confirmation will be added in Story 1.2)\n');
72
-
73
- // For now, return the detected type
74
- // Real implementation would prompt user to confirm or override
220
+ console.log('(Use selectInstallationMode for new three-mode selection)\n');
221
+
75
222
  return detectedType;
76
223
  }
77
224
 
@@ -87,7 +234,11 @@ function getProjectType(targetDir) {
87
234
 
88
235
  module.exports = {
89
236
  runWizard,
90
- confirmProjectType,
237
+ selectInstallationMode,
238
+ configureModeSpecific,
239
+ elicitDeploymentConfig,
240
+ confirmProjectType, // Deprecated - kept for backward compatibility
91
241
  getProjectType,
242
+ InstallationMode,
92
243
  };
93
244
 
@@ -9,6 +9,7 @@ const fs = require('fs-extra');
9
9
  const path = require('path');
10
10
  const os = require('os');
11
11
  const { configureEnvironment, updateGitignore } = require('../../src/config/configure-environment');
12
+ const pkg = require('../../../../package.json');
12
13
 
13
14
  /**
14
15
  * Cleanup helper with retry logic for flaky file system operations
@@ -72,7 +73,7 @@ describe('Environment Configuration Integration', () => {
72
73
 
73
74
  const content = await fs.readFile(envPath, 'utf8');
74
75
  expect(content).toContain('NODE_ENV=development');
75
- expect(content).toContain('AIOS_VERSION=2.1.0');
76
+ expect(content).toContain(`AIOS_VERSION=${pkg.version}`);
76
77
  });
77
78
 
78
79
  it('should create .env.example file', async () => {
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  const { generateEnvContent, generateEnvExample } = require('../../src/config/templates/env-template');
9
+ const pkg = require('../../../../package.json');
9
10
 
10
11
  describe('.env Template Generator', () => {
11
12
  describe('generateEnvContent', () => {
@@ -13,7 +14,7 @@ describe('.env Template Generator', () => {
13
14
  const content = generateEnvContent();
14
15
 
15
16
  expect(content).toContain('NODE_ENV=development');
16
- expect(content).toContain('AIOS_VERSION=2.1.0');
17
+ expect(content).toContain(`AIOS_VERSION=${pkg.version}`);
17
18
  expect(content).toContain('OPENAI_API_KEY=');
18
19
  expect(content).toContain('ANTHROPIC_API_KEY=');
19
20
  expect(content).toContain('# AIOS Environment Configuration');
@@ -83,7 +84,7 @@ describe('.env Template Generator', () => {
83
84
  const content = generateEnvExample();
84
85
 
85
86
  expect(content).toContain('NODE_ENV=development');
86
- expect(content).toContain('AIOS_VERSION=2.1.0');
87
+ expect(content).toContain(`AIOS_VERSION=${pkg.version}`);
87
88
  expect(content).toContain('OPENAI_API_KEY=');
88
89
  expect(content).toContain('ANTHROPIC_API_KEY=');
89
90
  expect(content).toContain('CLICKUP_API_KEY=');
@@ -1,243 +0,0 @@
1
- # validate-structure
2
-
3
- **Task ID:** validate-structure
4
- **Version:** 1.0.0
5
- **Agent:** @architect (Aria)
6
- **Story:** 6.8 - Source-Tree Guardian
7
-
8
- ---
9
-
10
- ## Purpose
11
-
12
- Validate file placement decisions against AIOS source-tree standards before implementation begins.
13
-
14
- **This task is MANDATORY for all stories that create new files.**
15
-
16
- ---
17
-
18
- ## When to Use
19
-
20
- - Before starting implementation of any story
21
- - When planning new modules or features
22
- - During architecture review
23
- - Before PR submission
24
-
25
- ---
26
-
27
- ## Prerequisites
28
-
29
- - Story file exists with implementation plan
30
- - Source-tree-guardian module installed
31
- - Access to `docs/architecture/source-tree.md`
32
-
33
- ---
34
-
35
- ## Execution
36
-
37
- ### Step 1: List New Files
38
-
39
- List all files that will be created in this story:
40
-
41
- | File | Purpose | Category |
42
- |------|---------|----------|
43
- | {path} | {purpose} | {agent/task/script/test/etc} |
44
-
45
- ### Step 2: Validate Each File
46
-
47
- For each file, run placement validation:
48
-
49
- ```bash
50
- npm run validate:structure -- --check "{file_path}"
51
- ```
52
-
53
- Or validate all planned files at once:
54
-
55
- ```bash
56
- npm run validate:structure -- --files "{glob_pattern}"
57
- ```
58
-
59
- ### Step 3: Document Decisions
60
-
61
- Add the following section to the story file:
62
-
63
- ```markdown
64
- ## Structure Validation
65
-
66
- | File | Validated Location | Approved |
67
- |------|-------------------|----------|
68
- | {file} | {location} | ✅/❌ |
69
-
70
- **Validated by:** @architect (Aria)
71
- **Date:** {YYYY-MM-DD}
72
- **Violations:** {count}
73
- **Notes:** {any special decisions}
74
- ```
75
-
76
- ### Step 4: Handle Violations
77
-
78
- If violations exist:
79
-
80
- 1. **Review the violation message** - Understand why the location is flagged
81
- 2. **Propose correct location** - Use suggested location or justify alternative
82
- 3. **Get PO approval** - If deviation from standard is needed
83
- 4. **Document reasoning** - Create ADR if significant deviation
84
- 5. **Update story** - Mark as resolved or approved exception
85
-
86
- ---
87
-
88
- ## Task Definition (YAML)
89
-
90
- ```yaml
91
- task: validateStructure()
92
- responsável: Aria (Architect)
93
- responsavel_type: Agente
94
- atomic_layer: Molecule
95
- elicit: true
96
-
97
- Entrada:
98
- - campo: story_files
99
- tipo: array
100
- origem: Story implementation plan
101
- obrigatório: true
102
- descrição: List of files to be created/modified
103
-
104
- - campo: story_path
105
- tipo: string
106
- origem: User input or context
107
- obrigatório: true
108
- descrição: Path to the story file
109
-
110
- Saída:
111
- - campo: placement_report
112
- tipo: object
113
- destino: Story file (## Structure Validation section)
114
- persistido: true
115
-
116
- - campo: violations
117
- tipo: array
118
- destino: Console output
119
- persistido: false
120
-
121
- Elicitation:
122
- - prompt: "What files will be created in this story?"
123
- type: list
124
- required: true
125
- help: "List each file with its full path"
126
-
127
- - prompt: "For each file, what is its purpose?"
128
- type: text
129
- required: true
130
- help: "Brief description of what each file does"
131
-
132
- - prompt: "What category does each file belong to?"
133
- type: select
134
- options:
135
- - agent
136
- - task
137
- - script
138
- - template
139
- - checklist
140
- - test
141
- - documentation
142
- - configuration
143
- - other
144
- required: true
145
- ```
146
-
147
- ---
148
-
149
- ## Checklist
150
-
151
- Use this checklist to ensure complete validation:
152
-
153
- - [ ] All new files have been listed
154
- - [ ] Each file has been validated against source-tree.md
155
- - [ ] Placement decisions are documented in story
156
- - [ ] Any violations have been resolved or approved
157
- - [ ] @architect sign-off is complete
158
- - [ ] Story "Structure Validation" section is populated
159
-
160
- ---
161
-
162
- ## CLI Commands Reference
163
-
164
- ```bash
165
- # Full validation
166
- npm run validate:structure
167
-
168
- # Check single file
169
- npm run validate:structure -- --check "path/to/file.js"
170
-
171
- # Check multiple files with glob
172
- npm run validate:structure -- --files "src/**/*.js"
173
-
174
- # Generate manifest
175
- npm run validate:structure -- --generate-manifest
176
-
177
- # Show suggestions for violations
178
- npm run validate:structure -- --fix
179
-
180
- # JSON output for automation
181
- npm run validate:structure -- --json
182
-
183
- # Verbose output
184
- npm run validate:structure -- --verbose
185
- ```
186
-
187
- ---
188
-
189
- ## Common Violations & Resolutions
190
-
191
- ### Scripts at Root Level
192
-
193
- **Violation:** `Scripts at root level are not allowed`
194
-
195
- **Resolution:**
196
- - Move to `.aios-core/infrastructure/scripts/{category}/`
197
- - Example: `scripts/foo.js` → `.aios-core/infrastructure/scripts/foo.js`
198
-
199
- ### Tools at Root Level
200
-
201
- **Violation:** `Tool definitions at root level are not allowed`
202
-
203
- **Resolution:**
204
- - Move to `.aios-core/infrastructure/tools/cli/` for CLI tools
205
- - Move to `.aios-core/infrastructure/tools/mcp/` for MCP tools
206
-
207
- ### Agents in Wrong Location
208
-
209
- **Violation:** `Agent files at root level are not allowed`
210
-
211
- **Resolution:**
212
- - Move to `.aios-core/development/agents/`
213
- - Ensure naming follows kebab-case: `{agent-name}.md`
214
-
215
- ### Tasks in Wrong Location
216
-
217
- **Violation:** `Task files at root level are not allowed`
218
-
219
- **Resolution:**
220
- - Move to `.aios-core/development/tasks/`
221
- - Ensure naming follows kebab-case: `{task-name}.md`
222
-
223
- ---
224
-
225
- ## Integration Points
226
-
227
- - **Pre-commit Hook:** Runs automatically on `git commit`
228
- - **CI/CD Pipeline:** Can be integrated with `npm run validate:structure -- --json`
229
- - **Story Workflow:** Executed by @architect before @dev implementation
230
-
231
- ---
232
-
233
- ## Related Resources
234
-
235
- - [Source Tree Structure](../../docs/architecture/source-tree.md)
236
- - [Coding Standards](../../docs/architecture/coding-standards.md)
237
- - [Story 6.8: Source-Tree Guardian](../../docs/stories/v2.1/sprint-6/story-6.8-source-tree-guardian.md)
238
-
239
- ---
240
-
241
- **Created:** 2025-12-14
242
- **Author:** @architect (Aria)
243
- **Story:** 6.8 - Source-Tree Guardian