update Markdown skills

This commit is contained in:
2026-08-19 17:36:27 +05:30
parent aa2fb41871
commit d3f7f439f6
30 changed files with 2341 additions and 221 deletions

View File

@@ -2,6 +2,7 @@ import * as React from 'react';
import { Sparkles } from 'lucide-react';
import { cn } from '@/lib/utils';
import { ResponseDocument } from './ResponseBlocks';
import OwliverAvatar from '@/components/krow/OwliverAvatar';
/**
* The thinking state, shown between sending and the first block arriving.
@@ -12,9 +13,7 @@ import { ResponseDocument } from './ResponseBlocks';
export function ThinkingIndicator() {
return (
<div className="flex items-center gap-2">
<span className="grid h-6 w-6 shrink-0 place-items-center rounded-lg bg-krow-blue-tint text-krow-blue">
<Sparkles className="h-3 w-3" aria-hidden="true" />
</span>
<OwliverAvatar className="h-6 w-6" rounded="rounded-full" />
<span className="inline-flex items-center gap-1 rounded-xl rounded-tl-sm border border-border bg-surface px-2.5 py-2 shadow-xs">
{[0, 1, 2].map((i) => (
<span
@@ -53,9 +52,7 @@ export const Message = React.memo(
return (
<div className="animate-slide-up">
<div className="mb-2 flex items-center gap-1.5">
<span className="grid h-5 w-5 shrink-0 place-items-center rounded-md bg-krow-blue-tint text-krow-blue">
<Sparkles className="h-2.5 w-2.5" aria-hidden="true" />
</span>
<OwliverAvatar className="h-5 w-5" rounded="rounded-full" />
<span className="text-[10px] font-semibold uppercase tracking-wide text-ink-4">Owliver</span>
</div>

View File

@@ -4,6 +4,7 @@ import { cn } from '@/lib/utils';
import KrowAssistant from './KrowAssistant';
import { useAssistantPanel } from './AssistantPanelContext';
import { ResizeDivider } from './ResizeDivider';
import OwliverAvatar from '@/components/krow/OwliverAvatar';
const EXPANDED_WIDTH = 620;
/**
@@ -68,9 +69,7 @@ function CollapsedTrigger({ page, onRestore }) {
hover:border-krow-blue/40 hover:shadow-lg
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-krow-blue/50"
>
<span className="grid h-7 w-7 shrink-0 place-items-center rounded-full bg-white overflow-hidden shadow-brand border border-border">
<img src="/krow logo.jpeg" alt="KROW Logo" className="h-full w-full object-cover" />
</span>
<OwliverAvatar className="h-7 w-7" rounded="rounded-full" />
<span className="text-body-sm font-semibold text-ink-1">Owliver</span>
<PanelLeftOpen className="h-3.5 w-3.5 shrink-0 text-ink-4 group-hover:text-krow-blue" aria-hidden="true" />
</button>

View File

@@ -23,6 +23,7 @@ import { useAssistantPanel } from './AssistantPanelContext';
import { usePageContext } from './PageContext';
import { useAssistantFacts, useConversation, useCurrentUserName } from './useAssistant';
import { buildIntro, buildPrompts } from './dynamic';
import OwliverAvatar from '@/components/krow/OwliverAvatar';
import { Message, ThinkingIndicator, TurnDivider } from './AssistantMessage';
import { PromptInput } from './PromptInput';
import { PromptChips } from './PromptChips';
@@ -613,9 +614,7 @@ export default function KrowAssistant({
>
{/* Header */}
<div className="flex shrink-0 items-center gap-2.5 border-b border-white/60 px-3.5 py-2.5">
<span className="grid h-7 w-7 shrink-0 place-items-center rounded-lg bg-white overflow-hidden shadow-brand border border-border">
<img src="/krow logo.jpeg" alt="KROW Logo" className="h-full w-full object-cover" />
</span>
<OwliverAvatar className="h-7 w-7" rounded="rounded-lg" />
<div className="min-w-0 flex-1">
<h2 className="font-heading text-body-sm font-semibold leading-tight text-ink-1">Owliver</h2>

View File

