refactor(config): simplify utility workflows (#43947)

This commit is contained in:
Kit Langton
2026-08-21 14:34:19 -04:00
committed by GitHub
parent 15864304a5
commit 1dea4b9391
6 changed files with 9 additions and 12 deletions
+1 -1
View File
@@ -793,7 +793,7 @@ function isPlainRecord(value: unknown): value is Record<string, unknown> {
}
function own(value: Record<string, unknown>, key: string) {
return Object.prototype.hasOwnProperty.call(value, key)
return Object.hasOwn(value, key)
}
function setOwn(value: Record<string, unknown>, key: string, item: unknown) {
+1 -2
View File
@@ -157,8 +157,7 @@ function isPathAction(action: string): action is PathAction {
}
function expandHome(resource: string, home: string) {
if (resource === "~") return home
if (resource === "$HOME") return home
if (resource === "~" || resource === "$HOME") return home
const relative = resource.startsWith("~/")
? resource.slice(2)
: resource.startsWith("$HOME/") || resource.startsWith("$HOME\\")
+2 -3
View File
@@ -37,11 +37,10 @@ const substituteFiles = Effect.fnUntraced(function* (input: SubstituteInput, tex
const fs = yield* FSUtil.Service
const configDir = input.type === "path" ? path.dirname(input.path) : input.dir
const configSource = input.type === "path" ? input.path : input.source
const matches = Array.from(text.matchAll(/\{file:[^}]+\}/g))
let out = ""
let cursor = 0
for (const match of matches) {
for (const match of text.matchAll(/\{file:[^}]+\}/g)) {
const token = match[0]
const index = match.index
out += text.slice(cursor, index)
@@ -54,7 +53,7 @@ const substituteFiles = Effect.fnUntraced(function* (input: SubstituteInput, tex
continue
}
const filePath = token.replace(/^\{file:/, "").replace(/\}$/, "")
const filePath = token.slice("{file:".length, -1)
const expandedPath = filePath.startsWith("~/") ? path.join(os.homedir(), filePath.slice(2)) : filePath
const resolvedPath = path.isAbsolute(expandedPath) ? expandedPath : path.resolve(configDir, expandedPath)
const fileContent = yield* fs.readFileString(resolvedPath).pipe(
+1 -1
View File
@@ -19,7 +19,7 @@ export const EmbeddedSource = Skill.EmbeddedSource
export type EmbeddedSource = Skill.EmbeddedSource
export const Source = Skill.Source
export type Source = typeof Source.Type
export type Source = Skill.Source
export const Info = Skill.Info
export type Info = Skill.Info
+1 -2
View File
@@ -72,8 +72,7 @@ const layer = Layer.effect(
load: Effect.fn("SkillInstructions.load")(function* (selection) {
const agent = selection.info
if (!agent) return Instructions.empty
const permitted = Skill.available(yield* skills.list(), agent)
const available = permitted
const available = Skill.available(yield* skills.list(), agent)
.flatMap((skill) =>
skill.description === undefined || skill.autoinvoke === false
? []
+3 -3
View File
@@ -180,9 +180,9 @@ const layer = Layer.effect(
}),
)
}),
resolve: Effect.fn("WellKnown.resolveEntry")(function* (entry, variables) {
return yield* resolveEntry(entry, variables).pipe(Effect.provideService(HttpClient.HttpClient, http))
}),
resolve: Effect.fn("WellKnown.resolveEntry")((entry, variables) =>
resolveEntry(entry, variables).pipe(Effect.provideService(HttpClient.HttpClient, http)),
),
})
}),
)