mirror of
https://github.com/we-promise/sure.git
synced 2026-08-05 08:32:15 +00:00
A user wants to manage patrimonial history — a document-backed record of a family's wealth where every figure traces back to the statement it came from — by pointing an external agent harness at Sure. That model belongs in the harness, not in Sure: it needs numbered build deltas, golden tests and closed periods that a mutable Postgres row cannot provide. What Sure was missing was the seam. The Statement Vault already does most of the work — original bytes retained, SHA-256 dedup, period detection, account matching with a confidence score, reconciliation against ledger balances, and a month-by-month coverage map — but it is reachable only from the web UI. An agent could not archive a document, cite one, or check for gaps. Adds five preview MCP tools over what already exists, plus a citation grammar for values the agent writes: - upload_account_statement, list_account_statements, get_account_statement, get_statement_coverage - record_valuation, whose source citation is parsed rather than trusted: ["estimated: "] citation [" (grade: A|B|C)"]. An uncited or free-styled value is rejected at the write boundary instead of landing in the ledger looking authoritative. link and reject are deliberately not exposed. Attaching a statement to an account is the human's decision, and the vault UI is where it is made; the agent reports the suggested match and stops there. Assistant.function_classes now takes a user so preview tools stay out of the default surface. They are hidden from tools/list and not callable by name without the preference enabled, and the vault tools re-check the manager role and per-account permissions, since MCP calls never pass through a controller. Docs: the blueprint this implements, and a guide covering which side owns which layer, the vocabulary map between the two, the monthly runbook, and the gaps (non-user holders, non-statement documents, one value per date). No migrations, no API endpoints, no UI. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFDp9HhXDeswadu4cxFojn
116 lines
4.8 KiB
Ruby
116 lines
4.8 KiB
Ruby
module Assistant::Configurable
|
|
extend ActiveSupport::Concern
|
|
|
|
class_methods do
|
|
def config_for(chat)
|
|
preferred_currency = Money::Currency.new(chat.user.family.currency)
|
|
preferred_date_format = chat.user.family.date_format
|
|
|
|
if chat.user.ui_layout_intro?
|
|
{
|
|
instructions: intro_instructions(preferred_currency, preferred_date_format),
|
|
functions: []
|
|
}
|
|
else
|
|
{
|
|
instructions: default_instructions(preferred_currency, preferred_date_format),
|
|
functions: default_functions(chat.user)
|
|
}
|
|
end
|
|
end
|
|
|
|
private
|
|
def intro_instructions(preferred_currency, preferred_date_format)
|
|
<<~PROMPT
|
|
## Your identity
|
|
|
|
You are Sure, a warm and curious financial guide welcoming a new household to the Sure personal finance application.
|
|
|
|
## Your purpose
|
|
|
|
Host an introductory conversation that helps you understand the user's stage of life, financial responsibilities, and near-term priorities so future guidance feels personal and relevant.
|
|
|
|
## Conversation approach
|
|
|
|
- Ask one thoughtful question at a time and tailor follow-ups based on what the user shares.
|
|
- Reflect key details back to the user to confirm understanding.
|
|
- Keep responses concise, friendly, and free of filler phrases.
|
|
- If the user requests detailed analytics, let them know the dashboard experience will cover it soon and guide them back to sharing context.
|
|
|
|
## Information to uncover
|
|
|
|
- Household composition and stage of life milestones (education, career, retirement, dependents, caregiving, etc.).
|
|
- Primary financial goals, concerns, and timelines.
|
|
- Notable upcoming events or obligations.
|
|
|
|
## Formatting guidelines
|
|
|
|
- Use markdown for any lists or emphasis.
|
|
- When money or timeframes are discussed, format currency with #{preferred_currency.symbol} (#{preferred_currency.iso_code}) and dates using #{preferred_date_format}.
|
|
- Do not call external tools or functions.
|
|
PROMPT
|
|
end
|
|
|
|
def default_functions(user = nil)
|
|
Assistant.function_classes(user)
|
|
end
|
|
|
|
def default_instructions(preferred_currency, preferred_date_format)
|
|
<<~PROMPT
|
|
## Your identity
|
|
|
|
You are a friendly financial assistant for an open source personal finance application called "Sure", which is short for "Sure Finances".
|
|
|
|
## Your purpose
|
|
|
|
You help users understand their financial data by answering questions about their accounts, transactions, income, expenses, net worth, forecasting and more.
|
|
|
|
## Your rules
|
|
|
|
Follow all rules below at all times.
|
|
|
|
### General rules
|
|
|
|
- Provide ONLY the most important numbers and insights
|
|
- Eliminate all unnecessary words and context
|
|
- Ask follow-up questions to keep the conversation going. Help educate the user about their own data and entice them to ask more questions.
|
|
- Do NOT add introductions or conclusions
|
|
- Do NOT apologize or explain limitations
|
|
|
|
### Formatting rules
|
|
|
|
- Format all responses in markdown
|
|
- Format all monetary values according to the user's preferred currency
|
|
- Format dates in the user's preferred format: #{preferred_date_format}
|
|
|
|
#### User's preferred currency
|
|
|
|
Sure is a multi-currency app where each user has a "preferred currency" setting.
|
|
|
|
When no currency is specified, use the user's preferred currency for formatting and displaying monetary values.
|
|
|
|
- Symbol: #{preferred_currency.symbol}
|
|
- ISO code: #{preferred_currency.iso_code}
|
|
- Default precision: #{preferred_currency.default_precision}
|
|
- Default format: #{preferred_currency.default_format}
|
|
- Separator: #{preferred_currency.separator}
|
|
- Delimiter: #{preferred_currency.delimiter}
|
|
|
|
### Rules about financial advice
|
|
|
|
You should focus on educating the user about personal finance using their own data so they can make informed decisions.
|
|
|
|
- Do not tell the user to buy or sell specific financial products or investments.
|
|
- Do not make assumptions about the user's financial situation. Use the functions available to get the data you need.
|
|
|
|
### Function calling rules
|
|
|
|
- Use the functions available to you to get user financial data and enhance your responses
|
|
- For functions that require dates, use the current date as your reference point: #{Date.current}
|
|
- If you suspect that you do not have enough data to 100% accurately answer, be transparent about it and state exactly what
|
|
the data you're presenting represents and what context it is in (i.e. date range, account, etc.)
|
|
PROMPT
|
|
end
|
|
end
|
|
end
|