pi-usereq 0.4.0 → 0.6.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.
Files changed (65) hide show
  1. package/.gitignore +3 -0
  2. package/CHANGELOG.md +41 -0
  3. package/README.md +1 -1
  4. package/package.json +1 -1
  5. package/{req → pi-usereq}/docs/REFERENCES.md +499 -491
  6. package/{req → pi-usereq}/docs/REQUIREMENTS.md +84 -62
  7. package/{req → pi-usereq}/docs/WORKFLOW.md +87 -102
  8. package/src/core/agent-tool-json.ts +42 -193
  9. package/src/core/compress-payload.ts +7 -15
  10. package/src/core/config.ts +39 -12
  11. package/src/core/extension-status.ts +94 -58
  12. package/src/core/find-payload.ts +21 -44
  13. package/src/core/pi-notify.ts +198 -11
  14. package/src/core/reference-payload.ts +6 -14
  15. package/src/core/runtime-project-paths.ts +3 -32
  16. package/src/core/settings-menu.ts +9 -4
  17. package/src/core/static-check.ts +35 -171
  18. package/src/core/token-counter.ts +3 -121
  19. package/src/index.ts +339 -180
  20. package/tests/attended-results-scenarios.ts +3 -13
  21. package/tests/cli-command-option-parity.test.ts +21 -12
  22. package/tests/debug-extension-harness.test.ts +20 -22
  23. package/tests/extension-registration.test.ts +394 -157
  24. package/tests/oracle-project.test.ts +8 -3
  25. package/tests/oracle-standalone.test.ts +7 -13
  26. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_c.c.json +0 -5
  27. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_cpp.cpp.json +0 -5
  28. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_csharp.cs.json +0 -5
  29. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_elixir.ex.json +0 -5
  30. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_go.go.json +0 -5
  31. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_haskell.hs.json +0 -5
  32. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_java.java.json +0 -5
  33. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_javascript.js.json +0 -5
  34. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_kotlin.kt.json +0 -5
  35. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_lua.lua.json +0 -5
  36. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_perl.pl.json +0 -5
  37. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_php.php.json +0 -5
  38. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_python.py.json +0 -5
  39. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_ruby.rb.json +0 -5
  40. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_rust.rs.json +0 -5
  41. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_scala.scala.json +0 -5
  42. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_shell.sh.json +0 -5
  43. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_swift.swift.json +0 -5
  44. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_typescript.ts.json +0 -5
  45. package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_zig.zig.json +0 -5
  46. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_c.c.json +0 -5
  47. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_cpp.cpp.json +0 -5
  48. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_csharp.cs.json +0 -5
  49. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_elixir.ex.json +0 -5
  50. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_go.go.json +0 -5
  51. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_haskell.hs.json +0 -5
  52. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_java.java.json +0 -5
  53. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_javascript.js.json +0 -5
  54. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_kotlin.kt.json +0 -5
  55. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_lua.lua.json +0 -5
  56. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_perl.pl.json +0 -5
  57. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_php.php.json +0 -5
  58. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_python.py.json +0 -5
  59. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_ruby.rb.json +0 -5
  60. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_rust.rs.json +0 -5
  61. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_scala.scala.json +0 -5
  62. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_shell.sh.json +0 -5
  63. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_swift.swift.json +0 -5
  64. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_typescript.ts.json +0 -5
  65. package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_zig.zig.json +0 -5
@@ -7,23 +7,18 @@
7
7
  import fs from "node:fs";
8
8
  import path from "node:path";
9
9
  import type { StaticCheckEntry } from "./config.js";
10
- import type { RuntimePathFacts } from "./path-context.js";
11
10
  import { ReqError } from "./errors.js";
12
11
  import { STATIC_CHECK_EXT_TO_LANG } from "./static-check.js";
13
12
  import type { ToolResult } from "./tool-runner.js";
14
13
 
15
14
  /**
16
15
  * @brief Describes normalized execution metadata shared by structured tool payloads.
17
- * @details Separates numeric status, line-oriented diagnostics, and optional raw text so downstream agents can branch on stable fields before consulting residual text. The interface is compile-time only and introduces no runtime cost.
16
+ * @details Stores only the exit code and residual stdout or stderr line arrays needed after response payload construction, omitting duplicate text and count fields to reduce token cost. The interface is compile-time only and introduces no runtime cost.
18
17
  */
19
18
  export interface ToolExecutionSection {
20
19
  code: number;
21
- stdout_line_count: number;
22
- stderr_line_count: number;
23
- stdout_lines: string[];
24
- stderr_lines: string[];
25
- stdout_text?: string;
26
- stderr_text?: string;
20
+ stdout_lines?: string[];
21
+ stderr_lines?: string[];
27
22
  }
