Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

index.ts: LoopState is part of the PromptGenerator extension contract but is not re-exported from the package root

Aperta Adatta ai principianti
#39 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

Inizia da src/index.ts e confronta le sue esportazioni pubbliche di tipi con la definizione di LoopState in src/util/loop-state.ts. Controlla l’utilizzo esistente in src/test/loop.test.ts, quindi esegui i test TypeScript pertinenti o la build. Il lavoro è completato quando un consumer può importare LoopState dalla root del package senza usare il sottopercorso non documentato.

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

Descrizione

bug S3

Observed behavior

src/index.ts re-exports the types needed to implement the documented extension points (Agent, PromptGenerator, Reporter) but it does not re-export LoopState. LoopState appears in the public PromptGenerator contract:

// src/prompt-generators.ts
export interface PromptGenerator {
  generate(loopState: LoopState): AsyncIterable<Prompt>;
}

A consumer who follows the README's "Custom Prompt Generator" pattern and depends only on the package root cannot type the loopState parameter:

import type { Prompt, PromptGenerator } from 'loop-the-loop';
import type { LoopState } from 'loop-the-loop';
// error TS2305: Module '"loop-the-loop"' has no exported member 'LoopState'.

The class still has to declare a parameter, so today the only working option is to reach into an undocumented subpath:

import type { LoopState } from 'loop-the-loop/util/loop-state';

The in-tree integration test already does exactly this (src/__test__/loop.test.ts line 18), which suggests it was not a deliberate omission so much as a missing re-export.

Expected behavior

LoopState should be re-exported from src/index.ts so that a downstream PromptGenerator implementation can be written using only import ... from 'loop-the-loop'. The README in fact already advertises this contract:

All extension-relevant types are exported from the package root (src/index.ts)

LoopState is currently the only extension-relevant type that violates that claim.

Minimal reproduction

// repro.ts
import type { Prompt, PromptGenerator } from 'loop-the-loop';
import type { LoopState } from 'loop-the-loop';

class MyGen implements PromptGenerator {
  async *generate(_state: LoopState): AsyncIterable<Prompt> {
    yield { id: '1', prompt: 'hi' };
  }
}
$ tsc --noEmit repro.ts
repro.ts(2,15): error TS2305: Module '"loop-the-loop"' has no exported member 'LoopState'.

Suggested fix

Add a type-only re-export to src/index.ts:

export type { LoopState } from './util/loop-state.js';

LoopState exposes mutating methods (begin, end, save), so a type-only export feels right for the extension surface; consumers of PromptGenerator only need isOutstanding(id) to author a generator.

Severity

S3. The library is still usable: the deep import path works thanks to the "./*" wildcard in package.json#exports. The bug is that the documented extension contract is incomplete, so writing a custom PromptGenerator from the package root currently requires an undocumented internal path.

Lingua principale
TypeScript
Stelle
2
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 joewalker/loop-the-loop

Tutte le issue di joewalker/loop-the-loop

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.