@lexicallayer/cli 0.1.3 → 0.1.5

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.
Files changed (2) hide show
  1. package/bin/index.js +78 -2
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -95,8 +95,44 @@ async function calibrate() {
95
95
  const verifyRes = await requestJSON(`${ENGINE_BASE_URL}/api/session/verify/${sessionId}`);
96
96
  if (verifyRes?.session?.approved) {
97
97
  approved = true;
98
+ const adapterFile = verifyRes.session.adapter_filename || "user_steered_rank16.safetensors";
98
99
  log("\n\x1b[32m✓ Başarılı! Kullanıcı Studio üzerinden ağırlıkları onayladı ve kilitledi.\x1b[0m");
99
- log(`Bağlanan Adaptör: \x1b[36m${verifyRes.session.adapter_filename || "user_steered_rank16.safetensors"}\x1b[0m`);
100
+ log(`Bağlanan Adaptör: \x1b[36m${adapterFile}\x1b[0m`);
101
+
102
+ // Generate a ready-to-use Agent Layer file directly in the developer's project
103
+ const fs = require("fs");
104
+ const path = require("path");
105
+ const targetDir = path.join(process.cwd(), ".lexicallayer");
106
+
107
+ if (!fs.existsSync(targetDir)) {
108
+ fs.mkdirSync(targetDir, { recursive: true });
109
+ }
110
+
111
+ const agentLayerCode = `// Otomatik Üretilen LexicalLayer Agent Katmanı
112
+ const { LexicalLayer } = require("@lexicallayer/sdk");
113
+
114
+ const layer = new LexicalLayer({
115
+ agentName: "${sessionPayload.agent_name}",
116
+ adapterFile: "${adapterFile}"
117
+ });
118
+
119
+ /**
120
+ * Bu fonksiyonu agent'ınızın OpenAI/Claude/LangChain client'ına sarın:
121
+ * const steeredOpenAI = wrapAgentWithUserStyle(openai);
122
+ */
123
+ function wrapAgentWithUserStyle(agentClient) {
124
+ return layer.wrapOpenAI(agentClient);
125
+ }
126
+
127
+ module.exports = { layer, wrapAgentWithUserStyle };
128
+ `;
129
+ fs.writeFileSync(path.join(targetDir, "layer.js"), agentLayerCode, "utf-8");
130
+
131
+ console.log(`\n\x1b[35m[LexicalLayer Entegrasyonu Tamamlandı]\x1b[0m`);
132
+ console.log(`📂 Projenize katman dosyası eklendi: \x1b[33m.lexicallayer/layer.js\x1b[0m`);
133
+ console.log(`\n\x1b[32mAgent'ınızda Kullanmak İçin Tek Satır:\x1b[0m`);
134
+ console.log(`\x1b[36mconst { wrapAgentWithUserStyle } = require("./.lexicallayer/layer");\x1b[0m`);
135
+ console.log(`\x1b[36mconst myAgent = wrapAgentWithUserStyle(openai);\x1b[0m\n`);
100
136
  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");
101
137
  process.exit(0);
102
138
  }
@@ -116,15 +152,55 @@ async function calibrate() {
116
152
  }
117
153
  }
118
154
 
155
+ async function startChat() {
156
+ const readline = require("readline");
157
+ const rl = readline.createInterface({
158
+ input: process.stdin,
159
+ output: process.stdout
160
+ });
161
+
162
+ log("\x1b[32mKalibre Edilmiş Model Başlatıldı (Rank-16 LoRA + Residual Steering Aktif)!\x1b[0m");
163
+ log("Çıkmak için 'q' veya 'exit' yazabilirsiniz.\n");
164
+
165
+ const promptUser = () => {
166
+ rl.question("\x1b[33mSen: \x1b[0m", async (input) => {
167
+ const q = input.trim();
168
+ if (!q || q === "exit" || q === "q") {
169
+ log("Oturum kapatıldı.");
170
+ rl.close();
171
+ process.exit(0);
172
+ }
173
+
174
+ try {
175
+ const res = await requestJSON(`${ENGINE_BASE_URL}/api/user-weights/test`, { method: "POST" }, {
176
+ prompt: q,
177
+ use_user_weights: true
178
+ });
179
+
180
+ console.log(`\n\x1b[36mModel (Kalibre Ağırlıklarla): \x1b[0m${res.output}\n`);
181
+ } catch (err) {
182
+ console.log(`Hata: ${err.message}`);
183
+ }
184
+
185
+ promptUser();
186
+ });
187
+ };
188
+
189
+ promptUser();
190
+ }
191
+
119
192
  if (command === "calibrate") {
120
193
  calibrate();
194
+ } else if (command === "chat") {
195
+ startChat();
121
196
  } else if (command === "--version" || command === "-v") {
122
- console.log("0.1.0");
197
+ console.log("0.1.4");
123
198
  } else {
124
199
  console.log(`
125
200
  LexicalLayer CLI
126
201
  Kullanım:
127
202
  lexicallayer calibrate Studio arayüzünü açar ve agent için ağırlık türetir
203
+ lexicallayer chat Kalibre edilmiş ağırlıklarla terminalde doğrudan sohbet et
128
204
  lexicallayer --version Versiyon bilgisi
129
205
  `);
130
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexicallayer/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "LexicalLayer CLI - Representation engineering and authentic weight calibration for AI agents",
5
5
  "main": "bin/index.js",
6
6
  "bin": {