107 lines
4.8 KiB
Vue
107 lines
4.8 KiB
Vue
<script setup lang="ts">
|
|
import { computed, ref, type Component } from "vue";
|
|
import { BookOpen, GitPullRequest, KeyRound, MessageSquare, Package, Plus, Search, UserCog, Workflow, Zap } from "@lucide/vue";
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
|
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group";
|
|
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item";
|
|
import { useExtensionsStore, type CatalogueEntry } from "@/stores/extensions";
|
|
|
|
/**
|
|
* The catalogue, grouped by what each package extends. Installed packages stay
|
|
* listed so the catalogue reads whole; they offer an update when one exists.
|
|
*/
|
|
const props = defineProps<{ updates: Map<string, CatalogueEntry> }>();
|
|
const store = useExtensionsStore();
|
|
|
|
// Surfaces in the order an operator sets archie up: where work comes from and
|
|
// goes, then credentials, then what agents do.
|
|
const SURFACES: { id: string; label: string; icon: Component }[] = [
|
|
{ id: "forge", label: "Forges", icon: GitPullRequest },
|
|
{ id: "channels", label: "Channels", icon: MessageSquare },
|
|
{ id: "secret-engines", label: "Secret engines", icon: KeyRound },
|
|
{ id: "workflows", label: "Workflows", icon: Workflow },
|
|
{ id: "playbooks", label: "Playbooks", icon: Zap },
|
|
{ id: "skills", label: "Skills", icon: BookOpen },
|
|
{ id: "profiles", label: "Agent profiles", icon: UserCog },
|
|
];
|
|
|
|
const query = ref("");
|
|
const groups = computed(() => {
|
|
const q = query.value.trim().toLowerCase();
|
|
const matching = store.catalogue.filter(
|
|
(entry) => !q || entry.name.toLowerCase().includes(q) || entry.description.toLowerCase().includes(q),
|
|
);
|
|
const known = new Set(SURFACES.map((s) => s.id));
|
|
const other = { id: "other", label: "Other", icon: Package };
|
|
return [...SURFACES, other]
|
|
.map((surface) => ({
|
|
...surface,
|
|
entries: matching.filter((e) => (surface.id === "other" ? !known.has(e.surface) : e.surface === surface.id)),
|
|
}))
|
|
.filter((group) => group.entries.length > 0);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="space-y-6">
|
|
<InputGroup class="max-w-sm">
|
|
<InputGroupAddon><Search /></InputGroupAddon>
|
|
<InputGroupInput v-model="query" type="search" placeholder="Search extensions" aria-label="Search extensions" />
|
|
</InputGroup>
|
|
|
|
<section v-for="group in groups" :key="group.id" :aria-labelledby="`surface-${group.id}`">
|
|
<h2 :id="`surface-${group.id}`" class="mb-2 flex items-center gap-2 text-label font-semibold">
|
|
<component :is="group.icon" class="size-4 text-fg-subtle" aria-hidden="true" />
|
|
{{ group.label }}
|
|
<span class="font-normal text-fg-subtle">{{ group.entries.length }}</span>
|
|
</h2>
|
|
<ul class="grid gap-2 @3xl:grid-cols-2">
|
|
<li v-for="entry in group.entries" :key="entry.name" class="flex">
|
|
<Item variant="outline" class="h-full flex-nowrap items-start bg-card">
|
|
<ItemMedia class="mt-0.5 size-8 rounded-md bg-muted">
|
|
<component :is="group.icon" class="size-4 text-fg-muted" aria-hidden="true" />
|
|
</ItemMedia>
|
|
<ItemContent class="min-w-0">
|
|
<ItemTitle>
|
|
{{ entry.name }}
|
|
<span class="font-mono text-caption font-normal text-fg-subtle">{{ entry.version }}</span>
|
|
</ItemTitle>
|
|
<ItemDescription class="text-caption" :title="entry.description">{{ entry.description }}</ItemDescription>
|
|
</ItemContent>
|
|
<ItemActions class="self-center">
|
|
<Button
|
|
v-if="props.updates.has(entry.name)"
|
|
variant="outline"
|
|
size="sm"
|
|
:disabled="!!store.busy"
|
|
@click="store.update(entry.name)"
|
|
>Update to {{ entry.version }}</Button
|
|
>
|
|
<Badge v-else-if="entry.installed" variant="ok">Installed</Badge>
|
|
<Button
|
|
v-else
|
|
variant="outline"
|
|
size="sm"
|
|
:disabled="!!store.busy"
|
|
:aria-label="`Install ${entry.name}`"
|
|
@click="store.installFromCatalogue(entry.name)"
|
|
><Plus data-icon="inline-start" />Install</Button
|
|
>
|
|
</ItemActions>
|
|
</Item>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<p v-if="!store.catalogueLoaded && !store.catalogueError" class="py-6 text-center text-label text-fg-muted" role="status">Loading catalogue…</p>
|
|
<Empty v-else-if="!groups.length" class="py-6">
|
|
<EmptyHeader>
|
|
<EmptyTitle>{{ store.catalogue.length ? "No extensions match" : "The catalogue is empty" }}</EmptyTitle>
|
|
</EmptyHeader>
|
|
</Empty>
|
|
</div>
|
|
</template>
|