@enactprotocol/cli 2.1.14 → 2.1.17

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 (46) hide show
  1. package/dist/commands/init/index.d.ts.map +1 -1
  2. package/dist/commands/init/index.js +6 -377
  3. package/dist/commands/init/index.js.map +1 -1
  4. package/dist/commands/init/templates/agent-agents.d.ts +5 -0
  5. package/dist/commands/init/templates/agent-agents.d.ts.map +1 -0
  6. package/dist/commands/init/templates/agent-agents.js +53 -0
  7. package/dist/commands/init/templates/agent-agents.js.map +1 -0
  8. package/dist/commands/init/templates/claude.d.ts +5 -0
  9. package/dist/commands/init/templates/claude.d.ts.map +1 -0
  10. package/dist/commands/init/templates/claude.js +71 -0
  11. package/dist/commands/init/templates/claude.js.map +1 -0
  12. package/dist/commands/init/templates/index.d.ts +8 -0
  13. package/dist/commands/init/templates/index.d.ts.map +1 -0
  14. package/dist/commands/init/templates/index.js +8 -0
  15. package/dist/commands/init/templates/index.js.map +1 -0
  16. package/dist/commands/init/templates/tool-agents.d.ts +5 -0
  17. package/dist/commands/init/templates/tool-agents.d.ts.map +1 -0
  18. package/dist/commands/init/templates/tool-agents.js +219 -0
  19. package/dist/commands/init/templates/tool-agents.js.map +1 -0
  20. package/dist/commands/init/templates/tool-skill.d.ts +5 -0
  21. package/dist/commands/init/templates/tool-skill.d.ts.map +1 -0
  22. package/dist/commands/init/templates/tool-skill.js +76 -0
  23. package/dist/commands/init/templates/tool-skill.js.map +1 -0
  24. package/dist/commands/publish/index.d.ts +1 -0
  25. package/dist/commands/publish/index.d.ts.map +1 -1
  26. package/dist/commands/publish/index.js +95 -2
  27. package/dist/commands/publish/index.js.map +1 -1
  28. package/dist/commands/sign/index.d.ts +7 -2
  29. package/dist/commands/sign/index.d.ts.map +1 -1
  30. package/dist/commands/sign/index.js +102 -49
  31. package/dist/commands/sign/index.js.map +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/package.json +5 -5
  35. package/src/commands/init/index.ts +11 -380
  36. package/src/commands/init/templates/{agent-agents.md → agent-agents.ts} +20 -15
  37. package/src/commands/init/templates/{claude.md → claude.ts} +24 -19
  38. package/src/commands/init/templates/index.ts +7 -0
  39. package/src/commands/init/templates/tool-agents.ts +218 -0
  40. package/src/commands/init/templates/tool-skill.ts +75 -0
  41. package/src/commands/publish/index.ts +111 -1
  42. package/src/commands/sign/index.ts +127 -52
  43. package/src/index.ts +1 -1
  44. package/tsconfig.tsbuildinfo +1 -1
  45. package/src/commands/init/templates/tool-agents.md +0 -56
  46. package/src/commands/init/templates/tool-enact.md +0 -44
@@ -10,6 +10,12 @@ import { getSecret } from "@enactprotocol/secrets";
10
10
  import type { Command } from "commander";
11
11
  import type { CommandContext, GlobalOptions } from "../../types";
12
12
  import { error, formatError, info, success, warning } from "../../utils";
13
+ import {
14
+ agentAgentsTemplate,
15
+ claudeTemplate,
16
+ toolAgentsTemplate,
17
+ toolSkillTemplate,
18
+ } from "./templates";
13
19
 
14
20
  /** Namespace for stored auth tokens */
15
21
  const AUTH_NAMESPACE = "enact:auth";
