requestshield 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -1,127 +1,246 @@
1
1
  # RequestShield CLI
2
2
 
3
- Customer-facing CLI for signing in, rotating RequestShield application keys,
4
- and installing the RequestShield skill for Codex or Claude.
3
+ Customer-facing CLI for IntelliFend RequestShield. It allows customers to sign
4
+ in, rotate application credentials, install the RequestShield Skill for Codex
5
+ or Claude, and update an npm-installed CLI.
6
+
7
+ Current package version: `0.1.4`.
5
8
 
6
9
  ## Requirements
7
10
 
8
11
  - Node.js 22.13 or newer.
9
- - A customer management API implementing the contract below.
12
+ - A RequestShield customer management API.
13
+ - npm for local development and publishing.
10
14
 
11
- The API defaults to `https://api.intellifend.ai`. For development, set
12
- `REQUESTSHIELD_API_URL` to the management API origin.
15
+ The management API defaults to `https://api.intellifend.ai`. Set
16
+ `REQUESTSHIELD_API_URL` to use a different management API during development.
13
17
 
14
- ## Commands
18
+ ## Implemented commands
15
19
 
16
20
  ```console
17
21
  requestshield signin
22
+ requestshield keys create [--yes]
23
+ requestshield agent setup [--force]
24
+ requestshield agent setup --codex [--force]
25
+ requestshield agent setup --claude [--force]
26
+ requestshield update check
27
+ requestshield --help
28
+ requestshield --version
29
+ ```
30
+
31
+ ### Sign in
32
+
33
+ ```console
34
+ requestshield signin
35
+ ```
36
+
37
+ Starts the device authorization flow. The CLI prints the verification URL and
38
+ user code without opening the browser automatically. After authorization, the
39
+ session is stored for the current operating-system user.
40
+
41
+ For CI or automation, provide `REQUESTSHIELD_ACCESS_TOKEN`. A token supplied by
42
+ the environment is used directly and is not persisted by the CLI.
43
+
44
+ ### Create new keys
45
+
46
+ ```console
18
47
  requestshield keys create
48
+ ```
49
+
50
+ Asks the customer to type `ROTATE`, then calls the management API to deactivate
51
+ the previous credentials and create a new `appKey` and `apiSecret`.
52
+
53
+ - `appKey` is the public application identifier.
54
+ - `apiSecret` is a backend-only secret displayed once.
55
+ - The CLI does not save the returned `apiSecret`.
56
+ - `--yes` skips the confirmation prompt for non-interactive automation.
57
+
58
+ Store the Secret Key in a backend secret manager immediately after creation.
59
+
60
+ ### Install the Agent Skill
61
+
62
+ Let the CLI detect the installed coding agent:
63
+
64
+ ```console
19
65
  requestshield agent setup
66
+ ```
67
+
68
+ Or select an agent explicitly:
69
+
70
+ ```console
20
71
  requestshield agent setup --codex
21
72
  requestshield agent setup --claude
22
73
  ```
23
74
 
24
- `signin` starts a device authorization flow and prints the verification URL and
25
- code for the customer to open manually. The returned session is stored under the user's standard
26
- application-data directory with permissions restricted to that user. CI may
27
- instead provide `REQUESTSHIELD_ACCESS_TOKEN`; environment tokens are never
28
- persisted.
75
+ The CLI installs the Skill into:
29
76
 
30
- `keys create` asks for confirmation, then atomically deactivates the previous
31
- application credentials and creates a new `appKey` + `apiSecret`. The public
32
- app key and the backend-only secret are printed after success. The secret is
33
- not stored by the CLI and cannot be retrieved again.
77
+ - Codex: `~/.agents/skills/requestshield`
78
+ - Claude: `~/.claude/skills/requestshield`
34
79
 
35
- `agent setup` detects Codex or Claude and installs the bundled `requestshield`
36
- skill into `~/.agents/skills` for Codex or `~/.claude/skills` for Claude. Use
37
- `--codex` or `--claude` to select one directly. When both agents are detected,
38
- an interactive terminal asks which one to use; non-interactive callers must
39
- provide one of the flags. Existing content is preserved unless `--force` is
40
- supplied.
80
+ If exactly one supported agent is detected, it is selected automatically. If
81
+ both are detected in an interactive terminal, the CLI asks which one to use.
82
+ If neither is detected, select one with `--codex` or `--claude`.
41
83
 
