postman-cli 1.90.0 → 1.92.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.
package/man/postman.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH POSTMAN 1 "2026-11-13" "v1.90.0" "Postman CLI Manual"
1
+ .TH POSTMAN 1 "2026-11-18" "v1.92.0" "Postman CLI Manual"
2
2
  .SH NAME
3
3
  postman \- Command\-line companion utility for Postman
4
4
  .SH SYNOPSIS
@@ -49,11 +49,11 @@ Specify the API key directly.
49
49
  .B \-\-region <region>
50
50
  Specify the region for authentication. Use "eu" for EU region.
51
51
  .TP
52
- .B \-\-migrate\-guest\-workspace
53
- Copy this repository's local work into a new workspace in the account you sign in to, even after the previous session has ended (for example after a logout).
52
+ .B \-\-claim
53
+ Move the work from your temporary session on this machine into the team you sign in to, without asking. Needed to move it when there is no terminal to ask in (an agent, CI, a pipe).
54
54
  .TP
55
- .B \-\-no\-migrate\-guest\-workspace
56
- Do not copy local work into the account you sign in to. By default local work is copied.
55
+ .B \-\-no\-claim
56
+ Don't move the work from your temporary session on this machine, and don't ask. By default you are asked once you have signed in.
57
57
  .TP
58
58
  .B \-\-verbose
59
59
  Show detailed error information
@@ -189,6 +189,138 @@ Examples:
189
189
  $ postman status ./services/api \-\-json
190
190
 
191
191
 
192
+ .SS "agent"
193
+ Manage CLI discovery hints for coding agents and plugins.
194
+
195
+ .B Usage:
196
+ [options] [command]
197
+
198
+ .B Subcommands:
199
+ .TP
200
+ .B agent discovery-hints
201
+ Manage CLI discovery hints for coding agents in global Claude Code and Codex instructions.
202
+ .TP
203
+ .B agent plugins
204
+ Install, inspect, or remove Postman plugins in coding agents.
205
+
206
+ .SS "agent discovery\-hints"
207
+ Manage CLI discovery hints for coding agents in global Claude Code and Codex instructions.
208
+
209
+ .B Usage:
210
+ [options] [command]
211
+
212
+ .B Subcommands:
213
+ .TP
214
+ .B agent discovery-hints add
215
+ Add CLI discovery hints for agents and remember this choice.
216
+ .TP
217
+ .B agent discovery-hints status
218
+ Inspect CLI discovery hints for agents.
219
+ .TP
220
+ .B agent discovery-hints remove
221
+ Remove CLI discovery hints for agents and remember this choice.
222
+
223
+ .SS "agent discovery\-hints add"
224
+ Add CLI discovery hints for agents and remember this choice.
225
+
226
+ .B Usage:
227
+ [options]
228
+
229
+ .B Options:
230
+ .TP
231
+ .B \-\-json
232
+ Print machine\-readable results.
233
+
234
+ .SS "agent discovery\-hints status"
235
+ Inspect CLI discovery hints for agents.
236
+
237
+ .B Usage:
238
+ [options]
239
+
240
+ .B Options:
241
+ .TP
242
+ .B \-\-json
243
+ Print machine\-readable results.
244
+
245
+ .SS "agent discovery\-hints remove"
246
+ Remove CLI discovery hints for agents and remember this choice.
247
+
248
+ .B Usage:
249
+ [options]
250
+
251
+ .B Options:
252
+ .TP
253
+ .B \-\-json
254
+ Print machine\-readable results.
255
+
256
+ .SS "agent plugins"
257
+ Install, inspect, or remove Postman plugins in coding agents.
258
+
259
+ .B Usage:
260
+ [options] [command]
261
+
262
+ .B Subcommands:
263
+ .TP
264
+ .B agent plugins install
265
+ install Postman plugins.
266
+ .TP
267
+ .B agent plugins status
268
+ status Postman plugins.
269
+ .TP
270
+ .B agent plugins remove
271
+ remove Postman plugins.
272
+
273
+ .SS "agent plugins install"
274
+ install Postman plugins.
275
+
276
+ .B Usage:
277
+ [options]
278
+
279
+ .B Options:
280
+ .TP
281
+ .B \-\-agent <id>
282
+ Limit changes to one agent: antigravity, claude\-code, codex, copilot, cursor, factory, kimi, opencode, pi.
283
+ .TP
284
+ .B \-y, \-\-yes
285
+ Confirm plugin changes without prompting.
286
+ .TP
287
+ .B \-\-dry\-run
288
+ Preview changes without modifying agent settings.
289
+ .TP
290
+ .B \-\-timeout <ms>
291
+ Plugin installer timeout in milliseconds. (default: 300000)
292
+
293
+ .SS "agent plugins status"
294
+ status Postman plugins.
295
+
296
+ .B Usage:
297
+ [options]
298
+
299
+ .B Options:
300
+ .TP
301
+ .B \-\-json
302
+ Print machine\-readable plugin status.
303
+
304
+ .SS "agent plugins remove"
305
+ remove Postman plugins.
306
+
307
+ .B Usage:
308
+ [options]
309
+
310
+ .B Options:
311
+ .TP
312
+ .B \-\-agent <id>
313
+ Limit changes to one agent: antigravity, claude\-code, codex, copilot, cursor, factory, kimi, opencode, pi.
314
+ .TP
315
+ .B \-y, \-\-yes
316
+ Confirm plugin changes without prompting.
317
+ .TP
318
+ .B \-\-dry\-run
319
+ Preview changes without modifying agent settings.
320
+ .TP
321
+ .B \-\-timeout <ms>
322
+ Plugin installer timeout in milliseconds. (default: 300000)
323
+
192
324
  .SS "feedback"
