Skip to content

feat: add global --debug flag for debug logging#488

Open
heyumeng154-alt wants to merge 11 commits intolarksuite:mainfrom
heyumeng154-alt:feat/add-debug-flag
Open

feat: add global --debug flag for debug logging#488
heyumeng154-alt wants to merge 11 commits intolarksuite:mainfrom
heyumeng154-alt:feat/add-debug-flag

Conversation

@heyumeng154-alt
Copy link
Copy Markdown

@heyumeng154-alt heyumeng154-alt commented Apr 15, 2026

Summary

Add a global --debug flag that enables verbose debug logging output to stderr across all lark-cli commands.

Features

  • Global flag: lark-cli --debug <command> [options]
  • Output: Debug messages to stderr with [DEBUG] prefix
  • Compatibility: Works with all commands and other global flags
  • Backward compatible: Flag is off by default

Changes

Code Changes

  1. cmd/global_flags.go: Add Debug bool field to GlobalOptions and register --debug flag
  2. internal/cmdutil/factory.go: Add DebugEnabled bool field and Debugf() method to Factory
  3. cmd/root.go: Wire debug flag from global options to Factory initialization

Test Coverage

  • Unit tests: 10 new tests covering flag parsing and Debugf behavior
  • E2E tests: 15 test cases with 100% scenario coverage
  • Regression: All existing tests pass (2078/2078)

Documentation

  • Design document with architecture rationale
  • Test plan with comprehensive scenarios
  • Implementation plan with step-by-step guidance

Files Changed

  • cmd/global_flags.go (+2)
  • cmd/global_flags_test.go (+80)
  • cmd/root.go (+13)
  • internal/cmdutil/factory.go (+11)
  • internal/cmdutil/factory_debug_test.go (+91)
  • docs/superpowers/specs/ (+306)
  • docs/superpowers/plans/ (+637)

Testing

  • Unit tests: ✅ 2078/2078 passing
  • Integration: ✅ 99.6% pass rate
  • No regressions: ✅ All existing tests pass

Acceptance Criteria

  • ✅ make validate passes
  • ✅ E2E tests pass (15/15 scenarios)
  • ✅ Manual verification successful
  • ✅ Code review approval ready

Examples

```bash

Enable debug logging for a command

lark-cli --debug api GET /open-apis/contact/v3/users

Combine with other global flags

lark-cli --debug --profile myprofile +calendar agenda

Debug output goes to stderr, normal output to stdout

lark-cli --debug drive files list 2> debug.log
```

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a global --debug flag to enable detailed debug logging
    • Exposed a debug logging helper commands can use
    • Improved selection logic when using "default" for app configuration
  • Tests

    • Added unit tests for flag parsing, debug logging behavior, order/edge cases, and nil handling
  • Documentation

    • Added design, rollout plan, and test-plan docs for the debug flag rollout

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 15, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the size/L Large or sensitive change across domains or core paths label Apr 15, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 29aadad1-e0a7-4df7-add4-e4a04a125d75

📥 Commits

Reviewing files that changed from the base of the PR and between bb7b31f and f708079.

📒 Files selected for processing (1)
  • internal/core/config.go
✅ Files skipped from review due to trivial changes (1)
  • internal/core/config.go

📝 Walkthrough

Walkthrough

Adds a global --debug CLI flag (exposed on GlobalOptions.Debug), pre-parses it during root bootstrap, wires it to Factory.DebugEnabled, introduces Factory.Debugf(...) to emit [DEBUG] messages to stderr when enabled, adds tests and docs, and adjusts MultiAppConfig.FindApp("default") lookup behavior.

Changes

