@code-sentinel-cli/code-sentinel-cli 4.0.13 → 4.0.14

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.
@@ -2,11 +2,6 @@ Bạn là senior Angular reviewer. Đánh giá Angular review unit dưới đây
2
2
 
3
3
  ## CRITICAL RULES
4
4
 
5
- Framework/contract evidence requirements:
6
-
7
- - Resolve the exact type import module (including aliases and re-exports) before reporting a missing response field. A same-named interface in an unused support file is not the caller's contract. For example `IAuthResponse` imported from `@core/auth` may include a reset `token` even when an old UI-local interface does not. Missing canonical support is insufficient evidence of a mismatch. A field truly absent from the canonical imported contract remains reportable.
8
-
9
-
10
5
  1. **CHỈ report lỗi có bằng chứng cụ thể** trong primary hoặc support files. Không đoán convention ngoài cluster.
11
6
  2. **`line` BẮT BUỘC trỏ về PRIMARY file**.
12
7
  3. **Confidence `<50` → KHÔNG emit**.
@@ -33,15 +28,6 @@ Framework/contract evidence requirements:
33
28
  - List<String> và encoder hỗ trợ array: truyền array để sinh `paths=a&paths=b`, giữ ký tự đặc biệt trong mỗi phần tử.
34
29
  - Reset-password token khác OAuth accessToken/refreshToken. Field thiếu trong interface là typing gap cần xác minh; không thay reset token bằng accessToken chỉ vì field chưa khai báo.
35
30
 
36
- ## Trace contract qua callee, không suy luận từ tên/type đơn lẻ
37
-
38
- - Lần theo method được caller gọi và pipeline thực tế trong support files: `map(res => res?.detail ?? res)` đã unwrap một lần. Caller đọc `res.content`/`res.totalElements` là đúng khi đó; thêm `.detail` sẽ gây double unwrap. Nếu generic `Observable<Wrapped>` còn giữ envelope dù pipeline unwrap, báo **typing mismatch ở service** khi service là PRIMARY, không khẳng định caller runtime sai.
39
- - `ResponseDetailType<T>` không đồng nghĩa `{detail:T}`: đọc định nghĩa field. Nếu type thực có `content`, caller `res.content` là nhất quán. Một method `getProcessEmployees` không thừa hưởng contract `getUnconfirmedList` chỉ vì cùng service hoặc tên kiểu gần giống.
40
- - Raw HttpClient trên service được inject vẫn chạy interceptors. Caller cố ý đọc raw envelope `res.detail`, gắn `SKIP_LOADING`, không có mismatch error handling đã chứng minh thì không flag chỉ vì không thêm wrapper method. Nếu headers/org/auth khác là lỗi, phải chỉ ra endpoint cần chúng trong support evidence; không giả định mọi endpoint có cùng yêu cầu.
41
- - `fetch(..., {keepalive:true})` trong beforeunload/ngOnDestroy có mục đích hoàn tất request khi page đóng. Không đề nghị thay bằng HttpClient hay sendBeacon chỉ vì khác kiến trúc: phải giữ keepalive và Authorization contract (sendBeacon không hỗ trợ header Authorization tùy ý). URL query chứa giá trị chưa encode vẫn là lỗi riêng; encodeURIComponent/HttpParams đã encode thì không flag query.
42
- - PUT khai báo `null` và caller đọc `res.detail` có contract mismatch; generic không chứng minh server thực trả null. Tách evidence compile contract với response backend chưa biết. Callback không đọc response, cache request snapshot sau success thì không flag mismatch; không tự đoán response object để đổi type.
43
- - Khi wrapper/interceptors nằm ngoài phạm vi context được phép gửi, thiếu support là **thiếu bằng chứng**. Không suy diễn runtime envelope hoặc framework auth từ khai báo return type `any` hay shared convention. Chỉ dùng source thực có trong primary/support; không coi import path là nội dung callee đã được xem.
44
-
45
31
  ## Primary file
46
32
 
47
33
  Additional non-violations:
@@ -1,7 +1,6 @@
1
1
  id: angular/api-service-contract-risk
2
- # v5: trace actual unwrap/raw interceptor/unload transport contracts.
3
- # Prior calibration is not evidence of precision for this changed prompt.
4
- version: 6
2
+ # v3 (ADR-0065 calibration): conf 60→85 (đo 26/26 TP)
3
+ version: 4
5
4
  kind: ai
6
5
  title: "Angular API service/error contract có rủi ro không?"
7
6
  description: |
@@ -2,12 +2,6 @@ Bạn là senior Angular reviewer. Đánh giá Angular review unit dưới đây
2
2
 
3
3
  ## CRITICAL RULES
4
4
 
5
- Framework/contract evidence requirements:
6
-
7
- - Angular computed tracks signal reads transitively through ordinary methods and inherited service methods. Follow the implementation of `service.format()` (including its base class) before claiming it is non-reactive. If it reads a signal, the computed is reactive; if support implementation is missing, state this evidence gap rather than asserting stale countdown. A method returning only a mutable plain field can still be a real stale-derived-state issue.
8
- - Zone.js normally patches FileReader callbacks. Do not assert they run outside NgZone solely because they are FileReader events; require explicit unpatched/zoneless/runOutsideAngular evidence and evaluate signal/ChangeDetectorRef scheduling.
9
-
10
-
11
5
  CRITICAL NON-VIOLATIONS:
12
6
 
13
7
  - NEVER report `form.patchValue(...)`, `form.reset()`, `form.getRawValue()`, or `form.controls.x.value` as an OnPush/change-detection issue by itself.
@@ -1,6 +1,6 @@
1
1
  id: angular/component-state-flow
