@jaimevalasek/aioson 1.3.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 (288) hide show
  1. package/CHANGELOG.md +456 -0
  2. package/CODE_OF_CONDUCT.md +12 -0
  3. package/CONTRIBUTING.md +13 -0
  4. package/LICENSE +21 -0
  5. package/README.md +254 -0
  6. package/bin/aioson.js +4 -0
  7. package/docs/en/cli-reference.md +398 -0
  8. package/docs/en/i18n.md +52 -0
  9. package/docs/en/json-schemas.md +41 -0
  10. package/docs/en/mcp.md +56 -0
  11. package/docs/en/parallel.md +82 -0
  12. package/docs/en/qa-browser.md +339 -0
  13. package/docs/en/release-flow.md +22 -0
  14. package/docs/en/release-notes-template.md +41 -0
  15. package/docs/en/release.md +28 -0
  16. package/docs/en/schemas/agent-prompt.schema.json +17 -0
  17. package/docs/en/schemas/agents.schema.json +32 -0
  18. package/docs/en/schemas/context-validate.schema.json +36 -0
  19. package/docs/en/schemas/doctor.schema.json +89 -0
  20. package/docs/en/schemas/error.schema.json +24 -0
  21. package/docs/en/schemas/i18n-add.schema.json +15 -0
  22. package/docs/en/schemas/index.json +116 -0
  23. package/docs/en/schemas/info.schema.json +39 -0
  24. package/docs/en/schemas/init.schema.json +48 -0
  25. package/docs/en/schemas/install.schema.json +60 -0
  26. package/docs/en/schemas/locale-apply.schema.json +30 -0
  27. package/docs/en/schemas/mcp-doctor.schema.json +95 -0
  28. package/docs/en/schemas/mcp-init.schema.json +122 -0
  29. package/docs/en/schemas/package-test.schema.json +24 -0
  30. package/docs/en/schemas/parallel-assign.schema.json +57 -0
  31. package/docs/en/schemas/parallel-doctor.schema.json +86 -0
  32. package/docs/en/schemas/parallel-init.schema.json +53 -0
  33. package/docs/en/schemas/parallel-status.schema.json +94 -0
  34. package/docs/en/schemas/setup-context.schema.json +39 -0
  35. package/docs/en/schemas/smoke.schema.json +23 -0
  36. package/docs/en/schemas/update.schema.json +48 -0
  37. package/docs/en/schemas/workflow-plan.schema.json +30 -0
  38. package/docs/en/web3.md +54 -0
  39. package/docs/pt/README.md +46 -0
  40. package/docs/pt/advisor-spec.md +335 -0
  41. package/docs/pt/agentes.md +453 -0
  42. package/docs/pt/cenarios.md +1230 -0
  43. package/docs/pt/clientes-ai.md +224 -0
  44. package/docs/pt/comandos-cli.md +511 -0
  45. package/docs/pt/genome-3.0-spec.md +296 -0
  46. package/docs/pt/guia-engineer.md +226 -0
  47. package/docs/pt/inicio-rapido.md +138 -0
  48. package/docs/pt/profiler-system.md +214 -0
  49. package/docs/pt/runtime-observability.md +72 -0
  50. package/docs/pt/squad-genoma.md +777 -0
  51. package/docs/pt/web3.md +797 -0
  52. package/docs/testing/genome-2.0-manual-regression.md +23 -0
  53. package/docs/testing/genome-2.0-matrix.md +36 -0
  54. package/docs/testing/genome-2.0-rollout.md +184 -0
  55. package/package.json +50 -0
  56. package/src/agents.js +56 -0
  57. package/src/cli.js +497 -0
  58. package/src/commands/agents.js +142 -0
  59. package/src/commands/cloud.js +1767 -0
  60. package/src/commands/config.js +90 -0
  61. package/src/commands/context-validate.js +91 -0
  62. package/src/commands/doctor.js +123 -0
  63. package/src/commands/genome-doctor.js +41 -0
  64. package/src/commands/genome-migrate.js +49 -0
  65. package/src/commands/i18n-add.js +56 -0
  66. package/src/commands/info.js +41 -0
  67. package/src/commands/init.js +75 -0
  68. package/src/commands/install.js +68 -0
  69. package/src/commands/locale-apply.js +51 -0
  70. package/src/commands/locale-diff.js +126 -0
  71. package/src/commands/mcp-doctor.js +406 -0
  72. package/src/commands/mcp-init.js +379 -0
  73. package/src/commands/package-e2e.js +273 -0
  74. package/src/commands/parallel-assign.js +403 -0
  75. package/src/commands/parallel-doctor.js +437 -0
  76. package/src/commands/parallel-init.js +249 -0
  77. package/src/commands/parallel-status.js +290 -0
  78. package/src/commands/qa-doctor.js +185 -0
  79. package/src/commands/qa-init.js +161 -0
  80. package/src/commands/qa-report.js +58 -0
  81. package/src/commands/qa-run.js +873 -0
  82. package/src/commands/qa-scan.js +337 -0
  83. package/src/commands/runtime.js +948 -0
  84. package/src/commands/scan-project.js +1107 -0
  85. package/src/commands/setup-context.js +650 -0
  86. package/src/commands/smoke.js +426 -0
  87. package/src/commands/squad-doctor.js +358 -0
  88. package/src/commands/squad-export.js +46 -0
  89. package/src/commands/squad-pipeline.js +97 -0
  90. package/src/commands/squad-repair-genomes.js +39 -0
  91. package/src/commands/squad-status.js +424 -0
  92. package/src/commands/squad-validate.js +230 -0
  93. package/src/commands/test-agents.js +194 -0
  94. package/src/commands/update.js +55 -0
  95. package/src/commands/workflow-next.js +594 -0
  96. package/src/commands/workflow-plan.js +108 -0
  97. package/src/constants.js +314 -0
  98. package/src/context-parse-reason.js +22 -0
  99. package/src/context-writer.js +150 -0
  100. package/src/context.js +217 -0
  101. package/src/detector.js +261 -0
  102. package/src/doctor.js +289 -0
  103. package/src/execution-gateway.js +461 -0
  104. package/src/genome-files.js +198 -0
  105. package/src/genome-format.js +442 -0
  106. package/src/genome-schema.js +215 -0
  107. package/src/genomes/bindings.js +281 -0
  108. package/src/genomes.js +467 -0
  109. package/src/i18n/index.js +103 -0
  110. package/src/i18n/messages/en.js +784 -0
  111. package/src/i18n/messages/es.js +718 -0
  112. package/src/i18n/messages/fr.js +725 -0
  113. package/src/i18n/messages/pt-BR.js +818 -0
  114. package/src/i18n/scaffold.js +64 -0
  115. package/src/installer.js +232 -0
  116. package/src/lib/genomes/compat.js +206 -0
  117. package/src/lib/genomes/migrate.js +90 -0
  118. package/src/lib/squads/genome-repair.js +49 -0
  119. package/src/locales.js +84 -0
  120. package/src/onboarding.js +305 -0
  121. package/src/parser.js +53 -0
  122. package/src/prompt-tool.js +20 -0
  123. package/src/qa-html-report.js +472 -0
  124. package/src/runtime-store.js +1527 -0
  125. package/src/squads/apply-genome.js +21 -0
  126. package/src/squads/genome-binding-service.js +154 -0
  127. package/src/updater.js +32 -0
  128. package/src/utils.js +46 -0
  129. package/src/version.js +50 -0
  130. package/template/.aioson/advisors/.gitkeep +1 -0
  131. package/template/.aioson/agents/analyst.md +225 -0
  132. package/template/.aioson/agents/architect.md +221 -0
  133. package/template/.aioson/agents/dev.md +201 -0
  134. package/template/.aioson/agents/discovery-design-doc.md +196 -0
  135. package/template/.aioson/agents/genoma.md +300 -0
  136. package/template/.aioson/agents/orchestrator.md +107 -0
  137. package/template/.aioson/agents/pm.md +89 -0
  138. package/template/.aioson/agents/product.md +361 -0
  139. package/template/.aioson/agents/profiler-enricher.md +266 -0
  140. package/template/.aioson/agents/profiler-forge.md +188 -0
  141. package/template/.aioson/agents/profiler-researcher.md +245 -0
  142. package/template/.aioson/agents/qa.md +344 -0
  143. package/template/.aioson/agents/setup.md +381 -0
  144. package/template/.aioson/agents/squad.md +837 -0
  145. package/template/.aioson/agents/ux-ui.md +416 -0
  146. package/template/.aioson/config.md +56 -0
  147. package/template/.aioson/context/.gitkeep +0 -0
  148. package/template/.aioson/context/parallel/.gitkeep +0 -0
  149. package/template/.aioson/context/spec.md.template +37 -0
  150. package/template/.aioson/genomas/.gitkeep +0 -0
  151. package/template/.aioson/locales/en/agents/analyst.md +214 -0
  152. package/template/.aioson/locales/en/agents/architect.md +210 -0
  153. package/template/.aioson/locales/en/agents/dev.md +187 -0
  154. package/template/.aioson/locales/en/agents/discovery-design-doc.md +27 -0
  155. package/template/.aioson/locales/en/agents/genoma.md +212 -0
  156. package/template/.aioson/locales/en/agents/orchestrator.md +105 -0
  157. package/template/.aioson/locales/en/agents/pm.md +77 -0
  158. package/template/.aioson/locales/en/agents/product.md +310 -0
  159. package/template/.aioson/locales/en/agents/profiler-enricher.md +5 -0
  160. package/template/.aioson/locales/en/agents/profiler-forge.md +5 -0
  161. package/template/.aioson/locales/en/agents/profiler-researcher.md +5 -0
  162. package/template/.aioson/locales/en/agents/qa.md +214 -0
  163. package/template/.aioson/locales/en/agents/setup.md +342 -0
  164. package/template/.aioson/locales/en/agents/squad.md +247 -0
  165. package/template/.aioson/locales/en/agents/ux-ui.md +320 -0
  166. package/template/.aioson/locales/es/agents/analyst.md +203 -0
  167. package/template/.aioson/locales/es/agents/architect.md +208 -0
  168. package/template/.aioson/locales/es/agents/dev.md +183 -0
  169. package/template/.aioson/locales/es/agents/discovery-design-doc.md +19 -0
  170. package/template/.aioson/locales/es/agents/genoma.md +102 -0
  171. package/template/.aioson/locales/es/agents/orchestrator.md +108 -0
  172. package/template/.aioson/locales/es/agents/pm.md +81 -0
  173. package/template/.aioson/locales/es/agents/product.md +310 -0
  174. package/template/.aioson/locales/es/agents/profiler-enricher.md +5 -0
  175. package/template/.aioson/locales/es/agents/profiler-forge.md +5 -0
  176. package/template/.aioson/locales/es/agents/profiler-researcher.md +5 -0
  177. package/template/.aioson/locales/es/agents/qa.md +163 -0
  178. package/template/.aioson/locales/es/agents/setup.md +347 -0
  179. package/template/.aioson/locales/es/agents/squad.md +247 -0
  180. package/template/.aioson/locales/es/agents/ux-ui.md +201 -0
  181. package/template/.aioson/locales/fr/agents/analyst.md +203 -0
  182. package/template/.aioson/locales/fr/agents/architect.md +208 -0
  183. package/template/.aioson/locales/fr/agents/dev.md +183 -0
  184. package/template/.aioson/locales/fr/agents/discovery-design-doc.md +19 -0
  185. package/template/.aioson/locales/fr/agents/genoma.md +102 -0
  186. package/template/.aioson/locales/fr/agents/orchestrator.md +108 -0
  187. package/template/.aioson/locales/fr/agents/pm.md +81 -0
  188. package/template/.aioson/locales/fr/agents/product.md +310 -0
  189. package/template/.aioson/locales/fr/agents/profiler-enricher.md +5 -0
  190. package/template/.aioson/locales/fr/agents/profiler-forge.md +5 -0
  191. package/template/.aioson/locales/fr/agents/profiler-researcher.md +5 -0
  192. package/template/.aioson/locales/fr/agents/qa.md +163 -0
  193. package/template/.aioson/locales/fr/agents/setup.md +347 -0
  194. package/template/.aioson/locales/fr/agents/squad.md +247 -0
  195. package/template/.aioson/locales/fr/agents/ux-ui.md +201 -0
  196. package/template/.aioson/locales/pt-BR/agents/analyst.md +217 -0
  197. package/template/.aioson/locales/pt-BR/agents/architect.md +213 -0
  198. package/template/.aioson/locales/pt-BR/agents/dev.md +198 -0
  199. package/template/.aioson/locales/pt-BR/agents/discovery-design-doc.md +198 -0
  200. package/template/.aioson/locales/pt-BR/agents/genoma.md +297 -0
  201. package/template/.aioson/locales/pt-BR/agents/orchestrator.md +108 -0
  202. package/template/.aioson/locales/pt-BR/agents/pm.md +81 -0
  203. package/template/.aioson/locales/pt-BR/agents/product.md +316 -0
  204. package/template/.aioson/locales/pt-BR/agents/profiler-enricher.md +5 -0
  205. package/template/.aioson/locales/pt-BR/agents/profiler-forge.md +5 -0
  206. package/template/.aioson/locales/pt-BR/agents/profiler-researcher.md +5 -0
  207. package/template/.aioson/locales/pt-BR/agents/qa.md +217 -0
  208. package/template/.aioson/locales/pt-BR/agents/setup.md +371 -0
  209. package/template/.aioson/locales/pt-BR/agents/squad.md +772 -0
  210. package/template/.aioson/locales/pt-BR/agents/ux-ui.md +322 -0
  211. package/template/.aioson/mcp/servers.md +24 -0
  212. package/template/.aioson/profiler-reports/.gitkeep +1 -0
  213. package/template/.aioson/schemas/content-blueprint.schema.json +30 -0
  214. package/template/.aioson/schemas/genome-meta.schema.json +150 -0
  215. package/template/.aioson/schemas/genome.schema.json +115 -0
  216. package/template/.aioson/schemas/readiness.schema.json +27 -0
  217. package/template/.aioson/schemas/squad-blueprint.schema.json +172 -0
  218. package/template/.aioson/schemas/squad-manifest.schema.json +276 -0
  219. package/template/.aioson/skills/dynamic/README.md +30 -0
  220. package/template/.aioson/skills/dynamic/cardano-docs.md +16 -0
  221. package/template/.aioson/skills/dynamic/ethereum-docs.md +17 -0
  222. package/template/.aioson/skills/dynamic/flux-ui-docs.md +13 -0
  223. package/template/.aioson/skills/dynamic/laravel-docs.md +41 -0
  224. package/template/.aioson/skills/dynamic/npm-packages.md +16 -0
  225. package/template/.aioson/skills/dynamic/solana-docs.md +16 -0
  226. package/template/.aioson/skills/references/premium-command-center-ui/master-application-prompt.md +79 -0
  227. package/template/.aioson/skills/references/premium-command-center-ui/operational-ux-playbook.md +253 -0
  228. package/template/.aioson/skills/references/premium-command-center-ui/quality-validation-checklist.md +82 -0
  229. package/template/.aioson/skills/references/premium-command-center-ui/visual-system-and-component-patterns.md +270 -0
  230. package/template/.aioson/skills/static/django-patterns.md +342 -0
  231. package/template/.aioson/skills/static/fastapi-patterns.md +344 -0
  232. package/template/.aioson/skills/static/filament-patterns.md +267 -0
  233. package/template/.aioson/skills/static/flux-ui-components.md +262 -0
  234. package/template/.aioson/skills/static/git-conventions.md +227 -0
  235. package/template/.aioson/skills/static/interface-design.md +372 -0
  236. package/template/.aioson/skills/static/jetstream-setup.md +200 -0
  237. package/template/.aioson/skills/static/laravel-conventions.md +491 -0
  238. package/template/.aioson/skills/static/nextjs-patterns.md +321 -0
  239. package/template/.aioson/skills/static/node-express-patterns.md +317 -0
  240. package/template/.aioson/skills/static/node-typescript-patterns.md +282 -0
  241. package/template/.aioson/skills/static/premium-command-center-ui.md +190 -0
  242. package/template/.aioson/skills/static/rails-conventions.md +307 -0
  243. package/template/.aioson/skills/static/react-motion-patterns.md +577 -0
  244. package/template/.aioson/skills/static/static-html-patterns.md +1935 -0
  245. package/template/.aioson/skills/static/tall-stack-patterns.md +286 -0
  246. package/template/.aioson/skills/static/ui-ux-modern.md +75 -0
  247. package/template/.aioson/skills/static/web3-cardano-patterns.md +337 -0
  248. package/template/.aioson/skills/static/web3-ethereum-patterns.md +310 -0
  249. package/template/.aioson/skills/static/web3-security-checklist.md +284 -0
  250. package/template/.aioson/skills/static/web3-solana-patterns.md +324 -0
  251. package/template/.aioson/squads/.artisan/.gitkeep +0 -0
  252. package/template/.aioson/squads/.gitkeep +0 -0
  253. package/template/.aioson/squads/memory.md +5 -0
  254. package/template/.aioson/tasks/squad-analyze.md +83 -0
  255. package/template/.aioson/tasks/squad-create.md +99 -0
  256. package/template/.aioson/tasks/squad-design.md +100 -0
  257. package/template/.aioson/tasks/squad-export.md +20 -0
  258. package/template/.aioson/tasks/squad-extend.md +68 -0
  259. package/template/.aioson/tasks/squad-pipeline.md +122 -0
  260. package/template/.aioson/tasks/squad-repair.md +85 -0
  261. package/template/.aioson/tasks/squad-validate.md +58 -0
  262. package/template/.aioson/templates/squads/content-basic/template.json +21 -0
  263. package/template/.aioson/templates/squads/media-channel/template.json +24 -0
  264. package/template/.aioson/templates/squads/research-analysis/template.json +22 -0
  265. package/template/.aioson/templates/squads/software-delivery/template.json +21 -0
  266. package/template/.claude/commands/aioson/analyst.md +5 -0
  267. package/template/.claude/commands/aioson/architect.md +5 -0
  268. package/template/.claude/commands/aioson/dev.md +5 -0
  269. package/template/.claude/commands/aioson/orchestrator.md +5 -0
  270. package/template/.claude/commands/aioson/pm.md +5 -0
  271. package/template/.claude/commands/aioson/qa.md +5 -0
  272. package/template/.claude/commands/aioson/setup.md +5 -0
  273. package/template/.claude/commands/aioson/ux-ui.md +5 -0
  274. package/template/.gemini/GEMINI.md +10 -0
  275. package/template/.gemini/commands/aios-analyst.toml +4 -0
  276. package/template/.gemini/commands/aios-architect.toml +7 -0
  277. package/template/.gemini/commands/aios-dev.toml +8 -0
  278. package/template/.gemini/commands/aios-discovery-design-doc.toml +4 -0
  279. package/template/.gemini/commands/aios-orchestrator.toml +8 -0
  280. package/template/.gemini/commands/aios-pm.toml +8 -0
  281. package/template/.gemini/commands/aios-product.toml +4 -0
  282. package/template/.gemini/commands/aios-qa.toml +6 -0
  283. package/template/.gemini/commands/aios-setup.toml +3 -0
  284. package/template/.gemini/commands/aios-ux-ui.toml +8 -0
  285. package/template/AGENTS.md +67 -0
  286. package/template/CLAUDE.md +31 -0
  287. package/template/OPENCODE.md +24 -0
  288. package/template/aioson-models.json +40 -0
