@jx-grxf/patchpilot 0.2.1 → 0.3.1-beta

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 (69) hide show
  1. package/README.md +70 -10
  2. package/SECURITY.md +20 -0
  3. package/dist/cli.js +52 -3
  4. package/dist/cli.js.map +1 -1
  5. package/dist/core/agent.d.ts +6 -2
  6. package/dist/core/agent.js +197 -27
  7. package/dist/core/agent.js.map +1 -1
  8. package/dist/core/codex.js +1 -1
  9. package/dist/core/codex.js.map +1 -1
  10. package/dist/core/gemini.js +8 -21
  11. package/dist/core/gemini.js.map +1 -1
  12. package/dist/core/http.d.ts +6 -0
  13. package/dist/core/http.js +45 -0
  14. package/dist/core/http.js.map +1 -0
  15. package/dist/core/json.js +9 -0
  16. package/dist/core/json.js.map +1 -1
  17. package/dist/core/nvidia.js +9 -2
  18. package/dist/core/nvidia.js.map +1 -1
  19. package/dist/core/ollama.js +8 -1
  20. package/dist/core/ollama.js.map +1 -1
  21. package/dist/core/openrouter.js +13 -8
  22. package/dist/core/openrouter.js.map +1 -1
  23. package/dist/core/reasoning.d.ts +12 -0
  24. package/dist/core/reasoning.js +108 -0
  25. package/dist/core/reasoning.js.map +1 -0
  26. package/dist/core/session.d.ts +31 -0
  27. package/dist/core/session.js +154 -0
  28. package/dist/core/session.js.map +1 -0
  29. package/dist/core/types.d.ts +103 -2
  30. package/dist/core/workspace.d.ts +17 -1
  31. package/dist/core/workspace.js +498 -16
  32. package/dist/core/workspace.js.map +1 -1
  33. package/dist/tui/App.js +368 -109
  34. package/dist/tui/App.js.map +1 -1
  35. package/dist/tui/commands.js +45 -4
  36. package/dist/tui/commands.js.map +1 -1
  37. package/dist/tui/components/Composer.js +1 -1
  38. package/dist/tui/components/Composer.js.map +1 -1
  39. package/dist/tui/components/Header.d.ts +2 -2
  40. package/dist/tui/components/Header.js +32 -53
  41. package/dist/tui/components/Header.js.map +1 -1
  42. package/dist/tui/components/OnboardingPanel.d.ts +5 -0
  43. package/dist/tui/components/OnboardingPanel.js +11 -13
  44. package/dist/tui/components/OnboardingPanel.js.map +1 -1
  45. package/dist/tui/components/Sidebar.d.ts +6 -1
  46. package/dist/tui/components/Sidebar.js +33 -7
  47. package/dist/tui/components/Sidebar.js.map +1 -1
  48. package/dist/tui/components/Transcript.js +57 -8
  49. package/dist/tui/components/Transcript.js.map +1 -1
  50. package/dist/tui/hosts.js +7 -1
  51. package/dist/tui/hosts.js.map +1 -1
  52. package/dist/tui/modelSelection.d.ts +1 -0
  53. package/dist/tui/modelSelection.js +29 -0
  54. package/dist/tui/modelSelection.js.map +1 -0
  55. package/dist/tui/modes.d.ts +10 -0
  56. package/dist/tui/modes.js +37 -0
  57. package/dist/tui/modes.js.map +1 -0
  58. package/dist/tui/types.d.ts +13 -3
  59. package/dist/tui/types.js.map +1 -1
  60. package/docs/releases/v0.1.0.md +26 -0
  61. package/docs/releases/v0.2.0.md +21 -0
  62. package/docs/releases/v0.2.1.md +26 -0
  63. package/docs/releases/v0.3.0.md +26 -0
  64. package/docs/releases/v0.3.1-beta.md +19 -0
  65. package/docs/showcase/patchpilot-showcase.svg +83 -38
  66. package/package.json +5 -2
  67. package/dist/tui/inputRouting.d.ts +0 -8
  68. package/dist/tui/inputRouting.js +0 -94
  69. package/dist/tui/inputRouting.js.map +0 -1
