@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.
Files changed (73) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +12 -0
  3. package/dist/agent.d.ts +2 -0
  4. package/dist/agent.js +66 -1
  5. package/dist/commands-v2/handlers/index.js +2 -2
  6. package/dist/commands-v2/handlers/project.d.ts +1 -0
  7. package/dist/commands-v2/handlers/project.js +36 -2
  8. package/dist/commands-v2/handlers/team.js +23 -3
  9. package/dist/compilr-diff-companion.vsix +0 -0
  10. package/dist/entitlements/index.d.ts +23 -0
  11. package/dist/entitlements/index.js +110 -0
  12. package/dist/guide/cli-guide-entries.d.ts +15 -0
  13. package/dist/guide/cli-guide-entries.js +99 -0
  14. package/dist/guide/index.d.ts +5 -4
  15. package/dist/guide/index.js +4 -3
  16. package/dist/guide/shared-content.js +188 -21
  17. package/dist/handlers/permission-handler.js +10 -3
  18. package/dist/index.js +23 -2
  19. package/dist/repl-v2.d.ts +16 -0
  20. package/dist/repl-v2.js +51 -17
  21. package/dist/tools/db-tools.d.ts +1 -1
  22. package/dist/tools/platform-adapter.d.ts +1 -1
  23. package/dist/tools/platform-adapter.js +6 -1
  24. package/dist/tools.js +6 -1
  25. package/dist/ui/overlay/impl/app-model-overlay-v2.d.ts +57 -0
  26. package/dist/ui/overlay/impl/app-model-overlay-v2.js +232 -0
  27. package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.d.ts +23 -1
  28. package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.js +203 -47
  29. package/dist/ui/overlay/impl/model-overlay-v2.js +2 -2
  30. package/dist/ui/overlay/impl/new-overlay-v2.d.ts +2 -2
  31. package/dist/ui/overlay/impl/new-overlay-v2.js +10 -17
  32. package/dist/ui/overlay/impl/team-overlay-v2.js +2 -2
  33. package/dist/ui/overlay/index.d.ts +1 -0
  34. package/dist/ui/overlay/index.js +1 -0
  35. package/dist/utils/update-checker.d.ts +6 -1
  36. package/dist/utils/update-checker.js +16 -1
  37. package/package.json +8 -7
  38. package/dist/.tsbuildinfo.app +0 -1
  39. package/dist/.tsbuildinfo.data +0 -1
  40. package/dist/.tsbuildinfo.domain +0 -1
  41. package/dist/.tsbuildinfo.foundation +0 -1
  42. package/dist/guide/guide-content.d.ts +0 -23
  43. package/dist/guide/guide-content.js +0 -196
  44. package/dist/multi-agent/activity.d.ts +0 -21
  45. package/dist/multi-agent/activity.js +0 -34
  46. package/dist/multi-agent/agent-selection.d.ts +0 -55
  47. package/dist/multi-agent/agent-selection.js +0 -90
  48. package/dist/multi-agent/artifacts.d.ts +0 -197
  49. package/dist/multi-agent/artifacts.js +0 -379
  50. package/dist/multi-agent/collision-utils.d.ts +0 -16
  51. package/dist/multi-agent/collision-utils.js +0 -28
  52. package/dist/multi-agent/context-resolver.d.ts +0 -97
  53. package/dist/multi-agent/context-resolver.js +0 -316
  54. package/dist/multi-agent/mention-parser.d.ts +0 -64
  55. package/dist/multi-agent/mention-parser.js +0 -146
  56. package/dist/multi-agent/shared-context.d.ts +0 -293
  57. package/dist/multi-agent/shared-context.js +0 -671
  58. package/dist/multi-agent/skill-requirements.d.ts +0 -66
  59. package/dist/multi-agent/skill-requirements.js +0 -178
  60. package/dist/multi-agent/task-assignment.d.ts +0 -69
  61. package/dist/multi-agent/task-assignment.js +0 -123
  62. package/dist/multi-agent/task-suggestion.d.ts +0 -31
  63. package/dist/multi-agent/task-suggestion.js +0 -72
  64. package/dist/multi-agent/team-agent.d.ts +0 -201
  65. package/dist/multi-agent/team-agent.js +0 -488
  66. package/dist/multi-agent/team.d.ts +0 -286
  67. package/dist/multi-agent/team.js +0 -610
  68. package/dist/multi-agent/tool-config.d.ts +0 -110
  69. package/dist/multi-agent/tool-config.js +0 -661
  70. package/dist/multi-agent/types.d.ts +0 -211
  71. package/dist/multi-agent/types.js +0 -617
  72. package/dist/tools/guide-tool.d.ts +0 -12
  73. package/dist/tools/guide-tool.js +0 -59
