Files
PromptX/core/project-base-integration.executing.md
2025-05-15 11:45:58 +08:00

2.3 KiB
Raw Blame History

记忆持久化规则

记忆存储规则

  1. 存储位置:记忆文件存储在项目根目录下的.memory目录中
  2. 目录创建:如果.memory目录不存在,需自动创建
  3. 文件命名使用class名称作为文件名.memory/{class}.context.md
  4. 文件格式使用Markdown格式存储记忆内容使用二级标题区分不同的context id

记忆文件结构

记忆文件采用以下结构:

---
class: class_name
---

## context_id_1
context_content_1

## context_id_2
context_content_2

记忆操作流程

flowchart TD
  A[开始] --> B{检查class文件是否存在}
  B -->|存在| C[读取已有记忆文件]
  B -->|不存在| D[创建新记忆文件]
  C --> E{检查context id是否存在}
  E -->|存在| F[更新已有context内容]
  E -->|不存在| G[添加新context内容]
  D --> G
  F --> H[保存记忆文件]
  G --> H
  H --> I[结束]

Context与Memory对接流程

文件组织规则

  1. Context按class分组存储
<context id="标识符" class="分类">内容</context>
→ .memory/{class}.context.md
  1. 在文件内通过二级标题区分不同id
## ${context.id}
${context.content}

对接流程

flowchart TD
    A[Context感知] --> B[提取class]
    B --> C[定位或创建class文件]
    C --> D[定位或创建context id段落]
    D --> E[更新context内容]
    E --> F[保存文件]
    
    style A fill:#4da6ff,stroke:#0066cc,color:white
    style B fill:#d94dbb,stroke:#a13b8f,color:white
    style C fill:#4dbb5f,stroke:#36873f,color:white
    style D fill:#ffa64d,stroke:#cc7a30,color:white
    style E fill:#4dbbbb,stroke:#368787,color:white
    style F fill:#71ff71,stroke:#3bc23b,color:white

示例结构

输入:

<context id="rootDir" class="project" confidence="0.95">
  /Users/sean/WorkSpaces/temp/promptx-init
</context>

输出文件 (.memory/project.context.md)

---
class: project
---

## rootDir
/Users/sean/WorkSpaces/temp/promptx-init

## otherProjectContext
其他项目相关上下文内容...

注意此对接流程采用按类分组的存储策略减少文件数量提高管理效率。每个class对应一个文件文件内使用二级标题组织不同的context内容。