compassmock/src/components/ai/package-info.tsx
Nicholai 8b34becbeb
feat(agent): AI agent harness with memory, GitHub, audio & feedback (#37)
* feat(agent): replace ElizaOS with AI SDK v6 harness

Replace custom ElizaOS sidecar proxy with Vercel AI SDK v6 +
OpenRouter provider for a proper agentic harness with multi-step
tool loops, streaming, and D1 conversation persistence.

- Add AI SDK agent library (provider, tools, system prompt, catalog)
- Rewrite API route to use streamText with 10-step tool loop
- Add server actions for conversation save/load/delete
- Migrate chat-panel and dashboard-chat to useChat hook
- Add action handler dispatch for navigate/toast/render tools
- Use qwen/qwen3-coder-next via OpenRouter (fallbacks disabled)
- Delete src/lib/eliza/ (replaced entirely)
- Exclude references/ from tsconfig build

* fix(chat): improve dashboard chat scroll and text size

- Rewrite auto-scroll: pin user message 75% out of
  frame after send, then follow bottom during streaming
- Use useEffect for scroll timing (DOM guaranteed ready)
  instead of rAF which fired before React commit
- Add user scroll detection to disengage auto-scroll
- Bump assistant text from 13px back to 14px (text-sm)
- Tighten prose spacing for headings and lists

* chore: installing new components

* refactor(chat): unify into one component, two presentations

Extract duplicated chat logic into shared ChatProvider context
and useCompassChat hook. Single ChatView component renders as
full-page hero on /dashboard or sidebar panel elsewhere. Chat
state persists across navigation.

New: chat-provider, chat-view, chat-panel-shell, use-compass-chat
Delete: agent-provider, chat-panel, dashboard-chat, 8 deprecated UI files
Fix: AI component import paths (~/  -> @/), shadcn component updates

* fix(lint): resolve eslint errors in AI components

- escape unescaped entities in demo JSX (actions, artifact,
  branch, reasoning, schema-display, task)
- add eslint-disable for @ts-nocheck in vendor components
  (file-tree, terminal, persona)
- remove unused imports in chat-view (ArrowUp, Square,
  useChatPanel)

* feat(agent): rename AI to Slab, add proactive help

rename assistant from Compass to Slab and add first
interaction guidance so it proactively offers
context-aware help based on the user's current page.

* fix(build): use HTML entity for strict string children

ReasoningContent expects children: string, so JSX
expression {"'"} splits into string[] causing type error.
Use ' HTML entity instead.

* feat(agent): add memory, github, audio, feedback

- persistent memory system (remember/recall across sessions)
- github integration (commits, PRs, issues, contributors)
- audio transcription via Whisper API
- UX feedback interview flow with auto-issue creation
- memories management table in settings
- audio waveform visualization component
- new schema tables: slab_memories, feedback_interviews
- enhanced system prompt with proactive tool usage

* feat(agent): unify chat into single morphing instance

Replaces two separate ChatView instances (page + panel) with
one layout-level component that transitions between full-page
and sidebar modes. Navigation now actually works via proper
AI SDK v6 part structure detection, with view transitions for
smooth crossfades, route validation to prevent 404s, and
auto-opening the panel when leaving dashboard.

Also fixes dark mode contrast, user bubble visibility, tool
display names, input focus ring, and system prompt accuracy.

* refactor(agent): rewrite waveform as time-series viz

Replace real-time frequency equalizer with amplitude
history that fills left-to-right as user speaks.
Bars auto-calculated from container width, with
non-linear boost and scroll when full.

* (feat): implemented architecture for plugins and skills, laying a foundation for future implementations of packages separate from the core application

* feat(agent): add skills.sh integration for slab

Skills client fetches SKILL.md from GitHub, parses
YAML frontmatter, and stores content in plugin DB.
Registry injects skill content into system prompt.
Agent tools and settings UI for skill management.

* feat(agent): add interactive UI action bridge

Wire agent-generated UIs to real server actions via
an action bridge API route. Forms submit, checkboxes
persist, and DataTable rows support CRUD operations.

- action-registry.ts: maps 19 dotted action names to
  server actions with zod validation + permissions
- /api/agent/action: POST route with auth, permission
  checks, schema validation, and action execution
- schema-agent.ts: agent_items table for user-scoped
  todos, notes, and checklists
- agent-items.ts: CRUD + toggle actions for agent items
- form-context.ts: FormIdProvider for input namespacing
- catalog.ts: Form component, value/onChangeAction props,
  DataTable rowActions, mutate/confirmDelete actions
- registry.tsx: useDataBinding on all form inputs, Form
  component, DataTable row action buttons, inline
  Checkbox/Switch mutations
- actions.ts: mutate + confirmDelete handlers that call
  the action bridge, formSubmit now collects + submits
- system-prompt.ts: interactive UI patterns section
- render/route.ts: interactive pattern custom rules

* docs: reorganize into topic subdirectories

Move docs into auth/, chat/, openclaw-principles/,
and ui/ subdirectories. Add openclaw architecture
and system prompt documentation.

* feat(agent): add commit diff support to github tools

Add fetchCommitDiff to github client with raw diff
fallback for missing patches. Wire commit_diff query
type into agent github tools.

* fix(ci): guard wrangler proxy init for dev only

initOpenNextCloudflareForDev() was running unconditionally
in next.config.ts, causing CI build and lint to fail with
"You must be logged in to use wrangler dev in remote mode".
Only init the proxy when NODE_ENV is development.

---------

Co-authored-by: Nicholai <nicholaivogelfilms@gmail.com>
2026-02-06 17:04:04 -07:00

238 lines
6.9 KiB
TypeScript
Executable File

"use client"
import { ArrowRightIcon, MinusIcon, PackageIcon, PlusIcon } from "lucide-react"
import { createContext, type HTMLAttributes, type ReactNode, useContext } from "react"
import { Badge } from "@/components/ui/badge"
import { cn } from "@/lib/utils"
type ChangeType = "major" | "minor" | "patch" | "added" | "removed"
interface PackageInfoContextType {
name: string
currentVersion?: string
newVersion?: string
changeType?: ChangeType
}
const PackageInfoContext = createContext<PackageInfoContextType>({
name: "",
})
export type PackageInfoProps = HTMLAttributes<HTMLDivElement> & {
name: string
currentVersion?: string
newVersion?: string
changeType?: ChangeType
}
export const PackageInfo = ({
name,
currentVersion,
newVersion,
changeType,
className,
children,
...props
}: PackageInfoProps) => (
<PackageInfoContext.Provider value={{ name, currentVersion, newVersion, changeType }}>
<div className={cn("rounded-lg border bg-background p-4", className)} {...props}>
{children ?? (
<>
<PackageInfoHeader>
<PackageInfoName />
{changeType && <PackageInfoChangeType />}
</PackageInfoHeader>
{(currentVersion || newVersion) && <PackageInfoVersion />}
</>
)}
</div>
</PackageInfoContext.Provider>
)
export type PackageInfoHeaderProps = HTMLAttributes<HTMLDivElement>
export const PackageInfoHeader = ({ className, children, ...props }: PackageInfoHeaderProps) => (
<div className={cn("flex items-center justify-between gap-2", className)} {...props}>
{children}
</div>
)
export type PackageInfoNameProps = HTMLAttributes<HTMLDivElement>
export const PackageInfoName = ({ className, children, ...props }: PackageInfoNameProps) => {
const { name } = useContext(PackageInfoContext)
return (
<div className={cn("flex items-center gap-2", className)} {...props}>
<PackageIcon className="size-4 text-muted-foreground" />
<span className="font-medium font-mono text-sm">{children ?? name}</span>
</div>
)
}
const changeTypeStyles: Record<ChangeType, string> = {
major: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",
minor: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
patch: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
added: "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",
removed: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
}
const changeTypeIcons: Record<ChangeType, ReactNode> = {
major: <ArrowRightIcon className="size-3" />,
minor: <ArrowRightIcon className="size-3" />,
patch: <ArrowRightIcon className="size-3" />,
added: <PlusIcon className="size-3" />,
removed: <MinusIcon className="size-3" />,
}
export type PackageInfoChangeTypeProps = HTMLAttributes<HTMLDivElement>
export const PackageInfoChangeType = ({
className,
children,
...props
}: PackageInfoChangeTypeProps) => {
const { changeType } = useContext(PackageInfoContext)
if (!changeType) {
return null
}
return (
<Badge
className={cn("gap-1 text-xs capitalize", changeTypeStyles[changeType], className)}
variant="secondary"
{...props}
>
{changeTypeIcons[changeType]}
{children ?? changeType}
</Badge>
)
}
export type PackageInfoVersionProps = HTMLAttributes<HTMLDivElement>
export const PackageInfoVersion = ({ className, children, ...props }: PackageInfoVersionProps) => {
const { currentVersion, newVersion } = useContext(PackageInfoContext)
if (!(currentVersion || newVersion)) {
return null
}
return (
<div
className={cn(
"mt-2 flex items-center gap-2 font-mono text-muted-foreground text-sm",
className,
)}
{...props}
>
{children ?? (
<>
{currentVersion && <span>{currentVersion}</span>}
{currentVersion && newVersion && <ArrowRightIcon className="size-3" />}
{newVersion && <span className="font-medium text-foreground">{newVersion}</span>}
</>
)}
</div>
)
}
export type PackageInfoDescriptionProps = HTMLAttributes<HTMLParagraphElement>
export const PackageInfoDescription = ({
className,
children,
...props
}: PackageInfoDescriptionProps) => (
<p className={cn("mt-2 text-muted-foreground text-sm", className)} {...props}>
{children}
</p>
)
export type PackageInfoContentProps = HTMLAttributes<HTMLDivElement>
export const PackageInfoContent = ({ className, children, ...props }: PackageInfoContentProps) => (
<div className={cn("mt-3 border-t pt-3", className)} {...props}>
{children}
</div>
)
export type PackageInfoDependenciesProps = HTMLAttributes<HTMLDivElement>
export const PackageInfoDependencies = ({
className,
children,
...props
}: PackageInfoDependenciesProps) => (
<div className={cn("space-y-2", className)} {...props}>
<span className="font-medium text-muted-foreground text-xs uppercase tracking-wide">
Dependencies
</span>
<div className="space-y-1">{children}</div>
</div>
)
export type PackageInfoDependencyProps = HTMLAttributes<HTMLDivElement> & {
name: string
version?: string
}
export const PackageInfoDependency = ({
name,
version,
className,
children,
...props
}: PackageInfoDependencyProps) => (
<div className={cn("flex items-center justify-between text-sm", className)} {...props}>
{children ?? (
<>
<span className="font-mono text-muted-foreground">{name}</span>
{version && <span className="font-mono text-xs">{version}</span>}
</>
)}
</div>
)
/** Demo component for preview */
export default function PackageInfoDemo() {
return (
<div className="flex w-full max-w-md flex-col gap-4 p-4">
<PackageInfo name="react" currentVersion="18.2.0" newVersion="19.0.0" changeType="major">
<PackageInfoHeader>
<PackageInfoName />
<PackageInfoChangeType />
</PackageInfoHeader>
<PackageInfoVersion />
<PackageInfoDescription>
A JavaScript library for building user interfaces
</PackageInfoDescription>
<PackageInfoContent>
<PackageInfoDependencies>
<PackageInfoDependency name="loose-envify" version="^1.1.0" />
<PackageInfoDependency name="scheduler" version="^0.23.0" />
</PackageInfoDependencies>
</PackageInfoContent>
</PackageInfo>
<PackageInfo name="@tanstack/react-query" changeType="added">
<PackageInfoHeader>
<PackageInfoName />
<PackageInfoChangeType />
</PackageInfoHeader>
<PackageInfoDescription>Powerful asynchronous state management</PackageInfoDescription>
</PackageInfo>
<PackageInfo name="lodash" currentVersion="4.17.21" changeType="removed">
<PackageInfoHeader>
<PackageInfoName />
<PackageInfoChangeType />
</PackageInfoHeader>
<PackageInfoVersion />
</PackageInfo>
</div>
)
}