arki 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -45,6 +45,7 @@ arki [options]
45
45
  Options:
46
46
  -p <path> Specify working directory
47
47
  --debug, -d Enable debug mode, show detailed logs
48
+ --init Initialize project config without prompting
48
49
  --reset Reset configuration to factory defaults
49
50
  --help, -h Show help information
50
51
  ```
@@ -80,9 +81,26 @@ Ways to enable:
80
81
  1. Add `--debug` or `-d` parameter at startup
81
82
  2. Type `/debug` during runtime to toggle
82
83
 
83
- ## Configuration File
84
+ ## Configuration
84
85
 
85
- Configuration file is located at `~/.config/arki/config.json`:
86
+ ### Global Configuration
87
+
88
+ Global configuration is stored in system-specific locations:
89
+
90
+ - **macOS/Linux**: `~/.config/arki/config.json`
91
+ - **Windows**: `%APPDATA%\arki\config.json`
92
+
93
+ On first run, Arki copies the default configuration template to this location.
94
+
95
+ ### Project Configuration
96
+
97
+ Each project can have its own configuration in `.arki/` directory:
98
+
99
+ - `.arki/config.json` - Project-specific settings (overrides global config)
100
+ - `.arki/state.json` - Project state and cache
101
+
102
+ On first run in a new project, Arki will ask if you trust the project before initializing the `.arki/` directory.
103
+ Use `--init` to skip the prompt in non-interactive environments.
86
104
 
87
105
  ### Reset to Factory Defaults
88
106
 
@@ -90,7 +108,7 @@ Configuration file is located at `~/.config/arki/config.json`:
90
108
  arki --reset
91
109
  ```
92
110
 
93
- This will delete the current configuration file. The default configuration will be used on next startup.
111
+ This will delete the global configuration file. The default configuration will be used on next startup.
94
112
 
95
113
  ## Development
