myagentmemory 0.4.6 → 0.4.7

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/dist/agent-memory CHANGED
Binary file
package/dist/core.js CHANGED
@@ -347,6 +347,24 @@ function resolveHomeDir() {
347
347
  return homeDirOverride;
348
348
  return process.env.HOME ?? process.env.USERPROFILE ?? null;
349
349
  }
350
+ function commandExists(cmd) {
351
+ const envPath = process.env.PATH ?? "";
352
+ if (!envPath)
353
+ return false;
354
+ const dirs = envPath.split(path.delimiter).filter(Boolean);
355
+ const isWin = process.platform === "win32";
356
+ const rawExts = isWin ? process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM" : "";
357
+ const exts = isWin ? rawExts.split(";").filter(Boolean) : [""];
358
+ for (const dir of dirs) {
359
+ for (const ext of exts) {
360
+ const fileName = isWin ? `${cmd}${ext}` : cmd;
361
+ const fullPath = path.join(dir, fileName);
362
+ if (fs.existsSync(fullPath))
363
+ return true;
364
+ }
365
+ }
366
+ return false;
367
+ }
350
368
  function findSkillsRoot() {
351
369
  const envRoot = process.env.AGENT_MEMORY_SKILLS_ROOT;
352
370
  if (envRoot)
@@ -612,12 +630,19 @@ export function installSkills() {
612
630
  srcDir: path.join(skillsDir, "claude-code"),
613
631
  destDir: path.join(homeDir, ".claude", "skills", "agent-memory"),
614
632
  homeMarker: path.join(homeDir, ".claude"),
633
+ detectFiles: [
634
+ path.join(homeDir, ".claude", "settings.json"),
635
+ path.join(homeDir, ".claude", "settings.local.json"),
636
+ ],
637
+ detectCommand: "claude",
615
638
  },
616
639
  {
617
640
  label: "Codex skill",
618
641
  srcDir: path.join(skillsDir, "codex"),
619
642
  destDir: path.join(homeDir, ".codex", "skills", "agent-memory"),
620
643
  homeMarker: path.join(homeDir, ".codex"),
644
+ detectFiles: [path.join(homeDir, ".codex", "config.toml")],
645
+ detectCommand: "codex",
621
646
  },
622
647
  {
623
648
  label: "Cursor skill",
@@ -640,6 +665,13 @@ export function installSkills() {
640
665
  skipped.push({ label: target.label, reason: `${target.homeMarker} not found` });
641
666
  continue;
642
667
  }
668
+ const detectedByFile = (target.detectFiles ?? []).some((file) => fs.existsSync(file));
669
+ const detectedByCommand = target.detectCommand ? commandExists(target.detectCommand) : false;
670
+ const requiresDetection = (target.detectFiles?.length ?? 0) > 0 || !!target.detectCommand;
671
+ if (requiresDetection && !detectedByFile && !detectedByCommand) {
672
+ skipped.push({ label: target.label, reason: "not detected" });
673
+ continue;
674
+ }
643
675
  detected.push({ label: target.label, homeMarker: target.homeMarker });
644
676
  const skillFile = path.join(target.srcDir, "SKILL.md");
645
677
  if (!fs.existsSync(skillFile)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagentmemory",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Persistent memory for coding agents (Claude Code, Codex, Cursor, Agent) with qmd-powered semantic search across daily logs, long-term memory, and scratchpad",
5
5
  "main": "./dist/core.js",
6
6
  "types": "./dist/core.d.ts",
@@ -8,7 +8,8 @@ function Install-Skill {
8
8
  [string]$Label,
9
9
  [string]$SrcDir,
10
10
  [string]$DestDir,
11
- [string]$HomeMarker
11
+ [string]$HomeMarker,
12
+ [ScriptBlock]$Detect
12
13
  )
13
14
 
14
15
  if (-not (Test-Path $HomeMarker)) {
@@ -16,6 +17,11 @@ function Install-Skill {
16
17
  return
17
18
  }
18
19
 
20
+ if ($Detect -and -not (& $Detect)) {
21
+ Write-Host "Skipping $Label (not detected)"
22
+ return
23
+ }
24
+
19
25
  $SkillSrc = Join-Path $SrcDir "SKILL.md"
20
26
  if (Test-Path $SkillSrc) {
21
27
  New-Item -ItemType Directory -Force -Path $DestDir | Out-Null
@@ -26,8 +32,8 @@ function Install-Skill {
26
32
  }
27
33
  }
28
34
 
29
- Install-Skill -Label "Claude Code skill" -SrcDir (Join-Path $ProjectDir "skills\\claude-code") -DestDir (Join-Path $env:USERPROFILE ".claude\\skills\\agent-memory") -HomeMarker (Join-Path $env:USERPROFILE ".claude")
30
- Install-Skill -Label "Codex skill" -SrcDir (Join-Path $ProjectDir "skills\\codex") -DestDir (Join-Path $env:USERPROFILE ".codex\\skills\\agent-memory") -HomeMarker (Join-Path $env:USERPROFILE ".codex")
35
+ Install-Skill -Label "Claude Code skill" -SrcDir (Join-Path $ProjectDir "skills\\claude-code") -DestDir (Join-Path $env:USERPROFILE ".claude\\skills\\agent-memory") -HomeMarker (Join-Path $env:USERPROFILE ".claude") -Detect { (Test-Path (Join-Path $env:USERPROFILE ".claude\\settings.json")) -or (Test-Path (Join-Path $env:USERPROFILE ".claude\\settings.local.json")) -or (Get-Command claude -ErrorAction SilentlyContinue) }
36
+ Install-Skill -Label "Codex skill" -SrcDir (Join-Path $ProjectDir "skills\\codex") -DestDir (Join-Path $env:USERPROFILE ".codex\\skills\\agent-memory") -HomeMarker (Join-Path $env:USERPROFILE ".codex") -Detect { (Test-Path (Join-Path $env:USERPROFILE ".codex\\config.toml")) -or (Get-Command codex -ErrorAction SilentlyContinue) }
31
37
  Install-Skill -Label "Cursor skill" -SrcDir (Join-Path $ProjectDir "skills\\cursor") -DestDir (Join-Path $env:USERPROFILE ".cursor\\skills\\agent-memory") -HomeMarker (Join-Path $env:USERPROFILE ".cursor")
32
38
  Install-Skill -Label "Agent CLI skill" -SrcDir (Join-Path $ProjectDir "skills\\agent") -DestDir (Join-Path $env:USERPROFILE ".agents\\skills\\agent-memory") -HomeMarker (Join-Path $env:USERPROFILE ".agents")
33
39
 
@@ -7,17 +7,27 @@ set -euo pipefail
7
7
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8
8
  PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
9
9
 
10
+ command_exists() {
11
+ command -v "$1" >/dev/null 2>&1
12
+ }
13
+
10
14
  install_skill() {
11
15
  local label="$1"
12
16
  local src_dir="$2"
13
17
  local dest_dir="$3"
14
18
  local home_marker="$4"
19
+ local detect_cmd="$5"
15
20
 
16
21
  if [ ! -d "$home_marker" ]; then
17
22
  echo "Skipping $label ($home_marker not found)"
18
23
  return
19
24
  fi
20
25
 
26
+ if [ -n "$detect_cmd" ] && ! eval "$detect_cmd"; then
27
+ echo "Skipping $label (not detected)"
28
+ return
29
+ fi
30
+
21
31
  if [ -d "$src_dir" ]; then
22
32
  mkdir -p "$dest_dir"
23
33
  cp "$src_dir/SKILL.md" "$dest_dir/SKILL.md"
@@ -27,8 +37,8 @@ install_skill() {
27
37
  fi
28
38
  }
29
39
 
30
- install_skill "Claude Code skill" "$PROJECT_DIR/skills/claude-code" "$HOME/.claude/skills/agent-memory" "$HOME/.claude"
31
- install_skill "Codex skill" "$PROJECT_DIR/skills/codex" "$HOME/.codex/skills/agent-memory" "$HOME/.codex"
40
+ install_skill "Claude Code skill" "$PROJECT_DIR/skills/claude-code" "$HOME/.claude/skills/agent-memory" "$HOME/.claude" '[ -f "$HOME/.claude/settings.json" ] || [ -f "$HOME/.claude/settings.local.json" ] || command_exists claude'
41
+ install_skill "Codex skill" "$PROJECT_DIR/skills/codex" "$HOME/.codex/skills/agent-memory" "$HOME/.codex" '[ -f "$HOME/.codex/config.toml" ] || command_exists codex'
32
42
  install_skill "Cursor skill" "$PROJECT_DIR/skills/cursor" "$HOME/.cursor/skills/agent-memory" "$HOME/.cursor"
33
43
  install_skill "Agent CLI skill" "$PROJECT_DIR/skills/agent" "$HOME/.agents/skills/agent-memory" "$HOME/.agents"
34
44
 
package/src/core.ts CHANGED
@@ -476,6 +476,26 @@ function resolveHomeDir(): string | null {
476
476
  return process.env.HOME ?? process.env.USERPROFILE ?? null;
477
477
  }
478
478
 
479
+ function commandExists(cmd: string): boolean {
480
+ const envPath = process.env.PATH ?? "";
481
+ if (!envPath) return false;
482
+
483
+ const dirs = envPath.split(path.delimiter).filter(Boolean);
484
+ const isWin = process.platform === "win32";
485
+ const rawExts = isWin ? process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM" : "";
486
+ const exts = isWin ? rawExts.split(";").filter(Boolean) : [""];
487
+
488
+ for (const dir of dirs) {
489
+ for (const ext of exts) {
490
+ const fileName = isWin ? `${cmd}${ext}` : cmd;
491
+ const fullPath = path.join(dir, fileName);
492
+ if (fs.existsSync(fullPath)) return true;
493
+ }
494
+ }
495
+
496
+ return false;
497
+ }
498
+
479
499
  function findSkillsRoot(): string | null {
480
500
  const envRoot = process.env.AGENT_MEMORY_SKILLS_ROOT;
481
501
  if (envRoot) return envRoot;
@@ -766,12 +786,19 @@ export function installSkills(): InstallSkillsReport {
766
786
  srcDir: path.join(skillsDir, "claude-code"),
767
787
  destDir: path.join(homeDir, ".claude", "skills", "agent-memory"),
768
788
  homeMarker: path.join(homeDir, ".claude"),
789
+ detectFiles: [
790
+ path.join(homeDir, ".claude", "settings.json"),
791
+ path.join(homeDir, ".claude", "settings.local.json"),
792
+ ],
793
+ detectCommand: "claude",
769
794
  },
770
795
  {
771
796
  label: "Codex skill",
772
797
  srcDir: path.join(skillsDir, "codex"),
773
798
  destDir: path.join(homeDir, ".codex", "skills", "agent-memory"),
774
799
  homeMarker: path.join(homeDir, ".codex"),
800
+ detectFiles: [path.join(homeDir, ".codex", "config.toml")],
801
+ detectCommand: "codex",
775
802
  },
776
803
  {
777
804
  label: "Cursor skill",
@@ -796,6 +823,14 @@ export function installSkills(): InstallSkillsReport {
796
823
  skipped.push({ label: target.label, reason: `${target.homeMarker} not found` });
797
824
  continue;
798
825
  }
826
+ const detectedByFile = (target.detectFiles ?? []).some((file) => fs.existsSync(file));
827
+ const detectedByCommand = target.detectCommand ? commandExists(target.detectCommand) : false;
828
+ const requiresDetection = (target.detectFiles?.length ?? 0) > 0 || !!target.detectCommand;
829
+ if (requiresDetection && !detectedByFile && !detectedByCommand) {
830
+ skipped.push({ label: target.label, reason: "not detected" });
831
+ continue;
832
+ }
833
+
799
834
  detected.push({ label: target.label, homeMarker: target.homeMarker });
800
835
 
801
836
  const skillFile = path.join(target.srcDir, "SKILL.md");