@getpochi/cli 0.5.96 → 0.5.97
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/dist/cli.js +340 -253
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -386409,13 +386409,11 @@ var zod_default = exports_external2;
|
|
|
386409
386409
|
|
|
386410
386410
|
// ../tools/src/constants.ts
|
|
386411
386411
|
var EditFileResultPrompt = `You may see the following fields in the result:
|
|
386412
|
-
- userEdits: If the user makes any edits, this field will contain a diff between your edit and their changes.
|
|
386413
386412
|
- autoFormattingEdits: If the auto-formatter makes any changes, this field will contain a diff against the file content after your edits and any user edits have been applied.
|
|
386414
386413
|
- newProblems: If any new problems are found after the edit, this field will contain information about them.
|
|
386415
386414
|
`.trim();
|
|
386416
386415
|
var EditFileOutputSchema = exports_external2.object({
|
|
386417
386416
|
success: exports_external2.boolean().describe("Indicates whether the file was successfully written."),
|
|
386418
|
-
userEdits: exports_external2.string().describe("The user's edits to the file, only present if the file was edited by the user.").optional(),
|
|
386419
386417
|
autoFormattingEdits: exports_external2.string().describe("The auto-formatting edits to the file, only present if the auto formatter made changes.").optional(),
|
|
386420
386418
|
newProblems: exports_external2.string().optional().describe("The new problems found after writing the file, if any."),
|
|
386421
386419
|
_meta: exports_external2.object({
|
|
@@ -386513,8 +386511,9 @@ var attemptCompletionSchema = exports_external2.object({
|
|
|
386513
386511
|
result: exports_external2.string().describe("The result of the task. Formulate this result in a way that is final and does not require further input from the user.")
|
|
386514
386512
|
});
|
|
386515
386513
|
var toolDef3 = {
|
|
386516
|
-
description: `
|
|
386514
|
+
description: `Once you've received the results of tool uses and can confirm that the task is complete, use this tool to present the result of your work to the user.
|
|
386517
386515
|
|
|
386516
|
+
You MUST NOT generate any text before this tool call. All conclusion text must be included within the result parameter of the attemptCompletion tool.
|
|
386518
386517
|
Never use this tool with a question or request to engage in further conversation! Formulate the end of your result in a way that is final and does not require further input from the user.
|
|
386519
386518
|
`.trim(),
|
|
386520
386519
|
inputSchema: attemptCompletionSchema,
|
|
@@ -386551,8 +386550,8 @@ Usage notes:
|
|
|
386551
386550
|
- You can specify an optional timeout in seconds (up to 300s / 5 minutes). If not specified, commands will timeout after 60s (1 minute).
|
|
386552
386551
|
- If the output exceeds 30000 characters, output will be truncated before being returned to you.
|
|
386553
386552
|
- When issuing multiple commands:
|
|
386554
|
-
- If the commands are independent and can run in parallel, make multiple
|
|
386555
|
-
- If the commands depend on each other and must run sequentially, use a single executeCommand call with '&&' to chain them together (e.g., \`git add . && git commit -m "message" && git push\`)
|
|
386553
|
+
- If the commands are independent and can run in parallel, make multiple Bash tool calls in a single message. For example, if you need to run "git status" and "git diff", send a single message with two executeCommand tool calls in parallel.
|
|
386554
|
+
- If the commands depend on each other and must run sequentially, use a single executeCommand call with '&&' to chain them together (e.g., \`git add . && git commit -m "message" && git push\`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before executeCommand for git operations, or git add before git commit), run these operations sequentially instead.
|
|
386556
386555
|
- Use ';' only when you need to run commands sequentially but don't care if earlier commands fail
|
|
386557
386556
|
- DO NOT use newlines to separate commands (newlines are ok in quoted strings)
|
|
386558
386557
|
- You shall avoid use the markdown code block syntax (backtick, '\`') in your command, as it will be interpreted as a command substitution.
|
|
@@ -386562,7 +386561,16 @@ Usage notes:
|
|
|
386562
386561
|
|
|
386563
386562
|
Only create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:
|
|
386564
386563
|
|
|
386565
|
-
|
|
386564
|
+
Git Safety Protocol:
|
|
386565
|
+
- NEVER update the git config
|
|
386566
|
+
- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them
|
|
386567
|
+
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
|
|
386568
|
+
- NEVER run force push to main/master, warn the user if they request it
|
|
386569
|
+
- Avoid git commit --amend. ONLY use --amend when either (1) user explicitly requested amend OR (2) adding edits from pre-commit hook (additional instructions below)
|
|
386570
|
+
- Before amending: ALWAYS check authorship (git log -1 --format='%an %ae')
|
|
386571
|
+
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
386572
|
+
|
|
386573
|
+
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the executeCommand tool:
|
|
386566
386574
|
- Run a git status command to see all untracked files.
|
|
386567
386575
|
- Run a git diff command to see both staged and unstaged changes that will be committed.
|
|
386568
386576
|
- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
|
|
@@ -386571,13 +386579,14 @@ Only create commits when requested by the user. If unclear, ask first. When the
|
|
|
386571
386579
|
- Check for any sensitive information that shouldn't be committed
|
|
386572
386580
|
- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"
|
|
386573
386581
|
- Ensure it accurately reflects the changes and their purpose
|
|
386574
|
-
3. You
|
|
386582
|
+
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:
|
|
386575
386583
|
- Add relevant untracked files to the staging area.
|
|
386576
386584
|
- Create the commit with a message ending with:
|
|
386577
386585
|
\uD83E\uDD16 Generated with [Pochi](https://getpochi.com)
|
|
386578
386586
|
|
|
386579
386587
|
Co-Authored-By: Pochi <noreply@getpochi.com>
|
|
386580
|
-
- Run git status
|
|
386588
|
+
- Run git status after the commit completes to verify success.
|
|
386589
|
+
Note: git status depends on the commit completing, so run it sequentially after the commit.
|
|
386581
386590
|
4. If the commit fails due to pre-commit hook changes, retry the commit ONCE to include these automated changes. If it fails again, it usually means a pre-commit hook is preventing the commit. If the commit succeeds but you notice that files were modified by the pre-commit hook, you MUST amend your commit to include them.
|
|
386582
386591
|
|
|
386583
386592
|
Important notes:
|
|
@@ -386603,13 +386612,13 @@ Use the gh command via the executeCommand tool for ALL GitHub-related tasks incl
|
|
|
386603
386612
|
|
|
386604
386613
|
IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
|
|
386605
386614
|
|
|
386606
|
-
1. You
|
|
386615
|
+
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel using the executeCommand tool, in order to understand the current state of the branch since it diverged from the main branch:
|
|
386607
386616
|
- Run a git status command to see all untracked files
|
|
386608
386617
|
- Run a git diff command to see both staged and unstaged changes that will be committed
|
|
386609
386618
|
- Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
|
|
386610
386619
|
- Run a git log command and \`git diff [base-branch]...HEAD\` to understand the full commit history for the current branch (from the time it diverged from the base branch)
|
|
386611
386620
|
2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary
|
|
386612
|
-
3. You
|
|
386621
|
+
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:
|
|
386613
386622
|
- Create new branch if needed
|
|
386614
386623
|
- Push to remote with -u flag if needed
|
|
386615
386624
|
- Create PR using gh pr create with the format below. Use a HEREDOC to pass the body to ensure correct formatting.
|
|
@@ -386675,60 +386684,6 @@ var toolDef6 = {
|
|
|
386675
386684
|
};
|
|
386676
386685
|
var listFiles = tool(toolDef6);
|
|
386677
386686
|
|
|
386678
|
-
// ../tools/src/multi-apply-diff.ts
|
|
386679
|
-
var toolDef7 = {
|
|
386680
|
-
description: `
|
|
386681
|
-
This is a tool for making multiple edits to a single file in one operation. It is built on top of the applyDiff tool and allows you to perform multiple find-and-replace operations efficiently. Prefer this tool over the applyDiff tool when you need to make multiple edits to the same file.
|
|
386682
|
-
|
|
386683
|
-
Before using this tool, use the readFile tool to understand the file's contents and context
|
|
386684
|
-
|
|
386685
|
-
To make multiple file edits, provide the following:
|
|
386686
|
-
1. path: The path to the file to modify (relative to the current working directory, or an absolute path)
|
|
386687
|
-
2. edits: An array of edit operations to perform, where each edit contains:
|
|
386688
|
-
- searchContent: The text to replace (must match the file contents exactly, including all whitespace and indentation)
|
|
386689
|
-
- replaceContent : The edited text to replace the old_string
|
|
386690
|
-
- expectedReplacements: The number of replacements you expect to make. Defaults to 1 if not specified.
|
|
386691
|
-
|
|
386692
|
-
IMPORTANT:
|
|
386693
|
-
- All edits are applied in sequence, in the order they are provided
|
|
386694
|
-
- Each edit operates on the result of the previous edit
|
|
386695
|
-
- All edits must be valid for the operation to succeed - if any edit fails, none will be applied
|
|
386696
|
-
- This tool is ideal when you need to make several changes to different parts of the same file
|
|
386697
|
-
|
|
386698
|
-
CRITICAL REQUIREMENTS:
|
|
386699
|
-
1. All edits follow the same requirements as the single applyDiff tool
|
|
386700
|
-
2. The edits are atomic - either all succeed or none are applied
|
|
386701
|
-
3. Plan your edits carefully to avoid conflicts between sequential operations
|
|
386702
|
-
|
|
386703
|
-
WARNING:
|
|
386704
|
-
- The tool will fail if edits.searchContent matches multiple locations and edits.expectedReplacements isn't specified
|
|
386705
|
-
- The tool will fail if the number of matches doesn't equal edits.expectedReplacements when it's specified
|
|
386706
|
-
- The tool will fail if edits.searchContent doesn't match the file contents exactly (including whitespace)
|
|
386707
|
-
- The tool will fail if edits.searchContent and edits.replaceContent are the same
|
|
386708
|
-
- Since edits are applied in sequence, ensure that earlier edits don't affect the text that later edits are trying to find
|
|
386709
|
-
|
|
386710
|
-
When making edits:
|
|
386711
|
-
- Ensure all edits result in idiomatic, correct code
|
|
386712
|
-
- Do not leave the code in a broken state
|
|
386713
|
-
|
|
386714
|
-
If you want to create a new file, use:
|
|
386715
|
-
- A new file path, including dir name if needed
|
|
386716
|
-
- First edit: empty old_string and the new file's contents as new_string
|
|
386717
|
-
- Subsequent edits: normal edit operations on the created content
|
|
386718
|
-
|
|
386719
|
-
${EditFileResultPrompt}`.trim(),
|
|
386720
|
-
inputSchema: exports_external2.object({
|
|
386721
|
-
path: exports_external2.string().describe("The path of the file to modify (relative to the current working directory, or an absolute path)."),
|
|
386722
|
-
edits: exports_external2.array(exports_external2.object({
|
|
386723
|
-
searchContent: exports_external2.string().describe("The text to replace."),
|
|
386724
|
-
replaceContent: exports_external2.string().describe("The text to replace it with."),
|
|
386725
|
-
expectedReplacements: exports_external2.number().optional().describe("The expected number of replacements to perform. Defaults to 1 if not specified.")
|
|
386726
|
-
})).describe("A list of search and replace operations to apply to the file.")
|
|
386727
|
-
}),
|
|
386728
|
-
outputSchema: EditFileOutputSchema
|
|
386729
|
-
};
|
|
386730
|
-
var multiApplyDiff = tool(toolDef7);
|
|
386731
|
-
|
|
386732
386687
|
// ../tools/src/new-task.ts
|
|
386733
386688
|
var CustomAgent = exports_external2.object({
|
|
386734
386689
|
name: exports_external2.string().describe("The name of the custom agent."),
|
|
@@ -386799,7 +386754,7 @@ Usage notes:
|
|
|
386799
386754
|
});
|
|
386800
386755
|
|
|
386801
386756
|
// ../tools/src/search-files.ts
|
|
386802
|
-
var
|
|
386757
|
+
var toolDef7 = {
|
|
386803
386758
|
description: `
|
|
386804
386759
|
- Fast content search tool that works with any codebase size
|
|
386805
386760
|
- Searches file contents using regular expressions
|
|
@@ -386825,7 +386780,7 @@ var toolDef8 = {
|
|
|
386825
386780
|
isTruncated: exports_external2.boolean().describe("Whether the content is truncated due to exceeding the maximum buffer length")
|
|
386826
386781
|
})
|
|
386827
386782
|
};
|
|
386828
|
-
var searchFiles = tool(
|
|
386783
|
+
var searchFiles = tool(toolDef7);
|
|
386829
386784
|
|
|
386830
386785
|
// ../tools/src/todo-write.ts
|
|
386831
386786
|
var Todo = exports_external2.object({
|
|
@@ -386834,7 +386789,7 @@ var Todo = exports_external2.object({
|
|
|
386834
386789
|
status: exports_external2.enum(["pending", "in-progress", "completed", "cancelled"]).describe("The status of the task."),
|
|
386835
386790
|
priority: exports_external2.enum(["low", "medium", "high"]).describe("The priority of the task.")
|
|
386836
386791
|
});
|
|
386837
|
-
var
|
|
386792
|
+
var toolDef8 = {
|
|
386838
386793
|
description: `
|
|
386839
386794
|
Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
386840
386795
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
@@ -387010,7 +386965,7 @@ When in doubt, use this tool. Being proactive with task management demonstrates
|
|
|
387010
386965
|
success: exports_external2.boolean().describe("Whether the todos were successfully updated.")
|
|
387011
386966
|
})
|
|
387012
386967
|
};
|
|
387013
|
-
var todoWrite = tool(
|
|
386968
|
+
var todoWrite = tool(toolDef8);
|
|
387014
386969
|
// ../tools/src/read-file.ts
|
|
387015
386970
|
var TextOutput = exports_external2.object({
|
|
387016
386971
|
type: exports_external2.literal("text").optional(),
|
|
@@ -387046,7 +387001,7 @@ var editNotebook = tool({
|
|
|
387046
387001
|
});
|
|
387047
387002
|
|
|
387048
387003
|
// ../tools/src/kill-background-job.ts
|
|
387049
|
-
var
|
|
387004
|
+
var toolDef9 = {
|
|
387050
387005
|
description: `- Kills a running background job by its ID
|
|
387051
387006
|
- Takes a backgroundJobId parameter identifying the job to kill
|
|
387052
387007
|
- Returns a success or failure status
|
|
@@ -387058,10 +387013,10 @@ var toolDef10 = {
|
|
|
387058
387013
|
success: zod_default.boolean().describe("Whether the background job was successfully killed.")
|
|
387059
387014
|
})
|
|
387060
387015
|
};
|
|
387061
|
-
var killBackgroundJob = tool(
|
|
387016
|
+
var killBackgroundJob = tool(toolDef9);
|
|
387062
387017
|
|
|
387063
387018
|
// ../tools/src/read-background-job-output.ts
|
|
387064
|
-
var
|
|
387019
|
+
var toolDef10 = {
|
|
387065
387020
|
description: `- Retrieves output from a running or completed background job
|
|
387066
387021
|
- Takes a backgroundJobId parameter identifying the job
|
|
387067
387022
|
- Always returns only new output since the last check
|
|
@@ -387078,10 +387033,10 @@ var toolDef11 = {
|
|
|
387078
387033
|
isTruncated: zod_default.boolean().optional().describe("Whether the output was truncated")
|
|
387079
387034
|
})
|
|
387080
387035
|
};
|
|
387081
|
-
var readBackgroundJobOutput = tool(
|
|
387036
|
+
var readBackgroundJobOutput = tool(toolDef10);
|
|
387082
387037
|
|
|
387083
387038
|
// ../tools/src/start-background-job.ts
|
|
387084
|
-
var
|
|
387039
|
+
var toolDef11 = {
|
|
387085
387040
|
description: `Start a background job to execute a bash command, which allows you to continue working while the job runs.
|
|
387086
387041
|
|
|
387087
387042
|
Before starting the background job, please follow these steps:
|
|
@@ -387121,10 +387076,10 @@ Command execution rules:
|
|
|
387121
387076
|
backgroundJobId: exports_external2.string().optional().describe("The ID of the background job")
|
|
387122
387077
|
})
|
|
387123
387078
|
};
|
|
387124
|
-
var startBackgroundJob = tool(
|
|
387079
|
+
var startBackgroundJob = tool(toolDef11);
|
|
387125
387080
|
|
|
387126
387081
|
// ../tools/src/write-to-file.ts
|
|
387127
|
-
var
|
|
387082
|
+
var toolDef12 = {
|
|
387128
387083
|
description: `
|
|
387129
387084
|
Request to write full content to a file at the specified path.
|
|
387130
387085
|
If the file exists, it will be overwritten with the provided content.
|
|
@@ -387137,7 +387092,7 @@ ${EditFileResultPrompt}`.trim(),
|
|
|
387137
387092
|
}),
|
|
387138
387093
|
outputSchema: EditFileOutputSchema
|
|
387139
387094
|
};
|
|
387140
|
-
var writeToFile = tool(
|
|
387095
|
+
var writeToFile = tool(toolDef12);
|
|
387141
387096
|
|
|
387142
387097
|
// ../tools/src/index.ts
|
|
387143
387098
|
function isUserInputToolName(name17) {
|
|
@@ -387171,7 +387126,6 @@ var ToolsByPermission = {
|
|
|
387171
387126
|
write: [
|
|
387172
387127
|
"writeToFile",
|
|
387173
387128
|
"applyDiff",
|
|
387174
|
-
"multiApplyDiff",
|
|
387175
387129
|
"editNotebook"
|
|
387176
387130
|
],
|
|
387177
387131
|
execute: [
|
|
@@ -387189,7 +387143,6 @@ var createCliTools = (options) => ({
|
|
|
387189
387143
|
executeCommand,
|
|
387190
387144
|
globFiles,
|
|
387191
387145
|
listFiles,
|
|
387192
|
-
multiApplyDiff,
|
|
387193
387146
|
readFile: createReadFileTool(options?.contentType),
|
|
387194
387147
|
searchFiles,
|
|
387195
387148
|
todoWrite,
|
|
@@ -387227,6 +387180,8 @@ var exports_constants = {};
|
|
|
387227
387180
|
__export(exports_constants, {
|
|
387228
387181
|
WorkspaceWorkflowPathSegments: () => WorkspaceWorkflowPathSegments,
|
|
387229
387182
|
PochiTaskIdHeader: () => PochiTaskIdHeader,
|
|
387183
|
+
PochiRequestUseCaseHeader: () => PochiRequestUseCaseHeader,
|
|
387184
|
+
PochiClientHeader: () => PochiClientHeader,
|
|
387230
387185
|
KnownTags: () => KnownTags,
|
|
387231
387186
|
DefaultMaxOutputTokens: () => DefaultMaxOutputTokens,
|
|
387232
387187
|
DefaultContextWindow: () => DefaultContextWindow,
|
|
@@ -387243,6 +387198,8 @@ var WorkspaceWorkflowPathSegments = [".pochi", "workflows"];
|
|
|
387243
387198
|
var DefaultContextWindow = 1e5;
|
|
387244
387199
|
var DefaultMaxOutputTokens = 4096;
|
|
387245
387200
|
var PochiTaskIdHeader = "x-pochi-task-id";
|
|
387201
|
+
var PochiClientHeader = "x-pochi-client";
|
|
387202
|
+
var PochiRequestUseCaseHeader = "x-pochi-request-use-case";
|
|
387246
387203
|
|
|
387247
387204
|
// ../common/src/base/prompts/compact.ts
|
|
387248
387205
|
function createCompactPrompt() {
|
|
@@ -387292,6 +387249,11 @@ Summary:
|
|
|
387292
387249
|
`;
|
|
387293
387250
|
}
|
|
387294
387251
|
|
|
387252
|
+
// ../common/src/base/prompts/create-pr.ts
|
|
387253
|
+
function createPr(isDraft) {
|
|
387254
|
+
return `Please use gh cli to create a ${isDraft ? "draft" : ""} pull request`;
|
|
387255
|
+
}
|
|
387256
|
+
|
|
387295
387257
|
// ../common/src/base/prompts/environment.ts
|
|
387296
387258
|
function createEnvironmentPrompt(environment, user) {
|
|
387297
387259
|
const sections = [
|
|
@@ -387575,7 +387537,6 @@ When the user directly asks about Pochi (eg 'can Pochi do...', 'does Pochi have.
|
|
|
387575
387537
|
|
|
387576
387538
|
${getTodoListPrompt()}
|
|
387577
387539
|
${getRulesPrompt()}
|
|
387578
|
-
${getObjectivePrompt()}
|
|
387579
387540
|
${customAgent ? "" : getCustomRulesPrompt(customRules)}
|
|
387580
387541
|
${getMcpInstructionsPrompt(mcpInstructions)}
|
|
387581
387542
|
`.trim();
|
|
@@ -387587,48 +387548,16 @@ RULES
|
|
|
387587
387548
|
|
|
387588
387549
|
- User messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result. You shall pay close attention to information in these tags and use it to inform you actions.
|
|
387589
387550
|
- When the user initially gives you a task, a recursive list of all filepaths in the current working directory will be included in <system-reminder> tag. This provides an overview of the project's file structure, offering key insights into the project from directory/file names (how developers conceptualize and organize their code) and file extensions (the language used). This can also guide decision-making on which files to explore further. If you need to further explore directories such as outside the current working directory, you can use the listFiles tool. If you pass 'true' for the recursive parameter, it will list files recursively.
|
|
387590
|
-
- All file paths used by tools must be relative to current working directory.
|
|
387591
|
-
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from current working directory, so be sure to pass in the correct 'path' parameter when using tools that require a path.
|
|
387592
|
-
- Do not use the ~ character or $HOME to refer to the home directory.
|
|
387593
|
-
- When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the writeToFile tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser.
|
|
387594
|
-
- For editing files, you have access to these tools: applyDiff (for replacing lines in existing files), multiApplyDiff (for replacing multiple lines in existing files), and writeToFile (for creating new files or complete file rewrites).
|
|
387595
|
-
* Prefer using writeToFile only for new files or when rewriting more than 70% of an existing file's content.
|
|
387596
|
-
* STRONGLY PREFER using multiApplyDiff over applyDiff in most scenarios - it's more efficient and atomic than multiple applyDiff calls.
|
|
387597
|
-
* Use multiApplyDiff when making ANY multiple changes to a file, even if they're in different sections.
|
|
387598
|
-
* Use multiApplyDiff when refactoring code patterns, updating imports, or making systematic changes across a file.
|
|
387599
|
-
* Use multiApplyDiff when you need to update related code elements (e.g., function signature + its calls, variable renames, etc.).
|
|
387600
|
-
* Only use applyDiff for truly isolated single changes where no other modifications are needed.
|
|
387601
|
-
* CRITICAL: Within a single response, you MUST NOT make multiple applyDiff calls to the same file path. If you need to make multiple edits to a single file, you MUST use multiApplyDiff instead. This is NON-NEGOTIABLE.
|
|
387602
|
-
- When using the writeToFile tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project.
|
|
387551
|
+
- All file paths used by tools must be relative to current working directory, do not use the ~ character or $HOME to refer to the home directory in file paths used by tools.
|
|
387603
387552
|
- Be sure to consider the type of project (e.g. Python, JavaScript, web application) when determining the appropriate structure and files to include. Also consider what files may be most relevant to accomplishing the task, for example looking at a project's manifest file would help you understand the project's dependencies, which you could incorporate into any code you write.
|
|
387604
|
-
- When making changes to code, always consider the context in which the code is being used. Ensure that your changes are compatible with the existing codebase and that they follow the project's coding standards and best practices.
|
|
387605
387553
|
- Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, you must use the attemptCompletion tool to present the result to the user. The user may provide feedback, which you can use to make improvements and try again.
|
|
387606
387554
|
- You are only allowed to ask the user questions using the askFollowupQuestion tool. Use this tool only when you need additional details to complete a task, and be sure to use a clear and concise question that will help you move forward with the task. However if you can use the available tools to avoid having to ask the user questions, you should do so. For example, if the user mentions a file that may be in an outside directory like the Desktop, you should use the listFiles tool to list the files in the Desktop and check if the file they are talking about is there, rather than asking the user to provide the file path themselves.
|
|
387607
|
-
- The user may provide a file's contents directly in their message, in which case you shouldn't use the readFile tool to get the file contents again since you already have it.
|
|
387608
|
-
- Your goal is to try to accomplish the user's task, NOT engage in a back and forth conversation.
|
|
387609
387555
|
- You are STRICTLY FORBIDDEN from starting your messages with "Great", "Certainly", "Okay", "Sure". You should NOT be conversational in your responses, but rather direct and to the point. For example you should NOT say "Great, I've updated the CSS" but instead something like "I've updated the CSS". It is important you be clear and technical in your messages.
|
|
387610
|
-
-
|
|
387611
|
-
- IMPORTANT: When userEdits is present in any file editing tool call's response, UNLESS user explicitly asks, you are FORBIDDEN to make any further edits to the file, consider the file as FINAL. use askFollowupQuestion tool if you need clarifying anything.
|
|
387612
|
-
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
387556
|
+
- Once you've completed the user's task, you MUST use the attemptCompletion tool to present the result of the task to the user. It is STRICTLY FORBIDDEN to complete the task without using this tool.
|
|
387613
387557
|
- When planning large-scale changes, create a high-level diagram using mermaid in Markdown. This helps explain your plan and allows you to gather user feedback before implementation.
|
|
387614
387558
|
`;
|
|
387615
387559
|
return prompt;
|
|
387616
387560
|
}
|
|
387617
|
-
function getObjectivePrompt() {
|
|
387618
|
-
const prompt = `====
|
|
387619
|
-
|
|
387620
|
-
OBJECTIVE
|
|
387621
|
-
|
|
387622
|
-
You accomplish a given task iteratively, breaking it down into clear steps and working through them methodically.
|
|
387623
|
-
|
|
387624
|
-
1. Analyze the user's task and set clear, achievable goals to accomplish it. Prioritize these goals in a logical order.
|
|
387625
|
-
2. Work through these goals sequentially, utilizing available tools one at a time as necessary. Each goal should correspond to a distinct step in your problem-solving process. You will be informed on the work completed and what's remaining as you go.
|
|
387626
|
-
3. Remember, you have extensive capabilities with access to a wide range of tools that can be used in powerful and clever ways as necessary to accomplish each goal. Before calling a tool, do some analysis: First, analyze the file structure provided in system-reminder to gain context and insights for proceeding effectively. Then, think about which of the provided tools is the most relevant tool to accomplish the user's task. Next, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, proceed with the tool use. BUT, if one of the values for a required parameter is missing, DO NOT invoke the tool (not even with fillers for the missing params) and instead, ask the user to provide the missing parameters using the askFollowupQuestion tool. DO NOT ask for more information on optional parameters if it is not provided.
|
|
387627
|
-
4. Once you've completed the user's task, you must use the attemptCompletion tool to present the result of the task to the user. You may also provide a CLI command to showcase the result of your task; this can be particularly useful for web development tasks, where you can run e.g. \`open index.html\` to show the website you've built.
|
|
387628
|
-
5. The user may provide feedback, which you can use to make improvements and try again. But DO NOT continue in pointless back and forth conversations, i.e. don't end your responses with questions or offers for further assistance.
|
|
387629
|
-
`;
|
|
387630
|
-
return prompt;
|
|
387631
|
-
}
|
|
387632
387561
|
function getTodoListPrompt() {
|
|
387633
387562
|
const prompt = `====
|
|
387634
387563
|
|
|
@@ -387673,6 +387602,17 @@ ${mcpInstructions}
|
|
|
387673
387602
|
return prompt;
|
|
387674
387603
|
}
|
|
387675
387604
|
|
|
387605
|
+
// ../common/src/base/prompts/workflow.ts
|
|
387606
|
+
function createWorkflowPrompt(id, path2, content) {
|
|
387607
|
+
let processedContent = content.replace(/\n+/g, `
|
|
387608
|
+
`);
|
|
387609
|
+
const workflowTagRegex = /<\/?workflow\b[^>]*>/g;
|
|
387610
|
+
processedContent = processedContent.replace(workflowTagRegex, (match2) => {
|
|
387611
|
+
return match2.replace("<", "<");
|
|
387612
|
+
});
|
|
387613
|
+
return `<workflow id="${id}" path="${path2}">${processedContent}</workflow>`;
|
|
387614
|
+
}
|
|
387615
|
+
|
|
387676
387616
|
// ../common/src/base/prompts/index.ts
|
|
387677
387617
|
var prompts = {
|
|
387678
387618
|
system: createSystemPrompt,
|
|
@@ -387688,7 +387628,8 @@ var prompts = {
|
|
|
387688
387628
|
generateTitle,
|
|
387689
387629
|
workflow: createWorkflowPrompt,
|
|
387690
387630
|
customAgent: createCustomAgentPrompt,
|
|
387691
|
-
injectBashOutputs
|
|
387631
|
+
injectBashOutputs,
|
|
387632
|
+
createPr
|
|
387692
387633
|
};
|
|
387693
387634
|
function createSystemReminder(content) {
|
|
387694
387635
|
return `<system-reminder>${content}</system-reminder>`;
|
|
@@ -387717,15 +387658,6 @@ function parseInlineCompact(text2) {
|
|
|
387717
387658
|
summary: match2[1]
|
|
387718
387659
|
};
|
|
387719
387660
|
}
|
|
387720
|
-
function createWorkflowPrompt(id, path2, content) {
|
|
387721
|
-
let processedContent = content.replace(/\n+/g, `
|
|
387722
|
-
`);
|
|
387723
|
-
const workflowTagRegex = /<\/?workflow\b[^>]*>/g;
|
|
387724
|
-
processedContent = processedContent.replace(workflowTagRegex, (match2) => {
|
|
387725
|
-
return match2.replace("<", "<");
|
|
387726
|
-
});
|
|
387727
|
-
return `<workflow id="${id}" path="${path2}">${processedContent}</workflow>`;
|
|
387728
|
-
}
|
|
387729
387661
|
function createCustomAgentPrompt(id, path2) {
|
|
387730
387662
|
let processedAgentName = id.replace(/\n+/g, `
|
|
387731
387663
|
`);
|
|
@@ -388010,6 +387942,34 @@ function toErrorMessage(error40) {
|
|
|
388010
387942
|
}
|
|
388011
387943
|
return JSON.stringify(error40);
|
|
388012
387944
|
}
|
|
387945
|
+
|
|
387946
|
+
// ../common/src/base/index.ts
|
|
387947
|
+
var PochiProviderOptions = exports_external.object({
|
|
387948
|
+
taskId: exports_external.string(),
|
|
387949
|
+
client: exports_external.string(),
|
|
387950
|
+
useCase: exports_external.union([
|
|
387951
|
+
exports_external.literal("agent"),
|
|
387952
|
+
exports_external.literal("output-schema"),
|
|
387953
|
+
exports_external.literal("repair-tool-call"),
|
|
387954
|
+
exports_external.literal("generate-task-title"),
|
|
387955
|
+
exports_external.literal("compact-task")
|
|
387956
|
+
])
|
|
387957
|
+
});
|
|
387958
|
+
// ../common/src/vscode-webui-bridge/types/git.ts
|
|
387959
|
+
var GitWorktreeInfo = v4_default.object({
|
|
387960
|
+
nextDisplayId: v4_default.number().min(1),
|
|
387961
|
+
github: v4_default.object({
|
|
387962
|
+
pullRequest: v4_default.object({
|
|
387963
|
+
id: v4_default.number().describe("the ID of the pull request"),
|
|
387964
|
+
status: v4_default.enum(["open", "closed", "merged"]),
|
|
387965
|
+
checks: v4_default.array(v4_default.object({
|
|
387966
|
+
name: v4_default.string().describe("the name of the check"),
|
|
387967
|
+
state: v4_default.string().describe("the state of the check"),
|
|
387968
|
+
url: v4_default.string().describe("the URL of the check")
|
|
387969
|
+
})).optional()
|
|
387970
|
+
}).optional()
|
|
387971
|
+
})
|
|
387972
|
+
});
|
|
388013
387973
|
// ../common/src/vscode-webui-bridge/types/custom-agent.ts
|
|
388014
387974
|
var isValidCustomAgentFile = (agent) => {
|
|
388015
387975
|
return agent.name !== undefined && agent.description !== undefined && agent.systemPrompt !== undefined && !agent.error;
|
|
@@ -391648,8 +391608,23 @@ var makeWebSearch = (getToken) => ({
|
|
|
391648
391608
|
description: `
|
|
391649
391609
|
- Allows Pochi to search the web and use the results to inform responses
|
|
391650
391610
|
- Provides up-to-date information for current events and recent data
|
|
391651
|
-
- Returns search result information formatted as search result blocks
|
|
391611
|
+
- Returns search result information formatted as search result blocks, including links as markdown hyperlinks
|
|
391652
391612
|
- Searches are performed automatically within a single API call
|
|
391613
|
+
|
|
391614
|
+
CRITICAL REQUIREMENT - You MUST follow this:
|
|
391615
|
+
- After answering the user's question, you MUST include a "Sources:" section at the end of your response
|
|
391616
|
+
- In the Sources section, list all relevant URLs from the search results as markdown hyperlinks: [Title](URL)
|
|
391617
|
+
- This is MANDATORY - never skip including sources in your response
|
|
391618
|
+
- Example format:
|
|
391619
|
+
|
|
391620
|
+
[Your answer here]
|
|
391621
|
+
|
|
391622
|
+
Sources:
|
|
391623
|
+
- [Source Title 1](https://example.com/1)
|
|
391624
|
+
- [Source Title 2](https://example.com/2)
|
|
391625
|
+
|
|
391626
|
+
Usage notes:
|
|
391627
|
+
- Account for "Today's date" in <system-reminder>. For example, if <system-reminder> says "Today's date: 2025-07-01", and the user wants the latest docs, do not use 2024 in the search query. Use 2025.
|
|
391653
391628
|
`.trim(),
|
|
391654
391629
|
inputSchema: {
|
|
391655
391630
|
jsonSchema: v4_default.toJSONSchema(v4_default.object({
|
|
@@ -393153,7 +393128,19 @@ function createPochiModel({
|
|
|
393153
393128
|
provider: "pochi",
|
|
393154
393129
|
modelId: modelId || "<default>",
|
|
393155
393130
|
supportedUrls: {},
|
|
393156
|
-
doGenerate: async ({
|
|
393131
|
+
doGenerate: async ({
|
|
393132
|
+
abortSignal,
|
|
393133
|
+
prompt,
|
|
393134
|
+
providerOptions,
|
|
393135
|
+
...options
|
|
393136
|
+
}) => {
|
|
393137
|
+
const headers = {};
|
|
393138
|
+
const parsedOptions = PochiProviderOptions.safeParse(providerOptions?.pochi);
|
|
393139
|
+
if (parsedOptions.success) {
|
|
393140
|
+
headers[exports_constants.PochiTaskIdHeader] = parsedOptions.data.taskId;
|
|
393141
|
+
headers[exports_constants.PochiClientHeader] = parsedOptions.data.client;
|
|
393142
|
+
headers[exports_constants.PochiRequestUseCaseHeader] = parsedOptions.data.useCase;
|
|
393143
|
+
}
|
|
393157
393144
|
const apiClient = createApiClient(getCredentials);
|
|
393158
393145
|
const resp = await apiClient.api.chat.$post({
|
|
393159
393146
|
json: {
|
|
@@ -393164,7 +393151,7 @@ function createPochiModel({
|
|
|
393164
393151
|
}
|
|
393165
393152
|
}
|
|
393166
393153
|
}, {
|
|
393167
|
-
headers
|
|
393154
|
+
headers,
|
|
393168
393155
|
init: {
|
|
393169
393156
|
signal: abortSignal
|
|
393170
393157
|
}
|
|
@@ -393177,9 +393164,16 @@ function createPochiModel({
|
|
|
393177
393164
|
abortSignal,
|
|
393178
393165
|
stopSequences,
|
|
393179
393166
|
tools,
|
|
393180
|
-
|
|
393167
|
+
providerOptions
|
|
393181
393168
|
}) => {
|
|
393182
393169
|
const apiClient = createApiClient(getCredentials);
|
|
393170
|
+
const headers = {};
|
|
393171
|
+
const parsedOptions = PochiProviderOptions.safeParse(providerOptions?.pochi);
|
|
393172
|
+
if (parsedOptions.success) {
|
|
393173
|
+
headers[exports_constants.PochiTaskIdHeader] = parsedOptions.data.taskId;
|
|
393174
|
+
headers[exports_constants.PochiClientHeader] = parsedOptions.data.client;
|
|
393175
|
+
headers[exports_constants.PochiRequestUseCaseHeader] = parsedOptions.data.useCase;
|
|
393176
|
+
}
|
|
393183
393177
|
const data = {
|
|
393184
393178
|
model: modelId,
|
|
393185
393179
|
callOptions: {
|
|
@@ -393191,7 +393185,7 @@ function createPochiModel({
|
|
|
393191
393185
|
const resp = await apiClient.api.chat.stream.$post({
|
|
393192
393186
|
json: data
|
|
393193
393187
|
}, {
|
|
393194
|
-
headers
|
|
393188
|
+
headers,
|
|
393195
393189
|
init: {
|
|
393196
393190
|
signal: abortSignal
|
|
393197
393191
|
}
|
|
@@ -393201,8 +393195,15 @@ function createPochiModel({
|
|
|
393201
393195
|
resp.headers.forEach((value2, key) => {
|
|
393202
393196
|
responseHeaders[key] = value2;
|
|
393203
393197
|
});
|
|
393198
|
+
let message = `Failed to fetch: ${resp.status} ${resp.statusText}`;
|
|
393199
|
+
if (resp.status >= 400 && resp.status < 600 && responseHeaders["content-type"]?.includes("text/plain")) {
|
|
393200
|
+
const errorMessage = await resp.text();
|
|
393201
|
+
if (errorMessage) {
|
|
393202
|
+
message = errorMessage;
|
|
393203
|
+
}
|
|
393204
|
+
}
|
|
393204
393205
|
throw new APICallError({
|
|
393205
|
-
message
|
|
393206
|
+
message,
|
|
393206
393207
|
statusCode: resp.status,
|
|
393207
393208
|
url: apiClient.api.chat.stream.$url().toString(),
|
|
393208
393209
|
requestBodyValues: data,
|
|
@@ -403621,7 +403622,7 @@ function createPatchedFetch3(getCredentials) {
|
|
|
403621
403622
|
registerModel(VendorId7, createQwenModel);
|
|
403622
403623
|
|
|
403623
403624
|
// src/cli.ts
|
|
403624
|
-
import
|
|
403625
|
+
import fs18 from "fs/promises";
|
|
403625
403626
|
import path28 from "path";
|
|
403626
403627
|
|
|
403627
403628
|
// ../../node_modules/@commander-js/extra-typings/esm.mjs
|
|
@@ -405397,6 +405398,12 @@ var Todo2 = exports_Schema2.Struct({
|
|
|
405397
405398
|
priority: exports_Schema2.Literal("low", "medium", "high")
|
|
405398
405399
|
});
|
|
405399
405400
|
var Todos = exports_Schema2.Array(Todo2);
|
|
405401
|
+
var ToolCall = exports_Schema2.Unknown;
|
|
405402
|
+
var ToolCalls = exports_Schema2.Array(ToolCall);
|
|
405403
|
+
var LineChanges = exports_Schema2.Struct({
|
|
405404
|
+
added: exports_Schema2.Number,
|
|
405405
|
+
removed: exports_Schema2.Number
|
|
405406
|
+
});
|
|
405400
405407
|
var TaskStatus = exports_Schema2.Literal("completed", "pending-input", "failed", "pending-tool", "pending-model");
|
|
405401
405408
|
var TaskError = exports_Schema2.Union(exports_Schema2.Struct({
|
|
405402
405409
|
kind: exports_Schema2.Literal("InternalError"),
|
|
@@ -405432,9 +405439,13 @@ var taskFullFields = {
|
|
|
405432
405439
|
title: exports_Schema2.optional(exports_Schema2.String),
|
|
405433
405440
|
status: TaskStatus,
|
|
405434
405441
|
todos: Todos,
|
|
405442
|
+
pendingToolCalls: exports_Schema2.optional(ToolCalls),
|
|
405435
405443
|
totalTokens: exports_Schema2.optional(exports_Schema2.Number),
|
|
405444
|
+
lineChanges: exports_Schema2.optional(LineChanges),
|
|
405445
|
+
lastStepDuration: exports_Schema2.optional(exports_Schema2.DurationFromMillis),
|
|
405436
405446
|
error: exports_Schema2.optional(TaskError),
|
|
405437
|
-
updatedAt: exports_Schema2.Date
|
|
405447
|
+
updatedAt: exports_Schema2.Date,
|
|
405448
|
+
displayId: exports_Schema2.optional(exports_Schema2.Number)
|
|
405438
405449
|
};
|
|
405439
405450
|
|
|
405440
405451
|
// ../livekit/src/livestore/default-schema.ts
|
|
@@ -405460,11 +405471,24 @@ var tables = {
|
|
|
405460
405471
|
nullable: true,
|
|
405461
405472
|
schema: Git
|
|
405462
405473
|
}),
|
|
405474
|
+
pendingToolCalls: exports_mod4.SQLite.json({
|
|
405475
|
+
nullable: true,
|
|
405476
|
+
schema: ToolCalls
|
|
405477
|
+
}),
|
|
405478
|
+
lineChanges: exports_mod4.SQLite.json({
|
|
405479
|
+
nullable: true,
|
|
405480
|
+
schema: LineChanges
|
|
405481
|
+
}),
|
|
405463
405482
|
totalTokens: exports_mod4.SQLite.integer({ nullable: true }),
|
|
405483
|
+
lastStepDuration: exports_mod4.SQLite.integer({
|
|
405484
|
+
nullable: true,
|
|
405485
|
+
schema: exports_Schema2.DurationFromMillis
|
|
405486
|
+
}),
|
|
405464
405487
|
error: exports_mod4.SQLite.json({ schema: TaskError, nullable: true }),
|
|
405465
405488
|
createdAt: exports_mod4.SQLite.integer({ schema: exports_Schema2.DateFromNumber }),
|
|
405466
405489
|
updatedAt: exports_mod4.SQLite.integer({ schema: exports_Schema2.DateFromNumber }),
|
|
405467
|
-
modelId: exports_mod4.SQLite.text({ nullable: true })
|
|
405490
|
+
modelId: exports_mod4.SQLite.text({ nullable: true }),
|
|
405491
|
+
displayId: exports_mod4.SQLite.integer({ nullable: true })
|
|
405468
405492
|
},
|
|
405469
405493
|
indexes: [
|
|
405470
405494
|
{
|
|
@@ -405511,6 +405535,7 @@ var events = {
|
|
|
405511
405535
|
name: "v1.TaskInited",
|
|
405512
405536
|
schema: exports_Schema2.Struct({
|
|
405513
405537
|
...taskInitFields,
|
|
405538
|
+
initMessages: exports_Schema2.optional(exports_Schema2.Array(DBMessage)),
|
|
405514
405539
|
initMessage: exports_Schema2.optional(exports_Schema2.Struct({
|
|
405515
405540
|
id: exports_Schema2.String,
|
|
405516
405541
|
parts: exports_Schema2.Array(DBUIPart)
|
|
@@ -405534,7 +405559,8 @@ var events = {
|
|
|
405534
405559
|
title: exports_Schema2.optional(exports_Schema2.String),
|
|
405535
405560
|
git: exports_Schema2.optional(Git),
|
|
405536
405561
|
updatedAt: exports_Schema2.Date,
|
|
405537
|
-
modelId: exports_Schema2.optional(exports_Schema2.String)
|
|
405562
|
+
modelId: exports_Schema2.optional(exports_Schema2.String),
|
|
405563
|
+
displayId: exports_Schema2.optional(exports_Schema2.Number)
|
|
405538
405564
|
})
|
|
405539
405565
|
}),
|
|
405540
405566
|
chatStreamFinished: exports_events.synced({
|
|
@@ -405544,7 +405570,8 @@ var events = {
|
|
|
405544
405570
|
data: DBMessage,
|
|
405545
405571
|
totalTokens: exports_Schema2.NullOr(exports_Schema2.Number),
|
|
405546
405572
|
status: TaskStatus,
|
|
405547
|
-
updatedAt: exports_Schema2.Date
|
|
405573
|
+
updatedAt: exports_Schema2.Date,
|
|
405574
|
+
duration: exports_Schema2.optional(exports_Schema2.DurationFromMillis)
|
|
405548
405575
|
})
|
|
405549
405576
|
}),
|
|
405550
405577
|
chatStreamFailed: exports_events.synced({
|
|
@@ -405553,7 +405580,8 @@ var events = {
|
|
|
405553
405580
|
id: exports_Schema2.String,
|
|
405554
405581
|
error: TaskError,
|
|
405555
405582
|
data: exports_Schema2.NullOr(DBMessage),
|
|
405556
|
-
updatedAt: exports_Schema2.Date
|
|
405583
|
+
updatedAt: exports_Schema2.Date,
|
|
405584
|
+
duration: exports_Schema2.optional(exports_Schema2.DurationFromMillis)
|
|
405557
405585
|
})
|
|
405558
405586
|
}),
|
|
405559
405587
|
updateShareId: exports_events.synced({
|
|
@@ -405588,19 +405616,40 @@ var events = {
|
|
|
405588
405616
|
mimeType: exports_Schema2.String,
|
|
405589
405617
|
data: exports_Schema2.Uint8Array
|
|
405590
405618
|
})
|
|
405619
|
+
}),
|
|
405620
|
+
updateLineChanges: exports_events.synced({
|
|
405621
|
+
name: "v1.updateLineChanges",
|
|
405622
|
+
schema: exports_Schema2.Struct({
|
|
405623
|
+
id: exports_Schema2.String,
|
|
405624
|
+
lineChanges: LineChanges,
|
|
405625
|
+
updatedAt: exports_Schema2.Date
|
|
405626
|
+
})
|
|
405591
405627
|
})
|
|
405592
405628
|
};
|
|
405593
405629
|
var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
405594
|
-
"v1.TaskInited": ({
|
|
405630
|
+
"v1.TaskInited": ({
|
|
405631
|
+
id: id4,
|
|
405632
|
+
parentId,
|
|
405633
|
+
createdAt,
|
|
405634
|
+
cwd,
|
|
405635
|
+
initMessage,
|
|
405636
|
+
initMessages
|
|
405637
|
+
}) => [
|
|
405595
405638
|
tables.tasks.insert({
|
|
405596
405639
|
id: id4,
|
|
405597
|
-
status: initMessage ? "pending-model" : "pending-input",
|
|
405640
|
+
status: initMessages ? initMessages.length > 0 ? "pending-model" : "pending-input" : initMessage ? "pending-model" : "pending-input",
|
|
405598
405641
|
parentId,
|
|
405599
405642
|
createdAt,
|
|
405600
405643
|
cwd,
|
|
405601
405644
|
updatedAt: createdAt
|
|
405602
405645
|
}),
|
|
405603
|
-
...
|
|
405646
|
+
...initMessages?.map((message) => {
|
|
405647
|
+
return tables.messages.insert({
|
|
405648
|
+
id: message.id,
|
|
405649
|
+
taskId: id4,
|
|
405650
|
+
data: message
|
|
405651
|
+
});
|
|
405652
|
+
}) ?? (initMessage ? [
|
|
405604
405653
|
tables.messages.insert({
|
|
405605
405654
|
id: initMessage.id,
|
|
405606
405655
|
taskId: id4,
|
|
@@ -405610,7 +405659,7 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405610
405659
|
parts: initMessage.parts
|
|
405611
405660
|
}
|
|
405612
405661
|
})
|
|
405613
|
-
] : []
|
|
405662
|
+
] : [])
|
|
405614
405663
|
],
|
|
405615
405664
|
"v1.TaskFailed": ({ id: id4, error: error42, updatedAt }) => [
|
|
405616
405665
|
tables.tasks.update({
|
|
@@ -405626,7 +405675,8 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405626
405675
|
git,
|
|
405627
405676
|
title,
|
|
405628
405677
|
updatedAt,
|
|
405629
|
-
modelId
|
|
405678
|
+
modelId,
|
|
405679
|
+
displayId
|
|
405630
405680
|
}) => [
|
|
405631
405681
|
tables.tasks.update({
|
|
405632
405682
|
status: "pending-model",
|
|
@@ -405634,7 +405684,8 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405634
405684
|
git,
|
|
405635
405685
|
title,
|
|
405636
405686
|
updatedAt,
|
|
405637
|
-
modelId
|
|
405687
|
+
modelId,
|
|
405688
|
+
displayId
|
|
405638
405689
|
}).where({ id: id4 }),
|
|
405639
405690
|
tables.messages.insert({
|
|
405640
405691
|
id: data.id,
|
|
@@ -405642,12 +405693,20 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405642
405693
|
data
|
|
405643
405694
|
}).onConflict("id", "replace")
|
|
405644
405695
|
],
|
|
405645
|
-
"v1.ChatStreamFinished": ({
|
|
405696
|
+
"v1.ChatStreamFinished": ({
|
|
405697
|
+
id: id4,
|
|
405698
|
+
data,
|
|
405699
|
+
totalTokens,
|
|
405700
|
+
status: status3,
|
|
405701
|
+
updatedAt,
|
|
405702
|
+
duration: duration7
|
|
405703
|
+
}) => [
|
|
405646
405704
|
tables.tasks.update({
|
|
405647
405705
|
totalTokens,
|
|
405648
405706
|
status: status3,
|
|
405649
405707
|
updatedAt,
|
|
405650
|
-
error: null
|
|
405708
|
+
error: null,
|
|
405709
|
+
lastStepDuration: duration7 ?? undefined
|
|
405651
405710
|
}).where({ id: id4 }),
|
|
405652
405711
|
tables.messages.insert({
|
|
405653
405712
|
id: data.id,
|
|
@@ -405655,11 +405714,12 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405655
405714
|
taskId: id4
|
|
405656
405715
|
}).onConflict("id", "replace")
|
|
405657
405716
|
],
|
|
405658
|
-
"v1.ChatStreamFailed": ({ id: id4, error: error42, updatedAt, data }) => [
|
|
405717
|
+
"v1.ChatStreamFailed": ({ id: id4, error: error42, updatedAt, data, duration: duration7 }) => [
|
|
405659
405718
|
tables.tasks.update({
|
|
405660
405719
|
status: "failed",
|
|
405661
405720
|
error: error42,
|
|
405662
|
-
updatedAt
|
|
405721
|
+
updatedAt,
|
|
405722
|
+
lastStepDuration: duration7 ?? undefined
|
|
405663
405723
|
}).where({ id: id4 }),
|
|
405664
405724
|
...data ? [
|
|
405665
405725
|
tables.messages.insert({
|
|
@@ -405677,7 +405737,11 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405677
405737
|
mimeType,
|
|
405678
405738
|
data: new Uint8Array(data),
|
|
405679
405739
|
createdAt
|
|
405680
|
-
}).onConflict("checksum", "ignore")
|
|
405740
|
+
}).onConflict("checksum", "ignore"),
|
|
405741
|
+
"v1.updateLineChanges": ({ id: id4, lineChanges, updatedAt }) => tables.tasks.update({
|
|
405742
|
+
lineChanges,
|
|
405743
|
+
updatedAt
|
|
405744
|
+
}).where({ id: id4 })
|
|
405681
405745
|
});
|
|
405682
405746
|
var state = exports_mod4.SQLite.makeState({ tables, materializers: materializers2 });
|
|
405683
405747
|
var schema6 = makeSchema({ events, state });
|
|
@@ -405916,7 +405980,7 @@ var {
|
|
|
405916
405980
|
// package.json
|
|
405917
405981
|
var package_default = {
|
|
405918
405982
|
name: "@getpochi/cli",
|
|
405919
|
-
version: "0.5.
|
|
405983
|
+
version: "0.5.97",
|
|
405920
405984
|
type: "module",
|
|
405921
405985
|
bin: {
|
|
405922
405986
|
pochi: "src/cli.ts"
|
|
@@ -417765,35 +417829,45 @@ async function parseAgentFile(filePath, readFileContent) {
|
|
|
417765
417829
|
var WorkflowFrontmatter = v4_default.object({
|
|
417766
417830
|
model: v4_default.string().optional()
|
|
417767
417831
|
});
|
|
417768
|
-
async function
|
|
417769
|
-
if (!content3)
|
|
417770
|
-
return { model: undefined };
|
|
417832
|
+
async function parseWorkflow(content3) {
|
|
417833
|
+
if (!content3) {
|
|
417834
|
+
return { frontmatter: { model: undefined }, content: "" };
|
|
417835
|
+
}
|
|
417771
417836
|
let vfile2;
|
|
417772
417837
|
try {
|
|
417773
|
-
vfile2 = await remark().use(remarkFrontmatter, [{ type: "yaml", marker: "-" }]).use(() => (_tree, file5) => matter2(file5)).
|
|
417838
|
+
vfile2 = await remark().use(remarkFrontmatter, [{ type: "yaml", marker: "-" }]).use(() => (_tree, file5) => matter2(file5)).use(() => (tree) => {
|
|
417839
|
+
if ("children" in tree && Array.isArray(tree.children)) {
|
|
417840
|
+
tree.children = tree.children.filter((node3) => node3.type !== "yaml");
|
|
417841
|
+
}
|
|
417842
|
+
}).process(content3);
|
|
417774
417843
|
} catch (error42) {
|
|
417775
417844
|
return {
|
|
417776
|
-
model: undefined,
|
|
417845
|
+
frontmatter: { model: undefined },
|
|
417846
|
+
content: content3,
|
|
417777
417847
|
error: "parseError",
|
|
417778
417848
|
message: toErrorMessage(error42)
|
|
417779
417849
|
};
|
|
417780
417850
|
}
|
|
417851
|
+
const contentWithoutFrontmatter = String(vfile2);
|
|
417781
417852
|
if (!vfile2.data.matter || Object.keys(vfile2.data.matter).length === 0) {
|
|
417782
417853
|
return {
|
|
417783
|
-
model: undefined
|
|
417854
|
+
frontmatter: { model: undefined },
|
|
417855
|
+
content: contentWithoutFrontmatter
|
|
417784
417856
|
};
|
|
417785
417857
|
}
|
|
417786
417858
|
const parseResult = WorkflowFrontmatter.safeParse(vfile2.data.matter);
|
|
417787
417859
|
if (!parseResult.success) {
|
|
417788
417860
|
return {
|
|
417789
|
-
model: undefined,
|
|
417861
|
+
frontmatter: { model: undefined },
|
|
417862
|
+
content: contentWithoutFrontmatter,
|
|
417790
417863
|
error: "validationError",
|
|
417791
417864
|
message: v4_default.prettifyError(parseResult.error)
|
|
417792
417865
|
};
|
|
417793
417866
|
}
|
|
417794
417867
|
const frontmatterData = parseResult.data;
|
|
417795
417868
|
return {
|
|
417796
|
-
model: frontmatterData.model
|
|
417869
|
+
frontmatter: { model: frontmatterData.model },
|
|
417870
|
+
content: contentWithoutFrontmatter
|
|
417797
417871
|
};
|
|
417798
417872
|
}
|
|
417799
417873
|
// ../common/src/tool-utils/notebook-utils.ts
|
|
@@ -419127,13 +419201,13 @@ async function readWorkflowsFromDir(dir2) {
|
|
|
419127
419201
|
const id4 = fileName.replace(/\.md$/, "");
|
|
419128
419202
|
const filePath = path11.join(dir2, fileName);
|
|
419129
419203
|
try {
|
|
419130
|
-
const
|
|
419131
|
-
const frontmatter2 = await
|
|
419204
|
+
const fileContent = await fs6.readFile(filePath, "utf-8");
|
|
419205
|
+
const { frontmatter: frontmatter2, content: content3 } = await parseWorkflow(fileContent);
|
|
419132
419206
|
workflows.push({
|
|
419133
419207
|
id: id4,
|
|
419134
419208
|
pathName: getWorkflowPath(id4),
|
|
419135
419209
|
content: content3,
|
|
419136
|
-
frontmatter:
|
|
419210
|
+
frontmatter: frontmatter2
|
|
419137
419211
|
});
|
|
419138
419212
|
} catch (e2) {}
|
|
419139
419213
|
}
|
|
@@ -446789,14 +446863,6 @@ function renderToolPart(part) {
|
|
|
446789
446863
|
error: errorText
|
|
446790
446864
|
};
|
|
446791
446865
|
}
|
|
446792
|
-
if (part.type === "tool-multiApplyDiff") {
|
|
446793
|
-
const { path: path26 = "unknown", edits = [] } = part.input || {};
|
|
446794
|
-
return {
|
|
446795
|
-
text: `\uD83D\uDD27 Applying ${edits.length} edits to ${source_default.bold(path26)}`,
|
|
446796
|
-
stop: hasError ? "fail" : "succeed",
|
|
446797
|
-
error: errorText
|
|
446798
|
-
};
|
|
446799
|
-
}
|
|
446800
446866
|
if (part.type === "tool-listFiles") {
|
|
446801
446867
|
const { path: path26 = ".", recursive = false } = part.input || {};
|
|
446802
446868
|
const recursiveText = recursive ? " recursively" : "";
|
|
@@ -446955,6 +447021,9 @@ function renderSubtaskMessages(messages2) {
|
|
|
446955
447021
|
return output2;
|
|
446956
447022
|
}
|
|
446957
447023
|
|
|
447024
|
+
// ../livekit/src/chat/live-chat-kit.ts
|
|
447025
|
+
init_effect();
|
|
447026
|
+
|
|
446958
447027
|
// ../livekit/src/task.ts
|
|
446959
447028
|
function toTaskStatus(message, finishReason) {
|
|
446960
447029
|
let lastStepStart = -1;
|
|
@@ -447096,8 +447165,12 @@ async function generateTitle2(store, taskId, model2, inputMessages, abortSignal)
|
|
|
447096
447165
|
}
|
|
447097
447166
|
];
|
|
447098
447167
|
const resp = await generateText({
|
|
447099
|
-
|
|
447100
|
-
|
|
447168
|
+
providerOptions: {
|
|
447169
|
+
pochi: {
|
|
447170
|
+
taskId,
|
|
447171
|
+
version: globalThis.POCHI_CLIENT,
|
|
447172
|
+
useCase: "generate-task-title"
|
|
447173
|
+
}
|
|
447101
447174
|
},
|
|
447102
447175
|
model: model2,
|
|
447103
447176
|
prompt: convertToModelMessages(formatters.llm(messages2, { removeSystemReminder: true })),
|
|
@@ -447175,8 +447248,12 @@ var makeRepairToolCall = (taskId, model2) => async ({ toolCall, inputSchema: inp
|
|
|
447175
447248
|
const tools = createClientTools();
|
|
447176
447249
|
const tool2 = tools[toolCall.toolName];
|
|
447177
447250
|
const { object: repairedArgs } = await generateObject({
|
|
447178
|
-
|
|
447179
|
-
|
|
447251
|
+
providerOptions: {
|
|
447252
|
+
pochi: {
|
|
447253
|
+
taskId,
|
|
447254
|
+
version: globalThis.POCHI_CLIENT,
|
|
447255
|
+
useCase: "repair-tool-call"
|
|
447256
|
+
}
|
|
447180
447257
|
},
|
|
447181
447258
|
model: model2,
|
|
447182
447259
|
schema: tool2.inputSchema,
|
|
@@ -447234,8 +447311,12 @@ async function createSummary(store, taskId, model2, abortSignal, inputMessages)
|
|
|
447234
447311
|
}
|
|
447235
447312
|
];
|
|
447236
447313
|
const resp = await generateText({
|
|
447237
|
-
|
|
447238
|
-
|
|
447314
|
+
providerOptions: {
|
|
447315
|
+
pochi: {
|
|
447316
|
+
taskId,
|
|
447317
|
+
version: globalThis.POCHI_CLIENT,
|
|
447318
|
+
useCase: "compact-task"
|
|
447319
|
+
}
|
|
447239
447320
|
},
|
|
447240
447321
|
model: model2,
|
|
447241
447322
|
prompt: convertToModelMessages(formatters.llm(messages2, {
|
|
@@ -447521,15 +447602,18 @@ function createNewTaskMiddleware(store, cwd2, parentTaskId, customAgents) {
|
|
|
447521
447602
|
cwd: cwd2,
|
|
447522
447603
|
parentId: parentTaskId,
|
|
447523
447604
|
createdAt: new Date,
|
|
447524
|
-
|
|
447525
|
-
|
|
447526
|
-
|
|
447527
|
-
|
|
447528
|
-
|
|
447529
|
-
|
|
447530
|
-
|
|
447531
|
-
|
|
447532
|
-
|
|
447605
|
+
initMessages: [
|
|
447606
|
+
{
|
|
447607
|
+
id: crypto.randomUUID(),
|
|
447608
|
+
role: "user",
|
|
447609
|
+
parts: [
|
|
447610
|
+
{
|
|
447611
|
+
type: "text",
|
|
447612
|
+
text: args2.prompt
|
|
447613
|
+
}
|
|
447614
|
+
]
|
|
447615
|
+
}
|
|
447616
|
+
]
|
|
447533
447617
|
}));
|
|
447534
447618
|
controller.enqueue({
|
|
447535
447619
|
...chunk4,
|
|
@@ -448039,8 +448123,12 @@ function createOutputSchemaMiddleware(taskId, model2, outputSchema2) {
|
|
|
448039
448123
|
async function ensureOutputSchema(taskId, model2, schema8, content3) {
|
|
448040
448124
|
try {
|
|
448041
448125
|
const { object: object4 } = await generateObject({
|
|
448042
|
-
|
|
448043
|
-
|
|
448126
|
+
providerOptions: {
|
|
448127
|
+
pochi: {
|
|
448128
|
+
taskId,
|
|
448129
|
+
version: globalThis.POCHI_CLIENT,
|
|
448130
|
+
useCase: "output-schema"
|
|
448131
|
+
}
|
|
448044
448132
|
},
|
|
448045
448133
|
model: model2,
|
|
448046
448134
|
schema: schema8,
|
|
@@ -448428,8 +448516,12 @@ class FlexibleChatTransport {
|
|
|
448428
448516
|
const preparedMessages = await prepareMessages(messages2, environment2);
|
|
448429
448517
|
const modelMessages = await resolvePromise(convertToModelMessages(formatters.llm(preparedMessages), { tools }));
|
|
448430
448518
|
const stream12 = streamText({
|
|
448431
|
-
|
|
448432
|
-
|
|
448519
|
+
providerOptions: {
|
|
448520
|
+
pochi: {
|
|
448521
|
+
taskId: chatId,
|
|
448522
|
+
client: globalThis.POCHI_CLIENT,
|
|
448523
|
+
useCase: "agent"
|
|
448524
|
+
}
|
|
448433
448525
|
},
|
|
448434
448526
|
system: prompts.system(environment2?.info?.customRules, this.customAgent, mcpInfo?.instructions),
|
|
448435
448527
|
messages: modelMessages,
|
|
@@ -448541,15 +448633,18 @@ var logger23 = getLogger("LiveChatKit");
|
|
|
448541
448633
|
|
|
448542
448634
|
class LiveChatKit {
|
|
448543
448635
|
taskId;
|
|
448636
|
+
displayId;
|
|
448544
448637
|
store;
|
|
448545
448638
|
chat;
|
|
448546
448639
|
transport;
|
|
448547
448640
|
onStreamStart;
|
|
448548
448641
|
onStreamFinish;
|
|
448549
448642
|
onStreamFailed;
|
|
448550
|
-
|
|
448643
|
+
compact;
|
|
448644
|
+
lastStepStartTimestamp;
|
|
448551
448645
|
constructor({
|
|
448552
448646
|
taskId,
|
|
448647
|
+
displayId,
|
|
448553
448648
|
abortSignal,
|
|
448554
448649
|
store,
|
|
448555
448650
|
chatClass,
|
|
@@ -448565,6 +448660,7 @@ class LiveChatKit {
|
|
|
448565
448660
|
...chatInit
|
|
448566
448661
|
}) {
|
|
448567
448662
|
this.taskId = taskId;
|
|
448663
|
+
this.displayId = displayId;
|
|
448568
448664
|
this.store = store;
|
|
448569
448665
|
this.onStreamStart = onStreamStart;
|
|
448570
448666
|
this.onStreamFinish = onStreamFinish;
|
|
@@ -448611,55 +448707,57 @@ class LiveChatKit {
|
|
|
448611
448707
|
}
|
|
448612
448708
|
}
|
|
448613
448709
|
if (onOverrideMessages) {
|
|
448614
|
-
await onOverrideMessages({
|
|
448710
|
+
await onOverrideMessages({
|
|
448711
|
+
store: this.store,
|
|
448712
|
+
taskId: this.taskId,
|
|
448713
|
+
messages: messages2,
|
|
448714
|
+
abortSignal: abortSignal2
|
|
448715
|
+
});
|
|
448615
448716
|
}
|
|
448616
448717
|
};
|
|
448617
|
-
this.
|
|
448618
|
-
const taskId2 = crypto.randomUUID();
|
|
448718
|
+
this.compact = async () => {
|
|
448619
448719
|
const { messages: messages2 } = this.chat;
|
|
448620
448720
|
const model2 = createModel2({ llm: getters.getLLM() });
|
|
448621
448721
|
const summary6 = await compactTask({
|
|
448622
448722
|
store: this.store,
|
|
448623
|
-
taskId:
|
|
448723
|
+
taskId: this.taskId,
|
|
448624
448724
|
model: model2,
|
|
448625
|
-
messages: messages2
|
|
448626
|
-
abortSignal
|
|
448725
|
+
messages: messages2
|
|
448627
448726
|
});
|
|
448628
448727
|
if (!summary6) {
|
|
448629
448728
|
throw new Error("Failed to compact task");
|
|
448630
448729
|
}
|
|
448631
|
-
|
|
448632
|
-
id: taskId2,
|
|
448633
|
-
cwd: this.task?.cwd || undefined,
|
|
448634
|
-
modelId: this.task?.modelId || undefined,
|
|
448635
|
-
createdAt: new Date,
|
|
448636
|
-
initMessage: {
|
|
448637
|
-
id: crypto.randomUUID(),
|
|
448638
|
-
parts: [
|
|
448639
|
-
{
|
|
448640
|
-
type: "text",
|
|
448641
|
-
text: summary6
|
|
448642
|
-
},
|
|
448643
|
-
{
|
|
448644
|
-
type: "text",
|
|
448645
|
-
text: "I've summarized the task and start a new task with the summary. Please analysis the current status, and use askFollowupQuestion with me to confirm the next steps"
|
|
448646
|
-
}
|
|
448647
|
-
]
|
|
448648
|
-
}
|
|
448649
|
-
}));
|
|
448650
|
-
return taskId2;
|
|
448730
|
+
return summary6;
|
|
448651
448731
|
};
|
|
448652
448732
|
}
|
|
448653
|
-
init(cwd2,
|
|
448654
|
-
|
|
448733
|
+
init(cwd2, options6) {
|
|
448734
|
+
let initMessages = undefined;
|
|
448735
|
+
if (options6) {
|
|
448736
|
+
if ("messages" in options6 && options6.messages) {
|
|
448737
|
+
initMessages = options6.messages;
|
|
448738
|
+
} else if ("parts" in options6 && options6.parts) {
|
|
448739
|
+
initMessages = [
|
|
448740
|
+
{
|
|
448741
|
+
id: crypto.randomUUID(),
|
|
448742
|
+
role: "user",
|
|
448743
|
+
parts: options6.parts
|
|
448744
|
+
}
|
|
448745
|
+
];
|
|
448746
|
+
} else if ("prompt" in options6 && options6.prompt) {
|
|
448747
|
+
initMessages = [
|
|
448748
|
+
{
|
|
448749
|
+
id: crypto.randomUUID(),
|
|
448750
|
+
role: "user",
|
|
448751
|
+
parts: [{ type: "text", text: options6.prompt }]
|
|
448752
|
+
}
|
|
448753
|
+
];
|
|
448754
|
+
}
|
|
448755
|
+
}
|
|
448655
448756
|
this.store.commit(events.taskInited({
|
|
448656
448757
|
id: this.taskId,
|
|
448657
448758
|
cwd: cwd2,
|
|
448658
448759
|
createdAt: new Date,
|
|
448659
|
-
|
|
448660
|
-
id: crypto.randomUUID(),
|
|
448661
|
-
parts: parts2
|
|
448662
|
-
} : undefined
|
|
448760
|
+
initMessages
|
|
448663
448761
|
}));
|
|
448664
448762
|
this.chat.messages = this.messages;
|
|
448665
448763
|
}
|
|
@@ -448720,8 +448818,10 @@ class LiveChatKit {
|
|
|
448720
448818
|
todos: environment2?.todos || [],
|
|
448721
448819
|
git: toTaskGitInfo(environment2?.workspace.gitStatus),
|
|
448722
448820
|
updatedAt: new Date,
|
|
448723
|
-
modelId: llm.id
|
|
448821
|
+
modelId: llm.id,
|
|
448822
|
+
displayId: this.displayId
|
|
448724
448823
|
}));
|
|
448824
|
+
this.lastStepStartTimestamp = Date.now();
|
|
448725
448825
|
this.onStreamStart?.();
|
|
448726
448826
|
}
|
|
448727
448827
|
};
|
|
@@ -448747,8 +448847,10 @@ class LiveChatKit {
|
|
|
448747
448847
|
status: status3,
|
|
448748
448848
|
data: message,
|
|
448749
448849
|
totalTokens: message.metadata.totalTokens,
|
|
448750
|
-
updatedAt: new Date
|
|
448850
|
+
updatedAt: new Date,
|
|
448851
|
+
duration: this.lastStepStartTimestamp ? exports_Duration.millis(Date.now() - this.lastStepStartTimestamp) : undefined
|
|
448751
448852
|
}));
|
|
448853
|
+
this.clearLastStepTimestamp();
|
|
448752
448854
|
this.onStreamFinish?.({
|
|
448753
448855
|
id: this.taskId,
|
|
448754
448856
|
cwd: this.task?.cwd ?? null,
|
|
@@ -448756,6 +448858,9 @@ class LiveChatKit {
|
|
|
448756
448858
|
messages: [...this.chat.messages]
|
|
448757
448859
|
});
|
|
448758
448860
|
};
|
|
448861
|
+
clearLastStepTimestamp = () => {
|
|
448862
|
+
this.lastStepStartTimestamp = undefined;
|
|
448863
|
+
};
|
|
448759
448864
|
onError = (error46) => {
|
|
448760
448865
|
logger23.error("onError", error46);
|
|
448761
448866
|
const lastMessage = this.chat.messages.at(-1) || null;
|
|
@@ -448763,8 +448868,10 @@ class LiveChatKit {
|
|
|
448763
448868
|
id: this.taskId,
|
|
448764
448869
|
error: toTaskError(error46),
|
|
448765
448870
|
data: lastMessage,
|
|
448766
|
-
updatedAt: new Date
|
|
448871
|
+
updatedAt: new Date,
|
|
448872
|
+
duration: this.lastStepStartTimestamp ? exports_Duration.millis(Date.now() - this.lastStepStartTimestamp) : undefined
|
|
448767
448873
|
}));
|
|
448874
|
+
this.clearLastStepTimestamp();
|
|
448768
448875
|
this.onStreamFailed?.({
|
|
448769
448876
|
cwd: this.task?.cwd ?? null,
|
|
448770
448877
|
error: error46,
|
|
@@ -449033,13 +449140,6 @@ async function parseDiffAndApply(fileContent3, searchContent, replaceContent, ex
|
|
|
449033
449140
|
}
|
|
449034
449141
|
return result2;
|
|
449035
449142
|
}
|
|
449036
|
-
async function processMultipleDiffs(fileContent3, edits) {
|
|
449037
|
-
let updatedContent = fileContent3;
|
|
449038
|
-
for (const edit of edits) {
|
|
449039
|
-
updatedContent = await parseDiffAndApply(updatedContent, edit.searchContent, edit.replaceContent, edit.expectedReplacements);
|
|
449040
|
-
}
|
|
449041
|
-
return updatedContent;
|
|
449042
|
-
}
|
|
449043
449143
|
var searchContentExact = (originalContent, searchContent) => {
|
|
449044
449144
|
const normalizedOriginal = normalize6(originalContent);
|
|
449045
449145
|
const normalizedSearch = normalize6(searchContent);
|
|
@@ -449333,19 +449433,6 @@ var listFiles3 = () => async ({ path: dirPath, recursive }, { abortSignal, cwd:
|
|
|
449333
449433
|
});
|
|
449334
449434
|
};
|
|
449335
449435
|
|
|
449336
|
-
// src/tools/multi-apply-diff.ts
|
|
449337
|
-
import * as fs15 from "node:fs/promises";
|
|
449338
|
-
var multiApplyDiff2 = () => async ({ path: path28, edits }, { cwd: cwd2 }) => {
|
|
449339
|
-
const fileUri = resolvePath(path28, cwd2);
|
|
449340
|
-
await ensureFileDirectoryExists(fileUri);
|
|
449341
|
-
const fileBuffer = await fs15.readFile(fileUri);
|
|
449342
|
-
validateTextFile(fileBuffer);
|
|
449343
|
-
const fileContent3 = fileBuffer.toString();
|
|
449344
|
-
const updatedContent = await processMultipleDiffs(fileContent3, edits);
|
|
449345
|
-
await fs15.writeFile(fileUri, updatedContent);
|
|
449346
|
-
return { success: true };
|
|
449347
|
-
};
|
|
449348
|
-
|
|
449349
449436
|
// src/tools/new-task.ts
|
|
449350
449437
|
var newTask = (options6) => async ({ _meta, agentType }) => {
|
|
449351
449438
|
const taskId = _meta?.uid || crypto.randomUUID();
|
|
@@ -449380,10 +449467,10 @@ var newTask = (options6) => async ({ _meta, agentType }) => {
|
|
|
449380
449467
|
};
|
|
449381
449468
|
|
|
449382
449469
|
// src/tools/read-file.ts
|
|
449383
|
-
import * as
|
|
449384
|
-
var
|
|
449470
|
+
import * as fs15 from "node:fs/promises";
|
|
449471
|
+
var readFile11 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2, contentType }) => {
|
|
449385
449472
|
const resolvedPath = resolvePath(path28, cwd2);
|
|
449386
|
-
const fileBuffer = await
|
|
449473
|
+
const fileBuffer = await fs15.readFile(resolvedPath);
|
|
449387
449474
|
const isPlainTextFile2 = isPlainText(fileBuffer);
|
|
449388
449475
|
if (contentType && contentType.length > 0 && !isPlainTextFile2) {
|
|
449389
449476
|
return readMediaFile(resolvedPath, fileBuffer, contentType);
|
|
@@ -449401,11 +449488,11 @@ var readFile12 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2,
|
|
|
449401
449488
|
};
|
|
449402
449489
|
|
|
449403
449490
|
// src/tools/search-files.ts
|
|
449404
|
-
import * as
|
|
449491
|
+
import * as fs16 from "node:fs";
|
|
449405
449492
|
var logger25 = getLogger("searchFiles");
|
|
449406
449493
|
var searchFiles2 = (context15) => async ({ path: path28, regex: regex3, filePattern }, { abortSignal, cwd: cwd2 }) => {
|
|
449407
449494
|
const rgPath = context15.rg;
|
|
449408
|
-
if (!rgPath || !
|
|
449495
|
+
if (!rgPath || !fs16.existsSync(rgPath)) {
|
|
449409
449496
|
logger25.error("Ripgrep not found at path", rgPath);
|
|
449410
449497
|
throw new Error(`Ripgrep not found at path: ${rgPath}`);
|
|
449411
449498
|
}
|
|
@@ -449420,27 +449507,26 @@ var todoWrite2 = (_options) => async () => {
|
|
|
449420
449507
|
};
|
|
449421
449508
|
|
|
449422
449509
|
// src/tools/write-to-file.ts
|
|
449423
|
-
import * as
|
|
449510
|
+
import * as fs17 from "node:fs/promises";
|
|
449424
449511
|
import * as nodePath from "node:path";
|
|
449425
449512
|
var writeToFile2 = () => async ({ path: path28, content: content3 }, { cwd: cwd2 }) => {
|
|
449426
449513
|
const filePath = resolvePath(path28, cwd2);
|
|
449427
449514
|
if (!await isFileExists(filePath)) {
|
|
449428
449515
|
const dirPath = nodePath.dirname(filePath);
|
|
449429
|
-
await
|
|
449516
|
+
await fs17.mkdir(dirPath, { recursive: true });
|
|
449430
449517
|
}
|
|
449431
449518
|
const processedContent = fixCodeGenerationOutput(content3);
|
|
449432
|
-
await
|
|
449519
|
+
await fs17.writeFile(filePath, processedContent);
|
|
449433
449520
|
return { success: true };
|
|
449434
449521
|
};
|
|
449435
449522
|
|
|
449436
449523
|
// src/tools/index.ts
|
|
449437
449524
|
var ToolMap = {
|
|
449438
|
-
readFile:
|
|
449525
|
+
readFile: readFile11,
|
|
449439
449526
|
applyDiff: applyDiff2,
|
|
449440
449527
|
editNotebook: editNotebook2,
|
|
449441
449528
|
globFiles: globFiles3,
|
|
449442
449529
|
listFiles: listFiles3,
|
|
449443
|
-
multiApplyDiff: multiApplyDiff2,
|
|
449444
449530
|
newTask,
|
|
449445
449531
|
todoWrite: todoWrite2,
|
|
449446
449532
|
writeToFile: writeToFile2,
|
|
@@ -449560,7 +449646,7 @@ class TaskRunner {
|
|
|
449560
449646
|
parts: options6.parts
|
|
449561
449647
|
});
|
|
449562
449648
|
} else {
|
|
449563
|
-
this.chatKit.init(options6.cwd, options6.parts);
|
|
449649
|
+
this.chatKit.init(options6.cwd, { parts: options6.parts });
|
|
449564
449650
|
}
|
|
449565
449651
|
}
|
|
449566
449652
|
this.taskId = options6.uid;
|
|
@@ -449981,6 +450067,7 @@ function registerUpgradeCommand(program5) {
|
|
|
449981
450067
|
}
|
|
449982
450068
|
// src/cli.ts
|
|
449983
450069
|
var logger27 = getLogger("Pochi");
|
|
450070
|
+
globalThis.POCHI_CLIENT = `PochiCli/${package_default.version}`;
|
|
449984
450071
|
logger27.debug(`pochi v${package_default.version}`);
|
|
449985
450072
|
var parsePositiveInt = (input2) => {
|
|
449986
450073
|
if (!input2) {
|
|
@@ -450005,7 +450092,7 @@ var program5 = new Command().name("pochi").description(`${source_default.bold("P
|
|
|
450005
450092
|
for (const attachmentPath of attachments) {
|
|
450006
450093
|
try {
|
|
450007
450094
|
const absolutePath = path28.resolve(process.cwd(), attachmentPath);
|
|
450008
|
-
const buffer4 = await
|
|
450095
|
+
const buffer4 = await fs18.readFile(absolutePath);
|
|
450009
450096
|
const mimeType = getMimeType(attachmentPath);
|
|
450010
450097
|
const dataUrl = await fileToUri(store, new File([buffer4], attachmentPath, {
|
|
450011
450098
|
type: mimeType
|