agent-permission 0.1.1 → 0.1.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/README.md CHANGED
@@ -1,21 +1,41 @@
1
1
  # Agent Permission CLI
2
2
 
3
- Run Agent Permission checks from a terminal or install agent-readable instructions into a project.
3
+ Give AI agents a permission gate before they touch external URLs.
4
4
 
5
5
  ## Quickstart
6
6
 
7
+ ```bash
8
+ npx agent-permission install --adapter auto
9
+ ```
10
+
11
+ This adds an Agent Permission block to the local agent instruction file, such as `AGENTS.md`, `CLAUDE.md`, or `agent-permission.chatgpt.md`, depending on the selected adapter.
12
+
13
+ To install instructions and configure live checks in one step:
14
+
15
+ ```bash
16
+ npx agent-permission install --adapter auto --api-key <YOUR_API_KEY>
17
+ ```
18
+
19
+ Add an API key when you want live checks from the command line, CI, or agent runs:
20
+
7
21
  ```bash
8
22
  npx agent-permission config set api-key <YOUR_API_KEY>
9
23
  npx agent-permission check https://example.com/blog-post --action summarize --exit-code
10
24
  ```
11
25
 
12
- ## Give This To Your Agent
26
+ ## What the Agent Runs
27
+
28
+ After install, project instructions tell compatible agents to run:
13
29
 
14
30
  ```bash
15
- npx agent-permission install --adapter auto
31
+ agent-permission check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
16
32
  ```
17
33
 
18
- This adds an Agent Permission block to the local agent instruction file, such as `AGENTS.md`, `CLAUDE.md`, or `agent-permission.chatgpt.md`, depending on the selected adapter.
34
+ If the binary is unavailable in the agent shell, the installed instructions tell the agent to use:
35
+
36
+ ```bash
37
+ npx -y agent-permission@latest check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
38
+ ```
19
39
 
20
40
  ## Commands
21
41
 
@@ -23,7 +43,7 @@ This adds an Agent Permission block to the local agent instruction file, such as
23
43
  agent-permission check <url> --action <crawl|summarize|extract|train|transact|post>
24
44
  agent-permission batch --file checks.json
25
45
  agent-permission verify-receipt --file receipt.json
26
- agent-permission install --adapter auto|codex|claude|chatgpt|openclaw
46
+ agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--api-key <key>]
27
47
  agent-permission config set api-key <key>
28
48
  agent-permission config doctor
