Skip to content

Desktop app that records your on-screen work session and uses the GitHub Copilot SDK to reconstruct it as an intent + ordered steps, then builds a reusable Skill or Automation for Microsoft Autopilots like Scout, Microsoft Copilot Cowork, or Copilot Studio.

Issue 37 data driven placement (#44)

Ramakrishnan Ramanb174458bf357
diff --git a/common/architecture-registry.test.ts b/common/architecture-registry.test.ts
index ef18474..bdc31aa 100644
--- a/common/architecture-registry.test.ts
+++ b/common/architecture-registry.test.ts
@@ -3,10 +3,17 @@ import test from "node:test";
import {
ARCHITECTURES,
+ DEFAULT_TARGET,
SkillArchitecture,
TARGETS,
+ buildTargetFor,
defineArchitectures,
enabledArchitectureLabels,
+ requireTargetPlacement,
+} from "./architecture-registry";
+import type {
+ ArchitectureDefinition,
+ ArchitectureTargetDefinition,
} from "./architecture-registry";
test("the manifest derives architecture validation and target availability", () => {
@@ -26,60 +33,112 @@ test("the manifest derives architecture validation and target availability", ()
],
);
assert.deepEqual(
- TARGETS.map(({ architecture, kind, enabled }) => [
- architecture,
- kind,
- enabled,
- ]),
+ TARGETS.map(
+ ({ architecture, kind, enabled, placements, installTargetLabel }) => [
+ architecture,
+ kind,
+ enabled,
+ placements,
+ installTargetLabel,
+ ],
+ ),
[
- ["scout", "skill", true],
- ["scout", "automation", true],
- ["cowork", "skill", true],
- ["copilot-studio", "skill", false],
+ ["scout", "skill", true, ["install", "export"], "Scout"],
+ ["scout", "automation", true, ["install"], "Scout"],
+ ["cowork", "skill", true, ["export"], "Microsoft 365 Copilot"],
+ ["copilot-studio", "skill", false, ["export"], "Copilot Studio"],
],
);
+ assert.equal(DEFAULT_TARGET.architecture, "scout");
+ assert.equal(DEFAULT_TARGET.kind, "skill");
+ assert.equal(
+ buildTargetFor(DEFAULT_TARGET.architecture, "automation").installTargetLabel,
+ "Scout",
+ );
assert.deepEqual(enabledArchitectureLabels("skill"), ["Scout", "Cowork"]);
assert.deepEqual(enabledArchitectureLabels("automation"), ["Scout"]);
});
+test("target placements are enforced from the manifest", () => {
+ assert.equal(requireTargetPlacement("scout", "skill", "install").architecture, "scout");
+ assert.equal(requireTargetPlacement("cowork", "skill", "export").architecture, "cowork");
+ assert.throws(
+ () => requireTargetPlacement("cowork", "skill", "install"),
+ /Architecture "cowork" target "skill" does not support "install" placement/,
+ );
+ assert.throws(
+ () => requireTargetPlacement("copilot-studio", "skill", "export"),
+ /Architecture "copilot-studio" target "skill" is not enabled/,
+ );
+});
+
test("architecture definitions reject invalid registry shapes", () => {
const skill = {
kind: "skill" as const,
label: "Skill",
enabled: true,
note: "Enabled.",
+ placements: ["install"] as const,
};
+ const architecture = (
+ id: string,
+ targets: readonly ArchitectureTargetDefinition[] = [skill],
+ ): ArchitectureDefinition => ({
+ id,
+ label: id,
+ installTargetLabel: id,
+ note: `${id}.`,
+ targets,
+ });
assert.throws(
() => defineArchitectures([]),
/Architecture manifest must contain at least one architecture/,
);
+ assert.throws(
+ () => defineArchitectures([architecture("duplicate"), architecture("duplicate")]),
+ /Duplicate architecture id "duplicate"/,
+ );
+ assert.throws(
+ () => defineArchitectures([architecture("empty", [])]),
+ /Architecture "empty" must declare at least one target/,
+ );
assert.throws(
() =>
defineArchitectures([
- { id: "duplicate", label: "First", note: "First.", targets: [skill] },
- { id: "duplicate", label: "Second", note: "Second.", targets: [skill] },
+ architecture("duplicate-kind", [skill, { ...skill, label: "Another skill" }]),
]),
- /Duplicate architecture id "duplicate"/,
+ /Architecture "duplicate-kind" declares "skill" more than once/,
);
assert.throws(
() =>
defineArchitectures([
- { id: "empty", label: "Empty", note: "Empty.", targets: [] },
+ {
+ ...architecture("empty-placement-list"),
+ targets: [{ ...skill, placements: [] }],
+ },
]),
- /Architecture "empty" must declare at least one target/,
+ /Architecture "empty-placement-list" target "skill" must declare at least one placement/,
);
assert.throws(
() =>
defineArchitectures([
{
- id: "duplicate-kind",
- label: "Duplicate kind",
- note: "Invalid.",
- targets: [skill, { ...skill, label: "Another skill" }],
+ ...architecture("duplicate-placement"),
+ targets: [{ ...skill, placements: ["install", "install"] }],
},
]),
- /Architecture "duplicate-kind" declares "skill" more than once/,
+ /Architecture "duplicate-placement" target "skill" declares placement "install" more than once/,
+ );
+ assert.throws(
+ () =>
+ defineArchitectures([
+ {
+ ...architecture("blank-install-target"),
+ installTargetLabel: " ",
+ },
+ ]),
+ /Architecture "blank-install-target" must declare an install target label\./,
);
});
diff --git a/common/architecture-registry.ts b/common/architecture-registry.ts
index 3490dac..1fae2f4 100644
--- a/common/architecture-registry.ts
+++ b/common/architecture-registry.ts
@@ -4,16 +4,22 @@ export const BUILD_KINDS = ["skill", "automation"] as const;
export const BuildKind = z.enum(BUILD_KINDS);
export type BuildKind = z.infer<typeof BuildKind>;
+export const TARGET_PLACEMENTS = ["install", "export"] as const;
+export type TargetPlacement = (typeof TARGET_PLACEMENTS)[number];
+
export interface ArchitectureTargetDefinition {
kind: BuildKind;
label: string;
enabled: boolean;
note: string;
+ /** Ordered delivery capabilities; the first entry is the primary/default placement. */
+ placements: readonly TargetPlacement[];
}
export interface ArchitectureDefinition<Id extends string = string> {
id: Id;
label: string;
+ installTargetLabel: string;
note: string;
targets: readonly ArchitectureTargetDefinition[];
}
@@ -32,6 +38,12 @@ export function defineArchitectures<
}
ids.add(definition.id);
+ if (!definition.installTargetLabel.trim()) {
+ throw new Error(
+ `Architecture "${definition.id}" must declare an install target label.`,
+ );
+ }
+
if (definition.targets.length === 0) {
throw new Error(`Architecture "${definition.id}" must declare at least one target.`);
}
@@ -44,6 +56,22 @@ export function defineArchitectures<
);
}
kinds.add(target.kind);
+
+ if (target.placements.length === 0) {
+ throw new Error(
+ `Architecture "${definition.id}" target "${target.kind}" must declare at least one placement.`,
+ );
+ }
+
+ const placements = new Set<TargetPlacement>();
+ for (const placement of target.placements) {
+ if (placements.has(placement)) {
+ throw new Error(
+ `Architecture "${definition.id}" target "${target.kind}" declares placement "${placement}" more than once.`,
+ );
+ }
+ placements.add(placement);
+ }
}
}
@@ -54,6 +82,7 @@ export const ARCHITECTURE_MANIFEST = defineArchitectures([
{
id: "scout",
label: "Scout",
+ installTargetLabel: "Scout",
note: "Microsoft Scout: native WorkIQ, browser, files, and built-in skills.",
targets: [
{
@@ -61,18 +90,21 @@ export const ARCHITECTURE_MANIFEST = defineArchitectures([
label: "Scout skill",
enabled: true,
note: "An on-demand skill Scout runs when its description matches the task.",
+ placements: ["install", "export"],
},
{
kind: "automation",
label: "Scout automation",
enabled: true,
note: "A scheduled, multi-step automation Scout runs on a trigger.",
+ placements: ["install"],
},
],
},
{
id: "cowork",
label: "Cowork",
+ installTargetLabel: "Microsoft 365 Copilot",
note:
"Microsoft 365 Copilot (Cowork): native Teams, Outlook, Calendar, " +
"SharePoint, files, and built-in skills.",
@@ -82,12 +114,14 @@ export const ARCHITECTURE_MANIFEST = defineArchitectures([
label: "Cowork skill",
enabled: true,
note: "An on-demand skill for Microsoft 365 Copilot (Cowork) you export and install.",
+ placements: ["export"],
},
],
},
{
id: "copilot-studio",
label: "Copilot Studio",
+ installTargetLabel: "Copilot Studio",
note: "Coming soon.",
targets: [
{
@@ -95,6 +129,7 @@ export const ARCHITECTURE_MANIFEST = defineArchitectures([
label: "Copilot Studio",
enabled: false,
note: "Coming soon.",
+ placements: ["export"],
},
],
},
@@ -123,6 +158,8 @@ export interface BuildTarget {
label: string;
enabled: boolean;
note: string;
+ placements: readonly TargetPlacement[];
+ installTargetLabel: string;
}
export const ARCHITECTURES: readonly ArchitectureOption[] = ARCHITECTURE_MANIFEST.map(
@@ -139,16 +176,56 @@ export const ARCHITECTURES: readonly ArchitectureOption[] = ARCHITECTURE_MANIFES
* so the target kind and architecture are chosen together before planning begins.
*/
export const TARGETS: readonly BuildTarget[] = ARCHITECTURE_MANIFEST.flatMap(
- ({ id, targets }) =>
+ ({ id, installTargetLabel, targets }) =>
targets.map((target) => ({
kind: target.kind,
architecture: id,
label: target.label,
enabled: target.enabled,
note: target.note,
+ placements: target.placements,
+ installTargetLabel,
})),
);
+export function buildTargetFor(
+ architecture: SkillArchitecture,
+ kind: BuildKind,
+): BuildTarget {
+ const target = TARGETS.find(
+ (candidate) => candidate.architecture === architecture && candidate.kind === kind,
+ );
+ if (!target) {
+ throw new Error(
+ `No "${kind}" target is configured for architecture "${architecture}".`,
+ );
+ }
+ return target;
+}
+
+export function requireTargetPlacement(
+ architecture: SkillArchitecture,
+ kind: BuildKind,
+ placement: TargetPlacement,
+): BuildTarget {
+ const target = buildTargetFor(architecture, kind);
+ if (!target.enabled) {
+ throw new Error(`Architecture "${architecture}" target "${kind}" is not enabled.`);
+ }
+ if (!target.placements.includes(placement)) {
+ throw new Error(
+ `Architecture "${architecture}" target "${kind}" does not support "${placement}" placement.`,
+ );
+ }
+ return target;
+}
+
+const defaultTarget = TARGETS.find((target) => target.enabled);
+if (!defaultTarget) {
+ throw new Error("Architecture manifest must contain at least one enabled target.");
+}
+export const DEFAULT_TARGET: BuildTarget = defaultTarget;
+
export function enabledArchitectureLabels(
kind: BuildKind,
definitions: readonly ArchitectureDefinition<SkillArchitecture>[] =
diff --git a/common/ipc.ts b/common/ipc.ts
index 3716243..4132641 100644
--- a/common/ipc.ts
+++ b/common/ipc.ts
@@ -2,7 +2,12 @@ import type { Analysis, AnalysisFeedback, AnalysisStep, Confidence } from "./ana
import type { AutomationPlan, BuiltAutomation } from "./automation";
import type { MicrophoneDevice } from "./microphone";
import type { NarrationLanguage } from "./narration";
-import type { BuiltSkill, SkillArchitecture, SkillPlan } from "./skill";
+import type {
+ BuiltSkill,
+ SkillArchitecture,
+ SkillPlan,
+ TargetPlacement,
+} from "./skill";
import type { RecorderState } from "./types";
/** The last completed session — the one that can be analyzed. */
@@ -149,7 +154,7 @@ export interface SkillPlanResult {
* - **install** — write it into the target agent's live skills folder (Scout auto-loads it).
* - **export** — download it to a folder the user picks (the only option for Cowork).
*/
-export type SkillPlacement = "install" | "export";
+export type SkillPlacement = TargetPlacement;
/** Result of finalizing + placing a skill. */
export interface SkillCreateResult {
diff --git a/electron/skillbuilder/builder.ts b/electron/skillbuilder/builder.ts
index 6495a40..e939883 100644
--- a/electron/skillbuilder/builder.ts
+++ b/electron/skillbuilder/builder.ts
@@ -7,6 +7,7 @@ import { approveAll, type CopilotSession } from "@github/copilot-sdk";
import {
BuiltSkillSchema,
renderSkillMarkdown,
+ requireTargetPlacement,
SkillPlanSchema,
slugifySkillName,
toBuiltSkill,
@@ -145,6 +146,7 @@ export class SkillBuilder extends AgentBuilder<LiveBuild> {
// proposed plan for older callers that don't pass one.
const plan = editedPlan ? SkillPlanSchema.parse(editedPlan) : held?.lastPlan ?? null;
if (!plan) throw new Error("There is no plan to build from yet.");
+ requireTargetPlacement(plan.architecture, "skill", target.kind);
// The pool may have evicted the live conversation while the user edited the plan;
// recreate one so export always works.
if (!held) held = await this.createLive(sessionId, plan.architecture);
diff --git a/electron/skillbuilder/placement.test.ts b/electron/skillbuilder/placement.test.ts
new file mode 100644
index 0000000..24f90d2
--- /dev/null
+++ b/electron/skillbuilder/placement.test.ts
@@ -0,0 +1,20 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { SkillPlanSchema } from "../../common/skill";
+import { SkillBuilder } from "./builder";
+
+test("skill creation rejects a placement unsupported by the plan architecture", async () => {
+ const builder = new SkillBuilder(() => undefined);
+ const plan = SkillPlanSchema.parse({
+ architecture: "cowork",
+ name: "reviewed-skill",
+ title: "Reviewed skill",
+ description: "A reviewed skill.",
+ });
+
+ await assert.rejects(
+ builder.create("placement-validation", plan, { kind: "install" }),
+ /Architecture "cowork" target "skill" does not support "install" placement/,
+ );
+});
diff --git a/package.json b/package.json
index 783b016..242ceb6 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"check:lockfile": "node scripts/check-lockfile-portability.mjs",
"typecheck": "tsc --noEmit",
"typecheck:evals": "tsc --noEmit -p evals/tsconfig.json",
- "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test evals/builder-imports.test.ts common/architecture-registry.test.ts electron/architectures/catalogue-registry.test.ts common/audio.test.ts common/microphone.test.ts common/narration.test.ts electron/recording-controls-bounds.test.ts electron/recording-privacy.test.ts electron/crash-guards.test.ts electron/recorder/controller.test.ts electron/recorder/session-store.test.ts electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/narration/analyze-gate.test.ts electron/narration/transcribe.test.ts electron/narration/whisper.test.ts electron/sessions.test.ts electron/debug-bundle.test.ts scripts/compliance.test.mjs",
+ "test": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs --test evals/builder-imports.test.ts common/architecture-registry.test.ts electron/architectures/catalogue-registry.test.ts common/audio.test.ts common/microphone.test.ts common/narration.test.ts electron/recording-controls-bounds.test.ts electron/recording-privacy.test.ts electron/crash-guards.test.ts electron/recorder/controller.test.ts electron/recorder/session-store.test.ts electron/frames/extractor.test.ts electron/narration/audio-analysis.test.ts electron/narration/analyze-gate.test.ts electron/narration/transcribe.test.ts electron/narration/whisper.test.ts electron/sessions.test.ts electron/debug-bundle.test.ts electron/skillbuilder/placement.test.ts src/skill-placement.test.ts scripts/compliance.test.mjs",
"eval": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/run.ts",
"eval:builder": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/builder/run.ts",
"eval:skill": "node --experimental-transform-types --no-warnings --import ./evals/register.mjs evals/skillbuilder/run.ts",
diff --git a/src/Library.tsx b/src/Library.tsx
index b9ca537..2a53943 100644
--- a/src/Library.tsx
+++ b/src/Library.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useRef, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import type { Analysis, AnalysisStep } from "../common/analysis";
import type {
@@ -17,7 +17,12 @@ import type {
SkillArchitecture,
SkillPlan,
} from "../common/skill";
-import { ARCHITECTURES, TARGETS } from "../common/skill";
+import {
+ ARCHITECTURES,
+ DEFAULT_TARGET,
+ TARGETS,
+ buildTargetFor,
+} from "../common/skill";
import type { AutomationPlan, BuiltAutomation } from "../common/automation";
import {
DEFAULT_NARRATION_LANGUAGE,
@@ -32,6 +37,7 @@ import {
SkillStepTiles,
} from "./plan-edit";
import { formatBytes, formatDur, formatWhen, shortLabel } from "./format";
+import { skillPlacementModel, skillTargetFor } from "./skill-placement";
export function Library() {
const [sessions, setSessions] = useState<SessionSummary[]>([]);
@@ -493,7 +499,7 @@ function AnalysisWorkspace({
? "automation"
: "none";
const [launch, setLaunch] = useState<LaunchTarget>(initialLaunch);
- const [chosenArch, setChosenArch] = useState<SkillArchitecture>("scout");
+ const [chosenArch, setChosenArch] = useState<SkillArchitecture>(DEFAULT_TARGET.architecture);
// Set while the user is deliberately canceling, so the aborted run's rejection
// doesn't surface as an error toast.
const canceled = useRef(false);
@@ -927,6 +933,11 @@ function SkillBuilderView({
hasSkill: boolean;
onClose: () => void;
}) {
+ const defaultPlacementFor = useCallback(
+ (architecture: SkillArchitecture): SkillPlacement =>
+ skillPlacementModel(skillTargetFor(architecture)).defaultPlacement,
+ [],
+ );
// If this recording is already a skill, hold on a spinner until we've loaded it,
// so we never flash the planning state before jumping to the skill.
const [phase, setPhase] = useState<BuildPhase>(hasSkill ? "loading" : "ready");
@@ -938,7 +949,8 @@ function SkillBuilderView({
const [builtName, setBuiltName] = useState("");
const canceled = useRef(false);
const inFlight = useRef(false);
- const [placement, setPlacement] = useState<SkillPlacement>("install");
+ const [placement, setPlacement] = useState<SkillPlacement>(() => defaultPlacementFor(initialArch));
+ const placementModel = useMemo(() => skillPlacementModel(skillTargetFor(architecture)), [architecture]);
const updatePlan = useCallback((part: Partial<SkillPlan>) => {
setPlan((prev) => (prev ? { ...prev, ...part } : prev));
@@ -961,9 +973,9 @@ function SkillBuilderView({
setBuiltName(s.name);
setExportedPath(s.exportedPath);
setArchitecture(s.architecture);
- // We don't persist how it was placed; Cowork can only export, and Scout defaults
- // to install (its primary action), so infer from the architecture on reopen.
- setPlacement(s.architecture === "cowork" ? "export" : "install");
+ // We don't persist how it was placed, so reopening infers the architecture's
+ // current default placement from the manifest.
+ setPlacement(defaultPlacementFor(s.architecture));
if (s.plan) setPlan(s.plan);
setPhase("done");
} else if (hasSkill) {
@@ -974,7 +986,7 @@ function SkillBuilderView({
return () => {
live = false;
};
- }, [sessionId, hasSkill]);
+ }, [sessionId, hasSkill, defaultPlacementFor]);
useEffect(() => {
return window.skillRecorder.onSkillProgress((p: SkillBuildProgress) => {
@@ -1124,11 +1136,13 @@ function SkillBuilderView({
<div className="sb-check" aria-hidden>
✓
</div>
- <h2 className="sb-title">{placement === "install" ? "Added to Scout" : "Skill exported"}</h2>
+ <h2 className="sb-title">
+ {placement === "install" ? placementModel.installDoneTitle : "Skill exported"}
+ </h2>
<p>
<code className="sb-slug">{builtName}</code>{" "}
{placement === "install"
- ? "is now in Scout — it loads automatically."
+ ? placementModel.installDoneMessage
: `is built for ${archLabel(architecture)}. Install it wherever ${archLabel(architecture)} loads skills.`}
</p>
{exportedPath && <p className="sb-path">{exportedPath}</p>}
@@ -1140,26 +1154,16 @@ function SkillBuilderView({
<div className="ws-foot">
<span className="foot-status" />
<div className="ws-foot-actions">
- {architecture === "scout" && (
+ {placementModel.actions.map((action) => (
<button
- className="ghost"
- onClick={() => void place("export")}
- title="Download the skill to a folder you choose"
+ key={action.placement}
+ className={action.primary ? "record-cta" : "ghost"}
+ onClick={() => void place(action.placement)}
+ title={action.title}
>
- Export…
+ {action.label}
</button>
- )}
- <button
- className="record-cta"
- onClick={() => void place(architecture === "scout" ? "install" : "export")}
- title={
- architecture === "scout"
- ? "Add the skill to Scout so it loads automatically"
- : "Download the skill to a folder you choose"
- }
- >
- {architecture === "scout" ? "Add to Scout" : "Export skill"}
- </button>
+ ))}
</div>
</div>
)}
@@ -1208,6 +1212,11 @@ function AutomationBuilderView({
const [builtName, setBuiltName] = useState("");
const canceled = useRef(false);
const inFlight = useRef(false);
+ // The initial architecture can reflect a prior skill choice while a saved automation loads.
+ const automationInstallTargetLabel =
+ phase === "done"
+ ? buildTargetFor(architecture, "automation").installTargetLabel
+ : "";
const updatePlan = useCallback((part: Partial<AutomationPlan>) => {
setPlan((prev) => (prev ? { ...prev, ...part } : prev));
@@ -1400,7 +1409,9 @@ function AutomationBuilderView({
</p>
{exportedPath && <p className="sb-path">{exportedPath}</p>}
<p className="sb-import-hint">
- Import it into Scout: open Scout → Automations → Import, and choose this bundle folder.
+ Import it into {automationInstallTargetLabel}: open{" "}
+ {automationInstallTargetLabel} → Automations → Import, and choose this bundle
+ folder.
</p>
</div>
)}
diff --git a/src/skill-placement.test.ts b/src/skill-placement.test.ts
new file mode 100644
index 0000000..28cc7da
--- /dev/null
+++ b/src/skill-placement.test.ts
@@ -0,0 +1,36 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { DEFAULT_TARGET, TARGETS } from "../common/skill";
+import { skillPlacementModel, skillTargetFor } from "./skill-placement";
+
+test("placement model preserves Scout and Cowork action ordering", () => {
+ const defaultSkill = skillPlacementModel(skillTargetFor(DEFAULT_TARGET.architecture));
+ assert.equal(defaultSkill.defaultPlacement, "install");
+ assert.deepEqual(
+ defaultSkill.actions.map(({ placement, primary, label }) => [placement, primary, label]),
+ [
+ ["export", false, "Export…"],
+ ["install", true, "Add to Scout"],
+ ],
+ );
+ assert.equal(defaultSkill.installDoneTitle, "Added to Scout");
+ assert.equal(defaultSkill.installDoneMessage, "is now in Scout — it loads automatically.");
+
+ const exportOnlyTarget = TARGETS.find(
+ (target) =>
+ target.kind === "skill" &&
+ target.enabled &&
+ target.placements.length === 1 &&
+ target.placements[0] === "export" &&
+ target.architecture !== DEFAULT_TARGET.architecture,
+ );
+ assert.ok(exportOnlyTarget);
+
+ const exportOnly = skillPlacementModel(skillTargetFor(exportOnlyTarget.architecture));
+ assert.equal(exportOnly.defaultPlacement, "export");
+ assert.deepEqual(
+ exportOnly.actions.map(({ placement, primary, label }) => [placement, primary, label]),
+ [["export", true, "Export skill"]],
+ );
+});
diff --git a/src/skill-placement.ts b/src/skill-placement.ts
new file mode 100644
index 0000000..3c1a6d1
--- /dev/null
+++ b/src/skill-placement.ts
@@ -0,0 +1,54 @@
+import {
+ buildTargetFor,
+ type BuildTarget,
+ type SkillArchitecture,
+} from "../common/architecture-registry";
+import type { SkillPlacement } from "../common/ipc";
+
+export interface SkillPlacementAction {
+ placement: SkillPlacement;
+ primary: boolean;
+ label: string;
+ title: string;
+}
+
+export interface SkillPlacementModel {
+ defaultPlacement: SkillPlacement;
+ actions: readonly SkillPlacementAction[];
+ installDoneTitle: string;
+ installDoneMessage: string;
+}
+
+export function skillTargetFor(architecture: SkillArchitecture): BuildTarget {
+ return buildTargetFor(architecture, "skill");
+}
+
+export function skillPlacementModel(target: BuildTarget): SkillPlacementModel {
+ if (target.placements.length === 0) {
+ throw new Error(`Skill target "${target.label}" must declare at least one placement.`);
+ }
+
+ const defaultPlacement = target.placements[0];
+ const placements = [...target.placements.slice(1), defaultPlacement];
+ const actions = placements.map((placement) => {
+ const primary = placement === defaultPlacement;
+ const label =
+ placement === "install"
+ ? `Add to ${target.installTargetLabel}`
+ : primary
+ ? "Export skill"
+ : "Export…";
+ const title =
+ placement === "install"
+ ? `Add the skill to ${target.installTargetLabel} so it loads automatically`
+ : "Download the skill to a folder you choose";
+ return { placement, primary, label, title };
+ });
+
+ return {
+ defaultPlacement,
+ actions,
+ installDoneTitle: `Added to ${target.installTargetLabel}`,
+ installDoneMessage: `is now in ${target.installTargetLabel} — it loads automatically.`,
+ };
+}