193
325
  Submit feedback about CLI usability, gaps, and improvement suggestions.
194
326
 
@@ -3949,9 +4081,9 @@ Load segments:
3949
4081
  ramp\-up — 2 segments
3950
4082
 
3951
4083
  peak ┤ _________ at peak __________
3952
- │ ramp\-up _____╱
3953
- │ ______╱
3954
- base ┤__ warm\-up ___╱
4084
+ │ ramp\-up _____/
4085
+ │ ______/
4086
+ base ┤__ warm\-up ___/
3955
4087
  └┬─────────────┬─────────────┬───────────────────────────┤ \-\-duration
3956
4088
  1 2 (3)
3957
4089
 
@@ -3963,10 +4095,10 @@ Load segments:
3963
4095
 
3964
4096
  spike — 3 segments · no time at the peak; use \-\-load\-profile peak to hold
3965
4097
 
3966
- peak ┤ ╱╲
3967
- │ ramp\-up _╱ ╲_ ramp\-down
3968
- │ _╱ ╲_
3969
- base ┤______ warm\-up _______╱ ╲______ at base _______
4098
+ peak ┤ /\e
4099
+ │ ramp\-up _/ \e_ ramp\-down
4100
+ │ _/ \e_
4101
+ base ┤______ warm\-up _______/ \e______ at base _______
3970
4102
  └┬─────────────────────┬─────┬─────┬─────────────────────┤ \-\-duration
3971
4103
  1 2 3 (4)
3972
4104
 
@@ -3979,9 +4111,9 @@ Load segments:
3979
4111
  peak — 4 segments
3980
4112
 
3981
4113
  peak ┤ __ hold ___
3982
- │ ramp\-up ____╱ ╲____ ramp\-down
3983
- │ ____╱ ╲____
3984
- base ┤_ warm\-up _╱ ╲_ at base __
4114
+ │ ramp\-up ____/ \e____ ramp\-down
4115
+ │ ____/ \e____
4116
+ base ┤_ warm\-up _/ \e_ at base __
3985
4117
  └┬──────────┬──────────┬──────────┬──────────┬───────────┤ \-\-duration
3986
4118
  1 2 3 4 (5)
3987
4119
 
@@ -4636,7 +4768,7 @@ Ctrl+C cancels the run; cancellation and timeout do not roll back completed acti
4636
4768
 
4637
4769
 
4638
4770
  .SS "request"
4639
- Send HTTP requests from the command line with full Postman capabilities including authentication, environment variables, assertions, retries, and detailed output control. Use `postman request grpc` for gRPC.
4771
+ Send HTTP requests from the command line with full Postman capabilities including authentication, environment variables, assertions, retries, and detailed output control. Use `postman request grpc` for gRPC or `postman request graphql` for GraphQL.
4640
4772
 
4641
4773
  .B Usage:
