prodex 2.0.1 → 2.1.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 (119) hide show
  1. package/README.md +367 -146
  2. package/dist/app/dependency-source-provider.d.ts +2 -0
  3. package/dist/app/dependency-source-provider.js +66 -0
  4. package/dist/app/entry-resolver.d.ts +7 -0
  5. package/dist/app/entry-resolver.js +26 -0
  6. package/dist/app/execute-run.d.ts +2 -2
  7. package/dist/app/execute-run.js +138 -37
  8. package/dist/app/git-source-provider.d.ts +4 -0
  9. package/dist/app/git-source-provider.js +551 -0
  10. package/dist/app/grep-source-provider.d.ts +2 -0
  11. package/dist/app/grep-source-provider.js +226 -0
  12. package/dist/app/planner.d.ts +12 -0
  13. package/dist/app/planner.js +106 -0
  14. package/dist/app/planners/attachment-options.d.ts +2 -0
  15. package/dist/app/planners/attachment-options.js +39 -0
  16. package/dist/app/planners/git-plan.d.ts +13 -0
  17. package/dist/app/planners/git-plan.js +141 -0
  18. package/dist/app/planners/grep-plan.d.ts +13 -0
  19. package/dist/app/planners/grep-plan.js +115 -0
  20. package/dist/app/planners/list-utils.d.ts +1 -0
  21. package/dist/app/planners/list-utils.js +6 -0
  22. package/dist/app/planners/pack-plan.d.ts +13 -0
  23. package/dist/app/planners/pack-plan.js +65 -0
  24. package/dist/app/planners/scope-plan.d.ts +17 -0
  25. package/dist/app/planners/scope-plan.js +143 -0
  26. package/dist/app/planners/trace-plan.d.ts +13 -0
  27. package/dist/app/planners/trace-plan.js +77 -0
  28. package/dist/app/source-collector.d.ts +5 -0
  29. package/dist/app/source-collector.js +33 -0
  30. package/dist/app/target-resolver.d.ts +7 -0
  31. package/dist/app/target-resolver.js +110 -0
  32. package/dist/cli/cli-input.js +70 -19
  33. package/dist/cli/flag-specs.d.ts +7 -3
  34. package/dist/cli/flag-specs.js +58 -8
  35. package/dist/cli/help-specs.d.ts +205 -0
  36. package/dist/cli/help-specs.js +136 -0
  37. package/dist/cli/help.js +107 -28
  38. package/dist/cli/report-command.js +35 -23
  39. package/dist/commands/{run-command.d.ts → git-command.d.ts} +3 -3
  40. package/dist/commands/git-command.js +7 -0
  41. package/dist/commands/grep-command.d.ts +11 -0
  42. package/dist/commands/grep-command.js +7 -0
  43. package/dist/commands/pack-command.d.ts +11 -0
  44. package/dist/commands/pack-command.js +7 -0
  45. package/dist/commands/scope-command.d.ts +12 -0
  46. package/dist/commands/scope-command.js +7 -0
  47. package/dist/commands/shared-runner.d.ts +12 -0
  48. package/dist/commands/shared-runner.js +30 -0
  49. package/dist/commands/trace-command.d.ts +11 -0
  50. package/dist/commands/trace-command.js +7 -0
  51. package/dist/config/default-config.js +7 -11
  52. package/dist/config/load.d.ts +1 -0
  53. package/dist/config/load.js +269 -4
  54. package/dist/config/migration/detect.d.ts +2 -1
  55. package/dist/config/migration/detect.js +10 -2
  56. package/dist/config/migration/messages.js +12 -11
  57. package/dist/config/migration/transform.js +77 -32
  58. package/dist/filesystem/binary.d.ts +2 -0
  59. package/dist/filesystem/binary.js +30 -0
  60. package/dist/filesystem/entry-discovery.d.ts +14 -0
  61. package/dist/filesystem/entry-discovery.js +78 -0
  62. package/dist/filesystem/file-set.d.ts +7 -0
  63. package/dist/filesystem/file-set.js +57 -0
  64. package/dist/filesystem/glob-scan.d.ts +6 -2
  65. package/dist/filesystem/glob-scan.js +12 -7
  66. package/dist/filesystem/path-patterns.d.ts +20 -0
  67. package/dist/filesystem/path-patterns.js +70 -0
  68. package/dist/index.js +51 -29
  69. package/dist/output/markdown-sections.d.ts +5 -0
  70. package/dist/output/markdown-sections.js +103 -0
  71. package/dist/output/markdown-toc.d.ts +31 -0
  72. package/dist/output/markdown-toc.js +287 -0
  73. package/dist/output/markdown.d.ts +5 -8
  74. package/dist/output/markdown.js +80 -127
  75. package/dist/output/produce-output.d.ts +4 -1
  76. package/dist/output/produce-output.js +6 -7
  77. package/dist/output/render-helpers.d.ts +4 -0
  78. package/dist/output/render-helpers.js +14 -0
  79. package/dist/output/text.d.ts +2 -2
  80. package/dist/output/text.js +47 -8
  81. package/dist/resolvers/js/resolve-alias.js +10 -41
  82. package/dist/resolvers/php/bindings.js +6 -6
  83. package/dist/resolvers/php/extract-imports.d.ts +19 -7
  84. package/dist/resolvers/php/extract-imports.js +146 -26
  85. package/dist/resolvers/php/php-resolver.js +55 -24
  86. package/dist/resolvers/php/psr4.d.ts +1 -1
  87. package/dist/resolvers/php/psr4.js +7 -1
  88. package/dist/runtime/shell-command-runner.d.ts +5 -0
  89. package/dist/runtime/shell-command-runner.js +118 -0
  90. package/dist/tracing/collect-trace.d.ts +10 -0
  91. package/dist/tracing/collect-trace.js +23 -0
  92. package/dist/tracing/exclude.d.ts +0 -5
  93. package/dist/tracing/exclude.js +16 -12
  94. package/dist/tracing/follow-chain.js +2 -2
  95. package/dist/types/app.types.d.ts +37 -8
  96. package/dist/types/artifact.types.d.ts +50 -0
  97. package/dist/types/artifact.types.js +2 -0
  98. package/dist/types/cli.types.d.ts +52 -4
  99. package/dist/types/config.types.d.ts +37 -20
  100. package/dist/types/index.d.ts +2 -0
  101. package/dist/types/index.js +2 -0
  102. package/dist/types/output.types.d.ts +12 -3
  103. package/dist/types/planner.types.d.ts +76 -0
  104. package/dist/types/planner.types.js +2 -0
  105. package/dist/types/resolver.types.d.ts +1 -1
  106. package/dist/types/tracing.types.d.ts +0 -11
  107. package/package.json +2 -2
  108. package/schema/prodex.schema.json +59 -41
  109. package/dist/app/run-plans.d.ts +0 -11
  110. package/dist/app/run-plans.js +0 -61
  111. package/dist/commands/profiles-command.d.ts +0 -6
  112. package/dist/commands/profiles-command.js +0 -16
  113. package/dist/commands/run-command.js +0 -17
  114. package/dist/config/build-config.d.ts +0 -13
  115. package/dist/config/build-config.js +0 -127
  116. package/dist/tracing/include-files.d.ts +0 -2
  117. package/dist/tracing/include-files.js +0 -36
  118. package/dist/tracing/trace-run.d.ts +0 -2
  119. package/dist/tracing/trace-run.js +0 -21
