| 102 | } |
| 103 | |
| 104 | func (t *projectFactTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error) { |
| 105 | fact, _ := input["fact"].(string) |
| 106 | if fact == "" { |
| 107 | return nil, errors.New("fact is required") |
| 108 | } |
| 109 | |
| 110 | scope := memory.Scope{ |
| 111 | UserID: t.userID, |
| 112 | ProjectID: t.projectID, |
| 113 | Shared: t.shared, |
| 114 | } |
| 115 | ns := scope.Namespace() |
| 116 | |
| 117 | payload := map[string]any{ |
| 118 | "file": "facts.md", |
| 119 | "namespace": ns, |
| 120 | "mode": "append", |
| 121 | "title": "Project fact", |
| 122 | "content": fact, |
| 123 | } |
| 124 | |
| 125 | return t.memoryWrite.Execute(ctx, payload, tc) |
| 126 | } |
| 127 | |
| 128 | func (t *projectFactTool) Prompt() string { |
| 129 | return `Use this tool to store stable project-level facts and conventions, such as coding standards, deployment rules, and critical decisions.` |