@zq-silk/yui 0.6.7 → 0.6.9

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.
@@ -1,6 +1,6 @@
1
- import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
1
+ import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
- import { join, resolve } from "node:path";
3
+ import { basename, dirname, join, resolve } from "node:path";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { validateConfiguredAgent } from "../agent/agent.js";
6
6
  import { validateCapabilityGrant } from "../grant/capabilityGrant.js";
@@ -1735,11 +1735,56 @@ export class StorageCancelledError extends Error {
1735
1735
  constructor(message) { super(message); this.name = "StorageCancelledError"; }
1736
1736
  }
1737
1737
  export function resolveYuiHome(env) {
1738
- return env.YUI_HOME === undefined || env.YUI_HOME.length === 0
1738
+ const requested = env.YUI_HOME === undefined || env.YUI_HOME.length === 0
1739
1739
  ? join(homedir(), ".yui")
1740
1740
  : resolve(env.YUI_HOME);
1741
+ return canonicalizeYuiHome(requested);
1741
1742
  }
1742
1743
  export function ensureYuiHome(rootDir) { mkdirSync(rootDir, { recursive: true, mode: 0o700 }); }
1744
+ /**
1745
+ * YUI_HOME is a runtime identity, not only a storage path. Resolve every
1746
+ * existing symlink component before Controller/tmux namespaces or exact
1747
+ * descriptors derive identity from it. A Home may not exist before `setup`,
1748
+ * so retain proven-missing trailing components below the longest existing
1749
+ * physical ancestor. Existing-but-unresolvable paths fail closed.
1750
+ */
1751
+ function canonicalizeYuiHome(value) {
1752
+ const absolute = resolve(value);
1753
+ let current = absolute;
1754
+ const trailing = [];
1755
+ for (;;) {
1756
+ try {
1757
+ const physical = realpathSync(current);
1758
+ return trailing.length === 0 ? physical : join(physical, ...trailing);
1759
+ }
1760
+ catch (realpathError) {
1761
+ if (!isErrno(realpathError, "ENOENT")) {
1762
+ throw unstableYuiHome(absolute, realpathError);
1763
+ }
1764
+ try {
1765
+ lstatSync(current);
1766
+ }
1767
+ catch (lstatError) {
1768
+ if (!isErrno(lstatError, "ENOENT")) {
1769
+ throw unstableYuiHome(absolute, lstatError);
1770
+ }
1771
+ const parent = dirname(current);
1772
+ if (parent === current)
1773
+ return absolute;
1774
+ trailing.unshift(basename(current));
1775
+ current = parent;
1776
+ continue;
1777
+ }
1778
+ throw unstableYuiHome(absolute, realpathError);
1779
+ }
1780
+ }
1781
+ }
1782
+ function unstableYuiHome(path, cause) {
1783
+ return new Error(`YUI_HOME cannot be resolved to a stable physical path: ${path}.`, { cause });
1784
+ }
1785
+ function isErrno(error, code) {
1786
+ return error instanceof Error && "code" in error && error.code === code;
1787
+ }
1743
1788
  function emptyState() {
1744
1789
  return {
1745
1790
  schemaVersion: CURRENT_STORAGE_STATE_SCHEMA_VERSION,
@@ -244,7 +244,7 @@ export function projectNextAction(facts) {
244
244
  },
245
245
  {
246
246
  kind: "native-subagent",
247
- reason: "Use one native implementer subagent when one bounded implementation pass benefits from parallel attention.",
247
+ reason: "Use native implementer subagents when bounded work benefits from specialist attention or parallel fan-out inside the Leader Session.",
248
248
  refs
249
249
  }
250
250
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zq-silk/yui",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "Local control plane for long-running native agent CLI sessions backed by tmux.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -38,21 +38,24 @@ Choose the executor in this order:
38
38
 
39
39
  1. **Leader directly** when the work is small and the current Leader context,
40
40
  authority, and tools are sufficient.
41
- 2. **At most one native implementer subagent** when one bounded implementation
42
- pass benefits from parallel attention or a specialist available inside the
43
- current Agent. Give it one explicit Profile, one writable workspace, and one
44
- result contract.
45
- 3. **Task Role AgentRun** only when the work genuinely needs independent
46
- parallel ownership, different credentials or authority, a provider/model
47
- capability unavailable to the current Agent, or an independently managed
48
- Session and durable Run lifecycle.
41
+ 2. **Native subagents** when bounded implementation or research benefits from
42
+ specialist attention or parallel fan-out inside the current Agent Session.
43
+ Give each child an explicit Profile, workspace access, and result contract.
44
+ 3. **Task Role AgentRun** when the work genuinely needs independent durable
45
+ ownership, different credentials or authority, a provider/model capability
46
+ unavailable to the current Agent, or an independently managed Session and
47
+ Run lifecycle.
49
48
 
50
49
  Do not dispatch a Task Role merely to obtain a fresh context, run a command,
51
50
  perform a routine small edit, or add an intermediate review. Direct and native
52
51
  execution add no Worker Role, Worker Yui Session, or Worker AgentRun. The exact
53
- Leader Run fence stays active until a native child hands back its result; the
52
+ Leader Run fence stays active while native child work is outstanding; the
54
53
  WorkItem and its workspace remain the durable delivery boundary.
55
54
 
55
+ Provider-native foreground and background child lifecycle stays owned by the
56
+ current Agent Session. Structured child completion notifications may resume the
57
+ Leader in later provider Turns while the same Yui AgentRun remains active.
58
+
56
59
  A Project-backed code result still uses one WorkItem-owned Develop workspace
57
60
  and a clean committed Candidate. The fast path compresses orchestration, not
58
61
  delivery evidence: Candidate, ChangeSet, committed Integration, acceptance,
@@ -84,11 +87,11 @@ WorkItem while its delivery scope remains open. If an immutable final-review
84
87
  boundary makes that impossible, create only the smallest repair WorkItem and
85
88
  retain the original Candidate, Review, and Integration evidence.
86
89
 
87
- Native and managed waits use different fences. For a native child, wait once on
88
- the native completion event inside the current Leader turn. Keep the exact
89
- Leader Run active; the child result returns control directly to this Leader.
90
- Do not poll, send a waiting Message, rewrite a checkpoint, or yield before that
91
- handoff.
90
+ Native and managed waits use different fences. For native children, let the
91
+ provider deliver structured completion notifications and continue the parent
92
+ Agent. The exact Leader Run stays active across intermediate provider Turn
93
+ boundaries while native children remain active. Do not poll, send a waiting
94
+ Message, rewrite a checkpoint, or yield merely to preserve that native wait.
92
95
 
93
96
  For a managed Task Role or Reviewer Run, persist a necessary changed checkpoint,
94
97
  yield the active Leader Run, and stop the turn. Its durable mailbox result or an
@@ -344,12 +347,12 @@ hint only if this Agent's native child API supports that override; otherwise
344
347
  inherit the actual runtime setting. Never claim a model that cannot be
345
348
  confirmed.
346
349
 
347
- Create and communicate with the child through the native Agent tools. Yui does
348
- not create, address, resume, or terminate that child. The child returns its
349
- result through the native child-result mechanism and must not mutate Yui
350
- lifecycle state. Wait on the native completion event in this Leader turn and
351
- keep the current Leader Run active until that one result arrives; do not yield
352
- the Run as though Yui could wake it for a native child.
350
+ Create and communicate with children through the native Agent tools. Yui does
351
+ not create, address, resume, or terminate those children; it observes their
352
+ structured lifecycle so the parent AgentRun can span the provider Turns needed
353
+ to receive their results. Children must not mutate Yui lifecycle state. Let the
354
+ provider's native completion mechanism return results to the Leader, then
355
+ synthesize them before deciding the next Yui workflow outcome.
353
356
 
354
357
  Review the returned work and run proportionate checks. Record each round in the
355
358
  WorkItem summary; preserve earlier round facts when updating it:
@@ -617,9 +620,10 @@ evidence; truthfully surface the blocker through the supported provider failure
617
620
  boundary. Do not add a fallback protocol.
618
621
 
619
622
  Yield before waiting only for managed Task Role or Reviewer results whose
620
- durable mailbox can wake the Task. Do not yield while a native child result is
621
- outstanding; its native completion event returns to this same Leader turn and
622
- requires the exact Leader Run fence to remain active.
623
+ durable mailbox can wake the Task. Do not yield merely because native child
624
+ results are outstanding: the provider owns their completion notifications, and
625
+ Yui keeps this AgentRun active across intermediate provider Turns. After native
626
+ work drains, continue to Task completion, InputRequest, or final yield.
623
627
 
624
628
  Complete only after required WorkItems are accepted, Role work is terminal,
625
629
  latest isolated results are integrated or deliberately abandoned, and user
@@ -162,11 +162,13 @@ Do not pre-split WorkItems or decide their dependsOn, execution path,
162
162
  acceptance, or Integration; the Leader owns WorkItem creation, replacement,
163
163
  parallel dispatch, dependency and conflict resolution inside the one Task.
164
164
 
165
- The Leader chooses among direct execution, a native subagent, and a Task Role
166
- AgentRun. A native subagent is created inside the Leader conversation, inherits
167
- the Leader Agent, ignores Task Role Agent bindings, and has no Yui launch
168
- command. A Task Role is required when the user requests a different provider,
169
- credentials, interactive Session, or durable independent lifecycle.
165
+ The Leader chooses among direct execution, native subagents, and a Task Role
166
+ AgentRun. Native subagents are created inside the Leader Session, inherit the
167
+ Leader Agent, ignore Task Role Agent bindings, and have no Yui launch command.
168
+ Their structured lifecycle and completion notifications may span provider
169
+ Turns inside the same Yui AgentRun. A Task Role is required when the user
170
+ requests a different provider, credentials, interactive Session, or durable
171
+ independent lifecycle.
170
172
 
171
173
  When the user requires a specific Leader or Worker provider, inspect Roles
172
174
  before routing: