@ariacode/cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +404 -0
- package/dist/actions.d.ts +271 -0
- package/dist/actions.js +1809 -0
- package/dist/actions.js.map +1 -0
- package/dist/agent.d.ts +26 -0
- package/dist/agent.js +182 -0
- package/dist/agent.js.map +1 -0
- package/dist/app.d.ts +14 -0
- package/dist/app.js +83 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.js +157 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +170 -0
- package/dist/config.js +291 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +58 -0
- package/dist/context.js +44 -0
- package/dist/context.js.map +1 -0
- package/dist/parser.d.ts +39 -0
- package/dist/parser.js +323 -0
- package/dist/parser.js.map +1 -0
- package/dist/prompts/ask.md +20 -0
- package/dist/prompts/explore.md +38 -0
- package/dist/prompts/patch.md +27 -0
- package/dist/prompts/plan.md +41 -0
- package/dist/prompts/prompts/ask.md +20 -0
- package/dist/prompts/prompts/explore.md +38 -0
- package/dist/prompts/prompts/patch.md +27 -0
- package/dist/prompts/prompts/plan.md +41 -0
- package/dist/prompts/prompts/review.md +33 -0
- package/dist/prompts/review.md +33 -0
- package/dist/provider.d.ts +148 -0
- package/dist/provider.js +486 -0
- package/dist/provider.js.map +1 -0
- package/dist/repo.d.ts +22 -0
- package/dist/repo.js +154 -0
- package/dist/repo.js.map +1 -0
- package/dist/safety.d.ts +48 -0
- package/dist/safety.js +140 -0
- package/dist/safety.js.map +1 -0
- package/dist/storage.d.ts +133 -0
- package/dist/storage.js +300 -0
- package/dist/storage.js.map +1 -0
- package/dist/tools.d.ts +70 -0
- package/dist/tools.js +654 -0
- package/dist/tools.js.map +1 -0
- package/dist/ui.d.ts +203 -0
- package/dist/ui.js +410 -0
- package/dist/ui.js.map +1 -0
- package/package.json +73 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Provider configuration
|
|
4
|
+
* Supports Anthropic, OpenAI, Ollama, and OpenRouter
|
|
5
|
+
*/
|
|
6
|
+
export declare const ProviderConfigSchema: z.ZodObject<{
|
|
7
|
+
default: z.ZodDefault<z.ZodEnum<{
|
|
8
|
+
anthropic: "anthropic";
|
|
9
|
+
openai: "openai";
|
|
10
|
+
ollama: "ollama";
|
|
11
|
+
openrouter: "openrouter";
|
|
12
|
+
}>>;
|
|
13
|
+
model: z.ZodDefault<z.ZodString>;
|
|
14
|
+
maxTokens: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type ProviderConfig = z.infer<typeof ProviderConfigSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* Agent configuration
|
|
19
|
+
* Controls agent loop behavior and execution mode
|
|
20
|
+
*/
|
|
21
|
+
export declare const AgentConfigSchema: z.ZodObject<{
|
|
22
|
+
maxIterations: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
24
|
+
plan: "plan";
|
|
25
|
+
build: "build";
|
|
26
|
+
}>>;
|
|
27
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type AgentConfig = z.infer<typeof AgentConfigSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Safety configuration
|
|
32
|
+
* Enforces boundaries and resource limits
|
|
33
|
+
*/
|
|
34
|
+
export declare const SafetyConfigSchema: z.ZodObject<{
|
|
35
|
+
requireConfirmForShell: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
+
allowedShellCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
37
|
+
maxFileSizeKb: z.ZodDefault<z.ZodNumber>;
|
|
38
|
+
maxFilesPerPatch: z.ZodDefault<z.ZodNumber>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type SafetyConfig = z.infer<typeof SafetyConfigSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* UI configuration
|
|
43
|
+
* Controls terminal output formatting
|
|
44
|
+
*/
|
|
45
|
+
export declare const UIConfigSchema: z.ZodObject<{
|
|
46
|
+
color: z.ZodDefault<z.ZodEnum<{
|
|
47
|
+
never: "never";
|
|
48
|
+
auto: "auto";
|
|
49
|
+
always: "always";
|
|
50
|
+
}>>;
|
|
51
|
+
quiet: z.ZodDefault<z.ZodBoolean>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export type UIConfig = z.infer<typeof UIConfigSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* History configuration
|
|
56
|
+
* Controls session retention policy
|
|
57
|
+
*/
|
|
58
|
+
export declare const HistoryConfigSchema: z.ZodObject<{
|
|
59
|
+
retainDays: z.ZodDefault<z.ZodNumber>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type HistoryConfig = z.infer<typeof HistoryConfigSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* Complete configuration schema
|
|
64
|
+
* Combines all configuration sections
|
|
65
|
+
*/
|
|
66
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
67
|
+
provider: z.ZodObject<{
|
|
68
|
+
default: z.ZodDefault<z.ZodEnum<{
|
|
69
|
+
anthropic: "anthropic";
|
|
70
|
+
openai: "openai";
|
|
71
|
+
ollama: "ollama";
|
|
72
|
+
openrouter: "openrouter";
|
|
73
|
+
}>>;
|
|
74
|
+
model: z.ZodDefault<z.ZodString>;
|
|
75
|
+
maxTokens: z.ZodDefault<z.ZodNumber>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
agent: z.ZodObject<{
|
|
78
|
+
maxIterations: z.ZodDefault<z.ZodNumber>;
|
|
79
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
80
|
+
plan: "plan";
|
|
81
|
+
build: "build";
|
|
82
|
+
}>>;
|
|
83
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
safety: z.ZodObject<{
|
|
86
|
+
requireConfirmForShell: z.ZodDefault<z.ZodBoolean>;
|
|
87
|
+
allowedShellCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
88
|
+
maxFileSizeKb: z.ZodDefault<z.ZodNumber>;
|
|
89
|
+
maxFilesPerPatch: z.ZodDefault<z.ZodNumber>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
ui: z.ZodObject<{
|
|
92
|
+
color: z.ZodDefault<z.ZodEnum<{
|
|
93
|
+
never: "never";
|
|
94
|
+
auto: "auto";
|
|
95
|
+
always: "always";
|
|
96
|
+
}>>;
|
|
97
|
+
quiet: z.ZodDefault<z.ZodBoolean>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
history: z.ZodObject<{
|
|
100
|
+
retainDays: z.ZodDefault<z.ZodNumber>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
104
|
+
/**
|
|
105
|
+
* Configuration error with context
|
|
106
|
+
*/
|
|
107
|
+
export declare class ConfigError extends Error {
|
|
108
|
+
readonly source?: string | undefined;
|
|
109
|
+
readonly cause?: unknown | undefined;
|
|
110
|
+
constructor(message: string, source?: string | undefined, cause?: unknown | undefined);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Parse a TOML configuration file
|
|
114
|
+
* @param filePath - Path to the TOML file
|
|
115
|
+
* @returns Parsed configuration object
|
|
116
|
+
* @throws ConfigError if file cannot be read or parsed
|
|
117
|
+
*/
|
|
118
|
+
export declare function parseConfigFile(filePath: string): unknown;
|
|
119
|
+
/**
|
|
120
|
+
* Configuration source for precedence tracking
|
|
121
|
+
*/
|
|
122
|
+
export interface ConfigSource {
|
|
123
|
+
provider?: Partial<ProviderConfig>;
|
|
124
|
+
agent?: Partial<AgentConfig>;
|
|
125
|
+
safety?: Partial<SafetyConfig>;
|
|
126
|
+
ui?: Partial<UIConfig>;
|
|
127
|
+
history?: Partial<HistoryConfig>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* CLI flags that can override configuration
|
|
131
|
+
*/
|
|
132
|
+
export interface CLIFlags {
|
|
133
|
+
dryRun?: boolean;
|
|
134
|
+
assumeYes?: boolean;
|
|
135
|
+
quiet?: boolean;
|
|
136
|
+
maxTokens?: number;
|
|
137
|
+
mode?: "plan" | "build";
|
|
138
|
+
color?: "auto" | "always" | "never";
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Load and merge configuration from all sources with correct precedence
|
|
142
|
+
* Precedence order (highest to lowest):
|
|
143
|
+
* 1. CLI flags
|
|
144
|
+
* 2. Environment variables
|
|
145
|
+
* 3. Project config (./.aria.toml)
|
|
146
|
+
* 4. User config (~/.aria/config.toml)
|
|
147
|
+
* 5. Defaults (from zod schemas)
|
|
148
|
+
*
|
|
149
|
+
* @param projectRoot - Project root directory for loading ./.aria.toml
|
|
150
|
+
* @param flags - CLI flags
|
|
151
|
+
* @returns Merged configuration from all sources
|
|
152
|
+
*/
|
|
153
|
+
export declare function loadConfig(projectRoot: string, flags?: CLIFlags): ConfigSource;
|
|
154
|
+
/**
|
|
155
|
+
* Validate and normalize configuration
|
|
156
|
+
* @param config - Raw configuration from all sources
|
|
157
|
+
* @returns Validated and normalized configuration
|
|
158
|
+
* @throws ConfigError if validation fails
|
|
159
|
+
*/
|
|
160
|
+
export declare function validateConfig(config: ConfigSource): Config;
|
|
161
|
+
/**
|
|
162
|
+
* Load, merge, and validate configuration from all sources
|
|
163
|
+
* This is the main entry point for configuration loading
|
|
164
|
+
*
|
|
165
|
+
* @param projectRoot - Project root directory
|
|
166
|
+
* @param flags - CLI flags
|
|
167
|
+
* @returns Validated configuration
|
|
168
|
+
* @throws ConfigError if loading or validation fails
|
|
169
|
+
*/
|
|
170
|
+
export declare function getConfig(projectRoot: string, flags?: CLIFlags): Config;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ExecutionModeSchema } from "./context.js";
|
|
3
|
+
import { parse as parseToml } from "smol-toml";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import * as os from "node:os";
|
|
7
|
+
/**
|
|
8
|
+
* Provider configuration
|
|
9
|
+
* Supports Anthropic, OpenAI, Ollama, and OpenRouter
|
|
10
|
+
*/
|
|
11
|
+
export const ProviderConfigSchema = z.object({
|
|
12
|
+
default: z
|
|
13
|
+
.enum(["anthropic", "openai", "ollama", "openrouter"])
|
|
14
|
+
.default("anthropic"),
|
|
15
|
+
model: z.string().default("claude-sonnet-4-6"),
|
|
16
|
+
maxTokens: z.number().int().positive().default(4096),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Agent configuration
|
|
20
|
+
* Controls agent loop behavior and execution mode
|
|
21
|
+
*/
|
|
22
|
+
export const AgentConfigSchema = z.object({
|
|
23
|
+
maxIterations: z.number().int().positive().default(25),
|
|
24
|
+
mode: ExecutionModeSchema.default("build"),
|
|
25
|
+
timeoutSeconds: z.number().int().positive().default(120),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Safety configuration
|
|
29
|
+
* Enforces boundaries and resource limits
|
|
30
|
+
*/
|
|
31
|
+
export const SafetyConfigSchema = z.object({
|
|
32
|
+
requireConfirmForShell: z.boolean().default(true),
|
|
33
|
+
allowedShellCommands: z
|
|
34
|
+
.array(z.string())
|
|
35
|
+
.default(["npm", "pnpm", "yarn", "npx", "git", "prisma", "tsc", "node"]),
|
|
36
|
+
maxFileSizeKb: z.number().int().positive().default(1024),
|
|
37
|
+
maxFilesPerPatch: z.number().int().positive().default(50),
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* UI configuration
|
|
41
|
+
* Controls terminal output formatting
|
|
42
|
+
*/
|
|
43
|
+
export const UIConfigSchema = z.object({
|
|
44
|
+
color: z.enum(["auto", "always", "never"]).default("auto"),
|
|
45
|
+
quiet: z.boolean().default(false),
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* History configuration
|
|
49
|
+
* Controls session retention policy
|
|
50
|
+
*/
|
|
51
|
+
export const HistoryConfigSchema = z.object({
|
|
52
|
+
retainDays: z.number().int().positive().default(90),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Complete configuration schema
|
|
56
|
+
* Combines all configuration sections
|
|
57
|
+
*/
|
|
58
|
+
export const ConfigSchema = z.object({
|
|
59
|
+
provider: ProviderConfigSchema,
|
|
60
|
+
agent: AgentConfigSchema,
|
|
61
|
+
safety: SafetyConfigSchema,
|
|
62
|
+
ui: UIConfigSchema,
|
|
63
|
+
history: HistoryConfigSchema,
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Configuration error with context
|
|
67
|
+
*/
|
|
68
|
+
export class ConfigError extends Error {
|
|
69
|
+
source;
|
|
70
|
+
cause;
|
|
71
|
+
constructor(message, source, cause) {
|
|
72
|
+
super(message);
|
|
73
|
+
this.source = source;
|
|
74
|
+
this.cause = cause;
|
|
75
|
+
this.name = "ConfigError";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse a TOML configuration file
|
|
80
|
+
* @param filePath - Path to the TOML file
|
|
81
|
+
* @returns Parsed configuration object
|
|
82
|
+
* @throws ConfigError if file cannot be read or parsed
|
|
83
|
+
*/
|
|
84
|
+
export function parseConfigFile(filePath) {
|
|
85
|
+
try {
|
|
86
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
87
|
+
return parseToml(content);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof Error) {
|
|
91
|
+
// Check if it's a file not found error
|
|
92
|
+
if ("code" in error && error.code === "ENOENT") {
|
|
93
|
+
throw new ConfigError(`Configuration file not found: ${filePath}`, filePath, error);
|
|
94
|
+
}
|
|
95
|
+
// Check if it's a TOML parse error
|
|
96
|
+
if (error.message.includes("TOML") || error.message.includes("parse")) {
|
|
97
|
+
throw new ConfigError(`Invalid TOML syntax in ${filePath}: ${error.message}`, filePath, error);
|
|
98
|
+
}
|
|
99
|
+
// Generic error
|
|
100
|
+
throw new ConfigError(`Failed to read configuration file ${filePath}: ${error.message}`, filePath, error);
|
|
101
|
+
}
|
|
102
|
+
throw new ConfigError(`Unknown error reading configuration file ${filePath}`, filePath, error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Load configuration from a TOML file if it exists
|
|
107
|
+
* @param filePath - Path to the TOML file
|
|
108
|
+
* @returns Parsed configuration or empty object if file doesn't exist
|
|
109
|
+
*/
|
|
110
|
+
function loadConfigFile(filePath) {
|
|
111
|
+
try {
|
|
112
|
+
if (!fs.existsSync(filePath)) {
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
const parsed = parseConfigFile(filePath);
|
|
116
|
+
return parsed;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (error instanceof ConfigError && error.cause) {
|
|
120
|
+
const cause = error.cause;
|
|
121
|
+
if (cause.code === "ENOENT") {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Load configuration from environment variables
|
|
130
|
+
* @returns Configuration from environment variables
|
|
131
|
+
*/
|
|
132
|
+
function loadEnvironmentConfig() {
|
|
133
|
+
const config = {};
|
|
134
|
+
// Provider configuration
|
|
135
|
+
const validProviders = ["anthropic", "openai", "ollama", "openrouter"];
|
|
136
|
+
if (process.env.ARIA_PROVIDER) {
|
|
137
|
+
const p = process.env.ARIA_PROVIDER;
|
|
138
|
+
if (validProviders.includes(p)) {
|
|
139
|
+
config.provider = { default: p };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (process.env.ARIA_MODEL) {
|
|
143
|
+
config.provider = { ...config.provider, model: process.env.ARIA_MODEL };
|
|
144
|
+
}
|
|
145
|
+
if (process.env.ARIA_MAX_TOKENS) {
|
|
146
|
+
const maxTokens = parseInt(process.env.ARIA_MAX_TOKENS, 10);
|
|
147
|
+
if (!isNaN(maxTokens)) {
|
|
148
|
+
config.provider = { ...config.provider, maxTokens };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Agent configuration
|
|
152
|
+
if (process.env.ARIA_MAX_ITERATIONS) {
|
|
153
|
+
const maxIterations = parseInt(process.env.ARIA_MAX_ITERATIONS, 10);
|
|
154
|
+
if (!isNaN(maxIterations)) {
|
|
155
|
+
config.agent = { maxIterations };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (process.env.ARIA_TIMEOUT_SECONDS) {
|
|
159
|
+
const timeoutSeconds = parseInt(process.env.ARIA_TIMEOUT_SECONDS, 10);
|
|
160
|
+
if (!isNaN(timeoutSeconds)) {
|
|
161
|
+
config.agent = { ...config.agent, timeoutSeconds };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// UI configuration
|
|
165
|
+
const validColorModes = ["auto", "always", "never"];
|
|
166
|
+
if (process.env.ARIA_COLOR) {
|
|
167
|
+
const c = process.env.ARIA_COLOR;
|
|
168
|
+
if (validColorModes.includes(c)) {
|
|
169
|
+
config.ui = { color: c };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (process.env.ARIA_QUIET) {
|
|
173
|
+
config.ui = { ...config.ui, quiet: process.env.ARIA_QUIET === "true" };
|
|
174
|
+
}
|
|
175
|
+
// History configuration
|
|
176
|
+
if (process.env.ARIA_RETAIN_DAYS) {
|
|
177
|
+
const retainDays = parseInt(process.env.ARIA_RETAIN_DAYS, 10);
|
|
178
|
+
if (!isNaN(retainDays)) {
|
|
179
|
+
config.history = { retainDays };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return config;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Convert CLI flags to configuration overrides
|
|
186
|
+
* @param flags - CLI flags
|
|
187
|
+
* @returns Configuration from CLI flags
|
|
188
|
+
*/
|
|
189
|
+
function flagsToConfig(flags) {
|
|
190
|
+
const config = {};
|
|
191
|
+
if (flags.maxTokens !== undefined) {
|
|
192
|
+
config.provider = { maxTokens: flags.maxTokens };
|
|
193
|
+
}
|
|
194
|
+
if (flags.mode !== undefined) {
|
|
195
|
+
config.agent = { mode: flags.mode };
|
|
196
|
+
}
|
|
197
|
+
if (flags.quiet !== undefined) {
|
|
198
|
+
config.ui = { quiet: flags.quiet };
|
|
199
|
+
}
|
|
200
|
+
if (flags.color !== undefined) {
|
|
201
|
+
config.ui = { ...config.ui, color: flags.color };
|
|
202
|
+
}
|
|
203
|
+
return config;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Deep merge two configuration sources
|
|
207
|
+
* Later source takes precedence for defined values
|
|
208
|
+
*/
|
|
209
|
+
function mergeConfigSources(base, override) {
|
|
210
|
+
return {
|
|
211
|
+
provider: { ...base.provider, ...override.provider },
|
|
212
|
+
agent: { ...base.agent, ...override.agent },
|
|
213
|
+
safety: { ...base.safety, ...override.safety },
|
|
214
|
+
ui: { ...base.ui, ...override.ui },
|
|
215
|
+
history: { ...base.history, ...override.history },
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Load and merge configuration from all sources with correct precedence
|
|
220
|
+
* Precedence order (highest to lowest):
|
|
221
|
+
* 1. CLI flags
|
|
222
|
+
* 2. Environment variables
|
|
223
|
+
* 3. Project config (./.aria.toml)
|
|
224
|
+
* 4. User config (~/.aria/config.toml)
|
|
225
|
+
* 5. Defaults (from zod schemas)
|
|
226
|
+
*
|
|
227
|
+
* @param projectRoot - Project root directory for loading ./.aria.toml
|
|
228
|
+
* @param flags - CLI flags
|
|
229
|
+
* @returns Merged configuration from all sources
|
|
230
|
+
*/
|
|
231
|
+
export function loadConfig(projectRoot, flags = {}) {
|
|
232
|
+
// Load from all sources
|
|
233
|
+
const userConfigPath = path.join(os.homedir(), ".aria", "config.toml");
|
|
234
|
+
const projectConfigPath = path.join(projectRoot, ".aria.toml");
|
|
235
|
+
const userConfig = loadConfigFile(userConfigPath);
|
|
236
|
+
const projectConfig = loadConfigFile(projectConfigPath);
|
|
237
|
+
const envConfig = loadEnvironmentConfig();
|
|
238
|
+
const flagConfig = flagsToConfig(flags);
|
|
239
|
+
// Merge with correct precedence (later overrides earlier)
|
|
240
|
+
let merged = {};
|
|
241
|
+
merged = mergeConfigSources(merged, userConfig);
|
|
242
|
+
merged = mergeConfigSources(merged, projectConfig);
|
|
243
|
+
merged = mergeConfigSources(merged, envConfig);
|
|
244
|
+
merged = mergeConfigSources(merged, flagConfig);
|
|
245
|
+
return merged;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Validate and normalize configuration
|
|
249
|
+
* @param config - Raw configuration from all sources
|
|
250
|
+
* @returns Validated and normalized configuration
|
|
251
|
+
* @throws ConfigError if validation fails
|
|
252
|
+
*/
|
|
253
|
+
export function validateConfig(config) {
|
|
254
|
+
try {
|
|
255
|
+
// Ensure all top-level sections are present as objects so Zod can apply
|
|
256
|
+
// nested defaults. Zod v4 does not apply defaults when the parent key is
|
|
257
|
+
// undefined — we must provide at least an empty object for each section.
|
|
258
|
+
const normalized = {
|
|
259
|
+
provider: config.provider ?? {},
|
|
260
|
+
agent: config.agent ?? {},
|
|
261
|
+
safety: config.safety ?? {},
|
|
262
|
+
ui: config.ui ?? {},
|
|
263
|
+
history: config.history ?? {},
|
|
264
|
+
};
|
|
265
|
+
const validated = ConfigSchema.parse(normalized);
|
|
266
|
+
return validated;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
if (error instanceof z.ZodError) {
|
|
270
|
+
const issues = error.issues
|
|
271
|
+
.map((issue) => ` - ${issue.path.join(".")}: ${issue.message}`)
|
|
272
|
+
.join("\n");
|
|
273
|
+
throw new ConfigError(`Configuration validation failed:\n${issues}`, undefined, error);
|
|
274
|
+
}
|
|
275
|
+
throw new ConfigError("Unknown configuration validation error", undefined, error);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Load, merge, and validate configuration from all sources
|
|
280
|
+
* This is the main entry point for configuration loading
|
|
281
|
+
*
|
|
282
|
+
* @param projectRoot - Project root directory
|
|
283
|
+
* @param flags - CLI flags
|
|
284
|
+
* @returns Validated configuration
|
|
285
|
+
* @throws ConfigError if loading or validation fails
|
|
286
|
+
*/
|
|
287
|
+
export function getConfig(projectRoot, flags = {}) {
|
|
288
|
+
const merged = loadConfig(projectRoot, flags);
|
|
289
|
+
return validateConfig(merged);
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC;SACP,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;SACrD,OAAO,CAAC,WAAW,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC;IA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AC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;iBACxB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;iBAC/D,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,MAAM,IAAI,WAAW,CACnB,qCAAqC,MAAM,EAAE,EAC7C,SAAS,EACT,KAAK,CACN,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,WAAW,CACnB,wCAAwC,EACxC,SAAS,EACT,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,WAAmB,EAAE,QAAkB,EAAE;IACjE,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Execution mode determines which tools are available
|
|
4
|
+
* - plan: Read-only mode, no mutations allowed
|
|
5
|
+
* - build: Normal mode, mutations allowed with confirmation
|
|
6
|
+
*/
|
|
7
|
+
export declare const ExecutionModeSchema: z.ZodEnum<{
|
|
8
|
+
plan: "plan";
|
|
9
|
+
build: "build";
|
|
10
|
+
}>;
|
|
11
|
+
export type ExecutionMode = z.infer<typeof ExecutionModeSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* ExecutionContext is passed to all commands and tools
|
|
14
|
+
* Enforces safety boundaries and execution mode
|
|
15
|
+
*/
|
|
16
|
+
export declare const ExecutionContextSchema: z.ZodObject<{
|
|
17
|
+
projectRoot: z.ZodString;
|
|
18
|
+
sessionId: z.ZodString;
|
|
19
|
+
provider: z.ZodString;
|
|
20
|
+
model: z.ZodString;
|
|
21
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
22
|
+
plan: "plan";
|
|
23
|
+
build: "build";
|
|
24
|
+
}>>;
|
|
25
|
+
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
assumeYes: z.ZodDefault<z.ZodBoolean>;
|
|
27
|
+
maxIterations: z.ZodDefault<z.ZodNumber>;
|
|
28
|
+
timeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type ExecutionContext = z.infer<typeof ExecutionContextSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Risk level for mutations
|
|
33
|
+
*/
|
|
34
|
+
export declare const RiskLevelSchema: z.ZodEnum<{
|
|
35
|
+
low: "low";
|
|
36
|
+
medium: "medium";
|
|
37
|
+
high: "high";
|
|
38
|
+
}>;
|
|
39
|
+
export type RiskLevel = z.infer<typeof RiskLevelSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* MutationSummary provides a preview of changes before execution
|
|
42
|
+
* Every mutation must produce this summary for user review
|
|
43
|
+
*/
|
|
44
|
+
export declare const MutationSummarySchema: z.ZodObject<{
|
|
45
|
+
action: z.ZodString;
|
|
46
|
+
affectedFiles: z.ZodArray<z.ZodString>;
|
|
47
|
+
commandsToRun: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
48
|
+
migrations: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
49
|
+
riskLevel: z.ZodEnum<{
|
|
50
|
+
low: "low";
|
|
51
|
+
medium: "medium";
|
|
52
|
+
high: "high";
|
|
53
|
+
}>;
|
|
54
|
+
reversible: z.ZodBoolean;
|
|
55
|
+
rollbackHints: z.ZodArray<z.ZodString>;
|
|
56
|
+
diffId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export type MutationSummary = z.infer<typeof MutationSummarySchema>;
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as nodePath from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Execution mode determines which tools are available
|
|
5
|
+
* - plan: Read-only mode, no mutations allowed
|
|
6
|
+
* - build: Normal mode, mutations allowed with confirmation
|
|
7
|
+
*/
|
|
8
|
+
export const ExecutionModeSchema = z.enum(["plan", "build"]);
|
|
9
|
+
/**
|
|
10
|
+
* ExecutionContext is passed to all commands and tools
|
|
11
|
+
* Enforces safety boundaries and execution mode
|
|
12
|
+
*/
|
|
13
|
+
export const ExecutionContextSchema = z.object({
|
|
14
|
+
projectRoot: z.string().refine((path) => nodePath.isAbsolute(path), {
|
|
15
|
+
message: "projectRoot must be absolute path",
|
|
16
|
+
}),
|
|
17
|
+
sessionId: z.string().uuid(),
|
|
18
|
+
provider: z.string(),
|
|
19
|
+
model: z.string(),
|
|
20
|
+
mode: ExecutionModeSchema.default("build"),
|
|
21
|
+
dryRun: z.boolean().default(false),
|
|
22
|
+
assumeYes: z.boolean().default(false),
|
|
23
|
+
maxIterations: z.number().int().positive().default(25),
|
|
24
|
+
timeoutSeconds: z.number().int().positive().default(120),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Risk level for mutations
|
|
28
|
+
*/
|
|
29
|
+
export const RiskLevelSchema = z.enum(["low", "medium", "high"]);
|
|
30
|
+
/**
|
|
31
|
+
* MutationSummary provides a preview of changes before execution
|
|
32
|
+
* Every mutation must produce this summary for user review
|
|
33
|
+
*/
|
|
34
|
+
export const MutationSummarySchema = z.object({
|
|
35
|
+
action: z.string(),
|
|
36
|
+
affectedFiles: z.array(z.string()),
|
|
37
|
+
commandsToRun: z.array(z.string()).default([]),
|
|
38
|
+
migrations: z.array(z.string()).default([]),
|
|
39
|
+
riskLevel: RiskLevelSchema,
|
|
40
|
+
reversible: z.boolean(),
|
|
41
|
+
rollbackHints: z.array(z.string()),
|
|
42
|
+
diffId: z.string().opt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,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAGjE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3C,SAAS,EAAE,eAAe;IAC1B,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;IACvB,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI argument parsing and validation — extracted for testability.
|
|
3
|
+
* This module has no side effects and does not call process.exit directly.
|
|
4
|
+
*/
|
|
5
|
+
export interface ParsedArgs {
|
|
6
|
+
command: string | null;
|
|
7
|
+
question?: string;
|
|
8
|
+
goal?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
dryRun: boolean;
|
|
11
|
+
assumeYes: boolean;
|
|
12
|
+
session?: string;
|
|
13
|
+
quiet: boolean;
|
|
14
|
+
format: "text" | "json";
|
|
15
|
+
maxTokens?: number;
|
|
16
|
+
output?: string;
|
|
17
|
+
unstaged?: boolean;
|
|
18
|
+
branch?: string;
|
|
19
|
+
depth?: number;
|
|
20
|
+
save?: boolean;
|
|
21
|
+
limit?: number;
|
|
22
|
+
tree?: boolean;
|
|
23
|
+
configSubcommand?: "get" | "set" | "path" | "init";
|
|
24
|
+
configKey?: string;
|
|
25
|
+
configValue?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const GLOBAL_USAGE: string;
|
|
28
|
+
export declare const COMMAND_USAGE: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Parse an argv array into a typed ParsedArgs object.
|
|
31
|
+
* Requirements: 2.1, 2.2, 2.3, 2.4, 2.7, 2.8
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseCLI(argv?: string[]): ParsedArgs;
|
|
34
|
+
/**
|
|
35
|
+
* Validate parsed arguments.
|
|
36
|
+
* Calls process.exit(2) on invalid arguments.
|
|
37
|
+
* Requirements: 2.5, 2.6
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateArgs(args: ParsedArgs): void;
|