4642
4774
  [METHOD] <URL|request\-file> [options]
@@ -4967,6 +5099,9 @@ Examples:
4967
5099
  .TP
4968
5100
  .B request grpc
4969
5101
  Invoke a gRPC method, or list and describe the methods a server exposes. The service definition comes from server reflection unless \-\-proto or \-\-protoset is given.
5102
+ .TP
5103
+ .B request graphql
5104
+ Send a GraphQL query, mutation, or subscription, or inspect its schema. Uses the same GraphQL runtime as the Postman workbench.
4970
5105
 
4971
5106
  .SS "request grpc"
4972
5107
  Invoke a gRPC method, or list and describe the methods a server exposes. The service definition comes from server reflection unless \-\-proto or \-\-protoset is given.
@@ -5081,6 +5216,55 @@ Exit Codes:
5081
5216
 
5082
5217
 
5083
5218
 
5219
+ .SS "request graphql"
5220
+ Send a GraphQL query, mutation, or subscription, or inspect its schema. Uses the same GraphQL runtime as the Postman workbench.
5221
+
5222
+ .B Usage:
5223
+ [options] <urlOrFile>
5224
+
5225
+ .B Options:
5226
+ .TP
5227
+ .B \-\-url <url>
5228
+ Override the saved endpoint URL. Supports {{variables}}.
5229
+ .TP
5230
+ .B \-\-query <query>
5231
+ GraphQL document, inline, @path, or \- for stdin. Overrides the saved query.
5232
+ .TP
5233
+ .B \-\-variables <json>
5234
+ Variables, inline JSON, @path, or \- for stdin. Overrides saved variables.
5235
+ .TP
5236
+ .B \-\-operation\-name <name>
5237
+ Operation to execute when a document contains multiple operations.
5238
+ .TP
5239
+ .B \-\-introspect
5240
+ Print the schema as SDL instead of executing a query. Scripts are skipped.
5241
+ .TP
5242
+ .B \-\-schema <pathOrUrl>
5243
+ Import an SDL or introspection JSON schema from a file or HTTP(S) URL. Used for query validation, or with \-\-introspect to inspect the imported schema.
5244
+ .TP
5245
+ .B \-\-script\-before\-query <script>
5246
+ Before\-query JavaScript, inline or @path. Supports pm.* APIs.
5247
+ .TP
5248
+ .B \-\-script\-after\-response <script>
5249
+ After\-response JavaScript, inline or @path. pm.test() assertions affect the exit code.
5250
+ .TP
5251
+ .B \-\-json
5252
+ Print response JSON, or newline\-delimited response and summary events for streams. With \-\-introspect, print introspection JSON.
5253
+
5254
+ .TP Examples:
5255
+
5256
+ Examples:
5257
+ postman request graphql https://api.example.com/graphql \-\-introspect
5258
+ postman request graphql https://api.example.com/graphql \-\-query @query.graphql \-\-variables @variables.json
5259
+ postman request graphql ./GetUser.request.yaml \-\-auth\-bearer\-token "{{token}}" \-e dev.json
5260
+ postman request graphql https://api.example.com/graphql \-\-schema schema.graphql \-\-introspect
5261
+ postman request graphql https://api.example.com/graphql \-\-query "subscription { updates { id } }" \-H "Accept: text/event\-stream" \-\-json
5262
+
5263
+ Shared options: \-H, \-\-auth\-<type>\-<param>, \-e, \-\-timeout, \-\-cookie\-jar, \-\-export\-cookie\-jar, \-\-response\-only, \-\-verbose, \-o. See postman request \-\-help.
5264
+ Auth types: apikey, basic, bearer, hawk, oauth1, oauth2, edgegrid, awsv4.
5265
+ Subscriptions use WebSocket by default; pass \-H "Accept: text/event\-stream" for SSE. TLS and HTTP settings inherited from request are ignored with a warning. Mutations are sent once; there are no automatic retries.
5266
+
5267
+
5084
5268
  .SS "sdk"
5085
5269
  Generate and manage your SDKs directly from the command line.
5086
5270
 