42
- ## Management API contract
84
+ Existing Skill content is preserved. Add `--force` to replace it:
43
85
 
44
- ### Start sign-in
86
+ ```console
87
+ requestshield agent setup --codex --force
88
+ ```
45
89
 
46
- `POST /v1/cli/signin`
90
+ Restart the selected agent or start a new task after installation.
47
91
 
48
- ```json
49
- {
50
- "client": "requestshield-cli"
51
- }
92
+ ### Check for updates
93
+
94
+ ```console
95
+ requestshield update check
52
96
  ```
53
97
 
54
- The response contains `deviceCode`, `userCode`, `verificationUri`,
55
- `expiresIn`, and `interval`.
98
+ Checks the npm registry for the latest `requestshield` version. When a newer
99
+ version exists, the CLI displays the current and latest versions and asks:
56
100
 
57
- ### Poll sign-in
101
+ ```text
102
+ Update to RequestShield <version>? (y/N):
103
+ ```
58
104
 
59
- `POST /v1/cli/signin/token` with `{ "deviceCode": "..." }`.
105
+ Entering `y` runs the equivalent of:
60
106
 
61
- Pending responses use HTTP 400 with `code` set to `authorization_pending` or
62
- `slow_down`. A successful response contains `accessToken` and optional account
63
- metadata.
107
+ ```console
108
+ npm install --global requestshield@<latest-version>
109
+ ```
64
110
 
65
- ### Rotate keys
111
+ This command requires an interactive terminal, Node.js, and npm. It updates a
112
+ global npm installation; it does not replace a standalone Windows executable.
66
113
 
67
- `POST /v1/cli/keys/rotate` with Bearer authentication and an empty JSON body.
68
- The response contains `appKey` and one-time `apiSecret`.
114
+ ## Install with npm
69
115
 
70
- ## Development
116
+ Install globally:
71
117
 
72
118
  ```console
73
- pnpm --filter requestshield lint
74
- pnpm --filter requestshield typecheck
75
- pnpm --filter requestshield test
76
- pnpm --filter requestshield build
119
+ npm install --global requestshield
120
+ requestshield --help
121
+ requestshield --version
77
122
  ```
78
- ## Quick start
79
-
80
- RequestShield requires Node.js 22.13 or newer.
81
123
 
82
- Run without installing globally:
124
+ Run a specific version without installing globally:
83
125
 
84
126
  ```console
85
- npx requestshield --help
86
- npx requestshield signin
87
- npx requestshield keys create
88
- npx requestshield agent setup
89
- npx requestshield agent setup --codex
90
- npx requestshield agent setup --claude
127
+ npx --yes requestshield@0.1.4 --help
128
+ npx --yes requestshield@0.1.4 signin
91
129
  ```
92
130
 
93
- Pin a specific version for reproducible usage:
131
+ To invoke the update command through npx, include the package name:
94
132
 
95
133
  ```console
96
- npx requestshield@0.1.0 --help
134
+ npx --yes requestshield@0.1.4 update check
97
135
  ```
98
136
 
99
- ## Packaging the bundled skill
137
+ Do not run `npx update check`; npm interprets `update` as the name of a different
138
+ npm package.
100
139
 
101
- The canonical RequestShield skill lives at `../skills/requestshield`, outside
102
- this npm package directory. The `prepack` hook temporarily copies the complete
103
- skill into `skills/requestshield`, and `postpack` removes that generated copy
104
- after npm creates the tarball. Do not edit the generated copy.
140
+ ## Local development
105
141
 
106
- Build and inspect a local package from this directory:
142
+ From the `requestshield-cli` directory:
107
143
 
108
144
  ```console
109
- npm test
110
- npm run typecheck
145
+ npm install
111
146
  npm run lint
