Skip to content

Commit

Permalink
Code lenses for actions/dev-tasks, fixed vulnerability creating rcc t…
Browse files Browse the repository at this point in the history
…erminal.
  • Loading branch information
fabioz authored Oct 31, 2024
1 parent c2b5727 commit 6d1e396
Show file tree
Hide file tree
Showing 27 changed files with 1,236 additions and 225 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
- Update RCC to `v18.5.0`.
- Using RCC directly to build the environment using `package.yaml` (instead of creating a `conda.yaml` first).
- When dealing with a `package.yaml`, always consider the `dev-environment` when building the environment.
- Add code lenses to:
- `Run Dev Task` (for `dev-tasks` inside a `package.yaml`)
- `Run Action` (for `@action` decorated methods in `.py` files)
- `Debug Action` (for `@action` decorated methods in `.py` files)
- Fixed vulnerability when creating temp file to create terminal (it could create a `.bat` / `.sh` file in a directory which could be shared by multiple users).

## New in 2.7.1 (2024-10-23)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ def small_vs_sleep():


def test_workspace_and_uris(tmpdir):
from sema4ai_ls_core.workspace import Workspace
from sema4ai_ls_core.watchdog_wrapper import create_observer
from sema4ai_ls_core import uris
from sema4ai_ls_core.lsp import TextDocumentItem
import os
import sys

from sema4ai_ls_core import uris
from sema4ai_ls_core.lsp import TextDocumentItem
from sema4ai_ls_core.watchdog_wrapper import create_observer
from sema4ai_ls_core.workspace import Workspace

ws_root_path = str(tmpdir)
root_uri = uris.from_fs_path(ws_root_path)
ws = Workspace(
Expand Down Expand Up @@ -58,17 +59,15 @@ def to_vscode_uri(uri):
)


def test_workspace_memory_cache(tmpdir, small_vs_sleep):
from sema4ai_ls_core.workspace import Workspace
from sema4ai_ls_core import uris
from sema4ai_ls_core.lsp import WorkspaceFolder
def test_workspace_memory_cache(tmpdir, small_vs_sleep) -> None:
import os
from typing import List
from sema4ai_ls_core.protocols import IWorkspaceFolder
import typing
from sema4ai_ls_core.workspace import _WorkspaceFolderWithVirtualFS
from sema4ai_ls_core import watchdog_wrapper

from sema4ai_ls_core import uris, watchdog_wrapper
from sema4ai_ls_core.basic import wait_for_condition
from sema4ai_ls_core.lsp import WorkspaceFolder
from sema4ai_ls_core.protocols import IWorkspaceFolder
from sema4ai_ls_core.workspace import Workspace, _WorkspaceFolderWithVirtualFS

root_uri = uris.from_fs_path(str(tmpdir))
workspace_folders: list[IWorkspaceFolder] = [
Expand Down
1 change: 1 addition & 0 deletions sema4ai/codegen/codegen_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get_json_contents():
"publisher": "sema4ai",
"engines": {"vscode": f"^1.65.0"},
"categories": ["Debuggers"],
"taskDefinitions": [{"type": "Sema4.ai: dev-task"}],
"activationEvents": get_activation_events_for_json()
+ views.get_activation_events_for_json()
+ ["onLanguage:json", "onLanguage:yaml", "onLanguage:python"],
Expand Down
6 changes: 6 additions & 0 deletions sema4ai/codegen/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,12 @@ def __init__(
server_handled=False,
hide_from_command_palette=False,
),
Command(
"sema4ai.runActionPackageDevTask",
"Run dev-task (from Action Package)",
add_to_package_json=True,
server_handled=False,
),
]


Expand Down
12 changes: 12 additions & 0 deletions sema4ai/codegen/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ def __init__(
"Specifies whether the 'Run Task' and 'Debug Task' code lenses should be shown.",
setting_type="boolean",
),
Setting(
"sema4ai.codeLens.actionsLaunch",
True,
"Specifies whether the 'Run Action' and 'Debug Action' code lenses should be shown.",
setting_type="boolean",
),
Setting(
"sema4ai.codeLens.devTask",
True,
"Specifies whether the 'Run Task' and 'Debug Task' code lenses should be shown in `dev-tasks` in `package.yaml`.",
setting_type="boolean",
),
]


Expand Down
21 changes: 21 additions & 0 deletions sema4ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"categories": [
"Debuggers"
],
"taskDefinitions": [
{
"type": "Sema4.ai: dev-task"
}
],
"activationEvents": [
"onCommand:sema4ai.getLanguageServerPython",
"onCommand:sema4ai.getLanguageServerPythonInfo",
Expand Down Expand Up @@ -162,6 +167,7 @@
"onCommand:sema4ai.updateAgentVersion.internal",
"onCommand:sema4ai.collapseAllEntries",
"onCommand:sema4ai.importActionPackage",
"onCommand:sema4ai.runActionPackageDevTask",
"onDebugInitialConfigurations",
"onDebugResolve:sema4ai",
"onView:sema4ai-task-packages-tree",
Expand Down Expand Up @@ -241,6 +247,16 @@
"type": "boolean",
"default": true,
"description": "Specifies whether the 'Run Task' and 'Debug Task' code lenses should be shown."
},
"sema4ai.codeLens.actionsLaunch": {
"type": "boolean",
"default": true,
"description": "Specifies whether the 'Run Action' and 'Debug Action' code lenses should be shown."
},
"sema4ai.codeLens.devTask": {
"type": "boolean",
"default": true,
"description": "Specifies whether the 'Run Task' and 'Debug Task' code lenses should be shown in `dev-tasks` in `package.yaml`."
}
}
},
Expand Down Expand Up @@ -969,6 +985,11 @@
"command": "sema4ai.importActionPackage",
"title": "Import Action Package",
"category": "Sema4.ai"
},
{
"command": "sema4ai.runActionPackageDevTask",
"title": "Run dev-task (from Action Package)",
"category": "Sema4.ai"
}
],
"menus": {
Expand Down
1 change: 1 addition & 0 deletions sema4ai/src/sema4ai_code/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
SEMA4AI_UPDATE_AGENT_VERSION_INTERNAL = "sema4ai.updateAgentVersion.internal" # Update Agent Version (internal)
SEMA4AI_COLLAPSE_ALL_ENTRIES = "sema4ai.collapseAllEntries" # Collapse All Entries
SEMA4AI_IMPORT_ACTION_PACKAGE = "sema4ai.importActionPackage" # Import Action Package
SEMA4AI_RUN_ACTION_PACKAGE_DEV_TASK = "sema4ai.runActionPackageDevTask" # Run dev-task (from Action Package)

ALL_SERVER_COMMANDS = [
SEMA4AI_GET_PLUGINS_DIR,
Expand Down
Loading

0 comments on commit 6d1e396

Please sign in to comment.