Skip to content

Render rich server command catalog#5

Merged
akcorca merged 1 commit into
mainfrom
codex/server-cli-command-catalog
May 20, 2026
Merged

Render rich server command catalog#5
akcorca merged 1 commit into
mainfrom
codex/server-cli-command-catalog

Conversation

@akcorca
Copy link
Copy Markdown
Contributor

@akcorca akcorca commented May 20, 2026

Summary

  • parse /api/client commands metadata in the Go CLI
  • render grouped server-owned command syntax in default help
  • make commands --format text print command id, syntax, and description
  • bump VERSION to v0.1.6

Tests

  • go test ./...
  • ./scripts/check_coverage.sh 35
  • golangci-lint run ./...
  • go build ./cmd/craken

Summary by CodeRabbit

릴리스 노트 v0.1.6

  • 새로운 기능

    • 서버 제공 명령을 CLI 헬프에서 발견하고 표시하는 기능 추가
    • 도움말 출력에서 서버 명령을 그룹화된 형식으로 구성하여 더 나은 가독성 제공
  • 문서

    • CLI 동작 및 명령 구문 지원에 대한 아키텍처 문서 업데이트

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

개요

PR은 서버 카탈로그에서 Commands 메타데이터를 파싱하고 렌더링하는 기능을 추가합니다. 헬프 출력과 craken commands 명령에서 서버 제공 명령 목록을 그룹별로 정렬하여 표시합니다.

변경 사항

Commands 기반 서버 카탈로그 지원

레이어 / 파일 요약
명령 카탈로그 데이터 모델 확장
internal/craken/generic.go
clientCatalogCommands 필드와 cliCommand 타입을 추가하여 명령/예제/그룹 메타데이터를 표현합니다.
카탈로그 Commands 필드 검증
internal/craken/generic.go
catalogFromValue에서 Commands의 필수 필드(ID/Group/Command/Description)와 Examples 존재 여부를 검증하고, 공백 문자열 제거 후 유효성을 확인합니다.
헬프 출력에서 Commands 렌더링
internal/craken/command.go
printCatalogHelp를 조건부 분기로 수정하여 Commands 존재 시 그룹별 정렬된 명령을 "Server commands" 섹션으로 표시합니다. commandGroup 타입과 groupedCommands, printCommandsText 함수를 추가합니다.
Commands 명령 출력 로직
internal/craken/generic.go
runCommands를 수정하여 --format text 실행 시 Commands 존재 여부에 따라 출력 포맷을 결정하고, JSON 출력은 원본 응답값을 사용하도록 변경합니다.
명령 카탈로그 기능 테스트
internal/craken/command_test.go
헬프 렌더링 테스트를 확장하여 Commands 기반 출력을 검증하고, TestCommandsTextRendersServerCommands 테스트를 추가하여 commands --format text의 정확한 포맷팅을 확인합니다.
문서 및 버전 업데이트
AGENTS.md, docs/architecture.md, VERSION
craken commands 항목을 AGENTS.md에 추가하고, 아키텍처 문서에서 Commands 기반 커맨드 디스커버리를 설명하며, 버전을 v0.1.6으로 변경합니다.

관련 PR

  • corca-ai/craken-cli#4: 동일한 printCatalogHelp 함수와 서버 /api/client 카탈로그 기반 헬프 렌더링 로직을 수정하는 코드 레벨의 직접적 관련성이 있습니다.

🎯 3 (Moderate) | ⏱️ ~20 분

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 PR의 주요 변경사항을 명확하게 요약합니다. 서버 커맨드 카탈로그를 렌더링하는 것이 이 PR의 핵심 목표이며, 제목은 이를 정확히 반영합니다.
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 codex/server-cli-command-catalog

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/craken/command.go (1)

273-290: ⚡ Quick win

명령 그룹/항목 정렬을 추가해 출력 순서를 안정화해 주세요.

현재는 서버가 준 순서를 그대로 사용해서 도움말 출력 순서가 비결정적일 수 있습니다. 그룹명/명령문 기준 정렬을 넣으면 사용자 경험과 테스트 안정성이 좋아집니다.

제안 패치
 import (
 	"context"
 	"fmt"
 	"io"
+	"sort"
 	"strings"
 )
@@
 func groupedCommands(commands []cliCommand) []commandGroup {
 	groups := []commandGroup{}
 	indexes := map[string]int{}
 	for _, command := range commands {
@@
 		groups[index].Commands = append(groups[index].Commands, command)
 	}
+	sort.Slice(groups, func(i, j int) bool {
+		return groups[i].Name < groups[j].Name
+	})
+	for i := range groups {
+		sort.Slice(groups[i].Commands, func(a, b int) bool {
+			if groups[i].Commands[a].Command == groups[i].Commands[b].Command {
+				return groups[i].Commands[a].ID < groups[i].Commands[b].ID
+			}
+			return groups[i].Commands[a].Command < groups[i].Commands[b].Command
+		})
+	}
 	return groups
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/craken/command.go` around lines 273 - 290, The groupedCommands
function currently preserves input order; make it deterministic by sorting the
resulting groups by group Name and sorting each group's Commands slice by a
stable command identifier (e.g. cliCommand.Name or whichever field represents
the command label). After you build groups in groupedCommands, run a sort.Slice
on groups comparing group.Name, and for each group run sort.Slice on
group.Commands comparing command.Name (replace with the actual field if
different), ensuring consistent output order for commandGroup and cliCommand.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/craken/command.go`:
- Around line 273-290: The groupedCommands function currently preserves input
order; make it deterministic by sorting the resulting groups by group Name and
sorting each group's Commands slice by a stable command identifier (e.g.
cliCommand.Name or whichever field represents the command label). After you
build groups in groupedCommands, run a sort.Slice on groups comparing
group.Name, and for each group run sort.Slice on group.Commands comparing
command.Name (replace with the actual field if different), ensuring consistent
output order for commandGroup and cliCommand.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8798fd7c-da46-4ab7-8889-d3f907590f7a

📥 Commits

Reviewing files that changed from the base of the PR and between 905bcc9 and de74685.

📒 Files selected for processing (6)
  • AGENTS.md
  • VERSION
  • docs/architecture.md
  • internal/craken/command.go
  • internal/craken/command_test.go
  • internal/craken/generic.go
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

Store named bearer profiles in ${CRAKEN_CONFIG_DIR:-~/.config/craken}/config.json, matching the legacy Node CLI profile format

Browser login must use the /api/client/device-authorizations and /api/client/device-token device-code flow for authentication

Discover new server APIs and command help through the server-owned /api/client catalog using craken commands, craken do, craken get, craken post, and related generic commands

Files:

  • internal/craken/command.go
  • internal/craken/command_test.go
  • internal/craken/generic.go
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: corca-ai/craken-cli

Timestamp: 2026-05-20T10:30:18.371Z
Learning: Consult docs/build.md for build-related information and procedures
Learnt from: CR
Repo: corca-ai/craken-cli

Timestamp: 2026-05-20T10:30:18.371Z
Learning: Consult docs/testing.md for testing-related information and procedures
Learnt from: CR
Repo: corca-ai/craken-cli

Timestamp: 2026-05-20T10:30:18.371Z
Learning: Consult docs/architecture.md for architecture-related information and procedures
Learnt from: CR
Repo: corca-ai/craken-cli

Timestamp: 2026-05-20T10:30:18.371Z
Learning: craken is a Go CLI that interfaces with the Craken service at https://craken.borca.ai
Learnt from: CR
Repo: corca-ai/craken-cli

Timestamp: 2026-05-20T10:30:18.371Z
Learning: Product commands call the same HTTP and WebSocket APIs used by the browser
🔇 Additional comments (6)
VERSION (1)

1-1: LGTM!

AGENTS.md (1)

14-14: LGTM!

docs/architecture.md (1)

5-7: LGTM!

internal/craken/generic.go (1)

31-45: LGTM!

Also applies to: 59-79, 182-191

internal/craken/command.go (1)

211-252: LGTM!

Also applies to: 268-271, 292-299

internal/craken/command_test.go (1)

52-59: LGTM!

Also applies to: 88-92, 104-105, 115-149

@akcorca akcorca merged commit 17d43de into main May 20, 2026
2 checks passed
@akcorca akcorca deleted the codex/server-cli-command-catalog branch May 20, 2026 10:37
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