@staix/vault-mem 0.9.1 → 0.10.1
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 +31 -0
- package/README.md +19 -6
- package/bin/vmem.js +2 -2
- package/package.json +2 -2
- package/src/analysis-commands.ts +24 -14
- package/src/analysis-input.ts +12 -0
- package/src/analysis-types.ts +5 -1
- package/src/assert-command.ts +48 -0
- package/src/assertion-exposure.ts +367 -0
- package/src/assertion-index.ts +86 -0
- package/src/assertion-policy.ts +63 -0
- package/src/assertion-read.ts +170 -0
- package/src/assertions-command.ts +123 -0
- package/src/assertions.ts +1013 -0
- package/src/cli-output.ts +9 -3
- package/src/cli.ts +44 -23
- package/src/commands-table.ts +16 -2
- package/src/evidence.ts +222 -0
- package/src/graph-evidence.ts +169 -0
- package/src/index.ts +14 -0
- package/src/links.ts +18 -0
- package/src/log-commands.ts +7 -7
- package/src/mcp-spec.ts +11 -11
- package/src/mcp-vault.ts +105 -6
- package/src/mcp.ts +4 -0
- package/src/org-commands.ts +5 -5
- package/src/org-promote.ts +9 -0
- package/src/promote-command.ts +6 -6
- package/src/proposal-commands.ts +100 -0
- package/src/proposal-provider.ts +335 -0
- package/src/proposal-storage.ts +334 -0
- package/src/proposals.ts +170 -0
- package/src/read-commands.ts +44 -12
- package/src/read-output.ts +42 -14
- package/src/skills-mine.ts +12 -7
- package/src/source-age.ts +131 -0
- package/src/spec-output.ts +14 -13
- package/src/sync.ts +14 -7
- package/src/text-output.ts +86 -21
- package/src/vault-brief.ts +8 -4
- package/src/vault-graph.ts +12 -3
- package/src/vault-history.ts +662 -0
- package/src/vault-index.ts +2 -0
- package/src/vault-lint.ts +15 -4
- package/src/write-commands.ts +18 -17
- package/src/write-output.ts +6 -6
- package/src/write-types.ts +1 -0
- package/src/write-validation.ts +3 -1
- package/src/writer.ts +257 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.10.1] - 2026-11-20
|
|
6
|
+
|
|
7
|
+
- Raise the exact `@staix/agent-mem` runtime pin from 0.29.0 to 0.30.0, allowing the home format floor to be raised after older library hosts stop. The upgrade does not raise the floor automatically.
|
|
8
|
+
|
|
9
|
+
## [0.10.0] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
- N-1: 0.9.1 and 0.10.0 share the same note/spec index files (`links2-schema4`, link resolution 2, schema 4) and config format 4; neither version rebuilds the other's note/spec index or changes the config format. CLI: 0.9.1 refuses the new proposal, assertion, history, evidence and graph-explain commands/options, does not relink subject notes on move/merge, and ignores `assertions/` during sync; 0.10.0 stages recognized assertion segments, reports L16/L17, uses the new human-output markers and tables, and uses exit 2 for usage errors (0.9.1 uses 1). Notes remain shared: 0.9.1 treats an unchanged `evidence` field as a warning and refuses newly introduced or explicitly changed unknown evidence metadata. MCP: 0.9.1 exposes 38 tools and rejects unknown tools/arguments, while 0.10.0 exposes 52; existing lint results gain L16/L17, `vmem_read` accepts `revision`, and move/merge receipts may gain `assertions`. Proposal records live under the configured home and the assertion journal lives in the vault; 0.9.1 does not use either. Agent-mem: 0.9.1 pins 0.28.0 and 0.10.0 pins 0.29.0; curated `INDEX_VERSION` moves from 4 to 5, rebuilding a separate derived index while leaving v4 intact for 0.9.1 to keep using; the upgrade does not automatically raise capture, candidate, sync or home format floors. An opt-in admitted placement realm is not recognized by the older reader.
|
|
12
|
+
|
|
13
|
+
- Raise the exact `@staix/agent-mem` runtime pin from 0.28.0 to 0.29.0. Its curated `INDEX_VERSION` changes from 4 to 5: it rebuilds a separate derived index and leaves v4 intact. Capture, candidate, sync and home formats gain no automatic floor. On index write contention, curated reads can retain already-indexed rows and retry instead of failing; the 0.28.1 home binding also tolerates a macOS device-number change. No used API signature or selection default changes. Activated placement sync scheduling changes upstream, but vmem does not call that sync.
|
|
14
|
+
|
|
15
|
+
- Add subject `relink` to `vmem assert` and `vmem_assert`. Successful note moves and merges relink current subjects after publication; previews list them and a failed relink leaves the note written with a recovery command in the receipt (#258).
|
|
16
|
+
- Add the read-only exposure report for purged payloads that survived in Git: `vmem assertions exposure <vault> [<assertion-id>] [--replace-file PATH] [--json]` and the MCP tool `vmem_assertions_exposure`. The scan walks the commits reachable from local branches, tags and remote-tracking refs, reads only `assertions/*.jsonl` blobs, and reports for each purged entry whether a reachable blob still holds its line with a `payload`, matching by `seg`, `seq` and `hash` with the payload's SHA-256 equal to `payload_sha256`, together with the holding commits, the refs that contain them and the scanned commit, blob and byte counts. It prints position and hash only, never payload text, and works under `write: none`; `denyPaths` on `assertions/` refuses it as it refuses `vmem assertions`. Bounds are the journal's per blob (8 MiB plus one batch of framing) and per commit (64 MiB) with an overall 100000-commit budget: crossing one sets `truncated` with the bound named, and a truncated or otherwise unreadable scan is never `clean: true`. A vault that is not a Git repository reports `clean: null` with `issues: ["not a git repository"]`, and every scan says it covers the local repository only. `--replace-file PATH` (CLI only) writes a `git-filter-repo --replace-text` expressions file mapping each exposed line to its purged form taken byte for byte from the current verified segment; it is created with mode 0600, refuses an existing path and must lie outside the vault, a line that cannot be expressed literally is reported unreplaceable with the manual step, and the receipt says to delete the file after use. The rewrite, force push, reflog expiry and `gc` stay with the owner (`docs/reference/writes.md`); vmem never runs them. The MCP tool count moves from 51 to 52, its request and reply share the 48 KiB frame bound, and an oversized reply drops `exposed[].refs` first, then rows with an `omitted` count (#259).
|
|
17
|
+
|
|
18
|
+
- Add the two-step assertion purge: `vmem assertions purge <vault> <assertion-id> --reason TEXT [--confirm --fingerprint SHA] [--json]` and the MCP tool `vmem_assertions_purge`. The preview writes nothing and returns every affected entry, each affected segment's verified length and a fingerprint; confirm with that fingerprint holds `assertions.lock` for the whole rewrite, drops `payload` from the assertion's entries, keeps `payload_sha256` and every hashed field and adds `purged: {at, reason}`, so the chain still verifies. The reason is 1..200 UTF-16 units, the unit the verifier counts, and is screened like any other write, so a reason carrying a secret (`V06`) or denied PII (`V07`) is refused instead of adding the content the purge removes. Rewritten bytes are verified before the rename, so a candidate the verifier would reject never replaces a segment. An interrupted rewrite leaves the original segment intact and the same fingerprint finishes the purge; a stale fingerprint is refused with `V09`. The disposable index at `VMEM_HOME/indexes/assertions-<digest>-v1.sqlite` is deleted and rebuilt from the purged journal under the same lock, so the cache keeps no purged payload. Reads then leave the assertion out of `--subject` and `--relation` answers, show it `unavailable` with `purged: true` in an unfiltered `--history` and count it in `coverage.purged`. The reason stays in the journal, and bytes in Git history, other clones or remotes are untouched: complete erasure needs a history rewrite outside vmem. The MCP tool count moves from 50 to 51, and its request and reply share the 48 KiB frame bound (#252).
|
|
19
|
+
|
|
20
|
+
- Add `vmem assertions` and the read-only MCP tool `vmem_assertions` for verified temporal journal queries, current policy screening, subject-note status and bounded pages. The disposable SQLite index is stored under the configured home and rebuilt from verified journal entries (#251).
|
|
21
|
+
|
|
22
|
+
- Add the append-only temporal assertion journal and its write contract: `vmem assert <vault> --batch FILE|- [--dry-run] [--log JSON] [--json]` and the MCP write tool `vmem_assert` share one implementation and append 1..32 `declare`, `assert`, `revise` or `retract` operations all-or-nothing as canonical hash-chained lines under `assertions/<16 lowercase hex>.jsonl`, one writer segment per clone under `assertions.lock`. An input `declare` is stored as the entry op `subject`. Every `assert` and `revise` needs evidence verified at append or a source reference, `revise` and `retract` need `expected_heads` equal to the head set computed from the verified segments (not the derived index), and a writer clock behind the segment tail or a parent is refused with `CLOCK` rather than clamped. A torn tail or interrupted batch is truncated back on the next append with a recovery note, a verified-segment mismatch starts a new segment, and the 64 MiB and 100000-entry journal bounds are checked from file sizes before reading. The exported `evaluateAssertions` answers world time and record time purely from verified segments, so a batch writes no note, changes no `updated` stamp and appends no log line unless `--log` is given. `vmem_assert` requests and replies stay within 48 KiB as an encoded JSON-RPC frame: a request is measured on the frame the client sent, and an oversized reply drops the entry rows and names their segment, so a batch already in the journal is never replayed (#250).
|
|
23
|
+
|
|
24
|
+
- `vmem sync` stages the assertion journal's segments: `assertions/<16 lowercase hex>.jsonl` directly under `assertions/` is committed and pushed like a note, so the journal has a backup. Every other path under `assertions/` (a stray name, uppercase or shortened id, a nested file) and the vault-root `assertions.lock` stay listed under `ignored` and are never staged, and a vault without `assertions/` syncs as before. The staged-path sentence in the sync output, the console's sync detail and the sync reference follow the same list.
|
|
25
|
+
|
|
26
|
+
- Add opt-in durable note proposals with screened submit, pending list and paged show, fingerprint-bound apply or reject, and read-only reconciliation of uncertain outcomes. `vmem proposal` and six `vmem_proposal_*` tools share the provider; existing direct writes remain unchanged. Proposals live in the configured home and require backup. Interrupted applies stay `apply_unknown`, and an applied note is not replayed when its log or receipt fails (#234).
|
|
27
|
+
|
|
28
|
+
- Add lint warning L17 for a note whose workspace `source` path changed after the note's `updated` date: a tracked path reports the number of first-parent commits (merges included) that touch it after that day, an untracked path reports `modified` when its mtime is later. Notes without `updated` are counted as unknown age and not flagged. URL, memory-id, denied and missing sources (L14) are skipped. The check reads only git history and file metadata, opens no source file, writes nothing, and checks at most 2000 source paths per run with the rest counted as skipped. `vmem lint --json` and `vmem_lint` carry it; no MCP tool or argument changes.
|
|
29
|
+
|
|
30
|
+
- Add the read-only `vmem graph explain <vault> <from> <to> [--max-hops 1..6] [--relation REL] [--via-hubs] [--json]` and `vmem_graph_explain` (schemaVersion 1). They take the path `graph path` selects from the same snapshot and list, for each hop, the link occurrences behind its edge: origin note path and sha256, line, UTF-8 byte range, body or frontmatter field, declared relation, authored from/to and forward or reverse traversal. Matches the graph used are `legacy_graph_match`, with `authored` telling whether `extractLinks` also accepts them; anchored and frontmatter references are annotations that add no edge. Output is bounded at 20 occurrences per hop and 48 KiB, with omitted counts, and is byte-identical for the same input. `graph build`, `graph path`, communities and the edge `confidence: 1` are unchanged.
|
|
31
|
+
|
|
32
|
+
- Add optional version-1 `evidence` frontmatter (`source`, `sha256`, `quote`, optional exact H2 `section`; at most 16 entries and 16 KiB, each source also listed in `source`) and the read-only `vmem evidence <vault> <note> [--json]` / `vmem_evidence` (schemaVersion 1). Flat `notes/*.md` sources in the same vault, resolved through the workspace root of the vault registry, are re-read on every call and reported `verified`, `stale`, `missing`, `ambiguous` or `unsupported` with UTF-8 byte offsets; other references are `unverified_external` without I/O. Newly introduced malformed evidence is a V01 write error; source drift is the new lint warning L16, never a write refusal. Org promotion removes evidence whose source is not retained in the target vault and lists the removals (`evidenceRemoved`, index and reason only). Existing notes and JSON shapes are unchanged.
|
|
33
|
+
- Adopt the shared CLI output colors and markers and add lint/check summaries. Invalid color options, unknown commands, and argument errors in registry, read, brief, analysis, write, log, spec, sync, promotion and skills commands now exit 2 instead of 1; operation failures remain exit 1. JSON schemas and report streams are unchanged (#228).
|
|
34
|
+
- Add read-only Git snapshot history over the registered vault's own repository: `vmem history` lists one note path's revisions (100 per page, 1000 first-parent commits traversed per request, one 5 s deadline) newest first, `vmem show --revision` reads one historical blob with the current reader's paging, UTF-8, symlink, size and deny rules, and `vmem changes` compares two pinned commits over `notes/` with before/after blob ids and status but no content diff (500 paths per page). MCP gains `vmem_history` and `vmem_changes` and a `revision` option on `vmem_read`, all through the same provider, so the tool count moves from 39 to 41. Every result carries `schemaVersion`, `basis: "git_snapshot"`, the pinned HEAD, `firstParent`, `renamePolicy: "exact_path"`, `timeBasis` and a separate `dirtyNotes` count, and every complete CLI or MCP response stays within 48 KiB including the JSON-RPC envelope and its escaping, so a page shrinks into a continuation instead of overrunning it; non-repositories, a repository above the vault root, unavailable Git, and empty, shallow or pruned repositories are reported as explicit capabilities rather than current content, a pruned or missing object included. Repository settings that would start a program or rewrite the path projection (`log.follow`, `log.showSignature`, `gpg.program`) are pinned off on every call, a clean filter attributed to `notes/` stops the dirty-note count with a stated reason instead of running it, and a note path carrying a control character is refused rather than handed to Git. Revision arguments are one full lowercase commit id reachable from HEAD, and no Git state, note file or log is written (#235).
|
|
35
|
+
|
|
5
36
|
## [0.9.1] - 2026-11-17
|
|
6
37
|
|
|
7
38
|
- Keeps the 0.9 line's N-1 with 0.8.0 unchanged: note and spec index files (`links2-schema4`, schema 4), config format 4, link resolution, the pinned MCP `initialize` instructions, the 38 MCP tools and the CLI commands are the same as 0.9.0, and agent-mem 0.28.0 keeps curated `INDEX_VERSION` 4, so both versions still read the same memory home.
|
package/README.md
CHANGED
|
@@ -27,10 +27,12 @@ vmem tidy personal --all # once after upgrading an existing vault: previe
|
|
|
27
27
|
|
|
28
28
|
## Concepts
|
|
29
29
|
|
|
30
|
-
- **Home**: the registry and policies live in `vmem.config.json` under the vmem home: `VMEM_HOME`, else the `home` pointer in the default home's config, else the default home (`$AGENTHUB_HOME/vmem`, or `~/.agenthub/vmem`). Derived index caches live under the home, never inside a vault.
|
|
30
|
+
- **Home**: the registry and policies live in `vmem.config.json` under the vmem home: `VMEM_HOME`, else the `home` pointer in the default home's config, else the default home (`$AGENTHUB_HOME/vmem`, or `~/.agenthub/vmem`). Derived index caches live under the home, never inside a vault. Proposal records are durable home data, not a rebuildable cache: include the configured home in backups.
|
|
31
31
|
- **Vault**: a directory with a flat `notes/` folder, an append-only `log` and optional `reports/` and `ops/`. Each vault has a `kind` (`personal` or `org`), a `write` policy (`mcp` allows CLI and MCP writes, `cli` CLI only, `none` no writes) and a PII policy (default `allow` for personal, `deny` for org).
|
|
32
32
|
- **Notes**: frontmatter `type` is one of <!-- facts:note-types -->`insight`, `decision`, `observation`, `person`, `project`, `method`, `moc`, `reference`<!-- /facts:note-types -->; links are `[[wiki links]]` resolved by filename stem inside the same vault.
|
|
33
|
-
- **Two-step changes**: move, delete, merge, tidy, promotion and
|
|
33
|
+
- **Two-step changes**: move, delete, merge, tidy, promotion, sync, proposal decisions and assertion purges first return a preview with a fingerprint and change nothing; `--confirm --fingerprint <sha>` (MCP `confirm`, `fingerprint`) applies exactly that preview.
|
|
34
|
+
- **Proposals**: opt-in create or exact-patch requests remain outside the vault and index until confirmed. Review and rejection do not authenticate a human; existing direct writes retain their policy. An interrupted apply remains `apply_unknown` until inspected, and is never replayed automatically.
|
|
35
|
+
- **Assertions**: an optional `assertions/` directory holds an append-only, hash-chained journal of manually authored subject/relation/value assertions, each with its evidence and its record time. `vmem assert` appends a validated batch there and writes no note, so a note edit never rewrites history; `vmem assertions` and `vmem_assertions` read it with current policy, and `vmem sync` commits the segments like the log. `vmem assertions purge` removes one assertion's payloads: `payload` goes, `payload_sha256` and every hashed field stay, `purged: {at, reason}` is added, the chain still verifies, and reads then leave the assertion out of answers, show it `unavailable` in history and count it in `coverage.purged`.
|
|
34
36
|
- **Receipts**: an applied write can still report a later failure (log append, cleanup, sync). Read `applied`, `logged` and `issues` before retrying, and never repeat an applied write blindly.
|
|
35
37
|
- **Git**: each vault is its own repository. Only `vmem sync` commits or pushes, and nothing runs on a schedule.
|
|
36
38
|
|
|
@@ -43,11 +45,13 @@ Output: every command prints text for people by default, following agent-hub's C
|
|
|
43
45
|
| area | commands | reference |
|
|
44
46
|
|---|---|---|
|
|
45
47
|
| Registry and policy | `status`, `doctor`, `recover`, `vaults add\|list\|remove\|pii`, `specs add\|list\|remove` | [configuration](docs/reference/configuration.md) |
|
|
46
|
-
| Reads | `rebuild`, `search`, `show`, `links`, `brief`, `stats` | [reads](docs/reference/reads.md) |
|
|
48
|
+
| Reads | `rebuild`, `search`, `show`, `links`, `brief`, `stats`, `evidence` | [reads](docs/reference/reads.md) |
|
|
47
49
|
| Writes and log | `new`, `patch`, `append`, `frontmatter`, `link`, `supersede`, `merge`, `move`, `delete`, `check`, `report`, `tidy`, `log append\|tail\|grep` | [writes](docs/reference/writes.md) |
|
|
50
|
+
| Assertions | `assert` (append a validated batch of temporal assertions), `assertions purge` (preview, then confirm removal of one assertion's payloads) | [writes](docs/reference/writes.md#assertions) |
|
|
51
|
+
| Proposals | `proposal submit\|list\|show\|apply\|reject\|reconcile` | [writes](docs/reference/writes.md#proposals) |
|
|
48
52
|
| MCP and hosts | `mcp`, `setup`, `completion`, `manifest` | [mcp-and-setup](docs/reference/mcp-and-setup.md) |
|
|
49
53
|
| Promotion and sync | `promote-from-amem`, `promote`, `sync` | [promotion-and-sync](docs/reference/promotion-and-sync.md) |
|
|
50
|
-
| Analysis | `lint`, `graph build\|neighbors\|path`, `skills mine` | [analysis](docs/reference/analysis.md) |
|
|
54
|
+
| Analysis | `lint`, `graph build\|neighbors\|path\|explain`, `skills mine` | [analysis](docs/reference/analysis.md) |
|
|
51
55
|
| Specs | `spec get\|graph\|grep\|validate\|create\|update\|delete` | [specs](docs/reference/specs.md) |
|
|
52
56
|
|
|
53
57
|
`vmem help <command>` prints one command's syntax; `vmem manifest --json` lists the commands and MCP tools for scripts. [docs/README.md](docs/README.md) says which document to open for which task.
|
|
@@ -57,23 +61,30 @@ Output: every command prints text for people by default, following agent-hub's C
|
|
|
57
61
|
- Live cutover of an existing vault writer: outside this repository (see Status).
|
|
58
62
|
- File watching, model calls and embeddings: reads and writes are deterministic and offline.
|
|
59
63
|
- Cross-vault links: `[[x]]` always resolves inside its own vault.
|
|
64
|
+
- Evidence verification of sources outside the same vault's `notes/` (other files, other vaults, URLs, memory ids): those entries are stored and reported `unverified_external` or `unsupported`, never fetched.
|
|
60
65
|
- Scheduled or automatic sync and push.
|
|
66
|
+
- Rewriting assertion bytes out of Git history, other clones or remotes: `vmem assertions purge` removes a payload from the journal in the working tree, and complete erasure needs a history rewrite outside vmem.
|
|
61
67
|
- A resolution setting for graph communities.
|
|
62
68
|
- An event-filtered capture read for skill mining.
|
|
63
69
|
- A console bin: vault-mem ships only the plugin module for the `acon` console of [agent-console](https://github.com/STAIxBWLB/agent-console).
|
|
64
70
|
|
|
65
71
|
## Library
|
|
66
72
|
|
|
67
|
-
The only runtime dependency is the exact first-party pin <!-- facts:amem-pin -->`@staix/agent-mem@0.
|
|
73
|
+
The only runtime dependency is the exact first-party pin <!-- facts:amem-pin -->`@staix/agent-mem@0.30.0`<!-- /facts:amem-pin -->; it is not loaded by registry commands. Public library exports (`@staix/vault-mem`, from `src/index.ts`) cover configuration and home resolution, registry operations, frontmatter, link resolution and the derived index, validated writes, the append-only log, the MCP server and its vault tools, host setup, the CLI command table and completion, promotion from agent-mem and to org vaults, lint and graph analysis, sync, source references, migration tidy, the temporal assertion journal and its evaluation, and the spec source registry, graph, validation and freshness. `@staix/vault-mem/ui-plugin` is the console plugin entry (see [Console plugin](docs/reference/mcp-and-setup.md#console-plugin)). No console bin is shipped. Exported functions and constants by module:
|
|
68
74
|
<!-- facts:exports -->
|
|
69
75
|
|
|
76
|
+
- `src/assertion-read.ts`: `readAssertions`, `ASSERTIONS_PAGE_LIMIT`
|
|
70
77
|
- `src/home.ts`: `resolveHome`
|
|
71
78
|
- `src/config.ts`: `parseConfig`, `parseVault`, `parseSpec`, `readConfig`, `CONFIG_FILE`, `MAX_CONFIG_BYTES`
|
|
72
79
|
- `src/registry.ts`: `addVault`, `removeVault`, `addSpec`, `removeSpec`, `specStatus`, `loadRegistry`, `registryStatus`, `recoverRegistry`, `effectivePii`, `syncDirectory`, `LOCK_FILE`
|
|
73
80
|
- `src/frontmatter.ts`: `parseFrontmatter`, `emitFrontmatter`
|
|
74
81
|
- `src/links.ts`: `extractLinks`, `resolveLinks`, `normalizeTarget`
|
|
75
82
|
- `src/vault-index.ts`: `VaultIndex`, `MAX_NOTE_BYTES`, `MAX_RESULTS`, `MAX_READ_BYTES`
|
|
83
|
+
- `src/vault-history.ts`: `readHistory`, `readRevision`, `readChanges`, `historyText`, `revisionText`, `changesText`, `HISTORY_PAGE_LIMIT`, `HISTORY_SCAN_LIMIT`, `CHANGES_PAGE_LIMIT`, `SNAPSHOT_TRANSPORT_BYTES`
|
|
84
|
+
- `src/assertions.ts`: `readJournal`, `verifySegment`, `evaluateAssertions`, `asOfCutoff`, `appendAssertions`, `purgeAssertions`, `assertFrameBytes`, `ASSERTIONS_DIR`, `ASSERTIONS_LOCK`, `ASSERTION_SCHEMA_VERSION`, `ASSERT_FRAME_BYTES`, `MAX_BATCH_OPS`, `PURGE_LIST_LIMIT`
|
|
85
|
+
- `src/assertion-exposure.ts`: `scanAssertionExposure`, `writeReplaceFile`, `EXPOSURE_COMMIT_BUDGET`, `EXPOSURE_BLOB_BYTES`, `EXPOSURE_COMMIT_BYTES`, `EXPOSURE_FRAME_BYTES`
|
|
76
86
|
- `src/writer.ts`: `applyWrite`, `sha256`, `MUTATION_LOCK`, `MAX_WRITE_BYTES`
|
|
87
|
+
- `src/proposal-provider.ts`: `submitProposal`, `listProposals`, `showProposal`, `previewProposalApply`, `applyProposal`, `previewProposalReject`, `rejectProposal`, `reconcileProposal`, `confirmProposalReconciliation`
|
|
77
88
|
- `src/write-validation.ts`: `validateWrite`, `screenContent`
|
|
78
89
|
- `src/vault-log.ts`: `appendLog`, `readLog`, `LOG_LOCK`, `MAX_LOG_READ_BYTES`, `MAX_LOG_RESULT_BYTES`, `LARGE_LOG_LINES`
|
|
79
90
|
- `src/log-format.ts`: `formatLogEvent`, `LOG_TYPES`, `AGENT_MARKERS`
|
|
@@ -84,10 +95,12 @@ The only runtime dependency is the exact first-party pin <!-- facts:amem-pin -->
|
|
|
84
95
|
- `src/promote.ts`: `promoteFromAmem`, `listPromotionCandidates`, `draftNote`, `stemFor`, `logProjectFor`
|
|
85
96
|
- `src/vault-lint.ts`: `lintVault`
|
|
86
97
|
- `src/vault-graph.ts`: `buildGraph`, `graphNeighbors`, `graphPath`, `graphReport`
|
|
98
|
+
- `src/graph-evidence.ts`: `explainGraphPath`, `EXPLAIN_OCCURRENCES_PER_HOP`, `EXPLAIN_MAX_BYTES`
|
|
87
99
|
- `src/analysis-reports.ts`: `writeAnalysisReports`
|
|
88
100
|
- `src/org-promote.ts`: `promoteToOrg`, `screenForOrg`, `dropUnresolvedLinks`, `lintPromoted`
|
|
89
101
|
- `src/sync.ts`: `syncVault`, `sameRemote`
|
|
90
102
|
- `src/source.ts`: `normalizeSource`, `sourceReferences`
|
|
103
|
+
- `src/evidence.ts`: `evidenceReport`, `verifyNoteEvidence`, `verifyEvidenceEntry`, `parseEvidence`, `evidenceProblem`, `screenEvidenceForTarget`, `EVIDENCE_SCHEMA_VERSION`
|
|
91
104
|
- `src/tidy.ts`: `tidyVault`, `parseTidyMap`, `TIDY_RULES`
|
|
92
105
|
- `src/spec-source.ts`: `resolveSpecWorktree`, `discoverSpecs`, `SpecIndex`
|
|
93
106
|
- `src/spec-graph.ts`: `buildSpecGraph`, `specSlice`, `SPEC_EDGE_KINDS`, `MAX_SPEC_INPUTS`, `MAX_SPEC_EDGES`
|
|
@@ -104,4 +117,4 @@ bun bin/vmem.js --help # run from a checkout
|
|
|
104
117
|
bun run check
|
|
105
118
|
```
|
|
106
119
|
|
|
107
|
-
`bun run check` needs Bun, git and tar: strict types, import boundaries, README facts, documentation freshness, tests, a package dry-run and a clean installed CLI/MCP smoke (the tarball install needs network access to resolve the pinned dependency). Node/npm are used only by the release workflow. CI runs on Ubuntu
|
|
120
|
+
`bun run check` needs Bun, git and tar: strict types, import boundaries, README facts, documentation freshness, tests, a package dry-run and a clean installed CLI/MCP smoke (the tarball install needs network access to resolve the pinned dependency). Node/npm are used only by the release workflow. CI runs on Ubuntu for pull requests (macOS too when the `ci:macos` label is added), and on Ubuntu and macOS for pushes to `main` and releases. Generated facts blocks in README.md and docs/reference change only through `bun scripts/readme-facts.ts --write`. Contributor rules are in [AGENTS.md](AGENTS.md) and [REVIEW.md](REVIEW.md); release gates in [docs/release-readiness.md](docs/release-readiness.md).
|
package/bin/vmem.js
CHANGED
|
@@ -4,13 +4,13 @@ if (!version || Number(version[1]) < 1 || (Number(version[1]) === 1 && (Number(v
|
|
|
4
4
|
console.error("vmem: Bun >=1.4.2 is required. Install Bun: https://bun.sh");
|
|
5
5
|
process.exit(1);
|
|
6
6
|
}
|
|
7
|
-
const { main, mainAsync, runMcp } = await import("../src/cli.ts");
|
|
7
|
+
const { main, mainAsync, reportError, runMcp } = await import("../src/cli.ts");
|
|
8
8
|
const { resolveColor, takeColorFlag } = await import("../src/text-output.ts");
|
|
9
9
|
const argv = process.argv.slice(2);
|
|
10
10
|
// `--color=` may stand anywhere, so the dispatch looks at the words without it; main/mainAsync take it off again.
|
|
11
11
|
let words;
|
|
12
12
|
try { const taken = takeColorFlag(argv); resolveColor(taken.color, { isTTY: false }); words = taken.args; }
|
|
13
|
-
catch (error) {
|
|
13
|
+
catch (error) { process.exit(reportError(error, argv)); }
|
|
14
14
|
if (words.length === 1 && words[0] === "mcp") {
|
|
15
15
|
try { await runMcp(); }
|
|
16
16
|
catch (error) { console.error(`vmem mcp: ${error instanceof Error ? error.message : "failed"}`); process.exitCode = 1; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@staix/vault-mem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Validated Obsidian-compatible knowledge vaults for agents and people",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"bun": ">=1.4.2"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@staix/agent-mem": "0.
|
|
15
|
+
"@staix/agent-mem": "0.30.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@staix/agent-console": "github:STAIxBWLB/agent-console#c978b31",
|
package/src/analysis-commands.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { analysisInput } from "./analysis-input.ts";
|
|
2
2
|
import { lintDetails } from "./vault-lint.ts";
|
|
3
|
-
import { analysisWriteText, lintText, neighborsText, pathText } from "./read-output.ts";
|
|
3
|
+
import { analysisWriteText, explainText, lintText, neighborsText, pathText } from "./read-output.ts";
|
|
4
4
|
import { buildGraph, graphNeighbors, graphPath } from "./vault-graph.ts";
|
|
5
|
+
import { explainGraphPath } from "./graph-evidence.ts";
|
|
5
6
|
import { writeAnalysisReports } from "./analysis-reports.ts";
|
|
6
|
-
import { PLAIN, type TextOptions } from "./text-output.ts";
|
|
7
|
+
import { PLAIN, UsageError, type TextOptions } from "./text-output.ts";
|
|
7
8
|
|
|
8
9
|
const OPTION_SCOPE: Record<string, string> = {
|
|
9
|
-
"--hops": "graph neighbors", "--limit": "graph neighbors", "--relation": "graph neighbors and graph
|
|
10
|
+
"--hops": "graph neighbors", "--limit": "graph neighbors", "--relation": "graph neighbors, graph path and graph explain", "--max-hops": "graph path and graph explain", "--via-hubs": "graph path and graph explain",
|
|
10
11
|
"--note": "lint", "--write": "lint", "--workspace": "graph build", "--dry-run": "lint --write and graph build",
|
|
11
12
|
};
|
|
12
13
|
export function runAnalysisCommand(command: string, args: string[], home: string, env: NodeJS.ProcessEnv = process.env, text: TextOptions = PLAIN): { text: string; code: number } {
|
|
@@ -14,17 +15,17 @@ export function runAnalysisCommand(command: string, args: string[], home: string
|
|
|
14
15
|
for (let i=0;i<args.length;i++) {
|
|
15
16
|
const word = args[i]!;
|
|
16
17
|
if (!word.startsWith("-")) { positional.push(word); continue; }
|
|
17
|
-
if (word in values || flags.has(word)) throw new
|
|
18
|
+
if (word in values || flags.has(word)) throw new UsageError("analysis: repeated option");
|
|
18
19
|
if (["--json","--dry-run","--write","--workspace","--via-hubs"].includes(word)) flags.add(word);
|
|
19
|
-
else if (["--note","--hops","--limit","--relation","--max-hops"].includes(word)) { const value = args[++i]; if (!value || value.startsWith("--")) throw new
|
|
20
|
-
else throw new
|
|
20
|
+
else if (["--note","--hops","--limit","--relation","--max-hops"].includes(word)) { const value = args[++i]; if (!value || value.startsWith("--")) throw new UsageError(`${word}: requires value`); values[word]=value; }
|
|
21
|
+
else throw new UsageError(`analysis: unknown option ${word}`);
|
|
21
22
|
}
|
|
22
23
|
// An option the subcommand does not take is named with where it applies, before any positional check.
|
|
23
24
|
const subcommand = command === "lint" ? "lint" : `graph ${positional[0] ?? ""}`.trim();
|
|
24
|
-
const accepted = command === "lint" ? ["--json", "--dry-run", "--write", "--note"] : positional[0] === "build" ? ["--json", "--dry-run", "--workspace"] : positional[0] === "neighbors" ? ["--json", "--hops", "--limit", "--relation"] : positional[0] === "path" ? ["--json", "--max-hops", "--relation", "--via-hubs"] : undefined;
|
|
25
|
-
if (accepted) for (const option of [...flags, ...Object.keys(values)]) if (!accepted.includes(option)) throw new
|
|
25
|
+
const accepted = command === "lint" ? ["--json", "--dry-run", "--write", "--note"] : positional[0] === "build" ? ["--json", "--dry-run", "--workspace"] : positional[0] === "neighbors" ? ["--json", "--hops", "--limit", "--relation"] : positional[0] === "path" || positional[0] === "explain" ? ["--json", "--max-hops", "--relation", "--via-hubs"] : undefined;
|
|
26
|
+
if (accepted) for (const option of [...flags, ...Object.keys(values)]) if (!accepted.includes(option)) throw new UsageError(`${subcommand}: ${option} applies only to ${OPTION_SCOPE[option]}`);
|
|
26
27
|
if (command === "lint") {
|
|
27
|
-
if (positional.length !== 1) throw new
|
|
28
|
+
if (positional.length !== 1) throw new UsageError("lint: requires one vault id");
|
|
28
29
|
if (flags.has("--write")) { const result = writeAnalysisReports(home,{vault:positional[0]!,kind:"lint",note:values["--note"],dryRun:flags.has("--dry-run")},env); return {text:flags.has("--json") ? JSON.stringify(result) : analysisWriteText(result,text,{kind:"lint",dryRun:flags.has("--dry-run")}),code:result.ok && (result.summary as {errors?:number}).errors === 0 ? 0 : 1}; }
|
|
29
30
|
const {snapshot} = analysisInput(home,positional[0]!,{hints:true});
|
|
30
31
|
const details = lintDetails(snapshot,values["--note"]), report = details.report;
|
|
@@ -32,22 +33,31 @@ export function runAnalysisCommand(command: string, args: string[], home: string
|
|
|
32
33
|
}
|
|
33
34
|
const action = positional.shift();
|
|
34
35
|
if (action === "build") {
|
|
35
|
-
if (positional.length !== 1) throw new
|
|
36
|
+
if (positional.length !== 1) throw new UsageError("graph build: requires one vault id");
|
|
36
37
|
const result = writeAnalysisReports(home,{vault:positional[0]!,kind:"graph",workspace:flags.has("--workspace"),dryRun:flags.has("--dry-run")},env);
|
|
37
38
|
return {text:flags.has("--json") ? JSON.stringify(result) : analysisWriteText(result,text,{kind:"graph",dryRun:flags.has("--dry-run")}),code:result.ok ? 0 : 1};
|
|
38
39
|
}
|
|
40
|
+
if (action === "explain") {
|
|
41
|
+
if (positional.length !== 3) throw new UsageError("graph explain: requires <vault> <from> <to>");
|
|
42
|
+
const maxHops = Number(values["--max-hops"] ?? 6);
|
|
43
|
+
if (!Number.isInteger(maxHops) || maxHops < 1 || maxHops > 6) throw new UsageError("graph explain: max hops 1..6");
|
|
44
|
+
const {snapshot} = analysisInput(home,positional[0]!);
|
|
45
|
+
const viaHubs = flags.has("--via-hubs"), relation = values["--relation"];
|
|
46
|
+
const result = explainGraphPath(snapshot,positional[1]!,positional[2]!,{maxHops,viaHubs,...(relation === undefined ? {} : {relation})});
|
|
47
|
+
return {text:flags.has("--json") ? JSON.stringify(result) : explainText(result,text,{vault:positional[0]!}),code:0};
|
|
48
|
+
}
|
|
39
49
|
if (action === "path") {
|
|
40
|
-
if (positional.length !== 3) throw new
|
|
50
|
+
if (positional.length !== 3) throw new UsageError("graph path: requires <vault> <from> <to>");
|
|
41
51
|
const maxHops = Number(values["--max-hops"] ?? 6);
|
|
42
|
-
if (!Number.isInteger(maxHops) || maxHops < 1 || maxHops > 6) throw new
|
|
52
|
+
if (!Number.isInteger(maxHops) || maxHops < 1 || maxHops > 6) throw new UsageError("graph path: max hops 1..6");
|
|
43
53
|
const {snapshot} = analysisInput(home,positional[0]!);
|
|
44
54
|
const viaHubs = flags.has("--via-hubs"), relation = values["--relation"];
|
|
45
55
|
const result = graphPath(buildGraph(snapshot),positional[1]!,positional[2]!,{maxHops,viaHubs,...(relation === undefined ? {} : {relation})});
|
|
46
56
|
return {text:flags.has("--json") ? JSON.stringify(result) : pathText(result,text,{vault:positional[0]!,maxHops,viaHubs,relation}),code:0};
|
|
47
57
|
}
|
|
48
|
-
if (action !== "neighbors" || positional.length !== 2) throw new
|
|
58
|
+
if (action !== "neighbors" || positional.length !== 2) throw new UsageError("graph: use build <vault>, neighbors <vault> <stem>, path <vault> <from> <to> or explain <vault> <from> <to>");
|
|
49
59
|
const hops = Number(values["--hops"] ?? 1), limit = Number(values["--limit"] ?? 50);
|
|
50
|
-
if ((hops !== 1 && hops !== 2) || !Number.isInteger(limit) || limit < 1 || limit > 500) throw new
|
|
60
|
+
if ((hops !== 1 && hops !== 2) || !Number.isInteger(limit) || limit < 1 || limit > 500) throw new UsageError("graph neighbors: hops 1..2, limit 1..500");
|
|
51
61
|
const {snapshot} = analysisInput(home,positional[0]!);
|
|
52
62
|
const result = graphNeighbors(buildGraph(snapshot),positional[1]!,hops,limit,values["--relation"]);
|
|
53
63
|
return {text:flags.has("--json") ? JSON.stringify(result) : neighborsText(result,text,{vault:positional[0]!,limit,relation:values["--relation"]}),code:0};
|
package/src/analysis-input.ts
CHANGED
|
@@ -10,6 +10,8 @@ import type { AnalysisSnapshot } from "./analysis-types.ts";
|
|
|
10
10
|
import { deadLinkScan } from "./vault-lint.ts";
|
|
11
11
|
import type { TitleSuggestion } from "./links.ts";
|
|
12
12
|
import { canonicalPath, isDenied } from "./platform.ts";
|
|
13
|
+
import { verifyNoteEvidence, type EvidenceReads } from "./evidence.ts";
|
|
14
|
+
import { sourceAgeFindings } from "./source-age.ts";
|
|
13
15
|
import { loadRegistry } from "./registry.ts";
|
|
14
16
|
import { VaultIndex } from "./vault-index.ts";
|
|
15
17
|
/** Largest auxiliary input one read takes, and the default bound of `analysisRead` and `analysisReadWithSize`. */
|
|
@@ -90,6 +92,16 @@ export function analysisInput(home: string, id: string, options: { today?: strin
|
|
|
90
92
|
if(found.length)warnings[note.path]=found;
|
|
91
93
|
}catch{ /* Invalid frontmatter remains visible to L02; do not infer missing source paths. */ }
|
|
92
94
|
if(Object.keys(warnings).length)snapshot.sourceWarnings=warnings;
|
|
95
|
+
// Evidence drift is a read/lint finding: status and reason only, never the quote or source text.
|
|
96
|
+
const drift:Record<string,string[]>=Object.create(null),reads:EvidenceReads=new Map();
|
|
97
|
+
for(const note of snapshot.notes)try{
|
|
98
|
+
const data=parseFrontmatter(note.source).data;if(data.evidence===undefined)continue;
|
|
99
|
+
const found=verifyNoteEvidence(vault,data,config.denyPaths??[],reads).filter(r=>r.status!=="verified"&&r.status!=="unverified_external").map(r=>`evidence[${r.index}] ${r.status}${r.reason?` (${r.reason})`:""}`);
|
|
100
|
+
if(found.length)drift[note.path]=found;
|
|
101
|
+
}catch{ /* Invalid frontmatter remains visible to L02. */ }
|
|
102
|
+
if(Object.keys(drift).length)snapshot.evidenceWarnings=drift;
|
|
103
|
+
// L17 runs git, so only lint (the hint pass) pays for it; graph reads never do.
|
|
104
|
+
if(options.hints&&sourceRoot)snapshot.sourceAge=sourceAgeFindings(snapshot.notes,sourceRoot,config.denyPaths??[]);
|
|
93
105
|
if(options.hints){
|
|
94
106
|
// A null prototype keeps the link text `__proto__` a stored key: on a plain object it would set the prototype,
|
|
95
107
|
// drop the hint and leave the object answering inherited members.
|
package/src/analysis-types.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface AnalysisSnapshot {
|
|
|
11
11
|
reports: Record<string, string>;
|
|
12
12
|
/** Bounded auxiliary source-path existence warnings captured outside the pure lint transform. */
|
|
13
13
|
sourceWarnings?: Record<string,string[]>;
|
|
14
|
+
/** Evidence entries that are not verified (status and reason only), keyed by note path relative to notes/. */
|
|
15
|
+
evidenceWarnings?: Record<string,string[]>;
|
|
16
|
+
/** L17 input: notes whose workspace source changed after their `updated` date, plus the unknown-age and skipped counts. */
|
|
17
|
+
sourceAge?: { findings: Record<string,string[]>; unknownAge: number; skipped: number; gitUnavailable?: string };
|
|
14
18
|
/**
|
|
15
19
|
* At most one title hint per dead link text, captured with an open index outside the pure lint transform.
|
|
16
20
|
* Link text is arbitrary (`__proto__` included), so a producer stores it in a null-prototype record and a reader
|
|
@@ -23,7 +27,7 @@ export interface AnalysisSnapshot {
|
|
|
23
27
|
*/
|
|
24
28
|
linkHintBound?: { cap: number; attempted: readonly string[]; skipped: number };
|
|
25
29
|
}
|
|
26
|
-
export type LintCode = "L01" | "L02" | "L03" | "L09" | "L10" | "L11" | "L12" | "L13" | "L14" | "L15";
|
|
30
|
+
export type LintCode = "L01" | "L02" | "L03" | "L09" | "L10" | "L11" | "L12" | "L13" | "L14" | "L15" | "L16" | "L17";
|
|
27
31
|
export interface LintReport {
|
|
28
32
|
findings: Record<LintCode, string[]>;
|
|
29
33
|
errors: number;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** `vmem assert <vault> --batch FILE|- [--dry-run] [--log JSON] [--json]`: one implementation shared with `vmem_assert`. */
|
|
2
|
+
import { appendAssertions, type AssertReceipt } from "./assertions.ts";
|
|
3
|
+
import { argumentError } from "./mcp.ts";
|
|
4
|
+
import { LOG_EVENT_SCHEMA } from "./log-format.ts";
|
|
5
|
+
import type { LogEvent } from "./log-types.ts";
|
|
6
|
+
import { input } from "./write-commands.ts";
|
|
7
|
+
import { blocks, clean, issueTable, paint, plural, status, table, PLAIN, UsageError, type TextOptions } from "./text-output.ts";
|
|
8
|
+
|
|
9
|
+
export function assertText(r: AssertReceipt, o: TextOptions, c: { vault: string }): string {
|
|
10
|
+
const ops = plural(r.entries.length, "operation");
|
|
11
|
+
const head = r.dryRun
|
|
12
|
+
? (r.ok ? status("ok", `dry run: ${ops} valid for ${clean(c.vault)}; nothing appended`, o) : status("fail", `assert: dry run refused, nothing appended to ${clean(c.vault)}`, o))
|
|
13
|
+
: r.applied
|
|
14
|
+
? (r.ok ? status("ok", `appended ${ops} to ${clean(c.vault)} segment ${r.segment} at ${r.recordedAt}`, o)
|
|
15
|
+
: status("fail", `${ops} appended to ${clean(c.vault)} segment ${r.segment}, but a later step failed; inspect the segment and the writer record before appending again`, o))
|
|
16
|
+
: status("fail", `assert: refused, nothing appended to ${clean(c.vault)}`, o);
|
|
17
|
+
const rows = r.entries.length ? table(["SEQ", "OP", "ID", "REV", "HASH"], r.entries.map(e => [e.seq ?? "-", e.op, e.id, e.rev ?? "-", e.hash ? e.hash.slice(0, 12) : "-"]), o) : undefined;
|
|
18
|
+
const recovery = r.recovery.length ? ["recovery:", ...r.recovery.map(note => ` - ${clean(note)}`)].join("\n") : undefined;
|
|
19
|
+
const log = r.log ? (r.log.ok ? status("ok", "log: appended", o) : blocks(status("fail", "log: not appended", o), issueTable(r.log.issues, o))) : undefined;
|
|
20
|
+
return blocks(head, rows, recovery && paint(recovery, "hint", o), issueTable(r.issues, o), log);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function runAssertCommand(args: string[], home: string, env: NodeJS.ProcessEnv = process.env, text: TextOptions = PLAIN): { text: string; code: number } {
|
|
24
|
+
const positional: string[] = [], flags: Record<string, string | boolean> = {};
|
|
25
|
+
for (let i = 0; i < args.length; i++) {
|
|
26
|
+
const word = args[i]!;
|
|
27
|
+
if (!word.startsWith("--") || word === "-") { positional.push(word); continue; }
|
|
28
|
+
if (Object.hasOwn(flags, word) || !["--batch", "--log", "--dry-run", "--json"].includes(word)) throw new UsageError(`assert: unknown or repeated option: ${word}`);
|
|
29
|
+
if (word === "--dry-run" || word === "--json") { flags[word] = true; continue; }
|
|
30
|
+
const value = args[++i];
|
|
31
|
+
if (value === undefined || (value.startsWith("--") && value !== "-")) throw new UsageError(`${word}: value required`);
|
|
32
|
+
flags[word] = value;
|
|
33
|
+
}
|
|
34
|
+
if (positional.length !== 1) throw new UsageError("assert: requires one vault id; usage: vmem assert <vault> --batch FILE|-");
|
|
35
|
+
if (typeof flags["--batch"] !== "string") throw new UsageError("assert: --batch FILE|- is required; pass a JSON file {\"ops\": [...]} or - for stdin");
|
|
36
|
+
let batch: unknown;
|
|
37
|
+
try { batch = JSON.parse(input(flags["--batch"], home)); } catch (caught) { throw caught instanceof UsageError ? caught : new UsageError(`--batch: ${caught instanceof SyntaxError ? "invalid JSON" : (caught as Error).message}; expected {"ops": [...]}`); }
|
|
38
|
+
if (!batch || typeof batch !== "object" || Array.isArray(batch) || Object.keys(batch).some(key => key !== "ops")) throw new UsageError("--batch: expected a JSON object {\"ops\": [...]} with no other keys; send one object holding the operation list");
|
|
39
|
+
let log: LogEvent | undefined;
|
|
40
|
+
if (typeof flags["--log"] === "string") {
|
|
41
|
+
try { log = JSON.parse(flags["--log"]) as LogEvent; } catch { throw new UsageError("--log: invalid JSON; pass one JSON log event object"); }
|
|
42
|
+
const problem = argumentError(log, LOG_EVENT_SCHEMA, "--log");
|
|
43
|
+
if (problem) throw new UsageError(`${problem}; expected {"type", "project", "source", "note"[, "dest"]} as for log append`);
|
|
44
|
+
}
|
|
45
|
+
const vault = positional[0]!;
|
|
46
|
+
const receipt = appendAssertions(home, { vault, ops: (batch as { ops: unknown }).ops, channel: "cli", dryRun: flags["--dry-run"] === true, ...(log ? { log } : {}) }, { env });
|
|
47
|
+
return { text: flags["--json"] ? JSON.stringify(receipt) : assertText(receipt, text, { vault }), code: receipt.ok && receipt.log?.ok !== false ? 0 : 1 };
|
|
48
|
+
}
|