airi/plugins/airi-plugin-claude-code
RainbowBird 08734c1e03
refactor: replace awilix, colorjs.io, debug, and @better-fetch/fetch (#3403)
## Summary

The repository uses one library for each of these jobs, but four
packages still imported a second one. This PR replaces them and bans the
imports in ESLint, so they do not come back.

| Removed | Replacement | Where |
| --- | --- | --- |
| `awilix` | `injeca` | Minecraft agent container |
| `colorjs.io` | `culori` | stage-layouts theme-color meta tag |
| `debug` | `@guiiai/logg` debug level | claude-code plugin `--debug`
flag |
| `@better-fetch/fetch` | `BetterAuthClientPlugin` from
`better-auth/client` | Steam client plugin type |

After this PR, no package imports or declares these four libraries.
Their catalog entries are removed. This PR follows #3032, which banned
`localforage` the same way. It is independent.

## Change map

| Module | Before | After | Description |
| --- | --- | --- | --- |
| Minecraft agent container (`cognitive/container.ts`,
`cognitive/index.ts`) | awilix container, synchronous `resolve(name)` |
injeca container, `await container.resolve(...names)` | Each service is
still built on its first resolve and cached. The rule engine is still
built after spawn and before `perceptionPipeline.init`. The container
logs nothing, as before |
| Theme color (`stage-layouts/composables/theme-color.ts`) | `new
Color(css).to('srgb').toString({ format: 'hex' })` | `parse`,
`toGamut('rgb', 'oklch')`, then `formatHex` or `formatHex8` | Same CSS
Color 4 gamut mapping. Alpha stays only for a translucent color. An
unparseable color leaves the tag unchanged, instead of an unhandled
rejection |
| claude-code plugin CLI (`cli.ts`) | `--debug` enabled `debug`
namespaces that no code wrote to | `--debug` sets the logg logger to the
debug level | The flag keeps its optional value, so existing hook
configs still parse. The unused tsdown helpers are removed |
| Steam client plugin (`stage-ui/libs/steam-auth-client.ts`) | `$fetch:
BetterFetch` from `@better-fetch/fetch` | Object `satisfies
BetterAuthClientPlugin` | `$fetch` takes its type from better-auth.
`linkSteam` and `signIn.steam` keep their types |
| ESLint (`eslint.config.ts`) | Bans `localforage` | Also bans the four
libraries, with the replacement in each message | |

## Boundaries and risks

| Invariant or boundary | Failure mode | Protection | Evidence or gap |
| --- | --- | --- | --- |
| Minecraft services stay singletons | Two instances of the event bus or
task executor | injeca caches each build | A probe resolved every
service twice. The brain got the same `eventBus`, `taskExecutor`, and
`reflexManager`, and repeated resolves returned the same objects |
| Rule engine timing | Rules load before spawn | It is resolved inside
`startCognitive`, before perception starts | The probe showed that the
rule engine loads rules only on its first resolve. Not verified against
a running Minecraft server |
| Spawn handler errors | `startCognitive` is async now, so an error is a
rejected promise | The handler catches it and logs it with the agent
logger | Code review |
| Theme color output | Different hex for the same color | Same gamut
mapping | Compared 11 inputs with both libraries. All match, except that
culori writes the long hex form (`#ffffff00` for `#fff0`) |
| claude-code `--quiet` and `--logLevel` | | | They did not work before
this PR, and they still do not. cac passes no `flags` argument to
`send`. Fixing them changes behavior, so it is out of scope |

## Verification

```text
turbo run typecheck (same filters as pnpm typecheck)        65/65 passed
moeru-lint . (pnpm lint)                                    0 errors
ESLint probe importing each of the four libraries           4 no-restricted-imports errors
stage-ui: vitest use-linked-accounts (node + browser)       9 tests passed
stage-ui: vue-tsc with a probe of authClient.linkSteam,
  authClient.signIn.steam, and a misspelled action          passed, and the misspelled action is a type error
tsx src/run.ts send --debug and send --debug hooks,net      debug level set, "Debugging enabled" logged
tsx src/run.ts send and send --quiet                        same output as main
```

`pnpm typecheck` does not cover `integrations/` or `plugins/`. On those
workspaces, `tsc --noEmit` reports errors, but none is in a changed
file. I did not compare that list with `main`.

Not verified:

- The Minecraft agent with a real server. `vitest run` in
`integrations/minecraft` has 4 failing files on this branch: `brain`,
`js-planner`, `map-renderer`, and `rules`. None imports the container.
They fail on the sandbox worker (`exited with code 9`) and on assertions
that do not involve the container.
- `packages/stage-layouts` `use-chat-interruption.test.ts` fails 7
tests. It does not import `theme-color.ts` or any other changed file.

## Rollout and follow-up

- claude-code plugin: `--quiet` and `--logLevel` have no effect, because
the `send` action reads `flags` from the wrong argument. `--quiet` also
passes `-1` to logg, which logg rejects.
- `uuid` cannot join the ban, because `memory.repo.ts` uses `v7`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 18:53:07 +08:00
..
src refactor: replace awilix, colorjs.io, debug, and @better-fetch/fetch (#3403) 2026-11-05 18:53:07 +08:00
package.json refactor: replace awilix, colorjs.io, debug, and @better-fetch/fetch (#3403) 2026-11-05 18:53:07 +08:00
tsdown.config.ts Revert "style: lint" 2026-08-26 20:13:10 +08:00