pi-usereq 0.11.0 → 0.13.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 (53) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +6 -6
  3. package/package.json +1 -1
  4. package/pi-usereq/docs/REFERENCES.md +1135 -834
  5. package/pi-usereq/docs/REQUIREMENTS.md +177 -110
  6. package/pi-usereq/docs/WORKFLOW.md +244 -79
  7. package/scripts/lib/extension-debug-harness.ts +2 -2
  8. package/scripts/tool-args-to-params.ts +2 -2
  9. package/src/cli.ts +12 -12
  10. package/src/core/config.ts +541 -180
  11. package/src/core/extension-status.ts +69 -12
  12. package/src/core/path-context.ts +19 -4
  13. package/src/core/pi-notify.ts +5 -5
  14. package/src/core/pi-usereq-tools.ts +4 -2
  15. package/src/core/prompt-command-catalog.ts +4 -5
  16. package/src/core/prompt-command-runtime.ts +183 -44
  17. package/src/core/prompts.ts +0 -2
  18. package/src/core/req-references-command.ts +175 -0
  19. package/src/core/req-reset-command.ts +323 -0
  20. package/src/core/resources.ts +6 -23
  21. package/src/core/settings-menu.ts +85 -28
  22. package/src/core/tool-runner.ts +26 -6
  23. package/src/index.ts +601 -116
  24. package/tests/attended-results-scenarios.ts +15 -9
  25. package/tests/cli-command-option-parity.test.ts +53 -35
  26. package/tests/debug-extension-harness.test.ts +8 -10
  27. package/tests/extension-registration.test.ts +1204 -205
  28. package/tests/helpers.ts +29 -6
  29. package/tests/oracle-project.test.ts +4 -4
  30. package/tests/oracle-standalone.test.ts +5 -5
  31. package/src/core/reference-payload.ts +0 -752
  32. package/src/resources/prompts/references.md +0 -64
  33. /package/tests/fixtures_attended_results/project/{references.json → summarize.json} +0 -0
  34. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_c.c.json +0 -0
  35. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_cpp.cpp.json +0 -0
  36. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_csharp.cs.json +0 -0
  37. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_elixir.ex.json +0 -0
  38. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_go.go.json +0 -0
  39. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_haskell.hs.json +0 -0
  40. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_java.java.json +0 -0
  41. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_javascript.js.json +0 -0
  42. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_kotlin.kt.json +0 -0
  43. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_lua.lua.json +0 -0
  44. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_perl.pl.json +0 -0
  45. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_php.php.json +0 -0
  46. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_python.py.json +0 -0
  47. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_ruby.rb.json +0 -0
  48. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_rust.rs.json +0 -0
  49. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_scala.scala.json +0 -0
  50. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_shell.sh.json +0 -0
  51. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_swift.swift.json +0 -0
  52. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_typescript.ts.json +0 -0
  53. /package/tests/fixtures_attended_results/standalone/{files-references → files-summarize}/fixture_zig.zig.json +0 -0
package/tests/helpers.ts CHANGED
@@ -8,8 +8,10 @@ import { createRequire } from "node:module";
8
8
  import {
9
9
  DEFAULT_DOCS_DIR,
10
10
  getDefaultConfig,
11
+ getGlobalConfigPath,
11
12
  getProjectConfigPath,
12
13
  saveConfig,
14
+ saveGlobalConfig,
13
15
  type StaticCheckLanguageConfig,
14
16
  type UseReqConfig,
15
17
  } from "../src/core/config.js";
@@ -31,6 +33,10 @@ const ORACLE_NODE_ROOT = fs.existsSync(path.join(ROOT, "node_modules"))
31
33
  : path.join(ROOT, "..", "PI-useReq");
32
34
  const ORACLE_STUBS_ROOT = path.join(ROOT, "tests", "python_oracle_stubs");
33
35
  const FIXTURES_DIR = path.join(ROOT, "tests", "fixtures");
36
+ const TEST_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "pi-usereq-home-"));
37
+ process.env.HOME = TEST_HOME;
38
+ process.env.USERPROFILE = TEST_HOME;
39
+ process.env.XDG_CONFIG_HOME = path.join(TEST_HOME, ".config");
34
40
 
35
41
  export function getFixtureFiles(): string[] {
36
42
  return fs
@@ -104,8 +110,16 @@ export function runPythonInline(code: string, cwd = ROOT, envOverrides?: NodeJS.
104
110
  });
105
111
  }
106
112
 
113
+ /**
114
+ * @brief Creates one temporary working directory and resets the isolated test global config.
115
+ * @details Allocates a unique directory under the system temp root, rewrites the process-scoped test global config file to documented defaults derived from the new project base, and returns the directory path. Runtime is O(n) in serialized config size. Side effects include directory creation and global-config file overwrite under the isolated test home.
116
+ * @param[in] prefix {string} Prefix forwarded to `fs.mkdtempSync(...)`.
117
+ * @return {string} Absolute temporary directory path.
118
+ */
107
119
  export function createTempDir(prefix: string): string {
108
- return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
120
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
121
+ saveGlobalConfig(getDefaultConfig(tempDir));
122
+ return tempDir;
109
123
  }
110
124
 