package/CHANGELOG.md ADDED
@@ -0,0 +1,104 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@compilr-dev/cli` are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ > **Beta notice:** versions in the `0.x` range may contain breaking changes
9
+ > between minors. Read each release entry before upgrading.
10
+
11
+ ---
12
+
13
+ ## [Unreleased]
14
+
15
+ ## [0.6.2] — 2026-04-25
16
+
17
+ ### Fixed
18
+ - Respect the [`NO_COLOR`](https://no-color.org) standard — `NO_COLOR=1 compilr ...`
19
+ now produces uncolored output instead of being silently overridden by
20
+ `FORCE_COLOR=3`. Restores accessibility for screen readers, low-contrast
21
+ terminals, log redirection, and CI environments.
22
+
23
+ ### Changed
24
+ - Lower minimum supported Node from `>=22.0.0` to `>=20.0.0` — Node 20 is the
25
+ active LTS line and the codebase uses no v22-only APIs. Restores compatibility
26
+ for users still on Node 20 LTS.
27
+
28
+ ### Added
29
+ - Documented opt-outs for the npm registry update check. Set any of the
30
+ following to skip the network call on startup:
31
+ - `COMPILR_NO_UPDATE_CHECK=1` (project-specific)
32
+ - `NO_UPDATE_NOTIFIER=1` (de-facto standard from `update-notifier`)
33
+ - `CI=true` (auto-respected in CI)
34
+ - `CHANGELOG.md` shipped in the published tarball (this file).
35
+
36
+ ### Removed
37
+ - TypeScript incremental build caches (`*.tsbuildinfo`) no longer ship in the
38
+ npm tarball. Tarball is now ~760 KB compressed (previously ~1 MB) — about
39
+ ~660 KB lighter on disk after install.
40
+
41
+ ---
42
+
43
+ ## [0.6.1] — 2026-04-21
44
+
45
+ ### Fixed
46
+ - Resolved `npm audit` vulnerabilities in transitive deps (`hono`, `protobufjs`).
47
+
48
+ ## [0.6.0] — 2026-04-19
49
+
50
+ ### Changed
51
+ - **Major:** CLI now builds on `createCompilrAgent` from `@compilr-dev/sdk`
52
+ (universal agent runtime). All agent setup, tool assembly, capability
53
+ loading, and team coordination flow through the SDK. CLI source dropped
54
+ from ~3.5 K LOC of agent wiring to a thin adapter.
55
+ - Logging is now structured JSON via `@compilr-dev/logger` (Pino) — no more
56
+ raw `console.log` from diagnostic paths. Logs are scrubbed for secrets.
57
+
58
+ ### Added
59
+ - Plan Mode V2 — permission-blocking + tool-based transitions for safer
60
+ multi-step planning workflows. Plan can now be approved/edited from
61
+ inside the CLI.
62
+ - `/app` command — terminal app model viewer overlay (entities, fields,
63
+ relationships, layout, config). Aligned columns, no emojis.
64
+ - Custom agent wizard Step 5 — free-text custom instructions added per agent.
65
+ - Template support in custom agent wizard — `Ctrl+T` to save as template,
66
+ list UI to load existing templates.
67
+ - Guide tool migrated to SDK (`createGuideTool({ environment, additionalEntries })`).
68
+ - Removed two-repo and guided-workflow options from the wizard — both are
69
+ always single-repo + flexible now.
70
+
71
+ ### Fixed
72
+ - Credential encryption now survives container restarts (master key
73
+ derivation hardened).
74
+ - `/app` overlay — aligned columns, layout/config in summary, no emojis.
75
+ - Agent IDs may contain dashes.
76
+
77
+ ## [0.5.x] — 2026-03 → 2026-04
78
+
79
+ Highlights from the 0.5 line:
80
+
81
+ - Migrated more code paths to `@compilr-dev/sdk` (anchors, MCP, permissions,
82
+ SQLite repositories, capability loading).
83
+ - Pin API replaces the older anchor API for project state injection.
84
+ - Multi-terminal session awareness, dynamic capability loading with
85
+ auto-load on filtered tool use, observation masking, tool input
86
+ compaction, and tool result auto-delegation.
87
+ - Multi-LLM support across 9 providers (Claude, OpenAI, Gemini, Groq,
88
+ Fireworks, Together, Perplexity, OpenRouter, Ollama).
89
+ - Multi-agent teams (delegate, delegate_background, $mention routing,
90
+ /team dashboard, background queues).
91
+
92
+ For commit-level detail of the 0.5 line, see git log between v0.5.0 and v0.6.0.
93
+
94
+ ---
95
+
96
+ ## Earlier versions
97
+
98
+ The `0.4.x` and prior series were rapid pre-MVP iterations. See the git
99
+ history for details.
100
+
101
+ [Unreleased]: https://github.com/compilr-dev/cli/compare/v0.6.2...HEAD
102
+ [0.6.2]: https://github.com/compilr-dev/cli/compare/v0.6.1...v0.6.2
103
+ [0.6.1]: https://github.com/compilr-dev/cli/compare/v0.6.0...v0.6.1
104
+ [0.6.0]: https://github.com/compilr-dev/cli/compare/v0.5.17...v0.6.0
package/README.md CHANGED
@@ -217,6 +217,18 @@ export GOOGLE_API_KEY="..." # Google Gemini
217
217
 
218
218
  Environment variables take priority over stored keys.
219
219
 
220
+ ### Behavior Environment Variables
221
+
222
+ The CLI honors several standard environment variables for accessibility,
223
+ privacy, and CI use:
224
+
225
+ | Variable | Effect |
226
+ |---|---|
227
+ | `NO_COLOR=1` | Disable all ANSI colors. Honors the [no-color.org](https://no-color.org) standard. |
228
+ | `COMPILR_NO_UPDATE_CHECK=1` | Skip the npm registry update check at startup. |
229
+ | `NO_UPDATE_NOTIFIER=1` | Same as above. De-facto standard from `update-notifier`. |
230
+ | `CI=true` | Auto-skips the update check (no nag in CI environments). |
231
+
220
232
  ### Project Configuration
221
233
 
222
234
  Create a `COMPILR.md` file in your project root to provide context:
package/dist/agent.d.ts CHANGED
@@ -57,6 +57,8 @@ export interface AgentOptions {
57
57
  guidedModeContext?: string;
58
58
  /** Plan mode context */
59
59
  planModeContext?: string;
60
+ /** Plan mode callbacks for plan_submit and plan_mode_exit tools */
61
+ planModeCallbacks?: import('@compilr-dev/sdk').PlanModeCallbacks;
60
62
  /** Enable anchors (critical info that survives compaction) */
61
63
  enableAnchors?: boolean;
62
64
  /** Pre-loaded anchors to add at startup */
package/dist/agent.js CHANGED
@@ -17,6 +17,59 @@ import { setStaticEstimates, estimateTokens, estimateJsonTokens, } from './utils
17
17
  import { createFileLockCheckHook, createFileLockAcquireHook } from './multi-agent/file-lock-hook.js';
18
18
  import { getActiveProject } from './tools/project-db.js';
19
19
  import { allDbTools, allFactoryTools } from './tools/db-tools.js';
20
+ import { createGuideTool } from '@compilr-dev/sdk';
21
+ import { CLI_GUIDE_ENTRIES } from './guide/cli-guide-entries.js';
22
+ const cliGuideTool = createGuideTool({
23
+ environment: 'cli',
24
+ additionalEntries: CLI_GUIDE_ENTRIES,
25
+ });
26
+ import { defineTool, createSuccessResult } from '@compilr-dev/agents';
27
+ /** Create plan_submit and plan_mode_exit tools if callbacks are provided */
28
+ function buildPlanModeTools(callbacks) {
29
+ if (!callbacks || !callbacks.onPlanSubmit || !callbacks.onPlanModeExit)
30
+ return [];
31
+ const onSubmit = callbacks.onPlanSubmit;
32
+ const onExit = callbacks.onPlanModeExit;
33
+ const planSubmitTool = defineTool({
34
+ name: 'plan_submit',
35
+ description: 'Submit a plan for user approval. Call when your plan is ready for review. ' +
36
+ 'The user will choose to approve, revise, or reject. On approval, write tools are unlocked.',
37
+ inputSchema: {
38
+ type: 'object',
39
+ properties: {
40
+ plan_id: { type: 'number', description: 'ID of the plan to submit' },
41
+ summary: { type: 'string', description: 'One-line summary of the plan' },
42
+ },
43
+ required: ['plan_id'],
44
+ },
45
+ execute: async (input) => {
46
+ const result = await onSubmit({ planId: input.plan_id, summary: input.summary });
47
+ const messages = {
48
+ 'approve-auto': 'Plan approved. Auto-accept mode enabled. Proceed with implementation.',
49
+ approve: 'Plan approved. Proceed with implementation.',
50
+ revise: `Plan needs revision. Feedback: ${result.feedback ?? 'No specific feedback.'}`,
51
+ reject: 'Plan rejected.',
52
+ };
53
+ return createSuccessResult({ action: result.action, message: messages[result.action] });
54
+ },
55
+ });
56
+ const planModeExitTool = defineTool({
57
+ name: 'plan_mode_exit',
58
+ description: 'Exit plan mode without a plan. Use when the task is simple enough to implement directly.',
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ reason: { type: 'string', description: 'Brief reason for exiting plan mode' },
63
+ },
64
+ required: ['reason'],
65
+ },
66
+ execute: async (input) => {
67
+ await onExit({ reason: input.reason });
68
+ return createSuccessResult({ message: `Exited plan mode: ${input.reason}. Full tools now available.` });
69
+ },
70
+ });
71
+ return [planSubmitTool, planModeExitTool];
72
+ }
20
73
  /**
21
74
  * Default permission rules for potentially dangerous operations
22
75
  */
@@ -190,6 +243,14 @@ function createContextPressureHook() {
190
243
  export function createAgent(options = {}) {
191
244
  const { provider, model, apiKey } = resolveProviderConfig(options);
192
245
  const systemPrompt = buildSystemPrompt(options);
246
+ log.info({
247
+ component: 'agent',
248
+ provider,
249
+ model: model ?? 'default',
250
+ quiet: options.quiet ?? false,
251
+ metaTools: options.enableMetaTools ?? false,
252
+ projectName: options.projectName,
253
+ }, 'Creating agent');
193
254
  // ── Create agent via SDK ──────────────────────────────────────────────────
194
255
  const compilrAgent = createCompilrAgent({
195
256
  provider,
@@ -236,7 +297,7 @@ export function createAgent(options = {}) {
236
297
  }
237
298
  : undefined,
238
299
  // Capability loading (replaces CLI's manual meta-tools wiring)
239
- // Platform tools (DB, factory) + MCP tools are passed as additionalTools
300
+ // Platform tools (DB, factory) + MCP + guide + plan mode tools
240
301
  capabilities: (options.enableMetaTools && !options.minimal && !options.noTools)
241
302
  ? {
242
303
  enabled: true,
@@ -245,6 +306,8 @@ export function createAgent(options = {}) {
245
306
  ...allDbTools,
246
307
  ...allFactoryTools,
247
308
  ...(options.mcpTools ?? []),
309
+ cliGuideTool,
310
+ ...buildPlanModeTools(options.planModeCallbacks),
248
311
  ],
249
312
  }
250
313
  : {
@@ -253,6 +316,8 @@ export function createAgent(options = {}) {
253
316
  ...allDbTools,
254
317
  ...allFactoryTools,
255
318
  ...(options.mcpTools ?? []),
319
+ cliGuideTool,
320
+ ...buildPlanModeTools(options.planModeCallbacks),
256
321
  ],
257
322
  },
258
323
  // CLI-specific hooks
@@ -11,7 +11,7 @@ import { debugCommands } from './debug.js';
11
11
  import { sessionCommands } from './session.js';
12
12
  import { resetCommands } from './reset.js';
13
13
  import { teamCommands } from './team.js';
14
- import { gamesCommand } from './games.js';
14
+ // import { gamesCommand } from './games.js'; // Temporarily disabled — Tetris copyright concerns
15
15
  import { tasksCommand } from './tasks.js';
16
16
  import { backgroundCommands } from './background.js';
17
17
  import { filterCommands } from './filter.js';
@@ -50,7 +50,7 @@ export const allCommands = [
50
50
  ...sessionCommands,
51
51
  ...resetCommands,
52
52
  ...teamCommands,
53
- gamesCommand,
53
+ // gamesCommand, // Temporarily disabled — Tetris copyright concerns
54
54
  tasksCommand,
55
55
  ...backgroundCommands,
56
56
  ...filterCommands,
@@ -19,4 +19,5 @@ export declare const scaffoldCommand: CommandHandlerV2;
19
19
  export declare const archCommand: CommandHandlerV2;
20
20
  export declare const docsCommand: CommandHandlerV2;
21
21
  export declare const projectsCommand: CommandHandlerV2;
22
+ export declare const appCommand: CommandHandlerV2;
22
23
  export declare const projectCommands: CommandHandlerV2[];
@@ -4,7 +4,7 @@
4
4
  * Commands for project management: init, backlog, workflow, anchors, design, sketch, refine
5
5
  */
6
6
  import { executeCommand } from '../registry.js';
7
- import { BacklogOverlayV2, WorkflowOverlayV2, DocsOverlayV2, DocumentDetailOverlayV2, AnchorsOverlayV2, ProjectsOverlayV2, NewProjectOverlayV2, OnboardingWizardOverlayV2, KeysOverlayV2, ArchTypeOverlayV2, ModelWarningOverlayV2 } from '../../ui/overlay/index.js';
7
+ import { BacklogOverlayV2, WorkflowOverlayV2, DocsOverlayV2, DocumentDetailOverlayV2, AnchorsOverlayV2, ProjectsOverlayV2, NewProjectOverlayV2, OnboardingWizardOverlayV2, KeysOverlayV2, ArchTypeOverlayV2, ModelWarningOverlayV2, AppModelOverlayV2 } from '../../ui/overlay/index.js';
8
8
  import { projectRepository, workItemRepository, documentRepository } from '../../db/repositories/index.js';
9
9
  import { setCurrentProject, getCurrentProject } from '../../tools/project-db.js';
10
10
  import { getSkillPrompt } from '../../repl-helpers.js';
@@ -85,7 +85,7 @@ export const newCommand = {
85
85
  display_name: displayName,
86
86
  description: result.description,
87
87
  path: result.projectPath,
88
- type: 'general',
88
+ type: 'general', // TODO: wizard should let user pick project type (web/cli/library/api/research/etc.)
89
89
  workflow_mode: result.workflowMode ?? 'flexible',
90
90
  git_remote: result.gitRemote,
91
91
  // For imports, include detected language and framework
@@ -1120,6 +1120,39 @@ export const projectsCommand = {
1120
1120
  },
1121
1121
  };
1122
1122
  // =============================================================================
1123
+ // App Model Command
1124
+ // =============================================================================
1125
+ export const appCommand = {
1126
+ name: 'app',
1127
+ description: 'View the application model (entities, relationships, features)',
1128
+ details: 'Opens an interactive overlay showing the ApplicationModel for the current project. Browse entities with their fields and relationships, see the relationship map, and review model summary stats.',
1129
+ examples: [{ code: '/app' }],
1130
+ interactions: [
1131
+ 'Tab cycles: Entities → Relationships → Summary',
1132
+ '↑/↓ to navigate, Enter for entity detail',
1133
+ '/ to search, q/Esc to close',
1134
+ ],
1135
+ async execute(_args, ctx) {
1136
+ const currentProject = getCurrentProject();
1137
+ if (!currentProject) {
1138
+ ctx.ui.print({ type: 'warning', message: 'No active project. Use /new or /projects first.' });
1139
+ return true;
1140
+ }
1141
+ // Load app model from document store
1142
+ const appModelDoc = documentRepository.getByType(currentProject.id, 'app-model');
1143
+ if (!appModelDoc) {
1144
+ ctx.ui.print({ type: 'warning', message: 'No application model found for this project.' });
1145
+ return true;
1146
+ }
1147
+ const overlay = new AppModelOverlayV2({
1148
+ modelJson: appModelDoc.content,
1149
+ projectName: currentProject.displayName,
1150
+ });
1151
+ await ctx.ui.showOverlay(overlay);
1152
+ return true;
1153
+ },
1154
+ };
1155
+ // =============================================================================
1123
1156
  // Export All Project Commands
1124
1157
  // =============================================================================
1125
1158
  export const projectCommands = [
@@ -1138,4 +1171,5 @@ export const projectCommands = [
1138
1171
  archCommand,
1139
1172
  docsCommand,
1140
1173
  projectsCommand,
1174
+ appCommand,
1141
1175
  ];
@@ -10,6 +10,7 @@ import { ArtifactOverlayV2, ArtifactDetailOverlayV2 } from '../../ui/overlay/ind
10
10
  import { ROLE_METADATA, PREDEFINED_ROLE_IDS } from '../../multi-agent/index.js';
11
11
  import { loadCustomAgents, createCustomAgentDefinition, addCustomAgent, removeCustomAgent, } from '../../multi-agent/custom-agents.js';
12
12
  import { getCurrentProject } from '../../tools/project-db.js';
13
+ import { listTemplates, saveTemplate } from '@compilr-dev/sdk';
13
14
  import { getSessionRegistry } from '../../multi-agent/session-registry.js';
14
15
  import { saveCurrentTeam, saveCurrentSession } from './session.js';
15
16
  // =============================================================================
@@ -291,19 +292,38 @@ async function handleCreateCustomAgent(ctx, team) {
291
292
  // Load existing custom agents for duplicate check
292
293
  const existingCustomAgents = loadCustomAgents(projectPath);
293
294
  const teamAgentIds = team.getAgentIds();
294
- // Show custom agent form
295
+ // Load templates for pre-population
296
+ const templates = listTemplates();
297
+ // Show custom agent form (with template support)
295
298
  const formOverlay = new CustomAgentFormOverlayV2({
296
299
  existingCustomAgents,
297
300
  teamAgentIds,
301
+ templates: templates.length > 0 ? templates : undefined,
298
302
  });
299
303
  const formResult = await ctx.ui.showOverlay(formOverlay);
300
304
  // User cancelled
301
305
  if (!formResult || formResult.cancelled || !formResult.agent) {
302
306
  return;
303
307
  }
304
- // Create the custom agent definition
308
+ // Save as template if user chose to
305
309
  const agentData = formResult.agent;
306
- const agentDef = createCustomAgentDefinition(agentData.id, agentData.displayName, agentData.specialty, agentData.personality, existingCustomAgents, agentData.toolConfig, agentData.enabledSkills, agentData.modelTier);
310
+ if (formResult.saveAsTemplate) {
311
+ saveTemplate(formResult.saveAsTemplate, {
312
+ id: agentData.id,
313
+ displayName: agentData.displayName,
314
+ specialty: agentData.specialty,
315
+ personality: agentData.personality,
316
+ systemPromptAddition: agentData.systemPromptAddition,
317
+ mascot: '',
318
+ createdAt: new Date().toISOString(),
319
+ toolConfig: agentData.toolConfig,
320
+ enabledSkills: agentData.enabledSkills,
321
+ modelTier: agentData.modelTier,
322
+ });
323
+ ctx.ui.print({ type: 'success', message: `Template "${formResult.saveAsTemplate}" saved.` });
324
+ }
325
+ // Create the custom agent definition
326
+ const agentDef = createCustomAgentDefinition(agentData.id, agentData.displayName, agentData.specialty, agentData.personality, existingCustomAgents, agentData.toolConfig, agentData.enabledSkills, agentData.modelTier, agentData.systemPromptAddition);
307
327
  // Save to project
308
328
  try {
309
329
  addCustomAgent(projectPath, agentDef);
Binary file
@@ -0,0 +1,23 @@
1
+ /**
2
+ * EntitlementService — Server-driven tier management for the CLI.
3
+ *
4
+ * Wraps the SDK's EntitlementCache with CLI-specific concerns:
5
+ * - Fetches from compilr.dev backend using the user's API token
6
+ * - Uses encrypted file for offline backup
7
+ * - Warms cache on startup
8
+ */
9
+ import { EntitlementCache } from '@compilr-dev/sdk';
10
+ import { DailyCounter } from '@compilr-dev/sdk';
11
+ /** Daily message counter — tracks agent LLM calls per day */
12
+ export declare const dailyMessageCounter: DailyCounter;
13
+ /** Daily conversation counter */
14
+ export declare const dailyConversationCounter: DailyCounter;
15
+ /**
16
+ * Get or create the entitlement cache singleton.
17
+ * @param getToken — async function that returns the current auth token
18
+ */
19
+ export declare function getEntitlementCache(getToken: () => Promise<string>): EntitlementCache;
20
+ /**
21
+ * Warm the cache on startup. Non-blocking — logs but doesn't throw.
22
+ */
23
+ export declare function warmEntitlementCache(getToken: () => Promise<string>): Promise<void>;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * EntitlementService — Server-driven tier management for the CLI.
3
+ *
4
+ * Wraps the SDK's EntitlementCache with CLI-specific concerns:
5
+ * - Fetches from compilr.dev backend using the user's API token
6
+ * - Uses encrypted file for offline backup
7
+ * - Warms cache on startup
8
+ */
9
+ import { EntitlementCache } from '@compilr-dev/sdk';
10
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
11
+ import { join } from 'node:path';
12
+ import { createCipheriv, createDecipheriv, randomBytes, createHash } from 'node:crypto';
13
+ import { homedir } from 'node:os';
14
+ // ─── Encrypted File Store ───────────────────────────────────────────────────
15
+ function getEntitlementPath() {
16
+ return join(homedir(), '.compilr-dev', 'entitlements.enc');
17
+ }
18
+ /**
19
+ * Derive a machine-specific encryption key from hostname + username.
20
+ * Not cryptographically strong against targeted attacks, but prevents
21
+ * casual file copying between machines.
22
+ */
23
+ function deriveKey() {
24
+ const material = `compilr-entitlements:${homedir()}:${String(process.pid)}`;
25
+ return createHash('sha256').update(material).digest();
26
+ }
27
+ const cliStore = {
28
+ save(data) {
29
+ try {
30
+ const dir = join(homedir(), '.compilr-dev');
31
+ if (!existsSync(dir))
32
+ mkdirSync(dir, { recursive: true });
33
+ const key = deriveKey();
34
+ const iv = randomBytes(16);
35
+ const cipher = createCipheriv('aes-256-cbc', key, iv);
36
+ const encrypted = Buffer.concat([cipher.update(data, 'utf-8'), cipher.final()]);
37
+ const payload = Buffer.concat([iv, encrypted]);
38
+ writeFileSync(getEntitlementPath(), payload);
39
+ }
40
+ catch {
41
+ // Best effort — don't crash on write failure
42
+ }
43
+ return Promise.resolve();
44
+ },
45
+ load() {
46
+ const path = getEntitlementPath();
47
+ if (!existsSync(path))
48
+ return Promise.resolve(null);
49
+ try {
50
+ const payload = readFileSync(path);
51
+ const iv = payload.subarray(0, 16);
52
+ const encrypted = payload.subarray(16);
53
+ const key = deriveKey();
54
+ const decipher = createDecipheriv('aes-256-cbc', key, iv);
55
+ const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
56
+ return Promise.resolve(decrypted.toString('utf-8'));
57
+ }
58
+ catch {
59
+ return Promise.resolve(null);
60
+ }
61
+ },
62
+ };
63
+ // ─── Fetch Function ─────────────────────────────────────────────────────────
64
+ async function fetchEntitlements(getToken) {
65
+ const token = await getToken();
66
+ const apiUrl = process.env['COMPILR_API_URL'] ?? 'https://compilr.dev/.netlify/functions';
67
+ const resp = await fetch(`${apiUrl}/cli-entitlements`, {
68
+ method: 'GET',
69
+ headers: {
70
+ 'Authorization': `Bearer ${token}`,
71
+ 'Content-Type': 'application/json',
72
+ },
73
+ });
74
+ if (!resp.ok) {
75
+ throw new Error(`Entitlements fetch failed: ${String(resp.status)}`);
76
+ }
77
+ return await resp.json();
78
+ }
79
+ // ─── Singleton ──────────────────────────────────────────────────────────────
80
+ import { DailyCounter } from '@compilr-dev/sdk';
81
+ let cacheInstance = null;
82
+ /** Daily message counter — tracks agent LLM calls per day */
83
+ export const dailyMessageCounter = new DailyCounter();
84
+ /** Daily conversation counter */
85
+ export const dailyConversationCounter = new DailyCounter();
86
+ /**
87
+ * Get or create the entitlement cache singleton.
88
+ * @param getToken — async function that returns the current auth token
89
+ */
90
+ export function getEntitlementCache(getToken) {
91
+ if (!cacheInstance) {
92
+ cacheInstance = new EntitlementCache({
93
+ fetchFn: () => fetchEntitlements(getToken),
94
+ store: cliStore,
95
+ });
96
+ }
97
+ return cacheInstance;
98
+ }
99
+ /**
100
+ * Warm the cache on startup. Non-blocking — logs but doesn't throw.
101
+ */
102
+ export async function warmEntitlementCache(getToken) {
103
+ try {
104
+ const cache = getEntitlementCache(getToken);
105
+ await cache.get();
106
+ }
107
+ catch {
108
+ // Not critical — will retry on next access
109
+ }
110
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * CLI-Specific Guide Entries
3
+ *
4
+ * These entries are only relevant for the CLI environment.
5
+ * Combined with SDK shared content via createGuideTool({ additionalEntries }).
6
+ *
7
+ * The shared-content.ts file is still used by the /tutorial overlay (CLI UI).
8
+ * This file converts those topics + CLI-only entries for the SDK guide tool.
9
+ */
10
+ import type { GuideEntry } from '@compilr-dev/sdk';
11
+ /**
12
+ * All CLI-specific guide entries.
13
+ * Includes CLI-only topics + converted shared-content topics (used by /tutorial).
14
+ */
15
+ export declare const CLI_GUIDE_ENTRIES: GuideEntry[];
@@ -0,0 +1,99 @@
1
+ /**
2
+ * CLI-Specific Guide Entries
3
+ *
4
+ * These entries are only relevant for the CLI environment.
5
+ * Combined with SDK shared content via createGuideTool({ additionalEntries }).
6
+ *
7
+ * The shared-content.ts file is still used by the /tutorial overlay (CLI UI).
8
+ * This file converts those topics + CLI-only entries for the SDK guide tool.
9
+ */
10
+ import { topicToGuideEntry } from '@compilr-dev/sdk';
11
+ import { CONTENT_TOPICS } from './shared-content.js';
12
+ // =============================================================================
13
+ // CLI-Only Entries (not in shared SDK content, not in tutorials)
14
+ // =============================================================================
15
+ const CLI_ONLY_ENTRIES = [
16
+ {
17
+ id: 'cli-overview',
18
+ title: 'Compilr Dev CLI Overview',
19
+ keywords: ['overview', 'what is', 'introduction', 'about', 'compilr', 'cli'],
20
+ content: `Compilr Dev CLI is an AI-powered coding assistant for your terminal.
21
+
22
+ Key features:
23
+ - Multi-LLM support (Claude, OpenAI, Gemini, Ollama)
24
+ - Project management with structured workflows
25
+ - Requirements gathering with /design command
26
+ - Backlog tracking with /backlog command
27
+ - Team agents for specialized assistance ($arch, $pm, $qa, etc.)
28
+ - Session persistence and context management
29
+ - Image support (paste screenshots into chat)
30
+
31
+ The CLI has two main interfaces:
32
+ 1. Dashboard — A menu-based interface for project management
33
+ 2. REPL — A command-line interface for chatting with the AI
34
+
35
+ Run "compilr" to start. Use /help to see all commands.`,
36
+ },
37
+ {
38
+ id: 'workflow-modes',
39
+ title: 'Workflow',
40
+ keywords: ['workflow', 'flexible', 'mode'],
41
+ content: `The agent works in flexible mode — it responds to your requests and adapts to your workflow.
42
+
43
+ The agent checks your project state and suggests next steps:
44
+ - Does the project have a PRD? If not, suggests /design
45
+ - Are there backlog items? Suggests /build
46
+ - Is architecture documented? Suggests /arch
47
+
48
+ Use /workflow to see project status and recommended next actions.`,
49
+ },
50
+ {
51
+ id: 'workflow-recommended',
52
+ title: 'Recommended Workflow',
53
+ keywords: ['workflow', 'how to', 'best practice', 'process'],
54
+ content: `Recommended workflow for new projects:
55
+
56
+ 1. Create project with /new — choose tech stack, set up git
57
+ 2. Plan with /design — describe what you want, AI generates PRD + backlog
58
+ 3. Review backlog with /backlog — prioritize tasks
59
+ 4. Build features — "Build REQ-001: User authentication"
60
+ 5. Manage context — /compact when context fills up, /anchors for decisions, /resume to continue later`,
61
+ },
62
+ {
63
+ id: 'command-resume',
64
+ title: '/resume Command',
65
+ keywords: ['/resume', 'resume', 'session', 'continue', 'previous'],
66
+ content: `/resume — Continue a previous session.
67
+
68
+ Sessions are auto-saved after each AI response.
69
+
70
+ Navigation: j/k (up/down), / (search), Enter (resume), d (delete), q/Esc (close)
71
+
72
+ Saved per session: conversation history, todo list, workflow state, token usage.
73
+ Saved per project (not session): anchors, team agents, documents.`,
74
+ },
75
+ {
76
+ id: 'command-team',
77
+ title: '/team Command',
78
+ keywords: ['/team', 'team', 'agents', 'manage'],
79
+ content: `/team — View and manage team agents.
80
+
81
+ Shows all available agents with status and context usage.
82
+ Tabs: Agents (list) | Context (token usage per agent)
83
+
84
+ Switch agents: select + Enter, or use $ prefix in REPL ($arch, $pm, $qa).`,
85
+ },
86
+ ];
87
+ // =============================================================================
88
+ // Combined CLI Entries (CLI-only + shared-content topics)
89
+ // =============================================================================
90
+ /**
91
+ * All CLI-specific guide entries.
92
+ * Includes CLI-only topics + converted shared-content topics (used by /tutorial).
93
+ */
94
+ export const CLI_GUIDE_ENTRIES = [
95
+ ...CLI_ONLY_ENTRIES,
96
+ // Convert shared ContentTopics to GuideEntries (these are CLI-specific
97
+ // topics like overlay navigation, REPL, dashboard, /commands)
98
+ ...CONTENT_TOPICS.map(topicToGuideEntry),
99
+ ];
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Compilr Guide Module
3
3
  *
4
- * Provides documentation for the AI agent to answer user questions
5
- * about how to use the CLI.
4
+ * CLI-specific guide entries for the SDK's compilr_guide tool.
5
+ * shared-content.ts is still used by the /tutorial overlay.
6
6
  */
7
- export { searchGuide, getGuideTopics, guideEntries } from './guide-content.js';
8
- export type { GuideEntry } from './guide-content.js';
7
+ export { CLI_GUIDE_ENTRIES } from './cli-guide-entries.js';
8
+ export { CONTENT_TOPICS, topicToPlainText, searchContentTopics, getAllTopicIds } from './shared-content.js';
9
+ export type { ContentTopic, ContentSection } from './shared-content.js';
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Compilr Guide Module
3
3
  *
4
- * Provides documentation for the AI agent to answer user questions
5
- * about how to use the CLI.
4
+ * CLI-specific guide entries for the SDK's compilr_guide tool.
5
+ * shared-content.ts is still used by the /tutorial overlay.
6
6
  */
7
- export { searchGuide, getGuideTopics, guideEntries } from './guide-content.js';
7
+ export { CLI_GUIDE_ENTRIES } from './cli-guide-entries.js';
8
+ export { CONTENT_TOPICS, topicToPlainText, searchContentTopics, getAllTopicIds } from './shared-content.js';