canicode 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -269
- package/dist/cli/index.js +61 -52
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +62 -53
- package/dist/mcp/server.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, writeFile, appendFile } from 'fs/promises';
|
|
|
3
3
|
import { basename, resolve, dirname } from 'path';
|
|
4
4
|
import { existsSync, mkdirSync } from 'fs';
|
|
5
5
|
|
|
6
|
-
// src/contracts/severity.ts
|
|
6
|
+
// src/core/contracts/severity.ts
|
|
7
7
|
var SeveritySchema = z.enum([
|
|
8
8
|
"blocking",
|
|
9
9
|
"risk",
|
|
@@ -200,7 +200,7 @@ var ReportSchema = z.object({
|
|
|
200
200
|
})
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
// src/rules/rule-config.ts
|
|
203
|
+
// src/core/rules/rule-config.ts
|
|
204
204
|
var RULE_CONFIGS = {
|
|
205
205
|
// ============================================
|
|
206
206
|
// Layout (11 rules)
|
|
@@ -495,7 +495,7 @@ function getRuleOption(ruleId, optionKey, defaultValue) {
|
|
|
495
495
|
return value ?? defaultValue;
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
// src/rules/rule-registry.ts
|
|
498
|
+
// src/core/rules/rule-registry.ts
|
|
499
499
|
var RuleRegistry = class {
|
|
500
500
|
rules = /* @__PURE__ */ new Map();
|
|
501
501
|
/**
|
|
@@ -556,7 +556,7 @@ function defineRule(rule) {
|
|
|
556
556
|
return rule;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
// src/core/rule-engine.ts
|
|
559
|
+
// src/core/engine/rule-engine.ts
|
|
560
560
|
function calculateMaxDepth(node, currentDepth = 0) {
|
|
561
561
|
if (!node.children || node.children.length === 0) {
|
|
562
562
|
return currentDepth;
|
|
@@ -729,7 +729,7 @@ function analyzeFile(file, options) {
|
|
|
729
729
|
return engine.analyze(file);
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
// src/core/scoring.ts
|
|
732
|
+
// src/core/engine/scoring.ts
|
|
733
733
|
var SEVERITY_DENSITY_WEIGHT = {
|
|
734
734
|
blocking: 3,
|
|
735
735
|
risk: 2,
|
|
@@ -915,13 +915,13 @@ function getSeverityLabel(severity) {
|
|
|
915
915
|
return labels[severity];
|
|
916
916
|
}
|
|
917
917
|
|
|
918
|
-
// src/rules/excluded-names.ts
|
|
918
|
+
// src/core/rules/excluded-names.ts
|
|
919
919
|
var EXCLUDED_NAME_PATTERN = /(badge|close|dismiss|overlay|float|fab|dot|indicator|corner|decoration|tag|status|notification|icon|ico|image|asset|filter|dim|dimmed|bg|background|logo|avatar|divider|separator|nav|navigation|gnb|header|footer|sidebar|toolbar|modal|dialog|popup|toast|tooltip|dropdown|menu|sticky|spinner|loader|cursor|cta|chatbot|thumb|thumbnail|tabbar|tab-bar|statusbar|status-bar)/i;
|
|
920
920
|
function isExcludedName(name) {
|
|
921
921
|
return EXCLUDED_NAME_PATTERN.test(name);
|
|
922
922
|
}
|
|
923
923
|
|
|
924
|
-
// src/rules/layout/index.ts
|
|
924
|
+
// src/core/rules/layout/index.ts
|
|
925
925
|
function isContainerNode(node) {
|
|
926
926
|
return node.type === "FRAME" || node.type === "GROUP" || node.type === "COMPONENT";
|
|
927
927
|
}
|
|
@@ -1208,7 +1208,7 @@ var inconsistentSiblingLayoutDirection = defineRule({
|
|
|
1208
1208
|
check: inconsistentSiblingLayoutDirectionCheck
|
|
1209
1209
|
});
|
|
1210
1210
|
|
|
1211
|
-
// src/rules/token/index.ts
|
|
1211
|
+
// src/core/rules/token/index.ts
|
|
1212
1212
|
function hasStyleReference(node, styleType) {
|
|
1213
1213
|
return node.styles !== void 0 && styleType in node.styles;
|
|
1214
1214
|
}
|
|
@@ -1412,7 +1412,7 @@ var multipleFillColors = defineRule({
|
|
|
1412
1412
|
check: multipleFillColorsCheck
|
|
1413
1413
|
});
|
|
1414
1414
|
|
|
1415
|
-
// src/rules/component/index.ts
|
|
1415
|
+
// src/core/rules/component/index.ts
|
|
1416
1416
|
function isComponentInstance(node) {
|
|
1417
1417
|
return node.type === "INSTANCE";
|
|
1418
1418
|
}
|
|
@@ -1586,7 +1586,7 @@ var singleUseComponent = defineRule({
|
|
|
1586
1586
|
check: singleUseComponentCheck
|
|
1587
1587
|
});
|
|
1588
1588
|
|
|
1589
|
-
// src/rules/naming/index.ts
|
|
1589
|
+
// src/core/rules/naming/index.ts
|
|
1590
1590
|
var DEFAULT_NAME_PATTERNS = [
|
|
1591
1591
|
/^Frame\s*\d*$/i,
|
|
1592
1592
|
/^Group\s*\d*$/i,
|
|
@@ -1771,7 +1771,7 @@ var tooLongName = defineRule({
|
|
|
1771
1771
|
check: tooLongNameCheck
|
|
1772
1772
|
});
|
|
1773
1773
|
|
|
1774
|
-
// src/rules/ai-readability/index.ts
|
|
1774
|
+
// src/core/rules/ai-readability/index.ts
|
|
1775
1775
|
function hasAutoLayout2(node) {
|
|
1776
1776
|
return node.layoutMode !== void 0 && node.layoutMode !== "NONE";
|
|
1777
1777
|
}
|
|
@@ -1948,7 +1948,7 @@ var emptyFrame = defineRule({
|
|
|
1948
1948
|
check: emptyFrameCheck
|
|
1949
1949
|
});
|
|
1950
1950
|
|
|
1951
|
-
// src/rules/handoff-risk/index.ts
|
|
1951
|
+
// src/core/rules/handoff-risk/index.ts
|
|
1952
1952
|
function hasAutoLayout3(node) {
|
|
1953
1953
|
return node.layoutMode !== void 0 && node.layoutMode !== "NONE";
|
|
1954
1954
|
}
|
|
@@ -2128,7 +2128,7 @@ function buildFigmaDeepLink(fileKey, nodeId) {
|
|
|
2128
2128
|
return `https://www.figma.com/design/${fileKey}?node-id=${encodeURIComponent(nodeId)}`;
|
|
2129
2129
|
}
|
|
2130
2130
|
|
|
2131
|
-
// src/adapters/figma-client.ts
|
|
2131
|
+
// src/core/adapters/figma-client.ts
|
|
2132
2132
|
var FIGMA_API_BASE = "https://api.figma.com/v1";
|
|
2133
2133
|
var FigmaClient = class _FigmaClient {
|
|
2134
2134
|
token;
|
|
@@ -2236,7 +2236,7 @@ var FigmaClientError = class extends Error {
|
|
|
2236
2236
|
}
|
|
2237
2237
|
};
|
|
2238
2238
|
|
|
2239
|
-
// src/adapters/figma-transformer.ts
|
|
2239
|
+
// src/core/adapters/figma-transformer.ts
|
|
2240
2240
|
function transformFigmaResponse(fileKey, response) {
|
|
2241
2241
|
return {
|
|
2242
2242
|
fileKey,
|
|
@@ -2372,7 +2372,7 @@ var FigmaFileLoadError = class extends Error {
|
|
|
2372
2372
|
}
|
|
2373
2373
|
};
|
|
2374
2374
|
|
|
2375
|
-
// src/adapters/figma-mcp-adapter.ts
|
|
2375
|
+
// src/core/adapters/figma-mcp-adapter.ts
|
|
2376
2376
|
var TAG_TYPE_MAP = {
|
|
2377
2377
|
canvas: "CANVAS",
|
|
2378
2378
|
frame: "FRAME",
|
|
@@ -3144,7 +3144,7 @@ function renderApplicationGuide(adjustments) {
|
|
|
3144
3144
|
lines.push("To apply these calibration results:");
|
|
3145
3145
|
lines.push("");
|
|
3146
3146
|
lines.push("1. Review each adjustment proposal above");
|
|
3147
|
-
lines.push("2. Edit `src/rules/rule-config.ts` to update scores and severities");
|
|
3147
|
+
lines.push("2. Edit `src/core/rules/rule-config.ts` to update scores and severities");
|
|
3148
3148
|
lines.push("3. Run `pnpm test:run` to verify no tests break");
|
|
3149
3149
|
lines.push("4. Re-run calibration to confirm improvements");
|
|
3150
3150
|
lines.push("");
|