Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - codeitlikemiley/tmp · GitHub
Skip to content

Repository files navigation

Tool Mapping Protocol (tmp)

Tool Mapping Protocol (TMP) Logo

TMP is a protocol for turning intent into verified operations. The first implementation is a Rust workspace that ships both a user-facing CLI and a set of embeddable library crates.

TMP is a map. Before a human, terminal, or AI agent runs something, TMP shows the correct road, the required inputs, the possible side effects, and the shape of the result.

TMP does not call language model APIs or manage provider keys. The deterministic core stays independent of AI providers. If a user wants model-assisted schema authoring, they use their preferred external agent to inspect help text, edit schema JSON, and then call into TMP.


What TMP Maps

TMP is bigger than a CLI helper. It can map any surface where an action can be invoked:

SurfaceExampleTMP Value
CLIcargo testknown flags & parameters
APIPOST /deploymentsschema + effects
SQLrecent_failed_jobssafe query templates
Workflowrelease_candidateordered steps
Scriptsync-datadocumented args
Completion<TAB>dynamic values
Agent toolresolve_intentgrounded lookup
Outputtest summaryless noise

Workspace

.
├── Cargo.toml # Workspace root
├── tmp-core/ # Core library crate (embeddable)
│ ├── examples/
│ └── src/
│ ├── compile.rs # Workspace context compiler
│ ├── config.rs # Config path loading
│ ├── context.rs # Project/build/git context detection
│ ├── generate.rs # Deterministic help-text draft schema generation
│ ├── help.rs # Recursive `--help` scraper
│ ├── registry.rs # Schema registry client
│ ├── resolve.rs # Heuristic schema-backed command resolver
│ ├── resolver.rs # Built-in dynamic token resolvers
│ ├── run.rs # Contextual command runner
│ ├── schema.rs # Schema data model and validation
│ └── versioning.rs # Schema history, rollback, and diff helpers
├── tmp/ # User-facing CLI binary
│ └── src/
│ ├── commands/
│ ├── main.rs
│ └── tui/
├── crates/
│ ├── command/ # Quiet std::process::Command wrapper (library)
│ └── tmp-agent/ # Agent adapter server (library + binary)
│ ├── src/
│ │ ├── lib.rs # Axum server, DB helpers, subagent orchestration
│ │ └── main.rs
│ └── tests/
├── docs/
│ └── whitepaper/ # Protocol whitepaper (Draft 0.4)
├── tests/ # E2E test tiers (Tier 1–4)
└── scripts/

Using TMP as a Library

The core value of TMP lives in its library crates. You can embed schema resolution, context detection, and compilation directly into your own tools without going through the CLI.

tmp-core — The Protocol Engine

tmp-core is the heart of TMP. It exposes all protocol primitives as a Rust library:

[dependencies]
tmp-core = { path = "tmp-core" }

Modules

ModulePurpose
schemaParse, validate, and serialize operation schemas
resolveMatch natural-language intent to a schema-backed command
compileBuild workspace context and resolved command maps
contextDetect project structure, build system, git state
generateDraft schemas from --help text
helpRecursive help-text scraper
resolverBuilt-in dynamic token resolvers (cargo:*, git:*, npm:*)
runExecute resolved commands with contextual inference
registryInteract with schema registries (search, install, publish)
versioningSchema history, rollback, and diff
configConfiguration path resolution

Key Types

use tmp_core::schema::{Schema,Command,Token,DataSource,TokenType};use tmp_core::resolve::{ResolveResult,TokenFill};use tmp_core::compile::{Compiler,CompileOutput,ResolvedCommand,ResolvedToken};use tmp_core::context::Context;

Example: Resolve Intent Programmatically

use tmp_core::context::Context;use tmp_core::resolve;fnmain(){let context = Context::detect(".");match resolve::resolve("run unit tests",&context,None,None){Ok(result) => {println!("Command: {}", result.command);println!("Confidence: {}", result.confidence);for fill in&result.tokens_filled{println!(" {} = {} ({})", fill.name, fill.value, fill.source);}}Err(e) => eprintln!("Resolution failed: {}", e),}}

Example: Compile Context

