@jc_stack/ez-library 0.1.0-beta.12
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/.dockerignore +12 -0
- package/.github/workflows/publish-beta.yml +40 -0
- package/CHANGELOG.md +57 -0
- package/CONTRIBUTING.md +89 -0
- package/Dockerfile +38 -0
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/SECURITY.md +13 -0
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/bin/ez-library.mjs +3 -0
- package/docker/fulltext-smoke.mjs +19 -0
- package/docker/github-smoke.mjs +114 -0
- package/docker/manager-smoke.mjs +53 -0
- package/docker/pnpm-lock.yaml +1443 -0
- package/docker/shared-smoke.mjs +81 -0
- package/docker/smoke.mjs +73 -0
- package/docker/sync-smoke.mjs +98 -0
- package/docker/text-mirror-smoke.mjs +42 -0
- package/docs/folder-sync.md +100 -0
- package/docs/github-sync.md +105 -0
- package/docs/named-libraries.md +75 -0
- package/docs/persistence.md +48 -0
- package/docs/rclone-LICENSE.txt +19 -0
- package/docs/releasing.md +74 -0
- package/docs/shared-embeddings.md +15 -0
- package/docs/text-mirror.md +54 -0
- package/ez-deployment.json +53 -0
- package/ez-plugin.json +15 -0
- package/package.json +69 -0
- package/patches/@tobilu__qmd@2.8.3.patch +60 -0
- package/scripts/publish-settings.mjs +101 -0
- package/scripts/release-check.mjs +16 -0
- package/skills/library/SKILL.md +104 -0
- package/src/cli.mjs +227 -0
- package/src/embedding-client.mjs +50 -0
- package/src/embedding-worker.mjs +59 -0
- package/src/git-mirror.mjs +121 -0
- package/src/git-sync.mjs +140 -0
- package/src/indexer.mjs +83 -0
- package/src/libraries.mjs +81 -0
- package/src/native.mjs +47 -0
- package/src/store.mjs +214 -0
- package/src/sync-worker.mjs +43 -0
- package/src/sync.mjs +172 -0
- package/test/embeddings.test.mjs +30 -0
- package/test/git-mirror.test.mjs +121 -0
- package/test/git-sync.test.mjs +135 -0
- package/test/indexer.test.mjs +73 -0
- package/test/libraries.test.mjs +132 -0
- package/test/library.test.mjs +163 -0
- package/test/publish-settings.test.mjs +101 -0
- package/test/sync.test.mjs +120 -0
package/.dockerignore
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Generated by scripts/generate-publish-caller.mjs; review changes before merging.
|
|
2
|
+
name: Publish verified npm beta
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
release-id:
|
|
7
|
+
description: 'Numeric ID of the staged draft prerelease'
|
|
8
|
+
required: true
|
|
9
|
+
type: string
|
|
10
|
+
version:
|
|
11
|
+
description: 'Reviewed beta version staged as draft release vVERSION'
|
|
12
|
+
required: true
|
|
13
|
+
type: string
|
|
14
|
+
source-sha:
|
|
15
|
+
description: 'Full tested commit SHA; must be current main'
|
|
16
|
+
required: true
|
|
17
|
+
type: string
|
|
18
|
+
artifact-sha256:
|
|
19
|
+
description: 'SHA-256 of the exact independently verified candidate.tgz'
|
|
20
|
+
required: true
|
|
21
|
+
type: string
|
|
22
|
+
permissions: {}
|
|
23
|
+
jobs:
|
|
24
|
+
publish:
|
|
25
|
+
if: github.repository == 'jdorado/ez-library' && github.ref == 'refs/heads/main'
|
|
26
|
+
permissions:
|
|
27
|
+
contents: write
|
|
28
|
+
checks: read
|
|
29
|
+
actions: read
|
|
30
|
+
pull-requests: read
|
|
31
|
+
id-token: write
|
|
32
|
+
uses: jdorado/ez-agents/.github/workflows/npm-beta-shared.yml@fed05b9c88a5d96a801436a36983254758f03389
|
|
33
|
+
with:
|
|
34
|
+
package: '@jc_stack/ez-library'
|
|
35
|
+
publisher-sha: 'fed05b9c88a5d96a801436a36983254758f03389'
|
|
36
|
+
required-checks: '["verify (22)","verify (24)","docker"]'
|
|
37
|
+
release-id: ${{ inputs.release-id }}
|
|
38
|
+
version: ${{ inputs.version }}
|
|
39
|
+
source-sha: ${{ inputs.source-sha }}
|
|
40
|
+
artifact-sha256: ${{ inputs.artifact-sha256 }}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-beta.12
|
|
4
|
+
|
|
5
|
+
- Prepare a new release with npm publishing-settings verification included. Package trust and registry delivery are verified separately from local release checks.
|
|
6
|
+
|
|
7
|
+
## 0.1.0-beta.11
|
|
8
|
+
|
|
9
|
+
- Prepare the initial public release with the corrected shared publisher. Include reviewed named libraries, Git text history and shared embedding support; requires schema-3-capable core beta.15 or newer.
|
|
10
|
+
- Testing beta; previously documented live-provider and fresh-host acceptance limits remain.
|
|
11
|
+
|
|
12
|
+
## 0.1.0-beta.10
|
|
13
|
+
|
|
14
|
+
- Opt-in shared embedding worker, capped at half a CPU core, with private per-agent indexes.
|
|
15
|
+
- Schema-3 manager support is required. Migration preserves the existing Library volume and compatible QMD vectors; deployment layout changes require explicit installation migration.
|
|
16
|
+
|
|
17
|
+
- Add one-way GitHub text history after successful folder sync, preserving Drive as the editable workspace.
|
|
18
|
+
|
|
19
|
+
- Respect global and per-library keyword-only indexing settings while keeping embeddings off until shared-worker enablement.
|
|
20
|
+
- Reject local Git sources inside any Library state, including symlink aliases.
|
|
21
|
+
- Add isolated named libraries, explicit command selection, source inventory and labelled cross-library QMD keyword search. Preserve existing state as default.
|
|
22
|
+
|
|
23
|
+
## 0.1.0-beta.6 — unreleased
|
|
24
|
+
|
|
25
|
+
- Add native GitHub-only two-way sync, remote commit verification and automatic QMD/PDF refresh.
|
|
26
|
+
- Bootstrap repository-specific SSH deploy keys through an already connected GitHub plugin; keep OAuth credentials in that provider.
|
|
27
|
+
- Retain native Git merge stages and pause on conflicts, unsupported trees, ignored originals or changed storage policy.
|
|
28
|
+
- Add isolated-branch live GitHub smoke coverage; existing Hybrid settings remain unchanged.
|
|
29
|
+
|
|
30
|
+
## 0.1.0-beta.5 — unreleased
|
|
31
|
+
|
|
32
|
+
- Adopt an existing folder with native rclone bisync, persistent binding/receipts, conflicts preserved and deletion safeguards.
|
|
33
|
+
- Supervise enabled sync every 60 seconds and refresh PDF extraction, QMD search and embeddings after changes.
|
|
34
|
+
- Add revision-guarded move/remove operations for agent organization, with recovery bytes and task-accessible receipts.
|
|
35
|
+
- Keep native connection consent explicit; GitHub/Hybrid automatic synchronization and OCR remain unsupported.
|
|
36
|
+
|
|
37
|
+
## 0.1.0-beta.4 — unreleased
|
|
38
|
+
|
|
39
|
+
- Default remote persistence to browsable ordinary files and stable paths, never archive workarounds.
|
|
40
|
+
- Clarify immediate save-batch mirroring, conflict preservation and the boundary to native continuous/two-way sync engines.
|
|
41
|
+
|
|
42
|
+
## 0.1.0-beta.3 — unreleased
|
|
43
|
+
|
|
44
|
+
- Interpret enabled provider backup as initial sync plus backup after each agent save; do not invent daily schedules.
|
|
45
|
+
- Document durable pending transfers, destination reuse and workspace routing for future intake.
|
|
46
|
+
|
|
47
|
+
## 0.1.0-beta.2 — unreleased
|
|
48
|
+
|
|
49
|
+
- Default owner attachment intake to preservation and verified indexing through the agent skill.
|
|
50
|
+
- Bundle native Poppler PDF text extraction with source/page-linked derived notes.
|
|
51
|
+
|
|
52
|
+
## 0.1.0-beta.1 — unreleased
|
|
53
|
+
|
|
54
|
+
- Introduce a separate Dockerized Library CLI and native QMD 2.8.3 command access.
|
|
55
|
+
- Store files with revision preconditions, operation keys, exact readback and local previous revisions.
|
|
56
|
+
- Add explicit Local, Drive, GitHub and Hybrid persistence settings, independently configured external backup intent.
|
|
57
|
+
- Package agent instructions for provider-owned persistence. Remote transfers, background sync, OCR and cloud restore verification are not implemented by this plugin.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Agent-owned shipping
|
|
4
|
+
|
|
5
|
+
The maintainer's request authorizes the requested work and its normal
|
|
6
|
+
implementation steps; never ask for approval of the same work again. The agent
|
|
7
|
+
owns implementation, proportional tests, independent review, repairs, package
|
|
8
|
+
verification and release preparation. Once gates pass, carry out the requested
|
|
9
|
+
merge/release and verify registry, artifact and runtime readback. Report versions,
|
|
10
|
+
channel, checks and material limits; reuse valid evidence and batch dependent
|
|
11
|
+
packages. Do not ask the maintainer to operate engineering tools. Merge-only
|
|
12
|
+
requests do not imply publication or private-package visibility changes; release
|
|
13
|
+
requests already authorize release. If shipping was not requested, report
|
|
14
|
+
readiness without publishing. Escalate only an unavoidable external requirement,
|
|
15
|
+
unrepairable gate, product decision or material scope change.
|
|
16
|
+
|
|
17
|
+
## Contribution checks
|
|
18
|
+
|
|
19
|
+
Humans, LLM agents and maintainers use the same small-PR process. Read AGENTS.md
|
|
20
|
+
and the relevant CLI help first. Open an issue for substantial scope changes;
|
|
21
|
+
small fixes need no proposal. Internal plans and private QA belong outside this
|
|
22
|
+
repository. Public docs describe shipped behavior and explicit limitations.
|
|
23
|
+
|
|
24
|
+
1. Fork/branch from main and make one coherent change. Preserve unrelated work.
|
|
25
|
+
2. Install Node 22+ and pnpm 10.30.3. Run `pnpm install --frozen-lockfile`.
|
|
26
|
+
3. Change the code, user instructions and focused tests together. Authority,
|
|
27
|
+
paths, credentials, cancellation and uncertain writes need negative tests.
|
|
28
|
+
4. Run `pnpm verify`, `npm run release:check` and `git diff --check`.
|
|
29
|
+
Packaging/runtime changes also need the Docker checks in docs/releasing.md.
|
|
30
|
+
5. Open a PR explaining the problem, resulting behavior, verification and limits.
|
|
31
|
+
Include a short sanitized reproduction. State which tests were not run.
|
|
32
|
+
6. A maintainer reviews and merges after CI. Maintainers use PRs too. No CLA,
|
|
33
|
+
ticket requirement, custom commit format or additional approval committee.
|
|
34
|
+
|
|
35
|
+
You are responsible for understanding submitted code, including AI-generated
|
|
36
|
+
code, and having the right to contribute it under this repository's license.
|
|
37
|
+
Do not upload conversation dumps, credentials, QR codes or customer records.
|
|
38
|
+
Installation authority alone does not authorize messaging another person.
|
|
39
|
+
Use synthetic providers for routine tests; live tests need a dedicated account
|
|
40
|
+
and explicit recipient authority. A process exit is not provider delivery proof.
|
|
41
|
+
|
|
42
|
+
Report bugs through a GitHub issue with version, OS, Node/Docker versions,
|
|
43
|
+
minimal steps, expected/actual behavior and sanitized output. Feature requests
|
|
44
|
+
should explain the user problem and a small acceptance example. Security reports
|
|
45
|
+
follow SECURITY.md. Release and new-plugin requirements: docs/releasing.md and
|
|
46
|
+
docs/plugin-contributions.md.
|
|
47
|
+
|
|
48
|
+
## Isolated work and review
|
|
49
|
+
|
|
50
|
+
- One coherent change, one branch, one dedicated Git worktree, one PR per
|
|
51
|
+
repository. Create the worktree from freshly fetched origin/main before edits.
|
|
52
|
+
Never develop on main or switch branches in another task's checkout.
|
|
53
|
+
- Inspect git status and git worktree list first. Reuse a worktree only for the
|
|
54
|
+
same task. Preserve other work; never stash, reset or commit another task's
|
|
55
|
+
files. Stage explicit paths or hunks and review the staged diff before committing.
|
|
56
|
+
- Keep worktrees outside the published package. Each task installs its own
|
|
57
|
+
dependencies and uses separate test state, ports and Docker project names.
|
|
58
|
+
Never share live bot tokens or provider profiles between test instances.
|
|
59
|
+
- Keep unrelated fixes/features in separate PRs. For work spanning repositories,
|
|
60
|
+
create one worktree/PR per repository and link dependencies and merge order.
|
|
61
|
+
Branch from an unmerged feature only when the dependency is intentional and
|
|
62
|
+
documented; do not quietly include it in an unrelated PR.
|
|
63
|
+
- Open a draft PR when the change is reviewable. Report its scope, exact commit,
|
|
64
|
+
validation and remaining QA. A completed coding task can remain a draft;
|
|
65
|
+
implementation completion does not authorize merge or npm publication.
|
|
66
|
+
- Before merge, obtain an independent human or agent review of the final diff.
|
|
67
|
+
The implementer's self-check and passing CI are not independent review.
|
|
68
|
+
Reviewers inspect correctness, architecture, state/permissions and negative
|
|
69
|
+
cases. Record reviewer identity/session, reviewed commit, findings and resolution
|
|
70
|
+
in the PR. If review is unavailable, leave it explicitly pending.
|
|
71
|
+
- New substantive commits or conflict resolutions invalidate the affected review
|
|
72
|
+
and test evidence. Refresh against current main, review the resulting diff and
|
|
73
|
+
run the applicable checks. Do not bypass protected-branch requirements.
|
|
74
|
+
- Merge only after review, required CI, applicable QA and maintainer authorization.
|
|
75
|
+
Publish only under the separate release process; commits and merges are not
|
|
76
|
+
releases. Record which source commit and artifact hash were tested.
|
|
77
|
+
- Keep the worktree while its PR or QA is open. After merge or explicit abandonment,
|
|
78
|
+
inspect it for uncommitted/untracked files and local-only commits. Remove only
|
|
79
|
+
the clean task worktree after valuable work is preserved; never force cleanup.
|
|
80
|
+
Delete its branch only after confirming merge or authorized abandonment.
|
|
81
|
+
|
|
82
|
+
Example, substituting a unique task name and an absolute external directory:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
git status --short
|
|
86
|
+
git worktree list
|
|
87
|
+
git fetch origin
|
|
88
|
+
git worktree add -b feat/task-name /absolute/worktrees/task-name origin/main
|
|
89
|
+
```
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
FROM rclone/rclone:1.74.2@sha256:9ce0d49b611d3781233e25334e9e23d7af01e5546da7087f90d55f034ef13637 AS sync-engine
|
|
2
|
+
|
|
3
|
+
FROM node:22.22.0-bookworm-slim@sha256:dd9d21971ec4395903fa6143c2b9267d048ae01ca6d3ea96f16cb30df6187d94 AS test
|
|
4
|
+
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
|
|
5
|
+
COPY --from=sync-engine /usr/local/bin/rclone /usr/local/bin/rclone
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
COPY package.json ./
|
|
8
|
+
COPY src ./src
|
|
9
|
+
COPY bin ./bin
|
|
10
|
+
COPY scripts/publish-settings.mjs ./scripts/publish-settings.mjs
|
|
11
|
+
COPY test ./test
|
|
12
|
+
RUN node --test test/*.test.mjs
|
|
13
|
+
|
|
14
|
+
FROM node:22.22.0-bookworm-slim@sha256:dd9d21971ec4395903fa6143c2b9267d048ae01ca6d3ea96f16cb30df6187d94 AS runtime
|
|
15
|
+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates poppler-utils python3 make g++ cmake git openssh-client && rm -rf /var/lib/apt/lists/*
|
|
16
|
+
RUN corepack enable && corepack prepare pnpm@10.30.3 --activate
|
|
17
|
+
COPY --from=sync-engine /usr/local/bin/rclone /usr/local/bin/rclone
|
|
18
|
+
WORKDIR /app
|
|
19
|
+
COPY package.json ./
|
|
20
|
+
COPY docker/pnpm-lock.yaml ./pnpm-lock.yaml
|
|
21
|
+
COPY patches ./patches
|
|
22
|
+
RUN pnpm install --prod --frozen-lockfile
|
|
23
|
+
COPY --chown=node:node src ./src
|
|
24
|
+
COPY --chown=node:node bin ./bin
|
|
25
|
+
COPY LICENSE THIRD_PARTY_NOTICES.md ./
|
|
26
|
+
COPY docs/rclone-LICENSE.txt /usr/share/doc/rclone/copyright
|
|
27
|
+
RUN mkdir -p /state/qmd/cache/qmd/models /state/qmd/config/qmd && chown -R node:node /state && chmod 700 /state /state/qmd
|
|
28
|
+
ENV EZ_LIBRARY_STATE=/state
|
|
29
|
+
USER node
|
|
30
|
+
CMD ["node", "/app/src/sync-worker.mjs"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
FROM runtime AS embeddings
|
|
34
|
+
USER root
|
|
35
|
+
RUN mkdir -p /inference /models && chown -R node:node /inference /models && chmod 770 /inference /models
|
|
36
|
+
ENV QMD_FORCE_CPU=1 QMD_EMBED_PARALLELISM=1
|
|
37
|
+
USER node
|
|
38
|
+
CMD ["node", "/app/src/embedding-worker.mjs"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ez-library contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Ez Library
|
|
2
|
+
|
|
3
|
+
A separate Dockerized plugin for an agent's files and QMD search. Preserve original Markdown and attachments, retrieve relevant notes, and record where the agent should persist them using its existing provider tools.
|
|
4
|
+
|
|
5
|
+
**Unreleased beta.** QMD supplies search; native rclone bisync supplies explicitly enabled folder synchronization. Existing-folder adoption, automatic indexing and guarded organization are implemented. Native Drive/Dropbox connections require separate authorization and remote QA. GitHub-only sync uses native Git and a repository-specific deploy key registered through the existing GitHub plugin. Hybrid remains an agent-owned persistence policy, not an automatic sync backend. OCR and versioned cloud backup/restore are not supplied. No relay changes are required.
|
|
6
|
+
|
|
7
|
+
See [existing-folder setup and sync policy](docs/folder-sync.md) and [GitHub-only two-way sync](docs/github-sync.md).
|
|
8
|
+
|
|
9
|
+
## Multiple libraries
|
|
10
|
+
|
|
11
|
+
Use [named libraries](docs/named-libraries.md) for independent repositories or
|
|
12
|
+
folders in one installation. `sources` lists names and destinations;
|
|
13
|
+
`source-add --name work --description 'Company documentation'` creates isolated
|
|
14
|
+
local state. Add `--library work` to onboarding and file commands. Once multiple
|
|
15
|
+
libraries exist, selection is required. `search 'query' --all` returns labelled
|
|
16
|
+
QMD results. Existing files remain in `default` without migration.
|
|
17
|
+
|
|
18
|
+
For Drive/Obsidian workspaces, add [GitHub text history](docs/text-mirror.md)
|
|
19
|
+
without moving attachments or changing the working folder.
|
|
20
|
+
|
|
21
|
+
## Requirements and installation
|
|
22
|
+
|
|
23
|
+
Use Node 22+, Docker with Compose, and an initialized agent-bound Ez plugin manager supporting deployment schema 3 with service CPU limits. The runtime is capped at 2 CPU cores and 4 GiB memory; optional shared embedding inference uses a separate 2 GiB memory ceiling, roughly 300 MB of model disk and a default half-core CPU limit. GitHub/Drive are optional, separately authorized connections.
|
|
24
|
+
|
|
25
|
+
Install a reviewed checkout or extracted package using the agent's bound `ez`:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
ez plugins inspect library --source /absolute/ez-library
|
|
29
|
+
# Use the exact returned revision after reviewing that source.
|
|
30
|
+
ez plugins install library --source /absolute/ez-library --revision sha256:RETURNED_HASH
|
|
31
|
+
ez plugins start library
|
|
32
|
+
ez library --help
|
|
33
|
+
ez library doctor
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Installation snapshots/builds the package without starting it. `start`, `stop`, `status` and `uninstall` are provided by `ez plugins`. Do not start a parallel standalone deployment for an installed agent. The manifest identifies plugin `library`, command `library`, and skill `skills/library/SKILL.md`.
|
|
37
|
+
|
|
38
|
+
## Default attachment intake
|
|
39
|
+
|
|
40
|
+
With the Library skill onboarded, owner-supplied attachments are saved and indexed by default, including when the owner asks only for a summary. The agent records this routing in its workspace tool instructions during onboarding. Explicit do-not-save requests override the default. This is agent guidance, not a relay upload hook.
|
|
41
|
+
|
|
42
|
+
`ez library pdf-text --path documents/example.pdf` runs bundled Poppler and emits UTF-8 text with page breaks. The agent preserves the original, saves source-linked Markdown, refreshes QMD, and verifies retrieval. Scanned PDFs require a separate OCR tool; an archived original alone is not content indexing. Provider uploads still follow the selected settings.
|
|
43
|
+
|
|
44
|
+
## First usable library
|
|
45
|
+
|
|
46
|
+
Choose local storage initially; `settings.json` here is a temporary input file in the owning workspace:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{"schemaVersion":1,"storage":{"mode":"local"},"backup":{"mode":"off"}}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
ez library configure --expected new --key setup-local-1 < settings.json
|
|
54
|
+
printf '# Travel checklist\n\nPassport, charger and toothbrush.\n' | ez library put --path notes/travel.md --expected new --key travel-1
|
|
55
|
+
ez library get --path notes/travel.md
|
|
56
|
+
ez library qmd collection add /state/files --name library --mask '**/*.{md,txt}'
|
|
57
|
+
ez library qmd search 'passport' -c library --json -n 5
|
|
58
|
+
ez library qmd get qmd://library/notes/travel.md
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`get` returns the content hash and size; `get --raw` emits exact bytes, including binary attachments. Files enter on stdin, so the plugin does not mount the agent workspace or infer host file access. Readback proves local storage only. Each agent's registry provides a separate data volume; never share it across identities merely to share search.
|
|
62
|
+
|
|
63
|
+
Semantic embeddings are **off by default**. Enable them explicitly through the owning agent's host manager:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
ez plugins shared-enable library embeddings
|
|
67
|
+
ez plugins shared-status library embeddings
|
|
68
|
+
ez library doctor
|
|
69
|
+
ez library qmd query 'vec: What should I pack for a trip?' -c library --no-rerank --json -n 5
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The manager discovers or creates one compatible embedding worker per Docker daemon. Clients share a read-only Unix-socket mount; model weights stay in the worker's persistent volume. Each agent keeps its own files, QMD database and vectors. No public port or Docker socket is mounted in Library. Concurrent first enables converge on one named container.
|
|
73
|
+
|
|
74
|
+
Enablement returns while the worker loads its model. `doctor` reports service and private-index readiness separately. The existing resident service indexes local files once the worker is ready, then checks every 60 seconds; adopted folders refresh after sync. `qmd update` and `qmd embed --no-gpu --max-docs-per-batch 8` can request immediate refresh under the same writer lock. A busy lock means wait for its active writer. Keyword search works while semantic indexing is pending or unavailable.
|
|
75
|
+
|
|
76
|
+
Only embedding/tokenizer inference is shared. Use structured `vec:` queries with `--no-rerank`; query expansion, reranking and per-agent `qmd pull` are deliberately unavailable. There is no silent local-model fallback. The pinned QMD transport patch leaves chunking, prompt formatting, storage and retrieval in QMD; see [shared embeddings](docs/shared-embeddings.md).
|
|
77
|
+
|
|
78
|
+
`ez plugins shared-disable library embeddings` detaches this Library and preserves its files and index. Stopping or uninstalling a Library never stops or deletes the shared worker/models. Retrieval is a snapshot; `library get` checks current bytes.
|
|
79
|
+
|
|
80
|
+
## Browsable remote mirror
|
|
81
|
+
|
|
82
|
+
Drive and GitHub persistence keep ordinary files at their original relative paths: PDFs, Markdown and zero-byte files can be browsed directly. No archive or base64 bundle substitutes for the current tree. GitHub does not represent empty directories. Provider revision history remains separate from the visible current files.
|
|
83
|
+
|
|
84
|
+
For an adopted folder, the resident service runs native bisync and indexes changes. The default interval is 60 seconds after each completed cycle, so transfers and embedding add latency. For legacy provider-only settings, uploads or Git commits/pushes remain agent-owned after each save batch. Never run both writers against the same destination.
|
|
85
|
+
|
|
86
|
+
## Backup after each save
|
|
87
|
+
|
|
88
|
+
When the owner asks to enable Drive backup and sync, the onboarded agent copies the existing Library now and backs up subsequent saved originals and derived notes in their intake tasks. It preserves local primary storage and records the verified private destination. Daily schedules are not a substitute or an implicit default. Failed uploads remain pending and are reported separately from successful local saves. This guidance uses existing provider tools; it does not watch external filesystem writes.
|
|
89
|
+
|
|
90
|
+
## Persistence settings
|
|
91
|
+
|
|
92
|
+
`ez library settings` returns the current settings and revision hash. Replace settings with `configure --expected HASH --key NEW_KEY < settings.json`. Supported storage modes are `local`, `drive`, `github`, and `hybrid`. [Settings and provider handoff](docs/persistence.md) define their schema and verification boundary. `doctor` reports cloud settings as `configured-not-verified`; successful configuration is never presented as a remote save.
|
|
93
|
+
|
|
94
|
+
## File writes and recovery
|
|
95
|
+
|
|
96
|
+
`put --expected new` creates a file. Replacements require the current SHA-256 from `get`, a new operation key, and new bytes on stdin. A matching retry returns the recorded outcome only if current bytes still match. Reusing a key with different content or preconditions fails. `operation --key KEY` reports `stored`, `changed`, or `missing` from actual bytes, including after interruption. Previous content is retained in `/state/history/<sha256>`; an operator can export it from the private volume and restore through a new guarded `put`.
|
|
97
|
+
|
|
98
|
+
Maximum intake is 512 MiB per file. Hidden paths, traversal, symlinks and special files are unsupported. `move --path SOURCE --to DEST --expected HASH --key KEY` and `remove --path SOURCE --expected HASH --key KEY` preserve recovery bytes and reject stale revisions. Their operation receipts live in the plugin volume, so child tasks do not need to edit a parent workspace manifest. `list --prefix notes/ --limit 100` is bounded and reports truncation; it is not a full backup manifest. All local commands emit JSON except `get --raw`; errors use stderr. Exit codes: 2 invalid input, 3 conflict/busy, 4 unavailable/uncertain. QMD preserves its native codes.
|
|
99
|
+
|
|
100
|
+
## State, lifecycle and limits
|
|
101
|
+
|
|
102
|
+
The named `data` volume contains `/state/files`, `settings.json`, `operations`, `history`, `tmp`, and `qmd`. Private state is not encrypted at rest. Native rclone credentials belong only in `/state/sync/rclone.conf`, outside mirrored files and settings. Adopted-folder state and receipts live under `/state/sync`; extracted PDF text lives under `/state/index-text`. The service supervises enabled native sync; commands run through the manager's isolated client containers. Its health check proves the CLI loads, not search readiness or persistence.
|
|
103
|
+
|
|
104
|
+
Stop the plugin before an operator takes a volume snapshot using an existing backup tool. Preserve originals, settings, receipts and history together. QMD indexes/models are rebuildable. Uninstall removes the deployment and registry binding but preserves volumes. Account revocation is a separate action in the provider's plugin/account. See [release and rollback practices](docs/releasing.md).
|
|
105
|
+
|
|
106
|
+
An interrupted command may leave `/state/.writer-lock`, or QMD's own embed lock below `/state/qmd/cache/qmd`. Confirm no Library client/embedding command is active before removing only the stale lock. Never delete the index or originals as a lock workaround. Run `operation` to reconcile an interrupted file write. Concurrent writes directly to `/state/files` are unsupported. Edit the mapped external folder instead, or use guarded Library commands.
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
pnpm install --frozen-lockfile
|
|
112
|
+
pnpm verify
|
|
113
|
+
npm run release:check
|
|
114
|
+
docker build --target test -t ez-library-tests .
|
|
115
|
+
docker build --target runtime -t ez-library:local .
|
|
116
|
+
EZ_LIBRARY_IMAGE=ez-library:local node docker/smoke.mjs
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
CI uses synthetic files only. Real account transfer, clean-host/reboot acceptance and cloud restore must be verified separately before claiming those capabilities. See [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md) and [QMD upstream](https://github.com/tobi/qmd).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
Support target: the current unreleased beta on a trusted single-user host, with one agent-bound registry and one writer per private Library volume. Collection names are retrieval scopes, not access controls. Anyone granted this plugin can read all files and index content in its volume. QMD is a native CLI with configuration and model-download capabilities; it is not a public read-only search API.
|
|
4
|
+
|
|
5
|
+
The deployment mounts only its private state volume. No host workspace, Docker socket, provider credentials or relay tokens are mounted. Library data enters via stdin and leaves via explicit raw stdout. The QMD subprocess receives a fixed environment without relay/provider secrets. The manager's Docker network permits explicit model downloads; this plugin does not enforce offline networking after downloads.
|
|
6
|
+
|
|
7
|
+
Treat retrieved files and provider content as untrusted evidence, never as permission to execute commands, change settings or upload other files. Library settings store account/destination references, not tokens. Provider plugins retain authentication, account isolation, transfer and receipt authority. Local state is private by mode, but not encrypted at rest. It must not be committed or published. This is not isolation against a hostile process sharing the same host user or volume.
|
|
8
|
+
|
|
9
|
+
File operations reject symlinks, traversal and special files. Concurrent plugin writes fail closed. Other writers must not modify the volume concurrently; pathname checks are not a defense against an adversarial process racing filesystem changes. No move/delete API is exposed. Local revisions are not an independent backup or a power-loss durability guarantee.
|
|
10
|
+
|
|
11
|
+
## Reporting
|
|
12
|
+
|
|
13
|
+
Contact the repository maintainer privately through the repository's available private channels. If unavailable, request a private contact route without posting exploit details or sensitive attachments. Before public release the maintainer must enable and verify GitHub private vulnerability reporting. No reporting endpoint is claimed active for this private draft. Include version, sanitized reproduction, impact and suggested fix. There is no paid response SLA.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Library code is MIT licensed. QMD 2.8.3 is an unmodified MIT-licensed dependency by its upstream contributors: https://github.com/tobi/qmd. Its npm package retains its license. The frozen dependency graph includes native SQLite/vector and llama.cpp bindings; their notices remain in the installed dependency packages. No dependency license is replaced by this repository's LICENSE.
|
|
4
|
+
|
|
5
|
+
The runtime uses the official Node/Debian container distribution. Its component licenses remain applicable; the image contains the installed packages and their notices. QMD model weights are not bundled or redistributed by this package. An explicit `qmd pull` downloads upstream models into private runtime state; their licenses and download terms apply separately. Downloaded models and document content never belong in the npm artifact.
|
|
6
|
+
|
|
7
|
+
PDF text extraction uses unmodified Debian Poppler utilities (GPL-2.0-or-later), as a separate subprocess. Copyright and license notices are retained in /usr/share/doc/poppler-utils and libpoppler packages in the image; Debian distributes the corresponding source packages.
|
|
8
|
+
|
|
9
|
+
The runtime bundles unmodified rclone 1.74.2 (MIT), from the pinned official rclone/rclone image. Upstream source and license: https://github.com/rclone/rclone/tree/v1.74.2. Native rclone owns filesystem synchronization and its provider profiles.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
const image = process.env.EZ_LIBRARY_IMAGE;
|
|
3
|
+
if (!image) throw Error('Set EZ_LIBRARY_IMAGE to the built runtime');
|
|
4
|
+
const script = `
|
|
5
|
+
import fs from 'node:fs/promises';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import {refreshIndex} from '/app/src/indexer.mjs';
|
|
8
|
+
import {qmd} from '/app/src/native.mjs';
|
|
9
|
+
const root='/state';
|
|
10
|
+
await fs.mkdir(root+'/files',{recursive:true});await fs.mkdir(root+'/sync',{recursive:true});
|
|
11
|
+
await fs.writeFile(root+'/files/note.md','# Calibration\\n\\nPreserve normalization anchors.\\n');
|
|
12
|
+
const first=await refreshIndex(root);
|
|
13
|
+
assert.equal(first.embedded,false);
|
|
14
|
+
const second=await refreshIndex(root);assert.equal(second.indexedAt,first.indexedAt);
|
|
15
|
+
const search=await qmd(root,['search','normalization','--json']);assert.equal(search.code,0);assert.match(search.stdout,/note/);
|
|
16
|
+
assert.deepEqual(await fs.readdir(root+'/qmd/cache/qmd/models'),[]);
|
|
17
|
+
console.log('PASS: offline full-text indexing/search; no embedding model download');
|
|
18
|
+
`;
|
|
19
|
+
execFileSync('docker', ['run','--rm','--network','none','-e','EZ_LIBRARY_EMBED=0',image,'node','--input-type=module','-e',script], {stdio:'inherit'});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Explicit live-provider QA. Only a new test branch is mutated. OAuth stays in
|
|
2
|
+
// the registered GitHub plugin. The temporary deploy key and volume are removed.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { setTimeout } from 'node:timers/promises';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
const ez = process.env.EZ_GITHUB_CLI, repository = process.env.EZ_LIBRARY_GITHUB_QA_REPOSITORY;
|
|
10
|
+
const models = process.env.EZ_LIBRARY_MODELS_DIR, image = process.env.EZ_LIBRARY_IMAGE || 'ez-library:local';
|
|
11
|
+
if (!ez || !path.isAbsolute(ez) || !/^[\w.-]+\/[\w.-]+$/.test(repository || '') || !models) throw Error('Set EZ_GITHUB_CLI, EZ_LIBRARY_GITHUB_QA_REPOSITORY and EZ_LIBRARY_MODELS_DIR; invoking this suite authorizes its isolated test branch and temporary deploy key');
|
|
12
|
+
const suffix = randomUUID().slice(0, 8), branch = 'library-sync-qa-' + suffix, folder = 'qa/' + suffix;
|
|
13
|
+
const container = 'ez-library-git-qa-' + suffix;
|
|
14
|
+
const invoke = (binary, args, input) => execFileSync(binary, args, { input, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], maxBuffer: 16 * 1024 * 1024, timeout: 180000 });
|
|
15
|
+
const docker = (args, input) => invoke('docker', args, input);
|
|
16
|
+
const api = (endpoint, method = 'GET', body) => {
|
|
17
|
+
const out = invoke(ez, ['github', 'gh', 'api', endpoint, '--method', method, ...(body ? ['--input', '-'] : [])], body ? JSON.stringify(body) : undefined);
|
|
18
|
+
return out.trim() ? JSON.parse(out) : null;
|
|
19
|
+
};
|
|
20
|
+
const call = (args, input) => docker(['exec', '-i', container, 'node', '/app/bin/ez-library.mjs', ...args], input);
|
|
21
|
+
const parsed = (args, input) => JSON.parse(call(args, input)).data;
|
|
22
|
+
const remote = file => api(`repos/${repository}/contents/${folder}/${file}?ref=${branch}`);
|
|
23
|
+
const saveRemote = (file, content, sha) => api(`repos/${repository}/contents/${folder}/${file}`, 'PUT', { branch, message: 'Library sync QA fixture', content: Buffer.from(content).toString('base64'), ...(sha ? { sha } : {}) });
|
|
24
|
+
const bytes = result => Buffer.from(result.content, 'base64').toString('utf8');
|
|
25
|
+
const mounts = ['-v', container + ':/state', '-v', models + ':/state/qmd/cache/qmd/models:ro'];
|
|
26
|
+
const start = worker => docker(['run', '-d', '--name', container, '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--cpus', '4', '--memory', '4g', ...mounts, image, ...(worker ? [] : ['sleep', 'infinity'])]);
|
|
27
|
+
async function waitForCommit(commit) {
|
|
28
|
+
for (let i = 0; i < 90; i++) {
|
|
29
|
+
await setTimeout(2000);
|
|
30
|
+
const s = parsed(['sync-status']).status;
|
|
31
|
+
if (s?.state === 'synced-and-indexed' && s.git?.commit === commit) return s;
|
|
32
|
+
}
|
|
33
|
+
throw Error('Resident Git worker did not import/index the expected remote commit');
|
|
34
|
+
}
|
|
35
|
+
function pdf(text) {
|
|
36
|
+
const stream = `BT /F1 12 Tf 40 100 Td (${text}) Tj ET`;
|
|
37
|
+
const objects = ['<< /Type /Catalog /Pages 2 0 R >>', '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
|
|
38
|
+
'<< /Type /Page /Parent 2 0 R /MediaBox [0 0 500 200] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>',
|
|
39
|
+
'<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>', `<< /Length ${stream.length} >>\nstream\n${stream}\nendstream`];
|
|
40
|
+
let content = '%PDF-1.4\n'; const offsets = [];
|
|
41
|
+
for (const [i, object] of objects.entries()) { offsets.push(content.length); content += `${i + 1} 0 obj\n${object}\nendobj\n`; }
|
|
42
|
+
const xref = content.length;
|
|
43
|
+
return content + `xref\n0 6\n0000000000 65535 f \n${offsets.map(n => String(n).padStart(10, '0') + ' 00000 n ').join('\n')}\ntrailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF\n`;
|
|
44
|
+
}
|
|
45
|
+
let keyId, volume = false;
|
|
46
|
+
try {
|
|
47
|
+
const repo = api(`repos/${repository}`);
|
|
48
|
+
assert(repo.private && repo.permissions.admin, 'Live QA requires the selected private repository and deploy-key administration');
|
|
49
|
+
const main = api(`repos/${repository}/git/ref/heads/${repo.default_branch}`).object.sha;
|
|
50
|
+
api(`repos/${repository}/git/refs`, 'POST', { ref: 'refs/heads/' + branch, sha: main });
|
|
51
|
+
saveRemote('stars.md', '# Stars\nAmber telescopes observe Jupiter at night.');
|
|
52
|
+
saveRemote('conflict.md', '# Draft\nOriginal revision.');
|
|
53
|
+
saveRemote('empty.txt', '');
|
|
54
|
+
saveRemote('lease.pdf', pdf('Lease renewal: November 2032.'));
|
|
55
|
+
docker(['volume', 'create', container]); volume = true; start(false);
|
|
56
|
+
const key = parsed(['git-key', '--repository', repository]);
|
|
57
|
+
keyId = api(`repos/${repository}/keys`, 'POST', { title: 'Ez Library smoke ' + suffix, key: key.publicKey, read_only: false }).id;
|
|
58
|
+
parsed(['git-adopt', '--repository', repository, '--branch', branch]);
|
|
59
|
+
const initial = parsed(['sync-run']);
|
|
60
|
+
assert(initial.git.remoteVerified && initial.embedded);
|
|
61
|
+
assert.match(call(['qmd', 'search', 'November', '-c', 'library-pdf', '--json']), /lease\.pdf\.md/);
|
|
62
|
+
assert.match(call(['qmd', 'query', 'vec: When is the lease renewed?', '-c', 'library-pdf', '--no-rerank', '--json', '-n', '10']), /lease\.pdf\.md/);
|
|
63
|
+
console.log(JSON.stringify({ stage: 'native-ssh-import-pdf-semantic', ok: true }));
|
|
64
|
+
|
|
65
|
+
// Start the installed supervisor and prove provider->Library auto-discovery.
|
|
66
|
+
docker(['rm', '-f', container]); start(true);
|
|
67
|
+
const incoming = saveRemote('incoming.md', '# Incoming\nCobalt otters live by the river.');
|
|
68
|
+
await waitForCommit(incoming.commit.sha);
|
|
69
|
+
assert.match(call(['qmd', 'search', 'cobalt', '--json']), /incoming\.md/);
|
|
70
|
+
let cfg = parsed(['sync-status']); parsed(['sync-policy', '--expected', cfg.revision, '--mode', 'two-way', '--interval', '30']);
|
|
71
|
+
const local = parsed(['put', '--path', folder + '/agent.md', '--expected', 'new', '--key', 'agent'], '# Agent\nSaffron notebooks.');
|
|
72
|
+
let exported = false;
|
|
73
|
+
for (let i = 0; i < 60; i++) {
|
|
74
|
+
await setTimeout(2000);
|
|
75
|
+
const s = parsed(['sync-status']).status;
|
|
76
|
+
if (s?.state === 'synced-and-indexed' && s.git?.commit !== incoming.commit.sha) {
|
|
77
|
+
assert.match(bytes(remote('agent.md')), /Saffron/); exported = true; break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
assert(exported, 'Agent save must be pushed by the resident worker');
|
|
81
|
+
console.log(JSON.stringify({ stage: 'automatic-both-directions', ok: true }));
|
|
82
|
+
|
|
83
|
+
// Pause recurring work while constructing a simultaneous conflict.
|
|
84
|
+
cfg = parsed(['sync-status']); parsed(['sync-policy', '--expected', cfg.revision, '--mode', 'paused']);
|
|
85
|
+
const name = folder + '/conflict.md';
|
|
86
|
+
parsed(['put', '--path', name, '--expected', parsed(['get', '--path', name]).sha256, '--key', 'local-conflict'], 'LOCAL revision\n');
|
|
87
|
+
saveRemote('conflict.md', 'REMOTE revision\n', remote('conflict.md').sha);
|
|
88
|
+
cfg = parsed(['sync-status']); parsed(['sync-policy', '--expected', cfg.revision, '--mode', 'two-way']);
|
|
89
|
+
assert.throws(() => call(['sync-run']), e => e.status === 3);
|
|
90
|
+
assert.match(call(['git', 'show', ':2:' + name]), /LOCAL revision/);
|
|
91
|
+
assert.match(call(['git', 'show', ':3:' + name]), /REMOTE revision/);
|
|
92
|
+
parsed(['put', '--path', name, '--expected', parsed(['get', '--path', name]).sha256, '--key', 'resolve'], 'Reviewed resolution\n');
|
|
93
|
+
call(['git', 'add', '--', name]); parsed(['sync-run']);
|
|
94
|
+
assert.match(bytes(remote('conflict.md')), /Reviewed resolution/);
|
|
95
|
+
parsed(['move', '--path', folder + '/agent.md', '--to', folder + '/organized.md', '--expected', local.sha256, '--key', 'move']);
|
|
96
|
+
parsed(['sync-run']); assert.match(bytes(remote('organized.md')), /Saffron/);
|
|
97
|
+
console.log(JSON.stringify({ stage: 'conflict-resolution-and-agent-rename', ok: true }));
|
|
98
|
+
|
|
99
|
+
saveRemote('lease.pdf', pdf('Lease renewal: December 2033.'), remote('lease.pdf').sha);
|
|
100
|
+
const deleted = api(`repos/${repository}/contents/${folder}/incoming.md`, 'DELETE', { branch, message: 'Library QA deletion', sha: remote('incoming.md').sha });
|
|
101
|
+
await waitForCommit(deleted.commit.sha);
|
|
102
|
+
assert.doesNotMatch(call(['qmd', 'search', 'cobalt', '--json']), /incoming\.md/);
|
|
103
|
+
assert.match(call(['qmd', 'search', 'December', '-c', 'library-pdf', '--json']), /lease\.pdf\.md/);
|
|
104
|
+
assert.doesNotMatch(call(['qmd', 'search', 'November', '-c', 'library-pdf', '--json']), /lease\.pdf\.md/);
|
|
105
|
+
docker(['restart', container]);
|
|
106
|
+
const restarted = saveRemote('restart.md', '# Restart\nTangerine satellites.');
|
|
107
|
+
await waitForCommit(restarted.commit.sha);
|
|
108
|
+
assert.match(call(['qmd', 'search', 'tangerine', '--json']), /restart\.md/);
|
|
109
|
+
console.log(JSON.stringify({ ok: true, repository, branch, folder, url: `https://github.com/${repository}/tree/${branch}/${folder}`, checks: ['existing-provider-deploy-key', 'private-ssh-import', 'automatic-two-way-sync', 'pdf-semantic-index', 'native-conflicts-retained-and-resolved', 'agent-rename', 'external-delete', 'pdf-replacement-removes-stale-text', 'restart-auto-import'], mainBranchModifiedByQA: false }));
|
|
110
|
+
} finally {
|
|
111
|
+
try { docker(['rm', '-f', container]); } catch {}
|
|
112
|
+
if (volume) docker(['volume', 'rm', container]);
|
|
113
|
+
if (keyId) api(`repos/${repository}/keys/${keyId}`, 'DELETE');
|
|
114
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Integration against an explicitly selected released Ez manager, never a runtime import.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
7
|
+
import { spawn, execFileSync } from 'node:child_process';
|
|
8
|
+
|
|
9
|
+
const modulePath = process.env.EZ_MANAGER_MODULE;
|
|
10
|
+
if (!modulePath || !path.isAbsolute(modulePath)) throw Error('Set EZ_MANAGER_MODULE to the absolute released src/plugins/manager.mjs');
|
|
11
|
+
const { snapshot, init } = await import(pathToFileURL(modulePath));
|
|
12
|
+
const source = fileURLToPath(new URL('../', import.meta.url));
|
|
13
|
+
const root = await fs.mkdtemp(path.join(tmpdir(), 'ez-library-manager-'));
|
|
14
|
+
const home = path.join(root, 'tools'), mind = path.join(root, 'mind');
|
|
15
|
+
const bin = path.resolve(path.dirname(modulePath), '../../bin/ezenciel-agents-tools.mjs');
|
|
16
|
+
let record;
|
|
17
|
+
function call(args, input) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const child = spawn(process.execPath, [bin, '--home', home, ...args]);
|
|
20
|
+
let stdout = '', stderr = '';
|
|
21
|
+
child.stdout.on('data', x => { stdout += x; }); child.stderr.on('data', x => { stderr += x; });
|
|
22
|
+
child.on('error', reject); child.on('close', code => code ? reject(Error(stderr || stdout || `Exit ${code}`)) : resolve(stdout));
|
|
23
|
+
child.stdin.end(input);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const parse = async (args, input) => JSON.parse(await call(args, input));
|
|
27
|
+
try {
|
|
28
|
+
await fs.mkdir(mind); const catalog = path.join(root, 'catalog.json'); await fs.writeFile(catalog, '{}');
|
|
29
|
+
await init(home, mind, catalog);
|
|
30
|
+
const inspected = await snapshot(source);
|
|
31
|
+
const installed = await parse(['plugins', 'install', 'library', '--source', source, '--revision', inspected.revision]);
|
|
32
|
+
assert.equal(installed.started, false);
|
|
33
|
+
record = JSON.parse(await fs.readFile(path.join(home, 'registry.json'))).plugins.library;
|
|
34
|
+
await call(['plugins', 'start', 'library']);
|
|
35
|
+
const note = '# Registry proof\n\nA synthetic violet bicycle.\n';
|
|
36
|
+
const put = await parse(['library', 'put', '--path', 'notes/registry.md', '--expected', 'new', '--key', 'registry-1'], note);
|
|
37
|
+
assert.equal(put.data.state, 'stored');
|
|
38
|
+
assert.equal(await call(['library', 'get', '--path', 'notes/registry.md', '--raw']), note);
|
|
39
|
+
await call(['library', 'qmd', 'collection', 'add', '/state/files', '--name', 'library']);
|
|
40
|
+
assert.match(await call(['library', 'qmd', 'search', 'violet', '--json']), /registry\.md/);
|
|
41
|
+
await call(['plugins', 'stop', 'library']); await call(['plugins', 'start', 'library']);
|
|
42
|
+
assert.equal((await parse(['library', 'operation', '--key', 'registry-1'])).data.state, 'stored');
|
|
43
|
+
assert.equal((await parse(['library', 'put', '--path', 'notes/registry.md', '--expected', 'new', '--key', 'registry-1'], note)).data.replay, true);
|
|
44
|
+
await call(['plugins', 'uninstall', 'library']);
|
|
45
|
+
const volumes = execFileSync('docker', ['volume', 'ls', '--filter', `label=com.docker.compose.project=${record.project}`, '--format', '{{.Name}}'], { encoding: 'utf8' }).trim();
|
|
46
|
+
assert(volumes); console.log(JSON.stringify({ ok: true, revision: inspected.revision, checks: ['inert-install', 'registered-dispatch', 'stdin-raw-readback', 'qmd-retrieval', 'restart-persistence', 'idempotency', 'data-preserving-uninstall'] }));
|
|
47
|
+
} finally {
|
|
48
|
+
if (record) {
|
|
49
|
+
execFileSync('docker', ['compose', '-p', record.project, '-f', record.compose, 'down', '--volumes'], { stdio: 'ignore' });
|
|
50
|
+
execFileSync('docker', ['image', 'rm', `${record.project}-library:${record.revision.slice(7, 23)}`], { stdio: 'ignore' });
|
|
51
|
+
}
|
|
52
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
53
|
+
}
|