@molecule/api-ai-tools 1.5.6 → 1.5.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AA2B9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAuCnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CA+8CxF"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AA2B9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAuCnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CAs+CxF"}
package/dist/tools.js CHANGED
@@ -103,9 +103,15 @@ export function buildTools(backend, config) {
103
103
  .run(command, { cwd: path.slice(0, path.lastIndexOf('/')) || '/', timeout: 15_000 })
104
104
  .catch(() => null);
105
105
  const problem = result ? parseCheckProblem(result) : null;
106
+ // JSX in a `.ts` file parses as a type assertion and fails on the first
107
+ // attribute — `Expected ">" but found "className"` — which does not say the
108
+ // file just needs to be `.tsx` (X1 flash-m28: three writes and 2.5 minutes).
109
+ const jsxInTs = problem !== null && /\.ts$/.test(path) && /Expected ">" but found|JSX/i.test(problem)
110
+ ? '\nThis looks like JSX in a `.ts` file: JSX only parses in a `.tsx` file — rename it (and its imports keep the `.js` extension).'
111
+ : '';
106
112
  return problem
107
113
  ? {
108
- syntaxError: `The file no longer parses after this change — fix it before anything else, every build and test fails until it does:\n${problem}`,
114
+ syntaxError: `The file no longer parses after this change — fix it before anything else, every build and test fails until it does:\n${problem}${jsxInTs}`,
109
115
  }
110
116
  : {};
111
117
  }
@@ -801,10 +807,23 @@ export function buildTools(backend, config) {
801
807
  }
802
808
  }
803
809
  const excerpt = renderEditExcerpt(finalContent, spans);
810
+ // A replacement whose old text ended in a newline and whose new text does not
811
+ // joins the line after it onto its last line. Applied as written, but said:
812
+ // flash-m28 saw two lines merged only one round trip later.
813
+ const joined = replacements.filter((r) => typeof r.old_string === 'string' &&
814
+ typeof r.new_string === 'string' &&
815
+ r.old_string.endsWith('\n') &&
816
+ r.new_string !== '' &&
817
+ !r.new_string.endsWith('\n')).length;
804
818
  return {
805
819
  path,
806
820
  ok: true,
807
821
  replacementsApplied: replacements.length - alreadyApplied,
822
+ ...(joined > 0
823
+ ? {
824
+ newlineNote: `${joined === 1 ? 'A replacement' : `${joined} replacements`} removed the line break after the replaced text (old_string ended with a newline, new_string does not), so the next line now continues on the same line. Check the excerpt; add the newline back if that was not intended.`,
825
+ }
826
+ : {}),
808
827
  ...(alreadyApplied > 0 ? { alreadyApplied, note: alreadyNote } : {}),
809
828
  totalLines: countLines(finalContent),
810
829
  ...(excerpt ? { excerpt: sanitizeFileContent(excerpt, path) } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-tools",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "Shared AI agent tools with backend abstraction for sandbox and local execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",