@sudocode-ai/types 0.1.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.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @sudocode/types
2
+
3
+ TypeScript type definitions for [sudocode](https://github.com/sudocode-ai/sudocode) - Git-native spec and issue management for AI-assisted software development.
4
+
5
+ ## Overview
6
+
7
+ This package provides shared TypeScript types used across all sudocode packages. It includes type definitions for specs, issues, relationships, feedback, events, and JSONL interchange formats.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @sudocode/types
13
+ ```
@@ -0,0 +1,45 @@
1
+ /**
2
+ * SQLite schema definition for sudocode
3
+ * Shared between CLI and server packages
4
+ */
5
+ export declare const SCHEMA_VERSION = "1.0";
6
+ /**
7
+ * Database configuration SQL
8
+ */
9
+ export declare const DB_CONFIG = "\n-- Enable WAL mode for better concurrency\nPRAGMA journal_mode=WAL;\n\n-- Enforce foreign keys\nPRAGMA foreign_keys=ON;\n\n-- Optimize for performance\nPRAGMA synchronous=NORMAL;\nPRAGMA temp_store=MEMORY;\nPRAGMA mmap_size=30000000000;\nPRAGMA page_size=4096;\nPRAGMA cache_size=10000;\n";
10
+ /**
11
+ * Core table schemas
12
+ */
13
+ export declare const SPECS_TABLE = "\nCREATE TABLE IF NOT EXISTS specs (\n id TEXT PRIMARY KEY,\n uuid TEXT NOT NULL UNIQUE,\n title TEXT NOT NULL CHECK(length(title) <= 500),\n file_path TEXT NOT NULL,\n content TEXT NOT NULL DEFAULT '',\n priority INTEGER NOT NULL DEFAULT 2 CHECK(priority >= 0 AND priority <= 4),\n archived INTEGER NOT NULL DEFAULT 0 CHECK(archived IN (0, 1)),\n archived_at DATETIME,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n parent_id TEXT,\n parent_uuid TEXT,\n FOREIGN KEY (parent_id) REFERENCES specs(id) ON DELETE SET NULL,\n FOREIGN KEY (parent_uuid) REFERENCES specs(uuid) ON DELETE SET NULL\n);\n";
14
+ export declare const ISSUES_TABLE = "\nCREATE TABLE IF NOT EXISTS issues (\n id TEXT PRIMARY KEY,\n uuid TEXT NOT NULL UNIQUE,\n title TEXT NOT NULL CHECK(length(title) <= 500),\n content TEXT NOT NULL DEFAULT '',\n status TEXT NOT NULL DEFAULT 'open',\n priority INTEGER NOT NULL DEFAULT 2 CHECK(priority >= 0 AND priority <= 4),\n assignee TEXT,\n archived INTEGER NOT NULL DEFAULT 0 CHECK(archived IN (0, 1)),\n archived_at DATETIME,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n closed_at DATETIME,\n parent_id TEXT,\n parent_uuid TEXT,\n FOREIGN KEY (parent_id) REFERENCES issues(id) ON DELETE SET NULL,\n FOREIGN KEY (parent_uuid) REFERENCES issues(uuid) ON DELETE SET NULL\n);\n";
15
+ export declare const RELATIONSHIPS_TABLE = "\nCREATE TABLE IF NOT EXISTS relationships (\n from_id TEXT NOT NULL,\n from_uuid TEXT NOT NULL,\n from_type TEXT NOT NULL,\n to_id TEXT NOT NULL,\n to_uuid TEXT NOT NULL,\n to_type TEXT NOT NULL,\n relationship_type TEXT NOT NULL,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n metadata TEXT,\n PRIMARY KEY (from_id, from_type, to_id, to_type, relationship_type)\n);\n";
16
+ export declare const TAGS_TABLE = "\nCREATE TABLE IF NOT EXISTS tags (\n entity_id TEXT NOT NULL,\n entity_uuid TEXT NOT NULL,\n entity_type TEXT NOT NULL,\n tag TEXT NOT NULL,\n PRIMARY KEY (entity_id, entity_type, tag)\n);\n";
17
+ export declare const EVENTS_TABLE = "\nCREATE TABLE IF NOT EXISTS events (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n entity_id TEXT NOT NULL,\n entity_uuid TEXT NOT NULL,\n entity_type TEXT NOT NULL,\n event_type TEXT NOT NULL,\n actor TEXT NOT NULL,\n old_value TEXT,\n new_value TEXT,\n comment TEXT,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n git_commit_sha TEXT,\n source TEXT\n);\n";
18
+ export declare const ISSUE_FEEDBACK_TABLE = "\nCREATE TABLE IF NOT EXISTS issue_feedback (\n id TEXT PRIMARY KEY,\n issue_id TEXT NOT NULL,\n issue_uuid TEXT NOT NULL,\n spec_id TEXT NOT NULL,\n spec_uuid TEXT NOT NULL,\n feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),\n content TEXT NOT NULL,\n agent TEXT,\n anchor TEXT,\n dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE,\n FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE CASCADE,\n FOREIGN KEY (spec_id) REFERENCES specs(id) ON DELETE CASCADE,\n FOREIGN KEY (spec_uuid) REFERENCES specs(uuid) ON DELETE CASCADE\n);\n";
19
+ export declare const EXECUTIONS_TABLE = "\nCREATE TABLE IF NOT EXISTS executions (\n id TEXT PRIMARY KEY,\n issue_id TEXT,\n issue_uuid TEXT,\n\n -- Execution mode and configuration\n mode TEXT CHECK(mode IN ('worktree', 'local')),\n prompt TEXT,\n config TEXT,\n\n -- Process information (legacy + new)\n agent_type TEXT CHECK(agent_type IN ('claude-code', 'codex')),\n session_id TEXT,\n workflow_execution_id TEXT,\n\n -- Git/branch information\n target_branch TEXT NOT NULL,\n branch_name TEXT NOT NULL,\n before_commit TEXT,\n after_commit TEXT,\n worktree_path TEXT,\n\n -- Status (unified - supports both old and new statuses)\n status TEXT NOT NULL CHECK(status IN (\n 'preparing', 'pending', 'running', 'paused',\n 'completed', 'failed', 'cancelled', 'stopped'\n )),\n\n -- Timing (consistent with other tables)\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n started_at DATETIME,\n completed_at DATETIME,\n cancelled_at DATETIME,\n\n -- Results and metadata\n exit_code INTEGER,\n error_message TEXT,\n error TEXT,\n model TEXT,\n summary TEXT,\n files_changed TEXT,\n\n -- Relationships\n parent_execution_id TEXT,\n\n -- Multi-step workflow support (future extension)\n step_type TEXT,\n step_index INTEGER,\n step_config TEXT,\n\n FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE SET NULL,\n FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE SET NULL,\n FOREIGN KEY (parent_execution_id) REFERENCES executions(id) ON DELETE SET NULL\n);\n";
20
+ export declare const PROMPT_TEMPLATES_TABLE = "\nCREATE TABLE IF NOT EXISTS prompt_templates (\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n description TEXT,\n type TEXT NOT NULL CHECK(type IN ('issue', 'spec', 'custom')),\n template TEXT NOT NULL,\n variables TEXT NOT NULL,\n is_default INTEGER NOT NULL DEFAULT 0 CHECK(is_default IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n";
21
+ export declare const EXECUTION_LOGS_TABLE = "\nCREATE TABLE IF NOT EXISTS execution_logs (\n execution_id TEXT PRIMARY KEY,\n logs TEXT NOT NULL DEFAULT '',\n byte_size INTEGER NOT NULL DEFAULT 0,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (execution_id) REFERENCES executions(id) ON DELETE CASCADE\n);\n";
22
+ /**
23
+ * Index definitions
24
+ */
25
+ export declare const SPECS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_specs_uuid ON specs(uuid);\nCREATE INDEX IF NOT EXISTS idx_specs_priority ON specs(priority);\nCREATE INDEX IF NOT EXISTS idx_specs_parent_id ON specs(parent_id);\nCREATE INDEX IF NOT EXISTS idx_specs_parent_uuid ON specs(parent_uuid);\nCREATE INDEX IF NOT EXISTS idx_specs_archived ON specs(archived);\nCREATE INDEX IF NOT EXISTS idx_specs_created_at ON specs(created_at);\nCREATE INDEX IF NOT EXISTS idx_specs_updated_at ON specs(updated_at);\n";
26
+ export declare const ISSUES_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_issues_uuid ON issues(uuid);\nCREATE INDEX IF NOT EXISTS idx_issues_status ON issues(status);\nCREATE INDEX IF NOT EXISTS idx_issues_priority ON issues(priority);\nCREATE INDEX IF NOT EXISTS idx_issues_assignee ON issues(assignee);\nCREATE INDEX IF NOT EXISTS idx_issues_parent_id ON issues(parent_id);\nCREATE INDEX IF NOT EXISTS idx_issues_parent_uuid ON issues(parent_uuid);\nCREATE INDEX IF NOT EXISTS idx_issues_archived ON issues(archived);\nCREATE INDEX IF NOT EXISTS idx_issues_created_at ON issues(created_at);\nCREATE INDEX IF NOT EXISTS idx_issues_updated_at ON issues(updated_at);\nCREATE INDEX IF NOT EXISTS idx_issues_closed_at ON issues(closed_at);\n";
27
+ export declare const RELATIONSHIPS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_rel_from_id ON relationships(from_id, from_type);\nCREATE INDEX IF NOT EXISTS idx_rel_from_uuid ON relationships(from_uuid, from_type);\nCREATE INDEX IF NOT EXISTS idx_rel_to_id ON relationships(to_id, to_type);\nCREATE INDEX IF NOT EXISTS idx_rel_to_uuid ON relationships(to_uuid, to_type);\nCREATE INDEX IF NOT EXISTS idx_rel_type ON relationships(relationship_type);\nCREATE INDEX IF NOT EXISTS idx_rel_created_at ON relationships(created_at);\n";
28
+ export declare const TAGS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_tags_entity_id ON tags(entity_id, entity_type);\nCREATE INDEX IF NOT EXISTS idx_tags_entity_uuid ON tags(entity_uuid, entity_type);\nCREATE INDEX IF NOT EXISTS idx_tags_tag ON tags(tag);\n";
29
+ export declare const EVENTS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_events_entity_id ON events(entity_id, entity_type);\nCREATE INDEX IF NOT EXISTS idx_events_entity_uuid ON events(entity_uuid, entity_type);\nCREATE INDEX IF NOT EXISTS idx_events_type ON events(event_type);\nCREATE INDEX IF NOT EXISTS idx_events_actor ON events(actor);\nCREATE INDEX IF NOT EXISTS idx_events_created_at ON events(created_at);\nCREATE INDEX IF NOT EXISTS idx_events_git_commit ON events(git_commit_sha);\n";
30
+ export declare const ISSUE_FEEDBACK_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_feedback_issue_id ON issue_feedback(issue_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_issue_uuid ON issue_feedback(issue_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_spec_id ON issue_feedback(spec_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_spec_uuid ON issue_feedback(spec_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);\nCREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);\nCREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);\n";
31
+ export declare const EXECUTIONS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_executions_issue_id ON executions(issue_id);\nCREATE INDEX IF NOT EXISTS idx_executions_issue_uuid ON executions(issue_uuid);\nCREATE INDEX IF NOT EXISTS idx_executions_status ON executions(status);\nCREATE INDEX IF NOT EXISTS idx_executions_session_id ON executions(session_id);\nCREATE INDEX IF NOT EXISTS idx_executions_parent ON executions(parent_execution_id);\nCREATE INDEX IF NOT EXISTS idx_executions_created_at ON executions(created_at);\nCREATE INDEX IF NOT EXISTS idx_executions_workflow ON executions(workflow_execution_id);\nCREATE INDEX IF NOT EXISTS idx_executions_workflow_step ON executions(workflow_execution_id, step_index);\nCREATE INDEX IF NOT EXISTS idx_executions_step_type ON executions(step_type);\n";
32
+ export declare const PROMPT_TEMPLATES_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_templates_type ON prompt_templates(type);\nCREATE INDEX IF NOT EXISTS idx_templates_default ON prompt_templates(is_default);\n";
33
+ export declare const EXECUTION_LOGS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_execution_logs_updated_at ON execution_logs(updated_at);\nCREATE INDEX IF NOT EXISTS idx_execution_logs_byte_size ON execution_logs(byte_size);\n";
34
+ /**
35
+ * View definitions
36
+ */
37
+ export declare const READY_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS ready_issues AS\nSELECT i.*\nFROM issues i\nWHERE i.status = 'open'\n AND i.archived = 0\n AND NOT EXISTS (\n SELECT 1 FROM relationships r\n JOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'\n WHERE r.from_id = i.id\n AND r.from_type = 'issue'\n AND r.relationship_type = 'blocks'\n AND blocker.status IN ('open', 'in_progress', 'blocked')\n );\n";
38
+ export declare const BLOCKED_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS blocked_issues AS\nSELECT\n i.*,\n COUNT(r.to_id) as blocked_by_count,\n GROUP_CONCAT(r.to_id) as blocked_by_ids\nFROM issues i\nJOIN relationships r ON i.id = r.from_id AND r.from_type = 'issue'\nJOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'\nWHERE i.status IN ('open', 'in_progress', 'blocked')\n AND i.archived = 0\n AND r.relationship_type = 'blocks'\n AND blocker.status IN ('open', 'in_progress', 'blocked')\nGROUP BY i.id;\n";
39
+ /**
40
+ * Combined schema initialization
41
+ */
42
+ export declare const ALL_TABLES: string[];
43
+ export declare const ALL_INDEXES: string[];
44
+ export declare const ALL_VIEWS: string[];
45
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,SAAS,uSAarB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,WAAW,ysBAiBvB,CAAC;AAEF,eAAO,MAAM,YAAY,qwBAmBxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,iaAa/B,CAAC;AAEF,eAAO,MAAM,UAAU,mNAQtB,CAAC;AAEF,eAAO,MAAM,YAAY,uZAexB,CAAC;AAEF,eAAO,MAAM,oBAAoB,6zBAmBhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,wmDAwD5B,CAAC;AAGF,eAAO,MAAM,sBAAsB,ocAYlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,iXAShC,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,aAAa,oeAQzB,CAAC;AAEF,eAAO,MAAM,cAAc,+rBAW1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,seAOjC,CAAC;AAEF,eAAO,MAAM,YAAY,kOAIxB,CAAC;AAEF,eAAO,MAAM,cAAc,2cAO1B,CAAC;AAEF,eAAO,MAAM,sBAAsB,2jBAQlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,0vBAU9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,oKAGpC,CAAC;AAEF,eAAO,MAAM,sBAAsB,uLAGlC,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,iBAAiB,yaAc7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,kfAc/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,UAUtB,CAAC;AAEF,eAAO,MAAM,WAAW,UAUvB,CAAC;AAEF,eAAO,MAAM,SAAS,UAA2C,CAAC"}
package/dist/schema.js ADDED
@@ -0,0 +1,338 @@
1
+ /**
2
+ * SQLite schema definition for sudocode
3
+ * Shared between CLI and server packages
4
+ */
5
+ export const SCHEMA_VERSION = "1.0";
6
+ /**
7
+ * Database configuration SQL
8
+ */
9
+ export const DB_CONFIG = `
10
+ -- Enable WAL mode for better concurrency
11
+ PRAGMA journal_mode=WAL;
12
+
13
+ -- Enforce foreign keys
14
+ PRAGMA foreign_keys=ON;
15
+
16
+ -- Optimize for performance
17
+ PRAGMA synchronous=NORMAL;
18
+ PRAGMA temp_store=MEMORY;
19
+ PRAGMA mmap_size=30000000000;
20
+ PRAGMA page_size=4096;
21
+ PRAGMA cache_size=10000;
22
+ `;
23
+ /**
24
+ * Core table schemas
25
+ */
26
+ export const SPECS_TABLE = `
27
+ CREATE TABLE IF NOT EXISTS specs (
28
+ id TEXT PRIMARY KEY,
29
+ uuid TEXT NOT NULL UNIQUE,
30
+ title TEXT NOT NULL CHECK(length(title) <= 500),
31
+ file_path TEXT NOT NULL,
32
+ content TEXT NOT NULL DEFAULT '',
33
+ priority INTEGER NOT NULL DEFAULT 2 CHECK(priority >= 0 AND priority <= 4),
34
+ archived INTEGER NOT NULL DEFAULT 0 CHECK(archived IN (0, 1)),
35
+ archived_at DATETIME,
36
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
37
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
38
+ parent_id TEXT,
39
+ parent_uuid TEXT,
40
+ FOREIGN KEY (parent_id) REFERENCES specs(id) ON DELETE SET NULL,
41
+ FOREIGN KEY (parent_uuid) REFERENCES specs(uuid) ON DELETE SET NULL
42
+ );
43
+ `;
44
+ export const ISSUES_TABLE = `
45
+ CREATE TABLE IF NOT EXISTS issues (
46
+ id TEXT PRIMARY KEY,
47
+ uuid TEXT NOT NULL UNIQUE,
48
+ title TEXT NOT NULL CHECK(length(title) <= 500),
49
+ content TEXT NOT NULL DEFAULT '',
50
+ status TEXT NOT NULL DEFAULT 'open',
51
+ priority INTEGER NOT NULL DEFAULT 2 CHECK(priority >= 0 AND priority <= 4),
52
+ assignee TEXT,
53
+ archived INTEGER NOT NULL DEFAULT 0 CHECK(archived IN (0, 1)),
54
+ archived_at DATETIME,
55
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
56
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
57
+ closed_at DATETIME,
58
+ parent_id TEXT,
59
+ parent_uuid TEXT,
60
+ FOREIGN KEY (parent_id) REFERENCES issues(id) ON DELETE SET NULL,
61
+ FOREIGN KEY (parent_uuid) REFERENCES issues(uuid) ON DELETE SET NULL
62
+ );
63
+ `;
64
+ export const RELATIONSHIPS_TABLE = `
65
+ CREATE TABLE IF NOT EXISTS relationships (
66
+ from_id TEXT NOT NULL,
67
+ from_uuid TEXT NOT NULL,
68
+ from_type TEXT NOT NULL,
69
+ to_id TEXT NOT NULL,
70
+ to_uuid TEXT NOT NULL,
71
+ to_type TEXT NOT NULL,
72
+ relationship_type TEXT NOT NULL,
73
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
74
+ metadata TEXT,
75
+ PRIMARY KEY (from_id, from_type, to_id, to_type, relationship_type)
76
+ );
77
+ `;
78
+ export const TAGS_TABLE = `
79
+ CREATE TABLE IF NOT EXISTS tags (
80
+ entity_id TEXT NOT NULL,
81
+ entity_uuid TEXT NOT NULL,
82
+ entity_type TEXT NOT NULL,
83
+ tag TEXT NOT NULL,
84
+ PRIMARY KEY (entity_id, entity_type, tag)
85
+ );
86
+ `;
87
+ export const EVENTS_TABLE = `
88
+ CREATE TABLE IF NOT EXISTS events (
89
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
90
+ entity_id TEXT NOT NULL,
91
+ entity_uuid TEXT NOT NULL,
92
+ entity_type TEXT NOT NULL,
93
+ event_type TEXT NOT NULL,
94
+ actor TEXT NOT NULL,
95
+ old_value TEXT,
96
+ new_value TEXT,
97
+ comment TEXT,
98
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
99
+ git_commit_sha TEXT,
100
+ source TEXT
101
+ );
102
+ `;
103
+ export const ISSUE_FEEDBACK_TABLE = `
104
+ CREATE TABLE IF NOT EXISTS issue_feedback (
105
+ id TEXT PRIMARY KEY,
106
+ issue_id TEXT NOT NULL,
107
+ issue_uuid TEXT NOT NULL,
108
+ spec_id TEXT NOT NULL,
109
+ spec_uuid TEXT NOT NULL,
110
+ feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),
111
+ content TEXT NOT NULL,
112
+ agent TEXT,
113
+ anchor TEXT,
114
+ dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),
115
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
116
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
117
+ FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE,
118
+ FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE CASCADE,
119
+ FOREIGN KEY (spec_id) REFERENCES specs(id) ON DELETE CASCADE,
120
+ FOREIGN KEY (spec_uuid) REFERENCES specs(uuid) ON DELETE CASCADE
121
+ );
122
+ `;
123
+ export const EXECUTIONS_TABLE = `
124
+ CREATE TABLE IF NOT EXISTS executions (
125
+ id TEXT PRIMARY KEY,
126
+ issue_id TEXT,
127
+ issue_uuid TEXT,
128
+
129
+ -- Execution mode and configuration
130
+ mode TEXT CHECK(mode IN ('worktree', 'local')),
131
+ prompt TEXT,
132
+ config TEXT,
133
+
134
+ -- Process information (legacy + new)
135
+ agent_type TEXT CHECK(agent_type IN ('claude-code', 'codex')),
136
+ session_id TEXT,
137
+ workflow_execution_id TEXT,
138
+
139
+ -- Git/branch information
140
+ target_branch TEXT NOT NULL,
141
+ branch_name TEXT NOT NULL,
142
+ before_commit TEXT,
143
+ after_commit TEXT,
144
+ worktree_path TEXT,
145
+
146
+ -- Status (unified - supports both old and new statuses)
147
+ status TEXT NOT NULL CHECK(status IN (
148
+ 'preparing', 'pending', 'running', 'paused',
149
+ 'completed', 'failed', 'cancelled', 'stopped'
150
+ )),
151
+
152
+ -- Timing (consistent with other tables)
153
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
154
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
155
+ started_at DATETIME,
156
+ completed_at DATETIME,
157
+ cancelled_at DATETIME,
158
+
159
+ -- Results and metadata
160
+ exit_code INTEGER,
161
+ error_message TEXT,
162
+ error TEXT,
163
+ model TEXT,
164
+ summary TEXT,
165
+ files_changed TEXT,
166
+
167
+ -- Relationships
168
+ parent_execution_id TEXT,
169
+
170
+ -- Multi-step workflow support (future extension)
171
+ step_type TEXT,
172
+ step_index INTEGER,
173
+ step_config TEXT,
174
+
175
+ FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE SET NULL,
176
+ FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE SET NULL,
177
+ FOREIGN KEY (parent_execution_id) REFERENCES executions(id) ON DELETE SET NULL
178
+ );
179
+ `;
180
+ // Prompt templates table
181
+ export const PROMPT_TEMPLATES_TABLE = `
182
+ CREATE TABLE IF NOT EXISTS prompt_templates (
183
+ id TEXT PRIMARY KEY,
184
+ name TEXT NOT NULL,
185
+ description TEXT,
186
+ type TEXT NOT NULL CHECK(type IN ('issue', 'spec', 'custom')),
187
+ template TEXT NOT NULL,
188
+ variables TEXT NOT NULL,
189
+ is_default INTEGER NOT NULL DEFAULT 0 CHECK(is_default IN (0, 1)),
190
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
191
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
192
+ );
193
+ `;
194
+ // Execution logs table - stores detailed execution output
195
+ // Logs are stored in JSONL format (newline-delimited JSON)
196
+ export const EXECUTION_LOGS_TABLE = `
197
+ CREATE TABLE IF NOT EXISTS execution_logs (
198
+ execution_id TEXT PRIMARY KEY,
199
+ logs TEXT NOT NULL DEFAULT '',
200
+ byte_size INTEGER NOT NULL DEFAULT 0,
201
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
202
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
203
+ FOREIGN KEY (execution_id) REFERENCES executions(id) ON DELETE CASCADE
204
+ );
205
+ `;
206
+ /**
207
+ * Index definitions
208
+ */
209
+ export const SPECS_INDEXES = `
210
+ CREATE INDEX IF NOT EXISTS idx_specs_uuid ON specs(uuid);
211
+ CREATE INDEX IF NOT EXISTS idx_specs_priority ON specs(priority);
212
+ CREATE INDEX IF NOT EXISTS idx_specs_parent_id ON specs(parent_id);
213
+ CREATE INDEX IF NOT EXISTS idx_specs_parent_uuid ON specs(parent_uuid);
214
+ CREATE INDEX IF NOT EXISTS idx_specs_archived ON specs(archived);
215
+ CREATE INDEX IF NOT EXISTS idx_specs_created_at ON specs(created_at);
216
+ CREATE INDEX IF NOT EXISTS idx_specs_updated_at ON specs(updated_at);
217
+ `;
218
+ export const ISSUES_INDEXES = `
219
+ CREATE INDEX IF NOT EXISTS idx_issues_uuid ON issues(uuid);
220
+ CREATE INDEX IF NOT EXISTS idx_issues_status ON issues(status);
221
+ CREATE INDEX IF NOT EXISTS idx_issues_priority ON issues(priority);
222
+ CREATE INDEX IF NOT EXISTS idx_issues_assignee ON issues(assignee);
223
+ CREATE INDEX IF NOT EXISTS idx_issues_parent_id ON issues(parent_id);
224
+ CREATE INDEX IF NOT EXISTS idx_issues_parent_uuid ON issues(parent_uuid);
225
+ CREATE INDEX IF NOT EXISTS idx_issues_archived ON issues(archived);
226
+ CREATE INDEX IF NOT EXISTS idx_issues_created_at ON issues(created_at);
227
+ CREATE INDEX IF NOT EXISTS idx_issues_updated_at ON issues(updated_at);
228
+ CREATE INDEX IF NOT EXISTS idx_issues_closed_at ON issues(closed_at);
229
+ `;
230
+ export const RELATIONSHIPS_INDEXES = `
231
+ CREATE INDEX IF NOT EXISTS idx_rel_from_id ON relationships(from_id, from_type);
232
+ CREATE INDEX IF NOT EXISTS idx_rel_from_uuid ON relationships(from_uuid, from_type);
233
+ CREATE INDEX IF NOT EXISTS idx_rel_to_id ON relationships(to_id, to_type);
234
+ CREATE INDEX IF NOT EXISTS idx_rel_to_uuid ON relationships(to_uuid, to_type);
235
+ CREATE INDEX IF NOT EXISTS idx_rel_type ON relationships(relationship_type);
236
+ CREATE INDEX IF NOT EXISTS idx_rel_created_at ON relationships(created_at);
237
+ `;
238
+ export const TAGS_INDEXES = `
239
+ CREATE INDEX IF NOT EXISTS idx_tags_entity_id ON tags(entity_id, entity_type);
240
+ CREATE INDEX IF NOT EXISTS idx_tags_entity_uuid ON tags(entity_uuid, entity_type);
241
+ CREATE INDEX IF NOT EXISTS idx_tags_tag ON tags(tag);
242
+ `;
243
+ export const EVENTS_INDEXES = `
244
+ CREATE INDEX IF NOT EXISTS idx_events_entity_id ON events(entity_id, entity_type);
245
+ CREATE INDEX IF NOT EXISTS idx_events_entity_uuid ON events(entity_uuid, entity_type);
246
+ CREATE INDEX IF NOT EXISTS idx_events_type ON events(event_type);
247
+ CREATE INDEX IF NOT EXISTS idx_events_actor ON events(actor);
248
+ CREATE INDEX IF NOT EXISTS idx_events_created_at ON events(created_at);
249
+ CREATE INDEX IF NOT EXISTS idx_events_git_commit ON events(git_commit_sha);
250
+ `;
251
+ export const ISSUE_FEEDBACK_INDEXES = `
252
+ CREATE INDEX IF NOT EXISTS idx_feedback_issue_id ON issue_feedback(issue_id);
253
+ CREATE INDEX IF NOT EXISTS idx_feedback_issue_uuid ON issue_feedback(issue_uuid);
254
+ CREATE INDEX IF NOT EXISTS idx_feedback_spec_id ON issue_feedback(spec_id);
255
+ CREATE INDEX IF NOT EXISTS idx_feedback_spec_uuid ON issue_feedback(spec_uuid);
256
+ CREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);
257
+ CREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);
258
+ CREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);
259
+ `;
260
+ export const EXECUTIONS_INDEXES = `
261
+ CREATE INDEX IF NOT EXISTS idx_executions_issue_id ON executions(issue_id);
262
+ CREATE INDEX IF NOT EXISTS idx_executions_issue_uuid ON executions(issue_uuid);
263
+ CREATE INDEX IF NOT EXISTS idx_executions_status ON executions(status);
264
+ CREATE INDEX IF NOT EXISTS idx_executions_session_id ON executions(session_id);
265
+ CREATE INDEX IF NOT EXISTS idx_executions_parent ON executions(parent_execution_id);
266
+ CREATE INDEX IF NOT EXISTS idx_executions_created_at ON executions(created_at);
267
+ CREATE INDEX IF NOT EXISTS idx_executions_workflow ON executions(workflow_execution_id);
268
+ CREATE INDEX IF NOT EXISTS idx_executions_workflow_step ON executions(workflow_execution_id, step_index);
269
+ CREATE INDEX IF NOT EXISTS idx_executions_step_type ON executions(step_type);
270
+ `;
271
+ export const PROMPT_TEMPLATES_INDEXES = `
272
+ CREATE INDEX IF NOT EXISTS idx_templates_type ON prompt_templates(type);
273
+ CREATE INDEX IF NOT EXISTS idx_templates_default ON prompt_templates(is_default);
274
+ `;
275
+ export const EXECUTION_LOGS_INDEXES = `
276
+ CREATE INDEX IF NOT EXISTS idx_execution_logs_updated_at ON execution_logs(updated_at);
277
+ CREATE INDEX IF NOT EXISTS idx_execution_logs_byte_size ON execution_logs(byte_size);
278
+ `;
279
+ /**
280
+ * View definitions
281
+ */
282
+ export const READY_ISSUES_VIEW = `
283
+ CREATE VIEW IF NOT EXISTS ready_issues AS
284
+ SELECT i.*
285
+ FROM issues i
286
+ WHERE i.status = 'open'
287
+ AND i.archived = 0
288
+ AND NOT EXISTS (
289
+ SELECT 1 FROM relationships r
290
+ JOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'
291
+ WHERE r.from_id = i.id
292
+ AND r.from_type = 'issue'
293
+ AND r.relationship_type = 'blocks'
294
+ AND blocker.status IN ('open', 'in_progress', 'blocked')
295
+ );
296
+ `;
297
+ export const BLOCKED_ISSUES_VIEW = `
298
+ CREATE VIEW IF NOT EXISTS blocked_issues AS
299
+ SELECT
300
+ i.*,
301
+ COUNT(r.to_id) as blocked_by_count,
302
+ GROUP_CONCAT(r.to_id) as blocked_by_ids
303
+ FROM issues i
304
+ JOIN relationships r ON i.id = r.from_id AND r.from_type = 'issue'
305
+ JOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'
306
+ WHERE i.status IN ('open', 'in_progress', 'blocked')
307
+ AND i.archived = 0
308
+ AND r.relationship_type = 'blocks'
309
+ AND blocker.status IN ('open', 'in_progress', 'blocked')
310
+ GROUP BY i.id;
311
+ `;
312
+ /**
313
+ * Combined schema initialization
314
+ */
315
+ export const ALL_TABLES = [
316
+ SPECS_TABLE,
317
+ ISSUES_TABLE,
318
+ RELATIONSHIPS_TABLE,
319
+ TAGS_TABLE,
320
+ EVENTS_TABLE,
321
+ ISSUE_FEEDBACK_TABLE,
322
+ EXECUTIONS_TABLE,
323
+ PROMPT_TEMPLATES_TABLE,
324
+ EXECUTION_LOGS_TABLE,
325
+ ];
326
+ export const ALL_INDEXES = [
327
+ SPECS_INDEXES,
328
+ ISSUES_INDEXES,
329
+ RELATIONSHIPS_INDEXES,
330
+ TAGS_INDEXES,
331
+ EVENTS_INDEXES,
332
+ ISSUE_FEEDBACK_INDEXES,
333
+ EXECUTIONS_INDEXES,
334
+ PROMPT_TEMPLATES_INDEXES,
335
+ EXECUTION_LOGS_INDEXES,
336
+ ];
337
+ export const ALL_VIEWS = [READY_ISSUES_VIEW, BLOCKED_ISSUES_VIEW];
338
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;CAaxB,CAAC;AAEF;;GAEG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;CAiB1B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;CAmB3B,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;CAalC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;CAQzB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;CAe3B,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;CAmBnC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwD/B,CAAC;AAEF,yBAAyB;AACzB,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;CAYrC,CAAC;AAEF,0DAA0D;AAC1D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAC;AAEF;;GAEG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;CAQ5B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;CAW7B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;CAOpC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;CAI3B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;CAO7B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;CAQrC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;CAUjC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;CAGvC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;CAGrC,CAAC;AAEF;;GAEG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;CAchC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;CAclC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,UAAU;IACV,YAAY;IACZ,oBAAoB;IACpB,gBAAgB;IAChB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa;IACb,cAAc;IACd,qBAAqB;IACrB,YAAY;IACZ,cAAc;IACd,sBAAsB;IACtB,kBAAkB;IAClB,wBAAwB;IACxB,sBAAsB;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@sudocode-ai/types",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript type definitions for sudocode",
5
+ "types": "src/index.d.ts",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "default": "./src/index.d.ts"
11
+ },
12
+ "./schema": {
13
+ "types": "./dist/schema.d.ts",
14
+ "default": "./dist/schema.js"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "build": "tsc"
19
+ },
20
+ "keywords": [
21
+ "sudocode",
22
+ "types",
23
+ "typescript"
24
+ ],
25
+ "author": "sudocode AI",
26
+ "license": "Apache-2.0",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/sudocode-ai/sudocode.git",
30
+ "directory": "types"
31
+ },
32
+ "homepage": "https://sudocode.ai",
33
+ "bugs": {
34
+ "url": "https://github.com/sudocode-ai/sudocode/issues"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "files": [
40
+ "src/index.d.ts",
41
+ "dist"
42
+ ],
43
+ "devDependencies": {
44
+ "typescript": "^5.0.0"
45
+ }
46
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,278 @@
1
+ /**
2
+ * Core entity types for sudocode
3
+ */
4
+ export interface Spec {
5
+ id: string;
6
+ title: string;
7
+ uuid: string;
8
+ file_path: string;
9
+ content: string;
10
+ priority: number;
11
+ archived?: boolean;
12
+ archived_at?: string;
13
+ created_at: string;
14
+ updated_at: string;
15
+ parent_id?: string;
16
+ parent_uuid?: string;
17
+ }
18
+
19
+ export interface Issue {
20
+ id: string;
21
+ title: string;
22
+ status: IssueStatus;
23
+ uuid: string;
24
+ content: string;
25
+ priority: number;
26
+ assignee?: string;
27
+ archived?: boolean;
28
+ archived_at?: string;
29
+ created_at: string;
30
+ updated_at: string;
31
+ closed_at?: string;
32
+ parent_id?: string;
33
+ parent_uuid?: string;
34
+ }
35
+
36
+ export type IssueStatus =
37
+ | "open"
38
+ | "in_progress"
39
+ | "blocked"
40
+ | "needs_review"
41
+ | "closed";
42
+
43
+ export interface Relationship {
44
+ from_id: string;
45
+ from_uuid: string;
46
+ from_type: EntityType;
47
+ to_id: string;
48
+ to_uuid: string;
49
+ to_type: EntityType;
50
+ relationship_type: RelationshipType;
51
+ created_at: string;
52
+ metadata?: string;
53
+ }
54
+
55
+ export type EntityType = "spec" | "issue";
56
+
57
+ export type RelationshipType =
58
+ | "blocks"
59
+ | "related"
60
+ | "discovered-from"
61
+ | "implements"
62
+ | "references"
63
+ | "depends-on";
64
+
65
+ export interface Tag {
66
+ entity_id: string;
67
+ entity_uuid: string;
68
+ entity_type: EntityType;
69
+ tag: string;
70
+ }
71
+
72
+ export interface Event {
73
+ id: number;
74
+ entity_id: string;
75
+ entity_uuid: string;
76
+ entity_type: EntityType;
77
+ event_type: EventType;
78
+ actor: string;
79
+ old_value: string | null;
80
+ new_value: string | null;
81
+ comment: string | null;
82
+ created_at: string;
83
+ git_commit_sha: string | null;
84
+ source?: string;
85
+ }
86
+
87
+ export type EventType =
88
+ | "created"
89
+ | "updated"
90
+ | "status_changed"
91
+ | "relationship_added"
92
+ | "relationship_removed"
93
+ | "tag_added"
94
+ | "tag_removed";
95
+
96
+ /**
97
+ * Issue-based spec feedback types
98
+ */
99
+ export interface IssueFeedback {
100
+ id: string;
101
+ issue_id: string;
102
+ issue_uuid: string;
103
+ spec_id: string;
104
+ spec_uuid: string;
105
+ feedback_type: FeedbackType;
106
+ content: string;
107
+ agent?: string;
108
+ anchor?: string;
109
+ dismissed?: boolean;
110
+ created_at: string;
111
+ updated_at: string;
112
+ }
113
+
114
+ /**
115
+ * Base location anchor for tracking positions in markdown documents
116
+ */
117
+ export interface LocationAnchor {
118
+ section_heading?: string;
119
+ section_level?: number;
120
+ line_number?: number;
121
+ line_offset?: number;
122
+ text_snippet?: string;
123
+ context_before?: string;
124
+ context_after?: string;
125
+ content_hash?: string;
126
+ }
127
+
128
+ /**
129
+ * Feedback anchor with additional tracking for changes over time
130
+ */
131
+ export interface FeedbackAnchor extends LocationAnchor {
132
+ anchor_status: "valid" | "relocated" | "stale";
133
+ last_verified_at?: string;
134
+ original_location?: {
135
+ line_number: number;
136
+ section_heading?: string;
137
+ };
138
+ }
139
+
140
+ export type FeedbackType = "comment" | "suggestion" | "request";
141
+
142
+ /**
143
+ * JSONL format types
144
+ */
145
+ export interface SpecJSONL extends Spec {
146
+ relationships: RelationshipJSONL[];
147
+ tags: string[];
148
+ }
149
+
150
+ export interface IssueJSONL extends Issue {
151
+ relationships: RelationshipJSONL[];
152
+ tags: string[];
153
+ feedback?: FeedbackJSONL[];
154
+ }
155
+
156
+ export interface FeedbackJSONL {
157
+ id: string;
158
+ issue_id: string;
159
+ spec_id: string;
160
+ feedback_type: FeedbackType;
161
+ content: string;
162
+ agent?: string;
163
+ anchor?: FeedbackAnchor;
164
+ dismissed?: boolean;
165
+ created_at: string;
166
+ updated_at: string;
167
+ }
168
+
169
+ export interface RelationshipJSONL {
170
+ from: string;
171
+ from_type: EntityType;
172
+ to: string;
173
+ to_type: EntityType;
174
+ type: RelationshipType;
175
+ }
176
+
177
+ /**
178
+ * Worktree configuration for session isolation
179
+ */
180
+ export interface WorktreeConfig {
181
+ /** Where to store worktrees (default: ".sudocode/worktrees") */
182
+ worktreeStoragePath: string;
183
+ /** Auto-create branches for new sessions (default: true) */
184
+ autoCreateBranches: boolean;
185
+ /** Auto-delete branches when session is cleaned up (default: false) */
186
+ autoDeleteBranches: boolean;
187
+ /** Use sparse-checkout for worktrees (default: false) */
188
+ enableSparseCheckout: boolean;
189
+ /** Patterns for sparse-checkout (optional) */
190
+ sparseCheckoutPatterns?: string[];
191
+ /** Branch naming prefix (default: "sudocode") */
192
+ branchPrefix: string;
193
+ /** Cleanup orphaned worktrees on server startup (default: true) */
194
+ cleanupOrphanedWorktreesOnStartup: boolean;
195
+ }
196
+
197
+ /**
198
+ * Config metadata file structure (.sudocode/config.json)
199
+ */
200
+ export interface Config {
201
+ version: string;
202
+ id_prefix: {
203
+ spec: string;
204
+ issue: string;
205
+ };
206
+ /** Worktree configuration (optional) */
207
+ worktree?: WorktreeConfig;
208
+ }
209
+
210
+ /**
211
+ * Agent types supported for execution
212
+ */
213
+ export type AgentType = "claude-code" | "codex";
214
+
215
+ /**
216
+ * Execution status
217
+ */
218
+ export type ExecutionStatus =
219
+ | "preparing" // Template being prepared
220
+ | "pending" // Created, not yet started
221
+ | "running" // Agent executing
222
+ | "paused" // Execution paused (awaiting follow-up)
223
+ | "completed" // Successfully finished
224
+ | "failed" // Execution failed
225
+ | "cancelled" // User cancelled
226
+ | "stopped"; // User stopped (legacy alias for cancelled)
227
+
228
+ /**
229
+ * Represents a single agent run on an issue
230
+ * Tracks the full lifecycle of a coding agent execution
231
+ */
232
+ export interface Execution {
233
+ id: string;
234
+ issue_id: string | null;
235
+ issue_uuid: string | null;
236
+
237
+ mode: string | null;
238
+ prompt: string | null;
239
+ config: string | null;
240
+
241
+ // Process information
242
+ agent_type: AgentType;
243
+ session_id: string | null;
244
+ workflow_execution_id: string | null;
245
+
246
+ // Git/branch information
247
+ target_branch: string;
248
+ branch_name: string;
249
+ before_commit: string | null;
250
+ after_commit: string | null;
251
+ worktree_path: string | null;
252
+
253
+ // Status
254
+ status: ExecutionStatus;
255
+
256
+ // Timing
257
+ created_at: string;
258
+ updated_at: string;
259
+ started_at: string | null;
260
+ completed_at: string | null;
261
+ cancelled_at: string | null;
262
+
263
+ // Results and metadata
264
+ // TODO: Expand as a proper JSON object
265
+ exit_code: number | null;
266
+ error_message: string | null;
267
+ error: string | null;
268
+ model: string | null;
269
+ summary: string | null;
270
+ files_changed: string | null;
271
+
272
+ parent_execution_id: string | null;
273
+
274
+ // Multi-step workflow support (future extension)
275
+ step_type: string | null;
276
+ step_index: number | null;
277
+ step_config: string | null;
278
+ }