@attentionform/astra-mcp-server 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -387,6 +387,8 @@ Preflight read-only OOXML schema audit for a session before committing changes.
387
387
 
388
388
  **Returns:** `{ ok: true, sessionId, revision, dirty, validation: { valid, errorCount, errors } }`
389
389
 
390
+ Validation advice: when `validate_document` reports an invalid document, its `normalizeHint` suggests attempting `normalize_document` and validating again. This is advice, not a repair forecast or a guarantee of validity; validation does not run repair rules to generate the hint. Normalization changes the open session; use `save_document` to persist the result, optionally to a new output path.
391
+
390
392
  ---
391
393
 
392
394
  ### `get_stats`
package/dist/index.js CHANGED
@@ -34015,19 +34015,6 @@ async function repairDocxBuffer(input, options = {}) {
34015
34015
  }
34016
34016
  return { buffer: normalized.length > 0 ? pack(current) : input, normalized, remaining, rolledBack };
34017
34017
  }
34018
- async function forecastNormalize(input) {
34019
- try {
34020
- const outcome = await repairDocxBuffer(input);
34021
- if (outcome.normalized.length === 0) return void 0;
34022
- return { changes: outcome.normalized.length, remaining: outcome.remaining };
34023
- } catch {
34024
- return void 0;
34025
- }
34026
- }
34027
- function normalizeHintSentence(forecast, errorCount, how) {
34028
- const left = forecast.remaining === 0 ? "and the document then validates" : forecast.remaining > 0 ? `and leaves ${forecast.remaining} of ${errorCount} errors, which need Word` : "and the rest need Word";
34029
- return `${how} can repair some of these errors (${forecast.changes} change${forecast.changes === 1 ? "" : "s"}) ${left}.`;
34030
- }
34031
34018
 
34032
34019
  // ../engine/src/export/html.ts