package/README.md CHANGED
@@ -1,239 +1,460 @@
1
1
  # Prodex
2
2
 
3
- Focused code-context extraction for large, multi-file projects.
3
+ Prodex packages the code an AI tool, reviewer, or teammate needs to see into readable Markdown or TXT.
4
4
 
5
- Prodex starts from real project entrypoints, follows supported dependencies, adds explicitly included files, and exports a clean Markdown trace. It helps you isolate the files that matter for a feature, review, debug session, documentation pass, handoff, or AI-assisted workflow without manually collecting every related file.
5
+ Use it to snapshot Git changes, collect files by search, save repeatable scopes, attach command output, or gather explicit files without copy-pasting half your repo into a chat window.
6
6
 
7
- Prodex is intentionally narrow: it creates readable, reproducible context bundles. It is not trying to be a full IDE indexer, static analysis platform, architecture rule engine, or graph visualizer.
7
+ ## Installation
8
8
 
9
- ## Why Prodex
9
+ ```bash
10
+ npm install -g prodex
11
+ ```
10
12
 
11
- Large projects make context gathering expensive. A feature can start in one route or component, then spread through shared utilities, types, controllers, services, bindings, and framework conventions. Copying those files by hand is slow, inconsistent, and easy to get wrong.
13
+ Or run it ad hoc without installing:
12
14
 
13
- Prodex gives that workflow a repeatable shape:
15
+ ```bash
16
+ npx prodex git --against origin/main
17
+ ```
14
18
 