96
114
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "agents": {}
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "initialized": true,
3
+ "createdAt": ""
4
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "agents": {
3
- "main": {
3
+ "arki": {
4
4
  "model": "gpt-5.1",
5
5
  "flex": true,
6
6
  "reasoningEffort": "medium"
package/dist/index.d.ts CHANGED
@@ -135,15 +135,41 @@ declare class Procedure {
135
135
  };
136
136
  }
137
137
 
138
- /**
139
- * Fixed parameters
140
- */
141
- declare const TEMPERATURE = 0.2;
142
- declare const MAX_COMPLETION_TOKENS = 4096;
138
+ /** OS type definition */
139
+ interface OS_TYPE {
140
+ /** Operating system name: 'windows' | 'mac' | 'linux' | 'other' */
141
+ name: 'windows' | 'mac' | 'linux' | 'other';
142
+ /** Operating system version */
143
+ version: string;
144
+ }
145
+ /** Global OS information */
146
+ declare const OS: OS_TYPE;
147
+ /** Working directory */
148
+ declare let workingDir: string;
149
+ /** Set working directory (for testing) */
150
+ declare function setWorkingDir(dir: string): void;
151
+ /** Global paths configuration */
152
+ declare const PATHS: {
153
+ /** Global config directory (~/.config/arki or %APPDATA%\arki) */
154
+ globalConfig: string;
155
+ /** Project config directory (.arki/) - returns path based on current workingDir */
156
+ readonly projectConfig: string;
157
+ /** Package's global config template directory */
158
+ globalTemplate: string;
159
+ /** Package's project config template directory */
160
+ projectTemplate: string;
161
+ };
162
+
143
163
  /**
144
164
  * Reasoning effort
145
165
  */
146
166
  type ReasoningEffort$1 = 'low' | 'medium' | 'high';
167
+ /**
168
+ * Platform-specific options for adapter
169
+ */
170
+ interface AdapterOptions {
171
+ [key: string]: unknown;
172
+ }
147
173
  /**
148
174
  * LLM response result
149
175
  */
@@ -159,34 +185,31 @@ interface AdapterResponse {
159
185
  }
160
186
  /**
161
187
  * LLM adapter base class
188
+ * Only contains platform authentication, model/tools belong to Agent
162
189
  */
163
190
  declare abstract class Adapter {
164
191
  protected apiKey: string;
165
- protected model: string;
166
- /** Use Flex API (OpenAI) - low priority, low cost */
167
- protected flex?: boolean;
168
- /** Reasoning effort (thinking mode) */
169
- protected reasoningEffort?: ReasoningEffort$1;
170
- /** Available tools list */
171
- protected tools?: Tool[];
172
- constructor(config: {
173
- apiKey: string;
174
- model: string;
175
- /** Use Flex API (OpenAI) - low priority, low cost */
176
- flex?: boolean;
177
- /** Reasoning effort (thinking mode) */
178
- reasoningEffort?: ReasoningEffort$1;
179
- /** Available tools list */
180
- tools?: Tool[];
181
- });
182
- abstract chat(messages: Msg[], onChunk?: (chunk: string) => void): Promise<AdapterResponse>;
183
- getModel(): string;
192
+ constructor(apiKey: string);
193
+ abstract chat(model: string, messages: Msg[], tools: Tool[], options: AdapterOptions, onChunk?: (chunk: string) => void): Promise<AdapterResponse>;
184
194
  }
185
195
 
196
+ /** Global tool registry */
197
+ declare const TOOLS: Record<string, Tool>;
198
+ /** Global procedure registry */
199
+ declare const PROCEDURES: Record<string, Procedure>;
200
+ /** Global adapter registry by platform */
201
+ declare const adapters: Record<string, Adapter>;
202
+ /**
203
+ * Get adapter by platform name
204
+ */
205
+ declare function getAdapter(platform: string): Adapter;
206
+ /** Initialize global state */
207
+ declare function init(cwd?: string, forceInit?: boolean): Promise<void>;
208
+
186
209
  /**
187
210
  * Agent type
188
211
  */
189
- type AgentType = 'main' | 'coder';
212
+ type AgentType = 'arki' | 'coder';
190
213
  /**
191
214
  * Reasoning effort
192
215
  */
@@ -195,60 +218,37 @@ type ReasoningEffort = 'low' | 'medium' | 'high';
195
218
  * Agent model configuration
196
219
  */
197
220
  interface AgentModelConfig {
198
- /** Model ID */
221
+ /** Model ID (provider is derived from MODELS) */
199
222
  model: string;
200
- /** Use Flex API (low priority, low cost) */
223
+ /** Use Flex API (low priority, low cost) - OpenAI specific */
201
224
  flex?: boolean;
202
225
  /** Reasoning effort (thinking mode) */
203
226
  reasoningEffort?: ReasoningEffort;
204
227
  }
205
228
  /**
206
- * Global configuration
229
+ * Global configuration (from config files)
207
230
  */
208
231
  interface GlobalConfig {
209
- apiKeys?: {
210
- openai?: string;
211
- anthropic?: string;
212
- google?: string;
213
- [key: string]: string | undefined;
214
- };
215
232
  agents: {
216
233
  [K in AgentType]?: AgentModelConfig;
217
234
  };
218
235
  }
219
236
  /**
220
- * Global configuration manager
237
+ * Get loaded configuration
221
238
  */
222
- declare class ConfigManager {
223
- private config;
224
- private loaded;
225
- /**
226
- * Load configuration (called at program startup)
227
- */
228
- load(): Promise<GlobalConfig>;
229
- /**
230
- * Save configuration
231
- */
232
- save(): Promise<void>;
233
- get(): GlobalConfig;
234
- getApiKey(provider: string): string | undefined;
235
- getAgentConfig(agentType: AgentType): AgentModelConfig;
236
- private loadEnvApiKeys;
237
- }
238
- declare const config: ConfigManager;
239
-
240
- /** Working directory */
241
- declare let workingDir: string;
242
- /** Set working directory (for testing) */
243
- declare function setWorkingDir(dir: string): void;
244
- /** Global tool registry */
245
- declare const TOOLS: Record<string, Tool>;
246
- /** Global procedure registry */
247
- declare const PROCEDURES: Record<string, Procedure>;
248
- /** Global Adapter instance */
249
- declare let adapter: Adapter | null;
250
- /** Initialize global state */
251
- declare function init(cwd?: string): Promise<void>;
239
+ declare function getConfig(): GlobalConfig;
240
+ /**
241
+ * Get API key from environment variable
242
+ */
243
+ declare function getApiKey(provider: string): string | undefined;
244
+ /**
245
+ * Get agent configuration
246
+ */
247
+ declare function getAgentConfig(agentType: AgentType): AgentModelConfig;
248
+ /**
249
+ * Save configuration to global config file
250
+ */
251
+ declare function saveConfig(): Promise<void>;
252
252
 
253
253
  /**
254
254
  * Debug logging module
@@ -271,6 +271,11 @@ declare function debug(category: string, message: string, data?: unknown): void;
271
271
  * All log output is single-line with timestamp prefix
272
272
  * Supports XML-style color tags: <red>text</red>, <bold>text</bold>, etc.
273
273
  */
274
+ /**
275
+ * Print output without timestamp (for prompts and simple messages)
276
+ * @param message Message string with optional XML color tags
277
+ */
278
+ declare function print(message: string): void;
274
279
  /**
275
280
  * Log output with timestamp and XML color tag support
276
281
  * @param message Message string with optional XML color tags
@@ -331,18 +336,23 @@ declare function convertColorTags(str: string): string;
331
336
  */
332
337
  declare function createColorConverter(): (chunk: string) => string;
333
338
 
339
+ /**
340
+ * OpenAI-specific options
341
+ */
342
+ interface OpenAIOptions extends AdapterOptions {
343
+ /** Use Flex API - low priority, low cost */
344
+ flex?: boolean;
345
+ /** Reasoning effort (thinking mode) */
346
+ reasoningEffort?: ReasoningEffort$1;
347
+ /** Maximum completion tokens for LLM response */
348
+ maxCompletionTokens?: number;
349
+ }
334
350
  declare class OpenAIAdapter extends Adapter {
335
351
  private client;
336
- constructor(config: {
337
- apiKey: string;
338
- model: string;
339
- flex?: boolean;
340
- reasoningEffort?: 'low' | 'medium' | 'high';
341
- tools?: Tool[];
342
- });
352
+ constructor(apiKey: string);
343
353
  private toOpenAIMessages;
344
- private getTools;
345
- chat(messages: Msg[], onChunk?: (chunk: string) => void): Promise<AdapterResponse>;
354
+ private formatTools;
355
+ chat(model: string, messages: Msg[], tools: Tool[], options: OpenAIOptions, onChunk?: (chunk: string) => void): Promise<AdapterResponse>;
346
356
  }
347
357
 
348
358
  interface AgentResponse {
@@ -359,17 +369,24 @@ interface AgentResponse {
359
369
  cachedTokens?: number;
360
370
  };
361
371
  }
372
+ interface AgentConfig {
373
+ adapter: Adapter;
374
+ model: string;
375
+ tools: Tool[];
376
+ platformOptions?: AdapterOptions;
377
+ messages: Msg[];
378
+ /** Maximum completion tokens for LLM response */
379
+ maxCompletionTokens?: number;
380
+ onStream?: (chunk: string) => void;
381
+ onToolCallMsg?: (msg: ToolCallMsg) => void;
382
+ onBeforeToolRun?: (name: string, args: Record<string, unknown>) => void;
383
+ onToolResult?: (name: string, args: Record<string, unknown>, result: string) => void;
384
+ }
362
385
  declare class Agent {
363
386
  private config;
364
387
  private messages;
365
- constructor(config: {
366
- adapter: Adapter;
367
- messages: Msg[];
368
- onStream?: (chunk: string) => void;
369
- onToolCallMsg?: (msg: ToolCallMsg) => void;
370
- onBeforeToolRun?: (name: string, args: Record<string, unknown>) => void;
371
- onToolResult?: (name: string, args: Record<string, unknown>, result: string) => void;
372
- });
388
+ private toolsMap;
389
+ constructor(config: AgentConfig);
373
390
  /**
374
391
  * Render template string, replacing {{variable}} style variables
375
392
  */
@@ -404,4 +421,4 @@ interface Model {
404
421
  readonly capabilities: ModelCapabilities;
405
422
  }
406
423
 
407
- export { AIMsg, Adapter, type AdapterResponse, Agent, type AgentResponse, type ColorName, HAS_MANUAL, MAX_COMPLETION_TOKENS, MODELS, type Model, type ModelCapabilities, type ModelProvider, Msg, MsgType, OpenAIAdapter, PROCEDURES, type ReasoningEffort$1 as ReasoningEffort, SystemMsg, TEMPERATURE, TOOLS, Tool, type ToolCall, ToolCallMsg, type ToolResult, ToolResultMsg, UserMsg, adapter, colors, config, convertColorTags, createColorConverter, debug, error, info, init, isDebugMode, log, setDebugMode, setWorkingDir, success, warn, workingDir };
424
+ export { AIMsg, Adapter, type AdapterOptions, type AdapterResponse, Agent, type AgentModelConfig, type AgentResponse, type AgentType, type ColorName, type GlobalConfig, HAS_MANUAL, MODELS, type Model, type ModelCapabilities, type ModelProvider, Msg, MsgType, OS, type OS_TYPE, OpenAIAdapter, type OpenAIOptions, PATHS, PROCEDURES, type ReasoningEffort$1 as ReasoningEffort, SystemMsg, TOOLS, Tool, type ToolCall, ToolCallMsg, type ToolResult, ToolResultMsg, UserMsg, adapters, colors, convertColorTags, createColorConverter, debug, error, getAdapter, getAgentConfig, getApiKey, getConfig, info, init, isDebugMode, log, print, saveConfig, setDebugMode, setWorkingDir, success, warn, workingDir };