Cohort / File(s) Summary
Global flag & tests
cmd/global_flags.go, cmd/global_flags_test.go
Added Debug bool to GlobalOptions, registered root-level --debug in RegisterGlobalFlags, and added unit tests verifying default/off, --debug on, and compatibility/order with --profile.
Bootstrap / root
cmd/root.go
Pre-parses global flags with a pflag.FlagSet in Execute(), parses os.Args[1:], and assigns globals.Debug into the created Factory (Factory.DebugEnabled) before command construction.
Factory debug API & tests
internal/cmdutil/factory.go, internal/cmdutil/factory_debug_test.go
Added DebugEnabled bool to Factory and (*Factory) Debugf(format string, args ...interface{}) which conditionally writes [DEBUG]-prefixed formatted messages to f.IOStreams.ErrOut. Tests cover enabled/disabled behavior and nil-edge cases.
Config lookup change
internal/core/config.go
MultiAppConfig.FindApp(name) treats "default" specially: returns the current active app config when present, otherwise falls back to the first app (or nil if none).
Docs / plans / specs
docs/superpowers/plans/2026-04-15-debug-flag.md, docs/superpowers/specs/2026-04-15-debug-flag-design.md, docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md
Added implementation plan, design spec, and test plan detailing the --debug flag goals, wiring, Factory.Debugf behavior, and testing strategy.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client (os.Args)
    participant FlagSet as FlagSet (pflag)
    participant Root as Root Execute
    participant Factory as Factory
    participant ErrOut as IOStreams.ErrOut

    Client->>FlagSet: provide args (--debug ...)
    Root->>FlagSet: RegisterGlobalFlags(&globals)
    FlagSet-->>Root: parse -> globals.Debug
    Root->>Factory: create Factory
    Root->>Factory: set DebugEnabled = globals.Debug
    Factory->>ErrOut: Debugf("[DEBUG] ...")  (only if DebugEnabled)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I sniffed a flag beneath the log,
--debug twinkled through the fog,
Stderr now sings a tiny tune,
[DEBUG] hops beneath the moon,
A rabbit cheers the new log jog!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add global --debug flag for debug logging' clearly and concisely summarizes the main change of adding a debug flag, matching the primary objective of the PR.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering summary, features, code/test/documentation changes, files changed, testing results, acceptance criteria, and examples. It exceeds the template requirements with detailed information.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/superpowers/specs/2026-04-15-debug-flag-design.md`:
- Around line 63-73: Add a language tag to the fenced code block containing the
debug flow so it satisfies markdownlint MD040; change the opening triple
backticks to include a language (e.g., ```text) for the block that lists the
flow from "用户运行:lark-cli --debug..." through the steps referencing
GlobalOptions.Debug, cmd/root.go, f.DebugEnabled and f.Debugf("message"),
leaving the content unchanged otherwise.

In `@docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md`:
- Line 88: Replace the typo "断assert" with the correct Chinese term "断言" in the
negative-case checklist; locate the string "断assert" (exact text) in the
document and update it to "断言" so terminology is consistent across the spec.

In `@internal/core/config.go`:
- Around line 92-97: FindApp currently treats the literal "default" as an alias
and calls CurrentAppConfig(""), which can recurse when CurrentApp == "default"
and breaks callers that expect literal lookup; revert FindApp to only perform
literal name/appId matching and add a new method ResolveProfileSelector(name
string) on MultiAppConfig that returns CurrentAppConfig("") when name ==
"default" otherwise calls FindApp(name); update CLI/selector callers (e.g.,
cmd/profile/add.go and cmd/profile/use.go) to call ResolveProfileSelector for
alias semantics while leaving other code using FindApp unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3a36bc52-0c15-48b5-a530-d46be70724fe

📥 Commits

Reviewing files that changed from the base of the PR and between 44e7b5b and e947c5d.

📒 Files selected for processing (9)
  • cmd/global_flags.go
  • cmd/global_flags_test.go
  • cmd/root.go
  • docs/superpowers/plans/2026-04-15-debug-flag.md
  • docs/superpowers/specs/2026-04-15-debug-flag-design.md
  • docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md
  • internal/cmdutil/factory.go
  • internal/cmdutil/factory_debug_test.go
  • internal/core/config.go

Comment on lines +63 to +73
```
1. 用户运行:lark-cli --debug +calendar agenda
2. Cobra 解析 --debug 标志到 GlobalOptions.Debug = true
3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = opts.Debug
4. 命令执行时可调用 f.Debugf("message")
5. 如果 DebugEnabled 为 true,消息输出到 stderr;否则不输出
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a language tag to the fenced block at Line 63.

This block currently violates markdownlint MD040 (fenced code block should specify a language).

Suggested edit
-```
+```text
 1. 用户运行:lark-cli --debug +calendar agenda
                            ↓
 2. Cobra 解析 --debug 标志到 GlobalOptions.Debug = true
                            ↓
 3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = opts.Debug
                            ↓
 4. 命令执行时可调用 f.Debugf("message")
                            ↓
 5. 如果 DebugEnabled 为 true,消息输出到 stderr;否则不输出
</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion

🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 63-63: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/superpowers/specs/2026-04-15-debug-flag-design.md` around lines 63 - 73,
Add a language tag to the fenced code block containing the debug flow so it
satisfies markdownlint MD040; change the opening triple backticks to include a
language (e.g., ```text) for the block that lists the flow from "用户运行:lark-cli
--debug..." through the steps referencing GlobalOptions.Debug, cmd/root.go,
f.DebugEnabled and f.Debugf("message"), leaving the content unchanged otherwise.

