@linxiraos/pi-utils 1.1.9 → 1.1.11

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 (167) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/THIRD-PARTY-NOTICES.txt +22909 -0
  3. package/dist/types/abortable.d.ts +32 -0
  4. package/dist/types/acp/connection.d.ts +118 -0
  5. package/dist/types/acp/protocol.d.ts +526 -0
  6. package/dist/types/acp/schema.d.ts +41 -0
  7. package/dist/types/acp/stream.d.ts +8 -0
  8. package/dist/types/acp/transport.d.ts +88 -0
  9. package/dist/types/acp.d.ts +6 -0
  10. package/dist/types/ar/arj.d.ts +5 -0
  11. package/dist/types/ar/asar.d.ts +7 -0
  12. package/dist/types/ar/bytes.d.ts +20 -0
  13. package/dist/types/ar/cab.d.ts +5 -0
  14. package/dist/types/ar/checksums.d.ts +10 -0
  15. package/dist/types/ar/codecs/bzip2.d.ts +4 -0
  16. package/dist/types/ar/codecs/gzip.d.ts +6 -0
  17. package/dist/types/ar/codecs/lzma.d.ts +6 -0
  18. package/dist/types/ar/codecs/lzw.d.ts +4 -0
  19. package/dist/types/ar/codecs/lzx.d.ts +7 -0
  20. package/dist/types/ar/codecs/xz.d.ts +4 -0
  21. package/dist/types/ar/codecs/zstd.d.ts +6 -0
  22. package/dist/types/ar/cpio.d.ts +7 -0
  23. package/dist/types/ar/deb.d.ts +5 -0
  24. package/dist/types/ar/entries.d.ts +22 -0
  25. package/dist/types/ar/error.d.ts +8 -0
  26. package/dist/types/ar/index.d.ts +11 -0
  27. package/dist/types/ar/iso.d.ts +5 -0
  28. package/dist/types/ar/limits.d.ts +33 -0
  29. package/dist/types/ar/lzh.d.ts +7 -0
  30. package/dist/types/ar/open.d.ts +45 -0
  31. package/dist/types/ar/paths.d.ts +18 -0
  32. package/dist/types/ar/rar/rar4-decoder.d.ts +6 -0
  33. package/dist/types/ar/rar/rar5-decoder.d.ts +6 -0
  34. package/dist/types/ar/rar.d.ts +5 -0
  35. package/dist/types/ar/reader.d.ts +28 -0
  36. package/dist/types/ar/registry.d.ts +17 -0
  37. package/dist/types/ar/rpm.d.ts +5 -0
  38. package/dist/types/ar/sevenzip/decode.d.ts +33 -0
  39. package/dist/types/ar/sevenzip.d.ts +5 -0
  40. package/dist/types/ar/source.d.ts +54 -0
  41. package/dist/types/ar/tar.d.ts +9 -0
  42. package/dist/types/ar/types.d.ts +99 -0
  43. package/dist/types/ar/unix-ar.d.ts +7 -0
  44. package/dist/types/ar/write.d.ts +10 -0
  45. package/dist/types/ar/zip.d.ts +10 -0
  46. package/dist/types/async.d.ts +32 -0
  47. package/dist/types/binary.d.ts +23 -0
  48. package/dist/types/browsers.d.ts +68 -0
  49. package/dist/types/chalk.d.ts +125 -0
  50. package/dist/types/cli.d.ts +134 -0
  51. package/dist/types/color.d.ts +136 -0
  52. package/dist/types/dates.d.ts +7 -0
  53. package/dist/types/dirs.d.ts +323 -0
  54. package/dist/types/docx/converter.d.ts +46 -0
  55. package/dist/types/docx/xml.d.ts +26 -0
  56. package/dist/types/docx.d.ts +11 -0
  57. package/dist/types/dom/core.d.ts +431 -0
  58. package/dist/types/dom/parser.d.ts +7 -0
  59. package/dist/types/dom/selector.d.ts +5 -0
  60. package/dist/types/dom.d.ts +5 -0
  61. package/dist/types/env.d.ts +132 -0
  62. package/dist/types/fetch-retry.d.ts +98 -0
  63. package/dist/types/file-lock.d.ts +23 -0
  64. package/dist/types/format.d.ts +37 -0
  65. package/dist/types/frontmatter.d.ts +46 -0
  66. package/dist/types/fs-error.d.ts +31 -0
  67. package/dist/types/glob.d.ts +28 -0
  68. package/dist/types/headers.d.ts +34 -0
  69. package/dist/types/incoming-json.d.ts +232 -0
  70. package/dist/types/index.d.ts +43 -0
  71. package/dist/types/json-lexer.d.ts +116 -0
  72. package/dist/types/json-parse.d.ts +83 -0
  73. package/dist/types/json.d.ts +20 -0
  74. package/dist/types/logger/rotating-file.d.ts +18 -0
  75. package/dist/types/logger.d.ts +96 -0
  76. package/dist/types/loop-phase.d.ts +10 -0
  77. package/dist/types/lru.d.ts +46 -0
  78. package/dist/types/marked/core.d.ts +445 -0
  79. package/dist/types/marked.d.ts +2 -0
  80. package/dist/types/materialize-string.d.ts +7 -0
  81. package/dist/types/math-delimiters.d.ts +45 -0
  82. package/dist/types/mermaid-ascii.d.ts +11 -0
  83. package/dist/types/mime.d.ts +29 -0
  84. package/dist/types/module-timer.d.ts +1 -0
  85. package/dist/types/path-tree.d.ts +76 -0
  86. package/dist/types/path.d.ts +4 -0
  87. package/dist/types/peek-file.d.ts +29 -0
  88. package/dist/types/postmortem.d.ts +178 -0
  89. package/dist/types/process-name.d.ts +7 -0
  90. package/dist/types/procmgr.d.ts +76 -0
  91. package/dist/types/prompt.d.ts +18 -0
  92. package/dist/types/ptree.d.ts +124 -0
  93. package/dist/types/readability/readability.d.ts +9 -0
  94. package/dist/types/readability/readerable.d.ts +10 -0
  95. package/dist/types/readability/types.d.ts +70 -0
  96. package/dist/types/readability.d.ts +4 -0
  97. package/dist/types/ring.d.ts +93 -0
  98. package/dist/types/runtime-install.d.ts +85 -0
  99. package/dist/types/sanitize-text.d.ts +29 -0
  100. package/dist/types/snowflake.d.ts +25 -0
  101. package/dist/types/sqlite.d.ts +26 -0
  102. package/dist/types/stderr-guard.d.ts +22 -0
  103. package/dist/types/stream.d.ts +75 -0
  104. package/dist/types/tab-spacing.d.ts +24 -0
  105. package/dist/types/temp.d.ts +24 -0
  106. package/dist/types/template.d.ts +62 -0
  107. package/dist/types/timing-buffer.d.ts +22 -0
  108. package/dist/types/tls-fetch.d.ts +50 -0
  109. package/dist/types/turndown/gfm.d.ts +11 -0
  110. package/dist/types/turndown/html.d.ts +5 -0
  111. package/dist/types/turndown/service.d.ts +21 -0
  112. package/dist/types/turndown/types.d.ts +70 -0
  113. package/dist/types/turndown.d.ts +4 -0
  114. package/dist/types/type-guards.d.ts +5 -0
  115. package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
  116. package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
  117. package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
  118. package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
  119. package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
  120. package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
  121. package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
  122. package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
  123. package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
  124. package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
  125. package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
  126. package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
  127. package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
  128. package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
  129. package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
  130. package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
  131. package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
  132. package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
  133. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
  134. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
  135. package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
  136. package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
  137. package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
  138. package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
  139. package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
  140. package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
  141. package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
  142. package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
  143. package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
  144. package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
  145. package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
  146. package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
  147. package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
  148. package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
  149. package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
  150. package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
  151. package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +23 -0
  152. package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
  153. package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
  154. package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
  155. package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
  156. package/dist/types/version.d.ts +18 -0
  157. package/dist/types/vterm/buffer.d.ts +99 -0
  158. package/dist/types/vterm/query-responder.d.ts +24 -0
  159. package/dist/types/vterm/terminal.d.ts +44 -0
  160. package/dist/types/vterm.d.ts +9 -0
  161. package/dist/types/which.d.ts +37 -0
  162. package/dist/types/worker-host.d.ts +51 -0
  163. package/dist/types/xml.d.ts +31 -0
  164. package/package.json +60 -57
  165. package/src/dirs.ts +40 -60
  166. package/src/env.ts +7 -14
  167. package/src/procmgr.ts +7 -0