2
2
  # v4 (ADR-0065 calibration): conf 60→85 (đo 49/49 TP)
3
- version: 5
3
+ version: 4
4
4
  kind: ai
5
5
  title: "Angular component state/change detection flow có rủi ro không?"
6
6
  description: |
@@ -2,12 +2,6 @@ Bạn là senior Angular reviewer. Đánh giá Angular review unit dưới đây
2
2
 
3
3
  ## CRITICAL RULES
4
4
 
5
- Framework/contract evidence requirements:
6
-
7
- - Angular `FormGroupDirective` intercepts a normal `<form [formGroup]>` submit and prevents browser reload even without an `(ngSubmit)` binding. A `type="submit"` button with `(click)` is not proof of default navigation. Report submit loss only with a demonstrated trigger that fails to call the handler, and avoid recommending both click and ngSubmit handlers that duplicate submission.
8
- - An input with `formControlName` is synchronized by its ControlValueAccessor. A custom `(input)` filter may call `setValue` only when normalization changes the text. Do not claim valid keystrokes never reach the control unless the actual accessor/binding is missing or proven broken. A manual input with no form binding still requires explicit synchronization.
9
-
10
-
11
5
  CRITICAL NON-VIOLATIONS:
12
6
 
13
7
  - NEVER report a required-validator issue when the external template renders a reusable error component bound to that control, such as `[control]="form.controls.title"`.
@@ -1,6 +1,6 @@
1
1
  id: angular/reactive-form-flow
2
2
  # v5 (ADR-0065 calibration): conf 60→85 (đo 46/46 TP)
3
- version: 6
3
+ version: 5
4
4
  kind: ai
5
5
  title: "Angular reactive form flow có rủi ro submit/validation không?"
6
6
  description: |
@@ -2,12 +2,6 @@ Bạn là senior Angular reviewer. Đánh giá Angular review unit dưới đây
2
2
 
3
3
  ## CRITICAL RULES
4
4
 
5
- Framework/contract evidence requirements:
6
-
7
- - Angular `@for` and `*ngFor` accept null/undefined collections and render zero items. A nullable iterable alone is not a crash or missing-guard violation. Unguarded nested property access before iteration, such as `nullableOwner.files`, can still be a bug.
8
- - Distinguish a missing optional field from a nullable receiver: `item.name` is safe property access when `item` exists even if `name?: string`; `item?.name` does not make a missing name defined. Require a concrete non-null API requirement or downstream dereference before reporting optional primitive fields as unsafe bindings.
9
-
10
-
11
5
  1. **CHỈ report lỗi có bằng chứng cụ thể** trong primary hoặc support files. Không đoán convention ngoài cluster.
12
6
  2. **`line` BẮT BUỘC trỏ về PRIMARY file**.
13
7
  3. **Confidence `<50` → KHÔNG emit**.
@@ -28,7 +22,7 @@ Framework/contract evidence requirements:
28
22
  - External template trong cluster tham chiếu property/method không tồn tại trong component class.
29
23
  - Template gọi method với số lượng/thứ tự/kiểu tham số rõ ràng không khớp signature.
30
24
  - Template truy cập nested property có thể `undefined` mà không guard (`?.`, `@if`, `*ngIf`) trong khi class khởi tạo nullable/optional.
31
- - Collection chứa phần tử nullable được template dereference mà không guard, hoặc biểu thức lấy collection dereference nullable owner.
25
+ - `*ngFor` hoặc `@for` render collection có thể undefined/null mà không fallback/guard.
32
26
  - Two-way binding trỏ vào object path có thể undefined.
33
27
 
34
28
  ## KHÔNG flag
@@ -1,6 +1,6 @@
1
1
  id: angular/template-contract-risk
2
2
  # v5 (ADR-0065 calibration): conf 60→70 (đo 7/7 TP — mẫu nhỏ, nâng dè dặt)
3
- version: 6
3
+ version: 5
4
4
  kind: ai
5
5
  title: "Angular template/component contract có rủi ro runtime không?"
6
6
  description: |
@@ -33,10 +33,6 @@ Language: {{language}}
33
33
  {{code}}
