8000 [pull] main from can1357:main by pull[bot] · Pull Request #120 · ericrihm/oh-my-pi · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8f9910a
fix(pi-edit): allow editing handwritten generated.go files
radkawar Sep 24, 2026
9484398
fix(agent): reject tool calls whose intent field carries the payload
radkawar Sep 24, 2026
4eba3f1
fix(coding-agent): link background job Full output to the raw capture
radkawar Sep 24, 2026
d288549
docs(coding-agent): credit #13139 in changelog entry
radkawar Sep 24, 2026
205c890
docs(coding-agent): link PR in changelog entry
radkawar Sep 24, 2026
8f09a5a
fix(agent): skip intent payload guard for unknown tools and tool-owned i
radkawar Sep 24, 2026
deb3ba5
chore(vendor): vendored tree-sitter-go 0.25.0 unmodified
radkawar Sep 24, 2026
622eb34
fix(ast): parse Go 1.26 new(expr) without syntax errors
radkawar Sep 24, 2026
cf5f732
docs(coding-agent): link #13149 in the Go new(expr) changelog entry
radkawar Sep 24, 2026
5a3c8ad
fix(coding-agent): keep grep dir/*.go globs out of subdirectories
radkawar Sep 24, 2026
7e0f006
docs(coding-agent): link grep glob fix PR in changelog
radkawar Sep 24, 2026
9600130
fix(pi-ast): PUT/CUT N* on a block's first statement stops at that st…
radkawar Sep 24, 2026
7babba0
docs(coding-agent): link PR in changelog entry
radkawar Sep 24, 2026
3ab6563
fix(natives): fail the build when an installed host addon cannot load
alphastorm Sep 21, 2026
9d1099a
fix(natives): probe only the host's own addon target
alphastorm Sep 22, 2026
a01014e
fix(shell): expand inherited Windows temp paths
CoderTCY Sep 25, 2026
c876348
test(natives): resolve the host addon filename for the load probe test
Sep 25, 2026
b26dafe
Merge PR #13141: fix(agent): reject tool calls whose intent field car…
Sep 25, 2026
e589051
Merge PR #13139: fix(pi-edit): allow editing handwritten generated.go…
Sep 25, 2026
e167f27
Merge PR #13149: fix(ast): parse Go 1.26 new(expr) without syntax err…
Sep 25, 2026
3255eaa
docs(changelog): move merged #13139/#13141/#13149 entries to Unreleased
Sep 25, 2026
afc5199
Merge remote-tracking branch 'origin/main' into fix-13154
Sep 25, 2026
ee5bcc2
Merge remote-tracking branch 'origin/main' into fix-13143
Sep 25, 2026
79b300b
fix(natives): build the musl addon for a musl host and bound the load…
Sep 25, 2026
911bda1
fix(pi-ast): skip trailing comments when checking a leading statement…
Sep 25, 2026
8a708c2
fix(coding-agent): keep trailing exit notices in raw-capture async pr…
Sep 25, 2026
0b6fc36
Merge remote-tracking branch 'origin/main' into fix-13150
Sep 25, 2026
42e056c
docs(coding-agent): document grep glob depth for directory-prefixed p…
Sep 25, 2026
17954ec
Merge PR #12682: fix(natives): fail the build when an installed host …
H4vC Sep 25, 2026
409eb96
Merge PR #13154: fix(pi-ast): PUT/CUT N* on a block's first statement…
Sep 25, 2026
bcecfba
Merge PR #13143: fix(coding-agent): link background job Full output t…
Sep 25, 2026
a25bf57
fix(shell): expand forwarded session TEMP and scope key folding
Sep 25, 2026
a3639f9
Merge remote-tracking branch 'origin/main' into pr-13265
Sep 25, 2026
56cc67e
Merge PR #13265: fix(shell): expand inherited Windows temp 8.3 paths …
H4vC Sep 25, 2026
8000 ea8b542
Merge PR #13150: fix(coding-agent): keep grep dir/*.go globs out of s…
Sep 25, 2026
ccb4451
feat(tui): filter the esc-esc rewind selector with f
Sep 25, 2026
7f21643
docs(changelog): add rewind selector filter entry
Sep 25, 2026
ba344f5
Merge pull request #13295 from can1357/feat/rewind-selector-filter
H4vC Sep 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ packages/*/CHANGELOG.md merge=union
packages/catalog/src/models.json binary
packages/catalog/src/compat/rules.json binary