@@ -0,0 +1,51 @@
1
+ /** Prefix reserved for argv selectors dispatched by the shared CLI worker host. */
2
+ export declare const WORKER_HOST_SELECTOR_PREFIX = "__omp_worker_";
3
+ /** Whether an argv value selects a worker hosted by the shared CLI entrypoint. */
4
+ export declare function isWorkerHostSelector(value: string | undefined): value is string;
5
+ /** Called by CLI entrypoints whose main module dispatches worker argv selectors. */
6
+ export declare function declareWorkerHostEntry(): void;
7
+ /** Main-module path of the self-dispatching CLI host, or null outside it. */
8
+ export declare function workerHostEntry(): string | null;
9
+ /**
10
+ * Buffers messages a Bun worker thread receives before its real handler is
11
+ * attached, then hands them off once it is.
12
+ *
13
+ * Bun delivers messages the parent posted before the worker spawned exactly
14
+ * once — when the worker entry module's top-level evaluation completes — to the
15
+ * `message` listeners present at that moment. A worker whose handler attaches
16
+ * via a later `await import(...)` therefore misses that flush. The
17
+ * self-dispatching CLI host imports each worker module dynamically from inside
18
+ * its argv dispatch, so the worker's own `parentPort.on("message")` lands after
19
+ * the flush and the parent's synchronously-posted `init` handshake is dropped —
20
+ * every run then stalls until the init timeout fires and silently falls back to
21
+ * the inline worker (issue: eval cells always taking the full timeout).
22
+ *
23
+ * The host calls {@link installWorkerInbox} synchronously in the entry's sync
24
+ * prefix (before importing the worker module) so a `parentPort` listener exists
25
+ * at flush time; the worker module then {@link consumeWorkerInbox}es it and
26
+ * binds the real handler, replaying anything buffered. Re-dispatching through
27
+ * `parentPort.emit("message", …)` is not an option — Bun's port is an
28
+ * `EventTarget` whose `emit` throws — so the inbox calls the handler directly.
29
+ */
30
+ export interface WorkerInbox {
31
+ /** Route buffered and subsequent messages to `handler`; returns an unbind fn. */
32
+ bind(handler: (message: unknown) => void): () => void;
33
+ }
34
+ /** Minimal `parentPort` surface the inbox needs (Node/Bun `MessagePort`). */
35
+ interface MessageListenerPort {
36
+ on(event: "message", listener: (value: unknown) => void): unknown;
37
+ }
38
+ /**
39
+ * Attach a buffering `message` listener on `port` synchronously and stash the
40
+ * resulting inbox for the worker module to {@link consumeWorkerInbox}. MUST be
41
+ * called in the entry module's synchronous prefix — before the worker module is
42
+ * imported — so the listener exists when Bun flushes pre-spawn messages.
43
+ */
44
+ export declare function installWorkerInbox(port: MessageListenerPort): WorkerInbox;
45
+ /**
46
+ * Take the inbox installed by {@link installWorkerInbox} for this worker, or
47
+ * `null` when the worker module was loaded directly (no host pre-buffering, so
48
+ * the module's own synchronous top-level listener already wins the flush).
49
+ */
50
+ export declare function consumeWorkerInbox(): WorkerInbox | null;
51
+ export {};
@@ -0,0 +1,31 @@
1
+ /** Behavior-compatible reimplementation of fast-xml-parser's used surface. */
2
+ /** Context supplied to an array-selection callback. */
3
+ export type XMLArraySelector = (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean | null) => boolean;
4
+ /** Options supported by {@link XMLParser}. */
5
+ export interface XMLParserOptions {
6
+ /** Omits attributes when true (default). */
7
+ ignoreAttributes?: boolean;
8
+ /** Prefix applied to attribute property names. */
9
+ attributeNamePrefix?: string;
10
+ /** Property used for text alongside children or attributes. */
11
+ textNodeName?: string;
12
+ /** Trims ordinary text and attribute values. */
13
+ trimValues?: boolean;
14
+ /** Coerces numeric and boolean element text. */
15
+ parseTagValue?: boolean;
16
+ /** Coerces numeric and boolean attribute values. */
17
+ parseAttributeValue?: boolean;
18
+ /** Controls entity processing and its expansion ceiling. */
19
+ processEntities?: boolean | {
20
+ maxTotalExpansions?: number;
21
+ };
22
+ /** Selects element or attribute properties that must always be arrays. */
23
+ isArray?: XMLArraySelector;
24
+ }
25
+ /** Parses XML into the object shape used by the document converters. */
26
+ export declare class XMLParser {
27
+ #private;
28
+ constructor(options?: XMLParserOptions);
29
+ /** Parses one XML document. */
30
+ parse(xml: string): unknown;
31
+ }
package/package.json CHANGED
@@ -1,59 +1,62 @@
1
1
  {
2
- "engines": {
3
- "bun": ">=1.3.14"
4
- },
5
- "devDependencies": {
6
- "@types/bun": "^1.3.14"
7
- },
8
- "dependencies": {
9
- "@linxiraos/pi-natives": "1.1.9"
10
- },
11
- "scripts": {
12
- "test": "bun test --parallel",
13
- "check:types": "tsgo -p tsconfig.json --noEmit",
14
- "check": "tsgo -p tsconfig.json --noEmit"
15
- },
16
- "exports": {
17
- "./*.js": "./src/*.ts",
18
- "./*": {
19
- "import": "./src/*.ts",
20
- "types": "./src/*.ts"
21
- },
22
- "./ar": {
23
- "import": "./src/ar/index.ts",
24
- "types": "./src/ar/index.ts"
25
- },
26
- ".": {
27
- "import": "./src/index.ts",
28
- "types": "./src/index.ts"
29
- }
30
- },
31
- "types": "./src/index.ts",
32
- "main": "./src/index.ts",
33
- "type": "module",
34
- "files": [
35
- "src",
36
- "README.md",
37
- "CHANGELOG.md"
38
- ],
39
- "repository": {
40
- "directory": "packages/utils",
41
- "url": "git+https://github.com/Linxira-OS/linxira-zeta.git",
42
- "type": "git"
43
- },
44
- "author": "Can Boluk",
45
- "license": "MIT",
46
- "bugs": {
47
- "url": "https://github.com/Linxira-OS/linxira-zeta/issues"
48
- },
49
- "homepage": "https://linxira-os.github.io/zeta/",
50
- "keywords": [
51
- "utilities",
52
- "cli",
53
- "logging",
54
- "streams"
55
- ],
56
- "description": "Shared utilities for pi packages",
57
- "version": "1.1.9",
58
- "name": "@linxiraos/pi-utils"
2
+ "name": "@linxiraos/pi-utils",
3
+ "version": "1.1.11",
4
+ "description": "Shared utilities for pi packages",
5
+ "keywords": [
6
+ "utilities",
7
+ "cli",
8
+ "logging",
9
+ "streams"
10
+ ],
11
+ "homepage": "https://linxira-os.github.io/zeta/",
12
+ "bugs": {
13
+ "url": "https://github.com/Linxira-OS/linxira-zeta/issues"
14
+ },
15
+ "license": "MIT",
16
+ "author": "Can Boluk",
17
+ "repository": {
18
+ "directory": "packages/utils",
19
+ "url": "git+https://github.com/Linxira-OS/linxira-zeta.git",
20
+ "type": "git"
21
+ },
22
+ "files": [
23
+ "src",
24
+ "README.md",
25
+ "CHANGELOG.md",
26
+ "LICENSE",
27
+ "THIRD-PARTY-NOTICES.txt",
28
+ "dist/types"
29
+ ],
30
+ "type": "module",
31
+ "main": "./src/index.ts",
32
+ "types": "./dist/types/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/types/index.d.ts",
36
+ "import": "./src/index.ts"
37
+ },
38
+ "./ar": {
39
+ "types": "./dist/types/ar/index.d.ts",
40
+ "import": "./src/ar/index.ts"
41
+ },
42
+ "./*": {
43
+ "types": "./dist/types/*.d.ts",
44
+ "import": "./src/*.ts"
45
+ },
46
+ "./*.js": "./src/*.ts"
47
+ },
48
+ "scripts": {
49
+ "check": "tsgo -p tsconfig.json --noEmit",
50
+ "check:types": "tsgo -p tsconfig.json --noEmit",
51
+ "test": "bun test --parallel"
52
+ },
53
+ "dependencies": {
54
+ "@linxiraos/pi-natives": "1.1.11"
55
+ },
56
+ "devDependencies": {
57
+ "@types/bun": "^1.3.14"
58
+ },
59
+ "engines": {
60
+ "bun": ">=1.3.14"
61
+ }
59
62
  }