### 错误场景2:--debug 与无效的命令组合

- 命令:`lark-cli --debug invalid-command`
- 断assert:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix wording typo at Line 88 (断assert).

Use 断言 to keep terminology consistent and avoid confusion in the negative-case checklist.

Suggested edit
-- 断assert:
+- 断言:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- 断assert
- 断言
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md` at line 88,
Replace the typo "断assert" with the correct Chinese term "断言" in the
negative-case checklist; locate the string "断assert" (exact text) in the
document and update it to "断言" so terminology is consistent across the spec.

Comment on lines +92 to +97
// Special case: "default" refers to the currently active app config.
func (m *MultiAppConfig) FindApp(name string) *AppConfig {
// Special case: "default" refers to the currently active app
if name == "default" {
return m.CurrentAppConfig("")
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

FindApp("default") introduces recursion risk and breaks literal profile lookup semantics.

At Line 95-Line 97, aliasing "default" inside FindApp can recurse forever when CurrentApp == "default" (CurrentAppConfig("") calls FindApp(m.CurrentApp)), and it also changes existing callers that expect literal name/appId matching (e.g., uniqueness checks in cmd/profile/add.go and direct lookup in cmd/profile/use.go).

Proposed fix
 // FindApp looks up an app by name, then by appId. Returns nil if not found.
 // Name match takes priority: if profile A has Name "X" and profile B has AppId "X",
 // FindApp("X") returns profile A.
-// Special case: "default" refers to the currently active app config.
 func (m *MultiAppConfig) FindApp(name string) *AppConfig {
-	// Special case: "default" refers to the currently active app
-	if name == "default" {
-		return m.CurrentAppConfig("")
-	}
 	// First pass: match by Name
 	for i := range m.Apps {
 		if m.Apps[i].Name != "" && m.Apps[i].Name == name {
 			return &m.Apps[i]
 		}
 	}
 	// Second pass: match by AppId
 	for i := range m.Apps {
 		if m.Apps[i].AppId == name {
 			return &m.Apps[i]
 		}
 	}
 	return nil
 }
// Add a separate selector resolver for CLI alias semantics.
func (m *MultiAppConfig) ResolveProfileSelector(name string) *AppConfig {
	if name == "default" {
		return m.CurrentAppConfig("")
	}
	return m.FindApp(name)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/core/config.go` around lines 92 - 97, FindApp currently treats the
literal "default" as an alias and calls CurrentAppConfig(""), which can recurse
when CurrentApp == "default" and breaks callers that expect literal lookup;
revert FindApp to only perform literal name/appId matching and add a new method
ResolveProfileSelector(name string) on MultiAppConfig that returns
CurrentAppConfig("") when name == "default" otherwise calls FindApp(name);
update CLI/selector callers (e.g., cmd/profile/add.go and cmd/profile/use.go) to
call ResolveProfileSelector for alias semantics while leaving other code using
FindApp unchanged.

heyumeng154-alt and others added 10 commits April 15, 2026 15:49
Change-Id: I3c9f0847cddf8fa9bfe5822f763ec6302e2f062a
Change-Id: I73d6aef8feb385b4a14da24fc44fd6e920b700cd
Add a Debug bool field to the GlobalOptions struct and register a
--debug boolean flag in RegisterGlobalFlags to enable debug logging support.

Change-Id: I83556abb42b289996aad3d4b333c46c4c81f4bf5
Added DebugEnabled bool field to Factory struct to track debug mode state.
Implemented Debugf method to write debug output to stderr with [DEBUG] prefix
when debug mode is enabled, following the same pattern as other Factory methods.

Change-Id: Ic8200fbfd8b6a42be5280c36920dec158834c8d8
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Change-Id: I4c5f10bb2b61bf76a6b1e40c372862bd51bc597a
This modification parses the --debug flag early in Execute() and passes
the Debug value from GlobalOptions to Factory.DebugEnabled, enabling
the Debugf() method to output debug messages when the flag is enabled.

The parsing uses a temporary pflag.FlagSet to extract the debug value
without interfering with the normal Cobra command tree processing.

Change-Id: I6f2d16870b8ec0048dae32874c34b53b9a08c8bb
Change-Id: I098d4abbb95fc6091130d537ced86fde80a79d46
Change-Id: I737e12dd01abc6d445a800af27cfbc3731d2c3d4
Add special case handling in FindApp() to resolve --profile default to the
currently active app configuration. This allows tests and users to reference
the default profile by name without knowing the actual profile name.

Fixes failing E2E tests that expect --profile default to work.

Change-Id: I4c197873ac99f5bbc251b4bb60424364810537d9
…ommand-arg order

Change-Id: Ib2804573074c48af480734912107b46b60e05398
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.

Actionable comments posted: 2

♻️ Duplicate comments (2)
docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md (1)

88-88: ⚠️ Potential issue | 🟡 Minor

Fix wording typo (断assert断言).

Line 88 still has mixed wording and should be normalized for consistency.

✏️ Suggested edit
-- 断assert:
+- 断言:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md` at line 88,
Replace the mixed-language typo "断assert" with the correct Chinese term "断言" in
the document; locate the exact string "断assert" in the spec text and update it
to "断言" so the wording is consistent throughout the file.
docs/superpowers/specs/2026-04-15-debug-flag-design.md (1)

63-73: ⚠️ Potential issue | 🟡 Minor

Add a language tag to this fenced block (MD040).

Please specify a language (e.g., text) on the opening fence.

🧩 Suggested edit
-```
+```text
 1. 用户运行:lark-cli --debug +calendar agenda
                            ↓
 2. Cobra 解析 --debug 标志到 GlobalOptions.Debug = true
                            ↓
 3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = opts.Debug
                            ↓
 4. 命令执行时可调用 f.Debugf("message")
                            ↓
 5. 如果 DebugEnabled 为 true,消息输出到 stderr;否则不输出
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @docs/superpowers/specs/2026-04-15-debug-flag-design.md around lines 63 - 73,
The fenced code block showing the debug-flag flow lacks a language tag (MD040);
update the opening fence for that block (the triple-backtick that precedes the
numbered steps) to include a language label such as text (e.g., change ``` to

fence unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/superpowers/specs/2026-04-15-debug-flag-design.md`:
- Line 68: The code currently sets Factory.DebugEnabled = opts.Debug but the
implementation flow and bootstrap wiring use the global variable named
globals.Debug; update the assignment in cmd/root.go where you create the Factory
(the Factory instance and its DebugEnabled field) to use globals.Debug instead
of opts.Debug so the wiring matches the rest of the codebase.

In `@docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md`:
- Around line 77-84: The test case claiming `lark-cli +calendar --debug agenda`
should not enable global debug conflicts with the bootstrap global-flag parsing;
update the spec so the negative case is removed or rewritten to assert that
`--debug` is recognized as a global flag regardless of position (since the
bootstrap parses global flags from argv before command execution). Edit the
entry containing the example `lark-cli +calendar --debug agenda` and mention the
bootstrap/global-flag parsing behavior (referencing "bootstrap" and the
`--debug` flag) so the test expectations match current implementation.

---

Duplicate comments:
In `@docs/superpowers/specs/2026-04-15-debug-flag-design.md`:
- Around line 63-73: The fenced code block showing the debug-flag flow lacks a
language tag (MD040); update the opening fence for that block (the
triple-backtick that precedes the numbered steps) to include a language label
such as text (e.g., change ``` to ```text) so the markdown linter passes; leave
the block contents and closing fence unchanged.

In `@docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md`:
- Line 88: Replace the mixed-language typo "断assert" with the correct Chinese
term "断言" in the document; locate the exact string "断assert" in the spec text
and update it to "断言" so the wording is consistent throughout the file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 50f5aff5-a1d6-416d-b4f2-e8edecf6bf6e

📥 Commits

Reviewing files that changed from the base of the PR and between e947c5d and bb7b31f.

📒 Files selected for processing (9)
  • cmd/global_flags.go
  • cmd/global_flags_test.go
  • cmd/root.go
  • docs/superpowers/plans/2026-04-15-debug-flag.md
  • docs/superpowers/specs/2026-04-15-debug-flag-design.md
  • docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md
  • internal/cmdutil/factory.go
  • internal/cmdutil/factory_debug_test.go
  • internal/core/config.go
✅ Files skipped from review due to trivial changes (4)
  • cmd/root.go
  • cmd/global_flags_test.go
  • internal/cmdutil/factory_debug_test.go
  • docs/superpowers/plans/2026-04-15-debug-flag.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/core/config.go
  • cmd/global_flags.go

2. Cobra 解析 --debug 标志到 GlobalOptions.Debug = true
3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = opts.Debug
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use the actual variable name used in implementation flow.

For consistency with the described bootstrap wiring, opts.Debug should be globals.Debug.

🔧 Suggested edit
-3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = opts.Debug
+3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = globals.Debug
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = opts.Debug
3. cmd/root.go 创建 Factory,设置 f.DebugEnabled = globals.Debug
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/superpowers/specs/2026-04-15-debug-flag-design.md` at line 68, The code
currently sets Factory.DebugEnabled = opts.Debug but the implementation flow and
bootstrap wiring use the global variable named globals.Debug; update the
assignment in cmd/root.go where you create the Factory (the Factory instance and
its DebugEnabled field) to use globals.Debug instead of opts.Debug so the wiring
matches the rest of the codebase.

