@ace-sdk/core 2.0.1 → 2.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.
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Bootstrap SSE Event Types
3
+ *
4
+ * Server sends these events during streaming bootstrap.
5
+ * Client displays progress to user.
6
+ *
7
+ * Updated to match ACE Server v3.13.0 response format.
8
+ *
9
+ * @package @ace-sdk/core
10
+ */
11
+ /**
12
+ * Human-readable labels for stages
13
+ */
14
+ export const BOOTSTRAP_STAGE_LABELS = {
15
+ received: 'Receiving code blocks',
16
+ analyzing: 'Analyzing patterns',
17
+ synthesizing: 'Synthesizing insights',
18
+ merging: 'Merging into playbook',
19
+ done: 'Bootstrap complete',
20
+ error: 'Error occurred'
21
+ };
22
+ // =============================================================================
23
+ // Type Guards
24
+ // =============================================================================
25
+ /**
26
+ * Type guard for received stage
27
+ */
28
+ export function isReceivedEvent(event) {
29
+ return event.stage === 'received';
30
+ }
31
+ /**
32
+ * Type guard for analyzing stage
33
+ */
34
+ export function isAnalyzingEvent(event) {
35
+ return event.stage === 'analyzing';
36
+ }
37
+ /**
38
+ * Type guard for synthesizing stage
39
+ */
40
+ export function isSynthesizingEvent(event) {
41
+ return event.stage === 'synthesizing';
42
+ }
43
+ /**
44
+ * Type guard for merging stage
45
+ */
46
+ export function isMergingEvent(event) {
47
+ return event.stage === 'merging';
48
+ }
49
+ /**
50
+ * Type guard for done stage
51
+ */
52
+ export function isDoneEvent(event) {
53
+ return event.stage === 'done';
54
+ }
55
+ /**
56
+ * Type guard for error stage
57
+ */
58
+ export function isErrorEvent(event) {
59
+ return event.stage === 'error';
60
+ }
61
+ /**
62
+ * Check if event is a terminal event (done or error)
63
+ */
64
+ export function isTerminalEvent(event) {
65
+ return event.stage === 'done' || event.stage === 'error';
66
+ }
67
+ /**
68
+ * @deprecated Use isDoneEvent instead
69
+ */
70
+ export function isCompleteEvent(event) {
71
+ return event.stage === 'done';
72
+ }
73
+ /**
74
+ * @deprecated Use isReceivedEvent instead
75
+ */
76
+ export function isStartedEvent(event) {
77
+ return event.stage === 'received';
78
+ }
79
+ /**
80
+ * @deprecated Use isAnalyzingEvent or isSynthesizingEvent instead
81
+ */
82
+ export function isStageEvent(event) {
83
+ return ['analyzing', 'synthesizing', 'merging'].includes(event.stage);
84
+ }
85
+ /**
86
+ * @deprecated Progress is embedded in stage messages
87
+ */
88
+ export function isProgressEvent(_event) {
89
+ return false;
90
+ }
91
+ /**
92
+ * @deprecated Patterns data is in done event
93
+ */
94
+ export function isPatternsEvent(_event) {
95
+ return false;
96
+ }
97
+ /**
98
+ * @deprecated Health data is in done event
99
+ */
100
+ export function isHealthEvent(_event) {
101
+ return false;
102
+ }
103
+ //# sourceMappingURL=bootstrap-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-events.js","sourceRoot":"","sources":["../../src/types/bootstrap-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA8BH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAmC;IACpE,QAAQ,EAAE,uBAAuB;IACjC,SAAS,EAAE,oBAAoB;IAC/B,YAAY,EAAE,uBAAuB;IACrC,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,gBAAgB;CACxB,CAAC;AAyHF,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAwB;IAExB,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAwB;IAExB,OAAO,KAAK,CAAC,KAAK,KAAK,WAAW,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAwB;IAExB,OAAO,KAAK,CAAC,KAAK,KAAK,cAAc,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAwB;IAExB,OAAO,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,KAAwB;IAExB,OAAO,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAwB;IAExB,OAAO,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB;IACtD,OAAO,KAAK,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC;AAC3D,CAAC;AAkBD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB;IACtD,OAAO,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,OAAO,CAAC,WAAW,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB;IACvD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB;IACvD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB;IACrD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Project DNA - Fingerprint for intelligent pattern matching
3
+ *
4
+ * Shared schema between @ace-sdk/core and ACE Server.
5
+ * Server stores this in `projects.settings_json` field.
6
+ *
7
+ * @package @ace-sdk/core
8
+ */
9
+ /**
10
+ * Language breakdown from linguist-js
11
+ */
12
+ export interface LanguageStats {
13
+ /** Language name (e.g., "TypeScript", "Python", "Java") */
14
+ name: string;
15
+ /** Percentage of codebase (0-100) */
16
+ percentage: number;
17
+ /** Number of files with this language */
18
+ files: number;
19
+ /** Total bytes of code */
20
+ bytes: number;
21
+ }
22
+ /**
23
+ * Detected project type based on folder structure and dependencies
24
+ */
25
+ export type ProjectType = 'library' | 'webapp' | 'api-server' | 'cli' | 'monorepo' | 'mobile' | 'unknown';
26
+ /**
27
+ * Framework detected from dependencies
28
+ */
29
+ export interface FrameworkInfo {
30
+ /** Framework name (e.g., "React", "Express", "FastAPI") */
31
+ name: string;
32
+ /** Semver version from package.json/requirements.txt */
33
+ version: string;
34
+ /** Framework category */
35
+ category: 'frontend' | 'backend' | 'testing' | 'build' | 'utility';
36
+ }
37
+ /**
38
+ * Metrics from import graph analysis
39
+ */
40
+ export interface GraphMetrics {
41
+ /** Total files in the graph */
42
+ totalFiles: number;
43
+ /** Files with 5+ importers (max 20) */
44
+ hubFiles: string[];
45
+ /** Files with no dependents (max 10) */
46
+ entryPoints: string[];
47
+ /** Files with no dependencies (max 20) */
48
+ leafNodes: string[];
49
+ /** Circular dependency chains (max 10) */
50
+ circularDeps: string[][];
51
+ }
52
+ /**
53
+ * Code health indicators from static analysis
54
+ */
55
+ export interface CodeHealthMetrics {
56
+ /** Percentage of files never imported */
57
+ deadCodePercentage: number;
58
+ /** Number of circular dependency chains */
59
+ circularDepsCount: number;
60
+ /** Number of unused package.json dependencies */
61
+ unusedDepsCount: number;
62
+ /** Average lines per file */
63
+ avgFileSize: number;
64
+ /** Largest file (lines) */
65
+ maxFileSize: number;
66
+ }
67
+ /**
68
+ * Detected architecture patterns
69
+ */
70
+ export interface PatternDetection {
71
+ /** Error handling approach */
72
+ errorHandling?: 'centralized' | 'distributed' | 'mixed';
73
+ /** Testing approach */
74
+ testingApproach?: 'unit' | 'integration' | 'e2e' | 'mixed' | 'none';
75
+ /** API style */
76
+ apiStyle?: 'rest' | 'graphql' | 'trpc' | 'grpc' | 'mixed';
77
+ /** State management solution */
78
+ stateManagement?: string;
79
+ }
80
+ /**
81
+ * Recommendation from code analysis
82
+ */
83
+ export interface Recommendation {
84
+ /** Priority level */
85
+ priority: 'high' | 'medium' | 'low';
86
+ /** Recommendation category */
87
+ category: 'architecture' | 'performance' | 'maintainability' | 'security';
88
+ /** Human-readable message */
89
+ message: string;
90
+ /** Affected files (optional) */
91
+ affectedFiles?: string[];
92
+ }
93
+ /**
94
+ * Complete Project DNA fingerprint
95
+ *
96
+ * This is the main data structure sent to the server for storage
97
+ * and used for cross-project pattern matching.
98
+ */
99
+ export interface ProjectDNA {
100
+ /** Organization ID */
101
+ orgId: string;
102
+ /** Project ID */
103
+ projectId: string;
104
+ /** ISO 8601 timestamp when analyzed */
105
+ analyzedAt: string;
106
+ /** Git commit hash at analysis time */
107
+ gitCommit?: string;
108
+ /** Detected project type */
109
+ projectType: ProjectType;
110
+ /** Language breakdown (sorted by percentage desc) */
111
+ languages: LanguageStats[];
112
+ /** Primary language name */
113
+ primaryLanguage: string;
114
+ /** Detected frameworks */
115
+ frameworks: FrameworkInfo[];
116
+ /** Detected patterns */
117
+ patterns: PatternDetection;
118
+ /** Import graph metrics */
119
+ graph: GraphMetrics;
120
+ /** Code health metrics */
121
+ health: CodeHealthMetrics;
122
+ /** Analysis recommendations */
123
+ recommendations: Recommendation[];
124
+ }
125
+ /**
126
+ * Request to store Project DNA on server
127
+ */
128
+ export interface StoreProjectDNARequest {
129
+ orgId: string;
130
+ projectId: string;
131
+ dna: ProjectDNA;
132
+ }
133
+ /**
134
+ * Response from server after storing DNA
135
+ */
136
+ export interface StoreProjectDNAResponse {
137
+ /** Whether storage succeeded */
138
+ success: boolean;
139
+ /** Timestamp when stored */
140
+ storedAt: string;
141
+ /** Similar projects for cross-project learning (future) */
142
+ similarProjects?: {
143
+ projectId: string;
144
+ similarity: number;
145
+ }[];
146
+ }
147
+ /**
148
+ * Create a default empty ProjectDNA structure
149
+ */
150
+ export declare function createEmptyProjectDNA(orgId: string, projectId: string): ProjectDNA;
151
+ //# sourceMappingURL=project-dna.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-dna.d.ts","sourceRoot":"","sources":["../../src/types/project-dna.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAMD;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,KAAK,GACL,UAAU,GACV,QAAQ,GACR,SAAS,CAAC;AAMd;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;CACpE;AAMD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,wCAAwC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;CAC1B;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,iBAA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UAAU,EAAE,aAAa,EAAE,CAAC;IAG5B,wBAAwB;IACxB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,2BAA2B;IAC3B,KAAK,EAAE,YAAY,CAAC;IAGpB,0BAA0B;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAG1B,+BAA+B;IAC/B,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC;AAMD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,UAAU,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,eAAe,CAAC,EAAE;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,EAAE,CAAC;CACL;AAMD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,UAAU,CA0BZ"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Project DNA - Fingerprint for intelligent pattern matching
3
+ *
4
+ * Shared schema between @ace-sdk/core and ACE Server.
5
+ * Server stores this in `projects.settings_json` field.
6
+ *
7
+ * @package @ace-sdk/core
8
+ */
9
+ // =============================================================================
10
+ // Builder Helper
11
+ // =============================================================================
12
+ /**
13
+ * Create a default empty ProjectDNA structure
14
+ */
15
+ export function createEmptyProjectDNA(orgId, projectId) {
16
+ return {
17
+ orgId,
18
+ projectId,
19
+ analyzedAt: new Date().toISOString(),
20
+ projectType: 'unknown',
21
+ languages: [],
22
+ primaryLanguage: 'Unknown',
23
+ frameworks: [],
24
+ patterns: {},
25
+ graph: {
26
+ totalFiles: 0,
27
+ hubFiles: [],
28
+ entryPoints: [],
29
+ leafNodes: [],
30
+ circularDeps: []
31
+ },
32
+ health: {
33
+ deadCodePercentage: 0,
34
+ circularDepsCount: 0,
35
+ unusedDepsCount: 0,
36
+ avgFileSize: 0,
37
+ maxFileSize: 0
38
+ },
39
+ recommendations: []
40
+ };
41
+ }
42
+ //# sourceMappingURL=project-dna.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-dna.js","sourceRoot":"","sources":["../../src/types/project-dna.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0MH,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAa,EACb,SAAiB;IAEjB,OAAO;QACL,KAAK;QACL,SAAS;QACT,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,WAAW,EAAE,SAAS;QACtB,SAAS,EAAE,EAAE;QACb,eAAe,EAAE,SAAS;QAC1B,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE;YACL,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;SACjB;QACD,MAAM,EAAE;YACN,kBAAkB,EAAE,CAAC;YACrB,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,CAAC;YAClB,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,CAAC;SACf;QACD,eAAe,EAAE,EAAE;KACpB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ace-sdk/core",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "ACE Core - Shared library for ACE pattern learning (HTTP client, caching, config, types)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,7 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "better-sqlite3": "^12.4.6",
41
- "linguist-js": "^2.9.2"
41
+ "linguist-js": "^2.9.2",
42
+ "skott": "^0.35.6"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/better-sqlite3": "^7.6.13",