@atlasnomos/atlas 1.1.5 → 1.1.9
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.
- package/atlas.js +1 -1
- package/package.json +2 -1
- package/src/interface/cli/commands/InitCommand.js +124 -28
package/atlas.js
CHANGED
|
@@ -117,7 +117,7 @@ const { ModelsCommand } = require('./src/interface/cli/commands/ModelsCommand');
|
|
|
117
117
|
|
|
118
118
|
// PHASE 4: Setup Flow Interception
|
|
119
119
|
const command = rawArgs[0] || 'doctor';
|
|
120
|
-
const isSetupCommand = ['init', 'help', '--help', '-h', '--version', '-v'].includes(command);
|
|
120
|
+
const isSetupCommand = ['init', 'help', '--help', '-h', '--version', '-v', 'config'].includes(command);
|
|
121
121
|
|
|
122
122
|
let context;
|
|
123
123
|
if (isSetupCommand) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasnomos/atlas",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Production-grade AI governance kernel for autonomous agents with fail-closed security and cryptographic audit trails",
|
|
5
5
|
"main": "atlas.js",
|
|
6
6
|
"bin": {
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/express": "5.0.6",
|
|
83
|
+
"@types/node": "^18.19.74",
|
|
83
84
|
"@types/node-fetch": "2.6.13",
|
|
84
85
|
"axios-mock-adapter": "1.22.0",
|
|
85
86
|
"chai": "4.3.10",
|
|
@@ -1,49 +1,145 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ATLAS V1 — Init Command
|
|
3
|
-
* Initialized Model Configuration Plane
|
|
2
|
+
* ATLAS V1 — Init Command (Interactive)
|
|
3
|
+
* Initialized Model Configuration Plane and Environment setup
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const path = require('path');
|
|
8
|
+
const { Input, Password } = require('enquirer');
|
|
8
9
|
|
|
9
10
|
class InitCommand {
|
|
10
11
|
constructor() { }
|
|
11
12
|
|
|
12
13
|
async execute(args) {
|
|
13
|
-
console.log('
|
|
14
|
+
console.log('\n╔═══════════════════════════════════════════════════════════════╗');
|
|
15
|
+
console.log('║ ATLAS Governance Kernel — Setup Wizard ║');
|
|
16
|
+
console.log('╚═══════════════════════════════════════════════════════════════╝\n');
|
|
14
17
|
|
|
15
|
-
const
|
|
18
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
19
|
+
const modelsPath = path.join(process.cwd(), 'atlas.models.json');
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
// 1. Collect API Keys
|
|
22
|
+
console.log(' [1/3] Configuring Provider Credentials...');
|
|
23
|
+
|
|
24
|
+
let existingEnv = {};
|
|
25
|
+
if (fs.existsSync(envPath)) {
|
|
26
|
+
const content = fs.readFileSync(envPath, 'utf8');
|
|
27
|
+
content.split('\n').forEach(line => {
|
|
28
|
+
const [k, v] = line.split('=');
|
|
29
|
+
if (k) existingEnv[k.trim()] = (v || '').trim();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const keys = {
|
|
34
|
+
OPENROUTER_API_KEY: await new Password({
|
|
35
|
+
message: 'Enter OpenRouter API Key (Recommended)',
|
|
36
|
+
initial: existingEnv.OPENROUTER_API_KEY || ''
|
|
37
|
+
}).run(),
|
|
38
|
+
ANTHROPIC_API_KEY: await new Password({
|
|
39
|
+
message: 'Enter Anthropic API Key (Optional)',
|
|
40
|
+
initial: existingEnv.ANTHROPIC_API_KEY || ''
|
|
41
|
+
}).run(),
|
|
42
|
+
OPENAI_API_KEY: await new Password({
|
|
43
|
+
message: 'Enter OpenAI API Key (Optional)',
|
|
44
|
+
initial: existingEnv.OPENAI_API_KEY || ''
|
|
45
|
+
}).run()
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// 2. Save .env
|
|
49
|
+
let envContent = '# ATLAS Environment Configuration\n';
|
|
50
|
+
for (const [k, v] of Object.entries(keys)) {
|
|
51
|
+
if (v) envContent += `${k}=${v}\n`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Preserve other env vars
|
|
55
|
+
for (const [k, v] of Object.entries(existingEnv)) {
|
|
56
|
+
if (!keys.hasOwnProperty(k)) {
|
|
57
|
+
envContent += `${k}=${v}\n`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fs.writeFileSync(envPath, envContent, 'utf8');
|
|
62
|
+
console.log(' ✓ Saved .env');
|
|
63
|
+
|
|
64
|
+
// 3. Configure Roles
|
|
65
|
+
console.log('\n [2/3] Initializing Mandatory Role Bindings...');
|
|
66
|
+
|
|
67
|
+
const template = {
|
|
68
|
+
"version": "1.0",
|
|
69
|
+
"default_provider": keys.OPENROUTER_API_KEY ? "openrouter" : "anthropic",
|
|
70
|
+
"roles": {
|
|
71
|
+
"planner": {
|
|
72
|
+
"model": "anthropic/claude-3.5-sonnet",
|
|
73
|
+
"temperature": 0.1,
|
|
74
|
+
"max_tokens": 4096,
|
|
75
|
+
"risk_limit": 1
|
|
36
76
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
77
|
+
"generator": {
|
|
78
|
+
"model": "anthropic/claude-3.5-sonnet",
|
|
79
|
+
"temperature": 0.2,
|
|
80
|
+
"max_tokens": 4096,
|
|
81
|
+
"risk_limit": 2
|
|
82
|
+
},
|
|
83
|
+
"reviewer": {
|
|
84
|
+
"model": "openai/gpt-4o",
|
|
85
|
+
"temperature": 0.1,
|
|
86
|
+
"max_tokens": 2048,
|
|
87
|
+
"risk_limit": 1
|
|
88
|
+
},
|
|
89
|
+
"fixer": {
|
|
90
|
+
"model": "anthropic/claude-3.5-sonnet",
|
|
91
|
+
"temperature": 0.1,
|
|
92
|
+
"max_tokens": 4096,
|
|
93
|
+
"risk_limit": 1
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"overrides": {
|
|
97
|
+
"ENV_DEVELOPMENT": true
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (fs.existsSync(modelsPath)) {
|
|
102
|
+
console.log(' ⚠ atlas.models.json already exists. Checking for missing mandatory roles...');
|
|
103
|
+
try {
|
|
104
|
+
const existingContent = JSON.parse(fs.readFileSync(modelsPath, 'utf8'));
|
|
105
|
+
let updated = false;
|
|
106
|
+
|
|
107
|
+
if (!existingContent.roles) existingContent.roles = {};
|
|
108
|
+
|
|
109
|
+
const mandatoryRoles = ['planner', 'generator', 'reviewer', 'fixer'];
|
|
110
|
+
for (const role of mandatoryRoles) {
|
|
111
|
+
if (!existingContent.roles[role]) {
|
|
112
|
+
console.log(` + Adding missing mandatory role: ${role}`);
|
|
113
|
+
existingContent.roles[role] = template.roles[role];
|
|
114
|
+
updated = true;
|
|
115
|
+
}
|
|
39
116
|
}
|
|
40
|
-
};
|
|
41
117
|
|
|
42
|
-
|
|
118
|
+
if (updated) {
|
|
119
|
+
fs.writeFileSync(modelsPath, JSON.stringify(existingContent, null, 4), 'utf8');
|
|
120
|
+
console.log(' ✓ Healed atlas.models.json with missing roles.');
|
|
121
|
+
} else {
|
|
122
|
+
console.log(' ✓ All mandatory roles are present.');
|
|
123
|
+
}
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.error(` ⛔ Failed to parse or update existing atlas.models.json: ${e.message}`);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
fs.writeFileSync(modelsPath, JSON.stringify(template, null, 4), 'utf8');
|
|
43
129
|
console.log(' ✓ Created atlas.models.json');
|
|
44
130
|
}
|
|
45
131
|
|
|
46
|
-
|
|
132
|
+
// 4. Finalize
|
|
133
|
+
console.log('\n [3/3] Finalizing Workspace...');
|
|
134
|
+
const logsDir = path.join(process.cwd(), '.atlas', 'logs');
|
|
135
|
+
if (!fs.existsSync(logsDir)) {
|
|
136
|
+
fs.mkdirSync(logsDir, { recursive: true });
|
|
137
|
+
}
|
|
138
|
+
console.log(' ✓ Initialized .atlas/ directory');
|
|
139
|
+
|
|
140
|
+
console.log('\n ✨ ATLAS Initialization Complete!');
|
|
141
|
+
console.log(' Run "atlas doctor" to verify your connection.\n');
|
|
142
|
+
|
|
47
143
|
return true;
|
|
48
144
|
}
|
|
49
145
|
}
|