From 69e8bab6efbc0394aecb9ce416eea27da755a5df Mon Sep 17 00:00:00 2001 From: Erik Kotsiuba Date: Mon, 22 Jun 2026 01:10:11 +0200 Subject: [PATCH] feat: add remote ask event contract Inspired-by: @S1M0N38 in PR #6 --- README.md | 2 +- docs/README.md | 4 +- docs/architecture.md | 2 + docs/contract.md | 15 ++ docs/remote-events.md | 187 +++++++++++++ package.json | 2 + src/answer-commands.ts | 34 ++- src/ask-tool.ts | 18 +- src/index.ts | 6 +- src/remote-ask.ts | 559 +++++++++++++++++++++++++++++++++++++++ src/ui/controller.ts | 49 +++- tests/remote-ask.test.ts | 272 +++++++++++++++++++ 12 files changed, 1136 insertions(+), 14 deletions(-) create mode 100644 docs/remote-events.md create mode 100644 src/remote-ask.ts create mode 100644 tests/remote-ask.test.ts diff --git a/README.md b/README.md index 75082dd..563c85c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # @eko24ive/pi-ask [![npm downloads](https://badgen.net/npm/dm/@eko24ive/pi-ask)](https://www.npmjs.com/package/@eko24ive/pi-ask) -[![last commit](https://badgen.net/github/last-commit/eko24ive/pi-ask?v=bf3c26d)](https://github.com/eko24ive/pi-ask/commits/main) +[![last commit](https://badgen.net/github/last-commit/eko24ive/pi-ask?v=fa89c15)](https://github.com/eko24ive/pi-ask/commits/main) [![stars](https://badgen.net/github/stars/eko24ive/pi-ask)](https://github.com/eko24ive/pi-ask/stargazers) `@eko24ive/pi-ask` is an ask tool that cares about your answers. diff --git a/docs/README.md b/docs/README.md index f255a7a..8347c6c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,8 @@ This folder keeps only the documentation needed to understand and maintain the e ## Files - `configuration.md` — source of truth for configuring pi-ask keymaps, behaviour, and `/answer` extraction -- `contract.md` — external behavior, full tool payload/result details, and UX guarantees +- `contract.md` — external behavior, tool payload/result details, and UX guarantees +- `remote-events.md` — local inter-extension event contract, bridge examples, and smoke-test steps - `architecture.md` — module boundaries and invariants - `../skills/ask-user/SKILL.md` — auto-bundled agent-side decision-gate guidance; enabled by default, but can be disabled via `pi config`; inspired by https://github.com/edlsh/pi-ask-user @@ -13,6 +14,7 @@ This folder keeps only the documentation needed to understand and maintain the e - start with `configuration.md` for config-editing rules - read `contract.md` for behavior +- read `remote-events.md` for local bridge/event integration - read `architecture.md` for code layout ## Local test run diff --git a/docs/architecture.md b/docs/architecture.md index fb562a0..50600ba 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -19,6 +19,7 @@ The codebase is split so the implementation reads through file boundaries and na - `src/answer-extraction.ts` — configured extraction model selection and raw-JSON extraction retries - `src/ask-payload-store.ts` — branch-aware persisted ask payload lookup - `src/notifications.ts` — best-effort ask notification payload rendering and channel execution +- `src/remote-ask.ts` — package-prefixed local event contract, active-flow registry, and explicit remote submission validation - `src/schema.ts` — TypeBox schema - `src/types.ts` — shared types @@ -86,6 +87,7 @@ The codebase is split so the implementation reads through file boundaries and na - legacy root config files are read as a fallback only when the current config file is absent; disk is left untouched - invalid config files are left untouched; defaults are loaded for the session with a notice - live config updates can affect an in-progress ask flow immediately +- remote ask submissions must be explicit `answer` or `cancel` responses; pi-ask validates ids/values but never infers approve/deny semantics from labels or option values ## Documentation rule diff --git a/docs/contract.md b/docs/contract.md index ec7d3f9..b338e7f 100644 --- a/docs/contract.md +++ b/docs/contract.md @@ -267,6 +267,21 @@ The ask flow subscribes to runtime settings updates while open. In practice, thi When enabled, pi-ask emits one best-effort external notification per ask session after the ask UI opens and waits for input. The default title is `pi ask`; the message is `Question waiting: