Skip to content

[NOT-744] Add PowerShell (Pwsh 7+) as a supported output language - #118

Open
sultanberisa wants to merge 1 commit into
nottelabs:mainfrom
sultanberisa:add-powershell-support
Open

[NOT-744] Add PowerShell (Pwsh 7+) as a supported output language#118
sultanberisa wants to merge 1 commit into
nottelabs:mainfrom
sultanberisa:add-powershell-support

Conversation

@sultanberisa

@sultanberisa sultanberisa commented Aug 3, 2026

Copy link
Copy Markdown
  • Adds PowerShell as a first-class output language
  • Generates .psm1 module + Example.ps1 (no .psd1 manifest, matching Go's "only if needed" pattern)
  • Follows approved-verb / CmdletBinding / explicit Export-ModuleMember conventions
  • Full test coverage added, existing suite unaffected

Summary by cubic

Adds PowerShell (pwsh 7+) as a first-class output language. Generates a .psm1 module with a runnable Example.ps1, updates settings/docs, and adds support across run/discovery utilities.

  • New Features
    • Adds powershell to output languages and /settings; supports .psm1 in discovery and run commands.
    • Generates api_client.psm1 plus Example.ps1 (no .psd1), with approved verbs, [CmdletBinding()], and explicit Export-ModuleMember.
    • Run command uses pwsh -NoProfile -File Example.ps1 with safe quoting and absolute paths.
    • Docs updated to “ten languages”; requires pwsh 7+ (PowerShell Core).

Written for commit 1579db1. Summary will update on new commits.

Review in cubic

Greptile Summary

This change adds PowerShell as a selectable generated-client language, including .psm1 modules and an Example.ps1 companion 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

  • Missing tool: pwsh (PowerShell 7+) is not installed. The command-construction path was exercised and confirmed to append caller values after Example.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 the click package.

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Comment thread src/reverse_api/utils.py
# (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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
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"

Comment thread src/reverse_api/utils.py
# 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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Comment thread src/reverse_api/utils.py
# (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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

@giordano-lucas giordano-lucas changed the title Add PowerShell (Pwsh 7+) as a supported output language [NOT-744] Add PowerShell (Pwsh 7+) as a supported output language Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant