style: biome formatting
This commit is contained in:
@@ -48,20 +48,27 @@ function buildInstallCommand(spec: SkillInstallSpec): {
|
|||||||
} {
|
} {
|
||||||
switch (spec.kind) {
|
switch (spec.kind) {
|
||||||
case "brew": {
|
case "brew": {
|
||||||
if (!spec.formula) return { argv: null, shell: null, error: "missing brew formula" };
|
if (!spec.formula)
|
||||||
|
return { argv: null, shell: null, error: "missing brew formula" };
|
||||||
return { argv: ["brew", "install", spec.formula], shell: null };
|
return { argv: ["brew", "install", spec.formula], shell: null };
|
||||||
}
|
}
|
||||||
case "node": {
|
case "node": {
|
||||||
if (!spec.package) return { argv: null, shell: null, error: "missing node package" };
|
if (!spec.package)
|
||||||
|
return { argv: null, shell: null, error: "missing node package" };
|
||||||
return { argv: ["npm", "install", "-g", spec.package], shell: null };
|
return { argv: ["npm", "install", "-g", spec.package], shell: null };
|
||||||
}
|
}
|
||||||
case "go": {
|
case "go": {
|
||||||
if (!spec.module) return { argv: null, shell: null, error: "missing go module" };
|
if (!spec.module)
|
||||||
|
return { argv: null, shell: null, error: "missing go module" };
|
||||||
return { argv: ["go", "install", spec.module], shell: null };
|
return { argv: ["go", "install", spec.module], shell: null };
|
||||||
}
|
}
|
||||||
case "pnpm": {
|
case "pnpm": {
|
||||||
if (!spec.repoPath || !spec.script) {
|
if (!spec.repoPath || !spec.script) {
|
||||||
return { argv: null, shell: null, error: "missing pnpm repoPath/script" };
|
return {
|
||||||
|
argv: null,
|
||||||
|
shell: null,
|
||||||
|
error: "missing pnpm repoPath/script",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const repoPath = resolveUserPath(spec.repoPath);
|
const repoPath = resolveUserPath(spec.repoPath);
|
||||||
const cmd = `cd ${JSON.stringify(repoPath)} && pnpm install && pnpm run ${JSON.stringify(spec.script)}`;
|
const cmd = `cd ${JSON.stringify(repoPath)} && pnpm install && pnpm run ${JSON.stringify(spec.script)}`;
|
||||||
@@ -69,14 +76,19 @@ function buildInstallCommand(spec: SkillInstallSpec): {
|
|||||||
}
|
}
|
||||||
case "git": {
|
case "git": {
|
||||||
if (!spec.url || !spec.destination) {
|
if (!spec.url || !spec.destination) {
|
||||||
return { argv: null, shell: null, error: "missing git url/destination" };
|
return {
|
||||||
|
argv: null,
|
||||||
|
shell: null,
|
||||||
|
error: "missing git url/destination",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const dest = resolveUserPath(spec.destination);
|
const dest = resolveUserPath(spec.destination);
|
||||||
const cmd = `if [ -d ${JSON.stringify(dest)} ]; then echo "Already cloned"; else git clone ${JSON.stringify(spec.url)} ${JSON.stringify(dest)}; fi`;
|
const cmd = `if [ -d ${JSON.stringify(dest)} ]; then echo "Already cloned"; else git clone ${JSON.stringify(spec.url)} ${JSON.stringify(dest)}; fi`;
|
||||||
return { argv: null, shell: cmd };
|
return { argv: null, shell: cmd };
|
||||||
}
|
}
|
||||||
case "shell": {
|
case "shell": {
|
||||||
if (!spec.command) return { argv: null, shell: null, error: "missing shell command" };
|
if (!spec.command)
|
||||||
|
return { argv: null, shell: null, error: "missing shell command" };
|
||||||
return { argv: null, shell: spec.command };
|
return { argv: null, shell: spec.command };
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -87,7 +99,10 @@ function buildInstallCommand(spec: SkillInstallSpec): {
|
|||||||
export async function installSkill(
|
export async function installSkill(
|
||||||
params: SkillInstallRequest,
|
params: SkillInstallRequest,
|
||||||
): Promise<SkillInstallResult> {
|
): Promise<SkillInstallResult> {
|
||||||
const timeoutMs = Math.min(Math.max(params.timeoutMs ?? 300_000, 1_000), 900_000);
|
const timeoutMs = Math.min(
|
||||||
|
Math.max(params.timeoutMs ?? 300_000, 1_000),
|
||||||
|
900_000,
|
||||||
|
);
|
||||||
const workspaceDir = resolveUserPath(params.workspaceDir);
|
const workspaceDir = resolveUserPath(params.workspaceDir);
|
||||||
const entries = loadWorkspaceSkillEntries(workspaceDir);
|
const entries = loadWorkspaceSkillEntries(workspaceDir);
|
||||||
const entry = entries.find((item) => item.skill.name === params.skillName);
|
const entry = entries.find((item) => item.skill.name === params.skillName);
|
||||||
@@ -134,7 +149,10 @@ export async function installSkill(
|
|||||||
|
|
||||||
const result = command.shell
|
const result = command.shell
|
||||||
? await runShell(command.shell, timeoutMs)
|
? await runShell(command.shell, timeoutMs)
|
||||||
: await runCommandWithTimeout(command.argv, { timeoutMs, cwd: command.cwd });
|
: await runCommandWithTimeout(command.argv, {
|
||||||
|
timeoutMs,
|
||||||
|
cwd: command.cwd,
|
||||||
|
});
|
||||||
|
|
||||||
const success = result.code === 0;
|
const success = result.code === 0;
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -91,7 +91,10 @@ function normalizeInstallOptions(entry: SkillEntry): SkillInstallOption[] {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSkillStatus(entry: SkillEntry, config?: ClawdisConfig): SkillStatusEntry {
|
function buildSkillStatus(
|
||||||
|
entry: SkillEntry,
|
||||||
|
config?: ClawdisConfig,
|
||||||
|
): SkillStatusEntry {
|
||||||
const skillKey = resolveSkillKey(entry);
|
const skillKey = resolveSkillKey(entry);
|
||||||
const skillConfig = resolveSkillConfig(config, skillKey);
|
const skillConfig = resolveSkillConfig(config, skillKey);
|
||||||
const disabled = skillConfig?.enabled === false;
|
const disabled = skillConfig?.enabled === false;
|
||||||
@@ -113,11 +116,13 @@ function buildSkillStatus(entry: SkillEntry, config?: ClawdisConfig): SkillStatu
|
|||||||
missingEnv.push(envName);
|
missingEnv.push(envName);
|
||||||
}
|
}
|
||||||
|
|
||||||
const configChecks: SkillStatusConfigCheck[] = requiredConfig.map((pathStr) => {
|
const configChecks: SkillStatusConfigCheck[] = requiredConfig.map(
|
||||||
const value = resolveConfigPath(config, pathStr);
|
(pathStr) => {
|
||||||
const satisfied = isConfigPathTruthy(config, pathStr);
|
const value = resolveConfigPath(config, pathStr);
|
||||||
return { path: pathStr, value, satisfied };
|
const satisfied = isConfigPathTruthy(config, pathStr);
|
||||||
});
|
return { path: pathStr, value, satisfied };
|
||||||
|
},
|
||||||
|
);
|
||||||
const missingConfig = configChecks
|
const missingConfig = configChecks
|
||||||
.filter((check) => !check.satisfied)
|
.filter((check) => !check.satisfied)
|
||||||
.map((check) => check.path);
|
.map((check) => check.path);
|
||||||
|
|||||||
@@ -279,7 +279,6 @@ function resolveSkillKey(skill: Skill, entry?: SkillEntry): string {
|
|||||||
return entry?.clawdis?.skillKey ?? skill.name;
|
return entry?.clawdis?.skillKey ?? skill.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function shouldIncludeSkill(params: {
|
function shouldIncludeSkill(params: {
|
||||||
entry: SkillEntry;
|
entry: SkillEntry;
|
||||||
config?: ClawdisConfig;
|
config?: ClawdisConfig;
|
||||||
@@ -329,7 +328,6 @@ function filterSkillEntries(
|
|||||||
return entries.filter((entry) => shouldIncludeSkill({ entry, config }));
|
return entries.filter((entry) => shouldIncludeSkill({ entry, config }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function applySkillEnvOverrides(params: {
|
export function applySkillEnvOverrides(params: {
|
||||||
skills: SkillEntry[];
|
skills: SkillEntry[];
|
||||||
config?: ClawdisConfig;
|
config?: ClawdisConfig;
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ import {
|
|||||||
ConfigGetParamsSchema,
|
ConfigGetParamsSchema,
|
||||||
type ConfigSetParams,
|
type ConfigSetParams,
|
||||||
ConfigSetParamsSchema,
|
ConfigSetParamsSchema,
|
||||||
type SkillsInstallParams,
|
|
||||||
SkillsInstallParamsSchema,
|
|
||||||
type SkillsStatusParams,
|
|
||||||
SkillsStatusParamsSchema,
|
|
||||||
type SkillsUpdateParams,
|
|
||||||
SkillsUpdateParamsSchema,
|
|
||||||
type ConnectParams,
|
type ConnectParams,
|
||||||
ConnectParamsSchema,
|
ConnectParamsSchema,
|
||||||
type CronAddParams,
|
type CronAddParams,
|
||||||
@@ -79,6 +73,12 @@ import {
|
|||||||
SessionsPatchParamsSchema,
|
SessionsPatchParamsSchema,
|
||||||
type ShutdownEvent,
|
type ShutdownEvent,
|
||||||
ShutdownEventSchema,
|
ShutdownEventSchema,
|
||||||
|
type SkillsInstallParams,
|
||||||
|
SkillsInstallParamsSchema,
|
||||||
|
type SkillsStatusParams,
|
||||||
|
SkillsStatusParamsSchema,
|
||||||
|
type SkillsUpdateParams,
|
||||||
|
SkillsUpdateParamsSchema,
|
||||||
type Snapshot,
|
type Snapshot,
|
||||||
SnapshotSchema,
|
SnapshotSchema,
|
||||||
type StateVersion,
|
type StateVersion,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import chalk from "chalk";
|
|||||||
import { type WebSocket, WebSocketServer } from "ws";
|
import { type WebSocket, WebSocketServer } from "ws";
|
||||||
import { lookupContextTokens } from "../agents/context.js";
|
import { lookupContextTokens } from "../agents/context.js";
|
||||||
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL } from "../agents/defaults.js";
|
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL } from "../agents/defaults.js";
|
||||||
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
|
|
||||||
import { installSkill } from "../agents/skills-install.js";
|
import { installSkill } from "../agents/skills-install.js";
|
||||||
|
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
|
||||||
import { DEFAULT_AGENT_WORKSPACE_DIR } from "../agents/workspace.js";
|
import { DEFAULT_AGENT_WORKSPACE_DIR } from "../agents/workspace.js";
|
||||||
import {
|
import {
|
||||||
normalizeThinkLevel,
|
normalizeThinkLevel,
|
||||||
|
|||||||
Reference in New Issue
Block a user