65faf99e11
Make every text artifact that goes into Shira's system prompt editable from
the EspoCRM admin UI, with code-level defaults kept as a safety floor.
* AssistantRule + CaseMemory: flip `tab: true` so admins can browse/edit from
the navbar. No longer invisible.
* New entity AssistantPrompt — one row per prompt section (tool_rules,
writing_style, legal_assistance, personality_case, personality_office,
other_rules_case, other_rules_office). Edits in the UI override the
in-code defaults; an inactive or missing row falls back to code.
Seeded on install with the current Python defaults via AfterInstall.
* New entity UserProfile — replaces /opt/data/profiles/{uid}.md. ACL is
own/all/no so each lawyer sees their own, admins see all. Injected into
the prompt's '=== ABOUT THIS USER ===' block.
* New entity AssistantSkill — replaces /opt/data/skills/. Tab-visible.
Context provider returns metadata only; full body fetched on demand.
* 3 new ContextProviders (AssistantPrompt, UserProfile, AssistantSkill)
injected into context by SmartAssistantService::chat at the same point
AssistantRule has been injecting since 2026-05-27.
* 3 new Controller classes (one-liner extends Record) — without these
EspoCRM returns 404 on the REST endpoint even when scopes/entityDefs
are correct. Same pattern as the AssistantRule fix in 2.9.2.
* New custom view smart-assistant:views/fields/prompt-editor — monospace
font, dir=auto for mixed RTL/LTR, taller textarea. Used by all three
long-text content fields.
* New admin panel 'ניהול שירה' that groups all five surfaces (prompts,
rules, skills, user profiles, case memory) under one Admin section.
* Hebrew labels for all new scopes added to fa_IR/Global.json.
Paired with shira-hermes (separate commit): prompt_builder.py refactored
to read each section from context['assistantPrompts'] with code defaults
as fallback; save_memory tool now goes through SmartAssistant/action/executeTool
so CaseMemory actually gets populated instead of dropping 'm Notes.
Migration script scripts/migrate_legacy_memory_notes.py in shira-hermes
moves existing 'm Notes into CaseMemory rows (one-shot, idempotent).
Refs Task Master none — schema additions, no destructive changes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Espo\Modules\SmartAssistant\Services;
|
|
|
|
use Espo\ORM\EntityManager;
|
|
use Espo\Core\Utils\Log;
|
|
|
|
/**
|
|
* Loads the active UserProfile row for a given user into Shira's context.
|
|
*
|
|
* Returns the markdown body that becomes the "=== ABOUT THIS USER ===" block
|
|
* in the system prompt. Returns "" when no profile exists; the Python prompt
|
|
* builder treats empty string as "skip this section".
|
|
*/
|
|
class UserProfileContextProvider
|
|
{
|
|
private EntityManager $entityManager;
|
|
private Log $log;
|
|
|
|
public function __construct(EntityManager $entityManager, Log $log)
|
|
{
|
|
$this->entityManager = $entityManager;
|
|
$this->log = $log;
|
|
}
|
|
|
|
public function getProfileForUser(string $userId): string
|
|
{
|
|
if (!$userId) {
|
|
return '';
|
|
}
|
|
|
|
$entity = $this->entityManager->getRDBRepository('UserProfile')
|
|
->where([
|
|
'userId' => $userId,
|
|
'isActive' => true,
|
|
'deleted' => false,
|
|
])
|
|
->findOne();
|
|
|
|
if (!$entity) {
|
|
return '';
|
|
}
|
|
|
|
return (string) ($entity->get('content') ?? '');
|
|
}
|
|
}
|