@zq-silk/yui 0.7.1 → 0.8.2

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 (73) hide show
  1. package/ARCHITECTURE.md +27 -28
  2. package/README.md +79 -71
  3. package/dist/cli/commandCatalog.js +283 -136
  4. package/dist/cli/completion.js +3 -3
  5. package/dist/cli/helpRenderer.js +3 -0
  6. package/dist/cli/interactionPolicy.js +48 -33
  7. package/dist/cli/interactiveSelection.js +1 -1
  8. package/dist/cli/invocationRouter.js +3 -2
  9. package/dist/cli/roleWizard.js +8 -8
  10. package/dist/cli.js +189 -93
  11. package/dist/commands/agentCommands.js +5 -5
  12. package/dist/commands/configCommands.js +351 -104
  13. package/dist/commands/configOverview.js +60 -0
  14. package/dist/commands/deliveryGuardPreflight.js +2 -2
  15. package/dist/commands/globalRoleCommands.js +9 -9
  16. package/dist/commands/profileCommands.js +8 -8
  17. package/dist/commands/resourcesCommands.js +6 -5
  18. package/dist/commands/taskCommands.js +111 -59
  19. package/dist/commands/taskRoleRuntimeStatus.js +3 -1
  20. package/dist/commands/telemetryCommands.js +11 -6
  21. package/dist/config/configCatalog.js +42 -0
  22. package/dist/config/yuiConfig.js +80 -35
  23. package/dist/context/sessionBootstrapManifest.js +1 -1
  24. package/dist/controller/clientRuntime.js +0 -2
  25. package/dist/controller/controller.js +21 -9
  26. package/dist/controller/fileSchedulerStoreAdapter.js +409 -79
  27. package/dist/controller/resourceInventory.js +9 -5
  28. package/dist/controller/runtime.js +112 -25
  29. package/dist/controller/runtimeLaunchCoordinator.js +18 -78
  30. package/dist/controller/structuredProviderObservation.js +273 -0
  31. package/dist/doctor/doctor.js +2 -2
  32. package/dist/executor/agentAdapter.js +40 -0
  33. package/dist/executor/agentExecutor.js +31 -7
  34. package/dist/executor/executorRegistry.js +11 -49
  35. package/dist/executor/fileRoleLaunchPlanner.js +115 -37
  36. package/dist/lifecycle/canonicalLifecycleEvent.js +5 -2
  37. package/dist/resources/autoResourceGc.js +3 -1
  38. package/dist/review/reviewConfig.js +0 -2
  39. package/dist/run/agentRun.js +2 -2
  40. package/dist/run/providerRetry.js +29 -16
  41. package/dist/run/providerRetryConfig.js +5 -3
  42. package/dist/runtime/agentHost.js +767 -158
  43. package/dist/runtime/builtinAgentDrivers.js +1 -5
  44. package/dist/runtime/codexAppServerRuntime.js +67 -60
  45. package/dist/runtime/exactControlPlane.js +7 -2
  46. package/dist/runtime/index.js +6 -2
  47. package/dist/runtime/launchBroker.js +30 -8
  48. package/dist/runtime/launchDiagnostics.js +1 -1
  49. package/dist/runtime/providerAuthorityFence.js +24 -0
  50. package/dist/runtime/providerControl.js +63 -0
  51. package/dist/runtime/providerRecoveryDecision.js +55 -0
  52. package/dist/runtime/providerRuntimeIdentity.js +269 -19
  53. package/dist/runtime/runtimeBinding.js +20 -11
  54. package/dist/runtime/structuredProviderHost.js +476 -0
  55. package/dist/runtime/tmuxAdapters.js +143 -42
  56. package/dist/scheduler/activeRoleRunDelivery.js +206 -120
  57. package/dist/scheduler/leaderWakeupProcessor.js +141 -16
  58. package/dist/scheduler/roleRunStall.js +12 -9
  59. package/dist/setup/setupCommand.js +153 -492
  60. package/dist/storage/compatibleTaskStore.js +9 -5
  61. package/dist/storage/migration/productionRegistry.js +169 -0
  62. package/dist/storage/taskStore.js +22 -3
  63. package/dist/telemetry/sqliteTelemetryStore.js +9 -1
  64. package/dist/telemetry/telemetryConfig.js +1 -18
  65. package/dist/telemetry/telemetryStore.js +2 -2
  66. package/dist/telemetry/telemetryWiring.js +6 -5
  67. package/dist/tmux/tmuxManager.js +1 -1
  68. package/dist/web/webSnapshot.js +5 -3
  69. package/i18n/README.zh-CN.md +48 -40
  70. package/package.json +1 -1
  71. package/skills/yui-leader/SKILL.md +12 -5
  72. package/skills/yui-operator/SKILL.md +44 -6
  73. package/skills/yui-runtime/SKILL.md +1 -1
