[NOT-744] Add PowerShell (Pwsh 7+) as a supported output language - #118
[NOT-744] Add PowerShell (Pwsh 7+) as a supported output language#118sultanberisa wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
3 issues found across 13 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/reverse_api/base_engineer.py">
<violation number="1" location="src/reverse_api/base_engineer.py:633">
P1: PowerShell runs on Linux/macOS can fail before exercising the generated client because this new command executes the example whose module import uses a Windows-style `\` path. Generating the import path with `Join-Path $PSScriptRoot '{client_filename}'` (or a platform-neutral separator) would keep the advertised cross-platform `pwsh` support working.</violation>
</file>
<file name="src/reverse_api/utils.py">
<violation number="1" location="src/reverse_api/utils.py:838">
P2: Selecting a PowerShell module other than `api_client.psm1` still runs the fixed `Example.ps1`, whose generated import targets `api_client.psm1`, so the selected module is ignored or the run fails when that file is absent. The command path should derive the module filename from `script` or otherwise validate that only the generated module can be selected.</violation>
<violation number="2" location="src/reverse_api/utils.py:839">
P2: PowerShell run arguments can be silently ineffective: `--args` are appended to the fixed example script, while generated `Example.ps1` has no required mechanism to forward them to the module's function call. The implementation should either make the example argument-aware or reject `script_args` explicitly instead of implying client argument support.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| # re-interpreted against the agent's cwd (scripts_dir.parent. | ||
| # parent) instead of the original cwd it was relative to, | ||
| # pointing -File at the wrong, doubly-nested location. | ||
| example = self._quote_path(str(self.scripts_dir.resolve() / "Example.ps1")) |
There was a problem hiding this comment.
P1: PowerShell runs on Linux/macOS can fail before exercising the generated client because this new command executes the example whose module import uses a Windows-style \ path. Generating the import path with Join-Path $PSScriptRoot '{client_filename}' (or a platform-neutral separator) would keep the advertised cross-platform pwsh support working.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/reverse_api/base_engineer.py, line 633:
<comment>PowerShell runs on Linux/macOS can fail before exercising the generated client because this new command executes the example whose module import uses a Windows-style `\` path. Generating the import path with `Join-Path $PSScriptRoot '{client_filename}'` (or a platform-neutral separator) would keep the advertised cross-platform `pwsh` support working.</comment>
<file context>
@@ -613,6 +614,24 @@ def _get_run_command(self) -> str:
+ # re-interpreted against the agent's cwd (scripts_dir.parent.
+ # parent) instead of the original cwd it was relative to,
+ # pointing -File at the wrong, doubly-nested location.
+ example = self._quote_path(str(self.scripts_dir.resolve() / "Example.ps1"))
+ return f"pwsh -NoProfile -File {example}"
return {
</file context>
| # (Example.ps1) that Imports the module and calls its exported | ||
| # functions, not the script argument itself. | ||
| example = d / "Example.ps1" | ||
| return [["pwsh", "-NoProfile", "-File", str(example), *script_args]], "pwsh" |
There was a problem hiding this comment.
P2: PowerShell run arguments can be silently ineffective: --args are appended to the fixed example script, while generated Example.ps1 has no required mechanism to forward them to the module's function call. The implementation should either make the example argument-aware or reject script_args explicitly instead of implying client argument support.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/reverse_api/utils.py, line 839:
<comment>PowerShell run arguments can be silently ineffective: `--args` are appended to the fixed example script, while generated `Example.ps1` has no required mechanism to forward them to the module's function call. The implementation should either make the example argument-aware or reject `script_args` explicitly instead of implying client argument support.</comment>
<file context>
@@ -829,6 +830,13 @@ def build_script_commands(script: Path, script_args: tuple[str, ...] = ()) -> tu
+ # (Example.ps1) that Imports the module and calls its exported
+ # functions, not the script argument itself.
+ example = d / "Example.ps1"
+ return [["pwsh", "-NoProfile", "-File", str(example), *script_args]], "pwsh"
raise ValueError(f"unsupported script type: {script.name}")
</file context>
| return [["pwsh", "-NoProfile", "-File", str(example), *script_args]], "pwsh" | |
| if script_args: | |
| raise ValueError( | |
| "script arguments are not supported for PowerShell clients: the generated Example.ps1 invocation is fixed" | |
| ) | |
| return [["pwsh", "-NoProfile", "-File", str(example)]], "pwsh" |
| # pom.xml/csproj, the actual command targets a fixed companion file | ||
| # (Example.ps1) that Imports the module and calls its exported | ||
| # functions, not the script argument itself. | ||
| example = d / "Example.ps1" |
There was a problem hiding this comment.
P2: Selecting a PowerShell module other than api_client.psm1 still runs the fixed Example.ps1, whose generated import targets api_client.psm1, so the selected module is ignored or the run fails when that file is absent. The command path should derive the module filename from script or otherwise validate that only the generated module can be selected.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/reverse_api/utils.py, line 838:
<comment>Selecting a PowerShell module other than `api_client.psm1` still runs the fixed `Example.ps1`, whose generated import targets `api_client.psm1`, so the selected module is ignored or the run fails when that file is absent. The command path should derive the module filename from `script` or otherwise validate that only the generated module can be selected.</comment>
<file context>
@@ -829,6 +830,13 @@ def build_script_commands(script: Path, script_args: tuple[str, ...] = ()) -> tu
+ # pom.xml/csproj, the actual command targets a fixed companion file
+ # (Example.ps1) that Imports the module and calls its exported
+ # functions, not the script argument itself.
+ example = d / "Example.ps1"
+ return [["pwsh", "-NoProfile", "-File", str(example), *script_args]], "pwsh"
raise ValueError(f"unsupported script type: {script.name}")
</file context>
| # (Example.ps1) that Imports the module and calls its exported | ||
| # functions, not the script argument itself. | ||
| example = d / "Example.ps1" | ||
| return [["pwsh", "-NoProfile", "-File", str(example), *script_args]], "pwsh" |
There was a problem hiding this comment.
Example wrapper drops run arguments
When a user supplies arguments to run, this branch passes them to Example.ps1, but the generation prompt does not require that wrapper to declare parameters or forward values to the module functions. As a result, generated PowerShell clients cannot reliably consume caller-provided run arguments: PowerShell may reject the unbound values, or the wrapper will never pass them to the exported API call.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/reverse_api/utils.py
Line: 839
Comment:
**Example wrapper drops run arguments**
When a user supplies arguments to `run`, this branch passes them to `Example.ps1`, but the generation prompt does not require that wrapper to declare parameters or forward values to the module functions. As a result, generated PowerShell clients cannot reliably consume caller-provided run arguments: PowerShell may reject the unbound values, or the wrapper will never pass them to the exported API call.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary by cubic
Adds PowerShell (
pwsh7+) as a first-class output language. Generates a.psm1module with a runnableExample.ps1, updates settings/docs, and adds support across run/discovery utilities.powershellto output languages and/settings; supports.psm1in discovery and run commands.api_client.psm1plusExample.ps1(no.psd1), with approved verbs,[CmdletBinding()], and explicitExport-ModuleMember.pwsh -NoProfile -File Example.ps1with safe quoting and absolute paths.pwsh7+ (PowerShell Core).Written for commit 1579db1. Summary will update on new commits.
Greptile Summary
This change adds PowerShell as a selectable generated-client language, including
.psm1modules and anExample.ps1companion runner.PowerShell run arguments are passed to
Example.ps1, but the generated-wrapper instructions do not require parameters or forwarding into the exported module function. Users invoking a generated client with arguments therefore cannot rely on those values reaching the API call.T-Rex validation blocked
pwsh(PowerShell 7+) is not installed. The command-construction path was exercised and confirmed to append caller values afterExample.ps1, but actual PowerShell parameter binding and forwarding could not be executed. The focused existing test selection was also unavailable because the Python environment lacked theclickpackage.Confidence Score: 4/5
Linear: NOT-744 — https://linear.app/nottelabsinc/issue/NOT-744/reverse-api-engineer-pr-118-add-powershell-pwsh-7-as-a-supported