openfleet 0.4.1 → 0.4.2

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/dist/index.js CHANGED
@@ -62,6 +62,10 @@ var models = {
62
62
  var defaultModel = process.env.OPENFLEET_MODEL ?? models.anthropic.sonnet;
63
63
  var bigModel = defaultModel;
64
64
  var fallbackModel = models.freeModels.minimaxM25Free;
65
+ function parseModel(model) {
66
+ const [providerID, ...rest] = model.split("/");
67
+ return { providerID, modelID: rest.join("/") };
68
+ }
65
69
 
66
70
  // src/agents/architect.ts
67
71
  var SYSTEM_PROMPT = `You are Architect, Planner of the Openfleet.
@@ -1075,8 +1079,7 @@ async function sleep(time_ms) {
1075
1079
 
1076
1080
  // src/logger.ts
1077
1081
  import { appendFileSync, existsSync } from "fs";
1078
- import { join as join2 } from "path";
1079
- var LOG_FILE = join2(OPENFLEET_DIR, "openfleet.log");
1082
+ var LOG_FILE = PATHS.logFile;
1080
1083
  var dirVerified = false;
1081
1084
  function writeLog(level, msg, ...args) {
1082
1085
  const timestamp = new Date().toISOString();
@@ -1114,28 +1117,17 @@ Use this tool:
1114
1117
  },
1115
1118
  async execute(_args, context) {
1116
1119
  const { sessionID } = context;
1117
- try {
1118
- const { data: messages } = await ctx.client.session.messages({
1119
- path: { id: sessionID },
1120
- query: { directory: ctx.directory }
1121
- });
1122
- if (!messages || messages.length === 0) {
1123
- return "No messages to save.";
1124
- }
1125
- const lastAssistant = [...messages].reverse().find((m) => m.info.role === "assistant");
1126
- const providerID = lastAssistant?.info.providerID ?? "anthropic";
1127
- const modelID = lastAssistant?.info.modelID ?? "claude-sonnet-4";
1128
- await ctx.client.session.summarize({
1129
- path: { id: sessionID },
1130
- body: { providerID, modelID },
1131
- query: { directory: ctx.directory }
1132
- });
1120
+ const { providerID, modelID } = parseModel(defaultModel);
1121
+ ctx.client.session.summarize({
1122
+ path: { id: sessionID },
1123
+ body: { providerID, modelID },
1124
+ query: { directory: ctx.directory }
1125
+ }).then(() => {
1133
1126
  logger.info("Session compacted", { sessionID, providerID, modelID });
1134
- return `\u2705 Context compacted successfully.`;
1135
- } catch (error) {
1127
+ }).catch((error) => {
1136
1128
  logger.error("Failed to compact session", error);
1137
- return `\u274C Failed to compact session: ${error}`;
1138
- }
1129
+ });
1130
+ return `\u2705 Context compaction initiated.`;
1139
1131
  }
1140
1132
  });
1141
1133
  }
@@ -1386,24 +1378,48 @@ import * as fs from "fs";
1386
1378
  import * as path4 from "path";
1387
1379
  import { fileURLToPath } from "url";
1388
1380
  // package.json
1389
- var version = "0.4.0";
1381
+ var version = "0.4.1";
1390
1382
 
1391
1383
  // src/utils/directory-init.ts
1392
1384
  var TEMPLATES_DIR = path4.join(path4.dirname(fileURLToPath(import.meta.url)), "templates", ".openfleet");
1385
+ var BUNDLED_MIGRATIONS_DIR = path4.join(TEMPLATES_DIR, "migrations");
1393
1386
  function initializeDirectories() {
1394
1387
  if (fs.existsSync(OPENFLEET_DIR)) {
1395
1388
  return;
1396
1389
  }
1397
1390
  copyDirectorySync(TEMPLATES_DIR, OPENFLEET_DIR);
1391
+ stampVersion();
1398
1392
  logger.info("Initialized .openfleet directory");
1399
1393
  }
1400
- function checkMigrationNeeded() {
1394
+ function getPendingMigrations() {
1401
1395
  if (!fs.existsSync(OPENFLEET_DIR))
1402
- return false;
1396
+ return [];
1397
+ if (!fs.existsSync(BUNDLED_MIGRATIONS_DIR))
1398
+ return [];
1399
+ const installedVersion = readInstalledVersion();
1400
+ return fs.readdirSync(BUNDLED_MIGRATIONS_DIR).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, "")).filter((v) => compareSemver(v, installedVersion) > 0 && compareSemver(v, version) <= 0).sort(compareSemver);
1401
+ }
1402
+ function stampVersion() {
1403
+ fs.writeFileSync(PATHS.versionFile, version);
1404
+ }
1405
+ function readInstalledVersion() {
1403
1406
  if (!fs.existsSync(PATHS.versionFile))
1404
- return true;
1405
- const installedVersion = fs.readFileSync(PATHS.versionFile, "utf-8").trim();
1406
- return installedVersion !== version;
1407
+ return "0.0.0";
1408
+ const raw = fs.readFileSync(PATHS.versionFile, "utf-8").trim();
1409
+ const parts = raw.split(".").map(Number);
1410
+ if (parts.length !== 3 || parts.some(isNaN))
1411
+ return "0.0.0";
1412
+ return raw;
1413
+ }
1414
+ function compareSemver(a, b) {
1415
+ const pa = a.split(".").map(Number);
1416
+ const pb = b.split(".").map(Number);
1417
+ for (let i = 0;i < 3; i++) {
1418
+ const diff = (pa[i] || 0) - (pb[i] || 0);
1419
+ if (diff !== 0)
1420
+ return diff;
1421
+ }
1422
+ return 0;
1407
1423
  }
1408
1424
  function copyDirectorySync(src, dest) {
1409
1425
  fs.mkdirSync(dest, { recursive: true });
@@ -1476,14 +1492,18 @@ var OpenfleetPlugin = async (ctx) => {
1476
1492
  const props = event.properties;
1477
1493
  if (!props?.info?.parentID) {
1478
1494
  setTimeout(async () => {
1479
- if (checkMigrationNeeded()) {
1495
+ const pending = getPendingMigrations();
1496
+ if (pending.length > 0) {
1497
+ const latest = pending[pending.length - 1];
1498
+ const message = pending.length === 1 ? `Run migration for v${latest}` : `${pending.length} migrations pending (v${pending[0]} \u2192 v${latest})`;
1480
1499
  await showToast(ctx, {
1481
1500
  title: "\u26A0\uFE0F Openfleet Migration Required",
1482
- message: "Copy this: 'github.com/scottsus/openfleet/issues/11' to the chat, to migrate to v0.4.0",
1501
+ message,
1483
1502
  variant: "warning",
1484
1503
  duration: 1e4
1485
1504
  });
1486
1505
  } else {
1506
+ stampVersion();
1487
1507
  await showFleetToast(ctx);
1488
1508
  }
1489
1509
  }, 0);
package/dist/models.d.ts CHANGED
@@ -29,3 +29,7 @@ export declare const defaultModel: string;
29
29
  export declare const bigModel: string;
30
30
  export declare const smallModel: string;
31
31
  export declare const fallbackModel: "opencode/minimax-m2.5-free";
32
+ export declare function parseModel(model: string): {
33
+ providerID: string;
34
+ modelID: string;
35
+ };
@@ -1,2 +1,9 @@
1
1
  export declare function initializeDirectories(): void;
2
- export declare function checkMigrationNeeded(): boolean;
2
+ /**
3
+ * Returns pending migration versions between the installed VERSION and current package version.
4
+ *
5
+ * Scans the bundled templates migrations dir (not runtime .openfleet/migrations/)
6
+ * since pre-0.4.0 installs won't have a migrations/ folder at all.
7
+ */
8
+ export declare function getPendingMigrations(): string[];
9
+ export declare function stampVersion(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfleet",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "SPARR framework agents + infinite context for OpenCode",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",