Open-source SEO, GEO, and marketing skills for AI agents.
chore(notfair-cmo): seal legacy openclaw types so build typechecks
Yuting Zhong52df046c2f07
diff --git a/notfair-cmo/next-env.d.ts b/notfair-cmo/next-env.d.tsindex c4b7818f..9edff1c7 100644--- a/notfair-cmo/next-env.d.ts+++ b/notfair-cmo/next-env.d.ts@@ -1,6 +1,6 @@/// <reference types="next" />/// <reference types="next/image-types/global" />-import "./.next/dev/types/routes.d.ts";+import "./.next/types/routes.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.diff --git a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/cron/page.tsx b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/cron/page.tsxindex 1f7de688..46131704 100644--- a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/cron/page.tsx+++ b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/cron/page.tsx@@ -17,24 +17,12 @@ import type { ScheduleInput } from "@/server/actions/cron-runs";const NUM_DAYS = 14;-/**- * Narrow the loose `CronSchedule` shape from OpenClaw to the discriminated- * union our run-matching server action accepts. Drops schedules whose `kind`- * we don't recognise so the action can fall back to time-window matching.- */function scheduleForCalendar(s: unknown): ScheduleInput | null {if (!s || typeof s !== "object") return null;- const obj = s as { kind?: string; expr?: unknown; tz?: unknown; everyMs?: unknown; anchorMs?: unknown };+ const obj = s as { kind?: string; expr?: unknown; tz?: unknown };if (obj.kind === "cron" && typeof obj.expr === "string") {return { kind: "cron", expr: obj.expr, ...(typeof obj.tz === "string" ? { tz: obj.tz } : {}) };}- if (obj.kind === "every" && typeof obj.everyMs === "number") {- return {- kind: "every",- everyMs: obj.everyMs,- ...(typeof obj.anchorMs === "number" ? { anchorMs: obj.anchorMs } : {}),- };- }return null;}diff --git a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/skills/page.tsx b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/skills/page.tsxindex 3d521d4e..c2904ba5 100644--- a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/skills/page.tsx+++ b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/skills/page.tsx@@ -57,7 +57,7 @@ export default async function AgentSkillsPage({)}{!error && skills.length > 0 && (- <SkillsList skills={skills} agentSlug={agentSlug} />+ <SkillsList skills={skills} />)}</div></div>diff --git a/notfair-cmo/src/app/(app)/[project]/crons/page.tsx b/notfair-cmo/src/app/(app)/[project]/crons/page.tsxindex 03ed1587..79b2f2a4 100644--- a/notfair-cmo/src/app/(app)/[project]/crons/page.tsx+++ b/notfair-cmo/src/app/(app)/[project]/crons/page.tsx@@ -16,17 +16,10 @@ import type { ScheduleInput } from "@/server/actions/cron-runs";function scheduleForCalendar(s: unknown): ScheduleInput | null {if (!s || typeof s !== "object") return null;- const obj = s as { kind?: string; expr?: unknown; tz?: unknown; everyMs?: unknown; anchorMs?: unknown };+ const obj = s as { kind?: string; expr?: unknown; tz?: unknown };if (obj.kind === "cron" && typeof obj.expr === "string") {return { kind: "cron", expr: obj.expr, ...(typeof obj.tz === "string" ? { tz: obj.tz } : {}) };}- if (obj.kind === "every" && typeof obj.everyMs === "number") {- return {- kind: "every",- everyMs: obj.everyMs,- ...(typeof obj.anchorMs === "number" ? { anchorMs: obj.anchorMs } : {}),- };- }return null;}diff --git a/notfair-cmo/src/components/schedule-cron-dialog.tsx b/notfair-cmo/src/components/schedule-cron-dialog.tsxindex cd103fd2..6c9aa50c 100644--- a/notfair-cmo/src/components/schedule-cron-dialog.tsx+++ b/notfair-cmo/src/components/schedule-cron-dialog.tsx@@ -25,7 +25,6 @@ import { scheduleCronAction } from "@/server/actions/crons";import { toast } from "sonner";type Specialist = "cmo" | "google_ads" | "seo";-type ScheduleKind = "cron" | "every";const SPECIALIST_LABEL: Record<Specialist, string> = {cmo: "CMO",@@ -39,20 +38,19 @@ type Props = {variant?: "button" | "icon";};-const PRESET_SCHEDULES: Array<{ label: string; kind: ScheduleKind; value: string; tz?: string }> = [- { label: "Every hour", kind: "every", value: "1h" },- { label: "Every 15 minutes", kind: "every", value: "15m" },- { label: "Daily at 9am (Los Angeles)", kind: "cron", value: "0 9 * * *", tz: "America/Los_Angeles" },- { label: "Weekdays at 8am (Los Angeles)", kind: "cron", value: "0 8 * * 1-5", tz: "America/Los_Angeles" },- { label: "Mondays at 6am (Los Angeles)", kind: "cron", value: "0 6 * * 1", tz: "America/Los_Angeles" },+const PRESET_SCHEDULES: Array<{ label: string; value: string; tz?: string }> = [+ { label: "Every hour", value: "0 * * * *", tz: "America/Los_Angeles" },+ { label: "Every 15 minutes", value: "*/15 * * * *", tz: "America/Los_Angeles" },+ { label: "Daily at 9am (Los Angeles)", value: "0 9 * * *", tz: "America/Los_Angeles" },+ { label: "Weekdays at 8am (Los Angeles)", value: "0 8 * * 1-5", tz: "America/Los_Angeles" },+ { label: "Mondays at 6am (Los Angeles)", value: "0 6 * * 1", tz: "America/Los_Angeles" },];export function ScheduleCronDialog({ projectSlug, defaultSpecialist, variant = "button" }: Props) {const [open, setOpen] = useState(false);const [specialist, setSpecialist] = useState<Specialist>(defaultSpecialist ?? "google_ads");const [name, setName] = useState("");- const [kind, setKind] = useState<ScheduleKind>("every");- const [scheduleValue, setScheduleValue] = useState("1h");+ const [scheduleValue, setScheduleValue] = useState("0 9 * * *");const [tz, setTz] = useState("America/Los_Angeles");const [brief, setBrief] = useState("");const [pending, start] = useTransition();@@ -60,12 +58,10 @@ export function ScheduleCronDialog({ projectSlug, defaultSpecialist, variant = "function reset() {setName("");setBrief("");- setKind("every");- setScheduleValue("1h");+ setScheduleValue("0 9 * * *");}function pickPreset(p: (typeof PRESET_SCHEDULES)[number]) {- setKind(p.kind);setScheduleValue(p.value);if (p.tz) setTz(p.tz);}@@ -76,9 +72,9 @@ export function ScheduleCronDialog({ projectSlug, defaultSpecialist, variant = "project_slug: projectSlug,specialist,name,- schedule_kind: kind,+ schedule_kind: "cron",schedule_value: scheduleValue,- tz: kind === "cron" ? tz : undefined,+ tz,brief,});if (!result.ok) {@@ -166,34 +162,21 @@ export function ScheduleCronDialog({ projectSlug, defaultSpecialist, variant = "</DropdownMenuContent></DropdownMenu></div>- <div className="flex gap-2">- <select- value={kind}- onChange={(e) => setKind(e.target.value as ScheduleKind)}- className="h-9 w-32 rounded-md border bg-background px-2 text-sm"- disabled={pending}- >- <option value="every">Every</option>- <option value="cron">Cron expr</option>- </select>- <Input- id="schedule"- placeholder={kind === "every" ? "1h" : "0 9 * * *"}- value={scheduleValue}- onChange={(e) => setScheduleValue(e.target.value)}- disabled={pending}- className="font-mono text-sm"- />- </div>- {kind === "cron" && (- <Input- placeholder="Timezone (IANA)"- value={tz}- onChange={(e) => setTz(e.target.value)}- disabled={pending}- className="font-mono text-sm"- />- )}+ <Input+ id="schedule"+ placeholder="0 9 * * *"+ value={scheduleValue}+ onChange={(e) => setScheduleValue(e.target.value)}+ disabled={pending}+ className="font-mono text-sm"+ />+ <Input+ placeholder="Timezone (IANA)"+ value={tz}+ onChange={(e) => setTz(e.target.value)}+ disabled={pending}+ className="font-mono text-sm"+ /></div><div className="grid gap-2">diff --git a/notfair-cmo/src/components/skills-list.test.tsx b/notfair-cmo/src/components/skills-list.test.tsxdeleted file mode 100644index 60ffe65d..00000000--- a/notfair-cmo/src/components/skills-list.test.tsx+++ /dev/null@@ -1,165 +0,0 @@-// @vitest-environment jsdom-import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";-import { render, screen, fireEvent, waitFor, cleanup } from "@testing-library/react";--const setSkillEnabledAction = vi.fn();-const toast = {- success: vi.fn(),- error: vi.fn(),-};--vi.mock("@/server/actions/skills", () => ({- setSkillEnabledAction: (...args: unknown[]) => setSkillEnabledAction(...args),-}));--vi.mock("sonner", () => ({- toast: {- success: (...args: unknown[]) => toast.success(...args),- error: (...args: unknown[]) => toast.error(...args),- },-}));--import { SkillsList } from "./skills-list";--type Skill = Parameters<typeof SkillsList>[0]["skills"][number];--function skill(over: Partial<Skill> = {}): Skill {- return {- name: "test-skill",- description: "A test skill",- source: "user",- bundled: false,- filePath: "/x",- baseDir: "/x",- skillKey: "test-skill",- emoji: "🧪",- always: false,- disabled: false,- eligible: true,- blockedByAllowlist: false,- blockedByAgentFilter: false,- userInvocable: true,- commandVisible: true,- ...over,- } as Skill;-}--const skills: Skill[] = [- skill({ skillKey: "enabled-a", name: "enabled-a", disabled: false }),- skill({ skillKey: "enabled-b", name: "enabled-b", disabled: false, bundled: true }),- skill({ skillKey: "disabled-a", name: "disabled-a", disabled: true }),- skill({- skillKey: "init",- name: "init",- always: true,- disabled: false,- }),- skill({- skillKey: "needs-setup",- name: "needs-setup",- disabled: false,- eligible: false,- }),-];--beforeEach(() => {- setSkillEnabledAction.mockReset();- toast.success.mockReset();- toast.error.mockReset();-});--afterEach(() => {- cleanup();-});--describe("SkillsList", () => {- it("renders one row per skill in the 'all' filter (default)", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- for (const s of skills) {- expect(screen.getByText(s.name)).toBeInTheDocument();- }- });-- it("shows filter tabs with per-bucket counts", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- expect(screen.getByRole("tab", { name: /All\s*5/i })).toBeInTheDocument();- expect(screen.getByRole("tab", { name: /Enabled\s*4/i })).toBeInTheDocument();- expect(screen.getByRole("tab", { name: /Disabled\s*1/i })).toBeInTheDocument();- });-- it("narrows to enabled skills when the Enabled tab is clicked", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- fireEvent.click(screen.getByRole("tab", { name: /Enabled\s*4/i }));- expect(screen.queryByText("disabled-a")).not.toBeInTheDocument();- expect(screen.getByText("enabled-a")).toBeInTheDocument();- });-- it("narrows to disabled skills when the Disabled tab is clicked", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- fireEvent.click(screen.getByRole("tab", { name: /Disabled\s*1/i }));- expect(screen.getByText("disabled-a")).toBeInTheDocument();- expect(screen.queryByText("enabled-a")).not.toBeInTheDocument();- });-- it("shows the empty-state when a filter yields no skills", () => {- render(<SkillsList skills={[]} agentSlug="cmo" />);- expect(screen.getByText(/no skills match this filter/i)).toBeInTheDocument();- });-- it("renders the 'bundled' badge on bundled skills", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- expect(screen.getByText("bundled")).toBeInTheDocument();- });-- it("renders the 'always-on' badge and disables the toggle on always skills", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- expect(screen.getByText("always-on")).toBeInTheDocument();- const row = screen.getByText("init").closest("li");- const btn = row?.querySelector("button");- expect(btn).toBeDisabled();- });-- it("renders the 'needs setup' badge when enabled but not eligible", () => {- render(<SkillsList skills={skills} agentSlug="cmo" />);- expect(screen.getByText("needs setup")).toBeInTheDocument();- });-- it("toggles a skill off when the user clicks Enabled and toasts success", async () => {- setSkillEnabledAction.mockResolvedValue({ ok: true });- render(<SkillsList skills={[skill({ skillKey: "k", name: "k" })]} agentSlug="cmo" />);- const btn = screen.getByRole("button", { name: /enabled/i });- fireEvent.click(btn);- await waitFor(() =>- expect(setSkillEnabledAction).toHaveBeenCalledWith("k", false, "cmo"),- );- await waitFor(() =>- expect(toast.success).toHaveBeenCalledWith("Disabled k"),- );- });-- it("toggles a disabled skill on and toasts success", async () => {- setSkillEnabledAction.mockResolvedValue({ ok: true });- render(- <SkillsList- skills={[skill({ skillKey: "k", name: "k", disabled: true })]}- agentSlug="cmo"- />,- );- const btn = screen.getByRole("button", { name: /enable/i });- fireEvent.click(btn);- await waitFor(() =>- expect(setSkillEnabledAction).toHaveBeenCalledWith("k", true, "cmo"),- );- await waitFor(() => expect(toast.success).toHaveBeenCalledWith("Enabled k"));- });-- it("reverts the optimistic state and toasts an error on failure", async () => {- setSkillEnabledAction.mockResolvedValue({ ok: false, error: "no" });- render(<SkillsList skills={[skill({ skillKey: "k", name: "k" })]} agentSlug="cmo" />);- const btn = screen.getByRole("button", { name: /enabled/i });- fireEvent.click(btn);- await waitFor(() => expect(toast.error).toHaveBeenCalledWith("no"));- // After revert: still in the "Enabled" visual state.- expect(screen.getByRole("button", { name: /enabled/i })).toBeInTheDocument();- });-});diff --git a/notfair-cmo/src/components/skills-list.tsx b/notfair-cmo/src/components/skills-list.tsxindex 3396a56a..c0914f91 100644--- a/notfair-cmo/src/components/skills-list.tsx+++ b/notfair-cmo/src/components/skills-list.tsx@@ -1,183 +1,40 @@-"use client";--import { useMemo, useState, useTransition } from "react";-import { Loader2 } from "lucide-react";import { Badge } from "@/components/ui/badge";-import { Button } from "@/components/ui/button";-import { cn } from "@/lib/utils";-import { toast } from "sonner";import type { SkillEntry } from "@/server/agents/skills";-import { setSkillEnabledAction } from "@/server/actions/skills";--type FilterKey = "all" | "enabled" | "disabled";--const FILTER_LABELS: Record<FilterKey, string> = {- all: "All",- enabled: "Enabled",- disabled: "Disabled",-};type Props = {skills: SkillEntry[];- agentSlug: string;};-/**- * Definition used by both the filter and the toggle:- * enabled = !skill.disabled- * `eligible` is computed by OpenClaw from `enabled` + requirement checks (binary- * present, allowlist passes, etc.). The user can flip `enabled`; they can't flip- * `eligible`. So our toggle binds to `!disabled`, and we surface ineligibility- * with a side badge instead of locking the switch.- */-export function SkillsList({ skills, agentSlug }: Props) {- const [filter, setFilter] = useState<FilterKey>("all");-- const counts = useMemo(() => {- let enabled = 0;- let disabled = 0;- for (const s of skills) {- if (s.disabled) disabled++;- else enabled++;- }- return { all: skills.length, enabled, disabled };- }, [skills]);-- const filtered = useMemo(() => {- if (filter === "all") return skills;- if (filter === "enabled") return skills.filter((s) => !s.disabled);- return skills.filter((s) => s.disabled);- }, [skills, filter]);-- return (- <div className="space-y-4">- <div- className="inline-flex items-center gap-1 rounded-lg border bg-muted/40 p-1"- role="tablist"- aria-label="Filter skills"- >- {(Object.keys(FILTER_LABELS) as FilterKey[]).map((key) => {- const isActive = filter === key;- return (- <button- key={key}- type="button"- role="tab"- aria-selected={isActive}- onClick={() => setFilter(key)}- className={cn(- "rounded-md px-3 py-1 text-xs font-medium transition-colors",- isActive- ? "bg-background text-foreground shadow-sm"- : "text-muted-foreground hover:text-foreground",- )}- >- {FILTER_LABELS[key]}- <span className="ml-1.5 text-[10px] tabular-nums text-muted-foreground">- {counts[key]}- </span>- </button>- );- })}+export function SkillsList({ skills }: Props) {+ if (skills.length === 0) {+ return (+ <div className="rounded-lg border bg-card py-10 text-center text-sm text-muted-foreground">+ No skills wired into this agent yet.</div>-- {filtered.length === 0 ? (- <div className="rounded-lg border bg-card py-10 text-center text-sm text-muted-foreground">- No skills match this filter.- </div>- ) : (- <ul className="divide-y rounded-lg border bg-card">- {filtered.map((s) => (- <SkillRow key={s.skillKey} skill={s} agentSlug={agentSlug} />- ))}- </ul>- )}- </div>- );-}--function SkillRow({ skill, agentSlug }: { skill: SkillEntry; agentSlug: string }) {- const [pending, startTransition] = useTransition();- // Optimistic flag so the row reflects the toggle instantly while the server- // round-trip + revalidation finishes.- const [optimistic, setOptimistic] = useState<boolean | null>(null);- const isEnabled = optimistic ?? !skill.disabled;-- function onToggle() {- const next = !isEnabled;- setOptimistic(next);- startTransition(async () => {- const r = await setSkillEnabledAction(skill.skillKey, next, agentSlug);- if (!r.ok) {- setOptimistic(!next); // revert- toast.error(r.error ?? `Could not ${next ? "enable" : "disable"} ${skill.name}`);- } else {- toast.success(`${next ? "Enabled" : "Disabled"} ${skill.name}`);- // Server revalidation will fold optimistic state back in on next render.- }- });+ );}-return (- <li- className={cn(- "flex items-start gap-3 px-4 py-3 transition-opacity",- !isEnabled && "opacity-70",- )}- >- <div className="flex size-7 shrink-0 items-center justify-center rounded-md border bg-background text-base">- {skill.emoji ?? "·"}- </div>- <div className="min-w-0 flex-1">- <div className="flex flex-wrap items-center gap-2">- <span className="font-mono text-sm">{skill.name}</span>- {skill.bundled && (- <Badge variant="outline" className="h-4 px-1 text-[9px] uppercase tracking-wide">- bundled- </Badge>- )}- {skill.always && (- <Badge variant="secondary" className="h-4 px-1 text-[9px] uppercase tracking-wide">- always-on- </Badge>- )}- {isEnabled && !skill.eligible && (- <Badge- variant="outline"- className="h-4 px-1 text-[9px] uppercase tracking-wide text-amber-600 dark:text-amber-400"- title="Enabled in config, but a requirement is missing (binary, allowlist, agent filter)."- >- needs setup- </Badge>- )}- </div>- {skill.description && (- <p className="mt-0.5 text-xs text-muted-foreground">{skill.description}</p>- )}- <p className="mt-1 truncate font-mono text-[10px] text-muted-foreground/70">- {skill.source}- </p>- </div>-- <div className="shrink-0 self-center">- <Button- type="button"- variant={isEnabled ? "outline" : "default"}- size="sm"- onClick={onToggle}- disabled={pending || skill.always}- title={skill.always ? "Always-on skill; cannot be disabled." : undefined}- className="h-7 w-20 text-xs"- >- {pending ? (- <Loader2 className="size-3.5 animate-spin" />- ) : isEnabled ? (- "Enabled"- ) : (- "Enable"- )}- </Button>- </div>- </li>+ <ul className="divide-y rounded-lg border bg-card">+ {skills.map((s) => (+ <li key={s.key} className="flex items-start gap-3 px-4 py-3">+ <div className="min-w-0 flex-1">+ <div className="flex flex-wrap items-center gap-2">+ <span className="font-mono text-sm">{s.name}</span>+ <Badge variant="secondary" className="h-4 px-1 text-[9px] uppercase tracking-wide">+ {s.scope}+ </Badge>+ </div>+ {s.description && (+ <p className="mt-0.5 text-xs text-muted-foreground">{s.description}</p>+ )}+ {s.source && (+ <p className="mt-1 truncate font-mono text-[10px] text-muted-foreground/70">+ {s.source}+ </p>+ )}+ </div>+ </li>+ ))}+ </ul>);}diff --git a/notfair-cmo/src/server/actions/crons.ts b/notfair-cmo/src/server/actions/crons.tsindex 66e2a34d..1548dd91 100644--- a/notfair-cmo/src/server/actions/crons.ts+++ b/notfair-cmo/src/server/actions/crons.ts@@ -18,7 +18,7 @@ export type ScheduleCronInput = {project_slug: string;specialist: AgentTemplate["key"];name: string;- schedule_kind: "cron" | "every";+ schedule_kind: "cron";schedule_value: string;tz?: string;brief: string;@@ -52,18 +52,6 @@ export async function scheduleCronAction(input: ScheduleCronInput): Promise<Scheconst agent_slug = target.slug;const agent_full_id = target.agent_id;- // The native scheduler only models cron expressions; "every N" inputs come- // in as `every 5m` strings which we transcribe to a cron expression with- // the equivalent step. For brevity (and since the CMO/specialists rarely- // emit non-cron schedules), reject `every` here for now — emitters should- // pass a real cron expression.- if (input.schedule_kind !== "cron") {- return {- ok: false,- error: "Only cron expressions are supported; use a 5-field cron string.",- };- }-try {const result = await createCron({project_slug: input.project_slug,diff --git a/notfair-cmo/src/server/actions/skills.ts b/notfair-cmo/src/server/actions/skills.tsdeleted file mode 100644index d83f1424..00000000--- a/notfair-cmo/src/server/actions/skills.ts+++ /dev/null@@ -1,24 +0,0 @@-"use server";--import { revalidatePath } from "next/cache";--export type SetSkillEnabledResult = { ok: true } | { ok: false; error: string };--/**- * Skills are inherent to the chosen harness adapter now (Claude Code skills,- * Codex prompts, etc.) plus the SKILL.md notfair-cmo writes into each agent- * workspace. There's no global enable/disable flag — agents always have- * access to the SKILL.md their workspace contains.- *- * The action is preserved so the existing UI tile in the per-agent Skills- * tab keeps compiling; clicks resolve immediately with no side effect.- */-export async function setSkillEnabledAction(- skillKey: string,- _enabled: boolean,- _agentSlug: string,-): Promise<SetSkillEnabledResult> {- if (!skillKey) return { ok: false, error: "skillKey is required" };- revalidatePath("/", "layout");- return { ok: true };-}