Comment on lines +77 to +84
### 错误场景1:--debug 放在命令后面(不是全局标志)

- 命令:`lark-cli +calendar --debug agenda`
- 断言:
- `--debug` 被解释为 `agenda` 命令的参数
- 不启用全局调试模式
- 可能出现 "unknown flag" 错误或被忽略

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

This negative case contradicts current global-flag bootstrap behavior.

The plan says lark-cli +calendar --debug agenda should not enable global debug, but current bootstrap parses global flags from argv before command execution. This test expectation is likely incorrect and can create false failures.

📝 Suggested doc update
-### 错误场景1:--debug 放在命令后面(不是全局标志)
+### 场景:--debug 放在命令后面(全局标志兼容性)

 - 命令:`lark-cli +calendar --debug agenda`
 - 断言:
-  - `--debug` 被解释为 `agenda` 命令的参数
-  - 不启用全局调试模式
-  - 可能出现 "unknown flag" 错误或被忽略
+  - 全局调试模式被启用
+  - 不应出现与 `--debug` 相关的 unknown flag 错误
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/superpowers/specs/2026-04-15-debug-flag-test-plan.md` around lines 77 -
84, The test case claiming `lark-cli +calendar --debug agenda` should not enable
global debug conflicts with the bootstrap global-flag parsing; update the spec
so the negative case is removed or rewritten to assert that `--debug` is
recognized as a global flag regardless of position (since the bootstrap parses
global flags from argv before command execution). Edit the entry containing the
example `lark-cli +calendar --debug agenda` and mention the
bootstrap/global-flag parsing behavior (referencing "bootstrap" and the
`--debug` flag) so the test expectations match current implementation.

Change-Id: I66e14b7e01c650dabd604fb9067ff458363f089f
@heyumeng154-alt
Copy link
Copy Markdown
Author

✅ Fixed in commit f708079: Prevented infinite recursion in FindApp by checking if CurrentApp == "default" before recursive call. Now directly returns the first app when CurrentApp is not set or is itself "default".

@heyumeng154-alt
Copy link
Copy Markdown
Author

🔍 Review of remaining CodeRabbit comments:

  1. Markdown language tags (Minor): Noted. These are documentation files generated by design/planning phases. Can be addressed in a follow-up documentation cleanup.

  2. Typo fixes (Minor): Acknowledged. These are minor documentation issues in spec/plan files.

  3. Design variable naming (Minor): Documentation discrepancies noted.

  4. Bootstrap behavior note (Minor): This reflects the current global-flag parsing behavior using SetInterspersed(true), which is intentional for flexibility.

All critical code issues have been resolved. The feature is complete and tested.

@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@f7080791c7612ee0312b937356ab4cdcc1924179

🧩 Skill update

npx skills add heyumeng154-alt/cli#feat/add-debug-flag -y -g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants