8000 [pull] main from can1357:main by pull[bot] · Pull Request #114 · 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
22 commits
Select commit Hold shift + click to select a range
7e83689
test(task): stop git background maintenance racing the commit fixture…
andrebrait Sep 23, 2026
7352e8f
test(browser): wait for the highlight overlay instead of sampling once
andrebrait Sep 23, 2026
05090f9
test(config-value): assert the descendant is dead instead of racing i…
andrebrait Sep 23, 2026
73a1142
feat: implemented per-account codex cyber access program routing and …
can1357 Sep 23, 2026
cbc3ce1
fix(coding-agent): strip inline data URI images from reader-mode fetc…
Sep 23, 2026
e61ac38
test(config-value): assert the SIGTERM-ignoring descendant is dead in…
andrebrait Sep 23, 2026
8bc86f2
test(task): stop git background maintenance racing the remaining fixt…
andrebrait Sep 23, 2026
63fb0c7
fix(coding-agent): match uppercase and titled data URI images in fetc…
Sep 23, 2026
ba68319
Merge pull request #13006 from can1357/fix/fetch-strip-data-uri-images
H4vC Sep 23, 2026
5c20520
feat(coding-agent): implemented automatic title retry for ambiguous f…
can1357 Sep 23, 2026
63850a2
feat(coding-agent/session): added persistent idle recap journal and G…
can1357 Sep 23, 2026
42b5400
feat: added native Apple Foundation Models integration
can1357 Sep 23, 2026
0f9a978
feat(commands): added toks command for token counting across offline …
can1357 Sep 23, 2026
8a383b9
feat: refactored edit syntax and added insertion capability
can1357 Sep 23, 2026
0bc53be
feat(tui/status-line): included tool examples in status line context …
can1357 Sep 23, 2026
ed91e5a
feat: added Jev native tokenizer support for offline token counting
can1357 Sep 23, 2026
3e61d59
Merge PR #12971: test(task): stop git background maintenance racing t…
H4vC Sep 23, 2026
2b9fad5
test(config-value): update ESCAPE_TIMEOUT_MS docblock for all four or…
Sep 23, 2026
f79556a
Merge PR #12972: test(browser): wait for the highlight overlay instea…
H4vC Sep 23, 2026
01cc999
Merge PR #12973: test(config-value): assert the descendant is dead in…
H4vC Sep 23, 2026
f89a6db
feat: deprecated hub tool in favor of wait and protocol-based interfaces
can1357 Sep 23, 2026
3d3ec7e
feat(pi-edit): added handling for trailing End Patch in sloppy mode
can1357 Sep 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ msvc_cc = use_repo_rule("//bazel/toolchains/msvc:cc.bzl", "msvc_cc_repository")

msvc_cc(name = "msvc_cc")

# Swift toolchain probe for the Apple Foundation Models bridge in pi-natives.
applefm_swift = use_repo_rule("//bazel/toolchains/swift:applefm.bzl", "applefm_swift_repository")

applefm_swift(name = "applefm_swift")

# blake3 assembles MASM .asm for x64 msvc targets; cc-rs resolves `ml64.exe`
# from the build-script PATH on non-windows hosts. Prepend @msvc_cc's wrapper
# dir (bin/ml64.exe → llvm-ml -m64; the dir rides into the sandbox with the
Expand Down
24 changes: 12 additions & 12 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</p>

<p align="center">
Fork of <a href="https://github.com/badlogic/pi-mono">Pi</a> by <a href="https://github.com/mariozechner">@mariozechner</a>
Built by <a href="https://stencil.so">Stencil Labs</a> · Fork of <a href="https://github.com/badlogic/pi-mono">Pi</a> by <a href="https://github.com/mariozechner">@mariozechner</a>
</p>

The most capable agent surface that ships. Continuously tuned by real-world use — complete out of the box, open all the way down.
Expand Down Expand Up @@ -688,11 +688,12 @@ component-local notices for attribution and additional terms.

