@sudocode-ai/local-server 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.
Files changed (130) hide show
  1. package/README.md +19 -0
  2. package/dist/cli.d.ts +7 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +105 -0
  5. package/dist/cli.js.map +7 -0
  6. package/dist/execution/engine/engine.d.ts +103 -0
  7. package/dist/execution/engine/engine.d.ts.map +1 -0
  8. package/dist/execution/engine/simple-engine.d.ts +190 -0
  9. package/dist/execution/engine/simple-engine.d.ts.map +1 -0
  10. package/dist/execution/engine/types.d.ts +116 -0
  11. package/dist/execution/engine/types.d.ts.map +1 -0
  12. package/dist/execution/output/ag-ui-adapter.d.ts +176 -0
  13. package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -0
  14. package/dist/execution/output/ag-ui-integration.d.ts +96 -0
  15. package/dist/execution/output/ag-ui-integration.d.ts.map +1 -0
  16. package/dist/execution/output/claude-code-output-processor.d.ts +321 -0
  17. package/dist/execution/output/claude-code-output-processor.d.ts.map +1 -0
  18. package/dist/execution/output/index.d.ts +18 -0
  19. package/dist/execution/output/index.d.ts.map +1 -0
  20. package/dist/execution/output/types.d.ts +421 -0
  21. package/dist/execution/output/types.d.ts.map +1 -0
  22. package/dist/execution/process/builders/claude.d.ts +86 -0
  23. package/dist/execution/process/builders/claude.d.ts.map +1 -0
  24. package/dist/execution/process/index.d.ts +15 -0
  25. package/dist/execution/process/index.d.ts.map +1 -0
  26. package/dist/execution/process/manager.d.ts +133 -0
  27. package/dist/execution/process/manager.d.ts.map +1 -0
  28. package/dist/execution/process/simple-manager.d.ts +102 -0
  29. package/dist/execution/process/simple-manager.d.ts.map +1 -0
  30. package/dist/execution/process/types.d.ts +105 -0
  31. package/dist/execution/process/types.d.ts.map +1 -0
  32. package/dist/execution/process/utils.d.ts +53 -0
  33. package/dist/execution/process/utils.d.ts.map +1 -0
  34. package/dist/execution/resilience/circuit-breaker.d.ts +170 -0
  35. package/dist/execution/resilience/circuit-breaker.d.ts.map +1 -0
  36. package/dist/execution/resilience/executor.d.ts +109 -0
  37. package/dist/execution/resilience/executor.d.ts.map +1 -0
  38. package/dist/execution/resilience/index.d.ts +14 -0
  39. package/dist/execution/resilience/index.d.ts.map +1 -0
  40. package/dist/execution/resilience/resilient-executor.d.ts +86 -0
  41. package/dist/execution/resilience/resilient-executor.d.ts.map +1 -0
  42. package/dist/execution/resilience/retry.d.ts +161 -0
  43. package/dist/execution/resilience/retry.d.ts.map +1 -0
  44. package/dist/execution/resilience/types.d.ts +226 -0
  45. package/dist/execution/resilience/types.d.ts.map +1 -0
  46. package/dist/execution/transport/event-buffer.d.ts +119 -0
  47. package/dist/execution/transport/event-buffer.d.ts.map +1 -0
  48. package/dist/execution/transport/index.d.ts +10 -0
  49. package/dist/execution/transport/index.d.ts.map +1 -0
  50. package/dist/execution/transport/sse-transport.d.ts +146 -0
  51. package/dist/execution/transport/sse-transport.d.ts.map +1 -0
  52. package/dist/execution/transport/transport-manager.d.ts +176 -0
  53. package/dist/execution/transport/transport-manager.d.ts.map +1 -0
  54. package/dist/execution/workflow/index.d.ts +13 -0
  55. package/dist/execution/workflow/index.d.ts.map +1 -0
  56. package/dist/execution/workflow/linear-orchestrator.d.ts +216 -0
  57. package/dist/execution/workflow/linear-orchestrator.d.ts.map +1 -0
  58. package/dist/execution/workflow/memory-storage.d.ts +54 -0
  59. package/dist/execution/workflow/memory-storage.d.ts.map +1 -0
  60. package/dist/execution/workflow/orchestrator.d.ts +158 -0
  61. package/dist/execution/workflow/orchestrator.d.ts.map +1 -0
  62. package/dist/execution/workflow/types.d.ts +172 -0
  63. package/dist/execution/workflow/types.d.ts.map +1 -0
  64. package/dist/execution/workflow/utils.d.ts +89 -0
  65. package/dist/execution/workflow/utils.d.ts.map +1 -0
  66. package/dist/execution/worktree/config.d.ts +74 -0
  67. package/dist/execution/worktree/config.d.ts.map +1 -0
  68. package/dist/execution/worktree/git-cli.d.ts +151 -0
  69. package/dist/execution/worktree/git-cli.d.ts.map +1 -0
  70. package/dist/execution/worktree/index.d.ts +16 -0
  71. package/dist/execution/worktree/index.d.ts.map +1 -0
  72. package/dist/execution/worktree/manager.d.ts +184 -0
  73. package/dist/execution/worktree/manager.d.ts.map +1 -0
  74. package/dist/execution/worktree/types.d.ts +90 -0
  75. package/dist/execution/worktree/types.d.ts.map +1 -0
  76. package/dist/index.d.ts +8 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +104 -0
  79. package/dist/index.js.map +7 -0
  80. package/dist/public/assets/index-C4SmlXoo.js +568 -0
  81. package/dist/public/assets/index-C4SmlXoo.js.map +1 -0
  82. package/dist/public/assets/index-DE59j7ti.css +1 -0
  83. package/dist/public/assets/react-vendor-LX0UoTxg.js +60 -0
  84. package/dist/public/assets/react-vendor-LX0UoTxg.js.map +1 -0
  85. package/dist/public/assets/ui-vendor-_cxVHaqZ.js +54 -0
  86. package/dist/public/assets/ui-vendor-_cxVHaqZ.js.map +1 -0
  87. package/dist/public/favicon.ico +0 -0
  88. package/dist/public/index.html +16 -0
  89. package/dist/public/logo.png +0 -0
  90. package/dist/routes/executions-stream.d.ts +24 -0
  91. package/dist/routes/executions-stream.d.ts.map +1 -0
  92. package/dist/routes/executions.d.ts +19 -0
  93. package/dist/routes/executions.d.ts.map +1 -0
  94. package/dist/routes/feedback.d.ts +7 -0
  95. package/dist/routes/feedback.d.ts.map +1 -0
  96. package/dist/routes/issues.d.ts +7 -0
  97. package/dist/routes/issues.d.ts.map +1 -0
  98. package/dist/routes/relationships.d.ts +7 -0
  99. package/dist/routes/relationships.d.ts.map +1 -0
  100. package/dist/routes/specs.d.ts +7 -0
  101. package/dist/routes/specs.d.ts.map +1 -0
  102. package/dist/services/db.d.ts +33 -0
  103. package/dist/services/db.d.ts.map +1 -0
  104. package/dist/services/execution-lifecycle.d.ts +108 -0
  105. package/dist/services/execution-lifecycle.d.ts.map +1 -0
  106. package/dist/services/execution-service.d.ts +185 -0
  107. package/dist/services/execution-service.d.ts.map +1 -0
  108. package/dist/services/executions.d.ts +59 -0
  109. package/dist/services/executions.d.ts.map +1 -0
  110. package/dist/services/export.d.ts +24 -0
  111. package/dist/services/export.d.ts.map +1 -0
  112. package/dist/services/feedback.d.ts +40 -0
  113. package/dist/services/feedback.d.ts.map +1 -0
  114. package/dist/services/issues.d.ts +27 -0
  115. package/dist/services/issues.d.ts.map +1 -0
  116. package/dist/services/prompt-template-engine.d.ts +108 -0
  117. package/dist/services/prompt-template-engine.d.ts.map +1 -0
  118. package/dist/services/prompt-templates.d.ts +97 -0
  119. package/dist/services/prompt-templates.d.ts.map +1 -0
  120. package/dist/services/relationships.d.ts +35 -0
  121. package/dist/services/relationships.d.ts.map +1 -0
  122. package/dist/services/specs.d.ts +27 -0
  123. package/dist/services/specs.d.ts.map +1 -0
  124. package/dist/services/watcher.d.ts +50 -0
  125. package/dist/services/watcher.d.ts.map +1 -0
  126. package/dist/services/websocket.d.ts +127 -0
  127. package/dist/services/websocket.d.ts.map +1 -0
  128. package/dist/utils/sudocode-dir.d.ts +6 -0
  129. package/dist/utils/sudocode-dir.d.ts.map +1 -0
  130. package/package.json +74 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Prompt Template Engine
