Skip to content

Commit

Permalink
feat(shire): add chatbox functionality and update file references
Browse files Browse the repository at this point in the history
- Introduce `SHIRE_CHAT_BOX_FILE` constant for chatbox file naming.
- Update `ShireInput` to use `SHIRE_CHAT_BOX_FILE` and enable scratch file creation.
- Modify `ShireFileRunService` to support chatbox-specific actions and messages.
- Add chatbox-related messages to `ShireBundle.properties`.
  • Loading branch information
phodal committed Dec 22, 2024
1 parent 1974282 commit d045cd3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.vfs.VirtualFile

public const val SHIRE_CHAT_BOX_FILE = "shire-chatbox.default.shire"
public const val SHIRE_TEMP_OUTPUT = ".shire-output"
public const val LLM_LOGGING_JSONL = "logging.jsonl"
public const val LLM_LOGGING = "logging.log"
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/kotlin/com/phodal/shirecore/ui/ShireInput.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.phodal.shirecore.ui

import com.intellij.ide.scratch.ScratchFileService
import com.intellij.ide.scratch.ScratchRootType
import com.intellij.lang.Language
import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.phodal.shirecore.SHIRE_CHAT_BOX_FILE
import com.phodal.shirecore.ShireCoreBundle
import com.phodal.shirecore.provider.shire.FileRunService
import java.awt.BorderLayout
Expand Down Expand Up @@ -53,9 +55,10 @@ class ShireInput(val project: Project) : JPanel(BorderLayout()), Disposable {

return ScratchRootType.getInstance().createScratchFile(
project,
"shire-temp.shire",
SHIRE_CHAT_BOX_FILE,
Language.findLanguageByID("Shire"),
content
content,
ScratchFileService.Option.create_if_missing
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.intellij.psi.PsiElement
import com.phodal.shirecore.config.InteractionType
import com.phodal.shirecore.config.ShireActionLocation
import com.phodal.shirecore.provider.shire.FileRunService
import com.phodal.shirelang.ShireBundle
import com.phodal.shirelang.actions.ShireRunFileAction.Companion.executeShireFile
import com.phodal.shirelang.actions.base.DynamicShireActionConfig
import com.phodal.shirelang.compiler.ast.hobbit.HobbitHole
Expand Down Expand Up @@ -50,6 +51,9 @@ class ShireFileRunService : FileRunService, Disposable {
return setting
}

/**
* Create ChatBox Run
*/
override fun runFile(project: Project, virtualFile: VirtualFile, psiElement: PsiElement?): String? {
val settings = createRunSettings(project, virtualFile, psiElement) ?: return null
val psiFile = ShireFile.lookup(project, virtualFile) ?: return null
Expand All @@ -58,15 +62,14 @@ class ShireFileRunService : FileRunService, Disposable {
if (config.hole == null) {
config = config.copy(
hole = HobbitHole.create(
"Chatbox",
"Run from Chatbox",
ShireBundle.message("shire.actions.chat-box"),
ShireBundle.message("shire.actions.run-from-chat-box"),
InteractionType.RightPanel,
ShireActionLocation.CHAT_BOX
)
)
}

/// we should recreate file in Here
executeShireFile(project, config, settings)
return "Running Shire file: ${virtualFile.name}"
}
Expand Down
5 changes: 2 additions & 3 deletions shirelang/src/main/resources/messages/ShireBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ shire.line.marker.run.0=Run {0}
shire.label.choose.file=Choice Shire File
shire.run.error.script.not.found=Script not found
shire.patch.cannot.read.patch=Cannot read a patch

inspection.group.name=Shire language
inspection.duplicate.agent=Duplicate agent calls detected. It is recommended to make only one call per agent. Please remove any duplicate agent calls.
shire.intention.name=Shire Assistant
Expand All @@ -13,13 +12,13 @@ shire.newFile=ShireAction
shire.file=Shire file
shire.run.local.mode=Local command detected, running in local mode
shire.intention=Shire intention action

shire.llm.notfound=No LLM provider found
shire.llm.done=\nDone!

shire.prompt.fix.command=You are a top software developer in the world, which can help me to fix the issue.\nWhen I use shell-like language and compile the script, I got an error, can you help me to fix it?\n\nOrigin script:\n```\n{0}\n```\n\nScript with result:\n####\n{1}\n####
shire.prompt.fix.run-result=You are a top software developer in the world, which can help me to fix the issue.\n\nHere is the run result, can you help me to fix it?\nRun result:\n####\n{0}\n####
intentions.request.background.process.title=Generate File
shire.toolchain.function.not.found=No match function: {0}, If you using toolchain function, visit: https://shire.phodal.com/shire/shire-toolchain-function for more. TODO for User custom.
intentions.assistant.name=Shire Intention Action
shire.line.marker.run.comment=Run Shire
shire.actions.chat-box=ChatBox
shire.actions.run-from-chat-box=Run from Chatbox
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// File: com/phodal/shirelang/run/ShireConfiguration Companion Test.kt

package com.phodal.shirelang.run

import com.phodal.shirelang.run.ShireConfiguration.Companion.mapStringToMap
Expand Down

0 comments on commit d045cd3

Please sign in to comment.