28
23
 
29
24
  /**
@@ -37,142 +32,85 @@ export interface StructuredToolExecuteResult<T> {
37
32
 
38
33
  /**
39
34
  * @brief Describes the structured payload returned by path-query tools.
40
- * @details Exposes the requested config key, caller cwd, resolved project base, resolved path value, and shared runtime path facts as direct-access fields. The interface is compile-time only and introduces no runtime cost.
35
+ * @details Exposes only the resolved path facts that can differ at runtime plus residual execution diagnostics, omitting caller-known request echoes and duplicated runtime-path inventories. The interface is compile-time only and introduces no runtime cost.
41
36
  */
42
37
  export interface PathQueryToolPayload {
43
- request: {
44
- tool_name: string;
45
- scope: "project-config";
46
- working_directory_path: string;
47
- project_base_path: string;
48
- query_key: "git-path" | "base-path";
49
- };
50
38
  result: {
51
- status: "resolved" | "empty";
52
- path_key: "git-path" | "base-path";
53
39
  path_value: string;
54
40
  path_present: boolean;
55
41
  };
56
- runtime_paths: RuntimePathFacts;
57
42
  execution: ToolExecutionSection;
58
43
  }
59
44
 
60
45
  /**
61
46
  * @brief Describes the structured payload returned by `git-check`.
62
- * @details Exposes git-root presence, repository validation status, shared runtime path facts, and normalized execution diagnostics as stable fields. The interface is compile-time only and introduces no runtime cost.
47
+ * @details Exposes only the runtime git-path presence fact plus aggregate repository validation status, omitting intermediate request metadata whose semantics already live in the tool registration. The interface is compile-time only and introduces no runtime cost.
63
48
  */
64
49
  export interface GitCheckToolPayload {
65
- request: {
66
- tool_name: "git-check";
67
- scope: "project-config";
68
- project_base_path: string;
69
- configured_git_path: string;
70
- git_path_present: boolean;
71
- };
72
50
  result: {
51
+ git_path_present: boolean;
73
52
  status: "clean" | "error";
74
- worktree_status: "clean" | "unknown";
75
- head_status: "valid" | "unknown";
76
53
  error_message?: string;
77
54
  };
78
- runtime_paths: RuntimePathFacts;
79
55
  execution: ToolExecutionSection;
80
56
  }
81
57
 
82
58
  /**
83
59
  * @brief Describes one canonical-doc status record returned by `docs-check`.
84
- * @details Binds each required filename to its prompt generator, normalized path facts, and presence status so agents can branch per missing document deterministically. The interface is compile-time only and introduces no runtime cost.
60
+ * @details Stores the canonical path, remediation prompt command, and presence status while omitting redundant filesystem probe fields already summarized by the status value. The interface is compile-time only and introduces no runtime cost.
85
61
  */
86
62
  export interface DocsCheckFileRecord {
87
63
  file_name: string;
88
64
  canonical_path: string;
89
- absolute_path: string;
90
65
  prompt_command: string;
91
- exists: boolean;
92
- is_file: boolean;
93
66
  status: "present" | "missing";
94
67
  }
95
68
 
96
69
  /**
97
70
  * @brief Describes the structured payload returned by `docs-check`.
98
- * @details Exposes docs-root selection, per-document presence facts, remediation prompt commands, shared runtime path facts, and execution diagnostics as stable JSON fields. The interface is compile-time only and introduces no runtime cost.
71
+ * @details Exposes per-document presence facts and remediation commands plus residual execution diagnostics, omitting static request metadata that can be inferred from the tool registration and caller context. The interface is compile-time only and introduces no runtime cost.
99
72
  */
100
73
  export interface DocsCheckToolPayload {
101
- request: {
102
- tool_name: "docs-check";
103
- scope: "canonical-docs";
104
- project_base_path: string;
105
- docs_directory_path: string;
106
- required_file_count: number;
107
- required_file_names: string[];
108
- };
109
74
  summary: {
110
75
  present_file_count: number;
111
76
  missing_file_count: number;
112
77
  };
113
78
  files: DocsCheckFileRecord[];
114
- runtime_paths: RuntimePathFacts;
115
79
  execution: ToolExecutionSection;
116
80
  }
117
81
 
