@vib795/agent-memory 0.1.9 → 0.1.10

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 CHANGED
@@ -96,6 +96,7 @@ agent-memory get <id> [--depth N] a note plus its neighborhood
96
96
  [--budget N] [--include-archived]
97
97
  agent-memory search <terms> [--limit N] full-text fallback when the tree misses
98
98
  agent-memory write --from-json <file> validated upsert; used by the skills
99
+ --from-json - read the JSON from stdin instead
99
100
  agent-memory compact dedup, decay, reindex, regenerate
100
101
  agent-memory doctor preflight and health report
101
102
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vib795/agent-memory",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Durable cross-repo knowledge graph for GitHub Copilot and Claude Code. Markdown source of truth, disposable SQLite index, zero runtime dependencies.",
5
5
  "keywords": [
6
6
  "github-copilot",
@@ -274,8 +274,7 @@ Types are `system`, `decision`, `convention`, `constraint`. Edge relations are
274
274
  `depends-on`, `applies-to`, `supersedes`, `contradicts`, `evidence-for`.
275
275
 
276
276
  ```bash
277
- tmp="$(mktemp)"
278
- cat > "$tmp" <<'JSON'
277
+ agent-memory write --from-json - --source handoff <<'JSON'
279
278
  {"nodes":[
280
279
  {"id":"use-sessions","type":"decision",
281
280
  "title":"Chose server sessions over JWT",
@@ -283,19 +282,21 @@ cat > "$tmp" <<'JSON'
283
282
  "edges":[{"rel":"evidence-for","dst":"auth-service"}]}
284
283
  ]}
285
284
  JSON
286
- agent-memory write --from-json "$tmp" --source handoff
287
- rm -f "$tmp"
288
285
  ```
289
286
 
290
287
  ```powershell
291
- $tmp = [System.IO.Path]::GetTempFileName()
292
288
  @'
293
289
  <the JSON>
294
- '@ | Set-Content -Path $tmp -Encoding UTF8
295
- agent-memory write --from-json $tmp --source handoff
296
- Remove-Item -Force $tmp
290
+ '@ | Set-Content -Path .agent-memory-write.json -Encoding UTF8
291
+ agent-memory write --from-json .agent-memory-write.json --source handoff
292
+ Remove-Item -Force .agent-memory-write.json
297
293
  ```
298
294
 
295
+ **Use these as written. Do not introduce a variable.** Some agent terminals rewrite
296
+ `$`-prefixed lines before the shell sees them, corrupting the payload into malformed
297
+ JSON. PowerShell writes a file rather than piping because Windows PowerShell pipes to
298
+ a native command using `$OutputEncoding`, which is not UTF-8 by default.
299
+
299
300
  `write` redacts before anything reaches disk and reports every validation error at
300
301
  once. Surface its warnings verbatim; a `title collision` warning means two ids now
301
302
  describe the same thing and the user should know.
@@ -98,25 +98,32 @@ Fields you may set: `id`, `type`, `title`, `body`, `repos`, `scope`, `confidence
98
98
  **bash (macOS / Linux):**
99
99
 
100
100
  ```bash
101
- tmp="$(mktemp)"
102
- cat > "$tmp" <<'JSON'
101
+ agent-memory write --from-json - --source remember <<'JSON'
103
102
  <the JSON from Step 2>
104
103
  JSON
105
- agent-memory write --from-json "$tmp" --source remember
106
- rm -f "$tmp"
107
104
  ```
108
105
 
109
106
  **PowerShell (Windows / AVD):**
110
107
 
111
108
  ```powershell
112
- $tmp = [System.IO.Path]::GetTempFileName()
113
109
  @'
114
110
  <the JSON from Step 2>
115
- '@ | Set-Content -Path $tmp -Encoding UTF8
116
- agent-memory write --from-json $tmp --source remember
117
- Remove-Item -Force $tmp
111
+ '@ | Set-Content -Path .agent-memory-write.json -Encoding UTF8
112
+ agent-memory write --from-json .agent-memory-write.json --source remember
113
+ Remove-Item -Force .agent-memory-write.json
118
114
  ```
119
115
 
116
+ **Use these as written. Do not introduce a variable.** Some agent terminals rewrite
117
+ `$`-prefixed lines before the shell sees them, which turns the payload into malformed
118
+ JSON and costs you two retries diagnosing a corruption that never reached disk. Both
119
+ recipes above are free of variables for that reason.
120
+
121
+ PowerShell writes a file rather than piping, because Windows PowerShell pipes to a
122
+ native command using `$OutputEncoding`, which is not UTF-8 by default and would mangle
123
+ any non-ASCII character in a body. `-Encoding UTF8` on a file is explicit and safe. The
124
+ file is written next to you and removed on the next line; if you see it left behind,
125
+ the write failed and the JSON is still there to read.
126
+
120
127
  Redaction runs inside `write`, before any bytes reach disk, and cannot be turned
121
128
  off. You still must not paste a raw secret into the JSON: the guard is a backstop,
122
129
  not a licence.
package/src/cli.js CHANGED
@@ -298,7 +298,11 @@ function cmdSearch(opts) {
298
298
  }
299
299
 
300
300
  function readNodesFrom(file) {
301
- const raw = JSON.parse(readFileSync(file, 'utf8'));
301
+ // `-` means stdin. Naming a temp file takes a shell variable, and some agent
302
+ // terminals rewrite `$`-prefixed lines before the shell ever sees them, which
303
+ // corrupts the payload into malformed JSON with nothing to point at. Reading the
304
+ // document straight off the pipe removes the variable, and with it the failure.
305
+ const raw = JSON.parse(readFileSync(file === '-' ? 0 : file, 'utf8'));
302
306
  if (Array.isArray(raw)) return raw;
303
307
  if (Array.isArray(raw?.nodes)) return raw.nodes;
304
308
  return [raw];
@@ -306,11 +310,11 @@ function readNodesFrom(file) {
306
310
 
307
311
  function cmdWrite(opts) {
308
312
  const file = opts['from-json'];
309
- if (!file || file === true || !existsSync(file)) {
313
+ if (!file || file === true || (file !== '-' && !existsSync(file))) {
310
314
  return {
311
315
  ok: false,
312
- error: 'write requires --from-json <file>',
313
- text: 'write requires --from-json <file>',
316
+ error: 'write requires --from-json <file>, or - to read stdin',
317
+ text: 'write requires --from-json <file>, or - to read stdin',
314
318
  };
315
319
  }
316
320