package/ARCHITECTURE.md CHANGED
@@ -201,34 +201,33 @@ context.
201
201
 
202
202
  ## Runtime ownership
203
203
 
204
- tmux owns Agent process lifetimes and observable output. The Controller owns
205
- mailbox delivery, wakeups, Role liveness, and reconciliation. Task attachment
206
- surfaces only attach to an existing pane and cannot create, resume, wake, or
207
- deliver to a managed runtime. Global interactive entry remains an explicit
208
- session-lifecycle operation.
209
-
210
- Task observation is read-only by default. Explicit write access publishes a
211
- Role-scoped tmux lease before revalidating durable Run state. The managed host
212
- also checks that lease before planning or process creation, so either the Run
213
- claim or the writer lease wins and they never share a pane. Writer contention
214
- is transient backpressure rather than a delivery failure: it does not consume
215
- bounded delivery retries, and lease release signals only existing durable work.
216
- Global interactive entry uses the same mechanism at tmux-host scope and
217
- automatically falls back to read-only when another writer already exists.
218
-
219
- Managed Task Claude execution is process-per-Run: the exact Run input is a
220
- stream-json stdin frame submitted at process launch, while native session IDs
221
- carry conversation continuity across processes. The lifecycle binding records
222
- the exact Run submitted at launch. A Controller restart may recover only the
223
- same reserved launch/Run as uncertain until its Provider Hook arrives; a newly
224
- reserved Run cannot reuse an older live Role pane, so its provisional launch
225
- is released, the old owner is fenced through the durable cleanup lane, and the
226
- same Run is retried only after cleanup; pending cleanup prevents a successor
227
- generation from starting early.
228
- Terminal key injection is therefore an interactive compatibility mechanism,
229
- not a managed Claude delivery protocol. Operator and Leader Sessions remain
230
- fixed Task/global Roles; Task Worker Sessions are selected through Role Agent
231
- bindings.
204
+ tmux owns the persistent Agent Host lifetime and observable output. The
205
+ Controller owns mailbox delivery, wakeups, Role liveness, recovery decisions,
206
+ and a durable single-writer authority epoch. The Agent Host owns one structured
207
+ Provider child process and mirrors its output to the pane. Managed prompts are
208
+ never terminal bytes: both Controller and human takeover input become fenced
209
+ Provider-native Turn requests.
210
+
211
+ Run, Conversation, Activation, and Turn identities are independent. A
212
+ Conversation can span Runs and Provider processes; one Activation identifies
213
+ one live process; one Turn identifies one pre-recorded input attempt. A live
214
+ Activation is retained when a later Run reuses the Conversation. Process exit
215
+ ends that Activation, and a resumed process receives a new Activation and a
216
+ higher authority epoch.
217
+
218
+ Task observation uses `task role view`. Explicit takeover requires a live
219
+ managed Run, atomically transfers authority to a human holder, synchronizes the
220
+ same fence to the Host, and only then exposes the PTY input gateway. Detach
221
+ releases authority; `task role release` is an idempotent repair path even after
222
+ the Run has ended. Global interactive entry remains a native session-lifecycle
223
+ operation outside this managed Provider contract.
224
+
225
+ Codex uses a persistent App Server JSON-RPC transport. Claude uses a persistent
226
+ stream-json transport with exact user-message replay acknowledgement. In both
227
+ cases, Yui records Turn intent before writing, accepts only exact Provider
228
+ evidence, and maps an uncertain write to `delivery-unknown` without automatic
229
+ resubmission. Conversation replacement requires exact missing evidence and no
230
+ unsettled input, Turn, Activation, or writer authority.
232
231
 
