hostwares-cli 2.4.5 → 2.4.6
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 +21 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1864,6 +1864,7 @@ var init_safety = __esm({
|
|
|
1864
1864
|
});
|
|
1865
1865
|
|
|
1866
1866
|
// node_modules/@hostwares/agent-client/dist/esm/agent/loop.js
|
|
1867
|
+
import { readdirSync as readdirSync5 } from "fs";
|
|
1867
1868
|
async function runTurn(opts) {
|
|
1868
1869
|
const { credentials, signal, host } = opts;
|
|
1869
1870
|
const emit = host.onActivity ?? silentSink;
|
|
@@ -1878,7 +1879,9 @@ async function runTurn(opts) {
|
|
|
1878
1879
|
let toolResults = [];
|
|
1879
1880
|
let firstHop = true;
|
|
1880
1881
|
const steering = buildSteeringContext(host.cwd ?? process.cwd(), opts.message);
|
|
1881
|
-
const
|
|
1882
|
+
const cwdGrounding = buildCwdGrounding(host.cwd ?? process.cwd());
|
|
1883
|
+
const preamble = [steering, cwdGrounding].filter(Boolean).join("\n\n");
|
|
1884
|
+
const firstMessage = preamble ? `${preamble}
|
|
1882
1885
|
|
|
1883
1886
|
---
|
|
1884
1887
|
|
|
@@ -2135,6 +2138,21 @@ function byteLength(content) {
|
|
|
2135
2138
|
return void 0;
|
|
2136
2139
|
return Buffer.byteLength(content, "utf8");
|
|
2137
2140
|
}
|
|
2141
|
+
function buildCwdGrounding(cwd) {
|
|
2142
|
+
try {
|
|
2143
|
+
const SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", ".cache", ".DS_Store"]);
|
|
2144
|
+
const entries = readdirSync5(cwd, { withFileTypes: true }).filter((e) => !SKIP.has(e.name) && !e.name.startsWith(".")).slice(0, 40).map((e) => e.isDirectory() ? `${e.name}/` : e.name);
|
|
2145
|
+
const listing = entries.length ? entries.map((e) => `- ${e}`).join("\n") : "(empty)";
|
|
2146
|
+
return `## Working directory
|
|
2147
|
+
You are in: ${cwd}
|
|
2148
|
+
It contains:
|
|
2149
|
+
${listing}
|
|
2150
|
+
|
|
2151
|
+
When I say "it", "this", "the app/file", or ask to change/fix/edit something without naming a path, I mean the files in THIS directory \u2014 act on them directly, don't search elsewhere or use a remembered path. If the request is genuinely ambiguous and nothing here makes the target obvious, ask ONE short question instead of calling tools to guess.`;
|
|
2152
|
+
} catch {
|
|
2153
|
+
return "";
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2138
2156
|
function targetOf(call) {
|
|
2139
2157
|
const i = call.input ?? {};
|
|
2140
2158
|
const raw = i.command ?? i.path ?? i.url ?? i.pattern ?? i.name ?? i.container ?? i.host ?? i.files;
|
|
@@ -3328,7 +3346,7 @@ init_config();
|
|
|
3328
3346
|
init_config();
|
|
3329
3347
|
import { createHash } from "crypto";
|
|
3330
3348
|
import { join as join8 } from "path";
|
|
3331
|
-
import { existsSync as existsSync8, readFileSync as readFileSync8, readdirSync as
|
|
3349
|
+
import { existsSync as existsSync8, readFileSync as readFileSync8, readdirSync as readdirSync6, unlinkSync as unlinkSync2, mkdirSync as mkdirSync6 } from "fs";
|
|
3332
3350
|
var SESSION_DIR = join8(HW_DIR, "sessions");
|
|
3333
3351
|
var SCHEMA_VERSION = 2;
|
|
3334
3352
|
function sessionPath(cwd) {
|
|
@@ -3386,7 +3404,7 @@ function appendTurn(session, role, content) {
|
|
|
3386
3404
|
function listSessions() {
|
|
3387
3405
|
if (!existsSync8(SESSION_DIR)) return [];
|
|
3388
3406
|
const out = [];
|
|
3389
|
-
for (const name of
|
|
3407
|
+
for (const name of readdirSync6(SESSION_DIR)) {
|
|
3390
3408
|
if (!name.endsWith(".json")) continue;
|
|
3391
3409
|
try {
|
|
3392
3410
|
const data = JSON.parse(readFileSync8(join8(SESSION_DIR, name), "utf8"));
|