@ahumandev/autocode 0.0.3 → 0.0.4
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/README.md +25 -15
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/prompts/assist.d.ts +1 -1
- package/dist/agents/prompts/assist.d.ts.map +1 -1
- package/dist/agents/prompts/assist_troubleshoot.d.ts +1 -1
- package/dist/agents/prompts/assist_troubleshoot.d.ts.map +1 -1
- package/dist/agents/prompts/auto.d.ts +1 -1
- package/dist/agents/prompts/auto.d.ts.map +1 -1
- package/dist/agents/prompts/design.d.ts +1 -1
- package/dist/agents/prompts/design.d.ts.map +1 -1
- package/dist/agents/prompts/execute_author.d.ts +1 -1
- package/dist/agents/prompts/execute_author.d.ts.map +1 -1
- package/dist/agents/prompts/research.d.ts +1 -1
- package/dist/agents/prompts/research.d.ts.map +1 -1
- package/dist/agents/prompts/temp_concept.d.ts +1 -1
- package/dist/agents/prompts/temp_concept.d.ts.map +1 -1
- package/dist/agents/prompts/temp_report.d.ts +1 -1
- package/dist/agents/prompts/temp_report.d.ts.map +1 -1
- package/dist/agents/rules/question.d.ts +1 -1
- package/dist/agents/rules/question.d.ts.map +1 -1
- package/dist/agents/rules/swap2previous.d.ts +2 -0
- package/dist/agents/rules/swap2previous.d.ts.map +1 -0
- package/dist/commands/author_article.d.ts +2 -0
- package/dist/commands/author_article.d.ts.map +1 -0
- package/dist/commands/document.d.ts +2 -0
- package/dist/commands/document.d.ts.map +1 -0
- package/dist/commands/document_code.d.ts +2 -0
- package/dist/commands/document_code.d.ts.map +1 -0
- package/dist/commands/document_conventions.d.ts +2 -0
- package/dist/commands/document_conventions.d.ts.map +1 -0
- package/dist/commands/document_prd.d.ts +2 -0
- package/dist/commands/document_prd.d.ts.map +1 -0
- package/dist/commands/document_ux.d.ts +2 -0
- package/dist/commands/document_ux.d.ts.map +1 -0
- package/dist/commands/git_commit.d.ts +2 -0
- package/dist/commands/git_commit.d.ts.map +1 -0
- package/dist/commands/git_conflict.d.ts +2 -0
- package/dist/commands/git_conflict.d.ts.map +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/install.d.ts +7 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/job_concepts.d.ts +2 -0
- package/dist/commands/job_concepts.d.ts.map +1 -0
- package/dist/commands/job_design.d.ts +2 -0
- package/dist/commands/job_design.d.ts.map +1 -0
- package/dist/commands/job_draft.d.ts +2 -0
- package/dist/commands/job_draft.d.ts.map +1 -0
- package/dist/commands/job_execute.d.ts +2 -0
- package/dist/commands/job_execute.d.ts.map +1 -0
- package/dist/commands/job_execute_assist.d.ts +2 -0
- package/dist/commands/job_execute_assist.d.ts.map +1 -0
- package/dist/commands/job_execute_auto.d.ts +2 -0
- package/dist/commands/job_execute_auto.d.ts.map +1 -0
- package/dist/commands/job_execution_template.d.ts +2 -0
- package/dist/commands/job_execution_template.d.ts.map +1 -0
- package/dist/commands/job_review.d.ts +2 -0
- package/dist/commands/job_review.d.ts.map +1 -0
- package/dist/commands/new_assist.d.ts +2 -0
- package/dist/commands/new_assist.d.ts.map +1 -0
- package/dist/commands/new_auto.d.ts +2 -0
- package/dist/commands/new_auto.d.ts.map +1 -0
- package/dist/commands/new_design.d.ts +2 -0
- package/dist/commands/new_design.d.ts.map +1 -0
- package/dist/commands/new_research.d.ts +2 -0
- package/dist/commands/new_research.d.ts.map +1 -0
- package/dist/commands/new_session_template.d.ts +2 -0
- package/dist/commands/new_session_template.d.ts.map +1 -0
- package/dist/commands/new_troubleshoot.d.ts +2 -0
- package/dist/commands/new_troubleshoot.d.ts.map +1 -0
- package/dist/commands/repeat_as_md.d.ts +2 -0
- package/dist/commands/repeat_as_md.d.ts.map +1 -0
- package/dist/commands/repeat_as_wiki.d.ts +2 -0
- package/dist/commands/repeat_as_wiki.d.ts.map +1 -0
- package/dist/commands/report_last.d.ts +2 -0
- package/dist/commands/report_last.d.ts.map +1 -0
- package/dist/commands/report_session.d.ts +2 -0
- package/dist/commands/report_session.d.ts.map +1 -0
- package/dist/install.d.ts +25 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.test.d.ts +2 -0
- package/dist/install.test.d.ts.map +1 -0
- package/dist/plugin.js +823 -465
- package/dist/tools/autocode_agent_execute.d.ts +16 -0
- package/dist/tools/autocode_agent_execute.d.ts.map +1 -0
- package/dist/tools/autocode_agent_execute.test.d.ts +2 -0
- package/dist/tools/autocode_agent_execute.test.d.ts.map +1 -0
- package/dist/tools/autocode_agent_previous.d.ts +4 -0
- package/dist/tools/autocode_agent_previous.d.ts.map +1 -0
- package/dist/tools/autocode_agent_previous.test.d.ts +2 -0
- package/dist/tools/autocode_agent_previous.test.d.ts.map +1 -0
- package/dist/tools/autocode_job_shelve.d.ts +5 -0
- package/dist/tools/autocode_job_shelve.d.ts.map +1 -0
- package/dist/tools/autocode_job_shelve.test.d.ts +2 -0
- package/dist/tools/autocode_job_shelve.test.d.ts.map +1 -0
- package/dist/tools/index.d.ts +20 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/utils/agent_swap.d.ts +15 -0
- package/dist/utils/agent_swap.d.ts.map +1 -1
- package/dist/utils/jobs.d.ts +7 -2
- package/dist/utils/jobs.d.ts.map +1 -1
- package/dist/utils/shelve.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/agents/rules/swap2assist.d.ts +0 -2
- package/dist/agents/rules/swap2assist.d.ts.map +0 -1
- package/dist/tools/autocode_shelve.d.ts +0 -5
- package/dist/tools/autocode_shelve.d.ts.map +0 -1
- package/dist/tools/autocode_shelve.test.d.ts +0 -2
- package/dist/tools/autocode_shelve.test.d.ts.map +0 -1
package/dist/plugin.js
CHANGED
|
@@ -786,40 +786,61 @@ async function updateCurrentSessionTitleToJobName(client, context, jobName, stat
|
|
|
786
786
|
async function ensurePlannedJobFiles(fileSystem, directoryPath) {
|
|
787
787
|
await fileSystem.mkdir(directoryPath, { recursive: true });
|
|
788
788
|
}
|
|
789
|
-
|
|
789
|
+
function formatTimestampPostfix(date = new Date) {
|
|
790
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
791
|
+
return `${String(date.getFullYear()).slice(-2)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}_${pad(date.getHours())}-${pad(date.getMinutes())}-${pad(date.getSeconds())}`;
|
|
792
|
+
}
|
|
793
|
+
function createShelvedCollisionJobName(jobName, date = new Date) {
|
|
794
|
+
return `${jobName}_${formatTimestampPostfix(date)}`;
|
|
795
|
+
}
|
|
796
|
+
async function moveResolvedPlannedJobToStatus(worktree, source, status, fileSystem = defaultMoveJobFileSystem, options = {}) {
|
|
790
797
|
const destinationDirectory = getCanonicalDirectoryForStatus(status);
|
|
791
|
-
|
|
798
|
+
let destinationJobName = source.job_name;
|
|
799
|
+
let destinationDir = getJobDirectoryPath(worktree, destinationDirectory, destinationJobName);
|
|
792
800
|
if (source.absolute_path !== destinationDir) {
|
|
793
801
|
await fileSystem.mkdir(getJobDirectoryPath(worktree, destinationDirectory, ""), { recursive: true });
|
|
794
802
|
try {
|
|
795
803
|
await fileSystem.rename(source.absolute_path, destinationDir);
|
|
796
804
|
} catch (error) {
|
|
797
805
|
if (isCollisionError(error)) {
|
|
798
|
-
|
|
806
|
+
if (status !== "shelved" || !options.shelvedCollisionTimestamp) {
|
|
807
|
+
return { type: "destination_collision", destinationDir };
|
|
808
|
+
}
|
|
809
|
+
destinationJobName = createShelvedCollisionJobName(source.job_name, options.shelvedCollisionTimestamp);
|
|
810
|
+
destinationDir = getJobDirectoryPath(worktree, destinationDirectory, destinationJobName);
|
|
811
|
+
try {
|
|
812
|
+
await fileSystem.rename(source.absolute_path, destinationDir);
|
|
813
|
+
} catch (retryError) {
|
|
814
|
+
if (isCollisionError(retryError)) {
|
|
815
|
+
return { type: "destination_collision", destinationDir };
|
|
816
|
+
}
|
|
817
|
+
throw retryError;
|
|
818
|
+
}
|
|
819
|
+
} else {
|
|
820
|
+
throw error;
|
|
799
821
|
}
|
|
800
|
-
throw error;
|
|
801
822
|
}
|
|
802
823
|
}
|
|
803
824
|
await ensurePlannedJobFiles(fileSystem, destinationDir);
|
|
804
825
|
return {
|
|
805
826
|
type: "success",
|
|
806
827
|
job: {
|
|
807
|
-
job_name:
|
|
828
|
+
job_name: destinationJobName,
|
|
808
829
|
status,
|
|
809
830
|
directory: destinationDirectory,
|
|
810
831
|
absolute_path: destinationDir,
|
|
811
|
-
job_path: getRelativeJobDirectoryPath(destinationDirectory,
|
|
812
|
-
relative_job_path: getRelativeJobDirectoryPath(destinationDirectory,
|
|
832
|
+
job_path: getRelativeJobDirectoryPath(destinationDirectory, destinationJobName),
|
|
833
|
+
relative_job_path: getRelativeJobDirectoryPath(destinationDirectory, destinationJobName)
|
|
813
834
|
},
|
|
814
835
|
from_status: source.status
|
|
815
836
|
};
|
|
816
837
|
}
|
|
817
|
-
async function movePlannedJobToStatus(worktree, jobName, status, fileSystem = defaultMoveJobFileSystem) {
|
|
838
|
+
async function movePlannedJobToStatus(worktree, jobName, status, fileSystem = defaultMoveJobFileSystem, options = {}) {
|
|
818
839
|
const resolved = await resolvePlannedJob(fileSystem, worktree, jobName);
|
|
819
840
|
if (resolved.type !== "found") {
|
|
820
841
|
return resolved.type === "missing" ? { type: "missing" } : { type: "collision", collision: resolved.collision };
|
|
821
842
|
}
|
|
822
|
-
return moveResolvedPlannedJobToStatus(worktree, resolved.job, status, fileSystem);
|
|
843
|
+
return moveResolvedPlannedJobToStatus(worktree, resolved.job, status, fileSystem, options);
|
|
823
844
|
}
|
|
824
845
|
async function findExistingJobFile(fileSystem, worktree, job, fileName, directories = [...activeJobLifecycleDirectories, completedJobLifecycleDirectory]) {
|
|
825
846
|
const matches = [];
|
|
@@ -1932,7 +1953,6 @@ Caveman English applies to: tool parameters, prompts, user responses (excluding
|
|
|
1932
1953
|
- Option labels in Caveman English
|
|
1933
1954
|
- Option descriptions in Caveman English and summarize agent prompt if chosen (max 30 words).
|
|
1934
1955
|
- If multiple choices may be selected together, set \`"multiple": true\`; otherwise set \`"multiple": false\` on question object.
|
|
1935
|
-
- NEVER include catch-all options like "Other".
|
|
1936
1956
|
|
|
1937
1957
|
### Batching
|
|
1938
1958
|
- Prefer batching related questions into single \`question\` tool call.
|
|
@@ -2034,9 +2054,9 @@ function getMarkdownBody(markdown2) {
|
|
|
2034
2054
|
return stripLeadingYamlFrontMatter(markdown2).trim();
|
|
2035
2055
|
}
|
|
2036
2056
|
|
|
2037
|
-
// src/agents/rules/
|
|
2038
|
-
var
|
|
2039
|
-
**IMPORTANT FINAL ACTION**: call \`
|
|
2057
|
+
// src/agents/rules/swap2previous.ts
|
|
2058
|
+
var swap2previousRule = `
|
|
2059
|
+
**IMPORTANT FINAL ACTION**: call \`autocode_agent_previous\`.
|
|
2040
2060
|
`;
|
|
2041
2061
|
|
|
2042
2062
|
// src/agents/prompts/temp_manual.ts
|
|
@@ -2088,7 +2108,7 @@ Follow this workflow to perform DANGEROUS OPERATIONS or user responsibilities:
|
|
|
2088
2108
|
1. You are only allowed to perform ONLY that specific DANGEROUS OPERATION on user's behalf
|
|
2089
2109
|
2. Next DANGEROUS OPERATION is user's responsibility again.
|
|
2090
2110
|
|
|
2091
|
-
${
|
|
2111
|
+
${swap2previousRule}
|
|
2092
2112
|
|
|
2093
2113
|
---
|
|
2094
2114
|
|
|
@@ -2139,14 +2159,15 @@ ${manualRules}
|
|
|
2139
2159
|
## Assistant Workflow
|
|
2140
2160
|
|
|
2141
2161
|
1. Next user request = your assignment
|
|
2142
|
-
2.
|
|
2143
|
-
|
|
2144
|
-
-
|
|
2145
|
-
|
|
2162
|
+
2. Need more info / has uncertainties / multiple good resolutions exist: then repeatedly interview user with \`question\` tool by suggesting options until clear.
|
|
2163
|
+
3. Consider practical tasks (immediately possible) to complete assignment:
|
|
2164
|
+
- Only 1 practical task to complete assignment: then tell user next task with emojis in Concise English (max 20 words) and then proceed with assignment.
|
|
2165
|
+
- Multiple practical tasks possible: then call question tool with tasks as options
|
|
2166
|
+
4. Complete the assignment by tasking subagents:
|
|
2146
2167
|
- Call \`todowrite\` tool to keep track of complex multi-step assignments
|
|
2147
2168
|
- Repeatedly task subagents until assignment is completed or failed
|
|
2148
|
-
|
|
2149
|
-
|
|
2169
|
+
5. Summarize output of \`task\` tool in Concise English (max 40 words), except if code was written then respond with basic flow diagram in Mermaid syntax
|
|
2170
|
+
6. Measure task results according against assignment:
|
|
2150
2171
|
- Failure: Follow [Troubleshooting Workflow](#troubleshooting)
|
|
2151
2172
|
- Success, but assignment is incomplete:
|
|
2152
2173
|
1. Report to user why assignment is incomplete and what is lacking
|
|
@@ -2599,7 +2620,7 @@ ${definitions}
|
|
|
2599
2620
|
- You \`task\` subagent \`auto_troubleshoot\` to resolve obstacles.
|
|
2600
2621
|
- You discover new CONSTRAINTS and RISKS as more info become available and alter acceptance criteria and PROPOSAL accordingly as long as original REQUIREMENTS are meet.
|
|
2601
2622
|
- You evaluate your own work against original REQUIREMENTS (acceptance criteria) and NEVER stop until all REQUIREMENTS are met.
|
|
2602
|
-
- When planned solution is completed and evaluated, tell the user to accept it with \`/job-review\`; use \`/job-
|
|
2623
|
+
- When planned solution is completed and evaluated, tell the user to accept it with \`/job-review\`; use \`/job-shelve\` only for closure without acceptance.
|
|
2603
2624
|
|
|
2604
2625
|
### User's Responsibilities
|
|
2605
2626
|
|
|
@@ -3973,9 +3994,9 @@ Read the instruction and determine what changes are requested, where, and if any
|
|
|
3973
3994
|
|
|
3974
3995
|
### Step 2: Load Skill
|
|
3975
3996
|
|
|
3976
|
-
For simple 1 line
|
|
3997
|
+
For simple 1 line or small correction tasks user specifically requested, do direct targeted edit and skip skill loading.
|
|
3977
3998
|
|
|
3978
|
-
|
|
3999
|
+
Load only skill that matches request (if not yet loaded).
|
|
3979
4000
|
|
|
3980
4001
|
### Step 3: Analyze Article
|
|
3981
4002
|
|
|
@@ -5630,7 +5651,7 @@ CONCEPT = a conceptual project improvement idea (like fixing bug, adding feature
|
|
|
5630
5651
|
2. Create 1 CONCEPT per independent group of issues calling \`autocode_concept_create\` tool with formatted [Concept Parameter](#concept)
|
|
5631
5652
|
3. Report CONCEPT labels and file paths.
|
|
5632
5653
|
|
|
5633
|
-
${
|
|
5654
|
+
${swap2previousRule}
|
|
5634
5655
|
|
|
5635
5656
|
## Concept Parameter {concept}
|
|
5636
5657
|
|
|
@@ -5739,7 +5760,7 @@ Rules:
|
|
|
5739
5760
|
- Start H2 titles and bullet points with relevant emojis
|
|
5740
5761
|
${markdown}
|
|
5741
5762
|
|
|
5742
|
-
${
|
|
5763
|
+
${swap2previousRule}
|
|
5743
5764
|
`;
|
|
5744
5765
|
|
|
5745
5766
|
// src/agents/index.ts
|
|
@@ -5934,6 +5955,7 @@ var baseAgents = {
|
|
|
5934
5955
|
mode: "primary",
|
|
5935
5956
|
permission: {
|
|
5936
5957
|
"*": "deny",
|
|
5958
|
+
autocode_agent_execute: "allow",
|
|
5937
5959
|
autocode_agent_swap: "allow",
|
|
5938
5960
|
autocode_concept_list: "allow",
|
|
5939
5961
|
autocode_concept_read: "allow",
|
|
@@ -6288,7 +6310,7 @@ var baseAgents = {
|
|
|
6288
6310
|
mode: "subagent",
|
|
6289
6311
|
permission: {
|
|
6290
6312
|
"*": "deny",
|
|
6291
|
-
|
|
6313
|
+
autocode_agent_previous: "allow",
|
|
6292
6314
|
doom_loop: "deny",
|
|
6293
6315
|
edit: "allow",
|
|
6294
6316
|
glob: "allow",
|
|
@@ -6310,7 +6332,7 @@ var baseAgents = {
|
|
|
6310
6332
|
mode: "subagent",
|
|
6311
6333
|
permission: {
|
|
6312
6334
|
"*": "deny",
|
|
6313
|
-
|
|
6335
|
+
autocode_agent_previous: "allow",
|
|
6314
6336
|
doom_loop: "deny",
|
|
6315
6337
|
edit: "allow",
|
|
6316
6338
|
glob: "allow",
|
|
@@ -6333,7 +6355,7 @@ var baseAgents = {
|
|
|
6333
6355
|
mode: "subagent",
|
|
6334
6356
|
permission: {
|
|
6335
6357
|
"*": "deny",
|
|
6336
|
-
|
|
6358
|
+
autocode_agent_previous: "allow",
|
|
6337
6359
|
doom_loop: "deny",
|
|
6338
6360
|
edit: "allow",
|
|
6339
6361
|
glob: "allow",
|
|
@@ -6356,7 +6378,7 @@ var baseAgents = {
|
|
|
6356
6378
|
mode: "subagent",
|
|
6357
6379
|
permission: {
|
|
6358
6380
|
"*": "deny",
|
|
6359
|
-
|
|
6381
|
+
autocode_agent_previous: "allow",
|
|
6360
6382
|
doom_loop: "deny",
|
|
6361
6383
|
edit: "allow",
|
|
6362
6384
|
glob: "allow",
|
|
@@ -6378,7 +6400,7 @@ var baseAgents = {
|
|
|
6378
6400
|
mode: "subagent",
|
|
6379
6401
|
permission: {
|
|
6380
6402
|
"*": "deny",
|
|
6381
|
-
|
|
6403
|
+
autocode_agent_previous: "allow",
|
|
6382
6404
|
doom_loop: "deny",
|
|
6383
6405
|
edit: "allow",
|
|
6384
6406
|
glob: "allow",
|
|
@@ -6401,7 +6423,7 @@ var baseAgents = {
|
|
|
6401
6423
|
mode: "subagent",
|
|
6402
6424
|
permission: {
|
|
6403
6425
|
"*": "deny",
|
|
6404
|
-
|
|
6426
|
+
autocode_agent_previous: "allow",
|
|
6405
6427
|
doom_loop: "deny",
|
|
6406
6428
|
edit: "allow",
|
|
6407
6429
|
glob: "allow",
|
|
@@ -6423,7 +6445,7 @@ var baseAgents = {
|
|
|
6423
6445
|
mode: "subagent",
|
|
6424
6446
|
permission: {
|
|
6425
6447
|
"*": "deny",
|
|
6426
|
-
|
|
6448
|
+
autocode_agent_previous: "allow",
|
|
6427
6449
|
autocode_logo_find: "allow",
|
|
6428
6450
|
doom_loop: "deny",
|
|
6429
6451
|
edit: "allow",
|
|
@@ -6537,7 +6559,9 @@ var baseAgents = {
|
|
|
6537
6559
|
mode: "subagent",
|
|
6538
6560
|
permission: {
|
|
6539
6561
|
"*": "deny",
|
|
6540
|
-
|
|
6562
|
+
autocode_agent_previous: "allow",
|
|
6563
|
+
autocode_criteria_list: "allow",
|
|
6564
|
+
autocode_job_shelve: "allow",
|
|
6541
6565
|
doom_loop: "deny",
|
|
6542
6566
|
git_git_add: "allow",
|
|
6543
6567
|
git_git_commit: "allow",
|
|
@@ -6809,26 +6833,13 @@ var baseAgents = {
|
|
|
6809
6833
|
temperature: 0.5,
|
|
6810
6834
|
tier: "fast"
|
|
6811
6835
|
},
|
|
6812
|
-
temp_agent: {
|
|
6813
|
-
color: colorWritableWorker,
|
|
6814
|
-
hidden: true,
|
|
6815
|
-
mode: "subagent",
|
|
6816
|
-
permission: {
|
|
6817
|
-
"*": "deny",
|
|
6818
|
-
autocode_agent_swap: "allow",
|
|
6819
|
-
autocode_job_list: "allow",
|
|
6820
|
-
autocode_plan_read: "allow"
|
|
6821
|
-
},
|
|
6822
|
-
prompt: "---",
|
|
6823
|
-
temperature: 0.5,
|
|
6824
|
-
tier: "fast"
|
|
6825
|
-
},
|
|
6826
6836
|
temp_concept: {
|
|
6827
6837
|
color: colorWritableWorker,
|
|
6828
6838
|
hidden: true,
|
|
6829
6839
|
mode: "subagent",
|
|
6830
6840
|
permission: {
|
|
6831
6841
|
"*": "deny",
|
|
6842
|
+
autocode_agent_previous: "allow",
|
|
6832
6843
|
autocode_concept_create: "allow",
|
|
6833
6844
|
skill: {
|
|
6834
6845
|
"*": "deny",
|
|
@@ -6839,13 +6850,27 @@ var baseAgents = {
|
|
|
6839
6850
|
prompt: tempConceptPrompt,
|
|
6840
6851
|
tier: "fast"
|
|
6841
6852
|
},
|
|
6853
|
+
temp_execute: {
|
|
6854
|
+
color: colorWritableWorker,
|
|
6855
|
+
hidden: true,
|
|
6856
|
+
mode: "subagent",
|
|
6857
|
+
permission: {
|
|
6858
|
+
"*": "deny",
|
|
6859
|
+
autocode_agent_execute: "allow",
|
|
6860
|
+
autocode_job_list: "allow",
|
|
6861
|
+
question: "allow"
|
|
6862
|
+
},
|
|
6863
|
+
prompt: "---",
|
|
6864
|
+
temperature: 0.5,
|
|
6865
|
+
tier: "fast"
|
|
6866
|
+
},
|
|
6842
6867
|
temp_manual: {
|
|
6843
6868
|
color: colorReadOnlyWorker,
|
|
6844
6869
|
hidden: true,
|
|
6845
6870
|
mode: "subagent",
|
|
6846
6871
|
permission: {
|
|
6847
6872
|
"*": "deny",
|
|
6848
|
-
|
|
6873
|
+
autocode_agent_previous: "allow"
|
|
6849
6874
|
},
|
|
6850
6875
|
prompt: tempManualPrompt,
|
|
6851
6876
|
temperature: 0.3,
|
|
@@ -6857,7 +6882,7 @@ var baseAgents = {
|
|
|
6857
6882
|
mode: "subagent",
|
|
6858
6883
|
permission: {
|
|
6859
6884
|
"*": "deny",
|
|
6860
|
-
|
|
6885
|
+
autocode_agent_previous: "allow"
|
|
6861
6886
|
},
|
|
6862
6887
|
prompt: tempReportPrompt,
|
|
6863
6888
|
temperature: 0.3,
|
|
@@ -6869,12 +6894,24 @@ var baseAgents = {
|
|
|
6869
6894
|
mode: "subagent",
|
|
6870
6895
|
permission: {
|
|
6871
6896
|
"*": "deny",
|
|
6872
|
-
|
|
6897
|
+
autocode_agent_previous: "allow",
|
|
6873
6898
|
autocode_session_create: "allow"
|
|
6874
6899
|
},
|
|
6875
6900
|
prompt: "---",
|
|
6876
6901
|
temperature: 0.5,
|
|
6877
6902
|
tier: "fast"
|
|
6903
|
+
},
|
|
6904
|
+
temp_shelve: {
|
|
6905
|
+
color: colorWritableWorker,
|
|
6906
|
+
hidden: true,
|
|
6907
|
+
mode: "subagent",
|
|
6908
|
+
permission: {
|
|
6909
|
+
"*": "deny",
|
|
6910
|
+
autocode_job_shelve: "allow"
|
|
6911
|
+
},
|
|
6912
|
+
prompt: "---",
|
|
6913
|
+
temperature: 0.5,
|
|
6914
|
+
tier: "fast"
|
|
6878
6915
|
}
|
|
6879
6916
|
};
|
|
6880
6917
|
function buildAgents(externalDirectories = {}, sandboxSupportOverride) {
|
|
@@ -7120,37 +7157,79 @@ async function loadAutocodeConfig(worktree, directory, fs = defaultFs) {
|
|
|
7120
7157
|
return { tiers, externalDirectories, sandbox };
|
|
7121
7158
|
}
|
|
7122
7159
|
|
|
7123
|
-
// src/commands/
|
|
7124
|
-
|
|
7125
|
-
return `
|
|
7126
|
-
Call \`autocode_job_execute\` with \`agent\` = \`${agent}\`, then evaluate tool output:
|
|
7127
|
-
- \`result_type == "draft_required"\`, then restart your Design Workflow without tasking other agents and draft a solution plan to execute.
|
|
7128
|
-
- \`result_type == "no_plans"\`, then tell user there are no plans to execute and that he should run \`/job-draft\` command first to create a drafted solution plan in \`.agents/jobs/drafts/{name}/plan.md\`.
|
|
7129
|
-
- \`result_type == "session_created"\`, then respond with:
|
|
7160
|
+
// src/commands/author_article.ts
|
|
7161
|
+
var authorArticleCommandTemplate = `$ARGUMENTS
|
|
7130
7162
|
|
|
7131
|
-
|
|
7132
|
-
Follow job at new session called: "[session_title]".
|
|
7133
|
-
\`\`\`
|
|
7163
|
+
_____________________________
|
|
7134
7164
|
|
|
7135
|
-
|
|
7165
|
+
Apply \`author-article\` skill to edit user provided article.
|
|
7166
|
+
|
|
7167
|
+
${swap2previousRule}
|
|
7136
7168
|
`;
|
|
7137
|
-
}
|
|
7138
|
-
function buildNewSessionTemplate(agent, promptInstructions, responsePrefix) {
|
|
7139
|
-
return `
|
|
7140
|
-
$ARGUMENTS
|
|
7141
7169
|
|
|
7142
|
-
|
|
7170
|
+
// src/commands/document_code.ts
|
|
7171
|
+
var documentCodeCommandTemplate = `$ARGUMENTS
|
|
7143
7172
|
|
|
7144
|
-
|
|
7145
|
-
|
|
7173
|
+
${swap2previousRule}
|
|
7174
|
+
`;
|
|
7146
7175
|
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
\`\`\`
|
|
7176
|
+
// src/commands/document_conventions.ts
|
|
7177
|
+
var documentConventionsCommandTemplate = `$ARGUMENTS
|
|
7150
7178
|
|
|
7151
|
-
|
|
7179
|
+
${swap2previousRule}
|
|
7152
7180
|
`;
|
|
7153
|
-
|
|
7181
|
+
|
|
7182
|
+
// src/commands/document_prd.ts
|
|
7183
|
+
var documentPrdCommandTemplate = `$ARGUMENTS
|
|
7184
|
+
|
|
7185
|
+
${swap2previousRule}
|
|
7186
|
+
`;
|
|
7187
|
+
|
|
7188
|
+
// src/commands/document.ts
|
|
7189
|
+
var documentCommandTemplate = `
|
|
7190
|
+
1. Determine responsible subagents to document recent project changes: \`document_conventions\`, \`document_code\`, \`document_install\`, \`document_prd\`, \`document_ux\`
|
|
7191
|
+
2. Task responsible subagent with instruction to update their SKILL.md file with only relevant changes (include only related changes in prompt - must match subagent description).
|
|
7192
|
+
3. Collect subagent reports
|
|
7193
|
+
4. Update \`README.md\` using collected reports (only update applicable sections - not entire file)
|
|
7194
|
+
5. Only task \`document_agents\` *AFTER* you had updated \`README.md\` with prompt to check if any of recent changes are applicable to content in AGENTS.md (only update AGENTS.md if outdated)
|
|
7195
|
+
|
|
7196
|
+
${swap2previousRule}
|
|
7197
|
+
`;
|
|
7198
|
+
|
|
7199
|
+
// src/commands/document_ux.ts
|
|
7200
|
+
var documentUxCommandTemplate = `$ARGUMENTS
|
|
7201
|
+
|
|
7202
|
+
${swap2previousRule}
|
|
7203
|
+
`;
|
|
7204
|
+
|
|
7205
|
+
// src/commands/git_commit.ts
|
|
7206
|
+
var gitCommitCommandTemplate = `
|
|
7207
|
+
Base your git commit message on the following:
|
|
7208
|
+
- Purpose of this session (see title)
|
|
7209
|
+
- Your recent conversation with user
|
|
7210
|
+
- Recent changes
|
|
7211
|
+
|
|
7212
|
+
${swap2previousRule}
|
|
7213
|
+
`;
|
|
7214
|
+
|
|
7215
|
+
// src/commands/git_conflict.ts
|
|
7216
|
+
var gitConflictCommandTemplate = `$ARGUMENTS
|
|
7217
|
+
|
|
7218
|
+
${swap2previousRule}
|
|
7219
|
+
`;
|
|
7220
|
+
|
|
7221
|
+
// src/commands/init.ts
|
|
7222
|
+
var initCommandTemplate = `
|
|
7223
|
+
1. Task subagents in parallel: \`document_conventions\`, \`document_code\`, \`document_install\`, \`document_prd\`
|
|
7224
|
+
2. Additionally task \`document_ux\` for frontend/web projects
|
|
7225
|
+
3. Collect all subagent reports
|
|
7226
|
+
4. Use \`author-readme\` skill to update \`README.md\` using collected reports
|
|
7227
|
+
5. Only task \`document_agents\` *AFTER* you had updated \`README.md\` because \`document_agents\` will read your updated \`README.md\` file
|
|
7228
|
+
|
|
7229
|
+
${swap2previousRule}
|
|
7230
|
+
`;
|
|
7231
|
+
|
|
7232
|
+
// src/commands/install.ts
|
|
7154
7233
|
var installCommand = {
|
|
7155
7234
|
agent: "assist",
|
|
7156
7235
|
description: "Install or remediate Autocode runtime dependencies.",
|
|
@@ -7170,21 +7249,15 @@ var installCommand = {
|
|
|
7170
7249
|
12. After summary report, perform no next action, just stop.
|
|
7171
7250
|
`
|
|
7172
7251
|
};
|
|
7173
|
-
var commands = {
|
|
7174
|
-
"job-concepts": {
|
|
7175
|
-
agent: "temp_concept",
|
|
7176
|
-
description: "Save concepts in .agents/jobs/concepts/.",
|
|
7177
|
-
subtask: false,
|
|
7178
|
-
template: `$ARGUMENTS
|
|
7179
7252
|
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7253
|
+
// src/commands/job_concepts.ts
|
|
7254
|
+
var jobConceptsCommandTemplate = `$ARGUMENTS
|
|
7255
|
+
|
|
7256
|
+
${swap2previousRule}
|
|
7257
|
+
`;
|
|
7258
|
+
|
|
7259
|
+
// src/commands/job_design.ts
|
|
7260
|
+
var jobDesignCommandTemplate = `$ARGUMENTS
|
|
7188
7261
|
|
|
7189
7262
|
_____________________________
|
|
7190
7263
|
|
|
@@ -7195,13 +7268,10 @@ If you recently created a concept with \`autocode_concept_create\`, then use tha
|
|
|
7195
7268
|
3. If concepts were listed, display available concept labels using \`question\` tool and ask "Which concept should we use to design an implementation plan?"
|
|
7196
7269
|
4. Call \`autocode_concept_read\` with the selected concept \`label\` to read your INSTRUCTIONS.
|
|
7197
7270
|
5. Continue implementation-proposal planning in the current session using the returned concept context and recent conversation.
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
description: "Save drafted solution plan in .agents/jobs/drafts/{name}/plan.md",
|
|
7203
|
-
subtask: false,
|
|
7204
|
-
template: `
|
|
7271
|
+
`;
|
|
7272
|
+
|
|
7273
|
+
// src/commands/job_draft.ts
|
|
7274
|
+
var jobDraftCommandTemplate = `
|
|
7205
7275
|
1. Call \`autocode_plan_save\` tool with planned sections: PROBLEMS, REQUIREMENTS, CONSTRAINTS, RISKS, and user chosen PROPOSAL.
|
|
7206
7276
|
2. Respond with:
|
|
7207
7277
|
|
|
@@ -7223,139 +7293,260 @@ Replace [job_path] with \`job_path\` value from \`autocode_plan_save\` tool resp
|
|
|
7223
7293
|
- Use emojis only to highlight important points.
|
|
7224
7294
|
- Include markdown links to sources consulted.
|
|
7225
7295
|
- Every constraints must be backed by evidence, assumptions are risks.
|
|
7226
|
-
|
|
7296
|
+
`;
|
|
7297
|
+
|
|
7298
|
+
// src/commands/job_execute.ts
|
|
7299
|
+
var jobExecuteCommandTemplate = `
|
|
7300
|
+
1. Call \`autocode_job_list\` to list all available jobs.
|
|
7301
|
+
2. Call \`question\` once with exactly two batched questions:
|
|
7302
|
+
- Choose one available job from \`autocode_job_list\` output.
|
|
7303
|
+
- Choose execution agent: \`auto\` or \`assist\`.
|
|
7304
|
+
3. Call \`autocode_agent_execute\` once with selected \`job_name\` and selected \`agent\`, then evaluate tool output:
|
|
7305
|
+
- If output includes \`failedAction\`, follow returned \`instruction\` exactly and stop.
|
|
7306
|
+
- If output includes \`current_status\`, respond to user:
|
|
7307
|
+
|
|
7308
|
+
\`\`\`markdown
|
|
7309
|
+
Continue job in [agent] session.
|
|
7310
|
+
\`\`\`
|
|
7311
|
+
|
|
7312
|
+
Replace [agent] with selected execution agent.
|
|
7313
|
+
`;
|
|
7314
|
+
|
|
7315
|
+
// src/commands/job_execution_template.ts
|
|
7316
|
+
function buildJobExecutionCommandTemplate(agent) {
|
|
7317
|
+
return `
|
|
7318
|
+
Call \`autocode_job_execute\` with \`agent\` = \`${agent}\`, then evaluate tool output:
|
|
7319
|
+
- If output includes \`failedAction\`, follow returned \`instruction\` exactly and stop.
|
|
7320
|
+
- \`result_type == "draft_required"\`, then restart your Design Workflow without tasking other agents and draft a solution plan to execute.
|
|
7321
|
+
- \`result_type == "no_plans"\`, then tell user there are no plans to execute and that they should run \`/job-draft\` first to create a drafted solution plan in \`.agents/jobs/drafts/{name}/plan.md\`.
|
|
7322
|
+
- \`result_type == "session_created"\`, then respond with:
|
|
7323
|
+
|
|
7324
|
+
\`\`\`markdown
|
|
7325
|
+
Follow job at new session called: "[session_title]".
|
|
7326
|
+
\`\`\`
|
|
7327
|
+
|
|
7328
|
+
Replace [session_title] with \`session_title\` value from \`autocode_job_execute\` tool response.
|
|
7329
|
+
`;
|
|
7330
|
+
}
|
|
7331
|
+
|
|
7332
|
+
// src/commands/job_execute_assist.ts
|
|
7333
|
+
var jobExecuteAssistCommandTemplate = buildJobExecutionCommandTemplate("assist");
|
|
7334
|
+
|
|
7335
|
+
// src/commands/job_execute_auto.ts
|
|
7336
|
+
var jobExecuteAutoCommandTemplate = buildJobExecutionCommandTemplate("auto");
|
|
7337
|
+
|
|
7338
|
+
// src/commands/job_review.ts
|
|
7339
|
+
var jobReviewCommandTemplate = `
|
|
7340
|
+
1. Call \`autocode_criteria_list\` tool, if output show any unmet criteria, then inform user about unmet criteria and stop.
|
|
7341
|
+
2. If this is git repo, then base your git commit message on plan of this job and Review Report.
|
|
7342
|
+
3. Lastly when done, call \`autocode_job_shelve\` to shelve accepted review, then stop.
|
|
7343
|
+
`;
|
|
7344
|
+
|
|
7345
|
+
// src/commands/new_session_template.ts
|
|
7346
|
+
function buildNewSessionCommandTemplate(agent, promptInstructions, responsePrefix) {
|
|
7347
|
+
return `
|
|
7348
|
+
$ARGUMENTS
|
|
7349
|
+
|
|
7350
|
+
__________
|
|
7351
|
+
|
|
7352
|
+
1. Call \`autocode_session_create\` with \`agent\` = \`${agent}\` and \`prompt\` ${promptInstructions}
|
|
7353
|
+
2. Respond to user:
|
|
7354
|
+
|
|
7355
|
+
\`\`\`markdown
|
|
7356
|
+
${responsePrefix}: "[session_title]".
|
|
7357
|
+
\`\`\`
|
|
7358
|
+
|
|
7359
|
+
Replace [session_title] with \`session_title\` value from \`autocode_session_create\` tool response.
|
|
7360
|
+
`;
|
|
7361
|
+
}
|
|
7362
|
+
|
|
7363
|
+
// src/commands/new_assist.ts
|
|
7364
|
+
var newAssistCommandTemplate = buildNewSessionCommandTemplate("assist", `with recent user instructions to solve recently mentioned problem which includes:
|
|
7365
|
+
- PROBLEMS = Brief background context and wrong/missing behavior/info (undesired symptoms)
|
|
7366
|
+
- REQUIREMENTS = Expected system behavior / use case / answer to query
|
|
7367
|
+
- CONSTRAINTS = research scope (domain) or fixed technical/legal limits (facts) like security measures, dependencies, performance limitations, maintainability limitations, failure handling, reversibility, etc.
|
|
7368
|
+
- RISKS = any uncertainties (inaccessible/conflicting info), *assumed* limitations (edge-case concerns), external blockers (uncontrollable events/dependencies preventing solution), assumed caused of problem
|
|
7369
|
+
- PROPOSAL = only include if user suggested a solution
|
|
7370
|
+
- DATA = proof (all known paths/links to sources or facts), previous tool output, research results, exact values provided by user (do not repeat already included data)`, "Assist task execution session");
|
|
7371
|
+
|
|
7372
|
+
// src/commands/new_auto.ts
|
|
7373
|
+
var newAutoCommandTemplate = buildNewSessionCommandTemplate("auto", `with recent user instructions to solve recently mentioned problem which includes:
|
|
7374
|
+
- PROBLEMS = Brief background context and wrong/missing behavior/info (undesired symptoms)
|
|
7375
|
+
- REQUIREMENTS = Expected system behavior / use case / answer to query
|
|
7376
|
+
- CONSTRAINTS = research scope (domain) or fixed technical/legal limits (facts) like security measures, dependencies, performance limitations, maintainability limitations, failure handling, reversibility, etc.
|
|
7377
|
+
- RISKS = any uncertainties (inaccessible/conflicting info), *assumed* limitations (edge-case concerns), external blockers (uncontrollable events/dependencies preventing solution), assumed caused of problem
|
|
7378
|
+
- PROPOSAL = only include if user suggested a solution
|
|
7379
|
+
- DATA = proof (all known paths/links to sources or facts), previous tool output, research results, exact values provided by user (do not repeat already included data)`, "Follow autonomous task execution session");
|
|
7380
|
+
|
|
7381
|
+
// src/commands/new_design.ts
|
|
7382
|
+
var newDesignCommandTemplate = buildNewSessionCommandTemplate("design", `with instructions to design solution plan according based on:
|
|
7383
|
+
- how: suggested cause of action
|
|
7384
|
+
- what: expectation of new session
|
|
7385
|
+
- why: brief background context
|
|
7386
|
+
- context: all known facts related to instruction such as (past actions + its outcomes, failed attempts + reason for failure, constraints/opportunities discovered related to instruction)
|
|
7387
|
+
- proof: all known paths/links to sources of facts
|
|
7388
|
+
- data: previous tool output / research results / data provided by user (only include related to instruction; do not repeat already included data)`, "Advise design session");
|
|
7389
|
+
|
|
7390
|
+
// src/commands/new_research.ts
|
|
7391
|
+
var newResearchCommandTemplate = buildNewSessionCommandTemplate("research", `with instructions to research topic based on:
|
|
7392
|
+
- subject: name what info is required based on recent reasoning / user conversation
|
|
7393
|
+
- context: include all known facts related to instruction such as (past actions + its outcomes, failed attempts + reason for failure, constraints/opportunities discovered related to instruction)
|
|
7394
|
+
- proof: all known paths/links to sources of facts
|
|
7395
|
+
- data: previous tool output / research results / data provided by user (only include related to instruction; do not repeat already included data)`, "Follow research session");
|
|
7396
|
+
|
|
7397
|
+
// src/commands/new_troubleshoot.ts
|
|
7398
|
+
var newTroubleshootCommandTemplate = buildNewSessionCommandTemplate("assist_troubleshoot", `with instructions that include:
|
|
7399
|
+
- SYMPTOMS = recently observed unexpected/wrong behavior
|
|
7400
|
+
- ENVIRONMENT = environment context where SYMPTOM occurs (like OS, runtime version, profile, config)
|
|
7401
|
+
- BACKGROUND = why assignment is needed (if known)
|
|
7402
|
+
- CHANGES = what you recently changed that might be relevant to obstacle
|
|
7403
|
+
- EXPECTATION = what is expected to happen (like "respond 200 OK")
|
|
7404
|
+
- CAUSE = what possibly caused SYMPTOM (like "new auth library is incorrectly implemented")
|
|
7405
|
+
- EVIDENCE = facts that support theory of CAUSE (include blockcode of actual data, snippets of code, filenames, line numbers, urls, etc)
|
|
7406
|
+
- ERROR = EVIDENCE observed facts about SYMPTOM (like specific error message, stack trace, or exception)
|
|
7407
|
+
- TRACE = where ERROR was observed (like trace_id, log file, line number, timestamp, surrounding log messages, etc)
|
|
7408
|
+
- REPRODUCTION = steps to reproduce SYMPTOM in ENVIRONMENT include sample input data in blockcode (if possible)`, "Follow troubleshoot session");
|
|
7409
|
+
|
|
7410
|
+
// src/commands/repeat_as_md.ts
|
|
7411
|
+
var repeatAsMdCommandTemplate = `
|
|
7412
|
+
Repeat your last response wrapped in markdown codeblock:
|
|
7413
|
+
|
|
7414
|
+
For example:
|
|
7415
|
+
|
|
7416
|
+
\`\`\`\`\`\`\`\`\`markdown
|
|
7417
|
+
Last response goes here...
|
|
7418
|
+
\`\`\`\`\`\`\`\`\`
|
|
7419
|
+
`;
|
|
7420
|
+
|
|
7421
|
+
// src/commands/repeat_as_wiki.ts
|
|
7422
|
+
var repeatAsWikiCommandTemplate = `
|
|
7423
|
+
Repeat your last response as Markdown block text in Atlassian Wiki Markup (Jira Wiki syntax) format:
|
|
7424
|
+
|
|
7425
|
+
For example:
|
|
7426
|
+
|
|
7427
|
+
\`\`\`\`\`\`\`\`\`markdown
|
|
7428
|
+
Wiki markup goes here...
|
|
7429
|
+
\`\`\`\`\`\`\`\`\`
|
|
7430
|
+
`;
|
|
7431
|
+
|
|
7432
|
+
// src/commands/report_last.ts
|
|
7433
|
+
var reportLastCommandTemplate = `
|
|
7434
|
+
Report **ONLY** on your last assignment (last user requested task). Include only last user prompt, recent actions since last user prompt and recent tool outputs into consideration when you compile the report.
|
|
7435
|
+
|
|
7436
|
+
${swap2previousRule}
|
|
7437
|
+
`;
|
|
7438
|
+
|
|
7439
|
+
// src/commands/report_session.ts
|
|
7440
|
+
var reportSessionCommandTemplate = `
|
|
7441
|
+
Report on entire session taking all actions, tool outputs and prompts in consideration.
|
|
7442
|
+
|
|
7443
|
+
${swap2previousRule}
|
|
7444
|
+
`;
|
|
7445
|
+
|
|
7446
|
+
// src/commands/index.ts
|
|
7447
|
+
var shelveCommandTemplate = "Call `autocode_job_shelve` to shelve job into `.agents/jobs/shelved/{name}/`, then stop.";
|
|
7448
|
+
var commands = {
|
|
7449
|
+
"job-concepts": {
|
|
7450
|
+
agent: "temp_concept",
|
|
7451
|
+
description: "Save concepts in .agents/jobs/concepts/.",
|
|
7452
|
+
subtask: false,
|
|
7453
|
+
template: jobConceptsCommandTemplate
|
|
7454
|
+
},
|
|
7455
|
+
"job-design": {
|
|
7456
|
+
agent: "design",
|
|
7457
|
+
description: "Design a solution plan from a concept in .agents/jobs/concepts/",
|
|
7458
|
+
subtask: false,
|
|
7459
|
+
template: jobDesignCommandTemplate
|
|
7460
|
+
},
|
|
7461
|
+
"job-draft": {
|
|
7462
|
+
agent: "design",
|
|
7463
|
+
description: "Save drafted solution plan in .agents/jobs/drafts/{name}/plan.md",
|
|
7464
|
+
subtask: false,
|
|
7465
|
+
template: jobDraftCommandTemplate
|
|
7227
7466
|
},
|
|
7228
7467
|
"job-execute-assist": {
|
|
7229
7468
|
agent: "design",
|
|
7230
7469
|
description: "Assist with job execution in new session. Job will move to .agents/jobs/assist/{name}/.",
|
|
7231
7470
|
subtask: false,
|
|
7232
|
-
template:
|
|
7471
|
+
template: jobExecuteAssistCommandTemplate
|
|
7233
7472
|
},
|
|
7234
7473
|
"job-execute-auto": {
|
|
7235
7474
|
agent: "design",
|
|
7236
7475
|
description: "Execute job autonomously in new session and move job to .agents/jobs/executing/{name}/",
|
|
7237
7476
|
subtask: false,
|
|
7238
|
-
template:
|
|
7477
|
+
template: jobExecuteAutoCommandTemplate
|
|
7239
7478
|
},
|
|
7240
7479
|
"job-execute": {
|
|
7241
|
-
agent: "
|
|
7480
|
+
agent: "temp_execute",
|
|
7242
7481
|
description: "Select and execute job in the current session.",
|
|
7243
7482
|
subtask: false,
|
|
7244
|
-
template:
|
|
7245
|
-
1. Call \`autocode_job_list\` to list all available jobs.
|
|
7246
|
-
2. Call \`question\` once with exactly two batched questions:
|
|
7247
|
-
- Choose one available job from \`autocode_job_list\` output.
|
|
7248
|
-
- Choose execution agent: \`auto\` or \`assist\`.
|
|
7249
|
-
3. Call \`autocode_plan_read\` with selected \`job_name\` to read the selected job plan.
|
|
7250
|
-
4. Call \`autocode_agent_swap\` with \`agent\` set to the selected agent.
|
|
7251
|
-
`
|
|
7483
|
+
template: jobExecuteCommandTemplate
|
|
7252
7484
|
},
|
|
7253
7485
|
"job-review": {
|
|
7254
|
-
agent: "
|
|
7486
|
+
agent: "execute_git_commit",
|
|
7255
7487
|
description: "Commit accepted work and shelve into .agents/jobs/shelved/{name}/",
|
|
7256
7488
|
subtask: false,
|
|
7257
|
-
template:
|
|
7258
|
-
1. Call \`autocode_criteria_list\` tool, if output show any unmet criteria, then inform user about unmet criteria and stop.
|
|
7259
|
-
2. If this is git repo, then base your git commit message on plan of this job and Review Report.
|
|
7260
|
-
3. Lastly when done, call \`autocode_shelve\` to shelve accepted review into \`.agents/jobs/shelved/{name}/\`, then stop.
|
|
7261
|
-
`
|
|
7489
|
+
template: jobReviewCommandTemplate
|
|
7262
7490
|
},
|
|
7263
|
-
"job-
|
|
7264
|
-
agent: "
|
|
7491
|
+
"job-shelve": {
|
|
7492
|
+
agent: "temp_shelve",
|
|
7265
7493
|
description: "Shelve current job and move job to .agents/jobs/shelved/{name}/",
|
|
7266
7494
|
subtask: false,
|
|
7267
|
-
template:
|
|
7495
|
+
template: shelveCommandTemplate
|
|
7268
7496
|
},
|
|
7269
7497
|
shelve: {
|
|
7270
|
-
agent: "
|
|
7498
|
+
agent: "temp_shelve",
|
|
7271
7499
|
description: "Shelve current job and move job to .agents/jobs/shelved/{name}/",
|
|
7272
7500
|
subtask: false,
|
|
7273
|
-
template:
|
|
7501
|
+
template: shelveCommandTemplate
|
|
7274
7502
|
},
|
|
7275
7503
|
"author-article": {
|
|
7276
7504
|
agent: "execute_author",
|
|
7277
7505
|
description: "Author a professional article/report.",
|
|
7278
7506
|
subtask: false,
|
|
7279
|
-
template:
|
|
7280
|
-
|
|
7281
|
-
_____________________________
|
|
7282
|
-
|
|
7283
|
-
Apply \`author-article\` skill to edit user provided article.
|
|
7284
|
-
|
|
7285
|
-
${swap2assistRule}
|
|
7286
|
-
`
|
|
7507
|
+
template: authorArticleCommandTemplate
|
|
7287
7508
|
},
|
|
7288
7509
|
document: {
|
|
7289
7510
|
agent: "document",
|
|
7290
7511
|
description: "Document recent project changes.",
|
|
7291
7512
|
subtask: false,
|
|
7292
|
-
template:
|
|
7293
|
-
1. Determine responsible subagents to document recent project changes: \`document_conventions\`, \`document_code\`, \`document_install\`, \`document_prd\`, \`document_ux\`
|
|
7294
|
-
2. Task responsible subagent with instruction to update their SKILL.md file with only relevant changes (include only related changes in prompt - must match subagent description).
|
|
7295
|
-
3. Collect subagent reports
|
|
7296
|
-
4. Update \`README.md\` using collected reports (only update applicable sections - not entire file)
|
|
7297
|
-
5. Only task \`document_agents\` *AFTER* you had updated \`README.md\` with prompt to check if any of recent changes are applicable to content in AGENTS.md (only update AGENTS.md if outdated)
|
|
7298
|
-
|
|
7299
|
-
${swap2assistRule}
|
|
7300
|
-
`
|
|
7513
|
+
template: documentCommandTemplate
|
|
7301
7514
|
},
|
|
7302
7515
|
"document-conventions": {
|
|
7303
7516
|
agent: "document_conventions",
|
|
7304
7517
|
description: "Document recently updated naming conventions and terminology.",
|
|
7305
7518
|
subtask: false,
|
|
7306
|
-
template:
|
|
7307
|
-
|
|
7308
|
-
${swap2assistRule}
|
|
7309
|
-
`
|
|
7519
|
+
template: documentConventionsCommandTemplate
|
|
7310
7520
|
},
|
|
7311
7521
|
"document-code": {
|
|
7312
7522
|
agent: "document_code",
|
|
7313
7523
|
description: "Document recently updated technical architecture and design decisions.",
|
|
7314
7524
|
subtask: false,
|
|
7315
|
-
template:
|
|
7316
|
-
|
|
7317
|
-
${swap2assistRule}
|
|
7318
|
-
`
|
|
7525
|
+
template: documentCodeCommandTemplate
|
|
7319
7526
|
},
|
|
7320
7527
|
"document-prd": {
|
|
7321
7528
|
agent: "document_prd",
|
|
7322
7529
|
description: "Document recently updated product requirements and user roles.",
|
|
7323
7530
|
subtask: false,
|
|
7324
|
-
template:
|
|
7325
|
-
|
|
7326
|
-
${swap2assistRule}
|
|
7327
|
-
`
|
|
7531
|
+
template: documentPrdCommandTemplate
|
|
7328
7532
|
},
|
|
7329
7533
|
"document-ux": {
|
|
7330
7534
|
agent: "document_ux",
|
|
7331
7535
|
description: "Document recently updated UX flows, navigation, and styling patterns.",
|
|
7332
7536
|
subtask: false,
|
|
7333
|
-
template:
|
|
7334
|
-
|
|
7335
|
-
${swap2assistRule}
|
|
7336
|
-
`
|
|
7537
|
+
template: documentUxCommandTemplate
|
|
7337
7538
|
},
|
|
7338
7539
|
"git-commit": {
|
|
7339
7540
|
agent: "execute_git_commit",
|
|
7340
7541
|
description: "Automatically commit staged changes.",
|
|
7341
7542
|
subtask: false,
|
|
7342
|
-
template:
|
|
7343
|
-
Base your git commit message on the following:
|
|
7344
|
-
- Purpose of this session (see title)
|
|
7345
|
-
- Your recent conversation with user
|
|
7346
|
-
- Recent changes
|
|
7347
|
-
|
|
7348
|
-
${swap2assistRule}
|
|
7349
|
-
`
|
|
7543
|
+
template: gitCommitCommandTemplate
|
|
7350
7544
|
},
|
|
7351
7545
|
"git-conflict": {
|
|
7352
7546
|
agent: "assist_git_conflict",
|
|
7353
7547
|
description: "Automatically handle git merge conflicts.",
|
|
7354
7548
|
subtask: false,
|
|
7355
|
-
template:
|
|
7356
|
-
|
|
7357
|
-
${swap2assistRule}
|
|
7358
|
-
`
|
|
7549
|
+
template: gitConflictCommandTemplate
|
|
7359
7550
|
},
|
|
7360
7551
|
install: installCommand,
|
|
7361
7552
|
"autocode-install": installCommand,
|
|
@@ -7363,123 +7554,59 @@ ${swap2assistRule}
|
|
|
7363
7554
|
agent: "execute_document",
|
|
7364
7555
|
description: "Document the entire project.",
|
|
7365
7556
|
subtask: true,
|
|
7366
|
-
template:
|
|
7367
|
-
1. Task subagents in parallel: \`document_conventions\`, \`document_code\`, \`document_install\`, \`document_prd\`
|
|
7368
|
-
2. Additionally task \`document_ux\` for frontend/web projects
|
|
7369
|
-
3. Collect all subagent reports
|
|
7370
|
-
4. Use \`author-readme\` skill to update \`README.md\` using collected reports
|
|
7371
|
-
5. Only task \`document_agents\` *AFTER* you had updated \`README.md\` because \`document_agents\` will read your updated \`README.md\` file
|
|
7372
|
-
|
|
7373
|
-
${swap2assistRule}
|
|
7374
|
-
`
|
|
7557
|
+
template: initCommandTemplate
|
|
7375
7558
|
},
|
|
7376
7559
|
"new-assist": {
|
|
7377
7560
|
agent: "temp_session",
|
|
7378
7561
|
description: "Assist task execution in new session.",
|
|
7379
7562
|
subtask: false,
|
|
7380
|
-
template:
|
|
7381
|
-
- PROBLEMS = Brief background context and wrong/missing behavior/info (undesired symptoms)
|
|
7382
|
-
- REQUIREMENTS = Expected system behavior / use case / answer to query
|
|
7383
|
-
- CONSTRAINTS = research scope (domain) or fixed technical/legal limits (facts) like security measures, dependencies, performance limitations, maintainability limitations, failure handling, reversibility, etc.
|
|
7384
|
-
- RISKS = any uncertainties (inaccessible/conflicting info), *assumed* limitations (edge-case concerns), external blockers (uncontrollable events/dependencies preventing solution), assumed caused of problem
|
|
7385
|
-
- PROPOSAL = only include if user suggested a solution
|
|
7386
|
-
- DATA = proof (all known paths/links to sources or facts), previous tool output, research results, exact values provided by user (do not repeat already included data)`, "Assist task execution session")
|
|
7563
|
+
template: newAssistCommandTemplate
|
|
7387
7564
|
},
|
|
7388
7565
|
"new-auto": {
|
|
7389
7566
|
agent: "temp_session",
|
|
7390
7567
|
description: "Autonomously execute task in new session.",
|
|
7391
7568
|
subtask: false,
|
|
7392
|
-
template:
|
|
7393
|
-
- PROBLEMS = Brief background context and wrong/missing behavior/info (undesired symptoms)
|
|
7394
|
-
- REQUIREMENTS = Expected system behavior / use case / answer to query
|
|
7395
|
-
- CONSTRAINTS = research scope (domain) or fixed technical/legal limits (facts) like security measures, dependencies, performance limitations, maintainability limitations, failure handling, reversibility, etc.
|
|
7396
|
-
- RISKS = any uncertainties (inaccessible/conflicting info), *assumed* limitations (edge-case concerns), external blockers (uncontrollable events/dependencies preventing solution), assumed caused of problem
|
|
7397
|
-
- PROPOSAL = only include if user suggested a solution
|
|
7398
|
-
- DATA = proof (all known paths/links to sources or facts), previous tool output, research results, exact values provided by user (do not repeat already included data)`, "Follow autonomous task execution session")
|
|
7569
|
+
template: newAutoCommandTemplate
|
|
7399
7570
|
},
|
|
7400
7571
|
"new-design": {
|
|
7401
7572
|
agent: "temp_session",
|
|
7402
7573
|
description: "Design solutions in new session.",
|
|
7403
7574
|
subtask: false,
|
|
7404
|
-
template:
|
|
7405
|
-
- how: suggested cause of action
|
|
7406
|
-
- what: expectation of new session
|
|
7407
|
-
- why: brief background context
|
|
7408
|
-
- context: all known facts related to instruction such as (past actions + its outcomes, failed attempts + reason for failure, constraints/opportunities discovered related to instruction)
|
|
7409
|
-
- proof: all known paths/links to sources of facts
|
|
7410
|
-
- data: previous tool output / research results / data provided by user (only include related to instruction; do not repeat already included data)`, "Advise design session")
|
|
7575
|
+
template: newDesignCommandTemplate
|
|
7411
7576
|
},
|
|
7412
7577
|
"new-research": {
|
|
7413
7578
|
agent: "temp_session",
|
|
7414
7579
|
description: "Research topic in new session that produces a research report.",
|
|
7415
7580
|
subtask: false,
|
|
7416
|
-
template:
|
|
7417
|
-
- subject: name what info is required based on recent reasoning / user conversation
|
|
7418
|
-
- context: include all known facts related to instruction such as (past actions + its outcomes, failed attempts + reason for failure, constraints/opportunities discovered related to instruction)
|
|
7419
|
-
- proof: all known paths/links to sources of facts
|
|
7420
|
-
- data: previous tool output / research results / data provided by user (only include related to instruction; do not repeat already included data)`, "Follow research session")
|
|
7581
|
+
template: newResearchCommandTemplate
|
|
7421
7582
|
},
|
|
7422
7583
|
"new-troubleshoot": {
|
|
7423
7584
|
agent: "temp_session",
|
|
7424
7585
|
description: "Troubleshoot issue in new session.",
|
|
7425
7586
|
subtask: false,
|
|
7426
|
-
template:
|
|
7427
|
-
- SYMPTOMS = recently observed unexpected/wrong behavior
|
|
7428
|
-
- ENVIRONMENT = environment context where SYMPTOM occurs (like OS, runtime version, profile, config)
|
|
7429
|
-
- BACKGROUND = why assignment is needed (if known)
|
|
7430
|
-
- CHANGES = what you recently changed that might be relevant to obstacle
|
|
7431
|
-
- EXPECTATION = what is expected to happen (like "respond 200 OK")
|
|
7432
|
-
- CAUSE = what possibly caused SYMPTOM (like "new auth library is incorrectly implemented")
|
|
7433
|
-
- EVIDENCE = facts that support theory of CAUSE (include blockcode of actual data, snippets of code, filenames, line numbers, urls, etc)
|
|
7434
|
-
- ERROR = EVIDENCE observed facts about SYMPTOM (like specific error message, stack trace, or exception)
|
|
7435
|
-
- TRACE = where ERROR was observed (like trace_id, log file, line number, timestamp, surrounding log messages, etc)
|
|
7436
|
-
- REPRODUCTION = steps to reproduce SYMPTOM in ENVIRONMENT include sample input data in blockcode (if possible)`, "Follow troubleshoot session")
|
|
7587
|
+
template: newTroubleshootCommandTemplate
|
|
7437
7588
|
},
|
|
7438
7589
|
"repeat-as-md": {
|
|
7439
7590
|
description: "Repeat the last response inside a fenced Markdown code block.",
|
|
7440
7591
|
subtask: false,
|
|
7441
|
-
template:
|
|
7442
|
-
Repeat your last response wrapped in markdown codeblock:
|
|
7443
|
-
|
|
7444
|
-
For example:
|
|
7445
|
-
|
|
7446
|
-
\`\`\`\`\`\`\`\`\`markdown
|
|
7447
|
-
Last response goes here...
|
|
7448
|
-
\`\`\`\`\`\`\`\`\`
|
|
7449
|
-
`
|
|
7592
|
+
template: repeatAsMdCommandTemplate
|
|
7450
7593
|
},
|
|
7451
7594
|
"repeat-as-wiki": {
|
|
7452
7595
|
description: "Repeat last response in Atlassian Wiki Markup",
|
|
7453
7596
|
subtask: false,
|
|
7454
|
-
template:
|
|
7455
|
-
Repeat your last response as Markdown block text in Atlassian Wiki Markup (Jira Wiki syntax) format:
|
|
7456
|
-
|
|
7457
|
-
For example:
|
|
7458
|
-
|
|
7459
|
-
\`\`\`\`\`\`\`\`\`markdown
|
|
7460
|
-
Wiki markup goes here...
|
|
7461
|
-
\`\`\`\`\`\`\`\`\`
|
|
7462
|
-
`
|
|
7597
|
+
template: repeatAsWikiCommandTemplate
|
|
7463
7598
|
},
|
|
7464
7599
|
"report-last": {
|
|
7465
7600
|
agent: "temp_report",
|
|
7466
7601
|
description: "Provide detailed report of last task.",
|
|
7467
7602
|
subtask: false,
|
|
7468
|
-
template:
|
|
7469
|
-
Report **ONLY** on your last assignment (last user requested task). Include only last user prompt, recent actions since last user prompt and recent tool outputs into consideration when you compile the report.
|
|
7470
|
-
|
|
7471
|
-
${swap2assistRule}
|
|
7472
|
-
`
|
|
7603
|
+
template: reportLastCommandTemplate
|
|
7473
7604
|
},
|
|
7474
7605
|
"report-session": {
|
|
7475
7606
|
agent: "temp_report",
|
|
7476
7607
|
description: "Provide detailed report of entire session.",
|
|
7477
7608
|
subtask: false,
|
|
7478
|
-
template:
|
|
7479
|
-
Report on entire session taking all actions, tool outputs and prompts in consideration.
|
|
7480
|
-
|
|
7481
|
-
${swap2assistRule}
|
|
7482
|
-
`
|
|
7609
|
+
template: reportSessionCommandTemplate
|
|
7483
7610
|
},
|
|
7484
7611
|
resume: {
|
|
7485
7612
|
description: "Resume interrupted session.",
|
|
@@ -19906,6 +20033,9 @@ function tool(input) {
|
|
|
19906
20033
|
return input;
|
|
19907
20034
|
}
|
|
19908
20035
|
tool.schema = exports_external;
|
|
20036
|
+
// src/tools/autocode_agent_execute.ts
|
|
20037
|
+
import { mkdir as mkdir4, readFile as readFile3, readdir as readdir4, rename as rename3, rm as rm4, stat as stat3, writeFile as writeFile4 } from "fs/promises";
|
|
20038
|
+
|
|
19909
20039
|
// src/utils/tools.ts
|
|
19910
20040
|
var retryCounts = new Map;
|
|
19911
20041
|
function sortValue(value, seen = new WeakSet) {
|
|
@@ -19980,6 +20110,7 @@ function createLifecycleJobRequiredRetryResponse(failedAction, subject) {
|
|
|
19980
20110
|
}
|
|
19981
20111
|
|
|
19982
20112
|
// src/utils/agent_swap.ts
|
|
20113
|
+
var primaryAutocodeAgents = ["assist", "auto", "design", "research"];
|
|
19983
20114
|
var allowedAutocodeSessionCreateAgents = ["assist", "auto", "research", "design"];
|
|
19984
20115
|
var allowedAutocodeSessionCreateAgentsText = allowedAutocodeSessionCreateAgents.join(", ");
|
|
19985
20116
|
function isNonBlankString(value) {
|
|
@@ -20003,6 +20134,15 @@ function unwrapOpenCodeError(response) {
|
|
|
20003
20134
|
function resolveAutocodeAgentSessionTier(agent) {
|
|
20004
20135
|
return getAgentTier(agent);
|
|
20005
20136
|
}
|
|
20137
|
+
function isPrimaryAutocodeAgent(agent) {
|
|
20138
|
+
return typeof agent === "string" && primaryAutocodeAgents.includes(agent);
|
|
20139
|
+
}
|
|
20140
|
+
function getMessageCreatedTime(message) {
|
|
20141
|
+
return message.info.time.created;
|
|
20142
|
+
}
|
|
20143
|
+
function getMessageAgent(message) {
|
|
20144
|
+
return message.info.agent;
|
|
20145
|
+
}
|
|
20006
20146
|
function resolveTierModel(tier, tiers) {
|
|
20007
20147
|
if (!tier) {
|
|
20008
20148
|
return {};
|
|
@@ -20147,10 +20287,220 @@ function createAutocodeAgentSwapSuccessResponse(agent, sessionID) {
|
|
|
20147
20287
|
message
|
|
20148
20288
|
});
|
|
20149
20289
|
}
|
|
20290
|
+
function createAutocodeAgentPreviousSkippedResponse(sessionID, reason) {
|
|
20291
|
+
const message = `Skipped previous-primary handoff for current session (${sessionID}): ${reason}`;
|
|
20292
|
+
return JSON.stringify({
|
|
20293
|
+
session_id: sessionID,
|
|
20294
|
+
skipped: true,
|
|
20295
|
+
reason,
|
|
20296
|
+
message
|
|
20297
|
+
});
|
|
20298
|
+
}
|
|
20299
|
+
async function findPreviousPrimaryAutocodeAgent(client, directory, sessionID, currentAgent) {
|
|
20300
|
+
if (!client.session.messages) {
|
|
20301
|
+
return {
|
|
20302
|
+
error: "Unable to inspect current session history: session.messages is unavailable",
|
|
20303
|
+
instruction: ""
|
|
20304
|
+
};
|
|
20305
|
+
}
|
|
20306
|
+
let response;
|
|
20307
|
+
try {
|
|
20308
|
+
response = await client.session.messages({
|
|
20309
|
+
path: { id: sessionID },
|
|
20310
|
+
query: {
|
|
20311
|
+
directory,
|
|
20312
|
+
limit: 200
|
|
20313
|
+
}
|
|
20314
|
+
});
|
|
20315
|
+
} catch (error45) {
|
|
20316
|
+
return {
|
|
20317
|
+
error: createAutocodeSessionError("session_messages", directory, sessionID, currentAgent ?? "unknown", error45),
|
|
20318
|
+
instruction: ""
|
|
20319
|
+
};
|
|
20320
|
+
}
|
|
20321
|
+
const responseError = unwrapOpenCodeError(response);
|
|
20322
|
+
if (responseError) {
|
|
20323
|
+
return {
|
|
20324
|
+
error: createAutocodeSessionError("session_messages", directory, sessionID, currentAgent ?? "unknown", responseError),
|
|
20325
|
+
instruction: ""
|
|
20326
|
+
};
|
|
20327
|
+
}
|
|
20328
|
+
const responseData = unwrapOpenCodeData(response) ?? [];
|
|
20329
|
+
const sortedMessages = [...responseData].sort((left, right) => getMessageCreatedTime(right) - getMessageCreatedTime(left));
|
|
20330
|
+
for (const message of sortedMessages) {
|
|
20331
|
+
const agent = getMessageAgent(message);
|
|
20332
|
+
if (!isPrimaryAutocodeAgent(agent)) {
|
|
20333
|
+
continue;
|
|
20334
|
+
}
|
|
20335
|
+
if (isPrimaryAutocodeAgent(currentAgent) && agent === currentAgent) {
|
|
20336
|
+
continue;
|
|
20337
|
+
}
|
|
20338
|
+
return {
|
|
20339
|
+
agent,
|
|
20340
|
+
skipped: false
|
|
20341
|
+
};
|
|
20342
|
+
}
|
|
20343
|
+
return {
|
|
20344
|
+
skipped: true,
|
|
20345
|
+
reason: "No previous primary agent found in current session history."
|
|
20346
|
+
};
|
|
20347
|
+
}
|
|
20150
20348
|
async function swapCurrentAutocodeSession(client, directory, sessionID, agent, prompt, resolvedModel = {}) {
|
|
20151
20349
|
return dispatchAutocodeAgentPrompt(client, directory, sessionID, agent, prompt, resolvedModel);
|
|
20152
20350
|
}
|
|
20153
20351
|
|
|
20352
|
+
// src/tools/autocode_agent_execute.ts
|
|
20353
|
+
async function readDirectory3(dirPath, options) {
|
|
20354
|
+
return options?.withFileTypes ? readdir4(dirPath, { withFileTypes: true }) : readdir4(dirPath);
|
|
20355
|
+
}
|
|
20356
|
+
var defaultFileSystem = {
|
|
20357
|
+
mkdir: mkdir4,
|
|
20358
|
+
readFile: readFile3,
|
|
20359
|
+
readdir: readDirectory3,
|
|
20360
|
+
rename: rename3,
|
|
20361
|
+
rm: rm4,
|
|
20362
|
+
stat: stat3,
|
|
20363
|
+
writeFile: writeFile4
|
|
20364
|
+
};
|
|
20365
|
+
function isExecutionAgent(agent) {
|
|
20366
|
+
return agent === "assist" || agent === "auto";
|
|
20367
|
+
}
|
|
20368
|
+
function getTargetStatus(agent, _currentStatus) {
|
|
20369
|
+
return agent === "assist" ? "assist" : "executing";
|
|
20370
|
+
}
|
|
20371
|
+
function createAgentExecutePrompt(jobName, plan) {
|
|
20372
|
+
return `Selected job: ${jobName}
|
|
20373
|
+
|
|
20374
|
+
plan.md:
|
|
20375
|
+
${plan}`;
|
|
20376
|
+
}
|
|
20377
|
+
function createMissingJobRetryResponse(jobName) {
|
|
20378
|
+
return createRetryResponse("autocode_agent_execute", `Planned job not found: ${jobName}`, "Provide job_name from an existing lifecycle job under .agents/jobs/.");
|
|
20379
|
+
}
|
|
20380
|
+
function createCollisionRetryResponse(jobName) {
|
|
20381
|
+
return createRetryResponse("autocode_agent_execute", `Active lifecycle collision for ${jobName}`, "Resolve duplicate active lifecycle directories for this job before retrying.");
|
|
20382
|
+
}
|
|
20383
|
+
function createDestinationCollisionRetryResponse(jobName, status) {
|
|
20384
|
+
return createRetryResponse("autocode_agent_execute", `${status} lifecycle directory already exists for ${jobName}`, `Resolve the existing .agents/jobs/${status}/ job collision before retrying.`);
|
|
20385
|
+
}
|
|
20386
|
+
function createMissingPlanRetryResponse(jobName) {
|
|
20387
|
+
return createRetryResponse("autocode_agent_execute", `Plan not found for job: ${jobName}`, "Restore plan.md under the selected job lifecycle directory before retrying.");
|
|
20388
|
+
}
|
|
20389
|
+
function createReviewStatusRetryResponse(jobName) {
|
|
20390
|
+
return createRetryResponse("autocode_agent_execute", `Selected job already in review: ${jobName}`, "Select job outside review before retrying autocode_agent_execute.");
|
|
20391
|
+
}
|
|
20392
|
+
function createAutocodeAgentExecuteTool(client, fileSystem = defaultFileSystem) {
|
|
20393
|
+
return tool({
|
|
20394
|
+
description: "Move selected job to execution status and swap current session to selected agent with plan.md injected.",
|
|
20395
|
+
args: {
|
|
20396
|
+
job_name: tool.schema.string().describe("Selected planned job_name in safe snake_case."),
|
|
20397
|
+
agent: tool.schema.string().describe("Execution agent: assist or auto.")
|
|
20398
|
+
},
|
|
20399
|
+
async execute(args, context) {
|
|
20400
|
+
const requestedJobName = args.job_name?.trim();
|
|
20401
|
+
if (!requestedJobName || !isCompatibleJobName(requestedJobName)) {
|
|
20402
|
+
return createRetryResponse("autocode_agent_execute", `Invalid job_name: ${requestedJobName ?? String(args.job_name)}`, "Provide a safe snake_case job_name containing only lowercase letters, numbers, and underscores.");
|
|
20403
|
+
}
|
|
20404
|
+
if (!isExecutionAgent(args.agent)) {
|
|
20405
|
+
return createRetryResponse("autocode_agent_execute", `Invalid agent: ${args.agent}`, "Provide agent as one of: assist, auto.");
|
|
20406
|
+
}
|
|
20407
|
+
if (!client) {
|
|
20408
|
+
return createAbortResponse("autocode_agent_execute", "Unable to swap current session: client is unavailable");
|
|
20409
|
+
}
|
|
20410
|
+
try {
|
|
20411
|
+
const storageRoot = resolveAgentsStorageRoot(context);
|
|
20412
|
+
const directoryFileSystem = createDirectoryFileSystem(fileSystem);
|
|
20413
|
+
const resolved = await resolvePlannedJob(directoryFileSystem, storageRoot, requestedJobName);
|
|
20414
|
+
if (resolved.type === "missing") {
|
|
20415
|
+
return createMissingJobRetryResponse(requestedJobName);
|
|
20416
|
+
}
|
|
20417
|
+
if (resolved.type === "collision") {
|
|
20418
|
+
return createCollisionRetryResponse(requestedJobName);
|
|
20419
|
+
}
|
|
20420
|
+
if (resolved.job.status === "review") {
|
|
20421
|
+
return createReviewStatusRetryResponse(requestedJobName);
|
|
20422
|
+
}
|
|
20423
|
+
const planPath = getJobFilePath(storageRoot, resolved.job.directory, resolved.job.job_name, "plan.md");
|
|
20424
|
+
let plan;
|
|
20425
|
+
try {
|
|
20426
|
+
plan = await fileSystem.readFile(planPath, "utf8");
|
|
20427
|
+
} catch (error45) {
|
|
20428
|
+
const code = error45.code;
|
|
20429
|
+
if (code === "ENOENT") {
|
|
20430
|
+
return createMissingPlanRetryResponse(requestedJobName);
|
|
20431
|
+
}
|
|
20432
|
+
throw error45;
|
|
20433
|
+
}
|
|
20434
|
+
if (!directoryFileSystem.rename) {
|
|
20435
|
+
return createAbortResponse("autocode_agent_execute", "Unable to update selected job lifecycle: rename is unavailable");
|
|
20436
|
+
}
|
|
20437
|
+
const targetStatus = getTargetStatus(args.agent, resolved.job.status);
|
|
20438
|
+
const moveFileSystem = {
|
|
20439
|
+
...directoryFileSystem,
|
|
20440
|
+
rename: directoryFileSystem.rename
|
|
20441
|
+
};
|
|
20442
|
+
const moved = await moveResolvedPlannedJobToStatus(storageRoot, resolved.job, targetStatus, moveFileSystem);
|
|
20443
|
+
if (moved.type === "missing") {
|
|
20444
|
+
return createMissingJobRetryResponse(requestedJobName);
|
|
20445
|
+
}
|
|
20446
|
+
if (moved.type === "collision") {
|
|
20447
|
+
return createCollisionRetryResponse(requestedJobName);
|
|
20448
|
+
}
|
|
20449
|
+
if (moved.type === "destination_collision") {
|
|
20450
|
+
return createDestinationCollisionRetryResponse(requestedJobName, targetStatus);
|
|
20451
|
+
}
|
|
20452
|
+
const sessionSettings = await resolveAutocodeAgentSessionSettings(args.agent, context.worktree, context.directory);
|
|
20453
|
+
if ("error" in sessionSettings) {
|
|
20454
|
+
return createAbortResponse("autocode_agent_execute", sessionSettings.error);
|
|
20455
|
+
}
|
|
20456
|
+
const handoff = await swapCurrentAutocodeSession(client, context.directory, context.sessionID, args.agent, createAgentExecutePrompt(moved.job.job_name, plan), sessionSettings.resolvedModel);
|
|
20457
|
+
if ("error" in handoff) {
|
|
20458
|
+
return createAbortResponse("autocode_agent_execute", handoff.error);
|
|
20459
|
+
}
|
|
20460
|
+
return JSON.stringify({
|
|
20461
|
+
current_status: moved.job.status
|
|
20462
|
+
});
|
|
20463
|
+
} catch (error45) {
|
|
20464
|
+
return createAbortResponse("autocode_agent_execute", error45);
|
|
20465
|
+
}
|
|
20466
|
+
}
|
|
20467
|
+
});
|
|
20468
|
+
}
|
|
20469
|
+
|
|
20470
|
+
// src/tools/autocode_agent_previous.ts
|
|
20471
|
+
function createAutocodeAgentPreviousTool(client) {
|
|
20472
|
+
return tool({
|
|
20473
|
+
description: "Swap agent back to previous primary agent.",
|
|
20474
|
+
args: {},
|
|
20475
|
+
async execute(_args, context) {
|
|
20476
|
+
if (!client) {
|
|
20477
|
+
return createAbortResponse("autocode_agent_previous", "Unable to inspect current session history: client is unavailable");
|
|
20478
|
+
}
|
|
20479
|
+
try {
|
|
20480
|
+
const currentAgent = context.agent;
|
|
20481
|
+
const previousPrimary = await findPreviousPrimaryAutocodeAgent(client, context.directory, context.sessionID, currentAgent);
|
|
20482
|
+
if ("error" in previousPrimary) {
|
|
20483
|
+
return createAbortResponse("autocode_agent_previous", previousPrimary.error);
|
|
20484
|
+
}
|
|
20485
|
+
if (previousPrimary.skipped || !previousPrimary.agent) {
|
|
20486
|
+
return createAutocodeAgentPreviousSkippedResponse(context.sessionID, previousPrimary.reason ?? "No previous primary agent found in current session history.");
|
|
20487
|
+
}
|
|
20488
|
+
const sessionSettings = await resolveAutocodeAgentSessionSettings(previousPrimary.agent, context.worktree, context.directory);
|
|
20489
|
+
if ("error" in sessionSettings) {
|
|
20490
|
+
return createAbortResponse("autocode_agent_previous", sessionSettings.error);
|
|
20491
|
+
}
|
|
20492
|
+
const handoff = await swapCurrentAutocodeSession(client, context.directory, context.sessionID, previousPrimary.agent, "Ask user for Next Action.", sessionSettings.resolvedModel);
|
|
20493
|
+
if ("error" in handoff) {
|
|
20494
|
+
return createAbortResponse("autocode_agent_previous", handoff.error);
|
|
20495
|
+
}
|
|
20496
|
+
return createAutocodeAgentSwapSuccessResponse(previousPrimary.agent, handoff.sessionID);
|
|
20497
|
+
} catch (error45) {
|
|
20498
|
+
return createAbortResponse("autocode_agent_previous", error45);
|
|
20499
|
+
}
|
|
20500
|
+
}
|
|
20501
|
+
});
|
|
20502
|
+
}
|
|
20503
|
+
|
|
20154
20504
|
// src/tools/autocode_agent_swap.ts
|
|
20155
20505
|
function createAutocodeAgentSwapTool(client) {
|
|
20156
20506
|
return tool({
|
|
@@ -20185,12 +20535,12 @@ function createAutocodeAgentSwapTool(client) {
|
|
|
20185
20535
|
}
|
|
20186
20536
|
|
|
20187
20537
|
// src/tools/autocode_concept_create.ts
|
|
20188
|
-
import { mkdir as
|
|
20538
|
+
import { mkdir as mkdir5, stat as stat4, writeFile as writeFile5 } from "fs/promises";
|
|
20189
20539
|
import path5 from "path";
|
|
20190
|
-
var
|
|
20191
|
-
mkdir:
|
|
20192
|
-
stat:
|
|
20193
|
-
writeFile:
|
|
20540
|
+
var defaultFileSystem2 = {
|
|
20541
|
+
mkdir: mkdir5,
|
|
20542
|
+
stat: stat4,
|
|
20543
|
+
writeFile: writeFile5
|
|
20194
20544
|
};
|
|
20195
20545
|
function formatLocalTimestamp(date5) {
|
|
20196
20546
|
const pad = (value) => String(value).padStart(2, "0");
|
|
@@ -20233,7 +20583,7 @@ async function resolveAvailableBacklogPath(fileSystem, worktree, baseLabel) {
|
|
|
20233
20583
|
}
|
|
20234
20584
|
throw new Error(`Unable to allocate backlog path for ${baseLabel}`);
|
|
20235
20585
|
}
|
|
20236
|
-
function createAutocodeConceptCreateTool(client, fileSystem =
|
|
20586
|
+
function createAutocodeConceptCreateTool(client, fileSystem = defaultFileSystem2, getNow = () => new Date) {
|
|
20237
20587
|
return tool({
|
|
20238
20588
|
description: "Create one concept Markdown file in .agents/jobs/concepts/ from a title or label and raw Markdown body.",
|
|
20239
20589
|
args: {
|
|
@@ -20279,11 +20629,11 @@ ${args.concept}`);
|
|
|
20279
20629
|
}
|
|
20280
20630
|
|
|
20281
20631
|
// src/tools/autocode_concept_list.ts
|
|
20282
|
-
import { readFile as
|
|
20632
|
+
import { readFile as readFile4, readdir as readdir5 } from "fs/promises";
|
|
20283
20633
|
import path6 from "path";
|
|
20284
|
-
var
|
|
20285
|
-
readdir:
|
|
20286
|
-
readFile:
|
|
20634
|
+
var defaultFileSystem3 = {
|
|
20635
|
+
readdir: readdir5,
|
|
20636
|
+
readFile: readFile4
|
|
20287
20637
|
};
|
|
20288
20638
|
function getDescription(source) {
|
|
20289
20639
|
const line = stripLeadingYamlFrontMatter(source).split(/\r?\n/).map((line2) => line2.trim()).find((line2) => !/^#{1,6}\s+/.test(line2) && /[a-z0-9]/i.test(line2)) ?? "";
|
|
@@ -20298,7 +20648,7 @@ async function readDirectoryEntries3(fileSystem, directory) {
|
|
|
20298
20648
|
throw error45;
|
|
20299
20649
|
}
|
|
20300
20650
|
}
|
|
20301
|
-
function createAutocodeConceptListTool(fileSystem =
|
|
20651
|
+
function createAutocodeConceptListTool(fileSystem = defaultFileSystem3) {
|
|
20302
20652
|
return tool({
|
|
20303
20653
|
description: "List available concepts.",
|
|
20304
20654
|
args: {},
|
|
@@ -20322,13 +20672,13 @@ function createAutocodeConceptListTool(fileSystem = defaultFileSystem2) {
|
|
|
20322
20672
|
}
|
|
20323
20673
|
|
|
20324
20674
|
// src/tools/autocode_concept_read.ts
|
|
20325
|
-
import { mkdir as
|
|
20675
|
+
import { mkdir as mkdir6, readFile as readFile5, rename as rename4, writeFile as writeFile6 } from "fs/promises";
|
|
20326
20676
|
import path7 from "path";
|
|
20327
|
-
var
|
|
20328
|
-
mkdir:
|
|
20329
|
-
readFile:
|
|
20330
|
-
rename:
|
|
20331
|
-
writeFile:
|
|
20677
|
+
var defaultFileSystem4 = {
|
|
20678
|
+
mkdir: mkdir6,
|
|
20679
|
+
readFile: readFile5,
|
|
20680
|
+
rename: rename4,
|
|
20681
|
+
writeFile: writeFile6
|
|
20332
20682
|
};
|
|
20333
20683
|
function getBacklogPath(worktree, label) {
|
|
20334
20684
|
return path7.join(worktree, getRelativeConceptFilePath(label));
|
|
@@ -20343,7 +20693,7 @@ function normalizeConceptReadToolArgs(clientOrFileSystem, maybeFileSystem) {
|
|
|
20343
20693
|
if (isFileSystem(clientOrFileSystem)) {
|
|
20344
20694
|
return { fileSystem: clientOrFileSystem };
|
|
20345
20695
|
}
|
|
20346
|
-
return { client: clientOrFileSystem, fileSystem:
|
|
20696
|
+
return { client: clientOrFileSystem, fileSystem: defaultFileSystem4 };
|
|
20347
20697
|
}
|
|
20348
20698
|
function createAutocodeConceptReadTool(clientOrFileSystem, maybeFileSystem) {
|
|
20349
20699
|
const { client, fileSystem } = normalizeConceptReadToolArgs(clientOrFileSystem, maybeFileSystem);
|
|
@@ -20381,12 +20731,12 @@ function createAutocodeConceptReadTool(clientOrFileSystem, maybeFileSystem) {
|
|
|
20381
20731
|
}
|
|
20382
20732
|
|
|
20383
20733
|
// src/tools/autocode_criteria.ts
|
|
20384
|
-
import { appendFile, mkdir as
|
|
20734
|
+
import { appendFile, mkdir as mkdir7, readFile as readFile6, readdir as readdir6, writeFile as writeFile7 } from "fs/promises";
|
|
20385
20735
|
async function readDirectoryEntries4(dirPath, options) {
|
|
20386
|
-
return
|
|
20736
|
+
return readdir6(dirPath, options);
|
|
20387
20737
|
}
|
|
20388
|
-
async function
|
|
20389
|
-
return options?.withFileTypes ?
|
|
20738
|
+
async function readDirectory4(dirPath, options) {
|
|
20739
|
+
return options?.withFileTypes ? readdir6(dirPath, { withFileTypes: true }) : readdir6(dirPath);
|
|
20390
20740
|
}
|
|
20391
20741
|
function createResolveJobFileSystem(fileSystem) {
|
|
20392
20742
|
return {
|
|
@@ -20397,12 +20747,12 @@ function createResolveJobFileSystem(fileSystem) {
|
|
|
20397
20747
|
}
|
|
20398
20748
|
};
|
|
20399
20749
|
}
|
|
20400
|
-
var
|
|
20750
|
+
var defaultFileSystem5 = {
|
|
20401
20751
|
appendFile,
|
|
20402
|
-
mkdir:
|
|
20403
|
-
readFile:
|
|
20404
|
-
readdir:
|
|
20405
|
-
writeFile:
|
|
20752
|
+
mkdir: mkdir7,
|
|
20753
|
+
readFile: readFile6,
|
|
20754
|
+
readdir: readDirectory4,
|
|
20755
|
+
writeFile: writeFile7
|
|
20406
20756
|
};
|
|
20407
20757
|
function isPlannedJobNotFoundError(error45) {
|
|
20408
20758
|
return error45.message?.startsWith("Planned job not found:") ?? false;
|
|
@@ -20455,7 +20805,7 @@ function normalizeCriteriaToolArgs(clientOrFileSystem, maybeFileSystem) {
|
|
|
20455
20805
|
if (candidate && "readFile" in candidate && "writeFile" in candidate) {
|
|
20456
20806
|
return { fileSystem: candidate };
|
|
20457
20807
|
}
|
|
20458
|
-
return { client: candidate, fileSystem:
|
|
20808
|
+
return { client: candidate, fileSystem: defaultFileSystem5 };
|
|
20459
20809
|
}
|
|
20460
20810
|
async function resolveCriteriaJobName(client, fileSystem, context, failedAction, options = {}) {
|
|
20461
20811
|
const identity = await resolvePlannedJobIdentity(createResolveJobFileSystem(fileSystem), client, context, "");
|
|
@@ -22085,18 +22435,18 @@ function createAutocodeDependenciesTool(deps = defaultSandboxDependencies) {
|
|
|
22085
22435
|
}
|
|
22086
22436
|
|
|
22087
22437
|
// src/tools/autocode_job_execute.ts
|
|
22088
|
-
import { mkdir as
|
|
22089
|
-
async function
|
|
22090
|
-
return options?.withFileTypes ?
|
|
22438
|
+
import { mkdir as mkdir8, readFile as readFile7, readdir as readdir7, rename as rename5, rm as rm5, stat as stat5, writeFile as writeFile8 } from "fs/promises";
|
|
22439
|
+
async function readDirectory5(dirPath, options) {
|
|
22440
|
+
return options?.withFileTypes ? readdir7(dirPath, { withFileTypes: true }) : readdir7(dirPath);
|
|
22091
22441
|
}
|
|
22092
|
-
var
|
|
22093
|
-
mkdir:
|
|
22094
|
-
readFile:
|
|
22095
|
-
readdir:
|
|
22096
|
-
rename:
|
|
22097
|
-
rm:
|
|
22098
|
-
stat:
|
|
22099
|
-
writeFile:
|
|
22442
|
+
var defaultFileSystem6 = {
|
|
22443
|
+
mkdir: mkdir8,
|
|
22444
|
+
readFile: readFile7,
|
|
22445
|
+
readdir: readDirectory5,
|
|
22446
|
+
rename: rename5,
|
|
22447
|
+
rm: rm5,
|
|
22448
|
+
stat: stat5,
|
|
22449
|
+
writeFile: writeFile8
|
|
22100
22450
|
};
|
|
22101
22451
|
function createStartRetryResponse(result, jobName, status) {
|
|
22102
22452
|
if (result.type === "missing") {
|
|
@@ -22116,7 +22466,7 @@ function getExecutionStatus(agent, currentStatus) {
|
|
|
22116
22466
|
}
|
|
22117
22467
|
return currentStatus === "review" ? "review" : "executing";
|
|
22118
22468
|
}
|
|
22119
|
-
function
|
|
22469
|
+
function isExecutionAgent2(agent) {
|
|
22120
22470
|
return agent === "auto" || agent === "assist";
|
|
22121
22471
|
}
|
|
22122
22472
|
async function persistJobSessionID(fileSystem, worktree, job, jobName, sessionID) {
|
|
@@ -22150,7 +22500,7 @@ async function hasExistingSession(client, directory, sessionID) {
|
|
|
22150
22500
|
return false;
|
|
22151
22501
|
}
|
|
22152
22502
|
}
|
|
22153
|
-
function createAutocodeJobExecuteTool(client, fileSystem =
|
|
22503
|
+
function createAutocodeJobExecuteTool(client, fileSystem = defaultFileSystem6) {
|
|
22154
22504
|
return tool({
|
|
22155
22505
|
description: "Execute job.",
|
|
22156
22506
|
args: {
|
|
@@ -22158,7 +22508,7 @@ function createAutocodeJobExecuteTool(client, fileSystem = defaultFileSystem5) {
|
|
|
22158
22508
|
},
|
|
22159
22509
|
async execute(args, context) {
|
|
22160
22510
|
try {
|
|
22161
|
-
if (!
|
|
22511
|
+
if (!isExecutionAgent2(args.agent)) {
|
|
22162
22512
|
return createRetryResponse("autocode_job_execute", `Invalid agent: ${args.agent}`, "Provide agent as one of: auto, assist.");
|
|
22163
22513
|
}
|
|
22164
22514
|
const storageRoot = resolveAgentsStorageRoot(context);
|
|
@@ -22246,13 +22596,13 @@ function createAutocodeJobExecuteTool(client, fileSystem = defaultFileSystem5) {
|
|
|
22246
22596
|
}
|
|
22247
22597
|
|
|
22248
22598
|
// src/tools/autocode_job_list.ts
|
|
22249
|
-
import { readFile as
|
|
22250
|
-
async function
|
|
22251
|
-
return options?.withFileTypes ?
|
|
22599
|
+
import { readFile as readFile8, readdir as readdir8 } from "fs/promises";
|
|
22600
|
+
async function readDirectory6(dirPath, options) {
|
|
22601
|
+
return options?.withFileTypes ? readdir8(dirPath, { withFileTypes: true }) : readdir8(dirPath);
|
|
22252
22602
|
}
|
|
22253
|
-
var
|
|
22254
|
-
readFile:
|
|
22255
|
-
readdir:
|
|
22603
|
+
var defaultFileSystem7 = {
|
|
22604
|
+
readFile: readFile8,
|
|
22605
|
+
readdir: readDirectory6
|
|
22256
22606
|
};
|
|
22257
22607
|
async function executePlannedJobList(fileSystem, worktree, options) {
|
|
22258
22608
|
try {
|
|
@@ -22267,7 +22617,7 @@ async function executePlannedJobList(fileSystem, worktree, options) {
|
|
|
22267
22617
|
return createAbortResponse(options.failedAction, error45);
|
|
22268
22618
|
}
|
|
22269
22619
|
}
|
|
22270
|
-
function createAutocodeJobListTool(fileSystem =
|
|
22620
|
+
function createAutocodeJobListTool(fileSystem = defaultFileSystem7) {
|
|
22271
22621
|
return tool({
|
|
22272
22622
|
description: "List active drafts/jobs.",
|
|
22273
22623
|
args: {
|
|
@@ -22288,47 +22638,169 @@ function createAutocodeJobListTool(fileSystem = defaultFileSystem6) {
|
|
|
22288
22638
|
});
|
|
22289
22639
|
}
|
|
22290
22640
|
|
|
22291
|
-
// src/tools/
|
|
22292
|
-
import { mkdir as
|
|
22641
|
+
// src/tools/autocode_job_shelve.ts
|
|
22642
|
+
import { mkdir as mkdir9, readFile as readFile9, readdir as readdir9, rename as rename6, rm as rm6, stat as stat6, writeFile as writeFile9 } from "fs/promises";
|
|
22293
22643
|
|
|
22294
22644
|
// src/utils/shelve.ts
|
|
22295
22645
|
async function shelveResolvedPlannedJob(options) {
|
|
22296
|
-
const
|
|
22646
|
+
const timestamp = options.now();
|
|
22647
|
+
const moved = await moveResolvedPlannedJobToStatus(options.storageRoot, options.resolvedJob, "shelved", options.moveFileSystem, {
|
|
22648
|
+
shelvedCollisionTimestamp: timestamp
|
|
22649
|
+
});
|
|
22297
22650
|
if (moved.type !== "success")
|
|
22298
22651
|
return moved;
|
|
22299
22652
|
const solution = createSolutionUtils(options.fileSystem, options.storageRoot, {
|
|
22300
22653
|
getDirectory: async () => moved.job.directory,
|
|
22301
|
-
now:
|
|
22654
|
+
now: () => timestamp
|
|
22302
22655
|
});
|
|
22303
22656
|
const logged = await solution.log(moved.job.job_name, "update_status" /* UpdateStatus */, "shelved", options.assistantResponseText, "Job shelved.");
|
|
22304
22657
|
const title = await updateCurrentSessionTitleToJobName(options.client, options.context, moved.job.job_name, moved.job.status);
|
|
22305
22658
|
const sandboxDeps = options.sandboxDependencies ?? { ...defaultSandboxDependencies, fileSystem: options.fileSystem };
|
|
22306
|
-
const sandboxArchive = await archiveJobSandboxesForShelvedJob(options.storageRoot,
|
|
22659
|
+
const sandboxArchive = await archiveJobSandboxesForShelvedJob(options.storageRoot, options.resolvedJob.job_name, moved.job.absolute_path, sandboxDeps);
|
|
22307
22660
|
return {
|
|
22308
22661
|
type: "success",
|
|
22309
22662
|
moved,
|
|
22310
22663
|
solution: logged,
|
|
22311
22664
|
title,
|
|
22312
|
-
sandbox_archive:
|
|
22665
|
+
sandbox_archive: {
|
|
22666
|
+
...sandboxArchive,
|
|
22667
|
+
job_name: moved.job.job_name
|
|
22668
|
+
}
|
|
22313
22669
|
};
|
|
22314
22670
|
}
|
|
22315
22671
|
|
|
22672
|
+
// src/tools/autocode_job_shelve.ts
|
|
22673
|
+
async function readDirectory7(dirPath, options) {
|
|
22674
|
+
return options?.withFileTypes ? readdir9(dirPath, { withFileTypes: true }) : readdir9(dirPath);
|
|
22675
|
+
}
|
|
22676
|
+
var defaultFileSystem8 = {
|
|
22677
|
+
mkdir: mkdir9,
|
|
22678
|
+
readFile: readFile9,
|
|
22679
|
+
readdir: readDirectory7,
|
|
22680
|
+
rename: rename6,
|
|
22681
|
+
rm: rm6,
|
|
22682
|
+
stat: stat6,
|
|
22683
|
+
writeFile: writeFile9
|
|
22684
|
+
};
|
|
22685
|
+
function normalizeShelveToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNow) {
|
|
22686
|
+
if (typeof fileSystemOrNow === "function") {
|
|
22687
|
+
return { fileSystem: clientOrFileSystem ?? defaultFileSystem8, now: fileSystemOrNow };
|
|
22688
|
+
}
|
|
22689
|
+
if (fileSystemOrNow) {
|
|
22690
|
+
return { client: clientOrFileSystem, fileSystem: fileSystemOrNow, now: maybeNow ?? (() => new Date) };
|
|
22691
|
+
}
|
|
22692
|
+
const candidate = clientOrFileSystem;
|
|
22693
|
+
if (candidate && "readFile" in candidate && "writeFile" in candidate) {
|
|
22694
|
+
return { fileSystem: candidate, now: () => new Date };
|
|
22695
|
+
}
|
|
22696
|
+
return { client: candidate, fileSystem: defaultFileSystem8, now: () => new Date };
|
|
22697
|
+
}
|
|
22698
|
+
function createMissingIdentityRetryResponse() {
|
|
22699
|
+
return createLifecycleJobRequiredRetryResponse("shelve job");
|
|
22700
|
+
}
|
|
22701
|
+
function createMissingJobRetryResponse2(jobName) {
|
|
22702
|
+
return createLifecycleJobRequiredRetryResponse("shelve job", `job ${jobName}`);
|
|
22703
|
+
}
|
|
22704
|
+
function getIdentityRetryResponse(identity) {
|
|
22705
|
+
if (identity.job_name) {
|
|
22706
|
+
if (identity.resolution === "collision") {
|
|
22707
|
+
return createRetryResponse("shelve job", `Planned job lifecycle collision: ${identity.job_name}`, "Resolve duplicate active lifecycle directories for this job before shelving.");
|
|
22708
|
+
}
|
|
22709
|
+
if (identity.resolution === "missing") {
|
|
22710
|
+
return createMissingJobRetryResponse2(identity.job_name);
|
|
22711
|
+
}
|
|
22712
|
+
}
|
|
22713
|
+
return createMissingIdentityRetryResponse();
|
|
22714
|
+
}
|
|
22715
|
+
function createAutocodeJobShelveTool(clientOrFileSystem, fileSystemOrNow, maybeNow) {
|
|
22716
|
+
const { client, fileSystem, now } = normalizeShelveToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNow);
|
|
22717
|
+
return tool({
|
|
22718
|
+
description: "Shelve current lifecycle job into .agents/jobs/shelved/{name}/.",
|
|
22719
|
+
args: {},
|
|
22720
|
+
async execute(_args, context) {
|
|
22721
|
+
if (!client) {
|
|
22722
|
+
return createMissingIdentityRetryResponse();
|
|
22723
|
+
}
|
|
22724
|
+
try {
|
|
22725
|
+
const storageRoot = resolveAgentsStorageRoot(context);
|
|
22726
|
+
const directoryFileSystem = createDirectoryFileSystem(fileSystem);
|
|
22727
|
+
const identity = await resolvePlannedJobIdentity(directoryFileSystem, client, context, { includeShelved: true });
|
|
22728
|
+
if (identity.mode !== "planned" || !identity.job_name) {
|
|
22729
|
+
return getIdentityRetryResponse(identity);
|
|
22730
|
+
}
|
|
22731
|
+
const jobName = identity.job_name;
|
|
22732
|
+
const resolvedJob = identity.resolved_job;
|
|
22733
|
+
if (!resolvedJob) {
|
|
22734
|
+
return createAbortResponse("shelve job", "Resolved planned-job identity is missing lifecycle details.");
|
|
22735
|
+
}
|
|
22736
|
+
if (!directoryFileSystem.rename) {
|
|
22737
|
+
return createAbortResponse("shelve job", "Unable to move planned job lifecycle directory: rename is unavailable");
|
|
22738
|
+
}
|
|
22739
|
+
const reportContentResult = await readLatestAssistantResponseText(client, context);
|
|
22740
|
+
if (reportContentResult.error) {
|
|
22741
|
+
return createAbortResponse("inspect current session messages", reportContentResult.error);
|
|
22742
|
+
}
|
|
22743
|
+
if (reportContentResult.limitation) {
|
|
22744
|
+
return createAbortResponse("inspect current session messages", reportContentResult.limitation);
|
|
22745
|
+
}
|
|
22746
|
+
if (!reportContentResult.text?.trim()) {
|
|
22747
|
+
return createRetryResponse("shelve job", "No assistant response text was found in the current session.", "First present the user-facing lifecycle update in assistant text with concrete actions and a separate reason/evidence summary, then call autocode_job_shelve again.");
|
|
22748
|
+
}
|
|
22749
|
+
const shelved = await shelveResolvedPlannedJob({
|
|
22750
|
+
storageRoot,
|
|
22751
|
+
client,
|
|
22752
|
+
context,
|
|
22753
|
+
fileSystem,
|
|
22754
|
+
moveFileSystem: { ...directoryFileSystem, rename: directoryFileSystem.rename },
|
|
22755
|
+
now,
|
|
22756
|
+
resolvedJob,
|
|
22757
|
+
assistantResponseText: reportContentResult.text
|
|
22758
|
+
});
|
|
22759
|
+
if (shelved.type === "missing") {
|
|
22760
|
+
return createMissingJobRetryResponse2(jobName);
|
|
22761
|
+
}
|
|
22762
|
+
if (shelved.type === "collision") {
|
|
22763
|
+
return createRetryResponse("shelve job", `Planned job lifecycle collision: ${jobName}`, "Resolve duplicate active lifecycle directories for this job before shelving.");
|
|
22764
|
+
}
|
|
22765
|
+
if (shelved.type === "destination_collision") {
|
|
22766
|
+
return createRetryResponse("shelve job", `Destination lifecycle directory already exists for ${jobName}`, "Resolve the existing lifecycle directory collision before shelving.");
|
|
22767
|
+
}
|
|
22768
|
+
if (!shelved.sandbox_archive.ok) {
|
|
22769
|
+
return createRetryResponse("archive job sandboxes", shelved.sandbox_archive.reason, "Resolve the sandbox archive collision or unsafe path before retrying. Do not overwrite existing sandbox archives.");
|
|
22770
|
+
}
|
|
22771
|
+
return JSON.stringify({
|
|
22772
|
+
job_name: shelved.moved.job.job_name,
|
|
22773
|
+
current_status: "shelved",
|
|
22774
|
+
job_path: shelved.moved.job.job_path,
|
|
22775
|
+
solution_path: shelved.solution.relativeSolutionPath,
|
|
22776
|
+
sandbox_archive: shelved.sandbox_archive,
|
|
22777
|
+
title_warning: shelved.title.warning,
|
|
22778
|
+
next_action: "Shelve complete; the job has no active lifecycle directory."
|
|
22779
|
+
});
|
|
22780
|
+
} catch (error45) {
|
|
22781
|
+
return createAbortResponse("shelve job", error45);
|
|
22782
|
+
}
|
|
22783
|
+
}
|
|
22784
|
+
});
|
|
22785
|
+
}
|
|
22786
|
+
|
|
22316
22787
|
// src/tools/autocode_job_status.ts
|
|
22317
|
-
|
|
22318
|
-
|
|
22788
|
+
import { mkdir as mkdir10, readFile as readFile10, readdir as readdir10, rename as rename7, rm as rm7, stat as stat7, writeFile as writeFile10 } from "fs/promises";
|
|
22789
|
+
async function readDirectory8(dirPath, options) {
|
|
22790
|
+
return options?.withFileTypes ? readdir10(dirPath, { withFileTypes: true }) : readdir10(dirPath);
|
|
22319
22791
|
}
|
|
22320
|
-
var
|
|
22321
|
-
mkdir:
|
|
22322
|
-
readFile:
|
|
22323
|
-
readdir:
|
|
22324
|
-
rename:
|
|
22325
|
-
rm:
|
|
22326
|
-
stat:
|
|
22327
|
-
writeFile:
|
|
22792
|
+
var defaultFileSystem9 = {
|
|
22793
|
+
mkdir: mkdir10,
|
|
22794
|
+
readFile: readFile10,
|
|
22795
|
+
readdir: readDirectory8,
|
|
22796
|
+
rename: rename7,
|
|
22797
|
+
rm: rm7,
|
|
22798
|
+
stat: stat7,
|
|
22799
|
+
writeFile: writeFile10
|
|
22328
22800
|
};
|
|
22329
22801
|
function normalizeJobStatusToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNow) {
|
|
22330
22802
|
if (typeof fileSystemOrNow === "function") {
|
|
22331
|
-
return { fileSystem: clientOrFileSystem ??
|
|
22803
|
+
return { fileSystem: clientOrFileSystem ?? defaultFileSystem9, now: fileSystemOrNow };
|
|
22332
22804
|
}
|
|
22333
22805
|
if (fileSystemOrNow) {
|
|
22334
22806
|
return { client: clientOrFileSystem, fileSystem: fileSystemOrNow, now: maybeNow ?? (() => new Date) };
|
|
@@ -22337,18 +22809,18 @@ function normalizeJobStatusToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNo
|
|
|
22337
22809
|
if (candidate && "readFile" in candidate && "writeFile" in candidate) {
|
|
22338
22810
|
return { fileSystem: candidate, now: () => new Date };
|
|
22339
22811
|
}
|
|
22340
|
-
return { client: candidate, fileSystem:
|
|
22812
|
+
return { client: candidate, fileSystem: defaultFileSystem9, now: () => new Date };
|
|
22341
22813
|
}
|
|
22342
|
-
function
|
|
22814
|
+
function createMissingJobRetryResponse3(jobName) {
|
|
22343
22815
|
return createLifecycleJobRequiredRetryResponse("update job status", `job ${jobName}`);
|
|
22344
22816
|
}
|
|
22345
|
-
function
|
|
22817
|
+
function createCollisionRetryResponse2(jobName, status) {
|
|
22346
22818
|
return createRetryResponse("update job status", `Planned job lifecycle collision: ${jobName}`, status === "shelved" ? "Resolve duplicate active lifecycle directories for this job before shelving." : "Resolve duplicate active lifecycle directories for this job before retrying.");
|
|
22347
22819
|
}
|
|
22348
22820
|
function createNextAction(status) {
|
|
22349
22821
|
return status === "shelved" ? "Shelve complete; the job has no active lifecycle directory." : `Continue the job from status ${status}.`;
|
|
22350
22822
|
}
|
|
22351
|
-
function
|
|
22823
|
+
function createMissingIdentityRetryResponse2() {
|
|
22352
22824
|
return createLifecycleJobRequiredRetryResponse("update job status");
|
|
22353
22825
|
}
|
|
22354
22826
|
function getRequestedStatus(args) {
|
|
@@ -22366,16 +22838,16 @@ function getRequestedStatus(args) {
|
|
|
22366
22838
|
error: createRetryResponse("update job status", `Invalid status: ${args.status}`, "Use one of: concepts, drafts, assist, executing, facilitate, review, shelved.")
|
|
22367
22839
|
};
|
|
22368
22840
|
}
|
|
22369
|
-
function
|
|
22841
|
+
function getIdentityRetryResponse2(identity, status) {
|
|
22370
22842
|
if (identity.job_name) {
|
|
22371
22843
|
if (identity.resolution === "collision") {
|
|
22372
|
-
return
|
|
22844
|
+
return createCollisionRetryResponse2(identity.job_name, status);
|
|
22373
22845
|
}
|
|
22374
22846
|
if (identity.resolution === "missing") {
|
|
22375
|
-
return
|
|
22847
|
+
return createMissingJobRetryResponse3(identity.job_name);
|
|
22376
22848
|
}
|
|
22377
22849
|
}
|
|
22378
|
-
return
|
|
22850
|
+
return createMissingIdentityRetryResponse2();
|
|
22379
22851
|
}
|
|
22380
22852
|
function createAutocodeJobStatusTool(clientOrFileSystem, fileSystemOrNow, maybeNow) {
|
|
22381
22853
|
const { client, fileSystem, now } = normalizeJobStatusToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNow);
|
|
@@ -22390,7 +22862,7 @@ function createAutocodeJobStatusTool(clientOrFileSystem, fileSystemOrNow, maybeN
|
|
|
22390
22862
|
return requestedStatusResult.error;
|
|
22391
22863
|
}
|
|
22392
22864
|
if (!client) {
|
|
22393
|
-
return
|
|
22865
|
+
return createMissingIdentityRetryResponse2();
|
|
22394
22866
|
}
|
|
22395
22867
|
try {
|
|
22396
22868
|
const storageRoot = resolveAgentsStorageRoot(context);
|
|
@@ -22398,7 +22870,7 @@ function createAutocodeJobStatusTool(clientOrFileSystem, fileSystemOrNow, maybeN
|
|
|
22398
22870
|
const status = requestedStatusResult.status;
|
|
22399
22871
|
const identity = await resolvePlannedJobIdentity(directoryFileSystem, client, context, { includeShelved: status === "shelved" });
|
|
22400
22872
|
if (identity.mode !== "planned" || !identity.job_name) {
|
|
22401
|
-
return
|
|
22873
|
+
return getIdentityRetryResponse2(identity, status);
|
|
22402
22874
|
}
|
|
22403
22875
|
const jobName = identity.job_name;
|
|
22404
22876
|
const resolvedJob = identity.resolved_job;
|
|
@@ -22435,10 +22907,10 @@ function createAutocodeJobStatusTool(clientOrFileSystem, fileSystemOrNow, maybeN
|
|
|
22435
22907
|
assistantResponseText: reportContentResult.text
|
|
22436
22908
|
});
|
|
22437
22909
|
if (shelved.type === "missing") {
|
|
22438
|
-
return
|
|
22910
|
+
return createMissingJobRetryResponse3(jobName);
|
|
22439
22911
|
}
|
|
22440
22912
|
if (shelved.type === "collision") {
|
|
22441
|
-
return
|
|
22913
|
+
return createCollisionRetryResponse2(jobName, effectiveStatus);
|
|
22442
22914
|
}
|
|
22443
22915
|
if (shelved.type === "destination_collision") {
|
|
22444
22916
|
return createRetryResponse("update job status", `Destination lifecycle directory already exists for ${jobName}`, "Resolve the existing lifecycle directory collision before shelving.");
|
|
@@ -22458,10 +22930,10 @@ function createAutocodeJobStatusTool(clientOrFileSystem, fileSystemOrNow, maybeN
|
|
|
22458
22930
|
}
|
|
22459
22931
|
const moved = await movePlannedJobToStatus(storageRoot, jobName, effectiveStatus, moveFileSystem);
|
|
22460
22932
|
if (moved.type === "missing") {
|
|
22461
|
-
return
|
|
22933
|
+
return createMissingJobRetryResponse3(jobName);
|
|
22462
22934
|
}
|
|
22463
22935
|
if (moved.type === "collision") {
|
|
22464
|
-
return
|
|
22936
|
+
return createCollisionRetryResponse2(jobName, effectiveStatus);
|
|
22465
22937
|
}
|
|
22466
22938
|
if (moved.type === "destination_collision") {
|
|
22467
22939
|
return createRetryResponse("update job status", `Destination lifecycle directory already exists for ${jobName}`, "Resolve the existing lifecycle directory collision before retrying.");
|
|
@@ -22489,7 +22961,7 @@ function createAutocodeJobStatusTool(clientOrFileSystem, fileSystemOrNow, maybeN
|
|
|
22489
22961
|
// src/tools/autocode_logo_find.ts
|
|
22490
22962
|
import { access } from "fs/promises";
|
|
22491
22963
|
import path9 from "path";
|
|
22492
|
-
var
|
|
22964
|
+
var defaultFileSystem10 = {
|
|
22493
22965
|
access
|
|
22494
22966
|
};
|
|
22495
22967
|
var logoBasePaths = [
|
|
@@ -22513,7 +22985,7 @@ function logoNotFoundResult(searched) {
|
|
|
22513
22985
|
searched
|
|
22514
22986
|
});
|
|
22515
22987
|
}
|
|
22516
|
-
function createAutocodeLogoFindTool(fileSystem =
|
|
22988
|
+
function createAutocodeLogoFindTool(fileSystem = defaultFileSystem10) {
|
|
22517
22989
|
return tool({
|
|
22518
22990
|
description: "Find project logo path.",
|
|
22519
22991
|
args: {},
|
|
@@ -22542,10 +23014,10 @@ function createAutocodeLogoFindTool(fileSystem = defaultFileSystem8) {
|
|
|
22542
23014
|
}
|
|
22543
23015
|
|
|
22544
23016
|
// src/tools/autocode_plan_read.ts
|
|
22545
|
-
import { readFile as
|
|
23017
|
+
import { readFile as readFile12, readdir as readdir12 } from "fs/promises";
|
|
22546
23018
|
|
|
22547
23019
|
// src/tools/autocode_plan_save.ts
|
|
22548
|
-
import { mkdir as
|
|
23020
|
+
import { mkdir as mkdir11, readFile as readFile11, readdir as readdir11, rm as rm8, stat as stat8, writeFile as writeFile11 } from "fs/promises";
|
|
22549
23021
|
import path10 from "path";
|
|
22550
23022
|
var planSections = ["problems", "requirements", "constraints", "risks", "proposal"];
|
|
22551
23023
|
var planSectionContentDescriptions = {
|
|
@@ -22595,16 +23067,16 @@ Propose ideal solution to solve \`problem\`:
|
|
|
22595
23067
|
- Never repeat any info already provided in other plan sections/parameters
|
|
22596
23068
|
`
|
|
22597
23069
|
};
|
|
22598
|
-
async function
|
|
22599
|
-
return
|
|
23070
|
+
async function readDirectory9(dirPath, options) {
|
|
23071
|
+
return readdir11(dirPath, options);
|
|
22600
23072
|
}
|
|
22601
|
-
var
|
|
22602
|
-
mkdir:
|
|
22603
|
-
readFile:
|
|
22604
|
-
rm:
|
|
22605
|
-
readdir:
|
|
22606
|
-
stat:
|
|
22607
|
-
writeFile:
|
|
23073
|
+
var defaultFileSystem11 = {
|
|
23074
|
+
mkdir: mkdir11,
|
|
23075
|
+
readFile: readFile11,
|
|
23076
|
+
rm: rm8,
|
|
23077
|
+
readdir: readDirectory9,
|
|
23078
|
+
stat: stat8,
|
|
23079
|
+
writeFile: writeFile11
|
|
22608
23080
|
};
|
|
22609
23081
|
function isPlanJobDirectory(directory) {
|
|
22610
23082
|
return directory === completedJobLifecycleDirectory || activeJobLifecycleDirectories.includes(directory);
|
|
@@ -22796,7 +23268,7 @@ function normalizePlanToolArgs(clientOrFileSystem, maybeFileSystem) {
|
|
|
22796
23268
|
if (candidate && "readFile" in candidate && "writeFile" in candidate) {
|
|
22797
23269
|
return { fileSystem: candidate };
|
|
22798
23270
|
}
|
|
22799
|
-
return { client: candidate, fileSystem:
|
|
23271
|
+
return { client: candidate, fileSystem: defaultFileSystem11 };
|
|
22800
23272
|
}
|
|
22801
23273
|
function createAutocodePlanSaveTool(clientOrFileSystem, maybeFileSystem) {
|
|
22802
23274
|
const { client, fileSystem } = normalizePlanToolArgs(clientOrFileSystem, maybeFileSystem);
|
|
@@ -22842,17 +23314,17 @@ function createAutocodePlanSaveTool(clientOrFileSystem, maybeFileSystem) {
|
|
|
22842
23314
|
}
|
|
22843
23315
|
|
|
22844
23316
|
// src/tools/autocode_plan_read.ts
|
|
22845
|
-
async function
|
|
22846
|
-
return
|
|
23317
|
+
async function readDirectory10(dirPath, options) {
|
|
23318
|
+
return readdir12(dirPath, options);
|
|
22847
23319
|
}
|
|
22848
|
-
var
|
|
22849
|
-
readFile:
|
|
22850
|
-
readdir:
|
|
23320
|
+
var defaultFileSystem12 = {
|
|
23321
|
+
readFile: readFile12,
|
|
23322
|
+
readdir: readDirectory10
|
|
22851
23323
|
};
|
|
22852
23324
|
function createPlanResolverFileSystem(fileSystem) {
|
|
22853
23325
|
return {
|
|
22854
23326
|
readFile: fileSystem.readFile,
|
|
22855
|
-
readdir: fileSystem.readdir ??
|
|
23327
|
+
readdir: fileSystem.readdir ?? readDirectory10
|
|
22856
23328
|
};
|
|
22857
23329
|
}
|
|
22858
23330
|
function normalizePlanReadToolArgs(clientOrFileSystem, maybeFileSystem) {
|
|
@@ -22863,7 +23335,7 @@ function normalizePlanReadToolArgs(clientOrFileSystem, maybeFileSystem) {
|
|
|
22863
23335
|
if (candidate && "readFile" in candidate) {
|
|
22864
23336
|
return { fileSystem: candidate };
|
|
22865
23337
|
}
|
|
22866
|
-
return { client: candidate, fileSystem:
|
|
23338
|
+
return { client: candidate, fileSystem: defaultFileSystem12 };
|
|
22867
23339
|
}
|
|
22868
23340
|
function createAutocodePlanReadTool(clientOrFileSystem, maybeFileSystem) {
|
|
22869
23341
|
const { client, fileSystem } = normalizePlanReadToolArgs(clientOrFileSystem, maybeFileSystem);
|
|
@@ -23431,7 +23903,7 @@ function createAutocodeSandboxDeleteTool(client, deps = defaultSandboxDependenci
|
|
|
23431
23903
|
}
|
|
23432
23904
|
|
|
23433
23905
|
// src/tools/autocode_sandbox_file_tools.ts
|
|
23434
|
-
import { lstat as lstat3, mkdir as
|
|
23906
|
+
import { lstat as lstat3, mkdir as mkdir12, readFile as readFileBuffer, readdir as readdir13, realpath as realpath2, rm as rm9, stat as stat9 } from "fs/promises";
|
|
23435
23907
|
import path14 from "path";
|
|
23436
23908
|
|
|
23437
23909
|
// src/utils/sandbox_file_tools.ts
|
|
@@ -29614,7 +30086,7 @@ function normalizePattern(input) {
|
|
|
29614
30086
|
}
|
|
29615
30087
|
async function createEntry(root, absolutePath) {
|
|
29616
30088
|
const direntStat = await lstat3(absolutePath);
|
|
29617
|
-
const fileStat = direntStat.isSymbolicLink() ? direntStat : await
|
|
30089
|
+
const fileStat = direntStat.isSymbolicLink() ? direntStat : await stat9(absolutePath).catch(() => direntStat);
|
|
29618
30090
|
const type = direntStat.isSymbolicLink() ? "symlink" : fileStat.isDirectory() ? "directory" : "file";
|
|
29619
30091
|
return {
|
|
29620
30092
|
path: sandboxRelativePath(root, absolutePath),
|
|
@@ -29632,7 +30104,7 @@ async function isSafeDiscoveredPath(root, absolutePath) {
|
|
|
29632
30104
|
return relative2 === "" || !relative2.startsWith("..") && !path14.isAbsolute(relative2);
|
|
29633
30105
|
}
|
|
29634
30106
|
async function walk(start, visitor) {
|
|
29635
|
-
const entries = await
|
|
30107
|
+
const entries = await readdir13(start, { withFileTypes: true }).catch(() => []);
|
|
29636
30108
|
const sorted = entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
29637
30109
|
for (const entry of sorted) {
|
|
29638
30110
|
const absolutePath = path14.join(start, entry.name);
|
|
@@ -29699,7 +30171,7 @@ function createAutocodeSandboxEditTool(client, deps = defaultSandboxDependencies
|
|
|
29699
30171
|
} else {
|
|
29700
30172
|
content = args2.newString;
|
|
29701
30173
|
}
|
|
29702
|
-
await
|
|
30174
|
+
await mkdir12(path14.dirname(target.value.absolutePath), { recursive: true });
|
|
29703
30175
|
await deps.fileSystem.writeFile(target.value.absolutePath, content);
|
|
29704
30176
|
return JSON.stringify({ operation: "write", target: target.value.relativePath, path: target.value.relativePath, resource: `sandbox:${sandbox3.paths.sandboxName}/${target.value.relativePath}`, existed, replacements });
|
|
29705
30177
|
} catch (error45) {
|
|
@@ -29775,7 +30247,7 @@ function createAutocodeSandboxGrepTool(client, deps = defaultSandboxDependencies
|
|
|
29775
30247
|
await walk(base.value.absolutePath, async (absolutePath) => {
|
|
29776
30248
|
if (!await isSafeDiscoveredPath(sandbox3.metadata.root_path, absolutePath))
|
|
29777
30249
|
return true;
|
|
29778
|
-
const fileStat = await
|
|
30250
|
+
const fileStat = await stat9(absolutePath).catch(() => {
|
|
29779
30251
|
return;
|
|
29780
30252
|
});
|
|
29781
30253
|
if (!fileStat?.isFile())
|
|
@@ -29844,9 +30316,9 @@ function createAutocodeSandboxReadTool(client, deps = defaultSandboxDependencies
|
|
|
29844
30316
|
const target = await resolveSafeRelativePath(sandbox3.metadata.root_path, args2.path, "path", true, true);
|
|
29845
30317
|
if (!target.ok)
|
|
29846
30318
|
return createRetryResponse("read sandbox path", target.reason, "Use a sandbox-root-relative path.");
|
|
29847
|
-
const fileStat = await
|
|
30319
|
+
const fileStat = await stat9(target.value.absolutePath);
|
|
29848
30320
|
if (fileStat.isDirectory()) {
|
|
29849
|
-
const entries = await
|
|
30321
|
+
const entries = await readdir13(target.value.absolutePath);
|
|
29850
30322
|
const listed = await Promise.all(entries.sort((left, right) => left.localeCompare(right)).slice(0, normalizeLimit(args2.limit, defaultLimit, maximumLimit)).map((entry) => createEntry(sandbox3.metadata.root_path, path14.join(target.value.absolutePath, entry))));
|
|
29851
30323
|
return JSON.stringify({ path: target.value.relativePath, type: "directory", entries: listed });
|
|
29852
30324
|
}
|
|
@@ -29900,17 +30372,17 @@ function createAutocodeSandboxCopyTool(client, deps = defaultSandboxDependencies
|
|
|
29900
30372
|
const target = await validateSafeWriteTarget(targetRoot, args2.local_target ?? args2.sandbox_target, "target", args2.sandbox_target !== undefined);
|
|
29901
30373
|
if (!target.ok)
|
|
29902
30374
|
return createRetryResponse("copy sandbox path", target.reason, "Use a safe target path inside project root or sandbox storage.");
|
|
29903
|
-
const sourceStat = await
|
|
29904
|
-
const targetStat = await
|
|
30375
|
+
const sourceStat = await stat9(source.value.absolutePath);
|
|
30376
|
+
const targetStat = await stat9(target.value.absolutePath).catch(() => {
|
|
29905
30377
|
return;
|
|
29906
30378
|
});
|
|
29907
30379
|
if (sourceStat.isDirectory() && targetStat?.isFile())
|
|
29908
30380
|
return createRetryResponse("copy sandbox path", "Cannot copy directory onto existing file.", "Choose a directory target or remove the file first.");
|
|
29909
30381
|
if (sourceStat.isFile() && targetStat?.isDirectory())
|
|
29910
30382
|
return createRetryResponse("copy sandbox path", "Cannot copy file onto existing directory.", "Choose a file target or remove the directory first.");
|
|
29911
|
-
await
|
|
30383
|
+
await mkdir12(path14.dirname(target.value.absolutePath), { recursive: true });
|
|
29912
30384
|
if (sourceStat.isFile() && targetStat?.isFile())
|
|
29913
|
-
await
|
|
30385
|
+
await rm9(target.value.absolutePath, { force: true });
|
|
29914
30386
|
await copyPath(source.value.absolutePath, target.value.absolutePath);
|
|
29915
30387
|
return JSON.stringify({ operation: "copy", source: source.value.relativePath, target: target.value.relativePath, resource: args2.sandbox_target !== undefined ? `sandbox:${sandbox3.paths.sandboxName}/${target.value.relativePath}` : `local:${target.value.relativePath}` });
|
|
29916
30388
|
} catch (error45) {
|
|
@@ -29956,122 +30428,6 @@ function createAutocodeSessionCreateTool(client) {
|
|
|
29956
30428
|
});
|
|
29957
30429
|
}
|
|
29958
30430
|
|
|
29959
|
-
// src/tools/autocode_shelve.ts
|
|
29960
|
-
import { mkdir as mkdir11, readFile as readFile11, readdir as readdir12, rename as rename6, rm as rm8, stat as stat8, writeFile as writeFile10 } from "fs/promises";
|
|
29961
|
-
async function readDirectory9(dirPath, options) {
|
|
29962
|
-
return options?.withFileTypes ? readdir12(dirPath, { withFileTypes: true }) : readdir12(dirPath);
|
|
29963
|
-
}
|
|
29964
|
-
var defaultFileSystem11 = {
|
|
29965
|
-
mkdir: mkdir11,
|
|
29966
|
-
readFile: readFile11,
|
|
29967
|
-
readdir: readDirectory9,
|
|
29968
|
-
rename: rename6,
|
|
29969
|
-
rm: rm8,
|
|
29970
|
-
stat: stat8,
|
|
29971
|
-
writeFile: writeFile10
|
|
29972
|
-
};
|
|
29973
|
-
function normalizeShelveToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNow) {
|
|
29974
|
-
if (typeof fileSystemOrNow === "function") {
|
|
29975
|
-
return { fileSystem: clientOrFileSystem ?? defaultFileSystem11, now: fileSystemOrNow };
|
|
29976
|
-
}
|
|
29977
|
-
if (fileSystemOrNow) {
|
|
29978
|
-
return { client: clientOrFileSystem, fileSystem: fileSystemOrNow, now: maybeNow ?? (() => new Date) };
|
|
29979
|
-
}
|
|
29980
|
-
const candidate = clientOrFileSystem;
|
|
29981
|
-
if (candidate && "readFile" in candidate && "writeFile" in candidate) {
|
|
29982
|
-
return { fileSystem: candidate, now: () => new Date };
|
|
29983
|
-
}
|
|
29984
|
-
return { client: candidate, fileSystem: defaultFileSystem11, now: () => new Date };
|
|
29985
|
-
}
|
|
29986
|
-
function createMissingIdentityRetryResponse2() {
|
|
29987
|
-
return createLifecycleJobRequiredRetryResponse("shelve job");
|
|
29988
|
-
}
|
|
29989
|
-
function createMissingJobRetryResponse2(jobName) {
|
|
29990
|
-
return createLifecycleJobRequiredRetryResponse("shelve job", `job ${jobName}`);
|
|
29991
|
-
}
|
|
29992
|
-
function getIdentityRetryResponse2(identity3) {
|
|
29993
|
-
if (identity3.job_name) {
|
|
29994
|
-
if (identity3.resolution === "collision") {
|
|
29995
|
-
return createRetryResponse("shelve job", `Planned job lifecycle collision: ${identity3.job_name}`, "Resolve duplicate active lifecycle directories for this job before shelving.");
|
|
29996
|
-
}
|
|
29997
|
-
if (identity3.resolution === "missing") {
|
|
29998
|
-
return createMissingJobRetryResponse2(identity3.job_name);
|
|
29999
|
-
}
|
|
30000
|
-
}
|
|
30001
|
-
return createMissingIdentityRetryResponse2();
|
|
30002
|
-
}
|
|
30003
|
-
function createAutocodeShelveTool(clientOrFileSystem, fileSystemOrNow, maybeNow) {
|
|
30004
|
-
const { client, fileSystem, now } = normalizeShelveToolArgs(clientOrFileSystem, fileSystemOrNow, maybeNow);
|
|
30005
|
-
return tool({
|
|
30006
|
-
description: "Shelve current lifecycle job into .agents/jobs/shelved/{name}/.",
|
|
30007
|
-
args: {},
|
|
30008
|
-
async execute(_args, context3) {
|
|
30009
|
-
if (!client) {
|
|
30010
|
-
return createMissingIdentityRetryResponse2();
|
|
30011
|
-
}
|
|
30012
|
-
try {
|
|
30013
|
-
const storageRoot = resolveAgentsStorageRoot(context3);
|
|
30014
|
-
const directoryFileSystem = createDirectoryFileSystem(fileSystem);
|
|
30015
|
-
const identity3 = await resolvePlannedJobIdentity(directoryFileSystem, client, context3, { includeShelved: true });
|
|
30016
|
-
if (identity3.mode !== "planned" || !identity3.job_name) {
|
|
30017
|
-
return getIdentityRetryResponse2(identity3);
|
|
30018
|
-
}
|
|
30019
|
-
const jobName = identity3.job_name;
|
|
30020
|
-
const resolvedJob = identity3.resolved_job;
|
|
30021
|
-
if (!resolvedJob) {
|
|
30022
|
-
return createAbortResponse("shelve job", "Resolved planned-job identity is missing lifecycle details.");
|
|
30023
|
-
}
|
|
30024
|
-
if (!directoryFileSystem.rename) {
|
|
30025
|
-
return createAbortResponse("shelve job", "Unable to move planned job lifecycle directory: rename is unavailable");
|
|
30026
|
-
}
|
|
30027
|
-
const reportContentResult = await readLatestAssistantResponseText(client, context3);
|
|
30028
|
-
if (reportContentResult.error) {
|
|
30029
|
-
return createAbortResponse("inspect current session messages", reportContentResult.error);
|
|
30030
|
-
}
|
|
30031
|
-
if (reportContentResult.limitation) {
|
|
30032
|
-
return createAbortResponse("inspect current session messages", reportContentResult.limitation);
|
|
30033
|
-
}
|
|
30034
|
-
if (!reportContentResult.text?.trim()) {
|
|
30035
|
-
return createRetryResponse("shelve job", "No assistant response text was found in the current session.", "First present the user-facing lifecycle update in assistant text with concrete actions and a separate reason/evidence summary, then call autocode_shelve again.");
|
|
30036
|
-
}
|
|
30037
|
-
const shelved = await shelveResolvedPlannedJob({
|
|
30038
|
-
storageRoot,
|
|
30039
|
-
client,
|
|
30040
|
-
context: context3,
|
|
30041
|
-
fileSystem,
|
|
30042
|
-
moveFileSystem: { ...directoryFileSystem, rename: directoryFileSystem.rename },
|
|
30043
|
-
now,
|
|
30044
|
-
resolvedJob,
|
|
30045
|
-
assistantResponseText: reportContentResult.text
|
|
30046
|
-
});
|
|
30047
|
-
if (shelved.type === "missing") {
|
|
30048
|
-
return createMissingJobRetryResponse2(jobName);
|
|
30049
|
-
}
|
|
30050
|
-
if (shelved.type === "collision") {
|
|
30051
|
-
return createRetryResponse("shelve job", `Planned job lifecycle collision: ${jobName}`, "Resolve duplicate active lifecycle directories for this job before shelving.");
|
|
30052
|
-
}
|
|
30053
|
-
if (shelved.type === "destination_collision") {
|
|
30054
|
-
return createRetryResponse("shelve job", `Destination lifecycle directory already exists for ${jobName}`, "Resolve the existing lifecycle directory collision before shelving.");
|
|
30055
|
-
}
|
|
30056
|
-
if (!shelved.sandbox_archive.ok) {
|
|
30057
|
-
return createRetryResponse("archive job sandboxes", shelved.sandbox_archive.reason, "Resolve the sandbox archive collision or unsafe path before retrying. Do not overwrite existing sandbox archives.");
|
|
30058
|
-
}
|
|
30059
|
-
return JSON.stringify({
|
|
30060
|
-
job_name: shelved.moved.job.job_name,
|
|
30061
|
-
current_status: "shelved",
|
|
30062
|
-
job_path: shelved.moved.job.job_path,
|
|
30063
|
-
solution_path: shelved.solution.relativeSolutionPath,
|
|
30064
|
-
sandbox_archive: shelved.sandbox_archive,
|
|
30065
|
-
title_warning: shelved.title.warning,
|
|
30066
|
-
next_action: "Shelve complete; the job has no active lifecycle directory."
|
|
30067
|
-
});
|
|
30068
|
-
} catch (error45) {
|
|
30069
|
-
return createAbortResponse("shelve job", error45);
|
|
30070
|
-
}
|
|
30071
|
-
}
|
|
30072
|
-
});
|
|
30073
|
-
}
|
|
30074
|
-
|
|
30075
30431
|
// src/tools/task_external.ts
|
|
30076
30432
|
import { spawn as nodeSpawn2 } from "child_process";
|
|
30077
30433
|
import { realpath as nodeRealpath, stat as nodeStat } from "fs/promises";
|
|
@@ -30620,6 +30976,8 @@ function createTaskResumeTool(client) {
|
|
|
30620
30976
|
// src/tools/index.ts
|
|
30621
30977
|
function createTools(client, sandboxConfig = {}) {
|
|
30622
30978
|
return {
|
|
30979
|
+
autocode_agent_execute: createAutocodeAgentExecuteTool(client),
|
|
30980
|
+
autocode_agent_previous: createAutocodeAgentPreviousTool(client),
|
|
30623
30981
|
autocode_agent_swap: createAutocodeAgentSwapTool(client),
|
|
30624
30982
|
autocode_concept_create: createAutocodeConceptCreateTool(client),
|
|
30625
30983
|
autocode_concept_list: createAutocodeConceptListTool(),
|
|
@@ -30635,8 +30993,8 @@ function createTools(client, sandboxConfig = {}) {
|
|
|
30635
30993
|
autocode_dependencies: createAutocodeDependenciesTool(),
|
|
30636
30994
|
autocode_job_list: createAutocodeJobListTool(),
|
|
30637
30995
|
autocode_job_execute: createAutocodeJobExecuteTool(client),
|
|
30996
|
+
autocode_job_shelve: createAutocodeJobShelveTool(client),
|
|
30638
30997
|
autocode_job_status: createAutocodeJobStatusTool(client),
|
|
30639
|
-
autocode_shelve: createAutocodeShelveTool(client),
|
|
30640
30998
|
autocode_logo_find: createAutocodeLogoFindTool(),
|
|
30641
30999
|
autocode_plan_read: createAutocodePlanReadTool(client),
|
|
30642
31000
|
autocode_plan_save: createAutocodePlanSaveTool(client),
|