@compilr-dev/cli 0.5.1 → 0.5.3

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 (56) hide show
  1. package/LICENSE +108 -0
  2. package/README.md +2 -2
  3. package/dist/.tsbuildinfo.app +1 -1
  4. package/dist/.tsbuildinfo.data +1 -1
  5. package/dist/.tsbuildinfo.domain +1 -1
  6. package/dist/.tsbuildinfo.foundation +1 -1
  7. package/dist/agent.js +8 -6
  8. package/dist/commands-v2/handlers/context.js +20 -0
  9. package/dist/commands-v2/handlers/core.js +26 -1
  10. package/dist/commands-v2/handlers/project.js +88 -12
  11. package/dist/commands-v2/handlers/reset.js +19 -6
  12. package/dist/commands-v2/handlers/session.d.ts +5 -1
  13. package/dist/commands-v2/handlers/session.js +54 -16
  14. package/dist/commands-v2/types.d.ts +5 -0
  15. package/dist/compilr-diff-companion.vsix +0 -0
  16. package/dist/db/repositories/document-repository.js +1 -0
  17. package/dist/db/schema.d.ts +1 -1
  18. package/dist/index.js +99 -30
  19. package/dist/models/providers.d.ts +3 -1
  20. package/dist/models/providers.js +9 -0
  21. package/dist/repl-helpers.js +2 -0
  22. package/dist/repl-v2.d.ts +12 -0
  23. package/dist/repl-v2.js +27 -11
  24. package/dist/tool-names.d.ts +9 -0
  25. package/dist/tool-names.js +36 -0
  26. package/dist/tools/db-tools.d.ts +6 -1
  27. package/dist/tools/db-tools.js +6 -2
  28. package/dist/tools/meta-tools.d.ts +1 -1
  29. package/dist/tools/platform-adapter.d.ts +6 -0
  30. package/dist/tools/platform-adapter.js +10 -0
  31. package/dist/tools.d.ts +14 -4
  32. package/dist/tools.js +60 -20
  33. package/dist/ui/constants/labels.js +1 -0
  34. package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +1 -0
  35. package/dist/ui/overlay/impl/workflow-overlay-v2.js +5 -3
  36. package/dist/ui/terminal-ui.d.ts +7 -7
  37. package/dist/ui/terminal-ui.js +1 -1
  38. package/dist/ui/tool-formatters.js +190 -6
  39. package/dist/ui/turn-metrics.d.ts +10 -10
  40. package/dist/ui/turn-metrics.js +5 -5
  41. package/dist/ui/types.d.ts +4 -4
  42. package/package.json +6 -5
  43. package/dist/tools/anchor-tools.d.ts +0 -31
  44. package/dist/tools/anchor-tools.js +0 -255
  45. package/dist/tools/artifact-tools.d.ts +0 -42
  46. package/dist/tools/artifact-tools.js +0 -328
  47. package/dist/tools/backlog-wrappers.d.ts +0 -56
  48. package/dist/tools/backlog-wrappers.js +0 -353
  49. package/dist/tools/document-db.d.ts +0 -43
  50. package/dist/tools/document-db.js +0 -220
  51. package/dist/tools/plan-tools.d.ts +0 -54
  52. package/dist/tools/plan-tools.js +0 -338
  53. package/dist/tools/recall-work-tool.d.ts +0 -18
  54. package/dist/tools/recall-work-tool.js +0 -82
  55. package/dist/tools/workitem-db.d.ts +0 -135
  56. package/dist/tools/workitem-db.js +0 -730
@@ -13,9 +13,9 @@ export interface TurnMetricsSnapshot {
13
13
  toolCalls: number;
14
14
  apiCalls: number;
15
15
  debugPayload?: {
16
- systemChars: number;
17
- contentsChars: number;
18
- toolsChars: number;
16
+ systemTokens: number;
17
+ contentsTokens: number;
18
+ toolsTokens: number;
19
19
  };
20
20
  }
21
21
  export declare class TurnMetrics {
@@ -24,9 +24,9 @@ export declare class TurnMetrics {
24
24
  thinkingTokens: number;
25
25
  cacheReadTokens: number;
26
26
  debugPayload?: {
27
- systemChars: number;
28
- contentsChars: number;
29
- toolsChars: number;
27
+ systemTokens: number;
28
+ contentsTokens: number;
29
+ toolsTokens: number;
30
30
  };
31
31
  startTime: number;
32
32
  toolCalls: number;
@@ -36,12 +36,12 @@ export declare class TurnMetrics {
36
36
  * Add input/output tokens for live display.
37
37
  * @param thinkingTokens - Optional thinking tokens (Gemini 2.5+ models)
38
38
  * @param cacheReadTokens - Optional cache read tokens (Anthropic/Gemini)
39
- * @param debugPayload - Optional debug payload sizes (char counts)
39
+ * @param debugPayload - Optional debug payload sizes (token estimates)
40
40
  */
41
41
  addTokens(inputTokens: number, outputTokens: number, thinkingTokens?: number, cacheReadTokens?: number, debugPayload?: {
42
- systemChars: number;
43
- contentsChars: number;
44
- toolsChars: number;
42
+ systemTokens: number;
43
+ contentsTokens: number;
44
+ toolsTokens: number;
45
45
  }): void;
46
46
  incrementToolCalls(): void;
47
47
  incrementApiCalls(): void;
@@ -18,7 +18,7 @@ export class TurnMetrics {
18
18
  * Add input/output tokens for live display.
19
19
  * @param thinkingTokens - Optional thinking tokens (Gemini 2.5+ models)
20
20
  * @param cacheReadTokens - Optional cache read tokens (Anthropic/Gemini)
21
- * @param debugPayload - Optional debug payload sizes (char counts)
21
+ * @param debugPayload - Optional debug payload sizes (token estimates)
22
22
  */
23
23
  addTokens(inputTokens, outputTokens, thinkingTokens, cacheReadTokens, debugPayload) {
24
24
  this.inputTokens += inputTokens;
@@ -31,11 +31,11 @@ export class TurnMetrics {
31
31
  }
32
32
  if (debugPayload) {
33
33
  if (!this.debugPayload) {
34
- this.debugPayload = { systemChars: 0, contentsChars: 0, toolsChars: 0 };
34
+ this.debugPayload = { systemTokens: 0, contentsTokens: 0, toolsTokens: 0 };
35
35
  }
36
- this.debugPayload.systemChars += debugPayload.systemChars;
37
- this.debugPayload.contentsChars += debugPayload.contentsChars;
38
- this.debugPayload.toolsChars += debugPayload.toolsChars;
36
+ this.debugPayload.systemTokens += debugPayload.systemTokens;
37
+ this.debugPayload.contentsTokens += debugPayload.contentsTokens;
38
+ this.debugPayload.toolsTokens += debugPayload.toolsTokens;
39
39
  }
40
40
  }
41
41
  incrementToolCalls() {
@@ -53,11 +53,11 @@ export interface TurnMetrics {
53
53
  subagentOutputTokens: number;
54
54
  toolCalls: number;
55
55
  durationMs: number;
56
- /** Debug payload info - char counts sent to provider (for debugging token discrepancies) */
56
+ /** Debug payload info - token estimates sent to provider */
57
57
  debugPayload?: {
58
- systemChars: number;
59
- contentsChars: number;
60
- toolsChars: number;
58
+ systemTokens: number;
59
+ contentsTokens: number;
60
+ toolsTokens: number;
61
61
  };
62
62
  }
63
63
  export interface CommandOption {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "AI-powered coding assistant CLI using @compilr-dev/agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "terminal"
36
36
  ],
37
37
  "author": "Carmelo Scozzola",
38
- "license": "MIT",
38
+ "license": "FSL-1.1-MIT",
39
39
  "repository": {
40
40
  "type": "git",
41
41
  "url": "git+https://github.com/compilr-dev/cli.git"
@@ -54,10 +54,11 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@anthropic-ai/sdk": "^0.74.0",
57
- "@compilr-dev/agents": "^0.3.16",
58
- "@compilr-dev/agents-coding": "^1.0.2",
57
+ "@compilr-dev/agents": "^0.3.22",
58
+ "@compilr-dev/agents-coding": "^1.0.4",
59
59
  "@compilr-dev/editor-core": "^0.0.2",
60
- "@compilr-dev/sdk": "^0.1.11",
60
+ "@compilr-dev/factory": "^0.1.12",
61
+ "@compilr-dev/sdk": "^0.1.18",
61
62
  "@compilr-dev/ui-core": "^0.0.1",
62
63
  "@modelcontextprotocol/sdk": "^1.23.0",
63
64
  "better-sqlite3": "^12.5.0",
@@ -1,31 +0,0 @@
1
- /**
2
- * Anchor Tools - Agent tools for managing anchors
3
- *
4
- * Provides anchor_add and anchor_remove tools that allow
5
- * the agent to add critical context that survives compaction.
6
- */
7
- interface AnchorAddInput {
8
- /** The anchor content - critical information to preserve */
9
- content: string;
10
- /** Priority level: 'critical' | 'safety' | 'info' (default: 'info') */
11
- priority?: 'critical' | 'safety' | 'info';
12
- /** Scope: 'global' or 'project' (default: 'project' if active project, else 'global') */
13
- scope?: 'global' | 'project';
14
- /** Tags for categorization */
15
- tags?: string[];
16
- }
17
- interface AnchorRemoveInput {
18
- /** ID of the anchor to remove */
19
- id: string;
20
- }
21
- interface AnchorListInput {
22
- /** Filter by scope: 'global' | 'project' | 'all' (default: 'all') */
23
- scope?: 'global' | 'project' | 'all';
24
- /** Filter by priority */
25
- priority?: 'critical' | 'safety' | 'info';
26
- }
27
- export declare const anchorAddTool: import("@compilr-dev/sdk").Tool<AnchorAddInput>;
28
- export declare const anchorRemoveTool: import("@compilr-dev/sdk").Tool<AnchorRemoveInput>;
29
- export declare const anchorListTool: import("@compilr-dev/sdk").Tool<AnchorListInput>;
30
- export declare const allAnchorTools: (import("@compilr-dev/sdk").Tool<AnchorAddInput> | import("@compilr-dev/sdk").Tool<AnchorRemoveInput>)[];
31
- export {};
@@ -1,255 +0,0 @@
1
- /**
2
- * Anchor Tools - Agent tools for managing anchors
3
- *
4
- * Provides anchor_add and anchor_remove tools that allow
5
- * the agent to add critical context that survives compaction.
6
- */
7
- import { defineTool } from '@compilr-dev/sdk';
8
- import { getGlobalAnchorManager, getAnchorManager, } from '../anchors/index.js';
9
- import { getActiveProject } from './project-db.js';
10
- // =============================================================================
11
- // anchor_add Tool
12
- // =============================================================================
13
- export const anchorAddTool = defineTool({
14
- name: 'anchor_add',
15
- description: 'Add critical information that must survive context compaction. ' +
16
- 'Use this for: project context, important decisions, user preferences, ' +
17
- 'architectural constraints, or any information that should persist across the entire conversation. ' +
18
- 'Anchors are always included at the top of the context window.',
19
- inputSchema: {
20
- type: 'object',
21
- properties: {
22
- content: {
23
- type: 'string',
24
- description: 'The critical information to preserve. Keep it concise but complete.',
25
- },
26
- priority: {
27
- type: 'string',
28
- enum: ['critical', 'safety', 'info'],
29
- description: 'Priority level. "critical" for must-never-forget info (user preferences, key constraints), ' +
30
- '"safety" for safety-related context, "info" for general helpful context.',
31
- },
32
- scope: {
33
- type: 'string',
34
- enum: ['global', 'project'],
35
- description: 'Scope for the anchor. "global" persists across all projects, ' +
36
- '"project" is specific to the current project (requires active project).',
37
- },
38
- tags: {
39
- type: 'array',
40
- items: { type: 'string' },
41
- description: 'Optional tags for categorization (e.g., ["architecture", "decision"])',
42
- },
43
- },
44
- required: ['content'],
45
- },
46
- execute: (input) => {
47
- try {
48
- // Validate content
49
- if (!input.content || input.content.trim().length === 0) {
50
- return Promise.resolve({
51
- success: false,
52
- error: 'Anchor content is required and cannot be empty',
53
- });
54
- }
55
- const content = input.content.trim();
56
- const priority = input.priority ?? 'info';
57
- const activeProject = getActiveProject();
58
- // Determine scope
59
- let scope = input.scope;
60
- if (!scope) {
61
- scope = activeProject ? 'project' : 'global';
62
- }
63
- // Validate project scope
64
- if (scope === 'project' && !activeProject) {
65
- return Promise.resolve({
66
- success: false,
67
- error: 'Cannot add project-scoped anchor: no active project. Use scope: "global" instead.',
68
- });
69
- }
70
- // Get project ID for project-scoped anchors (validated above that activeProject exists)
71
- const projectId = scope === 'project' && activeProject
72
- ? String(activeProject.id)
73
- : undefined;
74
- // Get the appropriate manager
75
- const manager = scope === 'global'
76
- ? getGlobalAnchorManager()
77
- : getAnchorManager(projectId ?? '');
78
- // Add the anchor
79
- const anchor = manager.add({
80
- content,
81
- priority,
82
- scope: 'persistent', // Anchors persist across sessions
83
- tags: input.tags,
84
- projectId,
85
- });
86
- return Promise.resolve({
87
- success: true,
88
- result: {
89
- id: anchor.id,
90
- content: anchor.content,
91
- priority: anchor.priority,
92
- scope: scope,
93
- tags: anchor.tags,
94
- message: `Anchor added successfully (${scope} scope, ${priority} priority)`,
95
- },
96
- });
97
- }
98
- catch (err) {
99
- return Promise.resolve({
100
- success: false,
101
- error: `Failed to add anchor: ${err instanceof Error ? err.message : String(err)}`,
102
- });
103
- }
104
- },
105
- });
106
- // =============================================================================
107
- // anchor_remove Tool
108
- // =============================================================================
109
- export const anchorRemoveTool = defineTool({
110
- name: 'anchor_remove',
111
- description: 'Remove an anchor by its ID. Use this to clean up outdated or no longer relevant anchors. ' +
112
- 'Use anchor_list first to see available anchors and their IDs.',
113
- inputSchema: {
114
- type: 'object',
115
- properties: {
116
- id: {
117
- type: 'string',
118
- description: 'The ID of the anchor to remove',
119
- },
120
- },
121
- required: ['id'],
122
- },
123
- execute: (input) => {
124
- try {
125
- if (!input.id || input.id.trim().length === 0) {
126
- return Promise.resolve({
127
- success: false,
128
- error: 'Anchor ID is required',
129
- });
130
- }
131
- const id = input.id.trim();
132
- const activeProject = getActiveProject();
133
- // Try to remove from project anchors first, then global
134
- let removed = false;
135
- let scope = 'unknown';
136
- if (activeProject) {
137
- const projectManager = getAnchorManager(String(activeProject.id));
138
- if (projectManager.has(id)) {
139
- removed = projectManager.remove(id);
140
- scope = 'project';
141
- }
142
- }
143
- if (!removed) {
144
- const globalManager = getGlobalAnchorManager();
145
- if (globalManager.has(id)) {
146
- removed = globalManager.remove(id);
147
- scope = 'global';
148
- }
149
- }
150
- if (!removed) {
151
- return Promise.resolve({
152
- success: false,
153
- error: `Anchor with ID "${id}" not found`,
154
- });
155
- }
156
- return Promise.resolve({
157
- success: true,
158
- result: {
159
- id,
160
- scope,
161
- message: `Anchor removed successfully (was ${scope} scope)`,
162
- },
163
- });
164
- }
165
- catch (err) {
166
- return Promise.resolve({
167
- success: false,
168
- error: `Failed to remove anchor: ${err instanceof Error ? err.message : String(err)}`,
169
- });
170
- }
171
- },
172
- });
173
- // =============================================================================
174
- // anchor_list Tool
175
- // =============================================================================
176
- export const anchorListTool = defineTool({
177
- name: 'anchor_list',
178
- description: 'List all anchors. Returns anchor IDs, content, priority, and scope. ' +
179
- 'Use this to see what persistent context is available before adding or removing anchors.',
180
- inputSchema: {
181
- type: 'object',
182
- properties: {
183
- scope: {
184
- type: 'string',
185
- enum: ['global', 'project', 'all'],
186
- description: 'Filter by scope: "global", "project", or "all" (default: "all")',
187
- },
188
- priority: {
189
- type: 'string',
190
- enum: ['critical', 'safety', 'info'],
191
- description: 'Filter by priority level',
192
- },
193
- },
194
- },
195
- execute: (input) => {
196
- try {
197
- const activeProject = getActiveProject();
198
- const scope = input.scope ?? 'all';
199
- const anchors = [];
200
- // Collect global anchors
201
- if (scope === 'global' || scope === 'all') {
202
- const globalManager = getGlobalAnchorManager();
203
- const globalAnchors = globalManager.getAll({ priority: input.priority });
204
- for (const anchor of globalAnchors) {
205
- anchors.push({
206
- id: anchor.id,
207
- content: anchor.content,
208
- priority: anchor.priority,
209
- scope: 'global',
210
- tags: anchor.tags,
211
- });
212
- }
213
- }
214
- // Collect project anchors
215
- if ((scope === 'project' || scope === 'all') && activeProject) {
216
- const projectManager = getAnchorManager(String(activeProject.id));
217
- const projectAnchors = projectManager.getAll({ priority: input.priority });
218
- for (const anchor of projectAnchors) {
219
- anchors.push({
220
- id: anchor.id,
221
- content: anchor.content,
222
- priority: anchor.priority,
223
- scope: 'project',
224
- tags: anchor.tags,
225
- });
226
- }
227
- }
228
- // Sort by priority (critical first)
229
- const priorityOrder = { critical: 0, safety: 1, info: 2 };
230
- anchors.sort((a, b) => {
231
- const pa = priorityOrder[a.priority] ?? 2;
232
- const pb = priorityOrder[b.priority] ?? 2;
233
- return pa - pb;
234
- });
235
- return Promise.resolve({
236
- success: true,
237
- result: {
238
- count: anchors.length,
239
- activeProject: activeProject?.displayName ?? null,
240
- anchors,
241
- },
242
- });
243
- }
244
- catch (err) {
245
- return Promise.resolve({
246
- success: false,
247
- error: `Failed to list anchors: ${err instanceof Error ? err.message : String(err)}`,
248
- });
249
- }
250
- },
251
- });
252
- // =============================================================================
253
- // Export all anchor tools
254
- // =============================================================================
255
- export const allAnchorTools = [anchorAddTool, anchorRemoveTool, anchorListTool];
@@ -1,42 +0,0 @@
1
- /**
2
- * Artifact Tools
3
- *
4
- * Tools for managing team artifacts - named pieces of work that agents
5
- * can publish and reference across the team.
6
- *
7
- * Artifact types:
8
- * - design: Architecture, API specs, data models
9
- * - plan: Sprint plans, task breakdowns, timelines
10
- * - review: Code reviews, security audits, feedback
11
- * - decision: Architectural decisions, trade-off analysis
12
- * - note: General notes, meeting summaries
13
- */
14
- export declare const artifactSaveTool: import("@compilr-dev/sdk").Tool<{
15
- name: string;
16
- type: string;
17
- content: string;
18
- summary?: string;
19
- agent?: string;
20
- }>;
21
- export declare const artifactGetTool: import("@compilr-dev/sdk").Tool<{
22
- name: string;
23
- }>;
24
- export declare const artifactListTool: import("@compilr-dev/sdk").Tool<{
25
- type?: string;
26
- agent?: string;
27
- search?: string;
28
- }>;
29
- export declare const artifactDeleteTool: import("@compilr-dev/sdk").Tool<{
30
- name: string;
31
- }>;
32
- export declare const allArtifactTools: (import("@compilr-dev/sdk").Tool<{
33
- name: string;
34
- type: string;
35
- content: string;
36
- summary?: string;
37
- agent?: string;
38
- }> | import("@compilr-dev/sdk").Tool<{
39
- type?: string;
40
- agent?: string;
41
- search?: string;
42
- }>)[];