34
34
  ```
35
35
 
36
- ## TypeScript union và giá trị khởi tạo
37
-
38
- `otpTtl: string | number | undefined = 0` là khai báo hợp lệ: giá trị khởi tạo thuộc union. Không báo kiểu không nhất quán chỉ vì union cho phép `undefined` nhưng khởi tạo bằng số; cũng không yêu cầu đổi mặc định sang `undefined` hoặc thu hẹp type khi API có thể trả nhiều kiểu. Chỉ báo khi có bằng chứng cách sử dụng giá trị gây hiểu nhầm hoặc trái contract; tách nhận xét naming khỏi nhận xét về type.
39
-
40
36
  ## Output yêu cầu
41
37
 
42
38
  Trả về **JSON HỢP LỆ DUY NHẤT** (không markdown fence, không text khác) theo schema:
@@ -5,7 +5,7 @@ id: general/code-clarity
5
5
  # MỘT pattern (`const R = VauthzResource`) lặp ở 27 file; 6 FP là param 1 ký
6
6
  # tự trong callback (`.map(b => b.brand)`). Cả hai đều là quy ước hợp lệ,
7
7
  # prompt v4 miễn tường minh.
8
- version: 5
8
+ version: 4
9
9
  kind: ai
10
10
  title: "Code có rõ ràng và dễ đọc không?"
11
11
  description: |
@@ -1,8 +1,4 @@
1
- import { existsSync, readFileSync } from 'fs';
2
- import { dirname, join, relative, sep, resolve } from 'path';
3
1
  import { asTreeSitterTree } from '@code-sentinel/parsers';
4
- import { globSync } from 'tinyglobby';
5
- import { Project, Node } from 'ts-morph';
6
2
 
7
3
  // builtin-rules/static/angular/button-accessible-name.rule.ts
8
4
  var ACCESSIBLE_NAME_ATTRS = /* @__PURE__ */ new Set([
@@ -40,237 +36,7 @@ function normalizeAttrName(name) {
40
36
  function attributeValue(attr) {
41
37
  const quoted = namedChildOfType(attr, "quoted_attribute_value");
42
38
  const value = quoted ? namedChildOfType(quoted, "attribute_value") : null;
43
- return value?.text ?? namedChildOfType(attr, "attribute_value")?.text ?? "";
44
- }
45
- function provenTailwindStyles(file) {
46
- try {
47
- let root = dirname(file);
48
- while (!existsSync(join(root, "angular.json")) || !existsSync(join(root, "package.json"))) {
49
- const parent = dirname(root);
50
- if (parent === root) return null;
51
- root = parent;
52
- }
53
- const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
54
- const version = pkg.dependencies?.tailwindcss ?? pkg.devDependencies?.tailwindcss;
55
- if (typeof version !== "string" || !/^[~^]?3\./.test(version)) return null;
56
- const configPath = ["tailwind.config.js", "tailwind.config.cjs", "tailwind.config.ts"].map((name) => join(root, name)).find(existsSync);
57
- if (!configPath) return null;
58
- const config = new Project({ useInMemoryFileSystem: true }).createSourceFile(
59
- "config.ts",
60
- readFileSync(configPath, "utf8")
61
- );
62
- const expression = config.getStatements().map((statement) => {
63
- if (Node.isExpressionStatement(statement)) {
64
- const expr = statement.getExpression();
65
- if (Node.isBinaryExpression(expr) && expr.getLeft().getText() === "module.exports")
66
- return expr.getRight();
67
- }
68
- if (Node.isExportAssignment(statement)) return statement.getExpression();
69
- return void 0;
70
- }).find((expression2) => expression2 && Node.isObjectLiteralExpression(expression2));
71
- if (!expression || !Node.isObjectLiteralExpression(expression) || config.getStatements().length !== 1)
72
- return null;
73
- if (expression.getDescendants().some(
74
- (node) => Node.isCallExpression(node) || Node.isNewExpression(node) || Node.isArrowFunction(node) || Node.isFunctionExpression(node) || Node.isGetAccessorDeclaration(node) || Node.isSpreadAssignment(node)
75
- ))
76
- return null;
77
- const allowed = /* @__PURE__ */ new Set(["content", "theme", "plugins"]);
78
- if (expression.getProperties().some((prop) => !Node.isPropertyAssignment(prop) || !allowed.has(prop.getName())))
79
- return null;
80
- const property = (name) => {
81
- const prop = expression.getProperty(name);
82
- return prop && Node.isPropertyAssignment(prop) ? prop.getInitializer() : void 0;
83
- };
84
- const plugins = property("plugins");
85
- if (plugins && (!Node.isArrayLiteralExpression(plugins) || plugins.getElements().length))
86
- return null;
87
- const content = property("content");
88
- if (!content || !Node.isArrayLiteralExpression(content)) return null;
89
- const patterns = content.getElements().map((value) => Node.isStringLiteral(value) ? value.getLiteralText() : null);
90
- if (patterns.some((value) => value === null)) return null;
91
- const template = relative(root, file).split(sep).join("/");
92
- if (!globSync(patterns, { cwd: root, onlyFiles: true }).includes(template))
93
- return null;
94
- const angular = JSON.parse(readFileSync(join(root, "angular.json"), "utf8"));
95
- if (!angular.projects || Object.keys(angular.projects).length !== 1) return null;
96
- const styles = /* @__PURE__ */ new Set();
97
- const collect = (value) => {
98
- if (!value || typeof value !== "object") return;
99
- for (const [key, item] of Object.entries(value)) {
100
- if (key === "styles" && Array.isArray(item)) {
101
- for (const style of item) {
102
- const input = typeof style === "string" ? style : style?.input;
103
- if (typeof input !== "string" || /[{}]/.test(input)) continue;
104
- styles.add(resolve(root, input));
105
- }
106
- } else collect(item);
107
- }
108
- };
109
- collect(angular);
110
- for (const extension of ["css", "scss", "less"]) {
111
- const companion = file.replace(/\.html$/, `.${extension}`);
112
- if (existsSync(companion)) styles.add(companion);
113
- }
114
- const texts = [];
115
- const visited = /* @__PURE__ */ new Set();
116
- const readStyles = (style) => {
117
- if (visited.has(style)) return true;
118
- visited.add(style);
119
- const text = readFileSync(style, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
120
- texts.push(text);
121
- if (/@(?:import|use|forward)\s+url\(/.test(text)) return false;
122
- if (/@(?:import|use|forward)[^;]*['"]\s*,/.test(text)) return false;
123
- for (const match of text.matchAll(/@(?:import|use|forward)\s+(['"])([^'"]+)\1/g)) {
124
- const specifier = match[2];
125
- if (!specifier || specifier.includes("#{")) return false;
126
- const candidate = specifier.startsWith(".") ? resolve(dirname(style), specifier) : resolve(root, "node_modules", specifier.replace(/^~/, ""));
127
- const resolved = [
128
- candidate,
129
- `${candidate}.scss`,
130
- `${candidate}.css`,
131
- `${candidate}.less`
132
- ].find(existsSync);
133
- if (!resolved || !readStyles(resolved)) return false;
134
- }
135
- return true;
136
- };
137
- if (![...styles].every(readStyles)) return null;
138
- if (!texts.some((text) => /@tailwind\s+utilities\s*;/.test(text))) return null;
139
- if (texts.some(
140
- (text) => /\.invisible(?:[^\w-]|$)|(?:^|[;{])\s*visibility\s*:|@apply[^;]*(?:visible|visibility)/m.test(
141
- text
142
- )
143
- ))
144
- return null;
145
- const componentPath = file.replace(/\.html$/, ".ts");
146
- if (existsSync(componentPath) && /\bstyles\s*:/.test(readFileSync(componentPath, "utf8")))
147
- return null;
148
- if (existsSync(componentPath)) {
149
- const component = readFileSync(componentPath, "utf8");
150
- for (const match of component.matchAll(/\bstyleUrls?\s*:\s*(?:\[\s*)?(['"])([^'"]+)\1/g)) {
151
- if (resolve(dirname(componentPath), match[2] ?? "") !== file.replace(/\.html$/, ".scss") && resolve(dirname(componentPath), match[2] ?? "") !== file.replace(/\.html$/, ".css") && resolve(dirname(componentPath), match[2] ?? "") !== file.replace(/\.html$/, ".less"))
152
- return null;
153
- }
154
- if (/\bstyleUrls\s*:\s*\[/.test(component)) return null;
155
- }
156
- return texts;
157
- } catch {
158
- return null;
159
- }
160
- }
161
- function hasProvenHiddenUtility(tag, tailwind) {
162
- if (!tailwind) return false;
163
- let classes = [];
164
- for (const attr of tag.namedChildren) {
165
- if (attr.type !== "attribute") continue;
166
- const name = namedChildOfType(attr, "attribute_name")?.text ?? "";
167
- const prop = normalizeAttrName(name);
168
- if (name.startsWith("[") || name.startsWith("bind-") || prop === "ngclass" || prop === "ngstyle")
169
- return false;
170
- if (prop === "style") return false;
171
- if (prop === "class") {
172
- const value = attributeValue(attr);
173
- if (value.includes("{{")) return false;
174
- classes = value.split(/\s+/);
175
- }
176
- }
177
- if (!classes.includes("invisible")) return false;
178
- if (classes.some((value) => value !== "invisible" && /(?:visible|visibility|\[|!)/.test(value)))
179
- return false;
180
- return true;
181
- }
182
- function visibilityOfTag(tagNode, tailwind = false) {
183
- let uncertain = false;
184
- let hidden = hasProvenHiddenUtility(tagNode, tailwind);
185
- for (const attr of tagNode.namedChildren) {
186
- if (attr.type !== "attribute") continue;
187
- const rawName = namedChildOfType(attr, "attribute_name")?.text ?? "";
188
- const prop = normalizeAttrName(rawName);
189
- const bound = rawName.startsWith("[") || rawName.startsWith("bind-");
190
- const value = attributeValue(attr).trim().toLowerCase();
191
- if (bound && (prop === "hidden" || prop === "aria-hidden" || prop.startsWith("style") || prop.startsWith("class") || prop === "ngclass" || prop === "ngstyle")) {
192
- uncertain = true;
193
- continue;
194
- }
195
- if (!bound && prop === "hidden") hidden = true;
196
- if (!bound && prop === "aria-hidden" && value === "true") hidden = true;
197
- if (!bound && prop === "style") {
198
- if (value.includes("{{")) {
199
- uncertain = true;
200
- continue;
201
- }
202
- const declarations = /* @__PURE__ */ new Map();
203
- for (const declaration of value.split(";")) {
204
- const colon = declaration.indexOf(":");
205
- if (colon < 0) continue;
206
- const name = declaration.slice(0, colon).trim();
207
- const rawValue = declaration.slice(colon + 1).trim();
208
- const important = /\s*!important$/.test(rawValue);
209
- if (declarations.get(name)?.important && !important) continue;
210
- declarations.set(name, { value: rawValue.replace(/\s*!important$/, "").trim(), important });
211
- }
212
- if (declarations.get("display")?.value === "none" || declarations.get("visibility")?.value === "hidden" || declarations.get("visibility")?.value === "collapse")
213
- hidden = true;
214
- }
215
- }
216
- return uncertain ? "uncertain" : hidden ? "hidden" : "visible";
217
- }
218
- function visibilityOfNode(node, tailwind = false) {
219
- let uncertain = false;
220
- let overridesInheritedVisibility = false;
221
- let cur = node;
222
- while (cur) {
223
- if (cur.type === "element") {
224
- const tag = namedChildOfType(cur, "start_tag") ?? namedChildOfType(cur, "self_closing_tag");
225
- if (tag) {
226
- const visibility = visibilityOfTag(tag, tailwind);
227
- const attrs = tag.namedChildren.filter((child) => child.type === "attribute");
228
- const inlineStyle = attrs.find(
229
- (attr) => namedChildOfType(attr, "attribute_name")?.text.toLowerCase() === "style"
230
- );
231
- const style = inlineStyle ? attributeValue(inlineStyle).trim().toLowerCase() : "";
232
- const onlyInheritedHidden = visibility === "hidden" && (hasProvenHiddenUtility(tag, tailwind) || /visibility\s*:\s*(hidden|collapse)/.test(style)) && !/display\s*:\s*none/.test(style) && !attrs.some((attr) => {
233
- const name = namedChildOfType(attr, "attribute_name")?.text.toLowerCase();
234
- return name === "hidden" || name === "aria-hidden" && attributeValue(attr).trim() === "true";
235
- });
236
- if (visibility === "hidden" && !(overridesInheritedVisibility && onlyInheritedHidden)) {
237
- if (onlyInheritedHidden && uncertain) return "uncertain";
238
- return "hidden";
239
- }
240
- uncertain ||= visibility === "uncertain";
241
- if (visibility !== "uncertain" && (/visibility\s*:\s*visible\s*(?:!important)?\s*(?:;|$)/.test(style) || tailwind && attrs.some(
242
- (attr) => namedChildOfType(attr, "attribute_name")?.text === "class" && attributeValue(attr).split(/\s+/).includes("visible")
243
- ))) {
244
- overridesInheritedVisibility = true;
245
- }
246
- }
247
- }
248
- cur = cur.parent;
249
- }
250
- return uncertain ? "uncertain" : "visible";
251
- }
252
- function hasMeaningfulImageAlt(element) {
253
- const tag = namedChildOfType(element, "start_tag") ?? namedChildOfType(element, "self_closing_tag");
254
- if (!tag || namedChildOfType(tag, "tag_name")?.text.toLowerCase() !== "img") return false;
255
- for (const attr of tag.namedChildren) {
256
- if (attr.type !== "attribute") continue;
257
- const rawName = namedChildOfType(attr, "attribute_name")?.text ?? "";
258
- const prop = normalizeAttrName(rawName);
259
- if (prop === "role" && DECORATIVE_ROLES.has(attributeValue(attr).trim().toLowerCase()))
260
- return false;
261
- }
262
- for (const attr of tag.namedChildren) {
263
- if (attr.type !== "attribute") continue;
264
- const rawName = namedChildOfType(attr, "attribute_name")?.text ?? "";
265
- if (normalizeAttrName(rawName) !== "alt") continue;
266
- const value = attributeValue(attr).trim();
267
- if (rawName.startsWith("[") || rawName.startsWith("bind-")) {
268
- const literal = /^(['"])([^'"\n]+)\1$/.exec(value);
269
- return Boolean(literal?.[2]?.trim());
270
- }
271
- return value.length > 0 && !value.includes("{{");
272
- }
273
- return false;
39
+ return value?.text ?? "";
274
40
  }
275
41
  function hasAccessibleAttr(tagNode) {
276
42
  for (let i = 0; i < tagNode.namedChildCount; i++) {
@@ -314,22 +80,8 @@ function isInsideIconTag(node, rootElement) {
314
80
  }
315
81
  return false;
316
82
  }
317
- function hasUncertainDescendantVisibility(node, root) {
318
- let current = node;
319
- while (current && current.id !== root.id) {
320
- if (current.type === "element") {
321
- const tag = namedChildOfType(current, "start_tag") ?? namedChildOfType(current, "self_closing_tag");
322
- if (tag && visibilityOfTag(tag) === "uncertain") return true;
323
- }
324
- current = current.parent;
325
- }
326
- return false;
327
- }
328
- function hasMeaningfulTextOrDirective(elementNode, tailwind = false) {
83
+ function hasMeaningfulTextOrDirective(elementNode) {
329
84
  for (const node of walkNodes(elementNode)) {
330
- if (visibilityOfNode(node, tailwind) === "hidden" || hasUncertainDescendantVisibility(node, elementNode))
331
- continue;
332
- if (node.type === "element" && hasMeaningfulImageAlt(node)) return true;
333
85
  if (node.type === "text") {
334
86
  const text = node.text.trim();
335
87
  if (text.length > 0 && !isInsideIconTag(node, elementNode)) return true;
@@ -348,7 +100,7 @@ function hasMeaningfulTextOrDirective(elementNode, tailwind = false) {
348
100
  }
349
101
  var rule = {
350
102
  id: "angular/button-accessible-name",
351
- version: 3,
103
+ version: 1,
352
104
  kind: "static-ts",
353
105
  title: "`<button>` v\xE0 `<a>` ph\u1EA3i c\xF3 accessible name (text ho\u1EB7c `aria-label`)",
354
106
  description: "N\xFAt b\u1EA5m (`<button>`) v\xE0 li\xEAn k\u1EBFt (`<a>`) thi\u1EBFu accessible name vi ph\u1EA1m WCAG 4.1.2 / 2.4.4. N\u1EBFu n\xFAt ch\u1EC9 ch\u1EE9a icon (nh\u01B0 `<mat-icon>`, `<i>`, `<svg>`), h\xE3y th\xEAm thu\u1ED9c t\xEDnh `aria-label` ho\u1EB7c text \u1EA9n (`cdk-visually-hidden`) \u0111\u1EC3 ng\u01B0\u1EDDi d\xF9ng screen-reader hi\u1EC3u \u0111\u01B0\u1EE3c ch\u1EE9c n\u0103ng.",
@@ -357,12 +109,10 @@ var rule = {
357
109
  languages: ["html"],
358
110
  scope: "angular",
359
111
  requires: "syntactic",
360
- usesProjectContext: true,
361
112
  baseConfidence: 85,
362
113
  check(ctx) {
363
114
  const tree = asTreeSitterTree(ctx.parsed);
364
115
  const findings = [];
365
- const tailwind = /\binvisible\b/.test(ctx.file.content) && provenTailwindStyles(ctx.file.absolutePath) !== null;
366
116
  for (const node of walkNodes(tree.rootNode)) {
367
117
  if (node.type !== "element") continue;
368
118
  const startTag = namedChildOfType(node, "start_tag") ?? namedChildOfType(node, "self_closing_tag");
@@ -372,16 +122,10 @@ var rule = {
372
122
  const tag = tagNameNode.text.toLowerCase();
373
123
  if (tag !== "button" && tag !== "a") continue;
374
124
  if (tag === "a" && !hasInteractiveLinkAttr(startTag)) continue;
375
- const visibility = visibilityOfNode(node, tailwind);
376
- if (visibility === "hidden") continue;
377
125
  if (hasAccessibleAttr(startTag)) continue;
378
- if (hasMeaningfulTextOrDirective(node, tailwind)) continue;
379
- const unresolvedHiddenClass = !tailwind && startTag.namedChildren.some(
380
- (attr) => attr.type === "attribute" && namedChildOfType(attr, "attribute_name")?.text === "class" && attributeValue(attr).split(/\s+/).includes("invisible")
381
- );
126
+ if (hasMeaningfulTextOrDirective(node)) continue;
382
127
  findings.push({
383
- confidence: visibility === "uncertain" || [...walkNodes(node)].some((child) => hasUncertainDescendantVisibility(child, node)) ? 70 : 85,
384
- message: `<${tag}>${unresolvedHiddenClass ? " c\xF3 utility visibility ch\u01B0a ki\u1EC3m ch\u1EE9ng CSS/config; c\u1EA7n review khi control hi\u1EC7n: " : visibility === "uncertain" ? " c\xF3 visibility \u0111\u1ED9ng; c\u1EA7n ki\u1EC3m ch\u1EE9ng khi hi\u1EC7n: " : " "}thi\u1EBFu accessible name${unresolvedHiddenClass || visibility === "uncertain" ? " n\u1EBFu control xu\u1EA5t hi\u1EC7n." : " \u2014 screen-reader kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c m\xF4 t\u1EA3 h\xE0nh \u0111\u1ED9ng (l\u1ED7i WCAG 4.1.2)."} Th\xEAm text b\xEAn trong n\xFAt ho\u1EB7c khai b\xE1o thu\u1ED9c t\xEDnh \`aria-label="m\xF4 t\u1EA3"\`.`,
128
+ message: `<${tag}> thi\u1EBFu accessible name \u2014 screen-reader kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c m\xF4 t\u1EA3 h\xE0nh \u0111\u1ED9ng (l\u1ED7i WCAG 4.1.2). Th\xEAm text b\xEAn trong n\xFAt ho\u1EB7c khai b\xE1o thu\u1ED9c t\xEDnh \`aria-label="m\xF4 t\u1EA3"\`.`,
385
129
  file: ctx.file.path,
