@orbit-build/cli 0.5.3 → 0.5.5

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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Hephaestus-DevKit contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@orbit-build/cli?label=npm&color=426b63)](https://www.npmjs.com/package/@orbit-build/cli)
8
8
  [![Node.js](https://img.shields.io/badge/Node.js-%E2%89%A520-43853d)](https://nodejs.org/)
9
+ [![License](https://img.shields.io/badge/license-Apache--2.0-3b82f6)](LICENSE)
9
10
 
10
11
  </div>
11
12
 
@@ -17,6 +18,8 @@ permissions, checkpoints, and cancellation state.
17
18
  ## Install
18
19
 
19
20
  Requires Node.js 20 or newer on Windows, macOS, or Linux.
21
+ Git is recommended for richer rollback and isolated agent work, but Orbit keeps
22
+ a filesystem-checkpoint fallback when Git is unavailable.
20
23
 
21
24
  ```bash
22
25
  npm install --global @orbit-build/cli
@@ -74,6 +77,20 @@ Accepted prompts are persisted before provider work begins. After an unexpected
74
77
  shutdown, Orbit repairs the conversation conservatively and never silently
75
78
  replays an unfinished side-effecting tool.
76
79
 
80
+ ## Security and data boundaries
81
+
82
+ Orbit stores chats, checkpoints, indexes, and project state locally. Requests
83
+ to an external model provider include the prompt and selected context required
84
+ for that request; web, MCP, and extension tools may contact their configured
85
+ services. The local Web UI binds to loopback and uses a per-run capability
86
+ token. Credentials are redacted from configuration, diagnostics, events,
87
+ sessions, and exported traces.
88
+
89
+ Review provider privacy terms before sending sensitive code, and treat the Web
90
+ UI URL as a secret. See the repository [security
91
+ policy](https://github.com/Hephaestus-DevKit/Orbit/blob/main/SECURITY.md) for
92
+ supported versions and private vulnerability reporting.
93
+
77
94
  ## Providers
78
95
 
79
96
  `orbit login` manages DeepSeek, TokenDance, OpenAI, Anthropic,
@@ -111,5 +128,8 @@ and prior exports.
111
128
  Use `orbit --help` or `orbit <command> --help` for the exact options installed
112
129
  on your machine.
113
130
 
114
- License terms have not yet been finalized. Repository visibility alone does not
115
- grant permission to use, modify, or redistribute the source.
131
+ ## License
132
+
133
+ Orbit is available under the [Apache License 2.0](LICENSE). Third-party
134
+ components retain their own terms; see the [third-party
135
+ notices](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,70 @@
1
+ # Third-party notices
2
+
3
+ This file records the production dependency licenses included in Orbit's
4
+ published runtime bundle. It is generated from the lockfile with
5
+ `pnpm notices` and does not determine Orbit's own license.
6
+
7
+ ## Apache-2.0
8
+
9
+ - `human-signals` 5.0.0 — https://www.github.com/ehmicky/human-signals
10
+ - `typescript` 6.0.3 — https://www.typescriptlang.org/
11
+
12
+ ## BSD-3-Clause
13
+
14
+ - `fast-uri` 3.1.5 — https://github.com/fastify/fast-uri
15
+
16
+ ## ISC
17
+
18
+ - `fastq` 1.20.1 — https://github.com/mcollina/fastq#readme
19
+ - `glob-parent` 5.1.2 — https://github.com/gulpjs/glob-parent#readme
20
+ - `isexe` 2.0.0 — https://github.com/isaacs/isexe#readme
21
+ - `picocolors` 1.1.1 — https://github.com/alexeyraspopov/picocolors#readme
22
+ - `signal-exit` 4.1.0 — https://github.com/tapjs/signal-exit#readme
23
+ - `which` 2.0.2 — https://github.com/isaacs/node-which#readme
24
+ - `yaml` 2.9.0 — https://eemeli.org/yaml/
25
+ - `zod-to-json-schema` 3.25.2 — https://github.com/StefanTerdell/zod-to-json-schema#readme
26
+
27
+ ## MIT
28
+
29
+ - `@clack/core` 1.4.3 — https://github.com/bombshell-dev/clack/tree/main/packages/core#readme
30
+ - `@clack/prompts` 1.7.0 — https://github.com/bombshell-dev/clack/tree/main/packages/prompts#readme
31
+ - `@nodelib/fs.scandir` 2.1.5 — https://github.com/nodelib/nodelib/tree/master#readme
32
+ - `@nodelib/fs.stat` 2.0.5 — https://github.com/nodelib/nodelib/tree/master#readme
33
+ - `@nodelib/fs.walk` 1.2.8 — https://github.com/nodelib/nodelib/tree/master#readme
34
+ - `ajv` 8.20.0 — https://ajv.js.org
35
+ - `braces` 3.0.3 — https://github.com/micromatch/braces
36
+ - `commander` 15.0.0 — https://github.com/tj/commander.js#readme
37
+ - `cross-spawn` 7.0.6 — https://github.com/moxystudio/node-cross-spawn
38
+ - `execa` 8.0.1 — https://github.com/sindresorhus/execa#readme
39
+ - `fast-deep-equal` 3.1.3 — https://github.com/epoberezkin/fast-deep-equal#readme
40
+ - `fast-glob` 3.3.3 — https://github.com/mrmlnc/fast-glob#readme
41
+ - `fast-string-truncated-width` 3.0.3 — https://github.com/fabiospampinato/fast-string-truncated-width#readme
42
+ - `fast-string-width` 3.0.2 — https://github.com/fabiospampinato/fast-string-width#readme
43
+ - `fast-wrap-ansi` 0.2.2 — https://github.com/43081j/fast-wrap-ansi#readme
44
+ - `fill-range` 7.1.1 — https://github.com/jonschlinkert/fill-range
45
+ - `get-stream` 8.0.1 — https://github.com/sindresorhus/get-stream#readme
46
+ - `ipaddr.js` 2.4.0 — https://github.com/whitequark/ipaddr.js#readme
47
+ - `is-extglob` 2.1.1 — https://github.com/jonschlinkert/is-extglob
48
+ - `is-glob` 4.0.3 — https://github.com/micromatch/is-glob
49
+ - `is-number` 7.0.0 — https://github.com/jonschlinkert/is-number
50
+ - `is-stream` 3.0.0 — https://github.com/sindresorhus/is-stream#readme
51
+ - `json-schema-traverse` 1.0.0 — https://github.com/epoberezkin/json-schema-traverse#readme
52
+ - `merge-stream` 2.0.0 — https://github.com/grncdr/merge-stream#readme
53
+ - `merge2` 1.4.1 — https://github.com/teambition/merge2
54
+ - `micromatch` 4.0.8 — https://github.com/micromatch/micromatch
55
+ - `mimic-fn` 4.0.0 — https://github.com/sindresorhus/mimic-fn#readme
56
+ - `npm-run-path` 5.3.0 — https://github.com/sindresorhus/npm-run-path#readme
57
+ - `onetime` 6.0.0 — https://github.com/sindresorhus/onetime#readme
58
+ - `path-key` 3.1.1, 4.0.0 — https://github.com/sindresorhus/path-key#readme
59
+ - `picomatch` 2.3.2 — https://github.com/micromatch/picomatch
60
+ - `queue-microtask` 1.2.3 — https://github.com/feross/queue-microtask
61
+ - `require-from-string` 2.0.2 — https://github.com/floatdrop/require-from-string#readme
62
+ - `reusify` 1.1.0 — https://github.com/mcollina/reusify#readme
63
+ - `run-parallel` 1.2.0 — https://github.com/feross/run-parallel
64
+ - `shebang-command` 2.0.0 — https://github.com/kevva/shebang-command#readme
65
+ - `shebang-regex` 3.0.0 — https://github.com/sindresorhus/shebang-regex#readme
66
+ - `sisteransi` 1.0.5 — https://github.com/terkelg/sisteransi#readme
67
+ - `strip-final-newline` 3.0.0 — https://github.com/sindresorhus/strip-final-newline#readme
68
+ - `to-regex-range` 5.0.1 — https://github.com/micromatch/to-regex-range
69
+ - `undici` 6.28.0 — https://undici.nodejs.org
70
+ - `zod` 3.25.76 — https://zod.dev
package/dist/index.js CHANGED
@@ -238396,6 +238396,20 @@ function redactSecrets(text2) {
238396
238396
  }
238397
238397
  return redacted;
238398
238398
  }
238399
+ var ANSI_ESCAPE_PATTERN = /\u001b\[[0-?]*[ -/]*[@-~]/g;
238400
+ var CONTROL_CHARACTER_PATTERN = /[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f]+/g;
238401
+ function sanitizeExternalErrorMessage(value, options = {}) {
238402
+ const maxLength = options.maxLength ?? 2e3;
238403
+ if (!Number.isSafeInteger(maxLength) || maxLength < 1) {
238404
+ throw new RangeError(
238405
+ "External error maxLength must be a positive integer."
238406
+ );
238407
+ }
238408
+ const source = value instanceof Error ? value.message : String(value);
238409
+ const withoutTerminalControls = source.replace(ANSI_ESCAPE_PATTERN, "").replace(CONTROL_CHARACTER_PATTERN, " ");
238410
+ const normalized = options.singleLine ? withoutTerminalControls.replace(/[\r\n]+/g, " ") : withoutTerminalControls;
238411
+ return redactSecrets(normalized).trim().slice(0, maxLength);
238412
+ }
238399
238413
  var LogTruncator = class {
238400
238414
  static truncate(output, maxLines = 150, maxChars = 2e4) {
238401
238415
  if (!output) return "";
@@ -254378,8 +254392,7 @@ function assertSupportedProtocolVersion(initializeResult) {
254378
254392
  }
254379
254393
  }
254380
254394
  function safeMessage(error) {
254381
- const message2 = error instanceof Error ? error.message : String(error);
254382
- return redactSecrets(message2).replace(/[\r\n]+/g, " ").slice(0, 2e3);
254395
+ return sanitizeExternalErrorMessage(error, { singleLine: true });
254383
254396
  }
254384
254397
  var DynamicMCPTool = class {
254385
254398
  constructor(serverName, toolDefinition, risk, client) {
@@ -255195,7 +255208,7 @@ function parseSseJson(body, expectedId) {
255195
255208
  throw new Error("MCP SSE response contained no matching JSON-RPC response.");
255196
255209
  }
255197
255210
  function safeMessage2(value) {
255198
- return redactSecrets(value instanceof Error ? value.message : String(value)).replace(/[\r\n]+/g, " ").slice(0, 2e3);
255211
+ return sanitizeExternalErrorMessage(value, { singleLine: true });
255199
255212
  }
255200
255213
  function assertSecureMcpUrl(value, label) {
255201
255214
  const url = new URL(value);
@@ -255300,7 +255313,7 @@ async function runMcpPkceLogin(options) {
255300
255313
  finish(400, "Authorization failed. Close this window and retry.");
255301
255314
  fail(
255302
255315
  new Error(
255303
- `MCP OAuth authorization failed: ${oauthError.slice(0, 200)}`
255316
+ `MCP OAuth authorization failed: ${sanitizeExternalErrorMessage(oauthError, { maxLength: 200, singleLine: true })}`
255304
255317
  )
255305
255318
  );
255306
255319
  return;
@@ -264780,30 +264793,59 @@ ${diff.substring(0, 2e4)}`
264780
264793
  return true;
264781
264794
  }
264782
264795
  rollbackFileToCheckpoint(filePath) {
264796
+ const result = this.rollbackFilesToCheckpoints([filePath]);
264797
+ return result.success && result.restored.length === 1;
264798
+ }
264799
+ /** Restore the latest available backup for each path as one transaction. */
264800
+ rollbackFilesToCheckpoints(filePaths) {
264783
264801
  this.sessionReviewCache = void 0;
264784
- let targetAbs;
264785
- try {
264786
- targetAbs = resolveSafePath(this.cwd, filePath);
264787
- } catch {
264788
- return false;
264789
- }
264790
264802
  const checkpoints = this.checkpointManager.getCheckpoints().reverse();
264791
- for (const cp of checkpoints) {
264792
- const backup = cp.backups.find((candidate) => {
264793
- try {
264794
- return resolveSafePath(this.cwd, candidate.path) === targetAbs;
264795
- } catch {
264796
- return false;
264803
+ const selected = [];
264804
+ const unresolved = [];
264805
+ for (const requestedPath of [...new Set(filePaths)]) {
264806
+ let targetAbs;
264807
+ try {
264808
+ targetAbs = resolveSafePath(this.cwd, requestedPath);
264809
+ } catch {
264810
+ unresolved.push(requestedPath);
264811
+ continue;
264812
+ }
264813
+ let match;
264814
+ for (const checkpoint of checkpoints) {
264815
+ const backup = checkpoint.backups.find((candidate) => {
264816
+ try {
264817
+ return resolveSafePath(this.cwd, candidate.path) === targetAbs;
264818
+ } catch {
264819
+ return false;
264820
+ }
264821
+ });
264822
+ if (backup) {
264823
+ match = { requestedPath, checkpoint, backup };
264824
+ break;
264797
264825
  }
264798
- });
264799
- if (backup) {
264800
- return this.rollbackManager.rollback({
264801
- ...cp,
264802
- backups: [backup]
264803
- }).success;
264804
264826
  }
264827
+ if (match) selected.push(match);
264828
+ else unresolved.push(requestedPath);
264805
264829
  }
264806
- return false;
264830
+ const result = this.rollbackManager.rollbackMany(
264831
+ selected.map(({ checkpoint, backup }) => ({
264832
+ ...checkpoint,
264833
+ backups: [backup]
264834
+ }))
264835
+ );
264836
+ if (!result.success) {
264837
+ return {
264838
+ success: false,
264839
+ restored: [],
264840
+ unresolved,
264841
+ error: result.error
264842
+ };
264843
+ }
264844
+ return {
264845
+ success: true,
264846
+ restored: selected.map(({ requestedPath }) => requestedPath),
264847
+ unresolved
264848
+ };
264807
264849
  }
264808
264850
  accumulateCost(model, usage2) {
264809
264851
  const pricing = this.resolvePricing(model);
@@ -274196,7 +274238,7 @@ var FullscreenTui = class {
274196
274238
  // src/runtime/ReplController.ts
274197
274239
  import picocolors19 from "picocolors";
274198
274240
  import { rmSync as rmSync6, watch } from "fs";
274199
- import { dirname as dirname12, resolve as resolve14 } from "path";
274241
+ import { dirname as dirname13, resolve as resolve14 } from "path";
274200
274242
  import { homedir as homedir10 } from "os";
274201
274243
  import http3 from "http";
274202
274244
  import { randomBytes as randomBytes4, randomUUID as randomUUID11, timingSafeEqual as timingSafeEqual2 } from "crypto";
@@ -280359,6 +280401,20 @@ import { relative as relative5 } from "path";
280359
280401
  // src/runtime/webui/WebUiSecurity.ts
280360
280402
  import { timingSafeEqual } from "crypto";
280361
280403
  import { z as z51 } from "zod";
280404
+
280405
+ // src/runtime/webui/WebUiErrors.ts
280406
+ var WebUiRequestError = class extends Error {
280407
+ constructor(code, statusCode, message2) {
280408
+ super(message2);
280409
+ this.code = code;
280410
+ this.statusCode = statusCode;
280411
+ }
280412
+ code;
280413
+ statusCode;
280414
+ name = "WebUiRequestError";
280415
+ };
280416
+
280417
+ // src/runtime/webui/WebUiSecurity.ts
280362
280418
  function sanitizeWebEventPayload(type, payload) {
280363
280419
  if (!isRecord4(payload)) return void 0;
280364
280420
  switch (type) {
@@ -280586,10 +280642,7 @@ function isAuthorizedWebEventRequest(req, expectedToken, url) {
280586
280642
  );
280587
280643
  }
280588
280644
  function safeWebMessage(error) {
280589
- return safeWebText(
280590
- error instanceof Error ? error.message : String(error),
280591
- 2e3
280592
- );
280645
+ return sanitizeExternalErrorMessage(error, { maxLength: 2e3 });
280593
280646
  }
280594
280647
  function summarizeWebToolValue(value, options = {}) {
280595
280648
  let candidate = value;
@@ -280668,9 +280721,7 @@ function sanitizeBaseUrl(value) {
280668
280721
  }
280669
280722
  function webRequestErrorStatus(error) {
280670
280723
  if (error instanceof z51.ZodError) return 400;
280671
- if (error instanceof Error && error.message === "Request body too large.") {
280672
- return 413;
280673
- }
280724
+ if (error instanceof WebUiRequestError) return error.statusCode;
280674
280725
  return 500;
280675
280726
  }
280676
280727
  function isNodeError3(error) {
@@ -281517,12 +281568,25 @@ async function readJsonBody(req) {
281517
281568
  const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
281518
281569
  totalBytes += buffer.length;
281519
281570
  if (totalBytes > WEB_UI_BODY_LIMIT_BYTES) {
281520
- throw new Error("Request body too large.");
281571
+ throw new WebUiRequestError(
281572
+ "request_body_too_large",
281573
+ 413,
281574
+ "Request body too large."
281575
+ );
281521
281576
  }
281522
281577
  chunks.push(buffer);
281523
281578
  }
281524
281579
  const body = Buffer.concat(chunks).toString("utf8").trim();
281525
- return body ? JSON.parse(body) : {};
281580
+ if (!body) return {};
281581
+ try {
281582
+ return JSON.parse(body);
281583
+ } catch {
281584
+ throw new WebUiRequestError(
281585
+ "invalid_json",
281586
+ 400,
281587
+ "Invalid JSON request body."
281588
+ );
281589
+ }
281526
281590
  }
281527
281591
  async function readBinaryBody(req, limitBytes) {
281528
281592
  const chunks = [];
@@ -281530,7 +281594,13 @@ async function readBinaryBody(req, limitBytes) {
281530
281594
  for await (const chunk of req) {
281531
281595
  const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
281532
281596
  totalBytes += buffer.length;
281533
- if (totalBytes > limitBytes) throw new Error("Attachment is too large.");
281597
+ if (totalBytes > limitBytes) {
281598
+ throw new WebUiRequestError(
281599
+ "attachment_too_large",
281600
+ 413,
281601
+ "Attachment is too large."
281602
+ );
281603
+ }
281534
281604
  chunks.push(buffer);
281535
281605
  }
281536
281606
  return Buffer.concat(chunks);
@@ -291054,29 +291124,103 @@ async function handleContextCommand(command, argument, dependencies) {
291054
291124
 
291055
291125
  // src/runtime/commands/RollbackCommandHandler.ts
291056
291126
  import { execFileSync as execFileSync7 } from "child_process";
291057
- import { existsSync as existsSync19, rmSync as rmSync5 } from "fs";
291127
+ import { existsSync as existsSync19, lstatSync as lstatSync7, mkdirSync as mkdirSync6, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "fs";
291128
+ import { dirname as dirname11 } from "path";
291058
291129
  import picocolors13 from "picocolors";
291059
291130
  import { z as z56 } from "zod";
291060
291131
  var GitStatusCodeSchema = z56.string().length(2).regex(/^[ MADRCU?!]{2}$/);
291061
291132
  var GitStatusPathSchema = z56.string().min(1).max(32768);
291133
+ var ROLLBACK_SNAPSHOT_FILE_MAX_BYTES = 16 * 1024 * 1024;
291134
+ var ROLLBACK_SNAPSHOT_TOTAL_MAX_BYTES = 128 * 1024 * 1024;
291135
+ var ROLLBACK_SNAPSHOT_MAX_PATHS = 1e4;
291136
+ var GIT_INDEX_PATCH_MAX_BYTES = 64 * 1024 * 1024;
291062
291137
  var defaultGitAdapter = {
291063
- status: (cwd) => execFileSync7("git", ["status", "--porcelain=v1", "-z"], {
291064
- ...HIDDEN_CHILD_PROCESS_OPTIONS,
291065
- cwd,
291066
- encoding: "utf8",
291067
- stdio: ["ignore", "pipe", "ignore"]
291068
- }),
291138
+ status: (cwd) => execFileSync7(
291139
+ "git",
291140
+ ["status", "--porcelain=v1", "-z", "--untracked-files=all"],
291141
+ {
291142
+ ...HIDDEN_CHILD_PROCESS_OPTIONS,
291143
+ cwd,
291144
+ encoding: "utf8",
291145
+ stdio: ["ignore", "pipe", "ignore"]
291146
+ }
291147
+ ),
291148
+ reset: (cwd, filePaths) => {
291149
+ if (filePaths.length === 0) return;
291150
+ let hasHead = true;
291151
+ try {
291152
+ execFileSync7("git", ["rev-parse", "--verify", "HEAD"], {
291153
+ ...HIDDEN_CHILD_PROCESS_OPTIONS,
291154
+ cwd,
291155
+ stdio: "ignore"
291156
+ });
291157
+ } catch {
291158
+ hasHead = false;
291159
+ }
291160
+ const args = hasHead ? ["reset", "--quiet", "HEAD", "--", ...filePaths] : [
291161
+ "rm",
291162
+ "--cached",
291163
+ "--force",
291164
+ "-r",
291165
+ "--ignore-unmatch",
291166
+ "--",
291167
+ ...filePaths
291168
+ ];
291169
+ execFileSync7("git", args, {
291170
+ ...HIDDEN_CHILD_PROCESS_OPTIONS,
291171
+ cwd,
291172
+ stdio: "ignore"
291173
+ });
291174
+ },
291069
291175
  checkout: (cwd, filePath) => {
291070
- execFileSync7("git", ["checkout", "--", filePath], {
291176
+ execFileSync7("git", ["checkout", "HEAD", "--", filePath], {
291071
291177
  ...HIDDEN_CHILD_PROCESS_OPTIONS,
291072
291178
  cwd,
291073
291179
  stdio: "ignore"
291074
291180
  });
291181
+ },
291182
+ snapshotIndex: (cwd, filePaths) => {
291183
+ if (filePaths.length === 0) return Buffer.alloc(0);
291184
+ return execFileSync7(
291185
+ "git",
291186
+ [
291187
+ "diff",
291188
+ "--cached",
291189
+ "--binary",
291190
+ "--full-index",
291191
+ "--no-ext-diff",
291192
+ "--",
291193
+ ...filePaths
291194
+ ],
291195
+ {
291196
+ ...HIDDEN_CHILD_PROCESS_OPTIONS,
291197
+ cwd,
291198
+ encoding: "buffer",
291199
+ maxBuffer: GIT_INDEX_PATCH_MAX_BYTES,
291200
+ stdio: ["ignore", "pipe", "ignore"]
291201
+ }
291202
+ );
291203
+ },
291204
+ restoreIndex: (cwd, filePaths, snapshot) => {
291205
+ if (filePaths.length === 0) return;
291206
+ defaultGitAdapter.reset(cwd, filePaths);
291207
+ if (snapshot.length === 0) return;
291208
+ execFileSync7(
291209
+ "git",
291210
+ ["apply", "--cached", "--whitespace=nowarn", "--recount", "-"],
291211
+ {
291212
+ ...HIDDEN_CHILD_PROCESS_OPTIONS,
291213
+ cwd,
291214
+ input: snapshot,
291215
+ maxBuffer: GIT_INDEX_PATCH_MAX_BYTES,
291216
+ stdio: ["pipe", "ignore", "ignore"]
291217
+ }
291218
+ );
291075
291219
  }
291076
291220
  };
291077
- function parseGitStatusPaths(output) {
291221
+ function parseGitStatusEntries(output) {
291078
291222
  const fields = output.split("\0");
291079
- const paths = [];
291223
+ const entries = [];
291080
291224
  for (let index = 0; index < fields.length; index++) {
291081
291225
  const record = fields[index];
291082
291226
  if (!record) continue;
@@ -291085,14 +291229,20 @@ function parseGitStatusPaths(output) {
291085
291229
  }
291086
291230
  const status = GitStatusCodeSchema.parse(record.slice(0, 2));
291087
291231
  const filePath = GitStatusPathSchema.parse(record.slice(3));
291088
- paths.push(filePath);
291232
+ let originalPath;
291089
291233
  if (status.includes("R") || status.includes("C")) {
291090
- const originalPath = fields[index + 1];
291091
- GitStatusPathSchema.parse(originalPath);
291234
+ originalPath = GitStatusPathSchema.parse(fields[index + 1]);
291092
291235
  index++;
291093
291236
  }
291237
+ entries.push({
291238
+ status,
291239
+ path: filePath,
291240
+ ...originalPath ? { originalPath } : {}
291241
+ });
291094
291242
  }
291095
- return [...new Set(paths)];
291243
+ return [
291244
+ ...new Map(entries.map((entry) => [entry.path, entry])).values()
291245
+ ];
291096
291246
  }
291097
291247
  async function handleRollbackCommand(command, argument, dependencies) {
291098
291248
  const isZh = dependencies.language !== "en";
@@ -291110,11 +291260,14 @@ async function handleRollbackCommand(command, argument, dependencies) {
291110
291260
  return HANDLED_COMMAND;
291111
291261
  }
291112
291262
  const git = dependencies.git ?? defaultGitAdapter;
291113
- let paths;
291263
+ let entries;
291114
291264
  try {
291115
- paths = parseGitStatusPaths(git.status(dependencies.cwd));
291116
- for (const filePath of paths) {
291117
- resolveSafePath(dependencies.cwd, filePath);
291265
+ entries = parseGitStatusEntries(git.status(dependencies.cwd));
291266
+ for (const entry of entries) {
291267
+ resolveSafePath(dependencies.cwd, entry.path);
291268
+ if (entry.originalPath) {
291269
+ resolveSafePath(dependencies.cwd, entry.originalPath);
291270
+ }
291118
291271
  }
291119
291272
  } catch (error) {
291120
291273
  if (error instanceof Error && error.message.includes("outside workspace")) {
@@ -291128,7 +291281,7 @@ async function handleRollbackCommand(command, argument, dependencies) {
291128
291281
  await dependencies.loop.rollbackLastCheckpoint();
291129
291282
  return HANDLED_COMMAND;
291130
291283
  }
291131
- if (paths.length === 0) {
291284
+ if (entries.length === 0) {
291132
291285
  dependencies.printOutput(
291133
291286
  picocolors13.yellow(
291134
291287
  isZh ? "\u5F53\u524D\u5DE5\u4F5C\u533A\u6CA1\u6709\u68C0\u6D4B\u5230\u4EFB\u4F55\u672A\u63D0\u4EA4\u7684\u4EE3\u7801\u53D8\u66F4\u3002" : "No uncommitted changes detected in the workspace."
@@ -291141,7 +291294,7 @@ async function handleRollbackCommand(command, argument, dependencies) {
291141
291294
  value: "all",
291142
291295
  label: isZh ? "\u3010\u5168\u90E8\u56DE\u6EDA\u3011 \u64A4\u9500\u6240\u6709\u53D8\u66F4" : "[Rollback All] Discard all changes"
291143
291296
  },
291144
- ...paths.map((filePath) => ({ value: filePath, label: filePath }))
291297
+ ...entries.map((entry) => ({ value: entry.path, label: entry.path }))
291145
291298
  ];
291146
291299
  const selected = await (dependencies.prompt ?? Prompt).askMultiSelect(
291147
291300
  isZh ? "\u9009\u62E9\u8981\u56DE\u6EDA\uFF08\u64A4\u9500\u53D8\u66F4\uFF09\u7684\u6587\u4EF6\uFF1A" : "Select files to rollback (discard changes):",
@@ -291158,16 +291311,52 @@ async function handleRollbackCommand(command, argument, dependencies) {
291158
291311
  return HANDLED_COMMAND;
291159
291312
  }
291160
291313
  try {
291161
- for (const filePath of selected) {
291162
- const absolutePath = resolveSafePath(dependencies.cwd, filePath);
291163
- if (dependencies.loop.rollbackFileToCheckpoint(filePath)) continue;
291314
+ const selectedEntries = revalidateSelectedEntries(
291315
+ selected,
291316
+ entries,
291317
+ parseGitStatusEntries(git.status(dependencies.cwd))
291318
+ );
291319
+ const indexPaths = collectIndexPaths(selectedEntries);
291320
+ const workspaceSnapshot = snapshotWorkspacePaths(
291321
+ dependencies.cwd,
291322
+ collectWorkspacePaths(selectedEntries)
291323
+ );
291324
+ const indexSnapshot = git.snapshotIndex?.(dependencies.cwd, indexPaths);
291325
+ try {
291326
+ if (indexPaths.length > 0) git.reset(dependencies.cwd, indexPaths);
291327
+ const checkpointResult = dependencies.loop.rollbackFilesToCheckpoints ? dependencies.loop.rollbackFilesToCheckpoints(
291328
+ selectedEntries.map((entry) => entry.path)
291329
+ ) : rollbackFilesIndividually(selectedEntries, dependencies.loop);
291330
+ if (!checkpointResult.success) {
291331
+ throw new Error(
291332
+ checkpointResult.error || "Checkpoint rollback transaction failed."
291333
+ );
291334
+ }
291335
+ const checkpointRestored = new Set(checkpointResult.restored);
291336
+ const gitEntries = selectedEntries.filter(
291337
+ (entry) => !checkpointRestored.has(entry.path)
291338
+ );
291339
+ for (const entry of gitEntries) {
291340
+ restoreGitStatusEntry(entry, dependencies, git);
291341
+ }
291342
+ } catch (error) {
291343
+ const compensationErrors = [];
291164
291344
  try {
291165
- git.checkout(dependencies.cwd, filePath);
291166
- } catch {
291167
- if (existsSync19(absolutePath)) {
291168
- (dependencies.removePath ?? removeWorkspacePath)(absolutePath);
291345
+ restoreWorkspaceSnapshot(dependencies.cwd, workspaceSnapshot);
291346
+ } catch (compensationError) {
291347
+ compensationErrors.push(toErrorMessage3(compensationError));
291348
+ }
291349
+ if (indexPaths.length > 0 && indexSnapshot && git.restoreIndex) {
291350
+ try {
291351
+ git.restoreIndex(dependencies.cwd, indexPaths, indexSnapshot);
291352
+ } catch (compensationError) {
291353
+ compensationErrors.push(toErrorMessage3(compensationError));
291169
291354
  }
291355
+ } else if (indexPaths.length > 0) {
291356
+ compensationErrors.push("Git index compensation is unavailable.");
291170
291357
  }
291358
+ const detail = compensationErrors.length === 0 ? " Previous workspace state was restored." : ` Compensation was incomplete: ${compensationErrors.join("; ")}`;
291359
+ throw new Error(`${toErrorMessage3(error)}${detail}`);
291171
291360
  }
291172
291361
  dependencies.printOutput(
291173
291362
  picocolors13.green(
@@ -291184,6 +291373,159 @@ async function handleRollbackCommand(command, argument, dependencies) {
291184
291373
  }
291185
291374
  return HANDLED_COMMAND;
291186
291375
  }
291376
+ function rollbackFilesIndividually(entries, loop) {
291377
+ const restored = entries.filter((entry) => loop.rollbackFileToCheckpoint(entry.path)).map((entry) => entry.path);
291378
+ const restoredSet = new Set(restored);
291379
+ return {
291380
+ success: true,
291381
+ restored,
291382
+ unresolved: entries.map((entry) => entry.path).filter((filePath) => !restoredSet.has(filePath))
291383
+ };
291384
+ }
291385
+ function revalidateSelectedEntries(selected, displayed, current) {
291386
+ const displayedByPath = new Map(
291387
+ displayed.map((entry) => [entry.path, entry])
291388
+ );
291389
+ const currentByPath = new Map(current.map((entry) => [entry.path, entry]));
291390
+ return selected.map((filePath) => {
291391
+ const previous = displayedByPath.get(filePath);
291392
+ const latest = currentByPath.get(filePath);
291393
+ if (!previous || !latest || !sameStatusEntry(previous, latest)) {
291394
+ throw new Error(
291395
+ `Git status changed while choosing rollback paths: ${filePath}`
291396
+ );
291397
+ }
291398
+ if (isUnmergedStatus(latest.status)) {
291399
+ throw new Error(
291400
+ `Resolve merge conflicts before rolling back this path: ${filePath}`
291401
+ );
291402
+ }
291403
+ return latest;
291404
+ });
291405
+ }
291406
+ function isUnmergedStatus(status) {
291407
+ return status.includes("U") || status === "AA" || status === "DD";
291408
+ }
291409
+ function sameStatusEntry(left, right) {
291410
+ return left.status === right.status && left.path === right.path && left.originalPath === right.originalPath;
291411
+ }
291412
+ function collectIndexPaths(entries) {
291413
+ return [
291414
+ ...new Set(
291415
+ entries.flatMap((entry) => {
291416
+ if (entry.status === "??") return [];
291417
+ return entry.originalPath ? [entry.path, entry.originalPath] : [entry.path];
291418
+ })
291419
+ )
291420
+ ];
291421
+ }
291422
+ function collectWorkspacePaths(entries) {
291423
+ return [
291424
+ ...new Set(
291425
+ entries.flatMap(
291426
+ (entry) => entry.originalPath ? [entry.path, entry.originalPath] : [entry.path]
291427
+ )
291428
+ )
291429
+ ];
291430
+ }
291431
+ function snapshotWorkspacePaths(cwd, filePaths) {
291432
+ if (filePaths.length > ROLLBACK_SNAPSHOT_MAX_PATHS) {
291433
+ throw new Error(
291434
+ `Rollback selection exceeds ${ROLLBACK_SNAPSHOT_MAX_PATHS} paths.`
291435
+ );
291436
+ }
291437
+ const snapshots = [];
291438
+ let totalBytes = 0;
291439
+ for (const filePath of filePaths) {
291440
+ const absolutePath = resolveSafePath(cwd, filePath);
291441
+ try {
291442
+ const stats = lstatSync7(absolutePath);
291443
+ if (stats.isSymbolicLink() || !stats.isFile()) {
291444
+ throw new Error(
291445
+ `Rollback transaction supports regular files only: ${filePath}`
291446
+ );
291447
+ }
291448
+ const content = readBoundedRegularFileBuffer(
291449
+ absolutePath,
291450
+ ROLLBACK_SNAPSHOT_FILE_MAX_BYTES
291451
+ );
291452
+ if (content === void 0) {
291453
+ throw new Error(`Rollback target disappeared: ${filePath}`);
291454
+ }
291455
+ totalBytes += content.length;
291456
+ if (totalBytes > ROLLBACK_SNAPSHOT_TOTAL_MAX_BYTES) {
291457
+ throw new Error(
291458
+ "Rollback selection exceeds the 128 MiB transaction snapshot limit."
291459
+ );
291460
+ }
291461
+ snapshots.push({ path: filePath, content });
291462
+ } catch (error) {
291463
+ if (isFileSystemError3(error, "ENOENT")) {
291464
+ snapshots.push({ path: filePath, content: null });
291465
+ continue;
291466
+ }
291467
+ throw error;
291468
+ }
291469
+ }
291470
+ return snapshots;
291471
+ }
291472
+ function restoreWorkspaceSnapshot(cwd, snapshots) {
291473
+ const failures = [];
291474
+ for (const snapshot of snapshots.slice().reverse()) {
291475
+ try {
291476
+ const absolutePath = resolveSafePath(cwd, snapshot.path);
291477
+ if (snapshot.content === null) {
291478
+ rmSync5(absolutePath, { recursive: true, force: true });
291479
+ continue;
291480
+ }
291481
+ if (existsSync19(absolutePath)) {
291482
+ const stats = lstatSync7(absolutePath);
291483
+ if (stats.isSymbolicLink() || !stats.isFile()) {
291484
+ throw new Error(
291485
+ `Compensation target is not a regular file: ${snapshot.path}`
291486
+ );
291487
+ }
291488
+ }
291489
+ mkdirSync6(dirname11(absolutePath), { recursive: true });
291490
+ writeFileSync8(resolveSafePath(cwd, snapshot.path), snapshot.content);
291491
+ } catch (error) {
291492
+ failures.push(`${snapshot.path}: ${toErrorMessage3(error)}`);
291493
+ }
291494
+ }
291495
+ if (failures.length > 0) {
291496
+ throw new Error(failures.join("; "));
291497
+ }
291498
+ }
291499
+ function isFileSystemError3(error, code) {
291500
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
291501
+ }
291502
+ function toErrorMessage3(error) {
291503
+ return error instanceof Error ? error.message : String(error);
291504
+ }
291505
+ function restoreGitStatusEntry(entry, dependencies, git) {
291506
+ const removePath = dependencies.removePath ?? removeWorkspacePath;
291507
+ const removeDestination = () => {
291508
+ const absolutePath = resolveSafePath(dependencies.cwd, entry.path);
291509
+ if (existsSync19(absolutePath)) removePath(absolutePath);
291510
+ };
291511
+ if (entry.status === "??" || entry.status.includes("A")) {
291512
+ removeDestination();
291513
+ return;
291514
+ }
291515
+ if (entry.status.includes("R")) {
291516
+ if (!entry.originalPath) {
291517
+ throw new Error(`Git rename is missing its original path: ${entry.path}`);
291518
+ }
291519
+ git.checkout(dependencies.cwd, entry.originalPath);
291520
+ removeDestination();
291521
+ return;
291522
+ }
291523
+ if (entry.status.includes("C")) {
291524
+ removeDestination();
291525
+ return;
291526
+ }
291527
+ git.checkout(dependencies.cwd, entry.path);
291528
+ }
291187
291529
  function printCheckpointTimeline(checkpoints, dependencies) {
291188
291530
  const isZh = dependencies.language !== "en";
291189
291531
  if (checkpoints.length === 0) {
@@ -291889,8 +292231,8 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
291889
292231
 
291890
292232
  // src/runtime/ProjectLauncher.ts
291891
292233
  import { spawn as spawn4 } from "child_process";
291892
- import { existsSync as existsSync20, mkdirSync as mkdirSync6, realpathSync as realpathSync3, statSync as statSync4 } from "fs";
291893
- import { dirname as dirname11, isAbsolute as isAbsolute7, parse as parse4, resolve as resolve13 } from "path";
292234
+ import { existsSync as existsSync20, mkdirSync as mkdirSync7, realpathSync as realpathSync3, statSync as statSync4 } from "fs";
292235
+ import { dirname as dirname12, isAbsolute as isAbsolute7, parse as parse4, resolve as resolve13 } from "path";
291894
292236
  var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
291895
292237
  async function launchOrbitProject(request, options = {}) {
291896
292238
  if (!isAbsolute7(request.path)) {
@@ -291983,7 +292325,7 @@ function createProjectDirectory(projectPath) {
291983
292325
  if (existsSync20(projectPath)) {
291984
292326
  throw new Error("Project folder already exists. Use Open folder instead.");
291985
292327
  }
291986
- const parentPath = dirname11(projectPath);
292328
+ const parentPath = dirname12(projectPath);
291987
292329
  if (!existsSync20(parentPath)) {
291988
292330
  throw new Error(
291989
292331
  "The parent folder does not exist. Choose an existing location first."
@@ -291993,7 +292335,7 @@ function createProjectDirectory(projectPath) {
291993
292335
  throw new Error("The project parent path must be a directory.");
291994
292336
  }
291995
292337
  try {
291996
- mkdirSync6(projectPath);
292338
+ mkdirSync7(projectPath);
291997
292339
  } catch (error) {
291998
292340
  if (isNodeError4(error) && error.code === "EEXIST") {
291999
292341
  throw new Error(
@@ -295094,7 +295436,7 @@ Risk Warning: ${reason}`);
295094
295436
  });
295095
295437
  const normCwd = resolve14(this.cwd).toLowerCase().replace(/\\/g, "/");
295096
295438
  const normHome = resolve14(homedir10()).toLowerCase().replace(/\\/g, "/");
295097
- const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname12(normCwd) === normCwd;
295439
+ const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname13(normCwd) === normCwd;
295098
295440
  if (!isHomeOrRoot) {
295099
295441
  const indexer = new SymbolIndexer(this.cwd);
295100
295442
  this.watcher = watch(
@@ -296516,13 +296858,13 @@ async function runSkillsCommand(action, options = {}) {
296516
296858
  // src/commands/trace.ts
296517
296859
  import {
296518
296860
  existsSync as existsSync21,
296519
- lstatSync as lstatSync7,
296520
- mkdirSync as mkdirSync7,
296861
+ lstatSync as lstatSync8,
296862
+ mkdirSync as mkdirSync8,
296521
296863
  renameSync as renameSync6,
296522
296864
  rmSync as rmSync7,
296523
- writeFileSync as writeFileSync8
296865
+ writeFileSync as writeFileSync9
296524
296866
  } from "fs";
296525
- import { dirname as dirname13, resolve as resolve15 } from "path";
296867
+ import { dirname as dirname14, resolve as resolve15 } from "path";
296526
296868
  import { randomUUID as randomUUID12 } from "crypto";
296527
296869
  import { z as z68 } from "zod";
296528
296870
  var TraceOptionsSchema = z68.object({
@@ -296542,18 +296884,18 @@ function runTraceExport(cwd, sessionId, options = {}) {
296542
296884
  return void 0;
296543
296885
  }
296544
296886
  const outputPath = resolveSafePath(cwd, value.out);
296545
- const directory = dirname13(outputPath);
296887
+ const directory = dirname14(outputPath);
296546
296888
  if (existsSync21(directory)) {
296547
- const stats = lstatSync7(directory);
296889
+ const stats = lstatSync8(directory);
296548
296890
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
296549
296891
  throw new Error("Trace output directory must be a real directory.");
296550
296892
  }
296551
296893
  } else {
296552
- mkdirSync7(directory, { recursive: true });
296894
+ mkdirSync8(directory, { recursive: true });
296553
296895
  }
296554
296896
  const temporaryPath = `${outputPath}.${process.pid}.${randomUUID12()}.tmp`;
296555
296897
  try {
296556
- writeFileSync8(temporaryPath, serialized, {
296898
+ writeFileSync9(temporaryPath, serialized, {
296557
296899
  encoding: "utf8",
296558
296900
  flag: "wx",
296559
296901
  mode: 384
@@ -296571,13 +296913,13 @@ import { exec as execCallback, execFileSync as execFileSync8 } from "child_proce
296571
296913
  import {
296572
296914
  copyFileSync,
296573
296915
  existsSync as existsSync28,
296574
- lstatSync as lstatSync8,
296575
- mkdirSync as mkdirSync8,
296916
+ lstatSync as lstatSync9,
296917
+ mkdirSync as mkdirSync9,
296576
296918
  renameSync as renameSync7,
296577
296919
  rmSync as rmSync8,
296578
- writeFileSync as writeFileSync9
296920
+ writeFileSync as writeFileSync10
296579
296921
  } from "fs";
296580
- import { basename as basename5, dirname as dirname14, join as join19 } from "path";
296922
+ import { basename as basename5, dirname as dirname15, join as join19 } from "path";
296581
296923
  import { randomUUID as randomUUID13 } from "crypto";
296582
296924
  import { promisify as promisify5 } from "util";
296583
296925
  import picocolors25 from "picocolors";
@@ -296750,7 +297092,7 @@ async function runEval(cwd, suiteFile, options = {}) {
296750
297092
  }
296751
297093
  function loadAcceptanceSuite(cwd, suiteFile) {
296752
297094
  const filePath = resolveSafePath(cwd, suiteFile);
296753
- const stats = lstatSync8(filePath);
297095
+ const stats = lstatSync9(filePath);
296754
297096
  if (stats.isSymbolicLink() || !stats.isFile()) {
296755
297097
  throw new Error("Acceptance suite must be a real file.");
296756
297098
  }
@@ -296847,9 +297189,9 @@ function snapshotWorkspaceIntoWorktree(sourceCwd, worktreeCwd) {
296847
297189
  if (isSensitiveSnapshotPath2(relativePath)) continue;
296848
297190
  const sourcePath = resolveSafePath(sourceCwd, relativePath);
296849
297191
  const targetPath = resolveSafePath(worktreeCwd, relativePath);
296850
- const stats = lstatSync8(sourcePath);
297192
+ const stats = lstatSync9(sourcePath);
296851
297193
  if (stats.isSymbolicLink() || !stats.isFile()) continue;
296852
- mkdirSync8(dirname14(targetPath), { recursive: true });
297194
+ mkdirSync9(dirname15(targetPath), { recursive: true });
296853
297195
  copyFileSync(sourcePath, targetPath);
296854
297196
  }
296855
297197
  execFileSync8("git", ["add", "-A"], {
@@ -296908,18 +297250,18 @@ function writeEvaluationReport(cwd, runId, report) {
296908
297250
  return filePath;
296909
297251
  }
296910
297252
  function writeJsonAtomically2(filePath, value) {
296911
- const directory = dirname14(filePath);
297253
+ const directory = dirname15(filePath);
296912
297254
  if (existsSync28(directory)) {
296913
- const stats = lstatSync8(directory);
297255
+ const stats = lstatSync9(directory);
296914
297256
  if (stats.isSymbolicLink() || !stats.isDirectory()) {
296915
297257
  throw new Error("Evaluation output directory must be a real directory.");
296916
297258
  }
296917
297259
  } else {
296918
- mkdirSync8(directory, { recursive: true });
297260
+ mkdirSync9(directory, { recursive: true });
296919
297261
  }
296920
297262
  const temporaryPath = `${filePath}.${process.pid}.${randomUUID13()}.tmp`;
296921
297263
  try {
296922
- writeFileSync9(temporaryPath, JSON.stringify(value, null, 2), {
297264
+ writeFileSync10(temporaryPath, JSON.stringify(value, null, 2), {
296923
297265
  encoding: "utf8",
296924
297266
  flag: "wx",
296925
297267
  mode: 384
@@ -296942,7 +297284,7 @@ import { resolve as resolve17 } from "path";
296942
297284
  import { z as z71 } from "zod";
296943
297285
 
296944
297286
  // src/runtime/CleanupManager.ts
296945
- import { lstatSync as lstatSync9, readdirSync as readdirSync9, rmSync as rmSync9 } from "fs";
297287
+ import { lstatSync as lstatSync10, readdirSync as readdirSync9, rmSync as rmSync9 } from "fs";
296946
297288
  import { homedir as homedir11 } from "os";
296947
297289
  import { basename as basename6, join as join20, parse as parse5, resolve as resolve16 } from "path";
296948
297290
  import { z as z70 } from "zod";
@@ -297012,7 +297354,7 @@ function inspectPath(targetPath) {
297012
297354
  const visit = (currentPath) => {
297013
297355
  let stat;
297014
297356
  try {
297015
- stat = lstatSync9(currentPath);
297357
+ stat = lstatSync10(currentPath);
297016
297358
  } catch (error) {
297017
297359
  warnings.push(safeInventoryWarning(currentPath, error));
297018
297360
  return;
@@ -297059,7 +297401,7 @@ function pathIdentity(targetPath) {
297059
297401
  }
297060
297402
  function pathExists(targetPath) {
297061
297403
  try {
297062
- lstatSync9(targetPath);
297404
+ lstatSync10(targetPath);
297063
297405
  return true;
297064
297406
  } catch {
297065
297407
  return false;
@@ -297196,15 +297538,15 @@ import { z as z75 } from "zod";
297196
297538
  // src/runtime/ProjectBackup.ts
297197
297539
  import {
297198
297540
  existsSync as existsSync29,
297199
- lstatSync as lstatSync10,
297200
- mkdirSync as mkdirSync9,
297541
+ lstatSync as lstatSync11,
297542
+ mkdirSync as mkdirSync10,
297201
297543
  readdirSync as readdirSync10,
297202
297544
  renameSync as renameSync8,
297203
297545
  rmSync as rmSync10,
297204
- writeFileSync as writeFileSync10
297546
+ writeFileSync as writeFileSync11
297205
297547
  } from "fs";
297206
297548
  import { createHash as createHash9, randomUUID as randomUUID14 } from "crypto";
297207
- import { dirname as dirname15, isAbsolute as isAbsolute8, join as join21, relative as relative9, resolve as resolve18, sep as sep2 } from "path";
297549
+ import { dirname as dirname16, isAbsolute as isAbsolute8, join as join21, relative as relative9, resolve as resolve18, sep as sep2 } from "path";
297208
297550
  import { z as z74 } from "zod";
297209
297551
  var MAX_BACKUP_BYTES = 64 * 1024 * 1024;
297210
297552
  var MAX_SERIALIZED_BACKUP_BYTES = 96 * 1024 * 1024;
@@ -297313,10 +297655,10 @@ function createProjectBackup(projectDirectory) {
297313
297655
  }
297314
297656
  function writeProjectBackup(outputPath, bundle) {
297315
297657
  const destination = resolve18(outputPath);
297316
- mkdirSync9(dirname15(destination), { recursive: true });
297658
+ mkdirSync10(dirname16(destination), { recursive: true });
297317
297659
  const temporaryPath = `${destination}.${process.pid}.${randomUUID14()}.tmp`;
297318
297660
  try {
297319
- writeFileSync10(
297661
+ writeFileSync11(
297320
297662
  temporaryPath,
297321
297663
  `${JSON.stringify(ProjectBackupBundleSchema.parse(bundle), null, 2)}
297322
297664
  `,
@@ -297358,11 +297700,11 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
297358
297700
  }
297359
297701
  const restored = [];
297360
297702
  for (const { file, destination } of planned) {
297361
- assertDirectoryChainHasNoSymlink(orbitRoot, dirname15(destination));
297362
- mkdirSync9(dirname15(destination), { recursive: true });
297703
+ assertDirectoryChainHasNoSymlink(orbitRoot, dirname16(destination));
297704
+ mkdirSync10(dirname16(destination), { recursive: true });
297363
297705
  const temporaryPath = `${destination}.${process.pid}.${randomUUID14()}.tmp`;
297364
297706
  try {
297365
- writeFileSync10(temporaryPath, Buffer.from(file.content, "base64"), {
297707
+ writeFileSync11(temporaryPath, Buffer.from(file.content, "base64"), {
297366
297708
  mode: 384
297367
297709
  });
297368
297710
  replaceFileAtomically2(temporaryPath, destination);
@@ -297393,7 +297735,7 @@ function listBackupFiles(root) {
297393
297735
  const relativePath = relative9(root, absolutePath).split(sep2).join("/");
297394
297736
  const topLevel = relativePath.split("/")[0]?.toLowerCase() ?? "";
297395
297737
  if (EXCLUDED_TOP_LEVEL.has(topLevel)) continue;
297396
- const status = lstatSync10(absolutePath);
297738
+ const status = lstatSync11(absolutePath);
297397
297739
  if (status.isSymbolicLink()) continue;
297398
297740
  if (status.isDirectory()) visit(absolutePath, depth + 1);
297399
297741
  else if (status.isFile()) {
@@ -297437,12 +297779,12 @@ function assertDirectoryChainHasNoSymlink(root, target) {
297437
297779
  throw new Error("Backup restore directory escapes the project.");
297438
297780
  }
297439
297781
  let current = absoluteRoot;
297440
- if (existsSync29(current) && lstatSync10(current).isSymbolicLink()) {
297782
+ if (existsSync29(current) && lstatSync11(current).isSymbolicLink()) {
297441
297783
  throw new Error(`Refusing to restore through symbolic link: ${current}`);
297442
297784
  }
297443
297785
  for (const part of relativeTarget.split(sep2).filter(Boolean)) {
297444
297786
  current = join21(current, part);
297445
- if (existsSync29(current) && lstatSync10(current).isSymbolicLink()) {
297787
+ if (existsSync29(current) && lstatSync11(current).isSymbolicLink()) {
297446
297788
  throw new Error(`Refusing to restore through symbolic link: ${current}`);
297447
297789
  }
297448
297790
  }
@@ -297571,15 +297913,15 @@ import picocolors28 from "picocolors";
297571
297913
  // src/runtime/ExtensionManager.ts
297572
297914
  import {
297573
297915
  existsSync as existsSync30,
297574
- lstatSync as lstatSync11,
297575
- mkdirSync as mkdirSync10,
297916
+ lstatSync as lstatSync12,
297917
+ mkdirSync as mkdirSync11,
297576
297918
  readdirSync as readdirSync11,
297577
297919
  renameSync as renameSync9,
297578
297920
  rmSync as rmSync11,
297579
- writeFileSync as writeFileSync11
297921
+ writeFileSync as writeFileSync12
297580
297922
  } from "fs";
297581
297923
  import { randomUUID as randomUUID15 } from "crypto";
297582
- import { dirname as dirname16, isAbsolute as isAbsolute9, join as join26, relative as relative10, resolve as resolve20, sep as sep3 } from "path";
297924
+ import { dirname as dirname17, isAbsolute as isAbsolute9, join as join26, relative as relative10, resolve as resolve20, sep as sep3 } from "path";
297583
297925
  import { homedir as homedir12 } from "os";
297584
297926
  import { z as z76 } from "zod";
297585
297927
  var InstalledExtensionSchema2 = z76.object({
@@ -297609,7 +297951,7 @@ var ExtensionManager = class {
297609
297951
  list() {
297610
297952
  try {
297611
297953
  return this.readRegistry().filter(
297612
- (extension) => this.isManagedExtensionPath(extension) && existsSync30(extension.path) && !lstatSync11(extension.path).isSymbolicLink()
297954
+ (extension) => this.isManagedExtensionPath(extension) && existsSync30(extension.path) && !lstatSync12(extension.path).isSymbolicLink()
297613
297955
  );
297614
297956
  } catch {
297615
297957
  return [];
@@ -297618,7 +297960,7 @@ var ExtensionManager = class {
297618
297960
  install(cwd, manifestPath, options = {}) {
297619
297961
  const manifest = loadOrbitExtensionManifest(cwd, manifestPath);
297620
297962
  verifyOrbitCompatibility(manifest, readCliVersion());
297621
- const sourceRoot = dirname16(resolve20(cwd, manifestPath));
297963
+ const sourceRoot = dirname17(resolve20(cwd, manifestPath));
297622
297964
  validateContributionFiles(sourceRoot, manifest);
297623
297965
  validateContributionPermissions(manifest);
297624
297966
  const requiresTrust = extensionRequiresTrust(manifest);
@@ -297655,7 +297997,7 @@ var ExtensionManager = class {
297655
297997
  { cause: error }
297656
297998
  );
297657
297999
  }
297658
- mkdirSync10(this.extensionsDir, { recursive: true });
298000
+ mkdirSync11(this.extensionsDir, { recursive: true });
297659
298001
  let targetBackedUp = false;
297660
298002
  let targetInstalled = false;
297661
298003
  let promptMutationStarted = false;
@@ -297668,7 +298010,7 @@ var ExtensionManager = class {
297668
298010
  }
297669
298011
  for (const prompt of promptTargets) {
297670
298012
  if (!existsSync30(prompt.target)) continue;
297671
- mkdirSync10(dirname16(prompt.backup), { recursive: true });
298013
+ mkdirSync11(dirname17(prompt.backup), { recursive: true });
297672
298014
  renameSync9(prompt.target, prompt.backup);
297673
298015
  prompt.backedUp = true;
297674
298016
  }
@@ -297711,7 +298053,7 @@ var ExtensionManager = class {
297711
298053
  rmSync11(prompt.target, { recursive: true, force: true });
297712
298054
  }
297713
298055
  if (prompt.backedUp && existsSync30(prompt.backup)) {
297714
- mkdirSync10(dirname16(prompt.target), { recursive: true });
298056
+ mkdirSync11(dirname17(prompt.target), { recursive: true });
297715
298057
  renameSync9(prompt.backup, prompt.target);
297716
298058
  }
297717
298059
  }
@@ -297738,7 +298080,7 @@ var ExtensionManager = class {
297738
298080
  );
297739
298081
  }
297740
298082
  const installed = registry.find(
297741
- (entry) => entry.id === id && existsSync30(entry.path) && !lstatSync11(entry.path).isSymbolicLink()
298083
+ (entry) => entry.id === id && existsSync30(entry.path) && !lstatSync12(entry.path).isSymbolicLink()
297742
298084
  );
297743
298085
  if (!installed) return false;
297744
298086
  const rollbackRoot = join26(
@@ -297759,7 +298101,7 @@ var ExtensionManager = class {
297759
298101
  try {
297760
298102
  for (const entry of targets) {
297761
298103
  if (!existsSync30(entry.target)) continue;
297762
- mkdirSync10(dirname16(entry.backup), { recursive: true });
298104
+ mkdirSync11(dirname17(entry.backup), { recursive: true });
297763
298105
  renameSync9(entry.target, entry.backup);
297764
298106
  entry.backedUp = true;
297765
298107
  }
@@ -297770,7 +298112,7 @@ var ExtensionManager = class {
297770
298112
  try {
297771
298113
  for (const entry of targets) {
297772
298114
  if (!entry.backedUp || !existsSync30(entry.backup)) continue;
297773
- mkdirSync10(dirname16(entry.target), { recursive: true });
298115
+ mkdirSync11(dirname17(entry.target), { recursive: true });
297774
298116
  renameSync9(entry.backup, entry.target);
297775
298117
  }
297776
298118
  rmSync11(rollbackRoot, { recursive: true, force: true });
@@ -297898,7 +298240,7 @@ function validateContributionFiles(root, manifest) {
297898
298240
  `Invalid extension contribution path: ${contribution.path}`
297899
298241
  );
297900
298242
  }
297901
- if (!existsSync30(target) || lstatSync11(target).isSymbolicLink()) {
298243
+ if (!existsSync30(target) || lstatSync12(target).isSymbolicLink()) {
297902
298244
  throw new Error(
297903
298245
  `Extension contribution is missing or unsafe: ${contribution.path}`
297904
298246
  );
@@ -297916,11 +298258,11 @@ function copyDirectoryEntry(source, target, budget, depth) {
297916
298258
  if (budget.entries > MAX_EXTENSION_TREE_ENTRIES) {
297917
298259
  throw new Error("Extension tree contains too many entries.");
297918
298260
  }
297919
- const stats = lstatSync11(source);
298261
+ const stats = lstatSync12(source);
297920
298262
  if (stats.isSymbolicLink())
297921
298263
  throw new Error("Extension directories cannot contain symlinks.");
297922
298264
  if (stats.isDirectory()) {
297923
- mkdirSync10(target, { recursive: true });
298265
+ mkdirSync11(target, { recursive: true });
297924
298266
  for (const entry of readdirSync11(source)) {
297925
298267
  if (entry === "node_modules" || entry === ".git") continue;
297926
298268
  copyDirectoryEntry(
@@ -297940,8 +298282,8 @@ function copyDirectoryEntry(source, target, budget, depth) {
297940
298282
  if (budget.bytes > MAX_EXTENSION_TREE_BYTES) {
297941
298283
  throw new Error("Extension tree exceeds the 256 MiB limit.");
297942
298284
  }
297943
- mkdirSync10(dirname16(target), { recursive: true });
297944
- writeFileSync11(target, data, { mode: 384 });
298285
+ mkdirSync11(dirname17(target), { recursive: true });
298286
+ writeFileSync12(target, data, { mode: 384 });
297945
298287
  }
297946
298288
  function materializePromptContributions(extensionRoot, manifest, orbitDir) {
297947
298289
  for (const [kind, contributions] of [
@@ -297952,7 +298294,7 @@ function materializePromptContributions(extensionRoot, manifest, orbitDir) {
297952
298294
  rmSync11(destinationRoot, { recursive: true, force: true });
297953
298295
  for (const contribution of contributions) {
297954
298296
  const source = resolve20(extensionRoot, contribution.path);
297955
- const sourceIsDirectory = lstatSync11(source).isDirectory();
298297
+ const sourceIsDirectory = lstatSync12(source).isDirectory();
297956
298298
  const destination = sourceIsDirectory ? join26(destinationRoot, contribution.name) : kind === "commands" ? join26(destinationRoot, `${contribution.name}.md`) : join26(destinationRoot, contribution.name, "SKILL.md");
297957
298299
  copyDirectorySafely(source, destination);
297958
298300
  }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
+ "license": "Apache-2.0",
4
5
  "description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
5
6
  "keywords": [
6
7
  "ai",
@@ -36,6 +37,7 @@
36
37
  "files": [
37
38
  "dist",
38
39
  "README.md",
40
+ "THIRD_PARTY_NOTICES.md",
39
41
  "commands",
40
42
  "skills"
41
43
  ],