@chipschat/opencode 1.0.6 → 1.0.9

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.
package/README.md CHANGED
@@ -8,12 +8,20 @@ server (`opencode serve`, 2.0).
8
8
  there speaks to it. It shows in OpenCode's own apps too.
9
9
  - A new agent a person asks for in a room (Add, then a new one) runs as the first OpenCode agent,
10
10
  in a session of its own.
11
+ - A space a person asks for from Chips's + is claimed under a new agent, which answers its first
12
+ words the same way.
11
13
  - A copy of an agent a person asks for in another room (Fork) is a copy of its session in its own
12
14
  room, in the same folder: it remembers what the agent did there, and from then on the two
13
15
  remember apart.
14
16
  - Restart on the harness's page restarts the OpenCode server the bridge runs (see [Restart](#restart)).
17
+ - Each agent's page shows its model and the files OpenCode builds it from, which a person may
18
+ change there, and how full its context window is, which a person may compact from there (see
19
+ [Models](#models), [Context files](#context-files) and [Context window](#context-window)).
15
20
 
16
- Apache-2.0. Not published: a local repository until Chips's SDK is.
21
+ A bridge that joins with a code asks for all of these. One that joined from Chips's gallery does
22
+ what its card grants: a link carries what the person chose on it, not what the bridge asks for.
23
+
24
+ Apache-2.0, published on npm as `@chipschat/opencode`.
17
25
 
18
26
  ## What Chips shows
19
27
 
@@ -28,10 +36,14 @@ Apache-2.0. Not published: a local repository until Chips's SDK is.
28
36
  | Files in the reply | each `MEDIA:<path>` line of its own in the answer, taken out of the words and sent from the session's folder (the agent's own), as OpenCode says it (each turn is told how); a file outside it is refused, and the reply says so |
29
37
  | Cost and tokens | each model call's `session.step.ended`: OpenCode's own cost, as a step's share |
30
38
  | The context gauge | the last call's tokens against the model's window from `GET /api/model` |
39
+ | An agent's model (Chips ADR 0241) | the models `GET /api/model` lists that OpenCode runs, each with its variants as levels; a person's pick put on the agent's session before its next message with `POST /api/session/{id}/model` (see [Models](#models)) |
40
+ | An agent's files (Chips ADRs 0134, 0241) | the `AGENTS.md` files OpenCode reads for its folder, and from OpenCode 2.0.30 (`GET /api/info`) the files its config's `instructions` names (`GET /api/config`); a person's edit saved where OpenCode reads it (see [Context files](#context-files)) |
41
+ | An agent's context window (Chips ADRs 0146, 0241) | its session's last model call's tokens, of its model's context limit from `GET /api/model`; Compact now is `POST /api/session/{id}/compact`, and `session.compaction.started`, `.ended` and `.failed` say how it went (see [Context window](#context-window)) |
31
42
  | An approval card | `permission.asked` → `POST …/permission/{id}/reply`: `always` when a person said always, else `once`, and `once` for a command, which Chips remembers by how each part starts (Chips ADR 0239); `reject` with their reason for a no. One answered in OpenCode's own apps is settled in Chips (ADR 0079) |
32
43
  | A question | a `form.created` whose fields are choices or yes-or-no, at most four → `POST …/form/{id}/reply` |
33
44
  | Stop | `POST …/interrupt`, and the words OpenCode hasn't taken yet taken back |
34
45
  | A steer, a follow-up, an interrupt | a prompt with `delivery: "steer"`; with `"queue"`; interrupt, then a prompt |
46
+ | A space from Chips's + (Chips ADR 0241) | claimed under a new agent, named from the first line of its first words; the agent answers them as the first OpenCode agent, in a session and a folder of its own |
35
47
  | Fork (Chips ADR 0087): a copy of an agent in another room | `POST /api/session/{id}/fork` of the agent's session in its room, which copies what it remembers; then `PATCH /api/session/{id}` names the copy for its room and marks it as the copy's. The copy is registered after it (*Nova · fork* for Nova), `forkedFrom` the original, for the room asked, and works in the original's folder. An ask heard again registers the same copy; an agent that never spoke in its room is copied as a new one with nothing to remember |
36
48
  | Not right? on an agent's reply (Chips ADR 0200), or a 👎 from an older device | a run of the agent who said it, in its session for the room, after its turns there: a prompt with its reply, what wasn't right, and to answer again in its place; the goal is *Looking again:* and the note's first line. A 👍, or any other reaction, is nothing |
37
49
  | Trouble on the harness | `GET /api/info` every 30 s |
@@ -50,11 +62,63 @@ Not yet:
50
62
  OpenCode's own apps.
51
63
  - A question answered in OpenCode's own apps stays open in Chips. The protocol has no way to take
52
64
  one back yet.
53
- - OpenCode's models as the agent's Model group in Chips. Its commands, skills and context files.
54
- - Fork for a bridge that joined from the gallery: its card grants `agents` and `new_agents`. A
55
- bridge that joins with a code asks for `forks` as well.
65
+ - OpenCode's commands and skills in Chips.
56
66
  - More than one OpenCode server per bridge.
57
67
 
68
+ ## Models
69
+
70
+ An agent's Model group in Chips (Chips ADR 0241) offers the models OpenCode's server runs: those
71
+ of the providers it is set up with (`GET /api/model`), less any disabled or retired, at most 40.
72
+ Each model's levels are its variants in OpenCode (`low`, `high`, `max` and so on), lowest first.
73
+
74
+ What an agent runs on, with no model of its own picked in Chips, is its `model` in the bridge's
75
+ config ("As in config.json"), else its OpenCode agent's model (`GET /api/agent`), else the server's
76
+ default (`GET /api/model/default`): "OpenCode's default". A person's pick, a model and a level, is
77
+ kept in `sessions.json`, not written into OpenCode's config. Before each message for the agent the
78
+ bridge puts the session it goes to on it (`POST /api/session/{id}/model`), where it isn't on it
79
+ already, and a new session is made on it. Picking the default again puts the agent's sessions back
80
+ on that before their next message. A copy made by Fork runs on what its original runs on. OpenCode
81
+ takes any model there, so the bridge refuses one its catalogue doesn't run, and a level its model
82
+ doesn't have, in so many words.
83
+
84
+ ## Context files
85
+
86
+ An agent's Context group in Chips (Chips ADRs 0134, 0241) lists the files OpenCode 2 builds it
87
+ from. OpenCode reads `AGENTS.md` only, never `CLAUDE.md` in its place: its own
88
+ (`~/.config/opencode/AGENTS.md`), then the `AGENTS.md` of the agent's folder and of each folder
89
+ above it, up to your home folder, or for a folder outside it up to its project's root. From 2.0.30
90
+ it reads after them the files its config's `instructions` names. It reads them all again before
91
+ each model call and tells the agent what changed, so an edit applies from its next message.
92
+
93
+ - The agent's own, which a person may change from its page: its folder's `AGENTS.md`, shown empty
94
+ until there is one, and any file `instructions` finds in its folder.
95
+ - The harness's own set, on its page: `~/chips-opencode/agents/AGENTS.md`, which every agent
96
+ reads and a person may change; any `AGENTS.md` above it; and your own, with the files
97
+ `instructions` names elsewhere, which your own OpenCode reads too, so they are shown and not
98
+ changed.
99
+
100
+ An edit is saved only if the file is still the one the person changed; otherwise Chips says it
101
+ changed meanwhile. A copy made by Fork works in its original's folder, so it reads the same files.
102
+ A URL in `instructions` isn't shown, nor is the `AGENTS.md` of a folder inside the agent's, which
103
+ OpenCode reads only once the agent reads a file there. With a `directory` in the config, every
104
+ agent's own files are that project's.
105
+
106
+ ## Context window
107
+
108
+ An agent's Context window group in Chips (Chips ADRs 0146, 0241) says how full its session is: the
109
+ tokens of its last model call, all it read and all it wrote, of its model's context limit. An
110
+ agent has a session in each space it is in, and Chips one window for it, so the group is of the
111
+ session that worked last; a bridge from before 1.0.7 reads it from that session's newest model
112
+ call when it starts. A turn that went past half the window says how full it got, and how often
113
+ OpenCode compacted it meanwhile.
114
+
115
+ Compact now asks OpenCode to compact that session (`POST /api/session/{id}/compact`): at once
116
+ when it is idle, and at its next step when it is working. OpenCode's events say when it starts and
117
+ how it went: what it held before, and after it the summary it wrote and the recent words it kept
118
+ as they were, these counted at four characters a token until its next model call says exactly.
119
+ OpenCode compacts a session itself when it is nearly full, as its config's `compaction` says, and
120
+ takes no other limit, so Chips shows the limit as OpenCode's own and doesn't offer one.
121
+
58
122
  ## Restart
59
123
 
60
124
  Where the bridge runs OpenCode's server itself (no `url` in the config), a person can restart it
@@ -75,28 +139,27 @@ configured the other keeps what it was granted when it joined:
75
139
  - Joined with a `url`, then running its own server: the bridge hears restarts, but Chips draws no
76
140
  Restart until you turn on *Be restarted from Chips* on the harness's page.
77
141
 
78
- A link carries what the person chose on it, not what the bridge asks for. The gallery's card for
79
- OpenCode doesn't grant `restarts` yet, so a bridge joined from it gets Restart once you turn it on
80
- on its page.
142
+ The gallery's card for OpenCode grants `restarts`, so a bridge joined from it before the card did
143
+ gets Restart once you turn it on on its page.
81
144
 
82
145
  ## From Chips's gallery
83
146
 
84
- The card's line is `chips connect opencode '<link>'` (Chips ADR 0218). It downloads this bridge as the npm package
147
+ The card's line is `CHIPS_JOIN_LINK='<link>' chips connect opencode` (Chips ADR 0218). It downloads this bridge as the npm package
85
148
  `@chipschat/opencode`, the newest 1.x, checks it against the registry's checksum, and runs it on the Node
86
149
  that Chips carries, so the machine needs no Node or npm of its own. The bridge checks OpenCode,
87
150
  joins, and keeps itself running from login. `chips disconnect opencode` stops it. On another computer,
88
- `curl -fsSL https://chipschat.ai/install | sh -s -- connect opencode '<link>'` installs Chips there
151
+ `curl -fsSL https://chipschat.ai/install | CHIPS_JOIN_LINK='<link>' sh -s -- connect opencode` installs Chips there
89
152
  first. The steps below run the bridge from this checkout instead, to work on it.
90
153
 
91
154
  ## Run it
92
155
 
93
156
  1. Install OpenCode (opencode.ai), and `npm install` once in this repository.
94
157
 
95
- 2. Join Chips once, with a link from Chips's gallery (Add an agent → OpenCode), whose card gives
158
+ 2. Join Chips once, with a link from Chips's gallery (Agents → Connect a harness → OpenCode), whose card gives
96
159
  this line with the link in it:
97
160
 
98
161
  ```
99
- cd ~/Work/Chips/chips-opencode && CHIPS_JOIN_LINK='<link>' npm run keep
162
+ cd chips-opencode && CHIPS_JOIN_LINK='<link>' npm run keep
100
163
  ```
101
164
 
102
165
  The bridge runs OpenCode's server itself (`opencode serve` on `127.0.0.1`, 4096 when it is
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/main.js` in @chipschat/opencode 1.0.6 carries these packages, bundled in. Each one's
3
+ `dist/main.js` in @chipschat/opencode 1.0.9 carries these packages, bundled in. Each one's
4
4
  licence follows.
5
5
 
6
6
  ## @chipschat/harness 0.0.0 (Apache-2.0)