15
- 1. Choose one or more entry files or globs.
16
- 2. Trace the dependencies Prodex can resolve.
17
- 3. Add any extra files you explicitly include.
18
- 4. Exclude noisy paths such as generated output, vendor code, or UI primitives.
19
- 5. Export a Markdown bundle with an index and file sections.
19
+ Create a starter config:
20
20
 
21
- The result is a focused project trace you can read, share, review, archive, or hand to another tool.
21
+ ```bash
22
+ prodex init
23
+ ```
22
24
 
23
- ## How It Works
25
+ ## Quick Start
24
26
 
25
27
  ```bash
26
- prodex run --entry src/index.ts
28
+ # Package all files changed in your current branch vs. origin/main
29
+ prodex git --against origin/main
30
+
31
+ # Include the diff beside the changed files
32
+ prodex git --changed --include-diff
33
+
34
+ # Collect every file that references a term or symbol
35
+ prodex grep --query "StripeWebhookHandler"
36
+
37
+ # Run a saved context selection
38
+ prodex scope -k billing
39
+
40
+ # Attach test output beside the code
41
+ prodex scope -k auth --cmd "npm test -- auth"
42
+
43
+ # Collect explicit files without dependency tracing
44
+ prodex pack -i src/config/database.ts,src/models/User.ts,docs/schema.md
45
+
46
+ # Trace imports from an entry file (JS, TS, PHP)
47
+ prodex trace -t src/api/router.ts
27
48
  ```
28
49
 
29
- Prodex resolves the requested entrypoints from your project root, follows supported dependency references, applies include and exclude rules, then writes a versioned Markdown file to `./prodex/` by default.
50
+ By default, commands write a versioned Markdown file to `./prodex/`. You can switch to TXT with `--format txt`. Output filenames include a `-trace` suffix and a timestamp when versioning is enabled (e.g. `billing-trace_260620-0430.md`). The output includes a file index, line ranges, and the collected source content in a single readable document.
51
+
52
+ ## Common Workflows
30
53
 
31
- For example:
54
+ ### Review your current branch against origin/main
32
55
 
33
56
  ```bash
34
- prodex run --entry resources/js/pages/Dashboard.tsx --include "routes/**/*.php"
57
+ prodex git --against origin/main
35
58
  ```
36
59
 
37
- This traces the dashboard entrypoint and adds the matching route files to the exported context.
60
+ Snapshots every file changed between your current HEAD and the merge-base with `origin/main`. Good for pre-PR review or sending a branch summary to an AI assistant.
38
61
 
39
- ## Profiles
62
+ ### Include the diff beside changed files
40
63
 
41
- Profiles are reusable named context maps stored in `prodex.json`.
64
+ ```bash
65
+ prodex git --changed --include-diff
66
+ ```
42
67
 
43
- They are one of Prodex's most useful workflow features: instead of rebuilding the same trace commands every time, teams can save important project areas as named profiles such as `dashboard`, `auth`, `billing`, `api`, `admin`, or `checkout`.
68
+ Includes the raw Git diff in the output alongside the collected files. In working-tree mode, two diff sections are added: one for unstaged changes and one for staged changes.
69
+
70
+ ### Collect files by search
44
71
 
45
72
  ```bash
46
- prodex run --profile dashboard
47
- prodex run --profile auth,billing
48
- prodex run --all
49
- prodex profiles
73
+ prodex grep --query "legacyPaymentClient"
74
+ prodex grep --any "AuthService,SessionManager"
75
+ prodex grep --regex "use.*Repository"
50
76
  ```
51
77
 
52
- Use profiles when a project has recurring review surfaces or ownership areas. A profile can define its own entries, includes, excludes, and optional output name; when no output name is set, the profile key becomes the trace basename. This makes context extraction repeatable across debugging, reviews, documentation, handoffs, and release work. Run one profile, a comma-separated set of profiles, or all profiles with `--all` when you need a broader pass.
78
+ Finds files containing the term or pattern and packages them into one document. Use this when the files you need are spread across the codebase and defined by what they reference, not where they live.
53
79
 
54
- Example:
80
+ ### Run a saved scope
55
81
 
