feat(dashboard): add skill autocomplete server-side enumeration and client wiring
- Add SkillsMixin with _enumerate_claude_skills and _enumerate_codex_skills - Claude: reads ~/.claude/skills/, parses YAML frontmatter for descriptions - Codex: reads curated cache + ~/.codex/skills/ user directory - Add /api/skills?agent= endpoint to HttpMixin - Add fetchSkills() API helper in dashboard - Wire autocomplete config through Modal -> SessionCard -> SimpleInput - Add getTriggerInfo() for detecting trigger at valid positions Closes: bd-3q1, bd-sv1, bd-3eu, bd-g9t, bd-30p, bd-1ba, bd-2n7, bd-3s3 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { html, useState, useRef } from '../lib/preact.js';
|
||||
import { html, useState, useRef, useCallback } from '../lib/preact.js';
|
||||
import { getStatusMeta } from '../utils/status.js';
|
||||
|
||||
export function SimpleInput({ sessionId, status, onRespond }) {
|
||||
export function SimpleInput({ sessionId, status, onRespond, autocompleteConfig = null }) {
|
||||
const [text, setText] = useState('');
|
||||
const [focused, setFocused] = useState(false);
|
||||
const [sending, setSending] = useState(false);
|
||||
@@ -9,6 +9,32 @@ export function SimpleInput({ sessionId, status, onRespond }) {
|
||||
const textareaRef = useRef(null);
|
||||
const meta = getStatusMeta(status);
|
||||
|
||||
// Detect if cursor is at a trigger position for autocomplete
|
||||
const getTriggerInfo = useCallback((value, cursorPos) => {
|
||||
// No config means no autocomplete
|
||||
if (!autocompleteConfig) return null;
|
||||
|
||||
const { trigger } = autocompleteConfig;
|
||||
|
||||
// Find the start of the current "word" (after last whitespace before cursor)
|
||||
let wordStart = cursorPos;
|
||||
while (wordStart > 0 && !/\s/.test(value[wordStart - 1])) {
|
||||
wordStart--;
|
||||
}
|
||||
|
||||
// Check if word starts with this agent's trigger character
|
||||
if (value[wordStart] === trigger) {
|
||||
return {
|
||||
trigger,
|
||||
filterText: value.slice(wordStart + 1, cursorPos).toLowerCase(),
|
||||
replaceStart: wordStart,
|
||||
replaceEnd: cursorPos,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}, [autocompleteConfig]);
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user