@swarmvaultai/engine 3.17.0 → 3.18.0

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.
@@ -140,13 +140,18 @@ function collectCommandCandidates(node, acc = []) {
140
140
  return acc;
141
141
  }
142
142
  function commandLooksLikeBroadSearch(command) {
143
- const tokens = command.replace(/[;&|()]/g, " ").split(/\s+/).map((token) => path.basename(token.replace(/^['"]|['"]$/g, ""))).filter(Boolean);
144
- for (let index = 0; index < tokens.length; index += 1) {
145
- const token = tokens[index];
146
- if (["rg", "grep", "find", "fd", "ag", "ack"].includes(token)) {
143
+ const statements = command.split(/;|&&|\|\|/);
144
+ for (const statement of statements) {
145
+ const firstStage = statement.split("|")[0] ?? "";
146
+ const tokens = firstStage.replace(/[()]/g, " ").split(/\s+/).map((token) => path.basename(token.replace(/^['"]|['"]$/g, ""))).filter(Boolean);
147
+ const leading = tokens.find((token) => !token.includes("=") && !token.startsWith("-"));
148
+ if (!leading) {
149
+ continue;
150
+ }
151
+ if (["rg", "grep", "find", "fd", "ag", "ack"].includes(leading)) {
147
152
  return true;
148
153
  }
149
- if (token === "git" && tokens[index + 1] === "grep") {
154
+ if (leading === "git" && tokens[tokens.indexOf(leading) + 1] === "grep") {
150
155
  return true;
151
156
  }
152
157
  }
@@ -206,7 +211,7 @@ async function resolveGraphFirstMode(cwd) {
206
211
  }
207
212
  } catch {
208
213
  }
209
- return "deny";
214
+ return "context";
210
215
  }
211
216
  async function readWatchStaleness(cwd) {
212
217
  const watchDir = path.join(artifactRootDir(cwd), "state", "watch");
@@ -120,13 +120,18 @@ function collectCommandCandidates(node, acc = []) {
120
120
  return acc;
121
121
  }
122
122
  function commandLooksLikeBroadSearch(command) {
123
- const tokens = command.replace(/[;&|()]/g, " ").split(/\s+/).map((token) => path.basename(token.replace(/^['"]|['"]$/g, ""))).filter(Boolean);
124
- for (let index = 0; index < tokens.length; index += 1) {
125
- const token = tokens[index];
126
- if (["rg", "grep", "find", "fd", "ag", "ack"].includes(token)) {
123
+ const statements = command.split(/;|&&|\|\|/);
124
+ for (const statement of statements) {
125
+ const firstStage = statement.split("|")[0] ?? "";
126
+ const tokens = firstStage.replace(/[()]/g, " ").split(/\s+/).map((token) => path.basename(token.replace(/^['"]|['"]$/g, ""))).filter(Boolean);
127
+ const leading = tokens.find((token) => !token.includes("=") && !token.startsWith("-"));
128
+ if (!leading) {
129
+ continue;
130
+ }
131
+ if (["rg", "grep", "find", "fd", "ag", "ack"].includes(leading)) {
127
132
  return true;
128
133
  }
129
- if (token === "git" && tokens[index + 1] === "grep") {
134
+ if (leading === "git" && tokens[tokens.indexOf(leading) + 1] === "grep") {
130
135
  return true;
131
136
  }
132
137
  }
@@ -186,7 +191,7 @@ async function resolveGraphFirstMode(cwd) {
186
191
  }
187
192
  } catch {
188
193
  }
189
- return "deny";
194
+ return "context";
190
195
  }
191
196
  async function readWatchStaleness(cwd) {
192
197
  const watchDir = path.join(artifactRootDir(cwd), "state", "watch");
@@ -166,7 +166,7 @@ async function resolveGraphFirstMode(cwd) {
166
166
  }
167
167
  } catch {
168
168
  }
169
- return "deny";
169
+ return "context";
170
170
  }
171
171
  async function readHookInput() {
172
172
  let body = "";
@@ -166,7 +166,7 @@ async function resolveGraphFirstMode(cwd) {
166
166
  }
167
167
  } catch {
168
168
  }
169
- return "deny";
169
+ return "context";
170
170
  }
171
171
  async function readWatchStaleness(cwd) {
172
172
  const watchDir = path.join(artifactRootDir(cwd), "state", "watch");
package/dist/index.d.ts CHANGED
@@ -1696,6 +1696,12 @@ interface InstallAgentOptions {
1696
1696
  scope?: "project" | "user";
1697
1697
  /** Register the SwarmVault MCP server in the agent's project MCP config. */
1698
1698
  mcp?: boolean;
1699
+ /**
1700
+ * Persist `hooks.graphFirst` in swarmvault.config.json. Enforcement
1701
+ * ("deny") is opt-in at install time; the hook default without config is
1702
+ * advisory "context".
1703
+ */
1704
+ graphFirst?: "deny" | "context" | "off";
1699
1705
  }
1700
1706
  interface InstallAgentResult {
1701
1707
  agent: AgentType;
@@ -2704,9 +2710,17 @@ declare function buildGraphTree(graph: GraphArtifact, options?: GraphTreeOptions
2704
2710
  declare function renderGraphTreeHtml(tree: GraphTreeNode, graph: GraphArtifact): string;
2705
2711
  declare function exportGraphTree(rootDir: string, outputPath?: string, options?: GraphTreeOptions): Promise<GraphTreeExportResult>;
2706
2712
 
2707
- declare function getGitHookStatus(rootDir: string): Promise<GitHookStatus>;
2708
- declare function installGitHooks(rootDir: string): Promise<GitHookStatus>;
2709
- declare function uninstallGitHooks(rootDir: string): Promise<GitHookStatus>;
2713
+ interface GitHookTargetOptions {
2714
+ /**
2715
+ * Git repo to install hooks into, when it is not above the vault root —
2716
+ * e.g. a vault at the workspace parent tracking repos in subdirectories.
2717
+ * The hook block still `cd`s back to the vault root before refreshing.
2718
+ */
2719
+ repoPath?: string;
2720
+ }
2721
+ declare function getGitHookStatus(rootDir: string, options?: GitHookTargetOptions): Promise<GitHookStatus>;
2722
+ declare function installGitHooks(rootDir: string, options?: GitHookTargetOptions): Promise<GitHookStatus>;
2723
+ declare function uninstallGitHooks(rootDir: string, options?: GitHookTargetOptions): Promise<GitHookStatus>;
2710
2724
 
2711
2725
  declare function listTrackedRepoRoots(rootDir: string): Promise<string[]>;
2712
2726
  declare function checkTrackedRepoChanges(rootDir: string, repoRoots?: string[]): Promise<GraphStatusChange[]>;
package/dist/index.js CHANGED
@@ -131,7 +131,7 @@ import {
131
131
  writeGuidedSourceSession,
132
132
  writeRetrievalManifest,
133
133
  writeWatchStatusArtifact
134
- } from "./chunk-JEWLYIHN.js";
134
+ } from "./chunk-DCSXDZAF.js";
135
135
  import {
136
136
  LocalWhisperProviderAdapter,
137
137
  SWARMVAULT_OUT_ENV,
@@ -5666,8 +5666,12 @@ async function removeHookBlock(filePath) {
5666
5666
  await fs9.writeFile(filePath, `${next}
5667
5667
  `, "utf8");
5668
5668
  }
5669
- async function getGitHookStatus(rootDir) {
5670
- const repoRoot = await findNearestGitRoot(rootDir);
5669
+ async function resolveHookRepoRoot(rootDir, options = {}) {
5670
+ const start = options.repoPath ? path11.resolve(rootDir, options.repoPath) : rootDir;
5671
+ return findNearestGitRoot(start);
5672
+ }
5673
+ async function getGitHookStatus(rootDir, options = {}) {
5674
+ const repoRoot = await resolveHookRepoRoot(rootDir, options);
5671
5675
  if (!repoRoot) {
5672
5676
  return {
5673
5677
  repoRoot: null,
@@ -5681,18 +5685,20 @@ async function getGitHookStatus(rootDir) {
5681
5685
  postCheckout: await readHookStatus(hookPath(repoRoot, "post-checkout"))
5682
5686
  };
5683
5687
  }
5684
- async function installGitHooks(rootDir) {
5685
- const repoRoot = await findNearestGitRoot(rootDir);
5688
+ async function installGitHooks(rootDir, options = {}) {
5689
+ const repoRoot = await resolveHookRepoRoot(rootDir, options);
5686
5690
  if (!repoRoot) {
5687
- throw new Error("No git repository found above the current vault.");
5691
+ throw new Error(
5692
+ options.repoPath ? `No git repository found at or above ${options.repoPath}.` : "No git repository found above the current vault. Pass a repo path (swarmvault hook install <repo>) when the tracked repo lives below the vault root."
5693
+ );
5688
5694
  }
5689
5695
  const block = managedHookBlock(path11.resolve(rootDir));
5690
5696
  await upsertHookFile(hookPath(repoRoot, "post-commit"), block);
5691
5697
  await upsertHookFile(hookPath(repoRoot, "post-checkout"), block);
5692
- return getGitHookStatus(rootDir);
5698
+ return getGitHookStatus(rootDir, options);
5693
5699
  }
5694
- async function uninstallGitHooks(rootDir) {
5695
- const repoRoot = await findNearestGitRoot(rootDir);
5700
+ async function uninstallGitHooks(rootDir, options = {}) {
5701
+ const repoRoot = await resolveHookRepoRoot(rootDir, options);
5696
5702
  if (!repoRoot) {
5697
5703
  return {
5698
5704
  repoRoot: null,
@@ -5702,7 +5708,7 @@ async function uninstallGitHooks(rootDir) {
5702
5708
  }
5703
5709
  await removeHookBlock(hookPath(repoRoot, "post-commit"));
5704
5710
  await removeHookBlock(hookPath(repoRoot, "post-checkout"));
5705
- return getGitHookStatus(rootDir);
5711
+ return getGitHookStatus(rootDir, options);
5706
5712
  }
5707
5713
 
5708
5714
  // src/mcp.ts
@@ -5711,7 +5717,7 @@ import path12 from "path";
5711
5717
  import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
5712
5718
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5713
5719
  import { z } from "zod";
5714
- var SERVER_VERSION = "3.17.0";
5720
+ var SERVER_VERSION = "3.18.0";
5715
5721
  var codeLanguageSchema = z.enum([
5716
5722
  "javascript",
5717
5723
  "jsx",
@@ -0,0 +1,32 @@
1
+ import {
2
+ buildMemoryGraphElements,
3
+ ensureMemoryLedger,
4
+ estimateMemoryTaskTokens,
5
+ finishMemoryTask,
6
+ listMemoryTasks,
7
+ loadMemoryTaskPages,
8
+ memoryTaskHashes,
9
+ memoryTaskPageRecord,
10
+ readMemoryTask,
11
+ renderMemoryTaskMarkdown,
12
+ resumeMemoryTask,
13
+ startMemoryTask,
14
+ updateMemoryTask
15
+ } from "./chunk-DCSXDZAF.js";
16
+ import "./chunk-NON6BVEI.js";
17
+ import "./chunk-NAIERP4C.js";
18
+ export {
19
+ buildMemoryGraphElements,
20
+ ensureMemoryLedger,
21
+ estimateMemoryTaskTokens,
22
+ finishMemoryTask,
23
+ listMemoryTasks,
24
+ loadMemoryTaskPages,
25
+ memoryTaskHashes,
26
+ memoryTaskPageRecord,
27
+ readMemoryTask,
28
+ renderMemoryTaskMarkdown,
29
+ resumeMemoryTask,
30
+ startMemoryTask,
31
+ updateMemoryTask
32
+ };
@@ -0,0 +1,32 @@
1
+ import {
2
+ buildMemoryGraphElements,
3
+ ensureMemoryLedger,
4
+ estimateMemoryTaskTokens,
5
+ finishMemoryTask,
6
+ listMemoryTasks,
7
+ loadMemoryTaskPages,
8
+ memoryTaskHashes,
9
+ memoryTaskPageRecord,
10
+ readMemoryTask,
11
+ renderMemoryTaskMarkdown,
12
+ resumeMemoryTask,
13
+ startMemoryTask,
14
+ updateMemoryTask
15
+ } from "./chunk-PXZGMENW.js";
16
+ import "./chunk-NON6BVEI.js";
17
+ import "./chunk-NAIERP4C.js";
18
+ export {
19
+ buildMemoryGraphElements,
20
+ ensureMemoryLedger,
21
+ estimateMemoryTaskTokens,
22
+ finishMemoryTask,
23
+ listMemoryTasks,
24
+ loadMemoryTaskPages,
25
+ memoryTaskHashes,
26
+ memoryTaskPageRecord,
27
+ readMemoryTask,
28
+ renderMemoryTaskMarkdown,
29
+ resumeMemoryTask,
30
+ startMemoryTask,
31
+ updateMemoryTask
32
+ };
@@ -0,0 +1,32 @@
1
+ import {
2
+ buildMemoryGraphElements,
3
+ ensureMemoryLedger,
4
+ estimateMemoryTaskTokens,
5
+ finishMemoryTask,
6
+ listMemoryTasks,
7
+ loadMemoryTaskPages,
8
+ memoryTaskHashes,
9
+ memoryTaskPageRecord,
10
+ readMemoryTask,
11
+ renderMemoryTaskMarkdown,
12
+ resumeMemoryTask,
13
+ startMemoryTask,
14
+ updateMemoryTask
15
+ } from "./chunk-WK2JR5H7.js";
16
+ import "./chunk-NON6BVEI.js";
17
+ import "./chunk-NAIERP4C.js";
18
+ export {
19
+ buildMemoryGraphElements,
20
+ ensureMemoryLedger,
21
+ estimateMemoryTaskTokens,
22
+ finishMemoryTask,
23
+ listMemoryTasks,
24
+ loadMemoryTaskPages,
25
+ memoryTaskHashes,
26
+ memoryTaskPageRecord,
27
+ readMemoryTask,
28
+ renderMemoryTaskMarkdown,
29
+ resumeMemoryTask,
30
+ startMemoryTask,
31
+ updateMemoryTask
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swarmvaultai/engine",
3
- "version": "3.17.0",
3
+ "version": "3.18.0",
4
4
  "description": "Core engine for SwarmVault: ingest, compile, query, lint, and provider abstractions.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",