@cleocode/contracts 2026.4.100 → 2026.4.101
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/brain-graph.d.ts +245 -0
- package/dist/brain-graph.d.ts.map +1 -0
- package/dist/brain-graph.js +30 -0
- package/dist/brain-graph.js.map +1 -0
- package/dist/exit-codes.d.ts +1 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +1 -1
- package/dist/exit-codes.js.map +1 -1
- package/dist/graph.d.ts +2 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nexus-contract-ops.d.ts +186 -0
- package/dist/nexus-contract-ops.d.ts.map +1 -0
- package/dist/nexus-contract-ops.js +11 -0
- package/dist/nexus-contract-ops.js.map +1 -0
- package/dist/nexus-living-brain-ops.d.ts +314 -0
- package/dist/nexus-living-brain-ops.d.ts.map +1 -0
- package/dist/nexus-living-brain-ops.js +15 -0
- package/dist/nexus-living-brain-ops.js.map +1 -0
- package/dist/nexus-query-ops.d.ts +82 -0
- package/dist/nexus-query-ops.d.ts.map +1 -0
- package/dist/nexus-query-ops.js +11 -0
- package/dist/nexus-query-ops.js.map +1 -0
- package/dist/nexus-route-ops.d.ts +103 -0
- package/dist/nexus-route-ops.d.ts.map +1 -0
- package/dist/nexus-route-ops.js +10 -0
- package/dist/nexus-route-ops.js.map +1 -0
- package/dist/nexus-tasks-bridge-ops.d.ts +68 -0
- package/dist/nexus-tasks-bridge-ops.d.ts.map +1 -0
- package/dist/nexus-tasks-bridge-ops.js +11 -0
- package/dist/nexus-tasks-bridge-ops.js.map +1 -0
- package/dist/nexus-wiki-ops.d.ts +51 -0
- package/dist/nexus-wiki-ops.d.ts.map +1 -0
- package/dist/nexus-wiki-ops.js +11 -0
- package/dist/nexus-wiki-ops.js.map +1 -0
- package/dist/operations/admin.d.ts +1781 -0
- package/dist/operations/admin.d.ts.map +1 -0
- package/dist/operations/admin.js +27 -0
- package/dist/operations/admin.js.map +1 -0
- package/dist/operations/brain.d.ts +34 -26
- package/dist/operations/brain.d.ts.map +1 -1
- package/dist/operations/brain.js +7 -6
- package/dist/operations/brain.js.map +1 -1
- package/dist/operations/docs.d.ts +279 -0
- package/dist/operations/docs.d.ts.map +1 -0
- package/dist/operations/docs.js +31 -0
- package/dist/operations/docs.js.map +1 -0
- package/dist/operations/intelligence.d.ts +319 -0
- package/dist/operations/intelligence.d.ts.map +1 -0
- package/dist/operations/intelligence.js +24 -0
- package/dist/operations/intelligence.js.map +1 -0
- package/dist/operations/orchestrate.d.ts +113 -2
- package/dist/operations/orchestrate.d.ts.map +1 -1
- package/dist/operations/orchestrate.js +3 -2
- package/dist/operations/orchestrate.js.map +1 -1
- package/dist/operations/session.d.ts +185 -47
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/session.js +7 -6
- package/dist/operations/session.js.map +1 -1
- package/dist/operations/sticky.d.ts +264 -0
- package/dist/operations/sticky.d.ts.map +1 -0
- package/dist/operations/sticky.js +19 -0
- package/dist/operations/sticky.js.map +1 -0
- package/dist/operations/validate.d.ts +145 -19
- package/dist/operations/validate.d.ts.map +1 -1
- package/dist/operations/validate.js +3 -3
- package/dist/task-record.d.ts +19 -0
- package/dist/task-record.d.ts.map +1 -1
- package/package.json +41 -1
- package/src/brain-graph.ts +282 -0
- package/src/exit-codes.ts +1 -1
- package/src/graph.ts +2 -0
- package/src/index.ts +109 -0
- package/src/nexus-contract-ops.ts +244 -0
- package/src/nexus-living-brain-ops.ts +345 -0
- package/src/nexus-query-ops.ts +100 -0
- package/src/nexus-route-ops.ts +134 -0
- package/src/nexus-tasks-bridge-ops.ts +71 -0
- package/src/nexus-wiki-ops.ts +53 -0
- package/src/operations/admin.ts +2087 -0
- package/src/operations/brain.ts +34 -26
- package/src/operations/docs.ts +322 -0
- package/src/operations/intelligence.ts +399 -0
- package/src/operations/orchestrate.ts +117 -2
- package/src/operations/session.ts +217 -48
- package/src/operations/sticky.ts +308 -0
- package/src/operations/validate.ts +161 -55
- package/src/task-record.ts +19 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nexus SQLite Recursive CTE Query Operations - Contract Layer
|
|
3
|
+
*
|
|
4
|
+
* Defines types for parameterized CTE execution against nexus.db.
|
|
5
|
+
* Contracts for the query DSL and template alias system.
|
|
6
|
+
*
|
|
7
|
+
* @task T1057
|
|
8
|
+
* @epic T1042
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Result of a recursive CTE query against nexus.db.
|
|
13
|
+
* Returns rows as generic Record[] and metadata about the query.
|
|
14
|
+
*/
|
|
15
|
+
export interface NexusCteResult {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the query executed successfully.
|
|
18
|
+
*/
|
|
19
|
+
success: boolean;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Query result rows. Empty array if no results.
|
|
23
|
+
*/
|
|
24
|
+
rows: Array<Record<string, unknown>>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Total number of rows returned.
|
|
28
|
+
*/
|
|
29
|
+
row_count: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Query execution time in milliseconds.
|
|
33
|
+
*/
|
|
34
|
+
execution_time_ms: number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* If success is false, error message describing the parse/execution failure.
|
|
38
|
+
* e.g. "CTE syntax error: ...", "Parameter mismatch: ..."
|
|
39
|
+
*/
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Parameters for CTE execution.
|
|
45
|
+
* Supports positional (?) and named (:name) parameter binding.
|
|
46
|
+
*/
|
|
47
|
+
export type NexusCteParams = (string | number | null)[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Named template alias for common CTE patterns.
|
|
51
|
+
* Compiles to parameterized CTE before execution.
|
|
52
|
+
*/
|
|
53
|
+
export type NexusCteAlias =
|
|
54
|
+
| 'callers-of'
|
|
55
|
+
| 'callees-of'
|
|
56
|
+
| 'co-changed'
|
|
57
|
+
| 'co-cited'
|
|
58
|
+
| 'path-between'
|
|
59
|
+
| 'community-members';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Represents a compiled CTE template ready for execution.
|
|
63
|
+
* Internal: generated by compileCteAlias().
|
|
64
|
+
*/
|
|
65
|
+
export interface NexusCtePlaceholder {
|
|
66
|
+
/**
|
|
67
|
+
* The CTE SQL string with parameter placeholders.
|
|
68
|
+
*/
|
|
69
|
+
cte: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Human-readable description of what this CTE queries.
|
|
73
|
+
*/
|
|
74
|
+
description: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Expected parameter count for this template.
|
|
78
|
+
*/
|
|
79
|
+
paramCount: number;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Parameter names for documentation.
|
|
83
|
+
*/
|
|
84
|
+
paramNames: string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Formatted markdown table of query results.
|
|
89
|
+
*/
|
|
90
|
+
export interface NexusCteMarkdownTable {
|
|
91
|
+
/**
|
|
92
|
+
* Markdown-formatted table string.
|
|
93
|
+
*/
|
|
94
|
+
markdown: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Number of rows in the table.
|
|
98
|
+
*/
|
|
99
|
+
row_count: number;
|
|
100
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route and API shape analysis contracts for NEXUS.
|
|
3
|
+
*
|
|
4
|
+
* Routes are first-class nodes in the code graph (kind: 'route').
|
|
5
|
+
* This module defines the query results for route mapping and shape checking.
|
|
6
|
+
*
|
|
7
|
+
* @task T1064 — Route-Map and Shape-Check Commands
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A single route handler entry from `route-map`.
|
|
12
|
+
*
|
|
13
|
+
* Maps a route node to its handler functions and downstream dependencies.
|
|
14
|
+
*/
|
|
15
|
+
export interface RouteMapEntry {
|
|
16
|
+
/** Route node ID (format: `<filePath>::<routeName>`). */
|
|
17
|
+
routeId: string;
|
|
18
|
+
|
|
19
|
+
/** Route handler function symbol ID. */
|
|
20
|
+
handlerId: string;
|
|
21
|
+
|
|
22
|
+
/** Human-readable handler name. */
|
|
23
|
+
handlerName: string;
|
|
24
|
+
|
|
25
|
+
/** File path of the handler (relative to project root). */
|
|
26
|
+
handlerFile: string;
|
|
27
|
+
|
|
28
|
+
/** Source language (typescript, python, etc.). */
|
|
29
|
+
language: string;
|
|
30
|
+
|
|
31
|
+
/** Route metadata from metaJson (method, path, etc.). */
|
|
32
|
+
routeMeta: {
|
|
33
|
+
/** HTTP method (GET, POST, PUT, DELETE, PATCH). */
|
|
34
|
+
method?: string;
|
|
35
|
+
|
|
36
|
+
/** Route path pattern (e.g., `/api/v1/tasks`). */
|
|
37
|
+
path?: string;
|
|
38
|
+
|
|
39
|
+
/** Additional metadata fields. */
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Symbols/modules fetched by this handler (external dependencies). */
|
|
44
|
+
fetchedDeps: Array<{
|
|
45
|
+
/** Dependency target symbol or module name. */
|
|
46
|
+
target: string;
|
|
47
|
+
|
|
48
|
+
/** Relation type (fetches, imports, calls). */
|
|
49
|
+
relationType: string;
|
|
50
|
+
|
|
51
|
+
/** Confidence score [0..1]. */
|
|
52
|
+
confidence: number;
|
|
53
|
+
}>;
|
|
54
|
+
|
|
55
|
+
/** Count of downstream callers of this handler. */
|
|
56
|
+
callerCount: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Result of `route-map` command — all routes with handlers and deps.
|
|
61
|
+
*/
|
|
62
|
+
export interface RouteMapResult {
|
|
63
|
+
/** Project ID the routes belong to. */
|
|
64
|
+
projectId: string;
|
|
65
|
+
|
|
66
|
+
/** All routes with their handlers and dependencies. */
|
|
67
|
+
routes: RouteMapEntry[];
|
|
68
|
+
|
|
69
|
+
/** Count of route nodes analyzed. */
|
|
70
|
+
routeCount: number;
|
|
71
|
+
|
|
72
|
+
/** Count of handler functions found. */
|
|
73
|
+
handlerCount: number;
|
|
74
|
+
|
|
75
|
+
/** External dependencies (distinct modules/specs fetched). */
|
|
76
|
+
distinctDeps: string[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Shape compatibility verdict from `shape-check`.
|
|
81
|
+
*/
|
|
82
|
+
export type ShapeCheckStatus = 'compatible' | 'incompatible' | 'partial' | 'unknown';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A single caller of a route handler and its expected response shape.
|
|
86
|
+
*/
|
|
87
|
+
export interface ShapeCheckCaller {
|
|
88
|
+
/** Caller symbol ID. */
|
|
89
|
+
callerId: string;
|
|
90
|
+
|
|
91
|
+
/** Caller name. */
|
|
92
|
+
callerName: string;
|
|
93
|
+
|
|
94
|
+
/** File path of the caller. */
|
|
95
|
+
callerFile: string;
|
|
96
|
+
|
|
97
|
+
/** Inferred expected response shape (from return type or usage). */
|
|
98
|
+
expectedShape: string;
|
|
99
|
+
|
|
100
|
+
/** Compatibility status versus the route's declared shape. */
|
|
101
|
+
status: ShapeCheckStatus;
|
|
102
|
+
|
|
103
|
+
/** Human-readable diagnosis. */
|
|
104
|
+
diagnosis: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Result of `shape-check` command — route's shape vs all callers.
|
|
109
|
+
*/
|
|
110
|
+
export interface ShapeCheckResult {
|
|
111
|
+
/** Route symbol ID being checked. */
|
|
112
|
+
routeId: string;
|
|
113
|
+
|
|
114
|
+
/** Route handler symbol ID. */
|
|
115
|
+
handlerId: string;
|
|
116
|
+
|
|
117
|
+
/** Declared response shape from meta_json or return type. */
|
|
118
|
+
declaredShape: string;
|
|
119
|
+
|
|
120
|
+
/** All callers and their expected shapes. */
|
|
121
|
+
callers: ShapeCheckCaller[];
|
|
122
|
+
|
|
123
|
+
/** Count of compatible callers. */
|
|
124
|
+
compatibleCount: number;
|
|
125
|
+
|
|
126
|
+
/** Count of incompatible callers. */
|
|
127
|
+
incompatibleCount: number;
|
|
128
|
+
|
|
129
|
+
/** Overall compatibility status. */
|
|
130
|
+
overallStatus: ShapeCheckStatus;
|
|
131
|
+
|
|
132
|
+
/** Recommendation. */
|
|
133
|
+
recommendation: string;
|
|
134
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for TASKS → NEXUS bridge operations.
|
|
3
|
+
*
|
|
4
|
+
* Enables querying which tasks touched which symbols (T1067).
|
|
5
|
+
* Supports forward lookup (task → symbols) and reverse lookup (symbol → tasks).
|
|
6
|
+
*
|
|
7
|
+
* @task T1067
|
|
8
|
+
* @epic T1042
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A single task reference in a symbol context.
|
|
13
|
+
* Used by getTasksForSymbol() reverse-lookup queries.
|
|
14
|
+
*/
|
|
15
|
+
export interface TaskReference {
|
|
16
|
+
/** Task ID (e.g., 'T001'). */
|
|
17
|
+
taskId: string;
|
|
18
|
+
/** Display label for the task. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Edge weight (confidence) that this task touched the symbol. */
|
|
21
|
+
weight: number;
|
|
22
|
+
/** Human-readable match strategy used ('git-log-file', 'file-symbol-match', etc.). */
|
|
23
|
+
matchStrategy: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A single symbol reference in a task context.
|
|
28
|
+
* Used by getSymbolsForTask() forward-lookup queries.
|
|
29
|
+
*/
|
|
30
|
+
export interface SymbolReference {
|
|
31
|
+
/** Nexus node ID (format: '<filePath>::<name>' or '<filePath>'). */
|
|
32
|
+
nexusNodeId: string;
|
|
33
|
+
/** Display label for the symbol (file path or function name). */
|
|
34
|
+
label: string;
|
|
35
|
+
/** Symbol kind ('function', 'class', 'file', etc.). */
|
|
36
|
+
kind: string;
|
|
37
|
+
/** File path where this symbol is defined. */
|
|
38
|
+
filePath: string | null;
|
|
39
|
+
/** Edge weight (confidence) that the task touched this symbol. */
|
|
40
|
+
weight: number;
|
|
41
|
+
/** Human-readable match strategy used ('git-log-file', 'file-symbol-match', etc.). */
|
|
42
|
+
matchStrategy: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Result from linkTaskToSymbols() operation.
|
|
47
|
+
*/
|
|
48
|
+
export interface LinkTaskResult {
|
|
49
|
+
/** Number of task_touches_symbol edges created or found. */
|
|
50
|
+
linked: number;
|
|
51
|
+
/** Task ID that was linked. */
|
|
52
|
+
taskId: string;
|
|
53
|
+
/** Number of files processed from task.files_json. */
|
|
54
|
+
filesProcessed: number;
|
|
55
|
+
/** Number of symbols found in those files. */
|
|
56
|
+
symbolsFound: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Result from runGitLogTaskLinker() git-log sweep operation.
|
|
61
|
+
*/
|
|
62
|
+
export interface GitLogLinkerResult {
|
|
63
|
+
/** Total number of task_touches_symbol edges created or found across all tasks. */
|
|
64
|
+
linked: number;
|
|
65
|
+
/** Commits processed from git log since --since. */
|
|
66
|
+
commitsProcessed: number;
|
|
67
|
+
/** Unique task IDs extracted from commit messages. */
|
|
68
|
+
tasksFound: number;
|
|
69
|
+
/** Last commit hash processed (stored for idempotency). */
|
|
70
|
+
lastCommitHash: string | null;
|
|
71
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nexus Wiki Index Operations - Contract Layer
|
|
3
|
+
*
|
|
4
|
+
* Defines types for generating a community-grouped wiki index
|
|
5
|
+
* from the nexus code graph.
|
|
6
|
+
*
|
|
7
|
+
* @task T1060
|
|
8
|
+
* @epic T1042
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Statistics for a single community in the wiki index.
|
|
13
|
+
*/
|
|
14
|
+
export interface CommunityWikiStats {
|
|
15
|
+
/** Community node ID (e.g. "community:42") */
|
|
16
|
+
communityId: string;
|
|
17
|
+
/** Number of symbols in this community */
|
|
18
|
+
memberCount: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result of wiki index generation.
|
|
23
|
+
*/
|
|
24
|
+
export interface NexusWikiResult {
|
|
25
|
+
/** Whether generation succeeded */
|
|
26
|
+
success: boolean;
|
|
27
|
+
/** Output directory where files were written */
|
|
28
|
+
outputDir: string;
|
|
29
|
+
/** Number of communities processed */
|
|
30
|
+
communityCount: number;
|
|
31
|
+
/** Total number of files written (community files + overview) */
|
|
32
|
+
fileCount: number;
|
|
33
|
+
/** Stats per community */
|
|
34
|
+
communities: CommunityWikiStats[];
|
|
35
|
+
/** Error message if success is false */
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Symbol metadata as it appears in the wiki index.
|
|
41
|
+
*/
|
|
42
|
+
export interface WikiSymbolRow {
|
|
43
|
+
/** Symbol name */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Symbol kind (function, class, interface, etc.) */
|
|
46
|
+
kind: string;
|
|
47
|
+
/** File path relative to project root */
|
|
48
|
+
filePath: string | null;
|
|
49
|
+
/** Number of symbols that call this symbol */
|
|
50
|
+
callerCount: number;
|
|
51
|
+
/** Number of symbols this symbol calls */
|
|
52
|
+
calleeCount: number;
|
|
53
|
+
}
|