CommandCodeAI / CommandCodeAI/command-code

ModApi: Persistence, Model & Account API

Đang mở
#637 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4k
Fork
350
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Feature Description

Disclaimer: This message was synthesized by an AI from a long, unstructured Markdown file of notes accumulated while building real mods. Use cases have been kept intentionally simple and generic. If anything seems off or incoherent, feel free to ask for clarification.

1. cmd.globalStore — cross-session key-value store

Problem: There is no way to persist data across sessions without writing a raw JSON file via cmd.exec("bash -c 'cat > ...'"). This works but it's a workaround, not an API.

Use case: Any mod that wants to remember something between sessions (counters, preferences, history) currently has to manage raw files manually.

await cmd.globalStore.set("total-count", 42);
await cmd.globalStore.get("total-count");

2. cmd.getAvailableModels() — machine-readable model list

Problem: The /model command shows model display names, but those don't match the IDs the API actually accepts. There's no way for a mod to programmatically get the list of valid model identifiers to use with cmd.setModel().

Use case: Any mod that needs to switch or list available models has no reliable source of truth for valid model IDs.


3. Per-model pricing exposed to mods

Problem: No way to get input/output cost per token from within a mod. Mods that track or estimate cost have to hardcode price tables manually and keep them up to date themselves.

Use case: Any mod that tracks or displays cost information needs access to current pricing without maintaining its own hardcoded table.


4. cmd.usage — cumulative session usage

Problem: The model_request_end event gives per-turn token usage, but there's no way to access cumulative usage for the current session from a mod.

Use case: Any mod that wants to display total session cost or token count needs to accumulate this manually from individual events rather than reading it from a single source.


5. cmd.account.plan — current user plan

Problem: No way for a mod to know what plan the user is on.

Use case: A mod that wants to adapt its behavior based on available resources or limits currently has no way to query this.


6. cmd.openBrowser() / cmd.openFile() — cross-platform helpers

Problem: Opening a file or URL from a mod requires cmd.exec({ command: 'open', args: [path] }), which is macOS-only and not part of the official API.

Use case: Any mod that generates output and wants to open it for the user should be able to do so cross-platform.

await cmd.openFile('/path/to/report.html');
await cmd.openBrowser('http://localhost:3000');

7. Programmatic sub-agents from a mod

Problem: Only the model can launch sub-agents via the agent tool. A mod has no way to orchestrate parallel workers or delegate work to a dedicated sub-agent.

Use case: A mod that needs to run background analysis or parallel processing on independent sub-tasks currently has no API path to do so.

const result = await cmd.runSubagent({
  model: "haiku",
  prompt: "Analyze this file",
  tools: ["read_file"],
  timeout: 30_000,
});
Use Case

No response

Additional Context

No response

How important is this to you?

None

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue không nêu tên tệp mã nguồn, test hoặc entry point nào. Hãy bắt đầu bằng cách xác định API của lệnh mod hiện có và các test của nó, sau đó làm rõ và xác định phạm vi riêng cho bảy khả năng được yêu cầu; trạng thái „done“ phải được xác định bằng các tiêu chí chấp nhận rõ ràng cho từng API, bao gồm persistence, dữ liệu model và account, các platform helper và hành vi của sub-agent.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
api, cli
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.