@compilr-dev/cli 0.6.0 → 0.6.2
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/CHANGELOG.md +104 -0
- package/README.md +12 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +66 -1
- package/dist/commands-v2/handlers/index.js +2 -2
- package/dist/commands-v2/handlers/project.d.ts +1 -0
- package/dist/commands-v2/handlers/project.js +36 -2
- package/dist/commands-v2/handlers/team.js +23 -3
- package/dist/compilr-diff-companion.vsix +0 -0
- package/dist/entitlements/index.d.ts +23 -0
- package/dist/entitlements/index.js +110 -0
- package/dist/guide/cli-guide-entries.d.ts +15 -0
- package/dist/guide/cli-guide-entries.js +99 -0
- package/dist/guide/index.d.ts +5 -4
- package/dist/guide/index.js +4 -3
- package/dist/guide/shared-content.js +188 -21
- package/dist/handlers/permission-handler.js +10 -3
- package/dist/index.js +23 -2
- package/dist/repl-v2.d.ts +16 -0
- package/dist/repl-v2.js +51 -17
- package/dist/tools/db-tools.d.ts +1 -1
- package/dist/tools/platform-adapter.d.ts +1 -1
- package/dist/tools/platform-adapter.js +6 -1
- package/dist/tools.js +6 -1
- package/dist/ui/overlay/impl/app-model-overlay-v2.d.ts +57 -0
- package/dist/ui/overlay/impl/app-model-overlay-v2.js +232 -0
- package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.d.ts +23 -1
- package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.js +203 -47
- package/dist/ui/overlay/impl/model-overlay-v2.js +2 -2
- package/dist/ui/overlay/impl/new-overlay-v2.d.ts +2 -2
- package/dist/ui/overlay/impl/new-overlay-v2.js +10 -17
- package/dist/ui/overlay/impl/team-overlay-v2.js +2 -2
- package/dist/ui/overlay/index.d.ts +1 -0
- package/dist/ui/overlay/index.js +1 -0
- package/dist/utils/update-checker.d.ts +6 -1
- package/dist/utils/update-checker.js +16 -1
- package/package.json +8 -7
- package/dist/.tsbuildinfo.app +0 -1
- package/dist/.tsbuildinfo.data +0 -1
- package/dist/.tsbuildinfo.domain +0 -1
- package/dist/.tsbuildinfo.foundation +0 -1
- package/dist/guide/guide-content.d.ts +0 -23
- package/dist/guide/guide-content.js +0 -196
- package/dist/multi-agent/activity.d.ts +0 -21
- package/dist/multi-agent/activity.js +0 -34
- package/dist/multi-agent/agent-selection.d.ts +0 -55
- package/dist/multi-agent/agent-selection.js +0 -90
- package/dist/multi-agent/artifacts.d.ts +0 -197
- package/dist/multi-agent/artifacts.js +0 -379
- package/dist/multi-agent/collision-utils.d.ts +0 -16
- package/dist/multi-agent/collision-utils.js +0 -28
- package/dist/multi-agent/context-resolver.d.ts +0 -97
- package/dist/multi-agent/context-resolver.js +0 -316
- package/dist/multi-agent/mention-parser.d.ts +0 -64
- package/dist/multi-agent/mention-parser.js +0 -146
- package/dist/multi-agent/shared-context.d.ts +0 -293
- package/dist/multi-agent/shared-context.js +0 -671
- package/dist/multi-agent/skill-requirements.d.ts +0 -66
- package/dist/multi-agent/skill-requirements.js +0 -178
- package/dist/multi-agent/task-assignment.d.ts +0 -69
- package/dist/multi-agent/task-assignment.js +0 -123
- package/dist/multi-agent/task-suggestion.d.ts +0 -31
- package/dist/multi-agent/task-suggestion.js +0 -72
- package/dist/multi-agent/team-agent.d.ts +0 -201
- package/dist/multi-agent/team-agent.js +0 -488
- package/dist/multi-agent/team.d.ts +0 -286
- package/dist/multi-agent/team.js +0 -610
- package/dist/multi-agent/tool-config.d.ts +0 -110
- package/dist/multi-agent/tool-config.js +0 -661
- package/dist/multi-agent/types.d.ts +0 -211
- package/dist/multi-agent/types.js +0 -617
- package/dist/tools/guide-tool.d.ts +0 -12
- package/dist/tools/guide-tool.js +0 -59
|
@@ -258,9 +258,10 @@ export const CONTENT_TOPICS = [
|
|
|
258
258
|
{
|
|
259
259
|
title: 'After /design completes:',
|
|
260
260
|
items: [
|
|
261
|
-
'PRD is saved to the project database
|
|
261
|
+
'PRD is saved to the project database',
|
|
262
|
+
'Application Model is created (entities, fields, relationships)',
|
|
262
263
|
'Work items are added to your backlog',
|
|
263
|
-
'Use /backlog to view
|
|
264
|
+
'Use /backlog to view items, /app to view the model',
|
|
264
265
|
],
|
|
265
266
|
},
|
|
266
267
|
{
|
|
@@ -429,35 +430,41 @@ export const CONTENT_TOPICS = [
|
|
|
429
430
|
{
|
|
430
431
|
id: 'command-scaffold',
|
|
431
432
|
title: '/scaffold Command',
|
|
432
|
-
keywords: ['/scaffold', 'scaffold', 'project setup', 'foundation', 'boilerplate'],
|
|
433
|
+
keywords: ['/scaffold', 'scaffold', 'project setup', 'foundation', 'boilerplate', 'factory', 'generate'],
|
|
433
434
|
sections: [
|
|
434
435
|
{
|
|
435
|
-
items: ['/scaffold -
|
|
436
|
+
items: ['/scaffold - Generate a full project from the Application Model or create a base structure.'],
|
|
436
437
|
},
|
|
437
438
|
{
|
|
438
|
-
title: '
|
|
439
|
+
title: 'Two modes:',
|
|
439
440
|
items: [
|
|
440
|
-
'
|
|
441
|
-
'
|
|
442
|
-
'When you need a working foundation before building features',
|
|
441
|
+
'Factory mode: If an Application Model exists (from /design), scaffolds using the factory',
|
|
442
|
+
'Manual mode: If no model, the agent creates structure from scratch',
|
|
443
443
|
],
|
|
444
444
|
},
|
|
445
445
|
{
|
|
446
|
-
title: '
|
|
446
|
+
title: 'Factory toolkits:',
|
|
447
447
|
items: [
|
|
448
|
-
'
|
|
449
|
-
'
|
|
450
|
-
'
|
|
451
|
-
'
|
|
452
|
-
'
|
|
448
|
+
'react-node - React 18 + Vite + Tailwind + Express + PostgreSQL',
|
|
449
|
+
'next-prisma - Next.js 14 App Router + Prisma ORM + Tailwind',
|
|
450
|
+
'static-landing - HTML + Tailwind CSS landing page',
|
|
451
|
+
'react-fastapi - React 18 + Vite + Tailwind + FastAPI (Python)',
|
|
452
|
+
'react-go - React 18 + Vite + Tailwind + Go (net/http)',
|
|
453
453
|
],
|
|
454
454
|
},
|
|
455
455
|
{
|
|
456
|
+
title: 'What factory mode produces:',
|
|
456
457
|
items: [
|
|
457
|
-
'
|
|
458
|
-
'
|
|
458
|
+
'Full CRUD pages for each entity (list, create, edit, detail)',
|
|
459
|
+
'API routes and data layer',
|
|
460
|
+
'Seed data from the model',
|
|
461
|
+
'Navigation, dashboard, theme, auth (if enabled)',
|
|
462
|
+
'Ready to run: npm install && npm run dev',
|
|
459
463
|
],
|
|
460
464
|
},
|
|
465
|
+
{
|
|
466
|
+
items: ['Use /app to view the Application Model before scaffolding.'],
|
|
467
|
+
},
|
|
461
468
|
],
|
|
462
469
|
},
|
|
463
470
|
// ===========================================================================
|
|
@@ -509,15 +516,19 @@ export const CONTENT_TOPICS = [
|
|
|
509
516
|
items: ['Team agents are specialized AI assistants with different expertise, tools, and model tiers.'],
|
|
510
517
|
},
|
|
511
518
|
{
|
|
512
|
-
title: 'Predefined roles (
|
|
519
|
+
title: 'Predefined roles (11):',
|
|
513
520
|
items: [
|
|
521
|
+
'$dev - Developer: Implementation, coding, debugging',
|
|
514
522
|
'$pm - PM: Planning, task tracking, timeline estimation',
|
|
515
523
|
'$arch - Architect: System design, patterns, tech decisions',
|
|
516
524
|
'$qa - QA Engineer: Testing, quality, code review',
|
|
517
|
-
'$
|
|
518
|
-
'$
|
|
519
|
-
'$
|
|
520
|
-
'$
|
|
525
|
+
'$writer - Technical Writer: Documentation, guides',
|
|
526
|
+
'$researcher - Researcher: Literature review, analysis',
|
|
527
|
+
'$reviewer - Reviewer: Code and content review',
|
|
528
|
+
'$editor - Editor: Content editing, prose, structure',
|
|
529
|
+
'$analyst - Analyst: Data and business analysis',
|
|
530
|
+
'$strategist - Strategist: Strategy and planning',
|
|
531
|
+
'$instructor - Instructor: Teaching, course design',
|
|
521
532
|
],
|
|
522
533
|
},
|
|
523
534
|
{
|
|
@@ -1225,6 +1236,162 @@ export const CONTENT_TOPICS = [
|
|
|
1225
1236
|
},
|
|
1226
1237
|
],
|
|
1227
1238
|
},
|
|
1239
|
+
// ===========================================================================
|
|
1240
|
+
// /app Command (Application Model Viewer)
|
|
1241
|
+
// ===========================================================================
|
|
1242
|
+
{
|
|
1243
|
+
id: 'command-app',
|
|
1244
|
+
title: '/app Command',
|
|
1245
|
+
keywords: ['/app', 'app', 'model', 'entities', 'fields', 'relationships', 'application model'],
|
|
1246
|
+
sections: [
|
|
1247
|
+
{
|
|
1248
|
+
items: ['/app - View the Application Model for the current project.'],
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
title: 'Three tabs:',
|
|
1252
|
+
items: [
|
|
1253
|
+
'Entities - List of all entities with field and relationship counts',
|
|
1254
|
+
'Relationships - Map of all entity relationships (hasMany/belongsTo)',
|
|
1255
|
+
'Summary - App identity, data model stats, configuration (layout, toolkit, features)',
|
|
1256
|
+
],
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
title: 'Navigation:',
|
|
1260
|
+
items: [
|
|
1261
|
+
'↑/↓ - Navigate items',
|
|
1262
|
+
'Enter - View entity detail (full field table + relationship map)',
|
|
1263
|
+
'Tab or 1-3 - Switch tabs',
|
|
1264
|
+
'/ - Search',
|
|
1265
|
+
'q/Esc - Close',
|
|
1266
|
+
],
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
items: [
|
|
1270
|
+
'The Application Model is created by /design and used by /scaffold to generate code.',
|
|
1271
|
+
'The agent can also modify the model via app_model_update tool.',
|
|
1272
|
+
],
|
|
1273
|
+
},
|
|
1274
|
+
],
|
|
1275
|
+
},
|
|
1276
|
+
// ===========================================================================
|
|
1277
|
+
// Image Support
|
|
1278
|
+
// ===========================================================================
|
|
1279
|
+
{
|
|
1280
|
+
id: 'image-support',
|
|
1281
|
+
title: 'Image Support',
|
|
1282
|
+
keywords: ['image', 'screenshot', 'picture', 'paste', 'attach', 'vision', 'view_image'],
|
|
1283
|
+
sections: [
|
|
1284
|
+
{
|
|
1285
|
+
items: ['You can send images to the agent for visual analysis (screenshots, diagrams, mockups).'],
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
title: 'Supported formats:',
|
|
1289
|
+
items: [
|
|
1290
|
+
'PNG, JPEG, GIF, WebP',
|
|
1291
|
+
],
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
title: 'How it works:',
|
|
1295
|
+
items: [
|
|
1296
|
+
'Images are resized to max 1568px to save tokens',
|
|
1297
|
+
'After a few turns, old images are replaced with text placeholders',
|
|
1298
|
+
'The agent can also view image files on disk via the view_image tool',
|
|
1299
|
+
'All major providers support vision: Claude, GPT-4o, Gemini',
|
|
1300
|
+
],
|
|
1301
|
+
},
|
|
1302
|
+
],
|
|
1303
|
+
},
|
|
1304
|
+
// ===========================================================================
|
|
1305
|
+
// Context Management (Compressors, Observation Masking)
|
|
1306
|
+
// ===========================================================================
|
|
1307
|
+
{
|
|
1308
|
+
id: 'context-management',
|
|
1309
|
+
title: 'Context Management',
|
|
1310
|
+
keywords: ['context', 'tokens', 'compressor', 'observation', 'masking', 'token saving'],
|
|
1311
|
+
sections: [
|
|
1312
|
+
{
|
|
1313
|
+
items: ['The agent automatically manages its context window to stay within limits.'],
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
title: 'Automatic optimizations:',
|
|
1317
|
+
items: [
|
|
1318
|
+
'Observation masking - Old tool results replaced with compact summaries after a few turns',
|
|
1319
|
+
'Image masking - Old images replaced with text placeholders (saves 1000+ tokens per image)',
|
|
1320
|
+
'Tool output compression - Large outputs compressed 60-90% (git, npm, file listings)',
|
|
1321
|
+
'Smart windowing - Oldest messages compacted when context fills up',
|
|
1322
|
+
'Dead message pruning - Removed permission exchanges and superseded errors',
|
|
1323
|
+
],
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
title: 'Manual controls:',
|
|
1327
|
+
items: [
|
|
1328
|
+
'/context - View current token usage and breakdown',
|
|
1329
|
+
'/compact - Force summarization of old messages',
|
|
1330
|
+
],
|
|
1331
|
+
},
|
|
1332
|
+
],
|
|
1333
|
+
},
|
|
1334
|
+
// ===========================================================================
|
|
1335
|
+
// Knowledge Base
|
|
1336
|
+
// ===========================================================================
|
|
1337
|
+
{
|
|
1338
|
+
id: 'knowledge-base',
|
|
1339
|
+
title: 'Knowledge Base',
|
|
1340
|
+
keywords: ['knowledge', 'kb', 'reference', 'documents', 'pin'],
|
|
1341
|
+
sections: [
|
|
1342
|
+
{
|
|
1343
|
+
items: ['The knowledge base stores reference documents and images for your project.'],
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
title: 'Adding content:',
|
|
1347
|
+
items: [
|
|
1348
|
+
'Files are added via the project_document_add tool or the desktop KB panel',
|
|
1349
|
+
'Supported: markdown, text, PDF, code files, images (PNG/JPEG/GIF/WebP)',
|
|
1350
|
+
'URLs can be imported (web page content fetched and stored)',
|
|
1351
|
+
],
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
title: 'Pinning:',
|
|
1355
|
+
items: [
|
|
1356
|
+
'Pinned files are included in every agent conversation',
|
|
1357
|
+
'Unpinned files are available on-demand (agent reads them when needed)',
|
|
1358
|
+
'Pin important reference docs to keep the agent informed',
|
|
1359
|
+
],
|
|
1360
|
+
},
|
|
1361
|
+
],
|
|
1362
|
+
},
|
|
1363
|
+
// ===========================================================================
|
|
1364
|
+
// Capability Packs
|
|
1365
|
+
// ===========================================================================
|
|
1366
|
+
{
|
|
1367
|
+
id: 'capability-packs',
|
|
1368
|
+
title: 'Capability Packs',
|
|
1369
|
+
keywords: ['capability', 'pack', 'tools', 'auto-load', 'dynamic', 'loading'],
|
|
1370
|
+
sections: [
|
|
1371
|
+
{
|
|
1372
|
+
items: ['Tools are organized into capability packs that load on demand.'],
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
title: 'How it works:',
|
|
1376
|
+
items: [
|
|
1377
|
+
'Only essential tools are loaded upfront (file read, shell, interaction)',
|
|
1378
|
+
'Additional packs load automatically when the agent needs them',
|
|
1379
|
+
'Reduces token cost by ~60% compared to loading all tools at once',
|
|
1380
|
+
],
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
title: 'Tool profiles control which packs are available:',
|
|
1384
|
+
items: [
|
|
1385
|
+
'full - All packs (default for primary agent)',
|
|
1386
|
+
'developer - Coding-focused packs',
|
|
1387
|
+
'read-only - Safe exploration only',
|
|
1388
|
+
'planner - Planning and documentation packs',
|
|
1389
|
+
'analyst - Analysis and research packs',
|
|
1390
|
+
'docs - Documentation packs',
|
|
1391
|
+
],
|
|
1392
|
+
},
|
|
1393
|
+
],
|
|
1394
|
+
},
|
|
1228
1395
|
];
|
|
1229
1396
|
// =============================================================================
|
|
1230
1397
|
// Helper Functions
|
|
@@ -27,10 +27,17 @@ export function createPermissionHandler(deps) {
|
|
|
27
27
|
if (permissionMode === 'auto-accept') {
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
|
-
// "Plan" mode:
|
|
30
|
+
// "Plan" mode: block write/execute tools, allow read/plan tools
|
|
31
|
+
if (permissionMode === 'plan') {
|
|
32
|
+
const { isToolAllowedInPlanMode } = await import('@compilr-dev/sdk');
|
|
33
|
+
if (!isToolAllowedInPlanMode(request.toolName)) {
|
|
34
|
+
return false; // Blocked — agent gets denial in tool result
|
|
35
|
+
}
|
|
36
|
+
// Read/plan tools pass through without prompting
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
31
39
|
// "Default" mode: use rule-based checking
|
|
32
|
-
|
|
33
|
-
if (permissionMode !== 'plan') {
|
|
40
|
+
{
|
|
34
41
|
const rule = findMatchingRule(request.toolName);
|
|
35
42
|
if (rule) {
|
|
36
43
|
if (rule.level === 'always') {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Force color output for all chalk-based libraries (cli-highlight, marked-terminal, etc.)
|
|
3
|
-
// This must be set BEFORE any imports that use chalk
|
|
4
|
-
|
|
3
|
+
// This must be set BEFORE any imports that use chalk.
|
|
4
|
+
// Respect the NO_COLOR standard (https://no-color.org) — never override an explicit user opt-out.
|
|
5
|
+
if (!process.env.NO_COLOR) {
|
|
6
|
+
process.env.FORCE_COLOR = '3';
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* @compilr-dev/cli
|
|
7
10
|
*
|
|
@@ -560,6 +563,19 @@ async function main() {
|
|
|
560
563
|
// MCP tools injected later via agent.registerTools() when background init completes
|
|
561
564
|
// Episode recorder for work history tracking
|
|
562
565
|
episodeRecorder: defaultEpisodeRecorder,
|
|
566
|
+
// Plan mode callbacks — wired to ReplV2's handlePlanApproval
|
|
567
|
+
planModeCallbacks: {
|
|
568
|
+
onPlanSubmit: async (info) => {
|
|
569
|
+
// Delegate to ReplV2's existing plan approval flow
|
|
570
|
+
if (sharedState.onPlanSubmit)
|
|
571
|
+
return sharedState.onPlanSubmit(info);
|
|
572
|
+
return { action: 'reject' }; // Fallback if repl not ready
|
|
573
|
+
},
|
|
574
|
+
onPlanModeExit: async (info) => {
|
|
575
|
+
if (sharedState.onPlanModeExit)
|
|
576
|
+
return sharedState.onPlanModeExit(info);
|
|
577
|
+
},
|
|
578
|
+
},
|
|
563
579
|
});
|
|
564
580
|
perf('create-agent-done');
|
|
565
581
|
// Mutable ref so grantSession and onDefaultAgentSwapped closures track the current default agent
|
|
@@ -731,6 +747,11 @@ async function main() {
|
|
|
731
747
|
onBackgroundDelegationReady: (runDelegation) => {
|
|
732
748
|
sharedState.runBackgroundDelegation = runDelegation;
|
|
733
749
|
},
|
|
750
|
+
// Plan mode: wire approval and exit callbacks to ReplV2
|
|
751
|
+
onPlanModeReady: (callbacks) => {
|
|
752
|
+
sharedState.onPlanSubmit = callbacks.onPlanSubmit;
|
|
753
|
+
sharedState.onPlanModeExit = callbacks.onPlanModeExit;
|
|
754
|
+
},
|
|
734
755
|
// Update sharedState.team when session restore replaces the team object
|
|
735
756
|
// (so delegation handlers see restored agents, not just 'default')
|
|
736
757
|
onTeamReplaced: (newTeam) => {
|
package/dist/repl-v2.d.ts
CHANGED
|
@@ -149,6 +149,21 @@ export interface ReplV2Options {
|
|
|
149
149
|
* Phase 3d-beta: Coordinator Mode
|
|
150
150
|
*/
|
|
151
151
|
onBackgroundDelegationReady?: (runDelegation: (agentId: string, message: string) => 'running' | 'queued' | null) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Plan mode: wire plan_submit and plan_mode_exit callbacks to the approval overlay.
|
|
154
|
+
*/
|
|
155
|
+
onPlanModeReady?: (callbacks: {
|
|
156
|
+
onPlanSubmit: (info: {
|
|
157
|
+
planId: number;
|
|
158
|
+
summary?: string;
|
|
159
|
+
}) => Promise<{
|
|
160
|
+
action: 'approve-auto' | 'approve' | 'revise' | 'reject';
|
|
161
|
+
feedback?: string;
|
|
162
|
+
}>;
|
|
163
|
+
onPlanModeExit: (info: {
|
|
164
|
+
reason: string;
|
|
165
|
+
}) => Promise<void>;
|
|
166
|
+
}) => void;
|
|
152
167
|
/**
|
|
153
168
|
* Callback invoked when terminal session is registered.
|
|
154
169
|
* Passes the session ID so index.ts can set sessionPrefix for IPC.
|
|
@@ -234,6 +249,7 @@ export declare class ReplV2 {
|
|
|
234
249
|
private readonly onPendingDelegation?;
|
|
235
250
|
private readonly onBackgroundAgentReady?;
|
|
236
251
|
private readonly onBackgroundDelegationReady?;
|
|
252
|
+
private readonly onPlanModeReady?;
|
|
237
253
|
private readonly onSessionRegistered?;
|
|
238
254
|
private readonly onTeamReplaced?;
|
|
239
255
|
private readonly onProjectStateUpdate?;
|
package/dist/repl-v2.js
CHANGED
|
@@ -31,7 +31,7 @@ import { renderMascotWithLogo } from './ui/mascot/renderer.js';
|
|
|
31
31
|
import { getStartupHighlights } from './changelog/index.js';
|
|
32
32
|
import { registerCommands, executeCommand, allCommands, getAutocompleteCommands, saveCurrentSession, saveCurrentTeam, loadProjectSession, archiveCurrentSession, convertMessagesToItems, } from './commands-v2/index.js';
|
|
33
33
|
import { getCustomCommandRegistry } from './commands/custom-registry.js';
|
|
34
|
-
import { getPlanModePrompt } from '
|
|
34
|
+
import { getPlanModePrompt } from '@compilr-dev/sdk';
|
|
35
35
|
import { planRepository } from './db/repositories/index.js';
|
|
36
36
|
import { PlanApprovalOverlayV2, } from './ui/overlay/impl/plan-approval-overlay-v2.js';
|
|
37
37
|
import { PermissionOverlayV2, } from './ui/overlay/impl/permission-overlay-v2.js';
|
|
@@ -197,6 +197,7 @@ export class ReplV2 {
|
|
|
197
197
|
onPendingDelegation;
|
|
198
198
|
onBackgroundAgentReady;
|
|
199
199
|
onBackgroundDelegationReady;
|
|
200
|
+
onPlanModeReady;
|
|
200
201
|
onSessionRegistered;
|
|
201
202
|
onTeamReplaced;
|
|
202
203
|
onProjectStateUpdate;
|
|
@@ -245,6 +246,7 @@ export class ReplV2 {
|
|
|
245
246
|
this.onPendingDelegation = options.onPendingDelegation;
|
|
246
247
|
this.onBackgroundAgentReady = options.onBackgroundAgentReady;
|
|
247
248
|
this.onBackgroundDelegationReady = options.onBackgroundDelegationReady;
|
|
249
|
+
this.onPlanModeReady = options.onPlanModeReady;
|
|
248
250
|
this.onSessionRegistered = options.onSessionRegistered;
|
|
249
251
|
this.onTeamReplaced = options.onTeamReplaced;
|
|
250
252
|
this.onProjectStateUpdate = options.onProjectStateUpdate;
|
|
@@ -987,6 +989,26 @@ export class ReplV2 {
|
|
|
987
989
|
return 'running';
|
|
988
990
|
});
|
|
989
991
|
}
|
|
992
|
+
// Plan mode: wire plan_submit and plan_mode_exit to handlePlanApproval
|
|
993
|
+
if (this.onPlanModeReady) {
|
|
994
|
+
this.onPlanModeReady({
|
|
995
|
+
onPlanSubmit: async (info) => {
|
|
996
|
+
await this.handlePlanApproval(info.planId, info.summary ?? 'Plan');
|
|
997
|
+
// Map the internal action to PlanSubmitResult
|
|
998
|
+
// handlePlanApproval already updates DB and mode — return a simplified result
|
|
999
|
+
const mode = this.ui.getMode();
|
|
1000
|
+
if (mode === 'auto-accept')
|
|
1001
|
+
return { action: 'approve-auto' };
|
|
1002
|
+
return { action: 'approve' };
|
|
1003
|
+
},
|
|
1004
|
+
onPlanModeExit: (info) => {
|
|
1005
|
+
this.ui.setMode('normal');
|
|
1006
|
+
this.ui.clearActivePlan();
|
|
1007
|
+
this.ui.print({ type: 'info', message: `Agent exited plan mode: ${info.reason}` });
|
|
1008
|
+
return Promise.resolve();
|
|
1009
|
+
},
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
990
1012
|
// Event handlers
|
|
991
1013
|
this.ui.on('submit', (input) => {
|
|
992
1014
|
void this.processInput(input);
|
|
@@ -1547,6 +1569,12 @@ export class ReplV2 {
|
|
|
1547
1569
|
// Start session heartbeat in background (don't block UI)
|
|
1548
1570
|
const auth = getAuthManager();
|
|
1549
1571
|
void auth.startSession();
|
|
1572
|
+
// Warm entitlement cache in background (non-blocking)
|
|
1573
|
+
if (await auth.isAuthenticated()) {
|
|
1574
|
+
import('./entitlements/index.js').then(({ warmEntitlementCache }) => {
|
|
1575
|
+
void warmEntitlementCache(() => auth.getAccessToken());
|
|
1576
|
+
}).catch(() => { });
|
|
1577
|
+
}
|
|
1550
1578
|
const startupMode = getStartupMode();
|
|
1551
1579
|
if (startupMode === 'menu') {
|
|
1552
1580
|
await this.handleCommand('menu', '');
|
|
@@ -2209,6 +2237,25 @@ export class ReplV2 {
|
|
|
2209
2237
|
async runAgentReal(userMessage) {
|
|
2210
2238
|
if (!this.agent)
|
|
2211
2239
|
return;
|
|
2240
|
+
// Entitlement check: daily message limit
|
|
2241
|
+
try {
|
|
2242
|
+
const { dailyMessageCounter, getEntitlementCache } = await import('./entitlements/index.js');
|
|
2243
|
+
const auth = (await import('./auth/index.js')).getAuthManager();
|
|
2244
|
+
if (await auth.isAuthenticated()) {
|
|
2245
|
+
const cache = getEntitlementCache(() => auth.getAccessToken());
|
|
2246
|
+
const msgCount = dailyMessageCounter.increment();
|
|
2247
|
+
const check = cache.checkLimit('maxAgentMessagesPerDay', msgCount);
|
|
2248
|
+
if (!check.allowed) {
|
|
2249
|
+
const { formatTimeUntilReset } = await import('@compilr-dev/sdk');
|
|
2250
|
+
this.ui.print({
|
|
2251
|
+
type: 'warning',
|
|
2252
|
+
message: `Daily message limit reached (${String(check.current)}/${String(check.limit)}). ${formatTimeUntilReset()}.`,
|
|
2253
|
+
});
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
catch { /* allow if entitlements unavailable */ }
|
|
2212
2259
|
const abortController = new AbortController();
|
|
2213
2260
|
const signal = abortController.signal;
|
|
2214
2261
|
const setAction = (action) => {
|
|
@@ -2252,7 +2299,7 @@ export class ReplV2 {
|
|
|
2252
2299
|
let messageToSend = userMessage;
|
|
2253
2300
|
if (this.ui.getMode() === 'plan') {
|
|
2254
2301
|
const activePlan = this.ui.getActivePlan();
|
|
2255
|
-
const planModePrompt = getPlanModePrompt(activePlan.id
|
|
2302
|
+
const planModePrompt = getPlanModePrompt(activePlan.id && activePlan.name ? { id: activePlan.id, name: activePlan.name } : undefined);
|
|
2256
2303
|
messageToSend = `${planModePrompt}\n\n---\n\nUser request: ${userMessage}`;
|
|
2257
2304
|
}
|
|
2258
2305
|
// Inject delegation completion notifications (deferred delivery)
|
|
@@ -2687,22 +2734,9 @@ export class ReplV2 {
|
|
|
2687
2734
|
});
|
|
2688
2735
|
}
|
|
2689
2736
|
}
|
|
2690
|
-
// Flush remaining text
|
|
2737
|
+
// Flush remaining text (PLAN_READY marker detection removed — plan_submit tool handles approval)
|
|
2691
2738
|
if (this.textAccumulator.trim()) {
|
|
2692
|
-
|
|
2693
|
-
// Check for PLAN_READY marker
|
|
2694
|
-
const planReadyInfo = this.detectPlanReady(text);
|
|
2695
|
-
// Print the text (remove the marker from display if present)
|
|
2696
|
-
const displayText = planReadyInfo
|
|
2697
|
-
? text.replace(ReplV2.PLAN_READY_REGEX, '').trim()
|
|
2698
|
-
: text;
|
|
2699
|
-
if (displayText) {
|
|
2700
|
-
this.ui.print({ type: 'agent-text', text: displayText, expression: this.getActiveAgentMascot(), agentId: activeAgentId });
|
|
2701
|
-
}
|
|
2702
|
-
// If PLAN_READY marker found, show approval overlay
|
|
2703
|
-
if (planReadyInfo) {
|
|
2704
|
-
await this.handlePlanApproval(planReadyInfo.planId, planReadyInfo.planName);
|
|
2705
|
-
}
|
|
2739
|
+
this.ui.print({ type: 'agent-text', text: this.textAccumulator.trim(), expression: this.getActiveAgentMascot(), agentId: activeAgentId });
|
|
2706
2740
|
}
|
|
2707
2741
|
// Print per-turn summary before stopping agent
|
|
2708
2742
|
this.printTurnSummary();
|
package/dist/tools/db-tools.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { getActiveProject, setActiveProject } from './project-db.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* All database tools combined (32 tools from SDK)
|
|
12
12
|
*/
|
|
13
|
-
export declare const allDbTools: import("@compilr-dev/
|
|
13
|
+
export declare const allDbTools: import("@compilr-dev/agents").Tool<never>[];
|
|
14
14
|
/**
|
|
15
15
|
* All factory tools (5 tools from @compilr-dev/factory)
|
|
16
16
|
*/
|
|
@@ -22,4 +22,4 @@ export declare const allPlatformTools: import("@compilr-dev/sdk").Tool<never>[];
|
|
|
22
22
|
* - 3 model tools (app_model_get, app_model_update, app_model_validate)
|
|
23
23
|
* - 2 factory tools (factory_scaffold, factory_list_toolkits)
|
|
24
24
|
*/
|
|
25
|
-
export declare const allFactoryTools: import(
|
|
25
|
+
export declare const allFactoryTools: import('@compilr-dev/agents').Tool<never>[];
|
|
@@ -9,6 +9,7 @@ import { createPlatformTools, createSQLiteRepositories, ProjectAnchorStore, } fr
|
|
|
9
9
|
import { createFactoryTools } from '@compilr-dev/factory';
|
|
10
10
|
import { getDb } from '../db/index.js';
|
|
11
11
|
import { getDataPath, getSessionsPath } from '../settings/paths.js';
|
|
12
|
+
import { getPermissionMode } from '../settings/index.js';
|
|
12
13
|
import { existsSync, rmSync } from 'fs';
|
|
13
14
|
import { join } from 'path';
|
|
14
15
|
import { getCurrentProject, setCurrentProject } from './project-db.js';
|
|
@@ -273,7 +274,11 @@ const config = {
|
|
|
273
274
|
* - 4 artifact tools (artifact_save, artifact_get, artifact_list, artifact_delete)
|
|
274
275
|
* - 1 episode tool (recall_work)
|
|
275
276
|
*/
|
|
276
|
-
export const allPlatformTools = createPlatformTools(config
|
|
277
|
+
export const allPlatformTools = createPlatformTools(config, {
|
|
278
|
+
planModeCallbacks: {
|
|
279
|
+
isPlanModeActive: () => getPermissionMode() === 'plan',
|
|
280
|
+
},
|
|
281
|
+
});
|
|
277
282
|
/**
|
|
278
283
|
* All 5 factory tools from @compilr-dev/factory:
|
|
279
284
|
* - 3 model tools (app_model_get, app_model_update, app_model_validate)
|
package/dist/tools.js
CHANGED
|
@@ -125,7 +125,12 @@ import { delegateTool } from './tools/delegate.js';
|
|
|
125
125
|
import { delegateBackgroundTool } from './tools/delegate-background.js';
|
|
126
126
|
import { delegationStatusTool } from './tools/delegation-status.js';
|
|
127
127
|
import { handoffTool } from './tools/handoff.js';
|
|
128
|
-
import {
|
|
128
|
+
import { createGuideTool } from '@compilr-dev/sdk';
|
|
129
|
+
import { CLI_GUIDE_ENTRIES } from './guide/cli-guide-entries.js';
|
|
130
|
+
const guideTool = createGuideTool({
|
|
131
|
+
environment: 'cli',
|
|
132
|
+
additionalEntries: CLI_GUIDE_ENTRIES,
|
|
133
|
+
});
|
|
129
134
|
// DB tools for project, work item, document, plan, backlog, anchor, artifact, and episode management
|
|
130
135
|
import { allDbTools, allFactoryTools } from './tools/db-tools.js';
|
|
131
136
|
// Meta-tools for dynamic tool loading
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Model Overlay V2
|
|
3
|
+
*
|
|
4
|
+
* Terminal visualization of the ApplicationModel (from @compilr-dev/factory).
|
|
5
|
+
* Three tabs: Entities (list with detail), Relationships (map), Summary (stats).
|
|
6
|
+
*
|
|
7
|
+
* Not a replacement for the desktop SVG viewer — text-based tables and lists
|
|
8
|
+
* for CLI users who want to inspect the model structure.
|
|
9
|
+
*/
|
|
10
|
+
import { TabbedListOverlayV2, BaseScreen } from '../../base/index.js';
|
|
11
|
+
interface ModelField {
|
|
12
|
+
name: string;
|
|
13
|
+
label: string;
|
|
14
|
+
type: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
enumValues?: readonly string[];
|
|
17
|
+
defaultValue?: string | number | boolean;
|
|
18
|
+
}
|
|
19
|
+
interface ModelRelationship {
|
|
20
|
+
type: 'belongsTo' | 'hasMany';
|
|
21
|
+
target: string;
|
|
22
|
+
fieldName?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ModelEntity {
|
|
25
|
+
name: string;
|
|
26
|
+
pluralName: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
icon: string;
|
|
29
|
+
fields: readonly ModelField[];
|
|
30
|
+
views: readonly string[];
|
|
31
|
+
relationships: readonly ModelRelationship[];
|
|
32
|
+
}
|
|
33
|
+
export interface AppModelOverlayV2Options {
|
|
34
|
+
/** Raw JSON content from the document store */
|
|
35
|
+
modelJson: string;
|
|
36
|
+
/** Project display name */
|
|
37
|
+
projectName: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AppModelOverlayV2Result {
|
|
40
|
+
dismissed: boolean;
|
|
41
|
+
}
|
|
42
|
+
interface ModelListItem {
|
|
43
|
+
id: string;
|
|
44
|
+
tab: string;
|
|
45
|
+
label: string;
|
|
46
|
+
detail: string;
|
|
47
|
+
entity?: ModelEntity;
|
|
48
|
+
}
|
|
49
|
+
export declare class AppModelOverlayV2 extends TabbedListOverlayV2<ModelListItem, AppModelOverlayV2Result> {
|
|
50
|
+
readonly type: "inline";
|
|
51
|
+
readonly id = "app-model-viewer";
|
|
52
|
+
private readonly model;
|
|
53
|
+
private readonly parseError;
|
|
54
|
+
constructor(options: AppModelOverlayV2Options);
|
|
55
|
+
protected createDetailScreen(item: ModelListItem): BaseScreen | null;
|
|
56
|
+
}
|
|
57
|
+
export {};
|