@fusengine/harness 0.1.8 → 0.1.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.
package/dist/cli/bin.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { t as detectHarness } from "../harness-C8Nxxyn_.mjs";
3
3
  import { n as stagedContent, r as stagedFiles, t as checkStaged } from "../run-h_2LNEA8.mjs";
4
4
  import { n as writeInitFile, t as initFor } from "../run-Cdp2Ef9B.mjs";
5
- import { t as handleHook } from "../handle-BGe0QZvQ.mjs";
5
+ import { t as handleHook } from "../handle-Lz_thVKr.mjs";
6
6
  //#region src/cli/bin.ts
7
7
  /**
8
8
  * harness — CLI for @fusengine/harness.
@@ -26,7 +26,8 @@ const cmd = process.argv[2];
26
26
  if (cmd === "hook") {
27
27
  const outcome = await handleHook(process.argv[3] ?? detectHarness().id, await readStdin(), {
28
28
  now: Date.now(),
29
- cwd: process.cwd()
29
+ cwd: process.cwd(),
30
+ refsDir: process.env.FUSE_HARNESS_REFS
30
31
  });
31
32
  if (outcome.stdout) process.stdout.write(outcome.stdout);
32
33
  process.exit(outcome.exit);
@@ -1,6 +1,7 @@
1
1
  import { l as detectFramework, t as evaluate } from "./evaluate-CsYyUucy.mjs";
2
2
  import { r as evaluateApex } from "./apex-gGrHzvM2.mjs";
3
3
  import { t as formatPrompt } from "./types-ernB1Dy3.mjs";
4
+ import { t as loadRefs } from "./loader-BephwI8n.mjs";
4
5
  import { a as recordAgent, n as saveTrack, o as recordDoc, r as agentsFresh, s as recordRefRead, t as loadTrack } from "./store-BWvwnnf6.mjs";
5
6
  import { join } from "node:path";
6
7
  import { tmpdir } from "node:os";
@@ -209,6 +210,7 @@ async function handleHook(id, payload, opts) {
209
210
  filePath: event.filePath,
210
211
  content: event.content,
211
212
  command: event.command,
213
+ refs: opts.refsDir ? await loadRefs(opts.refsDir) : void 0,
212
214
  now: opts.now,
213
215
  trackFile: file
214
216
  });
@@ -18,4 +18,14 @@ declare function scoreReferences(refs: RefMeta[], filePath: string, content: str
18
18
  */
19
19
  declare function routeReferences(refs: RefMeta[], filePath: string, content: string, skillPath?: string): RouteResult | null;
20
20
  //#endregion
