@linxiraos/pi-utils 1.0.0

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 (244) hide show
  1. package/CHANGELOG.md +449 -0
  2. package/README.md +36 -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 +81 -0
  9. package/dist/types/acp.d.ts +6 -0
  10. package/dist/types/async.d.ts +20 -0
  11. package/dist/types/binary.d.ts +17 -0
  12. package/dist/types/browsers.d.ts +68 -0
  13. package/dist/types/chalk.d.ts +125 -0
  14. package/dist/types/cli.d.ts +134 -0
  15. package/dist/types/color.d.ts +102 -0
  16. package/dist/types/dates.d.ts +7 -0
  17. package/dist/types/dirs.d.ts +282 -0
  18. package/dist/types/docx/converter.d.ts +46 -0
  19. package/dist/types/docx/xml.d.ts +26 -0
  20. package/dist/types/docx/zip.d.ts +6 -0
  21. package/dist/types/docx.d.ts +11 -0
  22. package/dist/types/dom/core.d.ts +431 -0
  23. package/dist/types/dom/parser.d.ts +7 -0
  24. package/dist/types/dom/selector.d.ts +5 -0
  25. package/dist/types/dom.d.ts +5 -0
  26. package/dist/types/env.d.ts +124 -0
  27. package/dist/types/fetch-retry.d.ts +96 -0
  28. package/dist/types/file-lock.d.ts +23 -0
  29. package/dist/types/format.d.ts +37 -0
  30. package/dist/types/frontmatter.d.ts +46 -0
  31. package/dist/types/fs-error.d.ts +31 -0
  32. package/dist/types/glob.d.ts +28 -0
  33. package/dist/types/headers.d.ts +34 -0
  34. package/dist/types/index.d.ts +39 -0
  35. package/dist/types/json-parse.d.ts +74 -0
  36. package/dist/types/json.d.ts +14 -0
  37. package/dist/types/logger/rotating-file.d.ts +18 -0
  38. package/dist/types/logger.d.ts +96 -0
  39. package/dist/types/loop-phase.d.ts +10 -0
  40. package/dist/types/lru.d.ts +46 -0
  41. package/dist/types/marked/core.d.ts +445 -0
  42. package/dist/types/marked.d.ts +2 -0
  43. package/dist/types/mermaid-ascii.d.ts +11 -0
  44. package/dist/types/mime.d.ts +29 -0
  45. package/dist/types/module-timer.d.ts +1 -0
  46. package/dist/types/path-tree.d.ts +76 -0
  47. package/dist/types/path.d.ts +2 -0
  48. package/dist/types/peek-file.d.ts +29 -0
  49. package/dist/types/postmortem.d.ts +104 -0
  50. package/dist/types/process-name.d.ts +7 -0
  51. package/dist/types/procmgr.d.ts +74 -0
  52. package/dist/types/prompt.d.ts +18 -0
  53. package/dist/types/ptree.d.ts +110 -0
  54. package/dist/types/readability/readability.d.ts +9 -0
  55. package/dist/types/readability/readerable.d.ts +10 -0
  56. package/dist/types/readability/types.d.ts +70 -0
  57. package/dist/types/readability.d.ts +4 -0
  58. package/dist/types/ring.d.ts +93 -0
  59. package/dist/types/runtime-install.d.ts +78 -0
  60. package/dist/types/sanitize-text.d.ts +29 -0
  61. package/dist/types/snowflake.d.ts +25 -0
  62. package/dist/types/stderr-guard.d.ts +22 -0
  63. package/dist/types/stream.d.ts +67 -0
  64. package/dist/types/tab-spacing.d.ts +24 -0
  65. package/dist/types/temp.d.ts +17 -0
  66. package/dist/types/template.d.ts +62 -0
  67. package/dist/types/timing-buffer.d.ts +22 -0
  68. package/dist/types/tls-fetch.d.ts +37 -0
  69. package/dist/types/turndown/gfm.d.ts +11 -0
  70. package/dist/types/turndown/html.d.ts +5 -0
  71. package/dist/types/turndown/service.d.ts +21 -0
  72. package/dist/types/turndown/types.d.ts +70 -0
  73. package/dist/types/turndown.d.ts +4 -0
  74. package/dist/types/type-guards.d.ts +5 -0
  75. package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
  76. package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
  77. package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
  78. package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
  79. package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
  80. package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
  81. package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
  82. package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
  83. package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
  84. package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
  85. package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
  86. package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
  87. package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
  88. package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
  89. package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
  90. package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
  91. package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
  92. package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
  93. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
  94. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
  95. package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
  96. package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
  97. package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
  98. package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
  99. package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
  100. package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
  101. package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
  102. package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
  103. package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
  104. package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
  105. package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
  106. package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
  107. package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
  108. package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
  109. package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
  110. package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
  111. package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +21 -0
  112. package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
  113. package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
  114. package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
  115. package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
  116. package/dist/types/version.d.ts +18 -0
  117. package/dist/types/vterm/buffer.d.ts +99 -0
  118. package/dist/types/vterm/terminal.d.ts +44 -0
  119. package/dist/types/vterm.d.ts +8 -0
  120. package/dist/types/which.d.ts +37 -0
  121. package/dist/types/worker-host.d.ts +51 -0
  122. package/dist/types/xml.d.ts +31 -0
  123. package/package.json +59 -0
  124. package/src/abortable.ts +109 -0
  125. package/src/acp/connection.ts +344 -0
  126. package/src/acp/protocol.ts +466 -0
  127. package/src/acp/schema.ts +160 -0
  128. package/src/acp/stream.ts +82 -0
  129. package/src/acp/transport.ts +213 -0
  130. package/src/acp.ts +6 -0
  131. package/src/async.ts +91 -0
  132. package/src/binary.ts +50 -0
  133. package/src/browsers.ts +501 -0
  134. package/src/chalk.ts +312 -0
  135. package/src/cli.ts +529 -0
  136. package/src/color.ts +302 -0
  137. package/src/dates.ts +194 -0
  138. package/src/dirs.ts +1026 -0
  139. package/src/docx/converter.ts +681 -0
  140. package/src/docx/xml.ts +166 -0
  141. package/src/docx/zip.ts +87 -0
  142. package/src/docx.ts +20 -0
  143. package/src/dom/core.ts +1254 -0
  144. package/src/dom/parser.ts +370 -0
  145. package/src/dom/selector.ts +290 -0
  146. package/src/dom.ts +33 -0
  147. package/src/env.ts +400 -0
  148. package/src/fetch-retry.ts +379 -0
  149. package/src/file-lock.ts +69 -0
  150. package/src/format.ts +113 -0
  151. package/src/frontmatter.ts +205 -0
  152. package/src/fs-error.ts +56 -0
  153. package/src/glob.ts +189 -0
  154. package/src/headers.ts +167 -0
  155. package/src/index.ts +59 -0
  156. package/src/json-parse.ts +821 -0
  157. package/src/json.ts +23 -0
  158. package/src/logger/rotating-file.ts +149 -0
  159. package/src/logger.ts +798 -0
  160. package/src/loop-phase.ts +49 -0
  161. package/src/lru.ts +185 -0
  162. package/src/marked/core.ts +1576 -0
  163. package/src/marked.ts +2 -0
  164. package/src/mermaid-ascii.ts +31 -0
  165. package/src/mime.ts +159 -0
  166. package/src/module-timer.ts +148 -0
  167. package/src/path-tree.ts +147 -0
  168. package/src/path.ts +28 -0
  169. package/src/peek-file.ts +188 -0
  170. package/src/postmortem.ts +433 -0
  171. package/src/process-name.ts +57 -0
  172. package/src/procmgr.ts +247 -0
  173. package/src/prompt.ts +545 -0
  174. package/src/ptree.ts +412 -0
  175. package/src/readability/readability.ts +533 -0
  176. package/src/readability/readerable.ts +51 -0
  177. package/src/readability/types.ts +72 -0
  178. package/src/readability.ts +11 -0
  179. package/src/ring.ts +169 -0
  180. package/src/runtime-install.ts +393 -0
  181. package/src/sanitize-text.ts +96 -0
  182. package/src/snowflake.ts +121 -0
  183. package/src/stderr-guard.ts +155 -0
  184. package/src/stream.ts +454 -0
  185. package/src/tab-spacing.ts +336 -0
  186. package/src/temp.ts +134 -0
  187. package/src/template.ts +586 -0
  188. package/src/timing-buffer.ts +47 -0
  189. package/src/tls-fetch.ts +178 -0
  190. package/src/turndown/gfm.ts +106 -0
  191. package/src/turndown/html.ts +257 -0
  192. package/src/turndown/service.ts +334 -0
  193. package/src/turndown/types.ts +81 -0
  194. package/src/turndown.ts +5 -0
  195. package/src/type-guards.ts +17 -0
  196. package/src/vendor/mermaid-ascii/NOTICE +33 -0
  197. package/src/vendor/mermaid-ascii/ascii/ansi.ts +409 -0
  198. package/src/vendor/mermaid-ascii/ascii/canvas.ts +476 -0
  199. package/src/vendor/mermaid-ascii/ascii/class-diagram.ts +699 -0
  200. package/src/vendor/mermaid-ascii/ascii/converter.ts +271 -0
  201. package/src/vendor/mermaid-ascii/ascii/draw.ts +1382 -0
  202. package/src/vendor/mermaid-ascii/ascii/edge-bundling.ts +328 -0
  203. package/src/vendor/mermaid-ascii/ascii/edge-routing.ts +297 -0
  204. package/src/vendor/mermaid-ascii/ascii/er-diagram.ts +441 -0
  205. package/src/vendor/mermaid-ascii/ascii/grid.ts +578 -0
  206. package/src/vendor/mermaid-ascii/ascii/index.ts +187 -0
  207. package/src/vendor/mermaid-ascii/ascii/multiline-utils.ts +78 -0
  208. package/src/vendor/mermaid-ascii/ascii/pathfinder.ts +277 -0
  209. package/src/vendor/mermaid-ascii/ascii/sequence.ts +460 -0
  210. package/src/vendor/mermaid-ascii/ascii/shapes/circle.ts +27 -0
  211. package/src/vendor/mermaid-ascii/ascii/shapes/corners.ts +127 -0
  212. package/src/vendor/mermaid-ascii/ascii/shapes/diamond.ts +27 -0
  213. package/src/vendor/mermaid-ascii/ascii/shapes/hexagon.ts +27 -0
  214. package/src/vendor/mermaid-ascii/ascii/shapes/index.ts +101 -0
  215. package/src/vendor/mermaid-ascii/ascii/shapes/rectangle.ts +175 -0
  216. package/src/vendor/mermaid-ascii/ascii/shapes/rounded.ts +27 -0
  217. package/src/vendor/mermaid-ascii/ascii/shapes/special.ts +296 -0
  218. package/src/vendor/mermaid-ascii/ascii/shapes/stadium.ts +114 -0
  219. package/src/vendor/mermaid-ascii/ascii/shapes/state.ts +192 -0
  220. package/src/vendor/mermaid-ascii/ascii/shapes/types.ts +73 -0
  221. package/src/vendor/mermaid-ascii/ascii/types.ts +273 -0
  222. package/src/vendor/mermaid-ascii/ascii/validate.ts +120 -0
  223. package/src/vendor/mermaid-ascii/ascii/xychart.ts +875 -0
  224. package/src/vendor/mermaid-ascii/class/parser.ts +290 -0
  225. package/src/vendor/mermaid-ascii/class/types.ts +121 -0
  226. package/src/vendor/mermaid-ascii/er/parser.ts +181 -0
  227. package/src/vendor/mermaid-ascii/er/types.ts +91 -0
  228. package/src/vendor/mermaid-ascii/index.ts +14 -0
  229. package/src/vendor/mermaid-ascii/multiline-utils.ts +30 -0
  230. package/src/vendor/mermaid-ascii/parser.ts +645 -0
  231. package/src/vendor/mermaid-ascii/sequence/parser.ts +207 -0
  232. package/src/vendor/mermaid-ascii/sequence/types.ts +146 -0
  233. package/src/vendor/mermaid-ascii/text-metrics.ts +71 -0
  234. package/src/vendor/mermaid-ascii/types.ts +164 -0
  235. package/src/vendor/mermaid-ascii/xychart/colors.ts +140 -0
  236. package/src/vendor/mermaid-ascii/xychart/parser.ts +115 -0
  237. package/src/vendor/mermaid-ascii/xychart/types.ts +150 -0
  238. package/src/version.ts +99 -0
  239. package/src/vterm/buffer.ts +218 -0
  240. package/src/vterm/terminal.ts +773 -0
  241. package/src/vterm.ts +8 -0
  242. package/src/which.ts +234 -0
  243. package/src/worker-host.ts +100 -0
  244. package/src/xml.ts +313 -0
