@prompts-gpt/client 0.2.0 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ### Security
6
+
7
+ - Validate `constraints` and `desiredOutput` length (max 1600 chars) client-side before network requests
8
+ - Validate token prefix (`pgpt_`) in `saveLocalCredentials` to reject malformed tokens at save time
9
+ - Sanitize Copilot prompt-file variable names to strip `$`, `{`, `}` injection characters
10
+ - Sanitize managed-block content to prevent marker injection via prompt content
11
+ - Validate API URL scheme (must be `https` or `http`) in `normalizeApiUrl`
12
+ - Auto-generate client-side request IDs (`pgcli_*`) when caller doesn't provide one for correlation
13
+
14
+ ### Fixed
15
+
16
+ - Fix package version mismatch between `package.json` (0.2.1) and CHANGELOG (0.2.2)
17
+ - Fix npm publish failure on unsupported CI providers by removing forced provenance from package metadata
18
+ - Fix race condition in file writes: use atomic `wx` flag with `EEXIST` catch instead of `existsSync` + `wx`
19
+ - Fix `formatPromptMarkdown` producing double blank lines when both `usageNotes` and `variables` are empty
20
+ - Fix `normalizeAgentTargets` deduplication when `all` is mixed with explicit targets (e.g. `all,codex`)
21
+ - Fix `normalizeAgentTargets` returning empty array for empty string input
22
+ - Fix `loadLocalCredentials` returning empty-string token instead of `null` for whitespace-only stored tokens
23
+ - Fix `safeSlug` for unicode-only input by normalizing NFKD and stripping combining marks
24
+ - Fix `ensureGitignoreEntry` to preserve CRLF line endings on Windows-style `.gitignore` files
25
+ - Fix `parseRetryAfterHeader` to cap parsed values at 10 minutes, preventing unbounded waits
26
+ - Fix `assertInside` / `assertSafeOutputDir` boundary comparison for paths at the project root
27
+ - Fix `writePromptIndex` to escape `[` and `]` in Markdown link text to prevent broken rendering
28
+ - Fix `yamlScalar` to handle multi-line strings by normalizing `\r\n` before quoting
29
+ - Serialize agent file writes sequentially to prevent concurrent write races on shared files
30
+
31
+ ### Improvements
32
+
33
+ - Add `--dry-run` flag to `sync` and `install-agents` commands for previewing changes
34
+ - Add dedicated CLI exit code `4` for rate-limit errors (HTTP 429)
35
+ - Use longer default timeout (60s) for prompt generation requests
36
+ - Add `DEFAULT_GENERATE_TIMEOUT_MS` constant for prompt generation timeout
37
+
38
+ ### Packaging
39
+
40
+ - Add npm `homepage` and `bugs.email` metadata so package consumers have a first-party support path from the registry page
41
+ - Clarify the project-local CLI install path and pre-publish `npm pack --dry-run` verification flow in the README
42
+
43
+ ## 0.2.2 (2026-05-16)
44
+
45
+ ### Local Sync
46
+
47
+ - Reject prompt filename collisions after slug normalization before writing local artifacts
48
+ - Respect each prompt pack's declared `agentTargets` when generating Codex, Cursor, VS Code, and Copilot files
49
+ - Skip existing non-managed agent files unless `--overwrite` is explicitly passed
50
+ - Expand `manifest.json` with agent targets, recommended path, and generated file locations for downstream discovery
51
+ - Emit GitHub Copilot prompt files in prompt-file format instead of generic prompt-pack Markdown
52
+ - Add `.github/instructions/prompts-gpt.instructions.md` so Copilot treats synced agent artifacts as generated files
53
+
54
+ ## 0.2.1 (2026-05-16)
55
+
56
+ ### Packaging
57
+
58
+ - Add an explicit `default` export target for better ESM consumer and bundler compatibility
59
+ - Enable npm provenance on publish for stronger package registry attestation
60
+ - Remove the redundant `typesVersions` entry and rely on the package `types` field plus export metadata
61
+
62
+ ### Documentation
63
+
64
+ - Replace stale `npx`-only examples with `npm exec` flows that pin to the latest published package
65
+ - Clarify that the importable SDK does not read `process.env` and requires explicit `fetch`
66
+ - Align CI/CD examples with the real CLI contract of passing tokens as flags instead of ambient env reads
67
+ - Document the packed artifact contents shipped to npm
68
+
3
69
  ## 0.2.0 (2026-05-16)
