agentic-diff 0.1.1 → 0.1.2

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.js CHANGED
@@ -11349,8 +11349,8 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
11349
11349
  });
11350
11350
  defineLazyInternal(inst, "pattern", (zod) => {
11351
11351
  if (zod.def.options.every((o) => o._zod.pattern)) {
11352
- const patterns2 = zod.def.options.map((o) => o._zod.pattern);
11353
- return new RegExp(`^(${patterns2.map((p) => cleanRegex(p.source)).join("|")})$`);
11352
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
11353
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
11354
11354
  }
11355
11355
  return void 0;
11356
11356
  });
@@ -13553,7 +13553,7 @@ var exactPattern = (p) => exactPatterns.get(p) ?? p;
13553
13553
  var stringProcessor = (schema, ctx, _json, _params) => {
13554
13554
  const json = _json;
13555
13555
  json.type = "string";
13556
- const { minimum, maximum, format, patterns: patterns2, contentEncoding, laxFormat } = aggregateChecks(schema);
13556
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
13557
13557
  if (typeof minimum === "number")
13558
13558
  json.minLength = minimum;
13559
13559
  if (typeof maximum === "number")
@@ -13568,8 +13568,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
13568
13568
  }
13569
13569
  if (contentEncoding)
13570
13570
  json.contentEncoding = contentEncoding;