@@ -23,388 +29,13 @@ const SUPABASE_ANON_KEY =
23
29
  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNpaWt3a2Znc21vdWlvb2RnaGhvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ2MTkzMzksImV4cCI6MjA4MDE5NTMzOX0.kxnx6-IPFhmGx6rzNx36vbyhFMFZKP_jFqaDbKnJ_E0";
24
30
 
25
31
  /**
26
- * Embedded templates (for single-binary compatibility)
32
+ * Template mapping for loadTemplate function
27
33
  */
28
34
  const TEMPLATES: Record<string, string> = {
29
- "tool-skill.md": `---
30
- name: {{TOOL_NAME}}
31
- description: A simple tool that echoes a greeting
32
- version: 0.1.0
33
- enact: "2.0"
34
-
35
- from: alpine:latest
36
-
37
- inputSchema:
38
- type: object
39
- properties:
40
- name:
41
- type: string
42
- description: Name to greet
43
- default: World
44
- required: []
45
-
46
- command: |
47
- echo "Hello, \${name}!"
48
- ---
49
-
50
- # {{TOOL_NAME}}
51
-
52
- A simple greeting tool created with \`enact init\`.
53
-
54
- ## Usage
55
-
56
- \`\`\`bash
57
- enact run ./ --args '{"name": "Alice"}'
58
- \`\`\`
59
-
60
- ## Customization
61
-
62
- Edit this file to create your own tool:
63
-
64
- 1. Update the \`name\` and \`description\` in the frontmatter
65
- 2. Modify the \`inputSchema\` to define your tool's inputs
66
- 3. Change the \`command\` to run your desired shell commands
67
- 4. Update this documentation section
68
-
69
- ## Learn More
70
-
71
- - [Enact Documentation](https://enact.dev/docs)
72
- - [Tool Manifest Reference](https://enact.dev/docs/manifest)
73
- `,
74
-
75
- "tool-agents.md": `# Enact Tool Development Guide
76
-
77
- Enact tools are containerized, cryptographically-signed executables. Each tool is defined by a \`SKILL.md\` file (YAML frontmatter + Markdown docs).
78
-
79
- ## Quick Reference
80
-
81
- | Task | Command |
82
- |------|---------|
83
- | Run with JSON | \`enact run ./ --args '{"key": "value"}'\` |
84
- | Run from file | \`enact run ./ --input-file inputs.json\` |
85
- | Dry run | \`enact run ./ --args '{}' --dry-run\` |
86
- | Sign & publish | \`enact sign ./ && enact publish ./\` |
87
-
88
- ## SKILL.md Structure
89
-
90
- \`\`\`yaml
91
- ---
92
- name: {{TOOL_NAME}}
93
- description: What the tool does
94
- version: 1.0.0
95
- enact: "2.0.0"
96
-
97
- from: python:3.12-slim # Docker image (pin versions, not :latest)
98
- build: pip install requests # Build steps (cached by Dagger)
99
- command: python /work/main.py \${input}
100
- timeout: 30s
101
-
102
- inputSchema:
103
- type: object
104
- properties:
105
- input:
106
- type: string
107
- description: "Input to process"
108
- required: [input]
109
-
110
- outputSchema:
111
- type: object
112
- properties:
113
- result:
114
- type: string
115
-
116
- env:
117
- API_KEY:
118
- description: "External API key"
119
- secret: true # Set via: enact env set API_KEY --secret
120
- ---
121
- # Tool Name
122
- Documentation here.
123
- \`\`\`
124
-
125
- ## Field Reference
126
-
127
- | Field | Description |
128
- |-------|-------------|
129
- | \`name\` | Hierarchical ID: \`org/category/tool\` |
130
- | \`description\` | What the tool does |
131
- | \`version\` | Semver version |
132
- | \`from\` | Docker image |
133
- | \`build\` | Build commands (string or array, cached) |
134
- | \`command\` | Shell command with \`\${param}\` substitution |
135
- | \`timeout\` | Max execution time (e.g., "30s", "5m") |
136
- | \`inputSchema\` | JSON Schema for inputs |
137
- | \`outputSchema\` | JSON Schema for outputs |
138
- | \`env\` | Environment variables and secrets |
139
-
140
- ## Parameter Substitution
141
-
142
- Enact auto-quotes parameters. **Never manually quote:**
143
-
144
- \`\`\`yaml
145
- # WRONG - causes double-quoting
146
- command: python /work/main.py "\${input}"
147
-
148
- # RIGHT - Enact handles quoting
149
- command: python /work/main.py \${input}
150
- \`\`\`
151
-
152
- **Optional params:** Missing optional params become empty strings. Always provide defaults:
153
- \`\`\`yaml
154
- inputSchema:
155
- properties:
156
- greeting:
157
- type: string
158
- default: "Hello" # Recommended for optional params
159
- \`\`\`
160
-
161
- Or handle empty in shell:
162
- \`\`\`yaml
163
- command: "echo \${greeting:-Hello} \${name}"
164
- \`\`\`
165
-
166
- Modifiers:
167
- - \`\${param}\` — auto-quoted (handles spaces, JSON, special chars)
168
- - \`\${param:raw}\` — raw, no quoting (use carefully)
169
-
170
- ## Output
171
-
172
- Output valid JSON to stdout when \`outputSchema\` is defined:
173
-
174
- \`\`\`python
175
- import json, sys
176
-
177
- try:
178
- result = do_work()
179
- print(json.dumps({"status": "success", "result": result}))
180
- except Exception as e:
181
- print(json.dumps({"status": "error", "message": str(e)}))
182
- sys.exit(1) # non-zero = error
183
- \`\`\`
184
-
185
- ## Build Steps by Language
186
-
187
- **Python:**
188
- \`\`\`yaml
189
- from: python:3.12-slim
190
- build: pip install requests pandas
191
- \`\`\`
192
-
193
- **Node.js:**
194
- \`\`\`yaml
195
- from: node:20-alpine
196
- build:
197
- - npm install
198
- - npm run build
199
- \`\`\`
200
-
201
- **Rust:**
202
- \`\`\`yaml
203
- from: rust:1.83-slim
204
- build: rustc /work/main.rs -o /work/tool
205
- command: /work/tool \${input}
206
- \`\`\`
207
-
208
- **Go:**
209
- \`\`\`yaml
210
- from: golang:1.22-alpine
211
- build: cd /work && go build -o tool main.go
212
- command: /work/tool \${input}
213
- \`\`\`
214
-
215
- **System packages:**
216
- \`\`\`yaml
217
- build: apt-get update && apt-get install -y libfoo-dev
218
- \`\`\`
219
-
220
- Build steps are cached — first run slow, subsequent runs instant.
221
-
222
- ## File Access
223
-
224
- Tools run in a container with \`/work\` as the working directory. All source files are copied there.
225
-
226
- ## Secrets
227
-
228
- Declare in \`SKILL.md\`:
229
- \`\`\`yaml
230
- env:
231
- API_KEY:
232
- description: "API key for service"
233
- secret: true
234
- \`\`\`
235
-
236
- Set before running:
237
- \`\`\`bash
238
- enact env set API_KEY --secret --namespace {{TOOL_NAME}}
239
- \`\`\`
240
-
241
- Access in code:
242
- \`\`\`python
243
- import os
244
- api_key = os.environ.get('API_KEY')
245
- \`\`\`
246
-
247
- ## LLM Instruction Tools
248
-
249
- Tools without a \`command\` field are interpreted by LLMs:
250
-
251
- \`\`\`yaml
252
- ---
253
- name: myorg/ai/reviewer
254
- description: AI-powered code review
255
- inputSchema:
256
- type: object
257
- properties:
258
- code: { type: string }
259
- required: [code]
260
- outputSchema:
261
- type: object
262
- properties:
263
- issues: { type: array }
264
- score: { type: number }
265
- ---
266
- # Code Reviewer
267
-
268
- You are a senior engineer. Review the code for bugs, style, and security.
269
- Return JSON: {"issues": [...], "score": 75}
270
- \`\`\`
271
-
272
- ## Publishing Checklist
273
-
274
- - [ ] \`name\` follows \`namespace/category/tool\` pattern
275
- - [ ] \`version\` set (semver)
276
- - [ ] \`description\` is clear and searchable
277
- - [ ] \`inputSchema\` / \`outputSchema\` defined
278
- - [ ] \`from\` uses pinned image version
279
- - [ ] \`timeout\` set appropriately
280
- - [ ] Tool tested locally with \`enact run ./\`
281
-
282
- ## Troubleshooting
283
-
284
- \`\`\`bash
285
- enact run ./ --args '{"x": "y"}' --verbose # Verbose output
286
- enact run ./ --args '{}' --dry-run # Preview command
287
- enact list # List installed tools
288
- \`\`\`
289
- `,
290
-
291
- "agent-agents.md": `# AGENTS.md
292
-
293
- This project uses Enact tools — containerized, cryptographically-signed executables.
294
-
295
- ## Running Tools
296
- \`\`\`bash
297
- enact run <tool-name> --args '{"key": "value"}' # Run installed tool
298
- enact run ./path/to/tool --args '{}' # Run local tool
299
- \`\`\`
300
-
301
- ## Finding & Installing Tools
302
- \`\`\`bash
303
- enact search "pdf extraction" # Search registry
304
- enact get author/category/tool # View tool info
305
- enact learn author/category/tool # View tool documentation
306
- enact install author/category/tool # Add to project (.enact/tools.json)
307
- enact install author/category/tool --global # Add globally
308
- enact list # List project tools
309
- \`\`\`
310
-
311
- ## Tool Output
312
- Tools output JSON to stdout. Parse with jq or your language's JSON parser:
313
- \`\`\`bash
314
- enact run tool --args '{}' | jq '.result'
315
- \`\`\`
316
-
317
- ## Creating Local Tools
318
- Create \`tools/<name>/SKILL.md\` with:
319
- \`\`\`yaml
320
- ---
321
- name: my-tool
322
- description: What it does
323
- command: echo "Hello \${name}"
324
- inputSchema:
325
- type: object
326
- properties:
327
- name: { type: string }
328
- ---
329
- # My Tool
330
- Documentation here.
331
- \`\`\`
332
- Run with: \`enact run ./tools/<name> --args '{"name": "World"}'\`
333
-
334
- ## Environment & Secrets
335
- \`\`\`bash
336
- enact env set API_KEY --secret --namespace author/tool # Set secret
337
- enact env list # List env vars
338
- \`\`\`
339
- `,
340
-
341
- "claude.md": `# CLAUDE.md
342
-
343
- This project uses Enact tools — containerized, signed executables you can run via CLI.
344
-
345
- ## Quick Reference
346
- \`\`\`bash
347
- enact run <tool> --args '{"key": "value"}' # Run a tool
348
- enact search "keyword" # Find tools
349
- enact learn author/tool # View tool documentation
350
- enact install author/tool # Install tool
351
- enact list # List installed tools
352
- \`\`\`
353
-
354
- ## Running Tools
355
- Tools take JSON input and return JSON output:
356
- \`\`\`bash
357
- # Run and capture output
358
- result=$(enact run author/utils/formatter --args '{"code": "const x=1"}')
359
-
360
- # Parse with jq
361
- enact run tool --args '{}' | jq '.data'
362
- \`\`\`
363
-
364
- ## Creating Tools
365
- Create \`SKILL.md\` in a directory:
366
- \`\`\`yaml
367
- ---
368
- name: namespace/category/tool
369
- description: Clear description for search
370
- version: 1.0.0
371
- from: python:3.12-slim # Docker image
372
- build: pip install requests # Install dependencies (cached)
373
- command: python /work/main.py \${input}
374
- inputSchema:
375
- type: object
376
- properties:
377
- input: { type: string, description: "The input to process" }
378
- required: [input]
379
- ---
380
- # Tool Name
381
- Usage documentation here.
382
- \`\`\`
383
-
384
- Key points:
385
- - \`\${param}\` is auto-quoted — never add manual quotes
386
- - \`from:\` pin image versions (not \`:latest\`)
387
- - \`build:\` steps are cached by Dagger
388
- - Output JSON to stdout, errors to stderr
389
- - Non-zero exit = failure
390
-
391
- ## Tool Development Workflow
392
- \`\`\`bash
393
- enact run ./ --args '{"input": "test"}' # Test locally
394
- enact run ./ --args '{}' --dry-run # Preview command
395
- enact sign ./ && enact publish ./ # Publish
396
- \`\`\`
397
-
398
- ## Secrets
399
- Declare in SKILL.md, set via CLI:
400
- \`\`\`yaml
401
- env:
402
- API_KEY: # Declared but not set
403
- \`\`\`
404
- \`\`\`bash
405
- enact env set API_KEY --secret --namespace author/tool
406
- \`\`\`
407
- `,
35
+ "tool-skill.md": toolSkillTemplate,
36
+ "tool-agents.md": toolAgentsTemplate,
37
+ "agent-agents.md": agentAgentsTemplate,
38
+ "claude.md": claudeTemplate,
408
39
  };