4
70
 
5
71
  ### Security
@@ -26,7 +92,7 @@
26
92
 
27
93
  ## 0.1.1 (2026-05-16)
28
94
 
29
- - Remove public GitHub repository, homepage, and bugs metadata from the npm package manifest.
95
+ - Remove public GitHub repository metadata from the npm package manifest while the source repository remains non-public.
30
96
  - Preserve executable permissions for the `prompts-gpt` CLI after package builds.
31
97
 
32
98
  ## 0.1.0 (2026-05-16)
package/README.md CHANGED
@@ -12,7 +12,7 @@ AI coding agents work best when they have stable, discoverable instructions insi
12
12
  |-------|-------------------|
13
13
  | **Codex** | `AGENTS.md` managed block |
14
14
  | **Cursor** | `.cursor/rules/prompts-gpt-*.mdc` |
15
- | **VS Code** | `.github/copilot-instructions.md` + `.vscode/*.code-snippets` |
15
+ | **VS Code** | `.github/copilot-instructions.md` + `.github/instructions/*.instructions.md` + `.vscode/*.code-snippets` |
16
16
  | **Copilot** | `.github/prompts/*.prompt.md` |
17
17
 
18
18
  Prompt Markdown files and a `manifest.json` are always written to `.prompts-gpt/` for discovery.
@@ -22,14 +22,14 @@ Prompt Markdown files and a `manifest.json` are always written to `.prompts-gpt/
22
22
  ## Quick start
23
23
 
24
24
  ```bash
25
- # 1. Initialize with a project token from the dashboard
26
- npx @prompts-gpt/client init --token <project-token>
25
+ # Run the latest CLI without installing it globally
26
+ npm exec --yes @prompts-gpt/client@latest -- init --token <project-token>
27
27
 
28
- # 2. Sync prompt packs + agent files in one command
29
- npx @prompts-gpt/client sync --agent all
28
+ # Sync prompt packs + agent files in one command
29
+ npm exec --yes @prompts-gpt/client@latest -- sync --agent all
30
30
 
31
- # 3. Generate a project-aware prompt and sync it
32
- npx @prompts-gpt/client generate \
31
+ # Generate a project-aware prompt and sync it
32
+ npm exec --yes @prompts-gpt/client@latest -- generate \
33
33
  --goal "Review this diff for security issues" \
34
34
  --context "Node.js API with PostgreSQL" \
35
35
  --agent codex,cursor,vscode
@@ -43,10 +43,21 @@ npx @prompts-gpt/client generate \
43
43
  npm install @prompts-gpt/client
44
44
  ```
45
45
 
46
+ If you want a project-local CLI instead of one-off `npm exec` usage, install it as a dev dependency and call the bin from `package.json` scripts:
47
+
48
+ ```json
49
+ {
50
+ "scripts": {
51
+ "prompts:sync": "prompts-gpt sync --agent all",
52
+ "prompts:generate": "prompts-gpt generate --goal \"Review this diff for security issues\" --agent codex"
53
+ }
54
+ }
55
+ ```
56
+
46
57
  Or run directly with `npx` — no install required:
47
58
 
48
59
  ```bash
49
- npx @prompts-gpt/client <command>
60
+ npx @prompts-gpt/client@latest <command>
50
61
  ```
51
62
 
52
63
  **Requires** Node.js 18.18 or later.
@@ -58,17 +69,21 @@ npx @prompts-gpt/client <command>
58
69
  Create a project token in the [Prompts-GPT dashboard](https://prompts-gpt.com/dashboard/agents), then:
59
70
 
60
71
  ```bash
