zhitalk 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.
Files changed (47) hide show
  1. package/README.md +2 -2
  2. package/dist/agent/agent.js +86 -63
  3. package/dist/agent/cli.js +39 -73
  4. package/dist/agent/colors.js +6 -44
  5. package/dist/agent/commands.js +22 -28
  6. package/dist/agent/config.js +20 -62
  7. package/dist/agent/context.js +14 -12
  8. package/dist/agent/db.js +17 -27
  9. package/dist/agent/hooks.d.ts +1 -1
  10. package/dist/agent/hooks.js +13 -22
  11. package/dist/agent/mcp/client.js +25 -29
  12. package/dist/agent/mcp/index.d.ts +1 -1
  13. package/dist/agent/mcp/index.js +8 -13
  14. package/dist/agent/mcp/wrapper.d.ts +2 -2
  15. package/dist/agent/mcp/wrapper.js +5 -8
  16. package/dist/agent/model.js +6 -10
  17. package/dist/agent/permission/exec.js +8 -11
  18. package/dist/agent/permission/is-dangerous-path.js +126 -18
  19. package/dist/agent/permission/is-safe-domains.js +1 -4
  20. package/dist/agent/permission/network.js +3 -6
  21. package/dist/agent/permission/read.js +3 -6
  22. package/dist/agent/permission/util.js +16 -26
  23. package/dist/agent/permission/write.js +5 -8
  24. package/dist/agent/prompt.js +9 -15
  25. package/dist/agent/skills.js +19 -24
  26. package/dist/agent/tools/agent_tool.js +2 -38
  27. package/dist/agent/tools/exec_tool.js +4 -7
  28. package/dist/agent/tools/load_skill_tool.js +3 -6
  29. package/dist/agent/tools/memory_create_tool.js +4 -10
  30. package/dist/agent/tools/memory_delete_tool.js +4 -10
  31. package/dist/agent/tools/memory_retrieve_tool.js +3 -6
  32. package/dist/agent/tools/profile_update_tool.js +11 -14
  33. package/dist/agent/tools/read_file_tool.js +4 -6
  34. package/dist/agent/tools/run_js_tool.js +3 -6
  35. package/dist/agent/tools/run_py_tool.js +4 -7
  36. package/dist/agent/tools/search.js +1 -4
  37. package/dist/agent/tools/web_fetch_tool.js +1 -4
  38. package/dist/agent/tools/web_search_tool.js +5 -8
  39. package/dist/agent/tools/write_file_tool.js +8 -9
  40. package/dist/agent/tools.js +76 -81
  41. package/dist/agent/utils.d.ts +1 -0
  42. package/dist/agent/utils.js +13 -6
  43. package/dist/index.js +23 -49
  44. package/dist/install.js +14 -50
  45. package/jest.config.js +11 -0
  46. package/package.json +8 -7
  47. package/dist/agent/permission/dangerous-path.json +0 -115
package/dist/install.js CHANGED
@@ -1,48 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.runInstall = runInstall;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
39
- const os = __importStar(require("os"));
40
- const child_process_1 = require("child_process");
41
- const config_1 = require("./agent/config");
42
- const db_1 = require("./agent/db");
43
- const SKILLS_DIR = path.join(config_1.WORKSPACE_DIR, '.agents', 'skills');
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as os from 'os';
4
+ import { execSync } from 'child_process';
5
+ import { WORKSPACE_DIR, CONFIG_PATH } from './agent/config.js';
6
+ import { initDb } from './agent/db.js';
7
+ const SKILLS_DIR = path.join(WORKSPACE_DIR, '.agents', 'skills');
44
8
  function run(command, options) {
45
- (0, child_process_1.execSync)(command, { stdio: 'inherit', ...options });
9
+ execSync(command, { stdio: 'inherit', ...options });
46
10
  }
