@hop-top/kit 0.4.0-alpha.1
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/CHANGELOG.md +86 -0
- package/LICENSE +25 -0
- package/README.md +189 -0
- package/dist/aim.d.ts +116 -0
- package/dist/aim.js +417 -0
- package/dist/alias.d.ts +73 -0
- package/dist/alias.js +207 -0
- package/dist/api.d.ts +62 -0
- package/dist/api.js +165 -0
- package/dist/auth.d.ts +26 -0
- package/dist/auth.js +41 -0
- package/dist/cli.d.ts +309 -0
- package/dist/cli.js +885 -0
- package/dist/config.d.ts +97 -0
- package/dist/config.js +79 -0
- package/dist/errcorrect.d.ts +37 -0
- package/dist/errcorrect.js +69 -0
- package/dist/llm.d.ts +188 -0
- package/dist/llm.js +356 -0
- package/dist/output.d.ts +213 -0
- package/dist/output.js +447 -0
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +56 -0
- package/dist/provenance.d.ts +24 -0
- package/dist/provenance.js +32 -0
- package/dist/routellm.d.ts +64 -0
- package/dist/routellm.js +258 -0
- package/dist/rpc.d.ts +25 -0
- package/dist/rpc.js +101 -0
- package/dist/safety.d.ts +24 -0
- package/dist/safety.js +44 -0
- package/dist/scope.d.ts +121 -0
- package/dist/scope.js +380 -0
- package/dist/sqlstore.d.ts +84 -0
- package/dist/sqlstore.js +85 -0
- package/dist/stream.d.ts +35 -0
- package/dist/stream.js +52 -0
- package/dist/tui/index.d.ts +300 -0
- package/dist/tui/index.js +332 -0
- package/dist/upgrade.d.ts +95 -0
- package/dist/upgrade.js +115 -0
- package/dist/xdg.d.ts +169 -0
- package/dist/xdg.js +129 -0
- package/eslint.config.mjs +17 -0
- package/package.json +133 -0
- package/src/README.md +3 -0
- package/src/aim.test.ts +331 -0
- package/src/aim.ts +388 -0
- package/src/alias.test.ts +423 -0
- package/src/alias.ts +256 -0
- package/src/api.test.ts +190 -0
- package/src/api.ts +214 -0
- package/src/auth.test.ts +24 -0
- package/src/auth.ts +37 -0
- package/src/bus.test.ts +178 -0
- package/src/bus.ts +114 -0
- package/src/cli.test.ts +690 -0
- package/src/cli.ts +741 -0
- package/src/completion-values.test.ts +202 -0
- package/src/completion-values.ts +173 -0
- package/src/completion.test.ts +212 -0
- package/src/completion.ts +158 -0
- package/src/compliance.test.ts +134 -0
- package/src/compliance.ts +669 -0
- package/src/config.test.ts +110 -0
- package/src/config.ts +164 -0
- package/src/errcorrect.test.ts +134 -0
- package/src/errcorrect.ts +84 -0
- package/src/flagregister.test.ts +103 -0
- package/src/flagregister.ts +78 -0
- package/src/gen/crud_connect.ts +76 -0
- package/src/gen/crud_pb.ts +269 -0
- package/src/hint.test.ts +315 -0
- package/src/hint.ts +178 -0
- package/src/llm.test.ts +612 -0
- package/src/llm.ts +577 -0
- package/src/log.test.ts +145 -0
- package/src/log.ts +155 -0
- package/src/output/builtins.ts +34 -0
- package/src/output/dispatch.ts +195 -0
- package/src/output/flags.ts +151 -0
- package/src/output/format_help.ts +80 -0
- package/src/output/formatter.ts +167 -0
- package/src/output/formatters/csv.ts +72 -0
- package/src/output/formatters/json.ts +44 -0
- package/src/output/formatters/table.ts +44 -0
- package/src/output/formatters/text.ts +109 -0
- package/src/output/formatters/yaml.ts +47 -0
- package/src/output/projection.ts +126 -0
- package/src/output/registry.ts +88 -0
- package/src/output/template.ts +63 -0
- package/src/output.test.ts +117 -0
- package/src/output.ts +90 -0
- package/src/progress.test.ts +93 -0
- package/src/progress.ts +58 -0
- package/src/provenance.test.ts +59 -0
- package/src/provenance.ts +26 -0
- package/src/routellm.test.ts +179 -0
- package/src/routellm.ts +365 -0
- package/src/router/bert.test.ts +180 -0
- package/src/router/bert.ts +145 -0
- package/src/router/controller.test.ts +183 -0
- package/src/router/controller.ts +165 -0
- package/src/router/integration.test.ts +309 -0
- package/src/router/intent.test.ts +187 -0
- package/src/router/intent.ts +208 -0
- package/src/router/mf.test.ts +66 -0
- package/src/router/mf.ts +52 -0
- package/src/router/random.test.ts +23 -0
- package/src/router/random.ts +13 -0
- package/src/router/router.test.ts +31 -0
- package/src/router/router.ts +62 -0
- package/src/router/server.test.ts +193 -0
- package/src/router/server.ts +134 -0
- package/src/router/sw.test.ts +199 -0
- package/src/router/sw.ts +232 -0
- package/src/rpc.test.ts +47 -0
- package/src/rpc.ts +91 -0
- package/src/safety.test.ts +53 -0
- package/src/safety.ts +42 -0
- package/src/scope-defaults.json +72 -0
- package/src/scope.test.ts +177 -0
- package/src/scope.ts +382 -0
- package/src/setflag.test.ts +110 -0
- package/src/setflag.ts +102 -0
- package/src/sqlstore.test.ts +110 -0
- package/src/sqlstore.ts +144 -0
- package/src/stream.test.ts +69 -0
- package/src/stream.ts +47 -0
- package/src/textflag.test.ts +105 -0
- package/src/textflag.ts +68 -0
- package/src/toolspec.test.ts +187 -0
- package/src/toolspec.ts +279 -0
- package/src/triton/client.test.ts +205 -0
- package/src/triton/client.ts +261 -0
- package/src/tui/anim.test.ts +146 -0
- package/src/tui/anim.ts +134 -0
- package/src/tui/badge.test.ts +41 -0
- package/src/tui/badge.ts +55 -0
- package/src/tui/confirm.test.ts +68 -0
- package/src/tui/confirm.ts +49 -0
- package/src/tui/index.ts +29 -0
- package/src/tui/list.test.ts +84 -0
- package/src/tui/list.ts +72 -0
- package/src/tui/parity.ts +41 -0
- package/src/tui/pills.test.ts +40 -0
- package/src/tui/pills.ts +43 -0
- package/src/tui/progress.test.ts +164 -0
- package/src/tui/progress.ts +120 -0
- package/src/tui/spinner.test.ts +111 -0
- package/src/tui/spinner.ts +96 -0
- package/src/tui/status.test.ts +68 -0
- package/src/tui/status.ts +66 -0
- package/src/upgrade.test.ts +298 -0
- package/src/upgrade.ts +205 -0
- package/src/uri.ts +199 -0
- package/src/wizard.test.ts +441 -0
- package/src/wizard.ts +662 -0
- package/src/xdg.test.ts +202 -0
- package/src/xdg.ts +280 -0
- package/test/output/cols.test.ts +148 -0
- package/test/output/csv.test.ts +129 -0
- package/test/output/dispatch.test.ts +194 -0
- package/test/output/format_help.test.ts +131 -0
- package/test/output/formatter.test.ts +137 -0
- package/test/output/output_flag.test.ts +124 -0
- package/test/output/registry.test.ts +127 -0
- package/test/output/smoke-capture.ts +83 -0
- package/test/output/smoke.test.ts +142 -0
- package/test/output/template.test.ts +95 -0
- package/test/output/text.test.ts +75 -0
- package/test/testdata/api-fixture.json +115 -0
- package/test/testdata/query-vectors.json +187 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @generated by protoc-gen-connect-es v1.6.1 with parameter "target=ts"
|
|
2
|
+
// @generated from file crud.proto (package crud.v1, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
|
|
6
|
+
import { CreateRequest, CreateResponse, DeleteRequest, DeleteResponse, GetRequest, GetResponse, ListRequest, ListResponse, UpdateRequest, UpdateResponse } from "./crud_pb.js";
|
|
7
|
+
import { MethodKind } from "@bufbuild/protobuf";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* EntityService provides generic CRUD operations over arbitrary
|
|
11
|
+
* domain entities. Payloads use google.protobuf.Struct so callers
|
|
12
|
+
* can work with any schema without per-type proto definitions.
|
|
13
|
+
*
|
|
14
|
+
* @generated from service crud.v1.EntityService
|
|
15
|
+
*/
|
|
16
|
+
export const EntityService = {
|
|
17
|
+
typeName: "crud.v1.EntityService",
|
|
18
|
+
methods: {
|
|
19
|
+
/**
|
|
20
|
+
* Create persists a new entity and returns the stored result.
|
|
21
|
+
*
|
|
22
|
+
* @generated from rpc crud.v1.EntityService.Create
|
|
23
|
+
*/
|
|
24
|
+
create: {
|
|
25
|
+
name: "Create",
|
|
26
|
+
I: CreateRequest,
|
|
27
|
+
O: CreateResponse,
|
|
28
|
+
kind: MethodKind.Unary,
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Get retrieves a single entity by ID.
|
|
32
|
+
*
|
|
33
|
+
* @generated from rpc crud.v1.EntityService.Get
|
|
34
|
+
*/
|
|
35
|
+
get: {
|
|
36
|
+
name: "Get",
|
|
37
|
+
I: GetRequest,
|
|
38
|
+
O: GetResponse,
|
|
39
|
+
kind: MethodKind.Unary,
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* List returns entities matching the query parameters.
|
|
43
|
+
*
|
|
44
|
+
* @generated from rpc crud.v1.EntityService.List
|
|
45
|
+
*/
|
|
46
|
+
list: {
|
|
47
|
+
name: "List",
|
|
48
|
+
I: ListRequest,
|
|
49
|
+
O: ListResponse,
|
|
50
|
+
kind: MethodKind.Unary,
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Update replaces an existing entity and returns the result.
|
|
54
|
+
*
|
|
55
|
+
* @generated from rpc crud.v1.EntityService.Update
|
|
56
|
+
*/
|
|
57
|
+
update: {
|
|
58
|
+
name: "Update",
|
|
59
|
+
I: UpdateRequest,
|
|
60
|
+
O: UpdateResponse,
|
|
61
|
+
kind: MethodKind.Unary,
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Delete removes an entity by ID.
|
|
65
|
+
*
|
|
66
|
+
* @generated from rpc crud.v1.EntityService.Delete
|
|
67
|
+
*/
|
|
68
|
+
delete: {
|
|
69
|
+
name: "Delete",
|
|
70
|
+
I: DeleteRequest,
|
|
71
|
+
O: DeleteResponse,
|
|
72
|
+
kind: MethodKind.Unary,
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
} as const;
|
|
76
|
+
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
|
|
2
|
+
// @generated from file crud.proto (package crud.v1, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
|
6
|
+
import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
|
|
7
|
+
import { file_google_protobuf_struct } from "@bufbuild/protobuf/wkt";
|
|
8
|
+
import type { JsonObject, Message } from "@bufbuild/protobuf";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Describes the file crud.proto.
|
|
12
|
+
*/
|
|
13
|
+
export const file_crud: GenFile = /*@__PURE__*/
|
|
14
|
+
fileDesc("CgpjcnVkLnByb3RvEgdjcnVkLnYxIjgKDUNyZWF0ZVJlcXVlc3QSJwoGZW50aXR5GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCI5Cg5DcmVhdGVSZXNwb25zZRInCgZlbnRpdHkYASABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0IhgKCkdldFJlcXVlc3QSCgoCaWQYASABKAkiNgoLR2V0UmVzcG9uc2USJwoGZW50aXR5GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCJKCgtMaXN0UmVxdWVzdBINCgVsaW1pdBgBIAEoBRIOCgZvZmZzZXQYAiABKAUSDAoEc29ydBgDIAEoCRIOCgZzZWFyY2gYBCABKAkiOQoMTGlzdFJlc3BvbnNlEikKCGVudGl0aWVzGAEgAygLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCI4Cg1VcGRhdGVSZXF1ZXN0EicKBmVudGl0eRgBIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3QiOQoOVXBkYXRlUmVzcG9uc2USJwoGZW50aXR5GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdCIbCg1EZWxldGVSZXF1ZXN0EgoKAmlkGAEgASgJIhAKDkRlbGV0ZVJlc3BvbnNlMqcCCg1FbnRpdHlTZXJ2aWNlEjkKBkNyZWF0ZRIWLmNydWQudjEuQ3JlYXRlUmVxdWVzdBoXLmNydWQudjEuQ3JlYXRlUmVzcG9uc2USMAoDR2V0EhMuY3J1ZC52MS5HZXRSZXF1ZXN0GhQuY3J1ZC52MS5HZXRSZXNwb25zZRIzCgRMaXN0EhQuY3J1ZC52MS5MaXN0UmVxdWVzdBoVLmNydWQudjEuTGlzdFJlc3BvbnNlEjkKBlVwZGF0ZRIWLmNydWQudjEuVXBkYXRlUmVxdWVzdBoXLmNydWQudjEuVXBkYXRlUmVzcG9uc2USOQoGRGVsZXRlEhYuY3J1ZC52MS5EZWxldGVSZXF1ZXN0GhcuY3J1ZC52MS5EZWxldGVSZXNwb25zZUJ3Cgtjb20uY3J1ZC52MUIJQ3J1ZFByb3RvUAFaIGhvcC50b3Ava2l0L3Byb3RvL2NydWQvdjE7Y3J1ZHYxogIDQ1hYqgIHQ3J1ZC5WMcoCB0NydWRcVjHiAhNDcnVkXFYxXEdQQk1ldGFkYXRh6gIIQ3J1ZDo6VjFiBnByb3RvMw", [file_google_protobuf_struct]);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @generated from message crud.v1.CreateRequest
|
|
18
|
+
*/
|
|
19
|
+
export type CreateRequest = Message<"crud.v1.CreateRequest"> & {
|
|
20
|
+
/**
|
|
21
|
+
* Untyped entity payload.
|
|
22
|
+
*
|
|
23
|
+
* @generated from field: google.protobuf.Struct entity = 1;
|
|
24
|
+
*/
|
|
25
|
+
entity?: JsonObject;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Describes the message crud.v1.CreateRequest.
|
|
30
|
+
* Use `create(CreateRequestSchema)` to create a new message.
|
|
31
|
+
*/
|
|
32
|
+
export const CreateRequestSchema: GenMessage<CreateRequest> = /*@__PURE__*/
|
|
33
|
+
messageDesc(file_crud, 0);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @generated from message crud.v1.CreateResponse
|
|
37
|
+
*/
|
|
38
|
+
export type CreateResponse = Message<"crud.v1.CreateResponse"> & {
|
|
39
|
+
/**
|
|
40
|
+
* Persisted entity with server-assigned fields (e.g. ID).
|
|
41
|
+
*
|
|
42
|
+
* @generated from field: google.protobuf.Struct entity = 1;
|
|
43
|
+
*/
|
|
44
|
+
entity?: JsonObject;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Describes the message crud.v1.CreateResponse.
|
|
49
|
+
* Use `create(CreateResponseSchema)` to create a new message.
|
|
50
|
+
*/
|
|
51
|
+
export const CreateResponseSchema: GenMessage<CreateResponse> = /*@__PURE__*/
|
|
52
|
+
messageDesc(file_crud, 1);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @generated from message crud.v1.GetRequest
|
|
56
|
+
*/
|
|
57
|
+
export type GetRequest = Message<"crud.v1.GetRequest"> & {
|
|
58
|
+
/**
|
|
59
|
+
* @generated from field: string id = 1;
|
|
60
|
+
*/
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Describes the message crud.v1.GetRequest.
|
|
66
|
+
* Use `create(GetRequestSchema)` to create a new message.
|
|
67
|
+
*/
|
|
68
|
+
export const GetRequestSchema: GenMessage<GetRequest> = /*@__PURE__*/
|
|
69
|
+
messageDesc(file_crud, 2);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @generated from message crud.v1.GetResponse
|
|
73
|
+
*/
|
|
74
|
+
export type GetResponse = Message<"crud.v1.GetResponse"> & {
|
|
75
|
+
/**
|
|
76
|
+
* @generated from field: google.protobuf.Struct entity = 1;
|
|
77
|
+
*/
|
|
78
|
+
entity?: JsonObject;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Describes the message crud.v1.GetResponse.
|
|
83
|
+
* Use `create(GetResponseSchema)` to create a new message.
|
|
84
|
+
*/
|
|
85
|
+
export const GetResponseSchema: GenMessage<GetResponse> = /*@__PURE__*/
|
|
86
|
+
messageDesc(file_crud, 3);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @generated from message crud.v1.ListRequest
|
|
90
|
+
*/
|
|
91
|
+
export type ListRequest = Message<"crud.v1.ListRequest"> & {
|
|
92
|
+
/**
|
|
93
|
+
* Maximum number of results to return. Zero means server default.
|
|
94
|
+
*
|
|
95
|
+
* @generated from field: int32 limit = 1;
|
|
96
|
+
*/
|
|
97
|
+
limit: number;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Number of results to skip (for pagination).
|
|
101
|
+
*
|
|
102
|
+
* @generated from field: int32 offset = 2;
|
|
103
|
+
*/
|
|
104
|
+
offset: number;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Field name to order by.
|
|
108
|
+
*
|
|
109
|
+
* @generated from field: string sort = 3;
|
|
110
|
+
*/
|
|
111
|
+
sort: string;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Free-text search filter.
|
|
115
|
+
*
|
|
116
|
+
* @generated from field: string search = 4;
|
|
117
|
+
*/
|
|
118
|
+
search: string;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Describes the message crud.v1.ListRequest.
|
|
123
|
+
* Use `create(ListRequestSchema)` to create a new message.
|
|
124
|
+
*/
|
|
125
|
+
export const ListRequestSchema: GenMessage<ListRequest> = /*@__PURE__*/
|
|
126
|
+
messageDesc(file_crud, 4);
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @generated from message crud.v1.ListResponse
|
|
130
|
+
*/
|
|
131
|
+
export type ListResponse = Message<"crud.v1.ListResponse"> & {
|
|
132
|
+
/**
|
|
133
|
+
* @generated from field: repeated google.protobuf.Struct entities = 1;
|
|
134
|
+
*/
|
|
135
|
+
entities: JsonObject[];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Describes the message crud.v1.ListResponse.
|
|
140
|
+
* Use `create(ListResponseSchema)` to create a new message.
|
|
141
|
+
*/
|
|
142
|
+
export const ListResponseSchema: GenMessage<ListResponse> = /*@__PURE__*/
|
|
143
|
+
messageDesc(file_crud, 5);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @generated from message crud.v1.UpdateRequest
|
|
147
|
+
*/
|
|
148
|
+
export type UpdateRequest = Message<"crud.v1.UpdateRequest"> & {
|
|
149
|
+
/**
|
|
150
|
+
* @generated from field: google.protobuf.Struct entity = 1;
|
|
151
|
+
*/
|
|
152
|
+
entity?: JsonObject;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Describes the message crud.v1.UpdateRequest.
|
|
157
|
+
* Use `create(UpdateRequestSchema)` to create a new message.
|
|
158
|
+
*/
|
|
159
|
+
export const UpdateRequestSchema: GenMessage<UpdateRequest> = /*@__PURE__*/
|
|
160
|
+
messageDesc(file_crud, 6);
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @generated from message crud.v1.UpdateResponse
|
|
164
|
+
*/
|
|
165
|
+
export type UpdateResponse = Message<"crud.v1.UpdateResponse"> & {
|
|
166
|
+
/**
|
|
167
|
+
* @generated from field: google.protobuf.Struct entity = 1;
|
|
168
|
+
*/
|
|
169
|
+
entity?: JsonObject;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Describes the message crud.v1.UpdateResponse.
|
|
174
|
+
* Use `create(UpdateResponseSchema)` to create a new message.
|
|
175
|
+
*/
|
|
176
|
+
export const UpdateResponseSchema: GenMessage<UpdateResponse> = /*@__PURE__*/
|
|
177
|
+
messageDesc(file_crud, 7);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @generated from message crud.v1.DeleteRequest
|
|
181
|
+
*/
|
|
182
|
+
export type DeleteRequest = Message<"crud.v1.DeleteRequest"> & {
|
|
183
|
+
/**
|
|
184
|
+
* @generated from field: string id = 1;
|
|
185
|
+
*/
|
|
186
|
+
id: string;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Describes the message crud.v1.DeleteRequest.
|
|
191
|
+
* Use `create(DeleteRequestSchema)` to create a new message.
|
|
192
|
+
*/
|
|
193
|
+
export const DeleteRequestSchema: GenMessage<DeleteRequest> = /*@__PURE__*/
|
|
194
|
+
messageDesc(file_crud, 8);
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @generated from message crud.v1.DeleteResponse
|
|
198
|
+
*/
|
|
199
|
+
export type DeleteResponse = Message<"crud.v1.DeleteResponse"> & {
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Describes the message crud.v1.DeleteResponse.
|
|
204
|
+
* Use `create(DeleteResponseSchema)` to create a new message.
|
|
205
|
+
*/
|
|
206
|
+
export const DeleteResponseSchema: GenMessage<DeleteResponse> = /*@__PURE__*/
|
|
207
|
+
messageDesc(file_crud, 9);
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* EntityService provides generic CRUD operations over arbitrary
|
|
211
|
+
* domain entities. Payloads use google.protobuf.Struct so callers
|
|
212
|
+
* can work with any schema without per-type proto definitions.
|
|
213
|
+
*
|
|
214
|
+
* @generated from service crud.v1.EntityService
|
|
215
|
+
*/
|
|
216
|
+
export const EntityService: GenService<{
|
|
217
|
+
/**
|
|
218
|
+
* Create persists a new entity and returns the stored result.
|
|
219
|
+
*
|
|
220
|
+
* @generated from rpc crud.v1.EntityService.Create
|
|
221
|
+
*/
|
|
222
|
+
create: {
|
|
223
|
+
methodKind: "unary";
|
|
224
|
+
input: typeof CreateRequestSchema;
|
|
225
|
+
output: typeof CreateResponseSchema;
|
|
226
|
+
},
|
|
227
|
+
/**
|
|
228
|
+
* Get retrieves a single entity by ID.
|
|
229
|
+
*
|
|
230
|
+
* @generated from rpc crud.v1.EntityService.Get
|
|
231
|
+
*/
|
|
232
|
+
get: {
|
|
233
|
+
methodKind: "unary";
|
|
234
|
+
input: typeof GetRequestSchema;
|
|
235
|
+
output: typeof GetResponseSchema;
|
|
236
|
+
},
|
|
237
|
+
/**
|
|
238
|
+
* List returns entities matching the query parameters.
|
|
239
|
+
*
|
|
240
|
+
* @generated from rpc crud.v1.EntityService.List
|
|
241
|
+
*/
|
|
242
|
+
list: {
|
|
243
|
+
methodKind: "unary";
|
|
244
|
+
input: typeof ListRequestSchema;
|
|
245
|
+
output: typeof ListResponseSchema;
|
|
246
|
+
},
|
|
247
|
+
/**
|
|
248
|
+
* Update replaces an existing entity and returns the result.
|
|
249
|
+
*
|
|
250
|
+
* @generated from rpc crud.v1.EntityService.Update
|
|
251
|
+
*/
|
|
252
|
+
update: {
|
|
253
|
+
methodKind: "unary";
|
|
254
|
+
input: typeof UpdateRequestSchema;
|
|
255
|
+
output: typeof UpdateResponseSchema;
|
|
256
|
+
},
|
|
257
|
+
/**
|
|
258
|
+
* Delete removes an entity by ID.
|
|
259
|
+
*
|
|
260
|
+
* @generated from rpc crud.v1.EntityService.Delete
|
|
261
|
+
*/
|
|
262
|
+
delete: {
|
|
263
|
+
methodKind: "unary";
|
|
264
|
+
input: typeof DeleteRequestSchema;
|
|
265
|
+
output: typeof DeleteResponseSchema;
|
|
266
|
+
},
|
|
267
|
+
}> = /*@__PURE__*/
|
|
268
|
+
serviceDesc(file_crud, 0);
|
|
269
|
+
|
package/src/hint.test.ts
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { Writable } from 'node:stream';
|
|
3
|
+
import {
|
|
4
|
+
HintSet, active, hintsEnabled, renderHints,
|
|
5
|
+
registerUpgradeHints, registerVersionHints,
|
|
6
|
+
} from './hint.js';
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// HintSet
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
describe('HintSet', () => {
|
|
13
|
+
it('lookup returns empty array when nothing registered', () => {
|
|
14
|
+
const s = new HintSet();
|
|
15
|
+
expect(s.lookup('foo')).toEqual([]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('register + lookup round-trips a single hint', () => {
|
|
19
|
+
const s = new HintSet();
|
|
20
|
+
s.register('foo', { message: 'do something' });
|
|
21
|
+
expect(s.lookup('foo')).toHaveLength(1);
|
|
22
|
+
expect(s.lookup('foo')[0].message).toBe('do something');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('register accumulates multiple hints for same command', () => {
|
|
26
|
+
const s = new HintSet();
|
|
27
|
+
s.register('foo', { message: 'a' }, { message: 'b' });
|
|
28
|
+
s.register('foo', { message: 'c' });
|
|
29
|
+
expect(s.lookup('foo')).toHaveLength(3);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('lookup returns independent copy — mutation does not affect set', () => {
|
|
33
|
+
const s = new HintSet();
|
|
34
|
+
s.register('foo', { message: 'x' });
|
|
35
|
+
const copy = s.lookup('foo');
|
|
36
|
+
copy.push({ message: 'injected' });
|
|
37
|
+
expect(s.lookup('foo')).toHaveLength(1);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('hints for different commands are independent', () => {
|
|
41
|
+
const s = new HintSet();
|
|
42
|
+
s.register('a', { message: 'hint-a' });
|
|
43
|
+
s.register('b', { message: 'hint-b' });
|
|
44
|
+
expect(s.lookup('a')[0].message).toBe('hint-a');
|
|
45
|
+
expect(s.lookup('b')[0].message).toBe('hint-b');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// active
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
describe('active', () => {
|
|
54
|
+
it('returns all hints when conditions are undefined', () => {
|
|
55
|
+
const hints = [{ message: 'a' }, { message: 'b' }];
|
|
56
|
+
expect(active(hints)).toHaveLength(2);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('filters out hints whose condition returns false', () => {
|
|
60
|
+
const hints = [
|
|
61
|
+
{ message: 'yes', condition: () => true },
|
|
62
|
+
{ message: 'no', condition: () => false },
|
|
63
|
+
];
|
|
64
|
+
const result = active(hints);
|
|
65
|
+
expect(result).toHaveLength(1);
|
|
66
|
+
expect(result[0].message).toBe('yes');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('returns empty array for empty input', () => {
|
|
70
|
+
expect(active([])).toEqual([]);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// hintsEnabled
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
describe('hintsEnabled', () => {
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
delete process.env['HOP_QUIET_HINTS'];
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('returns true by default', () => {
|
|
84
|
+
expect(hintsEnabled({})).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('returns false when noHints=true', () => {
|
|
88
|
+
expect(hintsEnabled({ noHints: true })).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('returns false when quiet=true', () => {
|
|
92
|
+
expect(hintsEnabled({ quiet: true })).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('returns false when hintsEnabled=false', () => {
|
|
96
|
+
expect(hintsEnabled({ hintsEnabled: false })).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('returns false when HOP_QUIET_HINTS=1', () => {
|
|
100
|
+
process.env['HOP_QUIET_HINTS'] = '1';
|
|
101
|
+
expect(hintsEnabled({})).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('returns false when HOP_QUIET_HINTS=true', () => {
|
|
105
|
+
process.env['HOP_QUIET_HINTS'] = 'true';
|
|
106
|
+
expect(hintsEnabled({})).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('returns false when HOP_QUIET_HINTS=yes', () => {
|
|
110
|
+
process.env['HOP_QUIET_HINTS'] = 'yes';
|
|
111
|
+
expect(hintsEnabled({})).toBe(false);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('returns true when HOP_QUIET_HINTS=0', () => {
|
|
115
|
+
process.env['HOP_QUIET_HINTS'] = '0';
|
|
116
|
+
expect(hintsEnabled({})).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// renderHints
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
/** Writable that captures written bytes as a string. */
|
|
125
|
+
class StringWriter extends Writable {
|
|
126
|
+
chunks: string[] = [];
|
|
127
|
+
_write(chunk: Buffer | string, _enc: string, done: () => void) {
|
|
128
|
+
this.chunks.push(chunk.toString());
|
|
129
|
+
done();
|
|
130
|
+
}
|
|
131
|
+
get value(): string { return this.chunks.join(''); }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** A Writable flagged as TTY so renderHints doesn't skip it. */
|
|
135
|
+
class TTYWriter extends StringWriter {
|
|
136
|
+
readonly isTTY = true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
describe('renderHints', () => {
|
|
140
|
+
afterEach(() => {
|
|
141
|
+
delete process.env['HOP_QUIET_HINTS'];
|
|
142
|
+
delete process.env['NO_COLOR'];
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('no-op when format is json', () => {
|
|
146
|
+
const w = new TTYWriter();
|
|
147
|
+
renderHints(w, [{ message: 'x' }], 'json', {}, '#858183');
|
|
148
|
+
expect(w.value).toBe('');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('no-op when format is yaml', () => {
|
|
152
|
+
const w = new TTYWriter();
|
|
153
|
+
renderHints(w, [{ message: 'x' }], 'yaml', {}, '#858183');
|
|
154
|
+
expect(w.value).toBe('');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('no-op when noHints=true', () => {
|
|
158
|
+
const w = new TTYWriter();
|
|
159
|
+
renderHints(w, [{ message: 'x' }], 'table', { noHints: true }, '#858183');
|
|
160
|
+
expect(w.value).toBe('');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('no-op when quiet=true', () => {
|
|
164
|
+
const w = new TTYWriter();
|
|
165
|
+
renderHints(w, [{ message: 'x' }], 'table', { quiet: true }, '#858183');
|
|
166
|
+
expect(w.value).toBe('');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('no-op when hints list is empty', () => {
|
|
170
|
+
const w = new TTYWriter();
|
|
171
|
+
renderHints(w, [], 'table', {}, '#858183');
|
|
172
|
+
expect(w.value).toBe('');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('no-op when stream is not a TTY', () => {
|
|
176
|
+
const w = new StringWriter(); // isTTY not set
|
|
177
|
+
renderHints(w, [{ message: 'x' }], 'table', {}, '#858183');
|
|
178
|
+
expect(w.value).toBe('');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('renders hint with → prefix to TTY', () => {
|
|
182
|
+
process.env['NO_COLOR'] = '1';
|
|
183
|
+
const w = new TTYWriter();
|
|
184
|
+
renderHints(w, [{ message: 'do this next' }], 'table', {}, '#858183');
|
|
185
|
+
expect(w.value).toContain('→ do this next');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('renders a leading blank line before hints', () => {
|
|
189
|
+
process.env['NO_COLOR'] = '1';
|
|
190
|
+
const w = new TTYWriter();
|
|
191
|
+
renderHints(w, [{ message: 'x' }], 'table', {}, '#858183');
|
|
192
|
+
expect(w.value.startsWith('\n')).toBe(true);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('renders multiple active hints', () => {
|
|
196
|
+
process.env['NO_COLOR'] = '1';
|
|
197
|
+
const w = new TTYWriter();
|
|
198
|
+
renderHints(w, [{ message: 'a' }, { message: 'b' }], 'table', {}, '#858183');
|
|
199
|
+
expect(w.value).toContain('→ a');
|
|
200
|
+
expect(w.value).toContain('→ b');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('skips hints whose condition returns false', () => {
|
|
204
|
+
process.env['NO_COLOR'] = '1';
|
|
205
|
+
const w = new TTYWriter();
|
|
206
|
+
renderHints(w, [
|
|
207
|
+
{ message: 'yes', condition: () => true },
|
|
208
|
+
{ message: 'no', condition: () => false },
|
|
209
|
+
], 'table', {}, '#858183');
|
|
210
|
+
expect(w.value).toContain('→ yes');
|
|
211
|
+
expect(w.value).not.toContain('→ no');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('includes ANSI color codes when NO_COLOR not set', () => {
|
|
215
|
+
const w = new TTYWriter();
|
|
216
|
+
renderHints(w, [{ message: 'colored' }], 'table', {}, '#858183');
|
|
217
|
+
expect(w.value).toContain('\x1b[');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('strips ANSI codes when NO_COLOR env set', () => {
|
|
221
|
+
process.env['NO_COLOR'] = '1';
|
|
222
|
+
const w = new TTYWriter();
|
|
223
|
+
renderHints(w, [{ message: 'plain' }], 'table', {}, '#858183');
|
|
224
|
+
expect(w.value).not.toContain('\x1b[');
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
// Standard factories
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
|
|
232
|
+
describe('registerUpgradeHints', () => {
|
|
233
|
+
it('registers hint for "upgrade" command', () => {
|
|
234
|
+
const s = new HintSet();
|
|
235
|
+
const upgraded = false;
|
|
236
|
+
registerUpgradeHints(s, 'mytool', () => upgraded);
|
|
237
|
+
expect(s.lookup('upgrade')).toHaveLength(1);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('hint is inactive when upgraded=false', () => {
|
|
241
|
+
const s = new HintSet();
|
|
242
|
+
const upgraded = false;
|
|
243
|
+
registerUpgradeHints(s, 'mytool', () => upgraded);
|
|
244
|
+
expect(active(s.lookup('upgrade'))).toHaveLength(0);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('hint is active when upgraded=true', () => {
|
|
248
|
+
const s = new HintSet();
|
|
249
|
+
let upgraded = false;
|
|
250
|
+
registerUpgradeHints(s, 'mytool', () => upgraded);
|
|
251
|
+
upgraded = true;
|
|
252
|
+
const result = active(s.lookup('upgrade'));
|
|
253
|
+
expect(result).toHaveLength(1);
|
|
254
|
+
expect(result[0].message).toContain('mytool version');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
describe('registerVersionHints', () => {
|
|
259
|
+
it('registers hint for "version" command', () => {
|
|
260
|
+
const s = new HintSet();
|
|
261
|
+
const avail = false;
|
|
262
|
+
registerVersionHints(s, 'mytool', () => avail);
|
|
263
|
+
expect(s.lookup('version')).toHaveLength(1);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('hint is inactive when updateAvail=false', () => {
|
|
267
|
+
const s = new HintSet();
|
|
268
|
+
const avail = false;
|
|
269
|
+
registerVersionHints(s, 'mytool', () => avail);
|
|
270
|
+
expect(active(s.lookup('version'))).toHaveLength(0);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('hint is active when updateAvail=true', () => {
|
|
274
|
+
const s = new HintSet();
|
|
275
|
+
let avail = false;
|
|
276
|
+
registerVersionHints(s, 'mytool', () => avail);
|
|
277
|
+
avail = true;
|
|
278
|
+
const result = active(s.lookup('version'));
|
|
279
|
+
expect(result).toHaveLength(1);
|
|
280
|
+
expect(result[0].message).toContain('mytool upgrade');
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
// createCLI integration — --no-hints flag
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
|
|
288
|
+
describe('createCLI --no-hints integration', () => {
|
|
289
|
+
it('--no-hints flag registered by default', async () => {
|
|
290
|
+
const { createCLI } = await import('./cli.js');
|
|
291
|
+
const { program } = createCLI({ name: 'mytool', version: '1.0.0', description: 'A tool' });
|
|
292
|
+
const opt = program.options.find(o => o.long === '--no-hints');
|
|
293
|
+
expect(opt).toBeDefined();
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('--no-hints absent when disable.hints=true', async () => {
|
|
297
|
+
const { createCLI } = await import('./cli.js');
|
|
298
|
+
const { program } = createCLI({
|
|
299
|
+
name: 'mytool', version: '1.0.0', description: 'A tool',
|
|
300
|
+
disable: { hints: true },
|
|
301
|
+
});
|
|
302
|
+
const opt = program.options.find(o => o.long === '--no-hints');
|
|
303
|
+
expect(opt).toBeUndefined();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('--no-hints survives when disable.format=true (decoupled)', async () => {
|
|
307
|
+
const { createCLI } = await import('./cli.js');
|
|
308
|
+
const { program } = createCLI({
|
|
309
|
+
name: 'mytool', version: '1.0.0', description: 'A tool',
|
|
310
|
+
disable: { format: true },
|
|
311
|
+
});
|
|
312
|
+
const opt = program.options.find(o => o.long === '--no-hints');
|
|
313
|
+
expect(opt).toBeDefined();
|
|
314
|
+
});
|
|
315
|
+
});
|