@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
@@ -1,5 +1,5 @@
1
1
  import { supportedAgentAdapterIds } from "../agent/adapterCatalog.js";
2
- import { CONFIG_KEYS } from "../commands/configCommands.js";
2
+ import { CONFIG_DEFINITIONS, CONFIG_DOMAINS, configDefinitionsForDomain } from "../config/configCatalog.js";
3
3
  function buildNode(input, parentPath = []) {
4
4
  const path = [...parentPath, input.name];
5
5
  const children = (input.children ?? []).map((child) => buildNode(child, path));
@@ -7,12 +7,16 @@ function buildNode(input, parentPath = []) {
7
7
  const usage = input.usage === undefined
8
8
  ? [`${path.join(" ")}${children.length > 0 && !executable ? " <command>" : ""}`]
9
9
  : typeof input.usage === "string" ? [input.usage] : [...input.usage];
10
+ const examples = input.examples === undefined
11
+ ? usage
12
+ : typeof input.examples === "string" ? [input.examples] : [...input.examples];
10
13
  return Object.freeze({
11
14
  name: input.name,
12
15
  path: Object.freeze(path),
13
16
  summary: input.summary,
14
17
  kind: children.length === 0 ? "leaf" : executable ? "hybrid" : "group",
15
18
  usage: Object.freeze(usage),
19
+ examples: Object.freeze(examples),
16
20
  sections: Object.freeze((input.sections ?? []).map((section) => Object.freeze({
17
21
  ...section,
18
22
  entries: Object.freeze([...section.entries])
@@ -37,49 +41,91 @@ function buildNode(input, parentPath = []) {
37
41
  function freezeRecord(record) {
38
42
  return Object.freeze(Object.fromEntries(Object.entries(record ?? {}).map(([key, values]) => [key, Object.freeze([...values])])));
39
43
  }
40
- const CONFIG_KEY_VALUES = [
41
- { name: "time-zone", summary: "IANA timezone for human-facing timestamps (default: Asia/Shanghai)." },
42
- { name: "reconciliation-interval-seconds", summary: "Recovery reconciliation interval, 5-300 seconds (default: 120)." },
43
- { name: "leader-next-action", summary: "Leader next-action mode: display, warn, or enforce (default: display)." },
44
- { name: "context-budget", summary: "Per-Session context token budget; set with --soft-tokens <n> --hard-tokens <n> (default: soft 100000 / hard 120000)." },
45
- { name: "resources-gc-mode", summary: "Resource GC mode: report or quarantine (default: report)." },
46
- { name: "resources-gc-auto-quarantine", summary: "Auto-quarantine terminal Task resources: true or false (default: false)." },
47
- { name: "provider-retry-mode", summary: "Provider retry mode: off, shadow, or enforce (default: enforce)." },
48
- { name: "provider-retry-adapters", summary: "Adapters with in-place retry: all, comma-separated adapter ids, or off (default: all)." },
49
- { name: "provider-retry-max-window-ms", summary: "Total retry budget per Run lineage in milliseconds (default: 600000)." },
50
- { name: "yield-receipt-replay", summary: "Replay committed yield receipts on resend: true or false (default: true)." },
51
- { name: "tmux-bin", summary: "Path to the tmux binary (default: tmux)." },
52
- { name: "git-bin", summary: "Path to the git binary (default: git)." },
53
- { name: "telemetry-mode", summary: "Telemetry mode: legacy, dual, or bounded (default: legacy)." },
54
- { name: "telemetry-terminal-keep", summary: "Telemetry terminal retention count (default: 200)." },
55
- { name: "telemetry-run-cap", summary: "Telemetry per-run row cap (default: 50000)." },
56
- { name: "review", summary: "Global WorkItem review rule; set with --role <global-role> --trigger <always|leader|final> [--finding-ledger <shadow|enforce>] [--delta-recheck <enabled|disabled>] (default: disabled)." }
57
- ];
44
+ const CONFIG_KEY_VALUES = CONFIG_DEFINITIONS.map((definition) => ({
45
+ name: definition.key,
46
+ summary: definition.summary,
47
+ takesEffect: definition.takesEffect
48
+ }));
49
+ const CONFIG_DOMAIN_SUMMARIES = {
50
+ system: "Configure Home-wide defaults and human-facing presentation.",
51
+ runtime: "Configure Controller recovery, concurrency, health, launch, delivery, and Provider retry policy.",
52
+ workflow: "Configure Leader convergence, context, and optional review policy.",
53
+ resources: "Configure resource garbage collection and quarantine policy.",
54
+ tools: "Configure tmux and optional diagnostic telemetry."
55
+ };
56
+ function durableConfigDomainNode(domain) {
57
+ const definitions = configDefinitionsForDomain(domain);
58
+ const keys = definitions.map(({ key }) => key);
59
+ const values = CONFIG_KEY_VALUES.filter(({ name }) => keys.includes(name));
60
+ const options = domain === "workflow"
61
+ ? [
62
+ "--soft-tokens", "--hard-tokens", "--role", "--trigger", "--finding-ledger",
63
+ "--delta-recheck", "--delta-recheck-max-lines", "--delta-recheck-max-files"
64
+ ]
65
+ : domain === "runtime"
66
+ ? ["--quiet-after-seconds", "--diagnostic-after-seconds", "--stall-after-seconds"]
67
+ : [];
68
+ return {
69
+ name: domain,
70
+ summary: CONFIG_DOMAIN_SUMMARIES[domain],
71
+ examples: [
72
+ `yui config ${domain} show`,
73
+ `yui config ${domain} set ${keys[0]} <value>`,
74
+ `yui config ${domain} clear ${keys[0]}`
75
+ ],
76
+ sections: [{ id: "manage", title: "Commands", entries: ["show", "set", "clear"] }],
77
+ children: [
78
+ { name: "show", summary: `Show effective ${domain} configuration.` },
79
+ {
80
+ name: "set",
81
+ summary: `Set one ${domain} configuration key.`,
82
+ usage: `yui config ${domain} set <key> <value...>`,
83
+ sections: [{ id: "keys", title: "Configuration keys", entries: keys }],
84
+ values,
85
+ options,
86
+ optionValues: domain === "workflow"
87
+ ? {
88
+ "--trigger": ["always", "leader", "final"],
89
+ "--finding-ledger": ["shadow", "enforce"],
90
+ "--delta-recheck": ["enabled", "disabled"]
91
+ }
92
+ : {}
93
+ },
94
+ {
95
+ name: "clear",
96
+ summary: `Reset one ${domain} configuration key to its default.`,
97
+ usage: `yui config ${domain} clear <key>`,
98
+ sections: [{ id: "keys", title: "Configuration keys", entries: keys }],
99
+ values
100
+ }
101
+ ]
102
+ };
103
+ }
58
104
  const agentChildren = [
59
105
  {
60
106
  name: "add",
61
107
  summary: "Add a configured native Agent CLI.",
62
- usage: "yui agent add <id> [--adapter <adapter>] --command <command> [--arg <arg> ...] [--env TARGET=PROCESS_NAME ...]",
108
+ usage: "yui config agent add <id> [--adapter <adapter>] --command <command> [--arg <arg> ...] [--env TARGET=PROCESS_NAME ...]",
63
109
  options: ["--adapter", "--command", "--arg", "--env"],
64
110
  optionValues: { "--adapter": supportedAgentAdapterIds() },
65
111
  executableOptions: ["--command"]
66
112
  },
67
113
  { name: "list", summary: "List configured Agents." },
68
- { name: "show", summary: "Show one configured Agent.", usage: "yui agent show <id>" },
114
+ { name: "show", summary: "Show one configured Agent.", usage: "yui config agent show <id>" },
69
115
  {
70
116
  name: "capabilities",
71
117
  summary: "Probe one Agent CLI for runtime configuration options.",
72
- usage: "yui agent capabilities <id>"
118
+ usage: "yui config agent capabilities <id>"
73
119
  },
74
120
  {
75
121
  name: "update",
76
122
  summary: "Update a configured Agent.",
77
- usage: "yui agent update <id> [--adapter <adapter>] [--command <command>] [--arg <arg> ... | --clear-args] [--env TARGET=PROCESS_NAME ... | --clear-env]",
123
+ usage: "yui config agent update <id> [--adapter <adapter>] [--command <command>] [--arg <arg> ... | --clear-args] [--env TARGET=PROCESS_NAME ... | --clear-env]",
78
124
  options: ["--adapter", "--command", "--arg", "--clear-args", "--env", "--clear-env"],
79
125
  optionValues: { "--adapter": supportedAgentAdapterIds() },
80
126
  executableOptions: ["--command"]
81
127
  },
82
- { name: "remove", summary: "Remove a configured Agent.", usage: "yui agent remove <id>" }
128
+ { name: "remove", summary: "Remove a configured Agent.", usage: "yui config agent remove <id>" }
83
129
  ];
84
130
  const roleProfileOptions = [
85
131
  "--description", "--responsibility", "--constraint",
@@ -114,67 +160,83 @@ const roleChildren = [
114
160
  {
115
161
  name: "add",
116
162
  summary: "Add a reusable global Role.",
117
- usage: "yui role add <name> --agent <id> [Role and Agent settings]",
163
+ usage: "yui config role add <name> --agent <id> [Role and Agent settings]",
118
164
  options: ["--agent", "--workspace", ...roleProfileOptions, ...roleAgentOptions],
119
165
  optionValues: roleAgentOptionValues,
120
166
  fileOptions: ["--workspace"]
121
167
  },
122
168
  { name: "list", summary: "List global Roles." },
123
- { name: "show", summary: "Show one global Role.", usage: "yui role show <name>" },
124
- { name: "context", summary: "Load the exact authorized global Role context.", usage: "yui role context <name>" },
169
+ { name: "show", summary: "Show one global Role.", usage: "yui config role show <name>" },
125
170
  {
126
171
  name: "update",
127
172
  summary: "Update a global Role.",
128
- usage: "yui role update <name> [profile options] [clear options]",
173
+ usage: "yui config role update <name> [profile options] [clear options]",
129
174
  options: ["--agent", "--workspace", ...roleProfileOptions, ...roleAgentOptions,
130
175
  ...roleProfileClearOptions, ...roleAgentClearOptions],
131
176
  optionValues: roleAgentOptionValues,
132
177
  fileOptions: ["--workspace"]
133
178
  },
134
- { name: "remove", summary: "Remove a global Role.", usage: "yui role remove <name>" },
135
- { name: "bind", summary: "Bind and activate an Agent for a global Role.", usage: "yui role bind <role> <agent-id>" },
136
- { name: "unbind", summary: "Unbind a dormant Agent from a global Role.", usage: "yui role unbind <role> <agent-id>" },
137
- { name: "enter", summary: "Enter a global Role's native session.", usage: "yui role enter <role>" },
179
+ { name: "remove", summary: "Remove a global Role.", usage: "yui config role remove <name>" },
180
+ { name: "bind", summary: "Bind and activate an Agent for a global Role.", usage: "yui config role bind <role> <agent-id>" },
181
+ { name: "unbind", summary: "Unbind a dormant Agent from a global Role.", usage: "yui config role unbind <role> <agent-id>" }
182
+ ];
183
+ const globalSessionChildren = [
184
+ { name: "enter", summary: "Enter a global Role's native session.", usage: "yui session enter <role>" },
138
185
  {
139
- name: "session",
140
- summary: "Manage native session IDs for a global Role.",
141
- sections: [{ id: "manage", title: "Commands", entries: ["record", "replace"] }],
142
- children: [
143
- {
144
- name: "record",
145
- summary: "Record the active Agent's native session ID.",
146
- usage: "yui role session record <role> --native-id <id>",
147
- options: ["--native-id"]
148
- },
149
- {
150
- name: "replace",
151
- summary: "Explicitly replace the active Agent's native session ID.",
152
- usage: "yui role session replace <role> --native-id <id> --reason <text>",
153
- options: ["--native-id", "--reason"]
154
- }
155
- ]
186
+ name: "context",
187
+ summary: "Load the exact authorized global Role context.",
188
+ usage: "yui session context <role>"
189
+ },
190
+ {
191
+ name: "record",
192
+ summary: "Record the active Agent's native session ID.",
193
+ usage: "yui session record <role> --native-id <id>",
194
+ options: ["--native-id"]
195
+ },
196
+ {
197
+ name: "replace",
198
+ summary: "Explicitly replace the active Agent's native session ID.",
199
+ usage: "yui session replace <role> --native-id <id> --reason <text>",
200
+ options: ["--native-id", "--reason"]
201
+ },
202
+ {
203
+ name: "reconcile",
204
+ summary: "Reconcile durable Session owners with native sessions.",
205
+ usage: "yui session reconcile [--report] [--cleanup]",
206
+ options: ["--report", "--cleanup"]
156
207
  }
157
208
  ];
158
209
  const profileChildren = [
159
210
  {
160
211
  name: "add",
161
212
  summary: "Add a reusable Agent Profile.",
162
- usage: "yui profile add <id> [--access <read|write>] [Profile settings]",
213
+ usage: "yui config profile add <id> [--access <read|write>] [Profile settings]",
163
214
  options: ["--access", ...agentProfileOptions],
164
215
  optionValues: { "--access": ["read", "write"] }
165
216
  },
166
217
  { name: "list", summary: "List Agent Profiles." },
167
- { name: "show", summary: "Show one Agent Profile.", usage: "yui profile show <id>" },
218
+ { name: "show", summary: "Show one Agent Profile.", usage: "yui config profile show <id>" },
168
219
  {
169
220
  name: "update",
170
221
  summary: "Update an Agent Profile.",
171
- usage: "yui profile update <id> [--access <read|write>] [Profile settings]",
222
+ usage: "yui config profile update <id> [--access <read|write>] [Profile settings]",
172
223
  options: ["--access", ...agentProfileOptions, ...agentProfileClearOptions],
173
224
  optionValues: { "--access": ["read", "write"] }
174
225
  },
175
- { name: "remove", summary: "Remove a custom Agent Profile.", usage: "yui profile remove <id>" },
226
+ { name: "remove", summary: "Remove a custom Agent Profile.", usage: "yui config profile remove <id>" },
176
227
  { name: "reset", summary: "Reset all built-in Agent Profiles." }
177
228
  ];
229
+ const completionChildren = [
230
+ { name: "bash", summary: "Interactively configure Bash completion." },
231
+ { name: "zsh", summary: "Interactively configure Zsh completion." },
232
+ { name: "fish", summary: "Interactively configure Fish completion." },
233
+ {
234
+ name: "candidates",
235
+ summary: "Resolve internal dynamic completion candidates.",
236
+ usage: "yui config completion candidates <prefix> -- <words...>",
237
+ hidden: true
238
+ }
239
+ ];
178
240
  const taskChildren = [
179
241
  {
180
242
  name: "create",
@@ -451,7 +513,8 @@ const taskChildren = [
451
513
  name: "role",
452
514
  summary: "Manage Roles within a Task.",
453
515
  sections: [{ id: "manage", title: "Commands", entries: [
454
- "add", "list", "status", "show", "update", "remove", "bind", "unbind", "reset", "enter"
516
+ "add", "list", "status", "show", "update", "remove", "bind", "unbind", "reset",
517
+ "view", "takeover", "release"
455
518
  ] }],
456
519
  children: [
457
520
  {
@@ -486,10 +549,19 @@ const taskChildren = [
486
549
  options: ["--reason"]
487
550
  },
488
551
  {
489
- name: "enter",
490
- summary: "Attach to an existing Task Role session without starting it.",
491
- usage: "yui task role enter <task> <role> [--read-only | --read-write]",
492
- options: ["--read-only", "--read-write"]
552
+ name: "view",
553
+ summary: "Attach read-only to a managed Provider presentation surface.",
554
+ usage: "yui task role view <task> <role>"
555
+ },
556
+ {
557
+ name: "takeover",
558
+ summary: "Acquire Provider writer authority and enter the PTY input gateway.",
559
+ usage: "yui task role takeover <task> <role>"
560
+ },
561
+ {
562
+ name: "release",
563
+ summary: "Return stranded human Provider authority to the Controller.",
564
+ usage: "yui task role release <task> <role>"
493
565
  }
494
566
  ]
495
567
  },
@@ -613,7 +685,7 @@ const taskChildren = [
613
685
  {
614
686
  name: "run",
615
687
  summary: "Inspect and control Task Role Agent Runs.",
616
- sections: [{ id: "manage", title: "Commands", entries: ["list", "show", "retry", "settle", "recover", "yield", "checkpoint"] }],
688
+ sections: [{ id: "manage", title: "Commands", entries: ["list", "show", "retry", "settle", "recover", "yield", "context", "checkpoint"] }],
617
689
  children: [
618
690
  { name: "list", summary: "List Runs for a work item.", usage: "yui task run list <task>/<work>" },
619
691
  {
@@ -644,6 +716,28 @@ const taskChildren = [
644
716
  options: ["--summary", "--summary-file"],
645
717
  fileOptions: ["--summary-file"]
646
718
  },
719
+ {
720
+ name: "context",
721
+ summary: "Load the exact authorized Run context.",
722
+ usage: "yui task run context <task>/<run> [--json]",
723
+ executable: true,
724
+ hidden: true,
725
+ sections: [{ id: "load", title: "Commands", entries: ["expand", "delta"] }],
726
+ children: [
727
+ {
728
+ name: "expand",
729
+ summary: "Expand one authorized Run context reference.",
730
+ usage: "yui task run context expand <task>/<run> <ref-id> [--mode full]",
731
+ options: ["--mode"]
732
+ },
733
+ {
734
+ name: "delta",
735
+ summary: "Load authorized Run context changes after a cursor.",
736
+ usage: "yui task run context delta <task>/<run> --after <cursor>",
737
+ options: ["--after"]
738
+ }
739
+ ]
740
+ },
647
741
  {
648
742
  name: "checkpoint",
649
743
  summary: "Record durable progress for a long-running Agent Run.",
@@ -878,24 +972,19 @@ const taskChildren = [
878
972
  { name: "show", summary: "Show one ChangeSet.", usage: "yui task change-set show <task>/<change-set>" }
879
973
  ]
880
974
  },
881
- {
882
- name: "enter",
883
- summary: "Attach to an existing Task Role, defaulting to Leader and read-only.",
884
- usage: "yui task enter <task> [role] [--read-only | --read-write]",
885
- options: ["--read-only", "--read-write"]
886
- }
887
975
  ];
888
976
  export const ROOT_COMMAND = buildNode({
889
977
  name: "yui",
890
978
  summary: "Coordinate durable, isolated Agent work.",
891
979
  usage: "yui [--json] <command>",
980
+ examples: ["yui setup", "yui operator enter", "yui config show", "yui task list"],
892
981
  sections: [
893
982
  { id: "general", title: "General", entries: [
894
- "help", "version", "update", "upgrade", "setup", "doctor", "completion"
983
+ "help", "version", "update", "upgrade", "setup", "doctor"
895
984
  ] },
896
985
  { id: "workflow", title: "Workflow", entries: ["operator", "project", "task"] },
897
- { id: "configuration", title: "Configuration", entries: ["config", "agent", "profile", "role"] },
898
- { id: "operations", title: "Operations", entries: ["web", "controller", "execution", "job", "jobs", "telemetry", "release"] },
986
+ { id: "configuration", title: "Configuration", entries: ["config"] },
987
+ { id: "operations", title: "Operations", entries: ["web", "controller", "session", "execution", "job", "jobs", "telemetry", "release"] },
899
988
  { id: "resources", title: "Resources", entries: ["resources"] },
900
989
  { id: "internal", title: "Internal", entries: ["internal"] }
901
990
  ],
@@ -909,7 +998,11 @@ export const ROOT_COMMAND = buildNode({
909
998
  usage: "yui upgrade [--dry-run]",
910
999
  options: ["--dry-run"]
911
1000
  },
912
- { name: "setup", summary: "Initialize or update Yui configuration." },
1001
+ {
1002
+ name: "setup",
1003
+ summary: "Initialize the minimum Operator and Leader configuration required to execute Tasks.",
1004
+ examples: "yui setup"
1005
+ },
913
1006
  { name: "doctor", summary: "Check Yui dependencies and file state." },
914
1007
  {
915
1008
  name: "web",
@@ -917,28 +1010,6 @@ export const ROOT_COMMAND = buildNode({
917
1010
  usage: "yui web [--host <loopback>] [--port <port>]",
918
1011
  options: ["--host", "--port"]
919
1012
  },
920
- {
921
- name: "completion",
922
- summary: "Interactively configure shell completion.",
923
- executable: true,
924
- acceptsArguments: false,
925
- usage: ["yui completion", "yui completion <bash|zsh|fish>"],
926
- sections: [
927
- { id: "shells", title: "Shells", entries: ["bash", "zsh", "fish"] },
928
- { id: "internal", title: "Internal", entries: ["candidates"] }
929
- ],
930
- children: [
931
- { name: "bash", summary: "Interactively configure Bash completion." },
932
- { name: "zsh", summary: "Interactively configure Zsh completion." },
933
- { name: "fish", summary: "Interactively configure Fish completion." },
934
- {
935
- name: "candidates",
936
- summary: "Resolve internal dynamic completion candidates.",
937
- usage: "yui completion candidates <prefix> -- <words...>",
938
- hidden: true
939
- }
940
- ]
941
- },
942
1013
  {
943
1014
  name: "controller",
944
1015
  summary: "Inspect and recover local Controller runtime resources.",
@@ -1028,29 +1099,78 @@ export const ROOT_COMMAND = buildNode({
1028
1099
  },
1029
1100
  {
1030
1101
  name: "config",
1031
- summary: "Inspect or update Yui configuration.",
1032
- sections: [{ id: "manage", title: "Commands", entries: ["show", "set", "clear"] }],
1102
+ summary: "Inspect, understand, and update all persistent Yui configuration.",
1103
+ examples: [
1104
+ "yui config show",
1105
+ "yui config describe runtime",
1106
+ "yui config workflow show",
1107
+ "yui config agent list",
1108
+ "yui config role show operator",
1109
+ "yui config profile list",
1110
+ "yui config completion"
1111
+ ],
1112
+ sections: [
1113
+ { id: "inspect", title: "Inspect", entries: ["show", "describe"] },
1114
+ { id: "domains", title: "Configuration domains", entries: [
1115
+ ...CONFIG_DOMAINS, "agent", "role", "profile", "completion"
1116
+ ] }
1117
+ ],
1033
1118
  children: [
1034
- { name: "show", summary: "Show effective Yui configuration." },
1035
1119
  {
1036
- name: "set",
1037
- summary: "Set one Yui configuration key.",
1038
- usage: "yui config set <key> <value...>",
1039
- sections: [{ id: "keys", title: "Configuration keys", entries: [...CONFIG_KEYS] }],
1040
- values: CONFIG_KEY_VALUES,
1041
- options: ["--role", "--trigger", "--finding-ledger", "--delta-recheck", "--delta-recheck-max-lines", "--delta-recheck-max-files"],
1042
- optionValues: {
1043
- "--trigger": ["always", "leader", "final"],
1044
- "--finding-ledger": ["shadow", "enforce"],
1045
- "--delta-recheck": ["enabled", "disabled"]
1046
- }
1120
+ name: "show",
1121
+ summary: "Show the complete effective Yui configuration.",
1122
+ examples: ["yui config show", "yui --json config show"]
1123
+ },
1124
+ {
1125
+ name: "describe",
1126
+ summary: "Explain configuration effects, defaults, choices, and activation behavior.",
1127
+ usage: `yui config describe [${[...CONFIG_DOMAINS, "agent", "role", "profile", "completion"].join("|")}]`,
1128
+ examples: ["yui config describe", "yui --json config describe role"],
1129
+ argumentValues: { 0: [...CONFIG_DOMAINS, "agent", "role", "profile", "completion"] }
1130
+ },
1131
+ ...CONFIG_DOMAINS.map(durableConfigDomainNode),
1132
+ {
1133
+ name: "agent",
1134
+ summary: "Manage configured native Agent CLIs; launch-setting changes require affected Sessions to be stopped.",
1135
+ examples: ["yui config agent list", "yui config agent capabilities codex"],
1136
+ sections: [
1137
+ { id: "inspect", title: "Inspect", entries: ["list", "show", "capabilities"] },
1138
+ { id: "manage", title: "Manage", entries: ["add", "update", "remove"] }
1139
+ ],
1140
+ children: agentChildren
1141
+ },
1142
+ {
1143
+ name: "profile",
1144
+ summary: "Manage reusable Agent Profiles; updates affect future copies and do not rewrite existing Task Roles.",
1145
+ examples: ["yui config profile list", "yui config profile show implementer"],
1146
+ sections: [
1147
+ { id: "inspect", title: "Inspect", entries: ["list", "show"] },
1148
+ { id: "manage", title: "Manage", entries: ["add", "update", "remove", "reset"] }
1149
+ ],
1150
+ children: profileChildren
1047
1151
  },
1048
1152
  {
1049
- name: "clear",
1050
- summary: "Reset one Yui configuration key to its default.",
1051
- usage: "yui config clear <key>",
1052
- sections: [{ id: "keys", title: "Configuration keys", entries: [...CONFIG_KEYS] }],
1053
- values: CONFIG_KEY_VALUES
1153
+ name: "role",
1154
+ summary: "Manage reusable global Roles and desired Agent launch configuration for the next compatible Session.",
1155
+ examples: ["yui config role list", "yui config role show operator"],
1156
+ sections: [
1157
+ { id: "inspect", title: "Inspect", entries: ["list", "show"] },
1158
+ { id: "manage", title: "Manage", entries: ["add", "update", "remove", "bind", "unbind"] }
1159
+ ],
1160
+ children: roleChildren
1161
+ },
1162
+ {
1163
+ name: "completion",
1164
+ summary: "Interactively configure shell completion after confirming generated files and startup-file changes.",
1165
+ executable: true,
1166
+ acceptsArguments: false,
1167
+ usage: ["yui config completion", "yui config completion <bash|zsh|fish>"],
1168
+ examples: ["yui config completion", "yui config completion zsh"],
1169
+ sections: [
1170
+ { id: "shells", title: "Shells", entries: ["bash", "zsh", "fish"] },
1171
+ { id: "internal", title: "Internal", entries: ["candidates"] }
1172
+ ],
1173
+ children: completionChildren
1054
1174
  }
1055
1175
  ]
1056
1176
  },
@@ -1207,39 +1327,25 @@ export const ROOT_COMMAND = buildNode({
1207
1327
  ]
1208
1328
  },
1209
1329
  {
1210
- name: "agent",
1211
- summary: "Manage configured native Agent CLIs.",
1212
- sections: [
1213
- { id: "inspect", title: "Inspect", entries: ["list", "show", "capabilities"] },
1214
- { id: "manage", title: "Manage", entries: ["add", "update", "remove"] }
1330
+ name: "session",
1331
+ summary: "Load and enter global Role sessions, and reconcile their durable identities.",
1332
+ examples: [
1333
+ "yui session context operator --json",
1334
+ "yui session enter operator",
1335
+ "yui session reconcile --report"
1215
1336
  ],
1216
- children: agentChildren
1217
- },
1218
- {
1219
- name: "profile",
1220
- summary: "Manage reusable Agent Profiles.",
1221
- sections: [
1222
- { id: "inspect", title: "Inspect", entries: ["list", "show"] },
1223
- { id: "manage", title: "Manage", entries: ["add", "update", "remove", "reset"] }
1224
- ],
1225
- children: profileChildren
1226
- },
1227
- {
1228
- name: "role",
1229
- summary: "Manage reusable global Roles and their native sessions.",
1230
1337
  sections: [
1231
- { id: "inspect", title: "Inspect", entries: ["list", "show", "context"] },
1232
- { id: "manage", title: "Manage", entries: ["add", "update", "remove", "bind", "unbind"] },
1233
- { id: "sessions", title: "Sessions", entries: ["enter", "session"] }
1338
+ { id: "global", title: "Global Role sessions", entries: ["context", "enter", "record", "replace"] },
1339
+ { id: "recovery", title: "Recovery", entries: ["reconcile"] }
1234
1340
  ],
1235
- children: roleChildren
1341
+ children: globalSessionChildren
1236
1342
  },
1237
1343
  {
1238
1344
  name: "task",
1239
1345
  summary: "Manage Tasks, WorkItems, Agent Runs, and integration.",
1240
1346
  sections: [
1241
1347
  { id: "lifecycle", title: "Lifecycle", entries: ["create", "project", "base", "update", "activate", "complete", "reopen", "retire", "list", "show", "context", "next-action", "archive", "rebuild", "history", "replace", "reconcile"] },
1242
- { id: "collaboration", title: "Collaboration", entries: ["message", "input", "grant", "workflow", "publication", "work", "run", "review", "integration", "role", "enter", "overlap", "change-set"] },
1348
+ { id: "collaboration", title: "Collaboration", entries: ["message", "input", "grant", "workflow", "publication", "work", "run", "review", "integration", "role", "overlap", "change-set"] },
1243
1349
  { id: "knowledge", title: "Task Knowledge", entries: ["brief", "decision", "milestone", "event", "continuation", "wake"] }
1244
1350
  ],
1245
1351
  children: taskChildren
@@ -1279,8 +1385,17 @@ export const ROOT_COMMAND = buildNode({
1279
1385
  name: "internal",
1280
1386
  summary: "Internal Yui callbacks.",
1281
1387
  hidden: true,
1282
- sections: [{ id: "callbacks", title: "Callbacks", entries: ["session-notify", "runtime-hook"] }],
1388
+ sections: [{
1389
+ id: "callbacks",
1390
+ title: "Callbacks",
1391
+ entries: ["session-notify", "runtime-hook", "agent-host"]
1392
+ }],
1283
1393
  children: [
1394
+ {
1395
+ name: "agent-host",
1396
+ summary: "Run the persistent structured Provider host.",
1397
+ usage: "yui internal agent-host <launch-id> <ticket>"
1398
+ },
1284
1399
  {
1285
1400
  name: "session-notify",
1286
1401
  summary: "Record a structured native session notification.",
@@ -1333,6 +1448,20 @@ export function findCommandNode(path) {
1333
1448
  return node;
1334
1449
  }
1335
1450
  export const findCommand = findCommandNode;
1451
+ /** Structured help projection consumed by `config describe --json` and Operator. */
1452
+ export function describeCommandTree(node) {
1453
+ return {
1454
+ path: node.path.slice(1).join(" "),
1455
+ summary: node.summary,
1456
+ usage: node.usage,
1457
+ examples: node.examples,
1458
+ options: node.options,
1459
+ optionValues: node.optionValues,
1460
+ argumentValues: node.argumentValues,
1461
+ values: node.values,
1462
+ children: visibleChildren(node).map(describeCommandTree)
1463
+ };
1464
+ }
1336
1465
  export function validateCommandCatalog(root) {
1337
1466
  const reservedAliases = new Set(["-h", "--help", "-help", "-v", "--version"]);
1338
1467
  const commandPathProviders = [];
@@ -1341,6 +1470,16 @@ export function validateCommandCatalog(root) {
1341
1470
  throw new Error(`Command summary is required: ${node.path.join(" ")}`);
1342
1471
  if (node.usage.length === 0)
1343
1472
  throw new Error(`Command usage is required: ${node.path.join(" ")}`);
1473
+ if (node.examples.length === 0 || node.examples.some((example) => example.trim().length === 0)) {
1474
+ throw new Error(`Command examples are required: ${node.path.join(" ")}`);
1475
+ }
1476
+ const canonicalPath = node.path.join(" ");
1477
+ for (const example of node.examples) {
1478
+ const normalized = example.replace(/^yui --json(?=\s|$)/, "yui");
1479
+ if (normalized !== canonicalPath && !normalized.startsWith(`${canonicalPath} `)) {
1480
+ throw new Error(`Command example does not match its path: ${canonicalPath}: ${example}`);
1481
+ }
1482
+ }
1344
1483
  if (node.commandPathArguments) {
1345
1484
  commandPathProviders.push(node);
1346
1485
  const ownsOtherCompletionMetadata = node.kind !== "leaf"
@@ -1432,10 +1571,18 @@ export function validateCommandCatalog(root) {
1432
1571
  if (!options.has(option))
1433
1572
  throw new Error(`Executable completion references unknown option: ${[...node.path, option].join(" ")}`);
1434
1573
  }
1574
+ if (new Set(node.workspaceMapOptions).size !== node.workspaceMapOptions.length) {
1575
+ throw new Error(`Duplicate workspace-map completion option: ${node.path.join(" ")}`);
1576
+ }
1577
+ for (const option of node.workspaceMapOptions) {
1578
+ if (!options.has(option))
1579
+ throw new Error(`Workspace-map completion references unknown option: ${[...node.path, option].join(" ")}`);
1580
+ }
1435
1581
  for (const option of options) {
1436
1582
  const owners = Number(Object.hasOwn(node.optionValues, option))
1437
1583
  + Number(node.fileOptions.includes(option))
1438
- + Number(node.executableOptions.includes(option));
1584
+ + Number(node.executableOptions.includes(option))
1585
+ + Number(node.workspaceMapOptions.includes(option));
1439
1586
  if (owners > 1)
1440
1587
  throw new Error(`Multiple completion owners for option: ${[...node.path, option].join(" ")}`);
1441
1588
  }