© 2025 Mario Zechner
© 2025-2026 Can Bölük
© 2026 Stencil Labs, Inc.
© 2026 [Stencil Labs, Inc.](https://stencil.so)

_made for terminals that stay open_

- [omp.sh](https://omp.sh)
- [Stencil Labs](https://stencil.so)
- [GitHub](https://github.com/can1357/oh-my-pi)
- [Changelog](https://github.com/can1357/oh-my-pi/blob/main/packages/coding-agent/CHANGELOG.md)
- [npm](https://www.npmjs.com/package/@oh-my-pi/pi-coding-agent)
Expand Down
1 change: 1 addition & 0 deletions bazel/toolchains/swift/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Repository rules for the Apple Foundation Models Swift bridge (applefm.bzl).
10000
71 changes: 71 additions & 0 deletions bazel/toolchains/swift/applefm.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Repository rule detecting the Swift toolchain for the Apple Foundation Models bridge.

Runs `crates/pi-natives/src/applefm/build-bridge.sh detect` on the host and
materializes the result so the `applefm_bridge` genrule and link step see the
toolchain as an input:

toolchain.txt "<swiftc>\\t<sdk>\\t<fingerprint>", empty when no Swift 6.4+
toolchain with the macOS 27 SDK exists (the bridge is then
built from stub.c)
defs.bzl APPLEFM_LINKOPTS for the bridge's Swift runtime and weak
FoundationModels link (mirrors `applefm_link_args` in
crates/pi-natives/build.rs)

Caching: the fingerprint (compiler version + SDK build) is part of the
genrule's inputs, so action and remote caches never reuse a bridge built by a
different toolchain, and an unchanged toolchain never recompiles. The rule
re-runs when the selection env vars (tracked through `getenv`) or the watched
compiler/SDK files change, and on `bazel fetch --configure`.
"""

_ENV = ["OMP_APPLEFM_SWIFTC", "SDKROOT", "DEVELOPER_DIR"]

_CANDIDATE_SDK_SETTINGS = [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/SDKSettings.plist",
]

def _watch_if_exists(rctx, path):
if path and rctx.path(path).exists:
rctx.watch(path)

def _applefm_swift_repository_impl(rctx):
line = ""
if rctx.os.name.lower().startswith("mac"):
environment = {}
for name in _ENV:
value = rctx.getenv(name)
if value:
environment[name] = value
script = rctx.path(Label("//crates/pi-natives:src/applefm/build-bridge.sh"))
result = rctx.execute(["/bin/sh", str(script), "detect"], environment = environment)
if result.return_code == 0:
line = result.stdout.strip()
selected = rctx.execute(["/usr/bin/xcrun", "--sdk", "macosx", "--show-sdk-path"])
for settings in _CANDIDATE_SDK_SETTINGS + [selected.stdout.strip() + "/SDKSettings.plist"]:
_watch_if_exists(rctx, settings)

linkopts = []
if line:
swiftc, sdk, _fingerprint = line.split("\t")
_watch_if_exists(rctx, swiftc)
_watch_if_exists(rctx, sdk + "/SDKSettings.plist")
toolchain_lib = str(rctx.path(swiftc).dirname.dirname) + "/lib/swift/macosx"
linkopts = [
"-L" + sdk + "/usr/lib/swift",
"-L" + toolchain_lib,
"-Wl,-rpath,/usr/lib/swift",
"-Wl,-weak_library," + sdk + "/System/Library/Frameworks/FoundationModels.framework/FoundationModels.tbd",
]

rctx.file("toolchain.txt", line + ("\n" if line else ""))
rctx.file("defs.bzl", "APPLEFM_LINKOPTS = {}\n".format(repr(linkopts)))
rctx.file("BUILD.bazel", """\
# Generated by //bazel/toolchains/swift:applefm.bzl.
exports_files(["toolchain.txt"], visibility = ["//visibility:public"])
""")

applefm_swift_repository = repository_rule(
implementation = _applefm_swift_repository_impl,
configure = True,
doc = "Detects the Swift toolchain used to build the Apple Foundation Models bridge.",
)
42 changes: 22 additions & 20 deletions crates/pi-edit/grammars/sloppy.lark
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
// Canonical grammar for the sloppy edit payload (constrained decoding).
//
// Shape:
// *** SM:EDIT relative/path.ts open edits in that file
// *** SM:EDIT relative/path.ts all
// apply every match
// *** SM:EDIT continue with the same file
// *** SM:FIND current-text body; … elides gaps
// *** SM:PUT final replacement body; empty deletes
// *** SM:AFTER lines inserted after the match
// *** Edit File: relative/path.ts open edits in that file
// *** Edit File: relative/path.ts all
// apply every match
// *** Edit File: continue with the same file
// *** Find current-text body; … elides gaps
// *** Replace final replacement body; empty deletes
// *** Insert Before lines inserted before the match
// *** Insert After lines inserted after the match
// Headers are standalone and case-insensitive. A body continues until the
// next recognized header or EOF; no closing delimiter is used. AFTER treats
// foreign Begin/End Patch rows as literal insertion text.
// next recognized header or EOF; no closing delimiter is used. Insert bodies
// treat foreign Begin/End Patch rows as literal insertion text, except a
// trailing End Patch, which the parser drops as a wrapper closer.
start: begin_patch? edit+

begin_patch: BEGIN_PATCH LF

edit: edit_open pair+
edit_open: EDIT_HEADER LF
pair: find (put | after)
pair: find (replace | insert)
find: FIND_HEADER LF body_line*
put: PUT_HEADER action_body?
after: AFTER_HEADER after_body?
replace: REPLACE_HEADER action_body?
insert: INSERT_HEADER insert_body?
action_body: LF body_line* BODY_TEXT?
after_body: LF after_body_line* AFTER_TEXT?
insert_body: LF insert_body_line* INSERT_TEXT?

body_line: BODY_TEXT LF | LF
after_body_line: AFTER_TEXT LF | LF
insert_body_line: INSERT_TEXT LF | LF

BEGIN_PATCH: /[ \t]*\*{3}[ \t]+(?i:Begin[ \t]+Patch)[ \t]*/
END_PATCH: /[ \t]*\*{3}[ \t]+(?i:End[ \t]+Patch)[ \t]*/
EDIT_HEADER: /[ \t]*\*{3}[ \t]+(?i:SM:EDIT)(?:[ \t]+[^\r\n]*)?/
FIND_HEADER: /[ \t]*\*{3}[ \t]+(?i:SM:FIND)[ \t]*/
PUT_HEADER: /[ \t]*\*{3}[ \t]+(?i:SM:PUT)[ \t]*/
AFTER_HEADER: /[ \t]*\*{3}[ \t]+(?i:SM:AFTER)[ \t]*/
EDIT_HEADER: /[ \t]*\*{3}[ \t]+(?i:Edit[ \t]+File:)(?:[ \t]+[^\r\n]*)?/
FIND_HEADER: /[ \t]*\*{3}[ \t]+(?i:Find)[ \t]*/
REPLACE_HEADER: /[ \t]*\*{3}[ \t]+(?i:Replace)[ \t]*/
INSERT_HEADER: /[ \t]*\*{3}[ \t]+(?i:Insert[ \t]+(?:Before|After))[ \t]*/

// LLGuidance supports terminal intersection/complement, not priorities or lookarounds.
BODY_TEXT: /[^\r\n]+/ & ~(EDIT_HEADER | FIND_HEADER | PUT_HEADER | AFTER_HEADER | BEGIN_PATCH | END_PATCH)
AFTER_TEXT: /[^\r\n]+/ & ~(EDIT_HEADER | FIND_HEADER | PUT_HEADER | AFTER_HEADER)
BODY_TEXT: /[^\r\n]+/ & ~(EDIT_HEADER | FIND_HEADER | REPLACE_HEADER | INSERT_HEADER | BEGIN_PATCH | END_PATCH)
INSERT_TEXT: /[^\r\n]+/ & ~(EDIT_HEADER | FIND_HEADER | REPLACE_HEADER | INSERT_HEADER)

%import common.LF
136 changes: 16 additions & 120 deletions crates/pi-edit/prompts/hashline.md
Original file line number Diff line number Diff line change
@@ -1,135 +1,31 @@
Line-anchored patch language: name original lines/gaps to replace, insert, cut, or paste; then give new content. `:` headers take `+` body rows; colonless paste `PUT`, `CUT`, `REM`, `MV` take none.

<headers>
Section: `[PATH#TAG]`; `TAG`: 4-hex snapshot from latest `read`/`search`, REQUIRED each section. New files: `write`; hashline edits existing files only.
</headers>
Hashline patches existing files; new files: `write`. Each file: `[PATH#TAG]`, `TAG` required 4-hex snapshot from latest `read`/`search`. Numbers: original `LINE:TEXT`, never hunk-shifted.

<ops>
`PUT N.=M:`: replace original inclusive lines N–M with body.
`PUT N*:`: replace syntactic block beginning N; closing line resolved.
`PUT <N:` insert body rows before line N (`PUT <1:` = file head).
`PUT >N:` insert body rows after line N (`PUT >$:` = file tail).
`PUT >N*:`: insert after block N's end, at sibling depth. Append inside block: `PUT >M:`.
`PUT <N @name` / `PUT >N @name` paste register `@name` at the gap before/after line N; omit `@name` for the anonymous register.
`PUT N.=M @name` / `PUT N* @name` paste `@name` over the range / resolved block; `@name` required here.
`CUT N.=M` / `CUT N*`: delete and capture inclusive lines N–M / block N; anonymous or given `@name`.
`REM`: delete section file. `MV DEST`: move/rename (quote paths with spaces); prior edits apply to source, final content to `DEST`.
Single line: `PUT N.=N:` / `CUT N.=N`. Ranges name original inclusive touched lines; body length irrelevant.
`PUT N.=M:` replace inclusive N–M with `+` body (`N.=N` for one line); `PUT N*:` replace block N.
`PUT <N:`/`PUT >N:` insert before/after N (`<1` head, `>$` tail). `PUT >N*:` insert after block N at sibling depth; inside, use `PUT >M:` at closer.
`CUT N.=M`/`CUT N*` delete and capture, optionally as `@name`.
`PUT <N @name`/`PUT >N @name` paste at gap (omit name for anonymous CUT); `PUT N.=M @name`/`PUT N* @name` paste over range/block (name REQUIRED). Register pastes have NO body; named registers persist across calls.
`REM` delete file; `MV DEST` rename after prior edits (quote spaced paths).
</ops>

<body-rows>
Only below `:` headers. Row: verbatim `+TEXT` (leading whitespace preserved); `+`: blank. NEVER `-old`, bare, or context rows: range deletes; body is final content. Keep line: exclude it from every range. Literal initial `-`/`+`: `- item` → `+- item`; `+ item` → `++ item`.
</body-rows>

<rules>
- Numbers and `#TAG`: latest `read`/`search` `LINE:TEXT`; numbers are original, never shifted by hunks.
- Each edit renumbers and changes `#TAG` → next numbers from edit response or fresh `read`.
- Touch displayed lines only; undisplayed hunks REJECTED. Far from read window: re-`read`; confirm construct.
- Elisions UNSEEN: `…`, `..`, collapsed `N-M:` rows. NEVER hunk in/across one; `read` first.
- NEVER start/end range mid-expression or mid-block.
- Ranges: changed lines only; NEVER widen over keepers. Non-adjacent changes: separate hunks.
- Whole construct: `PUT N*:`; internal lines: `PUT N.=M:`.
- `PUT N*:` resolves exactly node N. Leading decorators/attributes/doc-comments are separate nodes: point N at first decorator to include both. Standalone line-comments never swept: use `PUT N.=M:`.
- Block ops: opening line of multi-line construct, NEVER closer, last line, bare inner statement. One statement: plain `PUT N.=N:` / `CUT N.=N` / `PUT >N:`. At closer: `PUT >M:`.
- Markdown headings are block openers. Block op on `##`/`###`: whole section through deeper headings to next same/higher heading. After section `PUT >N*:`: end body with blank line to separate next heading.
- Pure addition: `PUT <N:` / `PUT >N:`, NEVER widened `PUT N.=M:`.
- Move: `CUT`+`PUT`; `CUT 5.=9 @fn` → `@fn`, `PUT >40 @fn` pastes. Single call-local move: unlabeled `CUT` + `PUT >40`. Named registers persist across edit calls.
- NEVER format/restyle with this tool; run project formatter.
- `:` ops only: body rows `+TEXT` verbatim incl. indent; lone `+` blank. Literal `- item`/`+ item` → `+- item`/`++ item`. NEVER `-`/bare context. Body length independent of range; delete with CUT, not empty PUT.
- Touch displayed changed lines only; `…`, `..`, collapsed `N-M:` and out-of-window lines UNSEEN. Re-read first. Tight ranges: split nonadjacent changes; NEVER include keepers or start/end mid-expression/block. Pure addition uses gap PUT.
- `*` requires multi-line opener, NEVER closer/last/inner statement; use range/gap for one statement. Anchor first decorator/attribute/doc-comment to include it; standalone comments need explicit range.
- Markdown heading blocks run through deeper headings until next same/higher; after section `PUT >N*:`, end body with blank line.
- NEVER restyle unrelated code. After EVERY edit tag/numbers change: use edit response or fresh `read`; stale tag/surprise → STOP, re-read.
</rules>

<example>
`read` output shape:
```
[greet.py#A1B2]
1:def greet(name):
2: msg = "Hello, " + name
3: print(msg)
4:greet("world")
```

Edit, then move:
```
[greet.py#A1B2]
PUT 1.=3:
PUT 1*:
+@cache
+def greet(name):
+ print(f"Hi, {name}")
MV lib/greet.py
```

Markdown bullets — file receives `- task`:
```
[PLAN.md#A1B2]
+ print(name)
[PLAN.md#3C4D]
PUT >2:
+- task
+ - nested task
```

Move `greet` to sibling file via named register; flows across sections:
```
[greet.py#A1B2]
CUT 1* @fn
[other.py#3C4D]
PUT <1 @fn
```

`PUT 1*:` resolves lines 1–3 (`def` through `print(msg)`); line 4 separate, remains:
```
[greet.py#A1B2]
PUT 1*:
+def greet(name):
+ print(f"Hello, {name}")
```

Decorator/doc-comment separate block: point N at decorator to include both; anchoring `def` line 2 orphans `@cache`:
```
[svc.py#C3D4]
PUT 1*:
+@cache
+def load(key):
+ return store[key]
```
Cross-file move: `CUT 1* @fn` in source, then `PUT <1 @fn` in destination section.
</example>

<anti-patterns>
# WRONG — empty `PUT` to delete. RIGHT: `CUT 4.=4`
PUT 4.=4:

# WRONG — range sized to the post-edit content. RIGHT: `PUT 1.=1:` (body length irrelevant)
PUT 1.=2:
+def greet(name):

# WRONG — `-` rows / bare context lines do not exist; the range deletes, the body is only new content.
PUT 3.=3:
msg = "Hello, " + name
- print(msg)
+ return msg
# RIGHT
PUT 3.=3:
+ return msg

# WRONG — pure insertion as a widened `PUT`: retyped keepers get dropped (here line 4).
PUT 2.=4:
+ msg = "Hello, " + name
+ extra = compute(name)
+ print(msg)
# RIGHT — touch nothing you keep.
PUT >2:
+ extra = compute(name)

# WRONG — `PUT >N*:` anchored on the closing delimiter / last visible line. RIGHT: plain `PUT >M:`
PUT >3*:
+after()
# RIGHT
PUT >3:
+after()

# WRONG — body rows under register PUT; register pastes take no body. RIGHT: bodyless `PUT >20 @fn`.
PUT >20 @fn:
+function f() {}
</anti-patterns>

<critical>
1. RE-GROUND AFTER EVERY EDIT: edits renumber and change `#TAG`; take next numbers from edit response or fresh `read`. Stale tag/surprise: STOP; re-`read`.
2. RANGES TIGHT: changed lines only. Whole construct: `PUT N*:`.
3. BODY FINAL CONTENT: every row starts `+`; Markdown bullet: `+- item`, not `- item`.
</critical>
Loading
Loading
0