@@ -5487,7 +5671,7 @@ Create, run, and manage Postman mocks — in your repository or in Postman cloud
5487
5671
  Generate a mock from a Postman collection, an OpenAPI file or a dataset, or a static mock from a built\-in sample shopping cart (POST /cart/items, GET /cart, POST /checkout). Writes a local mock by default, or a cloud mock with \-\-workspace. Add \-\-deploy to also make it a live mock server.
5488
5672
  .TP
5489
5673
  .B mock run
5490
- Start a mock using its path if it lives in your repository, or its id if it lives in Postman cloud (fetched and run locally).
5674
+ Start a mock using its path if it lives in your repository, or its id or <slug>.mock.<teamDomain> if it lives in Postman cloud (fetched and run locally).
5491
5675
  .TP
5492
5676
  .B mock stop
5493
5677
  Stop a mock started with `postman mock run` on this machine, and wait until it has exited and released its port.
@@ -5599,7 +5783,7 @@ Paths can be relative (e.g. ./my\-collection.json) or absolute (e.g. /Users/me/m
5599
5783
 
5600
5784
 
5601
5785
  .SS "mock run"
5602
- Start a mock using its path if it lives in your repository, or its id if it lives in Postman cloud (fetched and run locally).
5786
+ Start a mock using its path if it lives in your repository, or its id or <slug>.mock.<teamDomain> if it lives in Postman cloud (fetched and run locally).
5603
5787
 
5604
5788
  .B Usage:
5605
5789
  <mockIdOrPath>
@@ -5636,6 +5820,7 @@ Pass \-\-dataset multiple times to load several .dataset.yaml files (or director
5636
5820
  .TP Examples:
5637
5821
 
5638
5822
  Eg. postman mock run 12345678\-90ab\-cdef\-1234\-567890abcdef # by id, from Postman cloud
5823
+ postman mock run stripe.mock.postman # by slug and team domain, from cloud
5639
5824
  postman mock run ./postman/mocks/orders # by path, from your repository
5640
5825
  postman mock run ./postman/mocks/orders \-\-environment ./postman/environments/dev.environment.yaml
5641
5826
  postman mock run ./postman/mocks/orders \-\-port auto # pick any free port
@@ -6087,7 +6272,7 @@ List the simulations in your repository or Postman cloud workspace
6087
6272
  Show a simulation's details using its .sim.yaml path if it lives in your repository, or its id if it lives in Postman cloud.
6088
6273
  .TP
6089
6274
  .B simulation run
6090
- Serve a simulation's mocks on one local port, routing each by its routeKey. Pass a .sim.yaml path (local) or a Postman simulation id (fetched and run locally).
6275
+ Serve a simulation's mocks on one local port, routing each by its routeKey. Pass a .sim.yaml path (local), a Postman simulation id, or <slug>.mock.<teamDomain> (fetched and run locally).
6091
6276
  .TP
6092
6277
  .B simulation stop
6093
6278
  Stop a simulation started with `postman simulation run` on this machine, and wait until it has exited and released its port.
@@ -6221,7 +6406,7 @@ Paths can be relative (e.g. ./postman/simulations/checkout.sim.yaml) or absolute
6221
6406
 
6222
6407
 
6223
6408
  .SS "simulation run"
6224
- Serve a simulation's mocks on one local port, routing each by its routeKey. Pass a .sim.yaml path (local) or a Postman simulation id (fetched and run locally).
6409
+ Serve a simulation's mocks on one local port, routing each by its routeKey. Pass a .sim.yaml path (local), a Postman simulation id, or <slug>.mock.<teamDomain> (fetched and run locally).
6225
6410
 
6226
6411
  .B Usage:
6227
6412
  [options] <simIdOrPath>
@@ -7037,7 +7222,7 @@ Quick start:
7037
7222
  postman search requests "auth"
7038
7223
  postman search requests "auth" \-\-filter "method=POST AND visibility=public" \-\-ownership org \-\-limit 10 \-\-output json
7039
7224
 
7040
- Element types: requests, collections, workspaces, flows, specs, environments, mocks, documents
7225
+ Element types: requests, collections, workspaces, flows, specs, environments, mocks, documents, datasets
7041
7226
 
7042
7227
  Detailed help is split by element type:
7043
7228
  postman search requests \-\-help Request filters and examples
@@ -7048,6 +7233,7 @@ Detailed help is split by element type:
7048
7233
  postman search mocks \-\-help Mock filters and examples
7049
7234
  postman search environments \-\-help Environment filters and examples
7050
7235
  postman search documents \-\-help Document filters and examples
7236
+ postman search datasets \-\-help Dataset filters and examples
7051
7237
 
7052
7238
  Pagination: \-\-limit accepts up to 25 results. Use \-\-cursor from the previous response to paginate.
7053
7239
 
@@ -7077,6 +7263,9 @@ Search for environments by name or keyword.
7077
7263
  .TP
7078
7264
  .B search documents
7079
7265
  Search for documents by name or keyword.
7266
+ .TP
7267
+ .B search datasets
7268
+ Search for datasets by name or keyword.
7080
7269
 
7081
7270
  .SS "search requests"
7082
7271
  Search for requests by name or keyword.
@@ -7500,6 +7689,57 @@ Examples:
7500
7689
  postman search documents \-\-filter "documentId=doc\-abc123"
7501
7690
 
7502
7691
 
7692
+ .SS "search datasets"
7693
+ Search for datasets by name or keyword.
7694
+
7695
+ .B Usage:
7696
+ [options] [query]
7697
+
7698
+ .TP Examples:
7699
+
7700
+ Use \-\-cursor from the previous response to paginate.
7701
+ Ownership:
7702
+ organization, org Search resources owned by your organization
7703
+ external Search resources outside your organization
7704
+ all Search both organization and external resources
7705
+
7706
+ Output modes:
7707
+ default Card list including basic overview and web link per result
7708
+ json Detailed JSON response with search metadata
7709
+
7710
+ Filter syntax:
7711
+ Use = or != for single values: workspaceId=ws\-1
7712
+ Use IN or NIN for comma\-separated values: workspaceId IN ws\-1,ws\-2
7713
+ Combine filters with AND. Operators are case\-insensitive.
7714
+ Quote supported values that contain spaces or commas: <field>="value with spaces"
7715
+
7716
+ \-\-filter\-json format:
7717
+ {"$and":[{"workspaceId":{"$eq":"ws\-abc123"}}]}
7718
+ Only a top\-level $and array is supported; $or and nested groups are not supported.
7719
+ Each condition maps one field to one operator object ($eq, $ne, $in, $nin).
7720
+
7721
+ Shared filter fields:
7722
+ privateNetwork $eq, $ne (true/false)
7723
+ publisherIsVerified $eq, $ne (true/false)
7724
+ visibility $eq, $ne (internal, public, partner)
7725
+ workspaceId $eq, $ne, $in, $nin
7726
+ createdBy $eq, $ne, $in, $nin (user ID)
7727
+ organizationId $eq, $ne, $in, $nin (organization ID)
7728
+ teamId $eq, $ne, $in, $nin (team ID)
7729
+ isGitConnected $eq, $ne (true/false)
7730
+
7731
+ Dataset filter fields:
7732
+ datasetId $eq, $ne, $in, $nin
7733
+
7734
+ ID filters such as createdBy, organizationId, teamId, workspaceId, and collectionId expect IDs.
7735
+ Use \-\-output json on a broader search result to inspect available IDs.
7736
+
7737
+ Examples:
7738
+ postman search datasets "customers"
7739
+ postman search datasets "orders" \-\-filter "workspaceId=ws\-abc123"
7740
+ postman search datasets \-\-filter "datasetId=dataset\-abc123"
7741
+
7742
+
7503
7743
  .SS "webhook"
7504
7744
  Create and manage Postman webhooks.
7505
7745
 
@@ -7807,6 +8047,9 @@ Forward incoming webhook requests to a local port.
7807
8047
 
7808
8048
  .B Options:
7809
8049
  .TP
8050
+ .B \-\-https
8051
+ Use HTTPS for the local listener; accepts self\-signed certificates.
8052
+ .TP
7810
8053
  .B \-w, \-\-workspace <workspaceId>
7811
8054
  Postman workspace ID
7812
8055
  .TP
@@ -7818,6 +8061,7 @@ Postman API key
7818
8061
  Examples:
7819
8062
  postman webhook forward 00000000\-0000\-0000\-0000\-000000000000 8080
7820
8063
  postman webhook forward https://abc123.webhook.pstmn.io 8080
8064
+ postman webhook forward 00000000\-0000\-0000\-0000\-000000000000 8111 \-\-https
7821
8065
 
7822
8066
 
7823
8067
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postman-cli",
3
- "version": "1.90.0",
3
+ "version": "1.92.0",
4
4
  "description": "Official Postman CLI - Command-line companion for API development, testing, and automation",
5
5
  "keywords": [
6
6
  "postman",
@@ -57,10 +57,10 @@
57
57
  "scripts/"
58
58
  ],
59
59
  "optionalDependencies": {
60
- "@postman/pm-bin-macos-arm64": "1.90.0",
61
- "@postman/pm-bin-macos-x64": "1.90.0",
62
- "@postman/pm-bin-linux-x64": "1.90.0",
63
- "@postman/pm-bin-linux-arm64": "1.90.0",
64
- "@postman/pm-bin-windows-x64": "1.90.0"
60
+ "@postman/pm-bin-macos-arm64": "1.92.0",
61
+ "@postman/pm-bin-macos-x64": "1.92.0",
62
+ "@postman/pm-bin-linux-x64": "1.92.0",
63
+ "@postman/pm-bin-linux-arm64": "1.92.0",
64
+ "@postman/pm-bin-windows-x64": "1.92.0"
65
65
  }
66
66
  }
@@ -20,11 +20,11 @@ const POSTMAN_INSTRUCTION =
20
20
  '',
21
21
  'Claude Code users and agents can use the Postman Plugin for Claude Code for full API lifecycle',
22
22
  'management including documentation, collections, workspaces, environments, mocks, monitors right',
23
- 'from your repository.',
23
+ 'from the repository.',
24
24
  '',
25
25
  'Install it with:',
26
- ' claude plugin marketplace add anthropics/claude-plugins-official',
27
- ' claude plugin install postman@claude-plugins-official'
26
+ ' `claude plugin marketplace add anthropics/claude-plugins-official`',
27
+ ' `claude plugin install postman@claude-plugins-official`'
28
28
  ].join('\n');
