pi-usereq 0.5.0 → 0.7.0

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.
@@ -156,10 +156,11 @@ export interface FindToolRequestSection {
156
156
 
157
157
  /**
158
158
  * @brief Describes the summary section of the find payload.
159
- * @details Exposes aggregate file, match, line, and Doxygen counts as numeric fields plus one stable search-status discriminator. The interface is compile-time only and introduces no runtime cost.
159
+ * @details Exposes aggregate file, match, line, and Doxygen counts as numeric fields plus one stable search-status discriminator and the normalized validation error when request parsing fails. The interface is compile-time only and introduces no runtime cost.
160
160
  */
161
161
  export interface FindToolSummarySection {
162
162
  search_status: FindSearchStatus;
163
+ validation_error_message?: string;
163
164
  processable_file_count: number;
164
165
  matched_file_count: number;
165
166
  no_match_file_count: number;
@@ -172,22 +173,20 @@ export interface FindToolSummarySection {
172
173
 
173
174
  /**
174
175
  * @brief Describes the repository section of the find payload.
175
- * @details Stores the base path, configured source-directory scope, canonical file list, and supported-tag matrix needed to specialize later searches without rereading tool descriptions. The interface is compile-time only and introduces no runtime cost.
176
+ * @details Stores the base path, configured source-directory scope, and canonical file list used during search while omitting the static supported-tag matrix because that data belongs in tool registration metadata. The interface is compile-time only and introduces no runtime cost.
176
177
  */
177
178
  export interface FindToolRepositorySection {
178
179
  root_directory_path: string;
179
180
  source_directory_paths: string[];
180
181
  file_count: number;
181
182
  file_canonical_paths: string[];
182
- supported_tags_by_language: Record<string, string[]>;
183
183
  }
184
184
 
185
185
  /**
186
186
  * @brief Describes the full agent-oriented find payload.
187
- * @details Orders the top-level sections as request, summary, repository, and files so execution metadata can be appended deterministically by the tool wrapper. The interface is compile-time only and introduces no runtime cost.
187
+ * @details Exposes only aggregate search totals, repository scope, and per-file match records, omitting request echoes and static supported-tag matrices that already belong in registration metadata. The interface is compile-time only and introduces no runtime cost.
188
188
  */
189
189
  export interface FindToolPayload {
190
- request: FindToolRequestSection;
191
190
  summary: FindToolSummarySection;
192
191
  repository: FindToolRepositorySection;
193
192
  files: FindToolFileEntry[];
@@ -262,19 +261,6 @@ function buildLineRange(startLineNumber: number, endLineNumber: number): FindLin
262
261
  };
263
262
  }
264
263
 
265
- /**
266
- * @brief Returns the supported-tag matrix ordered for deterministic JSON emission.
267
- * @details Sorts languages alphabetically and tag arrays lexicographically so downstream agents can reuse the matrix without reparsing human prose. Runtime is O(l * t log t). No side effects occur.
268
- * @return {Record<string, string[]>} Supported tags keyed by canonical language identifier.
269
- */
270
- function buildSupportedTagsByLanguage(): Record<string, string[]> {
271
- return Object.fromEntries(
272
- Object.entries(LANGUAGE_TAGS)
273
- .sort(([left], [right]) => left.localeCompare(right))
274
- .map(([language, tagSet]) => [language, [...tagSet].sort()]),
275
- );
276
- }
277
-
278
264
  /**
279
265
  * @brief Resolves one stable symbol name from an analyzed element.
280
266
  * @details Prefers explicit analyzer name metadata, then falls back to the derived signature or the first source line so every matched construct retains a direct-access identifier. Runtime is O(1). No side effects occur.
@@ -717,9 +703,9 @@ function analyzeFindFile(
717
703
 
718
704
  /**
719
705
  * @brief Builds the full agent-oriented find payload.
720
- * @details Validates request parameters, analyzes requested files in caller order when the request is valid, preserves skipped and no-match outcomes in structured file entries, computes aggregate numeric totals, and emits a structured supported-tag matrix. Runtime is O(F log F + S + M). Side effects are limited to filesystem reads and optional stderr logging.
706
+ * @details Validates request parameters, analyzes requested files in caller order when the request is valid, preserves skipped and no-match outcomes in structured file entries, computes aggregate numeric totals, and omits request echoes plus the static supported-tag matrix already encoded in registration metadata. Runtime is O(F log F + S + M). Side effects are limited to filesystem reads and optional stderr logging.
721
707
  * @param[in] options {BuildFindToolPayloadOptions} Payload-construction options.
722
- * @return {FindToolPayload} Structured find payload ordered as request, summary, repository, and files.
708
+ * @return {FindToolPayload} Structured find payload ordered as summary, repository, and files.
723
709
  * @satisfies REQ-089, REQ-090, REQ-091, REQ-092, REQ-093, REQ-094, REQ-096, REQ-098
724
710
  */
725
711
  export function buildFindToolPayload(options: BuildFindToolPayloadOptions): FindToolPayload {
@@ -835,28 +821,20 @@ export function buildFindToolPayload(options: BuildFindToolPayloadOptions): Find
835
821
  const processableFiles = files.filter((file) => file.status !== "skipped");
836
822
  const repositoryFileCanonicalPaths = files.map((file) => file.canonical_path);
837
823
 
824
+ void toolName;
825
+ void scope;
826
+ void lineNumberMode;
827
+ void tagFilter;
828
+ void pattern;
829
+ void canonicalRequestedPaths;
838
830
  return {
839
- request: {
840
- tool_name: toolName,
841
- scope,
842
- base_dir_path: absoluteBaseDir,
843
- line_number_mode: lineNumberMode,
844
- tag_filter_text: tagFilter,
845
- tag_filter_values: tagValidation.tagValues,
846
- tag_filter_status: tagValidation.status,
847
- tag_filter_error_message: tagValidation.errorMessage,
848
- name_regex_text: pattern,
849
- regex_engine: "javascript-regexp-search",
850
- regex_status: regexValidation.status,
851
- regex_error_message: regexValidation.errorMessage,
852
- source_directory_count: sourceDirectoryPaths.length,
853
- source_directory_paths: sourceDirectoryPaths.map((sourceDirectoryPath) => canonicalizeFindPath(sourceDirectoryPath, absoluteBaseDir)),
854
- requested_file_count: requestedPaths.length,
855
- requested_input_paths: [...requestedPaths],
856
- requested_canonical_paths: canonicalRequestedPaths,
857
- },
858
831
  summary: {
859
832
  search_status: searchStatus,
833
+ validation_error_message: tagValidation.status === "invalid"
834
+ ? tagValidation.errorMessage
835
+ : regexValidation.status === "invalid"
836
+ ? regexValidation.errorMessage
837
+ : undefined,
860
838
  processable_file_count: processableFiles.length,
861
839
  matched_file_count: matchedFiles.length,
862
840
  no_match_file_count: files.filter((file) => file.status === "no_match").length,
@@ -874,7 +852,6 @@ export function buildFindToolPayload(options: BuildFindToolPayloadOptions): Find
874
852
  source_directory_paths: sourceDirectoryPaths.map((sourceDirectoryPath) => canonicalizeFindPath(sourceDirectoryPath, absoluteBaseDir)),
875
853
  file_count: repositoryFileCanonicalPaths.length,
876
854
  file_canonical_paths: repositoryFileCanonicalPaths,
877
- supported_tags_by_language: buildSupportedTagsByLanguage(),
878
855
  },
879
856
  files,
880
857
  };
@@ -889,11 +866,11 @@ export function buildFindToolPayload(options: BuildFindToolPayloadOptions): Find
889
866
  */
890
867
  export function buildFindToolExecutionStderr(payload: FindToolPayload): string {
891
868
  const diagnostics: string[] = [];
892
- if (payload.request.tag_filter_status === "invalid") {
893
- diagnostics.push(`error: tag_filter: ${payload.request.tag_filter_error_message ?? "invalid tag filter"}`);
869
+ if (payload.summary.search_status === "invalid_tag_filter") {
870
+ diagnostics.push(`error: tag_filter: ${payload.summary.validation_error_message ?? "invalid tag filter"}`);
894
871
  }
895
- if (payload.request.regex_status === "invalid") {
896
- diagnostics.push(`error: name_regex: ${payload.request.regex_error_message ?? "invalid regex"}`);
872
+ if (payload.summary.search_status === "invalid_regex") {
873
+ diagnostics.push(`error: name_regex: ${payload.summary.validation_error_message ?? "invalid regex"}`);
897
874
  }
898
875
  payload.files.forEach((file) => {
899
876
  if (file.status === "skipped") {