@iaforged/context-code 1.2.8 → 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.
Files changed (172) hide show
  1. package/README.md +119 -119
  2. package/context-bootstrap.js +26 -26
  3. package/dist/src/QueryEngine.js +394 -327
  4. package/dist/src/bridge/bridgeUI.js +1 -1
  5. package/dist/src/buddy/prompt.js +4 -4
  6. package/dist/src/cli/handlers/auth.js +126 -9
  7. package/dist/src/cli/print.js +35 -1
  8. package/dist/src/commands/agent/agent.js +28 -2
  9. package/dist/src/commands/agent/agentStore.js +8 -1
  10. package/dist/src/commands/agent/index.js +1 -1
  11. package/dist/src/commands/bridge-kick.js +9 -9
  12. package/dist/src/commands/commit.js +34 -34
  13. package/dist/src/commands/init-verifiers.js +3 -3
  14. package/dist/src/commands/init.js +88 -88
  15. package/dist/src/commands/insights.js +787 -787
  16. package/dist/src/commands/install.js +19 -19
  17. package/dist/src/commands/login/login.js +21 -12
  18. package/dist/src/commands/logout/logout.js +9 -0
  19. package/dist/src/commands/model/model.js +9 -4
  20. package/dist/src/commands/orchestrate/SwarmUI.js +50 -0
  21. package/dist/src/commands/orchestrate/index.js +2 -2
  22. package/dist/src/commands/orchestrate/orchestrate.js +708 -12
  23. package/dist/src/commands/pr_comments/index.js +33 -33
  24. package/dist/src/commands/profile/index.js +1 -1
  25. package/dist/src/commands/profile/profile.js +52 -3
  26. package/dist/src/commands/provider/index.js +1 -1
  27. package/dist/src/commands/provider/provider.js +117 -45
  28. package/dist/src/commands/resumen/index.js +9 -0
  29. package/dist/src/commands/resumen/resumen.js +29 -0
  30. package/dist/src/commands/security-review.js +190 -190
  31. package/dist/src/commands/swarm-auto/index.js +9 -0
  32. package/dist/src/commands/swarm-auto/swarmAuto.js +111 -0
  33. package/dist/src/commands/swarm-init/index.js +9 -0
  34. package/dist/src/commands/swarm-init/swarmInit.js +72 -0
  35. package/dist/src/commands/team/team.js +39 -6
  36. package/dist/src/commands.js +14 -0
  37. package/dist/src/components/LogoV2/CondensedLogo.js +2 -2
  38. package/dist/src/components/PromptInput/PromptInputQueuedCommands.js +3 -3
  39. package/dist/src/components/agents/agentFileUtils.js +6 -6
  40. package/dist/src/components/permissions/hooks.js +5 -5
  41. package/dist/src/constants/outputStyles.js +83 -83
  42. package/dist/src/core/agents/blueprints.js +58 -0
  43. package/dist/src/core/agents/cliAdapter.js +61 -0
  44. package/dist/src/core/agents/registry.js +93 -0
  45. package/dist/src/core/agents/runtime.js +4 -0
  46. package/dist/src/core/agents/runtime.smoke.js +42 -0
  47. package/dist/src/core/agents/swarm.smoke.js +48 -0
  48. package/dist/src/core/agents/swarmTools.js +38 -0
  49. package/dist/src/core/auth/index.js +2 -0
  50. package/dist/src/core/auth/loginCliAdapter.js +24 -0
  51. package/dist/src/core/auth/loginCore.js +67 -0
  52. package/dist/src/core/auth/logoutCliAdapter.js +34 -0
  53. package/dist/src/core/auth/logoutCore.js +52 -0
  54. package/dist/src/core/auth/preflight.smoke.js +151 -0
  55. package/dist/src/core/index.js +21 -0
  56. package/dist/src/core/mcp/blueprints.js +27 -0
  57. package/dist/src/core/mcp/common.js +14 -0
  58. package/dist/src/core/mcp/runtime.js +67 -0
  59. package/dist/src/core/mcp/runtime.smoke.js +50 -0
  60. package/dist/src/core/mcp/swarmClient.js +40 -0
  61. package/dist/src/core/mcp/swarmSetup.js +43 -0
  62. package/dist/src/core/providers/cliAdapter.js +39 -0
  63. package/dist/src/core/providers/contracts.js +1 -0
  64. package/dist/src/core/providers/index.js +3 -0
  65. package/dist/src/core/providers/llmCore.js +123 -0
  66. package/dist/src/core/providers/providerCore.js +141 -0
  67. package/dist/src/core/providers/providerModelCompatibility.js +98 -0
  68. package/dist/src/core/providers/providerParitySmoke.js +83 -0
  69. package/dist/src/core/providers/providerProfileModelSmoke.js +80 -0
  70. package/dist/src/core/query/contracts.js +1 -0
  71. package/dist/src/core/query/runtime.js +117 -0
  72. package/dist/src/core/query/runtime.smoke.js +39 -0
  73. package/dist/src/core/query/timelineThinking.smoke.js +25 -0
  74. package/dist/src/core/query/wiring.smoke.js +76 -0
  75. package/dist/src/core/skills/cliAdapter.js +38 -0
  76. package/dist/src/core/skills/index.js +52 -0
  77. package/dist/src/core/skills/runtime.smoke.js +53 -0
  78. package/dist/src/core/tasks/runtime.js +205 -0
  79. package/dist/src/core/tasks/runtime.smoke.js +63 -0
  80. package/dist/src/core/tasks/sdkAdapter.js +4 -0
  81. package/dist/src/core/tools/contracts.js +3 -0
  82. package/dist/src/core/tools/fileResolution.js +112 -0
  83. package/dist/src/core/tools/fileResolution.smoke.js +33 -0
  84. package/dist/src/core/tools/filesCore.js +51 -0
  85. package/dist/src/core/tools/filesCore.smoke.js +108 -0
  86. package/dist/src/core/tools/gitCore.js +20 -0
  87. package/dist/src/core/tools/imageParity.smoke.js +36 -0
  88. package/dist/src/core/tools/notebookParity.smoke.js +68 -0
  89. package/dist/src/core/tools/registry.js +22 -0
  90. package/dist/src/core/tools/runtime.smoke.js +32 -0
  91. package/dist/src/core/tools/shellCore.js +60 -0
  92. package/dist/src/core/types/agentContext.js +9 -0
  93. package/dist/src/core/types/auth.js +3 -0
  94. package/dist/src/core/types/command.js +13 -0
  95. package/dist/src/core/types/provider.js +3 -0
  96. package/dist/src/core/types/sdkEvent.js +10 -0
  97. package/dist/src/core/types/swarm.js +1 -0
  98. package/dist/src/cost-tracker.js +3 -3
  99. package/dist/src/hooks/useAwaySummary.js +22 -9
  100. package/dist/src/main.js +32 -2
  101. package/dist/src/screens/REPL.js +9 -0
  102. package/dist/src/services/AgentSummary/agentSummary.js +10 -10
  103. package/dist/src/services/autoDream/autoDream.js +5 -5
  104. package/dist/src/services/autoDream/consolidationPrompt.js +49 -49
  105. package/dist/src/services/compact/prompt.js +238 -238
  106. package/dist/src/services/limits/sessionCounter.js +17 -17
  107. package/dist/src/services/mcp/client.js +27 -1
  108. package/dist/src/services/orchestration/execution/AgentTaskExecutor.js +39 -20
  109. package/dist/src/services/orchestration/execution/OrchestrationExecutionRuntime.js +65 -58
  110. package/dist/src/skills/bundled/loop.js +57 -57
  111. package/dist/src/skills/bundled/remember.js +53 -53
  112. package/dist/src/skills/bundled/simplify.js +49 -49
  113. package/dist/src/skills/bundled/skillify.js +2 -2
  114. package/dist/src/state/onChangeAppState.js +6 -0
  115. package/dist/src/tasks/LocalAgentTask/LocalAgentTask.js +5 -5
  116. package/dist/src/tasks/LocalMainSessionTask.js +5 -5
  117. package/dist/src/tasks/LocalShellTask/LocalShellTask.js +13 -13
  118. package/dist/src/tools/AgentTool/forkSubagent.js +25 -25
  119. package/dist/src/tools/AskUserQuestionTool/prompt.js +29 -29
  120. package/dist/src/tools/BashTool/BashTool.js +27 -2
  121. package/dist/src/tools/BriefTool/prompt.js +14 -14
  122. package/dist/src/tools/EnterPlanModeTool/EnterPlanModeTool.js +12 -12
  123. package/dist/src/tools/EnterPlanModeTool/prompt.js +140 -140
  124. package/dist/src/tools/ExitPlanModeTool/ExitPlanModeV2Tool.js +18 -18
  125. package/dist/src/tools/ExitPlanModeTool/prompt.js +23 -23
  126. package/dist/src/tools/ExitWorktreeTool/prompt.js +29 -29
  127. package/dist/src/tools/FileEditTool/prompt.js +7 -7
  128. package/dist/src/tools/FileReadTool/FileReadTool.js +18 -1
  129. package/dist/src/tools/FileWriteTool/prompt.js +6 -6
  130. package/dist/src/tools/GlobTool/prompt.js +4 -4
  131. package/dist/src/tools/GrepTool/prompt.js +10 -10
  132. package/dist/src/tools/LSPTool/prompt.js +18 -18
  133. package/dist/src/tools/ListMcpResourcesTool/prompt.js +15 -15
  134. package/dist/src/tools/PowerShellTool/PowerShellTool.js +25 -2
  135. package/dist/src/tools/ReadMcpResourceTool/prompt.js +13 -13
  136. package/dist/src/tools/SendMessageTool/prompt.js +36 -36
  137. package/dist/src/tools/SkillTool/prompt.js +21 -21
  138. package/dist/src/tools/SleepTool/prompt.js +10 -10
  139. package/dist/src/tools/TaskCreateTool/prompt.js +41 -41
  140. package/dist/src/tools/TaskGetTool/prompt.js +21 -21
  141. package/dist/src/tools/TaskListTool/prompt.js +30 -30
  142. package/dist/src/tools/TaskOutputTool/TaskOutputTool.js +8 -8
  143. package/dist/src/tools/TaskStopTool/prompt.js +5 -5
  144. package/dist/src/tools/TaskUpdateTool/prompt.js +74 -74
  145. package/dist/src/tools/TodoWriteTool/prompt.js +178 -178
  146. package/dist/src/tools/ToolSearchTool/prompt.js +9 -9
  147. package/dist/src/tools/WebFetchTool/WebFetchTool.js +9 -9
  148. package/dist/src/tools/WebFetchTool/prompt.js +31 -31
  149. package/dist/src/tools/WebSearchTool/prompt.js +26 -26
  150. package/dist/src/utils/agentContext.js +2 -0
  151. package/dist/src/utils/agenticSessionSearch.js +38 -38
  152. package/dist/src/utils/config.js +2 -0
  153. package/dist/src/utils/genericProcessUtils.js +21 -21
  154. package/dist/src/utils/heapDumpService.js +4 -4
  155. package/dist/src/utils/mcpValidation.js +2 -2
  156. package/dist/src/utils/model/modelStrings.js +1 -1
  157. package/dist/src/utils/model/providers.js +5 -0
  158. package/dist/src/utils/orchestration/store/providerAgentStore.js +22 -22
  159. package/dist/src/utils/orchestration/store/providerWorkspaceStore.js +10 -10
  160. package/dist/src/utils/orchestration/store/runStore.js +68 -68
  161. package/dist/src/utils/orchestration/store/teamStore.js +28 -28
  162. package/dist/src/utils/permissions/permissionExplainer.js +6 -6
  163. package/dist/src/utils/permissions/permissionsDb.js +43 -43
  164. package/dist/src/utils/sdkEventQueue.js +2 -0
  165. package/dist/src/utils/secureStorage/sqliteStorage.js +12 -12
  166. package/dist/src/utils/standardMcp/common.js +15 -0
  167. package/dist/src/utils/standardMcp/setup.js +52 -0
  168. package/dist/src/utils/swarm/teammatePromptAddendum.js +10 -10
  169. package/dist/src/utils/task/framework.js +6 -6
  170. package/package.json +1 -1
  171. package/dist/src/commands/usage/index.js +0 -7
  172. package/dist/src/commands/usage/usage.js +0 -5