56
- ```json
57
- {
58
- "version": 4,
59
- "$schema": "https://raw.githubusercontent.com/emxhive/prodex/main/schema/prodex.schema.json",
60
- "output": {
61
- "dir": "prodex",
62
- "format": "md",
63
- "versioned": true
64
- },
65
- "entry": [],
66
- "include": [],
67
- "exclude": ["node_modules/**", "vendor/**", "dist/**"],
68
- "resolve": {
69
- "aliases": {
70
- "@": "resources/js"
71
- },
72
- "maxDepth": 10,
73
- "maxFiles": 200
74
- },
75
- "profiles": {
76
- "dashboard": {
77
- "entry": ["resources/js/pages/Dashboard.tsx"],
78
- "include": ["routes/**/*.php", "resources/js/types/**/*.d.ts"],
79
- "exclude": ["resources/js/components/ui/**"]
80
- },
81
- "api": {
82
- "entry": ["routes/api.php"],
83
- "include": ["app/Http/Requests/**/*.php"],
84
- "exclude": ["vendor/**"]
85
- }
86
- }
87
- }
82
+ ```bash
83
+ prodex scope -k billing
84
+ prodex scope -k auth,billing
85
+ prodex scope --all
88
86
  ```
89
87
 
90
- ## Markdown Output
88
+ Runs a named context selection you configured in `prodex.json`. Scopes are the repeatable version of an ad hoc command — same files, every time, no manual reassembly.
91
89
 
92
- Markdown is the primary Prodex output.
90
+ ### Attach command output beside the code
93
91
 
94
- Each generated trace includes:
92
+ ```bash
93
+ prodex scope -k auth --cmd "npm test -- auth"
94
+ prodex git --against origin/main --cmd "npm run lint"
95
+ ```
95
96
 
96
- - A file index
97
- - A total file count marker
98
- - Links to each exported file section
99
- - Line ranges for the generated sections
100
- - Syntax-highlighted code fences where possible
101
- - The collected source content in one readable bundle
97
+ Runs the command after collecting files and embeds its output in the document. The AI sees the failing test or lint result right next to the source that produced it.
102
98
 
103
- Versioned filenames are enabled by default so repeated runs do not overwrite earlier traces.
99
+ ### Collect explicit files
104
100
 
105
- ## Current Support
101
+ ```bash
102
+ prodex pack -i src/config/database.ts,src/models/User.ts,docs/schema.md
103
+ prodex pack -i "app/Http/Controllers/**"
104
+ ```
106
105
 
107
- Prodex's broader identity is controlled context extraction, not a single-framework tool.
106
+ Adds files directly by path or glob without dependency tracing. Use this when you know exactly which files you want and do not need imports followed automatically.
108
107
 
109
- Include-only extraction is language-agnostic: any source or text file matched by `--include` or a profile `include` rule can be added to a trace.
108
+ ### Trace imports from an entry file
110
109
 
111
- Dependency tracing is resolver-based. Today Prodex traces JavaScript, TypeScript, TSX, declaration files, and PHP entrypoints. Current tracing support includes JS/TS imports, dynamic imports, CommonJS `require`, re-exports, static PHP include/require statements, PHP namespace imports, PSR-4 resolution, and some Laravel binding awareness.
110
+ ```bash
111
+ prodex trace -t src/api/router.ts
112
+ prodex pack -e app/Http/Controllers/CheckoutController.php
113
+ ```
112
114
 
113
- Unsupported or dynamic relationships may need to be added with `--include` or profile `include` rules. That is expected: Prodex favors a focused, readable trace over pretending to understand every runtime edge in a project.
115
+ Follows import and require statements from the entry file to collect the files it depends on. Supported for JavaScript, TypeScript, TSX, declaration files, and PHP. See [Dependency Tracing](#dependency-tracing) for current language support details.
114
116
 
115
- ## Installation
117
+ `prodex trace` resolves targets by exact path, extensionless name, or bare module name — it does not accept glob patterns. Use `prodex pack --entry <glob>` to collect files by glob.
118
+
119
+ ## How Prodex Collects Context
120
+
121
+ Prodex can collect context from Git changes, search results, saved scopes, explicit files, or traced entrypoints. Command output can be attached to any run.
122
+
123
+ ### Git
124
+
125
+ `prodex git` reads your repository's Git history or working tree and snapshots the files involved.
126
+
127
+ Working-tree modes read file contents from disk:
128
+ - `--changed` (default): staged, unstaged, and untracked files
129
+ - `--staged`: staged files only
130
+ - `--unstaged`: unstaged files only
131
+ - `--untracked`: untracked files only
132
+
133
+ Historical modes read file contents from Git instead of the working tree:
134
+ - `--commit <rev>`: files changed by one commit; contents from that commit
135
+ - `--range <base..head>` or `<base...head>`: files changed between two refs; contents from `head`
136
+ - `--against <base>`: files changed between the merge-base of `<base>` and `HEAD`; contents from `HEAD`
137
+
138
+ Add `--include-diff` to any git run to include the raw diff output alongside the file contents. In working-tree mode this adds two sections — one for unstaged changes (`Full Diff`) and one for staged changes (`Cached Full Diff`).
139
+
140
+ ### Search
141
+
142
+ `prodex grep` searches your project for files containing a term or pattern and packages the matching files.
143
+
144
+ Search modes:
145
+ - `--query <text>`: files containing a fixed string
146
+ - `--any <list>`: files containing any of the terms (OR)
147
+ - `--all <list>`: files containing all of the terms (AND)
148
+ - `--regex <pattern>`: files matching a regular expression
149
+
150
+ Narrow the search with `--within <path>` or exclude paths with `--skip <path>`. Filter out files whose contents contain a term using `--not <text>`.
151
+
152
+ ### Scopes
153
+
154
+ Saved named selections in `prodex.json`. See [Saved Scopes](#saved-scopes).
155
+
156
+ ### Pack
157
+
158
+ `prodex pack` accepts `--include` for direct file collection, `--entry` to trace imports from an entry file, or both together. It is the same tracing engine as `prodex trace` with the option to mix in explicit files in the same run.
159
+
160
+ ### Command Output
161
+
162
+ `--cmd` runs a shell command after files are collected and embeds the output in the document. See [Command Attachments](#command-attachments).
163
+
164
+ ## Saved Scopes
165
+
166
+ Scopes are named, reusable context selections you configure once in `prodex.json` and run any time.
167
+
168
+ A scope can collect files in two ways:
169
+
170
+ - **By path**: select files and folders you know by name.
171
+ - **By search**: select files by what they contain.
116
172
 
117
173
  ```bash