61
- prompts-gpt init --token pgpt_your_token_here
72
+ prompts-gpt init --token-prompt
62
73
  ```
63
74
 
64
75
  Credentials are saved to `.prompts-gpt/.credentials.json` with `0600` permissions and automatically added to `.gitignore`.
65
76
 
66
- For CI/CD, pass your secret through the shell instead of letting the package read environment variables directly:
77
+ Project tokens are project-scoped, support separate `Read Prompts` and `Generate Prompts` scopes, and should use the shortest practical expiry for the machine or CI job that needs them.
78
+
79
+ For CI/CD or secret-manager pipes, use stdin instead of putting the raw token in shell history:
67
80
 
68
81
  ```bash
69
- prompts-gpt sync --token "$PROMPTS_GPT_TOKEN" --agent all
82
+ printf '%s' "$PROMPTS_GPT_TOKEN" | prompts-gpt sync --token-stdin --agent all
70
83
  ```
71
84
 
85
+ The importable SDK never reads `process.env` and never captures ambient `globalThis.fetch`. Pass explicit runtime dependencies in code.
86
+
72
87
  ---
73
88
 
74
89
  ## CLI reference
@@ -76,9 +91,11 @@ prompts-gpt sync --token "$PROMPTS_GPT_TOKEN" --agent all
76
91
  ### `init` — Save credentials
77
92
 
78
93
  ```bash
79
- prompts-gpt init --token <token> [--api-url <url>] [--cwd <path>]
94
+ prompts-gpt init (--token <token> | --token-stdin | --token-prompt) [--api-url <url>] [--cwd <path>]
80
95
  ```
81
96
 
97
+ Use `--token-prompt` for local interactive setup and `--token-stdin` for CI or secret-manager pipes.
98
+
82
99
  ### `sync` — Pull + generate + write everything
83
100
 
84
101
  ```bash
@@ -87,6 +104,8 @@ prompts-gpt sync [--goal "..."] [--limit 25] [--agent all] [--overwrite]
87
104
 
88
105
  The default workflow. Pulls library prompts, optionally generates one, writes Markdown files, agent integration files, and a manifest.
89
106
 
107
+ Existing prompt Markdown, Cursor rules, Copilot prompt files, and VS Code snippet files are skipped unless you pass `--overwrite`. Managed Prompts-GPT blocks inside `AGENTS.md` and `.github/copilot-instructions.md` remain idempotent and update in place, and a shared `.github/instructions/prompts-gpt.instructions.md` file teaches Copilot to treat synced artifacts as generated outputs.
108
+
90
109
  ### `pull` — Download prompt packs
91
110
 
92
111
  ```bash
@@ -123,6 +142,8 @@ prompts-gpt help
123
142
  | Flag | Description |
124
143
  |------|-------------|
125
144
  | `--token <token>` | Project API token |
145
+ | `--token-stdin` | Read the token from stdin |
146
+ | `--token-prompt` | Prompt for the token without echoing it |
126
147
  | `--api-url <url>` | Custom API base URL |
127
148
  | `--cwd <path>` | Target directory for config and generated files |
128
149
  | `--agent <targets>` | Comma-separated: `codex`, `cursor`, `vscode`, `copilot`, or `all` |
@@ -139,6 +160,7 @@ Codex, Claude Code, Cursor, GitHub Copilot, ChatGPT, Gemini, Perplexity, Grok, D
139
160
 
140
161
  ```typescript
