@eoasmxd/freya 0.5.0 → 0.5.1

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.
@@ -2,13 +2,13 @@ export interface FreyaPrompt {
2
2
  key: string;
3
3
  content: string;
4
4
  defaultPath: string;
5
- runPath?: string;
5
+ configFileName?: string;
6
6
  }
7
7
  /** 提示词内存注册表,管理所有系统及插件级提示词的分类检索 */
8
8
  export declare class FreyaPromptRegistry {
9
9
  private prompts;
10
- private getRunFilePath;
11
- /** 注册提示词元数据声明并执行异步双读载入 */
10
+ private resolveProbePaths;
11
+ /** 注册提示词元数据声明并执行三层级联探针载入 */
12
12
  register(prompt: Omit<FreyaPrompt, 'content'>): Promise<void>;
13
13
  /** 更新内存中的提示词文本内容 */
14
14
  updateContent(key: string, content: string): void;
@@ -16,7 +16,7 @@ export declare class FreyaPromptRegistry {
16
16
  unregister(key: string): void;
17
17
  get(key: string): string;
18
18
  getPrompts(): Map<string, FreyaPrompt>;
19
- /** 扫描并装载所有内核提示词,支持运行时提示词覆盖默认提示词 */
19
+ /** 扫描并装载所有内核提示词 */
20
20
  loadKernelPrompts(): Promise<void>;
21
21
  /** 获取并拼装完整的核心 System Prompt */
22
22
  getSystemPrompt(): string;
@@ -1,30 +1,49 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { FREYA_APP, FREYA_HOME } from '../utils/paths.js';
3
+ import { FREYA_APP, FREYA_HOME, FREYA_WORKSPACE } from '../utils/paths.js';
4
4
  /** 提示词内存注册表,管理所有系统及插件级提示词的分类检索 */
5
5
  export class FreyaPromptRegistry {
6
6
  prompts = new Map();
7
- getRunFilePath(prompt) {
8
- return prompt.runPath || path.join(FREYA_HOME, 'config', 'prompts', path.basename(prompt.defaultPath));
7
+ resolveProbePaths(prompt) {
8
+ const baseName = path.basename(prompt.defaultPath);
9
+ const rawPaths = [];
10
+ if (prompt.configFileName) {
11
+ rawPaths.push(path.join(FREYA_HOME, 'config', prompt.configFileName));
12
+ rawPaths.push(path.join(FREYA_WORKSPACE, 'config', prompt.configFileName));
13
+ }
14
+ rawPaths.push(path.join(FREYA_HOME, 'config', 'prompts', baseName));
15
+ rawPaths.push(path.join(FREYA_WORKSPACE, 'config', 'prompts', baseName));
16
+ rawPaths.push(prompt.defaultPath);
17
+ const candidates = [];
18
+ const seen = new Set();
19
+ for (const rawPath of rawPaths) {
20
+ const normalized = path.resolve(rawPath);
21
+ if (!seen.has(normalized)) {
22
+ seen.add(normalized);
23
+ candidates.push(normalized);
24
+ }
25
+ }
26
+ return candidates;
9
27
  }
10
- /** 注册提示词元数据声明并执行异步双读载入 */
28
+ /** 注册提示词元数据声明并执行三层级联探针载入 */
11
29
  async register(prompt) {
12
- const runFilePath = this.getRunFilePath(prompt);
30
+ const probePaths = this.resolveProbePaths(prompt);
13
31
  let content = '';
14
- try {
32
+ for (const filePath of probePaths) {
15
33
  try {
16
- content = await fs.readFile(runFilePath, 'utf-8');
17
- }
18
- catch {
19
- content = await fs.readFile(prompt.defaultPath, 'utf-8');
34
+ const text = await fs.readFile(filePath, 'utf-8');
35
+ if (text.trim().length > 0) {
36
+ content = text;
37
+ break;
38
+ }
20
39
  }
40
+ catch { }
21
41
  }
22
- catch { }
23
42
  this.prompts.set(prompt.key, {
24
43
  key: prompt.key,
25
44
  content: content.trim(),
26
45
  defaultPath: prompt.defaultPath,
27
- runPath: prompt.runPath
46
+ configFileName: prompt.configFileName
28
47
  });
29
48
  }
30
49
  /** 更新内存中的提示词文本内容 */
@@ -44,7 +63,7 @@ export class FreyaPromptRegistry {
44
63
  getPrompts() {
45
64
  return this.prompts;
46
65
  }
47
- /** 扫描并装载所有内核提示词,支持运行时提示词覆盖默认提示词 */
66
+ /** 扫描并装载所有内核提示词 */
48
67
  async loadKernelPrompts() {
49
68
  const defaultDirPath = path.join(FREYA_APP, 'config', 'prompts');
50
69
  try {
@@ -53,7 +72,7 @@ export class FreyaPromptRegistry {
53
72
  await this.register({
54
73
  key: `core.prompt.${name}`,
55
74
  defaultPath: path.join(defaultDirPath, `core.prompt.${name}.md`),
56
- runPath: path.join(FREYA_HOME, 'config', `${name.toUpperCase()}.md`)
75
+ configFileName: `${name.toUpperCase()}.md`
57
76
  });
58
77
  }
59
78
  try {
package/core/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eoasmxd/freya-core",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -16,7 +16,7 @@
16
16
  "clean": "rm -rf dist"
17
17
  },
18
18
  "dependencies": {
19
- "@eoasmxd/freya-sdk": "^0.5.0",
19
+ "@eoasmxd/freya-sdk": "^0.5.1",
20
20
  "ws": "^8.18.0"
21
21
  },
22
22
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eoasmxd/freya",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Freya - 微内核智能体系统",
@@ -35,7 +35,7 @@
35
35
  "src"
36
36
  ],
37
37
  "dependencies": {
38
- "@eoasmxd/freya-sdk": "^0.5.0",
38
+ "@eoasmxd/freya-sdk": "^0.5.1",
39
39
  "ws": "^8.18.0",
40
40
  "mysql2": "^3.11.0",
41
41
  "qrcode": "^1.5.4"
@@ -18,7 +18,7 @@
18
18
  "clean": "rm -rf dist"
19
19
  },
20
20
  "dependencies": {
21
- "@eoasmxd/freya-sdk": "^0.5.0"
21
+ "@eoasmxd/freya-sdk": "^0.5.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.0.0",
@@ -18,7 +18,7 @@
18
18
  "clean": "rm -rf dist"
19
19
  },
20
20
  "dependencies": {
21
- "@eoasmxd/freya-sdk": "^0.5.0"
21
+ "@eoasmxd/freya-sdk": "^0.5.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.0.0",
@@ -19,7 +19,7 @@
19
19
  "clean": "rm -rf dist"
20
20
  },
21
21
  "dependencies": {
22
- "@eoasmxd/freya-sdk": "^0.5.0"
22
+ "@eoasmxd/freya-sdk": "^0.5.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^22.0.0",
@@ -21,7 +21,7 @@
21
21
  "clean": "rm -rf dist"
22
22
  },
23
23
  "dependencies": {
24
- "@eoasmxd/freya-sdk": "^0.5.0"
24
+ "@eoasmxd/freya-sdk": "^0.5.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^22.0.0",
@@ -21,7 +21,7 @@
21
21
  "clean": "rm -rf dist"
22
22
  },
23
23
  "dependencies": {
24
- "@eoasmxd/freya-sdk": "^0.5.0"
24
+ "@eoasmxd/freya-sdk": "^0.5.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^22.0.0",
@@ -23,7 +23,7 @@
23
23
  "clean": "rm -rf dist"
24
24
  },
25
25
  "dependencies": {
26
- "@eoasmxd/freya-sdk": "^0.5.0",
26
+ "@eoasmxd/freya-sdk": "^0.5.1",
27
27
  "mysql2": "^3.11.0"
28
28
  },
29
29
  "devDependencies": {
@@ -22,7 +22,7 @@
22
22
  "clean": "rm -rf dist"
23
23
  },
24
24
  "dependencies": {
25
- "@eoasmxd/freya-sdk": "^0.5.0"
25
+ "@eoasmxd/freya-sdk": "^0.5.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.0.0",
@@ -19,7 +19,7 @@
19
19
  "clean": "rm -rf dist"
20
20
  },
21
21
  "dependencies": {
22
- "@eoasmxd/freya-sdk": "^0.5.0",
22
+ "@eoasmxd/freya-sdk": "^0.5.1",
23
23
  "ws": "^8.18.0"
24
24
  },
25
25
  "devDependencies": {
@@ -18,7 +18,7 @@
18
18
  "clean": "rm -rf dist"
19
19
  },
20
20
  "dependencies": {
21
- "@eoasmxd/freya-sdk": "^0.5.0",
21
+ "@eoasmxd/freya-sdk": "^0.5.1",
22
22
  "qrcode": "^1.5.4"
23
23
  },
24
24
  "devDependencies": {
@@ -1,39 +1,63 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { FREYA_APP, FREYA_HOME } from '../utils/paths.js';
3
+ import { FREYA_APP, FREYA_HOME, FREYA_WORKSPACE } from '../utils/paths.js';
4
4
 
5
5
  export interface FreyaPrompt {
6
6
  key: string;
7
7
  content: string;
8
8
  defaultPath: string;
9
- runPath?: string;
9
+ configFileName?: string;
10
10
  }
11
11
 
12
12
  /** 提示词内存注册表,管理所有系统及插件级提示词的分类检索 */
13
13
  export class FreyaPromptRegistry {
14
14
  private prompts = new Map<string, FreyaPrompt>();
15
15
 
16
- private getRunFilePath(prompt: Omit<FreyaPrompt, 'content'>): string {
17
- return prompt.runPath || path.join(FREYA_HOME, 'config', 'prompts', path.basename(prompt.defaultPath));
16
+ private resolveProbePaths(prompt: Omit<FreyaPrompt, 'content'>): string[] {
17
+ const baseName = path.basename(prompt.defaultPath);
18
+ const rawPaths: string[] = [];
19
+
20
+ if (prompt.configFileName) {
21
+ rawPaths.push(path.join(FREYA_HOME, 'config', prompt.configFileName));
22
+ rawPaths.push(path.join(FREYA_WORKSPACE, 'config', prompt.configFileName));
23
+ }
24
+
25
+ rawPaths.push(path.join(FREYA_HOME, 'config', 'prompts', baseName));
26
+ rawPaths.push(path.join(FREYA_WORKSPACE, 'config', 'prompts', baseName));
27
+ rawPaths.push(prompt.defaultPath);
28
+
29
+ const candidates: string[] = [];
30
+ const seen = new Set<string>();
31
+ for (const rawPath of rawPaths) {
32
+ const normalized = path.resolve(rawPath);
33
+ if (!seen.has(normalized)) {
34
+ seen.add(normalized);
35
+ candidates.push(normalized);
36
+ }
37
+ }
38
+ return candidates;
18
39
  }
19
40
 
20
- /** 注册提示词元数据声明并执行异步双读载入 */
41
+ /** 注册提示词元数据声明并执行三层级联探针载入 */
21
42
  async register(prompt: Omit<FreyaPrompt, 'content'>): Promise<void> {
22
- const runFilePath = this.getRunFilePath(prompt);
43
+ const probePaths = this.resolveProbePaths(prompt);
23
44
  let content = '';
24
- try {
45
+
46
+ for (const filePath of probePaths) {
25
47
  try {
26
- content = await fs.readFile(runFilePath, 'utf-8');
27
- } catch {
28
- content = await fs.readFile(prompt.defaultPath, 'utf-8');
29
- }
30
- } catch {}
48
+ const text = await fs.readFile(filePath, 'utf-8');
49
+ if (text.trim().length > 0) {
50
+ content = text;
51
+ break;
52
+ }
53
+ } catch {}
54
+ }
31
55
 
32
56
  this.prompts.set(prompt.key, {
33
57
  key: prompt.key,
34
58
  content: content.trim(),
35
59
  defaultPath: prompt.defaultPath,
36
- runPath: prompt.runPath
60
+ configFileName: prompt.configFileName
37
61
  });
38
62
  }
39
63
 
@@ -58,7 +82,7 @@ export class FreyaPromptRegistry {
58
82
  return this.prompts;
59
83
  }
60
84
 
61
- /** 扫描并装载所有内核提示词,支持运行时提示词覆盖默认提示词 */
85
+ /** 扫描并装载所有内核提示词 */
62
86
  async loadKernelPrompts(): Promise<void> {
63
87
  const defaultDirPath = path.join(FREYA_APP, 'config', 'prompts');
64
88
  try {
@@ -67,7 +91,7 @@ export class FreyaPromptRegistry {
67
91
  await this.register({
68
92
  key: `core.prompt.${name}`,
69
93
  defaultPath: path.join(defaultDirPath, `core.prompt.${name}.md`),
70
- runPath: path.join(FREYA_HOME, 'config', `${name.toUpperCase()}.md`)
94
+ configFileName: `${name.toUpperCase()}.md`
71
95
  });
72
96
  }
73
97