create-ai-memory 0.16.1 → 0.16.3
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/bin/create-ai-memory.js +24 -1
- package/package.json +1 -1
- package/shell/adapters.zsh +3 -1
- package/shell/ai-mem.zsh +29 -1
package/bin/create-ai-memory.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* Usage:
|
|
11
11
|
* npm create ai-memory@latest # into ~/ai-memory
|
|
12
12
|
* npx create-ai-memory ~/code/ai-memory # into a directory you choose
|
|
13
|
+
* npx create-ai-memory --version | --help
|
|
13
14
|
*/
|
|
14
15
|
'use strict';
|
|
15
16
|
|
|
@@ -19,7 +20,29 @@ const { join, resolve } = require('node:path');
|
|
|
19
20
|
const { homedir } = require('node:os');
|
|
20
21
|
|
|
21
22
|
const pkgRoot = resolve(__dirname, '..'); // bundled tool
|
|
22
|
-
const
|
|
23
|
+
const USAGE = 'Usage: create-ai-memory [install-dir] (default: ~/ai-memory)\n' +
|
|
24
|
+
' create-ai-memory --version | --help';
|
|
25
|
+
|
|
26
|
+
// Flags are handled before anything touches the disk. The first argument used
|
|
27
|
+
// to be taken as the install directory unconditionally, so `--version` created
|
|
28
|
+
// ./--version and ran the interactive installer inside it. Any other leading
|
|
29
|
+
// dash is rejected rather than guessed at: a directory name starting with `-`
|
|
30
|
+
// can still be passed as ./-name.
|
|
31
|
+
const arg = process.argv[2];
|
|
32
|
+
if (arg === '--version' || arg === '-v') {
|
|
33
|
+
console.log(require(join(pkgRoot, 'package.json')).version);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
if (arg === '--help' || arg === '-h') {
|
|
37
|
+
console.log(USAGE);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
if (arg && arg.startsWith('-')) {
|
|
41
|
+
console.error(`create-ai-memory: unknown option ${arg}\n${USAGE}`);
|
|
42
|
+
process.exit(2);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const dest = resolve(arg || join(homedir(), 'ai-memory'));
|
|
23
46
|
|
|
24
47
|
// Files that make up the tool; copied verbatim from the package into dest.
|
|
25
48
|
//
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ai-memory",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Persistent, harness-agnostic session memory for AI coding CLIs (Claude Code, Codex, Gemini, Cursor, opencode, omp). One Markdown vault, any harness.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-ai-memory": "bin/create-ai-memory.js",
|
package/shell/adapters.zsh
CHANGED
|
@@ -204,8 +204,10 @@ __ai_adapter_omp() {
|
|
|
204
204
|
export PATH="$ai_mem_bin:$PATH"
|
|
205
205
|
system_prompt+=$'\nUse the executable ai-mem-search for vault searches. Do not glob or read session-log files directly when answering memory questions; use ai-mem-search so project scope, archived-log filtering, ranking, and output limits remain correct.'
|
|
206
206
|
fi
|
|
207
|
+
# Research uses two sources: the ai-internet-search CLI for the authoritative
|
|
208
|
+
# core and the harness's built-in web search for breadth.
|
|
207
209
|
if command -v ai-internet-search >/dev/null 2>&1; then
|
|
208
|
-
system_prompt+=$'\
|
|
210
|
+
system_prompt+=$'\nFor explicit web research and current or uncertain external facts, use two sources every time: run ai-internet-search for the authoritative core, and run the built-in web search for breadth. Tell the user which facts came from each source.'
|
|
209
211
|
fi
|
|
210
212
|
if [[ -n "$mode_block" ]]; then
|
|
211
213
|
system_prompt+=$'\n\nActive local skill instructions:\n'
|
package/shell/ai-mem.zsh
CHANGED
|
@@ -519,10 +519,38 @@ __ai_mem_prepare_session() {
|
|
|
519
519
|
# Pull one "* **Label:** value" bullet out of a session log's fixed
|
|
520
520
|
# "# Session Outcome" section. Reads the log directly — no separate file is
|
|
521
521
|
# ever written, so there is nothing extra sitting in the vault.
|
|
522
|
+
#
|
|
523
|
+
# Indented lines under the bullet belong to it and are joined with "; ".
|
|
524
|
+
# Agents often write a field as a bare label with nested bullets; reading
|
|
525
|
+
# only the label line returned "", the digest showed "—", and the next agent
|
|
526
|
+
# was told there were no decisions when the log held a list of them (140 of
|
|
527
|
+
# 407 logs on a real vault). Blank lines inside the list are skipped; the
|
|
528
|
+
# first non-blank, non-indented line (next bullet or heading) ends the field.
|
|
522
529
|
__ai_mem_session_field() {
|
|
523
530
|
local file="$1" label="$2" value
|
|
524
531
|
[[ -f "$file" ]] || return 0
|
|
525
|
-
value="$(
|
|
532
|
+
value="$(awk -v prefix="* **${label}:**" '
|
|
533
|
+
!found {
|
|
534
|
+
if (index($0, prefix) == 1) {
|
|
535
|
+
found = 1
|
|
536
|
+
v = substr($0, length(prefix) + 1)
|
|
537
|
+
sub(/^[[:space:]]+/, "", v)
|
|
538
|
+
}
|
|
539
|
+
next
|
|
540
|
+
}
|
|
541
|
+
/^[[:space:]]*$/ { next }
|
|
542
|
+
/^[[:space:]]/ {
|
|
543
|
+
item = $0
|
|
544
|
+
sub(/^[[:space:]]+([-*+][[:space:]]+)?/, "", item)
|
|
545
|
+
# An item that already ends a sentence needs no extra "; ".
|
|
546
|
+
if (v == "") v = item
|
|
547
|
+
else if (v ~ /[.;:!?]$/) v = v " " item
|
|
548
|
+
else v = v "; " item
|
|
549
|
+
next
|
|
550
|
+
}
|
|
551
|
+
{ exit }
|
|
552
|
+
END { if (found) print v }
|
|
553
|
+
' "$file")"
|
|
526
554
|
# An untouched template still has its literal [bracket] placeholder — that
|
|
527
555
|
# is not real content, so treat it the same as an empty field.
|
|
528
556
|
[[ "$value" == \[*\] ]] && return 0
|