@gmickel/gno 1.22.0 → 1.24.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 +33 -12
- package/assets/skill/SKILL.md +41 -19
- package/package.json +1 -1
- package/spec/cli.md +127 -20
- package/spec/evals-agentic.md +35 -0
- package/spec/evals.md +6 -0
- package/spec/mcp.md +18 -0
- package/spec/output-schemas/query-diagnose-v1.schema.json +123 -0
- package/spec/output-schemas/query-diagnose.schema.json +89 -2
- package/spec/output-schemas/setup-activation-result.schema.json +456 -0
- package/spec/output-schemas/setup-command-result.schema.json +93 -0
- package/spec/output-schemas/setup-receipt.schema.json +258 -0
- package/spec/output-schemas/setup-semantic-receipt.schema.json +195 -0
- package/src/app/context-runtime-types.ts +3 -0
- package/src/app/context-runtime.ts +1 -0
- package/src/app/context-surface.ts +4 -2
- package/src/cli/commands/ask.ts +31 -20
- package/src/cli/commands/completion/scripts.ts +2 -0
- package/src/cli/commands/context-build.ts +17 -7
- package/src/cli/commands/embed.ts +7 -2
- package/src/cli/commands/query.ts +58 -37
- package/src/cli/commands/search.ts +29 -19
- package/src/cli/commands/setup-activation.ts +324 -0
- package/src/cli/commands/setup-semantic.ts +591 -0
- package/src/cli/commands/setup.ts +410 -0
- package/src/cli/commands/vsearch.ts +31 -22
- package/src/cli/options.ts +39 -0
- package/src/cli/program.ts +112 -0
- package/src/cli/setup-semantic-worker.ts +177 -0
- package/src/config/defaults.ts +10 -1
- package/src/config/types.ts +71 -0
- package/src/core/config-mutation.ts +94 -64
- package/src/core/file-lock.ts +70 -31
- package/src/core/folder-setup-planning.ts +453 -0
- package/src/core/folder-setup.ts +490 -0
- package/src/core/project-affinity-surface.ts +114 -0
- package/src/core/project-affinity.ts +330 -0
- package/src/core/setup-activation.ts +309 -0
- package/src/core/setup-receipt.ts +321 -0
- package/src/core/validation.ts +20 -1
- package/src/mcp/tools/ask.ts +10 -1
- package/src/mcp/tools/context.ts +18 -0
- package/src/mcp/tools/index.ts +13 -2
- package/src/mcp/tools/query.ts +12 -0
- package/src/mcp/tools/search.ts +7 -0
- package/src/mcp/tools/vsearch.ts +7 -0
- package/src/pipeline/diagnose.ts +48 -3
- package/src/pipeline/explain.ts +54 -13
- package/src/pipeline/hybrid.ts +100 -59
- package/src/pipeline/project-affinity.ts +162 -0
- package/src/pipeline/search.ts +76 -10
- package/src/pipeline/types.ts +9 -0
- package/src/pipeline/vsearch.ts +117 -91
- package/src/sdk/client.ts +80 -20
- package/src/sdk/index.ts +2 -0
- package/src/sdk/types.ts +20 -7
- package/src/serve/connectors.ts +29 -2
- package/src/serve/context-capsule.ts +18 -1
- package/src/serve/routes/api.ts +69 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "gno://schemas/setup-receipt@1.0",
|
|
4
|
+
"title": "GNO Verified Folder Setup Receipt",
|
|
5
|
+
"description": "Canonical local receipt for resumable lexical-first folder setup.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"schemaVersion",
|
|
10
|
+
"status",
|
|
11
|
+
"generatedAt",
|
|
12
|
+
"input",
|
|
13
|
+
"fingerprints",
|
|
14
|
+
"collection",
|
|
15
|
+
"paths",
|
|
16
|
+
"stages",
|
|
17
|
+
"pending",
|
|
18
|
+
"failure",
|
|
19
|
+
"activation"
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"schemaVersion": { "const": "1.0" },
|
|
23
|
+
"status": {
|
|
24
|
+
"enum": ["in_progress", "failed", "completed"]
|
|
25
|
+
},
|
|
26
|
+
"generatedAt": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"format": "date-time"
|
|
29
|
+
},
|
|
30
|
+
"input": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"additionalProperties": false,
|
|
33
|
+
"required": [
|
|
34
|
+
"folder",
|
|
35
|
+
"folderFingerprint",
|
|
36
|
+
"indexName",
|
|
37
|
+
"requestedName",
|
|
38
|
+
"excludes",
|
|
39
|
+
"secretRiskAuthorized"
|
|
40
|
+
],
|
|
41
|
+
"properties": {
|
|
42
|
+
"folder": { "type": "string", "minLength": 1 },
|
|
43
|
+
"folderFingerprint": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
46
|
+
},
|
|
47
|
+
"indexName": { "type": "string", "minLength": 1, "maxLength": 64 },
|
|
48
|
+
"requestedName": {
|
|
49
|
+
"type": ["string", "null"],
|
|
50
|
+
"minLength": 1,
|
|
51
|
+
"maxLength": 64
|
|
52
|
+
},
|
|
53
|
+
"excludes": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"uniqueItems": true,
|
|
56
|
+
"items": { "type": "string", "minLength": 1 }
|
|
57
|
+
},
|
|
58
|
+
"secretRiskAuthorized": { "type": "boolean" }
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"fingerprints": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"required": ["input", "config", "index"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"input": { "$ref": "#/definitions/fingerprint" },
|
|
67
|
+
"config": {
|
|
68
|
+
"oneOf": [{ "$ref": "#/definitions/fingerprint" }, { "type": "null" }]
|
|
69
|
+
},
|
|
70
|
+
"index": {
|
|
71
|
+
"oneOf": [{ "$ref": "#/definitions/fingerprint" }, { "type": "null" }]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"collection": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"additionalProperties": false,
|
|
78
|
+
"required": ["name", "path", "disposition"],
|
|
79
|
+
"properties": {
|
|
80
|
+
"name": {
|
|
81
|
+
"type": ["string", "null"],
|
|
82
|
+
"pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
|
|
83
|
+
},
|
|
84
|
+
"path": { "type": "string", "minLength": 1 },
|
|
85
|
+
"disposition": {
|
|
86
|
+
"enum": ["pending", "created", "reused"]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"paths": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": false,
|
|
93
|
+
"required": ["config", "receipt"],
|
|
94
|
+
"properties": {
|
|
95
|
+
"config": { "type": "string", "minLength": 1 },
|
|
96
|
+
"receipt": { "type": "string", "minLength": 1 }
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"stages": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"required": [
|
|
103
|
+
"preflight",
|
|
104
|
+
"config_saved",
|
|
105
|
+
"store_synced",
|
|
106
|
+
"lexical_indexed",
|
|
107
|
+
"lexical_proved",
|
|
108
|
+
"completed"
|
|
109
|
+
],
|
|
110
|
+
"properties": {
|
|
111
|
+
"preflight": { "$ref": "#/definitions/stage" },
|
|
112
|
+
"config_saved": { "$ref": "#/definitions/stage" },
|
|
113
|
+
"store_synced": { "$ref": "#/definitions/stage" },
|
|
114
|
+
"lexical_indexed": { "$ref": "#/definitions/stage" },
|
|
115
|
+
"lexical_proved": { "$ref": "#/definitions/stage" },
|
|
116
|
+
"completed": { "$ref": "#/definitions/stage" }
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"pending": {
|
|
120
|
+
"type": "array",
|
|
121
|
+
"uniqueItems": true,
|
|
122
|
+
"items": { "type": "string", "minLength": 1 }
|
|
123
|
+
},
|
|
124
|
+
"failure": {
|
|
125
|
+
"oneOf": [{ "$ref": "#/definitions/failure" }, { "type": "null" }]
|
|
126
|
+
},
|
|
127
|
+
"activation": {
|
|
128
|
+
"oneOf": [
|
|
129
|
+
{ "$ref": "gno://schemas/activation-verification@1.0" },
|
|
130
|
+
{ "type": "null" }
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"allOf": [
|
|
135
|
+
{
|
|
136
|
+
"if": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"properties": { "status": { "const": "completed" } },
|
|
139
|
+
"required": ["status"]
|
|
140
|
+
},
|
|
141
|
+
"then": {
|
|
142
|
+
"type": "object",
|
|
143
|
+
"properties": {
|
|
144
|
+
"failure": { "type": "null" },
|
|
145
|
+
"activation": {
|
|
146
|
+
"allOf": [
|
|
147
|
+
{ "$ref": "gno://schemas/activation-verification@1.0" },
|
|
148
|
+
{
|
|
149
|
+
"type": "object",
|
|
150
|
+
"properties": { "ready": { "const": true } },
|
|
151
|
+
"required": ["ready"]
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
"stages": {
|
|
156
|
+
"type": "object",
|
|
157
|
+
"properties": {
|
|
158
|
+
"preflight": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"properties": { "status": { "const": "passed" } }
|
|
161
|
+
},
|
|
162
|
+
"config_saved": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"properties": { "status": { "const": "passed" } }
|
|
165
|
+
},
|
|
166
|
+
"store_synced": {
|
|
167
|
+
"type": "object",
|
|
168
|
+
"properties": { "status": { "const": "passed" } }
|
|
169
|
+
},
|
|
170
|
+
"lexical_indexed": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"properties": { "status": { "const": "passed" } }
|
|
173
|
+
},
|
|
174
|
+
"lexical_proved": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"properties": { "status": { "const": "passed" } }
|
|
177
|
+
},
|
|
178
|
+
"completed": {
|
|
179
|
+
"type": "object",
|
|
180
|
+
"properties": { "status": { "const": "passed" } }
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"if": {
|
|
189
|
+
"type": "object",
|
|
190
|
+
"properties": { "status": { "const": "failed" } },
|
|
191
|
+
"required": ["status"]
|
|
192
|
+
},
|
|
193
|
+
"then": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"properties": {
|
|
196
|
+
"failure": { "$ref": "#/definitions/failure" }
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"definitions": {
|
|
202
|
+
"fingerprint": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
205
|
+
},
|
|
206
|
+
"stage": {
|
|
207
|
+
"type": "object",
|
|
208
|
+
"additionalProperties": false,
|
|
209
|
+
"required": [
|
|
210
|
+
"status",
|
|
211
|
+
"token",
|
|
212
|
+
"startedAt",
|
|
213
|
+
"completedAt",
|
|
214
|
+
"code",
|
|
215
|
+
"remediation"
|
|
216
|
+
],
|
|
217
|
+
"properties": {
|
|
218
|
+
"status": {
|
|
219
|
+
"enum": ["pending", "in_progress", "passed", "failed"]
|
|
220
|
+
},
|
|
221
|
+
"token": {
|
|
222
|
+
"type": ["string", "null"],
|
|
223
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
224
|
+
},
|
|
225
|
+
"startedAt": {
|
|
226
|
+
"type": ["string", "null"],
|
|
227
|
+
"format": "date-time"
|
|
228
|
+
},
|
|
229
|
+
"completedAt": {
|
|
230
|
+
"type": ["string", "null"],
|
|
231
|
+
"format": "date-time"
|
|
232
|
+
},
|
|
233
|
+
"code": { "type": ["string", "null"] },
|
|
234
|
+
"remediation": { "type": ["string", "null"] }
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"failure": {
|
|
238
|
+
"type": "object",
|
|
239
|
+
"additionalProperties": false,
|
|
240
|
+
"required": ["stage", "code", "message", "remediation"],
|
|
241
|
+
"properties": {
|
|
242
|
+
"stage": {
|
|
243
|
+
"enum": [
|
|
244
|
+
"preflight",
|
|
245
|
+
"config_saved",
|
|
246
|
+
"store_synced",
|
|
247
|
+
"lexical_indexed",
|
|
248
|
+
"lexical_proved",
|
|
249
|
+
"completed"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
"code": { "type": "string", "minLength": 1 },
|
|
253
|
+
"message": { "type": "string", "minLength": 1 },
|
|
254
|
+
"remediation": { "type": "string", "minLength": 1 }
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "gno://schemas/setup-semantic@1.0",
|
|
4
|
+
"title": "GNO Setup Semantic Handoff Receipt",
|
|
5
|
+
"description": "Privacy-bounded state for one standalone collection-scoped semantic setup worker.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"schemaVersion",
|
|
10
|
+
"status",
|
|
11
|
+
"generatedAt",
|
|
12
|
+
"startedAt",
|
|
13
|
+
"completedAt",
|
|
14
|
+
"jobId",
|
|
15
|
+
"collection",
|
|
16
|
+
"indexName",
|
|
17
|
+
"folderFingerprint",
|
|
18
|
+
"pid",
|
|
19
|
+
"offline",
|
|
20
|
+
"setupReceiptFingerprint",
|
|
21
|
+
"setupReceiptPath",
|
|
22
|
+
"receiptPath",
|
|
23
|
+
"logPath",
|
|
24
|
+
"resumeCommand",
|
|
25
|
+
"counts",
|
|
26
|
+
"error"
|
|
27
|
+
],
|
|
28
|
+
"properties": {
|
|
29
|
+
"schemaVersion": { "const": "1.0" },
|
|
30
|
+
"status": {
|
|
31
|
+
"enum": [
|
|
32
|
+
"scheduled",
|
|
33
|
+
"running",
|
|
34
|
+
"completed",
|
|
35
|
+
"failed",
|
|
36
|
+
"pending",
|
|
37
|
+
"skipped"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"generatedAt": { "type": "string", "format": "date-time" },
|
|
41
|
+
"startedAt": {
|
|
42
|
+
"type": ["string", "null"],
|
|
43
|
+
"format": "date-time"
|
|
44
|
+
},
|
|
45
|
+
"completedAt": {
|
|
46
|
+
"type": ["string", "null"],
|
|
47
|
+
"format": "date-time"
|
|
48
|
+
},
|
|
49
|
+
"jobId": { "$ref": "#/definitions/fingerprint" },
|
|
50
|
+
"collection": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
|
|
53
|
+
},
|
|
54
|
+
"indexName": { "type": "string", "minLength": 1, "maxLength": 64 },
|
|
55
|
+
"folderFingerprint": { "$ref": "#/definitions/fingerprint" },
|
|
56
|
+
"pid": {
|
|
57
|
+
"type": ["integer", "null"],
|
|
58
|
+
"minimum": 1
|
|
59
|
+
},
|
|
60
|
+
"offline": { "type": "boolean" },
|
|
61
|
+
"setupReceiptFingerprint": { "$ref": "#/definitions/fingerprint" },
|
|
62
|
+
"setupReceiptPath": { "type": "string", "minLength": 1 },
|
|
63
|
+
"receiptPath": { "type": "string", "minLength": 1 },
|
|
64
|
+
"logPath": { "type": "string", "minLength": 1 },
|
|
65
|
+
"resumeCommand": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"pattern": "^gno .* embed "
|
|
68
|
+
},
|
|
69
|
+
"counts": {
|
|
70
|
+
"oneOf": [
|
|
71
|
+
{
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"required": ["embedded", "errors"],
|
|
75
|
+
"properties": {
|
|
76
|
+
"embedded": { "type": "integer", "minimum": 0 },
|
|
77
|
+
"errors": { "type": "integer", "minimum": 0 }
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{ "type": "null" }
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"error": {
|
|
84
|
+
"oneOf": [
|
|
85
|
+
{
|
|
86
|
+
"type": "object",
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"required": ["message", "remediation"],
|
|
89
|
+
"properties": {
|
|
90
|
+
"message": { "type": "string", "minLength": 1, "maxLength": 500 },
|
|
91
|
+
"remediation": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"minLength": 1,
|
|
94
|
+
"maxLength": 8192
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{ "type": "null" }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"allOf": [
|
|
103
|
+
{
|
|
104
|
+
"if": {
|
|
105
|
+
"properties": { "status": { "const": "scheduled" } },
|
|
106
|
+
"required": ["status"]
|
|
107
|
+
},
|
|
108
|
+
"then": {
|
|
109
|
+
"properties": {
|
|
110
|
+
"startedAt": { "type": "null" },
|
|
111
|
+
"completedAt": { "type": "null" },
|
|
112
|
+
"counts": { "type": "null" },
|
|
113
|
+
"error": { "type": "null" }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"if": {
|
|
119
|
+
"properties": { "status": { "const": "running" } },
|
|
120
|
+
"required": ["status"]
|
|
121
|
+
},
|
|
122
|
+
"then": {
|
|
123
|
+
"properties": {
|
|
124
|
+
"pid": { "type": "integer", "minimum": 1 },
|
|
125
|
+
"startedAt": { "type": "string", "format": "date-time" },
|
|
126
|
+
"completedAt": { "type": "null" },
|
|
127
|
+
"counts": { "type": "null" },
|
|
128
|
+
"error": { "type": "null" }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"if": {
|
|
134
|
+
"properties": { "status": { "const": "completed" } },
|
|
135
|
+
"required": ["status"]
|
|
136
|
+
},
|
|
137
|
+
"then": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"properties": {
|
|
140
|
+
"pid": { "type": "null" },
|
|
141
|
+
"counts": { "type": "object" },
|
|
142
|
+
"error": { "type": "null" },
|
|
143
|
+
"completedAt": { "type": "string", "format": "date-time" }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"if": {
|
|
149
|
+
"properties": { "status": { "const": "failed" } },
|
|
150
|
+
"required": ["status"]
|
|
151
|
+
},
|
|
152
|
+
"then": {
|
|
153
|
+
"type": "object",
|
|
154
|
+
"properties": {
|
|
155
|
+
"pid": { "type": "null" },
|
|
156
|
+
"error": { "type": "object" },
|
|
157
|
+
"completedAt": { "type": "string", "format": "date-time" }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"if": {
|
|
163
|
+
"properties": { "status": { "const": "pending" } },
|
|
164
|
+
"required": ["status"]
|
|
165
|
+
},
|
|
166
|
+
"then": {
|
|
167
|
+
"properties": {
|
|
168
|
+
"completedAt": { "type": "null" },
|
|
169
|
+
"counts": { "type": "null" },
|
|
170
|
+
"error": { "type": "object" }
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"if": {
|
|
176
|
+
"properties": { "status": { "const": "skipped" } },
|
|
177
|
+
"required": ["status"]
|
|
178
|
+
},
|
|
179
|
+
"then": {
|
|
180
|
+
"type": "object",
|
|
181
|
+
"properties": {
|
|
182
|
+
"counts": { "type": "null" },
|
|
183
|
+
"error": { "type": "null" },
|
|
184
|
+
"completedAt": { "type": "string", "format": "date-time" }
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"definitions": {
|
|
190
|
+
"fingerprint": {
|
|
191
|
+
"type": "string",
|
|
192
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -4,6 +4,7 @@ import type { ContextEvidenceCompilerDeps } from "../core/context-evidence";
|
|
|
4
4
|
import type { ContextVerifierDeps } from "../core/context-verifier";
|
|
5
5
|
import type { RetrievalTraceSession } from "../core/retrieval-trace-session";
|
|
6
6
|
import type { EmbeddingPort, RerankPort } from "../llm/types";
|
|
7
|
+
import type { ProjectAffinityScoringInput } from "../pipeline/project-affinity";
|
|
7
8
|
import type { QueryModeInput } from "../pipeline/types";
|
|
8
9
|
import type { StorePort } from "../store/types";
|
|
9
10
|
import type { VectorIndexPort } from "../store/vector";
|
|
@@ -50,6 +51,8 @@ export interface ContextCapsuleRuntimeDeps {
|
|
|
50
51
|
countTokens?: (accountingJson: string) => number;
|
|
51
52
|
tokenizerFingerprint?: string | null;
|
|
52
53
|
resolveCurrentRanks?: ContextVerifierDeps["resolveCurrentRanks"];
|
|
54
|
+
/** Trusted, already-resolved project affinity; never accepts raw inputs. */
|
|
55
|
+
projectAffinity?: ProjectAffinityScoringInput;
|
|
53
56
|
/** Optional non-canonical receipt session owned by the calling surface. */
|
|
54
57
|
traceSession?: RetrievalTraceSession;
|
|
55
58
|
}
|
|
@@ -44,6 +44,7 @@ export const contextBuildSurfaceSchema = z
|
|
|
44
44
|
safetyMarginTokens: nonnegativeInteger.optional(),
|
|
45
45
|
safetyMarginBytes: nonnegativeInteger.optional(),
|
|
46
46
|
depthPolicy: z.enum(["fast", "balanced", "thorough"]).optional(),
|
|
47
|
+
projectHints: z.array(z.string()).max(16).optional(),
|
|
47
48
|
format: z.enum(["json", "md"]).optional(),
|
|
48
49
|
})
|
|
49
50
|
.strict();
|
|
@@ -60,6 +61,7 @@ export type ContextSurfaceFormat = "json" | "md";
|
|
|
60
61
|
export interface ParsedContextBuildSurfaceInput {
|
|
61
62
|
input: ContextCapsuleBuildInput;
|
|
62
63
|
format: ContextSurfaceFormat;
|
|
64
|
+
projectHints?: string[];
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
export interface ParsedContextVerifySurfaceInput {
|
|
@@ -117,8 +119,8 @@ export const parseContextBuildSurfaceInput = (
|
|
|
117
119
|
): ParsedContextBuildSurfaceInput => {
|
|
118
120
|
const parsed = contextBuildSurfaceSchema.safeParse(value);
|
|
119
121
|
if (!parsed.success) throw invalidInput(parsed.error);
|
|
120
|
-
const { format = "json", ...input } = parsed.data;
|
|
121
|
-
return { input: { ...input, indexName }, format };
|
|
122
|
+
const { format = "json", projectHints, ...input } = parsed.data;
|
|
123
|
+
return { input: { ...input, indexName }, format, projectHints };
|
|
122
124
|
};
|
|
123
125
|
|
|
124
126
|
export const parseContextVerifySurfaceInput = (
|
package/src/cli/commands/ask.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module src/cli/commands/ask
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type { CliProjectAffinityRequest } from "../../core/project-affinity-surface";
|
|
8
9
|
import type { RetrievalTraceSurfaceMetadata } from "../../core/retrieval-trace-session";
|
|
9
10
|
import type { RetrievalTraceSession } from "../../core/retrieval-trace-session";
|
|
10
11
|
import type {
|
|
@@ -15,6 +16,7 @@ import type {
|
|
|
15
16
|
import type { AskOptions, AskResult, Citation } from "../../pipeline/types";
|
|
16
17
|
|
|
17
18
|
import { buildVerifiedAsk } from "../../app/verified-ask";
|
|
19
|
+
import { resolveCliProjectAffinity } from "../../core/project-affinity-surface";
|
|
18
20
|
import {
|
|
19
21
|
finishRetrievalTraceAfterError,
|
|
20
22
|
retrievalTraceFilters,
|
|
@@ -46,24 +48,25 @@ export { formatAsk } from "./ask-format";
|
|
|
46
48
|
// Types
|
|
47
49
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
48
50
|
|
|
49
|
-
export type AskCommandOptions = AskOptions &
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
export type AskCommandOptions = Omit<AskOptions, "projectAffinity"> &
|
|
52
|
+
CliProjectAffinityRequest & {
|
|
53
|
+
/** Override config path */
|
|
54
|
+
configPath?: string;
|
|
55
|
+
/** Override embedding model */
|
|
56
|
+
embedModel?: string;
|
|
57
|
+
/** Override expansion model */
|
|
58
|
+
expandModel?: string;
|
|
59
|
+
/** Override answer generation model */
|
|
60
|
+
genModel?: string;
|
|
61
|
+
/** Override rerank model */
|
|
62
|
+
rerankModel?: string;
|
|
63
|
+
/** Output as JSON */
|
|
64
|
+
json?: boolean;
|
|
65
|
+
/** Output as Markdown */
|
|
66
|
+
md?: boolean;
|
|
67
|
+
/** Show all retrieved sources (not just cited) */
|
|
68
|
+
showSources?: boolean;
|
|
69
|
+
};
|
|
67
70
|
|
|
68
71
|
export type AskCommandResult =
|
|
69
72
|
| {
|
|
@@ -108,6 +111,12 @@ export async function ask(
|
|
|
108
111
|
let traceSession: RetrievalTraceSession | undefined;
|
|
109
112
|
|
|
110
113
|
try {
|
|
114
|
+
const { projectAffinityDisabled, projectRoots, ...askOptions } = options;
|
|
115
|
+
const projectAffinity = await resolveCliProjectAffinity(config, {
|
|
116
|
+
cwd: process.cwd(),
|
|
117
|
+
disabled: projectAffinityDisabled,
|
|
118
|
+
projectRoots,
|
|
119
|
+
});
|
|
111
120
|
const verificationRequested = options.verify === true;
|
|
112
121
|
const answerRequested =
|
|
113
122
|
verificationRequested || Boolean(options.answer && !options.noAnswer);
|
|
@@ -141,7 +150,7 @@ export async function ask(
|
|
|
141
150
|
store,
|
|
142
151
|
config,
|
|
143
152
|
query,
|
|
144
|
-
filters: retrievalTraceFilters({ ...
|
|
153
|
+
filters: retrievalTraceFilters({ ...askOptions, limit }),
|
|
145
154
|
pipeline: "ask",
|
|
146
155
|
indexName: globals.index,
|
|
147
156
|
modelUris: [embedUri, expandUri, answerUri, rerankUri].filter(
|
|
@@ -264,7 +273,7 @@ export async function ask(
|
|
|
264
273
|
if (verificationRequested && answerPort) {
|
|
265
274
|
const verified = await buildVerifiedAsk(
|
|
266
275
|
query,
|
|
267
|
-
{ ...
|
|
276
|
+
{ ...askOptions, limit, projectAffinity },
|
|
268
277
|
{
|
|
269
278
|
store,
|
|
270
279
|
config,
|
|
@@ -273,6 +282,7 @@ export async function ask(
|
|
|
273
282
|
embedPort,
|
|
274
283
|
rerankPort,
|
|
275
284
|
genPort: answerPort,
|
|
285
|
+
projectAffinity,
|
|
276
286
|
traceSession,
|
|
277
287
|
}
|
|
278
288
|
);
|
|
@@ -308,6 +318,7 @@ export async function ask(
|
|
|
308
318
|
noExpand: options.noExpand,
|
|
309
319
|
noRerank: options.noRerank,
|
|
310
320
|
candidateLimit: options.candidateLimit,
|
|
321
|
+
projectAffinity,
|
|
311
322
|
traceSession,
|
|
312
323
|
});
|
|
313
324
|
|
|
@@ -14,6 +14,7 @@ export const SUPPORTED_SHELLS: Shell[] = ["bash", "zsh", "fish"];
|
|
|
14
14
|
*/
|
|
15
15
|
const COMMANDS = [
|
|
16
16
|
"init",
|
|
17
|
+
"setup",
|
|
17
18
|
"index",
|
|
18
19
|
"update",
|
|
19
20
|
"embed",
|
|
@@ -317,6 +318,7 @@ export function getCompletionScript(shell: Shell): string {
|
|
|
317
318
|
function getCommandDescription(cmd: string): string {
|
|
318
319
|
const descriptions: Record<string, string> = {
|
|
319
320
|
init: "Initialize GNO configuration",
|
|
321
|
+
setup: "Add and verify a folder",
|
|
320
322
|
index: "Index files from collections",
|
|
321
323
|
update: "Sync files from disk",
|
|
322
324
|
embed: "Generate embeddings",
|