@lasso-ai/cli 1.3.7 → 1.3.9

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.
@@ -1183,47 +1183,14 @@ async function startBridge(cwd = process.cwd(), collabConfig = null, bridgePort
1183
1183
  }
1184
1184
  else if (msg.type === "apply") {
1185
1185
  try {
1186
- socket.send(JSON.stringify({
1187
- type: "agent_status",
1188
- taskId: msg.taskId,
1189
- status: "working",
1190
- message: "Re-generating changes with current file state..."
1191
- }));
1192
- // Re-run the edit request to get fresh changes based on current file state
1193
- const editRequest = editRequests.get(msg.taskId);
1194
- const editConfig = editConfigs.get(msg.taskId);
1195
- if (!editRequest || !editConfig) {
1196
- socket.send(JSON.stringify({
1197
- type: "agent_status",
1198
- taskId: msg.taskId,
1199
- status: "error",
1200
- message: "Could not re-generate changes: original request not found."
1201
- }));
1202
- return;
1203
- }
1204
- const controller = new AbortController();
1205
- taskControllers.set(msg.taskId, controller);
1206
- const freshProposal = await (0, agent_1.proposeChanges)(cwd, editRequest, editConfig, controller.signal, (message, detail, level) => {
1207
- if (!controller.signal.aborted && socket.readyState === socket.OPEN) {
1208
- socket.send(JSON.stringify({ type: "agent_status", taskId: msg.taskId, status: level === "error" ? "error" : "working", message, detail }));
1209
- }
1210
- }, (prompt) => {
1211
- if (!controller.signal.aborted && socket.readyState === socket.OPEN) {
1212
- socket.send(JSON.stringify({ type: "agent_prompt", taskId: msg.taskId, prompt }));
1213
- }
1214
- });
1215
- if (controller.signal.aborted) {
1216
- socket.send(JSON.stringify({ type: "agent_status", taskId: msg.taskId, status: "stopped", message: "Agent stopped." }));
1217
- return;
1218
- }
1219
- // Apply the fresh changes
1220
- const filePaths = [...new Set(freshProposal.changes.map(c => c.filePath))];
1186
+ // Create snapshot before applying changes
1187
+ const filePaths = [...new Set(msg.changes.map(c => c.filePath))];
1221
1188
  const parentSnapshot = (0, snapshot_1.getSnapshotByTaskId)(cwd, msg.taskId);
1222
1189
  // Create pre-apply snapshot
1223
- const preSnapshot = (0, snapshot_1.createSnapshot)(cwd, msg.taskId, `Pre-apply: ${freshProposal.changes.length} file${freshProposal.changes.length === 1 ? "" : "s"}`, filePaths, parentSnapshot?.id);
1190
+ const preSnapshot = (0, snapshot_1.createSnapshot)(cwd, msg.taskId, `Pre-apply: ${msg.changes.length} file${msg.changes.length === 1 ? "" : "s"}`, filePaths, parentSnapshot?.id);
1224
1191
  const snapshots = [];
1225
1192
  const planned = new Map();
1226
- for (const change of freshProposal.changes) {
1193
+ for (const change of msg.changes) {
1227
1194
  const isNew = !change.oldString;
1228
1195
  const filePath = resolveProposedFile(cwd, change.filePath, true);
1229
1196
  const exists = node_fs_1.default.existsSync(filePath);
@@ -1253,7 +1220,7 @@ async function startBridge(cwd = process.cwd(), collabConfig = null, bridgePort
1253
1220
  node_fs_1.default.writeFileSync(filePath, nextContent);
1254
1221
  }
1255
1222
  // Create post-apply snapshot
1256
- (0, snapshot_1.createSnapshot)(cwd, msg.taskId, `Applied: ${freshProposal.changes.length} file${freshProposal.changes.length === 1 ? "" : "s"}`, filePaths, preSnapshot.id);
1223
+ (0, snapshot_1.createSnapshot)(cwd, msg.taskId, `Applied: ${msg.changes.length} file${msg.changes.length === 1 ? "" : "s"}`, filePaths, preSnapshot.id);
1257
1224
  // Run build validation after applying changes
1258
1225
  const validation = await validateBuild(cwd);
1259
1226
  if (!validation.passed) {
@@ -1270,17 +1237,17 @@ async function startBridge(cwd = process.cwd(), collabConfig = null, bridgePort
1270
1237
  buildErrorContext.set(msg.taskId, {
1271
1238
  errors: validation.errors,
1272
1239
  command: validation.command,
1273
- originalChanges: freshProposal.changes,
1240
+ originalChanges: msg.changes,
1274
1241
  retryCount: 0
1275
1242
  });
1276
1243
  // Trigger automatic build fix
1277
- await triggerBuildFix(cwd, msg.taskId, validation.errors, validation.command, freshProposal.changes, resolvedLassoKey, agentConfig, collabConfig, socket, taskControllers, taskSnapshots, buildErrorContext);
1244
+ await triggerBuildFix(cwd, msg.taskId, validation.errors, validation.command, msg.changes, resolvedLassoKey, agentConfig, collabConfig, socket, taskControllers, taskSnapshots, buildErrorContext);
1278
1245
  return;
1279
1246
  }
1280
1247
  socket.send(JSON.stringify({
1281
1248
  type: "applied",
1282
1249
  taskId: msg.taskId,
1283
- message: `${freshProposal.changes.length} file${freshProposal.changes.length === 1 ? "" : "s"} updated. Your dev server will reload.`,
1250
+ message: `${msg.changes.length} file${msg.changes.length === 1 ? "" : "s"} updated. Your dev server will reload.`,
1284
1251
  validation
1285
1252
  }));
1286
1253
  }
@@ -17,6 +17,8 @@ const runtime_1 = require("./runtime");
17
17
  const dns_1 = require("./dns");
18
18
  const paths_1 = require("./paths");
19
19
  const certificates_1 = require("./certificates");
20
+ const package_json_1 = __importDefault(require("../../../package.json"));
21
+ const CURRENT_VERSION = package_json_1.default.version;
20
22
  exports.SERVICE_NAME = "lasso-host";
21
23
  function writeJson(res, status, body) {
22
24
  res.writeHead(status, { "content-type": "application/json" });
@@ -247,7 +249,9 @@ class LassoHost {
247
249
  writeJson(res, 200, {
248
250
  ok: true,
249
251
  service: exports.SERVICE_NAME,
250
- version: this.opts.version || "unknown",
252
+ version: this.opts.version || CURRENT_VERSION,
253
+ installedVersion: CURRENT_VERSION,
254
+ versionMismatch: (this.opts.version || CURRENT_VERSION) !== CURRENT_VERSION,
251
255
  pid: process.pid,
252
256
  dnsPort: this.dnsHandle?.port ?? null,
253
257
  proxyPort: this.opts.proxyPort,
@@ -5,6 +5,7 @@ export declare function spawnDaemon(env: Record<string, string>): Promise<{
5
5
  alreadyRunning?: boolean;
6
6
  pid?: number;
7
7
  error?: string;
8
+ restarted?: boolean;
8
9
  }>;
9
10
  export declare function isAutoStartInstalled(): boolean;
10
11
  export declare function enableAutoStart(): Promise<{
@@ -17,9 +17,12 @@ const node_os_1 = __importDefault(require("node:os"));
17
17
  const node_path_1 = __importDefault(require("node:path"));
18
18
  const node_readline_1 = __importDefault(require("node:readline"));
19
19
  const node_child_process_1 = require("node:child_process");
20
+ const chalk_1 = __importDefault(require("chalk"));
20
21
  const client_1 = require("./client");
21
22
  const dns_1 = require("./dns");
22
23
  const paths_1 = require("./paths");
24
+ const package_json_1 = __importDefault(require("../../../package.json"));
25
+ const CURRENT_VERSION = package_json_1.default.version;
23
26
  const AGENT_LABEL = "com.lasso.host";
24
27
  const LAUNCH_AGENT_FILE = node_path_1.default.join(node_os_1.default.homedir(), "Library", "LaunchAgents", `${AGENT_LABEL}.plist`);
25
28
  function cliEntry() {
@@ -31,8 +34,18 @@ function spawnDaemon(env) {
31
34
  const dnsPort = (0, paths_1.hostDnsPort)(env);
32
35
  const httpsPort = (0, paths_1.hostHttpsPort)(env);
33
36
  return (0, client_1.hostAlive)(port).then(async (health) => {
34
- if (health)
35
- return { ok: true, alreadyRunning: true };
37
+ if (health) {
38
+ // Check if the running daemon has a different version
39
+ if (health.version && health.version !== CURRENT_VERSION) {
40
+ console.log(chalk_1.default.yellow(`!`) + ` Lasso Host is running version ${health.version} but installed version is ${CURRENT_VERSION}. Restarting...`);
41
+ await stopDaemon(env);
42
+ // Wait a moment for the daemon to stop
43
+ await new Promise(resolve => setTimeout(resolve, 1000));
44
+ }
45
+ else {
46
+ return { ok: true, alreadyRunning: true };
47
+ }
48
+ }
36
49
  const entry = cliEntry();
37
50
  if (!entry)
38
51
  return { ok: false, error: "Could not resolve the Lasso CLI entry point. Run this from the installed CLI." };
@@ -46,7 +59,7 @@ function spawnDaemon(env) {
46
59
  child.unref();
47
60
  await new Promise((resolve) => setTimeout(resolve, 1800));
48
61
  if (await (0, client_1.hostAlive)(port))
49
- return { ok: true, pid };
62
+ return { ok: true, pid, restarted: Boolean(health && health.version !== CURRENT_VERSION) };
50
63
  return { ok: false, error: `Lasso Host did not come up on port ${port}. Check ${paths_1.LOG_FILE}.` };
51
64
  });
52
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lasso-ai/cli",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Select any part of your running app, describe a change, and let AI edit the real source code.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cli/index.js",