openfleet 0.3.11 → 0.3.13
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 +42 -10
- package/dist/models.d.ts +3 -3
- package/dist/transcript/hooks.d.ts +4 -0
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ var models = {
|
|
|
56
56
|
bigPickle: "opencode/big-pickle"
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
var defaultModel = models.
|
|
59
|
+
var defaultModel = models.anthropic.sonnet;
|
|
60
60
|
var bigModel = defaultModel;
|
|
61
61
|
var smallModel = defaultModel;
|
|
62
62
|
|
|
@@ -1121,6 +1121,10 @@ var logger = {
|
|
|
1121
1121
|
// src/tools/save-conversation/index.ts
|
|
1122
1122
|
import { tool } from "@opencode-ai/plugin";
|
|
1123
1123
|
|
|
1124
|
+
// src/transcript/hooks.ts
|
|
1125
|
+
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
1126
|
+
import path3 from "path";
|
|
1127
|
+
|
|
1124
1128
|
// src/transcript/writer.ts
|
|
1125
1129
|
import { existsSync as existsSync2 } from "fs";
|
|
1126
1130
|
import { appendFile, mkdir } from "fs/promises";
|
|
@@ -1292,6 +1296,9 @@ function extractContentFromParts(parts) {
|
|
|
1292
1296
|
|
|
1293
1297
|
// src/transcript/hooks.ts
|
|
1294
1298
|
var sessionInfoCache = new Map;
|
|
1299
|
+
var sessionAgentMap = new Map;
|
|
1300
|
+
var WORKSPACE_DIR = process.env.WORKSPACE_DIR ?? process.cwd();
|
|
1301
|
+
var AGENT_OVERRIDE_DIR = path3.join(WORKSPACE_DIR, ".opencode", "agents");
|
|
1295
1302
|
async function getSessionInfo(ctx, sessionID) {
|
|
1296
1303
|
const cached = sessionInfoCache.get(sessionID);
|
|
1297
1304
|
if (cached)
|
|
@@ -1316,6 +1323,9 @@ async function getSessionInfo(ctx, sessionID) {
|
|
|
1316
1323
|
function createTranscriptHooks(ctx) {
|
|
1317
1324
|
return {
|
|
1318
1325
|
"chat.message": async (input, output) => {
|
|
1326
|
+
if (input.agent) {
|
|
1327
|
+
sessionAgentMap.set(input.sessionID, input.agent);
|
|
1328
|
+
}
|
|
1319
1329
|
const session = await getSessionInfo(ctx, input.sessionID);
|
|
1320
1330
|
await recordUserMessage(session, output.message, output.parts);
|
|
1321
1331
|
},
|
|
@@ -1326,18 +1336,40 @@ function createTranscriptHooks(ctx) {
|
|
|
1326
1336
|
"tool.execute.after": async (input, output) => {
|
|
1327
1337
|
const session = await getSessionInfo(ctx, input.sessionID);
|
|
1328
1338
|
await recordToolResult(session, input.tool, input.callID, output);
|
|
1339
|
+
},
|
|
1340
|
+
"experimental.chat.system.transform": async (input, output) => {
|
|
1341
|
+
const agentName = input.sessionID ? sessionAgentMap.get(input.sessionID) : undefined;
|
|
1342
|
+
if (!agentName)
|
|
1343
|
+
return;
|
|
1344
|
+
const overridePath = path3.join(AGENT_OVERRIDE_DIR, agentName, "system_prompt.md");
|
|
1345
|
+
if (!overridePath.startsWith(AGENT_OVERRIDE_DIR + path3.sep))
|
|
1346
|
+
return;
|
|
1347
|
+
if (!existsSync3(overridePath))
|
|
1348
|
+
return;
|
|
1349
|
+
try {
|
|
1350
|
+
const content = readFileSync(overridePath, "utf-8").trim();
|
|
1351
|
+
if (content) {
|
|
1352
|
+
output.system.push(content);
|
|
1353
|
+
}
|
|
1354
|
+
} catch (err) {
|
|
1355
|
+
logger.error("Failed to read agent system prompt override", {
|
|
1356
|
+
agentName,
|
|
1357
|
+
overridePath,
|
|
1358
|
+
err
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1329
1361
|
}
|
|
1330
1362
|
};
|
|
1331
1363
|
}
|
|
1332
1364
|
// src/tools/save-conversation/counter.ts
|
|
1333
1365
|
import * as fs from "fs";
|
|
1334
|
-
import * as
|
|
1366
|
+
import * as path4 from "path";
|
|
1335
1367
|
var SESSIONS_DIR = PATHS.sessions;
|
|
1336
1368
|
var MAX_COUNTER = 999;
|
|
1337
1369
|
var FILENAME_PATTERN = /^(\d{3})_(.+)\.md$/;
|
|
1338
1370
|
async function getNextCounter(date) {
|
|
1339
1371
|
try {
|
|
1340
|
-
const dateDir =
|
|
1372
|
+
const dateDir = path4.join(SESSIONS_DIR, date);
|
|
1341
1373
|
ensureDateDir(dateDir);
|
|
1342
1374
|
const files = fs.readdirSync(dateDir);
|
|
1343
1375
|
const counters = files.map((file) => parseFilename(file)).filter((parsed) => parsed !== null).map((parsed) => parsed.counter);
|
|
@@ -1380,13 +1412,13 @@ function getCurrentDate() {
|
|
|
1380
1412
|
|
|
1381
1413
|
// src/tools/save-conversation/session-writer.ts
|
|
1382
1414
|
import * as fs2 from "fs";
|
|
1383
|
-
import * as
|
|
1415
|
+
import * as path5 from "path";
|
|
1384
1416
|
var SESSIONS_DIR2 = PATHS.sessions;
|
|
1385
1417
|
function writeSession(entry) {
|
|
1386
|
-
const dateDir =
|
|
1418
|
+
const dateDir = path5.join(SESSIONS_DIR2, entry.date);
|
|
1387
1419
|
ensureDateDir2(dateDir);
|
|
1388
1420
|
const filename = `${entry.counter}_${entry.slug}.md`;
|
|
1389
|
-
const filepath =
|
|
1421
|
+
const filepath = path5.join(dateDir, filename);
|
|
1390
1422
|
const content = buildSessionContent(entry);
|
|
1391
1423
|
try {
|
|
1392
1424
|
fs2.writeFileSync(filepath, content, { encoding: "utf8" });
|
|
@@ -1698,9 +1730,9 @@ function buildContextString(messages, note) {
|
|
|
1698
1730
|
|
|
1699
1731
|
// src/utils/directory-init.ts
|
|
1700
1732
|
import * as fs3 from "fs";
|
|
1701
|
-
import * as
|
|
1733
|
+
import * as path6 from "path";
|
|
1702
1734
|
import { fileURLToPath } from "url";
|
|
1703
|
-
var TEMPLATES_DIR =
|
|
1735
|
+
var TEMPLATES_DIR = path6.join(path6.dirname(fileURLToPath(import.meta.url)), "templates", ".openfleet");
|
|
1704
1736
|
function initializeDirectories() {
|
|
1705
1737
|
if (fs3.existsSync(OPENFLEET_DIR)) {
|
|
1706
1738
|
return;
|
|
@@ -1712,9 +1744,9 @@ function copyDirectorySync(src, dest) {
|
|
|
1712
1744
|
fs3.mkdirSync(dest, { recursive: true });
|
|
1713
1745
|
const entries = fs3.readdirSync(src, { withFileTypes: true });
|
|
1714
1746
|
for (const entry of entries) {
|
|
1715
|
-
const srcPath =
|
|
1747
|
+
const srcPath = path6.join(src, entry.name);
|
|
1716
1748
|
const destName = entry.name === "gitignore.template" ? ".gitignore" : entry.name;
|
|
1717
|
-
const destPath =
|
|
1749
|
+
const destPath = path6.join(dest, destName);
|
|
1718
1750
|
if (entry.isDirectory()) {
|
|
1719
1751
|
copyDirectorySync(srcPath, destPath);
|
|
1720
1752
|
} else {
|
package/dist/models.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ export declare const models: {
|
|
|
25
25
|
readonly bigPickle: "opencode/big-pickle";
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
export declare const defaultModel: "
|
|
29
|
-
export declare const bigModel: "
|
|
30
|
-
export declare const smallModel: "
|
|
28
|
+
export declare const defaultModel: "anthropic/claude-sonnet-4-6";
|
|
29
|
+
export declare const bigModel: "anthropic/claude-sonnet-4-6";
|
|
30
|
+
export declare const smallModel: "anthropic/claude-sonnet-4-6";
|
|
@@ -2,6 +2,7 @@ import type { PluginInput } from "@opencode-ai/plugin";
|
|
|
2
2
|
export declare function createTranscriptHooks(ctx: PluginInput): {
|
|
3
3
|
"chat.message": (input: {
|
|
4
4
|
sessionID: string;
|
|
5
|
+
agent?: string;
|
|
5
6
|
}, output: {
|
|
6
7
|
message: unknown;
|
|
7
8
|
parts: unknown[];
|
|
@@ -22,4 +23,7 @@ export declare function createTranscriptHooks(ctx: PluginInput): {
|
|
|
22
23
|
output: string;
|
|
23
24
|
metadata?: unknown;
|
|
24
25
|
}) => Promise<void>;
|
|
26
|
+
"experimental.chat.system.transform": (input: {}, output: {
|
|
27
|
+
system: string[];
|
|
28
|
+
}) => Promise<void>;
|
|
25
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openfleet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "SPARR framework agents + infinite context for OpenCode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"build": "rm -rf dist && bun build src/index.ts --outdir dist --target bun --format esm --external @opencode-ai/plugin --external @opencode-ai/sdk --external @anthropic-ai/sdk && tsc --emitDeclarationOnly && cp -r src/templates dist/",
|
|
23
23
|
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"test:watch": "bun test --watch",
|
|
25
27
|
"format": "prettier --write .",
|
|
26
28
|
"format:check": "prettier --check .",
|
|
27
29
|
"prepare": "husky"
|
|
@@ -36,9 +38,10 @@
|
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
41
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
|
39
42
|
"@opencode-ai/plugin": "~1.0.224",
|
|
40
43
|
"@opencode-ai/sdk": "~1.0.224",
|
|
41
|
-
"@
|
|
44
|
+
"@types/bun": "^1.3.10",
|
|
42
45
|
"@types/node": "^22",
|
|
43
46
|
"husky": "^9.1.7",
|
|
44
47
|
"lint-staged": "^16.2.7",
|