autoclaw 1.0.3 → 1.0.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.
package/README.md CHANGED
@@ -1,14 +1,23 @@
1
1
  # AutoClaw šŸ¦ž
2
2
 
3
- AutoClaw is a lightweight AI agent CLI tool that brings the power of Large Language Models (LLMs) directly to your terminal. It allows you to interact with your file system and execute commands using natural language.
3
+ **The Docker-Native Headless Agent for Massive Scale Automation.**
4
+
5
+ AutoClaw is a hyper-lightweight AI agent designed to live inside **Docker containers**. Unlike heavy, GUI-dependent agents, AutoClaw is built for **headless, massive-scale concurrency**.
6
+
7
+ You can run one instance to fix a local script, or orchestrate **10,000+ instances** in a Kubernetes cluster to refactor codebases, audit servers, or process data streams in parallel.
8
+
9
+ ## Why AutoClaw?
10
+ - 🐳 **Docker Native**: Built to run safely inside containers. Minimal footprint (Node.js/Alpine friendly).
11
+ - šŸš€ **Massive Scalability**: Text-only, headless design means you can spawn thousands of agents without consuming graphical resources.
12
+ - šŸ›”ļø **Sandbox Safety**: Ideal for running untrusted code when isolated in Docker.
13
+ - šŸ”Œ **Swarm Ready**: Stateless design allows for easy orchestration via K8s, Docker Swarm, or simple shell loops.
4
14
 
5
15
  ## Features
6
16
 
7
- - šŸ’¬ **Natural Language Interface**: Chat with your terminal to perform complex tasks.
8
- - šŸ›”ļø **Safe Execution**: All shell commands require user confirmation before execution.
9
- - šŸ“‚ **File Management**: Read and write files effortlessly.
10
- - 🧠 **Context Aware**: Automatically detects your OS, shell, and environment for accurate command generation.
11
- - šŸ”Œ **Model Agnostic**: Compatible with OpenAI, DeepSeek, LocalLLM, or any OpenAI-compatible API.
17
+ - šŸ“œ **Headless Execution**: No browsers, no GUIs. Pure terminal efficiency.
18
+ - šŸ¤– **Non-Interactive**: Intelligent flag handling (`-y`) for zero-touch automation.
19
+ - šŸ“‚ **Universal Control**: From simple file I/O to complex system administration.
20
+ - 🧠 **Context Aware**: Detects container environments to optimize command strategies.
12
21
 
13
22
  ## Installation
14
23
 
@@ -43,18 +52,29 @@ npm update -g autoclaw
43
52
 
44
53
  ## Configuration
45
54
 
46
- AutoClaw uses a global JSON configuration file located at `~/.autoclaw/setting.json`.
47
- You can also use a local `.env` file in your current directory to override global settings.
55
+ AutoClaw uses a hierarchical configuration system.
48
56
 
49
- Priority order:
50
- 1. Command-line arguments (e.g., `-m`)
51
- 2. Local `.env` file
52
- 3. Global config (`~/.autoclaw/setting.json`)
57
+ **Priority Order (Highest to Lowest):**
58
+ 1. **CLI Arguments**: (e.g., `-m gpt-4o`)
59
+ 2. **Environment Variables**: (`OPENAI_API_KEY`, `.env` file)
60
+ 3. **Project Config**: (`./.autoclaw/setting.json` in current directory)
61
+ 4. **Global Config**: (`~/.autoclaw/setting.json`)
53
62
 
54
- Supported Configuration Keys:
63
+ ### Supported Configuration Keys (JSON)
55
64
  - `apiKey`: Your API Key.
56
65
  - `baseUrl`: Custom Base URL.
57
- - `model`: Default model to use (default: `gpt-4o`).
66
+ - `model`: Default model to use.
67
+
68
+ ### Project-Level Config (Example)
69
+ Create a file at `.autoclaw/setting.json`:
70
+ ```json
71
+ {
72
+ "model": "gpt-3.5-turbo",
73
+ "baseUrl": "https://api.example.com/v1"
74
+ }
75
+ ```
76
+
77
+ > **āš ļø Security Warning**: If you store your `apiKey` in `.autoclaw/setting.json`, make sure to add `.autoclaw/` to your `.gitignore` file to prevent leaking secrets!
58
78
 