118
- npm install -g prodex
174
+ prodex scope -k dashboard # run one scope
175
+ prodex scope -k auth,billing # run multiple
176
+ prodex scope --all # run all configured scopes
177
+ prodex scope --list # show available scope keys
119
178
  ```
120
179
 
121
- Or run it ad hoc:
180
+ ### File scope example
122
181
 
123
- ```bash
124
- npx prodex run --entry src/index.ts
182
+ Selects files by path, with optional dependency tracing from `entry` files:
183
+
184
+ ```json
185
+ {
186
+ "version": 5,
187
+ "scopes": {
188
+ "dashboard": {
189
+ "entry": ["resources/js/pages/Dashboard.tsx"],
190
+ "include": ["routes/web.php"],
191
+ "exclude": ["resources/js/components/ui"]
192
+ }
193
+ }
194
+ }
125
195
  ```
126
196
 
127
- Create a starter config:
197
+ `entry` traces imports. `include` adds files directly. Both are optional — a scope can use either or both.
128
198
 
129
- ```bash
130
- prodex init
199
+ ### Search scope example
200
+
201
+ Selects files by what they contain:
202
+
203
+ ```json
204
+ {
205
+ "version": 5,
206
+ "scopes": {
207
+ "payments": {
208
+ "grep": {
209
+ "query": "StripeWebhookHandler",
210
+ "within": ["app", "tests"],
211
+ "skip": ["vendor"]
212
+ }
213
+ }
214
+ }
215
+ }
131
216
  ```
132
217
 
133
- ## Common Commands
218
+ Search scope options under `grep`:
219
+ - `query`: fixed-string match
220
+ - `any`: list — files containing any term
221
+ - `all`: list — files containing all terms
222
+ - `regex`: regular expression
223
+ - `not`: filter out files whose contents contain these terms
224
+ - `within`: search only these paths
225
+ - `skip`: skip these paths
134
226
 
135
- ```bash
136
- prodex run [root] --entry src/index.ts
137
- prodex run [root] --entry routes/web.php --include "**/*.d.ts"
138
- prodex run [root] --profile dashboard
139
- prodex run [root] --profile dashboard,api
140
- prodex run [root] --all
141
- prodex profiles [root]
142
- prodex migrate [root]
227
+ A scope can collect by path using `entry` and/or `include`, or by search using `grep`. A search scope may also use `include` for extra files, but it cannot define `entry`.
228
+
229
+ ### Scope keys and names
230
+
231
+ The scope key is the identifier used in CLI selection. The optional `name` field sets the output filename:
232
+
233
+ ```json
234
+ "scopes": {
235
+ "dashboard": {
236
+ "name": "frontend-dashboard",
237
+ "entry": ["resources/js/pages/Dashboard.tsx"]
238
+ }
239
+ }
143
240
  ```
144
241
 
