Skip to content

feat(cli): resolve untyped read resource ids#283

Merged
innomentats merged 1 commit into
chaitin:mainfrom
kingfs:feat/untyped-read-resource-ids
Jul 14, 2026
Merged

feat(cli): resolve untyped read resource ids#283
innomentats merged 1 commit into
chaitin:mainfrom
kingfs:feat/untyped-read-resource-ids

Conversation

@kingfs

@kingfs kingfs commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a daemon-side ResourceService.ResolveID API to locate projects, agents, runs, sandboxes, images, and caches by full or short ID.
  • Support agent-compose inspect <id> without requiring the resource type, while delegating inspection to the existing typed APIs.
  • Support agent-compose logs <id> for project, agent, run, and sandbox IDs without requiring a local Compose file.
  • Limit untyped resolution to IDs only. Name-based lookup continues to use the existing explicit typed syntax, and volumes remain excluded because they do not
    have stable resource IDs.
  • Preserve deterministic ambiguity reporting when a short ID matches multiple resources.

Testing

  • go test ./pkg/resources ./pkg/storage/configstore ./pkg/agentcompose/api ./pkg/agentcompose/app ./cmd/agent-compose
  • go test -race ./pkg/resources ./pkg/storage/configstore ./pkg/agentcompose/api ./cmd/agent-compose -run 'Test(Locator|FindResource|ResourceHandler| IntegrationCLI(Inspect|Logs)Resolves|E2ECLI(Inspect|Logs)Resolves)' -count=1
  • task lint
  • task build
  • task test
  • git diff --check origin/main...HEAD

Checklist

  • Documentation updated when behavior or configuration changed.
  • Tests added or updated for user-visible behavior.
  • No secrets, private endpoints, internal certificates, or local runtime state included.

@monkeyscan

monkeyscan Bot commented Jul 14, 2026

Copy link
Copy Markdown

PR Title: feat(cli): resolve untyped read resource ids

Commit: aaaaf94

本 PR 引入了资源 ID 解析功能,允许用户通过完整 ID 或十六进制短 ID 前缀查找 project、agent、run、sandbox、image 和 cache 等资源。核心变更包括:

  1. 数据层:新增 pkg/storage/configstore/resource_id_lookup.go,通过 SQL 范围查询实现基于前缀的数据库资源查找,支持 project、agent、run 三种存储资源的 ID 匹配。
  2. 业务层:新增 pkg/resources/locator.go,提供统一的 Locator.ResolveID 入口,整合存储层查询与 sandbox、image、cache 等运行时资源的列表匹配。
  3. API 层:新增 pkg/agentcompose/api/resource.go,实现 gRPC ResourceService.ResolveID 接口,完成 proto 与内部模型的映射。
  4. CLI 层:新增 cmd/agent-compose/cli_resource_locator.gocmd/agent-compose/cli_logs_locator.go,支持 inspectlogs 命令接受无类型 ID 参数,自动解析资源类型。
  5. Proto 与依赖注入:新增 ResourceService 服务定义,并在 app.go 中完成依赖注入和路由注册。

整体代码结构清晰,分层合理,参数化查询避免了 SQL 注入风险,测试覆盖了主要场景。未发现高严重性安全漏洞或正确性缺陷。

@innomentats
innomentats merged commit 0d58e9c into chaitin:main Jul 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants