@rotifer/playground 0.5.0-alpha.2 → 0.7.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/CHANGELOG.md +159 -15
- package/LICENSE +1 -1
- package/README.md +51 -23
- package/README.zh.md +54 -25
- package/dist/cloud/auth.d.ts +7 -1
- package/dist/cloud/auth.d.ts.map +1 -1
- package/dist/cloud/auth.js +65 -1
- package/dist/cloud/auth.js.map +1 -1
- package/dist/cloud/client.d.ts +4 -1
- package/dist/cloud/client.d.ts.map +1 -1
- package/dist/cloud/client.js +16 -3
- package/dist/cloud/client.js.map +1 -1
- package/dist/cloud/types.d.ts +6 -1
- package/dist/cloud/types.d.ts.map +1 -1
- package/dist/cloud/types.js.map +1 -1
- package/dist/commands/agent-create.d.ts.map +1 -1
- package/dist/commands/agent-create.js +66 -3
- package/dist/commands/agent-create.js.map +1 -1
- package/dist/commands/agent-run.d.ts.map +1 -1
- package/dist/commands/agent-run.js +296 -32
- package/dist/commands/agent-run.js.map +1 -1
- package/dist/commands/arena-list.js +8 -2
- package/dist/commands/arena-list.js.map +1 -1
- package/dist/commands/arena-submit.d.ts.map +1 -1
- package/dist/commands/arena-submit.js +45 -17
- package/dist/commands/arena-submit.js.map +1 -1
- package/dist/commands/arena-watch.js +8 -2
- package/dist/commands/arena-watch.js.map +1 -1
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +9 -3
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +13 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +23 -16
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/network.js +4 -4
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +200 -44
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +209 -23
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/wrap.d.ts.map +1 -1
- package/dist/commands/wrap.js +17 -1
- package/dist/commands/wrap.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/runtime/network-gateway.d.ts +53 -0
- package/dist/runtime/network-gateway.d.ts.map +1 -0
- package/dist/runtime/network-gateway.js +147 -0
- package/dist/runtime/network-gateway.js.map +1 -0
- package/dist/utils/binding.d.ts +25 -0
- package/dist/utils/binding.d.ts.map +1 -1
- package/dist/utils/binding.js.map +1 -1
- package/dist/utils/open-browser.d.ts +10 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +23 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/genes/academic-writer/.cloud-manifest.json +6 -0
- package/genes/academic-writer/.gene-manifest.json +8 -0
- package/genes/academic-writer/SKILL.md +274 -0
- package/genes/academic-writer/phenotype.json +28 -0
- package/genes/ai-components/.cloud-manifest.json +6 -0
- package/genes/ai-components/.gene-manifest.json +8 -0
- package/genes/ai-components/SKILL.md +381 -0
- package/genes/ai-components/phenotype.json +28 -0
- package/genes/algorithmic-art/.cloud-manifest.json +6 -0
- package/genes/algorithmic-art/.gene-manifest.json +8 -0
- package/genes/algorithmic-art/SKILL.md +405 -0
- package/genes/algorithmic-art/phenotype.json +28 -0
- package/genes/answer-synthesizer/.cloud-manifest.json +6 -0
- package/genes/answer-synthesizer/index.ts +194 -0
- package/genes/answer-synthesizer/phenotype.json +61 -0
- package/genes/api-designer/.cloud-manifest.json +6 -0
- package/genes/api-designer/.gene-manifest.json +8 -0
- package/genes/api-designer/SKILL.md +456 -0
- package/genes/api-designer/phenotype.json +28 -0
- package/genes/auto-coder/.cloud-manifest.json +6 -0
- package/genes/auto-coder/.gene-manifest.json +8 -0
- package/genes/auto-coder/SKILL.md +400 -0
- package/genes/auto-coder/phenotype.json +28 -0
- package/genes/auto-writer/.cloud-manifest.json +6 -0
- package/genes/auto-writer/.gene-manifest.json +8 -0
- package/genes/auto-writer/SKILL.md +361 -0
- package/genes/auto-writer/phenotype.json +28 -0
- package/genes/brand-personality/.cloud-manifest.json +6 -0
- package/genes/brand-personality/.gene-manifest.json +8 -0
- package/genes/brand-personality/SKILL.md +549 -0
- package/genes/brand-personality/phenotype.json +28 -0
- package/genes/business-writer/.cloud-manifest.json +6 -0
- package/genes/business-writer/.gene-manifest.json +8 -0
- package/genes/business-writer/SKILL.md +448 -0
- package/genes/business-writer/phenotype.json +28 -0
- package/genes/citation-manager/.cloud-manifest.json +6 -0
- package/genes/citation-manager/.gene-manifest.json +8 -0
- package/genes/citation-manager/SKILL.md +279 -0
- package/genes/citation-manager/index.ts +162 -0
- package/genes/citation-manager/package.json +1 -0
- package/genes/citation-manager/phenotype.json +50 -0
- package/genes/code-complexity/.cloud-manifest.json +6 -0
- package/genes/code-complexity/README.md +35 -0
- package/genes/code-complexity/index.ts +101 -0
- package/genes/code-complexity/phenotype.json +34 -0
- package/genes/copywriter/.cloud-manifest.json +6 -0
- package/genes/copywriter/.gene-manifest.json +8 -0
- package/genes/copywriter/SKILL.md +329 -0
- package/genes/copywriter/phenotype.json +28 -0
- package/genes/creative-writer/.cloud-manifest.json +6 -0
- package/genes/creative-writer/.gene-manifest.json +8 -0
- package/genes/creative-writer/SKILL.md +356 -0
- package/genes/creative-writer/phenotype.json +28 -0
- package/genes/data-modeler/.cloud-manifest.json +6 -0
- package/genes/data-modeler/.gene-manifest.json +8 -0
- package/genes/data-modeler/SKILL.md +486 -0
- package/genes/data-modeler/phenotype.json +28 -0
- package/genes/debugger/.cloud-manifest.json +6 -0
- package/genes/debugger/.gene-manifest.json +8 -0
- package/genes/debugger/SKILL.md +416 -0
- package/genes/debugger/phenotype.json +28 -0
- package/genes/design-tokens/.cloud-manifest.json +6 -0
- package/genes/design-tokens/.gene-manifest.json +8 -0
- package/genes/design-tokens/SKILL.md +222 -0
- package/genes/design-tokens/index.ts +128 -0
- package/genes/design-tokens/package.json +1 -0
- package/genes/design-tokens/phenotype.json +1 -0
- package/genes/devops-automator/.cloud-manifest.json +6 -0
- package/genes/devops-automator/.gene-manifest.json +8 -0
- package/genes/devops-automator/SKILL.md +490 -0
- package/genes/devops-automator/phenotype.json +28 -0
- package/genes/doc-coauthoring/.cloud-manifest.json +6 -0
- package/genes/doc-coauthoring/.gene-manifest.json +8 -0
- package/genes/doc-coauthoring/SKILL.md +375 -0
- package/genes/doc-coauthoring/phenotype.json +28 -0
- package/genes/doc-retrieval/.cloud-manifest.json +6 -0
- package/genes/doc-retrieval/index.ts +134 -0
- package/genes/doc-retrieval/phenotype.json +54 -0
- package/genes/docs-writer/.cloud-manifest.json +6 -0
- package/genes/docs-writer/.gene-manifest.json +8 -0
- package/genes/docs-writer/SKILL.md +492 -0
- package/genes/docs-writer/phenotype.json +28 -0
- package/genes/evolve-life/.cloud-manifest.json +6 -0
- package/genes/evolve-life/.compile-result.json +12 -0
- package/genes/evolve-life/README.md +52 -0
- package/genes/evolve-life/gene.ir.wasm +0 -0
- package/genes/evolve-life/gene.wasm +0 -0
- package/genes/evolve-life/index.ts +255 -0
- package/genes/evolve-life/phenotype.json +129 -0
- package/genes/evolve-life-bitwise/.cloud-manifest.json +6 -0
- package/genes/evolve-life-bitwise/.compile-result.json +12 -0
- package/genes/evolve-life-bitwise/gene.ir.wasm +0 -0
- package/genes/evolve-life-bitwise/gene.wasm +0 -0
- package/genes/evolve-life-bitwise/index.ts +273 -0
- package/genes/evolve-life-bitwise/phenotype.json +129 -0
- package/genes/evolve-life-sparse/.cloud-manifest.json +6 -0
- package/genes/evolve-life-sparse/.compile-result.json +12 -0
- package/genes/evolve-life-sparse/gene.ir.wasm +0 -0
- package/genes/evolve-life-sparse/gene.wasm +0 -0
- package/genes/evolve-life-sparse/index.ts +236 -0
- package/genes/evolve-life-sparse/phenotype.json +129 -0
- package/genes/fact-checker/.cloud-manifest.json +6 -0
- package/genes/fact-checker/.gene-manifest.json +8 -0
- package/genes/fact-checker/SKILL.md +373 -0
- package/genes/fact-checker/phenotype.json +28 -0
- package/genes/genesis-code-format/.cloud-manifest.json +6 -0
- package/genes/genesis-code-format/package.json +1 -0
- package/genes/genesis-code-format/phenotype.json +1 -0
- package/genes/genesis-file-read/.cloud-manifest.json +6 -0
- package/genes/genesis-file-read/index.ts +11 -1
- package/genes/genesis-file-read/package.json +1 -0
- package/genes/genesis-file-read/phenotype.json +1 -0
- package/genes/genesis-l0-constraint/.cloud-manifest.json +6 -0
- package/genes/genesis-l0-constraint/package.json +1 -0
- package/genes/genesis-l0-constraint/phenotype.json +1 -0
- package/genes/genesis-web-search/.cloud-manifest.json +2 -2
- package/genes/genesis-web-search/package.json +1 -0
- package/genes/genesis-web-search/phenotype.json +1 -0
- package/genes/genesis-web-search-lite/.cloud-manifest.json +6 -0
- package/genes/genesis-web-search-lite/package.json +1 -0
- package/genes/genesis-web-search-lite/phenotype.json +1 -0
- package/genes/git-workflow/.cloud-manifest.json +6 -0
- package/genes/git-workflow/.gene-manifest.json +8 -0
- package/genes/git-workflow/SKILL.md +407 -0
- package/genes/git-workflow/phenotype.json +28 -0
- package/genes/grammar-checker/.cloud-manifest.json +6 -0
- package/genes/grammar-checker/.gene-manifest.json +8 -0
- package/genes/grammar-checker/SKILL.md +194 -0
- package/genes/grammar-checker/index.ts +168 -0
- package/genes/grammar-checker/package.json +1 -0
- package/genes/grammar-checker/phenotype.json +52 -0
- package/genes/json-validator/.cloud-manifest.json +6 -0
- package/genes/json-validator/README.md +42 -0
- package/genes/json-validator/index.ts +112 -0
- package/genes/json-validator/phenotype.json +42 -0
- package/genes/license-advisor/.cloud-manifest.json +6 -0
- package/genes/license-advisor/.gene-manifest.json +8 -0
- package/genes/license-advisor/SKILL.md +117 -0
- package/genes/license-advisor/phenotype.json +28 -0
- package/genes/logic-architect/.cloud-manifest.json +6 -0
- package/genes/logic-architect/.gene-manifest.json +8 -0
- package/genes/logic-architect/SKILL.md +451 -0
- package/genes/logic-architect/phenotype.json +28 -0
- package/genes/markdown-formatter/.cloud-manifest.json +6 -0
- package/genes/markdown-formatter/README.md +34 -0
- package/genes/markdown-formatter/index.ts +86 -0
- package/genes/markdown-formatter/phenotype.json +32 -0
- package/genes/orch/.cloud-manifest.json +6 -0
- package/genes/orch/.gene-manifest.json +8 -0
- package/genes/orch/SKILL.md +504 -0
- package/genes/orch/phenotype.json +28 -0
- package/genes/particle-barneshut/.cloud-manifest.json +6 -0
- package/genes/particle-barneshut/.compile-result.json +12 -0
- package/genes/particle-barneshut/README.md +55 -0
- package/genes/particle-barneshut/gene.ir.wasm +0 -0
- package/genes/particle-barneshut/gene.wasm +0 -0
- package/genes/particle-barneshut/index.ts +486 -0
- package/genes/particle-barneshut/phenotype.json +137 -0
- package/genes/particle-brute/.cloud-manifest.json +6 -0
- package/genes/particle-brute/.compile-result.json +12 -0
- package/genes/particle-brute/README.md +55 -0
- package/genes/particle-brute/gene.ir.wasm +0 -0
- package/genes/particle-brute/gene.wasm +0 -0
- package/genes/particle-brute/index.ts +277 -0
- package/genes/particle-brute/phenotype.json +137 -0
- package/genes/particle-spatial/.cloud-manifest.json +6 -0
- package/genes/particle-spatial/.compile-result.json +12 -0
- package/genes/particle-spatial/README.md +53 -0
- package/genes/particle-spatial/gene.ir.wasm +0 -0
- package/genes/particle-spatial/gene.wasm +0 -0
- package/genes/particle-spatial/index.ts +352 -0
- package/genes/particle-spatial/phenotype.json +137 -0
- package/genes/performance-optimizer/.cloud-manifest.json +6 -0
- package/genes/performance-optimizer/.gene-manifest.json +8 -0
- package/genes/performance-optimizer/SKILL.md +480 -0
- package/genes/performance-optimizer/phenotype.json +28 -0
- package/genes/plagiarism-checker/.cloud-manifest.json +6 -0
- package/genes/plagiarism-checker/.gene-manifest.json +8 -0
- package/genes/plagiarism-checker/SKILL.md +342 -0
- package/genes/plagiarism-checker/phenotype.json +28 -0
- package/genes/product-manager/.cloud-manifest.json +6 -0
- package/genes/product-manager/.gene-manifest.json +8 -0
- package/genes/product-manager/SKILL.md +249 -0
- package/genes/product-manager/phenotype.json +28 -0
- package/genes/project-reviewer/.cloud-manifest.json +6 -0
- package/genes/project-reviewer/.gene-manifest.json +8 -0
- package/genes/project-reviewer/SKILL.md +312 -0
- package/genes/project-reviewer/phenotype.json +28 -0
- package/genes/prompt-engineer/.cloud-manifest.json +6 -0
- package/genes/prompt-engineer/.gene-manifest.json +8 -0
- package/genes/prompt-engineer/SKILL.md +411 -0
- package/genes/prompt-engineer/phenotype.json +28 -0
- package/genes/readability-analyzer/.cloud-manifest.json +6 -0
- package/genes/readability-analyzer/.gene-manifest.json +8 -0
- package/genes/readability-analyzer/SKILL.md +357 -0
- package/genes/readability-analyzer/index.ts +123 -0
- package/genes/readability-analyzer/package.json +1 -0
- package/genes/readability-analyzer/phenotype.json +35 -0
- package/genes/rotifer-protocol/SKILL.md +121 -0
- package/genes/security-auditor/.cloud-manifest.json +6 -0
- package/genes/security-auditor/.gene-manifest.json +8 -0
- package/genes/security-auditor/SKILL.md +494 -0
- package/genes/security-auditor/phenotype.json +28 -0
- package/genes/seo-optimizer/.cloud-manifest.json +6 -0
- package/genes/seo-optimizer/.gene-manifest.json +8 -0
- package/genes/seo-optimizer/SKILL.md +327 -0
- package/genes/seo-optimizer/index.ts +206 -0
- package/genes/seo-optimizer/package.json +1 -0
- package/genes/seo-optimizer/phenotype.json +1 -0
- package/genes/source-linker/.cloud-manifest.json +6 -0
- package/genes/source-linker/index.ts +88 -0
- package/genes/source-linker/phenotype.json +45 -0
- package/genes/style-optimizer/.cloud-manifest.json +6 -0
- package/genes/style-optimizer/.gene-manifest.json +8 -0
- package/genes/style-optimizer/SKILL.md +285 -0
- package/genes/style-optimizer/phenotype.json +28 -0
- package/genes/tech-lead/.cloud-manifest.json +6 -0
- package/genes/tech-lead/.gene-manifest.json +8 -0
- package/genes/tech-lead/SKILL.md +451 -0
- package/genes/tech-lead/phenotype.json +28 -0
- package/genes/test-wrap/.cloud-manifest.json +6 -0
- package/genes/test-wrap/.gene-manifest.json +8 -0
- package/genes/test-wrap/phenotype.json +28 -0
- package/genes/testing-strategist/.cloud-manifest.json +6 -0
- package/genes/testing-strategist/.gene-manifest.json +8 -0
- package/genes/testing-strategist/SKILL.md +500 -0
- package/genes/testing-strategist/phenotype.json +28 -0
- package/genes/text-summarizer/.cloud-manifest.json +6 -0
- package/genes/text-summarizer/README.md +34 -0
- package/genes/text-summarizer/index.ts +122 -0
- package/genes/text-summarizer/phenotype.json +32 -0
- package/genes/tone-analyzer/.cloud-manifest.json +6 -0
- package/genes/tone-analyzer/.gene-manifest.json +8 -0
- package/genes/tone-analyzer/SKILL.md +410 -0
- package/genes/tone-analyzer/phenotype.json +28 -0
- package/genes/translator/.cloud-manifest.json +6 -0
- package/genes/translator/.gene-manifest.json +8 -0
- package/genes/translator/SKILL.md +355 -0
- package/genes/translator/phenotype.json +28 -0
- package/genes/ui-components/.cloud-manifest.json +6 -0
- package/genes/ui-components/.gene-manifest.json +8 -0
- package/genes/ui-components/SKILL.md +467 -0
- package/genes/ui-components/phenotype.json +28 -0
- package/genes/uiux-designer/.cloud-manifest.json +6 -0
- package/genes/uiux-designer/.gene-manifest.json +8 -0
- package/genes/uiux-designer/SKILL.md +353 -0
- package/genes/uiux-designer/phenotype.json +28 -0
- package/genes/url-extractor/.cloud-manifest.json +6 -0
- package/genes/url-extractor/README.md +37 -0
- package/genes/url-extractor/index.ts +86 -0
- package/genes/url-extractor/phenotype.json +48 -0
- package/genes/ux-patterns/.cloud-manifest.json +6 -0
- package/genes/ux-patterns/.gene-manifest.json +8 -0
- package/genes/ux-patterns/SKILL.md +872 -0
- package/genes/ux-patterns/phenotype.json +28 -0
- package/genes/web3-components/.cloud-manifest.json +6 -0
- package/genes/web3-components/.gene-manifest.json +8 -0
- package/genes/web3-components/SKILL.md +390 -0
- package/genes/web3-components/phenotype.json +28 -0
- package/package.json +6 -5
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: citation-manager
|
|
3
|
+
description: Manage academic citations and references. Format citations according to APA, MLA, Chicago, GB/T 7714 and other styles. Use when writing academic papers or any content requiring proper source attribution.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Citation Manager
|
|
7
|
+
|
|
8
|
+
**Goal**: Manage academic citations, ensuring proper formatting and accurate source attribution.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Citation Format Reference
|
|
13
|
+
|
|
14
|
+
### APA 7th Edition
|
|
15
|
+
|
|
16
|
+
```markdown
|
|
17
|
+
## Journal Article
|
|
18
|
+
Author, A. A., & Author, B. B. (Year). Title of article. Title of Periodical, volume(issue), page–page. https://doi.org/xxxxx
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
Smith, J. D., & Johnson, M. K. (2020). The impact of AI on education. Journal of Educational Technology, 15(3), 45-60. https://doi.org/10.1234/jet.2020.45
|
|
22
|
+
|
|
23
|
+
## Book
|
|
24
|
+
Author, A. A. (Year). Title of work: Capital letter also for subtitle. Publisher.
|
|
25
|
+
|
|
26
|
+
Example:
|
|
27
|
+
Brown, T. (2019). Machine learning fundamentals. Academic Press.
|
|
28
|
+
|
|
29
|
+
## Edited Book Chapter
|
|
30
|
+
Author, A. A. (Year). Title of chapter. In E. E. Editor (Ed.), Title of book (pp. xx–xx). Publisher.
|
|
31
|
+
|
|
32
|
+
## Web Page
|
|
33
|
+
Author, A. A. (Year, Month Day). Title of page. Site Name. URL
|
|
34
|
+
|
|
35
|
+
Example:
|
|
36
|
+
World Health Organization. (2023, March 15). COVID-19 guidelines. https://www.who.int/covid-19
|
|
37
|
+
|
|
38
|
+
## In-Text Citations
|
|
39
|
+
- Single author: (Smith, 2020) or Smith (2020)
|
|
40
|
+
- Two authors: (Smith & Jones, 2020)
|
|
41
|
+
- Three or more: (Smith et al., 2020)
|
|
42
|
+
- Direct quote: (Smith, 2020, p. 45)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### MLA 9th Edition
|
|
46
|
+
|
|
47
|
+
```markdown
|
|
48
|
+
## Journal Article
|
|
49
|
+
Last name, First name. "Title of Article." Journal Name, vol. #, no. #, Year, pp. #-#.
|
|
50
|
+
|
|
51
|
+
Example:
|
|
52
|
+
Smith, John. "The Future of AI." Technology Review, vol. 25, no. 3, 2020, pp. 45-60.
|
|
53
|
+
|
|
54
|
+
## Book
|
|
55
|
+
Last name, First name. Title of Book. Publisher, Year.
|
|
56
|
+
|
|
57
|
+
Example:
|
|
58
|
+
Brown, Thomas. Machine Learning Basics. Academic Press, 2019.
|
|
59
|
+
|
|
60
|
+
## Web Page
|
|
61
|
+
Author. "Title of Page." Website Name, Publisher, Day Month Year, URL.
|
|
62
|
+
|
|
63
|
+
## In-Text Citations
|
|
64
|
+
- (Smith 45)
|
|
65
|
+
- (Smith and Jones 45)
|
|
66
|
+
- Three or more: (Smith et al. 45)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Chicago 17th Edition
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
## Notes-Bibliography System
|
|
73
|
+
|
|
74
|
+
### Notes (Footnotes/Endnotes)
|
|
75
|
+
1. John Smith, Machine Learning (New York: Academic Press, 2020), 45.
|
|
76
|
+
|
|
77
|
+
### Bibliography
|
|
78
|
+
Smith, John. Machine Learning. New York: Academic Press, 2020.
|
|
79
|
+
|
|
80
|
+
## Author-Date System
|
|
81
|
+
|
|
82
|
+
### In-Text Citation
|
|
83
|
+
(Smith 2020, 45)
|
|
84
|
+
|
|
85
|
+
### Reference List
|
|
86
|
+
Smith, John. 2020. Machine Learning. New York: Academic Press.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 2. Format Conversion
|
|
92
|
+
|
|
93
|
+
### Format Comparison Table
|
|
94
|
+
|
|
95
|
+
| Element | APA | MLA | Chicago |
|
|
96
|
+
|---------|-----|-----|---------|
|
|
97
|
+
| Author separator | , & | , and | , and |
|
|
98
|
+
| Year position | After author | End | Varies |
|
|
99
|
+
| Title format | Sentence case | Title case | Title case |
|
|
100
|
+
| Journal name | Italic | Italic | Italic |
|
|
101
|
+
| Book title | Italic | Italic | Italic |
|
|
102
|
+
| Page numbers | p./pp. | pp. | varies |
|
|
103
|
+
|
|
104
|
+
### Common Conversions
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
## MLA → APA
|
|
108
|
+
|
|
109
|
+
MLA:
|
|
110
|
+
Smith, John. "The Future of AI." Tech Review, vol. 25, no. 3, 2020, pp. 45-60.
|
|
111
|
+
|
|
112
|
+
APA:
|
|
113
|
+
Smith, J. (2020). The future of AI. Tech Review, 25(3), 45-60.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 3. Citation Principles
|
|
119
|
+
|
|
120
|
+
### When to Cite
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
## Must Cite
|
|
124
|
+
|
|
125
|
+
1. Direct quotations
|
|
126
|
+
2. Paraphrased ideas from others
|
|
127
|
+
3. Data or charts from other sources
|
|
128
|
+
4. Research methods borrowed from others
|
|
129
|
+
5. Definitions and concepts from specific sources
|
|
130
|
+
|
|
131
|
+
## No Citation Needed
|
|
132
|
+
|
|
133
|
+
1. Your own original ideas
|
|
134
|
+
2. Common knowledge
|
|
135
|
+
3. Well-known facts
|
|
136
|
+
4. Personal experiences/observations
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Citation Types
|
|
140
|
+
|
|
141
|
+
```markdown
|
|
142
|
+
## Direct Quotation
|
|
143
|
+
|
|
144
|
+
Short quote (<40 words):
|
|
145
|
+
Research shows that "artificial intelligence will profoundly change education" (Smith, 2020, p. 45).
|
|
146
|
+
|
|
147
|
+
Long quote (≥40 words):
|
|
148
|
+
Indent as a separate block, no quotation marks.
|
|
149
|
+
|
|
150
|
+
## Paraphrase (Indirect Citation)
|
|
151
|
+
|
|
152
|
+
Smith (2020) argues that AI is transforming traditional educational models.
|
|
153
|
+
Research suggests that AI is changing education (Smith, 2020).
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 4. Reference Management
|
|
159
|
+
|
|
160
|
+
### Recommended Tools
|
|
161
|
+
|
|
162
|
+
| Tool | Features | Best For |
|
|
163
|
+
|------|----------|----------|
|
|
164
|
+
| Zotero | Free, open-source | Academic research |
|
|
165
|
+
| EndNote | Professional, powerful | Institutional users |
|
|
166
|
+
| Mendeley | Free, social features | Collaborative research |
|
|
167
|
+
| BibTeX | LaTeX integration | Computer science |
|
|
168
|
+
|
|
169
|
+
### Organization Principles
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
## File Naming
|
|
173
|
+
|
|
174
|
+
[Author][Year][Keyword].pdf
|
|
175
|
+
Example: Smith2020_AI_Education.pdf
|
|
176
|
+
|
|
177
|
+
## Classification Methods
|
|
178
|
+
|
|
179
|
+
1. By topic
|
|
180
|
+
2. By project
|
|
181
|
+
3. By year
|
|
182
|
+
4. Using tag systems
|
|
183
|
+
|
|
184
|
+
## Information to Record
|
|
185
|
+
|
|
186
|
+
- Complete bibliographic details
|
|
187
|
+
- Reading notes
|
|
188
|
+
- Citation relationships
|
|
189
|
+
- Key quotes and excerpts
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 5. Common Errors
|
|
195
|
+
|
|
196
|
+
### Format Errors
|
|
197
|
+
|
|
198
|
+
```markdown
|
|
199
|
+
## Common Issues
|
|
200
|
+
|
|
201
|
+
- Inconsistent author name formatting
|
|
202
|
+
- Year in wrong position
|
|
203
|
+
- Incorrect punctuation
|
|
204
|
+
- Missing italics
|
|
205
|
+
- Wrong page number format
|
|
206
|
+
- Incomplete DOI/URL
|
|
207
|
+
|
|
208
|
+
## Verification Points
|
|
209
|
+
|
|
210
|
+
1. Same format used consistently throughout
|
|
211
|
+
2. In-text citations match reference list
|
|
212
|
+
3. Entries ordered per style requirements
|
|
213
|
+
4. All required information is complete
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Citation Ethics
|
|
217
|
+
|
|
218
|
+
```markdown
|
|
219
|
+
## Academic Misconduct
|
|
220
|
+
|
|
221
|
+
- Fabricated citations (invented sources)
|
|
222
|
+
- Misquotation (distorting original meaning)
|
|
223
|
+
- Excessive citation (padding references)
|
|
224
|
+
- Excessive self-citation
|
|
225
|
+
- Unmarked secondary citations
|
|
226
|
+
|
|
227
|
+
## Best Practices
|
|
228
|
+
|
|
229
|
+
- Read original source before citing
|
|
230
|
+
- Accurately represent the original meaning
|
|
231
|
+
- Cite moderately
|
|
232
|
+
- Mark secondary sources properly
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 6. Checklist
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
## Citation Checklist
|
|
241
|
+
|
|
242
|
+
### Format
|
|
243
|
+
- [ ] Consistent style (APA/MLA/Chicago)
|
|
244
|
+
- [ ] Author names formatted correctly
|
|
245
|
+
- [ ] Dates/years correct
|
|
246
|
+
- [ ] Titles formatted correctly
|
|
247
|
+
- [ ] Publication info complete
|
|
248
|
+
|
|
249
|
+
### Correspondence
|
|
250
|
+
- [ ] Every in-text citation has a reference entry
|
|
251
|
+
- [ ] Every reference has at least one in-text citation
|
|
252
|
+
- [ ] Page numbers accurate (for direct quotes)
|
|
253
|
+
- [ ] Entries in correct order
|
|
254
|
+
|
|
255
|
+
### Completeness
|
|
256
|
+
- [ ] DOI/URL accessible
|
|
257
|
+
- [ ] No duplicate entries
|
|
258
|
+
- [ ] No missing citations
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Quick Reference
|
|
264
|
+
|
|
265
|
+
### Format Quick Lookup
|
|
266
|
+
|
|
267
|
+
| Style | In-Text | Reference Sorting |
|
|
268
|
+
|-------|---------|-------------------|
|
|
269
|
+
| APA | (Author, Year) | Alphabetical by author |
|
|
270
|
+
| MLA | (Author Page) | Alphabetical by author |
|
|
271
|
+
| Chicago Notes | Superscript number | Citation order |
|
|
272
|
+
|
|
273
|
+
### Universal Journal Article Template
|
|
274
|
+
|
|
275
|
+
```markdown
|
|
276
|
+
APA: Author. (Year). Title. Journal, Vol(Issue), Pages. DOI
|
|
277
|
+
MLA: Author. "Title." Journal, vol. #, no. #, Year, pp. #-#.
|
|
278
|
+
Chicago: Author. "Title." Journal Vol, no. # (Year): Pages.
|
|
279
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
interface Source {
|
|
2
|
+
type: "book" | "article" | "website" | "conference";
|
|
3
|
+
authors: string[];
|
|
4
|
+
title: string;
|
|
5
|
+
year: number;
|
|
6
|
+
journal?: string;
|
|
7
|
+
volume?: number;
|
|
8
|
+
issue?: number;
|
|
9
|
+
pages?: string;
|
|
10
|
+
publisher?: string;
|
|
11
|
+
url?: string;
|
|
12
|
+
accessDate?: string;
|
|
13
|
+
conference?: string;
|
|
14
|
+
doi?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface CitationInput {
|
|
18
|
+
sources: Source[];
|
|
19
|
+
style: "apa" | "mla" | "chicago";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface CitationOutput {
|
|
23
|
+
formatted: string[];
|
|
24
|
+
bibliography: string;
|
|
25
|
+
style: string;
|
|
26
|
+
sourceCount: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function formatAuthorsAPA(authors: string[]): string {
|
|
30
|
+
if (authors.length === 0) return "";
|
|
31
|
+
if (authors.length === 1) return invertName(authors[0]);
|
|
32
|
+
if (authors.length === 2) return `${invertName(authors[0])} & ${invertName(authors[1])}`;
|
|
33
|
+
if (authors.length <= 20) {
|
|
34
|
+
const all = authors.map(invertName);
|
|
35
|
+
return all.slice(0, -1).join(", ") + ", & " + all[all.length - 1];
|
|
36
|
+
}
|
|
37
|
+
return authors.slice(0, 19).map(invertName).join(", ") + ", ... " + invertName(authors[authors.length - 1]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function formatAuthorsMLA(authors: string[]): string {
|
|
41
|
+
if (authors.length === 0) return "";
|
|
42
|
+
if (authors.length === 1) return invertName(authors[0]);
|
|
43
|
+
if (authors.length === 2) return `${invertName(authors[0])}, and ${authors[1]}`;
|
|
44
|
+
return `${invertName(authors[0])}, et al.`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function formatAuthorsChicago(authors: string[]): string {
|
|
48
|
+
if (authors.length === 0) return "";
|
|
49
|
+
if (authors.length === 1) return invertName(authors[0]);
|
|
50
|
+
if (authors.length <= 3) {
|
|
51
|
+
const all = authors.map((a, i) => (i === 0 ? invertName(a) : a));
|
|
52
|
+
return all.slice(0, -1).join(", ") + ", and " + all[all.length - 1];
|
|
53
|
+
}
|
|
54
|
+
return `${invertName(authors[0])} et al.`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function invertName(name: string): string {
|
|
58
|
+
const parts = name.trim().split(/\s+/);
|
|
59
|
+
if (parts.length < 2) return name;
|
|
60
|
+
const last = parts.pop()!;
|
|
61
|
+
const initials = parts.map((p) => p[0].toUpperCase() + ".").join(" ");
|
|
62
|
+
return `${last}, ${initials}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function formatAPA(source: Source): string {
|
|
66
|
+
const authors = formatAuthorsAPA(source.authors);
|
|
67
|
+
const year = `(${source.year})`;
|
|
68
|
+
const title = source.title;
|
|
69
|
+
|
|
70
|
+
switch (source.type) {
|
|
71
|
+
case "book":
|
|
72
|
+
return `${authors} ${year}. *${title}*. ${source.publisher || ""}.`.replace(/\.\./g, ".");
|
|
73
|
+
case "article": {
|
|
74
|
+
const journal = source.journal ? `*${source.journal}*` : "";
|
|
75
|
+
const vol = source.volume ? `, *${source.volume}*` : "";
|
|
76
|
+
const iss = source.issue ? `(${source.issue})` : "";
|
|
77
|
+
const pages = source.pages ? `, ${source.pages}` : "";
|
|
78
|
+
const doi = source.doi ? ` https://doi.org/${source.doi}` : "";
|
|
79
|
+
return `${authors} ${year}. ${title}. ${journal}${vol}${iss}${pages}.${doi}`.replace(/\.\./g, ".");
|
|
80
|
+
}
|
|
81
|
+
case "website": {
|
|
82
|
+
const url = source.url ? ` ${source.url}` : "";
|
|
83
|
+
return `${authors} ${year}. ${title}.${url}`.replace(/\.\./g, ".");
|
|
84
|
+
}
|
|
85
|
+
case "conference":
|
|
86
|
+
return `${authors} ${year}. ${title}. In *${source.conference || "Proceedings"}*.`.replace(/\.\./g, ".");
|
|
87
|
+
default:
|
|
88
|
+
return `${authors} ${year}. ${title}.`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function formatMLA(source: Source): string {
|
|
93
|
+
const authors = formatAuthorsMLA(source.authors);
|
|
94
|
+
const title = `"${source.title}"`;
|
|
95
|
+
|
|
96
|
+
switch (source.type) {
|
|
97
|
+
case "book":
|
|
98
|
+
return `${authors}. *${source.title}*. ${source.publisher || ""}, ${source.year}.`.replace(/\.\./g, ".");
|
|
99
|
+
case "article": {
|
|
100
|
+
const journal = source.journal ? `*${source.journal}*` : "";
|
|
101
|
+
const vol = source.volume ? `, vol. ${source.volume}` : "";
|
|
102
|
+
const iss = source.issue ? `, no. ${source.issue}` : "";
|
|
103
|
+
const pages = source.pages ? `, pp. ${source.pages}` : "";
|
|
104
|
+
return `${authors}. ${title}. ${journal}${vol}${iss}, ${source.year}${pages}.`.replace(/\.\./g, ".");
|
|
105
|
+
}
|
|
106
|
+
case "website": {
|
|
107
|
+
const url = source.url || "";
|
|
108
|
+
const access = source.accessDate ? ` Accessed ${source.accessDate}.` : "";
|
|
109
|
+
return `${authors}. ${title}. ${source.year}. ${url}.${access}`.replace(/\.\./g, ".");
|
|
110
|
+
}
|
|
111
|
+
case "conference":
|
|
112
|
+
return `${authors}. ${title}. *${source.conference || "Conference"}*, ${source.year}.`.replace(/\.\./g, ".");
|
|
113
|
+
default:
|
|
114
|
+
return `${authors}. ${title}. ${source.year}.`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function formatChicago(source: Source): string {
|
|
119
|
+
const authors = formatAuthorsChicago(source.authors);
|
|
120
|
+
|
|
121
|
+
switch (source.type) {
|
|
122
|
+
case "book":
|
|
123
|
+
return `${authors}. *${source.title}*. ${source.publisher || ""}, ${source.year}.`.replace(/\.\./g, ".");
|
|
124
|
+
case "article": {
|
|
125
|
+
const journal = source.journal ? `*${source.journal}*` : "";
|
|
126
|
+
const vol = source.volume ? ` ${source.volume}` : "";
|
|
127
|
+
const iss = source.issue ? `, no. ${source.issue}` : "";
|
|
128
|
+
const pages = source.pages ? `: ${source.pages}` : "";
|
|
129
|
+
return `${authors}. "${source.title}." ${journal}${vol}${iss} (${source.year})${pages}.`.replace(/\.\./g, ".");
|
|
130
|
+
}
|
|
131
|
+
case "website": {
|
|
132
|
+
const url = source.url ? ` ${source.url}` : "";
|
|
133
|
+
const access = source.accessDate ? ` Accessed ${source.accessDate}.` : "";
|
|
134
|
+
return `${authors}. "${source.title}." ${source.year}.${url}.${access}`.replace(/\.\./g, ".");
|
|
135
|
+
}
|
|
136
|
+
case "conference":
|
|
137
|
+
return `${authors}. "${source.title}." In *${source.conference || "Proceedings"}*, ${source.year}.`.replace(/\.\./g, ".");
|
|
138
|
+
default:
|
|
139
|
+
return `${authors}. "${source.title}." ${source.year}.`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Citation Manager Gene
|
|
145
|
+
*
|
|
146
|
+
* Formats academic citations in APA, MLA, and Chicago styles.
|
|
147
|
+
* Pure string processing with no external dependencies.
|
|
148
|
+
*/
|
|
149
|
+
export async function express(input: CitationInput): Promise<CitationOutput> {
|
|
150
|
+
const sources = input.sources || [];
|
|
151
|
+
const style = input.style || "apa";
|
|
152
|
+
|
|
153
|
+
if (sources.length === 0) {
|
|
154
|
+
return { formatted: [], bibliography: "", style, sourceCount: 0 };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const formatter = style === "mla" ? formatMLA : style === "chicago" ? formatChicago : formatAPA;
|
|
158
|
+
const formatted = sources.map(formatter);
|
|
159
|
+
const bibliography = formatted.join("\n\n");
|
|
160
|
+
|
|
161
|
+
return { formatted, bibliography, style, sourceCount: sources.length };
|
|
162
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domain": "content.citation",
|
|
3
|
+
"description": "Manage academic citations and references. Format citations according to APA, MLA, Chicago, GB/T 7714 and other styles. Use when writing academic papers or any content requiring proper source attribution.",
|
|
4
|
+
"inputSchema": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"sources": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"type": { "type": "string", "enum": ["book", "article", "website", "conference"] },
|
|
13
|
+
"authors": { "type": "array", "items": { "type": "string" } },
|
|
14
|
+
"title": { "type": "string" },
|
|
15
|
+
"year": { "type": "number" },
|
|
16
|
+
"journal": { "type": "string" },
|
|
17
|
+
"volume": { "type": "number" },
|
|
18
|
+
"issue": { "type": "number" },
|
|
19
|
+
"pages": { "type": "string" },
|
|
20
|
+
"publisher": { "type": "string" },
|
|
21
|
+
"url": { "type": "string" },
|
|
22
|
+
"accessDate": { "type": "string" },
|
|
23
|
+
"conference": { "type": "string" },
|
|
24
|
+
"doi": { "type": "string" }
|
|
25
|
+
},
|
|
26
|
+
"required": ["type", "authors", "title", "year"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"style": { "type": "string", "enum": ["apa", "mla", "chicago"] }
|
|
30
|
+
},
|
|
31
|
+
"required": ["sources", "style"]
|
|
32
|
+
},
|
|
33
|
+
"outputSchema": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": {
|
|
36
|
+
"formatted": { "type": "array", "items": { "type": "string" } },
|
|
37
|
+
"bibliography": { "type": "string" },
|
|
38
|
+
"style": { "type": "string" },
|
|
39
|
+
"sourceCount": { "type": "number" }
|
|
40
|
+
},
|
|
41
|
+
"required": ["formatted", "bibliography", "style", "sourceCount"]
|
|
42
|
+
},
|
|
43
|
+
"dependencies": [],
|
|
44
|
+
"version": "0.2.0",
|
|
45
|
+
"author": "rotifer-team",
|
|
46
|
+
"createdAt": 1771939404211,
|
|
47
|
+
"fidelity": "Native",
|
|
48
|
+
"transparency": "Open",
|
|
49
|
+
"source": "skill"
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# code-complexity
|
|
2
|
+
|
|
3
|
+
A Native Gene that measures source code complexity using industry-standard metrics.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
rotifer test code-complexity --input '{
|
|
9
|
+
"code": "function example(x) {\n if (x > 0) {\n for (let i = 0; i < x; i++) {\n if (i % 2 === 0) console.log(i);\n }\n }\n}",
|
|
10
|
+
"language": "javascript",
|
|
11
|
+
"threshold": 10
|
|
12
|
+
}'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Metrics
|
|
16
|
+
|
|
17
|
+
| Metric | Description |
|
|
18
|
+
|--------|-------------|
|
|
19
|
+
| **Cyclomatic Complexity** | McCabe's complexity — number of independent paths through code |
|
|
20
|
+
| **Lines of Code** | Non-blank, non-comment lines |
|
|
21
|
+
| **Max Nesting Depth** | Deepest level of nested control structures |
|
|
22
|
+
| **Function Count** | Number of functions/methods |
|
|
23
|
+
|
|
24
|
+
## Rating Scale
|
|
25
|
+
|
|
26
|
+
| Score | Rating | Meaning |
|
|
27
|
+
|-------|--------|---------|
|
|
28
|
+
| 1-5 | Low | Simple, easy to maintain |
|
|
29
|
+
| 6-10 | Moderate | Manageable complexity |
|
|
30
|
+
| 11-20 | High | Consider refactoring |
|
|
31
|
+
| 21+ | Very High | Refactoring strongly recommended |
|
|
32
|
+
|
|
33
|
+
## Supported Languages
|
|
34
|
+
|
|
35
|
+
TypeScript, JavaScript, Python, Rust, Go
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
interface ComplexityInput {
|
|
2
|
+
code: string;
|
|
3
|
+
language: string;
|
|
4
|
+
threshold?: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface ComplexityOutput {
|
|
8
|
+
cyclomaticComplexity: number;
|
|
9
|
+
linesOfCode: number;
|
|
10
|
+
maxNestingDepth: number;
|
|
11
|
+
functionCount: number;
|
|
12
|
+
rating: "low" | "moderate" | "high" | "very-high";
|
|
13
|
+
suggestions: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const BRANCH_PATTERNS: Record<string, RegExp[]> = {
|
|
17
|
+
typescript: [/\bif\b/g, /\belse\s+if\b/g, /\bwhile\b/g, /\bfor\b/g, /\bcase\b/g, /\bcatch\b/g, /\b\?\?/g, /\?\./g, /&&/g, /\|\|/g, /\?[^?:]/g],
|
|
18
|
+
javascript: [/\bif\b/g, /\belse\s+if\b/g, /\bwhile\b/g, /\bfor\b/g, /\bcase\b/g, /\bcatch\b/g, /\b\?\?/g, /\?\./g, /&&/g, /\|\|/g, /\?[^?:]/g],
|
|
19
|
+
python: [/\bif\b/g, /\belif\b/g, /\bwhile\b/g, /\bfor\b/g, /\bexcept\b/g, /\band\b/g, /\bor\b/g],
|
|
20
|
+
rust: [/\bif\b/g, /\belse\s+if\b/g, /\bwhile\b/g, /\bfor\b/g, /\bmatch\b/g, /=>/g, /&&/g, /\|\|/g],
|
|
21
|
+
go: [/\bif\b/g, /\belse\s+if\b/g, /\bfor\b/g, /\bcase\b/g, /&&/g, /\|\|/g],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const FUNC_PATTERNS: Record<string, RegExp> = {
|
|
25
|
+
typescript: /\b(?:function\b|=>|(?:async\s+)?(?:get|set)\s+\w+\s*\()/g,
|
|
26
|
+
javascript: /\b(?:function\b|=>)/g,
|
|
27
|
+
python: /\bdef\s+/g,
|
|
28
|
+
rust: /\bfn\s+/g,
|
|
29
|
+
go: /\bfunc\s+/g,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function stripComments(code: string, lang: string): string {
|
|
33
|
+
if (lang === "python") {
|
|
34
|
+
return code.replace(/#.*/g, "").replace(/"""[\s\S]*?"""/g, "").replace(/'''[\s\S]*?'''/g, "");
|
|
35
|
+
}
|
|
36
|
+
return code.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function countNesting(code: string, lang: string): number {
|
|
40
|
+
if (lang === "python") {
|
|
41
|
+
let max = 0;
|
|
42
|
+
for (const line of code.split("\n")) {
|
|
43
|
+
const indent = line.match(/^(\s*)/)?.[1].length ?? 0;
|
|
44
|
+
const level = Math.floor(indent / 4);
|
|
45
|
+
if (level > max) max = level;
|
|
46
|
+
}
|
|
47
|
+
return max;
|
|
48
|
+
}
|
|
49
|
+
let max = 0, cur = 0;
|
|
50
|
+
for (const ch of code) {
|
|
51
|
+
if (ch === "{") { cur++; if (cur > max) max = cur; }
|
|
52
|
+
else if (ch === "}") { cur = Math.max(0, cur - 1); }
|
|
53
|
+
}
|
|
54
|
+
return max;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function express(input: ComplexityInput): Promise<ComplexityOutput> {
|
|
58
|
+
const code = input.code || "";
|
|
59
|
+
const lang = (input.language || "javascript").toLowerCase();
|
|
60
|
+
const threshold = input.threshold ?? 10;
|
|
61
|
+
|
|
62
|
+
const stripped = stripComments(code, lang);
|
|
63
|
+
const lines = stripped.split("\n").filter((l) => l.trim().length > 0);
|
|
64
|
+
const linesOfCode = lines.length;
|
|
65
|
+
|
|
66
|
+
const patterns = BRANCH_PATTERNS[lang] || BRANCH_PATTERNS.javascript;
|
|
67
|
+
let branches = 0;
|
|
68
|
+
for (const pat of patterns) {
|
|
69
|
+
const re = new RegExp(pat.source, pat.flags);
|
|
70
|
+
let m: RegExpExecArray | null;
|
|
71
|
+
while ((m = re.exec(stripped)) !== null) branches++;
|
|
72
|
+
}
|
|
73
|
+
const cyclomaticComplexity = branches + 1;
|
|
74
|
+
|
|
75
|
+
const funcPat = FUNC_PATTERNS[lang] || FUNC_PATTERNS.javascript;
|
|
76
|
+
const funcRe = new RegExp(funcPat.source, funcPat.flags);
|
|
77
|
+
let functionCount = 0;
|
|
78
|
+
while (funcRe.exec(stripped) !== null) functionCount++;
|
|
79
|
+
if (functionCount === 0) functionCount = 1;
|
|
80
|
+
|
|
81
|
+
const maxNestingDepth = countNesting(stripped, lang);
|
|
82
|
+
|
|
83
|
+
let rating: ComplexityOutput["rating"];
|
|
84
|
+
if (cyclomaticComplexity <= 5) rating = "low";
|
|
85
|
+
else if (cyclomaticComplexity <= 10) rating = "moderate";
|
|
86
|
+
else if (cyclomaticComplexity <= 20) rating = "high";
|
|
87
|
+
else rating = "very-high";
|
|
88
|
+
|
|
89
|
+
const suggestions: string[] = [];
|
|
90
|
+
if (cyclomaticComplexity > threshold) {
|
|
91
|
+
suggestions.push(`Cyclomatic complexity (${cyclomaticComplexity}) exceeds threshold (${threshold}). Consider splitting into smaller functions.`);
|
|
92
|
+
}
|
|
93
|
+
if (maxNestingDepth > 4) {
|
|
94
|
+
suggestions.push(`Max nesting depth is ${maxNestingDepth}. Consider early returns or extracting nested logic.`);
|
|
95
|
+
}
|
|
96
|
+
if (linesOfCode > 200) {
|
|
97
|
+
suggestions.push(`File has ${linesOfCode} lines. Consider splitting into multiple modules.`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return { cyclomaticComplexity, linesOfCode, maxNestingDepth, functionCount, rating, suggestions };
|
|
101
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domain": "code.analyze",
|
|
3
|
+
"description": "Analyzes source code complexity using cyclomatic complexity, lines of code, and nesting depth metrics.",
|
|
4
|
+
"inputSchema": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"code": { "type": "string", "description": "Source code to analyze" },
|
|
8
|
+
"language": { "type": "string", "description": "Programming language", "enum": ["typescript", "javascript", "python", "rust", "go"] },
|
|
9
|
+
"threshold": { "type": "number", "description": "Complexity threshold for warnings", "default": 10 }
|
|
10
|
+
},
|
|
11
|
+
"required": ["code", "language"]
|
|
12
|
+
},
|
|
13
|
+
"outputSchema": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"cyclomaticComplexity": { "type": "number", "description": "McCabe cyclomatic complexity score" },
|
|
17
|
+
"linesOfCode": { "type": "number", "description": "Non-blank, non-comment lines" },
|
|
18
|
+
"maxNestingDepth": { "type": "number", "description": "Maximum nesting depth of control structures" },
|
|
19
|
+
"functionCount": { "type": "number", "description": "Number of functions/methods found" },
|
|
20
|
+
"rating": { "type": "string", "description": "Complexity rating", "enum": ["low", "moderate", "high", "very-high"] },
|
|
21
|
+
"suggestions": { "type": "array", "items": { "type": "string" }, "description": "Improvement suggestions if complexity is high" }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dependencies": [],
|
|
25
|
+
"version": "0.1.0",
|
|
26
|
+
"author": "rotifer-genesis",
|
|
27
|
+
"fidelity": "Native",
|
|
28
|
+
"transparency": "Open",
|
|
29
|
+
"semantic_requirements": {
|
|
30
|
+
"timeModel": "Sync",
|
|
31
|
+
"concurrencyModel": "Stateless",
|
|
32
|
+
"failureSemantics": "Fail"
|
|
33
|
+
}
|
|
34
|
+
}
|