147
+ npm run typecheck
148
+ npm test
149
+ npm run build
150
+ node src/main.mjs --help
151
+ node src/main.mjs --version
152
+ ```
153
+
154
+ The current `build` script validates the syntax of the `.mjs` source files. It
155
+ does not generate a standalone executable.
156
+
157
+ ### Test the update flow locally
158
+
159
+ The manual update test mocks the registry and install operation, so it does not
160
+ publish a package or change the installed version:
161
+
162
+ ```powershell
163
+ $env:REQUESTSHIELD_MOCK_LATEST_VERSION = "0.1.5"
164
+ npm run test:update-check:manual
165
+ Remove-Item Env:REQUESTSHIELD_MOCK_LATEST_VERSION
166
+ ```
167
+
168
+ After entering `y`, the test prints `[MOCK] Would install ...`.
169
+
170
+ ## Packaging the RequestShield Skill
171
+
172
+ The canonical Skill is stored at `../skills/requestshield`. Do not maintain a
173
+ second source copy inside this package.
174
+
175
+ Before npm creates the package, the `prepack` hook temporarily copies the
176
+ canonical Skill to `skills/requestshield`. The `postpack` hook removes that
177
+ generated copy after packaging.
178
+
179
+ Inspect the files that npm will publish:
180
+
181
+ ```console
112
182
  npm pack --dry-run
113
183
  ```
114
184
 
115
- To exercise the package entry point and bundled skill, create a tarball and run
116
- the command through that tarball:
185
+ Create a local tarball:
117
186
 
118
187
  ```console
119
188
  npm pack
120
- npx --yes --package=./requestshield-0.1.0.tgz requestshield agent setup --codex
121
189
  ```
122
190
 
123
- To automatically accept npm's installation prompt:
191
+ ## Publish to npm
192
+
193
+ npm does not allow an existing package version to be overwritten. Check the
194
+ published version, merge the latest team changes, then choose a new version in
195
+ `package.json` before publishing.
196
+
197
+ ```console
198
+ npm view requestshield version
199
+ npm run lint
200
+ npm run typecheck
201
+ npm test
202
+ npm pack --dry-run
203
+ npm publish --access public
204
+ ```
205
+
206
+ Verify the published package:
124
207
 
125
208
  ```console
126
- npx --yes requestshield@0.1.0 --help
209
+ npm view requestshield version
210
+ npm dist-tag ls requestshield
211
+ npx --yes requestshield@0.1.4 --version
127
212
  ```
213
+
214
+ ## Management API contract
215
+
216
+ ### Start sign-in
217
+
218
+ `POST /v1/cli/signin`
219
+
220
+ ```json
221
+ {
222
+ "client": "requestshield-cli"
223
+ }
224
+ ```
225
+
226
+ The response contains `deviceCode`, `userCode`, `verificationUri`, `expiresIn`,
227
+ and `interval`.
228
+
229
+ ### Poll sign-in
230
+
231
+ `POST /v1/cli/signin/token` with `{ "deviceCode": "..." }`.
232
+
233
+ Pending responses use HTTP 400 with `code` set to `authorization_pending` or
234
+ `slow_down`. A successful response contains `accessToken` and optional account
235
+ metadata.
236
+
237
+ ### Rotate keys
238
+
239
+ `POST /v1/cli/keys/rotate` with Bearer authentication and an empty JSON body.
240
+ The response contains `appKey` and the one-time `apiSecret`.
241
+
242
+ ## Security notes
243
+
244
+ - Never place an access token or Secret Key in URLs, command arguments, logs,
245
+ test fixtures, or committed files.
246
+ - The CLI does not persist the Secret Key returned by `keys create`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "requestshield",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Customer CLI for IntelliFend RequestShield.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,20 +14,18 @@
14
14
  "engines": {
15
15
  "node": ">=22.13"
16
16
  },
17
- "scripts": {
18
- "build": "node scripts/check-package.mjs",
19
- "lint": "node scripts/check-package.mjs",
20
- "test": "node --test",
21
- "typecheck": "tsc -p jsconfig.json --noEmit",
22
- "prepack": "node scripts/package-skill.mjs stage",
23
- "postpack": "node scripts/package-skill.mjs clean",
24
- "prepublishOnly": "npm run lint && npm run typecheck && npm test"
25
- },
26
17
  "devDependencies": {
27
18
  "@types/node": "26.1.1",
28
19
  "esbuild": "^0.28.1",
29
20
  "postject": "1.0.0-alpha.6",
30
21
  "typescript": "^6.0.3"
31
22
  },
32
- "license": "UNLICENSED"
33
- }
23
+ "license": "UNLICENSED",
24
+ "scripts": {
25
+ "build": "node scripts/check-package.mjs",
26
+ "lint": "node scripts/check-package.mjs",
27
+ "test": "node --test",
28
+ "test:update-check:manual": "node scripts/manual-update-check.mjs",
29
+ "typecheck": "tsc -p jsconfig.json --noEmit"
30
+ }
31
+ }