@oh-my-pi/pi-coding-agent 14.9.1 → 14.9.3

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/package.json +7 -7
  3. package/scripts/format-prompts.ts +3 -3
  4. package/src/config/prompt-templates.ts +0 -5
  5. package/src/config/settings-schema.ts +38 -0
  6. package/src/eval/eval.lark +10 -31
  7. package/src/eval/index.ts +1 -0
  8. package/src/eval/parse.ts +156 -255
  9. package/src/eval/sniff.ts +28 -0
  10. package/src/export/html/template.css +38 -0
  11. package/src/export/html/template.generated.ts +1 -1
  12. package/src/export/html/template.js +209 -15
  13. package/src/extensibility/extensions/runner.ts +173 -177
  14. package/src/hashline/apply.ts +8 -24
  15. package/src/hashline/constants.ts +20 -0
  16. package/src/hashline/execute.ts +0 -1
  17. package/src/hashline/grammar.lark +16 -27
  18. package/src/hashline/hash.ts +4 -34
  19. package/src/hashline/input.ts +16 -2
  20. package/src/hashline/parser.ts +12 -40
  21. package/src/hashline/types.ts +1 -2
  22. package/src/internal-urls/agent-protocol.ts +1 -0
  23. package/src/internal-urls/artifact-protocol.ts +1 -0
  24. package/src/internal-urls/docs-index.generated.ts +2 -1
  25. package/src/internal-urls/jobs-protocol.ts +1 -0
  26. package/src/internal-urls/local-protocol.ts +1 -0
  27. package/src/internal-urls/mcp-protocol.ts +1 -0
  28. package/src/internal-urls/memory-protocol.ts +1 -0
  29. package/src/internal-urls/pi-protocol.ts +1 -0
  30. package/src/internal-urls/router.ts +2 -1
  31. package/src/internal-urls/rule-protocol.ts +1 -0
  32. package/src/internal-urls/skill-protocol.ts +1 -0
  33. package/src/internal-urls/types.ts +18 -2
  34. package/src/mcp/transports/http.ts +49 -47
  35. package/src/prompts/system/custom-system-prompt.md +0 -2
  36. package/src/prompts/system/now-prompt.md +7 -0
  37. package/src/prompts/system/project-prompt.md +2 -0
  38. package/src/prompts/system/subagent-system-prompt.md +18 -9
  39. package/src/prompts/system/subagent-user-prompt.md +1 -10
  40. package/src/prompts/system/system-prompt.md +154 -233
  41. package/src/prompts/tools/bash.md +0 -24
  42. package/src/prompts/tools/eval.md +26 -13
  43. package/src/prompts/tools/hashline.md +1 -4
  44. package/src/sdk.ts +12 -22
  45. package/src/session/agent-session.ts +49 -17
  46. package/src/system-prompt.ts +38 -104
  47. package/src/task/executor.ts +15 -9
  48. package/src/task/index.ts +38 -33
  49. package/src/task/render.ts +4 -2
  50. package/src/tools/bash.ts +15 -41
  51. package/src/tools/eval.ts +13 -36
  52. package/src/tools/index.ts +0 -3
  53. package/src/tools/path-utils.ts +21 -1
  54. package/src/tools/read.ts +71 -49
  55. package/src/tools/search.ts +13 -1
  56. package/src/utils/file-display-mode.ts +11 -5
  57. package/src/workspace-tree.ts +210 -410
  58. package/src/task/template.ts +0 -47
  59. package/src/tools/bash-normalize.ts +0 -107
