@compilr-dev/cli 0.4.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.
Files changed (152) hide show
  1. package/README.md +110 -0
  2. package/dist/agent.d.ts +62 -0
  3. package/dist/agent.js +317 -0
  4. package/dist/agents/registry.d.ts +66 -0
  5. package/dist/agents/registry.js +238 -0
  6. package/dist/agents/types.d.ts +40 -0
  7. package/dist/agents/types.js +94 -0
  8. package/dist/commands/custom-registry.d.ts +69 -0
  9. package/dist/commands/custom-registry.js +246 -0
  10. package/dist/commands/index.d.ts +7 -0
  11. package/dist/commands/index.js +7 -0
  12. package/dist/commands/types.d.ts +31 -0
  13. package/dist/commands/types.js +26 -0
  14. package/dist/commands.d.ts +63 -0
  15. package/dist/commands.js +324 -0
  16. package/dist/db/index.d.ts +42 -0
  17. package/dist/db/index.js +146 -0
  18. package/dist/db/repositories/document-repository.d.ts +63 -0
  19. package/dist/db/repositories/document-repository.js +184 -0
  20. package/dist/db/repositories/index.d.ts +9 -0
  21. package/dist/db/repositories/index.js +6 -0
  22. package/dist/db/repositories/project-repository.d.ts +132 -0
  23. package/dist/db/repositories/project-repository.js +337 -0
  24. package/dist/db/repositories/work-item-repository.d.ts +115 -0
  25. package/dist/db/repositories/work-item-repository.js +389 -0
  26. package/dist/db/schema.d.ts +83 -0
  27. package/dist/db/schema.js +143 -0
  28. package/dist/debug.d.ts +8 -0
  29. package/dist/debug.js +48 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +348 -0
  32. package/dist/index.old.d.ts +7 -0
  33. package/dist/index.old.js +1014 -0
  34. package/dist/repl.d.ts +121 -0
  35. package/dist/repl.js +1878 -0
  36. package/dist/settings/index.d.ts +80 -0
  37. package/dist/settings/index.js +195 -0
  38. package/dist/shared-handlers.d.ts +63 -0
  39. package/dist/shared-handlers.js +57 -0
  40. package/dist/slash-autocomplete.d.ts +41 -0
  41. package/dist/slash-autocomplete.js +638 -0
  42. package/dist/state.d.ts +75 -0
  43. package/dist/state.js +130 -0
  44. package/dist/tabbed-menu.d.ts +11 -0
  45. package/dist/tabbed-menu.js +328 -0
  46. package/dist/templates/backlog-md.d.ts +7 -0
  47. package/dist/templates/backlog-md.js +94 -0
  48. package/dist/templates/claude-md.d.ts +7 -0
  49. package/dist/templates/claude-md.js +189 -0
  50. package/dist/templates/coding-standards.d.ts +7 -0
  51. package/dist/templates/coding-standards.js +299 -0
  52. package/dist/templates/compilr-md.d.ts +7 -0
  53. package/dist/templates/compilr-md.js +189 -0
  54. package/dist/templates/config-json.d.ts +38 -0
  55. package/dist/templates/config-json.js +39 -0
  56. package/dist/templates/gitignore.d.ts +7 -0
  57. package/dist/templates/gitignore.js +85 -0
  58. package/dist/templates/index.d.ts +19 -0
  59. package/dist/templates/index.js +302 -0
  60. package/dist/templates/package-json.d.ts +7 -0
  61. package/dist/templates/package-json.js +111 -0
  62. package/dist/templates/readme-md.d.ts +7 -0
  63. package/dist/templates/readme-md.js +161 -0
  64. package/dist/templates/tsconfig.d.ts +7 -0
  65. package/dist/templates/tsconfig.js +61 -0
  66. package/dist/templates/types.d.ts +33 -0
  67. package/dist/templates/types.js +24 -0
  68. package/dist/test-autocomplete.d.ts +7 -0
  69. package/dist/test-autocomplete.js +85 -0
  70. package/dist/test-tabbed-menu.d.ts +7 -0
  71. package/dist/test-tabbed-menu.js +25 -0
  72. package/dist/themes/colors.d.ts +49 -0
  73. package/dist/themes/colors.js +135 -0
  74. package/dist/themes/index.d.ts +23 -0
  75. package/dist/themes/index.js +24 -0
  76. package/dist/themes/registry.d.ts +60 -0
  77. package/dist/themes/registry.js +195 -0
  78. package/dist/themes/types.d.ts +82 -0
  79. package/dist/themes/types.js +7 -0
  80. package/dist/tool-selector.d.ts +71 -0
  81. package/dist/tool-selector.js +184 -0
  82. package/dist/tools/ask-user-simple.d.ts +19 -0
  83. package/dist/tools/ask-user-simple.js +86 -0
  84. package/dist/tools/ask-user.d.ts +32 -0
  85. package/dist/tools/ask-user.js +113 -0
  86. package/dist/tools/backlog.d.ts +53 -0
  87. package/dist/tools/backlog.js +709 -0
  88. package/dist/tools.d.ts +15 -0
  89. package/dist/tools.js +121 -0
  90. package/dist/ui/agents-overlay.d.ts +12 -0
  91. package/dist/ui/agents-overlay.js +501 -0
  92. package/dist/ui/arch-type-overlay.d.ts +20 -0
  93. package/dist/ui/arch-type-overlay.js +229 -0
  94. package/dist/ui/ask-user-overlay.d.ts +26 -0
  95. package/dist/ui/ask-user-overlay.js +647 -0
  96. package/dist/ui/ask-user-simple-overlay.d.ts +25 -0
  97. package/dist/ui/ask-user-simple-overlay.js +242 -0
  98. package/dist/ui/backlog-overlay.d.ts +17 -0
  99. package/dist/ui/backlog-overlay.js +786 -0
  100. package/dist/ui/commands-overlay.d.ts +11 -0
  101. package/dist/ui/commands-overlay.js +410 -0
  102. package/dist/ui/config-overlay.d.ts +34 -0
  103. package/dist/ui/config-overlay.js +977 -0
  104. package/dist/ui/conversation.d.ts +82 -0
  105. package/dist/ui/conversation.js +508 -0
  106. package/dist/ui/diff.d.ts +38 -0
  107. package/dist/ui/diff.js +182 -0
  108. package/dist/ui/ephemeral.d.ts +111 -0
  109. package/dist/ui/ephemeral.js +413 -0
  110. package/dist/ui/file-autocomplete.d.ts +45 -0
  111. package/dist/ui/file-autocomplete.js +237 -0
  112. package/dist/ui/footer.d.ts +153 -0
  113. package/dist/ui/footer.js +422 -0
  114. package/dist/ui/index.d.ts +12 -0
  115. package/dist/ui/index.js +15 -0
  116. package/dist/ui/init-overlay.d.ts +24 -0
  117. package/dist/ui/init-overlay.js +525 -0
  118. package/dist/ui/input-prompt-v2.d.ts +179 -0
  119. package/dist/ui/input-prompt-v2.js +991 -0
  120. package/dist/ui/input-prompt.d.ts +97 -0
  121. package/dist/ui/input-prompt.js +800 -0
  122. package/dist/ui/iteration-limit-overlay.d.ts +21 -0
  123. package/dist/ui/iteration-limit-overlay.js +150 -0
  124. package/dist/ui/keys-overlay.d.ts +14 -0
  125. package/dist/ui/keys-overlay.js +181 -0
  126. package/dist/ui/model-warning-overlay.d.ts +30 -0
  127. package/dist/ui/model-warning-overlay.js +171 -0
  128. package/dist/ui/overlay-controller.d.ts +25 -0
  129. package/dist/ui/overlay-controller.js +35 -0
  130. package/dist/ui/overlays.d.ts +47 -0
  131. package/dist/ui/overlays.js +627 -0
  132. package/dist/ui/permission-overlay.d.ts +16 -0
  133. package/dist/ui/permission-overlay.js +494 -0
  134. package/dist/ui/terminal.d.ts +117 -0
  135. package/dist/ui/terminal.js +237 -0
  136. package/dist/ui/todo-zone.d.ts +112 -0
  137. package/dist/ui/todo-zone.js +353 -0
  138. package/dist/ui/tools-overlay.d.ts +26 -0
  139. package/dist/ui/tools-overlay.js +278 -0
  140. package/dist/ui/tutorial-overlay.d.ts +10 -0
  141. package/dist/ui/tutorial-overlay.js +936 -0
  142. package/dist/ui/types.d.ts +103 -0
  143. package/dist/ui/types.js +33 -0
  144. package/dist/utils/credentials.d.ts +55 -0
  145. package/dist/utils/credentials.js +268 -0
  146. package/dist/utils/model-tiers.d.ts +37 -0
  147. package/dist/utils/model-tiers.js +118 -0
  148. package/dist/utils/project-memory.d.ts +47 -0
  149. package/dist/utils/project-memory.js +117 -0
  150. package/dist/utils/project-status.d.ts +56 -0
  151. package/dist/utils/project-status.js +237 -0
  152. package/package.json +66 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Document Repository