141
162
  import {
163
+ DEFAULT_PROMPTS_GPT_API_URL,
142
164
  PromptsGptClient,
143
165
  syncPrompts,
144
166
  writeAgentFiles,
@@ -147,7 +169,7 @@ import {
147
169
 
148
170
  const client = new PromptsGptClient({
149
171
  token: "pgpt_your_token_here",
150
- apiUrl: "https://prompts-gpt.com",
172
+ apiUrl: DEFAULT_PROMPTS_GPT_API_URL,
151
173
  fetch,
152
174
  });
153
175
 
@@ -175,6 +197,12 @@ console.log(`Wrote ${result.markdown.written.length} prompts`);
175
197
  console.log(`Synced ${result.agents.written.length} agent files`);
176
198
  ```
177
199
 
200
+ ### Runtime requirements
201
+
202
+ - `PromptsGptClient` requires an explicit `fetch` implementation. In Node.js 18.18+ you can pass the built-in `fetch`.
203
+ - The SDK is ESM-only. Use `import`, not `require`.
204
+ - File-writing helpers only write inside the provided project directory and reject path traversal.
205
+
178
206
  ### API methods
179
207
 
180
208
  | Method | Description |
@@ -215,6 +243,8 @@ AGENTS.md # Codex: managed <!-- prompts-gpt:start --> block
215
243
 
216
244
  .github/
217
245
  copilot-instructions.md # VS Code / Copilot shared instructions
246
+ instructions/
247
+ prompts-gpt.instructions.md # Copilot path-specific instructions for generated artifacts
218
248
  prompts/
219
249
  prompts-gpt-senior-code-reviewer.prompt.md # Copilot prompt file
220
250
 
@@ -222,14 +252,16 @@ AGENTS.md # Codex: managed <!-- prompts-gpt:start --> block
222
252
  prompts-gpt.code-snippets # VS Code snippets
223
253
  ```
224
254
 
255
+ `manifest.json` includes each prompt's supported agent targets, recommended local path, and generated file locations so downstream tools can discover the synced artifacts without guessing paths.
256
+
225
257
  ---
226
258
 
227
259
  ## Environment variables
228
260
 
229
261
  | Variable | Description |
230
262
  |----------|-------------|
231
- | `PROMPTS_GPT_TOKEN` | Project API token (alternative to `init`) |
232
- | `PROMPTS_GPT_API_URL` | Custom API base URL for self-hosted instances |
263
+ | `PROMPTS_GPT_TOKEN` | Shell variable you can expand into `--token` for CI or local scripts |
264
+ | `PROMPTS_GPT_API_URL` | Shell variable you can expand into `--api-url` for self-hosted instances |
233
265
 
234
266
  ---
235
267
 
@@ -254,6 +286,8 @@ try {
254
286
 
255
287
  The client automatically retries on `429`, `502`, `503`, and `504` responses with exponential backoff and jitter.
256
288
 
289
+ SDK responses include `X-Request-Id` plus rate-limit headers so CLI errors can be correlated with one server-side request path during support or incident triage.
290
+
257
291
  ---
258
292
 
259
293
  ## CI/CD usage
@@ -263,9 +297,35 @@ The client automatically retries on `429`, `502`, `503`, and `504` responses wit
263
297
  - name: Sync Prompts-GPT agent files
264
298
  env:
265
299
  PROMPTS_GPT_TOKEN: ${{ secrets.PROMPTS_GPT_TOKEN }}
266
- run: npx @prompts-gpt/client sync --agent all --overwrite
300
+ run: npm exec --yes @prompts-gpt/client@latest -- sync --token "$PROMPTS_GPT_TOKEN" --agent all --overwrite
267
301
  ```
268
302
 
303
+ Use `npm exec` here so the job always resolves the package bin explicitly and does not depend on a preinstalled global CLI.
304
+
305
+ ---
306
+
307
+ ## Package contents
308
+
309
+ The published tarball includes:
310
+
311
+ - `dist/` ESM JavaScript, source maps, and `.d.ts` files
312
+ - `README.md`
313
+ - `CHANGELOG.md`
314
+ - `LICENSE`
315
+ - `package.json`
316
+
317
+ This package intentionally does not publish source TypeScript, test fixtures, or local credential files.
318
+
319
+ Before publishing a new release, run:
320
+
321
+ ```bash
322
+ TMPDIR=/private/tmp npm_config_cache=/private/tmp/prompts-gpt-npm-cache npm pack --dry-run
323
+ ```
324
+
325
+ That verifies the `files` whitelist, the generated `dist/` output, and the executable mode on `dist/cli.js` without mutating the real npm cache.
326
+
327
+ Publish with the default npm flow unless the release runs inside a provider that supports npm provenance attestation. If you want provenance, enable it explicitly in that CI job instead of forcing it in `package.json`.
328
+
269
329
  ---
270
330
 
271
331
  ## Security