package/src/dirs.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Centralized path helpers for zeta config directories.
3
3
  *
4
4
  * Uses PI_CONFIG_DIR (default ".zeta") for the config root and
5
- * PI_CODING_AGENT_DIR to override the agent directory.
5
+ * ZETA_CODING_AGENT_DIR to override the agent directory.
6
6
  *
7
7
  * On Linux, if XDG_DATA_HOME / XDG_STATE_HOME / XDG_CACHE_HOME environment
8
8
  * variables are set, paths are redirected to XDG-compliant locations under
@@ -36,7 +36,7 @@ export const USER_AGENT = `zeta/${VERSION}`;
36
36
  export const MIN_BUN_VERSION: string = engines.bun.replace(/[^0-9.]/g, "");
37
37
 
38
38
  const PROFILE_NAME_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/;
39
- const PROFILE_ENV_KEYS = ["OMP_PROFILE", "PI_PROFILE"] as const;
39
+ const PROFILE_ENV_KEYS = ["ZETA_PROFILE"] as const;
40
40
 
41
41
  /**
42
42
  * Names Windows treats as reserved device aliases. Matches the basename
@@ -76,24 +76,21 @@ export function normalizeProfileName(profile: string | undefined): string | unde
76
76
  }
77
77
 
78
78
  /**
79
- * Resolve the active profile from the two profile env vars. `OMP_PROFILE` is the
80
- * canonical variable and takes precedence; `PI_PROFILE` is the legacy
81
- * compatibility fallback, consulted only when `OMP_PROFILE` is undefined. An
82
- * explicitly-empty `OMP_PROFILE` therefore selects the default profile rather
83
- * than silently inheriting `PI_PROFILE`. Delegates validation/normalization to
84
- * {@link normalizeProfileName} (which throws on a syntactically invalid value).
79
+ * Resolve the active profile from `ZETA_PROFILE`. Delegates
80
+ * validation/normalization to {@link normalizeProfileName} (which throws on a
81
+ * syntactically invalid value).
85
82
  */
