summaryrefslogtreecommitdiffhomepage
path: root/.rules/plan/17-20-readme-changelog-examples.md
blob: 55653d5e4fce2c4f440fc5a054ba79cab6ecbe99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Phase 17 — README, CHANGELOG, and examples

**Estimated time:** ~20 minutes
**Touches:**
`README.md`, `CHANGELOG.md`, `AGENTS.md`,
`examples/ask_standing_sitting.rb`,
`examples/usage_per_token.rb`,
`bin/setup`, `bin/console`, `bin/install`, `bin/check`.

## Goal

Replace all remaining user-facing documentation and examples so the gem
ships as a clean MiniMax adapter. By this phase the code and tests are
already clean; this is documentation polish.

## Steps

### 1. Rewrite `README.md`

Top to bottom rewrite. Required sections:

- **Title:** `# dispatch-adapter-minimax`
- **One-paragraph intro:** What it is. "Implements
  `Dispatch::Adapter::Base` for MiniMax via the Anthropic-compatible
  /v1/messages endpoint. Works with the MiniMax Token Plan."
- **Installation:**
  ```ruby
  gem "dispatch-adapter-minimax"
  ```
- **Configuration:**
  - The three API key resolution methods (constructor arg, env var,
    file).
  - Default base URL.
  - Default model.
- **Quick start:** A minimal working snippet showing how to chat.
- **Supported models:** The 7-model table.
- **Supported parameters:** A table mirroring MiniMax's compat docs
  (model, messages, max_tokens, stream, system, temperature,
  tool_choice, tools, top_p, metadata, thinking — all supported;
  top_k, stop_sequences, service_tier, mcp_servers,
  context_management, container — silently stripped).
- **Unsupported content blocks:** Image and document blocks raise
  `ArgumentError` at request-build time.
- **Cache control:** Documented as best-effort; MiniMax docs do not
  list cache_control as a recognized field, so any caching benefit is
  upstream-dependent.
- **Cost / quotas:** `Usage#cost.total_cost` is always `0.0` because
  Token Plan is request-quota; no per-token rate applies.
- **Running tests:** `bundle exec rubocop --autocorrect-all && bundle exec rspec`.
- **Live smoke testing:** Brief note that smoke testing requires a
  real Token Plan API key; not part of CI.

DO NOT carry over any Claude / Anthropic / OAuth / PKCE / Stainless /
Claude Code language. The README must read as if MiniMax was always
the target.

### 2. Rewrite `CHANGELOG.md`

```markdown
# Changelog

## 0.1.0 (unreleased)

- Initial release.
- MiniMax adapter implementing `Dispatch::Adapter::Base` via the
  Anthropic-compatible `/v1/messages` endpoint at
  `https://api.minimax.io/anthropic`.
- Supports MiniMax-M2.7 (default), MiniMax-M2.7-highspeed,
  MiniMax-M2.5, MiniMax-M2.5-highspeed, MiniMax-M2.1,
  MiniMax-M2.1-highspeed, MiniMax-M2.
- Token Plan static API key auth (constructor arg, ENV, or file).
- Streaming and non-streaming `/v1/messages` calls.
- `count_tokens` and `list_models` (best-effort; degrade gracefully if
  the upstream endpoint is unavailable).
- Strict-tool-schema fallback retry on `400 grammar/schema too large`.
- Image and document content blocks raise `ArgumentError`
  (unsupported by MiniMax).
- `Usage#cost` is always `0.0` (Token Plan is request-quota).
```

### 3. Rewrite `AGENTS.md`

Top to bottom. Mirror the Claude AGENTS.md structure but for MiniMax.
Required sections:

- **Purpose:** "Implements `Dispatch::Adapter::Base` for MiniMax via
  their Anthropic-compatible /v1/messages endpoint. Targets the Token
  Plan static API key flow."
- **File map:** updated tree:
  ```text
  lib/dispatch/adapter/minimax.rb
  lib/dispatch/adapter/minimax/
    version.rb
    errors.rb
    key_store.rb
    headers.rb
    pricing_table.rb
    model_catalog.rb
    request_builder.rb
    request_builder/messages.rb
    request_builder/tools.rb
    request_builder/cache_control.rb
    request_builder/thinking.rb
    response_builder.rb
    sse_parser.rb
    stream_collector.rb
    http_client.rb
    data/minimax_pricing.json
  ```
- **Key design decisions:**
  - No OAuth (Token Plan is static-key).
  - `temperature` validated to `(0.0, 1.0]` per MiniMax docs.
  - Image / document content rejected at request-build.
  - Strict-tool-schema fallback uses a broadened regex.
  - `Usage#cost` always 0.0.
- **Constants to track:** None beyond DEFAULT_BASE_URL / DEFAULT_MODEL.
  MiniMax has no equivalent of the Claude Code version + Stainless
  version drift.
- **Running tests:** Same as README.

### 4. Rewrite the examples

`examples/ask_standing_sitting.rb` and
`examples/usage_per_token.rb` (rename the latter — there is no
per-token usage to demonstrate).

DELETE `examples/usage_per_token.rb`. Replace with
`examples/list_models.rb` (or similar) which shows how to call
`adapter.list_models` and prints the resulting catalog.

For `examples/ask_standing_sitting.rb`: rewrite as a minimal MiniMax
hello-world. Example:

```ruby
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# Minimal MiniMax adapter usage example.
# Requires MINIMAX_API_KEY in env, or ~/.config/dispatch/minimax_api_key.

$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "dispatch/adapter/minimax"

adapter = Dispatch::Adapter::MiniMax.new(model: "MiniMax-M2.7", thinking: "high")

response = adapter.chat(
  [Dispatch::Adapter::Message.new(
    role: "user",
    content: [Dispatch::Adapter::TextBlock.new(text: "Say hi in one word.")]
  )],
  system: "You are concise."
)

response.content.each do |block|
  case block
  when Dispatch::Adapter::TextBlock     then puts "[text] #{block.text}"
  when Dispatch::Adapter::ThinkingBlock then puts "[thinking] #{block.thinking}"
  end
end

puts "stop_reason: #{response.stop_reason}"
puts "tokens: #{response.usage.input_tokens} in / #{response.usage.output_tokens} out"
```

DELETE `usage_per_token_error.log` if it still exists in the gem root.

### 5. Update `bin/setup`, `bin/install`, `bin/check`, `bin/console`

These bin scripts probably reference Claude. Rename references and
update any `require` statement to point at `dispatch/adapter/minimax`.

If a bin script does something Claude-specific that has no MiniMax
analogue (e.g. an OAuth login helper), DELETE the script.

### 6. Final cleanup

- Delete `usage_per_token_error.log` from the gem root if present.
- Verify `Gemfile.lock` regenerates cleanly via `bundle install`. If
  the lock is stale, delete it and let `run_tests` rebuild it via
  `bundle install` (the test gate runs bundler).

## Acceptance criteria

- `README.md`, `CHANGELOG.md`, `AGENTS.md` are all rewritten and
  contain ZERO Claude / Anthropic / OAuth / Claude Code references.
- `grep -rn 'Claude\|claude\|anthropic\|Anthropic' README.md CHANGELOG.md AGENTS.md examples/ bin/`
  returns ZERO matches (case-sensitive — except that the words
  "Anthropic-compatible" describing MiniMax's choice of wire format
  ARE allowed in the README and AGENTS.md only as a factual
  description; if you keep them, document why with a comment like
  "MiniMax exposes an Anthropic-compatible /v1/messages endpoint" and
  refine the grep accordingly).
- `examples/` contains no broken Ruby — every script `bundle exec ruby
  examples/<name>.rb` should at least load (it's OK if it then fails
  because no API key is available — that proves the require chain
  works).
- `bin/check` (or equivalent) runs cleanly.
- `bundle exec rubocop --autocorrect-all` exits 0.
- `bundle exec rspec` exits 0 with no skipped or pending examples.

## Verification

Run `run_tests` with `project_path=reference/dispatch-adapter-minimax`.

This is the FINAL phase. The gate is strict:

- Both rubocop and rspec must exit 0.
- No examples may be skipped or pending.
- Documentation greps above must be clean.

After `ask_for_next_plan` is called, the runner should report no
remaining plans and the agent should end its turn.

## Post-plan manual steps (NOT for the agent)

The user will smoke-test against a live MiniMax Token Plan key:

1. `export MINIMAX_API_KEY=<real key>`
2. `cd reference/dispatch-adapter-minimax && bundle install`
3. `ruby examples/<hello>.rb` — expect a real response.
4. Verify `count_tokens` and `list_models` either work or degrade
   gracefully.
5. Verify `cache_control` blocks do not produce 400 errors.
6. If any of those fail, file an issue describing the wire shape and
   we'll add a follow-up plan.