409
40
 
410
41
  interface InitOptions extends GlobalOptions {
@@ -1,35 +1,39 @@
1
- # AGENTS.md
1
+ /**
2
+ * AGENTS.md template for projects that use Enact tools
3
+ */
4
+ export const agentAgentsTemplate = `# AGENTS.md
2
5
 
3
6
  This project uses Enact tools — containerized, cryptographically-signed executables.
4
7
 
5
8
  ## Running Tools
6
- ```bash
9
+ \`\`\`bash
7
10
  enact run <tool-name> --args '{"key": "value"}' # Run installed tool
8
11
  enact run ./path/to/tool --args '{}' # Run local tool
9
- ```
12
+ \`\`\`
10
13
 
11
14
  ## Finding & Installing Tools
12
- ```bash
15
+ \`\`\`bash
13
16
  enact search "pdf extraction" # Search registry
14
- enact get author/category/tool # View tool info
17
+ enact info author/category/tool # View tool info
18
+ enact learn author/category/tool # View tool documentation
15
19
  enact install author/category/tool # Add to project (.enact/tools.json)
16
20
  enact install author/category/tool --global # Add globally
17
21
  enact list # List project tools
18
- ```
22
+ \`\`\`
19
23
 
20
24
  ## Tool Output
21
25
  Tools output JSON to stdout. Parse with jq or your language's JSON parser:
22
- ```bash
26
+ \`\`\`bash
23
27
  enact run tool --args '{}' | jq '.result'
24
- ```
28
+ \`\`\`
25
29
 
26
30
  ## Creating Local Tools
27
- Create `tools/<name>/enact.md` with:
28
- ```yaml
31
+ Create \`tools/<name>/SKILL.md\` with:
32
+ \`\`\`yaml
29
33
  ---
30
34
  name: my-tool
31
35
  description: What it does
32
- command: echo "Hello ${name}"
36
+ command: echo "Hello \${name}"
33
37
  inputSchema:
34
38
  type: object
35
39
  properties:
@@ -37,11 +41,12 @@ inputSchema:
37
41
  ---
38
42
  # My Tool
39
43
  Documentation here.
40
- ```
41
- Run with: `enact run ./tools/<name> --args '{"name": "World"}'`
44
+ \`\`\`
45
+ Run with: \`enact run ./tools/<name> --args '{"name": "World"}'\`
42
46
 
43
47
  ## Environment & Secrets
44
- ```bash
48
+ \`\`\`bash
45
49
  enact env set API_KEY --secret --namespace author/tool # Set secret
46
50
  enact env list # List env vars
47
- ```
51
+ \`\`\`
52
+ `;
@@ -1,35 +1,39 @@
1
- # CLAUDE.md
1
+ /**
2
+ * CLAUDE.md template for Claude integration
3
+ */
4
+ export const claudeTemplate = `# CLAUDE.md
2
5
 
3
6
  This project uses Enact tools — containerized, signed executables you can run via CLI.
4
7
 
5
8
  ## Quick Reference
6
- ```bash
9
+ \`\`\`bash
7
10
  enact run <tool> --args '{"key": "value"}' # Run a tool
8
11
  enact search "keyword" # Find tools
12
+ enact learn author/tool # View tool documentation
9
13
  enact install author/tool # Install tool
10
14
  enact list # List installed tools
11
- ```
15
+ \`\`\`
12
16
 
13
17
  ## Running Tools
14
18
  Tools take JSON input and return JSON output:
15
- ```bash
19
+ \`\`\`bash
16
20
  # Run and capture output
17
21
  result=$(enact run author/utils/formatter --args '{"code": "const x=1"}')
18
22
 
19
23
  # Parse with jq
20
24
  enact run tool --args '{}' | jq '.data'
21
- ```
25
+ \`\`\`
22
26
 
23
27
  ## Creating Tools
24
- Create `enact.md` in a directory:
25
- ```yaml
28
+ Create \`SKILL.md\` in a directory:
29
+ \`\`\`yaml
26
30
  ---
27
31
  name: namespace/category/tool
28
32
  description: Clear description for search
29
33
  version: 1.0.0
30
34
  from: python:3.12-slim # Docker image
31
35
  build: pip install requests # Install dependencies (cached)
32
- command: python /work/main.py ${input}
36
+ command: python /work/main.py \${input}
33
37
  inputSchema:
34
38
  type: object
35
39
  properties:
@@ -38,28 +42,29 @@ inputSchema:
38
42
  ---
39
43
  # Tool Name
40
44
  Usage documentation here.
41
- ```
45
+ \`\`\`
42
46
 
43
47
  Key points:
44
- - `${param}` is auto-quoted — never add manual quotes
45
- - `from:` pin image versions (not `:latest`)
46
- - `build:` steps are cached by Dagger
48
+ - \`\${param}\` is auto-quoted — never add manual quotes
49
+ - \`from:\` pin image versions (not \`:latest\`)
50
+ - \`build:\` steps are cached by Dagger
47
51
  - Output JSON to stdout, errors to stderr
48
52
  - Non-zero exit = failure
49
53
 
50
54
  ## Tool Development Workflow
51
- ```bash
55
+ \`\`\`bash
52
56
  enact run ./ --args '{"input": "test"}' # Test locally
53
57
  enact run ./ --args '{}' --dry-run # Preview command
54
58
  enact sign ./ && enact publish ./ # Publish
55
- ```
59
+ \`\`\`
56
60
 
57
61
  ## Secrets
58
- Declare in enact.md, set via CLI:
59
- ```yaml
62
+ Declare in SKILL.md, set via CLI:
63
+ \`\`\`yaml
60
64
  env:
61
65
  API_KEY: # Declared but not set
62
- ```
63
- ```bash
66
+ \`\`\`
67
+ \`\`\`bash
64
68
  enact env set API_KEY --secret --namespace author/tool
65
- ```
69
+ \`\`\`
70
+ `;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Template exports for enact init command
3
+ */
4
+ export { toolSkillTemplate } from "./tool-skill";
5
+ export { toolAgentsTemplate } from "./tool-agents";
6
+ export { agentAgentsTemplate } from "./agent-agents";
7
+ export { claudeTemplate } from "./claude";