@enactprotocol/cli 2.1.6 → 2.1.10
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/dist/commands/auth/index.js +1 -1
- package/dist/commands/auth/index.js.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/info/index.d.ts +11 -0
- package/dist/commands/info/index.d.ts.map +1 -0
- package/dist/commands/info/index.js +232 -0
- package/dist/commands/info/index.js.map +1 -0
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +92 -61
- package/dist/commands/init/index.js.map +1 -1
- package/dist/commands/learn/index.d.ts +4 -0
- package/dist/commands/learn/index.d.ts.map +1 -1
- package/dist/commands/learn/index.js +159 -5
- package/dist/commands/learn/index.js.map +1 -1
- package/dist/commands/mcp/index.d.ts +20 -0
- package/dist/commands/mcp/index.d.ts.map +1 -0
- package/dist/commands/mcp/index.js +460 -0
- package/dist/commands/mcp/index.js.map +1 -0
- package/dist/commands/publish/index.d.ts.map +1 -1
- package/dist/commands/publish/index.js +14 -7
- package/dist/commands/publish/index.js.map +1 -1
- package/dist/commands/sign/index.d.ts +2 -1
- package/dist/commands/sign/index.d.ts.map +1 -1
- package/dist/commands/sign/index.js +75 -17
- package/dist/commands/sign/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/commands/auth/index.ts +1 -1
- package/src/commands/index.ts +1 -1
- package/src/commands/{get → info}/index.ts +103 -16
- package/src/commands/init/index.ts +104 -65
- package/src/commands/learn/index.ts +228 -5
- package/src/commands/publish/index.ts +14 -7
- package/src/commands/sign/index.ts +93 -18
- package/src/index.ts +3 -3
- package/tests/commands/{get.test.ts → info.test.ts} +35 -33
- package/tests/commands/init.test.ts +204 -17
- package/tests/commands/learn.test.ts +2 -2
- package/tests/e2e.test.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- /package/tests/fixtures/echo-tool/{enact.md → SKILL.md} +0 -0
|
@@ -19,7 +19,7 @@ const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY ??
|
|
|
19
19
|
* Embedded templates (for single-binary compatibility)
|
|
20
20
|
*/
|
|
21
21
|
const TEMPLATES = {
|
|
22
|
-
"tool-
|
|
22
|
+
"tool-skill.md": `---
|
|
23
23
|
name: {{TOOL_NAME}}
|
|
24
24
|
description: A simple tool that echoes a greeting
|
|
25
25
|
version: 0.1.0
|
|
@@ -66,7 +66,7 @@ Edit this file to create your own tool:
|
|
|
66
66
|
`,
|
|
67
67
|
"tool-agents.md": `# Enact Tool Development Guide
|
|
68
68
|
|
|
69
|
-
Enact tools are containerized, cryptographically-signed executables. Each tool is defined by
|
|
69
|
+
Enact tools are containerized, cryptographically-signed executables. Each tool is defined by a \`SKILL.md\` file (YAML frontmatter + Markdown docs).
|
|
70
70
|
|
|
71
71
|
## Quick Reference
|
|
72
72
|
|
|
@@ -77,7 +77,7 @@ Enact tools are containerized, cryptographically-signed executables. Each tool i
|
|
|
77
77
|
| Dry run | \`enact run ./ --args '{}' --dry-run\` |
|
|
78
78
|
| Sign & publish | \`enact sign ./ && enact publish ./\` |
|
|
79
79
|
|
|
80
|
-
##
|
|
80
|
+
## SKILL.md Structure
|
|
81
81
|
|
|
82
82
|
\`\`\`yaml
|
|
83
83
|
---
|
|
@@ -217,7 +217,7 @@ Tools run in a container with \`/work\` as the working directory. All source fil
|
|
|
217
217
|
|
|
218
218
|
## Secrets
|
|
219
219
|
|
|
220
|
-
Declare in \`
|
|
220
|
+
Declare in \`SKILL.md\`:
|
|
221
221
|
\`\`\`yaml
|
|
222
222
|
env:
|
|
223
223
|
API_KEY:
|
|
@@ -293,6 +293,7 @@ enact run ./path/to/tool --args '{}' # Run local tool
|
|
|
293
293
|
\`\`\`bash
|
|
294
294
|
enact search "pdf extraction" # Search registry
|
|
295
295
|
enact get author/category/tool # View tool info
|
|
296
|
+
enact learn author/category/tool # View tool documentation
|
|
296
297
|
enact install author/category/tool # Add to project (.enact/tools.json)
|
|
297
298
|
enact install author/category/tool --global # Add globally
|
|
298
299
|
enact list # List project tools
|
|
@@ -305,7 +306,7 @@ enact run tool --args '{}' | jq '.result'
|
|
|
305
306
|
\`\`\`
|
|
306
307
|
|
|
307
308
|
## Creating Local Tools
|
|
308
|
-
Create \`tools/<name>/
|
|
309
|
+
Create \`tools/<name>/SKILL.md\` with:
|
|
309
310
|
\`\`\`yaml
|
|
310
311
|
---
|
|
311
312
|
name: my-tool
|
|
@@ -335,6 +336,7 @@ This project uses Enact tools — containerized, signed executables you can run
|
|
|
335
336
|
\`\`\`bash
|
|
336
337
|
enact run <tool> --args '{"key": "value"}' # Run a tool
|
|
337
338
|
enact search "keyword" # Find tools
|
|
339
|
+
enact learn author/tool # View tool documentation
|
|
338
340
|
enact install author/tool # Install tool
|
|
339
341
|
enact list # List installed tools
|
|
340
342
|
\`\`\`
|
|
@@ -350,7 +352,7 @@ enact run tool --args '{}' | jq '.data'
|
|
|
350
352
|
\`\`\`
|
|
351
353
|
|
|
352
354
|
## Creating Tools
|
|
353
|
-
Create \`
|
|
355
|
+
Create \`SKILL.md\` in a directory:
|
|
354
356
|
\`\`\`yaml
|
|
355
357
|
---
|
|
356
358
|
name: namespace/category/tool
|
|
@@ -384,7 +386,7 @@ enact sign ./ && enact publish ./ # Publish
|
|
|
384
386
|
\`\`\`
|
|
385
387
|
|
|
386
388
|
## Secrets
|
|
387
|
-
Declare in
|
|
389
|
+
Declare in SKILL.md, set via CLI:
|
|
388
390
|
\`\`\`yaml
|
|
389
391
|
env:
|
|
390
392
|
API_KEY: # Declared but not set
|
|
@@ -408,6 +410,26 @@ function loadTemplate(templateName, replacements = {}) {
|
|
|
408
410
|
}
|
|
409
411
|
return content;
|
|
410
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Create .enact/tools.json for project tool tracking
|
|
415
|
+
*/
|
|
416
|
+
function createEnactProjectDir(targetDir, force) {
|
|
417
|
+
const enactDir = join(targetDir, ".enact");
|
|
418
|
+
const toolsJsonPath = join(enactDir, "tools.json");
|
|
419
|
+
// Check if tools.json already exists
|
|
420
|
+
if (existsSync(toolsJsonPath) && !force) {
|
|
421
|
+
info(".enact/tools.json already exists, skipping");
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
// Create .enact directory if it doesn't exist
|
|
425
|
+
if (!existsSync(enactDir)) {
|
|
426
|
+
mkdirSync(enactDir, { recursive: true });
|
|
427
|
+
}
|
|
428
|
+
// Write empty tools.json
|
|
429
|
+
const toolsJson = { tools: {} };
|
|
430
|
+
writeFileSync(toolsJsonPath, `${JSON.stringify(toolsJson, null, 2)}\n`, "utf-8");
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
411
433
|
/**
|
|
412
434
|
* Get the current logged-in username
|
|
413
435
|
*/
|
|
@@ -471,23 +493,57 @@ async function getCurrentUsername() {
|
|
|
471
493
|
*/
|
|
472
494
|
async function initHandler(options, ctx) {
|
|
473
495
|
const targetDir = ctx.cwd;
|
|
474
|
-
// Determine mode: --
|
|
475
|
-
const
|
|
496
|
+
// Determine mode: --tool, --claude, or --agent (default)
|
|
497
|
+
const isToolMode = options.tool;
|
|
476
498
|
const isClaudeMode = options.claude;
|
|
477
|
-
// Default to
|
|
478
|
-
// Handle --
|
|
479
|
-
if (
|
|
499
|
+
// Default to agent mode if no flag specified
|
|
500
|
+
// Handle --tool mode: create SKILL.md + AGENTS.md for tool development
|
|
501
|
+
if (isToolMode) {
|
|
502
|
+
const manifestPath = join(targetDir, "SKILL.md");
|
|
480
503
|
const agentsPath = join(targetDir, "AGENTS.md");
|
|
481
|
-
if (existsSync(
|
|
482
|
-
warning(`
|
|
504
|
+
if (existsSync(manifestPath) && !options.force) {
|
|
505
|
+
warning(`Tool manifest already exists at: ${manifestPath}`);
|
|
483
506
|
info("Use --force to overwrite");
|
|
484
507
|
return;
|
|
485
508
|
}
|
|
486
|
-
|
|
487
|
-
|
|
509
|
+
// Get username for the tool name
|
|
510
|
+
let toolName = options.name;
|
|
511
|
+
if (!toolName) {
|
|
512
|
+
const username = await getCurrentUsername();
|
|
513
|
+
if (username) {
|
|
514
|
+
toolName = `${username}/my-tool`;
|
|
515
|
+
info(`Using logged-in username: ${username}`);
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
toolName = "my-tool";
|
|
519
|
+
info("Not logged in - using generic tool name");
|
|
520
|
+
info("Run 'enact auth login' to use your username in tool names");
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
// Load templates with placeholder replacement
|
|
524
|
+
const replacements = { TOOL_NAME: toolName };
|
|
525
|
+
const manifestContent = loadTemplate("tool-skill.md", replacements);
|
|
526
|
+
const agentsContent = loadTemplate("tool-agents.md", replacements);
|
|
527
|
+
// Ensure directory exists
|
|
528
|
+
if (!existsSync(targetDir)) {
|
|
529
|
+
mkdirSync(targetDir, { recursive: true });
|
|
530
|
+
}
|
|
531
|
+
// Write SKILL.md
|
|
532
|
+
writeFileSync(manifestPath, manifestContent, "utf-8");
|
|
533
|
+
success(`Created tool manifest: ${manifestPath}`);
|
|
534
|
+
// Write AGENTS.md (only if it doesn't exist or --force is used)
|
|
535
|
+
if (!existsSync(agentsPath) || options.force) {
|
|
536
|
+
writeFileSync(agentsPath, agentsContent, "utf-8");
|
|
537
|
+
success(`Created AGENTS.md: ${agentsPath}`);
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
info("AGENTS.md already exists, skipping (use --force to overwrite)");
|
|
541
|
+
}
|
|
488
542
|
info("");
|
|
489
|
-
info("
|
|
490
|
-
info("
|
|
543
|
+
info("Next steps:");
|
|
544
|
+
info(" 1. Edit SKILL.md to customize your tool");
|
|
545
|
+
info(" 2. Run 'enact run ./' to test your tool");
|
|
546
|
+
info(" 3. Run 'enact publish' to share your tool");
|
|
491
547
|
return;
|
|
492
548
|
}
|
|
493
549
|
// Handle --claude mode: create CLAUDE.md
|
|
@@ -500,56 +556,31 @@ async function initHandler(options, ctx) {
|
|
|
500
556
|
}
|
|
501
557
|
writeFileSync(claudePath, loadTemplate("claude.md"), "utf-8");
|
|
502
558
|
success(`Created CLAUDE.md: ${claudePath}`);
|
|
559
|
+
// Create .enact/tools.json
|
|
560
|
+
if (createEnactProjectDir(targetDir, options.force ?? false)) {
|
|
561
|
+
success("Created .enact/tools.json");
|
|
562
|
+
}
|
|
503
563
|
info("");
|
|
504
564
|
info("This file helps Claude understand how to use Enact tools in your project.");
|
|
505
565
|
return;
|
|
506
566
|
}
|
|
507
|
-
// Handle
|
|
508
|
-
const manifestPath = join(targetDir, "enact.md");
|
|
567
|
+
// Handle default (agent) mode: create AGENTS.md for projects using Enact tools
|
|
509
568
|
const agentsPath = join(targetDir, "AGENTS.md");
|
|
510
|
-
if (existsSync(
|
|
511
|
-
warning(`
|
|
569
|
+
if (existsSync(agentsPath) && !options.force) {
|
|
570
|
+
warning(`AGENTS.md already exists at: ${agentsPath}`);
|
|
512
571
|
info("Use --force to overwrite");
|
|
513
572
|
return;
|
|
514
573
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
toolName = `${username}/my-tool`;
|
|
521
|
-
info(`Using logged-in username: ${username}`);
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
toolName = "my-tool";
|
|
525
|
-
info("Not logged in - using generic tool name");
|
|
526
|
-
info("Run 'enact auth login' to use your username in tool names");
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
// Load templates with placeholder replacement
|
|
530
|
-
const replacements = { TOOL_NAME: toolName };
|
|
531
|
-
const manifestContent = loadTemplate("tool-enact.md", replacements);
|
|
532
|
-
const agentsContent = loadTemplate("tool-agents.md", replacements);
|
|
533
|
-
// Ensure directory exists
|
|
534
|
-
if (!existsSync(targetDir)) {
|
|
535
|
-
mkdirSync(targetDir, { recursive: true });
|
|
536
|
-
}
|
|
537
|
-
// Write enact.md
|
|
538
|
-
writeFileSync(manifestPath, manifestContent, "utf-8");
|
|
539
|
-
success(`Created tool manifest: ${manifestPath}`);
|
|
540
|
-
// Write AGENTS.md (only if it doesn't exist or --force is used)
|
|
541
|
-
if (!existsSync(agentsPath) || options.force) {
|
|
542
|
-
writeFileSync(agentsPath, agentsContent, "utf-8");
|
|
543
|
-
success(`Created AGENTS.md: ${agentsPath}`);
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
info("AGENTS.md already exists, skipping (use --force to overwrite)");
|
|
574
|
+
writeFileSync(agentsPath, loadTemplate("agent-agents.md"), "utf-8");
|
|
575
|
+
success(`Created AGENTS.md: ${agentsPath}`);
|
|
576
|
+
// Create .enact/tools.json
|
|
577
|
+
if (createEnactProjectDir(targetDir, options.force ?? false)) {
|
|
578
|
+
success("Created .enact/tools.json");
|
|
547
579
|
}
|
|
548
580
|
info("");
|
|
549
|
-
info("
|
|
550
|
-
info("
|
|
551
|
-
info("
|
|
552
|
-
info(" 3. Run 'enact publish' to share your tool");
|
|
581
|
+
info("This file helps AI agents understand how to use Enact tools in your project.");
|
|
582
|
+
info("Run 'enact search <query>' to find tools, 'enact learn <tool>' to view docs,");
|
|
583
|
+
info("and 'enact install <tool>' to add them.");
|
|
553
584
|
}
|
|
554
585
|
/**
|
|
555
586
|
* Configure the init command
|
|
@@ -560,9 +591,9 @@ export function configureInitCommand(program) {
|
|
|
560
591
|
.description("Initialize Enact in the current directory")
|
|
561
592
|
.option("-n, --name <name>", "Tool name (default: username/my-tool)")
|
|
562
593
|
.option("-f, --force", "Overwrite existing files")
|
|
563
|
-
.option("--tool", "Create a new Enact tool (
|
|
564
|
-
.option("--agent", "Create AGENTS.md
|
|
565
|
-
.option("--claude", "Create CLAUDE.md
|
|
594
|
+
.option("--tool", "Create a new Enact tool (SKILL.md + AGENTS.md)")
|
|
595
|
+
.option("--agent", "Create AGENTS.md + .enact/tools.json (default)")
|
|
596
|
+
.option("--claude", "Create CLAUDE.md + .enact/tools.json")
|
|
566
597
|
.option("-v, --verbose", "Show detailed output")
|
|
567
598
|
.action(async (options) => {
|
|
568
599
|
const ctx = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEzE,uCAAuC;AACvC,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AACxC,MAAM,eAAe,GAAG,aAAa,CAAC;AAEtC,6BAA6B;AAC7B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,0CAA0C,CAAC;AAC5F,MAAM,iBAAiB,GACrB,OAAO,CAAC,GAAG,CAAC,iBAAiB;IAC7B,kNAAkN,CAAC;AAErN;;GAEG;AACH,MAAM,SAAS,GAA2B;IACxC,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4ClB;IAEC,gBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsNnB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AC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Display the documentation (enact.md) for a tool.
|
|
5
5
|
* Fetches and displays the raw manifest content for easy reading.
|
|
6
|
+
*
|
|
7
|
+
* Security: For tools fetched from the registry, attestation checks are
|
|
8
|
+
* performed according to the trust policy. This prevents potentially
|
|
9
|
+
* malicious documentation from being displayed to LLMs or users.
|
|
6
10
|
*/
|
|
7
11
|
import type { Command } from "commander";
|
|
8
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/learn/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/learn/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqRzC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuB5D"}
|
|
@@ -3,19 +3,74 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Display the documentation (enact.md) for a tool.
|
|
5
5
|
* Fetches and displays the raw manifest content for easy reading.
|
|
6
|
+
*
|
|
7
|
+
* Security: For tools fetched from the registry, attestation checks are
|
|
8
|
+
* performed according to the trust policy. This prevents potentially
|
|
9
|
+
* malicious documentation from being displayed to LLMs or users.
|
|
6
10
|
*/
|
|
7
|
-
import { createApiClient, getToolInfo, getToolVersion } from "@enactprotocol/api";
|
|
8
|
-
import { loadConfig } from "@enactprotocol/shared";
|
|
9
|
-
import { dim, error, formatError, header, json, newline } from "../../utils";
|
|
11
|
+
import { createApiClient, getAttestationList, getToolInfo, getToolVersion, verifyAllAttestations, } from "@enactprotocol/api";
|
|
12
|
+
import { getMinimumAttestations, getTrustPolicy, getTrustedAuditors, loadConfig, tryResolveTool, } from "@enactprotocol/shared";
|
|
13
|
+
import { TrustError, confirm, dim, error, formatError, header, info, json, newline, success, symbols, } from "../../utils";
|
|
10
14
|
/**
|
|
11
15
|
* Learn command handler
|
|
12
16
|
*/
|
|
13
|
-
async function learnHandler(toolName, options,
|
|
17
|
+
async function learnHandler(toolName, options, ctx) {
|
|
18
|
+
// First, try to resolve locally (project → user → cache)
|
|
19
|
+
// If the tool is already installed/cached, we trust it
|
|
20
|
+
const resolution = tryResolveTool(toolName, { startDir: ctx.cwd });
|
|
21
|
+
if (resolution) {
|
|
22
|
+
// Tool is installed locally - read documentation from the manifest file
|
|
23
|
+
if (resolution.manifestPath.endsWith(".md")) {
|
|
24
|
+
const { readFileSync } = await import("node:fs");
|
|
25
|
+
const content = readFileSync(resolution.manifestPath, "utf-8");
|
|
26
|
+
if (options.json) {
|
|
27
|
+
json({
|
|
28
|
+
name: toolName,
|
|
29
|
+
version: resolution.manifest.version,
|
|
30
|
+
documentation: content,
|
|
31
|
+
source: "local",
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
header(`${toolName}@${resolution.manifest.version ?? "local"}`);
|
|
36
|
+
dim("(installed locally)");
|
|
37
|
+
newline();
|
|
38
|
+
console.log(content);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// Fallback for non-.md manifests
|
|
42
|
+
if (options.json) {
|
|
43
|
+
json({
|
|
44
|
+
name: toolName,
|
|
45
|
+
version: resolution.manifest.version,
|
|
46
|
+
documentation: resolution.manifest.doc ?? resolution.manifest.description ?? null,
|
|
47
|
+
source: "local",
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
header(`${toolName}@${resolution.manifest.version ?? "local"}`);
|
|
52
|
+
dim("(installed locally)");
|
|
53
|
+
newline();
|
|
54
|
+
console.log(resolution.manifest.doc ?? resolution.manifest.description ?? "No documentation available.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// If --local flag is set, don't fetch from registry
|
|
58
|
+
if (options.local) {
|
|
59
|
+
error(`Tool not found locally: ${toolName}`);
|
|
60
|
+
dim("The tool is not installed. Remove --local to fetch from registry.");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
// Tool not installed - fetch from registry with attestation checks
|
|
14
64
|
const config = loadConfig();
|
|
15
65
|
const registryUrl = process.env.ENACT_REGISTRY_URL ??
|
|
16
66
|
config.registry?.url ??
|
|
17
67
|
"https://siikwkfgsmouioodghho.supabase.co/functions/v1";
|
|
18
|
-
|
|
68
|
+
// Get auth token - use user token if available, otherwise use anon key for public access
|
|
69
|
+
let authToken = config.registry?.authToken ?? process.env.ENACT_AUTH_TOKEN;
|
|
70
|
+
if (!authToken && registryUrl.includes("siikwkfgsmouioodghho.supabase.co")) {
|
|
71
|
+
authToken =
|
|
72
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNpaWt3a2Znc21vdWlvb2RnaGhvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ2MTkzMzksImV4cCI6MjA4MDE5NTMzOX0.kxnx6-IPFhmGx6rzNx36vbyhFMFZKP_jFqaDbKnJ_E0";
|
|
73
|
+
}
|
|
19
74
|
const client = createApiClient({
|
|
20
75
|
baseUrl: registryUrl,
|
|
21
76
|
authToken: authToken,
|
|
@@ -27,13 +82,106 @@ async function learnHandler(toolName, options, _ctx) {
|
|
|
27
82
|
const toolInfo = await getToolInfo(client, toolName);
|
|
28
83
|
version = toolInfo.latestVersion;
|
|
29
84
|
}
|
|
85
|
+
if (!version) {
|
|
86
|
+
error(`No published versions for ${toolName}`);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
30
89
|
// Get the version info which includes rawManifest
|
|
31
90
|
const versionInfo = await getToolVersion(client, toolName, version);
|
|
91
|
+
// ========================================
|
|
92
|
+
// TRUST VERIFICATION - same as run command
|
|
93
|
+
// ========================================
|
|
94
|
+
const trustPolicy = getTrustPolicy();
|
|
95
|
+
const minimumAttestations = getMinimumAttestations();
|
|
96
|
+
const trustedAuditors = getTrustedAuditors();
|
|
97
|
+
// Fetch attestations from registry
|
|
98
|
+
const attestationsResponse = await getAttestationList(client, toolName, version);
|
|
99
|
+
const attestations = attestationsResponse.attestations;
|
|
100
|
+
if (attestations.length === 0) {
|
|
101
|
+
// No attestations found
|
|
102
|
+
info(`${symbols.warning} Tool ${toolName}@${version} has no attestations.`);
|
|
103
|
+
if (trustPolicy === "require_attestation") {
|
|
104
|
+
throw new TrustError("Trust policy requires attestations. Cannot display documentation from unverified tools.");
|
|
105
|
+
}
|
|
106
|
+
if (ctx.isInteractive && trustPolicy === "prompt") {
|
|
107
|
+
dim("Documentation from unverified tools may contain malicious content.");
|
|
108
|
+
const proceed = await confirm("View documentation from unverified tool?");
|
|
109
|
+
if (!proceed) {
|
|
110
|
+
info("Cancelled.");
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (!ctx.isInteractive && trustPolicy === "prompt") {
|
|
115
|
+
throw new TrustError("Cannot display documentation from unverified tools in non-interactive mode.");
|
|
116
|
+
}
|
|
117
|
+
// trustPolicy === "allow" - continue without prompting
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Verify attestations locally (never trust registry's verification status)
|
|
121
|
+
const verifiedAuditors = await verifyAllAttestations(client, toolName, version, versionInfo.bundle.hash ?? "");
|
|
122
|
+
// Check verified auditors against trust config using provider:identity format
|
|
123
|
+
const trustedVerifiedAuditors = verifiedAuditors
|
|
124
|
+
.filter((auditor) => trustedAuditors.includes(auditor.providerIdentity))
|
|
125
|
+
.map((auditor) => auditor.providerIdentity);
|
|
126
|
+
if (trustedVerifiedAuditors.length > 0) {
|
|
127
|
+
// Check if we meet minimum attestations threshold
|
|
128
|
+
if (trustedVerifiedAuditors.length < minimumAttestations) {
|
|
129
|
+
info(`${symbols.warning} Tool ${toolName}@${version} has ${trustedVerifiedAuditors.length} trusted attestation(s), but ${minimumAttestations} required.`);
|
|
130
|
+
dim(`Trusted attestations: ${trustedVerifiedAuditors.join(", ")}`);
|
|
131
|
+
if (trustPolicy === "require_attestation") {
|
|
132
|
+
throw new TrustError(`Trust policy requires at least ${minimumAttestations} attestation(s) from trusted identities.`);
|
|
133
|
+
}
|
|
134
|
+
if (ctx.isInteractive && trustPolicy === "prompt") {
|
|
135
|
+
const proceed = await confirm("View documentation with fewer attestations than required?");
|
|
136
|
+
if (!proceed) {
|
|
137
|
+
info("Cancelled.");
|
|
138
|
+
process.exit(0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (!ctx.isInteractive && trustPolicy === "prompt") {
|
|
142
|
+
throw new TrustError("Cannot display documentation without meeting minimum attestation requirement in non-interactive mode.");
|
|
143
|
+
}
|
|
144
|
+
// trustPolicy === "allow" - continue without prompting
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// Tool meets or exceeds minimum attestations
|
|
148
|
+
if (options.verbose) {
|
|
149
|
+
success(`Tool verified by ${trustedVerifiedAuditors.length} trusted identity(ies): ${trustedVerifiedAuditors.join(", ")}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Has attestations but none from trusted auditors
|
|
155
|
+
info(`${symbols.warning} Tool ${toolName}@${version} has ${verifiedAuditors.length} attestation(s), but none from trusted auditors.`);
|
|
156
|
+
if (trustPolicy === "require_attestation") {
|
|
157
|
+
dim(`Your trusted auditors: ${trustedAuditors.join(", ")}`);
|
|
158
|
+
dim(`Tool attested by: ${verifiedAuditors.map((a) => a.providerIdentity).join(", ")}`);
|
|
159
|
+
throw new TrustError("Trust policy requires attestations from trusted identities. Cannot display documentation.");
|
|
160
|
+
}
|
|
161
|
+
if (ctx.isInteractive && trustPolicy === "prompt") {
|
|
162
|
+
dim(`Attested by: ${verifiedAuditors.map((a) => a.providerIdentity).join(", ")}`);
|
|
163
|
+
dim(`Your trusted auditors: ${trustedAuditors.join(", ")}`);
|
|
164
|
+
const proceed = await confirm("View documentation anyway?");
|
|
165
|
+
if (!proceed) {
|
|
166
|
+
info("Cancelled.");
|
|
167
|
+
process.exit(0);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (!ctx.isInteractive && trustPolicy === "prompt") {
|
|
171
|
+
throw new TrustError("Cannot display documentation without trusted attestations in non-interactive mode.");
|
|
172
|
+
}
|
|
173
|
+
// trustPolicy === "allow" - continue without prompting
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ========================================
|
|
177
|
+
// Display documentation (trust verified)
|
|
178
|
+
// ========================================
|
|
32
179
|
if (options.json) {
|
|
33
180
|
json({
|
|
34
181
|
name: toolName,
|
|
35
182
|
version: versionInfo.version,
|
|
36
183
|
documentation: versionInfo.rawManifest ?? null,
|
|
184
|
+
source: "registry",
|
|
37
185
|
});
|
|
38
186
|
return;
|
|
39
187
|
}
|
|
@@ -48,6 +196,10 @@ async function learnHandler(toolName, options, _ctx) {
|
|
|
48
196
|
console.log(versionInfo.rawManifest);
|
|
49
197
|
}
|
|
50
198
|
catch (err) {
|
|
199
|
+
if (err instanceof TrustError) {
|
|
200
|
+
error(err.message);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
51
203
|
if (err instanceof Error) {
|
|
52
204
|
if (err.message.includes("not_found") || err.message.includes("404")) {
|
|
53
205
|
error(`Tool not found: ${toolName}`);
|
|
@@ -70,7 +222,9 @@ export function configureLearnCommand(program) {
|
|
|
70
222
|
.command("learn <tool>")
|
|
71
223
|
.description("Display documentation (enact.md) for a tool")
|
|
72
224
|
.option("--ver <version>", "Show documentation for a specific version")
|
|
225
|
+
.option("--local", "Only show documentation for locally installed tools")
|
|
73
226
|
.option("--json", "Output as JSON")
|
|
227
|
+
.option("-v, --verbose", "Show detailed output")
|
|
74
228
|
.action(async (toolName, options) => {
|
|
75
229
|
const ctx = {
|
|
76
230
|
cwd: process.cwd(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/learn/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/learn/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAEL,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,UAAU,EACV,OAAO,EACP,GAAG,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,GACR,MAAM,aAAa,CAAC;AAOrB;;GAEG;AACH,KAAK,UAAU,YAAY,CACzB,QAAgB,EAChB,OAAqB,EACrB,GAAmB;IAEnB,yDAAyD;IACzD,uDAAuD;IACvD,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnE,IAAI,UAAU,EAAE,CAAC;QACf,wEAAwE;QACxE,IAAI,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YACjD,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAE/D,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,IAAI,CAAC;oBACH,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,OAAO;oBACpC,aAAa,EAAE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H,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,6CAA6C,CAAC;SAC1D,MAAM,CAAC,iBAAiB,EAAE,2CAA2C,CAAC;SACtE,MAAM,CAAC,SAAS,EAAE,qDAAqD,CAAC;SACxE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,eAAe,EAAE,sBAAsB,CAAC;SAC/C,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,OAAqB,EAAE,EAAE;QACxD,MAAM,GAAG,GAAmB;YAC1B,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;YAClB,OAAO;YACP,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK;SAC7C,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* enact mcp command
|
|
3
|
+
*
|
|
4
|
+
* Manage MCP-exposed tools and toolsets.
|
|
5
|
+
*
|
|
6
|
+
* Subcommands:
|
|
7
|
+
* - install: Show configuration for MCP clients (Claude Code, etc.)
|
|
8
|
+
* - list: List tools exposed to MCP
|
|
9
|
+
* - add: Add a tool to MCP (from global installs)
|
|
10
|
+
* - remove: Remove a tool from MCP
|
|
11
|
+
* - toolsets: List available toolsets
|
|
12
|
+
* - use: Switch active toolset
|
|
13
|
+
* - toolset: Manage toolsets (create, delete, add, remove)
|
|
14
|
+
*/
|
|
15
|
+
import type { Command } from "commander";
|
|
16
|
+
/**
|
|
17
|
+
* Configure the mcp command
|
|
18
|
+
*/
|
|
19
|
+
export declare function configureMcpCommand(program: Command): void;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiBH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiZzC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8H1D"}
|