semantic-js-mcp 0.10.2 → 0.10.4

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/scripts/smoke.mjs CHANGED
@@ -9,6 +9,7 @@ import {Client} from "@modelcontextprotocol/sdk/client/index.js";
9
9
  import {StdioClientTransport} from "@modelcontextprotocol/sdk/client/stdio.js";
10
10
  import {parse as parseYaml} from "yaml";
11
11
  import {fileIdentity, locationKey, locationKeyAt, locationKeyForOperatingSystem} from "../lib/file-identity.mjs";
12
+ import {diagnosticUseSummary} from "../lib/diagnostic-evidence.mjs";
12
13
  import {removeTemporaryDirectory} from "../lib/temporary-directory.mjs";
13
14
  import {
14
15
  ACCOUNTING_STATUS,
@@ -22,6 +23,7 @@ import {
22
23
  DIAGNOSTIC_REGION,
23
24
  EVIDENCE_STATUS,
24
25
  DIAGNOSTIC_FRESHNESS,
26
+ DIAGNOSTIC_GUIDANCE,
25
27
  ENVIRONMENT_VARIABLE,
26
28
  ERROR_CODE,
27
29
  FINGERPRINT_FORMAT,
@@ -49,6 +51,35 @@ function assert(condition, message) {
49
51
  if (!condition) throw new Error(message);
50
52
  }
51
53
 
54
+ const unversionedDiagnosticUse = diagnosticUseSummary({versionConfirmed: false, reportReceived: true});
55
+ deepStrictEqual(
56
+ unversionedDiagnosticUse,
57
+ {
58
+ currentDocumentDiagnosticsAvailable: false,
59
+ unconfirmedDiagnosticReportAvailable: true,
60
+ usableAsCurrentDocumentDiagnosticEvidence: false,
61
+ guidance: DIAGNOSTIC_GUIDANCE.UNCONFIRMED_DIAGNOSTIC_REPORT_AVAILABLE,
62
+ },
63
+ "Unversioned diagnostic reports did not remain context-only",
64
+ );
65
+ const unavailableDiagnosticUse = diagnosticUseSummary({versionConfirmed: false, reportReceived: false});
66
+ deepStrictEqual(
67
+ unavailableDiagnosticUse,
68
+ {
69
+ currentDocumentDiagnosticsAvailable: false,
70
+ unconfirmedDiagnosticReportAvailable: false,
71
+ usableAsCurrentDocumentDiagnosticEvidence: false,
72
+ guidance: DIAGNOSTIC_GUIDANCE.CURRENT_DOCUMENT_DIAGNOSTICS_UNAVAILABLE,
73
+ },
74
+ "Missing current-document reports did not remain unavailable as validation",
75
+ );
76
+
77
+ function assertDiagnosticUse(result, message) {
78
+ const versionConfirmed = result.evidence.status === EVIDENCE_STATUS.VERIFIED;
79
+ const reportReceived = versionConfirmed || result.unconfirmedDiagnosticReport?.reportReceived === true;
80
+ deepStrictEqual(result.diagnosticUse, diagnosticUseSummary({versionConfirmed, reportReceived}), message);
81
+ }
82
+
52
83
  const windowsLocation = {
53
84
  file: "C:\\Repository\\src\\Example.ts",
54
85
  range: {start: {line: 2, column: 17}},
@@ -396,6 +427,7 @@ try {
396
427
  "Concurrent diagnostics disagreed about snapshot evidence",
397
428
  );
398
429
  const initialDiagnosticsVerified = initialDiagnostics.result.evidence.status === EVIDENCE_STATUS.VERIFIED;
430
+ assertDiagnosticUse(initialDiagnostics.result, "Initial diagnostics returned inconsistent usage guidance");
399
431
  assert(
400
432
  initialDiagnostics.collection.status === (initialDiagnosticsVerified ? COLLECTION_STATUS.COMPLETE : COLLECTION_STATUS.PARTIAL),
401
433
  "Diagnostics evidence status and collection status disagree",
@@ -411,6 +443,18 @@ try {
411
443
  );
412
444
  if (!initialDiagnosticsVerified) {
413
445
  assert(initialDiagnostics.result.unconfirmedDiagnosticReport, "Untrusted diagnostics omitted their separated report");
446
+ if (initialDiagnostics.result.evidence.reason === DIAGNOSTIC_EVIDENCE_REASON.LANGUAGE_SERVER_VERSION_NOT_REPORTED) {
447
+ assert(
448
+ initialDiagnostics.result.diagnosticUse.unconfirmedDiagnosticReportAvailable === true,
449
+ "Unversioned diagnostics did not expose their unconfirmed report",
450
+ );
451
+ }
452
+ if (initialDiagnostics.result.evidence.reason === DIAGNOSTIC_EVIDENCE_REASON.LANGUAGE_SERVER_DID_NOT_REPORT_CURRENT_DOCUMENT) {
453
+ assert(
454
+ initialDiagnostics.result.diagnosticUse.unconfirmedDiagnosticReportAvailable === false,
455
+ "Missing diagnostics claimed that an unconfirmed report was available",
456
+ );
457
+ }
414
458
  }
415
459
 
416
460
  const textCount = assertResult(
@@ -850,6 +894,7 @@ try {
850
894
  ].join("\n"),
851
895
  );
852
896
  const supersededDiagnostics = assertResult(await supersededDiagnosticsPromise, TOOL.DIAGNOSTICS);
897
+ assertDiagnosticUse(supersededDiagnostics.result, "Superseded diagnostics returned inconsistent usage guidance");
853
898
  assert(
854
899
  supersededDiagnostics.result.evidence.status === EVIDENCE_STATUS.UNTRUSTED,
855
900
  "Diagnostics trusted content that changed during acquisition",
@@ -864,6 +909,7 @@ try {
864
909
  ]);
865
910
  const changedDiagnostics = assertResult(changedDiagnosticsResponse, TOOL.DIAGNOSTICS);
866
911
  const concurrentChangedDiagnostics = assertResult(concurrentChangedDiagnosticsResponse, TOOL.DIAGNOSTICS);
912
+ assertDiagnosticUse(changedDiagnostics.result, "Changed diagnostics returned inconsistent usage guidance");
867
913
  deepStrictEqual(
868
914
  concurrentChangedDiagnostics.result.document,
869
915
  changedDiagnostics.result.document,
@@ -930,6 +976,7 @@ try {
930
976
  declarationExclusionAccounting: "ok",
931
977
  nodeModuleExtensions: "ok",
932
978
  diagnosticVersionReporting: "ok",
979
+ actionableDiagnosticUse: "ok",
933
980
  sharedDiagnosticAcquisition: "ok",
934
981
  diagnosticContentFreshness: "ok",
935
982
  diagnosticProvenance: "ok",
@@ -15,6 +15,7 @@ import {
15
15
  DEFINITION_RESOLUTION_METHOD,
16
16
  DEFINITION_SELECTION_STATUS,
17
17
  DIAGNOSTIC_EVIDENCE_REASON,
18
+ DIAGNOSTIC_GUIDANCE,
18
19
  DIAGNOSTIC_LANGUAGE,
19
20
  DIAGNOSTIC_PROVIDER,
20
21
  DIAGNOSTIC_REGION,
@@ -159,6 +160,16 @@ try {
159
160
  ) {
160
161
  throw new Error("Vue diagnostic pull omitted its snapshot-confirmation reason");
161
162
  }
163
+ deepStrictEqual(
164
+ vueDiagnosticsResponse.structuredContent?.result?.diagnosticUse,
165
+ {
166
+ currentDocumentDiagnosticsAvailable: true,
167
+ unconfirmedDiagnosticReportAvailable: false,
168
+ usableAsCurrentDocumentDiagnosticEvidence: true,
169
+ guidance: DIAGNOSTIC_GUIDANCE.CURRENT_DOCUMENT_DIAGNOSTICS_AVAILABLE,
170
+ },
171
+ "Vue diagnostic pull returned inconsistent usage guidance",
172
+ );
162
173
  const provenanceDiagnostics = await client.callTool({
163
174
  name: TOOL.DIAGNOSTICS,
164
175
  arguments: {file: diagnosticComponent, root: workspace},
package/server.mjs CHANGED
@@ -12,6 +12,7 @@ import * as z from "zod/v4";
12
12
  import {stringify as stringifyYaml} from "yaml";
13
13
  import {PACKAGE_ROOT, inspectRuntimeComponents, resolveRuntimeComponent, runtimeDependencyRoot} from "./lib/runtime.mjs";
14
14
  import {fileIdentity, locationKey, locationKeyAt} from "./lib/file-identity.mjs";
15
+ import {diagnosticUseSummary} from "./lib/diagnostic-evidence.mjs";
15
16
  import {isNamedSymbolTool, namedSemanticEvidence, namedSemanticEvidenceMatches} from "./lib/semantic-evidence.mjs";
16
17
  import {PendingRequestRegistry} from "./lib/pending-requests.mjs";
17
18
  import {collectStableSnapshot} from "./lib/stable-collection.mjs";
@@ -29,6 +30,7 @@ import {
29
30
  DIAGNOSTIC_LANGUAGE,
30
31
  DIAGNOSTIC_PROVIDER,
31
32
  DIAGNOSTIC_REGION,
33
+ DIAGNOSTIC_RESULT_FIELD,
32
34
  DIAGNOSTIC_SEVERITY,
33
35
  EVIDENCE_STATUS,
34
36
  ENVIRONMENT_VARIABLE,
@@ -2682,6 +2684,7 @@ server.registerTool(
2682
2684
  return toolResult(tool, {
2683
2685
  request: {file: context.file, searchScope: SEARCH_SCOPE.DOCUMENT, resultLimit: normalizedLimit(maxResults)},
2684
2686
  result: {
2687
+ [DIAGNOSTIC_RESULT_FIELD.DIAGNOSTIC_USE]: diagnosticUseSummary({versionConfirmed, reportReceived: report.reportReceived}),
2685
2688
  provenance: {provider: provenance.provider, documentLanguage: provenance.documentLanguage},
2686
2689
  evidence: {
2687
2690
  status: versionConfirmed ? EVIDENCE_STATUS.VERIFIED : EVIDENCE_STATUS.UNTRUSTED,
@@ -2691,10 +2694,11 @@ server.registerTool(
2691
2694
  version: report.documentVersion,
2692
2695
  contentFingerprint: publicContentFingerprint(report.documentContentFingerprint),
2693
2696
  },
2694
- diagnosticsForCurrentDocument: versionConfirmed ? diagnosticReport : null,
2695
- unconfirmedDiagnosticReport: versionConfirmed
2697
+ [DIAGNOSTIC_RESULT_FIELD.DIAGNOSTICS_FOR_CURRENT_DOCUMENT]: versionConfirmed ? diagnosticReport : null,
2698
+ [DIAGNOSTIC_RESULT_FIELD.UNCONFIRMED_DIAGNOSTIC_REPORT]: versionConfirmed
2696
2699
  ? undefined
2697
2700
  : {
2701
+ [DIAGNOSTIC_RESULT_FIELD.REPORT_RECEIVED]: report.reportReceived,
2698
2702
  ...diagnosticReport,
2699
2703
  languageServerReportedDocumentVersion: report.reportedDocumentVersion,
2700
2704
  freshness: report.freshness,
@@ -101,7 +101,9 @@ Use the reported `referenceSetId` with `lsp_unresolved_reference_page` when unre
101
101
 
102
102
  Reference collections include `collection.contentFreshness: verified-current-file-content` and `collection.repositoryInventoryFreshness: verified-current-repository-source-inventory`. `lsp_reference_page` verifies direct content hashes plus the repository source inventory before returning a page. This detects new, deleted, renamed, and normally modified source files. A change returns `error.code: REFERENCE_SET_CONTENT_CHANGED`; an expired or evicted set returns `REFERENCE_SET_NOT_FOUND_OR_EXPIRED`. Call `lsp_references` to create a current set. `REPOSITORY_CHANGED_DURING_COLLECTION` means edits did not settle during the collection attempts.
103
103
 
104
- Diagnostics identify the analyzed document with a version and SHA-256 fingerprint. Treat only `result.evidence.status: verified` and a non-null `diagnosticsForCurrentDocument` as current diagnostic evidence. `evidence.status: untrusted` places any report under `unconfirmedDiagnosticReport`, keeps `diagnosticsForCurrentDocument` null, and produces `collection.status: partial`. Do not interpret an empty unconfirmed report as a clean file.
104
+ Diagnostics identify the analyzed document with a version and SHA-256 fingerprint. Read `result.diagnosticUse` before reading diagnostic items. Only `currentDocumentDiagnosticsAvailable: true` and `usableAsCurrentDocumentDiagnosticEvidence: true` permit using `diagnosticsForCurrentDocument` as current diagnostic evidence. This evidence is still not proof of correctness; run applicable repository-native checks before making that claim.
105
+
106
+ `evidence.status: untrusted` keeps `diagnosticsForCurrentDocument` null and produces `collection.status: partial`. `unconfirmedDiagnosticReportAvailable: true` means the provider emitted a report that is available only as context under `unconfirmedDiagnosticReport`; it is not current-document, compile, or type validation. `false` means no unconfirmed provider report was available. In both cases, follow `diagnosticUse.guidance` and do not interpret missing or empty unconfirmed items as a clean file.
105
107
 
106
108
  `current-document-version-confirmed` means a push report carried the current document version. `current-document-snapshot-confirmed` means a provider-supported pull completed while the synchronized and filesystem content remained unchanged. `document-content-changed-during-diagnostic-acquisition` is untrusted evidence and requires a new diagnostic call after the file settles.
107
109
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Generated from `protocol.mjs`. Do not edit this file directly.
4
4
 
5
- Producer: `semantic-js-mcp` version `0.10.2`
5
+ Producer: `semantic-js-mcp` version `0.10.4`
6
6
  Display name: `Semantic JS MCP`
7
7
  Result schema version: `7`
8
8
 
@@ -40,7 +40,7 @@ Result schema version: `7`
40
40
  - `lsp_workspace_symbols`: `Returns declaration-shaped symbols whose names contain a query. Use lsp_count_named_symbol or lsp_audit_named_symbol with an exact name.`
41
41
  - `lsp_definition`: `Resolves definitions for one source position. Use lsp_hover for type information or lsp_count_references for impact scope.`
42
42
  - `lsp_hover`: `Returns inferred type information and documentation for one source position. Use lsp_definition for declaration identity.`
43
- - `lsp_diagnostics`: `Returns diagnostics for one file and marks evidence untrusted when the current document snapshot cannot be confirmed.`
43
+ - `lsp_diagnostics`: `Returns diagnostics for one file, separates unconfirmed context, and states whether the result is usable as current-document diagnostic evidence.`
44
44
  - `lsp_count_text_matches`: `Counts exact identifier text matches without semantic verification. Use lsp_count_named_symbol or lsp_audit_named_symbol to verify identity.`
45
45
  - `lsp_count_named_symbol`: `Returns exact-definition and verified-reference counts plus explicit semantic follow-up status for a symbol name. Use lsp_audit_named_symbol for identity, signature, or file-hint binding verification and lsp_reference_page with a returned referenceSetId for locations.`
46
46
  - `lsp_count_references`: `Returns verified-reference counts for the symbol at one source position. Use lsp_audit_symbol for identity and signature or lsp_reference_page with the returned referenceSetId for locations.`
@@ -236,6 +236,23 @@ Result schema version: `7`
236
236
  - `language-server-reported-different-version`
237
237
  - `language-server-did-not-report-current-document`
238
238
 
239
+ ## Diagnostic Result Fields
240
+
241
+ - `diagnosticUse`
242
+ - `diagnosticsForCurrentDocument`
243
+ - `unconfirmedDiagnosticReport`
244
+ - `reportReceived`
245
+ - `currentDocumentDiagnosticsAvailable`
246
+ - `unconfirmedDiagnosticReportAvailable`
247
+ - `usableAsCurrentDocumentDiagnosticEvidence`
248
+ - `guidance`
249
+
250
+ ## Diagnostic Guidance
251
+
252
+ - `Use these as current-document diagnostic evidence, not proof of correctness. Run applicable repository-native checks before claiming correctness.`
253
+ - `Treat the unconfirmed report as context only. It is not current-document, compile, or type validation. Run applicable repository-native typecheck, compile, or focused test commands.`
254
+ - `Current-document diagnostics are unavailable. Do not interpret this as a clean file. Run applicable repository-native typecheck, compile, or focused test commands.`
255
+
239
256
  ## Evidence Status
240
257
 
241
258
  - `verified`
package/AGENT_SETUP.md DELETED
@@ -1,176 +0,0 @@
1
- # Agent Setup
2
-
3
- This guide is for a coding agent whose user has explicitly requested that it
4
- install, configure, update, verify, roll back, or remove Semantic JS MCP. It is
5
- not an instruction to change an environment merely because this file was read.
6
-
7
- ## Scope
8
-
9
- First identify the application that will run the MCP server. That application
10
- is the MCP host. Use the verified Codex procedure only for Codex. For every
11
- other host, use the generic stdio procedure below and translate its fields into
12
- the host's documented configuration format. Do not guess a configuration file
13
- or schema.
14
-
15
- Semantic JS MCP requires Node.js 22 or newer and `rg` (ripgrep) on `PATH`.
16
- Before changing host configuration, run:
17
-
18
- ```bash
19
- node --version
20
- rg --version
21
- ```
22
-
23
- Stop if Node.js is older than 22 or either command is unavailable. Report the
24
- missing prerequisite. Do not continue with a partial installation.
25
-
26
- ## Safety Boundaries
27
-
28
- This guide does not override system, developer, organization, repository, or
29
- host security policy.
30
-
31
- - Inspect existing configuration before editing it and change only the entry
32
- approved by the user.
33
- - Request any approval required for package installation, global writes,
34
- configuration changes, network access, or process restart.
35
- - Never request or expose credentials, disable security controls, or execute a
36
- remote shell pipeline.
37
- - Preserve every unrelated MCP server and setting. Never replace an entire
38
- configuration file to add one server.
39
- - Stop and report the blocker when the requested host or prerequisite cannot be
40
- verified safely.
41
-
42
- ## Installation Procedure
43
-
44
- ### Codex
45
-
46
- Use the public marketplace adapter:
47
-
48
- ```bash
49
- codex plugin marketplace add elnonathan/semantic-js-mcp
50
- codex plugin add semantic-js-mcp@elnonathan
51
- codex plugin list
52
- ```
53
-
54
- Start a new Codex session after installation. The plugin supplies both the MCP
55
- server and the semantic-navigation skill.
56
-
57
- ### Generic Stdio Hosts
58
-
59
- Use this procedure only when the host supports local MCP servers over stdio. If
60
- that capability cannot be confirmed from installed help or host documentation,
61
- stop and report that the host is unsupported or unverified.
62
-
63
- After the user approves the package installation and configuration change,
64
- install the executable:
65
-
66
- ```bash
67
- npm install --global semantic-js-mcp
68
- ```
69
-
70
- Inspect the existing host configuration. Add exactly one MCP server with these
71
- values:
72
-
73
- - server name: `semanticjsmcp`
74
- - transport: `stdio`
75
- - executable or command: `semantic-js-mcp`
76
- - arguments: one argument, `serve`
77
- - enabled: `true`, when the host has an enabled field
78
-
79
- Do not configure a URL, port, shell command, or credentials. The host must
80
- start `semantic-js-mcp serve` as a local child process and communicate through
81
- standard input and standard output. Translate the values above into the host's
82
- documented schema; do not copy a configuration shape from a different host.
83
-
84
- Save the smallest possible change. Restart or reload the host when its
85
- documentation requires it.
86
-
87
- ## Verification
88
-
89
- For an executable installation, record the installed version and run the
90
- doctor:
91
-
92
- ```bash
93
- semantic-js-mcp --version
94
- semantic-js-mcp doctor
95
- ```
96
-
97
- Read the structured doctor result literally:
98
-
99
- - `pass`: continue to host tool verification.
100
- - `untrusted`: continue to host tool verification and report the stated
101
- uncertainty. Do not describe it as `pass`.
102
- - `blocked` or `fail`: stop, correct the reported problem when authorized, or
103
- report the blocker. Do not claim a successful installation.
104
-
105
- Then verify the host discovers tools whose base names begin with `lsp_`. A host
106
- may display the server name before the base name. Execute one read-only call
107
- such as `lsp_document_symbols` against a user-approved JavaScript, TypeScript,
108
- or Vue file. Do not claim successful installation from configuration text
109
- alone.
110
-
111
- For a Codex plugin installation without a global executable, verify the version
112
- with `codex plugin list`, start a new session, and confirm MCP tool discovery
113
- there.
114
-
115
- Installation is successful only when the host discovers the MCP tools and one
116
- read-only `lsp_*` call returns a result. Package installation or configuration
117
- text alone is not success.
118
-
119
- ## Update And Rollback
120
-
121
- Update an existing Codex installation by refreshing its marketplace snapshot
122
- before reinstalling:
123
-
124
- ```bash
125
- codex plugin marketplace upgrade elnonathan
126
- codex plugin add semantic-js-mcp@elnonathan
127
- codex plugin list
128
- ```
129
-
130
- Update a global npm installation with:
131
-
132
- ```bash
133
- npm install --global semantic-js-mcp@latest
134
- ```
135
-
136
- Before updating, record the working version. To roll back a global installation,
137
- install that exact known version, for example:
138
-
139
- ```bash
140
- npm install --global semantic-js-mcp@0.10.1
141
- ```
142
-
143
- For a host adapter, restore the previously recorded package version and host
144
- configuration together. Do not replace or remove unrelated configuration while
145
- rolling back.
146
-
147
- ## Removal
148
-
149
- For Codex, remove only this plugin:
150
-
151
- ```bash
152
- codex plugin remove semantic-js-mcp@elnonathan
153
- ```
154
-
155
- Remove the `elnonathan` marketplace only when the user confirms that no other
156
- installed plugin uses it:
157
-
158
- ```bash
159
- codex plugin marketplace remove elnonathan
160
- ```
161
-
162
- For a global executable, remove the package and only its `semanticjsmcp` MCP
163
- entry:
164
-
165
- ```bash
166
- npm uninstall --global semantic-js-mcp
167
- ```
168
-
169
- Restart the host and confirm the tools are no longer registered.
170
-
171
- ## Completion Report
172
-
173
- Report the detected host, installed or removed version, exact configuration
174
- entry changed, doctor status when available, tool-discovery result, required
175
- restart, and any remaining uncertainty. Do not include credentials or unrelated
176
- configuration values.