145
- `prodex run` requires the `run` command. Root-only positional command shortcuts are intentionally not supported.
242
+ ```bash
243
+ prodex scope -k dashboard # output filename: frontend-dashboard
244
+ ```
146
245
 
147
- ## CLI Reference
246
+ If `name` is omitted, the scope key is used as the output filename.
148
247
 
149
- | Flag | Short | Type | Description |
150
- | --- | --- | --- | --- |
151
- | `--entry` | `-e` | list | Entry file or glob to trace. Repeatable and comma-aware. |
152
- | `--include` | `-i` | list | Extra file or glob to add without dependency tracing. Repeatable and comma-aware. |
153
- | `--exclude` | `-x` | list | File or glob to skip during traversal. Repeatable and comma-aware. |
154
- | `--profile` | `-p` | list | Named profile to run. Comma-aware and repeatable. |
155
- | `--all` | `-a` | boolean | Run every configured profile. `--all-profiles` remains available as an explicit alias. |
156
- | `--name` | `-n` | string | Output basename for this run. |
157
- | `--format` | `-F` | `md`/`txt` | Output format. Markdown is the default. |
158
- | `--max-depth` | | number | Maximum dependency traversal depth. |
159
- | `--max-files` | | number | Maximum traced file count. |
248
+ ## Command Attachments
160
249
 
161
- Global metadata flags:
250
+ Add `--cmd` to any run to capture shell command output and embed it in the document alongside the collected files.
162
251
 
163
252
  ```bash
164
- prodex --version
165
- prodex run --help
166
- prodex profiles --help
167
- prodex migrate --help
253
+ prodex scope -k auth --cmd "npm test -- auth"
254
+ prodex git --against origin/main --cmd "npm run lint"
255
+ prodex pack -e src/index.ts --cmd "npm run build"
168
256
  ```
169
257
 
258
+ `--cmd` is repeatable. Commands run sequentially after files are collected, and each output is included as a separate section.
259
+
260
+ By default, a failed command adds a warning but still produces the output file. Use `--fail-on-cmd-error` to exit with an error instead.
261
+
262
+ Use `--dry-run` to preview which commands would run without executing them.
263
+
264
+ ## Dependency Tracing
265
+
266
+ `prodex pack --entry` and `prodex trace` follow import statements from an entry file to collect the files it depends on.
267
+
268
+ **Currently supported:**
269
+
270
+ - JavaScript and TypeScript: ES module imports, dynamic imports, CommonJS `require`, re-exports
271
+ - TSX and declaration files (`.d.ts`)
272
+ - PHP: static `include`/`require` statements, namespace imports, PSR-4 resolution, some Laravel service binding awareness
273
+
274
+ **Limitations:**
275
+
276
+ - Dynamic imports that are computed at runtime may not be followed
277
+ - Framework-injected dependencies (e.g., auto-resolved services, IoC containers) may not be resolved automatically
278
+ - Languages other than JS, TS, TSX, and PHP are not traced — use `--include` or a file scope to add those files directly
279
+
280
+ When tracing does not follow a relationship, add the file manually with `--include` or in the scope's `include` list. Prodex does not attempt to guess at runtime behaviour.
281
+
170
282
  ## Configuration
171
283
 
172
- Prodex reads `prodex.json` from the project root.
284
+ Prodex reads `prodex.json` from the project root. All fields are optional — Prodex works without a config file.
173
285
 
174
286
  ```json
175
287
  {
176
- "version": 4,
177
- "$schema": "https://raw.githubusercontent.com/emxhive/prodex/main/schema/prodex.schema.json",
178
- "output": {
179
- "dir": "prodex",
180
- "format": "md",
181
- "versioned": true
182
- },
183
- "entry": ["src/index.ts"],
184
- "include": [],
185
- "exclude": ["node_modules/**", "vendor/**", "dist/**"],
186
- "resolve": {
187
- "aliases": {
188
- "@": "resources/js"
189
- },
190
- "maxDepth": 10,
191
- "maxFiles": 200
192
- },
193
- "profiles": {}
288
+ "version": 5,
289
+ "$schema": "https://raw.githubusercontent.com/emxhive/prodex/main/schema/prodex.schema.json",
290
+ "output": {
291
+ "dir": "prodex",
292
+ "format": "md",
293
+ "versioned": true
294
+ },
295
+ "exclude": ["node_modules", "vendor", "dist"],
296
+ "aliases": {
297
+ "@": "resources/js"
298
+ },
299
+ "depth": 2,
300
+ "scopes": {}
194
301
  }
195
302
  ```
196
303
 
197
- Naming precedence:
304
+ `exclude`, `include`, and similar path fields accept file paths, folder names, or glob patterns.
198
305
 
199
- 1. `--name`
200
- 2. `profile.name`
201
- 3. Profile key, when running a named profile
202
- 4. Automatic name from entries
306
+ **Naming precedence** (highest to lowest):
307
+
308
+ 1. `--name` flag
309
+ 2. `scope.name` in config
310
+ 3. Scope key, when running a configured scope
311
+ 4. Automatic name derived from entries
203
312
  5. Internal fallback: `combined`
204
313
 
205
- CLI flags override config values for a run. Profile arrays replace base arrays for that profile run.
314
+ CLI flags override config values for a run. Excludes are additive: root excludes, scope excludes, and CLI excludes are all applied together.
206
315
 
207
- ## Migrating Configs
316
+ ## CLI Reference
317
+
318
+ ### `git` — Snapshot Git changes
319
+
320
+ ```bash
321
+ prodex git [root] --against <base>
322
+ prodex git [root] --changed
323
+ prodex git [root] --staged
324
+ prodex git [root] --unstaged
325
+ prodex git [root] --untracked
326
+ prodex git [root] --commit <rev>
327
+ prodex git [root] --range <base..head>
328
+ prodex git [root] --range <base...head>
329
+ ```
330
+
331
+ | Flag | Type | Description |
332
+ |---|---|---|
333
+ | `--changed` | boolean | Staged, unstaged, and untracked files (default) |
334
+ | `--staged` | boolean | Staged files only |
335
+ | `--unstaged` | boolean | Unstaged files only |
336
+ | `--untracked` | boolean | Untracked files only |
337
+ | `--commit <rev>` | string | Files changed by one commit; contents from that commit |
338
+ | `--range <spec>` | string | Files changed between two refs; contents from head |
339
+ | `--against <base>` | string | Files changed between merge-base and HEAD |
340
+ | `--include-diff` | boolean | Include full diff output in the document |
341
+ | `--include` / `-i` | list | Extra files to add |
342
+ | `--exclude` / `-x` | list | Files or paths to skip |
343
+ | `--name` / `-n` | string | Output filename |
344
+ | `--format` / `-F` | `md`/`txt` | Output format |
345
+ | `--cmd` | list | Command to run and embed. Repeatable. |
346
+ | `--fail-on-cmd-error` | boolean | Exit nonzero if an attached command fails |
347
+ | `--dry-run` | boolean | Preview without writing output |
348
+
349
+ ### `grep` — Collect files by search
350
+
351
+ ```bash
352
+ prodex grep [root] --query <text>
353
+ prodex grep [root] --any <term,term,...>
354
+ prodex grep [root] --all <term,term,...>
355
+ prodex grep [root] --regex <pattern>
356
+ ```
208
357
 
209
- Prodex requires config version 4. If a project has an older `prodex.json`, `prodex run` and `prodex profiles` fail with migration instructions instead of guessing.
358
+ | Flag | Short | Type | Description |
359
+ |---|---|---|---|
360
+ | `--query` | `-q` | string | Fixed-string search |
361
+ | `--any` | | list | Files containing any of the terms (OR) |
362
+ | `--all` | | list | Files containing all of the terms (AND) |
363
+ | `--regex` | `-r` | string | Regular expression search |
364
+ | `--not` | | list | Filter out files whose contents contain these terms |
365
+ | `--within` | | list | Search only inside these paths |
366
+ | `--skip` | | list | Skip these paths during search |
367
+ | `--include` | `-i` | list | Add extra files |
368
+ | `--exclude` | `-x` | list | Skip these files |
369
+ | `--name` | `-n` | string | Output filename |
370
+ | `--format` | `-F` | `md`/`txt` | Output format |
371
+ | `--cmd` | | list | Command to run and embed. Repeatable. |
372
+ | `--fail-on-cmd-error` | | boolean | Exit nonzero if an attached command fails |
373
+ | `--dry-run` | | boolean | Preview without writing output |
374
+
375
+ ### `scope` — Run saved scopes
210
376
 