111
125
  /**
@@ -126,8 +140,8 @@ function writeOracleReqConfig(projectBase: string, config: UseReqConfig): void {
126
140
  }
127
141
 
128
142
  /**
129
- * @brief Persists both Node and Python-oracle project configs for parity tests.
130
- * @details Writes `.pi-usereq.json` for the TypeScript CLI and `.req/config.json` for the Python oracle using the same logical payload. Runtime is O(n) in serialized config size. Side effects include directory creation and file overwrite.
143
+ * @brief Persists Node local/global configs plus the Python-oracle mirror for parity tests.
144
+ * @details Writes split `.pi-usereq.json` and `~/.config/pi-usereq/config.json` files for the TypeScript runtime, then writes `.req/config.json` for the Python oracle using the same effective payload. Runtime is O(n) in serialized config size. Side effects include directory creation and file overwrite.
131
145
  * @param[in] projectBase {string} Fixture project root.
132
146
  * @param[in] config {UseReqConfig} Effective project configuration to persist.
133
147
  * @return {void} No return value.
@@ -138,15 +152,24 @@ export function saveFixtureConfigs(projectBase: string, config: UseReqConfig): v
138
152
  }
139
153
 
140
154
  /**
141
- * @brief Reads the raw persisted TypeScript project config JSON.
142
- * @details Loads `.pi-usereq.json` without normalization so tests can inspect merge order and unknown metadata preservation exactly as written. Runtime is O(n) in file size. Side effects are limited to filesystem reads.
155
+ * @brief Reads the raw persisted TypeScript local project config JSON.
156
+ * @details Loads `.pi-usereq.json` without normalization so tests can inspect local-scope merge order and unknown metadata preservation exactly as written. Runtime is O(n) in file size. Side effects are limited to filesystem reads.
143
157
  * @param[in] projectBase {string} Fixture project root.
144
- * @return {Record<string, unknown>} Parsed raw configuration object.
158
+ * @return {Record<string, unknown>} Parsed raw local configuration object.
145
159
  */
146
160
  export function readProjectConfigJson(projectBase: string): Record<string, unknown> {
147
161
  return JSON.parse(fs.readFileSync(getProjectConfigPath(projectBase), "utf8")) as Record<string, unknown>;
148
162
  }
149
163
 
164
+ /**
165
+ * @brief Reads the raw persisted TypeScript global config JSON.
166
+ * @details Loads `~/.config/pi-usereq/config.json` without normalization so tests can inspect global-scope merge order and unknown metadata preservation exactly as written. Runtime is O(n) in file size. Side effects are limited to filesystem reads.
167
+ * @return {Record<string, unknown>} Parsed raw global configuration object.
168
+ */
169
+ export function readGlobalConfigJson(): Record<string, unknown> {
170
+ return JSON.parse(fs.readFileSync(getGlobalConfigPath(), "utf8")) as Record<string, unknown>;
171
+ }
172
+
150
173
  /**
151
174
  * @brief Writes one executable shell script for integration tests.
152
175
  * @details Creates the parent directory when required, writes UTF-8 content, and marks the file owner-executable. Runtime is O(n) in script size. Side effects include directory creation, file overwrite, and permission changes.
@@ -35,7 +35,7 @@ test("project-scan commands match the Python oracle on a git-backed repository w
35
35
  fs.rmSync(projectBase, { recursive: true, force: true });
36
36
  });
37
37
 
38
- await t.test("references", () => compareCli(["--references"], projectBase));
38
+ await t.test("summarize", () => compareCli(["--summarize"], projectBase));
39
39
  await t.test("compress", () => compareCli(["--compress"], projectBase));
40
40
  await t.test("compress with line numbers", () => compareCli(["--compress", "--enable-line-numbers"], projectBase));
41
41
  await t.test("find", () => {
@@ -53,9 +53,9 @@ test("project-scan source extraction preserves leading tabs for Go sources", (t)
53
53
  fs.rmSync(projectBase, { recursive: true, force: true });
54
54
  });
55
55
 
56
- const references = runNodeCli(["--references"], projectBase);
57
- assert.equal(references.status, 0, references.stderr);
58
- assert.match(references.stdout, /\tvar wg sync\.WaitGroup/);
56
+ const summarize = runNodeCli(["--summarize"], projectBase);
57
+ assert.equal(summarize.status, 0, summarize.stderr);
58
+ assert.match(summarize.stdout, /\tvar wg sync\.WaitGroup/);
59
59
 
60
60
  const compress = runNodeCli(["--compress", "--enable-line-numbers"], projectBase);
61
61
  assert.equal(compress.status, 0, compress.stderr);
@@ -31,8 +31,8 @@ test("standalone command outputs match the Python oracle for fixtures without pr
31
31
  if (fileName === TAB_SENSITIVE_FIXTURE_NAME) {
32
32
  continue;
33
33
  }
34
- await t.test(`files-references ${fileName}`, () => {
35
- compareCli(["--files-references", fixture]);
34
+ await t.test(`files-summarize ${fileName}`, () => {
35
+ compareCli(["--files-summarize", fixture]);
36
36
  });
37
37
  await t.test(`files-compress ${fileName}`, () => {
38
38
  compareCli(["--files-compress", fixture]);
@@ -54,9 +54,9 @@ test("standalone source extraction preserves leading tabs for the Go fixture", (
54
54
  assert.ok(fixture, `missing ${TAB_SENSITIVE_FIXTURE_NAME}`);
55
55
  const cwd = path.dirname(fixture);
56
56
 
57
- const references = runNodeCli(["--files-references", fixture], cwd);
58
- assert.equal(references.status, 0, references.stderr);
59
- assert.match(references.stdout, /\tvar wg sync\.WaitGroup/);
57
+ const summarize = runNodeCli(["--files-summarize", fixture], cwd);
58
+ assert.equal(summarize.status, 0, summarize.stderr);
59
+ assert.match(summarize.stdout, /\tvar wg sync\.WaitGroup/);
60
60
 
61
61
  const compress = runNodeCli(["--files-compress", fixture, "--enable-line-numbers"], cwd);
62
62
  assert.equal(compress.status, 0, compress.stderr);