KScript Dokumentation
DE

Sprache

Automatisch aus dem Englischen übersetzt; das englische Original ist maßgeblich.

Coding-Agenten

Hinweise zu eingebauten Befehlen

Pakete fügen ihren Befehlen, Methoden und Elementen dieselbe Art von Hinweisen hinzu, neben deren Beispielen. Die Paketdateien zeigen sie unter jedem Eintrag an:

Text
- `->push(items...): list` A new list with items added to the end.
  - pitfall: Returns a new list and leaves the old one alone: write items = $items->push($x).
  - e.g. `[1, 2]->push(3, 4)`
- `@api(url: string, options?: map): response` Makes an HTTP request and returns the response.
  - `options.timeout: duration` Maximum wait for an outbound HTTP(S) request. Example `30s`.
  - prefer: @api($url, as: Type) (the same as ->check()->convert(from: json, as: Type)) to fail fast and check the data's shape.
  - pitfall: A 4xx or 5xx status doesn't throw: chain ->check() (throws Network) or test .is_ok.

Ein Paket in C# fügt sie mit p.AgentNotes(("list->push", new AgentNotes(pitfall: "..."))) hinzu, geschlüsselt wie p.Examples ("@api", "list->push" oder "<input>" für ein Element). Halte jeden Hinweis auf eine kurze Zeile, da Agenten sie alle lesen.