386
130
  range: {
387
131
  line: startTag.startPosition.row + 1,
@@ -203,24 +203,7 @@ var assignmentTargetName = (subscribeCall) => {
203
203
  }
204
204
  return void 0;
205
205
  };
206
- var isReturnedObservableTeardown = (subscribeCall) => {
207
- const returned = subscribeCall.getParent();
208
- if (!returned || !Node.isReturnStatement(returned)) return false;
209
- const creator = subscribeCall.getFirstAncestor(
210
- (node) => Node.isArrowFunction(node) || Node.isFunctionExpression(node)
211
- );
212
- const observable = creator?.getParent();
213
- if (!observable || !Node.isNewExpression(observable)) return false;
214
- const observableConstructor = observable.getExpression();
215
- if (!Node.isIdentifier(observableConstructor)) return false;
216
- return observableConstructor.getSymbol()?.getDeclarations().some((declaration) => {
217
- if (!Node.isImportSpecifier(declaration) || declaration.getName() !== "Observable")
218
- return false;
219
- return declaration.getFirstAncestor(Node.isImportDeclaration)?.getModuleSpecifierValue() === "rxjs";
220
- }) ?? false;
221
- };
222
206
  var isManagedSubscription = (subscribeCall, unsubscribedNames) => {
223
- if (isReturnedObservableTeardown(subscribeCall)) return true;
224
207
  const parent = subscribeCall.getParent();
225
208
  if (parent !== void 0 && Node.isCallExpression(parent)) {
226
209
  const callee = parent.getExpression();
@@ -283,7 +266,7 @@ var findingFor = (nameNode, file, kind) => {
283
266
  };
284
267
  var rule = {
285
268
  id: "angular/no-leaky-subscription",
286
- version: 7,
269
+ version: 6,
287
270
  kind: "static-ts",
288
271
  title: "Subscription ph\u1EA3i \u0111\u01B0\u1EE3c h\u1EE7y (takeUntil / unsubscribe / Subscription.add / async pipe)",
289
272
  description: "v6: ownership-aware advice; member streams have advisory severity until retention is established. Service names and forkJoin do not prove finite lifetime. Teardown before a flattening/resubscription operator does not cover the resulting stream. Application commands are not auto-suppressed.",
@@ -30,18 +30,18 @@ var hasSpread = (obj) => obj.getProperties().some((prop) => Node.isSpreadAssignm
30
30
  var rule = {
31
31
  id: "angular/onpush-required",
32
32
  // v3 (ADR-0065 calibration): conf 70→95 (đo 122/122 TP)
33
- version: 4,
33
+ version: 3,
34
34
  kind: "static-ts",
35
35
  title: "@Component n\xEAn d\xF9ng ChangeDetectionStrategy.OnPush",
36
- description: "OnPush gi\u1EA3m s\u1ED1 l\u1EA7n change detection ch\u1EA1y, perf-critical cho app l\u1EDBn. Khuy\u1EBFn ngh\u1ECB \xE1p d\u1EE5ng cho h\u1EA7u h\u1EBFt Component; m\u1ED9t s\u1ED1 Component v\u1EABn h\u1EE3p l\u1EC7 khi d\xF9ng Default \u2192 \u0111\xE2y l\xE0 khuy\u1EBFn ngh\u1ECB perf (warning; confidence 95 ch\u1EC9 x\xE1c nh\u1EADn thi\u1EBFu strategy), kh\xF4ng ph\u1EA3i bug ch\u1EAFc ch\u1EAFn. B\u1ECF qua Component c\xF3 config spread (kh\xF4ng ch\u1EE9ng minh \u0111\u01B0\u1EE3c).",
36
+ description: "OnPush gi\u1EA3m s\u1ED1 l\u1EA7n change detection ch\u1EA1y, perf-critical cho app l\u1EDBn. Khuy\u1EBFn ngh\u1ECB \xE1p d\u1EE5ng cho h\u1EA7u h\u1EBFt Component; m\u1ED9t s\u1ED1 Component v\u1EABn h\u1EE3p l\u1EC7 khi d\xF9ng Default \u2192 \u0111\xE2y l\xE0 khuy\u1EBFn ngh\u1ECB perf (warning conf 70), kh\xF4ng ph\u1EA3i bug ch\u1EAFc ch\u1EAFn. B\u1ECF qua Component c\xF3 config spread (kh\xF4ng ch\u1EE9ng minh \u0111\u01B0\u1EE3c).",
37
37
  severity: "warning",
38
38
  category: "performance",
39
39
  languages: ["typescript"],
40
40
  scope: "angular",
41
41
  requires: "semantic-ts",
42
- // Confidence 95 describes deterministic missing-strategy detection.
43
- // Whether OnPush is safe or improves performance remains a separate judgment;
44
- // some Default components are valid and need their render triggers reviewed.
42
+ // A4 calibration: 85→70. Detection is deterministic, but "should be OnPush"
43
+ // is a judgment — some Default components are intentional. 70 = "worth a look,
44
+ // not certain", so `--min-confidence` can filter it out of a strict gate.
45
45
  baseConfidence: 95,
46
46
  check(ctx) {
47
47
  const sf = asTsMorphSourceFile(ctx.parsed);
@@ -56,10 +56,10 @@ var rule = {
56
56
  const className = cls.getName() ?? "<anonymous>";
57
57
  const { line, column } = sf.getLineAndColumnAtPos(decorator.getStart());
58
58
  findings.push({
59
- message: `Component "${className}" ch\u01B0a khai b\xE1o \`changeDetection: ChangeDetectionStrategy.OnPush\`; \u0111\xE2y l\xE0 khuy\u1EBFn ngh\u1ECB convention/performance, kh\xF4ng ch\u1EE9ng minh l\u1ED7i ch\u1EE9c n\u0103ng. Ki\u1EC3m ch\u1EE9ng trigger c\u1EADp nh\u1EADt view tr\u01B0\u1EDBc khi \u0111\u1ED5i strategy.`,
59
+ message: `Component "${className}" ch\u01B0a khai b\xE1o \`changeDetection: ChangeDetectionStrategy.OnPush\`.`,
60
60
  file: ctx.file.path,
61
61
  range: { line, column },
62
- suggestion: "Ki\u1EC3m ch\u1EE9ng input/reference, signal/async pipe, form v\xE0 callback b\u1EA5t \u0111\u1ED3ng b\u1ED9; ch\u1EC9 th\xEAm OnPush khi view c\xF3 trigger c\u1EADp nh\u1EADt \u0111\xFAng (markForCheck khi c\u1EA7n). Default c\xF3 th\u1EC3 l\xE0 l\u1EF1a ch\u1ECDn h\u1EE3p l\u1EC7."
62
+ suggestion: "Th\xEAm `changeDetection: ChangeDetectionStrategy.OnPush` v\xE0o @Component v\xE0 import t\u1EEB @angular/core."
63
63
  });
64
64
  }
65
65
  return findings;
@@ -51,34 +51,12 @@ function rootIdentifier(expr) {
51
51
  const m = /[A-Za-z_$][\w$]*/.exec(expr);
52
52
  return m ? m[0] : null;
53
53
  }
54
- function completeMethodCall(expr) {
55
- const value = expr.trim();
56
- const match = /^([A-Za-z_$][\w$]*)\s*\(/.exec(value);
57
- if (!match?.[1]) return null;
58
- let depth = 1;
59
- let quote = "";
60
- for (let i = match[0].length; i < value.length; i++) {
61
- const c = value[i];
62
- if (quote) {
63
- if (c === "\\") {
64
- i++;
65
- continue;
66
- }
67
- if (c === quote) quote = "";
68
- } else if (c === "'" || c === '"') quote = c;
69
- else if (c === "`") return null;
70
- else if (c === "(") depth++;
71
- else if (c === ")" && --depth === 0) return i === value.length - 1 ? match[1] : null;
72
- }
73
- return null;
74
- }
75
54
  var rule = {
76
55
  id: "angular/template-dom-xss",
77
56
  // v5 corrects native Angular HTML sanitizer semantics; old calibration is not reused as proof.
78
- version: 7,
57
+ version: 5,
79
58
  kind: "static-ts",
80
59
  usesTemplateComponent: true,
81
- usesProjectContext: true,
82
60
  title: "Binding nguy hi\u1EC3m trong template Angular (DOM XSS)",
83
61
  description: "Ki\u1EC3m tra bypass sanitizer v\xE0 k\u1EBFt qu\u1EA3 pipe/call ch\u01B0a x\xE1c minh trong binding HTML. Angular t\u1EF1 sanitize chu\u1ED7i \u1EDF binding HTML native; d\u1EEF li\u1EC7u route/API \u0111\u01A1n thu\u1EA7n kh\xF4ng ch\u1EE9ng minh XSS. Resource URL v\xE0 bypass t\u1EEB b\xEAn ngo\xE0i c\u1EA7n ki\u1EC3m tra ngu\u1ED3n/allowlist; kh\xF4ng tin pipe ch\u1EC9 theo t\xEAn.",
84
62
  severity: "warning",
@@ -105,9 +83,6 @@ var rule = {
105
83
  if (isHtmlSink && PURE_STRING_LITERAL.test(value)) continue;
106
84
  const hasPipe = HAS_PIPE.test(value);
107
85
  const hasCall = /[\w$)]\s*\(/.test(value);
108
- const pipeApplication = /^\s*[\w$.]+\s*\|\s*([\w$]+)(?:\s*:\s*[\w$.]+)*\s*$/.exec(value);
109
- if (isHtmlSink && pipeApplication?.[1] && link?.primitiveStringPipes?.has(pipeApplication[1]))
110
- continue;
111
86
  let origin = "unknown";
112
87
  if (link) {
113
88
  const root = rootIdentifier(value);
@@ -115,8 +90,6 @@ var rule = {
115
90
  }
116
91
  const externalBypass = origin === "external-bypass";
117
92
  if (origin === "sanitizer-trusted" && !hasPipe && !hasCall) continue;
118
- if (isHtmlSink && link?.sanitizedHtmlMethods?.has(completeMethodCall(value) ?? "") && !hasPipe)
119
- continue;
120
93
  if (isHtmlSink && !externalBypass && !hasPipe && !hasCall) continue;
121
94
  const where = `\`${nameNode.text}\` (${value})`;
122
95
  const message = externalBypass ? `\u26A0 Bypass sanitizer tr\xEAn d\u1EEF li\u1EC7u T\u1EEA B\xCAN NGO\xC0I component: ${where} trong \`${link?.componentPath}\`. Ki\u1EC3m tra ngu\u1ED3n d\u1EEF li\u1EC7u v\xE0 validation tr\u01B0\u1EDBc bypass; ch\u01B0a ch\u1EE9ng minh attacker control.` : isHtmlSink ? `\u26A0 Binding HTML d\xF9ng pipe/call ch\u01B0a x\xE1c minh: ${where}. Pipe ho\u1EB7c method c\xF3 th\u1EC3 tr\u1EA3 SafeHtml v\xE0 t\u1EAFt sanitizer; t\xEAn safe/sanitize kh\xF4ng ch\u1EE9ng minh an to\xE0n.` : `\u26A0 Binding resource URL c\u1EA7n ki\u1EC3m tra: ${where} tr\xEAn <${tag}>. Angular t\u1EEB ch\u1ED1i chu\u1ED7i kh\xF4ng trusted trong context n\xE0y; kh\xF4ng coi binding \u0111\u01A1n thu\u1EA7n l\xE0 XSS \u0111\xE3 x\xE1c nh\u1EADn.`;
@@ -15,7 +15,7 @@ var cyclesForGraph = (graph) => {
15
15
  var formatCycle = (paths) => paths.join(" -> ");
16
16
  var rule = {
17
17
  id: "general/no-circular-import",
18
- version: 5,
18
+ version: 4,
19
19
  kind: "static-ts",
20
20
  title: "Kh\xF4ng t\u1EA1o v\xF2ng import gi\u1EEFa c\xE1c file",
21
21
  description: "V\xF2ng import l\xE0m module kh\u1EDFi t\u1EA1o kh\xF4ng \u1ED5n \u0111\u1ECBnh, d\u1EC5 sinh undefined runtime v\xE0 che gi\u1EA5u coupling gi\u1EEFa c\xE1c layer.",
@@ -36,7 +36,7 @@ var exportedNamesFor = (graph, path) => {
36
36
  };
37
37
  var rule = {
38
38
  id: "general/no-unresolved-import-symbol",
39
- version: 9,
39
+ version: 8,
40
40
  kind: "static-ts",
41
41
  title: "Khong import/re-export symbol khong duoc export",
42
42
  description: "Named import/re-export noi bo phai tro toi symbol ma target file that su export; rule nay bo qua default, namespace, side-effect import va wildcard re-export de tranh false positive.",
package/dist/index.d.ts CHANGED
@@ -21,13 +21,7 @@ interface CliBuildMetadata {
21
21
  readonly buildTimestamp: string;
22
22
  readonly configSchemaRange: string;
23
23
  }
24
- /**
25
- * Values are embedded by tsup, with deterministic safe defaults for source tests.
26
- * In the review image (Dockerfile.cli) CS_BUILD_GIT_SHA / CS_BUILD_TIMESTAMP are set only right before the
27
- * build step, so a new commit does not invalidate the cached dependency install.
28
- * The same commit is the image tag on pt2 workloads (`code-sentinel-review:<sha>@sha256:…`), which is what the
29
- * Argo CD Telegram notification links to. A change here rebuilds only the review image (servicePackage).
30
- */
24
+ /** Values are embedded by tsup, with deterministic safe defaults for source tests. */
31
25
  declare const getCliBuildMetadata: (version: string) => CliBuildMetadata;
32
26
 
33
27
  interface StoredCredential {
@@ -151,7 +145,7 @@ declare class LinuxSecretServiceStore implements ISecretStore {
151
145
  }
152
146
  /** Byte-oriented API stores credential JSON as UTF-8. */
153
147
  interface WindowsSecretEntry {
154
- getSecret(): Promise<Uint8Array | null | undefined>;
148
+ getSecret(): Promise<Uint8Array | undefined>;
155
149
  setSecret(secret: Uint8Array): Promise<void>;
156
150
  deleteCredential(): Promise<boolean>;
157
151
  }