@bovinphang/craft-common 0.0.0-stage → 1.0.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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/content/catalog.d.ts +4 -0
  4. package/dist/content/resources.d.ts +2 -0
  5. package/dist/content/types.d.ts +21 -0
  6. package/dist/index.d.ts +7 -0
  7. package/dist/index.js +668 -0
  8. package/dist/install/identity.d.ts +5 -0
  9. package/dist/install/planner.d.ts +6 -0
  10. package/dist/install/transaction.d.ts +7 -0
  11. package/dist/install/types.d.ts +44 -0
  12. package/docs/consuming-common.md +33 -0
  13. package/localized/zh-CN/methods/debug.md +13 -0
  14. package/localized/zh-CN/methods/doc-sync.md +12 -0
  15. package/localized/zh-CN/methods/refactoring.md +16 -0
  16. package/localized/zh-CN/methods/source-driven-development.md +19 -0
  17. package/localized/zh-CN/methods/tdd.md +13 -0
  18. package/localized/zh-CN/skills/cc-debug-methodology/SKILL.md +8 -0
  19. package/localized/zh-CN/skills/cc-debug-methodology/references/method.md +13 -0
  20. package/localized/zh-CN/skills/cc-doc-sync-core/SKILL.md +8 -0
  21. package/localized/zh-CN/skills/cc-doc-sync-core/references/method.md +12 -0
  22. package/localized/zh-CN/skills/cc-drawio-studio/SKILL.md +73 -0
  23. package/localized/zh-CN/skills/cc-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  24. package/localized/zh-CN/skills/cc-drawio-studio/data/brand-icons.json +878 -0
  25. package/localized/zh-CN/skills/cc-drawio-studio/data/shape-index.json +83570 -0
  26. package/localized/zh-CN/skills/cc-drawio-studio/references/data-residency.md +27 -0
  27. package/localized/zh-CN/skills/cc-drawio-studio/references/diagram-patterns.md +60 -0
  28. package/localized/zh-CN/skills/cc-drawio-studio/references/flowchart-quality.md +49 -0
  29. package/localized/zh-CN/skills/cc-drawio-studio/references/layout-and-export.md +72 -0
  30. package/localized/zh-CN/skills/cc-drawio-studio/references/troubleshooting.md +29 -0
  31. package/localized/zh-CN/skills/cc-drawio-studio/references/xml-and-mermaid.md +58 -0
  32. package/localized/zh-CN/skills/cc-drawio-studio/scripts/brand-symbols.mjs +99 -0
  33. package/localized/zh-CN/skills/cc-drawio-studio/scripts/diagram-lint.mjs +205 -0
  34. package/localized/zh-CN/skills/cc-drawio-studio/scripts/diagram-url.mjs +102 -0
  35. package/localized/zh-CN/skills/cc-drawio-studio/scripts/drawio-export.mjs +134 -0
  36. package/localized/zh-CN/skills/cc-drawio-studio/scripts/layout-graph.mjs +107 -0
  37. package/localized/zh-CN/skills/cc-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  38. package/localized/zh-CN/skills/cc-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  39. package/localized/zh-CN/skills/cc-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  40. package/localized/zh-CN/skills/cc-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  41. package/localized/zh-CN/skills/cc-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  42. package/localized/zh-CN/skills/cc-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  43. package/localized/zh-CN/skills/cc-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  44. package/localized/zh-CN/skills/cc-drawio-studio/scripts/shape-query.mjs +121 -0
  45. package/localized/zh-CN/skills/cc-drawio-studio/scripts/studio-core.mjs +139 -0
  46. package/localized/zh-CN/skills/cc-drawio-studio/styles/built-in/corporate.json +49 -0
  47. package/localized/zh-CN/skills/cc-drawio-studio/styles/built-in/default.json +49 -0
  48. package/localized/zh-CN/skills/cc-drawio-studio/styles/built-in/handdrawn.json +49 -0
  49. package/localized/zh-CN/skills/cc-drawio-studio/styles/schema.json +112 -0
  50. package/localized/zh-CN/skills/cc-refactoring-core/SKILL.md +8 -0
  51. package/localized/zh-CN/skills/cc-refactoring-core/references/method.md +16 -0
  52. package/localized/zh-CN/skills/cc-source-driven-development/SKILL.md +8 -0
  53. package/localized/zh-CN/skills/cc-source-driven-development/references/method.md +19 -0
  54. package/localized/zh-CN/skills/cc-tdd-methodology/SKILL.md +8 -0
  55. package/localized/zh-CN/skills/cc-tdd-methodology/references/method.md +13 -0
  56. package/localized/zh-CN/skills/cc-technical-diagrams/SKILL.md +34 -0
  57. package/localized/zh-CN/skills/cc-technical-diagrams/assets/interactive-diagram.html +371 -0
  58. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/README.md +14 -0
  59. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/architecture.json +121 -0
  60. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/invalid-explicit.json +41 -0
  61. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/sequence.json +53 -0
  62. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/sequence.mmd +21 -0
  63. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/workflow.json +98 -0
  64. package/localized/zh-CN/skills/cc-technical-diagrams/assets/quality-examples/workflow.mmd +7 -0
  65. package/localized/zh-CN/skills/cc-technical-diagrams/references/diagram-workflows.md +81 -0
  66. package/localized/zh-CN/skills/cc-technical-diagrams/references/html-technical-diagrams.md +243 -0
  67. package/localized/zh-CN/skills/cc-technical-diagrams/references/png-qa-autofix.md +37 -0
  68. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/diagram-browser.mjs +153 -0
  69. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/diagram-layout.mjs +176 -0
  70. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/export-diagram.mjs +332 -0
  71. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/interactive-diagram-server.mjs +654 -0
  72. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/mermaid-render.mjs +64 -0
  73. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/png-qa.mjs +462 -0
  74. package/localized/zh-CN/skills/cc-technical-diagrams/scripts/tech-diagram-render.mjs +1537 -0
  75. package/localized/zh-CN/skills/eval_queries.json +160 -0
  76. package/localized/zh-CN/skills/metadata.json +223 -0
  77. package/localized/zh-CN/skills/relations.json +53 -0
  78. package/methods/debug.md +13 -0
  79. package/methods/doc-sync.md +12 -0
  80. package/methods/refactoring.md +16 -0
  81. package/methods/source-driven-development.md +19 -0
  82. package/methods/tdd.md +13 -0
  83. package/package.json +51 -4
  84. package/skills/cc-debug-methodology/SKILL.md +8 -0
  85. package/skills/cc-debug-methodology/references/method.md +13 -0
  86. package/skills/cc-doc-sync-core/SKILL.md +8 -0
  87. package/skills/cc-doc-sync-core/references/method.md +12 -0
  88. package/skills/cc-drawio-studio/SKILL.md +73 -0
  89. package/skills/cc-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  90. package/skills/cc-drawio-studio/data/brand-icons.json +878 -0
  91. package/skills/cc-drawio-studio/data/shape-index.json +83570 -0
  92. package/skills/cc-drawio-studio/references/data-residency.md +27 -0
  93. package/skills/cc-drawio-studio/references/diagram-patterns.md +60 -0
  94. package/skills/cc-drawio-studio/references/flowchart-quality.md +49 -0
  95. package/skills/cc-drawio-studio/references/layout-and-export.md +72 -0
  96. package/skills/cc-drawio-studio/references/troubleshooting.md +29 -0
  97. package/skills/cc-drawio-studio/references/xml-and-mermaid.md +58 -0
  98. package/skills/cc-drawio-studio/scripts/brand-symbols.mjs +99 -0
  99. package/skills/cc-drawio-studio/scripts/diagram-lint.mjs +205 -0
  100. package/skills/cc-drawio-studio/scripts/diagram-url.mjs +102 -0
  101. package/skills/cc-drawio-studio/scripts/drawio-export.mjs +134 -0
  102. package/skills/cc-drawio-studio/scripts/layout-graph.mjs +107 -0
  103. package/skills/cc-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  104. package/skills/cc-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  105. package/skills/cc-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  106. package/skills/cc-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  107. package/skills/cc-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  108. package/skills/cc-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  109. package/skills/cc-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  110. package/skills/cc-drawio-studio/scripts/shape-query.mjs +121 -0
  111. package/skills/cc-drawio-studio/scripts/studio-core.mjs +139 -0
  112. package/skills/cc-drawio-studio/styles/built-in/corporate.json +49 -0
  113. package/skills/cc-drawio-studio/styles/built-in/default.json +49 -0
  114. package/skills/cc-drawio-studio/styles/built-in/handdrawn.json +49 -0
  115. package/skills/cc-drawio-studio/styles/schema.json +112 -0
  116. package/skills/cc-refactoring-core/SKILL.md +8 -0
  117. package/skills/cc-refactoring-core/references/method.md +16 -0
  118. package/skills/cc-source-driven-development/SKILL.md +8 -0
  119. package/skills/cc-source-driven-development/references/method.md +19 -0
  120. package/skills/cc-tdd-methodology/SKILL.md +8 -0
  121. package/skills/cc-tdd-methodology/references/method.md +13 -0
  122. package/skills/cc-technical-diagrams/SKILL.md +34 -0
  123. package/skills/cc-technical-diagrams/assets/interactive-diagram.html +371 -0
  124. package/skills/cc-technical-diagrams/assets/quality-examples/README.md +14 -0
  125. package/skills/cc-technical-diagrams/assets/quality-examples/architecture.json +121 -0
  126. package/skills/cc-technical-diagrams/assets/quality-examples/invalid-explicit.json +41 -0
  127. package/skills/cc-technical-diagrams/assets/quality-examples/sequence.json +53 -0
  128. package/skills/cc-technical-diagrams/assets/quality-examples/sequence.mmd +21 -0
  129. package/skills/cc-technical-diagrams/assets/quality-examples/workflow.json +98 -0
  130. package/skills/cc-technical-diagrams/assets/quality-examples/workflow.mmd +7 -0
  131. package/skills/cc-technical-diagrams/references/diagram-workflows.md +81 -0
  132. package/skills/cc-technical-diagrams/references/html-technical-diagrams.md +243 -0
  133. package/skills/cc-technical-diagrams/references/png-qa-autofix.md +37 -0
  134. package/skills/cc-technical-diagrams/scripts/diagram-browser.mjs +153 -0
  135. package/skills/cc-technical-diagrams/scripts/diagram-layout.mjs +176 -0
  136. package/skills/cc-technical-diagrams/scripts/export-diagram.mjs +332 -0
  137. package/skills/cc-technical-diagrams/scripts/interactive-diagram-server.mjs +654 -0
  138. package/skills/cc-technical-diagrams/scripts/mermaid-render.mjs +64 -0
  139. package/skills/cc-technical-diagrams/scripts/png-qa.mjs +462 -0
  140. package/skills/cc-technical-diagrams/scripts/tech-diagram-render.mjs +1537 -0
  141. package/skills/eval_queries.json +160 -0
  142. package/skills/metadata.json +223 -0
  143. package/skills/relations.json +53 -0
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { formatResult, parseArgs, skillDir } from "./studio-core.mjs";
5
+
6
+ const INDEX = path.join(skillDir, "data", "shape-index.json");
7
+ const ALIASES = new Map([
8
+ ["亚马逊", "aws"],
9
+ ["阿里云", "alibaba cloud"],
10
+ ["微软云", "azure"],
11
+ ["谷歌云", "gcp"],
12
+ ["云", "cloud"],
13
+ ["数据库", "database"],
14
+ ["队列", "queue"],
15
+ ["网关", "gateway"],
16
+ ["服务", "service"],
17
+ ["用户", "user"],
18
+ ["角色", "actor"],
19
+ ["流程", "flowchart"],
20
+ ["容器", "container"],
21
+ ["网络", "network"],
22
+ ["交换机", "switch"],
23
+ ["路由器", "router"],
24
+ ["函数", "lambda"],
25
+ ["对象存储", "storage"],
26
+ ["消息", "message"],
27
+ ]);
28
+
29
+ export function loadShapes() {
30
+ return JSON.parse(fs.readFileSync(INDEX).toString("utf8"));
31
+ }
32
+
33
+ export function queryShapes(shapes, query, options = {}) {
34
+ const terms = expandTerms(query);
35
+ const category = options.category
36
+ ? String(options.category).toLowerCase()
37
+ : "";
38
+ const scored = [];
39
+ for (const [index, shape] of shapes.entries()) {
40
+ const haystack =
41
+ `${shape.title ?? ""} ${shape.tags ?? ""} ${shape.style ?? ""}`.toLowerCase();
42
+ if (category && !haystack.includes(category)) continue;
43
+ let score = 0;
44
+ const title = String(shape.title ?? "").toLowerCase();
45
+ const tags = String(shape.tags ?? "").toLowerCase();
46
+ for (const term of terms) {
47
+ if (title === term) score += 80;
48
+ else if (title.includes(term)) score += 45;
49
+ if (tags.split(/\s+/).includes(term)) score += 30;
50
+ else if (tags.includes(term)) score += 12;
51
+ if (fuzzyContains(haystack, term)) score += 4;
52
+ }
53
+ if (score > 0)
54
+ scored.push({
55
+ index,
56
+ score,
57
+ titleHits: terms.filter((term) => title.includes(term)).length,
58
+ shape,
59
+ });
60
+ }
61
+ return scored
62
+ .sort(
63
+ (a, b) =>
64
+ b.score - a.score ||
65
+ b.titleHits - a.titleHits ||
66
+ String(a.shape.title).localeCompare(String(b.shape.title)) ||
67
+ a.index - b.index,
68
+ )
69
+ .slice(0, Number(options.limit ?? 10))
70
+ .map(({ shape, score }) => ({
71
+ title: shape.title,
72
+ w: shape.w,
73
+ h: shape.h,
74
+ style: shape.style,
75
+ score,
76
+ }));
77
+ }
78
+
79
+ function expandTerms(query) {
80
+ const normalized = String(query ?? "").toLowerCase();
81
+ const raw = normalized.match(/[\p{L}\p{N}._-]+/gu) ?? [];
82
+ const expanded = [];
83
+ for (const term of raw) {
84
+ expanded.push(ALIASES.get(term) ?? term);
85
+ if (term.includes("-")) expanded.push(...term.split("-"));
86
+ }
87
+ return [
88
+ ...new Set(
89
+ expanded.join(" ").match(/[a-z0-9._-]+|[\u4e00-\u9fff]+/g) ?? [],
90
+ ),
91
+ ].filter((term) => term.length >= 2);
92
+ }
93
+
94
+ function fuzzyContains(text, term) {
95
+ if (term.length < 4) return false;
96
+ let cursor = 0;
97
+ for (const ch of text) {
98
+ if (ch === term[cursor]) cursor += 1;
99
+ if (cursor === term.length) return true;
100
+ }
101
+ return false;
102
+ }
103
+
104
+ const args = parseArgs(process.argv.slice(2));
105
+ const query = args._.join(" ");
106
+ if (!query) {
107
+ console.error(
108
+ "usage: node shape-query.mjs <keywords> [--limit 10] [--category aws] [--format markdown|json]",
109
+ );
110
+ process.exit(2);
111
+ }
112
+ const results = queryShapes(loadShapes(), query, args);
113
+ if (results.length === 0) {
114
+ console.error(`no shapes matched ${JSON.stringify(query)}`);
115
+ process.exit(1);
116
+ }
117
+ if ((args.format ?? (args.json ? "json" : "markdown")) === "json") {
118
+ process.stdout.write(`${JSON.stringify(results, null, 2)}\n`);
119
+ } else {
120
+ process.stdout.write(formatResult({ title: "Shape Query", query, results }));
121
+ }
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ export const scriptDir = path.dirname(fileURLToPath(import.meta.url));
7
+ export const skillDir = path.resolve(scriptDir, "..");
8
+
9
+ export function readText(filePath) {
10
+ return fs.readFileSync(filePath, "utf8");
11
+ }
12
+
13
+ export function writeText(filePath, body) {
14
+ fs.mkdirSync(path.dirname(path.resolve(filePath)), { recursive: true });
15
+ fs.writeFileSync(filePath, body, "utf8");
16
+ }
17
+
18
+ export function parseArgs(argv) {
19
+ const args = { _: [] };
20
+ for (let i = 0; i < argv.length; i += 1) {
21
+ const token = argv[i];
22
+ if (!token.startsWith("--")) {
23
+ args._.push(token);
24
+ continue;
25
+ }
26
+ const [rawKey, inline] = token.slice(2).split("=", 2);
27
+ const key = rawKey.replace(/-([a-z])/g, (_, ch) => ch.toUpperCase());
28
+ if (inline !== undefined) {
29
+ args[key] = inline;
30
+ } else if (argv[i + 1] && !argv[i + 1].startsWith("--")) {
31
+ args[key] = argv[i + 1];
32
+ i += 1;
33
+ } else {
34
+ args[key] = true;
35
+ }
36
+ }
37
+ return args;
38
+ }
39
+
40
+ export function formatResult(result, format = "markdown") {
41
+ if (format === "json") return `${JSON.stringify(result, null, 2)}\n`;
42
+ const lines = [`# ${result.title ?? "Drawio Studio Result"}`, ""];
43
+ for (const [key, value] of Object.entries(result)) {
44
+ if (key === "title") continue;
45
+ if (Array.isArray(value)) {
46
+ lines.push(`## ${label(key)}`, "");
47
+ if (value.length === 0) lines.push("- None");
48
+ else for (const item of value) lines.push(`- ${typeof item === "string" ? item : JSON.stringify(item)}`);
49
+ lines.push("");
50
+ } else if (value && typeof value === "object") {
51
+ lines.push(`## ${label(key)}`, "", "```json", JSON.stringify(value, null, 2), "```", "");
52
+ } else {
53
+ lines.push(`- ${label(key)}: ${String(value)}`);
54
+ }
55
+ }
56
+ return `${lines.join("\n").trimEnd()}\n`;
57
+ }
58
+
59
+ export function label(value) {
60
+ return value.replace(/([A-Z])/g, " $1").replace(/^./, (ch) => ch.toUpperCase());
61
+ }
62
+
63
+ export function xmlEscape(value) {
64
+ return String(value)
65
+ .replaceAll("&", "&amp;")
66
+ .replaceAll("<", "&lt;")
67
+ .replaceAll(">", "&gt;")
68
+ .replaceAll('"', "&quot;");
69
+ }
70
+
71
+ export function snap(value, grid = 10) {
72
+ return Math.round(value / grid) * grid;
73
+ }
74
+
75
+ export function walkFiles(root, predicate) {
76
+ const out = [];
77
+ const skip = new Set([".git", "node_modules", "dist", "target", "vendor", ".next", ".nuxt", "coverage"]);
78
+ function visit(dir) {
79
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
80
+ if (skip.has(entry.name)) continue;
81
+ const full = path.join(dir, entry.name);
82
+ if (entry.isDirectory()) visit(full);
83
+ else if (!predicate || predicate(full)) out.push(full);
84
+ }
85
+ }
86
+ visit(path.resolve(root));
87
+ return out.sort();
88
+ }
89
+
90
+ export function toPosix(value) {
91
+ return value.split(path.sep).join("/");
92
+ }
93
+
94
+ export function commonPrefix(values) {
95
+ if (values.length === 0) return "";
96
+ let prefix = values[0];
97
+ for (const value of values.slice(1)) {
98
+ while (prefix && !value.startsWith(prefix)) prefix = prefix.slice(0, -1);
99
+ }
100
+ return prefix.replace(/[^/]*$/, "");
101
+ }
102
+
103
+ export function reduceTransitive(nodes, edges) {
104
+ const ids = new Set(nodes.map((node) => node.id));
105
+ const unique = [];
106
+ const seen = new Set();
107
+ for (const edge of edges) {
108
+ if (!ids.has(edge.source) || !ids.has(edge.target) || edge.source === edge.target) continue;
109
+ const key = `${edge.source}\0${edge.target}`;
110
+ if (!seen.has(key)) {
111
+ seen.add(key);
112
+ unique.push({ source: edge.source, target: edge.target });
113
+ }
114
+ }
115
+ const adjacency = new Map();
116
+ for (const edge of unique) {
117
+ if (!adjacency.has(edge.source)) adjacency.set(edge.source, new Set());
118
+ adjacency.get(edge.source).add(edge.target);
119
+ }
120
+ return unique.filter((edge) => !hasAlternatePath(edge.source, edge.target, adjacency, edge));
121
+ }
122
+
123
+ function hasAlternatePath(source, target, adjacency, skipped) {
124
+ const stack = [...(adjacency.get(source) ?? [])].filter((next) => !(source === skipped.source && next === skipped.target));
125
+ const seen = new Set();
126
+ while (stack.length) {
127
+ const next = stack.pop();
128
+ if (next === target) return true;
129
+ if (!next || seen.has(next)) continue;
130
+ seen.add(next);
131
+ for (const child of adjacency.get(next) ?? []) stack.push(child);
132
+ }
133
+ return false;
134
+ }
135
+
136
+ export function printOrWrite(body, output) {
137
+ if (output) writeText(output, body);
138
+ else process.stdout.write(body);
139
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "../schema.json",
3
+ "name": "corporate",
4
+ "version": 1,
5
+ "default": false,
6
+ "source": { "type": "built-in" },
7
+ "confidence": "high",
8
+ "palette": {
9
+ "primary": { "fillColor": "#e3f2fd", "strokeColor": "#1565c0" },
10
+ "success": { "fillColor": "#e8f5e9", "strokeColor": "#2e7d32" },
11
+ "warning": { "fillColor": "#fff9c4", "strokeColor": "#f57c00" },
12
+ "accent": { "fillColor": "#fff3e0", "strokeColor": "#e65100" },
13
+ "danger": { "fillColor": "#ffebee", "strokeColor": "#c62828" },
14
+ "neutral": { "fillColor": "#eceff1", "strokeColor": "#455a64" },
15
+ "secondary": { "fillColor": "#f3e5f5", "strokeColor": "#6a1b9a" }
16
+ },
17
+ "roles": {
18
+ "service": "primary",
19
+ "database": "success",
20
+ "queue": "warning",
21
+ "gateway": "accent",
22
+ "error": "danger",
23
+ "external": "neutral",
24
+ "security": "secondary"
25
+ },
26
+ "shapes": {
27
+ "service": "rounded=0",
28
+ "database": "shape=cylinder3",
29
+ "queue": "rounded=0",
30
+ "decision": "rhombus",
31
+ "external": "rounded=0;dashed=1",
32
+ "container": "swimlane;startSize=30"
33
+ },
34
+ "font": {
35
+ "fontFamily": "Arial",
36
+ "fontSize": 11,
37
+ "titleFontSize": 13,
38
+ "titleBold": true
39
+ },
40
+ "edges": {
41
+ "style": "edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1",
42
+ "arrow": "endArrow=classic;endFill=1",
43
+ "dashedFor": ["optional", "async"]
44
+ },
45
+ "extras": {
46
+ "sketch": false,
47
+ "globalStrokeWidth": 1
48
+ }
49
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "../schema.json",
3
+ "name": "default",
4
+ "version": 1,
5
+ "default": false,
6
+ "source": { "type": "built-in" },
7
+ "confidence": "high",
8
+ "palette": {
9
+ "primary": { "fillColor": "#dae8fc", "strokeColor": "#6c8ebf" },
10
+ "success": { "fillColor": "#d5e8d4", "strokeColor": "#82b366" },
11
+ "warning": { "fillColor": "#fff2cc", "strokeColor": "#d6b656" },
12
+ "accent": { "fillColor": "#ffe6cc", "strokeColor": "#d79b00" },
13
+ "danger": { "fillColor": "#f8cecc", "strokeColor": "#b85450" },
14
+ "neutral": { "fillColor": "#f5f5f5", "strokeColor": "#666666" },
15
+ "secondary": { "fillColor": "#e1d5e7", "strokeColor": "#9673a6" }
16
+ },
17
+ "roles": {
18
+ "service": "primary",
19
+ "database": "success",
20
+ "queue": "warning",
21
+ "gateway": "accent",
22
+ "error": "danger",
23
+ "external": "neutral",
24
+ "security": "secondary"
25
+ },
26
+ "shapes": {
27
+ "service": "rounded=1",
28
+ "database": "shape=cylinder3",
29
+ "queue": "rounded=1",
30
+ "decision": "rhombus",
31
+ "external": "rounded=1;dashed=1",
32
+ "container": "swimlane;startSize=30"
33
+ },
34
+ "font": {
35
+ "fontFamily": "Helvetica",
36
+ "fontSize": 12,
37
+ "titleFontSize": 14,
38
+ "titleBold": true
39
+ },
40
+ "edges": {
41
+ "style": "edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1",
42
+ "arrow": "endArrow=classic;endFill=1",
43
+ "dashedFor": []
44
+ },
45
+ "extras": {
46
+ "sketch": false,
47
+ "globalStrokeWidth": 1
48
+ }
49
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "../schema.json",
3
+ "name": "handdrawn",
4
+ "version": 1,
5
+ "default": false,
6
+ "source": { "type": "built-in" },
7
+ "confidence": "high",
8
+ "palette": {
9
+ "primary": { "fillColor": "#ffe4b5", "strokeColor": "#b8651e" },
10
+ "success": { "fillColor": "#def0dc", "strokeColor": "#5c8a49" },
11
+ "warning": { "fillColor": "#fff4cc", "strokeColor": "#b8901a" },
12
+ "accent": { "fillColor": "#ffd9b3", "strokeColor": "#c25100" },
13
+ "danger": { "fillColor": "#ffcdbf", "strokeColor": "#a53d3d" },
14
+ "neutral": { "fillColor": "#f5e6d3", "strokeColor": "#8b7355" },
15
+ "secondary": { "fillColor": "#e6d7e8", "strokeColor": "#7b4397" }
16
+ },
17
+ "roles": {
18
+ "service": "primary",
19
+ "database": "success",
20
+ "queue": "warning",
21
+ "gateway": "accent",
22
+ "error": "danger",
23
+ "external": "neutral",
24
+ "security": "secondary"
25
+ },
26
+ "shapes": {
27
+ "service": "rounded=1",
28
+ "database": "shape=cylinder3",
29
+ "queue": "rounded=1",
30
+ "decision": "rhombus",
31
+ "external": "rounded=1;dashed=1",
32
+ "container": "swimlane;startSize=30"
33
+ },
34
+ "font": {
35
+ "fontFamily": "Helvetica",
36
+ "fontSize": 12,
37
+ "titleFontSize": 14,
38
+ "titleBold": true
39
+ },
40
+ "edges": {
41
+ "style": "edgeStyle=orthogonalEdgeStyle;curved=1;rounded=1;orthogonalLoop=1;jettySize=auto;html=1",
42
+ "arrow": "endArrow=classic;endFill=1",
43
+ "dashedFor": ["optional"]
44
+ },
45
+ "extras": {
46
+ "sketch": true,
47
+ "globalStrokeWidth": 2
48
+ }
49
+ }
@@ -0,0 +1,112 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/Agents365-ai/drawio-skill/styles/schema.json",
4
+ "title": "drawio-skill preset",
5
+ "type": "object",
6
+ "required": ["name", "version", "palette", "roles", "shapes", "font", "edges"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "$schema": { "type": "string" },
10
+ "name": { "type": "string", "pattern": "^[a-z0-9][a-z0-9_-]*$" },
11
+ "version": { "type": "integer", "const": 1 },
12
+ "default": { "type": "boolean" },
13
+ "confidence": { "type": "string", "enum": ["low", "medium", "high"] },
14
+ "source": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "properties": {
18
+ "type": { "type": "string", "enum": ["xml", "image", "built-in", "hand-authored"] },
19
+ "path": { "type": "string" },
20
+ "extracted_at": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" }
21
+ }
22
+ },
23
+ "palette": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["primary", "success", "warning", "accent", "danger", "neutral", "secondary"],
27
+ "properties": {
28
+ "primary": { "$ref": "#/$defs/colorPair" },
29
+ "success": { "$ref": "#/$defs/colorPair" },
30
+ "warning": { "$ref": "#/$defs/colorPair" },
31
+ "accent": { "$ref": "#/$defs/colorPair" },
32
+ "danger": { "$ref": "#/$defs/colorPair" },
33
+ "neutral": { "$ref": "#/$defs/colorPair" },
34
+ "secondary": { "$ref": "#/$defs/colorPair" }
35
+ }
36
+ },
37
+ "roles": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "service": { "$ref": "#/$defs/slotName" },
42
+ "database": { "$ref": "#/$defs/slotName" },
43
+ "queue": { "$ref": "#/$defs/slotName" },
44
+ "gateway": { "$ref": "#/$defs/slotName" },
45
+ "error": { "$ref": "#/$defs/slotName" },
46
+ "external": { "$ref": "#/$defs/slotName" },
47
+ "security": { "$ref": "#/$defs/slotName" }
48
+ }
49
+ },
50
+ "shapes": {
51
+ "type": "object",
52
+ "additionalProperties": { "type": "string" },
53
+ "properties": {
54
+ "service": { "type": "string" },
55
+ "database": { "type": "string" },
56
+ "queue": { "type": "string" },
57
+ "decision": { "type": "string" },
58
+ "external": { "type": "string" },
59
+ "container": { "type": "string" }
60
+ }
61
+ },
62
+ "font": {
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "required": ["fontFamily", "fontSize"],
66
+ "properties": {
67
+ "fontFamily": { "type": "string" },
68
+ "fontSize": { "type": "integer", "minimum": 8, "maximum": 36 },
69
+ "titleFontSize": { "type": "integer", "minimum": 8, "maximum": 48 },
70
+ "titleBold": { "type": "boolean" }
71
+ }
72
+ },
73
+ "edges": {
74
+ "type": "object",
75
+ "additionalProperties": false,
76
+ "required": ["style", "arrow"],
77
+ "properties": {
78
+ "style": { "type": "string" },
79
+ "arrow": { "type": "string" },
80
+ "dashedFor": { "type": "array", "items": { "type": "string" } }
81
+ }
82
+ },
83
+ "extras": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "properties": {
87
+ "sketch": { "type": "boolean" },
88
+ "globalStrokeWidth": { "type": "number", "minimum": 0.5, "maximum": 6 }
89
+ }
90
+ }
91
+ },
92
+ "$defs": {
93
+ "colorPair": {
94
+ "oneOf": [
95
+ { "type": "null" },
96
+ {
97
+ "type": "object",
98
+ "additionalProperties": false,
99
+ "required": ["fillColor", "strokeColor"],
100
+ "properties": {
101
+ "fillColor": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
102
+ "strokeColor": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" }
103
+ }
104
+ }
105
+ ]
106
+ },
107
+ "slotName": {
108
+ "type": "string",
109
+ "enum": ["primary", "success", "warning", "accent", "danger", "neutral", "secondary"]
110
+ }
111
+ }
112
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: cc-refactoring-core
3
+ description: Use when reorganizing existing code, extracting responsibilities, moving modules, or simplifying structure while preserving observable behavior. Do not use for new functionality, behavior-changing defect fixes, or dependency upgrades.
4
+ ---
5
+
6
+ # Behavior-preserving refactoring
7
+
8
+ Read and follow the [shared method](references/method.md). Select project-specific tools and domain checks from the actual repository; this workflow does not require a frontend stack.
@@ -0,0 +1,16 @@
1
+ # Behavior-preserving refactoring
2
+
3
+ Refactoring changes internal organization while preserving the observable contract. Use GREEN → REFACTOR → GREEN; do not manufacture a failing behavioral requirement for a structural change.
4
+
5
+ 1. Classify whether this is structural work, a new behavior, a defect fix, or a dependency migration. Keep behavior changes in a separate workflow.
6
+ 2. Read affected implementation, callers, exports, registration, persistence and tests. Define observable results, errors, side effects and ordering, state transitions, public names and protocols before editing.
7
+ 3. Establish the green baseline or record existing failures. If a relevant behavior lacks coverage, add characterization tests that describe current behavior; these may start green.
8
+ 4. Diagnose structural evidence and check false positives. Line count and complexity metrics alone do not justify a rewrite. Prefer the smallest safe, reversible transformation.
9
+ 5. Plan prerequisite steps. Each records target, structural intent, technique, risk, expected files/functions, expected public API/behavior changes (zero for pure refactoring), verification and rollback boundary.
10
+ 6. Change one primary structural concern, then run the nearest meaningful check and inspect the diff. Stop and reassess if the actual scope exceeds the planned diff budget.
11
+ 7. A new regression invalidates the current step: restore only that step, verify the previous baseline and shrink or reorder the transformation before retrying. Do not revert unrelated user edits or spread repairs across unrelated modules.
12
+ 8. Broaden verification as the changed contract requires: local/static checks, unit/integration, full lint/types/tests, build and relevant specialty checks. Use existing project tools rather than impose a framework.
13
+
14
+ Risk is contextual: SAFE for local/private changes with strong evidence; CAUTION for cross-module/shared-state/lifecycle changes; DANGER for public APIs, schemas, persistence, authentication, permission, protocols or architecture-wide changes. A technique name alone never makes a change safe.
15
+
16
+ Deliver a proof verdict: PASS when the relevant behavior is adequately covered and checks pass; PARTIAL when checks pass but coverage has important gaps; NOT PROVEN when evidence or environment prevents a credible preservation claim. Include executed commands, rollback decisions and remaining risks.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: cc-source-driven-development
3
+ description: Use when engineering decisions depend on version-sensitive packages, runtimes, platform behavior, public API assumptions, official documentation, source code, or a specified local knowledge base.
4
+ ---
5
+
6
+ # Source-driven development
7
+
8
+ Read and follow the [shared method](references/method.md). Select project-specific tools and domain checks from the actual repository; this workflow does not require a frontend stack.
@@ -0,0 +1,19 @@
1
+ # Source-driven development
2
+
3
+ Use project facts, authoritative sources and version-specific evidence to make engineering decisions.
4
+
5
+ 1. Establish the question, affected version and local contract. Read the project's manifests, configuration, implementation, callers and tests before proposing changes. Stable local transformations can rely on those facts; changing runtime, package or public API assumptions need authoritative verification.
6
+ 2. Collect official documentation, source, type definitions, release notes, specifications and migration guides for the actual version. Third-party discussions provide clues, not the final basis. Record source paths/URLs, versions, dates and relevant conclusions.
7
+ 3. Compare recommendations with the running project. State compatibility, maintenance cost, migration scope and rollback. Isolate unstable external assumptions behind a small boundary; do not overturn stable conventions just to use a newer pattern.
8
+ 4. Prove key assumptions using the project's existing checks or a minimal reproduction. Select checks for the actual stack. Record commands and observed outcomes; if verification is unavailable, report the uncertainty rather than claim support.
9
+ 5. Update a lightweight ADR, migration record or factual documentation when public interfaces, dependencies or team conventions change. Do not copy long external documents.
10
+
11
+ ## Local knowledge requests
12
+
13
+ When a user restricts evidence to a local repository or knowledge directory, search that source first and do not fill gaps with online guesses. Use the explicit path, otherwise check whether `knowledge/` exists. If absent, identify the missing source instead of inventing one.
14
+
15
+ Read `data_structure.md` navigation where available, choose relevant branches, and search progressively instead of loading the entire corpus. Default to at most five keyword refinement rounds. Record file paths, sections/pages/sheets, version range and evidence gaps. For PDF or spreadsheets choose an appropriate extraction tool before reading large content. Use external sources only when the user's scope permits them.
16
+
17
+ ## Evidence priority and delivery
18
+
19
+ Project implementation/configuration/tests establish the local contract; official versioned documentation/source establishes external behavior; specifications establish platform constraints; issues and articles only supplement these. Deliver the decision, sources, implementation impact, verification results and remaining uncertainty. "Checked the docs" without traceable evidence is insufficient.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: cc-tdd-methodology
3
+ description: Use when implementing new observable behavior or fixing a behavioral defect through tests, or when deciding whether a change is test-driven development or pure behavior-preserving refactoring.
4
+ ---
5
+
6
+ # Test-driven development
7
+
8
+ Read and follow the [shared method](references/method.md). Select project-specific tools and domain checks from the actual repository; this workflow does not require a frontend stack.
@@ -0,0 +1,13 @@
1
+ # Test-driven development
2
+
3
+ For new behavior and behavior-changing defect fixes use RED → GREEN → REFACTOR. The test describes an observable contract, not private implementation structure.
4
+
5
+ 1. Identify one behavior: inputs, output/error, state transition or externally observable side effect. Choose the closest meaningful test level using existing project tooling.
6
+ 2. Write the smallest test that distinguishes the missing or wrong behavior. Run it first and observe failure for the expected behavior, not a syntax, import or environment problem. For a defect, the test must fail against the original defect.
7
+ 3. Implement only enough to pass that test. Do not refactor during the red phase or add unrelated features.
8
+ 4. Run the test and relevant surrounding tests, then improve naming and structure while preserving green. New requirements enter the next cycle.
9
+ 5. Report the observed red/green commands, covered behavior and untested boundaries. Do not infer success from a diff or unexecuted tests.
10
+
11
+ Pure structural refactoring has a different contract: establish current behavior through existing or characterization coverage and keep GREEN → REFACTOR → GREEN. Do not invent a failure merely to satisfy a ritual.
12
+
13
+ Test logic close to the risk; use integration tests for real boundaries and end-to-end tests for journeys that need them. Do not make E2E the default or assert fragile private state. Do not introduce a new testing framework merely for TDD. If infrastructure is absent, explain the minimum test setup and obtain a decision before introducing it; use the actual stack rather than require frontend tools.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: cc-technical-diagrams
3
+ description: Use when creating or exporting structured technical diagrams, including architecture, workflows, sequence diagrams, data flows, lifecycle diagrams, agent or memory flows, local interactive previews, and PNG quality checks. Use editable draw.io sources when long-term manual editing or vendor shapes matter. Do not use for UI mockups, product imagery, posters, or raster image editing.
4
+ ---
5
+
6
+ # Technical diagrams
7
+
8
+ Create complete, readable technical diagrams from editable structured sources. This workflow applies across frontend, backend, infrastructure, and agent systems.
9
+
10
+ ## Choose the source
11
+
12
+ Read [diagram workflows](references/diagram-workflows.md). Prefer locally available Mermaid for standard sequence and flowcharts. Use HTML technical diagrams for self-contained browser viewing, semantic architecture and agent/memory flows; read [HTML technical diagrams](references/html-technical-diagrams.md). Choose editable draw.io sources for official vendor shapes or long-term manual editing.
13
+
14
+ Use a local interactive preview when the user benefits from incremental explanation; keep JSON/SVG/PNG exports as deliverables. The live server is [interactive-diagram-server.mjs](scripts/interactive-diagram-server.mjs) and the local page is [interactive-diagram.html](assets/interactive-diagram.html).
15
+
16
+ ## Render and export
17
+
18
+ Keep every node, relationship, complete label and explicit geometry. The renderer supports workflow, sequence, dataflow, lifecycle and architecture. Never silently simplify advanced sequence semantics; prefer Mermaid for activation and alt/loop/par fragments.
19
+
20
+ ```sh
21
+ node skills/cc-technical-diagrams/scripts/tech-diagram-render.mjs --input diagram.json --type architecture --output diagram.html --manifest diagram.layout.json
22
+ node skills/cc-technical-diagrams/scripts/export-diagram.mjs --input diagram.html --format png --output diagram.png --theme light --scale 2 --manifest diagram.layout.json --output-manifest diagram.actual.json
23
+ node skills/cc-technical-diagrams/scripts/png-qa.mjs --png diagram.png --manifest diagram.actual.json --format json
24
+ ```
25
+
26
+ Standard Mermaid sources use [mermaid-render.mjs](scripts/mermaid-render.mjs). Reuse [diagram-layout.mjs](scripts/diagram-layout.mjs) and [diagram-browser.mjs](scripts/diagram-browser.mjs); do not invent another renderer or add required browser libraries, remote scripts or downloaded icon packs.
27
+
28
+ ## Verify and deliver
29
+
30
+ Inspect the actual exported image for clipping, text truncation, crossing labels, overlaps and missing content. PNG QA uses the actual scaled export manifest, not the source's estimated coordinates. Successful export alone does not prove visual acceptance. Read [PNG repair guidance](references/png-qa-autofix.md); repair the source or layout, not the output pixels. Default to at most two repair rounds and report unresolved issues.
31
+
32
+ Deliver JSON/Mermaid source, HTML where relevant, exports and QA evidence. Record tool versions, theme, scale, repair rounds and partial acceptance. Optional Mermaid/Graphviz/browser tools must fail clearly or use an available fallback; do not install them automatically or claim a missing export succeeded. Retain complete labels instead of hiding overflow at higher resolution.
33
+
34
+ Examples and fixtures: [quality examples](assets/quality-examples/README.md), [sequence JSON](assets/quality-examples/sequence.json), [workflow JSON](assets/quality-examples/workflow.json), [architecture JSON](assets/quality-examples/architecture.json), [invalid explicit geometry](assets/quality-examples/invalid-explicit.json).