codemie-test-harness 0.1.169__py3-none-any.whl → 0.1.170__py3-none-any.whl
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.
Potentially problematic release.
This version of codemie-test-harness might be problematic. Click here for more details.
- codemie_test_harness/cli/cli.py +18 -74
- codemie_test_harness/cli/commands/assistant_cmd.py +104 -0
- codemie_test_harness/cli/commands/config_cmd.py +610 -20
- codemie_test_harness/cli/commands/workflow_cmd.py +64 -0
- codemie_test_harness/cli/constants.py +385 -6
- codemie_test_harness/cli/utils.py +9 -0
- codemie_test_harness/tests/test_data/project_management_test_data.py +1 -1
- codemie_test_harness/tests/ui/workflows/test_workflows.py +1 -1
- codemie_test_harness/tests/utils/credentials_manager.py +0 -15
- {codemie_test_harness-0.1.169.dist-info → codemie_test_harness-0.1.170.dist-info}/METADATA +2 -2
- {codemie_test_harness-0.1.169.dist-info → codemie_test_harness-0.1.170.dist-info}/RECORD +13 -11
- {codemie_test_harness-0.1.169.dist-info → codemie_test_harness-0.1.170.dist-info}/WHEEL +0 -0
- {codemie_test_harness-0.1.169.dist-info → codemie_test_harness-0.1.170.dist-info}/entry_points.txt +0 -0
codemie_test_harness/cli/cli.py
CHANGED
|
@@ -20,21 +20,9 @@ from .constants import (
|
|
|
20
20
|
KEY_AUTH_CLIENT_SECRET,
|
|
21
21
|
KEY_AUTH_REALM_NAME,
|
|
22
22
|
KEY_CODEMIE_API_DOMAIN,
|
|
23
|
+
KEY_AUTH_USERNAME,
|
|
24
|
+
KEY_AUTH_PASSWORD,
|
|
23
25
|
# integrations
|
|
24
|
-
KEY_GIT_ENV,
|
|
25
|
-
KEY_GITLAB_URL,
|
|
26
|
-
KEY_GITLAB_TOKEN,
|
|
27
|
-
KEY_GITLAB_PROJECT,
|
|
28
|
-
KEY_GITLAB_PROJECT_ID,
|
|
29
|
-
KEY_GITHUB_URL,
|
|
30
|
-
KEY_GITHUB_TOKEN,
|
|
31
|
-
KEY_GITHUB_PROJECT,
|
|
32
|
-
KEY_JIRA_URL,
|
|
33
|
-
KEY_JIRA_TOKEN,
|
|
34
|
-
KEY_JQL,
|
|
35
|
-
KEY_CONFLUENCE_URL,
|
|
36
|
-
KEY_CONFLUENCE_TOKEN,
|
|
37
|
-
KEY_CQL,
|
|
38
26
|
DEFAULT_MARKS,
|
|
39
27
|
DEFAULT_XDIST_N,
|
|
40
28
|
DEFAULT_RERUNS,
|
|
@@ -45,6 +33,8 @@ from .utils import get_config_value, ensure_env_from_config
|
|
|
45
33
|
from .runner import run_pytest
|
|
46
34
|
from .commands.config_cmd import config_cmd
|
|
47
35
|
from .commands.run_cmd import run_cmd
|
|
36
|
+
from .commands.assistant_cmd import assistant_cmd
|
|
37
|
+
from .commands.workflow_cmd import workflow_cmd
|
|
48
38
|
|
|
49
39
|
|
|
50
40
|
@click.group(context_settings=CONTEXT_SETTINGS)
|
|
@@ -65,40 +55,12 @@ from .commands.run_cmd import run_cmd
|
|
|
65
55
|
"--auth-client-secret", envvar=KEY_AUTH_CLIENT_SECRET, help="Auth client secret"
|
|
66
56
|
)
|
|
67
57
|
@click.option("--auth-realm-name", envvar=KEY_AUTH_REALM_NAME, help="Auth realm name")
|
|
58
|
+
@click.option("--auth-username", envvar=KEY_AUTH_USERNAME, help="Auth username")
|
|
59
|
+
@click.option("--auth-password", envvar=KEY_AUTH_PASSWORD, help="Auth password")
|
|
68
60
|
@click.option(
|
|
69
61
|
"--api-domain", envvar=KEY_CODEMIE_API_DOMAIN, help="CodeMie API domain URL"
|
|
70
62
|
)
|
|
71
|
-
#
|
|
72
|
-
@click.option(
|
|
73
|
-
"--git-env",
|
|
74
|
-
envvar=KEY_GIT_ENV,
|
|
75
|
-
type=click.Choice(["gitlab", "github"], case_sensitive=False),
|
|
76
|
-
help="Git provider env: gitlab or github",
|
|
77
|
-
)
|
|
78
|
-
# GitLab
|
|
79
|
-
@click.option("--gitlab-url", envvar=KEY_GITLAB_URL, help="GitLab base URL")
|
|
80
|
-
@click.option("--gitlab-token", envvar=KEY_GITLAB_TOKEN, help="GitLab access token")
|
|
81
|
-
@click.option("--gitlab-project", envvar=KEY_GITLAB_PROJECT, help="GitLab project URL")
|
|
82
|
-
@click.option(
|
|
83
|
-
"--gitlab-project-id",
|
|
84
|
-
envvar=KEY_GITLAB_PROJECT_ID,
|
|
85
|
-
help="GitLab project id",
|
|
86
|
-
type=str,
|
|
87
|
-
)
|
|
88
|
-
# GitHub
|
|
89
|
-
@click.option("--github-url", envvar=KEY_GITHUB_URL, help="GitHub base URL")
|
|
90
|
-
@click.option("--github-token", envvar=KEY_GITHUB_TOKEN, help="GitHub access token")
|
|
91
|
-
@click.option("--github-project", envvar=KEY_GITHUB_PROJECT, help="GitHub project URL")
|
|
92
|
-
# JIRA
|
|
93
|
-
@click.option("--jira-url", envvar=KEY_JIRA_URL, help="Jira base URL")
|
|
94
|
-
@click.option("--jira-token", envvar=KEY_JIRA_TOKEN, help="Jira token")
|
|
95
|
-
@click.option("--jql", envvar=KEY_JQL, help="JQL query string")
|
|
96
|
-
# Confluence
|
|
97
|
-
@click.option("--confluence-url", envvar=KEY_CONFLUENCE_URL, help="Confluence base URL")
|
|
98
|
-
@click.option(
|
|
99
|
-
"--confluence-token", envvar=KEY_CONFLUENCE_TOKEN, help="Confluence token"
|
|
100
|
-
)
|
|
101
|
-
@click.option("--cql", envvar=KEY_CQL, help="CQL query string")
|
|
63
|
+
# Integration credentials are set via 'codemie-test-harness config set' command
|
|
102
64
|
@click.pass_context
|
|
103
65
|
def cli(
|
|
104
66
|
ctx: click.Context,
|
|
@@ -109,25 +71,18 @@ def cli(
|
|
|
109
71
|
auth_client_id: Optional[str],
|
|
110
72
|
auth_client_secret: Optional[str],
|
|
111
73
|
auth_realm_name: Optional[str],
|
|
74
|
+
auth_username: Optional[str],
|
|
75
|
+
auth_password: Optional[str],
|
|
112
76
|
api_domain: Optional[str],
|
|
113
|
-
git_env: Optional[str],
|
|
114
|
-
gitlab_url: Optional[str],
|
|
115
|
-
gitlab_token: Optional[str],
|
|
116
|
-
gitlab_project: Optional[str],
|
|
117
|
-
gitlab_project_id: Optional[str],
|
|
118
|
-
github_url: Optional[str],
|
|
119
|
-
github_token: Optional[str],
|
|
120
|
-
github_project: Optional[str],
|
|
121
|
-
jira_url: Optional[str],
|
|
122
|
-
jira_token: Optional[str],
|
|
123
|
-
jql: Optional[str],
|
|
124
|
-
confluence_url: Optional[str],
|
|
125
|
-
confluence_token: Optional[str],
|
|
126
|
-
cql: Optional[str],
|
|
127
77
|
):
|
|
128
78
|
"""CodeMie Test Harness CLI.
|
|
129
79
|
|
|
130
80
|
Without subcommand it will run pytest using configured defaults.
|
|
81
|
+
|
|
82
|
+
Integration credentials should be set using:
|
|
83
|
+
codemie-test-harness config set KEY VALUE
|
|
84
|
+
|
|
85
|
+
Use 'codemie-test-harness config vars' to see all available credentials.
|
|
131
86
|
"""
|
|
132
87
|
ctx.ensure_object(dict)
|
|
133
88
|
|
|
@@ -150,23 +105,10 @@ def cli(
|
|
|
150
105
|
KEY_AUTH_SERVER_URL: auth_server_url,
|
|
151
106
|
KEY_AUTH_CLIENT_ID: auth_client_id,
|
|
152
107
|
KEY_AUTH_CLIENT_SECRET: auth_client_secret,
|
|
108
|
+
KEY_AUTH_USERNAME: auth_username,
|
|
109
|
+
KEY_AUTH_PASSWORD: auth_password,
|
|
153
110
|
KEY_AUTH_REALM_NAME: auth_realm_name,
|
|
154
111
|
KEY_CODEMIE_API_DOMAIN: api_domain,
|
|
155
|
-
# integrations
|
|
156
|
-
KEY_GIT_ENV: git_env,
|
|
157
|
-
KEY_GITLAB_URL: gitlab_url,
|
|
158
|
-
KEY_GITLAB_TOKEN: gitlab_token,
|
|
159
|
-
KEY_GITLAB_PROJECT: gitlab_project,
|
|
160
|
-
KEY_GITLAB_PROJECT_ID: gitlab_project_id,
|
|
161
|
-
KEY_GITHUB_URL: github_url,
|
|
162
|
-
KEY_GITHUB_TOKEN: github_token,
|
|
163
|
-
KEY_GITHUB_PROJECT: github_project,
|
|
164
|
-
KEY_JIRA_URL: jira_url,
|
|
165
|
-
KEY_JIRA_TOKEN: jira_token,
|
|
166
|
-
KEY_JQL: jql,
|
|
167
|
-
KEY_CONFLUENCE_URL: confluence_url,
|
|
168
|
-
KEY_CONFLUENCE_TOKEN: confluence_token,
|
|
169
|
-
KEY_CQL: cql,
|
|
170
112
|
}
|
|
171
113
|
for k, v in provided.items():
|
|
172
114
|
if v is not None and v != "":
|
|
@@ -186,6 +128,8 @@ def cli(
|
|
|
186
128
|
# Register subcommands
|
|
187
129
|
cli.add_command(config_cmd)
|
|
188
130
|
cli.add_command(run_cmd)
|
|
131
|
+
cli.add_command(assistant_cmd)
|
|
132
|
+
cli.add_command(workflow_cmd)
|
|
189
133
|
|
|
190
134
|
|
|
191
135
|
if __name__ == "__main__": # pragma: no cover
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Assistant CLI commands for interactive chat with assistants."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import uuid
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
from codemie_sdk.models.assistant import AssistantChatRequest
|
|
13
|
+
from codemie_test_harness.tests.utils.client_factory import get_client
|
|
14
|
+
from ..constants import CONSOLE
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.group(name="assistant")
|
|
18
|
+
def assistant_cmd():
|
|
19
|
+
"""Interact with CodeMie assistants."""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@assistant_cmd.command(name="chat")
|
|
24
|
+
@click.option(
|
|
25
|
+
"--assistant-id",
|
|
26
|
+
required=True,
|
|
27
|
+
help="Assistant ID to chat with",
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--conversation-id",
|
|
31
|
+
help="Conversation ID to continue existing chat (optional)",
|
|
32
|
+
)
|
|
33
|
+
@click.option(
|
|
34
|
+
"--message",
|
|
35
|
+
"-m",
|
|
36
|
+
required=True,
|
|
37
|
+
help="Message to send to the assistant",
|
|
38
|
+
)
|
|
39
|
+
@click.option(
|
|
40
|
+
"--stream/--no-stream",
|
|
41
|
+
default=False,
|
|
42
|
+
help="Stream the response (default: no-stream)",
|
|
43
|
+
)
|
|
44
|
+
def chat_cmd(
|
|
45
|
+
assistant_id: str,
|
|
46
|
+
conversation_id: Optional[str],
|
|
47
|
+
message: str,
|
|
48
|
+
stream: bool,
|
|
49
|
+
):
|
|
50
|
+
"""Chat with a specific assistant.
|
|
51
|
+
|
|
52
|
+
Example:
|
|
53
|
+
codemie-test-harness assistant chat --assistant-id "asst_123" -m "Hello, how can you help me?"
|
|
54
|
+
codemie-test-harness assistant chat --assistant-id "asst_123" --conversation-id "conv_456" -m "Continue our conversation"
|
|
55
|
+
"""
|
|
56
|
+
try:
|
|
57
|
+
client = get_client()
|
|
58
|
+
|
|
59
|
+
# Generate conversation ID if not provided
|
|
60
|
+
if not conversation_id:
|
|
61
|
+
conversation_id = str(uuid.uuid4())
|
|
62
|
+
CONSOLE.print(
|
|
63
|
+
f"[green]New conversation started with ID: {conversation_id}[/green]"
|
|
64
|
+
)
|
|
65
|
+
else:
|
|
66
|
+
CONSOLE.print(f"[blue]Continuing conversation: {conversation_id}[/blue]")
|
|
67
|
+
|
|
68
|
+
# Create chat request
|
|
69
|
+
langfuse_enabled = (
|
|
70
|
+
os.getenv("LANGFUSE_TRACES_ENABLED", "false").lower() == "true"
|
|
71
|
+
)
|
|
72
|
+
chat_request = AssistantChatRequest(
|
|
73
|
+
text=message,
|
|
74
|
+
conversation_id=conversation_id,
|
|
75
|
+
stream=stream,
|
|
76
|
+
metadata={"langfuse_traces_enabled": langfuse_enabled},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
CONSOLE.print(
|
|
80
|
+
f"[yellow]Sending message to assistant {assistant_id}...[/yellow]"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Send chat request
|
|
84
|
+
response = client.assistants.chat(
|
|
85
|
+
assistant_id=assistant_id, request=chat_request
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Display response
|
|
89
|
+
if hasattr(response, "generated") and response.generated:
|
|
90
|
+
CONSOLE.print("[green]Assistant Response:[/green]")
|
|
91
|
+
CONSOLE.print(response.generated)
|
|
92
|
+
elif hasattr(response, "task_id") and response.task_id:
|
|
93
|
+
CONSOLE.print(
|
|
94
|
+
f"[yellow]Background task created with ID: {response.task_id}[/yellow]"
|
|
95
|
+
)
|
|
96
|
+
CONSOLE.print(
|
|
97
|
+
"[blue]You can check the task status using the task ID[/blue]"
|
|
98
|
+
)
|
|
99
|
+
else:
|
|
100
|
+
CONSOLE.print(f"[cyan]Raw response:[/cyan] {response}")
|
|
101
|
+
|
|
102
|
+
except Exception as e:
|
|
103
|
+
CONSOLE.print(f"[red]Error chatting with assistant: {e}[/red]")
|
|
104
|
+
raise click.ClickException(str(e))
|