@@ -5,11 +5,12 @@ export type ChatMessage = {
5
5
  };
6
6
  export type ModelProvider = "ollama" | "gemini" | "codex" | "openrouter" | "nvidia";
7
7
  export type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
8
+ export type ProviderReasoningEffort = ReasoningEffort | "none";
8
9
  export type ModelChatOptions = {
9
10
  model: string;
10
11
  messages: ChatMessage[];
11
12
  formatJson?: boolean;
12
- reasoningEffort?: ReasoningEffort;
13
+ reasoningEffort?: ProviderReasoningEffort;
13
14
  signal?: AbortSignal;
14
15
  };
15
16
  export type ModelChatResult = {
@@ -20,11 +21,33 @@ export type ModelClient = {
20
21
  chat(options: ModelChatOptions): Promise<ModelChatResult>;
21
22
  listModels(): Promise<string[]>;
22
23
  };
23
- export type AgentToolName = "list_files" | "read_file" | "search_text" | "inspect_document" | "write_file" | "run_shell";
24
+ export type AgentWorkState = "idle" | "inspecting" | "planning" | "reading" | "editing" | "verifying" | "waiting_approval" | "done" | "error";
25
+ export type AgentToolName = "list_files" | "read_file" | "read_range" | "file_info" | "search_text" | "inspect_document" | "git_status" | "git_diff" | "list_changed_files" | "list_scripts" | "write_file" | "apply_patch" | "run_script" | "run_tests" | "run_shell";
24
26
  export type AgentToolCall = {
25
27
  name: AgentToolName;
26
28
  arguments: Record<string, unknown>;
27
29
  };
30
+ export type ToolRisk = "low" | "medium" | "high";
31
+ export type ToolSideEffect = "none" | "write" | "shell";
32
+ export type ToolPermission = "none" | "write" | "shell";
33
+ export type ToolCategory = "read" | "search" | "write" | "shell" | "git" | "test" | "document";
34
+ export type ToolSpec = {
35
+ name: AgentToolName;
36
+ description: string;
37
+ risk: ToolRisk;
38
+ sideEffects: ToolSideEffect;
39
+ permission: ToolPermission;
40
+ category: ToolCategory;
41
+ };
42
+ export type PermissionDecision = "allow_once" | "allow_session" | "deny";
43
+ export type ApprovalRequest = {
44
+ id: string;
45
+ tool: AgentToolName;
46
+ permission: Exclude<ToolPermission, "none">;
47
+ risk: ToolRisk;
48
+ preview: string;
49
+ arguments: Record<string, unknown>;
50
+ };
28
51
  export type AgentResponse = {
29
52
  action: "tools";
30
53
  message: string;
@@ -37,33 +60,111 @@ export type SubagentRole = "planner" | "reviewer" | "explorer";
37
60
  export type AgentEvent = {
38
61
  type: "status";
39
62
  message: string;
63
+ workState: AgentWorkState;
40
64
  } | {
41
65
  type: "metrics";
42
66
  metrics: ModelTelemetry;
67
+ workState: AgentWorkState;
43
68
  } | {
44
69
  type: "assistant";
45
70
  message: string;
71
+ workState: AgentWorkState;
46
72
  } | {
47
73
  type: "subagent";
48
74
  role: SubagentRole;
49
75
  message: string;
50
76
  metrics: ModelTelemetry;
77
+ workState: AgentWorkState;
51
78
  } | {
52
79
  type: "tool";
53
80
  name: AgentToolName;
54
81
  summary: string;
55
82
  ok: boolean;
83
+ workState: AgentWorkState;
84
+ toolCallId?: string;
85
+ category?: ToolCategory;
86
+ preview?: string;
87
+ metadata?: Record<string, unknown>;
88
+ } | {
89
+ type: "approval";
90
+ request: ApprovalRequest;
91
+ decision: PermissionDecision;
92
+ workState: AgentWorkState;
56
93
  } | {
57
94
  type: "final";
58
95
  message: string;
96
+ workState: AgentWorkState;
59
97
  } | {
60
98
  type: "error";
61
99
  message: string;
100
+ workState: AgentWorkState;
62
101
  };
63
102
  export type ToolResult = {
64
103
  ok: boolean;
65
104
  summary: string;
66
105
  content: string;
106
+ tool?: AgentToolName;
107
+ category?: ToolCategory;
108
+ preview?: string;
109
+ approval?: {
110
+ request: ApprovalRequest;
111
+ decision: PermissionDecision;
112
+ };
113
+ metadata?: Record<string, unknown>;
114
+ };
115
+ export type SessionEvent = {
116
+ type: "session.created";
117
+ sessionId: string;
118
+ workspace: string;
119
+ createdAt: string;
120
+ } | {
121
+ type: "run.started";
122
+ runId: string;
123
+ task: string;
124
+ provider: ModelProvider;
125
+ model: string;
126
+ startedAt: string;
127
+ } | {
128
+ type: "model.request";
129
+ runId: string;
130
+ workState: AgentWorkState;
131
+ provider: ModelProvider;
132
+ model: string;
133
+ step: number;
134
+ createdAt: string;
135
+ } | {
136
+ type: "tool.requested";
137
+ runId: string;
138
+ toolCallId: string;
139
+ tool: AgentToolName;
140
+ arguments: Record<string, unknown>;
141
+ workState: AgentWorkState;
142
+ createdAt: string;
143
+ } | {
144
+ type: "approval.requested";
145
+ runId: string;
146
+ request: ApprovalRequest;
147
+ decision: PermissionDecision;
148
+ createdAt: string;
149
+ } | {
150
+ type: "tool.completed";
151
+ runId: string;
152
+ toolCallId: string;
153
+ tool: AgentToolName;
154
+ ok: boolean;
155
+ summary: string;
156
+ workState: AgentWorkState;
157
+ createdAt: string;
158
+ } | {
159
+ type: "run.completed";
160
+ runId: string;
161
+ message: string;
162
+ completedAt: string;
163
+ } | {
164
+ type: "run.failed";
165
+ runId: string;
166
+ message: string;
167
+ failedAt: string;
67
168
  };
68
169
  export type ModelTelemetry = {
69
170
  promptTokens: number;
@@ -1,11 +1,14 @@
1
- import type { AgentToolCall, ToolResult } from "./types.js";
1
+ import type { AgentToolCall, AgentToolName, ApprovalRequest, PermissionDecision, ToolResult, ToolSpec } from "./types.js";
2
2
  export type WorkspaceToolsOptions = {
3
3
  root: string;
4
4
  allowWrite: boolean;
5
5
  allowShell: boolean;
6
6
  timeoutMs?: number;
7
7
  signal?: AbortSignal;
8
+ approvalHandler?: (request: ApprovalRequest) => Promise<PermissionDecision>;
8
9
  };
10
+ export declare const toolSpecs: Record<AgentToolName, ToolSpec>;
11
+ export declare function getToolSpec(name: AgentToolName): ToolSpec;
9
12
  export declare class WorkspaceTools {
10
13
  readonly root: string;
11
14
  private readonly rootRealPath;
@@ -13,16 +16,29 @@ export declare class WorkspaceTools {
13
16
  private readonly allowShell;
14
17
  private readonly timeoutMs;
15
18
  private readonly signal?;
19
+ private readonly approvalHandler?;
20
+ private readonly sessionApprovals;
16
21
  constructor(options: WorkspaceToolsOptions);
17
22
  execute(call: AgentToolCall): Promise<ToolResult>;
18
23
  resolveInsideWorkspace(requestedPath: string): string;
19
24
  normalizeWorkspaceRelativePath(requestedPath: string): string;
20
25
  private listFiles;
21
26
  private readFile;
27
+ private readRange;
28
+ private fileInfo;
22
29
  private inspectDocument;
23
30
  private searchText;
24
31
  private writeFile;
32
+ private gitStatus;
33
+ private gitDiff;
34
+ private listChangedFiles;
35
+ private listScripts;
36
+ private applyPatch;
37
+ private runScript;
38
+ private runTests;
25
39
  private runShell;
40
+ private readPackageScripts;
41
+ private requestApproval;
26
42
  private resolveReadPath;
27
43
  private resolveWritePath;
28
44
  }