29
29
 
30
30
  /**
@@ -79,7 +79,7 @@ const AGENT_CONFIGURATIONS = [
79
79
  name: 'Codex',
80
80
  configurationEnvironmentVariable: 'CODEX_HOME',
81
81
  fallbackDirectory: '.codex',
82
- instructionFileNames: ['AGENTS.override.md', 'AGENTS.md']
82
+ instructionFileNames: ['AGENTS.md']
83
83
  }
84
84
  ];
85
85
 
@@ -247,12 +247,13 @@ function configureAgent (agentConfiguration, environment, userHome, invocationDi
247
247
 
248
248
  detected = true;
249
249
 
250
+ const instructionFile = resolveInstructionFile(agentConfiguration, configurationRoot);
251
+
250
252
  return {
251
253
  name: agentConfiguration.name,
252
254
  detected,
253
- instruction: addPostmanInstruction(
254
- resolveInstructionFile(agentConfiguration, configurationRoot)
255
- ),
255
+ instruction: addPostmanInstruction(instructionFile),
256
+ path: instructionFile,
256
257
  errorCode: null
257
258
  };
258
259
  }
@@ -267,7 +268,7 @@ function configureAgent (agentConfiguration, environment, userHome, invocationDi
267
268
  }
268
269
 
269
270
  /**
270
- * Prints a concise result without exposing user-specific filesystem paths.
271
+ * Prints the instruction outcome and the path changed by the installer.
271
272
  *
272
273
  * @param {AgentConfigurationResult} result - Agent configuration result.
273
274
  * @returns {void}
@@ -285,6 +286,164 @@ function printAgentResult (result) {
285
286
  'the Postman CLI installation is still usable.'
286
287
  );
287
288
  }
289
+ else {
290
+ console.log(`${result.name}: skipped (agent configuration not detected).`);
291
+ }
292
+ if (result.path) {
293
+ console.log(` CLI discovery hint for agents: ${result.path}${result.instruction === 'existing' ? ' (skipped: already present)' : ''}`);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * @param {string} userHome - User home directory.
299
+ * @returns {string} Shared installer preference path.
300
+ */
301
+ function preferenceFile (userHome = operatingSystem.homedir()) {
302
+ return path.join(userHome, '.postman', 'installation-preferences');
303
+ }
304
+
305
+ /**
306
+ * @param {string} [userHome] - User home directory.
307
+ * @returns {string|null} Saved choice, or null on first install.
308
+ */
309
+ function readPreference (userHome = operatingSystem.homedir()) {
310
+ try {
311
+ const entries = fileSystem.readFileSync(preferenceFile(userHome), 'utf8').split(/\r?\n/)
312
+ .filter((line) => { return line.startsWith('agent-discovery-hints='); });
313
+
314
+ if (entries.length > 1) {
315
+ throw new Error('Invalid agent-discovery-hints preference.');
316
+ }
317
+ if (entries.length === 1) {
318
+ const preference = entries[0].slice('agent-discovery-hints='.length);
319
+
320
+ if (!['enabled', 'disabled'].includes(preference)) {
321
+ throw new Error('Invalid agent-discovery-hints preference.');
322
+ }
323
+
324
+ return preference;
325
+ }
326
+ }
327
+ catch (error) {
328
+ if (error.code !== 'ENOENT') {
329
+ throw error;
330
+ }
331
+ }
332
+
333
+ return null;
334
+ }
335
+
336
+ /**
337
+ * @param {'enabled'|'disabled'} preference - Explicit user choice.
338
+ * @param {string} [userHome] - User home directory.
339
+ * @param {'agent-discovery-hints'|'agent-plugins'} [feature='agent-discovery-hints'] - Installation choice to save.
340
+ * @returns {void}
341
+ */
342
+ function savePreference (preference, userHome, feature = 'agent-discovery-hints') {
343
+ if (!['agent-discovery-hints', 'agent-plugins'].includes(feature)) {
344
+ throw new Error('Unknown installation preference.');
345
+ }
346
+ const filename = preferenceFile(userHome),
347
+ prefix = `${feature}=`;
348
+ let contents = '';
349
+
350
+ try {
351
+ contents = fileSystem.readFileSync(filename, 'utf8');
352
+ }
353
+ catch (error) {
354
+ if (error.code !== 'ENOENT') {
355
+ throw error;
356
+ }
357
+ }
358
+
359
+ const retained = contents.split('\n').filter((line) => { return !line.startsWith(prefix); }).join('\n'),
360
+ separator = retained && !retained.endsWith('\n') ? '\n' : '';
361
+
362
+ fileSystem.mkdirSync(path.dirname(filename), { recursive: true });
363
+ fileSystem.writeFileSync(filename, `${retained}${separator}${prefix}${preference}\n`, { mode: 0o600 });
364
+ }
365
+
366
+ /**
367
+ * @param {'add'|'status'|'remove'} action - Requested operation.
368
+ * @param {NodeJS.ProcessEnv} [environment] - Agent configuration overrides.
369
+ * @returns {{preference: string|null, agents: object[]}} Per-file outcomes.
370
+ */
371
+ function manageAgentDiscoveryHints (action, environment = process.env) {
372
+ const userHome = operatingSystem.homedir(),
373
+ invocationDirectory = resolveInvocationDirectory(environment, userHome) || process.cwd();
374
+
375
+ if (action !== 'status') {
376
+ savePreference(action === 'add' ? 'enabled' : 'disabled', userHome);
377
+ }
378
+
379
+ const agents = AGENT_CONFIGURATIONS.flatMap((configuration) => {
380
+ const root = resolveAgentConfigurationRoot(configuration, environment, userHome, invocationDirectory),
381
+ selectedFile = resolveInstructionFile(configuration, root),
382
+ files = action === 'add' ? [selectedFile] :
383
+ configuration.instructionFileNames.map((filename) => { return path.join(root, filename); });
384
+
385
+ return files.map((filename) => {
386
+ try {
387
+ if (!isDirectory(root)) {
388
+ return { name: configuration.name, path: filename, status: 'skipped' };
389
+ }
390
+
391
+ if (action === 'add') {
392
+ return { name: configuration.name, path: filename, status: addPostmanInstruction(filename) };
393
+ }
394
+
395
+ let contents;
396
+
397
+ try {
398
+ contents = fileSystem.readFileSync(filename, 'utf8');
399
+ }
400
+ catch (error) {
401
+ if (error.code === 'ENOENT') {
402
+ return { name: configuration.name, path: filename, status: 'absent' };
403
+ }
404
+
405
+ throw error;
406
+ }
407
+
408
+ const lines = contents.split(/(?<=\n)/),
409
+ remaining = [];
410
+ let inBlock = false, found = false;
411
+
412
+ for (const line of lines) {
413
+ const text = line.replace(/[\r\n]+$/, '');
414
+
415
+ if (text === POSTMAN_INSTRUCTION_START) {
416
+ if (inBlock) { throw new Error('Malformed installation block.'); }
417
+ inBlock = true;
418
+ found = true;
419
+ }
420
+ else if (text === POSTMAN_INSTRUCTION_END) {
421
+ if (!inBlock) { throw new Error('Malformed installation block.'); }
422
+ inBlock = false;
423
+ }
424
+ else if (!inBlock && text !== POSTMAN_INSTRUCTION) {
425
+ remaining.push(line);
426
+ }
427
+ else if (text === POSTMAN_INSTRUCTION) {
428
+ found = true;
429
+ }
430
+ }
431
+
432
+ if (inBlock) { throw new Error('Malformed installation block.'); }
433
+ if (action === 'remove' && found) {
434
+ fileSystem.writeFileSync(filename, remaining.join(''), 'utf8');
435
+ }
436
+
437
+ return { name: configuration.name, path: filename,
438
+ status: found ? action === 'remove' ? 'removed' : 'existing' : 'absent' };
439
+ }
440
+ catch (error) {
441
+ return { name: configuration.name, path: filename, status: 'error', errorCode: getErrorCode(error) };
442
+ }
443
+ });
444
+ });
445
+
446
+ return { preference: readPreference(userHome), agents };
288
447
  }
