@ngo-a/native-memory-citations 0.1.3 → 2026.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -92
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
# Native Memory Citations
|
|
2
2
|
|
|
3
|
-
Native OpenClaw plugin for cited
|
|
4
|
-
Native
|
|
3
|
+
Native Memory Citations is an OpenClaw plugin for controlled, cited retrieval from
|
|
4
|
+
local workspace memory files. ("Native" denotes an OpenClaw-native plugin, not
|
|
5
|
+
native system memory.)
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
The plugin is built for environments where memory access must be explicit, bounded,
|
|
8
|
+
and auditable. An operator defines which workspace files or directories may be
|
|
9
|
+
searched. The plugin enforces that access boundary before reading any content,
|
|
10
|
+
redacts secret-shaped material from what it returns, and attaches citation metadata
|
|
11
|
+
so every answer can be traced back to its source. The objective is not broad memory
|
|
12
|
+
access; it is operator-controlled retrieval with an audit trail.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Key capabilities
|
|
17
|
+
|
|
18
|
+
- Operator-defined search scope, limited to workspace-relative roots.
|
|
19
|
+
- Optional shared mode that excludes private memory from the default set.
|
|
20
|
+
- Per-file size limits, with oversized files skipped rather than read.
|
|
21
|
+
- Redaction of secret-shaped content in all returned text (search, fetch, and answers).
|
|
22
|
+
- Citations on every result, with full-file SHA-256 hashes for staleness detection.
|
|
23
|
+
- Per-request output limits on fetched content.
|
|
24
|
+
- Read-only operation: the plugin never creates, modifies, or deletes memory files.
|
|
25
|
+
|
|
26
|
+
## Intended use
|
|
27
|
+
|
|
28
|
+
Native Memory Citations is intended for OpenClaw deployments where an agent needs
|
|
29
|
+
access to selected memory files without broad filesystem visibility. It suits
|
|
30
|
+
single-user, team, and shared environments in which private memory, project notes,
|
|
31
|
+
identity files, and tool references must be handled within clear boundaries.
|
|
7
32
|
|
|
8
33
|
## Tools
|
|
9
34
|
|
|
10
|
-
- `native_memory_search
|
|
11
|
-
- `native_memory_fetch
|
|
12
|
-
- `native_memory_answer
|
|
35
|
+
- `native_memory_search` — search the approved roots and return snippets with source paths, line numbers, and file SHA-256 hashes.
|
|
36
|
+
- `native_memory_fetch` — fetch a cited source by `sourceId` or a safe path, optionally checking an expected citation hash.
|
|
37
|
+
- `native_memory_answer` — build an extractive answer from cited snippets, and state plainly when no cited memory is found.
|
|
13
38
|
|
|
14
|
-
## Default
|
|
39
|
+
## Default scope
|
|
15
40
|
|
|
16
|
-
By default
|
|
41
|
+
By default the plugin searches:
|
|
17
42
|
|
|
18
43
|
- `memory/`
|
|
19
44
|
- `MEMORY.md`
|
|
@@ -21,34 +46,13 @@ By default, the plugin searches:
|
|
|
21
46
|
- `IDENTITY.md`
|
|
22
47
|
- `TOOLS.md`
|
|
23
48
|
|
|
24
|
-
Set `sharedMode: true`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Custom `allowedRoots` entries must be workspace-relative visible paths. Empty
|
|
29
|
-
entries, `.`, `..`, paths containing `..`, absolute paths, and hidden path
|
|
30
|
-
segments such as `memory/.dreams` are rejected.
|
|
49
|
+
Set `sharedMode: true` to exclude the private `MEMORY.md` from this default set.
|
|
50
|
+
Setting `allowedRoots` explicitly overrides the default set entirely and takes
|
|
51
|
+
precedence over `sharedMode`.
|
|
31
52
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
metadata in `src/index.ts`. Do not hand-edit it; regenerate after changing the
|
|
36
|
-
plugin id, name, description, `configSchema`, or any tool name:
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install
|
|
40
|
-
npm test
|
|
41
|
-
npm run plugin:build
|
|
42
|
-
npm run plugin:validate
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
In CI, fail on stale generated metadata without rewriting files:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm run plugin:build:check
|
|
49
|
-
npm run plugin:validate
|
|
50
|
-
npm test
|
|
51
|
-
```
|
|
53
|
+
Custom `allowedRoots` entries must be workspace-relative, visible paths. Empty
|
|
54
|
+
entries, `.`, `..`, paths containing `..`, absolute paths, and hidden segments such
|
|
55
|
+
as `memory/.dreams` are rejected.
|
|
52
56
|
|
|
53
57
|
## Configuration
|
|
54
58
|
|
|
@@ -60,15 +64,15 @@ All keys are optional.
|
|
|
60
64
|
| Key | Type | Default | Description |
|
|
61
65
|
|-----|------|---------|-------------|
|
|
62
66
|
| `workspace` | string | `$OPENCLAW_WORKSPACE`, then `~/.openclaw/workspace` | Absolute path against which roots are resolved. |
|
|
63
|
-
| `allowedRoots` | string[] | Built-in default set (see Default
|
|
67
|
+
| `allowedRoots` | string[] | Built-in default set (see Default scope) | Workspace-relative files or directories to search. When set to a non-empty array, it replaces the default set in full. |
|
|
64
68
|
| `sharedMode` | boolean | `false` | When `true`, excludes the private `MEMORY.md` from the default set. Has no effect when `allowedRoots` is set. |
|
|
65
69
|
| `maxFileBytes` | number | `1048576` (1 MiB) | Per-file size limit. Files exceeding this limit are skipped rather than reported as errors. |
|
|
66
70
|
|
|
67
71
|
### Default search scope
|
|
68
72
|
|
|
69
|
-
The default roots are
|
|
70
|
-
`
|
|
71
|
-
|
|
73
|
+
The default roots are listed in Default scope above: `memory/`, `MEMORY.md`,
|
|
74
|
+
`USER.md`, `IDENTITY.md`, and `TOOLS.md`. With `sharedMode: true`, `MEMORY.md` is
|
|
75
|
+
excluded.
|
|
72
76
|
|
|
73
77
|
### Defining custom roots
|
|
74
78
|
|
|
@@ -114,14 +118,14 @@ Permitting larger files (4 MiB) and specifying a non-default workspace:
|
|
|
114
118
|
### Operational notes
|
|
115
119
|
|
|
116
120
|
- `allowedRoots` replaces the default set; it does not extend it. A value of
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
`["notes"]` makes `MEMORY.md`, `USER.md`, and the remaining defaults unreachable.
|
|
122
|
+
List every path that should remain searchable.
|
|
119
123
|
- `sharedMode` has no effect once `allowedRoots` is set; the explicit list takes
|
|
120
|
-
|
|
124
|
+
precedence.
|
|
121
125
|
- Files exceeding `maxFileBytes` are skipped and logged rather than reported as
|
|
122
|
-
|
|
126
|
+
errors. Set the limit to accommodate the largest memory files in use.
|
|
123
127
|
- Hidden directories, `..` segments, and absolute paths cannot be included. This is
|
|
124
|
-
|
|
128
|
+
enforced by the access boundary.
|
|
125
129
|
|
|
126
130
|
### Settings not exposed through configuration
|
|
127
131
|
|
|
@@ -138,28 +142,10 @@ this version.
|
|
|
138
142
|
the range 256 to 20000) that bounds the amount of cited content returned by a single
|
|
139
143
|
fetch. This is a per-call tool argument and is independent of plugin configuration.
|
|
140
144
|
|
|
141
|
-
##
|
|
145
|
+
## Citation integrity
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Search is keyword/substring based with an mtime/size line cache, bounded scan
|
|
146
|
-
concurrency, and `AbortSignal` checks during scan.
|
|
147
|
-
|
|
148
|
-
Returned snippets, fetched content, match lines, and extractive answers are
|
|
149
|
-
redacted for common secret patterns such as bearer tokens, API keys, GitHub
|
|
150
|
-
tokens, password/secret/token assignment lines, credential URLs, JWTs, cloud
|
|
151
|
-
keys, and private key blocks. The named pattern list is best-effort labeling,
|
|
152
|
-
not the security boundary; returned text also masks sufficiently long
|
|
153
|
-
high-entropy tokens when no named pattern matches. Redaction is defense-in-depth,
|
|
154
|
-
not the access boundary; the access boundary is allowed roots, hidden-path
|
|
155
|
-
rejection, symlink/realpath checks, file-type filtering, and size limits.
|
|
156
|
-
Redaction does not mutate source files and does not affect citation hashes,
|
|
157
|
-
which are computed from original file text.
|
|
158
|
-
|
|
159
|
-
## Citation Integrity
|
|
160
|
-
|
|
161
|
-
Search hits include `sha256`, computed from the full text file used for line
|
|
162
|
-
splitting and citation line numbers. Fetch results include the current `sha256`
|
|
147
|
+
Search hits include a `sha256`, computed from the full text of the file used for
|
|
148
|
+
line splitting and citation line numbers. Fetch results include the current `sha256`
|
|
163
149
|
for the same full-file content.
|
|
164
150
|
|
|
165
151
|
To detect stale citations, pass the hash from a prior search hit:
|
|
@@ -173,53 +159,57 @@ To detect stale citations, pass the hash from a prior search hit:
|
|
|
173
159
|
}
|
|
174
160
|
```
|
|
175
161
|
|
|
176
|
-
If the file changed, fetch still returns the current content for inspection
|
|
162
|
+
If the file has changed, fetch still returns the current content for inspection but
|
|
177
163
|
marks the result with `stale: true` and a `staleMessage` explaining the hash
|
|
178
164
|
mismatch. Because hashes cover the full file, appending to a daily journal marks
|
|
179
165
|
earlier citations stale even when the cited lines themselves are unchanged.
|
|
180
166
|
|
|
167
|
+
## Security model
|
|
168
|
+
|
|
169
|
+
The plugin enforces a two-layer model.
|
|
170
|
+
|
|
171
|
+
The access boundary determines what may be read. `allowedRoots` is trusted operator
|
|
172
|
+
configuration. Any caller-supplied fetch path, and any symlink that would escape a
|
|
173
|
+
root, is treated as untrusted and re-checked with `realpath`. Symlinks encountered
|
|
174
|
+
while walking directories during search are skipped. Fetch additionally rejects
|
|
175
|
+
hidden path segments, non-text files, and files larger than `maxFileBytes`.
|
|
176
|
+
|
|
177
|
+
Redaction is applied to all returned text as defense-in-depth. Named secret patterns
|
|
178
|
+
provide readable labels for common formats; a high-entropy backstop masks unknown
|
|
179
|
+
long tokens. Redaction is not an authorization or access-control boundary. It does
|
|
180
|
+
not modify source files, and it does not affect citation hashes, which are computed
|
|
181
|
+
from the original file text.
|
|
182
|
+
|
|
183
|
+
To report a vulnerability, see [SECURITY.md](SECURITY.md).
|
|
184
|
+
|
|
181
185
|
## Install
|
|
182
186
|
|
|
183
187
|
From npm (recommended):
|
|
184
188
|
|
|
185
|
-
|
|
189
|
+
openclaw plugins install @ngo-a/native-memory-citations
|
|
186
190
|
|
|
187
191
|
From a local checkout (development):
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
openclaw plugins install ./native-memory-citations
|
|
190
194
|
|
|
191
195
|
Reload the Gateway after installing so the plugin host exposes the tools.
|
|
192
196
|
|
|
193
|
-
##
|
|
194
|
-
|
|
195
|
-
See [SECURITY.md](./SECURITY.md): `allowedRoots` is trusted operator config;
|
|
196
|
-
a symlink that escapes a root, and any caller-supplied fetch path, is untrusted
|
|
197
|
-
and re-checked with `realpath`; symlinks found while walking directories during
|
|
198
|
-
search are skipped. Fetch also rejects hidden path segments, non-text files, and
|
|
199
|
-
files larger than `maxFileBytes`. Citation hashes let callers detect when a
|
|
200
|
-
previous path-and-line citation may now point at changed content. Returned text
|
|
201
|
-
is redacted before it leaves the plugin; named secret patterns provide nicer
|
|
202
|
-
labels, while the high-entropy backstop handles unknown token formats. Redaction
|
|
203
|
-
is not an authorization or access-control boundary.
|
|
204
|
-
|
|
205
|
-
## Releasing
|
|
206
|
-
|
|
207
|
-
Published to npm as `@ngo-a/native-memory-citations`.
|
|
197
|
+
## Implementation notes
|
|
208
198
|
|
|
209
|
-
|
|
199
|
+
This v1 is intentionally local-file based. It is portable and dependency-light. A
|
|
200
|
+
future version can add vector search while keeping the same public tool names.
|
|
201
|
+
Search is keyword and substring based, with an mtime/size line cache, bounded scan
|
|
202
|
+
concurrency, and `AbortSignal` checks during the scan.
|
|
210
203
|
|
|
211
|
-
|
|
212
|
-
2. Bump `version` in `package.json` (e.g. `0.1.0` -> `0.1.1`) per semver.
|
|
213
|
-
3. `npm publish`
|
|
204
|
+
## Contributing
|
|
214
205
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
overwritten; fixes ship as a new version.
|
|
206
|
+
Development setup, manifest generation, and the release process are documented in
|
|
207
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
218
208
|
|
|
219
209
|
## License
|
|
220
210
|
|
|
221
|
-
[
|
|
211
|
+
MIT. See [LICENSE](LICENSE).
|
|
222
212
|
|
|
223
213
|
## Changelog
|
|
224
214
|
|
|
225
|
-
See [CHANGELOG.md](
|
|
215
|
+
See [CHANGELOG.md](CHANGELOG.md).
|
package/openclaw.plugin.json
CHANGED