@@ -12,8 +12,9 @@ import {
resolveDraft, weightsFromQuestion, weightsReply, weightsUnchangedReply, whichDraftReply,
} from '@/lib/skills/draftFlow';
import {
appliedToday, askWhichPosition, assignmentPreview, assignmentToExecute, availability,
candidateDetail, candidateMatches, candidateRoute, interviewReady, matchWorkforceIntent,
appliedToday, askHeadcount, askWhichPosition, assignmentPreview, assignmentToExecute,
availability, candidateDetail, candidateMatches, candidateRoute, headcountFrom,
interviewReady, matchWorkforceIntent,
namedAssignmentPreview,
interviewPreview, interviewToExecute,
namedAssignmentToExecute, positionPriority, resolveCandidate, resolvePosition,
@@ -303,6 +304,22 @@ function resolveWorkforce(question, workforce) {
: { kind: 'answer-doc', ...assignmentPreview(position, context) };
}
/**
* The answer to "how many people do you need?".
*
* The only write in the workforce path that is not an assignment, and it
* follows the same contract: the routing layer decides *what* should happen
* and hands it back, and `useAssistant` performs it through the mutation the
* Create Position form already uses. A sentence with no number in it is not a
* failure — it is the question being asked again.
*/
if (intent === 'set_headcount') {
const count = headcountFrom(question);
return count
? { kind: 'workforce', headcount: { position, count } }
: { kind: 'answer-doc', ...askHeadcount(position, context) };
}
/**
* Interview setup, for one named person against this role. Both steps resolve
* the name the same way assignment does, so the conversation stays on the same

View File

@@ -15,7 +15,8 @@ import {
publishedReply, weightsSetReply, weightsUnchangedReply,
} from '@/lib/skills/draftFlow';
import {
assignmentDone, assignmentFailed, assignmentFollowUp, interviewDone, interviewFailed,
assignmentDone, assignmentFailed, assignmentFollowUp, headcountFailed, headcountSet,
interviewDone, interviewFailed,
} from '@/lib/skills/workforceFlow';
import {
newConversationId, readHistory, removeConversation, saveConversation,
@@ -517,6 +518,34 @@ export function useConversation({
};
}
/**
* The headcount a position never stated, supplied by the reader.
*
* Written through `useUpdateJobPosting` — the same mutation the Create
* Position form and the Positions page call — so there is one position
* record and one demand figure, not a number the panel remembers. The reply
* is the assignment proposal the reader originally asked for, re-derived
* against the saved record rather than against the number they typed, so
* what they see is what was actually stored.
*/
if (intent.kind === 'workforce' && intent.headcount) {
const { position: target, count } = intent.headcount;
let saved = null;
try {
saved = await onUpdatePosition?.(target.id, { headcount: count });
} catch {
saved = null;
}
intent = {
...intent,
kind: 'answer-doc',
...(saved
? headcountSet(saved, workforce?.context || {})
: headcountFailed(target)),
};
}
/**
* The interview step. Same contract as the assignment above: it runs before
* the reply, only on a confirmed turn, and through the app's existing

View File

@@ -1,14 +1,13 @@
import { Image } from '@/components/ui/image';
import React from 'react';
const OWLIVER_URL = 'https://media.base44.com/images/public/6a653ab9436c05c43a00994f/620b75f07_WhatsAppImage2026-07-31at35919PM.jpeg';
const OWLIVER_URL = '/owliver-avatar.png';
export default function OwliverAvatar({ className = 'w-16 h-16', rounded = 'rounded-full' }) {
return (
<Image
<img
src={OWLIVER_URL}
alt="Owliver"
fittingType="fill"
className={`shrink-0 overflow-hidden ${rounded} ${className}`}
className={`shrink-0 overflow-hidden object-cover ${rounded} ${className}`}
/>
);
}

View File

@@ -4,7 +4,7 @@ import { Image } from '@/components/ui/image';
import { Sparkles, X } from 'lucide-react';
import Owliver from '@/pages/Owliver';
const OWLIVER_URL = 'https://media.base44.com/images/public/6a653ab9436c05c43a00994f/2005ea00e_WhatsAppImage2026-07-31at35919PM.jpeg';
const OWLIVER_URL = '/owliver-avatar.png';
export default function OwliverChatBubble({ open: externalOpen, onOpenChange, showTrigger = true }) {
const [internalOpen, setInternalOpen] = useState(false);

View File

@@ -1,9 +1,13 @@
import React from 'react';
import { Sparkles, Upload } from 'lucide-react';
import { Button, Field, Input, Modal, Textarea, toast } from '@/components/ds';
import { Button, Field, Input, Modal, Textarea } from '@/components/ds';
import { usePreferences, useUpdatePreferences } from '@/lib/krowHooks';
import { PAGE_KEYS, validateSkillSource } from '@/lib/skills/registry';
import { skillTemplate, upsertCustomSkill } from '@/lib/skills/customSkills';
import {
isReadableDefinition, normalizeUpload, owliverFieldsFromSource, patchFrontmatter,
} from '@/lib/skills/skillFields';
import { reportSave } from '@/lib/skills/saveFeedback';
/**
* Add an Owliver skill.
@@ -41,27 +45,71 @@ export function AddSkillDialog({ open, onOpenChange }) {
setError('');
}, [open]);
/* The fields drive the Markdown until the author edits the Markdown, after
which the Markdown wins — it is the thing being saved. */
/**
* A field edit, written into the definition.
*
* A fresh draft is composed from the template; once there is a definition to
* preserve — an uploaded file, or Markdown typed by hand — the field patches
* the key it owns and leaves everything else alone. It used to stop here
* entirely, so after an upload these four boxes edited nothing that was saved.
*/
const syncFromMeta = (next) => {
setMeta(next);
if (touched) return;
setSource(skillTemplate({
id: next.id,
name: next.name,
description: next.description,
pages: next.pages.split(',').map((p) => p.trim()).filter(Boolean),
const pages = next.pages.split(',').map((p) => p.trim()).filter(Boolean);
if (!touched) {
setSource(skillTemplate({
id: next.id,
name: next.name,
description: next.description,
pages,
}));
return;
}
setSource(patchFrontmatter(source, {
id: next.id || undefined,
name: next.name || undefined,
description: next.description || undefined,
pages: pages.length ? pages : undefined,
}));
};
/**
* A definition uploaded from a file.
*
* Filled the Markdown box and left every field beside it empty, and said
* nothing about whether the file was usable until Add was pressed. Both are
* fixed here: the frontmatter fills the fields, and an unusable file says so
* at the moment it arrives.
*/
const readFile = (event) => {
const file = event.target.files?.[0];
if (!file) return;
const reader = new FileReader();
reader.onerror = () => setError('That file could not be read.');
reader.onload = () => {
setSource(String(reader.result));
const raw = normalizeUpload(reader.result);
setSource(raw);
setTouched(true);
setError('');
/* Nothing readable: the fields stay as they were rather than emptying to
a row of placeholders that read as values. */
if (!isReadableDefinition(raw)) {
setError('That file has no frontmatter block, so there is nothing to read into the fields. '
+ 'A definition starts with `---` on its own line.');
return;
}
setError(validateSkillSource(raw) || '');
const fields = owliverFieldsFromSource(raw);
setMeta({
id: fields.id,
name: fields.name,
description: fields.description,
pages: fields.pages.join(', '),
});
};
reader.readAsText(file);
event.target.value = '';
@@ -76,8 +124,7 @@ export function AddSkillDialog({ open, onOpenChange }) {
const { skill, next } = upsertCustomSkill(preferences.customSkills || [], source);
updatePreferences.mutate({ customSkills: next });
toast.success(`${skill.name} added`);
updatePreferences.mutate({ customSkills: next }, reportSave(`${skill.name} added`));
onOpenChange(false);
};
@@ -101,14 +148,14 @@ export function AddSkillDialog({ open, onOpenChange }) {
<Field label="Skill name">
<Input
value={meta.name}
placeholder="Chef Training"
placeholder="e.g. Chef Training"
onChange={(e) => syncFromMeta({ ...meta, name: e.target.value })}
/>
</Field>
<Field label="Skill ID" hint="Lower-case, dashes.">
<Input
value={meta.id}
placeholder="chef-training"
placeholder="e.g. chef-training"
onChange={(e) => syncFromMeta({ ...meta, id: e.target.value })}
/>
</Field>
@@ -117,7 +164,7 @@ export function AddSkillDialog({ open, onOpenChange }) {
<Field label="Description">
<Input
value={meta.description}
placeholder="Helps Owliver explain chef training paths."
placeholder="e.g. Helps Owliver explain chef training paths."
onChange={(e) => syncFromMeta({ ...meta, description: e.target.value })}
/>
</Field>
@@ -142,8 +189,26 @@ export function AddSkillDialog({ open, onOpenChange }) {
className="font-mono text-[12px] leading-relaxed"
placeholder="---&#10;id: my-skill&#10;name: My Skill&#10;pages:&#10; - positions&#10;---"
onChange={(e) => {
setSource(e.target.value);
const next = e.target.value;
setSource(next);
setTouched(true);
/* Markdown → fields, the direction that was missing. Same
extractor the upload path uses; guarded so a half-typed
definition cannot wipe fields that are already filled in.
See the fuller note in the two skill editors. */
if (isReadableDefinition(next)) {
const fields = owliverFieldsFromSource(next);
if (fields.name) {
setMeta({
id: fields.id,
name: fields.name,
description: fields.description,
pages: fields.pages.join(', '),
});
}
}
if (error) setError('');
}}
/>
@@ -154,7 +219,9 @@ export function AddSkillDialog({ open, onOpenChange }) {
<Button variant="outline" size="sm" onClick={() => fileRef.current?.click()}>
<Upload aria-hidden="true" /> Upload .md
</Button>
<p className="text-caption text-ink-4">Markdown is stored as data. It is never executed.</p>
<p className="text-caption text-ink-4">
Stored as data in this browser, for this workspace. It is never executed.
</p>
</div>
</div>
</Modal>