@gitkraken/core-gitlens 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -1
- package/dist/git/cache.d.ts +28 -4
- package/dist/git/cache.d.ts.map +1 -1
- package/dist/git/cache.js +82 -18
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/commit.d.ts.map +1 -1
- package/dist/git/models/commit.js.map +1 -1
- package/dist/git/models/reference.d.ts +31 -0
- package/dist/git/models/reference.d.ts.map +1 -1
- package/dist/git/models/remote.d.ts.map +1 -1
- package/dist/git/models/remote.js.map +1 -1
- package/dist/git/models/repository.d.ts +9 -1
- package/dist/git/models/repository.d.ts.map +1 -1
- package/dist/git/models/repository.js +19 -3
- package/dist/git/models/repository.js.map +1 -1
- package/dist/git/models/search.d.ts +2 -2
- package/dist/git/models/search.d.ts.map +1 -1
- package/dist/git/models/worktree.d.ts +4 -1
- package/dist/git/models/worktree.d.ts.map +1 -1
- package/dist/git/models/worktree.js +2 -2
- package/dist/git/models/worktree.js.map +1 -1
- package/dist/git/parsers/diffParser.d.ts.map +1 -1
- package/dist/git/parsers/diffParser.js.map +1 -1
- package/dist/git/providers/branches.d.ts +15 -4
- package/dist/git/providers/branches.d.ts.map +1 -1
- package/dist/git/providers/config.d.ts +4 -1
- package/dist/git/providers/config.d.ts.map +1 -1
- package/dist/git/providers/operations.d.ts +33 -10
- package/dist/git/providers/operations.d.ts.map +1 -1
- package/dist/git/providers/pausedOperations.d.ts +3 -1
- package/dist/git/providers/pausedOperations.d.ts.map +1 -1
- package/dist/git/providers/refs.d.ts +23 -2
- package/dist/git/providers/refs.d.ts.map +1 -1
- package/dist/git/providers/staging.d.ts +16 -0
- package/dist/git/providers/staging.d.ts.map +1 -1
- package/dist/git/providers/status.d.ts +4 -1
- package/dist/git/providers/status.d.ts.map +1 -1
- package/dist/git/remotes/azure-devops.d.ts.map +1 -1
- package/dist/git/remotes/azure-devops.js.map +1 -1
- package/dist/git/{exec.types.d.ts → run.types.d.ts} +22 -3
- package/dist/git/run.types.d.ts.map +1 -0
- package/dist/git/run.types.js +2 -0
- package/dist/git/run.types.js.map +1 -0
- package/dist/git/service.d.ts.map +1 -1
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/autolink.utils.d.ts.map +1 -1
- package/dist/git/utils/autolink.utils.js.map +1 -1
- package/dist/git/utils/blame.utils.d.ts.map +1 -1
- package/dist/git/utils/blame.utils.js.map +1 -1
- package/dist/git/utils/conflictResolution.utils.d.ts +6 -0
- package/dist/git/utils/conflictResolution.utils.d.ts.map +1 -0
- package/dist/git/utils/conflictResolution.utils.js +25 -0
- package/dist/git/utils/conflictResolution.utils.js.map +1 -0
- package/dist/git/utils/fileStatus.utils.d.ts +2 -1
- package/dist/git/utils/fileStatus.utils.d.ts.map +1 -1
- package/dist/git/utils/fileStatus.utils.js +4 -0
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/utils/search.utils.d.ts.map +1 -1
- package/dist/git/utils/search.utils.js +3 -0
- package/dist/git/utils/search.utils.js.map +1 -1
- package/dist/git/utils/sorting.d.ts +8 -0
- package/dist/git/utils/sorting.d.ts.map +1 -1
- package/dist/git/utils/sorting.js +15 -0
- package/dist/git/utils/sorting.js.map +1 -1
- package/dist/git/utils/status.utils.d.ts.map +1 -1
- package/dist/git/utils/status.utils.js.map +1 -1
- package/dist/git/watching/classifyChange.d.ts.map +1 -1
- package/dist/git/watching/classifyChange.js +8 -0
- package/dist/git/watching/classifyChange.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.js +1 -1
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/initWatcher.d.ts.map +1 -1
- package/dist/git/watching/initWatcher.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts.map +1 -1
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts.map +1 -1
- package/dist/git/watching/watchService.js +24 -4
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts.map +1 -1
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git-cli/exec/exec.types.d.ts +1 -1
- package/dist/git-cli/exec/exec.types.d.ts.map +1 -1
- package/dist/git-cli/exec/git.d.ts +3 -3
- package/dist/git-cli/exec/git.d.ts.map +1 -1
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.d.ts +10 -2
- package/dist/git-cli/exec/gitQueue.d.ts.map +1 -1
- package/dist/git-cli/exec/gitQueue.js +39 -12
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/parsers/blameParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/blameParser.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/parsers/refParser.d.ts +3 -30
- package/dist/git-cli/parsers/refParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/refParser.js +30 -30
- package/dist/git-cli/parsers/refParser.js.map +1 -1
- package/dist/git-cli/providers/blame.d.ts.map +1 -1
- package/dist/git-cli/providers/blame.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +15 -5
- package/dist/git-cli/providers/branches.d.ts.map +1 -1
- package/dist/git-cli/providers/branches.js +98 -68
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts.map +1 -1
- package/dist/git-cli/providers/commits.js +74 -30
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +11 -2
- package/dist/git-cli/providers/config.d.ts.map +1 -1
- package/dist/git-cli/providers/config.js +27 -2
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts.map +1 -1
- package/dist/git-cli/providers/diff.js +4 -2
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.d.ts.map +1 -1
- package/dist/git-cli/providers/graph.js +7 -2
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +13 -11
- package/dist/git-cli/providers/operations.d.ts.map +1 -1
- package/dist/git-cli/providers/operations.js +108 -38
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.d.ts.map +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +3 -1
- package/dist/git-cli/providers/pausedOperations.d.ts.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +7 -1
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +19 -2
- package/dist/git-cli/providers/refs.d.ts.map +1 -1
- package/dist/git-cli/providers/refs.js +286 -2
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts +6 -0
- package/dist/git-cli/providers/staging.d.ts.map +1 -1
- package/dist/git-cli/providers/staging.js +32 -0
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +4 -1
- package/dist/git-cli/providers/status.d.ts.map +1 -1
- package/dist/git-cli/providers/status.js +4 -3
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts.map +1 -1
- package/dist/git-cli/providers/tags.js +10 -6
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/ipc/discovery.d.ts +27 -0
- package/dist/ipc/discovery.d.ts.map +1 -0
- package/dist/ipc/discovery.js +38 -0
- package/dist/ipc/discovery.js.map +1 -0
- package/dist/ipc/ipcServer.d.ts +20 -0
- package/dist/ipc/ipcServer.d.ts.map +1 -0
- package/dist/ipc/ipcServer.js +162 -0
- package/dist/ipc/ipcServer.js.map +1 -0
- package/dist/plus/agents/providers/claudeCodeProvider.d.ts +114 -0
- package/dist/plus/agents/providers/claudeCodeProvider.d.ts.map +1 -0
- package/dist/plus/agents/providers/claudeCodeProvider.js +1480 -0
- package/dist/plus/agents/providers/claudeCodeProvider.js.map +1 -0
- package/dist/plus/agents/providers/claudeCodeTranscript.d.ts +36 -0
- package/dist/plus/agents/providers/claudeCodeTranscript.d.ts.map +1 -0
- package/dist/plus/agents/providers/claudeCodeTranscript.js +171 -0
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -0
- package/dist/plus/agents/sanitizePrompt.d.ts +15 -0
- package/dist/plus/agents/sanitizePrompt.d.ts.map +1 -0
- package/dist/plus/agents/sanitizePrompt.js +103 -0
- package/dist/plus/agents/sanitizePrompt.js.map +1 -0
- package/dist/plus/agents/stateMachine.d.ts +32 -0
- package/dist/plus/agents/stateMachine.d.ts.map +1 -0
- package/dist/plus/agents/stateMachine.js +180 -0
- package/dist/plus/agents/stateMachine.js.map +1 -0
- package/dist/plus/agents/types.d.ts +203 -0
- package/dist/plus/agents/types.d.ts.map +1 -0
- package/dist/plus/agents/types.js +49 -0
- package/dist/plus/agents/types.js.map +1 -0
- package/dist/plus/ai/errors.d.ts +4 -1
- package/dist/plus/ai/errors.d.ts.map +1 -1
- package/dist/plus/ai/errors.js +38 -0
- package/dist/plus/ai/errors.js.map +1 -1
- package/dist/plus/ai/models/promptTemplates.d.ts +11 -2
- package/dist/plus/ai/models/promptTemplates.d.ts.map +1 -1
- package/dist/plus/ai/prompts.d.ts +1 -0
- package/dist/plus/ai/prompts.d.ts.map +1 -1
- package/dist/plus/ai/prompts.js +48 -8
- package/dist/plus/ai/prompts.js.map +1 -1
- package/dist/plus/ai/utils/results.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/results.utils.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +10 -1
- package/dist/plus/git-github/api/github.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.js +156 -49
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/types.d.ts +8 -0
- package/dist/plus/git-github/api/types.d.ts.map +1 -1
- package/dist/plus/git-github/models.d.ts +1 -1
- package/dist/plus/git-github/models.d.ts.map +1 -1
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/git-github/providers/github/blame.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/blame.js.map +1 -1
- package/dist/plus/git-github/providers/github/branches.d.ts +5 -1
- package/dist/plus/git-github/providers/github/branches.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/branches.js +47 -24
- package/dist/plus/git-github/providers/github/branches.js.map +1 -1
- package/dist/plus/git-github/providers/github/commits.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/commits.js +144 -92
- package/dist/plus/git-github/providers/github/commits.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/diff.js +23 -9
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/git-github/providers/github/refs.d.ts +9 -1
- package/dist/plus/git-github/providers/github/refs.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/refs.js +38 -13
- package/dist/plus/git-github/providers/github/refs.js.map +1 -1
- package/dist/plus/git-github/providers/github/revision.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/revision.js +1 -2
- package/dist/plus/git-github/providers/github/revision.js.map +1 -1
- package/dist/plus/git-github/providers/github/status.d.ts +4 -1
- package/dist/plus/git-github/providers/github/status.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/status.js +1 -1
- package/dist/plus/git-github/providers/github/status.js.map +1 -1
- package/dist/plus/git-github/providers/github/tags.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/tags.js +35 -36
- package/dist/plus/git-github/providers/github/tags.js.map +1 -1
- package/dist/plus/git-github/providers/githubGitProvider.d.ts.map +1 -1
- package/dist/plus/git-github/providers/githubGitProvider.js.map +1 -1
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js.map +1 -1
- package/dist/utils/decorators/serializable.d.ts.map +1 -1
- package/dist/utils/decorators/serializable.js.map +1 -1
- package/dist/utils/dedupedAsyncCache.d.ts +37 -0
- package/dist/utils/dedupedAsyncCache.d.ts.map +1 -0
- package/dist/utils/dedupedAsyncCache.js +68 -0
- package/dist/utils/dedupedAsyncCache.js.map +1 -0
- package/dist/utils/diff.d.ts +2 -0
- package/dist/utils/diff.d.ts.map +1 -0
- package/dist/utils/diff.js +53 -0
- package/dist/utils/diff.js.map +1 -0
- package/dist/utils/disposable.d.ts.map +1 -1
- package/dist/utils/disposable.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts.map +1 -1
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/iterable.d.ts.map +1 -1
- package/dist/utils/iterable.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/lruMap.d.ts +9 -0
- package/dist/utils/lruMap.d.ts.map +1 -1
- package/dist/utils/lruMap.js +26 -4
- package/dist/utils/lruMap.js.map +1 -1
- package/dist/utils/markdown.d.ts.map +1 -1
- package/dist/utils/markdown.js.map +1 -1
- package/dist/utils/mru.d.ts.map +1 -1
- package/dist/utils/mru.js.map +1 -1
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/promise.d.ts +1 -0
- package/dist/utils/promise.d.ts.map +1 -1
- package/dist/utils/promise.js +17 -0
- package/dist/utils/promise.js.map +1 -1
- package/dist/utils/promiseCache.d.ts +10 -0
- package/dist/utils/promiseCache.d.ts.map +1 -1
- package/dist/utils/promiseCache.js +22 -0
- package/dist/utils/promiseCache.js.map +1 -1
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/string.js.map +1 -1
- package/dist/utils/uri.d.ts.map +1 -1
- package/dist/utils/uri.js.map +1 -1
- package/dist/utils/version.d.ts.map +1 -1
- package/dist/utils/version.js.map +1 -1
- package/package.json +13 -1
- package/src/git/cache.ts +142 -28
- package/src/git/models/commit.ts +1 -0
- package/src/git/models/reference.ts +33 -0
- package/src/git/models/remote.ts +1 -0
- package/src/git/models/repository.ts +21 -3
- package/src/git/models/search.ts +2 -2
- package/src/git/models/worktree.ts +10 -2
- package/src/git/parsers/diffParser.ts +2 -0
- package/src/git/providers/branches.ts +22 -4
- package/src/git/providers/config.ts +2 -0
- package/src/git/providers/operations.ts +44 -0
- package/src/git/providers/pausedOperations.ts +1 -0
- package/src/git/providers/refs.ts +32 -3
- package/src/git/providers/staging.ts +12 -0
- package/src/git/providers/status.ts +6 -1
- package/src/git/remotes/azure-devops.ts +2 -0
- package/src/git/{exec.types.ts → run.types.ts} +22 -2
- package/src/git/service.ts +1 -0
- package/src/git/utils/autolink.utils.ts +1 -0
- package/src/git/utils/blame.utils.ts +2 -0
- package/src/git/utils/conflictResolution.utils.ts +31 -0
- package/src/git/utils/fileStatus.utils.ts +7 -1
- package/src/git/utils/search.utils.ts +2 -0
- package/src/git/utils/sorting.ts +17 -0
- package/src/git/utils/status.utils.ts +1 -0
- package/src/git/watching/classifyChange.ts +9 -0
- package/src/git/watching/gitIgnoreFilter.ts +2 -2
- package/src/git/watching/initWatcher.ts +2 -0
- package/src/git/watching/watchGroup.ts +3 -0
- package/src/git/watching/watchService.ts +38 -5
- package/src/git/watching/watchSession.ts +10 -0
- package/src/git-cli/exec/exec.types.ts +2 -2
- package/src/git-cli/exec/git.ts +6 -5
- package/src/git-cli/exec/gitQueue.ts +41 -12
- package/src/git-cli/parsers/blameParser.ts +1 -0
- package/src/git-cli/parsers/logParser.ts +1 -0
- package/src/git-cli/parsers/refParser.ts +33 -34
- package/src/git-cli/providers/blame.ts +1 -0
- package/src/git-cli/providers/branches.ts +164 -93
- package/src/git-cli/providers/commits.ts +83 -37
- package/src/git-cli/providers/config.ts +41 -2
- package/src/git-cli/providers/diff.ts +8 -2
- package/src/git-cli/providers/graph.ts +11 -2
- package/src/git-cli/providers/operations.ts +186 -49
- package/src/git-cli/providers/patch.ts +1 -0
- package/src/git-cli/providers/pausedOperations.ts +8 -0
- package/src/git-cli/providers/refs.ts +247 -3
- package/src/git-cli/providers/revision.ts +2 -2
- package/src/git-cli/providers/staging.ts +33 -0
- package/src/git-cli/providers/status.ts +15 -4
- package/src/git-cli/providers/tags.ts +15 -16
- package/src/ipc/discovery.ts +56 -0
- package/src/ipc/ipcServer.ts +171 -0
- package/src/plus/agents/providers/claudeCodeProvider.ts +1782 -0
- package/src/plus/agents/providers/claudeCodeTranscript.ts +214 -0
- package/src/plus/agents/sanitizePrompt.ts +109 -0
- package/src/plus/agents/stateMachine.ts +197 -0
- package/src/plus/agents/types.ts +277 -0
- package/src/plus/ai/errors.ts +40 -0
- package/src/plus/ai/models/promptTemplates.ts +13 -0
- package/src/plus/ai/prompts.ts +49 -8
- package/src/plus/ai/utils/results.utils.ts +2 -0
- package/src/plus/git-github/api/github.ts +199 -53
- package/src/plus/git-github/api/types.ts +15 -0
- package/src/plus/git-github/models.ts +1 -1
- package/src/plus/git-github/providers/github/blame.ts +2 -0
- package/src/plus/git-github/providers/github/branches.ts +61 -31
- package/src/plus/git-github/providers/github/commits.ts +231 -160
- package/src/plus/git-github/providers/github/diff.ts +27 -19
- package/src/plus/git-github/providers/github/refs.ts +57 -22
- package/src/plus/git-github/providers/github/revision.ts +1 -2
- package/src/plus/git-github/providers/github/status.ts +6 -1
- package/src/plus/git-github/providers/github/tags.ts +61 -62
- package/src/plus/git-github/providers/githubGitProvider.ts +1 -0
- package/src/utils/color.ts +2 -0
- package/src/utils/decorators/serializable.ts +1 -0
- package/src/utils/dedupedAsyncCache.ts +74 -0
- package/src/utils/diff.ts +61 -0
- package/src/utils/disposable.ts +2 -0
- package/src/utils/env/node/exec.ts +2 -0
- package/src/utils/error.ts +1 -0
- package/src/utils/iterable.ts +3 -0
- package/src/utils/logger.ts +1 -0
- package/src/utils/lruMap.ts +29 -4
- package/src/utils/markdown.ts +1 -0
- package/src/utils/mru.ts +2 -0
- package/src/utils/path.ts +1 -0
- package/src/utils/promise.ts +22 -0
- package/src/utils/promiseCache.ts +24 -0
- package/src/utils/string.ts +2 -0
- package/src/utils/uri.ts +1 -0
- package/src/utils/version.ts +1 -0
- package/dist/git/exec.types.d.ts.map +0 -1
- package/dist/git/exec.types.js +0 -2
- package/dist/git/exec.types.js.map +0 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { IpcHandler } from '../../ipc/ipcServer.js';
|
|
2
|
+
import type { UnifiedDisposable } from '../../utils/disposable.js';
|
|
3
|
+
import type { Event } from '../../utils/event.js';
|
|
4
|
+
|
|
5
|
+
export const claudeCodeNonBlockingHookEvents = [
|
|
6
|
+
'SessionStart',
|
|
7
|
+
'SessionEnd',
|
|
8
|
+
'UserPromptSubmit',
|
|
9
|
+
'PreToolUse',
|
|
10
|
+
'PostToolUse',
|
|
11
|
+
'PostToolUseFailure',
|
|
12
|
+
'Notification',
|
|
13
|
+
'Stop',
|
|
14
|
+
'StopFailure',
|
|
15
|
+
'SubagentStart',
|
|
16
|
+
'SubagentStop',
|
|
17
|
+
'TeammateIdle',
|
|
18
|
+
'TaskCompleted',
|
|
19
|
+
'InstructionsLoaded',
|
|
20
|
+
'ConfigChange',
|
|
21
|
+
'WorktreeCreate',
|
|
22
|
+
'WorktreeRemove',
|
|
23
|
+
'PreCompact',
|
|
24
|
+
'PostCompact',
|
|
25
|
+
'Elicitation',
|
|
26
|
+
'ElicitationResult',
|
|
27
|
+
'PermissionDenied',
|
|
28
|
+
'CwdChanged',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
export const claudeCodeBlockingHookEvents = ['PermissionRequest'] as const;
|
|
32
|
+
|
|
33
|
+
export type ClaudeCodeHookEvent =
|
|
34
|
+
| (typeof claudeCodeNonBlockingHookEvents)[number]
|
|
35
|
+
| (typeof claudeCodeBlockingHookEvents)[number];
|
|
36
|
+
|
|
37
|
+
export type PermissionDecision = 'allow' | 'deny';
|
|
38
|
+
|
|
39
|
+
export type AgentSessionStatus =
|
|
40
|
+
| 'thinking'
|
|
41
|
+
| 'tool_use'
|
|
42
|
+
| 'responding'
|
|
43
|
+
| 'waiting'
|
|
44
|
+
| 'idle'
|
|
45
|
+
| 'compacting'
|
|
46
|
+
| 'permission_requested';
|
|
47
|
+
|
|
48
|
+
export type AgentSessionPhase = 'idle' | 'working' | 'waiting';
|
|
49
|
+
|
|
50
|
+
export function getPhaseForStatus(status: AgentSessionStatus): AgentSessionPhase {
|
|
51
|
+
switch (status) {
|
|
52
|
+
case 'thinking':
|
|
53
|
+
case 'tool_use':
|
|
54
|
+
case 'responding':
|
|
55
|
+
case 'compacting':
|
|
56
|
+
return 'working';
|
|
57
|
+
case 'waiting':
|
|
58
|
+
case 'permission_requested':
|
|
59
|
+
return 'waiting';
|
|
60
|
+
case 'idle':
|
|
61
|
+
return 'idle';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns whether the given phase represents an agent that is actively doing work or
|
|
67
|
+
* awaiting input (as opposed to fully idle). Uses an explicit allowlist so new phases
|
|
68
|
+
* default to "not active" rather than being silently treated as live.
|
|
69
|
+
*/
|
|
70
|
+
export function isActiveAgentPhase(phase: AgentSessionPhase): boolean {
|
|
71
|
+
return phase === 'working' || phase === 'waiting';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface PermissionSuggestion {
|
|
75
|
+
readonly type: string;
|
|
76
|
+
readonly tool?: string;
|
|
77
|
+
readonly rules?: readonly { readonly toolName: string; readonly ruleContent?: string }[];
|
|
78
|
+
readonly destination?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Classification of what the agent is awaiting input for. Drives kind-aware UI: action button
|
|
82
|
+
* labels, phase wording, and which payload field carries the body. Detected at the provider
|
|
83
|
+
* boundary from the tool name / event so webviews don't grow their own classifiers.
|
|
84
|
+
* - `tool`: a regular tool permission (Bash, Edit, Read, …) — body is `toolDescription`.
|
|
85
|
+
* - `plan`: ExitPlanMode — body is `planSummary`; `planFilePath` may link the written plan.
|
|
86
|
+
* - `question`: AskUserQuestion — body is `questionText`; `questionCount` describes the batch.
|
|
87
|
+
* - `elicitation`: MCP elicitation — body is just `toolName`; user must respond in-session. */
|
|
88
|
+
export type PendingPermissionKind = 'tool' | 'plan' | 'question' | 'elicitation';
|
|
89
|
+
|
|
90
|
+
export interface PendingPermission {
|
|
91
|
+
readonly kind: PendingPermissionKind;
|
|
92
|
+
readonly toolName: string;
|
|
93
|
+
readonly toolDescription: string;
|
|
94
|
+
readonly toolInputDescription?: string;
|
|
95
|
+
readonly suggestions?: readonly PermissionSuggestion[];
|
|
96
|
+
/** Plan-mode (`kind === 'plan'`): on-disk path of the plan markdown, when the agent wrote one. */
|
|
97
|
+
readonly planFilePath?: string;
|
|
98
|
+
/** Plan-mode: short summary extracted from the plan content (first heading or leading sentence). */
|
|
99
|
+
readonly planSummary?: string;
|
|
100
|
+
/** Question-mode (`kind === 'question'`): the leading question text. */
|
|
101
|
+
readonly questionText?: string;
|
|
102
|
+
/** Question-mode: total number of questions in the batch. */
|
|
103
|
+
readonly questionCount?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface AgentSession {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly providerId: string;
|
|
109
|
+
readonly providerName: string;
|
|
110
|
+
readonly name?: string;
|
|
111
|
+
readonly status: AgentSessionStatus;
|
|
112
|
+
readonly phase: AgentSessionPhase;
|
|
113
|
+
readonly statusDetail?: string;
|
|
114
|
+
readonly worktreePath?: string;
|
|
115
|
+
/** Common (parent) repo path shared by every worktree in this session's repo. Set together
|
|
116
|
+
* with `worktreePath` by `resolveGitInfo` — equal to `worktreePath` for a default-worktree
|
|
117
|
+
* session, otherwise the parent repo's common path. Use this for "same repo" identity
|
|
118
|
+
* checks; {@link workspacePath} is the matched workspace folder, not repo identity.
|
|
119
|
+
*
|
|
120
|
+
* `undefined` carries two meanings the host distinguishes internally (via the
|
|
121
|
+
* `gitInfoUnresolvable` bookkeeping flag) but consumers should treat identically: either
|
|
122
|
+
* "not yet resolved" (no probe completed) or "resolved but cwd is not inside any git repo".
|
|
123
|
+
* Either way, no repo identity is available — never attempt to `path.join`/`path.resolve`
|
|
124
|
+
* against it without an explicit `!= null` check. */
|
|
125
|
+
readonly commonPath?: string;
|
|
126
|
+
readonly pid?: number;
|
|
127
|
+
readonly lastActivity: Date;
|
|
128
|
+
readonly phaseSince: Date;
|
|
129
|
+
readonly isSubagent: boolean;
|
|
130
|
+
readonly parentId?: string;
|
|
131
|
+
readonly subagents?: readonly AgentSession[];
|
|
132
|
+
readonly pendingPermission?: PendingPermission;
|
|
133
|
+
/** The VS Code workspace folder containing the agent's cwd, or `undefined` if cwd is outside
|
|
134
|
+
* any open workspace folder. Used for `isInWorkspace` and "Open Folder" only — NOT for repo
|
|
135
|
+
* identity. For "what repo is this session in", use {@link commonPath}. */
|
|
136
|
+
readonly workspacePath?: string;
|
|
137
|
+
readonly cwd?: string;
|
|
138
|
+
readonly planFile?: string;
|
|
139
|
+
readonly isInWorkspace: boolean;
|
|
140
|
+
readonly lastPrompt?: string;
|
|
141
|
+
readonly firstPrompt?: string;
|
|
142
|
+
/** Absolute paths of files targeted by in-flight file-editing tool calls (Edit/Write/MultiEdit/
|
|
143
|
+
* NotebookEdit). Populated on PreToolUse, drained on PostToolUse/PermissionDenied, cleared on
|
|
144
|
+
* Stop/SessionEnd. Empty/undefined when no file-editing tool is active.
|
|
145
|
+
*
|
|
146
|
+
* Mutable array form so `Shape<AgentSession>` projects it as `string[]` (the `Shape<>` type
|
|
147
|
+
* mangles `readonly T[]` into a mapped object that loses its iterator). Treat as immutable. */
|
|
148
|
+
currentFiles?: string[];
|
|
149
|
+
/** Absolute paths of files the agent recently *read* (Read/NotebookRead). Populated on
|
|
150
|
+
* PreToolUse, drained on PostToolUse/PermissionDenied with the same cooldown as
|
|
151
|
+
* `currentFiles`. Distinct from `currentFiles` which tracks write-class tools so consumers can
|
|
152
|
+
* visualize "looking at" vs "working on" differently. Treat as immutable. */
|
|
153
|
+
currentReads?: string[];
|
|
154
|
+
/** `true` when the session was discovered via peer IPC sync (i.e. another GitLens window hosts
|
|
155
|
+
* the agent's hook flow and Claude Code extension panel). Locally-owned sessions leave this
|
|
156
|
+
* unset. The dispatcher uses this to route opens through the peer's IPC route + an OS-level
|
|
157
|
+
* window focus, since calling `claude-vscode.editor.open` in *our* extension only opens an
|
|
158
|
+
* inert local view that isn't connected to the live session running in the peer.
|
|
159
|
+
*
|
|
160
|
+
* Window-local: never serialized faithfully across the IPC wire. Each window decides locally
|
|
161
|
+
* based on how it received the session — `querySiblingWindowSessions` always overrides to
|
|
162
|
+
* `true` regardless of what the peer published. */
|
|
163
|
+
readonly isPeerOwned?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Titles discovered by tailing the Claude Code transcript JSONL at
|
|
166
|
+
* `~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl`. Populated by
|
|
167
|
+
* `ClaudeCodeTranscriptReader`; used by `getSessionDisplayName` as a fallback when no
|
|
168
|
+
* harness-supplied `name` is available. Last occurrence in the transcript wins per type.
|
|
169
|
+
*/
|
|
170
|
+
readonly transcriptTitles?: {
|
|
171
|
+
readonly custom?: string;
|
|
172
|
+
readonly ai?: string;
|
|
173
|
+
readonly agent?: string;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface AgentSessionProvider extends UnifiedDisposable {
|
|
178
|
+
readonly id: string;
|
|
179
|
+
readonly name: string;
|
|
180
|
+
readonly icon: string;
|
|
181
|
+
|
|
182
|
+
readonly onDidChangeSessions: Event<void>;
|
|
183
|
+
readonly sessions: readonly AgentSession[];
|
|
184
|
+
|
|
185
|
+
start(workspacePaths: string[]): void;
|
|
186
|
+
stop(): void;
|
|
187
|
+
updateWorkspacePaths?(workspacePaths: string[]): void;
|
|
188
|
+
|
|
189
|
+
/** Resolves a pending permission. Returns `true` when the resolve was routed (the local IPC
|
|
190
|
+
* owns the session's pending entry); `false` when no local entry exists (typically a peer-
|
|
191
|
+
* discovered session owned by another GitLens window). Callers use this to give the user
|
|
192
|
+
* feedback rather than a silent no-op. */
|
|
193
|
+
resolvePermission?(
|
|
194
|
+
sessionId: string,
|
|
195
|
+
decision: PermissionDecision,
|
|
196
|
+
updatedPermissions?: PermissionSuggestion[],
|
|
197
|
+
): boolean;
|
|
198
|
+
|
|
199
|
+
/** Asks the peer GitLens window that has `workspacePath` open (or any peer whose workspacePath
|
|
200
|
+
* contains, or is contained by, it) to open the given session in its Claude Code extension
|
|
201
|
+
* via the `agents/sessions/open` IPC route. Resolves to `true` when at least one peer claimed
|
|
202
|
+
* the workspace AND was reachable; `false` otherwise. Best-effort: never rejects. The boolean
|
|
203
|
+
* is currently a diagnostic signal only — the dispatcher fires this in parallel with
|
|
204
|
+
* `vscode.openFolder` and relies on VS Code's window-folder matching to focus the owning
|
|
205
|
+
* window (which works whether or not the peer runs GitLens). */
|
|
206
|
+
notifyPeerOpenSession?(workspacePath: string, sessionId: string): Promise<boolean>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Host-supplied IPC service. The agents package registers handlers and publishes
|
|
211
|
+
* the agents discovery file via this interface so it doesn't depend on the host's
|
|
212
|
+
* IPC service directly.
|
|
213
|
+
*
|
|
214
|
+
* The agents package is the source of truth for the workspacePaths advertised in
|
|
215
|
+
* the agents discovery file — `publishAgents` takes them as an argument and the host
|
|
216
|
+
* is expected to re-publish whenever those paths change.
|
|
217
|
+
*/
|
|
218
|
+
export interface IpcRegistrar {
|
|
219
|
+
readonly port: number | undefined;
|
|
220
|
+
/** Directory scanned for peer-window agent discovery files. Omit to disable peer discovery (tests). */
|
|
221
|
+
readonly agentDiscoveryDir?: string;
|
|
222
|
+
registerHandler<Request = unknown, Response = unknown>(
|
|
223
|
+
name: string,
|
|
224
|
+
handler: IpcHandler<Request, Response>,
|
|
225
|
+
): UnifiedDisposable;
|
|
226
|
+
publishAgents(workspacePaths: string[]): Promise<void>;
|
|
227
|
+
unpublishAgents(): Promise<void>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface AgentProviderCallbacks {
|
|
231
|
+
/** Host-supplied IPC service. Required for agents to receive hook events from the GK CLI. */
|
|
232
|
+
ipc: IpcRegistrar;
|
|
233
|
+
|
|
234
|
+
/** Report that an agent session started. No-op if the host has no telemetry. */
|
|
235
|
+
onSessionStarted?(provider: string): void;
|
|
236
|
+
|
|
237
|
+
/** Report that an agent session ended. No-op if the host has no telemetry. */
|
|
238
|
+
onSessionEnded?(provider: string): void;
|
|
239
|
+
|
|
240
|
+
/** Report that a permission request was resolved. No-op if the host has no telemetry. */
|
|
241
|
+
onPermissionResolved?(info: { provider: string; tool: string; decision: PermissionDecision }): void;
|
|
242
|
+
|
|
243
|
+
/** Notify the host that a branch has agent activity. */
|
|
244
|
+
onBranchAgentActivity?(cwd: string): void;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Run the GK CLI with the given args. Returns stdout.
|
|
248
|
+
*
|
|
249
|
+
* Host responsibilities:
|
|
250
|
+
* - Resolve the CLI executable path (e.g. via `resolveCLIExecutable`)
|
|
251
|
+
* - Provide the default `cwd` if `options.cwd` is not set (e.g. `globalStorageUri.fsPath` in VS Code)
|
|
252
|
+
* - Inject any environment-specific flags (e.g. `--insiders` when the host has insiders mode enabled)
|
|
253
|
+
*/
|
|
254
|
+
runCLICommand(args: string[], options?: { cwd?: string }): Promise<string>;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Resolve git metadata for a session's cwd. Returns the stable worktree path; the worktree's
|
|
258
|
+
* display name (branch name for branch-type worktrees) is intentionally NOT returned — it's
|
|
259
|
+
* resolved live at serialization time so `git checkout` updates display without restarting.
|
|
260
|
+
* Optional — if omitted, sessions won't have worktree metadata.
|
|
261
|
+
*/
|
|
262
|
+
resolveGitInfo?(cwd: string): Promise<
|
|
263
|
+
| {
|
|
264
|
+
repoRoot: string;
|
|
265
|
+
isWorktree: boolean;
|
|
266
|
+
worktreePath?: string;
|
|
267
|
+
}
|
|
268
|
+
| undefined
|
|
269
|
+
>;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Open a Claude Code session in the Claude Code VS Code extension. Invoked by the IPC handler
|
|
273
|
+
* when a peer GitLens window asks this window to open a session on its behalf — the host wires
|
|
274
|
+
* this to `claude-vscode.editor.open`. Throws if the extension isn't installed/active.
|
|
275
|
+
*/
|
|
276
|
+
openSessionInClaudeExtension?(sessionId: string): Promise<void>;
|
|
277
|
+
}
|
package/src/plus/ai/errors.ts
CHANGED
|
@@ -10,6 +10,8 @@ export const enum AIErrorReason {
|
|
|
10
10
|
ServiceCapacityExceeded,
|
|
11
11
|
Unauthorized,
|
|
12
12
|
UserQuotaExceeded,
|
|
13
|
+
NoNetwork,
|
|
14
|
+
Unreachable,
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export class AIError extends Error {
|
|
@@ -37,6 +39,12 @@ export class AIError extends Error {
|
|
|
37
39
|
case AIErrorReason.ServiceCapacityExceeded:
|
|
38
40
|
message = 'Service capacity exceeded';
|
|
39
41
|
break;
|
|
42
|
+
case AIErrorReason.NoNetwork:
|
|
43
|
+
message = 'Unable to reach the AI service. Please check your internet connection.';
|
|
44
|
+
break;
|
|
45
|
+
case AIErrorReason.Unreachable:
|
|
46
|
+
message = 'The AI service is temporarily unreachable.';
|
|
47
|
+
break;
|
|
40
48
|
case AIErrorReason.NoRequestData:
|
|
41
49
|
message = original?.message ?? 'No data was provided for the request';
|
|
42
50
|
break;
|
|
@@ -80,3 +88,35 @@ export class AINoRequestDataError extends AIError {
|
|
|
80
88
|
Error.captureStackTrace?.(this, new.target);
|
|
81
89
|
}
|
|
82
90
|
}
|
|
91
|
+
|
|
92
|
+
const noNetworkErrorCodes = new Set([
|
|
93
|
+
'ENOTFOUND',
|
|
94
|
+
'ECONNREFUSED',
|
|
95
|
+
'EAI_AGAIN',
|
|
96
|
+
'EHOSTUNREACH',
|
|
97
|
+
'ENETUNREACH',
|
|
98
|
+
'ENETDOWN',
|
|
99
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
const unreachableErrorCodes = new Set(['ECONNRESET', 'ETIMEDOUT', 'UND_ERR_SOCKET']);
|
|
103
|
+
|
|
104
|
+
export function classifyNetworkError(ex: unknown): AIErrorReason.NoNetwork | AIErrorReason.Unreachable | undefined {
|
|
105
|
+
let current: unknown = ex;
|
|
106
|
+
let sawFetchFailed = false;
|
|
107
|
+
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
108
|
+
if (!(current instanceof Error)) break;
|
|
109
|
+
|
|
110
|
+
if (current.name === 'TypeError' && current.message === 'fetch failed') {
|
|
111
|
+
sawFetchFailed = true;
|
|
112
|
+
}
|
|
113
|
+
const code = (current as { code?: unknown }).code;
|
|
114
|
+
if (typeof code === 'string') {
|
|
115
|
+
if (noNetworkErrorCodes.has(code)) return AIErrorReason.NoNetwork;
|
|
116
|
+
if (unreachableErrorCodes.has(code)) return AIErrorReason.Unreachable;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
current = (current as { cause?: unknown }).cause;
|
|
120
|
+
}
|
|
121
|
+
return sawFetchFailed ? AIErrorReason.NoNetwork : undefined;
|
|
122
|
+
}
|
|
@@ -81,12 +81,14 @@ interface ReviewPullRequestPromptTemplateContext {
|
|
|
81
81
|
interface ReviewChangesPromptTemplateContext {
|
|
82
82
|
diff: string;
|
|
83
83
|
message: string;
|
|
84
|
+
context?: string;
|
|
84
85
|
instructions?: string;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
interface ReviewOverviewPromptTemplateContext {
|
|
88
89
|
files: string;
|
|
89
90
|
message: string;
|
|
91
|
+
context?: string;
|
|
90
92
|
instructions?: string;
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -95,6 +97,14 @@ interface ReviewDetailPromptTemplateContext {
|
|
|
95
97
|
overview: string;
|
|
96
98
|
message: string;
|
|
97
99
|
focusArea: string;
|
|
100
|
+
context?: string;
|
|
101
|
+
instructions?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface AddressReviewFindingsPromptTemplateContext {
|
|
105
|
+
reviewMarkdown: string;
|
|
106
|
+
scopeLabel: string;
|
|
107
|
+
granularity: 'review' | 'focusArea' | 'finding';
|
|
98
108
|
instructions?: string;
|
|
99
109
|
}
|
|
100
110
|
|
|
@@ -114,6 +124,7 @@ export type PromptTemplateType =
|
|
|
114
124
|
| 'review-changes'
|
|
115
125
|
| 'review-overview'
|
|
116
126
|
| 'review-detail'
|
|
127
|
+
| 'address-review-findings'
|
|
117
128
|
| 'start-review-pullRequest'
|
|
118
129
|
| 'start-work-issue';
|
|
119
130
|
|
|
@@ -144,6 +155,8 @@ export type PromptTemplateContext<T extends PromptTemplateType> = T extends 'gen
|
|
|
144
155
|
? ReviewOverviewPromptTemplateContext
|
|
145
156
|
: T extends 'review-detail'
|
|
146
157
|
? ReviewDetailPromptTemplateContext
|
|
158
|
+
: T extends 'address-review-findings'
|
|
159
|
+
? AddressReviewFindingsPromptTemplateContext
|
|
147
160
|
: T extends 'start-review-pullRequest'
|
|
148
161
|
? ReviewPullRequestPromptTemplateContext
|
|
149
162
|
: T extends 'start-work-issue'
|
package/src/plus/ai/prompts.ts
CHANGED
|
@@ -350,7 +350,7 @@ Available search operators:
|
|
|
350
350
|
- 'commit:' - Search by a specific commit SHA (e.g. 'commit:4ce3a')
|
|
351
351
|
- 'file:' - Search by file path (e.g. 'file:"package.json"', 'file:"*.ts"'); maps to \`git log -- <value>\`
|
|
352
352
|
- 'change:' - Search by specific code changes using regular expressions (e.g. 'change:"function.*auth"', 'change:"import.*react"'); maps to \`git log -G<value>\`
|
|
353
|
-
- 'type:' - Search by type -- supports stash and
|
|
353
|
+
- 'type:' - Search by type -- supports stash, tip, and wip (e.g. 'type:stash', 'type:tip', 'type:wip'). Use 'type:wip' for queries about work in progress, uncommitted changes, or pending changes across worktrees.
|
|
354
354
|
- 'ref:' - Search for commits reachable by a reference (branch, tag, commit) or reference range. Supports single refs (e.g. 'ref:main', 'ref:v1.0'), two-dot ranges (e.g. 'ref:main..feature' for commits in feature but not in main), three-dot ranges (e.g. 'ref:main...feature' for symmetric difference), and relative refs (e.g. 'ref:HEAD~5..HEAD'); maps to \`git log <ref>\`
|
|
355
355
|
- 'after:' - Search for commits after a certain date or range (e.g. 'after:2023-01-01', 'after:"6 months ago"', 'after:"last Tuesday"', 'after:"noon"', 'after:"1 month 2 days ago"'); maps to \`git log --since=<value>\`
|
|
356
356
|
- 'before:' - Search for commits before a certain date or range (e.g. 'before:2023-01-01', 'before:"6 months ago"', 'before:"yesterday"', 'before:"3PM GMT"'); maps to \`git log --until=<value>\`
|
|
@@ -529,10 +529,14 @@ Now, proceed with your analysis and provide a comprehensive review of the PR. Re
|
|
|
529
529
|
|
|
530
530
|
export const reviewChanges: PromptTemplate<'review-changes'> = {
|
|
531
531
|
id: 'review-changes',
|
|
532
|
-
variables: ['diff', 'message', 'instructions'],
|
|
532
|
+
variables: ['diff', 'message', 'context', 'instructions'],
|
|
533
533
|
template: `You are an expert code reviewer analyzing a set of code changes. Your goal is to identify meaningful issues — bugs, logic errors, security vulnerabilities, missing error handling, and potential regressions — while ignoring style preferences and linter-level concerns. Focus on problems a careful human reviewer would catch.
|
|
534
534
|
|
|
535
|
-
Examine the following code changes in Git diff format:
|
|
535
|
+
Examine the following code changes in Git diff format. Each non-header line inside a hunk has been annotated with its 1-based new-file line number in a \`[NNNNN]\` block placed immediately after the line-type marker (\` \`, \`+\`, or \`-\`):
|
|
536
|
+
\` [ 42] context line\` // context: exists in both old and new; number = new-file line
|
|
537
|
+
\`+[ 43] added line\` // added: only in new file; number = new-file line
|
|
538
|
+
\`-[ ] removed line\` // removed: not in new file; brackets are blank
|
|
539
|
+
\`@@ -10,5 +12,7 @@ ...\` // hunk header (no annotation; ignore for line citing)
|
|
536
540
|
<~~diff~~>
|
|
537
541
|
\${diff}
|
|
538
542
|
</~~diff~~>
|
|
@@ -542,6 +546,9 @@ Author's description of the changes:
|
|
|
542
546
|
\${message}
|
|
543
547
|
</~~message~~>
|
|
544
548
|
|
|
549
|
+
Related work items (known pull requests and issues for this change set). Use these for *intent*: what the change is trying to accomplish. They are not authoritative spec — if a finding contradicts the stated intent, flag it rather than defer to it. May be empty.
|
|
550
|
+
\${context}
|
|
551
|
+
|
|
545
552
|
Produce a structured review in the following XML format. Include ONLY the XML tags described — no other text:
|
|
546
553
|
|
|
547
554
|
<overview>
|
|
@@ -565,7 +572,7 @@ Guidelines:
|
|
|
565
572
|
- Group related findings into focus areas by theme, not by file
|
|
566
573
|
- If changes look correct and well-structured, say so in the overview and include zero focus areas
|
|
567
574
|
- 3-5 high-quality findings are better than 15 low-quality ones
|
|
568
|
-
-
|
|
575
|
+
- For \`lines="start-end"\`, copy the numbers from the \`[NNNNN]\` annotations of the specific lines your finding concerns. Do not count, infer, or estimate — use only the annotated numbers. Removed lines (blank brackets \`[ ]\`) cannot be cited; pick the nearest surrounding new-file line instead. Anchor the range tightly to the lines the finding actually concerns; do not span an entire hunk.
|
|
569
576
|
- Do not flag style issues, naming preferences, or things a linter would catch
|
|
570
577
|
- Base conclusions only on the code shown — do not speculate about unseen code
|
|
571
578
|
|
|
@@ -576,7 +583,7 @@ Review the changes and produce the structured XML output above.`,
|
|
|
576
583
|
|
|
577
584
|
export const reviewOverview: PromptTemplate<'review-overview'> = {
|
|
578
585
|
id: 'review-overview',
|
|
579
|
-
variables: ['files', 'message', 'instructions'],
|
|
586
|
+
variables: ['files', 'message', 'context', 'instructions'],
|
|
580
587
|
template: `You are an expert code reviewer performing an initial assessment of a set of code changes. You are given a file manifest (not full diffs) — use the file paths, change types, and line counts to identify which areas deserve closer inspection.
|
|
581
588
|
|
|
582
589
|
File manifest (JSON array of changed files):
|
|
@@ -589,6 +596,9 @@ Author's description of the changes:
|
|
|
589
596
|
\${message}
|
|
590
597
|
</~~message~~>
|
|
591
598
|
|
|
599
|
+
Related work items (known pull requests and issues for this change set). Use these for *intent* — what the change is trying to accomplish — when ranking which areas deserve closer review. May be empty.
|
|
600
|
+
\${context}
|
|
601
|
+
|
|
592
602
|
Produce a structured assessment in the following XML format. Include ONLY the XML tags described — no other text:
|
|
593
603
|
|
|
594
604
|
<overview>
|
|
@@ -613,9 +623,33 @@ Guidelines:
|
|
|
613
623
|
Assess the changes and produce the structured XML output above.`,
|
|
614
624
|
};
|
|
615
625
|
|
|
626
|
+
export const addressReviewFindings: PromptTemplate<'address-review-findings'> = {
|
|
627
|
+
id: 'address-review-findings',
|
|
628
|
+
variables: ['reviewMarkdown', 'scopeLabel', 'granularity', 'instructions'],
|
|
629
|
+
template: `You are an AI coding agent tasked with addressing the issues identified in a code review. Your goal is to understand each finding and, where appropriate, propose or make the code changes needed to fix it.
|
|
630
|
+
|
|
631
|
+
The review was performed against: \${scopeLabel}
|
|
632
|
+
|
|
633
|
+
The findings are provided as structured markdown below. Each finding includes a severity (\`**[CRITICAL]**\`, \`**[WARNING]**\`, or \`**[SUGGESTION]**\`), a short title, a description of the problem, and (when available) a file path and line range. Focus areas group related findings and include a rationale explaining why they matter.
|
|
634
|
+
|
|
635
|
+
<review>
|
|
636
|
+
\${reviewMarkdown}
|
|
637
|
+
</review>
|
|
638
|
+
|
|
639
|
+
Guidelines:
|
|
640
|
+
- Treat the findings as a working list. Prioritize critical issues, then warnings, then suggestions.
|
|
641
|
+
- For each finding, locate the referenced file(s) in the workspace before proposing a fix. If the file or line range no longer matches the review (the code may have evolved), reconcile against the current state.
|
|
642
|
+
- When making code changes, address the underlying problem the finding describes — do not just paper over symptoms.
|
|
643
|
+
- Prefer minimal, focused edits that don't introduce unrelated changes.
|
|
644
|
+
- If a finding is ambiguous, contradicts the surrounding code's intent, or is already addressed in the current state, say so explicitly rather than fabricating a fix.
|
|
645
|
+
- If a finding is out of scope (touches unrelated systems, requires significant refactoring, or contradicts established patterns), surface that as a tradeoff rather than acting on it.
|
|
646
|
+
|
|
647
|
+
\${instructions}`,
|
|
648
|
+
};
|
|
649
|
+
|
|
616
650
|
export const reviewDetail: PromptTemplate<'review-detail'> = {
|
|
617
651
|
id: 'review-detail',
|
|
618
|
-
variables: ['diff', 'overview', 'message', 'focusArea', 'instructions'],
|
|
652
|
+
variables: ['diff', 'overview', 'message', 'focusArea', 'context', 'instructions'],
|
|
619
653
|
template: `You are an expert code reviewer performing a detailed inspection of specific files that were flagged for closer review. You have the context from an initial overview assessment.
|
|
620
654
|
|
|
621
655
|
Initial overview of the full changeset:
|
|
@@ -630,7 +664,14 @@ Author's description of the changes:
|
|
|
630
664
|
\${message}
|
|
631
665
|
</~~message~~>
|
|
632
666
|
|
|
633
|
-
|
|
667
|
+
Related work items (known pull requests and issues for this change set). Use these for *intent* — what the change is trying to accomplish. They are not authoritative spec; if a finding contradicts the stated intent, flag it. May be empty.
|
|
668
|
+
\${context}
|
|
669
|
+
|
|
670
|
+
Code changes for the files in this focus area (Git diff format). Each non-header line inside a hunk has been annotated with its 1-based new-file line number in a \`[NNNNN]\` block placed immediately after the line-type marker (\` \`, \`+\`, or \`-\`):
|
|
671
|
+
\` [ 42] context line\` // context: exists in both old and new; number = new-file line
|
|
672
|
+
\`+[ 43] added line\` // added: only in new file; number = new-file line
|
|
673
|
+
\`-[ ] removed line\` // removed: not in new file; brackets are blank
|
|
674
|
+
\`@@ -10,5 +12,7 @@ ...\` // hunk header (no annotation; ignore for line citing)
|
|
634
675
|
<~~diff~~>
|
|
635
676
|
\${diff}
|
|
636
677
|
</~~diff~~>
|
|
@@ -646,7 +687,7 @@ Produce detailed findings in the following XML format. Include ONLY the XML tags
|
|
|
646
687
|
|
|
647
688
|
Guidelines:
|
|
648
689
|
- Severity: "critical" = bugs, security, data loss; "warning" = logic concerns, error handling, regressions; "suggestion" = improvements, maintainability
|
|
649
|
-
-
|
|
690
|
+
- For \`lines="start-end"\`, copy the numbers from the \`[NNNNN]\` annotations of the specific lines your finding concerns. Do not count, infer, or estimate — use only the annotated numbers. Removed lines (blank brackets \`[ ]\`) cannot be cited; pick the nearest surrounding new-file line instead. Anchor the range tightly to the lines the finding actually concerns; do not span an entire hunk.
|
|
650
691
|
- Be concrete — explain what the problem is and how to fix it
|
|
651
692
|
- If the code in this area looks correct, return an empty <findings></findings> block
|
|
652
693
|
- Do not flag style issues or things a linter would catch
|
|
@@ -78,9 +78,11 @@ function parseSeverity(value: string | undefined): AIReviewSeverity {
|
|
|
78
78
|
|
|
79
79
|
function parseLineRange(value: string | undefined): { start: number; end: number } | undefined {
|
|
80
80
|
if (!value) return undefined;
|
|
81
|
+
|
|
81
82
|
const parts = value.split('-');
|
|
82
83
|
const start = parseInt(parts[0], 10);
|
|
83
84
|
if (isNaN(start)) return undefined;
|
|
85
|
+
|
|
84
86
|
const end = parts.length > 1 ? parseInt(parts[1], 10) : start;
|
|
85
87
|
return { start: start, end: isNaN(end) ? start : end };
|
|
86
88
|
}
|