Skip to content

spec: define listing-aware file link resolution#9973

Open
oz-for-oss[bot] wants to merge 1 commit intomasterfrom
oz-agent/spec-issue-9908
Open

spec: define listing-aware file link resolution#9973
oz-for-oss[bot] wants to merge 1 commit intomasterfrom
oz-agent/spec-issue-9908

Conversation

@oz-for-oss
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot commented May 3, 2026

Summary

  • Add a product spec for resolving clickable filenames from ls DIR/-style output against the listed directory.
  • Add a technical spec grounded in the current BlockList link-detection flow, with proposed helper APIs, resolution order, performance guardrails, and validation coverage.

Validation

  • Reviewed relevant terminal link-detection, file-resolution, block serialization, and command parsing code paths.
  • Spec-only change; no production code or tests were modified.

Related issue: #9908

Co-Authored-By: Randy James <216760973+rndjams@users.noreply.github.com>
@oz-for-oss
Copy link
Copy Markdown
Contributor Author

oz-for-oss Bot commented May 3, 2026

@oz-for-oss[bot]

I'm starting a first review of this spec-only pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor Author

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This spec defines listing-aware file-link resolution for ls DIR/-style BlockList output and covers the main product behavior, code touchpoints, risks, and validation strategy.

Concerns

  • Compound and piped command opt-outs are not specified in a way the technical plan can enforce, so output transformed after ls DIR/ could still resolve against the listed directory.
  • Directory-as-operand flags such as ls -d are not excluded, leaving a path to the same silent misresolution the feature is meant to prevent.
  • The proposed listed-root type bypasses the existing shell-native path conversion path unless the spec defines how to convert it with the block session's launch data.

Verdict

Found: 0 critical, 3 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH9908/product.md
- The first path-like positional is not an existing directory.
- The command uses multiple directory operands in one invocation.
- The command is recursive, such as `ls -R subdir/`.
- The output is in a different block from the listing command because of pipes, redirects, scripts, or `cat` of saved output.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] Piped or compound commands do not necessarily move output to a different block, and the tech plan can still derive a listed root from the first command. Require listing-aware resolution to opt out when the block command contains pipes, redirects, or command separators so transformed output like ls subdir | sed ... is not resolved against subdir.

Comment thread specs/GH9908/tech.md
- Skip leading `KEY=VALUE` environment variable assignments before checking the command name.
- Check the command name against `listing_commands`.
- Skip flags and flag values that are known not to be directory operands.
- Reject recursive mode for `ls -R` and `ls --recursive`.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] Reject -d/--directory and equivalent replacement-command flags here too; those commands print the directory operand itself rather than entries under it, so ls -d subdir could resolve output token subdir as subdir/subdir when that nested path exists.

Comment thread specs/GH9908/tech.md
- Existing root: `working_directory: &str`.
- New root: `listing_directory: Option<PathBuf>`.
For each candidate path:
1. If `listing_directory` exists and the candidate is not already absolute and does not already include a path component that should resolve correctly against `working_directory`, try `absolute_path_if_valid(candidate, ShellPathType::PlatformNative(listing_directory.clone()), shell_launch_data)`.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] This treats listing_directory as platform-native even though the current resolver receives block.pwd() as a shell-native string. Specify how the helper converts the listed root with the block session's ShellLaunchData, or keep the listed root shell-native, so WSL/MSYS-style local shells do not lose correct resolution.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant