← 返回 Skills 市场
c-goro

AgentLedger

作者 c-goro · GitHub ↗ · v1.1.1
cross-platform ⚠ suspicious
3093
总下载
4
收藏
6
当前安装
2
版本数
在 OpenClaw 中安装
/install agentledger
功能描述
Expense tracking and accounting for AI agents. Log purchases, set budgets, generate spending reports, and manage multi-currency finances — all stored locally. Privacy.com card import, natural language queries, CSV/JSON export. Use when agents make purchases and need a financial audit trail.
使用说明 (SKILL.md)

AgentLedger - AI Agent Expense Tracking

Overview

AgentLedger is an accounting skill that logs every transaction you make, tracks spending across multiple accounts, and provides detailed reports. Use this to maintain a complete financial record of your purchases.

Important: Always log transactions immediately after making purchases. This skill is designed for AI agents to track their own expenses (API costs, tool subscriptions, etc.).

Core Functions

1. Log a Transaction

When you make any purchase, immediately log it:

// In Node.js context, require the ledger
const AgentLedger = require('./src/ledger.js');
const ledger = new AgentLedger();

// Log a transaction
await ledger.logTransaction({
  amount: 29.99,
  currency: 'USD',
  vendor: 'OpenAI',
  description: 'GPT-4 API credits',
  category: 'API/Services',
  account: 'privacy-card-1',
  context: 'Needed additional tokens for user project analysis',
  receiptUrl: 'https://platform.openai.com/receipts/xyz',
  confirmationId: 'sub_1234567890'
});

CLI Usage (supports both positional and named parameters):

# Positional style
node src/cli.js log 29.99 "OpenAI" "GPT-4 API credits" --category="API/Services"

# Named parameter style  
node src/cli.js log --amount=29.99 --vendor="OpenAI" --description="GPT-4 API credits" --category="API/Services" --context="Monthly API refill"

2. Check Current Spending

// Get spending summary
const summary = await ledger.getSummary('this-month');
console.log(`Total spent this month: $${summary.total}`);

// Check specific category
const apiSpending = await ledger.getCategorySpending('API/Services', 'this-month');

3. Generate Reports

// Monthly report
const report = await ledger.generateReport('monthly', { month: '2024-01' });

// Custom date range
const customReport = await ledger.generateReport('custom', {
  startDate: '2024-01-01',
  endDate: '2024-01-31'
});

4. Budget Management

// Set monthly budget for API services
await ledger.setBudget('API/Services', 500, 'monthly');

// Check budget status
const budgetStatus = await ledger.checkBudget('API/Services');
if (budgetStatus.isNearLimit) {
  console.log(`Warning: ${budgetStatus.percentUsed}% of API budget used`);
}

Categories

Use these predefined categories for consistent tracking:

  • API/Services - API credits, SaaS subscriptions
  • Infrastructure - Hosting, domains, CDN
  • Marketing - Ads, social media tools
  • Tools - Software licenses, utilities
  • Subscriptions - Recurring monthly/yearly services
  • Other - Miscellaneous expenses

Account Integration

Privacy.com Cards

The ledger automatically detects Privacy.com card data if available:

// If you have Privacy.com JSON exports in workspace/privacy/
await ledger.importPrivacyTransactions('./privacy/card-1.json');

Manual Account Setup

// Register a new payment method
await ledger.addAccount({
  id: 'stripe-main',
  name: 'Main Stripe Account',
  type: 'credit_card',
  currency: 'USD'
});

Natural Language Queries

Ask questions like:

  • "How much did I spend on API keys this month?"
  • "What was that $20 charge from yesterday?"
  • "Show me all infrastructure costs from last quarter"
  • "Am I over budget on marketing spend?"

The CLI handles these queries:

node src/cli.js query "API spending this month"
node src/cli.js find "OpenAI" --last-week

Time Periods

Supported natural language time periods:

  • today, yesterday
  • this-week, last-week
  • this-month, last-month
  • this-quarter, last-quarter
  • this-year, last-year
  • last-30-days, last-90-days

Data Export

// Export to CSV
await ledger.exportTransactions('csv', './exports/transactions.csv');

// Export to JSON
await ledger.exportTransactions('json', './exports/transactions.json');

CLI Quick Reference

Essential Commands for AI Agents

# Initialize (run once)
node src/cli.js init

# Log transactions (supports both styles)
node src/cli.js log 29.99 "OpenAI" "API credits" --category="API/Services"
node src/cli.js log --amount=29.99 --vendor="OpenAI" --description="API credits" --category="API/Services"

# Check current spending
node src/cli.js summary                    # This month
node src/cli.js summary --period="today"   # Today only
node src/cli.js summary --period="this-week" # This week

# Set and check budgets
node src/cli.js budget set "API/Services" 500    # Set monthly budget
node src/cli.js budget status                    # Check all budgets

# Generate detailed reports  
node src/cli.js report monthly
node src/cli.js report --type=category
node src/cli.js report --type=vendor

# Search transactions
node src/cli.js find "OpenAI"                    # Search by vendor
node src/cli.js find "API" --category="API/Services"  # Search by category
node src/cli.js find --min-amount=50             # Find large expenses

# Export data
node src/cli.js export csv                       # Export to CSV
node src/cli.js export --format=json            # Export to JSON

# Natural language queries
node src/cli.js query "How much did I spend on APIs this month?"
node src/cli.js query "What was that $25 charge?"

