Files
moeka-project/packages/stage-ui
Garfield Lee cf6ff23f7c refactor(core-agent): move spark-command agent from stage-ui to core-agent (#2528)
## Summary

Move `spark-command` and `spark-notify` agents from
`packages/stage-ui/src/tools/character/orchestrator/` to
`packages/core-agent/src/agents/` for better separation of concerns and
reusability across packages.

## Changes

- **Relocate spark-command agent** — moved `spark-command-shared.ts`,
`spark-command.ts`, and `spark-command.test.ts` to
`packages/core-agent/src/agents/spark-command/`
- **Relocate spark-notify test** — moved `spark-notify.test.ts` to
`packages/core-agent/src/agents/spark-notify/`
- **Add barrel export** — created
`packages/core-agent/src/agents/spark-command/index.ts` with re-exports
- **Update package.json** — added `./agents/spark-command` entry in
`packages/core-agent/package.json`
- **Update build config** — added `src/agents/spark-command/index.ts` to
`tsdown.config.ts` entry list
- **Consolidate schemas** — merged duplicate
`sparkNotifyCommandGuidanceSchema` into `sparkCommandGuidanceSchema`
- **Add JSDoc** — added `@example` blocks to all normalize functions in
`schema.ts`
- **Update imports** — provider tests and `tool-resolver.ts` now import
from `@proj-airi/core-agent/agents/spark-command`
- **Delete legacy shims** — removed `stage-ui/src/tools/character/`
re-export layer

## Verification

```bash
pnpm -F @proj-airi/core-agent typecheck
pnpm -F @proj-airi/stage-ui typecheck
pnpm -F @proj-airi/core-agent exec vitest run
pnpm lint
```
2026-09-12 09:34:05 +08:00
..
2026-03-12 05:09:32 +08:00
2026-08-26 20:13:10 +08:00
2026-08-26 20:13:10 +08:00
2026-08-26 20:13:10 +08:00

Stage UI

Shared core for stage

Character-card module settings

The card store owns three distinct states:

  • moduleDefaults stores global provider, model, voice, and display selections.
  • Each card stores explicit overrides. An empty string means inherit.
  • Module stores expose the resolved runtime selections used by the application.

Use configureForAuthentication for login and logout. It updates global defaults, then reapplies the active card without saving defaults into that card. Use card commands for activation and explicit edits. Settings pages must not save cards from watchers: authentication and remote snapshots also trigger them. The synchronization leader owns these commands; followers receive snapshots.

Models inherit only within the same provider. Voices also require the same model. A different provider without a model stays unconfigured rather than receiving an unrelated model id. The editor requires a model for an explicit chat or vision provider unless that model can be inherited safely.

Defaults are seeded once from the current runtime on upgrade. This cannot recover historical global values that an older card already overwrote. Existing speech-noop selections are preserved because they may represent intentional silence. Users can explicitly choose Inherit global settings in the editor; importing or saving an unrelated card field does not change it.

Button analytics

Register the shared plugin once in each Vue application:

import { trackButtonPlugin } from '@proj-airi/stage-ui/directives/track-button'

createApp(App)
  .use(trackButtonPlugin)
  .mount('#app')

Buttons that represent a product-analysis click intent can then declare a typed event without wrapping their business handler:

<Button
  v-track-button="{ name: 'update_check_clicked', channel: selectedChannel }"
  @click="checkForUpdates()"
/>

Keep async outcomes, confirmed state changes, impressions, and lifecycle events in their owning business flows instead of attaching them to the initial click.

Histoire (UI storyboard)

https://histoire.dev/

pnpm -F @proj-airi/stage-ui run story:dev

Project structure

  1. If a story is bound to a specific component, it can be placed beside the component in the src folder. e.g., MyComponent.story.vue
  2. If a story is not bound to a specific component, then it should be placed in the stories folder. e.g., MyStory.story.vue