gdharness 0.13.20 → 0.13.21

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/build/cli.js CHANGED
@@ -7591,6 +7591,15 @@ function unloadedTypes(messages, declared, cached) {
7591
7591
  }
7592
7592
  return found;
7593
7593
  }
7594
+ function classesNamedIn(source, known) {
7595
+ const named = new Set;
7596
+ for (const [word] of source.matchAll(/\b[A-Z][A-Za-z0-9_]*\b/g)) {
7597
+ if (known.has(word)) {
7598
+ named.add(word);
7599
+ }
7600
+ }
7601
+ return [...named].sort();
7602
+ }
7594
7603
  function contradictedDiagnostics(messages, classes, sourceOf) {
7595
7604
  const read = new Map;
7596
7605
  const found = [];
@@ -38105,7 +38114,19 @@ class GodotServer {
38105
38114
  const unloaded = messages.some((message) => unknownTypeIn(message) !== null) ? unloadedTypes(messages, declaredClasses(projectPath), cached) : [];
38106
38115
  const notes = [];
38107
38116
  if (contradicted.length > 0) {
38108
- notes.push(`The editor is reporting against an older copy of ${contradicted.length === 1 ? "a type" : "some types"} named under contradictedByTheFile. Each member listed is declared in the file the class cache points at, so those diagnostics are wrong however the code is written. Try editor_rescan first: it costs about half a second and cleared this in one of five measured attempts. If it does not, changing anything the named type itself depends on and rescanning again cleared it on the one occasion that has been tried. editor_launch restart is the only remedy that has always worked, and is the one to reach for when the count above is not good enough odds. project_import refresh_classes does not, and answers added: [] while this is happening.`);
38117
+ const dependsOn = new Set;
38118
+ for (const one of contradicted) {
38119
+ const source = cached === null ? null : this.sourceOfClass(projectPath, one.declaredIn);
38120
+ if (source === null || cached === null) {
38121
+ continue;
38122
+ }
38123
+ for (const name of classesNamedIn(source, cached)) {
38124
+ if (name !== one.type) {
38125
+ dependsOn.add(name);
38126
+ }
38127
+ }
38128
+ }
38129
+ notes.push(`The editor is reporting against an older copy of ${contradicted.length === 1 ? "a type" : "some types"} named under contradictedByTheFile. Each member listed is declared in the file the class cache points at, so those diagnostics are wrong however the code is written. Try editor_rescan first: it costs about half a second and cleared this in one of five measured attempts. If it does not, the lever is that a held type is refreshed when something it depends on changes rather than when it changes itself${dependsOn.size === 0 ? ", though the named types depend on no other global class, which leaves only the restart" : `, so change ${[...dependsOn].sort().join(", ")} and rescan again`}. editor_launch restart is the only remedy that has always worked, and is the one to reach for when the count above is not good enough odds. project_import refresh_classes does not, and answers added: [] while this is happening.`);
38109
38130
  }
38110
38131
  const uncached = unloaded.filter((type) => !type.inTheClassCache);
38111
38132
  if (uncached.length > 0) {
@@ -38121,6 +38142,17 @@ class GodotServer {
38121
38142
  ...notes.length === 0 ? {} : { staleAnalysis: notes.join(" ") }
38122
38143
  };
38123
38144
  }
38145
+ sourceOfClass(projectPath, resourcePath) {
38146
+ const contained = resolveWithinProject(projectPath, resourcePath);
38147
+ if (!contained.ok || !existsSync14(contained.absolutePath)) {
38148
+ return null;
38149
+ }
38150
+ try {
38151
+ return readFileSync15(contained.absolutePath, "utf8");
38152
+ } catch {
38153
+ return null;
38154
+ }
38155
+ }
38124
38156
  async handleLSP(toolName, args) {
38125
38157
  const port = this.editorServes("lspPort", "GDHARNESS_LSP_PORT", DEFAULT_LSP_PORT);
38126
38158
  if (this.lspClient !== null && this.lspClient.port !== port) {
package/build/index.js CHANGED
@@ -24851,6 +24851,15 @@ function unloadedTypes(messages, declared, cached) {
24851
24851
  }
24852
24852
  return found;
24853
24853
  }
24854
+ function classesNamedIn(source, known) {
24855
+ const named = new Set;
24856
+ for (const [word] of source.matchAll(/\b[A-Z][A-Za-z0-9_]*\b/g)) {
24857
+ if (known.has(word)) {
24858
+ named.add(word);
24859
+ }
24860
+ }
24861
+ return [...named].sort();
24862
+ }
24854
24863
  function contradictedDiagnostics(messages, classes, sourceOf) {
24855
24864
  const read = new Map;
24856
24865
  const found = [];
@@ -30857,7 +30866,19 @@ class GodotServer {
30857
30866
  const unloaded = messages.some((message) => unknownTypeIn(message) !== null) ? unloadedTypes(messages, declaredClasses(projectPath), cached) : [];
30858
30867
  const notes = [];
30859
30868
  if (contradicted.length > 0) {
30860
- notes.push(`The editor is reporting against an older copy of ${contradicted.length === 1 ? "a type" : "some types"} named under contradictedByTheFile. Each member listed is declared in the file the class cache points at, so those diagnostics are wrong however the code is written. Try editor_rescan first: it costs about half a second and cleared this in one of five measured attempts. If it does not, changing anything the named type itself depends on and rescanning again cleared it on the one occasion that has been tried. editor_launch restart is the only remedy that has always worked, and is the one to reach for when the count above is not good enough odds. project_import refresh_classes does not, and answers added: [] while this is happening.`);
30869
+ const dependsOn = new Set;
30870
+ for (const one of contradicted) {
30871
+ const source = cached === null ? null : this.sourceOfClass(projectPath, one.declaredIn);
30872
+ if (source === null || cached === null) {
30873
+ continue;
30874
+ }
30875
+ for (const name of classesNamedIn(source, cached)) {
30876
+ if (name !== one.type) {
30877
+ dependsOn.add(name);
30878
+ }
30879
+ }
30880
+ }
30881
+ notes.push(`The editor is reporting against an older copy of ${contradicted.length === 1 ? "a type" : "some types"} named under contradictedByTheFile. Each member listed is declared in the file the class cache points at, so those diagnostics are wrong however the code is written. Try editor_rescan first: it costs about half a second and cleared this in one of five measured attempts. If it does not, the lever is that a held type is refreshed when something it depends on changes rather than when it changes itself${dependsOn.size === 0 ? ", though the named types depend on no other global class, which leaves only the restart" : `, so change ${[...dependsOn].sort().join(", ")} and rescan again`}. editor_launch restart is the only remedy that has always worked, and is the one to reach for when the count above is not good enough odds. project_import refresh_classes does not, and answers added: [] while this is happening.`);
30861
30882
  }
30862
30883
  const uncached = unloaded.filter((type) => !type.inTheClassCache);
30863
30884
  if (uncached.length > 0) {
@@ -30873,6 +30894,17 @@ class GodotServer {
30873
30894
  ...notes.length === 0 ? {} : { staleAnalysis: notes.join(" ") }
30874
30895
  };
30875
30896
  }
30897
+ sourceOfClass(projectPath, resourcePath) {
30898
+ const contained = resolveWithinProject(projectPath, resourcePath);
30899
+ if (!contained.ok || !existsSync9(contained.absolutePath)) {
30900
+ return null;
30901
+ }
30902
+ try {
30903
+ return readFileSync11(contained.absolutePath, "utf8");
30904
+ } catch {
30905
+ return null;
30906
+ }
30907
+ }
30876
30908
  async handleLSP(toolName, args) {
30877
30909
  const port = this.editorServes("lspPort", "GDHARNESS_LSP_PORT", DEFAULT_LSP_PORT);
30878
30910
  if (this.lspClient !== null && this.lspClient.port !== port) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdharness",
3
- "version": "0.13.20",
3
+ "version": "0.13.21",
4
4
  "mcpName": "io.github.Aureliolo/gdharness",
5
5
  "description": "A harness for driving a Godot 4 project from an agent: editor addons, a runtime bridge into the running game, an MCP server in front of them, and a CLI that installs and diagnoses the Godot side.",
6
6
  "type": "module",