@xihe-lab/tapd-core 2.0.0-rc.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/LICENSE +190 -0
- package/dist/advisor/advisor.test.d.ts +2 -0
- package/dist/advisor/advisor.test.d.ts.map +1 -0
- package/dist/advisor/advisor.test.js +102 -0
- package/dist/advisor/advisor.test.js.map +1 -0
- package/dist/advisor/index.d.ts +19 -0
- package/dist/advisor/index.d.ts.map +1 -0
- package/dist/advisor/index.js +240 -0
- package/dist/advisor/index.js.map +1 -0
- package/dist/config/config.d.ts +43 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +221 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/config.test.d.ts +2 -0
- package/dist/config/config.test.d.ts.map +1 -0
- package/dist/config/config.test.js +229 -0
- package/dist/config/config.test.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/cli-meta.d.ts +4 -0
- package/dist/registry/cli-meta.d.ts.map +1 -0
- package/dist/registry/cli-meta.js +104 -0
- package/dist/registry/cli-meta.js.map +1 -0
- package/dist/registry/debug-commands.d.ts +2 -0
- package/dist/registry/debug-commands.d.ts.map +1 -0
- package/dist/registry/debug-commands.js +47 -0
- package/dist/registry/debug-commands.js.map +1 -0
- package/dist/registry/derive-command.d.ts +6 -0
- package/dist/registry/derive-command.d.ts.map +1 -0
- package/dist/registry/derive-command.js +69 -0
- package/dist/registry/derive-command.js.map +1 -0
- package/dist/registry/long-id-guard.d.ts +3 -0
- package/dist/registry/long-id-guard.d.ts.map +1 -0
- package/dist/registry/long-id-guard.js +39 -0
- package/dist/registry/long-id-guard.js.map +1 -0
- package/dist/registry/long-id-guard.test.d.ts +2 -0
- package/dist/registry/long-id-guard.test.d.ts.map +1 -0
- package/dist/registry/long-id-guard.test.js +224 -0
- package/dist/registry/long-id-guard.test.js.map +1 -0
- package/dist/registry/registry.d.ts +43 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +131 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/registry/registry.test.d.ts +2 -0
- package/dist/registry/registry.test.d.ts.map +1 -0
- package/dist/registry/registry.test.js +220 -0
- package/dist/registry/registry.test.js.map +1 -0
- package/dist/registry/richtext-manifests.generated.d.ts +3 -0
- package/dist/registry/richtext-manifests.generated.d.ts.map +1 -0
- package/dist/registry/richtext-manifests.generated.js +98 -0
- package/dist/registry/richtext-manifests.generated.js.map +1 -0
- package/dist/registry/richtext.d.ts +6 -0
- package/dist/registry/richtext.d.ts.map +1 -0
- package/dist/registry/richtext.js +64 -0
- package/dist/registry/richtext.js.map +1 -0
- package/dist/registry/richtext.test.d.ts +2 -0
- package/dist/registry/richtext.test.d.ts.map +1 -0
- package/dist/registry/richtext.test.js +210 -0
- package/dist/registry/richtext.test.js.map +1 -0
- package/dist/registry/write-policy.d.ts +3 -0
- package/dist/registry/write-policy.d.ts.map +1 -0
- package/dist/registry/write-policy.js +5 -0
- package/dist/registry/write-policy.js.map +1 -0
- package/dist/schema/export.d.ts +12 -0
- package/dist/schema/export.d.ts.map +1 -0
- package/dist/schema/export.js +39 -0
- package/dist/schema/export.js.map +1 -0
- package/dist/schema/export.test.d.ts +2 -0
- package/dist/schema/export.test.d.ts.map +1 -0
- package/dist/schema/export.test.js +68 -0
- package/dist/schema/export.test.js.map +1 -0
- package/dist/sdk-routes.d.ts +9 -0
- package/dist/sdk-routes.d.ts.map +1 -0
- package/dist/sdk-routes.js +148 -0
- package/dist/sdk-routes.js.map +1 -0
- package/dist/tapd-client.d.ts +99 -0
- package/dist/tapd-client.d.ts.map +1 -0
- package/dist/tapd-client.js +252 -0
- package/dist/tapd-client.js.map +1 -0
- package/dist/tools/attachment.d.ts +3 -0
- package/dist/tools/attachment.d.ts.map +1 -0
- package/dist/tools/attachment.js +99 -0
- package/dist/tools/attachment.js.map +1 -0
- package/dist/tools/board.d.ts +3 -0
- package/dist/tools/board.d.ts.map +1 -0
- package/dist/tools/board.js +98 -0
- package/dist/tools/board.js.map +1 -0
- package/dist/tools/bug.d.ts +3 -0
- package/dist/tools/bug.d.ts.map +1 -0
- package/dist/tools/bug.js +619 -0
- package/dist/tools/bug.js.map +1 -0
- package/dist/tools/changes.d.ts +3 -0
- package/dist/tools/changes.d.ts.map +1 -0
- package/dist/tools/changes.js +73 -0
- package/dist/tools/changes.js.map +1 -0
- package/dist/tools/comment.d.ts +3 -0
- package/dist/tools/comment.d.ts.map +1 -0
- package/dist/tools/comment.js +93 -0
- package/dist/tools/comment.js.map +1 -0
- package/dist/tools/custom-fields.d.ts +3 -0
- package/dist/tools/custom-fields.d.ts.map +1 -0
- package/dist/tools/custom-fields.js +105 -0
- package/dist/tools/custom-fields.js.map +1 -0
- package/dist/tools/image.d.ts +3 -0
- package/dist/tools/image.d.ts.map +1 -0
- package/dist/tools/image.js +23 -0
- package/dist/tools/image.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/iteration.d.ts +3 -0
- package/dist/tools/iteration.d.ts.map +1 -0
- package/dist/tools/iteration.js +190 -0
- package/dist/tools/iteration.js.map +1 -0
- package/dist/tools/md-to-html.test.d.ts +2 -0
- package/dist/tools/md-to-html.test.d.ts.map +1 -0
- package/dist/tools/md-to-html.test.js +125 -0
- package/dist/tools/md-to-html.test.js.map +1 -0
- package/dist/tools/mini-comment.d.ts +3 -0
- package/dist/tools/mini-comment.d.ts.map +1 -0
- package/dist/tools/mini-comment.js +74 -0
- package/dist/tools/mini-comment.js.map +1 -0
- package/dist/tools/mini-item.d.ts +3 -0
- package/dist/tools/mini-item.d.ts.map +1 -0
- package/dist/tools/mini-item.js +166 -0
- package/dist/tools/mini-item.js.map +1 -0
- package/dist/tools/mini-workspace.d.ts +3 -0
- package/dist/tools/mini-workspace.d.ts.map +1 -0
- package/dist/tools/mini-workspace.js +43 -0
- package/dist/tools/mini-workspace.js.map +1 -0
- package/dist/tools/program.d.ts +3 -0
- package/dist/tools/program.d.ts.map +1 -0
- package/dist/tools/program.js +27 -0
- package/dist/tools/program.js.map +1 -0
- package/dist/tools/relations.d.ts +3 -0
- package/dist/tools/relations.d.ts.map +1 -0
- package/dist/tools/relations.js +68 -0
- package/dist/tools/relations.js.map +1 -0
- package/dist/tools/release.d.ts +3 -0
- package/dist/tools/release.d.ts.map +1 -0
- package/dist/tools/release.js +250 -0
- package/dist/tools/release.js.map +1 -0
- package/dist/tools/report.d.ts +3 -0
- package/dist/tools/report.d.ts.map +1 -0
- package/dist/tools/report.js +38 -0
- package/dist/tools/report.js.map +1 -0
- package/dist/tools/settings.d.ts +3 -0
- package/dist/tools/settings.d.ts.map +1 -0
- package/dist/tools/settings.js +409 -0
- package/dist/tools/settings.js.map +1 -0
- package/dist/tools/source.d.ts +3 -0
- package/dist/tools/source.d.ts.map +1 -0
- package/dist/tools/source.js +69 -0
- package/dist/tools/source.js.map +1 -0
- package/dist/tools/story.d.ts +3 -0
- package/dist/tools/story.d.ts.map +1 -0
- package/dist/tools/story.js +680 -0
- package/dist/tools/story.js.map +1 -0
- package/dist/tools/task.d.ts +3 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +267 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/test.d.ts +3 -0
- package/dist/tools/test.d.ts.map +1 -0
- package/dist/tools/test.js +564 -0
- package/dist/tools/test.js.map +1 -0
- package/dist/tools/timesheet.d.ts +3 -0
- package/dist/tools/timesheet.d.ts.map +1 -0
- package/dist/tools/timesheet.js +118 -0
- package/dist/tools/timesheet.js.map +1 -0
- package/dist/tools/user.d.ts +3 -0
- package/dist/tools/user.d.ts.map +1 -0
- package/dist/tools/user.js +57 -0
- package/dist/tools/user.js.map +1 -0
- package/dist/tools/utility.d.ts +3 -0
- package/dist/tools/utility.d.ts.map +1 -0
- package/dist/tools/utility.js +165 -0
- package/dist/tools/utility.js.map +1 -0
- package/dist/tools/wiki.d.ts +3 -0
- package/dist/tools/wiki.d.ts.map +1 -0
- package/dist/tools/wiki.js +227 -0
- package/dist/tools/wiki.js.map +1 -0
- package/dist/tools/workflow.d.ts +3 -0
- package/dist/tools/workflow.d.ts.map +1 -0
- package/dist/tools/workflow.js +116 -0
- package/dist/tools/workflow.js.map +1 -0
- package/dist/tools/workspace.d.ts +3 -0
- package/dist/tools/workspace.d.ts.map +1 -0
- package/dist/tools/workspace.js +137 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/tools/zz-acceptance-echo.d.ts +3 -0
- package/dist/tools/zz-acceptance-echo.d.ts.map +1 -0
- package/dist/tools/zz-acceptance-echo.js +9 -0
- package/dist/tools/zz-acceptance-echo.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 xihe-lab
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advisor.test.d.ts","sourceRoot":"","sources":["../../src/advisor/advisor.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { allTools, ToolRegistry } from '../index.js';
|
|
4
|
+
import { buildAdvisorIndex, recommend } from './index.js';
|
|
5
|
+
const registry = new ToolRegistry();
|
|
6
|
+
registry.register(allTools);
|
|
7
|
+
const index = buildAdvisorIndex(registry);
|
|
8
|
+
const checks = [
|
|
9
|
+
['index covers all registered tools', () => {
|
|
10
|
+
assert.equal(index.length, registry.list().length);
|
|
11
|
+
const storyUpdate = index.find(e => e.toolName === 'tapd_update_story');
|
|
12
|
+
assert.equal(storyUpdate.command, 'story update');
|
|
13
|
+
assert.equal(storyUpdate.isWrite, true);
|
|
14
|
+
assert.equal(storyUpdate.weights.get('update'), 3);
|
|
15
|
+
assert.equal(storyUpdate.weights.get('story'), 3);
|
|
16
|
+
}],
|
|
17
|
+
['「切状态」story update 与 workflow status-map 进 top3', () => {
|
|
18
|
+
const hits = recommend('切状态', index);
|
|
19
|
+
const top3 = hits.slice(0, 3).map(h => h.command);
|
|
20
|
+
assert.ok(top3.includes('workflow status-map'), `top3=${top3.join(', ')}`);
|
|
21
|
+
assert.ok(top3.includes('story update'), `top3=${top3.join(', ')}`);
|
|
22
|
+
const statusMap = hits.find(h => h.command === 'workflow status-map');
|
|
23
|
+
assert.equal(statusMap.write, false);
|
|
24
|
+
const storyUpdate = hits.find(h => h.command === 'story update');
|
|
25
|
+
assert.equal(storyUpdate.write, true);
|
|
26
|
+
}],
|
|
27
|
+
['「分给我」命中 assign 类命令', () => {
|
|
28
|
+
const hits = recommend('分给我', index);
|
|
29
|
+
assert.ok(hits.length > 0);
|
|
30
|
+
assert.ok(hits.some(h => h.command.includes('assign')), hits.map(h => h.command).join(', '));
|
|
31
|
+
}],
|
|
32
|
+
['「指派」同义命中 assign 类命令', () => {
|
|
33
|
+
const hits = recommend('指派', index);
|
|
34
|
+
assert.ok(hits.some(h => h.command.includes('assign')));
|
|
35
|
+
}],
|
|
36
|
+
['「评论」命中 comment 类命令', () => {
|
|
37
|
+
const hits = recommend('评论', index);
|
|
38
|
+
assert.ok(hits.length > 0);
|
|
39
|
+
assert.ok(hits.some(h => h.command === 'story comment' || h.command.startsWith('comment')), hits.map(h => h.command).join(', '));
|
|
40
|
+
}],
|
|
41
|
+
['「拉迭代」第一名为 iteration list', () => {
|
|
42
|
+
const hits = recommend('拉迭代', index);
|
|
43
|
+
assert.ok(hits.length > 0);
|
|
44
|
+
assert.equal(hits[0].command, 'iteration list');
|
|
45
|
+
}],
|
|
46
|
+
['英文模糊:creat 命中 create 类命令', () => {
|
|
47
|
+
const hits = recommend('creat', index);
|
|
48
|
+
assert.ok(hits.length > 0);
|
|
49
|
+
assert.ok(hits.some(h => h.command.includes('create')), hits.map(h => h.command).join(', '));
|
|
50
|
+
}],
|
|
51
|
+
['无关词返回空', () => {
|
|
52
|
+
assert.equal(recommend('xyzabc', index).length, 0);
|
|
53
|
+
}],
|
|
54
|
+
['空查询返回空', () => {
|
|
55
|
+
assert.equal(recommend('', index).length, 0);
|
|
56
|
+
}],
|
|
57
|
+
['limit 截断生效', () => {
|
|
58
|
+
assert.ok(recommend('update', index, 3).length <= 3);
|
|
59
|
+
assert.equal(recommend('update', index).length, 10);
|
|
60
|
+
}],
|
|
61
|
+
['结果按分数降序排列', () => {
|
|
62
|
+
const hits = recommend('需求列表', index);
|
|
63
|
+
for (let i = 1; i < hits.length; i++) {
|
|
64
|
+
assert.ok(hits[i - 1].score >= hits[i].score);
|
|
65
|
+
}
|
|
66
|
+
}],
|
|
67
|
+
['cli.alias 以 4 分参与召回', () => {
|
|
68
|
+
const mini = new ToolRegistry();
|
|
69
|
+
const aliased = {
|
|
70
|
+
name: 'tapd_get_thing',
|
|
71
|
+
description: 'demo',
|
|
72
|
+
inputSchema: z.object({}),
|
|
73
|
+
handler: () => Promise.resolve({}),
|
|
74
|
+
cli: { resource: 'demo', action: 'run', alias: 'qswitch' },
|
|
75
|
+
};
|
|
76
|
+
mini.register([aliased]);
|
|
77
|
+
const miniIndex = buildAdvisorIndex(mini);
|
|
78
|
+
const hits = recommend('qswitch', miniIndex);
|
|
79
|
+
assert.equal(hits.length, 1);
|
|
80
|
+
assert.equal(hits[0].tool, 'tapd_get_thing');
|
|
81
|
+
}],
|
|
82
|
+
];
|
|
83
|
+
let failed = 0;
|
|
84
|
+
for (const [name, check] of checks) {
|
|
85
|
+
try {
|
|
86
|
+
await check();
|
|
87
|
+
console.log(`PASS ${name}`);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
failed++;
|
|
91
|
+
console.error(`FAIL ${name}`);
|
|
92
|
+
console.error(` ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (failed > 0) {
|
|
96
|
+
console.error(`\n${failed}/${checks.length} failed`);
|
|
97
|
+
process.exitCode = 1;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.log(`\n${checks.length}/${checks.length} passed`);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=advisor.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advisor.test.js","sourceRoot":"","sources":["../../src/advisor/advisor.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;AACpC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,MAAM,GAA2C;IACrD,CAAC,mCAAmC,EAAE,GAAG,EAAE;YACzC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;YACnD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,mBAAmB,CAAE,CAAC;YACzE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAClD,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACxC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACnD,MAAM,CAAC,KAAK,CAAC,WAAW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OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,IAAI,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;IACrD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ToolRegistry } from '../registry/registry.js';
|
|
2
|
+
export interface AdvisorEntry {
|
|
3
|
+
toolName: string;
|
|
4
|
+
command: string;
|
|
5
|
+
description: string;
|
|
6
|
+
isWrite: boolean;
|
|
7
|
+
tokens: Set<string>;
|
|
8
|
+
weights: Map<string, number>;
|
|
9
|
+
}
|
|
10
|
+
export interface AdvisorHit {
|
|
11
|
+
tool: string;
|
|
12
|
+
command: string;
|
|
13
|
+
description: string;
|
|
14
|
+
write: boolean;
|
|
15
|
+
score: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildAdvisorIndex(registry: ToolRegistry): AdvisorEntry[];
|
|
18
|
+
export declare function recommend(query: string, index: AdvisorEntry[], limit?: number): AdvisorHit[];
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/advisor/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AA2JD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAmCxE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,KAAK,SAAK,GAAG,UAAU,EAAE,CAwCxF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// 中文口语 → 英文 token(FSD 4.8),命中按 name 级 3 分计
|
|
2
|
+
const SYNONYMS = [
|
|
3
|
+
['切状态', ['status', 'update', 'transition']],
|
|
4
|
+
['流转', ['status', 'transition', 'workflow']],
|
|
5
|
+
['扭转', ['status', 'update', 'transition']],
|
|
6
|
+
['拉迭代', ['iteration', 'list']],
|
|
7
|
+
['分给我', ['assign', 'owner']],
|
|
8
|
+
['指派', ['assign', 'owner']],
|
|
9
|
+
['知识库', ['wiki']],
|
|
10
|
+
['负责人', ['owner']],
|
|
11
|
+
['处理人', ['owner']],
|
|
12
|
+
['评论', ['comment']],
|
|
13
|
+
['留言', ['comment']],
|
|
14
|
+
['附件', ['attachment']],
|
|
15
|
+
['迭代', ['iteration']],
|
|
16
|
+
['版本', ['version', 'release']],
|
|
17
|
+
['发布', ['release', 'version']],
|
|
18
|
+
['需求', ['story']],
|
|
19
|
+
['缺陷', ['bug']],
|
|
20
|
+
['任务', ['task']],
|
|
21
|
+
['文档', ['wiki']],
|
|
22
|
+
['工时', ['timesheet', 'effort']],
|
|
23
|
+
['项目', ['project', 'workspace']],
|
|
24
|
+
['创建', ['create']],
|
|
25
|
+
['新建', ['create']],
|
|
26
|
+
['新增', ['create']],
|
|
27
|
+
['更新', ['update']],
|
|
28
|
+
['修改', ['update']],
|
|
29
|
+
['删除', ['delete']],
|
|
30
|
+
['复制', ['copy']],
|
|
31
|
+
['克隆', ['copy']],
|
|
32
|
+
['列表', ['list']],
|
|
33
|
+
['查询', ['list', 'query']],
|
|
34
|
+
['查看', ['get', 'list']],
|
|
35
|
+
['统计', ['count']],
|
|
36
|
+
['数量', ['count']],
|
|
37
|
+
['历史', ['changes', 'history']],
|
|
38
|
+
['关联', ['link', 'relation']],
|
|
39
|
+
['绑定', ['bind']],
|
|
40
|
+
['锁定', ['lock']],
|
|
41
|
+
['解锁', ['unlock']],
|
|
42
|
+
['用例', ['test', 'case']],
|
|
43
|
+
['计划', ['plan']],
|
|
44
|
+
['字段', ['field']],
|
|
45
|
+
['模板', ['template']],
|
|
46
|
+
['批量', ['batch']],
|
|
47
|
+
];
|
|
48
|
+
const SYNONYM_ENTRIES = [...SYNONYMS].sort((a, b) => b[0].length - a[0].length);
|
|
49
|
+
const DOMAIN_RANK = ['story', 'bug', 'task', 'iteration', 'wiki', 'comment'];
|
|
50
|
+
const PLAIN = Number.MAX_SAFE_INTEGER;
|
|
51
|
+
const LATIN_TOKEN = /^[a-z0-9]+$/;
|
|
52
|
+
const LATIN_RUN = /[a-z0-9_-]+/g;
|
|
53
|
+
const CHINESE_RUN = /[一-鿿]+/g;
|
|
54
|
+
function singularize(word) {
|
|
55
|
+
if (word.endsWith('ies') && word.length > 4)
|
|
56
|
+
return `${word.slice(0, -3)}y`;
|
|
57
|
+
if (/(?:x|ch|sh|ss)es$/.test(word))
|
|
58
|
+
return word.slice(0, -2);
|
|
59
|
+
if (word.endsWith('s') && !word.endsWith('ss') && !word.endsWith('us') && word.length > 3) {
|
|
60
|
+
return word.slice(0, -1);
|
|
61
|
+
}
|
|
62
|
+
return word;
|
|
63
|
+
}
|
|
64
|
+
function chineseBigrams(text) {
|
|
65
|
+
if (text.length <= 1)
|
|
66
|
+
return text.length === 1 ? [text] : [];
|
|
67
|
+
const out = [];
|
|
68
|
+
for (let i = 0; i < text.length - 1; i++)
|
|
69
|
+
out.push(text.slice(i, i + 2));
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
function expandSynonyms(run) {
|
|
73
|
+
let rest = run;
|
|
74
|
+
const tokens = [];
|
|
75
|
+
for (const [key, expansion] of SYNONYM_ENTRIES) {
|
|
76
|
+
if (!rest.includes(key))
|
|
77
|
+
continue;
|
|
78
|
+
rest = rest.split(key).join('');
|
|
79
|
+
expansion.forEach((text, synIdx) => tokens.push({ text, synIdx }));
|
|
80
|
+
}
|
|
81
|
+
return { tokens, rest };
|
|
82
|
+
}
|
|
83
|
+
function tokenize(query) {
|
|
84
|
+
const lowered = query.toLowerCase();
|
|
85
|
+
const merged = new Map();
|
|
86
|
+
const add = (text, synIdx) => {
|
|
87
|
+
const prev = merged.get(text);
|
|
88
|
+
if (prev === undefined || synIdx < prev)
|
|
89
|
+
merged.set(text, synIdx);
|
|
90
|
+
};
|
|
91
|
+
for (const word of lowered.match(LATIN_RUN) ?? []) {
|
|
92
|
+
for (const part of word.split(/[-_]/)) {
|
|
93
|
+
if (part)
|
|
94
|
+
add(part, PLAIN);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const run of lowered.match(CHINESE_RUN) ?? []) {
|
|
98
|
+
const { tokens, rest } = expandSynonyms(run);
|
|
99
|
+
for (const token of tokens)
|
|
100
|
+
add(token.text, token.synIdx);
|
|
101
|
+
for (const bigram of chineseBigrams(rest))
|
|
102
|
+
add(bigram, PLAIN);
|
|
103
|
+
}
|
|
104
|
+
return [...merged].map(([text, synIdx]) => ({ text, synIdx }));
|
|
105
|
+
}
|
|
106
|
+
function withinEditDistance1(a, b) {
|
|
107
|
+
if (a === b)
|
|
108
|
+
return true;
|
|
109
|
+
const la = a.length;
|
|
110
|
+
const lb = b.length;
|
|
111
|
+
if (Math.abs(la - lb) > 1)
|
|
112
|
+
return false;
|
|
113
|
+
let i = 0;
|
|
114
|
+
let j = 0;
|
|
115
|
+
let edited = false;
|
|
116
|
+
while (i < la && j < lb) {
|
|
117
|
+
if (a[i] === b[j]) {
|
|
118
|
+
i++;
|
|
119
|
+
j++;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (edited)
|
|
123
|
+
return false;
|
|
124
|
+
edited = true;
|
|
125
|
+
if (la > lb)
|
|
126
|
+
i++;
|
|
127
|
+
else if (la < lb)
|
|
128
|
+
j++;
|
|
129
|
+
else {
|
|
130
|
+
i++;
|
|
131
|
+
j++;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
function fuzzyWeight(token, entry) {
|
|
137
|
+
if (token.length < 3 || !LATIN_TOKEN.test(token))
|
|
138
|
+
return 0;
|
|
139
|
+
let best = 0;
|
|
140
|
+
for (const [entryToken, weight] of entry.weights) {
|
|
141
|
+
if (!LATIN_TOKEN.test(entryToken))
|
|
142
|
+
continue;
|
|
143
|
+
if (entryToken.startsWith(token) || token.startsWith(entryToken)) {
|
|
144
|
+
if (weight > best)
|
|
145
|
+
best = weight;
|
|
146
|
+
}
|
|
147
|
+
else if (withinEditDistance1(token, entryToken) && weight > best) {
|
|
148
|
+
best = weight;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return best;
|
|
152
|
+
}
|
|
153
|
+
function domainRank(entry) {
|
|
154
|
+
const idx = DOMAIN_RANK.indexOf(entry.command.split(' ')[0]);
|
|
155
|
+
return idx === -1 ? DOMAIN_RANK.length : idx;
|
|
156
|
+
}
|
|
157
|
+
export function buildAdvisorIndex(registry) {
|
|
158
|
+
return registry.commands().map(cmd => {
|
|
159
|
+
const tool = registry.get(cmd.tool);
|
|
160
|
+
const weights = new Map();
|
|
161
|
+
const add = (token, weight) => {
|
|
162
|
+
const prev = weights.get(token);
|
|
163
|
+
if (prev === undefined || weight > prev)
|
|
164
|
+
weights.set(token, weight);
|
|
165
|
+
};
|
|
166
|
+
if (tool?.cli?.alias)
|
|
167
|
+
add(tool.cli.alias.toLowerCase(), 4);
|
|
168
|
+
for (const seg of cmd.tool.replace(/^tapd_/, '').toLowerCase().split('_')) {
|
|
169
|
+
add(seg, 3);
|
|
170
|
+
const sing = singularize(seg);
|
|
171
|
+
if (sing !== seg)
|
|
172
|
+
add(sing, 3);
|
|
173
|
+
}
|
|
174
|
+
for (const part of cmd.resource.split('-'))
|
|
175
|
+
add(part, 2);
|
|
176
|
+
for (const part of cmd.action.split('-'))
|
|
177
|
+
add(part, 2);
|
|
178
|
+
const description = tool?.description ?? '';
|
|
179
|
+
for (const word of description.toLowerCase().match(/[a-z0-9]+/g) ?? [])
|
|
180
|
+
add(word, 1);
|
|
181
|
+
for (const run of description.match(CHINESE_RUN) ?? []) {
|
|
182
|
+
for (const bigram of chineseBigrams(run))
|
|
183
|
+
add(bigram, 1);
|
|
184
|
+
}
|
|
185
|
+
if (tool?.cli?.examples) {
|
|
186
|
+
for (const example of tool.cli.examples) {
|
|
187
|
+
for (const word of example.toLowerCase().match(/[a-z0-9]+/g) ?? [])
|
|
188
|
+
add(word, 2);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
toolName: cmd.tool,
|
|
193
|
+
command: `${cmd.resource} ${cmd.action}`,
|
|
194
|
+
description,
|
|
195
|
+
isWrite: cmd.write,
|
|
196
|
+
tokens: new Set(weights.keys()),
|
|
197
|
+
weights,
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
export function recommend(query, index, limit = 10) {
|
|
202
|
+
const qTokens = tokenize(query);
|
|
203
|
+
if (qTokens.length === 0)
|
|
204
|
+
return [];
|
|
205
|
+
const scored = [];
|
|
206
|
+
for (const entry of index) {
|
|
207
|
+
let score = 0;
|
|
208
|
+
let priority = PLAIN;
|
|
209
|
+
for (const qt of qTokens) {
|
|
210
|
+
const direct = entry.weights.get(qt.text);
|
|
211
|
+
if (direct !== undefined) {
|
|
212
|
+
score += qt.synIdx === PLAIN ? direct : 3;
|
|
213
|
+
priority = Math.min(priority, qt.synIdx);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (qt.synIdx !== PLAIN)
|
|
217
|
+
continue;
|
|
218
|
+
const fuzzy = fuzzyWeight(qt.text, entry);
|
|
219
|
+
if (fuzzy > 0) {
|
|
220
|
+
score += fuzzy * 0.5;
|
|
221
|
+
priority = Math.min(priority, qt.synIdx);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (score <= 0)
|
|
225
|
+
continue;
|
|
226
|
+
scored.push({ entry, score, priority, rank: domainRank(entry) });
|
|
227
|
+
}
|
|
228
|
+
scored.sort((a, b) => b.score - a.score
|
|
229
|
+
|| a.priority - b.priority
|
|
230
|
+
|| a.rank - b.rank
|
|
231
|
+
|| (a.entry.toolName < b.entry.toolName ? -1 : 1));
|
|
232
|
+
return scored.slice(0, limit).map(({ entry, score }) => ({
|
|
233
|
+
tool: entry.toolName,
|
|
234
|
+
command: entry.command,
|
|
235
|
+
description: entry.description,
|
|
236
|
+
write: entry.isWrite,
|
|
237
|
+
score,
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/advisor/index.ts"],"names":[],"mappings":"AAmBA,2CAA2C;AAC3C,MAAM,QAAQ,GAAyB;IACrC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC,IAAI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G,CAAC,CAAC,KAAK;WACd,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ;WACvB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI;WACf,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACvD,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,KAAK;KACN,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type AuthMode = 'token' | 'basic';
|
|
2
|
+
export type OutputFormat = 'text' | 'table' | 'json' | 'auto';
|
|
3
|
+
export interface TapdConfig {
|
|
4
|
+
workspace_id?: number;
|
|
5
|
+
auth_mode?: AuthMode;
|
|
6
|
+
access_token?: string;
|
|
7
|
+
api_user?: string;
|
|
8
|
+
api_password?: string;
|
|
9
|
+
nick_name?: string;
|
|
10
|
+
default_output?: OutputFormat;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
read_only?: boolean;
|
|
13
|
+
use_sdk?: boolean;
|
|
14
|
+
use_richtext_auto?: boolean;
|
|
15
|
+
default_story_workitem_type_id?: string;
|
|
16
|
+
default_task_workitem_type_id?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const CONFIG_KEYS: readonly ["workspace_id", "auth_mode", "access_token", "api_user", "api_password", "nick_name", "default_output", "timeout", "read_only", "use_sdk", "use_richtext_auto", "default_story_workitem_type_id", "default_task_workitem_type_id"];
|
|
19
|
+
export type ConfigKey = (typeof CONFIG_KEYS)[number];
|
|
20
|
+
export type ConfigSource = 'flag' | 'env' | 'config' | 'default';
|
|
21
|
+
export interface ConfigFlags {
|
|
22
|
+
workspaceId?: number;
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
auth?: AuthMode;
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
output?: OutputFormat;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ResolvedConfig extends TapdConfig {
|
|
30
|
+
readOnly: boolean;
|
|
31
|
+
useSdk: boolean;
|
|
32
|
+
useRichtextAuto: boolean;
|
|
33
|
+
timeoutMs: number;
|
|
34
|
+
sources: Partial<Record<ConfigKey | 'read_only' | 'timeout', ConfigSource>>;
|
|
35
|
+
}
|
|
36
|
+
export declare function configPath(): string;
|
|
37
|
+
export declare function loadConfig(filePath?: string): TapdConfig;
|
|
38
|
+
export declare function saveConfig(config: TapdConfig, filePath?: string): void;
|
|
39
|
+
export declare function applyConfigToEnv(config: TapdConfig): void;
|
|
40
|
+
export declare function resolveConfig(flags?: ConfigFlags, config?: TapdConfig): ResolvedConfig;
|
|
41
|
+
export declare function maskSecret(value: string | undefined): string;
|
|
42
|
+
export declare function parseConfigSet(items: string[]): Partial<TapdConfig>;
|
|
43
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AACzC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE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