@@ -0,0 +1,282 @@
1
+ /**
2
+ * Centralized path helpers for omp config directories.
3
+ *
4
+ * Uses PI_CONFIG_DIR (default ".omp") for the config root and
5
+ * PI_CODING_AGENT_DIR to override the agent directory.
6
+ *
7
+ * On Linux, if XDG_DATA_HOME / XDG_STATE_HOME / XDG_CACHE_HOME environment
8
+ * variables are set, paths are redirected to XDG-compliant locations under
9
+ * $XDG_*_HOME/omp/. This requires running `omp config migrate` first to
10
+ * move data to the new locations. No filesystem existence checks are performed
11
+ * — if the env var is set, omp trusts that the migration has been done.
12
+ */
13
+ /** App name (e.g. "zeta") */
14
+ export declare const APP_NAME: string;
15
+ /** Config directory name (e.g. ".zeta") */
16
+ export declare const CONFIG_DIR_NAME: string;
17
+ /** Ordered main settings filenames: canonical write target first, legacy-compatible YAML fallback second. */
18
+ export declare const MAIN_CONFIG_FILENAMES: readonly ["config.yml", "config.yaml"];
19
+ /** Version (e.g. "1.0.0") */
20
+ export declare const VERSION: string;
21
+ /** Minimum Bun version */
22
+ export declare const MIN_BUN_VERSION: string;
23
+ /**
24
+ * Normalize and validate a profile name. Returns `undefined` for the implicit
25
+ * default (empty string, whitespace, or the explicit "default" sentinel) and
26
+ * throws for syntactically invalid or platform-reserved names.
27
+ *
28
+ * Exported so consumers of `@linxiraos/pi-utils/dirs` (CLI bootstrap, tests,
29
+ * downstream tools) can validate user input without re-deriving the rules.
30
+ */
31
+ export declare function normalizeProfileName(profile: string | undefined): string | undefined;
32
+ /**
33
+ * Resolve the active profile from the two profile env vars. `OMP_PROFILE` is the
34
+ * canonical variable and takes precedence; `PI_PROFILE` is the legacy
35
+ * compatibility fallback, consulted only when `OMP_PROFILE` is undefined. An
36
+ * explicitly-empty `OMP_PROFILE` therefore selects the default profile rather
37
+ * than silently inheriting `PI_PROFILE`. Delegates validation/normalization to
38
+ * {@link normalizeProfileName} (which throws on a syntactically invalid value).
39
+ */
40
+ export declare function resolveProfileEnv(omp: string | undefined, pi: string | undefined): string | undefined;
41
+ export declare function resolveEquivalentPath(inputPath: string): string;
42
+ export declare function normalizePathForComparison(inputPath: string): string;
43
+ export declare function pathIsWithin(root: string, candidate: string): boolean;
44
+ export declare function relativePathWithinRoot(root: string, candidate: string): string | null;
45
+ /** Get the project directory. */
46
+ export declare function getProjectDir(): string;
47
+ /** Set the project directory. */
48
+ export declare function setProjectDir(dir: string): void;
49
+ /**
50
+ * Whether `dir` resolves to an existing directory. Any stat failure — a deleted
51
+ * path (ENOENT), permission error, or a non-directory — returns `false`, so
52
+ * callers can decide whether a directory is safe to `chdir` into or adopt as a
53
+ * working directory before {@link setProjectDir} throws on it.
54
+ */
55
+ export declare function directoryExists(dir: string): Promise<boolean>;
56
+ /** Get the config directory name relative to home (e.g. ".zeta" or PI_CONFIG_DIR override). Falls back to ".omp" for backward compatibility. */
57
+ export declare function getConfigDirName(): string;
58
+ /** Get the config agent directory name relative to home (e.g. ".omp/agent" or PI_CONFIG_DIR + "/agent"). */
59
+ export declare function getConfigAgentDirName(): string;
60
+ /**
61
+ * Rebuild the dirs resolver from the current environment, reusing the profile
62
+ * resolved at module load. Directory-affecting keys (XDG_*_HOME and, in default
63
+ * mode, `PI_CODING_AGENT_DIR`) loaded from a profile/agent `.env` only reach
64
+ * `process.env` *after* this module froze the resolver at import time, so
65
+ * `env.ts` calls this once after applying its `.env` files. The agent `.env`
66
+ * location derives from the profile name + home before this runs, so the
67
+ * rebuild re-reads only the directory vars, never the profile selection. The
68
+ * `preProfileAgentDirEnv` snapshot is intentionally left untouched.
69
+ */
70
+ export declare function refreshDirsFromEnv(): void;
71
+ /** Get the config root directory (~/.omp). */
72
+ export declare function getConfigRootDir(): string;
73
+ /** Set the coding agent directory. Creates a fresh resolver, invalidating all cached paths. */
74
+ export declare function setAgentDir(dir: string): void;
75
+ /**
76
+ * Test-only: reset the pre-profile `PI_CODING_AGENT_DIR` snapshot to whatever
77
+ * the current environment looks like. Cross-suite test pollution can otherwise
78
+ * leak a stale snapshot through `setAgentDir` and corrupt `setProfile(undefined)`
79
+ * restore semantics. Production code MUST NOT call this — the snapshot's
80
+ * lifecycle is owned by `setAgentDir` / `setProfile` and a runtime caller has
81
+ * no business clearing it.
82
+ */
83
+ export declare function __resetProfileSnapshotForTests(): void;
84
+ /**
85
+ * Test-only: rebuild profile + directory state from the current process env.
86
+ * Production code keeps the module-load profile stable; tests that mutate
87
+ * `setAgentDir`/`setProfile` need an exact restore point after they put env vars
88
+ * back.
89
+ */
90
+ export declare function __resetDirsFromEnvForTests(): void;
91
+ /** Activate a named profile. Passing undefined or "default" returns to the default profile. */
92
+ export declare function setProfile(profile: string | undefined): void;
93
+ /** Get the active named profile. Undefined means the default profile. */
94
+ export declare function getActiveProfile(): string | undefined;
95
+ /** Resolve the config root that backs a profile without activating it. */
96
+ export declare function getProfileRootDir(profile: string | undefined): string;
97
+ /** Get the agent config directory (~/.omp/agent). */
98
+ export declare function getAgentDir(): string;
99
+ /** Get the project-local config directory (.zeta). Falls back to .omp for backward compatibility. */
100
+ export declare function getProjectAgentDir(cwd?: string): string;
101
+ /** Get the reports directory (~/.omp/reports). */
102
+ export declare function getReportsDir(): string;
103
+ /** Get the logs directory (~/.omp/logs). */
104
+ export declare function getLogsDir(): string;
105
+ /** Get this process's dated log path (~/.omp/logs/omp.YYYY-MM-DD.PID.log). */
106
+ export declare function getLogPath(date?: Date, pid?: number): string;
107
+ /**
108
+ * Get the plugins directory (~/.omp/plugins or its XDG equivalent).
109
+ *
110
+ * No-arg form (production callers) goes through the XDG-aware DirResolver so
111
+ * reads and writes always agree. The optional `home` parameter is for test
112
+ * isolation: when it differs from `os.homedir()` it short-circuits the resolver
113
+ * and returns `<home>/<configDir>/plugins` so tests with a temp HOME get a
114
+ * deterministic path. Passing `os.homedir()` explicitly is identical to the
115
+ * no-arg form — XDG semantics are preserved.
116
+ */
117
+ export declare function getPluginsDir(home?: string): string;
118
+ /** Where npm installs packages (~/.omp/plugins/node_modules). */
119
+ export declare function getPluginsNodeModules(home?: string): string;
120
+ /** Plugin manifest (~/.omp/plugins/package.json). */
121
+ export declare function getPluginsPackageJson(home?: string): string;
122
+ /** Plugin lock file (~/.omp/plugins/omp-plugins.lock.json). */
123
+ export declare function getPluginsLockfile(home?: string): string;
124
+ /** Get the remote mount directory (~/.omp/remote). */
125
+ export declare function getRemoteDir(): string;
126
+ /**
127
+ * Relocate the base directory for agent-managed worktrees (PR checkouts, task
128
+ * isolation, and `omp worktree` cleanup all read the same base). Driven by the
129
+ * `worktree.base` setting in coding-agent; pass `undefined`/empty to clear and
130
+ * fall back to `OMP_WORKTREE_DIR` or the `~/.omp/wt` default.
131
+ *
132
+ * `~` is expanded and a relative path is rejected (see {@link resolveWorktreeBase}).
133
+ * Returns the absolute path that took effect, or `undefined` if the input was
134
+ * cleared or rejected — callers can warn on a non-empty input that returns
135
+ * `undefined`.
136
+ */
137
+ export declare function setWorktreesDir(dir: string | undefined): string | undefined;
138
+ /**
139
+ * Get the agent-managed worktrees directory. Resolution order: the
140
+ * `OMP_WORKTREE_DIR` env var, then the {@link setWorktreesDir} override (the
141
+ * `worktree.base` setting), then the `~/.omp/wt` default. The env var and the
142
+ * override are both `~`-expanded and must be absolute; a relative value is
143
+ * ignored and resolution falls through.
144
+ */
145
+ export declare function getWorktreesDir(): string;
146
+ /** Get the SSH control socket directory (~/.omp/ssh-control). */
147
+ export declare function getSshControlDir(): string;
148
+ /** Get the remote host info directory (~/.omp/remote-host). */
149
+ export declare function getRemoteHostDir(): string;
150
+ /** Get the managed Python venv directory (~/.omp/python-env). */
151
+ export declare function getPythonEnvDir(): string;
152
+ /** Get the shared Python gateway state directory (~/.omp/agent/python-gateway; XDG default: $XDG_STATE_HOME/omp/python-gateway). */
153
+ export declare function getPythonGatewayDir(): string;
154
+ /** Get the puppeteer sandbox directory (~/.omp/puppeteer). */
155
+ export declare function getPuppeteerDir(): string;
156
+ /** Get the browser relay extension install directory (~/.omp/browser-relay). */
157
+ export declare function getBrowserRelayDir(): string;
158
+ /** Get DOCS_RS cache directory () */
159
+ export declare function getDocsRsCacheDir(): string;
160
+ /** Get the auto-QA grievances SQLite database path (~/.omp/autoqa.db; XDG: $XDG_DATA_HOME/omp/autoqa.db). */
161
+ export declare function getAutoQaDbPath(): string;
162
+ /**
163
+ * Stable 7-character hex digest of an absolute filesystem path.
164
+ *
165
+ * Used to pack the project identity into a single short fs-safe segment
166
+ * (e.g. PR-checkout and task-isolation worktree dirs under `~/.omp/wt/`).
167
+ * Bun.hash is non-cryptographic — collision space is ~2^28, which is fine
168
+ * for naming a handful of repos on a single machine. Same input on the
169
+ * same Bun runtime yields the same output.
170
+ */
171
+ export declare function hashPath(absPath: string): string;
172
+ /** Get the path to a single worktree directory (~/.omp/wt/<segment>). */
173
+ export declare function getWorktreeDir(segment: string): string;
174
+ /** Get the GPU cache path (~/.omp/gpu_cache.json). */
175
+ export declare function getGpuCachePath(): string;
176
+ /**
177
+ * Get the GitHub view cache database path (~/.omp/cache/github-cache.db).
178
+ * Honors the `OMP_GITHUB_CACHE_DB` env var when set so tests can isolate the
179
+ * cache file without touching the rest of the config root.
180
+ */
181
+ export declare function getGithubCacheDbPath(): string;
182
+ /**
183
+ * Get the encrypted auth-broker snapshot cache path (~/.omp/cache/auth-broker-snapshot.enc).
184
+ * Honors the `OMP_AUTH_BROKER_SNAPSHOT_CACHE` env var when set so tests and
185
+ * operators can isolate or relocate the cache file.
186
+ */
187
+ export declare function getAuthBrokerSnapshotCachePath(): string;
188
+ /** Get the local FastEmbed model cache directory (~/.omp/cache/fastembed). */
189
+ export declare function getFastembedCacheDir(): string;
190
+ /** Get the on-demand fastembed runtime install root (~/.omp/cache/fastembed-runtime). */
191
+ export declare function getFastembedRuntimeDir(): string;
192
+ /** Get the natives directory (~/.omp/natives). */
193
+ export declare function getNativesDir(): string;
194
+ /** Get the stats database path (~/.omp/stats.db). */
195
+ export declare function getStatsDbPath(): string;
196
+ /** Get the autoresearch state directory (~/.omp/autoresearch). */
197
+ export declare function getAutoresearchDir(): string;
198
+ /** Get the per-project autoresearch state directory (~/.omp/autoresearch/<encoded-project>). */
199
+ export declare function getAutoresearchProjectDir(encodedProject: string): string;
200
+ /** Get the per-project autoresearch SQLite database path (~/.omp/autoresearch/<encoded-project>.db). */
201
+ export declare function getAutoresearchDbPath(encodedProject: string): string;
202
+ /** Get the per-run artifact directory (~/.omp/autoresearch/<encoded-project>/runs/<runId>). */
203
+ export declare function getAutoresearchRunDir(encodedProject: string, runId: number): string;
204
+ /** Get the security-analysis state directory (~/.omp/security). */
205
+ export declare function getSecurityDir(): string;
206
+ /** Get one project's security-analysis state directory (~/.omp/security/<project-key>). */
207
+ export declare function getSecurityProjectDir(projectKey: string): string;
208
+ /** Get the path to agent.db (SQLite database for settings and auth storage). */
209
+ export declare function getAgentDbPath(agentDir?: string): string;
210
+ /** Get the last-seen-changelog-version marker file (~/.omp/agent/last-changelog-version). */
211
+ export declare function getLastChangelogVersionPath(agentDir?: string): string;
212
+ /** Get the path to history.db (SQLite database for session history). */
213
+ export declare function getHistoryDbPath(agentDir?: string): string;
214
+ /** Get the path to models.db (model cache database). */
215
+ export declare function getModelDbPath(agentDir?: string): string;
216
+ /** Get the tiny title model cache directory (~/.omp/agent/cache/tiny-models). */
217
+ export declare function getTinyModelsCacheDir(agentDir?: string): string;
218
+ /** Get the document conversion cache directory (~/.omp/agent/cache/document-conversions; XDG default: $XDG_CACHE_HOME/omp/cache/document-conversions). */
219
+ export declare function getDocumentConversionCacheDir(agentDir?: string): string;
220
+ /** Get the sessions directory (~/.omp/agent/sessions). */
221
+ export declare function getSessionsDir(agentDir?: string): string;
222
+ /** Get the content-addressed blob store directory (~/.omp/agent/blobs). */
223
+ export declare function getBlobsDir(agentDir?: string): string;
224
+ /** Get the custom themes directory (~/.omp/agent/themes). */
225
+ export declare function getCustomThemesDir(agentDir?: string): string;
226
+ /** Get the tools directory (~/.omp/agent/tools). */
227
+ export declare function getToolsDir(agentDir?: string): string;
228
+ /** Get the slash commands directory (~/.omp/agent/commands). */
229
+ export declare function getCommandsDir(agentDir?: string): string;
230
+ /** Get the prompts directory (~/.omp/agent/prompts). */
231
+ export declare function getPromptsDir(agentDir?: string): string;
232
+ /** Get the user-level Python modules directory (~/.omp/agent/modules). */
233
+ export declare function getAgentModulesDir(agentDir?: string): string;
234
+ /** Get the memories directory (~/.omp/agent/memories). */
235
+ export declare function getMemoriesDir(agentDir?: string): string;
236
+ /** Get the terminal sessions directory (~/.omp/agent/terminal-sessions). */
237
+ export declare function getTerminalSessionsDir(agentDir?: string): string;
238
+ /** Get the crash log path (~/.omp/agent/omp-crash.log). */
239
+ export declare function getCrashLogPath(agentDir?: string): string;
240
+ /** Get the debug log path (~/.omp/agent/omp-debug.log). */
241
+ export declare function getDebugLogPath(agentDir?: string): string;
242
+ /** Get the secret placeholder key path (~/.omp/agent/secret-placeholder.key; XDG default: $XDG_STATE_HOME/omp/secret-placeholder.key). Adopts a legacy key on first XDG resolution. */
243
+ export declare function getSecretPlaceholderKeyPath(): string;
244
+ /** Get the daemon runtime directory for a project (~/.omp/run/daemons/<hash>; XDG default: $XDG_STATE_HOME/omp/run/daemons/<hash>). */
245
+ export declare function getDaemonRuntimeDir(projectDir: string): string;
246
+ /** Get a profile-independent runtime directory for a machine-global daemon service. */
247
+ export declare function getGlobalDaemonRuntimeDir(service: string): string;
248
+ /** Get the provider in-flight root directory (~/.omp/run/provider-inflight; XDG default: $XDG_STATE_HOME/omp/run/provider-inflight). */
249
+ export declare function getProviderInFlightRoot(): string;
250
+ /** Get the marketplaces registry path (~/.omp/marketplaces.json; XDG default: $XDG_DATA_HOME/omp/marketplaces.json). Adopts a legacy registry on first XDG resolution. */
251
+ export declare function getMarketplacesRegistryPath(): string;
252
+ /** Get the project-level Python modules directory (.omp/modules). */
253
+ export declare function getProjectModulesDir(cwd?: string): string;
254
+ /** Get the project-level prompts directory (.omp/prompts). */
255
+ export declare function getProjectPromptsDir(cwd?: string): string;
256
+ /** Get the project-level plugin overrides path (.omp/plugin-overrides.json). */
257
+ export declare function getProjectPluginOverridesPath(cwd?: string): string;
258
+ /** Get the primary MCP config file path (first candidate). */
259
+ export declare function getMCPConfigPath(scope: "user" | "project", cwd?: string): string;
260
+ /** Get the SSH config file path. */
261
+ export declare function getSSHConfigPath(scope: "user" | "project", cwd?: string): string;
262
+ /** Get the project-level tracking directory (<project>/.zeta/tracking). */
263
+ export declare function getProjectTrackingDir(cwd?: string): string;
264
+ /** Get the global tracking index path (~/.zeta/agent/tracking-index.json). */
265
+ export declare function getTrackingIndexPath(agentDir?: string): string;
266
+ /**
267
+ * Persistent per-install UUID stored at `~/.omp/install-id`.
268
+ *
269
+ * Generated lazily on first call and persisted with `O_CREAT|O_EXCL` so
270
+ * concurrent first-call races don't clobber each other (loser re-reads the
271
+ * winner's id). Survives independently of agent state: deleting
272
+ * `~/.omp/agent/` does not regenerate it. Server-side dedup for grievance
273
+ * pushes (and similar telemetry) keys on this id.
274
+ *
275
+ * Anchored to the base config root (`~/.omp/install-id`) regardless of the
276
+ * active profile: install identity is per-install, not per-profile, so every
277
+ * profile shares one id and the global cache stays correct no matter the
278
+ * profile / `getInstallId` call order.
279
+ */
280
+ export declare function getInstallId(): string;
281
+ /** Test-only: clear cached install id. Never call from production code. */
282
+ export declare function __resetInstallIdCacheForTests(): void;
@@ -0,0 +1,46 @@
1
+ /** A mammoth-compatible diagnostic emitted while converting a document. */
2
+ export interface DocxMessage {
3
+ readonly type: "warning" | "error";
4
+ readonly message: string;
5
+ }
6
+ /** The HTML and diagnostics produced by a DOCX conversion. */
7
+ export interface DocxResult {
8
+ readonly value: string;
9
+ readonly messages: DocxMessage[];
10
+ }
11
+ /** An in-memory or filesystem DOCX input. */
12
+ export type DocxInput = {
13
+ readonly buffer: Uint8Array;
14
+ readonly path?: never;
15
+ } | {
16
+ readonly path: string;
17
+ readonly buffer?: never;
18
+ };
19
+ /** An image exposed to a custom image converter. */
20
+ export interface DocxImage {
21
+ readonly contentType: string;
22
+ readonly altText: string;
23
+ /** Read the image payload using mammoth's used encoding surface. */
24
+ read(encoding: "base64"): Promise<string>;
25
+ }
26
+ /** HTML attributes returned by a custom image converter. */
27
+ export type ImageAttributes = Readonly<Record<string, string>>;
28
+ /** A callback that maps an embedded DOCX image to HTML attributes. */
29
+ export type ImageAttributeConverter = (image: DocxImage) => ImageAttributes | Promise<ImageAttributes>;
30
+ /** An image converter created by `images.imgElement`. */
31
+ export interface ImageConverter {
32
+ readonly convert: ImageAttributeConverter;
33
+ }
34
+ /** Options supported by the behavior-compatible DOCX converter. */
35
+ export interface ConvertToHtmlOptions {
36
+ readonly convertImage?: ImageConverter;
37
+ readonly styleMap?: string | readonly string[];
38
+ readonly includeDefaultStyleMap?: boolean;
39
+ }
40
+ /** Mammoth-shaped helpers for configuring embedded image conversion. */
41
+ export declare const images: {
42
+ /** Wrap an image-to-attributes callback for `convertToHtml`. */
43
+ imgElement(convert: ImageAttributeConverter): ImageConverter;
44
+ };
45
+ /** Convert a DOCX buffer or path to mammoth-compatible HTML. */
46
+ export declare function convertToHtml(input: DocxInput, options?: ConvertToHtmlOptions): Promise<DocxResult>;
@@ -0,0 +1,26 @@
1
+ interface XmlText {
2
+ readonly kind: "text";
3
+ readonly value: string;
4
+ }
5
+ /** A minimal XML element used by the DOCX reader. */
6
+ export interface XmlElement {
7
+ readonly kind: "element";
8
+ readonly name: string;
9
+ readonly attributes: ReadonlyMap<string, string>;
10
+ readonly children: readonly XmlNode[];
11
+ }
12
+ /** A node in the DOCX reader's minimal XML tree. */
13
+ export type XmlNode = XmlElement | XmlText;
14
+ /** Return the namespace-independent part of an XML qualified name. */
15
+ export declare function localName(name: string): string;
16
+ /** Parse XML into a small namespace-tolerant element tree. */
17
+ export declare function parseXml(source: string): XmlElement;
18
+ /** Return direct element children, optionally filtered by local name. */
19
+ export declare function childElements(element: XmlElement, name?: string): XmlElement[];
20
+ /** Return the first direct child with the given local name. */
21
+ export declare function firstChild(element: XmlElement | undefined, name: string): XmlElement | undefined;
22
+ /** Return an attribute by qualified or namespace-independent name. */
23
+ export declare function attribute(element: XmlElement | undefined, name: string): string | undefined;
24
+ /** Return all descendant elements with a given local name. */
25
+ export declare function descendants(element: XmlElement, name: string): XmlElement[];
26
+ export {};
@@ -0,0 +1,6 @@
1
+ /** The decompressed members of a DOCX ZIP package. */
2
+ export type ZipEntries = ReadonlyMap<string, Uint8Array>;
3
+ /** Decode a ZIP package by walking its central directory. */
4
+ export declare function readZip(bytes: Uint8Array): ZipEntries;
5
+ /** Decode a ZIP member as UTF-8 text. */
6
+ export declare function readZipText(entries: ZipEntries, name: string): string | undefined;
@@ -0,0 +1,11 @@
1
+ /** Behavior-compatible reimplementation of mammoth's used surface. */
2
+ export { type ConvertToHtmlOptions, convertToHtml, type DocxImage, type DocxInput, type DocxMessage, type DocxResult, type ImageAttributeConverter, type ImageAttributes, type ImageConverter, images, } from "./docx/converter.js";
3
+ import { convertToHtml } from "./docx/converter.js";
4
+ /** Mammoth-shaped default export for drop-in consumer imports. */
5
+ declare const docx: {
6
+ convertToHtml: typeof convertToHtml;
7
+ images: {
8
+ imgElement(convert: import("./docx.js").ImageAttributeConverter): import("./docx.js").ImageConverter;
9
+ };
10
+ };
11
+ export default docx;