59
79
  ## License
60
80
 
package/dist/agent.js CHANGED
@@ -25,22 +25,22 @@ System Information:
25
25
  this.messages = [
26
26
  {
27
27
  role: "system",
28
- content: `You are AutoClaw, an advanced AI agent running in a CLI environment.
29
- Your goal is to help the user perform tasks on their computer.
30
- You have access to tools to execute shell commands and read/write files.
28
+ content: `You are AutoClaw, a Docker-Native Autonomous Agent designed for massive scale automation.
29
+ You are likely running inside a container or headless server, possibly as one of thousands of parallel units in a swarm.
31
30
 
32
31
  CONTEXT:
33
32
  ${systemInfo}
34
33
 
34
+ ENVIRONMENT CONSTRAINTS:
35
+ 1. HEADLESS: No GUI available. Do not try to open browsers or apps.
36
+ 2. CONTAINER-OPTIMIZED: Assume you are in a sandbox. You can be aggressive with file creation but robust with errors.
37
+ 3. NON-INTERACTIVE: Always use flags to suppress prompts (e.g., 'apt-get -y', 'rm -rf').
38
+
35
39
  GUIDELINES:
36
- 1. Use the System Information above to generate platform-specific commands (e.g., use 'dir' for Windows, 'ls' for Linux).
37
- 2. When asked to perform a task, analyze if you need to use tools.
38
- 3. If you need to run a command, always use 'execute_shell_command' and provide a clear rationale.
39
- 4. If you need to read a file, use 'read_file'.
40
- 5. If you need to write a file, use 'write_file'.
41
- 6. Be concise in your responses.
42
- 7. If the user's request is ambiguous, ask for clarification.
43
- 8. You are running on the user's local machine. Be careful with destructive commands (rm, etc.).
40
+ 1. EFFICIENCY: Your goal is speed and success. Write scripts that just work.
41
+ 2. ROBUSTNESS: Use standard Linux/Unix tools found in minimal images (Alpine/Debian).
42
+ 3. TOOLS: Use 'execute_shell_command' for actions, 'write_file' for code generation.
43
+ 4. CLARITY: Output concise logs. You are a worker unit, not a chat bot.
44
44
  `
45
45
  }
46
46
  ];
package/dist/index.js CHANGED
@@ -8,15 +8,16 @@ import * as fs from 'fs';
8
8
  import * as path from 'path';
9
9
  import * as os from 'os';
10
10
  import { fileURLToPath } from 'url';
11
- const CONFIG_DIR = path.join(os.homedir(), '.autoclaw');
12
- const CONFIG_FILE = path.join(CONFIG_DIR, 'setting.json');
13
- function loadGlobalConfig() {
14
- if (fs.existsSync(CONFIG_FILE)) {
11
+ const GLOBAL_CONFIG_DIR = path.join(os.homedir(), '.autoclaw');
12
+ const GLOBAL_CONFIG_FILE = path.join(GLOBAL_CONFIG_DIR, 'setting.json');
13
+ const LOCAL_CONFIG_FILE = path.join(process.cwd(), '.autoclaw', 'setting.json');
14
+ function loadJsonConfig(filePath) {
15
+ if (fs.existsSync(filePath)) {
15
16
  try {
16
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
17
+ return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
17
18
  }
18
19
  catch (e) {
19
- console.error(chalk.red("Error reading global config file."));
20
+ console.error(chalk.yellow(`Warning: Failed to parse config file at ${filePath}`));
20
21
  }
21
22
  }
22
23
  return {};
@@ -55,8 +56,8 @@ program
55
56
  program.parse(process.argv);
56
57
  async function runSetup() {
57
58
  console.log(chalk.bold.cyan("AutoClaw Setup Wizard šŸ¦ž\n"));
58
- console.log(chalk.dim(`Config will be saved to: ${CONFIG_FILE}`));
59
- const currentConfig = loadGlobalConfig();
59
+ console.log(chalk.dim(`Config will be saved to: ${GLOBAL_CONFIG_FILE}`));
60
+ const currentConfig = loadJsonConfig(GLOBAL_CONFIG_FILE);
60
61
  const answers = await inquirer.prompt([
61
62
  {
62
63
  type: 'password',
@@ -85,11 +86,11 @@ async function runSetup() {
85
86
  model: answers.model
86
87
  };
87
88
  try {
88
- if (!fs.existsSync(CONFIG_DIR)) {
89
- fs.mkdirSync(CONFIG_DIR, { recursive: true });
89
+ if (!fs.existsSync(GLOBAL_CONFIG_DIR)) {
90
+ fs.mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true });
90
91
  }
91
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(newConfig, null, 2), { mode: 0o600 });
92
- console.log(chalk.green(`\nāœ… Configuration saved to ${CONFIG_FILE}`));
92
+ fs.writeFileSync(GLOBAL_CONFIG_FILE, JSON.stringify(newConfig, null, 2), { mode: 0o600 });
93
+ console.log(chalk.green(`\nāœ… Configuration saved to ${GLOBAL_CONFIG_FILE}`));
93
94
  console.log(chalk.cyan("You can now run 'autoclaw' to start using the agent."));
94
95
  }
95
96
  catch (error) {
@@ -98,12 +99,17 @@ async function runSetup() {
98
99
  }
99
100
  async function runChat(options) {
100
101
  console.log(chalk.bold.cyan("Welcome to AutoClaw CLI šŸ¦ž"));
101
- // 1. Load Global (JSON)
102
- const globalConfig = loadGlobalConfig();
103
- // 2. Resolve final values (Priority: CLI > Env > Global JSON > Default)
104
- let apiKey = process.env.OPENAI_API_KEY || globalConfig.apiKey;
105
- let baseURL = process.env.OPENAI_BASE_URL || globalConfig.baseUrl;
106
- let model = options.model || process.env.OPENAI_MODEL || globalConfig.model || 'gpt-4o';
102
+ // 1. Load Global JSON
103
+ const globalConfig = loadJsonConfig(GLOBAL_CONFIG_FILE);
104
+ // 2. Load Local JSON (Project Level)
105
+ const localConfig = loadJsonConfig(LOCAL_CONFIG_FILE);
106
+ if (Object.keys(localConfig).length > 0) {
107
+ console.log(chalk.dim(`Loaded project config from ${LOCAL_CONFIG_FILE}`));
108
+ }
109
+ // 3. Merge: CLI > Env > Local JSON > Global JSON
110
+ let apiKey = process.env.OPENAI_API_KEY || localConfig.apiKey || globalConfig.apiKey;
111
+ let baseURL = process.env.OPENAI_BASE_URL || localConfig.baseUrl || globalConfig.baseUrl;
112
+ let model = options.model || process.env.OPENAI_MODEL || localConfig.model || globalConfig.model || 'gpt-4o';
107
113
  if (!apiKey) {
108
114
  console.log(chalk.yellow("API Key not found."));
109
115
  const { doSetup } = await inquirer.prompt([
@@ -116,7 +122,7 @@ async function runChat(options) {
116
122
  ]);
117
123
  if (doSetup) {
118
124
  await runSetup();
119
- const newConfig = loadGlobalConfig();
125
+ const newConfig = loadJsonConfig(GLOBAL_CONFIG_FILE);
120
126
  apiKey = newConfig.apiKey;
121
127
  baseURL = newConfig.baseUrl;
122
128
  model = options.model || newConfig.model || 'gpt-4o';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoclaw",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "chalk": "^5.6.2",
35
35
  "commander": "^14.0.3",
36
- "dotenv": "^17.2.4",
36
+ "dotenv": "^16.4.7",
37
37
  "inquirer": "^13.2.2",
38
38
  "openai": "^6.18.0",
39
39
  "ora": "^9.3.0"