233
232
  Role desired revisions and Run/Session effective snapshots keep configuration
234
233
  history explicit. Resume compares the complete effective snapshot and
package/README.md CHANGED
@@ -21,21 +21,37 @@ yui setup
21
21
  yui doctor
22
22
  ```
23
23
 
24
- `setup` is interactive. It detects installed Agent CLIs, asks which Agents to configure, selects the default and Operator Agent, and probes each selected CLI for its current models. It configures the Leader and Operator, then explains that the global Worker configuration is copied into new Task Roles and asks whether Worker should reuse Leader or be configured separately. Model selection is followed by that model's supported reasoning efforts. Setup also confirms the Project workspace outside Yui home and offers shell-completion setup. The picker includes the native CLI default and a custom-value option. Running setup again preserves existing Tasks, Roles, and the installation's Project workspace while allowing safe configuration changes. A successful setup ensures the current Home's detached Controller is running before it returns.
25
-
26
- Model and effort are per-Agent Role settings, so Operator, Leader, and the global Worker can use different values even when they share an Agent CLI. Interactive Role flows validate those settings against the selected Agent runtime. Worker Profile model and effort fields are provider-neutral child-execution hints and therefore remain explicit, scriptable values rather than Agent capability selections.
27
-
28
- Setup gives every managed Agent binding the explicit `bypass` permission
29
- strategy. Later Role updates may select `default`, `bypass`, or `configured`;
30
- the last choice exposes that adapter's native permission enums and tool rules.
31
-
32
- Runtime catalogs are refreshed per command and cached under Yui home. If a live probe times out or fails, Yui shows the last cache for the same Agent launch context and clearly marks it as potentially stale; without a matching cache, it offers CLI defaults and custom values. `yui agent capabilities <id>` exposes the same one-pass catalog, including models, model-specific efforts, and other runtime choices such as permissions, search availability, profiles, settings sources, and service tiers.
24
+ `setup` is intentionally minimal. It verifies tmux, reuses or creates one
25
+ available Agent, creates the default workspace outside Yui home, and configures
26
+ both Operator and Leader so the user can start Yui and execute Tasks. It does
27
+ not create Worker, Reviewer, Profile, or review-policy configuration, and does
28
+ not ask for model/effort, permission, or shell completion. The required
29
+ Operator and Leader bindings use Yui's adapter default permission strategy
30
+ (`bypass`); further changes belong under `config role`. Running setup again
31
+ preserves already usable Operator and Leader Roles. A successful setup starts
32
+ the current Home's detached Controller before it returns.
33
+
34
+ All persistent configuration is under `yui config`. `config show` reports the
35
+ complete effective state, while `config --help` introduces each domain and
36
+ shows examples. The Operator can read the same structured catalog with
37
+ `config describe`, explain current values, effects, choices, and activation
38
+ behavior, then apply only changes the user confirms.
39
+
40
+ Durable settings are grouped by responsibility: `config system` for Home
41
+ defaults and presentation, `config runtime` for Controller health, concurrency,
42
+ launch, delivery, and Provider retry, `config workflow` for Leader/context/review
43
+ policy, `config resources` for quarantine and GC, and `config tools` for tmux
44
+ and diagnostic telemetry. Configured Agents, global Roles, Profiles, and shell
45
+ completion remain the sibling `config agent|role|profile|completion` domains.
46
+ Use `show`, `set`, and `clear` consistently within each durable-settings domain.
47
+
48
+ Runtime catalogs are refreshed per command and cached under Yui home. If a live probe times out or fails, Yui shows the last cache for the same Agent launch context and clearly marks it as potentially stale; without a matching cache, it offers CLI defaults and custom values. `yui config agent capabilities <id>` exposes the same one-pass catalog, including models, model-specific efforts, and other runtime choices such as permissions, search availability, profiles, settings sources, and service tiers.
33
49
 
34
50
  `completion` is also interactive, with or without an explicit shell:
35
51
 
36
52
  ```sh
