2
0

seed-e2e.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const dir = process.env.KILO_E2E_PROJECT_DIR ?? process.cwd()
  2. const title = process.env.KILO_E2E_SESSION_TITLE ?? "E2E Session"
  3. const text = process.env.KILO_E2E_MESSAGE ?? "Seeded for UI e2e"
  4. const model = process.env.KILO_E2E_MODEL ?? "kilo/kilo-auto/frontier"
  5. const parts = model.split("/")
  6. const providerID = parts[0] ?? "kilo" // kilocode_change
  7. const modelID = parts.slice(1).join("/") || "kilo-auto/frontier" // kilocode_change
  8. const now = Date.now()
  9. const seed = async () => {
  10. const { Instance } = await import("../src/project/instance")
  11. const { InstanceBootstrap } = await import("../src/project/bootstrap")
  12. const { Config } = await import("../src/config/config")
  13. const { Session } = await import("../src/session")
  14. const { MessageID, PartID } = await import("../src/session/schema")
  15. const { Project } = await import("../src/project/project")
  16. const { ModelID, ProviderID } = await import("../src/provider/schema")
  17. const { ToolRegistry } = await import("../src/tool/registry")
  18. try {
  19. await Instance.provide({
  20. directory: dir,
  21. init: InstanceBootstrap,
  22. fn: async () => {
  23. await Config.waitForDependencies()
  24. await ToolRegistry.ids()
  25. const session = await Session.create({ title })
  26. const messageID = MessageID.ascending()
  27. const partID = PartID.ascending()
  28. const message = {
  29. id: messageID,
  30. sessionID: session.id,
  31. role: "user" as const,
  32. time: { created: now },
  33. agent: "code", // kilocode_change - renamed from "build" to "code"
  34. model: {
  35. providerID: ProviderID.make(providerID),
  36. modelID: ModelID.make(modelID),
  37. },
  38. }
  39. const part = {
  40. id: partID,
  41. sessionID: session.id,
  42. messageID,
  43. type: "text" as const,
  44. text,
  45. time: { start: now },
  46. }
  47. await Session.updateMessage(message)
  48. await Session.updatePart(part)
  49. await Project.update({ projectID: Instance.project.id, name: "E2E Project" })
  50. },
  51. })
  52. } finally {
  53. await Instance.disposeAll().catch(() => {})
  54. }
  55. }
  56. await seed()