@ia-ccun/code-agent-cli 0.0.6 → 0.0.8

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
@@ -22,19 +22,24 @@ npx @ia-ccun/code-agent-cli
22
22
  ## 快速开始
23
23
 
24
24
  ```bash
25
- # 启动交互式会话
25
+ # 启动交互式会话 (两种命令均可使用)
26
+ aicode
26
27
  aicode-cli
27
28
 
28
29
  # 查看帮助
30
+ aicode --help
29
31
  aicode-cli --help
30
32
 
31
33
  # 指定配置目录
34
+ aicode --config /path/to/config
32
35
  aicode-cli --config /path/to/config
33
36
 
34
37
  # 指定模型
38
+ aicode --model openai/gpt-4o
35
39
  aicode-cli --model openai/gpt-4o
36
40
 
37
41
  # 非交互模式
42
+ aicode -p "你的指令"
38
43
  aicode-cli -p "你的指令"
39
44
  ```
40
45
 
@@ -47,12 +52,41 @@ aicode-cli -p "你的指令"
47
52
  ```json
48
53
  {
49
54
  "name": "aicode-cli",
50
- "banner": "__default__",
55
+ "banner": ["Code is poetry", "Build with pride"],
51
56
  "themeColor": "#49bccf",
52
57
  "configDir": ".aicode-cli"
53
58
  }
54
59
  ```
55
60
 
61
+ **banner 配置说明:**
62
+
63
+ | 值 | 说明 |
64
+ |---|---|
65
+ | `""` | 禁用 banner |
66
+ | `"__default__"` | 使用 ASCII 艺术 banner |
67
+ | `"单条标语"` | 显示单条自定义标语 |
68
+ | `["标语1", "标语2"]` | 每次启动随机显示一条标语 |
69
+
70
+ **示例:**
71
+
72
+ ```json
73
+ // 禁用 banner
74
+ "banner": ""
75
+
76
+ // 使用 ASCII banner
77
+ "banner": "__default__"
78
+
79
+ // 单条标语
80
+ "banner": "Hello, World!"
81
+
82
+ // 多条标语(随机显示)
83
+ "banner": [
84
+ "Code is poetry",
85
+ "Build with pride",
86
+ "Ideas become reality"
87
+ ]
88
+ ```
89
+
56
90
  ### models.json
57
91
 
58
92
  编辑 `~/.aicode-cli/agent/models.json` 配置 LLM Provider:
@@ -125,11 +159,23 @@ aicode-cli -p "你的指令"
125
159
  ## 命令行参数
126
160
 
127
161
  ```bash
162
+ # 两种命令均可使用
163
+ aicode # 启动交互式会话
128
164
  aicode-cli # 启动交互式会话
129
- aicode-cli --help # 查看帮助
130
- aicode-cli --config /path # 指定配置目录
165
+
166
+ aicode --help # 查看帮助
167
+ aicode-cli --help # 查看帮助
168
+
169
+ aicode --config /path # 指定配置目录
170
+ aicode-cli --config /path # 指定配置目录
171
+
172
+ aicode --model provider/model # 指定模型
131
173
  aicode-cli --model provider/model # 指定模型
132
- aicode-cli -p "prompt" # 非交互模式
174
+
175
+ aicode -p "prompt" # 非交互模式
176
+ aicode-cli -p "prompt" # 非交互模式
177
+
178
+ aicode --list-models # 列出可用模型
133
179
  aicode-cli --list-models # 列出可用模型
134
180
  ```
135
181
 
package/bin/cli.js CHANGED
@@ -54,28 +54,56 @@ if (showBanner) {
54
54
  };
55
55
  };
56
56
 
57
- // Banner from src/banner.txt
58
- let lines = [];
57
+ // Read banner config
58
+ let bannerConfig = '';
59
59
  try {
60
- const bannerPath = join(__dirname, '..', 'scripts', 'banner.txt');
61
- const bannerContent = readFileSync(bannerPath, 'utf-8');
62
- lines = bannerContent.trim().split('\n');
60
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
61
+ bannerConfig = config.banner || '';
63
62
  } catch (e) {
64
- // fallback to scripts/banner.txt
65
- lines = [
66
- " _ ___ ____ ___ ____ ___ _ _ ____ ____ _ ___",
67
- " / \\ |_ _| / ___| / _ \\ | _ \\ |_ _| | \\ | | / ___| / ___| | | |_ _|",
68
- " / _ \\ | | | | | | | | | | | | | | | \\| | | | _ | | | | | |",
69
- " / ___ \\ | | | |___ | |_| | | |_| | | | | |\\ | | |_| | | |___ | |___ | |",
70
- " /_/ \\_\\ |___| \\____| \\___/ |____/ |___| |_| \\_| \\____| \\____| |_____| |___|",
71
- ];
63
+ // ignore
72
64
  }
73
65
 
74
66
  const rgb = hexToRgb(themeColor);
75
67
  const colorCode = `\x1b[38;2;${rgb.r};${rgb.g};${rgb.b}m`;
76
68
  const resetCode = '\x1b[0m';
77
69
 
