@compilr-dev/sdk 0.2.13 → 0.2.14
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/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/platform/context.d.ts +2 -1
- package/dist/platform/index.d.ts +4 -4
- package/dist/platform/index.js +1 -1
- package/dist/platform/repositories.d.ts +9 -1
- package/dist/platform/sqlite/comment-repository.d.ts +16 -0
- package/dist/platform/sqlite/comment-repository.js +62 -0
- package/dist/platform/sqlite/db.js +18 -0
- package/dist/platform/sqlite/index.d.ts +4 -2
- package/dist/platform/sqlite/index.js +3 -0
- package/dist/platform/sqlite/schema.d.ts +11 -2
- package/dist/platform/sqlite/schema.js +16 -1
- package/dist/platform/tools/index.d.ts +2 -2
- package/dist/platform/tools/index.js +2 -2
- package/dist/platform/tools/workitem-tools.d.ts +7 -3
- package/dist/platform/tools/workitem-tools.js +67 -3
- package/dist/platform/types.d.ts +18 -0
- package/dist/system-prompt/builder.d.ts +2 -0
- package/dist/system-prompt/index.d.ts +1 -1
- package/dist/system-prompt/index.js +1 -1
- package/dist/system-prompt/modules.d.ts +9 -0
- package/dist/system-prompt/modules.js +58 -0
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -51,12 +51,12 @@ export { MetaToolsRegistry, createMetaTools, META_TOOLS_SYSTEM_PROMPT_PREFIX, }
|
|
|
51
51
|
export type { MetaToolStats, MetaTools, FallbackOptions } from './meta-tools/index.js';
|
|
52
52
|
export { CapabilityManager, CAPABILITY_PACKS, FORBIDDEN_PACK_SUGGESTIONS, getPackCount, getAllPackIds, createLoadCapabilityTool, generateCapabilityCatalog, } from './capabilities/index.js';
|
|
53
53
|
export type { CapabilityPack, CapabilityTier, LoadedCapability, CapabilityCatalogEntry, CapabilityLoadResult, CapabilityManagerConfig, } from './capabilities/index.js';
|
|
54
|
-
export { SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats, ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './system-prompt/index.js';
|
|
54
|
+
export { SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats, ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, VISUAL_OUTPUT_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './system-prompt/index.js';
|
|
55
55
|
export type { SystemPromptContext, BuildResult, SystemPromptModule, ModuleConditions, } from './system-prompt/index.js';
|
|
56
|
-
export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState, WorkItemType, WorkItemStatus, WorkItemPriority, GuidedStep, DocumentType, PlanStatus, Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, PlatformContext, PlatformToolsConfig, PlatformHooks, StepCriteria, } from './platform/index.js';
|
|
57
|
-
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
|
|
58
|
-
export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, } from './platform/index.js';
|
|
59
|
-
export { createAskUserTool, createAskUserSimpleTool
|
|
56
|
+
export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState, WorkItemType, WorkItemStatus, WorkItemPriority, GuidedStep, DocumentType, PlanStatus, Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, WorkItemComment, CreateCommentInput, UpdateCommentInput, IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository, IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, PlatformContext, PlatformToolsConfig, PlatformHooks, StepCriteria, } from './platform/index.js';
|
|
57
|
+
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
|
|
58
|
+
export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, WorkItemCommentRecord, } from './platform/index.js';
|
|
59
|
+
export { createAskUserTool, createAskUserSimpleTool } from './tools/index.js';
|
|
60
60
|
export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './tools/index.js';
|
|
61
61
|
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, ProjectAnchorStore, } from './platform/index.js';
|
|
62
62
|
export type { ProjectAnchorStoreConfig } from './platform/index.js';
|
package/dist/index.js
CHANGED
|
@@ -109,17 +109,17 @@ export {
|
|
|
109
109
|
// Builder
|
|
110
110
|
SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats,
|
|
111
111
|
// Module constants
|
|
112
|
-
ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, ENVIRONMENT_MODULE,
|
|
112
|
+
ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, VISUAL_OUTPUT_MODULE, ENVIRONMENT_MODULE,
|
|
113
113
|
// Module utilities
|
|
114
114
|
shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './system-prompt/index.js';
|
|
115
115
|
// =============================================================================
|
|
116
116
|
// Platform SQLite Repositories (concrete implementations)
|
|
117
117
|
// =============================================================================
|
|
118
|
-
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
|
|
118
|
+
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './platform/index.js';
|
|
119
119
|
// =============================================================================
|
|
120
120
|
// User Interaction Tools (ask_user, ask_user_simple)
|
|
121
121
|
// =============================================================================
|
|
122
|
-
export { createAskUserTool, createAskUserSimpleTool
|
|
122
|
+
export { createAskUserTool, createAskUserSimpleTool } from './tools/index.js';
|
|
123
123
|
// =============================================================================
|
|
124
124
|
// Platform Tools (runtime — createPlatformTools factory + individual factories)
|
|
125
125
|
// =============================================================================
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides a single entry point for data access, abstracting over the
|
|
5
5
|
* underlying storage backend (SQLite in CLI, PostgreSQL in web/API).
|
|
6
6
|
*/
|
|
7
|
-
import type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository } from './repositories.js';
|
|
7
|
+
import type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository } from './repositories.js';
|
|
8
8
|
import type { IAnchorService, IArtifactService, IEpisodeService } from './services.js';
|
|
9
9
|
export interface PlatformContext {
|
|
10
10
|
readonly projects: IProjectRepository;
|
|
@@ -15,6 +15,7 @@ export interface PlatformContext {
|
|
|
15
15
|
readonly anchors?: IAnchorService;
|
|
16
16
|
readonly artifacts?: IArtifactService;
|
|
17
17
|
readonly episodes?: IEpisodeService;
|
|
18
|
+
readonly comments?: ICommentRepository;
|
|
18
19
|
}
|
|
19
20
|
export interface PlatformHooks {
|
|
20
21
|
/** Called when a project is resolved/selected as the current project */
|
package/dist/platform/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform — Repository interfaces, data models, tools, and workflow.
|
|
3
3
|
*/
|
|
4
|
-
export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState, WorkItemType, WorkItemStatus, WorkItemPriority, GuidedStep, DocumentType, PlanStatus, Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, } from './types.js';
|
|
5
|
-
export type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, } from './repositories.js';
|
|
4
|
+
export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleState, WorkItemType, WorkItemStatus, WorkItemPriority, GuidedStep, DocumentType, PlanStatus, Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, WorkItemComment, CreateCommentInput, UpdateCommentInput, } from './types.js';
|
|
5
|
+
export type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository, } from './repositories.js';
|
|
6
6
|
export type { IAnchorService, IArtifactService, IEpisodeService, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, } from './services.js';
|
|
7
7
|
export type { PlatformContext, PlatformToolsConfig, PlatformHooks } from './context.js';
|
|
8
8
|
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './tools/index.js';
|
|
9
|
-
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './sqlite/index.js';
|
|
10
|
-
export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, } from './sqlite/index.js';
|
|
9
|
+
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './sqlite/index.js';
|
|
10
|
+
export type { SQLiteRepositories, CreateSQLiteRepositoriesOptions, ProjectDeleteHooks, ProjectRecord, WorkItemRecord, ProjectDocumentRecord, WorkItemCommentRecord, } from './sqlite/index.js';
|
|
11
11
|
export { ProjectAnchorStore } from './file-anchor-service.js';
|
|
12
12
|
export type { ProjectAnchorStoreConfig } from './file-anchor-service.js';
|
|
13
13
|
export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './workflow.js';
|
package/dist/platform/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Platform tools (runtime)
|
|
5
5
|
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, } from './tools/index.js';
|
|
6
6
|
// SQLite implementations (concrete repositories)
|
|
7
|
-
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './sqlite/index.js';
|
|
7
|
+
export { createSQLiteRepositories, SQLiteProjectRepository, SQLiteWorkItemRepository, SQLiteDocumentRepository, SQLitePlanRepository, SQLiteCommentRepository, getDatabase, closeDatabase, closeAllDatabases, databaseExists, SCHEMA_VERSION, SCHEMA_SQL, } from './sqlite/index.js';
|
|
8
8
|
// File-based anchor service (shared by CLI and Desktop)
|
|
9
9
|
export { ProjectAnchorStore } from './file-anchor-service.js';
|
|
10
10
|
// Workflow (pure step-criteria logic)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* uses synchronous SQLite. This ensures compatibility with future async
|
|
6
6
|
* backends (PostgreSQL, HTTP APIs).
|
|
7
7
|
*/
|
|
8
|
-
import type { Project, WorkItem, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, ProjectStatus, WorkItemType, WorkItemStatus, DocumentType, PlanStatus } from './types.js';
|
|
8
|
+
import type { Project, WorkItem, WorkItemComment, ProjectDocument, Plan, PlanSummary, PlanWithWorkItem, HistoryEntry, CreateProjectInput, UpdateProjectInput, ProjectListOptions, CreateWorkItemInput, UpdateWorkItemInput, QueryWorkItemsInput, CreateCommentInput, UpdateCommentInput, CreateDocumentInput, UpdateDocumentInput, CreatePlanInput, UpdatePlanInput, ListPlansOptions, WorkItemQueryResult, ProjectListResult, BulkCreateItem, ProjectStatus, WorkItemType, WorkItemStatus, DocumentType, PlanStatus } from './types.js';
|
|
9
9
|
export interface IProjectRepository {
|
|
10
10
|
create(input: CreateProjectInput): Promise<Project>;
|
|
11
11
|
getById(id: number): Promise<Project | null>;
|
|
@@ -60,3 +60,11 @@ export interface IPlanRepository {
|
|
|
60
60
|
linkWorkItem(planId: number, workItemId: number): Promise<Plan | null>;
|
|
61
61
|
unlinkWorkItem(planId: number): Promise<Plan | null>;
|
|
62
62
|
}
|
|
63
|
+
export interface ICommentRepository {
|
|
64
|
+
create(input: CreateCommentInput): Promise<WorkItemComment>;
|
|
65
|
+
getById(id: number): Promise<WorkItemComment | null>;
|
|
66
|
+
listByWorkItem(workItemId: number): Promise<WorkItemComment[]>;
|
|
67
|
+
update(id: number, input: UpdateCommentInput): Promise<WorkItemComment | null>;
|
|
68
|
+
delete(id: number): Promise<boolean>;
|
|
69
|
+
countByWorkItem(workItemId: number): Promise<number>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Comment Repository — Concrete implementation of ICommentRepository.
|
|
3
|
+
*/
|
|
4
|
+
import type Database from 'better-sqlite3';
|
|
5
|
+
import type { ICommentRepository } from '../repositories.js';
|
|
6
|
+
import type { WorkItemComment, CreateCommentInput, UpdateCommentInput } from '../types.js';
|
|
7
|
+
export declare class SQLiteCommentRepository implements ICommentRepository {
|
|
8
|
+
private readonly db;
|
|
9
|
+
constructor(db: Database.Database);
|
|
10
|
+
create(input: CreateCommentInput): Promise<WorkItemComment>;
|
|
11
|
+
getById(id: number): Promise<WorkItemComment | null>;
|
|
12
|
+
listByWorkItem(workItemId: number): Promise<WorkItemComment[]>;
|
|
13
|
+
update(id: number, input: UpdateCommentInput): Promise<WorkItemComment | null>;
|
|
14
|
+
delete(id: number): Promise<boolean>;
|
|
15
|
+
countByWorkItem(workItemId: number): Promise<number>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Comment Repository — Concrete implementation of ICommentRepository.
|
|
3
|
+
*/
|
|
4
|
+
function recordToComment(record) {
|
|
5
|
+
return {
|
|
6
|
+
id: record.id,
|
|
7
|
+
workItemId: record.work_item_id,
|
|
8
|
+
projectId: record.project_id,
|
|
9
|
+
author: record.author,
|
|
10
|
+
content: record.content,
|
|
11
|
+
createdAt: new Date(record.created_at),
|
|
12
|
+
updatedAt: new Date(record.updated_at),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export class SQLiteCommentRepository {
|
|
16
|
+
db;
|
|
17
|
+
constructor(db) {
|
|
18
|
+
this.db = db;
|
|
19
|
+
}
|
|
20
|
+
async create(input) {
|
|
21
|
+
const result = this.db
|
|
22
|
+
.prepare(`INSERT INTO work_item_comments (work_item_id, project_id, author, content)
|
|
23
|
+
VALUES (@work_item_id, @project_id, @author, @content)`)
|
|
24
|
+
.run({
|
|
25
|
+
work_item_id: input.work_item_id,
|
|
26
|
+
project_id: input.project_id,
|
|
27
|
+
author: input.author,
|
|
28
|
+
content: input.content,
|
|
29
|
+
});
|
|
30
|
+
const record = this.db
|
|
31
|
+
.prepare('SELECT * FROM work_item_comments WHERE id = ?')
|
|
32
|
+
.get(Number(result.lastInsertRowid));
|
|
33
|
+
return Promise.resolve(recordToComment(record));
|
|
34
|
+
}
|
|
35
|
+
async getById(id) {
|
|
36
|
+
const record = this.db.prepare('SELECT * FROM work_item_comments WHERE id = ?').get(id);
|
|
37
|
+
return Promise.resolve(record ? recordToComment(record) : null);
|
|
38
|
+
}
|
|
39
|
+
async listByWorkItem(workItemId) {
|
|
40
|
+
const records = this.db
|
|
41
|
+
.prepare('SELECT * FROM work_item_comments WHERE work_item_id = ? ORDER BY created_at ASC')
|
|
42
|
+
.all(workItemId);
|
|
43
|
+
return Promise.resolve(records.map(recordToComment));
|
|
44
|
+
}
|
|
45
|
+
async update(id, input) {
|
|
46
|
+
this.db
|
|
47
|
+
.prepare(`UPDATE work_item_comments SET content = @content, updated_at = CURRENT_TIMESTAMP WHERE id = @id`)
|
|
48
|
+
.run({ id, content: input.content });
|
|
49
|
+
const record = this.db.prepare('SELECT * FROM work_item_comments WHERE id = ?').get(id);
|
|
50
|
+
return Promise.resolve(record ? recordToComment(record) : null);
|
|
51
|
+
}
|
|
52
|
+
async delete(id) {
|
|
53
|
+
const result = this.db.prepare('DELETE FROM work_item_comments WHERE id = ?').run(id);
|
|
54
|
+
return Promise.resolve(result.changes > 0);
|
|
55
|
+
}
|
|
56
|
+
async countByWorkItem(workItemId) {
|
|
57
|
+
const result = this.db
|
|
58
|
+
.prepare('SELECT COUNT(*) as count FROM work_item_comments WHERE work_item_id = ?')
|
|
59
|
+
.get(workItemId);
|
|
60
|
+
return Promise.resolve(result.count);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -139,4 +139,22 @@ function runMigrations(db, fromVersion, toVersion) {
|
|
|
139
139
|
`);
|
|
140
140
|
db.prepare('INSERT INTO schema_version (version) VALUES (?)').run(6);
|
|
141
141
|
}
|
|
142
|
+
if (fromVersion < 7 && toVersion >= 7) {
|
|
143
|
+
db.exec(`
|
|
144
|
+
CREATE TABLE IF NOT EXISTS work_item_comments (
|
|
145
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
146
|
+
work_item_id INTEGER NOT NULL,
|
|
147
|
+
project_id INTEGER NOT NULL,
|
|
148
|
+
author TEXT NOT NULL,
|
|
149
|
+
content TEXT NOT NULL,
|
|
150
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
151
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
152
|
+
FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE CASCADE,
|
|
153
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
|
|
154
|
+
);
|
|
155
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_comments_work_item ON work_item_comments(work_item_id);
|
|
156
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_comments_project ON work_item_comments(project_id);
|
|
157
|
+
`);
|
|
158
|
+
db.prepare('INSERT INTO schema_version (version) VALUES (?)').run(7);
|
|
159
|
+
}
|
|
142
160
|
}
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type Database from 'better-sqlite3';
|
|
19
19
|
import { type ProjectDeleteHooks } from './project-repository.js';
|
|
20
|
-
import type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository } from '../repositories.js';
|
|
20
|
+
import type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository } from '../repositories.js';
|
|
21
21
|
export interface SQLiteRepositories {
|
|
22
22
|
projects: IProjectRepository;
|
|
23
23
|
workItems: IWorkItemRepository;
|
|
24
24
|
documents: IDocumentRepository;
|
|
25
25
|
plans: IPlanRepository;
|
|
26
|
+
comments: ICommentRepository;
|
|
26
27
|
}
|
|
27
28
|
export interface CreateSQLiteRepositoriesOptions {
|
|
28
29
|
projectDeleteHooks?: ProjectDeleteHooks;
|
|
@@ -35,6 +36,7 @@ export { SQLiteProjectRepository, type ProjectDeleteHooks } from './project-repo
|
|
|
35
36
|
export { SQLiteWorkItemRepository } from './work-item-repository.js';
|
|
36
37
|
export { SQLiteDocumentRepository } from './document-repository.js';
|
|
37
38
|
export { SQLitePlanRepository } from './plan-repository.js';
|
|
39
|
+
export { SQLiteCommentRepository } from './comment-repository.js';
|
|
38
40
|
export { getDatabase, closeDatabase, closeAllDatabases, databaseExists } from './db.js';
|
|
39
41
|
export { SCHEMA_VERSION, SCHEMA_SQL } from './schema.js';
|
|
40
|
-
export type { ProjectRecord, WorkItemRecord, ProjectDocumentRecord } from './schema.js';
|
|
42
|
+
export type { ProjectRecord, WorkItemRecord, ProjectDocumentRecord, WorkItemCommentRecord, } from './schema.js';
|
|
@@ -19,6 +19,7 @@ import { SQLiteProjectRepository } from './project-repository.js';
|
|
|
19
19
|
import { SQLiteWorkItemRepository } from './work-item-repository.js';
|
|
20
20
|
import { SQLiteDocumentRepository } from './document-repository.js';
|
|
21
21
|
import { SQLitePlanRepository } from './plan-repository.js';
|
|
22
|
+
import { SQLiteCommentRepository } from './comment-repository.js';
|
|
22
23
|
/**
|
|
23
24
|
* Create all 4 platform repositories backed by a single SQLite database.
|
|
24
25
|
*/
|
|
@@ -28,6 +29,7 @@ export function createSQLiteRepositories(db, options) {
|
|
|
28
29
|
workItems: new SQLiteWorkItemRepository(db),
|
|
29
30
|
documents: new SQLiteDocumentRepository(db),
|
|
30
31
|
plans: new SQLitePlanRepository(db),
|
|
32
|
+
comments: new SQLiteCommentRepository(db),
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
// Re-export classes for advanced usage
|
|
@@ -35,6 +37,7 @@ export { SQLiteProjectRepository } from './project-repository.js';
|
|
|
35
37
|
export { SQLiteWorkItemRepository } from './work-item-repository.js';
|
|
36
38
|
export { SQLiteDocumentRepository } from './document-repository.js';
|
|
37
39
|
export { SQLitePlanRepository } from './plan-repository.js';
|
|
40
|
+
export { SQLiteCommentRepository } from './comment-repository.js';
|
|
38
41
|
// Re-export database utilities
|
|
39
42
|
export { getDatabase, closeDatabase, closeAllDatabases, databaseExists } from './db.js';
|
|
40
43
|
// Re-export schema (for consumers that need direct access)
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Shared between CLI and Desktop — both access ~/.compilr-dev/projects.db
|
|
5
5
|
* Schema version must be kept in sync across all consumers.
|
|
6
6
|
*/
|
|
7
|
-
export declare const SCHEMA_VERSION =
|
|
8
|
-
export declare const SCHEMA_SQL = "\n-- Schema version tracking\nCREATE TABLE IF NOT EXISTS schema_version (\n version INTEGER PRIMARY KEY,\n applied_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n\n-- Projects table\nCREATE TABLE IF NOT EXISTS projects (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n name TEXT UNIQUE NOT NULL,\n display_name TEXT NOT NULL,\n description TEXT,\n type TEXT DEFAULT 'general',\n status TEXT DEFAULT 'active',\n path TEXT NOT NULL,\n docs_path TEXT,\n repo_pattern TEXT DEFAULT 'single',\n language TEXT,\n framework TEXT,\n package_manager TEXT,\n runtime_version TEXT,\n commands TEXT,\n git_remote TEXT,\n git_branch TEXT DEFAULT 'main',\n workflow_mode TEXT DEFAULT 'flexible',\n lifecycle_state TEXT DEFAULT 'setup',\n current_item_id TEXT,\n last_context TEXT,\n metadata TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n last_activity_at DATETIME\n);\n\n-- Work items (backlog items, tasks, bugs)\nCREATE TABLE IF NOT EXISTS work_items (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n project_id INTEGER NOT NULL,\n item_number INTEGER NOT NULL,\n item_id TEXT NOT NULL,\n type TEXT NOT NULL,\n status TEXT DEFAULT 'backlog',\n priority TEXT DEFAULT 'medium',\n guided_step TEXT,\n owner TEXT,\n title TEXT NOT NULL,\n description TEXT,\n estimated_effort TEXT,\n actual_minutes INTEGER,\n completed_at DATETIME,\n completed_by TEXT,\n commit_hash TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,\n UNIQUE (project_id, item_id)\n);\n\n-- Project documents (PRD, architecture, plans, etc.)\nCREATE TABLE IF NOT EXISTS project_documents (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n project_id INTEGER NOT NULL,\n doc_type TEXT NOT NULL,\n title TEXT NOT NULL,\n content TEXT NOT NULL,\n status TEXT,\n work_item_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,\n FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE SET NULL\n);\n\n-- Work item history (audit trail)\nCREATE TABLE IF NOT EXISTS work_item_history (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n work_item_id INTEGER NOT NULL,\n project_id INTEGER NOT NULL,\n action TEXT NOT NULL,\n old_value TEXT,\n new_value TEXT,\n notes TEXT,\n changed_by TEXT,\n changed_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE CASCADE,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE\n);\n\n-- Indexes\nCREATE INDEX IF NOT EXISTS idx_projects_path ON projects(path);\nCREATE INDEX IF NOT EXISTS idx_projects_docs_path ON projects(docs_path);\nCREATE INDEX IF NOT EXISTS idx_projects_status ON projects(status);\nCREATE INDEX IF NOT EXISTS idx_work_items_project ON work_items(project_id);\nCREATE INDEX IF NOT EXISTS idx_work_items_status ON work_items(status);\nCREATE INDEX IF NOT EXISTS idx_work_items_priority ON work_items(priority);\nCREATE INDEX IF NOT EXISTS idx_work_items_owner ON work_items(owner);\nCREATE INDEX IF NOT EXISTS idx_project_documents_project ON project_documents(project_id);\nCREATE INDEX IF NOT EXISTS idx_project_documents_type ON project_documents(doc_type);\nCREATE INDEX IF NOT EXISTS idx_project_documents_status ON project_documents(status);\nCREATE INDEX IF NOT EXISTS idx_project_documents_work_item ON project_documents(work_item_id);\nCREATE INDEX IF NOT EXISTS idx_work_item_history_item ON work_item_history(work_item_id);\n\n-- Terminal sessions (multi-terminal awareness)\nCREATE TABLE IF NOT EXISTS terminal_sessions (\n id TEXT PRIMARY KEY,\n project_id INTEGER,\n pid INTEGER NOT NULL,\n tty_path TEXT,\n label TEXT,\n started_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n last_heartbeat DATETIME DEFAULT CURRENT_TIMESTAMP,\n active_agent TEXT DEFAULT 'default',\n agents_json TEXT DEFAULT '[]',\n status TEXT DEFAULT 'active',\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL\n);\nCREATE INDEX IF NOT EXISTS idx_terminal_sessions_project ON terminal_sessions(project_id);\nCREATE INDEX IF NOT EXISTS idx_terminal_sessions_status ON terminal_sessions(status);\n\n-- File locks (multi-terminal file lock awareness)\nCREATE TABLE IF NOT EXISTS file_locks (\n path TEXT NOT NULL,\n project_id INTEGER NOT NULL,\n session_id TEXT NOT NULL,\n agent_id TEXT NOT NULL,\n locked_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (path, project_id),\n FOREIGN KEY (session_id) REFERENCES terminal_sessions(id) ON DELETE CASCADE,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE\n);\nCREATE INDEX IF NOT EXISTS idx_file_locks_session ON file_locks(session_id);\n\n-- Session notifications (cross-session notifications)\nCREATE TABLE IF NOT EXISTS session_notifications (\n id TEXT PRIMARY KEY,\n project_id INTEGER NOT NULL,\n from_session_id TEXT NOT NULL,\n to_session_id TEXT,\n type TEXT NOT NULL,\n title TEXT NOT NULL,\n message TEXT,\n payload_json TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n read_at DATETIME,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,\n FOREIGN KEY (from_session_id) REFERENCES terminal_sessions(id) ON DELETE CASCADE\n);\nCREATE INDEX IF NOT EXISTS idx_session_notifications_project ON session_notifications(project_id);\nCREATE INDEX IF NOT EXISTS idx_session_notifications_to_session ON session_notifications(to_session_id);\nCREATE INDEX IF NOT EXISTS idx_session_notifications_unread ON session_notifications(read_at);\n";
|
|
7
|
+
export declare const SCHEMA_VERSION = 7;
|
|
8
|
+
export declare const SCHEMA_SQL = "\n-- Schema version tracking\nCREATE TABLE IF NOT EXISTS schema_version (\n version INTEGER PRIMARY KEY,\n applied_at DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n\n-- Projects table\nCREATE TABLE IF NOT EXISTS projects (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n name TEXT UNIQUE NOT NULL,\n display_name TEXT NOT NULL,\n description TEXT,\n type TEXT DEFAULT 'general',\n status TEXT DEFAULT 'active',\n path TEXT NOT NULL,\n docs_path TEXT,\n repo_pattern TEXT DEFAULT 'single',\n language TEXT,\n framework TEXT,\n package_manager TEXT,\n runtime_version TEXT,\n commands TEXT,\n git_remote TEXT,\n git_branch TEXT DEFAULT 'main',\n workflow_mode TEXT DEFAULT 'flexible',\n lifecycle_state TEXT DEFAULT 'setup',\n current_item_id TEXT,\n last_context TEXT,\n metadata TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n last_activity_at DATETIME\n);\n\n-- Work items (backlog items, tasks, bugs)\nCREATE TABLE IF NOT EXISTS work_items (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n project_id INTEGER NOT NULL,\n item_number INTEGER NOT NULL,\n item_id TEXT NOT NULL,\n type TEXT NOT NULL,\n status TEXT DEFAULT 'backlog',\n priority TEXT DEFAULT 'medium',\n guided_step TEXT,\n owner TEXT,\n title TEXT NOT NULL,\n description TEXT,\n estimated_effort TEXT,\n actual_minutes INTEGER,\n completed_at DATETIME,\n completed_by TEXT,\n commit_hash TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,\n UNIQUE (project_id, item_id)\n);\n\n-- Project documents (PRD, architecture, plans, etc.)\nCREATE TABLE IF NOT EXISTS project_documents (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n project_id INTEGER NOT NULL,\n doc_type TEXT NOT NULL,\n title TEXT NOT NULL,\n content TEXT NOT NULL,\n status TEXT,\n work_item_id INTEGER,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,\n FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE SET NULL\n);\n\n-- Work item history (audit trail)\nCREATE TABLE IF NOT EXISTS work_item_history (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n work_item_id INTEGER NOT NULL,\n project_id INTEGER NOT NULL,\n action TEXT NOT NULL,\n old_value TEXT,\n new_value TEXT,\n notes TEXT,\n changed_by TEXT,\n changed_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE CASCADE,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE\n);\n\n-- Indexes\nCREATE INDEX IF NOT EXISTS idx_projects_path ON projects(path);\nCREATE INDEX IF NOT EXISTS idx_projects_docs_path ON projects(docs_path);\nCREATE INDEX IF NOT EXISTS idx_projects_status ON projects(status);\nCREATE INDEX IF NOT EXISTS idx_work_items_project ON work_items(project_id);\nCREATE INDEX IF NOT EXISTS idx_work_items_status ON work_items(status);\nCREATE INDEX IF NOT EXISTS idx_work_items_priority ON work_items(priority);\nCREATE INDEX IF NOT EXISTS idx_work_items_owner ON work_items(owner);\nCREATE INDEX IF NOT EXISTS idx_project_documents_project ON project_documents(project_id);\nCREATE INDEX IF NOT EXISTS idx_project_documents_type ON project_documents(doc_type);\nCREATE INDEX IF NOT EXISTS idx_project_documents_status ON project_documents(status);\nCREATE INDEX IF NOT EXISTS idx_project_documents_work_item ON project_documents(work_item_id);\nCREATE INDEX IF NOT EXISTS idx_work_item_history_item ON work_item_history(work_item_id);\n\n-- Terminal sessions (multi-terminal awareness)\nCREATE TABLE IF NOT EXISTS terminal_sessions (\n id TEXT PRIMARY KEY,\n project_id INTEGER,\n pid INTEGER NOT NULL,\n tty_path TEXT,\n label TEXT,\n started_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n last_heartbeat DATETIME DEFAULT CURRENT_TIMESTAMP,\n active_agent TEXT DEFAULT 'default',\n agents_json TEXT DEFAULT '[]',\n status TEXT DEFAULT 'active',\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL\n);\nCREATE INDEX IF NOT EXISTS idx_terminal_sessions_project ON terminal_sessions(project_id);\nCREATE INDEX IF NOT EXISTS idx_terminal_sessions_status ON terminal_sessions(status);\n\n-- File locks (multi-terminal file lock awareness)\nCREATE TABLE IF NOT EXISTS file_locks (\n path TEXT NOT NULL,\n project_id INTEGER NOT NULL,\n session_id TEXT NOT NULL,\n agent_id TEXT NOT NULL,\n locked_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (path, project_id),\n FOREIGN KEY (session_id) REFERENCES terminal_sessions(id) ON DELETE CASCADE,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE\n);\nCREATE INDEX IF NOT EXISTS idx_file_locks_session ON file_locks(session_id);\n\n-- Session notifications (cross-session notifications)\nCREATE TABLE IF NOT EXISTS session_notifications (\n id TEXT PRIMARY KEY,\n project_id INTEGER NOT NULL,\n from_session_id TEXT NOT NULL,\n to_session_id TEXT,\n type TEXT NOT NULL,\n title TEXT NOT NULL,\n message TEXT,\n payload_json TEXT,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n read_at DATETIME,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,\n FOREIGN KEY (from_session_id) REFERENCES terminal_sessions(id) ON DELETE CASCADE\n);\nCREATE INDEX IF NOT EXISTS idx_session_notifications_project ON session_notifications(project_id);\nCREATE INDEX IF NOT EXISTS idx_session_notifications_to_session ON session_notifications(to_session_id);\nCREATE INDEX IF NOT EXISTS idx_session_notifications_unread ON session_notifications(read_at);\n\n-- Work item comments\nCREATE TABLE IF NOT EXISTS work_item_comments (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n work_item_id INTEGER NOT NULL,\n project_id INTEGER NOT NULL,\n author TEXT NOT NULL,\n content TEXT NOT NULL,\n created_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE CASCADE,\n FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE\n);\nCREATE INDEX IF NOT EXISTS idx_work_item_comments_work_item ON work_item_comments(work_item_id);\nCREATE INDEX IF NOT EXISTS idx_work_item_comments_project ON work_item_comments(project_id);\n";
|
|
9
9
|
export interface ProjectRecord {
|
|
10
10
|
id: number;
|
|
11
11
|
name: string;
|
|
@@ -63,3 +63,12 @@ export interface ProjectDocumentRecord {
|
|
|
63
63
|
created_at: string;
|
|
64
64
|
updated_at: string;
|
|
65
65
|
}
|
|
66
|
+
export interface WorkItemCommentRecord {
|
|
67
|
+
id: number;
|
|
68
|
+
work_item_id: number;
|
|
69
|
+
project_id: number;
|
|
70
|
+
author: string;
|
|
71
|
+
content: string;
|
|
72
|
+
created_at: string;
|
|
73
|
+
updated_at: string;
|
|
74
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Shared between CLI and Desktop — both access ~/.compilr-dev/projects.db
|
|
5
5
|
* Schema version must be kept in sync across all consumers.
|
|
6
6
|
*/
|
|
7
|
-
export const SCHEMA_VERSION =
|
|
7
|
+
export const SCHEMA_VERSION = 7;
|
|
8
8
|
export const SCHEMA_SQL = `
|
|
9
9
|
-- Schema version tracking
|
|
10
10
|
CREATE TABLE IF NOT EXISTS schema_version (
|
|
@@ -156,4 +156,19 @@ CREATE TABLE IF NOT EXISTS session_notifications (
|
|
|
156
156
|
CREATE INDEX IF NOT EXISTS idx_session_notifications_project ON session_notifications(project_id);
|
|
157
157
|
CREATE INDEX IF NOT EXISTS idx_session_notifications_to_session ON session_notifications(to_session_id);
|
|
158
158
|
CREATE INDEX IF NOT EXISTS idx_session_notifications_unread ON session_notifications(read_at);
|
|
159
|
+
|
|
160
|
+
-- Work item comments
|
|
161
|
+
CREATE TABLE IF NOT EXISTS work_item_comments (
|
|
162
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
163
|
+
work_item_id INTEGER NOT NULL,
|
|
164
|
+
project_id INTEGER NOT NULL,
|
|
165
|
+
author TEXT NOT NULL,
|
|
166
|
+
content TEXT NOT NULL,
|
|
167
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
168
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
169
|
+
FOREIGN KEY (work_item_id) REFERENCES work_items(id) ON DELETE CASCADE,
|
|
170
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
|
|
171
|
+
);
|
|
172
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_comments_work_item ON work_item_comments(work_item_id);
|
|
173
|
+
CREATE INDEX IF NOT EXISTS idx_work_item_comments_project ON work_item_comments(project_id);
|
|
159
174
|
`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Tools — Factory function for all platform tools.
|
|
3
3
|
*
|
|
4
|
-
* Returns up to
|
|
5
|
-
* -
|
|
4
|
+
* Returns up to 33 tool definitions operating against async PlatformContext.
|
|
5
|
+
* - 25 DB tools (always): project, workitem (incl. comment), document, plan, backlog
|
|
6
6
|
* - 3 anchor tools (if ctx.anchors provided)
|
|
7
7
|
* - 4 artifact tools (if ctx.artifacts provided)
|
|
8
8
|
* - 1 episode tool (if ctx.episodes provided)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Tools — Factory function for all platform tools.
|
|
3
3
|
*
|
|
4
|
-
* Returns up to
|
|
5
|
-
* -
|
|
4
|
+
* Returns up to 33 tool definitions operating against async PlatformContext.
|
|
5
|
+
* - 25 DB tools (always): project, workitem (incl. comment), document, plan, backlog
|
|
6
6
|
* - 3 anchor tools (if ctx.anchors provided)
|
|
7
7
|
* - 4 artifact tools (if ctx.artifacts provided)
|
|
8
8
|
* - 1 episode tool (if ctx.episodes provided)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Work Item Tools — CRUD + workflow operations for work items.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 10 tools: workitem_query, workitem_add, workitem_update, workitem_next,
|
|
5
|
+
* workitem_delete, workitem_status_counts, workitem_advance_step,
|
|
6
|
+
* workitem_claim, workitem_handoff, workitem_comment
|
|
7
7
|
*
|
|
8
8
|
* Ported from CLI's src/tools/workitem-db.ts. Key adaptations:
|
|
9
9
|
* - getActiveProject()?.id → ctx.currentProjectId
|
|
@@ -53,4 +53,8 @@ export declare function createWorkItemTools(config: PlatformToolsConfig): (impor
|
|
|
53
53
|
to_agent_id: string;
|
|
54
54
|
notes?: string;
|
|
55
55
|
project_id?: number;
|
|
56
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
57
|
+
item_id: string;
|
|
58
|
+
content: string;
|
|
59
|
+
project_id?: number;
|
|
56
60
|
}>)[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Work Item Tools — CRUD + workflow operations for work items.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 10 tools: workitem_query, workitem_add, workitem_update, workitem_next,
|
|
5
|
+
* workitem_delete, workitem_status_counts, workitem_advance_step,
|
|
6
|
+
* workitem_claim, workitem_handoff, workitem_comment
|
|
7
7
|
*
|
|
8
8
|
* Ported from CLI's src/tools/workitem-db.ts. Key adaptations:
|
|
9
9
|
* - getActiveProject()?.id → ctx.currentProjectId
|
|
@@ -696,6 +696,69 @@ export function createWorkItemTools(config) {
|
|
|
696
696
|
}
|
|
697
697
|
},
|
|
698
698
|
});
|
|
699
|
+
// ---------------------------------------------------------------------------
|
|
700
|
+
// workitem_comment
|
|
701
|
+
// ---------------------------------------------------------------------------
|
|
702
|
+
const workitemCommentTool = defineTool({
|
|
703
|
+
name: 'workitem_comment',
|
|
704
|
+
description: 'Add a comment to a work item. Comments support markdown and are visible in the work item timeline.',
|
|
705
|
+
inputSchema: {
|
|
706
|
+
type: 'object',
|
|
707
|
+
properties: {
|
|
708
|
+
item_id: {
|
|
709
|
+
type: 'string',
|
|
710
|
+
description: 'Work item ID (e.g., "REQ-001", "BUG-002")',
|
|
711
|
+
},
|
|
712
|
+
content: {
|
|
713
|
+
type: 'string',
|
|
714
|
+
description: 'Comment content (supports markdown)',
|
|
715
|
+
},
|
|
716
|
+
project_id: {
|
|
717
|
+
type: 'number',
|
|
718
|
+
description: 'Override active project.',
|
|
719
|
+
},
|
|
720
|
+
},
|
|
721
|
+
required: ['item_id', 'content'],
|
|
722
|
+
},
|
|
723
|
+
execute: async (input) => {
|
|
724
|
+
try {
|
|
725
|
+
const comments = ctx.comments;
|
|
726
|
+
if (!comments) {
|
|
727
|
+
return createErrorResult('Comment service not configured.');
|
|
728
|
+
}
|
|
729
|
+
const projectId = input.project_id ?? ctx.currentProjectId;
|
|
730
|
+
if (!projectId) {
|
|
731
|
+
return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
|
|
732
|
+
}
|
|
733
|
+
const existingItem = await ctx.workItems.getByItemId(projectId, input.item_id);
|
|
734
|
+
if (!existingItem) {
|
|
735
|
+
return createErrorResult(`Work item "${input.item_id}" not found in current project`);
|
|
736
|
+
}
|
|
737
|
+
// Resolve author: use agent identity from hook, or fallback to 'agent'
|
|
738
|
+
const author = hooks?.resolveOwner?.('self') ?? 'agent';
|
|
739
|
+
const comment = await comments.create({
|
|
740
|
+
work_item_id: existingItem.id,
|
|
741
|
+
project_id: projectId,
|
|
742
|
+
author,
|
|
743
|
+
content: input.content,
|
|
744
|
+
});
|
|
745
|
+
return createSuccessResult({
|
|
746
|
+
success: true,
|
|
747
|
+
message: `Comment added to ${input.item_id} by ${author}`,
|
|
748
|
+
comment: {
|
|
749
|
+
id: comment.id,
|
|
750
|
+
workItemId: comment.workItemId,
|
|
751
|
+
author: comment.author,
|
|
752
|
+
content: comment.content,
|
|
753
|
+
createdAt: comment.createdAt.toISOString(),
|
|
754
|
+
},
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
catch (error) {
|
|
758
|
+
return createErrorResult(`Failed to add comment: ${error instanceof Error ? error.message : String(error)}`);
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
});
|
|
699
762
|
return [
|
|
700
763
|
workitemQueryTool,
|
|
701
764
|
workitemAddTool,
|
|
@@ -706,5 +769,6 @@ export function createWorkItemTools(config) {
|
|
|
706
769
|
workitemAdvanceStepTool,
|
|
707
770
|
workitemClaimTool,
|
|
708
771
|
workitemHandoffTool,
|
|
772
|
+
workitemCommentTool,
|
|
709
773
|
];
|
|
710
774
|
}
|
package/dist/platform/types.d.ts
CHANGED
|
@@ -231,3 +231,21 @@ export interface BulkCreateItem {
|
|
|
231
231
|
priority?: WorkItemPriority;
|
|
232
232
|
owner?: string;
|
|
233
233
|
}
|
|
234
|
+
export interface WorkItemComment {
|
|
235
|
+
id: number;
|
|
236
|
+
workItemId: number;
|
|
237
|
+
projectId: number;
|
|
238
|
+
author: string;
|
|
239
|
+
content: string;
|
|
240
|
+
createdAt: Date;
|
|
241
|
+
updatedAt: Date;
|
|
242
|
+
}
|
|
243
|
+
export interface CreateCommentInput {
|
|
244
|
+
work_item_id: number;
|
|
245
|
+
project_id: number;
|
|
246
|
+
author: string;
|
|
247
|
+
content: string;
|
|
248
|
+
}
|
|
249
|
+
export interface UpdateCommentInput {
|
|
250
|
+
content: string;
|
|
251
|
+
}
|
|
@@ -22,6 +22,8 @@ export interface SystemPromptContext {
|
|
|
22
22
|
enableMetaTools?: boolean;
|
|
23
23
|
/** Does the agent have a role-specific identity? (team agents) */
|
|
24
24
|
hasRoleIdentity?: boolean;
|
|
25
|
+
/** Does the client support inline visual output (HTML/SVG preview)? Desktop only. */
|
|
26
|
+
hasVisualOutput?: boolean;
|
|
25
27
|
/** Active project display name (human-readable, e.g. "Hr Manager") */
|
|
26
28
|
projectName?: string;
|
|
27
29
|
/** Active project slug (unique identifier, e.g. "hr-manager") */
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export { SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats, type SystemPromptContext, type BuildResult, } from './builder.js';
|
|
34
|
-
export { ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, type SystemPromptModule, type ModuleConditions, } from './modules.js';
|
|
34
|
+
export { ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, VISUAL_OUTPUT_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, type SystemPromptModule, type ModuleConditions, } from './modules.js';
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export { SystemPromptBuilder, buildSystemPrompt, detectGitRepository, getModuleStats, } from './builder.js';
|
|
34
|
-
export { ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './modules.js';
|
|
34
|
+
export { ALL_MODULES, IDENTITY_MODULE, STYLE_MODULE, TASK_EXECUTION_MODULE, TODO_MANAGEMENT_MODULE, TOOL_USAGE_DIRECT_MODULE, TOOL_USAGE_HINTS_MODULE, PLATFORM_TOOL_HINTS_MODULE, FACTORY_TOOL_HINTS_MODULE, TOOL_USAGE_META_MODULE, DELEGATION_MODULE, GIT_SAFETY_MODULE, SUGGEST_MODULE, IMPORTANT_RULES_MODULE, VISUAL_OUTPUT_MODULE, ENVIRONMENT_MODULE, shouldIncludeModule, getEstimatedTokensForConditions, getTotalEstimatedTokens, } from './modules.js';
|
|
@@ -20,6 +20,8 @@ export interface ModuleConditions {
|
|
|
20
20
|
enableMetaTools?: boolean;
|
|
21
21
|
/** Include only if NO role identity is specified (for default identity module) */
|
|
22
22
|
noRoleIdentity?: boolean;
|
|
23
|
+
/** Include only if visual output is supported (desktop app with inline preview) */
|
|
24
|
+
hasVisualOutput?: boolean;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* A system prompt module
|
|
@@ -109,6 +111,11 @@ export declare const IMPORTANT_RULES_MODULE: SystemPromptModule;
|
|
|
109
111
|
* Current working directory and git config
|
|
110
112
|
* Note: {{PLACEHOLDERS}} are replaced at runtime
|
|
111
113
|
*/
|
|
114
|
+
/**
|
|
115
|
+
* Visual output module — only included when the client supports inline preview
|
|
116
|
+
* (desktop app with HTML/SVG/Mermaid rendering in iframes)
|
|
117
|
+
*/
|
|
118
|
+
export declare const VISUAL_OUTPUT_MODULE: SystemPromptModule;
|
|
112
119
|
export declare const ENVIRONMENT_MODULE: SystemPromptModule;
|
|
113
120
|
/**
|
|
114
121
|
* All modules in the order they should appear in the prompt.
|
|
@@ -128,6 +135,7 @@ export declare function getEstimatedTokensForConditions(conditions: {
|
|
|
128
135
|
mode?: 'flexible' | 'guided' | 'plan';
|
|
129
136
|
hasProject?: boolean;
|
|
130
137
|
hasRoleIdentity?: boolean;
|
|
138
|
+
hasVisualOutput?: boolean;
|
|
131
139
|
}): number;
|
|
132
140
|
/**
|
|
133
141
|
* Check if a module should be included based on conditions
|
|
@@ -138,4 +146,5 @@ export declare function shouldIncludeModule(module: SystemPromptModule, context:
|
|
|
138
146
|
mode?: 'flexible' | 'guided' | 'plan';
|
|
139
147
|
hasProject?: boolean;
|
|
140
148
|
hasRoleIdentity?: boolean;
|
|
149
|
+
hasVisualOutput?: boolean;
|
|
141
150
|
}): boolean;
|
|
@@ -328,6 +328,58 @@ export const IMPORTANT_RULES_MODULE = {
|
|
|
328
328
|
* Current working directory and git config
|
|
329
329
|
* Note: {{PLACEHOLDERS}} are replaced at runtime
|
|
330
330
|
*/
|
|
331
|
+
/**
|
|
332
|
+
* Visual output module — only included when the client supports inline preview
|
|
333
|
+
* (desktop app with HTML/SVG/Mermaid rendering in iframes)
|
|
334
|
+
*/
|
|
335
|
+
export const VISUAL_OUTPUT_MODULE = {
|
|
336
|
+
id: 'visual-output',
|
|
337
|
+
name: 'Visual Output',
|
|
338
|
+
estimatedTokens: 300,
|
|
339
|
+
conditions: {
|
|
340
|
+
hasVisualOutput: true,
|
|
341
|
+
},
|
|
342
|
+
content: `## Visual Output
|
|
343
|
+
|
|
344
|
+
You can render live, interactive previews inline by using fenced code blocks with these languages:
|
|
345
|
+
- \`html\` — Full HTML documents with CSS and JavaScript (interactive canvas, games, animations, data visualizations)
|
|
346
|
+
- \`svg\` — Vector graphics (diagrams, illustrations, charts)
|
|
347
|
+
- \`mermaid\` — Diagrams (flowcharts, sequence diagrams, class diagrams, ERDs)
|
|
348
|
+
- \`csv\` — Data tables
|
|
349
|
+
- \`latex\` — Mathematical formulas
|
|
350
|
+
|
|
351
|
+
These code blocks render as live previews by default. The user can toggle between preview and source code.
|
|
352
|
+
|
|
353
|
+
### When to Use Visuals (Proactively)
|
|
354
|
+
|
|
355
|
+
Use visual output when it communicates more effectively than text alone. Don't wait to be asked — reach for visuals naturally when the concept has spatial, sequential, or interactive qualities.
|
|
356
|
+
|
|
357
|
+
**Triggers — use visuals for:**
|
|
358
|
+
- Explaining architecture, data flows, state machines, or processes → mermaid or HTML/SVG diagram
|
|
359
|
+
- Comparing options or trade-offs → HTML table or side-by-side visual
|
|
360
|
+
- Demonstrating algorithms or data structures → animated HTML canvas
|
|
361
|
+
- Showing UI concepts, layouts, or mockups → HTML with CSS
|
|
362
|
+
- Presenting data or metrics → HTML chart or CSV table
|
|
363
|
+
- Mathematical concepts → LaTeX formulas
|
|
364
|
+
- Any request containing "show me", "visualize", "diagram", or "compare X vs Y"
|
|
365
|
+
|
|
366
|
+
**Do NOT generate visuals for:**
|
|
367
|
+
- Pure text tasks (drafting, writing, summarizing)
|
|
368
|
+
- Simple code explanations that don't have a structural component
|
|
369
|
+
- Quick answers that are better as a sentence
|
|
370
|
+
- When the user explicitly asks for text/code only
|
|
371
|
+
|
|
372
|
+
### Rendering Constraints
|
|
373
|
+
|
|
374
|
+
Previews run in a sandboxed iframe with no network access. Follow these rules:
|
|
375
|
+
- **No external resources** — no CDN links, no fetch/XHR, no external images or fonts. Everything must be inline.
|
|
376
|
+
- **Use inline styles** — no external CSS files.
|
|
377
|
+
- **Keep it self-contained** — a single HTML file with embedded \`<style>\` and \`<script>\`.
|
|
378
|
+
- **Dark theme default** — use dark backgrounds (#0a0a0a or similar), light text (#fafafa), accent colors.
|
|
379
|
+
- **Reasonable height** — content should fit within ~500px height. Avoid \`height: 100vh\`.
|
|
380
|
+
- **Keyboard interactivity works** — the user can click into the preview and use keyboard controls (games, form inputs, etc.).
|
|
381
|
+
- For simple structures, prefer \`mermaid\` (less tokens) over hand-drawn SVG/HTML.`,
|
|
382
|
+
};
|
|
331
383
|
export const ENVIRONMENT_MODULE = {
|
|
332
384
|
id: 'environment',
|
|
333
385
|
name: 'Environment Info',
|
|
@@ -358,6 +410,7 @@ export const ALL_MODULES = [
|
|
|
358
410
|
GIT_SAFETY_MODULE, // Conditional: hasGit
|
|
359
411
|
SUGGEST_MODULE,
|
|
360
412
|
IMPORTANT_RULES_MODULE,
|
|
413
|
+
VISUAL_OUTPUT_MODULE, // Conditional: hasVisualOutput (desktop only)
|
|
361
414
|
ENVIRONMENT_MODULE,
|
|
362
415
|
];
|
|
363
416
|
/**
|
|
@@ -411,5 +464,10 @@ export function shouldIncludeModule(module, context) {
|
|
|
411
464
|
if (conditions.hasProject !== undefined && conditions.hasProject !== context.hasProject) {
|
|
412
465
|
return false;
|
|
413
466
|
}
|
|
467
|
+
// Check hasVisualOutput condition
|
|
468
|
+
if (conditions.hasVisualOutput !== undefined &&
|
|
469
|
+
conditions.hasVisualOutput !== context.hasVisualOutput) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
414
472
|
return true;
|
|
415
473
|
}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* These tools require a UI handler callback from the consumer.
|
|
5
5
|
* The SDK defines schemas and types; consumers provide the UI.
|
|
6
6
|
*/
|
|
7
|
-
export { createAskUserTool, createAskUserSimpleTool
|
|
7
|
+
export { createAskUserTool, createAskUserSimpleTool } from './ask-user-tools.js';
|
|
8
8
|
export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from './ask-user-tools.js';
|
package/dist/tools/index.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* These tools require a UI handler callback from the consumer.
|
|
5
5
|
* The SDK defines schemas and types; consumers provide the UI.
|
|
6
6
|
*/
|
|
7
|
-
export { createAskUserTool, createAskUserSimpleTool
|
|
7
|
+
export { createAskUserTool, createAskUserSimpleTool } from './ask-user-tools.js';
|