# Generated tree-sitter parser: regenerate from grammar.js (see its README.md).
crates/vendor/tree-sitter-go/src/parser.c linguist-generated

3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"crates/pi-walker",
"crates/vendor/brush-core",
"crates/vendor/cfg_aliases",
"crates/vendor/tree-sitter-go",
]
resolver = "3"

Expand All @@ -33,6 +34,9 @@ brush-core = { path = "crates/vendor/brush-core" }
# portable-pty 0.9.0 pins nix 0.28, whose cfg_aliases 0.1.1 expansion emits
# future-incompatible trailing semicolons.
cfg_aliases = { path = "crates/vendor/cfg_aliases" }
# tree-sitter-go 0.25.0 (latest release) rejects Go 1.26 `new(expr)`; the
# vendored copy carries the upstream grammar fix (see its README.md).
tree-sitter-go = { path = "crates/vendor/tree-sitter-go" }

[profile.release]
opt-level = 3
Expand Down
4 changes: 3 additions & 1 deletion crates/pi-ast/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ rust_library(
edition = "2024",
proc_macro_deps = all_crate_deps(proc_macro = True),
version = "17.1.5",
deps = all_crate_deps(normal = True),
deps = all_crate_deps(normal = True) + [
"//crates/vendor/tree-sitter-go",
],
)

rust_test(
Expand Down
98 changes: 95 additions & 3 deletions crates/pi-ast/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::collections::BTreeSet;

use anyhow::Result;
use serde::{Deserialize, Serialize};
use tree_sitter::{Point, TreeCursor};
use tree_sitter::{Node, Point, TreeCursor};

use crate::{
parse_cache::parse_cached,
Expand Down Expand Up @@ -98,8 +98,10 @@ pub fn block_range_at(options: BlockRangeOptions) -> Result<Option<BlockRange>>
return Ok(None);
}
// Climb to the outermost named ancestor that still begins on `row`,
// excluding the whole-file root. Ancestors can only begin on an earlier
// row, so the first parent that starts before `row` stops the climb.
// excluding the whole-file root. The first parent that starts before `row`
// stops the climb, and so does a statement-sequence container: it begins
// exactly where its first statement does, so adopting it would swallow
// every following sibling statement.
let mut node = leaf;
while let Some(parent) = node.parent() {
if parent.id() == root.id() {
Expand All @@ -108,6 +110,9 @@ pub fn block_range_at(options: BlockRangeOptions) -> Result<Option<BlockRange>>
if parent.start_position().row != row {
break;
}
if is_statement_sequence(parent, node) {
break;
}
node = parent;
}
// Refuse degenerate error-recovery spans: a missing brace can make
Expand All @@ -123,6 +128,50 @@ pub fn block_range_at(options: BlockRangeOptions) -> Result<Option<BlockRange>>
}))
}