@@ -1,47 +0,0 @@
1
- import { prompt } from "@oh-my-pi/pi-utils";
2
- import subagentUserPromptTemplate from "../prompts/system/subagent-user-prompt.md" with { type: "text" };
3
- import { getTaskSimpleModeCapabilities, type TaskSimpleMode } from "./simple-mode";
4
- import type { TaskItem } from "./types";
5
-
6
- interface RenderResult {
7
- /** Full task text sent to the subagent */
8
- task: string;
9
- /** Raw per-task assignment text, without prompt template boilerplate */
10
- assignment: string;
11
- id: string;
12
- description: string;
13
- }
14
-
15
- /**
16
- * Build the full task text from shared context and per-task assignment.
17
- *
18
- * If context is provided, it is prepended with a separator.
19
- */
20
- export function renderTemplate(
21
- context: string | undefined,
22
- task: TaskItem,
23
- simpleMode: TaskSimpleMode = "default",
24
- ): RenderResult {
25
- let { id, description, assignment } = task;
26
- assignment = assignment.trim();
27
- const { contextEnabled } = getTaskSimpleModeCapabilities(simpleMode);
28
- context = contextEnabled ? context?.trim() : undefined;
29
-
30
- if (!context || !assignment) {
31
- if (simpleMode === "independent" && assignment) {
32
- return {
33
- task: prompt.render(subagentUserPromptTemplate, { assignment, independentMode: true }),
34
- assignment,
35
- id,
36
- description,
37
- };
38
- }
39
- return { task: assignment || context!, assignment: assignment || context!, id, description };
40
- }
41
- return {
42
- task: prompt.render(subagentUserPromptTemplate, { context, assignment, independentMode: false }),
43
- assignment,
44
- id,
45
- description,
46
- };
47
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * Bash command normalizer - extracts patterns that are better handled natively.
3
- *
4
- * Detects and extracts:
5
- * - `| head -n N` / `| head -N` - extracted to headLines
6
- * - `| tail -n N` / `| tail -N` - extracted to tailLines
7
- */
8
-
9
- export interface NormalizedCommand {
10
- /** Cleaned command with patterns stripped */
11
- command: string;
12
- /** Extracted head line count, if any */
13
- headLines?: number;
14
- /** Extracted tail line count, if any */
15
- tailLines?: number;
16
- }
17
-
18
- /**
19
- * Pattern to match trailing pipe to head/tail.
20
- * Captures: full match, command (head/tail), line count
21
- *
22
- * Matches:
23
- * - `| head -n 50`
24
- * - `| head -50`
25
- * - `| tail -n 100`
26
- * - `| tail -100`
27
- *
28
- * Does NOT match head/tail with other flags or without line count.
29
- */
30
- const TRAILING_HEAD_TAIL_PATTERN = /\|\s*(head|tail)\s+(?:-n\s*(\d+)|(-\d+))\s*$/;
31
-
32
- /**
33
- * Normalize a bash command by stripping patterns better handled natively.
34
- *
35
- * Extracts `| head -n N` and `| tail -n N` suffixes into separate fields
36
- * so they can be applied post-execution without breaking streaming.
37
- *
38
- * Strips `2>&1` since we already merge stdout/stderr.
39
- */
40
- export function normalizeBashCommand(command: string): NormalizedCommand {
41
- let normalized = command;
42
- let headLines: number | undefined;
43
- let tailLines: number | undefined;
44
-
45
- // Extract trailing head/tail
46
- const match = normalized.match(TRAILING_HEAD_TAIL_PATTERN);
47
- if (match) {
48
- const [fullMatch, cmd, nValue, dashValue] = match;
49
- const lineCount = nValue ? Number.parseInt(nValue, 10) : Number.parseInt(dashValue.slice(1), 10);
50
-
51
- if (cmd === "head") {
52
- headLines = lineCount;
53
- } else {
54
- tailLines = lineCount;
55
- }
56
-
57
- normalized = normalized.slice(0, -fullMatch.length);
58
- }
59
-
60
- // Preserve internal whitespace (important for heredocs / indentation-sensitive scripts)
61
- normalized = normalized.trim();
62
-
63
- return {
64
- command: normalized,
65
- headLines,
66
- tailLines,
67
- };
68
- }
69
-
70
- /**
71
- * Apply head/tail limits to output text.
72
- *
73
- * If both head and tail are specified, head is applied first (take first N lines),
74
- * then tail is applied (take last M lines of that).
75
- */
76
- export function applyHeadTail(
77
- text: string,
78
- headLines?: number,
79
- tailLines?: number,
80
- ): { text: string; applied: boolean; headApplied?: number; tailApplied?: number } {
81
- if (!headLines && !tailLines) {
82
- return { text, applied: false };
83
- }
84
-
85
- let lines = text.split("\n");
86
- let headApplied: number | undefined;
87
- let tailApplied: number | undefined;
88
-
89
- // Apply head first (keep first N lines)
90
- if (headLines !== undefined && headLines > 0 && lines.length > headLines) {
91
- lines = lines.slice(0, headLines);
92
- headApplied = headLines;
93
- }
94
-
95
- // Then apply tail (keep last N lines)
96
- if (tailLines !== undefined && tailLines > 0 && lines.length > tailLines) {
97
- lines = lines.slice(-tailLines);
98
- tailApplied = tailLines;
99
- }
100
-
101
- return {
102
- text: lines.join("\n"),
103
- applied: headApplied !== undefined || tailApplied !== undefined,
104
- headApplied,
105
- tailApplied,
106
- };
107
- }