289
448
 
290
449
  /**
@@ -334,7 +493,34 @@ function runPostInstallation (environment = process.env) {
334
493
  }
335
494
 
336
495
  const userHome = operatingSystem.homedir(),
337
- invocationDirectory = resolveInvocationDirectory(environment, userHome),
496
+ invocationDirectory = resolveInvocationDirectory(environment, userHome);
497
+
498
+ console.log('Postman CLI is installed and can be used for API Engineering work.');
499
+ const force = environment.POSTMAN_CLI_FORCE === 'agent-discovery-hints',
500
+ skip = environment.POSTMAN_CLI_SKIP === 'agent-discovery-hints',
501
+ preference = readPreference(userHome);
502
+
503
+ if ((environment.POSTMAN_CLI_SKIP && !skip) || (environment.POSTMAN_CLI_FORCE && !force)) {
504
+ throw new Error('CLI discovery hint controls for agents must name `agent-discovery-hints`.');
505
+ }
506
+
507
+ if (force && skip) {
508
+ throw new Error('Conflicting CLI discovery hint controls for agents.');
509
+ }
510
+ if (skip) {
511
+ savePreference('disabled', userHome);
512
+ }
513
+ if (!force) {
514
+ console.log('CLI discovery hints for agents: skipped (' + (skip || preference === 'disabled' ? 'opted out' :
515
+ ((environment.CI && !['0', 'false'].includes(environment.CI)) ||
516
+ environment.GITHUB_ACTIONS || environment.TF_BUILD || environment.BUILD_NUMBER) ?
517
+ 'CI Environment detected. Use `--force agent-discovery-hints` to add' :
518
+ 'not enabled during npm installation; set `POSTMAN_CLI_FORCE=agent-discovery-hints` to add') + ').');
519
+ return;
520
+ }
521
+
522
+ savePreference('enabled', userHome);
523
+ const
338
524
  configuredAgents = AGENT_CONFIGURATIONS.map((agentConfiguration) => {
339
525
  return {
340
526
  agentConfiguration,
@@ -347,7 +533,6 @@ function runPostInstallation (environment = process.env) {
347
533
  };
348
534
  });
349
535
 
350
- console.log('Postman CLI is installed and can be used for API Engineering work.');
351
536
  configuredAgents.forEach(({ configurationResult }) => {
352
537
  try {
353
538
  printAgentResult(configurationResult);
@@ -396,5 +581,8 @@ module.exports = {
396
581
  addPostmanInstruction,
397
582
  isGlobalInstallation,
398
583
  resolveAgentConfigurationRoot,
584
+ manageAgentDiscoveryHints,
585
+ readPreference,
586
+ savePreference,
399
587
  runPostInstallation
400
588
  };