3
+ *
4
+ * Handles all database operations for project documents (PRD, architecture, etc.).
5
+ */
6
+ import type { DocumentType } from '../schema.js';
7
+ export interface CreateDocumentInput {
8
+ project_id: number;
9
+ doc_type: DocumentType;
10
+ title: string;
11
+ content: string;
12
+ }
13
+ export interface UpdateDocumentInput {
14
+ title?: string;
15
+ content?: string;
16
+ }
17
+ export interface ProjectDocument {
18
+ id: number;
19
+ projectId: number;
20
+ docType: DocumentType;
21
+ title: string;
22
+ content: string;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ }
26
+ export declare const documentRepository: {
27
+ /**
28
+ * Create or update a document (upsert by project_id + doc_type)
29
+ */
30
+ upsert(input: CreateDocumentInput): ProjectDocument;
31
+ /**
32
+ * Create a new document
33
+ */
34
+ create(input: CreateDocumentInput): ProjectDocument;
35
+ /**
36
+ * Get document by ID
37
+ */
38
+ getById(id: number): ProjectDocument | null;
39
+ /**
40
+ * Get document by project and type
41
+ */
42
+ getByType(projectId: number, docType: DocumentType): ProjectDocument | null;
43
+ /**
44
+ * List all documents for a project
45
+ */
46
+ listByProject(projectId: number): ProjectDocument[];
47
+ /**
48
+ * Update a document
49
+ */
50
+ update(id: number, input: UpdateDocumentInput): ProjectDocument | null;
51
+ /**
52
+ * Delete a document
53
+ */
54
+ delete(id: number): boolean;
55
+ /**
56
+ * Delete all documents of a type for a project
57
+ */
58
+ deleteByType(projectId: number, docType: DocumentType): boolean;
59
+ /**
60
+ * Get document counts by type for a project
61
+ */
62
+ getTypeCounts(projectId: number): Record<DocumentType, number>;
63
+ };
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Document Repository
3
+ *
4
+ * Handles all database operations for project documents (PRD, architecture, etc.).
5
+ */
6
+ import { getDb } from '../index.js';
7
+ /**
8
+ * Convert database record to ProjectDocument object
9
+ */
10
+ function recordToDocument(record) {
11
+ return {
12
+ id: record.id,
13
+ projectId: record.project_id,
14
+ docType: record.doc_type,
15
+ title: record.title,
16
+ content: record.content,
17
+ createdAt: new Date(record.created_at),
18
+ updatedAt: new Date(record.updated_at),
19
+ };
20
+ }
21
+ export const documentRepository = {
22
+ /**
23
+ * Create or update a document (upsert by project_id + doc_type)
24
+ */
25
+ upsert(input) {
26
+ const db = getDb();
27
+ const now = new Date().toISOString();
28
+ // Check if document exists
29
+ const existing = this.getByType(input.project_id, input.doc_type);
30
+ if (existing) {
31
+ // Update existing document
32
+ db.prepare(`
33
+ UPDATE project_documents
34
+ SET title = ?, content = ?, updated_at = ?
35
+ WHERE id = ?
36
+ `).run(input.title, input.content, now, existing.id);
37
+ const doc = this.getById(existing.id);
38
+ if (!doc)
39
+ throw new Error('Failed to update document');
40
+ return doc;
41
+ }
42
+ // Create new document
43
+ const result = db
44
+ .prepare(`
45
+ INSERT INTO project_documents (
46
+ project_id, doc_type, title, content, created_at, updated_at
47
+ ) VALUES (?, ?, ?, ?, ?, ?)
48
+ `)
49
+ .run(input.project_id, input.doc_type, input.title, input.content, now, now);
50
+ const doc = this.getById(Number(result.lastInsertRowid));
51
+ if (!doc)
52
+ throw new Error('Failed to create document');
53
+ return doc;
54
+ },
55
+ /**
56
+ * Create a new document
57
+ */
58
+ create(input) {
59
+ const db = getDb();
60
+ const now = new Date().toISOString();
61
+ const result = db
62
+ .prepare(`
63
+ INSERT INTO project_documents (
64
+ project_id, doc_type, title, content, created_at, updated_at
65
+ ) VALUES (?, ?, ?, ?, ?, ?)
66
+ `)
67
+ .run(input.project_id, input.doc_type, input.title, input.content, now, now);
68
+ const doc = this.getById(Number(result.lastInsertRowid));
69
+ if (!doc)
70
+ throw new Error('Failed to create document');
71
+ return doc;
72
+ },
73
+ /**
74
+ * Get document by ID
75
+ */
76
+ getById(id) {
77
+ const db = getDb();
78
+ const record = db
79
+ .prepare('SELECT * FROM project_documents WHERE id = ?')
80
+ .get(id);
81
+ return record ? recordToDocument(record) : null;
82
+ },
83
+ /**
84
+ * Get document by project and type
85
+ */
86
+ getByType(projectId, docType) {
87
+ const db = getDb();
88
+ const record = db
89
+ .prepare('SELECT * FROM project_documents WHERE project_id = ? AND doc_type = ?')
90
+ .get(projectId, docType);
91
+ return record ? recordToDocument(record) : null;
92
+ },
93
+ /**
94
+ * List all documents for a project
95
+ */
96
+ listByProject(projectId) {
97
+ const db = getDb();
98
+ const records = db
99
+ .prepare(`
100
+ SELECT * FROM project_documents
101
+ WHERE project_id = ?
102
+ ORDER BY
103
+ CASE doc_type
104
+ WHEN 'prd' THEN 1
105
+ WHEN 'architecture' THEN 2
106
+ WHEN 'design' THEN 3
107
+ WHEN 'notes' THEN 4
108
+ ELSE 5
109
+ END,
110
+ created_at ASC
111
+ `)
112
+ .all(projectId);
113
+ return records.map(recordToDocument);
114
+ },
115
+ /**
116
+ * Update a document
117
+ */
118
+ update(id, input) {
119
+ const db = getDb();
120
+ const updates = [];
121
+ const params = [];
122
+ if (input.title !== undefined) {
123
+ updates.push('title = ?');
124
+ params.push(input.title);
125
+ }
126
+ if (input.content !== undefined) {
127
+ updates.push('content = ?');
128
+ params.push(input.content);
129
+ }
130
+ if (updates.length === 0) {
131
+ return this.getById(id);
132
+ }
133
+ updates.push('updated_at = ?');
134
+ params.push(new Date().toISOString());
135
+ params.push(id);
136
+ const query = `UPDATE project_documents SET ${updates.join(', ')} WHERE id = ?`;
137
+ db.prepare(query).run(...params);
138
+ return this.getById(id);
139
+ },
140
+ /**
141
+ * Delete a document
142
+ */
143
+ delete(id) {
144
+ const db = getDb();
145
+ const result = db
146
+ .prepare('DELETE FROM project_documents WHERE id = ?')
147
+ .run(id);
148
+ return result.changes > 0;
149
+ },
150
+ /**
151
+ * Delete all documents of a type for a project
152
+ */
153
+ deleteByType(projectId, docType) {
154
+ const db = getDb();
155
+ const result = db
156
+ .prepare('DELETE FROM project_documents WHERE project_id = ? AND doc_type = ?')
157
+ .run(projectId, docType);
158
+ return result.changes > 0;
159
+ },
160
+ /**
161
+ * Get document counts by type for a project
162
+ */
163
+ getTypeCounts(projectId) {
164
+ const db = getDb();
165
+ const results = db
166
+ .prepare(`
167
+ SELECT doc_type, COUNT(*) as count
168
+ FROM project_documents
169
+ WHERE project_id = ?
170
+ GROUP BY doc_type
171
+ `)
172
+ .all(projectId);
173
+ const counts = {
174
+ prd: 0,
175
+ architecture: 0,
176
+ design: 0,
177
+ notes: 0,
178
+ };
179
+ for (const row of results) {
180
+ counts[row.doc_type] = row.count;
181
+ }
182
+ return counts;
183
+ },
184
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Repository exports
3
+ */
4
+ export { projectRepository } from './project-repository.js';
5
+ export type { CreateProjectInput, UpdateProjectInput, Project, } from './project-repository.js';
6
+ export { workItemRepository } from './work-item-repository.js';
7
+ export type { CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, WorkItem, } from './work-item-repository.js';
8
+ export { documentRepository } from './document-repository.js';
9
+ export type { CreateDocumentInput, UpdateDocumentInput, ProjectDocument, } from './document-repository.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Repository exports
3
+ */
4
+ export { projectRepository } from './project-repository.js';
5
+ export { workItemRepository } from './work-item-repository.js';
6
+ export { documentRepository } from './document-repository.js';
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Project Repository
3
+ *
4
+ * Handles all database operations for projects.
5
+ */
6
+ import type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState } from '../schema.js';
7
+ export interface CreateProjectInput {
8
+ name: string;
9
+ display_name: string;
10
+ description?: string;
11
+ type?: ProjectType;
12
+ path: string;
13
+ docs_path?: string;
14
+ repo_pattern?: RepoPattern;
15
+ language?: string;
16
+ framework?: string;
17
+ package_manager?: string;
18
+ runtime_version?: string;
19
+ commands?: Record<string, string>;
20
+ git_remote?: string;
21
+ git_branch?: string;
22
+ workflow_mode?: WorkflowMode;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ export interface UpdateProjectInput {
26
+ display_name?: string;
27
+ description?: string;
28
+ type?: ProjectType;
29
+ status?: ProjectStatus;
30
+ docs_path?: string;
31
+ repo_pattern?: RepoPattern;
32
+ language?: string;
33
+ framework?: string;
34
+ package_manager?: string;
35
+ runtime_version?: string;
36
+ commands?: Record<string, string>;
37
+ git_remote?: string;
38
+ git_branch?: string;
39
+ workflow_mode?: WorkflowMode;
40
+ lifecycle_state?: LifecycleState;
41
+ current_item_id?: string | null;
42
+ last_context?: Record<string, unknown>;
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ export interface Project {
46
+ id: number;
47
+ name: string;
48
+ displayName: string;
49
+ description: string | null;
50
+ type: ProjectType;
51
+ status: ProjectStatus;
52
+ path: string;
53
+ docsPath: string | null;
54
+ repoPattern: RepoPattern;
55
+ language: string | null;
56
+ framework: string | null;
57
+ packageManager: string | null;
58
+ runtimeVersion: string | null;
59
+ commands: Record<string, string> | null;
60
+ gitRemote: string | null;
61
+ gitBranch: string;
62
+ workflowMode: WorkflowMode;
63
+ lifecycleState: LifecycleState;
64
+ currentItemId: string | null;
65
+ lastContext: Record<string, unknown> | null;
66
+ metadata: Record<string, unknown> | null;
67
+ createdAt: Date;
68
+ updatedAt: Date;
69
+ lastActivityAt: Date | null;
70
+ }
71
+ export declare const projectRepository: {
72
+ /**
73
+ * Create a new project
74
+ */
75
+ create(input: CreateProjectInput): Project;
76
+ /**
77
+ * Get project by ID
78
+ */
79
+ getById(id: number): Project | null;
80
+ /**
81
+ * Get project by name
82
+ */
83
+ getByName(name: string): Project | null;
84
+ /**
85
+ * Get project by path (code repo)
86
+ */
87
+ getByPath(projectPath: string): Project | null;
88
+ /**
89
+ * Get project by docs path (for two-repo pattern)
90
+ */
91
+ getByDocsPath(docsPath: string): Project | null;
92
+ /**
93
+ * Find project by path (checks both path and docs_path, including parent directories)
94
+ */
95
+ findByPath(searchPath: string): Project | null;
96
+ /**
97
+ * List projects with optional filters
98
+ */
99
+ list(options?: {
100
+ status?: ProjectStatus | "all";
101
+ type?: ProjectType | "all";
102
+ limit?: number;
103
+ offset?: number;
104
+ }): {
105
+ projects: Project[];
106
+ total: number;
107
+ };
108
+ /**
109
+ * Update a project
110
+ */
111
+ update(id: number, input: UpdateProjectInput): Project | null;
112
+ /**
113
+ * Update last activity timestamp
114
+ */
115
+ touch(id: number): void;
116
+ /**
117
+ * Delete a project (cascades to work_items, documents, history)
118
+ */
119
+ delete(id: number): boolean;
120
+ /**
121
+ * Archive a project (set status to 'archived')
122
+ */
123
+ archive(id: number): Project | null;
124
+ /**
125
+ * Check if a project name is available
126
+ */
127
+ isNameAvailable(name: string, excludeId?: number): boolean;
128
+ /**
129
+ * Get project counts by status
130
+ */
131
+ getStatusCounts(): Record<ProjectStatus, number>;
132
+ };