package/src/context.js ADDED
@@ -0,0 +1,217 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs/promises');
4
+ const path = require('node:path');
5
+ const {
6
+ CONTEXT_REQUIRED_FIELDS,
7
+ CONTEXT_ALLOWED_CLASSIFICATIONS,
8
+ CONTEXT_ALLOWED_PROJECT_TYPES,
9
+ CONTEXT_ALLOWED_PROFILES
10
+ } = require('./constants');
11
+ const { exists } = require('./utils');
12
+
13
+ function stripOuterQuotes(value) {
14
+ const text = String(value || '').trim();
15
+ if (
16
+ (text.startsWith('"') && text.endsWith('"')) ||
17
+ (text.startsWith("'") && text.endsWith("'"))
18
+ ) {
19
+ return text.slice(1, -1);
20
+ }
21
+ return text;
22
+ }
23
+
24
+ function parseScalar(value) {
25
+ const text = stripOuterQuotes(value);
26
+ if (text === 'true') return true;
27
+ if (text === 'false') return false;
28
+ return text;
29
+ }
30
+
31
+ function parseYamlFrontmatter(markdown) {
32
+ const text = String(markdown || '');
33
+ if (!text.startsWith('---\n') && !text.startsWith('---\r\n')) {
34
+ return {
35
+ ok: false,
36
+ data: null,
37
+ reason: 'missing_frontmatter'
38
+ };
39
+ }
40
+
41
+ const lines = text.split(/\r?\n/);
42
+ let closingIndex = -1;
43
+ for (let i = 1; i < lines.length; i += 1) {
44
+ if (lines[i].trim() === '---') {
45
+ closingIndex = i;
46
+ break;
47
+ }
48
+ }
49
+
50
+ if (closingIndex === -1) {
51
+ return {
52
+ ok: false,
53
+ data: null,
54
+ reason: 'unclosed_frontmatter'
55
+ };
56
+ }
57
+
58
+ const data = {};
59
+ for (let i = 1; i < closingIndex; i += 1) {
60
+ const line = lines[i].trim();
61
+ if (!line || line.startsWith('#')) continue;
62
+
63
+ const match = line.match(/^([a-zA-Z0-9_]+)\s*:\s*(.*)$/);
64
+ if (!match) {
65
+ return {
66
+ ok: false,
67
+ data: null,
68
+ reason: 'invalid_frontmatter_line',
69
+ line
70
+ };
71
+ }
72
+
73
+ const key = match[1];
74
+ const rawValue = match[2];
75
+ data[key] = parseScalar(rawValue);
76
+ }
77
+
78
+ return {
79
+ ok: true,
80
+ data
81
+ };
82
+ }
83
+
84
+ function isValidLanguageTag(value) {
85
+ const tag = String(value || '').trim();
86
+ return /^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/.test(tag);
87
+ }
88
+
89
+ function validateContextData(data) {
90
+ const issues = [];
91
+
92
+ for (const key of CONTEXT_REQUIRED_FIELDS) {
93
+ if (!Object.prototype.hasOwnProperty.call(data, key)) {
94
+ issues.push({
95
+ id: `context:missing:${key}`,
96
+ key: 'doctor.context_required_field',
97
+ params: { field: key },
98
+ hintKey: 'doctor.context_required_field_hint'
99
+ });
100
+ }
101
+ }
102
+
103
+ if (
104
+ Object.prototype.hasOwnProperty.call(data, 'framework_installed') &&
105
+ typeof data.framework_installed !== 'boolean'
106
+ ) {
107
+ issues.push({
108
+ id: 'context:framework_installed:type',
109
+ key: 'doctor.context_framework_installed_type',
110
+ params: {},
111
+ hintKey: 'doctor.context_framework_installed_type_hint'
112
+ });
113
+ }
114
+
115
+ if (
116
+ Object.prototype.hasOwnProperty.call(data, 'classification') &&
117
+ !CONTEXT_ALLOWED_CLASSIFICATIONS.includes(String(data.classification))
118
+ ) {
119
+ issues.push({
120
+ id: 'context:classification:value',
121
+ key: 'doctor.context_classification_value',
122
+ params: { expected: CONTEXT_ALLOWED_CLASSIFICATIONS.join('|') },
123
+ hintKey: 'doctor.context_classification_value_hint'
124
+ });
125
+ }
126
+
127
+ if (
128
+ Object.prototype.hasOwnProperty.call(data, 'project_type') &&
129
+ !CONTEXT_ALLOWED_PROJECT_TYPES.includes(String(data.project_type))
130
+ ) {
131
+ issues.push({
132
+ id: 'context:project_type:value',
133
+ key: 'doctor.context_project_type_value',
134
+ params: { expected: CONTEXT_ALLOWED_PROJECT_TYPES.join('|') },
135
+ hintKey: 'doctor.context_project_type_value_hint'
136
+ });
137
+ }
138
+
139
+ if (
140
+ Object.prototype.hasOwnProperty.call(data, 'profile') &&
141
+ !CONTEXT_ALLOWED_PROFILES.includes(String(data.profile))
142
+ ) {
143
+ issues.push({
144
+ id: 'context:profile:value',
145
+ key: 'doctor.context_profile_value',
146
+ params: { expected: CONTEXT_ALLOWED_PROFILES.join('|') },
147
+ hintKey: 'doctor.context_profile_value_hint'
148
+ });
149
+ }
150
+
151
+ if (
152
+ Object.prototype.hasOwnProperty.call(data, 'conversation_language') &&
153
+ !isValidLanguageTag(data.conversation_language)
154
+ ) {
155
+ issues.push({
156
+ id: 'context:conversation_language:format',
157
+ key: 'doctor.context_conversation_language_format',
158
+ params: {},
159
+ hintKey: 'doctor.context_conversation_language_format_hint'
160
+ });
161
+ }
162
+
163
+ return issues;
164
+ }
165
+
166
+ async function validateProjectContextFile(targetDir) {
167
+ const filePath = path.join(targetDir, '.aioson/context/project.context.md');
168
+ if (!(await exists(filePath))) {
169
+ return {
170
+ exists: false,
171
+ parsed: false,
172
+ valid: false,
173
+ filePath,
174
+ data: null,
175
+ issues: []
176
+ };
177
+ }
178
+
179
+ const content = await fs.readFile(filePath, 'utf8');
180
+ const parsed = parseYamlFrontmatter(content);
181
+ if (!parsed.ok) {
182
+ return {
183
+ exists: true,
184
+ parsed: false,
185
+ valid: false,
186
+ filePath,
187
+ data: null,
188
+ parseError: parsed.reason,
189
+ issues: [
190
+ {
191
+ id: 'context:frontmatter:invalid',
192
+ key: 'doctor.context_frontmatter_invalid',
193
+ params: { reason: parsed.reason },
194
+ hintKey: 'doctor.context_frontmatter_invalid_hint'
195
+ }
196
+ ]
197
+ };
198
+ }
199
+
200
+ const issues = validateContextData(parsed.data);
201
+ return {
202
+ exists: true,
203
+ parsed: true,
204
+ valid: issues.length === 0,
205
+ filePath,
206
+ data: parsed.data,
207
+ issues
208
+ };
209
+ }
210
+
211
+ module.exports = {
212
+ parseYamlFrontmatter,
213
+ validateContextData,
214
+ validateProjectContextFile,
215
+ isValidLanguageTag
216
+ };
217
+
@@ -0,0 +1,261 @@
1
+ 'use strict';
2
+
3
+ const path = require('node:path');
4
+ const { exists, readTextIfExists } = require('./utils');
5
+
6
+ function safeJsonParse(input) {
7
+ try {
8
+ return JSON.parse(input);
9
+ } catch {
10
+ return null;
11
+ }
12
+ }
13
+
14
+ function dependencyExists(pkg, names) {
15
+ if (!pkg) return false;
16
+ const sections = [
17
+ pkg.require || {},
18
+ pkg['require-dev'] || {},
19
+ pkg.dependencies || {},
20
+ pkg.devDependencies || {},
21
+ pkg.peerDependencies || {},
22
+ pkg.optionalDependencies || {}
23
+ ];
24
+
25
+ return sections.some((section) => names.some((name) => Object.prototype.hasOwnProperty.call(section, name)));
26
+ }
27
+
28
+ function includesToken(text, token) {
29
+ if (!text) return false;
30
+ return text.toLowerCase().includes(token.toLowerCase());
31
+ }
32
+
33
+ async function detectFramework(projectDir) {
34
+ const checks = [];
35
+
36
+ const packageJsonPath = path.join(projectDir, 'package.json');
37
+ const composerJsonPath = path.join(projectDir, 'composer.json');
38
+ const gemfilePath = path.join(projectDir, 'Gemfile');
39
+ const requirementsPath = path.join(projectDir, 'requirements.txt');
40
+ const pyprojectPath = path.join(projectDir, 'pyproject.toml');
41
+ const cargoTomlPath = path.join(projectDir, 'Cargo.toml');
42
+
43
+ const [packageText, composerText, gemfileText, requirementsText, pyprojectText, cargoTomlText] = await Promise.all([
44
+ readTextIfExists(packageJsonPath),
45
+ readTextIfExists(composerJsonPath),
46
+ readTextIfExists(gemfilePath),
47
+ readTextIfExists(requirementsPath),
48
+ readTextIfExists(pyprojectPath),
49
+ readTextIfExists(cargoTomlPath)
50
+ ]);
51
+
52
+ const packageJson = safeJsonParse(packageText || '');
53
+ const composerJson = safeJsonParse(composerText || '');
54
+
55
+ const hasArtisan = await exists(path.join(projectDir, 'artisan'));
56
+ const hasLaravelComposer = dependencyExists(composerJson, ['laravel/framework']);
57
+ if (hasArtisan || hasLaravelComposer) {
58
+ checks.push({ framework: 'Laravel', installed: true, evidence: hasArtisan ? 'artisan' : 'composer.json:laravel/framework', confidence: 'high' });
59
+ }
60
+
61
+ const hasCodeIgniter4Spark = await exists(path.join(projectDir, 'spark'));
62
+ const hasCodeIgniter4AppConfig = await exists(path.join(projectDir, 'app/Config/App.php'));
63
+ const hasCodeIgniter4Composer = dependencyExists(composerJson, ['codeigniter4/framework']);
64
+ if (hasCodeIgniter4Spark || hasCodeIgniter4AppConfig || hasCodeIgniter4Composer) {
65
+ checks.push({
66
+ framework: 'CodeIgniter 4',
67
+ installed: true,
68
+ evidence: hasCodeIgniter4Spark
69
+ ? 'spark'
70
+ : hasCodeIgniter4AppConfig
71
+ ? 'app/Config/App.php'
72
+ : 'composer.json:codeigniter4/framework',
73
+ confidence: hasCodeIgniter4Spark || hasCodeIgniter4AppConfig ? 'high' : 'medium'
74
+ });
75
+ }
76
+
77
+ const hasCodeIgniter3Core = await exists(path.join(projectDir, 'system/core/CodeIgniter.php'));
78
+ const hasCodeIgniter3Config = await exists(path.join(projectDir, 'application/config/config.php'));
79
+ if (hasCodeIgniter3Core || hasCodeIgniter3Config) {
80
+ checks.push({
81
+ framework: 'CodeIgniter 3',
82
+ installed: true,
83
+ evidence: hasCodeIgniter3Core ? 'system/core/CodeIgniter.php' : 'application/config/config.php',
84
+ confidence: 'high'
85
+ });
86
+ }
87
+
88
+ const hasSymfonyConsole = await exists(path.join(projectDir, 'bin/console'));
89
+ const hasSymfonyComposer = dependencyExists(composerJson, ['symfony/framework-bundle']);
90
+ if (hasSymfonyConsole || hasSymfonyComposer) {
91
+ checks.push({ framework: 'Symfony', installed: true, evidence: hasSymfonyConsole ? 'bin/console' : 'composer.json:symfony/framework-bundle', confidence: 'high' });
92
+ }
93
+
94
+ const hasRailsApp = await exists(path.join(projectDir, 'config/application.rb'));
95
+ const hasRailsGem = includesToken(gemfileText, 'gem "rails"') || includesToken(gemfileText, "gem 'rails'");
96
+ if (hasRailsApp || hasRailsGem) {
97
+ checks.push({ framework: 'Rails', installed: true, evidence: hasRailsApp ? 'config/application.rb' : 'Gemfile:rails', confidence: hasRailsApp ? 'high' : 'medium' });
98
+ }
99
+
100
+ const hasManagePy = await exists(path.join(projectDir, 'manage.py'));
101
+ const hasDjangoReq = includesToken(requirementsText, 'django');
102
+ const hasDjangoPyproject = includesToken(pyprojectText, 'django');
103
+ if (hasManagePy || hasDjangoReq || hasDjangoPyproject) {
104
+ checks.push({ framework: 'Django', installed: true, evidence: hasManagePy ? 'manage.py' : hasDjangoReq ? 'requirements.txt:django' : 'pyproject.toml:django', confidence: hasManagePy ? 'high' : 'medium' });
105
+ }
106
+
107
+ const hasHardhatConfig =
108
+ (await exists(path.join(projectDir, 'hardhat.config.js'))) ||
109
+ (await exists(path.join(projectDir, 'hardhat.config.ts')));
110
+ const hasHardhatDep = dependencyExists(packageJson, ['hardhat']);
111
+ if (hasHardhatConfig || hasHardhatDep) {
112
+ checks.push({
113
+ framework: 'Hardhat',
114
+ installed: true,
115
+ evidence: hasHardhatConfig ? 'hardhat.config.*' : 'package.json:hardhat',
116
+ confidence: hasHardhatConfig ? 'high' : 'medium'
117
+ });
118
+ }
119
+
120
+ const hasFoundryToml = await exists(path.join(projectDir, 'foundry.toml'));
121
+ if (hasFoundryToml) {
122
+ checks.push({
123
+ framework: 'Foundry',
124
+ installed: true,
125
+ evidence: 'foundry.toml',
126
+ confidence: 'high'
127
+ });
128
+ }
129
+
130
+ const hasTruffleConfig =
131
+ (await exists(path.join(projectDir, 'truffle-config.js'))) ||
132
+ (await exists(path.join(projectDir, 'truffle-config.ts')));
133
+ const hasTruffleDep = dependencyExists(packageJson, ['truffle']);
134
+ if (hasTruffleConfig || hasTruffleDep) {
135
+ checks.push({
136
+ framework: 'Truffle',
137
+ installed: true,
138
+ evidence: hasTruffleConfig ? 'truffle-config.*' : 'package.json:truffle',
139
+ confidence: hasTruffleConfig ? 'high' : 'medium'
140
+ });
141
+ }
142
+
143
+ const hasAnchorToml = await exists(path.join(projectDir, 'Anchor.toml'));
144
+ const hasAnchorDep = dependencyExists(packageJson, ['@coral-xyz/anchor']);
145
+ const hasAnchorCargo = includesToken(cargoTomlText, 'anchor-lang');
146
+ if (hasAnchorToml || hasAnchorDep || hasAnchorCargo) {
147
+ checks.push({
148
+ framework: 'Anchor',
149
+ installed: true,
150
+ evidence: hasAnchorToml
151
+ ? 'Anchor.toml'
152
+ : hasAnchorDep
153
+ ? 'package.json:@coral-xyz/anchor'
154
+ : 'Cargo.toml:anchor-lang',
155
+ confidence: hasAnchorToml ? 'high' : 'medium'
156
+ });
157
+ }
158
+
159
+ const hasSolanaWeb3Dep = dependencyExists(packageJson, ['@solana/web3.js']);
160
+ if (hasSolanaWeb3Dep && !checks.some((check) => check.framework === 'Anchor')) {
161
+ checks.push({
162
+ framework: 'Solana Web3',
163
+ installed: true,
164
+ evidence: 'package.json:@solana/web3.js',
165
+ confidence: 'medium'
166
+ });
167
+ }
168
+
169
+ const hasAikenToml = await exists(path.join(projectDir, 'aiken.toml'));
170
+ const hasCardanoDep = dependencyExists(packageJson, [
171
+ 'lucid-cardano',
172
+ '@meshsdk/core',
173
+ '@cardano-ogmios/client'
174
+ ]);
175
+ if (hasAikenToml || hasCardanoDep) {
176
+ checks.push({
177
+ framework: 'Cardano',
178
+ installed: true,
179
+ evidence: hasAikenToml ? 'aiken.toml' : 'package.json:cardano dependencies',
180
+ confidence: hasAikenToml ? 'high' : 'medium'
181
+ });
182
+ }
183
+
184
+ const hasNextConfig = (await exists(path.join(projectDir, 'next.config.js'))) || (await exists(path.join(projectDir, 'next.config.ts')));
185
+ const hasNextDep = dependencyExists(packageJson, ['next']);
186
+ if (hasNextConfig || hasNextDep) {
187
+ checks.push({ framework: 'Next.js', installed: true, evidence: hasNextConfig ? 'next.config.*' : 'package.json:next', confidence: hasNextConfig ? 'high' : 'medium' });
188
+ }
189
+
190
+ const hasNuxtConfig = (await exists(path.join(projectDir, 'nuxt.config.js'))) || (await exists(path.join(projectDir, 'nuxt.config.ts')));
191
+ const hasNuxtDep = dependencyExists(packageJson, ['nuxt']);
192
+ if (hasNuxtConfig || hasNuxtDep) {
193
+ checks.push({ framework: 'Nuxt', installed: true, evidence: hasNuxtConfig ? 'nuxt.config.*' : 'package.json:nuxt', confidence: hasNuxtConfig ? 'high' : 'medium' });
194
+ }
195
+
196
+ const hasSvelteConfig = await exists(path.join(projectDir, 'svelte.config.js'));
197
+ const hasSvelteKitDep = dependencyExists(packageJson, ['@sveltejs/kit']);
198
+ if (hasSvelteConfig || hasSvelteKitDep) {
199
+ checks.push({ framework: 'SvelteKit', installed: true, evidence: hasSvelteConfig ? 'svelte.config.js' : 'package.json:@sveltejs/kit', confidence: hasSvelteConfig ? 'high' : 'medium' });
200
+ }
201
+
202
+ const hasRemixConfig = (await exists(path.join(projectDir, 'remix.config.js'))) || (await exists(path.join(projectDir, 'remix.config.ts')));
203
+ const hasRemixDep = dependencyExists(packageJson, ['@remix-run/react', '@remix-run/node']);
204
+ if (hasRemixConfig || hasRemixDep) {
205
+ checks.push({ framework: 'Remix', installed: true, evidence: hasRemixConfig ? 'remix.config.*' : 'package.json:@remix-run/*', confidence: hasRemixConfig ? 'high' : 'medium' });
206
+ }
207
+
208
+ const hasAdonisAce = await exists(path.join(projectDir, 'ace'));
209
+ const hasAdonisDep = dependencyExists(packageJson, ['@adonisjs/core']);
210
+ if (hasAdonisAce || hasAdonisDep) {
211
+ checks.push({ framework: 'AdonisJS', installed: true, evidence: hasAdonisAce ? 'ace' : 'package.json:@adonisjs/core', confidence: hasAdonisAce ? 'high' : 'medium' });
212
+ }
213
+
214
+ const hasNodePackage = await exists(packageJsonPath);
215
+ if (checks.length === 0 && hasNodePackage) {
216
+ checks.push({ framework: 'Node', installed: true, evidence: 'package.json', confidence: 'low' });
217
+ }
218
+
219
+ if (checks.length === 0) {
220
+ return {
221
+ framework: null,
222
+ installed: false,
223
+ evidence: null,
224
+ confidence: 'none',
225
+ matches: []
226
+ };
227
+ }
228
+
229
+ return {
230
+ framework: checks[0].framework,
231
+ installed: true,
232
+ evidence: checks[0].evidence,
233
+ confidence: checks[0].confidence,
234
+ matches: checks
235
+ };
236
+ }
237
+
238
+ const WEB3_FRAMEWORKS = new Set(['Hardhat', 'Foundry', 'Truffle', 'Anchor', 'Solana Web3', 'Cardano']);
239
+ const BACKEND_FRAMEWORKS = new Set(['Laravel', 'Rails', 'Django', 'Symfony', 'AdonisJS', 'CodeIgniter 4', 'CodeIgniter 3']);
240
+ const FRONTEND_FRAMEWORKS = new Set(['Next.js', 'Nuxt', 'SvelteKit', 'Remix']);
241
+
242
+ /**
243
+ * Returns true when detection found both a Web3 framework and a backend or
244
+ * frontend framework in the same directory — typical of monorepos that bundle
245
+ * smart contracts alongside a web application.
246
+ */
247
+ function isMonorepoDetection(detection) {
248
+ if (!detection || !Array.isArray(detection.matches) || detection.matches.length < 2) return false;
249
+ const names = detection.matches.map((m) => m.framework);
250
+ const hasWeb3 = names.some((n) => WEB3_FRAMEWORKS.has(n));
251
+ const hasBackend = names.some((n) => BACKEND_FRAMEWORKS.has(n));
252
+ const hasFrontend = names.some((n) => FRONTEND_FRAMEWORKS.has(n));
253
+ return hasWeb3 && (hasBackend || hasFrontend);
254
+ }
255
+
256
+ module.exports = {
257
+ detectFramework,
258
+ isMonorepoDetection,
259
+ safeJsonParse,
260
+ dependencyExists
261
+ };