Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,29 @@ Before stabilizing the client API:
## Flagged ambiguities

- Legacy `experimental.chat.system.transform` can mutate the assembled baseline system prompt arbitrarily, but V2 plugins do not yet expose an equivalent hook. Decide separately whether to port it, replace dynamic uses with plugin-defined **Context Sources**, or narrow its semantics.

---

## Projekt-Metadaten (gepflegt von opencode)

Letzte Änderung: 2026-07-12

### Verzeichnisstruktur

| Pfad | Beschreibung |
|---|---|
| `packages/opencode/src/util/process.ts` | Process-Spawning/-Management inkl. `stop()` |
| `packages/opencode/src/lsp/` | LSP-Integration (client, server, launch) |
| `packages/opencode/src/mcp/` | MCP-Integration |

### Befehle (aus `packages/opencode/`)

```bash
bun typecheck # Typ-Prüfung
bun test # Tests (fehlgeschlagene)
bun dev # TUI starten
```

### Letzte Änderungen

- **2026-07-12**: `Process.stop()` in `util/process.ts` gefixt – SIGTERM → 5s Timeout → SIGKILL-Eskalation (bisher nur SIGTERM ohne Fallback). Gleicher Fix in SDK-Kopie `packages/sdk/js/src/process.ts`.
34 changes: 26 additions & 8 deletions packages/opencode/src/util/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,38 @@ export async function run(cmd: string[], opts: RunOptions = {}): Promise<Result>

// Duplicated in `packages/sdk/js/src/process.ts` because the SDK cannot import
// `opencode` without creating a cycle. Keep both copies in sync.
async function waitForExit(proc: ChildProcess): Promise<void> {
if (proc.exitCode !== null || proc.signalCode !== null) return
await new Promise<void>((resolve) => {
proc.once("exit", () => resolve())
proc.once("error", () => resolve())
})
}

export async function stop(proc: ChildProcess) {
if (proc.exitCode !== null || proc.signalCode !== null) return

if (process.platform !== "win32" || !proc.pid) {
proc.kill()
return
if (process.platform === "win32" && proc.pid) {
const out = await run(["taskkill", "/pid", String(proc.pid), "/T", "/F"], {
nothrow: true,
})
if (out.code === 0) return
}

const out = await run(["taskkill", "/pid", String(proc.pid), "/T", "/F"], {
nothrow: true,
})
proc.kill("SIGTERM")
if (proc.exitCode !== null || proc.signalCode !== null) return

if (out.code === 0) return
proc.kill()
const timeout = 5_000
const exited = waitForExit(proc)
const timer = new Promise<void>((resolve) => {
setTimeout(() => {
try {
proc.kill("SIGKILL")
} catch {}
resolve()
}, timeout)
})
await Promise.race([exited, timer])
}

export async function text(cmd: string[], opts: RunOptions = {}): Promise<TextResult> {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/js/src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function stop(proc: ChildProcess) {
const out = spawnSync("taskkill", ["/pid", String(proc.pid), "/T", "/F"], { windowsHide: true })
if (!out.error && out.status === 0) return
}
proc.kill()
proc.kill("SIGTERM")
}

export function bindAbort(proc: ChildProcess, signal?: AbortSignal, onAbort?: () => void) {
Expand Down
Loading