@zero-gravity/zero-gravity 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +50 -2
- package/THIRD-PARTY-NOTICES.md +100 -0
- package/dist/adv-context-SLTP32JQ.js +36 -0
- package/dist/advanced-EPLZB6DG.js +164 -0
- package/dist/agents-JYRQHH7R.js +181 -0
- package/dist/chat-AEHVCKXX.js +47 -0
- package/dist/chunk-2OH5KHWO.js +112 -0
- package/dist/chunk-2ZYSAYMJ.js +108 -0
- package/dist/chunk-4BZ4IXTO.js +161 -0
- package/dist/chunk-4ITJY25Z.js +144 -0
- package/dist/chunk-4JBLZQAQ.js +65 -0
- package/dist/chunk-6QLYRU3N.js +28 -0
- package/dist/chunk-7TACFVY2.js +57 -0
- package/dist/chunk-AY36KJTH.js +3023 -0
- package/dist/chunk-BJABQO7S.js +378 -0
- package/dist/chunk-C2GFK4JP.js +387 -0
- package/dist/chunk-CDC2K2KP.js +47 -0
- package/dist/chunk-DKCCXMSE.js +27 -0
- package/dist/chunk-FC3UOHOO.js +194 -0
- package/dist/chunk-FIASMDLX.js +216 -0
- package/dist/chunk-GMVDCQVW.js +88 -0
- package/dist/chunk-JQYZX56A.js +231 -0
- package/dist/chunk-JU5PGDOD.js +138 -0
- package/dist/chunk-JUZP5SXD.js +309 -0
- package/dist/chunk-KGA7VWQG.js +70 -0
- package/dist/chunk-L7VNR5LM.js +407 -0
- package/dist/chunk-LOSXCWHU.js +145 -0
- package/dist/chunk-NVC433AX.js +24 -0
- package/dist/chunk-QH27MDJM.js +248 -0
- package/dist/chunk-QUC5URWQ.js +708 -0
- package/dist/chunk-R2CPYTSP.js +31 -0
- package/dist/chunk-R5KQACGR.js +2833 -0
- package/dist/chunk-R6DONQKN.js +153 -0
- package/dist/chunk-RIX4S3J7.js +4747 -0
- package/dist/chunk-SZKAZ2VN.js +35 -0
- package/dist/chunk-T6DDNE3W.js +1338 -0
- package/dist/chunk-U4URD6TU.js +4605 -0
- package/dist/chunk-U5UIUB6L.js +51 -0
- package/dist/chunk-UMC77TR3.js +79 -0
- package/dist/chunk-UQURXFAE.js +80 -0
- package/dist/chunk-VBG7T7XY.js +1703 -0
- package/dist/chunk-VCCMJIAG.js +326 -0
- package/dist/chunk-VS375NYD.js +91 -0
- package/dist/chunk-WANZOLI5.js +1073 -0
- package/dist/chunk-WUF3TVAE.js +51 -0
- package/dist/chunk-XCWLFZSM.js +149 -0
- package/dist/chunk-YJEUXO5I.js +76 -0
- package/dist/chunk-YR6RCC6Y.js +894 -0
- package/dist/chunk-ZQFAX275.js +35 -0
- package/dist/config-ELG4FQ3K.js +30 -0
- package/dist/config-IEWRCG7R.js +50 -0
- package/dist/doctor-ZZC2D3RW.js +357 -0
- package/dist/ext-context-RIMZMEPB.js +37 -0
- package/dist/index.js +20 -0
- package/dist/init-UB3E47KM.js +22 -0
- package/dist/integrations-HW4VTLN4.js +183 -0
- package/dist/main-RAWWT22W.js +115 -0
- package/dist/mcp-SWD4SO35.js +232 -0
- package/dist/mcp-context-PM5FY665.js +28 -0
- package/dist/memory-QQ54GRCN.js +128 -0
- package/dist/memory-session-R6DGT6CS.js +14 -0
- package/dist/memory-summary-4P26B2ZY.js +18 -0
- package/dist/plugins-VUGTEUNV.js +166 -0
- package/dist/providers-O3WOVP5Q.js +417 -0
- package/dist/report-DDIZ6BLF.js +28 -0
- package/dist/sec-context-VQHW6TOZ.js +15 -0
- package/dist/security-SAYW4LU4.js +95 -0
- package/dist/sessions-CL6CRNQL.js +160 -0
- package/dist/skills-7KDGTTKX.js +126 -0
- package/dist/version-6E6A23B3.js +13 -0
- package/package.json +70 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to ZERO GRAVITY (`zg`) are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/): MAJOR for incompatible changes, MINOR for backwards-compatible features, PATCH for backwards-compatible fixes.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - Unreleased
|
|
6
|
+
|
|
7
|
+
First release candidate. Nothing has been published to npm yet; the date is added when it is.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Interactive terminal chat with streaming responses, slash commands, context budgeting and manual compaction.
|
|
11
|
+
- Providers: OpenAI, Anthropic, Gemini, Ollama and OpenAI-compatible endpoints. API keys come from environment variables only and are never written to zg's files.
|
|
12
|
+
- Agent that plans tasks for approval; reviewed file edits with backups and restore; approved terminal commands; Git status, diffs, staging, commits and branches after approval.
|
|
13
|
+
- Local memory and saved, resumable sessions with retention, redaction, export and import.
|
|
14
|
+
- MCP client (stdio and Streamable HTTP), an integrations catalog, skills, plugins (separate process) and custom agents.
|
|
15
|
+
- Advanced coding helpers: analyze, search, index, explain, debug, review, refactor, test and docs, plus optional language-server support.
|
|
16
|
+
- Central security and permission system: eight permission levels, protected files, hash-chained audit log, strict/balanced/custom modes.
|
|
17
|
+
- `zg doctor`, `zg diagnostics`, `zg version` and `zg status` (all with `--json`; no secret values).
|
|
18
|
+
|
|
19
|
+
### Performance
|
|
20
|
+
- Lazy loading of the MCP SDK and of command modules, plus code splitting; the index is no longer rewritten when nothing changed; indexing cancels promptly on large projects.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- MCP stdio `command` may now be an absolute Windows path (backslashes, spaces); a bare program name must still be one plain word and shell characters are still refused.
|
|
24
|
+
- Pressing Ctrl+D while a response streams no longer causes a "readline was closed" error.
|
|
25
|
+
|
|
26
|
+
### Known limitations
|
|
27
|
+
- Verified only on Ubuntu x64 and (through CI) the runners listed in `docs/COMPATIBILITY.md`. Termux, Windows and macOS behaviour is otherwise unverified.
|
|
28
|
+
- No live AI provider has been tested; providers are tested against local fake servers.
|
|
29
|
+
- Code intelligence is text-pattern based, not a full parser.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZERO GRAVITY contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ZERO GRAVITY (`zg`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An independent AI coding terminal. It runs on your computer, talks to the AI provider you choose with your own API key, and asks before it changes files, runs commands or changes Git.
|
|
4
|
+
|
|
5
|
+
> Version 0.1.0 is a first release. Read **Limitations** before relying on it.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @zero-gravity/zero-gravity
|
|
11
|
+
zg --version
|
|
12
|
+
zg doctor
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires **Node.js 22 or newer**. Update with `npm update -g @zero-gravity/zero-gravity` (or `npm install -g @zero-gravity/zero-gravity@latest`). Your configuration, sessions and memory are kept in your own config directory and are not touched by upgrades.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
zg # open the chat; no API key is needed just to open it
|
|
21
|
+
zg provider # choose an AI provider
|
|
22
|
+
zg auth # see which environment variable holds that provider's key
|
|
23
|
+
zg doctor # check your system
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Set the key in your shell, for example `export OPENAI_API_KEY=...` (PowerShell: `$env:OPENAI_API_KEY="..."`). zg never stores or prints key values.
|
|
27
|
+
|
|
28
|
+
## What it does
|
|
29
|
+
|
|
30
|
+
- Streaming chat with OpenAI, Anthropic, Gemini, Ollama and OpenAI-compatible servers.
|
|
31
|
+
- An agent that plans first and waits for your approval; reviewed file edits with backups; approved commands; approved Git changes.
|
|
32
|
+
- Memory and resumable sessions kept locally.
|
|
33
|
+
- MCP servers, skills, plugins and custom agents.
|
|
34
|
+
- Project analysis, text search, review, refactoring previews and documentation drafts.
|
|
35
|
+
- A central permission system with protected files and an audit log.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
`zg doctor`, `diagnostics`, `version`, `status`, `init`, `config`, `chat`, `providers`, `provider`, `models`, `auth`, `memory`, `sessions`, `mcp`, `integrations`, `skills`, `plugins`, `agents`, `analyze`, `search`, `index`, `explain`, `debug`, `review`, `refactor`, `test`, `docs`, `lsp`, `security`. Run `zg --help` or `zg <command> --help`.
|
|
40
|
+
|
|
41
|
+
## Limitations
|
|
42
|
+
|
|
43
|
+
- Tested on Ubuntu x64 and on the CI runners listed in the repository's `docs/COMPATIBILITY.md`; other platforms (including Termux) are unverified.
|
|
44
|
+
- No live provider has been tested against the real services; adapters are tested against local fake servers.
|
|
45
|
+
- Code intelligence is text-pattern based, not a full language parser.
|
|
46
|
+
|
|
47
|
+
## Links
|
|
48
|
+
|
|
49
|
+
- Repository and documentation: https://github.com/Pratik-Verma-002/Zero-Gravity
|
|
50
|
+
- Issues: https://github.com/Pratik-Verma-002/Zero-Gravity/issues
|
|
51
|
+
- License: MIT
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
ZERO GRAVITY is MIT licensed (see LICENSE). It depends at run time on the packages below, which npm installs next to it; they are not copied into this package. Each is distributed under its own license, shown here as declared in its package metadata. This list was generated from the dependency tree that was installed in the development environment for version 0.1.0; regenerate it when dependencies change.
|
|
4
|
+
|
|
5
|
+
| Package | Version | License |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| @hono/node-server | 2.1.11 | MIT |
|
|
8
|
+
| @modelcontextprotocol/sdk | 1.32.2 | MIT |
|
|
9
|
+
| accepts | 2.0.0 | MIT |
|
|
10
|
+
| ajv | 8.20.0 | MIT |
|
|
11
|
+
| ajv-formats | 3.0.1 | MIT |
|
|
12
|
+
| body-parser | 2.4.0 | MIT |
|
|
13
|
+
| bytes | 3.1.2 | MIT |
|
|
14
|
+
| call-bind-apply-helpers | 1.0.2 | MIT |
|
|
15
|
+
| call-bound | 1.0.4 | MIT |
|
|
16
|
+
| chalk | 5.6.2 | MIT |
|
|
17
|
+
| commander | 13.1.0 | MIT |
|
|
18
|
+
| content-disposition | 2.0.1 | MIT |
|
|
19
|
+
| content-type | 1.0.5 | MIT |
|
|
20
|
+
| content-type | 2.1.0 | MIT |
|
|
21
|
+
| cookie | 0.7.2 | MIT |
|
|
22
|
+
| cookie-signature | 1.2.2 | MIT |
|
|
23
|
+
| cors | 2.8.6 | MIT |
|
|
24
|
+
| cross-spawn | 7.0.6 | MIT |
|
|
25
|
+
| debug | 4.4.3 | MIT |
|
|
26
|
+
| depd | 2.0.0 | MIT |
|
|
27
|
+
| dunder-proto | 1.0.1 | MIT |
|
|
28
|
+
| ee-first | 1.1.1 | MIT |
|
|
29
|
+
| encodeurl | 2.0.3 | MIT |
|
|
30
|
+
| es-define-property | 1.0.1 | MIT |
|
|
31
|
+
| es-errors | 1.3.0 | MIT |
|
|
32
|
+
| es-object-atoms | 1.1.2 | MIT |
|
|
33
|
+
| escape-html | 1.0.3 | MIT |
|
|
34
|
+
| etag | 1.8.1 | MIT |
|
|
35
|
+
| eventsource | 3.0.7 | MIT |
|
|
36
|
+
| eventsource-parser | 3.1.1 | MIT |
|
|
37
|
+
| express | 5.3.0 | MIT |
|
|
38
|
+
| express-rate-limit | 8.7.5 | MIT |
|
|
39
|
+
| fast-deep-equal | 3.1.3 | MIT |
|
|
40
|
+
| fast-uri | 3.1.9 | BSD-3-Clause |
|
|
41
|
+
| finalhandler | 2.1.1 | MIT |
|
|
42
|
+
| forwarded | 0.2.0 | MIT |
|
|
43
|
+
| fresh | 2.0.0 | MIT |
|
|
44
|
+
| function-bind | 1.1.2 | MIT |
|
|
45
|
+
| get-intrinsic | 1.3.0 | MIT |
|
|
46
|
+
| get-proto | 1.0.1 | MIT |
|
|
47
|
+
| gopd | 1.2.0 | MIT |
|
|
48
|
+
| has-symbols | 1.1.0 | MIT |
|
|
49
|
+
| hasown | 2.0.4 | MIT |
|
|
50
|
+
| hono | 4.13.23 | MIT |
|
|
51
|
+
| http-errors | 2.0.1 | MIT |
|
|
52
|
+
| iconv-lite | 0.7.3 | MIT |
|
|
53
|
+
| inherits | 2.0.4 | ISC |
|
|
54
|
+
| ip-address | 10.7.7 | MIT |
|
|
55
|
+
| ipaddr.js | 1.9.1 | MIT |
|
|
56
|
+
| is-promise | 4.0.0 | MIT |
|
|
57
|
+
| isexe | 2.0.0 | ISC |
|
|
58
|
+
| jose | 6.2.18 | MIT |
|
|
59
|
+
| json-schema-traverse | 1.0.0 | MIT |
|
|
60
|
+
| json-schema-typed | 8.0.2 | BSD-2-Clause |
|
|
61
|
+
| math-intrinsics | 1.1.0 | MIT |
|
|
62
|
+
| media-typer | 1.1.1 | MIT |
|
|
63
|
+
| merge-descriptors | 2.0.0 | MIT |
|
|
64
|
+
| mime-db | 1.54.0 | MIT |
|
|
65
|
+
| mime-types | 3.0.2 | MIT |
|
|
66
|
+
| ms | 2.1.3 | MIT |
|
|
67
|
+
| negotiator | 1.1.0 | MIT |
|
|
68
|
+
| object-assign | 4.1.1 | MIT |
|
|
69
|
+
| object-inspect | 1.14.0 | MIT |
|
|
70
|
+
| on-finished | 2.4.2 | MIT |
|
|
71
|
+
| once | 1.4.0 | ISC |
|
|
72
|
+
| parseurl | 1.3.3 | MIT |
|
|
73
|
+
| path-key | 3.1.1 | MIT |
|
|
74
|
+
| path-to-regexp | 8.4.2 | MIT |
|
|
75
|
+
| pkce-challenge | 5.0.2 | MIT |
|
|
76
|
+
| proxy-addr | 2.0.8 | MIT |
|
|
77
|
+
| qs | 6.17.1 | BSD-3-Clause |
|
|
78
|
+
| range-parser | 1.3.0 | MIT |
|
|
79
|
+
| raw-body | 3.0.2 | MIT |
|
|
80
|
+
| require-from-string | 2.0.2 | MIT |
|
|
81
|
+
| router | 2.3.0 | MIT |
|
|
82
|
+
| safer-buffer | 2.1.2 | MIT |
|
|
83
|
+
| send | 1.2.1 | MIT |
|
|
84
|
+
| serve-static | 2.2.1 | MIT |
|
|
85
|
+
| setprototypeof | 1.2.0 | ISC |
|
|
86
|
+
| shebang-command | 2.0.0 | MIT |
|
|
87
|
+
| shebang-regex | 3.0.0 | MIT |
|
|
88
|
+
| side-channel | 1.1.1 | MIT |
|
|
89
|
+
| side-channel-list | 1.0.1 | MIT |
|
|
90
|
+
| side-channel-map | 1.0.1 | MIT |
|
|
91
|
+
| side-channel-weakmap | 1.0.2 | MIT |
|
|
92
|
+
| statuses | 2.0.2 | MIT |
|
|
93
|
+
| toidentifier | 1.0.1 | MIT |
|
|
94
|
+
| type-is | 2.1.0 | MIT |
|
|
95
|
+
| unpipe | 1.0.0 | MIT |
|
|
96
|
+
| vary | 1.1.2 | MIT |
|
|
97
|
+
| which | 2.0.2 | ISC |
|
|
98
|
+
| wrappy | 1.0.2 | ISC |
|
|
99
|
+
| zod | 4.6.7 | MIT |
|
|
100
|
+
| zod-to-json-schema | 3.25.2 | ISC |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
advGuard,
|
|
4
|
+
openAdvanced
|
|
5
|
+
} from "./chunk-4JBLZQAQ.js";
|
|
6
|
+
import "./chunk-U4URD6TU.js";
|
|
7
|
+
import "./chunk-R5KQACGR.js";
|
|
8
|
+
import "./chunk-L7VNR5LM.js";
|
|
9
|
+
import "./chunk-VCCMJIAG.js";
|
|
10
|
+
import "./chunk-RIX4S3J7.js";
|
|
11
|
+
import "./chunk-LOSXCWHU.js";
|
|
12
|
+
import "./chunk-WANZOLI5.js";
|
|
13
|
+
import "./chunk-JUZP5SXD.js";
|
|
14
|
+
import "./chunk-4ITJY25Z.js";
|
|
15
|
+
import "./chunk-CDC2K2KP.js";
|
|
16
|
+
import "./chunk-YJEUXO5I.js";
|
|
17
|
+
import "./chunk-KGA7VWQG.js";
|
|
18
|
+
import "./chunk-2ZYSAYMJ.js";
|
|
19
|
+
import "./chunk-YR6RCC6Y.js";
|
|
20
|
+
import "./chunk-SZKAZ2VN.js";
|
|
21
|
+
import "./chunk-DKCCXMSE.js";
|
|
22
|
+
import "./chunk-U5UIUB6L.js";
|
|
23
|
+
import "./chunk-XCWLFZSM.js";
|
|
24
|
+
import "./chunk-GMVDCQVW.js";
|
|
25
|
+
import "./chunk-JQYZX56A.js";
|
|
26
|
+
import "./chunk-R6DONQKN.js";
|
|
27
|
+
import "./chunk-QH27MDJM.js";
|
|
28
|
+
import "./chunk-C2GFK4JP.js";
|
|
29
|
+
import "./chunk-R2CPYTSP.js";
|
|
30
|
+
import "./chunk-ZQFAX275.js";
|
|
31
|
+
import "./chunk-FC3UOHOO.js";
|
|
32
|
+
import "./chunk-WUF3TVAE.js";
|
|
33
|
+
export {
|
|
34
|
+
advGuard,
|
|
35
|
+
openAdvanced
|
|
36
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
advGuard,
|
|
4
|
+
openAdvanced
|
|
5
|
+
} from "./chunk-4JBLZQAQ.js";
|
|
6
|
+
import "./chunk-U4URD6TU.js";
|
|
7
|
+
import "./chunk-R5KQACGR.js";
|
|
8
|
+
import "./chunk-L7VNR5LM.js";
|
|
9
|
+
import "./chunk-VCCMJIAG.js";
|
|
10
|
+
import "./chunk-RIX4S3J7.js";
|
|
11
|
+
import "./chunk-LOSXCWHU.js";
|
|
12
|
+
import "./chunk-WANZOLI5.js";
|
|
13
|
+
import "./chunk-JUZP5SXD.js";
|
|
14
|
+
import "./chunk-4ITJY25Z.js";
|
|
15
|
+
import "./chunk-CDC2K2KP.js";
|
|
16
|
+
import "./chunk-YJEUXO5I.js";
|
|
17
|
+
import "./chunk-KGA7VWQG.js";
|
|
18
|
+
import "./chunk-2ZYSAYMJ.js";
|
|
19
|
+
import {
|
|
20
|
+
confirm
|
|
21
|
+
} from "./chunk-YR6RCC6Y.js";
|
|
22
|
+
import "./chunk-SZKAZ2VN.js";
|
|
23
|
+
import "./chunk-DKCCXMSE.js";
|
|
24
|
+
import "./chunk-U5UIUB6L.js";
|
|
25
|
+
import "./chunk-XCWLFZSM.js";
|
|
26
|
+
import "./chunk-GMVDCQVW.js";
|
|
27
|
+
import "./chunk-JQYZX56A.js";
|
|
28
|
+
import "./chunk-R6DONQKN.js";
|
|
29
|
+
import "./chunk-QH27MDJM.js";
|
|
30
|
+
import "./chunk-C2GFK4JP.js";
|
|
31
|
+
import "./chunk-R2CPYTSP.js";
|
|
32
|
+
import "./chunk-ZQFAX275.js";
|
|
33
|
+
import {
|
|
34
|
+
ZgError
|
|
35
|
+
} from "./chunk-FC3UOHOO.js";
|
|
36
|
+
import {
|
|
37
|
+
redactSecrets
|
|
38
|
+
} from "./chunk-WUF3TVAE.js";
|
|
39
|
+
|
|
40
|
+
// src/cli/commands/advanced.ts
|
|
41
|
+
async function withCancel(fn) {
|
|
42
|
+
const ac = new AbortController();
|
|
43
|
+
const onSigint = () => ac.abort();
|
|
44
|
+
process.once("SIGINT", onSigint);
|
|
45
|
+
try {
|
|
46
|
+
return await fn(ac.signal);
|
|
47
|
+
} finally {
|
|
48
|
+
process.removeListener("SIGINT", onSigint);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function readStdin(ctx) {
|
|
52
|
+
const input = ctx.io.input;
|
|
53
|
+
if (input.isTTY) return "";
|
|
54
|
+
const chunks = [];
|
|
55
|
+
let size = 0;
|
|
56
|
+
for await (const c of input) {
|
|
57
|
+
const b = Buffer.isBuffer(c) ? c : Buffer.from(String(c));
|
|
58
|
+
size += b.length;
|
|
59
|
+
if (size > 2e6) throw new ZgError("The piped text is larger than 2 MB; pipe only the failing part (for example | tail -n 300).");
|
|
60
|
+
chunks.push(b);
|
|
61
|
+
}
|
|
62
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
63
|
+
}
|
|
64
|
+
function registerAdvanced(program, ctx) {
|
|
65
|
+
const say = (t) => ctx.stdout(redactSecrets(t));
|
|
66
|
+
const open = () => openAdvanced(ctx);
|
|
67
|
+
const offerApply = async (env, p, yes, apply) => {
|
|
68
|
+
if (!apply) {
|
|
69
|
+
say("\nPreview only. Add --apply to write these changes (you will be asked to confirm).");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const ok = await confirm(ctx, `Apply these changes (${p.set.changes.length} file${p.set.changes.length === 1 ? "" : "s"})?`, yes);
|
|
73
|
+
if (!ok) {
|
|
74
|
+
env.svc.discard(p.id);
|
|
75
|
+
say("Nothing was changed.");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
say(await advGuard(() => env.svc.apply(p.id, { confirmDelete: p.set.needsDeleteConfirmation && yes })));
|
|
79
|
+
};
|
|
80
|
+
program.command("analyze").description("Understand the project: structure, languages, entry points, dependencies, a file's symbols and imports").option("--file <path>", "analyze one file").option("--architecture", "architecture summary (the default)").option("--dependencies", "package managers, manifests, lockfiles, duplicates, unused packages").action(async (o) => {
|
|
81
|
+
const env = await open();
|
|
82
|
+
say(await advGuard(() => withCancel((signal) => env.svc.analyze({ ...o.file ? { file: o.file } : {}, ...o.architecture ? { architecture: true } : {}, ...o.dependencies ? { dependencies: true } : {}, signal }))));
|
|
83
|
+
});
|
|
84
|
+
program.command("search [query...]").description("Search the project by keyword or symbol name (text index, not semantic search)").option("--symbol <name>", "find a function/class/type by name").option("--limit <n>", "maximum results", (v) => Number(v)).action(async (query, o) => {
|
|
85
|
+
const q = o.symbol ?? query.join(" ");
|
|
86
|
+
if (!q.trim()) throw new ZgError("Say what to search for.", { hint: "zg search <words> or zg search --symbol <name>" });
|
|
87
|
+
const env = await open();
|
|
88
|
+
say(await advGuard(() => withCancel((signal) => env.svc.search(q, { ...o.symbol ? { symbol: true } : {}, ...o.limit && o.limit > 0 ? { limit: Math.min(o.limit, 200) } : {}, signal }))));
|
|
89
|
+
});
|
|
90
|
+
program.command("index").description("Build, update or clear zg's local code index (optional; never stores file contents or secrets)").option("--rebuild", "throw the old index away and build again").option("--clear", "delete the saved index").option("--status", "show what the index contains").action(async (o) => {
|
|
91
|
+
const env = await open();
|
|
92
|
+
say(await advGuard(() => withCancel((signal) => env.svc.index({ ...o, signal }))));
|
|
93
|
+
});
|
|
94
|
+
program.command("explain [file]").description("Explain a file or symbol using the configured AI provider (sends that file's text to the provider)").option("--symbol <name>", "explain a function/class by name").action(async (file, o) => {
|
|
95
|
+
const env = await open();
|
|
96
|
+
say(await advGuard(() => withCancel((signal) => env.svc.explain({ ...file ? { file } : {}, ...o.symbol ? { symbol: o.symbol } : {} }, signal))));
|
|
97
|
+
});
|
|
98
|
+
program.command("debug").description("Analyze a build/compile/test/runtime failure: pipe the output in, or use --file").option("--file <path>", "a saved log in the project, or a source file to check with a language server").action(async (o) => {
|
|
99
|
+
const env = await open();
|
|
100
|
+
const text = o.file ? "" : await readStdin(ctx);
|
|
101
|
+
say(await advGuard(() => withCancel((signal) => env.svc.debug({ ...o.file ? { file: o.file } : {}, text, signal }))));
|
|
102
|
+
await env.svc.lsp.stopAll();
|
|
103
|
+
});
|
|
104
|
+
program.command("review [files...]").description("Review changes (--staged or --diff) or named files with zg's rules; shows severity, line, evidence and confidence").option("--staged", "review staged changes").option("--diff", "review uncommitted changes (the default without files)").option("--ai", "also ask the AI provider (its findings are marked unverified)").action(async (files, o) => {
|
|
105
|
+
const env = await open();
|
|
106
|
+
const r = await advGuard(() => withCancel((signal) => env.svc.review({ ...files.length ? { files } : {}, ...o.staged ? { staged: true } : { diff: true }, ...o.ai ? { ai: true } : {}, signal })));
|
|
107
|
+
say(r.text);
|
|
108
|
+
});
|
|
109
|
+
program.command("refactor").description("Refactoring suggestions with evidence, or a previewed rename (--symbol <name> --to <new>)").option("--symbol <name>", "symbol to rename").option("--to <name>", "new name (previews every edit; nothing changes without --apply and confirmation)").option("--path <path>", "limit suggestions to a file or folder").option("--ai", "ask the AI provider for suggestions on --path <file>").option("--apply", "apply the previewed change after confirmation").option("--yes", "do not ask").action(async (o) => {
|
|
110
|
+
const env = await open();
|
|
111
|
+
const r = await advGuard(() => withCancel((signal) => env.svc.refactor({ ...o.symbol ? { symbol: o.symbol } : {}, ...o.to ? { to: o.to } : {}, ...o.path ? { path: o.path } : {}, ...o.ai ? { ai: true } : {}, signal })));
|
|
112
|
+
say(r.text.replace(/\nNothing is changed yet\. Approve with:.*$/s, ""));
|
|
113
|
+
if (r.pending) await offerApply(env, r.pending, o.yes === true, o.apply === true);
|
|
114
|
+
await env.svc.lsp.stopAll();
|
|
115
|
+
});
|
|
116
|
+
const test = program.command("test").description("Test assistance: discover tests, find gaps, draft new tests (zg never runs them itself)");
|
|
117
|
+
test.command("discover").description("Frameworks, test files, case counts").action(async () => say(await advGuard(async () => (await open()).svc.testDiscover())));
|
|
118
|
+
test.command("analyze").description("Also list source files with no matching test, and coverage if a report exists").action(async () => say(await advGuard(async () => (await open()).svc.testDiscover({ analyze: true }))));
|
|
119
|
+
test.command("generate <file>").description("Draft a test file with the AI provider and preview it (writes only with --apply and confirmation)").option("--out <path>", "where to save the test file").option("--apply", "create the file after confirmation").option("--yes", "do not ask").action(async (file, o) => {
|
|
120
|
+
const env = await open();
|
|
121
|
+
const r = await advGuard(() => withCancel((signal) => env.svc.testGenerate(file, { ...o.out ? { out: o.out } : {}, signal })));
|
|
122
|
+
say(r.text.replace(/\nNothing is created yet\. Approve with:.*$/s, ""));
|
|
123
|
+
if (r.pending) {
|
|
124
|
+
await offerApply(env, r.pending, o.yes === true, o.apply === true);
|
|
125
|
+
if (o.apply) say("Run the tests yourself, or in chat with /exec, to see real results. zg has not run this file.");
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const docs = program.command("docs").description("Documentation drafts built from your code (always previewed; written only with --apply)");
|
|
129
|
+
docs.command("generate [kind]").description("kind: readme (default), architecture, onboarding, config, module, api").option("--path <folder>", "folder for module/api docs").option("--out <path>", "where to save").option("--apply", "write the file after confirmation").option("--yes", "do not ask").action(async (kind, o) => {
|
|
130
|
+
const k = kind ?? "readme";
|
|
131
|
+
if (!["readme", "architecture", "onboarding", "config", "module", "api"].includes(k)) throw new ZgError(`Unknown document kind "${kind}".`, { hint: "Use one of: readme, architecture, onboarding, config, module, api." });
|
|
132
|
+
const env = await open();
|
|
133
|
+
const r = await advGuard(() => withCancel((signal) => env.svc.docsGenerate(k, { ...o.path ? { target: o.path } : {}, ...o.out ? { out: o.out } : {}, signal })));
|
|
134
|
+
say(r.text.replace(/\nNothing is written yet\. Approve with:.*$/s, ""));
|
|
135
|
+
if (r.pending) await offerApply(env, r.pending, o.yes === true, o.apply === true);
|
|
136
|
+
});
|
|
137
|
+
docs.command("explain <file>").description("Explain a file in plain language (same as: zg explain <file>)").action(async (file) => {
|
|
138
|
+
const env = await open();
|
|
139
|
+
say(await advGuard(() => withCancel((signal) => env.svc.explain({ file }, signal))));
|
|
140
|
+
});
|
|
141
|
+
const lsp = program.command("lsp").description("Language servers: see what is installed, set your own command (zg never installs one)");
|
|
142
|
+
const status = async () => {
|
|
143
|
+
const env = await open();
|
|
144
|
+
say(await advGuard(() => env.svc.lspStatus()));
|
|
145
|
+
};
|
|
146
|
+
lsp.action(status);
|
|
147
|
+
lsp.command("status").description("Which language servers are available, and whether they are turned on").action(status);
|
|
148
|
+
lsp.command("servers").description("Same as status, for every language zg knows").action(async () => {
|
|
149
|
+
const env = await open();
|
|
150
|
+
say(await advGuard(() => env.svc.lspStatus()));
|
|
151
|
+
});
|
|
152
|
+
lsp.command("configure <language> <command> [args...]").description("Use your own language server for a language (saved in your zg config; nothing is started or installed)").allowUnknownOption().action(async (language, command, args) => {
|
|
153
|
+
if (!/^[a-z][a-z0-9+_-]{0,29}$/.test(language)) throw new ZgError(`"${language}" is not a language name.`, { hint: "Use the language id shown by `zg lsp status`, for example typescript or python." });
|
|
154
|
+
if (/[\s;&|<>`$]/.test(command)) throw new ZgError("The command must be a single program name (no spaces or shell characters). Put its arguments after it.", { hint: "zg lsp configure python pylsp" });
|
|
155
|
+
const { config } = await ctx.manager.load();
|
|
156
|
+
const next = { ...config, advanced: { ...config.advanced, lsp: { ...config.advanced.lsp, servers: { ...config.advanced.lsp.servers, [language]: { command, args } } } } };
|
|
157
|
+
await ctx.manager.save(next);
|
|
158
|
+
say(`Saved: ${language} will use "${command}${args.length ? ` ${args.join(" ")}` : ""}" (found on your PATH when needed; zg does not check it now).${config.advanced.lsp.enabled ? "" : "\nLanguage servers are OFF: turn on with zg config set advanced.lsp.enabled true"}`);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
registerAdvanced,
|
|
163
|
+
withCancel
|
|
164
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
extGuard,
|
|
4
|
+
openExtEnv,
|
|
5
|
+
requireOn
|
|
6
|
+
} from "./chunk-RIX4S3J7.js";
|
|
7
|
+
import "./chunk-LOSXCWHU.js";
|
|
8
|
+
import "./chunk-WANZOLI5.js";
|
|
9
|
+
import "./chunk-JUZP5SXD.js";
|
|
10
|
+
import "./chunk-4ITJY25Z.js";
|
|
11
|
+
import "./chunk-CDC2K2KP.js";
|
|
12
|
+
import "./chunk-YJEUXO5I.js";
|
|
13
|
+
import "./chunk-KGA7VWQG.js";
|
|
14
|
+
import "./chunk-2ZYSAYMJ.js";
|
|
15
|
+
import {
|
|
16
|
+
confirm,
|
|
17
|
+
promptLine
|
|
18
|
+
} from "./chunk-YR6RCC6Y.js";
|
|
19
|
+
import "./chunk-SZKAZ2VN.js";
|
|
20
|
+
import "./chunk-DKCCXMSE.js";
|
|
21
|
+
import "./chunk-U5UIUB6L.js";
|
|
22
|
+
import "./chunk-XCWLFZSM.js";
|
|
23
|
+
import "./chunk-GMVDCQVW.js";
|
|
24
|
+
import "./chunk-JQYZX56A.js";
|
|
25
|
+
import "./chunk-R6DONQKN.js";
|
|
26
|
+
import "./chunk-QH27MDJM.js";
|
|
27
|
+
import "./chunk-R2CPYTSP.js";
|
|
28
|
+
import "./chunk-ZQFAX275.js";
|
|
29
|
+
import {
|
|
30
|
+
ZgError
|
|
31
|
+
} from "./chunk-FC3UOHOO.js";
|
|
32
|
+
import {
|
|
33
|
+
redactSecrets
|
|
34
|
+
} from "./chunk-WUF3TVAE.js";
|
|
35
|
+
|
|
36
|
+
// src/cli/commands/agents.ts
|
|
37
|
+
var collect = (v, prev = []) => [...prev, v];
|
|
38
|
+
var row = (v) => `${v.id.padEnd(24)} ${v.scope.padEnd(9)} ${v.enabled ? "ready " : "disabled"} fs:${v.permissions.filesystem} term:${v.permissions.terminal} git:${v.permissions.git} mcp:${v.permissions.mcp} ${v.description}`;
|
|
39
|
+
var runLine = (r) => `${r.id} ${r.agentId} ${r.status}${r.progress ? ` ${r.progress.completed}/${r.progress.total}` : ""}`;
|
|
40
|
+
function withFlags(cmd) {
|
|
41
|
+
return cmd.option("--name <text>", "display name").option("--description <text>", "what the agent is for").option("--instructions <text>", "the agent's role and rules (guidance only: it cannot grant itself permissions)").option("--provider <id>", "provider this agent prefers (or inherit); it must already be set up").option("--model <name>", "model for that provider (or inherit)").option("--filesystem <none|read|edit>", "file access (edits still need your approval)").option("--terminal <deny|ask>", "commands (each one still asks you)").option("--git <none|read|change>", "Git access (changes still ask you)").option("--mcp <none|ask>", "external MCP and plugin tools (each call still asks you)").option("--skill <id>", "skill that guides it (repeatable)", collect).option("--tool <pattern>", "external tool it may ask for: server.tool, server.*, plugin.tool (repeatable)", collect).option("--max-steps <n>", "step limit (can only be stricter than your global setting)").option("--timeout <seconds>", "time limit for one run").option("--format <concise|detailed>", "answer style");
|
|
42
|
+
}
|
|
43
|
+
function patchFrom(o) {
|
|
44
|
+
const p = {};
|
|
45
|
+
const perms = {};
|
|
46
|
+
if (o.name) p.name = o.name;
|
|
47
|
+
if (o.description) p.description = o.description;
|
|
48
|
+
if (o.instructions) p.instructions = o.instructions;
|
|
49
|
+
if (o.skill) p.skills = o.skill;
|
|
50
|
+
if (o.tool) p.tools = o.tool;
|
|
51
|
+
if (o.provider || o.model) p.model = { ...o.provider ? { provider: o.provider } : {}, ...o.model ? { name: o.model } : {} };
|
|
52
|
+
if (o.filesystem) perms.filesystem = o.filesystem;
|
|
53
|
+
if (o.terminal) perms.terminal = o.terminal;
|
|
54
|
+
if (o.git) perms.git = o.git;
|
|
55
|
+
if (o.mcp) perms.mcp = o.mcp;
|
|
56
|
+
if (Object.keys(perms).length) p.permissions = perms;
|
|
57
|
+
const limits = {};
|
|
58
|
+
const int = (v, what) => {
|
|
59
|
+
const n = Number(v);
|
|
60
|
+
if (!Number.isInteger(n)) throw new ZgError(`${what} must be a whole number.`);
|
|
61
|
+
return n;
|
|
62
|
+
};
|
|
63
|
+
if (o.maxSteps) limits.maxSteps = int(o.maxSteps, "--max-steps");
|
|
64
|
+
if (o.timeout) limits.timeoutSeconds = int(o.timeout, "--timeout");
|
|
65
|
+
if (Object.keys(limits).length) p.limits = limits;
|
|
66
|
+
if (o.format) p.output = { format: o.format };
|
|
67
|
+
return p;
|
|
68
|
+
}
|
|
69
|
+
function registerAgents(program, ctx) {
|
|
70
|
+
const say = (t) => ctx.stdout(redactSecrets(t));
|
|
71
|
+
const cmd = program.command("agents").description("Custom agents: named roles with their own instructions, skills and permissions (they never grant themselves more)");
|
|
72
|
+
const list = async () => {
|
|
73
|
+
const env = await openExtEnv(ctx);
|
|
74
|
+
if (!env.config.extensions.agents.enabled) say("Agents are off (turn on: zg config set extensions.agents.enabled true)");
|
|
75
|
+
for (const v of await env.svc.agents.list()) say(row(v));
|
|
76
|
+
for (const b of await env.svc.agents.broken()) say(`! ${b.id ?? b.file} (${b.scope}): ${b.message}`);
|
|
77
|
+
say("\nUse one in chat: /agent use <id>. Delegate a task: /agent run <id> <request>");
|
|
78
|
+
};
|
|
79
|
+
cmd.action(list);
|
|
80
|
+
cmd.command("list").description("List agents and what each may do").action(list);
|
|
81
|
+
cmd.command("show <id>").description("Show an agent's full configuration").action(async (id) => {
|
|
82
|
+
const env = await openExtEnv(ctx);
|
|
83
|
+
const { view: v, record } = await extGuard(() => env.svc.agents.show(id));
|
|
84
|
+
const d = record.def;
|
|
85
|
+
say([`${d.name} (${d.id}) ${d.version} [${v.scope}] ${v.enabled ? "ready" : "disabled"}`, d.description, `Provider: ${d.model.provider} Model: ${d.model.name}`, `Permissions: filesystem ${d.permissions.filesystem}, terminal ${d.permissions.terminal}, git ${d.permissions.git}, mcp ${d.permissions.mcp}`, `Capabilities it can actually use: ${v.capabilities.join(", ") || "none (reasoning only)"}`, `Skills: ${d.skills.join(", ") || "none"} External tools: ${d.tools.join(", ") || "none"}`, `Limits: steps ${d.limits.maxSteps ?? "global"}, timeout ${d.limits.timeoutSeconds ?? "global"}s`, ...v.problems.map((p) => `! ${p}`), ...v.warnings.map((w) => `! ${w}`), "", d.instructions].join("\n"));
|
|
86
|
+
});
|
|
87
|
+
withFlags(cmd.command("create [id]").description("Create an agent. Give options, or you are asked. New agents are read-only unless you say otherwise.")).option("--project", "keep it with the current project only").action(async (idArg, o) => {
|
|
88
|
+
const env = await openExtEnv(ctx);
|
|
89
|
+
requireOn(env, "agents");
|
|
90
|
+
const id = idArg ?? await promptLine(ctx, "Agent id (lowercase, dashes): ");
|
|
91
|
+
if (!id) throw new ZgError("An agent needs an id.", { hint: "zg agents create <id> --description ... --instructions ..." });
|
|
92
|
+
const description = o.description ?? await promptLine(ctx, "What is it for (one line): ");
|
|
93
|
+
const instructions = o.instructions ?? await promptLine(ctx, "Its role and rules (one line): ");
|
|
94
|
+
if (!description || !instructions) throw new ZgError("--description and --instructions are required when there is no terminal to ask in.");
|
|
95
|
+
const patch = patchFrom(o);
|
|
96
|
+
const rec = await extGuard(
|
|
97
|
+
() => env.svc.agents.create(
|
|
98
|
+
{
|
|
99
|
+
id,
|
|
100
|
+
name: o.name ?? id.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" "),
|
|
101
|
+
description,
|
|
102
|
+
instructions,
|
|
103
|
+
skills: patch.skills ?? [],
|
|
104
|
+
tools: patch.tools ?? [],
|
|
105
|
+
model: { provider: o.provider ?? "inherit", name: o.model ?? "inherit" },
|
|
106
|
+
permissions: { filesystem: "read", terminal: "deny", git: "none", mcp: "none", ...patch.permissions ?? {} },
|
|
107
|
+
limits: patch.limits ?? {},
|
|
108
|
+
output: patch.output ?? {}
|
|
109
|
+
},
|
|
110
|
+
o.project ? "project" : "user"
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
say(`Created agent ${rec.id} (${rec.scope}) at ${rec.file}`);
|
|
114
|
+
say(`Permissions: filesystem ${rec.def.permissions.filesystem}, terminal ${rec.def.permissions.terminal}, git ${rec.def.permissions.git}, mcp ${rec.def.permissions.mcp}. Approvals in chat still apply to everything it proposes.`);
|
|
115
|
+
});
|
|
116
|
+
withFlags(cmd.command("edit <id>").description("Change an agent (user and project agents only; a backup is kept)")).action(async (id, o) => {
|
|
117
|
+
const env = await openExtEnv(ctx);
|
|
118
|
+
const patch = patchFrom(o);
|
|
119
|
+
if (Object.keys(patch).length === 0) throw new ZgError("Nothing to change.", { hint: "Pass at least one option, for example --filesystem edit" });
|
|
120
|
+
await extGuard(() => env.svc.agents.update(id, patch));
|
|
121
|
+
say(`Updated "${id}": ${Object.keys(patch).join(", ")}.`);
|
|
122
|
+
});
|
|
123
|
+
cmd.command("customize <id>").description("Copy a built-in agent into your own agents so you can edit it").action(async (id) => {
|
|
124
|
+
const env = await openExtEnv(ctx);
|
|
125
|
+
const rec = await extGuard(() => env.svc.agents.customize(id));
|
|
126
|
+
say(`Copied to ${rec.file}. Change it with: zg agents edit ${id} ...`);
|
|
127
|
+
});
|
|
128
|
+
cmd.command("run <id> <request...>").description("Plan a task with an agent, show the plan, and (after you approve) run it. From the CLI the agent has no file or command tools; use /agent run in chat for those.").option("--yes", "approve the plan without asking").action(async (id, request, o) => {
|
|
129
|
+
const env = await openExtEnv(ctx);
|
|
130
|
+
requireOn(env, "agents");
|
|
131
|
+
if (!env.backend) throw new ZgError("No provider is ready to run an agent.", { hint: "Set one up: zg provider (then zg auth status)" });
|
|
132
|
+
const a = env.svc.agents;
|
|
133
|
+
const ac = new AbortController();
|
|
134
|
+
const onInt = () => {
|
|
135
|
+
ac.abort();
|
|
136
|
+
a.cancelAll();
|
|
137
|
+
};
|
|
138
|
+
process.once("SIGINT", onInt);
|
|
139
|
+
try {
|
|
140
|
+
const s = await extGuard(() => a.start(id, request.join(" "), { signal: ac.signal }));
|
|
141
|
+
const { summary, task } = a.status(s.id);
|
|
142
|
+
say(`Run ${summary.id}: ${summary.agentName} is ${summary.status}.${summary.note ? ` ${summary.note}` : ""}`);
|
|
143
|
+
for (const st of task?.steps ?? []) say(` ${st.id} ${st.title}`);
|
|
144
|
+
if (summary.status !== "awaiting-approval") return void (process.exitCode = summary.status === "failed" ? 1 : 0);
|
|
145
|
+
if (!await confirm(ctx, "Approve this plan?", o.yes === true)) {
|
|
146
|
+
a.reject(s.id);
|
|
147
|
+
return say("Rejected. Nothing was changed.");
|
|
148
|
+
}
|
|
149
|
+
const done = await extGuard(() => a.approve(s.id, { signal: ac.signal }));
|
|
150
|
+
say(runLine(done));
|
|
151
|
+
say(a.result(s.id));
|
|
152
|
+
if (done.status === "failed" || done.status === "timed-out") process.exitCode = 1;
|
|
153
|
+
} finally {
|
|
154
|
+
process.off("SIGINT", onInt);
|
|
155
|
+
await env.svc.shutdown();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
for (const on of [true, false]) {
|
|
159
|
+
cmd.command(`${on ? "enable" : "disable"} <id>`).description(on ? "Make an agent selectable (project agents start disabled)" : "Stop an agent from being selected or run").action(async (id) => {
|
|
160
|
+
const env = await openExtEnv(ctx);
|
|
161
|
+
const v = await extGuard(() => env.svc.agents.setEnabled(id, on));
|
|
162
|
+
say(`Agent "${v.id}" is ${v.enabled ? "enabled" : "disabled"}.`);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
cmd.command("remove <id>").description("Delete a user or project agent (a backup is kept)").option("--yes", "do not ask").action(async (id, o) => {
|
|
166
|
+
const env = await openExtEnv(ctx);
|
|
167
|
+
await extGuard(() => env.svc.agents.show(id));
|
|
168
|
+
if (!await confirm(ctx, `Delete agent "${id}"?`, o.yes === true)) return say("Cancelled. Nothing was removed.");
|
|
169
|
+
await extGuard(() => env.svc.agents.remove(id));
|
|
170
|
+
say(`Removed "${id}".`);
|
|
171
|
+
});
|
|
172
|
+
cmd.command("doctor").description("Check agent definitions, their skills and providers").option("--json", "machine-readable output").action(async (o) => {
|
|
173
|
+
const env = await openExtEnv(ctx);
|
|
174
|
+
const r = await env.svc.agents.doctor();
|
|
175
|
+
say(o.json ? JSON.stringify(r, null, 2) : r.lines.join("\n"));
|
|
176
|
+
if (!r.ok) process.exitCode = 1;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
registerAgents
|
|
181
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
launchChat,
|
|
4
|
+
registerChat
|
|
5
|
+
} from "./chunk-AY36KJTH.js";
|
|
6
|
+
import "./chunk-JU5PGDOD.js";
|
|
7
|
+
import "./chunk-FIASMDLX.js";
|
|
8
|
+
import "./chunk-VS375NYD.js";
|
|
9
|
+
import "./chunk-VBG7T7XY.js";
|
|
10
|
+
import "./chunk-7TACFVY2.js";
|
|
11
|
+
import "./chunk-NVC433AX.js";
|
|
12
|
+
import "./chunk-BJABQO7S.js";
|
|
13
|
+
import "./chunk-QUC5URWQ.js";
|
|
14
|
+
import "./chunk-T6DDNE3W.js";
|
|
15
|
+
import "./chunk-2OH5KHWO.js";
|
|
16
|
+
import "./chunk-U4URD6TU.js";
|
|
17
|
+
import "./chunk-R5KQACGR.js";
|
|
18
|
+
import "./chunk-L7VNR5LM.js";
|
|
19
|
+
import "./chunk-VCCMJIAG.js";
|
|
20
|
+
import "./chunk-RIX4S3J7.js";
|
|
21
|
+
import "./chunk-LOSXCWHU.js";
|
|
22
|
+
import "./chunk-WANZOLI5.js";
|
|
23
|
+
import "./chunk-JUZP5SXD.js";
|
|
24
|
+
import "./chunk-4ITJY25Z.js";
|
|
25
|
+
import "./chunk-CDC2K2KP.js";
|
|
26
|
+
import "./chunk-YJEUXO5I.js";
|
|
27
|
+
import "./chunk-KGA7VWQG.js";
|
|
28
|
+
import "./chunk-2ZYSAYMJ.js";
|
|
29
|
+
import "./chunk-YR6RCC6Y.js";
|
|
30
|
+
import "./chunk-SZKAZ2VN.js";
|
|
31
|
+
import "./chunk-DKCCXMSE.js";
|
|
32
|
+
import "./chunk-U5UIUB6L.js";
|
|
33
|
+
import "./chunk-XCWLFZSM.js";
|
|
34
|
+
import "./chunk-GMVDCQVW.js";
|
|
35
|
+
import "./chunk-JQYZX56A.js";
|
|
36
|
+
import "./chunk-R6DONQKN.js";
|
|
37
|
+
import "./chunk-QH27MDJM.js";
|
|
38
|
+
import "./chunk-4BZ4IXTO.js";
|
|
39
|
+
import "./chunk-C2GFK4JP.js";
|
|
40
|
+
import "./chunk-R2CPYTSP.js";
|
|
41
|
+
import "./chunk-ZQFAX275.js";
|
|
42
|
+
import "./chunk-FC3UOHOO.js";
|
|
43
|
+
import "./chunk-WUF3TVAE.js";
|
|
44
|
+
export {
|
|
45
|
+
launchChat,
|
|
46
|
+
registerChat
|
|
47
|
+
};
|