fotric-claw 0.1.0 → 0.1.2

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 (66) hide show
  1. package/README.md +33 -45
  2. package/bin/fotric-claw.js +59 -7
  3. package/package.json +13 -7
  4. package/backend/nest-cli.json +0 -8
  5. package/backend/package-lock.json +0 -13239
  6. package/backend/src/agent/agent.module.ts +0 -10
  7. package/backend/src/agent/agent.service.ts +0 -210
  8. package/backend/src/agent/index.ts +0 -4
  9. package/backend/src/agent/llm.factory.ts +0 -20
  10. package/backend/src/agent/tools/fetch.tool.ts +0 -128
  11. package/backend/src/agent/tools/file-read.tool.ts +0 -99
  12. package/backend/src/agent/tools/index.ts +0 -55
  13. package/backend/src/agent/tools/node-repl.tool.ts +0 -82
  14. package/backend/src/agent/tools/rag.tool.ts +0 -192
  15. package/backend/src/agent/tools/shell.tool.ts +0 -65
  16. package/backend/src/app.module.ts +0 -26
  17. package/backend/src/chat/chat.controller.ts +0 -34
  18. package/backend/src/chat/chat.module.ts +0 -12
  19. package/backend/src/chat/chat.service.ts +0 -52
  20. package/backend/src/chat/dto/chat.dto.ts +0 -12
  21. package/backend/src/chat/dto/index.ts +0 -1
  22. package/backend/src/chat/index.ts +0 -4
  23. package/backend/src/config/config.controller.ts +0 -92
  24. package/backend/src/config/config.module.ts +0 -7
  25. package/backend/src/config/constants.ts +0 -56
  26. package/backend/src/config/index.ts +0 -3
  27. package/backend/src/files/files.controller.ts +0 -87
  28. package/backend/src/files/files.module.ts +0 -7
  29. package/backend/src/files/index.ts +0 -2
  30. package/backend/src/main.ts +0 -21
  31. package/backend/src/memory/index.ts +0 -3
  32. package/backend/src/memory/memory.module.ts +0 -10
  33. package/backend/src/memory/memory.service.ts +0 -329
  34. package/backend/src/memory/memory.types.ts +0 -38
  35. package/backend/src/sessions/default.json +0 -7
  36. package/backend/src/sessions/index.ts +0 -2
  37. package/backend/src/sessions/main_session.json +0 -40
  38. package/backend/src/sessions/sessions.controller.ts +0 -25
  39. package/backend/src/sessions/sessions.module.ts +0 -9
  40. package/backend/src/sessions/test.json +0 -16
  41. package/backend/src/skills/browser_search/SKILL.md +0 -81
  42. package/backend/src/skills/get_weather/SKILL.md +0 -72
  43. package/backend/src/skills/index.ts +0 -3
  44. package/backend/src/skills/skill.types.ts +0 -27
  45. package/backend/src/skills/skills.module.ts +0 -8
  46. package/backend/src/skills/skills.service.ts +0 -139
  47. package/backend/src/skills/web_search/SKILL.md +0 -76
  48. package/backend/src/workspace/AGENTS.md +0 -47
  49. package/backend/src/workspace/IDENTITY.md +0 -32
  50. package/backend/src/workspace/MEMORY.md +0 -15
  51. package/backend/src/workspace/SOUL.md +0 -29
  52. package/backend/src/workspace/USER.md +0 -8
  53. package/backend/tsconfig.build.json +0 -4
  54. package/backend/tsconfig.json +0 -26
  55. package/frontend/next.config.js +0 -14
  56. package/frontend/package-lock.json +0 -5700
  57. package/frontend/package.json +0 -33
  58. package/frontend/postcss.config.js +0 -6
  59. package/frontend/src/app/globals.css +0 -41
  60. package/frontend/src/app/layout.tsx +0 -22
  61. package/frontend/src/app/page.tsx +0 -405
  62. package/frontend/src/lib/api.ts +0 -157
  63. package/frontend/src/lib/utils.ts +0 -3
  64. package/frontend/tailwind.config.js +0 -32
  65. package/frontend/tsconfig.json +0 -26
  66. package/scripts/init-skills.ts +0 -95
