@iaforged/context-code 1.2.9 → 1.2.10
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 +119 -119
- package/context-bootstrap.js +26 -26
- package/dist/src/QueryEngine.js +394 -327
- package/dist/src/bridge/bridgeUI.js +1 -1
- package/dist/src/buddy/prompt.js +4 -4
- package/dist/src/cli/handlers/auth.js +126 -9
- package/dist/src/cli/print.js +35 -1
- package/dist/src/commands/agent/agent.js +28 -2
- package/dist/src/commands/agent/agentStore.js +8 -1
- package/dist/src/commands/agent/index.js +1 -1
- package/dist/src/commands/bridge-kick.js +9 -9
- package/dist/src/commands/commit.js +34 -34
- package/dist/src/commands/init-verifiers.js +3 -3
- package/dist/src/commands/init.js +88 -88
- package/dist/src/commands/insights.js +787 -787
- package/dist/src/commands/install.js +19 -19
- package/dist/src/commands/login/login.js +21 -12
- package/dist/src/commands/logout/logout.js +9 -0
- package/dist/src/commands/model/model.js +9 -4
- package/dist/src/commands/orchestrate/SwarmUI.js +50 -0
- package/dist/src/commands/orchestrate/index.js +2 -2
- package/dist/src/commands/orchestrate/orchestrate.js +708 -12
- package/dist/src/commands/pr_comments/index.js +33 -33
- package/dist/src/commands/profile/index.js +1 -1
- package/dist/src/commands/profile/profile.js +52 -3
- package/dist/src/commands/provider/index.js +1 -1
- package/dist/src/commands/provider/provider.js +117 -45
- package/dist/src/commands/resumen/index.js +9 -0
- package/dist/src/commands/resumen/resumen.js +29 -0
- package/dist/src/commands/security-review.js +190 -190
- package/dist/src/commands/swarm-auto/index.js +9 -0
- package/dist/src/commands/swarm-auto/swarmAuto.js +111 -0
- package/dist/src/commands/swarm-init/index.js +9 -0
- package/dist/src/commands/swarm-init/swarmInit.js +72 -0
- package/dist/src/commands/team/team.js +39 -6
- package/dist/src/commands.js +14 -0
- package/dist/src/components/LogoV2/CondensedLogo.js +2 -2
- package/dist/src/components/PromptInput/PromptInputQueuedCommands.js +3 -3
- package/dist/src/components/agents/agentFileUtils.js +6 -6
- package/dist/src/components/permissions/hooks.js +5 -5
- package/dist/src/constants/outputStyles.js +83 -83
- package/dist/src/core/agents/blueprints.js +58 -0
- package/dist/src/core/agents/cliAdapter.js +61 -0
- package/dist/src/core/agents/registry.js +93 -0
- package/dist/src/core/agents/runtime.js +4 -0
- package/dist/src/core/agents/runtime.smoke.js +42 -0
- package/dist/src/core/agents/swarm.smoke.js +48 -0
- package/dist/src/core/agents/swarmTools.js +38 -0
- package/dist/src/core/auth/index.js +2 -0
- package/dist/src/core/auth/loginCliAdapter.js +24 -0
- package/dist/src/core/auth/loginCore.js +67 -0
- package/dist/src/core/auth/logoutCliAdapter.js +34 -0
- package/dist/src/core/auth/logoutCore.js +52 -0
- package/dist/src/core/auth/preflight.smoke.js +151 -0
- package/dist/src/core/index.js +21 -0
- package/dist/src/core/mcp/blueprints.js +27 -0
- package/dist/src/core/mcp/common.js +14 -0
- package/dist/src/core/mcp/runtime.js +67 -0
- package/dist/src/core/mcp/runtime.smoke.js +50 -0
- package/dist/src/core/mcp/swarmClient.js +40 -0
- package/dist/src/core/mcp/swarmSetup.js +43 -0
- package/dist/src/core/providers/cliAdapter.js +39 -0
- package/dist/src/core/providers/contracts.js +1 -0
- package/dist/src/core/providers/index.js +3 -0
- package/dist/src/core/providers/llmCore.js +123 -0
- package/dist/src/core/providers/providerCore.js +141 -0
- package/dist/src/core/providers/providerModelCompatibility.js +98 -0
- package/dist/src/core/providers/providerParitySmoke.js +83 -0
- package/dist/src/core/providers/providerProfileModelSmoke.js +80 -0
- package/dist/src/core/query/contracts.js +1 -0
- package/dist/src/core/query/runtime.js +117 -0
- package/dist/src/core/query/runtime.smoke.js +39 -0
- package/dist/src/core/query/timelineThinking.smoke.js +25 -0
- package/dist/src/core/query/wiring.smoke.js +76 -0
- package/dist/src/core/skills/cliAdapter.js +38 -0
- package/dist/src/core/skills/index.js +52 -0
- package/dist/src/core/skills/runtime.smoke.js +53 -0
- package/dist/src/core/tasks/runtime.js +205 -0
- package/dist/src/core/tasks/runtime.smoke.js +63 -0
- package/dist/src/core/tasks/sdkAdapter.js +4 -0
- package/dist/src/core/tools/contracts.js +3 -0
- package/dist/src/core/tools/fileResolution.js +112 -0
- package/dist/src/core/tools/fileResolution.smoke.js +33 -0
- package/dist/src/core/tools/filesCore.js +51 -0
- package/dist/src/core/tools/filesCore.smoke.js +108 -0
- package/dist/src/core/tools/gitCore.js +20 -0
- package/dist/src/core/tools/imageParity.smoke.js +36 -0
- package/dist/src/core/tools/notebookParity.smoke.js +68 -0
- package/dist/src/core/tools/registry.js +22 -0
- package/dist/src/core/tools/runtime.smoke.js +32 -0
- package/dist/src/core/tools/shellCore.js +60 -0
- package/dist/src/core/types/agentContext.js +9 -0
- package/dist/src/core/types/auth.js +3 -0
- package/dist/src/core/types/command.js +13 -0
- package/dist/src/core/types/provider.js +3 -0
- package/dist/src/core/types/sdkEvent.js +10 -0
- package/dist/src/core/types/swarm.js +1 -0
- package/dist/src/cost-tracker.js +3 -3
- package/dist/src/hooks/useAwaySummary.js +22 -9
- package/dist/src/main.js +32 -2
- package/dist/src/screens/REPL.js +9 -0
- package/dist/src/services/AgentSummary/agentSummary.js +10 -10
- package/dist/src/services/autoDream/autoDream.js +5 -5
- package/dist/src/services/autoDream/consolidationPrompt.js +49 -49
- package/dist/src/services/compact/prompt.js +238 -238
- package/dist/src/services/limits/sessionCounter.js +17 -17
- package/dist/src/services/mcp/client.js +27 -1
- package/dist/src/services/orchestration/execution/AgentTaskExecutor.js +39 -20
- package/dist/src/services/orchestration/execution/OrchestrationExecutionRuntime.js +65 -58
- package/dist/src/skills/bundled/loop.js +57 -57
- package/dist/src/skills/bundled/remember.js +53 -53
- package/dist/src/skills/bundled/simplify.js +49 -49
- package/dist/src/skills/bundled/skillify.js +2 -2
- package/dist/src/state/onChangeAppState.js +6 -0
- package/dist/src/tasks/LocalAgentTask/LocalAgentTask.js +5 -5
- package/dist/src/tasks/LocalMainSessionTask.js +5 -5
- package/dist/src/tasks/LocalShellTask/LocalShellTask.js +13 -13
- package/dist/src/tools/AgentTool/forkSubagent.js +25 -25
- package/dist/src/tools/AskUserQuestionTool/prompt.js +29 -29
- package/dist/src/tools/BashTool/BashTool.js +27 -2
- package/dist/src/tools/BriefTool/prompt.js +14 -14
- package/dist/src/tools/EnterPlanModeTool/EnterPlanModeTool.js +12 -12
- package/dist/src/tools/EnterPlanModeTool/prompt.js +140 -140
- package/dist/src/tools/ExitPlanModeTool/ExitPlanModeV2Tool.js +18 -18
- package/dist/src/tools/ExitPlanModeTool/prompt.js +23 -23
- package/dist/src/tools/ExitWorktreeTool/prompt.js +29 -29
- package/dist/src/tools/FileEditTool/prompt.js +7 -7
- package/dist/src/tools/FileReadTool/FileReadTool.js +18 -1
- package/dist/src/tools/FileWriteTool/prompt.js +6 -6
- package/dist/src/tools/GlobTool/prompt.js +4 -4
- package/dist/src/tools/GrepTool/prompt.js +10 -10
- package/dist/src/tools/LSPTool/prompt.js +18 -18
- package/dist/src/tools/ListMcpResourcesTool/prompt.js +15 -15
- package/dist/src/tools/PowerShellTool/PowerShellTool.js +25 -2
- package/dist/src/tools/ReadMcpResourceTool/prompt.js +13 -13
- package/dist/src/tools/SendMessageTool/prompt.js +36 -36
- package/dist/src/tools/SkillTool/prompt.js +21 -21
- package/dist/src/tools/SleepTool/prompt.js +10 -10
- package/dist/src/tools/TaskCreateTool/prompt.js +41 -41
- package/dist/src/tools/TaskGetTool/prompt.js +21 -21
- package/dist/src/tools/TaskListTool/prompt.js +30 -30
- package/dist/src/tools/TaskOutputTool/TaskOutputTool.js +8 -8
- package/dist/src/tools/TaskStopTool/prompt.js +5 -5
- package/dist/src/tools/TaskUpdateTool/prompt.js +74 -74
- package/dist/src/tools/TodoWriteTool/prompt.js +178 -178
- package/dist/src/tools/ToolSearchTool/prompt.js +9 -9
- package/dist/src/tools/WebFetchTool/WebFetchTool.js +9 -9
- package/dist/src/tools/WebFetchTool/prompt.js +31 -31
- package/dist/src/tools/WebSearchTool/prompt.js +26 -26
- package/dist/src/utils/agentContext.js +2 -0
- package/dist/src/utils/agenticSessionSearch.js +38 -38
- package/dist/src/utils/config.js +2 -0
- package/dist/src/utils/genericProcessUtils.js +21 -21
- package/dist/src/utils/heapDumpService.js +4 -4
- package/dist/src/utils/mcpValidation.js +2 -2
- package/dist/src/utils/model/modelStrings.js +1 -1
- package/dist/src/utils/model/providers.js +5 -0
- package/dist/src/utils/orchestration/store/providerAgentStore.js +22 -22
- package/dist/src/utils/orchestration/store/providerWorkspaceStore.js +10 -10
- package/dist/src/utils/orchestration/store/runStore.js +68 -68
- package/dist/src/utils/orchestration/store/teamStore.js +28 -28
- package/dist/src/utils/permissions/permissionExplainer.js +6 -6
- package/dist/src/utils/permissions/permissionsDb.js +43 -43
- package/dist/src/utils/sdkEventQueue.js +2 -0
- package/dist/src/utils/secureStorage/sqliteStorage.js +12 -12
- package/dist/src/utils/standardMcp/common.js +15 -0
- package/dist/src/utils/standardMcp/setup.js +52 -0
- package/dist/src/utils/swarm/teammatePromptAddendum.js +10 -10
- package/dist/src/utils/task/framework.js +6 -6
- package/package.json +1 -1
- package/dist/src/commands/usage/index.js +0 -7
- package/dist/src/commands/usage/usage.js +0 -5
|
@@ -14,249 +14,249 @@ const proactiveModule = feature('PROACTIVE') || feature('KAIROS')
|
|
|
14
14
|
// no text output → falls through to the streaming fallback (2.79% on 4.6 vs
|
|
15
15
|
// 0.01% on 4.5). Putting this FIRST and making it explicit about rejection
|
|
16
16
|
// consequences prevents the wasted turn.
|
|
17
|
-
const NO_TOOLS_PREAMBLE = `CRITICAL: Respond with TEXT ONLY. Do NOT call any tools.
|
|
18
|
-
|
|
19
|
-
- Do NOT use Read, Bash, Grep, Glob, Edit, Write, or ANY other tool.
|
|
20
|
-
- You already have all the context you need in the conversation above.
|
|
21
|
-
- Tool calls will be REJECTED and will waste your only turn — you will fail the task.
|
|
22
|
-
- Your entire response must be plain text: an <analysis> block followed by a <summary> block.
|
|
23
|
-
|
|
17
|
+
const NO_TOOLS_PREAMBLE = `CRITICAL: Respond with TEXT ONLY. Do NOT call any tools.
|
|
18
|
+
|
|
19
|
+
- Do NOT use Read, Bash, Grep, Glob, Edit, Write, or ANY other tool.
|
|
20
|
+
- You already have all the context you need in the conversation above.
|
|
21
|
+
- Tool calls will be REJECTED and will waste your only turn — you will fail the task.
|
|
22
|
+
- Your entire response must be plain text: an <analysis> block followed by a <summary> block.
|
|
23
|
+
|
|
24
24
|
`;
|
|
25
25
|
// Two variants: BASE scopes to "the conversation", PARTIAL scopes to "the
|
|
26
26
|
// recent messages". The <analysis> block is a drafting scratchpad that
|
|
27
27
|
// formatCompactSummary() strips before the summary reaches context.
|
|
28
|
-
const DETAILED_ANALYSIS_INSTRUCTION_BASE = `Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
|
|
29
|
-
|
|
30
|
-
1. Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
|
|
31
|
-
- The user's explicit requests and intents
|
|
32
|
-
- Your approach to addressing the user's requests
|
|
33
|
-
- Key decisions, technical concepts and code patterns
|
|
34
|
-
- Specific details like:
|
|
35
|
-
- file names
|
|
36
|
-
- full code snippets
|
|
37
|
-
- function signatures
|
|
38
|
-
- file edits
|
|
39
|
-
- Errors that you ran into and how you fixed them
|
|
40
|
-
- Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
28
|
+
const DETAILED_ANALYSIS_INSTRUCTION_BASE = `Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
|
|
29
|
+
|
|
30
|
+
1. Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
|
|
31
|
+
- The user's explicit requests and intents
|
|
32
|
+
- Your approach to addressing the user's requests
|
|
33
|
+
- Key decisions, technical concepts and code patterns
|
|
34
|
+
- Specific details like:
|
|
35
|
+
- file names
|
|
36
|
+
- full code snippets
|
|
37
|
+
- function signatures
|
|
38
|
+
- file edits
|
|
39
|
+
- Errors that you ran into and how you fixed them
|
|
40
|
+
- Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
41
41
|
2. Double-check for technical accuracy and completeness, addressing each required element thoroughly.`;
|
|
42
|
-
const DETAILED_ANALYSIS_INSTRUCTION_PARTIAL = `Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
|
|
43
|
-
|
|
44
|
-
1. Analyze the recent messages chronologically. For each section thoroughly identify:
|
|
45
|
-
- The user's explicit requests and intents
|
|
46
|
-
- Your approach to addressing the user's requests
|
|
47
|
-
- Key decisions, technical concepts and code patterns
|
|
48
|
-
- Specific details like:
|
|
49
|
-
- file names
|
|
50
|
-
- full code snippets
|
|
51
|
-
- function signatures
|
|
52
|
-
- file edits
|
|
53
|
-
- Errors that you ran into and how you fixed them
|
|
54
|
-
- Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
42
|
+
const DETAILED_ANALYSIS_INSTRUCTION_PARTIAL = `Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
|
|
43
|
+
|
|
44
|
+
1. Analyze the recent messages chronologically. For each section thoroughly identify:
|
|
45
|
+
- The user's explicit requests and intents
|
|
46
|
+
- Your approach to addressing the user's requests
|
|
47
|
+
- Key decisions, technical concepts and code patterns
|
|
48
|
+
- Specific details like:
|
|
49
|
+
- file names
|
|
50
|
+
- full code snippets
|
|
51
|
+
- function signatures
|
|
52
|
+
- file edits
|
|
53
|
+
- Errors that you ran into and how you fixed them
|
|
54
|
+
- Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
55
55
|
2. Double-check for technical accuracy and completeness, addressing each required element thoroughly.`;
|
|
56
|
-
const BASE_COMPACT_PROMPT = `Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
|
57
|
-
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
|
|
58
|
-
|
|
59
|
-
${DETAILED_ANALYSIS_INSTRUCTION_BASE}
|
|
60
|
-
|
|
61
|
-
Your summary should include the following sections:
|
|
62
|
-
|
|
63
|
-
1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
|
|
64
|
-
2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
|
|
65
|
-
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
66
|
-
4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
67
|
-
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
68
|
-
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
|
|
69
|
-
7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
|
|
70
|
-
8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
|
71
|
-
9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
|
|
72
|
-
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
|
|
73
|
-
|
|
74
|
-
Here's an example of how your output should be structured:
|
|
75
|
-
|
|
76
|
-
<example>
|
|
77
|
-
<analysis>
|
|
78
|
-
[Your thought process, ensuring all points are covered thoroughly and accurately]
|
|
79
|
-
</analysis>
|
|
80
|
-
|
|
81
|
-
<summary>
|
|
82
|
-
1. Primary Request and Intent:
|
|
83
|
-
[Detailed description]
|
|
84
|
-
|
|
85
|
-
2. Key Technical Concepts:
|
|
86
|
-
- [Concept 1]
|
|
87
|
-
- [Concept 2]
|
|
88
|
-
- [...]
|
|
89
|
-
|
|
90
|
-
3. Files and Code Sections:
|
|
91
|
-
- [File Name 1]
|
|
92
|
-
- [Summary of why this file is important]
|
|
93
|
-
- [Summary of the changes made to this file, if any]
|
|
94
|
-
- [Important Code Snippet]
|
|
95
|
-
- [File Name 2]
|
|
96
|
-
- [Important Code Snippet]
|
|
97
|
-
- [...]
|
|
98
|
-
|
|
99
|
-
4. Errors and fixes:
|
|
100
|
-
- [Detailed description of error 1]:
|
|
101
|
-
- [How you fixed the error]
|
|
102
|
-
- [User feedback on the error if any]
|
|
103
|
-
- [...]
|
|
104
|
-
|
|
105
|
-
5. Problem Solving:
|
|
106
|
-
[Description of solved problems and ongoing troubleshooting]
|
|
107
|
-
|
|
108
|
-
6. All user messages:
|
|
109
|
-
- [Detailed non tool use user message]
|
|
110
|
-
- [...]
|
|
111
|
-
|
|
112
|
-
7. Pending Tasks:
|
|
113
|
-
- [Task 1]
|
|
114
|
-
- [Task 2]
|
|
115
|
-
- [...]
|
|
116
|
-
|
|
117
|
-
8. Current Work:
|
|
118
|
-
[Precise description of current work]
|
|
119
|
-
|
|
120
|
-
9. Optional Next Step:
|
|
121
|
-
[Optional Next step to take]
|
|
122
|
-
|
|
123
|
-
</summary>
|
|
124
|
-
</example>
|
|
125
|
-
|
|
126
|
-
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
|
|
127
|
-
|
|
128
|
-
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
|
|
129
|
-
<example>
|
|
130
|
-
## Compact Instructions
|
|
131
|
-
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
|
|
132
|
-
</example>
|
|
133
|
-
|
|
134
|
-
<example>
|
|
135
|
-
# Summary instructions
|
|
136
|
-
When you are using compact - please focus on test output and code changes. Include file reads verbatim.
|
|
137
|
-
</example>
|
|
56
|
+
const BASE_COMPACT_PROMPT = `Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
|
57
|
+
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
|
|
58
|
+
|
|
59
|
+
${DETAILED_ANALYSIS_INSTRUCTION_BASE}
|
|
60
|
+
|
|
61
|
+
Your summary should include the following sections:
|
|
62
|
+
|
|
63
|
+
1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
|
|
64
|
+
2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
|
|
65
|
+
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
66
|
+
4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
67
|
+
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
68
|
+
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
|
|
69
|
+
7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
|
|
70
|
+
8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
|
71
|
+
9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
|
|
72
|
+
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
|
|
73
|
+
|
|
74
|
+
Here's an example of how your output should be structured:
|
|
75
|
+
|
|
76
|
+
<example>
|
|
77
|
+
<analysis>
|
|
78
|
+
[Your thought process, ensuring all points are covered thoroughly and accurately]
|
|
79
|
+
</analysis>
|
|
80
|
+
|
|
81
|
+
<summary>
|
|
82
|
+
1. Primary Request and Intent:
|
|
83
|
+
[Detailed description]
|
|
84
|
+
|
|
85
|
+
2. Key Technical Concepts:
|
|
86
|
+
- [Concept 1]
|
|
87
|
+
- [Concept 2]
|
|
88
|
+
- [...]
|
|
89
|
+
|
|
90
|
+
3. Files and Code Sections:
|
|
91
|
+
- [File Name 1]
|
|
92
|
+
- [Summary of why this file is important]
|
|
93
|
+
- [Summary of the changes made to this file, if any]
|
|
94
|
+
- [Important Code Snippet]
|
|
95
|
+
- [File Name 2]
|
|
96
|
+
- [Important Code Snippet]
|
|
97
|
+
- [...]
|
|
98
|
+
|
|
99
|
+
4. Errors and fixes:
|
|
100
|
+
- [Detailed description of error 1]:
|
|
101
|
+
- [How you fixed the error]
|
|
102
|
+
- [User feedback on the error if any]
|
|
103
|
+
- [...]
|
|
104
|
+
|
|
105
|
+
5. Problem Solving:
|
|
106
|
+
[Description of solved problems and ongoing troubleshooting]
|
|
107
|
+
|
|
108
|
+
6. All user messages:
|
|
109
|
+
- [Detailed non tool use user message]
|
|
110
|
+
- [...]
|
|
111
|
+
|
|
112
|
+
7. Pending Tasks:
|
|
113
|
+
- [Task 1]
|
|
114
|
+
- [Task 2]
|
|
115
|
+
- [...]
|
|
116
|
+
|
|
117
|
+
8. Current Work:
|
|
118
|
+
[Precise description of current work]
|
|
119
|
+
|
|
120
|
+
9. Optional Next Step:
|
|
121
|
+
[Optional Next step to take]
|
|
122
|
+
|
|
123
|
+
</summary>
|
|
124
|
+
</example>
|
|
125
|
+
|
|
126
|
+
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
|
|
127
|
+
|
|
128
|
+
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
|
|
129
|
+
<example>
|
|
130
|
+
## Compact Instructions
|
|
131
|
+
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
|
|
132
|
+
</example>
|
|
133
|
+
|
|
134
|
+
<example>
|
|
135
|
+
# Summary instructions
|
|
136
|
+
When you are using compact - please focus on test output and code changes. Include file reads verbatim.
|
|
137
|
+
</example>
|
|
138
138
|
`;
|
|
139
|
-
const PARTIAL_COMPACT_PROMPT = `Your task is to create a detailed summary of the RECENT portion of the conversation — the messages that follow earlier retained context. The earlier messages are being kept intact and do NOT need to be summarized. Focus your summary on what was discussed, learned, and accomplished in the recent messages only.
|
|
140
|
-
|
|
141
|
-
${DETAILED_ANALYSIS_INSTRUCTION_PARTIAL}
|
|
142
|
-
|
|
143
|
-
Your summary should include the following sections:
|
|
144
|
-
|
|
145
|
-
1. Primary Request and Intent: Capture the user's explicit requests and intents from the recent messages
|
|
146
|
-
2. Key Technical Concepts: List important technical concepts, technologies, and frameworks discussed recently.
|
|
147
|
-
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
148
|
-
4. Errors and fixes: List errors encountered and how they were fixed.
|
|
149
|
-
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
150
|
-
6. All user messages: List ALL user messages from the recent portion that are not tool results.
|
|
151
|
-
7. Pending Tasks: Outline any pending tasks from the recent messages.
|
|
152
|
-
8. Current Work: Describe precisely what was being worked on immediately before this summary request.
|
|
153
|
-
9. Optional Next Step: List the next step related to the most recent work. Include direct quotes from the most recent conversation.
|
|
154
|
-
|
|
155
|
-
Here's an example of how your output should be structured:
|
|
156
|
-
|
|
157
|
-
<example>
|
|
158
|
-
<analysis>
|
|
159
|
-
[Your thought process, ensuring all points are covered thoroughly and accurately]
|
|
160
|
-
</analysis>
|
|
161
|
-
|
|
162
|
-
<summary>
|
|
163
|
-
1. Primary Request and Intent:
|
|
164
|
-
[Detailed description]
|
|
165
|
-
|
|
166
|
-
2. Key Technical Concepts:
|
|
167
|
-
- [Concept 1]
|
|
168
|
-
- [Concept 2]
|
|
169
|
-
|
|
170
|
-
3. Files and Code Sections:
|
|
171
|
-
- [File Name 1]
|
|
172
|
-
- [Summary of why this file is important]
|
|
173
|
-
- [Important Code Snippet]
|
|
174
|
-
|
|
175
|
-
4. Errors and fixes:
|
|
176
|
-
- [Error description]:
|
|
177
|
-
- [How you fixed it]
|
|
178
|
-
|
|
179
|
-
5. Problem Solving:
|
|
180
|
-
[Description]
|
|
181
|
-
|
|
182
|
-
6. All user messages:
|
|
183
|
-
- [Detailed non tool use user message]
|
|
184
|
-
|
|
185
|
-
7. Pending Tasks:
|
|
186
|
-
- [Task 1]
|
|
187
|
-
|
|
188
|
-
8. Current Work:
|
|
189
|
-
[Precise description of current work]
|
|
190
|
-
|
|
191
|
-
9. Optional Next Step:
|
|
192
|
-
[Optional Next step to take]
|
|
193
|
-
|
|
194
|
-
</summary>
|
|
195
|
-
</example>
|
|
196
|
-
|
|
197
|
-
Please provide your summary based on the RECENT messages only (after the retained earlier context), following this structure and ensuring precision and thoroughness in your response.
|
|
139
|
+
const PARTIAL_COMPACT_PROMPT = `Your task is to create a detailed summary of the RECENT portion of the conversation — the messages that follow earlier retained context. The earlier messages are being kept intact and do NOT need to be summarized. Focus your summary on what was discussed, learned, and accomplished in the recent messages only.
|
|
140
|
+
|
|
141
|
+
${DETAILED_ANALYSIS_INSTRUCTION_PARTIAL}
|
|
142
|
+
|
|
143
|
+
Your summary should include the following sections:
|
|
144
|
+
|
|
145
|
+
1. Primary Request and Intent: Capture the user's explicit requests and intents from the recent messages
|
|
146
|
+
2. Key Technical Concepts: List important technical concepts, technologies, and frameworks discussed recently.
|
|
147
|
+
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
148
|
+
4. Errors and fixes: List errors encountered and how they were fixed.
|
|
149
|
+
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
150
|
+
6. All user messages: List ALL user messages from the recent portion that are not tool results.
|
|
151
|
+
7. Pending Tasks: Outline any pending tasks from the recent messages.
|
|
152
|
+
8. Current Work: Describe precisely what was being worked on immediately before this summary request.
|
|
153
|
+
9. Optional Next Step: List the next step related to the most recent work. Include direct quotes from the most recent conversation.
|
|
154
|
+
|
|
155
|
+
Here's an example of how your output should be structured:
|
|
156
|
+
|
|
157
|
+
<example>
|
|
158
|
+
<analysis>
|
|
159
|
+
[Your thought process, ensuring all points are covered thoroughly and accurately]
|
|
160
|
+
</analysis>
|
|
161
|
+
|
|
162
|
+
<summary>
|
|
163
|
+
1. Primary Request and Intent:
|
|
164
|
+
[Detailed description]
|
|
165
|
+
|
|
166
|
+
2. Key Technical Concepts:
|
|
167
|
+
- [Concept 1]
|
|
168
|
+
- [Concept 2]
|
|
169
|
+
|
|
170
|
+
3. Files and Code Sections:
|
|
171
|
+
- [File Name 1]
|
|
172
|
+
- [Summary of why this file is important]
|
|
173
|
+
- [Important Code Snippet]
|
|
174
|
+
|
|
175
|
+
4. Errors and fixes:
|
|
176
|
+
- [Error description]:
|
|
177
|
+
- [How you fixed it]
|
|
178
|
+
|
|
179
|
+
5. Problem Solving:
|
|
180
|
+
[Description]
|
|
181
|
+
|
|
182
|
+
6. All user messages:
|
|
183
|
+
- [Detailed non tool use user message]
|
|
184
|
+
|
|
185
|
+
7. Pending Tasks:
|
|
186
|
+
- [Task 1]
|
|
187
|
+
|
|
188
|
+
8. Current Work:
|
|
189
|
+
[Precise description of current work]
|
|
190
|
+
|
|
191
|
+
9. Optional Next Step:
|
|
192
|
+
[Optional Next step to take]
|
|
193
|
+
|
|
194
|
+
</summary>
|
|
195
|
+
</example>
|
|
196
|
+
|
|
197
|
+
Please provide your summary based on the RECENT messages only (after the retained earlier context), following this structure and ensuring precision and thoroughness in your response.
|
|
198
198
|
`;
|
|
199
199
|
// 'up_to': model sees only the summarized prefix (cache hit). Summary will
|
|
200
200
|
// precede kept recent messages, hence "Context for Continuing Work" section.
|
|
201
|
-
const PARTIAL_COMPACT_UP_TO_PROMPT = `Your task is to create a detailed summary of this conversation. This summary will be placed at the start of a continuing session; newer messages that build on this context will follow after your summary (you do not see them here). Summarize thoroughly so that someone reading only your summary and then the newer messages can fully understand what happened and continue the work.
|
|
202
|
-
|
|
203
|
-
${DETAILED_ANALYSIS_INSTRUCTION_BASE}
|
|
204
|
-
|
|
205
|
-
Your summary should include the following sections:
|
|
206
|
-
|
|
207
|
-
1. Primary Request and Intent: Capture the user's explicit requests and intents in detail
|
|
208
|
-
2. Key Technical Concepts: List important technical concepts, technologies, and frameworks discussed.
|
|
209
|
-
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
210
|
-
4. Errors and fixes: List errors encountered and how they were fixed.
|
|
211
|
-
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
212
|
-
6. All user messages: List ALL user messages that are not tool results.
|
|
213
|
-
7. Pending Tasks: Outline any pending tasks.
|
|
214
|
-
8. Work Completed: Describe what was accomplished by the end of this portion.
|
|
215
|
-
9. Context for Continuing Work: Summarize any context, decisions, or state that would be needed to understand and continue the work in subsequent messages.
|
|
216
|
-
|
|
217
|
-
Here's an example of how your output should be structured:
|
|
218
|
-
|
|
219
|
-
<example>
|
|
220
|
-
<analysis>
|
|
221
|
-
[Your thought process, ensuring all points are covered thoroughly and accurately]
|
|
222
|
-
</analysis>
|
|
223
|
-
|
|
224
|
-
<summary>
|
|
225
|
-
1. Primary Request and Intent:
|
|
226
|
-
[Detailed description]
|
|
227
|
-
|
|
228
|
-
2. Key Technical Concepts:
|
|
229
|
-
- [Concept 1]
|
|
230
|
-
- [Concept 2]
|
|
231
|
-
|
|
232
|
-
3. Files and Code Sections:
|
|
233
|
-
- [File Name 1]
|
|
234
|
-
- [Summary of why this file is important]
|
|
235
|
-
- [Important Code Snippet]
|
|
236
|
-
|
|
237
|
-
4. Errors and fixes:
|
|
238
|
-
- [Error description]:
|
|
239
|
-
- [How you fixed it]
|
|
240
|
-
|
|
241
|
-
5. Problem Solving:
|
|
242
|
-
[Description]
|
|
243
|
-
|
|
244
|
-
6. All user messages:
|
|
245
|
-
- [Detailed non tool use user message]
|
|
246
|
-
|
|
247
|
-
7. Pending Tasks:
|
|
248
|
-
- [Task 1]
|
|
249
|
-
|
|
250
|
-
8. Work Completed:
|
|
251
|
-
[Description of what was accomplished]
|
|
252
|
-
|
|
253
|
-
9. Context for Continuing Work:
|
|
254
|
-
[Key context, decisions, or state needed to continue the work]
|
|
255
|
-
|
|
256
|
-
</summary>
|
|
257
|
-
</example>
|
|
258
|
-
|
|
259
|
-
Please provide your summary following this structure, ensuring precision and thoroughness in your response.
|
|
201
|
+
const PARTIAL_COMPACT_UP_TO_PROMPT = `Your task is to create a detailed summary of this conversation. This summary will be placed at the start of a continuing session; newer messages that build on this context will follow after your summary (you do not see them here). Summarize thoroughly so that someone reading only your summary and then the newer messages can fully understand what happened and continue the work.
|
|
202
|
+
|
|
203
|
+
${DETAILED_ANALYSIS_INSTRUCTION_BASE}
|
|
204
|
+
|
|
205
|
+
Your summary should include the following sections:
|
|
206
|
+
|
|
207
|
+
1. Primary Request and Intent: Capture the user's explicit requests and intents in detail
|
|
208
|
+
2. Key Technical Concepts: List important technical concepts, technologies, and frameworks discussed.
|
|
209
|
+
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
210
|
+
4. Errors and fixes: List errors encountered and how they were fixed.
|
|
211
|
+
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
212
|
+
6. All user messages: List ALL user messages that are not tool results.
|
|
213
|
+
7. Pending Tasks: Outline any pending tasks.
|
|
214
|
+
8. Work Completed: Describe what was accomplished by the end of this portion.
|
|
215
|
+
9. Context for Continuing Work: Summarize any context, decisions, or state that would be needed to understand and continue the work in subsequent messages.
|
|
216
|
+
|
|
217
|
+
Here's an example of how your output should be structured:
|
|
218
|
+
|
|
219
|
+
<example>
|
|
220
|
+
<analysis>
|
|
221
|
+
[Your thought process, ensuring all points are covered thoroughly and accurately]
|
|
222
|
+
</analysis>
|
|
223
|
+
|
|
224
|
+
<summary>
|
|
225
|
+
1. Primary Request and Intent:
|
|
226
|
+
[Detailed description]
|
|
227
|
+
|
|
228
|
+
2. Key Technical Concepts:
|
|
229
|
+
- [Concept 1]
|
|
230
|
+
- [Concept 2]
|
|
231
|
+
|
|
232
|
+
3. Files and Code Sections:
|
|
233
|
+
- [File Name 1]
|
|
234
|
+
- [Summary of why this file is important]
|
|
235
|
+
- [Important Code Snippet]
|
|
236
|
+
|
|
237
|
+
4. Errors and fixes:
|
|
238
|
+
- [Error description]:
|
|
239
|
+
- [How you fixed it]
|
|
240
|
+
|
|
241
|
+
5. Problem Solving:
|
|
242
|
+
[Description]
|
|
243
|
+
|
|
244
|
+
6. All user messages:
|
|
245
|
+
- [Detailed non tool use user message]
|
|
246
|
+
|
|
247
|
+
7. Pending Tasks:
|
|
248
|
+
- [Task 1]
|
|
249
|
+
|
|
250
|
+
8. Work Completed:
|
|
251
|
+
[Description of what was accomplished]
|
|
252
|
+
|
|
253
|
+
9. Context for Continuing Work:
|
|
254
|
+
[Key context, decisions, or state needed to continue the work]
|
|
255
|
+
|
|
256
|
+
</summary>
|
|
257
|
+
</example>
|
|
258
|
+
|
|
259
|
+
Please provide your summary following this structure, ensuring precision and thoroughness in your response.
|
|
260
260
|
`;
|
|
261
261
|
const NO_TOOLS_TRAILER = '\n\nREMINDER: Do NOT call any tools. Respond with plain text only — ' +
|
|
262
262
|
'an <analysis> block followed by a <summary> block. ' +
|
|
@@ -303,8 +303,8 @@ export function formatCompactSummary(summary) {
|
|
|
303
303
|
}
|
|
304
304
|
export function getCompactUserSummaryMessage(summary, suppressFollowUpQuestions, transcriptPath, recentMessagesPreserved) {
|
|
305
305
|
const formattedSummary = formatCompactSummary(summary);
|
|
306
|
-
let baseSummary = `This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion of the conversation.
|
|
307
|
-
|
|
306
|
+
let baseSummary = `This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion of the conversation.
|
|
307
|
+
|
|
308
308
|
${formattedSummary}`;
|
|
309
309
|
if (transcriptPath) {
|
|
310
310
|
baseSummary += `\n\nIf you need specific details from before compaction (like exact code snippets, error messages, or content you generated), read the full transcript at: ${transcriptPath}`;
|
|
@@ -313,12 +313,12 @@ ${formattedSummary}`;
|
|
|
313
313
|
baseSummary += `\n\nRecent messages are preserved verbatim.`;
|
|
314
314
|
}
|
|
315
315
|
if (suppressFollowUpQuestions) {
|
|
316
|
-
let continuation = `${baseSummary}
|
|
316
|
+
let continuation = `${baseSummary}
|
|
317
317
|
Continue the conversation from where it left off without asking the user any further questions. Resume directly — do not acknowledge the summary, do not recap what was happening, do not preface with "I'll continue" or similar. Pick up the last task as if the break never happened.`;
|
|
318
318
|
if ((feature('PROACTIVE') || feature('KAIROS')) &&
|
|
319
319
|
proactiveModule?.isProactiveActive()) {
|
|
320
|
-
continuation += `
|
|
321
|
-
|
|
320
|
+
continuation += `
|
|
321
|
+
|
|
322
322
|
You are running in autonomous/proactive mode. This is NOT a first wake-up — you were already working autonomously before compaction. Continue your work loop: pick up where you left off based on the summary above. Do not greet the user or ask what to work on.`;
|
|
323
323
|
}
|
|
324
324
|
return continuation;
|
|
@@ -13,15 +13,15 @@ async function ensureTable() {
|
|
|
13
13
|
tableEnsurePromise = (async () => {
|
|
14
14
|
try {
|
|
15
15
|
const db = await getOrchestrationDatabase();
|
|
16
|
-
db.exec(`
|
|
17
|
-
CREATE TABLE IF NOT EXISTS provider_usage_counters (
|
|
18
|
-
provider TEXT NOT NULL,
|
|
19
|
-
profile_id TEXT NOT NULL,
|
|
20
|
-
tokens_in INTEGER NOT NULL DEFAULT 0,
|
|
21
|
-
tokens_out INTEGER NOT NULL DEFAULT 0,
|
|
22
|
-
last_updated TEXT NOT NULL,
|
|
23
|
-
PRIMARY KEY (provider, profile_id)
|
|
24
|
-
);
|
|
16
|
+
db.exec(`
|
|
17
|
+
CREATE TABLE IF NOT EXISTS provider_usage_counters (
|
|
18
|
+
provider TEXT NOT NULL,
|
|
19
|
+
profile_id TEXT NOT NULL,
|
|
20
|
+
tokens_in INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
tokens_out INTEGER NOT NULL DEFAULT 0,
|
|
22
|
+
last_updated TEXT NOT NULL,
|
|
23
|
+
PRIMARY KEY (provider, profile_id)
|
|
24
|
+
);
|
|
25
25
|
`);
|
|
26
26
|
tableEnsured = true;
|
|
27
27
|
}
|
|
@@ -55,8 +55,8 @@ async function readPersistedRowAsync(provider, profileId) {
|
|
|
55
55
|
try {
|
|
56
56
|
const db = await getOrchestrationDatabase();
|
|
57
57
|
const row = db
|
|
58
|
-
.prepare(`SELECT provider, profile_id, tokens_in, tokens_out, last_updated
|
|
59
|
-
FROM provider_usage_counters
|
|
58
|
+
.prepare(`SELECT provider, profile_id, tokens_in, tokens_out, last_updated
|
|
59
|
+
FROM provider_usage_counters
|
|
60
60
|
WHERE provider = ? AND profile_id = ?`)
|
|
61
61
|
.get(provider, profileId);
|
|
62
62
|
if (!row) {
|
|
@@ -79,11 +79,11 @@ async function persistIncrement(provider, profileId, tokensIn, tokensOut) {
|
|
|
79
79
|
try {
|
|
80
80
|
const db = await getOrchestrationDatabase();
|
|
81
81
|
const nowIso = new Date().toISOString();
|
|
82
|
-
db.prepare(`INSERT INTO provider_usage_counters (provider, profile_id, tokens_in, tokens_out, last_updated)
|
|
83
|
-
VALUES (?, ?, ?, ?, ?)
|
|
84
|
-
ON CONFLICT(provider, profile_id) DO UPDATE SET
|
|
85
|
-
tokens_in = tokens_in + excluded.tokens_in,
|
|
86
|
-
tokens_out = tokens_out + excluded.tokens_out,
|
|
82
|
+
db.prepare(`INSERT INTO provider_usage_counters (provider, profile_id, tokens_in, tokens_out, last_updated)
|
|
83
|
+
VALUES (?, ?, ?, ?, ?)
|
|
84
|
+
ON CONFLICT(provider, profile_id) DO UPDATE SET
|
|
85
|
+
tokens_in = tokens_in + excluded.tokens_in,
|
|
86
|
+
tokens_out = tokens_out + excluded.tokens_out,
|
|
87
87
|
last_updated = excluded.last_updated`).run(provider, profileId, tokensIn, tokensOut, nowIso);
|
|
88
88
|
}
|
|
89
89
|
catch {
|
|
@@ -126,7 +126,7 @@ export async function getAllCounters() {
|
|
|
126
126
|
try {
|
|
127
127
|
const db = await getOrchestrationDatabase();
|
|
128
128
|
persistedRows = db
|
|
129
|
-
.prepare(`SELECT provider, profile_id, tokens_in, tokens_out, last_updated
|
|
129
|
+
.prepare(`SELECT provider, profile_id, tokens_in, tokens_out, last_updated
|
|
130
130
|
FROM provider_usage_counters`)
|
|
131
131
|
.all();
|
|
132
132
|
}
|