3
+ *
4
+ * Simple template engine with Handlebars-like syntax for rendering prompts.
5
+ * Supports variable substitution, conditionals, and loops.
6
+ *
7
+ * @module services/prompt-template-engine
8
+ */
9
+ /**
10
+ * PromptTemplateEngine - Render templates with context variables
11
+ *
12
+ * Template Syntax:
13
+ * - Variables: {{variable}} or {{object.nested.path}}
14
+ * - Conditionals: {{#if variable}}content{{/if}}
15
+ * - Loops: {{#each array}}content{{/each}}
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const engine = new PromptTemplateEngine();
20
+ * const result = engine.render(
21
+ * 'Hello {{name}}!',
22
+ * { name: 'World' }
23
+ * );
24
+ * // Result: 'Hello World!'
25
+ * ```
26
+ */
27
+ export declare class PromptTemplateEngine {
28
+ /**
29
+ * Render template with context variables
30
+ *
31
+ * @param template - Template string with {{variable}} syntax
32
+ * @param context - Object containing variable values
33
+ * @returns Rendered template string
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const template = `
38
+ * Issue: {{issue.title}}
39
+ * {{#if issue.description}}
40
+ * Description: {{issue.description}}
41
+ * {{/if}}
42
+ * {{#each specs}}
43
+ * - [[{{id}}]]: {{title}}
44
+ * {{/each}}
45
+ * `;
46
+ *
47
+ * const context = {
48
+ * issue: { title: 'Bug fix', description: 'Fix auth' },
49
+ * specs: [{ id: 'SPEC-001', title: 'Auth' }]
50
+ * };
51
+ *
52
+ * engine.render(template, context);
53
+ * ```
54
+ */
55
+ render(template: string, context: Record<string, any>): string;
56
+ /**
57
+ * Replace one {{#each}} loop with balanced tags
58
+ * Processes innermost loop first
59
+ */
60
+ private replaceLoop;
61
+ /**
62
+ * Replace one {{#if}} conditional with balanced tags
63
+ */
64
+ private replaceConditional;
65
+ /**
66
+ * Find a balanced {{#tagName}} ... {{/tagName}} pair
67
+ * Returns the FIRST match (outermost, will be processed recursively)
68
+ */
69
+ private findBalancedTag;
70
+ /**
71
+ * Get nested value from context using dot notation
72
+ *
73
+ * @param context - Context object
74
+ * @param path - Dot-separated path (e.g., 'user.name')
75
+ * @returns Value at path or undefined
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * getValue({ user: { name: 'Alice' } }, 'user.name')
80
+ * // Returns: 'Alice'
81
+ * ```
82
+ */
83
+ private getValue;
84
+ /**
85
+ * Validate template syntax
86
+ *
87
+ * Checks for:
88
+ * - Balanced {{#if}} / {{/if}} tags
89
+ * - Balanced {{#each}} / {{/each}} tags
90
+ *
91
+ * @param template - Template string to validate
92
+ * @returns Validation result with errors if any
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * engine.validate('{{#if x}}content{{/if}}')
97
+ * // Returns: { valid: true, errors: [] }
98
+ *
99
+ * engine.validate('{{#if x}}content')
100
+ * // Returns: { valid: false, errors: ['Unbalanced {{#if}} tags'] }
101
+ * ```
102
+ */
103
+ validate(template: string): {
104
+ valid: boolean;
105
+ errors: string[];
106
+ };
107
+ }
108
+ //# sourceMappingURL=prompt-template-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-template-engine.d.ts","sourceRoot":"","sources":["../../src/services/prompt-template-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,oBAAoB;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IA8B9D;;;OAGG;IACH,OAAO,CAAC,WAAW;IAkBnB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;;OAGG;IACH,OAAO,CAAC,eAAe;IA8CvB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,QAAQ;IAYhB;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;CAwBjE"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Prompt Templates Service
3
+ *
4
+ * Manages prompt templates in the database, including:
5
+ * - Seeding default templates
6
+ * - Loading templates by ID or type
7
+ * - Validating template syntax
8
+ *
9
+ * @module services/prompt-templates
10
+ */
11
+ import type Database from 'better-sqlite3';
12
+ /**
13
+ * Prompt template record from database
14
+ */
15
+ export interface PromptTemplate {
16
+ id: string;
17
+ name: string;
18
+ description: string | null;
19
+ type: 'issue' | 'spec' | 'custom';
20
+ template: string;
21
+ variables: string;
22
+ is_default: number;
23
+ created_at: number;
24
+ updated_at: number;
25
+ }
26
+ /**
27
+ * Initialize default prompt templates in the database
28
+ *
29
+ * This function is idempotent - it will only insert templates if they don't exist.
30
+ * Should be called during database initialization.
31
+ *
32
+ * @param db - Database instance
33
+ */
34
+ export declare function initializeDefaultTemplates(db: Database.Database): void;
35
+ /**
36
+ * Get default template for a specific type
37
+ *
38
+ * @param db - Database instance
39
+ * @param type - Template type (issue, spec, custom)
40
+ * @returns Default template or null if not found
41
+ */
42
+ export declare function getDefaultTemplate(db: Database.Database, type: 'issue' | 'spec' | 'custom'): PromptTemplate | null;
43
+ /**
44
+ * Get template by ID
45
+ *
46
+ * @param db - Database instance
47
+ * @param templateId - Template ID
48
+ * @returns Template or null if not found
49
+ */
50
+ export declare function getTemplateById(db: Database.Database, templateId: string): PromptTemplate | null;
51
+ /**
52
+ * List all templates, optionally filtered by type
53
+ *
54
+ * @param db - Database instance
55
+ * @param type - Optional type filter
56
+ * @returns Array of templates
57
+ */
58
+ export declare function listTemplates(db: Database.Database, type?: 'issue' | 'spec' | 'custom'): PromptTemplate[];
59
+ /**
60
+ * Create a new custom template
61
+ *
62
+ * @param db - Database instance
63
+ * @param params - Template parameters
64
+ * @returns Created template
65
+ */
66
+ export declare function createTemplate(db: Database.Database, params: {
67
+ name: string;
68
+ description?: string;
69
+ type: 'issue' | 'spec' | 'custom';
70
+ template: string;
71
+ variables: string[];
72
+ isDefault?: boolean;
73
+ }): PromptTemplate;
74
+ /**
75
+ * Update an existing template
76
+ *
77
+ * @param db - Database instance
78
+ * @param templateId - Template ID
79
+ * @param updates - Fields to update
80
+ * @returns Updated template or null if not found
81
+ */
82
+ export declare function updateTemplate(db: Database.Database, templateId: string, updates: {
83
+ name?: string;
84
+ description?: string;
85
+ template?: string;
86
+ variables?: string[];
87
+ isDefault?: boolean;
88
+ }): PromptTemplate | null;
89
+ /**
90
+ * Delete a template
91
+ *
92
+ * @param db - Database instance
93
+ * @param templateId - Template ID
94
+ * @returns True if deleted, false if not found
95
+ */
96
+ export declare function deleteTemplate(db: Database.Database, templateId: string): boolean;
97
+ //# sourceMappingURL=prompt-templates.d.ts.map
@@ -0,0 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AO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACA,cAAc,CA+BhB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACA,cAAc,GAAG,IAAI,CA0DvB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAMT"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Service layer for Relationships API
3
+ * Wraps CLI operations for managing relationships between specs and issues
4
+ */
5
+ import type Database from "better-sqlite3";
6
+ import type { Relationship, EntityType, RelationshipType } from "@sudocode-ai/types";
7
+ import { type CreateRelationshipInput } from "@sudocode-ai/cli/dist/operations/relationships.js";
8
+ /**
9
+ * Create a new relationship between entities
10
+ */
11
+ export declare function createRelationship(db: Database.Database, input: CreateRelationshipInput): Relationship;
12
+ /**
13
+ * Get a specific relationship
14
+ */
15
+ export declare function getSpecificRelationship(db: Database.Database, from_id: string, from_type: EntityType, to_id: string, to_type: EntityType, relationship_type: RelationshipType): Relationship | null;
16
+ /**
17
+ * Delete a relationship
18
+ */
19
+ export declare function deleteRelationship(db: Database.Database, from_id: string, from_type: EntityType, to_id: string, to_type: EntityType, relationship_type: RelationshipType): boolean;
20
+ /**
21
+ * Get all outgoing relationships from an entity
22
+ */
23
+ export declare function getEntityOutgoingRelationships(db: Database.Database, entity_id: string, entity_type: EntityType, relationship_type?: RelationshipType): Relationship[];
24
+ /**
25
+ * Get all incoming relationships to an entity
26
+ */
27
+ export declare function getEntityIncomingRelationships(db: Database.Database, entity_id: string, entity_type: EntityType, relationship_type?: RelationshipType): Relationship[];
28
+ /**
29
+ * Get all relationships for an entity (both incoming and outgoing)
30
+ */
31
+ export declare function getEntityRelationships(db: Database.Database, entity_id: string, entity_type: EntityType): {
32
+ outgoing: Relationship[];
33
+ incoming: Relationship[];
34
+ };
35
+ //# sourceMappingURL=relationships.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/services/relationships.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAOL,KAAK,uBAAuB,EAC7B,MAAM,mDAAmD,CAAC;AAE3D;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,uBAAuB,GAC7B,YAAY,CAEd;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,EACnB,iBAAiB,EAAE,gBAAgB,GAClC,YAAY,GAAG,IAAI,CASrB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,UAAU,EACnB,iBAAiB,EAAE,gBAAgB,GAClC,OAAO,CAST;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,UAAU,EACvB,iBAAiB,CAAC,EAAE,gBAAgB,GACnC,YAAY,EAAE,CAOhB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,UAAU,EACvB,iBAAiB,CAAC,EAAE,gBAAgB,GACnC,YAAY,EAAE,CAOhB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,UAAU,GACtB;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,CAExD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Specs service - wraps CLI operations for API use
3
+ */
4
+ import type Database from "better-sqlite3";
5
+ import { type CreateSpecInput, type UpdateSpecInput, type ListSpecsOptions } from "@sudocode-ai/cli/dist/operations/index.js";
6
+ import type { Spec } from "@sudocode-ai/types";
7
+ /**
8
+ * Get all specs with optional filtering
9
+ */
10
+ export declare function getAllSpecs(db: Database.Database, options?: ListSpecsOptions): Spec[];
11
+ /**
12
+ * Get a single spec by ID
13
+ */
14
+ export declare function getSpecById(db: Database.Database, id: string): Spec | null;
15
+ /**
16
+ * Create a new spec
17
+ */
18
+ export declare function createNewSpec(db: Database.Database, input: CreateSpecInput): Spec;
19
+ /**
20
+ * Update an existing spec
21
+ */
22
+ export declare function updateExistingSpec(db: Database.Database, id: string, input: UpdateSpecInput): Spec;
23
+ /**
24
+ * Delete a spec
25
+ */
26
+ export declare function deleteExistingSpec(db: Database.Database, id: string): boolean;
27
+ //# sourceMappingURL=specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specs.d.ts","sourceRoot":"","sources":["../../src/services/specs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,CAAC,EAAE,gBAAgB,GACzB,IAAI,EAAE,CAER;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,eAAe,GACrB,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,eAAe,GACrB,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAE7E"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * File watcher service for the server
3
+ * Reuses the CLI watcher with server-specific callbacks
4
+ */
5
+ import type Database from "better-sqlite3";
6
+ import { type WatcherStats } from "@sudocode-ai/cli/dist/watcher.js";
7
+ export interface ServerWatcherOptions {
8
+ /**
9
+ * Database instance
10
+ */
11
+ db: Database.Database;
12
+ /**
13
+ * Base directory to watch (e.g., .sudocode)
14
+ */
15
+ baseDir: string;
16
+ /**
17
+ * Debounce delay in milliseconds (default: 2000)
18
+ */
19
+ debounceDelay?: number;
20
+ /**
21
+ * Enable reverse sync (JSONL → Markdown) when JSONL files change (default: false)
22
+ */
23
+ syncJSONLToMarkdown?: boolean;
24
+ /**
25
+ * Callback for file change events
26
+ * This will be used to broadcast WebSocket updates
27
+ */
28
+ onFileChange?: (info: {
29
+ filePath: string;
30
+ event: "add" | "change" | "unlink";
31
+ entityType?: "spec" | "issue";
32
+ entityId?: string;
33
+ }) => void;
34
+ }
35
+ export interface ServerWatcherControl {
36
+ /**
37
+ * Stop watching files
38
+ */
39
+ stop: () => Promise<void>;
40
+ /**
41
+ * Get watcher statistics
42
+ */
43
+ getStats: () => WatcherStats;
44
+ }
45
+ /**
46
+ * Start the file watcher for the server
47
+ * This wraps the CLI watcher with server-specific logging and callbacks
48
+ */
49
+ export declare function startServerWatcher(options: ServerWatcherOptions): ServerWatcherControl;
50
+ //# sourceMappingURL=watcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/services/watcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACnC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,KAAK,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,YAAY,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,oBAAoB,GAC5B,oBAAoB,CA4EtB"}
@@ -0,0 +1,127 @@
1
+ import * as http from "http";
2
+ /**
3
+ * Message types that the server sends to clients
4
+ */
5
+ export interface ServerMessage {
6
+ type: "issue_created" | "issue_updated" | "issue_deleted" | "spec_created" | "spec_updated" | "spec_deleted" | "feedback_created" | "feedback_updated" | "feedback_deleted" | "relationship_created" | "relationship_deleted" | "pong" | "error" | "subscribed" | "unsubscribed";
7
+ data?: any;
8
+ message?: string;
9
+ subscription?: string;
10
+ }
11
+ /**
12
+ * WebSocket server manager
13
+ */
14
+ declare class WebSocketManager {
15
+ private wss;
16
+ private clients;
17
+ private heartbeatInterval;
18
+ private readonly HEARTBEAT_INTERVAL;
19
+ /**
20
+ * Initialize the WebSocket server
21
+ */
22
+ init(server: http.Server, path?: string): void;
23
+ /**
24
+ * Handle new WebSocket connection
25
+ */
26
+ private handleConnection;
27
+ /**
28
+ * Handle client disconnection
29
+ */
30
+ private handleDisconnection;
31
+ /**
32
+ * Handle client errors
33
+ */
34
+ private handleError;
35
+ /**
36
+ * Handle pong response from client
37
+ */
38
+ private handlePong;
39
+ /**
40
+ * Handle incoming messages from clients
41
+ */
42
+ private handleMessage;
43
+ /**
44
+ * Handle subscription request
45
+ */
46
+ private handleSubscribe;
47
+ /**
48
+ * Handle unsubscription request
49
+ */
50
+ private handleUnsubscribe;
51
+ /**
52
+ * Send a message to a specific client
53
+ */
54
+ private sendToClient;
55
+ /**
56
+ * Broadcast a message to all subscribed clients
57
+ */
58
+ broadcast(entityType: "issue" | "spec", entityId: string, message: ServerMessage): void;
59
+ /**
60
+ * Broadcast a relationship or feedback update
61
+ * These don't have a specific entity type in the subscription, so we broadcast to 'all' subscribers
62
+ */
63
+ broadcastGeneric(message: ServerMessage): void;
64
+ /**
65
+ * Start the heartbeat mechanism to detect dead connections
66
+ */
67
+ private startHeartbeat;
68
+ /**
69
+ * Stop the heartbeat mechanism
70
+ */
71
+ private stopHeartbeat;
72
+ /**
73
+ * Get statistics about connected clients
74
+ */
75
+ getStats(): {
76
+ totalClients: number;
77
+ clients: Array<{
78
+ id: string;
79
+ subscriptions: string[];
80
+ connectedAt: string;
81
+ isAlive: boolean;
82
+ }>;
83
+ };
84
+ /**
85
+ * Gracefully shutdown the WebSocket server
86
+ */
87
+ shutdown(): Promise<void>;
88
+ }
89
+ export declare const websocketManager: WebSocketManager;
90
+ /**
91
+ * Initialize the WebSocket server
92
+ */
93
+ export declare function initWebSocketServer(server: http.Server, path?: string): void;
94
+ /**
95
+ * Broadcast issue updates to subscribed clients
96
+ */
97
+ export declare function broadcastIssueUpdate(issueId: string, action: "created" | "updated" | "deleted", data?: any): void;
98
+ /**
99
+ * Broadcast spec updates to subscribed clients
100
+ */
101
+ export declare function broadcastSpecUpdate(specId: string, action: "created" | "updated" | "deleted", data?: any): void;
102
+ /**
103
+ * Broadcast feedback updates to subscribed clients
104
+ */
105
+ export declare function broadcastFeedbackUpdate(action: "created" | "updated" | "deleted", data?: any): void;
106
+ /**
107
+ * Broadcast relationship updates to subscribed clients
108
+ */
109
+ export declare function broadcastRelationshipUpdate(action: "created" | "deleted", data?: any): void;
110
+ /**
111
+ * Get WebSocket server statistics
112
+ */
113
+ export declare function getWebSocketStats(): {
114
+ totalClients: number;
115
+ clients: Array<{
116
+ id: string;
117
+ subscriptions: string[];
118
+ connectedAt: string;
119
+ isAlive: boolean;
120
+ }>;
121
+ };
122
+ /**
123
+ * Shutdown the WebSocket server
124
+ */
125
+ export declare function shutdownWebSocketServer(): Promise<void>;
126
+ export {};
127
+ //# sourceMappingURL=websocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/services/websocket.ts"],"names":[],"mappings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;AAED;;GAEG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE7D"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility to get the SUDOCODE directory path
3
+ * Respects SUDOCODE_DIR environment variable for testing
4
+ */
5
+ export declare function getSudocodeDir(): string;
6
+ //# sourceMappingURL=sudocode-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sudocode-dir.d.ts","sourceRoot":"","sources":["../../src/utils/sudocode-dir.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@sudocode-ai/local-server",
3
+ "version": "0.1.0",
4
+ "description": "Local backend server for sudocode - provides REST API and WebSocket endpoints",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "sudocode-server": "dist/cli.js"
9
+ },
10
+ "scripts": {
11
+ "dev": "tsx watch src/index.ts",
12
+ "build": "node build.js",
13
+ "build:dev": "tsc && chmod +x dist/cli.js",
14
+ "start": "node dist/index.js",
15
+ "test": "NODE_ENV=test vitest",
16
+ "test:e2e": "RUN_E2E_TESTS=true NODE_ENV=test vitest --run",
17
+ "typecheck": "tsc --noEmit",
18
+ "clean": "rm -rf dist"
19
+ },
20
+ "keywords": [
21
+ "sudocode",
22
+ "server",
23
+ "api",
24
+ "backend"
25
+ ],
26
+ "author": "sudocode AI",
27
+ "license": "Apache-2.0",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/sudocode-ai/sudocode.git",
31
+ "directory": "server"
32
+ },
33
+ "homepage": "https://sudocode.ai",
34
+ "bugs": {
35
+ "url": "https://github.com/sudocode-ai/sudocode/issues"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "engines": {
41
+ "node": ">=18.0.0"
42
+ },
43
+ "dependencies": {
44
+ "@ag-ui/core": "^0.0.39",
45
+ "@copilotkit/runtime": "^1.10.6",
46
+ "@sudocode-ai/cli": "^0.1.0",
47
+ "@sudocode-ai/types": "^0.1.0",
48
+ "@types/ws": "^8.18.1",
49
+ "async-mutex": "^0.5.0",
50
+ "better-sqlite3": "^11.8.1",
51
+ "cors": "^2.8.5",
52
+ "dotenv": "^16.4.5",
53
+ "express": "^4.18.2",
54
+ "glob": "^11.0.3",
55
+ "node-fetch": "^2.7.0",
56
+ "ws": "^8.18.3",
57
+ "zod": "^3.22.4"
58
+ },
59
+ "devDependencies": {
60
+ "@types/better-sqlite3": "^7.6.8",
61
+ "@types/cors": "^2.8.17",
62
+ "@types/express": "^4.17.21",
63
+ "@types/node": "^20.11.19",
64
+ "@types/supertest": "^6.0.3",
65
+ "esbuild": "^0.24.2",
66
+ "supertest": "^7.1.4",
67
+ "tsx": "^4.7.1",
68
+ "typescript": "^5.3.3",
69
+ "vitest": "^3.2.4"
70
+ },
71
+ "files": [
72
+ "dist/**/*"
73
+ ]
74
+ }