29
49
  ```
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyD,KAAK,EAAuD,OAAO,EAAE,MAAM,YAAY,CAAC;AAExJ,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BzF;AA+GD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CA2BtD"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyD,KAAK,EAAuD,OAAO,EAAE,MAAM,YAAY,CAAC;AAExJ,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BzF;AAgID,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,CA2BtD"}
package/dist/cli.js CHANGED
@@ -100,7 +100,20 @@ async function runInstall(args, runtime, io) {
100
100
  const adapter = parseAdapter(stringFlag(parsed, 'adapter') || parsed.positionals[0] || 'auto');
101
101
  const scope = parseScope(stringFlag(parsed, 'scope') || 'project');
102
102
  const result = await installAgentInstructions(adapter, scope, runtime);
103
- io.stdout(`Installed Agent Permission instructions for ${result.adapter} at ${result.path}`);
103
+ const messages = [`Installed Agent Permission instructions for ${result.adapter} at ${result.path}`];
104
+ const apiKey = stringFlag(parsed, 'api-key');
105
+ if (apiKey) {
106
+ const current = await readConfig(runtime);
107
+ const path = await writeConfig(runtime, { ...current, apiKey });
108
+ messages.push(`Saved API key to ${path}`);
109
+ }
110
+ else {
111
+ const config = await resolveConfig(runtime);
112
+ if (!config.apiKey) {
113
+ messages.push('API key is not configured. Live checks will fail until you run `npx agent-permission config set api-key <YOUR_API_KEY>` or set AGENT_PERMISSION_API_KEY.', 'Verify setup with `npx agent-permission config doctor`.');
114
+ }
115
+ }
116
+ io.stdout(messages.join('\n'));
104
117
  return 0;
105
118
  }
106
119
  async function runConfig(args, runtime, io) {
@@ -192,7 +205,7 @@ Usage:
192
205
  agent-permission check <url> --action <action> [--json] [--exit-code]
193
206
  agent-permission batch --file checks.json [--json]
194
207
  agent-permission verify-receipt --file receipt.json
195
- agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--scope project|user]
208
+ agent-permission install --adapter auto|codex|claude|chatgpt|openclaw [--scope project|user] [--api-key <key>]
196
209
  agent-permission config set api-key <key>
197
210
  agent-permission config doctor
198
211
 
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAa9H;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAU9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,UAqBtE"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAa9H;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAU9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,UA2BtE"}
package/dist/install.js CHANGED
@@ -41,17 +41,27 @@ Before crawling, summarizing, extracting, training on, transacting with, or post
41
41
  agent-permission check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
42
42
  \`\`\`
43
43
 
44
+ If the \`agent-permission\` binary is not available in the agent shell, run the same check through npm:
45
+
46
+ \`\`\`bash
47
+ npx -y agent-permission@latest check <url> --action <crawl|summarize|extract|train|transact|post> --exit-code
48
+ \`\`\`
49
+
44
50
  Use \`crawl\` for fetching or indexing pages, \`summarize\` for compacting page content, \`extract\` for structured data pulls, \`train\` for model training or dataset creation, \`transact\` for purchase/account-changing actions, and \`post\` for creating or modifying remote content.
45
51
 
46
52
  Treat \`allow\` as permitted, \`deny\` as blocked, and \`escalate\` as requiring human approval before continuing. Preserve the returned receipt ID in task notes when a permission decision affects user-visible work.`;
47
53
  }
48
54
  async function detectAdapter(runtime) {
49
55
  const claudePath = join(runtime.cwd, 'CLAUDE.md');
56
+ const chatgptPath = join(runtime.cwd, 'agent-permission.chatgpt.md');
50
57
  const agentsPath = join(runtime.cwd, 'AGENTS.md');
51
58
  if (await fileExists(claudePath))
52
59
  return 'claude';
53
- if (await fileExists(agentsPath))
54
- return 'codex';
60
+ if (await fileExists(chatgptPath))
61
+ return 'chatgpt';
62
+ const agents = await readFileIfExists(agentsPath);
63
+ if (agents !== undefined)
64
+ return isOpenClawInstructions(agents) ? 'openclaw' : 'codex';
55
65
  return 'codex';
56
66
  }
57
67
  function getInstructionPath(adapter, scope, runtime) {
@@ -69,14 +79,21 @@ function getInstructionPath(adapter, scope, runtime) {
69
79
  return join(runtime.cwd, 'AGENTS.md');
70
80
  }
71
81
  async function fileExists(path) {
82
+ return (await readFileIfExists(path)) !== undefined;
83
+ }
84
+ async function readFileIfExists(path) {
72
85
  try {
73
- await readFile(path, 'utf8');
74
- return true;
86
+ return await readFile(path, 'utf8');
75
87
  }
76
- catch {
77
- return false;
88
+ catch (err) {
89
+ if (err && typeof err === 'object' && 'code' in err && err.code === 'ENOENT')
90
+ return undefined;
91
+ throw err;
78
92
  }
79
93
  }
94
+ function isOpenClawInstructions(content) {
95
+ return /\bOpenClaw\b/i.test(content);
96
+ }
80
97
  function escapeRegExp(value) {
81
98
  return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
82
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-permission",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Public CLI for Agent Permission checks and agent workspace installation.",
5
5
  "type": "module",
6
6
  "bin": "./dist/index.js",