use tmp_core::compile::Compiler;use tmp_core::context::Context;use std::path::Path;fnmain(){let cwd = Path::new(".");let context = Context::detect(".");let output = Compiler::compile(cwd,&context,None).unwrap();// Write .tmp/commands.json and .tmp/context.mdCompiler::write_to_disk(cwd,&output).unwrap();// Or generate markdown programmaticallylet markdown = Compiler::generate_markdown(&output);println!("{}", markdown);}

command — Quiet Process Execution

A thin wrapper around std::process::Command that suppresses console window creation on Windows. Useful as a drop-in replacement in cross-platform tools.

[dependencies]
command = { path = "crates/command" }
use command::Command;let output = Command::new("cargo").arg("test").output().expect("failed to execute");println!("{}",String::from_utf8_lossy(&output.stdout));

tmp-agent — Agent Adapter Server

An Axum-based HTTP server that exposes TMP capabilities to AI agents. It provides REST endpoints for command execution, file operations, chat (via Antigravity SDK), subagent orchestration, database introspection, and structured logging.

[dependencies]
tmp-agent = { path = "crates/tmp-agent" }

Endpoints

MethodPathPurpose
GET/statusHealth check and agent state
POST/chatSend a message to the AI agent
POST/executeRun a shell command
POST/read_fileRead file contents (sandboxed)
POST/write_fileWrite file contents (sandboxed)
POST/subagentSpawn an async subagent task
GET/subagent/:idPoll subagent status
POST/logStructured logging
POST/db/tablesList database tables (SQLite/PG)
POST/db/columnsGet column info for a table
POST/db/queryExecute read-only SQL queries

Security: file operations are sandboxed to the workspace directory. SQL queries are restricted to SELECT/WITH statements with mutating keyword detection.


CLI Quick Start

tmp init
tmp generate cargo
tmp generate cargo --verify
tmp compile
tmp resolve "run unit tests"
tmp run

For external agent setup:

tmp init-agent codex
tmp init-agent claude

The generated instruction files tell the external agent to use tmp resolve "<intent>" before running unknown commands.

CLI Commands

init

Creates the config directory and schemas/ directory. The default config is intentionally minimal and contains no API provider settings.

generate <tool>

Generates an unverified draft schema from help text. If --help-text is omitted, tmp runs <tool> --help and recursively checks detected subcommands up to the scraper limits. Draft schemas are saved with version history.

Useful flags:

  • --help-text <PATH|DIR|COMMAND>: Read help from a file, inspect a directory containing the tool binary, or run the value as a command.
  • --history: Print schema version history.
  • --rollback <VERSION>: Restore a prior schema as a new version.
  • --verify: Launch the verification TUI when running interactively.
  • --non-interactive: Save without prompting or launching TUI.
  • --force: Save even when generated output matches the latest version.

Draft output is marked verified: false. Treat it as a bootstrap artifact, not a complete or trusted command contract.

schema

Manages local schemas:

  • schema list
  • schema share <tool>
  • schema import <source>
  • schema keywords <tool> [words...]

registry

Searches, installs, and publishes schemas through a registry source:

  • registry search <query>
  • registry install <tool>
  • registry publish <tool>

compile

Compiles project context and relevant schemas into:

  • .tmp/commands.json
  • .tmp/context.md

Use --watch to refresh context on file changes.

resolve "<query>"

Resolves a natural-language query against installed schemas using local heuristic matching. If no schema match exists, the command fails closed instead of guessing.

Use --json for the full resolution structure. Successful resolution writes .tmp/last_command.json.

run [file]

Runs the last resolved command when no file is provided. With a file, it chooses a contextual local command, such as cargo run, cargo test --test <name>, rustc <file>, or npm test.

Use --dry-run to preview the command.

workflow

Imports and runs JSON/YAML workflow definitions:

  • workflow add <name> --from <path>
  • workflow run <name>
  • workflow list

Schema Notes

Schemas are JSON files under the active config directory's schemas/ folder. Tokens can use built-in data resolvers such as:

  • cargo:packages
  • cargo:bins
  • cargo:examples
  • cargo:features
  • cargo:tests
  • git:branches
  • git:remotes
  • npm:scripts

Custom token data sources can run shell commands and parse output as lines or words.


Core Invariants

These rules are tested across the E2E tier suite:

InvariantWhy It Matters
Unknown intent does not invoke anythingPrevents hallucinated operations
Draft maps are never treated as verifiedPrevents false trust
High-risk effects require approvalPrevents accidental destructive actions
Dynamic resolver failure is visiblePrevents hidden wrong defaults
Raw output is retained when output is shapedPreserves auditability
The core resolver is deterministicKeeps TMP independent of AI providers

Architecture

┌─────────────────────────────────────────────────┐
│ External Agents (Claude, Codex, Copilot, …) │
└──────────────────────┬──────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ tmp CLI │ │tmp-agent │ │ Your Tool │
│ (binary) │ │ (server) │ │ (embeds │
│ │ │ │ │ tmp-core) │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌────────────────┐
│ tmp-core │
│ (library) │
│ │
│ schema │
│ resolve │
│ compile │
│ context │
│ generate │
│ registry │
│ versioning │
│ run │
└───────┬────────┘
│
▼
┌────────────────┐
│ command │
│ (library) │
└────────────────┘

Development

cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace

Test Tiers

TierScope
1Schema, context, config, resolver fundamentals
2Generate, compile, resolve, run integration
3Registry, workflow, versioning
4Agent adapter, subagent orchestration

Further Reading

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages