@code4bug/jarvis-agent 1.1.5 → 1.1.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 (38) hide show
  1. package/README.md +171 -215
  2. package/dist/commands/index.d.ts +2 -0
  3. package/dist/commands/index.js +17 -15
  4. package/dist/components/MultilineInput.js +2 -2
  5. package/dist/components/WelcomeHeader.js +1 -1
  6. package/dist/config/dream.d.ts +10 -0
  7. package/dist/config/dream.js +60 -0
  8. package/dist/config/memory.d.ts +7 -0
  9. package/dist/config/memory.js +55 -0
  10. package/dist/config/userProfile.d.ts +5 -1
  11. package/dist/config/userProfile.js +15 -2
  12. package/dist/core/QueryEngine.d.ts +11 -0
  13. package/dist/core/QueryEngine.js +104 -8
  14. package/dist/core/WorkerBridge.d.ts +3 -1
  15. package/dist/core/WorkerBridge.js +2 -2
  16. package/dist/core/query.d.ts +5 -1
  17. package/dist/core/query.js +4 -4
  18. package/dist/core/queryWorker.d.ts +3 -0
  19. package/dist/core/queryWorker.js +1 -1
  20. package/dist/hooks/useSlashMenu.d.ts +3 -1
  21. package/dist/hooks/useSlashMenu.js +58 -71
  22. package/dist/screens/repl.js +63 -34
  23. package/dist/services/api/llm.d.ts +5 -2
  24. package/dist/services/api/llm.js +28 -7
  25. package/dist/services/api/mock.d.ts +3 -1
  26. package/dist/services/api/mock.js +1 -1
  27. package/dist/services/dream.d.ts +7 -0
  28. package/dist/services/dream.js +171 -0
  29. package/dist/services/persistentMemory.d.ts +8 -0
  30. package/dist/services/persistentMemory.js +178 -0
  31. package/dist/services/userProfile.d.ts +1 -0
  32. package/dist/services/userProfile.js +15 -0
  33. package/dist/tools/index.d.ts +2 -1
  34. package/dist/tools/index.js +3 -1
  35. package/dist/tools/manageMemory.d.ts +2 -0
  36. package/dist/tools/manageMemory.js +46 -0
  37. package/dist/types/index.d.ts +3 -1
  38. package/package.json +3 -3
@@ -11,13 +11,15 @@ import { sendToAgent } from './sendToAgent.js';
11
11
  import { publishMessage } from './publishMessage.js';
12
12
  import { subscribeMessage } from './subscribeMessage.js';
13
13
  import { readChannel } from './readChannel.js';
14
- export { readFile, writeFile, runCommand, listDirectory, searchFiles, semanticSearch, createSkill, runAgent, spawnAgent, sendToAgent, publishMessage, subscribeMessage, readChannel, };
14
+ import { manageMemory } from './manageMemory.js';
15
+ export { readFile, writeFile, runCommand, listDirectory, searchFiles, semanticSearch, createSkill, runAgent, spawnAgent, sendToAgent, publishMessage, subscribeMessage, readChannel, manageMemory, };
15
16
  /** 所有内置工具 */
16
17
  export const allTools = [
17
18
  readFile, writeFile, runCommand, listDirectory, searchFiles,
18
19
  semanticSearch, createSkill,
19
20
  runAgent, spawnAgent, sendToAgent,
20
21
  publishMessage, subscribeMessage, readChannel,
22
+ manageMemory,
21
23
  ];
22
24
  /** 按名称查找内置工具 */
23
25
  export function findTool(name) {
@@ -0,0 +1,2 @@
1
+ import { Tool } from '../types/index.js';
2
+ export declare const manageMemory: Tool;
@@ -0,0 +1,46 @@
1
+ import { MEMORY_FILE_PATH, appendPersistentMemory, readPersistentMemory, replacePersistentMemory, ensureMemoryFile, } from '../config/memory.js';
2
+ export const manageMemory = {
3
+ name: 'manage_memory',
4
+ description: [
5
+ '管理智能体长期记忆文件 ~/.jarvis/MEMORY.md。',
6
+ '可读取、追加、覆盖记忆,也可返回记忆文件路径。',
7
+ '适合沉淀可复用的经验、技能、偏好、约束和稳定环境事实。',
8
+ ].join('\n'),
9
+ parameters: {
10
+ action: {
11
+ type: 'string',
12
+ description: '操作类型:read | append | replace | path',
13
+ required: true,
14
+ },
15
+ content: {
16
+ type: 'string',
17
+ description: 'append 或 replace 时要写入的 Markdown 内容',
18
+ required: false,
19
+ },
20
+ },
21
+ execute: async (args) => {
22
+ const action = String(args.action || '').trim();
23
+ ensureMemoryFile();
24
+ if (action === 'path') {
25
+ return MEMORY_FILE_PATH;
26
+ }
27
+ if (action === 'read') {
28
+ return readPersistentMemory() || '(MEMORY.md 为空)';
29
+ }
30
+ if (action === 'append') {
31
+ const content = String(args.content || '').trim();
32
+ if (!content)
33
+ throw new Error('append 操作需要提供 content');
34
+ appendPersistentMemory(content);
35
+ return `长期记忆已追加到 ${MEMORY_FILE_PATH}`;
36
+ }
37
+ if (action === 'replace') {
38
+ const content = String(args.content || '').trim();
39
+ if (!content)
40
+ throw new Error('replace 操作需要提供 content');
41
+ replacePersistentMemory(content);
42
+ return `长期记忆已覆盖写入 ${MEMORY_FILE_PATH}`;
43
+ }
44
+ throw new Error(`不支持的 action: ${action}`);
45
+ },
46
+ };
@@ -100,7 +100,9 @@ export interface TranscriptMessage {
100
100
  toolUseId?: string;
101
101
  }
102
102
  export interface LLMService {
103
- streamMessage: (transcript: TranscriptMessage[], tools: Tool[], callbacks: StreamCallbacks, abortSignal?: AbortSignal) => Promise<void>;
103
+ streamMessage: (transcript: TranscriptMessage[], tools: Tool[], callbacks: StreamCallbacks, abortSignal?: AbortSignal, options?: {
104
+ includeUserProfile?: boolean;
105
+ }) => Promise<void>;
104
106
  }
105
107
  /** SubAgent 状态 */
106
108
  export type SubAgentStatus = 'idle' | 'running' | 'done' | 'error' | 'aborted';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code4bug/jarvis-agent",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "基于 React + TypeScript + Ink 构建的命令行智能体交互界面",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "license": "MIT",
36
36
  "author": "Code4Bug",
37
- "homepage": "https://github.com/Code4Bug/jarvis#readme",
37
+ "homepage": "https://github.com/Code4Bug/jarvis#readme",
38
38
  "repository": {
39
39
  "type": "git",
40
40
  "url": "git+https://github.com/Code4Bug/jarvis.git"
@@ -52,4 +52,4 @@
52
52
  "typescript",
53
53
  "terminal"
54
54
  ]
55
- }
55
+ }