@mndrk/agx 1.4.62 → 1.4.63

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 (98) hide show
  1. package/README.md +40 -0
  2. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/BUILD_ID +1 -1
  3. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-build-manifest.json +68 -68
  4. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-path-routes-manifest.json +14 -14
  5. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/build-manifest.json +2 -2
  6. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/prerender-manifest.json +12 -12
  7. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  8. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.html +2 -2
  9. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.rsc +1 -1
  10. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/audit/route_client-reference-manifest.js +1 -1
  11. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/[...nextauth]/route_client-reference-manifest.js +1 -1
  12. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/daemon-secret/route_client-reference-manifest.js +1 -1
  13. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/device/code/route_client-reference-manifest.js +1 -1
  14. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/device/token/route_client-reference-manifest.js +1 -1
  15. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/refresh/route_client-reference-manifest.js +1 -1
  16. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  17. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/domains/[id]/route_client-reference-manifest.js +1 -1
  18. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/domains/route_client-reference-manifest.js +1 -1
  19. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
  20. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/learnings/route_client-reference-manifest.js +1 -1
  21. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/logs/stream/route_client-reference-manifest.js +1 -1
  22. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  23. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/signal/route_client-reference-manifest.js +1 -1
  24. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/start/route_client-reference-manifest.js +1 -1
  25. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/status/route_client-reference-manifest.js +1 -1
  26. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
  27. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  28. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  29. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/complete/route_client-reference-manifest.js +1 -1
  30. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/route_client-reference-manifest.js +1 -1
  31. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/stage-prompts/route_client-reference-manifest.js +1 -1
  32. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/[commentId]/route_client-reference-manifest.js +1 -1
  33. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/route_client-reference-manifest.js +1 -1
  34. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/costs/route_client-reference-manifest.js +1 -1
  35. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/dependencies/route_client-reference-manifest.js +1 -1
  36. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/heartbeat/route_client-reference-manifest.js +1 -1
  37. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/history/route_client-reference-manifest.js +1 -1
  38. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/route_client-reference-manifest.js +1 -1
  39. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/stream/route_client-reference-manifest.js +1 -1
  40. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/restart-stage/route_client-reference-manifest.js +1 -1
  41. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/route_client-reference-manifest.js +1 -1
  42. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/route.js +1 -1
  43. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/route_client-reference-manifest.js +1 -1
  44. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/stream/route_client-reference-manifest.js +1 -1
  45. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/user-settings/route_client-reference-manifest.js +1 -1
  46. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/[id]/nodes/route_client-reference-manifest.js +1 -1
  47. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/[id]/route_client-reference-manifest.js +1 -1
  48. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
  49. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/callback/route_client-reference-manifest.js +1 -1
  50. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device/page.js +4 -4
  51. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device/page_client-reference-manifest.js +1 -1
  52. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device.html +1 -1
  53. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device.rsc +2 -2
  54. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard/page.js +1 -1
  55. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  56. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard.html +2 -2
  57. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard.rsc +2 -2
  58. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.html +2 -2
  59. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.rsc +1 -1
  60. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login/page_client-reference-manifest.js +1 -1
  61. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login.html +2 -2
  62. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login.rsc +1 -1
  63. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/page_client-reference-manifest.js +1 -1
  64. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  65. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/tasks/page_client-reference-manifest.js +1 -1
  66. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/workflow/page_client-reference-manifest.js +1 -1
  67. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  68. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.html +2 -2
  69. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.rsc +1 -1
  70. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  71. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.html +2 -2
  72. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.rsc +1 -1
  73. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app-paths-manifest.json +14 -14
  74. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/6317.js +1 -1
  75. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/7143.js +1 -1
  76. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/8521.js +1 -1
  77. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/middleware-manifest.json +5 -5
  78. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/404.html +1 -1
  79. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/500.html +1 -1
  80. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages-manifest.json +1 -1
  81. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.js +1 -1
  82. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.json +1 -1
  83. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/auth/device/page-06eeddaf1bb867c3.js +1 -0
  84. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/dashboard/page-6140206ded1cc4ae.js +1 -0
  85. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/worker/index.js +8 -0
  86. package/lib/cli/cloud/prompts.js +35 -133
  87. package/lib/cli/runCli.js +159 -17
  88. package/lib/cli/skillText.js +1 -56
  89. package/lib/cli/templateDefaults.js +22 -0
  90. package/lib/executor.js +8 -40
  91. package/lib/prompts/cloudTask.js +35 -75
  92. package/lib/prompts/templates.js +356 -0
  93. package/package.json +1 -1
  94. package/templates/stack/postgres/init/001_agx_board_schema.sql +17 -0
  95. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/auth/device/page-39c6907dc645eb6f.js +0 -1
  96. package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/dashboard/page-d35f0d29790d06ca.js +0 -1
  97. /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{_knBrbKtV87NnpUclVMJo → o_Dsarly6P4c-yqsBEkNM}/_buildManifest.js +0 -0
  98. /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{_knBrbKtV87NnpUclVMJo → o_Dsarly6P4c-yqsBEkNM}/_ssgManifest.js +0 -0
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable no-console */
2
2
  'use strict';
