Skip to content

Improve deployment list and logs CLI#126

Merged
khaliqgant merged 2 commits into
mainfrom
fix/deployment-observability-cli
May 19, 2026
Merged

Improve deployment list and logs CLI#126
khaliqgant merged 2 commits into
mainfrom
fix/deployment-observability-cli

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented May 19, 2026

Summary

  • show deployed agent names first in agentworkforce deployments list, with compact agent IDs moved to the end
  • add agentworkforce deployments logs [agent-name-or-id] for structured cloud log lookup
  • support log output formatting and argument parsing tests

Validation

  • corepack pnpm --filter @agentworkforce/cli test

Companion cloud PR: https://github.com/AgentWorkforce/cloud/pull/747

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ff7c6b0-5bbe-4a8b-9b60-b58501fdf88d

📥 Commits

Reviewing files that changed from the base of the PR and between 461dcd1 and 08fe520.

📒 Files selected for processing (2)
  • packages/cli/src/list-command.test.ts
  • packages/cli/src/list-command.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/list-command.ts

📝 Walkthrough

Walkthrough

The PR adds a new deployments logs subcommand to the agentworkforce CLI for viewing deployment log entries filtered by agent selector. It includes argument parsing for agent selection, log-file paths, tail limits, and output formatting (JSON or text), along with helper functions for API request handling, agent resolution, and log formatting. The existing deployments table is also updated with a name column and reordered schema.

Changes

Deployments logs feature

Layer / File(s) Summary
Log command types and schema
packages/cli/src/list-command.ts
DeploymentLogsOptions struct represents parsed log flags; DeploymentAgent is extended with personaSlug; response and entry types are defined for log API metadata and log entries.
Logs command implementation
packages/cli/src/list-command.ts
runDeploymentLogs resolves workspace/cloud/token context, optionally resolves agent selector by matching multiple agent identifiers, branches between --path reading vs listing workspace log paths, accumulates up to --tail, and outputs JSON or formatted text.
Logs helpers and I/O
packages/cli/src/list-command.ts
Helpers for authenticated JSON GET requests, workspace validation, fetching deployments, listing/sorting log paths, reading log entries (with optional agent filtering), merging newest-file entries, selector resolution errors, and output writing.
Arg parsing, formatting and validation
packages/cli/src/list-command.ts
parseDeploymentLogsArgs parses positional selector and flags; formatDeploymentsTable now renders a name column and reordered columns; formatDeploymentLogEntries formats entries; parseTail validates positive integer; agent parsing now extracts personaSlug.
CLI dispatcher wiring
packages/cli/src/cli.ts
Import runDeploymentLogs, update help text to document deployments logs, extend the deployments command dispatcher to accept and route the logs action, and update error messaging for unsupported actions.
Tests for deployments table and logs behavior
packages/cli/src/list-command.test.ts
Update test imports and deployments-table fixture with personaSlug and UUID-like personaId; adjust table assertions; add tests for parseDeploymentLogsArgs, formatDeploymentLogEntries, and tailLogEntriesFromNewestFiles.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as runDeploymentLogs
  participant API as API Server
  participant Output
  User->>CLI: agentworkforce deployments logs [selector]
  CLI->>CLI: Parse args (selector, path, tail, json, etc.)
  CLI->>API: Resolve workspace/token context
  Note over CLI,API: Optional: resolve agent selector
  alt Selector provided
    CLI->>API: Fetch deployments list
    CLI->>CLI: Match selector against agent IDs/names/slugs
  end
  alt --path specified
    CLI->>API: Read specific log file
  else --path not specified
    CLI->>API: List workspace log paths
  end
  CLI->>CLI: Accumulate entries up to tail limit
  alt --json flag
    CLI->>Output: Emit {entries} JSON
  else text output
    CLI->>Output: Emit formatted log lines
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through flags both small and grand,
To fetch the logs across the land,
Tail and JSON, slug and name,
Now deployment whispers find their frame!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: improving the deployment list display and adding a logs CLI command, which are the primary objectives of this PR.
Description check ✅ Passed The description is clearly related to the changeset, detailing the specific improvements to deployment list display and the new logs command functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deployment-observability-cli

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/cli/src/list-command.ts Outdated
Comment on lines +157 to +168
const entries: LogEntry[] = [];
for (const path of paths.slice(0, 14)) {
entries.push(...await fetchLogEntries({
cloudUrl,
workspace,
token,
path,
agentId: agent.agentId
}));
if (entries.length >= opts.tail) break;
}
writeLogOutput(entries.slice(-opts.tail), opts);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 --tail returns entries from oldest files instead of newest due to reversed accumulation order

fetchLogPaths sorts paths in descending order (newest first) at list-command.ts:377. The loop at lines 158-167 iterates newest-first and uses entries.push(...), placing entries from the newest log file at the beginning of the array and entries from progressively older files at the end. Then entries.slice(-opts.tail) takes the last N entries, which come from the oldest processed files — exactly the opposite of what --tail should return.

Concrete example

Given two log files sorted descending: ["2026-05-19.jsonl", "2026-05-18.jsonl"]

  • After processing 2026-05-19.jsonl: entries = [A(13:00), B(14:00), C(15:00)]
  • After processing 2026-05-18.jsonl: entries = [A(13:00), B(14:00), C(15:00), D(10:00_prev_day), E(11:00_prev_day)]
  • entries.slice(-3)[C(15:00), D(10:00_prev_day), E(11:00_prev_day)] — mixes days and includes older entries
  • Expected: [A(13:00), B(14:00), C(15:00)] — the 3 most recent entries
Suggested change
const entries: LogEntry[] = [];
for (const path of paths.slice(0, 14)) {
entries.push(...await fetchLogEntries({
cloudUrl,
workspace,
token,
path,
agentId: agent.agentId
}));
if (entries.length >= opts.tail) break;
}
writeLogOutput(entries.slice(-opts.tail), opts);
const entries: LogEntry[] = [];
for (const path of paths.slice(0, 14)) {
const fileEntries = await fetchLogEntries({
cloudUrl,
workspace,
token,
path,
agentId: agent.agentId
});
entries.unshift(...fileEntries);
if (entries.length >= opts.tail) break;
}
writeLogOutput(entries.slice(-opts.tail), opts);
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 08fe520. The command now keeps fetched files as newest-first chunks, rebuilds chronological order across chunks before applying tail, and has a regression test for the multi-file case.

@khaliqgant khaliqgant merged commit 6c7d63e into main May 19, 2026
2 of 3 checks passed
@khaliqgant khaliqgant deleted the fix/deployment-observability-cli branch May 19, 2026 16:12
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.

1 participant