Skip to content

feat(codemode): replace Yaegi with Expr - #155

Merged
Raezil merged 28 commits into
mainfrom
feat/expr-codemode
Aug 27, 2026
Merged

Raezil merged 28 commits into
mainfrom
feat/expr-codemode

Conversation

@Raezil

@Raezil Raezil commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Replace the Go/Yaegi CodeMode runtime with Expr on feat/expr-codemode.

  • execute CodeMode as Expr expressions
  • expose only the codemode runtime API
  • preserve exact tool whitelist validation and orchestration
  • support sequential tool chaining with let
  • collect streaming results through CallToolStream
  • remove Yaegi-specific tests and docs
  • add Expr runtime tests

Summary by cubic

Replaces the CodeMode Go/Yaegi interpreter with expr-lang/expr, so generated workflows are now Expr expressions instead of Go-like snippets. Code that relied on __out, imports, type assertions, or manual stream loops must be rewritten; tool whitelist validation and orchestration caching stay unchanged.

  • Adds github.com/expr-lang/expr v1.17.8, drops github.com/traefik/yaegi, and makes the orchestrator fully Expr-native.
  • Extracts the plan JSON from model output even when wrapped in prose or markdown, then validates snippets with Expr before execution.
  • The planner prompt now signals the Expr contract explicitly so generated programs are unambiguously non-Go.
  • Generated programs see only the codemode API object, with no Go imports or Yaegi stdlib.
  • codemode.CallToolStream collects streaming chunks into an array instead of a manual iterator.
  • Removes Yaegi benchmarks and preprocessing tests; replaces them with Expr runtime coverage.

Migration

  • Rewrite generated code as let-bound sequential expressions where the last expression is the result.
  • Read tool-result fields with codemode.Get instead of Go type assertions.
  • Replace return/__out patterns with the expression-oriented result model.

Written for commit 73be66c. Summary will update on new commits.

Review in cubic

Raezil added 25 commits August 27, 2026 17:44
@Raezil
Raezil marked this pull request as ready for review August 27, 2026 16:01

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

1 issue found and verified against the latest diff

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/plugins/codemode/codemode.go">

<violation number="1" location="src/plugins/codemode/codemode.go:89">
P1: When `stream.Next()` fails mid-stream, `CallToolStream` currently returns partial items with a nil error, so transport/runtime failures look like success. Handle EOF as completion and return non-EOF errors instead.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

stream, err := api.client.CallToolStream(api.ctx, name, args)
if err != nil { return nil, fmt.Errorf("CallToolStream failed: %w", err) }
items := make([]any, 0)
for { item, err := stream.Next(); if err != nil { return items, nil }; items = append(items, item) }

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: When stream.Next() fails mid-stream, CallToolStream currently returns partial items with a nil error, so transport/runtime failures look like success. Handle EOF as completion and return non-EOF errors instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/plugins/codemode/codemode.go, line 89:

<comment>When `stream.Next()` fails mid-stream, `CallToolStream` currently returns partial items with a nil error, so transport/runtime failures look like success. Handle EOF as completion and return non-EOF errors instead.</comment>

<file context>
@@ -1,567 +1,160 @@
+	stream, err := api.client.CallToolStream(api.ctx, name, args)
+	if err != nil { return nil, fmt.Errorf("CallToolStream failed: %w", err) }
+	items := make([]any, 0)
+	for { item, err := stream.Next(); if err != nil { return items, nil }; items = append(items, item) }
+}
+
</file context>

@Raezil
Raezil merged commit a0edb19 into main Aug 27, 2026
2 checks passed
@Raezil
Raezil deleted the feat/expr-codemode branch August 27, 2026 16:11
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