34033
34020
  function asFootnoteZipCapable(parser2) {
@@ -42092,6 +42079,35 @@ var LEAN6_HANDLERS = {
42092
42079
 
42093
42080
  // src/tools/export.ts
42094
42081
  var import_zod6 = require("zod");
42082
+
42083
+ // src/lib/fork-numbering.ts
42084
+ function adoptForkNumbering(fork, ast) {
42085
+ const source = ast.numbering?.source;
42086
+ const cloneDefinitions = (definitions) => Object.fromEntries(
42087
+ Object.entries(definitions).map(([id, element]) => [id, element.cloneNode(true)])
42088
+ );
42089
+ fork.adoptAstForNumbering({
42090
+ numbering: {
42091
+ abstractNum: cloneDefinitions(ast.numbering?.abstractNum ?? {}),
42092
+ concreteNum: cloneDefinitions(ast.numbering?.concreteNum ?? {}),
42093
+ // Mirrors the NumberingSource clone in engine ast.ts (cloneAST); keep both
42094
+ // in step when NumberingSource gains fields.
42095
+ ...source ? {
42096
+ source: {
42097
+ ...source,
42098
+ rootAttributes: source.rootAttributes.map((attribute) => ({ ...attribute })),
42099
+ leading: [...source.leading],
42100
+ trailing: [...source.trailing]
42101
+ }
42102
+ } : {}
42103
+ },
42104
+ relationships: Object.fromEntries(
42105
+ Object.entries(ast.relationships ?? {}).map(([id, relationship]) => [id, { ...relationship }])
42106
+ )
42107
+ });
42108
+ }
42109
+
42110
+ // src/tools/export.ts
42095
42111
  var fs15 = __toESM(require("fs"));
42096
42112
  var fsp8 = __toESM(require("fs/promises"));
42097
42113
  var path16 = __toESM(require("path"));
@@ -42255,16 +42271,7 @@ function serializeSessionCopy(parser2, ast) {
42255
42271
  }
42256
42272
  const fork = new DocxParser(zip.toBuffer());
42257
42273
  try {
42258
- const live = ast;
42259
- if (live && typeof live === "object") {
42260
- fork.adoptAstForNumbering({
42261
- numbering: {
42262
- abstractNum: { ...live.numbering?.abstractNum ?? {} },
42263
- concreteNum: { ...live.numbering?.concreteNum ?? {} }
42264
- },
42265
- relationships: { ...live.relationships ?? {} }
42266
- });
42267
- }
42274
+ adoptForkNumbering(fork, ast);
42268
42275
  } catch {
42269
42276
  }
42270
42277
  return fork.rezip();
@@ -42658,16 +42665,7 @@ function serializeSessionCopy2(parser2, ast) {
42658
42665
  }
42659
42666
  const fork = new DocxParser(zip.toBuffer());
42660
42667
  try {
42661
- const live = ast;
42662
- if (live && typeof live === "object") {
42663
- fork.adoptAstForNumbering({
42664
- numbering: {
42665
- abstractNum: { ...live.numbering?.abstractNum ?? {} },
42666
- concreteNum: { ...live.numbering?.concreteNum ?? {} }
42667
- },
42668
- relationships: { ...live.relationships ?? {} }
42669
- });
42670
- }
42668
+ adoptForkNumbering(fork, ast);
42671
42669
  } catch {
42672
42670
  }
42673
42671
  return fork.rezip();
@@ -43025,16 +43023,7 @@ function serializeSessionFork(parser2, ast) {
43025
43023
  try {
43026
43024
  const fork = new DocxParser(staleBytes);
43027
43025
  try {
43028
- const live = ast;
43029
- if (live && typeof live === "object") {
43030
- fork.adoptAstForNumbering({
43031
- numbering: {
43032
- abstractNum: { ...live.numbering?.abstractNum ?? {} },
43033
- concreteNum: { ...live.numbering?.concreteNum ?? {} }
43034
- },
43035
- relationships: { ...live.relationships ?? {} }
43036
- });
43037
- }
43026
+ adoptForkNumbering(fork, ast);
43038
43027
  } catch {
43039
43028
  }
43040
43029
  return fork.rezip();
@@ -43061,15 +43050,9 @@ async function handleValidateDocument(store, input) {
43061
43050
  }
43062
43051
  try {
43063
43052
  return await store.withSession(parsed.data.sessionId, async (handle) => {
43064
- const { validation, buf } = await forkValidation(handle);
43053
+ const { validation } = await forkValidation(handle);
43065
43054
  const pendingNormalizations = readPendingNormalizations(handle);
43066
- let normalizeHint;
43067
- if (!validation.valid) {
43068
- const forecast = await forecastNormalize(buf);
43069
- if (forecast) {
43070
- normalizeHint = normalizeHintSentence(forecast, validation.errorCount, "Run normalize_document: it");
43071
- }
43072
- }
43055
+ const normalizeHint = validation.valid ? void 0 : "Call `normalize_document` to attempt the supported repairs, then call `validate_document` again.";
43073
43056
  return {
43074
43057
  ok: true,
43075
43058
  sessionId: handle.sessionId,
@@ -43421,7 +43404,7 @@ var import_zod9 = require("zod");
43421
43404
  // package.json
43422
43405
  var package_default = {
43423
43406
  name: "@attentionform/astra-mcp-server",
43424
- version: "0.2.0",
43407
+ version: "0.2.1",
43425
43408
  description: "Official Model Context Protocol (MCP) server for ASTra document IDE",
43426
43409
  main: "dist/index.js",
43427
43410
  types: "dist/index.d.ts",
@@ -43462,8 +43445,8 @@ var package_default = {
43462
43445
  "adm-zip-gate": "node ../../scripts/check-adm-zip-imports.mjs"
43463
43446
  },
43464
43447
  dependencies: {
43465
- "@attentionform/astra-engine": "^0.2.0",
43466
- "@attentionform/ooxml-validator": "^0.2.0",
43448
+ "@attentionform/astra-engine": "^0.2.1",
43449
+ "@attentionform/ooxml-validator": "^0.2.1",
43467
43450
  "@modelcontextprotocol/sdk": "^1.32.2",
43468
43451
  "@xmldom/xmldom": "0.8.15",
43469
43452
  "adm-zip": "0.6.1",
@@ -0,0 +1,10 @@
1
+ import { type DocumentAST, type DocxParser } from '@attentionform/astra-engine';
2
+ /**
3
+ * Give a serialization fork the live numbering, including its original part
4
+ * metadata. The engine uses the source hashes to retain untouched bytes and
5
+ * the root attributes/extra children when definitions really have changed.
6
+ * Clone every numbering element and source record so fork serialization cannot
7
+ * change the session. Pass only numbering/relationships on purpose: the bare
8
+ * rezip path reads only those fields and must not receive other live AST data.
9
+ */
10
+ export declare function adoptForkNumbering(fork: DocxParser, ast: DocumentAST): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attentionform/astra-mcp-server",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Official Model Context Protocol (MCP) server for ASTra document IDE",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,8 +41,8 @@
41
41
  "adm-zip-gate": "node ../../scripts/check-adm-zip-imports.mjs"
42
42
  },
43
43
  "dependencies": {
44
- "@attentionform/astra-engine": "^0.2.0",
45
- "@attentionform/ooxml-validator": "^0.2.0",
44
+ "@attentionform/astra-engine": "^0.2.1",
45
+ "@attentionform/ooxml-validator": "^0.2.1",
46
46
  "@modelcontextprotocol/sdk": "^1.32.2",
47
47
  "@xmldom/xmldom": "0.8.15",
48
48
  "adm-zip": "0.6.1",