3
3
 
4
+ const { interpolate, AGGREGATOR_PROMPT, EXECUTE_ITERATION, VERIFY_PROMPT } = require('../../prompts/templates');
5
+
4
6
  function createCloudPromptHelpers(env) {
5
7
  const { path, truncateForPrompt, VERIFY_PROMPT_MAX_CHARS } = env || {};
6
8
 
@@ -49,57 +51,20 @@ function createCloudPromptHelpers(env) {
49
51
  '- artifacts/ (additional artifacts, if any)',
50
52
  ].join('\n');
51
53
 
52
- return `You are the decision aggregator for a ${role} run.
53
-
54
- Task ID: ${taskId}
55
- Title: ${task?.title || taskId}
56
- Stage: ${task?.stage || 'unknown'}
57
-
58
- User Request:
59
- """
60
- ${task?.title}
61
- ${task?.content}
62
- ---
63
- Task Thread:
64
- ${taskComments.map(c => `${c.author}: ${c.content}`).join('\n')}
65
- """
66
-
67
- Stage Objective: ${stagePrompt}
68
- Stage Completion Requirement: ${stageRequirement}
69
-
70
- Local run artifacts folder: ${runRoot || '(not available)'}
71
- Key run files:
72
- ${runFiles}
73
-
74
- Relevant files referenced during execution (detected from output/logs):
75
- ${refsBlock}
76
-
77
- Decide if the task is done. If not, provide the next instruction for another iteration.
78
- Only set "done": true when the Stage Completion Requirement is satisfied.
79
-
80
- You may think through your analysis first, but you MUST end your response with valid JSON.
81
-
82
- Output contract (strict):
83
- - You may include thinking/reasoning at the start of your response
84
- - Your response MUST end with exactly one raw JSON object
85
- - Do not use markdown/code fences/backticks around the JSON
86
- - Do not add commentary after the JSON
87
- - Use double-quoted keys and strings
88
- - Keep newlines escaped inside strings
89
- - If "done" is false, "next_prompt" must be a non-empty actionable instruction
90
-
91
- The final JSON in your response must have this exact shape:
92
- {
93
- "done": false,
94
- "decision": "done|blocked|not_done|failed",
95
- "explanation": "clear explanation of the decision",
96
- "final_result": "final result if done, empty string otherwise",
97
- "next_prompt": "specific actionable instruction for next iteration",
98
- "summary": "brief summary of current state"
99
- }
100
-
101
- If uncertain, still return valid JSON with decision "failed" and explain why in "explanation".
102
- `;
54
+ return interpolate(AGGREGATOR_PROMPT, {
55
+ role,
56
+ taskId,
57
+ title: task?.title || taskId,
58
+ stage: task?.stage || 'unknown',
59
+ taskTitle: task?.title,
60
+ taskContent: task?.content,
61
+ taskComments: taskComments.map(c => `${c.author}: ${c.content}`).join('\n'),
62
+ stagePrompt,
63
+ stageRequirement,
64
+ runRoot: runRoot || '(not available)',
65
+ runFiles,
66
+ refsBlock,
67
+ });
103
68
  }
104
69
 
