@myvillage/cli 1.28.1 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agent-runtime/loop.js +42 -4
- package/src/commands/agent-local.js +130 -0
- package/src/index.js +7 -56
- package/src/utils/agent-scaffolder.js +5 -3
- package/src/utils/api.js +1 -50
- package/src/utils/config.js +0 -1
- package/src/utils/formatters.js +0 -180
- package/src/commands/bizreqs.js +0 -941
package/package.json
CHANGED
|
@@ -12,7 +12,8 @@ import { getMCPTools, cleanupMCPClients } from './mcp-client.js';
|
|
|
12
12
|
import { gatherContext } from './context.js';
|
|
13
13
|
import { isWithinActiveHours, getNextCheckInMs } from './scheduler.js';
|
|
14
14
|
import { parse as parseYaml } from 'yaml';
|
|
15
|
-
import { postAgentHeartbeat, listAgentTasks, claimAgentTask, completeAgentTask } from '../utils/api.js';
|
|
15
|
+
import { postAgentHeartbeat, listAgentTasks, claimAgentTask, completeAgentTask, refreshAccessToken } from '../utils/api.js';
|
|
16
|
+
import { getAccessToken, isTokenExpired } from '../utils/auth.js';
|
|
16
17
|
import { readAgentWisdom } from '../utils/wisdom.js';
|
|
17
18
|
|
|
18
19
|
export async function agentLoop(agentName, { signal }) {
|
|
@@ -115,6 +116,29 @@ export async function agentLoop(agentName, { signal }) {
|
|
|
115
116
|
logActivity(agentDir, { type: 'loop_start', iteration });
|
|
116
117
|
updateHeartbeat(agentDir);
|
|
117
118
|
|
|
119
|
+
// Refresh OAuth token and reconnect MCP if the access token rotated.
|
|
120
|
+
// Why: the daemon is started with a snapshot of MYVILLAGE_ACCESS_TOKEN in
|
|
121
|
+
// env (see agent-local.js). The MCP client baked that token into its
|
|
122
|
+
// Authorization header at construction time and has no refresh path of
|
|
123
|
+
// its own — so once the OAuth token expires (~1h) every MCP tool call
|
|
124
|
+
// 401s until the daemon is restarted. Re-read credentials each loop and
|
|
125
|
+
// swap the MCP client when the token changes.
|
|
126
|
+
try {
|
|
127
|
+
if (isTokenExpired()) {
|
|
128
|
+
await refreshAccessToken();
|
|
129
|
+
}
|
|
130
|
+
const currentToken = getAccessToken();
|
|
131
|
+
if (currentToken && currentToken !== process.env.MYVILLAGE_ACCESS_TOKEN) {
|
|
132
|
+
process.env.MYVILLAGE_ACCESS_TOKEN = currentToken;
|
|
133
|
+
await cleanupMCPClients();
|
|
134
|
+
const refreshed = await getMCPTools(agentDir, config);
|
|
135
|
+
tools = refreshed.tools;
|
|
136
|
+
logActivity(agentDir, { type: 'mcp_reconnected', reason: 'token rotated' });
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
logActivity(agentDir, { type: 'error', error: `Token refresh / MCP reconnect failed: ${err.message}` });
|
|
140
|
+
}
|
|
141
|
+
|
|
118
142
|
// Activity counters for this iteration
|
|
119
143
|
const activity = {
|
|
120
144
|
postsCreated: 0,
|
|
@@ -335,16 +359,30 @@ Guidelines:
|
|
|
335
359
|
// whether the action tools actually succeeded — not on the model's
|
|
336
360
|
// self-report. The LLM sometimes claims "I posted!" after a tool error.
|
|
337
361
|
if (activeTask && config.man?.village_agent_id) {
|
|
362
|
+
// Three independent failure signals:
|
|
363
|
+
// 1. action tools tried and all failed (original signal — still right)
|
|
364
|
+
// 2. any tool errored AND no action tool succeeded (e.g. an
|
|
365
|
+
// MCP/auth error during discovery means the LLM never got to
|
|
366
|
+
// call an action tool — older versions marked these COMPLETED)
|
|
367
|
+
// 3. the LLM explicitly declared failure in its final text
|
|
368
|
+
// (matches the `**Task Failed:` sentinel the model emits when
|
|
369
|
+
// it gives up after repeated tool errors)
|
|
370
|
+
const llmDeclaredFailure = /^\s*\*\*Task Failed/i.test(result.text || '');
|
|
371
|
+
const hasToolErrors = taskActionAudit.toolErrors.length > 0;
|
|
338
372
|
const shouldFail =
|
|
339
|
-
taskActionAudit.actionToolsCalled > 0 &&
|
|
340
|
-
taskActionAudit.actionToolsSucceeded === 0
|
|
373
|
+
(taskActionAudit.actionToolsCalled > 0 && taskActionAudit.actionToolsSucceeded === 0) ||
|
|
374
|
+
(hasToolErrors && taskActionAudit.actionToolsSucceeded === 0) ||
|
|
375
|
+
llmDeclaredFailure;
|
|
341
376
|
|
|
342
377
|
try {
|
|
343
378
|
if (shouldFail) {
|
|
344
379
|
const firstError = taskActionAudit.toolErrors[0];
|
|
380
|
+
const firstLine = (result.text || '').split('\n').find(l => l.trim()) || '';
|
|
345
381
|
const errorMessage = firstError
|
|
346
382
|
? `${firstError.tool} failed: ${firstError.message}`
|
|
347
|
-
:
|
|
383
|
+
: llmDeclaredFailure
|
|
384
|
+
? firstLine.replace(/^\*\*|\*\*$/g, '').slice(0, 300) || 'Agent declared task failed'
|
|
385
|
+
: 'Action tools called but all failed';
|
|
348
386
|
await completeAgentTask(config.man.village_agent_id, activeTask.id, {
|
|
349
387
|
errorMessage,
|
|
350
388
|
output: {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
agentJoinCommunity as apiAgentJoinCommunity,
|
|
14
14
|
listCommunities,
|
|
15
15
|
getAgentActivity,
|
|
16
|
+
listMyAgents,
|
|
16
17
|
listMyUnlinkedAgentProfiles,
|
|
17
18
|
createVillageAgent as apiCreateVillageAgent,
|
|
18
19
|
listAgentTasks,
|
|
@@ -122,6 +123,7 @@ export async function agentCreateLocalCommand() {
|
|
|
122
123
|
{ name: 'Gmail', value: 'gmail' },
|
|
123
124
|
{ name: 'Calendar', value: 'calendar' },
|
|
124
125
|
{ name: 'GitHub', value: 'github' },
|
|
126
|
+
{ name: 'Browser (Puppeteer — downloads Chromium on first run)', value: 'browser' },
|
|
125
127
|
],
|
|
126
128
|
},
|
|
127
129
|
{
|
|
@@ -230,6 +232,26 @@ export async function agentStartCommand(name) {
|
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
if (!agentExists(name)) {
|
|
235
|
+
// Check whether the agent exists server-side under this handle. If so,
|
|
236
|
+
// this is a "different machine" situation \u2014 point them at `agent pull`
|
|
237
|
+
// rather than the misleading "not found" dead-end.
|
|
238
|
+
let remoteMatch = null;
|
|
239
|
+
try {
|
|
240
|
+
remoteMatch = await fetchMyAgentByHandle(name);
|
|
241
|
+
} catch {
|
|
242
|
+
// network error \u2014 fall through to the generic message below
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (remoteMatch) {
|
|
246
|
+
console.log(chalk.yellow(
|
|
247
|
+
` Agent "${name}" exists on the server but isn't set up on this machine yet.`,
|
|
248
|
+
));
|
|
249
|
+
console.log(chalk.yellow(
|
|
250
|
+
` Run ${brand.gold(`myvillage agent pull ${name}`)} to scaffold it locally, then start it.\n`,
|
|
251
|
+
));
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
233
255
|
console.log(chalk.red(` \u2717 Agent "${name}" not found. Run 'myvillage agent' to see your agents.\n`));
|
|
234
256
|
return;
|
|
235
257
|
}
|
|
@@ -1108,3 +1130,111 @@ export async function agentRememberCommand(name, text, options = {}) {
|
|
|
1108
1130
|
console.log(chalk.red(` ✗ Remember failed: ${msg}\n`));
|
|
1109
1131
|
}
|
|
1110
1132
|
}
|
|
1133
|
+
|
|
1134
|
+
// ── Pull Agent ─────────────────────────────────────────
|
|
1135
|
+
//
|
|
1136
|
+
// Rehydrate a local agent directory on a new machine from the server's
|
|
1137
|
+
// AgentProfile + VillageAgent records. Use case: you created `teacher_mvp`
|
|
1138
|
+
// on your laptop, now you want to run it on your desktop. The server
|
|
1139
|
+
// already has the agent — this command scaffolds the missing local config
|
|
1140
|
+
// (~/.myvillage/agents/<handle>/) so `agent start` can launch the daemon.
|
|
1141
|
+
//
|
|
1142
|
+
// What pulls down: the network identity (id, handle, displayName) and a
|
|
1143
|
+
// link to the existing VillageAgent task queue.
|
|
1144
|
+
// What doesn't: custom prompt edits, tools.yaml customizations, and any
|
|
1145
|
+
// API keys. Those stay machine-local and you'll need to redo them if you
|
|
1146
|
+
// want an exact replica. The scaffold defaults are a reasonable starting
|
|
1147
|
+
// point that will boot.
|
|
1148
|
+
|
|
1149
|
+
async function fetchMyAgentByHandle(handle) {
|
|
1150
|
+
const result = await listMyAgents({ includeVillageAgent: true });
|
|
1151
|
+
const agents = result.data || result;
|
|
1152
|
+
if (!Array.isArray(agents)) return null;
|
|
1153
|
+
return agents.find(a => a.handle === handle) || null;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
export async function agentPullCommand(handle, options = {}) {
|
|
1157
|
+
if (!isAuthenticated()) {
|
|
1158
|
+
console.log(chalk.red(' ✗ Authentication required. Run \'myvillage login\' first.'));
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// The local agent dir is keyed off the handle (= server-side AgentProfile.handle).
|
|
1163
|
+
const agentName = handle;
|
|
1164
|
+
const force = options.force === true;
|
|
1165
|
+
|
|
1166
|
+
if (agentExists(agentName) && !force) {
|
|
1167
|
+
console.log(chalk.yellow(
|
|
1168
|
+
` Agent "${agentName}" already exists locally at ~/.myvillage/agents/${agentName}/`,
|
|
1169
|
+
));
|
|
1170
|
+
console.log(chalk.yellow(' Use --force to overwrite, or just `myvillage agent start ' + agentName + '` to run it.\n'));
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
const spinner = villageSpinner(`Pulling ${handle} from the network...`).start();
|
|
1175
|
+
|
|
1176
|
+
let profile;
|
|
1177
|
+
try {
|
|
1178
|
+
profile = await fetchMyAgentByHandle(handle);
|
|
1179
|
+
} catch (err) {
|
|
1180
|
+
spinner.fail(`Failed to look up agent: ${err.response?.data?.error || err.message}`);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
if (!profile) {
|
|
1185
|
+
spinner.fail(`No agent with handle "${handle}" is owned by your account.`);
|
|
1186
|
+
console.log(chalk.yellow(
|
|
1187
|
+
' Run `myvillage agent` to see the agents on your account, then pull one by its handle.\n',
|
|
1188
|
+
));
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// Default scaffold: just the always-on MyVillage MCP tool. Users can add
|
|
1193
|
+
// more via `agent add-tool` once they're up.
|
|
1194
|
+
const agentDir = getAgentDir(agentName);
|
|
1195
|
+
try {
|
|
1196
|
+
scaffoldAgent(agentDir, {
|
|
1197
|
+
name: agentName,
|
|
1198
|
+
displayName: profile.displayName || agentName,
|
|
1199
|
+
description: profile.bio || `Pulled from the network on ${new Date().toISOString().split('T')[0]}.`,
|
|
1200
|
+
tools: ['myvillage'],
|
|
1201
|
+
checkInInterval: 'hourly',
|
|
1202
|
+
provider: 'anthropic',
|
|
1203
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
1204
|
+
});
|
|
1205
|
+
} catch (err) {
|
|
1206
|
+
spinner.fail(`Failed to scaffold local agent: ${err.message}`);
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// Prefill man.agent_id and man.village_agent_id so `start` skips the
|
|
1211
|
+
// create-on-first-boot step and links straight to the existing server rows.
|
|
1212
|
+
const cfg = readAgentConfig(agentName);
|
|
1213
|
+
cfg.man = cfg.man || {};
|
|
1214
|
+
cfg.man.agent_id = profile.id;
|
|
1215
|
+
cfg.man.handle = profile.handle;
|
|
1216
|
+
if (profile.villageAgent?.id) {
|
|
1217
|
+
cfg.man.village_agent_id = profile.villageAgent.id;
|
|
1218
|
+
}
|
|
1219
|
+
writeAgentConfig(agentName, cfg);
|
|
1220
|
+
|
|
1221
|
+
spinner.succeed(`Pulled ${handle} to ~/.myvillage/agents/${agentName}/`);
|
|
1222
|
+
|
|
1223
|
+
console.log('');
|
|
1224
|
+
console.log(brand.teal(' What pulled down:'));
|
|
1225
|
+
console.log(` - Network identity: @${profile.handle} (${profile.displayName})`);
|
|
1226
|
+
if (profile.villageAgent?.id) {
|
|
1227
|
+
console.log(` - VillageAgent task queue: ${profile.villageAgent.id}`);
|
|
1228
|
+
} else {
|
|
1229
|
+
console.log(` - ${chalk.yellow('No VillageAgent shim found — one will be created on first start.')}`);
|
|
1230
|
+
}
|
|
1231
|
+
console.log('');
|
|
1232
|
+
console.log(brand.teal(' Defaults that may need tweaking:'));
|
|
1233
|
+
console.log(` - ${brand.gold('prompt.md')} (system prompt — generic template)`);
|
|
1234
|
+
console.log(` - ${brand.gold('tools.yaml')} (only the MyVillage tool is enabled)`);
|
|
1235
|
+
console.log(` - ${brand.gold('agent.config.yaml')} (anthropic + claude-sonnet by default)`);
|
|
1236
|
+
console.log('');
|
|
1237
|
+
console.log(brand.teal(' Next:'));
|
|
1238
|
+
console.log(` ${brand.gold(`myvillage agent edit ${agentName}`)} Customize prompt / tools`);
|
|
1239
|
+
console.log(` ${brand.gold(`myvillage agent start ${agentName}`)} Launch the daemon\n`);
|
|
1240
|
+
}
|
package/src/index.js
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
agentStopCommand,
|
|
56
56
|
agentStatusCommand,
|
|
57
57
|
agentLogsCommand,
|
|
58
|
+
agentPullCommand,
|
|
58
59
|
agentAddToolCommand,
|
|
59
60
|
agentRemoveToolCommand,
|
|
60
61
|
agentTaskListCommand,
|
|
@@ -78,13 +79,6 @@ import {
|
|
|
78
79
|
agentDeactivateClientCommand,
|
|
79
80
|
agentRotateClientKeyCommand,
|
|
80
81
|
} from './commands/agent-client.js';
|
|
81
|
-
import {
|
|
82
|
-
bizreqsNewCommand,
|
|
83
|
-
bizreqsSpecCommand,
|
|
84
|
-
bizreqsListCommand,
|
|
85
|
-
bizreqsStatusCommand,
|
|
86
|
-
bizreqsImportCommand,
|
|
87
|
-
} from './commands/bizreqs.js';
|
|
88
82
|
import {
|
|
89
83
|
gameUpdateCommand,
|
|
90
84
|
gameUploadThumbnailCommand,
|
|
@@ -447,6 +441,12 @@ export function run() {
|
|
|
447
441
|
.description('Start a local agent daemon')
|
|
448
442
|
.action(agentStartCommand);
|
|
449
443
|
|
|
444
|
+
agentCmd
|
|
445
|
+
.command('pull <handle>')
|
|
446
|
+
.description('Rehydrate a local agent dir on a new machine from the server')
|
|
447
|
+
.option('--force', 'Overwrite an existing local agent dir')
|
|
448
|
+
.action(agentPullCommand);
|
|
449
|
+
|
|
450
450
|
agentCmd
|
|
451
451
|
.command('stop <name>')
|
|
452
452
|
.description('Stop a local agent daemon')
|
|
@@ -645,55 +645,6 @@ export function run() {
|
|
|
645
645
|
.description('Show status of a reel draft')
|
|
646
646
|
.action(mediaDraftStatusCommand);
|
|
647
647
|
|
|
648
|
-
// ── BizReqs: Business Requirements Pipeline ───────────
|
|
649
|
-
|
|
650
|
-
const bizreqsCmd = program
|
|
651
|
-
.command('bizreqs')
|
|
652
|
-
.description('Business requirements intake and project pipeline');
|
|
653
|
-
|
|
654
|
-
bizreqsCmd
|
|
655
|
-
.command('new')
|
|
656
|
-
.description('Start a new AI-guided business intake session')
|
|
657
|
-
.option('--org <name>', 'Organization name')
|
|
658
|
-
.option('--contact <name>', 'Contact name')
|
|
659
|
-
.option('--from-file <path>', 'Path to a text file with initial context')
|
|
660
|
-
.option('--from-url <url>', 'URL to the organization\'s website')
|
|
661
|
-
.option('--quick', 'Shortened flow (skip dream state, fewer exchanges)')
|
|
662
|
-
.action(bizreqsNewCommand);
|
|
663
|
-
|
|
664
|
-
bizreqsCmd
|
|
665
|
-
.command('spec <id>')
|
|
666
|
-
.description('Generate full project specification from an intake')
|
|
667
|
-
.option('--detail <level>', 'Detail level: brief, standard, comprehensive', 'standard')
|
|
668
|
-
.option('--output <dir>', 'Output directory for spec file', './specs')
|
|
669
|
-
.action(bizreqsSpecCommand);
|
|
670
|
-
|
|
671
|
-
bizreqsCmd
|
|
672
|
-
.command('list')
|
|
673
|
-
.description('List pipeline submissions')
|
|
674
|
-
.option('--status <status>', 'Filter: new, in-review, spec-ready, assigned, in-progress, delivered')
|
|
675
|
-
.option('--city <city>', 'Filter by city')
|
|
676
|
-
.option('--search <query>', 'Search by org name, solution, or ID')
|
|
677
|
-
.option('--sort <sort>', 'Sort: newest, oldest, priority', 'newest')
|
|
678
|
-
.option('-n, --limit <number>', 'Number of results', '50')
|
|
679
|
-
.option('--offset <number>', 'Pagination offset', '0')
|
|
680
|
-
.option('--json', 'Output raw JSON')
|
|
681
|
-
.action(bizreqsListCommand);
|
|
682
|
-
|
|
683
|
-
bizreqsCmd
|
|
684
|
-
.command('status <id>')
|
|
685
|
-
.description('Check project status')
|
|
686
|
-
.action(bizreqsStatusCommand);
|
|
687
|
-
|
|
688
|
-
bizreqsCmd
|
|
689
|
-
.command('import')
|
|
690
|
-
.description('Import requirements from a file or URL')
|
|
691
|
-
.option('--file <path>', 'Path to .txt or .md file')
|
|
692
|
-
.option('--url <url>', 'URL to fetch content from')
|
|
693
|
-
.option('--org <name>', 'Organization name')
|
|
694
|
-
.option('--contact <name>', 'Contact name')
|
|
695
|
-
.action(bizreqsImportCommand);
|
|
696
|
-
|
|
697
648
|
// ── SoulPrint Studio: Model Training Pipeline ───────────
|
|
698
649
|
|
|
699
650
|
// \u2500\u2500 Wisdom: agent skill packs (Books of Wisdom) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -38,9 +38,11 @@ const TOOL_CATALOG = {
|
|
|
38
38
|
env: { GITHUB_TOKEN: '${GITHUB_TOKEN}' },
|
|
39
39
|
description: 'GitHub repository access',
|
|
40
40
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
browser: {
|
|
42
|
+
command: 'npx',
|
|
43
|
+
args: ['-y', '@modelcontextprotocol/server-puppeteer'],
|
|
44
|
+
description: 'Navigate web pages, extract content (downloads Chromium on first run)',
|
|
45
|
+
},
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
export { TOOL_CATALOG };
|
package/src/utils/api.js
CHANGED
|
@@ -50,7 +50,7 @@ export function createClient(baseURL) {
|
|
|
50
50
|
return client;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
async function refreshAccessToken() {
|
|
53
|
+
export async function refreshAccessToken() {
|
|
54
54
|
const config = getConfig();
|
|
55
55
|
const creds = loadCredentials();
|
|
56
56
|
|
|
@@ -456,55 +456,6 @@ export async function rotateClientAgentKey(configId) {
|
|
|
456
456
|
return response.data;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
// ── BizReqs API Client (/api/bizreqs) ───────────────────
|
|
460
|
-
|
|
461
|
-
export function getBizReqsClient() {
|
|
462
|
-
const config = getConfig();
|
|
463
|
-
return createClient(config.bizreqsBaseUrl);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
export async function createBizReqsSubmission(data) {
|
|
467
|
-
const client = getBizReqsClient();
|
|
468
|
-
const response = await client.post('/', data);
|
|
469
|
-
return response.data;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
export async function listBizReqsSubmissions(params = {}) {
|
|
473
|
-
const client = getBizReqsClient();
|
|
474
|
-
const response = await client.get('/', { params });
|
|
475
|
-
return response.data;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
export async function getBizReqsSubmission(id) {
|
|
479
|
-
const client = getBizReqsClient();
|
|
480
|
-
const response = await client.get(`/${encodeURIComponent(id)}`);
|
|
481
|
-
return response.data;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
export async function updateBizReqsSubmission(id, data) {
|
|
485
|
-
const client = getBizReqsClient();
|
|
486
|
-
const response = await client.patch(`/${encodeURIComponent(id)}`, data);
|
|
487
|
-
return response.data;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
export async function getBizReqsStatus(id) {
|
|
491
|
-
const client = getBizReqsClient();
|
|
492
|
-
const response = await client.get(`/${encodeURIComponent(id)}/status`);
|
|
493
|
-
return response.data;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
export async function saveBizReqsSpec(id, data) {
|
|
497
|
-
const client = getBizReqsClient();
|
|
498
|
-
const response = await client.post(`/${encodeURIComponent(id)}/spec`, data);
|
|
499
|
-
return response.data;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
export async function getBizReqsSpec(id) {
|
|
503
|
-
const client = getBizReqsClient();
|
|
504
|
-
const response = await client.get(`/${encodeURIComponent(id)}/spec`);
|
|
505
|
-
return response.data;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
459
|
// ── Media Drafts API (/api/media/drafts) ────────────────
|
|
509
460
|
|
|
510
461
|
export async function createMediaDraft(data) {
|
package/src/utils/config.js
CHANGED
|
@@ -8,7 +8,6 @@ const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
|
8
8
|
const DEFAULT_CONFIG = {
|
|
9
9
|
apiBaseUrl: 'https://portal.myvillageproject.ai/api/v1',
|
|
10
10
|
networkBaseUrl: 'https://portal.myvillageproject.ai/api/network',
|
|
11
|
-
bizreqsBaseUrl: 'https://portal.myvillageproject.ai/api/bizreqs',
|
|
12
11
|
oauthBaseUrl: 'https://portal.myvillageproject.ai/api/oauth',
|
|
13
12
|
soulprintBaseUrl: 'https://soulprint-studio.myvillageproject.ai/api',
|
|
14
13
|
platformBaseUrl: 'https://portal.myvillageproject.ai/api',
|
package/src/utils/formatters.js
CHANGED
|
@@ -630,186 +630,6 @@ export function formatSearchResults(results) {
|
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
|
|
633
|
-
// ── BizReqs Formatting ─────────────────────────────────
|
|
634
|
-
|
|
635
|
-
const BIZREQS_STATUS_COLORS = {
|
|
636
|
-
NEW: chalk.cyan,
|
|
637
|
-
IN_REVIEW: chalk.yellow,
|
|
638
|
-
SPEC_READY: chalk.green,
|
|
639
|
-
ASSIGNED: chalk.blue,
|
|
640
|
-
IN_PROGRESS: chalk.magenta,
|
|
641
|
-
DELIVERED: chalk.greenBright,
|
|
642
|
-
CANCELLED: chalk.red,
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
const BIZREQS_PRIORITY_COLORS = {
|
|
646
|
-
LOW: chalk.dim,
|
|
647
|
-
MEDIUM: chalk.white,
|
|
648
|
-
HIGH: chalk.yellow,
|
|
649
|
-
URGENT: chalk.red,
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
export function formatBizReqsList(submissions) {
|
|
653
|
-
if (!submissions || submissions.length === 0) {
|
|
654
|
-
console.log(chalk.dim('\n No submissions found.\n'));
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
console.log('');
|
|
659
|
-
console.log(
|
|
660
|
-
` ${brand.teal(padRight('ID', 16))}${padRight('Organization', 30)}${padRight('Solution', 20)}${padRight('Submitted', 12)}${padRight('Complexity', 12)}Status`
|
|
661
|
-
);
|
|
662
|
-
console.log(brand.darkGold(` ${'\u2500'.repeat(14)} ${'\u2500'.repeat(28)} ${'\u2500'.repeat(18)} ${'\u2500'.repeat(10)} ${'\u2500'.repeat(10)} ${'\u2500'.repeat(12)}`));
|
|
663
|
-
|
|
664
|
-
for (const s of submissions) {
|
|
665
|
-
const id = chalk.cyan(padRight(s.submissionId, 16));
|
|
666
|
-
const org = padRight(truncate(s.organizationName, 28), 30);
|
|
667
|
-
const solution = padRight(truncate(s.solutionName || '—', 18), 20);
|
|
668
|
-
const date = padRight(relativeTime(s.createdAt), 12);
|
|
669
|
-
const complexity = padRight(s.overallComplexity || '—', 12);
|
|
670
|
-
const statusFn = BIZREQS_STATUS_COLORS[s.status] || chalk.white;
|
|
671
|
-
const status = statusFn(s.status.replace('_', ' '));
|
|
672
|
-
console.log(` ${id}${org}${solution}${date}${complexity}${status}`);
|
|
673
|
-
}
|
|
674
|
-
console.log('');
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
export function formatBizReqsStatusCounts(counts) {
|
|
678
|
-
if (!counts || Object.keys(counts).length === 0) return;
|
|
679
|
-
|
|
680
|
-
const parts = [];
|
|
681
|
-
const order = ['NEW', 'IN_REVIEW', 'SPEC_READY', 'ASSIGNED', 'IN_PROGRESS', 'DELIVERED'];
|
|
682
|
-
for (const status of order) {
|
|
683
|
-
if (counts[status]) {
|
|
684
|
-
const colorFn = BIZREQS_STATUS_COLORS[status] || chalk.white;
|
|
685
|
-
parts.push(colorFn(`${counts[status]} ${status.toLowerCase().replace('_', ' ')}`));
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
if (parts.length > 0) {
|
|
689
|
-
console.log(` ${parts.join(chalk.dim(' | '))}\n`);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
export function formatBizReqsStatus(data) {
|
|
694
|
-
const lines = [];
|
|
695
|
-
|
|
696
|
-
lines.push('');
|
|
697
|
-
const statusFn = BIZREQS_STATUS_COLORS[data.status] || chalk.white;
|
|
698
|
-
lines.push(` ${chalk.bold(data.submissionId)} ${chalk.dim('·')} ${statusFn(data.status.replace('_', ' '))}`);
|
|
699
|
-
lines.push(` ${brand.darkGold('\u2500'.repeat(50))}`);
|
|
700
|
-
lines.push('');
|
|
701
|
-
lines.push(` ${chalk.dim('Organization:')} ${data.organizationName}`);
|
|
702
|
-
|
|
703
|
-
if (data.solutionName) {
|
|
704
|
-
lines.push(` ${chalk.dim('Solution:')} ${data.solutionName}`);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
if (data.overallComplexity) {
|
|
708
|
-
lines.push(` ${chalk.dim('Complexity:')} ${data.overallComplexity}`);
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if (data.estimatedTimeline) {
|
|
712
|
-
lines.push(` ${chalk.dim('Timeline:')} ${data.estimatedTimeline}`);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
const priorityFn = BIZREQS_PRIORITY_COLORS[data.priority] || chalk.white;
|
|
716
|
-
lines.push(` ${chalk.dim('Priority:')} ${priorityFn(data.priority)}`);
|
|
717
|
-
|
|
718
|
-
if (data.components && Array.isArray(data.components) && data.components.length > 0) {
|
|
719
|
-
lines.push('');
|
|
720
|
-
lines.push(` ${chalk.dim('Components:')}`);
|
|
721
|
-
for (const comp of data.components) {
|
|
722
|
-
const name = comp.name || comp;
|
|
723
|
-
const type = comp.type ? chalk.dim(` (${comp.type})`) : '';
|
|
724
|
-
lines.push(` ${chalk.dim('•')} ${name}${type}`);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
lines.push('');
|
|
729
|
-
lines.push(` ${chalk.dim('Spec:')} ${data.hasSpec ? chalk.green('Generated') + chalk.dim(` (${formatDate(data.specGeneratedAt)})`) : chalk.dim('Not yet')}`);
|
|
730
|
-
lines.push(` ${chalk.dim('Submitted:')} ${formatDate(data.createdAt)}`);
|
|
731
|
-
if (data.reviewedAt) {
|
|
732
|
-
lines.push(` ${chalk.dim('Reviewed:')} ${formatDate(data.reviewedAt)}`);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
lines.push('');
|
|
736
|
-
console.log(lines.join('\n'));
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
export function formatRecommendationBox(rec) {
|
|
740
|
-
const lines = [];
|
|
741
|
-
const width = 65;
|
|
742
|
-
const bdr = '\u2500'.repeat(width);
|
|
743
|
-
const b = brand.darkGold;
|
|
744
|
-
|
|
745
|
-
lines.push('');
|
|
746
|
-
lines.push(` ${b('\u250C' + bdr + '\u2510')}`);
|
|
747
|
-
lines.push(` ${b('\u2502')} ${brand.gold(chalk.bold(`RECOMMENDED SOLUTION: ${rec.solutionName}`)).padEnd(width - 1)}${b('\u2502')}`);
|
|
748
|
-
if (rec.organizationName) {
|
|
749
|
-
lines.push(` ${b('\u2502')} ${brand.teal(`For: ${rec.organizationName}`).padEnd(width - 1)}${b('\u2502')}`);
|
|
750
|
-
}
|
|
751
|
-
lines.push(` ${b('\u251C' + bdr + '\u2524')}`);
|
|
752
|
-
lines.push(` ${b('\u2502')}${' '.repeat(width + 1)}${b('\u2502')}`);
|
|
753
|
-
|
|
754
|
-
if (rec.components && Array.isArray(rec.components)) {
|
|
755
|
-
for (let i = 0; i < rec.components.length; i++) {
|
|
756
|
-
const comp = rec.components[i];
|
|
757
|
-
const icon = comp.type === 'portal' ? '\uD83D\uDCF1'
|
|
758
|
-
: comp.type === 'game' ? '\uD83C\uDFAE'
|
|
759
|
-
: comp.type === 'agent' ? '\uD83E\uDD16'
|
|
760
|
-
: comp.type === 'feed' ? '\uD83D\uDCCA'
|
|
761
|
-
: comp.type === 'model' ? '\uD83E\uDDE0'
|
|
762
|
-
: comp.type === 'voice' ? '\uD83C\uDFA4'
|
|
763
|
-
: '\uD83D\uDCE6';
|
|
764
|
-
|
|
765
|
-
const compLine = ` ${icon} Component ${i + 1}: ${comp.name}`;
|
|
766
|
-
lines.push(` ${b('\u2502')} ${brand.cream(compLine).padEnd(width - 1)}${b('\u2502')}`);
|
|
767
|
-
|
|
768
|
-
if (comp.description) {
|
|
769
|
-
const descWords = comp.description.split(' ');
|
|
770
|
-
let currentLine = ' ';
|
|
771
|
-
for (const word of descWords) {
|
|
772
|
-
if (currentLine.length + word.length + 1 > width - 4) {
|
|
773
|
-
lines.push(` ${b('\u2502')} ${brand.teal(currentLine).padEnd(width - 1)}${b('\u2502')}`);
|
|
774
|
-
currentLine = ' ' + word;
|
|
775
|
-
} else {
|
|
776
|
-
currentLine += (currentLine.length > 5 ? ' ' : '') + word;
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
if (currentLine.trim()) {
|
|
780
|
-
lines.push(` ${b('\u2502')} ${brand.teal(currentLine).padEnd(width - 1)}${b('\u2502')}`);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
if (comp.type) {
|
|
785
|
-
const builtWith = ` Built with: myvillage ${comp.type}`;
|
|
786
|
-
lines.push(` ${b('\u2502')} ${brand.gold(builtWith).padEnd(width - 1)}${b('\u2502')}`);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
lines.push(` ${b('\u2502')}${' '.repeat(width + 1)}${b('\u2502')}`);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
lines.push(` ${b('\u251C' + bdr + '\u2524')}`);
|
|
794
|
-
|
|
795
|
-
if (rec.estimatedTimeline) {
|
|
796
|
-
const tl = ` Estimated Build Time: ${rec.estimatedTimeline}`;
|
|
797
|
-
lines.push(` ${b('\u2502')} ${brand.cream(tl).padEnd(width - 1)}${b('\u2502')}`);
|
|
798
|
-
}
|
|
799
|
-
if (rec.estimatedMVT) {
|
|
800
|
-
const mvt = ` Estimated MVT Budget: ${rec.estimatedMVT} MVT`;
|
|
801
|
-
lines.push(` ${b('\u2502')} ${brand.cream(mvt).padEnd(width - 1)}${b('\u2502')}`);
|
|
802
|
-
}
|
|
803
|
-
if (rec.overallComplexity) {
|
|
804
|
-
const cx = ` Complexity: ${rec.overallComplexity}`;
|
|
805
|
-
lines.push(` ${b('\u2502')} ${brand.cream(cx).padEnd(width - 1)}${b('\u2502')}`);
|
|
806
|
-
}
|
|
807
|
-
lines.push(` ${b('\u2514' + bdr + '\u2518')}`);
|
|
808
|
-
lines.push('');
|
|
809
|
-
|
|
810
|
-
console.log(lines.join('\n'));
|
|
811
|
-
}
|
|
812
|
-
|
|
813
633
|
// ── Pagination ──────────────────────────────────────────
|
|
814
634
|
|
|
815
635
|
export function formatPagination(meta) {
|