Frag das Portal (0.64.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Failing after 19m38s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 24m17s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m13s
CI / Build-Artefakte aktuell (pull_request) Successful in 6m4s

Antworten mit Quellen aus Seiten, QM-Dokumenten, Glossar und Neuigkeiten –
nur aus Sichtbarem, über den KI-Assistenten (Anthropic, OpenAI, Ollama).
Wissensquellen als Registry für Plugins, Auswertung ohne Personenbezug.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-10-07 18:08:35 +00:00
parent 372f0656f9
commit 9d8bdc08ce
168 changed files with 1751 additions and 383 deletions

View file

@ -0,0 +1,66 @@
<?php
namespace Inhaus\Plugins\Qm;
use App\Ask\Knowledge;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Inhaus\Plugins\Qm\Models\QmEntry;
/**
* Wissensquelle für „Frag das Portal“: QM-Dokumente in Ordnern, die die Person sieht –
* mit dem Text der aktuellen Fassung (auch aus PDF und Office-Dateien).
*/
class QmKnowledge
{
public function __construct(private readonly QmTree $tree, private readonly QmAccess $access, private readonly Presenter $presenter) {}
/**
* @param list<string> $terms
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, array $terms, int $limit): array
{
if (! $this->access->allows($user)) {
return [];
}
$folders = $this->tree->visibleIds($user) ?: [0];
$byMeta = QmEntry::query()->whereIn('folder_id', $folders);
Knowledge::whereAny($byMeta, ['title', 'description'], $terms);
$ids = $byMeta->limit($limit)->pluck('id')->all();
$byText = DB::table('qm_files')->join('qm_entries', 'qm_entries.id', '=', 'qm_files.entry_id')
->whereIn('qm_entries.folder_id', $folders)->whereNull('qm_files.archived_at')->whereNotNull('qm_files.text');
Knowledge::whereAny($byText, ['qm_files.text'], $terms);
$ids = array_values(array_unique([...$ids, ...$byText->limit($limit * 2)->pluck('qm_files.entry_id')->map(fn ($id) => (int) $id)->all()]));
if ($ids === []) {
return [];
}
// Je Eintrag ein Text – die Lesefassung vor der Vorlage
$texts = [];
foreach (DB::table('qm_files')->whereIn('entry_id', $ids)->whereNull('archived_at')->whereNotNull('text')->get(['entry_id', 'kind', 'text']) as $row) {
if (! isset($texts[(int) $row->entry_id]) || $row->kind === 'reading') {
$texts[(int) $row->entry_id] = (string) $row->text;
}
}
return QmEntry::query()->whereIn('id', $ids)->with(['readingFile', 'editableFile'])->get()
->map(function (QmEntry $entry) use ($texts) {
$shown = $this->presenter->entry($entry);
$folder = $this->presenter->folderLabel($entry->folder_id);
return [
'title' => $entry->title,
'url' => $shown['open_url'] ?? $folder['url'],
'text' => trim(Knowledge::plain((string) $entry->description)."\n".($texts[$entry->id] ?? '')),
'meta' => collect([$folder['path'], $entry->version ? 'Version '.$entry->version : null])->filter()->implode(', ') ?: null,
];
})
->all();
}
}

View file

@ -2,6 +2,7 @@
namespace Inhaus\Plugins\Qm;
use App\Ask\Knowledge;
use App\Dashboard\Widgets;
use App\Models\User;
use App\Plugins\Plugin;
@ -19,6 +20,7 @@ class QmPlugin extends Plugin
public function register(): void
{
$this->app->make(GlobalSearch::class)->add('qm', 'Qualitätsmanagement', 'shield-check', fn (...$args) => app(QmSearch::class)(...$args), sort: 50);
$this->app->make(Knowledge::class)->add('qm', 'Qualitätsmanagement', fn (...$args) => app(QmKnowledge::class)(...$args));
foreach ([QmTree::class, QmAccess::class, Presenter::class, Search::class, Library::class, Reviews::class, Acknowledgements::class, Indexer::class, TextExtractor::class, Ocr::class] as $class) {
$this->app->singleton($class);