13571
- if (patterns2 && patterns2.size > 0) {
13572
- const patternList = [...patterns2].map(exactPattern);
13571
+ if (patterns && patterns.size > 0) {
13572
+ const patternList = [...patterns].map(exactPattern);
13573
13573
  if (patternList.length === 1)
13574
13574
  json.pattern = patternList[0].source;
13575
13575
  else if (patternList.length > 1) {
@@ -13861,14 +13861,14 @@ var recordProcessor = (schema, ctx, _json, params) => {
13861
13861
  const def = schema._zod.def;
13862
13862
  json.type = "object";
13863
13863
  const keyType = def.keyType;
13864
- const patterns2 = aggregateChecks(keyType).patterns;
13865
- if (def.mode === "loose" && patterns2 && patterns2.size > 0) {
13864
+ const patterns = aggregateChecks(keyType).patterns;
13865
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
13866
13866
  const valueSchema = processSchema(def.valueType, ctx, {
13867
13867
  ...params,
13868
13868
  path: [...params.path, "patternProperties", "*"]
13869
13869
  });
13870
13870
  json.patternProperties = {};
13871
- for (const pattern of patterns2) {
13871
+ for (const pattern of patterns) {
13872
13872
  assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
13873
13873
  }
13874
13874
  } else {
@@ -18108,35 +18108,31 @@ async function undoChange(repo, store, changeId) {
18108
18108
  }
18109
18109
 
18110
18110
  // packages/core/src/symbols.ts
18111
- var KEYWORDS = "function\\*?|def|class|interface|type|enum|struct|trait|fn|func|const|let|var|val|module|impl|record|object|namespace|defn?|sub|proc";
18111
+ var KEYWORDS = "function\\*?|def|class|interface|type|enum|struct|trait|fn|fun|func|const|let|var|val|module|impl|record|object|namespace|protocol|extension|defn?|sub|proc";
18112
18112
  var WORD = "A-Za-z0-9_$";
18113
+ var SOURCE_EXTENSIONS = "js jsx mjs cjs ts tsx mts cts vue svelte py pyi rb php go rs java kt kts scala groovy swift m mm c h cc cpp cxx hpp hh cs fs dart ex exs erl clj cljs lua pl pm r jl sh bash zsh ps1 sql ds isml".split(" ");
18114
+ var SOURCE_PATHS = [...SOURCE_EXTENSIONS.map((extension2) => `*.${extension2}`), ":(exclude)*.min.js", ":(exclude)*.d.ts", ":(exclude)**/node_modules/**", ":(exclude)**/vendor/**", ":(exclude)**/dist/**"];
18115
+ var SEARCH_TIMEOUT_MS = 3e4;
18113
18116
  var MAX_HITS = 200;
18114
18117
  var MAX_LINE_CHARS = 240;
18115
- var escapeEre = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18116
- function patterns(name) {
18117
- return [
18118
- // "function name", "class Name", "def name", "const name" …
18119
- `(^|[^${WORD}])(${KEYWORDS})[[:space:]]+${name}([^${WORD}]|$)`,
18120
- // "name = function", "name: (a) =>", "name = async (" …
18121
- `(^|[^${WORD}.])${name}[[:space:]]*[:=][[:space:]]*(async[[:space:]]+)?(function|\\()`,
18122
- // Go methods: "func (r *T) name("
18123
- `func[[:space:]]+\\([^)]*\\)[[:space:]]+${name}[[:space:]]*\\(`,
18124
- // Methods in a class body: "name(args) {", "async name(", "public static name("
18125
- `^[[:space:]]+((public|private|protected|static|async|override|readonly|get|set)[[:space:]]+)*${name}[[:space:]]*\\([^;]*\\)[[:space:]]*(:[^;{]*)?\\{[[:space:]]*$`
18126
- ];
18127
- }
18128
18118
  var NAME_AFTER_KEYWORD = new RegExp(`(?:^|[^${WORD}])(${KEYWORDS})\\s+([A-Za-z_$][${WORD}]*)`);
18129
- var NAME_ASSIGNED = new RegExp(`([A-Za-z_$][${WORD}]*)\\s*[:=]\\s*(?:async\\s+)?(?:function|\\()`);
18119
+ var NAME_ASSIGNED = new RegExp(`(?:^|[^${WORD}.])([A-Za-z_$][${WORD}]*)\\s*=\\s*(?:async\\s+)?(?:function\\b|\\()`);
18120
+ var PROPERTY = new RegExp(`^\\s*([A-Za-z_$][${WORD}]*)\\s*:\\s*(?:async\\s+)?(?:function\\b|\\([^)]*\\)\\s*(?::[^=]*)?=>)`);
18130
18121
  var GO_METHOD = new RegExp(`func\\s+\\([^)]*\\)\\s+([A-Za-z_$][${WORD}]*)\\s*\\(`);
18131
- var METHOD = new RegExp(`^\\s+(?:(?:public|private|protected|static|async|override|readonly|get|set)\\s+)*([A-Za-z_$][${WORD}]*)\\s*\\(`);
18122
+ var METHOD = new RegExp(`^\\s+(?:(?:public|private|protected|static|async|override|readonly|get|set)\\s+)*([A-Za-z_$][${WORD}]*)\\s*\\([^;]*\\)\\s*(?::[^;{]*)?\\{\\s*$`);
18123
+ var TYPED = new RegExp(`^\\s*((?:[A-Za-z_][${WORD}<>,.:*&?\\s\\[\\]]*?))[\\s*&]+(?:[A-Za-z_][${WORD}]*::)?([A-Za-z_$][${WORD}]*)\\s*\\([^;]*$`);
18124
+ var NOT_TYPES = /(^|\s)(return|else|new|await|throw|case|typeof|delete|yield|in|of|if|while|for|switch|do|and|or|not|print|import|from|export\s+default|goto|using|echo)$/;
18132
18125
  var NOT_NAMES = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "catch", "return", "function", "else", "do", "try", "with", "new", "await", "typeof"]);
18133
18126
  function describe3(text, wanted) {
18134
18127
  const candidates = [
18135
18128
  { name: GO_METHOD.exec(text)?.[1], kind: "method" },
18136
18129
  { name: NAME_AFTER_KEYWORD.exec(text)?.[2], kind: (NAME_AFTER_KEYWORD.exec(text)?.[1] ?? "").replace("*", "") },
18137
18130
  { name: NAME_ASSIGNED.exec(text)?.[1], kind: "function" },
18131
+ { name: PROPERTY.exec(text)?.[1], kind: "property" },
18138
18132
  { name: METHOD.exec(text)?.[1], kind: "method" }
18139
18133
  ];
18134
+ const typed = TYPED.exec(text);
18135
+ if (typed && typed[1] !== void 0 && !NOT_TYPES.test(typed[1].trim()) && !new RegExp(`^(${KEYWORDS})$`).test(typed[1].trim())) candidates.push({ name: typed[2], kind: "function" });
18140
18136
  const found = candidates.filter((candidate) => candidate.name !== void 0 && !NOT_NAMES.has(candidate.name));
18141
18137
  return found.find((candidate) => wanted(candidate.name));
18142
18138
  }
@@ -18145,13 +18141,9 @@ async function findSymbols(repo, { rev, query, exact = false }) {
18145
18141
  throw new AppError("invalid_request", exact ? "That is not a name" : "Type at least two letters of a name");
18146
18142
  }
18147
18143
  if (rev !== WORKTREE && rev !== STAGED && !/^[0-9a-f]{40,64}$/.test(rev)) throw new AppError("invalid_request", '"rev" must be a commit id, :worktree or :staged');
18148
- const name = exact ? escapeEre(query) : `[${WORD}]*${escapeEre(query)}[${WORD}]*`;
18149
- const args = ["grep", "-n", "-z", "-I", "-E", "--no-color", "--full-name", ...exact ? [] : ["-i"]];
18150
- for (const pattern of patterns(name)) args.push("-e", pattern);
18151
- if (rev === STAGED) args.push("--cached");
18152
- else if (rev !== WORKTREE) args.push(rev);
18153
- args.push("--");
18154
- const { stdout } = await runGit(args, { cwd: repo.root, allowExitCodes: [1], timeoutMs: 15e3 });
18144
+ const where = rev === STAGED ? ["--cached"] : rev === WORKTREE ? [] : [rev];
18145
+ const options = { cwd: repo.root, allowExitCodes: [1], timeoutMs: SEARCH_TIMEOUT_MS };
18146
+ const { stdout } = await runGit(["grep", "-n", "-z", "-I", "-F", "--no-color", "--full-name", ...exact ? ["-w"] : ["-i"], "-e", query, ...where, "--", ...SOURCE_PATHS], options);
18155
18147
  const lower = query.toLowerCase();
18156
18148
  const wanted = (candidate) => exact ? candidate === query : candidate.toLowerCase().includes(lower);
18157
18149
  const hits = [];
@@ -18159,12 +18151,16 @@ async function findSymbols(repo, { rev, query, exact = false }) {
18159
18151
  const [file, lineText, ...rest] = record2.split("\0");
18160
18152
  if (file === void 0 || lineText === void 0 || rest.length === 0) continue;
18161
18153
  const text = rest.join("\0");
18154
+ if (/^\s*(\/\/|\/\*|\*|#|--|<!--)/.test(text)) continue;
18162
18155
  const found = describe3(text, wanted);
18163
18156
  if (!found) continue;
18157
+ const local = /^(const|let|var|val)$/.test(found.kind) && /^\s/.test(text) && !/[:=]\s*(async\s+)?(function\b|\([^)]*\)\s*(:[^=]*)?=>|[A-Za-z_$][\w$]*\s*=>)/.test(text);
18158
+ if (local && !exact) continue;
18164
18159
  const path = rev !== WORKTREE && rev !== STAGED && file.startsWith(`${rev}:`) ? file.slice(rev.length + 1) : file;
18165
18160
  hits.push({ path, line: Number(lineText), text: text.trim().slice(0, MAX_LINE_CHARS), ...found });
18166
18161
  }
18167
- const rank = (hit) => (hit.name.toLowerCase() === lower ? 0 : hit.name.toLowerCase().startsWith(lower) ? 1 : 2) + (/(^|\/)(tests?|e2e|__tests__|fixtures?)\//.test(hit.path) || /\.(test|spec)\./.test(hit.path) ? 0.5 : 0);
18162
+ const rank = (hit) => (hit.name.toLowerCase() === lower ? 0 : hit.name.toLowerCase().startsWith(lower) ? 1 : 2) + // A property that holds a function is a definition of sorts, but rarely the one that was meant.
18163
+ (hit.kind === "property" ? 3 : 0) + (/(^|\/)(tests?|e2e|__tests__|fixtures?)\//.test(hit.path) || /\.(test|spec)\./.test(hit.path) ? 0.5 : 0);
18168
18164
  hits.sort((a, b) => rank(a) - rank(b) || a.path.localeCompare(b.path) || a.line - b.line);
18169
18165
  return { hits: hits.slice(0, MAX_HITS), truncated: hits.length > MAX_HITS };
18170
18166
  }
@@ -19597,7 +19593,7 @@ import { dirname as dirname7, join as join15 } from "node:path";
19597
19593
  import { fileURLToPath } from "node:url";
19598
19594
 
19599
19595
  // packages/cli/src/version.ts
19600
- var VERSION = true ? "0.1.1" : "0.0.0-dev";
19596
+ var VERSION = true ? "0.1.2" : "0.0.0-dev";
19601
19597
 
19602
19598
  // packages/cli/src/daemon.ts
19603
19599
  var CLI_FILE = fileURLToPath(import.meta.url);