-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add CLI tools backend #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "caplets": minor | ||
| --- | ||
|
|
||
| Add `cliTools` Caplet backends for typed, shell-free CLI actions plus `caplets author cli` for generating reviewable CLI Caplet manifests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| $schema: https://raw.githubusercontent.com/spiritledsoftware/caplets/main/schemas/caplet.schema.json | ||
| name: GitHub CLI | ||
| description: Inspect GitHub pull requests and issues through curated gh CLI commands. | ||
| tags: | ||
| - cli | ||
| - github | ||
| - code | ||
| cliTools: | ||
| actions: | ||
| gh_pr_status: | ||
| description: Show pull request status for the current branch as JSON. | ||
| command: gh | ||
| args: | ||
| - pr | ||
| - status | ||
| - --json | ||
| - currentBranch | ||
| output: | ||
| type: json | ||
| annotations: | ||
| readOnlyHint: true | ||
| openWorldHint: true | ||
| gh_issue_list: | ||
| description: List open GitHub issues as JSON. | ||
| command: gh | ||
| args: | ||
| - issue | ||
| - list | ||
| - --json | ||
| - number,title,state,url | ||
| output: | ||
| type: json | ||
| annotations: | ||
| readOnlyHint: true | ||
| openWorldHint: true | ||
| --- | ||
|
|
||
| # GitHub CLI | ||
|
|
||
| Use this Caplet to expose read-oriented GitHub workflows through `gh` without giving the agent an unrestricted shell. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| $schema: https://raw.githubusercontent.com/spiritledsoftware/caplets/main/schemas/caplet.schema.json | ||
| name: Repository CLI | ||
| description: Inspect and run common local repository workflows through curated CLI tools. | ||
| tags: | ||
| - cli | ||
| - code | ||
| cliTools: | ||
| actions: | ||
| git_status: | ||
| description: Show concise Git working tree status. | ||
| command: git | ||
| args: | ||
| - status | ||
| - --short | ||
| annotations: | ||
| readOnlyHint: true | ||
| git_current_branch: | ||
| description: Print the current Git branch name. | ||
| command: git | ||
| args: | ||
| - branch | ||
| - --show-current | ||
| annotations: | ||
| readOnlyHint: true | ||
| package_test: | ||
| description: Run the repository test script with pnpm. | ||
| command: pnpm | ||
| args: | ||
| - run | ||
| - test | ||
| timeoutMs: 120000 | ||
| --- | ||
|
|
||
| # Repository CLI | ||
|
|
||
| Use this Caplet to expose a small, typed set of local repository commands without giving an agent arbitrary shell access. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # CLI Tools Backend For Caplets | ||
|
|
||
| ## Summary | ||
|
|
||
| Add a fifth backend, `cliTools`, that exposes curated command-line workflows as typed Caplets tools. Runtime execution is deterministic and shell-free: Caplets maps declared JSON inputs into `spawn(command, args)` calls, returns bounded structured results, and never exposes arbitrary bash. | ||
|
|
||
| Also add `caplets author cli` to generate reviewable CLI Caplet manifests from repo/package metadata and curated templates for `git`, `gh`, and the detected package manager. Generation prints to stdout by default. | ||
|
|
||
| ## Key Changes | ||
|
|
||
| - Add `cliTools` to config and Caplet frontmatter alongside `mcpServers`, `openapiEndpoints`, `graphqlEndpoints`, and `httpApis`. | ||
| - Use an `actions` map shape, mirroring `httpApis.actions`: | ||
| - action key is the downstream tool name. | ||
| - each action supports `description`, `inputSchema`, optional `outputSchema`, `command`, `args`, `env`, `cwd`, `timeoutMs`, `maxOutputBytes`, `output`, and MCP annotations. | ||
| - Execute with `spawn(command, args)` only; no shell mode in v1. | ||
| - Support `$input.foo` interpolation inside argv/env/cwd strings. | ||
| - Apply basic runtime input validation for required fields and primitive JSON Schema types before spawning. | ||
| - Default limits: `timeoutMs: 60000`, `maxOutputBytes: 1000000`, configurable at Caplet and action level. | ||
| - Return CLI results as structured content: | ||
| - `{ exitCode, stdout, stderr, elapsedMs }` | ||
| - `isError: true` for non-zero exits. | ||
| - optional stdout JSON parsing when `output.type: "json"` is declared. | ||
| - `check_backend` validates manifest shape, cwd/env resolution, command availability, and tool count without running configured actions. | ||
| - `list_tools`, `search_tools`, `get_tool`, `call_tool`, and field selection should work consistently with existing backends. | ||
| - Load user-root CLI Caplets normally; load project `.caplets` CLI Caplets only under the existing `CAPLETS_TRUST_PROJECT_CAPLETS` gate. | ||
|
|
||
| ## Authoring UX | ||
|
|
||
| - Add `caplets author cli <id>` with scriptable flags: | ||
| - `--repo <path>` to inspect a repository. | ||
| - `--include git,gh,package` to choose generators/templates. | ||
| - `--command <name>` for single-CLI generation. | ||
| - `--output -` by default, with explicit file output supported. | ||
| - Heuristic generator only in v1; no OpenAI/API/agent dependency. | ||
| - Repo workflow generation should inspect package scripts and lockfiles, then generate safe tools such as test, lint, typecheck, build, repo status, changed files, and PR status when applicable. | ||
| - Single-CLI templates should cover `git`, `gh`, and detected package manager commands. | ||
| - Generated manifests must be explicit Markdown Caplet files with `cliTools`, not hidden runtime state. | ||
|
|
||
| ## Docs And Examples | ||
|
|
||
| - Update README config docs, Caplet file docs, generated schemas, and backend operation docs. | ||
| - Add real bundled CLI examples under `caplets/`, focused on repo maintenance and GitHub workflows. | ||
| - Examples should be safe/read-oriented by default; mutating actions must carry clear annotations such as `readOnlyHint: false` and `destructiveHint` where appropriate. | ||
|
|
||
| ## Test Plan | ||
|
|
||
| - Config tests for `cliTools`, duplicate IDs across all five backend maps, Caplet frontmatter loading, project trust behavior, defaults, limits, and invalid command/action shapes. | ||
| - CLI manager tests for list/search/get/call, input interpolation, basic validation, JSON output parsing, non-zero exit handling, timeout handling, output byte limits, command-not-found errors, cwd/env behavior, and secret redaction. | ||
| - Runtime/registry tests for `cliTools` registration, `check_backend`, reload invalidation, and `caplets list`. | ||
| - Authoring tests for stdout output, explicit output path, package-script detection, `git`/`gh` templates, package manager detection, and generated Caplet validation. | ||
| - Schema check, typecheck, focused tests, full `pnpm verify`. | ||
|
|
||
| ## Assumptions | ||
|
|
||
| - V1 intentionally excludes shell snippets, conditional argv construction, full JSON Schema validation, LLM-assisted generation, and automatic installation into the user Caplets root. | ||
| - Complex workflows should be modeled as package scripts or wrapper executables, then called through typed `cliTools` actions. | ||
| - Caplets surfaces risk annotations but does not block declared mutating tools at runtime; client approval remains outside Caplets. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align benchmark figures with README to avoid conflicting product claims.
This file now reports
8400/2100, while README still reports8358/2090for the same deterministic benchmark. Please keep one canonical precision/number set across both docs.Also applies to: 41-41
🤖 Prompt for AI Agents