86
- export function resolveProfileEnv(omp: string | undefined, pi: string | undefined): string | undefined {
87
- return normalizeProfileName(omp !== undefined ? omp : pi);
83
+ export function resolveProfileEnv(profile: string | undefined): string | undefined {
84
+ return normalizeProfileName(profile);
88
85
  }
89
86
 
90
87
  function getProfileFromEnv(): string | undefined {
91
- return resolveProfileEnv(process.env.OMP_PROFILE, process.env.PI_PROFILE);
88
+ return resolveProfileEnv(process.env.ZETA_PROFILE);
92
89
  }
93
90
 
94
91
  /**
95
92
  * Module-load profile resolution. Unlike {@link getProfileFromEnv}, an invalid
96
- * OMP_PROFILE/PI_PROFILE value does NOT throw here — a bad env var must not
93
+ * ZETA_PROFILE value does NOT throw here — a bad env var must not
97
94
  * crash a bare `import` of this module with an uncaught stack trace before the
98
95
  * CLI's error handling is in scope. The default profile is used instead; the
99
96
  * CLI re-validates the env (see `runCli` in coding-agent/src/cli.ts) so the
@@ -116,14 +113,6 @@ function getProfileConfigRoot(profile: string | undefined): string {
116
113
  return profile ? path.join(root, "profiles", profile) : root;
117
114
  }
118
115
 
119
- function readPiProfileFromEnvSafe(): string | undefined {
120
- try {
121
- return normalizeProfileName(process.env.PI_PROFILE);
122
- } catch {
123
- return undefined;
124
- }
125
- }
126
-
127
116
  function getProfileAgentDir(profile: string): string {
128
117
  return path.join(getProfileConfigRoot(profile), "agent");
129
118
  }
@@ -398,14 +387,14 @@ class DirResolver {
398
387
  }
399
388
 
400
389
  /**
401
- * Decide which `PI_CODING_AGENT_DIR` value to capture as the pre-profile
390
+ * Decide which `ZETA_CODING_AGENT_DIR` value to capture as the pre-profile
402
391
  * baseline. A value equal to a profile's derived agent dir is profile-derived
403
392
  * (propagated by a parent's `setProfile`), so it must NOT be snapshotted as the
404
393
  * default-mode baseline — otherwise default mode would resolve to the profile's
405
- * agent dir. The profile source can be the active profile or a lower-priority
406
- * `PI_PROFILE` that was bypassed because `OMP_PROFILE` explicitly selected the
407
- * default profile. Returns `undefined` in those cases so reset falls back to the
408
- * standard `~/.zeta/agent`.
394
+ * agent dir. The profile source can be the active profile or an inherited
395
+ * `ZETA_PROFILE` (for example a parent CLI process that resolved a profile
396
+ * without exporting it). Returns `undefined` in those cases so reset falls back
397
+ * to the standard `~/.zeta/agent`.
409
398
  */
410
399
  function resolvePreProfileAgentDir(
411
400
  profile: string | undefined,
@@ -420,14 +409,21 @@ let activeProfile = readProfileFromEnvSafe();
420
409
  /**
421
410
  * Resolve the agent-dir override for the current `activeProfile` from the live
422
411
  * environment. A named profile derives its own agent dir (no override); default
423
- * mode honors a non-profile `PI_CODING_AGENT_DIR` (see
412
+ * mode honors a non-profile `ZETA_CODING_AGENT_DIR` (see
424
413
  * {@link resolvePreProfileAgentDir}). Shared by the module-load resolver and
425
414
  * {@link refreshDirsFromEnv} so both apply identical logic.
426
415
  */
427
416
  function resolveActiveAgentDirOverride(): string | undefined {
428
- return activeProfile
429
- ? undefined
430
- : resolvePreProfileAgentDir(undefined, process.env.PI_CODING_AGENT_DIR, readPiProfileFromEnvSafe());
417
+ if (activeProfile) return undefined;
418
+ // A ZETA_CODING_AGENT_DIR pointing under a profile subtree
419
+ // (`profiles/<name>/agent`) is derived state inherited from a parent that
420
+ // activated a profile — with a single profile key there is no second env var
421
+ // to consult, so the directory shape is the only witness. Treat it as absent
422
+ // for default-mode resolution (and the pre-profile snapshot), or default mode
423
+ // would silently resolve into a profile's agent dir.
424
+ const env = process.env.ZETA_CODING_AGENT_DIR;
425
+ if (env && /[/\\]profiles[/\\][^/\\]+[/\\]agent$/.test(env.replace(/\\/g, "/"))) return undefined;
426
+ return resolvePreProfileAgentDir(undefined, env);
431
427
  }
432
428
 
433
429
  let dirs = new DirResolver({
@@ -435,21 +431,16 @@ let dirs = new DirResolver({
435
431
  profile: activeProfile,
436
432
  });
437
433
  /**
438
- * Snapshot of `PI_CODING_AGENT_DIR` from before the first named-profile
434
+ * Snapshot of `ZETA_CODING_AGENT_DIR` from before the first named-profile
439
435
  * activation. Reset paths restore this value (or its absence) instead of
440
436
  * unconditionally deleting the env var. Without the snapshot, a process started
441
- * with `PI_CODING_AGENT_DIR=/custom` then `setProfile("work")` then
437
+ * with `ZETA_CODING_AGENT_DIR=/custom` then `setProfile("work")` then
442
438
  * `setProfile(undefined)` would silently lose `/custom` and fall back to
443
439
  * `~/.zeta/agent`. Captured at module load — ignoring a profile-derived value
444
- * inherited from a parent's `setProfile` (see {@link resolvePreProfileAgentDir})
445
- * — and refreshed on `setAgentDir`, since that call is the user explicitly
446
- * redefining the baseline.
440
+ * inherited from a parent's `setProfile` (detected by directory shape in
441
+ * {@link resolveActiveAgentDirOverride}) — and refreshed on `setAgentDir`.
447
442
  */
448
- let preProfileAgentDirEnv: string | undefined = resolvePreProfileAgentDir(
449
- activeProfile,
450
- process.env.PI_CODING_AGENT_DIR,
451
- activeProfile ?? readPiProfileFromEnvSafe(),
452
- );
443
+ let preProfileAgentDirEnv: string | undefined = resolveActiveAgentDirOverride();
453
444
  // Anchor home for the resolver. Captured at module load to stay stable across
454
445
  // test mocks of `os.homedir()`. `getPluginsDir(home)` compares against this so
455
446
  // production callers (`home === RESOLVER_HOME`) hit the XDG-aware resolver while
@@ -459,7 +450,7 @@ const RESOLVER_HOME = os.homedir();
459
450
  /**
460
451
  * Rebuild the dirs resolver from the current environment, reusing the profile
461
452
  * resolved at module load. Directory-affecting keys (XDG_*_HOME and, in default
462
- * mode, `PI_CODING_AGENT_DIR`) loaded from a profile/agent `.env` only reach
453
+ * mode, `ZETA_CODING_AGENT_DIR`) loaded from a profile/agent `.env` only reach
463
454
  * `process.env` *after* this module froze the resolver at import time, so
464
455
  * `env.ts` calls this once after applying its `.env` files. The agent `.env`
465
456
  * location derives from the profile name + home before this runs, so the
@@ -486,15 +477,14 @@ export function getConfigRootDir(): string {
486
477
  export function setAgentDir(dir: string): void {
487
478
  activeProfile = undefined;
488
479
  dirs = new DirResolver({ agentDirOverride: dir });
489
- process.env.PI_CODING_AGENT_DIR = dir;
490
- preProfileAgentDirEnv = dir;
480
+ process.env.ZETA_CODING_AGENT_DIR = dir;
491
481
  for (const key of PROFILE_ENV_KEYS) {
492
482
  delete process.env[key];
493
483
  }
494
484
  }
495
485
 
496
486
  /**
497
- * Test-only: reset the pre-profile `PI_CODING_AGENT_DIR` snapshot to whatever
487
+ * Test-only: reset the pre-profile `ZETA_CODING_AGENT_DIR` snapshot to whatever
498
488
  * the current environment looks like. Cross-suite test pollution can otherwise
499
489
  * leak a stale snapshot through `setAgentDir` and corrupt `setProfile(undefined)`
500
490
  * restore semantics. Production code MUST NOT call this — the snapshot's
@@ -502,11 +492,7 @@ export function setAgentDir(dir: string): void {
502
492
  * no business clearing it.
503
493
  */
504
494
  export function __resetProfileSnapshotForTests(): void {
505
- preProfileAgentDirEnv = resolvePreProfileAgentDir(
506
- activeProfile,
507
- process.env.PI_CODING_AGENT_DIR,
508
- activeProfile ?? readPiProfileFromEnvSafe(),
509
- );
495
+ preProfileAgentDirEnv = resolveActiveAgentDirOverride();
510
496
  }
511
497
 
512
498
  /**
@@ -521,35 +507,29 @@ export function __resetDirsFromEnvForTests(): void {
521
507
  refreshDirsFromEnv();
522
508
  }
523
509
 
524
- /** Activate a named profile. Passing undefined or "default" returns to the default profile. */
525
510
  export function setProfile(profile: string | undefined): void {
526
511
  const next = normalizeProfileName(profile);
527
512
  if (next && !activeProfile) {
528
513
  // First activation of a named profile in this process: snapshot the
529
- // current PI_CODING_AGENT_DIR so a later reset can restore the user's
514
+ // current ZETA_CODING_AGENT_DIR so a later reset can restore the user's
530
515
  // explicit override. Subsequent profile switches keep the original
531
516
  // snapshot — the "pre-profile" baseline is the state before profiles
532
517
  // entered the picture, not the state between two activations.
533
- preProfileAgentDirEnv = resolvePreProfileAgentDir(
534
- undefined,
535
- process.env.PI_CODING_AGENT_DIR,
536
- readPiProfileFromEnvSafe(),
537
- );
518
+ preProfileAgentDirEnv = resolveActiveAgentDirOverride();
538
519
  }
539
520
  activeProfile = next;
540
521
  if (activeProfile) {
541
522
  dirs = new DirResolver({ profile: activeProfile });
542
- process.env.OMP_PROFILE = activeProfile;
543
- process.env.PI_PROFILE = activeProfile;
544
- process.env.PI_CODING_AGENT_DIR = dirs.agentDir;
523
+ process.env.ZETA_PROFILE = activeProfile;
524
+ process.env.ZETA_CODING_AGENT_DIR = dirs.agentDir;
545
525
  } else {
546
526
  for (const key of PROFILE_ENV_KEYS) {
547
527
  delete process.env[key];
548
528
  }
549
529
  if (preProfileAgentDirEnv === undefined) {
550
- delete process.env.PI_CODING_AGENT_DIR;
530
+ delete process.env.ZETA_CODING_AGENT_DIR;
551
531
  } else {
552
- process.env.PI_CODING_AGENT_DIR = preProfileAgentDirEnv;
532
+ process.env.ZETA_CODING_AGENT_DIR = preProfileAgentDirEnv;
553
533
  }
554
534
  dirs = new DirResolver({ agentDirOverride: preProfileAgentDirEnv });
555
535
  }
package/src/env.ts CHANGED
@@ -112,9 +112,10 @@ export function filterChildShellEnv(
112
112
  env: Record<string, string | undefined>,
113
113
  cwd: string = process.cwd(),
114
114
  ): Record<string, string> {
115
+ const runtimeLaunchEnvValues = env === Bun.env || env === process.env ? launchEnvValues : undefined;
115
116
  const result = filterProcessEnv(env);
116
117
  const projectEnv = parseEnvFile(path.join(cwd, ".env"));
117
- const launchNodeEnv = launchEnvValues ? launchEnvValues.get("NODE_ENV") : env.NODE_ENV;
118
+ const launchNodeEnv = runtimeLaunchEnvValues ? runtimeLaunchEnvValues.get("NODE_ENV") : env.NODE_ENV;
118
119
  const nodeEnvName = `.env.${launchNodeEnv || "development"}`;
119
120
  const modeEnv = parseEnvFile(path.join(cwd, nodeEnvName));
120
121
  const localEnv = parseEnvFile(path.join(cwd, ".env.local"));
@@ -128,7 +129,7 @@ export function filterChildShellEnv(
128
129
  };
129
130
  let fallbackLaunchEnv: Record<string, string> | undefined;
130
131
  let expandedFallbackLaunchEnv: Record<string, string> | undefined;
131
- if (!launchEnvValues && nodeEnvName !== ".env.development") {
132
+ if (!runtimeLaunchEnvValues && nodeEnvName !== ".env.development") {
132
133
  const fallbackModeEnv = parseEnvFile(path.join(cwd, ".env.development"));
133
134
  const fallbackModeLocalEnv = parseEnvFile(path.join(cwd, ".env.development.local"));
134
135
  const candidate = { ...projectEnv, ...fallbackModeEnv, ...localEnv, ...fallbackModeLocalEnv };
@@ -147,7 +148,7 @@ export function filterChildShellEnv(
147
148
  }
148
149
  const allLaunchEnv = fallbackLaunchEnv ? { ...launchEnv, ...fallbackLaunchEnv } : launchEnv;
149
150
  for (const key in allLaunchEnv) {
150
- const launchValue = launchEnvValues?.get(key);
151
+ const launchValue = runtimeLaunchEnvValues?.get(key);
151
152
  if (launchValue !== undefined) {
152
153
  // Launcher-owned name: it keeps the launcher's own value. Bun overwrites
153
154
  // an empty launcher value with the dotenv one, so restore the launcher
@@ -163,7 +164,7 @@ export function filterChildShellEnv(
163
164
  }
164
165
  continue;
165
166
  }
166
- if (launchEnvValues || projectEnvNamesLoadedByOmp.has(key)) {
167
+ if (runtimeLaunchEnvValues || projectEnvNamesLoadedByOmp.has(key)) {
167
168
  // Strong provenance: the launch environment is known and this name is
168
169
  // absent from it, or OMP itself injected the value — either way it came
169
170
  // from a project dotenv file, not the parent shell.
@@ -211,8 +212,7 @@ function parseEnvLine(line: string): { key: string; value: string } | undefined
211
212
 
212
213
  /**
213
214
  * Parses a .env file synchronously into key-value string pairs using
214
- * {@link parseEnvLine} for Bun-compatible line semantics, then mirrors valid
215
- * `OMP_` variables to their `PI_` aliases.
215
+ * {@link parseEnvLine} for Bun-compatible line semantics.
216
216
  */
217
217
  export function parseEnvFile(filePath: string): Record<string, string> {
218
218
  const result: Record<string, string> = {};
@@ -226,13 +226,6 @@ export function parseEnvFile(filePath: string): Record<string, string> {
226
226
  // File doesn't exist or can't be read - return empty result
227
227
  }
228
228
 
229
- // OMP_ overrides PI_
230
- for (const k in result) {
231
- if (k.startsWith("OMP_")) {
232
- result[`PI_${k.slice(4)}`] = result[k];
233
- }
234
- }
235
-
236
229
  return result;
237
230
  }
238
231
 
@@ -258,7 +251,7 @@ for (const file of [projectEnv, agentEnv, piEnv, homeEnv]) {
258
251
  }
259
252
  }
260
253
 
261
- // Directory-affecting keys (XDG_*_HOME, and in default mode PI_CODING_AGENT_DIR)
254
+ // Directory-affecting keys (XDG_*_HOME, and in default mode ZETA_CODING_AGENT_DIR)
262
255
  // may have just arrived from the profile/agent `.env` applied above. The dirs
263
256
  // resolver cached its paths at module load — before this file ran — so rebuild
264
257
  // it now from the updated env. `getAgentDir()` already located the `.env` from
package/src/procmgr.ts CHANGED
@@ -82,6 +82,13 @@ export function isPowerShell(shell: string): boolean {
82
82
  return basename === "powershell.exe" || basename === "powershell" || basename === "pwsh.exe" || basename === "pwsh";
83
83
  }
84
84
 
85
+ const POSIX_SHELL_PATTERN = /(?:^|[\\/])(?:sh|bash|dash|ash|ksh|zsh)(?:\.exe)?$/i;
86
+
87
+ /** Whether the executable is a known shell whose command language uses POSIX quoting. */
88
+ export function isPosixShell(shell: string): boolean {
89
+ return POSIX_SHELL_PATTERN.test(shell);
90
+ }
91
+
85
92
  /**
86
93
  * Get shell prefix for wrapping commands (profilers, strace, etc.).
87
94
  */