47
11
  function installSkill(name, repo, skillPath, targetDir, tempDir) {
48
12
  if (fs.existsSync(targetDir)) {
@@ -70,11 +34,11 @@ function installSkill(name, repo, skillPath, targetDir, tempDir) {
70
34
  throw error;
71
35
  }
72
36
  }
73
- async function runInstall() {
37
+ export async function runInstall() {
74
38
  console.log('🚀 欢迎使用 Zhitalk!首次使用需要进行初始化配置。\n');
75
39
  // 1. 初始化数据库
76
40
  console.log('📦 正在初始化数据库...');
77
- (0, db_1.initDb)();
41
+ initDb();
78
42
  console.log('✅ 数据库初始化完成\n');
79
43
  // 2. 安装 skills
80
44
  console.log('🔧 正在安装默认 skills...');
@@ -100,15 +64,15 @@ async function runInstall() {
100
64
  TAVILY_API_KEY: 'your-tavily-api-key',
101
65
  },
102
66
  };
103
- fs.mkdirSync(path.dirname(config_1.CONFIG_PATH), { recursive: true });
104
- fs.writeFileSync(config_1.CONFIG_PATH, JSON.stringify(configTemplate, null, 2), 'utf-8');
105
- console.log(`✅ 配置文件已创建: ${config_1.CONFIG_PATH}\n`);
67
+ fs.mkdirSync(path.dirname(CONFIG_PATH), { recursive: true });
68
+ fs.writeFileSync(CONFIG_PATH, JSON.stringify(configTemplate, null, 2), 'utf-8');
69
+ console.log(`✅ 配置文件已创建: ${CONFIG_PATH}\n`);
106
70
  // 4. 提示用户
107
71
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
108
72
  console.log('🎉 初始化完成!');
109
73
  console.log('');
110
74
  console.log('⚠️ 请编辑配置文件,填入你的 API 密钥:');
111
- console.log(` ${config_1.CONFIG_PATH}`);
75
+ console.log(` ${CONFIG_PATH}`);
112
76
  console.log('');
113
77
  console.log('📖 配置文档: https://zhitalk.chat/#config');
114
78
  console.log('');
package/jest.config.js ADDED
@@ -0,0 +1,11 @@
1
+ export default {
2
+ preset: 'ts-jest/presets/default-esm',
3
+ extensionsToTreatAsEsm: ['.ts'],
4
+ moduleNameMapper: {
5
+ '^(\\.{1,2}/.*)\\.js$': '$1',
6
+ },
7
+ transform: {
8
+ '^.+\\.ts$': ['ts-jest', { useESM: true }],
9
+ },
10
+ testEnvironment: 'node',
11
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "zhitalk",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "A personal AI Agent like OpenClaw, including tools, skills, memory, hook, sub-agent, MCP server, etc. Run in the terminal.",
5
- "type": "commonjs",
5
+ "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
@@ -11,11 +11,11 @@
11
11
  "scripts": {
12
12
  "fix:perms": "chmod +x dist/index.js",
13
13
  "build": "pnpm clean && tsc && pnpm fix:perms",
14
- "dev": "ts-node src/index.ts",
14
+ "dev": "NODE_NO_WARNINGS=1 node --loader ts-node/esm src/index.ts",
15
15
  "start": "node dist/index.js",
16
- "test": "jest",
17
- "test:watch": "jest --watch",
18
- "test:coverage": "jest --coverage",
16
+ "test": "NODE_OPTIONS='--experimental-vm-modules' jest",
17
+ "test:watch": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
18
+ "test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
19
19
  "clean": "rm -rf dist"
20
20
  },
21
21
  "keywords": [],
@@ -23,6 +23,7 @@
23
23
  "license": "ISC",
24
24
  "docs": "https://zhitalk.chat/",
25
25
  "devDependencies": {
26
+ "@jest/globals": "^29.7.0",
26
27
  "@types/jest": "^29.5.12",
27
28
  "@types/node": "^20.11.0",
28
29
  "jest": "^29.7.0",
@@ -40,7 +41,7 @@
40
41
  "@types/better-sqlite3": "^7.6.13",
41
42
  "better-sqlite3": "^12.10.0",
42
43
  "boxen": "^8.0.1",
43
- "chalk": "^4.1.2",
44
+ "chalk": "^5.6.2",
44
45
  "cli-table3": "^0.6.5",
45
46
  "commander": "^14.0.3",
46
47
  "figlet": "^1.11.0",
@@ -1,115 +0,0 @@
1
- {
2
- "macos": [
3
- "~/.ssh",
4
- "~/.gnupg",
5
- "~/.aws",
6
- "~/.azure",
7
- "~/.config/gcloud",
8
- "~/.kube",
9
- "~/.docker",
10
- "~/.netrc",
11
- "~/Library/Keychains",
12
- "~/Library/Application Support/Google/Chrome",
13
- "~/Library/Application Support/Chromium",
14
- "~/Library/Application Support/Firefox",
15
- "~/Library/Application Support/Slack",
16
- "~/Library/Application Support/Discord",
17
- "~/Library/Application Support/Telegram",
18
- "~/Library/Application Support/Signal",
19
- "~/.zshrc",
20
- "~/.bashrc",
21
- "~/.bash_profile",
22
- "~/.profile",
23
- "~/.env",
24
- "~/.env.*",
25
- "~/.gitconfig",
26
- "~/.git-credentials",
27
- "~/.npmrc",
28
- "~/.pnpmrc",
29
- "~/.yarnrc",
30
- "~/.pypirc",
31
- "~/.m2",
32
- "~/.gradle",
33
- "~/.terraform",
34
- "~/.config/gh",
35
- "~/.config/gitlab",
36
- "~/.circleci",
37
- "~/.vercel",
38
- "~/.netlify",
39
- "~/Library/Containers",
40
- "/private",
41
- "/etc",
42
- "/var"
43
- ],
44
- "linux": [
45
- "~/.ssh",
46
- "~/.gnupg",
47
- "~/.pki",
48
- "~/.aws",
49
- "~/.azure",
50
- "~/.config/gcloud",
51
- "~/.kube",
52
- "~/.docker",
53
- "~/.netrc",
54
- "~/.local/share/keyrings",
55
- "~/.config/google-chrome",
56
- "~/.config/chromium",
57
- "~/.mozilla/firefox",
58
- "~/.config/Slack",
59
- "~/.config/discord",
60
- "~/.local/share/TelegramDesktop",
61
- "~/.zshrc",
62
- "~/.bashrc",
63
- "~/.bash_profile",
64
- "~/.profile",
65
- "~/.env",
66
- "~/.env.*",
67
- "~/.gitconfig",
68
- "~/.git-credentials",
69
- "~/.npmrc",
70
- "~/.pnpmrc",
71
- "~/.yarnrc",
72
- "~/.pypirc",
73
- "~/.m2",
74
- "~/.gradle",
75
- "~/.terraform",
76
- "~/.config/gh",
77
- "~/.config/gitlab",
78
- "~/.circleci",
79
- "~/.vercel",
80
- "~/.netlify",
81
- "/etc/shadow",
82
- "/etc/sudoers",
83
- "/proc",
84
- "/sys",
85
- "/var/lib",
86
- "/root"
87
- ],
88
- "windows": [
89
- "%USERPROFILE%\\.ssh",
90
- "%USERPROFILE%\\.gnupg",
91
- "%USERPROFILE%\\.aws",
92
- "%USERPROFILE%\\.azure",
93
- "%USERPROFILE%\\.kube",
94
- "%USERPROFILE%\\.docker",
95
- "%LOCALAPPDATA%\\Google\\Chrome\\User Data",
96
- "%LOCALAPPDATA%\\Chromium\\User Data",
97
- "%APPDATA%\\Mozilla\\Firefox",
98
- "%APPDATA%\\Slack",
99
- "%APPDATA%\\Discord",
100
- "%APPDATA%\\Telegram Desktop",
101
- "%USERPROFILE%\\.gitconfig",
102
- "%USERPROFILE%\\.git-credentials",
103
- "%USERPROFILE%\\.npmrc",
104
- "%USERPROFILE%\\.pnpmrc",
105
- "%USERPROFILE%\\.yarnrc",
106
- "%USERPROFILE%\\.m2",
107
- "%USERPROFILE%\\.gradle",
108
- "%APPDATA%",
109
- "%LOCALAPPDATA%",
110
- "C:\\Windows\\System32",
111
- "C:\\Windows\\System32\\config\\SAM",
112
- "C:\\Windows\\System32\\config\\SECURITY",
113
- "C:\\Windows\\System32\\config\\SYSTEM"
114
- ]
115
- }