105
70
  function truncateForPromptLocal(text, maxChars) {
@@ -114,26 +79,10 @@ If uncertain, still return valid JSON with decision "failed" and explain why in
114
79
  ? nextPrompt.trim()
115
80
  : 'Pick the next concrete step and implement it.';
116
81
 
117
- return [
118
- 'EXECUTE PHASE',
119
- `Iteration: ${iteration}`,
120
- '',
121
- 'Keep output concise and avoid dumping full file contents or long logs.',
122
- 'If you need to reference code, cite paths and describe changes instead of pasting whole files.',
123
- '',
124
- 'Output contract:',
125
- '- Start with "PLAN:" then 2-5 bullets.',
126
- '- Do the work.',
127
- '- End with "IMPLEMENTATION SUMMARY:" bullets:',
128
- ' - Changed: (paths only, 10 max)',
129
- ' - Commands: (what you ran)',
130
- ' - Notes:',
131
- '',
132
- `Task for this iteration: ${instruction}`,
133
- '',
134
- 'Do not output JSON in this phase.',
135
- ''
136
- ].join('\n');
82
+ return interpolate(EXECUTE_ITERATION, {
83
+ iteration,
84
+ instruction,
85
+ });
137
86
  }
138
87
 
139
88
  function buildVerifyPrompt({ taskId, task, stagePrompt, stageRequirement, gitSummary, verifyResults, iteration, lastRunPath, agentOutput }) {
@@ -161,68 +110,21 @@ If uncertain, still return valid JSON with decision "failed" and explain why in
161
110
 
162
111
  const runRoot = lastRunPath ? String(lastRunPath) : '';
163
112
 
164
- const prompt = `You are the verifier for an agx run.
165
-
166
- Task ID: ${taskId}
167
- Title: ${title || taskId}
168
- Stage: ${task?.stage || 'unknown'}
169
- Iteration: ${iteration}
170
-
171
- Stage Objective: ${stagePrompt}
172
- Stage Completion Requirement: ${stageRequirement}
173
-
174
- Local run artifacts folder: ${runRoot || '(not available)'}
175
-
176
- User Request:
177
- """
178
- ${title}
179
- ${content}
180
- """
181
-
182
- Target state evidence:
183
- - Before reviewing git status or diff, first ask whether the target state already exists and fully satisfies the user request.
184
- - Check the agent output and verification command logs for evidence (files, folders, config values, summaries) that the desired outcome is already in place, even if the diff is empty.
185
- - If those signals show the target is already achieved and verification commands pass, treat the work as done without requiring new diffs; only rely on git status/diff when the target state is missing or unclear.
186
-
187
- Repo summary (git):
188
- Status (porcelain):
189
- ${statusShort || '(none)'}
190
-
191
- Diff (stat):
192
- ${diffShort || '(none)'}
193
-
194
- Verification commands:
195
- ${cmdLines}
196
-
197
- Agent output (last iteration):
198
- ${agentOutputShort || '(not available)'}
199
-
200
- Decide if the stage is complete. Use verification commands as evidence.
201
- Ignore unrelated working tree changes; focus on whether the user request is satisfied.
202
- If not complete, provide the next smallest instruction for another iteration.
203
- Set "done": true when the user request is satisfied and the evidence supports it. Treat the stage objective/requirement as guidance, not a keyword checklist.
204
-
205
- IMPORTANT: Before you look at the git status/diff, first ask whether the target state already exists and the user request is satisfied. Check the agent output and verification command logs for evidence (files, folders, config values, summaries) that the outcome is already in place, even if the diff is empty. Treat that as "target achieved" and you may mark the stage done without requiring new diffs. Use git status/diff only when the target state is missing or unclear and you need to verify what changed to reach it. If verification commands pass and the evidence shows the desired result already exists, mark the work done.
206
-
207
- Output contract (strict): your response MUST be exactly one raw JSON object with this shape:
208
- {
209
- "done": false,
210
- "decision": "done|blocked|not_done|failed",
211
- "explanation": "clear explanation of the decision",
212
- "final_result": "final result if done, empty string otherwise",
213
- "next_prompt": "specific actionable instruction for next iteration",
214
- "summary": "brief summary of current state",
215
- "plan_md": "PLAN markdown for this iteration (newlines escaped)",
216
- "implementation_summary_md": "IMPLEMENTATION SUMMARY markdown (newlines escaped)",
217
- "verification_md": "VERIFICATION markdown (newlines escaped)"
218
- }
219
-
220
- Rules:
221
- - Use double-quoted keys and strings.
222
- - Keep newlines escaped inside strings (use \\n).
223
- - Keep the markdown fields short and checklist-style.
224
- - Always fill "explanation". For "blocked", include what is blocking and what input/action would unblock. For "failed", include what failed (command/tool/error) and a recovery step.
225
- `;
113
+ const prompt = interpolate(VERIFY_PROMPT, {
114
+ taskId,
115
+ title: title || taskId,
116
+ stage: task?.stage || 'unknown',
117
+ iteration,
118
+ stagePrompt,
119
+ stageRequirement,
120
+ runRoot: runRoot || '(not available)',
121
+ requestTitle: title,
122
+ requestContent: content,
123
+ statusShort: statusShort || '(none)',
124
+ diffShort: diffShort || '(none)',
125
+ cmdLines,
126
+ agentOutputShort: agentOutputShort || '(not available)',
127
+ });
226
128
 
227
129
  return (typeof truncateForPrompt === 'function'
228
130
  ? truncateForPrompt(prompt, VERIFY_PROMPT_MAX_CHARS)
package/lib/cli/runCli.js CHANGED
@@ -102,6 +102,7 @@ const {
102
102
  const { createCloudRunner } = require('./cloud');
103
103
  const daemon = require('./daemon');
104
104
  const { loadTemplate, renderTemplateContent } = require('../templates');
105
+ const { applyTemplateDefaults } = require('./templateDefaults');
105
106
  const { slugify } = require('../storage/paths');
106
107
  const {
107
108
  DAEMON_PID_FILE,
@@ -1343,20 +1344,6 @@ async function checkOnboarding() {
1343
1344
  templateName = args[templateIdx + 1];
1344
1345
  }
1345
1346
 
1346
- // Default provider from config
1347
- if (!provider) {
1348
- const config = loadConfig();
1349
- provider = config?.defaultProvider || 'claude';
1350
- }
1351
- if (template) {
1352
- if (!providerArgProvided && template.provider) {
1353
- provider = template.provider;
1354
- }
1355
- if (!modelArgProvided && template.model) {
1356
- model = template.model;
1357
- }
1358
- }
1359
-
1360
1347
  // Extract goal text (filter out flags)
1361
1348
  const flagsToRemove = [
1362
1349
  '--json',
@@ -1412,6 +1399,18 @@ async function checkOnboarding() {
1412
1399
  }
1413
1400
  }
1414
1401
 
1402
+ const config = loadConfig();
1403
+ const defaults = applyTemplateDefaults({
1404
+ provider,
1405
+ model,
1406
+ template,
1407
+ providerArgProvided,
1408
+ modelArgProvided,
1409
+ defaultProvider: config?.defaultProvider || 'claude',
1410
+ });
1411
+ provider = defaults.provider;
1412
+ model = defaults.model;
1413
+
1415
1414
  try {
1416
1415
  let projectId = null;
1417
1416
  if (projectSlug) {
@@ -1871,7 +1870,7 @@ async function checkOnboarding() {
1871
1870
  }
1872
1871
  }
1873
1872
 
1874
- // agx task ls [-a] (Docker-style namespace)
1873
+ // agx task ls [-a] [search] (Docker-style namespace)
1875
1874
  if ((cmd === 'task' && args[1] === 'ls') || cmd === 'list' || cmd === 'ls' || cmd === 'tasks') {
1876
1875
  const showAll = args.includes('-a') || args.includes('--all');
1877
1876
  const config = loadCloudConfig();
@@ -1880,10 +1879,42 @@ async function checkOnboarding() {
1880
1879
  process.exit(1);
1881
1880
  }
1882
1881
 
1882
+ // Extract search term
1883
+ const flagsToSkip = ['-a', '--all'];
1884
+ const cmdTokens = (cmd === 'task' && args[1] === 'ls') ? ['task', 'ls'] : [cmd];
1885
+ const searchParts = args.filter((arg, i) => {
1886
+ // Skip flags
1887
+ if (arg.startsWith('-')) return false;
1888
+ // Skip command words (simple heuristic: first occurrence of cmd words)
1889
+ // Actually simpler: iterate args, skip known command words at start.
1890
+ return true;
1891
+ });
1892
+
1893
+ // Better extraction:
1894
+ let startIndex = (cmd === 'task' && args[1] === 'ls') ? 2 : 1;
1895
+ let search = '';
1896
+ const searchTerms = [];
1897
+ for (let i = startIndex; i < args.length; i++) {
1898
+ if (!args[i].startsWith('-')) {
1899
+ searchTerms.push(args[i]);
1900
+ }
1901
+ }
1902
+ if (searchTerms.length > 0) {
1903
+ search = searchTerms.join(' ');
1904
+ }
1905
+
1883
1906
  try {
1884
- const { tasks } = await cloudRequest('GET', '/api/tasks');
1907
+ let url = '/api/tasks';
1908
+ if (search) {
1909
+ url += `?search=${encodeURIComponent(search)}`;
1910
+ }
1911
+ const { tasks } = await cloudRequest('GET', url);
1885
1912
  if (tasks.length === 0) {
1886
- console.log(`${c.dim}No tasks in queue${c.reset}`);
1913
+ if (search) {
1914
+ console.log(`${c.dim}No tasks found matching "${search}"${c.reset}`);
1915
+ } else {
1916
+ console.log(`${c.dim}No tasks in queue${c.reset}`);
1917
+ }
1887
1918
  process.exit(0);
1888
1919
  }
1889
1920
 
@@ -2839,6 +2870,117 @@ async function checkOnboarding() {
2839
2870
  process.exit(0);
2840
2871
  }
2841
2872
 
2873
+ // ============================================================
2874
+ // agx feedback - Quick bug reports with context
2875
+ // ============================================================
2876
+ if (cmd === 'feedback') {
2877
+ const readline = require('readline');
2878
+ const { exec, execSync } = require('child_process');
2879
+
2880
+ // Get description from args or prompt
2881
+ let description = args.slice(1).join(' ');
2882
+ if (!description) {
2883
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2884
+ description = await new Promise(resolve => {
2885
+ rl.question(`${c.cyan}What went wrong?${c.reset} `, answer => {
2886
+ rl.close();
2887
+ resolve(answer.trim());
2888
+ });
2889
+ });
2890
+ }
2891
+
2892
+ if (!description) {
2893
+ console.log(`${c.yellow}No description provided. Aborting.${c.reset}`);
2894
+ process.exit(1);
2895
+ }
2896
+
2897
+ console.log(`\n${c.dim}Collecting context...${c.reset}`);
2898
+
2899
+ // Collect system info
2900
+ const version = (() => { try { return require('../../package.json').version; } catch { return 'unknown'; } })();
2901
+ const nodeVersion = process.version;
2902
+ const platform = `${os.platform()} ${os.arch()}`;
2903
+
2904
+ // Collect recent daemon logs (sanitized)
2905
+ let recentLogs = '';
2906
+ const logDir = path.join(os.homedir(), '.agx', 'logs');
2907
+ try {
2908
+ const logFiles = fs.readdirSync(logDir).filter(f => f.endsWith('.log')).sort().reverse();
2909
+ if (logFiles.length > 0) {
2910
+ const latestLog = fs.readFileSync(path.join(logDir, logFiles[0]), 'utf8');
2911
+ const lines = latestLog.split('\n').slice(-30).join('\n');
2912
+ // Sanitize: remove potential secrets, paths with usernames
2913
+ recentLogs = lines
2914
+ .replace(/\/Users\/[^\/\s]+/g, '/Users/***')
2915
+ .replace(/\/home\/[^\/\s]+/g, '/home/***')
2916
+ .replace(/sk-[a-zA-Z0-9]+/g, 'sk-***')
2917
+ .replace(/key["\s:=]+[a-zA-Z0-9]+/gi, 'key=***');
2918
+ }
2919
+ } catch { }
2920
+
2921
+ // Build issue body
2922
+ const issueTitle = description.length > 60 ? description.substring(0, 60) + '...' : description;
2923
+ const issueBody = `## Description
2924
+ ${description}
2925
+
2926
+ ## Environment
2927
+ - **agx version:** ${version}
2928
+ - **Node.js:** ${nodeVersion}
2929
+ - **Platform:** ${platform}
2930
+
2931
+ ## Recent Logs
2932
+ \`\`\`
2933
+ ${recentLogs || 'No logs available'}
2934
+ \`\`\`
2935
+
2936
+ ---
2937
+ *Submitted via \`agx feedback\`*`;
2938
+
2939
+ // Try gh CLI first
2940
+ let ghAvailable = false;
2941
+ try {
2942
+ execSync('gh --version', { stdio: 'ignore' });
2943
+ ghAvailable = true;
2944
+ } catch { }
2945
+
2946
+ const repoUrl = 'https://github.com/ramarlina/agx';
2947
+
2948
+ if (ghAvailable) {
2949
+ console.log(`${c.dim}Using GitHub CLI...${c.reset}`);
2950
+ try {
2951
+ const result = execSync(
2952
+ `gh issue create --repo ramarlina/agx --title "${issueTitle.replace(/"/g, '\\"')}" --body "${issueBody.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`,
2953
+ { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }
2954
+ );
2955
+ console.log(`\n${c.green}✓${c.reset} Issue created: ${result.trim()}`);
2956
+ } catch (err) {
2957
+ console.log(`${c.yellow}GitHub CLI failed, opening browser instead...${c.reset}`);
2958
+ ghAvailable = false;
2959
+ }
2960
+ }
2961
+
2962
+ if (!ghAvailable) {
2963
+ // Fall back to opening browser with pre-filled URL
2964
+ const params = new URLSearchParams({
2965
+ title: issueTitle,
2966
+ body: issueBody,
2967
+ labels: 'bug,user-feedback'
2968
+ });
2969
+ const issueUrl = `${repoUrl}/issues/new?${params.toString()}`;
2970
+
2971
+ const openCmd = os.platform() === 'darwin' ? 'open' : os.platform() === 'win32' ? 'start' : 'xdg-open';
2972
+ try {
2973
+ execSync(`${openCmd} "${issueUrl}"`, { stdio: 'ignore' });
2974
+ console.log(`\n${c.green}✓${c.reset} Opened GitHub issue form in browser`);
2975
+ } catch {
2976
+ console.log(`\n${c.cyan}Open this URL to submit:${c.reset}\n${issueUrl}`);
2977
+ }
2978
+ }
2979
+
2980
+ console.log(`\n${c.dim}Thanks for the feedback! 🙏${c.reset}`);
2981
+ process.exit(0);
2982
+ }
2983
+
2842
2984
  // ============================================================
2843
2985
  // agx telemetry - Manage anonymous usage telemetry
2844
2986
  // ============================================================
@@ -1,60 +1,5 @@
1
1
  // agx skill - instructions for LLMs on how to use agx
2
2
 
3
- const AGX_SKILL = `---
4
- name: agx
5
- description: Task orchestrator for AI agents. Uses cloud API for persistence.
6
- ---
7
-
8
- # agx - AI Agent Task Orchestrator
9
-
10
- agx manages tasks and coordinates AI agents. Uses cloud API for persistence.
11
-
12
- ## Quick Start
13
-
14
- \`\`\`bash
15
- agx -a -p "Build a REST API" # Autonomous: works until done
16
- agx -p "explain this code" # One-shot question
17
- \`\`\`
18
-
19
- ## Task Lifecycle
20
-
21
- \`\`\`bash
22
- agx new "goal" # Create task
23
- agx run [task] # Run a task
24
- agx complete <taskId> # Mark task stage complete
25
- agx status <taskId> # Show detailed info for a specific task
26
- agx status # Show current status
27
- \`\`\`
28
-
29
- ## Checking Tasks
30
-
31
- \`\`\`bash
32
- agx task ls # List tasks
33
- agx task logs <id> [-f] # View/tail task logs
34
- agx task tail <id> # Tail task logs
35
- agx comments tail <id> # Tail task comments
36
- agx logs tail <id> # Tail task logs
37
- agx watch # Watch task updates in real-time (SSE)
38
- \`\`\`
39
-
40
- ## Cloud
41
-
42
- \`\`\`bash
43
- AGX_CLOUD_URL=http://localhost:41741 agx status
44
- AGX_CLOUD_URL=http://localhost:41741 agx task ls
45
- agx daemon start # Start local daemon
46
- \`\`\`
47
-
48
- ## Providers
49
-
50
- claude (c), gemini (g), ollama (o), codex (x)
51
-
52
- ## Key Flags
53
-
54
- -a Autonomous mode (daemon + work until done)
55
- -p Prompt/goal
56
- -y Skip confirmations (implied by -a)
57
- -P, --provider <c|g|o|x> Provider for new task (claude/gemini/ollama/codex)
58
- `;
3
+ const { AGX_SKILL } = require('../prompts/templates');
59
4
 
60
5
  module.exports = { AGX_SKILL };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ function applyTemplateDefaults({
4
+ provider,
5
+ model,
6
+ template,
7
+ providerArgProvided,
8
+ modelArgProvided,
9
+ defaultProvider,
10
+ }) {
11
+ let resolvedProvider = provider;
12
+ if (!providerArgProvided) {
13
+ resolvedProvider = template?.provider || defaultProvider || 'claude';
14
+ }
15
+ let resolvedModel = model;
16
+ if (!modelArgProvided) {
17
+ resolvedModel = template?.model || model;
18
+ }
19
+ return { provider: resolvedProvider, model: resolvedModel };
20
+ }
21
+
22
+ module.exports = { applyTemplateDefaults };
package/lib/executor.js CHANGED
@@ -10,22 +10,7 @@ const fs = require('fs');
10
10
  const path = require('path');
11
11
  const os = require('os');
12
12
  const { commandExists } = require('./proc/commandExists');
13
-
14
- const DEFAULT_STAGE_PROMPT = 'Execute this stage using the latest stage prompt from the cloud task context.';
15
-
16
- const PROJECT_CONTEXT = [
17
- 'AGX orchestrates autonomous AI agents with tasks defined via `agx new` and managed through `agx run`, `agx tasks`, `agx status`, and `agx context` so agents can wake, work, and sleep across sessions.',
18
- 'Task state lives in the cloud API (goal, criteria, progress, learnings) along with the orchestration worker (pg-boss); `agx info`/`agx context` expose structured project metadata.',
19
- 'Quick-start workflow: `agx new "<goal>"`, optionally `agx -a -p "<goal>"` for autonomous execution, then use `agx run`, `agx tasks`, `agx status`, and `agx context` to manage work.',
20
- 'Task management commands include `agx task ls`, `agx task logs`, `agx task stop`, `agx task rm`, `agx complete`, `agx pull`.',
21
- 'Daemon mode runs via `agx daemon start/stop/status/logs` so agents can poll for work continuously.',
22
- 'Providers: `agx claude` (alias `c`), `agx gemini` (alias `g`), and `agx ollama` (alias `o`).',
23
- 'Key flags: `-a/--autonomous`, `-p/--prompt`, `--prompt-file`, `-y/--yolo`, `--continue <task>`.',
24
- 'Key principles: persistent storage, criteria-driven completion, checkpoint often, ask when stuck, learn and adapt.',
25
- 'Agent workflow: orient on saved state, plan, execute, checkpoint, adapt to blockers, and report learnings.',
26
- 'State operations: define objectives via `agx new`, update learnings with `[learn: ...]`, mark completion via `agx complete`, and sync via `agx info`/`agx context`.',
27
- 'Project metadata: attach `--metadata key=value` and `--repo` info so `/api/projects` keeps structured context.',
28
- ].join('\n');
13
+ const { interpolate, DEFAULT_STAGE_PROMPT, PROJECT_CONTEXT, EXECUTOR_PROMPT } = require('./prompts/templates');
29
14
 
30
15
  // Engine configurations
31
16
  const ENGINES = {
@@ -238,30 +223,13 @@ async function executeTask(options) {
238
223
  * Build the full prompt for a stage
239
224
  */
240
225
  function buildPrompt(title, content, stage, stageConfig) {
241
- return `# Task: ${title}
242
-
243
- ## Stage: ${stage}
244
-
245
- ${stageConfig.prompt}
246
-
247
- ## Project Context
248
-
249
- ${PROJECT_CONTEXT}
250
-
251
- ## Task Details
252
-
253
- ${content}
254
-
255
- ## Instructions
256
-
257
- 1. Complete the work for this stage
258
- 2. Use [checkpoint: message] to save progress
259
- 3. Use [learn: insight] to record learnings
260
- 4. Use [done] when stage is complete
261
- 5. Use [blocked: reason] if you need human help
262
-
263
- Focus on this stage only. The task will automatically advance to the next stage when complete.
264
- `;
226
+ return interpolate(EXECUTOR_PROMPT, {
227
+ title,
228
+ stage,
229
+ stagePrompt: stageConfig.prompt,
230
+ projectContext: PROJECT_CONTEXT,
231
+ content,
232
+ });
265
233
  }
266
234
 
267
235
  /**