211
- Preview a migration:
377
+ ```bash
378
+ prodex scope [root] -k <key>
379
+ prodex scope [root] -k <key,key,...>
380
+ prodex scope [root] --all
381
+ prodex scope [root] --list
382
+ ```
383
+
384
+ | Flag | Short | Type | Description |
385
+ |---|---|---|---|
386
+ | `--key` | `-k` | list | Scope key to run. Comma-aware and repeatable. |
387
+ | `--all` | `-a` | boolean | Run all configured scopes |
388
+ | `--list` | | boolean | List configured scope keys |
389
+ | `--exclude` | `-x` | list | Additional paths to skip |
390
+ | `--format` | `-F` | `md`/`txt` | Output format |
391
+ | `--cmd` | | list | Command to run and embed. Repeatable. |
392
+ | `--fail-on-cmd-error` | | boolean | Exit nonzero if an attached command fails |
393
+ | `--dry-run` | | boolean | Preview without writing output |
394
+
395
+ ### `pack` — Collect explicit files or combine sources
212
396
 
213
397
  ```bash
214
- prodex migrate
398
+ prodex pack [root] -i <glob>
399
+ prodex pack [root] -e <entry> -i <glob>
215
400
  ```
216
401
 
217
- Check whether migration is needed:
402
+ | Flag | Short | Type | Description |
403
+ |---|---|---|---|
404
+ | `--entry` | `-e` | list | Entry file to trace imports from. Repeatable and comma-aware. |
405
+ | `--include` | `-i` | list | File or glob to add without tracing. Repeatable and comma-aware. |
406
+ | `--exclude` | `-x` | list | File or path to skip. |
407
+ | `--scope` | `-s` | list | Merge a configured scope's files into this pack. |
408
+ | `--name` | `-n` | string | Output filename |
409
+ | `--format` | `-F` | `md`/`txt` | Output format |
410
+ | `--depth` | | number | Maximum tracing depth |
411
+ | `--cmd` | | list | Command to run and embed. Repeatable. |
412
+ | `--fail-on-cmd-error` | | boolean | Exit nonzero if an attached command fails |
413
+ | `--dry-run` | | boolean | Preview without writing output |
414
+
415
+ ### `trace` — Trace imports from an entry file
218
416
 
219
417
  ```bash
220
- prodex migrate --check
418
+ prodex trace [root] -t <file>
221
419
  ```
222
420
 
223
- Write the migration:
421
+ | Flag | Short | Type | Description |
422
+ |---|---|---|---|
423
+ | `--target` | `-t` | list | File or module name to trace from. Accepts exact paths, extensionless names, or bare module names — not globs. Repeatable and comma-aware. |
424
+ | `--include` | `-i` | list | Extra files to add |
425
+ | `--exclude` | `-x` | list | Files or paths to skip |
426
+ | `--name` | `-n` | string | Output filename |
427
+ | `--format` | `-F` | `md`/`txt` | Output format |
428
+ | `--depth` | | number | Maximum tracing depth |
429
+ | `--cmd` | | list | Command to run and embed. Repeatable. |
430
+ | `--fail-on-cmd-error` | | boolean | Exit nonzero if an attached command fails |
431
+ | `--dry-run` | | boolean | Preview without writing output |
432
+
433
+ ### Global flags
224
434
 
225
435
  ```bash
226
- prodex migrate --write
436
+ prodex --version
437
+ prodex --help
438
+ prodex <command> --help
227
439
  ```
228
440
 
229
- `--write` creates a backup before replacing `prodex.json`.
441
+ ## Migrating Configs
442
+
443
+ Prodex requires config version 5. If your project has an older `prodex.json`, Prodex will fail with a prompt to migrate.
444
+
445
+ ```bash
446
+ prodex migrate # preview the migration
447
+ prodex migrate --check # exit nonzero if migration is needed
448
+ prodex migrate --write # apply the migration (creates a backup first)
449
+ ```
230
450
 
231
451
  ## Requirements
232
452
 
233
453
  - Node.js 22+
234
- - A project with JS, TS, TSX, declaration-file, or PHP entrypoints for dependency tracing
235
- - Any file type can be added through include-only extraction
236
- - Optional `prodex.json` for saved defaults and profiles
454
+ - `prodex.json` is optional; Prodex works without one
455
+ - Dependency tracing requires JS, TS, TSX, or PHP entrypoints
456
+ - Any file type can be collected with `--include`, `prodex grep`, or a saved scope
457
+ - `prodex grep` and search scopes require [ripgrep](https://github.com/BurntSushi/ripgrep) (`rg`) to be installed and available on your PATH
237
458
 
238
459
  ## License
239
460
 
@@ -0,0 +1,2 @@
1
+ import type { ExecutionPlan, SourceCollectionResult } from "../types";
2
+ export declare function collectDependencySources(plan: ExecutionPlan): Promise<SourceCollectionResult>;