@fusengine/harness 0.1.37 → 0.1.40
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/adapters/claude/index.d.mts +2 -2
- package/dist/adapters/claude/index.mjs +2 -2
- package/dist/adapters/cline/index.mjs +1 -1
- package/dist/adapters/codex/index.d.mts +1 -1
- package/dist/adapters/codex/index.mjs +1 -1
- package/dist/adapters/cursor/index.mjs +1 -1
- package/dist/adapters/gemini/index.mjs +1 -1
- package/dist/cache/index.d.mts +2 -2
- package/dist/cache/index.mjs +3 -3
- package/dist/cache-la_KkjCS.mjs +1 -0
- package/dist/{claude-3PqBGt_7.mjs → claude-BnFrSfMo.mjs} +17 -3
- package/dist/cli/bin.mjs +4 -3
- package/dist/cli/index.mjs +1 -1
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +3 -2
- package/dist/{doc-helpers-Dd_x1-tZ.mjs → doc-helpers-B4XYL1v8.mjs} +8 -6
- package/dist/{doc-helpers-CG1nuf-c.d.mts → doc-helpers-D14nkD5D.d.mts} +5 -3
- package/dist/{dotenv-TLNMiSjP.mjs → dotenv-DGyLln7U.mjs} +1 -20
- package/dist/{evaluate-zyxeVZPB.mjs → evaluate-B1n1ti0N.mjs} +89 -50
- package/dist/freshness/index.d.mts +1 -1
- package/dist/freshness/index.mjs +1 -1
- package/dist/{handle-DL2sZiWH.mjs → handle-gYSq5znf.mjs} +587 -153
- package/dist/index-BX-xcvhY.d.mts +75 -0
- package/dist/{index-DLUfyYmU.d.mts → index-COBvvc3L.d.mts} +3 -1
- package/dist/{index-FrWgmkbP.d.mts → index-CwOdFBOr.d.mts} +11 -2
- package/dist/{index-CPoF_hLP.d.mts → index-D7GpOmkl.d.mts} +1 -1
- package/dist/{index-QzK2dv0V.d.mts → index-DTrjSNmI.d.mts} +38 -13
- package/dist/{index-DL8MxjuP.d.mts → index-mmRF3KNp.d.mts} +4 -4
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +9 -9
- package/dist/{loader-CyAoJv2W.mjs → loader-Bn-DbZmt.mjs} +1 -1
- package/dist/mcp-store-CDUVqtJ0.mjs +238 -0
- package/dist/policy/index.d.mts +2 -2
- package/dist/policy/index.mjs +3 -3
- package/dist/refs/index.d.mts +1 -1
- package/dist/refs/index.mjs +2 -2
- package/dist/{router-D8cVrI-s.mjs → router-BfX0hJg8.mjs} +13 -20
- package/dist/{run-CUL70W0k.mjs → run-D-Ydrw3D.mjs} +1 -1
- package/dist/runtime/index.d.mts +32 -12
- package/dist/runtime/index.mjs +2 -2
- package/dist/{session-state-DxNkIBZ2.d.mts → session-state-Dzq6yrw7.d.mts} +1 -1
- package/dist/state/index.d.mts +1 -1
- package/dist/{store-7j02oGjt.mjs → store-3WBr37Xz.mjs} +1 -1
- package/dist/tracking/index.d.mts +1 -1
- package/dist/tracking/index.mjs +1 -1
- package/dist/ttl-BG55s6HZ.mjs +20 -0
- package/dist/{validate-DLrWtaDR.mjs → validate-BCRqp9XG.mjs} +15 -9
- package/package.json +1 -1
- package/dist/cache-C9z9LclL.mjs +0 -56
- package/dist/index-DPkCX_AR.d.mts +0 -40
- package/dist/store-PrNPm6So.mjs +0 -89
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/cache/compact.d.ts
|
|
2
|
+
/** Strip HTML entities + boilerplate, normalize blank lines, truncate to ~5KB. */
|
|
3
|
+
declare function compactMarkdown(content: string): string;
|
|
4
|
+
/** 8-char MD5 of `${toolName}::${query}`. */
|
|
5
|
+
declare function queryHash(toolName: string, query: string): string;
|
|
6
|
+
/** Bag-of-words Jaccard similarity strictly greater than `threshold`. */
|
|
7
|
+
declare function jaccardSimilar(a: string, b: string, threshold?: number): boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/cache/io.d.ts
|
|
10
|
+
/** Read a JSON array from `path`; [] on missing/corrupt/non-array. */
|
|
11
|
+
declare function loadIndex(path: string): unknown[];
|
|
12
|
+
/** Summary of a cache index. */
|
|
13
|
+
interface IndexSummary {
|
|
14
|
+
total: number;
|
|
15
|
+
byTool: Record<string, number>;
|
|
16
|
+
oldestTs: string | null;
|
|
17
|
+
newestTs: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** Summarize an index of `{ tool?, ts? }` entries. */
|
|
20
|
+
declare function summarizeIndex(index: unknown[]): IndexSummary;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/cache/mcp-response.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* Extract usable markdown from an MCP `tool_response`: a string, a list of
|
|
25
|
+
* content blocks (non-text blocks skipped), or any JSON structure (fallback).
|
|
26
|
+
* Recurses up to depth 5 to guard against pathological/cyclic structures.
|
|
27
|
+
*/
|
|
28
|
+
declare function extractText(resp: unknown, depth?: number): string;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/cache/mcp-store.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* Persist an MCP doc result the way `cache-mcp-result.py` does: compact the body,
|
|
33
|
+
* skip Jaccard-duplicate queries, write a front-matter `.md` (exact FNV key, so
|
|
34
|
+
* {@link cacheLookup} still hits) carrying the query for substring lookups, and
|
|
35
|
+
* append the entry to `index.json`. No-op on empty body or duplicate query.
|
|
36
|
+
* @param dir - Cache directory (also holds `index.json`).
|
|
37
|
+
* @param tool - MCP tool id.
|
|
38
|
+
* @param query - Doc query that keys the entry.
|
|
39
|
+
* @param body - Raw response text (compacted before write).
|
|
40
|
+
* @param now - Current epoch ms (timestamp source).
|
|
41
|
+
*/
|
|
42
|
+
declare function mcpCacheWrite(dir: string, tool: string, query: string, body: string, now: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Persist a WebFetch result the way `webfetch-cache-store.py` does: compact the
|
|
45
|
+
* body, write a front-matter `.md` keyed by `key` (url + prompt[:500]). No index
|
|
46
|
+
* and no dedup — WebFetch entries are exact-key only. No-op on empty body.
|
|
47
|
+
* @param dir - Cache directory.
|
|
48
|
+
* @param tool - Always `WebFetch`.
|
|
49
|
+
* @param key - The url+prompt cache key string.
|
|
50
|
+
* @param body - Raw response text (compacted before write).
|
|
51
|
+
* @param now - Current epoch ms (timestamp source).
|
|
52
|
+
*/
|
|
53
|
+
declare function webfetchCacheWrite(dir: string, tool: string, key: string, body: string, now: number): void;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/cache/store.d.ts
|
|
56
|
+
/** Stable 16-char key from a tool name + query (FNV-1a, non-crypto). */
|
|
57
|
+
declare function mcpCacheKey(tool: string, query: string): string;
|
|
58
|
+
/** Path of a cache entry under `dir`. */
|
|
59
|
+
declare function cachePath(dir: string, tool: string, query: string): string;
|
|
60
|
+
/** Read a cached entry if it exists and is fresh (mtime within `ttlMs`), else null. */
|
|
61
|
+
declare function cacheLookup(dir: string, tool: string, query: string, ttlMs: number, now: number): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* First fresh cache file whose body contains the (normalized, case-insensitive)
|
|
64
|
+
* query substring, else null. Relaxes the exact-key match to lift the hit-rate —
|
|
65
|
+
* parity with `mcp-cache-lookup.py` (`rg -i -F` over the first 80 query chars).
|
|
66
|
+
* @param dir - Cache directory to scan.
|
|
67
|
+
* @param query - Raw query; newlines folded to spaces, truncated to 80 chars.
|
|
68
|
+
* @param ttlMs - Freshness window (mtime-based).
|
|
69
|
+
* @param now - Current epoch ms.
|
|
70
|
+
*/
|
|
71
|
+
declare function cacheLookupSubstring(dir: string, query: string, ttlMs: number, now: number): string | null;
|
|
72
|
+
/** Store a cache entry (creates the dir; no-op on empty content). */
|
|
73
|
+
declare function cacheStore(dir: string, tool: string, query: string, content: string): void;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { mcpCacheKey as a, extractText as c, summarizeIndex as d, compactMarkdown as f, cacheStore as i, IndexSummary as l, queryHash as m, cacheLookupSubstring as n, mcpCacheWrite as o, jaccardSimilar as p, cachePath as r, webfetchCacheWrite as s, cacheLookup as t, loadIndex as u };
|
|
@@ -70,6 +70,8 @@ interface ProjectLayout {
|
|
|
70
70
|
declare function projectLayout(root: string): ProjectLayout;
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/config/dotenv.d.ts
|
|
73
|
+
/** Home config dir holding the `.env` for each harness (defaults to `.claude`). */
|
|
74
|
+
declare const HOME_DIR: Partial<Record<HarnessId, string>>;
|
|
73
75
|
/** Parse a `.env` file into a key→value map (`export KEY="v"` or `KEY=v`). */
|
|
74
76
|
declare function parseEnvFile(path: string): Record<string, string>;
|
|
75
77
|
/** The `.env` paths probed for a harness: home `.env` then `<cwd>/.env`. */
|
|
@@ -85,4 +87,4 @@ declare function envCandidates(id: HarnessId, home?: string, cwd?: string): stri
|
|
|
85
87
|
*/
|
|
86
88
|
declare function loadDotenv(id: HarnessId, env?: NodeJS.ProcessEnv, home?: string, cwd?: string): void;
|
|
87
89
|
//#endregion
|
|
88
|
-
export {
|
|
90
|
+
export { parseEnvInt as _, ProjectLayout as a, projectLayout as c, resolveMaxLines as d, splitTarget as f, ttlLabel as g, resolveTtlSec as h, parseEnvFile as i, DEFAULT_MAX_LINES as l, TTL_ENV_KEY as m, envCandidates as n, STATE_GITIGNORE as o, DEFAULT_TTL_SEC as p, loadDotenv as r, STATE_ROOT as s, HOME_DIR as t, MAX_LINES_ENV_KEY as u };
|
|
@@ -15,8 +15,17 @@ interface ClaudeHookInput {
|
|
|
15
15
|
}
|
|
16
16
|
/** Read & parse the Claude hook payload from stdin (empty object on bad input). */
|
|
17
17
|
declare function readClaudeInput(): Promise<ClaudeHookInput>;
|
|
18
|
-
/** A `deny` hook response for a given event. */
|
|
18
|
+
/** A `deny` hook response for a given event. PreToolUse-only field. */
|
|
19
19
|
declare function denyResponse(event: string, reason: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A PostToolUse (and Stop/UserPromptSubmit) `block` response. These events
|
|
22
|
+
* ignore `hookSpecificOutput.permissionDecision` (a PreToolUse-only field) and
|
|
23
|
+
* only honor the top-level `decision`/`reason` keys, which feed the reason back
|
|
24
|
+
* to Claude as automated feedback.
|
|
25
|
+
* @param reason - The block feedback shown to Claude.
|
|
26
|
+
* @returns The native `{decision:"block",reason}` response string.
|
|
27
|
+
*/
|
|
28
|
+
declare function blockResponse(reason: string): string;
|
|
20
29
|
/** An `additionalContext` injection response. */
|
|
21
30
|
declare function contextResponse(event: string, text: string): string;
|
|
22
31
|
/**
|
|
@@ -33,4 +42,4 @@ declare function guard(input: ClaudeHookInput): string | null;
|
|
|
33
42
|
/** @deprecated use {@link guard}. Kept for back-compat. */
|
|
34
43
|
declare const fileSizeGuard: typeof guard;
|
|
35
44
|
//#endregion
|
|
36
|
-
export {
|
|
45
|
+
export { fileSizeGuard as a, toClaudeResponse as c, denyResponse as i, blockResponse as n, guard as o, contextResponse as r, readClaudeInput as s, ClaudeHookInput as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Prompt } from "./types-D56jSgD9.mjs";
|
|
2
|
-
import { t as AuthEntry } from "./doc-helpers-
|
|
2
|
+
import { t as AuthEntry } from "./doc-helpers-D14nkD5D.mjs";
|
|
3
3
|
import { t as RefMeta } from "./types-CY5qT2X1.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/policy/detect-project.d.ts
|
|
@@ -49,10 +49,10 @@ interface FileSizeVerdict {
|
|
|
49
49
|
message: string | null;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* Count
|
|
53
|
-
* (
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* Count physical lines — parity with the Python `enforce-file-size.py`
|
|
53
|
+
* (`sum(1 for _ in f)`): every line counts (blanks and comments included), and a
|
|
54
|
+
* single trailing newline does not add a phantom line. The SOLID ceiling is
|
|
55
|
+
* measured on raw file length, not substantive code, to match the upstream plugin.
|
|
56
56
|
*/
|
|
57
57
|
declare function countLines(content: string): number;
|
|
58
58
|
/**
|
|
@@ -134,7 +134,7 @@ interface ApexContext {
|
|
|
134
134
|
}
|
|
135
135
|
/** A single APEX gate: returns a blocking {@link Prompt}, or null to pass. */
|
|
136
136
|
type ApexGate = (ctx: ApexContext) => Prompt | null;
|
|
137
|
-
/** Gate: Context7
|
|
137
|
+
/** Gate: any one documentation source (Context7, Exa, or web) must have been consulted this session. */
|
|
138
138
|
declare const docConsultedGate: ApexGate;
|
|
139
139
|
/** Gate: the routed SOLID references for this edit must have been read. */
|
|
140
140
|
declare const solidReadGate: ApexGate;
|
|
@@ -170,15 +170,27 @@ declare const ASK_PATTERNS: RegExp[];
|
|
|
170
170
|
declare function securityGuard(ctx: GuardContext): Prompt | null;
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/policy/guards/protected-path.d.ts
|
|
173
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Path fragments that mark a location as internal/generated state.
|
|
175
|
+
*
|
|
176
|
+
* Parity with safe_paths.py: `~/.claude/fusengine-cache` is a *writable* cache
|
|
177
|
+
* the harness owns (lessons, MCP cache, per-type state) — only the
|
|
178
|
+
* `fusengine-cache/sessions` subtree is protected, not the whole cache.
|
|
179
|
+
*/
|
|
174
180
|
declare const PROTECTED_FRAGMENTS: readonly string[];
|
|
175
181
|
/**
|
|
182
|
+
* Matches a real `.git` directory segment (`/.git/`, `~/.git`, leading or
|
|
183
|
+
* trailing `.git`) without matching unrelated names like `foo.git/` or
|
|
184
|
+
* `.github/`. Kept separate from the substring fragments for precise scoping.
|
|
185
|
+
*/
|
|
186
|
+
declare const PROTECTED_GIT_RE: RegExp;
|
|
187
|
+
/**
|
|
176
188
|
* Blocks direct edits to internal/generated state directories.
|
|
177
189
|
*
|
|
178
190
|
* Covers:
|
|
179
191
|
* - Write / Edit tool calls whose `filePath` targets a protected fragment.
|
|
180
|
-
* - Bash commands
|
|
181
|
-
*
|
|
192
|
+
* - Bash commands whose actual write *target* is a protected fragment
|
|
193
|
+
* (read sources are ignored; see `extractWriteTargets`).
|
|
182
194
|
*
|
|
183
195
|
* @param ctx - The guard context (tool, filePath, command).
|
|
184
196
|
* @returns A blocking {@link Prompt}, or null to allow.
|
|
@@ -188,9 +200,13 @@ declare function protectedPathGuard(ctx: GuardContext): Prompt | null;
|
|
|
188
200
|
//#region src/policy/guards/bash-write.d.ts
|
|
189
201
|
/** Redirect (`>`/`>>`) targeting a code-file extension. */
|
|
190
202
|
declare const CODE_REDIRECT: RegExp;
|
|
191
|
-
/** Interpreters / tools that mutate source in place, plus heredoc-into-file.
|
|
203
|
+
/** Interpreters / tools that mutate source in place, plus heredoc-into-file.
|
|
204
|
+
* `sed`/`perl`/`awk` allow intervening flags before `-i` (parity bash-write-guard.py). */
|
|
192
205
|
declare const CODE_MUTATORS: RegExp;
|
|
193
|
-
/** Redirect to a non-code file
|
|
206
|
+
/** Redirect to a non-code file. Excludes `/dev/null`, `2>`/`N>` and `>&N` fd
|
|
207
|
+
* redirects via the `(?<![0-9&])` lookbehind + `(?!…|&)` (parity has_file_redirect). */
|
|
208
|
+
declare const FILE_REDIRECT: RegExp;
|
|
209
|
+
/** Other ambiguous file writers (ASK): `tee <file>` (not `tee -a`/path) and `dd … of=`. */
|
|
194
210
|
declare const ASK_WRITERS: RegExp;
|
|
195
211
|
/**
|
|
196
212
|
* Blocks shell commands that mutate code files in place (and heredocs/redirects
|
|
@@ -204,7 +220,11 @@ declare function bashWriteGuard(ctx: GuardContext): Prompt | null;
|
|
|
204
220
|
declare const TS_DECL_RE: RegExp;
|
|
205
221
|
/** Python view models: class subclassing a schema/protocol base. */
|
|
206
222
|
declare const PY_MODEL_RE: RegExp;
|
|
207
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* PHP controllers: top-level `interface`, `abstract class`, or a concrete
|
|
225
|
+
* `class …Interface/DTO/Request`. Union of the TS-only `abstract class` rule
|
|
226
|
+
* and the Python rule (`class [A-Z].*(Interface|DTO|Request)`, enforce-interfaces.py:16).
|
|
227
|
+
*/
|
|
208
228
|
declare const PHP_DECL_RE: RegExp;
|
|
209
229
|
/** Swift views: top-level `protocol Foo`. */
|
|
210
230
|
declare const SWIFT_PROTO_RE: RegExp;
|
|
@@ -216,6 +236,11 @@ declare const JAVA_DECL_RE: RegExp;
|
|
|
216
236
|
* Blocks top-level interface/type/protocol declarations in component, view or
|
|
217
237
|
* controller files (Interface Segregation). Fires only when BOTH the path
|
|
218
238
|
* category AND the content pattern match.
|
|
239
|
+
*
|
|
240
|
+
* Parity note: enforce-interfaces.py only inspects `Write` (tool_input.content).
|
|
241
|
+
* We deliberately also fire on `Edit` — an in-place edit can introduce the same
|
|
242
|
+
* violation — and the path fragments accept singular *and* plural directory
|
|
243
|
+
* names (`view/` + `views/`), mirroring the Python `s?` regexes.
|
|
219
244
|
*/
|
|
220
245
|
declare function interfaceSeparationGuard(ctx: GuardContext): Prompt | null;
|
|
221
246
|
//#endregion
|
|
@@ -456,4 +481,4 @@ declare function isHtmlLike(path: string): boolean;
|
|
|
456
481
|
*/
|
|
457
482
|
declare function missingSeoElements(html: string): string[];
|
|
458
483
|
//#endregion
|
|
459
|
-
export {
|
|
484
|
+
export { Guard as $, GUARDS as A, TS_DECL_RE as B, SKILL_TRIGGERS as C, ProjectType as Ct, capVerbosity as D, requiredArchSkill as Dt, MAX_TOKENS as E, isApexCommand as Et, GO_DECL_RE as F, FILE_REDIRECT as G, ASK_WRITERS as H, JAVA_DECL_RE as I, PROTECTED_GIT_RE as J, bashWriteGuard as K, PHP_DECL_RE as L, registerGuard as M, runGuards as N, detectCreationIntent as O, installGuard as P, securityGuard as Q, PY_MODEL_RE as R, skillTriggerGate as S, ModularArchitecture as St, MAX_EXA_RESULTS as T, detectProjectType as Tt, CODE_MUTATORS as U, interfaceSeparationGuard as V, CODE_REDIRECT as W, ASK_PATTERNS as X, protectedPathGuard as Y, CRITICAL_PATTERNS as Z, DEV_VERBS as _, FileSizeVerdict as _t, firstHeading as a, docConsultedGate as at, detectClaudeMdProjectType as b, detectFramework as bt, parseEntry as c, solidReadGate as ct, EXCLUDE_DIRS as d, evaluate as dt, GuardContext as et, PROJECT_INDICATORS as f, GIT_ASK as ft, loadApexTaskState as g, matchPatterns as gt, buildApexTaskInjection as h, SYSTEM_INSTALL as ht, firstComment as i, brainstormGate as it, clearUserGuards as j, FAIL_CLOSED as k, parseBodyDesc as l, PolicyContext as lt, buildApexTaskContext as m, PROJECT_INSTALL as mt, missingSeoElements as n, ApexContext as nt, TreeEntry as o, evaluateApex as ot, ApexTaskState as p, GIT_BLOCKED as pt, PROTECTED_FRAGMENTS as q, descFromText as r, ApexGate as rt, parseEnrichment as s, freshnessGate as st, isHtmlLike as t, APEX_GATES as tt, parseField as u, PolicyResult as ut, buildApexInstruction as v, countLines as vt, frameworkSolidGate as w, detectModularArchitecture as wt, detectRequiredSkills as x, DEV_KEYWORDS as xt, buildClaudeMdContext as y, evaluateFileSize as yt, SWIFT_PROTO_RE as z };
|
|
@@ -8,10 +8,10 @@ declare function globToRe(g: string): RegExp;
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/refs/router.d.ts
|
|
10
10
|
/**
|
|
11
|
-
* Score references against a file edit (pure)
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Score references against a file edit (pure) — flat scoring, parity with the
|
|
12
|
+
* Python `ref_router._score_ref` (comma-split, single award per category):
|
|
13
|
+
* +10 once if ANY `applies-to` glob matches, +5 once if ANY `trigger-on-edit`
|
|
14
|
+
* fragment (trailing `/` stripped) is a substring of the path, +1 per keyword.
|
|
15
15
|
*/
|
|
16
16
|
declare function scoreReferences(refs: RefMeta[], filePath: string, content: string): ScoredRef[];
|
|
17
17
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { n as PromptKind, r as formatPrompt, t as Prompt } from "./types-D56jSgD9.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
2
|
+
import { a as mcpCacheKey, c as extractText, d as summarizeIndex, f as compactMarkdown, i as cacheStore, l as IndexSummary, m as queryHash, n as cacheLookupSubstring, o as mcpCacheWrite, p as jaccardSimilar, r as cachePath, s as webfetchCacheWrite, t as cacheLookup, u as loadIndex } from "./index-BX-xcvhY.mjs";
|
|
3
|
+
import { _ as parseEnvInt, a as ProjectLayout, c as projectLayout, d as resolveMaxLines, f as splitTarget, g as ttlLabel, h as resolveTtlSec, i as parseEnvFile, l as DEFAULT_MAX_LINES, m as TTL_ENV_KEY, n as envCandidates, o as STATE_GITIGNORE, p as DEFAULT_TTL_SEC, r as loadDotenv, s as STATE_ROOT, t as HOME_DIR, u as MAX_LINES_ENV_KEY } from "./index-COBvvc3L.mjs";
|
|
4
4
|
import { a as detectHarness, i as HarnessVia, n as HarnessInfo, o as detectMode, r as HarnessMode, s as modeFor, t as HarnessId } from "./harness-DwJskkz_.mjs";
|
|
5
|
-
import { a as isDocConsulted, i as formatDocSatisfactionStatus, n as DocSatisfactionStatus, o as resolveSessions, r as formatDocDeny, t as AuthEntry } from "./doc-helpers-
|
|
5
|
+
import { a as isDocConsulted, i as formatDocSatisfactionStatus, n as DocSatisfactionStatus, o as resolveSessions, r as formatDocDeny, t as AuthEntry } from "./doc-helpers-D14nkD5D.mjs";
|
|
6
6
|
import { t as incrementTrivialEditCounter } from "./index-BOBXQ91y.mjs";
|
|
7
7
|
import { a as compactJson, i as walkUpFor, n as projectRoot, r as projectRootOrNull, t as isCodeFile } from "./index-BEMumjOw.mjs";
|
|
8
|
-
import { $ as
|
|
8
|
+
import { $ as Guard, A as GUARDS, B as TS_DECL_RE, C as SKILL_TRIGGERS, Ct as ProjectType, D as capVerbosity, Dt as requiredArchSkill, E as MAX_TOKENS, Et as isApexCommand, F as GO_DECL_RE, G as FILE_REDIRECT, H as ASK_WRITERS, I as JAVA_DECL_RE, J as PROTECTED_GIT_RE, K as bashWriteGuard, L as PHP_DECL_RE, M as registerGuard, N as runGuards, O as detectCreationIntent, P as installGuard, Q as securityGuard, R as PY_MODEL_RE, S as skillTriggerGate, St as ModularArchitecture, T as MAX_EXA_RESULTS, Tt as detectProjectType, U as CODE_MUTATORS, V as interfaceSeparationGuard, W as CODE_REDIRECT, X as ASK_PATTERNS, Y as protectedPathGuard, Z as CRITICAL_PATTERNS, _ as DEV_VERBS, _t as FileSizeVerdict, a as firstHeading, at as docConsultedGate, b as detectClaudeMdProjectType, bt as detectFramework, c as parseEntry, ct as solidReadGate, d as EXCLUDE_DIRS, dt as evaluate, et as GuardContext, f as PROJECT_INDICATORS, ft as GIT_ASK, g as loadApexTaskState, gt as matchPatterns, h as buildApexTaskInjection, ht as SYSTEM_INSTALL, i as firstComment, it as brainstormGate, j as clearUserGuards, k as FAIL_CLOSED, l as parseBodyDesc, lt as PolicyContext, m as buildApexTaskContext, mt as PROJECT_INSTALL, n as missingSeoElements, nt as ApexContext, o as TreeEntry, ot as evaluateApex, p as ApexTaskState, pt as GIT_BLOCKED, q as PROTECTED_FRAGMENTS, r as descFromText, rt as ApexGate, s as parseEnrichment, st as freshnessGate, t as isHtmlLike, tt as APEX_GATES, u as parseField, ut as PolicyResult, v as buildApexInstruction, vt as countLines, w as frameworkSolidGate, wt as detectModularArchitecture, x as detectRequiredSkills, xt as DEV_KEYWORDS, y as buildClaudeMdContext, yt as evaluateFileSize, z as SWIFT_PROTO_RE } from "./index-DTrjSNmI.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 readState, d as throttleMs, i as registryFile, l as setStateField, n as addRoot, o as lessonsFileFor, r as readRoots, s as nowStamp, t as ensureMemoryGitignore, u as stateFileFor } from "./index-DLYhervv.mjs";
|
|
11
|
-
import { a as globToRe, i as scoreReferences, n as toRefMeta, o as parseFrontmatter, r as routeReferences, t as loadRefs } from "./index-
|
|
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-
|
|
11
|
+
import { a as globToRe, i as scoreReferences, n as toRefMeta, o as parseFrontmatter, r as routeReferences, t as loadRefs } from "./index-mmRF3KNp.mjs";
|
|
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-D7GpOmkl.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, ASK_PATTERNS, ASK_WRITERS, ApexContext, ApexGate, ApexState, ApexTask, ApexTaskFile, ApexTaskState, AuthEntry, CODE_MUTATORS, CODE_REDIRECT, COLOR_THRESHOLDS, CRITICAL_PATTERNS, ColorFn, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, DEV_VERBS, DocSatisfactionStatus, EXCLUDE_DIRS, FAIL_CLOSED, FileSizeVerdict, GIT_ASK, GIT_BLOCKED, GO_DECL_RE, GRADIENT_BLOCKS, GUARDS, Guard, GuardContext, HarnessId, HarnessInfo, HarnessMode, HarnessVia, IndexSummary, JAVA_DECL_RE, MAX_EXA_RESULTS, MAX_LINES_ENV_KEY, MAX_TOKENS, ModularArchitecture, PHP_DECL_RE, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INDICATORS, PROJECT_INSTALL, PROTECTED_FRAGMENTS, PY_MODEL_RE, Palette, PolicyContext, PolicyResult, ProgressBarOptions, ProjectLayout, ProjectType, Prompt, PromptKind, RefMeta, ReminderState, RouteResult, SKILL_TRIGGERS, STATE_GITIGNORE, STATE_ROOT, SWIFT_PROTO_RE, SYSTEM_INSTALL, ScoredRef, TIME_INTERVALS, TS_DECL_RE, TTL_ENV_KEY, TreeEntry, acquireLock, addRoot, apexStateDir, bashWriteGuard, brainstormGate, buildApexInstruction, buildApexTaskContext, buildApexTaskInjection, buildClaudeMdContext, cacheLookup, cachePath, cacheStore, capVerbosity, clearUserGuards, colors, compactJson, compactMarkdown, countLines, descFromText, detectClaudeMdProjectType, detectCreationIntent, detectFramework, detectHarness, detectMode, detectModularArchitecture, detectProjectType, detectRequiredSkills, docConsultedGate, ensureMemoryGitignore, ensureStateDir, envCandidates, evaluate, evaluateApex, evaluateFileSize, extractText, firstComment, firstHeading, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, frameworkSolidGate, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, installGuard, interfaceSeparationGuard, isApexCommand, isCodeFile, isDocConsulted, isHtmlLike, jaccardSimilar, lessonsFileFor, loadApexTaskState, loadDotenv, loadIndex, loadRefs, loadState, matchPatterns, mcpCacheKey, missingSeoElements, modeFor, nowStamp, parseBodyDesc, parseEnrichment, parseEntry, parseEnvFile, parseEnvInt, parseField, parseFrontmatter, progressiveColor, projectLayout, projectRoot, projectRootOrNull, protectedPathGuard, queryHash, readRoots, readState, registerGuard, registryFile, requiredArchSkill, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, runGuards, saveState, scoreReferences, securityGuard, setStateField, skillTriggerGate, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, toRefMeta, ttlLabel, walkUpFor };
|
|
14
|
+
export { APEX_GATES, ASK_PATTERNS, ASK_WRITERS, ApexContext, ApexGate, ApexState, ApexTask, ApexTaskFile, ApexTaskState, AuthEntry, CODE_MUTATORS, CODE_REDIRECT, COLOR_THRESHOLDS, CRITICAL_PATTERNS, ColorFn, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, DEV_VERBS, DocSatisfactionStatus, EXCLUDE_DIRS, FAIL_CLOSED, FILE_REDIRECT, FileSizeVerdict, GIT_ASK, GIT_BLOCKED, GO_DECL_RE, GRADIENT_BLOCKS, GUARDS, Guard, GuardContext, HOME_DIR, HarnessId, HarnessInfo, HarnessMode, HarnessVia, IndexSummary, JAVA_DECL_RE, MAX_EXA_RESULTS, MAX_LINES_ENV_KEY, MAX_TOKENS, ModularArchitecture, PHP_DECL_RE, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INDICATORS, PROJECT_INSTALL, PROTECTED_FRAGMENTS, PROTECTED_GIT_RE, PY_MODEL_RE, Palette, PolicyContext, PolicyResult, ProgressBarOptions, ProjectLayout, ProjectType, Prompt, PromptKind, RefMeta, ReminderState, RouteResult, SKILL_TRIGGERS, STATE_GITIGNORE, STATE_ROOT, SWIFT_PROTO_RE, SYSTEM_INSTALL, ScoredRef, TIME_INTERVALS, TS_DECL_RE, TTL_ENV_KEY, TreeEntry, acquireLock, addRoot, apexStateDir, bashWriteGuard, brainstormGate, buildApexInstruction, buildApexTaskContext, buildApexTaskInjection, buildClaudeMdContext, cacheLookup, cacheLookupSubstring, cachePath, cacheStore, capVerbosity, clearUserGuards, colors, compactJson, compactMarkdown, countLines, descFromText, detectClaudeMdProjectType, detectCreationIntent, detectFramework, detectHarness, detectMode, detectModularArchitecture, detectProjectType, detectRequiredSkills, docConsultedGate, ensureMemoryGitignore, ensureStateDir, envCandidates, evaluate, evaluateApex, evaluateFileSize, extractText, firstComment, firstHeading, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, frameworkSolidGate, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, installGuard, interfaceSeparationGuard, isApexCommand, isCodeFile, isDocConsulted, isHtmlLike, jaccardSimilar, lessonsFileFor, loadApexTaskState, loadDotenv, loadIndex, loadRefs, loadState, matchPatterns, mcpCacheKey, mcpCacheWrite, missingSeoElements, modeFor, nowStamp, parseBodyDesc, parseEnrichment, parseEntry, parseEnvFile, parseEnvInt, parseField, parseFrontmatter, progressiveColor, projectLayout, projectRoot, projectRootOrNull, protectedPathGuard, queryHash, readRoots, readState, registerGuard, registryFile, requiredArchSkill, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, runGuards, saveState, scoreReferences, securityGuard, setStateField, skillTriggerGate, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, toRefMeta, ttlLabel, walkUpFor, webfetchCacheWrite };
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { a as parseEnvInt, i as splitTarget, n as MAX_LINES_ENV_KEY, r as resolveMaxLines, t as DEFAULT_MAX_LINES } from "./limits-CHn8AIL1.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { i as ttlLabel, n as TTL_ENV_KEY, r as resolveTtlSec, t as DEFAULT_TTL_SEC } from "./ttl-BG55s6HZ.mjs";
|
|
3
3
|
import { n as STATE_ROOT, r as projectLayout, t as STATE_GITIGNORE } from "./layout-C0jaaCQC.mjs";
|
|
4
|
+
import { i as parseEnvFile, n as envCandidates, r as loadDotenv, t as HOME_DIR } from "./dotenv-DGyLln7U.mjs";
|
|
4
5
|
import { t as compactJson } from "./compact-json-DK2nX-MK.mjs";
|
|
5
6
|
import { i as walkUpFor, n as projectRoot, r as projectRootOrNull, t as isCodeFile } from "./project-root-3kk7gCOp.mjs";
|
|
6
7
|
import { n as detectMode, r as modeFor, t as detectHarness } from "./harness-C8Nxxyn_.mjs";
|
|
7
|
-
import { A as evaluateApex, C as MAX_EXA_RESULTS, D as APEX_GATES, E as detectCreationIntent, F as detectProjectType, I as isApexCommand, L as requiredArchSkill, M as solidReadGate, N as DEV_KEYWORDS, O as brainstormGate, P as detectModularArchitecture, S as frameworkSolidGate, T as capVerbosity, _ as buildClaudeMdContext, a as firstHeading, b as skillTriggerGate, c as parseBodyDesc, d as PROJECT_INDICATORS, f as buildApexTaskContext, g as buildApexInstruction, h as DEV_VERBS, i as firstComment, j as freshnessGate, k as docConsultedGate, l as parseField, m as loadApexTaskState, n as missingSeoElements, o as parseEnrichment, p as buildApexTaskInjection, r as descFromText, s as parseEntry, t as isHtmlLike, u as EXCLUDE_DIRS, v as detectClaudeMdProjectType, w as MAX_TOKENS, x as SKILL_TRIGGERS, y as detectRequiredSkills } from "./validate-
|
|
8
|
-
import { A as
|
|
9
|
-
import { i as resolveSessions, n as formatDocSatisfactionStatus, r as isDocConsulted, t as formatDocDeny } from "./doc-helpers-
|
|
10
|
-
import { i as parseFrontmatter, n as scoreReferences, r as globToRe, t as routeReferences } from "./router-
|
|
8
|
+
import { A as evaluateApex, C as MAX_EXA_RESULTS, D as APEX_GATES, E as detectCreationIntent, F as detectProjectType, I as isApexCommand, L as requiredArchSkill, M as solidReadGate, N as DEV_KEYWORDS, O as brainstormGate, P as detectModularArchitecture, S as frameworkSolidGate, T as capVerbosity, _ as buildClaudeMdContext, a as firstHeading, b as skillTriggerGate, c as parseBodyDesc, d as PROJECT_INDICATORS, f as buildApexTaskContext, g as buildApexInstruction, h as DEV_VERBS, i as firstComment, j as freshnessGate, k as docConsultedGate, l as parseField, m as loadApexTaskState, n as missingSeoElements, o as parseEnrichment, p as buildApexTaskInjection, r as descFromText, s as parseEntry, t as isHtmlLike, u as EXCLUDE_DIRS, v as detectClaudeMdProjectType, w as MAX_TOKENS, x as SKILL_TRIGGERS, y as detectRequiredSkills } from "./validate-BCRqp9XG.mjs";
|
|
9
|
+
import { A as matchPatterns, C as ASK_PATTERNS, D as GIT_BLOCKED, E as GIT_ASK, M as evaluateFileSize, N as detectFramework, O as PROJECT_INSTALL, S as protectedPathGuard, T as securityGuard, _ as CODE_REDIRECT, a as registerGuard, b as PROTECTED_FRAGMENTS, c as GO_DECL_RE, d as PY_MODEL_RE, f as SWIFT_PROTO_RE, g as CODE_MUTATORS, h as ASK_WRITERS, i as clearUserGuards, j as countLines, k as SYSTEM_INSTALL, l as JAVA_DECL_RE, m as interfaceSeparationGuard, n as FAIL_CLOSED, o as runGuards, p as TS_DECL_RE, r as GUARDS, s as installGuard, t as evaluate, u as PHP_DECL_RE, v as FILE_REDIRECT, w as CRITICAL_PATTERNS, x as PROTECTED_GIT_RE, y as bashWriteGuard } from "./evaluate-B1n1ti0N.mjs";
|
|
10
|
+
import { i as resolveSessions, n as formatDocSatisfactionStatus, r as isDocConsulted, t as formatDocDeny } from "./doc-helpers-B4XYL1v8.mjs";
|
|
11
|
+
import { i as parseFrontmatter, n as scoreReferences, r as globToRe, t as routeReferences } from "./router-BfX0hJg8.mjs";
|
|
11
12
|
import { t as formatPrompt } from "./types-ernB1Dy3.mjs";
|
|
12
13
|
import { a as nowStamp, c as stateFileFor, i as lessonsFileFor, l as throttleMs, n as readRoots, o as readState, r as registryFile, s as setStateField, t as addRoot, u as ensureMemoryGitignore } from "./registry-BkoEbdec.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import { a as extractText, i as mcpCacheKey, n as cachePath, o as loadIndex, r as cacheStore, s as summarizeIndex, t as cacheLookup } from "./store-PrNPm6So.mjs";
|
|
14
|
+
import { a as cachePath, c as extractText, d as compactMarkdown, f as jaccardSimilar, i as cacheLookupSubstring, l as loadIndex, n as webfetchCacheWrite, o as cacheStore, p as queryHash, r as cacheLookup, s as mcpCacheKey, t as mcpCacheWrite, u as summarizeIndex } from "./mcp-store-CDUVqtJ0.mjs";
|
|
15
15
|
import { t as incrementTrivialEditCounter } from "./freshness-43gxYpiX.mjs";
|
|
16
|
-
import { n as toRefMeta, t as loadRefs } from "./loader-
|
|
16
|
+
import { n as toRefMeta, t as loadRefs } from "./loader-Bn-DbZmt.mjs";
|
|
17
17
|
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-BthKK4Jj.mjs";
|
|
18
18
|
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";
|
|
19
|
-
export { APEX_GATES, ASK_PATTERNS, ASK_WRITERS, CODE_MUTATORS, CODE_REDIRECT, COLOR_THRESHOLDS, CRITICAL_PATTERNS, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, DEV_VERBS, EXCLUDE_DIRS, FAIL_CLOSED, GIT_ASK, GIT_BLOCKED, GO_DECL_RE, GRADIENT_BLOCKS, GUARDS, JAVA_DECL_RE, MAX_EXA_RESULTS, MAX_LINES_ENV_KEY, MAX_TOKENS, PHP_DECL_RE, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INDICATORS, PROJECT_INSTALL, PROTECTED_FRAGMENTS, PY_MODEL_RE, SKILL_TRIGGERS, STATE_GITIGNORE, STATE_ROOT, SWIFT_PROTO_RE, SYSTEM_INSTALL, TIME_INTERVALS, TS_DECL_RE, TTL_ENV_KEY, acquireLock, addRoot, apexStateDir, bashWriteGuard, brainstormGate, buildApexInstruction, buildApexTaskContext, buildApexTaskInjection, buildClaudeMdContext, cacheLookup, cachePath, cacheStore, capVerbosity, clearUserGuards, colors, compactJson, compactMarkdown, countLines, descFromText, detectClaudeMdProjectType, detectCreationIntent, detectFramework, detectHarness, detectMode, detectModularArchitecture, detectProjectType, detectRequiredSkills, docConsultedGate, ensureMemoryGitignore, ensureStateDir, envCandidates, evaluate, evaluateApex, evaluateFileSize, extractText, firstComment, firstHeading, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, frameworkSolidGate, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, installGuard, interfaceSeparationGuard, isApexCommand, isCodeFile, isDocConsulted, isHtmlLike, jaccardSimilar, lessonsFileFor, loadApexTaskState, loadDotenv, loadIndex, loadRefs, loadState, matchPatterns, mcpCacheKey, missingSeoElements, modeFor, nowStamp, parseBodyDesc, parseEnrichment, parseEntry, parseEnvFile, parseEnvInt, parseField, parseFrontmatter, progressiveColor, projectLayout, projectRoot, projectRootOrNull, protectedPathGuard, queryHash, readRoots, readState, registerGuard, registryFile, requiredArchSkill, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, runGuards, saveState, scoreReferences, securityGuard, setStateField, skillTriggerGate, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, toRefMeta, ttlLabel, walkUpFor };
|
|
19
|
+
export { APEX_GATES, ASK_PATTERNS, ASK_WRITERS, CODE_MUTATORS, CODE_REDIRECT, COLOR_THRESHOLDS, CRITICAL_PATTERNS, DEFAULT_MAX_LINES, DEFAULT_TTL_SEC, DEV_KEYWORDS, DEV_VERBS, EXCLUDE_DIRS, FAIL_CLOSED, FILE_REDIRECT, GIT_ASK, GIT_BLOCKED, GO_DECL_RE, GRADIENT_BLOCKS, GUARDS, HOME_DIR, JAVA_DECL_RE, MAX_EXA_RESULTS, MAX_LINES_ENV_KEY, MAX_TOKENS, PHP_DECL_RE, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, PROJECT_INDICATORS, PROJECT_INSTALL, PROTECTED_FRAGMENTS, PROTECTED_GIT_RE, PY_MODEL_RE, SKILL_TRIGGERS, STATE_GITIGNORE, STATE_ROOT, SWIFT_PROTO_RE, SYSTEM_INSTALL, TIME_INTERVALS, TS_DECL_RE, TTL_ENV_KEY, acquireLock, addRoot, apexStateDir, bashWriteGuard, brainstormGate, buildApexInstruction, buildApexTaskContext, buildApexTaskInjection, buildClaudeMdContext, cacheLookup, cacheLookupSubstring, cachePath, cacheStore, capVerbosity, clearUserGuards, colors, compactJson, compactMarkdown, countLines, descFromText, detectClaudeMdProjectType, detectCreationIntent, detectFramework, detectHarness, detectMode, detectModularArchitecture, detectProjectType, detectRequiredSkills, docConsultedGate, ensureMemoryGitignore, ensureStateDir, envCandidates, evaluate, evaluateApex, evaluateFileSize, extractText, firstComment, firstHeading, formatBasename, formatCost, formatDocDeny, formatDocSatisfactionStatus, formatPath, formatPrompt, formatTimeLeft, formatTokens, frameworkSolidGate, freshnessGate, generateGradientBar, generateProgressBar, globToRe, incrementTrivialEditCounter, installGuard, interfaceSeparationGuard, isApexCommand, isCodeFile, isDocConsulted, isHtmlLike, jaccardSimilar, lessonsFileFor, loadApexTaskState, loadDotenv, loadIndex, loadRefs, loadState, matchPatterns, mcpCacheKey, mcpCacheWrite, missingSeoElements, modeFor, nowStamp, parseBodyDesc, parseEnrichment, parseEntry, parseEnvFile, parseEnvInt, parseField, parseFrontmatter, progressiveColor, projectLayout, projectRoot, projectRootOrNull, protectedPathGuard, queryHash, readRoots, readState, registerGuard, registryFile, requiredArchSkill, resolveMaxLines, resolveSessions, resolveTtlSec, routeReferences, runGuards, saveState, scoreReferences, securityGuard, setStateField, skillTriggerGate, solidReadGate, splitTarget, stateFileFor, stateFilePath, summarizeIndex, taskComplete, taskCreate, taskStart, throttleMs, toRefMeta, ttlLabel, walkUpFor, webfetchCacheWrite };
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { t as atomicWrite } from "./json-io-CvSumjtz.mjs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
//#region src/cache/compact.ts
|
|
6
|
+
const HTML_ENTITIES = {
|
|
7
|
+
"&": "&",
|
|
8
|
+
"<": "<",
|
|
9
|
+
">": ">",
|
|
10
|
+
""": "\"",
|
|
11
|
+
"'": "'",
|
|
12
|
+
"'": "'",
|
|
13
|
+
" ": " ",
|
|
14
|
+
"'": "'"
|
|
15
|
+
};
|
|
16
|
+
const BOILERPLATE = [
|
|
17
|
+
/^.*cookie.*(accept|consent|banner).*$/gim,
|
|
18
|
+
/^.*was this (helpful|page helpful|article helpful).*$/gim,
|
|
19
|
+
/^.*©\s*\d{4}.*all rights reserved.*$/gim,
|
|
20
|
+
/^\s*(home|about|contact|privacy|terms)\s*\|\s*.*$/gim,
|
|
21
|
+
/^.*subscribe to (our )?newsletter.*$/gim,
|
|
22
|
+
/^.*follow us on (twitter|facebook|linkedin).*$/gim
|
|
23
|
+
];
|
|
24
|
+
const MAX_BYTES = 5 * 1024;
|
|
25
|
+
function decodeEntities(text) {
|
|
26
|
+
let out = text;
|
|
27
|
+
for (const [ent, ch] of Object.entries(HTML_ENTITIES)) out = out.split(ent).join(ch);
|
|
28
|
+
out = out.replace(/&#x([0-9a-fA-F]+);/g, (_m, h) => String.fromCodePoint(parseInt(h, 16)));
|
|
29
|
+
out = out.replace(/&#(\d+);/g, (_m, d) => String.fromCodePoint(parseInt(d, 10)));
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/** Strip HTML entities + boilerplate, normalize blank lines, truncate to ~5KB. */
|
|
33
|
+
function compactMarkdown(content) {
|
|
34
|
+
let text = decodeEntities(content);
|
|
35
|
+
for (const re of BOILERPLATE) text = text.replace(re, "");
|
|
36
|
+
text = text.replace(/\n{3,}/g, "\n\n").trim();
|
|
37
|
+
const enc = new TextEncoder().encode(text);
|
|
38
|
+
if (enc.length > MAX_BYTES) {
|
|
39
|
+
const truncated = new TextDecoder().decode(enc.slice(0, MAX_BYTES));
|
|
40
|
+
text = `${truncated}\n\n[... truncated, ${text.slice(truncated.length).split("\n").length - 1} lines]`;
|
|
41
|
+
}
|
|
42
|
+
return text;
|
|
43
|
+
}
|
|
44
|
+
/** 8-char MD5 of `${toolName}::${query}`. */
|
|
45
|
+
function queryHash(toolName, query) {
|
|
46
|
+
return createHash("md5").update(`${toolName}::${query}`).digest("hex").slice(0, 8);
|
|
47
|
+
}
|
|
48
|
+
/** Bag-of-words Jaccard similarity strictly greater than `threshold`. */
|
|
49
|
+
function jaccardSimilar(a, b, threshold = .8) {
|
|
50
|
+
const ta = new Set(a.toLowerCase().split(/\s+/).filter(Boolean));
|
|
51
|
+
const tb = new Set(b.toLowerCase().split(/\s+/).filter(Boolean));
|
|
52
|
+
if (ta.size === 0 || tb.size === 0) return false;
|
|
53
|
+
let inter = 0;
|
|
54
|
+
for (const t of ta) if (tb.has(t)) inter++;
|
|
55
|
+
const union = ta.size + tb.size - inter;
|
|
56
|
+
return inter / union > threshold;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/cache/io.ts
|
|
60
|
+
/** Read a JSON array from `path`; [] on missing/corrupt/non-array. */
|
|
61
|
+
function loadIndex(path) {
|
|
62
|
+
try {
|
|
63
|
+
if (!existsSync(path)) return [];
|
|
64
|
+
const data = JSON.parse(readFileSync(path, "utf8"));
|
|
65
|
+
return Array.isArray(data) ? data : [];
|
|
66
|
+
} catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Summarize an index of `{ tool?, ts? }` entries. */
|
|
71
|
+
function summarizeIndex(index) {
|
|
72
|
+
const byTool = {};
|
|
73
|
+
const timestamps = [];
|
|
74
|
+
for (const entry of index) {
|
|
75
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
76
|
+
const e = entry;
|
|
77
|
+
if (typeof e.tool === "string") byTool[e.tool] = (byTool[e.tool] ?? 0) + 1;
|
|
78
|
+
if (typeof e.ts === "string") timestamps.push(e.ts);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
total: index.length,
|
|
82
|
+
byTool,
|
|
83
|
+
oldestTs: timestamps.length ? timestamps.reduce((a, b) => a < b ? a : b) : null,
|
|
84
|
+
newestTs: timestamps.length ? timestamps.reduce((a, b) => a > b ? a : b) : null
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/cache/mcp-response.ts
|
|
89
|
+
const MAX_DEPTH = 5;
|
|
90
|
+
/**
|
|
91
|
+
* Extract usable markdown from an MCP `tool_response`: a string, a list of
|
|
92
|
+
* content blocks (non-text blocks skipped), or any JSON structure (fallback).
|
|
93
|
+
* Recurses up to depth 5 to guard against pathological/cyclic structures.
|
|
94
|
+
*/
|
|
95
|
+
function extractText(resp, depth = 0) {
|
|
96
|
+
if (depth >= MAX_DEPTH) return "";
|
|
97
|
+
if (typeof resp === "string") return resp;
|
|
98
|
+
if (Array.isArray(resp)) {
|
|
99
|
+
const parts = resp.filter((b) => typeof b === "object" && b !== null).filter((b) => b.type === "text").map((b) => b.text ?? "");
|
|
100
|
+
if (parts.length) return parts.join("\n\n");
|
|
101
|
+
const joined = resp.filter((b) => Array.isArray(b) || typeof b === "object" && b !== null).map((b) => extractText(b, depth + 1)).filter(Boolean).join("\n\n");
|
|
102
|
+
if (joined) return joined;
|
|
103
|
+
}
|
|
104
|
+
if (!resp) return "";
|
|
105
|
+
try {
|
|
106
|
+
return JSON.stringify(resp, (_k, v) => v !== null && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b))) : v);
|
|
107
|
+
} catch {
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/cache/store.ts
|
|
113
|
+
/** Max body bytes read on a substring lookup (parity with mcp-cache-lookup.py MAX_BODY). */
|
|
114
|
+
const MAX_BODY = 8 * 1024;
|
|
115
|
+
/** Needle length scanned on a substring lookup (first 80 query chars, ripgrep-aligned). */
|
|
116
|
+
const NEEDLE_LEN = 80;
|
|
117
|
+
/** Stable 16-char key from a tool name + query (FNV-1a, non-crypto). */
|
|
118
|
+
function mcpCacheKey(tool, query) {
|
|
119
|
+
const s = `${tool}\n${query}`;
|
|
120
|
+
let h = 2166136261;
|
|
121
|
+
for (let i = 0; i < s.length; i++) {
|
|
122
|
+
h ^= s.charCodeAt(i);
|
|
123
|
+
h = Math.imul(h, 16777619);
|
|
124
|
+
}
|
|
125
|
+
return (h >>> 0).toString(16).padStart(8, "0") + (s.length >>> 0).toString(16).padStart(8, "0");
|
|
126
|
+
}
|
|
127
|
+
/** Path of a cache entry under `dir`. */
|
|
128
|
+
function cachePath(dir, tool, query) {
|
|
129
|
+
return join(dir, `${mcpCacheKey(tool, query)}.md`);
|
|
130
|
+
}
|
|
131
|
+
/** Read a cached entry if it exists and is fresh (mtime within `ttlMs`), else null. */
|
|
132
|
+
function cacheLookup(dir, tool, query, ttlMs, now) {
|
|
133
|
+
const path = cachePath(dir, tool, query);
|
|
134
|
+
try {
|
|
135
|
+
if (!existsSync(path) || now - statSync(path).mtimeMs > ttlMs) return null;
|
|
136
|
+
return readFileSync(path, "utf8");
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* First fresh cache file whose body contains the (normalized, case-insensitive)
|
|
143
|
+
* query substring, else null. Relaxes the exact-key match to lift the hit-rate —
|
|
144
|
+
* parity with `mcp-cache-lookup.py` (`rg -i -F` over the first 80 query chars).
|
|
145
|
+
* @param dir - Cache directory to scan.
|
|
146
|
+
* @param query - Raw query; newlines folded to spaces, truncated to 80 chars.
|
|
147
|
+
* @param ttlMs - Freshness window (mtime-based).
|
|
148
|
+
* @param now - Current epoch ms.
|
|
149
|
+
*/
|
|
150
|
+
function cacheLookupSubstring(dir, query, ttlMs, now) {
|
|
151
|
+
const needle = query.replace(/[\r\n]+/g, " ").slice(0, NEEDLE_LEN).trim().toLowerCase();
|
|
152
|
+
if (!needle) return null;
|
|
153
|
+
let names;
|
|
154
|
+
try {
|
|
155
|
+
names = readdirSync(dir);
|
|
156
|
+
} catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
for (const name of names) {
|
|
160
|
+
if (!name.endsWith(".md")) continue;
|
|
161
|
+
const path = join(dir, name);
|
|
162
|
+
try {
|
|
163
|
+
if (now - statSync(path).mtimeMs > ttlMs) continue;
|
|
164
|
+
const body = readFileSync(path, "utf8").slice(0, MAX_BODY);
|
|
165
|
+
if (body.toLowerCase().includes(needle)) return body;
|
|
166
|
+
} catch {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
/** Store a cache entry (creates the dir; no-op on empty content). */
|
|
173
|
+
function cacheStore(dir, tool, query, content) {
|
|
174
|
+
if (!content) return;
|
|
175
|
+
const path = cachePath(dir, tool, query);
|
|
176
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
177
|
+
writeFileSync(path, content);
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/cache/mcp-store.ts
|
|
181
|
+
/** UTC timestamp `YYYY-MM-DDTHH:MM:SSZ` (no millis), mirroring the Python store. */
|
|
182
|
+
function stamp(now) {
|
|
183
|
+
return new Date(now).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
184
|
+
}
|
|
185
|
+
/** True when a Jaccard-similar query already exists for `tool` in `index`. */
|
|
186
|
+
function isDuplicate(index, tool, query) {
|
|
187
|
+
return index.some((e) => {
|
|
188
|
+
if (typeof e !== "object" || e === null) return false;
|
|
189
|
+
const r = e;
|
|
190
|
+
return r.tool === tool && typeof r.query === "string" && jaccardSimilar(r.query, query);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Persist an MCP doc result the way `cache-mcp-result.py` does: compact the body,
|
|
195
|
+
* skip Jaccard-duplicate queries, write a front-matter `.md` (exact FNV key, so
|
|
196
|
+
* {@link cacheLookup} still hits) carrying the query for substring lookups, and
|
|
197
|
+
* append the entry to `index.json`. No-op on empty body or duplicate query.
|
|
198
|
+
* @param dir - Cache directory (also holds `index.json`).
|
|
199
|
+
* @param tool - MCP tool id.
|
|
200
|
+
* @param query - Doc query that keys the entry.
|
|
201
|
+
* @param body - Raw response text (compacted before write).
|
|
202
|
+
* @param now - Current epoch ms (timestamp source).
|
|
203
|
+
*/
|
|
204
|
+
function mcpCacheWrite(dir, tool, query, body, now) {
|
|
205
|
+
const compacted = compactMarkdown(body);
|
|
206
|
+
if (!compacted) return;
|
|
207
|
+
const indexPath = join(dir, "index.json");
|
|
208
|
+
const index = loadIndex(indexPath);
|
|
209
|
+
if (isDuplicate(index, tool, query)) return;
|
|
210
|
+
const hash = queryHash(tool, query);
|
|
211
|
+
const ts = stamp(now);
|
|
212
|
+
cacheStore(dir, tool, query, `---\ntool: ${tool}\nquery: ${JSON.stringify(query)}\nts: ${ts}\nhash: ${hash}\n---\n\n` + compacted);
|
|
213
|
+
index.push({
|
|
214
|
+
tool,
|
|
215
|
+
query,
|
|
216
|
+
hash,
|
|
217
|
+
ts
|
|
218
|
+
});
|
|
219
|
+
atomicWrite(indexPath, JSON.stringify(index, null, 2));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Persist a WebFetch result the way `webfetch-cache-store.py` does: compact the
|
|
223
|
+
* body, write a front-matter `.md` keyed by `key` (url + prompt[:500]). No index
|
|
224
|
+
* and no dedup — WebFetch entries are exact-key only. No-op on empty body.
|
|
225
|
+
* @param dir - Cache directory.
|
|
226
|
+
* @param tool - Always `WebFetch`.
|
|
227
|
+
* @param key - The url+prompt cache key string.
|
|
228
|
+
* @param body - Raw response text (compacted before write).
|
|
229
|
+
* @param now - Current epoch ms (timestamp source).
|
|
230
|
+
*/
|
|
231
|
+
function webfetchCacheWrite(dir, tool, key, body, now) {
|
|
232
|
+
const compacted = compactMarkdown(body);
|
|
233
|
+
if (!compacted) return;
|
|
234
|
+
const hash = queryHash(tool, key);
|
|
235
|
+
cacheStore(dir, tool, key, `---\ntool: ${tool}\nkey: ${JSON.stringify(key)}\nts: ${stamp(now)}\nhash: ${hash}\n---\n\n` + compacted);
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { cachePath as a, extractText as c, compactMarkdown as d, jaccardSimilar as f, cacheLookupSubstring as i, loadIndex as l, webfetchCacheWrite as n, cacheStore as o, queryHash as p, cacheLookup as r, mcpCacheKey as s, mcpCacheWrite as t, summarizeIndex as u };
|
package/dist/policy/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { APEX_GATES, ASK_PATTERNS, ASK_WRITERS, ApexContext, ApexGate, ApexTaskState, CODE_MUTATORS, CODE_REDIRECT, CRITICAL_PATTERNS, DEV_KEYWORDS, DEV_VERBS, EXCLUDE_DIRS, FAIL_CLOSED, FileSizeVerdict, GIT_ASK, GIT_BLOCKED, GO_DECL_RE, GUARDS, Guard, GuardContext, JAVA_DECL_RE, MAX_EXA_RESULTS, MAX_TOKENS, ModularArchitecture, PHP_DECL_RE, PROJECT_INDICATORS, PROJECT_INSTALL, PROTECTED_FRAGMENTS, PY_MODEL_RE, PolicyContext, PolicyResult, ProjectType, SKILL_TRIGGERS, SWIFT_PROTO_RE, SYSTEM_INSTALL, TS_DECL_RE, TreeEntry, bashWriteGuard, brainstormGate, buildApexInstruction, buildApexTaskContext, buildApexTaskInjection, buildClaudeMdContext, capVerbosity, clearUserGuards, countLines, descFromText, detectClaudeMdProjectType, detectCreationIntent, detectFramework, detectModularArchitecture, detectProjectType, detectRequiredSkills, docConsultedGate, evaluate, evaluateApex, evaluateFileSize, firstComment, firstHeading, frameworkSolidGate, freshnessGate, installGuard, interfaceSeparationGuard, isApexCommand, isHtmlLike, loadApexTaskState, matchPatterns, missingSeoElements, parseBodyDesc, parseEnrichment, parseEntry, parseField, protectedPathGuard, registerGuard, requiredArchSkill, runGuards, securityGuard, skillTriggerGate, solidReadGate };
|
|
1
|
+
import { $ as Guard, A as GUARDS, B as TS_DECL_RE, C as SKILL_TRIGGERS, Ct as ProjectType, D as capVerbosity, Dt as requiredArchSkill, E as MAX_TOKENS, Et as isApexCommand, F as GO_DECL_RE, G as FILE_REDIRECT, H as ASK_WRITERS, I as JAVA_DECL_RE, J as PROTECTED_GIT_RE, K as bashWriteGuard, L as PHP_DECL_RE, M as registerGuard, N as runGuards, O as detectCreationIntent, P as installGuard, Q as securityGuard, R as PY_MODEL_RE, S as skillTriggerGate, St as ModularArchitecture, T as MAX_EXA_RESULTS, Tt as detectProjectType, U as CODE_MUTATORS, V as interfaceSeparationGuard, W as CODE_REDIRECT, X as ASK_PATTERNS, Y as protectedPathGuard, Z as CRITICAL_PATTERNS, _ as DEV_VERBS, _t as FileSizeVerdict, a as firstHeading, at as docConsultedGate, b as detectClaudeMdProjectType, bt as detectFramework, c as parseEntry, ct as solidReadGate, d as EXCLUDE_DIRS, dt as evaluate, et as GuardContext, f as PROJECT_INDICATORS, ft as GIT_ASK, g as loadApexTaskState, gt as matchPatterns, h as buildApexTaskInjection, ht as SYSTEM_INSTALL, i as firstComment, it as brainstormGate, j as clearUserGuards, k as FAIL_CLOSED, l as parseBodyDesc, lt as PolicyContext, m as buildApexTaskContext, mt as PROJECT_INSTALL, n as missingSeoElements, nt as ApexContext, o as TreeEntry, ot as evaluateApex, p as ApexTaskState, pt as GIT_BLOCKED, q as PROTECTED_FRAGMENTS, r as descFromText, rt as ApexGate, s as parseEnrichment, st as freshnessGate, t as isHtmlLike, tt as APEX_GATES, u as parseField, ut as PolicyResult, v as buildApexInstruction, vt as countLines, w as frameworkSolidGate, wt as detectModularArchitecture, x as detectRequiredSkills, xt as DEV_KEYWORDS, y as buildClaudeMdContext, yt as evaluateFileSize, z as SWIFT_PROTO_RE } from "../index-DTrjSNmI.mjs";
|
|
2
|
+
export { APEX_GATES, ASK_PATTERNS, ASK_WRITERS, ApexContext, ApexGate, ApexTaskState, CODE_MUTATORS, CODE_REDIRECT, CRITICAL_PATTERNS, DEV_KEYWORDS, DEV_VERBS, EXCLUDE_DIRS, FAIL_CLOSED, FILE_REDIRECT, FileSizeVerdict, GIT_ASK, GIT_BLOCKED, GO_DECL_RE, GUARDS, Guard, GuardContext, JAVA_DECL_RE, MAX_EXA_RESULTS, MAX_TOKENS, ModularArchitecture, PHP_DECL_RE, PROJECT_INDICATORS, PROJECT_INSTALL, PROTECTED_FRAGMENTS, PROTECTED_GIT_RE, PY_MODEL_RE, PolicyContext, PolicyResult, ProjectType, SKILL_TRIGGERS, SWIFT_PROTO_RE, SYSTEM_INSTALL, TS_DECL_RE, TreeEntry, bashWriteGuard, brainstormGate, buildApexInstruction, buildApexTaskContext, buildApexTaskInjection, buildClaudeMdContext, capVerbosity, clearUserGuards, countLines, descFromText, detectClaudeMdProjectType, detectCreationIntent, detectFramework, detectModularArchitecture, detectProjectType, detectRequiredSkills, docConsultedGate, evaluate, evaluateApex, evaluateFileSize, firstComment, firstHeading, frameworkSolidGate, freshnessGate, installGuard, interfaceSeparationGuard, isApexCommand, isHtmlLike, loadApexTaskState, matchPatterns, missingSeoElements, parseBodyDesc, parseEnrichment, parseEntry, parseField, protectedPathGuard, registerGuard, requiredArchSkill, runGuards, securityGuard, skillTriggerGate, solidReadGate };
|