@memoarchitect/tools 0.15.3 → 0.16.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.
Files changed (34) hide show
  1. package/README.md +2 -2
  2. package/package.json +2 -2
  3. package/packages/tools/lib/bin/memo.js +4 -0
  4. package/packages/tools/lib/bin/memo.js.map +1 -1
  5. package/packages/tools/lib/cli/project-commands.d.ts.map +1 -1
  6. package/packages/tools/lib/cli/project-commands.js +22 -2
  7. package/packages/tools/lib/cli/project-commands.js.map +1 -1
  8. package/packages/tools/lib/commands/init.d.ts +0 -10
  9. package/packages/tools/lib/commands/init.d.ts.map +1 -1
  10. package/packages/tools/lib/commands/init.js +3 -88
  11. package/packages/tools/lib/commands/init.js.map +1 -1
  12. package/packages/tools/lib/commands/upgrade.d.ts +16 -0
  13. package/packages/tools/lib/commands/upgrade.d.ts.map +1 -0
  14. package/packages/tools/lib/commands/upgrade.js +105 -0
  15. package/packages/tools/lib/commands/upgrade.js.map +1 -0
  16. package/packages/tools/lib/pin-check.d.ts +15 -0
  17. package/packages/tools/lib/pin-check.d.ts.map +1 -0
  18. package/packages/tools/lib/pin-check.js +78 -0
  19. package/packages/tools/lib/pin-check.js.map +1 -0
  20. package/packages/tools/lib/server/view-writer.d.ts.map +1 -1
  21. package/packages/tools/lib/server/view-writer.js +5 -2
  22. package/packages/tools/lib/server/view-writer.js.map +1 -1
  23. package/packages/tools/lib/stage2/package-metadata-from-api.d.ts +5 -0
  24. package/packages/tools/lib/stage2/package-metadata-from-api.d.ts.map +1 -1
  25. package/packages/tools/lib/stage2/package-metadata-from-api.js +8 -1
  26. package/packages/tools/lib/stage2/package-metadata-from-api.js.map +1 -1
  27. package/packages/tools/lib/toolchain/providers/syside-python.d.ts.map +1 -1
  28. package/packages/tools/lib/toolchain/providers/syside-python.js +3 -0
  29. package/packages/tools/lib/toolchain/providers/syside-python.js.map +1 -1
  30. package/packages/tools/lib/toolchain/providers/syside.d.ts +12 -2
  31. package/packages/tools/lib/toolchain/providers/syside.d.ts.map +1 -1
  32. package/packages/tools/lib/toolchain/providers/syside.js +20 -6
  33. package/packages/tools/lib/toolchain/providers/syside.js.map +1 -1
  34. package/packages/tools/python/memo_stage1_syside.py +40 -10
@@ -33,6 +33,7 @@ alone, `diagnostics` of the libraries and the project), with `"library":
33
33
  from __future__ import annotations
34
34
 
35
35
  import argparse
36
+ import contextlib
36
37
  import json
37
38
  import os
38
39
  import re
@@ -94,10 +95,16 @@ def classify(project_root: Path, library_roots: list[Path], files: list[str] | N
94
95
 
95
96
  def reported(diagnostics) -> list[dict]:
96
97
  out = []
97
- for diagnostic in diagnostics.all:
98
- # The full message is what `syside check` prints: the snippet with its
99
- # carets (the span's width) and any related note. Colour is stripped.
100
- text = ANSI.sub("", diagnostic.full_message).rstrip()
98
+ for item in diagnostics.all:
99
+ # SysIDE 1.0 yields (document url, diagnostic) pairs and has no
100
+ # `full_message`; 0.10 yields the diagnostic alone.
101
+ url, diagnostic = item if isinstance(item, tuple) else (None, item)
102
+ if hasattr(diagnostic, "full_message"):
103
+ # The full message is what `syside check` prints: the snippet with its
104
+ # carets (the span's width) and any related note. Colour is stripped.
105
+ text = ANSI.sub("", diagnostic.full_message).rstrip()
106
+ else:
107
+ text = f"{url}:{diagnostic.line}:{diagnostic.col}: {severity_of(diagnostic)} ({diagnostic.code}): {diagnostic.message}"
101
108
  out.append({"severity": severity_of(diagnostic), "text": text})
102
109
  return out
103
110
 
@@ -147,6 +154,29 @@ def base_of(path: Path, role: str, project_root: Path, library_roots: list[Path]
147
154
  (root for root in library_roots if root in path.parents), path.parent)
148
155
 
149
156
 
157
+ def user_documents(model):
158
+ """The model's own documents. SysIDE 1.0 calls them `documents` and hands
159
+ them over already locked; 0.10 kept them as `user_docs`, locked by the caller."""
160
+ return model.user_docs if hasattr(model, "user_docs") else model.documents
161
+
162
+
163
+ def standard_documents(model):
164
+ """The standard library's documents: `stdlib_docs` up to SysIDE 0.10, the
165
+ model's environment's `documents` from 1.0."""
166
+ return model.stdlib_docs if hasattr(model, "stdlib_docs") else model.environment.documents
167
+
168
+
169
+ @contextlib.contextmanager
170
+ def opened(shared):
171
+ """A document to read: locked for the caller on 0.10 (`SharedMutex`), already
172
+ a `Document` on 1.0."""
173
+ if hasattr(shared, "lock"):
174
+ with shared.lock() as document:
175
+ yield document
176
+ else:
177
+ yield shared
178
+
179
+
150
180
  def export(model, files: list[Path], role: str, project_root: Path, library_roots: list[Path],
151
181
  standard: dict[str, str | None], carried: frozenset[str] = frozenset()):
152
182
  """The API JSON of the model's documents among `files`, all of one role,
@@ -157,8 +187,8 @@ def export(model, files: list[Path], role: str, project_root: Path, library_root
157
187
  referenced: set[str] = set()
158
188
  documents = []
159
189
  index: dict[str, dict] = {}
160
- for shared in model.user_docs:
161
- with shared.lock() as document:
190
+ for shared in user_documents(model):
191
+ with opened(shared) as document:
162
192
  path = Path(document.url.path).resolve()
163
193
  if str(path) not in wanted_files:
164
194
  continue
@@ -174,8 +204,8 @@ def standard_names(model) -> dict[str, str | None]:
174
204
  """Each standard library element's qualified name (None for an unnamed one),
175
205
  by id: read once, since walking the library is most of an export's cost."""
176
206
  names: dict[str, str | None] = {}
177
- for shared in model.stdlib_docs:
178
- with shared.lock() as document:
207
+ for shared in standard_documents(model):
208
+ with opened(shared) as document:
179
209
  for element in document.all_nodes(syside.Element):
180
210
  qualified = element.qualified_name
181
211
  names[str(element.element_id)] = str(qualified) if qualified else None
@@ -307,8 +337,8 @@ class Project:
307
337
  if not reusable:
308
338
  self.exported = {}
309
339
  sent: set[str] = set()
310
- for shared in model.user_docs:
311
- with shared.lock() as document:
340
+ for shared in user_documents(model):
341
+ with opened(shared) as document:
312
342
  path = str(Path(document.url.path).resolve())
313
343
  if path not in texts:
314
344
  continue