refactor(kilo-indexing): migrate BusEvent and SemanticSearchTool schemas from zod to effect Schema

Replace zod-based schema definitions with Effect Schema equivalents in
the indexing status event and semantic-search tool parameters. This
aligns both modules with the broader zod-to-effect migration underway
across kilo packages.

- Add Effect Schema mirror of IndexingStatus for BusEvent.define
- Import INDEXING_STATUS_STATES literal union from kilo-indexing/status
- Convert SemanticSearchTool parameters from z.object to Schema.Struct
- Inline explicit type annotations on the tool execute callback to
  satisfy the new generic inference after dropping the type parameter
- Reformat long single-line expressions for readability
This commit is contained in:
Imanol Maiztegui
2026-04-27 19:31:58 +02:00
parent 27a4db57e9
commit bb7ee00b07
2 changed files with 36 additions and 15 deletions
+23 -4
View File
@@ -1,4 +1,5 @@
import z from "zod"
import { Schema } from "effect"
import path from "path"
import {
CodeIndexManager,
@@ -7,7 +8,12 @@ import {
} from "@kilocode/kilo-indexing/engine"
import { toIndexingConfigInput } from "@kilocode/kilo-indexing/config"
import { hasIndexingPlugin } from "@kilocode/kilo-indexing/detect"
import { IndexingStatus, disabledIndexingStatus, normalizeIndexingStatus } from "@kilocode/kilo-indexing/status"
import {
IndexingStatus,
INDEXING_STATUS_STATES,
disabledIndexingStatus,
normalizeIndexingStatus,
} from "@kilocode/kilo-indexing/status"
import { Telemetry } from "@kilocode/kilo-telemetry"
import { Instance } from "@/project/instance"
import { Bus } from "@/bus"
@@ -123,6 +129,17 @@ export namespace KiloIndexing {
export const Status = IndexingStatus
export type Status = z.infer<typeof Status>
// Mirror of IndexingStatus using Effect Schema for BusEvent.define, which
// requires a Schema.Top. The zod form above is kept for consumers that still
// depend on the z.infer-derived type.
const StatusSchema = Schema.Struct({
state: Schema.Literals(INDEXING_STATUS_STATES),
message: Schema.String,
processedFiles: Schema.Number,
totalFiles: Schema.Number,
percent: Schema.Number,
})
type Entry = {
manager?: CodeIndexManager
current(): Status
@@ -138,8 +155,8 @@ export namespace KiloIndexing {
export const Event = BusEvent.define(
"indexing.status",
z.object({
status: Status,
Schema.Struct({
status: StatusSchema,
}),
)
@@ -166,7 +183,9 @@ export namespace KiloIndexing {
}
if (cfg.experimental?.semantic_indexing !== true) {
return inert(() => disabledIndexingStatus("Semantic indexing is disabled. Enable it in the Experimental settings."))
return inert(() =>
disabledIndexingStatus("Semantic indexing is disabled. Enable it in the Experimental settings."),
)
}
if (isWorktreePath(dir)) {
@@ -1,5 +1,4 @@
import z from "zod"
import { Effect } from "effect"
import { Effect, Schema } from "effect"
import path from "path"
import * as Tool from "@/tool/tool"
import { KiloIndexing } from "@/kilocode/indexing"
@@ -7,14 +6,14 @@ import { Instance } from "@/project/instance"
import DESCRIPTION from "./semantic-search.txt"
const Parameters = z.object({
query: z.string().describe("The search query, expressed in natural language."),
path: z
.string()
.optional()
.describe(
const Parameters = Schema.Struct({
query: Schema.String.annotate({
description: "The search query, expressed in natural language.",
}),
path: Schema.optional(Schema.String).annotate({
description:
"Limit search to specific subdirectory (relative to the current workspace directory). Leave empty for entire workspace.",
),
}),
})
type SearchResult = {
@@ -29,12 +28,15 @@ type Meta = {
results: SearchResult[]
}
export const SemanticSearchTool = Tool.define<typeof Parameters, Meta, never, "semantic_search">(
export const SemanticSearchTool = Tool.define(
"semantic_search",
Effect.succeed({
description: DESCRIPTION,
parameters: Parameters,
execute: (params, ctx) =>
execute: (
params: Schema.Schema.Type<typeof Parameters>,
ctx: Tool.Context,
): Effect.Effect<Tool.ExecuteResult<Meta>> =>
Effect.gen(function* () {
if (!params.query) {
throw new Error("query is required")