Files
fidelity-ai-workspace/.agents/workflows/latest-message.md

77 lines
2.8 KiB
Markdown

---
description: Force-sync Mattermost and answer from the latest matching message
---
Force-refresh Mattermost first, then answer the user's question from the refreshed inbox.
Use this when the user asks for:
- the latest or last message
- what Jeff or another person just said
- the latest Mattermost update
- the latest message in `fidelity-preguntas`
Run sync:
!`start=$(date +%s); if [ -n "$AIW_MATTERMOST_SYNC_CMD" ]; then bash -lc "$AIW_MATTERMOST_SYNC_CMD"; elif [ -n "$FIDELITY_MATTERMOST_SYNC_CMD" ]; then bash -lc "$FIDELITY_MATTERMOST_SYNC_CMD"; elif [ -f scripts/mattermost/sync.sh ]; then bash scripts/mattermost/sync.sh; else echo "No Mattermost sync command is configured."; fi; status=$?; end=$(date +%s); echo "__MATTERMOST_SYNC_SECONDS__=$((end - start))"; exit "$status"`
Read a focused slice of refreshed Mattermost context:
!`python3 - <<'PY'
import json
from pathlib import Path
paths = [
Path("ai/inbox/mattermost-latest.md"),
Path("scripts/mattermost/generated/mattermost_context.jsonl"),
]
source = next((path for path in paths if path.is_file() and path.stat().st_size > 0), None)
if not source:
print("No Mattermost context available after sync.")
raise SystemExit(0)
records = []
for line in source.read_text().splitlines():
line = line.strip()
if not line:
continue
try:
records.append(json.loads(line))
except json.JSONDecodeError:
continue
manager_names = {"jeff", "jeff.dewitte"}
manager_records = [
record for record in records
if str(record.get("username", "")).lower() in manager_names
]
focused = manager_records[-10:] if manager_records else records[-15:]
for record in focused:
print(json.dumps(record, ensure_ascii=False))
PY`
User request:
$ARGUMENTS
Instructions:
- Do not answer from old conversation memory.
- Use only the focused refreshed Mattermost output above.
- If the user asks for the current manager/stakeholder, filter messages by the profile mapping when visible; for the Fidelity profile, also match `jeff` and `jeff.dewitte`.
- If multiple messages match, return the newest matching message first.
- Include timestamp, channel, sender, and concise summary.
- Do not edit workspace memory in this command.
- If the message appears to change project context, report it as a memory update candidate and name the likely target file.
- Use `/communication-sync` or an explicit user request to promote the fact after the latest-message answer is complete.
- If sync fails or no refreshed context is available, say that directly and do not infer from stale context.
- If a write or patch attempt fails in this flow, stop immediately and return the latest-message answer plus the failed target; do not retry.
Return:
1. Latest matching message
2. Why it matters
3. Memory update candidate, if any