@aiready/doc-drift 0.14.14 → 0.14.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,214 @@
1
+ export const DESCRIPTIVE_PARAMS = new Set([
2
+ 'data',
3
+ 'item',
4
+ 'value',
5
+ 'key',
6
+ 'index',
7
+ 'id',
8
+ 'name',
9
+ 'type',
10
+ 'config',
11
+ 'options',
12
+ 'params',
13
+ 'args',
14
+ 'input',
15
+ 'output',
16
+ 'result',
17
+ 'response',
18
+ 'request',
19
+ 'callback',
20
+ 'handler',
21
+ 'event',
22
+ 'error',
23
+ 'message',
24
+ 'context',
25
+ 'file',
26
+ 'path',
27
+ 'url',
28
+ 'source',
29
+ 'target',
30
+ 'content',
31
+ 'body',
32
+ 'payload',
33
+ 'user',
34
+ 'userid',
35
+ 'user_id',
36
+ 'starttime',
37
+ 'endtime',
38
+ 'duration',
39
+ 'timeout',
40
+ 'retry',
41
+ 'count',
42
+ 'limit',
43
+ 'offset',
44
+ 'page',
45
+ 'size',
46
+ 'length',
47
+ 'width',
48
+ 'height',
49
+ 'depth',
50
+ 'color',
51
+ 'background',
52
+ 'foreground',
53
+ 'border',
54
+ 'margin',
55
+ 'padding',
56
+ 'position',
57
+ 'top',
58
+ 'bottom',
59
+ 'left',
60
+ 'right',
61
+ 'center',
62
+ 'start',
63
+ 'end',
64
+ 'begin',
65
+ 'finish',
66
+ 'complete',
67
+ 'pending',
68
+ 'active',
69
+ 'inactive',
70
+ 'enabled',
71
+ 'disabled',
72
+ 'visible',
73
+ 'hidden',
74
+ 'open',
75
+ 'closed',
76
+ 'locked',
77
+ 'unlocked',
78
+ 'read',
79
+ 'write',
80
+ 'append',
81
+ 'prepend',
82
+ 'insert',
83
+ 'replace',
84
+ 'merge',
85
+ 'split',
86
+ 'join',
87
+ 'filter',
88
+ 'map',
89
+ 'reduce',
90
+ 'find',
91
+ 'sort',
92
+ 'reverse',
93
+ 'unique',
94
+ 'flatten',
95
+ 'compact',
96
+ 'chunk',
97
+ 'zip',
98
+ 'unzip',
99
+ 'completed',
100
+ 'failed',
101
+ 'healthy',
102
+ 'high',
103
+ 'medium',
104
+ 'low',
105
+ 'running',
106
+ 'stopped',
107
+ 'title',
108
+ 'subtitle',
109
+ 'label',
110
+ 'description',
111
+ 'version',
112
+ 'timestamp',
113
+ 'date',
114
+ 'time',
115
+ 'status',
116
+ 'mode',
117
+ 'action',
118
+ 'effect',
119
+ 'resource',
120
+ 'principal',
121
+ 'statement',
122
+ 'sid',
123
+ 'allow',
124
+ 'deny',
125
+ 'roi',
126
+ 'unifiedbudget',
127
+ 'filepath',
128
+ 'rootdir',
129
+ 'fp',
130
+ 'email',
131
+ 'username',
132
+ 'password',
133
+ 'token',
134
+ 'secret',
135
+ 'apikey',
136
+ 'api_key',
137
+ 'baseurl',
138
+ 'base_url',
139
+ 'endpoint',
140
+ 'method',
141
+ 'headers',
142
+ 'queryparams',
143
+ 'query_params',
144
+ 'bodyparams',
145
+ 'body_params',
146
+ 'formdata',
147
+ 'form_data',
148
+ 'filename',
149
+ 'file_name',
150
+ 'filetype',
151
+ 'file_type',
152
+ 'filesize',
153
+ 'file_size',
154
+ 'filecontent',
155
+ 'file_content',
156
+ 'fileurl',
157
+ 'file_url',
158
+ 'fileid',
159
+ 'file_id',
160
+ 'filekey',
161
+ 'file_key',
162
+ 'filepath',
163
+ 'file_path',
164
+ 'filedir',
165
+ 'file_dir',
166
+ 'fileext',
167
+ 'file_ext',
168
+ 'filebase',
169
+ 'file_base',
170
+ 'filenamewithoutext',
171
+ 'file_name_without_ext',
172
+ 'filedirname',
173
+ 'file_dirname',
174
+ 'filebasename',
175
+ 'file_basename',
176
+ 'fileextname',
177
+ 'file_extname',
178
+ 'fileroot',
179
+ 'file_root',
180
+ 'filesep',
181
+ 'file_sep',
182
+ 'filejoin',
183
+ 'file_join',
184
+ 'fileresolve',
185
+ 'file_resolve',
186
+ 'filenormalize',
187
+ 'file_normalize',
188
+ 'exp',
189
+ 'ctx',
190
+ 'options',
191
+ 'done',
192
+ 'next',
193
+ 'reject',
194
+ 'resolve',
195
+ 'error',
196
+ 'err',
197
+ 'req',
198
+ 'res',
199
+ 'event',
200
+ 'payload',
201
+ 'metadata',
202
+ 'params',
203
+ 'props',
204
+ 'state',
205
+ 'dispatch',
206
+ 'action',
207
+ 'config',
208
+ 'directory',
209
+ 'useroptions',
210
+ 'resultslength',
211
+ 'totalissues',
212
+ 'totaltokencost',
213
+ 'elapsedtime',
214
+ ]);
@@ -0,0 +1,53 @@
1
+ import { DESCRIPTIVE_PARAMS } from './constants';
2
+ import { ExportInfo } from '@aiready/core';
3
+
4
+ /**
5
+ * Checks if documentation for an export correctly covers its parameters.
6
+ * Returns a list of missing parameters that are NOT in DESCRIPTIVE_PARAMS.
7
+ */
8
+ export function getMissingParams(exp: ExportInfo): string[] {
9
+ if (exp.type !== 'function' || !exp.parameters || !exp.documentation) {
10
+ return [];
11
+ }
12
+
13
+ const docContent = exp.documentation.content;
14
+ const params = exp.parameters;
15
+
16
+ return params.filter((p) => {
17
+ // Skip descriptive parameters that don't need documentation
18
+ if (DESCRIPTIVE_PARAMS.has(p.toLowerCase())) {
19
+ return false;
20
+ }
21
+ const regex = new RegExp(`\\b${p}\\b`);
22
+ return !regex.test(docContent);
23
+ });
24
+ }
25
+
26
+ /**
27
+ * Heuristic check if an export has high complexity but is undocumented.
28
+ */
29
+ export function isUndocumentedComplexity(exp: ExportInfo): boolean {
30
+ if (exp.documentation) return false;
31
+ if (!exp.loc) return false;
32
+
33
+ const lines = exp.loc.end.line - exp.loc.start.line;
34
+ // Heuristic: more than 20 lines of code usually deserves documentation
35
+ return lines > 20;
36
+ }
37
+
38
+ /**
39
+ * Checks for temporal drift between documentation and code.
40
+ *
41
+ * @param bodyModified - Timestamp of last code modification
42
+ * @param docModified - Timestamp of last documentation modification
43
+ */
44
+ export function hasTemporalDrift(
45
+ bodyModified: number,
46
+ docModified: number
47
+ ): boolean {
48
+ if (bodyModified <= 0 || docModified <= 0) return false;
49
+
50
+ // If body was modified more than 1 day AFTER the documentation
51
+ const DRIFT_THRESHOLD_SECONDS = 24 * 60 * 60;
52
+ return bodyModified - docModified > DRIFT_THRESHOLD_SECONDS;
53
+ }