@@ -139,6 +139,7 @@ import { getSkillDirCommands, clearSkillCaches, getDynamicSkills, } from './skil
139
139
  import { getBundledSkills } from './skills/bundledSkills.js';
140
140
  import { getBuiltinPluginSkillCommands } from './plugins/builtinPlugins.js';
141
141
  import { getPluginCommands, clearPluginCommandCache, getPluginSkills, clearPluginSkillsCache, } from './utils/plugins/loadPluginCommands.js';
142
+ import { isCoreSkillsEnabled, loadCoreSkillCommandSources, } from './core/skills/index.js';
142
143
  import memoize from 'lodash-es/memoize.js';
143
144
  import { isUsing3PServices, isClaudeAISubscriber } from './utils/auth.js';
144
145
  import { isFirstPartyAnthropicBaseUrl } from './utils/model/providers.js';
@@ -153,7 +154,12 @@ import workspace from './commands/workspace/index.js';
153
154
  import provider from './commands/provider/index.js';
154
155
  import tag from './commands/tag/index.js';
155
156
  import teamAuto from './commands/team-auto/index.js';
157
+ import orchestrate from './commands/orchestrate/index.js';
158
+ import swarmAuto from './commands/swarm-auto/index.js';
159
+ import swarmInit from './commands/swarm-init/index.js';
160
+ import team from './commands/team/index.js';
156
161
  import limites from './commands/limites/index.js';
