Skip to content

Commit 9d8eae5

Browse files
committed
feat(prompts): add taskTimeSpent variable for prompt customization
Closes #327
1 parent 002947e commit 9d8eae5

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Variable `{taskTimeSpent}` in `HH:mm` format for prompt customization that is replaced with value from the active [task](https://www.jetbrains.com/help/idea/managing-tasks-and-context.html#work-with-tasks).
8+
59
## [2.9.1] - 2025-03-23
610

711
### Fixed

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ import com.github.blarc.ai.commits.intellij.plugin.notifications.Notification
44
import com.github.blarc.ai.commits.intellij.plugin.notifications.sendNotification
55
import com.github.blarc.ai.commits.intellij.plugin.settings.AppSettings2
66
import com.github.blarc.ai.commits.intellij.plugin.settings.ProjectSettings
7+
import com.intellij.DynamicBundle
78
import com.intellij.credentialStore.CredentialAttributes
89
import com.intellij.credentialStore.OneTimeString
9-
import com.intellij.DynamicBundle
1010
import com.intellij.ide.passwordSafe.PasswordSafe
1111
import com.intellij.openapi.components.service
1212
import com.intellij.openapi.diff.impl.patch.IdeaTextPatchBuilder
1313
import com.intellij.openapi.diff.impl.patch.UnifiedDiffWriter
1414
import com.intellij.openapi.project.Project
1515
import com.intellij.openapi.vcs.changes.Change
1616
import com.intellij.tasks.TaskManager
17+
import com.intellij.util.text.DateFormatUtil
1718
import git4idea.repo.GitRepositoryManager
1819
import kotlinx.coroutines.Dispatchers
1920
import kotlinx.coroutines.withContext
2021
import java.io.StringWriter
2122
import java.nio.file.FileSystems
22-
import java.util.Locale
23+
import java.util.*
2324

2425
object AICommitsUtils {
2526

@@ -51,6 +52,7 @@ object AICommitsUtils {
5152
content = content.replace("{taskId}", activeTask.id)
5253
content = content.replace("{taskSummary}", activeTask.summary)
5354
content = content.replace("{taskDescription}", activeTask.description.orEmpty())
55+
content = content.replace("{taskTimeSpent}", DateFormatUtil.formatTime(activeTask.totalTimeSpent))
5456
}
5557

5658
return if (content.contains("{diff}")) {

src/main/resources/messages/AiCommitsBundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ validation.float=Value should be a float.
4646
validation.double=Value should be a double.
4747
validation.temperature=Temperature should be between 0 and 2.
4848
settings.prompt.comment=<ul>\
49-
<li>Customize your prompt with variables: {locale}, {diff}, {branch}, {hint}, {taskId}, {taskSummary} and {taskDescription}.</li>\
49+
<li>Customize your prompt with variables: {locale}, {diff}, {branch}, {hint}, {taskId}, {taskSummary}, {taskDescription} and {taskTimeSpent}.</li>\
5050
<li>Include a hint by using a dollar sign prefix like this: {Here is a hint: $hint}. This adds the hint text inside the curly brackets only if a hint is provided.</li>\
5151
<li>Note: The prompt preview displays only the first 10,000 characters.</li>\
5252
</ul>

0 commit comments

Comments
 (0)