@lexicallayer/cli 0.0.0-stage → 0.1.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 +21 -2
- package/bin/index.js +124 -0
- package/package.json +25 -4
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lexicallayer/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Representation Engineering & Authentic Weight Calibration CLI for AI Agents.
|
|
4
|
+
|
|
5
|
+
## Kurulum ve Kullanım
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Kurulum gerektirmeden doğrudan çalıştırma:
|
|
9
|
+
npx @lexicallayer/cli calibrate
|
|
10
|
+
|
|
11
|
+
# veya global kurulum:
|
|
12
|
+
npm install -g @lexicallayer/cli
|
|
13
|
+
lexicallayer calibrate
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Nasıl Çalışır?
|
|
17
|
+
|
|
18
|
+
1. CLI çalıştırıldığında bir handshake oturumu başlatır (`lx_sess_...`).
|
|
19
|
+
2. Tarayıcıda LexicalLayer Studio açılır.
|
|
20
|
+
3. Kullanıcı kendi yazılarını, dokümanlarını veya blogunu ekler.
|
|
21
|
+
4. Modelin Rank-16 LoRA $\Delta W$ adaptörü ve Residual Steering vektörleri sentezlenir.
|
|
22
|
+
5. Kullanıcı Studio'da **"Ağırlığı Onayla & Agent'a Kilitle"** butonuna bastığında CLI `.safetensors` dosyasını teslim alarak başarıyla sonlanır.
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @lexicallayer/cli
|
|
5
|
+
* Representation Engineering & Weight Calibration CLI for AI Agents
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const http = require("http");
|
|
9
|
+
const https = require("https");
|
|
10
|
+
const { exec } = require("child_process");
|
|
11
|
+
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
const command = args[0] || "calibrate";
|
|
14
|
+
|
|
15
|
+
const STUDIO_BASE_URL = process.env.LEXICALLAYER_STUDIO_URL || "http://localhost:3000";
|
|
16
|
+
const ENGINE_BASE_URL = process.env.LEXICALLAYER_ENGINE_URL || "http://127.0.0.1:8001";
|
|
17
|
+
|
|
18
|
+
function log(msg) {
|
|
19
|
+
process.stdout.write(`\x1b[36m[LexicalLayer CLI]\x1b[0m ${msg}\n`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function requestJSON(url, options = {}, data = null) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const isHttps = url.startsWith("https://");
|
|
25
|
+
const client = isHttps ? https : http;
|
|
26
|
+
const urlObj = new URL(url);
|
|
27
|
+
|
|
28
|
+
const reqOptions = {
|
|
29
|
+
hostname: urlObj.hostname,
|
|
30
|
+
port: urlObj.port || (isHttps ? 443 : 80),
|
|
31
|
+
path: urlObj.pathname + urlObj.search,
|
|
32
|
+
method: options.method || "GET",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
...(data ? { "Content-Length": Buffer.byteLength(JSON.stringify(data)) } : {}),
|
|
36
|
+
...(options.headers || {})
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const req = client.request(reqOptions, (res) => {
|
|
41
|
+
let body = "";
|
|
42
|
+
res.on("data", (chunk) => (body += chunk));
|
|
43
|
+
res.on("end", () => {
|
|
44
|
+
try {
|
|
45
|
+
resolve(JSON.parse(body));
|
|
46
|
+
} catch {
|
|
47
|
+
resolve({ raw: body });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
req.on("error", reject);
|
|
53
|
+
if (data) req.write(JSON.stringify(data));
|
|
54
|
+
req.end();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function openBrowser(url) {
|
|
59
|
+
const startCmd = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
60
|
+
exec(`${startCmd} "${url}"`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function calibrate() {
|
|
64
|
+
log("\x1b[32mAgent Kimlik Doğrulama ve Ağırlık Kalibrasyonu Başlatılıyor...\x1b[0m");
|
|
65
|
+
|
|
66
|
+
const sessionPayload = {
|
|
67
|
+
agent_name: process.env.AGENT_NAME || "dev-agent",
|
|
68
|
+
email: process.env.AGENT_EMAIL || "developer@local.workspace"
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const initRes = await requestJSON(`${ENGINE_BASE_URL}/api/session/init`, { method: "POST" }, sessionPayload).catch(() => null);
|
|
73
|
+
const sessionId = initRes?.session?.id || `lx_sess_${Date.now()}`;
|
|
74
|
+
const targetUrl = `${STUDIO_BASE_URL}/studio?session=${sessionId}`;
|
|
75
|
+
|
|
76
|
+
log(`Oturum Anahtarı: \x1b[33m${sessionId}\x1b[0m`);
|
|
77
|
+
log(`Tarayıcı Açılıyor: \x1b[34m${targetUrl}\x1b[0m`);
|
|
78
|
+
log("Kullanıcının Studio üzerinden verilerini girmesi ve ağırlığı onaylaması bekleniyor...");
|
|
79
|
+
|
|
80
|
+
openBrowser(targetUrl);
|
|
81
|
+
|
|
82
|
+
let approved = false;
|
|
83
|
+
let attempts = 0;
|
|
84
|
+
while (!approved && attempts < 180) {
|
|
85
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
86
|
+
attempts++;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const verifyRes = await requestJSON(`${ENGINE_BASE_URL}/api/session/verify/${sessionId}`);
|
|
90
|
+
if (verifyRes?.session?.approved) {
|
|
91
|
+
approved = true;
|
|
92
|
+
log("\n\x1b[32m✓ Başarılı! Kullanıcı Studio üzerinden ağırlıkları onayladı ve kilitledi.\x1b[0m");
|
|
93
|
+
log(`Bağlanan Adaptör: \x1b[36m${verifyRes.session.adapter_filename || "user_steered_rank16.safetensors"}\x1b[0m`);
|
|
94
|
+
log("\x1b[32mAgent'ınız artık kullanıcının özgün üslubu ve ağırlıkları ile çalışmaya hazır!\x1b[0m");
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
// Retry
|
|
99
|
+
}
|
|
100
|
+
process.stdout.write(".");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!approved) {
|
|
104
|
+
log("\n\x1b[31mOturum zaman aşımına uğradı.\x1b[0m");
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
} catch (err) {
|
|
108
|
+
log(`\x1b[31mHata:\x1b[0m ${err.message}`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (command === "calibrate") {
|
|
114
|
+
calibrate();
|
|
115
|
+
} else if (command === "--version" || command === "-v") {
|
|
116
|
+
console.log("0.1.0");
|
|
117
|
+
} else {
|
|
118
|
+
console.log(`
|
|
119
|
+
LexicalLayer CLI
|
|
120
|
+
Kullanım:
|
|
121
|
+
lexicallayer calibrate Studio arayüzünü açar ve agent için ağırlık türetir
|
|
122
|
+
lexicallayer --version Versiyon bilgisi
|
|
123
|
+
`);
|
|
124
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexicallayer/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "LexicalLayer CLI - Representation engineering and authentic weight calibration for AI agents",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lexicallayer": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"agents",
|
|
16
|
+
"lora",
|
|
17
|
+
"safetensors",
|
|
18
|
+
"steering-vectors",
|
|
19
|
+
"representation-engineering",
|
|
20
|
+
"llm"
|
|
21
|
+
],
|
|
22
|
+
"author": "LexicalLayer Team",
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
}
|
|
27
|
+
}
|