@oh-my-pi/pi-coding-agent 14.5.3 → 14.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/examples/extensions/plan-mode.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/package.json +7 -7
- package/src/config/prompt-templates.ts +103 -8
- package/src/config/settings-schema.ts +14 -13
- package/src/config/settings.ts +1 -1
- package/src/cursor.ts +4 -4
- package/src/edit/index.ts +111 -109
- package/src/edit/line-hash.ts +33 -3
- package/src/edit/modes/apply-patch.ts +6 -4
- package/src/edit/modes/atom.lark +27 -0
- package/src/edit/modes/atom.ts +1057 -841
- package/src/edit/modes/hashline.ts +9 -10
- package/src/edit/modes/patch.ts +23 -19
- package/src/edit/modes/replace.ts +19 -15
- package/src/edit/renderer.ts +65 -8
- package/src/edit/streaming.ts +47 -77
- package/src/extensibility/extensions/types.ts +11 -11
- package/src/extensibility/hooks/types.ts +6 -6
- package/src/lsp/edits.ts +8 -5
- package/src/lsp/index.ts +4 -4
- package/src/lsp/utils.ts +7 -7
- package/src/mcp/discoverable-tool-metadata.ts +1 -1
- package/src/mcp/manager.ts +3 -3
- package/src/mcp/tool-bridge.ts +4 -4
- package/src/memories/index.ts +1 -1
- package/src/modes/acp/acp-event-mapper.ts +1 -1
- package/src/modes/components/session-observer-overlay.ts +1 -1
- package/src/modes/components/settings-defs.ts +3 -3
- package/src/modes/components/tree-selector.ts +2 -2
- package/src/modes/utils/ui-helpers.ts +31 -7
- package/src/prompts/agents/explore.md +1 -1
- package/src/prompts/agents/librarian.md +2 -2
- package/src/prompts/agents/plan.md +2 -2
- package/src/prompts/agents/reviewer.md +1 -1
- package/src/prompts/agents/task.md +2 -2
- package/src/prompts/system/plan-mode-active.md +1 -1
- package/src/prompts/system/system-prompt.md +34 -31
- package/src/prompts/tools/apply-patch.md +0 -2
- package/src/prompts/tools/atom.md +81 -63
- package/src/prompts/tools/bash.md +7 -4
- package/src/prompts/tools/checkpoint.md +1 -1
- package/src/prompts/tools/find.md +6 -1
- package/src/prompts/tools/hashline.md +10 -11
- package/src/prompts/tools/patch.md +13 -13
- package/src/prompts/tools/read.md +4 -4
- package/src/prompts/tools/replace.md +3 -3
- package/src/prompts/tools/{grep.md → search.md} +4 -4
- package/src/sdk.ts +19 -9
- package/src/session/agent-session.ts +65 -0
- package/src/system-prompt.ts +15 -5
- package/src/task/executor.ts +5 -0
- package/src/task/index.ts +10 -1
- package/src/tools/ast-edit.ts +4 -6
- package/src/tools/ast-grep.ts +4 -6
- package/src/tools/bash.ts +1 -1
- package/src/tools/file-recorder.ts +6 -6
- package/src/tools/find.ts +11 -13
- package/src/tools/index.ts +7 -7
- package/src/tools/path-utils.ts +31 -4
- package/src/tools/read.ts +12 -6
- package/src/tools/renderers.ts +2 -2
- package/src/tools/{grep.ts → search.ts} +32 -40
- package/src/tools/write.ts +8 -4
- package/src/web/search/index.ts +1 -1
- package/src/edit/block.ts +0 -308
- package/src/edit/indent.ts +0 -150
package/src/edit/line-hash.ts
CHANGED
|
@@ -676,18 +676,48 @@ export const HASHLINE_BIGRAM_RE_SRC = `(?:${HASHLINE_BIGRAMS.join("|")})`;
|
|
|
676
676
|
export const HASHLINE_CONTENT_SEPARATOR = "|";
|
|
677
677
|
|
|
678
678
|
const RE_SIGNIFICANT = /[\p{L}\p{N}]/u;
|
|
679
|
+
const RE_STRUCTURAL_STRIP = /[\s{}]/g;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Bigram returned for lines that contain only whitespace and `{`/`}`.
|
|
683
|
+
* Picks the English ordinal suffix for the line number (`1` → `st`,
|
|
684
|
+
* `2` → `nd`, `3` → `rd`, `11`/`12`/`13` → `th`, else `th`) so the
|
|
685
|
+
* line digits + bigram BPE-merge into a single ordinal token (`1st`, `42nd`,
|
|
686
|
+
* `100th`, …). Brace-only lines therefore cost one token for the whole
|
|
687
|
+
* `LINE+ID` anchor instead of two.
|
|
688
|
+
*/
|
|
689
|
+
function structuralBigram(line: number): string {
|
|
690
|
+
const mod100 = line % 100;
|
|
691
|
+
if (mod100 >= 11 && mod100 <= 13) return "th";
|
|
692
|
+
switch (line % 10) {
|
|
693
|
+
case 1:
|
|
694
|
+
return "st";
|
|
695
|
+
case 2:
|
|
696
|
+
return "nd";
|
|
697
|
+
case 3:
|
|
698
|
+
return "rd";
|
|
699
|
+
default:
|
|
700
|
+
return "th";
|
|
701
|
+
}
|
|
702
|
+
}
|
|
679
703
|
|
|
680
704
|
/**
|
|
681
705
|
* Compute a short BPE-bigram hash of a single line.
|
|
682
706
|
*
|
|
683
707
|
* Uses xxHash32 on a trailing-whitespace-trimmed, CR-stripped line, mapped into
|
|
684
|
-
* {@link HASHLINE_BIGRAMS} via modulo.
|
|
685
|
-
*
|
|
686
|
-
*
|
|
708
|
+
* {@link HASHLINE_BIGRAMS} via modulo. Lines that contain only whitespace and
|
|
709
|
+
* `{`/`}` collapse to an ordinal-suffix bigram (see {@link structuralBigram})
|
|
710
|
+
* so brace-only structure shares one merged ordinal token. For other lines
|
|
711
|
+
* containing no alphanumeric characters, the line number is mixed in to reduce hash collisions.
|
|
712
|
+
* The line input should not include a trailing newline.
|
|
687
713
|
*/
|
|
688
714
|
export function computeLineHash(idx: number, line: string): string {
|
|
689
715
|
line = line.replace(/\r/g, "").trimEnd();
|
|
690
716
|
|
|
717
|
+
if (line.replace(RE_STRUCTURAL_STRIP, "").length === 0) {
|
|
718
|
+
return structuralBigram(idx);
|
|
719
|
+
}
|
|
720
|
+
|
|
691
721
|
let seed = 0;
|
|
692
722
|
if (!RE_SIGNIFICANT.test(line)) {
|
|
693
723
|
seed = idx;
|
|
@@ -22,17 +22,19 @@ export const applyPatchSchema = Type.Object({
|
|
|
22
22
|
|
|
23
23
|
export type ApplyPatchParams = Static<typeof applyPatchSchema>;
|
|
24
24
|
|
|
25
|
+
export type ApplyPatchEntry = PatchEditEntry & { path: string };
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* Parse the envelope and lower each hunk to a `PatchEditEntry` so it can
|
|
27
29
|
* be routed through `executePatchSingle`.
|
|
28
30
|
*/
|
|
29
|
-
export function expandApplyPatchToEntries(params: ApplyPatchParams):
|
|
31
|
+
export function expandApplyPatchToEntries(params: ApplyPatchParams): ApplyPatchEntry[] {
|
|
30
32
|
const hunks = parseApplyPatch(params.input);
|
|
31
33
|
if (hunks.length === 0) {
|
|
32
34
|
throw new ApplyPatchError("No files were modified.");
|
|
33
35
|
}
|
|
34
36
|
return hunks.map(
|
|
35
|
-
(h):
|
|
37
|
+
(h): ApplyPatchEntry => ({
|
|
36
38
|
path: h.path,
|
|
37
39
|
op: h.op,
|
|
38
40
|
rename: h.rename,
|
|
@@ -41,10 +43,10 @@ export function expandApplyPatchToEntries(params: ApplyPatchParams): PatchEditEn
|
|
|
41
43
|
);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export function expandApplyPatchToPreviewEntries(params: ApplyPatchParams):
|
|
46
|
+
export function expandApplyPatchToPreviewEntries(params: ApplyPatchParams): ApplyPatchEntry[] {
|
|
45
47
|
const hunks = parseApplyPatchStreaming(params.input);
|
|
46
48
|
return hunks.map(
|
|
47
|
-
(h):
|
|
49
|
+
(h): ApplyPatchEntry => ({
|
|
48
50
|
path: h.path,
|
|
49
51
|
op: h.op,
|
|
50
52
|
rename: h.rename,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
%import common.LF
|
|
2
|
+
|
|
3
|
+
start: file_section+
|
|
4
|
+
|
|
5
|
+
file_section: file_header (line_change | whole_file_change)
|
|
6
|
+
file_header: "---" filename LF
|
|
7
|
+
|
|
8
|
+
filename: /(.+)/
|
|
9
|
+
|
|
10
|
+
line_change: line* mutation_line line*
|
|
11
|
+
line: insert_line | delete_line | set_line | move_line | blank
|
|
12
|
+
mutation_line: insert_line | delete_line | set_line
|
|
13
|
+
|
|
14
|
+
whole_file_change: blank* whole_file_line blank*
|
|
15
|
+
whole_file_line: remove_file | move_file
|
|
16
|
+
remove_file: "!rm" LF
|
|
17
|
+
move_file: "!mv" WS destination LF
|
|
18
|
+
destination: /(?:[^ \t\r\n]+|"[^"\r\n]+"|'[^'\r\n]+')/
|
|
19
|
+
|
|
20
|
+
insert_line: "+" /(.*)/ LF
|
|
21
|
+
delete_line: "-" LID LF
|
|
22
|
+
set_line: LID "=" /(.*)/ LF
|
|
23
|
+
move_line: ("@" LID | "$" | "^") LF
|
|
24
|
+
|
|
25
|
+
LID: /[1-9][0-9]*[a-z]{2}/
|
|
26
|
+
WS: /[ \t]+/
|
|
27
|
+
blank: LF
|