78
- lines.forEach(line => console.log(colorCode + line + resetCode));
70
+ // Get terminal width for centering
71
+ const terminalWidth = process.stdout.columns || 80;
72
+
73
+ // If banner is "__default__", use ASCII art; otherwise use custom text
74
+ if (bannerConfig === '__default__') {
75
+ // Banner from scripts/banner.txt
76
+ let lines = [];
77
+ try {
78
+ const bannerPath = join(__dirname, '..', 'scripts', 'banner.txt');
79
+ const bannerContent = readFileSync(bannerPath, 'utf-8');
80
+ lines = bannerContent.trim().split('\n');
81
+ } catch (e) {
82
+ // fallback - no banner
83
+ }
84
+ lines.forEach(line => console.log(colorCode + line + resetCode));
85
+ } else if (bannerConfig && bannerConfig !== '') {
86
+ // Custom text banner - handle both string and array
87
+ let quotes = [];
88
+ if (Array.isArray(bannerConfig)) {
89
+ quotes = bannerConfig;
90
+ } else if (typeof bannerConfig === 'string' && bannerConfig.startsWith('[')) {
91
+ try {
92
+ quotes = JSON.parse(bannerConfig);
93
+ } catch (e) {
94
+ quotes = [bannerConfig];
95
+ }
96
+ } else {
97
+ quotes = [bannerConfig];
98
+ }
99
+
100
+ // Random quote
101
+ const quote = quotes[Math.floor(Math.random() * quotes.length)];
102
+
103
+ // Center the quote
104
+ const padding = Math.max(0, Math.floor((terminalWidth - quote.length) / 2));
105
+ console.log(colorCode + ' '.repeat(padding) + quote + resetCode);
106
+ }
79
107
  console.log('');
80
108
  }
81
109
 
@@ -240,14 +240,19 @@ export default function (pi: ExtensionAPI) {
240
240
  usage: "/version",
241
241
  handler: async (_args, ctx) => {
242
242
  const { execSync } = await import("child_process");
243
- const pkgPath = "./package.json";
244
- const { readFileSync } = await import("fs");
243
+ const { readFileSync, existsSync } = await import("fs");
245
244
 
246
- // 读取本地版本
245
+ // 读取全局安装的 aicode-cli 版本
247
246
  let localVersion = "未知";
248
247
  try {
249
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
250
- localVersion = pkg.version;
248
+ // 获取全局 npm 包路径
249
+ const globalPath = execSync("npm root -g", { encoding: "utf8" }).trim();
250
+ const pkgPath = `${globalPath}/@ia-ccun/code-agent-cli/package.json`;
251
+
252
+ if (existsSync(pkgPath)) {
253
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
254
+ localVersion = pkg.version;
255
+ }
251
256
  } catch (e) {
252
257
  // 忽略
253
258
  }
package/config.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
2
  "name": "aicode-cli",
3
- "banner": "__default__",
3
+ "banner": [
4
+ "Code is poetry, written in logic",
5
+ "Build with purpose, ship with pride",
6
+ "Ideas become reality through code",
7
+ "Clean code is happy code",
8
+ "Engineers shape the future",
9
+ "Every function tells a story",
10
+ "Architecture is frozen music",
11
+ "Power through simplicity",
12
+ "Design patterns, proven wisdom",
13
+ "Refactor today, thank yourself tomorrow",
14
+ "Debug with patience, ship with confidence",
15
+ "Great software, built one line at a time",
16
+ "Talk is cheap, show me the code",
17
+ "Master the craft, own the art",
18
+ "Open source powers the world",
19
+ "Learn, code, repeat",
20
+ "Excellence in engineering",
21
+ "Code without borders",
22
+ "Embrace the complexity, master the craft",
23
+ "Where creativity meets logic"
24
+ ],
4
25
  "themeColor": "#49bccf",
5
26
  "configDir": ".aicode-cli"
6
- }
27
+ }
package/dist/banner.js CHANGED
@@ -6,10 +6,10 @@ import { dirname, join } from 'path';
6
6
  import { fileURLToPath } from 'url';
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = dirname(__filename);
9
- // 读取 banner.txt
9
+ // 读取 banner.txt (从 scripts 目录)
10
10
  let defaultBanner = '';
11
11
  try {
12
- const bannerPath = join(__dirname, 'banner.txt');
12
+ const bannerPath = join(__dirname, '..', 'scripts', 'banner.txt');
13
13
  defaultBanner = readFileSync(bannerPath, 'utf-8');
14
14
  }
15
15
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"banner.js","sourceRoot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,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QAChC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QAChC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;KACjC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@ia-ccun/code-agent-cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "AI Coding Agent CLI - 基于OpenClaw🦞底层Agent原理实现的的编码智能体(供学习使用)。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "bin": {
9
+ "aicode": "./bin/cli.js",
9
10
  "aicode-cli": "./bin/cli.js"
10
11
  },
11
12
  "preferGlobal": true,
@@ -1,5 +1,6 @@
1
- _ ___ ____ ___ ____ ___ _ _ ____ ____ _ ___
1
+ _ ___ ____ ___ ____ ___ _ _ ____ ____ _ ___
2
2
  / \ |_ _| / ___| / _ \ | _ \ |_ _| | \ | | / ___| / ___| | | |_ _|
3
- / _ \ | | | | | | | | | | | | | | | \| | | | _ | | | | | |
4
- / ___ \ | | | |___ | |_| | | |_| | | | | |\ | | |_| | | |___ | |___ | |
3
+ / _ \ | | | | | | | | | | | | | | | \| | | | _ | | | | | |
4
+ / ___ \ | | | |___ | |_| | | |_| | | | | |\ | | |_| | | |___ | |___ | |
5
5
  /_/ \_\ |___| \____| \___/ |____/ |___| |_| \_| \____| \____| |_____| |___|
6
+