package/README.md CHANGED
@@ -9,13 +9,23 @@ FotricCalw 是一个轻量级、透明的 AI Agent 系统,支持命令行安
9
9
 
10
10
  ## 安装方式
11
11
 
12
- ### 方式一:从 npm 安装(待开发)
12
+ ### 方式一:从 npm 安装
13
13
 
14
14
  ```bash
15
15
  npm install -g fotric-claw
16
16
  ```
17
17
 
18
- > 注:此方式暂不可用,请使用源码安装。
18
+ 安装后直接使用:
19
+
20
+ ```bash
21
+ # 配置 API
22
+ fotric-claw config
23
+
24
+ # 启动服务
25
+ fotric-claw start
26
+ ```
27
+
28
+ > npm 安装的版本已预编译,无需构建步骤。
19
29
 
20
30
  ### 方式二:从源码安装
21
31
 
@@ -57,27 +67,20 @@ node bin/fotric-claw.js config
57
67
 
58
68
  #### 步骤 4:启动服务
59
69
 
60
- **方式一:使用命令行工具(推荐)**
70
+ **开发模式:**
61
71
 
62
- (由于方式一的命令行工具暂未开发,此处仅展示手动启动的方式)
63
- ```bash
64
- fotric-claw start
65
- ```
66
- 使用该方案,等效于上述命令
67
72
  ```bash
68
73
  node bin/fotric-claw.js start
69
74
  ```
70
75
 
71
- 该命令将自动启动后端和前端服务。
72
-
73
- **方式二:手动启动**
76
+ **生产模式:**
74
77
 
75
78
  ```bash
76
- # 启动后端服务
77
- npm run backend
79
+ # 构建
80
+ node bin/fotric-claw.js build
78
81
 
79
- # 在新终端窗口启动前端服务
80
- npm run frontend
82
+ # 启动
83
+ node bin/fotric-claw.js start:prod
81
84
  ```
82
85
 
83
86
  #### 步骤 5:访问应用
@@ -94,26 +97,19 @@ FotricCalw 提供了交互式命令行配置工具,方便用户设置 LLM API
94
97
  fotric-claw help
95
98
  ```
96
99
 
97
- 输出:
100
+ **npm 安装用户可用命令:**
98
101
  ```
99
- FotricCalw CLI
100
-
101
- Usage:
102
- fotric-claw <command> [options]
103
-
104
102
  Commands:
105
- start Start backend and frontend services (dev mode)
106
- start:prod Start backend and frontend services (production mode)
107
- build Build backend and frontend for production
103
+ start Start backend and frontend services
108
104
  config Configure LLM API settings
109
105
  help Show this help message
106
+ ```
110
107
 
111
- Examples:
112
- fotric-claw start
113
- fotric-claw start:prod
114
- fotric-claw build
115
- fotric-claw config
116
- fotric-claw help
108
+ **源码安装用户额外可用命令:**
109
+ ```
110
+ Commands:
111
+ start Start backend and frontend services (dev mode)
112
+ build Build backend and frontend for production
117
113
  ```
118
114
 
119
115
  ### 配置 LLM API
@@ -183,7 +179,7 @@ FOTRIC_REPL_TIMEOUT=15000
183
179
 
184
180
  ## 启动服务
185
181
 
186
- ### 开发模式
182
+ ### 开发模式(仅源码安装)
187
183
 
188
184
  ```bash
189
185
  # 启动后端服务
@@ -195,28 +191,20 @@ npm run frontend
195
191
 
196
192
  ### 生产模式
197
193
 
198
- **方式一:使用命令行工具(推荐)**
194
+ **npm 安装用户:**
199
195
 