37
- yui completion
38
- yui completion zsh
53
+ yui config completion
54
+ yui config completion zsh
39
55
  ```
40
56
 
41
57
  Both forms confirm the generated script, installation path, and shell startup-file change. The installed completion is generated from the command catalog, including nested subcommands.
@@ -214,7 +230,8 @@ record-schema change, the integrating branch must supply the complete adjacent
214
230
  path (including an explicit `0->1` introduction for a new family) and re-test to
215
231
  convergence.
216
232
 
217
- Setup also seeds four reusable Worker Profiles:
233
+ Yui provides four reusable Worker Profile definitions through
234
+ `yui config profile reset`; minimum setup leaves them unconfigured:
218
235
 
219
236
  ```text
220
237
  worker explorer implementer reviewer
@@ -270,16 +287,16 @@ timezone with:
270
287
 
271
288
  ```sh
272
289
  yui config show
273
- yui config set time-zone Europe/London
290
+ yui config system set time-zone Europe/London
274
291
  ```
275
292
 
276
293
  WorkItem review is one global, optional rule that reuses an existing Global
277
294
  Role's Agent, model, permissions, prompt, and Skills:
278
295
 
279
296
  ```sh
280
- yui config set review --role reviewer --trigger always
297
+ yui config workflow set review --role reviewer --trigger always
281
298
  yui config show
282
- yui config clear review
299
+ yui config workflow clear review
283
300
  ```
284
301
 
285
302
  For Project-backed software delivery, use `--trigger final` to keep WorkItem
@@ -287,7 +304,7 @@ acceptance and Integration independent and run one fresh ReviewRound over the
287
304
  complete frozen integrated Task candidate before completion:
288
305
 
289
306
  ```sh
290
- yui config set review --role reviewer --trigger final
307
+ yui config workflow set review --role reviewer --trigger final
291
308
  ```
292
309
 
293
310
  Every result entering Leader acceptance is one explicit candidate on its
@@ -467,7 +484,7 @@ Create a Task-bound Worker instance from the configured global Worker, apply a
467
484
  Profile, and dispatch a WorkItem:
468
485
 
469
486
  ```sh
470
- yui role show worker
487
+ yui config role show worker
471
488
  yui task role add <task-id> implementer --profile implementer
472
489
  yui task role show <task-id> implementer
473
490
 
@@ -538,7 +555,7 @@ yui task work create <task-id> "Review the implementation" \
538
555
  --objective "Return source-backed findings" \
539
556
  --accept "Every finding identifies an affected path"
540
557
  yui task work update <task-id>/<work-item-id> running
541
- yui profile show reviewer
558
+ yui config profile show reviewer
542
559
  ```
543
560
 
544
561
  Subagent creation and result delivery happen inside the Leader's native Agent
@@ -642,55 +659,46 @@ yui task complete <task-id> --summary-file delivery.txt --refresh-remote
642
659
  yui task reopen <task-id>