118
82
  /**
119
83
  * @brief Describes the structured payload returned by `git-wt-name`.
120
- * @details Exposes the generated worktree name, its normative format, shared runtime path facts, and execution diagnostics as direct-access fields. The interface is compile-time only and introduces no runtime cost.
84
+ * @details Exposes only the generated worktree name plus residual execution diagnostics, omitting the static normative format string because it already belongs in registration metadata. The interface is compile-time only and introduces no runtime cost.
121
85
  */
122
86
  export interface WorktreeNameToolPayload {
123
- request: {
124
- tool_name: "git-wt-name";
125
- scope: "project-config";
126
- project_base_path: string;
127
- configured_git_path: string;
128
- };
129
87
  result: {
130
- status: "generated" | "error";
131
88
  worktree_name?: string;
132
- format_text: "useReq-<project>-<sanitized-branch>-<YYYYMMDDHHMMSS>";
133
89
  error_message?: string;
134
90
  };
135
- runtime_paths: RuntimePathFacts;
136
91
  execution: ToolExecutionSection;
137
92
  }
138
93
 
139
94
  /**
140
95
  * @brief Describes the structured payload returned by worktree mutation tools.
141
- * @details Exposes the requested operation, exact worktree name, derived worktree path, mutation status, shared runtime path facts, and execution diagnostics as stable JSON fields. The interface is compile-time only and introduces no runtime cost.
96
+ * @details Exposes only the exact worktree name and derived path that can vary per invocation plus residual execution diagnostics, omitting static operation descriptors and duplicated branch-name fields. The interface is compile-time only and introduces no runtime cost.
142
97
  */
143
98
  export interface WorktreeMutationToolPayload {
144
- request: {
145
- tool_name: "git-wt-create" | "git-wt-delete";
146
- scope: "project-config";
147
- operation: "create" | "delete";
148
- project_base_path: string;
149
- configured_git_path: string;
150
- worktree_name: string;
151
- };
152
99
  result: {
153
- status: "created" | "deleted" | "error";
154
100
  worktree_name: string;
155
- branch_name: string;
156
101
  worktree_path: string;
157
102
  error_message?: string;
158
103
  };
159
- runtime_paths: RuntimePathFacts;
160
104
  execution: ToolExecutionSection;
161
105
  }
162
106
 
163
107
  /**
164
108
  * @brief Describes one file-selection record inside a static-check payload.
165
- * @details Exposes request order, normalized path facts, detected language, configured checker modules, and stable selection status without forcing agents to parse checker output text. The interface is compile-time only and introduces no runtime cost.
109
+ * @details Exposes canonical path, detected language, configured checker modules, and stable selection status without echoing caller inputs or redundant filesystem probe fields. The interface is compile-time only and introduces no runtime cost.
166
110
  */
