zen-code 4.6.2 → 4.7.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/README.md CHANGED
@@ -1,55 +1,80 @@
1
- # Zen Code TUI
1
+ # Zen Code
2
2
 
3
- > Terminal User Interface for Zen Code
3
+ ## 🚀 快速开始
4
4
 
5
- ## 🎯 Overview
5
+ ### 安装
6
6
 
7
- Zen Code TUI is a terminal user interface built with React + Ink, providing a fluid interactive AI coding assistant experience.
7
+ ```bash
8
+ bun install -g zen-code
9
+ ```
10
+
11
+ ### 启动
12
+
13
+ ```bash
14
+ zen-code
15
+ ```
16
+
17
+ 首次启动会自动弹出初始化向导,引导完成基本配置。
8
18
 
9
- ## 🚀 Quick Start
19
+ ## 📖 使用方式
10
20
 
11
- ### Install
21
+ ### 1. 交互式模式(默认)
22
+
23
+ 直接启动进入 TUI 界面:
12
24
 
13
25
  ```bash
14
- pnpx zen-code
26
+ zen-code
27
+ bunx --bun zen-code
15
28
  ```
16
29
 
17
- ### Initialize Configuration
30
+ ### 2. 提示模式
31
+
32
+ 直接执行单个任务:
18
33
 
19
34
  ```bash
20
- zen-code init
35
+ zen-code -p "分析当前代码库结构"
21
36
  ```
22
37
 
23
- ### Start
38
+ ### 3. 管道模式
39
+
40
+ 从 stdin 读取数据:
24
41
 
25
42
  ```bash
26
- zen-code
43
+ cat large-file.ts | zen-code
27
44
  ```
28
45
 
29
- ## 💡 Usage
46
+ ### 4. 快速模式(YOLO)
30
47
 
31
- ### Model Switching
48
+ 禁用人机确认,自动执行所有操作:
32
49
 
33
50
  ```bash
34
- /m # List all models
35
- /m 2 # Switch to the 2nd model in the list
36
- /m gpt-4o # Switch to a specific model
37
- /mp # Open interactive model selection panel
51
+ zen-code --yolo
38
52
  ```
39
53
 
40
- ### Common Commands
54
+ ## 💬 常用命令
55
+
56
+ 在 TUI 界面中输入以下命令:
41
57
 
42
- | Command | Description |
43
- |---------|-------------|
44
- | `/init` | Initialize configuration |
45
- | `/help` | Show help |
46
- | `/config` | Configuration management |
58
+ | 命令 | 描述 |
59
+ | ------------ | -------------- |
60
+ | `/help` | 显示帮助 |
61
+ | `/m` | 模型管理 |
62
+ | `/agent` | 切换 AI 助手 |
63
+ | `/history` | 聊天历史 |
64
+ | `/knowledge` | 知识库管理 |
65
+ | `/mcp` | MCP 服务器管理 |
66
+ | `/status` | 查看系统状态 |
67
+ | `/config` | 配置管理 |
68
+ | `/sum` | 压缩记忆 |
47
69
 
48
- ### Keyboard Shortcuts
70
+ ### 模型切换
49
71
 
50
- - **↑↓**: Navigate in lists
51
- - **Enter**: Confirm selection
52
- - **q**: Close panel
72
+ ```bash
73
+ /m # 列出所有模型
74
+ /m 2 # 切换到第 2 个模型
75
+ /m gpt-4o # 切换到特定模型
76
+ /mp # 打开交互式模型选择面板
77
+ ```
53
78
 
54
79
  ## 📄 License
55
80
 
@@ -0,0 +1,108 @@
1
+ import e from "node:fs/promises";
2
+ import n from "node:path";
3
+ import u from "node:os";
4
+ import f from "yaml";
5
+ class v {
6
+ skillsDir;
7
+ projectSkillsDir;
8
+ constructor() {
9
+ const t = u.homedir();
10
+ this.skillsDir = n.join(t, ".claude", "skills"), this.projectSkillsDir = n.join(process.cwd(), ".claude", "skills");
11
+ }
12
+ async listSkills() {
13
+ const t = /* @__PURE__ */ new Map(), s = await this.listSkillsInDir(this.skillsDir);
14
+ for (const i of s)
15
+ t.set(i.name, i);
16
+ const r = await this.listSkillsInDir(this.projectSkillsDir);
17
+ for (const i of r)
18
+ t.set(i.name, i);
19
+ return Array.from(t.values());
20
+ }
21
+ async listSkillsInDir(t) {
22
+ try {
23
+ const s = await e.readdir(t, { withFileTypes: !0 }), r = [];
24
+ for (const i of s) {
25
+ const o = n.join(t, i.name), c = await e.lstat(o).catch(() => null);
26
+ if (!c) continue;
27
+ const m = await e.stat(o).catch(() => null);
28
+ if (!m || !m.isDirectory()) continue;
29
+ if (c.isSymbolicLink()) {
30
+ const l = n.resolve(o), a = n.resolve(t), k = l.substring(a.length);
31
+ if (!(l === a || k.startsWith("/") || k === "")) {
32
+ const S = u.homedir();
33
+ if (!l.startsWith(S))
34
+ continue;
35
+ }
36
+ }
37
+ const h = n.join(o, "SKILL.md");
38
+ try {
39
+ const l = await e.readFile(h, "utf-8"), a = this.parseFrontmatter(l);
40
+ r.push({
41
+ name: i.name,
42
+ description: a.description || "",
43
+ path: h
44
+ });
45
+ } catch {
46
+ }
47
+ }
48
+ return r;
49
+ } catch {
50
+ return [];
51
+ }
52
+ }
53
+ async getSkill(t) {
54
+ const s = n.join(this.projectSkillsDir, t, "SKILL.md");
55
+ try {
56
+ const i = await e.readFile(s, "utf-8");
57
+ return this.parseSkillContent(i);
58
+ } catch {
59
+ }
60
+ const r = n.join(this.skillsDir, t, "SKILL.md");
61
+ try {
62
+ const i = await e.readFile(r, "utf-8");
63
+ return this.parseSkillContent(i);
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+ async saveSkill(t, s) {
69
+ const r = n.join(this.skillsDir, t);
70
+ await e.mkdir(r, { recursive: !0 });
71
+ const i = this.formatSkillContent(s);
72
+ await e.writeFile(n.join(r, "SKILL.md"), i, "utf-8");
73
+ }
74
+ async deleteSkill(t) {
75
+ const s = n.join(this.skillsDir, t);
76
+ await e.rm(s, { recursive: !0, force: !0 });
77
+ }
78
+ async syncFromRemote(t) {
79
+ const s = await t.listRemoteSkills();
80
+ for (const r of s) {
81
+ const i = await t.fetchSkill(r.name);
82
+ i && await this.saveSkill(r.name, i);
83
+ }
84
+ }
85
+ parseFrontmatter(t) {
86
+ const s = t.match(/^---\n(.+?)\n---/s);
87
+ if (!s) return {};
88
+ try {
89
+ return f.parse(s[1]);
90
+ } catch {
91
+ return {};
92
+ }
93
+ }
94
+ parseSkillContent(t) {
95
+ const s = this.parseFrontmatter(t), r = t.replace(/^---\n.+?\n---\n*/s, "");
96
+ return { frontmatter: s, markdown: r };
97
+ }
98
+ formatSkillContent(t) {
99
+ return `---
100
+ ${f.stringify(t.frontmatter).trim()}
101
+ ---
102
+
103
+ ${t.markdown}`;
104
+ }
105
+ }
106
+ export {
107
+ v as FileSystemSkillStore
108
+ };