aia-input-assist
v1.1.1
Published
Drop-in AI writing assistant for any text input or textarea.
Maintainers
Readme
AIA Input Assist
Drop a friendly AI co-writer next to any
<input>or<textarea>with a single call.
AIA Input Assist is a lightweight widget that anchors to focused text fields and offers common AI actions such as rephrase, translate, shorten, and more. It is framework-agnostic, works in plain browser environments, and exposes a tiny API so you can plug in your own AI provider.
Features
- ⚡️ Zero-config install –
API.init()attaches the widget globally. - 🧠 Provider-agnostic – bring your own AI backend (OpenAI proxy, internal API, etc.).
- ♿️ Keyboard/ARIA friendly – keeps focus management intact for accessible forms.
- 🧩 Works with every framework – React/Vue/Svelte/vanilla because it hooks straight into the DOM.
- 🧪 Included mock provider for local development.
Installation
npm install aia-input-assist
# or
yarn add aia-input-assistQuick start
import AIA, { API, providers } from "aia-input-assist";
// Optional: supply your own provider
API.init({
provider: providers.openaiProxy(
"https://your-api-proxy.example.com/query",
process.env.OPENAI_PROXY_KEY!
),
});
// Alternatively, call later via the global helper
window.AIA?.("configure", { theme: "dark" });As soon as API.init() runs, focusing any text field on the page displays the Assist button. Choosing an action runs the configured provider and writes the output back into the field with a smooth “AI typing” animation.
Custom providers
Implement the Provider interface to route actions to your own service:
import type { Provider, ActionId } from "aia-input-assist";
const myProvider: Provider = {
async run(action: ActionId, text: string, params) {
const response = await fetch("/api/assist", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action, text, params }),
});
if (!response.ok) throw new Error("Assist request failed.");
const { result } = await response.json();
return result ?? text;
},
};
API.init({ provider: myProvider });Configuration
API.init({
position: "right", // left | right | top | bottom
theme: "auto", // auto switches with OS theme
actions: ["rephrase", "translate"], // limit visible options
provider: providers.simple(), // quick mock provider
});You can call API.configure later to update these values on the fly. See src/lib/core.ts for documented options.
Examples
examples/react– small React playground powered by Vite. Run with:npm run dev:exampleand open the provided URL.
Feel free to contribute additional framework examples!
Building locally
npm install
npm run buildThis outputs:
dist/aia-input-assist.esm.js– modern module build.dist/aia-input-assist.umd.js– unminified UMD build.dist/aia-input-assist.umd.min.js– minified bundle for CDN usage.- Type definitions alongside the bundles.
Roadmap
- [ ] Multi-step provider pipelines.
- [ ] Plug-and-play CSS themes.
- [ ] Optional history panel.
Have an idea? Open an issue or start a discussion.
Contributing
- Fork and clone the repo.
- Install dependencies with
npm install. - Use
npm run dev:exampleto hack on the React playground while editing the library. - Submit a pull request with a clear description of your changes.
Please make sure your PR keeps TypeScript strict mode happy and adds tests or docs when it makes sense.
License
MIT © AIA Labs. See LICENSE for details.