162
+ import resumen from './commands/resumen/index.js';
157
163
  import outputStyle from './commands/output-style/index.js';
158
164
  import remoteEnv from './commands/remote-env/index.js';
159
165
  import upgrade from './commands/upgrade/index.js';
@@ -243,6 +249,7 @@ const COMMANDS = memoize(() => [
243
249
  remoteEnv,
244
250
  plugin,
245
251
  pr_comments,
252
+ resumen,
246
253
  releaseNotes,
247
254
  reloadPlugins,
248
255
  rename,
@@ -255,6 +262,10 @@ const COMMANDS = memoize(() => [
255
262
  stickers,
256
263
  tag,
257
264
  teamAuto,
265
+ orchestrate,
266
+ swarmAuto,
267
+ swarmInit,
268
+ team,
258
269
  limites,
259
270
  theme,
260
271
  timeline,
@@ -299,6 +310,9 @@ const COMMANDS = memoize(() => [
299
310
  export const builtInCommandNames = memoize(() => new Set(COMMANDS().flatMap(_ => [_.name || '', ...(_.aliases?.filter(Boolean) ?? [])].map(n => n.toLowerCase()))));
300
311
  async function getSkills(cwd) {
301
312
  try {
313
+ if (isCoreSkillsEnabled()) {
314
+ return await loadCoreSkillCommandSources(cwd);
315
+ }
302
316
  const [skillDirCommands, pluginSkills] = await Promise.all([
303
317
  getSkillDirCommands(cwd).catch(err => {
304
318
  logError(toError(err));
@@ -95,7 +95,7 @@ export function CondensedLogo() {
95
95
  }
96
96
  let t7;
97
97
  if ($[11] !== shouldSplit || $[12] !== truncatedBilling || $[13] !== truncatedModel) {
98
- t7 = shouldSplit ? _jsxs(_Fragment, { children: [_jsx(Text, { dimColor: true, children: truncatedModel }), _jsx(Text, { dimColor: true, children: truncatedBilling })] }) : _jsxs(Text, { dimColor: true, children: [truncatedModel, " \u00B7 ", truncatedBilling] });
98
+ t7 = shouldSplit ? _jsxs(_Fragment, { children: [_jsxs(Text, { children: ["Perfil: ", truncatedModel] }), _jsx(Text, { children: truncatedBilling })] }) : _jsxs(Text, { children: ["Perfil: ", truncatedModel, " \uFFFD ", truncatedBilling] });
99
99
  $[11] = shouldSplit;
100
100
  $[12] = truncatedBilling;
101
101
  $[13] = truncatedModel;
@@ -134,7 +134,7 @@ export function CondensedLogo() {
134
134
  else {
135
135
  t11 = $[22];
136
136
  }
137
- return _jsx(OffscreenFreeze, { children: _jsxs(Box, { flexDirection: "row", gap: 2, alignItems: "center", children: [t4, _jsxs(Box, { flexDirection: "column", children: [t6, t7, agentName ? _jsxs(Text, { dimColor: true, children: ["@", agentName] }) : null, t9, t10, t11] })] }) });
137
+ return _jsx(OffscreenFreeze, { children: _jsxs(Box, { flexDirection: "row", gap: 2, alignItems: "center", children: [t4, _jsxs(Box, { flexDirection: "column", children: [t6, t7, agentName ? _jsxs(Text, { children: ["Proveedor: @", agentName] }) : null, _jsxs(Text, { children: ["Ruta: ", t8] }), t10, t11] })] }) });
138
138
  }
139
139
  function _temp2(s_0) {
140
140
  return s_0.effortValue;
@@ -31,9 +31,9 @@ const MAX_VISIBLE_NOTIFICATIONS = 3;
31
31
  * Create a synthetic overflow notification message for capped task notifications.
32
32
  */
33
33
  function createOverflowNotificationMessage(count) {
34
- return `<${TASK_NOTIFICATION_TAG}>
35
- <${SUMMARY_TAG}>+${count} tareas más completadas</${SUMMARY_TAG}>
36
- <${STATUS_TAG}>completed</${STATUS_TAG}>
34
+ return `<${TASK_NOTIFICATION_TAG}>
35
+ <${SUMMARY_TAG}>+${count} tareas más completadas</${SUMMARY_TAG}>
36
+ <${STATUS_TAG}>completed</${STATUS_TAG}>
37
37
  </${TASK_NOTIFICATION_TAG}>`;
38
38
  }
39
39
  /**
@@ -32,12 +32,12 @@ export function formatAgentAsMarkdown(agentType, whenToUse, tools, systemPrompt,
32
32
  const effortLine = effort !== undefined ? `\neffort: ${effort}` : '';
33
33
  const colorLine = color ? `\ncolor: ${color}` : '';
34
34
  const memoryLine = memory ? `\nmemory: ${memory}` : '';
35
- return `---
36
- name: ${agentType}
37
- description: "${escapedWhenToUse}"${toolsLine}${modelLine}${providerLine}${effortLine}${colorLine}${memoryLine}
38
- ---
39
-
40
- ${systemPrompt}
35
+ return `---
36
+ name: ${agentType}
37
+ description: "${escapedWhenToUse}"${toolsLine}${modelLine}${providerLine}${effortLine}${colorLine}${memoryLine}
38
+ ---
39
+
40
+ ${systemPrompt}
41
41
  `;
42
42
  }
43
43
  /**
@@ -20,20 +20,20 @@ function permissionResultToLog(permissionResult) {
20
20
  const suggestions = rules.length > 0
21
21
  ? rules.map(r => permissionRuleValueToString(r)).join(', ')
22
22
  : 'none';
23
- return `ask: ${permissionResult.message},
24
- suggestions: ${suggestions}
23
+ return `ask: ${permissionResult.message},
24
+ suggestions: ${suggestions}
25
25
  reason: ${decisionReasonToString(permissionResult.decisionReason)}`;
26
26
  }
27
27
  case 'deny':
28
- return `deny: ${permissionResult.message},
28
+ return `deny: ${permissionResult.message},
29
29
  reason: ${decisionReasonToString(permissionResult.decisionReason)}`;
30
30
  case 'passthrough': {
31
31
  const rules = extractRules(permissionResult.suggestions);
32
32
  const suggestions = rules.length > 0
33
33
  ? rules.map(r => permissionRuleValueToString(r)).join(', ')
34
34
  : 'none';
35
- return `passthrough: ${permissionResult.message},
36
- suggestions: ${suggestions}
35
+ return `passthrough: ${permissionResult.message},
36
+ suggestions: ${suggestions}
37
37
  reason: ${decisionReasonToString(permissionResult.decisionReason)}`;
38
38
  }
39
39
  }
@@ -6,13 +6,13 @@ import { logForDebugging } from '../utils/debug.js';
6
6
  import { loadPluginOutputStyles } from '../utils/plugins/loadPluginOutputStyles.js';
7
7
  import { getSettings_DEPRECATED } from '../utils/settings/settings.js';
8
8
  // Used in both the Explanatory and Learning modes
9
- const EXPLANATORY_FEATURE_PROMPT = `
10
- ## Insights
11
- In order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):
12
- "\`${figures.star} Insight ─────────────────────────────────────\`
13
- [2-3 key educational points]
14
- \`─────────────────────────────────────────────────\`"
15
-
9
+ const EXPLANATORY_FEATURE_PROMPT = `
10
+ ## Insights
11
+ In order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):
12
+ "\`${figures.star} Insight ─────────────────────────────────────\`
13
+ [2-3 key educational points]
14
+ \`─────────────────────────────────────────────────\`"
15
+
16
16
  These insights should be included in the conversation, not in the codebase. You should generally focus on interesting insights that are specific to the codebase or the code you just wrote, rather than general programming concepts.`;
17
17
  export const DEFAULT_OUTPUT_STYLE_NAME = 'default';
18
18
  export const OUTPUT_STYLE_CONFIG = {
@@ -22,11 +22,11 @@ export const OUTPUT_STYLE_CONFIG = {
22
22
  source: 'built-in',
23
23
  description: 'Claude explains its implementation choices and codebase patterns',
24
24
  keepCodingInstructions: true,
25
- prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should provide educational insights about the codebase along the way.
26
-
27
- You should be clear and educational, providing helpful explanations while remaining focused on the task. Balance educational content with task completion. When providing insights, you may exceed typical length constraints, but remain focused and relevant.
28
-
29
- # Explanatory Style Active
25
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should provide educational insights about the codebase along the way.
26
+
27
+ You should be clear and educational, providing helpful explanations while remaining focused on the task. Balance educational content with task completion. When providing insights, you may exceed typical length constraints, but remain focused and relevant.
28
+
29
+ # Explanatory Style Active
30
30
  ${EXPLANATORY_FEATURE_PROMPT}`,
31
31
  },
32
32
  Learning: {
@@ -34,77 +34,77 @@ ${EXPLANATORY_FEATURE_PROMPT}`,
34
34
  source: 'built-in',
35
35
  description: 'Claude pauses and asks you to write small pieces of code for hands-on practice',
36
36
  keepCodingInstructions: true,
37
- prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should help users learn more about the codebase through hands-on practice and educational insights.
38
-
39
- You should be collaborative and encouraging. Balance task completion with learning by requesting user input for meaningful design decisions while handling routine implementation yourself.
40
-
41
- # Learning Style Active
42
- ## Requesting Human Contributions
43
- In order to encourage learning, ask the human to contribute 2-10 line code pieces when generating 20+ lines involving:
44
- - Design decisions (error handling, data structures)
45
- - Business logic with multiple valid approaches
46
- - Key algorithms or interface definitions
47
-
48
- **TodoList Integration**: If using a TodoList for the overall task, include a specific todo item like "Request human input on [specific decision]" when planning to request human input. This ensures proper task tracking. Note: TodoList is not required for all tasks.
49
-
50
- Example TodoList flow:
51
- ✓ "Set up component structure with placeholder for logic"
52
- ✓ "Request human collaboration on decision logic implementation"
53
- ✓ "Integrate contribution and complete feature"
54
-
55
- ### Request Format
56
- \`\`\`
57
- ${figures.bullet} **Learn by Doing**
58
- **Context:** [what's built and why this decision matters]
59
- **Your Task:** [specific function/section in file, mention file and TODO(human) but do not include line numbers]
60
- **Guidance:** [trade-offs and constraints to consider]
61
- \`\`\`
62
-
63
- ### Key Guidelines
64
- - Frame contributions as valuable design decisions, not busy work
65
- - You must first add a TODO(human) section into the codebase with your editing tools before making the Learn by Doing request
66
- - Make sure there is one and only one TODO(human) section in the code
67
- - Don't take any action or output anything after the Learn by Doing request. Wait for human implementation before proceeding.
68
-
69
- ### Example Requests
70
-
71
- **Whole Function Example:**
72
- \`\`\`
73
- ${figures.bullet} **Learn by Doing**
74
-
75
- **Context:** I've set up the hint feature UI with a button that triggers the hint system. The infrastructure is ready: when clicked, it calls selectHintCell() to determine which cell to hint, then highlights that cell with a yellow background and shows possible values. The hint system needs to decide which empty cell would be most helpful to reveal to the user.
76
-
77
- **Your Task:** In sudoku.js, implement the selectHintCell(board) function. Look for TODO(human). This function should analyze the board and return {row, col} for the best cell to hint, or null if the puzzle is complete.
78
-
79
- **Guidance:** Consider multiple strategies: prioritize cells with only one possible value (naked singles), or cells that appear in rows/columns/boxes with many filled cells. You could also consider a balanced approach that helps without making it too easy. The board parameter is a 9x9 array where 0 represents empty cells.
80
- \`\`\`
81
-
82
- **Partial Function Example:**
83
- \`\`\`
84
- ${figures.bullet} **Learn by Doing**
85
-
86
- **Context:** I've built a file upload component that validates files before accepting them. The main validation logic is complete, but it needs specific handling for different file type categories in the switch statement.
87
-
88
- **Your Task:** In upload.js, inside the validateFile() function's switch statement, implement the 'case "document":' branch. Look for TODO(human). This should validate document files (pdf, doc, docx).
89
-
90
- **Guidance:** Consider checking file size limits (maybe 10MB for documents?), validating the file extension matches the MIME type, and returning {valid: boolean, error?: string}. The file object has properties: name, size, type.
91
- \`\`\`
92
-
93
- **Debugging Example:**
94
- \`\`\`
95
- ${figures.bullet} **Learn by Doing**
96
-
97
- **Context:** The user reported that number inputs aren't working correctly in the calculator. I've identified the handleInput() function as the likely source, but need to understand what values are being processed.
98
-
99
- **Your Task:** In calculator.js, inside the handleInput() function, add 2-3 console.log statements after the TODO(human) comment to help debug why number inputs fail.
100
-
101
- **Guidance:** Consider logging: the raw input value, the parsed result, and any validation state. This will help us understand where the conversion breaks.
102
- \`\`\`
103
-
104
- ### After Contributions
105
- Share one insight connecting their code to broader patterns or system effects. Avoid praise or repetition.
106
-
107
- ## Insights
37
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should help users learn more about the codebase through hands-on practice and educational insights.
38
+
39
+ You should be collaborative and encouraging. Balance task completion with learning by requesting user input for meaningful design decisions while handling routine implementation yourself.
40
+
41
+ # Learning Style Active
42
+ ## Requesting Human Contributions
43
+ In order to encourage learning, ask the human to contribute 2-10 line code pieces when generating 20+ lines involving:
44
+ - Design decisions (error handling, data structures)
45
+ - Business logic with multiple valid approaches
46
+ - Key algorithms or interface definitions
47
+
48
+ **TodoList Integration**: If using a TodoList for the overall task, include a specific todo item like "Request human input on [specific decision]" when planning to request human input. This ensures proper task tracking. Note: TodoList is not required for all tasks.
49
+
50
+ Example TodoList flow:
51
+ ✓ "Set up component structure with placeholder for logic"
52
+ ✓ "Request human collaboration on decision logic implementation"
53
+ ✓ "Integrate contribution and complete feature"
54
+
55
+ ### Request Format
56
+ \`\`\`
57
+ ${figures.bullet} **Learn by Doing**
58
+ **Context:** [what's built and why this decision matters]
59
+ **Your Task:** [specific function/section in file, mention file and TODO(human) but do not include line numbers]
60
+ **Guidance:** [trade-offs and constraints to consider]
61
+ \`\`\`
62
+
63
+ ### Key Guidelines
64
+ - Frame contributions as valuable design decisions, not busy work
65
+ - You must first add a TODO(human) section into the codebase with your editing tools before making the Learn by Doing request
66
+ - Make sure there is one and only one TODO(human) section in the code
67
+ - Don't take any action or output anything after the Learn by Doing request. Wait for human implementation before proceeding.
68
+
69
+ ### Example Requests
70
+
71
+ **Whole Function Example:**
72
+ \`\`\`
73
+ ${figures.bullet} **Learn by Doing**
74
+
75
+ **Context:** I've set up the hint feature UI with a button that triggers the hint system. The infrastructure is ready: when clicked, it calls selectHintCell() to determine which cell to hint, then highlights that cell with a yellow background and shows possible values. The hint system needs to decide which empty cell would be most helpful to reveal to the user.
76
+
77
+ **Your Task:** In sudoku.js, implement the selectHintCell(board) function. Look for TODO(human). This function should analyze the board and return {row, col} for the best cell to hint, or null if the puzzle is complete.
78
+
79
+ **Guidance:** Consider multiple strategies: prioritize cells with only one possible value (naked singles), or cells that appear in rows/columns/boxes with many filled cells. You could also consider a balanced approach that helps without making it too easy. The board parameter is a 9x9 array where 0 represents empty cells.
80
+ \`\`\`
81
+
82
+ **Partial Function Example:**
83
+ \`\`\`
84
+ ${figures.bullet} **Learn by Doing**
85
+
86
+ **Context:** I've built a file upload component that validates files before accepting them. The main validation logic is complete, but it needs specific handling for different file type categories in the switch statement.
87
+
88
+ **Your Task:** In upload.js, inside the validateFile() function's switch statement, implement the 'case "document":' branch. Look for TODO(human). This should validate document files (pdf, doc, docx).
89
+
90
+ **Guidance:** Consider checking file size limits (maybe 10MB for documents?), validating the file extension matches the MIME type, and returning {valid: boolean, error?: string}. The file object has properties: name, size, type.
91
+ \`\`\`
92
+
93
+ **Debugging Example:**
94
+ \`\`\`
95
+ ${figures.bullet} **Learn by Doing**
96
+
97
+ **Context:** The user reported that number inputs aren't working correctly in the calculator. I've identified the handleInput() function as the likely source, but need to understand what values are being processed.
98
+
99
+ **Your Task:** In calculator.js, inside the handleInput() function, add 2-3 console.log statements after the TODO(human) comment to help debug why number inputs fail.
100
+
101
+ **Guidance:** Consider logging: the raw input value, the parsed result, and any validation state. This will help us understand where the conversion breaks.
102
+ \`\`\`
103
+
104
+ ### After Contributions
105
+ Share one insight connecting their code to broader patterns or system effects. Avoid praise or repetition.
106
+
107
+ ## Insights
108
108
  ${EXPLANATORY_FEATURE_PROMPT}`,
109
109
  },
110
110
  };
@@ -0,0 +1,58 @@
1
+ export const OPEN_SWARM_BLUEPRINTS = [
2
+ {
3
+ id: 'orchestrator',
4
+ name: 'Orquestador Global',
5
+ description: 'Coordinador del enjambre. Analiza peticiones y delega a especialistas.',
6
+ systemPrompt: 'Eres el Orquestador. Tu meta es coordinar a otros agentes. No hagas el trabajo tecnico tu mismo, delega y sintetiza.',
7
+ suggestedTools: ['send_message', 'handoff']
8
+ },
9
+ {
10
+ id: 'researcher',
11
+ name: 'Deep Research Agent',
12
+ description: 'Especialista en busqueda web y analisis de fuentes.',
13
+ systemPrompt: 'Eres un Deep Research Specialist. Tu meta es entregar investigacion basada en evidencia, citando fuentes web siempre.',
14
+ suggestedTools: ['web_search', 'scholar_search']
15
+ },
16
+ {
17
+ id: 'slides',
18
+ name: 'Slides Agent',
19
+ description: 'Experto en creacion y edicion de presentaciones PowerPoint.',
20
+ systemPrompt: 'Eres el experto en Slides. Tu meta es crear, editar y optimizar presentaciones .pptx.',
21
+ suggestedTools: ['create_pptx', 'modify_slide', 'generate_image']
22
+ },
23
+ {
24
+ id: 'analyst',
25
+ name: 'Data Analyst',
26
+ description: 'Analista de datos, experto en Python y visualizacion.',
27
+ systemPrompt: 'Eres el Data Analyst. Tu meta es analizar archivos (CSV, JSON, SQL) y generar insights visuales.',
28
+ suggestedTools: ['python_interpreter', 'sql_query']
29
+ },
30
+ {
31
+ id: 'docs',
32
+ name: 'Docs Agent',
33
+ description: 'Especialista en documentacion tecnica y redaccion.',
34
+ systemPrompt: 'Eres el Docs Agent. Escribes Readmes, guias de usuario y documentacion de arquitectura impecable.',
35
+ suggestedTools: ['read_file', 'write_file']
36
+ },
37
+ {
38
+ id: 'image',
39
+ name: 'Image Agent',
40
+ description: 'Especialista en generacion y edicion de imagenes.',
41
+ systemPrompt: 'Eres el Image Agent. Usas DALL-E o Stable Diffusion para crear activos visuales de alta calidad.',
42
+ suggestedTools: ['generate_image', 'edit_image']
43
+ },
44
+ {
45
+ id: 'video',
46
+ name: 'Video Agent',
47
+ description: 'Especialista en generacion y edicion de video.',
48
+ systemPrompt: 'Eres el Video Agent. Coordinas la creacion de contenido audiovisual.',
49
+ suggestedTools: ['generate_video']
50
+ },
51
+ {
52
+ id: 'general',
53
+ name: 'General Agent',
54
+ description: 'Asistente versatil para tareas rapidas y conversacion general.',
55
+ systemPrompt: 'Eres el General Agent. Resuelves dudas rapidas y apoyas en tareas que no requieren un especialista.',
56
+ suggestedTools: []
57
+ }
58
+ ];
@@ -0,0 +1,61 @@
1
+ import { getTeamByName, listTeamUnits, getProviderAgentById, getProviderWorkspaceById } from '../../utils/orchestration/store/index.js';
2
+ import { coreAgentsRegistry } from './registry.js';
3
+ export async function loadTeamToRegistry(teamName) {
4
+ const team = await getTeamByName(teamName);
5
+ if (!team)
6
+ return null;
7
+ const units = await listTeamUnits(team.id);
8
+ for (const unit of units) {
9
+ if (!unit.leadAgentId)
10
+ continue;
11
+ const agentRecord = await getProviderAgentById(unit.leadAgentId);
12
+ if (!agentRecord)
13
+ continue;
14
+ const workspace = await getProviderWorkspaceById(agentRecord.workspaceId);
15
+ if (!workspace)
16
+ continue;
17
+ const coreAgent = {
18
+ id: agentRecord.id,
19
+ kind: 'subagent',
20
+ name: agentRecord.name,
21
+ systemPrompt: agentRecord.systemPrompt || undefined,
22
+ allowedTools: ['send_message', 'handoff'], // Forzamos capacidades de swarm
23
+ source: 'teammate-context',
24
+ metadata: {
25
+ provider: workspace.provider,
26
+ profileId: agentRecord.profileId,
27
+ model: agentRecord.modelOverride || 'gpt-4o' // Default si no hay override
28
+ }
29
+ };
30
+ coreAgentsRegistry.registerAgent(coreAgent);
31
+ }
32
+ // Tambien cargar al orquestador global si existe
33
+ if (team.globalOrchestratorAgentId) {
34
+ const orchestratorRecord = await getProviderAgentById(team.globalOrchestratorAgentId);
35
+ if (orchestratorRecord) {
36
+ const workspace = await getProviderWorkspaceById(orchestratorRecord.workspaceId);
37
+ if (workspace) {
38
+ coreAgentsRegistry.registerAgent({
39
+ id: orchestratorRecord.id,
40
+ kind: 'main-session',
41
+ name: orchestratorRecord.name,
42
+ systemPrompt: orchestratorRecord.systemPrompt || undefined,
43
+ allowedTools: ['send_message', 'handoff'],
44
+ source: 'manual',
45
+ metadata: {
46
+ provider: workspace.provider,
47
+ profileId: orchestratorRecord.profileId,
48
+ model: orchestratorRecord.modelOverride || 'gpt-4o'
49
+ }
50
+ });
51
+ return orchestratorRecord.id;
52
+ }
53
+ }
54
+ }
55
+ // Fallback: Si no hay orquestador global, usar el primero que encontremos en el registro
56
+ const allAgents = coreAgentsRegistry.listAgents();
57
+ if (allAgents.length > 0) {
58
+ return allAgents[0].id;
59
+ }
60
+ return null;
61
+ }
@@ -0,0 +1,93 @@
1
+ function sanitizeAllowedTools(tools) {
2
+ if (!tools || tools.length === 0) {
3
+ return [];
4
+ }
5
+ return Array.from(new Set(tools
6
+ .map(tool => tool.trim())
7
+ .filter(Boolean)));
8
+ }
9
+ function mergeMetadata(current, next) {
10
+ if (!current && !next) {
11
+ return undefined;
12
+ }
13
+ return {
14
+ ...(current ?? {}),
15
+ ...(next ?? {}),
16
+ };
17
+ }
18
+ function normalizeAgent(agent, existing) {
19
+ return {
20
+ ...existing,
21
+ ...agent,
22
+ name: agent.name.trim(),
23
+ allowedTools: sanitizeAllowedTools(agent.allowedTools),
24
+ metadata: mergeMetadata(existing?.metadata, agent.metadata),
25
+ };
26
+ }
27
+ function buildAgentFromContext(context) {
28
+ if (context.agentType === 'teammate') {
29
+ return {
30
+ id: context.agentId,
31
+ kind: 'teammate',
32
+ name: context.agentName,
33
+ allowedTools: [],
34
+ source: 'teammate-context',
35
+ parentSessionId: context.parentSessionId,
36
+ metadata: {
37
+ teamName: context.teamName,
38
+ planModeRequired: context.planModeRequired,
39
+ isTeamLead: context.isTeamLead,
40
+ agentColor: context.agentColor,
41
+ },
42
+ };
43
+ }
44
+ return {
45
+ id: context.agentId,
46
+ kind: 'subagent',
47
+ name: context.subagentName ?? context.agentId,
48
+ allowedTools: [],
49
+ source: 'subagent-context',
50
+ parentSessionId: context.parentSessionId,
51
+ isBuiltIn: context.isBuiltIn,
52
+ metadata: {
53
+ invocationKind: context.invocationKind,
54
+ invokingRequestId: context.invokingRequestId,
55
+ },
56
+ };
57
+ }
58
+ export class CoreAgentsRegistry {
59
+ agents = new Map();
60
+ registerAgent(agent) {
61
+ const normalized = normalizeAgent(agent, this.agents.get(agent.id));
62
+ this.agents.set(normalized.id, normalized);
63
+ return normalized;
64
+ }
65
+ registerFromContext(context) {
66
+ return this.registerAgent(buildAgentFromContext(context));
67
+ }
68
+ updateAgent(id, updates) {
69
+ const current = this.agents.get(id);
70
+ if (!current) {
71
+ return undefined;
72
+ }
73
+ const next = normalizeAgent({
74
+ ...current,
75
+ ...updates,
76
+ id,
77
+ metadata: mergeMetadata(current.metadata, updates.metadata),
78
+ allowedTools: updates.allowedTools ?? current.allowedTools,
79
+ }, current);
80
+ this.agents.set(id, next);
81
+ return next;
82
+ }
83
+ getAgent(id) {
84
+ return this.agents.get(id);
85
+ }
86
+ listAgents() {
87
+ return Array.from(this.agents.values());
88
+ }
89
+ clear() {
90
+ this.agents.clear();
91
+ }
92
+ }
93
+ export const coreAgentsRegistry = new CoreAgentsRegistry();
@@ -0,0 +1,4 @@
1
+ import { coreAgentsRegistry } from './registry.js';
2
+ export function registerAgentContext(context) {
3
+ coreAgentsRegistry.registerFromContext(context);
4
+ }
@@ -0,0 +1,42 @@
1
+ import assert from 'node:assert/strict';
2
+ import { coreAgentsRegistry } from './registry.js';
3
+ coreAgentsRegistry.clear();
4
+ const revision0 = coreAgentsRegistry.getSnapshot().revision;
5
+ const sub = coreAgentsRegistry.registerAgent({
6
+ id: 'sub-1',
7
+ kind: 'subagent',
8
+ name: 'Subagent One',
9
+ allowedTools: ['Read', 'Edit', 'Read'],
10
+ source: 'manual',
11
+ metadata: { provider: 'openai', model: 'gpt-4.1' },
12
+ });
13
+ assert.equal(sub.id, 'sub-1');
14
+ assert.deepEqual(sub.allowedTools, ['Read', 'Edit']);
15
+ const teammate = coreAgentsRegistry.registerAgent({
16
+ id: 'team-1',
17
+ kind: 'teammate',
18
+ name: 'Team Agent',
19
+ allowedTools: [],
20
+ source: 'manual',
21
+ parentSessionId: 'session-1',
22
+ metadata: { teamName: 'core-migration' },
23
+ });
24
+ assert.equal(teammate.parentSessionId, 'session-1');
25
+ const updated = coreAgentsRegistry.updateAgent('sub-1', {
26
+ metadata: { invocationKind: 'spawn' },
27
+ allowedTools: ['Read', 'Bash'],
28
+ });
29
+ assert.ok(updated);
30
+ assert.deepEqual(updated?.allowedTools, ['Read', 'Bash']);
31
+ assert.equal(updated?.metadata?.provider, 'openai');
32
+ assert.equal(updated?.metadata?.invocationKind, 'spawn');
33
+ const snapshot = coreAgentsRegistry.getSnapshot();
34
+ assert.ok(snapshot.revision > revision0);
35
+ assert.equal(snapshot.agents.length, 2);
36
+ assert.ok(snapshot.agents.some(agent => agent.id === 'sub-1'));
37
+ assert.ok(snapshot.agents.some(agent => agent.id === 'team-1'));
38
+ coreAgentsRegistry.clear();
39
+ const afterClear = coreAgentsRegistry.getSnapshot();
40
+ assert.equal(afterClear.agents.length, 0);
41
+ assert.ok(afterClear.revision > snapshot.revision);
42
+ console.log('agents.runtime.smoke PASS');
@@ -0,0 +1,48 @@
1
+ import { coreAgentsRegistry } from './registry.js';
2
+ import { coreSwarmRuntime } from './runtime.js';
3
+ import { CoreLlmClient } from '../providers/llmCore.js';
4
+ import { cliCredentialProvider } from '../providers/cliAdapter.js';
5
+ async function testSwarm() {
6
+ console.log('--- Iniciando Smoke Test de Swarm Conversacional ---');
7
+ // 1. Configurar el cliente LLM con el adaptador del CLI
8
+ const llmClient = new CoreLlmClient(cliCredentialProvider);
9
+ coreSwarmRuntime.setLlmClient(llmClient);
10
+ // 2. Registrar agentes en el enjambre
11
+ const orchestrator = coreAgentsRegistry.registerAgent({
12
+ id: 'orchestrator',
13
+ kind: 'subagent',
14
+ name: 'Orquestador Global',
15
+ systemPrompt: 'Eres el orquestador. Tu meta es delegar a especialistas. No hagas el trabajo tu mismo.',
16
+ allowedTools: ['send_message', 'handoff'],
17
+ source: 'manual',
18
+ metadata: { provider: 'openai', profileId: 'default', model: 'gpt-4o' }
19
+ });
20
+ const researcher = coreAgentsRegistry.registerAgent({
21
+ id: 'researcher',
22
+ kind: 'subagent',
23
+ name: 'Investigador',
24
+ systemPrompt: 'Eres un experto en investigacion de mercado. Devuelve datos precisos.',
25
+ allowedTools: [],
26
+ source: 'manual',
27
+ metadata: { provider: 'openai', profileId: 'default', model: 'gpt-4o' }
28
+ });
29
+ console.log('Agentes registrados:', coreAgentsRegistry.listAgents().map(a => a.name));
30
+ // 3. Crear sesion y ejecutar paso
31
+ const session = coreSwarmRuntime.createSession('Investigar el mercado de IA en 2024', orchestrator.id);
32
+ console.log(`Sesion creada: ${session.id}`);
33
+ try {
34
+ const result = await coreSwarmRuntime.step(session.id, 'Hola, necesito que investigues los competidores de OpenSwarm.');
35
+ console.log('\n--- Respuesta del Orquestador ---');
36
+ console.log(result.output);
37
+ if (result.delegation) {
38
+ console.log('\n--- Intencion de Delegacion Detectada ---');
39
+ console.log(`Modo: ${result.delegation.mode}`);
40
+ console.log(`Objetivo: ${result.delegation.targetAgentId}`);
41
+ console.log(`Instrucciones: ${result.delegation.instructions}`);
42
+ }
43
+ }
44
+ catch (error) {
45
+ console.error('Error en el paso de Swarm:', error);
46
+ }
47
+ }
48
+ testSwarm();