@whoz-oss/coday-server 0.53.1 → 0.54.0
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/package.json +1 -1
- package/server.js +168 -1
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -793,7 +793,174 @@ You deemed the task completed by not delegating another task, so:
|
|
|
793
793
|
It should not be generic knowledge and neither a perfect copy on a file, but rather from a paragraph up to a 3 pages document.
|
|
794
794
|
If unsure or lacking clarity, use the available tools to test or request guidance.
|
|
795
795
|
Format it in markdown.
|
|
796
|
-
Then memorize it, each subject at a time.`]}
|
|
796
|
+
Then memorize it, each subject at a time.`]},{name:"plan",description:"Create a detailed execution plan before starting complex tasks. Research context, ask clarifying questions, and generate structured plan.",commands:[`@ Create a comprehensive execution plan for the following task:
|
|
797
|
+
|
|
798
|
+
PROMPT
|
|
799
|
+
|
|
800
|
+
## Phase 1: Research & Understanding
|
|
801
|
+
|
|
802
|
+
1. **Analyze the request** to identify:
|
|
803
|
+
- Core requirements and objectives
|
|
804
|
+
- Implicit assumptions or expectations
|
|
805
|
+
- Technical scope and constraints
|
|
806
|
+
|
|
807
|
+
2. **Research relevant context** using available tools:
|
|
808
|
+
- Use whatever tools you have available (file reading, API calls, search, etc.)
|
|
809
|
+
- Gather information about existing patterns, structures, and conventions
|
|
810
|
+
- Identify relevant files, modules, or resources
|
|
811
|
+
- Document key findings briefly
|
|
812
|
+
|
|
813
|
+
3. **Assess feasibility**:
|
|
814
|
+
- Identify potential challenges or blockers
|
|
815
|
+
- Note any dependencies or prerequisites
|
|
816
|
+
- Consider alternative approaches if applicable
|
|
817
|
+
|
|
818
|
+
Do not assume you have specific tools - use what's available to you.`,`@ Continue with Phase 2: Clarifying Questions
|
|
819
|
+
|
|
820
|
+
Based on your research and understanding:
|
|
821
|
+
|
|
822
|
+
1. **Identify ambiguities** or missing information that could impact the plan
|
|
823
|
+
|
|
824
|
+
2. **Ask focused questions** if clarification is needed:
|
|
825
|
+
- Use the 'invite' or 'choice' tools for user input
|
|
826
|
+
- Keep questions concise and specific
|
|
827
|
+
- Prioritize questions that significantly impact the approach
|
|
828
|
+
|
|
829
|
+
3. **Skip this phase** if the requirements are clear enough to proceed
|
|
830
|
+
|
|
831
|
+
Remember: Only ask questions that are truly necessary for creating a solid plan.`,`@ Complete Phase 3: Plan Creation
|
|
832
|
+
|
|
833
|
+
Now create a detailed execution plan and save it to exchange://execution-plan.md
|
|
834
|
+
|
|
835
|
+
The plan must follow this Markdown structure:
|
|
836
|
+
|
|
837
|
+
# Execution Plan: [Task Title]
|
|
838
|
+
|
|
839
|
+
## Overview
|
|
840
|
+
1-2 sentence summary of what will be accomplished.
|
|
841
|
+
|
|
842
|
+
## Context
|
|
843
|
+
Key information and constraints identified during research:
|
|
844
|
+
- Relevant patterns/conventions found
|
|
845
|
+
- Technical constraints
|
|
846
|
+
- Dependencies or prerequisites
|
|
847
|
+
- Key files/resources involved
|
|
848
|
+
|
|
849
|
+
## Steps
|
|
850
|
+
|
|
851
|
+
### Step 1: [Step Title]
|
|
852
|
+
- **Resources to modify**: List files, APIs, or resources
|
|
853
|
+
- **Changes**: Specific modifications to make
|
|
854
|
+
- **Validation**: How to verify this step (compile, test, manual check)
|
|
855
|
+
- **Dependencies**: Which previous steps must complete first (or "None")
|
|
856
|
+
|
|
857
|
+
### Step 2: [Step Title]
|
|
858
|
+
[Same structure as Step 1]
|
|
859
|
+
|
|
860
|
+
[Continue for all steps...]
|
|
861
|
+
|
|
862
|
+
## Verification
|
|
863
|
+
How to test the complete implementation:
|
|
864
|
+
1. Compilation checks
|
|
865
|
+
2. Automated tests
|
|
866
|
+
3. Manual verification steps
|
|
867
|
+
|
|
868
|
+
## Risks & Considerations
|
|
869
|
+
- Potential issues or edge cases
|
|
870
|
+
- Alternative approaches considered
|
|
871
|
+
- Technical debt or future improvements
|
|
872
|
+
|
|
873
|
+
---
|
|
874
|
+
|
|
875
|
+
After saving the plan:
|
|
876
|
+
1. Inform the user that the plan is ready
|
|
877
|
+
2. Mention it can be reviewed with: load exchange://execution-plan.md
|
|
878
|
+
3. Mention it can be edited manually or via agent assistance
|
|
879
|
+
4. Mention it can be executed with: execute-plan`]},{name:"execute-plan",description:"Execute a previously created plan step by step, with validation and progress tracking.",commands:[`@ Execute the plan from exchange://execution-plan.md
|
|
880
|
+
|
|
881
|
+
## Important Notes
|
|
882
|
+
- The plan file may have been edited by the user since creation
|
|
883
|
+
- Always read the current version from exchange://execution-plan.md
|
|
884
|
+
- Respect the plan structure and order unless issues arise
|
|
885
|
+
|
|
886
|
+
## Execution Protocol
|
|
887
|
+
|
|
888
|
+
### 1. Load and Parse the Plan
|
|
889
|
+
- Read the plan from exchange://execution-plan.md
|
|
890
|
+
- Parse the structure to understand:
|
|
891
|
+
- Overall objective
|
|
892
|
+
- Context and constraints
|
|
893
|
+
- Ordered steps with dependencies
|
|
894
|
+
- Validation criteria
|
|
895
|
+
|
|
896
|
+
### 2. Pre-execution Check
|
|
897
|
+
- Review the plan overview and context
|
|
898
|
+
- Verify prerequisites are met
|
|
899
|
+
- Identify any obvious issues with the plan
|
|
900
|
+
- If significant issues found, report them and ask for guidance
|
|
901
|
+
|
|
902
|
+
### 3. Step-by-Step Execution
|
|
903
|
+
For each step in order:
|
|
904
|
+
|
|
905
|
+
a) **Announce the step**:
|
|
906
|
+
- State which step you're starting
|
|
907
|
+
- Briefly explain what will be done
|
|
908
|
+
|
|
909
|
+
b) **Check dependencies**:
|
|
910
|
+
- Verify required previous steps completed successfully
|
|
911
|
+
- If dependencies not met, report and stop
|
|
912
|
+
|
|
913
|
+
c) **Execute the changes**:
|
|
914
|
+
- Make the specified modifications
|
|
915
|
+
- Follow the plan's guidance
|
|
916
|
+
- If plan lacks details, use best judgment based on context
|
|
917
|
+
|
|
918
|
+
d) **Validate the step**:
|
|
919
|
+
- Run specified validation (compile, test, etc.)
|
|
920
|
+
- Verify changes work as expected
|
|
921
|
+
- Report any issues immediately
|
|
922
|
+
|
|
923
|
+
e) **Optional confirmation** (for complex/risky steps):
|
|
924
|
+
- For steps that modify critical files or have significant impact
|
|
925
|
+
- Ask user confirmation before proceeding to next step
|
|
926
|
+
- Use 'choice' tool for quick yes/no
|
|
927
|
+
|
|
928
|
+
f) **Report completion**:
|
|
929
|
+
- Confirm step completed successfully
|
|
930
|
+
- Note any deviations from the plan
|
|
931
|
+
- Proceed to next step
|
|
932
|
+
|
|
933
|
+
### 4. Handle Issues
|
|
934
|
+
If a step fails:
|
|
935
|
+
- Report the specific issue clearly
|
|
936
|
+
- Explain what went wrong
|
|
937
|
+
- Suggest potential solutions:
|
|
938
|
+
- Retry with adjustments
|
|
939
|
+
- Skip and continue (if non-critical)
|
|
940
|
+
- Stop and ask for guidance
|
|
941
|
+
- Use 'choice' tool to ask user how to proceed
|
|
942
|
+
|
|
943
|
+
### 5. Final Verification
|
|
944
|
+
After all steps complete:
|
|
945
|
+
- Run final validation checks from the plan
|
|
946
|
+
- Test the complete implementation
|
|
947
|
+
- Verify all objectives met
|
|
948
|
+
|
|
949
|
+
### 6. Summary Report
|
|
950
|
+
Provide a comprehensive summary:
|
|
951
|
+
- What was accomplished
|
|
952
|
+
- List of changes made (files modified, features added, etc.)
|
|
953
|
+
- Any deviations from the original plan and why
|
|
954
|
+
- Validation results (tests passed, compilation successful, etc.)
|
|
955
|
+
- Known issues or limitations
|
|
956
|
+
- Suggested next steps or follow-ups
|
|
957
|
+
|
|
958
|
+
## Execution Guidelines
|
|
959
|
+
- Be methodical and thorough
|
|
960
|
+
- Validate frequently to catch issues early
|
|
961
|
+
- Communicate progress clearly
|
|
962
|
+
- Don't hesitate to ask for guidance if plan is unclear
|
|
963
|
+
- Respect the plan but adapt if circumstances require it`]}];var ax=class extends De{constructor(t){super({commandWord:"file",description:"Loads a file by its path relative to project root, ex: `load-file ./folder/file.extension`"});this.interactor=t}async handle(t,n){let a=this.getSubCommand(t).trim();if(!a)return this.interactor.error("Please provide a valid file path."),n;a.startsWith(".")||(a=`.${a}`);let s=await Cie({relPath:a,root:n.project.root,interactor:this.interactor});return n.aiThread?.addUserMessage(n.username,{type:"text",content:`File with path: ${a}
|
|
797
964
|
|
|
798
965
|
${s}`}),n}};import*as y4 from"fs";import*as jo from"path";var UJe=(r,e)=>{let t=jo.resolve(e),n=jo.resolve(t,r),i=jo.normalize(t),a=jo.normalize(n);if(!a.startsWith(i+jo.sep)&&a!==i)throw new Error(`Attempt to navigate outside the root folder: ${r} is not allowed`);return n},HJe=async r=>{try{if(!(await y4.promises.stat(r)).isDirectory())throw new Error(`Symbolic link target is not a directory: ${r}`)}catch(e){throw e.code==="ENOENT"?new Error(`Symbolic link target does not exist: ${r}`):e}},WJe=async r=>{let e;try{e=await y4.promises.lstat(r)}catch(t){throw t.code==="ENOENT"?new Error(`Directory does not exist: ${r}`):new Error(`Cannot access path ${r}: ${t.message}`)}if(e.isSymbolicLink())await HJe(r);else if(!e.isDirectory())throw new Error(`Path is not a directory: ${r}`)},GJe=async(r,e)=>{try{return(await y4.promises.lstat(r)).isDirectory()?`${e}/`:e}catch{return`${e} (inaccessible)`}},sx=async({relPath:r,root:e})=>{let t=UJe(r,e);await WJe(t);let n=await y4.promises.readdir(t);return await Promise.all(n.map(a=>{let s=jo.join(t,a);return GJe(s,a)}))};var ox=class extends De{constructor(t){super({commandWord:"folder",description:"Loads files from a folder, does not do depth nor recursive."});this.interactor=t}async handle(t,n){let i=this.getSubCommand(t);if(!i)return this.interactor.error("Please provide a valid folder path."),n;i.startsWith(".")||(i=`.${i}`);let a;try{a=await sx({relPath:i,root:n.project.root});let s=a.filter(o=>!o.endsWith("/")).map(o=>`load file ${i}/${o}`);n.addCommands(...s),this.interactor.displayText(`Folder loaded: ${i}`)}catch(s){this.interactor.error(`Failed to load folder: ${s}`)}return n}};var cx=class extends Sn{constructor(e){super({commandWord:"load",description:"handles load related commands"},e),this.handlers=[new ax(e),new ox(e)]}};var lx=class extends De{constructor(t,n){super({commandWord:"agents",description:"Show agent usage statistics sorted by number of calls. Use --from=YYYY-MM-DD and --to=YYYY-MM-DD for custom date range (default: last 7 days)"});this.interactor=t;this.services=n}async handle(t,n){try{let i=this.getSubCommand(t),a=at(i,[{key:"from",alias:"f"},{key:"to",alias:"t"}]),s,o;if(a.to&&typeof a.to=="string"){let d=this.parseDate(a.to);if(!d)return this.interactor.error("Invalid --to date format. Please use YYYY-MM-DD"),n;s=d,s.setHours(23,59,59,999)}else s=new Date,s.setHours(23,59,59,999);if(a.from&&typeof a.from=="string"){let d=this.parseDate(a.from);if(!d)return this.interactor.error("Invalid --from date format. Please use YYYY-MM-DD"),n;o=d,o.setHours(0,0,0,0)}else o=new Date(s),o.setDate(o.getDate()-7),o.setHours(0,0,0,0);if(o>s)return this.interactor.error("Invalid date range: --from date must be before --to date"),n;let c=(await this.services.logger.readLogs(o,s)).filter(d=>!d.type||d.type==="AGENT_USAGE");if(c.length===0){let d=this.formatDateRange(o,s);return this.interactor.displayText(`\u{1F4CA} No usage data found for ${d}`),n}let l=new Map;for(let d of c){let p=l.get(d.agent)||{calls:0,totalCost:0};l.set(d.agent,{calls:p.calls+1,totalCost:p.totalCost+d.cost})}let u=Array.from(l.entries()).map(([d,p])=>({agent:d,calls:p.calls,totalCost:p.totalCost,avgCost:p.totalCost/p.calls}));u.sort((d,p)=>p.calls-d.calls);let f=this.formatAgentStats(u,o,s);this.interactor.displayText(f)}catch(i){this.interactor.error(`Failed to retrieve agent statistics: ${i}`)}return n}parseDate(t){if(!t.match(/^(\d{4})-(\d{2})-(\d{2})$/))return null;let i=new Date(t);return isNaN(i.getTime())?null:i}formatDateRange(t,n){let i=t.toISOString().split("T")[0],a=n.toISOString().split("T")[0];return`${i} to ${a}`}formatAgentStats(t,n,i){let s=`\u{1F4CA} Agent Usage Statistics (${this.formatDateRange(n,i)})
|
|
799
966
|
=====================================
|