21
- export { parseFrontmatter as i, scoreReferences as n, globToRe as r, routeReferences as t };
21
+ //#region src/refs/loader.d.ts
22
+ /** Build a {@link RefMeta} from parsed frontmatter, tolerant of kebab/camel keys. */
23
+ declare function toRefMeta(fm: Record<string, string>, filePath: string): RefMeta;
24
+ /**
25
+ * Scan a directory recursively for `.md` reference files and parse each into a
26
+ * {@link RefMeta}. The content is entirely the consumer's — point this at any
27
+ * refs dir (`FUSE_HARNESS_REFS`). Returns an empty list when the dir is absent.
28
+ */
29
+ declare function loadRefs(dir: string): Promise<RefMeta[]>;
30
+ //#endregion
31
+ export { globToRe as a, scoreReferences as i, toRefMeta as n, parseFrontmatter as o, routeReferences as r, loadRefs as t };
package/dist/index.d.mts CHANGED
@@ -8,7 +8,7 @@ import { i as compactJson, n as projectRoot, r as projectRootOrNull, t as isCode
8
8
  import { C as isApexCommand, S as detectProjectType, _ as countLines, a as evaluateApex, b as DEV_KEYWORDS, c as PolicyContext, d as GIT_ASK, f as GIT_BLOCKED, g as FileSizeVerdict, h as matchPatterns, i as docConsultedGate, l as PolicyResult, m as SYSTEM_INSTALL, n as ApexContext, o as freshnessGate, p as PROJECT_INSTALL, r as ApexGate, s as solidReadGate, t as APEX_GATES, u as evaluate, v as evaluateFileSize, x as ProjectType, y as detectFramework } from "./index-BbJucvaG.mjs";
9
9
  import { n as RouteResult, r as ScoredRef, t as RefMeta } from "./types-CY5qT2X1.mjs";
10
10
  import { a as ReminderState, c as setStateField, i as registryFile, l as stateFileFor, n as addRoot, o as nowStamp, r as readRoots, s as readState, t as ensureMemoryGitignore, u as throttleMs } from "./index-BEM-mQMC.mjs";
11
- import { i as parseFrontmatter, n as scoreReferences, r as globToRe, t as routeReferences } from "./index-C2Lz-cwJ.mjs";
11
+ import { a as globToRe, i as scoreReferences, n as toRefMeta, o as parseFrontmatter, r as routeReferences, t as loadRefs } from "./index-hL_r6tlc.mjs";
12
12
  import { a as taskStart, c as ensureStateDir, d as stateFilePath, f as acquireLock, i as taskCreate, l as loadState, n as ApexTaskFile, o as ApexState, r as taskComplete, s as apexStateDir, t as ApexTask, u as saveState } from "./index-CPoF_hLP.mjs";
13
13
  import { _ as TIME_INTERVALS, a as formatCost, c as formatTokens, d as colors, f as progressiveColor, g as PROGRESS_CHARS, h as PROGRESS_BAR_DEFAULTS, i as formatBasename, l as ColorFn, m as GRADIENT_BLOCKS, n as generateGradientBar, o as formatPath, p as COLOR_THRESHOLDS, r as generateProgressBar, s as formatTimeLeft, t as ProgressBarOptions, u as Palette } from "./index-BWK8slRi.mjs";
14
- export { APEX_GATES, ApexContext, ApexGate, ApexState, ApexTask, ApexTaskFile, AuthEntry, COLOR_THRESHOLDS, ColorFn, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, DocSatisfactionStatus, FileSizeVerdict, GIT_ASK, GIT_BLOCKED, GRADIENT_BLOCKS, HarnessId, HarnessInfo, HarnessMode, HarnessVia, IndexSummary, MAX_LINES_ENV_KEY, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INSTALL, Palette, PolicyContext, PolicyResult, ProgressBarOptions, ProjectType, Prompt, PromptKind, RefMeta, ReminderState, RouteResult, SYSTEM_INSTALL, ScoredRef, TIME_INTERVALS, TTL_ENV_KEY, acquireLock, addRoot, apexStateDir, colors, compactJson, compactMarkdown, countLines, detectFramework, detectHarness, detectMode, detectProjectType, docConsultedGate, ensureMemoryGitignore, ensureStateDir, evaluate, evaluateApex, evaluateFileSize, extractText, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, isApexCommand, isCodeFile, isDocConsulted, jaccardSimilar, loadIndex, loadState, matchPatterns, modeFor, nowStamp, parseEnvInt, parseFrontmatter, progressiveColor, projectRoot, projectRootOrNull, queryHash, readRoots, readState, registryFile, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, saveState, scoreReferences, setStateField, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, ttlLabel };
14
+ export { APEX_GATES, ApexContext, ApexGate, ApexState, ApexTask, ApexTaskFile, AuthEntry, COLOR_THRESHOLDS, ColorFn, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, DocSatisfactionStatus, FileSizeVerdict, GIT_ASK, GIT_BLOCKED, GRADIENT_BLOCKS, HarnessId, HarnessInfo, HarnessMode, HarnessVia, IndexSummary, MAX_LINES_ENV_KEY, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INSTALL, Palette, PolicyContext, PolicyResult, ProgressBarOptions, ProjectType, Prompt, PromptKind, RefMeta, ReminderState, RouteResult, SYSTEM_INSTALL, ScoredRef, TIME_INTERVALS, TTL_ENV_KEY, acquireLock, addRoot, apexStateDir, colors, compactJson, compactMarkdown, countLines, detectFramework, detectHarness, detectMode, detectProjectType, docConsultedGate, ensureMemoryGitignore, ensureStateDir, evaluate, evaluateApex, evaluateFileSize, extractText, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, isApexCommand, isCodeFile, isDocConsulted, jaccardSimilar, loadIndex, loadRefs, loadState, matchPatterns, modeFor, nowStamp, parseEnvInt, parseFrontmatter, progressiveColor, projectRoot, projectRootOrNull, queryHash, readRoots, readState, registryFile, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, saveState, scoreReferences, setStateField, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, toRefMeta, ttlLabel };
package/dist/index.mjs CHANGED
@@ -12,6 +12,7 @@ import { t as formatPrompt } from "./types-ernB1Dy3.mjs";
12
12
  import { a as readState, c as throttleMs, i as nowStamp, l as ensureMemoryGitignore, n as readRoots, o as setStateField, r as registryFile, s as stateFileFor, t as addRoot } from "./memory-BVNt4Ary.mjs";
13
13
  import { a as jaccardSimilar, i as compactMarkdown, n as loadIndex, o as queryHash, r as summarizeIndex, t as extractText } from "./cache-DbPSJ9bC.mjs";
14
14
  import { t as incrementTrivialEditCounter } from "./freshness-BK9Xg6oG.mjs";
15
+ import { n as toRefMeta, t as loadRefs } from "./loader-BephwI8n.mjs";
15
16
  import { a as ensureStateDir, c as stateFilePath, i as apexStateDir, l as acquireLock, n as taskCreate, o as loadState, r as taskStart, s as saveState, t as taskComplete } from "./state-Bc4wdnCG.mjs";
16
17
  import { a as formatPath, c as colors, d as GRADIENT_BLOCKS, f as PROGRESS_BAR_DEFAULTS, i as formatCost, l as progressiveColor, m as TIME_INTERVALS, n as generateProgressBar, o as formatTimeLeft, p as PROGRESS_CHARS, r as formatBasename, s as formatTokens, t as generateGradientBar, u as COLOR_THRESHOLDS } from "./statusline-D87eUNXl.mjs";
17
- export { APEX_GATES, COLOR_THRESHOLDS, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, GIT_ASK, GIT_BLOCKED, GRADIENT_BLOCKS, MAX_LINES_ENV_KEY, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INSTALL, SYSTEM_INSTALL, TIME_INTERVALS, TTL_ENV_KEY, acquireLock, addRoot, apexStateDir, colors, compactJson, compactMarkdown, countLines, detectFramework, detectHarness, detectMode, detectProjectType, docConsultedGate, ensureMemoryGitignore, ensureStateDir, evaluate, evaluateApex, evaluateFileSize, extractText, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, isApexCommand, isCodeFile, isDocConsulted, jaccardSimilar, loadIndex, loadState, matchPatterns, modeFor, nowStamp, parseEnvInt, parseFrontmatter, progressiveColor, projectRoot, projectRootOrNull, queryHash, readRoots, readState, registryFile, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, saveState, scoreReferences, setStateField, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, ttlLabel };
18
+ export { APEX_GATES, COLOR_THRESHOLDS, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, GIT_ASK, GIT_BLOCKED, GRADIENT_BLOCKS, MAX_LINES_ENV_KEY, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INSTALL, SYSTEM_INSTALL, TIME_INTERVALS, TTL_ENV_KEY, acquireLock, addRoot, apexStateDir, colors, compactJson, compactMarkdown, countLines, detectFramework, detectHarness, detectMode, detectProjectType, docConsultedGate, ensureMemoryGitignore, ensureStateDir, evaluate, evaluateApex, evaluateFileSize, extractText, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, isApexCommand, isCodeFile, isDocConsulted, jaccardSimilar, loadIndex, loadRefs, loadState, matchPatterns, modeFor, nowStamp, parseEnvInt, parseFrontmatter, progressiveColor, projectRoot, projectRootOrNull, queryHash, readRoots, readState, registryFile, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, saveState, scoreReferences, setStateField, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, toRefMeta, ttlLabel };
@@ -0,0 +1,47 @@
1
+ import { i as parseFrontmatter } from "./router-Dj3AfgBE.mjs";
2
+ import { join } from "node:path";
3
+ import { readFile, readdir } from "node:fs/promises";
4
+ //#region src/refs/loader.ts
5
+ function pick(fm, ...keys) {
6
+ for (const k of keys) {
7
+ const v = fm[k];
8
+ if (v) return v;
9
+ }
10
+ return "";
11
+ }
12
+ /** Build a {@link RefMeta} from parsed frontmatter, tolerant of kebab/camel keys. */
13
+ function toRefMeta(fm, filePath) {
14
+ return {
15
+ name: pick(fm, "name") || filePath,
16
+ description: pick(fm, "description"),
17
+ keywords: pick(fm, "keywords"),
18
+ priority: pick(fm, "priority"),
19
+ related: pick(fm, "related"),
20
+ appliesTo: pick(fm, "appliesTo", "applies-to", "applies_to"),
21
+ triggerOnEdit: pick(fm, "triggerOnEdit", "trigger-on-edit", "trigger_on_edit"),
22
+ level: pick(fm, "level"),
23
+ filePath
24
+ };
25
+ }
26
+ /**
27
+ * Scan a directory recursively for `.md` reference files and parse each into a
28
+ * {@link RefMeta}. The content is entirely the consumer's — point this at any
29
+ * refs dir (`FUSE_HARNESS_REFS`). Returns an empty list when the dir is absent.
30
+ */
31
+ async function loadRefs(dir) {
32
+ let entries;
33
+ try {
34
+ entries = await readdir(dir, { recursive: true });
35
+ } catch {
36
+ return [];
37
+ }
38
+ const refs = [];
39
+ for (const rel of entries) {
40
+ if (!rel.endsWith(".md")) continue;
41
+ const filePath = join(dir, rel);
42
+ refs.push(toRefMeta(parseFrontmatter(await readFile(filePath, "utf8")), filePath));
43
+ }
44
+ return refs;
45
+ }
46
+ //#endregion
47
+ export { toRefMeta as n, loadRefs as t };
@@ -1,3 +1,3 @@
1
1
  import { n as RouteResult, r as ScoredRef, t as RefMeta } from "../types-CY5qT2X1.mjs";
2
- import { i as parseFrontmatter, n as scoreReferences, r as globToRe, t as routeReferences } from "../index-C2Lz-cwJ.mjs";
3
- export { RefMeta, RouteResult, ScoredRef, globToRe, parseFrontmatter, routeReferences, scoreReferences };
2
+ import { a as globToRe, i as scoreReferences, n as toRefMeta, o as parseFrontmatter, r as routeReferences, t as loadRefs } from "../index-hL_r6tlc.mjs";
3
+ export { RefMeta, RouteResult, ScoredRef, globToRe, loadRefs, parseFrontmatter, routeReferences, scoreReferences, toRefMeta };
@@ -1,3 +1,4 @@
1
1
  import { i as parseFrontmatter, n as scoreReferences, r as globToRe, t as routeReferences } from "../router-Dj3AfgBE.mjs";
2
+ import { n as toRefMeta, t as loadRefs } from "../loader-BephwI8n.mjs";
2
3
  import "../refs-la_KkjCS.mjs";
3
- export { globToRe, parseFrontmatter, routeReferences, scoreReferences };
4
+ export { globToRe, loadRefs, parseFrontmatter, routeReferences, scoreReferences, toRefMeta };
@@ -107,6 +107,8 @@ declare function respond(id: string, prompt: Prompt): string;
107
107
  interface HandleOptions {
108
108
  now: number;
109
109
  cwd: string;
110
+ /** Directory of SOLID reference `.md` files for `solidReadGate` (else inert). */
111
+ refsDir?: string;
110
112
  }
111
113
  /** What the hook bin should print + exit with. */
112
114
  interface HandleOutcome {
@@ -1,2 +1,2 @@
1
- import { a as trackFile, c as REQUIRED_AGENTS, i as recordActivity, l as gate, n as harnessTrackDir, o as normalizeEvent, r as respond, s as DEFAULT_WINDOW_MS, t as handleHook, u as activityFor } from "../handle-BGe0QZvQ.mjs";
1
+ import { a as trackFile, c as REQUIRED_AGENTS, i as recordActivity, l as gate, n as harnessTrackDir, o as normalizeEvent, r as respond, s as DEFAULT_WINDOW_MS, t as handleHook, u as activityFor } from "../handle-Lz_thVKr.mjs";
2
2
  export { DEFAULT_WINDOW_MS, REQUIRED_AGENTS, activityFor, gate, handleHook, harnessTrackDir, normalizeEvent, recordActivity, respond, trackFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusengine/harness",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
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",