Skip to content

Commit fd13318

Browse files
authored
Merge branch 'main' into review-improve
2 parents 7e0250e + ea6fa20 commit fd13318

42 files changed

Lines changed: 2846 additions & 560 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import {
3939
TaskDeclineRequest,
4040
ConnectorSpecRequest,
4141
ConnectorSpecCancelRequest,
42+
ConfigurationProvideRequest,
43+
ConfigurationCancelRequest,
4244
UIChatMessage,
4345
CheckpointInfo,
4446
AbortAIGenerationRequest,
@@ -93,6 +95,8 @@ export interface AIPanelAPI {
9395
declineTask: (params: TaskDeclineRequest) => Promise<void>;
9496
provideConnectorSpec: (params: ConnectorSpecRequest) => Promise<void>;
9597
cancelConnectorSpec: (params: ConnectorSpecCancelRequest) => Promise<void>;
98+
provideConfiguration: (params: ConfigurationProvideRequest) => Promise<void>;
99+
cancelConfiguration: (params: ConfigurationCancelRequest) => Promise<void>;
96100
// ==================================
97101
// Chat State Management
98102
// ==================================

workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/interfaces.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ export interface ConnectorSpecCancelRequest {
437437
comment?: string;
438438
}
439439

440+
export interface ConfigurationProvideRequest {
441+
requestId: string;
442+
configValues: Record<string, string>;
443+
}
444+
445+
export interface ConfigurationCancelRequest {
446+
requestId: string;
447+
comment?: string;
448+
}
449+
440450
export type ErrorCode = {
441451
code: number;
442452
message: string;

workspaces/ballerina/ballerina-core/src/rpc-types/ai-panel/rpc-type.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import {
4141
TaskDeclineRequest,
4242
ConnectorSpecRequest,
4343
ConnectorSpecCancelRequest,
44+
ConfigurationProvideRequest,
45+
ConfigurationCancelRequest,
4446
UIChatMessage,
4547
CheckpointInfo,
4648
AbortAIGenerationRequest,
@@ -85,6 +87,8 @@ export const approveTask: RequestType<ApproveTaskRequest, void> = { method: `${_
8587
export const declineTask: RequestType<TaskDeclineRequest, void> = { method: `${_preFix}/declineTask` };
8688
export const provideConnectorSpec: RequestType<ConnectorSpecRequest, void> = { method: `${_preFix}/provideConnectorSpec` };
8789
export const cancelConnectorSpec: RequestType<ConnectorSpecCancelRequest, void> = { method: `${_preFix}/cancelConnectorSpec` };
90+
export const provideConfiguration: RequestType<ConfigurationProvideRequest, void> = { method: `${_preFix}/provideConfiguration` };
91+
export const cancelConfiguration: RequestType<ConfigurationCancelRequest, void> = { method: `${_preFix}/cancelConfiguration` };
8892
export const getChatMessages: NotificationType<void> = { method: `${_preFix}/getChatMessages` };
8993
export const getCheckpoints: NotificationType<void> = { method: `${_preFix}/getCheckpoints` };
9094
export const restoreCheckpoint: RequestType<RestoreCheckpointRequest, void> = { method: `${_preFix}/restoreCheckpoint` };

workspaces/ballerina/ballerina-core/src/state-machine-types.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export enum MACHINE_VIEW {
103103
ServiceFunctionForm = "Service Function Form",
104104
BISamplesView = "BI Samples View",
105105
ReviewMode = "Review Mode SKIP",
106-
EvalsetViewer = "Evalset Viewer SKIP"
106+
EvalsetViewer = "Evalset Viewer SKIP",
107+
ConfigurationCollector = "Configuration Collector"
107108
}
108109

109110
export interface MachineEvent {
@@ -168,7 +169,20 @@ export interface ArtifactData {
168169
identifier?: string;
169170
}
170171

172+
export interface ConfigurationCollectorMetadata {
173+
requestId: string;
174+
variables: Array<{
175+
name: string;
176+
description: string;
177+
type?: "string" | "int";
178+
}>;
179+
existingValues?: Record<string, string>;
180+
message: string;
181+
isTestConfig?: boolean;
182+
}
183+
171184
export interface AgentMetadata {
185+
configurationCollector?: ConfigurationCollectorMetadata;
172186
}
173187

174188
export interface ApprovalOverlayState {
@@ -263,7 +277,7 @@ export interface EvalsetTrace {
263277
iterations: EvalIteration[];
264278
output: EvalChatAssistantMessage | any;
265279
tools: EvalToolSchema[];
266-
toolCalls: EvalFunctionCall[];
280+
toolCalls?: EvalFunctionCall[];
267281
startTime: string;
268282
endTime: string;
269283
}
@@ -326,6 +340,7 @@ export type ChatNotify =
326340
| TaskApprovalRequest
327341
| GeneratedSourcesEvent
328342
| ConnectorGenerationNotification
343+
| ConfigurationCollectionEvent
329344
| CodeReviewActions
330345
| PlanUpdated;
331346

@@ -446,6 +461,24 @@ export interface ConnectorGenerationNotification {
446461
message: string;
447462
}
448463

464+
export interface ConfigurationCollectionEvent {
465+
type: "configuration_collection_event";
466+
requestId: string;
467+
stage: "creating_file" | "collecting" | "done" | "skipped" | "error";
468+
variables?: Array<{
469+
name: string;
470+
description: string;
471+
type?: "string" | "int";
472+
}>;
473+
existingValues?: Record<string, string>;
474+
message: string;
475+
isTestConfig?: boolean;
476+
error?: {
477+
message: string;
478+
code: string;
479+
};
480+
}
481+
449482
export interface CodeReviewActions {
450483
type: "review_actions";
451484
}

workspaces/ballerina/ballerina-extension/package.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,30 @@
753753
"icon": "$(clear-all)",
754754
"hidden": true,
755755
"enablement": "isSupportedProject"
756+
},
757+
{
758+
"command": "ballerina.createNewEvalset",
759+
"title": "Create New Evalset",
760+
"category": "Ballerina",
761+
"icon": "$(add)"
762+
},
763+
{
764+
"command": "ballerina.createNewThread",
765+
"title": "Add Thread",
766+
"category": "Ballerina",
767+
"icon": "$(add)"
768+
},
769+
{
770+
"command": "ballerina.deleteEvalset",
771+
"title": "Delete Evalset",
772+
"category": "Ballerina",
773+
"icon": "$(trash)"
774+
},
775+
{
776+
"command": "ballerina.deleteThread",
777+
"title": "Delete Thread",
778+
"category": "Ballerina",
779+
"icon": "$(trash)"
756780
}
757781
],
758782
"views": {
@@ -865,6 +889,28 @@
865889
"when": "view == ballerina-traceView && ballerina.tracingEnabled && !ballerina.tracesEmpty",
866890
"group": "navigation",
867891
"title": "Clear Traces"
892+
},
893+
{
894+
"command": "ballerina.createNewEvalset",
895+
"when": "view == ballerina-evalsets",
896+
"group": "navigation"
897+
}
898+
],
899+
"view/item/context": [
900+
{
901+
"command": "ballerina.createNewThread",
902+
"when": "view == ballerina-evalsets && viewItem == evalsetFile",
903+
"group": "inline"
904+
},
905+
{
906+
"command": "ballerina.deleteEvalset",
907+
"when": "view == ballerina-evalsets && viewItem == evalsetFile",
908+
"group": "inline"
909+
},
910+
{
911+
"command": "ballerina.deleteThread",
912+
"when": "view == ballerina-evalsets && viewItem == evalsetThread",
913+
"group": "inline"
868914
}
869915
],
870916
"BI.test.add.submenu": [

workspaces/ballerina/ballerina-extension/src/features/ai/agent/np/prompts.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// specific language governing permissions and limitations
1515
// under the License.
1616

17+
import { CONFIG_COLLECTOR_TOOL } from "../tools/config-collector";
18+
1719
export const REQUIREMENTS_DOCUMENT_KEY: string = "user_requirements_file";
1820

1921
export function getRequirementAnalysisCodeGenPrefix(requirementAnalysisDocument: string) {
@@ -93,6 +95,12 @@ You are an expert test automation engineer specializing in generating test artif
9395
9496
2. Create Ballerina test module with:
9597
- Network client configurations (if required, e.g., HTTP, GraphQL, WebSocket, etc.)
98+
- Setup test configuration (if main code uses it):
99+
* If main code uses configuration values (API keys, tokens, passwords), use ${CONFIG_COLLECTOR_TOOL}
100+
* Set mode: "collect", isTestConfig: true
101+
* Tell user: "Setting up test configuration based on main configuration"
102+
* The tool will automatically handle reading from main config and saving to tests/Config.toml
103+
* Example: { mode: "collect", variables: [{ name: "API_KEY", description: "Stripe API key", type: "string" }], isTestConfig: true }
96104
- Test data factories
97105
- Reusable validation functions
98106

workspaces/ballerina/ballerina-extension/src/features/ai/agent/prompts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { LIBRARY_SEARCH_TOOL } from "./tools/library-search";
2020
import { TASK_WRITE_TOOL_NAME } from "./tools/task-writer";
2121
import { FILE_BATCH_EDIT_TOOL_NAME, FILE_SINGLE_EDIT_TOOL_NAME, FILE_WRITE_TOOL_NAME } from "./tools/text-editor";
2222
import { CONNECTOR_GENERATOR_TOOL } from "./tools/connector-generator";
23+
import { CONFIG_COLLECTOR_TOOL } from "./tools/config-collector";
2324
import { getLanglibInstructions } from "../utils/libs/langlibs";
2425
import { formatCodebaseStructure, formatCodeContext } from "./utils";
2526
import { GenerateAgentCodeRequest, OperationType, ProjectSource } from "@wso2/ballerina-core";
@@ -152,6 +153,11 @@ ${getLanglibInstructions()}
152153
153154
## Code Structure
154155
- Define required configurables for the query. Use only string, int, decimal, boolean types in configurable variables.
156+
- For sensitive configuration values (API keys, tokens, passwords), use ${CONFIG_COLLECTOR_TOOL} in COLLECT mode. Variable names are converted to lowercase without underscores in Config.toml. You MUST use the exact Config.toml names in your Ballerina configurables to avoid runtime errors.
157+
- When generating tests that need configuration values:
158+
- Use COLLECT mode with isTestConfig: true
159+
- The tool will automatically read existing values from Config.toml (if exists), ask user to reuse or modify for testing, and save to tests/Config.toml
160+
- Example: { mode: "collect", variables: [...], isTestConfig: true }
155161
- Initialize any necessary clients with the correct configuration based on the retrieved libraries at the module level (before any function or service declarations).
156162
- Implement the main function OR service to address the query requirements.
157163
@@ -181,7 +187,7 @@ ${getLanglibInstructions()}
181187
)} tools. The complete existing source code will be provided in the <existing_code> section of the user prompt.
182188
- When making replacements inside an existing file, provide the **exact old string** and the **exact new string** with all newlines, spaces, and indentation, being mindful to replace nearby occurrences together to minimize the number of tool calls.
183189
- Do NOT create a new markdown file to document each change or summarize your work unless specifically requested by the user.
184-
- Do not add/modify toml files (Config.toml/Ballerina.toml/Dependencies.toml) as you don't have access to those files.
190+
- Do not manually add/modify toml files (Ballerina.toml/Dependencies.toml). For Config.toml configuration management, use ${CONFIG_COLLECTOR_TOOL}.
185191
- Prefer modifying existing bal files over creating new files unless explicitly asked to create a new file in the query.
186192
187193
${getNPSuffix(projects, op)}

workspaces/ballerina/ballerina-extension/src/features/ai/agent/tool-registry.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { GenerationType } from '../utils/libs/libraries';
4040
import { getHealthcareLibraryProviderTool, HEALTHCARE_LIBRARY_PROVIDER_TOOL } from './tools/healthcare-library';
4141
import { createConnectorGeneratorTool, CONNECTOR_GENERATOR_TOOL } from './tools/connector-generator';
4242
import { LIBRARY_SEARCH_TOOL, getLibrarySearchTool } from './tools/library-search';
43+
import { createConfigCollectorTool, CONFIG_COLLECTOR_TOOL } from './tools/config-collector';
4344

4445
export interface ToolRegistryOptions {
4546
eventHandler: CopilotEventHandler;
@@ -79,6 +80,14 @@ export function createToolRegistry(opts: ToolRegistryOptions) {
7980
projects[0].projectName,
8081
modifiedFiles
8182
),
83+
[CONFIG_COLLECTOR_TOOL]: createConfigCollectorTool(
84+
eventHandler,
85+
{
86+
tempPath: tempProjectPath,
87+
workspacePath: workspaceId
88+
},
89+
modifiedFiles
90+
),
8291
[FILE_WRITE_TOOL_NAME]: createWriteTool(
8392
createWriteExecute(eventHandler, tempProjectPath, modifiedFiles)
8493
),

0 commit comments

Comments
 (0)