@adaptiqai/opencode 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +129 -2
  2. package/lib/index.js +17896 -0
  3. package/package.json +42 -3
package/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # AdaptiqAI for OpenCode and Kilo
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Your AdaptiqAI workspace in [OpenCode](https://opencode.ai) (1.x from 1.18.29,
4
+ and 2.x) and in [Kilo](https://kilo.ai): its models, conversations that
5
+ AdaptiqAI remembers, and your saved knowledge, in one plugin.
6
+
7
+ ## Install
8
+
9
+ Add the plugin to the harness's config:
10
+
11
+ | Harness | Config | Entry |
12
+ |---|---|---|
13
+ | OpenCode 1.x | `~/.config/opencode/opencode.json` | `"plugin": ["@adaptiqai/opencode"]` |
14
+ | OpenCode 2.x | `~/.config/opencode/opencode.json` | `"plugins": ["@adaptiqai/opencode"]` |
15
+ | Kilo | `~/.config/kilo/kilo.json` | `"plugin": ["@adaptiqai/opencode"]` |
16
+
17
+ Then sign in: run `opencode auth login` (or `kilo auth login`, or `/connect`
18
+ in the app) and choose **AdaptiqAI**:
19
+
20
+ - **Sign in with your browser** opens the AdaptiqAI approval page. You sign in
21
+ (or create an account) and approve, and the harness picks it up by itself.
22
+ - **AdaptiqAI API key** takes a key from the AdaptiqAI console.
23
+ `ADAPTIQAI_API_KEY` in the environment works too.
24
+
25
+ Choose a model from the **AdaptiqAI** provider (`adaptiqai/<model>`). The list
26
+ is the models in your workspace, each with its own output limit and
27
+ thinking levels (OpenCode's variants).
28
+
29
+ ## What it does
30
+
31
+ - **A conversation is one AdaptiqAI session.** Every turn carries the
32
+ harness's session id as `x-adaptiq-session-id`. AdaptiqAI keeps the
33
+ conversation's memory, and the collections and conversations you attach to
34
+ it in the console reach the model.
35
+ - **The harness's own session headers are replaced.** OpenCode and Kilo put
36
+ session headers of their own on every request, title calls too. OpenCode 2
37
+ even puts the root conversation's id in a subagent's `X-Session-Id`. A turn
38
+ goes out with only the plugin's header, a helper call with none.
39
+ - **Helper calls leave nothing.** Titles, compaction and summaries run once,
40
+ marked ephemeral, and never become a conversation. So do Kilo's commit
41
+ messages and branch names, and any request the plugin cannot tell is a turn.
42
+ - **The harness never compacts an AdaptiqAI conversation by itself.**
43
+ AdaptiqAI holds the conversation whole. The harness's own compaction would
44
+ rewrite that history and make the engine compile the conversation again.
45
+ - The plugin leaves its models' context window unknown, which all three
46
+ harnesses read as "never compact automatically". Every other model keeps
47
+ the harness's compaction.
48
+ - Compacting on purpose (`/compact`) still works, once and ephemeral, but
49
+ an unknown window sizes it less well. OpenCode 1.x and Kilo keep no
50
+ recent messages word for word beside the summary, and Kilo 7.8.15 sums
51
+ up one message per request. OpenCode 2 sums up only as much as fits a
52
+ 200k window, and its model list shows the window as 0.
53
+ - A request the gateway refuses as too large (HTTP 413) still makes the
54
+ harness compact.
55
+ - **A subagent names the conversation that started it**
56
+ (`X-Adaptiq-Parent-Session-Id`, role `helper`), so the console folds it
57
+ under that conversation.
58
+ - **Tools for the agent:**
59
+ - `adaptiq_knowledge`: what this conversation uses; search, use or stop a
60
+ collection.
61
+ - `adaptiq_memory`: how full the memory is; the saved collections; keep a
62
+ conversation private.
63
+ - `adaptiq_create_knowledge`: save material as a collection, only when you
64
+ ask.
65
+
66
+ In OpenCode 2 they are on the model's own tool list, not behind Code Mode.
67
+ - **`/adaptiq`** asks the agent where this conversation's memory and
68
+ knowledge stand. OpenCode and Kilo give a plugin's command no way to answer
69
+ by itself, so it is a turn of the model and costs like one. That turn reads
70
+ the conversation and saves nothing: the question and its answer stay out of
71
+ the conversation's memory. Only what you type after `/adaptiq` counts as
72
+ your own words.
73
+
74
+ Signing out in the harness (`opencode auth logout`, or removing the
75
+ credential in OpenCode 2) signs the plugin out too, and the plugin removes
76
+ its own copy of the sign-in, refresh token and all:
77
+
78
+ - OpenCode 2 tells the plugin at once.
79
+ - `opencode auth logout` and `kilo auth logout` change only the harness's
80
+ own file. The plugin removes its copy at the next request, or within five
81
+ minutes while the harness runs, or when the harness next starts.
82
+
83
+ The copy is removed from this computer, not revoked at AdaptiqAI: to
84
+ disconnect this computer altogether, use Connected apps in the AdaptiqAI
85
+ console.
86
+
87
+ OpenCode 1.x and 2.x keep separate AdaptiqAI sign-ins, and so does the
88
+ plugin: signing out of one leaves the other signed in.
89
+
90
+ ## How it fits each harness
91
+
92
+ | | OpenCode 1.x and Kilo (`server()`) | OpenCode 2.x (`setup()`) |
93
+ |---|---|---|
94
+ | Provider and models | added to the config by the `config` hook | `provider.transform`, reloaded when the list changes |
95
+ | Sign-in | `auth` methods; the plugin's own fetch signs each request | integration methods; OAuth `refresh` renews OpenCode's copy |
96
+ | Turn or helper call | `chat.headers` marks it by agent (and Kilo's session ids) | `model.request` by request kind |
97
+ | Session headers | replaced in the plugin's fetch | replaced in `model.request` |
98
+ | Memory field | added in the plugin's fetch | added in `http.request` |
99
+ | No automatic compaction | window left unknown (`limit.context: 0`) | the same |
100
+ | Tools | zod arguments, rebuilt from the core's JSON Schema | the core's JSON Schema, `codemode: false` |
101
+
102
+ A provider that only the config knows never gets a plugin's model list in
103
+ OpenCode 1.x or Kilo, so the models go into the config. The config is read
104
+ once as the harness starts (and again when its connect dialog reloads after a
105
+ sign-in), so the plugin starts with the models it last listed.
106
+
107
+ ## Configuration
108
+
109
+ | Variable | Default |
110
+ |---|---|
111
+ | `ADAPTIQAI_API_KEY` | none: the harness's own sign-in |
112
+ | `ADAPTIQAI_API_BASE` | `https://api.adaptiqai.com` |
113
+ | `ADAPTIQAI_CONSOLE_URL` | `https://memory.adaptiqai.com/memory` |
114
+
115
+ The browser sign-in, the plugin's state and the last model list are kept in
116
+ `adaptiqai/` in the harness's data folder (`~/.local/share/opencode` or
117
+ `~/.local/share/kilo`, or under `XDG_DATA_HOME`), readable by you alone.
118
+ OpenCode 2 shares OpenCode 1.x's data folder, so its copy is in
119
+ `adaptiqai-2/` there.
120
+
121
+ ## Development
122
+
123
+ ```bash
124
+ pnpm install
125
+ pnpm --filter @adaptiqai/opencode run build
126
+ pnpm --filter @adaptiqai/opencode run test
127
+ ```
128
+
129
+ To try it, put the package folder's absolute path in the config's `plugin`
130
+ (or, for OpenCode 2, `plugins`) list.