@velvetmonkey/flywheel-crank 0.9.0 → 0.10.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.
Files changed (2) hide show
  1. package/dist/index.js +14 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -162,8 +162,8 @@ function formatContent(content, format) {
162
162
  return trimmed;
163
163
  }
164
164
  }
165
- function detectListIndentation(lines, insertLineIndex, sectionStartLine) {
166
- for (let i = insertLineIndex - 1; i >= sectionStartLine; i--) {
165
+ function detectSectionBaseIndentation(lines, sectionStartLine, sectionEndLine) {
166
+ for (let i = sectionStartLine; i <= sectionEndLine; i++) {
167
167
  const line = lines[i];
168
168
  const trimmed = line.trim();
169
169
  if (trimmed === "")
@@ -173,7 +173,7 @@ function detectListIndentation(lines, insertLineIndex, sectionStartLine) {
173
173
  const indent = listMatch[1] || listMatch[2] || listMatch[3] || "";
174
174
  return indent;
175
175
  }
176
- if (trimmed.match(/^#+\s/)) {
176
+ if (i > sectionStartLine && trimmed.match(/^#+\s/)) {
177
177
  break;
178
178
  }
179
179
  }
@@ -216,7 +216,7 @@ function insertInSection(content, section, newContent, position, options) {
216
216
  }
217
217
  if (lastContentLineIdx >= section.contentStartLine && isEmptyPlaceholder(lines[lastContentLineIdx])) {
218
218
  if (options?.preserveListNesting) {
219
- const indent = detectListIndentation(lines, lastContentLineIdx, section.contentStartLine);
219
+ const indent = detectSectionBaseIndentation(lines, section.contentStartLine, section.endLine);
220
220
  const indentedContent = formattedContent.split("\n").map((line) => indent + line).join("\n");
221
221
  lines[lastContentLineIdx] = indentedContent;
222
222
  } else {
@@ -235,7 +235,7 @@ function insertInSection(content, section, newContent, position, options) {
235
235
  insertLine = section.contentStartLine;
236
236
  }
237
237
  if (options?.preserveListNesting) {
238
- const indent = detectListIndentation(lines, insertLine, section.contentStartLine);
238
+ const indent = detectSectionBaseIndentation(lines, section.contentStartLine, section.endLine);
239
239
  const indentedContent = formattedContent.split("\n").map((line) => indent + line).join("\n");
240
240
  lines.splice(insertLine, 0, indentedContent);
241
241
  } else {
@@ -1582,6 +1582,7 @@ var STRICTNESS_CONFIGS = {
1582
1582
  var DEFAULT_STRICTNESS = "conservative";
1583
1583
  var MIN_SUGGESTION_SCORE = STRICTNESS_CONFIGS.balanced.minSuggestionScore;
1584
1584
  var MIN_MATCH_RATIO = STRICTNESS_CONFIGS.balanced.minMatchRatio;
1585
+ var FULL_ALIAS_MATCH_BONUS = 8;
1585
1586
  function scoreNameAgainstContent(name, contentTokens, contentStems, config) {
1586
1587
  const nameTokens = tokenize(name);
1587
1588
  if (nameTokens.length === 0) {
@@ -1617,9 +1618,16 @@ function scoreEntity(entity, contentTokens, contentStems, config) {
1617
1618
  }
1618
1619
  }
1619
1620
  const bestResult = nameResult.score >= bestAliasResult.score ? nameResult : bestAliasResult;
1620
- const { score, matchedWords, exactMatches, totalTokens } = bestResult;
1621
+ let { score, matchedWords, exactMatches, totalTokens } = bestResult;
1621
1622
  if (totalTokens === 0)
1622
1623
  return 0;
1624
+ for (const alias of aliases) {
1625
+ const aliasLower = alias.toLowerCase();
1626
+ if (aliasLower.length >= 4 && !/\s/.test(aliasLower) && contentTokens.has(aliasLower)) {
1627
+ score += FULL_ALIAS_MATCH_BONUS;
1628
+ break;
1629
+ }
1630
+ }
1623
1631
  if (totalTokens > 1) {
1624
1632
  const matchRatio = matchedWords / totalTokens;
1625
1633
  if (matchRatio < config.minMatchRatio) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velvetmonkey/flywheel-crank",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Deterministic vault mutations for Obsidian via MCP",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",