trinity-method-sdk 2.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 (191) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/LICENSE +21 -0
  3. package/README.md +555 -0
  4. package/dist/cli/commands/deploy/agents.d.ts +14 -0
  5. package/dist/cli/commands/deploy/agents.js +59 -0
  6. package/dist/cli/commands/deploy/ci-cd.d.ts +13 -0
  7. package/dist/cli/commands/deploy/ci-cd.js +50 -0
  8. package/dist/cli/commands/deploy/claude-setup.d.ts +17 -0
  9. package/dist/cli/commands/deploy/claude-setup.js +91 -0
  10. package/dist/cli/commands/deploy/configuration.d.ts +13 -0
  11. package/dist/cli/commands/deploy/configuration.js +215 -0
  12. package/dist/cli/commands/deploy/directories.d.ts +12 -0
  13. package/dist/cli/commands/deploy/directories.js +38 -0
  14. package/dist/cli/commands/deploy/gitignore.d.ts +12 -0
  15. package/dist/cli/commands/deploy/gitignore.js +53 -0
  16. package/dist/cli/commands/deploy/index.d.ts +38 -0
  17. package/dist/cli/commands/deploy/index.js +156 -0
  18. package/dist/cli/commands/deploy/knowledge-base.d.ts +16 -0
  19. package/dist/cli/commands/deploy/knowledge-base.js +75 -0
  20. package/dist/cli/commands/deploy/linting.d.ts +18 -0
  21. package/dist/cli/commands/deploy/linting.js +51 -0
  22. package/dist/cli/commands/deploy/metrics.d.ts +13 -0
  23. package/dist/cli/commands/deploy/metrics.js +34 -0
  24. package/dist/cli/commands/deploy/pre-flight.d.ts +13 -0
  25. package/dist/cli/commands/deploy/pre-flight.js +29 -0
  26. package/dist/cli/commands/deploy/root-files.d.ts +16 -0
  27. package/dist/cli/commands/deploy/root-files.js +178 -0
  28. package/dist/cli/commands/deploy/sdk-install.d.ts +12 -0
  29. package/dist/cli/commands/deploy/sdk-install.js +57 -0
  30. package/dist/cli/commands/deploy/summary.d.ts +14 -0
  31. package/dist/cli/commands/deploy/summary.js +130 -0
  32. package/dist/cli/commands/deploy/templates.d.ts +14 -0
  33. package/dist/cli/commands/deploy/templates.js +84 -0
  34. package/dist/cli/commands/deploy/types.d.ts +39 -0
  35. package/dist/cli/commands/deploy/types.js +5 -0
  36. package/dist/cli/commands/update/agents.d.ts +14 -0
  37. package/dist/cli/commands/update/agents.js +31 -0
  38. package/dist/cli/commands/update/backup.d.ts +31 -0
  39. package/dist/cli/commands/update/backup.js +97 -0
  40. package/dist/cli/commands/update/commands.d.ts +14 -0
  41. package/dist/cli/commands/update/commands.js +75 -0
  42. package/dist/cli/commands/update/index.d.ts +15 -0
  43. package/dist/cli/commands/update/index.js +118 -0
  44. package/dist/cli/commands/update/knowledge-base.d.ts +14 -0
  45. package/dist/cli/commands/update/knowledge-base.js +38 -0
  46. package/dist/cli/commands/update/pre-flight.d.ts +13 -0
  47. package/dist/cli/commands/update/pre-flight.js +37 -0
  48. package/dist/cli/commands/update/summary.d.ts +20 -0
  49. package/dist/cli/commands/update/summary.js +47 -0
  50. package/dist/cli/commands/update/templates.d.ts +14 -0
  51. package/dist/cli/commands/update/templates.js +25 -0
  52. package/dist/cli/commands/update/types.d.ts +13 -0
  53. package/dist/cli/commands/update/types.js +7 -0
  54. package/dist/cli/commands/update/utils.d.ts +11 -0
  55. package/dist/cli/commands/update/utils.js +19 -0
  56. package/dist/cli/commands/update/verification.d.ts +20 -0
  57. package/dist/cli/commands/update/verification.js +54 -0
  58. package/dist/cli/commands/update/version.d.ts +18 -0
  59. package/dist/cli/commands/update/version.js +36 -0
  60. package/dist/cli/commands/update.d.ts +7 -0
  61. package/dist/cli/commands/update.js +7 -0
  62. package/dist/cli/index.d.ts +3 -0
  63. package/dist/cli/index.js +36 -0
  64. package/dist/cli/types.d.ts +77 -0
  65. package/dist/cli/types.js +5 -0
  66. package/dist/cli/utils/deploy-ci.d.ts +22 -0
  67. package/dist/cli/utils/deploy-ci.js +138 -0
  68. package/dist/cli/utils/deploy-linting.d.ts +3 -0
  69. package/dist/cli/utils/deploy-linting.js +136 -0
  70. package/dist/cli/utils/detect-stack.d.ts +3 -0
  71. package/dist/cli/utils/detect-stack.js +270 -0
  72. package/dist/cli/utils/error-classes.d.ts +63 -0
  73. package/dist/cli/utils/error-classes.js +84 -0
  74. package/dist/cli/utils/error-handler.d.ts +59 -0
  75. package/dist/cli/utils/error-handler.js +127 -0
  76. package/dist/cli/utils/errors.d.ts +52 -0
  77. package/dist/cli/utils/errors.js +102 -0
  78. package/dist/cli/utils/get-sdk-path.d.ts +18 -0
  79. package/dist/cli/utils/get-sdk-path.js +31 -0
  80. package/dist/cli/utils/inject-dependencies.d.ts +2 -0
  81. package/dist/cli/utils/inject-dependencies.js +55 -0
  82. package/dist/cli/utils/linting-tools.d.ts +8 -0
  83. package/dist/cli/utils/linting-tools.js +206 -0
  84. package/dist/cli/utils/metrics/code-quality.d.ts +32 -0
  85. package/dist/cli/utils/metrics/code-quality.js +122 -0
  86. package/dist/cli/utils/metrics/dependency-parser.d.ts +21 -0
  87. package/dist/cli/utils/metrics/dependency-parser.js +153 -0
  88. package/dist/cli/utils/metrics/file-complexity.d.ts +26 -0
  89. package/dist/cli/utils/metrics/file-complexity.js +77 -0
  90. package/dist/cli/utils/metrics/framework-detector.d.ts +17 -0
  91. package/dist/cli/utils/metrics/framework-detector.js +120 -0
  92. package/dist/cli/utils/metrics/git-metrics.d.ts +30 -0
  93. package/dist/cli/utils/metrics/git-metrics.js +83 -0
  94. package/dist/cli/utils/metrics/index.d.ts +28 -0
  95. package/dist/cli/utils/metrics/index.js +100 -0
  96. package/dist/cli/utils/template-processor.d.ts +10 -0
  97. package/dist/cli/utils/template-processor.js +188 -0
  98. package/dist/cli/utils/validate-path.d.ts +80 -0
  99. package/dist/cli/utils/validate-path.js +180 -0
  100. package/dist/index.d.ts +6 -0
  101. package/dist/index.js +8 -0
  102. package/dist/templates/agents/aj-team/apo-documentation-specialist.md.template +572 -0
  103. package/dist/templates/agents/aj-team/bas-quality-gate.md.template +906 -0
  104. package/dist/templates/agents/aj-team/bon-dependency-manager.md.template +636 -0
  105. package/dist/templates/agents/aj-team/cap-configuration-specialist.md.template +670 -0
  106. package/dist/templates/agents/aj-team/dra-code-reviewer.md.template +768 -0
  107. package/dist/templates/agents/aj-team/kil-task-executor.md.template +764 -0
  108. package/dist/templates/agents/aj-team/uro-refactoring-specialist.md.template +759 -0
  109. package/dist/templates/agents/audit/juno-auditor.md.template +447 -0
  110. package/dist/templates/agents/deployment/ein-cicd.md.template +694 -0
  111. package/dist/templates/agents/deployment/ino-context.md.template +733 -0
  112. package/dist/templates/agents/deployment/tan-structure.md.template +661 -0
  113. package/dist/templates/agents/deployment/zen-knowledge.md.template +451 -0
  114. package/dist/templates/agents/leadership/aj-cc.md.template +462 -0
  115. package/dist/templates/agents/leadership/aj-maestro.md.template +943 -0
  116. package/dist/templates/agents/leadership/aly-cto.md.template +407 -0
  117. package/dist/templates/agents/planning/eus-decomposer.md.template +496 -0
  118. package/dist/templates/agents/planning/mon-requirements.md.template +323 -0
  119. package/dist/templates/agents/planning/ror-design.md.template +465 -0
  120. package/dist/templates/agents/planning/tra-planner.md.template +432 -0
  121. package/dist/templates/ci/cd.yml.template +175 -0
  122. package/dist/templates/ci/ci.yml.template +196 -0
  123. package/dist/templates/ci/generic-ci.yml +115 -0
  124. package/dist/templates/ci/github-actions.yml +86 -0
  125. package/dist/templates/ci/gitlab-ci.yml +103 -0
  126. package/dist/templates/claude/EMPLOYEE-DIRECTORY.md.template +545 -0
  127. package/dist/templates/documentation/ROOT-README.md.template +307 -0
  128. package/dist/templates/documentation/SUBDIRECTORY-README.md.template +261 -0
  129. package/dist/templates/investigations/bug.md.template +484 -0
  130. package/dist/templates/investigations/feature.md.template +564 -0
  131. package/dist/templates/investigations/performance.md.template +625 -0
  132. package/dist/templates/investigations/security.md.template +714 -0
  133. package/dist/templates/investigations/technical.md.template +433 -0
  134. package/dist/templates/knowledge-base/AI-DEVELOPMENT-GUIDE.md.template +957 -0
  135. package/dist/templates/knowledge-base/ARCHITECTURE.md.template +452 -0
  136. package/dist/templates/knowledge-base/CODING-PRINCIPLES.md.template +750 -0
  137. package/dist/templates/knowledge-base/DOCUMENTATION-CRITERIA.md.template +1118 -0
  138. package/dist/templates/knowledge-base/ISSUES.md.template +539 -0
  139. package/dist/templates/knowledge-base/TESTING-PRINCIPLES.md.template +894 -0
  140. package/dist/templates/knowledge-base/Technical-Debt.md.template +640 -0
  141. package/dist/templates/knowledge-base/To-do.md.template +407 -0
  142. package/dist/templates/knowledge-base/Trinity.md.template +464 -0
  143. package/dist/templates/linting/flutter/.pre-commit-config.yaml.template +27 -0
  144. package/dist/templates/linting/flutter/analysis_options.yaml.template +26 -0
  145. package/dist/templates/linting/nodejs/.eslintrc-commonjs.json.template +19 -0
  146. package/dist/templates/linting/nodejs/.eslintrc-esm.json.template +19 -0
  147. package/dist/templates/linting/nodejs/.eslintrc-typescript.json.template +22 -0
  148. package/dist/templates/linting/nodejs/.pre-commit-config.yaml.template +51 -0
  149. package/dist/templates/linting/nodejs/.prettierrc.json.template +10 -0
  150. package/dist/templates/linting/python/.flake8.template +16 -0
  151. package/dist/templates/linting/python/.pre-commit-config.yaml.template +30 -0
  152. package/dist/templates/linting/python/pyproject.toml.template +38 -0
  153. package/dist/templates/linting/rust/.pre-commit-config.yaml.template +28 -0
  154. package/dist/templates/linting/rust/clippy.toml.template +14 -0
  155. package/dist/templates/linting/rust/rustfmt.toml.template +12 -0
  156. package/dist/templates/root/CLAUDE.md.template +65 -0
  157. package/dist/templates/root/TRINITY.md.template +52 -0
  158. package/dist/templates/shared/claude-commands/trinity-agents.md.template +168 -0
  159. package/dist/templates/shared/claude-commands/trinity-audit.md.template +646 -0
  160. package/dist/templates/shared/claude-commands/trinity-changelog.md.template +624 -0
  161. package/dist/templates/shared/claude-commands/trinity-continue.md.template +549 -0
  162. package/dist/templates/shared/claude-commands/trinity-create-investigation.md.template +232 -0
  163. package/dist/templates/shared/claude-commands/trinity-decompose.md.template +181 -0
  164. package/dist/templates/shared/claude-commands/trinity-design.md.template +347 -0
  165. package/dist/templates/shared/claude-commands/trinity-docs.md.template +2093 -0
  166. package/dist/templates/shared/claude-commands/trinity-end.md.template +397 -0
  167. package/dist/templates/shared/claude-commands/trinity-init.md.template +606 -0
  168. package/dist/templates/shared/claude-commands/trinity-investigate-templates.md.template +725 -0
  169. package/dist/templates/shared/claude-commands/trinity-orchestrate.md.template +1061 -0
  170. package/dist/templates/shared/claude-commands/trinity-plan-investigation.md.template +135 -0
  171. package/dist/templates/shared/claude-commands/trinity-plan.md.template +201 -0
  172. package/dist/templates/shared/claude-commands/trinity-readme.md.template +1971 -0
  173. package/dist/templates/shared/claude-commands/trinity-requirements.md.template +148 -0
  174. package/dist/templates/shared/claude-commands/trinity-start.md.template +268 -0
  175. package/dist/templates/shared/claude-commands/trinity-verify.md.template +453 -0
  176. package/dist/templates/shared/claude-commands/trinity-workorder.md.template +249 -0
  177. package/dist/templates/source/base-CLAUDE.md.template +310 -0
  178. package/dist/templates/source/flutter-CLAUDE.md.template +593 -0
  179. package/dist/templates/source/nodejs-CLAUDE.md.template +531 -0
  180. package/dist/templates/source/python-CLAUDE.md.template +510 -0
  181. package/dist/templates/source/react-CLAUDE.md.template +513 -0
  182. package/dist/templates/source/rust-CLAUDE.md.template +653 -0
  183. package/dist/templates/source/tests-CLAUDE.md.template +432 -0
  184. package/dist/templates/trinity/CLAUDE.md.template +372 -0
  185. package/dist/templates/work-orders/ANALYSIS-TEMPLATE.md.template +276 -0
  186. package/dist/templates/work-orders/AUDIT-TEMPLATE.md.template +262 -0
  187. package/dist/templates/work-orders/IMPLEMENTATION-TEMPLATE.md.template +260 -0
  188. package/dist/templates/work-orders/INVESTIGATION-TEMPLATE.md.template +206 -0
  189. package/dist/templates/work-orders/PATTERN-TEMPLATE.md.template +320 -0
  190. package/dist/templates/work-orders/VERIFICATION-TEMPLATE.md.template +273 -0
  191. package/package.json +94 -0
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CLI Command Option Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,22 @@
1
+ interface CIDeploymentStats {
2
+ deployed: string[];
3
+ skipped: string[];
4
+ errors: Array<{
5
+ file?: string;
6
+ error?: string;
7
+ general?: string;
8
+ }>;
9
+ }
10
+ interface CIDeployOptions {
11
+ yes?: boolean;
12
+ force?: boolean;
13
+ }
14
+ /**
15
+ * Deploy CI/CD workflow templates based on detected Git platform
16
+ *
17
+ * @param options - Deployment options
18
+ * @returns Deployment results with statistics
19
+ */
20
+ export declare function deployCITemplates(options?: CIDeployOptions): Promise<CIDeploymentStats>;
21
+ export {};
22
+ //# sourceMappingURL=deploy-ci.d.ts.map
@@ -0,0 +1,138 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname } from 'path';
5
+ import { validatePath } from './validate-path.js';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ /**
9
+ * Deploy GitLab CI template
10
+ * @param templatesPath - Path to templates directory
11
+ * @param options - Deployment options
12
+ * @param stats - Statistics object to update
13
+ */
14
+ async function deployGitLabCI(templatesPath, options, stats) {
15
+ try {
16
+ const gitlabTemplate = path.join(templatesPath, 'gitlab-ci.yml');
17
+ if (!(await fs.pathExists(gitlabTemplate))) {
18
+ return;
19
+ }
20
+ const content = await fs.readFile(gitlabTemplate, 'utf8');
21
+ const gitlabCIExists = await fs.pathExists('.gitlab-ci.yml');
22
+ if (gitlabCIExists && !options.force) {
23
+ stats.skipped.push('.gitlab-ci.yml (already exists)');
24
+ return;
25
+ }
26
+ // Validate destination path for security
27
+ const destPath = validatePath('.gitlab-ci.yml');
28
+ await fs.writeFile(destPath, content);
29
+ stats.deployed.push('.gitlab-ci.yml');
30
+ }
31
+ catch (error) {
32
+ const { getErrorMessage } = await import('./errors.js');
33
+ stats.errors.push({ file: '.gitlab-ci.yml', error: getErrorMessage(error) });
34
+ }
35
+ }
36
+ /**
37
+ * Deploy CI/CD workflow templates based on detected Git platform
38
+ *
39
+ * @param options - Deployment options
40
+ * @returns Deployment results with statistics
41
+ */
42
+ export async function deployCITemplates(options = {}) {
43
+ const stats = {
44
+ deployed: [],
45
+ skipped: [],
46
+ errors: [],
47
+ };
48
+ try {
49
+ // Detect Git platform
50
+ const platform = await detectGitPlatform();
51
+ const templatesPath = path.join(__dirname, '../../templates/ci');
52
+ // GitHub Actions - Deploy both CI and CD workflows
53
+ if (platform === 'github' || platform === 'unknown') {
54
+ try {
55
+ await fs.ensureDir('.github/workflows');
56
+ // Deploy CI workflow
57
+ const ciTemplate = path.join(templatesPath, 'ci.yml.template');
58
+ if (await fs.pathExists(ciTemplate)) {
59
+ const content = await fs.readFile(ciTemplate, 'utf8');
60
+ // Validate destination path for security
61
+ const destPath = validatePath('.github/workflows/ci.yml');
62
+ await fs.writeFile(destPath, content);
63
+ stats.deployed.push('.github/workflows/ci.yml');
64
+ }
65
+ // Deploy CD workflow
66
+ const cdTemplate = path.join(templatesPath, 'cd.yml.template');
67
+ if (await fs.pathExists(cdTemplate)) {
68
+ const content = await fs.readFile(cdTemplate, 'utf8');
69
+ // Validate destination path for security
70
+ const destPath = validatePath('.github/workflows/cd.yml');
71
+ await fs.writeFile(destPath, content);
72
+ stats.deployed.push('.github/workflows/cd.yml');
73
+ }
74
+ }
75
+ catch (error) {
76
+ const { getErrorMessage } = await import('./errors.js');
77
+ stats.errors.push({
78
+ file: '.github/workflows/ci.yml or cd.yml',
79
+ error: getErrorMessage(error),
80
+ });
81
+ }
82
+ }
83
+ // GitLab CI
84
+ if (platform === 'gitlab') {
85
+ await deployGitLabCI(templatesPath, options, stats);
86
+ }
87
+ // Generic template (always deploy to trinity/templates/ci)
88
+ try {
89
+ await fs.ensureDir('trinity/templates/ci');
90
+ const genericTemplate = path.join(templatesPath, 'generic-ci.yml');
91
+ if (await fs.pathExists(genericTemplate)) {
92
+ const content = await fs.readFile(genericTemplate, 'utf8');
93
+ // Validate destination path for security
94
+ const destPath = validatePath('trinity/templates/ci/generic-ci.yml');
95
+ await fs.writeFile(destPath, content);
96
+ stats.deployed.push('trinity/templates/ci/generic-ci.yml');
97
+ }
98
+ }
99
+ catch (error) {
100
+ const { getErrorMessage } = await import('./errors.js');
101
+ stats.errors.push({
102
+ file: 'trinity/templates/ci/generic-ci.yml',
103
+ error: getErrorMessage(error),
104
+ });
105
+ }
106
+ return stats;
107
+ }
108
+ catch (error) {
109
+ const { getErrorMessage } = await import('./errors.js');
110
+ stats.errors.push({ general: getErrorMessage(error) });
111
+ return stats;
112
+ }
113
+ }
114
+ /**
115
+ * Detect Git platform (GitHub, GitLab, or unknown)
116
+ *
117
+ * @returns Platform name: 'github', 'gitlab', or 'unknown'
118
+ */
119
+ async function detectGitPlatform() {
120
+ try {
121
+ // Check .git/config for remote origin
122
+ const gitConfigPath = '.git/config';
123
+ if (await fs.pathExists(gitConfigPath)) {
124
+ const config = await fs.readFile(gitConfigPath, 'utf8');
125
+ if (config.includes('github.com')) {
126
+ return 'github';
127
+ }
128
+ if (config.includes('gitlab.com') || config.includes('gitlab')) {
129
+ return 'gitlab';
130
+ }
131
+ }
132
+ return 'unknown';
133
+ }
134
+ catch {
135
+ return 'unknown';
136
+ }
137
+ }
138
+ //# sourceMappingURL=deploy-ci.js.map
@@ -0,0 +1,3 @@
1
+ import { LintingTool, Stack } from '../types.js';
2
+ export declare function deployLintingTool(tool: LintingTool, stack: Stack, templatesPath: string, variables: Record<string, string | number>): Promise<void>;
3
+ //# sourceMappingURL=deploy-linting.d.ts.map
@@ -0,0 +1,136 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { processTemplate } from './template-processor.js';
4
+ import { validatePath } from './validate-path.js';
5
+ export async function deployLintingTool(tool, stack, templatesPath, variables) {
6
+ const frameworkDir = getFrameworkDirectory(stack.framework);
7
+ const templateDir = path.join(templatesPath, 'linting', frameworkDir);
8
+ switch (tool.id) {
9
+ case 'eslint':
10
+ case 'eslint-typescript': // Alias for eslint with TypeScript (backward compatibility)
11
+ await deployESLint(tool, stack, templateDir, variables);
12
+ break;
13
+ case 'prettier':
14
+ await deployPrettier(tool, templateDir, variables);
15
+ break;
16
+ case 'precommit':
17
+ await deployPreCommit(tool, templateDir, variables);
18
+ break;
19
+ case 'typescript-eslint':
20
+ await deployTypeScriptESLint(tool, stack, templateDir, variables);
21
+ break;
22
+ case 'black':
23
+ case 'flake8':
24
+ case 'isort':
25
+ await deployPythonTool(tool, templateDir, variables);
26
+ break;
27
+ case 'dartanalyzer':
28
+ await deployDartAnalyzer(tool, templateDir, variables);
29
+ break;
30
+ case 'clippy':
31
+ case 'rustfmt':
32
+ await deployRustTool(tool, templateDir, variables);
33
+ break;
34
+ default:
35
+ console.warn(`Unknown linting tool: ${tool.id}`);
36
+ }
37
+ }
38
+ function getFrameworkDirectory(framework) {
39
+ const frameworkMap = {
40
+ 'Node.js': 'nodejs',
41
+ React: 'nodejs',
42
+ 'Next.js': 'nodejs',
43
+ Python: 'python',
44
+ Flutter: 'flutter',
45
+ Rust: 'rust',
46
+ };
47
+ return frameworkMap[framework] || 'nodejs';
48
+ }
49
+ async function deployESLint(tool, stack, templateDir, variables) {
50
+ let templateFile;
51
+ if (stack.language === 'TypeScript') {
52
+ templateFile = '.eslintrc-typescript.json.template';
53
+ }
54
+ else if ('moduleType' in stack && stack.moduleType === 'esm') {
55
+ templateFile = '.eslintrc-esm.json.template';
56
+ }
57
+ else {
58
+ templateFile = '.eslintrc-commonjs.json.template';
59
+ }
60
+ const templatePath = path.join(templateDir, templateFile);
61
+ const content = await fs.readFile(templatePath, 'utf8');
62
+ const processed = processTemplate(content, variables);
63
+ // Validate destination path for security
64
+ const destPath = validatePath('.eslintrc.json');
65
+ await fs.writeFile(destPath, processed);
66
+ }
67
+ async function deployPrettier(tool, templateDir, variables) {
68
+ const templatePath = path.join(templateDir, '.prettierrc.json.template');
69
+ const content = await fs.readFile(templatePath, 'utf8');
70
+ const processed = processTemplate(content, variables);
71
+ // Validate destination path for security
72
+ const destPath = validatePath('.prettierrc.json');
73
+ await fs.writeFile(destPath, processed);
74
+ }
75
+ async function deployPreCommit(tool, templateDir, variables) {
76
+ const templatePath = path.join(templateDir, '.pre-commit-config.yaml.template');
77
+ const content = await fs.readFile(templatePath, 'utf8');
78
+ const processed = processTemplate(content, variables);
79
+ // Validate destination path for security
80
+ const destPath = validatePath('.pre-commit-config.yaml');
81
+ await fs.writeFile(destPath, processed);
82
+ }
83
+ async function deployTypeScriptESLint(_tool, _stack, _templateDir, _variables) {
84
+ // Modify existing .eslintrc.json to add TypeScript support
85
+ const eslintPath = '.eslintrc.json';
86
+ if (await fs.pathExists(eslintPath)) {
87
+ const config = await fs.readJson(eslintPath);
88
+ config.extends = config.extends || [];
89
+ if (!config.extends.includes('plugin:@typescript-eslint/recommended')) {
90
+ config.extends.push('plugin:@typescript-eslint/recommended');
91
+ }
92
+ config.parser = '@typescript-eslint/parser';
93
+ config.plugins = config.plugins || [];
94
+ if (!config.plugins.includes('@typescript-eslint')) {
95
+ config.plugins.push('@typescript-eslint');
96
+ }
97
+ await fs.writeJson(eslintPath, config, { spaces: 2 });
98
+ }
99
+ }
100
+ async function deployPythonTool(tool, templateDir, variables) {
101
+ if (tool.id === 'black' || tool.id === 'isort') {
102
+ // Both go in pyproject.toml
103
+ const templatePath = path.join(templateDir, 'pyproject.toml.template');
104
+ const content = await fs.readFile(templatePath, 'utf8');
105
+ const processed = processTemplate(content, variables);
106
+ // Validate destination path for security
107
+ const destPath = validatePath('pyproject.toml');
108
+ await fs.writeFile(destPath, processed);
109
+ }
110
+ else if (tool.id === 'flake8') {
111
+ const templatePath = path.join(templateDir, '.flake8.template');
112
+ const content = await fs.readFile(templatePath, 'utf8');
113
+ const processed = processTemplate(content, variables);
114
+ // Validate destination path for security
115
+ const destPath = validatePath('.flake8');
116
+ await fs.writeFile(destPath, processed);
117
+ }
118
+ }
119
+ async function deployDartAnalyzer(tool, templateDir, variables) {
120
+ const templatePath = path.join(templateDir, 'analysis_options.yaml.template');
121
+ const content = await fs.readFile(templatePath, 'utf8');
122
+ const processed = processTemplate(content, variables);
123
+ // Validate destination path for security
124
+ const destPath = validatePath('analysis_options.yaml');
125
+ await fs.writeFile(destPath, processed);
126
+ }
127
+ async function deployRustTool(tool, templateDir, variables) {
128
+ const filename = tool.id === 'clippy' ? 'clippy.toml' : 'rustfmt.toml';
129
+ const templatePath = path.join(templateDir, `${filename}.template`);
130
+ const content = await fs.readFile(templatePath, 'utf8');
131
+ const processed = processTemplate(content, variables);
132
+ // Validate destination path for security
133
+ const destPath = validatePath(filename);
134
+ await fs.writeFile(destPath, processed);
135
+ }
136
+ //# sourceMappingURL=deploy-linting.js.map
@@ -0,0 +1,3 @@
1
+ import { Stack } from '../types.js';
2
+ export declare function detectStack(targetDir?: string): Promise<Stack>;
3
+ //# sourceMappingURL=detect-stack.d.ts.map
@@ -0,0 +1,270 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ // Common source directory names
4
+ const COMMON_SOURCE_DIRS = [
5
+ 'src',
6
+ 'lib',
7
+ 'app',
8
+ 'backend',
9
+ 'frontend',
10
+ 'server',
11
+ 'client',
12
+ 'database',
13
+ 'packages',
14
+ 'apps',
15
+ ];
16
+ // Nested directory patterns (2-level and 3-level)
17
+ const NESTED_PATTERNS = [
18
+ // 2-level patterns - backend variations
19
+ ['backend', 'src'],
20
+ ['backend', 'lib'],
21
+ ['backend', 'app'],
22
+ // 2-level patterns - frontend variations
23
+ ['frontend', 'src'],
24
+ ['frontend', 'lib'],
25
+ ['frontend', 'app'],
26
+ // 2-level patterns - server/client variations
27
+ ['server', 'src'],
28
+ ['server', 'lib'],
29
+ ['server', 'app'],
30
+ ['client', 'src'],
31
+ ['client', 'lib'],
32
+ ['client', 'app'],
33
+ // 2-level patterns - src nested
34
+ ['src', 'backend'],
35
+ ['src', 'frontend'],
36
+ ['src', 'database'],
37
+ ['src', 'server'],
38
+ ['src', 'client'],
39
+ // 3-level patterns - src nested deeply
40
+ ['src', 'backend', 'src'],
41
+ ['src', 'backend', 'lib'],
42
+ ['src', 'backend', 'app'],
43
+ ['src', 'frontend', 'src'],
44
+ ['src', 'frontend', 'lib'],
45
+ ['src', 'frontend', 'app'],
46
+ ['src', 'database', 'src'],
47
+ ['src', 'database', 'lib'],
48
+ // 3-level patterns - frontend/backend with app
49
+ ['frontend', 'app', 'lib'],
50
+ ['frontend', 'app', 'src'],
51
+ ['backend', 'app', 'lib'],
52
+ ['backend', 'app', 'src'],
53
+ ['server', 'app', 'lib'],
54
+ ['server', 'app', 'src'],
55
+ ['client', 'app', 'lib'],
56
+ ['client', 'app', 'src'],
57
+ ];
58
+ /**
59
+ * Detect all source directories in the project (monorepo support)
60
+ */
61
+ async function detectSourceDirectories(targetDir) {
62
+ const foundDirs = [];
63
+ // Check top-level directories
64
+ for (const dir of COMMON_SOURCE_DIRS) {
65
+ const dirPath = path.join(targetDir, dir);
66
+ if (await exists(dirPath)) {
67
+ foundDirs.push(dir);
68
+ }
69
+ }
70
+ // Check 2-level nested patterns
71
+ for (const pattern of NESTED_PATTERNS) {
72
+ if (pattern.length === 2) {
73
+ const [parent, child] = pattern;
74
+ const fullPath = path.join(targetDir, parent, child);
75
+ if (await exists(fullPath)) {
76
+ const relativePath = `${parent}/${child}`;
77
+ if (!foundDirs.includes(relativePath)) {
78
+ foundDirs.push(relativePath);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ // Check 3-level nested patterns (also captures intermediate directories)
84
+ for (const pattern of NESTED_PATTERNS) {
85
+ if (pattern.length === 3) {
86
+ const [level1, level2, level3] = pattern;
87
+ const fullPath = path.join(targetDir, level1, level2, level3);
88
+ if (await exists(fullPath)) {
89
+ // Add the 3-level path
90
+ const deepPath = `${level1}/${level2}/${level3}`;
91
+ if (!foundDirs.includes(deepPath)) {
92
+ foundDirs.push(deepPath);
93
+ }
94
+ // Also add intermediate 2-level path
95
+ const intermediatePath = `${level1}/${level2}`;
96
+ if (!foundDirs.includes(intermediatePath)) {
97
+ foundDirs.push(intermediatePath);
98
+ }
99
+ }
100
+ }
101
+ }
102
+ return foundDirs;
103
+ }
104
+ /**
105
+ * Detect Flutter project
106
+ */
107
+ async function detectFlutter(targetDir) {
108
+ if (await exists(path.join(targetDir, 'pubspec.yaml'))) {
109
+ return {
110
+ language: 'Dart',
111
+ framework: 'Flutter',
112
+ sourceDir: 'lib',
113
+ };
114
+ }
115
+ return null;
116
+ }
117
+ /**
118
+ * Detect Rust project
119
+ */
120
+ async function detectRust(targetDir) {
121
+ if (await exists(path.join(targetDir, 'Cargo.toml'))) {
122
+ return {
123
+ language: 'Rust',
124
+ framework: 'Generic',
125
+ sourceDir: 'src',
126
+ };
127
+ }
128
+ return null;
129
+ }
130
+ /**
131
+ * Detect Go project
132
+ */
133
+ async function detectGo(targetDir) {
134
+ if (await exists(path.join(targetDir, 'go.mod'))) {
135
+ return {
136
+ language: 'Go',
137
+ framework: 'Generic',
138
+ sourceDir: '.',
139
+ };
140
+ }
141
+ return null;
142
+ }
143
+ /**
144
+ * Detect Node.js/JavaScript framework
145
+ */
146
+ async function detectNodeFramework(pkg) {
147
+ const deps = pkg.dependencies;
148
+ if (deps?.next)
149
+ return 'Next.js';
150
+ if (deps?.react)
151
+ return 'React';
152
+ if (deps?.vue)
153
+ return 'Vue';
154
+ if (deps?.['@angular/core'])
155
+ return 'Angular';
156
+ if (deps?.express)
157
+ return 'Express';
158
+ return 'Node.js';
159
+ }
160
+ /**
161
+ * Detect package manager
162
+ */
163
+ async function detectPackageManager(targetDir) {
164
+ if (await exists(path.join(targetDir, 'pnpm-lock.yaml')))
165
+ return 'pnpm';
166
+ if (await exists(path.join(targetDir, 'yarn.lock')))
167
+ return 'yarn';
168
+ return 'npm';
169
+ }
170
+ /**
171
+ * Detect Node.js project
172
+ */
173
+ async function detectNodeJs(targetDir) {
174
+ if (!(await exists(path.join(targetDir, 'package.json')))) {
175
+ return null;
176
+ }
177
+ try {
178
+ const pkgPath = path.join(targetDir, 'package.json');
179
+ const pkgContent = await fs.readFile(pkgPath, 'utf8');
180
+ const pkg = JSON.parse(pkgContent);
181
+ const framework = await detectNodeFramework(pkg);
182
+ const packageManager = await detectPackageManager(targetDir);
183
+ return {
184
+ language: 'JavaScript/TypeScript',
185
+ framework,
186
+ sourceDir: framework === 'Angular' ? 'src/app' : 'src',
187
+ packageManager,
188
+ };
189
+ }
190
+ catch (parseError) {
191
+ const { displayError, getErrorMessage } = await import('../utils/errors.js');
192
+ displayError(`Error parsing package.json: ${getErrorMessage(parseError)}`);
193
+ return null;
194
+ }
195
+ }
196
+ /**
197
+ * Detect Python project
198
+ */
199
+ async function detectPython(targetDir) {
200
+ const hasPythonFiles = (await exists(path.join(targetDir, 'requirements.txt'))) ||
201
+ (await exists(path.join(targetDir, 'setup.py'))) ||
202
+ (await exists(path.join(targetDir, 'pyproject.toml')));
203
+ if (!hasPythonFiles) {
204
+ return null;
205
+ }
206
+ let framework = 'Generic';
207
+ // Check for Flask
208
+ if (await exists(path.join(targetDir, 'requirements.txt'))) {
209
+ const reqContent = await fs.readFile(path.join(targetDir, 'requirements.txt'), 'utf8');
210
+ if (reqContent.toLowerCase().includes('flask')) {
211
+ framework = 'Flask';
212
+ }
213
+ }
214
+ return {
215
+ language: 'Python',
216
+ framework,
217
+ sourceDir: 'app',
218
+ };
219
+ }
220
+ /**
221
+ * Finalize source directories
222
+ */
223
+ function finalizeSourceDirs(result) {
224
+ if (result.sourceDirs.length === 0) {
225
+ result.sourceDirs = [result.sourceDir];
226
+ }
227
+ else if (!result.sourceDirs.includes(result.sourceDir)) {
228
+ result.sourceDir = result.sourceDirs[0];
229
+ }
230
+ }
231
+ export async function detectStack(targetDir = process.cwd()) {
232
+ const result = {
233
+ language: 'Unknown',
234
+ framework: 'Generic',
235
+ sourceDir: 'src',
236
+ sourceDirs: [],
237
+ packageManager: 'npm',
238
+ };
239
+ try {
240
+ // Detector array pattern - order matters!
241
+ // Check Flutter FIRST to avoid false positives when Trinity SDK creates package.json
242
+ const detectors = [detectFlutter, detectRust, detectGo, detectNodeJs, detectPython];
243
+ for (const detector of detectors) {
244
+ const detected = await detector(targetDir);
245
+ if (detected) {
246
+ Object.assign(result, detected);
247
+ break;
248
+ }
249
+ }
250
+ }
251
+ catch (error) {
252
+ const { displayWarning, getErrorMessage } = await import('../utils/errors.js');
253
+ displayWarning(`Error detecting stack: ${getErrorMessage(error)}`);
254
+ }
255
+ // Detect all source directories (monorepo support)
256
+ result.sourceDirs = await detectSourceDirectories(targetDir);
257
+ // Finalize source directories
258
+ finalizeSourceDirs(result);
259
+ return result;
260
+ }
261
+ async function exists(filePath) {
262
+ try {
263
+ await fs.access(filePath);
264
+ return true;
265
+ }
266
+ catch {
267
+ return false;
268
+ }
269
+ }
270
+ //# sourceMappingURL=detect-stack.js.map
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Custom error classes for Trinity CLI
3
+ * Provides domain-specific error types with codes and context
4
+ * @module cli/utils/error-classes
5
+ */
6
+ /**
7
+ * Base error class for Trinity CLI
8
+ * All custom errors extend this class
9
+ */
10
+ export declare class TrinityCLIError extends Error {
11
+ readonly code: string;
12
+ readonly exitCode: number;
13
+ readonly context?: Record<string, unknown>;
14
+ /**
15
+ * Create a Trinity CLI error
16
+ * @param message - Human-readable error message
17
+ * @param code - Error code for categorization (e.g., 'DEPLOYMENT_ERROR')
18
+ * @param exitCode - Process exit code (default: 1)
19
+ * @param context - Additional context for debugging
20
+ */
21
+ constructor(message: string, code: string, exitCode?: number, context?: Record<string, unknown>);
22
+ /**
23
+ * Format error for user display
24
+ * @returns Formatted error message with code
25
+ */
26
+ format(): string;
27
+ }
28
+ /**
29
+ * User input validation errors
30
+ * Used when user provides invalid input or options
31
+ */
32
+ export declare class ValidationError extends TrinityCLIError {
33
+ constructor(message: string, context?: Record<string, unknown>);
34
+ }
35
+ /**
36
+ * Filesystem operation errors
37
+ * Used when file/directory operations fail
38
+ */
39
+ export declare class FilesystemError extends TrinityCLIError {
40
+ constructor(message: string, context?: Record<string, unknown>);
41
+ }
42
+ /**
43
+ * Deployment errors
44
+ * Used when Trinity deployment fails
45
+ */
46
+ export declare class DeploymentError extends TrinityCLIError {
47
+ constructor(message: string, context?: Record<string, unknown>);
48
+ }
49
+ /**
50
+ * Update errors
51
+ * Used when Trinity update fails
52
+ */
53
+ export declare class UpdateError extends TrinityCLIError {
54
+ constructor(message: string, context?: Record<string, unknown>);
55
+ }
56
+ /**
57
+ * Configuration errors
58
+ * Used when configuration is invalid or missing
59
+ */
60
+ export declare class ConfigurationError extends TrinityCLIError {
61
+ constructor(message: string, context?: Record<string, unknown>);
62
+ }
63
+ //# sourceMappingURL=error-classes.d.ts.map