@theia/ai-terminal 1.59.0 → 1.60.0-next.47
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/lib/browser/ai-terminal-agent.d.ts.map +1 -1
- package/lib/browser/ai-terminal-agent.js +2 -63
- package/lib/browser/ai-terminal-agent.js.map +1 -1
- package/lib/browser/ai-terminal-prompt-template.d.ts +7 -0
- package/lib/browser/ai-terminal-prompt-template.d.ts.map +1 -0
- package/lib/browser/ai-terminal-prompt-template.js +80 -0
- package/lib/browser/ai-terminal-prompt-template.js.map +1 -0
- package/package.json +6 -6
- package/src/browser/ai-terminal-agent.ts +2 -63
- package/src/browser/ai-terminal-prompt-template.ts +78 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-terminal-agent.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,EACL,6BAA6B,EAG7B,qBAAqB,EAAE,wBAAwB,EAC/C,aAAa,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAgB,OAAO,EAAO,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-terminal-agent.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,EACL,6BAA6B,EAG7B,qBAAqB,EAAE,wBAAwB,EAC/C,aAAa,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAgB,OAAO,EAAO,MAAM,aAAa,CAAC;AAWzD,qBACa,eAAgB,YAAW,KAAK;IAEzC,SAAS,CAAC,gBAAgB,EAAE,6BAA6B,CAAC;IAE1D,EAAE,SAAwB;IAC1B,IAAI,SAAwB;IAC5B,WAAW,SAEqI;IAChJ,SAAS,UAAM;IACf,SAAS,UAAM;IACf,sBAAsB;;;;QAKpB;IACF,eAAe;;;;;QAA2B;IAC1C,yBAAyB,EAAE,wBAAwB,EAAE,CAKnD;IAGF,SAAS,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAGvD,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAGvC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAEpB,WAAW,CACb,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,sBAAsB,EAAE,MAAM,EAAE,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC;CAsFvB"}
|
|
@@ -19,6 +19,7 @@ exports.AiTerminalAgent = void 0;
|
|
|
19
19
|
const tslib_1 = require("tslib");
|
|
20
20
|
const common_1 = require("@theia/ai-core/lib/common");
|
|
21
21
|
const core_1 = require("@theia/core");
|
|
22
|
+
const ai_terminal_prompt_template_1 = require("./ai-terminal-prompt-template");
|
|
22
23
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
23
24
|
const zod_1 = require("zod");
|
|
24
25
|
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
@@ -40,69 +41,7 @@ let AiTerminalAgent = class AiTerminalAgent {
|
|
|
40
41
|
{ name: 'cwd', usedInPrompt: true, description: 'The current working directory.' },
|
|
41
42
|
{ name: 'recentTerminalContents', usedInPrompt: true, description: 'The last 0 to 50 recent lines visible in the terminal.' }
|
|
42
43
|
];
|
|
43
|
-
this.promptTemplates =
|
|
44
|
-
{
|
|
45
|
-
id: 'terminal-system',
|
|
46
|
-
name: 'AI Terminal System Prompt',
|
|
47
|
-
description: core_1.nls.localize('theia/ai/terminal/systemPrompt/description', 'Prompt for the AI Terminal Assistant'),
|
|
48
|
-
template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
49
|
-
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
50
|
-
# Instructions
|
|
51
|
-
Generate one or more command suggestions based on the user's request, considering the shell being used,
|
|
52
|
-
the current working directory, and the recent terminal contents. Provide the best suggestion first,
|
|
53
|
-
followed by other relevant suggestions if the user asks for further options.
|
|
54
|
-
|
|
55
|
-
Parameters:
|
|
56
|
-
- user-request: The user's question or request.
|
|
57
|
-
- shell: The shell being used, e.g., /usr/bin/zsh.
|
|
58
|
-
- cwd: The current working directory.
|
|
59
|
-
- recent-terminal-contents: The last 0 to 50 recent lines visible in the terminal.
|
|
60
|
-
|
|
61
|
-
Return the result in the following JSON format:
|
|
62
|
-
{
|
|
63
|
-
"commands": [
|
|
64
|
-
"best_command_suggestion",
|
|
65
|
-
"next_best_command_suggestion",
|
|
66
|
-
"another_command_suggestion"
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
## Example
|
|
71
|
-
user-request: "How do I commit changes?"
|
|
72
|
-
shell: "/usr/bin/zsh"
|
|
73
|
-
cwd: "/home/user/project"
|
|
74
|
-
recent-terminal-contents:
|
|
75
|
-
git status
|
|
76
|
-
On branch main
|
|
77
|
-
Your branch is up to date with 'origin/main'.
|
|
78
|
-
nothing to commit, working tree clean
|
|
79
|
-
|
|
80
|
-
## Expected JSON output
|
|
81
|
-
\`\`\`json
|
|
82
|
-
\{
|
|
83
|
-
"commands": [
|
|
84
|
-
"git commit",
|
|
85
|
-
"git commit --amend",
|
|
86
|
-
"git commit -a"
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
\`\`\`
|
|
90
|
-
`
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'terminal-user',
|
|
94
|
-
name: 'AI Terminal User Prompt',
|
|
95
|
-
description: core_1.nls.localize('theia/ai/terminal/userPrompt/description', 'Prompt that contains the user request'),
|
|
96
|
-
template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
97
|
-
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
98
|
-
user-request: {{userRequest}}
|
|
99
|
-
shell: {{shell}}
|
|
100
|
-
cwd: {{cwd}}
|
|
101
|
-
recent-terminal-contents:
|
|
102
|
-
{{recentTerminalContents}}
|
|
103
|
-
`
|
|
104
|
-
}
|
|
105
|
-
];
|
|
44
|
+
this.promptTemplates = ai_terminal_prompt_template_1.terminalPromptTemplates;
|
|
106
45
|
this.languageModelRequirements = [
|
|
107
46
|
{
|
|
108
47
|
purpose: 'suggest-terminal-commands',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-terminal-agent.js","sourceRoot":"","sources":["../../src/browser/ai-terminal-agent.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,sDAOmC;AACnC,sCAAyD;AACzD,4DAAkE;AAClE,6BAAwB;AACxB,2DAAiD;AAEjD,MAAM,QAAQ,GAAG,OAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CAAC;AAII,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QAIH,OAAE,GAAG,oBAAoB,CAAC;QAC1B,SAAI,GAAG,oBAAoB,CAAC;QAC5B,gBAAW,GAAG,UAAG,CAAC,QAAQ,CAAC,qCAAqC,EAAE;;kJAE4E,CAAC,CAAC;QAChJ,cAAS,GAAG,EAAE,CAAC;QACf,cAAS,GAAG,EAAE,CAAC;QACf,2BAAsB,GAAG;YACrB,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,kCAAkC,EAAE;YAC5F,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,2CAA2C,EAAE;YAC/F,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EA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C,CAAC;YACL,CAAC;YAED,6CAA6C;YAC7C,MAAM,UAAU,GAAG,MAAM,IAAA,0BAAiB,EAAC,MAAM,CAAC,CAAC;YACnD,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC,CAAC;YACjH,MAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1C,CAAC;YAED,OAAO,EAAE,CAAC;QAEd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;YACrE,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CAEJ,CAAA;AA7HY,0CAAe;AAEd;IADT,IAAA,kBAAM,EAAC,sCAA6B,CAAC;;yDACoB;AAwBhD;IADT,IAAA,kBAAM,EAAC,8BAAqB,CAAC;;8DACyB;AAG7C;IADT,IAAA,kBAAM,EAAC,sBAAa,CAAC;;sDACiB;AAG7B;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;+CACU;0BAhCjB,eAAe;IAD3B,IAAA,sBAAU,GAAE;GACA,eAAe,CA6H3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-terminal-prompt-template.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-prompt-template.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,uBAAuB;;;;;GAgEnC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/tslint/config */
|
|
3
|
+
// *****************************************************************************
|
|
4
|
+
// Copyright (C) 2025 EclipseSource GmbH and others.
|
|
5
|
+
//
|
|
6
|
+
// This file is licensed under the MIT License.
|
|
7
|
+
// See LICENSE-MIT.txt in the project root for license information.
|
|
8
|
+
// https://opensource.org/license/mit.
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: MIT
|
|
11
|
+
// *****************************************************************************
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.terminalPromptTemplates = void 0;
|
|
14
|
+
const core_1 = require("@theia/core");
|
|
15
|
+
exports.terminalPromptTemplates = [
|
|
16
|
+
{
|
|
17
|
+
id: 'terminal-system',
|
|
18
|
+
name: 'AI Terminal System Prompt',
|
|
19
|
+
description: core_1.nls.localize('theia/ai/terminal/systemPrompt/description', 'Prompt for the AI Terminal Assistant'),
|
|
20
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
21
|
+
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
22
|
+
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
23
|
+
# Instructions
|
|
24
|
+
Generate one or more command suggestions based on the user's request, considering the shell being used,
|
|
25
|
+
the current working directory, and the recent terminal contents. Provide the best suggestion first,
|
|
26
|
+
followed by other relevant suggestions if the user asks for further options.
|
|
27
|
+
|
|
28
|
+
Parameters:
|
|
29
|
+
- user-request: The user's question or request.
|
|
30
|
+
- shell: The shell being used, e.g., /usr/bin/zsh.
|
|
31
|
+
- cwd: The current working directory.
|
|
32
|
+
- recent-terminal-contents: The last 0 to 50 recent lines visible in the terminal.
|
|
33
|
+
|
|
34
|
+
Return the result in the following JSON format:
|
|
35
|
+
{
|
|
36
|
+
"commands": [
|
|
37
|
+
"best_command_suggestion",
|
|
38
|
+
"next_best_command_suggestion",
|
|
39
|
+
"another_command_suggestion"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
## Example
|
|
44
|
+
user-request: "How do I commit changes?"
|
|
45
|
+
shell: "/usr/bin/zsh"
|
|
46
|
+
cwd: "/home/user/project"
|
|
47
|
+
recent-terminal-contents:
|
|
48
|
+
git status
|
|
49
|
+
On branch main
|
|
50
|
+
Your branch is up to date with 'origin/main'.
|
|
51
|
+
nothing to commit, working tree clean
|
|
52
|
+
|
|
53
|
+
## Expected JSON output
|
|
54
|
+
\`\`\`json
|
|
55
|
+
\{
|
|
56
|
+
"commands": [
|
|
57
|
+
"git commit",
|
|
58
|
+
"git commit --amend",
|
|
59
|
+
"git commit -a"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
\`\`\`
|
|
63
|
+
`
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'terminal-user',
|
|
67
|
+
name: 'AI Terminal User Prompt',
|
|
68
|
+
description: core_1.nls.localize('theia/ai/terminal/userPrompt/description', 'Prompt that contains the user request'),
|
|
69
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
70
|
+
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
71
|
+
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
72
|
+
user-request: {{userRequest}}
|
|
73
|
+
shell: {{shell}}
|
|
74
|
+
cwd: {{cwd}}
|
|
75
|
+
recent-terminal-contents:
|
|
76
|
+
{{recentTerminalContents}}
|
|
77
|
+
`
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
//# sourceMappingURL=ai-terminal-prompt-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-terminal-prompt-template.js","sourceRoot":"","sources":["../../src/browser/ai-terminal-prompt-template.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,+CAA+C;AAC/C,mEAAmE;AACnE,sCAAsC;AACtC,EAAE;AACF,+BAA+B;AAC/B,gFAAgF;;;AAEhF,sCAAkC;AAErB,QAAA,uBAAuB,GAAG;IACrC;QACE,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAE,2BAA2B;QACjC,WAAW,EAAE,UAAG,CAAC,QAAQ,CAAC,4CAA4C,EAAE,sCAAsC,CAAC;QAC/G,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cb;KACE;IACD;QACE,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,UAAG,CAAC,QAAQ,CAAC,0CAA0C,EAAE,uCAAuC,CAAC;QAC9G,QAAQ,EAAE;;;;;;;;CAQb;KACE;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-terminal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.60.0-next.47+9332521b9",
|
|
4
4
|
"description": "Theia - AI Terminal Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-chat": "1.
|
|
7
|
-
"@theia/ai-core": "1.
|
|
8
|
-
"@theia/core": "1.
|
|
9
|
-
"@theia/terminal": "1.
|
|
6
|
+
"@theia/ai-chat": "1.60.0-next.47+9332521b9",
|
|
7
|
+
"@theia/ai-core": "1.60.0-next.47+9332521b9",
|
|
8
|
+
"@theia/core": "1.60.0-next.47+9332521b9",
|
|
9
|
+
"@theia/terminal": "1.60.0-next.47+9332521b9",
|
|
10
10
|
"zod": "^3.23.8",
|
|
11
11
|
"zod-to-json-schema": "^3.23.2"
|
|
12
12
|
},
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"nyc": {
|
|
49
49
|
"extends": "../../configs/nyc.json"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9332521b9aa74bf534d45968905d37e30a13c3b5"
|
|
52
52
|
}
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
PromptService
|
|
24
24
|
} from '@theia/ai-core/lib/common';
|
|
25
25
|
import { generateUuid, ILogger, nls } from '@theia/core';
|
|
26
|
+
import { terminalPromptTemplates } from './ai-terminal-prompt-template';
|
|
26
27
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
27
28
|
import { z } from 'zod';
|
|
28
29
|
import zodToJsonSchema from 'zod-to-json-schema';
|
|
@@ -50,69 +51,7 @@ export class AiTerminalAgent implements Agent {
|
|
|
50
51
|
{ name: 'cwd', usedInPrompt: true, description: 'The current working directory.' },
|
|
51
52
|
{ name: 'recentTerminalContents', usedInPrompt: true, description: 'The last 0 to 50 recent lines visible in the terminal.' }
|
|
52
53
|
];
|
|
53
|
-
promptTemplates =
|
|
54
|
-
{
|
|
55
|
-
id: 'terminal-system',
|
|
56
|
-
name: 'AI Terminal System Prompt',
|
|
57
|
-
description: nls.localize('theia/ai/terminal/systemPrompt/description', 'Prompt for the AI Terminal Assistant'),
|
|
58
|
-
template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
59
|
-
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
60
|
-
# Instructions
|
|
61
|
-
Generate one or more command suggestions based on the user's request, considering the shell being used,
|
|
62
|
-
the current working directory, and the recent terminal contents. Provide the best suggestion first,
|
|
63
|
-
followed by other relevant suggestions if the user asks for further options.
|
|
64
|
-
|
|
65
|
-
Parameters:
|
|
66
|
-
- user-request: The user's question or request.
|
|
67
|
-
- shell: The shell being used, e.g., /usr/bin/zsh.
|
|
68
|
-
- cwd: The current working directory.
|
|
69
|
-
- recent-terminal-contents: The last 0 to 50 recent lines visible in the terminal.
|
|
70
|
-
|
|
71
|
-
Return the result in the following JSON format:
|
|
72
|
-
{
|
|
73
|
-
"commands": [
|
|
74
|
-
"best_command_suggestion",
|
|
75
|
-
"next_best_command_suggestion",
|
|
76
|
-
"another_command_suggestion"
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
## Example
|
|
81
|
-
user-request: "How do I commit changes?"
|
|
82
|
-
shell: "/usr/bin/zsh"
|
|
83
|
-
cwd: "/home/user/project"
|
|
84
|
-
recent-terminal-contents:
|
|
85
|
-
git status
|
|
86
|
-
On branch main
|
|
87
|
-
Your branch is up to date with 'origin/main'.
|
|
88
|
-
nothing to commit, working tree clean
|
|
89
|
-
|
|
90
|
-
## Expected JSON output
|
|
91
|
-
\`\`\`json
|
|
92
|
-
\{
|
|
93
|
-
"commands": [
|
|
94
|
-
"git commit",
|
|
95
|
-
"git commit --amend",
|
|
96
|
-
"git commit -a"
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
\`\`\`
|
|
100
|
-
`
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: 'terminal-user',
|
|
104
|
-
name: 'AI Terminal User Prompt',
|
|
105
|
-
description: nls.localize('theia/ai/terminal/userPrompt/description', 'Prompt that contains the user request'),
|
|
106
|
-
template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
107
|
-
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
108
|
-
user-request: {{userRequest}}
|
|
109
|
-
shell: {{shell}}
|
|
110
|
-
cwd: {{cwd}}
|
|
111
|
-
recent-terminal-contents:
|
|
112
|
-
{{recentTerminalContents}}
|
|
113
|
-
`
|
|
114
|
-
}
|
|
115
|
-
];
|
|
54
|
+
promptTemplates = terminalPromptTemplates;
|
|
116
55
|
languageModelRequirements: LanguageModelRequirement[] = [
|
|
117
56
|
{
|
|
118
57
|
purpose: 'suggest-terminal-commands',
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/tslint/config */
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2025 EclipseSource GmbH and others.
|
|
4
|
+
//
|
|
5
|
+
// This file is licensed under the MIT License.
|
|
6
|
+
// See LICENSE-MIT.txt in the project root for license information.
|
|
7
|
+
// https://opensource.org/license/mit.
|
|
8
|
+
//
|
|
9
|
+
// SPDX-License-Identifier: MIT
|
|
10
|
+
// *****************************************************************************
|
|
11
|
+
|
|
12
|
+
import { nls } from '@theia/core';
|
|
13
|
+
|
|
14
|
+
export const terminalPromptTemplates = [
|
|
15
|
+
{
|
|
16
|
+
id: 'terminal-system',
|
|
17
|
+
name: 'AI Terminal System Prompt',
|
|
18
|
+
description: nls.localize('theia/ai/terminal/systemPrompt/description', 'Prompt for the AI Terminal Assistant'),
|
|
19
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
20
|
+
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
21
|
+
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
22
|
+
# Instructions
|
|
23
|
+
Generate one or more command suggestions based on the user's request, considering the shell being used,
|
|
24
|
+
the current working directory, and the recent terminal contents. Provide the best suggestion first,
|
|
25
|
+
followed by other relevant suggestions if the user asks for further options.
|
|
26
|
+
|
|
27
|
+
Parameters:
|
|
28
|
+
- user-request: The user's question or request.
|
|
29
|
+
- shell: The shell being used, e.g., /usr/bin/zsh.
|
|
30
|
+
- cwd: The current working directory.
|
|
31
|
+
- recent-terminal-contents: The last 0 to 50 recent lines visible in the terminal.
|
|
32
|
+
|
|
33
|
+
Return the result in the following JSON format:
|
|
34
|
+
{
|
|
35
|
+
"commands": [
|
|
36
|
+
"best_command_suggestion",
|
|
37
|
+
"next_best_command_suggestion",
|
|
38
|
+
"another_command_suggestion"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
user-request: "How do I commit changes?"
|
|
44
|
+
shell: "/usr/bin/zsh"
|
|
45
|
+
cwd: "/home/user/project"
|
|
46
|
+
recent-terminal-contents:
|
|
47
|
+
git status
|
|
48
|
+
On branch main
|
|
49
|
+
Your branch is up to date with 'origin/main'.
|
|
50
|
+
nothing to commit, working tree clean
|
|
51
|
+
|
|
52
|
+
## Expected JSON output
|
|
53
|
+
\`\`\`json
|
|
54
|
+
\{
|
|
55
|
+
"commands": [
|
|
56
|
+
"git commit",
|
|
57
|
+
"git commit --amend",
|
|
58
|
+
"git commit -a"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
\`\`\`
|
|
62
|
+
`
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'terminal-user',
|
|
66
|
+
name: 'AI Terminal User Prompt',
|
|
67
|
+
description: nls.localize('theia/ai/terminal/userPrompt/description', 'Prompt that contains the user request'),
|
|
68
|
+
template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
|
|
69
|
+
Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
|
|
70
|
+
https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
|
|
71
|
+
user-request: {{userRequest}}
|
|
72
|
+
shell: {{shell}}
|
|
73
|
+
cwd: {{cwd}}
|
|
74
|
+
recent-terminal-contents:
|
|
75
|
+
{{recentTerminalContents}}
|
|
76
|
+
`
|
|
77
|
+
}
|
|
78
|
+
];
|