643
660
  ```
644
661
 
645
- Completed Tasks reject messages, dispatch, enter, retry, and late yields until explicitly reopened, while retaining Task main for inspection or integration. Every isolated WorkItem worktree must be explicitly cleaned as integrated or abandoned before archive; that cleanup also removes its managed branch. Archive requires `--integrated` or `--abandon` to state the Task main outcome and is allowed only after Task main is clean. It removes managed worktrees but retains Task and WorkItem records. The Task main branch is retained as a recovery artifact instead of being silently deleted.
662
+ Completed Tasks reject messages, dispatch, Provider authority changes, retry, and late yields until explicitly reopened, while retaining Task main for inspection or integration. Every isolated WorkItem worktree must be explicitly cleaned as integrated or abandoned before archive; that cleanup also removes its managed branch. Archive requires `--integrated` or `--abandon` to state the Task main outcome and is allowed only after Task main is clean. It removes managed worktrees but retains Task and WorkItem records. The Task main branch is retained as a recovery artifact instead of being silently deleted.
646
663
  Task lifecycle completion/selection only suggests valid source states: Draft for activate, active for complete, and completed for reopen.
647
664
 
648
665
  ## Sessions and tmux
649
666
 
650
- tmux owns Agent process lifetimes and their observable output. Global Operator
651
- and global Role sessions remain native interactive CLIs. A managed Task Claude
652
- Run instead starts one finite Claude process with `--print`, stream-json input
653
- and stream-json output. Yui writes the exact Run prompt as one newline-delimited
654
- JSON user frame on stdin, drains output concurrently, and carries native
655
- continuity with Claude's session ID. Startup and delivery therefore never
656
- depend on a TUI composer, readiness glyph, paste delay, or a synthetic Enter
657
- key. Codex keeps its adapter-native launch-prompt and structured callback path.
658
-
659
- `task enter` and `task role enter` are pure attachments to an existing Task
660
- Role pane. They do not start the Controller, prepare a workspace, create or
661
- resume an Agent, wake a Role, or deliver input. Task attachments default to
662
- `--read-only`; `--read-write` is explicit and is rejected while that Role owns
663
- an active managed Run, a managed Claude process is still exiting, or another
664
- writer owns the same pane. A read-write attach first publishes a Role-scoped
665
- tmux writer lease and then revalidates durable Run state, closing the race with
666
- Controller launch. While the lease exists, managed delivery for that Role is
667
- paused without consuming its bounded delivery retries; detach releases the
668
- lease and signals only already-durable Role work for reconsideration. Other
669
- Roles in the same Task continue independently. Before any attach Yui closes
670
- readline, leaves raw mode, pauses its stdin, and synchronously hands the terminal
671
- to tmux. The attach uses the real outer terminal capabilities and a clean alternate
672
- screen; mouse scrolling stays in the Agent pane's
673
- 100,000-line tmux history instead of mixing with earlier shell or IDE terminal
674
- history. A read-write attachment exposes whatever native interaction the
675
- existing pane supports, but it is never part of managed startup or delivery.
676
-
677
- tmux fixes a pane's history capacity when that pane is created. Roles created
678
- before this limit was configured keep their earlier capacity; Yui warns on
679
- Terminal attach and in Web so the user can exit and re-enter that Role once to
680
- create a 100,000-line pane while retaining the native Agent conversation.
681
-
682
- Global interactive entry remains writable when no writer exists and
683
- automatically downgrades to read-only when another writer is present; global
684
- Web keeps one writer per tmux session. Task Web is always read-only. Task CLI
685
- entry is read-only unless `--read-write` is requested, preventing observation
686
- from changing Agent execution.
687
-
688
- ```sh
689
- yui role enter <global-role>
690
- yui task enter <task-id> [role] [--read-only | --read-write]
691
- yui task role enter <task-id> <role> [--read-only | --read-write]
667
+ Managed Task Agents use the [hybrid Provider runtime](docs/provider-runtime.md).
668
+ The Controller and Agent Host send Provider-native structured requests; tmux
669
+ and PTY keep the Host alive, show output, and provide an explicit human input
670
+ gateway. Managed prompts are never delivered as terminal bytes.
671
+
672
+ Codex uses a persistent App Server JSON-RPC process. Claude Code uses a
673
+ persistent stream-json process with exact user-message replay acknowledgement.
674
+ Both follow the same Conversation, Activation, Turn, and authority-epoch
675
+ contract. A timeout or uncertain write becomes `delivery-unknown` and is never
676
+ automatically retried.
677
+
678
+ Task Role observation and takeover are explicit:
679
+
680
+ ```sh
681
+ yui task role view <task-id> <role>
682
+ yui task role takeover <task-id> <role>
683
+ yui task role release <task-id> <role>
692
684
  ```
