openclaw-langcache 1.0.0 → 1.0.1
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 +1 -1
- package/package.json +2 -1
- package/scripts/postinstall.js +102 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Reduce LLM costs and latency by caching responses for semantically similar queri
|
|
|
20
20
|
### Via npm (Recommended)
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm install
|
|
23
|
+
npm install openclaw-langcache
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
The skill will be automatically installed to your OpenClaw workspace.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-langcache",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Semantic caching skill for OpenClaw using Redis LangCache",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openclaw",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"skills/",
|
|
29
|
+
"scripts/",
|
|
29
30
|
"README.md",
|
|
30
31
|
"LICENSE"
|
|
31
32
|
],
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script for @openclaw/langcache
|
|
4
|
+
* Copies the skill to the user's OpenClaw workspace
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
|
|
11
|
+
const SKILL_NAME = 'langcache';
|
|
12
|
+
|
|
13
|
+
// Determine OpenClaw workspace path
|
|
14
|
+
function getOpenClawPath() {
|
|
15
|
+
// Check OPENCLAW_HOME environment variable first
|
|
16
|
+
if (process.env.OPENCLAW_HOME) {
|
|
17
|
+
return path.join(process.env.OPENCLAW_HOME, 'workspace', 'skills');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Default paths by platform
|
|
21
|
+
const home = os.homedir();
|
|
22
|
+
|
|
23
|
+
if (process.platform === 'win32') {
|
|
24
|
+
return path.join(home, '.openclaw', 'workspace', 'skills');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// macOS and Linux
|
|
28
|
+
return path.join(home, '.openclaw', 'workspace', 'skills');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Recursively copy directory
|
|
32
|
+
function copyDir(src, dest) {
|
|
33
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
34
|
+
|
|
35
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
36
|
+
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const srcPath = path.join(src, entry.name);
|
|
39
|
+
const destPath = path.join(dest, entry.name);
|
|
40
|
+
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
copyDir(srcPath, destPath);
|
|
43
|
+
} else {
|
|
44
|
+
fs.copyFileSync(srcPath, destPath);
|
|
45
|
+
|
|
46
|
+
// Make shell scripts executable
|
|
47
|
+
if (entry.name.endsWith('.sh')) {
|
|
48
|
+
fs.chmodSync(destPath, 0o755);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function main() {
|
|
55
|
+
try {
|
|
56
|
+
const skillsPath = getOpenClawPath();
|
|
57
|
+
const destPath = path.join(skillsPath, SKILL_NAME);
|
|
58
|
+
|
|
59
|
+
// Find the source skill directory
|
|
60
|
+
// When installed via npm, we're in node_modules/@openclaw/langcache
|
|
61
|
+
const packageRoot = path.dirname(__dirname);
|
|
62
|
+
const srcPath = path.join(packageRoot, 'skills', SKILL_NAME);
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(srcPath)) {
|
|
65
|
+
console.log(`Source skill not found at ${srcPath}, skipping installation`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Create skills directory if it doesn't exist
|
|
70
|
+
fs.mkdirSync(skillsPath, { recursive: true });
|
|
71
|
+
|
|
72
|
+
// Check if skill already exists
|
|
73
|
+
if (fs.existsSync(destPath)) {
|
|
74
|
+
console.log(`Skill '${SKILL_NAME}' already exists at ${destPath}`);
|
|
75
|
+
console.log('To update, remove the existing skill and reinstall:');
|
|
76
|
+
console.log(` rm -rf ${destPath}`);
|
|
77
|
+
console.log(' npm install @openclaw/langcache');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Copy skill to workspace
|
|
82
|
+
copyDir(srcPath, destPath);
|
|
83
|
+
|
|
84
|
+
console.log(`\n✓ Installed '${SKILL_NAME}' skill to ${destPath}\n`);
|
|
85
|
+
console.log('Next steps:');
|
|
86
|
+
console.log('1. Add your Redis LangCache credentials to ~/.openclaw/secrets.env:');
|
|
87
|
+
console.log(' LANGCACHE_HOST=your-instance.redis.cloud');
|
|
88
|
+
console.log(' LANGCACHE_CACHE_ID=your-cache-id');
|
|
89
|
+
console.log(' LANGCACHE_API_KEY=your-api-key');
|
|
90
|
+
console.log('');
|
|
91
|
+
console.log('2. The skill will auto-activate when you mention "semantic caching"');
|
|
92
|
+
console.log(' or use the CLI: langcache.sh search "your query"');
|
|
93
|
+
console.log('');
|
|
94
|
+
|
|
95
|
+
} catch (err) {
|
|
96
|
+
// Don't fail the npm install if postinstall fails
|
|
97
|
+
console.warn(`Warning: Could not install skill to OpenClaw workspace: ${err.message}`);
|
|
98
|
+
console.warn('You can manually copy the skill from node_modules/@openclaw/langcache/skills/');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
main();
|