# Import from Privacy.com
node src/cli.js import privacy ./privacy-export.json

File Storage

  • Transactions: workspace/ledger/transactions.json
  • Accounts: workspace/ledger/accounts.json
  • Budgets: workspace/ledger/budgets.json
  • Settings: workspace/ledger/settings.json

Best Practices

  1. Log immediately - Don't wait, log every purchase as it happens
  2. Add context - Explain why the purchase was necessary
  3. Use consistent categories - Stick to the predefined categories
  4. Include receipts - Store confirmation numbers and receipt URLs
  5. Set budgets - Establish spending limits for each category
  6. Review regularly - Generate monthly reports to track spending patterns

Error Handling & Edge Cases

The ledger handles common errors gracefully:

Input Validation

  • Negative amounts: Rejected (use positive amounts only)
  • Missing required fields: Clear error messages with usage examples
  • Invalid currency: Accepted (no validation - assumes user knows what they're doing)
  • Very long descriptions: Handled without truncation

Data Safety

  • Automatic backups: Created before each save operation
  • Corrupted data recovery: Automatic recovery from .backup files
  • Empty periods: Gracefully shows $0.00 totals
  • Multi-currency: Properly separated in summaries and reports

Example Error Recovery

# If you see "Could not load transactions" message:
# The system automatically tries to recover from backup
# Your data should be restored automatically

# Manual backup check
ls workspace/ledger/*.backup  # Check if backups exist

Security & Privacy

  • Local storage only: All data stays in workspace/ledger/ JSON files
  • No external API calls: Core functionality works offline
  • No sensitive data: Never store actual card numbers or passwords
  • Account aliases: Use descriptive IDs like privacy-card-1 or company-amex
  • Receipt URLs: Store links to receipts, not receipt content itself
安全使用建议
AgentLedger appears coherent: it runs under Node, stores all data locally under workspace/ledger, and asks for no external credentials. Before installing, consider the following: 1) Privacy of stored data — transactions include receipt URLs, confirmation IDs and free-text context; ensure your workspace is secure and do not import raw exports containing full card numbers. 2) Verify the Privacy.com importer implementation (importPrivacyTransactions) to confirm it only processes local JSON and does not make network calls or log sensitive fields. 3) Inspect the omitted/truncated files for any child_process, eval, or network code (HTTP requests, fetch, axios) if you need high assurance. 4) Run the package in a sandbox or dedicated agent workspace first and run the test suite (node test/ledger.test.js). 5) If you want to prevent autonomous agent use of this skill, set disable-model-invocation or only allow user-invocable usage in your agent policy. Overall this skill is internally consistent with its stated purpose, but you should still validate the importer and keep sensitive exports out of the workspace.
功能分析
Type: OpenClaw Skill Name: agentledger Version: 1.1.1 The skill's core functionality for expense tracking is benign, and the code itself does not exhibit malicious intent. However, the `package.json` requests broad `"filesystem": ["read", "write"]` permissions. While the code primarily operates within its designated `workspace/ledger` directory, this permission, combined with user-controlled file paths for import/export functions (e.g., `importPrivacyTransactions`, `exportTransactions`), could allow an agent to read or write arbitrary files on the system if explicitly instructed by a malicious prompt, despite the skill's stated intent of local storage within its workspace. This broad capability without strict path validation makes it suspicious.
能力评估
Purpose & Capability
Name/description (expense tracking, budgets, reports, Privacy.com imports) match the included code (ledger, budget, reports, CLI). Required binary is just node and no credentials/config paths are requested, which is proportionate for a local ledger tool.
Instruction Scope
SKILL.md instructs only local operations (logging, importing local Privacy.com JSON exports, exporting CSV/JSON, reading/writing workspace/ledger JSON files). It does not instruct the agent to read unrelated system files, access environment secrets, or send data to external endpoints.
Install Mechanism
There is no remote download/install step in the skill metadata. The package.json and README expect the skill to be copied into the workspace and run with node; that is low-risk and consistent with the skill's purpose.
Credentials
The skill declares no required environment variables or credentials and only needs filesystem access in the workspace (package.json lists filesystem permissions). That matches the stated local-storage design and is proportional.
Persistence & Privilege
always is false and the skill does not request any elevated or cross-skill privileges. It stores data under workspace/ledger only and does not modify other skills or global agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install agentledger
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /agentledger 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.1
v1.1.1 — Added summary and keywords for ClawHub listing.
v1.0.0
v1.0.0 — AI agent expense tracking and accounting. Transaction logging, budget alerts, spending reports, Privacy.com import, CSV/JSON export.
元数据
Slug agentledger
版本 1.1.1
许可证
累计安装 6
当前安装数 6
历史版本数 2
常见问题

AgentLedger 是什么?

Expense tracking and accounting for AI agents. Log purchases, set budgets, generate spending reports, and manage multi-currency finances — all stored locally. Privacy.com card import, natural language queries, CSV/JSON export. Use when agents make purchases and need a financial audit trail. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 3093 次。

如何安装 AgentLedger?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install agentledger」即可一键安装,无需额外配置。

AgentLedger 是免费的吗?

是的,AgentLedger 完全免费(开源免费),可自由下载、安装和使用。

AgentLedger 支持哪些平台?

AgentLedger 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 AgentLedger?

由 c-goro(@c-goro)开发并维护,当前版本 v1.1.1。

💬 留言讨论