693
685
 
686
+ `view` is read-only. `takeover` transfers the durable writer authority to the
687
+ human before enabling the Host PTY gateway and requires a live managed Run;
688
+ detach returns it to the Controller. `release` remains available without a live
689
+ Run and idempotently repairs a stranded or partially synchronized takeover.
690
+ Authority cannot transfer while a Provider Turn or input delivery is unsettled.
691
+
692
+ Global Operator and global Role sessions remain native interactive CLIs:
693
+
694
+ ```sh
695
+ yui session enter <global-role>
696
+ ```
697
+
698
+ tmux fixes a pane's history capacity when that pane is created. Existing panes
699
+ retain their configured capacity; managed runtime output remains observable in
700
+ the Agent Host pane without becoming lifecycle or acknowledgement evidence.
701
+
694
702
  Each Role, including a Task-bound Worker instance, can bind multiple configured Agents, has one active Agent, and keeps
695
703
  a separate native session per Agent binding. Operator narrows this to at most
696
704
  one Agent per adapter—for example, one Codex and one Claude—so its bindings are
@@ -710,14 +718,12 @@ the terminal Session's immutable effective snapshot in history. Until that
710
718
  process terminates, exact control-plane wakes continue through its actual
711
719
  snapshot instead of applying desired drift as a hot change.
712
720
 
713
- Use `yui role unbind <global-role> <agent-id>` or `yui task role unbind <task-id> <role> <agent-id>` to retire a dormant binding. The active binding and any non-stopped native session are rejected; a stopped session record is removed atomically with the binding.
721
+ Use `yui config role unbind <global-role> <agent-id>` or `yui task role unbind <task-id> <role> <agent-id>` to retire a dormant binding. The active binding and any non-stopped native session are rejected; a stopped session record is removed atomically with the binding.
714
722
 
715
- Claude session IDs are preallocated at launch. Every managed Task Claude Run
716
- uses a new finite process; resume starts a new process against the fixed native
717
- session instead of reusing an interactive pane. Codex discovers its native
718
- thread identity from structured lifecycle events. Managed Task Runs use one
719
- Agent Driver Hook ingress for both CLIs. Global interactive Codex sessions may
720
- still use its structured `notify` callback for conversation presentation.
723
+ Claude session IDs are preallocated at launch. Codex discovers its native
724
+ thread identity from App Server responses. Managed Task Runs use structured
725
+ Provider observations for both CLIs. Global interactive Codex sessions may
726
+ still use its `notify` callback for conversation presentation.
721
727
 
722
728
  Automated lifecycle and delivery decisions use structured Hook payloads,
723
729
  persisted identities, usage snapshots, tmux process state, receipts, and pane
@@ -847,9 +853,11 @@ The restored management surface includes:
847
853
  ```sh
848
854
  yui update
849
855
  yui upgrade [--dry-run]
850
- yui agent add|list|show|capabilities|update|remove
851
- yui role add|list|show|update|remove|bind|enter
852
- yui role session record|replace
856
+ yui config agent add|list|show|capabilities|update|remove
857
+ yui config role add|list|show|update|remove|bind|unbind
858
+ yui config profile add|list|show|update|remove|reset
859
+ yui config completion [bash|zsh|fish]
860
+ yui session enter|record|replace|reconcile
853
861
  yui project add|clone|refresh|update|discover|list|show|knowledge
854
862
  ```
855
863