Skip to content

feat(sdk): add test-generator example with TS/Python support#6

Open
Deepak-png981 wants to merge 9 commits intocursor:mainfrom
Deepak-png981:feat/sdk-test-generator
Open

feat(sdk): add test-generator example with TS/Python support#6
Deepak-png981 wants to merge 9 commits intocursor:mainfrom
Deepak-png981:feat/sdk-test-generator

Conversation

@Deepak-png981
Copy link
Copy Markdown

@Deepak-png981 Deepak-png981 commented Apr 29, 2026

Summary

  • add sdk/test-generator, a new Cursor SDK cookbook example for local test generation and repair loops
  • support TypeScript/JavaScript projects (Vitest/Jest) and Python projects (Pytest) with framework detection and overrides
  • include both plain CLI and Ink TUI flows with file selection, streaming progress, and per-file diff review (accept/reject)
  • add sample source files and docs, and link the example from the root README

Test plan

  • cd sdk/test-generator && pnpm install
  • cd sdk/test-generator && pnpm typecheck
  • cd sdk/test-generator && pnpm build
  • cd sdk/test-generator && pnpm dev -- --help
  • cd sdk/test-generator && pnpm dev -- examples/sample.ts --yes --overwrite --max-iters=1
  • cd sdk/test-generator && pnpm dev -- --lang python examples/sample.py --yes --overwrite --max-iters=1
image

Note

Medium Risk
Mostly additive example code, but it introduces a new CLI that can execute local test commands and optionally rewrite source files, so reviewers should validate guardrails like overwrite behavior, target file resolution, and cancellation/cleanup.

Overview
Adds a new SDK cookbook example, sdk/test-generator, that uses @cursor/sdk to generate unit tests for selected source files, run them locally, and iteratively prompt the agent to repair failures (optionally allowing source edits).

Includes project detection for TypeScript/JavaScript (Vitest/Jest) and Python (Pytest), a plain CLI mode plus an Ink TUI for file selection/model selection/progress/cancel/diff review, and supporting packaging/docs (new package.json, lockfile, tsconfig, sample files, and root README link).

Reviewed by Cursor Bugbot for commit 14481b8. Bugbot is set up for automated code reviews on this repo. Configure here.

@Deepak-png981 Deepak-png981 force-pushed the feat/sdk-test-generator branch from bf2ed43 to c6e29d0 Compare April 29, 2026 17:28
Add a new SDK example that generates tests, runs framework-native test commands, and iterates on failures so users can see a practical agent + deterministic verification loop in both CLI and TUI flows.
@Deepak-png981 Deepak-png981 force-pushed the feat/sdk-test-generator branch from c6e29d0 to 68aa4b8 Compare April 29, 2026 17:28
Comment thread sdk/test-generator/src/workflow.ts Outdated
Comment thread sdk/test-generator/src/index.ts
Comment thread sdk/test-generator/src/index.ts
Comment thread sdk/test-generator/src/workflow.ts
Comment thread sdk/test-generator/src/workflow.ts
Moved compactText and formatDuration functions from index.ts, session.ts, and AppView.tsx to a new format.ts module for better organization and reusability. Updated imports accordingly.
Comment thread sdk/test-generator/src/session.ts Outdated
Comment thread sdk/test-generator/src/tui/AppView.tsx
Comment thread sdk/test-generator/src/workflow.ts
Comment thread sdk/test-generator/src/prompts.ts
Comment thread sdk/test-generator/src/detector.ts Outdated
Comment thread sdk/test-generator/src/index.ts
Comment thread sdk/test-generator/src/workflow.ts
Improve TUI error handling, make string-heavy helpers use named parameters, and render review diffs with line sequence matching so overwrite reviews are less misleading.
Make max-iteration parsing use named arguments and apply shared ignore globs when resolving explicit glob and directory targets.
@Deepak-png981 Deepak-png981 force-pushed the feat/sdk-test-generator branch from 99f1b0d to fb1bddd Compare April 29, 2026 18:15
Comment thread sdk/test-generator/src/detector.ts
Preserve source subdirectories under the generated tests directory so same-named Python files in different folders do not overwrite each other's tests.
Comment thread sdk/test-generator/src/workflow.ts Outdated
Comment thread sdk/test-generator/src/workflow.ts
Use named arguments for diff helpers and restore source content when rejecting an agent run that was allowed to edit source files.
Comment thread sdk/test-generator/src/tui/AppView.tsx Outdated
Comment thread sdk/test-generator/src/tui/AppView.tsx
Comment thread sdk/test-generator/src/workflow.ts Outdated
Clamp empty picker navigation, stop multi-file generation on cancel, and remove the unused iterations field from generated file results.
Comment thread sdk/test-generator/src/tui/AppView.tsx
Comment thread sdk/test-generator/src/workflow.ts
Comment thread sdk/test-generator/src/index.ts
Comment thread sdk/test-generator/src/detector.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high mode and found 3 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 14481b8. Configure here.

Comment thread sdk/test-generator/src/tui/AppView.tsx
Comment thread sdk/test-generator/src/tui/AppView.tsx
Comment thread sdk/test-generator/src/index.ts
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