200
196
  ```bash
201
- # 构建项目
202
- fotric-claw build
203
-
204
- # 启动生产服务
205
- fotric-claw start:prod
197
+ fotric-claw start
206
198
  ```
207
199
 
208
- **方式二:手动操作**
200
+ **源码安装用户:**
209
201
 
210
202
  ```bash
211
203
  # 构建项目
212
- npm run build:backend
213
- npm run build:frontend
214
-
215
- # 启动后端
216
- cd backend && npm run start:prod
204
+ node bin/fotric-claw.js build
217
205
 
218
- # 启动前端
219
- cd frontend && npm run start
206
+ # 启动生产服务
207
+ node bin/fotric-claw.js start:prod
220
208
  ```
221
209
 
222
210
  ## 访问服务
@@ -8,6 +8,12 @@ const { spawn } = require('child_process');
8
8
  const ENV_FILE = path.resolve(__dirname, '../backend/.env');
9
9
  const PROJECT_ROOT = path.resolve(__dirname, '..');
10
10
 
11
+ function isNpmInstalled() {
12
+ const backendSrc = path.resolve(PROJECT_ROOT, 'backend/src');
13
+ const frontendSrc = path.resolve(PROJECT_ROOT, 'frontend/src');
14
+ return !fs.existsSync(backendSrc) || !fs.existsSync(frontendSrc);
15
+ }
16
+
11
17
  const rl = readline.createInterface({
12
18
  input: process.stdin,
13
19
  output: process.stdout
@@ -114,30 +120,41 @@ async function configCommand() {
114
120
  }
115
121
 
116
122
  async function showHelp() {
123
+ const isNpm = isNpmInstalled();
124
+
117
125
  console.log(`
118
126
  FotricCalw CLI
119
127
 
120
128
  Usage:
121
129
  fotric-claw <command> [options]
122
130
 
123
- Commands:
131
+ Commands:${isNpm ? `
132
+ start Start backend and frontend services
133
+ config Configure LLM API settings
134
+ help Show this help message` : `
124
135
  start Start backend and frontend services (dev mode)
125
136
  start:prod Start backend and frontend services (production mode)
126
137
  build Build backend and frontend for production
127
138
  config Configure LLM API settings
128
- help Show this help message
139
+ help Show this help message`}
129
140
 
130
- Examples:
141
+ Examples:${isNpm ? `
142
+ fotric-claw start
143
+ fotric-claw config` : `
131
144
  fotric-claw start
132
145
  fotric-claw start:prod
133
146
  fotric-claw build
134
- fotric-claw config
135
- fotric-claw help
147
+ fotric-claw config`}
136
148
  `);
137
149
  rl.close();
138
150
  }
139
151
 
140
152
  function startCommand() {
153
+ if (isNpmInstalled()) {
154
+ startProdCommand();
155
+ return;
156
+ }
157
+
141
158
  console.log('\n🚀 Starting FotricCalw (Development Mode)...\n');
142
159
 
143
160
  const isWindows = process.platform === 'win32';
@@ -176,6 +193,21 @@ function startProdCommand() {
176
193
  const isWindows = process.platform === 'win32';
177
194
  const shell = isWindows ? true : false;
178
195
 
196
+ const backendDist = path.resolve(PROJECT_ROOT, 'backend/dist');
197
+ const frontendStandalone = path.resolve(PROJECT_ROOT, 'frontend/.next/standalone');
198
+
199
+ if (!fs.existsSync(backendDist)) {
200
+ console.error('❌ Backend not built. Please run "fotric-claw build" first.\n');
201
+ rl.close();
202
+ return;
203
+ }
204
+
205
+ if (!fs.existsSync(frontendStandalone)) {
206
+ console.error('❌ Frontend not built. Please run "fotric-claw build" first.\n');
207
+ rl.close();
208
+ return;
209
+ }
210
+
179
211
  const backend = spawn('node', ['dist/main'], {
180
212
  cwd: path.resolve(PROJECT_ROOT, 'backend'),
181
213
  shell,
@@ -183,8 +215,8 @@ function startProdCommand() {
183
215
  });
184
216
 
185
217
  setTimeout(() => {
186
- const frontend = spawn('npm', ['run', 'start'], {
187
- cwd: path.resolve(PROJECT_ROOT, 'frontend'),
218
+ const frontend = spawn('node', ['server.js'], {
219
+ cwd: path.resolve(PROJECT_ROOT, 'frontend/.next/standalone'),
188
220
  shell,
189
221
  stdio: 'inherit'
190
222
  });
@@ -204,6 +236,13 @@ function startProdCommand() {
204
236
  }
205
237
 
206
238
  function buildCommand() {
239
+ if (isNpmInstalled()) {
240
+ console.log('\n⚠️ Build command not available in npm installation.');
241
+ console.log(' The package is already pre-built.\n');
242
+ rl.close();
243
+ return;
244
+ }
245
+
207
246
  console.log('\n📦 Building FotricCalw for production...\n');
208
247
 
209
248
  const isWindows = process.platform === 'win32';
@@ -236,6 +275,19 @@ function buildCommand() {
236
275
  console.error('❌ Frontend build failed');
237
276
  process.exit(frontendCode);
238
277
  }
278
+
279
+ const staticSrc = path.resolve(PROJECT_ROOT, 'frontend/.next/static');
280
+ const staticDest = path.resolve(PROJECT_ROOT, 'frontend/.next/standalone/.next/static');
281
+ if (fs.existsSync(staticSrc) && !fs.existsSync(staticDest)) {
282
+ fs.cpSync(staticSrc, staticDest, { recursive: true });
283
+ }
284
+
285
+ const publicSrc = path.resolve(PROJECT_ROOT, 'frontend/public');
286
+ const publicDest = path.resolve(PROJECT_ROOT, 'frontend/.next/standalone/public');
287
+ if (fs.existsSync(publicSrc) && !fs.existsSync(publicDest)) {
288
+ fs.cpSync(publicSrc, publicDest, { recursive: true });
289
+ }
290
+
239
291
  console.log('\n✅ Frontend build complete');
240
292
  console.log('\n🎉 Build complete! Run "fotric-claw start:prod" to start in production mode.\n');
241
293
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fotric-claw",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "FotricCalw - A lightweight, transparent AI Agent system",
5
5
  "author": "FOTRIC",
6
6
  "license": "MIT",
@@ -9,18 +9,24 @@
9
9
  },
10
10
  "files": [
11
11
  "bin/",
12
- "backend/",
13
- "frontend/",
12
+ "backend/dist/",
13
+ "backend/package.json",
14
+ "backend/.env.example",
15
+ "frontend/.next/standalone/",
16
+ "frontend/.next/static/",
17
+ "frontend/public/",
14
18
  "knowledge/",
15
19
  "storage/",
16
- "scripts/",
17
- "README.md"
20
+ "README.md",
21
+ "LICENSE"
18
22
  ],
19
23
  "scripts": {
20
- "backend": "cd backend && npm run start:dev",
21
- "frontend": "cd frontend && npm run dev",
24
+ "build": "npm run build:backend && npm run build:frontend",
22
25
  "build:backend": "cd backend && npm run build",
23
26
  "build:frontend": "cd frontend && npm run build",
27
+ "prepublishOnly": "npm run build",
28
+ "backend": "cd backend && npm run start:dev",
29
+ "frontend": "cd frontend && npm run dev",
24
30
  "install:all": "cd backend && npm install && cd ../frontend && npm install"
25
31
  },
26
32
  "keywords": [
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/nest-cli",
3
- "collection": "@nestjs/schematics",
4
- "sourceRoot": "src",
5
- "compilerOptions": {
6
- "deleteOutDir": true
7
- }
8
- }