@fusengine/harness 0.1.18 → 0.1.19
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/cli/bin.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { r as resolveTtlSec } from "../ttl-BG55s6HZ.mjs";
|
|
|
3
3
|
import { t as detectHarness } from "../harness-C8Nxxyn_.mjs";
|
|
4
4
|
import { n as stagedContent, r as stagedFiles, t as checkStaged } from "../run-_Cy9-Tgv.mjs";
|
|
5
5
|
import { n as writeInitFile, t as initFor } from "../run-D91N4ul1.mjs";
|
|
6
|
-
import { t as handleHook } from "../handle-
|
|
6
|
+
import { t as handleHook } from "../handle-DYF2Fju8.mjs";
|
|
7
7
|
//#region src/cli/bin.ts
|
|
8
8
|
/**
|
|
9
9
|
* harness — CLI for @fusengine/harness.
|
|
@@ -142,6 +142,11 @@ function mutateWith(id, input) {
|
|
|
142
142
|
if (id === "gemini-cli") return JSON.stringify({ hookSpecificOutput: { tool_input: input } });
|
|
143
143
|
return "";
|
|
144
144
|
}
|
|
145
|
+
/** The doc provider a served cache-hit satisfies (`exa`/`context7`), else undefined. */
|
|
146
|
+
function docSourceOf(tool) {
|
|
147
|
+
if (/exa/i.test(tool)) return "exa";
|
|
148
|
+
if (/context7/i.test(tool)) return "context7";
|
|
149
|
+
}
|
|
145
150
|
/**
|
|
146
151
|
* Pre-event MCP interception: serve a fresh cache hit (deny + cached content),
|
|
147
152
|
* else cap exa verbosity (allow + mutated input), else null to allow normally.
|
|
@@ -152,12 +157,15 @@ function mcpPreIntercept(id, tool, input, dir, ttlMs, now) {
|
|
|
152
157
|
const cached = cacheLookup(dir, tool, queryOf(input), ttlMs, now);
|
|
153
158
|
if (cached) {
|
|
154
159
|
const served = denyWith(id, cached);
|
|
155
|
-
if (served) return
|
|
160
|
+
if (served) return {
|
|
161
|
+
stdout: served,
|
|
162
|
+
docSource: docSourceOf(tool)
|
|
163
|
+
};
|
|
156
164
|
}
|
|
157
165
|
const capped = capVerbosity(tool, input);
|
|
158
166
|
if (capped) {
|
|
159
167
|
const mutated = mutateWith(id, capped);
|
|
160
|
-
if (mutated) return mutated;
|
|
168
|
+
if (mutated) return { stdout: mutated };
|
|
161
169
|
}
|
|
162
170
|
return null;
|
|
163
171
|
}
|
|
@@ -291,10 +299,18 @@ async function handleHook(id, payload, opts) {
|
|
|
291
299
|
};
|
|
292
300
|
}
|
|
293
301
|
const intercept = mcpPreIntercept(id, event.tool, event.input, mcpDir, MCP_TTL_MS, opts.now);
|
|
294
|
-
if (intercept !== null)
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
302
|
+
if (intercept !== null) {
|
|
303
|
+
if (intercept.docSource) await recordActivity(file, {
|
|
304
|
+
kind: "doc",
|
|
305
|
+
framework,
|
|
306
|
+
sessionId: event.sessionId,
|
|
307
|
+
source: intercept.docSource
|
|
308
|
+
});
|
|
309
|
+
return {
|
|
310
|
+
stdout: intercept.stdout,
|
|
311
|
+
exit: 0
|
|
312
|
+
};
|
|
313
|
+
}
|
|
298
314
|
const prompt = await gate({
|
|
299
315
|
sessionId: event.sessionId,
|
|
300
316
|
framework,
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -117,12 +117,17 @@ declare const MCP_TTL_MS = 1728e5;
|
|
|
117
117
|
declare function isMcpTool(tool: string): boolean;
|
|
118
118
|
/** The query/url that keys the cache. */
|
|
119
119
|
declare function queryOf(input: Record<string, unknown>): string;
|
|
120
|
+
/** A pre-event MCP interception: the native response + any doc source it satisfied. */
|
|
121
|
+
interface McpIntercept {
|
|
122
|
+
stdout: string;
|
|
123
|
+
docSource?: string;
|
|
124
|
+
}
|
|
120
125
|
/**
|
|
121
126
|
* Pre-event MCP interception: serve a fresh cache hit (deny + cached content),
|
|
122
127
|
* else cap exa verbosity (allow + mutated input), else null to allow normally.
|
|
123
128
|
* Harnesses without input-mutation/cache support fall through to null.
|
|
124
129
|
*/
|
|
125
|
-
declare function mcpPreIntercept(id: string, tool: string, input: Record<string, unknown>, dir: string, ttlMs: number, now: number):
|
|
130
|
+
declare function mcpPreIntercept(id: string, tool: string, input: Record<string, unknown>, dir: string, ttlMs: number, now: number): McpIntercept | null;
|
|
126
131
|
/** Post-event: store the MCP/WebFetch response (extracted to markdown) in the cache. */
|
|
127
132
|
declare function mcpPostStore(tool: string, input: Record<string, unknown>, response: unknown, dir: string): void;
|
|
128
133
|
//#endregion
|
|
@@ -149,4 +154,4 @@ interface HandleOutcome {
|
|
|
149
154
|
*/
|
|
150
155
|
declare function handleHook(id: string, payload: Record<string, unknown>, opts: HandleOptions): Promise<HandleOutcome>;
|
|
151
156
|
//#endregion
|
|
152
|
-
export { Activity, DEFAULT_WINDOW_MS, GateInput, HandleOptions, HandleOutcome, MCP_TTL_MS, NormalizedEvent, REQUIRED_AGENTS, TRIVIAL_BUDGET, ToolEvent, activityFor, gate, handleHook, harnessStateDir, isMcpTool, mcpPostStore, mcpPreIntercept, normalizeEvent, queryOf, recordActivity, respond, trackFile };
|
|
157
|
+
export { Activity, DEFAULT_WINDOW_MS, GateInput, HandleOptions, HandleOutcome, MCP_TTL_MS, McpIntercept, NormalizedEvent, REQUIRED_AGENTS, TRIVIAL_BUDGET, ToolEvent, activityFor, gate, handleHook, harnessStateDir, isMcpTool, mcpPostStore, mcpPreIntercept, normalizeEvent, queryOf, recordActivity, respond, trackFile };
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as projectLayout } from "../layout-C0jaaCQC.mjs";
|
|
2
|
-
import { a as normalizeEvent, c as mcpPostStore, d as DEFAULT_WINDOW_MS, f as REQUIRED_AGENTS, h as activityFor, i as trackFile, l as mcpPreIntercept, m as gate, n as respond, o as MCP_TTL_MS, p as TRIVIAL_BUDGET, r as recordActivity, s as isMcpTool, t as handleHook, u as queryOf } from "../handle-
|
|
2
|
+
import { a as normalizeEvent, c as mcpPostStore, d as DEFAULT_WINDOW_MS, f as REQUIRED_AGENTS, h as activityFor, i as trackFile, l as mcpPreIntercept, m as gate, n as respond, o as MCP_TTL_MS, p as TRIVIAL_BUDGET, r as recordActivity, s as isMcpTool, t as handleHook, u as queryOf } from "../handle-DYF2Fju8.mjs";
|
|
3
3
|
//#region src/runtime/storage.ts
|
|
4
4
|
/**
|
|
5
5
|
* The project's single state dir (`<root>/.harness`) — neutral + harness-agnostic,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusengine/harness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Harness-agnostic toolkit for AI coding agents: runtime harness detection (Claude Code, Codex, Cursor, Cline, Gemini, Aider...), pure policy core (env config, project/framework detection, SOLID/file-size limits, APEX freshness, guard patterns, portable prompts), cache, project memory, ref routing, state/locks, statusline, per-harness adapters (Claude/Cursor/Cline/Gemini) and a cli-mode harness-check binary. Bun-native, with a built dist for Node + bundlers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.ts",
|