openclaw-langcache 1.0.1 → 1.1.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 +6 -4
- package/claude-skills/langcache/SKILL.md +173 -0
- package/claude-skills/langcache/examples/agent-integration.py +453 -0
- package/claude-skills/langcache/examples/basic-caching.sh +56 -0
- package/claude-skills/langcache/references/api-reference.md +260 -0
- package/claude-skills/langcache/references/best-practices.md +215 -0
- package/claude-skills/langcache/scripts/langcache.sh +528 -0
- package/package.json +13 -8
- package/scripts/postinstall.js +67 -53
package/scripts/postinstall.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Postinstall script for
|
|
4
|
-
*
|
|
3
|
+
* Postinstall script for openclaw-langcache
|
|
4
|
+
* Installs the skill to both OpenClaw and Claude Code workspaces
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const fs = require('fs');
|
|
@@ -10,22 +10,20 @@ const os = require('os');
|
|
|
10
10
|
|
|
11
11
|
const SKILL_NAME = 'langcache';
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
function
|
|
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
|
|
13
|
+
// Get installation paths
|
|
14
|
+
function getInstallPaths() {
|
|
21
15
|
const home = os.homedir();
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
return {
|
|
18
|
+
openclaw: path.join(
|
|
19
|
+
process.env.OPENCLAW_HOME || path.join(home, '.openclaw'),
|
|
20
|
+
'workspace', 'skills'
|
|
21
|
+
),
|
|
22
|
+
claude: path.join(
|
|
23
|
+
process.env.CLAUDE_HOME || path.join(home, '.claude'),
|
|
24
|
+
'skills'
|
|
25
|
+
)
|
|
26
|
+
};
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
// Recursively copy directory
|
|
@@ -43,59 +41,75 @@ function copyDir(src, dest) {
|
|
|
43
41
|
} else {
|
|
44
42
|
fs.copyFileSync(srcPath, destPath);
|
|
45
43
|
|
|
46
|
-
// Make shell scripts executable
|
|
47
|
-
if (entry.name.endsWith('.sh')) {
|
|
44
|
+
// Make shell scripts and python files executable
|
|
45
|
+
if (entry.name.endsWith('.sh') || entry.name.endsWith('.py')) {
|
|
48
46
|
fs.chmodSync(destPath, 0o755);
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
|
|
52
|
+
function installSkill(name, srcDir, destDir, skillSrcPath) {
|
|
53
|
+
const destPath = path.join(destDir, SKILL_NAME);
|
|
54
|
+
|
|
55
|
+
if (!fs.existsSync(skillSrcPath)) {
|
|
56
|
+
console.log(` ⚠ ${name}: Source not found, skipping`);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Create skills directory if needed
|
|
61
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
62
|
+
|
|
63
|
+
// Check if already exists
|
|
64
|
+
if (fs.existsSync(destPath)) {
|
|
65
|
+
console.log(` ⚠ ${name}: Already exists at ${destPath}`);
|
|
66
|
+
console.log(` To update: rm -rf ${destPath} && npm install openclaw-langcache`);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Copy skill
|
|
71
|
+
copyDir(skillSrcPath, destPath);
|
|
72
|
+
console.log(` ✓ ${name}: Installed to ${destPath}`);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
54
76
|
function main() {
|
|
55
|
-
|
|
56
|
-
const skillsPath = getOpenClawPath();
|
|
57
|
-
const destPath = path.join(skillsPath, SKILL_NAME);
|
|
77
|
+
console.log('\n📦 Installing langcache skill...\n');
|
|
58
78
|
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
try {
|
|
80
|
+
const paths = getInstallPaths();
|
|
61
81
|
const packageRoot = path.dirname(__dirname);
|
|
62
|
-
const srcPath = path.join(packageRoot, 'skills', SKILL_NAME);
|
|
63
82
|
|
|
64
|
-
|
|
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 });
|
|
83
|
+
let installed = 0;
|
|
71
84
|
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(` rm -rf ${destPath}`);
|
|
77
|
-
console.log(' npm install @openclaw/langcache');
|
|
78
|
-
return;
|
|
85
|
+
// Install OpenClaw skill
|
|
86
|
+
const openclawSrc = path.join(packageRoot, 'skills', SKILL_NAME);
|
|
87
|
+
if (installSkill('OpenClaw', 'skills', paths.openclaw, openclawSrc)) {
|
|
88
|
+
installed++;
|
|
79
89
|
}
|
|
80
90
|
|
|
81
|
-
//
|
|
82
|
-
|
|
91
|
+
// Install Claude Code skill
|
|
92
|
+
const claudeSrc = path.join(packageRoot, 'claude-skills', SKILL_NAME);
|
|
93
|
+
if (installSkill('Claude Code', 'claude-skills', paths.claude, claudeSrc)) {
|
|
94
|
+
installed++;
|
|
95
|
+
}
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
if (installed > 0) {
|
|
98
|
+
console.log('\n✅ Installation complete!\n');
|
|
99
|
+
console.log('Next steps:');
|
|
100
|
+
console.log('1. Set your Redis LangCache credentials:');
|
|
101
|
+
console.log(' export LANGCACHE_HOST=your-instance.redis.cloud');
|
|
102
|
+
console.log(' export LANGCACHE_CACHE_ID=your-cache-id');
|
|
103
|
+
console.log(' export LANGCACHE_API_KEY=your-api-key');
|
|
104
|
+
console.log('');
|
|
105
|
+
console.log('2. The skill auto-activates when you mention "semantic caching"');
|
|
106
|
+
console.log(' or invoke manually with /langcache');
|
|
107
|
+
console.log('');
|
|
108
|
+
}
|
|
94
109
|
|
|
95
110
|
} catch (err) {
|
|
96
|
-
|
|
97
|
-
console.warn(
|
|
98
|
-
console.warn('You can manually copy the skill from node_modules/@openclaw/langcache/skills/');
|
|
111
|
+
console.warn(`⚠ Warning: ${err.message}`);
|
|
112
|
+
console.warn('You can manually copy skills from node_modules/openclaw-langcache/');
|
|
99
113
|
}
|
|
100
114
|
}
|
|
101
115
|
|