@getpochi/cli 0.5.95 → 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 +433 -268
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -113843,14 +113843,14 @@ var init_ShardManager = __esm(() => {
|
|
|
113843
113843
|
unassignedShards.unsafeUpdate(stats.unassigned, []);
|
|
113844
113844
|
}
|
|
113845
113845
|
updateShardMetrics();
|
|
113846
|
-
function
|
|
113846
|
+
function withRetry2(effect4) {
|
|
113847
113847
|
return effect4.pipe(retry2({
|
|
113848
113848
|
schedule: spaced2(config5.persistRetryCount),
|
|
113849
113849
|
times: config5.persistRetryCount
|
|
113850
113850
|
}), ignore2);
|
|
113851
113851
|
}
|
|
113852
|
-
const persistRunners = unsafeMakeSemaphore2(1).withPermits(1)(
|
|
113853
|
-
const persistAssignments = unsafeMakeSemaphore2(1).withPermits(1)(
|
|
113852
|
+
const persistRunners = unsafeMakeSemaphore2(1).withPermits(1)(withRetry2(suspend3(() => storage.saveRunners(map4(state3.allRunners, ([address, runner]) => [address, runner.runner])))));
|
|
113853
|
+
const persistAssignments = unsafeMakeSemaphore2(1).withPermits(1)(withRetry2(suspend3(() => storage.saveAssignments(state3.assignments))));
|
|
113854
113854
|
const notifyUnhealthyRunner = fnUntraced2(function* (address) {
|
|
113855
113855
|
if (!has6(state3.allRunners, address))
|
|
113856
113856
|
return;
|
|
@@ -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({
|
|
@@ -391690,6 +391665,28 @@ var VendorId = "pochi";
|
|
|
391690
391665
|
|
|
391691
391666
|
// ../vendor-pochi/src/vendor.ts
|
|
391692
391667
|
var logger3 = getLogger("PochiVendor");
|
|
391668
|
+
async function withRetry(fn, options = {}) {
|
|
391669
|
+
const {
|
|
391670
|
+
maxRetries = 3,
|
|
391671
|
+
initialDelay = 1000,
|
|
391672
|
+
maxDelay = 1e4,
|
|
391673
|
+
delayMultiplier = 2
|
|
391674
|
+
} = options;
|
|
391675
|
+
let lastError;
|
|
391676
|
+
let delay2 = initialDelay;
|
|
391677
|
+
for (let attempt = 0;attempt <= maxRetries; attempt++) {
|
|
391678
|
+
try {
|
|
391679
|
+
return await fn();
|
|
391680
|
+
} catch (error40) {
|
|
391681
|
+
lastError = error40 instanceof Error ? error40 : new Error(String(error40));
|
|
391682
|
+
if (attempt < maxRetries) {
|
|
391683
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay2));
|
|
391684
|
+
delay2 = Math.min(delay2 * delayMultiplier, maxDelay);
|
|
391685
|
+
}
|
|
391686
|
+
}
|
|
391687
|
+
}
|
|
391688
|
+
throw lastError;
|
|
391689
|
+
}
|
|
391693
391690
|
|
|
391694
391691
|
class Pochi extends VendorBase {
|
|
391695
391692
|
cachedModels;
|
|
@@ -391702,7 +391699,14 @@ class Pochi extends VendorBase {
|
|
|
391702
391699
|
async fetchModels() {
|
|
391703
391700
|
if (!this.cachedModels) {
|
|
391704
391701
|
const apiClient = hc(getServerBaseUrl());
|
|
391705
|
-
const data = await
|
|
391702
|
+
const data = await withRetry(async () => {
|
|
391703
|
+
const response = await apiClient.api.models.$get();
|
|
391704
|
+
return response.json();
|
|
391705
|
+
}, {
|
|
391706
|
+
maxRetries: 3,
|
|
391707
|
+
initialDelay: 1000
|
|
391708
|
+
}).catch((error40) => {
|
|
391709
|
+
logger3.error(`Failed to fetch models: ${error40.message}`);
|
|
391706
391710
|
return [];
|
|
391707
391711
|
});
|
|
391708
391712
|
this.cachedModels = Object.fromEntries(data.map((x) => [
|
|
@@ -393124,7 +393128,19 @@ function createPochiModel({
|
|
|
393124
393128
|
provider: "pochi",
|
|
393125
393129
|
modelId: modelId || "<default>",
|
|
393126
393130
|
supportedUrls: {},
|
|
393127
|
-
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
|
+
}
|
|
393128
393144
|
const apiClient = createApiClient(getCredentials);
|
|
393129
393145
|
const resp = await apiClient.api.chat.$post({
|
|
393130
393146
|
json: {
|
|
@@ -393135,7 +393151,7 @@ function createPochiModel({
|
|
|
393135
393151
|
}
|
|
393136
393152
|
}
|
|
393137
393153
|
}, {
|
|
393138
|
-
headers
|
|
393154
|
+
headers,
|
|
393139
393155
|
init: {
|
|
393140
393156
|
signal: abortSignal
|
|
393141
393157
|
}
|
|
@@ -393148,9 +393164,16 @@ function createPochiModel({
|
|
|
393148
393164
|
abortSignal,
|
|
393149
393165
|
stopSequences,
|
|
393150
393166
|
tools,
|
|
393151
|
-
|
|
393167
|
+
providerOptions
|
|
393152
393168
|
}) => {
|
|
393153
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
|
+
}
|
|
393154
393177
|
const data = {
|
|
393155
393178
|
model: modelId,
|
|
393156
393179
|
callOptions: {
|
|
@@ -393162,7 +393185,7 @@ function createPochiModel({
|
|
|
393162
393185
|
const resp = await apiClient.api.chat.stream.$post({
|
|
393163
393186
|
json: data
|
|
393164
393187
|
}, {
|
|
393165
|
-
headers
|
|
393188
|
+
headers,
|
|
393166
393189
|
init: {
|
|
393167
393190
|
signal: abortSignal
|
|
393168
393191
|
}
|
|
@@ -393172,8 +393195,15 @@ function createPochiModel({
|
|
|
393172
393195
|
resp.headers.forEach((value2, key) => {
|
|
393173
393196
|
responseHeaders[key] = value2;
|
|
393174
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
|
+
}
|
|
393175
393205
|
throw new APICallError({
|
|
393176
|
-
message
|
|
393206
|
+
message,
|
|
393177
393207
|
statusCode: resp.status,
|
|
393178
393208
|
url: apiClient.api.chat.stream.$url().toString(),
|
|
393179
393209
|
requestBodyValues: data,
|
|
@@ -403592,7 +403622,7 @@ function createPatchedFetch3(getCredentials) {
|
|
|
403592
403622
|
registerModel(VendorId7, createQwenModel);
|
|
403593
403623
|
|
|
403594
403624
|
// src/cli.ts
|
|
403595
|
-
import
|
|
403625
|
+
import fs18 from "fs/promises";
|
|
403596
403626
|
import path28 from "path";
|
|
403597
403627
|
|
|
403598
403628
|
// ../../node_modules/@commander-js/extra-typings/esm.mjs
|
|
@@ -405368,6 +405398,12 @@ var Todo2 = exports_Schema2.Struct({
|
|
|
405368
405398
|
priority: exports_Schema2.Literal("low", "medium", "high")
|
|
405369
405399
|
});
|
|
405370
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
|
+
});
|
|
405371
405407
|
var TaskStatus = exports_Schema2.Literal("completed", "pending-input", "failed", "pending-tool", "pending-model");
|
|
405372
405408
|
var TaskError = exports_Schema2.Union(exports_Schema2.Struct({
|
|
405373
405409
|
kind: exports_Schema2.Literal("InternalError"),
|
|
@@ -405403,9 +405439,13 @@ var taskFullFields = {
|
|
|
405403
405439
|
title: exports_Schema2.optional(exports_Schema2.String),
|
|
405404
405440
|
status: TaskStatus,
|
|
405405
405441
|
todos: Todos,
|
|
405442
|
+
pendingToolCalls: exports_Schema2.optional(ToolCalls),
|
|
405406
405443
|
totalTokens: exports_Schema2.optional(exports_Schema2.Number),
|
|
405444
|
+
lineChanges: exports_Schema2.optional(LineChanges),
|
|
405445
|
+
lastStepDuration: exports_Schema2.optional(exports_Schema2.DurationFromMillis),
|
|
405407
405446
|
error: exports_Schema2.optional(TaskError),
|
|
405408
|
-
updatedAt: exports_Schema2.Date
|
|
405447
|
+
updatedAt: exports_Schema2.Date,
|
|
405448
|
+
displayId: exports_Schema2.optional(exports_Schema2.Number)
|
|
405409
405449
|
};
|
|
405410
405450
|
|
|
405411
405451
|
// ../livekit/src/livestore/default-schema.ts
|
|
@@ -405431,11 +405471,24 @@ var tables = {
|
|
|
405431
405471
|
nullable: true,
|
|
405432
405472
|
schema: Git
|
|
405433
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
|
+
}),
|
|
405434
405482
|
totalTokens: exports_mod4.SQLite.integer({ nullable: true }),
|
|
405483
|
+
lastStepDuration: exports_mod4.SQLite.integer({
|
|
405484
|
+
nullable: true,
|
|
405485
|
+
schema: exports_Schema2.DurationFromMillis
|
|
405486
|
+
}),
|
|
405435
405487
|
error: exports_mod4.SQLite.json({ schema: TaskError, nullable: true }),
|
|
405436
405488
|
createdAt: exports_mod4.SQLite.integer({ schema: exports_Schema2.DateFromNumber }),
|
|
405437
405489
|
updatedAt: exports_mod4.SQLite.integer({ schema: exports_Schema2.DateFromNumber }),
|
|
405438
|
-
modelId: exports_mod4.SQLite.text({ nullable: true })
|
|
405490
|
+
modelId: exports_mod4.SQLite.text({ nullable: true }),
|
|
405491
|
+
displayId: exports_mod4.SQLite.integer({ nullable: true })
|
|
405439
405492
|
},
|
|
405440
405493
|
indexes: [
|
|
405441
405494
|
{
|
|
@@ -405482,6 +405535,7 @@ var events = {
|
|
|
405482
405535
|
name: "v1.TaskInited",
|
|
405483
405536
|
schema: exports_Schema2.Struct({
|
|
405484
405537
|
...taskInitFields,
|
|
405538
|
+
initMessages: exports_Schema2.optional(exports_Schema2.Array(DBMessage)),
|
|
405485
405539
|
initMessage: exports_Schema2.optional(exports_Schema2.Struct({
|
|
405486
405540
|
id: exports_Schema2.String,
|
|
405487
405541
|
parts: exports_Schema2.Array(DBUIPart)
|
|
@@ -405505,7 +405559,8 @@ var events = {
|
|
|
405505
405559
|
title: exports_Schema2.optional(exports_Schema2.String),
|
|
405506
405560
|
git: exports_Schema2.optional(Git),
|
|
405507
405561
|
updatedAt: exports_Schema2.Date,
|
|
405508
|
-
modelId: exports_Schema2.optional(exports_Schema2.String)
|
|
405562
|
+
modelId: exports_Schema2.optional(exports_Schema2.String),
|
|
405563
|
+
displayId: exports_Schema2.optional(exports_Schema2.Number)
|
|
405509
405564
|
})
|
|
405510
405565
|
}),
|
|
405511
405566
|
chatStreamFinished: exports_events.synced({
|
|
@@ -405515,7 +405570,8 @@ var events = {
|
|
|
405515
405570
|
data: DBMessage,
|
|
405516
405571
|
totalTokens: exports_Schema2.NullOr(exports_Schema2.Number),
|
|
405517
405572
|
status: TaskStatus,
|
|
405518
|
-
updatedAt: exports_Schema2.Date
|
|
405573
|
+
updatedAt: exports_Schema2.Date,
|
|
405574
|
+
duration: exports_Schema2.optional(exports_Schema2.DurationFromMillis)
|
|
405519
405575
|
})
|
|
405520
405576
|
}),
|
|
405521
405577
|
chatStreamFailed: exports_events.synced({
|
|
@@ -405524,7 +405580,8 @@ var events = {
|
|
|
405524
405580
|
id: exports_Schema2.String,
|
|
405525
405581
|
error: TaskError,
|
|
405526
405582
|
data: exports_Schema2.NullOr(DBMessage),
|
|
405527
|
-
updatedAt: exports_Schema2.Date
|
|
405583
|
+
updatedAt: exports_Schema2.Date,
|
|
405584
|
+
duration: exports_Schema2.optional(exports_Schema2.DurationFromMillis)
|
|
405528
405585
|
})
|
|
405529
405586
|
}),
|
|
405530
405587
|
updateShareId: exports_events.synced({
|
|
@@ -405559,19 +405616,40 @@ var events = {
|
|
|
405559
405616
|
mimeType: exports_Schema2.String,
|
|
405560
405617
|
data: exports_Schema2.Uint8Array
|
|
405561
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
|
+
})
|
|
405562
405627
|
})
|
|
405563
405628
|
};
|
|
405564
405629
|
var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
405565
|
-
"v1.TaskInited": ({
|
|
405630
|
+
"v1.TaskInited": ({
|
|
405631
|
+
id: id4,
|
|
405632
|
+
parentId,
|
|
405633
|
+
createdAt,
|
|
405634
|
+
cwd,
|
|
405635
|
+
initMessage,
|
|
405636
|
+
initMessages
|
|
405637
|
+
}) => [
|
|
405566
405638
|
tables.tasks.insert({
|
|
405567
405639
|
id: id4,
|
|
405568
|
-
status: initMessage ? "pending-model" : "pending-input",
|
|
405640
|
+
status: initMessages ? initMessages.length > 0 ? "pending-model" : "pending-input" : initMessage ? "pending-model" : "pending-input",
|
|
405569
405641
|
parentId,
|
|
405570
405642
|
createdAt,
|
|
405571
405643
|
cwd,
|
|
405572
405644
|
updatedAt: createdAt
|
|
405573
405645
|
}),
|
|
405574
|
-
...
|
|
405646
|
+
...initMessages?.map((message) => {
|
|
405647
|
+
return tables.messages.insert({
|
|
405648
|
+
id: message.id,
|
|
405649
|
+
taskId: id4,
|
|
405650
|
+
data: message
|
|
405651
|
+
});
|
|
405652
|
+
}) ?? (initMessage ? [
|
|
405575
405653
|
tables.messages.insert({
|
|
405576
405654
|
id: initMessage.id,
|
|
405577
405655
|
taskId: id4,
|
|
@@ -405581,7 +405659,7 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405581
405659
|
parts: initMessage.parts
|
|
405582
405660
|
}
|
|
405583
405661
|
})
|
|
405584
|
-
] : []
|
|
405662
|
+
] : [])
|
|
405585
405663
|
],
|
|
405586
405664
|
"v1.TaskFailed": ({ id: id4, error: error42, updatedAt }) => [
|
|
405587
405665
|
tables.tasks.update({
|
|
@@ -405597,7 +405675,8 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405597
405675
|
git,
|
|
405598
405676
|
title,
|
|
405599
405677
|
updatedAt,
|
|
405600
|
-
modelId
|
|
405678
|
+
modelId,
|
|
405679
|
+
displayId
|
|
405601
405680
|
}) => [
|
|
405602
405681
|
tables.tasks.update({
|
|
405603
405682
|
status: "pending-model",
|
|
@@ -405605,7 +405684,8 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405605
405684
|
git,
|
|
405606
405685
|
title,
|
|
405607
405686
|
updatedAt,
|
|
405608
|
-
modelId
|
|
405687
|
+
modelId,
|
|
405688
|
+
displayId
|
|
405609
405689
|
}).where({ id: id4 }),
|
|
405610
405690
|
tables.messages.insert({
|
|
405611
405691
|
id: data.id,
|
|
@@ -405613,12 +405693,20 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405613
405693
|
data
|
|
405614
405694
|
}).onConflict("id", "replace")
|
|
405615
405695
|
],
|
|
405616
|
-
"v1.ChatStreamFinished": ({
|
|
405696
|
+
"v1.ChatStreamFinished": ({
|
|
405697
|
+
id: id4,
|
|
405698
|
+
data,
|
|
405699
|
+
totalTokens,
|
|
405700
|
+
status: status3,
|
|
405701
|
+
updatedAt,
|
|
405702
|
+
duration: duration7
|
|
405703
|
+
}) => [
|
|
405617
405704
|
tables.tasks.update({
|
|
405618
405705
|
totalTokens,
|
|
405619
405706
|
status: status3,
|
|
405620
405707
|
updatedAt,
|
|
405621
|
-
error: null
|
|
405708
|
+
error: null,
|
|
405709
|
+
lastStepDuration: duration7 ?? undefined
|
|
405622
405710
|
}).where({ id: id4 }),
|
|
405623
405711
|
tables.messages.insert({
|
|
405624
405712
|
id: data.id,
|
|
@@ -405626,11 +405714,12 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405626
405714
|
taskId: id4
|
|
405627
405715
|
}).onConflict("id", "replace")
|
|
405628
405716
|
],
|
|
405629
|
-
"v1.ChatStreamFailed": ({ id: id4, error: error42, updatedAt, data }) => [
|
|
405717
|
+
"v1.ChatStreamFailed": ({ id: id4, error: error42, updatedAt, data, duration: duration7 }) => [
|
|
405630
405718
|
tables.tasks.update({
|
|
405631
405719
|
status: "failed",
|
|
405632
405720
|
error: error42,
|
|
405633
|
-
updatedAt
|
|
405721
|
+
updatedAt,
|
|
405722
|
+
lastStepDuration: duration7 ?? undefined
|
|
405634
405723
|
}).where({ id: id4 }),
|
|
405635
405724
|
...data ? [
|
|
405636
405725
|
tables.messages.insert({
|
|
@@ -405648,7 +405737,11 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
405648
405737
|
mimeType,
|
|
405649
405738
|
data: new Uint8Array(data),
|
|
405650
405739
|
createdAt
|
|
405651
|
-
}).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 })
|
|
405652
405745
|
});
|
|
405653
405746
|
var state = exports_mod4.SQLite.makeState({ tables, materializers: materializers2 });
|
|
405654
405747
|
var schema6 = makeSchema({ events, state });
|
|
@@ -405887,7 +405980,7 @@ var {
|
|
|
405887
405980
|
// package.json
|
|
405888
405981
|
var package_default = {
|
|
405889
405982
|
name: "@getpochi/cli",
|
|
405890
|
-
version: "0.5.
|
|
405983
|
+
version: "0.5.97",
|
|
405891
405984
|
type: "module",
|
|
405892
405985
|
bin: {
|
|
405893
405986
|
pochi: "src/cli.ts"
|
|
@@ -417736,35 +417829,45 @@ async function parseAgentFile(filePath, readFileContent) {
|
|
|
417736
417829
|
var WorkflowFrontmatter = v4_default.object({
|
|
417737
417830
|
model: v4_default.string().optional()
|
|
417738
417831
|
});
|
|
417739
|
-
async function
|
|
417740
|
-
if (!content3)
|
|
417741
|
-
return { model: undefined };
|
|
417832
|
+
async function parseWorkflow(content3) {
|
|
417833
|
+
if (!content3) {
|
|
417834
|
+
return { frontmatter: { model: undefined }, content: "" };
|
|
417835
|
+
}
|
|
417742
417836
|
let vfile2;
|
|
417743
417837
|
try {
|
|
417744
|
-
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);
|
|
417745
417843
|
} catch (error42) {
|
|
417746
417844
|
return {
|
|
417747
|
-
model: undefined,
|
|
417845
|
+
frontmatter: { model: undefined },
|
|
417846
|
+
content: content3,
|
|
417748
417847
|
error: "parseError",
|
|
417749
417848
|
message: toErrorMessage(error42)
|
|
417750
417849
|
};
|
|
417751
417850
|
}
|
|
417851
|
+
const contentWithoutFrontmatter = String(vfile2);
|
|
417752
417852
|
if (!vfile2.data.matter || Object.keys(vfile2.data.matter).length === 0) {
|
|
417753
417853
|
return {
|
|
417754
|
-
model: undefined
|
|
417854
|
+
frontmatter: { model: undefined },
|
|
417855
|
+
content: contentWithoutFrontmatter
|
|
417755
417856
|
};
|
|
417756
417857
|
}
|
|
417757
417858
|
const parseResult = WorkflowFrontmatter.safeParse(vfile2.data.matter);
|
|
417758
417859
|
if (!parseResult.success) {
|
|
417759
417860
|
return {
|
|
417760
|
-
model: undefined,
|
|
417861
|
+
frontmatter: { model: undefined },
|
|
417862
|
+
content: contentWithoutFrontmatter,
|
|
417761
417863
|
error: "validationError",
|
|
417762
417864
|
message: v4_default.prettifyError(parseResult.error)
|
|
417763
417865
|
};
|
|
417764
417866
|
}
|
|
417765
417867
|
const frontmatterData = parseResult.data;
|
|
417766
417868
|
return {
|
|
417767
|
-
model: frontmatterData.model
|
|
417869
|
+
frontmatter: { model: frontmatterData.model },
|
|
417870
|
+
content: contentWithoutFrontmatter
|
|
417768
417871
|
};
|
|
417769
417872
|
}
|
|
417770
417873
|
// ../common/src/tool-utils/notebook-utils.ts
|
|
@@ -419098,13 +419201,13 @@ async function readWorkflowsFromDir(dir2) {
|
|
|
419098
419201
|
const id4 = fileName.replace(/\.md$/, "");
|
|
419099
419202
|
const filePath = path11.join(dir2, fileName);
|
|
419100
419203
|
try {
|
|
419101
|
-
const
|
|
419102
|
-
const frontmatter2 = await
|
|
419204
|
+
const fileContent = await fs6.readFile(filePath, "utf-8");
|
|
419205
|
+
const { frontmatter: frontmatter2, content: content3 } = await parseWorkflow(fileContent);
|
|
419103
419206
|
workflows.push({
|
|
419104
419207
|
id: id4,
|
|
419105
419208
|
pathName: getWorkflowPath(id4),
|
|
419106
419209
|
content: content3,
|
|
419107
|
-
frontmatter:
|
|
419210
|
+
frontmatter: frontmatter2
|
|
419108
419211
|
});
|
|
419109
419212
|
} catch (e2) {}
|
|
419110
419213
|
}
|
|
@@ -419134,20 +419237,43 @@ class JsonRenderer {
|
|
|
419134
419237
|
state;
|
|
419135
419238
|
outputMessageIds = new Set;
|
|
419136
419239
|
lastMessageCount = 0;
|
|
419137
|
-
|
|
419240
|
+
mode;
|
|
419241
|
+
constructor(store, state3, options4 = { mode: "full" }) {
|
|
419138
419242
|
this.store = store;
|
|
419139
419243
|
this.state = state3;
|
|
419140
|
-
this.
|
|
419141
|
-
|
|
419142
|
-
|
|
419143
|
-
this.lastMessageCount
|
|
419144
|
-
|
|
419145
|
-
|
|
419244
|
+
this.mode = options4.mode;
|
|
419245
|
+
if (this.mode === "full") {
|
|
419246
|
+
this.state.signal.messages.subscribe((messages) => {
|
|
419247
|
+
if (messages.length > this.lastMessageCount) {
|
|
419248
|
+
this.outputMessages(messages.slice(0, -1));
|
|
419249
|
+
this.lastMessageCount = messages.length;
|
|
419250
|
+
}
|
|
419251
|
+
});
|
|
419252
|
+
}
|
|
419146
419253
|
}
|
|
419147
419254
|
shutdown() {
|
|
419148
|
-
|
|
419255
|
+
if (this.mode === "result-only") {
|
|
419256
|
+
this.outputResult();
|
|
419257
|
+
} else {
|
|
419258
|
+
this.outputMessages(this.state.signal.messages.value);
|
|
419259
|
+
}
|
|
419149
419260
|
}
|
|
419150
419261
|
renderSubTask(_task) {}
|
|
419262
|
+
outputResult() {
|
|
419263
|
+
const messages = this.state.signal.messages.value;
|
|
419264
|
+
const lastMessage = messages.at(-1);
|
|
419265
|
+
if (lastMessage?.role === "assistant") {
|
|
419266
|
+
for (const part of lastMessage.parts || []) {
|
|
419267
|
+
if (isToolUIPart(part) && part.type === "tool-attemptCompletion") {
|
|
419268
|
+
if (part.input) {
|
|
419269
|
+
const result2 = part.input.result || "";
|
|
419270
|
+
console.log(result2);
|
|
419271
|
+
}
|
|
419272
|
+
return;
|
|
419273
|
+
}
|
|
419274
|
+
}
|
|
419275
|
+
}
|
|
419276
|
+
}
|
|
419151
419277
|
outputMessages(messages) {
|
|
419152
419278
|
for (const message of messages) {
|
|
419153
419279
|
if (!this.outputMessageIds.has(message.id)) {
|
|
@@ -446737,14 +446863,6 @@ function renderToolPart(part) {
|
|
|
446737
446863
|
error: errorText
|
|
446738
446864
|
};
|
|
446739
446865
|
}
|
|
446740
|
-
if (part.type === "tool-multiApplyDiff") {
|
|
446741
|
-
const { path: path26 = "unknown", edits = [] } = part.input || {};
|
|
446742
|
-
return {
|
|
446743
|
-
text: `\uD83D\uDD27 Applying ${edits.length} edits to ${source_default.bold(path26)}`,
|
|
446744
|
-
stop: hasError ? "fail" : "succeed",
|
|
446745
|
-
error: errorText
|
|
446746
|
-
};
|
|
446747
|
-
}
|
|
446748
446866
|
if (part.type === "tool-listFiles") {
|
|
446749
446867
|
const { path: path26 = ".", recursive = false } = part.input || {};
|
|
446750
446868
|
const recursiveText = recursive ? " recursively" : "";
|
|
@@ -446903,6 +447021,9 @@ function renderSubtaskMessages(messages2) {
|
|
|
446903
447021
|
return output2;
|
|
446904
447022
|
}
|
|
446905
447023
|
|
|
447024
|
+
// ../livekit/src/chat/live-chat-kit.ts
|
|
447025
|
+
init_effect();
|
|
447026
|
+
|
|
446906
447027
|
// ../livekit/src/task.ts
|
|
446907
447028
|
function toTaskStatus(message, finishReason) {
|
|
446908
447029
|
let lastStepStart = -1;
|
|
@@ -447044,8 +447165,12 @@ async function generateTitle2(store, taskId, model2, inputMessages, abortSignal)
|
|
|
447044
447165
|
}
|
|
447045
447166
|
];
|
|
447046
447167
|
const resp = await generateText({
|
|
447047
|
-
|
|
447048
|
-
|
|
447168
|
+
providerOptions: {
|
|
447169
|
+
pochi: {
|
|
447170
|
+
taskId,
|
|
447171
|
+
version: globalThis.POCHI_CLIENT,
|
|
447172
|
+
useCase: "generate-task-title"
|
|
447173
|
+
}
|
|
447049
447174
|
},
|
|
447050
447175
|
model: model2,
|
|
447051
447176
|
prompt: convertToModelMessages(formatters.llm(messages2, { removeSystemReminder: true })),
|
|
@@ -447123,8 +447248,12 @@ var makeRepairToolCall = (taskId, model2) => async ({ toolCall, inputSchema: inp
|
|
|
447123
447248
|
const tools = createClientTools();
|
|
447124
447249
|
const tool2 = tools[toolCall.toolName];
|
|
447125
447250
|
const { object: repairedArgs } = await generateObject({
|
|
447126
|
-
|
|
447127
|
-
|
|
447251
|
+
providerOptions: {
|
|
447252
|
+
pochi: {
|
|
447253
|
+
taskId,
|
|
447254
|
+
version: globalThis.POCHI_CLIENT,
|
|
447255
|
+
useCase: "repair-tool-call"
|
|
447256
|
+
}
|
|
447128
447257
|
},
|
|
447129
447258
|
model: model2,
|
|
447130
447259
|
schema: tool2.inputSchema,
|
|
@@ -447182,8 +447311,12 @@ async function createSummary(store, taskId, model2, abortSignal, inputMessages)
|
|
|
447182
447311
|
}
|
|
447183
447312
|
];
|
|
447184
447313
|
const resp = await generateText({
|
|
447185
|
-
|
|
447186
|
-
|
|
447314
|
+
providerOptions: {
|
|
447315
|
+
pochi: {
|
|
447316
|
+
taskId,
|
|
447317
|
+
version: globalThis.POCHI_CLIENT,
|
|
447318
|
+
useCase: "compact-task"
|
|
447319
|
+
}
|
|
447187
447320
|
},
|
|
447188
447321
|
model: model2,
|
|
447189
447322
|
prompt: convertToModelMessages(formatters.llm(messages2, {
|
|
@@ -447469,15 +447602,18 @@ function createNewTaskMiddleware(store, cwd2, parentTaskId, customAgents) {
|
|
|
447469
447602
|
cwd: cwd2,
|
|
447470
447603
|
parentId: parentTaskId,
|
|
447471
447604
|
createdAt: new Date,
|
|
447472
|
-
|
|
447473
|
-
|
|
447474
|
-
|
|
447475
|
-
|
|
447476
|
-
|
|
447477
|
-
|
|
447478
|
-
|
|
447479
|
-
|
|
447480
|
-
|
|
447605
|
+
initMessages: [
|
|
447606
|
+
{
|
|
447607
|
+
id: crypto.randomUUID(),
|
|
447608
|
+
role: "user",
|
|
447609
|
+
parts: [
|
|
447610
|
+
{
|
|
447611
|
+
type: "text",
|
|
447612
|
+
text: args2.prompt
|
|
447613
|
+
}
|
|
447614
|
+
]
|
|
447615
|
+
}
|
|
447616
|
+
]
|
|
447481
447617
|
}));
|
|
447482
447618
|
controller.enqueue({
|
|
447483
447619
|
...chunk4,
|
|
@@ -447987,8 +448123,12 @@ function createOutputSchemaMiddleware(taskId, model2, outputSchema2) {
|
|
|
447987
448123
|
async function ensureOutputSchema(taskId, model2, schema8, content3) {
|
|
447988
448124
|
try {
|
|
447989
448125
|
const { object: object4 } = await generateObject({
|
|
447990
|
-
|
|
447991
|
-
|
|
448126
|
+
providerOptions: {
|
|
448127
|
+
pochi: {
|
|
448128
|
+
taskId,
|
|
448129
|
+
version: globalThis.POCHI_CLIENT,
|
|
448130
|
+
useCase: "output-schema"
|
|
448131
|
+
}
|
|
447992
448132
|
},
|
|
447993
448133
|
model: model2,
|
|
447994
448134
|
schema: schema8,
|
|
@@ -448376,8 +448516,12 @@ class FlexibleChatTransport {
|
|
|
448376
448516
|
const preparedMessages = await prepareMessages(messages2, environment2);
|
|
448377
448517
|
const modelMessages = await resolvePromise(convertToModelMessages(formatters.llm(preparedMessages), { tools }));
|
|
448378
448518
|
const stream12 = streamText({
|
|
448379
|
-
|
|
448380
|
-
|
|
448519
|
+
providerOptions: {
|
|
448520
|
+
pochi: {
|
|
448521
|
+
taskId: chatId,
|
|
448522
|
+
client: globalThis.POCHI_CLIENT,
|
|
448523
|
+
useCase: "agent"
|
|
448524
|
+
}
|
|
448381
448525
|
},
|
|
448382
448526
|
system: prompts.system(environment2?.info?.customRules, this.customAgent, mcpInfo?.instructions),
|
|
448383
448527
|
messages: modelMessages,
|
|
@@ -448489,12 +448633,18 @@ var logger23 = getLogger("LiveChatKit");
|
|
|
448489
448633
|
|
|
448490
448634
|
class LiveChatKit {
|
|
448491
448635
|
taskId;
|
|
448636
|
+
displayId;
|
|
448492
448637
|
store;
|
|
448493
448638
|
chat;
|
|
448494
448639
|
transport;
|
|
448495
|
-
|
|
448640
|
+
onStreamStart;
|
|
448641
|
+
onStreamFinish;
|
|
448642
|
+
onStreamFailed;
|
|
448643
|
+
compact;
|
|
448644
|
+
lastStepStartTimestamp;
|
|
448496
448645
|
constructor({
|
|
448497
448646
|
taskId,
|
|
448647
|
+
displayId,
|
|
448498
448648
|
abortSignal,
|
|
448499
448649
|
store,
|
|
448500
448650
|
chatClass,
|
|
@@ -448504,10 +448654,17 @@ class LiveChatKit {
|
|
|
448504
448654
|
isCli,
|
|
448505
448655
|
customAgent,
|
|
448506
448656
|
outputSchema: outputSchema2,
|
|
448657
|
+
onStreamStart,
|
|
448658
|
+
onStreamFinish,
|
|
448659
|
+
onStreamFailed,
|
|
448507
448660
|
...chatInit
|
|
448508
448661
|
}) {
|
|
448509
448662
|
this.taskId = taskId;
|
|
448663
|
+
this.displayId = displayId;
|
|
448510
448664
|
this.store = store;
|
|
448665
|
+
this.onStreamStart = onStreamStart;
|
|
448666
|
+
this.onStreamFinish = onStreamFinish;
|
|
448667
|
+
this.onStreamFailed = onStreamFailed;
|
|
448511
448668
|
this.transport = new FlexibleChatTransport({
|
|
448512
448669
|
store,
|
|
448513
448670
|
onStart: this.onStart,
|
|
@@ -448550,55 +448707,57 @@ class LiveChatKit {
|
|
|
448550
448707
|
}
|
|
448551
448708
|
}
|
|
448552
448709
|
if (onOverrideMessages) {
|
|
448553
|
-
await onOverrideMessages({
|
|
448710
|
+
await onOverrideMessages({
|
|
448711
|
+
store: this.store,
|
|
448712
|
+
taskId: this.taskId,
|
|
448713
|
+
messages: messages2,
|
|
448714
|
+
abortSignal: abortSignal2
|
|
448715
|
+
});
|
|
448554
448716
|
}
|
|
448555
448717
|
};
|
|
448556
|
-
this.
|
|
448557
|
-
const taskId2 = crypto.randomUUID();
|
|
448718
|
+
this.compact = async () => {
|
|
448558
448719
|
const { messages: messages2 } = this.chat;
|
|
448559
448720
|
const model2 = createModel2({ llm: getters.getLLM() });
|
|
448560
448721
|
const summary6 = await compactTask({
|
|
448561
448722
|
store: this.store,
|
|
448562
|
-
taskId:
|
|
448723
|
+
taskId: this.taskId,
|
|
448563
448724
|
model: model2,
|
|
448564
|
-
messages: messages2
|
|
448565
|
-
abortSignal
|
|
448725
|
+
messages: messages2
|
|
448566
448726
|
});
|
|
448567
448727
|
if (!summary6) {
|
|
448568
448728
|
throw new Error("Failed to compact task");
|
|
448569
448729
|
}
|
|
448570
|
-
|
|
448571
|
-
id: taskId2,
|
|
448572
|
-
cwd: this.task?.cwd || undefined,
|
|
448573
|
-
modelId: this.task?.modelId || undefined,
|
|
448574
|
-
createdAt: new Date,
|
|
448575
|
-
initMessage: {
|
|
448576
|
-
id: crypto.randomUUID(),
|
|
448577
|
-
parts: [
|
|
448578
|
-
{
|
|
448579
|
-
type: "text",
|
|
448580
|
-
text: summary6
|
|
448581
|
-
},
|
|
448582
|
-
{
|
|
448583
|
-
type: "text",
|
|
448584
|
-
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"
|
|
448585
|
-
}
|
|
448586
|
-
]
|
|
448587
|
-
}
|
|
448588
|
-
}));
|
|
448589
|
-
return taskId2;
|
|
448730
|
+
return summary6;
|
|
448590
448731
|
};
|
|
448591
448732
|
}
|
|
448592
|
-
init(cwd2,
|
|
448593
|
-
|
|
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
|
+
}
|
|
448594
448756
|
this.store.commit(events.taskInited({
|
|
448595
448757
|
id: this.taskId,
|
|
448596
448758
|
cwd: cwd2,
|
|
448597
448759
|
createdAt: new Date,
|
|
448598
|
-
|
|
448599
|
-
id: crypto.randomUUID(),
|
|
448600
|
-
parts: parts2
|
|
448601
|
-
} : undefined
|
|
448760
|
+
initMessages
|
|
448602
448761
|
}));
|
|
448603
448762
|
this.chat.messages = this.messages;
|
|
448604
448763
|
}
|
|
@@ -448659,8 +448818,11 @@ class LiveChatKit {
|
|
|
448659
448818
|
todos: environment2?.todos || [],
|
|
448660
448819
|
git: toTaskGitInfo(environment2?.workspace.gitStatus),
|
|
448661
448820
|
updatedAt: new Date,
|
|
448662
|
-
modelId: llm.id
|
|
448821
|
+
modelId: llm.id,
|
|
448822
|
+
displayId: this.displayId
|
|
448663
448823
|
}));
|
|
448824
|
+
this.lastStepStartTimestamp = Date.now();
|
|
448825
|
+
this.onStreamStart?.();
|
|
448664
448826
|
}
|
|
448665
448827
|
};
|
|
448666
448828
|
onFinish = ({
|
|
@@ -448679,13 +448841,25 @@ class LiveChatKit {
|
|
|
448679
448841
|
if (message.metadata?.kind !== "assistant") {
|
|
448680
448842
|
return this.onError(abortError);
|
|
448681
448843
|
}
|
|
448844
|
+
const status3 = toTaskStatus(message, message.metadata?.finishReason);
|
|
448682
448845
|
store.commit(events.chatStreamFinished({
|
|
448683
448846
|
id: this.taskId,
|
|
448684
|
-
status:
|
|
448847
|
+
status: status3,
|
|
448685
448848
|
data: message,
|
|
448686
448849
|
totalTokens: message.metadata.totalTokens,
|
|
448687
|
-
updatedAt: new Date
|
|
448850
|
+
updatedAt: new Date,
|
|
448851
|
+
duration: this.lastStepStartTimestamp ? exports_Duration.millis(Date.now() - this.lastStepStartTimestamp) : undefined
|
|
448688
448852
|
}));
|
|
448853
|
+
this.clearLastStepTimestamp();
|
|
448854
|
+
this.onStreamFinish?.({
|
|
448855
|
+
id: this.taskId,
|
|
448856
|
+
cwd: this.task?.cwd ?? null,
|
|
448857
|
+
status: status3,
|
|
448858
|
+
messages: [...this.chat.messages]
|
|
448859
|
+
});
|
|
448860
|
+
};
|
|
448861
|
+
clearLastStepTimestamp = () => {
|
|
448862
|
+
this.lastStepStartTimestamp = undefined;
|
|
448689
448863
|
};
|
|
448690
448864
|
onError = (error46) => {
|
|
448691
448865
|
logger23.error("onError", error46);
|
|
@@ -448694,8 +448868,15 @@ class LiveChatKit {
|
|
|
448694
448868
|
id: this.taskId,
|
|
448695
448869
|
error: toTaskError(error46),
|
|
448696
448870
|
data: lastMessage,
|
|
448697
|
-
updatedAt: new Date
|
|
448871
|
+
updatedAt: new Date,
|
|
448872
|
+
duration: this.lastStepStartTimestamp ? exports_Duration.millis(Date.now() - this.lastStepStartTimestamp) : undefined
|
|
448698
448873
|
}));
|
|
448874
|
+
this.clearLastStepTimestamp();
|
|
448875
|
+
this.onStreamFailed?.({
|
|
448876
|
+
cwd: this.task?.cwd ?? null,
|
|
448877
|
+
error: error46,
|
|
448878
|
+
messages: [...this.chat.messages]
|
|
448879
|
+
});
|
|
448699
448880
|
};
|
|
448700
448881
|
}
|
|
448701
448882
|
// src/lib/read-environment.ts
|
|
@@ -448959,13 +449140,6 @@ async function parseDiffAndApply(fileContent3, searchContent, replaceContent, ex
|
|
|
448959
449140
|
}
|
|
448960
449141
|
return result2;
|
|
448961
449142
|
}
|
|
448962
|
-
async function processMultipleDiffs(fileContent3, edits) {
|
|
448963
|
-
let updatedContent = fileContent3;
|
|
448964
|
-
for (const edit of edits) {
|
|
448965
|
-
updatedContent = await parseDiffAndApply(updatedContent, edit.searchContent, edit.replaceContent, edit.expectedReplacements);
|
|
448966
|
-
}
|
|
448967
|
-
return updatedContent;
|
|
448968
|
-
}
|
|
448969
449143
|
var searchContentExact = (originalContent, searchContent) => {
|
|
448970
449144
|
const normalizedOriginal = normalize6(originalContent);
|
|
448971
449145
|
const normalizedSearch = normalize6(searchContent);
|
|
@@ -449259,19 +449433,6 @@ var listFiles3 = () => async ({ path: dirPath, recursive }, { abortSignal, cwd:
|
|
|
449259
449433
|
});
|
|
449260
449434
|
};
|
|
449261
449435
|
|
|
449262
|
-
// src/tools/multi-apply-diff.ts
|
|
449263
|
-
import * as fs15 from "node:fs/promises";
|
|
449264
|
-
var multiApplyDiff2 = () => async ({ path: path28, edits }, { cwd: cwd2 }) => {
|
|
449265
|
-
const fileUri = resolvePath(path28, cwd2);
|
|
449266
|
-
await ensureFileDirectoryExists(fileUri);
|
|
449267
|
-
const fileBuffer = await fs15.readFile(fileUri);
|
|
449268
|
-
validateTextFile(fileBuffer);
|
|
449269
|
-
const fileContent3 = fileBuffer.toString();
|
|
449270
|
-
const updatedContent = await processMultipleDiffs(fileContent3, edits);
|
|
449271
|
-
await fs15.writeFile(fileUri, updatedContent);
|
|
449272
|
-
return { success: true };
|
|
449273
|
-
};
|
|
449274
|
-
|
|
449275
449436
|
// src/tools/new-task.ts
|
|
449276
449437
|
var newTask = (options6) => async ({ _meta, agentType }) => {
|
|
449277
449438
|
const taskId = _meta?.uid || crypto.randomUUID();
|
|
@@ -449306,10 +449467,10 @@ var newTask = (options6) => async ({ _meta, agentType }) => {
|
|
|
449306
449467
|
};
|
|
449307
449468
|
|
|
449308
449469
|
// src/tools/read-file.ts
|
|
449309
|
-
import * as
|
|
449310
|
-
var
|
|
449470
|
+
import * as fs15 from "node:fs/promises";
|
|
449471
|
+
var readFile11 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2, contentType }) => {
|
|
449311
449472
|
const resolvedPath = resolvePath(path28, cwd2);
|
|
449312
|
-
const fileBuffer = await
|
|
449473
|
+
const fileBuffer = await fs15.readFile(resolvedPath);
|
|
449313
449474
|
const isPlainTextFile2 = isPlainText(fileBuffer);
|
|
449314
449475
|
if (contentType && contentType.length > 0 && !isPlainTextFile2) {
|
|
449315
449476
|
return readMediaFile(resolvedPath, fileBuffer, contentType);
|
|
@@ -449327,11 +449488,11 @@ var readFile12 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2,
|
|
|
449327
449488
|
};
|
|
449328
449489
|
|
|
449329
449490
|
// src/tools/search-files.ts
|
|
449330
|
-
import * as
|
|
449491
|
+
import * as fs16 from "node:fs";
|
|
449331
449492
|
var logger25 = getLogger("searchFiles");
|
|
449332
449493
|
var searchFiles2 = (context15) => async ({ path: path28, regex: regex3, filePattern }, { abortSignal, cwd: cwd2 }) => {
|
|
449333
449494
|
const rgPath = context15.rg;
|
|
449334
|
-
if (!rgPath || !
|
|
449495
|
+
if (!rgPath || !fs16.existsSync(rgPath)) {
|
|
449335
449496
|
logger25.error("Ripgrep not found at path", rgPath);
|
|
449336
449497
|
throw new Error(`Ripgrep not found at path: ${rgPath}`);
|
|
449337
449498
|
}
|
|
@@ -449346,27 +449507,26 @@ var todoWrite2 = (_options) => async () => {
|
|
|
449346
449507
|
};
|
|
449347
449508
|
|
|
449348
449509
|
// src/tools/write-to-file.ts
|
|
449349
|
-
import * as
|
|
449510
|
+
import * as fs17 from "node:fs/promises";
|
|
449350
449511
|
import * as nodePath from "node:path";
|
|
449351
449512
|
var writeToFile2 = () => async ({ path: path28, content: content3 }, { cwd: cwd2 }) => {
|
|
449352
449513
|
const filePath = resolvePath(path28, cwd2);
|
|
449353
449514
|
if (!await isFileExists(filePath)) {
|
|
449354
449515
|
const dirPath = nodePath.dirname(filePath);
|
|
449355
|
-
await
|
|
449516
|
+
await fs17.mkdir(dirPath, { recursive: true });
|
|
449356
449517
|
}
|
|
449357
449518
|
const processedContent = fixCodeGenerationOutput(content3);
|
|
449358
|
-
await
|
|
449519
|
+
await fs17.writeFile(filePath, processedContent);
|
|
449359
449520
|
return { success: true };
|
|
449360
449521
|
};
|
|
449361
449522
|
|
|
449362
449523
|
// src/tools/index.ts
|
|
449363
449524
|
var ToolMap = {
|
|
449364
|
-
readFile:
|
|
449525
|
+
readFile: readFile11,
|
|
449365
449526
|
applyDiff: applyDiff2,
|
|
449366
449527
|
editNotebook: editNotebook2,
|
|
449367
449528
|
globFiles: globFiles3,
|
|
449368
449529
|
listFiles: listFiles3,
|
|
449369
|
-
multiApplyDiff: multiApplyDiff2,
|
|
449370
449530
|
newTask,
|
|
449371
449531
|
todoWrite: todoWrite2,
|
|
449372
449532
|
writeToFile: writeToFile2,
|
|
@@ -449486,7 +449646,7 @@ class TaskRunner {
|
|
|
449486
449646
|
parts: options6.parts
|
|
449487
449647
|
});
|
|
449488
449648
|
} else {
|
|
449489
|
-
this.chatKit.init(options6.cwd, options6.parts);
|
|
449649
|
+
this.chatKit.init(options6.cwd, { parts: options6.parts });
|
|
449490
449650
|
}
|
|
449491
449651
|
}
|
|
449492
449652
|
this.taskId = options6.uid;
|
|
@@ -449907,6 +450067,7 @@ function registerUpgradeCommand(program5) {
|
|
|
449907
450067
|
}
|
|
449908
450068
|
// src/cli.ts
|
|
449909
450069
|
var logger27 = getLogger("Pochi");
|
|
450070
|
+
globalThis.POCHI_CLIENT = `PochiCli/${package_default.version}`;
|
|
449910
450071
|
logger27.debug(`pochi v${package_default.version}`);
|
|
449911
450072
|
var parsePositiveInt = (input2) => {
|
|
449912
450073
|
if (!input2) {
|
|
@@ -449918,7 +450079,7 @@ var parsePositiveInt = (input2) => {
|
|
|
449918
450079
|
}
|
|
449919
450080
|
return result2;
|
|
449920
450081
|
};
|
|
449921
|
-
var program5 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`. Workflows can be triggered with `/workflow-name`, like `pochi -p /create-pr`.").option("-a, --attach <path...>", "Attach one or more files to the prompt, e.g images").optionsGroup("Options:").option("--stream-json", "Stream the output in JSON format. This is useful for parsing the output in scripts.").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).addOption(new Option("--experimental-output-schema <schema>", "Specify a JSON schema for the output of the task. The task will be validated against this schema.").hideHelp()).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "
|
|
450082
|
+
var program5 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`. Workflows can be triggered with `/workflow-name`, like `pochi -p /create-pr`.").option("-a, --attach <path...>", "Attach one or more files to the prompt, e.g images").optionsGroup("Options:").option("--stream-json", "Stream the output in JSON format. This is useful for parsing the output in scripts.").option("-x, --output-result", "Output the result from attemptCompletion to stdout. This is useful for scripts that need to capture the final result.").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).addOption(new Option("--experimental-output-schema <schema>", "Specify a JSON schema for the output of the task. The task will be validated against this schema.").hideHelp()).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "google/gemini-2.5-flash").optionsGroup("MCP:").option("--no-mcp", "Disable MCP (Model Context Protocol) integration completely.").action(async (options6) => {
|
|
449922
450083
|
const customAgents = await loadAgents(process.cwd());
|
|
449923
450084
|
const workflows = await loadWorkflows(process.cwd());
|
|
449924
450085
|
const { uid, prompt: prompt3, attachments } = await parseTaskInput(options6, program5, {
|
|
@@ -449931,7 +450092,7 @@ var program5 = new Command().name("pochi").description(`${source_default.bold("P
|
|
|
449931
450092
|
for (const attachmentPath of attachments) {
|
|
449932
450093
|
try {
|
|
449933
450094
|
const absolutePath = path28.resolve(process.cwd(), attachmentPath);
|
|
449934
|
-
const buffer4 = await
|
|
450095
|
+
const buffer4 = await fs18.readFile(absolutePath);
|
|
449935
450096
|
const mimeType = getMimeType(attachmentPath);
|
|
449936
450097
|
const dataUrl = await fileToUri(store, new File([buffer4], attachmentPath, {
|
|
449937
450098
|
type: mimeType
|
|
@@ -449995,7 +450156,11 @@ ${error46}`);
|
|
|
449995
450156
|
const renderer = new OutputRenderer(runner.state);
|
|
449996
450157
|
let jsonRenderer;
|
|
449997
450158
|
if (options6.streamJson) {
|
|
449998
|
-
jsonRenderer = new JsonRenderer(store, runner.state);
|
|
450159
|
+
jsonRenderer = new JsonRenderer(store, runner.state, { mode: "full" });
|
|
450160
|
+
} else if (options6.outputResult) {
|
|
450161
|
+
jsonRenderer = new JsonRenderer(store, runner.state, {
|
|
450162
|
+
mode: "result-only"
|
|
450163
|
+
});
|
|
449999
450164
|
}
|
|
450000
450165
|
await runner.run();
|
|
450001
450166
|
renderer.shutdown();
|