167
111
  export interface StaticCheckFileRecord {
168
- request_index: number;
169
- input_path: string;
170
112
  canonical_path: string;
171
- absolute_path: string;
172
- exists: boolean;
173
- is_file: boolean;
174
113
  language_name?: string;
175
- configured_checker_count: number;
176
114
  configured_checker_modules: string[];
177
115
  status: "selected" | "skipped" | "unsupported_language" | "no_configured_checkers";
178
116
  error_message?: string;
@@ -180,20 +118,9 @@ export interface StaticCheckFileRecord {
180
118
 
181
119
  /**
182
120
  * @brief Describes the structured payload returned by static-check agent tools.
183
- * @details Exposes scope selection, configured checker coverage, per-file selection facts, shared runtime path facts, and normalized execution diagnostics while keeping residual checker text optional under execution. The interface is compile-time only and introduces no runtime cost.
121
+ * @details Exposes aggregate checker coverage, per-file selection facts, and normalized execution diagnostics while omitting request echoes whose semantics are already available in the tool registration and input parameters. The interface is compile-time only and introduces no runtime cost.
184
122
  */
185
123
  export interface StaticCheckToolPayload {
186
- request: {
187
- tool_name: "files-static-check" | "static-check";
188
- scope: "explicit-files" | "configured-source-and-test-directories";
189
- project_base_path: string;
190
- configured_language_count: number;
191
- configured_languages: string[];
192
- selection_directory_paths: string[];
193
- excluded_directory_paths: string[];
194
- requested_file_count: number;
195
- requested_input_paths: string[];
196
- };
197
124
  summary: {
198
125
  selected_file_count: number;
199
126
  skipped_file_count: number;
@@ -202,7 +129,6 @@ export interface StaticCheckToolPayload {
202
129
  total_configured_checker_count: number;
203
130
  };
204
131
  files: StaticCheckFileRecord[];
205
- runtime_paths: RuntimePathFacts;
206
132
  execution: ToolExecutionSection;
207
133
  }
208
134
 
@@ -260,9 +186,9 @@ export function buildStructuredToolExecuteResult<T extends { execution: ToolExec
260
186
 
261
187
  /**
262
188
  * @brief Converts one raw `ToolResult` into a normalized execution section.
263
- * @details Separates numeric exit status, line-oriented stdout/stderr arrays, and optional raw text so downstream agents can consume structured facts before consulting residual text. Runtime is O(n) in output size. No external state is mutated.
189
+ * @details Preserves only the exit code plus non-empty stdout or stderr line arrays so downstream payloads carry residual diagnostics without duplicating the primary structured response body. Runtime is O(n) in output size. No external state is mutated.
264
190
  * @param[in] result {ToolResult} Raw tool result.
265
- * @return {ToolExecutionSection} Normalized execution metadata.
191
+ * @return {ToolExecutionSection} Normalized residual execution metadata.
266
192
  */
267
193
  export function buildToolExecutionSection(result: ToolResult): ToolExecutionSection {
268
194
  const stdoutText = result.stdout.trimEnd();
@@ -271,12 +197,8 @@ export function buildToolExecutionSection(result: ToolResult): ToolExecutionSect
271
197
  const stderrLines = splitToolOutputLines(stderrText);
272
198
  return {
273
199
  code: result.code,
274
- stdout_line_count: stdoutLines.length,
275
- stderr_line_count: stderrLines.length,
276
- stdout_lines: stdoutLines,
277
- stderr_lines: stderrLines,
278
- stdout_text: stdoutText === "" ? undefined : stdoutText,
279
- stderr_text: stderrText === "" ? undefined : stderrText,
200
+ stdout_lines: stdoutLines.length === 0 ? undefined : stdoutLines,
201
+ stderr_lines: stderrLines.length === 0 ? undefined : stderrLines,
280
202
  };
281
203
  }
282
204
 
@@ -300,12 +222,11 @@ export function normalizeToolFailure(error: unknown): ToolResult {
300
222
 
301
223
  /**
302
224
  * @brief Builds the structured payload returned by `git-path` or `get-base-path`.
303
- * @details Exposes the resolved runtime path value as a direct-access field and preserves normalized execution metadata separately from path facts. Runtime is O(p) in path length. No external state is mutated.
225
+ * @details Exposes only the resolved runtime path value plus residual execution metadata, omitting request echoes and duplicated runtime-path inventories from the runtime payload. Runtime is O(p) in path length. No external state is mutated.
304
226
  * @param[in] toolName {"git-path" | "get-base-path"} Target tool name.
305
227
  * @param[in] workingDirectoryPath {string} Caller working directory.
306
228
  * @param[in] projectBasePath {string} Resolved project base path.
307
229
  * @param[in] resolvedPath {string} Resolved config path value.
308
- * @param[in] runtimePaths {RuntimePathFacts} Shared runtime path facts.
309
230
  * @param[in] execution {ToolExecutionSection} Normalized execution metadata.
310
231
  * @return {PathQueryToolPayload} Structured path-query payload.
311
232
  */
@@ -314,76 +235,55 @@ export function buildPathQueryToolPayload(
314
235
  workingDirectoryPath: string,
315
236
  projectBasePath: string,
316
237
  resolvedPath: string,
317
- runtimePaths: RuntimePathFacts,
318
238
  execution: ToolExecutionSection,
319
239
  ): PathQueryToolPayload {
320
- const queryKey = toolName === "git-path" ? "git-path" : "base-path";
240
+ void toolName;
241
+ void workingDirectoryPath;
242
+ void projectBasePath;
321
243
  return {
322
- request: {
323
- tool_name: toolName,
324
- scope: "project-config",
325
- working_directory_path: path.resolve(workingDirectoryPath).split(path.sep).join("/"),
326
- project_base_path: path.resolve(projectBasePath).split(path.sep).join("/"),
327
- query_key: queryKey,
328
- },
329
244
  result: {
330
- status: resolvedPath === "" ? "empty" : "resolved",
331
- path_key: queryKey,
332
245
  path_value: resolvedPath,
333
246
  path_present: resolvedPath !== "",
334
247
  },
335
- runtime_paths: runtimePaths,
336
248
  execution,
337
249
  };
338
250
  }
339
251
 
340
252
  /**
341
253
  * @brief Builds the structured payload returned by `git-check`.
342
- * @details Encodes runtime git-root presence plus clean-versus-error status as direct fields while preserving raw diagnostics under execution. Runtime is O(p) in path length. No external state is mutated.
254
+ * @details Encodes runtime git-path presence plus aggregate clean-versus-error status while preserving raw diagnostics under execution. Runtime is O(p) in path length. No external state is mutated.
343
255
  * @param[in] projectBasePath {string} Resolved project base path.
344
256
  * @param[in] configuredGitPath {string | undefined} Runtime git root path.
345
- * @param[in] runtimePaths {RuntimePathFacts} Shared runtime path facts.
346
257
  * @param[in] execution {ToolExecutionSection} Normalized execution metadata.
347
258
  * @return {GitCheckToolPayload} Structured git-check payload.
348
259
  */
349
260
  export function buildGitCheckToolPayload(
350
261
  projectBasePath: string,
351
262
  configuredGitPath: string | undefined,
352
- runtimePaths: RuntimePathFacts,
353
263
  execution: ToolExecutionSection,
354
264
  ): GitCheckToolPayload {
355
- const errorMessage = execution.stderr_lines[0];
265
+ void projectBasePath;
266
+ const errorMessage = execution.stderr_lines?.[0];
356
267
  return {
357
- request: {
358
- tool_name: "git-check",
359
- scope: "project-config",
360
- project_base_path: path.resolve(projectBasePath).split(path.sep).join("/"),
361
- configured_git_path: configuredGitPath ?? "",
362
- git_path_present: Boolean(configuredGitPath),
363
- },
364
268
  result: {
269
+ git_path_present: Boolean(configuredGitPath),
365
270
  status: execution.code === 0 ? "clean" : "error",
366
- worktree_status: execution.code === 0 ? "clean" : "unknown",
367
- head_status: execution.code === 0 ? "valid" : "unknown",
368
271
  error_message: execution.code === 0 ? undefined : errorMessage,
369
272
  },
370
- runtime_paths: runtimePaths,
371
273
  execution,
372
274
  };
373
275
  }
374
276
 
375
277
  /**
376
278
  * @brief Builds the structured payload returned by `docs-check`.
377
- * @details Enumerates required canonical documents, binds each missing file to its remediation prompt command, and emits summary counts plus normalized execution metadata. Runtime is O(k) in required file count plus filesystem reads. Side effects are limited to filesystem reads.
279
+ * @details Enumerates required canonical documents, binds each missing file to its remediation prompt command, and emits summary counts plus residual execution diagnostics while omitting static request metadata. Runtime is O(k) in required file count plus filesystem reads. Side effects are limited to filesystem reads.
378
280
  * @param[in] projectBasePath {string} Resolved project base path.
379
281
  * @param[in] docsDirPath {string} Configured docs directory relative to the project base.
380
- * @param[in] runtimePaths {RuntimePathFacts} Shared runtime path facts.
381
282
  * @return {DocsCheckToolPayload} Structured docs-check payload.
382
283
  */
383
284
  export function buildDocsCheckToolPayload(
384
285
  projectBasePath: string,
385
286
  docsDirPath: string,
386
- runtimePaths: RuntimePathFacts,
387
287
  ): DocsCheckToolPayload {
388
288
  const normalizedProjectBasePath = path.resolve(projectBasePath);
389
289
  const normalizedDocsRootPath = path.join(normalizedProjectBasePath, docsDirPath.replace(/[/\\]+$/, ""));
@@ -398,10 +298,7 @@ export function buildDocsCheckToolPayload(
398
298
  return {
399
299
  file_name: fileName,
400
300
  canonical_path: canonicalizeToolPath(normalizedProjectBasePath, absolutePath),
401
- absolute_path: absolutePath.split(path.sep).join("/"),
402
301
  prompt_command: promptCommand,
403
- exists,
404
- is_file: isFile,
405
302
  status: isFile ? "present" : "missing",
406
303
  };
407
304
  });
@@ -414,66 +311,47 @@ export function buildDocsCheckToolPayload(
414
311
  code: missingFiles.length === 0 ? 0 : 1,
415
312
  });
416
313
  return {
417
- request: {
418
- tool_name: "docs-check",
419
- scope: "canonical-docs",
420
- project_base_path: normalizedProjectBasePath.split(path.sep).join("/"),
421
- docs_directory_path: normalizedDocsRootPath.split(path.sep).join("/"),
422
- required_file_count: files.length,
423
- required_file_names: files.map((file) => file.file_name),
424
- },
425
314
  summary: {
426
315
  present_file_count: files.length - missingFiles.length,
427
316
  missing_file_count: missingFiles.length,
428
317
  },
429
318
  files,
430
- runtime_paths: runtimePaths,
431
319
  execution,
432
320
  };
433
321
  }
434
322
 
435
323
  /**
436
324
  * @brief Builds the structured payload returned by `git-wt-name`.
437
- * @details Preserves the generated worktree name plus its normative format string as direct-access fields and reports failures through structured execution metadata. Runtime is O(n) in output size. No external state is mutated.
325
+ * @details Preserves only the generated worktree name and error diagnostics, leaving the static naming format in registration metadata instead of the runtime payload. Runtime is O(n) in output size. No external state is mutated.
438
326
  * @param[in] projectBasePath {string} Resolved project base path.
439
327
  * @param[in] configuredGitPath {string | undefined} Runtime git root path.
440
- * @param[in] runtimePaths {RuntimePathFacts} Shared runtime path facts.
441
328
  * @param[in] execution {ToolExecutionSection} Normalized execution metadata.
442
329
  * @return {WorktreeNameToolPayload} Structured worktree-name payload.
443
330
  */
444
331
  export function buildWorktreeNameToolPayload(
445
332
  projectBasePath: string,
446
333
  configuredGitPath: string | undefined,
447
- runtimePaths: RuntimePathFacts,
448
334
  execution: ToolExecutionSection,
449
335
  ): WorktreeNameToolPayload {
450
- const worktreeName = execution.stdout_lines[0];
336
+ void projectBasePath;
337
+ void configuredGitPath;
338
+ const worktreeName = execution.stdout_lines?.[0];
451
339
  return {
452
- request: {
453
- tool_name: "git-wt-name",
454
- scope: "project-config",
455
- project_base_path: path.resolve(projectBasePath).split(path.sep).join("/"),
456
- configured_git_path: configuredGitPath ?? "",
457
- },
458
340
  result: {
459
- status: execution.code === 0 && worktreeName ? "generated" : "error",
460
341
  worktree_name: worktreeName,
461
- format_text: "useReq-<project>-<sanitized-branch>-<YYYYMMDDHHMMSS>",
462
- error_message: execution.code === 0 ? undefined : execution.stderr_lines[0],
342
+ error_message: execution.code === 0 ? undefined : execution.stderr_lines?.[0],
463
343
  },
464
- runtime_paths: runtimePaths,
465
344
  execution,
466
345
  };
467
346
  }
468
347
 
469
348
  /**
470
349
  * @brief Builds the structured payload returned by `git-wt-create` or `git-wt-delete`.
471
- * @details Exposes the requested operation, exact worktree name, derived worktree path, and mutation outcome as stable JSON fields while preserving raw diagnostics under execution. Runtime is O(p) in path length. No external state is mutated.
350
+ * @details Exposes only the exact worktree name, derived worktree path, and error diagnostics, omitting static operation and branch-name echoes from the runtime payload. Runtime is O(p) in path length. No external state is mutated.
472
351
  * @param[in] toolName {"git-wt-create" | "git-wt-delete"} Target tool name.
473
352
  * @param[in] projectBasePath {string} Resolved project base path.
474
353
  * @param[in] configuredGitPath {string | undefined} Runtime git root path.
475
354
  * @param[in] worktreeName {string} Exact requested worktree name.
476
- * @param[in] runtimePaths {RuntimePathFacts} Shared runtime path facts.
477
355
  * @param[in] execution {ToolExecutionSection} Normalized execution metadata.
478
356
  * @return {WorktreeMutationToolPayload} Structured worktree mutation payload.
479
357
  */
@@ -482,40 +360,27 @@ export function buildWorktreeMutationToolPayload(
482
360
  projectBasePath: string,
483
361
  configuredGitPath: string | undefined,
484
362
  worktreeName: string,
485
- runtimePaths: RuntimePathFacts,
486
363
  execution: ToolExecutionSection,
487
364
  ): WorktreeMutationToolPayload {
365
+ void toolName;
366
+ void projectBasePath;
488
367
  const gitRoot = configuredGitPath ? path.resolve(configuredGitPath) : "";
489
368
  const worktreePath = gitRoot === ""
490
369
  ? ""
491
370
  : path.join(path.dirname(gitRoot), worktreeName).split(path.sep).join("/");
492
- const operation = toolName === "git-wt-create" ? "create" : "delete";
493
371
  return {
494
- request: {
495
- tool_name: toolName,
496
- scope: "project-config",
497
- operation,
498
- project_base_path: path.resolve(projectBasePath).split(path.sep).join("/"),
499
- configured_git_path: configuredGitPath ?? "",
500
- worktree_name: worktreeName,
501
- },
502
372
  result: {
503
- status: execution.code === 0
504
- ? (operation === "create" ? "created" : "deleted")
505
- : "error",
506
373
  worktree_name: worktreeName,
507
- branch_name: worktreeName,
508
374
  worktree_path: worktreePath,
509
- error_message: execution.code === 0 ? undefined : execution.stderr_lines[0],
375
+ error_message: execution.code === 0 ? undefined : execution.stderr_lines?.[0],
510
376
  },
511
- runtime_paths: runtimePaths,
512
377
  execution,
513
378
  };
514
379
  }
515
380
 
516
381
  /**
517
382
  * @brief Builds one static-check file-selection record.
518
- * @details Resolves filesystem status, detects the configured language by file extension, counts configured checker entries, and emits a stable selection status without parsing checker output text. Runtime is O(p + c) in path length plus configured checker count. Side effects are limited to filesystem reads.
383
+ * @details Resolves filesystem status, detects the configured language by file extension, and emits the configured checker modules plus a stable selection status without echoing caller inputs or redundant filesystem facts. Runtime is O(p + c) in path length plus configured checker count. Side effects are limited to filesystem reads.
519
384
  * @param[in] inputPath {string} Caller-supplied file path.
520
385
  * @param[in] requestIndex {number} Zero-based request position.
521
386
  * @param[in] projectBasePath {string} Resolved project base path.
@@ -528,6 +393,7 @@ function buildStaticCheckFileRecord(
528
393
  projectBasePath: string,
529
394
  staticCheckConfig: Record<string, StaticCheckEntry[]>,
530
395
  ): StaticCheckFileRecord {
396
+ void requestIndex;
531
397
  const absolutePath = path.resolve(projectBasePath, inputPath);
532
398
  const exists = fs.existsSync(absolutePath);
533
399
  const isFile = exists && fs.statSync(absolutePath).isFile();
@@ -549,14 +415,8 @@ function buildStaticCheckFileRecord(
549
415
  errorMessage = "no configured checkers";
550
416
  }
551
417
  return {
552
- request_index: requestIndex,
553
- input_path: inputPath,
554
418
  canonical_path: canonicalizeToolPath(projectBasePath, absolutePath),
555
- absolute_path: absolutePath.split(path.sep).join("/"),
556
- exists,
557
- is_file: isFile,
558
419
  language_name: languageName,
559
- configured_checker_count: configuredCheckers.length,
560
420
  configured_checker_modules: configuredCheckers.map((checker) => checker.module),
561
421
  status,
562
422
  error_message: errorMessage,
@@ -565,7 +425,7 @@ function buildStaticCheckFileRecord(
565
425
 
566
426
  /**
567
427
  * @brief Builds the structured payload returned by `files-static-check` or `static-check`.
568
- * @details Exposes configured checker coverage, per-file selection facts, and normalized execution diagnostics while leaving raw checker output under execution for residual inspection only. Runtime is O(F + C). Side effects are limited to filesystem reads.
428
+ * @details Exposes configured checker coverage, per-file selection facts, and normalized execution diagnostics while omitting request echoes whose semantics already live in registration metadata. Runtime is O(F + C). Side effects are limited to filesystem reads.
569
429
  * @param[in] toolName {"files-static-check" | "static-check"} Target tool name.
570
430
  * @param[in] scope {"explicit-files" | "configured-source-and-test-directories"} Selection scope label.
571
431
  * @param[in] projectBasePath {string} Resolved project base path.
@@ -573,7 +433,6 @@ function buildStaticCheckFileRecord(
573
433
  * @param[in] selectionDirectoryPaths {string[]} Directories that produced the selection.
574
434
  * @param[in] excludedDirectoryPaths {string[]} Directory roots excluded from project selection.
575
435
  * @param[in] staticCheckConfig {Record<string, StaticCheckEntry[]>} Effective static-check configuration.
576
- * @param[in] runtimePaths {RuntimePathFacts} Shared runtime path facts.
577
436
  * @param[in] execution {ToolExecutionSection} Normalized execution metadata.
578
437
  * @return {StaticCheckToolPayload} Structured static-check payload.
579
438
  */
@@ -585,37 +444,27 @@ export function buildStaticCheckToolPayload(
585
444
  selectionDirectoryPaths: string[],
586
445
  excludedDirectoryPaths: string[],
587
446
  staticCheckConfig: Record<string, StaticCheckEntry[]>,
588
- runtimePaths: RuntimePathFacts,
589
447
  execution: ToolExecutionSection,
590
448
  ): StaticCheckToolPayload {
449
+ void toolName;
450
+ void scope;
451
+ void selectionDirectoryPaths;
452
+ void excludedDirectoryPaths;
591
453
  const files = requestedPaths.map((inputPath, index) => buildStaticCheckFileRecord(
592
454
  inputPath,
593
455
  index,
594
456
  projectBasePath,
595
457
  staticCheckConfig,
596
458
  ));
597
- const configuredLanguages = Object.keys(staticCheckConfig).sort((left, right) => left.localeCompare(right));
598
459
  return {
599
- request: {
600
- tool_name: toolName,
601
- scope,
602
- project_base_path: path.resolve(projectBasePath).split(path.sep).join("/"),
603
- configured_language_count: configuredLanguages.length,
604
- configured_languages: configuredLanguages,
605
- selection_directory_paths: [...selectionDirectoryPaths],
606
- excluded_directory_paths: [...excludedDirectoryPaths],
607
- requested_file_count: requestedPaths.length,
608
- requested_input_paths: [...requestedPaths],
609
- },
610
460
  summary: {
611
461
  selected_file_count: files.filter((file) => file.status === "selected").length,
612
462
  skipped_file_count: files.filter((file) => file.status === "skipped").length,
613
463
  unsupported_file_count: files.filter((file) => file.status === "unsupported_language").length,
614
464
  no_configured_checker_file_count: files.filter((file) => file.status === "no_configured_checkers").length,
615
- total_configured_checker_count: files.reduce((sum, file) => sum + file.configured_checker_count, 0),
465
+ total_configured_checker_count: files.reduce((sum, file) => sum + file.configured_checker_modules.length, 0),
616
466
  },
617
467
  files,
618
- runtime_paths: runtimePaths,
619
468
  execution,
620
469
  };
621
470
  }
@@ -165,10 +165,9 @@ export interface CompressToolRepositorySection {
165
165
 
166
166
  /**
167
167
  * @brief Describes the full agent-oriented compression payload.
168
- * @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.
168
+ * @details Exposes only aggregate compression totals, repository scope, and per-file compression records, omitting request echoes that are already known to the caller or encoded in tool registration metadata. The interface is compile-time only and introduces no runtime cost.
169
169
  */
170
170
  export interface CompressToolPayload {
171
- request: CompressToolRequestSection;
172
171
  summary: CompressToolSummarySection;
173
172
  repository: CompressToolRepositorySection;
174
173
  files: CompressToolFileEntry[];
@@ -506,9 +505,9 @@ function analyzeCompressFile(
506
505
 
507
506
  /**
508
507
  * @brief Builds the full agent-oriented compression payload.
509
- * @details Validates requested paths against the filesystem, compresses processable files in caller order, preserves skipped and failed inputs in structured file entries, computes aggregate numeric totals, and emits repository scope metadata. Runtime is O(F log F + S). Side effects are limited to filesystem reads and optional stderr logging.
508
+ * @details Validates requested paths against the filesystem, compresses processable files in caller order, preserves skipped and failed inputs in structured file entries, computes aggregate numeric totals, and emits repository scope metadata without echoing request facts already known to the caller. Runtime is O(F log F + S). Side effects are limited to filesystem reads and optional stderr logging.
510
509
  * @param[in] options {BuildCompressToolPayloadOptions} Payload-construction options.
511
- * @return {CompressToolPayload} Structured compression payload ordered as request, summary, repository, and files.
510
+ * @return {CompressToolPayload} Structured compression payload ordered as summary, repository, and files.
512
511
  * @satisfies REQ-081, REQ-082, REQ-083, REQ-084, REQ-085, REQ-087
513
512
  */
514
513
  export function buildCompressToolPayload(options: BuildCompressToolPayloadOptions): CompressToolPayload {
@@ -593,18 +592,11 @@ export function buildCompressToolPayload(options: BuildCompressToolPayloadOption
593
592
  const compressedFiles = files.filter((file) => file.status === "compressed");
594
593
  const symbolAnalysisErrorCount = compressedFiles.filter((file) => file.symbol_analysis_status === "error").length;
595
594
 
595
+ void toolName;
596
+ void scope;
597
+ void lineNumberMode;
598
+ void canonicalRequestedPaths;
596
599
  return {
597
- request: {
598
- tool_name: toolName,
599
- scope,
600
- base_dir_path: absoluteBaseDir,
601
- line_number_mode: lineNumberMode,
602
- source_directory_count: sourceDirectoryPaths.length,
603
- source_directory_paths: [...sourceDirectoryPaths],
604
- requested_file_count: requestedPaths.length,
605
- requested_input_paths: [...requestedPaths],
606
- requested_canonical_paths: canonicalRequestedPaths,
607
- },
608
600
  summary: {
609
601
  processable_file_count: files.filter((file) => file.status !== "skipped").length,
610
602
  compressed_file_count: compressedFiles.length,