save_code: write the generated script to a file instead of round-tripping it through context

Aperta
#206 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
65/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
nodejs, typescript
Ambito
tooling

Direzione di ricerca

Start from the handler that serves the wdio://session/current/code resource and the {sessionId} template, since save_code must produce the same text; then look at how existing tools are registered and how they resolve the current session. Implement save_code({ path, session? }) so it writes that text with the filesystem API and returns path, line count and step count, with a description noting it only works over stdio. Done when a test writes a script to a temp path and asserts the returned counts; see #178 for the related opt-in file output idea.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Target: main. Standalone: does not wait on #178 or #184.

Problem. To get the generated WebdriverIO script into the user's project, an agent reads wdio://session/current/code (or the {sessionId} template) into its context, then writes the same text out with its own file tool. That pays for the script twice in tokens, and long scripts risk transcription errors. Anthropic's "code execution with MCP" article gives this exact pattern (read a document in, write it back out) as the main waste of passing data through the model.

Proposal. A save_code tool: save_code({ path, overwrite?, session? }) writes the script generated by src/recording/code-generator.ts for the current (or named) session to path and returns the path, the line count and the number of steps. It is session-targeted, not sessionless.

Only meaningful when the server and the agent share a filesystem (stdio). Under --http the path is on the server's disk, and the description should say so.

Related: #178 (opt-in file output for large tool results) is a different case: that one writes tool output, this one writes the session's code.

Acceptance

  • path may be absolute or relative to the server's working directory; the result always reports the resolved absolute path.
  • Refuses to overwrite an existing file unless overwrite: true.
  • Returns path, lines and steps.
  • Session-targeted (routed through withSessionTarget).
Lingua principale
TypeScript
Stelle
45
Fork
20
Merge medio
2g 9h
PR unite (30g)
16

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webdriverio/mcp

Tutte le issue di webdriverio/mcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.