agent-whisker 0.1.0 → 0.2.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/README.md +12 -3
- package/README.zh-CN.md +12 -3
- package/package.json +3 -2
- package/packages/antigravity-plugin/package.json +1 -1
- package/packages/antigravity-plugin/plugin.json +1 -1
- package/packages/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/packages/claude-plugin/.codex-plugin/plugin.json +1 -1
- package/packages/claude-plugin/README.md +11 -1
- package/packages/claude-plugin/README.zh-CN.md +4 -1
- package/packages/claude-plugin/bin/taskstate +145 -4
- package/packages/claude-plugin/hooks/codex.json +8 -8
- package/packages/claude-plugin/package.json +1 -1
- package/packages/cli/README.md +76 -3
- package/packages/cli/README.zh-CN.md +76 -3
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/command.js +20 -3
- package/packages/cli/src/commands/catalog.js +26 -7
- package/packages/cli/src/commands/doctor.js +31 -27
- package/packages/cli/src/commands/exclude.js +156 -0
- package/packages/cli/src/commands/extract.js +4 -2
- package/packages/cli/src/commands/index-command.js +1 -1
- package/packages/cli/src/commands/index.js +4 -0
- package/packages/cli/src/commands/install.js +12 -1
- package/packages/cli/src/commands/nudge.js +39 -37
- package/packages/cli/src/commands/read.js +2 -1
- package/packages/cli/src/commands/search.js +33 -3
- package/packages/cli/src/commands/sessions.js +20 -12
- package/packages/cli/src/commands/status.js +6 -3
- package/packages/cli/src/commands/tui.js +62 -0
- package/packages/cli/src/commands/version.js +4 -4
- package/packages/cli/src/exclusion.js +88 -0
- package/packages/cli/src/install/codex-plugin.js +6 -5
- package/packages/cli/src/install/external.js +48 -37
- package/packages/cli/src/install/handlers.js +4 -3
- package/packages/cli/src/install/mcp.js +3 -3
- package/packages/cli/src/install/steps.js +43 -15
- package/packages/cli/src/install/wrapper.js +28 -5
- package/packages/cli/src/main.js +9 -12
- package/packages/cli/src/node-version.js +25 -0
- package/packages/cli/src/run.js +25 -5
- package/packages/cli/src/tui/app.js +1430 -0
- package/packages/cli/src/tui/data/call.js +83 -0
- package/packages/cli/src/tui/data/poll.js +24 -0
- package/packages/cli/src/tui/glyphs.js +93 -0
- package/packages/cli/src/tui/i18n.js +342 -0
- package/packages/cli/src/tui/model.js +251 -0
- package/packages/cli/src/tui/pages/common.js +71 -0
- package/packages/cli/src/tui/pages/library.js +154 -0
- package/packages/cli/src/tui/pages/sessions.js +96 -0
- package/packages/cli/src/tui/pages/system.js +124 -0
- package/packages/cli/src/tui/pages/tasks.js +297 -0
- package/packages/cli/src/tui/run.js +216 -0
- package/packages/cli/src/tui/term/keys.js +152 -0
- package/packages/cli/src/tui/term/screen.js +88 -0
- package/packages/cli/src/tui/term/term.js +157 -0
- package/packages/cli/src/tui/term/width.js +290 -0
- package/packages/cli/src/tui/ui/widgets.js +247 -0
- package/packages/core/README.md +1 -1
- package/packages/core/README.zh-CN.md +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/src/catalog.js +13 -1
- package/packages/core/src/clairic.js +1 -1
- package/packages/core/src/convert.js +1 -1
- package/packages/core/src/db.js +6 -1
- package/packages/core/src/host.js +104 -0
- package/packages/core/src/index.js +2 -2
- package/packages/core/src/library-read.js +12 -8
- package/packages/core/src/nudge.js +34 -1
- package/packages/core/src/schema.js +17 -0
- package/packages/core/src/sessions-read.js +23 -11
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/herdr-plugin/herdr-plugin.toml +1 -1
- package/packages/herdr-plugin/package.json +1 -1
- package/packages/mcp/README.md +5 -5
- package/packages/mcp/README.zh-CN.md +5 -5
- package/packages/mcp/package.json +1 -1
- package/packages/pi-extension/README.md +1 -1
- package/packages/pi-extension/README.zh-CN.md +1 -1
- package/packages/pi-extension/package.json +1 -1
- package/packages/pi-extension/src/extension.ts +3 -3
- package/packages/service/package.json +1 -1
- package/packages/service/src/index.js +1 -1
- package/packages/service/src/runtime.js +4 -0
package/packages/cli/README.md
CHANGED
|
@@ -7,15 +7,20 @@ The `agent-whisker` CLI manages the local library and session index. See the [qu
|
|
|
7
7
|
| Task | Commands |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| Set up and diagnose | `init`, `install` (macOS, Windows), `doctor`, `status`, `version` |
|
|
10
|
-
| Manage the library | `project`, `ingest`, `document remove\|restore`, `index` |
|
|
10
|
+
| Manage the library | `project`, `ingest`, `exclude add\|remove`, `document remove\|restore`, `index` |
|
|
11
11
|
| Look up documents | `catalog`, `search`, `grep`, `read` |
|
|
12
12
|
| Work with session history | `sessions status\|sync\|search\|grep\|read\|wait\|forget` |
|
|
13
13
|
| Run integrations | `mcp`, `service`, `nudge`, `hook` |
|
|
14
|
+
| Browse it all in a terminal | `tui` ([below](#terminal-interface)) |
|
|
14
15
|
|
|
15
16
|
`hook claude` is what the Claude Code plugin's hooks run: it reads the hook's JSON on stdin and prints, at session start and at a subagent's start, a pointer line on the sessions recorded in the directory, or nothing; at session start, when the data directory is not initialised, a notice the person sees and the model does not; at a prompt, one line when earlier main sessions hold two of the prompt's rare words (in Chinese or Japanese, pairs of adjacent characters) together, naming them, the count, the latest date and the search for them, or nothing; `AGENT_WHISKER_PROMPT_POINTER` turns that line off when it is `off` and is its budget when it is a whole number of milliseconds from 50 to 5000 (else 300) ([plugin guide](../claude-plugin/README.md#parts)). `hook codex`, `hook pi` and `hook antigravity` answer those programs' session start in their own form: for Codex and pi what agent-whisker holds and when to call it, and the pointer line when there is one; for Antigravity the pointer line only; `hook dsh`, which dsh's plugin runs at a root session's start, prints the pointer line alone, as plain text, counting the sessions of the directory and those below it, since dsh's model has the server's instructions in full; `hook codex` and `hook antigravity` give `hook claude`'s notice for a data directory that is not initialised. Without a session index (before the first session sync) or with no earlier session in the directory, `hook codex` and `hook pi` print the sentences alone; without a data directory `hook pi` prints nothing, and for a store that does not open (newer than the code, held by maintenance) each prints nothing. `sessions wait` is for an agent that waits for another session: run as a background command, it ends when that session has new entries or has stopped changing, or a new one begins in the directory, with the call that reads it ([below](#waiting-for-another-session)).
|
|
16
17
|
|
|
17
18
|
Run `node packages/cli/src/main.ts` from the repository if you do not have the launcher. Use `--json` for machine-readable results and `--cwd <directory>` to select the working directory. Exit codes: 0 for success, 1 for failure, 2 for usage errors, and 3 when the store is not initialized. After `error: NotAStore:` the line `run: agent-whisker init` follows only where `init` would create the store, that is, where the data directory does not exist or is an empty directory; for anything else there (a store of an earlier format, a directory holding other files) the error's own message is the answer. `service install`, `service ensure`, `doctor`'s `store` row and the notice at a session's start follow the same rule.
|
|
18
19
|
|
|
20
|
+
`search` and `sessions search` take one query per positional argument: up to 8 queries, each at most 1024 UTF-8 bytes. Quote multiple words to make one query, e.g. `agent-whisker search "audit risk"`.
|
|
21
|
+
|
|
22
|
+
`sessions search` defaults to user and assistant dialogue; use `--role all` to include tools. `sessions grep` searches retained entries, including tool calls and retained results. `sessions read --results` can also read unretained results from an unchanged source file.
|
|
23
|
+
|
|
19
24
|
## Installation and diagnostics
|
|
20
25
|
|
|
21
26
|
`init` creates the data directory and touches nothing outside it. The key store keeps only the reranker's key: macOS defaults to Keychain, other systems to no store (the key then comes from `AGENT_WHISKER_RERANK_KEY`); set `AGENT_WHISKER_KEYSTORE=file:/absolute/path/to/keys` for file storage; on POSIX, group or other permissions on the key directory or file cause refusal, and on Windows a key file whose access list names any account but yours. The store defaults to `~/.agent-whisker`; `AGENT_WHISKER_HOME` overrides it.
|
|
@@ -68,7 +73,7 @@ Run `agent-whisker index gc` to reclaim unused blob files under the exclusive ma
|
|
|
68
73
|
|
|
69
74
|
## The npm package
|
|
70
75
|
|
|
71
|
-
The whole tool is one npm package. `node scripts/package.ts pack <directory>` builds it from this checkout's tracked files and writes `agent-whisker-<version>.tgz` there: the CLI and the workspaces it depends on as JavaScript made by Node's own type stripper (Node refuses TypeScript under `node_modules`), bundled runtime dependencies (`jieba-wasm` and `yaml`), every folder `install` hands to the agent programs, and the guides, with no install script.
|
|
76
|
+
The whole tool is one npm package. `node scripts/package.ts pack <directory>` builds it from this checkout's tracked files and writes `agent-whisker-<version>.tgz` there: the CLI and the workspaces it depends on as JavaScript made by Node's own type stripper (Node refuses TypeScript under `node_modules`), bundled runtime dependencies (`jieba-wasm` and `yaml`), every folder `install` hands to the agent programs, and the guides, with no install script. Each `v*.*.*` tag publishes that package to npm as `agent-whisker`, starting with `0.1.0`. `npm install -g agent-whisker` installs the published package and `npm install -g <tarball>` a locally packed one (on Unix, if `npm prefix -g` is `~/.local`, npm's `~/.local/bin/agent-whisker` symlink occupies the launcher path `install` refuses to overwrite, so install under Node's default global prefix or another prefix before running `install --apply wrapper`), and then:
|
|
72
77
|
|
|
73
78
|
- `agent-whisker install --dry-run`, then `agent-whisker install --apply all`, set it up as from a checkout; every path they give an agent program lies in the installed package (`npm root -g` names its folder), and the launcher runs its `packages/cli/src/main.js`.
|
|
74
79
|
- To update, install the newer package the same way, then run `agent-whisker install --apply all`, which replaces the copies Codex, agy, dsh and the Herdr app keep and restarts the service, and restart the agent programs, whose MCP servers run the old code until then.
|
|
@@ -87,6 +92,10 @@ agent-whisker install --remove all
|
|
|
87
92
|
|
|
88
93
|
What stays: the data directory (`~/.agent-whisker`, or `AGENT_WHISKER_HOME`), the task state (`~/.local/state/agent-whisker-task`, or `AGENT_WHISKER_TASK_HOME` when it is an absolute path; a relative value is ignored, as `taskstate` ignores it), a saved rerank key in the key store, and the folders install made, emptied. The command's last lines give `rm -rf` for the two folders, and `npm rm -g agent-whisker` for a copy installed from npm; a checkout can be deleted.
|
|
89
94
|
|
|
95
|
+
## Linux
|
|
96
|
+
|
|
97
|
+
On Linux, `npm install -g agent-whisker` installs both `agent-whisker` and `taskstate`. Run `agent-whisker init`, then use `agent-whisker sessions sync` on demand or `agent-whisker service run` in the foreground. For startup at login, set a systemd `--user` unit’s `ExecStart` to the absolute executable path followed by `service run`. For manual MCP registration, use that path with `mcp`; Linux has no `install --apply`.
|
|
98
|
+
|
|
90
99
|
## Windows
|
|
91
100
|
|
|
92
101
|
On Windows (run on Windows 11 only so far), `init`, `install`, `doctor`, the background service and the MCP server work, from the repository or from the npm package, with the differences below; the rest of this guide applies as written.
|
|
@@ -164,10 +173,14 @@ Give one library document ID, or explicitly select local PDF, PNG, JPEG, WebP, M
|
|
|
164
173
|
|
|
165
174
|
A directory that holds an entry named `.agent-whisker-exclude` (an empty file will do; its content is never read) is kept out with everything below it. A directory walk does not enter it and reports `ingest: excluded directories skipped: <n>` on stderr (`excludedDirectories` in `--json`); an argument that is such a directory, or lies anywhere below one, also through a symbolic link, fails alone with `Excluded`. A document ingested before its folder was marked keeps its stored versions and is no longer refreshed; `document remove` takes it out of catalog, search and reads.
|
|
166
175
|
|
|
176
|
+
`exclude add <dir>` writes that marker, an empty `.agent-whisker-exclude`, into `<dir>` (one already there is left as it is), so that ingest skips the directory and everything below it from then on. With `--hide-ingested` it also hides the documents already ingested from there that are visible now, as `document remove` does (`document restore` brings each back), and reports how many it hid. `exclude remove <dir>` deletes the marker, and only when it is an empty regular file, so it never deletes a file of yours; without a marker it succeeds and reports `removed: false`. It takes no `--hide-ingested` and does not restore the documents an `exclude add --hide-ingested` hid. Both need an initialised data directory and take `--json`. Their errors: `NotFound` when `<dir>` does not exist, `NotADirectory` when it is not a directory, `NotAMarker` when the marker's name holds a directory or a symbolic link, and, for `remove`, `NotEmpty` when the marker has content.
|
|
177
|
+
|
|
167
178
|
The last line on stderr is `ingest: <n> added, <n> moved, <n> updated, <n> unchanged, <n> failed`. A file moved and edited between two ingests becomes a new document; `ingest --doc <doc-id> <file>` gives it to the old document instead, which must have no file on this machine other than this one. Ingest never restores a removed document: it prints `note: document <doc-id> is removed; restore it with: agent-whisker document restore <doc-id> --scope user` on stderr, and for a project document says to run it from inside the project with `--scope project`. The [architecture page](../../docs/architecture.md#storage-and-retrieval) says how ingest picks a file's document.
|
|
168
179
|
|
|
169
180
|
`document remove <doc-id>` takes a document out of `catalog`, `search` and `read`, for agents too: MCP `library_read` answers for it, by any version, as for a document that does not exist, and `read` fails with `NoSuchDocument`, naming the `document restore` command that brings it back. Older versions of a document that is not removed stay readable with `read --version`. Removal does not delete the extracted text or outline in `truth/blobs/`, the title or path in the journal, or the original file at its source.
|
|
170
181
|
|
|
182
|
+
`catalog --removed` lists, reading only, the documents of the current view that are hidden (by `document remove` or `exclude add --hide-ingested`), in the form and pages of `catalog` and with its tier limit, `personal`, and `no hidden documents` when there are none; with `--json` each document also has `excluded: true|false`, whether its file lies under a directory marked with `.agent-whisker-exclude`. `search --json` gives `avoided: { removed, excluded }` with its result: how many hidden documents lie within the search's view and filters (the current project's and the user scope, the tier limit `personal`, `--kind`, `--folder`), which the search could not see since a hidden document is not in the index; it does not say whether any of them would have matched. `excluded` counts those whose source file lies under a marked directory, `removed` the rest. The text output of `search` and the MCP tools are unchanged.
|
|
183
|
+
|
|
171
184
|
Without `--kind`, a document's kind is inferred from its source and its extracted text, with no model; `--kind` always wins. A `kind: note|paper|web|skill` line in front matter gives the kind; a file named `SKILL.md` is a `skill`; a front-matter `url:` or `source:` holding an HTTP(S) URL makes it `web`. It is a `paper` when an `Abstract` or `摘要` heading starts a line in its first 128,000 characters and there is one more sign: a `References`, `Bibliography` or `参考文献` heading in its last 64,000 characters, or an arXiv identifier or DOI in the first 128,000 (in a PDF, a letter-spaced `A b s t r a c t` counts only with an arXiv identifier or DOI). Everything else is a `note`. A document keeps the kind it was ingested with: `agent-whisker index reclassify-kinds` judges every `note` again, under the maintenance barrier and by appending ordinary events, and `agent-whisker index` then brings the index up to date.
|
|
172
185
|
|
|
173
186
|
## Projects
|
|
@@ -216,6 +229,66 @@ agent-whisker: the Codex session "Review the uploader's retry change" has 3 new
|
|
|
216
229
|
|
|
217
230
|
The exit status is 0 when what it waited for happened, 124 at the timeout (with a line saying so), 1 when it cannot tell (no such session, no session index, the session's file not found or gone, or for `--new` the service not running), 2 for a usage error and 3 without a data directory. `--json` prints one object instead, with `result` (`entries`, `quiet`, `new` or `timeout`). The wait never syncs, refreshes a session or nudges the service, and writes no file; a signal ends it at once.
|
|
218
231
|
|
|
232
|
+
## Terminal interface
|
|
233
|
+
|
|
234
|
+
`agent-whisker tui [--page tasks|library|sessions|agents|doctor]` opens one terminal screen over the task state, the library, the sessions, the agent programs' setup and `doctor`. It has no dependency beyond Node. It needs an interactive terminal, with standard input and standard output both a TTY and `TERM` other than `dumb`; elsewhere it exits with status 1 and `error: NotATerminal: …`, and writes nothing to standard output.
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
agent-whisker tui
|
|
238
|
+
agent-whisker tui --page library # start on another page
|
|
239
|
+
alias awt='agent-whisker tui' # a shell alias of your own; the CLI has none built in
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
What it shows comes from the CLI's own commands with `--json`, called in process, and from `taskstate … --json`. Each call opens the store and closes it again, so the interface holds no `store.lock` while it waits for a key, and `index repair` can run beside it. Every 2 seconds, or every 10 seconds after 5 minutes without a key, it only compares the store's file stamps, without a lock (`storeStamp` in [core](../core/README.md)), and loads again when they changed. Until all three are done, the Agents and Models & doctor pages start with three first steps, each checked against the real state: `init`, `project add` or `ingest`, and `install`.
|
|
243
|
+
|
|
244
|
+
### Pages
|
|
245
|
+
|
|
246
|
+
- `1` Tasks: the tasks `taskstate` keeps. Each expectation has three columns, baseline, evidence and conclusion, marked `◆` met or passing, `◇` to be reviewed or without a red baseline, `⊘` no longer valid, and `✕` not met. A stale conclusion is marked, and so is a self-review: a conclusion written by the session that recorded a run it rests on. A claim is shown as what the agent says of its own work, never as evidence. A gap's proposed command is shown as text and never run.
|
|
247
|
+
- `2` Library: at the top, where documents go: personal and project documents, then the line of what the MCP server admits (N visible, M hidden), then the boundary of this machine (`◎` `personal`, this machine only; `◯` `open`, usable by a cloud endpoint). Below, a flat list of documents by facet: all visible, `◎` `personal`, `◯` `open`, and hidden or excluded.
|
|
248
|
+
- `3` Sessions: the sessions of the five agent programs, filtered by program, with full-text search, a mark on a session whose source file is gone and whose retained copy stays, a full-screen reader, and jumps to and from Tasks.
|
|
249
|
+
- `4` Agents: each of the five programs' setup and the `install --dry-run` preview. It previews and never applies.
|
|
250
|
+
- `5` Models & doctor: the read-time model paths, Decide and Extract, whether `pdftotext`, `qpdf` and `pandoc` are found, and `D`, which runs `doctor` once.
|
|
251
|
+
|
|
252
|
+
### Keys
|
|
253
|
+
|
|
254
|
+
| Key | Does |
|
|
255
|
+
| --- | --- |
|
|
256
|
+
| `1`–`5` | Switch page |
|
|
257
|
+
| `Ctrl+K` or `/` | Search as an agent: while you type, a quick search with `--no-rerank`; `Enter` runs it again with the view the MCP server has. The bottom line says how many hidden or excluded documents lay out of the search's sight (`avoided`). |
|
|
258
|
+
| `j`/`k`, arrow keys | Move |
|
|
259
|
+
| `g`/`G` | First, last |
|
|
260
|
+
| `Enter`, `Esc` | Open, back |
|
|
261
|
+
| `Tab` | Switch column on a wide screen |
|
|
262
|
+
| `r` | Refresh |
|
|
263
|
+
| `?` | Help |
|
|
264
|
+
| `q` | Quit |
|
|
265
|
+
| `Ctrl+C` | Quit at once, at any level |
|
|
266
|
+
| `Ctrl+Z` | Suspend |
|
|
267
|
+
|
|
268
|
+
The bottom line shows the keys of the screen in order of priority; those that do not fit are under `?`.
|
|
269
|
+
|
|
270
|
+
### Writes and the confirmation bar
|
|
271
|
+
|
|
272
|
+
Every write first asks on a confirmation bar at the bottom, and the `$ …` command on the bar is the argv that runs.
|
|
273
|
+
|
|
274
|
+
- Tasks, `H`: hand the task off, `taskstate hold <T>`.
|
|
275
|
+
- Tasks, `P`: park or resume it, `taskstate park <T>` or `taskstate unpark <T>`.
|
|
276
|
+
- Tasks, `C`: close it, `taskstate close <T>`. Only `y` confirms; `Enter` does not.
|
|
277
|
+
- Library, `x`: hide or restore a document, `agent-whisker document remove <doc-id>` or `agent-whisker document restore <doc-id>`.
|
|
278
|
+
- Library, `u`: undo the last write.
|
|
279
|
+
- Library, `E`: exclude a folder, `agent-whisker exclude add <dir> [--hide-ingested]`; the space bar switches whether its ingested documents are hidden too.
|
|
280
|
+
- Library, `A`: add a folder, `agent-whisker ingest <dir> --tier <tier>`, where the tier, `open` or `personal`, must be chosen.
|
|
281
|
+
|
|
282
|
+
The interface never runs `taskstate run`, `conclude`, `expect` or `gap`. When it exits, it prints the writes it ran, each with its equivalent command, to standard error as a record.
|
|
283
|
+
|
|
284
|
+
### Terminal and colour
|
|
285
|
+
|
|
286
|
+
- At 100 columns or more, a list and its detail stand side by side. From 40 to 99 columns (designed at 57, for a phone or a split pane), one column shows at a time, with `Enter` and `Esc` moving through a stack of pages. Below 40×12, the screen only says that the terminal is too small.
|
|
287
|
+
- Colour is the 16-colour foregrounds 31, 32 and 33 with bold, dim and reverse, and `NO_COLOR` turns it off. Without a UTF-8 locale, or with `AGENT_WHISKER_TUI_ASCII=1`, the symbols are ASCII.
|
|
288
|
+
- The width of East Asian Ambiguous characters is measured at start with `\x1b[6n`; `AGENT_WHISKER_TUI_AMBIGUOUS=wide` or `narrow` sets it instead.
|
|
289
|
+
- `AGENT_WHISKER_LANG=en` or `zh-CN` chooses the language of the screen; without it, `LC_ALL` and `LANG` do, and the default is English.
|
|
290
|
+
- Control characters in untrusted text, such as a session's, are shown as `?`, so that the text cannot send escape sequences to the terminal. The interface does not capture the mouse.
|
|
291
|
+
|
|
219
292
|
## Implementation
|
|
220
293
|
|
|
221
|
-
`src/main.ts` calls `runCli` with the system Host. `src/commands/index.ts` registers commands; the `index` command is in `index-command.ts`. Shared parsing and diagnostics live in `src/command.ts`, store access in `src/store-access.ts`, and the key store (the rerank key) in `src/keystore.ts`. The CLI depends on core, MCP, and service.
|
|
294
|
+
`src/main.ts` calls `runCli` with the system Host. `src/commands/index.ts` registers commands; the `index` command is in `index-command.ts`. Shared parsing and diagnostics live in `src/command.ts`, store access in `src/store-access.ts`, and the key store (the rerank key) in `src/keystore.ts`. The terminal interface is in `src/tui/` and reads only through the CLI's commands and `taskstate` ([terminal interface](#terminal-interface)). The CLI depends on core, MCP, and service.
|
|
@@ -7,15 +7,20 @@
|
|
|
7
7
|
| 任务 | 命令 |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| 设置与诊断 | `init`、`install`(macOS、Windows)、`doctor`、`status`、`version` |
|
|
10
|
-
| 管理文档库 | `project`、`ingest`、`document remove\|restore`、`index` |
|
|
10
|
+
| 管理文档库 | `project`、`ingest`、`exclude add\|remove`、`document remove\|restore`、`index` |
|
|
11
11
|
| 查找文档 | `catalog`、`search`、`grep`、`read` |
|
|
12
12
|
| 处理会话历史 | `sessions status\|sync\|search\|grep\|read\|wait\|forget` |
|
|
13
13
|
| 运行集成 | `mcp`、`service`、`nudge`、`hook` |
|
|
14
|
+
| 在终端里浏览全部内容 | `tui`(见[下文](#终端界面)) |
|
|
14
15
|
|
|
15
16
|
`hook claude` 是 Claude Code 插件的钩子所运行的命令:它从标准输入读取钩子的 JSON,在会话开始和子代理启动时,打印一行关于该目录中已记录会话的指引,或者什么也不打印;会话开始时,如果数据目录尚未初始化,它给出一条提示,人能看到,模型看不到;提交提示词时,以前的主会话在同一个条目里含有提示词中两个罕见的词(中文或日文里是相邻的两个字)时,它打印一行,给出这两个词、会话数、最近的日期和搜索它们的调用,否则什么也不打印;`AGENT_WHISKER_PROMPT_POINTER` 是 `off` 时关掉这一行,是 50 到 5000 之间的整数时是它的时间预算(毫秒,否则是 300)([插件指南](../claude-plugin/README.zh-CN.md#组成部分))。`hook codex`、`hook pi` 和 `hook antigravity` 以各自程序的形式回应会话开始:对 Codex 和 pi,说明 agent-whisker 里有什么、什么时候调用它,有指引行时再加上它;对 Antigravity,只给指引行;`hook dsh` 由 dsh 的插件在根会话开始时运行,因为 dsh 的模型能看到服务的完整说明,它只打印指引行,用纯文本,计入这个目录及其下各目录的会话;数据目录尚未初始化时,`hook codex` 和 `hook antigravity` 给出与 `hook claude` 相同的提示。没有会话索引(第一次会话同步之前)、或者这个目录里没有以前的会话时,`hook codex` 和 `hook pi` 只打印那几句说明;没有数据目录时,`hook pi` 什么也不打印;存储打不开时(比代码新,或者正被维护占用),它们都什么也不打印。`sessions wait` 供等待另一个会话的 agent 使用:作为后台命令运行时,那个会话有新条目或不再变化、或者这个目录里开始了一个新会话,它就结束,并给出读取该会话的调用(见[下文](#等待另一个会话))。
|
|
16
17
|
|
|
17
18
|
没有启动脚本时,在仓库里运行 `node packages/cli/src/main.ts`。用 `--json` 得到机器可读的结果,用 `--cwd <directory>` 选择工作目录。退出码:0 表示成功,1 表示失败,2 表示用法错误,3 表示存储尚未初始化。`error: NotAStore:` 之后,只有在 `init` 能在那里创建存储时(数据目录不存在,或是一个空目录),才跟着一行 `run: agent-whisker init`;那里是别的东西时(较早格式的存储、放着其他文件的目录),错误本身的消息就是全部回答。`service install`、`service ensure`、`doctor` 的 `store` 一行和会话开始时的提示都按同一条规则。
|
|
18
19
|
|
|
20
|
+
`search` 和 `sessions search` 把每个位置参数当作一条查询,最多 8 条,每条最多 1024 个 UTF-8 字节。用引号把多个词作为一条查询,例如 `agent-whisker search "audit risk"`。
|
|
21
|
+
|
|
22
|
+
`sessions search` 默认只搜用户和助手的对话;用 `--role all` 可包含工具。`sessions grep` 搜索保留的条目(包括工具调用和保留的结果)。`sessions read --results` 还可以从未改变的源文件读出未保留的结果。
|
|
23
|
+
|
|
19
24
|
## 安装与诊断
|
|
20
25
|
|
|
21
26
|
`init` 创建数据目录,不碰数据目录以外的任何东西。密钥存储只保存重排服务的密钥:macOS 上默认存进钥匙串,其他系统默认不设密钥库(这时密钥来自 `AGENT_WHISKER_RERANK_KEY`);要用文件保存,设置 `AGENT_WHISKER_KEYSTORE=file:/absolute/path/to/keys`;在 POSIX 系统上,密钥目录或密钥文件对同组用户或其他用户开放了权限时,会被拒绝,在 Windows 上,密钥文件的访问列表里出现你以外的账户时,也会被拒绝。存储默认在 `~/.agent-whisker`;`AGENT_WHISKER_HOME` 可以改变它。
|
|
@@ -68,7 +73,7 @@
|
|
|
68
73
|
|
|
69
74
|
## npm 包
|
|
70
75
|
|
|
71
|
-
整个工具是一个 npm 包。`node scripts/package.ts pack <directory>` 用本检出目录里受 Git 跟踪的文件构建它,把 `agent-whisker-<version>.tgz` 写到那个目录:CLI 和它依赖的各个工作区是由 Node 自带的类型剥离生成的 JavaScript(Node 不处理 `node_modules` 下的 TypeScript),随包内联的运行时依赖(`jieba-wasm` 与 `yaml`),还有 `install` 交给各个 agent
|
|
76
|
+
整个工具是一个 npm 包。`node scripts/package.ts pack <directory>` 用本检出目录里受 Git 跟踪的文件构建它,把 `agent-whisker-<version>.tgz` 写到那个目录:CLI 和它依赖的各个工作区是由 Node 自带的类型剥离生成的 JavaScript(Node 不处理 `node_modules` 下的 TypeScript),随包内联的运行时依赖(`jieba-wasm` 与 `yaml`),还有 `install` 交给各个 agent 程序的每个目录和各份指南;没有安装脚本。每个 `v*.*.*` 标签都会把这个包以 `agent-whisker` 为名发布到 npm,第一个版本是 `0.1.0`。用 `npm install -g agent-whisker` 安装已发布的包,或用 `npm install -g <tarball>` 安装本地构建的包,之后(在 Unix 上,若 `npm prefix -g` 设为 `~/.local`,npm 创建的 `~/.local/bin/agent-whisker` 软链接会占用 `install` 拒绝覆盖的启动器路径,请使用 Node 默认全局前缀或其他前缀安装后再运行 `install --apply wrapper`):
|
|
72
77
|
|
|
73
78
|
- 先运行 `agent-whisker install --dry-run`,再运行 `agent-whisker install --apply all`,安装方式和检出目录一样;它们交给 agent 程序的每个路径都在已安装的包里(`npm root -g` 给出它所在的目录),启动脚本运行的是其中的 `packages/cli/src/main.js`。
|
|
74
79
|
- 更新时,用同样的方式安装新版本的包,然后运行 `agent-whisker install --apply all`:它替换 Codex、agy、dsh 和 Herdr 应用各自保存的副本,并重启后台服务;再重启各个 agent 程序,在此之前它们的 MCP 服务运行的还是旧代码。
|
|
@@ -87,6 +92,10 @@ agent-whisker install --remove all
|
|
|
87
92
|
|
|
88
93
|
会留下的:数据目录(`~/.agent-whisker`,或 `AGENT_WHISKER_HOME`)、任务状态(`~/.local/state/agent-whisker-task`,`AGENT_WHISKER_TASK_HOME` 是绝对路径时为它;相对路径的值会被忽略,和 `taskstate` 一样)、密钥库里保存过的重排序密钥,以及安装程序建的目录(已经清空)。命令的最后几行给出删除这两个目录的 `rm -rf`,以及从 npm 安装时用的 `npm rm -g agent-whisker`;检出目录直接删除即可。
|
|
89
94
|
|
|
95
|
+
## Linux
|
|
96
|
+
|
|
97
|
+
Linux 上,`npm install -g agent-whisker` 会安装 `agent-whisker` 和 `taskstate`。运行 `agent-whisker init`,然后用 `agent-whisker sessions sync` 按需同步,或用 `agent-whisker service run` 在前台持续同步。要让它随登录启动,可在 systemd `--user` 服务的 `ExecStart` 里填写可执行文件的绝对路径及参数 `service run`。手动注册 MCP 时同样用绝对路径,参数为 `mcp`;Linux 不支持 `install --apply`。
|
|
98
|
+
|
|
90
99
|
## Windows
|
|
91
100
|
|
|
92
101
|
在 Windows 上(目前只在 Windows 11 上运行过),`init`、`install`、`doctor`、后台服务和 MCP 服务都能用,可以从仓库运行,也可以从 npm 包运行,差别见下文;本指南的其余部分照常适用。
|
|
@@ -164,10 +173,14 @@ agent-whisker extract --state 'Total: $12.50' --fields '{"total":{"type":"number
|
|
|
164
173
|
|
|
165
174
|
目录里有一个名为 `.agent-whisker-exclude` 的条目(空文件即可;从不读取它的内容)时,这个目录及其下的全部内容都会被排除。遍历目录时不进入它,并在标准错误上报告 `ingest: excluded directories skipped: <n>`(在 `--json` 中是 `excludedDirectories`);命令行参数本身是这样的目录,或位于这样的目录之下的任何位置(经由符号链接也算)时,这个参数单独以 `Excluded` 失败。文件夹被标记之前就已导入的文档,保留已存的版本,但不再更新;用 `document remove` 把它从目录、检索和读取中去掉。
|
|
166
175
|
|
|
176
|
+
`exclude add <dir>` 在 `<dir>` 里写入这个标记,即一个空的 `.agent-whisker-exclude`(已经有了就保持不变),此后导入会跳过这个目录及其下的全部内容。加上 `--hide-ingested` 时,它还把从那里已经导入、当前可见的文档隐藏起来,与 `document remove` 的效果相同(用 `document restore` 逐个找回),并报告隐藏了几篇。`exclude remove <dir>` 删除这个标记,而且只在它是一个空的普通文件时才删,所以绝不会删掉你的文件;没有标记时它照样成功,报告 `removed: false`。它不接受 `--hide-ingested`,也不会恢复 `exclude add --hide-ingested` 隐藏的文档。两者都需要已初始化的数据目录,都接受 `--json`。错误码:`<dir>` 不存在时是 `NotFound`,不是目录时是 `NotADirectory`,标记的位置上是目录或符号链接时是 `NotAMarker`;对 `remove`,标记有内容时是 `NotEmpty`。
|
|
177
|
+
|
|
167
178
|
标准错误上的最后一行是 `ingest: <n> added, <n> moved, <n> updated, <n> unchanged, <n> failed`。在两次导入之间既被移动又被修改的文件,会成为一个新文档;`ingest --doc <doc-id> <file>` 则把它归给原来的文档,前提是那个文档在本机上除了这个文件没有别的文件。导入从不恢复已移除的文档:它在标准错误上打印 `note: document <doc-id> is removed; restore it with: agent-whisker document restore <doc-id> --scope user`;如果是项目文档,则提示在项目内部用 `--scope project` 运行。导入如何为一个文件选定文档,见[架构页](../../docs/architecture.zh-CN.md#存储与检索)。
|
|
168
179
|
|
|
169
180
|
`document remove <doc-id>` 把一个文档从 `catalog`、`search` 和 `read` 中去掉,对 agent 也一样:MCP 的 `library_read` 对它的任何版本,都像对一个不存在的文档那样回答;`read` 以 `NoSuchDocument` 失败,并给出能把它找回来的 `document restore` 命令。没有被移除的文档,旧版本仍可以用 `read --version` 读取。移除操作不会删除 `truth/blobs/` 中的提取文本和大纲、日志中的标题和路径,或原位置的源文件。
|
|
170
181
|
|
|
182
|
+
`catalog --removed` 只读地列出当前视角里已隐藏的文档(由 `document remove` 或 `exclude add --hide-ingested` 隐藏),输出格式和分页与 `catalog` 相同,分级上限也同为 `personal`,一篇都没有时打印 `no hidden documents`;带 `--json` 时,每篇文档还多一个 `excluded: true|false`,表示它的文件是否位于带 `.agent-whisker-exclude` 标记的目录之下。`search --json` 的结果里附带 `avoided: { removed, excluded }`:在这次检索的视角和筛选条件(当前项目与用户作用域、分级上限 `personal`、`--kind`、`--folder`)之内有多少篇已隐藏的文档。已隐藏的文档根本不在索引里,所以这是这次检索看不到的文档数,并不说明其中有没有本来会匹配的。源文件位于带标记目录之下的计入 `excluded`,其余的计入 `removed`。`search` 的文本输出和 MCP 工具的回答都不变。
|
|
183
|
+
|
|
171
184
|
不给 `--kind` 时,文档的种类根据它的来源和提取出的文本推断,不用任何模型;给了 `--kind` 就总以它为准。front matter 里的一行 `kind: note|paper|web|skill` 直接给出种类;名为 `SKILL.md` 的文件是 `skill`;front matter 里的 `url:` 或 `source:` 是 HTTP(S) 网址时,是 `web`。前 128,000 个字符里有一个位于行首的 `Abstract` 或 `摘要` 标题,并且还有一个标志时,是 `paper`:最后 64,000 个字符里有 `References`、`Bibliography` 或 `参考文献` 标题,或者前 128,000 个字符里有 arXiv 编号或 DOI(PDF 里字母分开的 `A b s t r a c t` 只有在同时有 arXiv 编号或 DOI 时才算)。其余的都是 `note`。文档保留导入时得到的种类:`agent-whisker index reclassify-kinds` 在维护屏障下、以追加普通事件的方式重新判定每个 `note`,之后运行 `agent-whisker index` 让索引跟上。
|
|
172
185
|
|
|
173
186
|
## 项目
|
|
@@ -216,6 +229,66 @@ agent-whisker: the Codex session "Review the uploader's retry change" has 3 new
|
|
|
216
229
|
|
|
217
230
|
退出码:等待的事情发生了是 0;超时是 124(同时打印一行说明);无法判断时是 1(没有这个会话、没有会话索引、找不到或丢失了会话的文件,或者 `--new` 时后台服务没有运行);用法错误是 2;没有数据目录是 3。`--json` 改为打印一个对象,其中 `result` 是 `entries`、`quiet`、`new` 或 `timeout`。等待从不同步、不刷新会话、不提醒后台服务,也不写任何文件;收到信号时立即结束。
|
|
218
231
|
|
|
232
|
+
## 终端界面
|
|
233
|
+
|
|
234
|
+
`agent-whisker tui [--page tasks|library|sessions|agents|doctor]` 在一个终端界面里呈现任务状态、文档库、会话、各 agent 程序的接入情况和 `doctor`。它除了 Node 不依赖任何东西。它需要交互式终端:标准输入和标准输出都是 TTY,且 `TERM` 不是 `dumb`;否则以退出码 1 退出,报 `error: NotATerminal: …`,标准输出上什么也不写。
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
agent-whisker tui
|
|
238
|
+
agent-whisker tui --page library # 从另一个页签开始
|
|
239
|
+
alias awt='agent-whisker tui' # 你自己的 shell 别名;CLI 没有内建别名
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
它显示的内容都来自在进程内调用的 CLI 自己的命令(带 `--json`),以及 `taskstate … --json`。每次调用都是打开存储、用完即关,所以界面在等待按键时不持有 `store.lock`,`index repair` 可以同时运行。每 2 秒(5 分钟没有按键之后改为每 10 秒),它只比较存储文件的文件戳,不加锁(见 [core](../core/README.zh-CN.md) 的 `storeStamp`),有变化时才重新加载。在三项都完成之前,Agent 页和「模型与诊断」页顶部列出三项起步清单,每一项都按真实状态判断:`init`、`project add` 或 `ingest`,以及 `install`。
|
|
243
|
+
|
|
244
|
+
### 页签
|
|
245
|
+
|
|
246
|
+
- `1` Tasks:`taskstate` 记录的任务。每条期望有三列:基线、证据、结论,用形状标出:`◆` 达标或通过,`◇` 待复核或缺红灯基线,`⊘` 已失效,`✕` 未达标。已过期的结论会标出来,自审也会:写结论的会话,正是记录其所依据的运行的那个会话。声明只作为 agent 对自己工作的自述显示,从不算作证据。缺口的建议命令只以文本显示,从不运行。
|
|
247
|
+
- `2` Library:顶部是文档的流向:个人与项目文档,然后是 MCP 服务的准入线(可见 N 篇、已隐藏 M 篇),然后是本机边界(`◎` `personal`,仅限本机;`◯` `open`,云端端点可用)。下方是按切面筛选的平铺文档列表:全部可见、`◎` `personal`、`◯` `open`,以及已隐藏与不收录。
|
|
248
|
+
- `3` Sessions:五个 agent 程序的会话,可按程序筛选,可全文检索;源文件已删除、但留存副本还在的会话带有标记;还有全屏阅读器,以及与 Tasks 之间的互相跳转。
|
|
249
|
+
- `4` Agents:五个程序各自的接入状态,以及 `install --dry-run` 的预览。它只预览,从不应用。
|
|
250
|
+
- `5` Models & doctor:读取时的模型路径 Decide 和 Extract,`pdftotext`、`qpdf` 和 `pandoc` 是否找得到,以及 `D`:运行一次 `doctor`。
|
|
251
|
+
|
|
252
|
+
### 键位
|
|
253
|
+
|
|
254
|
+
| 键 | 作用 |
|
|
255
|
+
| --- | --- |
|
|
256
|
+
| `1`–`5` | 切换页签 |
|
|
257
|
+
| `Ctrl+K` 或 `/` | 以 agent 视角试搜:输入时用 `--no-rerank` 快速检索;`Enter` 用与 MCP 服务相同的视角重新运行。底栏显示有多少篇已隐藏或已排除的文档不在这次检索的视野里(`avoided`)。 |
|
|
258
|
+
| `j`/`k`、方向键 | 移动 |
|
|
259
|
+
| `g`/`G` | 首项、末项 |
|
|
260
|
+
| `Enter`、`Esc` | 进入、返回 |
|
|
261
|
+
| `Tab` | 宽屏时切换栏 |
|
|
262
|
+
| `r` | 刷新 |
|
|
263
|
+
| `?` | 帮助 |
|
|
264
|
+
| `q` | 退出 |
|
|
265
|
+
| `Ctrl+C` | 在任何一层立即退出 |
|
|
266
|
+
| `Ctrl+Z` | 挂起 |
|
|
267
|
+
|
|
268
|
+
底栏按优先级显示当前屏幕的键位;放不下的收进 `?`。
|
|
269
|
+
|
|
270
|
+
### 写操作与确认条
|
|
271
|
+
|
|
272
|
+
每个写操作都先在底部的确认条上询问,确认条上显示的 `$ …` 命令就是实际执行的 argv。
|
|
273
|
+
|
|
274
|
+
- Tasks,`H`:交接任务,`taskstate hold <T>`。
|
|
275
|
+
- Tasks,`P`:暂挂或恢复任务,`taskstate park <T>` 或 `taskstate unpark <T>`。
|
|
276
|
+
- Tasks,`C`:结案,`taskstate close <T>`。只有 `y` 算确认;`Enter` 无效。
|
|
277
|
+
- Library,`x`:隐藏或恢复一篇文档,`agent-whisker document remove <doc-id>` 或 `agent-whisker document restore <doc-id>`。
|
|
278
|
+
- Library,`u`:撤销上一次写操作。
|
|
279
|
+
- Library,`E`:排除一个目录,`agent-whisker exclude add <dir> [--hide-ingested]`;空格键切换是否同时隐藏其中已导入的文档。
|
|
280
|
+
- Library,`A`:加入一个目录,`agent-whisker ingest <dir> --tier <tier>`,分级必须明确选择 `open` 或 `personal`。
|
|
281
|
+
|
|
282
|
+
界面从不运行 `taskstate run`、`conclude`、`expect` 或 `gap`。退出时,它把本次执行过的写操作连同各自的等价命令打印到标准错误,作为审计记录。
|
|
283
|
+
|
|
284
|
+
### 终端与配色
|
|
285
|
+
|
|
286
|
+
- 宽度在 100 列及以上时,列表与详情左右并排。40 到 99 列时(设计基准为 57 列,适合手机或分屏),一次只显示一栏,用 `Enter` 和 `Esc` 在页面栈里前进后退。小于 40×12 时,屏幕只提示终端太小。
|
|
287
|
+
- 配色只用 16 色前景 31、32 和 33,加上粗体、dim 和反色;`NO_COLOR` 关闭配色。非 UTF-8 语言环境下,或设置了 `AGENT_WHISKER_TUI_ASCII=1` 时,符号改用 ASCII。
|
|
288
|
+
- East Asian Ambiguous 字符的宽度在启动时用 `\x1b[6n` 实测;`AGENT_WHISKER_TUI_AMBIGUOUS=wide` 或 `narrow` 可以直接指定。
|
|
289
|
+
- `AGENT_WHISKER_LANG=en` 或 `zh-CN` 选择界面语言;不设置时看 `LC_ALL` 和 `LANG`,默认是英文。
|
|
290
|
+
- 会话正文等不可信文本里的控制字符一律显示为 `?`,这样文本无法向终端发送转义序列。界面不开启鼠标捕获。
|
|
291
|
+
|
|
219
292
|
## 实现
|
|
220
293
|
|
|
221
|
-
`src/main.ts` 用系统 Host 调用 `runCli`。`src/commands/index.ts` 注册各个命令;`index` 命令在 `index-command.ts` 里。共用的解析和诊断代码在 `src/command.ts`,存储访问在 `src/store-access.ts`,密钥库(重排密钥)在 `src/keystore.ts
|
|
294
|
+
`src/main.ts` 用系统 Host 调用 `runCli`。`src/commands/index.ts` 注册各个命令;`index` 命令在 `index-command.ts` 里。共用的解析和诊断代码在 `src/command.ts`,存储访问在 `src/store-access.ts`,密钥库(重排密钥)在 `src/keystore.ts`。终端界面在 `src/tui/`,只通过 CLI 的命令和 `taskstate` 读取数据(见[终端界面](#终端界面))。CLI 依赖 core、MCP 和 service。
|
|
@@ -91,6 +91,7 @@ export const EXIT = { ok: 0, failure: 1, usage: 2, notInitialised: 3 } ;
|
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
|
|
94
95
|
|
|
95
96
|
|
|
96
97
|
|
|
@@ -141,8 +142,24 @@ export class CliError extends Error {
|
|
|
141
142
|
* may carry file names, arguments and other outside text.
|
|
142
143
|
* The stack and cause are not written: a person only needs the sentence. No side effects.
|
|
143
144
|
*/
|
|
144
|
-
export function errorLine(error , prefix ) {
|
|
145
|
-
const { code, message } = describeError(error);
|
|
145
|
+
export function errorLine(error , prefix , command ) {
|
|
146
|
+
const { code, message: original } = describeError(error);
|
|
147
|
+
let message = original;
|
|
148
|
+
if (code === "InvalidArgument") {
|
|
149
|
+
if (command === "grep" || command === "sessions")
|
|
150
|
+
message = message.replace("; pass fixed to search", "; pass -F to search");
|
|
151
|
+
if (command === "grep")
|
|
152
|
+
message = message
|
|
153
|
+
.replace(/^after must /, "-A/--after-context must ")
|
|
154
|
+
.replace(/^before must /, "-B/--before-context must ");
|
|
155
|
+
if (command === "sessions")
|
|
156
|
+
message = message
|
|
157
|
+
.replace(/^cwd must /, "--cwd-prefix must ")
|
|
158
|
+
.replace(
|
|
159
|
+
/^role must be dialogue, user, assistant or tool$/,
|
|
160
|
+
"--role must be dialogue, user, assistant, tool or all",
|
|
161
|
+
);
|
|
162
|
+
}
|
|
146
163
|
const said = prefix === undefined ? message : `${prefix}: ${message}`;
|
|
147
164
|
return `error: ${code}: ${displayField(oneLine(said))}\n`;
|
|
148
165
|
}
|
|
@@ -194,7 +211,7 @@ export function listOf(items ) {
|
|
|
194
211
|
* Writes a command's result: when ctx.json is true, value serialised as one JSON line (no whitespace) to stdout;
|
|
195
212
|
* otherwise each line of text plus a newline to stdout. An empty text array writes nothing. Side effects: host.out only.
|
|
196
213
|
*/
|
|
197
|
-
export function writeResult(ctx
|
|
214
|
+
export function writeResult(ctx , value , text ) {
|
|
198
215
|
if (ctx.json) {
|
|
199
216
|
ctx.host.out(`${JSON.stringify(value)}\n`);
|
|
200
217
|
return;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// `agent-whisker catalog [--kind <kind>] [--title <substring>] [--folder <folder>] [--limit <n>] [--after <cursor>]
|
|
2
|
-
// lists the visible documents
|
|
1
|
+
// `agent-whisker catalog [--kind <kind>] [--title <substring>] [--folder <folder>] [--limit <n>] [--after <cursor>]
|
|
2
|
+
// [--removed]`: lists the visible documents, or with --removed the hidden ones (`document remove`, `exclude add
|
|
3
|
+
// --hide-ingested`), read-only, in the same view, tier ceiling and output.
|
|
3
4
|
//
|
|
4
5
|
// The view is the current project plus user, or user alone when no project is found; the tier ceiling is personal
|
|
5
6
|
// (currentView in store-access.ts). Arguments go to store.catalog as given: --kind becomes a one-item docKinds,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
UsageError,
|
|
24
25
|
writeResult,
|
|
25
26
|
} from "../command.js";
|
|
27
|
+
import { documentPath, markerChecker } from "../exclusion.js";
|
|
26
28
|
import { currentView, withStore } from "../store-access.js";
|
|
27
29
|
|
|
28
30
|
/** The --kind value: one of core's DOC_KINDS, or undefined when not given. Throws UsageError. ingest and grep use it too. */
|
|
@@ -39,6 +41,7 @@ const OPTIONS = {
|
|
|
39
41
|
after: { type: "string" },
|
|
40
42
|
title: { type: "string" },
|
|
41
43
|
folder: { type: "string" },
|
|
44
|
+
removed: { type: "boolean" },
|
|
42
45
|
} ;
|
|
43
46
|
|
|
44
47
|
/** The `catalog` entry in the command table. */
|
|
@@ -46,7 +49,8 @@ export const catalogCommand = {
|
|
|
46
49
|
name: "catalog",
|
|
47
50
|
summary: "List the documents of the current project and the user's notes",
|
|
48
51
|
usage:
|
|
49
|
-
"agent-whisker catalog [--kind <kind>] [--title <substring>] [--folder <folder>] [--limit <n>] [--after <cursor>]",
|
|
52
|
+
"agent-whisker catalog [--kind <kind>] [--title <substring>] [--folder <folder>] [--limit <n>] [--after <cursor>] [--removed]",
|
|
53
|
+
help: "The default --limit is 50.",
|
|
50
54
|
needsStore: true,
|
|
51
55
|
checksIntegrity: false,
|
|
52
56
|
run(ctx) {
|
|
@@ -63,20 +67,35 @@ export const catalogCommand = {
|
|
|
63
67
|
...(values.after === undefined ? {} : { after: values.after }),
|
|
64
68
|
...(values.title === undefined ? {} : { title: values.title }),
|
|
65
69
|
...(values.folder === undefined ? {} : { folder: values.folder }),
|
|
70
|
+
...(values.removed === true ? { removed: true } : {}),
|
|
66
71
|
});
|
|
67
|
-
|
|
72
|
+
if (values.removed !== true) {
|
|
73
|
+
writeResult(ctx, result, catalogText(result, false));
|
|
74
|
+
return EXIT.ok;
|
|
75
|
+
}
|
|
76
|
+
// A hidden document says whether its file lies under an exclusion marker (exclude add), so a view can tell a
|
|
77
|
+
// document hidden on its own from one kept out with its directory.
|
|
78
|
+
const marked = markerChecker();
|
|
79
|
+
const documents = result.documents.map((doc) => {
|
|
80
|
+
const path = documentPath(doc, ctx.host.homeDir, view.project);
|
|
81
|
+
return { ...doc, excluded: path !== null && marked(path) };
|
|
82
|
+
});
|
|
83
|
+
writeResult(ctx, { ...result, documents }, catalogText(result, true));
|
|
68
84
|
return EXIT.ok;
|
|
69
85
|
});
|
|
70
86
|
},
|
|
71
87
|
};
|
|
72
88
|
|
|
73
89
|
/** Text output of catalog, as described in the file header. */
|
|
74
|
-
function catalogText(result ) {
|
|
75
|
-
if (result.documents.length === 0 && result.next === undefined)
|
|
90
|
+
function catalogText(result , removed ) {
|
|
91
|
+
if (result.documents.length === 0 && result.next === undefined)
|
|
92
|
+
return [removed ? "no hidden documents" : "no documents"];
|
|
76
93
|
const lines = result.documents.map(
|
|
77
94
|
(doc) =>
|
|
78
95
|
`${doc.docId} ${doc.scope} ${doc.docKind} ${doc.bytes} ${displayField(doc.source)} ${displayField(doc.title)}`,
|
|
79
96
|
);
|
|
80
|
-
|
|
97
|
+
lines.unshift("doc scope kind bytes source title");
|
|
98
|
+
if (result.next !== undefined)
|
|
99
|
+
lines.push(`next: agent-whisker catalog${removed ? " --removed" : ""} --after '${displayField(result.next)}'`);
|
|
81
100
|
return lines;
|
|
82
101
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Every program is run at the path the login shell found for it (runFound), through its own read-only listing; no
|
|
8
8
|
// command that starts a server or opens a connection is run (codex app-server is not, so Codex's hook trust is not
|
|
9
9
|
// read).
|
|
10
|
-
import {
|
|
10
|
+
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
11
11
|
import { basename, dirname, isAbsolute, join, win32 } from "node:path";
|
|
12
12
|
import {
|
|
13
13
|
|
|
@@ -108,9 +108,11 @@ import {
|
|
|
108
108
|
import {
|
|
109
109
|
ask,
|
|
110
110
|
CHECK_TIMEOUT_MS,
|
|
111
|
+
executable,
|
|
111
112
|
exitedText,
|
|
112
113
|
HERDR_APP,
|
|
113
114
|
HERDR_CORE,
|
|
115
|
+
isLauncherPath,
|
|
114
116
|
isWantedNode,
|
|
115
117
|
LAUNCHER_NAME,
|
|
116
118
|
|
|
@@ -127,7 +129,6 @@ import {
|
|
|
127
129
|
|
|
128
130
|
runFound,
|
|
129
131
|
SERVER_NAME,
|
|
130
|
-
samePath,
|
|
131
132
|
shellArgv,
|
|
132
133
|
shellLine,
|
|
133
134
|
unrecognised,
|
|
@@ -281,6 +282,16 @@ function runChecks(ctx ) {
|
|
|
281
282
|
versions.set(key, known);
|
|
282
283
|
return known;
|
|
283
284
|
};
|
|
285
|
+
if (host.platform === "linux") {
|
|
286
|
+
return [
|
|
287
|
+
guarded("frameworks", () => frameworksCheck(lookup, ctx.agents, versionOf, host.platform)),
|
|
288
|
+
guarded("cli", () => cliCheck(host)),
|
|
289
|
+
guarded("service", () => serviceCheck(host, ctx.home, wrapper, null)),
|
|
290
|
+
guarded("store", () => storeCheck(ctx)),
|
|
291
|
+
guarded("convert", () => convertCheck(host)),
|
|
292
|
+
guarded("sessions", () => sessionsCheck(ctx)),
|
|
293
|
+
];
|
|
294
|
+
}
|
|
284
295
|
const wrapperFacts = guarded("wrapper", () => wrapperCheck(host, wrapper, lookup));
|
|
285
296
|
const wrapperNode = "node" in wrapperFacts ? wrapperFacts.node : null;
|
|
286
297
|
const clients = CLIENTS.map((row) => ({
|
|
@@ -328,8 +339,7 @@ function runChecks(ctx ) {
|
|
|
328
339
|
const unitCheck = ({ status, detail } ) => ({ status, detail });
|
|
329
340
|
|
|
330
341
|
/** The detail of a row doctor does not check on Windows (windowsChecks). */
|
|
331
|
-
const NOT_ON_WINDOWS =
|
|
332
|
-
"not on Windows yet: install sets this up, and doctor finds programs through a login shell, only on macOS and Linux";
|
|
342
|
+
const NOT_ON_WINDOWS = "doctor does not check this integration on Windows yet";
|
|
333
343
|
|
|
334
344
|
/**
|
|
335
345
|
* runChecks on Windows, in the same order: there is no POSIX login shell, so programs are found by core's lookup on
|
|
@@ -474,7 +484,9 @@ function convertCheck(host ) {
|
|
|
474
484
|
const result = host.run(program, [flag], { timeoutMs: CHECK_TIMEOUT_MS });
|
|
475
485
|
if (result.code === 127) {
|
|
476
486
|
warn = true;
|
|
477
|
-
|
|
487
|
+
const install =
|
|
488
|
+
program === "pdftotext" ? "Poppler (poppler on Homebrew, poppler-utils on Debian/Ubuntu)" : program;
|
|
489
|
+
return `${program} not found, so ${missing}; install ${install}`;
|
|
478
490
|
}
|
|
479
491
|
if (result.code === null) {
|
|
480
492
|
warn = true;
|
|
@@ -669,11 +681,8 @@ function foundFirst(lookup , wrapper , windows
|
|
|
669
681
|
const found = lookup(LAUNCHER_NAME);
|
|
670
682
|
if (found.kind !== "found") return null;
|
|
671
683
|
// On Windows the lookup finds a `.cmd` shim, never the settings file: it is ours when it is in the launcher's folder.
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
? !win32.isAbsolute(found.path) || folder(found.path) === folder(wrapper)
|
|
675
|
-
: !isAbsolute(found.path) || samePath(found.path, wrapper);
|
|
676
|
-
if (ours) return null;
|
|
684
|
+
const absolute = windows ? win32.isAbsolute : isAbsolute;
|
|
685
|
+
if (!absolute(found.path) || isLauncherPath(found.path, wrapper, windows)) return null;
|
|
677
686
|
const finds = windows ? "this process's PATH finds" : "the login shell finds";
|
|
678
687
|
const before = windows ? win32.dirname(found.path) : dirname(found.path);
|
|
679
688
|
return `${finds} ${LAUNCHER_NAME} at ${found.path} before ${wrapper}, so what you type there and the hooks that call ${LAUNCHER_NAME} by name run that one, without the launcher's node and settings; put ${dirname(wrapper)} before ${before} in PATH`;
|
|
@@ -1332,16 +1341,6 @@ function dshPluginRow(
|
|
|
1332
1341
|
return { status: warns.length === 0 ? "ok" : "warn", detail, ...gives };
|
|
1333
1342
|
}
|
|
1334
1343
|
|
|
1335
|
-
/** Whether path is a regular file this process may execute. */
|
|
1336
|
-
function executable(path ) {
|
|
1337
|
-
try {
|
|
1338
|
-
accessSync(path, fsConstants.X_OK);
|
|
1339
|
-
return statSync(path).isFile();
|
|
1340
|
-
} catch {
|
|
1341
|
-
return false;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
1344
|
/**
|
|
1346
1345
|
* The plugin's load record against the newest dsh main session the store holds (by its first entry): a warning when
|
|
1347
1346
|
* that session started after the record and is not the record's session, "dsh sessions since <time> ran without the
|
|
@@ -1546,8 +1545,8 @@ function claudePart(look )
|
|
|
1546
1545
|
* (serviceStatus: try the service lock; failing to get it means running), then what its last round says failed
|
|
1547
1546
|
* (lastRoundFailures, from service.json in home, the data directory). ok when all are right and nothing failed,
|
|
1548
1547
|
* otherwise warn. A plist install could not have written (launchAgentState's foreign) is warn, said in the service
|
|
1549
|
-
* step's words (foreignPlist), before whether launchd has it loaded and whether it runs.
|
|
1550
|
-
*
|
|
1548
|
+
* step's words (foreignPlist), before whether launchd has it loaded and whether it runs. Outside macOS report the
|
|
1549
|
+
* service itself rather than checking for a LaunchAgent.
|
|
1551
1550
|
*/
|
|
1552
1551
|
function serviceCheck(
|
|
1553
1552
|
host ,
|
|
@@ -1557,10 +1556,12 @@ function serviceCheck(
|
|
|
1557
1556
|
) {
|
|
1558
1557
|
if (host.platform === "win32") return windowsServiceCheck(host, home, wrapper);
|
|
1559
1558
|
if (host.platform !== "darwin") {
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1559
|
+
const { running, state } = serviceStatus(host);
|
|
1560
|
+
const failures = lastRoundFailures(state, home);
|
|
1561
|
+
const detail = running
|
|
1562
|
+
? "running"
|
|
1563
|
+
: "not running; run agent-whisker service run in the foreground, or agent-whisker sessions sync once";
|
|
1564
|
+
return { status: running && failures.length === 0 ? "ok" : "warn", detail: [detail, ...failures].join("; ") };
|
|
1564
1565
|
}
|
|
1565
1566
|
const state = launchAgentState(host);
|
|
1566
1567
|
if (!state.installed) {
|
|
@@ -1712,7 +1713,10 @@ function sshCheck(host , wrapper )
|
|
|
1712
1713
|
*/
|
|
1713
1714
|
function storeCheck(ctx ) {
|
|
1714
1715
|
const home = ctx.home;
|
|
1715
|
-
const initHint =
|
|
1716
|
+
const initHint =
|
|
1717
|
+
ctx.host.platform === "linux"
|
|
1718
|
+
? "run agent-whisker init"
|
|
1719
|
+
: "run agent-whisker init (or agent-whisker install --apply init)";
|
|
1716
1720
|
if (!existsSync(home) && initCreatesStore(home))
|
|
1717
1721
|
return { status: "warn", detail: `the data directory ${home} is not initialised; ${initHint}` };
|
|
1718
1722
|
try {
|