/// Is `parent` a statement-sequence container that `node` merely opens? These
/// nodes wrap the sibling statements or entries of a body without a token of
/// their own, so they begin exactly where their first child does: Go and
/// PowerShell `statement_list`, Python/Starlark/Lua `block`, Ruby
/// `body_statement`, Swift/Kotlin `statements`, HCL/CMake `body`, Scala
/// `indented_block`, YAML `block_mapping`/`block_sequence`, Kotlin
/// `import_list`, PowerShell `hash_literal_body`.
///
/// The container is matched by kind because grammars expose no uniform
/// structural marker: field-less prefix runs such as Java/Kotlin/Swift
/// `modifiers` (one annotation per line) look identical but must be climbed
/// through to reach the declaration. Braced `block`s never match because they
/// begin at `{`; requiring the next sibling to start a later row at `node`'s
/// column also rules out a leading label (`'a: {` in Rust). Extras (comments)
/// trailing `node` on its last row are skipped so `if … {} // note` still
/// stops the climb.
fn is_statement_sequence(parent: Node<'_>, node: Node<'_>) -> bool {
if !matches!(
parent.kind(),
"statement_list"
| "block"
| "body_statement"
| "statements"
| "body"
| "indented_block"
| "block_mapping"
| "block_sequence"
| "import_list"
| "hash_literal_body"
) || parent.start_byte() != node.start_byte()
{
return false;
}
let end_row = node.end_position().row;
let mut next = node.next_named_sibling();
while let Some(sibling) = next.filter(|s| s.is_extra() && s.start_position().row == end_row) {
next = sibling.next_named_sibling();
}
next.is_some_and(|next| {
let next_start = next.start_position();
next_start.row > end_row && next_start.column == node.start_position().column
})
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub struct LineRange {
/// 1-indexed inclusive first visible line.
Expand Down Expand Up @@ -501,6 +550,49 @@ mod tests {
assert_eq!(resolve(code, "f.py", 3), Some(BlockRange { start_line: 3, end_line: 4 }));
}

#[test]
fn go_leading_statement_excludes_following_siblings() {
// tree-sitter-go wraps a block body in a `statement_list` that begins
// exactly at its first statement; the leading `if` must not resolve to
// the whole list and swallow the statements after it.
let code = "package p\n\nfunc f() error {\n\tif err := step(); err != nil {\n\t\treturn \
err\n\t}\n\tother()\n\treturn nil\n}\n";
assert_eq!(resolve(code, "x.go", 4), Some(BlockRange { start_line: 4, end_line: 6 }));
assert_eq!(resolve(code, "x.go", 3), Some(BlockRange { start_line: 3, end_line: 9 }));
}

#[test]
fn python_leading_statement_excludes_following_siblings() {
let code = "def f(x):\n if x:\n return 1\n y = 2\n return y\n";
assert_eq!(resolve(code, "f.py", 2), Some(BlockRange { start_line: 2, end_line: 3 }));
}

#[test]
fn leading_statement_with_trailing_comment_excludes_following_siblings() {
// A comment on the statement's last row is a named sibling; it must not
// hide the next statement and let the climb swallow the whole body.
let go = "package p\n\nfunc f() error {\n\tif err := step(); err != nil {\n\t\treturn \
err\n\t} // note\n\tother()\n\treturn nil\n}\n";
assert_eq!(resolve(go, "x.go", 4), Some(BlockRange { start_line: 4, end_line: 6 }));
let py = "def f(x):\n y = 2 # note\n z = 3\n return y\n";
assert_eq!(resolve(py, "f.py", 2), Some(BlockRange { start_line: 2, end_line: 2 }));
}

#[test]
fn yaml_first_top_level_key_resolves_only_its_entry() {
let code = "name: ci\non:\n push:\n branches: [main]\njobs:\n build: {}\n";
assert_eq!(resolve(code, "ci.yml", 1), Some(BlockRange { start_line: 1, end_line: 1 }));
assert_eq!(resolve(code, "ci.yml", 3), Some(BlockRange { start_line: 3, end_line: 4 }));
}

#[test]
fn java_stacked_annotations_still_resolve_the_declaration() {
// One annotation per line forms a `modifiers` run that also begins at
// its first child; unlike a statement list it must be climbed through.
let code = "class A {\n @Override\n @Deprecated\n public void f() {\n g();\n }\n}\n";
assert_eq!(resolve(code, "A.java", 2), Some(BlockRange { start_line: 2, end_line: 6 }));
}

#[test]
fn resolves_nested_block_to_outermost_on_line() {
// Point at the inner `if` line; it resolves the whole `if` block
Expand Down
13 changes: 13 additions & 0 deletions crates/pi-ast/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,19 @@ mod tests {
assert!(!result.segments.is_empty());
}

#[test]
fn parses_go_new_with_expression_operand() {
// Go 1.26 `new(expr)` must parse alongside the classic `new(T)` form.
let result = summarize(
"package p\n\nfunc f() {\n\tframe.Due = new(work.Due.Add(delay))\n\tx := new(g(1))\n\ty \
:= new(T)\n\t_, _ = x, y\n}\n",
"fixture.go",
);

assert!(result.parsed);
assert_eq!(result.language.as_deref(), Some("go"));
}

#[test]
fn summarizes_emacs_lisp_defun_body() {
let code = "(defun greet (name)\n \"Doc.\"\n (let ((message (format \"Hello %s\" \
Expand Down
39 changes: 38 additions & 1 deletion crates/pi-edit/src/path_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ fn escape_glob_metachars(value: &str) -> String {
out
}

/// Basenames that only generators produce; these block without inspecting
/// content. Ambiguous names such as `generated.go` are left to the content
/// marker check instead.
fn generated_filename(display: &str) -> Option<String> {
let name = display.replace('\\', "/").rsplit('/').next()?.to_owned();
let patterns = [
Expand All @@ -557,7 +560,6 @@ fn generated_filename(display: &str) -> Option<String> {
r"_pb2\.py$",
r"_pb2_grpc\.py$",
r"\.gen\.(go|ts|js|py)$",
r"^generated\.(go|ts|js|py)$",
r"\.swagger\.json$",
r"\.mock\.(go|ts)$",
r"\.mocks?\.(go|ts|js)$",
Expand All @@ -578,6 +580,7 @@ fn detect_generated_marker(content: &str, display: &str) -> Option<String> {
for pattern in [
r"(?i)@generated\b".to_owned(),
r"(?i)\bcode\s+generated\s+by\s+[a-z0-9_.-]+".to_owned(),
r"(?i)\bcode\s+generated\b.*\bdo\s+not\s+edit\b".to_owned(),
r"(?i)\bthis\s+file\s+was\s+automatically\s+generated\b".to_owned(),
format!(r"(?i)\bgenerated\s+by\s+{known}\b"),
] {
Expand Down Expand Up @@ -931,6 +934,40 @@ mod tests {
);
}

#[test]
fn ambiguous_generated_basename_requires_content_marker() {
let tmp = tempfile::tempdir().unwrap();
let p = policy(tmp.path());
assert!(
p.auto_generated_message(
"internal/services/organizations/generated.go",
b"package organizations\n\nfunc Build() {}\n"
)
.is_none()
);
assert!(p.auto_generated_message("generated.ts", b"").is_none());
assert!(
p.auto_generated_message(
"internal/services/organizations/generated.go",
b"// Code generated by x. DO NOT EDIT.\n\npackage organizations\n"
)
.unwrap()
.contains("Code generated by x")
);
assert!(
p.auto_generated_message(
"generated.go",
b"// Code generated from schema.graphql; DO NOT EDIT.\n\npackage api\n"
)
.is_some()
);
assert!(
p.auto_generated_message("zz_generated.deepcopy.go", b"package v1\n")
.unwrap()
.contains("detected marker: \"zz_generated.deepcopy.go\"")
);
}

#[test]
fn permits_hand_authored_openapi_json() {
let tmp = tempfile::tempdir().unwrap();
Expand Down
25 changes: 25 additions & 0 deletions crates/pi-edit/tests/hashline_parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,31 @@ async fn block_replace_cases_resolve_syntax_end_to_end() {
);
}

#[tokio::test]
async fn block_cut_on_leading_go_statement_keeps_following_siblings() {
let source = "package p\n\nfunc f() error {\n\tif err := step(); err != nil {\n\t\treturn \
err\n\t}\n\tother()\n\treturn nil\n}\n";
let workspace = Workspace::new(EditMode::Hashline);
workspace.write("x.go", source);
let tag = workspace.snapshot("x.go", source, None);
let args = json!({ "input": format!("[x.go#{tag}]\nCUT 4*") });
let result = workspace
.apply_json(&args, &common::DiskWriter::default())
.await
.expect("deletes the leading `if` block");
assert_eq!(
workspace.read("x.go").as_deref(),
Some("package p\n\nfunc f() error {\n\tother()\n\treturn nil\n}\n")
);
assert!(
result
.text
.contains("CUT 4* → resolved lines 4-6 (3 lines)"),
"{}",
result.text
);
}

#[tokio::test]
async fn seen_line_guard_rejects_hidden_anchors_and_accepts_seen_anchors() {
let root = fixture("parity_seen_line_guard.json");
Expand Down
44 changes: 40 additions & 4 deletions crates/pi-natives/src/grep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ pub struct GrepOptions<'env> {
pub path: String,
/// Glob filter for filenames (e.g., "*.ts").
pub glob: Option<String>,
/// Match simple glob patterns at any depth (default: true; `*.ts` ->
/// `**/*.ts`). Set false when `glob` is already relative to `path`.
pub recursive: Option<bool>,
/// Filter by file type (e.g., "js", "py", "rust").
pub r#type: Option<String>,
/// Case-insensitive search.
Expand Down Expand Up @@ -798,6 +801,7 @@ pub(crate) struct GrepConfig {
pub(crate) pattern: String,
pub(crate) path: String,
pub(crate) glob: Option<String>,
pub(crate) recursive: Option<bool>,
pub(crate) type_filter: Option<String>,
pub(crate) ignore_case: Option<bool>,
pub(crate) multiline: Option<bool>,
Expand Down Expand Up @@ -1121,8 +1125,7 @@ fn build_grep_walk_request(
order: pi_walker::WalkOrder,
) -> Result<pi_walker::WalkRequest> {
let mut filter = pi_walker::WalkFilter::files_only();
if let Some(glob) = glob.map(str::trim).filter(|value| !value.is_empty()) {
let pattern = glob_util::build_glob_pattern(glob, true);
if let Some(pattern) = glob {
let compiled = pi_walker::CompiledWalkGlob::new([pattern])
.map_err(|err| Error::from_reason(format!("Invalid glob pattern: {err}")))?;
filter = filter.glob(compiled);
Expand Down Expand Up @@ -1949,8 +1952,14 @@ fn grep_sync_with_matcher<M: Matcher + Sync>(
let offset = options.offset.unwrap_or(0) as u64;
let include_hidden = options.hidden.unwrap_or(true);
let use_gitignore = options.gitignore.unwrap_or(true);
let glob = options.glob.as_deref();
let _ = glob_util::try_compile_glob(glob, true)?;
let glob = options
.glob
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.map(|value| glob_util::build_glob_pattern(value, options.recursive.unwrap_or(true)));
let _ = glob_util::try_compile_glob(glob.as_deref(), false)?;
let glob = glob.as_deref();
let type_filter = resolve_type_filter(options.type_filter.as_deref());

let params = SearchParams {
Expand Down Expand Up @@ -2239,6 +2248,7 @@ pub fn grep(
pattern,
path,
glob,
recursive,
r#type,
ignore_case,
multiline,
Expand All @@ -2262,6 +2272,7 @@ pub fn grep(
pattern,
path,
glob,
recursive,
type_filter: r#type,
ignore_case,
multiline,
Expand Down Expand Up @@ -2357,6 +2368,7 @@ mod tests {
pattern: "needle".to_string(),
path: path.to_string_lossy().into_owned(),
glob: None,
recursive: None,
type_filter: None,
ignore_case: None,
multiline: None,
Expand Down Expand Up @@ -2595,6 +2607,30 @@ mod tests {
assert_eq!(result.matches[0].line, "needle kept");
}

#[cfg(unix)]
#[test]
fn grep_non_recursive_glob_matches_only_direct_children() {
let root = TempDirGuard::new();
write_file(&root.path().join("x.go"), "needle root\n");
write_file(&root.path().join("svc/y.go"), "needle nested\n");

let mut config = base_grep_config(root.path());
config.glob = Some("*.go".to_string());
config.recursive = Some(false);
let result = grep_sync(config, None, task::CancelToken::default())
.expect("non-recursive glob grep should succeed");
let paths: Vec<&str> = result.matches.iter().map(|m| m.path.as_str()).collect();
assert_eq!(paths, ["x.go"]);

let mut config = base_grep_config(root.path());
config.glob = Some("*.go".to_string());
let result = grep_sync(config, None, task::CancelToken::default())
.expect("default glob grep should succeed");
let mut paths: Vec<&str> = result.matches.iter().map(|m| m.path.as_str()).collect();
paths.sort_unstable();
assert_eq!(paths, ["svc/y.go", "x.go"]);
}

#[cfg(unix)]
#[test]
fn grep_files_with_matches_counts_all_searched_files_when_none_match() {
Expand Down
Loading
Loading
0